Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

MS fortran powerstation 4.0 Total Memory use

dc353
Beginner
571 Views
Hi,

Is there a way to check how much memory I'm using? I saw this code for the g95 standard but it won't run on MS 4.0. Not sure how to modify it.

MODULE meminfo

USE ISO_C_BINDING, ONLY : C_LONG_LONG
IMPLICIT NONE
PRIVATE
! the KIND might dependent on g95 version/architecture
INTEGER(KIND=C_LONG_LONG), BIND(C, NAME='_g95_total_alloc') ::
total_memory
PUBLIC :: total_memory

END MODULE meminfo

USE meminfo, ONLY: total_memory
INTEGER, PARAMETER :: N=16
TYPE T
INTEGER, DIMENSION(:), POINTER :: scratch
END TYPE T
TYPE(T) :: data(N)
write(6,*) "Total memory used: ",total_memory/(1024*1024),"Mb"
DO i=1,N
ALLOCATE(data(i)%scratch(128*1024*1024))
ENDDO
write(6,*) "Total memory used: ",total_memory/(1024*1024),"Mb"
DO i=1,N
DEALLOCATE(data(i)%scratch)
ENDDO
write(6,*) "Total memory used: ",total_memory/(1024*1024),"Mb"
END


0 Kudos
1 Reply
Steven_L_Intel1
Employee
571 Views
"g95 standard"???

That program uses some specific routine that's part of the g95 library (as well as a Fortran 2003 feature, C interoperability, that PowerStation doesn't have.)

You could try modifying the following which possibly could be made to work under FPS4. I don't remember if FPS4 had INTEGER(8). You'll need to replace the "kernel32" with "msfwin".

Perhaps it's time to move to a current, supported compiler such as Intel Visual Fortran.

program MemoryStatus
use kernel32
implicit none

type (T_MEMORYSTATUS) :: stat

call GlobalMemoryStatus (stat)

write (*,'(I0,A)') stat%dwMemoryLoad, '% of memory is in use'
write (*,'(A,A)') trim(gv(stat%dwTotalPhys)), ' total physical memory'
write (*,'(A,A)') trim(gv(stat%dwAvailPhys)), ' available physical memory'
write (*,'(A,A)') trim(gv(stat%dwTotalPageFile)), ' total pageable memory'
write (*,'(A,A)') trim(gv(stat%dwAvailPageFile)), ' available pageable memory'
write (*,'(A,A)') trim(gv(stat%dwTotalVirtual )), ' total virtual memory'
write (*,'(A,A)') trim(gv(stat%dwAvailVirtual )), ' available virtual memory'

contains

function gv (val)
use kernel32, only: SIZE_T
character(30) gv
integer(SIZE_T), intent(in) :: val
integer(8), parameter :: DIV = 1024
integer(8) :: lval

lval = zext(val,8)
if (val == -1) then
gv = '(unrepresentable)'
else if (lval < 1024) then
write (gv, 101) lval, ' bytes'
101 format (I0,A)
else if (lval < (DIV*DIV)) then
write (gv,101) lval/DIV, 'KB'
else if (lval < (DIV*DIV*DIV)) then
write (gv,101) lval/(DIV*DIV), 'MB'
else
write (gv,102) REAL(lval/(DIV*DIV))/REAL(DIV), 'GB'
102 format (F20.2,A)
gv = adjustl(gv)
end if
end function gv

end program MemoryStatus
0 Kudos
Reply