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

Consistency of fortran string lengths #49

Open
jedwards4b opened this issue Jan 3, 2020 · 12 comments
Open

Consistency of fortran string lengths #49

jedwards4b opened this issue Jan 3, 2020 · 12 comments
Assignees
Labels
bug Something isn't working post release issues that will be fixed after the release

Comments

@jedwards4b
Copy link
Collaborator

I ran into a problem with the filename_base string setting in fv3 model_configure:
The length of this string as declared in io/module_fv3_io_def.F90 is 255, however in testing
we have found the length to be limited to 80 characters. It is very difficult to pinpoint exactly where this restriction is introduced as there is no consistency in the declaration of string lengths in fv3 - in this particular case I found that this variable is used in module_fcst_grid_comp.F90 with length 128 and in fv3_cap.F90 (variable fcstItemNameList) with length 80.

I would like to propose that all character lengths be declared as
character(len=lenvar)
where lenvar is defined in a module of constants and that variables of the form
character(nn) or character(len=nn) where nn is integer be removed from the current code and banned from future contributions.

@jedwards4b jedwards4b added the bug Something isn't working label Jan 3, 2020
@rsdunlapiv
Copy link
Collaborator

@junwang-noaa can you please comment on this

@rsdunlapiv rsdunlapiv changed the title consistancy of fortran string lengths Consistency of fortran string lengths Jan 6, 2020
@junwang-noaa
Copy link

Rocky,

I do not know how the testing is done. But from the code, it looks to me the fieldname_base is defined in io/module_fv3_io_def.F90 as 255 character string:

character(255),dimension(:),allocatable :: filename_base

And it gets its value from ESMF calls in fv3_cap.F90, does not change value since then:

use module_fv3_io_def, only: num_pes_fcst,write_groups,app_domain, &
num_files, filename_base, ....
...
allocate(filename_base(num_files))
CALL ESMF_ConfigFindLabel(CF,'filename_base:',rc=RC)
do i=1,num_files
CALL ESMF_ConfigGetAttribute(config=CF,value=filename_base(i), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=LINE, file=FILE)) return
enddo
if(mype == 0) print *,'af nems config,num_files=',num_files, &
'filename_base=',filename_base

It seems the ESMF call ESMF_ConfigGetAttribute has problem to get the 255 character string? Thanks

@jedwards4b
Copy link
Collaborator Author

For reasons that are not clear to me the field bundle names are associated with filename_base,
in fv3cap.F90 variable fcstItemNameList is declared with length 80 and used to set these names, it is in the cap, not in esmf where the restriction to 80 characters occurs.

@junwang-noaa
Copy link

junwang-noaa commented Jan 9, 2020 via email

@jedwards4b
Copy link
Collaborator Author

fcstItemNameList is not changing fieldname_base, on the contrary fieldname_base (with length 255) is used in the creation of fcstItemNameList (length 80) which presents a practical limit of 80 on the length of fieldname_base - if it is any longer you get an error due to the truncation of strings in fcstItemNameList.

@junwang-noaa
Copy link

So, if I understand correctly, you are trying to get 255 character fcstItemNameList, is it correct? If that is the case, please be aware that the fieldname_base is combined with strings for interpolation method to mark the field bundle name. In other words, setting fcstItemNameList string names to 255 won't guarantee you can set 255 characters in filename_base since the 255 fieldname_base may mess up the interpolation method. A solution might be not to combine the interpolation method with the field bundle names, instead set an attribute for the interpolation method for the corresponding field bundles.

@jedwards4b
Copy link
Collaborator Author

I opened the issue to point out a general problem - because there is no consistency in character string lengths the model is prone to errors of this nature that are very difficult to track down. The case of fieldname_base and fcstItemNameList is intended as an illustration of this more general issue.

@arunchawla-NOAA
Copy link
Collaborator

Is this a long term issue that can be addressed at a later date or needs to be tackled now for the release? I ask because of the limited time that we have

@jedwards4b
Copy link
Collaborator Author

The general problem does not need to be addressed prior to the release. However it would be very helpful if the PR that I have submitted to fv3atm were accepted into the ufs_release branch.

@arunchawla-NOAA arunchawla-NOAA added the post release issues that will be fixed after the release label Jan 29, 2020
@climbfuji
Copy link
Collaborator

The PR was merged (NOAA-EMC/fv3atm#43), are you ok with closing this issue?

@jedwards4b
Copy link
Collaborator Author

The PR covered one particular case of something that is a pervasive problem in the model. The issue will not be resolved anytime soon.

@mvertens
Copy link
Collaborator

mvertens commented Jan 30, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working post release issues that will be fixed after the release
Projects
None yet
Development

No branches or pull requests

6 participants