Skip to content

Commit

Permalink
Merge branch 'dev/no-diff-to-benchmark' into adjoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lizziel committed Nov 21, 2024
2 parents 0d115ba + 7507eb5 commit f2a908f
Show file tree
Hide file tree
Showing 22 changed files with 619 additions and 427 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ This file documents all notable changes to the GEOS-Chem repository starting in

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased] - TBD
### Added
- Added allocate guards for arrays in `pressure_mod`
- Added `State_Diag%SatDiagnEdgeCount` counter for the `SatDiagnEdge` collection
- Added `State_Diag%Archive_SatDiagnEdgeCount` field
- Added `State_Diag%Archive_SatDiagnEdge` field
- Added routine `SatDiagn_or_SatDiagnEdge` in `History/history_utils_mod.F90`

### Changed
- Renamed `Emiss_Carbon_Gases` to `CO2_Production` in `carbon_gases_mod.F90`
- Updated start date and restart file for CO2 and tagCO simulations for consistency with carbon simulations
- Allocated `State_Diag%SatDiagnPEDGE` ffield with vertical dimension `State_Grid%NZ+1`

### Fixed
- Added a fix to skip the call to KPP when only CO2 is defined in the carbon simulation
- Added fix to turn on ship emissions for CO2 in the carbon simulation
- Updated `HEMCO_Config.rc` for carbon simulation to read data based on carbon species used
- Fixed entries for CO2 emissions in `ExtData.rc.carbon`
- Fixed metals simulation name in config file template comments
- Fixed bug in `download_data.py` which caused script to fail if log filename contained uppercase characters.
- Fixed the satellite diagnostics counters from being inadvertently being reset
- Fixed segmentation fault in qfyaml when running with certain compilers without debug flags on

### Removed
- Removed duplicate `WD_RetFactor` tag for HgClHO2 in `species_database.yml`

## [14.5.0] - 2024-11-07
### Added
- Added vectors `State_Chm%KPP_AbsTol` and `State_Chm%KPP_RelTol`
Expand Down
630 changes: 328 additions & 302 deletions GeosCore/carbon_gases_mod.F90

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions GeosCore/diagnostics_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1474,13 +1474,18 @@ SUBROUTINE Do_Archive_SatDiagn( Input_Opt, State_Chm, State_Diag, &
locTime <= State_Diag%SatDiagn_EndHr ) good = 1.0_fp

!---------------------------------------------------------------------
! SatDiagnCount: Count number of local times
! SatDiagnCount and SatDiagnEdgeCount: Count number of local times
!---------------------------------------------------------------------
IF ( State_Diag%Archive_SatDiagnCount ) THEN
State_Diag%SatDiagnCount(I,:,:) = &
State_Diag%SatDiagnCount(I,:,:) + good
ENDIF

IF ( State_Diag%Archive_SatDiagnEdgeCount ) THEN
State_Diag%SatDiagnEdgeCount(I,:,:) = &
State_Diag%SatDiagnEdgeCount(I,:,:) + good
ENDIF

!---------------------------------------------------------------------
! SatDiagnOH: OH concentration [molec/cm3]:
!---------------------------------------------------------------------
Expand Down Expand Up @@ -1518,8 +1523,7 @@ SUBROUTINE Do_Archive_SatDiagn( Input_Opt, State_Chm, State_Diag, &
! Pressure edges [hPa]:
!---------------------------------------------------------------------
IF ( State_Diag%Archive_SatDiagnPEdge ) THEN
State_Diag%SatDiagnPEdge(I,:,:) = &
State_Met%PEDGE(I,:,1:State_Grid%NZ) * good
State_Diag%SatDiagnPEdge(I,:,:) = State_Met%PEDGE(I,:,:) * good
ENDIF

!---------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions GeosCore/emissions_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ SUBROUTINE Emissions_Run( Input_Opt, State_Chm, State_Diag, State_Grid, &
! !USES:
!
USE CARBON_MOD, ONLY : EmissCarbon
USE Carbon_Gases_Mod, ONLY : Emiss_Carbon_Gases
USE Carbon_Gases_Mod, ONLY : CO2_Production
USE CO2_MOD, ONLY : EmissCO2
USE ErrCode_Mod
USE HCO_Interface_GC_Mod, ONLY : HCOI_GC_Run
Expand Down Expand Up @@ -264,8 +264,8 @@ SUBROUTINE Emissions_Run( Input_Opt, State_Chm, State_Diag, State_Grid, &
!
! Computes CO2 production from CO oxidation
IF ( Input_Opt%ITS_A_CARBON_SIM ) THEN
CALL Emiss_Carbon_Gases( Input_Opt, State_Chm, State_Diag, &
State_Grid, State_Met, RC )
CALL CO2_Production( Input_Opt, State_Chm, State_Diag, &
State_Grid, State_Met, RC )

! Trap potential errors
IF ( RC /= GC_SUCCESS ) THEN
Expand Down
6 changes: 3 additions & 3 deletions GeosCore/input_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ SUBROUTINE Config_CO( Config, Input_Opt, RC )
! Initialize
RC = GC_SUCCESS
errMsg = ''
thisLoc = ' -> at Config_CO2 (in module GeosCore/input_mod.F90)'
thisLoc = ' -> at Config_CO (in module GeosCore/input_mod.F90)'

!------------------------------------------------------------------------
! Use P(CO) from CH4 (archived from a fullchem simulation)?
Expand Down Expand Up @@ -2046,7 +2046,7 @@ SUBROUTINE Config_CO( Config, Input_Opt, RC )
!========================================================================
! Print to screen
!========================================================================
IF ( Input_Opt%ITS_A_TAGCO_SIM .and. Input_Opt%amIRoot ) THEN
IF ( Input_Opt%amIRoot ) THEN
WRITE(6,90 ) 'TAGGED CO SIMULATION SETTINGS'
WRITE(6,95 ) '(overwrites any other settings related to CO)'
WRITE(6,95 ) '---------------------------------------------'
Expand Down Expand Up @@ -2154,7 +2154,7 @@ SUBROUTINE Config_CO2( Config, Input_Opt, RC )
!=================================================================
! Print to screen
!=================================================================
IF ( Input_Opt%ITS_A_CO2_SIM .and. Input_Opt%amIRoot ) THEN
IF ( Input_Opt%amIRoot ) THEN
WRITE( 6,90 ) 'CO2 SIMULATION SETTINGS'
WRITE( 6,95 ) '(overwrites any other settings related to CO2)'
WRITE( 6,95 ) '----------------------------------------------'
Expand Down
83 changes: 49 additions & 34 deletions GeosUtil/pressure_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -517,42 +517,57 @@ SUBROUTINE INIT_PRESSURE( Input_Opt, State_Grid, RC )
RC = GC_SUCCESS
ThisLoc = ' -> at Init_Pressure (in GeosUtil/pressure_mod.F90)'

ALLOCATE( PFLT_DRY( State_Grid%NX, State_Grid%NY ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:PFLT_DRY', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
PFLT_DRY = 0e+0_fp

ALLOCATE( PFLT_WET( State_Grid%NX, State_Grid%NY ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:PFLT_WET', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
PFLT_WET = 0e+0_fp

ALLOCATE( AP( State_Grid%NZ+1 ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:AP', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
AP = 1e+0_fp

ALLOCATE( BP( State_Grid%NZ+1 ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:BP', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
BP = 0e+0_fp

ALLOCATE( AP_FULLGRID( State_Grid%NativeNZ+1 ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:AP_FULLGRID', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
AP = 1e+0_fp

ALLOCATE( BP_FULLGRID( State_Grid%NativeNZ+1 ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:BP_FULLGRID', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
BP = 0e+0_fp
IF (.NOT. ALLOCATED( PFLT_DRY )) THEN
ALLOCATE( PFLT_DRY( State_Grid%NX, State_Grid%NY ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:PFLT_DRY', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
PFLT_DRY = 0e+0_fp
END IF

IF (.NOT. ALLOCATED( PFLT_WET )) THEN
ALLOCATE( PFLT_WET( State_Grid%NX, State_Grid%NY ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:PFLT_WET', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
PFLT_WET = 0e+0_fp
END IF

IF (.NOT. ALLOCATED( AP )) THEN
ALLOCATE( AP( State_Grid%NZ+1 ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:AP', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
AP = 1e+0_fp
END IF

IF (.NOT. ALLOCATED( BP )) THEN
ALLOCATE( BP( State_Grid%NZ+1 ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:BP', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
BP = 0e+0_fp
END IF

IF (.NOT. ALLOCATED( AP_FULLGRID )) THEN
ALLOCATE( AP_FULLGRID( State_Grid%NativeNZ+1 ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:AP_FULLGRID', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
AP = 1e+0_fp
END IF

IF (.NOT. ALLOCATED( BP_FULLGRID )) THEN
ALLOCATE( BP_FULLGRID( State_Grid%NativeNZ+1 ), STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:BP_FULLGRID', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
BP = 0e+0_fp
END IF

#if defined( ESMF_ ) || defined( MODEL_ )
ALLOCATE( EXTERNAL_PEDGE( State_Grid%NX, State_Grid%NY, State_Grid%NZ+1 ), &
STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:EXTERNAL_PEDGE', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
EXTERNAL_PEDGE = 0e+0_fp
IF (.NOT. ALLOCATED( EXTERNAL_PEDGE )) THEN
ALLOCATE( EXTERNAL_PEDGE( State_Grid%NX, State_Grid%NY, &
State_Grid%NZ+1 ), &
STAT=RC )
CALL GC_CheckVar( 'vdiff_mod.F90:EXTERNAL_PEDGE', 2, RC )
IF ( RC /= GC_SUCCESS ) RETURN
EXTERNAL_PEDGE = 0e+0_fp
END IF
#endif

IF ( State_Grid%NZ == 47 ) THEN
Expand Down
3 changes: 2 additions & 1 deletion Headers/qfyaml_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,8 @@ SUBROUTINE Partition_Var_List(list, marker)

! Take the middle element as pivot
pivot_ix = SIZE( list ) / 2
pivot_value = list(pivot_ix)%var_name
temp = list(pivot_ix)
pivot_value = temp%var_name

DO WHILE ( left < right )

Expand Down
61 changes: 49 additions & 12 deletions Headers/state_diag_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ MODULE State_Diag_Mod
TYPE(DgnMap), POINTER :: Map_SatDiagnDryDep
LOGICAL :: Archive_SatDiagnDryDep
LOGICAL :: Archive_SatDiagn
LOGICAL :: Archive_SatDiagnEdge

REAL(f4), POINTER :: SatDiagnDryDepVel(:,:,:)
TYPE(DgnMap), POINTER :: Map_SatDiagnDryDepVel
Expand Down Expand Up @@ -914,6 +915,9 @@ MODULE State_Diag_Mod

REAL(f8), POINTER :: SatDiagnCount(:,:,:)
LOGICAL :: Archive_SatDiagnCount

REAL(f8), POINTER :: SatDiagnEdgeCount(:,:,:)
LOGICAL :: Archive_SatDiagnEdgeCount

REAL(f8), POINTER :: SatDiagnConc(:,:,:,:)
TYPE(DgnMap), POINTER :: Map_SatDiagnConc
Expand Down Expand Up @@ -2381,6 +2385,9 @@ SUBROUTINE Zero_State_Diag( State_Diag, RC )

State_Diag%SatDiagnCount => NULL()
State_Diag%Archive_SatDiagnCount = .FALSE.

State_Diag%SatDiagnEdgeCount => NULL()
State_Diag%Archive_SatDiagnEdgeCount = .FALSE.

State_Diag%SatDiagnConc => NULL()
State_Diag%Map_SatDiagnConc => NULL()
Expand Down Expand Up @@ -5208,7 +5215,7 @@ SUBROUTINE Init_State_Diag( Input_Opt, State_Chm, State_Grid, &
ENDIF

!------------------------------------------------------------------------
! Set a single logical for SatDiagn output
! Set logicals for SatDiagn and/or SatDiagnEdge output
! For ease of comparison, place fields in alphabetical order
!------------------------------------------------------------------------
State_Diag%Archive_SatDiagn = ( &
Expand All @@ -5218,7 +5225,6 @@ SUBROUTINE Init_State_Diag( Input_Opt, State_Chm, State_Grid, &
State_Diag%Archive_SatDiagnConc .or. &
State_Diag%Archive_SatDiagnDryDep .or. &
State_Diag%Archive_SatDiagnDryDepVel .or. &
State_Diag%Archive_SatDiagnPEdge .or. &
State_Diag%Archive_SatDiagnTROPP .or. &
State_Diag%Archive_SatDiagnTropLev .or. &
State_Diag%Archive_SatDiagnPBLHeight .or. &
Expand All @@ -5238,7 +5244,6 @@ SUBROUTINE Init_State_Diag( Input_Opt, State_Chm, State_Grid, &
State_Diag%Archive_SatDiagnPBLHeight .or. &
State_Diag%Archive_SatDiagnPBLTop .or. &
State_Diag%Archive_SatDiagnPBLTopL .or. &
State_Diag%Archive_SatDiagnPEdge .or. &
State_Diag%Archive_SatDiagnPRECTOT .or. &
State_Diag%Archive_SatDiagnProd .or. &
State_Diag%Archive_SatDiagnRH .or. &
Expand All @@ -5252,21 +5257,32 @@ SUBROUTINE Init_State_Diag( Input_Opt, State_Chm, State_Grid, &
State_Diag%Archive_SatDiagnWetLossLS .or. &
State_Diag%Archive_SatDiagnWetLossConv )

State_Diag%Archive_SatDiagnEdge = ( &
State_Diag%Archive_SatDiagnPEdge )

!------------------------------------------------------------------------
! Satellite diagnostic: Counter
! Satellite diagnostic: Counters
!------------------------------------------------------------------------
IF ( State_Diag%Archive_SatDiagn ) THEN

! Array to contain the satellite diagnostic weights
ALLOCATE( State_Diag%SatDiagnCount( State_Grid%NX, &
State_Grid%NY, &
State_Grid%NZ ), STAT=RC )
CALL GC_CheckVar( 'State_Diag%DiagnCount', 0, RC )
CALL GC_CheckVar( 'State_Diag%SatDiagnCount', 0, RC )
IF ( RC /= GC_SUCCESS ) RETURN
State_Diag%SatDiagnCount = 0.0_f4
State_Diag%Archive_SatDiagnCount = .TRUE.
ENDIF

IF ( State_Diag%Archive_SatDiagnEdge ) THEN
ALLOCATE( State_Diag%SatDiagnEdgeCount( State_Grid%NX, &
State_Grid%NY, &
State_Grid%NZ+1 ), STAT=RC )
CALL GC_CheckVar( 'State_Diag%SatDiagnEdgeCount', 0, RC )
IF ( RC /= GC_SUCCESS ) RETURN
State_Diag%SatDiagnEdgeCount = 0.0_f4
State_Diag%Archive_SatDiagnEdgeCount = .TRUE.
ENDIF

!=======================================================================
! The following diagnostic quantities are only relevant for:
!
Expand Down Expand Up @@ -12985,6 +13001,16 @@ SUBROUTINE Cleanup_State_Diag( State_Diag, RC )
! State_Diag%WashFracLS => NULL()
! ENDIF

CALL Finalize( diagId = 'SatDiagnCount', &
Ptr2Data = State_Diag%SatDiagnCount, &
RC = RC )
IF ( RC /= GC_SUCCESS ) RETURN

CALL Finalize( diagId = 'SatDiagnEdgeCount', &
Ptr2Data = State_Diag%SatDiagnEdgeCount, &
RC = RC )
IF ( RC /= GC_SUCCESS ) RETURN

CALL Finalize( diagId = 'SatDiagnConc', &
Ptr2Data = State_Diag%SatDiagnConc, &
mapData = State_Diag%Map_SatDiagnConc, &
Expand Down Expand Up @@ -15178,7 +15204,7 @@ SUBROUTINE Get_Metadata_State_Diag( am_I_Root, metadataID, Found, &
IF ( isDesc ) Desc = 'Pressure edges'
IF ( isUnits ) Units = 'hPa'
IF ( isRank ) Rank = 3
!IF ( isVLoc ) VLoc = VLocationEdge
IF ( isVLoc ) VLoc = VLocationEdge

ELSE IF ( TRIM( Name_AllCaps ) == 'SATDIAGNTROPP' ) THEN
IF ( isDesc ) Desc = 'Tropopause pressure'
Expand Down Expand Up @@ -20104,9 +20130,10 @@ SUBROUTINE Init_and_Register_R8_3D( Input_Opt, State_Chm, &
!
! !USES:
!
USE Input_Opt_Mod, ONLY : OptInput
USE State_Chm_Mod, ONLY : ChmState
USE State_Grid_Mod, ONLY : GrdState
USE Input_Opt_Mod, ONLY : OptInput
USE State_Chm_Mod, ONLY : ChmState
USE State_Grid_Mod, ONLY : GrdState
USE Registry_Params_Mod, ONLY : VLocationEdge
!
! !INPUT PARAMETERS:
!
Expand Down Expand Up @@ -20142,7 +20169,7 @@ SUBROUTINE Init_and_Register_R8_3D( Input_Opt, State_Chm, &
! Scalars
LOGICAL :: alwaysDefine, found
INTEGER :: NX, NY, NZ
INTEGER :: NW, numSlots
INTEGER :: NW, numSlots, vLoc

! Strings
CHARACTER(LEN=1) :: indFlag
Expand All @@ -20159,6 +20186,7 @@ SUBROUTINE Init_and_Register_R8_3D( Input_Opt, State_Chm, &
RC = GC_SUCCESS
numSlots = -1
found = .FALSE.
vLoc = .FALSE.
arrayID = 'State_Diag%' // TRIM( diagId )
errMsg = ''
thisLoc = &
Expand Down Expand Up @@ -20225,6 +20253,15 @@ SUBROUTINE Init_and_Register_R8_3D( Input_Opt, State_Chm, &
NY = State_Grid%NY
NZ = State_Grid%NZ

! Determine if the array is defined on level edges
! NOTE: This is only needed for the SatDiagnPEDGE field
CALL Get_Metadata_State_Diag( am_I_Root = Input_Opt%amIRoot, &
metadataId = diagId, &
found = found, &
vLoc = vLoc, &
RC = RC )
IF ( vLoc == vLocationEdge ) NZ = NZ + 1

! Allocate array
IF ( numSlots > 0 ) THEN
ALLOCATE( Ptr2Data( NX, NY, numSlots ), STAT=RC )
Expand Down
Loading

0 comments on commit f2a908f

Please sign in to comment.