Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #46

Merged
merged 4 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
DEBUG: 0
FC: ${{ matrix.compiler }}

- name: Non-NetCDF comile and run
- name: Non-NetCDF compile and run
run: |
make clean
make
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Current Canopy-App components:
**Current Canopy-App Output:** Outputs 3D canopy winds, canopy vertical/eddy diffusivity values, and
canopy photolysis attenuation correction factors, and 2D Wind Adjustment Factor (WAF).

Namelist Option : `file_out` Prefix string (e.g., 'test') used for output file name (Currently in both 1D txt or 2D NetCDF format (only when 2D NCF input is used, i.e., infmt_opt=0).
Namelist Option : `file_out` Prefix string (e.g., 'test') used for output file name (Currently 1D txt output with input 1D data, or 2D NetCDF output when 2D NCF input is used, i.e., infmt_opt=0).


**Table 1. Canopy-App Required Input Variables**
Expand Down
12 changes: 6 additions & 6 deletions canopy_alloc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SUBROUTINE canopy_alloc
!-------------------------------------------------------------------------------

if(.not.allocated(variables)) allocate(variables(nlat*nlon))
if(.not.allocated(variables_2d)) allocate(variables_2d(nlat,nlon))
if(.not.allocated(variables_2d)) allocate(variables_2d(nlon,nlat))

!-------------------------------------------------------------------------------
! Allocate arrays for Internal Canopy Distribution Variables
Expand All @@ -38,11 +38,11 @@ SUBROUTINE canopy_alloc
if(.not.allocated(canBOT)) allocate(canBOT(modlays))
if(.not.allocated(canTOP)) allocate(canTOP(modlays))
if(.not.allocated(canWIND)) allocate(canWIND(nlat*nlon,modlays))
if(.not.allocated(canWIND_3d)) allocate(canWIND_3d(nlat,nlon,modlays))
if(.not.allocated(canWIND_3d)) allocate(canWIND_3d(nlon,nlat,modlays))
if(.not.allocated(dx)) allocate(dx(nlat*nlon))
if(.not.allocated(dx_2d)) allocate(dx_2d(nlat,nlon))
if(.not.allocated(dx_2d)) allocate(dx_2d(nlon,nlat))
if(.not.allocated(waf)) allocate(waf(nlat*nlon))
if(.not.allocated(waf_2d)) allocate(waf_2d(nlat,nlon))
if(.not.allocated(waf_2d)) allocate(waf_2d(nlon,nlat))

end if

Expand All @@ -54,7 +54,7 @@ SUBROUTINE canopy_alloc
write(*,*) 'Canopy eddy Kz option selected'
write(*,*) '-------------------------------'
if(.not.allocated(Kz)) allocate(Kz(nlat*nlon,modlays))
if(.not.allocated(Kz_3d)) allocate(Kz_3d(nlat,nlon,modlays))
if(.not.allocated(Kz_3d)) allocate(Kz_3d(nlon,nlat,modlays))
end if


Expand All @@ -66,7 +66,7 @@ SUBROUTINE canopy_alloc
write(*,*) 'Canopy photolysis option selected'
write(*,*) '-------------------------------'
if(.not.allocated(rjcf)) allocate(rjcf(nlat*nlon,modlays))
if(.not.allocated(rjcf_3d)) allocate(rjcf_3d(nlat,nlon,modlays))
if(.not.allocated(rjcf_3d)) allocate(rjcf_3d(nlon,nlat,modlays))
end if


Expand Down
10 changes: 5 additions & 5 deletions canopy_calcs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ SUBROUTINE canopy_calcs

! ... Main loop through model grid cells for 2D input/output

do j=1, nlon
do i=1, nlat
do i=1, nlon
do j=1, nlat

hcmref = variables_2d(i,j)%fh
ubzref = variables_2d(i,j)%ws
Expand Down Expand Up @@ -128,7 +128,7 @@ SUBROUTINE canopy_calcs
end if !Contiguous Canopy

else
write(*,*) 'Warning VIIRS VTYPE ', vtyperef, ' is not supported...continue'
! write(*,*) 'Warning VIIRS VTYPE ', vtyperef, ' is not supported...continue'
end if !Vegetation types
else
write(*,*) 'Wrong LU_OPT choice of ', lu_opt, ' in namelist...exiting'
Expand Down Expand Up @@ -233,7 +233,7 @@ SUBROUTINE canopy_calcs
end if !Contiguous Canopy

else
write(*,*) 'Warning VIIRS VTYPE ', vtyperef, ' is not supported...continue'
! write(*,*) 'Warning VIIRS VTYPE ', vtyperef, ' is not supported...continue'
end if !Vegetation types
else
write(*,*) 'Wrong LU_OPT choice of ', lu_opt, ' in namelist...exiting'
Expand Down Expand Up @@ -339,7 +339,7 @@ SUBROUTINE canopy_calcs
end if !Contiguous Canopy

else
write(*,*) 'Warning VIIRS VTYPE ', vtyperef, ' is not supported...continue'
! write(*,*) 'Warning VIIRS VTYPE ', vtyperef, ' is not supported...continue'
end if !Vegetation types
else
write(*,*) 'Wrong LU_OPT choice of ', lu_opt, ' in namelist...exiting'
Expand Down
2 changes: 1 addition & 1 deletion canopy_canopts_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MODULE canopy_canopts_mod
use canopy_const_mod, ONLY: rk
IMPLICIT NONE

!! .... defines canopy optionss (read from user namelist)
!! .... defines canopy options (read from user namelist)
integer :: infmt_opt !Integer for choosing 1D or 2D input file format (default = 0, 2D)
integer :: href_opt !Integer for using set href in namelist (=0) or array from file(=1) (default = 0)
real(rk) :: href_set !Set reference Height above canopy @ 10 m (m)
Expand Down
2 changes: 1 addition & 1 deletion canopy_const_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MODULE canopy_const_mod
! Cambridge Univ. Press, 206 pp, 1995.
! Snyder, J.P., "Map Projections-A Working Manual, U.S. Geological Survey
! Paper 1395 U.S.GPO, Washington, DC, 1987.
! Stull, R. B., "An Introduction to Bounday Layer Meteorology", Kluwer,
! Stull, R. B., "An Introduction to Boundary Layer Meteorology", Kluwer,
! Dordrecht, 1988
!-------------------------------------------------------------------------------

Expand Down
14 changes: 7 additions & 7 deletions canopy_dxcalc_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ SUBROUTINE CANOPY_CALCDX_2D(DXOPT, DXSET, NLAT, NLON, LAT, LON, DX )
! Local variables
integer :: i,j ! NLON,NLAT

do j=1, NLON
do i=1, NLAT
do i=1, NLON
do j=1, NLAT

if (DXOPT .eq. 0) then !user set to calculate dx grid cell distance from grid lons
if (NLON .gt. 1) then !convert grid points to distances using Haversine formula (m)
if (i .lt. NLAT ) then !inside LON inside domain
if (i .lt. NLON ) then !inside LON inside domain
DX(i,j) = CalcDX(LAT(i,j), abs(LON(i+1,j) - LON(i,j)))
else if (i .eq. NLAT ) then !at the domain edge --set to NLAT-1
DX(i,j) = DX(NLAT-1,j)
else if (j .eq. NLON ) then !at the domain edge --set to NLON-1
DX(i,j) = DX(i,NLON-1)
else if (i .eq. NLON ) then !at the domain edge --set to NLON-1
DX(i,j) = DX(NLON-1,j)
else if (j .eq. NLAT ) then !at the domain edge --set to NLAT-1
DX(i,j) = DX(i,NLAT-1)
end if
else !single grid cell/point, use namelist defined dx resolution (m) for cell
write(*,*) 'DX_OPT_2D set to calc, but nlon or nlat <= 1...setting dx = ', &
Expand Down
2 changes: 1 addition & 1 deletion canopy_eddy_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SUBROUTINE CANOPY_EDDYX( HCM, ZK, USTAR, MOL, KZ )
real(rk) :: rr ! sigma parameter R (Makar et al., 2017)
real(rk) :: aa ! sigma parameter A (Makar et al., 2017)
real(rk) :: bb ! sigma parameter B (Makar et al., 2017)
real(rk) :: sigma ! eulerian vertial velocity (m/s)
real(rk) :: sigma ! eulerian vertical velocity (m/s)

! Citation:
!Makar, P., Staebler, R., Akingunola, A. et al. The effects of forest canopy shading and turbulence on boundary layer ozone.
Expand Down
19 changes: 14 additions & 5 deletions canopy_ncf_io_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ SUBROUTINE get_var_2d_real_cdf (cdfid, var, dum2d, it, rcode)
INTEGER, INTENT(OUT) :: rcode
CHARACTER(LEN=*), INTENT(IN) :: var

nx = SIZE(dum2d,2)
ny = SIZE(dum2d,1)
nx = SIZE(dum2d,1)
ny = SIZE(dum2d,2)

rcode = nf90_inq_varid (cdfid, var, id_data)
IF ( rcode /= nf90_noerr ) then
Expand Down Expand Up @@ -164,8 +164,8 @@ SUBROUTINE get_var_2d_int_cdf (cdfid, var, idum2d, it, rcode)
INTEGER, INTENT(OUT) :: rcode
CHARACTER(LEN=*), INTENT(IN) :: var

nx = SIZE(idum2d,2)
ny = SIZE(idum2d,1)
nx = SIZE(idum2d,1)
ny = SIZE(idum2d,2)

rcode = nf90_inq_varid (cdfid, var, id_data)
IF ( rcode /= nf90_noerr ) RETURN
Expand Down Expand Up @@ -1321,9 +1321,14 @@ SUBROUTINE canopy_write_ncf (OUTPREFX)
! Write variables.
!-------------------------------------------------------------------------------

write(*,*) 'Writing NetCDF Output'
write(*,*) '-------------------------------'

!-------------------------------------------------------------------------------
! Time-independent 2d fields at cell centers.
!-------------------------------------------------------------------------------
write(*,*) 'Writing Time-independent 2d fields'
write(*,*) '-------------------------------'

DO n = 1, nfld2dxy
var = TRIM(fld2dxy(n)%fldname)
Expand All @@ -1340,6 +1345,8 @@ SUBROUTINE canopy_write_ncf (OUTPREFX)
!-------------------------------------------------------------------------------
! Time-varying 2d fields at cell centers.
!-------------------------------------------------------------------------------
write(*,*) 'Writing Time-varying 2d fields'
write(*,*) '-------------------------------'

DO n = 1, nfld2dxyt
nn = ntot + n
Expand All @@ -1357,8 +1364,10 @@ SUBROUTINE canopy_write_ncf (OUTPREFX)
ntot = ntot + nfld2dxyt

!-------------------------------------------------------------------------------
! Time-independent 3d fields at cell centers.
! Time-varying 3d fields at cell centers.
!-------------------------------------------------------------------------------
write(*,*) 'Writing Time-varying 3d fields'
write(*,*) '-------------------------------'

DO n = 1, nfld3dxyzt
nn = ntot + n
Expand Down
6 changes: 3 additions & 3 deletions canopy_profile_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ SUBROUTINE CANOPY_ZPD( ZHC, FCLAI, UBZREF, Z0GHC, &
real(rk) :: qstar ! Total Reynolds stress term
real(rk) :: fafraczInt_tota ! Numerator term of term B for d/h (Eq. 15 Massman et al.)
real(rk) :: fafraczInt_totb ! Denominator term of term B for d/h (Eq. 15 Massman et al.)
real(rk) :: cstress ! Suface stress at/above canopy height (nondimensional)
real(rk) :: drag ! Drag area index (i.e., wind speed attentuation) (nondimensional)
real(rk) :: cstress ! Surface stress at/above canopy height (nondimensional)
real(rk) :: drag ! Drag area index (i.e., wind speed attenuation) (nondimensional)
real(rk) :: nrat ! Ratio of drag/cstress (nondimensional)
real(rk) :: z0_set ! set roughness length (m)
real(rk) :: uc ! initial guess of wind speed at canopy height (m/s) from log-profile
Expand Down Expand Up @@ -294,7 +294,7 @@ SUBROUTINE CANOPY_ZPD( ZHC, FCLAI, UBZREF, Z0GHC, &
uc = UBZREF
end if

!Solve for final z0 and zpd esimates:
!Solve for final z0 and zpd estimates:
ustrmod = uc*(0.38 - (0.38 + (vonk/log(Z0GHC)))*exp(-1.0*(15.0*drag)))
cstress = (2.0*(ustrmod**2.0))/(uc**2.0)
nrat = drag/cstress
Expand Down
102 changes: 54 additions & 48 deletions canopy_txt_io_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,66 +52,72 @@ SUBROUTINE write_txt(TXTPREFX)
!Local variables
integer k, loc

if (ifcanwind) then
write(*,*) 'Writing canopy wind output'
if (infmt_opt .eq. 1) then !only output text with 1D input

write(*,*) 'Writing Text Output'
write(*,*) '-------------------------------'

if (ifcanwind) then
write(*,*) 'Writing canopy wind output'
write(*,*) '-------------------------------'
! ... save as text file
open(10, file=TRIM(TXTPREFX)//'_output_canopy_wind.txt')
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, a15)') 'Lat', 'Lon', 'Height (m)', 'WS (m/s)'
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)
open(10, file=TRIM(TXTPREFX)//'_output_canopy_wind.txt')
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, a15)') 'Lat', 'Lon', 'Height (m)', 'WS (m/s)'
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)
end do
end do
end do
end if
end if

! ... save as text file
if (ifcanwaf) then
write(*,*) 'Writing canopy WAF output'
write(*,*) '-------------------------------'
open(11, file=TRIM(TXTPREFX)//'_output_waf.txt')
write(11, '(a30, f6.1)') 'Reference height, h: ', href_set, 'm'
write(11, '(a8, a9, a19, a11)') 'Lat', 'Lon', 'Canopy height (m)', 'WAF'
do loc=1, nlat*nlon
write(11, '(f8.2, f9.2, f19.2, es15.7)') variables(loc)%lat, variables(loc)%lon, hcmref, waf(loc)
end do
end if
if (ifcanwaf) then
write(*,*) 'Writing canopy WAF output'
write(*,*) '-------------------------------'
open(11, file=TRIM(TXTPREFX)//'_output_waf.txt')
write(11, '(a30, f6.1)') 'Reference height, h: ', href_set, 'm'
write(11, '(a8, a9, a19, a11)') 'Lat', 'Lon', 'Canopy height (m)', 'WAF'
do loc=1, nlat*nlon
write(11, '(f8.2, f9.2, f19.2, es15.7)') variables(loc)%lat, variables(loc)%lon, hcmref, waf(loc)
end do
end if

if (ifcaneddy) then
write(*,*) 'Writing canopy eddy diffusivity scaling values'
write(*,*) '-------------------------------'
if (ifcaneddy) then
write(*,*) 'Writing canopy eddy diffusivity scaling values'
write(*,*) '-------------------------------'
! ... save as text file
open(12, file=TRIM(TXTPREFX)//'_output_eddy_Kz.txt')
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'
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)
open(12, file=TRIM(TXTPREFX)//'_output_eddy_Kz.txt')
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'
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)
end do
end do
end do
end if
end if

if (ifcanphot) then
write(*,*) 'Writing canopy photolysis correction factors'
write(*,*) '-------------------------------'
if (ifcanphot) then
write(*,*) 'Writing canopy photolysis correction factors'
write(*,*) '-------------------------------'
! ... save as text file
open(13, file=TRIM(TXTPREFX)//'_output_phot.txt')
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'
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)
open(13, file=TRIM(TXTPREFX)//'_output_phot.txt')
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'
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)
end do
end do
end do
end if
end if

end if
END SUBROUTINE write_txt

!-------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions canopy_waf_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SUBROUTINE CANOPY_FLAMEH( FLAMEH_OPT, FLAMEH_SET, DX, MODRES, &
write(*,*) 'Wrong FLAMEH_OPT choice of ', FLAMEH_OPT, ' in namelist...exiting'
call exit(2)
end if
if (FLAMEH .le. MODRES) then !flameh beween first (z=0) and second layer height
if (FLAMEH .le. MODRES) then !flameh between first (z=0) and second layer height
MIDFLAMEPOINT = 2 !do not put at z = 0, but rather in second layer
else
flamelays = floor(FLAMEH/MODRES) + 1 !force full flame layers
Expand Down Expand Up @@ -100,7 +100,7 @@ SUBROUTINE CANOPY_WAF( HCM, LAMDARS, RSL_OPT, HREF, FLAMEH, FIRETYPE, &
! Local variables
real(rk) :: term1 ! Major Term1 in WAF calculation (Eqs. 17 and 18 Massman et al. 2017)
real(rk) :: term2 ! Major Term2 in WAF calculation (Eqs. 17 and 18 Massman et al. 2017)
real(rk) :: delta ! Ratio parmeter used in WAF for above-canopy (Eq. 18 Massman et al.)
real(rk) :: delta ! Ratio parameter used in WAF for above-canopy (Eq. 18 Massman et al.)
real(rk) :: lamda_rs ! local values for influence of roughness sublayer (nondimensional)

! Citation:
Expand Down
Loading