# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import pprint as PP #pretty print
-import subprocess as SP #Popen
-import multiprocessing as MP #cpu_count
+import multiprocessing as MP # cpu_count
+import pprint as PP # pretty print
+import subprocess as SP # Popen
+
def okToSys(aResult, verbose=False):
"""to get windows or linux result of script"""
def okToSys(aResult, verbose=False):
"""to get windows or linux result of script"""
def exec_command(cmd, verbose=False):
"""Exec ONE command with popen"""
def exec_command(cmd, verbose=False):
"""Exec ONE command with popen"""
- pipe = SP.Popen(cmd, shell=True, stdout=SP.PIPE, stderr=SP.PIPE )
+ pipe = SP.Popen(cmd, shell=True, stdout=SP.PIPE, stderr=SP.PIPE)
#export PATH=/export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing/bin:$PATH
#do not work prefer set before salome launch
OPENMPI_INSTALL_DIR = "/export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing/bin"
#export PATH=/export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing/bin:$PATH
#do not work prefer set before salome launch
OPENMPI_INSTALL_DIR = "/export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing/bin"
#INSTALL_DIR = /export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing
for i in sys.path[0:10]: print "PATH",i
"""
#INSTALL_DIR = /export/home/prerequisites_SALOME_780_LAURENT/openmpi-1.8.4/FROM_nothing
for i in sys.path[0:10]: print "PATH",i
"""
##########################################################################
def launchMultithread(args):
##########################################################################
def launchMultithread(args):
- #--out is ONE file: basename_tetra_hpc.mesh
- outputMulti = os.path.splitext(args.inputFile)[0] + "_tetra_hpc.mesh" #only one file if Multithread
+ # --out is ONE file: basename_tetra_hpc.mesh
+ outputMulti = os.path.splitext(args.inputFile)[0] + "_tetra_hpc.mesh" # only one file if Multithread
cmd = "mg-tetra_hpc.exe --max_number_of_threads %i --in %s --gradation %s --max_size %s --min_size %s; cp %s %s; ls -alt %s*; " % \
(args.number, args.inputFile, args.gradation, args.max_size, args.min_size, outputMulti, outputMultiAsMpi, outputs)
else:
cmd = "mg-tetra_hpc.exe --max_number_of_threads %i --in %s --gradation %s --max_size %s --min_size %s; cp %s %s; ls -alt %s*; " % \
(args.number, args.inputFile, args.gradation, args.max_size, args.min_size, outputMulti, outputMultiAsMpi, outputs)
else:
""" compile libmeshgems_mpi.so: no needs
COMPILDIR=os.getenv("MESHGEMSHOME") + "/stubs"
TARGETDIR=os.getenv("MESHGEMSHOME") + "/lib/Linux_64"
""" compile libmeshgems_mpi.so: no needs
COMPILDIR=os.getenv("MESHGEMSHOME") + "/stubs"
TARGETDIR=os.getenv("MESHGEMSHOME") + "/lib/Linux_64"
cmd += "mpirun -n %i mg-tetra_hpc_mpi.exe --in %s --out %s --gradation %s --max_size %s --min_size %s; ls -alt %s*; " % \
(args.number, args.inputFile, args.outputFiles, args.gradation, args.max_size, args.min_size, outputs)
else:
cmd += "mpirun -n %i mg-tetra_hpc_mpi.exe --in %s --out %s --gradation %s --max_size %s --min_size %s; ls -alt %s*; " % \
(args.number, args.inputFile, args.outputFiles, args.gradation, args.max_size, args.min_size, outputs)
else:
if __name__ == '__main__':
parser = AP.ArgumentParser(description='launch tetra_hpc.exe or tetra_hpc_mpi.exe mesh computation', argument_default=None)
if __name__ == '__main__':
parser = AP.ArgumentParser(description='launch tetra_hpc.exe or tetra_hpc_mpi.exe mesh computation', argument_default=None)
help='if multithread: number of threads, else distributed: number of processes MPI',
choices=[ArgRange(1, 999999)],
type=int,
help='if multithread: number of threads, else distributed: number of processes MPI',
choices=[ArgRange(1, 999999)],
type=int,
help='size ratio adjacent cell, default 0 is 1.05',
type=float,
choices=[ArgRange(0.0, 3.0)],
help='size ratio adjacent cell, default 0 is 1.05',
type=float,
choices=[ArgRange(0.0, 3.0)],
help='min size cell, default 0 is no constraint',
type=float,
choices=[ArgRange(0.0, 9e99)],
help='min size cell, default 0 is no constraint',
type=float,
choices=[ArgRange(0.0, 9e99)],
help='max size cell, default 0 is no constraint',
type=float,
choices=[ArgRange(0.0, 9e99)],
help='max size cell, default 0 is no constraint',
type=float,
choices=[ArgRange(0.0, 9e99)],
parameters, data, used arrays and results and other...
"""
args = parser.parse_args()
parameters, data, used arrays and results and other...
"""
args = parser.parse_args()
parser.print_help()
sys.exit(KOSYS)
if args.outputFiles == None:
tmp, _ = os.path.splitext(args.inputFile)
args.outputFiles = tmp + "_out.mesh"
parser.print_help()
sys.exit(KOSYS)
if args.outputFiles == None:
tmp, _ = os.path.splitext(args.inputFile)
args.outputFiles = tmp + "_out.mesh"
- print("INFO: mg-tetra_hpc.py assume licence file set:\n DLIM8VAR=%s\n DISTENE_LICENSE_FILE=%s" % \
- (os.getenv("DLIM8VAR"), os.getenv("DISTENE_LICENSE_FILE")))
-
- if args.multithread == "yes":
+ print(("INFO: mg-tetra_hpc.py assume licence file set:\n DLIM8VAR=%s\n DISTENE_LICENSE_FILE=%s" % \
+ (os.getenv("DLIM8VAR"), os.getenv("DISTENE_LICENSE_FILE"))))
+
+ if args.multithread == "yes":
result = launchMultithread(args)
else:
result = launchMpi(args)
sys.exit(okToSys(result, verbose=True))
result = launchMultithread(args)
else:
result = launchMpi(args)
sys.exit(okToSys(result, verbose=True))