LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 04-03-2014, 12:53 PM   #16
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255

Quote:
Originally Posted by AlexBB View Post
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 04:45 PM. Reason: Added comparison example
 
Old 04-03-2014, 04:54 PM   #17
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
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.
 
Old 04-03-2014, 06:17 PM   #18
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
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
Attached Thumbnails
Click image for larger version

Name:	AA.png
Views:	9
Size:	69.8 KB
ID:	15157   Click image for larger version

Name:	AAA.png
Views:	7
Size:	35.0 KB
ID:	15158  
 
Old 04-03-2014, 06:32 PM   #19
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,362

Rep: Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004
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 06:42 PM.
 
1 members found this post helpful.
Old 04-03-2014, 06:44 PM   #20
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
OK, suicidaleggroll, now it compiled. Thank you. However I do not see any output in the Terminal. Where did it go?

Thanks, - Alex
 
Old 04-03-2014, 06:52 PM   #21
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,362

Rep: Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004
"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.
 
Old 04-03-2014, 09:57 PM   #22
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
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 :-)
 
Old 09-05-2014, 08:47 PM   #23
PeteTy
LQ Newbie
 
Registered: Sep 2014
Location: cincinnati ohio,usa
Distribution: red hat about 1990 ubuntu since
Posts: 8

Rep: Reputation: Disabled
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)
 
Old 09-06-2014, 01:22 PM   #24
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0, RHEL5,6), CentOS, SuSE (10.x, 11.x, 12.2, 13.2), Solaris (8-10), Tru64, MacOS, Raspian
Posts: 1,113

Rep: Reputation: 65
Quote:
Originally Posted by AlexBB View Post
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
 
Old 09-06-2014, 01:42 PM   #25
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
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
 
Old 09-06-2014, 01:59 PM   #26
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0, RHEL5,6), CentOS, SuSE (10.x, 11.x, 12.2, 13.2), Solaris (8-10), Tru64, MacOS, Raspian
Posts: 1,113

Rep: Reputation: 65
Quote:
Originally Posted by AlexBB View Post
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
 
Old 09-06-2014, 05:15 PM   #27
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
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...
 
Old 09-06-2014, 06:56 PM   #28
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,362

Rep: Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004
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".
 
Old 09-06-2014, 07:06 PM   #29
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0, RHEL5,6), CentOS, SuSE (10.x, 11.x, 12.2, 13.2), Solaris (8-10), Tru64, MacOS, Raspian
Posts: 1,113

Rep: Reputation: 65
Quote:
Originally Posted by suicidaleggroll View Post
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
 
Old 09-06-2014, 07:21 PM   #30
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0, RHEL5,6), CentOS, SuSE (10.x, 11.x, 12.2, 13.2), Solaris (8-10), Tru64, MacOS, Raspian
Posts: 1,113

Rep: Reputation: 65
Quote:
Originally Posted by jpollard View Post
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?!"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running mysql from ssh & query statement has a Text Header in the SELECT statement? djlerman Linux - Server 6 11-19-2013 07:33 PM
Can't compile f77 code using gfortran or g77 GradientDrift Programming 2 11-18-2009 11:18 PM
gfortran: Syntax error in DATA statement at (1) science_guy Programming 1 10-16-2009 01:10 AM
XLF compile HELP !The unformatted I/O statement on the file "..." cannot be completed chonchis AIX 0 06-12-2009 02:22 PM
Gfortran compile error aukuntin Linux From Scratch 2 01-28-2007 09:08 PM


All times are GMT -5. The time now is 12:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration