redrighthand
Programmer
Hi all
My question is that, is there a way to use a character as a name of a real array? In the following example "dir" is a character. According to the value of "idir", "dir" becomes, x, y or z. In the last statement, I am calculating "hgt" using the real arrays(x,y, or z arrays). x, y, and z real arrays are already defined in the code. Is there a way out for this problem.all I want to do is to use a dynamic name for the real arrays.
idir=2 ! 1=x, 2=y, 3=z
if (idir ==1) then
istart=istep
iend=istep2
write(dir,'(a)')'x'
elseif (idir == 2) then
istart=jstep
iend=jstep2
write(dir,'(a)')'y'
else
istart=kstep
iend=kstep2
write(dir,'(a)')'z'
endif
hgt = dir(iend)-dir(istart)
My question is that, is there a way to use a character as a name of a real array? In the following example "dir" is a character. According to the value of "idir", "dir" becomes, x, y or z. In the last statement, I am calculating "hgt" using the real arrays(x,y, or z arrays). x, y, and z real arrays are already defined in the code. Is there a way out for this problem.all I want to do is to use a dynamic name for the real arrays.
idir=2 ! 1=x, 2=y, 3=z
if (idir ==1) then
istart=istep
iend=istep2
write(dir,'(a)')'x'
elseif (idir == 2) then
istart=jstep
iend=jstep2
write(dir,'(a)')'y'
else
istart=kstep
iend=kstep2
write(dir,'(a)')'z'
endif
hgt = dir(iend)-dir(istart)