Snippets

Bing Xia Array job templates

Created by Bing Xia
#!/usr/bin/env python
# Change first line to point to your python if needed
import sys
import linecache

if __name__ == "__main__":
    index = os.getenv("SGE_TASK_ID", None)
    if index is None:
        sys.exit(1)  # or whatever you want to do when it isn't run as an array job
    nslots = os.getenv("NSLOTS", None)
    if nslots is not None:
        os.environ['OMP_NUM_THREADS'] = nslots  # configure parallel environment
    
    # If reading parameters from a file, uncomment
    # param_file = sys.argv[1]
    # params = linecache.getline(param_file, index).strip()
    
    # Rest of script
1
2
3
4
5
6
7
8
#!/bin/sh
# Change first line to point to your favorite shell if needed

# Use environment variable ${SGE_TASK_ID} to grab a line from a parameter file
PARAM=$(sed -n "${SGE_TASK_ID}p" $1)

# Whatever your script needs to do
# cmd $PARAM

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.