Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ice_grid: initialize 'l_readCenter' for all grid types (#758)
In 3fedc78 (Allow for read of tlat, tlon, anglet with popgrid (#463), 2020-06-24), ice_grid::init_grid2 was changed so that ice_grid::Tlatlon, which computes the TLAT and TLON arrays from ULAT and ULON, is only called if the private module variable 'l_readCenter' is false. The idea is that if the grid file contains a variable 'anglet', then it is assumed that it also contains variables 'tlon' and 'tlat', and so these fields are read directly instead of being computed. This logic, however, was only implemented in ice_grid::popgrid_nc, which sets 'l_readCenter' depending on the presence or absence of 'anglet' in the grid file. This means that if 'popgrid_nc' is not called (for example with "grid_format='bin'", in which case init_grid2 calls 'popgrid' and not 'popgrid_nc'), then 'l_readCenter' is used uninitialized in init_grid2, and so it's possible that 'Tlatlon' is not called, if 'l_readCenter' happens to be initialized to true. This in turns leads to 'TLAT' and 'TLON' being uninitialized, and the code failing when accessing these arrays if compiling with NaN initialization. Fix this by initializing 'l_readCenter' at the beginning of init_grid2, such that it is initialized for all choices of 'grid_format' and 'grid_type'. Remove the initialization in 'popgrid_nc'.
- Loading branch information