Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add consistent character lengths for files and paths #1567

Merged
merged 11 commits into from
Aug 5, 2024

Conversation

rem1776
Copy link
Contributor

@rem1776 rem1776 commented Aug 2, 2024

Description

  • Adds two parameter values to platform_mod, FMS_PATH_LEN and FMS_FILE_LEN that are set by the FMS_MAX_PATH_LEN and FMS_MAX_FILE_LEN cpp macros in the fms_platform.h file and default to 1024 and 255 respectively.
  • Replaces/removes any lengths for file/path names with the exception of fm_path_name_len. Since it is used externally, I removed internal usage and set the value to FMS_PATH_LEN so we can remove it later along with updating the components, see issue remove path length parameter from field_manager #1564.
  • Uses len=* instead of a set length for any filename related character arguments

It can be somewhat ambiguous what is intended as a filename vs a full path name, so let me know if you think a length should be one instead of the other or if anything was missed.

Fixes #1518

How Has This Been Tested?
gnu 13 + mpich on the amd box

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

thomas-robinson
thomas-robinson previously approved these changes Aug 2, 2024
Copy link
Member

@thomas-robinson thomas-robinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the platform files and that looked alright, and very briefly skimmed the rest. Will defer to @bensonr because I am not going to be available for a more thorough review.

@thomas-robinson
Copy link
Member

@climbfuji @mathomp4 @Dooruk Does this work sufficiently fix your issue?

Copy link
Contributor

@bensonr bensonr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any tests codes that would need changed as well?

@@ -1348,8 +1348,7 @@ end function rarray_to_char
integer, dimension(2) :: get_ascii_file_num_lines_and_length !< number of lines (1) and
!! max line length (2)
integer :: num_lines, max_length
integer, parameter :: LENGTH=1024
character(len=LENGTH) :: str_tmp
character(len=FMS_FILE_LEN) :: str_tmp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a filename, but the length of a string being read from an ascii file for conversion to a character variable. Using FMS_FILE_LEN would now impose a limit of 255 from the original 1024.

Copy link
Contributor Author

@rem1776 rem1776 Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with f9cac03, all the changes for that routine should be reverted.

Comment on lines 1391 to 1392
if ( len_trim(str_tmp) == FMS_FILE_LEN ) then
write(UNIT=text, FMT='(I5)') FMS_FILE_LEN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to revert this to the original code here as the LENGTH here is not referring to a file length or pathname.

call mpp_error(FATAL, 'get_ascii_file_num_lines: Length of output string ('//trim(text)//&
& ' is too small. Increase the LENGTH value.')
& ' is too small. Increase the FMS_MAX_FILE_LEN cpp value.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to revert this as well.

@@ -126,7 +126,7 @@ module time_interp_external2_mod
!> Holds filename and file object
!> @ingroup time_interp_external2_mod
type, private :: filetype
character(len=128) :: filename = ''
character(len=FMS_PATH_LEN) :: filename = ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a filename, shouldn't it be limited using FMS_FILE_LEN? If so, need to change the platform module use statement as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think this one should be a file length, fixed with f9cac03

@rem1776
Copy link
Contributor Author

rem1776 commented Aug 5, 2024

Are there any tests codes that would need changed as well?

@bensonr I skipped the tests because most file/path names used in the tests are typically set once and not modified so there's not really a chance of one being too short. There's a couple cases where a filename can be set by a namelist, but then the values are just set in the test scripts so it would always be set to a value we control.

Do you think they should be updated as well?

@bensonr
Copy link
Contributor

bensonr commented Aug 5, 2024

Are there any tests codes that would need changed as well?

@bensonr I skipped the tests because most file/path names used in the tests are typically set once and not modified so there's not really a chance of one being too short. There's a couple cases where a filename can be set by a namelist, but then the values are just set in the test scripts so it would always be set to a value we control.

Do you think they should be updated as well?

@rem1776 - hopefully we'll find out during testing or via the automated ci/cd

@rem1776 rem1776 merged commit a5de6a5 into NOAA-GFDL:main Aug 5, 2024
26 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consistent maximum length of filenames?
3 participants