Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diag field type #1017

Merged
merged 11 commits into from
Aug 15, 2022
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ list(APPEND fms_fortran_src_files
diag_manager/fms_diag_object.F90
diag_manager/fms_diag_yaml.F90
diag_manager/fms_diag_file_object.F90
diag_manager/fms_diag_field_object.F90
diag_manager/fms_diag_axis_object.F90
diag_manager/fms_diag_dlinked_list.F90
diag_manager/fms_diag_object_container.F90
Expand Down
8 changes: 6 additions & 2 deletions diag_manager/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ libdiag_manager_la_SOURCES = \
diag_table.F90 \
diag_util.F90 \
fms_diag_file_object.F90 \
fms_diag_field_object.F90 \
fms_diag_yaml.F90 \
fms_diag_object.F90 \
fms_diag_axis_object.F90 \
Expand All @@ -52,9 +53,11 @@ diag_util_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_axis_mod.$(FC_MODEXT
diag_grid_mod.$(FC_MODEXT)
diag_table_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_util_mod.$(FC_MODEXT)
fms_diag_yaml_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_util_mod.$(FC_MODEXT)
fms_diag_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_axis_mod.$(FC_MODEXT) fms_diag_file_object_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) \
fms_diag_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_axis_mod.$(FC_MODEXT) fms_diag_file_object_mod.$(FC_MODEXT) fms_diag_field_object_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) \
diag_util_mod.$(FC_MODEXT)
fms_diag_file_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_axis_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT)
fms_diag_field_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_axis_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) \
diag_util_mod.$(FC_MODEXT)
fms_diag_file_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT) diag_axis_mod.$(FC_MODEXT) fms_diag_yaml_mod.$(FC_MODEXT) fms_diag_field_object_mod.$(FC_MODEXT)
fms_diag_object_container_mod.$(FC_MODEXT): fms_diag_object_mod.$(FC_MODEXT) fms_diag_dlinked_list_mod.$(FC_MODEXT)
fms_diag_axis_object_mod.$(FC_MODEXT): diag_data_mod.$(FC_MODEXT)
diag_manager_mod.$(FC_MODEXT): diag_axis_mod.$(FC_MODEXT) diag_data_mod.$(FC_MODEXT) diag_util_mod.$(FC_MODEXT) \
Expand All @@ -73,6 +76,7 @@ MODFILES = \
diag_table_mod.$(FC_MODEXT) \
fms_diag_yaml_mod.$(FC_MODEXT) \
fms_diag_file_object_mod.$(FC_MODEXT) \
fms_diag_field_object_mod.$(FC_MODEXT) \
fms_diag_object_mod.$(FC_MODEXT) \
fms_diag_axis_object_mod.$(FC_MODEXT) \
fms_diag_dlinked_list_mod.$(FC_MODEXT) \
Expand Down
36 changes: 16 additions & 20 deletions diag_manager/diag_manager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,11 @@ MODULE diag_manager_mod
USE diag_table_mod, ONLY: parse_diag_table
USE diag_output_mod, ONLY: get_diag_global_att, set_diag_global_att
USE diag_grid_mod, ONLY: diag_grid_init, diag_grid_end
USE fms_diag_object_mod, ONLY: fmsDiagObject_type, fms_diag_object_init, fms_register_diag_field_array, &
& fms_register_diag_field_scalar, fms_diag_object_end, fms_register_static_field, fms_diag_field_add_attribute, &
& fms_get_diag_field_id
USE fms_diag_file_object_mod, only: fms_diag_files_object_initialized
#ifdef use_yaml
use fms_diag_yaml_mod, only: diag_yaml_object_init, diag_yaml_object_end, get_num_unique_fields, find_diag_field
use fms_diag_axis_object_mod, only: fms_diag_axis_object_end, fms_diag_axis_object_init
use fms_diag_file_object_mod, only: fms_diag_files_object_init
#endif
use fms_diag_object_mod, only:fms_diag_object

USE constants_mod, ONLY: SECONDS_PER_DAY

Expand Down Expand Up @@ -407,8 +403,9 @@ INTEGER FUNCTION register_diag_field_scalar(module_name, field_name, init_time,
END IF
END IF
if (use_modern_diag) then
register_diag_field_scalar = fms_register_diag_field_scalar(module_name, field_name, init_time, &
& long_name=long_name, units=units, missing_value=missing_value, var_range=range, standard_name=standard_name, &
register_diag_field_scalar = fms_diag_object%fms_register_diag_field_scalar( &
& module_name, field_name, init_time, long_name=long_name, units=units, &
& missing_value=missing_value, var_range=range, standard_name=standard_name, &
& do_not_log=do_not_log, err_msg=err_msg, area=area, volume=volume, realm=realm)
else
register_diag_field_scalar = register_diag_field_scalar_old(module_name, field_name, init_time, &
Expand Down Expand Up @@ -445,8 +442,9 @@ INTEGER FUNCTION register_diag_field_array(module_name, field_name, axes, init_t
CHARACTER(len=*), OPTIONAL, INTENT(in) :: realm !< String to set as the modeling_realm attribute

if (use_modern_diag) then
register_diag_field_array = fms_register_diag_field_array(module_name, field_name, axes, init_time, &
& long_name=long_name, units=units, missing_value=missing_value, var_range=range, mask_variant=mask_variant, &
register_diag_field_array = fms_diag_object%fms_register_diag_field_array( &
& module_name, field_name, axes, init_time, long_name=long_name, &
& units=units, missing_value=missing_value, var_range=range, mask_variant=mask_variant, &
& standard_name=standard_name, verbose=verbose, do_not_log=do_not_log, err_msg=err_msg, &
& interp_method=interp_method, tile_count=tile_count, area=area, volume=volume, realm=realm)
else
Expand Down Expand Up @@ -493,7 +491,7 @@ INTEGER FUNCTION register_static_field(module_name, field_name, axes, long_name,
END IF

if (use_modern_diag) then
register_static_field = fms_register_static_field(module_name, field_name, axes, &
register_static_field = fms_diag_object%fms_register_static_field(module_name, field_name, axes, &
& long_name=long_name, units=units, missing_value=missing_value, range=range, mask_variant=mask_variant, &
& standard_name=standard_name, dynamic=DYNAMIC, do_not_log=do_not_log, interp_method=interp_method,&
& tile_count=tile_count, area=area, volume=volume, realm=realm)
Expand Down Expand Up @@ -1228,7 +1226,7 @@ INTEGER FUNCTION get_diag_field_id(module_name, field_name)

get_diag_field_id = DIAG_FIELD_NOT_FOUND
if (use_modern_diag) then
get_diag_field_id = fms_get_diag_field_id(module_name, field_name)
get_diag_field_id = fms_diag_object%fms_get_diag_field_id_from_name(module_name, field_name)
else
! find_input_field will return DIAG_FIELD_NOT_FOUND if the field is not
! included in the diag_table
Expand Down Expand Up @@ -3704,7 +3702,7 @@ SUBROUTINE diag_manager_end(time)
if (use_modern_diag) then
call diag_yaml_object_end
call fms_diag_axis_object_end()
call fms_diag_object_end()
call fms_diag_object%diag_end()
endif
#endif
END SUBROUTINE diag_manager_end
Expand Down Expand Up @@ -3922,9 +3920,7 @@ SUBROUTINE diag_manager_init(diag_model_subset, time_init, err_msg)
if (use_modern_diag) then
CALL diag_yaml_object_init(diag_subset_output)
CALL fms_diag_axis_object_init()
CALL fms_diag_object_init(255, 255) !< TO DO: MAX_LEN_VARNAME and MAX_LEN_META are supposed to be read from
!! the namelist and sent to fms_diag_object
fms_diag_files_object_initialized = fms_diag_files_object_init ()
CALL fms_diag_object%init(diag_subset_output)
Comment on lines 3921 to +3923
Copy link
Contributor

@uramirez8707 uramirez8707 Aug 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This initializes the yaml twice. Once in L3921 and then inside CALL fms_diag_object%init(diag_subset_output)
call diag_yaml_object_init(diag_subset_output) needs to be remove

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A module initialized was added to the yaml module so that it doesn';t crash. The code needs to be rearranged so that the diag object handles the inialization of the yaml and the axis objects.

endif
#else
if (use_modern_diag) &
Expand Down Expand Up @@ -4220,7 +4216,7 @@ SUBROUTINE diag_field_add_attribute_scalar_r(diag_field_id, att_name, att_value)
REAL, INTENT(in) :: att_value !< new attribute value

if (use_modern_diag) then
call fms_diag_field_add_attribute(diag_field_id, att_name, (/att_value /))
call fms_diag_object%fms_diag_field_add_attribute(diag_field_id, att_name, (/att_value /))
else
CALL diag_field_add_attribute_r1d(diag_field_id, att_name, (/ att_value /))
endif
Expand All @@ -4233,7 +4229,7 @@ SUBROUTINE diag_field_add_attribute_scalar_i(diag_field_id, att_name, att_value)
INTEGER, INTENT(in) :: att_value !< new attribute value

if (use_modern_diag) then
call fms_diag_field_add_attribute(diag_field_id, att_name, (/att_value /))
call fms_diag_object%fms_diag_field_add_attribute(diag_field_id, att_name, (/att_value /))
else
CALL diag_field_add_attribute_i1d(diag_field_id, att_name, (/ att_value /))
endif
Expand All @@ -4246,7 +4242,7 @@ SUBROUTINE diag_field_add_attribute_scalar_c(diag_field_id, att_name, att_value)
CHARACTER(len=*), INTENT(in) :: att_value !< new attribute value

if (use_modern_diag) then
call fms_diag_field_add_attribute(diag_field_id, att_name, (/att_value /))
call fms_diag_object%fms_diag_field_add_attribute(diag_field_id, att_name, (/att_value /))
else
CALL diag_field_attribute_init(diag_field_id, att_name, NF90_CHAR, cval=att_value)
endif
Expand All @@ -4259,7 +4255,7 @@ SUBROUTINE diag_field_add_attribute_r1d(diag_field_id, att_name, att_value)
REAL, DIMENSION(:), INTENT(in) :: att_value !< new attribute value

if (use_modern_diag) then
call fms_diag_field_add_attribute(diag_field_id, att_name, att_value)
call fms_diag_object%fms_diag_field_add_attribute(diag_field_id, att_name, att_value)
else
CALL diag_field_attribute_init(diag_field_id, att_name, NF90_FLOAT, rval=att_value)
endif
Expand All @@ -4272,7 +4268,7 @@ SUBROUTINE diag_field_add_attribute_i1d(diag_field_id, att_name, att_value)
INTEGER, DIMENSION(:), INTENT(in) :: att_value !< new attribute value

if (use_modern_diag) then
call fms_diag_field_add_attribute(diag_field_id, att_name, att_value)
call fms_diag_object%fms_diag_field_add_attribute(diag_field_id, att_name, att_value)
else
CALL diag_field_attribute_init(diag_field_id, att_name, NF90_INT, ival=att_value)
endif
Expand Down
Loading