3

I have a piece of Fortran code and my Fortran editor (Force 2.0.9) can not understand the following line in that code.

real(kr8) :: rnum

I could not find anything about this type of declaration of variables. What does (kr8) mean? I really appreciate if anyone can explain it to me?

Pshemo
  • 122,468
  • 25
  • 185
  • 269
John Tab
  • 35
  • 4
  • 2
    `Force 2.0.9` has several [download options](http://lepsch.blogspot.de/2009/05/downloads.html) with different compilers. I would suggest that you get the one with `gfortran` and move away from the world of FORTRAN 77 into the nicer world of Fortran 90+. – Hristo Iliev Aug 03 '12 at 08:23

1 Answers1

6

This is short for:

real(kind=kr8) :: rnum

In this case, variable or parameter kr8 is specified elsewhere in the code - above this line if in the same procedure, or in a different file if it is accessed through a module. From its name, one could assume that kr8 is defined in such fashion that it has the kind of a double precision floating point number (8 bytes in size) for some particular compiler.

See your Fortran compiler documentation on what values the kind parameter can take for various precision and range of integer and real variables. If you are using force, your compiler is either gfortran, g95 or g77. The kind parameter is a feature introduced to Fortran 90, and if your compiler is g77, it is possible that you will not be able to compile using this parameter.

Answers to this SO question will also be useful to read: Fortran 90 kind parameter.

Community
  • 1
  • 1
milancurcic
  • 6,202
  • 2
  • 34
  • 47