I have 256 files to be opened and read. And I have to write the result in another separate 256 files with similar names but in different folders. The files should be called in a form of loop (do i = 1,16; do j = 1,16) where the filename is phi=i_theta=j. Thus, it needs to open, read and write the 256 files. I did a code but it is unable to run.
program test1
implicit none
integer:: lskip,lread , count
real ReThe, ImThe, RePhi, ImPhi
integer i,j
real v1,v2,v3,v4,v5
count = 100
do i = 1,16
do j = 1,16
open(count, file ='phi=',i,'_theta=',j,'.efe')
!skip first 17 line
do lskip = 1,17
read(count,*)
End do
! First 17 lines skiped
do lread = 1,1
read(count,*) v1,v2,v3,v4,v5,ReThe, ImThe, RePhi, ImPhi
End do
open(count,file ='C:\Users\user\Desktop\test\output_test\
&phi=',i,'_theta=',j,'.efe', status = 'replace')
write(count,*)ReThe, ImThe, RePhi, ImPhi
count = count +1
end do
end do
stop
end program test1
There are quite many errors when I compile and run the program. The errors are: In file C:\Users\user\Desktop\rtpact1\0_polarization\many_inc\Near_field\TESTSOURCE.f:14
open(count, file ='phi=',i,'_theta=',j,'.efe')
1
Error: Syntax error in OPEN statement at (1) In file C:\Users\user\Desktop\rtpact1\0_polarization\many_inc\Near_field\TESTSOURCE.f:28
&phi=',i,'_theta=',j,'.efe', status = 'replace')
1
Error: Syntax error in OPEN statement at (1) In file C:\Users\user\Desktop\rtpact1\0_polarization\many_inc\Near_field\TESTSOURCE.f:28
&phi=',i,'_theta=',j,'.efe', status = 'replace')
1
Error: Bad continuation line at (1) In file C:\Users\user\Desktop\rtpact1\0_polarization\many_inc\Near_field\TESTSOURCE.f:28
&phi=',i,'_theta=',j,'.efe', status = 'replace')
1
Error: Unclassifiable statement at (1)
Please help to make adjustment in the code. Your help is really appreciated. Thank you