Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jukkr
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kkr
jukkr
Commits
d6752570
Commit
d6752570
authored
3 years ago
by
Philipp Rüssmann
Browse files
Options
Downloads
Patches
Plain Diff
Update tests.py for KKRnano to python3
parent
d3642bed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/KKRnano/regtests/tests.py
+16
-15
16 additions, 15 deletions
source/KKRnano/regtests/tests.py
with
16 additions
and
15 deletions
source/KKRnano/regtests/tests.py
+
16
−
15
View file @
d6752570
...
...
@@ -28,18 +28,18 @@ def run_it(cmd):
"""
Run cmd, suppressing output. Returns output from stdout and exit code
"""
start_time
=
time
.
time
()
if
verbose
:
print
'
Run command
"
{0}
"'
.
format
(
cmd
)
print
(
'
Run command
"
{0}
"'
.
format
(
cmd
)
)
proc
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
close_fds
=
True
,
preexec_fn
=
os
.
setsid
,
shell
=
True
)
out
,
err
=
proc
.
communicate
()
end_time
=
time
.
time
()
tim
=
end_time
-
start_time
return
out
,
proc
.
returncode
,
tim
return
out
.
decode
(
'
utf-8
'
)
,
proc
.
returncode
,
tim
def
get_energy
(
string
):
try
:
match
=
list
(
re
.
finditer
(
r
"
^.*TOTAL ENERGY in ryd. :(.*)$
"
,
string
,
re
.
M
))[
-
1
]
# get last match only
except
:
print
string
print
(
string
)
raise
ArgumentError
if
match
is
not
None
:
return
float
(
match
.
group
(
1
))
...
...
@@ -49,14 +49,14 @@ def get_energy(string):
def
KKRnano
(
inputdir
,
nranks
=
DEFAULT_nranks
,
nthreads
=
DEFAULT_nthreads
,
solver
=
DEFAULT_solver
,
lmax
=
DEFAULT_lmax
,
Lly
=
DEFAULT_Lly
,
**
kwargs
):
"""
Run KKR-calculation with input from
'
inputdir
'
and returns the total energy
"""
if
verbose
:
print
"
start KKR for
"
,
inputdir
,
"
with lmax=
"
,
lmax
,
"
, solver=
"
,
solver
,
"
, nthreads=
"
,
nthreads
,
"
nranks=
"
,
nranks
print
'
test dir:
'
,
TESTDIR
print
(
"
start KKR for
"
,
inputdir
,
"
with lmax=
"
,
lmax
,
"
, solver=
"
,
solver
,
"
, nthreads=
"
,
nthreads
,
"
nranks=
"
,
nranks
)
print
(
'
test dir:
'
,
TESTDIR
)
out
,
err
,
tim
=
run_it
(
"
./clearfiles.sh
"
)
global
ShowMD5
if
ShowMD5
:
out
,
err
,
tim
=
run_it
(
"
md5sum ./kkr.exe
"
)
print
out
print
(
out
)
ShowMD5
=
False
## do not show again
for
file
in
glob
.
glob
(
os
.
path
.
join
(
inputdir
,
'
*
'
)):
...
...
@@ -87,21 +87,22 @@ def KKRnano(inputdir, nranks=DEFAULT_nranks, nthreads=DEFAULT_nthreads, solver=D
mpirun
=
'
srun -n
'
out
,
err
,
tim
=
run_it
(
"
OMP_STACKSIZE=80M OMP_NUM_THREADS={0}
"
.
format
(
int
(
nthreads
))
+
mpirun
+
"
{0} ./kkr.exe
"
.
format
(
int
(
nranks
)))
if
verbose
:
print
'
out
'
,
out
print
'
err
'
,
err
print
'
tim
'
,
tim
print
(
'
out
'
,
out
)
print
(
'
err
'
,
err
)
print
(
'
tim
'
,
tim
)
### grep the result
total_energy
=
get_energy
(
out
)
print
"
KKR for
"
,
inputdir
,
"
with lmax=
"
,
lmax
,
"
gives
"
,
total_energy
,
"
Ryd
"
,
msg
=
f
"
KKR for
{
inputdir
}
with lmax=
{
lmax
}
gives
{
total_energy
}
Ryd
"
if
solver
!=
DEFAULT_solver
:
print
"
, solver=
"
,
solver
,
msg
+=
f
"
, solver=
{
solver
}
"
if
nthreads
!=
DEFAULT_nthreads
:
print
"
, nthreads=
"
,
nthreads
,
msg
+=
f
"
, nthreads=
{
nthreads
}
"
if
nranks
!=
DEFAULT_nranks
:
print
"
, nranks=
"
,
nranks
,
msg
+=
f
"
, nranks=
{
nranks
}
"
if
Lly
!=
DEFAULT_Lly
:
print
"
, Lly=
"
,
Lly
,
print
"
in
"
,
tim
,
"
sec
"
msg
+=
f
"
, Lly=
{
Lly
}
"
msg
+=
f
"
in
{
tim
}
sec
"
print
(
msg
)
out
,
err
,
tim
=
run_it
(
"
./clearfiles.sh
"
)
return
total_energy
...
...
This diff is collapsed.
Click to expand it.
Philipp Rüssmann
@ruess
mentioned in commit
cbb5645d
·
2 years ago
mentioned in commit
cbb5645d
mentioned in commit cbb5645d48afdad6e29c449ffb1dc770c3ecb55f
Toggle commit list
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