subroutine initfields use modglobal, only : ib,ie,jb,je,ih,jh,kb,ke,kh,jtot,nsv,& ihc,jhc,khc,ltdump,lmintdump,lytdump,lxytdump,ltkedump,ltempeq,lmoist,lchem,lscasrcr,ltreedump!, iadv_kappa,iadv_sv use decomp_2d, only : alloc_z ! Allocation of prognostic variables implicit none udef = 0.; vdef = 0. !allocate(worksave(2*imax*jmax*ktot)) ! Maybe define in poisson ! ! Original ! allocate(um(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); um = 0. ! allocate(vm(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); vm = 0. ! allocate(wm(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); wm = 0. ! allocate(u0(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); u0 = 0. ! allocate(v0(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); v0 = 0. ! allocate(w0(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); w0 = 0. allocate(up(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)) ; up=0. allocate(vp(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)) ; vp = 0. allocate(wp(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)) ; wp = 0. allocate(ru(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)) ; ru=0. allocate(rv(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)) ; rv = 0. allocate(rw(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)) ; rw = 0. ! allocate(pres0(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); pres0 = 0. ! ! ! Always have to allocate these, even if they are constant ! ! Maybe change this eventually ! allocate(thlm(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); thlm = 0. ! allocate(thl0(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); thl0 = 0. ! allocate(thl0h(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); thl0h = 0. allocate(thlp(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)); thlp = 0. allocate(thlpc(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb:ke+khc)); thlpc = 0. ! allocate(qtm(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); qtm = 0. ! allocate(qt0(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); qt0 = 0. ! allocate(ql0(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); ql0 = 0. ! allocate(qt0h(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); qt0h = 0. allocate(qtp(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)); qtp = 0. ! allocate(e12m(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); e12m = 0. ! allocate(e120(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); e120 = 0. allocate(e12p(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)); e12p = 0. allocate(ql0h(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)); ql0h = 0. allocate(dthvdz(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)); dthvdz = 0. allocate(thv0h(ib-ih:ie+ih,jb-jh:je+jh,kb:ke+kh)); thv0h = 0. ! allocate(mindist(ib:ie,jb:je,kb:ke)); mindist = 0. !! Allocate 3D fields using 2DECOMP&FFT in z-pencil. call alloc_z(um); um = 0. call alloc_z(vm); vm = 0. call alloc_z(wm); wm = 0. call alloc_z(u0); u0 = 0. call alloc_z(v0); v0 = 0. call alloc_z(w0); w0 = 0. call alloc_z(tau_x); tau_x = 0. call alloc_z(tau_y); tau_y = 0. call alloc_z(tau_z); tau_z = 0. call alloc_z(thl_flux); thl_flux = 0. call alloc_z(uinit); uinit = 0. call alloc_z(vinit); vinit = 0. ! call alloc_z(up); up = 0. ! call alloc_z(vp); vp = 0. ! call alloc_z(wp); wp = 0. call alloc_z(pres0); pres0 = 0. call alloc_z(div, opt_zlevel=(/0,0,0/)) call alloc_z(dudx, opt_zlevel=(/0,0,0/)) call alloc_z(dvdy, opt_zlevel=(/0,0,0/)) call alloc_z(dwdz, opt_zlevel=(/0,0,0/)) ! Always have to allocate these, even if ltempeq/lmoist = .false. call alloc_z(thlm); thlm = 0. !allocate(thlm(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb-khc:ke+khc)); thlm = 0. call alloc_z(thl0); thl0 = 0. allocate(thl0c(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb-khc:ke+khc)); thl0c = 0. ! call alloc_z(thlp); thlp = 0. call alloc_z(thl0h); thl0h = 0. ! call alloc_z(thv0h); thv0h = 0. ! call alloc_z(dthvdz); dthvdz = 0. call alloc_z(qtm); qtm = 0. call alloc_z(qt0); qt0 = 0. call alloc_z(ql0); ql0 = 0. ! call alloc_z(qtp); qtp = 0. call alloc_z(qt0h); qt0h = 0. ! call alloc_z(ql0h); ql0h = 0. call alloc_z(e12m); e12m = 0. call alloc_z(e120); e120 = 0. ! call alloc_z(e12p); e12p = 0. call alloc_z(mindist, opt_zlevel=(/0,0,0/)); mindist = 0. ! These always have to be allocated differently? !if (nsv>0) then allocate(svm(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb-khc:ke+khc,nsv)); svm = 0. allocate(sv0(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb-khc:ke+khc,nsv)); sv0 = 0. allocate(svp(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb:ke+khc,nsv)); svp = 0. allocate(svpp(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb:ke+khc,1)); svpp = 0. !end if ! Allocation of diagnostic variables ! Only used in nearwall in modibm, which is not being used any more allocate(whls(kb:ke+kh)); whls = 0. allocate(presf(kb:ke+kh)); presf = 0. allocate(presh(kb:ke+kh)); presh = 0. allocate(exnf(kb:ke+kh)); exnf = 0. allocate(exnh(kb:ke+kh)); exnh = 0. allocate(thvf(kb:ke+kh)); thvf = 0. allocate(thvh(kb:ke+kh)); thvh = 0. allocate(rhof(kb:ke+kh)); rhof = 0. allocate(qt0av(kb:ke+kh)); qt0av = 0. allocate(ql0av(kb:ke+kh)); ql0av = 0. allocate(thl0av(kb:ke+kh)); thl0av = 0. allocate(u0av(kb:ke+kh)); u0av = 0. allocate(v0av(kb:ke+kh)); v0av = 0. allocate(ug(kb:ke+kh)); ug = 0. allocate(vg(kb:ke+kh)); vg = 0. allocate(pgx(kb:ke+kh)); pgx = 0. allocate(pgy(kb:ke+kh)); pgy = 0. allocate(dpdxl(kb:ke+kh)); dpdxl = 0. allocate(dpdyl(kb:ke+kh)); dpdyl = 0. allocate(dthldxls(kb:ke+kh)); dthldxls = 0. allocate(dthldyls(kb:ke+kh)); dthldyls = 0. allocate(dqtdxls(kb:ke+kh)); dqtdxls = 0. allocate(dqtdyls(kb:ke+kh)); dqtdyls = 0. allocate(dqtdtls(kb:ke+kh)); dqtdtls = 0. allocate(dudxls(kb:ke+kh)); dudxls = 0. allocate(dudyls(kb:ke+kh)); dudyls = 0. allocate(dvdxls(kb:ke+kh)); dvdxls = 0. allocate(dvdyls(kb:ke+kh)); dvdyls = 0. allocate(wfls (kb:ke+kh)); wfls = 0. allocate(thlprof(kb:ke+kh)); thlprof = 0. allocate(qtprof(kb:ke+kh)); qtprof = 0. allocate(qlprof(kb:ke+kh)); qlprof = 0. allocate(uprof(kb:ke+kh)); uprof = 0. allocate(vprof(kb:ke+kh)); vprof = 0. allocate(e12prof(kb:ke+kh)); e12prof = 0. allocate(sv0av(kb:ke+khc,nsv)); sv0av = 0. allocate(svprof(kb:ke+kh,nsv)); svprof = 0. allocate(thlpcar(kb:ke+kh)); thlpcar = 0. allocate(wout(ib:ie)); wout = 0.; ! j -averaged top velocity !allocate(friction(ib:ie)); friction = 0. ! line-averaged (along j) skin friction !allocate(momthick(ib:ie)); momthick = 0. ! line-averaged (along j) momentum thickness !allocate(displthick(ib:ie)); displthick = 0. ! line-averaged (along j) displacement thickness !allocate(SW_up_TOA(ib-ih:ie+ih,jb-jh:je+jh)); SW_up_TOA = 0. !allocate(SW_dn_TOA(ib-ih:ie+ih,jb-jh:je+jh)); SW_dn_TOA = 0. !allocate(LW_up_TOA(ib-ih:ie+ih,jb-jh:je+jh)); LW_up_TOA = 0. !allocate(LW_dn_TOA(ib-ih:ie+ih,jb-jh:je+jh)); LW_dn_TOA = 0. !allocate(viscratioav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)); viscratioav = 0. allocate(rhobf(kb:ke+kh)); rhobf = 1. allocate(rhobh(kb:ke+kh)); rhobh = 1. allocate(IIc(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb:ke+khc)) allocate(IIu(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb:ke+khc)) allocate(IIv(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb:ke+khc)) allocate(IIw(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb:ke+khc)) allocate(IIuw(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb:ke+khc)) allocate(IIvw(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb:ke+khc)) allocate(IIuv(ib-ihc:ie+ihc,jb-jhc:je+jhc,kb:ke+khc)) allocate(IIct(ib:ie,kb:ke)) allocate(IIwt(ib:ie,kb:ke)) allocate(IIuwt(ib:ie,kb:ke)) allocate(IIut(ib:ie,kb:ke)) allocate(IIvt(ib:ie,kb:ke)) allocate(IIcs(kb:ke+khc)) allocate(IIus(kb:ke+khc)) allocate(IIvs(kb:ke+khc)) allocate(IIws(kb:ke+khc)) allocate(IIuws(kb:ke+khc)) allocate(IIvws(kb:ke+khc)) allocate(IIuvs(kb:ke+khc)) IIc=1;IIu=1;IIv=1;IIct=1;IIw=1;IIuw=1;IIvw=1;IIuwt=1;IIut=1;IIvt=1;IIwt=1;IIcs=1;IIus=1;IIvs=1;IIws=1;IIuws=1;IIvws=1;IIuw=1;IIuvs=1 if (ltreedump) then allocate(qc(kb:ke)) allocate(qa(kb:ke)) allocate(ladzf(kb:ke)) allocate(ladzh(kb:ke)) allocate(Rn(kb:ke)) allocate(clai(kb:ke)) allocate(tr_u(ib:ie,jb:je,kb:ke)) allocate(tr_v(ib:ie,jb:je,kb:ke)) allocate(tr_w(ib:ie,jb:je,kb:ke)) allocate(tr_qt(ib:ie,jb:je,kb:ke)) allocate(tr_qtR(ib:ie,jb:je,kb:ke)) allocate(tr_qtA(ib:ie,jb:je,kb:ke)) allocate(tr_thl(ib:ie,jb:je,kb:ke)) allocate(tr_sv(ib:ie,jb:je,kb:ke,1:nsv)) allocate(tr_omega(ib:ie,jb:je,kb:ke)) allocate(tr_ut(ib:ie,jb:je,kb:ke)) allocate(tr_vt(ib:ie,jb:je,kb:ke)) allocate(tr_wt(ib:ie,jb:je,kb:ke)) allocate(tr_qtt(ib:ie,jb:je,kb:ke)) allocate(tr_qtRt(ib:ie,jb:je,kb:ke)) allocate(tr_qtAt(ib:ie,jb:je,kb:ke)) allocate(tr_thlt(ib:ie,jb:je,kb:ke)) allocate(tr_sv1t(ib:ie,jb:je,kb:ke)) allocate(tr_sv2t(ib:ie,jb:je,kb:ke)) allocate(tr_omegat(ib:ie,jb:je,kb:ke)) clai=0.;Rn=0.;qc=0.;qa=0.;ladzf=0.;ladzh=0.;tr_u=0.;tr_v=0.;tr_w=0.;tr_thl=0.;tr_qt=0.;tr_qtR=0.;tr_qtA=0.;tr_sv=0. tr_ut=0.;tr_vt=0.;tr_wt=0.;tr_thlt=0.;tr_qtt=0.;tr_qtRt=0.;tr_qtAt=0.;tr_sv1t=0.;tr_sv2t=0.;tr_omega=0.;tr_omegat=0. end if ! Statistics - currenly not implemented. if (lytdump) then allocate(uyt(ib:ie,kb:ke)) allocate(uytik(ib:ie,kb:ke)) allocate(vyt(ib:ie,kb:ke)) allocate(wyt(ib:ie,kb:ke)) allocate(wytik(ib:ie,kb:ke)) allocate(thlyt(ib:ie,kb:ke)) allocate(qtyt(ib:ie,kb:ke)) allocate(thlytk(ib:ie,kb:ke)) allocate(sca1yt(ib:ie,kb:ke)) allocate(sca2yt(ib:ie,kb:ke)) allocate(sca3yt(ib:ie,kb:ke)) allocate(usgsyt(ib:ie,kb:ke)) allocate(thlsgsyt(ib:ie,kb:ke)) allocate(qtsgsyt(ib:ie,kb:ke)) allocate(wsgsyt(ib:ie,kb:ke)) allocate(sv1sgsyt(ib:ie,kb:ke)) allocate(sv2sgsyt(ib:ie,kb:ke)) allocate(sv3sgsyt(ib:ie,kb:ke)) uyt=0.;uytik=0.;vyt=0.;wyt=0.;wytik=0.;thlyt=0.;qtyt=0.;thlytk=0.;sca1yt=0.;sca2yt=0.;sca3yt=0.;usgsyt=0.;thlsgsyt=0.;wsgsyt=0.;qtsgsyt=0.;sv1sgsyt=0.;sv2sgsyt=0.;sv3sgsyt=0. end if if (lxytdump) then allocate(uxyt(kb:ke+kh)) allocate(vxyt(kb:ke+kh)) allocate(wxyt(kb:ke+kh)) allocate(thlxyt(kb:ke+kh)) allocate(qtxyt(kb:ke+kh)) allocate(pxyt(kb:ke+kh)) allocate(usgsxyt(kb:ke+kh)) allocate(thlsgsxyt(kb:ke+kh)) allocate(vsgsxyt(kb:ke+kh)) uxyt=0.;vxyt=0.;wxyt=0.;thlxyt=0.;qtxyt=0.;pxyt=0.;usgsxyt=0.;vsgsxyt=0.;thlsgsxyt=0.; end if if (lxytdump .or. lytdump .or. ltdump .or. lmintdump) then allocate(umt(ib:ie,jb:je,kb:ke+kh)); umt = 0; allocate(vmt(ib:ie,jb:je,kb:ke+kh)); vmt = 0; allocate(wmt(ib:ie,jb:je,kb:ke+kh)); wmt = 0; allocate(utc(ib:ie,jb:je,kb:ke+kh)); utc = 0; allocate(vtc(ib:ie,jb:je,kb:ke+kh)); vtc = 0; allocate(wtc(ib:ie,jb:je,kb:ke+kh)); wtc = 0; allocate(utij(ib:ie,jb:je,kb:ke+kh)); utij = 0; allocate(utik(ib:ie,jb:je,kb:ke+kh)); utik = 0; allocate(vtij(ib:ie,jb:je,kb:ke+kh)); vtij = 0; allocate(vtjk(ib:ie,jb:je,kb:ke+kh)); vtjk = 0; allocate(wtik(ib:ie,jb:je,kb:ke+kh)); wtik = 0; allocate(wtjk(ib:ie,jb:je,kb:ke+kh)); wtjk = 0; allocate(uvtij(ib:ie,jb:je,kb:ke+kh)); uvtij = 0; allocate(uwtik(ib:ie,jb:je,kb:ke+kh)); uwtik = 0; allocate(vwtjk(ib:ie,jb:je,kb:ke+kh)); vwtjk = 0; allocate(uutc(ib:ie,jb:je,kb:ke+kh)); uutc = 0; allocate(vvtc(ib:ie,jb:je,kb:ke+kh)); vvtc = 0; allocate(wwtc(ib:ie,jb:je,kb:ke+kh)); wwtc = 0; allocate(pt(ib:ie,jb:je,kb:ke+kh)); pt = 0; !if (ltempeq) then ! can't have this switch for now because arrays will be wrong size in tdump file e.g. allocate(thlt(ib:ie,jb:je,kb:ke+kh)); thlt = 0; allocate(thltk(ib:ie,jb:je,kb:ke+kh)); thltk = 0; allocate(wthltk(ib:ie,jb:je,kb:ke+kh)); wthltk = 0; allocate(thlthlt(ib:ie,jb:je,kb:ke+kh)); thlthlt = 0; !end if !if (lmoist) then allocate(qtt(ib:ie,jb:je,kb:ke+kh)); qtt = 0; allocate(qttk(ib:ie,jb:je,kb:ke+kh)); qttk = 0; allocate(wqttk(ib:ie,jb:je,kb:ke+kh)); wqttk = 0; allocate(qtqtt(ib:ie,jb:je,kb:ke+kh)); qtqtt = 0; !end if !if (nsv>0) then allocate(sv1t(ib:ie,jb:je,kb:ke+kh)); sv1t = 0; allocate(sv1tk(ib:ie,jb:je,kb:ke+kh)); sv1tk = 0; allocate(wsv1tk(ib:ie,jb:je,kb:ke+kh)); wsv1tk = 0; allocate(sv1sv1t(ib:ie,jb:je,kb:ke+kh)); sv1sv1t = 0; allocate(sv1sgst(ib:ie,jb:je,kb:ke+kh)); sv1sgst = 0; !if (nsv>1) then allocate(sv2t(ib:ie,jb:je,kb:ke+kh)); sv2t = 0; allocate(sv2tk(ib:ie,jb:je,kb:ke+kh)); sv2tk = 0; allocate(wsv2tk(ib:ie,jb:je,kb:ke+kh)); wsv2tk = 0; allocate(sv2sv2t(ib:ie,jb:je,kb:ke+kh)); sv2sv2t = 0; allocate(sv2sgst(ib:ie,jb:je,kb:ke+kh)); sv2sgst = 0; !if (nsv>2) then allocate(sv3t(ib:ie,jb:je,kb:ke+kh)); sv3t = 0; allocate(sv3tk(ib:ie,jb:je,kb:ke+kh)); sv3tk = 0; allocate(wsv3tk(ib:ie,jb:je,kb:ke+kh)); wsv3tk = 0; allocate(sv3sv3t(ib:ie,jb:je,kb:ke+kh)); sv3sv3t = 0; allocate(sv3sgst(ib:ie,jb:je,kb:ke+kh)); sv3sgst = 0; !if (nsv>3) then allocate(sv4t(ib:ie,jb:je,kb:ke+kh)); sv4t = 0; allocate(sv4tk(ib:ie,jb:je,kb:ke+kh)); sv4tk = 0; allocate(wsv4tk(ib:ie,jb:je,kb:ke+kh)); wsv4tk = 0; allocate(sv4sv4t(ib:ie,jb:je,kb:ke+kh)); sv4sv4t = 0; allocate(sv4sgst(ib:ie,jb:je,kb:ke+kh)); sv4sgst = 0; !end if !end if !end if !end if !if ((lchem .eqv. .true.) .and. (nsv>2)) then allocate(PSSt(ib:ie,jb:je,kb:ke+kh)); PSSt = 0; !end if ! uwtik=0.;wthltk=0.;wqttk=0.;thlthlt=0.;qtqtt=0.;sv1sv1t=0.;sv2sv2t=0.;sv3sv3t=0.;sv4sv4t=0.;uutc=0.;vvtc=0.;wwtc=0.;vwtjk=0.;uvtij=0.;utik=0.;wtik=0.;wtjk=0.;vtjk=0.;utij=0.;vtij=0.; ! wmt=0.;thltk=0.;qttk=0.;thlt=0.;utc=0.;vtc=0.;wtc=0. ! wsv1tk=0.;wsv2tk=0.;wsv3tk=0.;wsv4tk=0.;sv1sgst=0.;sv2sgst=0.;sv3sgst=0.;sv4sgst=0.;qtt=0.;pt=0. ! PSSt = 0. !sv1max = 0.; sv2max = 0.; sv3max = 0.; sv4max = 0. end if if (lscasrcr .and. nsv>0) then allocate(scar(ib:ie,jb:jtot)) allocate(scarl(ib:ie,jb:je)) scar=0.;scarl=0. end if if (ltkedump) then ! this is currently not usable ! allocate averaged variables allocate(uav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(vav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(wav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(thlav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(qtav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(qlav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(presav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(svav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh,1:nsv)) allocate(umint(ib:ie,jb:je,kb:ke)) allocate(vmint(ib:ie,jb:je,kb:ke)) allocate(wmint(ib:ie,jb:je,kb:ke)) allocate(uuav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(vvav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(wwav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(uvav(ib:ie+ih,jb:je+jh,kb:ke )) allocate(uwav(ib:ie+ih,jb:je ,kb:ke+kh)) allocate(vwav(ib:ie ,jb:je+jh,kb:ke+kh)) !TKE budget terms allocate(tvmx (ib-1:ie+1,jb-1:je+1,kb:ke)) allocate(tvmy (ib-1:ie+1,jb-1:je+1,kb:ke)) allocate(tvmz (ib:ie,jb:je,kb:ke+1)) allocate(tpm (ib:ie,jb:je,kb:ke)) allocate(ttmx (ib-1:ie+1,jb-1:je+1,kb:ke)) allocate(ttmy (ib-1:ie+1,jb-1:je+1,kb:ke)) allocate(ttmz (ib:ie, jb:je, kb:ke+1)) allocate(tsgsmx1(ib-1:ie+1,jb-1:je+1,kb:ke)) allocate(tsgsmy1(ib-1:ie+1,jb-1:je+1,kb:ke)) allocate(tsgsmz1(ib:ie,jb:je,kb:ke+1)) allocate(tsgsmx2(ib-1:ie+1,jb-1:je+1,kb:ke)) allocate(tsgsmy2(ib-1:ie+1,jb-1:je+1,kb:ke)) allocate(tsgsmz2(ib:ie,jb:je,kb:ke+1)) allocate(t_pav (ib:ie,jb:je,kb:ke)) allocate(t_vav (ib:ie,jb:je,kb:ke)) allocate(t_tav (ib:ie,jb:je,kb:ke)) allocate(t_sgsav(ib:ie,jb:je,kb:ke)) allocate(p_tav (ib:ie,jb:je,kb:ke)) allocate(p_bav (ib:ie,jb:je,kb:ke)) allocate(d_sgsav(ib:ie,jb:je,kb:ke)) allocate(tkeadv(ib:ie,jb:je,kb:ke)) allocate(t_p (kb:ke)) allocate(t_v (kb:ke)) allocate(t_t (kb:ke)) allocate(t_sgs (kb:ke)) allocate(p_t (kb:ke)) allocate(p_b (kb:ke)) allocate(d_sgs (kb:ke)) allocate(adv (kb:ke)) uav=0.;vav=0.;wav=0.;thlav=0.;qtav=0.;svav=0.;;uuav=0.;vvav=0. wwav=0.;uvav=0.;uwav=0.;vwav=0.;presav=0. umint=0.;vmint=0.;wmint=0. t_vav=0.;tvmx=0.;tvmy=0.;tvmz=0.;tpm=0.;ttmx=0.;ttmy=0.;ttmz=0.;t_sgsav=0.;p_tav=0. tsgsmx1=0.;tsgsmy1=0.;tsgsmz1=0.;tsgsmx2=0.;tsgsmy2=0.;tsgsmz2=0. t_pav=0.;t_tav=0.;p_bav=0.;d_sgsav=0.;tkeadv=0.;t_p=0.;t_v=0.;t_t=0.;t_sgs=0.;p_t=0.;p_b=0.;d_sgs=0.;adv=0. allocate(thl2av(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(ql2av(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(qt2av(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(sv2av(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh,1:nsv)) allocate(thluav(ib:ie+ih,jb:je ,kb:ke )) allocate(thlvav(ib:ie ,jb:je+jh,kb:ke )) allocate(thlwav(ib:ie ,jb:je, kb:ke+kh)) allocate(thlthlav(ib:ie ,jb:je, kb:ke+kh)) allocate(qluav(ib:ie+ih,jb:je ,kb:ke )) allocate(qlvav(ib:ie ,jb:je+jh,kb:ke )) allocate(qlwav(ib:ie ,jb:je, kb:ke+kh)) allocate(qtuav(ib:ie+ih,jb:je ,kb:ke )) allocate(qtvav(ib:ie ,jb:je+jh,kb:ke )) allocate(qtwav(ib:ie ,jb:je, kb:ke+kh)) allocate(svuav (ib:ie+ih,jb:je ,kb:ke ,1:nsv)) allocate(svvav (ib:ie ,jb:je+jh,kb:ke ,1:nsv)) allocate(svwav (ib:ie ,jb:je ,kb:ke+kh,1:nsv)) thluav=0.;thlvav=0.;thlwav=0.;thlthlav=0.;svuav=0.;svvav=0.;svwav=0.;sv2av=0.;thl2av=0.;ql2av=0.;qt2av=0.; ! <x'x> ( = <xx> -<x><x> ) allocate(upupav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(vpvpav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(wpwpav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(upvpav(ib:ie+ih,jb:je+jh,kb:ke )) allocate(upwpav(ib:ie+ih,jb:je ,kb:ke+kh)) allocate(vpwpav(ib:ie ,jb:je+jh,kb:ke+kh)) allocate(thlpthlpav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(thlpupav(ib:ie+ih,jb:je ,kb:ke )) allocate(thlpvpav(ib:ie ,jb:je+jh,kb:ke )) allocate(thlpwpav(ib:ie ,jb:je ,kb:ke+kh)) allocate(qlpqlpav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(qlpupav(ib:ie+ih,jb:je ,kb:ke )) allocate(qlpvpav(ib:ie ,jb:je+jh,kb:ke )) allocate(qlpwpav(ib:ie ,jb:je ,kb:ke+kh)) allocate(qtpqtpav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(qtpupav(ib:ie+ih,jb:je ,kb:ke )) allocate(qtpvpav(ib:ie ,jb:je+jh,kb:ke )) allocate(qtpwpav(ib:ie ,jb:je ,kb:ke+kh)) allocate(svpsvpav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh,1:nsv)) allocate(svpupav(ib:ie+ih,jb:je ,kb:ke ,1:nsv)) allocate(svpvpav(ib:ie ,jb:je+jh,kb:ke ,1:nsv)) allocate(svpwpav(ib:ie ,jb:je ,kb:ke+kh,1:nsv)) upupav=0.;vpvpav=0.;wpwpav=0.;thlpthlpav=0.;qlpqlpav=0.;qtpqtpav=0.;svpsvpav=0.;upvpav=0.;upwpav=0.;vpwpav=0. thlpupav=0.;thlpvpav=0.;thlpwpav=0.;qlpupav=0.;qlpvpav=0.;qlpwpav=0.;qtpwpav=0.;qtpvpav=0.;qtpupav=0.;svpupav=0.;svpvpav=0.;svpwpav=0. ! Subgrid allocate(uusgsav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(vvsgsav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(wwsgsav(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(uwsgsav(ib:ie+ih,jb:je ,kb:ke+kh)) allocate(thlusgsav(ib:ie+ih,jb:je ,kb:ke )) allocate(thlwsgsav(ib:ie ,jb:je, kb:ke+kh)) allocate(qlusgsav(ib:ie+ih,jb:je ,kb:ke )) allocate(qlwsgsav(ib:ie ,jb:je, kb:ke+kh)) allocate(qtusgsav(ib:ie+ih,jb:je ,kb:ke )) allocate(qtwsgsav(ib:ie ,jb:je, kb:ke+kh)) allocate(tkesgsav (ib:ie ,jb:je ,kb:ke )) allocate(svusgsav (ib:ie+ih,jb:je ,kb:ke ,1:nsv)) allocate(svwsgsav (ib:ie ,jb:je ,kb:ke+kh,1:nsv)) allocate(nusgsav (ib:ie ,jb:je ,kb:ke )) uusgsav=0.;vvsgsav=0.;wwsgsav=0.;uwsgsav=0.;thlusgsav=0.;thlwsgsav=0.;qlusgsav=0.;qlwsgsav=0.;qtwsgsav=0.;qtusgsav=0.; svusgsav=0.;svwsgsav=0.;tkesgsav=0.;nusgsav=0. allocate(strain2av(ib:ie,jb:je,kb:ke)) ! resolved dissipation allocate(disssgsav(ib:ie,jb:je,kb:ke)) ! Subgrid dissipation strain2av=0. disssgsav=0. end if ! allocate wall shear-stress terms (immersed boundaries) allocate(shear(ib-1:ie+1,jb-1:je+1,kb-1:ke+1,0:12)) ! halo is set to 1 allocate(momfluxb(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(tfluxb(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(qfluxb(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(cth(ib-ih:ie+ih,jb-jh:je+jh,kb-kh:ke+kh)) allocate(wall(ib:ie,jb:je,kb:ke,5)) momfluxb=0.;tfluxb=0.;qfluxb=0.;cth=0. shear=0. ! domain fluid volume and area calculations uoutarea=0.;voutarea=0.;fluidvol=0. end subroutine initfields