hai.. I need your help for solve this problem.. For example, I have a file with 5 number in my data.txt.. And I sum this 5 number like this code and save the output into result.txt.. If I want to sum another file into this code (not data.txt) how could I solve this problem?
program tes
integer, parameter :: N = 5
real, dimension(1:N) :: x
real :: y
open (unit=1, file='data.txt')
do i = 1,N
read (unit=1, fmt=*) x(i)
y=x(i)+y
end do
close(unit=1)
print*,'y=',y
open (unit=2, file='result.txt')
write (unit=2, fmt=*) y
close (unit=2)
end program
thank you for your help..
program tes
integer, parameter :: N = 5
real, dimension(1:N) :: x
real :: y
open (unit=1, file='data.txt')
do i = 1,N
read (unit=1, fmt=*) x(i)
y=x(i)+y
end do
close(unit=1)
print*,'y=',y
open (unit=2, file='result.txt')
write (unit=2, fmt=*) y
close (unit=2)
end program
thank you for your help..