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 156 forks source link

Modify fullchem #2374

Open yangning-code opened 1 month ago

yangning-code commented 1 month ago

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?

yantosca commented 1 month ago

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:

https://github.com/geoschem/geos-chem/blob/dd859ee45494af71d29f0877f359ff571f697b67/KPP/fullchem/commonIncludeVars.H#L112-L213

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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