Skip to content

Commit a5de6a5

Browse files
authored
feat: add macros for consistent file and path name lengths (#1567)
1 parent 7cc9803 commit a5de6a5

40 files changed

+177
-160
lines changed

amip_interp/amip_interp.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,11 @@ module amip_interp_mod
135135
NOTE, mpp_error, fms_error_handler
136136

137137
use constants_mod, only: TFREEZE, pi
138-
use platform_mod, only: r4_kind, r8_kind, i2_kind
138+
use platform_mod, only: r4_kind, r8_kind, i2_kind, FMS_FILE_LEN
139139
use mpp_mod, only: input_nml_file
140140
use fms2_io_mod, only: FmsNetcdfFile_t, fms2_io_file_exists=>file_exists, open_file, close_file, &
141141
get_dimension_size, fms2_io_read_data=>read_data
142+
use netcdf, only: NF90_MAX_NAME
142143

143144
implicit none
144145
private
@@ -302,9 +303,8 @@ module amip_interp_mod
302303

303304
! ---- global unit & date ----
304305

305-
integer, parameter :: maxc = 128
306306
integer :: iunit
307-
character(len=maxc) :: file_name_sst, file_name_ice
307+
character(len=FMS_FILE_LEN) :: file_name_sst, file_name_ice
308308
type(FmsNetcdfFile_t), target :: fileobj_sst, fileobj_ice
309309

310310
type (date_type) :: Curr_date = date_type( -99, -99, -99 )

amip_interp/include/amip_interp.inc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ subroutine GET_AMIP_SST_ (Time, Interp, sst, err_msg, lon_model, lat_model)
4646
integer, dimension(:), allocatable :: ryr, rmo, rdy
4747
character(len=30) :: time_unit
4848
real(FMS_AMIP_INTERP_KIND_), dimension(:), allocatable :: timeval
49-
character(len=maxc) :: ncfilename
49+
character(len=FMS_FILE_LEN) :: ncfilename
5050
type(FmsNetcdfFile_t) :: fileobj
5151
logical :: the_file_exists
5252
! end add by JHC
@@ -652,7 +652,8 @@ endif
652652
integer(I2_KIND) :: idat(mobs,nobs)
653653
integer :: nrecords, yr, mo, dy, ierr, k
654654
integer, dimension(:), allocatable :: ryr, rmo, rdy
655-
character(len=maxc) :: ncfilename, ncfieldname
655+
character(len=FMS_FILE_LEN) :: ncfilename
656+
character(len=NF90_MAX_NAME) :: ncfieldname
656657
type(FmsNetcdfFile_t), pointer :: fileobj
657658
integer, parameter :: lkind = FMS_AMIP_INTERP_KIND_
658659

column_diagnostics/column_diagnostics.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module column_diagnostics_mod
3232
get_date, time_type
3333
use constants_mod, only: constants_init, PI, RADIAN
3434
use mpp_mod, only: input_nml_file
35-
use platform_mod, only: r4_kind, r8_kind
35+
use platform_mod, only: r4_kind, r8_kind, FMS_FILE_LEN
3636
!-------------------------------------------------------------------
3737

3838
implicit none

column_diagnostics/include/column_diagnostics.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ integer, dimension(:), intent(out) :: diag_units !< unit number for
9999
real(FMS_CD_KIND_) :: ref_lat
100100
real(FMS_CD_KIND_) :: current_distance
101101
character(len=8) :: char !< character string for diaganostic column index
102-
character(len=32) :: filename !< filename for output file for diagnostic column
102+
character(len=FMS_FILE_LEN) :: filename !< filename for output file for diagnostic column
103103
logical :: allow_ij_input
104104
logical :: open_file
105105
integer :: io

coupler/atmos_ocean_fluxes.F90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module atmos_ocean_fluxes_mod
4848
use coupler_types_mod, only: ind_runoff
4949
use coupler_types_mod, only: ind_flux, ind_deltap, ind_kw, ind_flux0
5050

51-
use field_manager_mod, only: fm_path_name_len, fm_string_len, fm_exists, fm_get_index
51+
use field_manager_mod, only: fm_string_len, fm_exists, fm_get_index
5252
use field_manager_mod, only: fm_new_list, fm_get_current_list, fm_change_list
5353
use field_manager_mod, only: fm_field_name_len, fm_type_name_len, fm_dump_list
5454
use field_manager_mod, only: fm_loop_over_list
@@ -63,7 +63,7 @@ module atmos_ocean_fluxes_mod
6363
use fm_util_mod, only: fm_util_get_real_array, fm_util_get_real, fm_util_get_integer
6464
use fm_util_mod, only: fm_util_get_logical, fm_util_get_logical_array
6565
use fms_io_utils_mod, only: get_data_type_string
66-
use platform_mod, only: r4_kind, r8_kind
66+
use platform_mod, only: r4_kind, r8_kind, FMS_PATH_LEN
6767

6868
implicit none
6969
private
@@ -135,8 +135,8 @@ function aof_set_coupler_flux(name, flux_type, implementation, atm_tr_index, par
135135
integer :: length
136136
integer :: num_parameters
137137
integer :: outunit
138-
character(len=fm_path_name_len) :: coupler_list
139-
character(len=fm_path_name_len) :: current_list
138+
character(len=FMS_PATH_LEN) :: coupler_list
139+
character(len=FMS_PATH_LEN) :: current_list
140140
character(len=fm_string_len) :: flux_type_test
141141
character(len=fm_string_len) :: implementation_test
142142
character(len=256) :: error_header

coupler/coupler_types.F90

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module coupler_types_mod
4141
use mpp_domains_mod, only: domain2D, mpp_redistribute
4242
use mpp_mod, only: mpp_error, FATAL, mpp_chksum
4343
use fms_string_utils_mod, only: string
44-
use platform_mod, only: r4_kind, r8_kind, i8_kind
44+
use platform_mod, only: r4_kind, r8_kind, i8_kind, FMS_FILE_LEN, FMS_PATH_LEN
4545

4646
implicit none
4747
private
@@ -103,8 +103,8 @@ module coupler_types_mod
103103
character(len=128) :: implementation = ' ' !< implementation
104104
logical, pointer, dimension(:) :: flag => NULL() !< flag
105105
integer :: atm_tr_index = 0 !< atm_tr_index
106-
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
107-
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
106+
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
107+
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
108108
#ifdef use_deprecated_io
109109
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
110110
!! that is used for this field.
@@ -146,8 +146,8 @@ module coupler_types_mod
146146
character(len=128) :: implementation = ' ' !< implementation
147147
logical, pointer, dimension(:) :: flag => NULL() !< flag
148148
integer :: atm_tr_index = 0 !< atm_tr_index
149-
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
150-
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
149+
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
150+
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
151151
#ifdef use_deprecated_io
152152
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
153153
!! that is used for this field.
@@ -207,8 +207,8 @@ module coupler_types_mod
207207
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
208208
logical, pointer, dimension(:) :: flag => NULL() !< flag
209209
integer :: atm_tr_index = 0 !< atm_tr_index
210-
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
211-
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
210+
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
211+
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
212212
#ifdef use_deprecated_io
213213
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
214214
!! that is used for this field.
@@ -253,8 +253,8 @@ module coupler_types_mod
253253
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
254254
logical, pointer, dimension(:) :: flag => NULL() !< flag
255255
integer :: atm_tr_index = 0 !< atm_tr_index
256-
character(len=124) :: ice_restart_file = ' ' !< ice_restart_file
257-
character(len=124) :: ocean_restart_file = ' ' !< ocean_restart_file
256+
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
257+
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
258258
#ifdef use_deprecated_io
259259
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
260260
!! that is used for this field.
@@ -309,8 +309,8 @@ module coupler_types_mod
309309
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
310310
logical, pointer, dimension(:) :: flag => NULL() !< flag
311311
integer :: atm_tr_index = 0 !< atm_tr_index
312-
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
313-
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
312+
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
313+
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
314314
logical :: use_atm_pressure !< use_atm_pressure
315315
logical :: use_10m_wind_speed !< use_10m_wind_speed
316316
logical :: pass_through_ice !< pass_through_ice
@@ -350,8 +350,8 @@ module coupler_types_mod
350350
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
351351
logical, pointer, dimension(:) :: flag => NULL() !< flag
352352
integer :: atm_tr_index = 0 !< atm_tr_index
353-
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
354-
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
353+
character(len=FMS_FILE_LEN) :: ice_restart_file = ' ' !< ice_restart_file
354+
character(len=FMS_FILE_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
355355
logical :: use_atm_pressure !< use_atm_pressure
356356
logical :: use_10m_wind_speed !< use_10m_wind_speed
357357
logical :: pass_through_ice !< pass_through_ice
@@ -3076,15 +3076,15 @@ subroutine CT_register_restarts_2d(var, bc_rest_files, num_rest_files, mpp_domai
30763076
logical, optional,intent(in) :: ocean_restart !< If true, use the ocean restart file name.
30773077
character(len=*),optional,intent(in) :: directory !< Directory where to open the file
30783078

3079-
character(len=80), dimension(max(1,var%num_bcs)) :: rest_file_names
3080-
character(len=80) :: file_nm
3079+
character(len=FMS_FILE_LEN), dimension(max(1,var%num_bcs)) :: rest_file_names
3080+
character(len=FMS_FILE_LEN) :: file_nm
30813081
logical :: ocn_rest
30823082
integer :: f, n, m
30833083

30843084
character(len=20), allocatable, dimension(:) :: dim_names !< Array of dimension names
30853085
character(len=20) :: io_type !< flag indicating io type: "read" "overwrite"
30863086
logical, dimension(max(1,var%num_bcs)) :: file_is_open !< flag indicating if file is open
3087-
character(len=20) :: dir !< Directory where to open the file
3087+
character(len=FMS_PATH_LEN) :: dir !< Directory where to open the file
30883088

30893089
if(var%set .and. var%num_bcs .gt. 0) then
30903090
if(associated(var%bc) .eqv. associated(var%bc_r4)) then
@@ -3358,15 +3358,15 @@ subroutine CT_register_restarts_3d(var, bc_rest_files, num_rest_files, mpp_domai
33583358
logical, optional,intent(in) :: ocean_restart !< If true, use the ocean restart file name.
33593359
character(len=*),optional,intent(in) :: directory !< Directory where to open the file
33603360

3361-
character(len=80), dimension(max(1,var%num_bcs)) :: rest_file_names
3362-
character(len=80) :: file_nm
3361+
character(len=FMS_FILE_LEN), dimension(max(1,var%num_bcs)) :: rest_file_names
3362+
character(len=FMS_FILE_LEN) :: file_nm
33633363
logical :: ocn_rest
33643364
integer :: f, n, m
33653365

33663366
character(len=20), allocatable, dimension(:) :: dim_names !< Array of dimension names
33673367
character(len=20) :: io_type !< flag indicating io type: "read" "overwrite"
33683368
logical, dimension(max(1,var%num_bcs)) :: file_is_open !< Flag indicating if file is open
3369-
character(len=20) :: dir !< Directory where to open the file
3369+
character(len=FMS_PATH_LEN) :: dir !< Directory where to open the file
33703370
integer :: nz !< Length of the z direction of each file
33713371

33723372
if(var%set .and. var%num_bcs .gt. 0) then

data_override/get_grid_version.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
!> @{
2525
module get_grid_version_mod
2626
use constants_mod, only: DEG_TO_RAD
27-
use platform_mod, only: r4_kind, r8_kind
27+
use platform_mod, only: r4_kind, r8_kind, FMS_PATH_LEN
2828
use mpp_mod, only : mpp_error,FATAL,NOTE, mpp_min, mpp_max
2929
use mpp_domains_mod, only : domain2d, operator(.NE.),operator(.EQ.)
3030
use mpp_domains_mod, only : mpp_get_global_domain, mpp_get_data_domain

data_override/include/data_override.inc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
! modules. These modules are not intended to be used directly - they should be
2222
! used through the data_override_mod API. See data_override.F90 for details.
2323

24-
use platform_mod, only: r4_kind, r8_kind
24+
use platform_mod, only: r4_kind, r8_kind, FMS_PATH_LEN
2525
use yaml_parser_mod
2626
use constants_mod, only: DEG_TO_RAD
2727
use mpp_mod, only : mpp_error, FATAL, WARNING, NOTE, stdout, stdlog, mpp_max
@@ -61,7 +61,7 @@ type data_type
6161
character(len=3) :: gridname
6262
character(len=128) :: fieldname_code !< fieldname used in user's code (model)
6363
character(len=128) :: fieldname_file !< fieldname used in the netcdf data file
64-
character(len=512) :: file_name !< name of netCDF data file
64+
character(len=FMS_PATH_LEN) :: file_name !< name of netCDF data file
6565
character(len=128) :: interpol_method !< interpolation method (default "bilinear")
6666
logical :: ext_weights
6767
character(len=128) :: ext_weights_file_name
@@ -70,8 +70,8 @@ type data_type
7070
real(FMS_DATA_OVERRIDE_KIND_) :: lon_start, lon_end, lat_start, lat_end
7171
integer :: region_type
7272
logical :: multifile = .false.
73-
character(len=512) :: prev_file_name !< name of netCDF data file for previous segment
74-
character(len=512) :: next_file_name !< name of netCDF data file for next segment
73+
character(len=FMS_PATH_LEN) :: prev_file_name !< name of netCDF data file for previous segment
74+
character(len=FMS_PATH_LEN) :: next_file_name !< name of netCDF data file for next segment
7575
type(time_type), dimension(:), allocatable :: time_records
7676
type(time_type), dimension(:), allocatable :: time_prev_records
7777
type(time_type), dimension(:), allocatable :: time_next_records
@@ -172,7 +172,7 @@ subroutine DATA_OVERRIDE_INIT_IMPL_(Atm_domain_in, Ocean_domain_in, Ice_domain_i
172172
type (domain2d), intent(in), optional :: Land_domain_in !> Land domain
173173
type(domainUG) , intent(in), optional :: Land_domainUG_in !> Land domain, unstructured grid
174174

175-
character(len=128) :: grid_file = 'INPUT/grid_spec.nc'
175+
character(len=18), parameter :: grid_file = 'INPUT/grid_spec.nc'
176176
integer :: is,ie,js,je,use_get_grid_version
177177
integer :: i, iunit, io_status, ierr
178178
logical :: atm_on, ocn_on, lnd_on, ice_on, lndUG_on
@@ -847,9 +847,9 @@ subroutine DATA_OVERRIDE_0D_(gridname,fieldname_code,data_out,time,override,data
847847
848848
type(time_type) :: first_record !< first record of "current" file
849849
type(time_type) :: last_record !< last record of "current" file
850-
character(len=512) :: filename !< file containing source data
851-
character(len=512) :: prevfilename !< file containing previous source data, when using multiple files
852-
character(len=512) :: nextfilename !< file containing next source data, when using multiple files
850+
character(len=FMS_PATH_LEN) :: filename !< file containing source data
851+
character(len=FMS_PATH_LEN) :: prevfilename !< file containing previous source data, when using multiple files
852+
character(len=FMS_PATH_LEN) :: nextfilename !< file containing next source data, when using multiple files
853853
character(len=128) :: fieldname !< fieldname used in the data file
854854
integer :: index1 !< field index in data_table
855855
integer :: dims(4)
@@ -1041,12 +1041,12 @@ subroutine DATA_OVERRIDE_3D_(gridname,fieldname_code,return_data,time,override,d
10411041
integer, optional, intent(in) :: is_in, ie_in, js_in, je_in
10421042
logical, dimension(:,:,:), allocatable :: mask_out
10431043

1044-
character(len=512) :: filename !< file containing source data
1045-
character(len=512) :: filename2 !< file containing source data
1046-
character(len=512) :: prevfilename !< file containing source data for previous file
1047-
character(len=512) :: prevfilename2 !< file containing source data for previous file
1048-
character(len=512) :: nextfilename !< file containing source data for next file
1049-
character(len=512) :: nextfilename2 !< file containing source data for next file
1044+
character(len=FMS_PATH_LEN) :: filename !< file containing source data
1045+
character(len=FMS_PATH_LEN) :: filename2 !< file containing source data
1046+
character(len=FMS_PATH_LEN) :: prevfilename !< file containing source data for previous file
1047+
character(len=FMS_PATH_LEN) :: prevfilename2 !< file containing source data for previous file
1048+
character(len=FMS_PATH_LEN) :: nextfilename !< file containing source data for next file
1049+
character(len=FMS_PATH_LEN) :: nextfilename2 !< file containing source data for next file
10501050
character(len=128) :: fieldname !< fieldname used in the data file
10511051
integer :: i,j
10521052
integer :: dims(4)

data_override/include/get_grid_version.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
165165
integer :: isd, ied, jsd, jed
166166
integer :: isg, ieg, jsg, jeg
167167
integer :: isc2, iec2, jsc2, jec2
168-
character(len=256) :: solo_mosaic_file, grid_file
168+
character(len=FMS_PATH_LEN) :: solo_mosaic_file, grid_file
169169
real(lkind), allocatable :: tmpx(:,:), tmpy(:,:)
170170
logical :: open_solo_mosaic
171171
type(FmsNetcdfFile_t) :: mosaicfileobj, tilefileobj

0 commit comments

Comments
 (0)