FORTRAN error #6404: This name does not have a type, and must have an explicit type

Pavigo picture Pavigo · Dec 11, 2011 · Viewed 21.9k times · Source

I'm new to FORTRAN, and getting this error #6404.

my_file.f(11): error #6404: This name does not have a type, and must have an explicit type.
[POTENCIAL]      d=POTENCIAL(1.0,1.0,1.0,1.0,1.4,1.4)

This is with the ifort compiler, and I hope it is not a compiler bug.

Any ideas where I'm wrong?

  program iiuu
  implicit none
  REAL*8 d
  d=POTENCIAL(1.0,1.0,1.0,1.0,1.4,1.4)
  write(*,*) 'potential=', d
  END program iiuu

  FUNCTION POTENCIAL(R1,R2,R3,R4,R5,R6)
  REAL*8 R1,R2,R3,R4,R5,R6,V2,V3,V4
  DIMENSION R(6)
  R(1)=R1
  R(2)=R2
  R(3)=R3
  R(4)=R4
  R(5)=R5
  R(6)=R6
  V2=V2BODY(R)
  V3=V3BODY(R)
  V4=V4BODY(R)
  POTENCIAL=V2+V3+V4+VADD(R)
  RETURN
  END

  FUNCTION V2BODY(R)
  .....
  .....

Answer

ev-br picture ev-br · Dec 11, 2011

No, it is not a compiler bug. Here's an edit of your code which has at least a chance of compiling:

program iiuu
  implicit none
  REAL*8 d
  d=POTENCIAL(1.0d0,1.0d0,1.0d0,1.0d0,1.4d0,1.4d0)
  write(*,*) 'potential=', d

  contains

  real*8 FUNCTION  POTENCIAL(R1,R2,R3,R4,R5,R6)
  REAL*8 R1,R2,R3,R4,R5,R6,V2,V3,V4
  real*8, DIMENSION(6) :: R
  R(1)=R1
  R(2)=R2
  R(3)=R3
  R(4)=R4
  R(5)=R5
  R(6)=R6
  V2=V2BODY(R)
  V3=V3BODY(R)
  V4=V4BODY(R)
  POTENCIAL=V2+V3+V4+VADD(R)
  END function potencial

  END program iiuu
  1. Your potencial function did not have a return type (which is the original error message you came across)
  2. It did not return anything (return statement was not necessary)
  3. At the call point compiler had no idea where to look for the function. Either package your functions into modules and use them, or use contains statement, like in the example above
  4. 1.0 is single-precision. Use 1.d0 to tell the compiler it's a double precision number
  5. Why on earth do you send six numbers instead of having an array as an argument of the potencial function?