Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ice_calendar: zero-initialize 'nstreams' (CICE-Consortium#752)
The variable ice_calendar::nstreams, which corresponds to the number of output history streams to use for the run, is initialized in ice_history::init_hist depending on the number of non-'x' elements in 'histfreq' in the namelist. However, the code does use 'nstreams' before ice_history::init_hist is called, in ice_calendar::calendar when called from ice_calendar::init_calendar. Both 'init_calendar' and 'init_hist' are called from CICE_InitMod::cice_init, in that order, such that the loop that initializes 'write_history' in 'calendar' uses 'nstreams' uninitialized. 'calendar' ends up being called at least once more during 'cice_init', from ice_calendar::advance_timestep, at which point 'nstreams' is correctly defined and 'write_history' is thus correctly initialized, before its first use in 'accum_hist'. To avoid using 'nstreams' uninitialized in the first call to 'calendar' from 'init_calendar', initialize it to zero in 'init_calendar' before calling 'calendar'. This issue was discovered by compiling using the '-init=huge' flag of the Intel compiler.
- Loading branch information