Skip to content

Commit 5c4f6ab

Browse files
committed
More places for the LLVM workaround when dealing with Fortran pointers
inside Fortran derived types that are handed through the C/C++ layer.
1 parent 1241096 commit 5c4f6ab

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

src/Infrastructure/Util/src/ESMF_FortranWordsize.cppF90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,11 @@ subroutine f_esmf_fortranudtpointercompare(ptr1, ptr2, flag)
288288
type (wrapper):: ptr1
289289
type (wrapper):: ptr2
290290
integer :: flag
291+
type(simple_udt), pointer:: udt1, udt2
292+
udt1 => ptr1%udt
293+
udt2 => ptr2%udt
291294
flag = 0
292-
if (associated(ptr1%udt,ptr2%udt)) flag = 1
295+
if (associated(udt1,udt2)) flag = 1
293296
end subroutine
294297

295298

src/addon/NUOPC/src/NUOPC_Connector.F90

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5290,10 +5290,10 @@ subroutine InitializeIPDv05p6b(connector, importState, exportState, clock, rc)
52905290
line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out
52915291

52925292
! prepare FieldBundles to store src and dst Fields
5293-
is%wrap%srcFields = ESMF_FieldBundleCreate(rc=rc)
5293+
is%wrap%srcFields = ESMF_FieldBundleCreate(name="srcFields", rc=rc)
52945294
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
52955295
line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out
5296-
is%wrap%dstFields = ESMF_FieldBundleCreate(rc=rc)
5296+
is%wrap%dstFields = ESMF_FieldBundleCreate(name="dstFields", rc=rc)
52975297
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
52985298
line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out
52995299

@@ -6621,6 +6621,7 @@ subroutine Finalize(connector, importState, exportState, clock, rc)
66216621
character(*), parameter :: rName="Finalize"
66226622
integer :: stat
66236623
type(type_InternalState) :: is
6624+
type(type_InternalStateStruct), pointer :: wrap
66246625
integer :: localrc
66256626
logical :: existflag
66266627
logical :: routeHandleIsCreated
@@ -6867,14 +6868,15 @@ subroutine Finalize(connector, importState, exportState, clock, rc)
68676868
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &
68686869
return ! bail out
68696870
endif
6870-
6871+
68716872
! deallocate internal state memory
6872-
deallocate(is%wrap, stat=stat)
6873+
wrap => is%wrap
6874+
deallocate(wrap, stat=stat)
68736875
if (ESMF_LogFoundDeallocError(statusToCheck=stat, &
68746876
msg="Deallocation of internal state memory failed.", &
68756877
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &
68766878
return ! bail out
6877-
6879+
68786880
! handle diagnostic
68796881
if (btest(diagnostic,10)) then
68806882
call NUOPC_Write(importState, fileNamePrefix="diagnostic_"//&

src/addon/NUOPC/src/NUOPC_Driver.F90

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3939,10 +3939,13 @@ recursive subroutine Finalize(driver, importState, exportState, clock, rc)
39393939
character(*), parameter :: rName="Finalize"
39403940
integer :: urc, stat
39413941
type(type_InternalState) :: is
3942+
type(type_InternalStateStruct), pointer :: wrap
39423943
type(ESMF_Clock) :: internalClock
39433944
integer :: i, j, itemCount
39443945
type(ComponentMapEntry) :: cmEntry
3946+
type(ComponentMapEntryT), pointer :: cmWrap
39453947
type(ConnectorMapEntry) :: cnEntry
3948+
type(ConnectorMapEntryT), pointer :: cnWrap
39463949
character(ESMF_MAXSTR) :: iString, jString
39473950
logical :: existflag
39483951
logical :: areServicesSet
@@ -4218,7 +4221,8 @@ recursive subroutine Finalize(driver, importState, exportState, clock, rc)
42184221
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
42194222
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &
42204223
return ! bail out
4221-
deallocate(cmEntry%wrap, stat=stat)
4224+
cmWrap => cmEntry%wrap
4225+
deallocate(cmWrap, stat=stat)
42224226
if (ESMF_LogFoundDeallocError(statusToCheck=stat, &
42234227
msg="Deallocation of cmEntry failed.", &
42244228
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &
@@ -4239,7 +4243,8 @@ recursive subroutine Finalize(driver, importState, exportState, clock, rc)
42394243
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
42404244
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &
42414245
return ! bail out
4242-
deallocate(cnEntry%wrap, stat=stat)
4246+
cnWrap => cnEntry%wrap
4247+
deallocate(cnWrap, stat=stat)
42434248
if (ESMF_LogFoundDeallocError(statusToCheck=stat, &
42444249
msg="Deallocation of cnEntry failed.", &
42454250
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &
@@ -4294,7 +4299,8 @@ recursive subroutine Finalize(driver, importState, exportState, clock, rc)
42944299
line=__LINE__, file=trim(name)//":"//FILENAME)) return ! bail out
42954300

42964301
! deallocate internal state memory
4297-
deallocate(is%wrap, stat=stat)
4302+
wrap => is%wrap
4303+
deallocate(wrap, stat=stat)
42984304
if (ESMF_LogFoundDeallocError(statusToCheck=stat, &
42994305
msg="Deallocation of internal state memory failed.", &
43004306
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &

src/addon/NUOPC/src/NUOPC_ModelBase.F90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2392,6 +2392,7 @@ recursive subroutine Finalize(gcomp, importState, exportState, clock, rc)
23922392
type(ESMF_Clock) :: internalClock
23932393
integer :: verbosity, diagnostic, profiling
23942394
type(type_InternalState) :: is
2395+
type(type_InternalStateStruct), pointer :: wrap
23952396
type(ESMF_Time) :: currTime
23962397
character(len=40) :: currTimeString
23972398

@@ -2519,7 +2520,8 @@ recursive subroutine Finalize(gcomp, importState, exportState, clock, rc)
25192520
deallocate(is%wrap%cachedExportFieldList)
25202521

25212522
! deallocate internal state memory
2522-
deallocate(is%wrap, stat=stat)
2523+
wrap => is%wrap
2524+
deallocate(wrap, stat=stat)
25232525
if (ESMF_LogFoundDeallocError(statusToCheck=stat, &
25242526
msg="Deallocation of internal state memory failed.", &
25252527
line=__LINE__, file=trim(name)//":"//FILENAME, rcToReturn=rc)) &

0 commit comments

Comments
 (0)