Skip to content

Commit db4dc08

Browse files
committed
Merge branch 'fix/llvm' into develop
2 parents ee2798f + a9e8403 commit db4dc08

File tree

19 files changed

+131
-71
lines changed

19 files changed

+131
-71
lines changed

src/Infrastructure/Container/tests/ESMF_ContainerUTest.F90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ program ESMF_ContainerUTest
8181
integer :: garbageCount, itemCount
8282
logical :: isPresent, loopResult
8383
type(TestType) :: tt
84-
84+
type(TestTypeStruct), pointer :: wrap
85+
8586
!-------------------------------------------------------------------------------
8687
! The unit tests are divided into Sanity and Exhaustive. The Sanity tests are
8788
! always run. When the environment variable, EXHAUSTIVE, is set to ON then
@@ -1100,7 +1101,8 @@ program ESMF_ContainerUTest
11001101
loopResult = .false.
11011102
exit
11021103
endif
1103-
deallocate(tt%wrap, stat=stat)
1104+
wrap => tt%wrap ! LLVM workaround for deallocate() runtime error!
1105+
deallocate(wrap, stat=stat)
11041106
if (stat/=0) then
11051107
loopResult = .false.
11061108
exit

src/Infrastructure/Field/interface/ESMF_Field_C.F90

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -736,27 +736,30 @@ subroutine f_esmf_fieldcollectgarbage(field, rc)
736736

737737
type(ESMF_Field) :: field
738738
integer, intent(out) :: rc
739-
739+
740+
type(ESMF_FieldType), pointer :: ftypepp
740741
integer :: localrc
741-
742+
742743
! initialize return code; assume routine not implemented
743744
localrc = ESMF_RC_NOT_IMPL
744745
rc = ESMF_RC_NOT_IMPL
745-
746+
746747
!print *, "collecting Field garbage"
747748

748-
if (associated(field%ftypep)) then
749+
ftypepp => field%ftypep ! LLVM workaround for deallocate() runtime error!
750+
751+
if (associated(ftypepp)) then
749752
! destruct internal data allocations
750-
call ESMF_FieldDestruct(field%ftypep, rc=localrc)
753+
call ESMF_FieldDestruct(ftypepp, rc=localrc)
751754
if (ESMF_LogFoundError(localrc, &
752755
ESMF_ERR_PASSTHRU, &
753756
ESMF_CONTEXT, rcToReturn=rc)) return
754757
! deallocate actual FieldType allocation
755-
!print *, "deallocate(field%ftypep)"
756-
deallocate(field%ftypep, stat=localrc)
758+
deallocate(ftypepp, stat=localrc)
757759
if (ESMF_LogFoundDeallocError(localrc, msg="Deallocating Field", &
758760
ESMF_CONTEXT, rcToReturn=rc)) return
759761
endif
762+
760763
nullify(field%ftypep)
761764

762765
! return successfully

src/Infrastructure/FieldBundle/interface/ESMF_FieldBundle_C.F90

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,32 @@ subroutine f_esmf_fbundlecollectgarbage(fb, rc)
7878

7979
type(ESMF_FieldBundle):: fb
8080
integer, intent(out) :: rc
81-
81+
82+
type(ESMF_FieldBundleType), pointer :: fbpp
8283
integer :: localrc
83-
84+
8485
! initialize return code; assume routine not implemented
8586
localrc = ESMF_RC_NOT_IMPL
8687
rc = ESMF_RC_NOT_IMPL
8788

8889
!print *, "collecting FieldBundle garbage"
89-
90-
if (associated(fb%this)) then
90+
91+
fbpp => fb%this ! LLVM workaround for deallocate() runtime error!
92+
93+
if (associated(fbpp)) then
9194
! destruct internal data allocations
92-
call ESMF_FieldBundleDestruct(fb%this, localrc)
95+
call ESMF_FieldBundleDestruct(fbpp, rc=localrc)
9396
if (ESMF_LogFoundError(localrc, &
9497
ESMF_ERR_PASSTHRU, &
9598
ESMF_CONTEXT, &
9699
rcToReturn=rc)) return
97100
! deallocate actual FieldBundleType allocation
98-
deallocate(fb%this, stat=localrc)
101+
deallocate(fbpp, stat=localrc)
99102
if (ESMF_LogFoundDeallocError(localrc, msg="Deallocating FieldBundle", &
100103
ESMF_CONTEXT, &
101104
rcToReturn=rc)) return
102105
endif
106+
103107
nullify(fb%this)
104108

105109
! return successfully

src/Infrastructure/LocStream/interface/ESMF_LocStream_C.F90

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,28 +195,32 @@ subroutine f_esmf_locstreamcollectgarbage(locstream, rc)
195195
implicit none
196196

197197
type(ESMF_LocStream) :: locstream
198-
integer, intent(out) :: rc
199-
200-
integer :: localrc
201-
198+
integer, intent(out) :: rc
199+
200+
type(ESMF_LocStreamType), pointer :: lspp
201+
integer :: localrc
202+
202203
! initialize return code; assume routine not implemented
203204
localrc = ESMF_RC_NOT_IMPL
204205
rc = ESMF_RC_NOT_IMPL
205-
206+
206207
!print *, "collecting LocStream garbage"
207-
208+
209+
lspp => locstream%lstypep ! LLVM workaround for deallocate() runtime error!
210+
208211
! destruct internal data allocations
209-
call ESMF_LocStreamDestruct(locstream%lstypep, rc=localrc)
212+
call ESMF_LocStreamDestruct(lspp, rc=localrc)
210213
if (ESMF_LogFoundError(localrc, &
211214
ESMF_ERR_PASSTHRU, &
212215
ESMF_CONTEXT, rcToReturn=rc)) return
213216

214217
! deallocate actual LocStreamType allocation
215-
if (associated(locstream%lstypep)) then
216-
deallocate(locstream%lstypep, stat=localrc)
218+
if (associated(lspp)) then
219+
deallocate(lspp, stat=localrc)
217220
if (ESMF_LogFoundDeallocError(localrc, msg="Deallocating LocStream", &
218221
ESMF_CONTEXT, rcToReturn=rc)) return
219222
endif
223+
220224
nullify(locstream%lstypep)
221225

222226
! return successfully

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 ! LLVM workaround, require local pointer variable!
293+
udt2 => ptr2%udt ! LLVM workaround, require local pointer variable!
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/Infrastructure/XGridGeomBase/src/ESMF_XGridGeomBase.F90

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ subroutine f_esmf_xgridgeombasecolgarbage(gb, rc)
13621362
type(ESMF_XGridGeomBase) :: gb
13631363
integer, intent(out) :: rc
13641364

1365+
type(ESMF_XGridGeomBaseClass), pointer :: gbcpp
13651366
integer :: localrc
13661367

13671368
! initialize return code; assume routine not implemented
@@ -1370,12 +1371,15 @@ subroutine f_esmf_xgridgeombasecolgarbage(gb, rc)
13701371

13711372
!print *, "collecting GeomBase garbage"
13721373

1374+
gbcpp => gb%gbcp ! LLVM workaround for deallocate() runtime error!
1375+
13731376
! deallocate actual GeomBaseClass allocation
1374-
if (associated(gb%gbcp)) then
1375-
deallocate(gb%gbcp, stat=localrc)
1377+
if (associated(gbcpp)) then
1378+
deallocate(gbcpp, stat=localrc)
13761379
if (ESMF_LogFoundAllocError(localrc, msg="Deallocating GeomBase", &
13771380
ESMF_CONTEXT, rcToReturn=rc)) return
13781381
endif
1382+
13791383
nullify(gb%gbcp)
13801384

13811385
! return successfully

src/Superstructure/Component/interface/ESMF_Comp_C.F90

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ recursive subroutine f_esmf_compcollectgarbage2(comp, rc)
491491
type(ESMF_CWrap) :: comp
492492
integer, intent(out) :: rc
493493

494+
type(ESMF_CompClass), pointer :: comppp
494495
integer :: localrc
495496
integer :: timeout
496497
logical :: timeoutFlag
@@ -501,22 +502,25 @@ recursive subroutine f_esmf_compcollectgarbage2(comp, rc)
501502

502503
!print *, "collecting Component garbage #2"
503504

505+
comppp => comp%compp ! LLVM workaround for deallocate() runtime error!
506+
504507
! destruct internal data allocations and perform full shut down, making this
505508
! call collective on some MPI implementations
506509
timeout = 10 ! allow for 10s timeout
507510
! calling with 'timeoutFlag' prevents timeout to propagate as error condition
508-
call ESMF_CompDestruct(comp%compp, interCompComm=.false., &
511+
call ESMF_CompDestruct(comppp, interCompComm=.false., &
509512
fullShutdown=.true., timeout=timeout, timeoutFlag=timeoutFlag, rc=localrc)
510513
if (ESMF_LogFoundError(localrc, &
511514
ESMF_ERR_PASSTHRU, &
512515
ESMF_CONTEXT, rcToReturn=rc)) return
513516

514517
! deallocate actual CompClass allocation
515-
if (associated(comp%compp)) then
516-
deallocate(comp%compp, stat=localrc)
518+
if (associated(comppp)) then
519+
deallocate(comppp, stat=localrc)
517520
if (ESMF_LogFoundDeallocError(localrc, msg="Deallocating Comp", &
518521
ESMF_CONTEXT, rcToReturn=rc)) return
519522
endif
523+
520524
nullify(comp%compp)
521525

522526
! return successfully

src/Superstructure/InternalState/examples/ESMF_InternalStateEx.F90

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ program ESMF_InternalStateEx
5454
end type
5555

5656
type(dataWrapper) :: wrap
57+
type(testData), pointer :: p
5758
character(len=:), allocatable :: labelList(:)
5859
!EOC
5960
integer :: result
@@ -129,7 +130,8 @@ program ESMF_InternalStateEx
129130
endif
130131

131132
! Deallocate the private data block
132-
deallocate(wrap%p)
133+
p => wrap%p ! LLVM workaround for deallocate() runtime error!
134+
deallocate(p)
133135

134136
!EOC
135137
!-------------------------------------------------------------------------
@@ -192,15 +194,17 @@ program ESMF_InternalStateEx
192194
if (rc .ne. ESMF_SUCCESS) finalrc = ESMF_FAILURE
193195

194196
! Deallocate the private data block
195-
deallocate(wrap%p)
197+
p => wrap%p ! LLVM workaround for deallocate() runtime error!
198+
deallocate(p)
196199

197200
! Get Internal State
198201
call ESMF_InternalStateGet(comp, internalState=wrap, &
199202
label="second named data block", rc=rc)
200203
if (rc .ne. ESMF_SUCCESS) finalrc = ESMF_FAILURE
201204

202205
! Deallocate the private data block
203-
deallocate(wrap%p)
206+
p => wrap%p ! LLVM workaround for deallocate() runtime error!
207+
deallocate(p)
204208

205209
!EOC
206210

src/Superstructure/InternalState/tests/ESMF_InternalStateUTest.F90

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ program ESMF_InternalStateUTest
5555
end type
5656

5757
type(dataWrapper) :: wrapAdd, wrapGet
58+
type(testData), pointer :: p
5859
character(len=:), allocatable :: labelList(:)
5960
logical :: isValid
6061

@@ -232,7 +233,8 @@ program ESMF_InternalStateUTest
232233
call ESMF_Test((isValid), name, failMsg, result, ESMF_SRCLINE)
233234

234235
! deallocate InternalState data
235-
deallocate(wrapGet%p)
236+
p => wrapGet%p ! LLVM workaround for deallocate() runtime error!
237+
deallocate(p)
236238

237239
!------------------------------------------------------------------------
238240
!NEX_UTest
@@ -250,7 +252,8 @@ program ESMF_InternalStateUTest
250252
call ESMF_Test((isValid), name, failMsg, result, ESMF_SRCLINE)
251253

252254
! deallocate InternalState data
253-
deallocate(wrapGet%p)
255+
p => wrapGet%p ! LLVM workaround for deallocate() runtime error!
256+
deallocate(p)
254257

255258
!------------------------------------------------------------------------
256259
!NEX_UTest
@@ -268,7 +271,8 @@ program ESMF_InternalStateUTest
268271
call ESMF_Test((isValid), name, failMsg, result, ESMF_SRCLINE)
269272

270273
! deallocate InternalState data
271-
deallocate(wrapGet%p)
274+
p => wrapGet%p ! LLVM workaround for deallocate() runtime error!
275+
deallocate(p)
272276

273277
!------------------------------------------------------------------------
274278
!NEX_UTest

src/Superstructure/State/interface/ESMF_State_C.F90

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -455,34 +455,38 @@ subroutine f_esmf_statecollectgarbage(state, rc)
455455
use ESMF_LogErrMod
456456
use ESMF_StateTypesMod
457457
use ESMF_StateMod
458-
458+
459459
implicit none
460-
460+
461461
type(ESMF_State) :: state
462462
integer, intent(out) :: rc
463-
463+
464+
type(ESMF_StateClass), pointer :: statepp
464465
integer :: localrc
465-
466+
466467
! initialize return code; assume routine not implemented
467468
localrc = ESMF_RC_NOT_IMPL
468469
rc = ESMF_RC_NOT_IMPL
469-
470+
470471
!print *, "collecting State garbage"
471472

472-
if (associated(state%statep)) then
473+
statepp => state%statep ! LLVM workaround for deallocate() runtime error!
474+
475+
if (associated(statepp)) then
473476
! destruct internal data allocations
474-
call ESMF_StateDestruct(state%statep, rc=localrc)
477+
call ESMF_StateDestruct(statepp, rc=localrc)
475478
if (ESMF_LogFoundError(localrc, &
476479
ESMF_ERR_PASSTHRU, &
477480
ESMF_CONTEXT, &
478481
rcToReturn=rc)) return
479482
! deallocate actual StateClass allocation
480-
deallocate(state%statep, stat=localrc)
483+
deallocate(statepp, stat=localrc)
481484
localrc = merge (ESMF_SUCCESS, ESMF_RC_MEM_DEALLOCATE, localrc == 0)
482485
if (ESMF_LogFoundDeallocError(localrc, msg="Deallocating State", &
483486
ESMF_CONTEXT, &
484487
rcToReturn=rc)) return
485488
endif
489+
486490
nullify(state%statep)
487491

488492
! return successfully

0 commit comments

Comments
 (0)