Repository: HECBioSim/Longbow

Issue:
redirects for stdout and stderr from schedulers
Self explanatory 

Discussion:

Patch:
diff --git a/longbow/schedulers/lsf.py b/longbow/schedulers/lsf.py
index eca4234..51dd4a2 100644
--- a/longbow/schedulers/lsf.py
+++ b/longbow/schedulers/lsf.py
@@ -129,22 +129,22 @@ def prepare(job):
     jobfile.write("#BSUB -n " + job["cores"] + "\n")
 
     # Redirect stdout
-    if job["stdout"] == "":
+    if job["stdout"] != "":
 
-        jobfile.write("#BSUB -o %J.out")
+        jobfile.write("#BSUB -o " + job["stdout"] + "\n")
 
     else:
 
-        jobfile.write("#BSUB -o " + job["stdout"])
+        jobfile.write("#BSUB -o %J.out" + "\n")
 
     # Redirect stderr
-    if job["stderr"] == "":
+    if job["stderr"] != "":
 
-        jobfile.write("#BSUB -e %J.err")
+        jobfile.write("#BSUB -e " + job["stderr"] + "\n")
 
     else:
 
-        jobfile.write("#BSUB -e " + job["stderr"])
+        jobfile.write("#BSUB -e %J.err" + "\n")
 
     # Load any custom scripts.
     if job["scripts"] != "":
diff --git a/longbow/schedulers/pbs.py b/longbow/schedulers/pbs.py
index dd5a1e1..4449614 100644
--- a/longbow/schedulers/pbs.py
+++ b/longbow/schedulers/pbs.py
@@ -160,6 +160,16 @@ def prepare(job):
         jobfile.write("#PBS -J 1-" + job["replicates"] + "\n")
         jobfile.write("#PBS -r y\n")
 
+    # Redirect stdout
+    if job["stdout"] != "":
+
+        jobfile.write("#PBS -o " + job["stdout"] + "\n")
+
+    # Redirect stderr
+    if job["stderr"] != "":
+
+        jobfile.write("#PBS -e " + job["stderr"] + "\n")
+
     # Set some environment variables for PBS.
     jobfile.write(
         "\n" + "export PBS_O_WORKDIR=$(readlink -f $PBS_O_WORKDIR)\n"
diff --git a/longbow/schedulers/sge.py b/longbow/schedulers/sge.py
index c1acd0f..fc0007f 100644
--- a/longbow/schedulers/sge.py
+++ b/longbow/schedulers/sge.py
@@ -126,6 +126,16 @@ def prepare(job):
         jobfile.write("#$ -pe " + job["sge-peflag"] + " " +
                       job["cores"] + "\n\n")
 
+    # Redirect stdout
+    if job["stdout"] != "":
+
+        jobfile.write("#$ -o " + job["stdout"] + "\n")
+
+    # Redirect stderr
+    if job["stderr"] != "":
+
+        jobfile.write("#$ -e " + job["stderr"] + "\n\n")
+
     # Load any custom scripts.
     if job["scripts"] != "":
 
diff --git a/longbow/schedulers/slurm.py b/longbow/schedulers/slurm.py
index 752e83a..e324aef 100644
--- a/longbow/schedulers/slurm.py
+++ b/longbow/schedulers/slurm.py
@@ -137,6 +137,16 @@ def prepare(job):
     # Walltime for job
     jobfile.write("#SBATCH -t " + job["maxtime"] + ":00\n\n")
 
+    # Redirect stdout
+    if job["stdout"] != "":
+
+        jobfile.write("#SBATCH -o " + job["stdout"] + "\n")
+
+    # Redirect stderr
+    if job["stderr"] != "":
+
+        jobfile.write("#SBATCH -e " + job["stderr"] + "\n\n")
+
     # Load any custom scripts.
     if job["scripts"] != "":
 
diff --git a/longbow/schedulers/soge.py b/longbow/schedulers/soge.py
index 9217a95..9b2560f 100644
--- a/longbow/schedulers/soge.py
+++ b/longbow/schedulers/soge.py
@@ -150,6 +150,16 @@ def prepare(job):
 
     jobfile.write("#$ -pe ib " + cores + "\n\n")
 
+    # Redirect stdout
+    if job["stdout"] != "":
+
+        jobfile.write("#$ -o " + job["stdout"] + "\n")
+
+    # Redirect stderr
+    if job["stderr"] != "":
+
+        jobfile.write("#$ -e " + job["stderr"] + "\n\n")
+
     # Load any custom scripts.
     if job["scripts"] != "":
 


Test patch:
diff --git a/tests/standards/lsf_submitfiles/case1.txt b/tests/standards/lsf_submitfiles/case1.txt
index f24ced2..323d567 100644
--- a/tests/standards/lsf_submitfiles/case1.txt
+++ b/tests/standards/lsf_submitfiles/case1.txt
@@ -3,7 +3,9 @@
 #BSUB -q debug
 #BSUB -W 24:00
 #BSUB -n 24
+#BSUB -o %J.out
+#BSUB -e %J.err
 
 module load amber
 
-mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
+mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/standards/lsf_submitfiles/case10.txt b/tests/standards/lsf_submitfiles/case10.txt
new file mode 100644
index 0000000..57ec0db
--- /dev/null
+++ b/tests/standards/lsf_submitfiles/case10.txt
@@ -0,0 +1,11 @@
+#!/bin/bash --login
+#BSUB -J testjob
+#BSUB -q debug
+#BSUB -W 24:00
+#BSUB -n 24
+#BSUB -o test.log
+#BSUB -e test.err
+
+module load amber
+
+mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/standards/lsf_submitfiles/case2.txt b/tests/standards/lsf_submitfiles/case2.txt
index 686a34b..9a2efa1 100644
--- a/tests/standards/lsf_submitfiles/case2.txt
+++ b/tests/standards/lsf_submitfiles/case2.txt
@@ -3,8 +3,10 @@
 #BSUB -q debug
 #BSUB -W 24:00
 #BSUB -n 24
+#BSUB -o %J.out
+#BSUB -e %J.err
 
 module load amber
 
 cd rep${LSB_JOBINDEX}/
-mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
+mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/standards/lsf_submitfiles/case3.txt b/tests/standards/lsf_submitfiles/case3.txt
index 5cff21b..d1a77bb 100644
--- a/tests/standards/lsf_submitfiles/case3.txt
+++ b/tests/standards/lsf_submitfiles/case3.txt
@@ -4,7 +4,9 @@
 #BSUB -m cluster1
 #BSUB -W 24:00
 #BSUB -n 24
+#BSUB -o %J.out
+#BSUB -e %J.err
 
 module load amber
 
-mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
+mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/standards/lsf_submitfiles/case4.txt b/tests/standards/lsf_submitfiles/case4.txt
index 143d16f..cde8f06 100644
--- a/tests/standards/lsf_submitfiles/case4.txt
+++ b/tests/standards/lsf_submitfiles/case4.txt
@@ -4,7 +4,9 @@
 #BSUB -P accno1234
 #BSUB -W 24:00
 #BSUB -n 24
+#BSUB -o %J.out
+#BSUB -e %J.err
 
 module load amber
 
-mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
+mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/standards/lsf_submitfiles/case5.txt b/tests/standards/lsf_submitfiles/case5.txt
index ccd1936..bcabb83 100644
--- a/tests/standards/lsf_submitfiles/case5.txt
+++ b/tests/standards/lsf_submitfiles/case5.txt
@@ -4,7 +4,9 @@
 #BSUB -F accno1234
 #BSUB -W 24:00
 #BSUB -n 24
+#BSUB -o %J.out
+#BSUB -e %J.err
 
 module load amber
 
-mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
+mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/standards/lsf_submitfiles/case6.txt b/tests/standards/lsf_submitfiles/case6.txt
index 96702bb..5c1ecb1 100644
--- a/tests/standards/lsf_submitfiles/case6.txt
+++ b/tests/standards/lsf_submitfiles/case6.txt
@@ -5,7 +5,9 @@
 #BSUB -u test.email@server.com
 #BSUB -W 24:00
 #BSUB -n 24
+#BSUB -o %J.out
+#BSUB -e %J.err
 
 module load amber
 
-mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
+mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/standards/lsf_submitfiles/case7.txt b/tests/standards/lsf_submitfiles/case7.txt
index 3136604..fcf31c4 100644
--- a/tests/standards/lsf_submitfiles/case7.txt
+++ b/tests/standards/lsf_submitfiles/case7.txt
@@ -3,10 +3,12 @@
 #BSUB -q debug
 #BSUB -W 24:00
 #BSUB -n 24
+#BSUB -o %J.out
+#BSUB -e %J.err
 
 ls /dir
 cd /dir
 
 module load amber
 
-mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
+mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/standards/lsf_submitfiles/case8.txt b/tests/standards/lsf_submitfiles/case8.txt
index 44b8244..5b7de26 100644
--- a/tests/standards/lsf_submitfiles/case8.txt
+++ b/tests/standards/lsf_submitfiles/case8.txt
@@ -3,6 +3,8 @@
 #BSUB -q debug
 #BSUB -W 24:00
 #BSUB -n 24
+#BSUB -o %J.out
+#BSUB -e %J.err
 
 module load amber
 
diff --git a/tests/standards/lsf_submitfiles/case9.txt b/tests/standards/lsf_submitfiles/case9.txt
index 60275d9..2f8b28d 100644
--- a/tests/standards/lsf_submitfiles/case9.txt
+++ b/tests/standards/lsf_submitfiles/case9.txt
@@ -4,6 +4,8 @@
 #BSUB -R "rusage[mem=10G]"
 #BSUB -W 24:00
 #BSUB -n 24
+#BSUB -o %J.out
+#BSUB -e %J.err
 
 module load amber
 
diff --git a/tests/standards/pbs_submitfiles/case10.txt b/tests/standards/pbs_submitfiles/case10.txt
new file mode 100644
index 0000000..350cdac
--- /dev/null
+++ b/tests/standards/pbs_submitfiles/case10.txt
@@ -0,0 +1,15 @@
+#!/bin/bash --login
+#PBS -N testjob
+#PBS -q debug
+#PBS -l select=1:ncpus=24:mpiprocs=24
+#PBS -l walltime=24:00:00
+#PBS -o test.log
+#PBS -e test.err
+
+export PBS_O_WORKDIR=$(readlink -f $PBS_O_WORKDIR)
+cd $PBS_O_WORKDIR
+export OMP_NUM_THREADS=1
+
+module load amber
+
+mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/standards/sge_submitfiles/case9.txt b/tests/standards/sge_submitfiles/case9.txt
new file mode 100644
index 0000000..206fde0
--- /dev/null
+++ b/tests/standards/sge_submitfiles/case9.txt
@@ -0,0 +1,13 @@
+#!/bin/bash --login
+#$ -cwd -V
+#$ -N testjob
+#$ -q debug
+#$ -l h_rt=24:00:00
+#$ -pe mpi 24
+
+#$ -o test.log
+#$ -e test.err
+
+module load amber
+
+mpirun -n 24 pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/standards/slurm_submitfiles/case9.txt b/tests/standards/slurm_submitfiles/case9.txt
new file mode 100644
index 0000000..6133488
--- /dev/null
+++ b/tests/standards/slurm_submitfiles/case9.txt
@@ -0,0 +1,13 @@
+#!/bin/bash --login
+#SBATCH -J testjob
+#SBATCH -p debug
+#SBATCH -n 24
+#SBATCH -N 1
+#SBATCH -t 24:00:00
+
+#SBATCH -o test.log
+#SBATCH -e test.err
+
+module load amber
+
+mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/standards/soge_submitfiles/case9.txt b/tests/standards/soge_submitfiles/case9.txt
new file mode 100644
index 0000000..c8f1dc6
--- /dev/null
+++ b/tests/standards/soge_submitfiles/case9.txt
@@ -0,0 +1,14 @@
+#!/bin/bash --login
+#$ -cwd -V
+#$ -N testjob
+#$ -q debug
+#$ -l h_rt=24:00:00
+#$ -l nodes=1
+#$ -pe ib 24
+
+#$ -o test.log
+#$ -e test.err
+
+module load amber
+
+mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
diff --git a/tests/unit/schedulers_lsf/test_lsf_prepare.py b/tests/unit/schedulers_lsf/test_lsf_prepare.py
index e22c2b9..9813208 100644
--- a/tests/unit/schedulers_lsf/test_lsf_prepare.py
+++ b/tests/unit/schedulers_lsf/test_lsf_prepare.py
@@ -59,6 +59,8 @@ def test_prepare_case1():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -94,6 +96,8 @@ def test_prepare_case2():
         "modules": "amber",
         "queue": "debug",
         "replicates": "5",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -127,6 +131,8 @@ def test_prepare_case3():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -161,6 +167,8 @@ def test_prepare_case4():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -195,6 +203,8 @@ def test_prepare_case5():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -229,6 +239,8 @@ def test_prepare_case6():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -263,6 +275,8 @@ def test_prepare_case7():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "ls /dir, cd /dir",
         "upload-include": "file1, file2"
     }
@@ -297,6 +311,8 @@ def test_prepare_case8():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -331,6 +347,8 @@ def test_prepare_case9():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -341,3 +359,40 @@ def test_prepare_case9():
         os.path.join(
             os.getcwd(),
             "tests/standards/lsf_submitfiles/case9.txt"), "rb").read()
+
+
+def test_prepare_case10():
+
+    """
+    Stdout and stderr check
+    """
+
+    job = {
+        "account": "",
+        "cores": "24",
+        "executableargs": "pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out",
+        "handler": "mpirun",
+        "email-address": "",
+        "email-flags": "",
+        "jobname": "testjob",
+        "localworkdir": "/tmp",
+        "lsf-cluster": "",
+        "maxtime": "24:00",
+        "memory": "",
+        "modules": "amber",
+        "queue": "debug",
+        "replicates": "1",
+        "stdout": "test.log",
+        "stderr": "test.err",
+        "scripts": "",
+        "upload-include": "file1, file2"
+    }
+
+    prepare(job)
+
+    assert job["subfile"] == "submit.lsf"
+    assert job["upload-include"] == "file1, file2, submit.lsf"
+    assert open("/tmp/submit.lsf", "rb").read() == open(
+        os.path.join(
+            os.getcwd(),
+            "tests/standards/lsf_submitfiles/case10.txt"), "rb").read()
diff --git a/tests/unit/schedulers_pbs/test_pbs_prepare.py b/tests/unit/schedulers_pbs/test_pbs_prepare.py
index 80405f0..b8b04f9 100644
--- a/tests/unit/schedulers_pbs/test_pbs_prepare.py
+++ b/tests/unit/schedulers_pbs/test_pbs_prepare.py
@@ -60,6 +60,8 @@ def test_prepare_case1():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -96,6 +98,8 @@ def test_prepare_case2():
         "modules": "amber",
         "queue": "debug",
         "replicates": "5",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -130,6 +134,8 @@ def test_prepare_case3():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -165,6 +171,8 @@ def test_prepare_case4():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -200,6 +208,8 @@ def test_prepare_case5():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -235,6 +245,8 @@ def test_prepare_case6():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -270,6 +282,8 @@ def test_prepare_case7():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "ls /dir, cd /dir",
         "upload-include": "file1, file2"
     }
@@ -305,6 +319,8 @@ def test_prepare_case8():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -340,6 +356,8 @@ def test_prepare_case9():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "upload-include": "file1, file2"
     }
@@ -350,3 +368,41 @@ def test_prepare_case9():
         os.path.join(
             os.getcwd(),
             "tests/standards/pbs_submitfiles/case9.txt"), "rb").read()
+
+
+def test_prepare_case10():
+
+    """
+    stdout and stderr test.
+    """
+
+    job = {
+        "account": "",
+        "cluster": "",
+        "cores": "24",
+        "corespernode": "24",
+        "executableargs": "pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out",
+        "handler": "mpirun",
+        "email-address": "",
+        "email-flags": "",
+        "jobname": "testjob",
+        "localworkdir": "/tmp",
+        "maxtime": "24:00",
+        "memory": "",
+        "modules": "amber",
+        "queue": "debug",
+        "replicates": "1",
+        "stdout": "test.log",
+        "stderr": "test.err",
+        "scripts": "",
+        "upload-include": "file1, file2"
+    }
+
+    prepare(job)
+
+    assert job["subfile"] == "submit.pbs"
+    assert job["upload-include"] == "file1, file2, submit.pbs"
+    assert open("/tmp/submit.pbs", "rb").read() == open(
+        os.path.join(
+            os.getcwd(),
+            "tests/standards/pbs_submitfiles/case10.txt"), "rb").read()
diff --git a/tests/unit/schedulers_sge/test_sge_prepare.py b/tests/unit/schedulers_sge/test_sge_prepare.py
index a462308..4a6c03d 100644
--- a/tests/unit/schedulers_sge/test_sge_prepare.py
+++ b/tests/unit/schedulers_sge/test_sge_prepare.py
@@ -60,6 +60,8 @@ def test_prepare_case1():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -98,6 +100,8 @@ def test_prepare_case2():
         "modules": "amber",
         "queue": "debug",
         "replicates": "5",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -135,6 +139,8 @@ def test_prepare_case3():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -172,6 +178,8 @@ def test_prepare_case4():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -209,6 +217,8 @@ def test_prepare_case5():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -246,6 +256,8 @@ def test_prepare_case6():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "ls /dir, cd /dir",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -283,6 +295,8 @@ def test_prepare_case7():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -320,6 +334,8 @@ def test_prepare_case8():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -332,3 +348,43 @@ def test_prepare_case8():
         os.path.join(
             os.getcwd(),
             "tests/standards/sge_submitfiles/case8.txt"), "rb").read()
+
+
+def test_prepare_case9():
+
+    """
+    stdout and stderr test
+    """
+
+    job = {
+        "account": "",
+        "cluster": "",
+        "cores": "24",
+        "corespernode": "",
+        "executableargs": "pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out",
+        "handler": "mpirun",
+        "email-address": "",
+        "email-flags": "",
+        "jobname": "testjob",
+        "localworkdir": "/tmp",
+        "maxtime": "24:00",
+        "memory": "",
+        "modules": "amber",
+        "queue": "debug",
+        "replicates": "1",
+        "stdout": "test.log",
+        "stderr": "test.err",
+        "scripts": "",
+        "sge-peflag": "mpi",
+        "sge-peoverride": "false",
+        "upload-include": "file1, file2"
+    }
+
+    prepare(job)
+
+    assert job["subfile"] == "submit.sge"
+    assert job["upload-include"] == "file1, file2, submit.sge"
+    assert open("/tmp/submit.sge", "rb").read() == open(
+        os.path.join(
+            os.getcwd(),
+            "tests/standards/sge_submitfiles/case9.txt"), "rb").read()
diff --git a/tests/unit/schedulers_slurm/test_slurm_prepare.py b/tests/unit/schedulers_slurm/test_slurm_prepare.py
index f40bebe..d4bdd96 100644
--- a/tests/unit/schedulers_slurm/test_slurm_prepare.py
+++ b/tests/unit/schedulers_slurm/test_slurm_prepare.py
@@ -60,6 +60,8 @@ def test_prepare_case1():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "slurm-gres": "",
         "sge-peflag": "mpi",
@@ -99,6 +101,8 @@ def test_prepare_case2():
         "modules": "amber",
         "queue": "debug",
         "replicates": "5",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "slurm-gres": "",
         "sge-peflag": "mpi",
@@ -137,6 +141,8 @@ def test_prepare_case3():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "slurm-gres": "",
         "sge-peflag": "mpi",
@@ -175,6 +181,8 @@ def test_prepare_case4():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "slurm-gres": "",
         "sge-peflag": "mpi",
@@ -213,6 +221,8 @@ def test_prepare_case5():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "slurm-gres": "",
         "sge-peflag": "mpi",
@@ -251,6 +261,8 @@ def test_prepare_case6():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "ls /dir, cd /dir",
         "slurm-gres": "",
         "sge-peflag": "mpi",
@@ -289,6 +301,8 @@ def test_prepare_case7():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "ls /dir, cd /dir",
         "slurm-gres": "gpu:1",
         "sge-peflag": "mpi",
@@ -327,6 +341,8 @@ def test_prepare_case8():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "ls /dir, cd /dir",
         "slurm-gres": "gpu:1",
         "sge-peflag": "mpi",
@@ -340,3 +356,44 @@ def test_prepare_case8():
         os.path.join(
             os.getcwd(),
             "tests/standards/slurm_submitfiles/case8.txt"), "rb").read()
+
+
+def test_prepare_case9():
+
+    """
+    Simple test
+    """
+
+    job = {
+        "account": "",
+        "cluster": "",
+        "cores": "24",
+        "corespernode": "24",
+        "executableargs": "pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out",
+        "handler": "mpirun",
+        "email-address": "",
+        "email-flags": "",
+        "jobname": "testjob",
+        "localworkdir": "/tmp",
+        "maxtime": "24:00",
+        "memory": "",
+        "modules": "amber",
+        "queue": "debug",
+        "replicates": "1",
+        "stdout": "test.log",
+        "stderr": "test.err",
+        "scripts": "",
+        "slurm-gres": "",
+        "sge-peflag": "mpi",
+        "sge-peoverride": "false",
+        "upload-include": "file1, file2"
+    }
+
+    prepare(job)
+
+    assert job["subfile"] == "submit.slurm"
+    assert job["upload-include"] == "file1, file2, submit.slurm"
+    assert open("/tmp/submit.slurm", "rb").read() == open(
+        os.path.join(
+            os.getcwd(),
+            "tests/standards/slurm_submitfiles/case9.txt"), "rb").read()
diff --git a/tests/unit/schedulers_soge/test_soge_prepare.py b/tests/unit/schedulers_soge/test_soge_prepare.py
index dbf9615..f307921 100644
--- a/tests/unit/schedulers_soge/test_soge_prepare.py
+++ b/tests/unit/schedulers_soge/test_soge_prepare.py
@@ -60,6 +60,8 @@ def test_prepare_case1():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -98,6 +100,8 @@ def test_prepare_case2():
         "modules": "amber",
         "queue": "debug",
         "replicates": "5",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -135,6 +139,8 @@ def test_prepare_case3():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -172,6 +178,8 @@ def test_prepare_case4():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -209,6 +217,8 @@ def test_prepare_case5():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -246,6 +256,8 @@ def test_prepare_case6():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "ls /dir, cd /dir",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -283,6 +295,8 @@ def test_prepare_case7():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -320,6 +334,8 @@ def test_prepare_case8():
         "modules": "amber",
         "queue": "debug",
         "replicates": "1",
+        "stdout": "",
+        "stderr": "",
         "scripts": "",
         "sge-peflag": "mpi",
         "sge-peoverride": "false",
@@ -332,3 +348,43 @@ def test_prepare_case8():
         os.path.join(
             os.getcwd(),
             "tests/standards/soge_submitfiles/case8.txt"), "rb").read()
+
+
+def test_prepare_case9():
+
+    """
+    stdout and stderr test.
+    """
+
+    job = {
+        "account": "",
+        "cluster": "",
+        "cores": "24",
+        "corespernode": "24",
+        "executableargs": "pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out",
+        "handler": "mpirun",
+        "email-address": "",
+        "email-flags": "",
+        "jobname": "testjob",
+        "localworkdir": "/tmp",
+        "maxtime": "24:00",
+        "memory": "",
+        "modules": "amber",
+        "queue": "debug",
+        "replicates": "1",
+        "stdout": "test.log",
+        "stderr": "test.err",
+        "scripts": "",
+        "sge-peflag": "mpi",
+        "sge-peoverride": "false",
+        "upload-include": "file1, file2"
+    }
+
+    prepare(job)
+
+    assert job["subfile"] == "submit.soge"
+    assert job["upload-include"] == "file1, file2, submit.soge"
+    assert open("/tmp/submit.soge", "rb").read() == open(
+        os.path.join(
+            os.getcwd(),
+            "tests/standards/soge_submitfiles/case9.txt"), "rb").read()