Skip to content

Commit

Permalink
use path size in platform mod for (hopefully) all filename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rem1776 authored and rem1776 committed Aug 1, 2024
1 parent c7caaf8 commit 480636a
Show file tree
Hide file tree
Showing 26 changed files with 94 additions and 92 deletions.
6 changes: 3 additions & 3 deletions amip_interp/amip_interp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ module amip_interp_mod
NOTE, mpp_error, fms_error_handler

use constants_mod, only: TFREEZE, pi
use platform_mod, only: r4_kind, r8_kind, i2_kind
use platform_mod, only: r4_kind, r8_kind, i2_kind, FMS_PATH_LEN
use mpp_mod, only: input_nml_file
use fms2_io_mod, only: FmsNetcdfFile_t, fms2_io_file_exists=>file_exists, open_file, close_file, &
get_dimension_size, fms2_io_read_data=>read_data
use netcdf, only: NF90_MAX_NAME

implicit none
private
Expand Down Expand Up @@ -302,9 +303,8 @@ module amip_interp_mod

! ---- global unit & date ----

integer, parameter :: maxc = 128
integer :: iunit
character(len=maxc) :: file_name_sst, file_name_ice
character(len=FMS_PATH_LEN) :: file_name_sst, file_name_ice
type(FmsNetcdfFile_t), target :: fileobj_sst, fileobj_ice

type (date_type) :: Curr_date = date_type( -99, -99, -99 )
Expand Down
5 changes: 3 additions & 2 deletions amip_interp/include/amip_interp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ subroutine GET_AMIP_SST_ (Time, Interp, sst, err_msg, lon_model, lat_model)
integer, dimension(:), allocatable :: ryr, rmo, rdy
character(len=30) :: time_unit
real(FMS_AMIP_INTERP_KIND_), dimension(:), allocatable :: timeval
character(len=maxc) :: ncfilename
character(len=FMS_PATH_LEN) :: ncfilename
type(FmsNetcdfFile_t) :: fileobj
logical :: the_file_exists
! end add by JHC
Expand Down Expand Up @@ -652,7 +652,8 @@ endif
integer(I2_KIND) :: idat(mobs,nobs)
integer :: nrecords, yr, mo, dy, ierr, k
integer, dimension(:), allocatable :: ryr, rmo, rdy
character(len=maxc) :: ncfilename, ncfieldname
character(len=FMS_PATH_LEN) :: ncfilename
character(len=NF90_MAX_NAME) :: ncfieldname
type(FmsNetcdfFile_t), pointer :: fileobj
integer, parameter :: lkind = FMS_AMIP_INTERP_KIND_

Expand Down
2 changes: 1 addition & 1 deletion column_diagnostics/include/column_diagnostics.inc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ integer, dimension(:), intent(out) :: diag_units !< unit number for
real(FMS_CD_KIND_) :: ref_lat
real(FMS_CD_KIND_) :: current_distance
character(len=8) :: char !< character string for diaganostic column index
character(len=32) :: filename !< filename for output file for diagnostic column
character(len=FMS_PATH_LEN) :: filename !< filename for output file for diagnostic column
logical :: allow_ij_input
logical :: open_file
integer :: io
Expand Down
38 changes: 19 additions & 19 deletions coupler/coupler_types.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module coupler_types_mod
use mpp_domains_mod, only: domain2D, mpp_redistribute
use mpp_mod, only: mpp_error, FATAL, mpp_chksum
use fms_string_utils_mod, only: string
use platform_mod, only: r4_kind, r8_kind, i8_kind
use platform_mod, only: r4_kind, r8_kind, i8_kind, FMS_PATH_LEN

implicit none
private
Expand Down Expand Up @@ -103,8 +103,8 @@ module coupler_types_mod
character(len=128) :: implementation = ' ' !< implementation
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_PATH_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_PATH_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
#ifdef use_deprecated_io
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
!! that is used for this field.
Expand Down Expand Up @@ -146,8 +146,8 @@ module coupler_types_mod
character(len=128) :: implementation = ' ' !< implementation
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_PATH_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_PATH_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
#ifdef use_deprecated_io
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
!! that is used for this field.
Expand Down Expand Up @@ -207,8 +207,8 @@ module coupler_types_mod
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_PATH_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_PATH_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
#ifdef use_deprecated_io
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
!! that is used for this field.
Expand Down Expand Up @@ -253,8 +253,8 @@ module coupler_types_mod
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=124) :: ice_restart_file = ' ' !< ice_restart_file
character(len=124) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_PATH_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_PATH_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
#ifdef use_deprecated_io
type(restart_file_type), pointer :: rest_type => NULL() !< A pointer to the restart_file_type
!! that is used for this field.
Expand Down Expand Up @@ -309,8 +309,8 @@ module coupler_types_mod
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_PATH_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_PATH_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
logical :: use_atm_pressure !< use_atm_pressure
logical :: use_10m_wind_speed !< use_10m_wind_speed
logical :: pass_through_ice !< pass_through_ice
Expand Down Expand Up @@ -350,8 +350,8 @@ module coupler_types_mod
real(r8_kind), pointer, dimension(:) :: param => NULL() !< param
logical, pointer, dimension(:) :: flag => NULL() !< flag
integer :: atm_tr_index = 0 !< atm_tr_index
character(len=128) :: ice_restart_file = ' ' !< ice_restart_file
character(len=128) :: ocean_restart_file = ' ' !< ocean_restart_file
character(len=FMS_PATH_LEN) :: ice_restart_file = ' ' !< ice_restart_file
character(len=FMS_PATH_LEN) :: ocean_restart_file = ' ' !< ocean_restart_file
logical :: use_atm_pressure !< use_atm_pressure
logical :: use_10m_wind_speed !< use_10m_wind_speed
logical :: pass_through_ice !< pass_through_ice
Expand Down Expand Up @@ -3076,15 +3076,15 @@ subroutine CT_register_restarts_2d(var, bc_rest_files, num_rest_files, mpp_domai
logical, optional,intent(in) :: ocean_restart !< If true, use the ocean restart file name.
character(len=*),optional,intent(in) :: directory !< Directory where to open the file

character(len=80), dimension(max(1,var%num_bcs)) :: rest_file_names
character(len=80) :: file_nm
character(len=FMS_PATH_LEN), dimension(max(1,var%num_bcs)) :: rest_file_names
character(len=FMS_PATH_LEN) :: file_nm
logical :: ocn_rest
integer :: f, n, m

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

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

character(len=80), dimension(max(1,var%num_bcs)) :: rest_file_names
character(len=80) :: file_nm
character(len=FMS_PATH_LEN), dimension(max(1,var%num_bcs)) :: rest_file_names
character(len=FMS_PATH_LEN) :: file_nm
logical :: ocn_rest
integer :: f, n, m

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

if(var%set .and. var%num_bcs .gt. 0) then
Expand Down
27 changes: 14 additions & 13 deletions data_override/include/data_override.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use fms2_io_mod, only : FmsNetcdfFile_t, open_file, close_file, &
get_mosaic_tile_file, file_exists
use get_grid_version_mod, only: get_grid_version_1, get_grid_version_2
use fms_string_utils_mod, only: string
use platform_mod

implicit none
private
Expand All @@ -61,14 +62,14 @@ type data_type
character(len=3) :: gridname
character(len=128) :: fieldname_code !< fieldname used in user's code (model)
character(len=128) :: fieldname_file !< fieldname used in the netcdf data file
character(len=512) :: file_name !< name of netCDF data file
character(len=FMS_PATH_LEN) :: file_name !< name of netCDF data file
character(len=128) :: interpol_method !< interpolation method (default "bilinear")
real(FMS_DATA_OVERRIDE_KIND_) :: factor !< For unit conversion, default=1, see OVERVIEW above
real(FMS_DATA_OVERRIDE_KIND_) :: lon_start, lon_end, lat_start, lat_end
integer :: region_type
logical :: multifile = .false.
character(len=512) :: prev_file_name !< name of netCDF data file for previous segment
character(len=512) :: next_file_name !< name of netCDF data file for next segment
character(len=FMS_PATH_LEN) :: prev_file_name !< name of netCDF data file for previous segment
character(len=FMS_PATH_LEN) :: next_file_name !< name of netCDF data file for next segment
type(time_type), dimension(:), allocatable :: time_records
type(time_type), dimension(:), allocatable :: time_prev_records
type(time_type), dimension(:), allocatable :: time_next_records
Expand Down Expand Up @@ -152,7 +153,7 @@ subroutine DATA_OVERRIDE_INIT_IMPL_(Atm_domain_in, Ocean_domain_in, Ice_domain_i
type (domain2d), intent(in), optional :: Land_domain_in !> Land domain
type(domainUG) , intent(in), optional :: Land_domainUG_in !> Land domain, unstructured grid

character(len=128) :: grid_file = 'INPUT/grid_spec.nc'
character(len=18), parameter :: grid_file = 'INPUT/grid_spec.nc'
integer :: is,ie,js,je,use_get_grid_version
integer :: i, iunit, io_status, ierr
logical :: atm_on, ocn_on, lnd_on, ice_on, lndUG_on
Expand Down Expand Up @@ -786,9 +787,9 @@ subroutine DATA_OVERRIDE_0D_(gridname,fieldname_code,data_out,time,override,data
type(time_type) :: first_record !< first record of "current" file
type(time_type) :: last_record !< last record of "current" file
character(len=512) :: filename !< file containing source data
character(len=512) :: prevfilename !< file containing previous source data, when using multiple files
character(len=512) :: nextfilename !< file containing next source data, when using multiple files
character(len=FMS_PATH_LEN) :: filename !< file containing source data
character(len=FMS_PATH_LEN) :: prevfilename !< file containing previous source data, when using multiple files
character(len=FMS_PATH_LEN) :: nextfilename !< file containing next source data, when using multiple files
character(len=128) :: fieldname !< fieldname used in the data file
integer :: index1 !< field index in data_table
integer :: dims(4)
Expand Down Expand Up @@ -980,12 +981,12 @@ subroutine DATA_OVERRIDE_3D_(gridname,fieldname_code,return_data,time,override,d
integer, optional, intent(in) :: is_in, ie_in, js_in, je_in
logical, dimension(:,:,:), allocatable :: mask_out

character(len=512) :: filename !< file containing source data
character(len=512) :: filename2 !< file containing source data
character(len=512) :: prevfilename !< file containing source data for previous file
character(len=512) :: prevfilename2 !< file containing source data for previous file
character(len=512) :: nextfilename !< file containing source data for next file
character(len=512) :: nextfilename2 !< file containing source data for next file
character(len=FMS_PATH_LEN) :: filename !< file containing source data
character(len=FMS_PATH_LEN) :: filename2 !< file containing source data
character(len=FMS_PATH_LEN) :: prevfilename !< file containing source data for previous file
character(len=FMS_PATH_LEN) :: prevfilename2 !< file containing source data for previous file
character(len=FMS_PATH_LEN) :: nextfilename !< file containing source data for next file
character(len=FMS_PATH_LEN) :: nextfilename2 !< file containing source data for next file
character(len=128) :: fieldname !< fieldname used in the data file
integer :: i,j
integer :: dims(4)
Expand Down
2 changes: 1 addition & 1 deletion data_override/include/get_grid_version.inc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ subroutine GET_GRID_VERSION_2_(fileobj, mod_name, domain, isc, iec, jsc, jec, lo
integer :: isd, ied, jsd, jed
integer :: isg, ieg, jsg, jeg
integer :: isc2, iec2, jsc2, jec2
character(len=256) :: solo_mosaic_file, grid_file
character(len=FMS_PATH_LEN) :: solo_mosaic_file, grid_file
real(lkind), allocatable :: tmpx(:,:), tmpy(:,:)
logical :: open_solo_mosaic
type(FmsNetcdfFile_t) :: mosaicfileobj, tilefileobj
Expand Down
15 changes: 6 additions & 9 deletions diag_integral/diag_integral.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module diag_integral_mod

!###############################################################################

use platform_mod, only: i8_kind
use platform_mod, only: i8_kind, FMS_PATH_LEN
use time_manager_mod, only: time_type, get_time, set_time, &
time_manager_init, &
operator(+), operator(-), &
Expand Down Expand Up @@ -135,16 +135,13 @@ module diag_integral_mod
!-------------------------------------------------------------------------------
!------ namelist -------

integer, parameter :: &
mxch = 64 !< maximum number of characters in
!! the optional output file name
real(r8_kind) :: &
output_interval = -1.0_r8_kind !< time interval at which integrals
!! are to be output
character(len=8) :: &
time_units = 'hours' !< time units associated with
!! output_interval
character(len=mxch) :: &
character(len=FMS_PATH_LEN) :: &
file_name = ' ' !< optional integrals output file name
logical :: &
print_header = .true. !< print a header for the integrals
Expand Down Expand Up @@ -1081,14 +1078,14 @@ end function vert_diag_integral
!> @brief Adds .ens_## to the diag_integral.out file name
!! @return character array updated_file_name
function ensemble_file_name(fname) result(updated_file_name)
character (len=mxch), intent(inout) :: fname
character (len=mxch) :: updated_file_name
character (len=*), intent(inout) :: fname
character (len=FMS_PATH_LEN) :: updated_file_name
integer :: ensemble_id_int
character(len=7) :: ensemble_suffix
character(len=2) :: ensemble_id_char
integer :: i
!> Make sure the file name short enough to handle adding the ensemble number
if (len(trim(fname)) > mxch-7) call error_mesg ('diag_integral_mod :: ensemble_file_name', &
if (len(trim(fname)) > FMS_PATH_LEN-7) call error_mesg ('diag_integral_mod :: ensemble_file_name', &
trim(fname)//" is too long and can not support adding ens_XX. Please shorten the "//&
"file_name in the diag_integral_nml", FATAL)
!> Get the ensemble ID and convert it to a string
Expand All @@ -1107,7 +1104,7 @@ function ensemble_file_name(fname) result(updated_file_name)
!> Loop through to find the last period
do i=len(trim(fname)),2,-1
if (fname(i:i) == ".") then
updated_file_name = fname(1:i-1)//trim(ensemble_suffix)//fname(i:mxch)
updated_file_name = fname(1:i-1)//trim(ensemble_suffix)//fname(i:FMS_PATH_LEN)
return
endif
enddo
Expand Down
2 changes: 1 addition & 1 deletion diag_manager/diag_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ MODULE diag_data_mod
!> @brief Type to define the diagnostic files that will be written as defined by the diagnostic table.
!> @ingroup diag_data_mod
TYPE file_type
CHARACTER(len=128) :: name !< Name of the output file.
CHARACTER(len=FMS_PATH_LEN) :: name !< Name of the output file.
CHARACTER(len=128) :: long_name
INTEGER, DIMENSION(max_fields_per_file) :: fields
INTEGER :: num_fields
Expand Down
2 changes: 1 addition & 1 deletion diag_manager/diag_manager.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ SUBROUTINE add_associated_files(file_num, cm_file_num, cm_ind)
INTEGER :: year, month, day, hour, minute, second
INTEGER :: n
CHARACTER(len=25) :: date_prefix
CHARACTER(len=256) :: asso_file_name
CHARACTER(len=FMS_PATH_LEN) :: asso_file_name

! Create the date_string
IF ( prepend_date ) THEN
Expand Down
2 changes: 1 addition & 1 deletion diag_manager/diag_output.F90
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ SUBROUTINE diag_output_init (file_name, file_title, file_unit,&
integer, allocatable, dimension(:) :: current_pelist
integer :: mype !< The pe you are on
character(len=9) :: mype_string !< a string to store the pe
character(len=128) :: filename_tile !< Filename with the tile number included
character(len=FMS_PATH_LEN) :: filename_tile !< Filename with the tile number included
!! It is needed for subregional diagnostics

!---- initialize mpp_io ----
Expand Down
3 changes: 2 additions & 1 deletion diag_manager/diag_table.F90
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ MODULE diag_table_mod
USE diag_data_mod, ONLY: global_descriptor, get_base_time, set_base_time, &
& DIAG_OTHER, DIAG_OCEAN, DIAG_ALL, coord_type, append_pelist_name, pelist_name
USE diag_util_mod, ONLY: init_file, check_duplicate_output_fields, init_input_field, init_output_field
USE platform_mod, ONLY: FMS_PATH_LEN

IMPLICIT NONE

Expand Down Expand Up @@ -283,7 +284,7 @@ MODULE diag_table_mod
INTEGER :: iOutput_freq_units
INTEGER :: iNew_file_freq_units
INTEGER :: iFile_duration_units
CHARACTER(len=128) :: file_name
CHARACTER(len=FMS_PATH_LEN) :: file_name
CHARACTER(len=10) :: output_freq_units
CHARACTER(len=10) :: time_units
CHARACTER(len=128) :: long_name
Expand Down
Loading

0 comments on commit 480636a

Please sign in to comment.