Linux - Newbie This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
|
04-03-2014, 11:53 AM
|
#16
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
Quote:
Originally Posted by AlexBB
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=.
Compare:
Code:
601 FORMAT(4H A= ,I5,5H B= ,I5,5H C= ,I5,8H AREA= ,F10.2,12HSQUARE UNITS) -> theirs
601 FORMAT(4H A= ,I5,5H B= ,I5,5H C= ,I5,8H AREA= ,F10.2,12HSQUARE UNITS) -> yours
Last edited by jpollard; 04-03-2014 at 03:45 PM.
Reason: Added comparison example
|
|
|
04-03-2014, 03:54 PM
|
#17
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
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.
|
|
|
04-03-2014, 05:17 PM
|
#18
|
Member
Registered: Mar 2014
Posts: 464
Original Poster
Rep: 
|
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
|
|
|
04-03-2014, 05:32 PM
|
#19
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
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
it looks like 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.
|
|
1 members found this post helpful.
|
04-03-2014, 05:44 PM
|
#20
|
Member
Registered: Mar 2014
Posts: 464
Original Poster
Rep: 
|
OK, suicidaleggroll, now it compiled. Thank you. However I do not see any output in the Terminal. Where did it go?
Thanks, - Alex
|
|
|
04-03-2014, 05:52 PM
|
#21
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
"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.
|
|
|
04-03-2014, 08:57 PM
|
#22
|
Member
Registered: Mar 2014
Posts: 464
Original Poster
Rep: 
|
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 :-)
|
|
|
09-05-2014, 07:47 PM
|
#23
|
LQ Newbie
Registered: Sep 2014
Location: cincinnati ohio,usa
Distribution: red hat about 1990 ubuntu since
Posts: 8
Rep: 
|
suicideeggg
format('Sometimes you can',1h','t use the ',1h',' and must use the TRADITIONAL xxH ')
but I to have gone to the life changing pascal still trying to find kylix though
fortran IV does not have ' ascii '
watfor does not
watfive does
or perhaps fortran'77
on one machine perhaps the ibm 7090 Hollerith was only 1H. or 2H..
format(2hth,2he ,2hst,2hri,2hng,2hs ,2hca,2hn ,2hon,2hly,2h b,2he,2h 2,2h c,2hha,2hra,2hct,2her,2hs ,2hlo,2hng)
|
|
|
09-06-2014, 12:22 PM
|
#24
|
Senior Member
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,849
|
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.
--
Rick
|
|
|
09-06-2014, 12:42 PM
|
#25
|
Member
Registered: Mar 2014
Posts: 464
Original Poster
Rep: 
|
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
|
|
|
09-06-2014, 12:59 PM
|
#26
|
Senior Member
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,849
|
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.
Later...
--
Rick
|
|
|
09-06-2014, 04:15 PM
|
#27
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
A number of things are accepted for continuation:
<tab><digit>
6 spaces and any character...
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...
|
|
|
09-06-2014, 05:56 PM
|
#28
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
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".
|
|
|
09-06-2014, 06:06 PM
|
#29
|
Senior Member
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,849
|
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.
--
Rick
|
|
|
09-06-2014, 06:21 PM
|
#30
|
Senior Member
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,849
|
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?!"
|
|
|
All times are GMT -5. The time now is 01:14 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|