Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This forum is the most helpful site I've ever used. I used to use Deja.com; but, this site is better - hands down!..."

Geography

Where in the world do Tek-Tips members come from?

Fortran newbie, simple loop question, continues everywhere!

AndersO (Programmer)
9 Jan 04 4:28
I'm about to convert a Fortran77 program to C and have encounter a code snippet something like this:

        DIMENSION TMP(5)
        DO 10 K=1, 5
10         TMP(K)=0
        CALL FUNC
20        CONTINUE

        STOP
        END

        SUBROUTINE FUNC
        WRITE (*,*)'Just a test'
        RETURN
        END

Whats the deal with that continue?.. There is no reference to label 20 anywhere in the program, first I thought there was some nested DO loop I've missed (This snippet is just part of a bigger program ofcourse), I've rechecked this a couple of times.. Func gets called only once too..

I've come to the conclusion that that continue is just some leftover from some old loop that was removed, but the continue was forgotten or something. Or is there some reason why one should put continues here and there in a program? :)
ArkM (IS/IT--Management)
9 Jan 04 5:33
If label 20 is true unreferenced in the module, forget this continue stmt...
The Good Old FORTRAN liked labels...
zeitghost (Programmer)
9 Jan 04 7:20
You could comment out the CONTINUE statement, then recompile the program and see if it complains.

You could do wonderfully incomprehensible things with F77 like calling subroutines with alternative return addresses in the parameter list....

That one might be a joy to find.

rgds
Zeit.
AndersO (Programmer)
9 Jan 04 8:11
Ok, as I suspected then.. I haven't completly finished the conversion so it wont compile yet.

Thanks!
zeitghost (Programmer)
9 Jan 04 11:28
Sorry.

I meant that you should recompile the Fortran source not your C code.

Unless you don't have a F77 compiler anymore....

I think that the 20 CONTINUE statement is very probably completely redundant, but it might pay you to check...

rgds
Zeit.
AndersO (Programmer)
10 Jan 04 7:13
Oups.. I realize that now. But the Fortran code is on paper in a book!, after emailing the author I now know the continue has no meaning.

However, I downloaded a free fortran77 compiler and I'm going to write it down. Like an reference to the conversion.

And immediatly I stumble on another (newbie I guess) problem, source code line length limits.. In the book, if the line is longer than a certain characters, it is breaked down into more lines, and those lines begins with a number. But I dont get that to work with the compiler that I have. (watcom)

Hmm, this must be in some faq. I go look for it.
zeitghost (Programmer)
10 Jan 04 9:34
Hi.

Oh joy! Running programs out of a book! Can the author supply the source code? or is there a disk with the book?

The format of classic Fortran is that characters in positions 1 to 5 are the statement number.

(i.e. instead of 20 Continue you could have 12345 continue).

Position 6 is the continuation line indicator.

It's blank for a normal line, but will have a character at position 6 if the line is a continuation line.

So
12345678901234567890 (Character positions for the following)
12345 CONTINUE

could be written

12345
      6CONTINUE

(The 6 should appear in the column after the 5 on the line above it).

though why anyone would want to....

The FORTRAN statements normally occupy characters 7 to 72.

73 to 80 are used for other purposes.

In the days of punched cards, the card number appeared here so you could sort the cards if the rubber band broke.

There are normally compiler controls to set up compilation for FORTRAN IV, FORTRAN 77, etc. as suits the source code.

hope this helps.
rgds
Zeit.
AndersO (Programmer)
10 Jan 04 10:11
That helped allot!, thanks!. What a weird programming language.

No, no disk. Didn't ask for the source code either, spoiling all the fun?!

Rubber band?.. Never thrust a computer with rubber bands in it. :)
zeitghost (Programmer)
11 Jan 04 4:46
Nah, the rubber band was used to keep the deck of punched cards together.

After a time, the rubber band *always* broke, with a resulting cascade of cards to the floor.

Sorting the deck was made easier by the numbers in cols 73 to 80. (In theory).

In practice, most people threw the deck away & punched a new set.

Have you thought of using a scanner to scan the page into the pc & using OCR software to produce a text file?

I've tried this a few times, but it's usually a waste of time.

FORTRAN isn't really weird, it's just very old.

If you're lucky, you'll never discover the joys of the ARITHMETIC IF and the ASSIGNED GOTO.

rgds
Zeit.
AndersO (Programmer)
13 Jan 04 7:10
Well, its all done now!.. Fortran and C conversion.. Took a bit longer to convert than I thought. Arrays start at 1 in Fortran and at 0 in C, that kept me going for a while..

And the result from the program seems to be the same both in Fortran and C, so either both have the same error or both is working!.


Thanks again!
zeitghost (Programmer)
13 Jan 04 9:04
Good show!

Fun isn't it?

rgds
Zeit.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close