shortened string and path assembly

This commit is contained in:
Philip Eisenlohr 2021-08-24 15:14:39 -04:00
parent 03622c5d9d
commit 4055bf9199
1 changed files with 4 additions and 8 deletions

View File

@ -48,19 +48,16 @@ class Marc:
compile = False, compile = False,
optimization = ''): optimization = ''):
usersub = self.damask_root/'src/DAMASK_Marc' usersub = (self.damask_root/'src/DAMASK_Marc').with_suffix('.f90' if compile else '.marc')
usersub = usersub.parent/(usersub.name + ('.f90' if compile else '.marc'))
if not usersub.is_file(): if not usersub.is_file():
raise FileNotFoundError(f'subroutine ({"source" if compile else "binary"}) "{usersub}" not found') raise FileNotFoundError(f'subroutine ({"source" if compile else "binary"}) "{usersub}" not found')
# Define options [see Marc Installation and Operation Guide, pp 23] # Define options [see Marc Installation and Operation Guide, pp 23]
script = f'run_damask_{optimization}mp' script = f'run_damask_{optimization}mp'
cmd = str(self.tools_path/script) + \ cmd = f'{self.tools_path/script} -jid {model}_{job} -nprocd 1 -autorst 0 -ci n -cr n -dcoup 0 -b no -v no ' \
' -jid ' + model+'_'+job + \ + (f'-u {usersub} -save y' if compile else f'-prog {usersub.with_suffix("")}')
' -nprocd 1 -autorst 0 -ci n -cr n -dcoup 0 -b no -v no'
cmd += ' -u ' + str(usersub) + ' -save y' if compile else \
' -prog ' + str(usersub.with_suffix(''))
print(cmd) print(cmd)
ret = subprocess.run(shlex.split(cmd),capture_output=True) ret = subprocess.run(shlex.split(cmd),capture_output=True)
@ -75,4 +72,3 @@ class Marc:
print(ret.stderr.decode()) print(ret.stderr.decode())
print(ret.stdout.decode()) print(ret.stdout.decode())
raise RuntimeError('Marc simulation failed (unknown return value)') raise RuntimeError('Marc simulation failed (unknown return value)')