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 errmsg to check_allocate abort message #311

Merged
merged 7 commits into from
Dec 19, 2024

Conversation

jimmielin
Copy link
Member

Fixes #297

Following up from the tropopause_find PR I've updated check_allocate to take in errmsg and updated the tropopause_climo_read to use it and other places within SIMA. I did not update all instances of check_allocate, particularly those in dynamics and in cpl/nuopc as I was not sure if they were brought in externally or not.

If the optional errmsg argument is present a linebreak is added to the end of the abort message using the new_line intrinsic (Fortran 2003). Since errmsg in allocate is a F2003 feature I think this is safe to use? It can otherwise be removed, it's just used to make the output prettier.

This is what it looks like:

 ERROR: cam_thermo_init: Allocate of 'test(test)' failed with code 1. Memory highwater is     641.32 mb, current memory usage is      42.41 mb
Allocation failed with: Hello world this is not really a failure but just a test at /somewhere/CAM-SIMA/src/data/cam_thermo.F90:203

or an actual example made possible by a duplicate allocation...

 ERROR: cam_thermo_init: Allocate of 'kmcnd(pcols,pverp)--2test' failed with code 5014. Memory highwater is     641.35 mb, current memory usage is      43.08 mb
Allocation failed with: Attempt to allocate an allocated object at /somewhere/CAM-SIMA/src/data/cam_thermo.F90:207

@jimmielin jimmielin added the enhancement New feature or request label Oct 8, 2024
@jimmielin jimmielin self-assigned this Oct 8, 2024
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Thanks for adding this feature @jimmielin! I did have one (optional) request, which is to change the beginning of the full check_allocate error message from Allocate of <varname> to Allocation of <varname>, as I realized that is probably more grammatically correct. Of course don't feel like you have to if it will hold up this PR. Thanks again!

@jimmielin
Copy link
Member Author

Thanks @nusbaume! Updated to Allocation of <varname>

Copy link
Collaborator

@peverwhee peverwhee left a comment

Choose a reason for hiding this comment

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

one small thing but it doesn't hold up my approval! thanks @jimmielin

@@ -122,6 +122,7 @@ subroutine tropopause_climo_read_file()
real(kind_phys), parameter :: d2r=pi/180._kind_phys, zero=0._kind_phys, twopi=pi*2._kind_phys
character(len=shr_kind_cl) :: locfn
character(len=shr_kind_cm) :: errmsg
Copy link
Collaborator

Choose a reason for hiding this comment

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

would it make sense to change this errmsg to "shr_kind_cl" as well to match the other error messages? It's probably unlikely to be too short, but would be consistent with the other usage.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, updated!

@jimmielin
Copy link
Member Author

Regression tests passed subject to existing failures

aux_sima_intel_20241219072857: 9 tests
  SMS_Ln9.mpasa480_mpasa480.FKESSLER.derecho_intel.cam-outfrq_kessler_mpas_derecho (Overall: PEND) details:
    PEND SMS_Ln9.mpasa480_mpasa480.FKESSLER.derecho_intel.cam-outfrq_kessler_mpas_derecho RUN
  SMS_Ln9.ne5pg3_ne5pg3_mg37.FCAM7.derecho_intel.cam-outfrq_se_cslam_analy_ic (Overall: PEND) details:
    PEND SMS_Ln9.ne5pg3_ne5pg3_mg37.FCAM7.derecho_intel.cam-outfrq_se_cslam_analy_ic SHAREDLIB_BUILD RERUN


aux_sima_gnu_20241219072901: 9 tests
  SMS_Ln9.mpasa480_mpasa480.FKESSLER.derecho_gnu.cam-outfrq_kessler_mpas_derecho (Overall: FAIL) details:
    FAIL SMS_Ln9.mpasa480_mpasa480.FKESSLER.derecho_gnu.cam-outfrq_kessler_mpas_derecho RUN time=20
  SMS_Ln9.ne5pg3_ne5pg3_mg37.FCAM7.derecho_gnu.cam-outfrq_se_cslam_analy_ic (Overall: PEND) details:
    PEND SMS_Ln9.ne5pg3_ne5pg3_mg37.FCAM7.derecho_gnu.cam-outfrq_se_cslam_analy_ic SHAREDLIB_BUILD RERUN

@jimmielin jimmielin merged commit 4501d8d into ESCOMP:development Dec 19, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Tag
Development

Successfully merging this pull request may close these issues.

3 participants