School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,096 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,032 people online right now. Registration is fast and FREE... Join Now!




Problem with READ Sentence in FORTRAN

 

Problem with READ Sentence in FORTRAN

henryl

7 Oct, 2009 - 10:11 AM
Post #1

New D.I.C Head
*

Joined: 12 May, 2006
Posts: 24



Thanked: 2 times
My Contributions
CODE

OPEN(21,FILE='bank150_m2.bcs.s2c')
READ(21,'(A)')header
READ(21,'(A)')header
READ(21,'(A)')header
DO i=1,nbedim+1
  READ(21,*,END=11)node(i),amp(i),phase(i)
  nnodes=i
END DO
WRITE(*,*)'Error in reading input boundary condition file ... ',  &
    'The number of entries exceeds NBEDIM'
STOP
11   CLOSE(21)


This a file I have to read in Fortran 90. The open part is pretty clear, but I have problems understanding the READ sentence. Specifically what this sentence does, with a third parameter included (END=11). Can someone please, explain to me how this piece of code works?

User is offlineProfile CardPM
+Quote Post


crazy_prog

RE: Problem With READ Sentence In FORTRAN

5 Nov, 2009 - 11:48 AM
Post #2

New D.I.C Head
*

Joined: 5 Nov, 2009
Posts: 2

END = s -> end-of-file specifier

where s is the statement label of an executable statement that appears in the same program unit as the end-of-file specifier.

If a READ statement contains an end-of-file specifier and the processor encounters an end-of-file condition and no error condition during execution of the statement:

1) execution of the READ statement terminates,
2) if the READ statement contains an input/output status specifier ( 12.7), the variable or array element ios becomes defined with a processor-dependent negative integer value, and execution continues with the statement labeled s .
User is offlineProfile CardPM
+Quote Post

kcc9999

RE: Problem With READ Sentence In FORTRAN

16 Nov, 2009 - 02:58 PM
Post #3

New D.I.C Head
*

Joined: 16 Nov, 2009
Posts: 3

QUOTE(henryl @ 7 Oct, 2009 - 10:11 AM) *

CODE

OPEN(21,FILE='bank150_m2.bcs.s2c')
READ(21,'(A)')header
READ(21,'(A)')header
READ(21,'(A)')header
DO i=1,nbedim+1
  READ(21,*,END=11)node(i),amp(i),phase(i)
  nnodes=i
END DO
WRITE(*,*)'Error in reading input boundary condition file ... ',  &
    'The number of entries exceeds NBEDIM'
STOP
11   CLOSE(21)


This a file I have to read in Fortran 90. The open part is pretty clear, but I have problems understanding the READ sentence. Specifically what this sentence does, with a third parameter included (END=11). Can someone please, explain to me how this piece of code works?


User is offlineProfile CardPM
+Quote Post

kcc9999

RE: Problem With READ Sentence In FORTRAN

16 Nov, 2009 - 03:06 PM
Post #4

New D.I.C Head
*

Joined: 16 Nov, 2009
Posts: 3

QUOTE(henryl @ 7 Oct, 2009 - 10:11 AM) *

CODE

OPEN(21,FILE='bank150_m2.bcs.s2c')
READ(21,'(A)')header
READ(21,'(A)')header
READ(21,'(A)')header
DO i=1,nbedim+1
  READ(21,*,END=11)node(i),amp(i),phase(i)
  nnodes=i
END DO
WRITE(*,*)'Error in reading input boundary condition file ... ',  &
    'The number of entries exceeds NBEDIM'
STOP
11   CLOSE(21)


This a file I have to read in Fortran 90. The open part is pretty clear, but I have problems understanding the READ sentence. Specifically what this sentence does, with a third parameter included (END=11). Can someone please, explain to me how this piece of code works?



Sorry - I screwed that last post up.
Crazy_Prog is correct but specifically to this code - when the read statement reaches the end of the file denoted by unit 21, the program will jump to the statement that says "11 CLOSE(21)" . Sorry for the last post.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 11:57AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month