ai2cm / fv3gfs-fortran

FV3GFS Fortran for internal development at AI2
Other
6 stars 9 forks source link

Fix bug in `fv_diagnostics.F90` that prevents outputting z500 and cape #375

Closed spencerkclark closed 1 year ago

spencerkclark commented 1 year ago

There is a bug in the fine resolution diagnostics code that prevents outputting any height-related variable and CAPE at the same time. The issue relates to attempting to allocate a work variable twice.

At line 2816 of file tools/fv_diagnostics.F90
Fortran runtime error: Attempting to allocate already allocated variable 'a3'

This PR fixes this by providing a unique 3D allocatable field for the CAPE diagnostic to use. One could argue that maybe we should find where a3 could potentially be deallocated earlier, which would allow us to reallocate it again, but using a unique allocatable field feels safest (it isolates the effect of this PR to the CAPE diagnostic). We have not run into this previously since we have not output the CAPE diagnostic before.

This notebook demonstrates the existing bug; this notebook illustrates that this issue was fixed.

We update the default regression tests to include cape and z500 as diagnostics, which exercise this code. Naturally checksums for those diagnostics tapes needed to be updated.