Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Thank you guys. I will try your suggestions in a few hours, at the end of the day since I am at work now. Please keep it in mind that I copied this code from a website which advertises "Fortran Samples." It is not my creation. I am trying to relearn the language in a hurry. Thanks, - Alex
... the examples there are right... they have an extra space that you left out - two spaces before the B=, C= and AREA=.
As an aside, All UNIX compilers (and all the ones I've used since 1970) allowed the use of the apostrophe quoting to simplify entering Hollerith data. They also dropped the 73-80 column usage... That was for punched card programming, and was set aside to be used as a card numbering process in case you dropped the deck. Having a couple of thousand line program dropped was a major headache to put back in proper order. If the cards were numbered then the process was only about 10 minutes on a card sorter.
OK, Gentlemen. I did as you said: I inserted an extra space before those characters. Now there is only ONE space before "A" 2 spaces before "B" 2 spaces before "C" and 2 spaces before "AREA"
The source code is in the snapshot. I get the same error message. You can see it in the second thumbnail.
In spite of all this I appreciate your attention to my code. Thank you, - Alex
Then it looks like your format code is messed up. The 12H tells it to take 12 characters, this is then immediately followed by "SQUARE UNITS", 12 characters. But, when you put the line break in the middle of this, it's probably taking all of those spaces before "UNITS" as part of the 12. So to the compiler, instead of
Code:
"12HSQUARE UNITS"
it looks like
Code:
"12HSQUARE UNITS"
And since you're past 12, it sees the U and throws an error, since it's not expecting any more characters. You could remove all of the spaces before "UNITS" and shove it right next to the line wrap character, or you could move the line break earlier in the line, say after the "F10.2," before the 12H, but you may have similar problems there too.
Personally I have never once used Hollerith in Fortran, mostly because it's archaic, hard to use, and obsolete. I strongly suggest you switch to the much more traditional quote form:
Code:
FORMAT('A=',I5,'B=',F10.2)
etc.
Last edited by suicidaleggroll; 04-03-2014 at 05:42 PM.
"WRITE(6,601)" means write to unit number 6, with the format code from statement label 601.
Unit number 6 is is stdout, so that's right, but following the logic trail, it won't get to that write until it has passed through the read, which is reading from unit number 5, stdin.
So, it looks like the program is going to wait for user input from stdin, then do something with it and write to stdout. If you haven't entered any values for it to read, then it's going to sit there and wait at the read statement until you do.
Well, it never asked me for input. It just ran the code, it seems, and I saw the same prompt in the Terminal. It did not even say it compiled. I presume it did.
Thank you for your help, suicidaleggroll. What a funny name, though :-)
Distribution: openSUSE, Raspbian, Slackware. Older: Coherent, MacOS, Red Hat, Big Iron IXs: AIX, Solaris, Tru64
Posts: 2,741
Rep:
Quote:
Originally Posted by AlexBB
Thank you guys. Yes evo2, I recall now, the asterisk in the 6th column should do the trick.
(A long time ago) I used to use an ampersand as a continuation character as it was a character that was unrecognized by the compiler and the error message would alert me that I missed a space in columns 1-5. Not sure if the GNU Fortran compiler is that picky about ampersands.
I'm surprised to see anyone still using the Hollerith format specifier.
rnturn, it is my recollection that ANY character in that position (6) would be interpreted as a continuation character. Asterisk was simply the most pleasing, sort of easily understood as such. Thanks, - Alex
Distribution: openSUSE, Raspbian, Slackware. Older: Coherent, MacOS, Red Hat, Big Iron IXs: AIX, Solaris, Tru64
Posts: 2,741
Rep:
Quote:
Originally Posted by AlexBB
rnturn, it is my recollection that ANY character in that position (6) would be interpreted as a continuation character. Asterisk was simply the most pleasing, sort of easily understood as such. Thanks, - Alex
You're right. Any non-blank character would do. Many co-workers would use "C" (for "Continuation"). I got burned enough times by putting a "C" in column 7 by accident and getting some truly cryptic errors that using an illegal (to FORTRAN) character for continuation gave me a more easily understood error message should I screw up and put it into a field (cols 1-5, 7-72) where it would get identified as an invalid character. Like I said, I don't know whether the ampersand is an illegal character for the GNU compiler; I'm thinking back to the days of the IBM FORT-H compiler when doing crap like using IMPLICIT statements to make everything LOGICAL*1 to force you to declare everything, and examining the compiler listings to see what declarations you missed, what variables were actually unused, or never initialized, etc. was common practice. I was actually surprised to see some of my ancient code from my IBM CMS and DEC RT/RSX past actually compile -- and some of it actually link and run -- using the GNU compiler.
The nice thing with the <tab><digit> form was that it allowed the continuations to be numbered (at least 1-9), by which time you really shouldn't be using a continuation...
You can do that with 6 spaces and a character too, just make the character a number. I've seen a lot of codes written that way, I typically use a "|" though, it just feels "right".
Distribution: openSUSE, Raspbian, Slackware. Older: Coherent, MacOS, Red Hat, Big Iron IXs: AIX, Solaris, Tru64
Posts: 2,741
Rep:
Quote:
Originally Posted by suicidaleggroll
You need TWO spaces after the 601 before FORMAT (or if you don't have a space before 601, then you need three spaces between 601 and FORMAT). The F in FORMAT needs to start on column 7, your examples have it on column 5.
I've written more FORTRAN than I care to admit and with any compiler I ever used you wouldn't need two space between the statement label and the beginning of the FORMAT statement. Statement labels could be anywhere in columns 2-5 and I recall setting up my IBM editor (XEDIT) with macros to routinely right justify all statement labels in those columns. The first non-blank character of statements didn't have to begin in column 7. I was indenting statements for readability many years ago (for example: nested DO loops) and especially once FORTRAN-77 came out and structures like IF-THEN-ELSE were possible.
I think the original code snippet suffered from a typo that had the statement beginning in the wrong column and we've gotten sidetracked by a cut-n-paste error. I agree with the comment that the FORMAT statement would have been much easier to setup and debug if the "H" specifiers had not been used. $DIETY I haven't used that since FORTG and I don't think is was mandatory even then.
Anyone ever encounter (read: got stuck maintaining someone else's) source code that took advantage of many FORTRAN compilers treating most spaces in the statement field as optional? Some clever types would save tons of disk space (kidding, of course) by coding a DO loop as "DO10I=1,100,3" while the rest of us were still entering "DO 10 I = 1, 100, 3".
Another interesting variation was VAX FORTRAN's allowing you to use a "D" in column 1 which would either be a comment or be compiled as a "debug" statement with a command line switch.
Distribution: openSUSE, Raspbian, Slackware. Older: Coherent, MacOS, Red Hat, Big Iron IXs: AIX, Solaris, Tru64
Posts: 2,741
Rep:
Quote:
Originally Posted by jpollard
They also dropped the 73-80 column usage... That was for punched card programming, and was set aside to be used as a card numbering process in case you dropped the deck.
Oddly, though, IBM's editors would still put the darned sequence numbers in your source files long after people had left punched cards behind [1]. You could easily strip them off (replaced with spaces) to save a little more disk space when you save the source code on disk in compressed format. But subsequent edit sessions might add them to any new lines you added to the source and you'd have to strip them off again.
--
Rick
[1] - Favorite punch card story: The University had removed most of the keypunch machines on campus a few years before I took a "Business FORTRAN" class. (There were still at least one reader and punch in the data center, though.)The professor wanted card decks to be turned in as part of the assignments. There was no way I was going to wrestle with a keypunch so I wrote and debugged the code on my trusty ADM3 and asked the night operator to transfer the file in my virtual punch to the physical punch. The operator's response to my message: "Seriously?!"
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.