NOAA-GFDL / GFDL_atmos_cubed_sphere

The GFDL atmos_cubed_sphere dynamical core code
Other
55 stars 118 forks source link

Array size mismatch in atmosphere.F90 #34

Closed thomas-robinson closed 4 years ago

thomas-robinson commented 4 years ago

When I run AM4 with the gnu compiler on gaea (prod), I encounter an error with an invalid reference to memory. When running in debug mode, the following error occurs:

Fortran runtime error: Array bound mismatch for dimension 4 of array 'qtend' (4/26)

This happens on line 437 of driver/GFDL/atmosphere.F90

   if ( any((/ id_qdt_dyn, id_qldt_dyn, id_qidt_dyn, id_qadt_dyn /) > 0) .or. &
        query_cmip_diag_id(ID_tnhusa) ) qtend(:, :, :, :) = Atm(mygrid)%q (isc:iec, jsc:jec, :, :)

Are qtend and Atm(mygrid)%q supposed to be the same size?

bensonr commented 4 years ago

This is a poor programming choice as the behavior will be compiler dependent. Traditionally there has been nothing in the standard about implied loops and whether the extents are right hand defined or left hand defined. Regardless, the qtend array is explicity defined to have a length of 4, because is is supposed to contain only the water vapor + 3 condensate species as defined for AM3/AM4.

Does this need to be fixed for 2020.02 or can it wait for another release?

lharris4 commented 4 years ago

Hi, Tom, Rusty. S-J always encouraged explicit loops when doing an array assignment unless the assignment is to a single value.

Lucas

On Mon, Apr 27, 2020 at 2:17 PM bensonr notifications@github.com wrote:

This is a poor programming choice as the behavior will be compiler dependent. Traditionally there has been nothing in the standard about implied loops and whether the extents are right hand defined or left hand defined. Regardless, the qtend array is explicity defined to have a length of 4, because is is supposed to contain only the water vapor + 3 condensate species as defined for AM3/AM4.

Does this need to be fixed for 2020.02 or can it wait for another release?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/NOAA-GFDL/GFDL_atmos_cubed_sphere/issues/34#issuecomment-620149618, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMUQRVBVE5MZYEVMZN3AXQTROXDZXANCNFSM4MSAMBQA .

bensonr commented 4 years ago

As this logic is purely for a diagnostic added by the physics team and only affects the GFDL driver, I will fix this change for the GNU compiler. Look for a coming PR for you to approve.

thomas-robinson commented 4 years ago

This can wait, but it is needed for running with gfortran