Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29242 Discussions

Error #7977: The type of the function reference does not match the type of the function

史_建鑫
Beginner
977 Views



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!

0 Kudos
1 Reply
Steven_L_Intel1
Employee
977 Views

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.

0 Kudos
Reply