26 module axis_utils2_mod
29 use fms2_io_mod,
only: fmsnetcdfdomainfile_t, variable_att_exists, fmsnetcdffile_t, &
30 get_variable_num_dimensions, get_variable_attribute, &
31 get_variable_size,
read_data, variable_exists
32 use platform_mod,
only: r4_kind, r8_kind
41 integer,
parameter :: maxatts = 100
42 real(r8_kind),
parameter :: epsln = 1.e-10_r8_kind
43 real(r8_kind),
parameter :: fp5 = 0.5_r8_kind, f360 = 360.0_r8_kind
47 #include<file_version.h>
60 module procedure axis_edges_r4, axis_edges_r8
64 module procedure lon_in_range_r4, lon_in_range_r8
68 module procedure frac_index_r4, frac_index_r8
72 module procedure nearest_index_r4, nearest_index_r8
76 module procedure tranlon_r4, tranlon_r8
80 module procedure interp_1d_linear_r4, interp_1d_linear_r8
84 module procedure interp_1d_cubic_spline_r4, interp_1d_cubic_spline_r8
88 module procedure interp_1d_1d_r4, interp_1d_1d_r8
89 module procedure interp_1d_2d_r4, interp_1d_2d_r8
90 module procedure interp_1d_3d_r4, interp_1d_3d_r8
94 module procedure find_index_r4, find_index_r8
104 type(fmsnetcdffile_t),
intent(in) :: fileobj
105 character(len=*),
intent(in) :: axisname
106 character(len=1),
intent(out) :: cart
108 character(len=1) :: axis_cart
109 character(len=16),
dimension(2) :: lon_names, lat_names
110 character(len=16),
dimension(3) :: z_names
111 character(len=16),
dimension(2) :: t_names
112 character(len=16),
dimension(3) :: lon_units, lat_units
113 character(len=8) ,
dimension(4) :: z_units
114 character(len=3) ,
dimension(6) :: t_units
115 character(len=32) :: name
118 lon_names = (/
'lon',
'x '/)
119 lat_names = (/
'lat',
'y '/)
120 z_names = (/
'depth ',
'height',
'z '/)
121 t_names = (/
'time',
't '/)
122 lon_units = (/
'degrees_e ',
'degrees_east',
'degreese '/)
123 lat_units = (/
'degrees_n ',
'degrees_north',
'degreesn '/)
124 z_units = (/
'cm ',
'm ',
'pa ',
'hpa'/)
125 t_units = (/
'sec',
'min',
'hou',
'day',
'mon',
'yea'/)
128 if (variable_exists(fileobj, axisname))
then
129 if (variable_att_exists(fileobj, axisname,
"cartesian_axis"))
then
130 call get_variable_attribute(fileobj, axisname,
"cartesian_axis", cart(1:1))
131 elseif (variable_att_exists(fileobj, axisname,
"axis"))
then
132 call get_variable_attribute(fileobj, axisname,
"axis", cart(1:1))
134 axis_cart = uppercase(cart)
135 if (axis_cart .eq.
'X' .or. axis_cart .eq.
'Y' .or. axis_cart .eq.
'Z' &
136 .or. axis_cart .eq.
'T')
then
142 if (cart /=
'X' .and. cart /=
'Y' .and. cart /=
'Z' .and. cart /=
'T')
then
143 name = lowercase(axisname)
144 do i=1,
size(lon_names(:))
145 if (trim(name(1:3)) == trim(lon_names(i))) cart =
'X'
147 do i=1,
size(lat_names(:))
148 if (trim(name(1:3)) == trim(lat_names(i))) cart =
'Y'
150 do i=1,
size(z_names(:))
151 if (trim(name) == trim(z_names(i))) cart =
'Z'
153 do i=1,
size(t_names(:))
154 if (trim(name) == t_names(i)) cart =
'T'
158 if (cart /=
'X' .and. cart /=
'Y' .and. cart /=
'Z' .and. cart /=
'T')
then
159 name = lowercase(axisname)
160 do i=1,
size(lon_units(:))
161 if (trim(name) == trim(lon_units(i))) cart =
'X'
163 do i=1,
size(lat_units(:))
164 if (trim(name) == trim(lat_units(i))) cart =
'Y'
166 do i=1,
size(z_units(:))
167 if (trim(name) == trim(z_units(i))) cart =
'Z'
169 do i=1,
size(t_units(:))
170 if (name(1:3) == trim(t_units(i))) cart =
'T'
179 type(fmsnetcdffile_t),
intent(in) :: fileobj
180 character(len=*),
intent(in) :: axisname
189 type(fmsnetcdffile_t),
intent(in) :: fileobj
190 character(len=*),
intent(in) :: axisname
191 character(len=*),
intent(out) :: tbeg, tend
193 logical :: found_tbeg, found_tend
195 found_tbeg = variable_att_exists(fileobj, axisname,
"modulo_beg")
196 found_tend = variable_att_exists(fileobj, axisname,
"modulo_end")
198 if (found_tbeg .and. .not. found_tend)
then
199 call mpp_error(fatal,
'error in get: Found modulo_beg but not modulo_end')
201 if (.not. found_tbeg .and. found_tend)
then
202 call mpp_error(fatal,
'error in get: Found modulo_end but not modulo_beg')
206 call get_variable_attribute(fileobj, axisname,
"modulo_beg", tbeg)
207 call get_variable_attribute(fileobj, axisname,
"modulo_end", tend)
215 #include "axis_utils2_r4.fh"
216 #include "axis_utils2_r8.fh"
218 end module axis_utils2_mod
subroutine, public get_axis_cart(fileobj, axisname, cart)
Returns X,Y,Z or T cartesian attribute.
logical function, public get_axis_modulo(fileobj, axisname)
Checks if 'modulo' variable exists for a given axis.
logical function, public get_axis_modulo_times(fileobj, axisname, tbeg, tend)
Perform 1D interpolation between grids.
Read data from a defined field in a file.
logical function, public string_array_index(string, string_array, index)
match the input character string to a string in an array/list of character strings
logical function, public fms_error_handler(routine, message, err_msg)
Facilitates the control of fatal error conditions.
integer function stdout()
This function returns the current standard fortran unit numbers for output.