Reputation: 1
Is it possible to create dynamic variable names in fortran? (ft1,ft2,ft3 are being read from file input and all are same).(deg = 10 as of now).
I am giving snippet here as well :
call RKUTTA(h,TX,X,Y,ft1,ft2,ft3,kglobal,cglobal,invmass,Xout1,Yout1)
write(20,*) " TIME STEP VALUES "
write(20,*) " Xout1 Yout1 "
do num = 1,deg
write(20,'(30f20.5)') Xout(deg) , Yout(deg)
end do
I have 2 questions:
In the above subroutine ft1,ft2,ft3 are used as inputs to get the output Xout and Yout. The subroutine has to be called again with a different set of inputs to get a different output.
call RKUTTA(h,TX,Xout1,Yout1,ft4,ft5,ft6,kglobal,cglobal,invmass,Xout2,Yout2)
write(20,*) " TIME STEP VALUES "
write(20,*) " Xout2 Yout2 "
do num = 1,deg
write(20,'(30f20.5)') Xout2(deg) , Yout2(deg)
Similarly the ft4,ft5,ft6... will expand to ftn,ftn+1,ftn+2 to get Xoutn and Youtn.
Hope you have understood my question. If not please bear with me and ask me for anything that needs to be changed.
Thanks
Upvotes: 0
Views: 58
Reputation: 21431
No, it is not possible.
Use an array to hold the values of ft1 ... ftn and similar variables.
Upvotes: 1