From 35365b5a888e6781d125faaefd20538cb8bd846d Mon Sep 17 00:00:00 2001 From: Lizzie Lundgren Date: Fri, 21 Jul 2023 16:35:52 -0400 Subject: [PATCH] Fix bug introduced by prior commit of blocking prints to root thread only This update fixes a problem where the simulation will crash in the volcano extension init subroutine on non-root threads if the volcano extension is turned off, such as in the transport tracer simulation. The fix moves the return if extension number is zero to directly after the call to retrieve extension number. This is the same handling as all other HEMCO extension initialization routines. Signed-off-by: Lizzie Lundgren --- src/Extensions/hcox_volcano_mod.F90 | 36 +++++++++++------------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/Extensions/hcox_volcano_mod.F90 b/src/Extensions/hcox_volcano_mod.F90 index 2c6f8b59..1dc9841a 100644 --- a/src/Extensions/hcox_volcano_mod.F90 +++ b/src/Extensions/hcox_volcano_mod.F90 @@ -354,23 +354,7 @@ SUBROUTINE HCOX_Volcano_Init( HcoState, ExtName,ExtState, RC ) ! Extension Nr. ExtNr = GetExtNr( HcoState%Config%ExtList, TRIM(ExtName) ) - - ! Print to log - IF ( HcoState%amIRoot ) THEN - IF ( ExtNr > 0 ) THEN - ! Write the name of the extension regardless of the verbose setting - msg = 'Using HEMCO extension: Volcano (volcanic SO2 emissions)' - IF ( HCO_IsVerb( HcoState%Config%Err ) ) THEN - CALL HCO_Msg( HcoState%Config%Err, msg, sep1='-' ) ! with separator - ELSE - CALL HCO_Msg( msg, verb=.TRUE. ) ! w/o separator - ENDIF - ELSE - MSG = 'The Volcano extension is turned off.' - CALL HCO_MSG( HcoState%Config%Err, MSG ) - RETURN - ENDIF - ENDIF + IF ( ExtNr <= 0 ) RETURN ! Enter CALL HCO_ENTER( HcoState%Config%Err, LOC, RC ) @@ -379,15 +363,24 @@ SUBROUTINE HCOX_Volcano_Init( HcoState, ExtName,ExtState, RC ) RETURN ENDIF - ! Create Volcano instance for this simulation + ! Create instance for this simulation Inst => NULL() CALL InstCreate( ExtNr, ExtState%Volcano, Inst, RC ) IF ( RC /= HCO_SUCCESS ) THEN - CALL HCO_Error( & - 'Cannot create Volcano instance', RC ) + CALL HCO_Error( 'Cannot create Volcano instance', RC ) RETURN ENDIF + ! Write the name of the extension regardless of the verbose settings + IF ( HcoState%amIRoot ) THEN + msg = 'Using HEMCO extension: Volcano (volcanic SO2 emissions)' + IF ( HCO_IsVerb( HcoState%Config%Err ) ) THEN + CALL HCO_Msg( HcoState%Config%Err, msg, sep1='-' ) ! with separator + ELSE + CALL HCO_Msg( msg, verb=.TRUE. ) ! w/o separator + ENDIF + ENDIF + ! Get species IDs. CALL HCO_GetExtHcoID( HcoState, ExtNr, Inst%SpcIDs, & SpcNames, Inst%nSpc, RC ) @@ -483,9 +476,6 @@ SUBROUTINE HCOX_Volcano_Init( HcoState, ExtName,ExtState, RC ) ! Verbose mode IF ( HcoState%amIRoot ) THEN - MSG = 'Use emissions extension `Volcano`:' - CALL HCO_MSG( HcoState%Config%Err, MSG ) - MSG = ' - use the following species (Name, HcoID, Scaling relative to kgS):' CALL HCO_MSG( HcoState%Config%Err, MSG) DO N = 1, Inst%nSpc