Passing arguments to qsub script

1,313 views
Skip to first unread message

William Harris

unread,
Jan 3, 2016, 5:32:45 PM1/3/16
to moose-users
I know how to change parameters in the MOOSE input file at the command line, as follows:

script.sh contains:

int_cond=0.0001
mpiexec ./tiger-opt -i ./Thermal.i Materials/HafniumAluminum/interface_cond=$int_cond

Then I can run on falcon with qsub script.sh. My goal is to systematically vary int_cond. I know that I could do ./script_sh argument1 to change int_cond from outside the script. but I do not know how to do the equivalent thing using the qsub command. Is there a way to do this?

Thank you,
Wil

john.m...@uconn.edu

unread,
Jan 3, 2016, 7:12:31 PM1/3/16
to moose-users
Not sure how to use your qsub

There is a python script floating around in this users group, I think Derek Gaston shared it a while back and it may be in MOOSE somewhere now. That script varied input file parameters and submits jobs, you might have to search for it.

Or you could use my cheap and lazy method, create N input files and then send your jobs as a batch. Here I changed the boundary condition (a pressure) instead of initial condition but in principle anything could be used. I use python to change the input files:

import os
import subprocess
import numpy as np

os
.chdir('/dir/')
pressure_vec
= np.linspace(-1.0e-08,1.0e-08,121)  

for t in range(0,121):
    infile
= open('/dir/vary_hydroP.i') # Define the base file we will be iteratively modifiying
    outfile
= open('/dir/newvary_hydroP-'+repr(t)+'.i', 'w') # Open the out file we will write at each step in the iteration

   
# Note that we are using -'+repr(t)+'.i' in order to loop over the path name. This is used again in the next line.

    replace
= {'pressure = default_pressure':'pressure = %s' % pressure_vec[t],'file_base = out_Surf_core_iso_shell':'file_base = out_Surf_core_iso_shell-'+repr(t)}
   
for ln in infile:
       
for src, target in replace.iteritems():
            ln
= ln.replace(src, target)
        outfile
.write(line)
    infile
.close()
    outfile
.close()


This just takes a base file and replaces the string  (here I'm replacing all pressure  = default_pressure to pressure = #) where # is a component of my N = 121 length vector. This is one way to do it, and we can thank a stackexchange post for this. If you try string replacing with other methods, sometimes it destroys the syntax of the input file, but this particular code preserves it.

Garvey, Cormac T

unread,
Jan 4, 2016, 1:57:06 PM1/4/16
to moose...@googlegroups.com
You could try exporting environmental variables to your pbs script.

e.g
qsub -v int_cond pbs_script.pbs

Then refer to $int_cond in your pbs script (pbs_script.pbs).

Thanks,
Cormac.

--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/moose-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/a0fca18b-9e61-435a-a9d6-b600680cd5a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Cormac Garvey
HPC Software Consultant
Scientific Computing
Idaho National Laboratory
Ph: 208-526-6294

Reply all
Reply to author
Forward
0 new messages