#include "UTIonIO.h" #include "ION.h" /***********************************************************************/ /// Constructor - get the object that manages simulation timing info /** * @param UTMHD - object that keeps track of simulation time * (required for naming files) */ UTIonIO::UTIonIO(UTMHD *ut_manager) { #ifdef DEBUG_MODE_ON printf("DEBUG: in UTIonIO.C::UTIonIO(...)\n"); #endif UTManager = ut_manager; } /***********************************************************************/ /// UT-IO version of ion_dump_step /** * Save ionosphere data to a file named * - "[base]_ion_YYYY-MM-DDTHH-MM-SS.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 UTMHD object (UTManager) to specify timing information */ int UTIonIO::dump_step(char *base, ION *ion) { #ifdef DEBUG_MODE_ON printf("DEBUG: in UTIonIO.C::dump_step(...)\n"); #endif std::string timestr = UTManager->current.getDateTimeString(); char *suffix_1 = new char [ timestr.size()+1]; strcpy(suffix_1, timestr.c_str()); char suffix_2[128] = "dmp"; double mjdTime = UTManager->current.getMJD(); int iStep = UTManager->currentStep; double Time = UTManager->simTime; // These functions are defined in the IonIO Base Class open_write_hdf(&base[0], &suffix_1[0], &suffix_2[0], &mjdTime, &iStep, &Time); delete [] suffix_1; write_data(ion, &iStep, &Time); close_hdf(); Communication_Manager::Sync(); return 0; } /***********************************************************************/ /// UT-IO version of ion_read_step /** * Read ionosphere data from a file named * - "[base]_ion_YYYY-MM-DDTHH-MM-SS.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 UTMHD object (UTManager) to specify timing information */ int UTIonIO::read_step(char *base, ION *ion) { #ifdef DEBUG_MODE_ON printf("DEBUG: in UTIonIO.C::read_step(...)\n"); #endif std::string timestr = UTManager->current.getDateTimeString(); char *suffix_1 = new char [ timestr.size()+1]; strcpy(suffix_1, timestr.c_str()); char suffix_2[128] = "hdf"; double mjdTime = UTManager->current.getMJD(); int iStep = UTManager->currentStep; double Time = UTManager->simTime; // These functions are defined in the IonIO Base Class open_read_hdf(&base[0], &suffix_1[0], &suffix_2[0], &mjdTime, &iStep, &Time); delete [] suffix_1; read_data(ion, &iStep, &Time); close_hdf(); Communication_Manager::Sync(); return 0; }