You have to declare STAT somehow. If you start to play with dynamic memory allocation, staying in FORTRAN 77 is hopeless. Maybe someone id able to come up with some solution, but this is the smallest change I found possible. It uses Fortran 2003 interoperability with C.(Maybe Cray pointer solution would be shorter, but non-standard)
USE ISO_C_BINDING
IMPLICIT NONE
INTEGER(C_INT) KEY,SIZE,ADDR,I
DATA KEY / 777 /
DATA SIZE / 64 /
!DATA ADDR / Z'b76fb000' /
INTEGER,POINTER :: STAT(:)
TYPE(C_PTR) :: STATPTR
CALL CALL_FC(KEY, ADDR, SIZE, STATPTR)
call C_F_POINTER(STATPTR,STAT,(/SIZE/))
PRINT *, 'stat is : '
DO I=1,SIZE
PRINT *,STAT(I)
END DO
! CAN I ACCESS TO STAT LIKE THIS?
!DO I=1,10
!STAT(I) = STAT(I) + 5
!WRITE (*,*) STAT(I)
!END DO
END
I am getting some error from your C part, which I didn't check. Also I do not know exactly, what the program is supposed to do.
However I really encourage you to use modern Fortran features. Most important is ISO_C_BINDING for interoperability between C and Fortran. Also forget DATA
statements and use variable initialization.
Quick translation to a more modern Fortran:
use iso_c_binding
implicit none
interface
subroutine call_fc(key,addr,size,status) bind(C,name='call_fc_')
import
integer(c_int) :: key !intents should be added
integer(c_int) :: addr
integer(c_int) :: size
type(c_ptr) :: status
end subroutine
end interface
integer(c_int) :: key = 777, size=64,addr,i
integer(c_int),pointer :: stat(:)
type(C_ptr) :: statptr
call call_fc(key, addr, size, statptr)
call c_f_pointer(statptr,stat,(/size/))
print *, 'stat is : ',stat
end