Hi there,
I have a linked list class:
Type :: LLEle !!the list element Integer :: Isval Type(LLEle_IS), Pointer :: next=>null() End type LLEle Type :: LLCon !!the list container Integer, Pointer :: ISOutPutUnit=>null() Integer :: ISLength=0 Integer :: issubstat=0 Character(:), allocatable :: CSMSG Type(LLEle), Pointer :: TLStart=>null(), TLEnd=>null(),&& TLRun=>null(), TLTmp=>null(), TLLastAdded=>null() contains Procedure, Pass :: Add => SubAddToList Procedure, Pass :: Insert => SubInsert ....................... End Type LLCon_Is
I noticed that changing "isval" to "allocatable" doubles the processing time (which is sort of reasonable), but also doubles the ram requirement of the list. Note that allocation of isval is done implicitly ("isval=input", not "Allocate(isval,source=input)").
I can imagine that without the allocatable keyword, the scalar is accessible through the memory address of the allocated list element, whereas with the allocatable keyword, the scalar will have an own memory address, in addition to the memory address of the pointer. this then will inturn have consequences for the access speed when searching for values because two addresses must be resolved. However, I am just guessing, so someone with a more profound understanding of the matter may clarify.
Any suggestions are much appreciated.