Skip to content

Commit

Permalink
modsamptend: fix closing of netCDF file
Browse files Browse the repository at this point in the history
  • Loading branch information
fjansson committed Dec 13, 2024
1 parent 9a74ec8 commit 5cd9417
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/modsamptend.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1602,12 +1602,23 @@ end subroutine writenetcdf_proc
!> Cleans up after the run
subroutine exitsamptend
use modstat_nc, only: exitstat_nc,lnetcdf
use modmpi, only: myid
implicit none

if (.not. lsamptend) return
if(isamptot == 0) return
if(.not.(lnetcdf)) return
call exitstat_nc(ncid)

if (lprocblock) then
! Each block writes its own budget to its own file
call exitstat_nc(ncid)
else
! We average over all blocks and write to a single file
if (myid==0) then
call exitstat_nc(ncid)
end if
end if

if (lsamptendu) deallocate (uptm, upmn, upav, ust)
if (lsamptendv) deallocate (vptm, vpmn, vpav, vst)
if (lsamptendw) deallocate (wptm, wpmn, wpav, wst)
Expand Down

0 comments on commit 5cd9417

Please sign in to comment.