FMS  2024.03
Flexible Modeling System
time_interp_external2_mod

Perform I/O and time interpolation of external fields (contained in a file), using fms2_io. More...

Data Types

type  ext_fieldtype
 Represents external fields. More...
 
type  filetype
 Holds filename and file object. More...
 
interface  time_interp_external
 Provide data from external file interpolated to current model time. Data may be local to current processor or global, depending on "init_external_field" flags. Uses FMS2 IO for I/O. More...
 

Functions/Subroutines

integer function, private find_buf_index (indx, buf)
 simple linear search for given value in given list TODO should use better search if this list is bigger
 
real(r8_kind) function, public get_external_field_missing (index)
 return missing value More...
 
integer function, dimension(4), public get_external_field_size (index)
 Returns size of field after call to init_external_field. Ordering is X/Y/Z/T. This call only makes sense for non-distributed reads. More...
 
logical function, public get_external_fileobj (filename, fileobj)
 
subroutine, public get_time_axis (index, time)
 
integer function, public init_external_field (file, fieldname, domain, desired_units, verbose, axis_names, axis_sizes, override, correct_leap_year_inconsistency, permit_calendar_conversion, use_comp_domain, ierr, nwindows, ignore_axis_atts, ongrid)
 Initialize an external field. Buffer "num_io_buffers" (default=2) in memory to reduce memory allocations. distributed reads are supported using the optional "domain" flag. Units conversion via the optional "desired_units" flag using udunits_mod. More...
 
subroutine load_record (field, rec, interp, is_in, ie_in, js_in, je_in, window_id_in)
 load specified record from file Always loads in r8, casts down for horiz_interp if interp argument is already allocated for r4's.
 
subroutine load_record_0d (field, rec)
 Given a initialized ext_fieldtype and record number, loads the given index into fieldsrc_data.
 
subroutine realloc_fields (n)
 reallocates array of fields,increasing its size
 
subroutine realloc_files (n)
 reallocates array of fields, increasing its size
 
subroutine, public reset_src_data_region (index, is, ie, js, je)
 Reallocates src_data for field from module level loaded_fields array.
 
subroutine, public set_override_region (index, region_type, is_region, ie_region, js_region, je_region)
 
subroutine, private set_time_modulo (Time)
 
subroutine time_interp_external_0d_ (index, time, time_data, verbose)
 Scalar interpolation for time_interp_external.
 
subroutine time_interp_external_2d_ (index, time, data_in, interp, verbose, horz_interp, mask_out, is_in, ie_in, js_in, je_in, window_id)
 2D interpolation for time_interp_external More...
 
subroutine time_interp_external_3d_ (index, time, time_data, interp, verbose, horz_interp, mask_out, is_in, ie_in, js_in, je_in, window_id)
 3D interpolation for time_interp_external Provide data from external file interpolated to current model time. Data may be local to current processor or global, depending on "init_external_field" flags. More...
 
subroutine time_interp_external_bridge_0d_ (index1, index2, time, time_data, verbose)
 
subroutine time_interp_external_bridge_2d_ (index1, index2, time, data_in, interp, verbose, horz_interp, mask_out, is_in, ie_in, js_in, je_in, window_id)
 2D interpolation for time_interp_external_bridge More...
 
subroutine time_interp_external_bridge_3d_ (index1, index2, time, time_data, interp, verbose, horz_interp, mask_out, is_in, ie_in, js_in, je_in, window_id)
 3D interpolation for time_interp_external Provide data from external file interpolated to current model time. Data may be local to current processor or global, depending on "init_external_field" flags. More...
 
subroutine, public time_interp_external_exit ()
 exit time_interp_external_mod. Close all open files and release storage
 
subroutine, public time_interp_external_init ()
 Initialize the time_interp_external_mod module.
 

Variables

logical, private debug_this_module = .false.
 
real(r8_kind), parameter, private default_missing_value = -1e20_r8_kind
 
integer, parameter, public err_field_not_found = 1
 
integer, parameter, public inside_region =1
 
integer, parameter, private linear_time_interp = 1
 
type(ext_fieldtype), dimension(:), pointer, save, private loaded_fields => NULL()
 
integer, private max_fields = 100
 
integer, private max_files = 40
 
logical, private module_initialized = .false.
 
integer, parameter, private modulo_year = 0001
 
integer, private num_fields = 0
 
integer, private num_files =0
 
integer, private num_io_buffers = 2
 
type(filetype), dimension(:), pointer, save, private opened_files => NULL()
 
integer, parameter, public outside_region =2
 
integer outunit
 
integer, parameter, public success = 0
 
real(r8_kind), parameter, private time_interp_missing =-1e99_r8_kind
 

Detailed Description

Perform I/O and time interpolation of external fields (contained in a file), using fms2_io.

Author
M.J. Harrison

Perform I/O and time interpolation for external fields. Uses udunits library to calculate calendar dates and convert units. Allows for reading data decomposed across model horizontal grid using optional domain2d argument

data are defined over data domain for domain2d data (halo values are NOT updated by this module)


Data Type Documentation

◆ time_interp_external2_mod::ext_fieldtype

type time_interp_external2_mod::ext_fieldtype

Represents external fields.

Definition at line 96 of file time_interp_external2.F90.

Collaboration diagram for ext_fieldtype:
[legend]

Private Attributes

character(len=32), dimension(4) axisname
 
logical correct_leap_year_inconsistency
 
type(domain2ddomain
 
real(r8_kind), dimension(:,:,:,:), pointer domain_data =>NULL()
 defined over data domain or global domain
 
logical domain_present
 
type(time_type), dimension(:), pointer end_time =>NULL()
 
type(fmsnetcdffile_t), pointer fileobj =>NULL()
 keep unit open when not reading all records
 
logical have_modulo_times
 
integer, dimension(:), pointer ibuf =>NULL()
 record numbers associated with buffers
 
integer ie_region
 
integer ie_src
 
integer iec
 
real(r8_kind) intercept
 
integer is_region
 
integer is_src
 
integer isc
 
integer je_region
 
integer je_src
 
integer jec
 
integer js_region
 
integer js_src
 
integer jsc
 
logical, dimension(:,:,:,:), pointer mask =>NULL()
 defined over data domain or global domain
 
real(r8_kind) missing
 
logical modulo_time
 denote climatological time axis
 
type(time_typemodulo_time_beg
 
type(time_typemodulo_time_end
 
character(len=128) name
 
integer nbuf
 
integer ndim
 
logical, dimension(:,:), pointer need_compute =>NULL()
 
integer numwindows
 
type(time_type), dimension(:), pointer period =>NULL()
 
integer region_type
 
integer, dimension(4) siz
 
real(r8_kind) slope
 
real(r8_kind), dimension(:,:,:,:), pointer src_data =>NULL()
 input data buffer
 
type(time_type), dimension(:), pointer start_time =>NULL()
 
integer tdim
 
type(time_type), dimension(:), pointer time =>NULL()
 midpoint of time interval
 
character(len=128) units
 
type(valid_tvalid
 

◆ time_interp_external2_mod::filetype

type time_interp_external2_mod::filetype

Holds filename and file object.

Definition at line 128 of file time_interp_external2.F90.

Collaboration diagram for filetype:
[legend]

Private Attributes

character(len=fms_file_len) filename = ''
 
type(fmsnetcdffile_t), pointer fileobj => NULL()
 

◆ time_interp_external2_mod::time_interp_external

interface time_interp_external2_mod::time_interp_external

Provide data from external file interpolated to current model time. Data may be local to current processor or global, depending on "init_external_field" flags. Uses FMS2 IO for I/O.

Parameters
indexindex of external field from previous call to init_external_field
timetarget time for data
[in,out]dataglobal or local data array
interptime_interp_external defined interpolation method (optional). Currently this module only supports LINEAR_TIME_INTERP.
verboseverbose flag for debugging (optional).

Definition at line 145 of file time_interp_external2.F90.

Private Member Functions

 time_interp_external_0d_r4
 
 time_interp_external_0d_r8
 
 time_interp_external_2d_r4
 
 time_interp_external_2d_r8
 
 time_interp_external_3d_r4
 
 time_interp_external_3d_r8
 

Function/Subroutine Documentation

◆ get_external_field_missing()

real(r8_kind) function, public time_interp_external2_mod::get_external_field_missing ( integer  index)

return missing value

Parameters
indexreturned from previous call to init_external_field.

Definition at line 1078 of file time_interp_external2.F90.

◆ get_external_field_size()

integer function, dimension(4), public time_interp_external2_mod::get_external_field_size ( integer  index)

Returns size of field after call to init_external_field. Ordering is X/Y/Z/T. This call only makes sense for non-distributed reads.

Parameters
indexreturned from previous call to init_external_field.

Definition at line 1061 of file time_interp_external2.F90.

◆ get_time_axis()

subroutine, public time_interp_external2_mod::get_time_axis ( integer, intent(in)  index,
type(time_type), dimension(:), intent(out)  time 
)
Parameters
[in]indexfield id
[out]timearray of time values to be filled

Definition at line 1091 of file time_interp_external2.F90.

◆ init_external_field()

integer function, public time_interp_external2_mod::init_external_field ( character(len=*), intent(in)  file,
character(len=*), intent(in)  fieldname,
type(domain2d), intent(in), optional  domain,
character(len=*), intent(in), optional  desired_units,
logical, intent(in), optional  verbose,
character(len=*), dimension(4), intent(out), optional  axis_names,
integer, dimension(4), intent(inout), optional  axis_sizes,
logical, intent(in), optional  override,
logical, intent(in), optional  correct_leap_year_inconsistency,
logical, intent(in), optional  permit_calendar_conversion,
logical, intent(in), optional  use_comp_domain,
integer, intent(out), optional  ierr,
integer, intent(in), optional  nwindows,
logical, optional  ignore_axis_atts,
logical, optional  ongrid 
)

Initialize an external field. Buffer "num_io_buffers" (default=2) in memory to reduce memory allocations. distributed reads are supported using the optional "domain" flag. Units conversion via the optional "desired_units" flag using udunits_mod.

Returns
integer id of field for future calls to time_interp_external.
Parameters
filefilename
fieldnamefieldname (in file)
formatmpp_io flag for format of file(optional). Currently only "MPP_NETCDF" supported
threadingmpp_io flag for threading (optional). "MPP_SINGLE" means root pe reads global field and distributes to other PEs. "MPP_MULTI" means all PEs read data
domaindomain flag (optional)
desired_unitsTarget units for data (optional), e.g. convert from deg_K to deg_C. Failure to convert using udunits will result in failure of this module.
verboseverbose flag for debugging (optional).
[out]axis_namesList of axis names (optional).
[in,out]axis_sizesarray of axis lengths ordered X-Y-Z-T (optional).
ongridOptional flag indicating if the data is ongrid

If this is an ongrid case, set is[e]js[e]data to be equal to the compute domain. This is what it is used to allocate space for the data!

Definition at line 270 of file time_interp_external2.F90.

◆ time_interp_external_2d_()

subroutine time_interp_external_2d_ ( integer, intent(in)  index,
type(time_type), intent(in)  time,
real(fms_ti_kind_), dimension(:,:), intent(inout)  data_in,
integer, intent(in), optional  interp,
logical, intent(in), optional  verbose,
type(horiz_interp_type), intent(in), optional  horz_interp,
logical, dimension(:,:), intent(out), optional  mask_out,
integer, intent(in), optional  is_in,
integer, intent(in), optional  ie_in,
integer, intent(in), optional  js_in,
integer, intent(in), optional  je_in,
integer, intent(in), optional  window_id 
)

2D interpolation for time_interp_external

Parameters
[out]mask_outset to true where output data is valid

Definition at line 24 of file time_interp_external2.inc.

◆ time_interp_external_3d_()

subroutine time_interp_external_3d_ ( integer, intent(in)  index,
type(time_type), intent(in)  time,
real(fms_ti_kind_), dimension(:,:,:), intent(inout)  time_data,
integer, intent(in), optional  interp,
logical, intent(in), optional  verbose,
type(horiz_interp_type), intent(in), optional  horz_interp,
logical, dimension(:,:,:), intent(out), optional  mask_out,
integer, intent(in), optional  is_in,
integer, intent(in), optional  ie_in,
integer, intent(in), optional  js_in,
integer, intent(in), optional  je_in,
integer, intent(in), optional  window_id 
)

3D interpolation for time_interp_external Provide data from external file interpolated to current model time. Data may be local to current processor or global, depending on "init_external_field" flags.

Parameters
[in]indexindex of external field from previous call to init_external_field
[in]timetarget time for data
[in,out]time_dataglobal or local data array
[in]verboseflag for debugging
[out]mask_outset to true where output data is valid

Definition at line 55 of file time_interp_external2.inc.

◆ time_interp_external_bridge_0d_()

subroutine time_interp_external_bridge_0d_ ( integer, intent(in)  index1,
integer, intent(in)  index2,
type(time_type), intent(in)  time,
real(fms_ti_kind_), intent(inout)  time_data,
logical, intent(in), optional  verbose 
)
Parameters
[in]index1index of first external field
[in]index2index of second external field
[in]timetarget time for data
[in,out]time_dataglobal or local data array
[in]verboseflag for debugging

Definition at line 230 of file time_interp_external2_bridge.inc.

◆ time_interp_external_bridge_2d_()

subroutine time_interp_external_bridge_2d_ ( integer, intent(in)  index1,
integer, intent(in)  index2,
type(time_type), intent(in)  time,
real(fms_ti_kind_), dimension(:,:), intent(inout)  data_in,
integer, intent(in), optional  interp,
logical, intent(in), optional  verbose,
type(horiz_interp_type), intent(in), optional  horz_interp,
logical, dimension(:,:), intent(out), optional  mask_out,
integer, intent(in), optional  is_in,
integer, intent(in), optional  ie_in,
integer, intent(in), optional  js_in,
integer, intent(in), optional  je_in,
integer, intent(in), optional  window_id 
)

2D interpolation for time_interp_external_bridge

Parameters
[in]index1index of first external field
[in]index2index of second external field
[in]timetarget time for data
[in,out]data_inglobal or local data array
[in]interphardcoded to linear
[in]verboseflag for debugging
[in]horz_interphorizontal interpolation type
[out]mask_outset to true where output data is valid
[in]je_inhorizontal indices for load_record
[in]window_idharcoded to 1 in load_record

Definition at line 24 of file time_interp_external2_bridge.inc.

◆ time_interp_external_bridge_3d_()

subroutine time_interp_external_bridge_3d_ ( integer, intent(in)  index1,
integer, intent(in)  index2,
type(time_type), intent(in)  time,
real(fms_ti_kind_), dimension(:,:,:), intent(inout)  time_data,
integer, intent(in), optional  interp,
logical, intent(in), optional  verbose,
type(horiz_interp_type), intent(in), optional  horz_interp,
logical, dimension(:,:,:), intent(out), optional  mask_out,
integer, intent(in), optional  is_in,
integer, intent(in), optional  ie_in,
integer, intent(in), optional  js_in,
integer, intent(in), optional  je_in,
integer, intent(in), optional  window_id 
)

3D interpolation for time_interp_external Provide data from external file interpolated to current model time. Data may be local to current processor or global, depending on "init_external_field" flags.

Parameters
[in]index1index of first external field
[in]index2index of second external field
[in]timetarget time for data
[in,out]time_dataglobal or local data array
[in]interphardcoded to linear
[in]verboseflag for debugging
[in]horz_interphorizontal interpolation type
[out]mask_outset to true where output data is valid
[in]ie_inx horizontal indices for load_record
[in]je_iny horizontal indices for load_record
[in]window_idharcoded to 1 in load_record

Definition at line 54 of file time_interp_external2_bridge.inc.