base_util_snapshot_save Subroutine

public subroutine base_util_snapshot_save(self, snapshot)

Checks the current size of the storage object against the required size and extends it by a factor of 2 more than
requested if it is too small.
Note: The reason to extend it by a factor of 2 is for performance. When there are many enounters per step, resizing
every time you want to add an encounter takes significant computational effort. Resizing by a factor of 2 is a tradeoff
between performance (fewer resize calls) and memory managment. Memory usage grows by a factor of 2 each time it fills
up, but no more.

Type Bound

base_storage

Arguments

Type IntentOptional Attributes Name
class(base_storage), intent(inout) :: self

Storage encounter storage object

class(*), intent(in) :: snapshot

Object to snapshot


Calls

proc~~base_util_snapshot_save~~CallsGraph proc~base_util_snapshot_save base_storage%base_util_snapshot_save proc~base_util_resize_storage base_storage%base_util_resize_storage proc~base_util_snapshot_save->proc~base_util_resize_storage

Source Code

      subroutine base_util_snapshot_save(self, snapshot)
         !! author: David A. Minton 
         !! 
         !! Checks the current size of the storage object against the required size and extends it by a factor of 2 more than  
         !! requested if it is too small.   
         !! Note: The reason to extend it by a factor of 2 is for performance. When there are many enounters per step, resizing  
         !! every time you want to add an encounter takes significant computational effort. Resizing by a factor of 2 is a tradeoff  
         !! between performance (fewer resize calls) and memory managment. Memory usage grows by a factor of 2 each time it fills  
         !! up, but no more.  
         implicit none
         ! Arguments
         class(base_storage), intent(inout) :: self     
            !! Storage encounter storage object 
         class(*),            intent(in)    :: snapshot 
            !! Object to snapshot 
         ! Internals
         integer(I4B) :: nnew, nold

         ! Advance the snapshot frame counter
         self%iframe = self%iframe + 1

         nnew = self%iframe
         nold = self%nframes

         ! Check to make sure the current storage  object is big enough. If not, grow it by a factor of 2
         if (nnew > nold) call self%resize(nnew)

         self%frame(nnew) = snapshot
      
         return
      end subroutine base_util_snapshot_save