Skip to content

Commit

Permalink
Merge pull request #85 from noaa-oar-arl/update-ci
Browse files Browse the repository at this point in the history
Update CI
  • Loading branch information
drnimbusrain authored Feb 2, 2024
2 parents 9ed6c4b + 90dfd1d commit 2d65723
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 84 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ jobs:
shell: bash -l {0}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libnetcdff-dev
- name: Set up Python (micromamba)
uses: mamba-org/provision-with-micromamba@v15
uses: mamba-org/setup-micromamba@v1
with:
environment-file: python/environment.yml
cache-env: true
extra-specs: |
cache-environment: true
create-args: |
python=3.10
- name: Check that default input is nc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: "3.10"
- uses: pre-commit/action@v3.0.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ See [the included Makefile](./src/Makefile), which detects NetCDF using `nf-conf
Compilation options can be controlled with environment variables:

- `FC=gfortran` (default) or compiler name/path (e.g. `FC=ifort`, `FC=gfortran-11`, `FC=/usr/bin/gfortran-11`)
- `DEBUG=0` (off; default) or `DEBUG=1` (on)
- `DEBUG=0` (off; default) or `DEBUG=1` (on) or `DEBUG=2` (more flags, including FPE traps and traceback)
- `NC=0` (off) or `NC=1` (on; default)

Example:
Expand Down
89 changes: 49 additions & 40 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,28 @@ NC ?= 1

# Compile flags
$(info DEBUG setting: '$(DEBUG)')
ifeq ($(DEBUG), 1)
ifeq ($(DEBUG), 0)
FCFLAGS := -O3
else ifeq ($(DEBUG), 1)
ifeq ($(findstring gfortran,$(notdir $(FC))),gfortran)
FCFLAGS := -g -Wall -Wextra -Wconversion -Og -pedantic -fcheck=bounds -fmax-errors=5 -std=f2003 -fall-intrinsics
# More Debug Flags
# FCFLAGS := -g -Og -Wall -Wextra -pedantic -fcheck=all -fmax-errors=5 -std=f2003 \
# -fall-intrinsics -fbacktrace -ffpe-trap=invalid,zero,overflow
FCFLAGS := -g -Og -Wall -Wextra -Wconversion -pedantic \
-fcheck=bounds -fall-intrinsics -fmax-errors=5 \
-std=f2003
else ifeq ($(FC),ifort)
FCFLAGS := -g -warn all -check bounds -implicitnone -O0 -error-limit 5
FCFLAGS := -g -O0 -warn all -check bounds -implicitnone -error-limit 5
endif
else ifeq ($(DEBUG), 2)
ifeq ($(findstring gfortran,$(notdir $(FC))),gfortran)
FCFLAGS := -g -Og -Wall -Wextra -Wconversion -pedantic \
-fcheck=all -fall-intrinsics -fmax-errors=0 \
-fbacktrace -ffpe-trap=invalid,zero,overflow -finit-real=snan -finit-integer=-99999999 \
-std=f2003
else ifeq ($(FC),ifort)
FCFLAGS := -g -O0 -warn all -check all -implicitnone -error-limit 0 \
-fpe0 -traceback
endif
else ifeq ($(DEBUG), 0)
FCFLAGS := -O3
else
$(error invalid setting for DEBUG, should be 0 or 1 but is '$(DEBUG)')
$(error invalid setting for DEBUG, should be 0, 1 or 2 but is '$(DEBUG)')
endif
$(info FCFLAGS: '$(FCFLAGS)')

Expand All @@ -54,37 +63,37 @@ $(info LIBS: '$(LIBS)')
$(info INC: '$(INC)')

# Source objects
OBJS :=\
canopy_const_mod.o \
canopy_date_mod.o \
canopy_coord_mod.o \
canopy_canopts_mod.o \
canopy_canmet_mod.o \
canopy_canvars_mod.o \
canopy_utils_mod.o \
canopy_files_mod.o \
canopy_readnml.o \
canopy_alloc.o \
canopy_init.o \
canopy_txt_io_mod.o \
canopy_ncf_io_mod.o \
canopy_check_input.o \
canopy_read_txt.o \
canopy_dxcalc_mod.o \
canopy_profile_mod.o \
canopy_var3din_mod.o \
canopy_phot_mod.o \
canopy_rad_mod.o \
canopy_tleaf_mod.o \
canopy_wind_mod.o \
canopy_fire_mod.o \
canopy_eddy_mod.o \
canopy_bioparm_mod.o \
canopy_bioemi_mod.o \
canopy_calcs.o \
canopy_write_txt.o \
canopy_dealloc.o \
canopy_app.o
OBJS := \
canopy_const_mod.o \
canopy_date_mod.o \
canopy_coord_mod.o \
canopy_canopts_mod.o \
canopy_canmet_mod.o \
canopy_canvars_mod.o \
canopy_utils_mod.o \
canopy_files_mod.o \
canopy_readnml.o \
canopy_alloc.o \
canopy_init.o \
canopy_txt_io_mod.o \
canopy_ncf_io_mod.o \
canopy_check_input.o \
canopy_read_txt.o \
canopy_dxcalc_mod.o \
canopy_profile_mod.o \
canopy_var3din_mod.o \
canopy_phot_mod.o \
canopy_rad_mod.o \
canopy_tleaf_mod.o \
canopy_wind_mod.o \
canopy_fire_mod.o \
canopy_eddy_mod.o \
canopy_bioparm_mod.o \
canopy_bioemi_mod.o \
canopy_calcs.o \
canopy_write_txt.o \
canopy_dealloc.o \
canopy_app.o

ifeq ($(NC), 0)
_ncf_objs := canopy_check_input.o canopy_ncf_io_mod.o
Expand Down
71 changes: 33 additions & 38 deletions src/canopy_utils_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -658,56 +658,51 @@ function GET_GAMMA_LEAFAGE(leafage_opt,LAIpast,LAIcurrent,tsteplai,TABOVE,Anew,A
!------------------------------------------------------------------------------
!BOC

!-----------------------
! Compute GAMMA_LEAFAGE
!-----------------------


!TABOVE (Tt in MEGAN code) -> Above Canopy TEMP (tmp2mref or temp2)

! Calculate foliage fraction
!-----------------------
!Also, Compute ti and tm
! ti: number of days after budbreak required to induce emissions
! tm: number of days after budbreak required to reach peak emissions
IF (LAIcurrent - LAIpast > LAIdelta) THEN !(i.e. LAI has Increased)
IF (TABOVE .le. 303.0_rk) THEN
ti = 5.0_rk + 0.7_rk*(300.0_rk-TABOVE)
ELSE
ti = 2.9_rk
ENDIF
tm = 2.3_rk*ti
!Fnew calculated
IF (ti .ge. tsteplai) THEN
Fnew = 1.0_rk - (LAIpast/LAIcurrent)
ELSE
Fnew = (ti/tsteplai) * ( 1.0_rk-(LAIpast/LAIcurrent) )
ENDIF
!Fmat calculated
IF (tm .ge. tsteplai) THEN
Fmat = LAIpast/LAIcurrent
ELSE
Fmat = (LAIpast/LAIcurrent) + ( (tsteplai-tm)/tsteplai ) * ( 1.0_rk-(LAIpast/LAIcurrent) )
ENDIF

Fgro = 1.0_rk - Fnew - Fmat
Fold = 0.0_rk
ELSEIF (LAIpast - LAIcurrent > LAIdelta) THEN !(i.e. LAI has decreased)
Fnew = 0.0_rk
Fgro = 0.0_rk
Fold = ( LAIpast-LAIcurrent ) / LAIpast
Fmat = 1.0_rk-Fold
ELSE !(LAIpast == LAIcurrent) THEN !If LAI remains same
Fnew = 0.0_rk
Fgro = 0.1_rk
Fmat = 0.8_rk
Fold = 0.1_rk
ENDIF

!-----------------------
! Compute GAMMA_AGE
!-----------------------
IF (leafage_opt .eq. 0) THEN
IF (LAIcurrent - LAIpast > LAIdelta) THEN !(i.e. LAI has Increased)
IF (TABOVE .le. 303.0_rk) THEN
ti = 5.0_rk + 0.7_rk*(300.0_rk-TABOVE)
ELSE
ti = 2.9_rk
ENDIF
tm = 2.3_rk*ti
!Fnew calculated
IF (ti .ge. tsteplai) THEN
Fnew = 1.0_rk - (LAIpast/LAIcurrent)
ELSE
Fnew = (ti/tsteplai) * ( 1.0_rk-(LAIpast/LAIcurrent) )
ENDIF
!Fmat calculated
IF (tm .ge. tsteplai) THEN
Fmat = LAIpast/LAIcurrent
ELSE
Fmat = (LAIpast/LAIcurrent) + ( (tsteplai-tm)/tsteplai ) * ( 1.0_rk-(LAIpast/LAIcurrent) )
ENDIF

Fgro = 1.0_rk - Fnew - Fmat
Fold = 0.0_rk
ELSEIF (LAIpast - LAIcurrent > LAIdelta) THEN !(i.e. LAI has decreased)
Fnew = 0.0_rk
Fgro = 0.0_rk
Fold = ( LAIpast-LAIcurrent ) / LAIpast
Fmat = 1.0_rk-Fold
ELSE !(LAIpast == LAIcurrent) THEN !If LAI remains same
Fnew = 0.0_rk
Fgro = 0.1_rk
Fmat = 0.8_rk
Fold = 0.1_rk
ENDIF
! Compute GAMMA_LEAFAGE
GAMMA_LEAFAGE = Fnew*Anew + Fgro*Agro + Fmat*Amat + Fold*Aold
! Prevent negative values
Expand Down

0 comments on commit 2d65723

Please sign in to comment.