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.
Hi there. I hope there is someone out there familiar with Fortran IV. Many years ago I was writing Fortran IV programs, month after months. I probably wrote tens of thousand statements and of course everything compiled. Since then I went through C, Pascal, C++, C# (lately) and Visual Fox Pro, and now I need Fortran again. My environment is: Windows 7==>VirtualBox==>Ubuntu==>GFortran (Fortran 77). Needless to say I forgot my Fortran. Now I have to recover what I've lost. Anyhow, I began by copying a code for Fortran IV from this website to Vim editor. I then ran Gfortran in Ubuntu and got an error message that one FORMAT statement was incorrect.
601 FORMAT(4H A= ,I5,5H B= ,I5,5H C= ,I5,8H AREA= ,F10.2,12HSQUARE UNI
1
Error: Unexpected end of format string in format string at (1)
fortran_1.f:15.17:
I decided that the statement was too long. I remember that in Fortran IV the statements could not exceed 78 characters I believe, so I broke the line in two this way:
It really helps to use a text editor that understands the language you are coding in. I don't use vim but I suspect it must have some sort of fortran mode that helps with your syntax.
Thank you guys. Yes evo2, I recall now, the asterisk in the 6th column should do the trick. I will be able to try it in a few hours. I thought too, Vim should have sensed Fortran. It really does not. I could not even force it to display column numbers somewhere. There must be a special editor for the language in Ubuntu. - Alex
$ UNITS)
1
Error: Unexpected element 'N' in format string at (1)
fortran_1.f:16.17:
I figured the quote marks distort columns. The dollar sign actually is between 601 and Format, in the right position. The error mark "1" points to "I" in UNITS.
Go, figure. Thanks, - Alex
John_W, as far as I remember you have never given me a suggestion that worked. More than that, they all resulted in wasted efforts and confusion. When I tried to install gcc33-fortran and gcc-34-fortran as you advised I got an error: the package could not be found. It happened with both installation attempts.
whitespace is important in fortran. Are you sure everything is in the correct column? Please post using [code] tags not [quote] tags to preserve the formatting.
As evo2 said, you aren't following the spacing rules, as has been pointed out multiple times.
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.
The $ for the line wrap (it can be any character) needs to be in column 6.
Fortran 77 is not a free-format language, but has a very strict set of rules for how the source code should be formatted. The most important rules are the column position rules:
Col. 1 : Blank, or a "c" or "*" for comments
Col. 1-5 : Statement label (optional)
Col. 6 : Continuation of previous line (optional)
Col. 7-72 : Statements
Col. 73-80: Sequence number (optional, rarely used today)
Most lines in a Fortran 77 program starts with 6 blanks and ends before column 72, i.e. only the statement field is used.
Last edited by suicidaleggroll; 04-02-2014 at 09:22 PM.
Your first spec "4H A= ,I5" is correct. 4H has space A= space. The ,I5, part is ok.
Your next hollerith form "5H B= ,I5" appears incorrect. It should be 4H as 5H includes the comma, which then cause the I5 to be run without the comma separator. Last I knew that was required.
The next hollerith form has the same error. The last looks like it is OK.
I suggest using the quote forms instead - it is easier to get them right.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.