Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Backofen, Rainer
amdis
Commits
4de96d0f
Commit
4de96d0f
authored
Jun 13, 2017
by
Praetorius, Simon
Browse files
initfile singleton made thread-safe (at least the construction
parent
67e47bc7
Changes
13
Hide whitespace changes
Inline
Side-by-side
AMDiS/cmake3/AMDIS.cmake.in
View file @
4de96d0f
set(AMDIS_NEED_CXX11 @ENABLE_CXX11@)
set(AMDIS_NEED_UMFPACK @ENABLE_UMFPACK@)
set(AMDIS_NEED_UMFPACK @ENABLE_UMFPACK@)
set(AMDIS_NEED_COMPRESSION @ENABLE_COMPRESSION@)
set(AMDIS_NEED_COMPRESSION @ENABLE_COMPRESSION@)
set(AMDIS_NEED_EXTENSIONS @ENABLE_EXTENSIONS@)
set(AMDIS_NEED_EXTENSIONS @ENABLE_EXTENSIONS@)
...
@@ -18,19 +17,17 @@ add_library(AMDiS ALIAS amdis_base)
...
@@ -18,19 +17,17 @@ add_library(AMDiS ALIAS amdis_base)
target_compile_definitions(amdis_base INTERFACE)
target_compile_definitions(amdis_base INTERFACE)
if (AMDIS_NEED_CXX11)
target_enable_cxx14(SUPPORTS_CXX14 amdis_base INTERFACE)
target_enable_cxx14(SUPPORTS_CXX14 amdis_base INTERFACE)
if (NOT SUPPORTS_CXX14)
if (NOT SUPPORTS_CXX14)
target_enable_cxx11(SUPPORTS_CXX11 amdis_base INTERFACE)
target_enable_cxx11(SUPPORTS_CXX11 amdis_base INTERFACE)
endif ()
endif ()
if (NOT SUPPORTS_CXX11 AND NOT SUPPORTS_CXX14)
if (NOT SUPPORTS_CXX11 AND NOT SUPPORTS_CXX14)
message(FATAL_ERROR "AMDiS was compiled with c++11 support, but the current compiler does not support this feature!")
message(FATAL_ERROR "AMDiS was compiled with c++11 support, but the current compiler does not support this feature!")
endif ()
endif ()
target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=1)
target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=1)
else ()
target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=0)
endif (AMDIS_NEED_CXX11)
# try to detect the AMDiS include directory
# try to detect the AMDiS include directory
...
...
AMDiS/cmake3/CMakeLists.txt
View file @
4de96d0f
...
@@ -23,12 +23,19 @@ add_library(AMDiS::base ALIAS amdis_base)
...
@@ -23,12 +23,19 @@ add_library(AMDiS::base ALIAS amdis_base)
target_include_directories
(
amdis_base INTERFACE
${
SOURCE_DIR
}
)
target_include_directories
(
amdis_base INTERFACE
${
SOURCE_DIR
}
)
target_compile_definitions
(
amdis_base INTERFACE
)
target_compile_definitions
(
amdis_base INTERFACE
)
target_enable_cxx11
(
ENABLE_CXX11 amdis_base INTERFACE
)
if
(
ENABLE_CXX11
)
target_enable_cxx14
(
SUPPORTS_CXX14 amdis_base INTERFACE
)
target_compile_definitions
(
amdis_base INTERFACE AMDIS_HAS_CXX11=1
)
if
(
SUPPORTS_CXX14
)
target_compile_definitions
(
amdis_base INTERFACE AMDIS_HAS_CXX14=1
)
else
()
else
()
target_compile_definitions
(
amdis_base INTERFACE AMDIS_HAS_CXX11=0
)
target_enable_cxx11
(
SUPPORTS_CXX11 amdis_base INTERFACE
)
endif
(
ENABLE_CXX11
)
endif
()
if
(
NOT SUPPORTS_CXX11 AND NOT SUPPORTS_CXX14
)
message
(
FATAL_ERROR
"AMDiS needs c++11 support, but the current compiler does not support this feature!"
)
endif
()
target_compile_definitions
(
amdis_base INTERFACE AMDIS_HAS_CXX11=1
)
target_enable_mtl4
(
amdis_base INTERFACE
)
target_enable_mtl4
(
amdis_base INTERFACE
)
target_enable_boost
(
amdis_base INTERFACE
)
target_enable_boost
(
amdis_base INTERFACE
)
...
...
AMDiS/cmake3/muparser.cmake
View file @
4de96d0f
...
@@ -17,10 +17,8 @@ add_library(muparser STATIC
...
@@ -17,10 +17,8 @@ add_library(muparser STATIC
target_include_directories
(
muparser PUBLIC
${
MUPARSER_INCLUDE_DIR
}
)
target_include_directories
(
muparser PUBLIC
${
MUPARSER_INCLUDE_DIR
}
)
set_property
(
TARGET muparser PROPERTY POSITION_INDEPENDENT_CODE ON
)
set_property
(
TARGET muparser PROPERTY POSITION_INDEPENDENT_CODE ON
)
if
(
ENABLE_CXX11
)
target_enable_cxx11
(
MUPARSER_ENABLE_CXX11 muparser PRIVATE
)
target_enable_cxx11
(
MUPARSER_ENABLE_CXX11 muparser PRIVATE
)
target_compile_definitions
(
muparser PRIVATE AMDIS_HAS_CXX11=1
)
target_compile_definitions
(
muparser PRIVATE AMDIS_HAS_CXX11=1
)
endif
(
ENABLE_CXX11
)
# specify how to install this target:
# specify how to install this target:
# -----------------------------------
# -----------------------------------
...
...
AMDiS/cmake3/target_enable_boost.cmake
View file @
4de96d0f
...
@@ -13,7 +13,7 @@ macro(target_enable_boost _TARGET_ _SCOPE_)
...
@@ -13,7 +13,7 @@ macro(target_enable_boost _TARGET_ _SCOPE_)
endif
(
BOOST_LIBRARYDIR
)
endif
(
BOOST_LIBRARYDIR
)
set
(
BOOST_VERSION
"1.48"
)
set
(
BOOST_VERSION
"1.48"
)
set
(
BOOST_LIBS_REQUIRED system iostreams filesystem program_options date_time
)
set
(
BOOST_LIBS_REQUIRED system iostreams filesystem program_options date_time
thread
)
if
(
WIN32
)
if
(
WIN32
)
list
(
APPEND BOOST_LIBS_REQUIRED zlib
)
list
(
APPEND BOOST_LIBS_REQUIRED zlib
)
if
(
ENABLE_COMPRESSION OR AMDIS_NEED_COMPRESSION
)
if
(
ENABLE_COMPRESSION OR AMDIS_NEED_COMPRESSION
)
...
...
AMDiS/cmake3/target_enable_mtl4.cmake
View file @
4de96d0f
macro
(
target_enable_mtl4 _TARGET_ _SCOPE_
)
macro
(
target_enable_mtl4 _TARGET_ _SCOPE_
)
if
(
${
ARGC
}
GREATER 2
)
if
(
${
ARGC
}
GREATER 2
)
set
(
LINK_EXECUTABLE ON
)
set
(
LINK_EXECUTABLE ON
)
else
()
else
()
set
(
LINK_EXECUTABLE OFF
)
set
(
LINK_EXECUTABLE OFF
)
endif
()
endif
()
if
(
LINK_EXECUTABLE
)
if
(
LINK_EXECUTABLE
)
target_include_directories
(
${
_TARGET_
}
${
_SCOPE_
}
${
AMDIS_INCLUDE_DIR
}
/mtl4
)
target_include_directories
(
${
_TARGET_
}
${
_SCOPE_
}
${
AMDIS_INCLUDE_DIR
}
/mtl4
)
else
()
else
()
target_include_directories
(
${
_TARGET_
}
${
_SCOPE_
}
${
BASE_DIR
}
/lib/mtl4
)
target_include_directories
(
${
_TARGET_
}
${
_SCOPE_
}
${
BASE_DIR
}
/lib/mtl4
)
endif
(
LINK_EXECUTABLE
)
endif
(
LINK_EXECUTABLE
)
target_compile_definitions
(
${
_TARGET_
}
${
_SCOPE_
}
MTL_ASSERT_FOR_THROW=1
)
target_compile_definitions
(
${
_TARGET_
}
${
_SCOPE_
}
MTL_ASSERT_FOR_THROW=1
)
if
(
ENABLE_CXX11
)
set
(
CXX_ELEVEN_FEATURE_LIST
"MOVE"
"AUTO"
"RANGEDFOR"
"INITLIST"
"STATICASSERT"
"DEFAULTIMPL"
)
set
(
CXX_ELEVEN_FEATURE_LIST
"MOVE"
"AUTO"
"RANGEDFOR"
"INITLIST"
"STATICASSERT"
"DEFAULTIMPL"
)
foreach
(
feature
${
CXX_ELEVEN_FEATURE_LIST
}
)
foreach
(
feature
${
CXX_ELEVEN_FEATURE_LIST
}
)
target_compile_definitions
(
${
_TARGET_
}
${
_SCOPE_
}
MTL_WITH_
${
feature
}
)
target_compile_definitions
(
${
_TARGET_
}
${
_SCOPE_
}
MTL_WITH_
${
feature
}
)
endforeach
()
endforeach
()
endif
(
ENABLE_CXX11
)
if
(
ENABLE_OPENMP
)
find_package
(
OpenMP REQUIRED
)
if
(
OPENMP_FOUND
)
target_compile_definitions
(
${
_TARGET_
}
${
_SCOPE_
}
MTL_WITH_OPENMP
)
target_compile_options
(
${
_TARGET_
}
${
_SCOPE_
}
${
OpenMP_CXX_FLAGS
}
)
else
()
message
(
FATAL_ERROR
"OpenMP not found"
)
endif
(
OPENMP_FOUND
)
endif
(
ENABLE_OPENMP
)
if
(
ENABLE_OPENMP
)
find_package
(
OpenMP REQUIRED
)
if
(
OPENMP_FOUND
)
target_compile_definitions
(
${
_TARGET_
}
${
_SCOPE_
}
MTL_WITH_OPENMP
)
target_compile_options
(
${
_TARGET_
}
${
_SCOPE_
}
${
OpenMP_CXX_FLAGS
}
)
else
()
message
(
FATAL_ERROR
"OpenMP not found"
)
endif
(
OPENMP_FOUND
)
endif
(
ENABLE_OPENMP
)
endmacro
(
target_enable_mtl4
)
endmacro
(
target_enable_mtl4
)
AMDiS/src/DOFVector.hh
View file @
4de96d0f
...
@@ -124,8 +124,10 @@ namespace AMDiS {
...
@@ -124,8 +124,10 @@ namespace AMDiS {
{
{
this
->
name
=
n
;
this
->
name
=
n
;
this
->
feSpace
=
f
;
this
->
feSpace
=
f
;
if
(
this
->
feSpace
&&
this
->
feSpace
->
getAdmin
())
if
(
this
->
feSpace
&&
this
->
feSpace
->
getAdmin
())
(
this
->
feSpace
->
getAdmin
())
->
addDOFIndexed
(
this
);
(
this
->
feSpace
->
getAdmin
())
->
addDOFIndexed
(
this
);
this
->
boundaryManager
=
new
BoundaryManager
(
f
);
this
->
boundaryManager
=
new
BoundaryManager
(
f
);
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
if
(
addToSynch
&&
Parallel
::
MeshDistributor
::
globalMeshDistributor
!=
NULL
)
if
(
addToSynch
&&
Parallel
::
MeshDistributor
::
globalMeshDistributor
!=
NULL
)
...
@@ -140,6 +142,8 @@ namespace AMDiS {
...
@@ -140,6 +142,8 @@ namespace AMDiS {
if
(
Parallel
::
MeshDistributor
::
globalMeshDistributor
!=
NULL
)
if
(
Parallel
::
MeshDistributor
::
globalMeshDistributor
!=
NULL
)
Parallel
::
MeshDistributor
::
globalMeshDistributor
->
removeInterchangeVector
(
this
);
Parallel
::
MeshDistributor
::
globalMeshDistributor
->
removeInterchangeVector
(
this
);
#endif
#endif
#pragma omp critical
if
(
this
->
feSpace
&&
this
->
feSpace
->
getAdmin
())
if
(
this
->
feSpace
&&
this
->
feSpace
->
getAdmin
())
(
this
->
feSpace
->
getAdmin
())
->
removeDOFIndexed
(
this
);
(
this
->
feSpace
->
getAdmin
())
->
removeDOFIndexed
(
this
);
...
...
AMDiS/src/ElInfo1d.cc
View file @
4de96d0f
...
@@ -161,8 +161,6 @@ namespace AMDiS {
...
@@ -161,8 +161,6 @@ namespace AMDiS {
double
length
=
(
coord
[
1
][
0
]
-
a
);
double
length
=
(
coord
[
1
][
0
]
-
a
);
int
dim
=
mesh
->
getDim
();
int
dim
=
mesh
->
getDim
();
static
DimVec
<
double
>
vec
(
dim
,
NO_INIT
);
TEST_EXIT_DBG
(
lambda
)(
"lambda must not be NULL
\n
"
);
TEST_EXIT_DBG
(
lambda
)(
"lambda must not be NULL
\n
"
);
TEST_EXIT_DBG
(
dim
==
1
)(
"dim!=1
\n
"
);
TEST_EXIT_DBG
(
dim
==
1
)(
"dim!=1
\n
"
);
TEST_EXIT_DBG
(
dimOfWorld
==
dim
)(
"not yet for DIM != DIM_OF_WORLD
\n
"
);
TEST_EXIT_DBG
(
dimOfWorld
==
dim
)(
"not yet for DIM != DIM_OF_WORLD
\n
"
);
...
...
AMDiS/src/ElInfo2d.cc
View file @
4de96d0f
...
@@ -679,7 +679,6 @@ namespace AMDiS {
...
@@ -679,7 +679,6 @@ namespace AMDiS {
DimVec
<
WorldVector
<
double
>
>
edge
(
mesh
->
getDim
(),
NO_INIT
);
DimVec
<
WorldVector
<
double
>
>
edge
(
mesh
->
getDim
(),
NO_INIT
);
WorldVector
<
double
>
x
;
WorldVector
<
double
>
x
;
static
DimVec
<
double
>
vec
(
mesh
->
getDim
(),
NO_INIT
);
int
dim
=
mesh
->
getDim
();
int
dim
=
mesh
->
getDim
();
...
@@ -875,4 +874,4 @@ namespace AMDiS {
...
@@ -875,4 +874,4 @@ namespace AMDiS {
{
{
return
getSubElemCoordsMat
(
degree
);
return
getSubElemCoordsMat
(
degree
);
}
}
}
}
\ No newline at end of file
AMDiS/src/ElInfo3d.cc
View file @
4de96d0f
...
@@ -336,8 +336,6 @@ namespace AMDiS {
...
@@ -336,8 +336,6 @@ namespace AMDiS {
WorldVector
<
double
>
x
;
WorldVector
<
double
>
x
;
double
x0
,
det
,
det0
,
det1
,
det2
;
double
x0
,
det
,
det0
,
det1
,
det2
;
static
DimVec
<
double
>
vec
(
mesh
->
getDim
(),
NO_INIT
);
TEST_EXIT_DBG
(
lambda
)(
"lambda must not be NULL
\n
"
);
TEST_EXIT_DBG
(
lambda
)(
"lambda must not be NULL
\n
"
);
int
dim
=
mesh
->
getDim
();
int
dim
=
mesh
->
getDim
();
...
...
AMDiS/src/Global.cc
View file @
4de96d0f
...
@@ -317,7 +317,6 @@ namespace AMDiS {
...
@@ -317,7 +317,6 @@ namespace AMDiS {
int
d
=
-
1
;
int
d
=
-
1
;
// get dimension
// get dimension
TEST_EXIT
(
Parameters
::
initialized
())(
"Parameters not initialized!
\n
"
);
Parameters
::
get
(
"dimension of world"
,
d
,
0
);
Parameters
::
get
(
"dimension of world"
,
d
,
0
);
TEST_EXIT
(
d
>
0
)(
"Cannot initialize dimension!
\n
"
);
TEST_EXIT
(
d
>
0
)(
"Cannot initialize dimension!
\n
"
);
TEST_EXIT
((
d
==
1
)
||
(
d
==
2
)
||
(
d
==
3
))(
"Invalid world dimension %d!
\n
"
,
d
);
TEST_EXIT
((
d
==
1
)
||
(
d
==
2
)
||
(
d
==
3
))(
"Invalid world dimension %d!
\n
"
,
d
);
...
...
AMDiS/src/Initfile.cc
View file @
4de96d0f
...
@@ -67,17 +67,13 @@ namespace AMDiS {
...
@@ -67,17 +67,13 @@ namespace AMDiS {
}
}
}
}
Initfile
*
Initfile
::
singlett
=
NULL
;
std
::
set
<
std
::
string
>
Initfile
::
fn_include_list
;
/// initialize singleton object and global parameters
/// initialize singleton object an global parameters
void
Initfile
::
init
(
std
::
string
in
)
void
Initfile
::
init
(
std
::
string
in
)
{
{
initIntern
();
getIncludeList
().
clear
();
fn_include_list
.
clear
();
singlett
().
read
(
in
);
singlett
->
read
(
in
);
singlett
().
getInternalParameters
();
singlett
->
getInternalParameters
();
}
}
...
@@ -85,13 +81,13 @@ namespace AMDiS {
...
@@ -85,13 +81,13 @@ namespace AMDiS {
void
Initfile
::
read
(
std
::
string
fn
,
bool
force
)
void
Initfile
::
read
(
std
::
string
fn
,
bool
force
)
{
{
// read file if its not parsed already
// read file if its not parsed already
if
(
fn_i
nclude
_l
ist
.
find
(
fn
)
==
fn_i
nclude
_l
ist
.
end
()
||
force
)
{
if
(
getI
nclude
L
ist
()
.
find
(
fn
)
==
getI
nclude
L
ist
()
.
end
()
||
force
)
{
std
::
ifstream
inputFile
;
std
::
ifstream
inputFile
;
inputFile
.
open
(
fn
.
c_str
(),
std
::
ios
::
in
);
inputFile
.
open
(
fn
.
c_str
(),
std
::
ios
::
in
);
if
(
!
inputFile
.
is_open
())
if
(
!
inputFile
.
is_open
())
throw
runtime_error
(
"init-file '"
+
fn
+
"' cannot be opened for reading"
);
throw
runtime_error
(
"init-file '"
+
fn
+
"' cannot be opened for reading"
);
fn_i
nclude
_l
ist
.
insert
(
fn
);
getI
nclude
L
ist
()
.
insert
(
fn
);
read
(
inputFile
);
read
(
inputFile
);
}
}
}
}
...
@@ -233,8 +229,6 @@ namespace AMDiS {
...
@@ -233,8 +229,6 @@ namespace AMDiS {
void
Initfile
::
readArgv
(
std
::
string
parameters
,
int
debugInfo
)
void
Initfile
::
readArgv
(
std
::
string
parameters
,
int
debugInfo
)
{
{
initIntern
();
char
seperator
=
';'
;
char
seperator
=
';'
;
typedef
boost
::
escaped_list_separator
<
char
>
TokenizerFunc
;
typedef
boost
::
escaped_list_separator
<
char
>
TokenizerFunc
;
typedef
boost
::
tokenizer
<
TokenizerFunc
>
Tokenizer
;
typedef
boost
::
tokenizer
<
TokenizerFunc
>
Tokenizer
;
...
@@ -286,8 +280,7 @@ namespace AMDiS {
...
@@ -286,8 +280,7 @@ namespace AMDiS {
/// print all parameters to std::cout
/// print all parameters to std::cout
void
Initfile
::
printParameters
()
void
Initfile
::
printParameters
()
{
{
initIntern
();
for
(
Initfile
::
iterator
it
=
singlett
().
begin
();
it
!=
singlett
().
end
();
it
++
)
for
(
Initfile
::
iterator
it
=
singlett
->
begin
();
it
!=
singlett
->
end
();
it
++
)
std
::
cout
<<
(
*
it
).
first
<<
" => "
<<
(
*
it
).
second
<<
std
::
endl
;
std
::
cout
<<
(
*
it
).
first
<<
" => "
<<
(
*
it
).
second
<<
std
::
endl
;
}
}
...
...
AMDiS/src/Initfile.h
View file @
4de96d0f
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include
<boost/lexical_cast.hpp>
#include
<boost/lexical_cast.hpp>
#include
<boost/numeric/conversion/cast.hpp>
#include
<boost/numeric/conversion/cast.hpp>
#include
<boost/thread/shared_mutex.hpp>
// requires c++14
#include
<boost/type_traits.hpp>
#include
<boost/type_traits.hpp>
...
@@ -422,18 +423,19 @@ namespace AMDiS {
...
@@ -422,18 +423,19 @@ namespace AMDiS {
template
<
typename
T
>
template
<
typename
T
>
static
void
get
(
const
std
::
string
tag
,
T
&
value
,
int
debugInfo
=
-
1
)
static
void
get
(
const
std
::
string
tag
,
T
&
value
,
int
debugInfo
=
-
1
)
{
{
initIntern
();
// boost::shared_lock<boost::shared_mutex> lock(singlett().mutex_);
if
(
debugInfo
==
-
1
)
if
(
debugInfo
==
-
1
)
debugInfo
=
singlett
->
getMsgInfo
();
debugInfo
=
singlett
().
getMsgInfo
();
else
{
else
{
int
swap
(
debugInfo
);
int
swap
(
debugInfo
);
debugInfo
=
singlett
->
getMsgInfo
();
debugInfo
=
singlett
().
getMsgInfo
();
singlett
->
msgInfo
=
swap
;
singlett
().
msgInfo
=
swap
;
}
}
std
::
string
valStr
;
std
::
string
valStr
;
try
{
try
{
int
error_code
=
singlett
->
checkedGet
(
tag
,
valStr
);
int
error_code
=
singlett
().
checkedGet
(
tag
,
valStr
);
if
(
error_code
==
0
)
{
if
(
error_code
==
0
)
{
valStr
=
trim
(
valStr
);
valStr
=
trim
(
valStr
);
detail
::
convert
(
valStr
,
value
);
detail
::
convert
(
valStr
,
value
);
...
@@ -454,7 +456,7 @@ namespace AMDiS {
...
@@ -454,7 +456,7 @@ namespace AMDiS {
std
::
cout
<<
"Parameter '"
<<
tag
<<
"'"
std
::
cout
<<
"Parameter '"
<<
tag
<<
"'"
<<
" initialized with: "
<<
value
<<
std
::
endl
;
<<
" initialized with: "
<<
value
<<
std
::
endl
;
}
}
singlett
->
msgInfo
=
debugInfo
;
singlett
().
msgInfo
=
debugInfo
;
}
}
...
@@ -471,8 +473,7 @@ namespace AMDiS {
...
@@ -471,8 +473,7 @@ namespace AMDiS {
std
::
map
<
std
::
string
,
std
::
string
>
&
pm
,
std
::
map
<
std
::
string
,
std
::
string
>
&
pm
,
int
debugInfo
=
-
1
)
int
debugInfo
=
-
1
)
{
{
initIntern
();
for
(
Initfile
::
iterator
it
=
singlett
().
begin
();
it
!=
singlett
().
end
();
it
++
){
for
(
Initfile
::
iterator
it
=
singlett
->
begin
();
it
!=
singlett
->
end
();
it
++
){
std
::
string
longTag
=
(
*
it
).
first
;
std
::
string
longTag
=
(
*
it
).
first
;
std
::
string
value
=
(
*
it
).
second
;
std
::
string
value
=
(
*
it
).
second
;
if
(
longTag
.
length
()
>
tag
.
length
()
&&
if
(
longTag
.
length
()
>
tag
.
length
()
&&
...
@@ -497,10 +498,12 @@ namespace AMDiS {
...
@@ -497,10 +498,12 @@ namespace AMDiS {
/// return InitEntry object for tag tag
/// return InitEntry object for tag tag
static
InitEntry
get
(
const
std
::
string
tag
)
static
InitEntry
get
(
const
std
::
string
tag
)
{
{
// boost::shared_lock<boost::shared_mutex> lock(singlett().mutex_);
InitEntry
result
;
InitEntry
result
;
std
::
string
valStr
;
std
::
string
valStr
;
int
error_code
=
singlett
->
checkedGet
(
tag
,
valStr
);
int
error_code
=
singlett
().
checkedGet
(
tag
,
valStr
);
if
(
error_code
==
0
)
{
if
(
error_code
==
0
)
{
valStr
=
trim
(
valStr
);
valStr
=
trim
(
valStr
);
result
=
InitEntry
(
valStr
);
result
=
InitEntry
(
valStr
);
...
@@ -524,15 +527,16 @@ else if(error_code == TAG_NOT_FOUND_BREAK)
...
@@ -524,15 +527,16 @@ else if(error_code == TAG_NOT_FOUND_BREAK)
template
<
typename
T
>
template
<
typename
T
>
static
void
set
(
const
std
::
string
tag
,
T
&
value
,
int
debugInfo
=
-
1
)
static
void
set
(
const
std
::
string
tag
,
T
&
value
,
int
debugInfo
=
-
1
)
{
{
initIntern
();
// boost::unique_lock<boost::shared_mutex> lock(singlett().mutex_);
if
(
debugInfo
==
-
1
)
if
(
debugInfo
==
-
1
)
debugInfo
=
singlett
->
getMsgInfo
();
debugInfo
=
singlett
().
getMsgInfo
();
std
::
string
swap
=
""
;
std
::
string
swap
=
""
;
detail
::
convert
(
value
,
swap
);
detail
::
convert
(
value
,
swap
);
(
*
singlett
)[
trim
(
tag
)]
=
swap
;
singlett
(
)[
trim
(
tag
)]
=
swap
;
// update msg parameters msgInfo, msgWait, paramInfo
// update msg parameters msgInfo, msgWait, paramInfo
singlett
->
getInternalParameters
();
singlett
().
getInternalParameters
();
if
(
debugInfo
==
2
)
if
(
debugInfo
==
2
)
std
::
cout
<<
"Parameter '"
<<
tag
<<
"'"
std
::
cout
<<
"Parameter '"
<<
tag
<<
"'"
<<
" set to: "
<<
value
<<
std
::
endl
;
<<
" set to: "
<<
value
<<
std
::
endl
;
...
@@ -554,28 +558,14 @@ else if(error_code == TAG_NOT_FOUND_BREAK)
...
@@ -554,28 +558,14 @@ else if(error_code == TAG_NOT_FOUND_BREAK)
/// Returns specified info level
/// Returns specified info level
static
int
getMsgInfo
()
static
int
getMsgInfo
()
{
{
return
(
singlett
!=
NULL
)
?
singlett
->
msgInfo
:
0
;
return
singlett
().
msgInfo
;
}
}
/// Returns specified wait value
/// Returns specified wait value
static
int
getMsgWait
()
static
int
getMsgWait
()
{
{
return
(
singlett
!=
NULL
)
?
singlett
->
msgWait
:
0
;
return
singlett
().
msgWait
;
}
/// Checks whether parameters are initialized. if not, call init()
static
bool
initialized
()
{
return
(
singlett
!=
NULL
);
}
/// return pointer to singleton
static
Initfile
*
getSingleton
()
{
return
singlett
;
}
}
...
@@ -586,21 +576,24 @@ else if(error_code == TAG_NOT_FOUND_BREAK)
...
@@ -586,21 +576,24 @@ else if(error_code == TAG_NOT_FOUND_BREAK)
/// clear data in singleton
/// clear data in singleton
static
void
clearData
()
static
void
clearData
()
{
{
initIntern
();
singlett
().
clear
();
singlett
->
clear
();
}
}
/// save singlett-data to file with filename fn
/// save singlett-data to file with filename fn
static
void
save
(
std
::
string
fn
)
static
void
save
(
std
::
string
fn
)
{
{
initIntern
();
singlett
().
write
(
fn
);
singlett
->
write
(
fn
);
}
}
static
std
::
set
<
std
::
string
>
getIncludeList
(){
// list of included filenames
return
fn_include_list
;
static
std
::
set
<
std
::
string
>&
getIncludeList
()
{
static
std
::
set
<
std
::
string
>
include_list
;
return
include_list
;
}
}
protected:
protected:
Initfile
()
Initfile
()
:
msgInfo
(
0
),
:
msgInfo
(
0
),
...
@@ -609,22 +602,14 @@ protected:
...
@@ -609,22 +602,14 @@ protected:
breakOnMissingTag
(
0
)
breakOnMissingTag
(
0
)
{}
{}
/// return reference to singleton
static
void
initIntern
()
static
Initfile
&
singlett
()
{
{
if
(
singlett
==
NULL
)
static
Initfile
singlett_
{};
singlett
=
new
Initfile
;
return
singlett_
;
}
}
/// list of processed files
static
std
::
set
<
std
::
string
>
fn_include_list
;
/// pointer to the singleton that contains the data
static
Initfile
*
singlett
;
/// return the value of the given tag or throws an exception if the tag
/// return the value of the given tag or throws an exception if the tag
/// does not exist
/// does not exist
int
checkedGet
(
const
std
::
string
&
tag
,
std
::
string
&
valStr
)
const
int
checkedGet
(
const
std
::
string
&
tag
,
std
::
string
&
valStr
)
const
...
@@ -671,6 +656,8 @@ protected:
...
@@ -671,6 +656,8 @@ protected:
void
getInternalParameters
();
void
getInternalParameters
();
int
msgInfo
,
msgWait
,
paramInfo
,
breakOnMissingTag
;
int
msgInfo
,
msgWait
,
paramInfo
,
breakOnMissingTag
;
// mutable boost::shared_mutex mutex_;
};
};
typedef
Initfile
Parameters
;
typedef
Initfile
Parameters
;
...
...
configure.sh
View file @
4de96d0f
...
@@ -15,7 +15,7 @@ ENABLE_COMPRESSION="OFF"
...
@@ -15,7 +15,7 @@ ENABLE_COMPRESSION="OFF"
ENABLE_PARALLEL
=
"OFF"
ENABLE_PARALLEL
=
"OFF"
BOOST_PREFIX
=
"
${
BOOST_ROOT
}
"
BOOST_PREFIX
=
"
${
BOOST_ROOT
}
"
DOWNLOAD_BOOST
=
"0"
DOWNLOAD_BOOST
=
"0"
BOOST_VERSION
=
"1.6
2
.0"
BOOST_VERSION
=
"1.6
4
.0"
PETSC_PREFIX
=
"
${
PETSC_DIR
}
"
PETSC_PREFIX
=
"
${
PETSC_DIR
}
"
DOWNLOAD_PETSC
=
"0"
DOWNLOAD_PETSC
=
"0"
PETSC_VERSION
=
"3.5.4"
PETSC_VERSION
=
"3.5.4"
...
@@ -196,11 +196,11 @@ if [ "${DOWNLOAD_BOOST}" -eq "1" ]; then
...
@@ -196,11 +196,11 @@ if [ "${DOWNLOAD_BOOST}" -eq "1" ]; then
BOOST_PREFIX
=
${
SRC_DIR
}
/packages/boost/
${
BOOST_VERSION
}
BOOST_PREFIX
=
${
SRC_DIR
}
/packages/boost/
${
BOOST_VERSION
}
cd
/tmp/src/boost
cd
/tmp/src/boost
./bootstrap.sh
--prefix
=
${
BOOST_PREFIX
}
--with-libraries
=
system,iostreams,filesystem,program_options,date_time,test
./bootstrap.sh
--prefix
=
${
BOOST_PREFIX
}
--with-libraries
=
system,iostreams,filesystem,program_options,date_time,test
,thread
if
[
"
${
ENABLE_COMPRESSION
}
"
=
"ON"
]
;
then