fortran 77 conflicting types in external

375 views Asked by At

I'm working with a F77 code, and I am encountering a problem in the compilation. I think I've narrowed down the problem but don't know a straight forward way of fixing it.

The code is extremely long so I'll try to be as clear as possible with the little snippets I use.

The error is the following:

/tmp/fort77-4812-1.c:2728:12: error: conflicting types for ‘func_’
doublereal func_(doublereal *e)

/tmp/fort77-4812-1.c:272:43: 

note: previous declaration of ‘func1_’ was here

extern /* Subroutine */ int func1_(), func2_();
                                       ^

where func(n) is some function. This happens with both func1 and func2 and they both have the same format, they differ in arithmetic.

The code starts like this:

Implicit double precision(a-h,o-z)
...
//initialization of some Arrays & parameters
...
external func1,func2
...
...
...

function func1(n)
implicit double precision(a-h,o-z)
...
...
end

I think the external is trying to keep the function as int but it is defined as a realdouble because of the implicit double.

Any thoughts?

1

There are 1 answers

3
casey On

This looks like an error caused by your choice of compiler, which I am assuming is f2c, which is a language translator. The problem is the translation is not handling the external attribute declaration properly and is producing a C language variable declaration which is not respecting your implicit typing rules (which appears to be a bug I cannot reproduce with f2c version 20060506).

I recommend using a proper Fortran compiler instead of f2c.