Skip to content

Commit

Permalink
Improved options handling for cache
Browse files Browse the repository at this point in the history
  • Loading branch information
MircoValentiniECMWF committed Nov 17, 2024
1 parent 0a06079 commit 5a082a7
Show file tree
Hide file tree
Showing 24 changed files with 2,216 additions and 1,137 deletions.
104 changes: 52 additions & 52 deletions src/multiom/data-structures/fortran_message_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,9 @@ END FUNCTION FORTRAN_MESSAGE_COPY_DATA_FROM
FUNCTION FORTRAN_MESSAGE_SWAP_DATA( THIS, OTHER, OPT, HOOKS ) RESULT(RET)

!> Symbols imported from other modules within the project.
USE :: DATAKINDS_DEF_MOD, ONLY: JPIB_K
USE :: HOOKS_MOD, ONLY: HOOKS_T
USE :: GRIB_ENCODER_OPTIONS_MOD, ONLY: GRIB_ENCODER_OPTIONS_T
USE :: DATAKINDS_DEF_MOD, ONLY: JPIB_K
USE :: HOOKS_MOD, ONLY: HOOKS_T
USE :: CACHE_UTILS_MOD, ONLY: CACHE_OPTIONS_T

! Symbols imported by the preprocessor for debugging purposes
PP_DEBUG_USE_VARS
Expand All @@ -796,7 +796,7 @@ FUNCTION FORTRAN_MESSAGE_SWAP_DATA( THIS, OTHER, OPT, HOOKS ) RESULT(RET)
!> Dummy arguments
CLASS(FORTRAN_MESSAGE_T), INTENT(INOUT) :: THIS
TYPE(FORTRAN_MESSAGE_T), INTENT(INOUT) :: OTHER
TYPE(GRIB_ENCODER_OPTIONS_T), INTENT(IN) :: OPT
TYPE(CACHE_OPTIONS_T), INTENT(IN) :: OPT
TYPE(HOOKS_T), INTENT(INOUT) :: HOOKS

!> Function result
Expand Down Expand Up @@ -969,9 +969,9 @@ END FUNCTION FORTRAN_MESSAGE_SWAP_DATA
FUNCTION FORTRAN_MESSAGE_EQUAL_TO( THIS, OTHER, OPT, IS_EQUAL, HOOKS ) RESULT(RET)

!> Symbols imported from other modules within the project.
USE :: DATAKINDS_DEF_MOD, ONLY: JPIB_K
USE :: HOOKS_MOD, ONLY: HOOKS_T
USE :: GRIB_ENCODER_OPTIONS_MOD, ONLY: GRIB_ENCODER_OPTIONS_T
USE :: DATAKINDS_DEF_MOD, ONLY: JPIB_K
USE :: HOOKS_MOD, ONLY: HOOKS_T
USE :: CACHE_UTILS_MOD, ONLY: CACHE_OPTIONS_T

! Symbols imported by the preprocessor for debugging purposes
PP_DEBUG_USE_VARS
Expand All @@ -985,11 +985,11 @@ FUNCTION FORTRAN_MESSAGE_EQUAL_TO( THIS, OTHER, OPT, IS_EQUAL, HOOKS ) RESULT(RE
IMPLICIT NONE

!> Dummy arguments
CLASS(FORTRAN_MESSAGE_T), INTENT(IN) :: THIS
TYPE(FORTRAN_MESSAGE_T), INTENT(IN) :: OTHER
TYPE(GRIB_ENCODER_OPTIONS_T), INTENT(IN) :: OPT
LOGICAL, INTENT(OUT) :: IS_EQUAL
TYPE(HOOKS_T), INTENT(INOUT) :: HOOKS
CLASS(FORTRAN_MESSAGE_T), INTENT(IN) :: THIS
TYPE(FORTRAN_MESSAGE_T), INTENT(IN) :: OTHER
TYPE(CACHE_OPTIONS_T), INTENT(IN) :: OPT
LOGICAL, INTENT(OUT) :: IS_EQUAL
TYPE(HOOKS_T), INTENT(INOUT) :: HOOKS

!> Function result
INTEGER(KIND=JPIB_K) :: RET
Expand All @@ -1013,55 +1013,55 @@ FUNCTION FORTRAN_MESSAGE_EQUAL_TO( THIS, OTHER, OPT, IS_EQUAL, HOOKS ) RESULT(RE
!> Compare two messages
IS_EQUAL = .TRUE.

IF ( OPT%CACHE_LOCAL_USE_INFO ) THEN
!IF ( OPT%CACHE_LOCAL_USE_INFO ) THEN
IS_EQUAL = IS_EQUAL .AND. ( THIS%STREAM .EQ. OTHER%STREAM )
IS_EQUAL = IS_EQUAL .AND. ( THIS%TYPE .EQ. OTHER%TYPE )
IS_EQUAL = IS_EQUAL .AND. ( THIS%CLASS .EQ. OTHER%CLASS )
IS_EQUAL = IS_EQUAL .AND. ( THIS%EXPVER .EQ. OTHER%EXPVER )
IS_EQUAL = IS_EQUAL .AND. ( THIS%ORIGIN .EQ. OTHER%ORIGIN )
ENDIF
!ENDIF

! Information related to time should never be compared
IF ( OPT%CACHE_TIME_RELATED_INFO ) THEN
!IF ( OPT%CACHE_TIME_RELATED_INFO ) THEN
IS_EQUAL = IS_EQUAL .AND. ( THIS%ANOFFSET .EQ. OTHER%ANOFFSET )
ENDIF
!ENDIF

IF ( OPT%CACHE_SATELLITES_INFO ) THEN
!IF ( OPT%CACHE_SATELLITES_INFO ) THEN
IS_EQUAL = IS_EQUAL .AND. ( THIS%NUMBER .EQ. OTHER%NUMBER )
IS_EQUAL = IS_EQUAL .AND. ( THIS%IDENT .EQ. OTHER%IDENT )
IS_EQUAL = IS_EQUAL .AND. ( THIS%INSTRUMENT .EQ. OTHER%INSTRUMENT )
IS_EQUAL = IS_EQUAL .AND. ( THIS%CHANNEL .EQ. OTHER%CHANNEL )
ENDIF
!ENDIF

IF ( OPT%CACHE_PRODUCT_DEFINITION_INFO ) THEN
!IF ( OPT%CACHE_PRODUCT_DEFINITION_INFO ) THEN
IS_EQUAL = IS_EQUAL .AND. ( THIS%PARAM_TYPE .EQ. OTHER%PARAM_TYPE )
IS_EQUAL = IS_EQUAL .AND. ( THIS%CHEM .EQ. OTHER%CHEM )
IS_EQUAL = IS_EQUAL .AND. ( THIS%PARAM .EQ. OTHER%PARAM )
IS_EQUAL = IS_EQUAL .AND. ( THIS%LEVTYPE .EQ. OTHER%LEVTYPE )
IS_EQUAL = IS_EQUAL .AND. ( THIS%MODEL .EQ. OTHER%MODEL )
ENDIF
!ENDIF

IF ( OPT%CACHE_TYPE_OF_LEVELS ) THEN
!IF ( OPT%CACHE_TYPE_OF_LEVELS ) THEN
IS_EQUAL = IS_EQUAL .AND. ( THIS%LEVELIST .EQ. OTHER%LEVELIST )
ENDIF
!ENDIF

IF ( OPT%CACHE_DIRECTION_FREQUENCY ) THEN
!IF ( OPT%CACHE_DIRECTION_FREQUENCY ) THEN
IS_EQUAL = IS_EQUAL .AND. ( THIS%DIRECTION .EQ. OTHER%DIRECTION )
IS_EQUAL = IS_EQUAL .AND. ( THIS%FREQUENCY .EQ. OTHER%FREQUENCY )
ENDIF
!ENDIF


! Time information should never be cached
IF ( OPT%CACHE_TIME_RELATED_INFO ) THEN
!IF ( OPT%CACHE_TIME_RELATED_INFO ) THEN
IS_EQUAL = IS_EQUAL .AND. ( THIS%DATE .EQ. OTHER%DATE )
IS_EQUAL = IS_EQUAL .AND. ( THIS%TIME .EQ. OTHER%TIME )
IS_EQUAL = IS_EQUAL .AND. ( THIS%STEP .EQ. OTHER%STEP )
ENDIF
!ENDIF

IF ( OPT%CACHE_GRID_DEFINITION_INFO ) THEN
!IF ( OPT%CACHE_GRID_DEFINITION_INFO ) THEN
IS_EQUAL = IS_EQUAL .AND. ( THIS%REPRES .EQ. OTHER%REPRES )
IS_EQUAL = IS_EQUAL .AND. ( THIS%GRID .EQ. OTHER%GRID )
ENDIF
!ENDIF

! Trace end of procedure (on success)
PP_TRACE_EXIT_PROCEDURE_ON_SUCCESS()
Expand Down Expand Up @@ -1113,9 +1113,9 @@ END FUNCTION FORTRAN_MESSAGE_EQUAL_TO
FUNCTION FORTRAN_MESSAGE_LOWER_THAN( THIS, OTHER, OPT, IS_LOWER_THAN, HOOKS ) RESULT(RET)

!> Symbols imported from other modules within the project.
USE :: DATAKINDS_DEF_MOD, ONLY: JPIB_K
USE :: HOOKS_MOD, ONLY: HOOKS_T
USE :: GRIB_ENCODER_OPTIONS_MOD, ONLY: GRIB_ENCODER_OPTIONS_T
USE :: DATAKINDS_DEF_MOD, ONLY: JPIB_K
USE :: HOOKS_MOD, ONLY: HOOKS_T
USE :: CACHE_UTILS_MOD, ONLY: CACHE_OPTIONS_T

! Symbols imported by the preprocessor for debugging purposes
PP_DEBUG_USE_VARS
Expand All @@ -1129,11 +1129,11 @@ FUNCTION FORTRAN_MESSAGE_LOWER_THAN( THIS, OTHER, OPT, IS_LOWER_THAN, HOOKS ) RE
IMPLICIT NONE

!> Dummy arguments
CLASS(FORTRAN_MESSAGE_T), INTENT(IN) :: THIS
TYPE(FORTRAN_MESSAGE_T), INTENT(IN) :: OTHER
TYPE(GRIB_ENCODER_OPTIONS_T), INTENT(IN) :: OPT
LOGICAL, INTENT(OUT) :: IS_LOWER_THAN
TYPE(HOOKS_T), INTENT(INOUT) :: HOOKS
CLASS(FORTRAN_MESSAGE_T), INTENT(IN) :: THIS
TYPE(FORTRAN_MESSAGE_T), INTENT(IN) :: OTHER
TYPE(CACHE_OPTIONS_T), INTENT(IN) :: OPT
LOGICAL, INTENT(OUT) :: IS_LOWER_THAN
TYPE(HOOKS_T), INTENT(INOUT) :: HOOKS

!> Function result
INTEGER(KIND=JPIB_K) :: RET
Expand All @@ -1156,55 +1156,55 @@ FUNCTION FORTRAN_MESSAGE_LOWER_THAN( THIS, OTHER, OPT, IS_LOWER_THAN, HOOKS ) RE

!> Compare two messages
IS_LOWER_THAN = .TRUE.
IF ( OPT%CACHE_LOCAL_USE_INFO ) THEN
! IF ( OPT%CACHE_LOCAL_USE_INFO ) THEN
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%STREAM .LT. OTHER%STREAM )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%TYPE .LT. OTHER%TYPE )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%CLASS .LT. OTHER%CLASS )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%EXPVER .LT. OTHER%EXPVER )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%ORIGIN .LT. OTHER%ORIGIN )
ENDIF
! ENDIF


! Information related to time should never be compared
IF ( OPT%CACHE_TIME_RELATED_INFO ) THEN
! IF ( OPT%CACHE_TIME_RELATED_INFO ) THEN
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%ANOFFSET .LT. OTHER%ANOFFSET )
ENDIF
! ENDIF

IF ( OPT%CACHE_SATELLITES_INFO ) THEN
! IF ( OPT%CACHE_SATELLITES_INFO ) THEN
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%NUMBER .LT. OTHER%NUMBER )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%IDENT .LT. OTHER%IDENT )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%INSTRUMENT .LT. OTHER%INSTRUMENT )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%CHANNEL .LT. OTHER%CHANNEL )
ENDIF
! ENDIF

IF ( OPT%CACHE_PRODUCT_DEFINITION_INFO ) THEN
! IF ( OPT%CACHE_PRODUCT_DEFINITION_INFO ) THEN
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%PARAM_TYPE .LT. OTHER%PARAM_TYPE )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%CHEM .LT. OTHER%CHEM )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%PARAM .LT. OTHER%PARAM )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%LEVTYPE .LT. OTHER%LEVTYPE )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%MODEL .LT. OTHER%MODEL )
ENDIF
! ENDIF

IF ( OPT%CACHE_TYPE_OF_LEVELS ) THEN
! IF ( OPT%CACHE_TYPE_OF_LEVELS ) THEN
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%LEVELIST .LT. OTHER%LEVELIST )
ENDIF
! ENDIF

IF ( OPT%CACHE_DIRECTION_FREQUENCY ) THEN
! IF ( OPT%CACHE_DIRECTION_FREQUENCY ) THEN
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%DIRECTION .LT. OTHER%DIRECTION )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%FREQUENCY .LT. OTHER%FREQUENCY )
ENDIF
! ENDIF

! Time information should never be cached!!!
IF ( OPT%CACHE_TIME_RELATED_INFO ) THEN
! IF ( OPT%CACHE_TIME_RELATED_INFO ) THEN
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%DATE .LT. OTHER%DATE )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%TIME .LT. OTHER%TIME )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%STEP .LT. OTHER%STEP )
ENDIF
! ENDIF

IF ( OPT%CACHE_GRID_DEFINITION_INFO ) THEN
! IF ( OPT%CACHE_GRID_DEFINITION_INFO ) THEN
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%REPRES .LT. OTHER%REPRES )
IS_LOWER_THAN = IS_LOWER_THAN .AND. ( THIS%GRID .LT. OTHER%GRID )
ENDIF
! ENDIF

! Trace end of procedure (on success)
PP_TRACE_EXIT_PROCEDURE_ON_SUCCESS()
Expand Down
Loading

0 comments on commit 5a082a7

Please sign in to comment.