Hello Yigun,
the attached log file is not very helpful, it lacks quite some
information. This is not your fault, I improved the script. If you want,
you can use the attached version.
Part of the log file is the following line:
> dumux/cmake.opts: file not found
This indicates, that from the folder where dunecontrol is executed, no
dumux/cmake.opts was found. I don't know how this can happen. Can you
check whether the file dumux/dumux/cmake.opts exists relative to your
installdumux.py file?
Further, you can execute in the dumux forder (not dumux/dumux) the
following command and share the output:
./dune-common/bin/dunecontrol --opts=dumux/cmake.opts all
Bye
Christoph
Am 20.07.23 um 06:03 schrieb Yiqun Ma:
Dear Sir/Madam,
I am a newbie to DuMux and I am getting this error while installing
using the script in
https://dumux.org/docs/doxygen/master/installation.html
<https://dumux.org/docs/doxygen/master/installation.html>. What should I
do to fix it please?
All the best,
Yiqun
#!/usr/bin/env python3
# SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
# SPDX-License-Identifier: GPL-3.0-or-later
"""
One click install script for dumux
"""
import os
import sys
import argparse
import subprocess
import textwrap
from shutil import which
class _Version:
def __init__(self, version: str) -> None:
self._version = [int(v) for v in version.strip(" ").strip("\n").split(".")]
def __lt__(self, other) -> bool:
for versionSelf, versionOther in zip(self._version, other._version):
if versionSelf < versionOther:
return True
if versionSelf > versionOther:
return False
return False
parser = argparse.ArgumentParser(
prog="installdumux",
usage="./installdumux.py [OPTIONS]",
description="This script downloads and compiles the latest release of Dumux.",
)
# Optional arguments
parser.add_argument("--dune-version", default="2.9", help="Dune version to be checked out.")
parser.add_argument("--dumux-version", default="3.7", help="Dumux version to be checked out.")
args = vars(parser.parse_args())
duneBranch = (
args["dune_version"] if args["dune_version"] == "master" else "releases/" + args["dune_version"]
)
dumuxBranch = (
args["dumux_version"]
if args["dumux_version"] == "master"
else "releases/" + args["dumux_version"]
)
def showMessage(message):
"""Pretty print message"""
print("*" * 120)
print(message)
print("*" * 120)
def checkCppVersion():
"""Check compiler version"""
requiredversion = "9.3"
result = subprocess.check_output(["g++", "-dumpversion"]).decode().strip()
if _Version(result) < _Version(requiredversion):
print("-- An error occurred while checking for prerequistes.")
raise Exception(
f"g++ greater than or equal to {requiredversion} "
"is required for dumux releases >=3.2!"
)
def runCommand(command, workdir="."):
"""Run command with error checking"""
with open("../installdumux.log", "a") as log:
print("> ", " ".join(command), file=log)
with subprocess.Popen(
command,
stdout=log,
stderr=log,
universal_newlines=True,
cwd=workdir,
) as popen:
returnCode = popen.wait()
if returnCode:
message = textwrap.dedent(
f"""\
(Error) The command {command} returned with non-zero exit code
If you can't fix the problem yourself consider reporting your issue
on the mailing list (dumux@listserv.uni-stuttgart.de) and
attach the file 'installdumux.log'
"""
)
showMessage(message)
print(message, file=log)
sys.exit(1)
def gitClone(url, branch=None):
"""Clone git repo"""
clone = ["git", "clone"]
if branch:
clone += ["-b", branch]
runCommand(command=[*clone, url])
def gitSetBranch(folder, branch):
"""Checkout specific git branch"""
checkout = ["git", "checkout", branch]
runCommand(command=checkout, workdir=folder)
# clear the log file
with open("installdumux.log", "w") as _:
pass
log = open('installdumux.log', 'a')
#################################################################
#################################################################
# (1/3) Check some prerequistes
#################################################################
#################################################################
programs = ["git", "gcc", "g++", "cmake", "pkg-config"]
showMessage("(1/3) Checking all prerequistes: " + " ".join(programs) + "...")
print("(1/3) Checking all prerequistes: " + " ".join(programs) + "...", file=log)
# check some prerequistes
for program in programs:
if which(program) is None:
print("-- An error occurred while checking for prerequistes.")
raise Exception(f"Program {program} has not been found.")
if which("paraview") is None:
print(
"-- Warning: paraview seems to be missing. You may not be able to view simulation results!"
)
checkCppVersion()
showMessage("(1/3) Step completed. All prerequistes found.")
print("(1/3) Step completed. All prerequistes found.", file=log)
#################################################################
#################################################################
# (2/3) Clone modules
#################################################################
#################################################################
# make a new folder containing everything
os.makedirs("./dumux", exist_ok=True)
os.chdir("dumux")
showMessage(
"(2/3) Cloning repositories. This may take a while. "
"Make sure to be connected to the internet..."
)
print("(2/3) Cloning repositories. This may take a while.", file=log)
# the core modules
for module in ["common", "geometry", "grid", "localfunctions", "istl"]:
if not os.path.exists(f"dune-{module}"):
gitClone(f"https://gitlab.dune-project.org/core/dune-{module}.git", duneBranch)
else:
print(f"-- Skip cloning dune-{module} because the folder already exists.")
print(f"-- Skip cloning dune-{module} because the folder already exists.", file=log)
gitSetBranch(f"dune-{module}", duneBranch)
# dumux
if not os.path.exists("dumux"):
gitClone("https://git.iws.uni-stuttgart.de/dumux-repositories/dumux.git", dumuxBranch)
else:
print("-- Skip cloning dumux because the folder already exists.")
print("-- Skip cloning dumux because the folder already exists.", file=log)
gitSetBranch("dumux", dumuxBranch)
showMessage("(2/3) Step completed. All repositories have been cloned into a containing folder.")
print("(2/3) Step completed. All repositories have been cloned into a containing folder.", file=log)
#################################################################
#################################################################
# (3/3) Configure and build
#################################################################
#################################################################
showMessage(
"(3/3) Configure and build dune modules and dumux using dunecontrol. "
"This may take several minutes..."
)
print("(3/3) Configure and build dune modules and dumux using dunecontrol.", file=log)
# run dunecontrol
runCommand(command=["./dune-common/bin/dunecontrol", "--opts=dumux/cmake.opts", "all"])
showMessage("(3/3) Step completed. Successfully configured and built dune and dumux.")
print("(3/3) Step completed. Successfully configured and built dune and dumux.", file=log)
#################################################################
#################################################################
# Show message how to check that everything works
#################################################################
#################################################################
TEST_PATH = "dumux/dumux/build-cmake/test/porousmediumflow/1p"
if dumuxBranch == "master" or _Version(args["dumux_version"]) > _Version("3.3"):
TEST_PATH += "/isothermal"
else:
TEST_PATH += "/implicit/isothermal"
showMessage(
"(Installation complete) To test if everything works, "
"please run the following commands (can be copied to command line):\n\n"
f" cd {TEST_PATH}\n"
" make test_1p_tpfa\n"
" ./test_1p_tpfa\n"
" paraview *pvd\n"
)
print("(Installation complete)", file=log)
_______________________________________________
DuMux mailing list
DuMux@listserv.uni-stuttgart.de
https://listserv.uni-stuttgart.de/mailman/listinfo/dumux