3 echo "This is a script that can be run concurrently."
4 echo "It takes as single argument the number of concurrent executions:"
5 echo "Usage: " $0 "<nb_execution> <output_folder>"
7 echo "Here is what executed code contents looks like:"
8 echo " - do some stuff"
9 echo " - run SALOME in terminal mode, and log port number to a file"
10 echo " - run some scripts (Python, binary), each in a dedicated SALOME session on a specific port"
11 echo " - do some stuff"
16 echo "Usage:" $0 "<nb_execution> <output_folder>"
25 case ${OUTPUT_FOLDER} in
26 /*) ;; # OUTPUT_FOLDER is given as an absolute path
27 *) OUTPUT_FOLDER=${BASE_DIR}/${OUTPUT_FOLDER} ;; # build absolute path
30 if [ "x${SALOME_APPLI_FOLDER}" == "x" ]; then
31 echo "SALOME_APPLI_FOLDER variable is not set (or empty)."
32 echo "Try to locate SALOME launcher in current directory."
33 SALOME_APPLI_FOLDER=`pwd`
34 if ! [ -f ${SALOME_APPLI_FOLDER}/salome ]; then
35 echo "Unable to locate salome command."
41 ${SALOME_APPLI_FOLDER}/salome start -t --ns-port-log=${OUTPUT_FOLDER}/session.log
42 SALOME_PORT=`cat ${OUTPUT_FOLDER}/session.log`
43 echo "SALOME is running on port" ${SALOME_PORT}
47 ${SALOME_APPLI_FOLDER}/salome shell -p ${SALOME_PORT} ${SALOME_APPLI_FOLDER}/bin/salome/killSalomeWithPort.py args:${SALOME_PORT}
51 WORK_DIR=`pwd` # a pushd has been done before calling this function
52 echo "Run command in folder:" ${WORK_DIR}
53 ${SALOME_APPLI_FOLDER}/salome shell -p ${SALOME_PORT} ${SALOME_APPLI_FOLDER}/bin/salome/waitContainers.py
54 ${SALOME_APPLI_FOLDER}/salome shell -p ${SALOME_PORT} ${BASE_DIR}/myscript.py args:${WORK_DIR}
55 echo "Execution terminated in folder:" ${WORK_DIR}
65 work_dir = sys.argv[1]
66 logfile = os.path.join(work_dir, 'myscript.log')
67 msg = 'Waiting for 3s in folder %s'%work_dir
69 with open(logfile, 'w') as f:
71 " > ${BASE_DIR}/myscript.py
73 # Build output folders
74 typeset -i i=${NB_COMP}
77 mkdir -p ${OUTPUT_FOLDER}/execution_$i
83 typeset -i i=${NB_COMP}
86 pushd ${OUTPUT_FOLDER}/execution_$i > /dev/null