As there are lots of folders and files, I wish to use loop to open the folder and read them.
The names of the folders to open and read them are rt20, rt30, rt40 and so on. Whereas, the names of the folders to save some text files are sphere20, sphere30, etc. I created an array of characters and concatenate with the name of the folders but failed.
The actual code that I created is:
PROGRAM TEST1
IMPLICIT NONE
INTEGER ::lskip,lread,count
INTEGER :: n,I,j
REAL l,b,c,d,e,ReThe,ImThe,RePhi,ImPhi
CHARACTER(len=100) :: FN,FNL
character*2,parameter :: A(*) = ['20','30','40','50','60','70']
N=256
do j = 1,6
OPEN(11,file='rt',A(j),'\\output.dat',form='formatted')
!--allocate your vectors here
DO I=1,N
WRITE(FN,10)I
WRITE(6,*)FN
OPEN(1,FILE=FN)
!skip first 17 lines
do lskip = 1,18
READ(1,*)
end do
! Now read actual lines
do lread = 1,1
READ(1,*)l,b,ReThe,ImThe,RePhi,ImPhi,c,d,e
end do
write(11,20)ReThe,ImThe,RePhi,ImPhi
CLOSE(1)
END DO
10 format ('pm\\vertical\\sphere',A(j),'\\n_FarField',I0,'.ffe')
20 format (E14.7,4X,E14.7,4X,E14.7,4X,E14.7)
end do
END PROGRAM
The errors that are appeared in the program:
In file C:\Users\Hamsalekha\Desktop\far_field_sphere\Source1.f:12
OPEN(11,file='rt',A(j),'\\output.dat',form='formatted')
1
Error: Syntax error in OPEN statement at (1)
In file C:\Users\Hamsalekha\Desktop\far_field_sphere\Source1.f:33
10 FORMAT('pm\\vertical\\sphere',A(j),'\\n_FarField',I0,'.ffe')
1
Error: Unexpected element in format string at (1)
I couldn't find a solution on any websites. I really appreciate if someone can help me to solve this problem or give any hint.