Hi,
I am using Fortran 90 and my requirement is that I want to resize an array inside a subroutine. I have declared this array as allocatable inside another module.
module global
type(user_defined),allocatable ::array_a)
end module
Now I am defining a subroutine which will take this array as input and resize it with a number passed as another input. It will be called something like this:
program test_resize
allocate(array_a(100))
new_size = 200
call resize(array_a,new_size)
end program
Subroutine is expected to work like this
subroutine resize(array_a,newsize)
deallocate(array_a)
allocate(array_a(new_size)
end subroutine
now when I try to compile this kind of program, it throws an error saying 'illegal use of array_a in allocate/deallocate'.
Can anyone help me to solve this problem.
Many thanks,
Jags
I am using Fortran 90 and my requirement is that I want to resize an array inside a subroutine. I have declared this array as allocatable inside another module.
module global
type(user_defined),allocatable ::array_a)
end module
Now I am defining a subroutine which will take this array as input and resize it with a number passed as another input. It will be called something like this:
program test_resize
allocate(array_a(100))
new_size = 200
call resize(array_a,new_size)
end program
Subroutine is expected to work like this
subroutine resize(array_a,newsize)
deallocate(array_a)
allocate(array_a(new_size)
end subroutine
now when I try to compile this kind of program, it throws an error saying 'illegal use of array_a in allocate/deallocate'.
Can anyone help me to solve this problem.
Many thanks,
Jags