Skip to content

Commit

Permalink
Merge pull request noaa-oar-arl#117 from noaa-oar-arl/lad_out
Browse files Browse the repository at this point in the history
Adding LAD as output
  • Loading branch information
drnimbusrain authored Feb 15, 2024
2 parents a84a6ac + 7122b6f commit d02da85
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Current Canopy-App components:
| `emi_ovoc` | Other VOC emissions (49 compounds, Table 1 Guenther et al. (2012) |

**Current Canopy-App Output:** As discussed above, the current Canopy-App optional outputs includes 3D canopy winds (`canwind`), canopy vertical/eddy diffusivity values `kz`), biogenic emissions (see Table 1), and
canopy photolysis attenuation correction factors (`rjcf`). Current 2D fields includes the Wind Adjustment Factor (`waf`).
canopy photolysis attenuation correction factors (`rjcf`), and derived Leaf Area Density (`lad`) from the foliage shape function. Current 2D fields includes the Wind Adjustment Factor (`waf`), flame heights (`flameh`), and canopy heights (`canheight`). Current 1D fields include the canopy model interface levels (`z`).

Namelist Option : `file_out` Prefix string (e.g., `'test'`) used to name output file (Output is 1D txt when using input 1D data (i.e., `infmt_opt=1`), or is 2D NetCDF output when 2D NetCDF input is used (i.e., `infmt_opt=0`)).

Expand Down
2 changes: 2 additions & 0 deletions src/canopy_alloc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ SUBROUTINE canopy_alloc
if(.not.allocated(ppfd_sun)) allocate(ppfd_sun(modlays))
if(.not.allocated(ppfd_shade)) allocate(ppfd_shade(modlays))
if(.not.allocated(ppfd_ave)) allocate(ppfd_ave(modlays))
if(.not.allocated(lad)) allocate(lad(nlat*nlon,modlays))
if(.not.allocated(lad_3d)) allocate(lad_3d(nlon,nlat,modlays))

!-------------------------------------------------------------------------------
! Allocate arrays for Canopy Wind Outputs
Expand Down
26 changes: 26 additions & 0 deletions src/canopy_calcs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ SUBROUTINE canopy_calcs(nn)
end if
end if

! ... calculate leaf area density profile from foliage shape function for output (m2/m3)
do k=1, modlays
if (zk(k) .gt. 0.0 .and. zk(k) .le. hcmref) then ! above ground level and at/below canopy top
if (k .lt. modlays) then
lad_3d(i,j,k) = ((fafraczInt(k+1) - fafraczInt(k))*lairef)/modres
else
lad_3d(i,j,k) = lad_3d(i,j,modlays-1)
end if
else
lad_3d(i,j,k) = 0.0_rk
end if
end do

! ... calculate zero-plane displacement height/hc and surface (soil+veg) roughness lengths/hc
call canopy_zpd(zhc(1:cansublays), fafraczInt(1:cansublays), &
ubzref, z0ghc, lambdars, cdrag, pai, hcmref, hgtref, &
Expand Down Expand Up @@ -585,6 +598,19 @@ SUBROUTINE canopy_calcs(nn)
end if
end if

! ... calculate leaf area density profile from foliage shape function for output (m2/m3)
do k=1, modlays
if (zk(k) .gt. 0.0 .and. zk(k) .le. hcmref) then ! above ground level and at/below canopy top
if (k .lt. modlays) then
lad(loc,k) = ((fafraczInt(k+1) - fafraczInt(k))*lairef)/modres
else
lad(loc,k) = lad(loc,modlays-1)
end if
else
lad(loc,k) = 0.0_rk
end if
end do

! ... calculate zero-plane displacement height/hc and surface (soil+veg) roughness lengths/hc

call canopy_zpd(zhc(1:cansublays), fafraczInt(1:cansublays), &
Expand Down
3 changes: 3 additions & 0 deletions src/canopy_canvars_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ MODULE canopy_canvars_mod
real(rk), allocatable :: ppfd_ave ( : ) ! Average PPFD for sunlit and shaded leaves (umol phot/m2 s)
real(rk), allocatable :: canBOT ( : ) ! Canopy bottom wind reduction factors
real(rk), allocatable :: canTOP ( : ) ! Canopy top wind reduction factors
real(rk), allocatable :: lad ( : , : ) ! Leaf Area Density calculated from foliage shape function (m2/m3)
real(rk), allocatable :: lad_3d ( : , : , : ) ! Leaf Area Density calculated from foliage shape function (m2/m3)
real(rk), allocatable :: canWIND ( : , : ) ! canopy wind speeds (m/s)
real(rk), allocatable :: canWIND_3d ( : , : , : ) ! canopy wind speeds -- 3D (m/s)
real(rk), allocatable :: dx ( : ) ! Model grid cell distance/resolution (m)
Expand Down Expand Up @@ -199,6 +201,7 @@ MODULE canopy_canvars_mod
!-------------------------------------------------------------------------------

TYPE(fld3ddata), ALLOCATABLE, TARGET :: fld3dxyzt ( : )
TYPE(fld3ddata), POINTER :: c_lad
TYPE(fld3ddata), POINTER :: c_canwind
TYPE(fld3ddata), POINTER :: c_Kz
TYPE(fld3ddata), POINTER :: c_rjcf
Expand Down
2 changes: 2 additions & 0 deletions src/canopy_dealloc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ SUBROUTINE canopy_dealloc
if(allocated(ppfd_sun)) deallocate(ppfd_sun)
if(allocated(ppfd_shade)) deallocate(ppfd_shade)
if(allocated(ppfd_ave)) deallocate(ppfd_ave)
if(allocated(lad)) deallocate(lad)
if(allocated(lad_3d)) deallocate(lad_3d)

!-------------------------------------------------------------------------------
! Deallocate arrays for Canopy Wind
Expand Down
6 changes: 5 additions & 1 deletion src/canopy_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ SUBROUTINE canopy_init
if(allocated(tleaf_ave)) tleaf_ave(:) = fillreal
if(allocated(ppfd_sun)) ppfd_sun(:) = fillreal
if(allocated(ppfd_shade)) ppfd_shade(:) = fillreal
if(allocated(ppfd_ave)) ppfd_ave(:) = fillreal
if(allocated(ppfd_ave)) ppfd_ave(:) = fillreal
if(allocated(lad)) lad(:,:) = fillreal
if(allocated(lad_3d)) lad_3d(:,:,:) = fillreal

!-------------------------------------------------------------------------------
! Initialize arrays for Canopy Wind
Expand All @@ -40,6 +42,8 @@ SUBROUTINE canopy_init
if(allocated(canWIND_3d)) canWIND_3d(:,:,:) = fillreal
if(allocated(dx)) dx(:) = fillreal
if(allocated(dx_2d)) dx_2d(:,:) = fillreal
if(allocated(flameh)) flameh(:) = fillreal
if(allocated(flameh_2d)) flameh_2d(:,:) = fillreal
if(allocated(waf)) waf(:) = fillreal
if(allocated(waf_2d)) waf_2d(:,:) = fillreal
end if
Expand Down
26 changes: 25 additions & 1 deletion src/canopy_ncf_io_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,21 @@ SUBROUTINE canopy_outncf_init
!-------------------------------------------------------------------------------
! Time-varying 3d fields at cell centers.
!-------------------------------------------------------------------------------
c_lad%fld = fillreal
c_lad%fldname = 'lad'
c_lad%long_name = 'leaf area density'
c_lad%units = 'm2 m-3'
c_lad%fillvalue = fillreal
c_lad%dimnames(1) = 'nlon'
c_lad%dimnames(2) = 'nlat'
c_lad%dimnames(3) = 'modlays'
c_lad%istart(1) = 1
c_lad%istart(2) = 1
c_lad%istart(3) = 1
c_lad%iend(1) = nlon
c_lad%iend(2) = nlat
c_lad%iend(3) = modlays

if (ifcanwind .or. ifcanwaf) then
c_canwind%fld = fillreal
c_canwind%fldname = 'ws'
Expand Down Expand Up @@ -804,7 +819,9 @@ SUBROUTINE canopy_outncf_alloc
! Time-varying 2d fields at cell centers.
!-------------------------------------------------------------------------------

nfld2dxyt = 1 ! canopy height
nfld2dxyt = 0

nfld2dxyt = nfld2dxyt +1 ! canopy height

if (ifcanwind .or. ifcanwaf) then
nfld2dxyt = nfld2dxyt + 1 !WAF
Expand Down Expand Up @@ -832,6 +849,8 @@ SUBROUTINE canopy_outncf_alloc

nfld3dxyzt = 0

nfld3dxyzt = nfld3dxyzt + 1 !LAD

if (ifcanwind .or. ifcanwaf) then
nfld3dxyzt = nfld3dxyzt + 1 !CANWIND
end if
Expand Down Expand Up @@ -873,6 +892,10 @@ SUBROUTINE canopy_outncf_alloc
ENDDO

set_index = 0

set_index = set_index + 1
c_lad => fld3dxyzt( set_index )

if (ifcanwind .or. ifcanwaf) then
set_index = set_index + 1
c_canwind => fld3dxyzt( set_index )
Expand Down Expand Up @@ -1906,6 +1929,7 @@ SUBROUTINE canopy_write_ncf (OUTPREFX)
!-------------------------------------------------------------------------------
! Time-varying 3d fields at cell centers.
!-------------------------------------------------------------------------------
c_lad%fld = lad_3d
if (ifcanwind .or. ifcanwaf) then
c_canwind%fld = canWIND_3d
end if
Expand Down
28 changes: 14 additions & 14 deletions src/canopy_txt_io_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ SUBROUTINE write_txt(TXTPREFX,TIMENOW)
write(10, '(a15, a24)') 'time stamp: ', TIMENOW
write(10, '(a30, f6.1, a2)') 'reference height, h: ', href_set, 'm'
write(10, '(a30, i6)') 'number of model layers: ', modlays
write(10, '(a8, a9, a12, a17)') 'lat', 'lon', 'height (m)', 'ws (m s-1)'
write(10, '(a8, a9, a12, a13, a17)') 'lat', 'lon', 'height (m)', 'LAD (m2 m-3)', 'ws (m s-1)'
do loc=1, nlat*nlon
do k=1, modlays
write(10, '(f8.2, f9.2, f12.2, es15.7)') variables(loc)%lat, variables(loc)%lon, &
zk(k), canWIND(loc, k)
write(10, '(f8.2, f9.2, f10.2, f12.2, es15.7)') variables(loc)%lat, variables(loc)%lon, &
zk(k), lad(loc,k), canWIND(loc, k)
end do
end do
end if
Expand Down Expand Up @@ -122,11 +122,11 @@ SUBROUTINE write_txt(TXTPREFX,TIMENOW)
write(12, '(a15, a24)') 'time stamp: ', TIMENOW
write(12, '(a30, f6.1, a2)') 'reference height, h: ', href_set, 'm'
write(12, '(a30, i6)') 'number of model layers: ', modlays
write(12, '(a8, a9, a12, a15)') 'lat', 'lon', 'height (m)', 'kz (m2 s-1)'
write(12, '(a8, a9, a12, a13, a15)') 'lat', 'lon', 'height (m)', 'LAD (m2 m-3)', 'kz (m2 s-1)'
do loc=1, nlat*nlon
do k=1, modlays
write(12, '(f8.2, f9.2, f12.2, es15.7)') variables(loc)%lat, variables(loc)%lon, &
zk(k), Kz(loc,k)
write(12, '(f8.2, f9.2, f12.2, f12.2, es15.7)') variables(loc)%lat, variables(loc)%lon, &
zk(k), lad(loc,k), Kz(loc,k)
end do
end do
end if
Expand All @@ -139,11 +139,11 @@ SUBROUTINE write_txt(TXTPREFX,TIMENOW)
write(13, '(a15, a24)') 'time stamp: ', TIMENOW
write(13, '(a30, f6.1, a2)') 'reference height, h: ', href_set, 'm'
write(13, '(a30, i6)') 'number of model layers: ', modlays
write(13, '(a8, a9, a12, a15)') 'lat', 'lon', 'height (m)', 'rjcf (1)'
write(13, '(a8, a9, a12, a13, a15)') 'lat', 'lon', 'height (m)', 'LAD (m2 m-3)', 'rjcf (1)'
do loc=1, nlat*nlon
do k=1, modlays
write(13, '(f8.2, f9.2, f12.2, es15.7)') variables(loc)%lat, variables(loc)%lon, &
zk(k), rjcf(loc,k)
write(13, '(f8.2, f9.2, f12.2, f12.2, es15.7)') variables(loc)%lat, variables(loc)%lon, &
zk(k), lad(loc,k), rjcf(loc,k)
end do
end do
end if
Expand All @@ -155,8 +155,8 @@ SUBROUTINE write_txt(TXTPREFX,TIMENOW)
write(14, '(a15, a24)') 'time stamp: ', TIMENOW
write(14, '(a30, f6.1, a2)') 'reference height, h: ', href_set, 'm'
write(14, '(a30, i6)') 'number of model layers: ', modlays
write(14, '(a8, a9, a12, a28, a28, a28, a28, a28, a28, a28, a28, a28, a28, &
& a28, a28, a28, a28, a28, a28, a28, a28, a28)') 'lat', 'lon', 'height (m)', &
write(14, '(a8, a9, a12, a13, a28, a28, a28, a28, a28, a28, a28, a28, a28, a28, &
& a28, a28, a28, a28, a28, a28, a28, a28, a28)') 'lat', 'lon', 'height (m)', 'LAD (m2 m-3)', &
'emi_isop (kg m-3 s-1)', 'emi_myrc (kg m-3 s-1)', 'emi_sabi (kg m-3 s-1)', &
'emi_limo (kg m-3 s-1)', 'emi_care (kg m-3 s-1)', 'emi_ocim (kg m-3 s-1)', &
'emi_bpin (kg m-3 s-1)', 'emi_apin (kg m-3 s-1)', 'emi_mono (kg m-3 s-1)', &
Expand All @@ -166,11 +166,11 @@ SUBROUTINE write_txt(TXTPREFX,TIMENOW)
'emi_ovoc (kg m-3 s-1)'
do loc=1, nlat*nlon
do k=1, modlays
write(14, '(f8.2, f9.2, f12.2, es15.7, es15.7, es15.7, es15.7, es15.7, es15.7, &
write(14, '(f8.2, f9.2, f12.2, f12.2, es15.7, es15.7, es15.7, es15.7, es15.7, es15.7, &
& es15.7, es15.7, es15.7, es15.7, es15.7, es15.7, es15.7, es15.7, &
& es15.7, es15.7, es15.7, es15.7, es15.7)') &
variables(loc)%lat, variables(loc)%lon, &
zk(k), emi_isop(loc,k), emi_myrc(loc,k), emi_sabi(loc,k), emi_limo(loc,k), &
variables(loc)%lat, variables(loc)%lon, zk(k), &
lad(loc,k), emi_isop(loc,k), emi_myrc(loc,k), emi_sabi(loc,k), emi_limo(loc,k), &
emi_care(loc,k), emi_ocim(loc,k), emi_bpin(loc,k), emi_apin(loc,k), &
emi_mono(loc,k), emi_farn(loc,k), emi_cary(loc,k), emi_sesq(loc,k), &
emi_mbol(loc,k), emi_meth(loc,k), emi_acet(loc,k), emi_co(loc,k), &
Expand Down

0 comments on commit d02da85

Please sign in to comment.