From e4a5e5849abfd2164458741681b5b34f140ff13c Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 11 Jul 2024 05:57:33 -0600 Subject: [PATCH] make sure variables are allocated before deallocating (#480) --- mediator/med_io_mod.F90 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mediator/med_io_mod.F90 b/mediator/med_io_mod.F90 index f4abadaf..6966a37d 100644 --- a/mediator/med_io_mod.F90 +++ b/mediator/med_io_mod.F90 @@ -1086,7 +1086,15 @@ subroutine med_io_write_FB(io_file, FB, whead, wdata, nx, ny, nt, & call pio_syncfile(io_file) call pio_freedecomp(io_file, iodesc) endif - deallocate(ownedElemCoords, ownedElemCoords_x, ownedElemCoords_y) + if(allocated(ownedElemCoords)) then + deallocate(ownedElemCoords) + endif + if(allocated(ownedElemCoords_x)) then + deallocate(ownedElemCoords_x) + endif + if(allocated(ownedElemCoords_y)) then + deallocate(ownedElemCoords_y) + endif if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO)