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

Adding method to check namelist in any order, tested with NAG Fortran. #801

Merged
merged 6 commits into from
Dec 16, 2022

Conversation

daveh150
Copy link
Contributor

@daveh150 daveh150 commented Dec 2, 2022

PR checklist

  • Short (1 sentence) summary of your PR:
    Check namelist in any order to support NAG compiler.
  • Developer(s):
    David Hebert
  • Suggest PR reviewers from list in the column to the right.
  • Please copy the PR test results link or provide a summary of testing completed below.
    ran quicksuite, modified for tests to run with 1 PE. Compiled main branch with gnu for baseline.
    Then compiled check_namelist2 branch with gnu and nag compilers. Results show all tests past.
    Also added errors to namelists. Code crashes with message on what line has error.:

(abort_ice)ABORTED:
(abort_ice) called from ice_init.F90
(abort_ice) line number 644
(abort_ice) error = (input_data)ERROR: grid_nml reading test_namelist = .true.

  • How much do the PR code changes differ from the unmodified code?
    • bit for bit
    • different at roundoff level
    • more substantial
  • Does this PR create or have dependencies on Icepack or any other models?
    • Yes
    • No
  • Does this PR update the Icepack submodule? If so, the Icepack submodule must point to a hash on Icepack's main branch.
    • Yes
    • No
  • Does this PR add any new test cases?
    • Yes
    • No
  • Is the documentation being updated? ("Documentation" includes information on the wiki or in the .rst files from doc/source/, which are used to create the online technical docs at https://readthedocs.org/projects/cice-consortium-cice/. A test build of the technical docs will be performed as part of the PR testing.)
    • Yes
    • No, does the documentation need to be updated at a later time?
      • Yes
      • No
  • Please provide any additional information or relevant details below:

Re-opening #788. Implemented method to rewind and search ice_in for namelist, then read namelist and check for errors. This is done through addition of subroutine goto_nml_group in ice_namelist_mod.F90. I added new file because of circular dependencies between ice_in.F90 and ice_domain.F90.

I have a trial NAG FORTRAN compiler license for a few more days, this has been tested with serial NAG and GNU compiler. I inserted error in namelists and run crashes with message like:

(abort_ice)ABORTED:
(abort_ice) called from ice_init.F90
(abort_ice) line number 644
(abort_ice) error = (input_data)ERROR: grid_nml reading test_namelist = .true.

I also reordered the namelists, putting grid_nml before setup_nml, and both compilers worked.

I admittedly do not have mpi fortran compiled with NAG, but since this is only a namelist check I am hoping mpi vs. serial won't matter. If someone has access to machine with NAG FORTRAN MPI to do a more thorough test that would be helpful.

Disclosure, after much googling for namelist, method is based on this link:
https://stackoverflow.com/questions/57553995/how-to-handle-an-optional-group-in-a-fortran-namelist

…amelist_mod.F90 to search for namelist in ice_in.
@apcraig
Copy link
Contributor

apcraig commented Dec 2, 2022

Thanks @daveh150 for continuing to pursue this! This looks great assuming it's robust. I can run some tests on more compilers/platforms (although I don't have access to nag at the moment either). One comment, rather than create a new file for the new subroutine, how about dropping it into cicecore/shared/ice_fileunits.F90. I think it's both a reasonable place and shouldn't have any problems with circular logic. Thoughts?

@daveh150
Copy link
Contributor Author

daveh150 commented Dec 2, 2022

Thanks @apcraig! Sure, moving the goto_nml_group to ice_fileunits.F90 seems the best location without adding more files. I'll make that move now.

@daveh150
Copy link
Contributor Author

daveh150 commented Dec 2, 2022

I moved the goto_ nml subroutine to ice_fileunits.F90. If there are any other thoughts or suggestions please let me know.

@apcraig
Copy link
Contributor

apcraig commented Dec 5, 2022

FYI, I plan to defer this PR until next week, after the release. I want to be able to adequately test on several platforms and make sure everything is robust. We've had issue in the past, although I think this solution should be fine. Just don't want to introduce unnecessary risk this late. Thanks.

@daveh150
Copy link
Contributor Author

daveh150 commented Dec 5, 2022 via email

@@ -305,24 +309,41 @@ subroutine init_hist_bgc_2D
!-----------------------------------------------------------------

if (my_task == master_task) then
write(nu_diag,*) subname,' Reading icefields_bgc_nml'
nml_name = 'icefields_bgc_nml'
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this line needs an extra space for alignment.

@@ -165,6 +167,7 @@ subroutine input_data
integer (kind=int_kind) :: rplvl, rptopo
real (kind=dbl_kind) :: Cf, ksno, puny
character (len=char_len) :: abort_list
character(len=char_len) :: nml_name ! namelist name
Copy link
Contributor

Choose a reason for hiding this comment

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

alignment with line above/below?


call abort_ice(subname//'ERROR: '//trim(nml_name)//' reading '// &
trim(tmpstr2), &
file=__FILE__, line=__LINE__)
Copy link
Contributor

Choose a reason for hiding this comment

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

combine onto prior line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found the line to be too long with the entire concatenated string on a single line. I prefer to leave it as it, but if others find it too confusing I can put it all on one line.

Copy link
Contributor

Choose a reason for hiding this comment

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

I might combine the last two lines, tmpstr2 and file/line, leaving first line alone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I see now. I combined the last to to read trim (tmpstr2), file=...

I think I have all other intents/spacings updated. Let me know if I missed anything. Thanks!

read(nu_nml,fmt='(A)') tmpstr2
call abort_ice(subname//'ERROR: '// trim(nml_name)//' reading '// &
trim(tmpstr2), &
file=__FILE__, line=__LINE__)
Copy link
Contributor

Choose a reason for hiding this comment

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

same, check other instances too

@apcraig
Copy link
Contributor

apcraig commented Dec 16, 2022

Testing seems to be good. I think we can merge this. Maybe one more quick pass looking at the indentation things noted above, then we can merge. Thanks.

@daveh150
Copy link
Contributor Author

daveh150 commented Dec 16, 2022 via email

@apcraig apcraig merged commit eebb350 into CICE-Consortium:main Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants