27 module axis_utils2_mod
30 use fms2_io_mod,
only: fmsnetcdfdomainfile_t, variable_att_exists, fmsnetcdffile_t, &
31 get_variable_num_dimensions, get_variable_attribute, &
32 get_variable_size,
read_data, variable_exists
33 use platform_mod,
only: r4_kind, r8_kind
42 integer,
parameter :: maxatts = 100
43 real(r8_kind),
parameter :: epsln = 1.e-10_r8_kind
44 real(r8_kind),
parameter :: fp5 = 0.5_r8_kind, f360 = 360.0_r8_kind
48 #include<file_version.h>
61 module procedure axis_edges_r4, axis_edges_r8
65 module procedure lon_in_range_r4, lon_in_range_r8
69 module procedure frac_index_r4, frac_index_r8
73 module procedure nearest_index_r4, nearest_index_r8
77 module procedure tranlon_r4, tranlon_r8
81 module procedure interp_1d_linear_r4, interp_1d_linear_r8
85 module procedure interp_1d_cubic_spline_r4, interp_1d_cubic_spline_r8
89 module procedure interp_1d_1d_r4, interp_1d_1d_r8
90 module procedure interp_1d_2d_r4, interp_1d_2d_r8
91 module procedure interp_1d_3d_r4, interp_1d_3d_r8
95 module procedure find_index_r4, find_index_r8
105 type(fmsnetcdffile_t),
intent(in) :: fileobj
106 character(len=*),
intent(in) :: axisname
107 character(len=1),
intent(out) :: cart
109 character(len=1) :: axis_cart
110 character(len=16),
dimension(2) :: lon_names, lat_names
111 character(len=16),
dimension(3) :: z_names
112 character(len=16),
dimension(2) :: t_names
113 character(len=16),
dimension(3) :: lon_units, lat_units
114 character(len=8) ,
dimension(4) :: z_units
115 character(len=3) ,
dimension(6) :: t_units
116 character(len=32) :: name
119 lon_names = (/
'lon',
'x '/)
120 lat_names = (/
'lat',
'y '/)
121 z_names = (/
'depth ',
'height',
'z '/)
122 t_names = (/
'time',
't '/)
123 lon_units = (/
'degrees_e ',
'degrees_east',
'degreese '/)
124 lat_units = (/
'degrees_n ',
'degrees_north',
'degreesn '/)
125 z_units = (/
'cm ',
'm ',
'pa ',
'hpa'/)
126 t_units = (/
'sec',
'min',
'hou',
'day',
'mon',
'yea'/)
129 if (variable_exists(fileobj, axisname))
then
130 if (variable_att_exists(fileobj, axisname,
"cartesian_axis"))
then
131 call get_variable_attribute(fileobj, axisname,
"cartesian_axis", cart(1:1))
132 elseif (variable_att_exists(fileobj, axisname,
"axis"))
then
133 call get_variable_attribute(fileobj, axisname,
"axis", cart(1:1))
135 axis_cart = uppercase(cart)
136 if (axis_cart .eq.
'X' .or. axis_cart .eq.
'Y' .or. axis_cart .eq.
'Z' &
137 .or. axis_cart .eq.
'T')
then
143 if (cart /=
'X' .and. cart /=
'Y' .and. cart /=
'Z' .and. cart /=
'T')
then
144 name = lowercase(axisname)
145 do i=1,
size(lon_names(:))
146 if (trim(name(1:3)) == trim(lon_names(i))) cart =
'X'
148 do i=1,
size(lat_names(:))
149 if (trim(name(1:3)) == trim(lat_names(i))) cart =
'Y'
151 do i=1,
size(z_names(:))
152 if (trim(name) == trim(z_names(i))) cart =
'Z'
154 do i=1,
size(t_names(:))
155 if (trim(name) == t_names(i)) cart =
'T'
159 if (cart /=
'X' .and. cart /=
'Y' .and. cart /=
'Z' .and. cart /=
'T')
then
160 name = lowercase(axisname)
161 do i=1,
size(lon_units(:))
162 if (trim(name) == trim(lon_units(i))) cart =
'X'
164 do i=1,
size(lat_units(:))
165 if (trim(name) == trim(lat_units(i))) cart =
'Y'
167 do i=1,
size(z_units(:))
168 if (trim(name) == trim(z_units(i))) cart =
'Z'
170 do i=1,
size(t_units(:))
171 if (name(1:3) == trim(t_units(i))) cart =
'T'
180 type(fmsnetcdffile_t),
intent(in) :: fileobj
181 character(len=*),
intent(in) :: axisname
190 type(fmsnetcdffile_t),
intent(in) :: fileobj
191 character(len=*),
intent(in) :: axisname
192 character(len=*),
intent(out) :: tbeg, tend
194 logical :: found_tbeg, found_tend
196 found_tbeg = variable_att_exists(fileobj, axisname,
"modulo_beg")
197 found_tend = variable_att_exists(fileobj, axisname,
"modulo_end")
199 if (found_tbeg .and. .not. found_tend)
then
200 call mpp_error(fatal,
'error in get: Found modulo_beg but not modulo_end')
202 if (.not. found_tbeg .and. found_tend)
then
203 call mpp_error(fatal,
'error in get: Found modulo_end but not modulo_beg')
207 call get_variable_attribute(fileobj, axisname,
"modulo_beg", tbeg)
208 call get_variable_attribute(fileobj, axisname,
"modulo_end", tend)
216 #include "axis_utils2_r4.fh"
217 #include "axis_utils2_r8.fh"
219 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.