void store_crux_data(Crux *crux, int ncycle) { size_t nsize = num_int_vals*sizeof(int) + num_double_vals*sizeof(double); nsize += state->get_checkpoint_size(); int int_vals[num_int_vals]; int_vals[ 0] = CRUX_CLAMR_VERSION; // Version number int_vals[ 1] = nx; int_vals[ 2] = ny; int_vals[ 3] = levmx; int_vals[ 4] = ndim; int_vals[ 5] = outputInterval; int_vals[ 6] = enhanced_precision_sum; int_vals[ 7] = niter; int_vals[ 8] = it; int_vals[ 9] = ncycle; int_vals[10] = graphic_outputInterval; int_vals[11] = checkpoint_outputInterval; int_vals[12] = next_cp_cycle; int_vals[13] = next_graphics_cycle; double double_vals[num_double_vals]; double_vals[ 0] = circ_radius; double_vals[ 1] = H_sum_initial; double_vals[ 2] = simTime; double_vals[ 3] = deltaT; double_vals[ 4] = upper_mass_diff_percentage; clamr_bootstrap_memory.memory_add(int_vals, size_t(num_int_vals), 4, "bootstrap_int_vals", RESTART_DATA); clamr_bootstrap_memory.memory_add(double_vals, size_t(num_double_vals), 8, "bootstrap_double_vals", RESTART_DATA); crux->store_begin(nsize, ncycle); crux->store_MallocPlus(clamr_bootstrap_memory); state->store_checkpoint(crux); crux->store_end(); clamr_bootstrap_memory.memory_remove(int_vals); clamr_bootstrap_memory.memory_remove(double_vals); next_cp_cycle += checkpoint_outputInterval; }
void restore_crux_data_bootstrap(Crux *crux, char *restart_file, int rollback_counter) { crux->restore_begin(restart_file, rollback_counter); int int_vals[num_int_vals]; double double_vals[num_double_vals]; clamr_bootstrap_memory.memory_add(int_vals, size_t(num_int_vals), 4, "bootstrap_int_vals", RESTART_DATA); clamr_bootstrap_memory.memory_add(double_vals, size_t(num_double_vals), 8, "bootstrap_double_vals", RESTART_DATA); crux->restore_MallocPlus(clamr_bootstrap_memory); if (int_vals[ 0] != CRUX_CLAMR_VERSION) { printf("CRUX version mismatch for clamr data, version on file is %d, version in code is %d\n", int_vals[0], CRUX_CLAMR_VERSION); exit(0); } nx = int_vals[ 1]; ny = int_vals[ 2]; levmx = int_vals[ 3]; ndim = int_vals[ 4]; outputInterval = int_vals[ 5]; enhanced_precision_sum = int_vals[ 6]; niter = int_vals[ 7]; it = int_vals[ 8]; ncycle = int_vals[ 9]; crux_type = int_vals[10]; graphic_outputInterval = int_vals[11]; checkpoint_outputInterval = int_vals[12]; next_cp_cycle = int_vals[13]; next_graphics_cycle = int_vals[14]; circ_radius = double_vals[ 0]; H_sum_initial = double_vals[ 1]; simTime = double_vals[ 2]; deltaT = double_vals[ 3]; upper_mass_diff_percentage = double_vals[ 4]; // need to reset crux type, because initialize to none // before checkpoint is read crux->set_crux_type(crux_type); clamr_bootstrap_memory.memory_remove(int_vals); clamr_bootstrap_memory.memory_remove(double_vals); #ifdef DEBUG_RESTORE_VALS if (DEBUG_RESTORE_VALS) { const char *int_vals_descriptor[num_int_vals] = { "CRUX_CLAMR_VERSION", "nx", "ny", "levmx", "ndim", "outputInterval", "enhanced_precision_sum", "niter", "it", "ncycle", "crux_type", "graphic_outputInterval", "checkpoint_outputInterval", "next_cp_cycle", "next_graphics_cycle" }; printf("\n"); printf(" === Restored bootstrap int_vals ===\n"); for (int i = 0; i < num_int_vals; i++){ printf(" %-30s %d\n",int_vals_descriptor[i], int_vals[i]); } printf(" === Restored bootstrap int_vals ===\n"); printf("\n"); } #endif #ifdef DEBUG_RESTORE_VALS if (DEBUG_RESTORE_VALS) { const char *double_vals_descriptor[num_double_vals] = { "circ_radius", "H_sum_initial", "simTime", "deltaT", "upper_mass_diff_percentage" }; printf("\n"); printf(" === Restored bootstrap double_vals ===\n"); for (int i = 0; i < num_double_vals; i++){ printf(" %-30s %lg\n",double_vals_descriptor[i], double_vals[i]); } printf(" === Restored bootstrap double_vals ===\n"); printf("\n"); } #endif }