Example #1
0
int cow_domain_readsize(cow_domain *d, char *fname, char *dname)
{
#if (COW_HDF5)
  hid_t file = H5Fopen(fname, H5F_ACC_RDONLY, d->fapl);
  if (file < 0) {
    return 1;
  }
  hid_t dset = H5Dopen(file, dname, H5P_DEFAULT);
  if (dset < 0) {
    return 1;
  }
  hid_t fspc = H5Dget_space(dset);
  hsize_t dims[3] = { 1, 1, 1 };
  int ndims = H5Sget_simple_extent_dims(fspc, dims, NULL);
  H5Dclose(dset);
  H5Fclose(file);
  cow_domain_setndim(d, ndims);
  for (int n=0; n<ndims; ++n) {
    cow_domain_setsize(d, n, dims[n]);
  }
  printf("[%s] inferred global domain size of (%lld %lld %lld) from %s/%s\n",
	 MODULE, dims[0], dims[1], dims[2], fname, dname);
  return 0;
#endif
}
Example #2
0
int main(int argc, char **argv)
{
  int modes = 0;
  int collective = GETENVINT("COW_HDF5_COLLECTIVE", 0);
  int chunk = GETENVINT("COW_HDF5_CHUNK", 1);
  modes |= GETENVINT("COW_NOREOPEN_STDOUT", 0) ? COW_NOREOPEN_STDOUT : 0;
  modes |= GETENVINT("COW_DISABLE_MPI", 0) ? COW_DISABLE_MPI : 0;

  cow_init(argc, argv, modes);
  if (argc == 3) {
    printf("running on input file %s\n", argv[1]);
  }
  else {
    printf("usage: $> srhdhist infile.h5 outfile.h5\n");
    cow_finalize();
    return 0;
  }
  printf("COW_HDF5_COLLECTIVE: %d\n", collective);

  char *finp = argv[1];
  char *fout = argv[2];
  cow_domain *domain = cow_domain_new();
  cow_dfield *vel = cow_dfield_new2(domain, "prim");

  cow_domain_setndim(domain, 3);
  cow_domain_setguard(domain, 2);
  cow_domain_setsize(domain, 0, 16);
  cow_domain_setsize(domain, 1, 16);
  cow_domain_setsize(domain, 2, 16);
  cow_domain_commit(domain);

  cow_domain_setchunk(domain, chunk);
  cow_domain_setcollective(domain, collective);
  cow_domain_setalign(domain, 4*KILOBYTES, 4*MEGABYTES);

  cow_dfield_addmember(vel, "vx");
  cow_dfield_addmember(vel, "vy");
  cow_dfield_addmember(vel, "vz");
  cow_dfield_commit(vel);

  cow_dfield_read(vel, finp);
  cow_fft_pspecvecfield2(vel, fout, "pspec");

  cow_dfield *dil = cow_dfield_dup(vel);
  cow_dfield *sol = cow_dfield_dup(vel);
  cow_dfield_setname(dil, "dil");
  cow_dfield_setname(sol, "sol");

  cow_fft_helmholtzdecomp(sol, COW_PROJECT_OUT_DIV);
  cow_fft_helmholtzdecomp(dil, COW_PROJECT_OUT_CURL);
  cow_dfield_write(dil, fout);
  cow_dfield_write(sol, fout);
  cow_dfield_write(vel, fout);

  cow_dfield_del(dil);
  cow_dfield_del(sol);
  cow_dfield_del(vel);
  cow_domain_del(domain);

  cow_finalize();
  return 0;
}