0

Issues with TOUGH3 compilation

Hi there,

I am new to TOUGH, but want to install and use it now. I do have a copy of a recent version of the code (3.1.2), however, I have failed to install it so far, so I am hoping to find some help here!

I am trying to install on Linux Ubuntu 24.04 (running through WSL2, actually) and using a recent PETSC version (3.26). First, I did install PETSC following the instruction. In the end, there appears a prompt on the command line:

Now to check if the libraries are working do:
make PETSC_DIR=/home/rolft/petsc-3.26.0/ PETSC_ARCH=arch-t3 check

 

If I do that, I get the following output (which seems to suggest that the PETSC install went fine):

Running PETSc check examples to verify correct installation
Using PETSC_DIR=/home/rolft/petsc-3.26.0/ and PETSC_ARCH=arch-t3
C/C++ example src/snes/tutorials/ex19 run successfully with 1 MPI process
C/C++ example src/snes/tutorials/ex19 run successfully with 2 MPI processes
Fortran example src/snes/tutorials/ex5f run successfully with 1 MPI processCompleted PETSc check examples

 

After that, I changed into the TOUGH3 source directory and wanted to configure using:

./configure.sh --build-type=RELEASE --eos==eco2m --no-x11 --petsc-dir=/home/rolft/petsc-3.26.0 --petsc-arch=arch-t3

 

This fails, however, it seems due to compatibility issues with the CMake version. 

./configure.sh --build-type=RELEASE --eos==2 --no-x11 --petsc-dir=/home/rolft/petsc-3.26.0/ --petsc-arch=arch-t3
--eos==2
BUILD_TYPE = RELEASE
Build directories ready
Searching for a C compiler
Searching for mpicc
Build with C compiler: /usr/bin/mpicc
Searching for a C++ compiler
Searching for mpicxx
Build with C++ compiler: /usr/bin/mpicxx
Searching for a Fortran compiler
Searching for mpif90
Build with Fortran compiler: /usr/bin/mpif90
Searching for mpiexec
Searching for mpiexec
MPIEXEC used: /usr/bin/mpiexec
Compiler Check complete
Tool check complete
Running on a Debian system... -DMPI_EXEC=/usr/bin/mpiexec -DUSE_MPI:BOOL=TRUE -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/mpicxx -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/mpicc -DCMAKE_Fortran_COMPILER:FILEPATH=/usr/bin/mpif90 -DUSE_X11:BOOL=FALSE
./configure.sh: line 768: [: ==: unary operator expected

CMake Error at CMakeLists.txt:2 (cmake_minimum_required):
Compatibility with CMake < 3.5 has been removed from CMake.
Update the VERSION argument value.
Or, use the ... syntax  to tell CMake that the project requires at least but has been updated  to work with policies introduced by or earlier.
Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.

-- Configuring incomplete, errors occurred!
Script ERROR: Failed to configure TOUGH TPLS

 

Well, I did try to just comment out the line 2 in the CMakeLists.txt, which states that the mimimum version should be 2.8.5. That did not help. Neither did it help to change that version number to 3.5. Same error. I also added that this line to my configure.sh, as suggested by the previous output:

CONFIG_FLAGS="${CONFIG_FLAGS} -DCMAKE_POLICY_VERSION_MINIMUM=3.5"

 

But apart from this extra flag being shown when re-rerunning configure.sh, it does not lead to any changes.

 

Has anyone encountered this problem before? Any ideas how to resolve it?

 

Thanks so much in advance!

2 replies

null
    • kenny
    • 7 days ago
    • Reported - view

    You may use Codex. Create a new project for the folder where the tough3 is located.  Then just tell the agent that you want to compile it. That is all.

    • Tobias_Rolf
    • 6 hrs ago
    • Reported - view

    Dear Kenny, 

    thanks for this suggestion. With this, I was able to twist things and make TOUGH3 running on my machine incl. PETSC-/MPI-Support 😀

    Best, Tobias.

     

    ps. #######################################################################

    Just in case someone cares:

    the main problem was that my system was "too new" (using Ubuntu 26.04, Python 3.14, CMake 4.2.3), which leads to several incompatibilites. When building TOUGH there are SEVERAL CMakeLists.txt files, not only the one at top-level (i.e., in esd-tough3), in particular in the sources of METIS and AZTEC. All these start by checking whether the minimum requirement for CMake are met:

    cmake_minimum_required(VERSION 2.8)

    With a recent CMake (>4.X,), this fails, but changing the version in all relevant CMakeLists.txt files gets you going. However, every time I cleared my build (rm -r build/) and tried to rebuild, the problem returned: in the CMakeLists.txt for METIS and AZTEC, the VERSION is changed back to 2.8. And needs to be fixed again, but I am sure this can be fixed permanently relatively easily ...

    This was sufficient to build TOUGH3 only without PETSC and/or MPI support. After trying a few things, I gave up on PETSC 3.26 and downgraded to 3.17. The package xdrlib is needed then, but it isn't available anymore with Python 3.13+. A workaround is to load the alternative package py-xdrlib

    python -m pip install py-xdrlib

    But there were still issues between PETSC 3.17 and OpenMPI 5.0.10. A first fix were two small edits in the PETSC's MPI configuration script (~/petsc-3.17.0/config/BuildSystem/config/packages/MPI.py). In the definition of configureMPI2, I replaced:

    int a,b,c,d,flag,sendbuf[1]={1},recvbuf[1]={2};
    # replace with -->
    int a,b,c,d,flag,sendbuf[1]={1},recvbuf[1]={2},recvcounts[1]={1};

    and also

    if (MPI_Reduce_scatter(sendbuf,recvbuf,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD)) return 0;
    # replace with -->
    if (MPI_Reduce_scatter(sendbuf,recvbuf,recvcounts,MPI_INT,MPI_SUM,MPI_COMM_WORLD)) return 0;

    Next issue: Python 3.14 does not support the internal function "_parse_makefile" anymore.  I had to go to ~/petsc-3.17.0/config/gmakegen.py and replace the line 

    from sysconfig import _parse_makefile as parse_makefile

    with:

    def parse_makefile(fn, out=None):
        if out is None:
            out = {}
        with open(fn) as f:
            for line in f:
                if "=" in line:
                    key, value = line.split("=", 1)
                    out[key.strip()] = value.strip()
        return out

    Finally, one of the build-rules (MAKEFLAGS) in PETSC 3.17 was incompatible. To fix this, I had to go to ~/petsc-3.17.0/lib/petsc/rules and replace:

    libs: ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/files ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles
           +@cd ${PETSC_DIR} && MAKEFLAGS="-j$(MAKE_NP) -l$(MAKE_LOAD) $(MAKEFLAGS)" ${OMAKE_PRINTDIR} -f gmakefile ${MAKE_PAR_OUT_FLG} V=${V} libs

    with

    libs: ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/files ${PETSC_DIR}/${PETSC_ARCH}/tests/testfiles
           +@cd ${PETSC_DIR} && MAKEFLAGS="-j$(MAKE_NP) -l$(MAKE_LOAD) $(filter-out w,$(MAKEFLAGS))" ${OMAKE_PRINTDIR} -f gmakefile ${MAKE_PAR_OUT_FLG} V=${V} libs

    After this, I could rebuild PETSC:

    cd ~/petsc-3.17.0
    env -u MAKEFLAGS -u GNUMAKEFLAGS -u MFLAGS \
      /usr/bin/make --no-print-directory -j2 \
      PETSC_DIR=~/petsc-3.17.0 \
      PETSC_ARCH=arch-linux-openmpi-f all

    And finally, build TOUGH3 including PETSC and MPI  (here for eos=eco2n, as an example):

    cd ~/tough3-v112/esd-tough3
    ./configure.sh --build-type=RELEASE --eos=eco2n --no-x11 \
      --petsc-dir=~/petsc-3.17.0 \
      --petsc-arch=arch-linux-openmpi-f

    There are surely better ways to doing this, but this one worked for me.

Content aside

  • 6 hrs agoLast active
  • 2Replies
  • 24Views
  • 2 Following