Code snipped to read /proc status with fortran.
E.g. used memory and so...
! original: http://hiliev.eu/posts/recipe-obtaining-peak-vm-memory-size-in-pure-fortran.html
module ProcStatus
contains
!---------------------------------------------------------------!
! Returns current process virtual memory size !
! Requires Linux procfs mounted at /proc !
!---------------------------------------------------------------!
! Output: vmsize - vmsize VM size in kB !
!---------------------------------------------------------------!
function getVmSize() result(vmsize)
implicit none
integer :: vmsize
character(len=80) :: stat_key, stat_value
!
vmsize = 0
open(unit=1000, file="/proc/self/status", status='old', err=99)
do while (.true.)
read(unit=1000, fmt=*, err=88) stat_key, stat_value
if (stat_key == 'VmSize:') then
read(stat_value, *) vmsize
exit
end if
end do
88 close(unit=1000)
if (vmsize == 0) goto 99
return
!
99 print *, 'ERROR: procfs not mounted or not compatible'
vmsize = -1
end function getVmSize
end module ProcStatus
program test
use ProcStatus
implicit none
integer :: vmsize
integer, allocatable :: arr(:)
allocate(arr(10000000)) ! ~ 40MB
arr(:) = 0
vmsize = getVmSize()
print *, 'VM size: ', vmsize, ' kB'
end program test