- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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' ?
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page