Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing unallocated array dtdt (dtdt_m) to subroutine Lagrangian_to_Eulerian #29

Closed
climbfuji opened this issue Jun 29, 2020 · 2 comments · Fixed by #50
Closed

Passing unallocated array dtdt (dtdt_m) to subroutine Lagrangian_to_Eulerian #29

climbfuji opened this issue Jun 29, 2020 · 2 comments · Fixed by #50

Comments

@climbfuji
Copy link

This affects the non-CCPP option only.

Subroutine Lagrangian_to_Eulerian expects the array dtdt (or dtdt_m internally) to be allocated: fv_mapz.F90, around line 200:

real, intent(inout)::   dtdt(is:ie,js:je,km)

In fv_dynamics.F90, however, this array is only allocated under certain conditions:

if ( idiag%id_mdt > 0 .and. (.not. do_adiabatic_init) ) then
       allocate ( dtdt_m(is:ie,js:je,npz) )
...

This can go very wrong and lead to model crashes or data corruption (luckily, it hasn't on the platforms and for the compilers we have been using so far; but we have seen similar cases leading to model crashes in the physics). A simple solution is to always allocate the array or make it an automatic array so that it gets allocated only once and only reset every time. Or make the variable declaration in Lagrangian_to_Eulerian an assumed-size declaration, in which case passing an unallocated object should be allowed:

real, intent(inout)::   dtdt(:,:,:)

This affects the non-CCPP option only. For CCPP the corresponding array is a member of the CCPP_interstitial data type and is always allocated.

@junwang-noaa
Copy link
Collaborator

Dom, is this issue resolved?

@climbfuji
Copy link
Author

No, this is still an issue and needs to be addressed. The solution, however, will be easy now that we can remove the IPD related code - as soon as that is done and only the CCPP version remains, the array will always be allocated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants