static void LoadBlock (LoadState* S, void* b, size_t size)
{
 if (S->swap)
 {
  char* p=(char*) b+size-1;
  int n=size;
  while (n--) *p--=(char)ezgetc(S);
 }
 else
  ezread(S,b,size);
}
Beispiel #2
0
static void LoadBlock (lua_State* L, void* b, size_t size, ZIO* Z, int swap)
{
 if (swap)
 {
  char *p=(char *) b+size-1;
  int n=size;
  while (n--) *p--=(char)ezgetc(L,Z);
 }
 else
  ezread(L,Z,b,size);
}
static TString* LoadString (LoadState* S)
{
 size_t size=LoadSize(S);
 if (size==0)
  return NULL;
 else
 {
  char* s=luaZ_openspace(S->L,S->b,size);
  ezread(S,s,size);
  return luaS_newlstr(S->L,s,size-1);        /* remove trailing '\0' */
 }
}
Beispiel #4
0
static TString* LoadWString (LoadState* S)
{
 size_t size=LoadSize(S);
 if (size==0)
  return NULL;
 else
 {
  lua_WChar* s=(lua_WChar *)luaZ_openspace(S->L,S->b,size*2);
  ezread(S,s,size*2);
  return luaS_newlwstr(S->L,(const lua_WChar*)s,size-1);	/* remove trailing '\0' */
 }
}
static void LoadVector (LoadState* S, void* b, int m, size_t size)
{
 if (S->swap)
 {
  char* q=(char*) b;
  while (m--)
  {
   char* p=q+size-1;
   int n=size;
   while (n--) *p--=(char)ezgetc(S);
   q+=size;
  }
 }
 else
  ezread(S,b,m*size);
}
Beispiel #6
0
static void LoadVector (lua_State* L, void* b, int m, size_t size, ZIO* Z, int swap)
{
 if (swap)
 {
  char *q=(char *) b;
  while (m--)
  {
   char *p=q+size-1;
   int n=size;
   while (n--) *p--=(char)ezgetc(L,Z);
   q+=size;
  }
 }
 else
  ezread(L,Z,b,m*size);
}
Beispiel #7
0
int SeisPipe2D(DsuTask *zz)
{

  int nt,nx,nz,nw,ntpad,ntfft;
  int it,ix,iz,izz,iw,iw0,iw1,iw2,iw3,iwmin,iwmax;
  int nfreqs,verbose;

  float dt,dx,dy,dz,dw;
  float freqs[4],fw,w,scale,fftscl;
  float *p, **v, *wdxov,*sx;

  complex *cpx;
  float **qx;

  void *TabInfo;
  eTable *et;


  char 	msg[80];

  int   info, ToTid, MasterTid;
  int   sz, pz, pei;

  int	SeisIntPars[20];
  float	SeisFloPars[20];


/* Receive process control information */
  MsgLog(zz, "Receiving Control info  ... " );

  MasterTid = RecvInt(SeisIntPars, 2, -1, MsgCntl); 
  pei = SeisIntPars[0];
  ToTid = SeisIntPars[1];

  MsgLog(zz, " Ready  \n");
  
/*  Receive: 	efile and other pars ...  */

  MsgLog(zz, "Receiving parameters ..." );

  TabInfo = RecvBytes(-1, MsgTable);
  RecvFI(SeisFloPars, 10, SeisIntPars, 10, -1, -1);

  MsgLog(zz, " Ready  \n" );

/* get integer parameters */

  nt = SeisIntPars[0];
  nx = SeisIntPars[1];
  nz = SeisIntPars[2];
  ntpad = SeisIntPars[3];
  verbose = SeisIntPars[4];
  sz = SeisIntPars[5];
  pz = SeisIntPars[6];

  	
/* get Floating point parameters */
  dt = SeisFloPars[0];
  dx = SeisFloPars[1];
  dz = SeisFloPars[2];

  freqs[0] = SeisFloPars[3];
  freqs[1] = SeisFloPars[4];
  freqs[2] = SeisFloPars[5];
  freqs[3] = SeisFloPars[6];

  sz = nz / pz;
  if (pei == (pz - 1)) sz += nz % pz;

  sprintf(msg, "Receiving Velocity info (pei = %d, sz = %d) ... ", pei, sz);
  MsgLog(zz,msg);
  
  v   = alloc2float(nx, sz);

  for (iz=0; iz<sz; ++iz)
    RecvFloat(v[iz], nx, -1, MsgVel);

  MsgLog(zz, " Ready  \n" );

/* determine frequency w sampling */
  ntfft = npfar(nt+ntpad);
  nw = ntfft/2+1;
  dw = 2.0*PI/(ntfft*dt);
  iwmin = MAX(0,MIN(nw-1,NINT(2.0*PI*freqs[0]/dw)));
  iwmax = MAX(0,MIN(nw-1,NINT(2.0*PI*freqs[3]/dw)));
	
/* read extrapolator table */
  et = ezread(TabInfo);
  /* pret(zz -> fp_log, et); */
	
/* allocate workspace */

  MsgLog(zz, "Allocating space ... ");

  qx = alloc2float(nx,sz);
  sx = alloc1float(nx);
  wdxov = alloc1float(nx);
  cpx = alloc1complex(nx);
 
  MsgLog(zz, " Ready \n");

  sprintf(msg, "Process (%d) starting loop on depth steps(%d,%d)\n", 
			pei, pei*(nz/pz), pei*(nz/pz) + sz);
  MsgLog(zz, msg);

  /*  Cleanup qx */

  for (iz=0; iz<sz; ++iz)
          for (ix=0; ix<nx; ++ix)
                  qx[iz][ix] = 0.0;

  /* loop over frequencies w */
  for (iw=iwmin,w=iwmin*dw; iw<iwmax; ++iw,w+=dw) {

    if (verbose && !(iw%1)) {
      sprintf(msg, "\t%d/%d\n",iw,iwmax);
      MsgLog(zz, msg);
    }

    /* load wavefield */
    RecvCplx(cpx, nx, -1, MsgSlice);

    /* loop over depth steps nz */

    for (iz=0; iz<sz; ++iz) {

        /* compute 2.0*dx/v(x) and zero migrated data */
        for (ix=0; ix<nx; ix++)
                  sx[ix] = 2.0*dx/v[iz][ix];

        /* make w*dx/v(x) */
        for (ix=0; ix<nx; ++ix)
                wdxov[ix] = w*sx[ix];

        /* extrapolate wavefield */
        etextrap(et,nx,wdxov,cpx);

        /* accumulate migrated data */
        for (ix=0; ix<nx; ++ix)
                qx[iz][ix] += cpx[ix].r;
    }
    /* Send down the wavefield */
    if ( pei != (pz -1))
            SendCplx(cpx, nx, ToTid, MsgSlice);

  } /* End of loop for iw */

  for (iz=0; iz<sz; iz++) {

    izz = pei*(nz/pz) + iz;
    if (verbose) {
      sprintf(msg, "Sending values for iz = %d\n",izz);
      MsgLog(zz, msg);
    }

    SendFI(qx[iz], nx, &izz, 1, MasterTid, MsgDepth);
  }

  sprintf(msg, "End of processing  for (%d)\n",pei);
  MsgLog(zz, msg);

  /* free workspace */
  free1float(sx);
  free1float(wdxov);
  free2float(v);
  free2float(qx);
  free1complex(cpx);

  pvm_exit();
  return(0);
}