Exemplo n.º 1
0
int main(int argc, char **argv)
{
  if (argc<3) return 1;
  const std::string filename_in = argv[1], 
                    filename_out = argv[2];
 
  int ndims = 3;
  int dims[3];
  double lengths[3];
  bool pbc[3];
  double time; 
  double B[3];
  double Jxext, Kx, V;
  double *re, *im;

  GLGPU_IO_Helper_ReadBDAT(
  // GLGPU_IO_Helper_ReadLegacy(
      filename_in, 
      ndims, dims, lengths, pbc,
      time, B, Jxext, Kx, V, 
      &re, &im);
  fprintf(stderr, "dims={%d, %d, %d}\n", dims[0], dims[1], dims[2]);

  GLGPU_IO_Helper_WriteNetCDF(
      filename_out, 
      ndims, dims, lengths, pbc,
      B, Jxext, Kx, V, 
      re, im);

  return 0;
}
Exemplo n.º 2
0
static bool LoadTimesteps(const std::string& dataname)
{
  std::ifstream ifs; 
  ifs.open(dataname.c_str(), std::ifstream::in); 
  if (!ifs.is_open()) return false;
  
  filenames.clear();
  timesteps.clear();

  GLHeader h;
  char fname[1024];

  while (ifs.getline(fname, 1024)) {
    filenames.push_back(fname);

    bool succ = false;
    if (!succ) {
      succ = GLGPU_IO_Helper_ReadBDAT(
          fname, h, NULL, NULL, NULL, NULL, NULL, NULL, NULL, true);
    } 
    if (!succ) {
      succ = GLGPU_IO_Helper_ReadLegacy(
          fname, h, NULL, NULL, NULL, NULL, NULL, NULL, NULL, true);
    }
    if (!succ) {
      fprintf(stderr, "cannot open file: %s\n", fname);
      return false;
    }

    timesteps.push_back(h.time);
    // fprintf(stderr, "frame=%d, time=%f\n", filenames.size()-1, h.time);
  }

  ifs.close();
  return true;
}