bin – executable python scripts

Introduction

The python scripts in this directory are executable. They are useful for running BOUT++ code and data processing.

The following scripts only work on NERSC system:

  • jobstate.py
  • jobsubmit.py

Executable Scripts

The following executable scripts can be called directly in a terminal:

$ jobsubmit.py -d data -e ./elm_pb -n 512 -t 10:00 -qr -r
# -d data: path to store the BOUT.dmp.nc
# -e ./elm_pb: executable module
# -t 10:00: walltime limit, 10 mins
# -qr: regular queue
# -r: restart

compare_inp.py – Compare the BOUT.inp files

usage: compare_inp.py [-h] [-g] [-c] [-r] [-s] [configfiles [configfiles ...]]

get differences of configure files

positional arguments:
  configfiles   name of configure files (default: None)

optional arguments:
  -h, --help    show this help message and exit
  -g, --grid    output difference of grid names (default: True)
  -c, --case    case sensitive about the option value (default: True)
  -r, --render  render the output in terminal (default: True)
  -s, --short   use short name for cases name (default: True)

Examples:

$ compare_inp.py */n10/BOUT.inp
cases:
                     Name
case0  diamag/n10
case1  diamag_er_2Er/n10
case2  diamag_er_Er/n10
--------------------------------------------------
differences:
               case0 case1 case2
Er_factor      1.0    2.0   1.0
diamag_er      false  true  true
diamag_phi0    false  true  true
experiment_Er  false  true  true

See also

compare_inp

growthrate.py – calculate growth rate

usage: growthrate.py [-h] [-g [GRID]] [-G] [-x [X]] [-y [Y]] [-d]
                     [-D [DATABASE]] [-t [TIME]] [-o [OUTPUT]] [-v [VAR]]
                     [-c [CHECK]] [-C] [--savedb] [-i] [-p [PERCENT]]
                     [-k {c,contourf,s,surface,n,None}]
                     [dirs [dirs ...]]

Calculate the growth rate.

positional arguments:
  dirs                  Path to BOUT++ simulation data (default: [u'./'])

optional arguments:
  -h, --help            show this help message and exit
  -g [GRID], --grid [GRID]
                        Grid file name (default: None)
  -G, --Global          choose peak position of rms to calculate the growth
                        rate (default: False)
  -x [X]                Index in x-axis to calculate the growth rate (default
                        at peak rms) (default: None)
  -y [Y]                Index in y-axis to calculate the growth rate (default
                        at outer mid-plane) (default: None)
  -d, --data            Using data directory instead of case directory
                        (default: False)
  -D [DATABASE], --Database [DATABASE]
                        specify directory name to store the figs & data
                        (default: db)
  -t [TIME], --time [TIME]
                        Time range to calculate the growth rate (default:
                        -200,-1)
  -o [OUTPUT], --output [OUTPUT]
                        Filename of output (default: gamma_info)
  -v [VAR], --var [VAR]
                        Variable lists, separate with comma (default: P)
  -c [CHECK], --check [CHECK]
                        Variable lists, to be checked in BOUT.inp,separate
                        with comma, first one is the one scanned (default:
                        ZPERIOD)
  -C, --Case            store gamma info with options case sensitive (default:
                        True)
  --savedb              save figures and gamma info (default: True)
  -i, --info            Print more informations (default: False)
  -p [PERCENT], --percent [PERCENT]
                        Ignore percentage of both x-boundary to detect peak of
                        rms (default: 0.25)
  -k {c,contourf,s,surface,n,None}, --kind {c,contourf,s,surface,n,None}
                        plot type for 2D rms data (default: s)

gamma_plot.py – plot growthrate spectrum

usage: gamma_plot.py [-h] [-x [XVAR]] [-y [YVAR]] [-C] [-f [FILTER]]
                     [-t [THRESHOLD]] [-i]
                     [gamma_info [gamma_info ...]]

plot growth rate spectrum

positional arguments:
  gamma_info            files contain gamma info (default: ['gamma_fit_info'])

optional arguments:
  -h, --help            show this help message and exit
  -x [XVAR], --xvar [XVAR]
                        xaxis variable, `yvar vs. `xvar, `xvar should exist in
                        `gamma_info (default: ZPERIOD)
  -y [YVAR], --yvar [YVAR]
                        yaxis variable, `yvar vs. `xvar, `yvar should exist in
                        `gamma_info (default: gamma)
  -C, --Case            case sensitive in `gamma_info files (default: True)
  -f [FILTER], --filter [FILTER]
                        filter out `yvar using `filter, `threshold (default:
                        gamma)
  -t [THRESHOLD], --threshold [THRESHOLD]
                        threshold for the filter (default: < 0)
  -i, --info            print verbose information (default: False)

jobsubmit.py – submit serial jobs in NERSC

usage: jobsubmit.py [-h] [-a [AFTERANY]] [-c CPUS_PER_TASK]
                    [--cpu_bind [CPU_BIND]] [-d] [-e [EXE]] [-i] [-l [LABEL]]
                    [-L [LICENSE]] [-m JOB_NUM_MAX] [--mode [MODE]]
                    [-n NTASKS] [--ntasks-per-node NTASKS_PER_NODE] [-N NODES]
                    [-p {debug,regular,d,r}] [-r] [-t [TIME]]
                    [path [path ...]]

Python script for BOUT++ Job submission on NERSC

positional arguments:
  path                  working directories [default: ./]

optional arguments:
  -h, --help            show this help message and exit
  -a [AFTERANY], --afterany [AFTERANY]
                        defer job after the job `AFTERANY` finished
  -c CPUS_PER_TASK, --cpus_per_task CPUS_PER_TASK
                        run *cpus* threads per MPI task [default: 2(edison),
                        2(cori), 4(knl)]
  --cpu_bind [CPU_BIND]
                        [default: cores]
  -d, --data            the path is data_path [default: False]
  -e [EXE], --exe [EXE]
                        executable file name
  -i, --info            Print more informations [default: False]
  -l [LABEL], --label [LABEL]
                        label for job
  -L [LICENSE], --License [LICENSE]
                        specify the file system needed for jobs
  -m JOB_NUM_MAX, --job-num-max JOB_NUM_MAX
                        run this job for `job_num_max` times
  --mode [MODE]         KNL processor modes [default: quad,cache]
  -n NTASKS, --ntasks NTASKS
                        specify the number of tasks to run
  --ntasks-per-node NTASKS_PER_NODE
                        use ntasks per node [default: 24(edison), 32(cori),
                        64(knl)]
  -N NODES, --nodes NODES
                        number of nodes
  -p {debug,regular,d,r}, --partition {debug,regular,d,r}
                        specify the partition for the jobs [default: debug]
  -r, --restart         restart job [default: False]
  -t [TIME], --time [TIME]
                        specify the maximum wallclock time for the jobs
                        [default: 30:00]

jobstate.py – check & update & delete jobs

usage: jobstate.py [-h] [-d] [-u]

Check or modify jobs state

optional arguments:
  -h, --help    show this help message and exit
  -d, --delete  Delete jobs in queue (default: False)
  -u, --update  Modify jobs state (default: False)

scan.py – create parameter scan

usage: scan.py [-h] [-d] [-i] [-p [PREFIX]] [-r [RANGE]] [-t [TEMPLATE]]
               [-v [VAR]]

Parameters Scanning For BOUT++

optional arguments:
  -h, --help            show this help message and exit
  -d, --data            the path is data_path (default: False)
  -i, --info            Print more informations (default: False)
  -p [PREFIX], --prefix [PREFIX]
                        prefix of dirname (default: n)
  -r [RANGE], --range [RANGE]
                        range of variable for scanning, string delimited with
                        comma (default: 5, 10 ,20, 30, 40, 50)
  -t [TEMPLATE], --template [TEMPLATE]
                        template for parameters scanning, only change the
                        value of option "var" in BOUT.inp (default: dia-n2)
  -v [VAR], --var [VAR]
                        name of variable for scanning (default: ZPERIOD)