Skip to content

Commit

Permalink
Merge PR #2532 (Add allocate guards in pressure_mod )
Browse files Browse the repository at this point in the history
This merge brings PR #2532 (Add allocate guards for
arrays in pressure_mod, by @jwallwork) into the GEOS-Chem
"no-diff-to-benchmark" development stream.

This PR adds checks to make sure that we do not allocate
arrays that have already been allocated.

Signed-off-by: Bob Yantosca <[email protected]>
  • Loading branch information
yantosca committed Nov 20, 2024
2 parents af83cf8 + a02905c commit 67ce84a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 34 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ 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`

### 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
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

0 comments on commit 67ce84a

Please sign in to comment.