public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Issues with file I/O fortran 9.2
@ 2020-03-12 10:06 Francois Clemens
  2020-03-12 11:36 ` Brian L. Drummond
  0 siblings, 1 reply; 2+ messages in thread
From: Francois Clemens @ 2020-03-12 10:06 UTC (permalink / raw)
  To: gcc-help

Hi,

I’ve got a small issue with reading data from Matlab generated csv files.

First some general info:

OS: MAC OS Catalina 10.15.3
Fortran compiler: gfortran 9.2 (update oct 2019, reportedly for Catalina OS).
programming environment: Elcipse 2019-12 (4.14.0)



 Here is the code I’m having trouble with:

filename='positie_frame_cam'
extension='.txt'
do icam=1,6,1
    write (getal,'(I1)') icam ! converting integer to string using an 'internal file'
    totalname=filename//getal//extension
    print*,totalname
    open(unit=icam+10,file=totalname, form='formatted',action='read')
    nlines(icam)=0
    iop=0
    i=0
    do while (iop.ge.0)
      i=i+1
      write(0,*)' regel nummer ',i
      read(icam+10,*,iostat=iop)tel,DUMY(1),DUMY(2),&
      DUMY(3),DUMY(4),DUMY(5),DUMY(6),DUMY(7)
      write(0,*) 'iostat=',iop
      write(0,*) tel,DUMY(1),DUMY(2),&
      DUMY(3),DUMY(4),DUMY(5),DUMY(6),DUMY(7)
      nlines(icam)=nlines(icam)+1
      if (iop.ge.0) then
       nlines(icam)=nlines(icam)-1
       write(0,*) 'something went wrong!'
       close(icam+10)
       !exit
      else
      endif
      if (iop.eq.-1)then
         write(0,*)'eof'
         close(icam+10)
         exit
      endif
    end do
end do

Here is an example of the 6 files i’m trying to read:

    1,0.00000000,0.36611265,0.05310654,0.60107656,-0.02129885,0.99435631,-0.10393212
    1,0.00833892,0.36611265,0.05310654,0.60107656,-0.02129885,0.99435631,-0.10393212
    1,0.01667784,0.36486442,0.05303874,0.59982310,-0.02163688,0.99431165,-0.10428895
    1,0.02501677,0.35989577,0.05282108,0.59855295,-0.02244646,0.99420581,-0.10512358
    1,0.03335569,0.35492529,0.05268669,0.59727332,-0.02325602,0.99409861,-0.10595804
    1,0.04169461,0.35368452,0.05266613,0.59726437,-0.02341294,0.99407797,-0.10611699
    1,0.05003353,0.35491671,0.05268653,0.59602339,-0.02343777,0.99407317,-0.10615646
    1,0.05837246,0.35862988,0.05277895,0.59479665,-0.02314764,0.99410979,-0.10587683
    1,0.06671138,0.36359068,0.05297500,0.59481924,-0.02251773,0.99419203,-0.10523858
    1,0.07505030,0.36483061,0.05303698,0.59482341,-0.02236010,0.99421248,-0.10507885

This is the output I get for one file:

Last login: Thu Mar 12 09:19:00 on ttys001
/Users/fclemens/eclipse-workspace/Fit_ellipsoid/Release/Fit_ellipsoid ; exit;

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
(base) wlan-145-94-195-39:~ fclemens$ /Users/fclemens/eclipse-workspace/Fit_ellipsoid/Release/Fit_ellipsoid ; exit;
 positie_frame_cam1.txt
  regel nummer            1
 iostat=           0
           1   0.0000000000000000       0.36611264999999998        5.3106540000000001E-002  0.60107655999999998       -2.1298850000000001E-002  0.99435631000000002      -0.10393212000000000     
 something went wrong!
  regel nummer            2
 iostat=          -1
           1   0.0000000000000000       0.36611264999999998        5.3106540000000001E-002  0.60107655999999998       -2.1298850000000001E-002  0.99435631000000002      -0.10393212000000000     
 eof


So apparently record 1 is read successfully, but then the record is read again instead of the second one and eof is detected. I’m not sure how to tackle this issue? Any suggestions?


kind regards


Francois Clemens




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Issues with file I/O fortran 9.2
  2020-03-12 10:06 Issues with file I/O fortran 9.2 Francois Clemens
@ 2020-03-12 11:36 ` Brian L. Drummond
  0 siblings, 0 replies; 2+ messages in thread
From: Brian L. Drummond @ 2020-03-12 11:36 UTC (permalink / raw)
  To: gcc-help

On Thu, 2020-03-12 at 11:06 +0100, Francois Clemens via Gcc-help wrote:
> Hi,
> 
> I’ve got a small issue with reading data from Matlab generated csv
> files.

Looks like you never attempt to read the second line.

-- Brian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-12 11:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12 10:06 Issues with file I/O fortran 9.2 Francois Clemens
2020-03-12 11:36 ` Brian L. Drummond

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).