Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
READ (1, *) (TIO (I), I=1, NN2)
1
Error: Expected variable in READ statement at (1)
VibeOPS.f:149.18:
READ (1, *) (SIO (I), I=1, NN2)
1
Error: Expected variable in READ statement at (1)
Thank you
I haven't had a lot of trouble compiling old FORTRAN-IV or F77 code other than dealing with indentation problems but I'll take a stab at this. (Full disclosure: it's been quite a while since I wrote FORTRAN code in my sleep.)
Qs:
* Can you provide a little context? Single READ statements aren't a lot of help.
* Have you tried a smaller version of the program that isn't compiling that isolates one of the problematic statements? Something small enough that you could paste it in a post (inside "code" directives, of course.) This program wouldn't have to actually do anything useful but it if fails to compile in the same way others could cut-n-paste it into a file on their system and hack at it until it does compile. Example:
Code:
program test
parameter (nn2 = 10)
dimension tio(nn2)
integer*2 i
read(1, *) (tio(i), i=1, nn2)
end
Compiles just fine. (It's useless but it compiles.)
UPDATE:
About that error message...
I suspect that it's pointing to line:column what the compiler sees an error. If so, that seems to indicate that the variable "I" is the problem. Have you done something like
Code:
IMPLICIT NONE
and then forget to declare "I"? Or declare "I" to be something other than an integer? Adding the "implicit none" to my little test program resulted in errors but not what you are seeing.
Thank you for your help.
I found mistakes.
When I describing the variables, I made a typo and instead TIO and SIO I put zero on the end (TI0 and SI0).
This is old program in Fortran IV( Consists around 1500 lines) worked well and now I am trying to “reanimate” it.
I got more errors, but I am trying to fix it by myself.
Also, when compiling code, you recommended :
1 program test
2 parameter (nn2 = 10)
3 dimension tio(nn2)
4 integer*2 i
5 read(1, *) (tio(i), i=1, nn2
6 end
I received an error:
At line 5 of file programtest.f (unit = 1, file = 'fort.1')
Fortran runtime error: End of file
What’s wrong with it?
Another issue: when I tried to install Fortran Analyzer that you recommended my MacBook doesn’t allow to do it.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
Quote:
Originally Posted by Fpaul8
Hello all !
Thank you for your help.
I found mistakes.
When I describing the variables, I made a typo and instead TIO and SIO I put zero on the end (TI0 and SI0).
This is old program that I wrote long time ago in Fortran IV( Consists around 1500 lines) worked well and now I am trying to “reanimate” it.
I got more errors, but I am trying to fix it by myself.
Hmm... So I'm guessing that "TIO" was declared to be an array but "TI0" was not, right? :^)
"Back in the day"... I would ask the compilers to produce a detailed listing and examine the list of defined variables at the bottom and look for variables that were used but not declared to show spelling errors. (This was mainly using the IBM compilers on VM/CMS but I think it was also an option on the DEC compilers---no idea whether GNU even generates a listing). The other thing you could do is to add "implicit none" right after the "program" statement. That'll cause the compiler to holler about each and every undeclared variable. (Sort of like "use strict" in Perl.)
Quote:
Also, when compiling code, you recommended :
1 program test
2 parameter (nn2 = 10)
3 dimension tio(nn2)
4 integer*2 i
5 read(1, *) (tio(i), i=1, nn2
6 end
I received an error:
MacBook-Pro-2:Vibe_OPS_30.01.17 Pavel$ ./programtest programtest.f
At line 5 of file programtest.f (unit = 1, file = 'fort.1')
Fortran runtime error: End of file
What’s wrong with it?
My goal with the throwaway program was to isolate the READ and see if the compiler balked at it for some reason. The "0" vs. "O" error is pretty common (I sure do it a lot---bummer that those keys are so close). Glad you found it. BTW: One way to make it easier for others to read the code is to enclose it in the "code" tags used on this site. Highlight the code and click on the "pound sign" above the Message field. It turns the text into monospaced typeface and the zeroes will be rendered with a little dot in the middle---at least they do on my desktop. Another thing you could do would be to use lowercase characters in your code. Except for the IBM FORTRAN-IV and FORT-H compilers and DEC FORTRAN-IV compilers, lowercase characters in statements have been acceptable in FORTRAN source code. I recall that the RT-11 and RSX-11M-PLUS F77 compilers did as did VAX FORTRAN as do the GNU compilers. With lowercase statements ("o" and "0" are readily differentiated).
As for that error message: I get it, too. I never opened an actual file to be attached to unit "1". (Remember from above: I was only using the compiler to verify syntax) Try:
Code:
program test
implicit none
integer*2 nn2
parameter (nn2 = 10)
real*4 tio(nn2)
integer*1 i
open(1, file='test.data')
read(1, *) (tio(i), i=1, nn2)
close(1)
write(*, '(1x, f10.1)') (tio(i), i=1, nn2)
end
with a file 'test.data' that contains 1 record with 10 numbers/record (remember: nn2=10).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.