FMS  2024.03
Flexible Modeling System
axis_utils2_mod

A set of utilities for manipulating axes and extracting axis attributes. FMS2_IO equivalent version of axis_utils_mod. More...

Data Types

interface  axis_edges
 Perform 1D interpolation between grids. More...
 

Functions/Subroutines

subroutine axis_edges_ (fileobj, name, edge_data, reproduce_null_char_bug_flag)
 get axis edge data from a given file More...
 
subroutine find_index_ (grid1, xs, xe, ks, ke)
 
real(kind=fms_au_kind_) function frac_index_ (rval, array)
 
subroutine, public get_axis_cart (fileobj, axisname, cart)
 Returns X,Y,Z or T cartesian attribute. More...
 
logical function, public get_axis_modulo (fileobj, axisname)
 Checks if 'modulo' variable exists for a given axis. More...
 
logical function, public get_axis_modulo_times (fileobj, axisname, tbeg, tend)
 
subroutine interp_1d_1d_ (grid1, grid2, data1, data2, method, yp1, yp2)
 
subroutine interp_1d_2d_ (grid1, grid2, data1, data2)
 
subroutine interp_1d_3d_ (grid1, grid2, data1, data2, method, yp1, yp2)
 
subroutine interp_1d_cubic_spline_ (grid1, grid2, data1, data2, yp1, ypn)
 
subroutine interp_1d_linear_ (grid1, grid2, data1, data2)
 
real(kind=fms_au_kind_) function lon_in_range_ (lon, l_strt)
 Returns lon_strt <= longitude <= lon_strt+360. More...
 
integer function nearest_index_ (rval, array)
 Return index of nearest point along axis. More...
 
subroutine tranlon_ (lon, lon_start, istrt)
 Returns monotonic array of longitudes s.t., lon_strt <= lon(:) < lon_strt+360. More...
 

Variables

real(r8_kind), parameter epsln = 1.e-10_r8_kind
 
real(r8_kind), parameter f360 = 360.0_r8_kind
 
real(r8_kind), parameter fp5 = 0.5_r8_kind
 

Detailed Description

A set of utilities for manipulating axes and extracting axis attributes. FMS2_IO equivalent version of axis_utils_mod.

Author
M.J. Harrison

Data Type Documentation

◆ axis_utils2_mod::axis_edges

interface axis_utils2_mod::axis_edges

Perform 1D interpolation between grids.

Data and grids can have 1, 2, or 3 dimensions.

Parameters
grid1grid for data1
grid2grid for data2
data1Data to interpolate
[in,out]data2Interpolated data
methodEither "linear" or "cubic_spline" interpolation method, default="linear"

Definition at line 60 of file axis_utils2.F90.

Private Member Functions

 axis_edges_r4
 
 axis_edges_r8
 

Function/Subroutine Documentation

◆ axis_edges_()

subroutine axis_edges_ ( class(fmsnetcdffile_t), intent(in)  fileobj,
character(len=*), intent(in)  name,
real(fms_au_kind_), dimension(:), intent(out)  edge_data,
logical, intent(in), optional  reproduce_null_char_bug_flag 
)

get axis edge data from a given file

Parameters
[in]fileobjFile object to read from
[in]nameName of a given axis
[out]edge_dataReturned edge data from given axis name
[in]reproduce_null_char_bug_flagFlag indicating to reproduce the mpp_io bug where the null characters were not removed after reading a string attribute

Definition at line 29 of file axis_utils2.inc.

◆ frac_index_()

real(kind=fms_au_kind_) function frac_index_ ( real(kind=fms_au_kind_)  rval,
real(kind=fms_au_kind_), dimension(:)  array 
)
Parameters
rvalarbitrary data...same units as elements in "array"
arrayarray of data points (must be monotonically increasing)

Definition at line 226 of file axis_utils2.inc.

◆ get_axis_cart()

subroutine, public axis_utils2_mod::get_axis_cart ( type(fmsnetcdffile_t), intent(in)  fileobj,
character(len=*), intent(in)  axisname,
character(len=1), intent(out)  cart 
)

Returns X,Y,Z or T cartesian attribute.

Parameters
[in]fileobjfile object to read from
[in]axisnamename of axis to retrieve
[out]cartReturned attribute axis

Definition at line 104 of file axis_utils2.F90.

◆ get_axis_modulo()

logical function, public axis_utils2_mod::get_axis_modulo ( type(fmsnetcdffile_t), intent(in)  fileobj,
character(len=*), intent(in)  axisname 
)

Checks if 'modulo' variable exists for a given axis.

Returns
true if modulo variable exists in fileobj for the given axis name.

Definition at line 179 of file axis_utils2.F90.

◆ get_axis_modulo_times()

logical function, public axis_utils2_mod::get_axis_modulo_times ( type(fmsnetcdffile_t), intent(in)  fileobj,
character(len=*), intent(in)  axisname,
character(len=*), intent(out)  tbeg,
character(len=*), intent(out)  tend 
)
Returns
true if modulo_beg and modulo_end exist in fileobj with the given axis, and returns their values in tbeg and tend.

Definition at line 189 of file axis_utils2.F90.

◆ lon_in_range_()

real(kind=fms_au_kind_) function lon_in_range_ ( real(kind=fms_au_kind_), intent(in)  lon,
real(kind=fms_au_kind_), intent(in)  l_strt 
)

Returns lon_strt <= longitude <= lon_strt+360.

Returns
real lon_in_range */

Definition at line 141 of file axis_utils2.inc.

◆ nearest_index_()

integer function nearest_index_ ( real(kind=fms_au_kind_), intent(in)  rval,
real(kind=fms_au_kind_), dimension(:), intent(in)  array 
)

Return index of nearest point along axis.

nearest_index = index of nearest data point within "array" corresponding to
       "value".

inputs:

rval   = arbitrary data...same units as elements in "array"
array  = array of data points  (must be monotonically)
ia     = dimension of "array"

output:

nearest_index =  index of nearest data point to "value"
        if "value" is outside the domain of "array" then nearest_index = 1
        or "ia" depending on whether array(1) or array(ia) is
        closest to "value"

        note: if "array" is dimensioned array(0:ia) in the calling
              program, then the returned index should be reduced
              by one to account for the zero base.

example:

let model depths be defined by the following:
parameter (km=5)
dimension z(km)
data z /5.0, 10.0, 50.0, 100.0, 250.0/

k1 = nearest_index (12.5, z, km)
k2 = nearest_index (0.0, z, km)

k1 would be set to 2, and k2 would be set to 1 so that
z(k1) would be the nearest data point to 12.5 and z(k2) would
be the nearest data point to 0.0
Returns
integer nearest_index
Parameters
[in]rvalarbitrary data...same units as elements in "array"
[in]arrayarray of data points (must be monotonic)

Definition at line 301 of file axis_utils2.inc.

◆ tranlon_()

subroutine tranlon_ ( real(kind=fms_au_kind_), dimension(:), intent(inout)  lon,
real(kind=fms_au_kind_), intent(in)  lon_start,
integer, intent(out)  istrt 
)

Returns monotonic array of longitudes s.t., lon_strt <= lon(:) < lon_strt+360.

This may require that entries be moved from the beginning of the array to the end. If no entries are moved (i.e., if lon(:) is already monotonic in the range from lon_start to lon_start + 360), then istrt is set to 0. If any entries are moved, then istrt is set to the original index of the entry which becomes lon(1).

e.g.,

   lon = 0 1 2 3 4 5  ...  358 359; lon_strt = 3

==> lon = 3 4 5 6 7 8 ... 359 360 361 362; istrt = 4

Definition at line 185 of file axis_utils2.inc.