Salome HOME
Fix typos by Kunda
[modules/kernel.git] / src / MPIContainer / launch_testMPI2.csh
1 #! /bin/csh -f
2
3 # Copyright (C) 2011-2016  CEA/DEN, EDF R&D, OPEN CASCADE
4 #
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.
9 #
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.
14 #
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
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21
22 # debug mode display information about communication
23 if $1 == "--debug" then
24   set debug="-debug"
25 else
26   set debug=""
27 endif
28 # get mpi implementation
29 ${KERNEL_ROOT_DIR}/bin/salome/getMPIImplementation
30 set res = $?
31 if $res == 1 then
32   set mpi="openmpi"
33 else if $res == 2 then
34   set mpi="mpich"
35 endif
36 if $mpi == "openmpi" then
37 # launch ompi-server
38   setenv OMPI_URI_FILE ${HOME}/.urifile_$$
39   set lpid1=`pidof ompi-server`
40   ompi-server -r ${OMPI_URI_FILE}
41   set lpid2=`pidof ompi-server`
42 else if $mpi == "mpich" then
43 # launch hydra_nameserver
44   set lpid1=`pidof hydra_nameserver`
45   if $lpid1 == "" then
46     hydra_nameserver &
47   endif
48   set lpid2=`pidof hydra_nameserver`
49 endif
50 # get pid of mpi server
51 set pid=0
52 foreach i ($lpid2)
53   set flag=0
54   foreach j ($lpid1)
55     if ($i == $j) then
56       set flag=1
57     endif
58   end
59   if ($flag == 0) then
60     set pid=$i
61   endif
62 end
63 sleep 2
64 # launch two instances of executable to create communication between both
65 if $mpi == "openmpi" then
66   mpirun -np 2 -ompi-server file:${OMPI_URI_FILE} ${KERNEL_ROOT_DIR}/bin/salome/testMPI2 -vsize 32 $debug &
67   mpirun -np 3 -ompi-server file:${OMPI_URI_FILE} ${KERNEL_ROOT_DIR}/bin/salome/testMPI2 -vsize 32 $debug
68 else if $mpi == "mpich" then
69   mpirun -np 2 -nameserver $HOSTNAME ${KERNEL_ROOT_DIR}/bin/salome/testMPI2 -vsize 32 $debug &
70   mpirun -np 3 -nameserver $HOSTNAME ${KERNEL_ROOT_DIR}/bin/salome/testMPI2 -vsize 32 $debug
71 endif
72 set res=$status
73 sleep 1
74 # kill mpi server
75 if $pid != 0 then
76   kill -9 $pid
77 endif
78 if $mpi == "openmpi" then
79 # delete uri file
80   rm -f  ${OMPI_URI_FILE}
81 endif
82 # give result of test
83 if $res == 0 then
84   echo "OK"
85 else
86   echo "KO"
87 endif
88 exit $res