Esempio n. 1
0
def multi_run(runs):
    """
    Run several simulations

    Arg:
    runs - A list of dictionaries.
        Dic; "processes"; The number of processes
             "sdp"; The event control file parameters, as attributes on an
                    object

    """
    for run in runs:
        # get a temporary file
        (handle, control_file) = tempfile.mkstemp(
            '.py', 'multi_run_generated_')
        os.close(handle)

         # Build the base eqrm_flags.
        flags = create_parameter_data(run["sdp"])
        num_nodes = run["processes"]
        # Write an EQRM control file, then do an mpi run call
        eqrm_flags_to_control_file(control_file, flags)
        (cluster, _) = util.get_hostname()

        cmd = mpi_command(cluster, num_nodes, control_file)
        subprocess.call(cmd)

        # clean up
        os.remove(control_file)
Esempio n. 2
0
def multi_run(runs):
    """
    Run several simulations
    
    Arg:
    runs - A list of dictionaries. 
        Dic; "processes"; The number of processes
             "sdp"; The event control file parameters
             
    """
    for run in runs:
        control_file = 'temp.py'
         # Build the base eqrm_flags.
        flags = create_parameter_data(run["sdp"])
        num_nodes = run["processes"]
        # Write an EQRM control file, then do an mpi run call
        eqrm_flags_to_control_file(control_file, flags)
        (cluster, _) = util.get_hostname()
    
        cmd = mpi_command(cluster, num_nodes, control_file)
        subprocess.call(cmd)
Esempio n. 3
0
def multi_run(base_control,
              nodes, 
              sites=None,
              max_site_index=None,
              input_dir=None,
              output_dir_funct=None,
              total_events=None, 
              #execute=True, 
              **kwargs):
    """
    Run several simulations
    
    Arg:
    base_control -  An instance with attributes of EQRM paramters.
    input_dir_funct -  a function that can make the input_dir string, 
                       **kwargs is passed in.
    output_dir_funct -  a function that can make the output_dir string, 
                       **kwargs is passed in.
    nodes - a list of the number of nodes to run each simulation on.
            The first value is for the first simulation ect.
    sites - a list of number of sites to run each simulation on.
            The first value is for the first simulation ect.
            The sites chosen will be spread out.
    max_site_index - The number of sites in the site file.
    total_events - a list of the number of events to run each simulation on.
            The first value is for the first simulation ect.
    **kwargs - Each key is an eqrm control file attribute. The value is
            a lists of vaules to go into each simulation.
             The first value is for the first simulation ect.
    """
    control_file = 'temp.py'
    # Build the base eqrm_flags.
    flags = create_parameter_data(base_control)
    
    # First check that all the array sizes are correct
    runs = len(nodes)
    for k, v in kwargs.items():
        if not len(v) == runs:
            msg = k  + " list is length " + len(v) + "," + runs + \
                " was expected." 
            raise ListLengthError(msg)
     
    # Start Looping
    for i, num_nodes in enumerate(nodes):       
        
        new_flags = {}
        for k, v in kwargs.items():
            kwargs_column[k] = v[i]
            
        # Add the kwargs
        flags.update(new_flags)
        
        # Add the directories
        if output_dir_funct is not None:
            flags['output_dir'] = output_dir_funct(**flags)
        if input_dir is not None:
            flags['input_dir'] = input_dir   
        
        # Write an EQRM control file, then do an mpi run call
        eqrm_flags_to_control_file(control_file, flags)
        (cluster, _) = util.get_hostname()
    
        cmd = mpi_command(cluster, num_nodes, control_file)
        subprocess.call(cmd)