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

Update CI #85

Merged
merged 8 commits into from
Feb 2, 2024
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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zmoon Although, what has changed in the leafage option with your PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be nothing. I just moved the calculation under the if statement to avoid FPE related to the LAI being unitialized. Little note in d241bea

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
Loading