next up previous print clean
Next: Inversion example Up: Examples Previous: Simple parallel jobs

Complex parallel job

The script fdmod.py in the report directory parallelizes 2-D finite difference modeling using the SEPlib program Fdmod. The general form is the same as seen in the scripts in the flow example. The fdmod_par object extends the SEP.pj_base.par_job class. The user describes a regular spaced set of shot locations using the parametes oxs,dxs,nxs,ozs and the number different blocks to break the problem into using nblock. Each job process a different set of shot locations and needs its own set of parameters. The function build_sect_pars calculates the parameters that vary as a function of job and stores the contents in the dictionary sect_pars.
  def build_sect_params(self):
    """Build parameters for parallel job"""
    sect_pars={}
    nxs=int(self.param("nxs"))
    oxs=float(self.param("oxs"))
    dxs=float(self.param("dxs"))
    ozs=float(self.param("ozs"))
    nblock=self.param("nblock")
    if not nblock: nblock=nxs
    nblock=int(block)
    imin=int(n/nblock)
    nextra=n-nblock*imin
    itot=0
    for i in range(nblock):
      sect_pars[str(i)]=SEP.args.basic(name=str(i))
      ol=o+d*itot
      dl=d
      nl=imin
      if i < nextra: nl=nl+1
      itot=itot+nl
      sect_pars[str(i)].add_string("nzs=1 ozs=%f dzs=1."%(ozs))
      sect_pars[str(i)].add_string("nxs=%d oxs=%f dxs=%f"%(nl,ol,dl))
    return sect_pars

The prep_run function creates the list of parameters and defines a dictionary of parallel files. The velocity space is copied to all of the nodes using the SEP.pf_copy.parfile class, the output shot gather files are spread accross the cluster using the SEP.pf_split.parfile object.

   par_files={}
   par_files["vel"]=SEP.pf_copy.parfile(name=self.param("intag"),
     tag="intag=",usage="INPUT",njobs=len(sect_pars.keys()),restart=restart)
 
   par_files["hsfile"]=SEP.pf_split.parfile(name=self.param("hsfile"),
    dff_axis=3,tag="hsfile=",usage="OUTPUT",njobs=len(sect_pars.keys()),
     restart=restart,nblock=len(sect_pars.keys()))
The section parameters, the parallel files, and the modeling program are then added to the objects parameters and the parallel job is initialized.
   self.add_param("files",par_files)
   self.add_param("sect_pars",sect_pars)
   self.add_param("program","%s/Fdmod"%SEP.paths.sepbindir)
   SEP.pj_base.par_job.prep_run(self)

next up previous print clean
Next: Inversion example Up: Examples Previous: Simple parallel jobs
Stanford Exploration Project
5/3/2005