problem of using global allocatable array

problem of using global allocatable array

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.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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' ?

Leave a Comment

Please sign in to add a comment. Not a member? Join today