3 # Copyright (C) 2015-2019 CEA/DEN, EDF R&D, OPEN CASCADE
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 echo "This is a script that can be run concurrently."
23 echo "It takes as single argument the number of concurrent executions:"
24 echo "Usage: " $0 "<nb_execution> <output_folder>"
26 echo "Here is what executed code contents looks like:"
27 echo " - do some stuff"
28 echo " - run SALOME in terminal mode, and log port number to a file"
29 echo " - run some scripts (Python, binary), each in a dedicated SALOME session on a specific port"
30 echo " - do some stuff"
35 echo "Usage:" $0 "<nb_execution> <output_folder>"
44 case ${OUTPUT_FOLDER} in
45 /*) ;; # OUTPUT_FOLDER is given as an absolute path
46 *) OUTPUT_FOLDER=${BASE_DIR}/${OUTPUT_FOLDER} ;; # build absolute path
49 if [ "x${SALOME_APPLI_FOLDER}" == "x" ]; then
50 echo "SALOME_APPLI_FOLDER variable is not set (or empty)."
51 echo "Try to locate SALOME launcher in current directory."
52 SALOME_APPLI_FOLDER=`pwd`
53 if ! [ -f ${SALOME_APPLI_FOLDER}/salome ]; then
54 echo "Unable to locate salome command."
60 ${SALOME_APPLI_FOLDER}/salome start -t --ns-port-log=${OUTPUT_FOLDER}/session.log
61 SALOME_PORT=`cat ${OUTPUT_FOLDER}/session.log`
62 echo "SALOME is running on port" ${SALOME_PORT}
66 ${SALOME_APPLI_FOLDER}/salome shell -p ${SALOME_PORT} ${SALOME_APPLI_FOLDER}/bin/salome/killSalomeWithPort.py args:${SALOME_PORT}
70 WORK_DIR=`pwd` # a pushd has been done before calling this function
71 echo "Run command in folder:" ${WORK_DIR}
72 ${SALOME_APPLI_FOLDER}/salome shell -p ${SALOME_PORT} ${SALOME_APPLI_FOLDER}/bin/salome/waitContainers.py
73 ${SALOME_APPLI_FOLDER}/salome shell -p ${SALOME_PORT} ${BASE_DIR}/myscript.py args:${WORK_DIR}
74 echo "Execution terminated in folder:" ${WORK_DIR}
84 work_dir = sys.argv[1]
85 logfile = os.path.join(work_dir, 'myscript.log')
86 msg = 'Waiting for 3s in folder %s'%work_dir
88 with open(logfile, 'w') as f:
90 " > ${BASE_DIR}/myscript.py
92 # Build output folders
93 typeset -i i=${NB_COMP}
96 mkdir -p ${OUTPUT_FOLDER}/execution_$i
102 typeset -i i=${NB_COMP}
105 pushd ${OUTPUT_FOLDER}/execution_$i > /dev/null