views:

2175

answers:

2

Is there an analog of the "-fdefault-real-8" gfortran (the GNU Fortran 95 compiler) option in g77 (the GNU Fortran 77 compiler)? This option sets the default real type to an 8-byte wide type.

I currently have code where single-precision arithmetic is limiting my accuracy, and so I need double-precision. (It's not just intermediate values that I want to be in double-precision, which is an FPU flag; I want everything to be in double-precision.) I know that I have some other approaches (using gfortran, using other compilers, or changing all REALs to DOUBLE PRECISIONs), but they're not ideal for my situation.

So, is there any way to set the default real type to be double precision, namely 8 bytes wide, in g77?

+1  A: 

If you can't find a flag in the man pages, you might try a #define macro.

#define REAL DOUBLE PRECISION
Scottie T
Good idea! I think it leaves the problem of constants still being in single-precision, but I suppose that's okay ... (see http://www.fourmilab.ch/fourmilog/archives/2004-11/000432.html )
A. Rex
Accepted as the best idea, if not directly answering the question (there might not *be* an answer).
A. Rex
Rex, one thing to look out for is case sensitivity. You should probably define an upper case macro and a lower case macro.
Scottie T
A: 

Since a lot of FORTRAN 77 is still legal, is it possible to use gfortran to compile your FORTRAN 77 code, and supply the -fdefault-real-8 option?

Tim Whitcomb
Yeah, that's a good idea, too. I mentioned that gfortran isn't ideal for my situation because the code doesn't compile with gfortran for some reason. It's somewhat of a priority for me to figure out precisely why not ...
A. Rex