LBL logo Lawrence Berkeley National Laboratory ยป Earth Sciences Division
Questions & Comments | Privacy & Security Notice

TOUGH Issues & Solutions

The following is an incomplete list of installation and simulation issues related to teh TOUGH codes, along with suggestions for how to resolve them.

Issue 1: Wrong estimation of machine precision leads to non-performance (issue arises on 64-bit machines)

Issue 2: Wrong end-of-line character leads to compilation and run-time errors

Issue 3: Installation of TOUGH2-MP with METIS Version 5

Issue 1: Precision

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.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.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 1.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 1.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 1.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:

      N10=PRECISION(A)
      DF=SQRT(EPSILON(A)/2)

The two functions PRECISION() and EPSILON() are intrinsic to FORTRAN90 or later FORTRAN versions. 

Issue 2: End-of-Line and Special Characters

Issue 2 - Compilation or Run-Time Errors

Depending on the system, text editor, and file distribution used, files may have invalid end-of-line or other special characters embedded, which leads to compilation errors (for source files) or run-time errors (for input files).

Solution 2 - Check End-of-Line Characters

Make sure each line of the Fortran source-code files and of all TOUGH input files (including files such a CO2TAB) have a proper end-of-line character. Use appropriate conversion script (e.g., dos2unix) or load files into a text editor and save it in a proper text format (for example, open the file using Microsoft Word and then save it as a plain text file, with the box "Insert line break" checked.)

Do not use tabulators in TOUGH input files; use a typewriter font (e.g., Courier New) and the space bar to advance to to appropriate column.

Issue 3: METIS Version for TOUGH2-MP

TOUGH2-MP uses METIS for graph partitioning.

 

Issue 3 - TOUGH2-MP Does Not Run with New METIS Version

In June of 2011, a new version of METIS became available.Version 5 of METIS made some API changes (http://glaros.dtc.umn.edu/gkhome/metis/metis/changes), which are not compatible with the API implemented in TOUGH2-MP.

Solution 3.1 - Use Version 4 of METIS

To get the current version of TOUGH2-MP to work, obtain Version 4 of METIS. Older versions of METIS can be found athttp://glaros.dtc.umn.edu/gkhome/fsroot/sw/metis/OLD. We recommend Version 4.0.3.

Solution 3.2 - Adapt METIS Calls to API of METIS Version 5

Modify the TOUGH2-MP fortran (Main_Comp.f) to use the new API of METIS Version 5.
To change the TOUGH2-MP Fortran source code, edit file Main_Comp.f and replace thefollowing section:
        if (PartReady==0) then
         nparts = nprocs
         if (EE_partitioner .EQ. 'METIS_Kway') then
            call METIS_PartGraphKway(nel, XADJ, ADJ, 
     &           NULL, NULL, 0, 1, nparts, 0, edgecut, part)
         elseif (EE_partitioner .EQ. 'METIS_VKway') then
            call METIS_PartGraphVKway(nel, XADJ, ADJ, 
     &        NULL, NULL, 0, 1, nparts, 0, edgecut, part)
         elseif (EE_partitioner .EQ. 'METIS_Recursive') then
            call METIS_PartGraphRecursive(nel, XADJ, ADJ, 
     &        NULL, NULL, 0, 1, nparts, 0, edgecut, part)
         end if
       else 
with:
        if (PartReady==0) then
          nparts = nprocs
          if (EE_partitioner .EQ. 'METIS_Kway') then
            call METIS_Partition_KWay_EdgeCut_Unweighted(nel, XADJ,
     &           ADJ, nparts, edgecut, part)
          elseif (EE_partitioner .EQ. 'METIS_VKway') then
            call METIS_Partition_KWay_Volume_Unweighted(nel, XADJ, 
     &           ADJ, nparts, edgecut, part)
          elseif (EE_partitioner .EQ. 'METIS_Recursive') then
            call METIS_Partition_Recursive_Unweighted(nel, XADJ, 
     &           ADJ, nparts, edgecut, part)
          end if
        else
Note that TOUGH2-MP has not been fully tested with METIS Version 5.