Skip to content

Commit

Permalink
Add CMake and structural updates for the aciduptake simulation
Browse files Browse the repository at this point in the history
CMake updates:
(1) Added KPP/aciduptake/CMakeLists.txt
(2) Added if block in KPP/CMakeLists.txt for add_subdirectory based
    on the value of MECH.  If MECH=fullchem, configure KPP/fullchem, etc.
(3) In all KPP/*/CMakeLists.txt, removed multiple target names.
    e.g. KPPFirstPass_fullchem, KPPFirstPass_custom, and
    KPPFirstPass_aciduptake is just KPP_FirstPass, and similarly
    for the KPP target.
(4) GeosCore/CMakeLists.txt references the KPP target.
(5) Headers/CMakeLists.txt references the KPP_FirstPass target.

Other code updates:
(1) Broke off acid dust uptake rate-law functions into a new module
    KPP/aciduptake/aciduptake_DustChemFuncs.F90.
(2) KPP/aciduptake folder has symbolic links to the other fullchem_*.F90
    and rateLawUtilFuncs.F90 modules in the KPP/fullchem folder.
(3) Added a stub module KPP/fullchem/aciduptake_DustChemFuncs.F90
    since this needs to be called from GeosCore/fullchem_mod.F90.
(4) Updated comments, added formatting.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
  • Loading branch information
yantosca committed Sep 1, 2021
1 parent 465de33 commit 039d2e4
Show file tree
Hide file tree
Showing 11 changed files with 335 additions and 149 deletions.
23 changes: 7 additions & 16 deletions GeosCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,13 @@ if(("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU") AND NOT (CMAKE_Fortran_COMPIL
)
endif()

# Dependencies
target_link_libraries(GeosCore
PUBLIC
Transport ObsPack History Isorropia
# Define dependencies for libGeosCore.a
target_link_libraries(GeosCore PUBLIC
Transport ObsPack History Isorropia KPP

$<LINK_ONLY:HCOI_Shared> # link only to avoid gathering the rest of the TURs

# Add dependency on the correct KPP library
$<$<STREQUAL:${MECH},fullchem>:KPP_fullchem>
$<$<STREQUAL:${MECH},custom>:KPP_custom>
#------------------------------------------------------------------
# Kludge for KPP development, can remove it later (bmy, 3/16/21)
$<$<STREQUAL:${MECH},aerochem>:KPP_aerochem>
#------------------------------------------------------------------
$<LINK_ONLY:HCOI_Shared> # link only to avoid gathering the rest of the TURs

$<$<BOOL:${APM}>:APM> # depends on APM iff APM is true
$<$<BOOL:${RRTMG}>:GeosRad> # depends on GeosRad iff RRTMG is true
$<$<BOOL:${GTMM}>:Hg> # depends on Hg iff GTMM is true
$<$<BOOL:${APM}>:APM> # depends on APM iff APM is true
$<$<BOOL:${RRTMG}>:GeosRad> # depends on GeosRad iff RRTMG is true
$<$<BOOL:${GTMM}>:Hg> # depends on Hg iff GTMM is true
)
15 changes: 11 additions & 4 deletions GeosCore/fullchem_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,6 @@ SUBROUTINE Do_FullChem( Input_Opt, State_Chm, State_Diag, &
! Initialize private loop variables for each (I,J,L)
! Other private variables will be assigned in Set_Kpp_GridBox_Values
!=====================================================================
HET = 0.0_dp ! Het chem array
IERR = 0 ! KPP success or failure flag
ISTATUS = 0.0_dp ! Rosenbrock output
PHOTOL = 0.0_dp ! Photolysis array for KPP
Expand Down Expand Up @@ -2144,6 +2143,7 @@ SUBROUTINE Init_FullChem( Input_Opt, State_Chm, State_Diag, RC )
!
! !USES:
!
USE aciduptake_DustChemFuncs, ONLY : aciduptake_InitDustChem
USE ErrCode_Mod
USE Gckpp_Monitor, ONLY : Eqn_Names, Fam_Names
USE Gckpp_Precision
Expand Down Expand Up @@ -2217,6 +2217,8 @@ SUBROUTINE Init_FullChem( Input_Opt, State_Chm, State_Diag, RC )
id_O3P = Ind_( 'O' )
id_O1D = Ind_( 'O1D' )
id_OH = Ind_( 'OH' )
id_SALAAL = Ind_( 'SALAAL' )
id_SALCAL = Ind_( 'SALCAL' )

#ifdef MODEL_GEOS
! ckeller
Expand Down Expand Up @@ -2258,9 +2260,6 @@ SUBROUTINE Init_FullChem( Input_Opt, State_Chm, State_Diag, RC )
id_ICNOO = Ind_( 'ICNOO' )
id_IDNOO = Ind_( 'IDNOO' )
#endif
! MSL
id_SALAAL = Ind_( 'SALAAL' )
id_SALCAL = Ind_( 'SALCAL' )

! Set flags to denote if each species is defined
ok_HO2 = ( id_HO2 > 0 )
Expand Down Expand Up @@ -2393,6 +2392,14 @@ SUBROUTINE Init_FullChem( Input_Opt, State_Chm, State_Diag, RC )
RETURN
ENDIF

! Initialize dust acid uptake code (Mike Long, Bob Yantosca)
CALL aciduptake_InitDustChem( RC )
IF ( RC /= GC_SUCCESS ) THEN
ErrMsg = 'Error encountered in "aciduptake_InitDustChem"!'
CALL GC_Error( ErrMsg, RC, ThisLoc )
RETURN
ENDIF

END SUBROUTINE Init_FullChem
!EOC
!------------------------------------------------------------------------------
Expand Down
67 changes: 33 additions & 34 deletions Headers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
add_library(Headers STATIC EXCLUDE_FROM_ALL
charpak_mod.F90
CMN_DIAG_mod.F90
CMN_FJX_MOD.F90
CMN_O3_mod.F90
CMN_SIZE_mod.F90
diaglist_mod.F90
dictionary_m.F90
taggeddiaglist_mod.F90
errcode_mod.F90
input_opt_mod.F90
inquireMod.F90
physconstants.F90
precision_mod.F90
qfyaml_mod.F90
registry_mod.F90
registry_params_mod.F90
roundoff_mod.F90
species_database_mod.F90
species_mod.F90
state_chm_mod.F90
state_diag_mod.F90
state_grid_mod.F90
state_met_mod.F90
)
target_link_libraries(Headers
PUBLIC
$<$<STREQUAL:${MECH},fullchem>:KPPFirstPass_fullchem>
$<$<STREQUAL:${MECH},custom>:KPPFirstPass_custom>
#------------------------------------------------------
### Kludge for KPP development (can remove this later)
### bmy, msl, 3/16/21
$<$<STREQUAL:${MECH},aerochem>:KPPFirstPass_aerochem>
#------------------------------------------------------
# Headers/CMakeLists.txt

#----------------------------------------------------------------------------
# Define libHeaders.a
#----------------------------------------------------------------------------
add_library(Headers
STATIC EXCLUDE_FROM_ALL
charpak_mod.F90
CMN_DIAG_mod.F90
CMN_FJX_MOD.F90
CMN_O3_mod.F90
CMN_SIZE_mod.F90
diaglist_mod.F90
dictionary_m.F90
taggeddiaglist_mod.F90
errcode_mod.F90
input_opt_mod.F90
inquireMod.F90
physconstants.F90
precision_mod.F90
qfyaml_mod.F90
registry_mod.F90
registry_params_mod.F90
roundoff_mod.F90
species_database_mod.F90
species_mod.F90
state_chm_mod.F90
state_diag_mod.F90
state_grid_mod.F90
state_met_mod.F90
)

# Define dependencies for libHeaders.a
target_link_libraries(Headers PUBLIC KPP_FirstPass)

12 changes: 9 additions & 3 deletions KPP/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# Build the fullchem mechanism if configured with -DMECH=fullchem
# (This is the default option)
if("${MECH}" STREQUAL fullchem)
add_subdirectory(fullchem)
add_subdirectory(fullchem)
endif()

# Build the aciduptake mechanism if configured with -DMECH=aciduptake
if("${MECH}" STREQUAL aciduptake)
add_subdirectory(aciduptake)
add_subdirectory(aciduptake)
endif()

# Build the custom mechanism if configured with -DMECH=custom
if("${MECH}" STREQUAL custom)
add_subdirectory(custom)
add_subdirectory(custom)
endif()

49 changes: 49 additions & 0 deletions KPP/aciduptake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# KPP/aciduptake/CMakeLists.txt

#----------------------------------------------------------------------------
# Add libKPPFirstPass.a -- aciduptake mechanism
#----------------------------------------------------------------------------
add_library(KPP_FirstPass
STATIC EXCLUDE_FROM_ALL
gckpp_Precision.F90
gckpp_Parameters.F90
gckpp_Monitor.F90
)

# Define dependencies for libKPP_FirstPass.a
target_link_libraries(KPP_FirstPass PUBLIC GEOSChemBuildProperties)

#----------------------------------------------------------------------------
# Add libKPP.a -- aciduptake mechanism
#----------------------------------------------------------------------------
add_library(KPP
STATIC EXCLUDE_FROM_ALL
aciduptake_DustChemFuncs.F90
fullchem_HetStateFuncs.F90
fullchem_RateLawFuncs.F90
fullchem_SulfurChemFuncs.F90
gckpp_Function.F90
gckpp_Global.F90
gckpp_Initialize.F90
gckpp_Integrator.F90
gckpp_Jacobian.F90
gckpp_JacobianSP.F90
gckpp_LinearAlgebra.F90
gckpp_Model.F90
gckpp_Monitor.F90
gckpp_Parameters.F90
gckpp_Precision.F90
gckpp_Rates.F90
gckpp_Util.F90
rateLawUtilFuncs.F90
)

# Define dependencies for libKPP.a
target_link_libraries(KPP PUBLIC GeosUtil)

# When building libKPP.a, treat REAL as if it were REAL*8
target_compile_options(KPP
PRIVATE ""
$<$<STREQUAL:"${CMAKE_Fortran_COMPILER_ID}","Intel">:-r8>
$<$<STREQUAL:"${CMAKE_Fortran_COMPILER_ID}","GNU">:-fdefault-real-8 -fdefault-double-8>
)
Loading

0 comments on commit 039d2e4

Please sign in to comment.