Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
icepack_shortwave: zero-initialize local variables for shortwave comp…
…onents In shortwave_ccsm3, the local variables 'l_fswthru_{v,i}d{r,f}' are sent to 'absorbed_solar' and then the arguments 'fswthru_{v,i}d{r,f}' are reset to the values of the respective local variables. However, the call to 'absorbed_solar' is conditional on 'aicen(n) > puny', so it's possible that not all elements of the arrays are set after the call to absorbed_solar. This lead to uninitialized values in 'fswthru_{v,i}d{r,f}' and thus potential crashes if compiling with NaNs initialization. Fix that by initializing the local variables to zero. In run_dEdd, the equivalent local variables 'l_fswthrun_{v,i}d{r,f}' are sent to 'shortwave_dEdd' as arguments 'fswthru_{v,i}d{r,f}', outside of any 'if' statement, and these arguments are zero-initialized in 'shortwave_dEdd', also outside of any 'if' statement. So in this case there is no risk that uninitialized values will creep in the 'fswthrun_{v,i}d{r,f}' arrays when they are reset to the values of 'l_fswthrun_{v,i}d{r,f}' at the end of 'run_dEdd'. But to be on the safe side with regards to potential future code changes, also zero-initialize these local variables. For the same reason, also zero-initialize the equivalent local variables in icepack_step_radiation.
- Loading branch information