def Creation_Fichier_Export_Esclave(self, tmp_macr_recal): """ Creation du fichier .export pour le calcul esclave """ # Recuperation du fichier .export if self.export: export = self.export else: list_export = glob.glob('*.export') if len(list_export) == 0: UTMESS('F', 'RECAL0_4') elif len(list_export) > 1: UTMESS('F', 'RECAL0_5') export = list_export[0] # On modifie le profil prof = AsterProfil(export) # En local user_mach = '' # Chaine user@hostname (pour les calculs distribues et en batch) try: username = prof.param['username'][0] except: try: username = os.getlogin() except: username = getpass.getuser() user_mach_dist = "%s@%s:" % (username, socket.gethostname()) # On cherche s'il y a un fichier hostfile pour rajouter user@hostname l_fr = getattr(prof, 'data') l_tmp = l_fr[:] for dico in l_tmp: if dico['type'] == 'hostfile': user_mach = user_mach_dist break # Parametres ajoutes par le mot-cle CALCUL_ESCLAVE if self.tpsjob: prof.param['tpsjob'] = str(self.tpsjob) if self.tpmax: prof.args['tpmax'] = str(self.tpmax) if self.mem_aster: prof.param['mem_aster'] = str(self.mem_aster) if self.memjob: prof.param['memjob'] = str(self.memjob) if self.memjeveux: prof.args['memjeveux'] = str(self.memjeveux) if self.mpi_nbcpu: prof.param['mpi_nbcpu'] = str(self.mpi_nbcpu) if self.mpi_nbnoeud: prof.param['mpi_nbnoeud'] = str(self.mpi_nbnoeud) # En batch et distribue if self.MODE == 'BATCH': user_mach = user_mach_dist prof.param['mode'] = 'batch' # if self.mem_aster: prof.param['mem_aster'] = str(self.mem_aster) # Choix d'une classe reservee if self.CLASSE: prof.param['classe'] = self.CLASSE # xterm if 'xterm' in prof.param: del prof.param['xterm'] # fichier/répertoire for lab in ('data', 'resu'): l_fr = getattr(prof, lab) l_tmp = l_fr[:] for dico in l_tmp: # répertoires if dico['isrep']: # base non prise en compte if dico['type'] in ('base', 'bhdf'): l_fr.remove(dico) if lab == 'resu': dico['path'] = user_mach + os.path.join( tmp_macr_recal, os.path.basename(dico['path'])) # fichiers else: # Nom du fichier .mess (pour recuperation dans REPE_OUT) if dico['ul'] == 6: self.nom_fichier_mess_fils = os.path.basename( dico['path']) # Nom du fichier .resu (pour recuperation dans REPE_OUT) if dico['ul'] == 8: self.nom_fichier_resu_fils = os.path.basename( dico['path']) # Ancien .comm non pris en compte # Fichier d'unite logique UNITE_RESU (rapport de # MACR_RECAL) non pris en compte if dico['type'] == 'comm' or (dico['ul'] == self.UNITE_RESU and lab == 'resu'): l_fr.remove(dico) # Fichier d'unite logique UL devient le nouveau .comm elif dico['ul'] == self.UNITE_ESCL: self.fichier_esclave = dico['path'] dico['type'] = 'comm' dico['ul'] = 1 dico['path'] = user_mach + os.path.join( os.getcwd(), 'fort.%d' % self.UNITE_ESCL) # Tous les autres fichiers en Resultat elif lab == 'resu': l_fr.remove(dico) # Tous les autres fichiers en Donnees elif lab == 'data': if dico['type'] not in ('exec', 'ele'): if dico['ul'] != 0: # Traite le cas des sources python sourchargees # Si distant/distribue on doit prendre les # fichiers de donnes dans un endroit partage # entre les machines/noeuds if user_mach: src = dico['path'] dst = os.path.join( tmp_macr_recal, os.path.basename(dico['path'])) try: shutil.copyfile(src, dst) dico['path'] = user_mach + os.path.join( tmp_macr_recal, os.path.basename(dico['path'])) except Exception as e: if debug: print(e) else: dico['path'] = user_mach + os.path.join( os.getcwd(), 'fort.%s' % dico['ul']) # sinon on garde la ligne telle quelle setattr(prof, lab, l_fr) # Ecriture du nouveau fichier export prof.WriteExportTo(self.new_export) if debug: os.system('cp ' + self.new_export + ' /tmp')
def run_distrib(self, list_val): """ Module permettant de lancer N+1 calculs avec le module de calculs distribues d'asrun """ # ---------------------------------------------------------------------------- # Parametres # ---------------------------------------------------------------------------- # Code_Aster installation ASTER_ROOT = self.ASTER_ROOT as_run = self.as_run # General resudir = self.resudir clean = self.clean info = self.info # Study export = self.export # MACR_RECAL inputs parametres = self.parametres calcul = self.calcul experience = self.experience parametres = self.parametres calcul = self.calcul experience = self.experience CalcGradient = self.CalcGradient NMAX_SIMULT = self.NMAX_SIMULT # ---------------------------------------------------------------------------- # Import des modules python d'ASTK # ---------------------------------------------------------------------------- if not ASTER_ROOT: try: ASTER_ROOT = os.environ['ASTER_ROOT'] except: pass try: sys.path.append( os.path.join(ASTER_ROOT, 'ASTK', 'ASTK_SERV', 'lib')) sys.path.append( os.path.join( ASTER_ROOT, 'lib', 'python%s.%s' % (sys.version_info[0], sys.version_info[1]), 'site-packages')) except: pass assert is_list_of_dict(list_val) nbval = len(list_val) # ---------------------------------------------------------------------------- # Generation des etudes esclaves # ---------------------------------------------------------------------------- sys.argv = [''] run = AsRunFactory() # if info<=2: run.options['debug_stderr'] = False # pas d'output d'executions des esclaves dans l'output maitre if self.unity_follow and info == 2: run.options['debug_stderr'] = True else: run.options[ 'debug_stderr'] = False # pas d'output d'executions des esclaves dans l'output maitre # Master profile prof = AsterProfil(run=run, filename=export) tmp_param = tempfile.mkdtemp() try: username = prof.param['username'][0] except: username = os.environ['LOGNAME'] try: noeud = prof.param['noeud'][0] except: noeud = platform.uname()[1] tmp_param = "%s@%s:%s" % (username, noeud, tmp_param) prof.Set( 'R', { 'type': 'repe', 'isrep': True, 'ul': 0, 'compr': False, 'path': tmp_param }) if info >= 2: print(prof) # Si batch n'est pas possible, on bascule en interactif if not prof['mode'][0] or (prof['mode'][0] == 'batch' and run.get('batch') == 'non'): UTMESS('I', 'RECAL0_28', valk=noeud) prof['mode'] = 'interactif' prof['version'] = ExecutionParameter().get_option("rcdir") # result directories if resudir: if not os.path.isdir(resudir): try: os.mkdir(resudir) except: if info >= 1: UTMESS('A', 'RECAL0_82', valk=resudir) resudir = None if not resudir: # Par defaut, dans un sous-repertoire du repertoire d'execution pref = 'tmp_macr_recal_' # On cherche s'il y a un fichier hostfile pour placer les fichiers dans un repertoire partage l_fr = getattr(prof, 'data') l_tmp = l_fr[:] for dico in l_tmp: if dico['type'] == 'hostfile': pref = get_shared_tmpdir('tmp_macr_recal_') break # Si batch alors on place les fichiers dans un repertoire partage if prof['mode'][0] == 'batch': pref = get_shared_tmpdir('tmp_macr_recal1_') resudir = tempfile.mkdtemp(prefix=pref) flashdir = os.path.join(resudir, 'flash') if info >= 1: UTMESS('I', 'RECAL0_81', valk=resudir) prof.WriteExportTo(os.path.join(resudir, 'master.export')) # get hostrc object hostrc = get_hostrc(run, prof) # timeout before rejected a job timeout = prof.get_timeout() # Ajout des impressions de tables a la fin du .comm t = [] reponses = calcul for i in range(len(reponses)): _ul = str(int(100 + i)) num_ul = '99' # Pour la dynamique la table avec la matrice MAC a un traitement different if self.DYNAMIQUE: if ('MAC' in reponses[i][2]): t.append(self.ajout_post_mac(reponses[i])) try: os.remove('tmp_macr_recal' + os.sep + "REPE_TABLE" + os.sep + "fort." + _ul) except: pass t.append("\n# Recuperation de la table : " + str(reponses[i][0]) + "\n") t.append("DEFI_FICHIER(UNITE=" + num_ul + ", FICHIER='" + os.path.join('.', 'REPE_OUT', 'fort.' + _ul) + "',);\n") t.append("IMPR_TABLE(TABLE=" + str(reponses[i][0]) + ", FORMAT='ASTER', UNITE=" + num_ul + ", INFO=1, FORMAT_R='E30.20',);\n") t.append("DEFI_FICHIER(ACTION='LIBERER', UNITE=" + num_ul + ",);\n") # Pour la dynamique uniquement if self.DYNAMIQUE: if ( self.DYNAMIQUE['APPARIEMENT_MANUEL'] == 'OUI' and self.graph_mac and (True in ['MAC' in reponses[ii][2] for ii in range(len(reponses))]) ): ## on cherche a inverser la liste de frequences potentiellement changee par la fenetre MAC for ind_rep in range(len(reponses)): if reponses[ind_rep][2] == 'FREQ': t.append("data1 = " + reponses[ind_rep][0] + ".EXTR_TABLE().Array('" + reponses[ind_rep][1] + "','FREQ')\n" ) ## on recupere la table des frequences t.append("nume_freq=data1[:,0].tolist()\n") t.append("val_freq=data1[:,1].tolist()\n") t.append( "val_freq_permute=[]\n" ) ## val_freq_permute contient la liste de frequences permutee t.append("for ii in range(len(list_num_pour_freq)):\n") t.append( " if list_num_pour_freq[ii]==list_exp_pour_freq[ii]:\n" ) t.append( " val_freq_permute.append(val_freq[ii])\n") t.append(" else:\n") t.append( " ii_p= list_exp_pour_freq.index(list_num_pour_freq[ii])\n" ) t.append( " val_freq_permute.append(val_freq[ii_p])\n") t.append("DETRUIRE(CONCEPT=_F(NOM=" + str(reponses[ind_rep][0]) + "),)\n") t.append( reponses[ind_rep][0] + "=CREA_TABLE(LISTE=(_F(PARA='" + reponses[ind_rep][1] + "',LISTE_I=nume_freq,),_F(PARA='FREQ',LISTE_R=val_freq_permute,),),)\n" ) # number of threads to follow execution numthread = 1 # ---------------------------------------------------------------------------- # Executions des etudes esclaves # ---------------------------------------------------------------------------- # ----- Execute calcutions in parallel using a Dispatcher object # elementary task... task = DistribParametricTask( run=run, prof=prof, # IN hostrc=hostrc, nbmaxitem=self.NMAX_SIMULT, timeout=timeout, resudir=resudir, flashdir=flashdir, keywords={'POST_CALCUL': '\n'.join(t)}, info=info, nbnook=[ 0, ] * numthread, exec_result=[]) # OUT # ... and dispatch task on 'list_tests' etiq = 'calc_%%0%dd' % (int(log10(nbval)) + 1) labels = [etiq % (i + 1) for i in range(nbval)] couples = list(zip(labels, list_val)) if info >= 2: print(couples) execution = Dispatcher(couples, task, numthread=numthread) # ---------------------------------------------------------------------------- # Liste des diagnostics # ---------------------------------------------------------------------------- d_diag = {} for result in task.exec_result: label = result[0] diag = result[2] if len(result) >= 8: output_filename = os.path.join('~', 'flasheur', str(result[7])) else: output_filename = '' d_diag[label] = diag # Affichage de l'output de l'esclave dans l'output du maitre if self.unity_follow: affiche(unity=self.unity_follow, filename=output_filename, label=label, filetype='stdout') # Calcul esclave NOOK if not diag[0:2] in ['OK', '<A']: # Affichage de l'output et/ou de l'error de l'esclave dans l'output du maitre try: affiche(unity=None, filename=output_filename, label=label, filetype='stdout') error_filename = '.'.join( output_filename.split('.') [0:-1]) + '.e' + output_filename.split('.')[-1][1:] affiche(unity=None, filename=error_filename, label=label, filetype='stderr') except Exception as e: print(e) if diag in ['<F>_NOT_RUN', '<A>_NOT_SUBMITTED']: UTMESS('F', 'RECAL0_86', valk=(label, diag)) else: UTMESS('A', 'RECAL0_83', valk=(label, output_filename)) if not d_diag: UTMESS('F', 'RECAL0_84', valk=resudir) self.list_diag = [d_diag[label] for label in labels] # ---------------------------------------------------------------------------- # Arret si tous les jobs ne se sont pas deroules correctement # ---------------------------------------------------------------------------- if sum(task.nbnook) > 0: UTMESS('F', 'RECAL0_84', valk=resudir) # ---------------------------------------------------------------------------- # Recuperation des tables calculees # ---------------------------------------------------------------------------- Lcalc = [] i = 0 for c in labels: tbl = get_tables(tables_calc=calcul, tmp_repe_table=os.path.join( resudir, c, 'REPE_OUT'), prof=prof) Lcalc.append(tbl) # On stocke sous la forme d'une liste de numpy i += 1 # ---------------------------------------------------------------------------- # Calcul de la fonctionnelle et du gradient # ---------------------------------------------------------------------------- if debug: print("AA4/Lcalc=", Lcalc) fonctionnelle, gradient = self.calc2fonc_gradient(Lcalc) # ---------------------------------------------------------------------------- # Clean result directories # ---------------------------------------------------------------------------- if clean: shutil.rmtree(resudir, ignore_errors=True) # ---------------------------------------------------------------------------- # Save all calculated responses # ---------------------------------------------------------------------------- self.Lcalc = Lcalc return fonctionnelle, gradient
def RunAster(run, *args): """Allow to run Code_Aster with or without compiling additional source files, check a development, run a list of test cases... """ run.print_timer = True prev = os.getcwdu() # ----- check argument if len(args) != 1: run.parser.error( _(u"'--%s' requires one argument") % run.current_action) # 1. ----- initializations jn = run['num_job'] fprof = get_tmpname(run, run['tmp_user'], basename='profil_astk') run.ToDelete(fprof) # 1.1. ----- check argument type # 1.1.1. ----- use profile from args if isinstance(args[0], AsterProfil): prof = args[0].copy() prof.WriteExportTo(fprof) forig = fprof else: # 1.1.2. ----- read profile from args forig = args[0] kret = run.Copy(fprof, forig, niverr='<F>_PROFILE_COPY') prof = AsterProfil(fprof, run) if not run.IsRemote(forig): export_fname = run.PathOnly(get_absolute_path(forig)) prof.absolutize_filename(export_fname) if not prof['mode'][0] in ('batch', 'interactif'): run.Mess(_(u"Unknown mode (%s), use 'interactif' instead") % \ repr(prof['mode'][0]), 'UNEXPECTED_VALUE') prof['mode'] = ['interactif'] run.DBG("Input export : %s" % fprof, prof) # 1.2. get AsterConfig and AsterBuild objects REPREF = prof.get_version_path() conf = build_config_from_export(run, prof) build = AsterBuild(run, conf) DbgPara = { 'debug': { 'exe': conf['BIN_DBG'][0], 'suff': conf['BINOBJ_DBG'][0], 'libast': conf['BINLIB_DBG'][0], 'libfer': conf['BINLIBF_DBG'][0] }, 'nodebug': { 'exe': conf['BIN_NODBG'][0], 'suff': conf['BINOBJ_NODBG'][0], 'libast': conf['BINLIB_NODBG'][0], 'libfer': conf['BINLIBF_NODBG'][0] }, } # 1.3. set environment depending on version for f in conf.get_with_absolute_path('ENV_SH'): run.AddToEnv(f) # 1.4. set runner parameters klass = Runner # allow to customize of the execution objects if run.get('schema_execute'): schem = get_plugin(run['schema_execute']) run.DBG("calling plugin : %s" % run['schema_execute']) klass = schem(prof) runner = klass(conf.get_defines()) iret = runner.set_cpuinfo(prof['mpi_nbnoeud'][0], prof['mpi_nbcpu'][0]) if iret == 1: run.Mess( ufmt( _(u"%s is not a MPI version of Code_Aster. " "The number of nodes/processors must be equal to 1."), REPREF), "<F>_INVALID_PARAMETER") elif iret != 0: run.Mess(_(u"incorrect value for mpi_nbnoeud (%s) or mpi_nbcpu (%s)") \ % (prof['mpi_nbnoeud'][0], prof['mpi_nbcpu'][0]), '<F>_INVALID_PARAMETER') # 1.5. rep_trav from profile or from run[...] reptrav = runner.set_rep_trav(prof['rep_trav'][0], prof['mode'][0]) # write reptrav in the export prof['rep_trav'] = reptrav prof.WriteExportTo(prof.get_filename()) #XXX overrides the original export if forig != prof.get_filename(): run.Copy(forig, prof.get_filename(), niverr='<A>_ALARM') # add reptrav to LD_LIBRARY_PATH (to find dynamic libs provided by user) old = os.environ.get("LD_LIBRARY_PATH", "") os.environ["LD_LIBRARY_PATH"] = (reptrav + os.pathsep + old).strip( os.pathsep) # do not reinitialize rep_trav if if prof['prep_env'][0] not in NO_VALUES: run.MkDir(reptrav, chmod=0700) if prof['detr_rep_trav'][0] not in NO_VALUES: run.ToDelete(reptrav) # 1.6. copy profile in rep_trav kret = run.Copy(osp.join(reptrav, jn + '.export'), fprof) # ... and config file as ./config.txt conf.WriteConfigTo(osp.join(reptrav, 'config.txt')) # 1.7. debug/nodebug dbg = prof['debug'][0] if dbg == '': dbg = 'nodebug' # 1.8. default values exetmp = osp.join(REPREF, DbgPara[dbg]['exe']) cmdetmp = osp.join(REPREF, conf['BINCMDE'][0]) eletmp = osp.join(REPREF, conf['BINELE'][0]) # 2. ----- read profile values # it's valid because exec, cmde and ele must appear only once # these values will be overidden if they are available in reptrav # after an occurence of 'make_...' if prof.Get('DR', 'exec'): exetmp = prof.Get('DR', 'exec')[0]['path'] if prof.Get('DR', 'cmde'): cmdetmp = prof.Get('DR', 'cmde')[0]['path'] if prof.Get('DR', 'ele'): eletmp = prof.Get('DR', 'ele')[0]['path'] # order of actions : list_actions = [ 'make_exec', 'make_cmde', 'make_ele', 'make_etude', 'make_dbg', 'make_env', 'astout', 'distribution', 'multiple', 'exec_crs', 'exec_crp' ] # 3. ==> Let's go ! # 3.0. check if we know what to do for act in prof['actions']: if act == '': run.Mess(_(u'nothing to do'), 'OK') elif not act in list_actions: run.Mess(_(u'unknown action : %s') % act, '<A>_ALARM') # check if the version allows developments if conf['DEVEL'][0] in NO_VALUES and \ ( 'make_exec' in prof['actions'] or \ 'make_cmde' in prof['actions'] or \ 'make_ele' in prof['actions'] ): run.Mess( _(u'The configuration of this version does not allow ' 'user developments.'), '<F>_ERROR') # # 3.1. ----- make_exec # iret = 0 if 'make_exec' in prof['actions']: run.DBG(u'Start make_exec action') exetmp = osp.join(reptrav, 'aster.exe') tit = _(u'Compilation of source files') run.Mess(tit, 'TITLE') run.timer.Start(tit) repact = osp.join(reptrav, 'make_exec') repobj = osp.join(repact, 'repobj') run.MkDir(repact) lf = [] for typ in ('c', 'f', 'f90'): for rep in [l['path'] for l in prof.Get('D', typ=typ)]: jret, lbi = build.Compil(typ.upper(), rep, repobj, dbg, rep_trav=repact, error_if_empty=True, numthread='auto') iret = max(iret, jret) lf.extend(lbi) # liste des fichiers surchargés vers = get_aster_version(REPREF) vers = '.'.join(vers[:3]) fsurch = osp.join(repact, 'surchg.f') listsurcharge(vers, fsurch, lf) jret, lbi = build.Compil('F', fsurch, repobj, dbg, repact) run.timer.Stop(tit) run.CheckOK() tit = _(u'Build executable') run.Mess(tit, 'TITLE') run.timer.Start(tit) libaster = osp.join(REPREF, DbgPara[dbg]['libast']) libferm = osp.join(REPREF, DbgPara[dbg]['libfer']) # for backward compatibility if run.IsDir(libaster): libaster = osp.join(libaster, 'lib_aster.lib') if run.IsDir(libferm): libferm = osp.join(libferm, 'ferm.lib') lobj = glob(osp.join(repobj, '*.o')) # build an archive if there are more than NNN object files if len(lobj) > 500: run.timer.Stop(tit) tit2 = _(u'Add object files to library') run.timer.Start(tit2) libtmp = osp.join(repobj, 'libsurch.a') run.Copy(libtmp, libaster) kret = build.Archive(repobj, libtmp, force=True) lobj = [] libaster = libtmp run.timer.Stop(tit2) run.timer.Start(tit) kret = build.Link(exetmp, lobj, libaster, libferm, repact) run.timer.Stop(tit) run.CheckOK() tit = _(u'Copying results') run.timer.Start(tit, num=999) if prof.Get('R', typ='exec'): exe = prof.Get('R', typ='exec')[0] run.Delete(exe['path'], remove_dirs=False) iret = run.MkDir(osp.dirname(exe['path'])) iret = run.Copy(exe['path'], exetmp) exedata = prof.Get('D', typ='exec') if exedata and exedata[0]['path'] != exe['path']: exetmp = exedata[0]['path'] run.timer.Stop(tit) run.Mess(_(u'Code_Aster executable successfully created'), 'OK') # # 3.2. ----- make_cmde # if 'make_cmde' in prof['actions']: run.DBG(u'Start make_cmde action') tit = _(u"Compilation of commands catalogue") cmdetmp = osp.join(reptrav, 'cata_commande') run.timer.Start(tit) repact = osp.join(reptrav, 'make_cmde') run.MkDir(repact) kargs = { 'exe': exetmp, 'cmde': cmdetmp, } kargs['capy'] = [l['path'] for l in prof.Get('D', typ='capy')] lfun = prof.Get('D', typ='unig') if lfun: kargs['unigest'] = build.GetUnigest(lfun[0]['path']) if prof.Get('D', typ='py'): kargs['py'] = [l['path'] for l in prof.Get('D', typ='py')] jret = build.CompilCapy(REPREF, repact, **kargs) #i18n=True, run.timer.Stop(tit) run.CheckOK() tit = _(u'Copying results') run.timer.Start(tit) if prof.Get('R', typ='cmde'): cmde = prof.Get('R', typ='cmde')[0] iret = run.MkDir(cmde['path']) iret = run.Copy(cmde['path'], osp.join(cmdetmp, 'cata*.py*')) run.timer.Stop(tit) # # 3.3. ----- make_ele # if 'make_ele' in prof['actions']: run.DBG(u'Start make_ele action') tit = _(u"Compilation of elements") eletmp = osp.join(reptrav, 'elem.1') run.timer.Start(tit) repact = osp.join(reptrav, 'make_ele') run.MkDir(repact) kargs = { 'exe': exetmp, 'cmde': cmdetmp, 'ele': eletmp, } kargs['cata'] = [l['path'] for l in prof.Get('D', typ='cata')] lfun = prof.Get('D', typ='unig') if lfun: kargs['unigest'] = build.GetUnigest(lfun[0]['path']) if prof.Get('D', typ='py'): kargs['py'] = [l['path'] for l in prof.Get('D', typ='py')] jret = build.CompilEle(REPREF, repact, **kargs) run.timer.Stop(tit) run.CheckOK() tit = _(u'Copying results') run.timer.Start(tit) if prof.Get('R', typ='ele'): ele = prof.Get('R', typ='ele')[0] iret = run.MkDir(osp.dirname(ele['path'])) iret = run.Copy(ele['path'], eletmp) run.timer.Stop(tit) # # 3.4. ----- make_env / make_etude / make_dbg # if 'make_env' in prof['actions'] or 'make_etude' in prof['actions'] or \ 'make_dbg' in prof['actions']: run.DBG(u'Start make_etude/make_env/make_dbg action') os.chdir(reptrav) run.Mess(_(u'Code_Aster execution'), 'TITLE') # 3.4.1. prepare reptrav to run Code_Aster (proc# = 0) only_env = 'make_env' in prof['actions'] kargs = { 'exe': exetmp, 'cmde': cmdetmp, 'ele': eletmp, 'lang': prof['lang'][0], 'only_env': only_env, } lfun = prof.Get('D', typ='unig') if lfun: kargs['unigest'] = build.GetUnigest(lfun[0]['path']) if prof.Get('D', typ='py'): kargs['py'] = [l['path'] for l in prof.Get('D', typ='py')] tit = _(u'Preparation of environment') run.timer.Start(tit) run.Mess(ufmt(_(u'prepare environment in %s'), reptrav)) if prof['prep_env'][0] != 'no': build.PrepEnv(REPREF, reptrav, dbg=dbg, **kargs) else: run.Mess(_(u'... skipped (%s = no) !') % 'prep_env', 'SILENT') run.timer.Stop(tit) # 3.4.2. copy datas (raise <E> errors if failed) tit = _(u'Copying datas') run.Mess(tit, 'TITLE') run.timer.Start(tit) if prof['copy_data'][0] not in NO_VALUES: copyfiles(run, 'DATA', prof) else: run.Mess(_(u'... skipped (%s = no) !') % 'copy_data', 'SILENT') print3(os.getcwdu()) run.timer.Stop(tit) # 3.4.3. execution diag, tcpu, tsys, ttot, copybase = execute(reptrav, multiple=False, with_dbg='make_dbg' in prof['actions'], only_env=only_env, runner=runner, run=run, conf=conf, prof=prof, build=build, exe=exetmp) if not 'make_env' in prof['actions']: # 3.4.4. copy results tit = _(u'Copying results') run.Mess(tit, 'TITLE') run.timer.Start(tit) if prof['copy_result'][0] not in NO_VALUES: emit_alarm = prof['copy_result_alarm'][0] not in NO_VALUES copyfiles(run, 'RESU', prof, copybase, emit_alarm) else: run.Mess( _(u'... skipped (%s = no) !') % 'copy_result', 'SILENT') run.timer.Stop(tit) run.Mess(_(u'Code_Aster run ended'), diag) # 3.4.5. add .resu/.erre to output for testcases ctest = prof['parent'][0] == "astout" if ctest: run.Mess(_(u'Content of RESU file'), 'TITLE') run.FileCat('fort.8', magic.get_stdout()) run.Mess(_(u'Content of ERROR file'), 'TITLE') run.FileCat('fort.9', magic.get_stdout()) # 3.4.6. notify the user if prof['notify'][0]: content = _( '[Code_Aster] job %(job)s on %(server)s ended: %(diag)s') content = content % { 'job': prof.get_jobname(), 'diag': diag, 'server': prof['serveur'][0], } dest = ','.join(prof['notify']) run.SendMail(dest=dest, text=content, subject=content.splitlines()[0]) run.Mess(_(u'Email notification sent to %s') % dest) run.CheckOK() os.chdir(prev) # 3.5. ----- astout if 'astout' in prof['actions']: run.DBG(u'Start astout action') kargs = { 'exe': exetmp, 'cmde': cmdetmp, 'ele': eletmp, 'numthread': prof['numthread'][0], } os.chdir(reptrav) RunAstout(run, conf, prof, runner=runner, **kargs) os.chdir(prev) # 3.6. ----- distribution if 'distribution' in prof['actions']: run.DBG(u'Start distribution action') kargs = { 'exe': exetmp, 'cmde': cmdetmp, 'ele': eletmp, 'numthread': prof['numthread'][0], } Parametric(run, prof, runner=runner, **kargs) # 3.7. ----- multiple if 'multiple' in prof['actions']: run.DBG(u'Start multiple action') Multiple(run, prof, runner=runner, numthread=prof['numthread'][0]) # 4. ----- clean up if 'make_env' in prof['actions'] and prof['detr_rep_trav'][ 0] not in NO_VALUES: run.DoNotDelete(reptrav)