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
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
Backofen, Rainer
amdis
Commits
9eb8ad95
Commit
9eb8ad95
authored
15 years ago
by
Thomas Witkowski
Browse files
Options
Downloads
Patches
Plain Diff
Small code refactoring.
parent
a10991dc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AMDiS/src/Parameters.cc
+12
-72
12 additions, 72 deletions
AMDiS/src/Parameters.cc
with
12 additions
and
72 deletions
AMDiS/src/Parameters.cc
+
12
−
72
View file @
9eb8ad95
...
...
@@ -507,73 +507,16 @@ namespace AMDiS {
singlett
->
read
(
fn
);
}
else
{
singlett
->
inputFile
.
open
(
fn
.
data
(),
std
::
ios
::
in
);
if
(
!
(
singlett
->
inputFile
.
rdstate
()))
{
if
(
!
(
singlett
->
inputFile
.
rdstate
()))
{
ERROR
(
"can not read from file %s
\n
"
,
fn
.
data
());
return
;
}
singlett
->
inputFile
.
close
();
time
(
&
act_time
);
if
(
sys_test
(
"test -w"
,
"/tmp"
))
{
/* you may write to /tmp */
file
=
fn
.
substr
(
fn
.
find_last_of
(
"/
\\
"
));
tmp_file
<<
"/tmp/"
<<
file
<<
".cpp"
;
if
(
sys_test
(
"test -f"
,
tmp_file
.
str
()))
{
/* file exists :-( */
tmp_file
.
freeze
(
false
);
tmp_file
<<
"."
<<
static_cast
<
int
>
(
act_time
);
if
(
sys_test
(
"test -f"
,
tmp_file
.
str
()))
/* file exists :-( */
*
(
tmp_file
.
str
())
=
'\0'
;
}
}
if
(
*
(
tmp_file
.
str
())
==
'\0'
)
if
(
sys_test
(
"test -f"
,
tmp_file
.
str
()
+
5
))
*
(
tmp_file
.
str
())
=
'\0'
;
if
(
*
(
tmp_file
.
str
())
!=
'\0'
&&
(
outFile
.
open
(
tmp_file
.
str
())))
{
outFile
.
close
();
}
else
{
ERROR
(
"could not open temporary file for CPP
\n
"
);
ERROR
(
"can not write to /tmp and files %s.cpp and
\n
"
,
fn
);
ERROR_EXIT
(
"%s.cpp.%d either exist or are not writable
\n
"
,
fn
,
act_time
);
}
tmp_file
.
freeze
(
false
);
cpp_flags
<<
"-DDIM="
<<
DIM
<<
" -DDIM_OF_WORLD="
<<
Global
::
getGeo
(
WORLD
);
if
(
flags
)
cpp_flags
<<
flags
;
call_cpp
<<
CPP
<<
" "
<<
cpp_flags
<<
" "
<<
fn
<<
" > "
<<
tmp_file
;
/****************************************************************************/
/* invoke cpp: */
/****************************************************************************/
val
=
system
(
call_cpp
.
str
());
if
(
val
)
{
MSG
(
"val = %d
\n
"
,
val
);
ERROR
(
"error during cpp call; reading file %s without help of cpp
\n
"
,
fn
);
WAIT
;
init
(
p
,
fn
);
return
;
}
/**********************************************************************/
/* read parameters from temp file */
/**********************************************************************/
cpp_read
=
true
;
singlett
->
read
(
tmp_file
);
cpp_read
=
false
;
/**********************************************************************/
/* remove temp file */
/**********************************************************************/
sprintf
(
call_cpp
.
str
(),
"/bin/rm %s"
,
tmp_file
.
str
());
val
=
system
(
call_cpp
.
str
());
call_cpp
.
freeze
(
false
);
tmp_file
.
freeze
(
false
);
ERROR
(
"no cpp available; reading file %s without help of cpp
\n
"
,
fn
.
c_str
());
init
(
p
,
fn
);
return
;
}
val
=
10
;
// default for level of information
...
...
@@ -591,7 +534,7 @@ namespace AMDiS {
if
(
!
singlett
->
msgInfo
)
singlett
->
paramInfo
=
0
;
if
(
p
&&
singlett
->
msgInfo
)
if
(
p
&&
singlett
->
msgInfo
)
printParameters
();
Global
::
init
();
...
...
@@ -644,8 +587,6 @@ namespace AMDiS {
{
FUNCNAME
(
"Parameters::addGlobalParameter()"
);
int
val
;
initIntern
();
if
(
key
.
size
()
==
0
||
par
.
size
()
==
0
)
...
...
@@ -653,7 +594,7 @@ namespace AMDiS {
singlett
->
addParam
(
key
,
par
,
std
::
string
(
file
),
line
,
fname
);
val
=
10
;
// defualt for level of information
int
val
=
10
;
// defualt for level of information
getGlobalParameter
(
0
,
"level of information"
,
"%d"
,
&
val
);
singlett
->
msgInfo
=
val
;
...
...
@@ -683,13 +624,12 @@ namespace AMDiS {
return
NULL
;
int
wb2
=
s
->
find_first_of
(
" "
);
if
(
wb2
==
static_cast
<
int
>
(
std
::
string
::
npos
))
{
if
(
wb2
==
static_cast
<
int
>
(
std
::
string
::
npos
))
wb2
=
s
->
length
();
}
s
->
copy
(
Val
,
wb2
-
wb1
,
wb1
);
s
->
copy
(
Val
,
wb2
-
wb1
,
wb1
);
Val
[
wb2
-
wb1
]
=
'\0'
;
Val
[
wb2
-
wb1
]
=
'\0'
;
return
Val
;
}
...
...
@@ -702,7 +642,7 @@ namespace AMDiS {
initIntern
();
fp
.
open
(
file
.
data
(),
std
::
ios
::
out
);
if
(
0
!=
fp
.
rdstate
())
if
(
0
!=
fp
.
rdstate
())
return
;
for
(
it
=
singlett
->
allParam
.
begin
();
it
!=
singlett
->
allParam
.
end
();
it
++
)
{
...
...
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