I have a data file with 2 columns. Let's say:
column 1 (8,8,8,6,9)
, reading it as a
.
column 2 (3,4,5,6,7)
, reading it as b
.
I want to write a code checking if a(i)=a(i+1)
then b=0
.
So result should be column 1 as a
: (8,8,8,6,7)
, column 2 as b
should be (0,0,0,6,7)
.
I tried this but failed:
program read2cols
implicit none
integer ::ios,i,j
real a,b
open(file='8081.txt', unit=22, status='old', action='read')
do
read(22,*,iostat=ios) a(i),b(j)
if(a(i)<a(i))b=0
if(ios/=0) exit
print*,a,b
enddo
close(22)
end program read2cols