bool RegEdit::SaveSocFile(const QString& filename) { normalize(m_cur_socfile.GetSoc()); if(!produce_xml(filename.toStdString(), m_cur_socfile.GetSoc())) { QMessageBox::warning(this, "The description was not saved", "There was an error when saving the file"); return false; } m_soc_tree->clear(); FillSocTree(); SetModified(false, false); return true; }
static void build_dataset_from_specs( const char *filename_prefix, const char *transform_name, const dataset_xml_spec_t *xml_spec, const dataset_global_spec_t *global_spec, int num_ts, int num_pgs_per_ts, dataset_pg_spec_t pg_specs[num_ts][num_pgs_per_ts]) // Not const because C has an corner case here (http://c-faq.com/ansi/constmismatch.html) { int var; char xml_filename[strlen(filename_prefix) + strlen(".xml") + 1]; char bp_filename[strlen(filename_prefix) + strlen(".bp") + 1]; int timestep, pg_in_timestep; char dimvar[32]; // Construct the XML and BP filenames sprintf(xml_filename, "%s.xml", filename_prefix); sprintf(bp_filename, "%s.bp", filename_prefix); // Write out the XML file FILE *xml_out = fopen(xml_filename, "w"); assert(xml_out); produce_xml(xml_out, xml_spec, transform_name); fclose(xml_out); // Write out the BP file adios_init(xml_filename, MPI_COMM_WORLD); // Compute the groupsize contribution of the dimension scalars const uint64_t base_groupsize = xml_spec->ndim * 3 * 4; // *3 for 3 scalars (N, D, O) *4 for sizeof(adios_integer) (not sure how what function in the User API to call to get this programatically // For each timestep, for each PG in that timestep, write out all variables using the provided vardata buffers int64_t adios_file; for (timestep = 0; timestep < global_spec->num_ts; ++timestep) { for (pg_in_timestep = 0; pg_in_timestep < global_spec->num_pgs_per_ts; ++pg_in_timestep) { // (Re-)open the file in write or append mode, depending on whether or not this is the first PG written const int is_first_pg = (timestep == 0 && pg_in_timestep == 0); adios_open(&adios_file, xml_spec->group_name, bp_filename, is_first_pg ? "w" : "a", MPI_COMM_WORLD); // Pin the timestep to allow multiple adios_open/adios_close cycles to write // to the same timestep (this simulates a parallel file write with fewer core) adios_pin_timestep(timestep + 1); // +1 because we want the timesteps to be 1-based const dataset_pg_spec_t *pg_spec = &pg_specs[timestep][pg_in_timestep]; // Compute the group size uint64_t groupsize = compute_groupsize(base_groupsize, xml_spec, pg_spec); uint64_t out_groupsize; adios_group_size(adios_file, groupsize, &out_groupsize); write_adios_dimension_scalars(adios_file, "N", xml_spec->ndim, global_spec->global_dims); write_adios_dimension_scalars(adios_file, "D", xml_spec->ndim, pg_spec->pg_dim); write_adios_dimension_scalars(adios_file, "O", xml_spec->ndim, pg_spec->pg_offset); // Write each variable for (var = 0; var < xml_spec->nvar; ++var) { adios_write(adios_file, xml_spec->varnames[var], (void*)pg_spec->vardata[var]); // (void*) to get rid of compiler complaining about constness } // Close the file to commit it adios_close(adios_file); } } }