| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in), | optional | :: | MemSize | ||
| logical, | intent(in), | optional | :: | print_err |
subroutine InitMemoryManager(MemSize, print_err) ! Initialise memory manager. ! In: ! MemSize (optional) : max amount of memory available in MB. Default: MaxMemLimit ! print_err (optional): print all error messages from memory manager. Default: true. ! MAXMEM must be set via c pre-processing or set to be an integer. integer(int64), intent(in), optional :: MemSize logical, intent(in), optional :: print_err integer(int64) :: MaxMemBytes ! Obtained via CPP in the makefile. MAXMEM in MB. integer(int64), parameter :: MaxMemLimit = MAXMEM def_default(err_output, print_err, .true.) if (present(MemSize)) then MaxMemBytes = MemSize * 1024**2 else MaxMemBytes = MaxMemLimit * 1024**2 end if if (initialised) then if (err_output) write (stdout, *) 'Already initialised memory manager. Not re-initialsing.' else if (MaxMemBytes <= 0) then if (err_output) then write (stdout, *) 'Illegal maximum memory value passed to memorymanager.' write (stdout, *) 'MaxMemgbytes = ', real(MaxMemBytes, dp) / (1024**2) write (stdout, *) 'Setting maximum memory available to 1GB.' end if MaxMemBytes = 1024**3 endif if (.not. allocated(MemLog)) allocate (MemLog(MaxLen)) if (.not. allocated(PeakMemLog)) allocate (PeakMemLog(MaxLen)) if (.not. allocated(LookupPointer)) allocate (LookupPointer(MaxLen)) lookuppointer = 0 MaxMemory = MaxMemBytes MemoryUsed = 0 MemoryLeft = MaxMemory MaxMemoryUsed = 0 initialised = .true. nWarn = 0 ! Deal with debug options at a later date. ! debug = gmemdebug write (stdout, '(a33,f8.1,a3)') ' Memory Manager initialised with ', real(MaxMemBytes, dp) / (1024**2), ' MB' end if end subroutine InitMemoryManager