PDA

View Full Version : Fortran77: What does a period in the middle of an eq mean?


dimensionless
Oct14-05, 05:44 PM
I'm trying to comprehend some old Fortran 77 code. I've run across an a line of code that resembles the following:

R(1)=2.*RL(1)*N(1)

What does the period in the above code mean?

DuncanM
Oct14-05, 06:36 PM
I'm no Fortran expert, but I'll make an educated guess:
I suspect the period is there simply to indicate to the compiler that the "2" is a float variable rather than an integer. Without the period, the compiler might treat the "2" as an integer, which could cause problems elsewhere in the program.

ranger
Oct14-05, 07:38 PM
here (http://www.ictp.trieste.it/~manuals/programming/sun/fortran/f77rm/1_elements.doc.html) has list of fortran symbols. According to them the period(.) is a Radix point, delimiter for logical constants and operators, record fields.

Dr Transport
Oct14-05, 08:36 PM
DuncanM has it corretct, 2 is an integer, 2. a float. Also can be written as

R(1)=float(2)*RL(1)*N(1)

dimensionless
Oct16-05, 04:26 PM
When does the period need to be used?

Dr Transport
Oct16-05, 07:28 PM
If you want R(1) to be a float, you have to use either 2. or float(2) in the expression, if not R(2) probaly will be truncated to an integer value. Many of the more recent compilers will overlook this and convert it to a float variable, it is just good programming practice to have it in there or else you may have problems down the road.