Skip to content

Commit

Permalink
Fix issue #293 NUOPC_CompAttributeIngest failure
Browse files Browse the repository at this point in the history
  • Loading branch information
danrosen25 committed Oct 31, 2024
1 parent d3d6090 commit 9f0ba2d
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions src/addon/NUOPC/src/NUOPC_Comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.", &
Expand Down Expand Up @@ -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
Expand Down Expand 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

Expand Down Expand Up @@ -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.", &
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9f0ba2d

Please sign in to comment.