Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

resizing an allocatble array in a subroutine

Status
Not open for further replies.

jags015

Technical User
Mar 6, 2013
4
FR
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 don't get the feeling that this description of yours and posted source lines are 100% precise...please post the entire code of your program, subprogram and module; make sure to use code tags, starting 'code' and ending '/code' tags each enclosed in square brackets "[ ]" and the source in between such tags.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top