NOAA-GFDL / FMS

GFDL's Flexible Modeling System
Other
92 stars 134 forks source link

Consistent maximum length of filenames? #1518

Closed climbfuji closed 2 months ago

climbfuji commented 4 months ago

Is your feature request related to a problem? Please describe. There is code in fms that still uses string lengths of 128 characters for filenames. This is causing problems with models such as GEOS, which uses deep paths (see e.g. https://github.com/GEOS-ESM/swell/issues/340).

I looked around in the fms code and found that there is a "wide range" of character limits for filenames. I also found that several places are using

./mosaic2/mosaic2.F90:     MAX_FILE = 1024, & !> max length of the file names
./mosaic2/mosaic2.F90:    character(len=MAX_FILE) :: gridfile

which coincidentally fits with @mathomp4's suggestion to use 1024 characters (aka ESMF_MAXPATHLEN). See https://github.com/GEOS-ESM/swell/issues/340#issuecomment-2104793923.

Describe the solution you'd like It would be really nice if all file names in fms - unless an edge case requires shorter paths - were using MAX_FILE.

Describe alternatives you've considered Manually bump up character limits for filenames in several places (not a good idea).

Additional context n/a

mathomp4 commented 4 months ago

The code I saw was this in mpp_util.inc:

    character(len=128) :: filename
...
    filename='input_'//trim(pelist_name)//'.nml'
    inquire(FILE=filename, EXIST=file_exist)
    if (.not. file_exist ) then
       if (present(alt_input_nml_path)) then
          filename = alt_input_nml_path
       else
          filename = 'input.nml'
       end if
    endif

where even if alt_input_nml_path is passed in and is 500 chars long, it'll be truncated to 128 by filename.

Dooruk commented 2 months ago

After testing with the new FMS/2023.04 version in JEDI after recent updates, this is still an issue. We would really appreciate a solution as this is impacting our CI tests.

I guess the latest update regarding this was the following?

From the 2023.02 Changelog:

thomas-robinson commented 2 months ago

We discussed this issue yesterday and we are looking at some sort of parameter integer value of 1024. We are looking at where to put it also because it needs to be fairly low-level. Is 1024 sufficiently long enough?

We have a release scheduled for a few weeks (mid august), so hopefully there is a relatively quick turn around.

mathomp4 commented 2 months ago

I believe in MAPL we still have a few places using ESMF_MAXPATHLEN so 1024 might be good.

More recent work in MAPL has moved us to use allocatable strings:

character(len=:), allocatable

which sort of make all this less necessary anymore. But that would a pretty big rewrite. 😄 (I'm also not sure if that last nvfortran caveat is necessary anymore...I should test that.)