Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include PET number in error messages if using ESMF #925

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 29 additions & 1 deletion Headers/errcode_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ SUBROUTINE GC_Error( ErrMsg, RC, ThisLoc, Instr )
#if defined( MODEL_CESM )
USE CAM_ABORTUTILS, ONLY : ENDRUN
#endif
#if defined( ESMF_ )
#include "MAPL_Generic.h"
USE ESMF
USE MAPL_Mod
#endif
!
! !INPUT PARAMETERS:
!
Expand All @@ -81,11 +86,33 @@ SUBROUTINE GC_Error( ErrMsg, RC, ThisLoc, Instr )
!BOC

CHARACTER(LEN=1000) :: Message

#if defined( ESMF_)
INTEGER :: localPET, STATUS
CHARACTER(4) :: localPETchar
CHARACTER(LEN=1023) :: MSG, MSG1, MSG2
TYPE(ESMF_VM) :: VM
#endif
!=======================================================================
! GC_ERROR begins here
!=======================================================================

! Construct error message
#if defined( ESMF_ )
! Get current thread number
CALL ESMF_VMGetCurrent(VM, RC=STATUS)
CALL ESMF_VmGet( VM, localPET=localPET, __RC__ )
WRITE(localPETchar,'(I4.4)') localPET
MSG1 = 'GEOS-Chem ERROR ['//TRIM(localPETchar)//']: '//TRIM(ErrMsg)
MSG2 = ''
IF ( PRESENT(THISLOC) ) THEN
MSG2 = NEW_LINE('a') // ' --> LOCATION: ' // TRIM( THISLOC )
ENDIF
MSG = NEW_LINE('a') // TRIM(MSG1) // TRIM(MSG2)

! Print error message
WRITE(*,*) TRIM(MSG)
#else

! Separator
WRITE( 6, '(a)' ) REPEAT( '=', 79 )

Expand All @@ -108,6 +135,7 @@ SUBROUTINE GC_Error( ErrMsg, RC, ThisLoc, Instr )
! Separators
WRITE( 6, '(a)' ) REPEAT( '=', 79 )
WRITE( 6, '(a)' ) ''
#endif

! Force the message to be flushed to the log file
CALL Flush( 6 )
Expand Down