Skip to content
Snippets Groups Projects
Commit 2eafd116 authored by Alain Schubiger's avatar Alain Schubiger
Browse files

module to submit jobs to hpc

parent cc925232
No related branches found
No related tags found
No related merge requests found
import os
import sys
from pathlib import Path
from subprocess import Popen, PIPE
import yaml
def subprocess_cmd(cmd):
global output
global error
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
stdout, stderr = proc.communicate()
output = stdout.decode(sys.getdefaultencoding())
error = stderr.decode(sys.getdefaultencoding())
num_nodes = 1
jobcomment = 'test'
wds = [90, 150, 240] # sectors to run, leave empty if sectors in yaml config should be used
fluent_version = 20.2
# read input config
with open('config.yaml') as f:
config = yaml.load(f, Loader=yaml.FullLoader)
site_name = config['site']['name']
sub_script = 'python /home/pool/poweruserhpc/scripts/submitScripts/subfluent.py'
if not wds:
wds = [x for x in config['setup']['wind_directions']]
parent = Path.cwd()
for wd in wds:
os.chdir(parent / 'simulation/rans' / f'winddir-{wd:03.0f}')
print(Path.cwd())
sub_cmd = f'{sub_script} -s 3ddp -f RANS.jou -n {num_nodes} -j {site_name}_{wd:03.0f}_{jobcomment} -v {fluent_version}'
print(sub_cmd)
subprocess_cmd(sub_cmd)
# os.chdir(parent)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment