- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @all,
latest confusion I have concerns declaration and include files. Consider the following code:
PROGRAM ABC
REAL SD(16)
! several further declarations
include 'SOMEFTN.INC'
! REAL SD(16)
! Some file 10 gets opened
READ(10,' (1X,''SD(1) '',28X,F10.3)',END=20)SD(1)
END
The problem now is:
Error: Constants and expressions are invalid in read-only I/O lists. [SD]
Background: In the someftn.inc this variable SD is used and modified.
When I declare SD again after the include line (outcommented above), the compilation works. But I fear that all the manipulation done within the include file concerning SD gets lost. Am I right or wrong? And how can this be solved better?
(Intel Fortran Compiler 8.0 used)
TIA
Harald
PS: If I leave out the complete include line and the second declaration, I get
"Fatal: There has been an internal compiler error (C0000005). (code 1)"
Whatever that means...
Message Edited by h-faber on 04-04-2005 08:19 AM
Link Copied
11 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If the compiler were accepting a declaration of SD() from the include file, a subsequent re-declaration should be flagged. So I would agree with your apparent suspicion that include processing is in trouble. Likewise, the error you quote appears to imply that no declaration was seen. Pre-processing was broken in the 8.0 Windows Fortrans. I suggest you try a current version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't see that preprocessing is in use here and I would want to see all the sources to reproduce the problem. My guess is that there is something important in the files not shown and that the compiler error is correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Isn't the compiler complaining because the format string for the READ statement contains the string "SD(1)" as part of the I/O list? Shouldn't the I/O list of a READ statement contain only variables?
Mike D.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An array element is a variable, at least in this context.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, actually I still do not understand why the compiler speaks of constants or expressions. But the I/O can be because in the included file there is some file input/output operation. I changed it so that this is no longer an included file but a subroutine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would still like to see a complete example that shows the original problem. Would you please send it (as a ZIP) to me at steve dot lionel at intel dot com? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
it is customer's code so I have to ask for permission or refactor some variables and names.
it is customer's code so I have to ask for permission or refactor some variables and names.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm talking about the first occurrence of SD(1) in the READ statement, not the second.
READ(10,' (1X,''SD(1) '',28X,F10.3)',END=20)SD(1)
Isn't it illegal to read a character constant, and isn't that what the error message at the beginning of this thread is saying?
Mike D.
Message Edited by durisinm on 04-06-2005 02:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, I see. Hmm. Yes, that's true - character constants in a format used for a READ are not allowed. I was looking elsewhere and missed that. Good catch.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So this is a change? On VMS it worked that way so far, using Fortran 77 code/compiler. Anyway thanks for pointing this out!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
durisinm wrote:
I'm talking about the first occurrence of SD(1) in the READ statement, not the second.READ(10,' (1X,''SD(1) '',28X,F10.3)',END=20)SD(1)Isn't it illegal to read a character constant, and isn't that what the error message at the beginning of this thread is saying?Mike D.Message Edited by durisinm on 04-06-2005 02:04 PM
This sounds senseful of course - except that the code compiles when I use
CALL someftn()
instead of
INCLUDE someftn.inc
(After changing the included file to a subroutine inits first line)
The question remains:
Why does it compile without errors when I use CALL, but does not compile when I try to INCLUDE? The READ(...) shouldn't play a role I'd say. Am I wrong?

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page