Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iwr
amdis
Commits
14ae585a
Commit
14ae585a
authored
14 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
read vector-parameters from init-files by %E,%F,%G or %D
parent
8c586a2d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
AMDiS/src/AdaptInfo.h
+6
-0
6 additions, 0 deletions
AMDiS/src/AdaptInfo.h
AMDiS/src/Parameters.cc
+63
-0
63 additions, 0 deletions
AMDiS/src/Parameters.cc
AMDiS/src/Parameters.h
+14
-2
14 additions, 2 deletions
AMDiS/src/Parameters.h
with
83 additions
and
2 deletions
AMDiS/src/AdaptInfo.h
+
6
−
0
View file @
14ae585a
...
@@ -369,6 +369,12 @@ namespace AMDiS {
...
@@ -369,6 +369,12 @@ namespace AMDiS {
return
nTimesteps
;
return
nTimesteps
;
}
}
/// Sets \ref nTimesteps.
inline
void
setNumberOfTimesteps
(
int
num
)
{
nTimesteps
=
num
;
}
/// Increments \ref timestepNumber by 1;
/// Increments \ref timestepNumber by 1;
inline
void
incTimestepNumber
()
inline
void
incTimestepNumber
()
{
{
...
...
This diff is collapsed.
Click to expand it.
AMDiS/src/Parameters.cc
+
63
−
0
View file @
14ae585a
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
namespace
AMDiS
{
namespace
AMDiS
{
const
char
Parameters
::
comment
=
'%'
;
const
char
Parameters
::
comment
=
'%'
;
const
std
::
string
Parameters
::
separators
=
",; "
;
Parameters
*
Parameters
::
singlett
=
NULL
;
Parameters
*
Parameters
::
singlett
=
NULL
;
const
char
*
Parameters
::
param_call_fct
=
NULL
;
const
char
*
Parameters
::
param_call_fct
=
NULL
;
const
char
*
Parameters
::
param_call_file
=
NULL
;
const
char
*
Parameters
::
param_call_file
=
NULL
;
...
@@ -158,6 +159,68 @@ namespace AMDiS {
...
@@ -158,6 +159,68 @@ namespace AMDiS {
(
*
vecVal
)[
ind
]
=
atof
(
sstr
.
c_str
());
(
*
vecVal
)[
ind
]
=
atof
(
sstr
.
c_str
());
}
}
break
;
break
;
case
'E'
:
// list of double values, example parameter: {a,b,c,d,e}
case
'F'
:
case
'G'
:
{
std
::
vector
<
double
>
*
vecVal
=
va_arg
(
arg
,
std
::
vector
<
double
>
*
);
std
::
string
sstr
=
std
::
string
(
word
);
std
::
string
brackets1
=
"[{("
,
brackets2
=
"]})"
;
int
bracketIdx1
=
sstr
.
find_first_of
(
brackets1
);
int
bracket
=
brackets1
.
find_first_of
(
sstr
[
bracketIdx1
]);
int
bracketIdx2
=
sstr
.
find_first_of
(
brackets2
[
bracket
]);
TEST_EXIT
(
bracket
>=
0
&&
bracketIdx1
>=
0
&&
bracketIdx2
>=
0
&&
bracketIdx1
<
bracketIdx2
)
(
"no enclosing brackets found in '%s'
\n
"
,
key
.
data
());
sstr
=
sstr
.
substr
(
bracketIdx1
+
1
,
bracketIdx2
-
bracketIdx1
);
int
found
=
sstr
.
find_first_of
(
separators
);
std
::
string
seperator
;
seperator
=
sstr
[
found
];
while
(
found
!=
static_cast
<
int
>
(
std
::
string
::
npos
))
{
if
(
found
>
0
)
{
vecVal
->
push_back
(
atof
(
sstr
.
substr
(
0
,
found
).
c_str
()));
}
sstr
=
sstr
.
substr
(
found
+
1
);
found
=
sstr
.
find_first_of
(
seperator
);
}
if
(
sstr
.
length
()
>
0
)
vecVal
->
push_back
(
atof
(
sstr
.
c_str
()));
if
(
vecVal
->
size
()
==
0
)
WARNING
(
"no values in parameter vector!
\n
"
);
}
break
;
case
'D'
:
// list of int values, example parameter: {a,b,c,d,e}
{
std
::
vector
<
int
>
*
vecVal
=
va_arg
(
arg
,
std
::
vector
<
int
>
*
);
std
::
string
sstr
=
std
::
string
(
word
);
std
::
string
brackets1
=
"[{("
,
brackets2
=
"]})"
;
int
bracketIdx1
=
sstr
.
find_first_of
(
brackets1
);
int
bracket
=
brackets1
.
find_first_of
(
sstr
[
bracketIdx1
]);
int
bracketIdx2
=
sstr
.
find_first_of
(
brackets2
[
bracket
]);
TEST_EXIT
(
bracket
>=
0
&&
bracketIdx1
>=
0
&&
bracketIdx2
>=
0
&&
bracketIdx1
<
bracketIdx2
)
(
"no enclosing brackets found in '%s'
\n
"
,
key
.
data
());
sstr
=
sstr
.
substr
(
bracketIdx1
+
1
,
bracketIdx2
-
bracketIdx1
);
int
found
=
sstr
.
find_first_of
(
separators
);
std
::
string
seperator
;
seperator
=
sstr
[
found
];
while
(
found
!=
static_cast
<
int
>
(
std
::
string
::
npos
))
{
if
(
found
>
0
)
{
vecVal
->
push_back
(
atoi
(
sstr
.
substr
(
0
,
found
).
c_str
()));
}
sstr
=
sstr
.
substr
(
found
+
1
);
found
=
sstr
.
find_first_of
(
seperator
);
}
if
(
sstr
.
length
()
>
0
)
vecVal
->
push_back
(
atoi
(
sstr
.
c_str
()));
if
(
vecVal
->
size
()
==
0
)
WARNING
(
"no values in parameter vector!
\n
"
);
}
break
;
case
'*'
:
case
'*'
:
break
;
break
;
default
:
default
:
...
...
This diff is collapsed.
Click to expand it.
AMDiS/src/Parameters.h
+
14
−
2
View file @
14ae585a
...
@@ -122,7 +122,8 @@ namespace AMDiS {
...
@@ -122,7 +122,8 @@ namespace AMDiS {
* The return value is the number of converted arguments.
* The return value is the number of converted arguments.
*
*
* The control string must only contain the following characters used as
* The control string must only contain the following characters used as
* conversion specification: \%s, \%c, \%d, \%e, \%f, \%g, \%U, \%S, or \%*.
* conversion specification: \%s, \%c, \%d, \%D, \%e, \%E, \%f, \%F, \%g, \%G,
* \%U, \%S, or \%*.
* All other characters are ignored. In contrast to scanf(), a numerical
* All other characters are ignored. In contrast to scanf(), a numerical
* value for a field width is not allowed. For each element of the control
* value for a field width is not allowed. For each element of the control
* string the next word of the parameter string is converted as follows:
* string the next word of the parameter string is converted as follows:
...
@@ -143,11 +144,21 @@ namespace AMDiS {
...
@@ -143,11 +144,21 @@ namespace AMDiS {
* the subject sequence of the atoi() function; the corresponding
* the subject sequence of the atoi() function; the corresponding
* argument should be a pointer to an int variable;
* argument should be a pointer to an int variable;
*
*
* -\%e,%f,%g: matches an optionally signed floating point number, whose
* -\%D: matches a list of %d types; the corresponding argument should
* be a pointer to a std::vector<int> variable; the
* parameter should be enclosed in brackets, like {...}, [...] or (...)
* and the values separated by comma, semicolon or space;
*
* -\%e,\%f,\%g: matches an optionally signed floating point number, whose
* format is the same as expected for the subject string of the atof()
* format is the same as expected for the subject string of the atof()
* function; the corresponding argument should be a pointer to a double
* function; the corresponding argument should be a pointer to a double
* variable;
* variable;
*
*
* -\%E,\%F,\%G: matches a list of %e,%f or %g types; the corresponding argument
* should be a pointer to a std::vector<double> variable; the
* parameter should be enclosed in brackets, like {...}, [...] or (...)
* and the values separated by comma, semicolon or space;
*
* -\%U: matches an unsigned decimal integer in the range [0,255], whose
* -\%U: matches an unsigned decimal integer in the range [0,255], whose
* format is the same as expected for the subject sequence of the
* format is the same as expected for the subject sequence of the
* atoi() function; the corresponding argument should be a pointer to
* atoi() function; the corresponding argument should be a pointer to
...
@@ -279,6 +290,7 @@ namespace AMDiS {
...
@@ -279,6 +290,7 @@ namespace AMDiS {
};
};
static
const
char
comment
;
static
const
char
comment
;
static
const
std
::
string
separators
;
std
::
string
buffer
;
std
::
string
buffer
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment