Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
220487c
add megan modules
lwcugb Jul 31, 2024
fab3b42
updated Megan modules
lwcugb Jul 31, 2024
ed9c494
updates Megan modules
lwcugb Jul 31, 2024
344afb7
Merge branch 'bbakernoaa:feature/catchem_begins' into feature/catchem…
lwcugb Aug 1, 2024
90160eb
update Megan modules with EmisState
lwcugb Aug 1, 2024
05dc57e
Updates Megan modules
lwcugb Aug 1, 2024
c08aebf
Add Megan process test with bug fix
lwcugb Nov 15, 2024
052211a
change process name to bvoc
lwcugb Nov 26, 2024
caea32e
Merge branch 'feature/catchem_begins' of https://github.com/lwcugb/CA…
lwcugb Dec 16, 2024
afcbfc4
update bvoc megan2 process
lwcugb Dec 16, 2024
b31acf1
Merge branch 'develop' into feature/catchem_begins
bbakernoaa Dec 20, 2024
b7a7376
add historical effects and solve compiler warnings
lwcugb Jan 22, 2025
1bda156
Merge remote-tracking branch 'ufs/develop' into wei-begins
zmoon Jan 22, 2025
521ee44
remove some unused variables
lwcugb Jan 22, 2025
f9e7037
change test program name
lwcugb Jan 22, 2025
f6b4258
Merge branch 'develop' into feature/catchem_begins
bbakernoaa Jan 27, 2025
435dc0b
fix config bug and format
lwcugb Jan 30, 2025
82e7f4f
Merge branch 'feature/catchem_begins' of https://github.com/lwcugb/CA…
lwcugb Jan 30, 2025
e440c0c
calculate EF online for seven species
lwcugb Jan 30, 2025
6b52ab6
update default confiduration
lwcugb Feb 13, 2025
9a05046
tidy up
lwcugb Mar 6, 2025
8fb6042
replace some pointers
lwcugb Mar 21, 2025
173f5f6
add initializations
lwcugb Mar 21, 2025
73c3b12
Merge remote-tracking branch 'ufs/develop' into feature/catchem_begins
lwcugb Apr 3, 2025
6836cfd
add cmake flag to ci.yaml for yaml-cpp bug
lwcugb Apr 3, 2025
9bfa143
adress comments
lwcugb Jun 9, 2025
75e2bff
adress github building error
lwcugb Jun 9, 2025
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 @@ -37,7 +37,7 @@ jobs:

- name: Build
run: |
cmake -B $BUILD_DIR
cmake -B $BUILD_DIR -DCMAKE_POLICY_VERSION_MINIMUM=3.5
cmake --build $BUILD_DIR
env:
FC: ${{ matrix.compiler }}
Expand Down
1 change: 1 addition & 0 deletions src/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ target_link_libraries(${_lib} PUBLIC CATChem_process_dust)
target_link_libraries(${_lib} PUBLIC CATChem_process_seasalt)
target_link_libraries(${_lib} PUBLIC CATChem_process_plumerise)
target_link_libraries(${_lib} PUBLIC CATChem_process_drydep)
target_link_libraries(${_lib} PUBLIC CATChem_process_bvoc)
target_link_libraries(${_lib} PUBLIC CATChem_process_chem)
set_target_properties(
${_lib}
Expand Down
7 changes: 7 additions & 0 deletions src/api/catchem.F90
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ module CATChem
! Chemical mechanism solver
use CCPr_Chem_mod, only: cc_get_micm_version => get_micm_version

! BVOC emissions
use CCPr_Bvoc_Common_Mod, only: BvocStateType !< BVOC State
use CCPr_Bvoc_mod, only: cc_bvoc_init => CCPr_Bvoc_Init !< BVOC Process Initialization Routine
use CCPr_Bvoc_mod, only: cc_bvoc_run => CCPr_Bvoc_Run !< BVOC Process Run Routine
use CCPr_Bvoc_mod, only: cc_bvoc_finalize => CCPr_Bvoc_Final !< BVOC Process Finalization Routine


implicit none

public
Expand Down
102 changes: 102 additions & 0 deletions src/core/config_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ SUBROUTINE Read_Input_File( Config , GridState, EmisState, ChemState, RC, Config
RETURN
ENDIF

call Config_Process_Bvoc(ConfigInput, Config, RC)
IF ( RC /= CC_SUCCESS ) THEN
errMsg = 'Error in "Config_Process_Bvoc"!'
CALL CC_Error( errMsg, RC, thisLoc )
CALL QFYAML_CleanUp( ConfigInput )
CALL QFYAML_CleanUp( ConfigAnchored )
RETURN
ENDIF

call Config_Process_Plumerise(ConfigInput, Config, RC)
IF ( RC /= CC_SUCCESS ) THEN
errMsg = 'Error in "Config_Process_Plumerise"!'
Expand Down Expand Up @@ -1373,4 +1382,97 @@ SUBROUTINE Config_Process_DryDep( ConfigInput, Config, RC )
END SUBROUTINE Config_Process_DryDep


!> \brief Process BVOC configuration
!!
!! This function processes the biogenic VOC configuration and performs the necessary actions based on the configuration.
!!
!! \param[in] ConfigInput The YAML configuration object
!! \param[inout] Config The configuration object
!! \param[out] RC The return code
!!
!! \ingroup core_modules
!!!>
SUBROUTINE Config_Process_Bvoc( ConfigInput, Config, RC )
USE CharPak_Mod, ONLY : StrSplit
USE Error_Mod
USE Config_Opt_Mod, ONLY : ConfigType

TYPE(QFYAML_t), INTENT(INOUT) ::ConfigInput ! YAML Config object
TYPE(ConfigType), INTENT(INOUT) :: Config ! Input options

!
! !OUTPUT PARAMETERS:
!
INTEGER, INTENT(OUT) :: RC ! Success or failure
! !LOCAL VARIABLES:
!
! Scalars
LOGICAL :: v_bool
INTEGER :: v_int
! Reals
REAL(fp) :: v_real
! Strings
CHARACTER(LEN=255) :: thisLoc
CHARACTER(LEN=512) :: errMsg
CHARACTER(LEN=QFYAML_StrLen) :: key

!========================================================================
! Config_Process_Bvoc begins here!
!========================================================================

! Initialize
RC = CC_SUCCESS
thisLoc = ' -> at Config_Process_Bvoc (in CATChem/src/core/config_mod.F90)'
errMsg = ''
! TODO #105 Fix reading of config file
key = "process%bvoc%activate"
v_bool = MISSING_BOOL
CALL QFYAML_Add_Get( ConfigInput, TRIM( key ), v_bool, "", RC )
IF ( RC /= CC_SUCCESS ) THEN
errMsg = 'Error parsing ' // TRIM( key ) // '!'
CALL CC_Error( errMsg, RC, thisLoc )
RETURN
ENDIF
Config%bvoc_activate = v_bool

key = "process%bvoc%scheme_opt"
v_int = MISSING_INT
CALL QFYAML_Add_Get( ConfigInput, TRIM( key ), v_int, "", RC )
IF ( RC /= CC_SUCCESS ) THEN
errMsg = TRIM( key ) // ' Not Found, Setting Default to 1'
CALL CC_Warning( errMsg, RC, thisLoc )
v_int = 1 ! default is one
ENDIF
Config%bvoc_scheme = v_int

key = "process%bvoc%co2_inhib"
v_bool = MISSING_BOOL
CALL QFYAML_Add_Get( ConfigInput, TRIM( key ), v_bool, "", RC )
IF ( RC /= CC_SUCCESS ) THEN
errMsg = TRIM( key ) // ' Not Found, Setting Default to TRUE'
CALL CC_Warning( errMsg, RC, thisLoc )
v_bool = .TRUE. ! default is true
ENDIF
Config%megan_co2_inhib = v_bool

key = 'process%bvoc%co2_conc_ppm'
v_real = MISSING_REAL
CALL QFYAML_Add_Get( ConfigInput, TRIM( key ), v_real, "", RC )
IF ( RC /= CC_SUCCESS ) THEN
errMsg = TRIM( key ) // ' Not Found, Setting Default to 390.0'
CALL CC_Warning( errMsg, RC, thisLoc )
v_real = 390.0_fp ! default is 390 ppm
ENDIF
Config%megan_co2_conc_ppm = v_real

write(*,*) "BVOC Configuration"
write(*,*) '------------------------------------'
write(*,*) 'Config%bvoc_activate = ', Config%bvoc_activate
write(*,*) 'Config%bvoc_scheme = ', Config%bvoc_scheme
write(*,*) 'Config%megan_co2_inhib = ', Config%megan_co2_inhib
write(*,*) 'Config%megan_co2_conc_ppm = ', Config%megan_co2_conc_ppm
write(*,*) '------------------------------------'

END SUBROUTINE Config_Process_Bvoc

END MODULE config_mod
16 changes: 16 additions & 0 deletions src/core/config_opt_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ MODULE Config_Opt_Mod
!! - `drydep_activate` : Activate drydep process
!! - `drydep_scheme` : Scheme option for drydep process
!! - `drydep_resuspension` : Activate resuspension
!! - `bvoc_activate` : Activate BVOC process
!! - `bvoc_scheme` : Scheme option for BVOC process
!! - `megan_co2_inhib` : use CO2 inhibition for isoprene?
!! - `megan_co2_conc_ppm` : If so, provide CO2 concentrations
!!
!! \ingroup core_modules
!!!>
Expand Down Expand Up @@ -94,6 +98,12 @@ MODULE Config_Opt_Mod
INTEGER :: seasalt_scheme
real(fp) :: seasalt_scalefactor

! BVOC Process
LOGICAL :: bvoc_activate
INTEGER :: bvoc_scheme
LOGICAL :: megan_co2_inhib
real(fp) :: megan_co2_conc_ppm

! Plumerise Process
LOGICAL :: plumerise_activate

Expand Down Expand Up @@ -176,6 +186,12 @@ SUBROUTINE Set_Config( am_I_Root, Config, RC )
Config%drydep_scheme = 1
Config%drydep_resuspension = .FALSE.

!BVOC Process
Config%bvoc_activate = .FALSE.
Config%bvoc_scheme = 1
Config%megan_co2_inhib = .TRUE.
Config%megan_co2_conc_ppm = 390.0_fp

END SUBROUTINE Set_Config
!> \brief Cleanup the Config options
!!
Expand Down
17 changes: 17 additions & 0 deletions src/core/diagstate_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ module DiagState_Mod
real(fp), allocatable :: drydep_frequency(:)
real(fp), allocatable :: drydep_vel(:)

! MEGAN historical variables
! TODO: this is better to be done in restart files if possible in the future
real(fp), allocatable :: T_LAST24H !< temperature of last 24 hours
real(fp), allocatable :: T_LASTXDAYS !< temperature of last NUM_DAYS
real(fp), allocatable :: PARDR_LASTXDAYS !< direct radiation of last NUM_DAYS
real(fp), allocatable :: PARDF_LASTXDAYS !< diffuse radiation of last NUM_DAYS
real(fp), allocatable :: PMISOLAI !< LAI of last 24 hours


! Species Specific Variables


Expand Down Expand Up @@ -124,6 +133,14 @@ subroutine Diag_Allocate(Config, DiagState, ChemState, RC)

endif

! If bvoc process is activated then allocate bvoc related diagnostics
if (Config%bvoc_activate) then
DiagState%T_LAST24H = ZERO
DiagState%T_LASTXDAYS = ZERO
DiagState%PARDR_LASTXDAYS = ZERO
DiagState%PARDF_LASTXDAYS = ZERO
DiagState%PMISOLAI = ZERO
endif


end subroutine Diag_Allocate
Expand Down
15 changes: 15 additions & 0 deletions src/core/metstate_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@ MODULE MetState_Mod
REAL(fp), ALLOCATABLE :: PMID(:) !< Average wet air pressure [hPa] defined as arithmetic average of edge pressures
REAL(fp), ALLOCATABLE :: PMID_DRY(:) !< Dry air partial pressure [hPa] defined as arithmetic avg of edge pressures

! Some met fields need for MEGAN but not included yet. Some variables can be calculated online in the future
!---------------------
real(fp) :: PMISOLAI !< LAI of previous month
real(fp), pointer :: PFT_16(:) !< plant functional type fraction
real(fp) :: Q_DIR_2 !< surface downwelling par diffuse flux
real(fp) :: Q_DIFF_2 !< surface downwelling par beam flux
real(fp) :: PARDR_LASTXDAYS !< Avg. PARDF of last NUM_DAYS
real(fp) :: PARDF_LASTXDAYS !< Avg. PARDR of last NUM_DAYS
real(fp) :: T_LASTXDAYS !< Avg. temperature of last NUM_DAYS
real(fp) :: T_LAST24H !< Avg. temperature of last 24 hours
real(fp) :: LAT !< Latitude
integer :: DOY !< Day of year
real(fp) :: LocalHour !< Local hour
real(fp) :: D_BTW_M !< Days between mid-months

END TYPE MetStateType

CONTAINS
Expand Down
1 change: 1 addition & 0 deletions src/process/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ add_subdirectory(dust)
add_subdirectory(seasalt)
add_subdirectory(plumerise)
add_subdirectory(drydep)
add_subdirectory(bvoc)
add_subdirectory(chem)
Loading