getTable Function

public function getTable(filename, rows, cols)

Returns data from csv formatted file

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: filename
integer, intent(in) :: rows

No. of rows

integer, intent(in) :: cols

No. of columns

Return Value real, dimension(rows,cols)


Called by

proc~~gettable~~CalledByGraph proc~gettable getTable program~demo1 demo1 program~demo1->proc~gettable program~demo3 demo3 program~demo3->proc~gettable program~demo2 demo2 program~demo2->proc~gettable

Contents

Source Code


Source Code

  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