Returns data from csv formatted file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename | |||
integer, | intent(in) | :: | rows | No. of rows |
||
integer, | intent(in) | :: | cols | No. of columns |
function getTable(filename,rows,cols)
!! Returns data from csv formatted file
character(len=*), intent(in) :: filename
integer, intent(in) :: rows !! No. of rows
integer, intent(in) :: cols !! No. of columns
integer :: i, j
integer :: stat
real, dimension(rows,cols) :: getTable
open(unit=10, file=filename, status='old', action='read', iostat=stat)
if (stat>0) then
print*, 'ERROR: '//trim(filename)//' file not found'
error stop
endif
do i=1,rows
read(10,*) (getTable(i,j),j=1,cols)
enddo
close(10)
end function getTable