subroutine initdriver
use modglobal, only : ih,ib,ie,jh,jb,je,kb,ke,kh,jhc,khc,idriver,iplane,xf,lstoreplane,nstore,Uinf,ltempeq,lmoist,pi,zf,zh,driverstore,tdriverstart,tdriverdump,timeleft,dtdriver,nsv,timee,lsdriver
use modfields, only : um
use modmpi, only : myid,nprocs
implicit none
real :: pfi, epsi
integer :: k
if (idriver==1) then
if (tdriverstart < timee) then
write(0, *) 'ERROR: tdriverstart must be greater than the elapsed time at the start of the simulation'
stop 1
end if
tdriverdump = tdriverstart
endif
if (idriver==1) then
allocate(storetdriver(1:driverstore))
allocate(storeu0driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storeumdriver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storev0driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storevmdriver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storew0driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storewmdriver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
!allocate(storee120driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
!allocate(storee12mdriver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
if (ltempeq ) then
allocate(storethl0driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storethlmdriver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
end if
if (lmoist ) then
allocate(storeqt0driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storeqtmdriver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
end if
if (nsv>0 ) then
allocate(storesv0driver(jb-jhc:je+jhc,kb-khc:ke+khc,1:nsv,1:driverstore))
allocate(storesvmdriver(jb-jhc:je+jhc,kb-khc:ke+khc,1:nsv,1:driverstore))
end if
irecydriver = iplane!+ib ! index of recycle plane from driver simulation equals iplane (read from namoptions)
else if (idriver == 2) then
allocate(storetdriver(1:driverstore))
allocate(storeu0driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storeumdriver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storev0driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storevmdriver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storew0driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storewmdriver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
!allocate(storee120driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
!allocate(storee12mdriver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(u0driver(jb-jh:je+jh,kb-kh:ke+kh))
allocate(v0driver(jb-jh:je+jh,kb-kh:ke+kh))
allocate(w0driver(jb-jh:je+jh,kb-kh:ke+kh))
!allocate(e120driver(jb-jh:je+jh,kb-kh:ke+kh))
allocate(umdriver(jb-jh:je+jh,kb-kh:ke+kh))
allocate(vmdriver(jb-jh:je+jh,kb-kh:ke+kh))
allocate(wmdriver(jb-jh:je+jh,kb-kh:ke+kh))
!allocate(e12mdriver(jb-jh:je+jh,kb-kh:ke+kh))
if (ltempeq ) then
allocate(storethl0driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storethlmdriver(jb-jh:je+kh,kb-kh:ke+kh,1:driverstore))
allocate(thl0driver(jb-jh:je+jh,kb-kh:ke+kh))
allocate(thlmdriver(jb-jh:je+jh,kb-kh:ke+kh))
end if
if (lmoist ) then
allocate(storeqt0driver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(storeqtmdriver(jb-jh:je+jh,kb-kh:ke+kh,1:driverstore))
allocate(qt0driver(jb-jh:je+jh,kb-kh:ke+kh))
allocate(qtmdriver(jb-jh:je+jh,kb-kh:ke+kh))
end if
if (nsv>0 .and. lsdriver) then
allocate(storesv0driver(jb-jhc:je+jhc,kb-khc:ke+khc,1:nsv,1:driverstore))
allocate(storesvmdriver(jb-jhc:je+jhc,kb-khc:ke+khc,1:nsv,1:driverstore))
allocate(sv0driver(jb-jhc:je+jhc,kb-khc:ke+khc,1:nsv))
allocate(svmdriver(jb-jhc:je+jhc,kb-khc:ke+khc,1:nsv))
end if
irecydriver = iplane!+ib
else
return
end if
end subroutine initdriver