From 13b068df319449ad47380f1ad243369d4f70a3cd Mon Sep 17 00:00:00 2001 From: rem1776 Date: Thu, 1 Aug 2024 13:00:01 -0400 Subject: [PATCH] replace usage of fm_path_name_len --- coupler/atmos_ocean_fluxes.F90 | 8 +++--- field_manager/field_manager.F90 | 38 +++++++++++++------------ field_manager/fm_util.F90 | 32 ++++++++++----------- field_manager/include/field_manager.inc | 2 +- field_manager/include/fm_util.inc | 6 ++-- include/fms_platform.h | 7 +++++ mpp/include/mpp_util.inc | 2 +- platform/platform.F90 | 2 ++ 8 files changed, 54 insertions(+), 43 deletions(-) diff --git a/coupler/atmos_ocean_fluxes.F90 b/coupler/atmos_ocean_fluxes.F90 index e15aec78bc..42b96bf062 100644 --- a/coupler/atmos_ocean_fluxes.F90 +++ b/coupler/atmos_ocean_fluxes.F90 @@ -48,7 +48,7 @@ module atmos_ocean_fluxes_mod use coupler_types_mod, only: ind_runoff use coupler_types_mod, only: ind_flux, ind_deltap, ind_kw, ind_flux0 - use field_manager_mod, only: fm_path_name_len, fm_string_len, fm_exists, fm_get_index + use field_manager_mod, only: fm_string_len, fm_exists, fm_get_index use field_manager_mod, only: fm_new_list, fm_get_current_list, fm_change_list use field_manager_mod, only: fm_field_name_len, fm_type_name_len, fm_dump_list use field_manager_mod, only: fm_loop_over_list @@ -63,7 +63,7 @@ module atmos_ocean_fluxes_mod use fm_util_mod, only: fm_util_get_real_array, fm_util_get_real, fm_util_get_integer use fm_util_mod, only: fm_util_get_logical, fm_util_get_logical_array use fms_io_utils_mod, only: get_data_type_string - use platform_mod, only: r4_kind, r8_kind + use platform_mod, only: r4_kind, r8_kind, FMS_PATH_LEN implicit none private @@ -135,8 +135,8 @@ function aof_set_coupler_flux(name, flux_type, implementation, atm_tr_index, par integer :: length integer :: num_parameters integer :: outunit - character(len=fm_path_name_len) :: coupler_list - character(len=fm_path_name_len) :: current_list + character(len=FMS_PATH_LEN) :: coupler_list + character(len=FMS_PATH_LEN) :: current_list character(len=fm_string_len) :: flux_type_test character(len=fm_string_len) :: implementation_test character(len=256) :: error_header diff --git a/field_manager/field_manager.F90 b/field_manager/field_manager.F90 index 8d9804c2e1..502fe4fb76 100644 --- a/field_manager/field_manager.F90 +++ b/field_manager/field_manager.F90 @@ -191,7 +191,7 @@ module field_manager_mod write_version_number, & check_nml_error use fms2_io_mod, only: file_exists -use platform_mod, only: r4_kind, r8_kind +use platform_mod, only: r4_kind, r8_kind, FMS_PATH_LEN #ifdef use_yaml use fm_yaml_mod #endif @@ -258,8 +258,10 @@ module field_manager_mod !> The length of a character string representing the field name. integer, parameter, public :: fm_field_name_len = 48 +!! TODO this should be removed in favor of the global FMS_PATH_LEN +!! when possible, currently used in ocean_BGC and land_lad2 !> The length of a character string representing the field path. -integer, parameter, public :: fm_path_name_len = 512 +integer, parameter, public :: fm_path_name_len = FMS_PATH_LEN !> The length of a character string representing character values for the field. integer, parameter, public :: fm_string_len = 1024 !> The length of a character string representing the various types that the values of the field can take. @@ -509,7 +511,7 @@ module field_manager_mod type(field_mgr_type), dimension(:), allocatable, private :: fields !< fields of field_mgr_type -character(len=fm_path_name_len) :: loop_list +character(len=FMS_PATH_LEN) :: loop_list character(len=fm_type_name_len) :: field_type_name(num_types) character(len=fm_field_name_len) :: save_root_name ! The string set is the set of characters. @@ -595,7 +597,7 @@ subroutine read_field_table_yaml(nfields, table_name) integer :: h, i, j, k, l, m !< dummy integer buffer type (fmTable_t) :: my_table !< the field table integer :: model !< model assocaited with the current field -character(len=fm_path_name_len) :: list_name !< field_manager list name +character(len=FMS_PATH_LEN) :: list_name !< field_manager list name character(len=fm_string_len) :: subparamvalue !< subparam value to be used when defining new name character(len=fm_string_len) :: fm_yaml_null !< useful hack when OG subparam does not contain an equals sign integer :: current_field !< field index within loop @@ -857,7 +859,7 @@ subroutine read_field_table_legacy(nfields, table_name) character(len=1024) :: record character(len=fm_string_len) :: control_str -character(len=fm_path_name_len) :: list_name +character(len=FMS_PATH_LEN) :: list_name character(len=fm_string_len) :: method_name character(len=fm_string_len) :: name_str character(len=fm_string_len) :: type_str @@ -1905,8 +1907,8 @@ function find_list(path, relative_p, create) & type (field_def), pointer :: relative_p !< pointer to the list to which "path" is relative to logical, intent(in) :: create !< If the list does not exist, it will be created if set to true -character(len=fm_path_name_len) :: working_path -character(len=fm_path_name_len) :: rest +character(len=FMS_PATH_LEN) :: working_path +character(len=FMS_PATH_LEN) :: rest character(len=fm_field_name_len) :: this_list integer :: i, out_unit type (field_def), pointer, save :: working_path_p @@ -2172,7 +2174,7 @@ end function fm_get_index !> @returns The path corresponding to the current list function fm_get_current_list() & result (path) -character(len=fm_path_name_len) :: path +character(len=FMS_PATH_LEN) :: path type (field_def), pointer, save :: temp_list_p ! Initialize the field manager if needed @@ -2582,7 +2584,7 @@ function fm_new_list(name, create, keep) & logical :: create_t logical :: keep_t -character(len=fm_path_name_len) :: path +character(len=FMS_PATH_LEN) :: path character(len=fm_field_name_len) :: base type (field_def), pointer, save :: temp_list_p integer :: out_unit @@ -2652,7 +2654,7 @@ function fm_new_value_integer(name, new_ival, create, index, append) & integer :: i integer :: index_t integer, pointer, dimension(:) :: temp_i_value -character(len=fm_path_name_len) :: path +character(len=FMS_PATH_LEN) :: path character(len=fm_field_name_len) :: base type (field_def), pointer, save :: temp_list_p type (field_def), pointer, save :: temp_field_p @@ -2788,7 +2790,7 @@ function fm_new_value_logical(name, new_lval, create, index, append) & logical, intent(in), optional :: append !< If present and .true., then append the value to !! an array of the present values. If present and .true., then index cannot be greater than 0. -character(len=fm_path_name_len) :: path +character(len=FMS_PATH_LEN) :: path character(len=fm_field_name_len) :: base integer :: i integer :: index_t @@ -2922,7 +2924,7 @@ function fm_new_value_string(name, new_sval, create, index, append) & logical, intent(in), optional :: append !< If present and .true., then append the value to character(len=fm_string_len), dimension(:), pointer :: temp_s_value -character(len=fm_path_name_len) :: path +character(len=FMS_PATH_LEN) :: path character(len=fm_field_name_len) :: base integer :: i integer :: index_t @@ -3086,7 +3088,7 @@ function get_field(name, this_list_p) & type (field_def), pointer :: this_list_p !< A pointer to a list that serves as the base point !! for searching for name -character(len=fm_path_name_len) :: path +character(len=FMS_PATH_LEN) :: path character(len=fm_field_name_len) :: base type (field_def), pointer, save :: temp_p @@ -3122,7 +3124,7 @@ function fm_modify_name(oldname, newname) character(len=*), intent(in) :: newname !< The name that the user wishes to change the name of !! the field to. -character(len=fm_path_name_len) :: path +character(len=FMS_PATH_LEN) :: path character(len=fm_field_name_len) :: base type (field_def), pointer, save :: list_p type (field_def), pointer, save :: temp_p @@ -3263,9 +3265,9 @@ function fm_query_method(name, method_name, method_control) & character(len=*), intent(out) :: method_name !< name of a parameter associated with the named field character(len=*), intent(out) :: method_control !< value of parameters associated with the named field -character(len=fm_path_name_len) :: path -character(len=fm_path_name_len) :: base -character(len=fm_path_name_len) :: name_loc +character(len=FMS_PATH_LEN) :: path +character(len=FMS_PATH_LEN) :: base +character(len=FMS_PATH_LEN) :: name_loc logical :: recursive_t type (field_def), pointer, save :: temp_list_p type (field_def), pointer, save :: temp_value_p @@ -3571,7 +3573,7 @@ recursive function find_method(list_p, recursive, num_meth, method, control) & character(len=*), intent(out), dimension(:) :: method !< The methods associated with the field pointed to by list_p character(len=*), intent(out), dimension(:) :: control !< The control parameters for the methods found -character(len=fm_path_name_len) :: scratch +character(len=FMS_PATH_LEN) :: scratch integer :: i integer :: n type (field_def), pointer, save :: this_field_p diff --git a/field_manager/fm_util.F90 b/field_manager/fm_util.F90 index 41432ca9e3..1042a0cab6 100644 --- a/field_manager/fm_util.F90 +++ b/field_manager/fm_util.F90 @@ -28,14 +28,14 @@ !> @{ module fm_util_mod !{ -use field_manager_mod, only: fm_string_len, fm_path_name_len, fm_field_name_len, fm_type_name_len +use field_manager_mod, only: fm_string_len, fm_field_name_len, fm_type_name_len use field_manager_mod, only: fm_get_type, fm_get_index, fm_get_length use field_manager_mod, only: fm_get_current_list, fm_new_list, fm_change_list, fm_loop_over_list use field_manager_mod, only: fm_new_value, fm_get_value use field_manager_mod, only: fm_exists, fm_dump_list use fms_mod, only: FATAL, stdout use mpp_mod, only: mpp_error -use platform_mod, only: r4_kind, r8_kind +use platform_mod, only: r4_kind, r8_kind, FMS_PATH_LEN implicit none @@ -93,9 +93,9 @@ module fm_util_mod !{ character(len=128) :: save_default_good_name_list = ' ' logical :: default_no_overwrite = .false. logical :: save_default_no_overwrite = .false. -character(len=fm_path_name_len) :: save_current_list -character(len=fm_path_name_len) :: save_path -character(len=fm_path_name_len) :: save_name +character(len=FMS_PATH_LEN) :: save_current_list +character(len=FMS_PATH_LEN) :: save_path +character(len=FMS_PATH_LEN) :: save_name ! Include variable "version" to be written to log file. #include @@ -1602,7 +1602,7 @@ subroutine fm_util_set_value_integer_array(name, ival, length, caller, no_overwr integer, intent(in) :: ival(length) character(len=*), intent(in), optional :: caller logical, intent(in), optional :: no_overwrite -character(len=fm_path_name_len), intent(in), optional :: good_name_list +character(len=FMS_PATH_LEN), intent(in), optional :: good_name_list ! ! Local parameters @@ -1623,7 +1623,7 @@ subroutine fm_util_set_value_integer_array(name, ival, length, caller, no_overwr integer :: field_length integer :: n logical :: no_overwrite_use -character(len=fm_path_name_len) :: good_name_list_use +character(len=FMS_PATH_LEN) :: good_name_list_use logical :: add_name ! @@ -1759,7 +1759,7 @@ subroutine fm_util_set_value_logical_array(name, lval, length, caller, no_overwr logical, intent(in) :: lval(length) character(len=*), intent(in), optional :: caller logical, intent(in), optional :: no_overwrite -character(len=fm_path_name_len), intent(in), optional :: good_name_list +character(len=FMS_PATH_LEN), intent(in), optional :: good_name_list ! ! Local parameters @@ -1780,7 +1780,7 @@ subroutine fm_util_set_value_logical_array(name, lval, length, caller, no_overwr integer :: field_length integer :: n logical :: no_overwrite_use -character(len=fm_path_name_len) :: good_name_list_use +character(len=FMS_PATH_LEN) :: good_name_list_use logical :: add_name ! @@ -1916,7 +1916,7 @@ subroutine fm_util_set_value_string_array(name, sval, length, caller, no_overwri character(len=*), intent(in) :: sval(length) character(len=*), intent(in), optional :: caller logical, intent(in), optional :: no_overwrite -character(len=fm_path_name_len), intent(in), optional :: good_name_list +character(len=FMS_PATH_LEN), intent(in), optional :: good_name_list ! ! Local parameters @@ -1937,7 +1937,7 @@ subroutine fm_util_set_value_string_array(name, sval, length, caller, no_overwri integer :: field_length integer :: n logical :: no_overwrite_use -character(len=fm_path_name_len) :: good_name_list_use +character(len=FMS_PATH_LEN) :: good_name_list_use logical :: add_name ! @@ -2096,7 +2096,7 @@ subroutine fm_util_set_value_integer(name, ival, caller, index, append, no_creat integer :: field_index logical :: no_overwrite_use integer :: field_length -character(len=fm_path_name_len) :: good_name_list_use +character(len=FMS_PATH_LEN) :: good_name_list_use logical :: create logical :: add_name @@ -2268,7 +2268,7 @@ subroutine fm_util_set_value_logical(name, lval, caller, index, append, no_creat integer :: field_index logical :: no_overwrite_use integer :: field_length -character(len=fm_path_name_len) :: good_name_list_use +character(len=FMS_PATH_LEN) :: good_name_list_use logical :: create logical :: add_name @@ -2439,7 +2439,7 @@ subroutine fm_util_set_value_string(name, sval, caller, index, append, no_create integer :: field_index logical :: no_overwrite_use integer :: field_length -character(len=fm_path_name_len) :: good_name_list_use +character(len=FMS_PATH_LEN) :: good_name_list_use logical :: create logical :: add_name @@ -2600,7 +2600,7 @@ subroutine fm_util_start_namelist(path, name, caller, no_overwrite, check) !{ ! integer :: namelist_index -character(len=fm_path_name_len) :: path_name +character(len=FMS_PATH_LEN) :: path_name character(len=256) :: error_header character(len=256) :: warn_header character(len=256) :: note_header @@ -2764,7 +2764,7 @@ subroutine fm_util_end_namelist(path, name, caller, check) !{ ! character(len=fm_string_len), pointer, dimension(:) :: good_list => NULL() -character(len=fm_path_name_len) :: path_name +character(len=FMS_PATH_LEN) :: path_name character(len=256) :: error_header character(len=256) :: warn_header character(len=256) :: note_header diff --git a/field_manager/include/field_manager.inc b/field_manager/include/field_manager.inc index e39cf2d7a9..c462152c7f 100644 --- a/field_manager/include/field_manager.inc +++ b/field_manager/include/field_manager.inc @@ -117,7 +117,7 @@ logical :: create_t integer :: i integer :: index_t real(r8_kind), allocatable, dimension(:) :: temp_r_value -character(len=fm_path_name_len) :: path +character(len=FMS_PATH_LEN) :: path character(len=fm_field_name_len) :: base type (field_def), pointer, save :: temp_list_p type (field_def), pointer, save :: temp_field_p diff --git a/field_manager/include/fm_util.inc b/field_manager/include/fm_util.inc index 26066ca868..6102532e96 100644 --- a/field_manager/include/fm_util.inc +++ b/field_manager/include/fm_util.inc @@ -36,7 +36,7 @@ integer, intent(in) :: length real(FMS_FM_KIND_), intent(in) :: rval(length) character(len=*), intent(in), optional :: caller logical, intent(in), optional :: no_overwrite -character(len=fm_path_name_len), intent(in), optional :: good_name_list +character(len=FMS_PATH_LEN), intent(in), optional :: good_name_list ! ! Local parameters @@ -57,7 +57,7 @@ integer :: field_index integer :: field_length integer :: n logical :: no_overwrite_use -character(len=fm_path_name_len) :: good_name_list_use +character(len=FMS_PATH_LEN) :: good_name_list_use logical :: add_name integer, parameter :: lkind=FMS_FM_KIND_ @@ -218,7 +218,7 @@ character(len=32) :: str_error integer :: field_index logical :: no_overwrite_use integer :: field_length -character(len=fm_path_name_len) :: good_name_list_use +character(len=FMS_PATH_LEN) :: good_name_list_use logical :: create logical :: add_name diff --git a/include/fms_platform.h b/include/fms_platform.h index 30feb9f73b..9a473f49f8 100644 --- a/include/fms_platform.h +++ b/include/fms_platform.h @@ -88,5 +88,12 @@ use,intrinsic :: iso_c_binding, only: c_double,c_float,c_int64_t, & #define QUAD_KIND DOUBLE_KIND #endif +!Max string sizes for paths and files +#ifndef FMS_MAX_PATH_LEN +#define FMS_MAX_PATH_LEN 1024 +#endif +#ifndef FMS_MAX_FILE_LEN +#define FMS_MAX_FILE_LEN 255 +#endif #endif diff --git a/mpp/include/mpp_util.inc b/mpp/include/mpp_util.inc index a86fcba626..ca3fa3d980 100644 --- a/mpp/include/mpp_util.inc +++ b/mpp/include/mpp_util.inc @@ -1228,7 +1228,7 @@ end function rarray_to_char integer, dimension(2) :: lines_and_length logical :: file_exist character(len=len(peset(current_peset_num)%name)) :: pelist_name - character(len=128) :: filename + character(len=FMS_PATH_LEN) :: filename ! check the status of input_nml_file if ( allocated(input_nml_file) ) then diff --git a/platform/platform.F90 b/platform/platform.F90 index ed5d9a2568..9845d3f330 100644 --- a/platform/platform.F90 +++ b/platform/platform.F90 @@ -32,6 +32,8 @@ module platform_mod l8_kind=LONG_KIND, l4_kind=INT_KIND, & i8_kind=LONG_KIND, i4_kind=INT_KIND, i2_kind=SHORT_KIND, & ptr_kind=POINTER_KIND + integer, parameter :: FMS_PATH_LEN = FMS_MAX_PATH_LEN + integer, parameter :: FMS_FILE_LEN = FMS_MAX_FILE_LEN !could additionally define things like OS, compiler...: useful? end module platform_mod !> @}