Locks for particle lists are now inside the type.

The lock of a particle list is no longer an external variable, it is now
part of the type.

New procedures have been added to set and unset the lock.
This commit is contained in:
Jorge Gonzalez 2022-12-31 11:22:02 +01:00
commit 8199a228c8
5 changed files with 39 additions and 16 deletions

View file

@ -612,7 +612,7 @@ MODULE moduleInput
nPartOld = 0
!Initialize the lock for the non-analogue (NA) list of particles
CALL OMP_INIT_LOCK(lockWScheme)
CALL OMP_INIT_LOCK(partWScheme%lock)
END SUBROUTINE readSpecies
@ -676,7 +676,7 @@ MODULE moduleInput
CALL config%get('interactions.folderCollisions', pathCollisions, found)
!Inits lock for list of particles
CALL OMP_INIT_LOCK(lockCollisions)
CALL OMP_INIT_LOCK(partCollisions%lock)
CALL config%info('interactions.collisions', found, n_children = nPairs)
DO i = 1, nPairs
@ -770,6 +770,7 @@ MODULE moduleInput
USE moduleErrors
USE moduleSpecies
USE moduleRefParam
USE moduleList, ONLY: partSurfaces
USE json_module
IMPLICIT NONE
@ -862,6 +863,9 @@ MODULE moduleInput
END DO
!Init the list of particles from surfaces
CALL OMP_INIT_LOCK(partSurfaces%lock)
END SUBROUTINE readBoundary
!Read the geometry (mesh) for the case

View file

@ -169,10 +169,10 @@ MODULE moduleMeshBoundary
newIon%n_in = .TRUE.
!Add particles to list
CALL OMP_SET_LOCK(lockSurfaces)
CALL partSurfaces%setLock()
CALL partSurfaces%add(newElectron)
CALL partSurfaces%add(newIon)
CALL OMP_UNSET_LOCK(lockSurfaces)
CALL partSurfaces%unsetLock()
!Electron loses energy due to ionization
eRel = eRel - bound%eThreshold

View file

@ -347,7 +347,6 @@ MODULE moduleCollisions
ELSEIF (electron%weight < neutral%weight) THEN
!If primary electron is ligther than neutral, change weight of neutral and create new neutral
ALLOCATE(remainingNeutral)
PRINT *, "ionize"
remainingNeutral = neutral
@ -369,13 +368,13 @@ MODULE moduleCollisions
END SELECT
!Adds new particles to the list
CALL OMP_SET_LOCK(lockCollisions)
CALL partCollisions%setLock()
CALL partCollisions%add(newElectron)
IF (ASSOCIATED(remainingNeutral)) THEN
CALL partCollisions%add(remainingNeutral)
END IF
CALL OMP_UNSET_LOCK(lockCollisions)
CALL partCollisions%unsetLock()
END IF
@ -495,9 +494,9 @@ MODULE moduleCollisions
!Adds new particles to the list
IF (ASSOCIATED(remainingIon)) THEN
CALL OMP_SET_LOCK(lockCollisions)
CALL partCollisions%setLock()
CALL partCollisions%add(remainingIon)
CALL OMP_UNSET_LOCK(lockCollisions)
CALL partCollisions%unsetLock()
END IF
END SUBROUTINE collideBinaryRecombination

View file

@ -13,19 +13,19 @@ MODULE moduleList
INTEGER:: amount = 0
TYPE(lNode),POINTER:: head => NULL()
TYPE(lNode),POINTER:: tail => NULL()
INTEGER(KIND=OMP_LOCK_KIND):: lock
CONTAINS
PROCEDURE,PASS:: add => addToList
PROCEDURE,PASS:: convert2Array
PROCEDURE,PASS:: erase => eraseList
PROCEDURE,PASS:: setLock
PROCEDURE,PASS:: unsetLock
END TYPE listNode
TYPE(listNode):: partWScheme !Particles comming from the nonAnalogue scheme
INTEGER(KIND=OMP_LOCK_KIND):: lockWScheme !Lock for the NA list of particles
TYPE(listNode):: partCollisions !Particles created in collisional process
INTEGER(KIND=OMP_LOCK_KIND):: lockCollisions !Lock for the NA list of particles
TYPE(listNode):: partSurfaces !Particles created in surface interactions
INTEGER(KIND=OMP_LOCK_KIND):: lockSurfaces !Lock for the NA list of particles
TYPE(listNode):: partInitial !Initial distribution of particles
TYPE pointerArray
@ -80,8 +80,10 @@ MODULE moduleList
END FUNCTION convert2Array
!Erase list
SUBROUTINE eraseList(self)
CLASS(listNode):: self
PURE SUBROUTINE eraseList(self)
IMPLICIT NONE
CLASS(listNode), INTENT(inout):: self
TYPE(lNode),POINTER:: current, next
current => self%head
@ -95,4 +97,22 @@ MODULE moduleList
self%amount = 0
END SUBROUTINE eraseList
SUBROUTINE setLock(self)
USE OMP_LIB
IMPLICIT NONE
CLASS(listNode):: self
CALL OMP_SET_LOCK(self%lock)
END SUBROUTINE setLock
SUBROUTINE unsetLock(self)
USE OMP_LIB
IMPLICIT NONE
CLASS(listNode):: self
CALL OMP_UNSET_LOCK(self%lock)
END SUBROUTINE unsetLock
END MODULE moduleList

View file

@ -434,9 +434,9 @@ MODULE moduleSolver
!Copy data from original particle
newPart = part
!Add particle to list of new particles from weighting scheme
CALL OMP_SET_LOCK(lockWScheme)
CALL partWScheme%setLock()
CALL partWScheme%add(newPart)
CALL OMP_UNSET_LOCK(lockWScheme)
CALL partWScheme%unsetLock()
!Add particle to cell list
CALL OMP_SET_lock(vol%lock)
sp = part%species%n