geoschem / geos-chem

GEOS-Chem "Science Codebase" repository. Contains GEOS-Chem science routines, run directory generation scripts, and interface code. This repository is used as a submodule within the GCClassic and GCHP wrappers, as well as in other modeling contexts (external ESMs).
http://geos-chem.org
Other
164 stars 157 forks source link

[QUESTION]How to save a production and loss diagnostic for a specific species? #729

Closed yangxiajie closed 3 years ago

yangxiajie commented 3 years ago

In Geos-Chem 12.9.3, I want to save production and loss of chlorinated hydrocarbons (CHxCly) in HISTRY.rc, by using THE ProdLoss COLLECTION. This is my setting:

ProdLoss.template:          '%y4%m2%d2_%h2%n2z.nc4',
ProdLoss.format:            'CFIO',
ProdLoss.frequency:         00000000 010000
ProdLoss.duration:          00000100 000000
ProdLoss.mode:              'time-averaged'
ProdLoss.fields:            'Prod_CH2Cl2 ', 'GIGCchem',
                            'Loss_CH2Cl2', 'GIGCchem'

But model reported errors:

HISTORY (INIT): Opening ./HISTORY.rc
===============================================================================
GEOS-Chem ERROR: PROD_CH2CL2 is not found in the registry for the DIAG object!
-> at Registry_Lookup (in Headers/registry_mod.F90)
===============================================================================

===============================================================================
GEOS-Chem ERROR: Could not locate Prod_CH2Cl2 diagnostics state registry.
-> History_AddItemToCollection (in History/history_mod.F90)
===============================================================================

===============================================================================
GEOS-Chem ERROR: Could not add diagnostic "Prod_CH2Cl2" to collection: ProdLoss
-> at History_ReadCollectionData (in module History/history_mod.F90)

-> ERROR occurred at (or near) line    391 of the HISTORY.rc file
===============================================================================

===============================================================================
GEOS-Chem ERROR: Error encountered in "History_ReadCollectionData"!
-> at History_Init (in module History/history_mod.F90)
===============================================================================

===============================================================================
GEOS-CHEM ERROR: Error encountered in "History_Init"!
STOP at  -> at GEOS-Chem (in GeosCore/main.F90)
===============================================================================

Is there any way to save production and loss diagnostic of chlorinated hydrocarbons (CHxCly) ?

yantosca commented 3 years ago

Thanks for writing @yangxiajie. This topic was covered in issue #463. You will need to define production and loss families for CH2CL2 in the #FAMILIES section of gckpp.kpp, as shown below:

#FAMILIES
POx : O3 + NO2 + 2NO3 + ... etc not shown ...
LOx : O3 + NO2 + 2NO3 + ... etc not shown ...
PCO : CO;
LCO : CO;
PSO4 : SO4;
LCH4 : CH4;
PH2O2 : H2O2;
PCH2Cl2: CH2Cl2
LCH2Cl2: CH2Cl2

Then re-generate the gckpp*.F90 files (which define the chemical mechanism) with KPP-for-GEOS-Chem version 2.2.5_gc. Then once you have regenerated these files, you can compile GEOS-Chem into an executable. After this, the PCH2Cl2 and LCH2Cl2 diagnostics will be saved out properly.

Please also see our KPP-for-GEOS-Chem documentation (https://kpp.readthedocs.io) for detailed instructions on how to download and compile the KPP-for-GEOS-Chem.

yangxiajie commented 3 years ago

Thanks @yantosca

I have re-generate the gckpp*.F90 files, and define production and loss families for all CHxCly in the #FAMILIES section of gckpp.kpp, as shown below:

PCHCl3 : CHCl3;
LCHCl3 : CHCl3;
PCH2Cl2 : CH2Cl2;
LCH2Cl2 : CH2Cl2;
PCH3Cl : CH3Cl;
LCH3Cl : CH3Cl;

It can successfully compile KPP:

This is KPP-2.2.5_gc.

KPP is parsing the equation file.
KPP is computing Jacobian sparsity structure.
KPP is starting the code generation.
KPP is initializing the code generation.
KPP is generating the monitor data:
    - gckpp_Monitor
KPP is generating the utility data:
    - gckpp_Util
KPP is generating the global declarations:
    - gckpp_Main
KPP is generating the ODE function:
    - gckpp_Function
KPP is generating the ODE Jacobian:
    - gckpp_Jacobian
    - gckpp_JacobianSP
KPP is generating the linear algebra routines:
    - gckpp_LinearAlgebra
KPP is generating the utility functions:
    - gckpp_Util
KPP is generating the rate laws:
    - gckpp_Rates
KPP is generating the parameters:
    - gckpp_Parameters
KPP is generating the global data:
    - gckpp_Global
KPP is generating the driver from none.f90:
    - gckpp_Main
KPP is starting the code post-processing.

KPP has succesfully created the model "gckpp".

"gckpp_Function.f90" -> "gckpp_Function.F90"
"gckpp_Global.f90" -> "gckpp_Global.F90"
"gckpp_Initialize.f90" -> "gckpp_Initialize.F90"
"gckpp_Integrator.f90" -> "gckpp_Integrator.F90"
"gckpp_Jacobian.f90" -> "gckpp_Jacobian.F90"
"gckpp_JacobianSP.f90" -> "gckpp_JacobianSP.F90"
"gckpp_LinearAlgebra.f90" -> "gckpp_LinearAlgebra.F90"
"gckpp_Model.f90" -> "gckpp_Model.F90"
"gckpp_Monitor.f90" -> "gckpp_Monitor.F90"
"gckpp_Parameters.f90" -> "gckpp_Parameters.F90"
"gckpp_Precision.f90" -> "gckpp_Precision.F90"
"gckpp_Rates.f90" -> "gckpp_Rates.F90"
"gckpp_Util.f90" -> "gckpp_Util.F90"
Reactivity consists of 164 reactions
Written to gckpp_Util.F90

However, another error is reported in GEOS-Chem:

===============================================================================
GEOS-Chem ERROR: Is_Gas and Is_Aerosol are both FALSE for species LCHCl3!
 -> at Init_Species_Database (in module Headers/species_database_mod.F90
===============================================================================

===============================================================================
GEOS-Chem ERROR: Error encountered in routine "Init_Species_Database"!
 -> at Init_State_Chm (in Headers/state_chm_mod.F90)
===============================================================================

===============================================================================
GEOS-Chem ERROR: Error encountered within call to "Init_State_Chm"!
 -> at GC_Init_StateObj (in GeosCore/gc_environment_mod.F90)
===============================================================================

===============================================================================
GEOS-CHEM ERROR: Error encountered in "GC_Init_All!"!
STOP at  -> at GEOS-Chem (in GeosCore/main.F90)
===============================================================================

I can find CHCl3 in species_database.yml file, and the setting is :

CHCl3:
  Formula: CHCl3
  FullName: Chloroform
  Is_Advected: true
  Is_Gas: true
  Is_Photolysis: true
  MW_g: 119.35

So I used #669 to fix.

After that, another error is reoprted in model:

===============================================================================
GEOS-Chem ERROR: Could not locate KPP prod/loss species: PCHCl3!
 -> at MapProdLossSpecies (in module Headers/state_chm_mod.F90)
===============================================================================

===============================================================================
GEOS-Chem ERROR: Error encountered in "MapProdLossSpecies"!
 -> at Init_State_Chm (in Headers/state_chm_mod.F90)
===============================================================================

===============================================================================
GEOS-Chem ERROR: Error encountered within call to "Init_State_Chm"!
 -> at GC_Init_StateObj (in GeosCore/gc_environment_mod.F90)
===============================================================================

===============================================================================
GEOS-CHEM ERROR: Error encountered in "GC_Init_All!"!
STOP at  -> at GEOS-Chem (in GeosCore/main.F90)
===============================================================================

It seems there is no PCHCl3 in gckpp.map file, but I donot know how to fix it.

I upload my gckpp.kpp, gckpp.map and Tropchem.eqn files. Files.zip

yantosca commented 3 years ago

Thanks for writing. I think to fix this you would simply need to add entries for your prod & loss species to the species_database.yml file, such as:

PCHCl3:
  Formula: CHCl3
  FullName: Production of Chloroform
  Is_Gas: true
  MW_g: 119.35
LCHCl3:
  Formula: CHCl3
  FullName: Loss of Chloroform
  Is_Gas: true
  MW_g: 119.35

and then it should work. That error message is meant to make sure that each entry in the species_database.yml file is tagged as either a gas or aerosol. This prevents issues interpreting missing species.

yangxiajie commented 3 years ago

Thank you @yantosca

Now I fix it.