103use fms_mod,
only: lowercase, error_mesg, fatal, note
104use tracer_manager_mod,
only: no_tracer
111use mpp_mod,
only: mpp_root_pe, mpp_pe
112use fms_string_utils_mod,
only:
string
114implicit none ;
private
119character(3) :: module_name =
'gex'
120logical :: initialized = .false.
122integer,
parameter :: gex_name = 1
123integer,
parameter :: gex_units = 2
128 character(fm_field_name_len):: name =
''
129 character(fm_string_len) :: units =
''
130 logical :: set = .false.
136 type(gex_type),
allocatable:: field(:)
139integer,
allocatable :: n_gex(:,:)
140type(gex_type_r),
allocatable :: gex_fields(:,:)
156 if (initialized)
return
165 if (mpp_pe()==mpp_root_pe())
then
167 write(*,*)
'####################################'
168 write(*,*)
'# generic exchanged fields [gex] #'
169 write(*,*)
'####################################'
178 if (mpp_pe()==mpp_root_pe())
then
180 write(*,*)
'####################################'
189 character(len=*),
intent(in) :: listroot
190 integer,
intent(in) :: MODEL_SRC
191 integer,
intent(in) :: MODEL_REC
194 character(fm_field_name_len) :: name =
''
195 character(fm_type_name_len) :: ftype
196 character(fm_path_name_len) :: listname
201 call error_mesg(
'gex_read_field_table', &
202 'Cannot dump field list "'//listroot//
'". No additional field will be exchanged', &
208 allocate(gex_fields(model_src,model_rec)%field(n_gex(model_src,model_rec)))
212 associate(fld=>gex_fields(model_src,model_rec)%field(n))
213 fld%name = trim(name)
215 listname = trim(listroot)//
'/'//trim(name)
217 call error_mesg(module_name,
'Cannot change fm list to "'//trim(listname)//
'"', fatal)
220 fld%units =
fm_util_get_string(
'units', caller = module_name, default_value =
'', scalar = .true.)
223 if (mpp_pe()==mpp_root_pe())
write(*,*) listroot,n, &
224 ' name="'//trim(fld%name)//
'"', &
225 ' units="'//trim(fld%units)//
'"'
232 integer,
intent(in) :: model_src
233 integer,
intent(in) :: model_rec
236 if (.not. initialized)
call error_mesg(
'flux_exchange|gex_get_n_ex',
'gex not initialized',fatal)
246 integer,
intent(in) :: model_src
247 integer,
intent(in) :: model_rec
248 integer,
intent(in) :: gex_index
249 integer,
intent(in) :: property
253 if (.not. initialized)
call error_mesg(
'flux_exchange|check_gex_property',
'gex not initialized',fatal)
258 associate(field => gex_fields(model_src,model_rec)%field(gex_index))
259 if (property.eq.gex_name)
then
261 elseif (property.eq.gex_units)
then
264 call error_mesg(
'flux_exchange|gex',
'property does not exist: ' // field%name,fatal)
272 character(len=*),
intent(in) :: name
273 integer,
intent(in) :: model_src
274 integer,
intent(in) :: model_rec
275 logical,
intent(in),
optional :: record
281 if (.not. initialized)
call error_mesg(
'flux_exchange|gex_get_index',
'gex not initialized',fatal)
283 do i = 1, n_gex(model_src,model_rec)
284 if (lowercase(trim(name)) == trim(gex_fields(model_src,model_rec)%field(i)%name))
then
286 if (
present(record))
then
287 if (record) gex_fields(model_src,model_rec)%field(i)%set = .true.
299 integer,
intent(in) :: model_src
300 integer,
intent(in) :: model_rec
301 character(len=*),
intent(in) :: name
307 if (.not. initialized)
call error_mesg(
'flux_exchange|check_gex_name',
'gex not initialized',fatal)
311 if (index.eq.no_tracer)
then
312 call error_mesg(
'flux_exchange|gex',
'requested gex field does not exist '// &
315 if (gex_fields(model_src,model_rec)%field(index)%set)
then
318 call error_mesg(
'flux_exchange|gex',
'requested gex field not set '// &
328 integer,
intent(in) :: model_src
329 integer,
intent(in) :: model_rec
330 integer,
intent(in) :: index
335 if (index.eq.no_tracer)
then
336 call error_mesg(
'flux_exchange|gex',
'requested gex field does not exist '// &
337 gex_fields(model_src,model_rec)%field(index)%name,fatal)
339 if (gex_fields(model_src,model_rec)%field(index)%set)
then
342 call error_mesg(
'flux_exchange|gex',
'requested gex field not set '// &
343 gex_fields(model_src,model_rec)%field(index)%name,fatal)
351 integer,
intent(in) :: indx
352 integer,
intent(in) :: lb
353 integer,
intent(in) :: ub
354 character(*),
intent(in) :: name
356 if (indx.lt.lb .or. indx.gt.ub)
then
357 call error_mesg(module_name,
"Invalid " // name //
" index: " // string(indx), fatal)
character(len=fms_path_len) function, public fm_get_current_list()
A function to return the full path of the current list.
integer, parameter, public fm_string_len
The length of a character string representing character values for the field.
logical function, public fm_dump_list(name, recursive, unit)
A function to list properties associated with a field.
integer, parameter, public model_land
Land model.
subroutine, public fm_init_loop(loop_list, iter)
given a name of the list, prepares an iterator over the list content. If the name of the given list i...
logical function, public fm_change_list(name)
Change the current list. Return true on success, false otherwise.
integer, parameter, public fm_field_name_len
The length of a character string representing the field name.
integer, parameter, public fm_type_name_len
The length of a character string representing the various types that the values of the field can take...
integer, parameter, public model_ocean
Ocean model.
integer, parameter, public fm_path_name_len
The length of a character string representing the field path.
integer, parameter, public model_atmos
Atmospheric model.
integer, parameter, public num_models
Number of models (ATMOS, OCEAN, LAND, ICE, COUPLER).
subroutine, public field_manager_init(nfields, table_name)
Routine to initialize the field manager.
integer function, public fm_get_length(name)
A function to return how many elements are contained within the named list or entry.
A function for looping over a list.
Iterator over the field manager list.
character(len=fm_string_len) function, public fm_util_get_string(name, caller, index, default_value, scalar)
Get a string value from the Field Manager tree.
real(r8_kind) function, public fm_util_get_real(name, caller, index, default_value, scalar)
Get a real value from the Field Manager tree.
logical function, public fm_util_get_logical(name, caller, index, default_value, scalar)
Get a logical value from the Field Manager tree.
character(:) function, allocatable, public string(v, fmt)
Converts a number or a Boolean value to a string.
integer function, public gex_get_n_ex(model_src, model_rec)
Function to return number of fields exchanged.
subroutine gex_assert_valid_index(indx, name, lb, ub)
Check that an index falls within a range of valid values.
subroutine, public gex_init()
Subroutine to initialize generic exchange between model components.
subroutine gex_read_field_table(listroot, model_src, model_rec)
Subroutine to fields for a given exchange.
integer function, public gex_get_index(model_src, model_rec, name, record)
Function to return index of exchanged field.
logical function check_gex_index(model_src, model_rec, index)
Function to check if gex index is properly set.
logical function check_gex_name(model_src, model_rec, name)
Function to return the value of exchanged field and check that it was set.
character(len=64) function, public gex_get_property(model_src, model_rec, gex_index, property)
Function to return property value (string)
check that gex field was accessed by the sending component
This type represents the entries for a specific exchanged field.
This type stores information about all the exchanged fields.