- #1
alyflex
- 9
- 0
Hi,
I have a rather large program written in fortran 77/90. In one of the subroutines a lot of local dynamic arrays are declared.
In order to make this program able to calculate more stuff, I need to bring these dynamic arrays back into the main program.
I have tried to define the arrays allocatable in the main program and then passing them on to the subroutine which sets them as allocatable. But when I allocate them in the subroutine the program crashes.
I have tried to do it with common blocks, but as far as I can see that's a dead end.
I have considered trying interface blocks, but I am still a bit uncertain as to how they work and if it is possible to do it with those.
Does anyone know a way to do this, I have been stuck with this problem for 2 days now, so any help would be much appreciated.
A short example of what I am trying to do
Main.f90
Program main
double complex, allocatable :: Vlm(:)
...
Call init_potential(input,output,Vlm)
...
End main
init_potential.f90
subroutine init_potential(input,output,Vlm)
double complex, allocatable, intent(out) :: Vlm(:)
...
allocate(Vlm(sizeofVlm))
...
end init_potential
I have a rather large program written in fortran 77/90. In one of the subroutines a lot of local dynamic arrays are declared.
In order to make this program able to calculate more stuff, I need to bring these dynamic arrays back into the main program.
I have tried to define the arrays allocatable in the main program and then passing them on to the subroutine which sets them as allocatable. But when I allocate them in the subroutine the program crashes.
I have tried to do it with common blocks, but as far as I can see that's a dead end.
I have considered trying interface blocks, but I am still a bit uncertain as to how they work and if it is possible to do it with those.
Does anyone know a way to do this, I have been stuck with this problem for 2 days now, so any help would be much appreciated.
A short example of what I am trying to do
Main.f90
Program main
double complex, allocatable :: Vlm(:)
...
Call init_potential(input,output,Vlm)
...
End main
init_potential.f90
subroutine init_potential(input,output,Vlm)
double complex, allocatable, intent(out) :: Vlm(:)
...
allocate(Vlm(sizeofVlm))
...
end init_potential