Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor II
16 Views

Read Statement

When I try to read this it does not get past the 07,  I want to miss up to the third comma and then grab the 3 doubles

2000,07/29/2016,10:10:14.349327,-0.0689359262076682,0.0031493396999162,1.00790136372755,,,

Is there a method in Fortran to inquire as to the list of files in a directory  and return say the CSV files

 

 

0 Kudos
3 Replies
Highlighted
Black Belt
16 Views

1. List-directed input considers '/' as end-of-record. Try

program jmnread
implicit none
character(132) :: iline = '2000,07/29/2016,10:10:14.349327,-0.0689359262076682,0.0031493396999162,1.00790136372755,,,'
double precision d(3)
integer :: p=0, ncom=0
!
do
   p=p+1
   if(iline(p:p) == ',')then       ! scan for commas
      ncom=ncom+1
      p=p+1
      if(ncom == 3)exit            ! 3 fields skipped
   endif
end do
read(iline(p:),*)d(1),d(2),d(3)    ! 
write(*,'(1p,3D15.4)')d
end program

2. See the documentation and example code for GETFILEINFOQQ:

    <Intel_Installation_Directory>/documentation_2016/en/compiler_f/common/core/index.htm  

0 Kudos
Highlighted
New Contributor II
16 Views

Thanks -- worked a treat once I used '(A)' to read from the file

0 Kudos
Highlighted
New Contributor II
16 Views

subroutine lineread(iline)
      implicit none
      character(160) :: iline
      double precision d(3)
      integer :: p=0, ncom=0, p1=0
!
      do p = 1,159
          if(iline(p:p) == ',')then       ! scan for commas
              ncom=ncom+1
              if(ncom == 3) then
                  p1 = p+1
                  exit            ! 3 fields skipped
              endif
          endif
      end do
      read(iline(p1:),*)d(1),d(2),d(3)
      write(*,'(1p,3D15.4)')d
      end subroutine

 

0 Kudos