Skip to content

Commit

Permalink
Move KPP standalone code to KPP/standalone folder
Browse files Browse the repository at this point in the history
KPP/CMakeLists.txt
- Calls the KPP/standalone/CMakeLists.txt file to build the
  KPP standalone executable when fullchem or custom mechanisms
  are selected

KPP/standalone/kpp_standalone.F90
KPP/standalone/kpp_standalone_init.F90
- Moved from KPP/fullchem folder
- Trimmed trailing whitespace

KPP/standalone/sample_sites
- Moved from KPP/fullchem/samples_kpp_standalone

KPP/standalone/CMakeLists.txt
- Compiles the kpp_standalone_init.F90 and kpp_standalone.F90 modules,
  linking it to the KPP library that is built (fullchem or custom)

CHANGELOG.md
- Updaetd accordingly

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
  • Loading branch information
yantosca committed Oct 8, 2024
1 parent edcafd0 commit 38162aa
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 53 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Added computation of water concentration to use in photolysis for application of UV absorption by water in Cloud-J v8
- Added ACO3, ACR, ACRO2, ALK4N{1,2,O}2, ALK4P, ALK7, APAN, APINN, APINO2, APINP, AROCMCHO, AROMCO3, AROMPN, BPINN, BPINO2, BPINON, BPINOO2, BPINOOH, BPINP, BUTN, BUTO2, C4H6, C96N, C96O2, C9602H, EBZ, GCO3, HACTA, LIMAL, LIMKB, LIMKET, LIMKO2, LIMN, LIMNB, LIMO2H, LIMO3, LIMO3H, LIMPAN, MEKCO3, MEKPN, MYRCO, PHAN, PIN, PINAL, PINO3, PINONIC, PINPAN, R7N{1,2}, R7O2, R7P, RNO3, STYR, TLFUO2, TLFUONE, TMB, ZRO2 to `species_database.yml` following Travis et al. 2024.
- Added TSOIL1 field to `State_Met` for use in HEMCO soil NOx extension. This should only be read in when the `UseSoilTemperature` option is true in HEMCO config.
- Added KPP standalone
- Added KPP standalone; executable will be built when compiling for fullchem or custom mechanisms

### Changed
- Copy values from `State_Chm%KPP_AbsTol` to `ATOL` and `State_Chm%KPP_RelTol` to `RTOL` for fullchem and Hg simulations
Expand Down
2 changes: 2 additions & 0 deletions KPP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#-----------------------------------------------------------------------------
if("${MECH}" STREQUAL fullchem)
add_subdirectory(fullchem)
add_subdirectory(standalone)
endif()

#-----------------------------------------------------------------------------
Expand All @@ -20,6 +21,7 @@ endif()
#-----------------------------------------------------------------------------
if("${MECH}" STREQUAL custom)
add_subdirectory(custom)
add_subdirectory(standalone)
endif()

#-----------------------------------------------------------------------------
Expand Down
23 changes: 23 additions & 0 deletions KPP/standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# KPP/fullchem/CMakeLists.txt

#----------------------------------------------------------------------------
# Add libKPPStandalone.a -- KPP standalone executable
#----------------------------------------------------------------------------
add_library(KPPStandalone
STATIC EXCLUDE_FROM_ALL
kpp_standalone.F90
kpp_standalone_init.F90
)

# Dependencies
target_link_libraries(KPPStandalone
PUBLIC
KPP
)

# Treat REAL as if it were REAL*8
target_compile_options(KPPStandalone
PRIVATE ""
$<$<STREQUAL:"${CMAKE_Fortran_COMPILER_ID}","Intel">:-r8>
$<$<STREQUAL:"${CMAKE_Fortran_COMPILER_ID}","GNU">:-fdefault-real-8 -fdefault-double-8>
)
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
program main

! The KPP Standalone for GEOS-Chem Mechanism Analysis
!
!
!
!
! Program Description:
!
!
! This program runs the GEOS-Chem KPP Standalone for a given set of initial conditions.
! It reads an input file generated by the KPP Standalone Interface that generates model
! output of the full chemical state of grid cells in 3D GEOS-Chem, GCHP, and GEOS-CF runs.
! The full mechanism is run to replicate the chemistry of the specified grid cell.
! Obin Sturm (psturm@usc.edu), Michael S Long, Christoph Keller

! The KPP Standalone is adapted from a box model used in the following publication:
! Lin, H., Long, M. S., Sander, R., Sandu, A., Yantosca, R. M., Estrada, L. A., et al. (2023).
! An adaptive auto-reduction solver for speeding up integration of chemical kinetics in atmospheric chemistry models:
! Implementation and evaluation in the Kinetic Pre-Processor (KPP) version 3.0.0.
! Lin, H., Long, M. S., Sander, R., Sandu, A., Yantosca, R. M., Estrada, L. A., et al. (2023).
! An adaptive auto-reduction solver for speeding up integration of chemical kinetics in atmospheric chemistry models:
! Implementation and evaluation in the Kinetic Pre-Processor (KPP) version 3.0.0.
! Journal of Advances in Modeling Earth Systems, 15, e2022MS003293. https://doi.org/10.1029/2022MS003293

! Updates:
! - 2024/05/06, Obin Sturm: Simplification of the code for the GEOS-Chem KPP Standalone,
! removed all autoreduce and convergence criteria testing.
! The more general tool just runs one operator timestep
! The more general tool just runs one operator timestep
! and then prints out the results to an output file.

USE GCKPP_GLOBAL
Expand Down Expand Up @@ -52,7 +52,7 @@ program main

LOGICAL :: OUTPUT
LOGICAL :: ReInit


! Vars for reading files
character(len=256) :: inputfile
Expand All @@ -64,7 +64,7 @@ program main
! Get the first argument
call get_command_argument(1, inputfile)
print*, 'Processing sample: ', trim(inputfile)
else
else
print*, 'No sample provided. Exiting.'
stop
endif
Expand All @@ -87,7 +87,6 @@ program main
call read_input(inputfile, R, Cinit, SPC_NAMES, Hstart, Hexit, cosSZA, level, fileTotSteps, OperatorTimestep)



! Run the full mechanism
call fullmech(RTOL_VALUE=0.5e-2_dp)

Expand All @@ -110,7 +109,7 @@ subroutine fullmech(RTOL_VALUE)

! Set OPTIONS
IERR = 0 ! Success or failure flag
ISTATUS = 0 ! Rosenbrock output
ISTATUS = 0 ! Rosenbrock output
RCNTRL = 0.0_dp ! Rosenbrock input
RCNTRL(3) = Hstart
! write(*,'(a,f10.2)') " Hstart: ", Hstart
Expand All @@ -121,7 +120,7 @@ subroutine fullmech(RTOL_VALUE)
ICNTRL(3) = 4
ICNTRL(7) = 1
ICNTRL(15) = -1

! Tolerances
ATOL = 1e-2_dp
RTOL = RTOL_VALUE ! default in GEOS-CF 2.0 is 0.5e-2_dp
Expand All @@ -131,7 +130,7 @@ subroutine fullmech(RTOL_VALUE)
TIN = T
TOUT = T + OperatorTimestep
TEMP = 298.

full_avg = 0.
full_sumtime = 0.
start = 0.
Expand Down Expand Up @@ -163,7 +162,7 @@ subroutine fullmech(RTOL_VALUE)
endif

! Run the RTOL variation loop
DO I=1,NRTOL
DO I=1,NRTOL
call Initialize()
C(1:NSPEC) = Cinit(1:NSPEC)

Expand Down Expand Up @@ -200,7 +199,7 @@ subroutine write_output(inputfile, outputfile)
! Write meteo data lines of the input to the output file
open(20, file=outputfile)
open(10, file=inputfile, status='old')

! Write the header lines to the output file
write(20, '(A)') "30"
write(20, '(A)') "==========================================================================="
Expand Down Expand Up @@ -237,4 +236,3 @@ subroutine write_output(inputfile, outputfile)
end subroutine write_output

end program main

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ subroutine read_input(filename, R, C, SPC_NAMES, Hstart, Hexit, cosSZA, level, f
do i = 1, NHEADER
read(file_unit, '(A)', iostat=ierr) line
if (ierr /= 0) then
print *, "Error reading line", i
print *, "Error reading line", i
exit
end if
! Get level
Expand Down Expand Up @@ -91,7 +91,7 @@ subroutine read_input(filename, R, C, SPC_NAMES, Hstart, Hexit, cosSZA, level, f
do i = 1, NSPEC
read(file_unit, '(A)', iostat=ierr) line
if (ierr /= 0) then
print *, "Error reading line", i+NHEADER
print *, "Error reading line", i+NHEADER
exit
end if
idx = index(line, ',') + 1
Expand All @@ -108,7 +108,7 @@ subroutine read_input(filename, R, C, SPC_NAMES, Hstart, Hexit, cosSZA, level, f
do i = 1, NREACT
read(file_unit, '(A)', iostat=ierr) line
if (ierr /= 0) then
print *, "Error reading line", i+NSPEC+NHEADER
print *, "Error reading line", i+NSPEC+NHEADER
exit
end if
idx = index(line, ',') + 1
Expand All @@ -120,4 +120,3 @@ subroutine read_input(filename, R, C, SPC_NAMES, Hstart, Hexit, cosSZA, level, f
end subroutine read_input

end module kpp_standalone_init

Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
48
48
===========================================================================
KPP Standalone Atmospheric Chemical State
File Description:
This file contains model output of the atmospheric chemical state
as simulated by the GEOS-Chem chemistry module in a 3D setting.
Each grid cell represents the chemical state of an individual location,
suitable for input into a separate KPP Standalone program which will
replicate the chemical evolution of that grid cell for mechanism analysis.
Note that the KPP Standalone will only use concentrations, rate constants,

KPP Standalone Atmospheric Chemical State
File Description:
This file contains model output of the atmospheric chemical state
as simulated by the GEOS-Chem chemistry module in a 3D setting.
Each grid cell represents the chemical state of an individual location,
suitable for input into a separate KPP Standalone program which will
replicate the chemical evolution of that grid cell for mechanism analysis.
Note that the KPP Standalone will only use concentrations, rate constants,
and KPP-specific fields. All other fields are for reference. The first line
contains the number of lines in this header. If wanting to use this output
for other analysis, a Python class to read these fields is available by
request, contact Obin Sturm (psturm@usc.edu).
Generated by the GEOS-Chem Model
(https://geos-chem.org/)
Using the KPP Standalone Interface
github.com/GEOS-ESM/geos-chem/tree/feature/psturm/kpp_standalone_interface
With contributions from:
Obin Sturm (psturm@usc.edu)
Christoph Keller
Michael Long
Sam Silva
Meteorological and general grid cell metadata
contains the number of lines in this header. If wanting to use this output
for other analysis, a Python class to read these fields is available by
request, contact Obin Sturm (psturm@usc.edu).

Generated by the GEOS-Chem Model
(https://geos-chem.org/)
Using the KPP Standalone Interface
github.com/GEOS-ESM/geos-chem/tree/feature/psturm/kpp_standalone_interface
With contributions from:
Obin Sturm (psturm@usc.edu)
Christoph Keller
Michael Long
Sam Silva

Meteorological and general grid cell metadata
Location: Beijing
Timestamp: 2020/01/06 13:45
Longitude (degrees): 117.0185
Expand All @@ -36,17 +36,17 @@ Dry air density (molec/cm3): 0.2646E+20
Water vapor mixing ratio (vol H2O/vol dry air): 0.3956E-02
Cloud fraction: 0.0000E+00
Cosine of solar zenith angle: -0.8279E+00
KPP Integrator-specific parameters
KPP Integrator-specific parameters
Init KPP Timestep (seconds): 268.3002
Exit KPP Timestep (seconds): 32.4352
Chemistry operator timestep (seconds): 900.0000
Number of internal timesteps: 28
CSV data of full chemical state, including species concentrations,
rate constants (R) and instantaneous reaction rates (A).
All concentration units are in molecules/cc and rates in molec/cc/s.
CSV data of full chemical state, including species concentrations,
rate constants (R) and instantaneous reaction rates (A).
All concentration units are in molecules/cc and rates in molec/cc/s.

===========================================================================
Name, Value
Name, Value
CH2I2, 0.5229637490161687E+06
CH2IBr, 0.5401741649323440E+06
CH2ICl, 0.2389579494513276E+07
Expand Down Expand Up @@ -2130,4 +2130,3 @@ A891, 0.0000000000000000E+00
A892, 0.0000000000000000E+00
A893, 0.0000000000000000E+00
A894, 0.0000000000000000E+00

0 comments on commit 38162aa

Please sign in to comment.