Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
237 Views

Compile old fortran source code with modern Intel Fortran Compiler

Hello everyone,

I have an old console application built with Lahey/Fujitsu Fortran 95 compiler. I want to compile these Fortran 95 source files with the Intel
Visual Fortran Compiler 19.0 and Visual Studio 2017. Unfortunately in Visual Studio appear 238 errors. What could be the reason and how to solve the issues properly?

One error is for example #6236: A specification statement cannot appear in the executable section.

I already found articles in which such a problem, to compile older source fortran files with modern compilers, is described. As a reason for those errors is declared that modern compilers are not compatible with old fortran standard.

I already searched for extensions, that fix the errors automatically but couldnt find something appropriate.

Thanks for hints and suggestions.
 

0 Kudos
30 Replies
Highlighted
232 Views

For that specific error see: https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/738193

Also see: https://www.physicsforums.com/threads/a-specification-statement-cannot-appear-in-the-executable-sect...

Note, the solution (not given in link) is to either:

1) insert end program before subroutine compute, or
2) add contains preceding the subroutine (iow make the subroutine a contained procedure)

Jim Dempsey

0 Kudos
Highlighted
Black Belt
232 Views

I suspect that you are compiling fixed format Fortran source code with the compiler treating it as free format source (or vice versa). Such errors are quite easy to rectify provided you show us the source code. You may attach a zipped-up set of sources or, if the source code is short, use the {code} button to include the source code in your reply.

Almost always, Fortran 95 source code should get compiled by a F2003 or F2008 compiler with no complaints or problems.

0 Kudos
Highlighted
Beginner
232 Views

Thanks for the replies. But there appear about 240 errors. Maybe there is an option in Visual Studio to enable Fortran 95 syntax. I can not post the source code because it is a code of a program at my university. So I guess the only way ist to correct the specific errors myself. In Visual Studio you can enable the f2003 semantics but not f2003 syntax. I am new at this section so I dont really understand what fixed format Fortran source or free format source code is.

Greetings

0 Kudos
Highlighted
Valued Contributor II
232 Views

There is no specific Fortran 95 syntax that is not also incorporated in Fortran 2003 (some very old stuff has been deleted from the standard, but not necessarily from the compilers for precisely the reason to be still able to compile old program code).

What has changed is that compilers are much better at diagnosing source code problems. It may be that you are running into that. As you are not able to pos tthe source code, are you at least able to show us fragments that the compiler complains about?

0 Kudos
Highlighted
Beginner
232 Views

Here are some fragments ...

error #6669: The specification of this object is invalid.
REAL::hr(4,4)  &

error #8294: This field width 'W' must be immediately followed by a dot (.).   [12]     
read(pref_file, '(e12)') initial_move

error #6404: This name does not have a type, and must have an explicit type.   [LASTFALL]          
WRITE(14,'(A,I2)',ADVANCE='YES',ERR=200) '  SPC =',lastfall

0 Kudos
Highlighted
Honored Contributor I
232 Views

@v. vladimir,

Will you be interested in taking a look at a Fortran textbook, say Modern Fortran Explained?

https://play.google.com/store/books/details/Modern_Fortran_Explained_Incorporating_Fortran_201?id=sB...

This may allow you to help yourself in the best and fastest way possible.

0 Kudos
Highlighted
Valued Contributor III
232 Views

I agree with #3. What is the extension of the source files? .for or .f90 the & at the line end for error 6669 suggests it is free format and hence the file should have a .f90 extension.

0 Kudos
Highlighted
Valued Contributor III
232 Views

You also have code errors, E12 is invalid E12.2 would be valid. The old compiler did not detected this error and must have assumed some behaviour.

0 Kudos
Highlighted
New Contributor II
232 Views

I think to be written with 'I2' format, lastfall must be declared as an integer.  I suspect that you have many undeclared variables, perhaps because the old code assumed that names beginning with 'i' to 'n' referred to integers.  I don't know if there is a compiler option that does that.

0 Kudos
Highlighted
Black Belt
232 Views

Well, if one is new to Fortran, has a source code that cannot be shown and is generating hundreds of syntax errors, one has to work at removing those limitations, one by one, or conclude that one has been given an impossible task.

0 Kudos
Highlighted
New Contributor I
232 Views

When I make many changes to a source file or create a completely fortran new source file, before compiling the file with IVF in Visual Studio, I am still using Lahey/Fujitsu 97  for a first compilations. Some useful warnings are not yet generated by IVF.  

0 Kudos
Highlighted
Valued Contributor III
232 Views

Luigi R. wrote:

When I make many changes to a source file or create a completely fortran new source file, before compiling the file with IVF in Visual Studio, I am still using Lahey/Fujitsu 97  for a first compilations. Some useful warnings are not yet generated by IVF.  

 

Interesting, could you give some examples of these?

0 Kudos
Highlighted
New Contributor I
232 Views

In my development work, the most important warning is the use of a variable before assigning to it some value. This is notified at compile time and it saves a lot of time. With IVF this case is detected only at run time debugging. I have raised this fact to IVF compiler developers many years ago.

Of course more recent Fortran features are marked as errors by Lahey compiler.

0 Kudos
Highlighted
Beginner
232 Views

andrew_4619 wrote:

I agree with #3. What is the extension of the source files? .for or .f90 the & at the line end for error 6669 suggests it is free format and hence the file should have a .f90 extension.

All the source files have a .f90 extension. I conclude that all the errors detected by the IVF Compiler during compilation, occured earlier as bugs during run time and not at compilation.

0 Kudos
Highlighted
Black Belt
232 Views

v, vladimir wrote:

All the source files have a .f90 extension. I conclude that all the errors detected by the IVF Compiler during compilation, occurred earlier as bugs during run time and not at compilation.

That is definitely an instance of jumping to a false conclusion.

I think that what is at issue here is that the source file compiled and ran fine with a certain set of options with the Lahey-Fujitsu compiler. The attempt at compiling with Ifort failed because the corresponding options were not used or the source file was modified in some way. 

Type out the contents of the lf95.fig file that was used with the Lahey-Fujitsu compiler, and report that here. We have be able to tell you the corresponding options for the Intel Fortran compiler.

0 Kudos
Highlighted
Beginner
232 Views

I have requested the lf95.fig file from my professor but it isnt clear if this file still exists with the configuration options. Also I got the information that extensions were used with the Lahey/Fujitsu Compiler. I dont know yet which were used. Anyway, is it helpful to know which extensions were used?

0 Kudos
Highlighted
Black Belt Retired Employee
232 Views

lf95 is one of a set of compilers that, inappropriately in my view, accepts the .f95 file type for Fortran free-form source. Intel Fortran doesn't, though you have to go to some lengths to get it to even try to compile a .f95 file. Maybe you renamed .f95 files to .f?

What would really help us is if you ZIPped the buildlog.htm from the project's Debug or Release folder and attached it to a reply here, as that would show us which options were used, the file name, and the complete and exact text of the error messages (which are incomplete in your post.) I agree with others that the issue is likely to be a mismatch of source form.

0 Kudos
Highlighted
New Contributor I
232 Views

This is the content of the LF95.fig file, included in the LF97 installation (opened with notepad). I have never used it.
==============================================================
# LF95.FIG: user default options for Lahey/Fujitsu Fortran 95
# Place your default options here. You may remove these comment lines.
# See the LF95 User's Guide for more information.
# Use only one of the following compiler switches to specify the
# target platform (T4=486, TP=Pentium, TPP=Pentium III/II/Pro).
# Warning: TPP is not compatible with earlier processors.
# -t4
# -tp
# -tpp

===========================================================

Regards

 

0 Kudos
Highlighted
Beginner
232 Views

LF95 has numerous specific extensions that were used in the source code. Some usable extensions in LF95 are ..

- Dollar sign as a letter
- DO UNTIL statement
- VALUE statement
- Binary, Octal, or Hexadecimal constant in a DATA, PARAMETER, or type declaration statement

I think the last extension above could be the reason for an error like:
error #6404: This name does not have a type, and must have an explicit type.

 

0 Kudos