NOAA-GFDL/GFDL_atmos_cubed_sphere

Uninitialized variable inf remap_restart

Closed this issue · 0 comments

Describe the bug
The model crashes when trying to read data from a restart file that has a different number of vertical levels than you
want to use in the run. More specifically, when npz .ne. npz_rst. The cause of this is the use of the uninitialized variable
n used here before it is assigned:

call rst_remap(npz_rst, npz, isc, iec, jsc, jec, isd, ied, jsd, jed, ntracers, ntprog, &
delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r,&
Atm(n)%delp, Atm(n)%u, Atm(n)%v, Atm(n)%w, Atm(n)%delz, Atm(n)%pt, Atm(n)%q, &
Atm(n)%qdiag, ak_r, bk_r, Atm(n)%ptop, Atm(n)%ak, Atm(n)%bk, &
Atm(n)%flagstruct%hydrostatic, Atm(n)%flagstruct%make_nh, Atm(n)%domain, &
Atm(n)%gridstruct%square_domain)

To Reproduce
Perform a run and set npz_rst to a value that is different from npz in fv_core_nml.

Expected behavior
The model should not crash, and be able to remap the restart data to correct number of vertical levels.

System Environment
It' caused by undefined compiler behavior, so I'd expect to see it on all systems.

Additional context
It can be solved by setting n = 1.