Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify fullchem #2374

Open
yangning-code opened this issue Jul 12, 2024 · 4 comments
Open

Modify fullchem #2374

yangning-code opened this issue Jul 12, 2024 · 4 comments
Assignees
Labels
category: Question Further information is requested topic: Chemical Mechanisms Related to KPP and/or GEOS-Chem chemistry mechanisms

Comments

@yangning-code
Copy link

Your name

Ning Yang

Your affiliation

JNU

Please provide a clear and concise description of your question or discussion topic.

I am using GEOSChemV13.3.2. I want to call the concentration of BCPO in GeosCore/aerosol_mod.F90 in KPP/fullchem/fullchem_RateLawFuncs.F90 so that I can do a mechanism update, but I don’t know how to add it. Can you give me some help?

@yangning-code yangning-code added the category: Question Further information is requested label Jul 12, 2024
@yantosca yantosca added the topic: Chemical Mechanisms Related to KPP and/or GEOS-Chem chemistry mechanisms label Jul 12, 2024
@yantosca yantosca self-assigned this Jul 12, 2024
@yantosca
Copy link
Contributor

Thanks for writing @yangning-code. Maybe the best thing to do would be to add a line

REAL(dp) :: BCPO

to the HetState derived type in commonIncludeVars.H:

TYPE, PUBLIC :: HetState
REAL(dp) :: AVO ! Avogadro's constant [molec/mol]
LOGICAL :: debugBox ! Are we in a debugging box?
LOGICAL :: natSurface ! Is there NAT in this box?
LOGICAL :: pscBox ! Are there polar strat clouds?
LOGICAL :: stratBox ! Are we in the stratosphere
INTEGER :: NAEROTYPE ! Number of aerosol types
REAL(dp) :: aClArea ! Fine SSA+SNA aerosol area [cm2/cm3]
REAL(dp) :: aClRadi ! Fine SSA+SNA aerosol radius [cm]
REAL(dp) :: aClVol ! Fine SSA+SNA aerosol volume [cm3/cm3]
REAL(dp) :: aIce ! Ice surface area [cm2/cm3]
REAL(dp) :: aLiq ! Liquid surface area [cm2/cm3]
REAL(dp) :: aWater(2) ! ISORROPIA/HETP aerosol water (fine & coarse)
REAL(dp) :: Br_conc_CldA ! Br- in cloud (A=fine SSA) [mol/kg H2O]
REAL(dp) :: Br_conc_CldC ! Br- in cloud (C=coarse SSA) [mol/kg H2O]
REAL(dp) :: Br_conc_CldG ! Br- in cloud (G=gas-phase) [mol/kg H2O]
REAL(dp) :: Br_conc_Cld ! Br- total in cloud = A + C + G
REAL(dp) :: Br_conc_SSA ! Br- in fine SSA [mol/kg H2O]
REAL(dp) :: Br_conc_SSC ! Br- in coarse SSA [mol/kg H2O]
REAL(dp) :: Br_over_Cl_Cld ! Br/Cl ratio in cloud
REAL(dp) :: Br_over_Cl_SSA ! Br/Cl ratio in fine sea salt
REAL(dp) :: Br_over_Cl_SSC ! Br/Cl ratio in coarse sea salt
REAL(dp) :: Cl_conc_CldA ! Cl- in cloud (A=fine SSA) [mol/kg H2O]
REAL(dp) :: Cl_conc_CldC ! Cl- in cloud (C=coarse SSA) [mol/kg H2O]
REAL(dp) :: Cl_conc_CldG ! Cl- in cloud (G=gas-phase) [mol/kg H2O]
REAL(dp) :: Cl_conc_Cld ! Cl- total = A + C + G
REAL(dp) :: Cl_conc_SSA ! Cl- in fine sea salt [mol/kg H2O]
REAL(dp) :: Cl_conc_SSC ! Cl- in coarse sea salt [mol/kg H2O]
REAL(dp) :: cldFr ! Cloud fraction
REAL(dp) :: clearFr ! Clear sky fraction
REAL(dp) :: frac_Br_CldA ! Frac of Br- in fine SSA(in cloud)
REAL(dp) :: frac_Br_CldC ! Frac of Br- in coarse SSA (in cloud)
REAL(dp) :: frac_Br_CldG ! Frac of Br- in gas phase
REAL(dp) :: frac_Cl_CldA ! Frac of Cl- in fine SSA (in cloud)
REAL(dp) :: frac_Cl_CldC ! Frac of Cl- in coarse SSA (in cloud)
REAL(dp) :: frac_Cl_CldG ! Frac of Cl- in gas phase
REAL(dp) :: frac_HSO3_aq ! HSO3_aq / ( HSO3_aq + SO3_aq )
REAL(dp) :: frac_SALACL ! Frac of SALACL / total fine sea salt
REAL(dp) :: frac_SO3_aq ! SO3_aq / ( HSO3_aq + SO3_aq )
REAL(dp) :: fupdateHOBr ! Correction factor - HOBr
REAL(dp) :: fupdateHOCl ! Correction factor - HOCl
REAL(dp) :: gamma_HO2 ! Uptake probability for HO2 [1]
REAL(dp) :: H2O ! H2O concentration
REAL(dp) :: HBr_theta ! HBr theta for uptake on ice
REAL(dp) :: HCl_theta ! HCl theta for uptake on ice
REAL(dp) :: H_conc_ICl ! Ice phase pH, Cl-
REAL(dp) :: H_conc_LCl ! Liquid phase pH, Cl-
REAL(dp) :: H_conc_SSA ! Liquid phase pH, fine sea salt
REAL(dp) :: H_conc_SSC ! Liquid phase pH, coarse sea salt
REAL(dp) :: H_conc_Sul ! Liquid phase pH, sulfate
REAL(dp) :: HNO3_theta ! HNO3 theta for uptake on ice
REAL(dp) :: HSO3_aq ! Cloud bisulfite (aka HSO3-) [mol/L]
REAL(dp) :: SO3_aq ! Cloud sulfite (aka SO3--) [mol/L]
REAL(dp) :: HSO3m ! HSO3-/SO2 ratio [1]
REAL(dp) :: SO3mm ! SO3--/SO2 ratio [1]
REAL(dp) :: TSO3_aq ! Cloud sulfite + bisulfite [mol/L]
REAL(dp) :: H_plus ! Proton activity [1] and H+ conc [M]
REAL(dp) :: KHETI_SLA(11) ! Probs for PSC uptk rxns on SLA [1]
REAL(dp) :: HSO4_molal ! Bisulfate concentration [M]
REAL(dp) :: NO3_molal ! Nitrate concentration [M]
REAL(dp) :: SO4_molal ! Sulfate concentration [M]
REAL(dp) :: NIT_conc_SSA ! Cl- in fine sea salt [mol/kg H2O]
REAL(dp) :: NIT_conc_SSC ! Cl- in coarse sea salt [mol/kg H2O]
REAL(dp) :: PI ! PI constant
REAL(dp) :: pHCloud ! Cloud PH
REAL(dp) :: pHSSA(2) ! Sea salt pH (1=fine, 2=coarse)
REAL(dp) :: OMOC_POA ! Org matter/orgc carbon in POA [1]
REAL(dp) :: OMOC_OPOA ! Org matter/org carbon in POA [1]
REAL(dp) :: qIce ! Ice mixing ratio [kg/kg]
REAL(dp) :: qLIq ! Water mixing ratio [kg/kg]
REAL(dp) :: rIce ! Ice radius
REAL(dp) :: rLiq ! Liquid radius
REAL(dp) :: f_Acid_SSA ! Fraction of fine sea salt that is acidic
REAL(dp) :: f_Acid_SSC ! Fraction of coarse sea salt that is acidic
REAL(dp) :: f_Alk_SSA ! Fraction of fine sea salt that is alkaline
REAL(dp) :: f_Alk_SSC ! Fraction of coarse sea salt that is alkaline
LOGICAL :: SSA_is_Alk ! Is fine sea-salt alkaline?
LOGICAL :: SSA_is_Acid ! Is fine sea-salt acidic?
LOGICAL :: SSC_is_Alk ! Is coarse sea-salt alkaline?
LOGICAL :: SSC_is_Acid ! Is coarse sea-salt acidic?
REAL(dp) :: vAir ! Volume of air [cm3]
REAL(dp) :: vIce ! Ice volume [cm3]
REAL(dp) :: vLiq ! Liquid volume [cm3]
REAL(dp) :: wetArea(14) ! Aerosol specific wet sfc area [cm2/cm3]
REAL(dp) :: xArea(14) ! Aerosol specific sfc area [cm2/cm3]
REAL(dp) :: xH2O(14) ! Aerosol water content [cm3/cm3]
REAL(dp) :: xRadi(14) ! Aerosol effective radius [cm]
REAL(dp) :: xVol(14) ! Aerosol specific volume [cm3/cm3]
!
! Additional fields only used by the Hg simulation
!
LOGICAL :: cloudBox ! Are we in a box with cloud?
REAL(dp) :: fracOrgAer ! Fraction of organic aerosol [1]
REAL(dp) :: fracInorgAer ! Fraction of organic aerosol [1]
!
! Additional fields for GEOS runs
!
LOGICAL :: TurnOffHetRates ! Turn off heterogeneous reactions in stratosphere?
END TYPE HetState
TYPE(HetState), TARGET, PUBLIC :: State_Het
!$OMP THREADPRIVATE( State_Het )

and then to copy the values of BCPO into that in the SetStateHet function in KPP/fullchem/fullchem_HetStateFuncs.F90:

 SUBROUTINE fullChem_SetStateHet( I,         J,         L,                  &
                                   id_SALA,   id_SALAAL, id_SALC,            &
                                   id_SALCAL, Input_Opt, State_Chm,          &
                                   State_Met, H,         RC                 )
!
! !USES:
!
    USE ErrCode_Mod
    USE GcKpp_Global
    USE GcKpp_Parameters
    USE PhysConstants,    ONLY : AVO, PI
    USE Input_Opt_Mod,    ONLY : OptInput
    USE rateLawUtilFuncs
    USE State_Chm_Mod,    ONLY : ChmState, Ind_
    USE State_Met_Mod,    ONLY : MetState
    USE Aerosol_Mod,      ONLY : BCPO     ! <=== add this line

and then later on in that function add a line to copy values from BCPO array to the State_Het%BCPO field:

    !========================================================================
    ! Populate fields of the HetState object in gckpp_Global
    !========================================================================


    ! Identify a box for debug printout within rate-law functions
    H%debugBox      = .FALSE.


    ! Constants (so that we can use these within KPP)
    H%AVO           = AVO
    H%PI            = PI


    ! Meteorology-related quantities
    H%CldFr         = MIN(MAX(State_Met%CLDF(I,J,L), 0.0_dp), 1.0_dp)
    H%ClearFr       = 1.0_dp - H%CldFr
    H%QICE          = State_Met%QI(I,J,L)
    H%QLIQ          = State_Met%QL(I,J,L)
    H%vAir          = State_Met%AIRVOL(I,J,L) * 1.0e6_dp


    ! Aerosol fields
    H%nAeroType     = State_Chm%nAeroType
    H%aClArea       = State_Chm%aClArea(I,J,L)
    H%aClRadi       = State_Chm%aClRadi(I,J,L)
    H%aClVol        = H%aClArea * H%aClRadi / 3.0_dp
    H%AWATER(:)     = State_Chm%IsorropAeroH2O(I,J,L,:)
    H%xArea(1:NA)   = State_Chm%AeroArea(I,J,L,1:NA)
    H%xRadi(1:NA)   = State_Chm%AeroRadi(I,J,L,1:NA)
    H%xVol(1:NA)    = H%xArea(1:NA) * H%xRadi(1:NA) / 3.0_dp
    H%wetArea(1:NA) = State_Chm%WetAeroArea(I,J,L,1:NA)
    H%xH2O(1:NA)    = State_Chm%AeroH2O(I,J,L,1:NA) * 1.0e-6_dp
    H%OMOC_POA      = State_Chm%OMOC_POA(I,J)
    H%OMOC_OPOA     = State_Chm%OMOC_OPOA(I,J)
    H%BCPO          = BCPO(I,J,L)  ! <=== add this line

(note, 'State_Hetis passed to this routine as theH` argument, for brevity).

Then make sure to pass State-Het to your rate law function and then you can use the BCPO.

NOTE: There have been a LOT of changes since 13.3. Again, I would recommend using a newer version if possible.

@yangning-code
Copy link
Author

Because of the model version issue, I did not find the commonIncludeVars.H you mentioned. However, the fullchem.kpp in the version 13.3.2 I used has the same content as commonIncludeVars.H, so I added REAL(dp) :: BCPO
微信截图_20240712224417
Then, I added USE Aerosol_Mod, ONLY : BCPO ! <=== add this line and H%BCPO = BCPO(I,J,L) ! <=== add this line in KPP/fullchem/fullchem_HetStateFuncs.F90

Finally, I recompiled KPP, and then an error occurred when compiling the code again
微信截图

@yantosca
Copy link
Contributor

Thanks @yangning-code. Yes, the commonIncludeVars.H was added in a later version. It just moved stuff out of the fullchem.kpp file into a common file that could be used for all of the mechanisms.

It looks like the code can't resolve the aerosol_mod.F90. The other thing you can do is to pass BCPO as an argument into the SetStateHet routine instead of trying to get it from aerosol_mod.

@yangning-code
Copy link
Author

It's a bit difficult for me, can you give me an example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Question Further information is requested topic: Chemical Mechanisms Related to KPP and/or GEOS-Chem chemistry mechanisms
Projects
None yet
Development

No branches or pull requests

2 participants