Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lammps
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
multiscale
lammps
Commits
7d23a073
Commit
7d23a073
authored
8 years ago
by
Axel Kohlmeyer
Browse files
Options
Downloads
Patches
Plain Diff
add thorough checking for valid arguments to -partition or -p
parent
5d787f7f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/universe.cpp
+43
-11
43 additions, 11 deletions
src/universe.cpp
with
43 additions
and
11 deletions
src/universe.cpp
+
43
−
11
View file @
7d23a073
...
@@ -163,17 +163,49 @@ void Universe::add_world(char *str)
...
@@ -163,17 +163,49 @@ void Universe::add_world(char *str)
int
n
,
nper
;
int
n
,
nper
;
char
*
ptr
;
char
*
ptr
;
if
(
str
==
NULL
)
{
n
=
1
;
n
=
1
;
if
(
str
!=
NULL
)
{
nper
=
nprocs
;
}
else
if
((
ptr
=
strchr
(
str
,
'x'
))
!=
NULL
)
{
// check for valid partition argument
*
ptr
=
'\0'
;
n
=
atoi
(
str
);
bool
valid
=
true
;
nper
=
atoi
(
ptr
+
1
);
}
else
{
// str may not be empty and may only consist of digits or 'x'
n
=
1
;
nper
=
atoi
(
str
);
int
len
=
strlen
(
str
);
}
if
(
len
<
1
)
valid
=
false
;
for
(
int
i
=
0
;
i
<
len
;
++
i
)
if
(
isdigit
(
str
[
i
])
||
str
[
i
]
==
'x'
)
continue
;
else
valid
=
false
;
if
(
valid
)
{
if
((
ptr
=
strchr
(
str
,
'x'
))
!=
NULL
)
{
// 'x' may not be the first or last character
if
(
ptr
==
str
)
{
valid
=
false
;
}
else
if
(
strlen
(
str
)
==
len
-
1
)
{
valid
=
false
;
}
else
{
*
ptr
=
'\0'
;
n
=
atoi
(
str
);
nper
=
atoi
(
ptr
+
1
);
*
ptr
=
'x'
;
}
}
else
nper
=
atoi
(
str
);
}
// require minimum of 1 partition with 1 processor
if
(
n
<
1
||
nper
<
1
)
valid
=
false
;
if
(
!
valid
)
{
char
msg
[
128
];
sprintf
(
msg
,
"Invalid partition string '%s'"
,
str
);
error
->
universe_all
(
FLERR
,
msg
);
}
}
else
nper
=
nprocs
;
memory
->
grow
(
procs_per_world
,
nworlds
+
n
,
"universe:procs_per_world"
);
memory
->
grow
(
procs_per_world
,
nworlds
+
n
,
"universe:procs_per_world"
);
memory
->
grow
(
root_proc
,(
nworlds
+
n
),
"universe:root_proc"
);
memory
->
grow
(
root_proc
,(
nworlds
+
n
),
"universe:root_proc"
);
...
...
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