Skip to content

Instantly share code, notes, and snippets.

@bast
Created February 27, 2020 14:39
Show Gist options
  • Save bast/e983b422ee1b6218b64b8fb6b70cf911 to your computer and use it in GitHub Desktop.
Save bast/e983b422ee1b6218b64b8fb6b70cf911 to your computer and use it in GitHub Desktop.
Allocates a chunk of memory. Can be used to test memory high water mark tools.
! /usr/bin/time -v ./a.out
program example
implicit none
integer(8), parameter :: mw = 1000000 ! 200 MW or 1525 MB
real(8), allocatable :: a(:)
print *, 'will try to allocate', 200*mw, 'double precision floats'
! allocate 200 MW or 1525 MB
allocate(a(200*mw))
a = 1.0d0
print *, 'first element:', a(1)
deallocate(a)
print *, 'ok all went fine'
end program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment