FMS icon indicating copy to clipboard operation
FMS copied to clipboard

Consistent maximum length of filenames?

Open climbfuji opened this issue 1 year ago • 1 comments

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

climbfuji avatar May 10 '24 16:05 climbfuji

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.

mathomp4 avatar May 10 '24 18:05 mathomp4

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:

  • MPP: Added workaround for GCC 12 issues causing errors with string lengths in fms2_io

Dooruk avatar Jul 25 '24 03:07 Dooruk

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.

thomas-robinson avatar Jul 26 '24 12:07 thomas-robinson

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.)

mathomp4 avatar Jul 26 '24 15:07 mathomp4