示例#1
0
 def write_transfer_function_file(self):
     """ write transfer_function.f file for the specific subprocesses """
     
     text='$B$ TF_HEADER $E$\n'
     text+=self.text_get_central_point()+'\n'
     text+=self.text_transfer_fct()+'\n'
     text+=self.text_tf_E_for_part()+'\n'
     
     template = mod_file.Mod_file(rule_file='./Source/MadWeight/transfer_function/input/mod_generic')
     text=mod_file.mod_text(text,template.dico)
     text=put_in_fortran_format(text)
     
     ff=open(self.dir+'/call_TF.f','w')
     ff.writelines(text)
     ff.close()
示例#2
0
def create_all_fortran_code(MW_info, i=1):
    """goes  in each subprocess and creates the fortran code in each of them"""
    import madweight
    # load template for file
    template = mod_file.Mod_file(
        rule_file='./Source/MadWeight/mod_file/mod_main_code')
    # load MadWeight option
    for MW_dir in MW_info.MW_listdir:
        print 'treating', MW_dir, 'directory'
        diag = MG_diagram(
            './SubProcesses/' + MW_dir, 'param_card_1.dat',
            './Source/MadWeight/transfer_function/ordering_file.inc', i,
            MW_info)
        diag.create_all_fortran_code()
        diag.write_code(template)
示例#3
0
 def create_transfer_functions(self):
     """ define for each block the 3 functions TF and the three TF width """
  
     def create_optional_variable(text,blockname,variable,list_var=[]):
         """ replace all #1,#2 by fortran name """
         
         output=''
         Pattern=re.compile(r'''#(\d*)''')
         prov=Pattern.split(text)
         i=0
         while i<len(prov)-1:
             output+=prov[i]
             i+=1
             if not('tf_'+blockname+"_"+variable+"_"+prov[i] in list_var):
                 list_var.append('tf_'+blockname+"_"+variable+"_"+prov[i])
             output+='tf_'+blockname+"_"+variable+"_"+prov[i]
             i+=1    
         output+=prov[-1]
         return output,list_var
     
     template = mod_file.Mod_file(rule_file='./input/mod_generic')
     list_var=[] #list all variable needed to defined in order to be set in the transfer card
     
     text='$B$ TF_HEADER $E$'
     text=mod_file.mod_text(text,template.dico)
     for block in self.block.values():
         for variable in ['E','THETA','PHI']:
             tf_var='tf_'+variable+'_'+block.name
             new_text='$B$ GENERIC_TF $E$'
             width_var='width_'+variable+'_'+block.name  
             new_text+='$B$ GENERIC_WIDTH $E$'
             new_text=mod_file.mod_text(new_text,template.dico)  #extend generic
             new_rule={'tf_var':tf_var,'width_var':width_var}
             new_rule['tf_definition']=block[variable].tf_code
             new_rule['width_definition']=block[variable].width_code
             new_text=mod_file.mod_text(new_text,new_rule) #change default variable in real one
             new_text,list_var=create_optional_variable(new_text,block.name,variable,list_var)
             new_text=put_in_fortran_format(new_text)
             text+=new_text
             
     text=put_in_fortran_format(text)
     ff=open('./transfer_function.f','w')
     ff.writelines(text)
     return list_var