def build_batch_file(self, distrep, casename, coupling=None): """ Retrieve batch file for the current system Update batch file for the study """ batch_file = os.path.join(distrep, 'runcase') if sys.platform.startswith('win'): batch_file = batch_file + '.bat' if self.copy is not None: ref_runcase_path = os.path.join(self.copy, 'SCRIPTS', 'runcase') if sys.platform.startswith('win'): ref_runcase_path += '.bat' try: shutil.copy(ref_runcase_path, batch_file) except Exception: pass # Add info from parent in case of copy runcase = cs_runcase.runcase(batch_file, package=self.package, rebuild=True, study_name=self.name, case_name=casename) if coupling: runcase.set_coupling(coupling) runcase.save()
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_BatchRunningForm.__init__(self) self.setupUi(self) self.case = case self.parent = parent self.case.undoStopGlobal() self.mdl = ScriptRunningModel(self.case) # Check if the script file name is already defined if self.case['scripts_path']: if not self.case['runcase']: if self.case['package'].runcase in os.listdir( self.case['scripts_path']): runcase_path = os.path.join(self.case['scripts_path'], self.case['package'].runcase) self.case['runcase'] = cs_runcase.runcase( runcase_path, package=self.case['package'])
def build_batch_file(self, distrep, casename, coupling=None, cathare_path=None): """ Retrieve batch file for the current system Update batch file for the study """ batch_file = os.path.join(distrep, 'runcase') if sys.platform.startswith('win'): batch_file = batch_file + '.bat' if self.copy is not None: ref_runcase_path = os.path.join(self.copy, 'SCRIPTS', 'runcase') if sys.platform.startswith('win'): ref_runcase_path += '.bat' try: shutil.copy(ref_runcase_path, batch_file) except Exception: pass # Add info from parent in case of copy runcase = cs_runcase.runcase(batch_file, package=self.package, rebuild=True, study_name=self.name, case_name=casename) if coupling: runcase.set_coupling(coupling) # If a cathare LIBPATH is given, it is added to LD_LIBRARY_PATH. # This modification is needed for the dlopen of the cathare .so file if cathare_path: v25_3_line = "export v25_3=%s" % cathare_path new_line = "export LD_PATH_LIBRARY=$v25_3/%s/" + ":$LD_LIBRARY_PATH" il = 0 for line in runcase.lines: il += 1 if 'export PATH' in line: runcase.lines.insert(il, new_line % ("lib/ICoCo")) runcase.lines.insert(il, new_line % ("lib")) runcase.lines.insert(il, v25_3_line) runcase.run_cmd_line_id += 3 break runcase.save()
def __get_exe(self, old_pkg): """ Return the name of the exe of the case, in order to mix Code_Saturne and NEPTUNE_CFD test cases in the same study. """ run_ref = os.path.join(self.__repo, self.label, "SCRIPTS", "runcase") # Read the runcase script from the Repository runcase = cs_runcase.runcase(run_ref) if runcase.cmd_name == "code_saturne": from Base.XMLinitialize import XMLinit from cs_package import package pkg = package(old_pkg.scriptdir) elif runcase.cmd_name == "neptune_cfd": from core.XMLinitialize import XMLinit from nc_package import package pkg = package(old_pkg.scriptdir) return runcase.cmd_name, pkg
def initializeBatchRunningWindow(self): """ initializes variables concerning the display of batchrunning """ self.IdPthMdl = IdentityAndPathesModel(self.case) fic = self.IdPthMdl.getXmlFileName() if not fic: file_name = os.getcwd() if os.path.basename(f) == 'DATA': file_name = os.path.dirname(file_name) self.IdPthMdl.setCasePath(file_name) else: file_dir = os.path.split(fic)[0] if file_dir: self.IdPthMdl.setCasePath(os.path.split(file_dir)[0]) if not os.path.basename(file_dir) == 'DATA': self.IdPthMdl.setCasePath(file_dir) else: file_dir = os.path.split(os.getcwd())[0] self.IdPthMdl.setCasePath(file_dir) for p, rep in [('data_path', 'DATA'), ('resu_path', 'RESU'), ('user_src_path', 'SRC'), ('scripts_path', 'SCRIPTS')]: self.IdPthMdl.setPathI(p, os.path.join(file_dir, rep)) self.IdPthMdl.setRelevantSubdir("yes", "") self.IdPthMdl.setPathI('mesh_path', os.path.join(os.path.abspath(os.path.split(file_dir)[0], 'MESH'))) self.case['runcase'] = cs_runcase.runcase(os.path.join(self.case['scripts_path'], self.batch_file), package=self.package) del IdentityAndPathesModel self.updateStudyId()
def slotSearchBatchFile(self): """ Open a FileDialog in order to search the batch command file in the system file. """ file_name = "" if self.case['scripts_path'] and os.path.isdir(self.case['scripts_path']): path = self.case['scripts_path'] else: path = os.getcwd() title = self.tr("Select the batch script") filetypes = self.tr("All Files (*)") file_name = QFileDialog.getOpenFileName(self, title, path, filetypes) file_name = str(file_name) if file_name: launcher = os.path.basename(file_name) setGreenColor(self.toolButtonSearchBatch, False) if self.case['scripts_path'] == os.path.dirname(file_name): self.case['runcase'] = cs_runcase.runcase(os.path.join(self.case['scripts_path'], launcher), package=self.case['package']) self.labelBatchName.setText(str(launcher)) self.hideBatchInfo() if self.case['batch_type'] != None: self.displayBatchInfo() else: title = self.tr("Warning") msg = self.tr("The new batch file is not in scripts "\ "directory given in the 'Identity and paths' "\ "section.\n\n" + \ "Verify the existence and location of these files, "\ "and the 'Identity and Pathes' section") QMessageBox.warning(self, title, msg)
def main(argv, pkg): """ Main function. """ # Use alternate compute (back-end) package if defined batch = cs_batch.batch(pkg) submit_cmd = batch.submit_command_prefix() if not submit_cmd: submit_cmd = get_shell_type() runcase_path = process_cmd_line(argv, submit_cmd, pkg) if not runcase_path: return 1 scripts_dir = os.path.abspath(os.path.dirname(runcase_path)) runcase = cs_runcase.runcase(runcase_path) # Adjust run command for staging only run_args = runcase.get_run_args() for a in ['--stage', '--initialize', '--execute', '--finalize']: while a in run_args: run_args.remove(a) run_args.append('--stage') retcode, run_id, result_path = cs_run.run(run_args, pkg) # Now prepare runcase for submission if retcode != 0 or not result_path: err_str = ' run not staged due to prior error.' raise Exception(err_str) run_args = runcase.get_run_args() while '--stage' in run_args: run_args.remove(a) stages = [] for a in ['--initialize', '--execute', '--finalize']: if a in run_args: stages.append(a) if not stages: run_args.append('--initialize') run_args.append('--finalize') runcase.set_run_args(run_args) runcase.set_run_id(run_id=run_id) runcase_path = os.path.join(result_path, os.path.basename(runcase_path)) runcase.save(runcase_path) # Now submit case save_wd = os.getcwd() os.chdir(result_path) for a in argv: if os.path.isfile(a) and runcase_path: submit_cmd += ' ' + enquote_arg(runcase_path) runcase_path = None else: submit_cmd += ' ' + enquote_arg(a) return subprocess.call(submit_cmd, shell=True) os.chdir(save_wd)
def coupling(package, domains, casedir, verbose=True, package_compute=None): use_saturne = False use_syrthes = False use_neptune = False # Use alternate compute (back-end) package if defined config = configparser.ConfigParser() config.read(package.get_global_configfile()) if package_compute == None: package_compute = package # Initialize code domains sat_domains = [] syr_domains = [] nep_domains = [] ast_domain = None fsi_coupler = None if domains == None: raise RunCaseError('No domains defined.') for d in domains: if ((d.get('script') == None or d.get('domain') == None) \ and d.get('coupler') == None): msg = 'Check your coupling definition.\n' msg += 'script or domain key is missing.' raise RunCaseError(msg) if (d.get('solver') == 'Code_Saturne' or d.get('solver') == 'Saturne'): try: runcase = cs_runcase.runcase( os.path.join(os.getcwd(), d.get('domain'), 'SCRIPTS', d.get('script'))) param = runcase.get_parameters() except Exception: err_str = 'Cannot read Code_Saturne script: ' + runcase raise RunCaseError(err_str) dom = domain(package, package_compute=package_compute, name=d.get('domain'), param=param, n_procs_weight=d.get('n_procs_weight'), n_procs_min=d.get('n_procs_min'), n_procs_max=d.get('n_procs_max')) use_saturne = True sat_domains.append(dom) elif (d.get('solver') == 'SYRTHES'): try: dom = syrthes_domain(package, cmd_line=d.get('opt'), name=d.get('domain'), param=d.get('script'), n_procs_weight=d.get('n_procs_weight'), n_procs_min=d.get('n_procs_min'), n_procs_max=d.get('n_procs_max')) except Exception: err_str = 'Cannot create SYRTHES domain. Opt = ' + d.get( 'opt') + '\n' err_str += ' domain = ' + d.get('domain') err_str += ' script = ' + d.get('script') + '\n' err_str += ' n_procs_weight = ' + str( d.get('n_procs_weight')) + '\n' raise RunCaseError(err_str) use_syrthes = True syr_domains.append(dom) elif (d.get('solver') == 'NEPTUNE_CFD'): try: runcase = cs_runcase.runcase( os.path.join(os.getcwd(), d.get('domain'), 'SCRIPTS', d.get('script'))) param = runcase.get_parameters() except Exception: err_str = 'Cannot read NEPTUNE_CFD script: ' + runcase raise RunCaseError(err_str) dom = domain(package, package_compute=package_compute, name=d.get('domain'), param=param, n_procs_weight=d.get('n_procs_weight'), n_procs_min=d.get('n_procs_min'), n_procs_max=d.get('n_procs_max')) use_neptune = True nep_domains.append(dom) elif (d.get('solver') == 'Code_Aster' or d.get('solver') == 'Aster'): if ast_domain: err_str = 'Only 1 Code_Aster domain is currently handled\n' raise RunCaseError(err_str) try: dom = aster_domain(package, name=d.get('domain'), param=d.get('script')) except Exception: err_str = 'Cannot create Code_Aster domain.\n' err_str += ' domain = ' + d.get('domain') + '\n' err_str += ' script = ' + d.get('script') + '\n' raise RunCaseError(err_str) ast_domain = dom elif (d.get('coupler') == 'FSI_coupler'): if fsi_coupler: err_str = 'Only 1 FSI coupler is currently handled\n' raise RunCaseError(err_str) try: fsi_coupler = { 'max_time_steps': d.get('max_time_steps'), 'n_sub_iterations': d.get('n_sub_iterations'), 'time_step': d.get('time_step'), 'start_time': d.get('start_time'), 'epsilon': d.get('epsilon') } except Exception: err_str = 'Cannot create FSI coupler\n' err_str += ' max_time_steps = ' + d.get( 'max_time_steps') + '\n' err_str += ' n_sub_iterations = ' + d.get('n_sub_iterations' + '\n') err_str += ' time_step = ' + d.get('time_step') + '\n' err_str += ' start_time = ' + d.get('start_time') + '\n' err_str += ' epsilon = ' + d.get('epsilon') + '\n' raise RunCaseError(err_str) else: err_str = 'Unknown code type : ' + d.get('solver') + '.\n' raise RunCaseError(err_str) # Now handle case for the corresponding calculation domain(s). c = case(package, package_compute=package_compute, case_dir=casedir, domains=sat_domains + nep_domains, syr_domains=syr_domains, ast_domain=ast_domain, fsi_coupler=fsi_coupler) if verbose: msg = ' Coupling execution between: \n' if use_saturne == True: msg += ' o Code_Saturne [' + str( len(sat_domains)) + ' domain(s)];\n' if use_syrthes == True: msg += ' o SYRTHES [' + str( len(syr_domains)) + ' domain(s)];\n' if use_neptune == True: msg += ' o NEPTUNE_CFD [' + str( len(nep_domains)) + ' domain(s)];\n' if ast_domain or fsi_coupler: msg += ' o Code_Aster [1 domain(s)];\n' msg += ' [1 coupler(s)];\n' sys.stdout.write(msg + '\n') return c
def update_case(options, pkg): repbase = os.getcwd() study_name = os.path.basename(os.getcwd()) for case in options.case_names: os.chdir(repbase) if case == ".": casename = os.path.split(repbase)[-1] else: casename = case if options.verbose > 0: sys.stdout.write(" o Updating case '%s' paths...\n" % casename) datadir = os.path.join(pkg.get_dir("pkgdatadir")) os.chdir(case) # Write a wrapper for GUI launching data = 'DATA' if not os.path.isdir(data): os.mkdir(data) guiscript = os.path.join(data, pkg.guiname) fd = open(guiscript, 'w') cs_exec_environment.write_shell_shebang(fd) cs_exec_environment.write_script_comment( fd, 'Ensure the correct command is found:\n') cs_exec_environment.write_prepend_path(fd, 'PATH', pkg.get_dir("bindir")) fd.write('\n') cs_exec_environment.write_script_comment(fd, 'Run command:\n') # On Linux systems, add a backslash to prevent aliases if sys.platform.startswith('linux'): fd.write('\\') fd.write(pkg.name + ' gui ' + cs_exec_environment.get_script_positional_args() + '\n') fd.close() set_executable(guiscript) # User source files directory src = 'SRC' if not os.path.isdir(src): os.mkdir(src) user_distpath = os.path.join(datadir, 'user') user_examples_distpath = os.path.join(datadir, 'user_examples') user = os.path.join(src, 'REFERENCE') user_examples = os.path.join(src, 'EXAMPLES') copy_directory(user_distpath, user) copy_directory(user_examples_distpath, user_examples) add_datadirs = [] if pkg.name == 'neptune_cfd': add_datadirs.append(os.path.join(pkg.get_dir("datadir"), pkg.name)) for d in add_datadirs: user_distpath = os.path.join(d, 'user') if os.path.isdir(user_distpath): copy_directory(user_distpath, user) user_examples_distpath = os.path.join(d, 'user_examples') if os.path.isdir(user_examples_distpath): copy_directory(user_examples_distpath, user_examples) unset_executable(user) unset_executable(user_examples) # Results directory (only one for all instances) resu = 'RESU' if not os.path.isdir(resu): os.mkdir(resu) # Script directory (only one for all instances) scripts = 'SCRIPTS' if not os.path.isdir(scripts): os.mkdir(scripts) batch_file = os.path.join(repbase, case, scripts, 'runcase') if sys.platform.startswith('win'): batch_file = batch_file + '.bat' # Add info from parent in case of copy runcase = cs_runcase.runcase(batch_file, package=pkg, rebuild=True, study_name=study_name, case_name=case) runcase.save()
def coupling(package, domains, casedir, staging_dir = None, verbose = True, package_compute = None): use_saturne = False use_syrthes = False use_neptune = False use_cathare = False # Use alternate compute (back-end) package if defined config = configparser.ConfigParser() config.read(package.get_global_configfile()) if package_compute == None: package_compute = package # Initialize code domains sat_domains = [] syr_domains = [] nep_domains = [] cat_domains = [] ast_domain = None fsi_coupler = None if domains == None: raise RunCaseError('No domains defined.') for d in domains: if ((d.get('script') == None or d.get('domain') == None) \ and d.get('coupler') == None): msg = 'Check your coupling definition.\n' msg += 'script or domain key is missing.' raise RunCaseError(msg) if (d.get('solver') == 'Code_Saturne' or d.get('solver') == 'NEPTUNE_CFD'): script = d.get('script') if script[-4:] == '.xml': param = script else: runcase_path = os.path.join(os.getcwd(), d.get('domain'), 'SCRIPTS', script) try: runcase = cs_runcase.runcase(runcase_path) param = runcase.get_parameters() except Exception: err_str = 'Cannot read ' + d.get('solver') \ + ' script: ' + runcase_path raise RunCaseError(err_str) d['script'] = param dom = domain(package, package_compute = package_compute, name = d.get('domain'), param = param, n_procs_weight = d.get('n_procs_weight'), n_procs_min = d.get('n_procs_min'), n_procs_max = d.get('n_procs_max')) if (d.get('solver')) == 'Code_Saturne': use_saturne = True sat_domains.append(dom) elif (d.get('solver')) == 'NEPTUNE_CFD': use_neptune = True nep_domains.append(dom) elif (d.get('solver') == 'SYRTHES'): try: dom = syrthes_domain(package, cmd_line = d.get('opt'), name = d.get('domain'), param = d.get('script'), n_procs_weight = d.get('n_procs_weight'), n_procs_min = d.get('n_procs_min'), n_procs_max = d.get('n_procs_max')) except Exception: err_str = 'Cannot create SYRTHES domain. Opt = ' + d.get('opt') + '\n' err_str += ' domain = ' + d.get('domain') err_str += ' script = ' + d.get('script') + '\n' err_str += ' n_procs_weight = ' + str(d.get('n_procs_weight')) + '\n' raise RunCaseError(err_str) use_syrthes = True syr_domains.append(dom) elif (d.get('solver') == 'Code_Aster' or d.get('solver') == 'Aster'): if ast_domain: err_str = 'Only 1 Code_Aster domain is currently handled\n' raise RunCaseError(err_str) try: dom = aster_domain(package, name = d.get('domain'), param = d.get('script')) except Exception: err_str = 'Cannot create Code_Aster domain.\n' err_str += ' domain = ' + d.get('domain') + '\n' err_str += ' script = ' + d.get('script') + '\n' raise RunCaseError(err_str) ast_domain = dom elif (d.get('coupler') == 'FSI_coupler'): if fsi_coupler: err_str = 'Only 1 FSI coupler is currently handled\n' raise RunCaseError(err_str) try: fsi_coupler = {'max_time_steps' : d.get('max_time_steps'), 'n_sub_iterations' : d.get('n_sub_iterations'), 'time_step' : d.get('time_step'), 'start_time' : d.get('start_time'), 'epsilon' : d.get('epsilon')} except Exception: err_str = 'Cannot create FSI coupler\n' err_str += ' max_time_steps = ' + d.get('max_time_steps') + '\n' err_str += ' n_sub_iterations = ' + d.get('n_sub_iterations' + '\n') err_str += ' time_step = ' + d.get('time_step') + '\n' err_str += ' start_time = ' + d.get('start_time') + '\n' err_str += ' epsilon = ' + d.get('epsilon') + '\n' raise RunCaseError(err_str) elif (d.get('solver') == 'CATHARE'): # Current version using Cathare2: the cathare case is converted to a # .so library which is opened and launched by a NEPTUNE_CFD executable script = d.get('script') if script[-4:] == '.xml': param = script else: runcase_path = os.path.join(os.getcwd(), d.get('domain'), 'SCRIPTS', script) try: runcase = cs_runcase.runcase(runcase_path) param = runcase.get_parameters() except Exception: err_str = 'Cannot read ' + d.get('solver') \ + ' script: ' + runcase_path raise RunCaseError(err_str) d['script'] = param dom = cathare_domain(package, package_compute = package_compute, name = d.get('domain'), param = d.get('paramfile'), n_procs_weight = d.get('n_procs_weight'), n_procs_min = d.get('n_procs_min'), n_procs_max = d.get('n_procs_max'), cathare_case_file=d.get('cathare_case_file'), neptune_cfd_dom=d.get('neptune_cfd_domain')) use_cathare = True cat_domains.append(dom) else: err_str = 'Unknown code type : ' + d.get('solver') + '.\n' raise RunCaseError(err_str) # Now handle case for the corresponding calculation domain(s). coupling_parameters = \ """ # -*- coding: utf-8 -*-" domains = [ """ d_first = True for d in domains: if not d_first: coupling_parameters += ",\n\n" d_first = False k_first = True for k in ('solver', 'domain', 'script', 'n_procs_weight', 'n_procs_min', 'coupler', 'max_time_steps', 'n_sub_iterations', 'time_step', 'start_time', 'epsilon'): v = d.get(k) if v: if type(v) == str: s_v = "'" + v + "'" else: s_v = str(v) if k_first: coupling_parameters += " {" k_first = False else: coupling_parameters += ",\n " coupling_parameters += "'" + k + "': " + s_v coupling_parameters += "}" coupling_parameters += "\n\n ]\n\n" c = case(package, package_compute = package_compute, case_dir = casedir, staging_dir = staging_dir, coupling_parameters = coupling_parameters, domains = sat_domains + nep_domains + cat_domains, syr_domains = syr_domains, ast_domain = ast_domain, fsi_coupler = fsi_coupler) if verbose: msg = ' Coupling execution between: \n' if use_saturne == True: msg += ' o Code_Saturne [' + str(len(sat_domains)) + ' domain(s)];\n' if use_syrthes == True: msg += ' o SYRTHES [' + str(len(syr_domains)) + ' domain(s)];\n' if use_neptune == True: msg += ' o NEPTUNE_CFD [' + str(len(nep_domains)) + ' domain(s)];\n' if ast_domain or fsi_coupler: msg += ' o Code_Aster [1 domain(s)];\n' msg += ' [1 coupler(s)];\n' if use_cathare == True: msg += ' o CATHARE2 [' + str(len(cat_domains)) + ' domain(s)];\n' sys.stdout.write(msg+'\n') return c
def __init__(self, parent, case): """ Constructor """ QWidget.__init__(self, parent) Ui_BatchRunningForm.__init__(self) self.setupUi(self) self.case = case self.parent = parent self.case.undoStopGlobal() self.mdl = ScriptRunningModel(self.case) # Check if the script file name is already defined if self.case['scripts_path']: if not self.case['runcase']: if self.case['package'].runcase in os.listdir(self.case['scripts_path']): runcase_path = os.path.join(self.case['scripts_path'], self.case['package'].runcase) self.case['runcase'] = cs_runcase.runcase(runcase_path, package=self.case['package']) # Get batch type config = configparser.ConfigParser() config.read(self.case['package'].get_configfiles()) cs_batch_type = None if config.has_option('install', 'batch'): cs_batch_type = config.get('install', 'batch') if os.path.isabs(cs_batch_type): i = cs_batch_type.rfind(".") if i > -1: cs_batch_type = cs_batch_type[i+1:] self.case['batch_type'] = cs_batch_type # Get MPI and OpenMP features self.have_mpi = False self.have_openmp = False config_features = self.case['package'].config.features if config.has_option('install', 'compute_versions'): compute_versions = config.get('install', 'compute_versions').split(':') if compute_versions[0]: pkg_compute = self.case['package'].get_alternate_version(compute_versions[0]) config_features = pkg_compute.config.features if config_features['mpi'] == 'yes': self.have_mpi = True if config_features['openmp'] == 'yes': self.have_openmp = True self.jmdl = BatchRunningModel(parent, self.case) # Batch info self.hideBatchInfo() self.labelNProcs.hide() self.spinBoxNProcs.hide() self.labelNThreads.hide() self.spinBoxNThreads.hide() self.class_list = None if self.case['batch_type'] != None: self.groupBoxArchi.setTitle("Job and script files") self.labelBatch.show() self.toolButtonSearchBatch.show() validatorSimpleName = RegExpValidator(self.lineEditJobName, QRegExp("[_A-Za-z0-9]*")) validatorAccountName = RegExpValidator(self.lineEditJobAccount, QRegExp("\\S+")) self.lineEditJobName.setValidator(validatorSimpleName) self.lineEditJobAccount.setValidator(validatorAccountName) self.lineEditJobWCKey.setValidator(validatorAccountName) self.pushButtonRunSubmit.setText("Submit job") else: if self.jmdl.dictValues['run_nprocs'] == None: try: # For backwards compatibility # (this is a specific case, as we move information from # the XML model to the batch script) self.jmdl.dictValues['run_nprocs'] = self.mdl.getString('n_procs') self.mdl.setString('n_procs', None) except Exception: pass # Connections if self.case['batch_type'] != None: self.connect(self.lineEditJobName, SIGNAL("textChanged(const QString &)"), self.slotJobName) self.connect(self.spinBoxNodes, SIGNAL("valueChanged(int)"), self.slotJobNodes) self.connect(self.spinBoxPpn, SIGNAL("valueChanged(int)"), self.slotJobPpn) self.connect(self.spinBoxProcs, SIGNAL("valueChanged(int)"), self.slotJobProcs) self.connect(self.spinBoxThreads, SIGNAL("valueChanged(int)"), self.slotJobThreads) self.connect(self.spinBoxDays, SIGNAL("valueChanged(int)"), self.slotJobWallTime) self.connect(self.spinBoxHours, SIGNAL("valueChanged(int)"), self.slotJobWallTime) self.connect(self.spinBoxMinutes, SIGNAL("valueChanged(int)"), self.slotJobWallTime) self.connect(self.spinBoxSeconds, SIGNAL("valueChanged(int)"), self.slotJobWallTime) self.connect(self.comboBoxClass, SIGNAL("activated(const QString&)"), self.slotClass) self.connect(self.lineEditJobAccount, SIGNAL("textChanged(const QString &)"), self.slotJobAccount) self.connect(self.lineEditJobWCKey, SIGNAL("textChanged(const QString &)"), self.slotJobWCKey) else: self.connect(self.spinBoxNProcs, SIGNAL("valueChanged(int)"), self.slotNProcs) self.connect(self.spinBoxNThreads, SIGNAL("valueChanged(int)"), self.slotNThreads) self.connect(self.toolButtonSearchBatch, SIGNAL("clicked()"), self.slotSearchBatchFile) self.connect(self.comboBoxRunType, SIGNAL("activated(const QString&)"), self.slotArgRunType) self.connect(self.toolButtonAdvanced, SIGNAL("clicked()"), self.slotAdvancedOptions) self.connect(self.pushButtonRunSubmit, SIGNAL("clicked()"), self.slotBatchRunning) # Combomodels self.modelArg_cs_verif = ComboModel(self.comboBoxRunType, 2, 1) self.modelArg_cs_verif.addItem(self.tr("Import mesh only"), 'none') self.modelArg_cs_verif.addItem(self.tr("Mesh preprocessing"), 'mesh preprocess') self.modelArg_cs_verif.addItem(self.tr("Mesh quality criteria"), 'mesh quality') self.modelArg_cs_verif.addItem(self.tr("Standard"), 'standard') self.modelArg_cs_verif.setItem(str_model=self.mdl.getRunType()) # initialize Widgets # Check if the script file name is already defined if self.case['runcase']: name = os.path.basename(self.case['runcase'].path) self.labelBatchName.setText(str(name)) setGreenColor(self.toolButtonSearchBatch, False) else: setGreenColor(self.toolButtonSearchBatch, True) if self.case['batch_type'] != None and self.case['runcase']: self.displayBatchInfo() # Script info is based on the XML model self.displayScriptInfo() self.case.undoStartGlobal()
def coupling(package, domains, casedir, package_compute = None): use_saturne = False use_syrthes = False use_neptune = False # Use alternate compute (back-end) package if defined config = configparser.ConfigParser() config.read(package.get_global_configfile()) if package_compute == None: package_compute = package # Initialize code domains sat_domains = [] syr_domains = [] nep_domains = [] ast_domain = None fsi_coupler = None if domains == None: raise RunCaseError('No domains defined.') for d in domains: if ((d.get('script') == None or d.get('domain') == None) \ and d.get('coupler') == None): msg = 'Check your coupling definition.\n' msg += 'script or domain key is missing.' raise RunCaseError(msg) if (d.get('solver') == 'Code_Saturne' or d.get('solver') == 'Saturne'): try: runcase = cs_runcase.runcase(os.path.join(os.getcwd(), d.get('domain'), 'SCRIPTS', d.get('script'))) param = runcase.get_parameters() except Exception: err_str = 'Cannot read Code_Saturne script: ' + runcase raise RunCaseError(err_str) dom = domain(package, package_compute = package_compute, name = d.get('domain'), param = param, n_procs_weight = d.get('n_procs_weight'), n_procs_min = d.get('n_procs_min'), n_procs_max = d.get('n_procs_max')) use_saturne = True sat_domains.append(dom) elif (d.get('solver') == 'SYRTHES'): try: dom = syrthes_domain(package, cmd_line = d.get('opt'), name = d.get('domain'), param = d.get('script'), n_procs_weight = d.get('n_procs_weight'), n_procs_min = d.get('n_procs_min'), n_procs_max = d.get('n_procs_max')) except Exception: err_str = 'Cannot create SYRTHES domain. Opt = ' + d.get('opt') + '\n' err_str += ' domain = ' + d.get('domain') err_str += ' script = ' + d.get('script') + '\n' err_str += ' n_procs_weight = ' + str(d.get('n_procs_weight')) + '\n' raise RunCaseError(err_str) use_syrthes = True syr_domains.append(dom) elif (d.get('solver') == 'NEPTUNE_CFD'): try: runcase = cs_runcase.runcase(os.path.join(os.getcwd(), d.get('domain'), 'SCRIPTS', d.get('script'))) param = runcase.get_parameters() except Exception: err_str = 'Cannot read NEPTUNE_CFD script: ' + runcase raise RunCaseError(err_str) dom = domain(package, package_compute = package_compute, name = d.get('domain'), param = param, n_procs_weight = d.get('n_procs_weight'), n_procs_min = d.get('n_procs_min'), n_procs_max = d.get('n_procs_max')) use_neptune = True nep_domains.append(dom) elif (d.get('solver') == 'Code_Aster' or d.get('solver') == 'Aster'): if ast_domain: err_str = 'Only 1 Code_Aster domain is currently handled\n' raise RunCaseError(err_str) try: dom = aster_domain(package, name = d.get('domain'), param = d.get('script')) except Exception: err_str = 'Cannot create Code_Aster domain.\n' err_str += ' domain = ' + d.get('domain') + '\n' err_str += ' script = ' + d.get('script') + '\n' raise RunCaseError(err_str) ast_domain = dom elif (d.get('coupler') == 'FSI_coupler'): if fsi_coupler: err_str = 'Only 1 FSI coupler is currently handled\n' raise RunCaseError(err_str) try: fsi_coupler = {'max_time_steps' : d.get('max_time_steps'), 'n_sub_iterations' : d.get('n_sub_iterations'), 'time_step' : d.get('time_step'), 'start_time' : d.get('start_time'), 'epsilon' : d.get('epsilon')} except Exception: err_str = 'Cannot create FSI coupler\n' err_str += ' max_time_steps = ' + d.get('max_time_steps') + '\n' err_str += ' n_sub_iterations = ' + d.get('n_sub_iterations' + '\n') err_str += ' time_step = ' + d.get('time_step') + '\n' err_str += ' start_time = ' + d.get('start_time') + '\n' err_str += ' epsilon = ' + d.get('epsilon') + '\n' raise RunCaseError(err_str) else: err_str = 'Unknown code type : ' + d.get('solver') + '.\n' raise RunCaseError(err_str) # Now handle case for the corresponding calculation domain(s). c = case(package, package_compute = package_compute, case_dir = casedir, domains = sat_domains + nep_domains, syr_domains = syr_domains, ast_domain = ast_domain, fsi_coupler = fsi_coupler) msg = ' Coupling execution between: \n' if use_saturne == True: msg += ' o Code_Saturne [' + str(len(sat_domains)) + ' domain(s)];\n' if use_syrthes == True: msg += ' o SYRTHES [' + str(len(syr_domains)) + ' domain(s)];\n' if use_neptune == True: msg += ' o NEPTUNE_CFD [' + str(len(nep_domains)) + ' domain(s)];\n' if ast_domain or fsi_coupler: msg += ' o Code_Aster [1 domain(s)];\n' msg += ' [1 coupler(s)];\n' sys.stdout.write(msg+'\n') return c