Skip to content

Commit

Permalink
allow user to omit initial values of CLAM/BA/SAV/Marsh in hotstart.nc
Browse files Browse the repository at this point in the history
  • Loading branch information
wzhengui committed Jul 31, 2024
1 parent 30fb71a commit 2cf23b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/Hydro/schism_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5563,15 +5563,20 @@ subroutine schism_init(iorder,indir,iths,ntime)
do l=1,wqhot(k)%dims(2)
if(myrank==0) then
j=nf90_inq_varid(ncid2,trim(adjustl(wqhot(k)%name)),mm)
if(j/=NF90_NOERR) call parallel_abort('hotstart.nc, ICM 1: '//trim(adjustl(wqhot(k)%name)))
if(wqhot(k)%ndim==1) j=nf90_get_var(ncid2,mm,buf3(1:ne_global),(/1/),(/ne_global/))
if(wqhot(k)%ndim==2) j=nf90_get_var(ncid2,mm,buf3(1:ne_global),(/l,1/),(/1,ne_global/))
if(wqhot(k)%ndim==3) j=nf90_get_var(ncid2,mm,buf3(1:ne_global),(/m,l,1/),(/1,1,ne_global/))
if(j/=NF90_NOERR) call parallel_abort('hotstart.nc, ICM 2: '//trim(adjustl(wqhot(k)%name)))
if(j/=NF90_NOERR) then !skip reading variable, and pass -9999
buf3(1:ne_global)=-9999.0
write(16,*) 'WARNING ICM hotstart.nc: variable not found (use values in icm.nml), '//trim(adjustl(wqhot(k)%name))
else
if(wqhot(k)%ndim==1) j=nf90_get_var(ncid2,mm,buf3(1:ne_global),(/1/),(/ne_global/))
if(wqhot(k)%ndim==2) j=nf90_get_var(ncid2,mm,buf3(1:ne_global),(/l,1/),(/1,ne_global/))
if(wqhot(k)%ndim==3) j=nf90_get_var(ncid2,mm,buf3(1:ne_global),(/m,l,1/),(/1,1,ne_global/))
if(j/=NF90_NOERR) call parallel_abort('ICM hotstart.nc, failed in read: '//trim(adjustl(wqhot(k)%name)))
endif
endif
call mpi_bcast(buf3,ns_global,rtype,0,comm,istat)
do i=1,ne_global
if(iegl(i)%rank==myrank) then
if(abs(buf3(i)+9999.d0)<1.d-6) cycle
if(wqhot(k)%ndim==1) wqhot(k)%p1(iegl(i)%id)=buf3(i)
if(wqhot(k)%ndim==2) wqhot(k)%p2(l,iegl(i)%id)=buf3(i)
if(wqhot(k)%ndim==3) wqhot(k)%p3(m,l,iegl(i)%id)=buf3(i)
Expand Down
9 changes: 8 additions & 1 deletion src/ICM/icm_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1041,16 +1041,23 @@ subroutine icm_vars_init
if(iPh==1) ppatch(i)=nint(ppatch0)
if(jsav/=0) then
spatch(i)=nint(spatch0); sav(:,i)=sav0; call get_canopy(i)
if(jsav==2) EP(i)=EP0; TEP(i)=EP0*sav0(1)
if(jsav==2) then; EP(i)=EP0; TEP(i)=EP0*sav0(1); endif
if(spatch(i)==0) then !zero for other region
sav(:,i)=0; sht(i)=0
if(jsav==2) then; EP(i)=0; TEP(i)=0; endif
endif
endif
if(jmarsh==1) then
vpatch(i)=nint(vpatch0); vmarsh(:,:,i)=vmarsh0; call get_canopy(i)
if(vpatch(i)==0) then; vmarsh(:,:,i)=0; vht(:,i)=0; endif
endif
if(iBA==1) then
gpatch(i)=nint(gpatch0); gBA(i)=gBA0
if(gpatch(i)==0) gBA(i)=0 !zero for other region
endif
if(iClam==1) then
cpatch(i)=nint(cpatch0); CLAM(1:nclam,i)=clam0
if(cpatch(i)==0) CLAM(1:nclam,i)=0 !zero for other region
endif
enddo

Expand Down

0 comments on commit 2cf23b6

Please sign in to comment.