Check that self%perturbation is allocated before trying to apply perturbations#29
Check that self%perturbation is allocated before trying to apply perturbations#29dougiesquire merged 1 commit intomasterfrom
self%perturbation is allocated before trying to apply perturbations#29Conversation
…urbations This prevents 'invalid memory reference.' errors when using GCC
self%perturbation is allocated before trying to apply perturbations
|
@anton-seaice could please review. This allows building and running ACCESS-OM2 with GCC (see here) and doesn't change answers with oneapi (see here) |
|
I'm sure i've over thought this Here: libaccessom2/libforcing/src/forcing_config.F90 Lines 176 to 182 in 23f82af if num_perturbations is 0, then it should return (and not allocate perturbations) The change lined in this PR could just be
|
|
We almost need a config / repro test with some perturbations included |
|
I'm possibly not understanding what you're saying, but I think: will still allocate the array, but it's size will be zero. To be clear, I didn't add the check that |
|
Yeah - that's right. But why allocate an array that's not needed? Feels neater just not to allocate it and treat all cases of having no pertubations to apply the same ? |
|
I think I'm fine with what I currently have. It's less code changes and, more importantly, it's what I've tested and I'm not that interested in spending more time on this 😅 |
|
Yeah - its also probably lowest risk |
anton-seaice
left a comment
There was a problem hiding this comment.
Thanks Dougie - it looks like if no peturbations section is provided in the forcing.json then this array isn't allocated, so this make sense
This PR adds a check to
libforcing/src/forcing_field.F90::forcing_field_apply_perturbationsto ensure that thatself%perturbationis allocated before trying to apply perturbations.This prevents errors like:
when running with GCC-compiled binaries