Wrong estimation of machine precision leads to non-performance (issue arises on 64-bit machines)
All TOUGH simulators require 64-bit arithmetic for accurate results. The number of significant digits represented by the TOUGH programs is evaluated internally in subroutine FLOP. The result of this evaluation depends on the declaration of data types, chip architecture, and compiler options. The default value for numerically calculating derivatives (DFAC) is also determined by this evaluation. The result of this evaluation is printed to the TOUGH output file. Typically, the number of significant digist is 15, resulting in a default DFAC value of approximately 10-8. The following two deviations from this result may occur:
Issue 1 - Not Enough Significant Digits
If the number of significant digits turns out to b too small (e.g., 6), this indicates that default real type is set to a 4 byte wide type (instead of an 8 byte wide type), resulting in insufficient precision of floating-point operations.
Solution 1 - Use Appropriate Compiler Option
In some packages (e.g., TOUGH2-MP, TOUGHREACT, iTOUGH2), real numbers are declared as 8 byte wide variables (the issue should not occur); in others (specifically TOUGH2), real numbers are not declared explicitly, resulting in a default 4 byte type. Set an appropriate compiler option to ensure 64-bit arithmetic. The flag to be set depends on the compiler, but is typically -r8; -fdefault-real-8; real-size:64 or similar compiler option. Check the compiler user's guide.
Issue 2 - Too Many Significant Digits
The evaluation of the number of signifcant digits may fail if certain aggressive optimization levels are chosen on certain compilers. As a result, an unrealistic number of significant digits (e.g., 77) is obtained, leading to a wrong value for DFAC.
Solution 2.1 - Set DFAC in TOUGH Input File
Overwrite the default value of DFAC by specifying 1.0E-8 in Columns 51-60 of TOUGH input record PARAM.3 (see TOUGH2 Users' Guide).
Solution 2.2 - Change Source Code
In file t2cg22.f (for TOUGH2) or file it2main.f (for iTOUGH2), edit subroutine FLOP and replace the calculation of variables N10 and DF with the following two statements:
The two functions PRECISION() and EPSILON() are intrinsic to FORTRAN90 or later FORTRAN versions.