フィルターのクリア

Passing JobID to Matlab Script (not Function) in Submitting Multiple Jobs

1 回表示 (過去 30 日間)
Esma Ozer
Esma Ozer 2021 年 10 月 26 日
編集済み: Esma Ozer 2021 年 10 月 26 日
In my main script, I call a function and within that function I call stata (with system command) where it takes input from matlab and then matlab calls the output of this stata command. I want each of these input and output files have a unique JobID. (I can give other unique IDs with datetime etc, but I don't want this.) I want JobIDs like 1,2,3...
I am using a cluster environment and PBS file to add details about my submit. I want this PBS file take the JOBID from my first step and then send it to the matlab script.
My steps are as follows:
1- write a .py script for multiple jobs (I first try for #2 jobs)
#!/bin/env python
#PBS -A open
import csv, subprocess
for i in range(1,3)
qsub_cmd = """qsub -F JOBID = {jobid} submit_m3.pbs""".format(jobid=i)
print(qsub_cmd)
exit = subprocess.call(qsub_cmd, shell=True)
2 - Write pbs file called submit_m3.pbs (I need to pass JOBID here)
#!/bin/bash
#PBS -l nodes=1:ppn=8
#PBS -l walltime=48:00:00
#PBS -l pmem=10gb
#PBS -A open
# Load in matlab
module purge
module load matlab
cd ~/code
matlab -nodisplay -nosplash < myScript.m > log.myLog
# JOBID must be placed somewhere in the above line.
3- Call the .py script in Linux terminal
python myPyFile.py
In the step 2, instead of the line starting with matlab, I also tried this (following other community questions)
matlab -nodisplay -nosplash -nodesktop -r "job_id=${JOBID};run('myScript.m');exit;"
but this code didn't pass JOBID to my script.
So, 2 things need to be solved. Passing JOBID to .pbs file and then to matlab file. Once it is in matlab, the rest (stata part) is OK!

回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by