Skip to content

Commit

Permalink
Merge pull request #13 from GEOS-ESM/feature/mmanyin/lat-lon_boundary…
Browse files Browse the repository at this point in the history
…_conditions

Add ExtData Boundary Conditions
  • Loading branch information
mmanyin authored Dec 19, 2023
2 parents 7e1b250 + 0e68e4b commit a585d3b
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
### Added

- Capability to use 2D ExtData files as Boundary Conditions

### Changed
### Removed
### Deprecated
Expand Down
4 changes: 2 additions & 2 deletions GMI_GridComp/GMI_ExtData.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Collections:

## Monthly values

GMI.CH4_surf_values.clim: { template: /gpfsm/dnb33/mmanyin/CCM/run/aug2_GMI/aug2_GMI.test_ch4.20500315_1200z.nc4 }
GMI.CH4_surf_values.monthly.2000-2009: { valid_range: "2000-01-16T12:00/2009-12-16T12:00", template: /discover/nobackup/mmanyin/CCM/CH4/qOHreplay2.CH4_at_surface.%y4%m2.nc4 }

GMI.CMIP6_BB.emis.monthly.1950-2015: { valid_range: "1950-01-16T00:00/2015-12-16T00:00", template: ExtData/CMIP6/sfc/biomass_burning/CMIP6_BB.emis.x1440_y720_t12.%y4.nc4 }
GMI.CMIP6_BB_SSP245.emis.monthly.2015-2100: { valid_range: "2015-01-16T00:00/2100-12-16T00:00", template: /discover/nobackup/projects/gmao/ccmdev/input/emissions/SSP/sfc/CMIP6_BB.ssp2_45.emis.x720_y360_t12.%y4.nc4 }
Expand Down Expand Up @@ -259,4 +259,4 @@ Exports:
du004: { variable: DU004, collection: GMI.aero_MERRA2.monthly_clim, regrid: CONSERVE, sample: GMI.daily_wrap }
du005: { variable: DU005, collection: GMI.aero_MERRA2.monthly_clim, regrid: CONSERVE, sample: GMI.daily_wrap }

CH4_BC: { variable: CH4, collection: GMI.CH4_surf_values.clim, regrid: CONSERVE, sample: GMI.constant }
CH4_BC: { variable: CH4, collection: GMI.CH4_surf_values.monthly.2000-2009, regrid: CONSERVE, sample: GMI.daily_wrap }
9 changes: 9 additions & 0 deletions GMI_GridComp/GmiChemistry/StratTrop_HFC_S/GMI_GridComp.rc
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,15 @@ xxx

# The xxx entries above are for SF6 and CO2

###########################################################
# GHG and ODS surface source gases - read with ExtData
###########################################################
ext_bc_kmin: 1
ext_bc_kmax: 2
extdataBcSpeciesNames::
#CH4
::


# ----------------------------------------------------
# sad_opt
Expand Down
9 changes: 9 additions & 0 deletions GMI_GridComp/GmiChemistry/StratTrop_Orig/GMI_GridComp.rc
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ xxx

# The xxx entries above are for HFC23 HFC32 HFC125 HFC134A HFC143A HFC152A SF6 and CO2

###########################################################
# GHG and ODS surface source gases - read with ExtData
###########################################################
ext_bc_kmin: 1
ext_bc_kmax: 2
extdataBcSpeciesNames::
#CH4
::


# ----------------------------------------------------
# sad_opt
Expand Down
90 changes: 79 additions & 11 deletions GMI_GridComp/GmiForcingBC_GridCompClassMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ MODULE GmiForcingBC_GCCMod

USE ESMF
USE MAPL
USE Chem_Mod ! Chemistry Base Class
USE Chem_Mod ! Chemistry Base Class
USE Chem_UtilMod

USE Species_BundleMod
Expand Down Expand Up @@ -86,9 +86,13 @@ MODULE GmiForcingBC_GCCMod
integer :: forc_bc_years
integer :: forc_bc_start_num
integer :: forc_bc_kmin
integer :: ext_bc_kmin
integer :: forc_bc_kmax
integer :: ext_bc_kmax
integer :: forc_bc_num
integer :: ext_bc_count
integer :: forc_bc_map (MAX_NUM_CONST)
integer :: ext_bc_map (MAX_NUM_CONST)
real*8 :: forc_bc_init_val
real*8 :: forc_bc_incrpyr
real*8 :: forc_bc_lz_val
Expand Down Expand Up @@ -189,7 +193,8 @@ SUBROUTINE GmiForcingBC_GridCompInitialize( self, bgg, bxx, impChem, expChem, ny
CHARACTER(LEN=255) :: importRestartFile
CHARACTER(LEN=255) :: string
character (len=MAX_LENGTH_SPECIES_NAME), pointer :: tempListNames(:)
character (len=MAX_STRING_LENGTH ) :: forcedBcSpeciesNames
character (len=MAX_STRING_LENGTH ) :: forcedBcSpeciesNames
character (len=MAX_STRING_LENGTH ) :: extdataBcSpeciesNames

type (ESMF_Config) :: gmiConfigFile

Expand Down Expand Up @@ -326,15 +331,31 @@ SUBROUTINE GmiForcingBC_GridCompInitialize( self, bgg, bxx, impChem, expChem, ny
& default = 1, rc=STATUS )
VERIFY_(STATUS)

call ESMF_ConfigGetAttribute(gmiConfigFile, self%ext_bc_kmin, &
& label = "ext_bc_kmin:", &
& default = 1, rc=STATUS )
VERIFY_(STATUS)

call ESMF_ConfigGetAttribute(gmiConfigFile, self%forc_bc_kmax, &
& label = "forc_bc_kmax:", &
& default = 1, rc=STATUS )
VERIFY_(STATUS)

call ESMF_ConfigGetAttribute(gmiConfigFile, self%ext_bc_kmax, &
& label = "ext_bc_kmax:", &
& default = 1, rc=STATUS )
VERIFY_(STATUS)

self%forc_bc_map(:) = 0
self%ext_bc_map(:) = 0

call rcEsmfReadTable(gmiConfigFile, forcedBcSpeciesNames, &
& "forcedBcSpeciesNames::", rc=STATUS)
VERIFY_(STATUS)

call rcEsmfReadTable(gmiConfigFile, extdataBcSpeciesNames, &
& "extdataBcSpeciesNames::", rc=STATUS)
VERIFY_(STATUS)

call ESMF_ConfigGetAttribute(gmiConfigFile, self%forc_bc_init_val, &
& label = "forc_bc_init_val:", &
Expand Down Expand Up @@ -371,7 +392,7 @@ SUBROUTINE GmiForcingBC_GridCompInitialize( self, bgg, bxx, impChem, expChem, ny

IF (rootProc) THEN
PRINT *," "
PRINT *,"Number of GHG and ODP gases: ",self%forc_bc_num
PRINT *,"Number of ASCII GHG and ODP gases: ",self%forc_bc_num
PRINT *," "
PRINT *,"forc_bc_map:"
PRINT *, self%forc_bc_map
Expand All @@ -380,6 +401,34 @@ SUBROUTINE GmiForcingBC_GridCompInitialize( self, bgg, bxx, impChem, expChem, ny

end if


!! Now do ExtData (ext) same as ASCII (forc):

! Set the initial value of the list
! allocate(tempListNames(NSP)) already done above
tempListNames(:) = ''

! Construct the list of names using the long string
call constructListNames(tempListNames, extdataBcSpeciesNames)


self%ext_bc_count = Count (tempListNames(:) /= '')
if (self%ext_bc_count > 0) then
do ic = 1, self%ext_bc_count
self%ext_bc_map(ic) = getSpeciesIndex(tempListNames(ic))
end do

IF (rootProc) THEN
PRINT *," "
PRINT *,"Number of ExtData GHG and ODP gases: ",self%ext_bc_count
PRINT *," "
PRINT *,"ext_bc_map:"
PRINT *, self%ext_bc_map
PRINT *," "
END IF

end if

deallocate(tempListNames)

! Does the GMICHEM import restart file exist? If not,
Expand Down Expand Up @@ -637,6 +686,8 @@ SUBROUTINE GmiForcingBC_GridCompRun ( self, bgg, bxx, impChem, expChem, nymd, nh
CHARACTER(LEN=255) :: speciesName
CHARACTER(LEN=255) :: importName

REAL, POINTER, DIMENSION(:,:) :: PTR2D

LOGICAL :: found, rootProc
LOGICAL, PARAMETER :: doThis = .FALSE.

Expand Down Expand Up @@ -734,16 +785,33 @@ SUBROUTINE GmiForcingBC_GridCompRun ( self, bgg, bxx, impChem, expChem, nymd, nh
! ------------------------------------------------------------------------

IF (self%gotImportRst) then

! ASCII
if (self%forc_bc_num > 0) then
call updateForcingBC (self%forc_bc_data, &
self%SpeciesConcentration%concentration, self%jlatmd, &
& self%last_year, nymd, gmi_sec, self%fbc_j1, self%fbc_j2, &
& self%forc_bc_num, self%forc_bc_kmax, self%forc_bc_kmin, &
& self%forc_bc_opt, self%forc_bc_map, self%forc_bc_incrpyr, &
& self%forc_bc_start_num, self%forc_bc_years, self%gmiGrid%i1, &
& self%gmiGrid%i2, self%gmiGrid%ju1, self%gmiGrid%j2, &
& self%gmiGrid%k1, self%gmiGrid%k2, NSP)
call updateForcingBC (self%forc_bc_data, &
self%SpeciesConcentration%concentration, self%jlatmd, &
self%last_year, nymd, gmi_sec, self%fbc_j1, self%fbc_j2, &
self%forc_bc_num, self%forc_bc_kmax, self%forc_bc_kmin, &
self%forc_bc_opt, self%forc_bc_map, self%forc_bc_incrpyr, &
self%forc_bc_start_num, self%forc_bc_years, self%gmiGrid%i1, &
self%gmiGrid%i2, self%gmiGrid%ju1, self%gmiGrid%j2, &
self%gmiGrid%k1, self%gmiGrid%k2, NSP)
end if

! ExtData
if (self%ext_bc_count > 0) then
DO ic = 1,self%ext_bc_count
speciesName = TRIM(lchemvar(self%ext_bc_map(ic)))
importName = TRIM(speciesName)//'_BC'
CALL MAPL_GetPointer(impChem, PTR2D, TRIM(importName), RC=STATUS)
VERIFY_(STATUS)

do k = self%ext_bc_kmin,self%ext_bc_kmax
self%SpeciesConcentration%concentration(self%ext_bc_map(ic))%pArray3D(:,:,k) = PTR2D(:,:)
end do
end do
end if

END IF

! Return species concentrations to the chemistry bundle
Expand Down
33 changes: 32 additions & 1 deletion GMIchem_GridCompMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ MODULE GMIchem_GridCompMod
USE MAPL
USE Runtime_RegistryMod
USE Species_BundleMod
USE Chem_Mod ! Chemistry Base Class
USE Chem_Mod ! Chemistry Base Class
USE GMI_GridCompMod ! ESMF parent component
USE Chem_UtilMod, ONLY : Chem_UtilNegFiller ! Eliminates negative vmr
USE Chem_GroupMod ! For Family Transport
USE OVP, ONLY: OVP_init, OVP_end_of_timestep_hms, OVP_mask, OVP_apply_mask
USE GmiESMFrcFileReading_mod, ONLY : rcEsmfReadTable
USE GmiStringManipulation_mod, ONLY : constructListNames

IMPLICIT NONE
PRIVATE
Expand All @@ -35,6 +37,10 @@ MODULE GMIchem_GridCompMod
INTEGER, SAVE :: OVP_GC_DT
INTEGER, SAVE :: OVP_MASK_DT

#include "setkin_par.h"
#include "GmiParameters.h"


!
! !PUBLIC MEMBER FUNCTIONS:
!
Expand Down Expand Up @@ -150,6 +156,10 @@ SUBROUTINE SetServices ( GC, RC )
TYPE (ESMF_Config) :: gmi_config
LOGICAL :: doMEGANviaHEMCO

CHARACTER (LEN=MAX_STRING_LENGTH) :: extdataBcSpeciesNames
CHARACTER (LEN=MAX_LENGTH_SPECIES_NAME), pointer :: tempListNames(:)
INTEGER :: bc_count, ic

! Get my name and set-up traceback handle
! ---------------------------------------
call ESMF_GridCompGet( GC, NAME=COMP_NAME, CONFIG=CF, RC=STATUS )
Expand Down Expand Up @@ -343,6 +353,27 @@ SUBROUTINE SetServices ( GC, RC )

call ESMF_ConfigLoadFile(gmiConfig, 'GMI_GridComp.rc', __RC__)

! This duplicates the call in the Forced BC code; really should only be done once!
call rcEsmfReadTable(gmiConfig, extdataBcSpeciesNames, "extdataBcSpeciesNames::", __RC__)

! Set the initial value of the list
allocate(tempListNames(NSP))
tempListNames(:) = ''

call constructListNames(tempListNames, extdataBcSpeciesNames)

bc_count = COUNT (tempListNames(:) /= '')
do ic = 1, bc_count
call MAPL_AddImportSpec(GC, &
SHORT_NAME = TRIM(tempListNames(ic))//'_BC', &
LONG_NAME = 'Surface BC for '//TRIM(tempListNames(ic)), &
UNITS = 'mol mol-1', &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)
end do

deallocate(tempListNames)

! This duplicates the call in the Emissions code; really should only be done once!
! call rcEsmfReadLogical(gmiConfig, do_ShipEmission, "do_ShipEmission:", default=.false., __RC__)
CALL ESMF_ConfigGetAttribute(gmiConfig, value= do_ShipEmission, Default=.false., &
Expand Down

0 comments on commit a585d3b

Please sign in to comment.