marcin
marcin

Reputation: 3571

minimal Fortran file that compiles with any compiler

CMake developers recommend adding a dummy Fortran file to tell CMake that static libraries need to be linked with Fortran libraries (for example when linking C program with LAPACK).

My first thought was to use empty dummy.f. But ifort 9.0 won't compile it.

What is the minimal portable dummy Fortran file?

Is old Intel compiler the only one that has problem with empty file?

Upvotes: 1

Views: 228

Answers (1)

user1220978
user1220978

Reputation:

Same error with GFortran and Absoft Fortran. Actually, you need a "program" block to build an executable. This dummy.f would work:

      program dummy
      end

According to standard, "A Fortran program must contain one main program and may contain any number of the other kinds of program units". (see "Fortran 95 handbook" by Adams et al., section 2.1.1 p.19)

Or in standard Fortran 95 same section 2.2.1, p.12:

A program consists of exactly one main program unit and any number
(including zero) of other kinds of program units. The set of program
units may include any combination of the different kinds of program
units in any order as long as there is only one main program unit.

Upvotes: 3

Related Questions