Hi Jesse,
Thanks a lot for your guidance.
I was able to successfully output the resistances after a few tries.
Appreciate your help a lot!
I am sharing the changes that I made here, so that if anyone else in the community wants, they can just use it.
CMAQv5.4
ASX_DATA_MOD.F (3 changes):
- under “Sub grid cell resistances”, line 190
- under “Allocation”, line 548
- just after step (2), initiate with 0.0
(1)
!> Sub grid cell resistances
Real, Allocatable :: RA ( :,:,: ) ! aerodynamic resistance [s/m]
Real, Allocatable :: RB ( :,:,: ) ! quasi-laminar soil/water resistance [s/m]
Real, Allocatable :: RB_L ( :,:,: ) ! quasi-laminary leaf resistance [s/m]
Real, Allocatable :: RSTW ( :,:,: ) ! Stomatal Resistance of water [s/m]
Real, Allocatable :: RCUT ( :,:,: ) ! cuticlular resistance [s/m]
Real, Allocatable :: RGC ( :,:,: ) ! under canopy soil resistance [s/m]
Real, Allocatable :: RG ( :,:,: ) ! soil resistance [s/m]
Real, Allocatable :: RWAT ( :,:,: ) ! surface water resistance [s/m]
(2)
ALLOCATE( Mosaic_Data%USTAR ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%LAI ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%DELTA ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%VEG ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%Z0 ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%RA ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%RB ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%RB_L ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%RSTW ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%RCUT ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%RGC ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%RG ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%RWAT ( NCOLS,NROWS,Tile_Data%n_lufrac ),
& Mosaic_Data%NAME ( Tile_Data%n_lufrac ),
& Mosaic_Data%LU_Type ( Tile_Data%n_lufrac ),
& STAT = ALLOCSTAT )
(3)
Mosaic_Data%USTAR = 0.0
Mosaic_Data%LAI = 0.0
Mosaic_Data%DELTA = 0.0
Mosaic_Data%VEG = 0.0
Mosaic_Data%Z0 = 0.0
Mosaic_Data%RSTW = 1.0e6
Mosaic_Data%RA = 1.0e6
Mosaic_Data%RB = 1.0e6
Mosaic_Data%RB_L = 0.0
Mosaic_Data%RCUT = 0.0
Mosaic_Data%RGC = 0.0
Mosaic_Data%RG = 0.0
Mosaic_Data%RWAT = 0.0
Mosaic_Data%NAME = Tile_Data%name_lu
Mosaic_Data%LU_Type = Tile_Data%cat_lu
STAGE_MOD.F:
!-------------------------------------------------------------------------------------------------
! Quasi-laminar boundary layer resistance
!-------------------------------------------------------------------------------------------------
Rb = Calc_Rbw( ustar, scc_pr_23 )
!-------------------------------------------------------------------------------------------------
! Air-water exchange
!-------------------------------------------------------------------------------------------------
If( Water( l ) ) Then
!-------------------------------------------------------------------------------------------------
! Resistance to surface water
!-------------------------------------------------------------------------------------------------
Rwat = Calc_Rwater( ustar, q_2m, temp_2m, temp_g, tw, LeBasM( s ), heff_wat, O3_hit,
& Hg_hit, sea_ice )
If(c_wat .Gt. 0.0 ) Then
LU_Emis = c_wat / ( Ra + Rb + Rwat )
End If
Tile_Data%Lu_Vd( c,r,n,l ) = 1.0 / ( Ra + Rb + Rwat )
f_wat = f_wat + frac_lu * ( c_wat - c_atm ) / ( Ra + Rb + Rwat )
Mosaic_Data%RWAT( c,r,l ) = Rwat
Mosaic_Data%RB( c,r,l ) = Rb
Else
!-------------------------------------------------------------------------------------------------
! Air-land exchange
!-------------------------------------------------------------------------------------------------
! Resistance to air-canopy exchange
!-------------------------------------------------------------------------------------------------
C Calculate Rst
If( lai .Gt. 0.0 ) Then
!-------------------------------------------------------------------------------------------------
! Quazi Laminar Resistance to leaf
!-------------------------------------------------------------------------------------------------
Rb_leaf = Calc_Rb_leaf( k_vis, dif_T, ustar, l_leaf, lai )
!-------------------------------------------------------------------------------------------------
! Resistance to air-stomatal exchange
!-------------------------------------------------------------------------------------------------
Rst = Calc_Rst( Mosaic_Data%RSTW( c,r,l ), dwat_T, dif_T, heff_ap, f0( s ), lai )
!-------------------------------------------------------------------------------------------------
! Resistance to air-cuticle exchange
!-------------------------------------------------------------------------------------------------
Rcut = Calc_Rcut( temp_g, rel_rx(s), molwt_all( s ), M_ac( s ), heff, dif_T,
& a_cut( l ), snow, no_snow, dry, wet, rh, lai, O3_hit, NH3_hit, ABFLUX )
Mosaic_Data%RCUT( c,r,l ) = Rcut
Mosaic_Data%RB_L( c,r,l ) = Rb_leaf
!-------------------------------------------------------------------------------------------------
! Resistance to air-canopy covered soil exchange
!-------------------------------------------------------------------------------------------------
Else ! LAI = 0.0
Rst = 1.0e6
Rcut = 1.0e6
Rb_leaf = 1.0e6
End If ! LAI
!-------------------------------------------------------------------------------------------------
! Resistance to air-base soil exchange
!-------------------------------------------------------------------------------------------------
If( ABFLUX .And. NH3_Hit ) Then
Call Get_NH3_Comp( c_stom, c_ll, c_grnd, dif_T, r, c, l, l_ag ) ! Qauzi Laminar Boundary Layer resistance
End If ! ABFLUX and NH3
Rgc = Calc_Rg( dif_T, k_vis, rel_rx( s ), Ra, ustar, lai, temp_g, molwt_all( s ), M_ac( s ),
& heff, sm_v1cm,sm_v5cm, sm_vsat, sm_vfc, sm_vwlt, sm_vres, sm_bslp, zsoil1,
& ir_frac, dry, wet, snow, no_snow, O3_Hit, NH3_Hit, ABFLUX )
Rg = Calc_Rg( dif_T, k_vis, rel_rx( s ), Ra, ustar, 0.0, temp_g, molwt_all( s ), M_ac( s ),
& heff, sm_v1cm,sm_v5cm, sm_vsat, sm_vfc, sm_vwlt, sm_vres, sm_bslp, zsoil1,
& ir_frac, dry, wet, snow, no_snow, O3_Hit, NH3_Hit, ABFLUX )
Mosaic_Data%RGC( c,r,l ) = Rgc
Mosaic_Data%RG( c,r,l ) = Rg
STAGE_OUTPUT.F (3 changes):
- increase number of NVARS3D from + 7 to + 13
- under “Set output file characteristics based on GRIDDESC and open the dep velocity dignostic file” line 146
- under “STAGE Diagnostic Output” line 258
(1)
NVARS3D = Tile_Data%n_Vd + 13
(2)
N = 0
N = N + 1 ! 1
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'RA'
UNITS3D( N ) = 's m-1'
VDESC3D( N ) = 'aerodynamic resistance for land use category'
N = N + 1 ! 2
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'LUFRAC'
UNITS3D( N ) = 'dimensionless'
VDESC3D( N ) = 'Fractional land use'
N = N + 1 ! 3
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'LAI'
UNITS3D( N ) = 'dimensionless'
VDESC3D( N ) = 'leaf area index for land use category'
N = N + 1 ! 4
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'USTAR'
UNITS3D( N ) = 'm s-1'
VDESC3D( N ) = 'friction velocity for land use category'
N = N + 1 ! 5
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'Z0'
UNITS3D( N ) = 'm'
VDESC3D( N ) = 'surface roughness for land use category'
N = N + 1 ! 6
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'RST'
UNITS3D( N ) = 's m-1'
VDESC3D( N ) = 'Stomatal resistance to water vapor'
N = N + 1 ! 7
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'VEG'
UNITS3D( N ) = 'ratio'
VDESC3D( N ) = 'Vegetation coverage'
N = N + 1 ! 8
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'RB'
UNITS3D( N ) = 's m-1'
VDESC3D( N ) = 'quasi-laminar soil/water resistance'
N = N + 1 ! 9
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'RB_L'
UNITS3D( N ) = 's m-1'
VDESC3D( N ) = 'quasi-laminary leaf resistance'
N = N + 1 ! 10
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'RCUT'
UNITS3D( N ) = 's m-1'
VDESC3D( N ) = 'cuticlular resistance'
N = N + 1 ! 11
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'RGC'
UNITS3D( N ) = 's m-1'
VDESC3D( N ) = 'under canopy soil resistance'
N = N + 1 ! 12
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'RG'
UNITS3D( N ) = 's m-1'
VDESC3D( N ) = 'soil resistance'
N = N + 1 ! 13
VTYPE3D( N ) = M3REAL
VNAME3D( N ) = 'RWAT'
UNITS3D( N ) = 's m-1'
VDESC3D( N ) = 'surface water resistance'
(3)
IF ( .NOT. WRITE3( CTM_DEPV_MOS, 'LUFRAC',
& DATE, TIME, Tile_Data%LUFRAC ) ) THEN
XMSG = 'Could not write ' // CTM_DEPV_MOS // ' file'
CALL M3EXIT ( PNAME, DATE, TIME, XMSG, XSTAT1 )
END IF
IF ( .NOT. WRITE3( CTM_DEPV_MOS, 'RA',
& DATE, TIME, MOSAIC_DATA%RA ) ) THEN
XMSG = 'Could not write ' // CTM_DEPV_MOS // ' file'
CALL M3EXIT ( PNAME, DATE, TIME, XMSG, XSTAT1 )
END IF
IF ( .NOT. WRITE3( CTM_DEPV_MOS, 'RB',
& DATE, TIME, Mosaic_Data%RB ) ) THEN
XMSG = 'Could not write ' // CTM_DEPV_MOS // ' file'
CALL M3EXIT ( PNAME, DATE, TIME, XMSG, XSTAT1 )
END IF
IF ( .NOT. WRITE3( CTM_DEPV_MOS, 'RB_L',
& DATE, TIME, Mosaic_Data%RB_L ) ) THEN
XMSG = 'Could not write ' // CTM_DEPV_MOS // ' file'
CALL M3EXIT ( PNAME, DATE, TIME, XMSG, XSTAT1 )
END IF
IF ( .NOT. WRITE3( CTM_DEPV_MOS, 'RST',
& DATE, TIME, Mosaic_Data%RSTW ) ) THEN
XMSG = 'Could not write ' // CTM_DEPV_MOS // ' file'
CALL M3EXIT ( PNAME, DATE, TIME, XMSG, XSTAT1 )
END IF
IF ( .NOT. WRITE3( CTM_DEPV_MOS, 'RCUT',
& DATE, TIME, Mosaic_Data%RCUT ) ) THEN
XMSG = 'Could not write ' // CTM_DEPV_MOS // ' file'
CALL M3EXIT ( PNAME, DATE, TIME, XMSG, XSTAT1 )
END IF
IF ( .NOT. WRITE3( CTM_DEPV_MOS, 'RGC',
& DATE, TIME, Mosaic_Data%RGC ) ) THEN
XMSG = 'Could not write ' // CTM_DEPV_MOS // ' file'
CALL M3EXIT ( PNAME, DATE, TIME, XMSG, XSTAT1 )
END IF
IF ( .NOT. WRITE3( CTM_DEPV_MOS, 'RG',
& DATE, TIME, Mosaic_Data%RG ) ) THEN
XMSG = 'Could not write ' // CTM_DEPV_MOS // ' file'
CALL M3EXIT ( PNAME, DATE, TIME, XMSG, XSTAT1 )
END IF
IF ( .NOT. WRITE3( CTM_DEPV_MOS, 'RWAT',
& DATE, TIME, Mosaic_Data%RWAT ) ) THEN
XMSG = 'Could not write ' // CTM_DEPV_MOS // ' file'
CALL M3EXIT ( PNAME, DATE, TIME, XMSG, XSTAT1 )
END IF
Best,
Kiarash