kkhhhkk
Coder
Hello, I'm trying to use f90 to read multiple files using do loop, here is what I have:
This script opens 1368 files and reads the content as a matrix, however I get an error when it tries to read the filename, how can can I fix this?
Code:
program rotate
implicit none
integer :: i
character(len=20) :: MyStr, str1, str2, str_combined
character(len=50) :: filename
integer, parameter :: n = 10, m = 3
real :: matrix(n,m)
integer :: j, k
character(len=200) :: line
do i = 1,1368
!everything inside
str1 = 'coordinates_'
str2 = '.ye'
write(MyStr,'(i0)') i
!above turns integer to string
filename = "(A)",trim(str1)//trim(adjustl(MyStr))//trim(str2)
open(10,file="filename",status='old')
do j=1,n
read(10,'(A)') line
read(line, *)matrix(i,:)
enddo
close(10)
do j=1,n
write(*, '(3F10.6)') matrix(i,:)
enddo
end do
end program rotate
This script opens 1368 files and reads the content as a matrix, however I get an error when it tries to read the filename, how can can I fix this?