- #1
ctaini
- 8
- 0
hi...
program below just for example
integer i,j
do j=1,100
do i=55,78
if(i==j)then
print*,i,j
end if
end do
end do
end
if base on do loop theory,outer do will read 1st line of j then proceed to inner loop,then find if i==j,if true the program will print result and if false the program will proceed to outer loop to read 2nd line and so on until outer line (j=100).
my problem is, if data for outer loop from file "one.txt" (for example )and inner loop from another file "two.txt"(for example)..i facing problem where after inner loop read all the data,the program will end at inner loop,program not proceed to outer loop.The program only read 1st line of outer loop from "one.txt" file.
just for info,both file contain different format and line.
example
file "one.txt"
a1 b1
1004 4567
1015 4567
1027 4567
1038 7890
1049 7890
1055 7890
1066 7890
1074 4567
108 4567
109 7890
110 7890
file"two.txt"
c1 b2
440 1056
458 0089
563 4567
789 2045
123 7890
456 2345
for example that is my file.if i make a program:
if(b1==b2)then
print*,a1,b1,c1
end if
my result is: 1004 4567 563
the result that i want is:
1004 4567 563
1015 4567 563
...
...
110 7890 123
my question is,how to make program that can complete the rule of do loop with 2 different file.
program below just for example
integer i,j
do j=1,100
do i=55,78
if(i==j)then
print*,i,j
end if
end do
end do
end
if base on do loop theory,outer do will read 1st line of j then proceed to inner loop,then find if i==j,if true the program will print result and if false the program will proceed to outer loop to read 2nd line and so on until outer line (j=100).
my problem is, if data for outer loop from file "one.txt" (for example )and inner loop from another file "two.txt"(for example)..i facing problem where after inner loop read all the data,the program will end at inner loop,program not proceed to outer loop.The program only read 1st line of outer loop from "one.txt" file.
just for info,both file contain different format and line.
example
file "one.txt"
a1 b1
1004 4567
1015 4567
1027 4567
1038 7890
1049 7890
1055 7890
1066 7890
1074 4567
108 4567
109 7890
110 7890
file"two.txt"
c1 b2
440 1056
458 0089
563 4567
789 2045
123 7890
456 2345
for example that is my file.if i make a program:
if(b1==b2)then
print*,a1,b1,c1
end if
my result is: 1004 4567 563
the result that i want is:
1004 4567 563
1015 4567 563
...
...
110 7890 123
my question is,how to make program that can complete the rule of do loop with 2 different file.