Hi Guys,
Im relatively new to fortran but been learning FAST! I am using fortran to carry out thousands of iterative calculations from a data set which is in the form of a csv file. My code works excellently considering how new I am to fortran, however, I have encountered a big problem (that seems simple) and i can't get past it.
The data set is 2601 rows by 20 column. I need the program to - read one column - store as an array - analyse it - read the next column - etc etc etc... Till all columns are analysed. I have shown an excerpt of the code below (the code ONLY shows the part I cannot solve). Basically, I need to store the data as an array, column by column, so if my method is wrong then please comment.
Fortran seems to have issues when reading the array and is very particular. For some reason it gives the error 'Attempt to read past end of file'. However I have specified at the end of reading one column, it moves to the next, starting at 1 again so I am not sure why this error is ocuring. I have done my research on this however it seems this one i cannot solve alone.
Thanks in advance guys for any help you can give,
Martin
Im relatively new to fortran but been learning FAST! I am using fortran to carry out thousands of iterative calculations from a data set which is in the form of a csv file. My code works excellently considering how new I am to fortran, however, I have encountered a big problem (that seems simple) and i can't get past it.
The data set is 2601 rows by 20 column. I need the program to - read one column - store as an array - analyse it - read the next column - etc etc etc... Till all columns are analysed. I have shown an excerpt of the code below (the code ONLY shows the part I cannot solve). Basically, I need to store the data as an array, column by column, so if my method is wrong then please comment.
Code:
Program ReadingTest
implicit none
!----------------------------------------------------------------------------------------------------------------------
Integer :: row
Integer :: col
Real, Dimension(2601,20) :: Fo
!----------------------------------------------------------------------------------------------------------------------
Open (unit=1, file='G:\Programs\SilverFrost\FTN95\FULLACC.csv', status='old', action='read')
Do 15 col = 1,20
Do 10 row = 1,2601
Read (1,*) Fo(row,col)
print *, Fo(row,col)
10 continue
15 Continue
Close(1)
!----------------------------------------------------------------------------------------------------------------------
!
!IN THIS SECTION I HAVE INPUT A COMPLEX GEOTECHNICAL FUNCTION WHICH IS IRRELEVANT TO MY PROBLEM AND HENCE REMOVED
!
!----------------------------------------------------------------------------------------------------------------------
End Program ReadingTest
Fortran seems to have issues when reading the array and is very particular. For some reason it gives the error 'Attempt to read past end of file'. However I have specified at the end of reading one column, it moves to the next, starting at 1 again so I am not sure why this error is ocuring. I have done my research on this however it seems this one i cannot solve alone.
Thanks in advance guys for any help you can give,
Martin