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

problem of using global allocatable array

kashif10
Beginner
373 Views
I have a program test.f

PROGRAM test
use globalloc
IMPLICIT NONE
allocate(pop(mesh))
read(*,*)mesh
do i=1,mesh,1
read(*,*)pop(i)
end do
call peace()
end

that uses a module globalloc.f

module globalloc
double precision,allocatable,dimension(:) :: pop
integer mesh,i
end module globalloc

and uses a subroutine peace.f
subroutine peace()
use globalloc
implicit none
double precision, dimension(:),allocatable::gum
allocate(gum(mesh))
do i = 1,mesh,1
gum(i)=pop(i)
write (*,*) pop(i)
end do
end

when the input i give
mesh=5
pop(1)=2.0
pop(2)=3.0
pop(3)=4.0
pop(4)=5.0
pop(5)=6.0

the output is

2.00000000000000
3.00000000000000
4.00000000000000
5.00000000000000
1.39804067596061D-076


** Address Error **


please help me why it is not taking all values from module.
0 Kudos
1 Reply
miu
Beginner
373 Views
Can allocate be used before specifying the size of Dimension? Is it necessary to replace the line of `allocate(pop(mesh))', and the line of `read(*,*)mesh' ?
0 Kudos
Reply