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

Fixes towards achieving bit-for-bit reproducibility in GC-Classic upon restart #2521

Draft
wants to merge 13 commits into
base: dev/14.6.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 4 additions & 51 deletions GeosCore/airs_ch4_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ SUBROUTINE CALC_AIRS_CH4_FORCE( Input_Opt, State_Chm, State_Grid, &
USE State_Grid_Mod, ONLY : GrdState
USE State_Met_Mod, ONLY : MetState
USE Timers_Mod, ONLY : Timer_End, Timer_Start
USE UnitConv_Mod
USE UnitConv_Mod, ONLY : Check_Units, MOLES_SPECIES_PER_MOLES_DRY_AIR
!
! !INPUT PARAMETERS:
!
Expand Down Expand Up @@ -517,33 +517,13 @@ SUBROUTINE CALC_AIRS_CH4_FORCE( Input_Opt, State_Chm, State_Grid, &
print*, ' for hour range: ', GET_HOUR(), GET_HOUR()+1
print*, ' found # AIRS observations: ', NOBS

! Halt diagnostics timer (so that unit conv can be timed separately)
IF ( Input_Opt%useTimers ) THEN
CALL Timer_End( "Diagnostics", RC )
ENDIF

! Convert species units to [v/v] (mps, 6/12/2020)
CALL Convert_Spc_Units( &
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
mapping = State_Chm%Map_Advect, &
new_units = MOLES_SPECIES_PER_MOLES_DRY_AIR, &
previous_units = previous_units, &
RC = RC )

IF ( RC /= GC_SUCCESS ) THEN
ErrMsg = 'Unit conversion error (kg/kg dry -> v/v dry)'
! Verify that incoming State_Chm%Species units are mol/mol dry air.
IF ( .not. Check_Units( State_Chm, MOLES_SPECIES_PER_MOLES_DRY_AIR ) ) THEN
ErrMsg = 'Not all species are in "mol/mol dry" units!'
CALL GC_Error( ErrMsg, RC, ThisLoc )
RETURN
ENDIF

! Start diagnostics timer again
IF ( Input_Opt%useTimers ) THEN
CALL Timer_Start( "Diagnostics", RC )
ENDIF

!! need to update this in order to do i/o with this loop parallel
!! ! Now do a parallel loop for analyzing data
!!$OMP PARALLEL DO
Expand Down Expand Up @@ -705,33 +685,6 @@ SUBROUTINE CALC_AIRS_CH4_FORCE( Input_Opt, State_Chm, State_Grid, &
ENDDO ! NT
!!$OMP END PARALLEL DO

! Halt diagnostics timer (so that unit conv can be timed separately)
IF ( Input_Opt%useTimers ) THEN
CALL Timer_End( "Diagnostics", RC )
ENDIF

! Convert species units back to original unit (mps, 6/12/2020)
CALL Convert_Spc_Units( &
Input_Opt = Input_Opt, &
State_Chm = State_Chm, &
State_Grid = State_Grid, &
State_Met = State_Met, &
mapping = State_Chm%Map_Advect, &
new_units = previous_units, &
RC = RC )

! Trap errors
IF ( RC /= GC_SUCCESS ) THEN
ErrMsg = 'Unit conversion error'
CALL GC_Error( ErrMsg, RC, ThisLoc )
RETURN
ENDIF

! Start diagnostics timer
IF ( Input_Opt%useTimers ) THEN
CALL Timer_Start( "Diagnostics", RC )
ENDIF

283 FORMAT( I10,2x,I4,2x,I4,2x,F8.3,2x,F8.4,2x,I4,2x,I2,2x,I2,2x,I2, &
2x,I2,2x,I2,2x,F12.3,2x,E12.6,2x,E12.6,2x,E12.6, &
2x, E12.6,2x, E12.6,2x, F12.3, 2x,E12.6, 2x, E12.6, 2x, &
Expand Down
88 changes: 23 additions & 65 deletions GeosCore/diagnostics_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ MODULE Diagnostics_mod
!
PUBLIC :: Set_AerMass_Diagnostic
PUBLIC :: Set_Diagnostics_EndofTimestep
PUBLIC :: Set_SpcConc_Diags_VVDry
PUBLIC :: Zero_Diagnostics_StartofTimestep
PUBLIC :: Compute_Budget_Diagnostics
#ifdef ADJOINT
Expand All @@ -34,7 +35,6 @@ MODULE Diagnostics_mod
!
! !PRIVATE MEMBER FUNCTIONS
!
PRIVATE :: Set_SpcConc_Diags_VVDry
PRIVATE :: Set_SpcConc_Diags_MND
!
! !REVISION HISTORY:
Expand Down Expand Up @@ -121,20 +121,6 @@ SUBROUTINE Set_Diagnostics_EndofTimestep( Input_Opt, State_Chm, &
ThisLoc = &
' -> at Set_Diagnostics_EndofTimestep (in GeosCore/diagnostics_mod.F90)'

!------------------------------------------------------------------------
! Set species concentration for diagnostics in units of
! v/v dry air = mol/mol dry air
!------------------------------------------------------------------------
CALL Set_SpcConc_Diags_VVDry( Input_Opt, State_Chm, State_Diag, &
State_Grid, State_Met, RC )

! Trap potential errors
IF ( RC /= GC_SUCCESS ) THEN
ErrMsg = 'Error encountered setting SpeciesConcVV diagnostic'
CALL GC_ERROR( ErrMsg, RC, ThisLoc )
RETURN
ENDIF

!-----------------------------------------------------------------------
! Set species concentration for diagnostics in units of
! molec/cm3 (hplin, 11/21/21)
Expand Down Expand Up @@ -487,7 +473,6 @@ SUBROUTINE Set_SpcAdj_Diagnostic( Input_Opt, State_Chm, State_Diag, &

! Assume success
RC = GC_SUCCESS
Found = .FALSE.
ThisLoc = ' -> Set_SpcAdj_Diagnostic (in GeosCore/diagnostics_mod.F90)'

! Make sure all units are in kg/kg dry
Expand Down Expand Up @@ -588,14 +573,13 @@ SUBROUTINE Set_SpcConc_Diags_VVDry( Input_Opt, State_Chm, State_Diag, &
! !USES:
!
USE Input_Opt_Mod, ONLY : OptInput
USE PhysConstants, ONLY : AIRMW
USE State_Met_Mod, ONLY : MetState
USE State_Chm_Mod, ONLY : ChmState
USE State_Diag_Mod, ONLY : DgnMap
USE State_Diag_Mod, ONLY : DgnState
USE State_Grid_Mod, ONLY : GrdState
USE Time_Mod, ONLY : Get_LocalTime
USE UnitConv_Mod, ONLY : Check_Units, KG_SPECIES_PER_KG_DRY_AIR
USE UnitConv_Mod, ONLY : Check_Units, MOLES_SPECIES_PER_MOLES_DRY_AIR
!
! !INPUT PARAMETERS:
!
Expand All @@ -622,7 +606,6 @@ SUBROUTINE Set_SpcConc_Diags_VVDry( Input_Opt, State_Chm, State_Diag, &
! !LOCAL VARIABLES:
!
! Scalars
LOGICAL :: Found
INTEGER :: D, I, J, L, N, S
REAL(fp) :: TmpVal, Conv, LT, GOOD

Expand All @@ -632,52 +615,22 @@ SUBROUTINE Set_SpcConc_Diags_VVDry( Input_Opt, State_Chm, State_Diag, &
! Objects
TYPE(DgnMap), POINTER :: mapData

! Arrays
REAL(fp) :: TmpSpcArr(State_Grid%NX,State_Grid%NY, &
State_Grid%NZ,State_Chm%nSpecies)

!====================================================================
! Set_SpcConc_Diags_VVDry begins here!
!====================================================================

! Assume success
RC = GC_SUCCESS
Found = .FALSE.
ThisLoc = &
' -> at Set_SpcConc_Diags_VVDry (in GeosCore/diagnostics_mod.F90)'

! Verify that incoming State_Chm%Species units are kg/kg dry air.
IF ( .not. Check_Units( State_Chm, KG_SPECIES_PER_KG_DRY_AIR ) ) THEN
ErrMsg = 'Not all species are in "kg/kg dry" units!'
! Verify that incoming State_Chm%Species units are mol/mol dry air.
IF ( .not. Check_Units( State_Chm, MOLES_SPECIES_PER_MOLES_DRY_AIR ) ) THEN
ErrMsg = 'Not all species are in "mol/mol dry" units!'
CALL GC_Error( ErrMsg, RC, ThisLoc )
RETURN
ENDIF

! Store species in v/v dry as temporary variable if diagnostics on
IF ( State_Diag%Archive_SpeciesConcVV .or. &
State_Diag%Archive_SpeciesBC .or. &
State_Diag%Archive_SpeciesRst .or. &
State_Diag%Archive_ConcAboveSfc .or. &
State_Diag%Archive_SatDiagnConc ) THEN

!$OMP PARALLEL DO &
!$OMP DEFAULT( SHARED )&
!$OMP PRIVATE( I, J, L, N )&
!$OMP COLLAPSE( 4 )
DO N = 1, State_Chm%nSpecies
DO L = 1, State_Grid%NZ
DO J = 1, State_Grid%NY
DO I = 1, State_Grid%NX
TmpSpcArr(I,J,L,N) = State_Chm%Species(N)%Conc(I,J,L) * &
( AIRMW / State_Chm%SpcData(N)%Info%MW_g )
ENDDO
ENDDO
ENDDO
ENDDO
!$OMP END PARALLEL DO

ENDIF

!=======================================================================
! Copy species to SpeciesConc (concentrations diagnostic) [v/v dry]
!=======================================================================
Expand All @@ -691,7 +644,7 @@ SUBROUTINE Set_SpcConc_Diags_VVDry( Input_Opt, State_Chm, State_Diag, &
!$OMP PRIVATE( N, S )
DO S = 1, mapData%nSlots
N = mapData%slot2id(S)
State_Diag%SpeciesConcVV(:,:,:,S) = TmpSpcArr(:,:,:,N)
State_Diag%SpeciesConcVV(:,:,:,S) = State_Chm%Species(N)%Conc(:,:,:)
ENDDO
!$OMP END PARALLEL DO

Expand Down Expand Up @@ -724,7 +677,8 @@ SUBROUTINE Set_SpcConc_Diags_VVDry( Input_Opt, State_Chm, State_Diag, &
! Archie into SatDiagnConc diagnostic array
DO S = 1, State_Diag%Map_SatDiagnConc%nSlots
N = State_Diag%Map_SatDiagnConc%slot2id(S)
State_Diag%SatDiagnConc(I,:,:,S) = TmpSpcArr(I,:,:,N) * GOOD
State_Diag%SatDiagnConc(I,:,:,S) = &
State_Chm%Species(N)%Conc(I,:,:) * GOOD
ENDDO
ENDDO
!$OMP END PARALLEL DO
Expand All @@ -743,7 +697,7 @@ SUBROUTINE Set_SpcConc_Diags_VVDry( Input_Opt, State_Chm, State_Diag, &
!$OMP PRIVATE( N, S )
DO S = 1, mapData%nSlots
N = mapData%slot2id(S)
State_Diag%SpeciesBC(:,:,:,S) = TmpSpcArr(:,:,:,N)
State_Diag%SpeciesBC(:,:,:,S) = State_Chm%Species(N)%Conc(:,:,:)
ENDDO
!$OMP END PARALLEL DO

Expand All @@ -756,8 +710,14 @@ SUBROUTINE Set_SpcConc_Diags_VVDry( Input_Opt, State_Chm, State_Diag, &
! Copy species to SpeciesRst (restart file output) [v/v dry]
!=======================================================================
IF ( State_Diag%Archive_SpeciesRst ) THEN
State_Diag%SpeciesRst(:,:,:,:) = TmpSpcArr(:,:,:,:)
ENDIF
!$OMP PARALLEL DO &
!$OMP DEFAULT( SHARED ) &
!$OMP PRIVATE( N )
DO N = 1, State_Chm%nSpecies
State_Diag%SpeciesRst(:,:,:,N) = State_Chm%Species(N)%Conc(:,:,:)
ENDDO
!$OMP END PARALLEL DO
ENDIF

!=======================================================================
! Diagnostic for correcting species concentrations from the height
Expand Down Expand Up @@ -792,9 +752,9 @@ SUBROUTINE Set_SpcConc_Diags_VVDry( Input_Opt, State_Chm, State_Diag, &

! Loop over the number of drydep species that we wish
! to save at a user-specified altitude above the surface
!$OMP PARALLEL DO &
!$OMP DEFAULT( SHARED ) &
!$OMP PRIVATE( D, N, I, J, TmpVal, Conv )
!$OMP PARALLEL DO &
!$OMP DEFAULT( SHARED ) &
!$OMP PRIVATE( D, N, I, J, Conv )
DO D = 1, State_Chm%nDryAlt

! Get the corresponding species index and drydep index
Expand All @@ -804,9 +764,6 @@ SUBROUTINE Set_SpcConc_Diags_VVDry( Input_Opt, State_Chm, State_Diag, &
DO J = 1, State_Grid%NY
DO I = 1, State_Grid%NX

! Species concentration [v/v dry]
TmpVal = TmpSpcArr(I,J,1,N)

! Conversion factor used to translate from
! lowest model layer (~60m) to the surface
Conv = ( 1.0_fp &
Expand All @@ -818,7 +775,8 @@ SUBROUTINE Set_SpcConc_Diags_VVDry( Input_Opt, State_Chm, State_Diag, &

! Save concentration at the user-defined altitude
! as defined in geoschem_config.yml (usually 10m).
State_Diag%SpeciesConcALT1(I,J,D) = TmpVal * Conv
State_Diag%SpeciesConcALT1(I,J,D) = &
State_Chm%Species(N)%Conc(I,J,1) * Conv

ENDDO
ENDDO
Expand All @@ -838,7 +796,7 @@ END SUBROUTINE Set_SpcConc_Diags_VVDry
!
! !DESCRIPTION: Subroutine Set_SpcConc\_Diags\_MND sets several species
! concentration diagnostic arrays stored in State_Diag to the instantaneous
! State_Chm%Species values (in units of "v/v, dry air").
! State_Chm%Species values (in units of "molecules/cm3 air").
!\\
!\\
! !INTERFACE:
Expand Down
6 changes: 2 additions & 4 deletions GeosCore/get_ndep_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ MODULE GET_NDEP_MOD
!\\
! !INTERFACE:
!
SUBROUTINE SOIL_DRYDEP( I, J, L, NN, TDRYFX, State_Chm )
SUBROUTINE SOIL_DRYDEP( I, J, NN, TDRYFX, State_Chm )
!
! !USES:
!
Expand All @@ -87,7 +87,6 @@ SUBROUTINE SOIL_DRYDEP( I, J, L, NN, TDRYFX, State_Chm )
!
INTEGER, INTENT(IN) :: I ! I
INTEGER, INTENT(IN) :: J ! J
INTEGER, INTENT(IN) :: L ! Level
INTEGER, INTENT(IN) :: NN ! Dry Dep Tracer #
REAL(fp), INTENT(IN) :: TDRYFX ! Dry dep flux [molec/cm2/s]
!
Expand Down Expand Up @@ -126,7 +125,7 @@ END SUBROUTINE SOIL_DRYDEP
!\\
! !INTERFACE:
!
SUBROUTINE SOIL_WETDEP( I, J, L, NN, TWETFX, State_Chm )
SUBROUTINE SOIL_WETDEP( I, J, NN, TWETFX, State_Chm )
!
! !USES:
!
Expand All @@ -136,7 +135,6 @@ SUBROUTINE SOIL_WETDEP( I, J, L, NN, TWETFX, State_Chm )
!
INTEGER, INTENT(IN) :: I ! I
INTEGER, INTENT(IN) :: J ! J
INTEGER, INTENT(IN) :: L ! Level
INTEGER, INTENT(IN) :: NN ! Wet Dep Tracer #
REAL(fp), INTENT(IN) :: TWETFX ! Wet dep flux [kg/s]
!
Expand Down
Loading