Skip to content

Commit 9c11d6e

Browse files
committed
Initial commits for MAPL3
Signed-off-by: Lizzie Lundgren <elundgren@seas.harvard.edu>
1 parent 89cb608 commit 9c11d6e

37 files changed

Lines changed: 562 additions & 302 deletions

CMakeLists.txt

Lines changed: 183 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ message("=================================================================")
3434
#
3535
# Optionally, super project can define and configure this target.
3636
#-----------------------------------------------------------------------------
37-
if(NOT TARGET GEOSChemBuildProperties)
37+
#if(NOT TARGET GEOSChemBuildProperties)
3838
add_library(GEOSChemBuildProperties INTERFACE)
39-
endif()
39+
#endif()
4040

4141
#-----------------------------------------------------------------------------
4242
# Add all the subdirectories.
@@ -54,15 +54,193 @@ add_subdirectory(GTMM)
5454
add_subdirectory(GeosCore)
5555

5656
#-----------------------------------------------------------------------------
57-
# Build GEOS-Chem Classic driver program (if MODEL_CLASSIC=T)
57+
# Build GEOS-Chem Classic driver program if using GC-Classic
5858
#-----------------------------------------------------------------------------
5959
if(MODEL_CLASSIC)
6060
add_subdirectory(Interfaces/GCClassic)
6161
endif()
6262

6363
#-----------------------------------------------------------------------------
64-
# Build GCHPctm driver program (if MODEL_GCHPCTM=T)
64+
# Build GCHP driver program if using GCHP
6565
#-----------------------------------------------------------------------------
66-
if(MODEL_GCHPCTM)
66+
if(MODEL_GCHP)
6767
add_subdirectory(Interfaces/GCHP)
6868
endif()
69+
70+
#-----------------------------------------------------------------------------
71+
# Additional GEOS-Chem settings if using GCHP (all necessary?)
72+
#-----------------------------------------------------------------------------
73+
if(MODEL_GCHP)
74+
75+
set(RRTMG OFF CACHE BOOL
76+
"Switch to build RRTMG as a component of GEOS-Chem"
77+
)
78+
set(TOMAS OFF CACHE BOOL
79+
"Switch to build TOMAS as a component of GEOS-Chem"
80+
)
81+
set(LUO_WETDEP OFF CACHE BOOL
82+
"Switch to build the Luo et al (2020) wetdep scheme into GEOS-Chem"
83+
)
84+
set(FASTJX OFF CACHE BOOL
85+
"Switch to use legacy FAST-JX photolysis in GEOS-Chem"
86+
)
87+
set(KPPSA OFF CACHE BOOL
88+
"Switch to build the KPP-Standalone Box Model"
89+
)
90+
91+
# Local variables
92+
set(GTMM FALSE)
93+
set(MECH "fullchem" CACHE STRING "Name of the chemistry mechanism to use")
94+
95+
# Configure build properties for GEOS-Chem
96+
target_compile_definitions(GEOSChemBuildProperties INTERFACE
97+
MODEL_GCHPCTM
98+
MODEL_GCHP
99+
USE_ESMF
100+
MAPL_ESMF
101+
MAPL3
102+
EXTERNAL_GRID
103+
NC_HAS_COMPRESSION
104+
$<$<BOOL:${USE_REAL8}>:USE_REAL8> $<$<BOOL:${RRTMG}>:RRTMG>
105+
$<$<BOOL:${ADJOINT}>:ADJOINT>
106+
$<$<BOOL:${REVERSE_OPERATORS}>:REVERSE_OPERATORS>
107+
$<$<BOOL:${TOMAS}>:TOMAS>
108+
$<$<STREQUAL:${TOMAS_BINS},15>:TOMAS15>
109+
$<$<STREQUAL:${TOMAS_BINS},40>:TOMAS40>
110+
$<$<BOOL:${LUO_WETDEP}>:LUO_WETDEP>
111+
$<$<BOOL:${FASTJX}>:FASTJX>
112+
)
113+
114+
if(NOT MAPL3)
115+
target_link_libraries(GEOSChemBuildProperties INTERFACE
116+
$<LINK_ONLY:MAPL.base>
117+
$<LINK_ONLY:FVdycoreCubed_GridComp>
118+
$<LINK_ONLY:HCOI_MAPL_ESMF>
119+
$<$<BOOL:${OMP}>:OpenMP::OpenMP_Fortran>
120+
MPI::MPI_C MPI::MPI_Fortran
121+
)
122+
target_include_directories(GEOSChemBuildProperties INTERFACE
123+
$<TARGET_PROPERTY:MAPL.base,INTERFACE_INCLUDE_DIRECTORIES>
124+
$<TARGET_PROPERTY:FVdycoreCubed_GridComp,INTERFACE_INCLUDE_DIRECTORIES>
125+
$<TARGET_PROPERTY:HCOI_MAPL_ESMF,INTERFACE_INCLUDE_DIRECTORIES>
126+
${CMAKE_Fortran_MODULE_DIRECTORY}
127+
)
128+
# GeosCore
129+
endif()
130+
if(MAPL3)
131+
target_link_libraries(GEOSChemBuildProperties INTERFACE
132+
$<LINK_ONLY:MAPL.base>
133+
$<LINK_ONLY:FVdycoreCubed_GridComp>
134+
$<LINK_ONLY:HCOI_MAPL_ESMF>
135+
$<$<BOOL:${OMP}>:OpenMP::OpenMP_Fortran>
136+
MPI::MPI_C MPI::MPI_Fortran
137+
$<LINK_ONLY:mapl3g>
138+
$<LINK_ONLY:MAPL.generic3g>
139+
$<LINK_ONLY:MAPL.state>
140+
)
141+
target_include_directories(GEOSChemBuildProperties INTERFACE
142+
$<TARGET_PROPERTY:mapl3g,INTERFACE_INCLUDE_DIRECTORIES>
143+
$<TARGET_PROPERTY:MAPL.generic3g,INTERFACE_INCLUDE_DIRECTORIES>
144+
$<TARGET_PROPERTY:MAPL.state,INTERFACE_INCLUDE_DIRECTORIES>
145+
$<TARGET_PROPERTY:MAPL.base,INTERFACE_INCLUDE_DIRECTORIES>
146+
$<TARGET_PROPERTY:FVdycoreCubed_GridComp,INTERFACE_INCLUDE_DIRECTORIES>
147+
$<TARGET_PROPERTY:HCOI_MAPL_ESMF,INTERFACE_INCLUDE_DIRECTORIES>
148+
${CMAKE_Fortran_MODULE_DIRECTORY}
149+
)
150+
# Turn off acg for now
151+
#mapl_acg(GEOSchem_GridComp GEOSchem_StateSpecs.rc
152+
# IMPORT_SPECS EXPORT_SPECS INTERNAL_SPECS
153+
# GET_POINTERS DECLARE_POINTERS
154+
# 3g
155+
#)
156+
endif()
157+
158+
set(GEOSChem_Fortran_FLAGS_Intel
159+
-cpp -w -auto -noalign "SHELL:-convert big_endian" "SHELL:-fp-model source"
160+
-mcmodel=medium -shared-intel -traceback -DLINUX_IFORT
161+
CACHE STRING "GEOSChem compiler flags for all build types with Intel compilers"
162+
)
163+
set(GEOSChem_Fortran_FLAGS_RELEASE_Intel
164+
-O2
165+
CACHE STRING "GEOSChem compiler flags for build type release with Intel compilers"
166+
)
167+
set(GEOSChem_Fortran_FLAGS_RELWITHDEBINFO_Intel
168+
-O2
169+
CACHE STRING "GEOSChem compiler flags for build type relwithdebinfo with Intel compilers"
170+
)
171+
set(GEOSChem_Fortran_FLAGS_DEBUG_Intel
172+
-g -O0 "SHELL:-check arg_temp_created" "SHELL:-debug all" -fpe0 -ftrapuv -check,bounds
173+
CACHE STRING "GEOSChem compiler flags for build type debug with Intel compilers"
174+
)
175+
176+
set(GEOSChem_Fortran_FLAGS_GNU
177+
-cpp -w -std=legacy -fautomatic -fno-align-commons
178+
-fconvert=big-endian -fno-range-check -mcmodel=medium
179+
-fbacktrace -g -DLINUX_GFORTRAN -ffree-line-length-none
180+
CACHE STRING "GEOSChem compiler flags for all build types with GNU compilers"
181+
)
182+
set(GEOSChem_Fortran_FLAGS_RELEASE_GNU
183+
-O3 -funroll-loops
184+
CACHE STRING "GEOSChem compiler flags for build type release with GNU compilers"
185+
)
186+
set(GEOSChem_Fortran_FLAGS_RELWITHDEBINFO_GNU
187+
-O3 -funroll-loops
188+
CACHE STRING "GEOSChem compiler flags for build type relwithdebinfo with GNU compilers"
189+
)
190+
set(GEOSChem_Fortran_FLAGS_DEBUG_GNU
191+
-g -gdwarf-2 -gstrict-dwarf -O0 -Wall -Wextra -Wconversion -Warray-temporaries
192+
-fcheck=array-temps -ffpe-trap=invalid,zero,overflow -finit-real=snan
193+
-fcheck=bounds -fcheck=pointer
194+
CACHE STRING "GEOSChem compiler flags for build type debug with GNU compilers"
195+
)
196+
set(CMAKE_Fortran_FLAGS "")
197+
set(CMAKE_Fortran_FLAGS_RELEASE "")
198+
set(CMAKE_Fortran_FLAGS_Debug "")
199+
set(CMAKE_Fortran_FLAGS_RelWithDebInfo "")
200+
201+
set(GEOSChem_SUPPORTED_COMPILER_IDS "Intel" "GNU")
202+
if(NOT CMAKE_Fortran_COMPILER_ID IN_LIST GEOSChem_SUPPORTED_COMPILER_IDS)
203+
message(FATAL_ERROR "GEOSChem does not support ${CMAKE_Fortran_COMPILER_ID} compilers")
204+
endif()
205+
206+
#---------------------------------------------------------------------
207+
# Assign comiler options to build properties
208+
#---------------------------------------------------------------------
209+
target_compile_options(GEOSChemBuildProperties
210+
INTERFACE
211+
$<$<STREQUAL:${CMAKE_Fortran_COMPILER_ID},Intel>:
212+
${GEOSChem_Fortran_FLAGS_Intel}
213+
$<$<CONFIG:Debug>:${GEOSChem_Fortran_FLAGS_DEBUG_Intel}>
214+
$<$<CONFIG:RelWithDebInfo>:${GEOSChem_Fortran_FLAGS_RELWITHDEBINFO_Intel}>
215+
$<$<CONFIG:Release>:${GEOSChem_Fortran_FLAGS_RELEASE_Intel}>
216+
>
217+
$<$<STREQUAL:${CMAKE_Fortran_COMPILER_ID},GNU>:
218+
${GEOSChem_Fortran_FLAGS_GNU}
219+
$<$<CONFIG:Debug>:${GEOSChem_Fortran_FLAGS_DEBUG_GNU}>
220+
$<$<CONFIG:RelWithDebInfo>:${GEOSChem_Fortran_FLAGS_RELWITHDEBINFO_GNU}>
221+
$<$<CONFIG:Release>:${GEOSChem_Fortran_FLAGS_RELEASE_GNU}>
222+
>
223+
)
224+
225+
target_compile_definitions(GEOSChemBuildProperties
226+
INTERFACE
227+
$<$<STREQUAL:${CMAKE_Fortran_COMPILER_ID},Intel>:LINUX_IFORT>
228+
$<$<STREQUAL:${CMAKE_Fortran_COMPILER_ID},GNU>:LINUX_GFORTRAN>
229+
)
230+
231+
# Print the options that are turned on in GEOS-Chem
232+
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/CMakeScripts)
233+
include(GC-Helpers)
234+
gc_pretty_print(SECTION "Settings")
235+
gc_pretty_print(VARIABLE MECH OPTIONS "fullchem" "carbon" "custom")
236+
gc_pretty_print(VARIABLE OMP IS_BOOLEAN)
237+
gc_pretty_print(VARIABLE USE_REAL8 IS_BOOLEAN)
238+
gc_pretty_print(VARIABLE APM IS_BOOLEAN)
239+
gc_pretty_print(VARIABLE TOMAS IS_BOOLEAN)
240+
gc_pretty_print(VARIABLE RRTMG IS_BOOLEAN)
241+
gc_pretty_print(VARIABLE GTMM IS_BOOLEAN)
242+
gc_pretty_print(VARIABLE LUO_WETDEP IS_BOOLEAN)
243+
gc_pretty_print(VARIABLE FASTJX IS_BOOLEAN)
244+
gc_pretty_print(VARIABLE KPPSA IS_BOOLEAN)
245+
endif()
246+

GeosCore/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ endif()
9999

100100
# Define dependencies for libGeosCore.a
101101
target_link_libraries(GeosCore PUBLIC
102+
GeosUtil
102103
ObsPack
103104
History
104105
KPP

GeosCore/calc_met_mod.F90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ MODULE CALC_MET_MOD
3030
PUBLIC :: INTERP
3131
PUBLIC :: SET_DRY_SURFACE_PRESSURE
3232
PUBLIC :: Set_Clock_Tracer
33-
#if defined( ESMF_ ) || defined( EXTERNAL_GRID )
33+
#if defined( USE_ESMF ) || defined( EXTERNAL_GRID )
3434
PUBLIC :: GCHP_Cap_Tropopause_Prs
3535
#endif
3636
!
@@ -845,7 +845,7 @@ SUBROUTINE INTERP( NTIME0, NTIME1, NTDT, Input_Opt, State_Grid, State_Met )
845845

846846
END SUBROUTINE INTERP
847847
!EOC
848-
#if defined( ESMF_ ) || defined( EXTERNAL_GRID )
848+
#if defined( USE_ESMF ) || defined( EXTERNAL_GRID )
849849
!------------------------------------------------------------------------------
850850
! GEOS-Chem Global Chemical Transport Model !
851851
!------------------------------------------------------------------------------
@@ -858,6 +858,8 @@ END SUBROUTINE INTERP
858858
! troposheric chemistry too high over the poles. This is done in the
859859
! standalone GEOS-Chem, and we also need to apply this when running
860860
! GEOS-Chem within the GEOS-5 GCM.
861+
!
862+
! ewl question: do we do this in CESM too? If yes, update this description.
861863
!\\
862864
!\\
863865
! !INTERFACE:

GeosCore/drydep_mod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3643,7 +3643,7 @@ FUNCTION AERO_SFCRSII( K, II, PRESS, TEMP, USTAR, RHB, W10, VTSout, Input_Opt, S
36433643
! Use the formulation of Slinn and Slinn (1980) for the impaction over
36443644
! water surfaces (jaegle 5/11/11)
36453645
IF (LUC == 14) THEN
3646-
#ifdef MODEL_GCHPCTM
3646+
#ifdef MODEL_GCHP
36473647
! Include check that winds are non-zero to avoid div by 0 error
36483648
IF ( IS_SAFE_DIV(1.e+0_f8, W10) ) THEN
36493649
RS = 1.e+0_f8 / (USTAR**2.e+0_f8/ (W10*VON_KARMAN) * &

GeosCore/dust_mod.F90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ MODULE DUST_MOD
5959
! Arrays
6060
REAL(fp), ALLOCATABLE :: FRAC_S(:)
6161
REAL(fp), ALLOCATABLE :: SRCE_FUNC(:,:,:)
62+
! ewl: it seems srce_func isn't used anywhere in the model. Can we delete?
6263

6364
#ifdef TOMAS
6465
! To replicate the obsolete Input_Opt%IDDEP field
@@ -2105,10 +2106,10 @@ SUBROUTINE INIT_DUST( Input_Opt, State_Chm, State_Diag, State_Grid, RC )
21052106
ENDIF
21062107
#endif
21072108

2108-
#if defined( ESMF_ ) || defined( TOMAS )
2109+
#if defined( USE_ESMF ) || defined( TOMAS )
21092110
! EXPERIMENTAL: For archiving the dust source for GCHP
21102111
!
2111-
! Changed to use the ESMF_ flag and not EXTERNAL_GRID/EXTERNAL_FORCING, as
2112+
! Changed to use the ESMF flag and not EXTERNAL_GRID/EXTERNAL_FORCING, as
21122113
! WRF-GC which uses these flags does not require SRCE_FUNC (hplin, 1/22/19)
21132114
ALLOCATE( SRCE_FUNC(State_Grid%NX,State_Grid%NY,3), STAT=AS )
21142115
IF ( AS /= 0 ) CALL ALLOC_ERR( 'SRCE_FUNC' )

GeosCore/hco_interface_gc_mod.F90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ SUBROUTINE HCOI_GC_Init( Input_Opt, State_Chm, State_Grid, &
577577
! compared to a stand-alone version: in ESMF, the source file name
578578
! is set to the container name since this is the identifying name
579579
! used by ExtData.
580-
#ifdef ESMF_
580+
#ifdef USE_ESMF
581581
HcoState%Options%isESMF = .TRUE.
582582
#else
583583
HcoState%Options%isESMF = .FALSE.
@@ -968,7 +968,7 @@ SUBROUTINE HCOI_GC_Run( Input_Opt, State_Chm, State_Grid, &
968968
ENDIF
969969
ENDIF
970970

971-
#if !defined( ESMF_ ) && !defined( MODEL_WRF )
971+
#if !defined( USE_ESMF ) && !defined( MODEL_WRF )
972972
! Check if HEMCO has already been called for this timestep
973973
IF ( ( Phase == 1 ) .and. ( GET_TAU() == PrevTAU ) .and. Input_Opt%amIRoot ) THEN
974974
Print*, 'HEMCO already called for this timestep. Returning.'
@@ -1700,7 +1700,7 @@ SUBROUTINE ExtState_SetFields( Input_Opt, State_Chm, State_Grid, &
17001700
USE State_Met_Mod, ONLY : MetState
17011701
USE State_Chm_Mod, ONLY : ChmState
17021702
USE Drydep_Mod, ONLY : DryCoeff
1703-
#ifdef ESMF_
1703+
#ifdef USE_ESMF
17041704
USE HCOI_Esmf_Mod, ONLY : HCO_SetExtState_ESMF
17051705
#endif
17061706
!
@@ -2814,7 +2814,7 @@ SUBROUTINE ExtState_SetFields( Input_Opt, State_Chm, State_Grid, &
28142814
ExtState%PBL_MAX => HCO_PBL_MAX
28152815
ENDIF
28162816

2817-
#ifdef ESMF_
2817+
#ifdef USE_ESMF
28182818
!=======================================================================
28192819
! ESMF environment: add some additional variables to ExtState.
28202820
! These values must be defined here and not in the initialization
@@ -2874,7 +2874,7 @@ SUBROUTINE ExtState_UpdateFields( Input_Opt, State_Chm, &
28742874
USE State_Chm_Mod, ONLY : ChmState
28752875
USE State_Grid_Mod, ONLY : GrdState
28762876
USE State_Met_Mod, ONLY : MetState
2877-
#ifdef ESMF_
2877+
#ifdef USE_ESMF
28782878
USE HCOI_ESMF_MOD, ONLY : HCO_SetExtState_ESMF
28792879
#endif
28802880
#if defined( MODEL_CLASSIC )
@@ -4140,7 +4140,7 @@ SUBROUTINE CheckSettings( HcoConfig, Input_Opt, State_Met, State_Chm, RC )
41404140

41414141
ENDIF
41424142

4143-
#ifdef ESMF_
4143+
#ifdef USE_ESMF
41444144
!-----------------------------------------------------------------------
41454145
! Also check that HEMCO_RESTART is not set in ESMF
41464146
!-----------------------------------------------------------------------

GeosCore/hco_utilities_gc_mod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2496,7 +2496,7 @@ SUBROUTINE Get_GC_Restart( Input_Opt, State_Chm, State_Grid, &
24962496
ENDIF
24972497
ELSE
24982498
IF ( Input_Opt%amIRoot ) THEN
2499-
#ifdef ESMF_
2499+
#ifdef MAPL_ESMF
25002500
! ExtData and HEMCO behave ambiguously - if the file was found
25012501
! but was full of zeros throughout the domain of interest, it
25022502
! will result in the same output from ExtData as if the field

GeosCore/input_mod.F90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ SUBROUTINE Config_Simulation( Config, Input_Opt, RC )
373373
LOGICAL :: v_bool
374374
INTEGER :: N, C
375375
REAL(fp) :: JulianDateStart, JulianDateEnd
376-
#if defined( ESMF_ ) || defined( MODEL_ )
376+
#if defined( MODEL_GCHP ) || defined( MODEL_GEOS )
377377
INTEGER :: H, M, S
378378
REAL(f4) :: init_UTC
379379
#endif
@@ -597,10 +597,10 @@ SUBROUTINE Config_Simulation( Config, Input_Opt, RC )
597597
ENDIF
598598
Input_Opt%CHEM_INPUTS_DIR = TRIM( v_str )
599599

600-
#if defined( MODEL_GCHP )
601600
!------------------------------------------------------------------------
602601
! Meteorology field
603602
!------------------------------------------------------------------------
603+
#ifdef MODEL_GCHP
604604
key = "simulation%met_field"
605605
v_str = MISSING_STR
606606
CALL QFYAML_Add_Get( Config, TRIM( key ), v_str, "", RC )
@@ -612,7 +612,7 @@ SUBROUTINE Config_Simulation( Config, Input_Opt, RC )
612612
Input_Opt%MetField = TRIM( v_str )
613613
#endif
614614

615-
#if defined( MODEL_GEOS )
615+
#ifdef MODEL_GEOS
616616
Input_Opt%MetField = 'See ExtData.rc'
617617
#endif
618618

@@ -2702,7 +2702,7 @@ SUBROUTINE Config_RRTMG( Config, Input_Opt, RC )
27022702
ENDIF
27032703
ENDIF
27042704

2705-
#ifndef MODEL_GCHPCTM
2705+
#ifndef MODEL_GCHP
27062706
If (Input_Opt%RRTMG_FDH) Then
27072707
errMsg = 'Fixed dynamical heating in RRTMG is currently only available in GCHP'
27082708
CALL GC_Error( errMsg, RC, thisLoc )

GeosCore/linoz_mod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ SUBROUTINE LINOZ_CHEM3( DTCHEM, Input_Opt, State_Chm, State_Grid, &
352352

353353
!IF ( Input_Opt%Verbose ) CALL DEBUG_MSG('DONE GET_PEDGE')
354354

355-
#if defined( ESMF_ ) || defined( EXTERNAL_GRID ) || defined( EXTERNAL_FORCING )
355+
#if defined( USE_ESMF ) || defined( EXTERNAL_GRID ) || defined( EXTERNAL_FORCING )
356356
!-----------------------------------------------------------
357357
! %%%%%%% GEOS-Chem HP (with ESMF & MPI) %%%%%%%
358358
!

0 commit comments

Comments
 (0)