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 optional errmsg argument to check_allocate #297

Closed
peverwhee opened this issue Sep 6, 2024 · 0 comments
Closed

Add optional errmsg argument to check_allocate #297

peverwhee opened this issue Sep 6, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@peverwhee
Copy link
Collaborator

What is the feature/what would you like to discuss?

As @nusbaume pointed out in #274 , allocate() can now return an error message!

Adding an optional argument to check_allocate will allow us to pass that new message in and print that message when we endrun.

Is there anyone in particular you want to be part of this conversation?

No response

Will this change (regression test) answers?

No

Will you be implementing this enhancement yourself?

Any Software Engineer can do this

@peverwhee peverwhee added the enhancement New feature or request label Sep 6, 2024
jimmielin added a commit that referenced this issue Dec 19, 2024
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](https://gcc.gnu.org/onlinedocs/gfortran/intrinsic-procedures/newline.html)).
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 self-assigned this Dec 19, 2024
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
None yet
Development

No branches or pull requests

2 participants