Skip to content

Commit

Permalink
Bug fix: Now correctly check History diagnostic subset indices
Browse files Browse the repository at this point in the history
Interfaces/GCClassic/main.F90:
- Pass State_Grid to routine History_Init

History/history_mod.F90:
- History_Init now accepts the State_Grid object and passes it to
  routine History_ReadCollectionData
- History_ReadCollectionData accepts the State_Grid object.
- State_Grid%NX and State_Grid%NY are used to error-check the
  values of CollectionSubsetInd(:,C) for each collection C.  For
  lon we ensure that indices are within 1 < index < State_Grid%NX,
  and for lat we ensure that indices are within 1 < index < State_Grid%NY.

NOTE: These updates only affect GEOS-Chem Classic History diagnostics.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
  • Loading branch information
yantosca committed Dec 6, 2021
1 parent 0648444 commit 9ab6931
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
27 changes: 16 additions & 11 deletions History/history_mod.F90
Expand Up @@ -104,7 +104,8 @@ MODULE History_Mod
!\\
! !INTERFACE:
!
SUBROUTINE History_Init( Input_Opt, State_Met, State_Chm, State_Diag, RC )
SUBROUTINE History_Init( Input_Opt, State_Met, State_Chm, &
State_Diag, State_Grid, RC )
!
! !USES:
!
Expand All @@ -113,13 +114,15 @@ SUBROUTINE History_Init( Input_Opt, State_Met, State_Chm, State_Diag, RC )
USE Input_Opt_Mod, ONLY : OptInput
USE State_Chm_Mod , ONLY : ChmState
USE State_Diag_Mod, ONLY : DgnState
USE State_Grid_Mod, ONLY : GrdState
USE State_Met_Mod, ONLY : MetState
!
! !INPUT PARAMETERS:
!
TYPE(OptInput), INTENT(IN) :: Input_Opt
TYPE(ChmState), INTENT(IN) :: State_Chm
TYPE(DgnState), INTENT(IN) :: State_Diag
TYPE(GrdState), INTENT(IN) :: State_Grid
TYPE(MetState), INTENT(IN) :: State_Met
!
! !OUTPUT PARAMETERS:
Expand Down Expand Up @@ -170,8 +173,8 @@ SUBROUTINE History_Init( Input_Opt, State_Met, State_Chm, State_Diag, RC )
! Then determine the fields that will be saved to each collection
! NOTE: For dry-run, enter to print out file name & status
!=======================================================================
CALL History_ReadCollectionData( Input_Opt, State_Chm, &
State_Diag, State_Met, RC )
CALL History_ReadCollectionData( Input_Opt, State_Chm, State_Diag, &
State_Grid, State_Met, RC )

! Trap potential errors
IF ( RC /= GC_SUCCESS ) THEN
Expand All @@ -196,8 +199,8 @@ END SUBROUTINE History_Init
!\\
! !INTERFACE:
!
SUBROUTINE History_ReadCollectionNames( Input_Opt, State_Chm, &
State_Diag, State_Met, RC )
SUBROUTINE History_ReadCollectionNames( Input_Opt, State_Chm, &
State_Diag, State_Met, RC )
!
! !USES:
!
Expand Down Expand Up @@ -469,8 +472,8 @@ END SUBROUTINE History_ReadCollectionNames
!\\
! !INTERFACE:
!
SUBROUTINE History_ReadCollectionData( Input_Opt, State_Chm, &
State_Diag, State_Met, RC )
SUBROUTINE History_ReadCollectionData( Input_Opt, State_Chm, State_Diag, &
State_Grid, State_Met, RC )
!
! !USES:
!
Expand All @@ -488,13 +491,15 @@ SUBROUTINE History_ReadCollectionData( Input_Opt, State_Chm, &
USE Species_Mod, ONLY : Species
USE State_Chm_Mod
USE State_Diag_Mod
USE State_Grid_Mod, ONLY : GrdState
USE State_Met_Mod
!
! !INPUT PARAMETERS:
!
TYPE(OptInput), INTENT(IN) :: Input_Opt ! Input Options object
TYPE(ChmState), INTENT(IN) :: State_Chm ! Chemistry State object
TYPE(DgnState), INTENT(IN) :: State_Diag ! Diagnostic State object
TYPE(GrdState), INTENT(IN) :: State_Grid ! Grid State Object object
TYPE(MetState), INTENT(IN) :: State_Met ! Meteorology State object
!
! !OUTPUT PARAMETERS:
Expand Down Expand Up @@ -1010,8 +1015,8 @@ SUBROUTINE History_ReadCollectionData( Input_Opt, State_Chm, &

! Error check longitudes
DO N = 1, 2
IF ( CollectionSubsetInd(N,C) < -180.0_f8 .or. &
CollectionSubsetInd(N,C) > 180.0_f8 ) THEN
IF ( CollectionSubsetInd(N,C) < 1 .or. &
CollectionSubsetInd(N,C) > State_Grid%NX ) THEN
ErrMsg = 'Invalid longitude subset values for ' // &
'collection "'// TRIM(CollectionName(C)) // '"!'
WRITE( ErrorLine, 250 ) LineNum
Expand Down Expand Up @@ -1063,8 +1068,8 @@ SUBROUTINE History_ReadCollectionData( Input_Opt, State_Chm, &

! Error check latitudes
DO N = 3, 4
IF ( CollectionSubsetInd(N,C) < -90.0_f8 .or. &
CollectionSubsetInd(N,C) > 90.0_f8 ) THEN
IF ( CollectionSubsetInd(N,C) < 1 .or. &
CollectionSubsetInd(N,C) > State_Grid%NY ) THEN
ErrMsg = 'Invalid latitude subset values for ' // &
'collection " '// TRIM(CollectionName(C)) // '"!'
WRITE( ErrorLine, 250 ) LineNum
Expand Down
3 changes: 2 additions & 1 deletion Interfaces/GCClassic/main.F90
Expand Up @@ -699,7 +699,8 @@ PROGRAM GEOS_Chem

! Initialize the GEOS-Chem history component
! (for dry-run, enter routine to print out HISTORY.rc status)
CALL History_Init( Input_Opt, State_Met, State_Chm, State_Diag, RC )
CALL History_Init( Input_Opt, State_Met, State_Chm, &
State_Diag, State_Grid, RC )

! Trap error
IF ( RC /= GC_SUCCESS ) THEN
Expand Down

0 comments on commit 9ab6931

Please sign in to comment.