- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I have a function that got the error #7977 when i compiled it. This code is to get the available physical memory during the program run and the compile platform is win32
[fortran]
function int4to8(src) result(des)
use IFWINTY
implicit none
type(T_LARGE_INTEGERX) :: src
integer(kind=8) :: des
integer :: i
integer :: tmp
do i=0,31
write(*,*) BTEST (src%LowPart,i)
if(BTEST (src%LowPart,i) == .TRUE. ) then
des = IBSET (des,i)
end if
if(BTEST (src%HighPart,i) ==.TRUE.) then
des = IBSET (des,i+32)
end if
end do
end function int4to8
program GetSystemMemory
use KERNEL32
use IFWINTY
type(T_MEMORYSTATUSEX) :: mymem
logical :: switch
type(T_LARGE_INTEGERX) :: xixi
integer(kind=8) :: res
MYMem%dwLength = sizeof(MYMem)
switch = GlobalMemoryStatusEx(MYMem)
xixi = MYMem%ullAvailPhys
res = int4to8(xixi)
write(*,*) "ullAvailPhys", res/1024
[/fortran]
Thank you for your help!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The error message is exactly on target. You declared the result of int4to8 to be integer(8), but didn't declare it that way in the main program, so it was integer(4) there. If you had made the function a contained procedure or module procedure, this would not have been an issue.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page