| 106 | } |
| 107 | |
| 108 | void fields::dump(const char *filename, bool single_parallel_file) { |
| 109 | if (verbosity > 0) { |
| 110 | printf("creating fields output file \"%s\" (%d)...\n", filename, single_parallel_file); |
| 111 | } |
| 112 | |
| 113 | h5file file(filename, h5file::WRITE, single_parallel_file, !single_parallel_file); |
| 114 | |
| 115 | // Write out the current time 't' |
| 116 | size_t dims[1] = {1}; |
| 117 | size_t start[1] = {0}; |
| 118 | size_t _t[1] = {(size_t)t}; |
| 119 | file.create_data("t", 1, dims); |
| 120 | if (am_master() || !single_parallel_file) file.write_chunk(1, start, dims, _t); |
| 121 | |
| 122 | dump_fields_chunk_field(&file, single_parallel_file, "f", |
| 123 | [](fields_chunk *chunk, int c, int d) { return &(chunk->f[c][d]); }); |
| 124 | dump_fields_chunk_field(&file, single_parallel_file, "f_u", |
| 125 | [](fields_chunk *chunk, int c, int d) { return &(chunk->f_u[c][d]); }); |
| 126 | dump_fields_chunk_field(&file, single_parallel_file, "f_w", |
| 127 | [](fields_chunk *chunk, int c, int d) { return &(chunk->f_w[c][d]); }); |
| 128 | dump_fields_chunk_field(&file, single_parallel_file, "f_cond", |
| 129 | [](fields_chunk *chunk, int c, int d) { return &(chunk->f_cond[c][d]); }); |
| 130 | dump_fields_chunk_field( |
| 131 | &file, single_parallel_file, "f_bfast", |
| 132 | [](fields_chunk *chunk, int c, int d) { return &(chunk->f_bfast[c][d]); }); |
| 133 | dump_fields_chunk_field( |
| 134 | &file, single_parallel_file, "f_w_prev", |
| 135 | [](fields_chunk *chunk, int c, int d) { return &(chunk->f_w_prev[c][d]); }); |
| 136 | |
| 137 | // Dump DFT chunks. |
| 138 | for (int i = 0; i < num_chunks; i++) { |
| 139 | if (single_parallel_file || chunks[i]->is_mine()) { |
| 140 | char dataname[1024]; |
| 141 | snprintf(dataname, 1024, "chunk%02d", i); |
| 142 | save_dft_hdf5(chunks[i]->dft_chunks, dataname, &file, 0, single_parallel_file); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | void fields::load_fields_chunk_field(h5file *h5f, bool single_parallel_file, |
| 148 | const std::string &field_name, |
no test coverage detected