Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)
  .....
  .....
like image 588
Pavigo Avatar asked Dec 11 '11 08:12

Pavigo


People also ask

What is Fortran runtime error?

The likely cause of this error is that the processor attempted to parse the contents of the external input file that you provided to the ParaMonte routines. However, while doing do, it reached the end of file before completing the input file reading.

How do you find errors in Fortran?

Most errors in Fortran routines can be identified by the information provided in Fortran runtime messages, which begin with the prefix "FOR". The Fortran compiler cannot identify all possible errors.

What is floating point error in Fortran?

Floating-Point Exceptions and Fortran In general, a message results if any one of the invalid, division-by-zero, or overflow exceptions have occurred. Inexact exceptions do not generate messages because they occur so frequently in real programs.

How do you stop a code in Fortran?

If you wish execution of your program to cease, you can insert a stop statement.


2 Answers

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?
like image 140
ev-br Avatar answered Sep 30 '22 02:09

ev-br


I got it to work. Just changed it to correct data type representation. The rest still the same.

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

FUNCTION POTENCIAL(R1,R2,R3,R4,R5,R6)
IMPLICIT REAL*8(A-H,O-Z)
DIMENSION R(6)
R(1)=R1
R(2)=R2
......
......
like image 38
Pavigo Avatar answered Sep 30 '22 02:09

Pavigo