TABLE OF CONTENTS
- 1. /PILIndex
- 1.1. PILIndex/tIndexList
- 1.2. PILIndex/PIL_nEntry0
- 1.3. PILIndex/PILIndex_PUT
- 1.4. PILIndex/PILIndex_FIND
- 1.5. PILIndex/PILIndex_Print
- 1.6. PILIndex/PILIndex_Allocate
- 1.7. PILIndex/PILIndex_DeAllocate
- 1.8. PILIndex/PILIndex_DELETE
/PILIndex [ Modules ]
NAME
module PILIndex
PURPOSE
Provide a multi usable list connecting the (unique) particle number with the index number of some additional information in some other array.
While the list in the 'other array' is filled entry by entry, the list provided here is sorted by the index number in increasing order. This is done in order to speed up finding information about a particle from the 'other array' and whether information about this specific particle is actually stored in the array.
This implementation speeds up getting information at the expense of inserting new information.
INPUTS
(none)
NOTES
- ...maybe one could change the access to PIL_nEntry0
- "PIL" stands for "PartInfoList"
PILIndex/tIndexList [ Types ]
[ Top ] [ PILIndex ] [ Types ]
NAME
type tIndexList
PURPOSE
store all information of a IndexList
SOURCE
type, public :: tIndexList integer :: nEntry = -999 ! number of used entries integer :: nHole = 0 ! number of deleted entries integer, allocatable :: PartNumber(:) ! array of particle numbers integer, allocatable :: Entry(:) ! array of indices end type tIndexList
PILIndex/PIL_nEntry0 [ Global module-variables ]
[ Top ] [ PILIndex ] [ Global module-variables ]
PURPOSE
default size of arrays (at the beginning)
SOURCE
integer,parameter :: PIL_nEntry0 = 1000
PILIndex/PILIndex_PUT [ Functions ]
[ Top ] [ PILIndex ] [ Functions ]
NAME
integer function PILIndex_PUT(List, number)
PURPOSE
find the place, where some information concerning a particle with "number" should be put into some info vector.
INPUTS
- type(tIndexList) :: List -- The List to put the entry in
- integer :: number -- The particle number to insert
- character(*),intent(in),optional :: CallName -- Name of the List
OUTPUT
- List is modified
- return value gives the position where the info to be stored. If this value is negative, some allocation/reallocation of the infovector has to be done, then the info can be stored at the position given by the absolute value of the return value.
PILIndex/PILIndex_FIND [ Functions ]
[ Top ] [ PILIndex ] [ Functions ]
NAME
integer function PILIndex_FIND(List, number)
PURPOSE
find the place, where the "number" is in the list or where it should be stored
INPUTS
- type(tIndexList) :: List -- The List
- integer :: number -- The particle number to find
OUTPUT
if the return value R is > 0: here the entry "number" was found in the list
if the return value R <= 0: This means, that the entry at position (-R) is smaller than number, while the entry at position (-R)+1 is already larger.
NOTES
the return value R==0 is possible. This means of course, that already the first entry is larger than number. But you should never (!) try to access some entries at position R==0, because this undershoots the lower bound of the arrays.
PILIndex/PILIndex_Print [ Subroutines ]
[ Top ] [ PILIndex ] [ Subroutines ]
NAME
subroutine PILIndex_Print(List, file)
PURPOSE
just print the list to a file stream
INPUTS
- type(tIndexList) :: List -- The List
- integer :: file -- The file number
PILIndex/PILIndex_Allocate [ Subroutines ]
[ Top ] [ PILIndex ] [ Subroutines ]
NAME
subroutine PILIndex_Allocate(List)
PURPOSE
Do all allocation and reallocatiomn stuff connected with "List"
INPUTS
- type(tIndexList) :: List -- The List
OUTPUT
- if the arrays of "list" were not allocated before, they are allocated with some default size
- if the arrays were allocated, they are reallocated with a size 1.3 times larger than the original size
NOTES
I think to remeber having read that the factor 1.3 is a good compromise between the effort of copying around all data and how often this happens. Of course this implies that one starts with some reasonable value. Maybe one could improve. (Kai)
For security one should insert here checks, whether the memory allocations failed and stop execution in these cases.
It would be a good idea to check whether the compiler knows the intrinsic MOVE_ALLOC subroutine and use this instead of copying the contents twice.
PILIndex/PILIndex_DeAllocate [ Subroutines ]
[ Top ] [ PILIndex ] [ Subroutines ]
NAME
subroutine PILIndex_DeAllocate(List)
PURPOSE
DeAllocate all memory connected wit this index list.
PILIndex/PILIndex_DELETE [ Functions ]
[ Top ] [ PILIndex ] [ Functions ]
NAME
integer function PILIndex_DELETE(List, number)
PURPOSE
find the place, where the "number" is in the list, delete it and return the index for others list to follow.
INPUTS
- type(tIndexList) :: List -- The List
- integer :: number -- The particle number to find
OUTPUT
if the return value R is > 0: here the entry "number" was found in the list
if the return value R <= 0: the entry was not found and not deleted
NOTES
Attention, this routine returns iH=List%Entry(i1), i.e. directy the index for ValueList(...). (Contrary to the _FIND routine, where you have to calculate the index by looking it up in %Entry(...). But here this entry is already deleted!)