diff --git a/src/Core/hco_config_mod.F90 b/src/Core/hco_config_mod.F90 index 65e937f6..689b165a 100644 --- a/src/Core/hco_config_mod.F90 +++ b/src/Core/hco_config_mod.F90 @@ -59,7 +59,7 @@ MODULE HCO_Config_Mod PUBLIC :: Config_GetSpecNames PUBLIC :: ConfigInit ! -! !PRIVATE: +! !PRIVATE MEMBER FUNCTIONS: ! PRIVATE :: ReadSettings PRIVATE :: ExtSwitch2Buffer @@ -157,7 +157,8 @@ SUBROUTINE Config_ReadFile( am_I_Root, HcoConfig, ConfigFile, Phase, & INTEGER :: IU_HCO, IOS ! Strings - CHARACTER(LEN=255) :: MSG, LOC, FileMsg + CHARACTER(LEN=255) :: loc, fileMsg + CHARACTER(LEN=512) :: msg CHARACTER(LEN=2047) :: CFDIR CHARACTER(LEN=2047) :: LINE @@ -167,7 +168,8 @@ SUBROUTINE Config_ReadFile( am_I_Root, HcoConfig, ConfigFile, Phase, & ! Enter RC = HCO_SUCCESS - LOC = 'Config_ReadFile (hco_config_mod.F90)' + msg = '' + loc = 'Config_ReadFile (hco_config_mod.F90)' ! Initialize config object if not already initialized IF ( .NOT. ASSOCIATED(HcoConfig) ) THEN @@ -243,13 +245,14 @@ SUBROUTINE Config_ReadFile( am_I_Root, HcoConfig, ConfigFile, Phase, & ENDIF ENDIF - ! Extract configuration file directory. This is the directory containing the - ! configuration file. Any tokens $CFDIR in the given configuration file will - ! be replaced with the configuration file directory + ! Extract configuration file directory. This is the directory containing + ! the configuration file. Any tokens $CFDIR in the given configuration + ! file will be replaced with the configuration file directory CALL HCO_GetBase( ConfigFile, CFDIR, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 0', RC, THISLOC=LOC ) - RETURN + msg = 'Could not replace $CFDIR token in: ' // TRIM( ConfigFile ) + CALL HCO_Error( msg, RC, thisLoc=LOC ) + RETURN ENDIF ! Find free LUN @@ -282,7 +285,8 @@ SUBROUTINE Config_ReadFile( am_I_Root, HcoConfig, ConfigFile, Phase, & IF ( .NOT. ExtNrInUse( HcoConfig%ExtList, CoreNr ) ) THEN CALL AddExt( HcoConfig, 'CORE', CoreNr, .TRUE., 'all', RC ) IF ( RC /= HCO_SUCCESS ) THEN - WRITE(*,*) 'Error adding CORE extension' + msg = 'Error adding CORE extension' + CALL HCO_Error( msg, RC, thisLoc=loc ) RC = HCO_FAIL RETURN ENDIF @@ -297,8 +301,9 @@ SUBROUTINE Config_ReadFile( am_I_Root, HcoConfig, ConfigFile, Phase, & ! Read a line from the file, exit if EOF CALL HCO_ReadLine ( IU_HCO, LINE, EOF, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 1', RC, THISLOC=LOC ) - RETURN + msg = 'Error in HEMCO_Config.rc @ line: ' // TRIM( Line ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF IF ( EOF ) EXIT @@ -313,8 +318,9 @@ SUBROUTINE Config_ReadFile( am_I_Root, HcoConfig, ConfigFile, Phase, & IF ( PHASE < 2 ) THEN CALL ReadSettings( HcoConfig, IU_HCO, EOF, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 2', RC, THISLOC=LOC ) - RETURN + msg = 'Error in HEMCO_Config.rc @ section ' // TRIM( line ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF IF ( EOF ) EXIT @@ -332,8 +338,9 @@ SUBROUTINE Config_ReadFile( am_I_Root, HcoConfig, ConfigFile, Phase, & IF ( PHASE < 2 ) THEN CALL ExtSwitch2Buffer( HcoConfig, IU_HCO, EOF, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 3', RC, THISLOC=LOC ) - RETURN + msg = 'Error in HEMCO_Config,rc @ section: ' // TRIM( line ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF IF ( EOF ) EXIT @@ -356,8 +363,9 @@ SUBROUTINE Config_ReadFile( am_I_Root, HcoConfig, ConfigFile, Phase, & HCO_DCTTYPE_BASE, EOF, RC, & IsDryRun=IsDryRun ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 4', RC, THISLOC=LOC ) - RETURN + msg = 'Error in HEMCO_Config.rc @ section: ' // TRIM( Line ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF IF ( EOF ) EXIT @@ -372,8 +380,9 @@ SUBROUTINE Config_ReadFile( am_I_Root, HcoConfig, ConfigFile, Phase, & CALL Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & HCO_DCTTYPE_SCAL, EOF, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 5', RC, THISLOC=LOC ) - RETURN + msg= 'Error in HEMCO_Config.rc @ section: ' // TRIM( Line ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF IF ( EOF ) EXIT @@ -384,8 +393,9 @@ SUBROUTINE Config_ReadFile( am_I_Root, HcoConfig, ConfigFile, Phase, & CALL Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & HCO_DCTTYPE_MASK, EOF, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 6', RC, THISLOC=LOC ) - RETURN + msg = 'Error in HEMCO_Config.rc @ line: ' // TRIM( Line ) + CALL HCO_Error( msg, RC, thisLoc=LOC ) + RETURN ENDIF IF ( EOF ) EXIT @@ -408,7 +418,8 @@ SUBROUTINE Config_ReadFile( am_I_Root, HcoConfig, ConfigFile, Phase, & ! Close file CLOSE( UNIT=IU_HCO, IOSTAT=IOS ) IF ( IOS /= 0 ) THEN - WRITE(*,*) 'Error closing ' // TRIM(ConfigFile) + msg = 'Error closing ' // TRIM(ConfigFile) + CALL HCO_Error( msg, RC, thisLoc=loc ) RC = HCO_FAIL RETURN ENDIF @@ -461,27 +472,32 @@ SUBROUTINE SetReadList( HcoState, RC ) !------------------------------------------------------------------------------ !BOC - CHARACTER(LEN=255) :: MSG, LOC + CHARACTER(LEN=255) :: loc + CHARACTER(LEN=512) :: msg !====================================================================== ! SetReadList begins here !====================================================================== - LOC = 'SetReadList (HCO_CONFIG_MOD.F90)' + msg = '' + loc = 'SetReadList (HCO_CONFIG_MOD.F90)' ! Init CALL HCO_ENTER ( HcoState%Config%Err, LOC, RC ) IF ( RC /= HCO_SUCCESS ) THEN - PRINT *,'Error in HCO_ENTER called from HEMCO SetReadList' + msg = 'Error encountered in routine "HCO_Enter"!' + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF ! Return w/ error if configuration file hasn't been read yet! IF ( .NOT. ASSOCIATED(HcoState%Config) ) THEN - PRINT *,'HEMCO configuration object in HEMCO state is empty! Error in HEMCO SetReadList.' + msg = 'HEMCO configuration object in HEMCO state is empty!' + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF IF ( .NOT. HcoState%Config%ConfigFileRead ) THEN - PRINT *,'HEMCO configuration file not read! Error in HEMCO SetReadList.' + msg = 'HEMCO configuration file not read!' + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF @@ -626,13 +642,13 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & CHARACTER(LEN= 31) :: SpcName CHARACTER(LEN=255) :: Char1 CHARACTER(LEN=255) :: Char2 - CHARACTER(LEN=255) :: LOC, MSG + CHARACTER(LEN=255) :: loc CHARACTER(LEN=255) :: LINE CHARACTER(LEN=255) :: tagId CHARACTER(LEN=255) :: tagName CHARACTER(LEN=255) :: tagcName CHARACTER(LEN=255) :: ItemPrefix - CHARACTER(LEN=255) :: ErrMsg + CHARACTER(LEN=512) :: msg ! Arrays INTEGER :: SplitInts(255) @@ -648,7 +664,7 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & !================================================================= ! Enter - LOC = 'Config_ReadCont (hco_config_mod.F90)' + loc = 'Config_ReadCont (hco_config_mod.F90)' ! Initialize SKIP = .FALSE. @@ -740,7 +756,8 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & ! Error if not enough entries found IF ( STAT == 100 ) THEN - CALL HCO_ERROR ( 'STAT == 100', RC, THISLOC=LOC ) + msg = 'STAT == 100; not enough entries found!' + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF @@ -750,8 +767,9 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & ! ------------------------------------------------------------- CALL BracketCheck( HcoConfig, STAT, LINE, SKIP, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 7', RC, THISLOC=LOC ) - RETURN + msg = 'Bracket error in HEMCO_Config.rc @ line ' // TRIM( line ) + CALL HCO_ERROR( msg, RC, thisLoc=loc ) + RETURN ENDIF ! Skip if needed @@ -772,15 +790,17 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & ! contain any data tokens ($YR, $MM, etc.). CALL HCO_CharParse ( HcoConfig, LINE, 0, 0, 0, 0, 0, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 8', RC, THISLOC=LOC ) - RETURN + msg = 'Parse error in HEMCO_Config.rc @ line: ' // TRIM( line ) + CALL HCO_Error( msg, RC, thisLoc=LOC ) + RETURN ENDIF CALL Config_ReadFile( HcoConfig%amIRoot, HcoConfig, LINE, 0, RC, & IsNest=.TRUE., IsDryRun=IsDryRun ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 9', RC, THISLOC=LOC ) - RETURN + msg = 'Error reading HEMCO_Config.rc @ line: ' // TRIM( line ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ! All done with this line @@ -789,7 +809,8 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & ! Output status should be 0 if none of the statuses above applies IF ( STAT /= 0 ) THEN - CALL HCO_ERROR ( 'STAT /= 0', RC, THISLOC=LOC ) + msg = 'STAT /= 0; indicates I/O error!' + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF @@ -824,9 +845,9 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & CALL Hco_GetTagInfo( tagId, HcoConfig, Found, RC, N=N, & tagName=tagName ) IF ( RC /= HCO_SUCCESS ) THEN - ErrMsg = 'Error retrieving tag name for' // & - ' wildcard ' // TRIM(tagId) - CALL HCO_Error( ErrMsg, RC ) + msg = 'Error retrieving tag name for' // & + ' wildcard ' // TRIM(tagId) + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF @@ -848,8 +869,9 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & ! Check if name exists already CALL CheckForDuplicateName( HcoConfig, tagcName, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 10', RC, THISLOC=LOC ) - RETURN + msg = 'Duplicate container name: ' // TRIM( tagcName ) + CALL HCO_ERROR( msg, RC, thisLoc=loc ) + RETURN ENDIF ! Attributes used by all data types: data type number and @@ -867,8 +889,9 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & ! CatMax integers, or empty. CALL HCO_CharSplit( Char2, Separator, Wildcard, Cats, nCat, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 11', RC, THISLOC=LOC ) - RETURN + msg = 'Could not extract category at line: ' // TRIM( char2 ) + CALL HCO_Error( msg, RC, thisLoc=LOC ) + RETURN ENDIF IF ( nCat == 0 ) THEN Lct%Dct%Cat = -999 @@ -881,8 +904,10 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & CALL HCO_CharSplit( Char1, Separator, Wildcard, & SplitInts, nScl, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 12', RC, THISLOC=LOC ) - RETURN + msg = 'Could not get scale factor ID''s in line: ' // & + TRIM( char1 ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF IF ( nScl > 0 ) THEN ALLOCATE ( Lct%Dct%Scal_cID(nScl) ) @@ -895,8 +920,9 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & ! with model species (see Config\_GetSpecNames). CALL SpecName_Register ( HcoConfig, ADJUSTL(SpcName), RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 13', RC, THISLOC=LOC ) - RETURN + msg = 'Could not register species name: ' // TRIM(SpcName) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ! ------------------------------------------------------------- @@ -916,7 +942,7 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & IF ( TRIM(srcFile) == '-' ) THEN IF ( .NOT. ASSOCIATED(Dta) ) THEN MSG = 'Cannot use previous data container: '//TRIM(tagcName) - CALL HCO_ERROR ( MSG, RC, THISLOC=LOC ) + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF Lct%Dct%DtaHome = Lct%Dct%DtaHome - 1 @@ -958,8 +984,9 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & IF ( TRIM(srcTime) /= '-' ) THEN CALL HCO_ExtractTime( HcoConfig, srcTime, Dta, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 14', RC, THISLOC=LOC ) - RETURN + msg = 'Could not extract time cycle information!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ENDIF @@ -1021,8 +1048,9 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & ! Check if name exists already CALL CheckForDuplicateName( HcoConfig, cName, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 18', RC, THISLOC=LOC ) - RETURN + msg = 'Duplicate name: ' // TRIM( cName ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ! Attributes used by all data types: data type number and @@ -1043,7 +1071,8 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & ! CatMax integers, or empty. CALL HCO_CharSplit( Char2, Separator, Wildcard, Cats, nCat, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 19', RC, THISLOC=LOC ) + msg = 'Could not extract category from: ' // TRIM( char2 ) + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF IF ( nCat == 0 ) THEN @@ -1057,8 +1086,9 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & CALL HCO_CharSplit( Char1, Separator, Wildcard, & SplitInts, nScl, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 20', RC, THISLOC=LOC ) - RETURN + msg = 'Could not get scale factor IDs from: ' // TRIM( char1 ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF IF ( nScl > 0 ) THEN ALLOCATE ( Lct%Dct%Scal_cID(nScl) ) @@ -1071,8 +1101,9 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & ! with model species (see Config\_GetSpecNames). CALL SpecName_Register ( HcoConfig, ADJUSTL(SpcName), RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 21', RC, THISLOC=LOC ) - RETURN + msg = 'Could not register species: ' // TRIM( SpcName ) + CALL HCO_ERROR( msg, RC, thisLoc=loc ) + RETURN ENDIF ! Scale factor & mask specific attributes @@ -1087,14 +1118,16 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & IF ( Lct%Dct%ScalID < 0 ) THEN CALL ScalID2List( HcoConfig%ScalIDList, Lct%Dct%ScalID, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 22', RC, THISLOC=LOC ) - RETURN + msg = 'Could not make sure that negative scale ' // & + 'are always read!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ENDIF ELSE - CALL HCO_ERROR ( 'Invalid data type!', RC, & - THISLOC=LOC ) + msg = 'Invalid data type!' + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF @@ -1115,7 +1148,7 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & IF ( TRIM(srcFile) == '-' ) THEN IF ( .NOT. ASSOCIATED(Dta) ) THEN MSG = 'Cannot use previous data container: '//TRIM(cName) - CALL HCO_ERROR ( MSG, RC, THISLOC=LOC ) + CALL HCO_Error( msg, RC, thisLoc=loc) RETURN ENDIF Lct%Dct%DtaHome = Lct%Dct%DtaHome - 1 @@ -1157,8 +1190,9 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & IF ( TRIM(srcTime) /= '-' ) THEN CALL HCO_ExtractTime( HcoConfig, srcTime, Dta, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 23', RC, THISLOC=LOC ) - RETURN + msg = 'Could not extract time information!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ENDIF @@ -1214,15 +1248,16 @@ SUBROUTINE Config_ReadCont( HcoConfig, IU_HCO, CFDIR, & ! nCat cannot exceed CatMax IF ( nCat > CatMax ) THEN - MSG = 'Category max exceeded' - CALL HCO_ERROR ( MSG, RC, THISLOC=LOC ) + MSG = 'Exceeded maximum number of categories!' + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF CALL AddShadowFields( HcoConfig, Lct, Cats, nCat, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 27', RC, THISLOC=LOC ) - RETURN + msg = 'Could not create shadow emission container!' + CALL HCO_ERROR( msg, RC, thisLoc=loc ) + RETURN ENDIF ! Reset nCat @@ -1310,7 +1345,7 @@ SUBROUTINE BracketCheck( HcoConfig, STAT, LINE, SKIP, RC ) INTEGER, SAVE :: SKIPLEVEL = 0 CHARACTER(LEN=255), SAVE :: AllBrackets(MAXBRACKNEST) = '' CHARACTER(LEN=255) :: TmpBracket, CheckBracket, ThisBracket - CHARACTER(LEN=255) :: MSG + CHARACTER(LEN=512) :: msg CHARACTER(LEN=255), PARAMETER :: LOC = 'BracketCheck (hco_config_mod.F90)' @@ -1325,9 +1360,8 @@ SUBROUTINE BracketCheck( HcoConfig, STAT, LINE, SKIP, RC ) IF ( STAT == 5 .OR. STAT == 6 ) THEN STRLEN = LEN(LINE) IF ( STRLEN < 4 ) THEN - CALL HCO_ERROR ( & - 'Illegal bracket length: '//TRIM(LINE), & - RC, THISLOC=LOC ) + msg = 'Illegal bracket length: ' // TRIM(line) + CALL HCO_ERROR ( msg, RC, thisLoc=loc ) RETURN ELSE TmpBracket = TRIM(LINE(4:STRLEN)) @@ -1344,7 +1378,7 @@ SUBROUTINE BracketCheck( HcoConfig, STAT, LINE, SKIP, RC ) NEST = NEST + 1 IF ( NEST > MAXBRACKNEST ) THEN MSG = 'Too many nested brackets' - CALL HCO_ERROR( MSG, RC, THISLOC=LOC ) + CALL HCO_Error( msg, RC, thisLoc=LOC ) RETURN ENDIF AllBrackets(NEST) = TmpBracket @@ -1407,8 +1441,9 @@ SUBROUTINE BracketCheck( HcoConfig, STAT, LINE, SKIP, RC ) CALL GetExtOpt( HcoConfig, -999, TRIM(ThisBracket), & OptValBool=UseThis, FOUND=FOUND, RC=RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 28', RC, THISLOC=LOC ) - RETURN + msg = 'Error when checking '// TRIM( thisBracket ) // '!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ! If bracket name was found in options, update the UseBracket @@ -1451,9 +1486,9 @@ SUBROUTINE BracketCheck( HcoConfig, STAT, LINE, SKIP, RC ) ! Verbose mode IF ( verb ) THEN MSG = 'Opened shortcut bracket: '//TRIM(TmpBracket) - CALL HCO_MSG( HcoConfig%Err, MSG ) + CALL HCO_MSG( HcoConfig%Err, msg ) WRITE(MSG,*) ' - Skip content of this bracket: ', SKIP - CALL HCO_MSG( HcoConfig%Err, MSG ) + CALL HCO_MSG( HcoConfig%Err, msg ) ENDIF ENDIF @@ -1464,7 +1499,7 @@ SUBROUTINE BracketCheck( HcoConfig, STAT, LINE, SKIP, RC ) IF ( TRIM(TmpBracket) /= TRIM(AllBrackets(NEST)) ) THEN MSG = 'Closing bracket does not match opening bracket: '// & TRIM(TmpBracket)//', expected: '//TRIM(AllBrackets(NEST)) - CALL HCO_ERROR( MSG, RC, THISLOC=LOC ) + CALL HCO_Error( msg, RC, thisLoc=LOC ) RETURN ENDIF @@ -1480,9 +1515,9 @@ SUBROUTINE BracketCheck( HcoConfig, STAT, LINE, SKIP, RC ) ! Verbose mode IF ( verb ) THEN MSG = 'Closed shortcut bracket: '//TRIM(TmpBracket) - CALL HCO_MSG( HcoConfig%Err, MSG ) + CALL HCO_MSG( HcoConfig%Err, msg ) WRITE(MSG,*) ' - Skip following lines: ', SKIP - CALL HCO_MSG( HcoConfig%Err, MSG ) + CALL HCO_MSG( HcoConfig%Err, msg ) ENDIF ENDIF @@ -1536,7 +1571,7 @@ SUBROUTINE AddShadowFields( HcoConfig, Lct, Cats, nCat, RC ) LOGICAL :: verb INTEGER :: I, N TYPE(ListCont), POINTER :: Shd - CHARACTER(LEN=255) :: MSG + CHARACTER(LEN=512) :: msg CHARACTER(LEN=5) :: C5 CHARACTER(LEN=255), PARAMETER :: LOC = 'AddShadowFields (hco_config_mod.F90)' @@ -1610,7 +1645,7 @@ SUBROUTINE AddShadowFields( HcoConfig, Lct, Cats, nCat, RC ) ! verbose mode IF ( verb ) THEN MSG = 'Created shadow base emission field: ' // TRIM(Shd%Dct%cName) - CALL HCO_MSG(HcoConfig%Err,MSG) + CALL HCO_MSG( HcoConfig%Err, msg ) ENDIF ! Cleanup @@ -1620,8 +1655,9 @@ SUBROUTINE AddShadowFields( HcoConfig, Lct, Cats, nCat, RC ) ! Add zero scale factor container CALL AddZeroScal( HcoConfig, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 29', RC, THISLOC=LOC ) - RETURN + msg = 'Call to AddZeroScal could not add zero scale factor container!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ! Return w/ success @@ -1774,7 +1810,8 @@ SUBROUTINE ExtSwitch2Buffer( HcoConfig, IU_HCO, EOF, RC ) ! INTEGER :: I, N, Idx, ExtNr LOGICAL :: Enabled, NewExt - CHARACTER(LEN=255) :: LOC + CHARACTER(LEN=255) :: loc + CHARACTER(LEN=512) :: msg CHARACTER(LEN=1023) :: OPTS CHARACTER(LEN=2047) :: LINE CHARACTER(LEN=2047) :: SUBSTR(255), SPECS(255) @@ -1784,8 +1821,9 @@ SUBROUTINE ExtSwitch2Buffer( HcoConfig, IU_HCO, EOF, RC ) !====================================================================== ! Enter - LOC = 'ExtSwitch2Buffer (hco_config_mod.F90)' RC = HCO_SUCCESS + msg = '' + loc = 'ExtSwitch2Buffer (hco_config_mod.F90)' ExtNr = -1 ! Do until exit @@ -1794,8 +1832,9 @@ SUBROUTINE ExtSwitch2Buffer( HcoConfig, IU_HCO, EOF, RC ) ! Read line CALL HCO_ReadLine ( IU_HCO, LINE, EOF, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 30', RC, THISLOC=LOC ) - RETURN + msg = 'Error in HEMCO_Config.rc @ line: ' // TRIM( line ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ! Return if EOF @@ -1815,8 +1854,9 @@ SUBROUTINE ExtSwitch2Buffer( HcoConfig, IU_HCO, EOF, RC ) CALL AddExtOpt( HcoConfig, TRIM(LINE), & ExtNr, RC, IgnoreIfExist=.TRUE. ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 31', RC, THISLOC=LOC ) - RETURN + msg = 'Error in HEMCO_Config.rc @ line: ' // TRIM( line ) + CALL HCO_ERROR( msg, RC, thisLoc=loc ) + RETURN ENDIF ENDIF CYCLE @@ -1894,8 +1934,9 @@ SUBROUTINE ExtSwitch2Buffer( HcoConfig, IU_HCO, EOF, RC ) DO I = 1, N CALL SpecName_Register ( HcoConfig, SPECS(I), RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 33', RC, THISLOC=LOC ) - RETURN + msg = 'Error encountered in "SpecName_Register"!' + CALL HCO_ERROR( msg, RC, thisLoc=LOC ) + RETURN ENDIF ENDDO ENDIF @@ -1957,12 +1998,12 @@ SUBROUTINE ReadSettings( HcoConfig, IU_HCO, EOF, RC ) ! Strings CHARACTER(LEN=255) :: Line - CHARACTER(LEN=255) :: Loc - CHARACTER(LEN=255) :: Msg + CHARACTER(LEN=255) :: loc CHARACTER(LEN=255) :: LogFile CHARACTER(LEN=255) :: DiagnPrefix CHARACTER(LEN=255) :: MetField CHARACTER(LEN=255) :: GridRes + CHARACTER(LEN=512) :: msg !====================================================================== ! ReadSettings begins here @@ -1981,8 +2022,9 @@ SUBROUTINE ReadSettings( HcoConfig, IU_HCO, EOF, RC ) ! Read line CALL HCO_ReadLine ( IU_HCO, LINE, EOF, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 34', RC, THISLOC=LOC ) - RETURN + msg = 'Error in HEMCO_Config.rc @ line: ' // TRIM( Line ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ! Return if EOF @@ -2001,8 +2043,9 @@ SUBROUTINE ReadSettings( HcoConfig, IU_HCO, EOF, RC ) CALL AddExtOpt ( HcoConfig, TRIM(LINE), & CoreNr, RC, IgnoreIfExist=.TRUE. ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 35', RC, THISLOC=LOC ) - RETURN + msg = 'Error in HEMCO_Config.rc @ line: ' // TRIM( Line ) + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ENDDO @@ -2066,8 +2109,9 @@ SUBROUTINE ReadSettings( HcoConfig, IU_HCO, EOF, RC ) CALL GetExtOpt( HcoConfig, CoreNr, 'Verbose', & OptValInt=verb, FOUND=FOUND, RC=RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 36', RC, THISLOC=LOC ) - RETURN + msg = 'Error looking for "Verbose" HEMCO_Config.rc!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF IF ( .NOT. FOUND ) THEN verb = 3 @@ -2078,8 +2122,9 @@ SUBROUTINE ReadSettings( HcoConfig, IU_HCO, EOF, RC ) CALL GetExtOpt( HcoConfig, CoreNr, 'Logfile', & OptValChar=Logfile, FOUND=FOUND, RC=RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 37', RC, THISLOC=LOC ) - RETURN + msg = 'Error looking for "Logfile" in HEMCO_Config.rc!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF IF ( .NOT. FOUND ) THEN LogFile = 'HEMCO.log' @@ -2090,8 +2135,9 @@ SUBROUTINE ReadSettings( HcoConfig, IU_HCO, EOF, RC ) CALL GetExtOpt( HcoConfig, CoreNr, 'Warnings', & OptValInt=warn, FOUND=FOUND, RC=RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 38', RC, THISLOC=LOC ) - RETURN + msg = 'Error looking for "Warnings" in HEMCO_Config.rc!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF IF ( .NOT. FOUND ) THEN warn = 3 @@ -2101,21 +2147,24 @@ SUBROUTINE ReadSettings( HcoConfig, IU_HCO, EOF, RC ) ! Initialize (standard) HEMCO tokens CALL HCO_SetDefaultToken( HcoConfig, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 39', RC, THISLOC=LOC ) - RETURN + msg = 'Error encountered in routine "HCO_SetDefaultToken"!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ! If LogFile is equal to wildcard character, set LogFile to asterik ! character. This will ensure that all output is written to standard ! output! - IF ( TRIM(LogFile) == HCO_GetOpt(HcoConfig%ExtList,'Wildcard') ) LogFile = '*' + IF ( TRIM(LogFile) == HCO_GetOpt(HcoConfig%ExtList,'Wildcard') ) & + LogFile = '*' ! We should now have everything to define the HEMCO error settings CALL HCO_ERROR_SET( HcoConfig%amIRoot, HcoConfig%Err, LogFile, & verb, warn, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 40', RC, THISLOC=LOC ) - RETURN + msg = 'Error encountered in routine "Hco_Error_Set"!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ENDIF @@ -2177,18 +2226,20 @@ SUBROUTINE RegisterPrepare( HcoState, RC ) INTEGER :: ThisCover, ThisHcoID, FLAG INTEGER :: lon1, lon2, lat1, lat2 INTEGER :: cpux1, cpux2, cpuy1, cpuy2 - CHARACTER(LEN=255) :: MSG, LOC + CHARACTER(LEN=255) :: loc + CHARACTER(LEN=512) :: msg !================================================================= ! RegisterPrepare begins here! !================================================================= - LOC = 'RegisterPrepare (HCO_CONFIG_MOD.F90)' + loc = 'RegisterPrepare (HCO_CONFIG_MOD.F90)' ! Enter CALL HCO_ENTER ( HcoState%Config%Err, LOC, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 41', RC, THISLOC=LOC ) - RETURN + msg = 'Error encountered in routine "HCO_Enter"!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ! Initialize @@ -2297,17 +2348,18 @@ SUBROUTINE RegisterPrepare( HcoState, RC ) ! IF ( (mskLct%Dct%DctType == HCO_DCTTYPE_MASK ) .AND. & ! (mskLct%Dct%Dta%Cover == 0 ) ) THEN ! - ! Because the code only distinguishes between full/partial and zero coverage, - ! and skips reading the base field if coverage is zero, this may cause - ! issues with MPI environments in WRF and CESM where the mask lon1/lat1/lon2/lat2 - ! boundaries are set too small compared to the mask, and result in the - ! base field being skipped over small CPU decompositions where it should not have - ! been. The above fix does not fix the issue where ThisCover == 0, - ! which is the root cause in WRF and CESM. Thus, always set to partial coverage + ! Because the code only distinguishes between full/partial and zero + ! coverage, and skips reading the base field if coverage is zero, + ! this may cause issues with MPI environments in WRF and CESM where + ! the mask lon1/lat1/lon2/lat2 boundaries are set too small compared + ! to the mask, and result in the base field being skipped over small + ! CPU decompositions where it should not have been. The above fix + ! does not fix the issue where ThisCover == 0, which is the root + ! cause in WRF and CESM. Thus, always set to partial coverage ! (hplin, 8/19/22) ! - ! Thus, the following fix needs to be applied for ESMF environments, skipping - ! a lot of the calculations below. + ! Thus, the following fix needs to be applied for ESMF environments, + ! skipping a lot of the calculations below. #if defined ( ESMF_ ) || defined( MODEL_WRF ) || defined( MODEL_CESM ) ThisCover = -1 #else @@ -2330,7 +2382,7 @@ SUBROUTINE RegisterPrepare( HcoState, RC ) IF ( HCO_IsVerb(HcoSTate%Config%Err,3) ) THEN WRITE(MSG,*) 'Coverage: ', Lct%Dct%Dta%Cover - CALL HCO_MSG(HcoState%Config%Err,MSG) + CALL HCO_MSG( HcoState%Config%Err, msg ) ENDIF ENDIF @@ -2391,17 +2443,19 @@ SUBROUTINE Register_Base( HcoState, RC ) INTEGER :: N, cID, HcoID INTEGER :: targetID, FLAG LOGICAL :: Ignore, Add - CHARACTER(LEN=255) :: MSG, LOC + CHARACTER(LEN=255) :: LOC + CHARACTER(LEN=512) :: msg !====================================================================== ! Register_Base begins here !====================================================================== - LOC = 'Register_Base (HCO_CONFIG_MOD.F90)' + loc = 'Register_Base (HCO_CONFIG_MOD.F90)' ! Enter - CALL HCO_ENTER ( HcoState%Config%Err, LOC, RC ) + CALL HCO_ENTER ( HcoState%Config%Err, loc, RC ) IF ( RC /= HCO_SUCCESS ) THEN - PRINT *,'Error in HCO_ENTER called from Register_Base' + msg = 'Error encountered in routine "HCO_Enter"!' + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF @@ -2498,9 +2552,9 @@ SUBROUTINE Register_Base( HcoState, RC ) ! verbose IF ( HCO_IsVerb(HcoState%Config%Err,3) ) THEN WRITE(MSG,*) 'Container ID : ', Lct%Dct%cID - CALL HCO_MSG(HcoState%Config%Err,MSG) + CALL HCO_MSG( HcoState%Config%Err, msg ) WRITE(MSG,*) 'Assigned targetID: ', targetID - CALL HCO_MSG(HcoState%Config%Err,MSG) + CALL HCO_MSG( HcoState%Config%Err, msg ) ENDIF ! Negative targetID is assigned to base data that doesn't need @@ -2523,14 +2577,15 @@ SUBROUTINE Register_Base( HcoState, RC ) ! in the reading lists sorted by cID. CALL ReadList_Set( HcoState, Lct%Dct, RC ) IF ( RC /= HCO_SUCCESS ) THEN - PRINT *,'Error in ReadList_Set called from Register_Base' + msg = 'Error encountered in routine "ReadList_Set"!' + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF ! Print some information if verbose mode is on IF ( HCO_IsVerb(HcoState%Config%Err,2) ) THEN WRITE(MSG,*) 'Base field registered: ', TRIM(Lct%Dct%cName) - CALL HCO_MSG(HcoState%Config%Err,MSG) + CALL HCO_MSG( HcoState%Config%Err, msg ) ENDIF ! Advance to next line @@ -2588,20 +2643,22 @@ SUBROUTINE Register_Scal( HcoState, RC ) ! Scalars INTEGER :: cID, FLAG - CHARACTER(LEN=255) :: MSG, LOC + CHARACTER(LEN=255) :: LOC + CHARACTER(LEN=512) :: msg CHARACTER(LEN= 5) :: strID INTEGER :: ThisScalID !====================================================================== ! Register_Scal begins here !====================================================================== - LOC = 'Register_Scal (HCO_CONFIG_MOD.F90)' + loc = 'Register_Scal (HCO_CONFIG_MOD.F90)' ! Enter - CALL HCO_ENTER ( HcoState%Config%Err, LOC, RC ) + CALL HCO_ENTER ( HcoState%Config%Err, loc, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 42', RC, THISLOC=LOC ) - RETURN + msg = 'Error encountered in routine "HCO_Enter"!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ! Loop over all scale factor ids @@ -2632,8 +2689,8 @@ SUBROUTINE Register_Scal( HcoState, RC ) ! Return error if scale factor ID not found IF ( .NOT. ASSOCIATED(Lct) ) THEN WRITE ( strID, * ) ThisScalID - MSG = 'Container ID not found: ' // strID - CALL HCO_ERROR ( MSG, RC) + msg = 'Container ID not found: ' // strID + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF @@ -2641,7 +2698,7 @@ SUBROUTINE Register_Scal( HcoState, RC ) IF ( Lct%Dct%DctType == HCO_DCTTYPE_BASE ) THEN WRITE ( strID, * ) ThisScalID MSG = 'Container ID belongs to base field: ' // strID - CALL HCO_ERROR ( MSG, RC) + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF @@ -2654,8 +2711,9 @@ SUBROUTINE Register_Scal( HcoState, RC ) IF ( Lct%Dct%nScalID > 0 ) THEN CALL ScalID_Register ( Lct%Dct, HcoState%Config, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 43', RC, THISLOC=LOC ) - RETURN + msg = 'Error encountered in routine "ScalID_Register"!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ENDIF @@ -2663,14 +2721,15 @@ SUBROUTINE Register_Scal( HcoState, RC ) ! in the reading lists sorted by cID. CALL ReadList_Set( HcoState, Lct%Dct, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 44', RC, THISLOC=LOC ) - RETURN + msg = 'Error encountered in "ReadList_Set"!' + CALL HCO_Error( msg, RC, thisLoc=loc ) + RETURN ENDIF ! Print some information if verbose mode is on IF ( HCO_IsVerb(HcoState%Config%Err,2) ) THEN WRITE(MSG,*) 'Scale field registered: ', TRIM(Lct%Dct%cName) - CALL HCO_MSG(HcoState%Config%Err,MSG) + CALL HCO_MSG( HcoState%Config%Err, msg ) ENDIF ! Advance @@ -2754,19 +2813,21 @@ SUBROUTINE Get_targetID( HcoState, Lct, targetID, RC ) INTEGER :: tmpID INTEGER :: I, J, FLAG1, tmpCov LOGICAL :: found, sameCont - CHARACTER(LEN=255) :: MSG, LOC + CHARACTER(LEN=255) :: loc + CHARACTER(LEN=512) :: msg CHARACTER(LEN= 7) :: strID !====================================================================== ! Get_targetID begins here !====================================================================== - LOC = 'Get_targetID (HCO_CONFIG_MOD.F90)' + loc = 'Get_targetID (HCO_CONFIG_MOD.F90)' ! Enter CALL HCO_ENTER ( HcoState%Config%Err, LOC, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_ERROR( 'ERROR 45', RC, THISLOC=LOC ) - RETURN + msg = 'Error encountered in routine "HCO_Enter"!' + CALL HCO_ERROR( msg, RC, thisLoc=LOC ) + RETURN ENDIF ! Initialize @@ -2825,8 +2886,8 @@ SUBROUTINE Get_targetID( HcoState, Lct, targetID, RC ) ! Error if scale factor not found IF ( .NOT. FOUND ) THEN WRITE ( strID, * ) Lct%Dct%Scal_cID(I) - MSG = 'No scale factor with cID: ' // TRIM(strID) - CALL HCO_ERROR ( MSG, RC) + msg = 'No scale factor with cID: ' // TRIM(strID) + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF @@ -2838,7 +2899,7 @@ SUBROUTINE Get_targetID( HcoState, Lct, targetID, RC ) IF ( HCO_IsVerb(HcoState%Config%Err,1) ) THEN WRITE(MSG,*) 'Data not defined over this CPU, skip ' // & TRIM(Lct%Dct%cName) - CALL HCO_MSG(HcoState%Config%Err,MSG) + CALL HCO_MSG( HcoState%Config%Err, msg ) ENDIF ! Return @@ -2939,7 +3000,7 @@ SUBROUTINE Get_targetID( HcoState, Lct, targetID, RC ) ! Error if container not found IF ( .NOT. FOUND ) THEN WRITE(MSG,*) 'No scale factor with ID: ', tmpID - CALL HCO_ERROR ( MSG, RC) + CALL HCO_Error( msg, RC, thisLoc=loc ) RETURN ENDIF @@ -2977,7 +3038,7 @@ SUBROUTINE Get_targetID( HcoState, Lct, targetID, RC ) IF ( HCO_IsVerb(HcoState%Config%Err,1) ) THEN WRITE(MSG,*) 'Skip container ', TRIM(Lct%Dct%cName), & ' because of ', TRIM(tmpLct%Dct%cName) - CALL HCO_MSG(HcoState%Config%Err,MSG) + CALL HCO_MSG( HcoState%Config%Err, msg ) ENDIF ! Return @@ -4133,6 +4194,7 @@ SUBROUTINE Config_GetSpecAttr( HcoConfig, N, SpecNames, RC ) INTEGER :: AS CHARACTER(LEN=255), PARAMETER :: & LOC = 'Config_GetSpecAttr (hco_config_mod.F90)' + CHARACTER(LEN=512) :: errMsg !====================================================================== ! Config_GetSpecAttr begins here @@ -4145,20 +4207,20 @@ SUBROUTINE Config_GetSpecAttr( HcoConfig, N, SpecNames, RC ) IF ( PRESENT(SpecNames) ) THEN IF ( .NOT. ASSOCIATED(SpecNames) ) THEN IF ( N <= 0 ) THEN - CALL HCO_ERROR ( & - 'Cannot allocate SpecNames - N is size 0 or smaller', RC, THISLOC=LOC ) + errMsg = 'Cannot allocate SpecNames - N is size 0 or smaller' + CALL HCO_Error( errMsg, RC, thisLoc=LOC ) RETURN ENDIF ALLOCATE(SpecNames(N), STAT=AS ) IF ( AS/= 0 ) THEN - CALL HCO_ERROR ( & - 'SpecNames allocation error', RC, THISLOC=LOC ) + errMsg = 'Could not allocate the SpcNames array!' + CALL HCO_Error( errMsg, RC, thisLoc=LOC ) RETURN ENDIF SpecNames(:) = '' ELSEIF ( SIZE(SpecNames) /= N ) THEN - CALL HCO_ERROR ( & - 'SpecNames size error', RC, THISLOC=LOC ) + errMsg = 'Size(SpecNames) does not match the passed N argument!' + CALL HCO_Error( errMsg, RC, thisLoc=LOC ) RETURN ENDIF ENDIF @@ -4311,7 +4373,7 @@ SUBROUTINE ExtractSrcDim( HcoConfig, SrcDim, Dta, Lscal1, Lscal2, RC ) ! ExtractSrcDim begins here !====================================================================== - MSG = 'Illegal source dimension ' // TRIM(srcDim) // & + msg = 'Illegal source dimension ' // TRIM(srcDim) // & ' for file ' // TRIM(Dta%ncFile) // & '. Valid entries are e.g. xy or xyz.' @@ -4341,13 +4403,13 @@ SUBROUTINE ExtractSrcDim( HcoConfig, SrcDim, Dta, Lscal1, Lscal2, RC ) ! There must be at least 3 characters (e.g. xyz) IF ( strLen < 3 ) THEN - CALL HCO_ERROR ( MSG, RC, THISLOC=LOC ) + CALL HCO_Error( msg, RC, thisLoc=LOC ) RETURN ENDIF ! First two entries must be xy IF ( str1(1:2) /= 'xy' ) THEN - CALL HCO_ERROR ( MSG, RC, THISLOC=LOC ) + CALL HCO_Error( msg, RC, thisLoc=LOC ) RETURN ENDIF @@ -4356,7 +4418,7 @@ SUBROUTINE ExtractSrcDim( HcoConfig, SrcDim, Dta, Lscal1, Lscal2, RC ) ! emitted into level 4. IF ( str1(3:3) == 'L' .OR. str1(3:3) == 'l' ) THEN IF ( strLen < 4 ) THEN - CALL HCO_ERROR ( MSG, RC, THISLOC=LOC ) + CALL HCO_Error( msg, RC, thisLoc=LOC ) RETURN ENDIF Dta%SpaceDim = 2 @@ -4439,7 +4501,7 @@ SUBROUTINE ExtractSrcDim( HcoConfig, SrcDim, Dta, Lscal1, Lscal2, RC ) // 'and contain the name/value pair, e.g. xyz+"ens"=3' idx = INDEX( TRIM(str2), '=' ) IF ( idx <= 0 ) THEN - CALL HCO_ERROR( MSG, RC, THISLOC=LOC ) + CALL HCO_Error( msg, RC, thisLoc=LOC ) RETURN ENDIF @@ -4468,7 +4530,7 @@ SUBROUTINE ExtractSrcDim( HcoConfig, SrcDim, Dta, Lscal1, Lscal2, RC ) WRITE(MSG,*) 'Will use additional dimension on file ', & TRIM(Dta%ncFile), ': ', TRIM(Dta%ArbDimName), ' = ', & TRIM(Dta%ArbDimVal) - CALL HCO_MSG(HcoConfig%Err,MSG) + CALL HCO_Msg( HcoConfig%Err, msg ) ENDIF ENDIF @@ -4511,6 +4573,8 @@ SUBROUTINE ConfigInit ( HcoConfig, RC, nModelSpecies ) ! !LOCAL VARIABLES: ! INTEGER :: I, AS + CHARACTER(LEN=255) :: thisLoc + CHARACTER(LEN=512) :: errMsg !===================================================================== ! ConfigInit begins here! @@ -4528,12 +4592,17 @@ SUBROUTINE ConfigInit ( HcoConfig, RC, nModelSpecies ) IF ( PRESENT( nModelSpecies ) ) THEN + ! Initialize strings + errMsg = '' + thisLoc = 'ConfigInit (in module hco_config_mod.F90)' + ! Initialize vector w/ species information HcoConfig%nModelSpc = nModelSpecies IF ( nModelSpecies > 0 ) THEN ALLOCATE ( HcoConfig%ModelSpc( nModelSpecies ), STAT=AS ) IF ( AS /= 0 ) THEN - CALL HCO_ERROR( 'ModelSpecies', RC ) + errMsg = 'Could not allocate "ModelSpecies" array!' + CALL HCO_Error( errMsg, RC, thisLoc ) RETURN ENDIF @@ -4658,14 +4727,17 @@ Subroutine CheckForDuplicateName( HcoConfig, cName, RC ) ! TYPE(ListCont), POINTER :: ThisLct => NULL() LOGICAL :: Duplicate - CHARACTER(LEN=255) :: tmpName, MSG + CHARACTER(LEN=255) :: tmpName, thisLoc + CHARACTER(LEN=512) :: errMsg !====================================================================== ! CheckForDuplicateName begins here! !====================================================================== ! Init - RC = HCO_SUCCESS + RC = HCO_SUCCESS + errMsg = '' + thisLoc = 'CheckForDuplicateName (in module hco_config_mod.F90)' Duplicate = .FALSE. ! Pass name to clear spaces @@ -4692,8 +4764,8 @@ Subroutine CheckForDuplicateName( HcoConfig, cName, RC ) ENDDO IF ( Duplicate ) THEN - MSG = 'Error: HEMCO field already exists:'//TRIM(cName) - CALL HCO_ERROR ( MSG, RC ) + errMsg = 'Error: HEMCO field already exists:'//TRIM(cName) + CALL HCO_Error( errMsg, RC, thisLoc ) RETURN ENDIF @@ -4748,14 +4820,16 @@ SUBROUTINE Hco_GetTagInfo( tagID, HcoConfig, Found, & LOGICAL :: isNumTags, isTagName, isN ! Strings - CHARACTER(LEN=255) :: ErrMsg, ThisLoc, Nstr + CHARACTER(LEN=255) :: thisLoc, Nstr + CHARACTER(LEN=512) :: errMsg !======================================================================= ! Hco_GetTagInfo begins here !======================================================================= ! Initialize - ErrMsg = '' + errMsg = '' + thisLoc = 'Hco_Get_TagInfo (in module hco_config_mod.F90)' Found = .TRUE. numTags = 0 @@ -4767,7 +4841,7 @@ SUBROUTINE Hco_GetTagInfo( tagID, HcoConfig, Found, & ! Exit with error if getting tag name but index not specified IF ( isTagName .AND. .NOT. isN ) THEN ErrMsg = 'Index must be specified if retrieving an individual tag name' - CALL HCO_ERROR( ErrMsg, RC ) + CALL HCO_Error( errMsg, RC, thisLoc ) RETURN ENDIF @@ -4783,7 +4857,7 @@ SUBROUTINE Hco_GetTagInfo( tagID, HcoConfig, Found, & FOUND = .FALSE. ErrMsg = 'Handling of tagId ' // TRIM(tagId) // & ' is not implemented for getting number of tags' - CALL HCO_Error( ErrMsg, RC ) + CALL HCO_Error( errMsg, RC, thisLoc ) RETURN END SELECT @@ -4799,9 +4873,10 @@ SUBROUTINE Hco_GetTagInfo( tagID, HcoConfig, Found, & ! Exit with error if index exceeds number of tags for this wildcard IF ( isTagName .AND. .NOT. isN ) THEN - ErrMsg = 'Index must be greater than total number of tags for wildcard' & - // TRIM(tagId) - CALL HCO_Error( ErrMsg, RC ) + errMsg = & + 'Index must be greater than total number of tags for wildcard' & + // TRIM(tagId) + CALL HCO_Error( errMsg, RC, thisLoc ) RETURN ENDIF @@ -4813,9 +4888,9 @@ SUBROUTINE Hco_GetTagInfo( tagID, HcoConfig, Found, & D = N CASE DEFAULT FOUND = .FALSE. - ErrMsg = 'Handling of tagId ' // TRIM( tagId ) // & + errMsg = 'Handling of tagId ' // TRIM( tagId ) // & ' is not implemented for getting tag name' - CALL HCO_Error( ErrMsg, RC ) + CALL HCO_Error( errMsg, RC, thisLoc ) RETURN END SELECT @@ -5077,7 +5152,7 @@ SUBROUTINE UpdateDtaProperties( char1, char2, dctType, int3, & CALL ScalID2List( HcoConfig%ScalIDList, Lct%Dct%ScalID, RC ) IF ( RC /= HCO_SUCCESS ) THEN errMsg = 'Error encountered in routine "ScalID2List"!' - CALL HCO_ERROR( errMsg, RC, thisLoc ) + CALL HCO_Error( errMsg, RC, thisLoc ) RETURN ENDIF ENDIF