-
Notifications
You must be signed in to change notification settings - Fork 147
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
Use of uninitialized data in ugwp_driver_v0.F #1103
Comments
@climbfuji Thanks for identifying this. Sure seems like a bug to me. |
This is definitely a bug. However, this code is in subroutine 'gwdps_v0' that is only called by the CCPP scheme 'cires_ugwp' when 'do_ugwp=true'. I see there are still some suites (e.g., FV3_GFS_v16, FV3_RRFS_v1beta) that include this scheme. The later suites use the 'unified_ugwp' and 'ugwpv1_gsldrag' schemes, which do not call 'gwdps_v0', but instead call 'gwdps_run' or 'drag_suite', which are free of the corresponding bug. (One caveat is that the bug exists on lines 437-438 of module 'cires_ugwpv1_oro': I am planning on doing a code clean-up eventually, and these subroutines that contain the bug will be removed. |
@mdtoyNOAA Thanks. Unfortunately, the NRL code still uses this. I am seeing this a few lines further down:
This fixes the NaN for bnv2 for k=1, but by that time it has already been assigned to RI_N(i,k+1) (and that one doesn't get fixed. Would it be ok to move the calculation of RI_N to its own k-loop after bnv2 (i,1) is set to bnv2(i,2)? |
Or, even better:
? This way:
|
@climbfuji It looks like
This wouldn't work because SHR2 is calculated at each level in the k-loop, so it would have to become a stored vector, i.e., SHR2(k) |
yes, therefore the second suggestion to use max(k,2) in the current place in the code |
@climbfuji Oops! Sorry, I got mixed up on the order of your suggestions. Yes, that's the way to do it: |
Thanks! I'll make the change in the NRL fork, and if it all works as expected I'll create the PR for upstream (NCAR ccpp-physics main) to close this issue. |
Please take a look at:
ccpp-physics/physics/GWD/ugwp_driver_v0.F
Line 351 in a3f4d93
In the nested
do
loopthe variable
bnv2(i,k+1)
is calculated - but in the next line,RI_N(I,K+1) = Bnv2(i,k)/SHR2
is calculated from thei,k
value. The arraybnv2
is not initialized prior to this loop - in other words, in the first pass of the loop overk
(k=1
),ri_n(i,2)
is calculated from an uninitializedbnv(i,1)
.The text was updated successfully, but these errors were encountered: