#include "TimestepIonIO.h" #include "ION.h" /***********************************************************************/ /// Constructor - get the object that manages simulation timing info /** * @param timestep_Manager - object that keeps track of simulation time * (required for naming files) */ TimestepIonIO::TimestepIonIO(TimestepMHD *timestep_manager) { #ifdef DEBUG_MODE_ON printf("DEBUG: in TimestepIonIO.C::TimestepIonIO(...)\n"); #endif timestepManager = timestep_manager; } /***********************************************************************/ /// Standard ion_dump_step /** * Save ionosphere data to a file named * - "[base]_ion_[iStep].hdf" * * The ionospheric variables are stored on two different grids, one * refering to the mapped MHD grid and another to the actual * ionosphere calcualtion grid. * * On the mapped grid, we have: * - Field aligned current * - density * - sound speed * On the ionospheric calculation grid, we have: * - field aligned current * - precipitating flux * - average energy * - Pedersen conductance * - Hall conductance * - Potential * * @param base - base filename to pre-pend to each file * @param ion - ion object * * @note use the TimestepMHD object (timestepManager) to specify timing information */ int TimestepIonIO::dump_step(char *base, ION *ion) { #ifdef DEBUG_MODE_ON printf("DEBUG: in TimestepIonIO.C::dump_step(...)\n"); #endif int iStep = timestepManager->currentStep; double Time = timestepManager->simTime; char suffix_1[128]; sprintf(suffix_1, "%07d", iStep); char suffix_2[128] = "dmp"; double mjd = -999.9; // These functions are defined in the IonIO Base Class open_write_hdf(&base[0], &suffix_1[0], &suffix_2[0], &mjd, &iStep, &Time); write_data(ion, &iStep, &Time); close_hdf(); Communication_Manager::Sync(); return 0; } /***********************************************************************/ /// Standard ion_read_step /** * Read ionosphere data from a file named * - "[base]_ion_[iStep].hdf" * * The ionospheric variables are stored on two different grids, one * refering to the mapped MHD grid and another to the actual * ionosphere calcualtion grid. * * On the mapped grid, we have: * - Field aligned current * - density * - sound speed * On the ionospheric calculation grid, we have: * - field aligned current * - precipitating flux * - average energy * - Pedersen conductance * - Hall conductance * - Potential * * @param base - base filename to pre-pend to each file * @param ion - ion object * * @note use the TimestepMHD object (timestepManager) to specify timing information */ int TimestepIonIO::read_step(char *base, ION *ion) { #ifdef DEBUG_MODE_ON printf("DEBUG: in TimestepIonIO.C::read_step(...)\n"); #endif int iStep = timestepManager->currentStep; double Time = timestepManager->simTime; char suffix_1[128]; sprintf(suffix_1, "%07d", iStep); char suffix_2[128] = "hdf"; double mjd = -999.9; // These functions are defined in the IonIO Base Class open_read_hdf(&base[0], &suffix_1[0], &suffix_2[0], &mjd, &iStep, &Time); read_data(ion, &iStep, &Time); close_hdf(); Communication_Manager::Sync(); return 0; }