- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have quite a bit of legacy Fortran code that we compile with the Compaq Fortran f90 compile on Tru64 Unix and the Intel Visual Fortran compiler on Windows XP. We run on both platforms. We have a discrepancy between the 2 compilers.
Take this sample program:
REAL*4 A(5)/ 5*0/
DATA A(2) /30.0/
DATA A(4) /20.0/
WRITE (6,*)A
STOP
END
The array is initialized on declaration and also with a DATA statement. The program compiles with both compilers; however, with the Compaq compiler, the variable is initialized with the DATA statement, with the Intel Fortran Compiler, the DATA statement does not initialize the variable, the array is initialized with the initial declaration statement of 0.
Is there some way that we can get the Intel Fortran compiler to behave like the Compaq compiler using compiler flags? Does the latest version of the Intel Compiler behave the same? Our current Package ID is W_FC_C_9.0.025
I realize that the program above displays poor programming practise and either the DATA statement or the initialization at declaration should be removed; however, we have many lines of code and their is no guarantee that we can correct all instances which may lead to unwanted behaviour in the future.
Take this sample program:
REAL*4 A(5)/ 5*0/
DATA A(2) /30.0/
DATA A(4) /20.0/
WRITE (6,*)A
STOP
END
The array is initialized on declaration and also with a DATA statement. The program compiles with both compilers; however, with the Compaq compiler, the variable is initialized with the DATA statement, with the Intel Fortran Compiler, the DATA statement does not initialize the variable, the array is initialized with the initial declaration statement of 0.
Is there some way that we can get the Intel Fortran compiler to behave like the Compaq compiler using compiler flags? Does the latest version of the Intel Compiler behave the same? Our current Package ID is W_FC_C_9.0.025
I realize that the program above displays poor programming practise and either the DATA statement or the initialization at declaration should be removed; however, we have many lines of code and their is no guarantee that we can correct all instances which may lead to unwanted behaviour in the future.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a violation of the Fortran standard, but you are correct that CVF accepted it as an extension. The standard says: "A variable, or part of a variable, shall not be explicitly initialized more than once in a program.
We lost this behavior with the move to the Intel code generator. We have an open feature request to bring it back. I note that you also reported this through Intel Premier Support - your request will be added to the list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
This is a violation of the Fortran standard, but you are correct that CVF accepted it as an extension. The standard says: "A variable, or part of a variable, shall not be explicitly initialized more than once in a program.
We lost this behavior with the move to the Intel code generator. We have an open feature request to bring it back. I note that you also reported this through Intel Premier Support - your request will be added to the list.
That feature should have a rather difficult means of enabling it
ifort -i_realy_do_want_to_overlay_DATA_initializations
Some option that you cannot possibly mistype.
When you are combining multiple files from different sources, it would not be unusual to expect a conflict with something like
COMMON /TEMP_DATA/ ...
in multiple files. Each of which may assume their initializer is the active initialization.
In this case you want a linker error message so you can fix the problem.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Initialization of the same common in multiple files is not possible on Windows, as the linker will prohibit it. We're not going to try to support that.

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