Fortran non advancing reading of a text file

前端 未结 1 531
故里飘歌
故里飘歌 2021-01-17 04:38

I have a text file with a header of information followed by lines with just numbers, which are the data to be read.

I don\'t know how many lines are there in the hea

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-17 04:58

    A non-advancing read will still set the file position to before start of the next record if the end of the current record is encountered while reading from the file to satisfy the items in the output item list of the read statement - non-advancing doesn't mean "never-advancing". You can use the value assigned to the variable nominated in an iostat specifier for the read statement to see if the end of the current record was reached - use the IS_IOSTAT_EOR intrinsic or test against the equivalent value from ISO_FORTRAN_ENV.

    (Implicit in the above is the fact that a non-advancing read still advances over the file positions that correspond to items actually read... hence once that getTypeOfLine procedure decides that it has a line of data at least part of that line has already been read. Unless you reposition the file subsequent "data" read statements will miss that part.)

    0 讨论(0)
提交回复
热议问题