mat sift(const mat &H) {
  imgpyr2 blurred;
  imgpyr2 edges;
  // 1) SIFT Scale-space extrema
  int noctaves = 4, nscales = 5;
  double sigma2 = 1.6;
  lappyr2(blurred, edges, noctaves, nscales, sigma2);
  const int radius = 1;
  for (int i = 0; i < edges.size(); i++) {
    for (int j = 1; j < edges[i].size() - 1; j++) {
      // grab three blurred images from an octave
      mat E1 = edges[i][j];
      mat E0 = edges[i][j - 1];
      mat E2 = edges[i][j + 1];
      // for every pixel in E1, check to make sure that it
      // is larger or smaller than all neighbors (local extrema)
      bool max_ext = true;
      bool min_ext = true;
      for (int u = 0; u < E1.n_rows; u++) {
        for (int v = 0; v < E1.n_cols; v++) {
          if (u == 0 || v == 0 || u == E1.n_rows || v = E1.n_cols) {
            E1(u, v) = 0;
          }
          // find the extrema in the images
          for (int x = -radius; x <= radius; x++) {
            for (int y = -radius; y <= radius; y++) {
              if (E1(u, v) < E0(u + y, v + x) ||
                  E1(u, v) < E2(u + y, v + x) ||
                  E1(u, v) < E1(u + y, v + x)) {
                max_ext = false;
              }
              if (E1(u, v) > E0(u + y, v + x) ||
                  E1(u, v) > E2(u + y, v + x) ||
                  E1(u, v) > E1(u + y, v + x)) {
                min_ext = false;
              }
            }
          }
          E1(u, v) = max_ext || min_ext;
        }
      }
      // once we have the image pyramids, then we can
      // try to find the magnitude of the keypoint descriptor
    }
  }
  // 2) Accurate Keypoint Localization
  // use the Taylor method (later on)
  // for now just return everything
  
  // 3) Orientation Assignment
}
Example #2
0
void GridSod::set_refine_flags() {

	const Real r0 = pow(1.0e+5 / 0.49, 1.0 / 5.0) * pow(get_time(), 2.0 / 5.0);
	Real r;
	ChildIndex c;
	if (get_level() < OctNode::get_max_level_allowed() - 2) {
		for (int i = 0; i < OCT_NCHILD; i++) {
			set_refine_flag(i, true);
		}
	} else if (get_level() < get_max_level_allowed()) {
		for (int k = BW; k < GNX - BW; k++) {
			c.set_z(2 * k / GNX);
			for (int j = BW; j < GNX - BW; j++) {
				c.set_y(2 * j / GNX);
				for (int i = BW; i < GNX - BW; i++) {
					c.set_x(2 * i / GNX);
					if (!get_refine_flag(c)) {
						r = sqrt(X(i, j, k).dot(X(i, j, k)));
						if (E0(i, j, k).mag() > 1) {
							set_refine_flag(c, true);
						}
					}
				}
			}
		}
	}
}
Example #3
0
/***********************************************************************************************
* 函数名称:void sha256_ProChunk()
* 功    能:处理一个数据块(512位)
***********************************************************************************************/
void sha256_ProChunk()
{
	short i;
	unsigned long t1,t2;
	
	//步骤一
	for(i=0;i<64;i++)
	{
		if(0<=i&&i<=15)
		{
		}
		if(16<=i&&i<=63)
		{
			sha256_w[i]=Q1(sha256_w[i-2])+sha256_w[i-7]+Q0(sha256_w[i-15])+sha256_w[i-16];
		}    
	}
	
	//步骤二
	sha256_a=sha256_hh[0];
	sha256_b=sha256_hh[1];
	sha256_c=sha256_hh[2];
	sha256_d=sha256_hh[3];
	sha256_e=sha256_hh[4];
	sha256_f=sha256_hh[5];
	sha256_g=sha256_hh[6];
	sha256_h=sha256_hh[7];
	
	//步骤三
	for(i=0;i<64;i++)
	{
		t1=sha256_h+E1(sha256_e)+CH(sha256_e,sha256_f,sha256_g)+sha256_K[i]+sha256_w[i];
		t2=E0(sha256_a)+MAJ(sha256_a,sha256_b,sha256_c);
		sha256_h=sha256_g;
		sha256_g=sha256_f;
		sha256_f=sha256_e;
		sha256_e=sha256_d+t1;
		sha256_d=sha256_c;
		sha256_c=sha256_b;
		sha256_b=sha256_a;
		sha256_a=t1+t2;
	}
	
	//步骤四
	sha256_hh[0] += sha256_a;
	sha256_hh[1] += sha256_b;
	sha256_hh[2] += sha256_c;
	sha256_hh[3] += sha256_d;
	sha256_hh[4] += sha256_e;
	sha256_hh[5] += sha256_f;
	sha256_hh[6] += sha256_g;
	sha256_hh[7] += sha256_h;
}
Example #4
0
//Spell1「低速ばらまき弾」
void shot_E0(){
	int t=spcount;

	if(t>=120){
		E0();

		if(t%20==0)
			se_flag[0]=1;
	}

	for(int i=0;i < BULLET_MAX;i++){
		if(bullet[i].flag==1){
			if(bullet[i].cnt<20){
				bullet[i].spd+=0.02;
			}
		}
	}
}
Example #5
0
void Mesh :: buildEigenvalueProblem( void )
{
   // allocate a sparse |V|x|V| matrix
   int nV = vertices.size();
   QuaternionMatrix E0;
   E0.resize( nV, nV );

   // visit each face
   for( size_t k = 0; k < faces.size(); k++ )
   {
      double A = area(k);
      double a = -1. / (4.*A);
      double b = rho[k] / 6.;
      double c = A*rho[k]*rho[k] / 9.;

      // get vertex indices
      int I[3] =
      {
         faces[k].vertex[0],
         faces[k].vertex[1],
         faces[k].vertex[2]
      };

      // compute edges across from each vertex
      Quaternion e[3];
      for( int i = 0; i < 3; i++ )
      {
         e[i] = vertices[ I[ (i+2) % 3 ]] -
                vertices[ I[ (i+1) % 3 ]] ;
      }

      // increment matrix entry for each ordered pair of vertices
      for( int i = 0; i < 3; i++ )
      for( int j = 0; j < 3; j++ )
      {
         E0(I[i],I[j]) += a*e[i]*e[j] + b*(e[j]-e[i]) + c;
      }
   }

   // build Cholesky factorization
   E.build( E0.toReal() );
}
	int test()
	{
		int Error = 0;

		int A0 = static_cast<int>(glm::log2(16.f));
		glm::ivec1 B0(glm::log2(glm::vec1(16.f)));
		glm::ivec2 C0(glm::log2(glm::vec2(16.f)));
		glm::ivec3 D0(glm::log2(glm::vec3(16.f)));
		glm::ivec4 E0(glm::log2(glm::vec4(16.f)));

		int A1 = glm::log2(int(16));
		glm::ivec1 B1 = glm::log2(glm::ivec1(16));
		glm::ivec2 C1 = glm::log2(glm::ivec2(16));
		glm::ivec3 D1 = glm::log2(glm::ivec3(16));
		glm::ivec4 E1 = glm::log2(glm::ivec4(16));

		Error += A0 == A1 ? 0 : 1;
		Error += glm::all(glm::equal(B0, B1)) ? 0 : 1;
		Error += glm::all(glm::equal(C0, C1)) ? 0 : 1;
		Error += glm::all(glm::equal(D0, D1)) ? 0 : 1;
		Error += glm::all(glm::equal(E0, E1)) ? 0 : 1;

		glm::uint64 A2 = glm::log2(glm::uint64(16));
		glm::u64vec1 B2 = glm::log2(glm::u64vec1(16));
		glm::u64vec2 C2 = glm::log2(glm::u64vec2(16));
		glm::u64vec3 D2 = glm::log2(glm::u64vec3(16));
		glm::u64vec4 E2 = glm::log2(glm::u64vec4(16));

		Error += A2 == glm::uint64(4) ? 0 : 1;
		Error += glm::all(glm::equal(B2, glm::u64vec1(4))) ? 0 : 1;
		Error += glm::all(glm::equal(C2, glm::u64vec2(4))) ? 0 : 1;
		Error += glm::all(glm::equal(D2, glm::u64vec3(4))) ? 0 : 1;
		Error += glm::all(glm::equal(E2, glm::u64vec4(4))) ? 0 : 1;

		return Error;
	}
Example #7
0
	int test()
	{
		int Error = 0;

		int A0(glm::log2(10.f));
		glm::ivec1 B0(glm::log2(glm::vec1(10.f)));
		glm::ivec2 C0(glm::log2(glm::vec2(10.f)));
		glm::ivec3 D0(glm::log2(glm::vec3(10.f)));
		glm::ivec4 E0(glm::log2(glm::vec4(10.f)));

		int A1 = glm::log2(int(10.f));
		glm::ivec1 B1 = glm::log2(glm::ivec1(10.f));
		glm::ivec2 C1 = glm::log2(glm::ivec2(10.f));
		glm::ivec3 D1 = glm::log2(glm::ivec3(10.f));
		glm::ivec4 E1 = glm::log2(glm::ivec4(10.f));

		Error += A0 == A1 ? 0 : 1;
		Error += glm::all(glm::equal(B0, B1)) ? 0 : 1;
		Error += glm::all(glm::equal(C0, C1)) ? 0 : 1;
		Error += glm::all(glm::equal(D0, D1)) ? 0 : 1;
		Error += glm::all(glm::equal(E0, E1)) ? 0 : 1;

		return Error;
	}
Example #8
0
void sha256(char *pInput, unsigned int iInputLength, _hash *p_hash)
{
    //printf("length:%d\n",iInputLength);
    unsigned long h1 = 0x6a09e667;
    unsigned long h2 = 0xbb67ae85;
    unsigned long h3 = 0x3c6ef372;
    unsigned long h4 = 0xa54ff53a;
    unsigned long h5 = 0x510e527f;
    unsigned long h6 = 0x9b05688c;
    unsigned long h7 = 0x1f83d9ab;
    unsigned long h8 = 0x5be0cd19;
    //print8longs(h1, h2, h3, h4, h5, h6, h7, h8);

    unsigned int isize = (iInputLength / 64 > 0) ? (iInputLength / 64 * 64 + 64) : 64;
    isize =  iInputLength % 64 >= 56 ? isize + 64 : isize;
    //printf("size:%d\n", isize);
    unsigned long *pPreparedInput = (unsigned long*)malloc(isize);
    prepare_input(pPreparedInput, isize/4, pInput, iInputLength);

    //printstr((char*)pPreparedInput, isize);

    for (int i = 0; i < isize/4; i = i + 16)
    {
        unsigned long W[64] = {0};
        for (int j = 0; j < 16; j++)
            W[j] = pPreparedInput[i+j];
        for (int j = 16; j < 64; j++)
            W[j] = Q1(W[j-2]) + W[j-7] + Q0(W[j-15]) + W[j-16];
        unsigned long a = h1;
        unsigned long b = h2;
        unsigned long c = h3;
        unsigned long d = h4;
        unsigned long e = h5;
        unsigned long f = h6;
        unsigned long g = h7;
        unsigned long h = h8; 
        for (int j = 0; j < 64; j++)
        {
            unsigned long t1 = h + E1(e) + CH(e, f, g) + K[j] + W[j];
            unsigned long t2 = E0(a) + MAJ(a, b, c);
            /*
            printf("h:");
            printlong(h);
            printf("\n");
            printf("E1(e):");
            printlong(E1(e));
            printf("\n");
            printf("CH(e,f,g):");
            printlong(CH(e,f,g));
            printf("\n");
            printf("K[%d]:", j);
            printlong(K[j]);
            printf("\n");
            printf("W[%d]:", j);
            printlong(W[j]);
            printf("\n");
            printf("T1");
            printlong(t1);
            printf("\n");
            */
            h = g;
            g = f;
            f = e;
            e = d + t1;
            d = c;
            c = b;
            b = a;
            a = t1 + t2;
            //printf("%d:", j);
            //print8longs(a, b, c, d, e, f, g, h);
        }
        h1 += a;
        h2 += b;
        h3 += c;
        h4 += d;
        h5 += e;
        h6 += f;
        h7 += g;
        h8 += h;
    }
    //print8longs(h1, h2, h3, h4, h5, h6, h7, h8);
    long2char4(h1, p_hash->X);
    long2char4(h2, p_hash->X+4);
    long2char4(h3, p_hash->X+8);
    long2char4(h4, p_hash->X+12);
    long2char4(h5, p_hash->X+16);
    long2char4(h6, p_hash->X+20);
    long2char4(h7, p_hash->X+24);
    long2char4(h8, p_hash->X+28);

    free(pPreparedInput);
}
Example #9
0
int main(int argc, char * argv[])
{

	MPI_Init(&argc, &argv);

#ifdef _FPESIG_ENABLE_
  fpe_catch();
#endif


	int nproc, myproc;
	MPI_Comm_size(MPI_COMM_WORLD, & nproc);
	MPI_Comm_rank(MPI_COMM_WORLD, &myproc);
	
	srand48(12345);
  
  if (myproc == 1) {
    gwait = 0;
    while (gwait == 1) {
      std::cerr << " waiting ... zzzz \n";
      sleep(2);
    };
  }
		

#if 0
	{
		fvmhd3d::system s(myproc, nproc);

		s.set_geometry(true);

#if 0
		s.build_mesh(true);
		s.build_mesh(true);
#endif
		
		int nremove = 100;
		const double t0 = mytimer::get_wtime();
		int success = 0;
		for (int i = 0; i < nremove; i++)
		{
			int ix = s.local_n/(nremove - 1) * i;
			const fvmhd3d::Site si(fvmhd3d::vec3(s.ptcl[ix].x, s.ptcl[ix].y, s.ptcl[ix].z), ix, s.ptcl[ix].rmax);
			std::vector< std::pair<int, std::pair<fvmhd3d::real, fvmhd3d::real> > > volume;
			const bool success_flag =  s.remove_site(si, volume);
			if (!success_flag) continue;
			success++;
			fvmhd3d::real v = 0;
			for (int  i1 = 0; i1 < (int)volume.size(); i1++)
			{
				const double dv = volume[i1].second.second - volume[i1].second.first;
				assert(dv > -1.0e-10*volume[i1].second.first);
				const int j = volume[i1].first;
				assert(j != ix);
				if (j < s.local_n)
					s.cells[j].Volume = volume[i1].second.second;
				v += dv;
			}
			if (!(std::abs(s.cells[ix].Volume - v)/s.cells[ix].Volume < 1.0e-13))
			{
				fprintf(stderr, "i= %d [%d] ix= %d vi= %g  vex= %g  dv= %g [ %g ]  %g %g %g\n",
						i, nremove, ix,
						s.cells[ix].Volume, v,  
						(s.cells[ix].Volume - v),
						(s.cells[ix].Volume - v)/s.cells[ix].Volume,
						si.pos.x, si.pos.y, si.pos.z);
			}
			assert(std::abs(s.cells[ix].Volume - v)/s.cells[ix].Volume < 1.0e-10);
		}
		fprintf(stderr, " nremove= %d  success= %d ::  removing done in %g sec \n",
				nremove, success, mytimer::get_wtime() - t0);


	}
#endif

#if 1
	{
		char path[256] = "ZZZZZZ";
		if (argc > 1) {
			sprintf(path, "%s", argv[1]);
		} else {
			if (myproc == 0) {
				fprintf(stderr, " ./main data_path \n");
				exit(-1);
			}
		}

		fvmhd3d::system s(myproc, nproc);

		if (argc > 2)
		{
			if (myproc == 0) 
				fprintf(stderr, " ... Reading snapshot ... \n");
			s.set_geometry(false);
			s.set_problem(false);
			s.read_binary((const char*)argv[2], 1);
		}
		else
		{
			s.set_geometry(true);
			s.set_problem(true);
		}
		
		fvmhd3d::Energy E0(s.get_energy());
    {
      const double volume_exact = s.global_domain_size.x*s.global_domain_size.y*s.global_domain_size.z;
      E0.data[fvmhd3d::Energy::VOLUME] = volume_exact;
    }
    bool first_dE_flag = true;
    if (myproc == 0)
    {
      E0.print_energy  (stderr, " E0: ");
      E0.print_momentum(stderr, " M0: ");
    }

    double t_dump    = s.t_global + (s.t_global > 0 ? s.dt_dump : 0.0);
    t_dump = (int)(t_dump/s.dt_dump)*s.dt_dump;
    double t_restart = s.t_global + s.dt_restart;
    int    i_log     = s.iteration;

    const int niter_max = 5;
    int niter = 0;
    const double t_start = mytimer::get_wtime();


#ifdef _SEQ_WRITE_
    const char lockfn[256] = "write-lock.fvmhd3d";
#endif

    while(niter < niter_max)
    {
      //			niter++;

      bool out = false;
      //
      // ***** writing dump file
      //
      if (s.t_global >= t_dump)
      { 
        if (s.all_active)
        {
          out = true;
          char fn[256];
          const int iout = (t_dump + 0.001*s.dt_dump)/s.dt_dump;
#ifdef _CREATE_FOLDER_
					char filepath[256];
          sprintf(filepath, "%s/iter%.6d", path, iout);
					if (myproc == 0)
						mkdir(filepath, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IWOTH);
					MPI_Barrier(MPI_COMM_WORLD);

					sprintf(fn, "%s/iter%.6d_proc%.3d.snap", filepath ,iout, myproc);
#else
					sprintf(fn, "%s/iter%.6d_proc%.3d.snap", path, iout, myproc);
#endif
					if (myproc == 0) 
					{
						fprintf(stderr, " *** dumping snapshot %s @ t= %g\n",
								fn, s.t_global);
					}
#ifdef _SEQ_WRITE_
					FILE *fd;
					while ((fd = fopen(lockfn, "r")))
					{
						if (myproc == 0)
							fprintf(stderr, " ... write-lock ... waiting ... zzz\n");
						fclose(fd);
						sleep(1.0);
					}
					MPI_Barrier(MPI_COMM_WORLD);
					if (myproc == 0)
					{
						fd = fopen(lockfn, "w");
						fclose(fd);
						fprintf(stderr, " write-lock removed ... writing ... \n");
					}
					MPI_Barrier(MPI_COMM_WORLD);
					for (int p = 0; p < nproc; p++)
					{
						MPI_Barrier(MPI_COMM_WORLD);
						if (myproc == p)
						{
							fd = fopen(lockfn, "w");
							fclose(fd);
							fprintf(stderr, " proc= %d dumps data into %s @ t = %g ... \n ",
									myproc, fn, s.t_global);
							s.dump_binary(fn);
							fd = fopen(lockfn, "w");
							fclose(fd);
							fprintf(stderr, " proc= %d ... done writing \n", myproc);
						}
					}
					MPI_Barrier(MPI_COMM_WORLD);
					if (myproc == 0)
						remove(lockfn);
#else
					s.dump_binary(fn);
					if (myproc == 0)
						fprintf(stderr, " proc= %d ... done writing \n", myproc);
#endif
					t_dump += s.dt_dump;
				}
			}

#if 0
			MPI_Barrier(MPI_COMM_WORLD);
#endif

			//
			// ***** writing restart file
			//
			if (s.t_global >= t_restart) 
			{
				if (!out && s.all_active)
				{
					char fn[256];
					const int irestart = (t_restart + 0.001*s.dt_restart)/s.dt_restart;
#ifdef _CREATE_FOLDER_
					char filepath[256];
          sprintf(filepath, "%s/restart%.3d", path, irestart%s.n_restart);
					if (myproc == 0)
						mkdir(filepath, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IWOTH);
					MPI_Barrier(MPI_COMM_WORLD);
					sprintf(fn, "%s/restart%.3d_proc%.3d.snap", filepath ,irestart%s.n_restart, myproc);
#else
					sprintf(fn, "%s/restart%.3d_proc%.3d.snap", path, irestart%s.n_restart, myproc);
#endif

					if (myproc == 0) 
						fprintf(stderr, " *** dumping restart file %s @ t= %g\n",
								fn, s.t_global);
					if (myproc == 0) 
					{
						fprintf(stderr, " *** dumping snapshot %s @ t= %g\n",
								fn, s.t_global);
					}
#ifdef _SEQ_WRITE_
					FILE *fd;
					while ((fd = fopen(lockfn, "r")))
					{
						if (myproc == 0)
							fprintf(stderr, " ... write-lock ... waiting ... zzz\n");
						fclose(fd);
						sleep(1.0);
					}
					MPI_Barrier(MPI_COMM_WORLD);
					if (myproc == 0)
					{
						fd = fopen(lockfn, "w");
						fclose(fd);
						fprintf(stderr, " write-lock removed ... writing ... \n");
					}
					MPI_Barrier(MPI_COMM_WORLD);
					for (int p = 0; p < nproc; p++)
					{
						MPI_Barrier(MPI_COMM_WORLD);
						if (myproc == p)
						{
							fd = fopen(lockfn, "w");
							fclose(fd);
							fprintf(stderr, " proc= %d dumps data into %s @ t = %g ... \n ",
									myproc, fn, s.t_global);
							s.dump_binary(fn);
							fd = fopen(lockfn, "w");
							fclose(fd);
							fprintf(stderr, " proc= %d ... done writing \n", myproc);
						}
					}
					MPI_Barrier(MPI_COMM_WORLD);
					if (myproc == 0)
						remove(lockfn);
#else
					s.dump_binary(fn);
					if (myproc == 0)
						fprintf(stderr, " proc= %d ... done writing \n", myproc);
#endif
				}
				if (s.all_active)
					t_restart += s.dt_restart;
			}

#if 0
			MPI_Barrier(MPI_COMM_WORLD);
#endif

#if 0
#define _PROFILE_EVERY_
			if (myproc == 0)
				fprintf(stderr, "--------------------------------------   new iteration   ------------------------------------------------- \n");
#endif
			MPI_Barrier(MPI_COMM_WORLD);
			const double tbeg = mytimer::get_wtime();
			s.iterate();
			double dt_iter  = mytimer::get_wtime() - tbeg;

			const int n_active = s.nactive_glb;
			double dt_iter_max;
			MPI_Reduce(&dt_iter, &dt_iter_max, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
			unsigned long long nvirtual_glb, boundary_glb;
			MPI_Reduce(&s.virtual_n, &nvirtual_glb,  1, MPI_UNSIGNED_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD);
			MPI_Reduce(&s.boundary_n, &boundary_glb, 1, MPI_UNSIGNED_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD);

			if (myproc == 0) 
			{
				fprintf(stderr, " iter= %d : t= %g dt= %g [ %g ] n_act= %d [ %g ] [%lld %lld] running_time= %g h  [ %g sec :: %g cells/s/proc/threads ( %g // %g ) ] \n",
						s.iteration, s.t_global, s.dt_global, s.courant_no,
						n_active, n_active*1.0/s.global_n,
						nvirtual_glb, boundary_glb,
						(mytimer::get_wtime() - t_start)/3600.0, 
						dt_iter_max, 
						s.global_n/nproc/dt_iter, 
						n_active/dt_iter, n_active/dt_iter/nproc);
			}

			if (s.all_active)
			{
#if 1
				const fvmhd3d::Energy E1(s.get_energy());
				if (false && first_dE_flag)
				{
					E0 = s.get_energy();
					E0.print_energy  (stderr, " E0: ");
					E0.print_momentum(stderr, " M0: ");
					first_dE_flag = false;
				}
				const fvmhd3d::Energy dE = (E1 - E0)/E0.abs();
				if (myproc == 0)
				{
					E1.print_energy(stderr, " E1: ");
					dE.print_energy(stderr, " dE: ");
					E1.print_mass(stderr, " M1: ");
					dE.print_mass(stderr, " dM: "); 
					E1.print_momentum(stderr, "Mom1: ");
					dE.print_momentum(stderr, "dMom: ");
				}
#endif
			}

#if 1
			if (s.iteration >= i_log || s.all_active)
#endif
			{
				s.dump_profile_info();
				if (s.iteration >= i_log)
					i_log += s.di_log;
			}

			if (s.t_global >= s.t_end && s.all_active) break;
		}

		if (s.t_global >= t_dump) 
		{ 
			char fn[256];
			const int iout = (t_dump + 0.001*s.dt_dump)/s.dt_dump;
#ifdef _CREATE_FOLDER_
      char filepath[256];
      sprintf(filepath, "%s/iter%.6d", path, iout);
      if (myproc == 0)
        mkdir(filepath, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IWOTH);
      MPI_Barrier(MPI_COMM_WORLD);

      sprintf(fn, "%s/iter%.6d_proc%.3d.snap", filepath ,iout, myproc);
#else
      sprintf(fn, "%s/iter%.6d_proc%.3d.snap", path, iout, myproc);
#endif
      if (myproc == 0) 
        fprintf(stderr, " *** dumping snapshot %s @ t= %g\n",
            fn, s.t_global);
      s.dump_binary(fn);
      t_dump += s.dt_dump;
    }

  }
#endif



  MPI_Finalize();
  fprintf(stderr, "end-of-program\n");
  return 0;
}