Commit 1d544540 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: handle wmake -debug option via FOAM_EXTRA_CXX_FLAGS

- ensures that subsequent Allwmake scripts know about it.

ENH: add bin/tools/query-detect wrapper for wmake have_* scripts

CONFIG: use project/ThirdParty without additional sanity checks

- no need to test for Allwmake or platforms/ if ThirdParty is located
  within the project directory itself.

COMP: add simple mpi test to 00-dummy

- for testing library linkage, etc.
parent 83fb4867
......@@ -18,7 +18,7 @@ fi
#------------------------------------------------------------------------------
# Preamble. Report tools or at least the mpirun location
if [ -f "$WM_PROJECT_DIR"/wmake/scripts/list_tools ]
then . "$WM_PROJECT_DIR"/wmake/scripts/list_tools
then sh "$WM_PROJECT_DIR"/wmake/scripts/list_tools || true
else
echo "mpirun=$(command -v mpirun || true)"
fi
......
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
library/Allwclean
wclean libso dummy
wclean
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
# Can never be too certain ...
# Compile tools for wmake
( cd "${WM_DIR:-${WM_PROJECT_DIR}/wmake}/src" && ./Allmake )
# Toolchain binaries (wmake)
"${WM_DIR:-${WM_PROJECT_DIR}/wmake}"/src/Allmake
#------------------------------------------------------------------------------
library/Allwmake
wmake libso dummy
wmake
#------------------------------------------------------------------------------
/* Without the normal project defaults */
/* Disable normal project defaults */
PROJECT_INC =
PROJECT_LIBS =
EXE_INC = -Idummy
EXE_LIBS = -lOpenFOAM-dummy
EXE_INC = \
-I./library
EXE_LIBS = \
-lTestDummy-OpenFOAM \
-L$(FOAM_LIBBIN)/dummy -lTestDummyMpi
......@@ -32,6 +32,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "dummyLib.H"
#include <cstring>
#include <iostream>
......@@ -42,7 +43,7 @@ constexpr const char* const norm = "\\fR"; // nroff
constexpr const char* const website = "www.openfoam.com";
using std::cout;
using wmake = Foam::Detail::dummyLib;
using dummyLib = Foam::Detail::dummyLib;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -71,6 +72,16 @@ static void printMan(const char* exeName)
cout
<< ".SH OPTIONS" << nl
<< ".TP" << nl
<< "-parallel" << nl
<< "Run parallel and provide simple report" << nl;
if (!Foam::Detail::dummyLib::hasMPI())
{
cout << "[warning: no mpi]" << nl;
}
cout
<< ".TP" << nl
<< "-help-man" << nl
<< "Display manpage" << nl;
......@@ -78,28 +89,28 @@ static void printMan(const char* exeName)
cout
<< ".SH INFORMATION" << nl
<< ".nf" << nl
<< "label = " << wmake::label_size << nl
<< "scalar = " << wmake::scalar_size;
<< "label = " << dummyLib::label_size << nl
<< "scalar = " << dummyLib::scalar_size;
if
(
wmake::solveScalar_size
&& wmake::solveScalar_size != wmake::scalar_size
dummyLib::solveScalar_size
&& dummyLib::solveScalar_size != dummyLib::scalar_size
)
{
cout
<< " [solve=" << wmake::solveScalar_size << "]";
<< " [solve=" << dummyLib::solveScalar_size << "]";
}
cout
<< " (" << wmake::precision << ')' << nl
<< "arch = " << wmake::arch << nl
<< "compiler = " << wmake::compiler << nl;
<< " (" << dummyLib::precision << ')' << nl
<< "arch = " << dummyLib::arch << nl
<< "compiler = " << dummyLib::compiler << nl;
cout
<< nl
<< "archComp = " << wmake::archComp << nl
<< "archCompBase = " << wmake::archCompBase << nl
<< "archCompFull = " << wmake::archCompFull << nl;
<< "archComp = " << dummyLib::archComp << nl
<< "archCompBase = " << dummyLib::archCompBase << nl
<< "archCompFull = " << dummyLib::archCompFull << nl;
cout
<< ".fi" << nl;
......@@ -110,43 +121,61 @@ static void printMan(const char* exeName)
}
int main(int argc, char *argv[])
static void printInfo()
{
// Process -help-man
if (argc > 1 && strcmp(argv[1], "-help-man") == 0)
{
printMan("Test-dummyLib");
return 0;
}
cout
<< nl
<< "OPENFOAM = " << OPENFOAM << nl
<< "label = " << wmake::label_size << nl
<< "scalar = " << wmake::scalar_size
<< " (" << wmake::precision << ')' << nl;
<< "label = " << dummyLib::label_size << nl
<< "scalar = " << dummyLib::scalar_size
<< " (" << dummyLib::precision << ')' << nl;
if
(
wmake::solveScalar_size
&& wmake::solveScalar_size != wmake::scalar_size
dummyLib::solveScalar_size
&& dummyLib::solveScalar_size != dummyLib::scalar_size
)
{
cout
<< "solve = " << wmake::solveScalar_size << nl;
<< "solve = " << dummyLib::solveScalar_size << nl;
}
cout
<< "arch = " << wmake::arch << nl
<< "compiler = " << wmake::compiler << nl;
<< "arch = " << dummyLib::arch << nl
<< "compiler = " << dummyLib::compiler << nl;
cout
<< nl
<< "archComp = " << wmake::archComp << nl
<< "archCompBase = " << wmake::archCompBase << nl
<< "archCompFull = " << wmake::archCompFull << nl;
<< "archComp = " << dummyLib::archComp << nl
<< "archCompBase = " << dummyLib::archCompBase << nl
<< "archCompFull = " << dummyLib::archCompFull << nl;
cout<< nl;
}
int main(int argc, char *argv[])
{
bool master = true;
if (argc > 1)
{
if (strcmp(argv[1], "-help-man") == 0)
{
printMan("Test-dummyLib");
return 0;
}
if (strcmp(argv[1], "-parallel") == 0)
{
master = dummyLib::printMPI();
}
}
if (master)
{
printInfo();
}
return 0;
}
......
/* Install into FOAM_LIBBIN to support 'fake' builds (to test packaging) */
dummyLib.C
LIB = $(FOAM_LIBBIN)/libOpenFOAM-dummy
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
wclean dummy
./Allwclean-mpi
wclean
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
#------------------------------------------------------------------------------
wcleanLibMpi mpi
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
wmake libso dummy
./Allwmake-mpi
wmake libso
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -no-recursion "$@"
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
#------------------------------------------------------------------------------
# Environment
# - FOAM_MPI_LIBBIN (optional: defaults to FOAM_LIBBIN/FOAM_MPI)
wmakeLibMpi mpi
#------------------------------------------------------------------------------
/* Install into central FOAM_LIBBIN for 'fake' builds (test packaging) */
dummyLib.C
LIB = $(FOAM_LIBBIN)/libTestDummy-OpenFOAM
......@@ -8,4 +8,4 @@ EXE_INC = \
-DWM_COMPILE_OPTION=\"$(WM_COMPILE_OPTION)\" \
-DWM_OPTIONS=\"$(WM_OPTIONS)\"
/* LIB_LIBS = */
LIB_LIBS =
/* Install into central FOAM_LIBBIN/dummy for 'fake' builds (test packaging) */
dummyMpiLib.C
LIB = $(FOAM_LIBBIN)/dummy/libTestDummyMpi
/* Disable normal project defaults */
PROJECT_INC =
PROJECT_LIBS =
EXE_INC = \
-I../
/* LIB_LIBS = */
/*---------------------------------------------------------------------------*\
========= |
\\ / 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.
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 "dummyLib.H"
#include <iostream>
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
bool Foam::Detail::dummyLib::hasMPI()
{
return false;
}
bool Foam::Detail::dummyLib::printMPI()
{
std::cout << "Compiled without mpi\n";
return true;
}
// ************************************************************************* //
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......
......@@ -24,20 +24,22 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::Detail::dummyLib
Foam::Detail::dummy
Description
This class serves little useful purpose, but can be used to compile
into a dummy library and link against for a minimal application
that uses the wmake framework
No useful purpose other than to use the wmake framework to generate
a dummy library for testing/packaging purposes
Note
Pure C++ without any OpenFOAM classes or libraries.
SourceFiles
dummyLib.C
\*---------------------------------------------------------------------------*/
#ifndef dummyLib_H
#define dummyLib_H
#ifndef testing_dummyLib_H
#define testing_dummyLib_H
#include <string>
......@@ -80,6 +82,12 @@ struct dummyLib
//- DIY Compile-time value of WM_OPTIONS
static const std::string archCompFull;
//- Compiled/linked with mpi?
static bool hasMPI();
//- Print ranks (trivial mpi test). Return true for master only.
static bool printMPI();
};
......
/* Install into central FOAM_MPI_LIBBIN for 'fake' builds (test packaging) */
dummyMpiLib.C
LIB = $(FOAM_MPI_LIBBIN)/libTestDummyMpi
/* Disable normal project defaults */
PROJECT_INC =
PROJECT_LIBS =
sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB)
sinclude $(DEFAULT_RULES)/mplib$(WM_MPLIB)
/* Default is PROJECT LIB/mpi target */
ifeq (,$(FOAM_MPI_LIBBIN))
FOAM_MPI_LIBBIN := $(FOAM_LIBBIN)/$(FOAM_MPI)
endif
EXE_INC = \
-I.. \
$(PFLAGS) $(PINC) $(c++LESSWARN) -DFOAM_MPI=\"$(FOAM_MPI)\"
LIB_LIBS = $(PLIBS)
/*---------------------------------------------------------------------------*\
========= |
\\ / 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.
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 "dummyLib.H"
#include <iostream>
#include <mpi.h>
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
bool Foam::Detail::dummyLib::hasMPI()
{
return true;
}
bool Foam::Detail::dummyLib::printMPI()
{
int rank = 0, nprocs = 0;
MPI_Init(nullptr, nullptr);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// Hello world
std::cout
<<
(
std::string("mpi rank ")
+ std::to_string(rank) + '/' + std::to_string(nprocs)
+ '\n'
);
MPI_Finalize();
#ifdef FOAM_MPI
if (rank == 0)
{
std::cout
<<
(
std::string("FOAM_MPI=") + std::string(FOAM_MPI)
+ '\n'
);
}
#endif
return rank == 0;
}
// ************************************************************************* //
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment