From de7fb2d951aecdbe9338562cd54b9519413b87b0 Mon Sep 17 00:00:00 2001 From: Tomas Torsvik Date: Tue, 3 Dec 2024 10:50:16 +0100 Subject: [PATCH] Always allocate shelfmask array --- hamocc/mo_read_shelfmask.F90 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hamocc/mo_read_shelfmask.F90 b/hamocc/mo_read_shelfmask.F90 index 0953172a..2d237231 100644 --- a/hamocc/mo_read_shelfmask.F90 +++ b/hamocc/mo_read_shelfmask.F90 @@ -62,6 +62,18 @@ subroutine ini_read_shelfmask(kpie,kpje,kbnd,pbath,omask) integer :: i,j,errstat,ncid,ncstat real,allocatable :: mask(:,:) + ! Always allocate field to hold shelfsea mask + if(mnproc.eq.1) then + write(io_stdo_bgc,*)'Memory allocation for variable shelfmask ...' + write(io_stdo_bgc,*)'First dimension : ',kpie + write(io_stdo_bgc,*)'Second dimension : ',kpje + endif + allocate(shelfmask(kpie,kpje),stat=errstat) + allocate(mask(kpie,kpje),stat=errstat) + if(errstat.ne.0) stop 'not enough memory shelfmask' + shelfmask(:,:) = .false. + mask = 0. + ! Check, if we are going to run with shelf-sea water residence time tracers if (.not.use_shelfsea_res_time) then if (mnproc.eq.1) then @@ -82,18 +94,6 @@ subroutine ini_read_shelfmask(kpie,kpje,kbnd,pbath,omask) write(io_stdo_bgc,*) '... using internal bathymetry data to reconstruct the mask ' endif - ! Allocate field to hold shelfsea mask - if(mnproc.eq.1) then - write(io_stdo_bgc,*)'Memory allocation for variable shelfmask ...' - write(io_stdo_bgc,*)'First dimension : ',kpie - write(io_stdo_bgc,*)'Second dimension : ',kpje - endif - allocate(shelfmask(kpie,kpje),stat=errstat) - allocate(mask(kpie,kpje),stat=errstat) - if(errstat.ne.0) stop 'not enough memory shelfmask' - shelfmask(:,:) = .false. - mask = 0. - if (file_exists) then ! read shelf sea mask from file if (mnproc.eq.1) then