initfields Subroutine

public subroutine initfields()

Uses

  • proc~~initfields~~UsesGraph proc~initfields initfields decomp_2d decomp_2d proc~initfields->decomp_2d module~modglobal modglobal proc~initfields->module~modglobal

Arguments

None

Calls

proc~~initfields~~CallsGraph proc~initfields initfields alloc_z alloc_z proc~initfields->alloc_z

Called by

proc~~initfields~~CalledByGraph proc~initfields initfields proc~tests_mpi_operators tests_mpi_operators proc~tests_mpi_operators->proc~initfields proc~tests_sgs_statistics tests_sgs_statistics proc~tests_sgs_statistics->proc~initfields program~udales uDALES program~udales->proc~initfields proc~execute_runmode_actions execute_runmode_actions program~udales->proc~execute_runmode_actions proc~execute_runmode_actions->proc~tests_mpi_operators proc~execute_runmode_actions->proc~tests_sgs_statistics

Source Code

  subroutine initfields

    use modglobal, only : ib,ie,jb,je,ih,jh,kb,ke,kh,jtot,nsv,&
         ihc,jhc,khc,lmintdump,ltkedump,lscasrcr
    ! use modglobal, only : ltempeq, lmoist
    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(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.

    ! 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 (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(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;
      !end if

      !if (lmoist) then
        allocate(qtt(ib:ie,jb:je,kb:ke+kh)); qtt = 0;
      !end if
    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 ! disabled: initstatsdump aborts on ltkedump, see issue #352
      ! 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(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.

      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(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(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.;svuav=0.;svvav=0.;svwav=0.;sv2av=0.;thl2av=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(thlpwpav(ib:ie   ,jb:je   ,kb:ke+kh))
      upupav=0.;vpvpav=0.;wpwpav=0.;upvpav=0.;upwpav=0.;vpwpav=0.
      thlpwpav=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(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.;
      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)); wall = 0   ! written to restart files: initialise so they are reproducible
    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