24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2. For thread-safety and reentrancy, the include file /usr/include/fpdc.h contains a<br />

THREADLOCAL directive that is protected by the trigger constant <strong>IBM</strong>T. The<br />

invocation commands xlf_r, xlf_r7, xlf90_r, xlf90_r7, xlf95_r, and xlf95_r7 turn<br />

on the -qthreaded compiler option by default, which in turn implies the trigger<br />

constant <strong>IBM</strong>T. If you are including the file /usr/include/fpdc.h in code that is<br />

not intended to be thread-safe, do not specify <strong>IBM</strong>T as a trigger constant.<br />

Related In<strong>for</strong>mation: For more in<strong>for</strong>mation about the bits in the FPSCR register<br />

that correspond to the fpstat array elements, see the<br />

POWERstation and POWERserver ® Hardware Technical<br />

Reference - General In<strong>for</strong>mation.<br />

Minimizing Rounding Errors<br />

There are several strategies <strong>for</strong> handling rounding errors and other unexpected,<br />

slight differences in calculated results. You may want to consider one or more of<br />

the following strategies:<br />

v Minimizing the amount of overall rounding<br />

v Delaying as much rounding as possible to run time<br />

v Ensuring that if some rounding is per<strong>for</strong>med in a mode other than<br />

round-to-nearest, all rounding is per<strong>for</strong>med in the same mode<br />

Minimizing Overall Rounding<br />

Rounding operations, especially in loops, reduce code per<strong>for</strong>mance and may have<br />

a negative effect on the precision of computations. Consider using double-precision<br />

variables instead of single-precision variables when you store the temporary results<br />

of double-precision calculations, and delay rounding operations until the final<br />

result is computed. You can also specify the hssngl suboption of -qfloat instead of<br />

converting a stored single-precision result back to double-precision. This suboption<br />

preserves computed double-precision results so that they can be used again later.<br />

Delaying Rounding until Run Time<br />

The compiler evaluates floating-point expressions during compilation when it can,<br />

so that the resulting program does not run more slowly due to unnecessary<br />

run-time calculations. However, the results of the compiler’s evaluation might not<br />

match exactly the results of the run-time calculation. To delay these calculations<br />

until run time, specify the nofold suboption of the -qfloat option.<br />

The results may still not be identical; <strong>for</strong> example, calculations in DATA and<br />

PARAMETER statements are still per<strong>for</strong>med at compile time.<br />

The differences in results due to fold or nofold are greatest <strong>for</strong> programs that<br />

per<strong>for</strong>m extended-precision calculations or are compiled with the -O option or<br />

both.<br />

Ensuring that the Rounding Mode is Consistent<br />

You can change the rounding mode from its default setting of round-to-nearest.<br />

(See <strong>for</strong> examples.) If you do so, you must be careful that all rounding operations<br />

<strong>for</strong> the program use the same mode:<br />

v Specify the equivalent setting on the -qieee option, so that any compile-time<br />

calculations use the same rounding mode.<br />

v Specify the rrm suboption of the -qfloat option, so that the compiler does not<br />

per<strong>for</strong>m any optimizations that require round-to-nearest rounding mode to work<br />

correctly.<br />

294 <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> : User’s <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!