{"id":2485,"date":"2016-02-12T20:37:32","date_gmt":"2016-02-12T19:37:32","guid":{"rendered":"http:\/\/roboblog.fatal-fury.de\/?p=2485"},"modified":"2016-02-12T20:42:34","modified_gmt":"2016-02-12T19:42:34","slug":"proc-status","status":"publish","type":"post","link":"http:\/\/roboblog.fatal-fury.de\/?p=2485","title":{"rendered":"\/proc status"},"content":{"rendered":"<p>Code snipped to read \/proc status with fortran.<br \/>\nE.g. used memory and so...<\/p>\n<pre><code>\r\n! original: http:\/\/hiliev.eu\/posts\/recipe-obtaining-peak-vm-memory-size-in-pure-fortran.html\r\n\r\nmodule ProcStatus\r\n  contains\r\n    !---------------------------------------------------------------!\r\n    ! Returns current process virtual memory size             !\r\n    ! Requires Linux procfs mounted at \/proc                        !\r\n    !---------------------------------------------------------------!\r\n    ! Output: vmsize - vmsize VM size in kB                             !\r\n    !---------------------------------------------------------------!\r\n    function getVmSize() result(vmsize)\r\n      implicit none\r\n      integer :: vmsize\r\n      character(len=80) :: stat_key, stat_value\r\n      !\r\n      vmsize = 0\r\n      open(unit=1000, file=\"\/proc\/self\/status\", status='old', err=99)\r\n      do while (.true.)\r\n        read(unit=1000, fmt=*, err=88) stat_key, stat_value\r\n        if (stat_key == 'VmSize:') then\r\n          read(stat_value, *) vmsize\r\n          exit\r\n        end if\r\n      end do\r\n    88 close(unit=1000)\r\n      if (vmsize == 0) goto 99\r\n      return\r\n      !\r\n    99 print *, 'ERROR: procfs not mounted or not compatible'\r\n      vmsize = -1\r\n    end function getVmSize\r\n\r\nend module ProcStatus\r\n\r\nprogram test\r\n  use ProcStatus\r\n  implicit none\r\n  integer :: vmsize\r\n  integer, allocatable :: arr(:)\r\n\r\n  allocate(arr(10000000)) ! ~ 40MB\r\n  arr(:) = 0\r\n\r\n  vmsize = getVmSize()\r\n  print *, 'VM size: ', vmsize, ' kB'\r\nend program test\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 :: [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[30],"class_list":["post-2485","post","type-post","status-publish","format-standard","hentry","category-allgemein","tag-fortran"],"_links":{"self":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts\/2485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2485"}],"version-history":[{"count":1,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts\/2485\/revisions"}],"predecessor-version":[{"id":2486,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts\/2485\/revisions\/2486"}],"wp:attachment":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2485"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}