From 9f0ba2dff339e0b3065f131bf13e9434714c8884 Mon Sep 17 00:00:00 2001 From: Daniel Rosen Date: Thu, 31 Oct 2024 14:42:36 -0600 Subject: [PATCH] Fix issue #293 NUOPC_CompAttributeIngest failure --- src/addon/NUOPC/src/NUOPC_Comp.F90 | 49 ++++++++++++++++++------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/addon/NUOPC/src/NUOPC_Comp.F90 b/src/addon/NUOPC/src/NUOPC_Comp.F90 index 67d2d8a9d1..3dad246b11 100644 --- a/src/addon/NUOPC/src/NUOPC_Comp.F90 +++ b/src/addon/NUOPC/src/NUOPC_Comp.F90 @@ -1649,8 +1649,10 @@ subroutine NUOPC_GridCompAttributeIng(comp, freeFormat, addFlag, rc) character(ESMF_MAXSTR) :: name integer :: localrc integer :: stat - integer :: i, lineCount, tokenCount + integer :: i, j + integer :: lineCount, tokenCount character(len=NUOPC_FreeFormatLen), allocatable :: tokenList(:) + character(len=NUOPC_FreeFormatLen) :: value logical :: addFlagOpt logical :: isPresent @@ -1687,7 +1689,13 @@ subroutine NUOPC_GridCompAttributeIng(comp, freeFormat, addFlag, rc) return ! bail out ! process the configuration line - if (tokenCount == 3) then + if (tokenCount < 3) then + call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & + msg="Free format Attribute line incorrectly formatted.", & + line=__LINE__, & + file=trim(name)//":"//FILENAME, rcToReturn=rc) + return ! bail out + else if (trim(tokenList(2)) /= "=") then call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & msg="Free format Attribute line incorrectly formatted.", & @@ -1715,18 +1723,15 @@ subroutine NUOPC_GridCompAttributeIng(comp, freeFormat, addFlag, rc) return ! bail out endif endif + value=tokenList(3) + do j=4, tokenCount + value=trim(value)//" "//tokenList(j) + enddo call NUOPC_CompAttributeSet(comp, name=trim(tokenList(1)), & - value=trim(tokenList(3)), rc=localrc) + value=trim(value), rc=localrc) if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & return ! bail out - else - ! Just skip these lines for now.... - !call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & - ! msg="Free format Attribute line incorrectly formatted.", & - ! line=__LINE__, & - ! file=trim(name)//":"//FILENAME, rcToReturn=rc) - !return ! bail out endif ! clean-up @@ -1800,8 +1805,10 @@ subroutine NUOPC_CplCompAttributeIng(comp, freeFormat, addFlag, rc) character(ESMF_MAXSTR) :: name integer :: localrc integer :: stat - integer :: i, lineCount, tokenCount + integer :: i, j + integer :: lineCount, tokenCount character(len=NUOPC_FreeFormatLen), allocatable :: tokenList(:) + character(len=NUOPC_FreeFormatLen) :: value logical :: addFlagOpt logical :: isPresent @@ -1838,7 +1845,13 @@ subroutine NUOPC_CplCompAttributeIng(comp, freeFormat, addFlag, rc) return ! bail out ! process the configuration line - if (tokenCount == 3) then + if (tokenCount < 3) then + call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & + msg="Free format Attribute line incorrectly formatted.", & + line=__LINE__, & + file=trim(name)//":"//FILENAME, rcToReturn=rc) + return ! bail out + else if (trim(tokenList(2)) /= "=") then call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & msg="Free format Attribute line incorrectly formatted.", & @@ -1866,17 +1879,15 @@ subroutine NUOPC_CplCompAttributeIng(comp, freeFormat, addFlag, rc) return ! bail out endif endif + value=tokenList(3) + do j=4, tokenCount + value=trim(value)//" "//tokenList(j) + enddo call NUOPC_CompAttributeSet(comp, name=trim(tokenList(1)), & - value=trim(tokenList(3)), rc=localrc) + value=trim(value), rc=localrc) if (ESMF_LogFoundError(rcToCheck=localrc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) & return ! bail out - else - call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & - msg="Free format Attribute line incorrectly formatted.", & - line=__LINE__, & - file=trim(name)//":"//FILENAME, rcToReturn=rc) - return ! bail out endif ! clean-up