Skip to content

Commit

Permalink
Fix issue wih inconsistent serialize/deserialize buffer indexing in C…
Browse files Browse the repository at this point in the history
… and Fortran.
  • Loading branch information
oehmke committed Nov 8, 2024
1 parent 3879274 commit aaab4a6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Superstructure/StateReconcile/src/ESMF_StateReconcile.F90
Original file line number Diff line number Diff line change
@@ -1840,7 +1840,7 @@ subroutine ESMF_ReconcileSingleCompCase(state, vm, vmId, attreconflag, siwrap, r
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return

if (localPet/=rootPet) allocate(buffer(sizeBuffer(1)))
if (localPet/=rootPet) allocate(buffer(0:sizeBuffer(1)-1))

call ESMF_VMBroadcast(vm, buffer, count=sizeBuffer(1), rootPet=rootPet, &
rc=localrc)
@@ -2591,7 +2591,7 @@ subroutine ESMF_ReconcileDeserializeAll(state, vm, buffer, attreconflag, rc)
rcToReturn=rc)) return

! Set start position of buffer
posBuffer = 1
posBuffer = 0

! Get the number of items to add
numNewItems = transfer ( &
@@ -4485,7 +4485,7 @@ subroutine ESMF_ReconcileSerializeAll(state, vm, vmid, siwrap, &
sizeBuffer=ESMF_SIZEOF_DEFINT

! Allocate a fake buffer for passing in when asking for size
allocate(fakeBuffer(ESMF_SIZEOF_DEFINT))
allocate(fakeBuffer(0:ESMF_SIZEOF_DEFINT-1))

! Fake buffer size
sizeFakeBuffer=size(fakeBuffer)
@@ -4658,7 +4658,7 @@ subroutine ESMF_ReconcileSerializeAll(state, vm, vmid, siwrap, &
deallocate(fakeBuffer)

!!!!! Allocate buffer to serialize into !!!!!
allocate(buffer(sizeBuffer), stat=memstat)
allocate(buffer(0:sizeBuffer-1), stat=memstat)
if (ESMF_LogFoundAllocError(memstat, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, &
rcToReturn=rc)) return
@@ -4667,12 +4667,12 @@ subroutine ESMF_ReconcileSerializeAll(state, vm, vmid, siwrap, &
!!!!! Serialize information into buffer !!!!!

! Start position of buffer
posBuffer = 1
posBuffer = 0

! Put item count in buffer
buffer(posBuffer:posBuffer+ESMF_SIZEOF_DEFINT-1) = transfer ( &
source=numStateItems, &
mold=buffer(1:ESMF_SIZEOF_DEFINT))
mold=buffer(0:ESMF_SIZEOF_DEFINT-1))
posBuffer = posbuffer + ESMF_SIZEOF_DEFINT

! Set flag to actually serialize
@@ -4690,7 +4690,7 @@ subroutine ESMF_ReconcileSerializeAll(state, vm, vmid, siwrap, &
! Add item type to buffer
buffer(posBuffer:posBuffer+ESMF_SIZEOF_DEFINT-1) = transfer (&
source=itemType, &
mold =buffer(1:ESMF_SIZEOF_DEFINT))
mold =buffer(0:ESMF_SIZEOF_DEFINT-1))
posBuffer = posbuffer + ESMF_SIZEOF_DEFINT

! Add serialized items

0 comments on commit aaab4a6

Please sign in to comment.