Increasing Size of FORTRAN Array without Reallocation

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 3K views
Zahur
Messages
1
Reaction score
0
Is it possible to increase the size of an already allocated array in FORTRAN, without reallocation?
e.g. if in start A(3)=[4, 5, 6] and now I want something like A(4)=[4, 5, 6, 7].
Currently I am using a temporary array to do this

allocate(A(3))
A=(/4, 5, 6/)
allocate(temp(3))
temp=A
deallocate(A)
allocate(A(4))
A(1:3)=temp
A(4)=7


Or some other suggestion

Zahur
 
Physics news on Phys.org
I'm not a Fortran programmer, but some googling lead me to this. NB: I've not read the code, or tested it.