1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| MODULE allocvars
implicit none
real,dimension(:,:),allocatable :: field
END MODULE
PROGRAM main
use allocvars
implicit none
INTERFACE
SUBROUTINE sub(fieldbyreference)
use allocvars
implicit none
real,dimension(:,:),INTENT(IN) :: fieldbyreference
END SUBROUTINE sub
END INTERFACE
allocate(field(5,5))
field=4.0
write(*,*) 'field in main : ',field(2,2)
call sub(field)
END
SUBROUTINE sub(fieldbyreference)
use allocvars
implicit none
real,dimension(:,:),INTENT(IN) :: fieldbyreference
write(*,*) 'field in sub (from module):',field(2,2)
write(*,*) 'field in sub (from reference):',fieldbyreference(2,2)
END |
Partager