Skip to content

Commit

Permalink
Merge pull request #3 from jimmielin/CESM-GC_dev
Browse files Browse the repository at this point in the history
Feat: Write ZPJ values for HEMCO paranox and bug fix
  • Loading branch information
fritzt authored Feb 24, 2021
2 parents 17783e7 + 63db2d5 commit d142a78
Showing 1 changed file with 49 additions and 11 deletions.
60 changes: 49 additions & 11 deletions src/chemistry/geoschem/chemistry.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,7 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
use PBL_Mix_Mod, only : Compute_PBL_Height
use UCX_Mod, only : Set_H2O_Trac
use CMN_FJX_MOD, only : ZPJ
USE FAST_JX_MOD, only : RXN_NO2, RXN_O3_1, RXN_O3_2a
use State_Diag_Mod, only : get_TagInfo
use Unitconv_Mod, only : Convert_Spc_Units

Expand Down Expand Up @@ -3046,10 +3047,9 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )

! Day
FIELDNAME = TRIM(PREFIX) // '_DAY'
fldname_ns = FIELDNAME
tmpIdx = pbuf_get_index(fldname_ns, RC)
tmpIdx = pbuf_get_index(FIELDNAME, RC)
IF ( tmpIdx < 0 .or. ( iStep == 1 ) ) THEN
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(fldname_ns)
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(FIELDNAME)
BrPtrDay(N)%MR(1,:nY,nZ:1:-1) = 0.0e+0_f4
ELSE
pbuf_chnk => pbuf_get_chunk(hco_pbuf2d, LCHNK)
Expand All @@ -3062,9 +3062,9 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )

! Night
FIELDNAME = TRIM(PREFIX) // '_NIGHT'
tmpIdx = pbuf_get_index(fldname_ns, RC)
tmpIdx = pbuf_get_index(FIELDNAME, RC)
IF ( tmpIdx < 0 .or. ( iStep == 1 ) ) THEN
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(fldname_ns)
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(FIELDNAME)
BrPtrDay(N)%MR(1,:nY,nZ:1:-1) = 0.0e+0_f4
ELSE
pbuf_chnk => pbuf_get_chunk(hco_pbuf2d, LCHNK)
Expand Down Expand Up @@ -3105,9 +3105,9 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
IF ( IERR .NE. 0 ) CALL ENDRUN('Failure while allocating PLVEC%PROD')

! Get pointer from HEMCO
tmpIdx = pbuf_get_index(fldname_ns, RC)
tmpIdx = pbuf_get_index(FIELDNAME, RC)
IF ( tmpIdx < 0 .or. ( iStep == 1 ) ) THEN
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(fldname_ns)
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(FIELDNAME)
PLVEC(N)%PROD(1,:nY,nZ:1:-1) = 0.0e+0_f4
FND = .False.
ELSE
Expand Down Expand Up @@ -3137,9 +3137,9 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
ENDIF

! Get pointer from HEMCO
tmpIdx = pbuf_get_index(fldname_ns, RC)
tmpIdx = pbuf_get_index(FIELDNAME, RC)
IF ( tmpIdx < 0 .or. ( iStep == 1 ) ) THEN
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(fldname_ns)
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(FIELDNAME)
PLVEC(N)%LOSS(1,:nY,nZ:1:-1) = 0.0e+0_f4
FND = .False.
ELSE
Expand Down Expand Up @@ -3168,9 +3168,9 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
ALLOCATE( STRAT_OH(1,PCOLS,nZ), STAT=IERR )
IF ( IERR .NE. 0 ) CALL ENDRUN('Failure while allocating STRAT_OH')

tmpIdx = pbuf_get_index(fldname_ns, RC)
tmpIdx = pbuf_get_index(FIELDNAME, RC)
IF ( tmpIdx < 0 .or. ( iStep == 1 ) ) THEN
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(fldname_ns)
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(FIELDNAME)
STRAT_OH(1,:nY,nZ:1:-1) = 0.0e+0_f4
ELSE
pbuf_chnk => pbuf_get_chunk(hco_pbuf2d, LCHNK)
Expand Down Expand Up @@ -3550,6 +3550,44 @@ subroutine chem_timestep_tend( state, ptend, cam_in, cam_out, dT, pbuf, fh2o )
CALL ENDRUN('Incorrect unit in GEOS-Chem State_Chm%Species')
ENDIF

! Save and write J-values to pbuf for HEMCO
! in HCO_IN_JNO2, HCO_IN_JOH
FIELDNAME = 'HCO_IN_JNO2'
tmpIdx = pbuf_get_index(FIELDNAME, RC)
IF ( tmpIdx < 0 .or. ( iStep == 1 ) ) THEN
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(FIELDNAME)
ELSE
pbuf_chnk => pbuf_get_chunk(hco_pbuf2d, LCHNK)
CALL pbuf_get_field(pbuf_chnk, tmpIdx, pbuf_ik)

! RXN_NO2: NO2 + hv --> NO + O
pbuf_ik(:nY,:nZ) = ZPJ(nZ:1:-1, RXN_NO2, 1, :nY)

pbuf_chnk => NULL()
pbuf_ik => NULL()
ENDIF


FIELDNAME = 'HCO_IN_JOH'
tmpIdx = pbuf_get_index(FIELDNAME, RC)
IF ( tmpIdx < 0 .or. ( iStep == 1 ) ) THEN
IF ( rootChunk ) Write(iulog,*) "chem_timestep_tend: Field not found ", TRIM(FIELDNAME)
ELSE
pbuf_chnk => pbuf_get_chunk(hco_pbuf2d, LCHNK)
CALL pbuf_get_field(pbuf_chnk, tmpIdx, pbuf_ik)

IF ( Input_Opt%LUCX ) THEN
! RXN_O3_1: O3 + hv --> O2 + O
pbuf_ik(:nY,:nZ) = ZPJ(nZ:1:-1, RXN_O3_1, 1, :nY)
ELSE
! RXN_O3_2a: O3 + hv --> 2OH
pbuf_ik(:nY,:nZ) = ZPJ(nZ:1:-1, RXN_O3_2a, 1, :nY)
ENDIF

pbuf_chnk => NULL()
pbuf_ik => NULL()
ENDIF

! GEOS-Chem considers CO2 as a dead species and resets its concentration
! internally. Right after the call to `Do_Chemistry`, State_Chm%Species(iCO2)
! corresponds to the chemically-produced CO2. The real CO2 concentration
Expand Down

0 comments on commit d142a78

Please sign in to comment.