- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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.
- Marcas:
- Intel® Fortran Compiler
Link copiado
1 Responder
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
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' ?
Responder
Opções do tópico
- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora