Compare commits

...

18 Commits

Author SHA1 Message Date
d0324a97f3 ENH: install helpers to assist when installing into system mpi directories
- the problem noted in issue #1893 is caused by the rpm-mpi-hooks
  (fedora and redhat-8).

  For the additional mpi library qualifier (openmpi-x86_64) to be
  added to the requirements, the mpi-specific libraries (eg,
  libPstream.so) need to be installed in the mpi system directory
  (eg, /usr/lib64/openmpi).

  However, need to then create symlinks to ensure that the libraries
  are correctly found via our LD_LIBRARY_PATH and we don't get dummy
  libraries.
2020-11-05 18:34:54 +01:00
16e45fa114 BACKPORT: align wmake have_* scripts with v2006
- simplify maintenance
2020-11-05 18:34:54 +01:00
841e7fde9f BACKPORT: improve handling of pt-scotch headers/libraries
- provide dedicated detection 'have_ptscotch' function that can be
  used after the 'have_scotch' function.

  It sets the PTSCOTCH_ARCH_PATH, PTSCOTCH_INC_DIR, PTSCOTCH_LIB_DIR
  and helps when the serial and parallel versions are located with
  different logic.

2020-11-04 : include more recent fixes for finding scotch on redhat
2020-11-05 18:34:54 +01:00
40c6fb6bd7 BACKPORT: adjust wmake/scripts/*Functions according to v2006
- simplifies maintenance of detection scripts
2020-11-05 18:34:54 +01:00
c9345e0497 BACKPORT: wmake compiler flag handling as per v2006
- simplifies maintenance
2020-11-05 18:34:54 +01:00
cc9db3ea3a BACKPORT: relocate wmake binaries into project platforms/tools (#1647)
- can aid when creating source-only or binary-only packages

- replace dirToString binary with shell/awk equivalent for simpler
  maintenance. The utility is very rarely used (auto scanning to
  create Make/files) so there is no performance difference.
2020-11-05 18:34:53 +01:00
fbbff15eae BUG: extraneous brackets after Fluent cell types (fixes #1872)
ENH: limit output to 25 cell types per line for readability

- makes it easier to trace potential format errors etc

STYLE: downgrade warning about polyhedrals to a simple info message

- can assume that polyhedral support is widespread enough to not
  warrant a warning.
2020-10-29 11:28:56 +01:00
b68c1fc582 BUG: parallel foamToEnsight fails depending on lagrangian order (fixes #1873)
- the problem arises when output fields are missing on some
  processors.

  When the information is combined, the resulting HashTables can have
  different insertion orders. This poses an issue when there are hash
  key collisions and thus different chaining.

- Use sorted order.
2020-10-08 19:07:08 +02:00
a589f48d09 CONFIG: increment patch level 2020-07-27 11:52:30 +02:00
201c5d2cfa BUG: potential memory leaks in HashPtrTable::set (#1787)
- backported fix from develop
2020-07-27 11:52:30 +02:00
6d6ab639f3 CONFIG: increment patch level 2020-06-04 21:58:21 +02:00
d3f9f1bce4 BUG: missing compilation for some vtk conversion components (fixes #1720) 2020-06-04 21:57:38 +02:00
3eb1fdcf5f COMP: erroneous return from void method (fixes #1716) 2020-05-26 10:41:35 +02:00
579760b7f5 BUG: incorrect startLineNumber for primitiveEntry (fixes #1706) 2020-05-14 17:22:33 +02:00
7cfddaef77 BUG: Pair sort on construct did the opposite (fixes #1701) 2020-05-11 20:25:15 +02:00
3bf486b24b COMP: adjust for CGAL-4.14 changes 2020-05-11 16:34:31 +02:00
28ae07a26a CONFIG: additional packaging helpers, tutorial test helper
- bin/tools/create-mpi-config to query/write values for system openmpi.
  In some cases this can be used to avoid an mpicc requirement at runtime.

- adjust openfoam session to latest version,
  including -test-tutorial forwarding.

- adjust foamConfigurePaths to latest version

- removal of gperftools default config, as per develop
2020-04-20 20:22:27 +02:00
eb2b797d7a BUG: missing output for foamDictionary -includes (closes #1635)
- log to stdout when explicitly enabled
2020-03-16 17:37:17 +01:00
64 changed files with 4848 additions and 2085 deletions

View File

@ -24,8 +24,8 @@ command -v mpirun 2>/dev/null || true
echo "========================================"
date "+%Y-%m-%d %H:%M:%S %z" 2>/dev/null || echo "date is unknown"
echo "Starting compile ${WM_PROJECT_DIR##*/} ${0##*}"
echo " $WM_COMPILER $WM_COMPILER_TYPE compiler"
echo "Starting compile ${WM_PROJECT_DIR##*/} ${0##*/}"
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
echo "========================================"
echo
@ -36,9 +36,18 @@ echo
# Compile ThirdParty libraries and applications
if [ -d "$WM_THIRD_PARTY_DIR" ]
then
$WM_THIRD_PARTY_DIR/Allwmake
if [ -e "$WM_THIRD_PARTY_DIR"/Allwmake.override ]
then
if [ -x "$WM_THIRD_PARTY_DIR"/Allwmake.override ]
then "$WM_THIRD_PARTY_DIR"/Allwmake.override
fi
elif [ -x "$WM_THIRD_PARTY_DIR"/Allwmake ]
then "$WM_THIRD_PARTY_DIR"/Allwmake
else
echo "Skip ThirdParty (no Allwmake* files)"
fi
else
echo "No ThirdParty directory found - skipping"
echo "Skip ThirdParty (no directory)"
fi
echo "========================================"
@ -57,13 +66,13 @@ then
echo "========================================"
echo "Compile OpenFOAM modules"
echo
(cd $WM_PROJECT_DIR/modules 2>/dev/null && wmake -all)
(cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all)
fi
# Count files in given directory. Ignore "Test-*" binaries.
_foamCountDirEntries()
{
(cd "$1" 2>/dev/null && find -mindepth 1 -maxdepth 1 -type f 2>/dev/null) |\
(cd "$1" 2>/dev/null && find . -mindepth 1 -maxdepth 1 -type f 2>/dev/null) |\
sed -e '\@/Test-@d' | wc -l
}
@ -72,13 +81,13 @@ echo
date "+%Y-%m-%d %H:%M:%S %z" 2>/dev/null || echo "date is unknown"
echo "========================================"
echo " ${WM_PROJECT_DIR##*/}"
echo " $WM_COMPILER $WM_COMPILER_TYPE compiler"
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
echo
echo " api = $(wmakeBuildInfo -show-api 2>/dev/null)"
echo " patch = $(wmakeBuildInfo -show-patch 2>/dev/null)"
echo " bin = $(_foamCountDirEntries $FOAM_APPBIN) entries"
echo " lib = $(_foamCountDirEntries $FOAM_LIBBIN) entries"
echo " api = $(etc/openfoam -show-api 2>/dev/null)"
echo " patch = $(etc/openfoam -show-patch 2>/dev/null)"
echo " bin = $(_foamCountDirEntries "$FOAM_APPBIN") entries"
echo " lib = $(_foamCountDirEntries "$FOAM_LIBBIN") entries"
echo
echo "========================================"

View File

@ -1,2 +1,2 @@
api=1812
patch=200312
patch=200727

View File

@ -2,8 +2,11 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -60,13 +63,13 @@ void Foam::fluentFvMesh::writeFluentMesh() const
/ time().caseName() + ".msh"
);
Info<< "Writing Header" << endl;
Info<< "Writing Fluent Mesh" << endl;
fluentMeshFile
<< "(0 \"FOAM to Fluent Mesh File\")" << std::endl << std::endl
<< "(0 \"Dimension:\")" << std::endl
<< "(2 3)" << std::endl << std::endl
<< "(0 \"Grid dimensions:\")" << std::endl;
<< "(0 \"OpenFOAM to Fluent Mesh File\")" << nl << nl
<< "(0 \"Dimension:\")" << nl
<< "(2 3)" << nl << nl
<< "(0 \"Grid dimensions:\")" << nl;
// Writing number of points
fluentMeshFile
@ -215,8 +218,8 @@ void Foam::fluentFvMesh::writeFluentMesh() const
// Writing cells
fluentMeshFile
<< "(12 (1 1 "
<< nCells() << " 1 0)(" << std::endl;
<< "(12 (1 1 " << nCells() << " 1 0)" << nl
<< '(';
const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellModel& prism = cellModel::ref(cellModel::PRISM);
@ -225,44 +228,59 @@ void Foam::fluentFvMesh::writeFluentMesh() const
const cellShapeList& cells = cellShapes();
bool hasWarned = false;
label nPolys = 0;
int nElemPerLine = 25; // Start with linebreak and indent
forAll(cells, celli)
{
if (nElemPerLine == 25)
{
// 25 elements per line with initial indent (readability)
fluentMeshFile << "\n ";
nElemPerLine = 0;
}
else if (!(nElemPerLine % 5))
{
// Format in blocks of 5 (readability)
fluentMeshFile << token::SPACE;
}
fluentMeshFile << token::SPACE;
++nElemPerLine;
if (cells[celli].model() == tet)
{
fluentMeshFile << " " << 2;
fluentMeshFile << 2;
}
else if (cells[celli].model() == hex)
{
fluentMeshFile << " " << 4;
fluentMeshFile << 4;
}
else if (cells[celli].model() == pyr)
{
fluentMeshFile << " " << 5;
fluentMeshFile << 5;
}
else if (cells[celli].model() == prism)
{
fluentMeshFile << " " << 6;
fluentMeshFile << 6;
}
else
{
if (!hasWarned)
{
hasWarned = true;
WarningInFunction
<< "foamMeshToFluent: cell shape for cell "
<< celli << " only supported by Fluent polyhedral meshes."
<< nl
<< " Suppressing any further messages for polyhedral"
<< " cells." << endl;
}
fluentMeshFile << " " << 7;
fluentMeshFile << 7;
++nPolys;
}
}
fluentMeshFile << ")())" << std::endl;
fluentMeshFile
<< nl << "))" << nl;
if (nPolys)
{
Info<< "Mesh had " << nPolys << " polyhedrals." << endl;
}
// Return to dec
fluentMeshFile.setf(ios::dec, ios::basefield);

View File

@ -71,10 +71,10 @@ if (doLagrangian)
}
}
forAllConstIters(theseCloudFields, fieldIter)
// Field order may differ on individual processors, so sort by name
for (const word& fieldName : theseCloudFields.sortedToc())
{
const word& fieldName = fieldIter.key();
const word& fieldType = fieldIter.object();
const word& fieldType = theseCloudFields[fieldName];
IOobject fieldObject
(
@ -92,9 +92,13 @@ if (doLagrangian)
// but that combination does not work.
// So check the header and sync globally
const bool parRun = Pstream::parRun();
Pstream::parRun() = false;
fieldExists =
fieldObject.typeHeaderOk<IOField<scalar>>(false);
Pstream::parRun() = parRun;
reduce(fieldExists, orOp<bool>());
}

View File

@ -2,8 +2,11 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,6 +28,7 @@ Typedefs
CGAL3DKernel
Description
A typedef for selecting inexact (faster) or exact (slower) 3D model.
\*---------------------------------------------------------------------------*/
@ -36,13 +40,13 @@ Description
#ifdef CGAL_INEXACT
// Fast kernel using a double as the storage type
#include "CGAL/Exact_predicates_inexact_constructions_kernel.h"
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
#else
// Very robust but expensive kernel
#include "CGAL/Exact_predicates_exact_constructions_kernel.h"
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
#endif

View File

@ -2,8 +2,10 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -63,6 +65,7 @@ struct IndexedFace
Foam::label index;
Foam::label region;
};
struct My_items
:
public CGAL::Polyhedron_items_3

View File

@ -20,4 +20,5 @@ EXE_INC = \
LIB_LIBS = \
-L$(CGAL_ARCH_PATH)/lib \
-L$(CGAL_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
-lsurfMesh \
-lmeshTools

View File

@ -2,8 +2,11 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,14 +28,50 @@ License
#include "PolyhedronReader.H"
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
template<class HDS>
void Foam::PolyhedronReader::Build_triangle<HDS>::operator()(HDS& hds)
{
// Postcondition: hds is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HDS> B(hds, true);
B.begin_surface(s_.nPoints(), s_.size());
typedef typename HDS::Vertex Vertex;
typedef typename Vertex::Point Point;
for (const auto& pt : s_.points())
{
B.add_vertex(Point(pt.x(), pt.y(), pt.z()));
}
for (const auto& f : s_)
{
B.begin_facet();
for (const label verti : f)
{
B.add_vertex_to_facet(verti);
}
B.end_facet();
}
B.end_surface();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::PolyhedronReader::PolyhedronReader(const triSurface& s, Polyhedron& p)
{
Build_triangle<HalfedgeDS> triangle(s);
p.delegate(triangle);
// Populate index and region
Foam::label nTris = 0;
for
(
Facet_iterator fi = p.facets_begin();
@ -40,8 +79,10 @@ Foam::PolyhedronReader::PolyhedronReader(const triSurface& s, Polyhedron& p)
++fi
)
{
fi->index = nTris++;
fi->region = s[fi->index].region();
fi->index = nTris;
fi->region = s[nTris].region();
++nTris;
}
}

View File

@ -2,8 +2,10 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,28 +61,21 @@ class PolyhedronReader
public:
Build_triangle(const triSurface& s);
Build_triangle(const triSurface& s)
:
s_(s)
{}
void operator()(HDS& hds);
};
// Private Member Functions
//- No copy construct
PolyhedronReader(const PolyhedronReader&) = delete;
//- No copy assignment
void operator=(const PolyhedronReader&) = delete;
public:
// Constructors
//- Populate polyhedron from surface
PolyhedronReader(const triSurface& s, Polyhedron& p);
};
@ -90,12 +85,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "PolyhedronReaderTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,72 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "PolyhedronReader.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class HDS>
Foam::PolyhedronReader::Build_triangle<HDS>::Build_triangle
(
const triSurface& s
)
:
s_(s)
{}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
template<class HDS>
void Foam::PolyhedronReader::Build_triangle<HDS>::operator()(HDS& hds)
{
// Postcondition: hds is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HDS> B(hds, true);
B.begin_surface(s_.nPoints(), s_.size());
typedef typename HDS::Vertex Vertex;
typedef typename Vertex::Point Point;
const Foam::pointField& pts = s_.points();
forAll(pts, i)
{
const Foam::point& pt = pts[i];
B.add_vertex(Point(pt.x(), pt.y(), pt.z()));
}
forAll(s_, i)
{
const Foam::labelledTri& t = s_[i];
B.begin_facet();
B.add_vertex_to_facet(t[0]);
B.add_vertex_to_facet(t[1]);
B.add_vertex_to_facet(t[2]);
B.end_facet();
}
B.end_surface();
}
// ************************************************************************* //

View File

@ -2,8 +2,11 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -99,8 +102,10 @@ typedef CGAL::AABB_face_graph_triangle_primitive
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef boost::optional<Tree::Intersection_and_primitive_id<Segment>::Type>
Segment_intersection;
typedef boost::optional
<
Tree::Intersection_and_primitive_id<Segment>::Type
> Segment_intersection;
#endif // NO_CGAL
@ -630,17 +635,14 @@ labelPair edgeIntersectionsCGAL
segments.clear();
tree.all_intersections(segment_query, std::back_inserter(segments));
for
(
std::vector<Segment_intersection>::const_iterator iter =
segments.begin(),
end = segments.end();
iter != end;
++iter
)
for (const Segment_intersection& intersect : segments)
{
// Get intersection object
if (const Point* ptPtr = boost::get<Point>(&((*iter)->first)))
if
(
const Point* ptPtr = boost::get<Point>(&(intersect->first))
)
{
point pt
(
@ -649,7 +651,12 @@ labelPair edgeIntersectionsCGAL
CGAL::to_double(ptPtr->z())
);
Polyhedron::Face_handle f = (*iter)->second;
#if defined (CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1041400000)
Polyhedron::Face_handle f = (intersect->second);
#else
// 4.14 and later
Polyhedron::Face_handle f = (intersect->second).first;
#endif
intersections[edgeI].append
(
@ -662,18 +669,24 @@ labelPair edgeIntersectionsCGAL
);
// Intersection on edge interior
classifications[edgeI].append(-1);
nPoints++;
++nPoints;
}
else if
(
const Segment* sPtr = boost::get<Segment>(&((*iter)->first))
const Segment* sPtr = boost::get<Segment>(&(intersect->first))
)
{
#if defined (CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1041400000)
Polyhedron::Face_handle f = (intersect->second);
#else
// 4.14 and later
Polyhedron::Face_handle f = (intersect->second).first;
#endif
//std::cout
// << "intersection object is a segment:" << sPtr->source()
// << " " << sPtr->target() << std::endl;
Polyhedron::Face_handle f = (*iter)->second;
//std::cout<< "triangle:" << f->index
// << " region:" << f->region << std::endl;
@ -703,7 +716,7 @@ labelPair edgeIntersectionsCGAL
);
// Intersection aligned with face. Tbd: enums
classifications[edgeI].append(2);
nSegments++;
++nSegments;
}
}
}
@ -1242,7 +1255,7 @@ autoPtr<extendedFeatureEdgeMesh> createEdgeMesh
label nFeatEds = inter.cutEdges().size();
DynamicList<vector> normals(2*nFeatEds);
vectorField edgeDirections(nFeatEds, vector::zero);
vectorField edgeDirections(nFeatEds, Zero);
DynamicList<extendedFeatureEdgeMesh::sideVolumeType> normalVolumeTypes
(
2*nFeatEds

View File

@ -3,15 +3,17 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
#-------------------------------------------------------------------------------
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# foamEtcFile
# bin/foamEtcFile
#
# Description
# Locate user/group/other file as per '#includeEtc'.
@ -30,7 +32,13 @@
# \endcode
#
# Environment
# - WM_PROJECT_SITE (unset defaults to PROJECT/site)
# FOAM_CONFIG_ETC
# Alternative etc directory for shipped files
#
# FOAM_CONFIG_MODE
# Fallback search mode for etc files. Unset is the same as "ugo".
#
# WM_PROJECT_SITE (unset defaults to PROJECT/site)
#
# Note
# This script must exist in the project 'bin' directory
@ -43,8 +51,8 @@
printHelp() {
cat<<USAGE
Usage: foamEtcFile [OPTION] fileName [-- args]
foamEtcFile [OPTION] [-list|-list-test] [fileName]
Usage: ${0##*/} [OPTION] fileName [-- args]
${0##*/} [OPTION] [-list|-list-test] [fileName]
options:
-all (-a) Return all files (otherwise stop after the first match)
@ -58,8 +66,8 @@ options:
-config Add config directory prefix for shell type:
with -csh* for a config.csh/ prefix
with -sh* for a config.sh/ prefix
-show-api Print api value from wmake/rules, or meta-info and exit
-show-patch Print patch value from meta-info and exit
-show-api Print META-INFO api value and exit
-show-patch Print META-INFO patch value and exit
-with-api=NUM Specify alternative api value to search with
-quiet (-q) Suppress all normal output
-silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output
@ -103,64 +111,40 @@ projectDir="$(\cd $(dirname $binDir) && \pwd -L)" # Project dir
userDir="$HOME/.OpenFOAM" # As per foamVersion.H
groupDir="${WM_PROJECT_SITE:-$projectDir/site}" # As per foamVersion.H
optMode=ugo # Default search = 'ugo'
# Environment overrides
case "$FOAM_CONFIG_MODE" in ([ugo]*) optMode="$FOAM_CONFIG_MODE" ;; esac
# Verify validity of FOAM_CONFIG_ETC
if [ -n "$FOAM_CONFIG_ETC" ]
then
if [ ! -d "$FOAM_CONFIG_ETC" ] || [ "$FOAM_CONFIG_ETC" = "$projectDir/etc" ]
then
# Bad directory or redundant value
unset FOAM_CONFIG_ETC
fi
fi
#-------------------------------------------------------------------------------
# The API locations. See wmake/wmakeBuildInfo
rulesFile="$projectDir/wmake/rules/General/general"
metaInfoDir="$projectDir/META-INFO"
# Get api from rules/General/general
#
# Failure modes:
# - No api information (can't find file etc).
# -> Fatal for building, but could be OK for a stripped down version
#
# Fallback. Get from api-info
#
getApi()
# Get a value from META-INFO/api-info
# $1 : keyword
getApiInfo()
{
local value
value="$(sed -ne '/^ *#/!{ /WM_VERSION.*OPENFOAM=/{ s@^.*OPENFOAM= *\([0-9][0-9]*\).*@\1@p; q }}' $rulesFile 2>/dev/null)"
if [ -z "$value" ] && [ -f "$metaInfoDir/api-info" ]
then
# Fallback. Get from api-info
value="$(sed -ne 's@^ *api *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
fi
if [ -n "$value" ]
then
echo "$value"
else
return 1
fi
}
# Get patch from meta-info / api-info
#
# Failure modes:
# - No patch information (can't find file etc).
#
getPatchLevel()
{
local value
# Fallback. Get from api-info
value="$(sed -ne 's@^ *patch *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
value="$(sed -ne 's@^'"$1"' *= *\([0-9][0-9]*\).*@\1@p' "$projectDir"/META-INFO/api-info 2>/dev/null)"
if [ -n "$value" ]
then
echo "$value"
else
echo "Could not determine OPENFOAM '$1' value" 1>&2
return 1
fi
}
#-------------------------------------------------------------------------------
optMode=ugo # Default mode is always 'ugo'
unset shellOutput verboseOutput
unset optAll optConfig optList projectApi
@ -171,14 +155,12 @@ do
-h | -help*)
printHelp
;;
-show-api)
# Show API and exit
getApi
-show-api) # Show API and exit
getApiInfo api
exit $?
;;
-show-patch)
# Show patch level and exit
getPatchLevel
-show-patch) # Show patch level and exit
getApiInfo patch
exit $?
;;
-with-api=*)
@ -205,7 +187,7 @@ do
-config)
optConfig=true
;;
-mode=[ugoa]*)
-mode=[ugo]*)
optMode="${1#*=}"
;;
-m | -mode)
@ -213,7 +195,7 @@ do
shift
# Sanity check. Handles missing argument too.
case "$optMode" in
([ugoa]*)
([ugo]*)
;;
(*)
die "invalid mode '$optMode'"
@ -254,8 +236,7 @@ done
#-------------------------------------------------------------------------------
# Establish the API value
[ -n "$projectApi" ] || projectApi=$(getApi)
[ -n "$projectApi" ] || projectApi=$(getApiInfo api)
# Split arguments into filename (for searching) and trailing bits for shell eval
# Silently remove leading ~OpenFOAM/ (as per Foam::findEtcFile)
@ -290,23 +271,23 @@ fi
# Define the various places to be searched:
unset dirList
case "$optMode" in (*[au]*) # (A)ll or (U)ser
case "$optMode" in (*[u]*) # (U)ser
dirList="$dirList $userDir/$projectApi $userDir"
;;
esac
case "$optMode" in (*[ag]*) # (A)ll or (G)roup == site
case "$optMode" in (*[g]*) # (G)roup == site
dirList="$dirList $groupDir/$projectApi/etc $groupDir/etc"
;;
esac
case "$optMode" in (*[ao]*) # (A)ll or (O)ther == shipped
dirList="$dirList $projectDir/etc"
case "$optMode" in (*[o]*) # (O)ther == shipped
dirList="$dirList $FOAM_CONFIG_ETC $projectDir/etc"
;;
esac
set -- $dirList
[ "$#" -ge 1 ] || die "No directories to scan. Programming error?"
[ "$#" -ge 1 ] || die "No directories to scan. Programming or user error?"
exitCode=2 # Fallback is a FileNotFound error
@ -315,7 +296,7 @@ exitCode=2 # Fallback is a FileNotFound error
#
# Special handling of config.sh/ , config.csh/ directories
if [ -n "$optConfig" -a -n "$shellOutput" -a -n "$fileName" ]
if [ -n "$optConfig" ] && [ -n "$shellOutput" ] && [ -n "$fileName" ]
then
case "$shellOutput" in
csh*)

272
bin/tools/create-mpi-config Executable file
View File

@ -0,0 +1,272 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# bin/tools/create-mpi-config
#
# Description
# Define hard-coded packaging settings for MPI flavours,
# primarily for system openmpi.
# This eliminates a runtime dependency on mpicc, for example.
#
# Instead of querying/parsing 'mpicc --showme:link' each time,
# it is done once during packaging.
#
# Environment
# FOAM_MPI, MPI_ARCH_PATH, DEB_TARGET_MULTIARCH
#
# Possible Dependencies
# - dpkg-architecture
# - mpicc
#
# Notes
# Run from top-level directory when creating config files
#
#------------------------------------------------------------------------------
printHelp() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} options
options:
-dry-run Report but do not write config files
-no-mpicc Bypass any use of mpicc
-query-openmpi Report installation directory for system openmpi
-write-openmpi Query system openmpi and write config files
-write Write config files using FOAM_MPI, MPI_ARCH_PATH
Define hard-coded packaging settings for MPI flavours.
Equivalent options:
-write-system-openmpi | -write-openmpi
-query-system-openmpi | -query-openmpi
USAGE
exit 0 # A clean exit
}
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '${0##*/} -help' for usage"
echo
exit 1
}
#------------------------------------------------------------------------------
# Options
unset optDryRun
useMpicc=true
# Get installation directory for system openmpi
# - from "mpicc --showme:link"
# - manual fallback
#
# The mpicc content looks like this:
# ----
# -pthread -L/usr/lib64/mpi/gcc/openmpi/lib64 -lmpi
# ----
query_system_openmpi()
{
unset arch_path
if [ "$useMpicc" = true ]
then
arch_path=$(mpicc --showme:link 2>/dev/null | sed -e 's#^.*-L\([^ ]*\).*#\1#')
arch_path="${arch_path%/*}"
if [ -n "$arch_path" ]
then
echo "$arch_path"
return 0 # Clean exit
fi
echo "No mpicc found. Attempt manually" 1>&2
fi
# Manual discovery
if [ -z "$DEB_TARGET_MULTIARCH" ]
then
DEB_TARGET_MULTIARCH=$(dpkg-architecture -qDEB_TARGET_MULTIARCH 2>/dev/null || true)
fi
# Include is under /usr/lib... (eg, debian, openSUSE)
for testdir in \
/usr/lib/"${DEB_TARGET_MULTIARCH:+${DEB_TARGET_MULTIARCH}/}"openmpi/include \
/usr/lib64/mpi/gcc/openmpi/include \
;
do
if [ -e "$testdir/mpi.h" ]
then
echo "${testdir%/*}"
return 0 # Clean exit
fi
done
# Include is under /usr/include (eg, RedHat)
for testdir in \
/usr/include/openmpi-"$(uname -m)" \
/usr/include/openmpi \
;
do
if [ -e "$testdir/mpi.h" ]
then
echo "/usr"
return 0 # Clean exit
fi
done
# Failed (should not happen)
# - report '/usr', but with error code 2
echo "/usr"
return 2
}
# Generate etc/config.{csh,sh}/MPI-TYPE files
# based on the values for FOAM_MPI and MPI_ARCH_PATH
create_files()
{
[ -n "$FOAM_MPI" ] || die "FOAM_MPI not set"
if [ -d "$MPI_ARCH_PATH" ]
then
echo "Define $FOAM_MPI with $MPI_ARCH_PATH" 1>&2
case "$FOAM_MPI" in
(openmpi-system)
configDir="etc/config.sh"
if [ "$optDryRun" = true ]
then
cat << CONTENT 1>&2
dry-run: $configDir/$FOAM_MPI
#
# Packaging configured value for $FOAM_MPI
export MPI_ARCH_PATH="$MPI_ARCH_PATH"
CONTENT
elif [ -d "$configDir" ]
then
echo "Write $configDir/$FOAM_MPI" 1>&2
cat << CONTENT > "$configDir/$FOAM_MPI"
# $configDir/$FOAM_MPI
#
# Packaging configured value for $FOAM_MPI
export MPI_ARCH_PATH="$MPI_ARCH_PATH"
#----
CONTENT
else
echo "Cannot write $configDir/$FOAM_MPI - no directory" 1>&2
fi
configDir="etc/config.csh"
if [ "$optDryRun" = true ]
then
cat << CONTENT 1>&2
dry-run: $configDir/$FOAM_MPI
#
# Packaging configured value for $FOAM_MPI
setenv MPI_ARCH_PATH "$MPI_ARCH_PATH"
CONTENT
elif [ -d "$configDir" ]
then
echo "Write $configDir/$FOAM_MPI" 1>&2
cat << CONTENT > "$configDir/$FOAM_MPI"
# $configDir/$FOAM_MPI
#
# Packaging configured value for $FOAM_MPI
setenv MPI_ARCH_PATH "$MPI_ARCH_PATH"
#----
CONTENT
else
echo "Cannot write $configDir/$FOAM_MPI - no directory" 1>&2
fi
;;
esac
else
echo "Warning: $FOAM_MPI with bad MPI_ARCH_PATH: $MPI_ARCH_PATH" 1>&2
# TBD - remove old/bad entries?
#
# for file in "etc/config.sh/$FOAM_MPI" "etc/config.csh/$FOAM_MPI"
# do
# [ -f "$file" ] && rm -f "$file"
# done
fi
}
#------------------------------------------------------------------------------
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help* | --help*)
printHelp
;;
'')
# Discard empty arguments
;;
-dry-run)
optDryRun=true
;;
-no-mpicc)
unset useMpicc
;;
-query-openmpi | -query-system-openmpi)
query_system_openmpi
exit $?
;;
-write-openmpi | -write-system-openmpi)
if MPI_ARCH_PATH=$(query_system_openmpi)
then
FOAM_MPI="openmpi-system"
create_files
else
die "Failed query for system openmpi"
fi
;;
-write)
create_files
;;
*)
echo "Ignore unknown option/argument: '$1'" 1>&2
;;
esac
shift
done
exit 0 # A clean exit, if we get this far
# -----------------------------------------------------------------------------

View File

@ -16,69 +16,28 @@
# foamConfigurePaths
#
# Description
# Adjust hardcoded installation versions and paths in bashrc and config.sh/
# Adjust hardcoded installation versions and paths
# in etc/{bashrc,cshrc} and etc/config.{sh,csh}/
#
# Requires
# - sed
# - bin/foamEtcFile
#
# Environment
# FOAM_CONFIG_ETC
# Alternative etc directory for shipped files
#
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
printHelp() {
usage: ${0##*/} options
Basic
-project-path DIR specify 'WM_PROJECT_DIR' (eg, /opt/openfoam1806-patch1)
-version VER specify project version (eg, v1806)
-archOption 32|64 specify 'WM_ARCH_OPTION' architecture option
-SP | -float32 specify 'WM_PRECISION_OPTION' for single precision
-DP | -float64 specify 'WM_PRECISION_OPTION' for double precision
-int32 | -int64 specify 'WM_LABEL_SIZE'
Compiler
-system NAME specify 'system' compiler to use (eg, Gcc, Icc,...)
-third NAME specify 'ThirdParty' compiler to use (eg, Clang40,...)
-gcc VER specify 'default_gcc_version' for ThirdParty Gcc
-clang VER specify 'default_clang_version' for ThirdParty Clang
gmp-VERSION for ThirdParty gcc (gmp-system for system library)
mpfr-VERSION for ThirdParty gcc (mpfr-system for system library)
mpc-VERSION for ThirdParty gcc (mpc-system for system library)
MPI
-mpi NAME specify 'WM_MPLIB' type (eg, INTELMPI, etc)
-openmpi VER use ThirdParty openmpi, with version for 'FOAM_MPI'
-openmpi-system use system openmpi
-openmpi-third use ThirdParty openmpi (using default version)
Components
-boost VER specify 'boost_version'
-boost-path DIR specify 'BOOST_ARCH_PATH'
-cgal ver specify 'cgal_version'
-cgal-path DIR specify 'CGAL_ARCH_PATH'
-cmake VER specify 'cmake_version'
-fftw VER specify 'fffw_version'
-fftw-path DIR specify 'FFTW_ARCH_PATH'
-kahip VER specify 'KAHIP_VERSION'
-kahip-path DIR specify 'KAHIP_ARCH_PATH'
-metis ver specify 'METIS_VERSION'
-metis-path DIR specify 'METIS_ARCH_PATH'
-scotch VER specify 'SCOTCH_VERSION' (eg, scotch_6.0.4)
-scotch-path DIR specify 'SCOTCH_ARCH_PATH' (eg, /opt/scotch_6.0.4)
Graphics
-paraview VER specify 'ParaView_VERSION' (eg, 5.4.1 or system)
-paraview-qt VER specify 'ParaView_QT' (eg, qt-system)
-paraview-path DIR specify 'ParaView_DIR' (eg, /opt/ParaView-5.4.1)
-vtk VER specify 'vtk_version' (eg, VTK-7.1.0)
-mesa VER specify 'mesa_version' (eg, mesa-13.0.1)
Misc
case "$1" in
(*compat*)
cat<<HELP_COMPAT
Obsolete options:
-foamInstall DIR [obsolete]
-projectName NAME [obsolete]
-sigfpe|-no-sigfpe [obsolete - now under etc/controlDict]
Adjusts hardcoded versions and installation paths (for bash, POSIX shell).
-archOption 32|64 [obsolete setting of 'WM_ARCH_OPTION' - edit manually]
Equivalent options:
-version -foamVersion --projectVersion
@ -88,11 +47,96 @@ Equivalent options:
-paraview-path --paraviewInstall | -paraviewInstall
-scotch --scotchVersion | -scotchVersion
-scotch-path --scotchArchPath | -scotchArchPath
-system-compiler -system
-third-compiler -third
USAGE
exit 1
HELP_COMPAT
exit 0 # A clean exit
;;
esac
cat<<HELP_HEAD
usage: $0 options
Options
-h | -help Display short help and exit
-help-compat Display compatibility options and exit
-help-full Display full help and exit
Basic
-etc=DIR set FOAM_CONFIG_ETC for alternative project files
-project-path DIR specify 'WM_PROJECT_DIR' (eg, /opt/openfoam1806-patch1)
-version VER specify project version (eg, v1806)
-sp | -SP | -float32 single precision (WM_PRECISION_OPTION)
-dp | -DP | -float64 double precision (WM_PRECISION_OPTION)
-spdp | -SPDP mixed precision (WM_PRECISION_OPTION)
-int32 | -int64 label-size (WM_LABEL_SIZE)
Compiler
-system-compiler NAME The 'system' compiler to use (eg, Gcc, Clang, Icc,...)
-third-compiler NAME The 'ThirdParty' compiler to use (eg, Clang40,...)
-gcc VER The 'default_gcc_version' for ThirdParty Gcc
-clang VER The 'default_clang_version' for ThirdParty Clang
gmp-VERSION For ThirdParty gcc (gmp-system for system library)
mpfr-VERSION For ThirdParty gcc (mpfr-system for system library)
mpc-VERSION For ThirdParty gcc (mpc-system for system library)
MPI
-mpi NAME specify 'WM_MPLIB' type (eg, INTELMPI, etc)
-openmpi VER use ThirdParty openmpi, with version for 'FOAM_MPI'
-openmpi-system use system openmpi
-openmpi-third use ThirdParty openmpi (using default version)
Components versions (ThirdParty)
-adios VER specify 'adios2_version'
-boost VER specify 'boost_version'
-cgal VER specify 'cgal_version'
-cmake VER specify 'cmake_version'
-fftw VER specify 'fffw_version'
-kahip VER specify 'KAHIP_VERSION'
-metis VER specify 'METIS_VERSION'
-scotch VER specify 'SCOTCH_VERSION' (eg, scotch_6.0.4)
HELP_HEAD
case "$1" in
(*full*)
cat<<HELP_FULL
Components specified by absolute path
-adios-path DIR Path for 'ADIOS2_ARCH_PATH' (overrides -adios)
-boost-path DIR Path for 'BOOST_ARCH_PATH' (overrides -boost)
-cgal-path DIR Path for 'CGAL_ARCH_PATH' (overrides -cgal)
-fftw-path DIR Path for 'FFTW_ARCH_PATH' (overrides -fftw)
-kahip-path DIR Path for 'KAHIP_ARCH_PATH' (overrides -kahip)
-metis-path DIR Path for 'METIS_ARCH_PATH' (overrides -metis)
-scotch-path DIR Path for 'SCOTCH_ARCH_PATH' (overrides -scotch)
Graphics
-paraview VER specify 'ParaView_VERSION' (eg, 5.4.1 or system)
-paraview-qt VER specify 'ParaView_QT' (eg, qt-system)
-paraview-path DIR specify 'ParaView_DIR' (eg, /opt/ParaView-5.4.1)
-llvm VER specify 'mesa_llvm'
-mesa VER specify 'mesa_version' (eg, mesa-13.0.1)
-vtk VER specify 'vtk_version' (eg, VTK-7.1.0)
-llvm-path DIR Path for 'LLVM_ARCH_PATH' (overrides -llvm)
-mesa-path DIR Path for 'MESA_ARCH_PATH' (overrides -mesa)
-vtk-path DIR Path for 'VTK_DIR' (overrides -vtk)
HELP_FULL
;;
esac
cat<<HELP_TAIL_COMMON
Adjusts hardcoded versions and installation paths (POSIX and C-shell)
for OpenFOAM.
HELP_TAIL_COMMON
exit 0 # A clean exit
}
# Report error and exit
die()
{
@ -101,16 +145,32 @@ die()
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '${0##*/} -help' for usage"
echo "See '$0 -help' for usage"
echo
exit 1
}
# -----------------------------------------------------------------------------
projectDir="$(\pwd -L)" # Project dir
# Check that it appears to be an OpenFOAM installation
[ -f etc/bashrc -a -d etc/config.sh ] || \
usage "Please run from top-level directory of installation"
if [ -f etc/bashrc ] && [ -d "META-INFO" ]
then
echo "Configuring OpenFOAM ($projectDir)" 1>&2
else
die "Please run from the OpenFOAM top-level installation directory" \
"No etc/bashrc or META-INFO/ found"
fi
# Use foamEtcFile to locate files, but only edit shipped files
if [ -x bin/foamEtcFile ]
then
_foamEtc() {
./bin/foamEtcFile -mode=o "$@"
}
else
die "No bin/foamEtcFile found in installation"
fi
# Check if argument matches the expected input. Respects case.
@ -141,18 +201,22 @@ _inlineSed()
local replacement="$3"
local msg="$4"
local cmd='/^[^#]/s@'"$regexp"'@'"$replacement"'@'
local localFile
[ -f "$file" ] || {
echo "Missing file: $file"
exit 2 # Fatal
}
# Local filename (for reporting)
localFile="$(echo "$file" | sed -e "s#^$projectDir/##")"
grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file" || { \
echo "Failed: ${msg:-replacement} in $file"
echo "Failed: ${msg:-replacement} in $localFile"
return 1
}
[ -n "$msg" ] && echo " $msg ($file)"
[ -n "$msg" ] && echo " $msg ($localFile)"
return 0
}
@ -178,7 +242,7 @@ replace()
"$file" \
"$key=.*" \
"$key=$val" \
"Replaced $key setting by '$val'"
"Replaced $key by '$val'"
done
}
@ -201,14 +265,35 @@ replaceCsh()
_inlineSed \
"$file" \
"setenv *$key [^ #]*" \
"setenv [ ]*$key [^ #]*" \
"setenv $key $val" \
"Replaced $key setenv by '$val'"
"Replaced $key by '$val'"
done
}
# Get the option's value (argument).
# Die if the argument doesn't exist or is empty
# Locate file with foamEtcFile -mode=o and forward to replace()
replaceEtc()
{
local file="$1"
shift
file=$(_foamEtc "$file")
replace $file "$@"
}
# Locate file with foamEtcFile -mode=o and forward to replaceCsh()
replaceEtcCsh()
{
local file="$1"
shift
file=$(_foamEtc "$file")
replaceCsh $file "$@"
}
# Get the option's value (argument), or die on missing or empty argument
# $1 option
# $2 value
getOptionValue()
@ -271,23 +356,62 @@ unset adjusted optMpi
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help* | --help*)
usage
-help-c*) # Compat help
printHelp -compat
;;
-help-f*) # Full help
printHelp -full
;;
-h | -help*) # Short help
printHelp
;;
'')
# Discard empty arguments
;;
-debug-list)
# Undocumented (experimental)
# TDB: List files that can be edited by this script
cat << CONFIG_SH
etc/bashrc
etc/config.sh/adios2
etc/config.sh/compiler
etc/config.sh/paraview
etc/config.sh/vtk
etc/config.sh/CGAL
etc/config.sh/FFTW
etc/config.sh/metis
etc/config.sh/kahip
etc/config.sh/scotch
CONFIG_SH
cat << CONFIG_CSH
etc/cshrc
etc/config.csh/adios2
etc/config.csh/compiler
etc/config.csh/paraview
etc/config.csh/vtk
etc/config.csh/CGAL
etc/config.csh/FFTW
CONFIG_CSH
exit 0
;;
## Basic ##
-etc=*)
# Define FOAM_CONFIG_ETC for finding files
export FOAM_CONFIG_ETC="${1#*=}"
;;
-project-path)
# Replace WM_PROJECT_DIR=...
optionValue=$(getOptionValue "$@")
replace etc/bashrc WM_PROJECT_DIR "\"$optionValue\""
replaceCsh etc/cshrc WM_PROJECT_DIR "\"$optionValue\""
replaceEtc bashrc WM_PROJECT_DIR "\"$optionValue\""
replaceEtcCsh cshrc WM_PROJECT_DIR "\"$optionValue\""
removeBashMagic etc/bashrc
removeCshMagic etc/cshrc
removeBashMagic $(_foamEtc bashrc)
removeCshMagic $(_foamEtc cshrc)
adjusted=true
shift
@ -296,8 +420,8 @@ do
-version | -foamVersion | --projectVersion)
# Replace WM_PROJECT_VERSION=...
optionValue=$(getOptionValue "$@")
replace etc/bashrc WM_PROJECT_VERSION "$optionValue"
replaceCsh etc/cshrc WM_PROJECT_VERSION "$optionValue"
replaceEtc bashrc WM_PROJECT_VERSION "$optionValue"
replaceEtcCsh cshrc WM_PROJECT_VERSION "$optionValue"
adjusted=true
shift
;;
@ -305,40 +429,36 @@ do
-archOption | --archOption)
# Replace WM_ARCH_OPTION=...
optionValue=$(getOptionValue "$@")
_matches "$optionValue" 32 64 || \
die "'$1' has bad value: '$optionValue'"
if [ "$optionValue" = "$(sed -ne '/^[^#]/s/^.* WM_ARCH_OPTION=//p' etc/bashrc)" ]
then
echo "WM_ARCH_OPTION already set to $optionValue"
: ${adjusted:=false}
else
replace etc/bashrc WM_ARCH_OPTION "$optionValue"
replaceCsh etc/cshrc WM_ARCH_OPTION "$optionValue"
adjusted=true
fi
echo "Ignoring $1 option: no longer supported" 1>&2
shift
;;
-SP | -float32)
-sp | -SP | -float32)
# Replace WM_PRECISION_OPTION=...
replace etc/bashrc WM_PRECISION_OPTION "SP"
replaceCsh etc/cshrc WM_PRECISION_OPTION "SP"
replaceEtc bashrc WM_PRECISION_OPTION "SP"
replaceEtcCsh cshrc WM_PRECISION_OPTION "SP"
adjusted=true
;;
-DP | -float64)
-dp | -DP | -float64)
# Replace WM_PRECISION_OPTION=...
replace etc/bashrc WM_PRECISION_OPTION "DP"
replaceCsh etc/cshrc WM_PRECISION_OPTION "DP"
replaceEtc bashrc WM_PRECISION_OPTION "DP"
replaceEtcCsh cshrc WM_PRECISION_OPTION "DP"
adjusted=true
;;
-spdp | -SPDP)
# Replace WM_PRECISION_OPTION=...
replaceEtc bashrc WM_PRECISION_OPTION "SPDP"
replaceEtcCsh cshrc WM_PRECISION_OPTION "SPDP"
adjusted=true
;;
-int32 | -int64)
# Replace WM_LABEL_SIZE=...
optionValue="${1#-int}"
replace etc/bashrc WM_LABEL_SIZE "$optionValue"
replaceCsh etc/cshrc WM_LABEL_SIZE "$optionValue"
replaceEtc bashrc WM_LABEL_SIZE "$optionValue"
replaceEtcCsh cshrc WM_LABEL_SIZE "$optionValue"
adjusted=true
;;
@ -348,8 +468,8 @@ do
-clang)
# Replace default_clang_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/compiler default_clang_version "$optionValue"
replace etc/config.csh/compiler default_clang_version "$optionValue"
replaceEtc config.sh/compiler default_clang_version "$optionValue"
replaceEtc config.csh/compiler default_clang_version "$optionValue"
adjusted=true
shift
;;
@ -357,32 +477,32 @@ do
-gcc)
# Replace default_gcc_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/compiler default_gcc_version "$optionValue"
replace etc/config.csh/compiler default_gcc_version "$optionValue"
replaceEtc config.sh/compiler default_gcc_version "$optionValue"
replaceEtc config.csh/compiler default_gcc_version "$optionValue"
adjusted=true
shift
;;
-system)
-system-compiler | -system)
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
optionValue=$(getOptionValue "$@")
replace etc/bashrc \
replaceEtc bashrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optionValue"
replaceCsh etc/cshrc \
replaceEtcCsh cshrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optionValue"
adjusted=true
shift
;;
-third | -ThirdParty)
-third-compiler | -third | -ThirdParty)
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
optionValue=$(getOptionValue "$@")
replace etc/bashrc \
replaceEtc bashrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optionValue"
replaceCsh etc/cshrc \
replaceEtcCsh cshrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optionValue"
adjusted=true
@ -391,22 +511,22 @@ do
gmp-[4-9]* | gmp-system)
# gcc-related package
replace etc/config.sh/compiler default_gmp_version "$1"
replace etc/config.csh/compiler default_gmp_version "$1"
replaceEtc config.sh/compiler default_gmp_version "$1"
replaceEtc config.csh/compiler default_gmp_version "$1"
adjusted=true
;;
mpfr-[2-9]* | mpfr-system)
# gcc-related package
replace etc/config.sh/compiler default_mpfr_version "$1"
replace etc/config.csh/compiler default_mpfr_version "$1"
replaceEtc config.sh/compiler default_mpfr_version "$1"
replaceEtc config.csh/compiler default_mpfr_version "$1"
adjusted=true
;;
mpc-[0-9]* | mpc-system)
# gcc-related package
replace etc/config.sh/compiler default_mpc_version "$1"
replace etc/config.csh/compiler default_mpc_version "$1"
replaceEtc config.sh/compiler default_mpc_version "$1"
replaceEtc config.csh/compiler default_mpc_version "$1"
adjusted=true
;;
@ -416,8 +536,8 @@ do
-mpi)
# Explicitly set WM_MPLIB=...
optionValue=$(getOptionValue "$@")
replace etc/bashrc WM_MPLIB "$optionValue"
replaceCsh etc/bashrc WM_MPLIB "$optionValue"
replaceEtc bashrc WM_MPLIB "$optionValue"
replaceEtcCsh cshrc WM_MPLIB "$optionValue"
optMpi=system
adjusted=true
shift
@ -432,34 +552,34 @@ do
_matches "$optMpi" "$expected" || \
die "'$1' has bad value: '$optMpi'"
_inlineSed etc/config.sh/mpi \
_inlineSed $(_foamEtc config.sh/mpi) \
"FOAM_MPI=$expected" \
"FOAM_MPI=$optMpi" \
"Replaced 'FOAM_MPI=$expected' setting by 'FOAM_MPI=$optMpi'"
"Replaced 'FOAM_MPI=$expected' by 'FOAM_MPI=$optMpi'"
_inlineSed etc/config.csh/mpi \
_inlineSed $(_foamEtc config.csh/mpi) \
"FOAM_MPI $expected" \
"FOAM_MPI $optMpi" \
"Replaced 'FOAM_MPI $expected' setting by 'FOAM_MPI $optMpi'"
"Replaced 'FOAM_MPI $expected' by 'FOAM_MPI $optMpi'"
replace etc/bashrc WM_MPLIB OPENMPI
replaceCsh etc/cshrc WM_MPLIB OPENMPI
replaceEtc bashrc WM_MPLIB OPENMPI
replaceEtcCsh cshrc WM_MPLIB OPENMPI
adjusted=true
shift
;;
-openmpi-system)
# Explicitly set WM_MPLIB=SYSTEMOPENMPI
replace etc/bashrc WM_MPLIB SYSTEMOPENMPI
replaceCsh etc/cshrc WM_MPLIB SYSTEMOPENMPI
replaceEtc bashrc WM_MPLIB SYSTEMOPENMPI
replaceEtcCsh cshrc WM_MPLIB SYSTEMOPENMPI
optMpi=system
adjusted=true
;;
-openmpi-third)
# Explicitly set WM_MPLIB=OPENMPI, using default setting for openmpi
replace etc/bashrc WM_MPLIB OPENMPI
replaceCsh etc/cshrc WM_MPLIB OPENMPI
replaceEtc bashrc WM_MPLIB OPENMPI
replaceEtcCsh cshrc WM_MPLIB OPENMPI
optMpi=third
adjusted=true
;;
@ -467,11 +587,29 @@ do
## Components ##
-adios | -adios2)
# Replace adios2_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/adios2 adios2_version "$optionValue"
replaceEtc config.csh/adios2 adios2_version "$optionValue"
adjusted=true
shift
;;
-adios-path | -adios2-path)
# Replace ADIOS2_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
replaceEtcCsh config.csh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
-boost)
# Replace boost_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/CGAL boost_version "$optionValue"
replace etc/config.csh/CGAL boost_version "$optionValue"
replaceEtc config.sh/CGAL boost_version "$optionValue"
replaceEtc config.csh/CGAL boost_version "$optionValue"
adjusted=true
shift
;;
@ -479,8 +617,8 @@ do
-boost-path)
# Replace BOOST_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/CGAL BOOST_ARCH_PATH "\"$optionValue\""
replaceCsh etc/config.csh/CGAL BOOST_ARCH_PATH "\"$optionValue\""
replaceEtc config.sh/CGAL BOOST_ARCH_PATH "\"$optionValue\""
replaceEtcCsh config.csh/CGAL BOOST_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
@ -488,8 +626,8 @@ do
-cgal)
# Replace cgal_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/CGAL cgal_version "$optionValue"
replace etc/config.csh/CGAL cgal_version "$optionValue"
replaceEtc config.sh/CGAL cgal_version "$optionValue"
replaceEtc config.csh/CGAL cgal_version "$optionValue"
adjusted=true
shift
;;
@ -497,8 +635,8 @@ do
-cgal-path)
# Replace CGAL_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/CGAL CGAL_ARCH_PATH "$optionValue"
replaceCsh etc/config.csh/CGAL CGAL_ARCH_PATH "$optionValue"
replaceEtc config.sh/CGAL CGAL_ARCH_PATH "$optionValue"
replaceEtcCsh config.csh/CGAL CGAL_ARCH_PATH "$optionValue"
adjusted=true
shift
;;
@ -506,8 +644,8 @@ do
-fftw)
# Replace fftw_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/FFTW fftw_version "$optionValue"
replace etc/config.csh/FFTW fftw_version "$optionValue"
replaceEtc config.sh/FFTW fftw_version "$optionValue"
replaceEtc config.csh/FFTW fftw_version "$optionValue"
adjusted=true
shift
;;
@ -515,8 +653,8 @@ do
-fftw-path)
# Replace FFTW_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/FFTW FFTW_ARCH_PATH "\"$optionValue\""
replaceCsh etc/config.csh/FFTW FFTW_ARCH_PATH "\"$optionValue\""
replaceEtc config.sh/FFTW FFTW_ARCH_PATH "\"$optionValue\""
replaceEtcCsh config.csh/FFTW FFTW_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
@ -524,8 +662,8 @@ do
-cmake)
# Replace cmake_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/paraview cmake_version "$optionValue"
replace etc/config.csh/paraview cmake_version "$optionValue"
replaceEtc config.sh/paraview cmake_version "$optionValue"
replaceEtc config.csh/paraview cmake_version "$optionValue"
adjusted=true
shift
;;
@ -533,7 +671,7 @@ do
-kahip)
# Replace KAHIP_VERSION=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/kahip KAHIP_VERSION "$optionValue"
replaceEtc config.sh/kahip KAHIP_VERSION "$optionValue"
adjusted=true
shift
;;
@ -541,7 +679,7 @@ do
-kahip-path)
# Replace KAHIP_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/kahip KAHIP_ARCH_PATH "\"$optionValue\""
replaceEtc config.sh/kahip KAHIP_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
@ -549,7 +687,7 @@ do
-metis)
# Replace METIS_VERSION=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/metis METIS_VERSION "$optionValue"
replaceEtc config.sh/metis METIS_VERSION "$optionValue"
adjusted=true
shift
;;
@ -557,7 +695,7 @@ do
-metis-path)
# Replace METIS_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/metis METIS_ARCH_PATH "\"$optionValue\""
replaceEtc config.sh/metis METIS_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
@ -565,7 +703,7 @@ do
-scotch | -scotchVersion | --scotchVersion)
# Replace SCOTCH_VERSION=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/scotch SCOTCH_VERSION "$optionValue"
replaceEtc config.sh/scotch SCOTCH_VERSION "$optionValue"
adjusted=true
shift
;;
@ -573,7 +711,7 @@ do
-scotch-path | -scotchArchPath | --scotchArchPath)
# Replace SCOTCH_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/scotch SCOTCH_ARCH_PATH "\"$optionValue\""
replaceEtc config.sh/scotch SCOTCH_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
@ -588,8 +726,8 @@ do
_matches "$optionValue" "$expected" || \
[ "$optionValue" != "${optionValue%system}" ] || \
die "'$1' has bad value: '$optionValue'"
replace etc/config.sh/paraview ParaView_VERSION "$optionValue"
replace etc/config.csh/paraview ParaView_VERSION "$optionValue"
replaceEtc config.sh/paraview ParaView_VERSION "$optionValue"
replaceEtc config.csh/paraview ParaView_VERSION "$optionValue"
adjusted=true
shift
;;
@ -597,8 +735,8 @@ do
-paraview-qt)
# Replace ParaView_QT=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/paraview ParaView_QT "$optionValue"
replace etc/config.csh/paraview ParaView_QT "$optionValue"
replaceEtc config.sh/paraview ParaView_QT "$optionValue"
replaceEtc config.csh/paraview ParaView_QT "$optionValue"
adjusted=true
shift
;;
@ -606,17 +744,17 @@ do
-paraview-path | -paraviewInstall | --paraviewInstall)
# Replace ParaView_DIR=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/paraview ParaView_DIR \""$optionValue\""
replaceCsh etc/config.csh/paraview ParaView_DIR \""$optionValue\""
replaceEtc config.sh/paraview ParaView_DIR \""$optionValue\""
replaceEtcCsh config.csh/paraview ParaView_DIR \""$optionValue\""
adjusted=true
shift
;;
-vtk)
# Replace vtk_version=...
-llvm)
# Replace mesa_llvm=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/vtk vtk_version "$optionValue"
replace etc/config.csh/vtk vtk_version "$optionValue"
replaceEtc config.sh/vtk mesa_llvm "$optionValue"
replaceEtc config.csh/vtk mesa_llvm "$optionValue"
adjusted=true
shift
;;
@ -624,8 +762,44 @@ do
-mesa)
# Replace mesa_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/vtk mesa_version "$optionValue"
replace etc/config.csh/vtk mesa_version "$optionValue"
replaceEtc config.sh/vtk mesa_version "$optionValue"
replaceEtc config.csh/vtk mesa_version "$optionValue"
adjusted=true
shift
;;
-vtk)
# Replace vtk_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk vtk_version "$optionValue"
replaceEtc config.csh/vtk vtk_version "$optionValue"
adjusted=true
shift
;;
-llvm-path)
# Replace LLVM_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk LLVM_ARCH_PATH \""$optionValue\""
replaceEtcCsh config.csh/vtk LLVM_ARCH_PATH \""$optionValue\""
adjusted=true
shift
;;
-mesa-path)
# Replace MESA_ARCH_PATH...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk MESA_ARCH_PATH \""$optionValue\""
replaceEtcCsh config.csh/vtk MESA_ARCH_PATH \""$optionValue\""
adjusted=true
shift
;;
-vtk-path)
# Replace VTK_DIR...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk VTK_DIR \""$optionValue\""
replaceEtcCsh config.csh/vtk VTK_DIR \""$optionValue\""
adjusted=true
shift
;;

317
bin/tools/install-platform Executable file
View File

@ -0,0 +1,317 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# install-platform
#
# Example usage
# install-platform -prefix=/opt/openfoam2006
#
# Description
# Simple installer for binary bin/, lib/ directories
# (platforms directories), to simplify packaging.
#
# Note
# The platforms/tools directory must be handled separately
#
# Layout of OpenFOAM platforms
#
# platforms
# |-- <WM_OPTIONS>
# |-- bin
# | |-- ...
# `-- lib
# |-- ...
# |-- dummy
# | `-- ...
# |-- openmpi-system
# | |-- libPstream.so
# | `-- libptscotchDecomp.so
# `-- paraview-MAJ.MIN
# `-- ...
#
#------------------------------------------------------------------------------
printHelp() {
cat<<USAGE
Usage: ${0##*/} [OPTION]
input options:
-source=DIR Source directory (default: $WM_PROJECT_DIR)
-platform=NAME Platform name (default: $WM_OPTIONS)
-foam-mpi=NAME OpenFOAM mpi name (default: $FOAM_MPI)
target options:
-prefix=DIR Top-level installation directory (eg, /opt/openfoamVER)
-bindir=DIR bin directory [<prefix>/platforms/<platform>/bin]
-libdir=DIR lib directory [<prefix>/platforms/<platform>/lib]
-mpi-libdir=DIR mpi lib directory [<prefix>/platforms/<platform>/lib/<foam-mpi>]
tuning options:
-no-bin Do not install bin directory
-no-lib Do not install lib directory
-no-mpi Do not install mpi lib directory
-mpi-only Only install mpi lib directory
-mpi-mkdir Create foam-mpi directory within libdir
general options:
-dry-run, -n Do not perform any operations
-verbose, -v Additional verbosity
-help Print the help and exit
Simple installer for binary bin/, lib/ directories (platforms directories),
to simplify packaging.
USAGE
exit 0 # A clean exit
}
unset optDryRun hadError
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '%{0##*/} -help' for usage"
echo
exit 1
}
# Report error and exit
warnOrDie()
{
if [ -n "$optDryRun" ]
then
hadError=true
while [ "$#" -ge 1 ]; do echo "Error: $1" 1>&2; shift; done
else
die "$@"
fi
}
# Get the option's value (argument), or die on missing or empty value
# $1 option=value
getOptionValue()
{
local value="${1#*=}"
# Remove any surrounding double quotes
value="${value%\"}"
value="${value#\"}"
[ -n "$value" ] || die "'${1%=}' option requires a value"
echo "$value"
}
#-------------------------------------------------------------------------------
# Defaults from current OpenFOAM environment
sourceDir="$WM_PROJECT_DIR"
platform="$WM_OPTIONS"
foam_mpi="$FOAM_MPI"
unset optInstall_bin optInstall_lib
unset optMpi_mkdir
optInstall_mpi=true
unset prefix bindir libdir libdir_mpi optVerbose
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*) printHelp ;;
-n | -dry-run) optDryRun="(dry-run) " ;;
-v | -verbose) optVerbose=true ;;
# Inputs
-source=*) sourceDir="$(getOptionValue "$1")" ;;
-platform=*) platform="$(getOptionValue "$1")" ;;
-foam-mpi=*) foam_mpi="$(getOptionValue "$1")" ;;
# Targets
-prefix=*) prefix="$(getOptionValue "$1")" ;;
-bindir=*) bindir="$(getOptionValue "$1")" ;;
-libdir=*) libdir="$(getOptionValue "$1")" ;;
-mpi-libdir=*) libdir_mpi="$(getOptionValue "$1")" ;;
-no-bin) optInstall_bin=false ;;
-no-lib) optInstall_lib=false ;;
-no-mpi) optInstall_mpi=false ;;
-mpi-only) optInstall_mpi=exclusive ;;
-mpi-mkdir) optMpi_mkdir=true ;;
*)
die "Unknown option/argument: $1"
;;
esac
shift
done
#-------------------------------------------------------------------------------
# Report settings
echo "Preparing install with the following parameters" 1>&2
echo "source:" 1>&2
echo " directory $sourceDir" 1>&2
echo " platform $platform" 1>&2
echo " foam-mpi $foam_mpi" 1>&2
echo 1>&2
echo "target (mpi-install: $optInstall_mpi)" 1>&2
echo " directory $prefix" 1>&2
echo " bindir ${bindir:-[default]}" 1>&2
echo " libdir ${libdir:-[default]}" 1>&2
echo " libdir(mpi) ${libdir_mpi:-[default]}" 1>&2
echo 1>&2
# Input checks
[ -d "$sourceDir" ] || warnOrDie "Invalid -source directory: $sourceDir"
[ -n "$platform" ] || warnOrDie "No -platform detected or specified"
[ -n "$foam_mpi" ] || warnOrDie "No -foam-mpi detected or specified"
sourcePlatform="$sourceDir/platforms/$platform"
[ -d "$sourcePlatform" ] || \
warnOrDie "Missing platforms directory for: $platform"
# Installation directories
if [ -n "$prefix" ]
then
installPlatform="$prefix/platforms/$platform"
# Set defaults based on -prefix
[ -n "$bindir" ] || bindir="$installPlatform/bin"
[ -n "$libdir" ] || libdir="$installPlatform/lib"
fi
# Default mpi libdir based on libdir
if [ -z "$libdir_mpi" ] && [ -n "$libdir" ]
then
libdir_mpi="$libdir/$foam_mpi"
fi
# Check sanity
[ -n "$bindir$libdir$libdir_mpi" ] || \
warnOrDie "Must specify at least one of -prefix, -bindir, -libdir, -mpi-libdir"
if [ -n "$hadError" ]
then
echo "Errors encounters in dry-run. Stopping" 1>&2
exit 1
fi
#------------------------------------------------------------------------------
if [ "$optInstall_bin" = false ] || [ "$optInstall_mpi" = exclusive ]
then
unset bindir
fi
if [ "$optInstall_lib" = false ] || [ "$optInstall_mpi" = exclusive ]
then
unset libdir
fi
if [ "$optInstall_mpi" = false ]
then
unset libdir_mpi
fi
# bin/
if [ -n "$bindir" ]
then
echo "${optDryRun}Install bindir: $bindir" 1>&2
if [ -z "$optDryRun" ]
then
mkdir -p "$bindir" 2>/dev/null
[ -n "$optVerbose" ] && echo "Copy $sourcePlatform/bin" 1>&2
for i in "$sourcePlatform/bin/"*
do
if [ -e "$i" ]
then
cp -a ${optVerbose:+-v} "$i" "$bindir"
fi
done
fi
else
echo "${optDryRun}Install bindir: [disabled]" 1>&2
fi
# lib/ without mpi
if [ -n "$libdir" ]
then
echo "${optDryRun}Install libdir(non-mpi): $libdir" 1>&2
if [ -z "$optDryRun" ]
then
mkdir -p "$libdir" 2>/dev/null
[ -n "$optVerbose" ] && echo "Copy $sourcePlatform/lib" 1>&2
for i in "$sourcePlatform/lib/"*
do
if [ "${i##*/}" = "$foam_mpi" ]
then
if [ "$optMpi_mkdir" = true ]
then
mkdir -p "$libdir/$foam_mpi"
fi
elif [ -e "$i" ]
then
cp -a ${optVerbose:+-v} "$i" "$libdir"
else
echo "bogus lib entry? $i" 1>&2
fi
done
fi
else
echo "${optDryRun}Install libdir: [disabled]" 1>&2
fi
# lib/mpi
if [ -n "$libdir_mpi" ]
then
echo "${optDryRun}Install libdir(mpi): $libdir_mpi" 1>&2
if [ -z "$optDryRun" ]
then
mkdir -p "$libdir_mpi" 2>/dev/null
[ -n "$optVerbose" ] && echo "Copy $sourcePlatform/lib/$foam_mpi" 1>&2
for i in "$sourcePlatform/lib/$foam_mpi"/*
do
if [ -e "$i" ]
then
# Always verbose (not many files anyhow)
cp -a -v "$i" "$libdir_mpi"
else
echo "bogus mpi-lib entry? $i" 1>&2
fi
done
fi
else
echo "${optDryRun}Install libdir(mpi): [disabled]" 1>&2
fi
exit 0 # clean exit
#------------------------------------------------------------------------------

View File

@ -1,191 +0,0 @@
#!/bin/bash
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# Script
# openfoam [args]
#
# Description
# Open an interactive bash session with an OpenFOAM environment,
# or run an OpenFOAM application (with arguments) after first sourcing
# the OpenFOAM etc/bashrc file from the project directory.
#
# This script normally exists in $WM_PROJECT_DIR/bin/tools but can also
# be modified to use a hard-coded PROJECT_DIR entry and placed elsewhere
# in the filesystem (eg, /usr/bin).
#
#------------------------------------------------------------------------------
# Hard-coded value (eg, with autoconfig)
projectDir="@PROJECT_DIR@"
if [ -z "$projectDir" ] || [ "${projectDir#@}" != "$projectDir" ]
then
# Auto-detect from location
toolsDir="${0%/*}" # The bin/tools dir
projectDir="${toolsDir%/bin/tools}" # Project dir
case "$projectDir" in
(/bin | /usr/bin | /usr/local/bin)
# This shouldn't happen.
# If copied to a system dir, should also be using hard-coded values!
echo "Warning: suspicious looking project dir: $projectDir" 1>&2
;;
("$toolsDir")
# Eg, called as ./openfoam etc - need to try harder
projectDir="$(\cd $(dirname $0)/../.. && \pwd -L)" || unset projectDir
;;
esac
fi
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: ${0##*/} [OPTION] [application ...]
options:
-prefix=DIR Specify alternative OpenFOAM directory
-sp Single precision
-dp Double precision
-spdp Mixed single/double precision
-int32 | -int64 The label-size
-help Print the usage
Open an interactive bash session with an OpenFOAM environment,
or run an OpenFOAM application (with arguments) after first sourcing
the OpenFOAM etc/bashrc file from the project directory:
($projectDir)
For more information: www.OpenFOAM.com
USAGE
exit 1
}
#-------------------------------------------------------------------------------
# Only preserve settings for non-interactive?
if [ "$#" -eq 0 ]
then
unset _foamSettings FOAM_SETTINGS
else
_foamSettings="$FOAM_SETTINGS"
fi
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
usage
;;
-prefix=* | -foam=*)
projectDir="${1#*=}"
;;
-sp | -SP)
# WM_PRECISION_OPTION=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=SP"
;;
-dp | -DP)
# WM_PRECISION_OPTION=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=DP"
;;
-spdp | -SPDP)
# WM_PRECISION_OPTION=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=SPDP"
;;
-int32 | -int64)
# WM_LABEL_SIZE=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_LABEL_SIZE=${1#-int}"
;;
--)
shift
break
;;
-*)
echo "Error: unknown option: '$1'" 1>&2
exit 1
;;
*)
break
;;
esac
shift
done
#-------------------------------------------------------------------------------
# Remove current OpenFOAM environment
if [ -d "$WM_PROJECT_DIR" ] && [ -f "$WM_PROJECT_DIR/etc/config.sh/unset" ]
then
. "$WM_PROJECT_DIR/etc/config.sh/unset"
fi
[ -d "$projectDir" ] || {
echo "Error: no project dir: $projectDir" 1>&2
exit 2
}
_foamSourceBashEnv="$projectDir/etc/bashrc"
if [ "$#" -eq 0 ]
then
# Interactive shell
_foamSourceBashEnv="$projectDir/bin/tools/source-bashrc"
fi
[ -f "$_foamSourceBashEnv" ] || {
echo "Error: file not found: $_foamSourceBashEnv" 1>&2
exit 2
}
if [ "$#" -eq 0 ]
then
# Source user ~/.bashrc and OpenFOAM etc/bashrc.
# 1) Can either use a tmp file, or 2) chain off to a dedicated file
# We use a dedicated file.
if [ -n "$_foamSettings" ]
then
export FOAM_SETTINGS="$_foamSettings"
fi
## echo "Source with $_foamSourceBashEnv with '$FOAM_SETTINGS'" 1>&2
# Interactive shell (newer bash can use --init-file instead of --rcfile)
exec bash --rcfile "$_foamSourceBashEnv" -i
else
# Non-interactive
# Source bashrc within a function to preserve command-line arguments
# - this will not have aliases, but working non-interactively anyhow
sourceBashrc()
{
. "$_foamSourceBashEnv" $_foamSettings
}
sourceBashrc
exec "$@"
fi
#------------------------------------------------------------------------------

19
bin/tools/openfoam.in Normal file
View File

@ -0,0 +1,19 @@
#!/bin/sh
exec "@PROJECT_DIR@"/etc/openfoam "$@"
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Description
# Forwarding to OpenFOAM etc/openfoam bash session script.
# Uses a hard-code directory path (eg, generated with autoconfig).
#
#------------------------------------------------------------------------------

View File

@ -0,0 +1,75 @@
#!/bin/sh
FOAM_MPI="@FOAM_MPI@"
FOAM_SYSTEM_MPI_LIBBIN="@FOAM_SYSTEM_MPI_LIBBIN@"
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Description
# Local update of links from system mpi lib/ to local lib/mpi-name
#
# Note
# Normally located as a trigger within the platforms/ directory
# Uses hard-code values (eg, generated with autoconfig).
#
#------------------------------------------------------------------------------
cd "${0%/*}" || exit # Run from this directory
# Local values
FOAM_LIBBIN="$(pwd -P)/lib"
FOAM_MPI_LIBBIN="$FOAM_LIBBIN/$FOAM_MPI"
#------------------------------------------------------------------------------
echo "Link OpenFOAM ($FOAM_MPI) from system mpi locations"
echo "Target: $FOAM_MPI_LIBBIN"
echo "Source: $FOAM_SYSTEM_MPI_LIBBIN"
if [ -z "$FOAM_MPI" ]
then
echo "FOAM_MPI not defined - skipping"
exit 0
fi
if [ -z "$FOAM_SYSTEM_MPI_LIBBIN" ]
then
echo "FOAM_SYSTEM_MPI_LIBBIN not defined - skipping"
exit 0
fi
if [ ! -d "$FOAM_SYSTEM_MPI_LIBBIN" ]
then
echo "No system mpi lib: $FOAM_SYSTEM_MPI_LIBBIN"
echo "... not updating"
exit 0
fi
if [ ! -d "$FOAM_LIBBIN" ]
then
echo "Missing $FOAM_LIBBIN"
exit 0
fi
#------------------------------------------------------------------------------
mkdir -p "$FOAM_MPI_LIBBIN"
# Create symlinks
(
cd "$FOAM_MPI_LIBBIN" || exit
for i in "$FOAM_SYSTEM_MPI_LIBBIN"/*
do
if [ -f "$i" ]
then
ln -svf "$i" "${i##*/}"
fi
done
)
exit 0 # clean exit
#------------------------------------------------------------------------------

1
doc/modules/README Normal file
View File

@ -0,0 +1 @@
Modules-related documents when collated for an installation package.

70
doc/openfoam.1.in Normal file
View File

@ -0,0 +1,70 @@
.TH "OPENFOAM" 1 "OpenFOAM-version" "www.openfoam.com" "OpenFOAM Commands Manual"
.SH NAME
openfoam \- OpenFOAM bash(1) session
.SH SYNOPSIS
\fBopenfoam\fR [\fIOPTIONS\fR] [\fIapplication ...\fR]
.SH DESCRIPTION
Activate an \fBOpenFOAM\fR environment in an interactive or
non-interactive bash(1) session.
If no application is given, an interactive bash session will be used.
If an application (optionally with arguments) is provided, the
OpenFOAM \fIetc/bashrc\fR file will be sourced from the project directory
prior to running the application.
.SH OPTIONS
.TP
\fB\-c\fR \fIcommand\fR
Execute shell commands with OpenFOAM environment
.TP
\fB\-D\fR\fIkey=[value]\fR
Define key/value to pass as a preference
.TP
\fB\-sp\fR
Use single precision for scalar-size
.TP
\fB\-dp\fR
Use double precision for scalar-size
.TP
\fB\-spdp\fR
Use single precision for scalar-size, double for solve-scalar size
.TP
\fB\-int32\fR
Use 32-bit label-size
.TP
\fB\-int64\fR
Use 64-bit label-size
.TP
\fB\-prefix=DIR\fR
Specify alternative OpenFOAM project directory
.TP
\fB\-show-api\fR | \fB\-version\fR
Print META-INFO api value and exit
.TP
\fB\-show-patch\fR
Print META-INFO patch value and exit
.TP
\fB\-show-prefix\fR
Print project directory and exit
.TP
\fB\-help\fR
Print the usage
.SH ARGUMENTS
If arguments remain after option processing, the first argument is
assumed to be an application with options and arguments.
.SH FILES
The \fIetc/bashrc\fR file from the OpenFOAM project directory supplies
the environment settings.
.SH "SEE ALSO"
Online documentation https://www.openfoam.com/documentation/
.SH COPYRIGHT
Copyright \(co 2020 OpenCFD Ltd.

View File

@ -2,16 +2,18 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2012-2016 OpenFOAM Foundation
# Copyright (C) 2016-2018 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/config.sh/gperftools
# - sourced by OpenFOAM-*/etc/bashrc
# Not normally sourced by OpenFOAM-*/etc/bashrc
#
# Description
# Setup file for GPERFTOOLS binaries/libraries.
@ -45,7 +47,7 @@ then
echo "Using gperftools ($gperftools_version) -> $GPERFTOOLS_ARCH_PATH" 1>&2
fi
if command -v _foamAddLib > /dev/null 2>&1 # Normal sourcing
if command -v _foamAddLib >/dev/null # Normal sourcing
then
# If GPERFTOOLS_ARCH_PATH does not end with '-system' or '-none',

View File

@ -119,7 +119,6 @@ _foamEtc -config settings
_foamEtc -config mpi
_foamEtc -config paraview -- "$@" # Pass through for evaluation
_foamEtc -config vtk
_foamEtc -config gperftools
## _foamEtc -config ADIOS
## _foamEtc -config ADIOS2
_foamEtc -config CGAL

301
etc/openfoam Executable file
View File

@ -0,0 +1,301 @@
#!/bin/bash
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# openfoam [options] [args]
#
# Description
# Open an interactive bash session with an OpenFOAM environment,
# or run an OpenFOAM application (with arguments) after first sourcing
# the OpenFOAM etc/bashrc file from the project directory.
#
# Note
# This script normally exists in the $WM_PROJECT_DIR/etc/ directory.
# Do not copy/move/link to other locations. Use instead an edited copy of
# `bin/tools/openfoam.in` with a hard-coded projectDir entry.
#
# See OpenFOAM etc/bashrc for (command-line) preferences.
# Some equivalent settings:
# -sp | -DWM_PRECISION_OPTION=SP
# -dp | -DWM_PRECISION_OPTION=DP
# -int32 | -DWM_LABEL_SIZE=32
# -int64 | -DWM_LABEL_SIZE=64
#
# However, the '-D' options grant more flexibility. For example,
# etc/openfoam -DWM_COMPILER=Clang
#
#------------------------------------------------------------------------------
# Auto-detect from location. Do not call from within the etc/directory itself!
projectDir="$(\cd "$(dirname "${0%/*}")" && \pwd -L)"
#------------------------------------------------------------------------------
printHelp() {
cat<<USAGE
Usage: ${0##*/} [OPTION] [application ...]
options:
-c command Execute shell commands with OpenFOAM environment
-Dkey[=value] Define key/value to pass as a preference
-sp Single precision
-dp Double precision
-spdp Mixed single/double precision
-int32 | -int64 The label-size
-etc=DIR Additional project etc/ directory
-prefix=DIR Alternative OpenFOAM project directory
-show-api | -version Print META-INFO api value and exit
-show-patch Print META-INFO patch value and exit
-show-prefix Print project directory and exit
-test-tutorial Forward arguments to tutorials/AutoTest
-verbose Set FOAM_VERBOSE=true (interactive only)
-help Print the usage
Open an interactive bash session with an OpenFOAM environment,
or run an OpenFOAM application (with arguments) after first sourcing
the OpenFOAM etc/bashrc file from the project directory:
($projectDir)
For more information: www.openfoam.com
USAGE
exit 0 # A clean exit
}
#-------------------------------------------------------------------------------
# Get a value from META-INFO/api-info
# $1 : keyword
getApiInfo()
{
value="$(sed -ne 's@^'"$1"' *= *\([0-9][0-9]*\).*@\1@p' "$projectDir"/META-INFO/api-info 2>/dev/null)"
if [ -n "$value" ]
then
echo "$value"
else
echo "Could not determine OPENFOAM '$1' value" 1>&2
return 1
fi
}
#-------------------------------------------------------------------------------
# No inheritance of FOAM_SETTINGS
unset FOAM_SETTINGS
unset _foamEtcDir _foamSettings _foamScriptCommand
unset optTestTut
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help* | --help*)
printHelp
;;
-show-api | -version | --version) # Show API and exit
getApiInfo api
exit $?
;;
-show-patch) # Show patch level and exit
getApiInfo patch
exit $?
;;
-show-prefix) # Show project directory and exit
echo "$projectDir"
exit $?
;;
-test-tutorial) # Run tutorials/AutoTest
optTestTut=true
;;
-c) # Shell command
_foamScriptCommand="$2"
[ -n "$_foamScriptCommand" ] || {
echo "$0: missing or bad command argument: $2" 1>&2
exit 1
}
shift 2
break
;;
-D*) # Define key/value to pass as preference
setting="${1#-D}"
if [ -n "$setting" ]
then
_foamSettings="$_foamSettings${_foamSettings:+ }$setting"
fi
;;
-sp | -dp | -spdp )
# WM_PRECISION_OPTION=(SP|DP|SPDP)
setting=$(echo "${1#-}" | sed -e 's/-//g;y/sdp/SDP/')
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=$setting"
;;
-int32 | -int64)
# WM_LABEL_SIZE=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_LABEL_SIZE=${1#-int}"
;;
-etc=*)
# Define FOAM_CONFIG_ETC for finding files
_foamEtcDir="${1#*=}"
;;
-prefix=*)
projectDir="${1#*=}"
;;
-verbose)
export FOAM_VERBOSE=true
;;
--)
shift
break
;;
-*)
echo "$0: unknown option: '$1'" 1>&2
exit 1
;;
*)
break
;;
esac
shift
done
#-------------------------------------------------------------------------------
# Sanity check (installed under /bin, /usr/bin, /usr/local/bin)
# This should not happen.
# If copied to a system dir, should also be using hard-coded values!
if [ "${projectDir%/bin}" != "$projectDir" ]
then
echo "Warning: suspicious project dir: $projectDir" 1>&2
fi
[ -d "$projectDir/META-INFO" ] || {
echo "Warning: missing META-INFO in OpenFOAM directory:" 1>&2
echo " $projectDir" 1>&2
}
# Remove current OpenFOAM environment
if [ -d "$WM_PROJECT_DIR" ] && [ -f "$WM_PROJECT_DIR/etc/config.sh/unset" ]
then
. "$WM_PROJECT_DIR/etc/config.sh/unset" || true
fi
unset interactive
if [ "$#" -eq 0 ] && [ -z "$_foamScriptCommand" ] && [ -z "$optTestTut" ]
then
# Interactive shell, chain off via a file
interactive=true
_foamSourceBashEnv="$projectDir/bin/tools/source-bashrc"
else
# Non-interactive shell, use the OPENFOAM etc/bashrc
_foamSourceBashEnv="$projectDir/etc/bashrc"
fi
[ -f "$_foamSourceBashEnv" ] || {
echo "Error: file not found: $_foamSourceBashEnv" 1>&2
exit 2
}
if [ -n "$_foamEtcDir" ] && [ -d "$_foamEtcDir" ]
then
# Additional etc directory
export FOAM_CONFIG_ETC="$_foamEtcDir"
else
unset FOAM_CONFIG_ETC
fi
if [ -n "$interactive" ]
then
# Interactive shell
# -----------------
# Source ~/.bashrc and OpenFOAM etc/bashrc in one of two ways:
# 1) Generate and use a tmp file
# 2) Chain off to a dedicated file [This is what we use]
if [ -n "$_foamSettings" ]
then
# Pass preferences via the FOAM_SETTINGS mechanism
export FOAM_SETTINGS="$_foamSettings"
fi
## echo "Source with $_foamSourceBashEnv with '$FOAM_SETTINGS'" 1>&2
# Newer bash can use --init-file instead of --rcfile
exec bash --rcfile "$_foamSourceBashEnv" -i
exit $? # Safety
fi
# Non-interactive shell
# ---------------------
# Source bashrc within a function to preserve command-line arguments
# Suppresses aliases as a side-effect, but non-interactive anyhow.
sourceBashrc()
{
. "$_foamSourceBashEnv" $_foamSettings
}
if [ -n "$_foamScriptCommand" ]
then
# A shell command
sourceBashrc
exec bash -c "$_foamScriptCommand" "$@"
exit $? # Safety
fi
if [ -n "$optTestTut" ]
then
sourceBashrc
exec "$WM_PROJECT_DIR/tutorials/AutoTest" "$@"
exit $? # Safety
fi
# An application or a shell script
# It may actually be a script with a '#!/project-path/bin/openfoam',
# so we need to catch this to avoid infinite recursion.
if [ -f "$1" ] \
&& [ -n "$(sed -ne '1{/^#!.*\/openfoam$/p; q}' "$1" 2>/dev/null)" ]
then
# A shell script
sourceBashrc
exec bash "$@"
else
# An application
sourceBashrc
exec "$@"
fi
#------------------------------------------------------------------------------

View File

@ -2,8 +2,10 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -84,7 +86,19 @@ inline bool Foam::HashPtrTable<T, Key, Hash>::set
T* ptr
)
{
return this->parent_type::set(key, ptr);
// Newer: const T* old = this->get(key);
iterator iter(this->find(key));
const T* old = (iter.found() ? iter.object() : nullptr);
const bool ok = this->parent_type::set(key, ptr);
if (ok && old != ptr)
{
delete const_cast<T*>(old);
}
return ok;
}

View File

@ -104,21 +104,21 @@ inline void Foam::PtrList<T>::append(T* ptr)
template<class T>
inline void Foam::PtrList<T>::append(autoPtr<T>& aptr)
{
return UPtrList<T>::append(aptr.release());
UPtrList<T>::append(aptr.release());
}
template<class T>
inline void Foam::PtrList<T>::append(autoPtr<T>&& aptr)
{
return UPtrList<T>::append(aptr.release());
UPtrList<T>::append(aptr.release());
}
template<class T>
inline void Foam::PtrList<T>::append(const tmp<T>& tptr)
{
return UPtrList<T>::append(tptr.ptr());
UPtrList<T>::append(tptr.ptr());
}

View File

@ -2,8 +2,11 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -141,7 +144,8 @@ bool Foam::functionEntries::includeEntry::execute
{
if (Foam::functionEntries::includeEntry::log)
{
DetailInfo << fName << endl;
// Report to stdout which file is included
Info<< fName << nl;
}
// Add watch on included file
@ -186,7 +190,8 @@ bool Foam::functionEntries::includeEntry::execute
{
if (Foam::functionEntries::includeEntry::log)
{
DetailInfo << fName << endl;
// Report to stdout which file is included
Info<< fName << nl;
}
// Add watch on included file

View File

@ -2,8 +2,11 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -102,7 +105,8 @@ bool Foam::functionEntries::includeEtcEntry::execute
{
if (Foam::functionEntries::includeEtcEntry::log)
{
DetailInfo << fName << endl;
// Report to stdout which file is included
Info<< fName << nl;
}
parentDict.read(ifs);
return true;
@ -135,7 +139,8 @@ bool Foam::functionEntries::includeEtcEntry::execute
{
if (Foam::functionEntries::includeEtcEntry::log)
{
DetailInfo << fName << endl;
// Report to stdout which file is included
Info<< fName << nl;
}
entry.read(parentDict, ifs);
return true;

View File

@ -167,7 +167,7 @@ Foam::label Foam::primitiveEntry::startLineNumber() const
if (tokens.size())
{
tokens.first().lineNumber();
return tokens.first().lineNumber();
}
return -1;

View File

@ -2,8 +2,10 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,7 +70,7 @@ inline Foam::Pair<T>::Pair(const FixedList<T, 2>& lst)
template<class T>
inline Foam::Pair<T>::Pair(const T& f, const T& s, const bool doSort)
{
if (doSort && f < s)
if (doSort && s < f)
{
first() = s;
second() = f;
@ -88,7 +90,6 @@ inline Foam::Pair<T>::Pair(const FixedList<T, 2>& lst, const bool doSort)
{}
template<class T>
inline Foam::Pair<T>::Pair(Istream& is)
:

View File

@ -24,8 +24,8 @@ starcd/STARCDMeshWriter.C
polyDualMesh/polyDualMesh.C
vtk/output/foamVtkInternalWriter.H
vtk/output/foamVtkPatchWriter.H
vtk/output/foamVtkInternalWriter.C
vtk/output/foamVtkPatchWriter.C
vtk/output/foamVtkSurfaceFieldWriter.C
LIB = $(FOAM_LIBBIN)/libconversion

View File

@ -41,7 +41,8 @@ wmakeLnInclude -u decompositionMethods
if have_scotch
then
wmake $targetType scotchDecomp
if [ -d "$FOAM_LIBBIN/$FOAM_MPI" ]
if have_ptscotch
then
wmakeMpiLib "$SCOTCH_VERSION" ptscotchDecomp
fi

View File

@ -1,13 +1,12 @@
/*
* NB: mplib PINC must appear after the SCOTCH_ARCH_PATH/include/FOAM_MPI
* to ensure we do not accidentally get a ptscotch header from the
* mpi distribution.
* NB: mplib PINC must appear after PTSCOTCH_INC_DIR to ensure we
* do not accidentally get a ptscotch header from the MPI distribution.
*/
sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB)
sinclude $(DEFAULT_RULES)/mplib$(WM_MPLIB)
EXE_INC = \
-I$(SCOTCH_ARCH_PATH)/include/$(FOAM_MPI) \
-I$(PTSCOTCH_INC_DIR) \
-I$(SCOTCH_INC_DIR) \
$(PFLAGS) $(PINC) \
-I../decompositionMethods/lnInclude
@ -17,9 +16,8 @@ EXE_INC = \
* ptscotch 6 requires scotch linked in, but does not declare the dependency
*/
LIB_LIBS = \
-L$(PTSCOTCH_LIB_DIR) \
-L$(SCOTCH_LIB_DIR) \
-L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) \
-L$(FOAM_EXT_LIBBIN) \
-lptscotch -lptscotcherrexit \
-lscotch

199
tutorials/AutoTest Executable file
View File

@ -0,0 +1,199 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# tutorials/AutoTest dir [.. dirN]
#
# Description
# Run foamRunTutorials with specified tutorial directories
# Creates/destroys a temporary directory for each test.
#
# Environment
# Requires an initialized OpenFOAM environment.
#
# Note
# Potentially useful for debian autopkgtest
#
#------------------------------------------------------------------------------
# Auto-detect from location
#Unused# projectDir="$(\cd "$(dirname "${0%/*}")" && \pwd -L)"
#------------------------------------------------------------------------------
printHelp() {
cat<<USAGE
usage: ${0##*/} [OPTION] dir [.. dirN]
options:
-1 Modify case controlDict to run only one time step (default)
-full Do not modify controlDict (run tutorial to completion)
-debian Any modifications when running with autopkgtest
-help Print the usage
Run foamRunTutorials with specified tutorial directories.
Creates/destroys a temporary directory for each.
USAGE
exit 0 # A clean exit
}
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '${0##*/} -help' for usage"
echo
exit 1
}
#------------------------------------------------------------------------------
unset optDebian optVerbose
optRunLimit=1
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h*)
printHelp
;;
-1)
optRunLimit="${1#-}"
;;
-full)
unset optRunLimit
;;
-debian)
# Redirect stderr to stdout, if autopkgtest (tests/control)
# does NOT use "Restrictions: allow-stderr"
exec 2>&1
;;
--)
break
;;
-*)
die "unknown option $1"
;;
*)
break
;;
esac
shift
done
#------------------------------------------------------------------------------
# Basic sanity checks
[ -n "$FOAM_TUTORIALS" ] || export FOAM_TUTORIALS="$WM_PROJECT_DIR"/tutorials
[ -d "${WM_PROJECT_DIR:?}" ] || die "No OpenFOAM environment: $WM_PROJECT_DIR"
[ -d "$FOAM_TUTORIALS" ] || die "No OpenFOAM tutorials : $FOAM_TUTORIALS"
#------------------------------------------------------------------------------
#
# Modify case controlDicts to run only one time step
#
modifyCaseControlDict()
{
for dict in $(find . -name "controlDict*" -type f)
do
cp -f "${dict}" "${dict}.orig"
sed \
-e 's/\(startFrom[ \t]*\)\([A-Za-z]*\);/\1 latestTime;/' \
-e 's/\(stopAt[ \t]*\)\([A-Za-z]*\);/\1 nextWrite;/' \
-e 's/\(writeControl[ \t]*\)\([A-Za-z]*\);/\1 timeStep;/' \
-e 's/\(writeInterval[ \t]*\)\([-.0-9A-Za-z]*\);/\1 '"$optRunLimit"';/' \
"${dict}.orig" > "${dict}"
done
}
#------------------------------------------------------------------------------
nTests="$#"
nPassed=0
for testdir in "$@"
do
testdir="${testdir#tutorials/}"
testdir="$(echo "$testdir" | sed -e 's@^//*@@; s@//*$@@;')"
suffix="$(echo "$testdir" | sed -e 's@//*@_@g')"
if [ -n "$testdir" ] && [ -d "$FOAM_TUTORIALS/$testdir" ]
then
(
echo "Run test: $testdir"
set -e
TESTDIR="$(mktemp --directory --suffix=".$suffix")"
trap 'rm -rf $TESTDIR' 0 INT QUIT ABRT PIPE TERM
cp -r "$FOAM_TUTORIALS/$testdir"/* "$TESTDIR"/
cd "$TESTDIR"
if [ -n "$optRunLimit" ]
then
set +e
modifyCaseControlDict
set -e
fi
nInput="$(ls | wc -l)"
foamRunTutorials
nOutput="$(ls | wc -l)"
if [ "$nInput" = 0 ]
then
echo "No input for $testdir" 1>&2
exit 1
elif [ "$nOutput" = "$nInput" ]
then
echo "Run failure for $testdir" 1>&2
exit 1
else
echo "run: OK"
fi
) && nPassed=$((nPassed + 1))
else
echo "No tutorial: $testdir" 1>&2
fi
done
if [ "$nTests" = 0 ]
then
die "No tests specified"
elif [ "$nPassed" = "$nTests" ]
then
echo "Passed all $nTests tests"
else
echo "Passed $nPassed/$nTests tests" 1>&2
exit 1
fi
#------------------------------------------------------------------------------

1
tutorials/modules/README Normal file
View File

@ -0,0 +1 @@
Modules-related tutorials when collated for an installation package.

98
wmake/makefiles/info Normal file
View File

@ -0,0 +1,98 @@
#----------------------------*- makefile-gmake -*------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# File
# wmake/makefiles/info
#
# Description
# Makefile to generate information.
# Used by wmake -show-*
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Use POSIX shell
#------------------------------------------------------------------------------
SHELL = /bin/sh
#------------------------------------------------------------------------------
# No default suffix rules used
#------------------------------------------------------------------------------
.SUFFIXES:
#------------------------------------------------------------------------------
# Some default values
#------------------------------------------------------------------------------
# Shared library extension (with '.' separator)
EXT_SO = .so
#------------------------------------------------------------------------------
# Compilation rules
#------------------------------------------------------------------------------
GENERAL_RULES = $(WM_DIR)/rules/General
include $(GENERAL_RULES)/general
# Commands
COMPILE_C := $(strip $(cc) $(cFLAGS))
COMPILE_CXX := $(strip $(CC) $(c++FLAGS))
#------------------------------------------------------------------------------
# Display information
#------------------------------------------------------------------------------
.PHONY: api
api:
@echo "$(lastword $(subst =, ,$(WM_VERSION)))"
.PHONY: ext-so
ext-so:
@echo "$(EXT_SO)"
.PHONY: compile-c
compile-c:
@echo "$(COMPILE_C)"
.PHONY: compile-cxx
compile-cxx:
@echo "$(COMPILE_CXX)"
.PHONY: c
c:
@echo "$(firstword $(cc))"
.PHONY: cxx
cxx:
@echo "$(firstword $(CC))"
.PHONY: cflags
cflags:
@echo "$(wordlist 2,$(words $(COMPILE_C)), $(COMPILE_C))"
.PHONY: cxxflags
cxxflags:
@echo "$(wordlist 2,$(words $(COMPILE_CXX)), $(COMPILE_CXX))"
.PHONY: cflags-arch
cflags-arch:
@echo "$(strip $(cARCH))"
.PHONY: cxxflags-arch
cxxflags-arch:
@echo "$(strip $(c++ARCH))"
#----------------------------- vim: set ft=make: ------------------------------

View File

@ -17,7 +17,7 @@ GLIB_LIBS =
COMPILER_TYPE = $(shell echo $(WM_COMPILER) | tr -d [:digit:])
DEFAULT_RULES = $(WM_DIR)/rules/$(WM_ARCH)$(COMPILER_TYPE)
RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER)
WMAKE_BIN = $(WM_DIR)/platforms/$(WM_ARCH)$(WM_COMPILER)
WMAKE_BIN = $(WM_PROJECT_DIR)/platforms/tools/$(WM_ARCH)$(WM_COMPILER)
ifeq ($(WM_SCHEDULER),)
AND = &&

View File

@ -0,0 +1,6 @@
# Empty flags for not compiling/linking with CGAL
CGAL_INC =
CGAL_LIBS =
#------------------------------------------------------------------------------

View File

@ -2,12 +2,14 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2014-2017 OpenFOAM Foundation
# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# wmake/scripts/AllwmakeParseArguments
@ -17,16 +19,37 @@
#
# Usage
# # Parse the arguments by sourcing this script
# . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
# . ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
#
# Parsed options (make)
# -k | -keep-going | -non-stop
# -j | -jN | -j N
#
# Parsed options (wmake)
# -debug
# -q | -queue
# -module-prefix=...
# Exports FOAM_MODULE_PREFIX value.
# Unsets FOAM_MODULE_APPBIN, FOAM_MODULE_LIBBIN.
# Handles (user|group|openfoam) or (u|g|o) as per foamEtcFile,
# or absolute/relative paths
#
# Parsed options (special)
# -l | -log | -log=FILE
# -prefix=... same as -module-prefix=...
#
#------------------------------------------------------------------------------
if [ -z "$WM_PROJECT_DIR" ]
then
echo "$Script error: The OpenFOAM environment is not set."
echo " Check the OpenFOAM entries in your dot-files and source them."
# Check environment
[ -d "$WM_PROJECT_DIR" ] || {
exec 1>&2
echo "$0"
echo "Error encountered:"
echo " The OpenFOAM environment not set or incorrect."
echo " Check your setup."
echo
exit 1
fi
}
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
@ -37,13 +60,18 @@ Executing ${0##*/} is equivalent to
wmake -all [OPTIONS]
With these additional options:
-l | -log | -log=name
With additional options:
-l | -log Tee output to log.\$WM_OPTIONS
-log=NAME Tee output to given filename
-prefix=... Define FOAM_MODULE_PREFIX (same as wmake -module-prefix)
-no-recursion Prevent recursive call (do NOT call 'wmake -all')
-fromWmake Same as -no-recursion
See
wmake -help (or wmake -help-full)
USAGE
wmake -help
exit 0
exit 0 # clean exit
}
@ -51,7 +79,7 @@ USAGE
# Parse the arguments and options
#------------------------------------------------------------------------------
unset fromWmake optLog optQueue
unset optDebug optLog optNonRecursive optPrefix optQueue
for arg in "$@"
do
@ -62,37 +90,83 @@ do
-h | -help*)
usage
;;
-fromWmake)
# If called from wmake (to avoid recursion)
fromWmake=true
-no-recurs* | -fromWmake)
# Avoid recursion (eg, if called from wmake)
optNonRecursive=true
# Pass onwards to other Allwmake scripts
;;
-k | -non-stop)
# Non-stop compilation, ignoring errors
-module-prefix=* | -prefix=* | --prefix=*)
optPrefix="${arg#*=}"
case "$optPrefix" in
# Prefix: user
(u | user)
export FOAM_MODULE_PREFIX="${FOAM_USER_LIBBIN%/*}"
;;
# Prefix: group
(g | group)
export FOAM_MODULE_PREFIX="${FOAM_SITE_LIBBIN%/*}"
;;
# Prefix: openfoam (other)
(o | openfoam)
export FOAM_MODULE_PREFIX="${FOAM_LIBBIN%/*}"
;;
# Prefix: custom (absolute or relative)
(*)
export FOAM_MODULE_PREFIX="$optPrefix"
: "${FOAM_MODULE_PREFIX:=/usr/local}" # Default (autoconf)
# Require absolute path
[ "${FOAM_MODULE_PREFIX#/}" != "${FOAM_MODULE_PREFIX}" ] || \
FOAM_MODULE_PREFIX="${PWD}/${FOAM_MODULE_PREFIX}"
;;
esac
unset FOAM_MODULE_APPBIN FOAM_MODULE_LIBBIN
echo "Module prefix = $FOAM_MODULE_PREFIX" 1>&2
continue # Handled argument
;;
-k | -keep-going | -non-stop)
# Keep going, ignoring errors
export WM_CONTINUE_ON_ERROR=true
continue # Permanently remove arg
;;
-l | -log)
optLog="log.${WM_OPTIONS:-Allwmake}"
optLog="log.${WM_OPTIONS:-build}"
continue # Permanently remove arg
;;
-log=*)
optLog="${arg##*=}"
if [ -d "$optLog" ]
then
optLog="${optLog%/}/log.${WM_OPTIONS:-Allwmake}"
optLog="${optLog%/}/log.${WM_OPTIONS:-build}"
elif [ -z "$optLog" ]
then
optLog="log.${WM_OPTIONS:-Allwmake}"
optLog="log.${WM_OPTIONS:-build}"
fi
continue # Permanently remove arg
;;
-q | -queue)
optQueue="-q"
-debug)
optDebug="-debug"
continue # Permanently remove arg
;;
-q | -queue)
optQueue="-queue"
continue # Permanently remove arg
;;
lib | libo | libso | dep | objects)
# Target type
targetType=$arg
targetType="$arg"
;;
esac
@ -105,20 +179,20 @@ done
# Execute wmake -all if not called from wmake
#------------------------------------------------------------------------------
if [ -z "$fromWmake" ]
if [ -z "$optNonRecursive" ]
then
if [ -z "$optLog" ]
then
exec wmake -all $optQueue $*
exec wmake -all $optDebug $optQueue $*
exit $? # Unneeded, but just in case something went wrong
else
echo "Logging wmake -all output to '$optLog'" 1>&2
echo 1>&2
exec wmake -all $optQueue $* 2>&1 | /usr/bin/tee $optLog
exec wmake -all $optDebug $optQueue $* 2>&1 | /usr/bin/tee $optLog
# Need to cleanup after the tee
rc=$? # Error code from tee (not wmake), but not entirely important
echo "Done logging to '$optLog'" 1>&2
exit $rc
exit "$rc"
fi
fi
@ -137,7 +211,7 @@ fi
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset fromWmake optLog optQueue
unset optNonRecursive optDebug optLog optPrefix optQueue
unset -f usage

View File

@ -2,70 +2,45 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# cmakeFunctions
#
# Description
# Helper functions for CMake
#
# Environment
# Consider CMAKE_INSTALL_PREFIX as a reserved name, although it is not
# set/unset here.
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions # Require some wmake functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
# Ensure CMake gets the correct C/C++ compilers
[ -n "$WM_CC" ] && export CC="$WM_CC"
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
# Export compiler information for cmake
export CC="$(wmake -show-c)"
export CXX="$(wmake -show-cxx)"
export CFLAGS="$(wmake -show-cflags)"
export CXXFLAGS="$(wmake -show-cxxflags)"
#------------------------------------------------------------------------------
#
# Check sentinel file(s) to handle paraview / vtk version changes
#
sameDependency()
{
local depend="$1"
local sourceDir="$2"
local objectsDir sentinel prev
# Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
sentinel="$objectsDir/ThirdParty"
echo "$sentinel"
if read -r prev 2>/dev/null < $sentinel
then
if [ "$prev" = "$depend" ]
then
return 0
else
echo "${depend%=*} changed between builds" 1>&2
return 1
fi
elif [ -f "$objectsDir/CMakeCache.txt" ]
then
echo "previous build was incomplete" 1>&2
return 1
else
return 0
fi
}
# CMake with output suppressed according to WM_QUIET
_cmake()
call_cmake()
{
echo "cmake..."
if [ -n "$WM_QUIET" ]
then
echo "cmake..."
cmake -DCMAKE_RULE_MESSAGES=OFF $@ >/dev/null
else
echo "cmake $@"
cmake $@
fi
}
@ -89,12 +64,13 @@ cmakeVersioned()
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
# Version changed
sentinel=$(sameDependency "$depend" "$sourceDir") || \
rm -rf "$objectsDir" > /dev/null 2>&1
sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
rm -rf "$objectsDir" 2>/dev/null
mkdir -p "$objectsDir" \
&& (cd "$objectsDir" && _cmake "$@" "$sourceDir" && make) \
&& echo "$depend" >| "${sentinel:-/dev/null}"
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
make ) \
&& storeDependency "$sentinel" "$depend" $@
}
@ -115,12 +91,13 @@ cmakeVersionedInstall()
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
# Version changed
sentinel=$(sameDependency "$depend" "$sourceDir") || \
rm -rf "$objectsDir" > /dev/null 2>&1
sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
rm -rf "$objectsDir" 2>/dev/null
mkdir -p "$objectsDir" \
&& (cd "$objectsDir" && _cmake "$@" "$sourceDir" && make install) \
&& echo "$depend" >| "${sentinel:-/dev/null}"
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
make install ) \
&& storeDependency "$sentinel" "$depend" $@
}
@ -142,12 +119,12 @@ wmakeVersioned()
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
# Version changed
sentinel=$(sameDependency "$depend" "$sourceDir") || \
rm -rf "$objectsDir" > /dev/null 2>&1
sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
rm -rf "$objectsDir" 2>/dev/null
mkdir -p "$objectsDir" \
&& wmake "$@" \
&& echo "$depend" >| "${sentinel:-/dev/null}"
&& storeDependency "$sentinel" "$depend" $@
}

92
wmake/scripts/dirToString Executable file
View File

@ -0,0 +1,92 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# Script
# dirToString
#
# Usage
# dirToString path/to/file
#
# Description
# Converts a directory path into a camelCase string.
# Leading [./] characters are stripped by default.
#
# For example,
# input: dir1/dir2/dir3
# output: dir1Dir2Dir3
#
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: ${0##*/} [OPTION] dir
options:
-no-strip Do not ignore leading [./] characters
-strip Ignore leading [./] characters (default)
-h, -help Print the usage
Converts a directory path into a camelCase string
USAGE
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
#------------------------------------------------------------------------------
optStrip=true
while [ "$#" -gt 0 ]
do
case "$1" in
# Print help
(-h | -help*)
usage
;;
(-s | -strip)
optStrip=true
;;
(-no-strip)
unset optStrip
;;
(--)
shift
break
;;
(*)
break
;;
esac
shift
done
if [ -z "$optStrip" ]
then
dirName="$1"
else
# Ignore any leading ./ characters
dirName="$(echo ""$1"" | sed -e 's@^[./]*@@')"
fi
dirName=$(echo "$dirName" | \
awk 'BEGIN{FS="";RS="/";ORS=""} {if (FNR>1) {$0=toupper(substr($0,1,1))substr($0,2)}} 1')
echo "$dirName"
#------------------------------------------------------------------------------

View File

@ -2,12 +2,13 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_adios2
@ -19,7 +20,8 @@
# ADIOS2_ARCH_PATH
#
# Functions provided
# have_adios2, no_adios2, echo_adios2
# have_adios2, no_adios2, echo_adios2, query_adios2, search_adios2
# hint_adios2
#
# Variables set on success
# HAVE_ADIOS2
@ -28,15 +30,14 @@
# ADIOS2_LIB_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_adios2()
{
unset HAVE_ADIOS2 ADIOS2_INC_DIR ADIOS2_LIB_DIR
return 0
}
@ -44,99 +45,137 @@ no_adios2()
echo_adios2()
{
echo "adios2=${HAVE_ADIOS2:-false}"
echo "root=$ADIOS2_ARCH_PATH"
echo "include=$ADIOS2_INC_DIR"
echo "library=$ADIOS2_LIB_DIR"
echo "root=\"$ADIOS2_ARCH_PATH\""
echo "include=\"$ADIOS2_INC_DIR\""
echo "library=\"$ADIOS2_LIB_DIR\""
}
# Hint for enabling
hint_adios2()
{
/bin/cat<<INFORMATION 1>&2
==> adios2 not found?
Define manually, enable in OpenFOAM etc/bashrc, or try the following [POSIX]:
eval \$(foamEtcFile -sh -config adios2 -- -force)
==
INFORMATION
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_ADIOS2, ADIOS2_INC_DIR, ADIOS2_LIB_DIR
have_adios2()
search_adios2()
{
local header library static label settings warn
# warn="==> skip adios2"
local warn # warn="==> skip adios2"
local incName="adios2.h"
local libName="libadios2"
local libName2="libadios2_cxx11_mpi"
# Basic setup/checks
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ADIOS2) || {
[ -n "$warn" ] && echo "$warn (no config.sh/ADIOS2 settings)"
local prefix="${1:-system}"
local header library
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
}
. $settings
if isNone "$ADIOS2_ARCH_PATH"
elif hasAbsdir "$prefix"
then
[ -n "$warn" ] && echo "$warn (not available)"
return 1
fi
# Header/library names
header="adios2.h"
library="libadios2$extLibso"
if hasAbsdir "$ADIOS2_ARCH_PATH"
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findFirstFile $ADIOS2_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$ADIOS2_ARCH_PATH/lib/$library \
$ADIOS2_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \
)
elif isSystem "$ADIOS2_ARCH_PATH"
then
header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
else
unset header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| library=$(findLibrary -prefix="$prefix" -name="$libName2") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
header="${header%/*}" # Strip one-level (include/adios2/...)
# ----------------------------------
# OK
export HAVE_ADIOS2=true
export ADIOS2_ARCH_PATH
export ADIOS2_ARCH_PATH="$prefix"
export ADIOS2_INC_DIR="${header%/*}" # Basename
export ADIOS2_LIB_DIR="${library%/*}" # Basename
}
# Force reset of old variables
no_adios2
# Output as per search_* function
have_adios2()
{
local warn # warn="==> skip adios2"
local config="config.sh/adios2"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
search_adios2 "$ADIOS2_ARCH_PATH"
}
# Query settings
query_adios2()
{
local config="config.sh/adios2"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query adios2 "$ADIOS2_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "adios2=unknown"
fi
}
# Testing
if [ "$1" = "-test" ]
then
have_adios2
echo_adios2
fi
#------------------------------------------------------------------------------
# Reset
no_adios2
# Test/query
case "$1" in
-test)
have_adios2
echo_adios2
;;
-query)
query_adios2
;;
-hint)
hint_adios2
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,24 +2,26 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_boost
#
# Description
# Detection/setup of Boost
# Detection/setup of BOOST
#
# Requires
# BOOST_ARCH_PATH
# or config.sh/CGAL (when BOOST_ARCH_PATH is empty)
#
# Functions provided
# have_boost, no_boost, echo_boost
# have_boost, no_boost, echo_boost, query_boost, search_boost
#
# Variables set on success
# HAVE_BOOST
@ -28,15 +30,14 @@
# BOOST_LIB_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_boost()
{
unset HAVE_BOOST BOOST_INC_DIR BOOST_LIB_DIR
return 0
}
@ -44,94 +45,124 @@ no_boost()
echo_boost()
{
echo "boost=${HAVE_BOOST:-false}"
echo "root=$BOOST_ARCH_PATH"
echo "include=$BOOST_INC_DIR"
echo "library=$BOOST_LIB_DIR"
echo "root=\"$BOOST_ARCH_PATH\""
echo "include=\"$BOOST_INC_DIR\""
echo "library=\"$BOOST_LIB_DIR\""
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_BOOST, BOOST_INC_DIR, BOOST_LIB_DIR
have_boost()
search_boost()
{
local header library static label settings warn
# warn="==> skip boost"
local warn # warn="==> skip boost"
local incName="boost/version.hpp"
local libName="libboost_system"
# Basic setup/checks
if isNone "$BOOST_ARCH_PATH"
local prefix="${1:-system}"
local header library
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (not available)"
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
fi
# Header/library names
header="boost/version.hpp"
library="libboost_system$extLibso"
if hasAbsdir "$BOOST_ARCH_PATH"
elif hasAbsdir "$prefix"
then
header=$(findFirstFile $BOOST_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$BOOST_ARCH_PATH/lib/$library \
$BOOST_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \
)
elif isSystem "$BOOST_ARCH_PATH"
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
else
unset header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
header="${header%/*}" # Strip one-level (include/boost/...)
# ----------------------------------
header="${header%/*}" # Strip one-level (include/boost/...)
# OK
export HAVE_BOOST=true
export BOOST_ARCH_PATH
export BOOST_ARCH_PATH="$prefix"
export BOOST_INC_DIR="${header%/*}" # Basename
export BOOST_LIB_DIR="${library%/*}" # Basename
}
# Force reset of old variables
no_boost
# Output as per search_* function
have_boost()
{
local warn # warn="==> skip boost"
local config="config.sh/CGAL"
local file
# Setup - current environment if set
if [ -z "$BOOST_ARCH_PATH" ]
then
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
fi
search_boost "$BOOST_ARCH_PATH"
}
# Query settings (from CGAL setup)
query_boost()
{
local config="config.sh/CGAL"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query boost "$BOOST_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "boost=unknown"
fi
}
# Testing
if [ "$1" = "-test" ]
then
have_boost
echo_boost
fi
#------------------------------------------------------------------------------
# Reset
no_boost
# Test/query
case "$1" in
-test)
have_boost
echo_boost
;;
-query)
query_boost
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,24 +2,25 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_ccmio
#
# Description
# Detection/setup of ccmio
# Detection/setup of CCMIO
#
# Requires
# config.sh/ccmio
#
# Functions provided
# have_ccmio, no_ccmio, echo_ccmio
# have_ccmio, no_ccmio, echo_ccmio, query_ccmio, search_ccmio
#
# Variables set on success
# HAVE_CCMIO
@ -28,86 +29,78 @@
# CCMIO_LIB_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_ccmio()
{
unset HAVE_CCMIO CCMIO_INC_DIR CCMIO_LIB_DIR
return 0
}
# Report
echo_ccmio()
{
echo "ccmio=${HAVE_CCMIO:-false}"
echo "root=$CCMIO_ARCH_PATH"
echo "include=$CCMIO_INC_DIR"
echo "library=$CCMIO_LIB_DIR"
echo "root=\"$CCMIO_ARCH_PATH\""
echo "include=\"$CCMIO_INC_DIR\""
echo "library=\"$CCMIO_LIB_DIR\""
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_CCMIO, CCMIO_INC_DIR, CCMIO_LIB_DIR
have_ccmio()
search_ccmio()
{
local header library static label settings warn good
warn="==> skip ccmio"
# Basic setup/checks
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio) || {
[ -n "$warn" ] && echo "$warn (no config.sh/ccmio settings)"
return 1
}
. $settings
if isNone "$CCMIO_ARCH_PATH"
then
[ -n "$warn" ] && echo "$warn (not available)"
return 1
fi
# Header/library names.
local warn="==> skip ccmio"
local incName="libccmio/ccmio.h"
local libName="libccmio.a"
# Link with static libccmio only (fewer issues)
#
header="libccmio/ccmio.h"
static="libccmio$extLiba"
local prefix="${1:-system}"
local header library
if hasAbsdir "$CCMIO_ARCH_PATH"
# ----------------------------------
if isNone "$prefix"
then
header=$(findFirstFile $CCMIO_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$CCMIO_ARCH_PATH/lib/$static \
$CCMIO_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$static \
)
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
else
unset header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
header="${header%/*}" # Strip one-level (include/libccmio/...)
# ----------------------------------
# The libccmio uses int32_t.
# The OpenFOAM adapter thus requires additional work for 64-bit labels.
# The OpenFOAM adapter was originally only designed for 'double'
local good
if [ "$WM_LABEL_SIZE" = 32 ]
then
if [ "$WM_PRECISION_OPTION" = DP ]
@ -124,21 +117,67 @@ have_ccmio()
return 1
fi
header="${header%/*}" # Strip one-level (include/libccmio/...)
# OK
export HAVE_CCMIO=true
export CCMIO_ARCH_PATH
export CCMIO_ARCH_PATH="$prefix"
export CCMIO_INC_DIR="${header%/*}" # Basename
export CCMIO_LIB_DIR="${library%/*}" # Basename
}
# Force reset of old variables
no_ccmio
# Output as per search_* function
have_ccmio()
{
local warn="==> skip ccmio"
local config="config.sh/ccmio"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
search_ccmio "$CCMIO_ARCH_PATH"
}
# Query settings
query_ccmio()
{
local config="config.sh/ccmio"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query ccmio "$CCMIO_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "ccmio=unknown"
fi
}
# Testing
if [ "$1" = "-test" ]
then
have_ccmio
echo_ccmio
fi
#------------------------------------------------------------------------------
# Reset
no_ccmio
# Test/query
case "$1" in
-test)
have_ccmio
echo_ccmio
;;
-query)
query_ccmio
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,12 +2,13 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_cgal
@ -17,121 +18,161 @@
#
# Requires
# CGAL_ARCH_PATH
# or config.sh/CGAL (when CGAL_ARCH_PATH is empty)
#
# Functions provided
# have_cgal, no_cgal, echo_cgal
# have_cgal, no_cgal, echo_cgal, query_cgal
#
# Variables set on success
# HAVE_CGAL
# CGAL_FLAVOUR (header, library, ...)
# CGAL_ARCH_PATH
# CGAL_INC_DIR
# CGAL_LIB_DIR
#
# Uses
# BOOST_ARCH_PATH and have_boost::search_boost()
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/have_boost # boost + system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_cgal()
{
unset HAVE_CGAL CGAL_INC_DIR CGAL_LIB_DIR
return 0
unset HAVE_CGAL CGAL_FLAVOUR CGAL_INC_DIR CGAL_LIB_DIR
}
# Reset variables
# Report
echo_cgal()
{
echo "cgal=${HAVE_CGAL:-false}"
echo "root=$CGAL_ARCH_PATH"
echo "include=$CGAL_INC_DIR"
echo "library=$CGAL_LIB_DIR"
echo "flavour=$CGAL_FLAVOUR"
echo "root=\"$CGAL_ARCH_PATH\""
echo "include=\"$CGAL_INC_DIR\""
echo "library=\"$CGAL_LIB_DIR\""
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_CGAL, CGAL_INC_DIR, CGAL_LIB_DIR
have_cgal()
# -> HAVE_CGAL, CGAL_INC_DIR, CGAL_LIB_DIR, CGAL_FLAVOUR
search_cgal()
{
local header library static label settings warn
# warn="==> skip cgal"
local warn # warn="==> skip cgal"
local incName="CGAL/version.h"
local libName="libCGAL"
# Basic setup/checks
if isNone "$CGAL_ARCH_PATH"
local prefix="${1:-system}"
local header library flavour
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (not available)"
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
fi
# Header/library names
header="CGAL/version.h"
library="libCGAL$extLibso"
if hasAbsdir "$CGAL_ARCH_PATH"
elif hasAbsdir "$prefix"
then
header=$(findFirstFile $CGAL_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$CGAL_ARCH_PATH/lib/$library \
$CGAL_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \
)
elif isSystem "$CGAL_ARCH_PATH"
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
else
unset header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
return 2
# Library may be optional - eg, header-only
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| {
[ -n "$warn" ] && echo "==> cgal (no library)"
unset library
flavour="header" # Header only
}
header="${header%/*}" # Strip one-level (include/CGAL/...)
# ----------------------------------
header="${header%/*}" # Strip one-level (include/CGAL/...)
# OK
export HAVE_CGAL=true
export CGAL_ARCH_PATH
export CGAL_FLAVOUR="${flavour:-library}"
export CGAL_ARCH_PATH="$prefix"
export CGAL_INC_DIR="${header%/*}" # Basename
export CGAL_LIB_DIR="${library%/*}" # Basename
}
# Force reset of old variables
no_cgal
# Output as per search_* function
have_cgal()
{
local warn # warn="==> skip cgal"
local config="config.sh/CGAL"
local file
# Setup - current environment if set
if [ -z "$CGAL_ARCH_PATH" ]
then
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
fi
# Need boost for cgal
search_boost "$BOOST_ARCH_PATH"
search_cgal "$CGAL_ARCH_PATH"
}
# Query settings (from CGAL setup)
query_cgal()
{
local config="config.sh/CGAL"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query cgal "$CGAL_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "cgal=unknown"
fi
}
# Testing
if [ "$1" = "-test" ]
then
have_cgal
echo_cgal
fi
#------------------------------------------------------------------------------
# Reset
no_cgal
# Test/query
case "$1" in
-test)
have_cgal
echo_cgal
;;
-query)
query_cgal
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,12 +2,13 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_fftw
@ -17,9 +18,10 @@
#
# Requires
# FFTW_ARCH_PATH
# or config.sh/FFTW (when FFTW_ARCH_PATH is empty)
#
# Functions provided
# have_fftw, no_fftw, echo_fftw
# have_fftw, no_fftw, echo_fftw, query_fftw, search_fftw
#
# Variables set on success
# HAVE_FFTW
@ -28,15 +30,14 @@
# FFTW_LIB_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_fftw()
{
unset HAVE_FFTW FFTW_INC_DIR FFTW_LIB_DIR
return 0
}
@ -44,95 +45,123 @@ no_fftw()
echo_fftw()
{
echo "fftw=${HAVE_FFTW:-false}"
echo "root=$FFTW_ARCH_PATH"
echo "include=$FFTW_INC_DIR"
echo "library=$FFTW_LIB_DIR"
echo "root=\"$FFTW_ARCH_PATH\""
echo "include=\"$FFTW_INC_DIR\""
echo "library=\"$FFTW_LIB_DIR\""
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_FFTW, FFTW_INC_DIR, FFTW_LIB_DIR
have_fftw()
search_fftw()
{
local header library static label settings warn
# warn="==> skip fftw"
local warn # warn="==> skip fftw"
local incName="fftw3.h"
local libName="libfftw3"
# Basic setup/checks
if isNone "$FFTW_ARCH_PATH"
local prefix="${1:-system}"
local header library
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (not available)"
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
fi
# Header/library names
header="fftw3.h"
library="libfftw3$extLibso"
static="libfftw3$extLiba"
if hasAbsdir "$FFTW_ARCH_PATH"
elif hasAbsdir "$prefix"
then
header=$(findFirstFile $FFTW_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$FFTW_ARCH_PATH/lib/$static \
$FFTW_ARCH_PATH/lib/$library \
$FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$static \
$FFTW_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \
)
elif isSystem "$FFTW_ARCH_PATH"
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
else
unset header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
# OK
export HAVE_FFTW=true
export FFTW_ARCH_PATH
export FFTW_ARCH_PATH="$prefix"
export FFTW_INC_DIR="${header%/*}" # Basename
export FFTW_LIB_DIR="${library%/*}" # Basename
}
# Force reset of old variables
no_fftw
# Output as per search_* function
have_fftw()
{
local warn # warn="==> skip fftw"
local config="config.sh/FFTW"
local file
# Setup - current environment if set
if [ -z "$FFTW_ARCH_PATH" ]
then
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
fi
search_fftw "$FFTW_ARCH_PATH"
}
# Query settings
query_fftw()
{
local config="config.sh/FFTW"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query fftw "$FFTW_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "fftw=unknown"
fi
}
# Testing
if [ "$1" = "-test" ]
then
have_fftw
echo_fftw
fi
#------------------------------------------------------------------------------
# Reset
no_fftw
# Test/query
case "$1" in
-test)
have_fftw
echo_fftw
;;
-query)
query_fftw
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,12 +2,13 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_hypre
@ -17,9 +18,11 @@
#
# Requires
# HYPRE_ARCH_PATH
# or config.sh/hypre
#
# Functions provided
# have_hypre, no_hypre, echo_hypre
# have_hypre, no_hypre, echo_hypre, query_hypre, search_hypre
# hint_hypre
#
# Variables set on success
# HAVE_HYPRE
@ -28,116 +31,157 @@
# HYPRE_LIB_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_hypre()
{
unset HAVE_HYPRE HYPRE_INC_DIR HYPRE_LIB_DIR
return 0
}
# Reset variables
# Report
echo_hypre()
{
echo "hypre=${HAVE_HYPRE:-false}"
echo "root=$HYPRE_ARCH_PATH"
echo "include=$HYPRE_INC_DIR"
echo "library=$HYPRE_LIB_DIR"
echo "root=\"$HYPRE_ARCH_PATH\""
echo "include=\"$HYPRE_INC_DIR\""
echo "library=\"$HYPRE_LIB_DIR\""
}
# Hint for enabling
hint_hypre()
{
/bin/cat<<INFORMATION 1>&2
==> hypre not found?
Define manually, enable in OpenFOAM etc/bashrc, or try the following [POSIX]:
eval \$(foamEtcFile -sh -config hypre -- -force)
==
INFORMATION
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_HYPRE, HYPRE_INC_DIR, HYPRE_LIB_DIR
have_hypre()
search_hypre()
{
local header library static label settings warn
warn="==> skip hypre"
local warn="==> skip hypre"
local incName="HYPRE.h"
local libName="libHYPRE"
# Basic setup/checks. Prefer current environment value? (TDB)
if [ ! -d "$HYPRE_ARCH_PATH" ]
local prefix="${1:-system}"
local header library
# ----------------------------------
if isNone "$prefix"
then
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/hypre) || {
[ -n "$warn" ] && echo "$warn (no config.sh/hypre settings)"
return 1
}
. $settings
fi
if isNone "$HYPRE_ARCH_PATH"
then
[ -n "$warn" ] && echo "$warn (not available)"
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
fi
# Header/library names
header="HYPRE.h"
library="libHYPRE$extLibso"
if hasAbsdir "$HYPRE_ARCH_PATH"
elif hasAbsdir "$prefix"
then
header=$(findFirstFile $HYPRE_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$HYPRE_ARCH_PATH/lib/$library \
$HYPRE_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \
)
elif isSystem "$HYPRE_ARCH_PATH"
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
else
unset header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
# OK
export HAVE_HYPRE=true
export HYPRE_ARCH_PATH
export HYPRE_ARCH_PATH="$prefix"
export HYPRE_INC_DIR="${header%/*}" # Basename
export HYPRE_LIB_DIR="${library%/*}" # Basename
}
# Force reset of old variables
no_hypre
# Output as per search_* function
have_hypre()
{
local warn="==> skip hypre"
local config="config.sh/hypre"
local file
# Setup - prefer current environment value
if [ -d "$HYPRE_ARCH_PATH" ] || [ "$HYPRE_ARCH_PATH" = system ]
then
:
else
# Use config file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
fi
search_hypre "$HYPRE_ARCH_PATH"
}
# Query settings
query_hypre()
{
local config="config.sh/hypre"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query hypre "$HYPRE_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "hypre=unknown"
fi
}
# Testing
if [ "$1" = "-test" ]
then
have_hypre
echo_hypre
fi
#------------------------------------------------------------------------------
# Reset
no_hypre
# Test/query
case "$1" in
-test)
have_hypre
echo_hypre
;;
-query)
query_hypre
;;
-hint)
hint_hypre
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,12 +2,13 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_kahip
@ -19,7 +20,7 @@
# config.sh/kahip
#
# Functions provided
# have_kahip, no_kahip, echo_kahip
# have_kahip, no_kahip, echo_kahip, query_kahip, search_kahip
#
# Variables set on success
# HAVE_KAHIP
@ -28,16 +29,15 @@
# KAHIP_LIB_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_kahip()
{
unset HAVE_KAHIP KAHIP_ARCH_PATH KAHIP_INC_DIR KAHIP_LIB_DIR
unset KAHIP_VERSION
return 0
}
@ -45,104 +45,121 @@ no_kahip()
echo_kahip()
{
echo "kahip=${HAVE_KAHIP:-false}"
echo "root=$KAHIP_ARCH_PATH"
echo "include=$KAHIP_INC_DIR"
echo "library=$KAHIP_LIB_DIR"
echo "root=\"$KAHIP_ARCH_PATH\""
echo "include=\"$KAHIP_INC_DIR\""
echo "library=\"$KAHIP_LIB_DIR\""
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_KAHIP, KAHIP_ARCH_PATH, KAHIP_INC_DIR, KAHIP_LIB_DIR
have_kahip()
search_kahip()
{
local header library static label settings warn
warn="==> skip kahip"
local warn="==> skip kahip"
local incName="kaHIP_interface.h"
local libName="libkahip"
# Basic setup/checks
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/kahip) || {
[ -n "$warn" ] && echo "$warn (no config.sh/kahip settings)"
local prefix="${1:-system}"
local header library
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
}
. $settings
if isNone "$KAHIP_ARCH_PATH"
elif hasAbsdir "$prefix"
then
[ -n "$warn" ] && echo "$warn (not available)"
return 1
fi
# Header/library names
header="kaHIP_interface.h"
library="libkahip$extLibso"
static="libkahip$extLiba"
if hasAbsdir "$KAHIP_ARCH_PATH"
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findFirstFile $KAHIP_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$KAHIP_ARCH_PATH/lib/$static \
$KAHIP_ARCH_PATH/lib/$library \
$KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$static \
$KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \
)
elif isSystem "$KAHIP_ARCH_PATH"
then
header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
else
unset header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
# kahip itself is 32-bit int, but our interface itself handles some
# kahip itself is 32-bit int, but our interface handles some
# 64-bit conversion (mesh size).
echo "kahip (label=32) - $KAHIP_ARCH_PATH"
echo "kahip (label=32) - $prefix"
export HAVE_KAHIP=true
export KAHIP_ARCH_PATH
export KAHIP_ARCH_PATH="$prefix"
export KAHIP_INC_DIR="${header%/*}" # Basename
export KAHIP_LIB_DIR="${library%/*}" # Basename
}
# Force reset of old variables
no_kahip
# Output as per search_* function
have_kahip()
{
local warn="==> skip kahip"
local config="config.sh/kahip"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 1
fi
search_kahip "$KAHIP_ARCH_PATH"
}
# Query settings
query_kahip()
{
local config="config.sh/kahip"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query kahip "$KAHIP_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "kahip=unknown"
fi
}
# Testing
if [ "$1" = "-test" ]
then
have_kahip
echo_kahip
fi
#------------------------------------------------------------------------------
# Reset
no_kahip
# Test/query
case "$1" in
-test)
have_kahip
echo_kahip
;;
-query)
query_kahip
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,24 +2,25 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_metis
#
# Description
# Detection/setup of metis
# Detection/setup of METIS
#
# Requires
# config.sh/metis
#
# Functions provided
# have_metis, no_metis, echo_metis
# have_metis, no_metis, echo_metis, query_metis, search_metis
#
# Variables set on success
# HAVE_METIS
@ -28,16 +29,15 @@
# METIS_LIB_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_metis()
{
unset HAVE_METIS METIS_ARCH_PATH METIS_INC_DIR METIS_LIB_DIR
unset METIS_VERSION
return 0
}
@ -45,117 +45,128 @@ no_metis()
echo_metis()
{
echo "metis=${HAVE_METIS:-false}"
echo "root=$METIS_ARCH_PATH"
echo "include=$METIS_INC_DIR"
echo "library=$METIS_LIB_DIR"
echo "root=\"$METIS_ARCH_PATH\""
echo "include=\"$METIS_INC_DIR\""
echo "library=\"$METIS_LIB_DIR\""
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_METIS, METIS_ARCH_PATH, METIS_INC_DIR, METIS_LIB_DIR
have_metis()
search_metis()
{
local header library static label settings warn
warn="==> skip metis"
local warn="==> skip metis"
local incName="metis.h"
local libName="libmetis"
# Basic setup/checks
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/metis) || {
[ -n "$warn" ] && echo "$warn (no config.sh/metis settings)"
local prefix="${1:-system}"
local header library
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
}
. $settings
if isNone "$METIS_ARCH_PATH"
elif hasAbsdir "$prefix"
then
[ -n "$warn" ] && echo "$warn (not available)"
return 1
fi
# Header/library names
header="metis.h"
library="libmetis$extLibso"
static="libmetis$extLiba"
if hasAbsdir "$METIS_ARCH_PATH"
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findFirstFile $METIS_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$METIS_ARCH_PATH/lib/$static \
$METIS_ARCH_PATH/lib/$library \
$METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$static \
$METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \
)
elif isSystem "$METIS_ARCH_PATH"
then
header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
else
unset header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
local label
# Ensure consistent sizes between OpenFOAM and metis header
# Extract IDXTYPEWIDTH from metis.h: regex as per ThirdParty Allwmake
label=$(sed -ne 's/^.*#define *IDXTYPEWIDTH *\([1-9][0-9]\).*/\1/p' $header)
: ${label:=unknown}
label=$(sed -ne \
's/^.*#define *IDXTYPEWIDTH *\([1-9][0-9]\).*/\1/p' \
"$header")
: "${label:=unknown}"
if [ "$WM_LABEL_SIZE" = "$label" ]
# OK
echo "metis (label=$label) - $prefix"
export HAVE_METIS=true
export METIS_ARCH_PATH="$prefix"
export METIS_INC_DIR="${header%/*}" # Basename
export METIS_LIB_DIR="${library%/*}" # Basename
}
# Output as per search_* function
have_metis()
{
local warn="==> skip metis"
local config="config.sh/metis"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
echo "Metis (label=$label) - $METIS_ARCH_PATH"
export HAVE_METIS=true
export METIS_ARCH_PATH
export METIS_INC_DIR="${header%/*}" # Basename
export METIS_LIB_DIR="${library%/*}" # Basename
. "$file"
else
if [ -n "$warn" ]
then
echo "$warn (label=$WM_LABEL_SIZE, metis.h has '$label')"
fi
no_metis
return 1
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
search_metis "$METIS_ARCH_PATH"
}
# Query settings
query_metis()
{
local config="config.sh/metis"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query metis "$METIS_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "metis=unknown"
fi
}
# Force reset of old variables
#------------------------------------------------------------------------------
# Reset variables
no_metis
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_metis
echo_metis
fi
;;
-query)
query_metis
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,24 +2,25 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_mgridgen
#
# Description
# Detection/setup of mgridgen
# Detection/setup of MGRIDGEN
#
# Requires
# config.sh/mgridgen
#
# Functions provided
# have_mgridgen, no_mgridgen, echo_mgridgen
# have_mgridgen, no_mgridgen, echo_mgridgen, query_mgridgen, search_mgridgen
#
# Variables set on success
# HAVE_MGRIDGEN
@ -28,16 +29,15 @@
# MGRIDGEN_LIB_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_mgridgen()
{
unset HAVE_MGRIDGEN MGRIDGEN_ARCH_PATH MGRIDGEN_INC_DIR MGRIDGEN_LIB_DIR
unset MGRIDGEN_VERSION
return 0
}
@ -45,85 +45,63 @@ no_mgridgen()
echo_mgridgen()
{
echo "mgridgen=${HAVE_MGRIDGEN:-false}"
echo "root=$MGRIDGEN_ARCH_PATH"
echo "include=$MGRIDGEN_INC_DIR"
echo "library=$MGRIDGEN_LIB_DIR"
echo "root=\"$MGRIDGEN_ARCH_PATH\""
echo "include=\"$MGRIDGEN_INC_DIR\""
echo "library=\"$MGRIDGEN_LIB_DIR\""
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_MGRIDGEN, MGRIDGEN_ARCH_PATH, MGRIDGEN_INC_DIR, MGRIDGEN_LIB_DIR
have_mgridgen()
search_mgridgen()
{
local header library static label scalar settings warn good
warn="==> skip mgridgen"
local warn="==> skip mgridgen"
local incName="mgridgen.h"
local libName="libMGridGen"
local libName2="libmgrid"
# Basic setup/checks
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mgridgen) || {
#silent# [ -n "$warn" ] && echo "$warn (no config.sh/mgridgen settings)"
local prefix="${1:-system}"
local header library
# ----------------------------------
if isNone "$prefix"
then
#silent# [ -n "$warn" ] && echo "$warn (disabled)"
return 1
}
. $settings
if isNone "$MGRIDGEN_ARCH_PATH"
elif hasAbsdir "$prefix"
then
#silent# [ -n "$warn" ] && echo "$warn (not available)"
return 1
fi
# Header/library names
header="mgridgen.h"
library="libMGridGen$extLibso"
static="libmgrid$extLiba"
if hasAbsdir "$MGRIDGEN_ARCH_PATH"
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName" "$libName2")
elif isSystem "$prefix"
then
header=$(findFirstFile $MGRIDGEN_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$MGRIDGEN_ARCH_PATH/lib/$static \
$MGRIDGEN_ARCH_PATH/lib/$library \
$MGRIDGEN_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$static \
$MGRIDGEN_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \
)
elif isSystem "$MGRIDGEN_ARCH_PATH"
then
header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
else
unset header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
#silent# [ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
#silent# [ -n "$warn" ] && echo "$warn (missing library)"
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| library=$(findLibrary -prefix="$prefix" -name="$libName2") \
|| {
#silent# [ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
local label scalar
# Ensure consistent sizes with OpenFOAM and mgridgen header
# Extract typedef for idxtype, realtype
@ -134,54 +112,96 @@ have_mgridgen()
's/^.*typedef *\([^ ]*\) *realtype.*/\1/ip' \
"$header")
: ${label:=unknown}
: ${scalar:=unknown}
: "${label:=unknown}"
: "${scalar:=unknown}"
case "$WM_LABEL_SIZE:$label" in
(32:int32_t | 32:int | 64:int64_t | 64:long)
good=true
;;
*)
(*)
if [ -n "$warn" ]
then
echo "$warn (label='$WM_LABEL_SIZE', mgridgen.h has '$label')"
echo "$warn (label='$WM_LABEL_SIZE', ${header##*/} has '$label')"
fi
no_mgridgen
return 1
;;
esac
case "$WM_PRECISION_OPTION:$scalar" in
(SP:float | DP:double)
good=true
(SP:float | SPDP:float | DP:double)
;;
*)
(*)
if [ -n "$warn" ]
then
echo "$warn (scalar='$WM_PRECISION_OPTION', mgridgen.h has '$scalar')"
echo "$warn (scalar='$WM_PRECISION_OPTION', ${header##*/} has '$scalar')"
fi
no_mgridgen
return 1
;;
esac
# OK
echo "mgridgen (label=$label, scalar=$scalar) - $MGRIDGEN_ARCH_PATH"
echo "mgridgen (label=$label, scalar=$scalar) - $prefix"
export HAVE_MGRIDGEN=true
export MGRIDGEN_ARCH_PATH MGRIDGEN_VERSION
export MGRIDGEN_ARCH_PATH="$prefix"
export MGRIDGEN_INC_DIR="${header%/*}" # Basename
export MGRIDGEN_LIB_DIR="${library%/*}" # Basename
export MGRIDGEN_VERSION
}
# Force reset of old variables
no_mgridgen
# Output as per search_* function
have_mgridgen()
{
local warn="==> skip mgridgen"
local config="config.sh/mgridgen"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
#silent# [ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
search_mgridgen "$MGRIDGEN_ARCH_PATH"
}
# Query settings
query_mgridgen()
{
local config="config.sh/mgridgen"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query mgridgen "$MGRIDGEN_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "mgridgen=unknown"
fi
}
# Testing
if [ "$1" = "-test" ]
then
have_mgridgen
echo_mgridgen
fi
#------------------------------------------------------------------------------
# Reset
no_mgridgen
# Test/query
case "$1" in
-test)
have_mgridgen
echo_mgridgen
;;
-query)
query_mgridgen
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,12 +2,13 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_petsc
@ -17,9 +18,12 @@
#
# Requires
# PETSC_ARCH_PATH
# or PETSC_DIR, PETSC_ARCH
# or config.sh/petsc
#
# Functions provided
# have_petsc, no_petsc, echo_petsc
# have_petsc, no_petsc, echo_petsc, query_petsc, search_petsc
# hint_petsc
#
# Variables set on success
# HAVE_PETSC
@ -28,25 +32,141 @@
# PETSC_LIB_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_petsc()
{
unset HAVE_PETSC PETSC_INC_DIR PETSC_LIB_DIR
return 0
}
# Reset variables
# Report
echo_petsc()
{
echo "petsc=${HAVE_PETSC:-false}"
echo "root=$PETSC_ARCH_PATH"
echo "include=$PETSC_INC_DIR"
echo "library=$PETSC_LIB_DIR"
echo "root=\"$PETSC_ARCH_PATH\""
echo "include=\"$PETSC_INC_DIR\""
echo "library=\"$PETSC_LIB_DIR\""
}
# Hint for enabling
hint_petsc()
{
/bin/cat<<INFORMATION 1>&2
==> petsc not found?
Define manually, enable in OpenFOAM etc/bashrc, or try the following [POSIX]:
eval \$(foamEtcFile -sh -config petsc -- -force)
==
INFORMATION
}
# On success, return 0 and export variables
# -> HAVE_PETSC, PETSC_INC_DIR, PETSC_LIB_DIR
#
# $1 = prefix (eg, PETSC_DIR, PETSC_ARCH_PATH)
# $2 = [arch] (eg, PETSC_ARCH)
#
# Gets ugly with in-source installation.
# 1) In the simple case, petsc is installed with --prefix
# we find PREFIX/{include,lib}
#
# 2) With in-source installation,
# headers in PETSC_DIR/include and PETSC_DIR/PETSC_ARCH/include
# library is PETSC_DIR/PETSC_ARCH/lib*
search_petsc()
{
local warn="==> skip petsc"
local incName="petsc.h"
local libName="libpetsc"
local pkgName="PETSc"
local prefix="${1:-system}"
local arch="$2"
local header library includeDirs libraryDirs
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
# No system header, attempt discovery with pkg-config
if [ -z "$header" ] && pkg-config --exists "$pkgName" 2>/dev/null
then
includeDirs=$(pkg-config --cflags-only-I "$pkgName" | sed -e 's/^-[IL]//; s/[ ]-[IL]/ /;')
libraryDirs=$(pkg-config --libs-only-L "$pkgName" | sed -e 's/^-[IL]//; s/[ ]-[IL]/ /;')
prefix="${includeDirs% *}" # First entry (ie, split on space)
prefix="${prefix%/*}" # Basename
fi
else
unset prefix
fi
# ----------------------------------
# Header -> directory
if [ -z "$includeDirs" ]
then
includeDirs="${header%/*}" # Basename
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
fi
# Library -> directory
if [ -z "$libraryDirs" ]
then
if [ -n "$arch" ] && [ -d "$prefix/$arch" ]
then
# Prepend with petsc-arch/include
if [ -d "$prefix/$arch/include" ]
then
includeDirs="$prefix/$arch/include${includeDirs:+ }$includeDirs"
fi
# Prefer with petsc-arch/lib
if [ -z "$library" ]
then
library=$(findLibrary -prefix="$prefix/$arch" -name="$libName")
fi
fi
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
libraryDirs="${library%/*}" # Basename
fi
# ----------------------------------
# TODO: check size of petsc integer vs label, real vs double?
# OK
export HAVE_PETSC=true
export PETSC_ARCH_PATH="$prefix"
export PETSC_INC_DIR="$includeDirs"
export PETSC_LIB_DIR="$libraryDirs"
}
@ -54,90 +174,69 @@ echo_petsc()
# -> HAVE_PETSC, PETSC_INC_DIR, PETSC_LIB_DIR
have_petsc()
{
local header library static label settings warn
warn="==> skip petsc"
local warn="==> skip petsc"
local config="config.sh/petsc"
local file
# Basic setup/checks. Prefer current environment value? (TDB)
if [ ! -d "$PETSC_ARCH_PATH" ]
# Setup - prefer current environment value
if [ -d "$PETSC_ARCH_PATH" ] || [ "$PETSC_ARCH_PATH" = system ]
then
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/petsc) || {
[ -n "$warn" ] && echo "$warn (no config.sh/petsc settings)"
return 1
}
. $settings
fi
if isNone "$PETSC_ARCH_PATH"
# OpenFOAM prefix naming, possibly with petsc-arch
search_petsc "$PETSC_ARCH_PATH" $PETSC_ARCH
elif [ -d "$PETSC_DIR" ]
then
[ -n "$warn" ] && echo "$warn (not available)"
return 1
fi
# petsc-dir, petsc-arch naming
search_petsc "$PETSC_DIR" $PETSC_ARCH
# Header/library names
header="petsc.h"
library="libpetsc$extLibso"
if hasAbsdir "$PETSC_ARCH_PATH"
then
header=$(findFirstFile $PETSC_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$PETSC_ARCH_PATH/lib/$library \
$PETSC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \
)
elif isSystem "$PETSC_ARCH_PATH"
then
header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
else
unset header library
# Use config file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
search_petsc "$PETSC_ARCH_PATH"
fi
# Header found?
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
return 2
}
export HAVE_PETSC=true
export PETSC_ARCH_PATH
export PETSC_INC_DIR="${header%/*}" # Basename
export PETSC_LIB_DIR="${library%/*}" # Basename
}
# Force reset of old variables
no_petsc
# Query settings
query_petsc()
{
local config="config.sh/petsc"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query petsc "$PETSC_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "petsc=unknown"
fi
}
# Testing
if [ "$1" = "-test" ]
then
have_petsc
echo_petsc
fi
#------------------------------------------------------------------------------
# Reset
no_petsc
# Test/query
case "$1" in
-test)
have_petsc
echo_petsc
;;
-query)
query_petsc
;;
-hint)
hint_petsc
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,24 +2,25 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_readline
#
# Description
# Detection/setup of readline
# Detection/setup of READLINE
#
# Requires
# None
#
# Functions provided
# have_readline, no_readline, echo_readline
# have_readline, no_readline, echo_readline, search_readline
#
# Variables set on success
# HAVE_LIBREADLINE - as per GNU autoconf
@ -27,15 +28,14 @@
# READLINE_LIB_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_readline()
{
unset HAVE_LIBREADLINE READLINE_INC_DIR READLINE_LIB_DIR
return 0
}
@ -43,70 +43,86 @@ no_readline()
echo_readline()
{
echo "readline=${HAVE_LIBREADLINE:-false}"
echo "include=$READLINE_INC_DIR"
echo "library=$READLINE_LIB_DIR"
echo "include=\"$READLINE_INC_DIR\""
echo "library=\"$READLINE_LIB_DIR\""
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_LIBREADLINE, READLINE_INC_DIR, READLINE_LIB_DIR
have_readline()
search_readline()
{
local header library static settings warn
# warn="==> skip readline"
local warn # warn="==> skip readline"
local incName="readline/readline.h"
local libName="libreadline"
local prefix="${1:-system}"
local header library
# Header/library names
header="readline/readline.h"
library="libreadline$extLibso"
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
else
unset prefix
fi
# ----------------------------------
# System only?
header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
header="${header%/*}" # Strip one-level (include/readline/...)
# ----------------------------------
header="${header%/*}" # Strip one-level (include/readline/...)
# OK
export HAVE_LIBREADLINE=true
export READLINE_INC_DIR="${header%/*}" # Basename
export READLINE_LIB_DIR="${library%/*}" # Basename
}
# Force reset of old variables
no_readline
# Output as per search_* function
have_readline()
{
search_readline system
}
# Testing
if [ "$1" = "-test" ]
then
have_readline
echo_readline
fi
#------------------------------------------------------------------------------
# Reset
no_readline
# Test/query
case "$1" in
-test)
have_readline
echo_readline
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,24 +2,25 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_scotch
#
# Description
# Detection/setup of scotch
# Detection/setup of SCOTCH
#
# Requires
# config.sh/scotch
#
# Functions provided
# have_scotch, no_scotch, echo_scotch
# have_ptscotch, search_ptscotch
#
# Variables set on success
# HAVE_SCOTCH
@ -27,17 +28,67 @@
# SCOTCH_INC_DIR
# SCOTCH_LIB_DIR
#
# Functions provided [Must call have_scotch first]
# have_ptscotch, search_ptscotch
#
# Variables set on success
# HAVE_PTSCOTCH
# PTSCOTCH_ARCH_PATH
# PTSCOTCH_INC_DIR
# PTSCOTCH_LIB_DIR
#
#
# System files can be hiding in a large variety of locations
#
# ArchLinux
# ---------
# scotch include=/usr/include/ptscotch
#
# ptscotch include=/usr/include/ptscotch
#
#
# Debian/Ubuntu
# -------------
# scotch include=/usr/include/scotch-int32
# scotch library=/usr/lib/x86_64-linux-gnu
#
# ptscotch include=/usr/include/scotch-int32
# ptscotch library=/usr/lib/x86_64-linux-gnu
#
#
# RedHat
# ------
# scotch include=/usr/include
# scotch library=/usr/lib64
#
# ptscotch include=/usr/include/openmpi-x86_64
# ptscotch library=/usr/lib64/openmpi/lib
#
# when MPI_ARCH_PATH=/usr/lib64/openmpi
# and mpicc --showme:compile -> -I/usr/include/openmpi-x86_64
#
#
# openSUSE
# --------
# scotch include=/usr/include
# scotch library=/usr/lib64
#
# ptscotch include=/usr/lib64/mpi/gcc/openmpi2/include
# ptscotch library=/usr/lib64/mpi/gcc/openmpi2/lib64
#
# when MPI_ARCH_PATH=/usr/lib64/mpi/gcc/openmpi2
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_scotch()
{
unset HAVE_SCOTCH SCOTCH_ARCH_PATH SCOTCH_INC_DIR SCOTCH_LIB_DIR
unset SCOTCH_VERSION
return 0
unset HAVE_PTSCOTCH PTSCOTCH_ARCH_PATH PTSCOTCH_INC_DIR PTSCOTCH_LIB_DIR
}
@ -45,97 +96,86 @@ no_scotch()
echo_scotch()
{
echo "scotch=${HAVE_SCOTCH:-false}"
echo "root=$SCOTCH_ARCH_PATH"
echo "include=$SCOTCH_INC_DIR"
echo "library=$SCOTCH_LIB_DIR"
echo "root=\"$SCOTCH_ARCH_PATH\""
echo "include=\"$SCOTCH_INC_DIR\""
echo "library=\"$SCOTCH_LIB_DIR\""
echo
echo "ptscotch=${HAVE_PTSCOTCH:-false}"
echo "root=\"$PTSCOTCH_ARCH_PATH\""
echo "include=\"$PTSCOTCH_INC_DIR\""
echo "library=\"$PTSCOTCH_LIB_DIR\""
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_SCOTCH, SCOTCH_ARCH_PATH, SCOTCH_INC_DIR, SCOTCH_LIB_DIR
have_scotch()
search_scotch()
{
local header library static label settings warn
warn="==> skip scotch"
local warn="==> skip scotch"
local incName="scotch.h"
local libName="libscotch"
local localDir="scotch-int$WM_LABEL_SIZE"
# Basic setup/checks
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch) || {
[ -n "$warn" ] && echo "$warn (no config.sh/scotch settings)"
return 1
}
. $settings
if isNone "$SCOTCH_ARCH_PATH"
local prefix="${1:-system}"
local header library
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (not available)"
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
fi
# Header/library names
header="scotch.h"
library="libscotch$extLibso"
static="libscotch$extLiba"
if hasAbsdir "$SCOTCH_ARCH_PATH"
then
header=$(findFirstFile $SCOTCH_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$SCOTCH_ARCH_PATH/lib/$static \
$SCOTCH_ARCH_PATH/lib/$library \
$SCOTCH_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$static \
$SCOTCH_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \
)
elif isSystem "$SCOTCH_ARCH_PATH"
elif hasAbsdir "$prefix"
then
header=$(findFirstFile \
/usr/local/include/$header \
/usr/local/include/scotch/$header \
/usr/include/$header \
/usr/include/scotch/$header \
"$prefix/include/$localDir/$incName" \
"$prefix/include/scotch/$incName" \
"$prefix/include/$incName" \
)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findFirstFile \
"/usr/local/include/$localDir/$incName" \
"/usr/local/include/scotch/$incName" \
"/usr/local/include/$incName" \
"/usr/include/$localDir/$incName" \
"/usr/include/scotch/$incName" \
"/usr/include/$incName" \
)
prefix=$(sysPrefix "$header")
else
unset header library
unset prefix
fi
# ----------------------------------
equalBaseName "${header%/*}" "$localDir" || unset localDir
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName" -local="$localDir") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
local label
# Ensure consistent sizes between OpenFOAM and scotch header
# extract 'typedef int64_t SCOTCH_Num' or equivalent
label=$(sed -ne \
's/^.*typedef *\([^ ]*\) *SCOTCH_Num.*/\1/p' \
"$header")
: ${label:=unknown} # Failsafe value
: "${label:=unknown}"
# No SCOTCH_VERSION set? Try to obtain from header
@ -152,38 +192,184 @@ have_scotch()
IFS="."
[ "$#" -gt 0 ] && echo "scotch-$*"
)
: ${SCOTCH_VERSION:=scotch} # Failsafe value
: "${SCOTCH_VERSION:=scotch}" # Failsafe value
case "$WM_LABEL_SIZE:$label" in
(32:int32_t | 32:int | 64:int64_t | 64:long)
echo "Scotch (label=$label) - $SCOTCH_ARCH_PATH"
export HAVE_SCOTCH=true
export SCOTCH_ARCH_PATH SCOTCH_VERSION
export SCOTCH_INC_DIR="${header%/*}" # Basename
export SCOTCH_LIB_DIR="${library%/*}" # Basename
;;
*)
(*)
if [ -n "$warn" ]
then
echo "$warn (label='$WM_LABEL_SIZE', scotch.h has '$label')"
echo "$warn (label='$WM_LABEL_SIZE', ${header##*/} has '$label')"
fi
no_scotch
return 1
;;
esac
# OK
echo "scotch (label=$label) - $prefix"
export HAVE_SCOTCH=true
export SCOTCH_ARCH_PATH="$prefix"
export SCOTCH_INC_DIR="${header%/*}" # Basename
export SCOTCH_LIB_DIR="${library%/*}" # Basename
export SCOTCH_VERSION
}
# Force reset of old variables
no_scotch
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_PTSCOTCH, PTSCOTCH_ARCH_PATH, PTSCOTCH_INC_DIR, PTSCOTCH_LIB_DIR
search_ptscotch()
{
local warn="==> skip ptscotch"
local incName="ptscotch.h"
local libName="libptscotch"
local localDir="scotch-int$WM_LABEL_SIZE"
local prefix="${1:-system}"
local header library
local mpiPrefix="$MPI_ARCH_PATH"
local mpiName="${MPI_ARCH_PATH##*/}"
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile \
"$prefix/include/$FOAM_MPI/$incName" \
"$prefix/include/$localDir/$incName" \
"$prefix/include/ptscotch/$incName" \
"$prefix/include/scotch/$incName" \
"$prefix/include/$incName" \
"$mpiPrefix/include/$incName" \
"$prefix/include/$mpiName/$incName" \
"$prefix/include/${mpiName}-$(uname -m)/$incName" \
)
library="$(findExtLib $FOAM_MPI/$libName $libName)"
elif isSystem "$prefix"
then
header=$(findFirstFile \
"/usr/local/include/$localDir/$incName" \
"/usr/local/include/ptscotch/$incName" \
"/usr/local/include/scotch/$incName" \
"/usr/local/include/$incName" \
"/usr/include/$localDir/$incName" \
"/usr/include/ptscotch/$incName" \
"/usr/include/scotch/$incName" \
"/usr/include/$incName" \
"$mpiPrefix/include/$incName" \
"/usr/include/$mpiName/$incName" \
"$prefix/include/${mpiName}-$(uname -m)/$incName" \
)
prefix=$(sysPrefix "$header")
else
unset prefix
fi
# ----------------------------------
equalBaseName "${header%/*}" "$localDir" || unset localDir
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName" -local="$localDir") \
|| library=$(findLibrary -prefix="$mpiPrefix" -name="$libName" -local="$localDir") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
# OK
echo "ptscotch - $prefix"
export HAVE_PTSCOTCH=true
export PTSCOTCH_ARCH_PATH="$prefix"
export PTSCOTCH_INC_DIR="${header%/*}" # Basename
export PTSCOTCH_LIB_DIR="${library%/*}" # Basename
}
# Output as per search_* function
have_scotch()
{
local warn="==> skip scotch"
local config="config.sh/scotch"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
search_scotch "$SCOTCH_ARCH_PATH"
}
# Output as per search_* function
have_ptscotch()
{
local warn="==> skip ptscotch"
if [ "$HAVE_SCOTCH" != true ]
then
echo "$warn (no serial scotch available?)"
return 1
fi
# Reuse old settings
[ -n "$PTSCOTCH_ARCH_PATH" ] || PTSCOTCH_ARCH_PATH="$SCOTCH_ARCH_PATH"
search_ptscotch "$PTSCOTCH_ARCH_PATH"
}
# Query settings
query_scotch()
{
local config="config.sh/scotch"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query scotch "$SCOTCH_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "scotch=unknown"
fi
}
# Testing
if [ "$1" = "-test" ]
then
have_scotch
echo_scotch
fi
#------------------------------------------------------------------------------
# Reset
no_scotch
# Test/query
case "$1" in
-test)
have_scotch && have_ptscotch
echo_scotch
;;
-query)
query_scotch
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,24 +2,25 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_zoltan
#
# Description
# Detection/setup of zoltan
# Detection/setup of ZOLTAN
#
# Requires
# config.sh/zoltan
#
# Functions provided
# have_zoltan, no_zoltan, echo_zoltan
# have_zoltan, no_zoltan, echo_zoltan, query_zoltan, search_zoltan
#
# Variables set on success
# HAVE_ZOLTAN
@ -28,15 +29,14 @@
# ZOLTAN_LIB_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
#------------------------------------------------------------------------------
# Reset variables
# Reset
no_zoltan()
{
unset HAVE_ZOLTAN ZOLTAN_INC_DIR ZOLTAN_LIB_DIR
return 0
}
@ -44,100 +44,118 @@ no_zoltan()
echo_zoltan()
{
echo "zoltan=${HAVE_ZOLTAN:-false}"
echo "root=$ZOLTAN_ARCH_PATH"
echo "include=$ZOLTAN_INC_DIR"
echo "library=$ZOLTAN_LIB_DIR"
echo "root=\"$ZOLTAN_ARCH_PATH\""
echo "include=\"$ZOLTAN_INC_DIR\""
echo "library=\"$ZOLTAN_LIB_DIR\""
}
# Search
# $1 : prefix (*_ARCH_PATH, system, ...)
#
# On success, return 0 and export variables
# -> HAVE_ZOLTAN, ZOLTAN_INC_DIR, ZOLTAN_LIB_DIR
have_zoltan()
search_zoltan()
{
local header library static label settings warn
# warn="==> skip zoltan"
local warn # warn="==> skip zoltan"
local incName="zoltan.h"
local libName="libzoltan"
# Basic setup/checks
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/zoltan) || {
[ -n "$warn" ] && echo "$warn (no config.sh/zoltan settings)"
local prefix="${1:-system}"
local header library
# ----------------------------------
if isNone "$prefix"
then
[ -n "$warn" ] && echo "$warn (disabled)"
return 1
}
. $settings
if isNone "$ZOLTAN_ARCH_PATH"
elif hasAbsdir "$prefix"
then
[ -n "$warn" ] && echo "$warn (not available)"
return 1
fi
# Header/library names
header="zoltan.h"
library="libzoltan$extLibso"
static="libzoltan$extLiba"
if hasAbsdir "$ZOLTAN_ARCH_PATH"
header=$(findFirstFile "$prefix/include/$incName")
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findFirstFile $ZOLTAN_ARCH_PATH/include/$header)
library=$(findFirstFile \
"$(thirdExtLib $library)" \
$ZOLTAN_ARCH_PATH/lib/$static \
$ZOLTAN_ARCH_PATH/lib/$library \
$ZOLTAN_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$static \
$ZOLTAN_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/$library \
)
elif isSystem "$ZOLTAN_ARCH_PATH"
then
header=$(findFirstFile /usr/local/include/$header /usr/include/$header)
case "$header" in
/usr/local/*)
library=$(findFirstFile \
/usr/local/lib/$library \
/usr/local/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
*)
library=$(findFirstFile \
/usr/lib/$library \
/usr/lib$WM_COMPILER_LIB_ARCH/$library \
)
;;
esac
header=$(findSystemInclude -name="$incName")
prefix=$(sysPrefix "$header")
else
unset header library
unset prefix
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# Library found?
[ -n "$library" ] || {
[ -n "$warn" ] && echo "$warn (missing library)"
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
}
# ----------------------------------
# OK
export HAVE_ZOLTAN=true
export ZOLTAN_ARCH_PATH
export ZOLTAN_ARCH_PATH="$prefix"
export ZOLTAN_INC_DIR="${header%/*}" # Basename
export ZOLTAN_LIB_DIR="${library%/*}" # Basename
}
# Force reset of old variables
no_zoltan
# Output as per search_* function
have_zoltan()
{
local warn # warn="==> skip zoltan"
local config="config.sh/zoltan"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$file"
else
[ -n "$warn" ] && echo "$warn (no $config)"
return 2
fi
search_zoltan "$ZOLTAN_ARCH_PATH"
}
# Query settings
query_zoltan()
{
local config="config.sh/zoltan"
local file
if file="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$file"
_process_query zoltan "$ZOLTAN_ARCH_PATH"
else
echo "(no $config)" 1>&2
echo "zoltan=unknown"
fi
}
# Testing
if [ "$1" = "-test" ]
then
have_zoltan
echo_zoltan
fi
#------------------------------------------------------------------------------
# Reset
no_zoltan
# Test/query
case "$1" in
-test)
have_zoltan
echo_zoltan
;;
-query)
query_zoltan
;;
esac
#------------------------------------------------------------------------------

View File

@ -3,9 +3,11 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.

View File

@ -3,9 +3,11 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
@ -31,7 +33,7 @@
# Usage : makeFiles
#
#------------------------------------------------------------------------------
dirToString="$WM_DIR/platforms/$WM_ARCH$WM_COMPILER"/dirToString
dirToString="$WM_DIR/scripts/dirToString"
if [ -r Make/files ]
then
@ -46,8 +48,10 @@ fi
[ -d Make ] || mkdir Make
rm -f Make/files
#------------------------------------------------------------------------------
echo "Creating Make/files"
echo "Creating Make/files ..."
for dir in $(find . -mindepth 1 -type d -print)
do
@ -56,7 +60,7 @@ do
# Skip special directories
;;
*)
echo "$(echo $dir | $dirToString -strip) = ${dir#./}"
echo "$($dirToString "$dir") = ${dir#./}"
;;
esac
done > Make/files
@ -64,11 +68,11 @@ done > Make/files
for file in $(find . -name "*.[cCylLfF]" -type f -print)
do
pathName=$(echo ${file%/*} | $dirToString -strip)
pathName="$($dirToString "${file%/*}")"
if [ -n "$pathName" ]
then
echo '$('$pathName')/'"${file##*/}"
echo '$('"$pathName"')/'"${file##*/}"
else
echo "${file##*/}"
fi

View File

@ -3,9 +3,11 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
@ -40,7 +42,9 @@ fi
[ -d Make ] || mkdir Make
rm -f Make/options
#------------------------------------------------------------------------------
echo "Creating Make/options"
echo 'EXE_INC = \

View File

@ -3,9 +3,11 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.

View File

@ -2,12 +2,13 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# paraviewFunctions
@ -17,12 +18,12 @@
# Setup of variables for creating ParaView plugins
#
# Requires
# ParaView_DIR (unless system)
# PV_PLUGIN_PATH
# ParaView_DIR (unless system)
# PV_PLUGIN_PATH (or rely on automatic mechanism)
#
# Provides Functions
# have_pvplugin_support, no_paraview, echo_paraview
# cmakeVtk, cmakePv
# get_pvplugin_api, have_pvplugin_support, no_paraview, echo_paraview
# cmakeVtk, cmakePv, cmakePvInstall
#
# Variables on success
# HAVE_PVPLUGIN_SUPPORT
@ -35,8 +36,8 @@
# paraview-major.minor encoded in its name.
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/wmake/scripts/sysFunctions # General system functions
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions # Require cmake functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions
. ${WM_PROJECT_DIR:?}/wmake/scripts/cmakeFunctions # Require cmake functions
#------------------------------------------------------------------------------
@ -45,7 +46,6 @@ no_paraview()
{
unset HAVE_PVPLUGIN_SUPPORT FOAM_PV_PLUGIN_LIBBIN
unset PARAVIEW_API PARAVIEW_INC_DIR
return 0
}
@ -53,42 +53,123 @@ no_paraview()
echo_paraview()
{
echo "paraview=${HAVE_PVPLUGIN_SUPPORT:-false}"
echo "root=$ParaView_DIR"
echo "include=$PARAVIEW_INC_DIR"
echo "plugin=$FOAM_PV_PLUGIN_LIBBIN"
echo "root=\"$ParaView_DIR\""
echo "include=\"$PARAVIEW_INC_DIR\""
echo "plugin=\"$FOAM_PV_PLUGIN_LIBBIN\""
echo "api=$PARAVIEW_API"
}
# CMake into objectsDir with VTK_DIR dependency
# 1 - sourceDir
# 2.. optional cmake defines
cmakeVtk()
{
cmakeVersioned "VTK_DIR=$VTK_DIR" "$1"
cmakeVersioned "VTK_DIR=$VTK_DIR" "$@"
}
# CMake into objectsDir with ParaView_DIR dependency
# 1 - sourceDir
# 2.. optional cmake defines
cmakePv()
{
cmakeVersioned "ParaView_DIR=$ParaView_DIR" "$1"
cmakeVersioned "ParaView_DIR=$ParaView_DIR" "$@"
}
#
# CMake into objectsDir with ParaView_DIR dependency
# 1 - sourceDir
# 2.. optional cmake defines
cmakePvInstall()
{
cmakeVersionedInstall "ParaView_DIR=$ParaView_DIR" "$@"
}
# Build library - use sentinel file(s) to handle paraview version changes
# Some difficulty handling different installation options as well
# as wmake options, so only handle build/configure information for now
#
# 1 - libName
# 2... build/configure information
#
# Similar to wmakeVersioned
wmakeLibPv()
{
local depend="ParaView_DIR=$ParaView_DIR"
local libName="$1"
shift 1
local sentinel
for libName
do
sentinel=$(sameDependency "$depend" $libName) || \
wclean $libName
sentinel=$(sameDependency "$libName" "$depend" $@) || \
wclean "$libName"
wmake $targetType $libName \
&& echo "$depend" > ${sentinel:-/dev/null}
done
wmake $targetType "$libName" \
&& storeDependency "$sentinel" "$depend" $@
}
# Get ParaView API from given path.
# Eg, "/path/paraview-dir/paraview-5.6" -> "5.6"
#
# Or the output from `paraview --version`
# Eg, "paraview version 5.6.3" -> "5.6"
#
# 1 - the input path ending with paraview-x.y, or paraview --version information
#
# On success, return 0 and echo value
#
get_pvapi()
{
local pv_api
# Extract paraview major+minor version from the directory name
# From /path/paraview-5.6 -> 5.6
pv_api=$(echo "${1:-none}" | \
sed -ne 's@^.*/@@;s@^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$@\1@p')
if [ -z "$pv_api" ]
then
# Extract paraview major+minor version from "paraview --version" information
pv_api=$(echo "${1:-none}" | \
sed -ne 's@^.*version *\([0-9][0-9]*\.[0-9][0-9]*\).*$@\1@p')
fi
[ -n "$pv_api" ] || return 1
# OK
echo "$pv_api"
}
# Extract ParaView plugin api number from PV_PLUGIN_PATH
# On success, return 0 and export variables
# -> FOAM_PV_PLUGIN_LIBBIN, PARAVIEW_API
#
get_pvplugin_api()
{
# OK
unset FOAM_PV_PLUGIN_LIBBIN PARAVIEW_API
local pv_api targetDir
# The OpenFOAM plugin must be the first in PV_PLUGIN_PATH
# and must have the paraview major+minor version encoded in its name!
# Eg, PV_PLUGIN_PATH="$FOAM_LIBBIN/paraview-5.5"
# Get the first entry from PV_PLUGIN_PATH=dir1;dir2;...
targetDir="${PV_PLUGIN_PATH##;}"
targetDir="${targetDir%%;*}"
# Extract paraview major+minor version from directory name
# From /path/paraview-5.6 -> 5.6
pv_api=$(get_pvapi "$targetDir")
[ -n "$pv_api" ] || return 1
# OK
export FOAM_PV_PLUGIN_LIBBIN="$targetDir"
export PARAVIEW_API="$pv_api"
return 0 # success
}
@ -101,47 +182,52 @@ wmakeLibPv()
#
have_pvplugin_support()
{
local header settings warn pv_api installDir binDir includeDir targetDir
warn="==> skip paraview-plugin"
local warn="==> skip paraview-plugin"
local settings pv_api pv_executable installDir binDir includeDir targetDir
# Trivial check
command -v cmake > /dev/null 2>&1 || {
command -v cmake >/dev/null || {
echo "$warn (no cmake)"
return 1
}
if get_pvplugin_api
then
targetDir="$FOAM_PV_PLUGIN_LIBBIN"
pv_api="$PARAVIEW_API"
fi
unset FOAM_PV_PLUGIN_LIBBIN PARAVIEW_API
# The OpenFOAM plugin must be the first in PV_PLUGIN_PATH
# and must have the paraview major+minor version encoded in its name!
# Eg, PV_PLUGIN_PATH="$FOAM_LIBBIN/paraview-5.5"
# Probably not needed...
# if [ -z "$targetDir" ] || [ -z "$pv_api" ]
# then
# echo "$warn (could not determine target or major.minor version)"
# echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-???}"
# return 1
# fi
# Get the first entry from PV_PLUGIN_PATH=dir1;dir2;...
targetDir="${PV_PLUGIN_PATH##;}"
targetDir="${targetDir%%;*}"
# Extract the paraview major+minor version from the directory name
# From /path/paraview-5.6 -> 5.6
pv_api=$(echo "$targetDir" | \
sed -ne 's@^.*/@@;s/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/p')
[ -n "$targetDir" ] || {
echo "$warn (could not determine target)"
echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-???}"
return 1
}
[ -n "$pv_api" ] || {
echo "$warn (could not determine major.minor version)"
return 1
}
# Header/library names
header="pqServerManagerModel.h"
# Include/library names
local header="pqServerManagerModel.h"
if [ -n "$ParaView_DIR" ]
then
# ParaView_DIR defined. Look for include/
# Unless already known, get API value from include directory name
if [ -z "$pv_api" ]
then
for settings in $(find "$ParaView_DIR"/include -maxdepth 1 -name 'paraview-*' -type d)
do
pv_api=$(get_pvapi "$settings") && break
done
if [ -z "$pv_api" ]
then
echo "$warn (could not determine paraview major.minor version)"
return 1
fi
fi
header=$(findFirstFile \
"$ParaView_DIR/include/paraview-$pv_api/$header" \
"$ParaView_DIR/include/paraview/$header"
@ -150,11 +236,14 @@ have_pvplugin_support()
else
# No ParaView_DIR defined
# - use location of 'paraview' to guess an equivalent ParaView_DIR
# - assume we can use paraview-config
# - assume paraview-config works, but might be removed too!
binDir="$(command -v paraview 2>/dev/null)"
binDir="${binDir%/*}" # Eg, /usr/bin/paraview -> /usr/bin
installDir="${binDir%/*}" # Eg, /usr/bin -> /usr
pv_executable="$(command -v paraview 2>/dev/null)" || {
echo "$warn (no paraview found?)"
return 2
}
binDir="${pv_executable%/*}" # Eg, /usr/bin/paraview -> /usr/bin
installDir="${binDir%/*}" # Eg, /usr/bin -> /usr
case "$installDir" in
(/*) # An absolute path
@ -162,6 +251,17 @@ have_pvplugin_support()
;;
esac
# Unless already known, get API value from `paraview --version` information
if [ -z "$pv_api" ]
then
pv_api=$(get_pvapi "$("$pv_executable" --version)")
if [ -z "$pv_api" ]
then
echo "$warn (could not determine paraview major.minor version)"
return 1
fi
fi
header=$(findFirstFile \
"$(paraview-config --include 2>/dev/null |sed -ne 's/^ *-I//p')/$header"\
"${includeDir:+$includeDir/paraview-$pv_api/$header}" \
@ -173,15 +273,20 @@ have_pvplugin_support()
)
fi
# ----------------------------------
# Header found?
# Header
[ -n "$header" ] || {
[ -n "$warn" ] && echo "$warn (no header)"
return 2
}
# ----------------------------------
# OK
# Use FOAM_LIBBIN/paraview-maj.min as default
export HAVE_PVPLUGIN_SUPPORT=true
export FOAM_PV_PLUGIN_LIBBIN="$targetDir"
export FOAM_PV_PLUGIN_LIBBIN="${targetDir:-$FOAM_LIBBIN/paraview-$pv_api}"
export PARAVIEW_API="$pv_api"
export PARAVIEW_INC_DIR="${header%/*}" # Basename
@ -192,11 +297,15 @@ have_pvplugin_support()
# Force reset of old variables
no_paraview
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_pvplugin_support
echo_paraview
fi
;;
-query)
## query_paraview
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,12 +2,13 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# sysFunctions
@ -16,14 +17,26 @@
# General system helper functions
#
# Functions provided
# isDarwin
# isNone
# isSystem
# isAbsdir, hasAbsdir
# isNone, isSystem, isAbsdir, hasAbsdir
# isDarwin, isWindows
# findFirstFile
# findSystemInclude
# findLibrary
# findExtLib
# versionCompare
#
# Internal variables used
# extLibraries
#
# External variables used
# WM_OSTYPE (is set for Windows)
# WM_COMPILER_LIB_ARCH
# DEB_TARGET_MULTIARCH
#
# Compatibility functions
# thirdExtLib
#
# Variables provided
# Compatibility variables
# extLiba
# extLibso
#
@ -34,28 +47,39 @@ then
# Load once, but do not rely on this variable elsewhere
WMAKE_SCRIPTS_SYSFUNCTIONS=loaded
# Static library extension. Default=.a
extLiba=".a"
# Shared library extension. Default=.so
case "$(uname -s 2>/dev/null)" in
Darwin)
extLibso=".dylib"
;;
*)
extLibso=".so"
;;
esac
# Debian multi-arch, ignore missing/bad dpkg-architecture.
if [ -z "$DEB_TARGET_MULTIARCH" ]
then
DEB_TARGET_MULTIARCH=$(dpkg-architecture -qDEB_TARGET_MULTIARCH 2>/dev/null || true)
fi
# True if OS is Darwin.
# Uses libso extension to cache the value
# (instead of calling 'uname -s' each time)
isDarwin()
{
test "$extLibso" = ".dylib"
test Darwin = "$(uname -s 2>/dev/null || true)"
}
# True if target OS is Windows
isWindows()
{
test MSwindows = "$WM_OSTYPE"
}
# Static, dynamic library extensions
extLibraries=".a .so"
extLiba=".a" # [compat] static library
extLibso=".so" # [compat] dynamic library
if isDarwin
then
extLibraries=".a .dylib"
extLibso=".dylib" # [compat] dynamic library
elif isWindows
then
extLibraries=".a .dll .dll.a" # including cross-compiling
fi
# True if '$1' begins with '/'
isAbsdir()
@ -71,16 +95,16 @@ then
}
# True if '$1' is an empty string or matches "*-none".
# True if '$1' is an empty string, "none" or ends in "-none"
# Eg,
# if isNone "$KAHIP_ARCH_PATH" ...
# if isNone "$BOOST_ARCH_PATH" ...
isNone()
{
test -z "$1" -o "${1##*-}" = none
}
# True if '$1' matches "*-system"
# True if '$1' is "system" or ends in "-system"
# Eg,
# if isSystem "$BOOST_ARCH_PATH"
isSystem()
@ -89,22 +113,226 @@ then
}
# Check for the existence of any of the files
# True if '$1' and '$2' have the same directory basename
# Eg,
# equalBaseName "/usr/include/scotch-int32" "scotch-int32"
equalBaseName()
{
test "${1##*/}" = "${2##*/}"
}
# Simple output for -query
# $1 = software
# $2 = setting
_process_query()
{
if isNone "$2"
then
echo "$1=none"
elif isAbsdir "$2" ## not hasAbsdir
then
echo "$1=${2##*/}"
elif isSystem "$2"
then
echo "$1=system"
else
echo "$1=unknown"
fi
}
# Return system prefix (/usr, /usr/local, ...) based on hint provided
# Eg,
# sysPrefix "/usr/local/include/fftw3.h" -> "/usr/local"
#
# Without a hint, echoes "/usr"
sysPrefix()
{
case "$1" in
/usr/local/*)
echo "/usr/local"
;;
*)
echo "/usr"
;;
esac
}
# Check existence of any of the files
# On success, echoes the file found and returns 0, otherwise returns 2
findFirstFile()
{
local file
for file
do
if [ -f "$file" -a -r "$file" ]
if [ -f "$file" ] && [ -r "$file" ]
then
echo "$file"
echo "$file" # Found
return 0
fi
done
return 2
}
# Check system /usr/local/include /usr/include paths
#
# On success, echoes the resolved file and returns 0, otherwise returns 2
#
# Specify -name=incName to search for
#
findSystemInclude()
{
local searchName
case "$1" in
-name=*)
searchName="${1#*=}"
;;
esac
if [ -z "$searchName" ]
then
return 1
fi
findFirstFile \
"/usr/local/include/$searchName" \
"/usr/include/$searchName" \
;
}
# Check existence of library with ending '.a', '.so' ...
#
# On success, echoes the resolved file and returns 0, otherwise returns 2
#
# This function has two modes of operation.
#
# 1) Automated search.
# Specify -prefix=dirName -name=libName, optionally -local=subdirName
# and search for (lib, lib64, lib/x86_64..) etc.
#
# 2) Directed search.
# specify the fully qualified names to search on the parameter list
#
findLibrary()
{
local prefixDir localDir searchDir searchName
local file ext
searchDir=true
while [ "$searchDir" = true ] && [ "$#" -gt 0 ]
do
case "$1" in
-prefix=*)
prefixDir="${1#*=}"
shift
;;
-local=*)
# Prefix with directory separator
localDir="/${1#*=}"
shift
;;
-name=*)
searchName="${1#*=}"
shift
;;
(*)
unset searchDir
;;
esac
done
if [ -n "$searchName" ]
then
# Automated search (eg, lib/ lib64/, lib/x86_64-linux-gnu)
# but also handle possible local versions (eg, lib/scotch-int32)
: "${prefixDir:=/usr}" # A reasonable default
[ -d "$prefixDir" ] || return 2
# Local and regular search paths
set -- \
"lib${localDir}" \
"${WM_COMPILER_LIB_ARCH:+lib${WM_COMPILER_LIB_ARCH}${localDir}}" \
"${DEB_TARGET_MULTIARCH:+lib/${DEB_TARGET_MULTIARCH}${localDir}}" \
"lib" \
"${WM_COMPILER_LIB_ARCH:+lib${WM_COMPILER_LIB_ARCH}}" \
"${DEB_TARGET_MULTIARCH:+lib/${DEB_TARGET_MULTIARCH}}" \
;
# Ignore empty local search path ("/")
[ "${#localDir}" -gt 1 ] || shift 3
## echo "search: $# $@" 1>&2
for searchDir in "$@"
do
[ -n "$searchDir" ] || continue
for ext in '' $extLibraries
do
file="$prefixDir/$searchDir/$searchName$ext"
if [ -f "$file" ] && [ -r "$file" ]
then
echo "$file" # Found
return 0
fi
done
done
else
# Directed search
for file
do
[ -n "$file" ] || continue
for ext in '' $extLibraries
do
if [ -f "$file$ext" ] && [ -r "$file$ext" ]
then
echo "$file$ext" # Found
return 0
fi
done
done
fi
return 2
}
# Check existence of library in FOAM_EXT_LIBBIN, but conditional
# on FOAM_EXT_LIBBIN being located in the ThirdParty directory
#
# On success, echoes the resolved file and returns 0, otherwise returns 2
findExtLib()
{
local file
if [ -n "$FOAM_EXT_LIBBIN" ] && \
[ -n "$WM_THIRD_PARTY_DIR" ] && \
[ "${FOAM_EXT_LIBBIN#$WM_THIRD_PARTY_DIR}" != "$FOAM_EXT_LIBBIN" ]
then
for file
do
if file="$(findLibrary "$FOAM_EXT_LIBBIN/$file")"
then
echo "$file"
return 0
fi
done
fi
return 2
}
# [compat]
# Check for existence of file in FOAM_EXT_LIBBIN,
# but not if either file or FOAM_EXT_LIBBIN are empty or
# if the FOAM_EXT_LIBBIN is not located in the ThirdParty directory
@ -125,6 +353,74 @@ then
return 2
fi
}
# Compare version tuples with syntax similar to POSIX shell,
# but respecting dot separators.
#
# arg1 OP arg2
# OP is one of -eq, -ne, -lt, -le, -gt, or -ge.
# Returns true for a successful comparison.
# Arg1 and arg2 normally comprise positive integers, but leading content
# before a '-' is stripped.
# Missing digits are treated as '0'.
#
# Eg,
# versionCompare "software-1.2.3" -gt 1.1 && echo True
#
# Ad hoc handling of "git" version as always newest.
# "git" -gt "1.2.3" : True
# "1.2.3" -lt "git" : True
versionCompare()
{
[ "$#" -eq 3 ] || {
echo "Compare needs 3 arguments (was given $#)" 1>&2
return 2
}
local arg1="${1#*-}" # Strip leading prefix-
local op="${2}"
local arg2="${3#*-}" # Strip leading prefix-
local result='' # Empty represents 'equal'
arg1="${arg1:-0}."
arg2="${arg2:-0}."
if [ "$arg1" = "$arg2" ]; then unset arg1 arg2 # Identical
elif [ "${arg1#git}" != "$arg1" ]; then result='more' # (git > arg2)
elif [ "${arg2#git}" != "$arg2" ]; then result='less' # (arg1 < git)
fi
while [ -z "$result" ] && [ -n "${arg1}${arg2}" ]
do
local digits1="${arg1%%.*}"
local digits2="${arg2%%.*}"
arg1="${arg1#*.}"
arg2="${arg2#*.}"
: "${digits1:=0}"
: "${digits2:=0}"
# Other handling of non-integer values?
if [ "$digits1" -lt "$digits2" ]; then result='less'
elif [ "$digits1" -gt "$digits2" ]; then result='more'
fi
done
case "$op" in
(-eq | eq) [ -z "$result" ] ;;
(-ne | ne) [ -n "$result" ] ;;
(-lt | lt) [ 'less' = "$result" ] ;;
(-gt | gt) [ 'more' = "$result" ] ;;
(-le | le) [ 'less' = "${result:-less}" ] ;;
(-ge | ge) [ 'more' = "${result:-more}" ] ;;
(*)
echo "Unknown operator: '$op'" 1>&2
return 2
;;
esac
}
fi

View File

@ -2,18 +2,23 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2015-2016 OpenFOAM Foundation
# Copyright (C) 2018-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wmakeFunctions
#
# Description
# Functions to check wmake environment and find .dep and .o files
# Support functions for wmake infrastructure.
# For example, check environment, find .dep and .o files, various
# wrappers when making libraries.
#
#------------------------------------------------------------------------------
# Ensure these variables are always defined
@ -28,17 +33,18 @@ then
fi
#------------------------------------------------------------------------------
# Check environment variables
#------------------------------------------------------------------------------
# Check environment variables
checkEnv()
{
local check failed
for check in WM_PROJECT_DIR WM_OPTIONS WM_DIR
# Default for WM_DIR already provided above
for check in WM_PROJECT_DIR WM_OPTIONS
do
eval test "\$$check" || failed="$failed $check"
eval test -n "\$$check" || failed="$failed $check"
done
[ -z "$failed" ] || {
@ -49,11 +55,8 @@ checkEnv()
}
#------------------------------------------------------------------------------
# Search up directories tree for the Make sub-directory
#------------------------------------------------------------------------------
# Return the absolute path for a directory or a file's parent directory
# Return the absolute (physical) path for a directory or
# for a file's parent directory
# expandPath dirName
# expandPath fileName
#
@ -66,12 +69,13 @@ expandPath()
(cd "$1" && pwd -P)
elif [ -n "$1" ]
then
(cd $(dirname "$1") && pwd -P)
(cd "$(dirname "$1")" && pwd -P)
else
pwd -P
fi
}
# Find the target directory, which contains a Make/ directory
# search upwards in its parent directories, but stopping
# when it hits the project root, home, or the file-system root
@ -85,15 +89,15 @@ expandPath()
# - WM_PROJECT_DIR, HOME
findTarget()
{
local project=$(expandPath $WM_PROJECT_DIR)
local home=$(expandPath $HOME)
local project=$(expandPath "$WM_PROJECT_DIR")
local home=$(expandPath "$HOME")
local reldir="${1:-.}"
local absdir=$(expandPath $reldir)
local absdir=$(expandPath "$reldir")
while [ -n "$absdir" ]
do
case "$absdir" in
($project | $home | /)
("$project" | "$home" | /)
break
;;
esac
@ -109,7 +113,7 @@ findTarget()
fi
done
echo "Error: no Make directory for $(expandPath $1)" 1>&2
echo "Error: no Make directory for $(expandPath "$1")" 1>&2
echo 1>&2
return 1
}
@ -129,14 +133,14 @@ cdSource()
echo " Searching up directories tree for Make directory" 1>&2
dir=$(findTarget .) || exit 1 # Fatal
cd $dir 2>/dev/null || {
cd "$dir" 2>/dev/null || {
echo "$Script error: could not change to directory '$dir'" 1>&2
exit 1
}
unset targetType
fi
[ -r $MakeDir/files ] || {
[ -r "$MakeDir"/files ] || {
echo "$Script error: file '$MakeDir/files' does not exist in $PWD" 1>&2
exit 1
}
@ -154,23 +158,34 @@ cdSource()
# - WM_PROJECT_DIR, WM_OPTIONS
findObjectDir()
{
local project=$(expandPath $WM_PROJECT_DIR)
local absdir=$(expandPath ${1:-.})
local objectsDir
local project="$(expandPath "$WM_PROJECT_DIR")"
local absdir="$(expandPath "${1:-.}")"
local appDir relativeDir objectsDir
case "$absdir" in
("$project"/*)
local buildPath=$WM_PROJECT_DIR/build/${WM_OPTIONS}
objectsDir=$buildPath$(echo $absdir | sed s%$project%% )
;;
(*)
local path=$absdir
local appDir=.
[ -d Make ] || appDir=$(findTarget .) || exit 1 # Fatal
absdir=$(expandPath $appDir/.)
objectsDir=$appDir/Make/${WM_OPTIONS}$(echo $path | sed s%$absdir%% )
;;
esac
# Treat project/ builds as out-of-source
relativeDir="${absdir#${project}/}"
if [ "$relativeDir" != "$absdir" ]
then
[ -w "$WM_PROJECT_DIR" ] && \
objectsDir="${WM_PROJECT_DIR}/build/${WM_OPTIONS}/${relativeDir}"
fi
# Default (local) build directory
if [ -z "$objectsDir" ]
then
if [ -d "$absdir/Make" ]
then
objectsDir="${absdir}/Make/${WM_OPTIONS}"
else
relativeDir="$absdir"
appDir=.
[ -d Make ] || appDir=$(findTarget .) || exit 1 # Fatal
absdir=$(expandPath "$appDir"/.)
relativeDir="${relativeDir#${absdir}}"
objectsDir="${appDir}/Make/${WM_OPTIONS}${relativeDir}"
fi
fi
echo "$objectsDir"
}
@ -187,14 +202,147 @@ findObjectDir()
# - WM_PROJECT_DIR, WM_OPTIONS
removeObjectDir()
{
local objectsDir=$(findObjectDir ${1:-.})
local objectsDir="$(findObjectDir "${1:-.}")"
if [ -d "$objectsDir" ]
then
rm -rf "$objectsDir" > /dev/null 2>&1
rm -rf "$objectsDir" 2>/dev/null
fi
}
# Save build/configure parameter information (dependency) into sentinel file
#
# 1 - sentinelFile
# 2... build/configure parameters
#
storeDependency()
{
local sentinel="$1"
local depend
shift
if [ -n "$sentinel" ]
then
mkdir -p "$(dirname "$sentinel")"
echo '# Build/configure parameters' >| "$sentinel"
for depend
do
echo "-- $depend"
done >> "$sentinel"
fi
return 0
}
# Check sentinel file(s) to handle changed build/configure parameters
# such as paraview / vtk version changes
#
# 1 - sourceDir
# 2... build/configure parameters
#
# The additional test for "CMakeCache.txt" helps for cmake projects and
# has no adverse affect for others
#
sameDependency()
{
local sourceDir="$1"
shift
local objectsDir
local compare=0
# Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
local sentinel="$objectsDir/ConfigParameters"
if [ -f "$sentinel" ]
then
# Create an .update version for comparison
storeDependency "${sentinel}.update" $@
cmp "${sentinel}" "${sentinel}.update" >/dev/null 2>&1
compare=$?
if [ "$compare" -ne 0 ]
then
echo "build/configure parameters changed between builds" 1>&2
## cat "${sentinel}.update" 1>&2
fi
else
# No sentinel file: First time, or failed compilation?
if [ -f "$objectsDir/CMakeCache.txt" ]
then
echo "previous build was incomplete" 1>&2
compare=1
fi
fi
echo "$sentinel"
return "$compare"
}
# Build a mpi-versioned library (targetType)
# - use sentinel file(s) to handle paraview version changes
# compile into qualified directory
# use sentinel file(s) to handle version changes
# 1 - libName
# 2... build/configure information
#
# Global variables used:
# - WM_OPTIONS, WM_MPLIB, FOAM_MPI
#
# Requires that WM_MPLIB contain an "MPI" string
wmakeLibMpi()
{
local libName="$1"
shift
case "$WM_MPLIB" in (*MPI* | *mpi*)
(
WM_OPTIONS="$WM_OPTIONS$WM_MPLIB"
# Where generated files are stored
objectsDir="$(findObjectDir "$libName")" || exit 1 # Fatal
# Something changed
sentinel=$(sameDependency "$libName" "MPLIB=$WM_MPLIB" "MPI=$FOAM_MPI" $@) || \
wclean "$libName"
echo "wmake $targetType $libName (mpi=$WM_MPLIB)"
wmake $targetType "$libName" && \
storeDependency "$sentinel" "MPLIB=$WM_MPLIB" "MPI=$FOAM_MPI" $@
)
;;
esac
}
# Clean an mpi-versioned library
#
# Global variables used:
# - WM_OPTIONS, WM_MPLIB
#
# Requires that WM_MPLIB contain an "MPI" string
wcleanLibMpi()
{
case "$WM_MPLIB" in (*MPI* | *mpi*)
(
WM_OPTIONS="$WM_OPTIONS$WM_MPLIB"
for libName
do
wclean "$libName"
done
)
;;
esac
}
#------------------------------------------------------------------------------
# depToSource depFile
#
# Output:
@ -207,7 +355,7 @@ if [ -n "$BASH_VERSION" ]
then
depToSource()
{
local sourceFile=${1%.dep}
local sourceFile="${1%.dep}"
sourceFile="${sourceFile/build\/${WM_OPTIONS}\//}"
sourceFile="${sourceFile/build\/${WM_OPTIONS}${WM_MPLIB}\//}"
sourceFile="${sourceFile/Make\/${WM_OPTIONS}\//}"
@ -218,13 +366,11 @@ then
else
depToSource()
{
local sourceFile=$(echo ${1%.dep} | \
sed -e s%build/${WM_OPTIONS}/%% \
-e s%build/${WM_OPTIONS}${WM_MPLIB}/%% \
-e s%Make/${WM_OPTIONS}/%% \
-e s%Make/${WM_OPTIONS}${WM_MPLIB}/%% )
echo "$sourceFile"
echo "${1%.dep}" | sed \
-e "s%build/${WM_OPTIONS}/%%" \
-e "s%build/${WM_OPTIONS}${WM_MPLIB}/%%" \
-e "s%Make/${WM_OPTIONS}/%%" \
-e "s%Make/${WM_OPTIONS}${WM_MPLIB}/%%"
}
fi

View File

@ -1,12 +1,39 @@
#!/bin/sh
cd "${0%/*}" || exit 1 # Run from this directory
cd "${0%/*}" || exit # This directory (/path/project/wmake/src)
if [ -z "$WM_DIR" ] # Require WM_DIR
if [ -z "$WM_DIR" ] # Require WM_DIR (/path/project/wmake)
then
WM_DIR="$(\cd $(dirname $0)/.. && \pwd -L)"
WM_DIR="$(dirname "$(pwd -L)")"
export WM_DIR
fi
make # Compile tools for wmake
if [ -z "$WM_PROJECT_DIR" ] # Expect WM_PROJECT_DIR (/path/project)
then
echo "Warning (${0##*/}) : No WM_PROJECT_DIR set" 1>&2
WM_PROJECT_DIR="${WM_DIR%/*}"
export WM_PROJECT_DIR
fi
if [ -z "$WM_ARCH" ] || [ -z "$WM_COMPILER" ]
then
echo "Error (${0##*/}) : No WM_ARCH or WM_COMPILER set"
echo " Check your OpenFOAM environment and installation"
exit 1
fi
case "$WM_COMPILER" in
Mingw*)
# Host wmake toolchain with system gcc (when cross-compiling)
make \
WM_COMPILER=Gcc WM_COMPILER_TYPE=system \
WMAKE_BIN="${WM_PROJECT_DIR}/platforms/tools/${WM_ARCH}${WM_COMPILER}" \
"$@"
;;
*)
# Regular wmake toolchain
make "$@"
;;
esac
#------------------------------------------------------------------------------

View File

@ -2,9 +2,12 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
@ -30,13 +33,13 @@
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# The Makefile use a POSIX shell
# Use POSIX shell
#------------------------------------------------------------------------------
SHELL = /bin/sh
SHELL = /bin/sh
#------------------------------------------------------------------------------
# Unset suffices list (suffix rules are not used)
# No default suffix rules used
#------------------------------------------------------------------------------
.SUFFIXES:
@ -52,41 +55,44 @@ WM_COMPILE_OPTION = Opt
GENERAL_RULES = $(WM_DIR)/rules/General
include $(GENERAL_RULES)/general
archHost := $(WM_ARCH)$(WM_COMPILER)
archTarget := $(shell basename $(WMAKE_BIN))
#------------------------------------------------------------------------------
# Targets
#------------------------------------------------------------------------------
.PHONY: all clean
.PHONY: all clean message old
all: $(WMAKE_BIN)/dirToString $(WMAKE_BIN)/wmkdep $(WMAKE_BIN)/wmkdepend
@echo built wmake-bin for $(WM_ARCH)$(WM_COMPILER)
all: $(WMAKE_BIN)/wmkdepend message
# Flex-based processing
old: $(WMAKE_BIN)/wmkdep
message:
@echo "built wmake-bin ($(archTarget))"
clean:
@echo clean wmake-bin for $(WM_ARCH)$(WM_COMPILER)
@rm -rf $(WMAKE_BIN) 2>/dev/null
@echo "clean wmake-bin ($(archTarget))"
@rm -rf $(WMAKE_BIN)
@rmdir $(shell dirname $(WMAKE_BIN)) 2>/dev/null || true
$(WMAKE_BIN)/dirToString: dirToString.c
@mkdir -p $(WMAKE_BIN)
$(call QUIET_MESSAGE,compile,$(<F))
$E $(cc) $(cFLAGS) $(<F) -o $@
$(WMAKE_BIN)/wmkdep: wmkdep.l
@mkdir -p $(WMAKE_BIN)
$(call QUIET_MESSAGE,flex,$(<F))
$E flex -o $@.c $(<F) && $(cc) $(cFLAGS) $@.c -o $@
@rm -f $@.c 2>/dev/null
@rm -f $@.c
$(WMAKE_BIN)/wmkdepend: wmkdepend.cpp
@mkdir -p $(WMAKE_BIN)
$(call QUIET_MESSAGE,wmkdepend,$(<F))
$E $(CC) $(c++FLAGS) $(c++LESSWARN) $(<F) -o $@
# $(WMAKE_BIN)/wmkdepend: wmkdepend.rl
# @mkdir -p $(WMAKE_BIN)
# $(call QUIET_MESSAGE,ragel,$(<F))
# $E ragel -G2 -o $@.cpp $(<F) && $(CC) $(c++FLAGS) $(c++LESSWARN) $@.cpp -o $@
# @rm -f $@.cpp 2>/dev/null
#$(WMAKE_BIN)/wmkdepend: wmkdepend.rl
# @mkdir -p $(WMAKE_BIN)
# $(call QUIET_MESSAGE,ragel,$(<F))
# $E ragel -G2 -o $@.cpp $(<F) && $(CC) $(c++FLAGS) $@.cpp -o $@
# @rm -f $@.cpp
#------------------------------------------------------------------------------

View File

@ -1,113 +0,0 @@
/*----------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
dirToString
Description
Converts a directory path into a camelCase string.
e.g. dir1/dir2/dir3 becomes dir1Dir2Dir3
Usage
echo dirName | dirToString
e.g.
using sh
baseDirName=$(echo $dir | $bin/dirToString -strip)
using csh
set baseDirName=`echo $dir | $bin/dirToString -strip`
\*----------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/* The executable name (for messages), without requiring access to argv[] */
#define EXENAME "dirToString"
int main(int argc, char* argv[])
{
int c;
if (argc > 1)
{
if (!strncmp(argv[1], "-h", 2))
{
/* Option: -h, -help */
fputs
(
"\nUsage: " EXENAME
" [-strip]\n\n"
" -strip ignore leading [./] characters.\n\n"
"Converts a directory path into a camelCase string\n\n",
stderr
);
return 0;
}
if (!strcmp(argv[1], "-s") || !strcmp(argv[1], "-strip"))
{
/* Option: -s, -strip */
while ((c=getchar()) != EOF && (c == '.' || c == '/'))
{
/* nop */
}
if (c == EOF)
{
return 0;
}
putchar(c);
}
}
int nextUpper = 0;
while ((c = getchar()) != EOF)
{
if (c == '/')
{
nextUpper = 1;
}
else if (nextUpper)
{
putchar(toupper(c));
nextUpper = 0;
}
else
{
putchar(c);
}
}
return 0;
}
/*****************************************************************************/

View File

@ -3,9 +3,12 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
#-------------------------------------------------------------------------------
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
@ -26,90 +29,144 @@
# wmake
#
# Description
# General, easy to use make system for multi-platform development
# with support for local and network parallel compilation.
# General, wrapped make system for multi-platform development.
#
# This updated wmake supports out-of-tree object and dependency files to
# avoid the clutter which accumulates in the source-tree with the original
# wmake system. Now when building the OpenFOAM package both the object and
# dependency files are now located in a tree with the same structure as the
# source tree but in the platforms/$WM_OPTIONS sub-directory of
# $WM_PROJECT_DIR.
# Intermediate object and dependency files retain the tree structure
# of the original source files, with its location depending on the
# build context.
#
# When building user libraries and applications which are not located in the
# OpenFOAM source-tree the object and dependency files are located in a tree
# with the same structure as the source tree but in the Make/$WM_OPTIONS
# sub-directory.
# 1. Building within the OpenFOAM project:
# The tree is located under $WM_PROJECT_DIR/build/$WM_OPTIONS/
#
# The disadvantage of the out-of-tree compilation is that the dependency
# files are harder to find but are sometimes useful to study which header
# files are included. For those who need access to the dependency files the
# new wdep script is provided to locate them. See the wdep script header or
# run:
# wdep -h
# 2. Building applications or libraries outside the OpenFOAM project:
# The tree is located under its local Make/$WM_OPTIONS/
#
# The `wdep` script can be used to locate the dependency file
# corresponding to a given source file.
#
# When `wmake -all` is used, the following rules are applied:
# 1. If `Allwmake.override` exists, use it.
# 2. (OR) If `Allwmake` exists, use it.
# 3. (OR) descend into each sub-directory and repeat.
#
# See also
# wmakeLnInclude, wmakeLnIncludeAll, wmakeCollect, wdep, wrmdep, wrmo,
# wclean, wcleanPlatform, wcleanLnIncludeAll
# wclean, wcleanLnIncludeAll
#
#------------------------------------------------------------------------------
Script="${0##*/}" # Use 'Script' for error messages in wmakeFunctions
. "${0%/*}/scripts/wmakeFunctions" # Source wmake functions
Script="${0##*/}" # Need 'Script' for wmakeFunctions messages
scriptsDir="${0%/*}"/scripts # wmake/scripts directory
. "$scriptsDir"/wmakeFunctions # Source wmake functions
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
printHelp() {
cat<<HELP_HEAD
Usage: $Script [OPTION] [dir]
$Script [OPTION] target [dir [MakeDir]]
options:
-s | -silent Quiet mode (does not echo commands)
-s | -silent Silent mode (do not echo commands)
-a | -all wmake all sub-directories, running Allwmake if present
-q | -queue wmakeCollect all sub-directories, running Allwmake if present
-k or -non-stop Compile without stopping when errors occur
-j Compile using all local cores/hyperthreads
-jN or -j N Compile using N cores/hyperthreads
-no-scheduler Compile without wmakeScheduler
-update Update lnInclude directories, dep files, remove deprecated
files and directories
-h | -help Print the usage
-q | -queue wmakeCollect sub-directories, running Allwmake if present
-k | -keep-going Keep going even when errors occur (-non-stop)
-j | -jN | -j N Compile using all or specified N cores/hyperthreads
-update Update lnInclude, dep files, remove deprecated files/dirs
HELP_HEAD
if [ -n "$1" ]
then
cat<<HELP_FULL
-debug Define c++DBUG='-DFULLDEBUG -g -O0' as override
-module-prefix=PATH Specify FOAM_MODULE_PREFIX as absolute/relative path
-module-prefix=TYPE Specify FOAM_MODULE_PREFIX as predefined type
(u,user | g,group | o,openfoam)
-no-scheduler Disable scheduled parallel compilation
-show-api Print api value (from Make rules)
-show-ext-so Print shared library extension (with '.' separator)
-show-c Print C compiler value
-show-cflags Print C compiler flags
-show-cxx Print C++ compiler value
-show-cxxflags Print C++ compiler flags
-show-cflags-arch The C compiler arch flag (eg, -m64 etc)
-show-cxxflags-arch The C++ compiler arch flag (eg, -m64 etc)
-show-compile-c Same as '-show-c -show-cflags'
-show-compile-cxx Same as '-show-cxx -show-cxxflags'
-show-path-c Print path to C compiler
-show-path-cxx Print path to C++ compiler
HELP_FULL
fi
A general, easy-to-use make system for multi-platform development
with support for local and network parallel compilation.
cat<<TAIL_OPTIONS
-pwd Print root directory containing a Make/ directory
-version | --version Print version (same as -show-api)
-help Display short help and exit
-help-full Display full help and exit
TAIL_OPTIONS
The 'target' is a Makefile target:
e.g., platforms/linux64GccDPOpt/.../fvMesh.o
cat<<HELP_TAIL_COMMON
or a special target:
all wmake all sub-directories, running Allwmake if present
queue wmakeCollect all sub-directories, running Allwmake if present
General, wrapped make system for multi-platform development.
HELP_TAIL_COMMON
if [ -n "$1" ]
then
cat<<HELP_TAIL_FULL
Makefile targets: platforms/linux64GccDPInt32Opt/.../fvMesh.o (for example)
Special targets:
all | queue Same as -all | -queue options
exe Compile statically linked executable
lib Compile statically linked archive lib (.a)
libo Compile statically linked lib (.o)
libso Compile dynamically linked lib (.so)
dep Compile lnInclude and dependencies only
updatedep Compile dependencies only (in case of broken dependencies)
dep Create lnInclude and dependencies only
updatedep Create dependencies only (in case of broken dependencies)
objects Compile but not link
USAGE
Environment
FOAM_MODULE_PREFIX
HELP_TAIL_FULL
else
cat<<HELP_TAIL_BRIEF
Some special targets (see -help-full for details):
all | queue Same as -all | -queue options
exe Executables
lib libo libso Libraries
HELP_TAIL_BRIEF
fi
exit 0 # clean exit
}
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '${0##*/} -help' for usage"
echo
exit 1
}
# Default make is the "make" in the path
make="make"
# Print compiler/system information (serial only)
printInfo() { make --no-print-directory -f "$WM_DIR"/makefiles/info "$@"; }
#------------------------------------------------------------------------------
# Set nCores to the number of cores on the machine
nCores=0
allCores()
{
nCores=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || nCores=1
: ${nCores:=1}
echo "${nCores:-1}"
}
@ -118,47 +175,111 @@ allCores()
#------------------------------------------------------------------------------
# Default to compiling the local target only
unset all update
unset optAll optUpdate optDebug optQuiet optShow optPwd
# Consistency with inherited values
if [ "$WM_QUIET" = true ]
then optQuiet=true
fi
while [ "$#" -gt 0 ]
do
case "$1" in
# Print help
-h | -help*)
usage
-help-f*) # Full help
printHelp -full
;;
-s | -silent)
-h | -help*) # Short help
printHelp
;;
-s | -silent | -quiet)
optQuiet=true
export WM_QUIET=true
;;
-debug)
echo "Ignore option: -debug" 1>&2
;;
-module-prefix=*)
optPrefix="${1#*=}"
case "$optPrefix" in
# Prefix: user
(u | user)
export FOAM_MODULE_PREFIX="${FOAM_USER_LIBBIN%/*}"
;;
# Prefix: group
(g | group)
export FOAM_MODULE_PREFIX="${FOAM_SITE_LIBBIN%/*}"
;;
# Prefix: openfoam (other)
(o | openfoam)
export FOAM_MODULE_PREFIX="${FOAM_LIBBIN%/*}"
;;
# Prefix: custom (absolute or relative)
(*)
export FOAM_MODULE_PREFIX="$optPrefix"
: "${FOAM_MODULE_PREFIX:=/usr/local}" # Default (autoconf)
# Require absolute path
[ "${FOAM_MODULE_PREFIX#/}" != "${FOAM_MODULE_PREFIX}" ] || \
FOAM_MODULE_PREFIX="${PWD}/${FOAM_MODULE_PREFIX}"
;;
esac
unset FOAM_MODULE_APPBIN FOAM_MODULE_LIBBIN
echo "Module prefix = $FOAM_MODULE_PREFIX" 1>&2
;;
-show-api | -show-ext-so | \
-show-compile-c | -show-c | -show-cflags | -show-cflags-arch | \
-show-compile-cxx | -show-cxx | -show-cxxflags | -show-cxxflags-arch )
printInfo "${1#-show-}"
optShow=true
;;
-show-path-c | -show-path-cxx )
command -v $(printInfo "${1#-show-path-}")
optShow=true
;;
-a | -all | all)
all=all
optAll=all
;;
-q | -queue | queue)
all=queue
optAll=queue
;;
# Parallel compilation on all cores (or specified number of cores)
-j)
nCores=0
test $# -ge 2 && expr $2 + 1 > /dev/null 2>&1 \
&& shift && nCores=$1
[ "$nCores" = 0 ] && allCores
export WM_NCOMPPROCS=$nCores
echo "Compiling enabled on $WM_NCOMPPROCS cores"
export WM_NCOMPPROCS=0
case "$2" in
[0-9]*)
if WM_NCOMPPROCS="$(expr 0 + "$2" 2>/dev/null)"
then
shift
fi
;;
esac
[ "${WM_NCOMPPROCS:=0}" -gt 0 ] || WM_NCOMPPROCS=$(allCores)
echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
;;
# Parallel compilation on specified number of cores
-j[1-9]*)
export WM_NCOMPPROCS=${1#-j}
echo "Compiling enabled on $WM_NCOMPPROCS cores"
export WM_NCOMPPROCS="${1#-j}"
echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
;;
# Non-stop compilation, ignoring errors
-k | -non-stop)
# Keep going, ignoring errors
-k | -keep-going | -non-stop)
export WM_CONTINUE_ON_ERROR=true
;;
# Disable scheduled parallel compilation
-no-scheduler)
unset WM_SCHEDULER
;;
# Print root directory containing a Make/ directory and exit
-pwd)
optPwd=true
;;
# Meant to be used following a pull, this will:
# - remove dep files that depend on deleted files;
# - remove stale dep files;
@ -166,15 +287,20 @@ do
# - remove empty directories, along with deprecated object directories
# and respective binaries.
-update)
update=true
: ${all:=all} # implies 'all', unless previous set to 'queue' etc.
optUpdate=true
: "${optAll:=all}" # implies 'all', unless previously set
;;
-version | --version)
printInfo api
optShow=true
break;
;;
--)
shift
break
;;
-*)
usage "unknown option: '$1'"
die "unknown option: '$1'"
;;
*)
break
@ -183,6 +309,11 @@ do
shift
done
if [ "$optShow" = true ]
then
exit 0
fi
#------------------------------------------------------------------------------
# Check environment variables
@ -190,42 +321,28 @@ done
checkEnv
# When compiling anything but a standalone exe WM_PROJECT and WM_PROJECT_DIR
# must be set
[ "$1" = exe -o \( "$WM_PROJECT" -a "$WM_PROJECT_DIR" \) ] || {
# Require WM_PROJECT for anything except a standalone exe.
# The WM_PROJECT_DIR was already tested in checkEnv.
if [ -z "$WM_PROJECT" ] && [ "$1" != exe ]
then
exec 1>&2
echo "$Script error:"
echo " environment variable \$WM_PROJECT or \$WM_PROJECT_DIR not set"
echo " environment variable \$WM_PROJECT not set"
echo " while building project library"
exit 1
}
fi
#------------------------------------------------------------------------------
# Setup parallel compilation
#------------------------------------------------------------------------------
# Set WM_NCOMPPROCS automatically when both WM_HOSTS and WM_SCHEDULER are set
if [ -z "$WM_NCOMPPROCS" -a -n "$WM_HOSTS" -a -n "$WM_SCHEDULER" ]
then
WM_NCOMPPROCS=$(wmakeScheduler -count) || unset WM_NCOMPPROCS
fi
if [ -n "$WM_NCOMPPROCS" ]
then
parOpt="-j $WM_NCOMPPROCS"
if [ "$WM_NCOMPPROCS" -gt 1 -a -z "$MAKEFLAGS" ]
if [ "$WM_NCOMPPROCS" -gt 1 ] && [ -z "$MAKEFLAGS" ]
then
lockDir=$HOME/.$WM_PROJECT/.wmake
if [ -d $lockDir ]
then
rm -f $lockDir/*
else
mkdir -p $lockDir
fi
make="$make --no-print-directory $parOpt"
fi
fi
@ -239,48 +356,90 @@ fi
unset targetType
MakeDir=Make
if [ $# -ge 1 ]
unset dir
if [ -n "$optPwd" ]
then
unset dir
if [ -d "$1" ]
if [ $# -ge 1 ]
then
dir="${1%/}"
elif [ -f "$1" ]
then
dir="${1%/*}"
: "${dir:=.}"
else
targetType="$1"
fi
if [ -d "$1" ]
then
dir="${1%/}"
elif [ -f "$1" ]
then
dir="${1%/*}"
: "${dir:=.}"
[ "$dir" != "$1" ] || dir="."
else
echo "$Script error: not a file or directory" 1>&2
exit 1
fi
# Specified directory name:
[ $# -ge 2 ] && dir="${2%/}"
# Specified alternative name for the Make sub-directory:
[ $# -ge 3 ] && MakeDir="${3%/}"
if [ -n "$dir" ]
then
cd $dir 2>/dev/null || {
cd "$dir" 2>/dev/null || {
echo "$Script error: could not change to directory '$dir'" 1>&2
exit 1
}
elif [ -f "$MakeDir/files" ]
then
dir="(${PWD##*/})" # Implicit directory information
fi
# Print command
echo "$Script $targetType${targetType:+ }$dir"
unset dir
# Locate target with Make/ directory
if dir="$(findTarget .)"
then
(cd "$dir" && pwd -L)
exit 0
else
exit 2
fi
else
if [ $# -ge 1 ]
then
if [ -d "$1" ]
then
dir="${1%/}"
elif [ -f "$1" ]
then
dir="${1%/*}"
: "${dir:=.}"
if [ "$dir" = "$1" ]
then
dir="."
fi
else
targetType="$1"
fi
# Specified directory name:
[ $# -ge 2 ] && dir="${2%/}"
# Specified alternative name for the Make sub-directory:
[ $# -ge 3 ] && MakeDir="${3%/}"
if [ -n "$dir" ]
then
cd "$dir" 2>/dev/null || {
echo "$Script error: could not change to directory '$dir'" 1>&2
exit 1
}
elif [ -f "$MakeDir/files" ]
then
dir="(${PWD##*/})" # Implicit directory information
fi
# Print command
echo "$Script $targetType${targetType:+ }$dir"
unset dir
fi
fi
unset dir
#------------------------------------------------------------------------------
# Recurse the source tree to update all
#------------------------------------------------------------------------------
if [ "$update" = true ]
if [ "$optUpdate" = true ]
then
wrmdep -update
wrmdep -old
@ -290,23 +449,47 @@ then
fi
unset exitCode
#------------------------------------------------------------------------------
# Recurse the source tree to compile "all" targets
#------------------------------------------------------------------------------
if [ "$all" = all ]
if [ "$optAll" = all ]
then
if [ -e Allwmake ]
if [ -e Allwmake.override ]
then
if [ -x Allwmake.override ]
then
./Allwmake.override -fromWmake $targetType
exitCode="$?"
else
# Allow empty or non-executable file (eg, touch Allwmake.override)
exitCode=0
fi
elif [ -e Allwmake ]
then
./Allwmake -fromWmake $targetType
exit $?
exitCode="$?"
fi
if [ -n "$exitCode" ]
then
exit "$exitCode"
fi
exitCode=0 # For fall-through
# Find all the sub-directories containing a 'Make' directory
# (xargs is just used to flatten the list)
FOAM_APPS=$(
for d in *
do [ -d "$d" -a "$d" != Optional -a "$d" != Make ] && echo "$d"
do
case "$d" in
(Make) ;; # Do not make within Make/ dir
(*) [ -d "$d" ] && echo "$d" ;;
esac
done | xargs)
if [ -n "$FOAM_APPS" ]
@ -315,35 +498,31 @@ then
$make ${WM_CONTINUE_ON_ERROR:+-k} \
-f $WM_DIR/makefiles/apps \
TARGET="$targetType" FOAM_APPS="$FOAM_APPS"
makeExitCode=$?
else
makeExitCode=0 # For fall-through
exitCode=$?
fi
# Exit if current directory does not contains a 'Make' directory or
# an error was previously encountered
if [ ! -d "$MakeDir" -o $makeExitCode -ne 0 ]
# Exit on error, or if current directory does not have a 'Make' directory
if [ ! -d "$MakeDir" ] || [ "$exitCode" -ne 0 ]
then
exit $makeExitCode
exit "$exitCode"
fi
fi
#------------------------------------------------------------------------------
# Recurse the source tree to compile "all" targets using wmakeCollect
# Recurse source tree to compile "all" targets using wmakeCollect
#------------------------------------------------------------------------------
if [ "$all" = queue ]
if [ "$optAll" = queue ]
then
[ "$update" = true ] || wmakeLnIncludeAll $parOpt
[ "$optUpdate" = true ] || wmakeLnIncludeAll $parOpt
(
export WM_COLLECT_DIR=$WM_PROJECT_DIR/build/${WM_OPTIONS}/${PWD////_}
export WM_SCHEDULER=wmakeCollect
export WM_COLLECT_DIR="$WM_PROJECT_DIR/build/${WM_OPTIONS}/${PWD////_}"
export WM_SCHEDULER="$WM_DIR/wmakeCollect"
trap '$WM_SCHEDULER -kill' TERM INT
$WM_SCHEDULER -clean \
"$WM_SCHEDULER" -clean \
&& wmake -all objects \
&& $WM_SCHEDULER
&& "$WM_SCHEDULER"
) && wmake -all
exit $?
fi
@ -385,25 +564,35 @@ fi
# files and options being built in parallel
#------------------------------------------------------------------------------
objectsDir=$MakeDir/$WM_OPTIONS
case "$PWD" in
("$WM_PROJECT_DIR"/*)
buildPath=$WM_PROJECT_DIR/build/${WM_OPTIONS}
objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% )
;;
esac
# Mini-version of findObjectDir
unset objectsDir
# Handle project/{applications,src} as out-of-source build
relativeDir="${PWD#${WM_PROJECT_DIR}/}"
if [ "$relativeDir" != "$PWD" ]
then
[ -w "$WM_PROJECT_DIR" ] && \
objectsDir="${WM_PROJECT_DIR}/build/${WM_OPTIONS}/${relativeDir}"
fi
# Default (local) build directory
if [ -z "$objectsDir" ]
then
objectsDir="$MakeDir/$WM_OPTIONS"
fi
(
unset MAKEFLAGS
mkdir -p $objectsDir
mkdir -p "$objectsDir"
# Pre-build the $WM_OPTIONS/options file
# which is included when building the $WM_OPTIONS/files file
$make -s -f $WM_DIR/makefiles/files MAKE_DIR=$MakeDir \
OBJECTS_DIR=$objectsDir $objectsDir/options
$make -s -f $WM_DIR/makefiles/files \
MAKE_DIR="$MakeDir" OBJECTS_DIR="$objectsDir" "$objectsDir"/options
$make -s -f $WM_DIR/makefiles/files MAKE_DIR=$MakeDir \
OBJECTS_DIR=$objectsDir
$make -s -f $WM_DIR/makefiles/files \
MAKE_DIR=$MakeDir OBJECTS_DIR=$objectsDir
)
@ -427,8 +616,8 @@ case "$targetType" in
(lib | libo | libso | dep)
if grep -qe '^ *LIB *=' "$MakeDir/files" 2>/dev/null
then
$make -s -f $WM_DIR/makefiles/general MAKE_DIR=$MakeDir \
OBJECTS_DIR=$objectsDir lnInclude
$make -s -f $WM_DIR/makefiles/general \
MAKE_DIR=$MakeDir OBJECTS_DIR=$objectsDir lnInclude
fi
;;
esac
@ -441,11 +630,11 @@ esac
if [ -n "$WM_UPDATE_DEPENDENCIES" ]
then
$make -f $WM_DIR/makefiles/general MAKE_DIR=$MakeDir \
OBJECTS_DIR=$objectsDir updatedep
makeExitCode=$?
$make -f $WM_DIR/makefiles/general \
MAKE_DIR=$MakeDir OBJECTS_DIR=$objectsDir updatedep
exitCode="$?"
[ $makeExitCode -eq 0 ] || exit $makeExitCode
[ "$exitCode" -eq 0 ] || exit "$exitCode"
fi
@ -453,8 +642,8 @@ fi
# Make the dependency files or object files and link
#------------------------------------------------------------------------------
exec $make -f $WM_DIR/makefiles/general MAKE_DIR=$MakeDir \
OBJECTS_DIR=$objectsDir $targetType
exec $make -f $WM_DIR/makefiles/general \
MAKE_DIR=$MakeDir OBJECTS_DIR=$objectsDir $targetType
exit 0 # clean exit