module mod_extra
!! From extra.comm
   IMPLICIT NONE
      PUBLIC
      real, allocatable, dimension(:,:,:)::pdsl,pdvp1,pslp
      real, allocatable, dimension(:,:,:,:)::pint,alpint,zint

!!    common/extra/ pdsl,pint,alpint,zint,pdvp1,pslp
  contains
  subroutine alloc_extra
    include 'param_o.h'

!!      real, allocatable, dimension(0:im+1,0:jm+1,nm)::pdsl,pdvp1,pslp
    ALLOCATE(pdsl(0:im+1,0:jm+1,nm))
    pdsl = 0.0
    ALLOCATE(pdvp1(0:im+1,0:jm+1,nm))
    pdvp1 = 0.0
    ALLOCATE(pslp(0:im+1,0:jm+1,nm))
    pslp = 0.0

!!      real, allocatable, dimension(0:im+1,0:jm+1,nm,lp1)::pint,alpint,zint
    ALLOCATE(pint(0:im+1,0:jm+1,nm,lp1))
    pint = 0.0
    ALLOCATE(alpint(0:im+1,0:jm+1,nm,lp1))
    alpint = 0.0

    ALLOCATE(zint(0:im+1,0:jm+1,nm,lp1))
    zint = 0.0

  end subroutine alloc_extra

  subroutine dealloc_extra

     DEALLOCATE(pdsl,pdvp1,pslp,pint,alpint,zint)

  end subroutine dealloc_extra

end module mod_extra
!
!
!
!
module mod_graph
!! From graph.comm
   IMPLICIT NONE
      PUBLIC
      !! real, allocatable, dimension(:,:)::GLON,GLAT   !glon,glat,  DRAGAN
      real, allocatable, dimension(:,:)::xmp0,ymp0   !glon,glat,  DRAGAN
      integer, allocatable, dimension(:,:)::kmp0
      real, allocatable, dimension(:,:,:)::u2us,v2us,u2vs,v2vs

!!       common /graph/  &
!!       XMP0,YMP0,KMP0,u2us,v2us,u2vs,v2vs     !GLON,GLAT,  DRAGAN 
  contains
  subroutine alloc_graph
    include 'param_o.h'

!!      real, allocatable, dimension(igm,jgm)::xmp0,ymp0   !glon,glat,  DRAGAN
!!      integer, allocatable, dimension(igm,jgm)::kmp0
!!     ALLOCATE(GLON(igm,jgm))
!!     ALLOCATE(GLAT(igm,jgm))
!!     glon = 0.0
!!     glat = 0.0

    ALLOCATE(xmp0(igm,jgm))
    xmp0 = 0.0
    ALLOCATE(ymp0(igm,jgm))
    ymp0 = 0.0
    ALLOCATE(kmp0(igm,jgm))
    kmp0 = 0

!!      real, allocatable, dimension(0:im+1,0:jm+1,nm)::u2us,v2us,u2vs,v2vs
    ALLOCATE(u2us(0:im+1,0:jm+1,nm))  
    ALLOCATE(v2us(0:im+1,0:jm+1,nm))  
    ALLOCATE(u2vs(0:im+1,0:jm+1,nm))  
    ALLOCATE(v2vs(0:im+1,0:jm+1,nm))  
    u2us = 0.0
    v2us = 0.0
    u2vs = 0.0
    v2vs = 0.0

  end subroutine alloc_graph
!
!
!
!
  subroutine dealloc_graph

    DEALLOCATE(xmp0,ymp0,kmp0,u2us,v2us,u2vs,v2vs)

  end subroutine dealloc_graph
end module mod_graph
!
!
!
!
!
!! module mod_mapot
! !! From mapot.comm
!!         real,dimension(lsm)::spl,alsl
!! 	common/mapot/ spl,alsl
!! end module mod_mapot
!
!
!
!
!
module mod_masks
!! From masks.comm
   IMPLICIT NONE
       PUBLIC
      real, allocatable, dimension(:,:,:,:)::htm,vtm
      integer, allocatable, dimension(:,:,:)::lmh,lmv

!!      common/masks/ htm,vtm,lmh,lmv
  contains
!
  subroutine alloc_masks
    include 'param_o.h'

!!      real, allocatable, dimension(0:im+1,0:jm+1,nm,lm)::htm,vtm
    ALLOCATE(htm(0:im+1,0:jm+1,nm,lm))
    htm = 0.0
    ALLOCATE(vtm(0:im+1,0:jm+1,nm,lm))
    vtm = 0.0

!!      integer, allocatable, dimension(0:im+1,0:jm+1,nm)::lmh,lmv
    ALLOCATE(lmh(0:im+1,0:jm+1,nm))
    ALLOCATE(lmv(0:im+1,0:jm+1,nm))
    lmh = 0
    lmv = 0

  end subroutine alloc_masks
!
!
!
!
!
  subroutine dealloc_masks

    DEALLOCATE(htm,vtm,lmh,lmv)

  end subroutine dealloc_masks

!
!
end module mod_masks
!
!
!
!
!
module mod_pvrbls
!! From pvrbls.comm
   IMPLICIT NONE
       PUBLIC
       real, allocatable, dimension(:,:,:)::ths,u00 
       real, allocatable, dimension(:,:,:)::sfclhx,sfcshx,vegfrc,z0,albedo  !DRAGAN
       
       real, allocatable, dimension(:,:,:)::RSWIN,RSWOUT,RSWTOA,ASWIN,ASWOUT,ASWTOA,rswnet   !
       real, allocatable, dimension(:,:,:)::RLWIN,RLWOUT,RLWTOA,ALWIN,ALWOUT,ALWTOA,rlwnet   ! DRAGAN   (RADIATION)
       real, allocatable, dimension(:,:,:,:)::RSWTT,RLWTT                                   !
       real, allocatable, dimension(:,:,:)::CUPPT,cfracl,cfracm,cfrach            !clouds
       real, allocatable, dimension(:,:,:)::acprec,cuprec,aprec,acsnow,prec       !precipitation
       
       real, allocatable, dimension(:,:,:)::SMSTAV,BGROFF,SSROFF                  !soil
       integer,parameter:: nsoil=4
       real, allocatable, dimension(:,:,:,:)::smc,stc

       real, allocatable, dimension(:)::ul
!       real, allocatable, dimension(0:im+1,0:jm+1,nm,lm)::q2

       real, allocatable, dimension(:,:,:)::albase,cnvtop,cnvbot,htop,hbot        !newly added
       integer, allocatable, dimension(:,:,:)::IVGTYP,ISLTYP

       real, allocatable, dimension(:,:,:)::acfrcv,acfrst,acsnom,cmc,   &
       czen,czmean,epsr,glat,glon,grnflx,mxsnal,potevp,potflx

       real, allocatable, dimension(:,:,:,:)::omgalf,q2,tcucn,train,div,rtop

!!!       real, allocatable, dimension(lm,0:im+1,0:jm+1,nm)::f_ice,f_rain,f_RimeF
      
       real, allocatable, dimension(:,:,:)::qwbs,twbs,sm,q10,th10,qz0,thz0,radot,sigt4,  &
       sfcevp,subshx,snopcx,si,sno,sice,smstot,soiltb,tg,sr,akhs,akms,plm
       
       real, allocatable, dimension(:,:,:)::u10,v10,uz0,vz0,ustar

!!       common/pvrbls/ ths,u00,sfclhx,sfcshx,vegfrc,z0,albedo,  &
!!        RSWIN,RSWOUT,RSWTOA,ASWIN,ASWOUT,ASWTOA,rswnet,RLWIN,RLWOUT,RLWTOA,ALWIN,ALWOUT,ALWTOA,rlwnet,  &
!!	RSWTT,RLWTT,CUPPT,cfracl,cfracm,cfrach,acprec,cuprec,aprec,acsnow,prec,  &
!!	SMSTAV,BGROFF,SSROFF,smc,stc,albase,cnvtop,cnvbot,htop,hbot,IVGTYP,ISLTYP,   &
!!	acfrcv,acfrst,acsnom,cmc,czen,czmean,epsr,glat,glon,grnflx,mxsnal,potevp,potflx,   &
!!	omgalf,qwbs,twbs,sm,q10,th10,qz0,thz0,radot,sigt4,sfcevp,subshx,snopcx,  &
!!        si,sno,sice,smstot,soiltb,tg,sr,akhs,akms,q2,tcucn,train,div,rtop,plm,   &
!!	u10,v10,uz0,vz0,ustar     !!!DRAGAN

  contains
  subroutine alloc_pvrbls
    include 'param_o.h'

!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::ths,u00 
!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::sfclhx,sfcshx,vegfrc,z0,albedo  !DRAGAN
    ALLOCATE(ths(0:im+1,0:jm+1,nm))
    ths = 0.0
    ALLOCATE(u00(0:im+1,0:jm+1,nm))
    u00 = 0.0
    ALLOCATE(sfclhx(0:im+1,0:jm+1,nm))
    sfclhx = 0.0
    ALLOCATE(sfcshx(0:im+1,0:jm+1,nm))
    sfclhx = 0.0
    ALLOCATE(vegfrc(0:im+1,0:jm+1,nm))
    vegfrc = 0.0
    ALLOCATE(z0(0:im+1,0:jm+1,nm))
    z0 = 0.0
    ALLOCATE(albedo(0:im+1,0:jm+1,nm))
    albedo = 0.0

!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::RSWIN,RSWOUT,RSWTOA,ASWIN,ASWOUT,ASWTOA,rswnet   !
!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::RLWIN,RLWOUT,RLWTOA,ALWIN,ALWOUT,ALWTOA,rlwnet   ! DRAGAN   (RADIATION)
    ALLOCATE(RSWIN(0:im+1,0:jm+1,nm))
    RSWIN = 0.0
    ALLOCATE(RSWOUT(0:im+1,0:jm+1,nm))
    RSWOUT = 0.0
    ALLOCATE(RSWTOA(0:im+1,0:jm+1,nm))
    RSWTOA = 0.0
    ALLOCATE(ASWIN(0:im+1,0:jm+1,nm))
    ASWIN = 0.0
    ALLOCATE(ASWOUT(0:im+1,0:jm+1,nm))
    ASWOUT = 0.0
    ALLOCATE(ASWTOA(0:im+1,0:jm+1,nm))
    ASWTOA = 0.0
    ALLOCATE(RSWnet(0:im+1,0:jm+1,nm))
    rswnet = 0.0
    ALLOCATE(RLWIN(0:im+1,0:jm+1,nm))
    RLWIN = 0.0
    ALLOCATE(RLWOUT(0:im+1,0:jm+1,nm))
    RLWOUT = 0.0
    ALLOCATE(RLWTOA(0:im+1,0:jm+1,nm))
    RLWTOA = 0.0
    ALLOCATE(ALWIN(0:im+1,0:jm+1,nm))
    ALWIN = 0.0
    ALLOCATE(ALWOUT(0:im+1,0:jm+1,nm))
    ALWOUT = 0.0
    ALLOCATE(ALWTOA(0:im+1,0:jm+1,nm))
    ALWTOA = 0.0
    ALLOCATE(RLWnet(0:im+1,0:jm+1,nm))
    rlwnet = 0.0

!!       real, allocatable, dimension(0:im+1,0:jm+1,nm,lm)::RSWTT,RLWTT                                   !
!!       real, allocatable, dimension(0:im+1,0:jm+1,nm,lm)::
    ALLOCATE(RSWTT(0:im+1,0:jm+1,nm,lm))
    RSWTT = 0.0
    ALLOCATE(RLWTT(0:im+1,0:jm+1,nm,lm))
    RLWTT = 0.0

!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::CUPPT,cfracl,cfracm,cfrach            !clouds
    ALLOCATE(CUPPT(0:im+1,0:jm+1,nm))
    CUPPT = 0.0
    ALLOCATE(cfracl(0:im+1,0:jm+1,nm))
    cfracl = 0.0
    ALLOCATE(cfracm(0:im+1,0:jm+1,nm))
    cfracm = 0.0
    ALLOCATE(cfrach(0:im+1,0:jm+1,nm))
    cfrach = 0.0

!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::acprec,cuprec,aprec,acsnow,prec       !precipitation
    ALLOCATE(acprec(0:im+1,0:jm+1,nm))
    acprec = 0.0
    ALLOCATE(cuprec(0:im+1,0:jm+1,nm))
    cuprec = 0.0
    ALLOCATE(aprec(0:im+1,0:jm+1,nm))
    aprec = 0.0
    ALLOCATE(acsnow(0:im+1,0:jm+1,nm))
    acsnow = 0.0
    ALLOCATE(prec(0:im+1,0:jm+1,nm))
    prec  = 0.0

!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::SMSTAV,BGROFF,SSROFF                  !soil
!!       real, allocatable, dimension(0:im+1,0:jm+1,nm,nsoil)::smc,stc
    ALLOCATE(SMSTAV(0:im+1,0:jm+1,nm))
    SMSTAV = 0.0
    ALLOCATE(BGROFF(0:im+1,0:jm+1,nm))
    BGROFF = 0.0
    ALLOCATE(SSROFF(0:im+1,0:jm+1,nm))
    SSROFF = 0.0

    ALLOCATE(smc(0:im+1,0:jm+1,nm,nsoil))
    smc = 0.0
    ALLOCATE(stc(0:im+1,0:jm+1,nm,nsoil))
    stc = 0.0

!!       real, allocatable, dimension(2*lm)::ul
    ALLOCATE(ul(2*lm))
    ul = 0.0

!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::albase,cnvtop,cnvbot,htop,hbot        !newly added
!!       integer, allocatable, dimension(0:im+1,0:jm+1,nm)::IVGTYP,ISLTYP
    ALLOCATE(albase(0:im+1,0:jm+1,nm))
    albase = 0.0
    ALLOCATE(cnvtop(0:im+1,0:jm+1,nm))
    cnvtop = 0.0
    ALLOCATE(cnvbot(0:im+1,0:jm+1,nm))
    cnvbot = 0.0
    ALLOCATE(htop(0:im+1,0:jm+1,nm))
    htop = 0.0
    ALLOCATE(hbot(0:im+1,0:jm+1,nm))
    hbot = 0.0

    ALLOCATE(IVGTYP(0:im+1,0:jm+1,nm))
    IVGTYP = 0
    ALLOCATE(ISLTYP(0:im+1,0:jm+1,nm))
    ISLTYP = 0
       
!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::acfrcv,acfrst,acsnom,cmc,   &
!!       czen,czmean,epsr,glat,glon,grnflx,mxsnal,potevp,potflx
    ALLOCATE(acfrcv(0:im+1,0:jm+1,nm))
    acfrcv = 0.0
    ALLOCATE(acfrst(0:im+1,0:jm+1,nm))
    acfrst = 0.0
    ALLOCATE(acsnom(0:im+1,0:jm+1,nm))
    acsnom = 0.0
    ALLOCATE(cmc(0:im+1,0:jm+1,nm))
    cmc = 0.0
    ALLOCATE(czen(0:im+1,0:jm+1,nm))
    czen = 0.0
    ALLOCATE(czmean(0:im+1,0:jm+1,nm))
    czmean = 0.0
    ALLOCATE(epsr(0:im+1,0:jm+1,nm))
    epsr = 0.0
    ALLOCATE(glat(0:im+1,0:jm+1,nm))
    glat = 0.0
    ALLOCATE(glon(0:im+1,0:jm+1,nm))
    glon = 0.0
    ALLOCATE(grnflx(0:im+1,0:jm+1,nm))
    grnflx = 0.0
    ALLOCATE(mxsnal(0:im+1,0:jm+1,nm))
    mxsnal = 0.0
    ALLOCATE(potevp(0:im+1,0:jm+1,nm))
    potevp = 0.0
    ALLOCATE(potflx(0:im+1,0:jm+1,nm))
    potflx = 0.0
       
!!       real, allocatable, dimension(0:im+1,0:jm+1,nm,lm)::omgalf,q2,tcucn,train,div,rtop
    ALLOCATE(omgalf(0:im+1,0:jm+1,nm,lm))
    omgalf = 0.0
    ALLOCATE(q2(0:im+1,0:jm+1,nm,lm))
    q2 = 0.0
    ALLOCATE(tcucn(0:im+1,0:jm+1,nm,lm))
    tcucn = 0.0
    ALLOCATE(train(0:im+1,0:jm+1,nm,lm))
    train = 0.0
    ALLOCATE(div(0:im+1,0:jm+1,nm,lm))
    div = 0.0
    ALLOCATE(rtop(0:im+1,0:jm+1,nm,lm))
    rtop = 0.0
       
!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::qwbs,twbs,sm,q10,th10,qz0,thz0,radot,sigt4,  &
!!       sfcevp,subshx,snopcx,si,sno,sice,smstot,soiltb,tg,sr,akhs,akms,plm
    ALLOCATE(qwbs(0:im+1,0:jm+1,nm))
    ALLOCATE(twbs(0:im+1,0:jm+1,nm))
    ALLOCATE(sm(0:im+1,0:jm+1,nm))
    ALLOCATE(q10(0:im+1,0:jm+1,nm))
    ALLOCATE(th10(0:im+1,0:jm+1,nm))
    ALLOCATE(qz0(0:im+1,0:jm+1,nm))
    ALLOCATE(thz0(0:im+1,0:jm+1,nm))
    ALLOCATE(radot(0:im+1,0:jm+1,nm))
    ALLOCATE(sigt4(0:im+1,0:jm+1,nm))
    ALLOCATE(sfcevp(0:im+1,0:jm+1,nm))
    ALLOCATE(subshx(0:im+1,0:jm+1,nm))
    ALLOCATE(snopcx(0:im+1,0:jm+1,nm))
    ALLOCATE(si(0:im+1,0:jm+1,nm))
    ALLOCATE(sno(0:im+1,0:jm+1,nm))
    ALLOCATE(sice(0:im+1,0:jm+1,nm))
    ALLOCATE(smstot(0:im+1,0:jm+1,nm))
    ALLOCATE(soiltb(0:im+1,0:jm+1,nm))
    ALLOCATE(tg(0:im+1,0:jm+1,nm))
    ALLOCATE(sr(0:im+1,0:jm+1,nm))
    ALLOCATE(akhs(0:im+1,0:jm+1,nm))
    ALLOCATE(akms(0:im+1,0:jm+1,nm))
    ALLOCATE(plm(0:im+1,0:jm+1,nm))
    qwbs = 0.0
    twbs = 0.0
    sm = 0.0
    q10 = 0.0
    th10 = 0.0
    qz0 = 0.0
    thz0 = 0.0
    radot = 0.0
    sigt4 = 0.0
    sfcevp = 0.0
    subshx = 0.0
    snopcx = 0.0
    si = 0.0
    sno = 0.0
    sice = 0.0
    smstot = 0.0
    soiltb = 0.0
    tg = 0.0
    sr = 0.0
    akhs = 0.0
    akms = 0.0
    plm = 0.0

!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::u10,v10,uz0,vz0,ustar
    ALLOCATE(u10(0:im+1,0:jm+1,nm))
    ALLOCATE(v10(0:im+1,0:jm+1,nm))
    ALLOCATE(uz0(0:im+1,0:jm+1,nm))
    ALLOCATE(vz0(0:im+1,0:jm+1,nm))
    ALLOCATE(ustar(0:im+1,0:jm+1,nm))
    u10 = 0.0
    v10 = 0.0
    uz0 = 0.0
    vz0 = 0.0
    ustar = 0.0

  end subroutine alloc_pvrbls

  subroutine dealloc_pvrbls

    DEALLOCATE(ths,u00,sfclhx,vegfrc,z0,albedo)
    DEALLOCATE(RSWIN,RSWOUT,RSWTOA,ASWIN,ASWOUT,ASWTOA,RSWnet,RLWIN,RLWOUT,RLWTOA,ALWIN,ALWOUT,ALWTOA,RLWnet)
    DEALLOCATE(RSWTT,RLWTT,CUPPT,cfracl,cfracm,cfrach,acprec,cuprec,aprec,acsnow,prec)
    DEALLOCATE(SMSTAV,BGROFF,SSROFF,smc,stc,ul,albase,cnvtop,cnvbot,htop,hbot,IVGTYP,ISLTYP)
    DEALLOCATE(acfrcv,acfrst,acsnom,cmc,czen,czmean,epsr,glat,glon,grnflx,mxsnal,potevp,potflx)
    DEALLOCATE(omgalf,q2,tcucn,train,div,rtop)
    DEALLOCATE(qwbs,twbs,sm,q10,th10,qz0,thz0,radot,sigt4,sfcevp,subshx,snopcx,si,sno,sice,smstot,soiltb,tg,sr,akhs,akms,plm)
    DEALLOCATE(u10,v10,uz0,vz0,ustar)

  end subroutine dealloc_pvrbls

end module mod_pvrbls
!
!
!
!
module mod_vrbls
!! From vrbls.comm
   IMPLICIT NONE
      PUBLIC
       real, allocatable, dimension(:,:,:)::pd,res,fis
       real, allocatable, dimension(:,:,:,:)::u,v,q,t,cwm
       
       real, allocatable, dimension(:,:,:,:)::w,dwdt,z   !non-hydrostatic 2016
       
       real, allocatable, dimension(:,:,:)::tshltr,qshltr    !DRAGAN

!!       common/vrbls/ pd,u,v,q,t,cwm,fis,res,tshltr,qshltr,w,dwdt,z
  contains
  subroutine alloc_vrbls
    include 'param_o.h'

!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::pd,res,fis
    ALLOCATE(pd(0:im+1,0:jm+1,nm))
    ALLOCATE(res(0:im+1,0:jm+1,nm))
    ALLOCATE(fis(0:im+1,0:jm+1,nm))
    pd = 0.0
    res = 0.0
    fis = 0.0

!!       real, allocatable, dimension(0:im+1,0:jm+1,nm,lm)::u,v,q,t,cwm
    ALLOCATE(u(0:im+1,0:jm+1,nm,lm))
    ALLOCATE(v(0:im+1,0:jm+1,nm,lm))
    ALLOCATE(q(0:im+1,0:jm+1,nm,lm))
    ALLOCATE(t(0:im+1,0:jm+1,nm,lm))
    ALLOCATE(cwm(0:im+1,0:jm+1,nm,lm))
    u = 0.0
    v = 0.0
    q = 0.0
    t = 0.0
    cwm = 0.0
       
!!       real, allocatable, dimension(0:im+1,0:jm+1,nm,lm)::w,dwdt,z   !non-hydrostatic 2016
    ALLOCATE(w(0:im+1,0:jm+1,nm,lm))
    ALLOCATE(dwdt(0:im+1,0:jm+1,nm,lm))
    ALLOCATE(z(0:im+1,0:jm+1,nm,lm))
    w = 0.0
    dwdt = 0.0
    z = 0.0
       
!!       real, allocatable, dimension(0:im+1,0:jm+1,nm)::tshltr,qshltr    !DRAGAN
    ALLOCATE(tshltr(0:im+1,0:jm+1,nm))
    ALLOCATE(qshltr(0:im+1,0:jm+1,nm))
    tshltr = 0.0
    qshltr = 0.0

  end subroutine alloc_vrbls

  subroutine dealloc_vrbls

    DEALLOCATE(pd,res,fis,u,v,q,t,cwm,w,dwdt,z,tshltr,qshltr)

  end subroutine dealloc_vrbls

end module mod_vrbls

module mod_pvrbls_ll
!! From qu2ll2.f90
   IMPLICIT NONE
      PUBLIC
!!pvrbls_ll       real,dimension(igm,jgm)::psurf_ll,tsfc_ll,pslp_ll,sfcshx_ll,sfclhx_ll,vegfrc_ll,z0_ll,albedo_ll
      real, allocatable, dimension(:,:)::psurf_ll,tsfc_ll,pslp_ll,sfcshx_ll,sfclhx_ll,vegfrc_ll,z0_ll,albedo_ll

!!pvrbls_ll      real,dimension(igm,jgm)::RSWIN_ll,RSWOUT_ll,RSWTOA_ll,ASWIN_ll,ASWOUT_ll,ASWTOA_ll,rswnet_ll
!!pvrbls_ll      real,dimension(igm,jgm)::RLWIN_ll,RLWOUT_ll,RLWTOA_ll,ALWIN_ll,ALWOUT_ll,ALWTOA_ll,rlwnet_ll
      real, allocatable, dimension(:,:)::RSWIN_ll,RSWOUT_ll,RSWTOA_ll,ASWIN_ll,ASWOUT_ll,ASWTOA_ll,rswnet_ll
      real, allocatable, dimension(:,:)::RLWIN_ll,RLWOUT_ll,RLWTOA_ll,ALWIN_ll,ALWOUT_ll,ALWTOA_ll,rlwnet_ll

!!pvrbls_ll      real,dimension(igm,jgm,lsm)::RSWTT_ll,RLWTT_ll
      real, allocatable, dimension(:,:,:)::RSWTT_ll,RLWTT_ll

!!pvrbls_ll      real,dimension(igm,jgm)::CUPPT_ll,cfracl_ll,cfracm_ll,cfrach_ll
      real, allocatable, dimension(:,:)::CUPPT_ll,cfracl_ll,cfracm_ll,cfrach_ll

!!pvrbls_ll      real,dimension(igm,jgm)::acprec_ll,cuprec_ll,aprec_ll,acsnow_ll,prec_ll
      real, allocatable, dimension(:,:)::acprec_ll,cuprec_ll,aprec_ll,acsnow_ll,prec_ll

      integer,parameter :: nsoil=4
!!pvrbls_ll      real,dimension(igm,jgm,nsoil)::stc_ll,smc_ll
      real, allocatable, dimension(:,:,:)::stc_ll,smc_ll

!!pvrbls_ll      real,dimension(igm,jgm)::tshltr_ll,qshltr_ll,albase_ll,cnvtop_ll,cnvbot_ll,htop_ll,hbot_ll
      real, allocatable, dimension(:,:)::tshltr_ll,qshltr_ll,albase_ll,cnvtop_ll,cnvbot_ll,htop_ll,hbot_ll

!!pvrbls_ll      integer,dimension(igm,jgm)::IVGTYP_ll,ISLTYP_ll
      integer, allocatable, dimension(:,:)::IVGTYP_ll,ISLTYP_ll

!!pvrbls_ll      real,dimension(igm,jgm)::acfrcv_ll,acfrst_ll,acsnom_ll,cmc_ll,   &
      real, allocatable, dimension(:,:)::acfrcv_ll,acfrst_ll,acsnom_ll,cmc_ll,   &
      czen_ll,czmean_ll,epsr_ll,glat_ll,glon_ll,grnflx_ll,mxsnal_ll,potevp_ll,potflx_ll

!!pvrbls_ll      real,dimension(igm,jgm,lsm)::omgalf_ll,q2_ll,tcucn_ll,train_ll,div_ll,rtop_ll,htm_ll,vtm_ll, w_ll, dwdt_ll, z_ll
      real, allocatable, dimension(:,:,:)::omgalf_ll,q2_ll,tcucn_ll,train_ll,div_ll,rtop_ll,htm_ll,vtm_ll, w_ll, dwdt_ll, z_ll

!!pvrbls_ll      real,dimension(igm,jgm)::qwbs_ll,twbs_ll,sm_ll,fis_ll,q10_ll,th10_ll,qz0_ll,thz0_ll,  &
      real, allocatable, dimension(:,:)::qwbs_ll,twbs_ll,sm_ll,fis_ll,q10_ll,th10_ll,qz0_ll,thz0_ll,  &
      radot_ll,sigt4_ll,sfcevp_ll,subshx_ll,snopcx_ll,si_ll,sno_ll,sice_ll,smstot_ll,soiltb_ll,  &
      tg_ll,sr_ll,akhs_ll,akms_ll,ths_ll,plm_ll

!!pvrbls_ll      real,dimension(0:im+1,0:jm+1,nm):: u10ll,v10ll,uz0ll,vz0ll
!!pvrbls_ll      real,dimension(igm,jgm)::u10_ll,v10_ll,uz0_ll,vz0_ll,ustar_ll
      real, allocatable, dimension(:,:,:):: u10ll,v10ll,uz0ll,vz0ll
      real, allocatable, dimension(:,:)::u10_ll,v10_ll,uz0_ll,vz0_ll,ustar_ll

  contains

  subroutine alloc_pvrbls_ll

    include 'param_o.h'

!!pvrbls_ll       real,dimension(igm,jgm)::psurf_ll,tsfc_ll,pslp_ll,sfcshx_ll,sfclhx_ll,vegfrc_ll,z0_ll,albedo_ll
    ALLOCATE(psurf_ll(igm,jgm))
    ALLOCATE(tsfc_ll(igm,jgm))
    ALLOCATE(pslp_ll(igm,jgm))
    ALLOCATE(sfcshx_ll(igm,jgm))
    ALLOCATE(sfclhx_ll(igm,jgm))
    ALLOCATE(vegfrc_ll(igm,jgm))
    ALLOCATE(z0_ll(igm,jgm))
    ALLOCATE(albedo_ll(igm,jgm))
    psurf_ll = 0.0
    tsfc_ll = 0.0
    pslp_ll = 0.0
    sfcshx_ll = 0.0
    sfclhx_ll = 0.0
    vegfrc_ll = 0.0
    z0_ll = 0.0
    albedo_ll = 0.0

!!pvrbls_ll      real,dimension(igm,jgm)::RSWIN_ll,RSWOUT_ll,RSWTOA_ll,ASWIN_ll,ASWOUT_ll,ASWTOA_ll,rswnet_ll
    ALLOCATE(RSWIN_ll(igm,jgm))
    ALLOCATE(RSWOUT_ll(igm,jgm))
    ALLOCATE(RSWTOA_ll(igm,jgm))
    ALLOCATE(ASWIN_ll(igm,jgm))
    ALLOCATE(ASWOUT_ll(igm,jgm))
    ALLOCATE(ASWTOA_ll(igm,jgm))
    ALLOCATE(RSWnet_ll(igm,jgm))
    RSWIN_ll = 0.0
    RSWOUT_ll = 0.0
    RSWTOA_ll = 0.0
    ASWIN_ll = 0.0
    ASWOUT_ll = 0.0
    ASWTOA_ll = 0.0
    rswnet_ll = 0.0

!!pvrbls_ll      real,dimension(igm,jgm)::RLWIN_ll,RLWOUT_ll,RLWTOA_ll,ALWIN_ll,ALWOUT_ll,ALWTOA_ll,rlwnet_ll
    ALLOCATE(RLWIN_ll(igm,jgm))
    ALLOCATE(RLWOUT_ll(igm,jgm))
    ALLOCATE(RLWTOA_ll(igm,jgm))
    ALLOCATE(ALWIN_ll(igm,jgm))
    ALLOCATE(ALWOUT_ll(igm,jgm))
    ALLOCATE(ALWTOA_ll(igm,jgm))
    ALLOCATE(RLWnet_ll(igm,jgm))
    RLWIN_ll = 0.0
    RLWOUT_ll = 0.0
    RLWTOA_ll = 0.0
    ALWIN_ll = 0.0
    ALWOUT_ll = 0.0
    ALWTOA_ll = 0.0
    rlwnet_ll = 0.0

!!pvrbls_ll      real,dimension(igm,jgm,lsm)::RSWTT_ll,RLWTT_ll
    ALLOCATE(RSWTT_ll(igm,jgm,lsm))
    ALLOCATE(RLWTT_ll(igm,jgm,lsm))
    RSWTT_ll = 0.0
    RLWTT_ll = 0.0
    
!!pvrbls_ll      real,dimension(igm,jgm)::CUPPT_ll,cfracl_ll,cfracm_ll,cfrach_ll
    ALLOCATE(CUPPT_ll(igm,jgm))
    ALLOCATE(cfracl_ll(igm,jgm))
    ALLOCATE(cfracm_ll(igm,jgm))
    ALLOCATE(cfrach_ll(igm,jgm))
    CUPPT_ll = 0.0
    cfracl_ll = 0.0
    cfracm_ll = 0.0
    cfrach_ll = 0.0

!!pvrbls_ll      real,dimension(igm,jgm)::acprec_ll,cuprec_ll,aprec_ll,acsnow_ll,prec_ll
    ALLOCATE(acprec_ll(igm,jgm))
    ALLOCATE(cuprec_ll(igm,jgm))
    ALLOCATE(aprec_ll(igm,jgm))
    ALLOCATE(acsnow_ll(igm,jgm))
    ALLOCATE(prec_ll(igm,jgm))
    acprec_ll = 0.0
    cuprec_ll = 0.0
    aprec_ll = 0.0
    acsnow_ll = 0.0
    prec_ll = 0.0

!!pvrbls_ll      real,dimension(igm,jgm,nsoil)::stc_ll,smc_ll
    ALLOCATE(stc_ll(igm,jgm,nsoil))
    ALLOCATE(smc_ll(igm,jgm,nsoil))
    stc_ll = 0.0
    smc_ll = 0.0

!!pvrbls_ll      real,dimension(igm,jgm)::tshltr_ll,qshltr_ll,albase_ll,cnvtop_ll,cnvbot_ll,htop_ll,hbot_ll
    ALLOCATE(tshltr_ll(igm,jgm))
    ALLOCATE(qshltr_ll(igm,jgm))
    ALLOCATE(albase_ll(igm,jgm))
    ALLOCATE(cnvtop_ll(igm,jgm))
    ALLOCATE(cnvbot_ll(igm,jgm))
    ALLOCATE(htop_ll(igm,jgm))
    ALLOCATE(hbot_ll(igm,jgm))
    tshltr_ll = 0.0
    qshltr_ll = 0.0
    albase_ll = 0.0
    cnvtop_ll = 0.0
    cnvbot_ll = 0.0
    htop_ll = 0.0
    hbot_ll = 0.0

!!pvrbls_ll      integer,dimension(igm,jgm)::IVGTYP_ll,ISLTYP_ll
    ALLOCATE(IVGTYP_ll(igm,jgm))
    ALLOCATE(ISLTYP_ll(igm,jgm))
    IVGTYP_ll = 0
    ISLTYP_ll = 0

!!pvrbls_ll      real,dimension(igm,jgm)::acfrcv_ll,acfrst_ll,acsnom_ll,cmc_ll,   &
!!      czen_ll,czmean_ll,epsr_ll,glat_ll,glon_ll,grnflx_ll,mxsnal_ll,potevp_ll,potflx_ll
    ALLOCATE(acfrcv_ll(igm,jgm))
    ALLOCATE(acfrst_ll(igm,jgm))
    ALLOCATE(acsnom_ll(igm,jgm))
    ALLOCATE(cmc_ll(igm,jgm))
    ALLOCATE(czen_ll(igm,jgm))
    ALLOCATE(czmean_ll(igm,jgm))
    ALLOCATE(epsr_ll(igm,jgm))
    ALLOCATE(glat_ll(igm,jgm))
    ALLOCATE(glon_ll(igm,jgm))
    ALLOCATE(grnflx_ll(igm,jgm))
    ALLOCATE(mxsnal_ll(igm,jgm))
    ALLOCATE(potevp_ll(igm,jgm))
    ALLOCATE(potflx_ll(igm,jgm))
    acfrcv_ll = 0.0
    acfrst_ll = 0.0
    acsnom_ll = 0.0
    cmc_ll = 0.0
    czen_ll = 0.0
    czmean_ll = 0.0
    epsr_ll = 0.0
    glat_ll = 0.0
    glon_ll = 0.0
    grnflx_ll = 0.0
    mxsnal_ll = 0.0
    potevp_ll = 0.0
    potflx_ll = 0.0

!!pvrbls_ll      real,dimension(igm,jgm,lsm)::omgalf_ll,q2_ll,tcucn_ll,train_ll,div_ll,rtop_ll,htm_ll,vtm_ll, w_ll, dwdt_ll, z_ll
    ALLOCATE(omgalf_ll(igm,jgm,lsm))
    ALLOCATE(q2_ll(igm,jgm,lsm))
    ALLOCATE(tcucn_ll(igm,jgm,lsm))
    ALLOCATE(train_ll(igm,jgm,lsm))
    ALLOCATE(div_ll(igm,jgm,lsm))
    ALLOCATE(rtop_ll(igm,jgm,lsm))
    ALLOCATE(htm_ll(igm,jgm,lsm))
    ALLOCATE(vtm_ll(igm,jgm,lsm))
    ALLOCATE(w_ll(igm,jgm,lsm))
    ALLOCATE(dwdt_ll(igm,jgm,lsm))
    ALLOCATE(z_ll(igm,jgm,lsm))
    omgalf_ll = 0.0
    q2_ll = 0.0
    tcucn_ll = 0.0
    train_ll = 0.0
    div_ll = 0.0
    rtop_ll = 0.0
    htm_ll = 0.0
    vtm_ll = 0.0
    w_ll = 0.0
    dwdt_ll = 0.0
    z_ll = 0.0

!!pvrbls_ll      real,dimension(igm,jgm)::qwbs_ll,twbs_ll,sm_ll,fis_ll,q10_ll,th10_ll,qz0_ll,thz0_ll,  &
!!      radot_ll,sigt4_ll,sfcevp_ll,subshx_ll,snopcx_ll,si_ll,sno_ll,sice_ll,smstot_ll,soiltb_ll,  &
!!      tg_ll,sr_ll,akhs_ll,akms_ll,ths_ll,plm_ll
    ALLOCATE(qwbs_ll(igm,jgm))
    ALLOCATE(twbs_ll(igm,jgm))
    ALLOCATE(sm_ll(igm,jgm))
    ALLOCATE(fis_ll(igm,jgm))
    ALLOCATE(q10_ll(igm,jgm))
    ALLOCATE(th10_ll(igm,jgm))
    ALLOCATE(qz0_ll(igm,jgm))
    ALLOCATE(thz0_ll(igm,jgm))
    ALLOCATE(radot_ll(igm,jgm))
    ALLOCATE(sigt4_ll(igm,jgm))
    ALLOCATE(sfcevp_ll(igm,jgm))
    ALLOCATE(subshx_ll(igm,jgm))
    ALLOCATE(snopcx_ll(igm,jgm))
    ALLOCATE(si_ll(igm,jgm))
    ALLOCATE(sno_ll(igm,jgm))
    ALLOCATE(sice_ll(igm,jgm))
    ALLOCATE(smstot_ll(igm,jgm))
    ALLOCATE(soiltb_ll(igm,jgm))
    ALLOCATE(tg_ll(igm,jgm))
    ALLOCATE(sr_ll(igm,jgm))
    ALLOCATE(akhs_ll(igm,jgm))
    ALLOCATE(akms_ll(igm,jgm))
    ALLOCATE(ths_ll(igm,jgm))
    ALLOCATE(plm_ll(igm,jgm))
    qwbs_ll = 0.0
    twbs_ll = 0.0
    sm_ll = 0.0
    fis_ll = 0.0
    q10_ll = 0.0
    th10_ll = 0.0
    qz0_ll = 0.0
    thz0_ll = 0.0
     
    radot_ll = 0.0
    sigt4_ll = 0.0
    sfcevp_ll = 0.0
    subshx_ll = 0.0
    snopcx_ll = 0.0
    si_ll = 0.0
    sno_ll = 0.0
    sice_ll = 0.0
    smstot_ll = 0.0
    soiltb_ll = 0.0
     
    tg_ll = 0.0
    sr_ll = 0.0
    akhs_ll = 0.0
    akms_ll = 0.0
    ths_ll = 0.0
    plm_ll = 0.0

!!pvrbls_ll      real,dimension(0:im+1,0:jm+1,nm):: u10ll,v10ll,uz0ll,vz0ll
!!pvrbls_ll      real,dimension(igm,jgm)::u10_ll,v10_ll,uz0_ll,vz0_ll,ustar_ll
    ALLOCATE(u10ll(0:im+1,0:jm+1,nm))
    ALLOCATE(v10ll(0:im+1,0:jm+1,nm))
    ALLOCATE(uz0ll(0:im+1,0:jm+1,nm))
    ALLOCATE(vz0ll(0:im+1,0:jm+1,nm))
    u10ll = 0.0
    v10ll = 0.0
    uz0ll = 0.0
    vz0ll = 0.0

    ALLOCATE(u10_ll(igm,jgm))
    ALLOCATE(v10_ll(igm,jgm))
    ALLOCATE(uz0_ll(igm,jgm))
    ALLOCATE(vz0_ll(igm,jgm))
    ALLOCATE(ustar_ll(igm,jgm))
    u10_ll = 0.0
    v10_ll = 0.0
    uz0_ll = 0.0
    vz0_ll = 0.0
    ustar_ll = 0.0

  end subroutine alloc_pvrbls_ll

  subroutine dealloc_pvrbls_ll

    DEALLOCATE(psurf_ll, tsfc_ll, pslp_ll, sfcshx_ll, sfclhx_ll, vegfrc_ll, z0_ll, albedo_ll)
    DEALLOCATE(RSWIN_ll, RSWOUT_ll, RSWTOA_ll, ASWIN_ll, ASWOUT_ll, ASWTOA_ll, rswnet_ll)
    DEALLOCATE(RLWIN_ll, RLWOUT_ll, RLWTOA_ll, ALWIN_ll, ALWOUT_ll, ALWTOA_ll, rlwnet_ll)
    DEALLOCATE(RSWTT_ll, RLWTT_ll, CUPPT_ll, cfracl_ll, cfracm_ll, cfrach_ll, acprec_ll, cuprec_ll, aprec_ll, acsnow_ll, prec_ll, stc_ll, smc_ll)
    DEALLOCATE(tshltr_ll, qshltr_ll, albase_ll, cnvtop_ll, cnvbot_ll, htop_ll, hbot_ll, IVGTYP_ll, ISLTYP_ll)
    DEALLOCATE(acfrcv_ll, acfrst_ll, acsnom_ll, cmc_ll, czen_ll, czmean_ll, epsr_ll, glat_ll, glon_ll, grnflx_ll, mxsnal_ll, potevp_ll, potflx_ll)
    DEALLOCATE(omgalf_ll, q2_ll, tcucn_ll, train_ll, div_ll, rtop_ll, htm_ll, vtm_ll, w_ll, dwdt_ll, z_ll)
    DEALLOCATE(qwbs_ll, twbs_ll, sm_ll, fis_ll, q10_ll, th10_ll, qz0_ll, thz0_ll, radot_ll, sigt4_ll, sfcevp_ll, subshx_ll, snopcx_ll, si_ll, sno_ll, sice_ll, smstot_ll, soiltb_ll, tg_ll, sr_ll, akhs_ll, akms_ll, ths_ll, plm_ll)
    DEALLOCATE(u10ll, v10ll, uz0ll, vz0ll, u10_ll, v10_ll, uz0_ll, vz0_ll, ustar_ll)

  end subroutine dealloc_pvrbls_ll

end module mod_pvrbls_ll
