Closed spencerkclark closed 10 months ago
@spencerkclark you are correct. gam(i,km) was incorrectly not specified in the iv .eq. -2
branch. I believe it should be specified the same way as in the interior (gam(i,k) = d4(i) / bet
). This is an oversight on my part.
@laurenchilutti I haven't been assigned an issue before. Should I test the code and submit a patch? Thanks.
@lharris4 I did not look closely before assigning this - I had thought this was a PR and I was adding you as a reviewer. Please disregard the assignment.
@laurenchilutti Thank you.
Thanks @lharris4 — I went ahead and made a PR with your suggested fix, and confirmed that it fixed the reproducibility issue: #302. I'm leaning on your expertise regarding the scientific correctness of this change.
Describe the bug
Debugging the source of non-reproducibility for a configuration of SHiELD turned up the use of uninitialized values in a local array in the
cs_profile
subroutine of thefv_mapz
module. The issue occurs only wheniv == -3
, which corresponds to one of two possible modes for use when remapping the vertical velocity, the other beingiv == -2
. I have verified this with additional means, but the issue can be identified by inspecting the lines of code clipped below, considering the case wheniv == -3
: https://github.com/NOAA-GFDL/GFDL_atmos_cubed_sphere/blob/e94dc4b57c12cc399f6d319dc5733143fc6c718b/model/fv_mapz.F90#L1988-L2071 The issue specifically stems from the localgam
array, which is declared in line 1988 without any initial assignment. Wheniv == -3
it gets values for level1
in line 2025 and levels2
throughkm - 1
(inclusive) in line 2034, but is not assigned values for levelkm
prior to being used in line 2068. This leads to undefined / non-reproducible behavior at runtime.To Reproduce
Run SHiELD in non-hydrostatic mode with
fv_core_nml.kord_wz
less than zero andabs(fv_core_nml.kord_wz) > 7
, e.g.fv_core_nml.kord_wz = -9
. This tells the model to useiv == -3
andcs_profile
when remapping the vertical velocity:https://github.com/NOAA-GFDL/GFDL_atmos_cubed_sphere/blob/e94dc4b57c12cc399f6d319dc5733143fc6c718b/model/fv_mapz.F90#L411-L424
Expected behavior
I would expect values to be defined for
gam(:,km)
wheniv == -3
prior to it being used in line 2068.System Environment
Describe the system environment, include: