1.1.1. 06.2.3.1 "put" and "putSlice" functions
put | putSlice |
---|---|
IMAS C++ :: put #include "UALClasses.h" using namespace IdsNs; int main(int argc, char *argv[]) { IDS::core_profiles ids; // <= IDS object const char* treename = "ids"; const char* database = "test"; int shot = 13; int run = 22; char* userName; char* imasVersion; // Gets user name and data version userName = getenv("USER"); imasVersion = getenv("IMAS_VERSION"); //Create a new instance of database IdsNs::IDS imas(shot, run, -1, -1); imas.createEnv(userName, database, imasVersion); ids = imas._core_profiles; // Mandatory to define this property ids.ids_properties.homogeneous_time = IDS_TIME_MODE_HOMOGENEOUS; ids.ids_properties.comment = "IDS stored by put (CPP)"; // allocate the IDS structures - vector of size N ids.time.resize(10); ids.global_quantities.ip.resize(10); // Fill IDS time-dependent fields for(int i=0; i < 10; i++) { // Do not forget time!! ids.time(i) = i; // Setting values of data ids.global_quantities.ip(i) = 2*i; } // Save data in the database ids.put(); // Close the pulse file imas.close(); } | IMAS C++ :: putSlice #include "UALClasses.h" using namespace IdsNs; int main(int argc, char *argv[]) { IDS::core_profiles ids; // <= IDS object const char* treename = "ids"; const char* database = "test"; int shot = 13; int run = 22; char* userName; char* imasVersion; // Gets user name and data version userName = getenv("USER"); imasVersion = getenv("IMAS_VERSION"); //Create a new instance of database IdsNs::IDS imas(shot, run, -1, -1); imas.createEnv(userName, database, imasVersion); ids = imas._core_profiles; // Mandatory to define this property ids.ids_properties.homogeneous_time = IDS_TIME_MODE_HOMOGENEOUS; ids.ids_properties.comment = "IDS stored by putSlice (CPP)"; // allocate the IDS structures - vector of size 1 ids.global_quantities.ip.resize(1); ids.time.resize(1); // Fill IDS time-dependent fields for(int i=0; i < 10; i++) { // Do not forget time!! ids.time(0) = i; // Setting values of data ids.global_quantities.ip(0) = 2*i; // Save data in the database if( i == 0) ids.put(); else ids.putSlice(); } // Close the pulse file imas.close(); } |
1.1.2. 06.2.3.2 "get" and "getSlice" functions
get | getSlice |
---|---|
IMAS C++ :: get #include <iostream> #include "UALClasses.h" using namespace IdsNs; int main(int argc, char *argv[]) { IDS::core_profiles ids; // <= IDS object const char* treename = "ids"; const char* database = "test"; int shot = 13; int run = 22; char* userName; char* imasVersion; // Gets user name and data version userName = getenv("USER"); imasVersion = getenv("IMAS_VERSION"); //Open database IdsNs::IDS imas(shot, run, -1, -1); imas.openEnv(userName, database, imasVersion); ids = imas._core_profiles; ids.get(); cout << "Time: " << ids.time << endl; cout << "Value: " << ids.global_quantities.ip << endl; // Close the pulse file imas.close(); } | IMAS C++ :: getSlice #include <iostream> #include "UALClasses.h" using namespace IdsNs; int main(int argc, char *argv[]) { IDS::core_profiles ids; // <= IDS object const char* treename = "ids"; const char* database = "test"; int shot = 13; int run = 22; char* userName; char* imasVersion; // Gets user name and data version userName = getenv("USER"); imasVersion = getenv("IMAS_VERSION"); //Open database IdsNs::IDS imas(shot, run, -1, -1); imas.openEnv(userName, database, imasVersion); ids = imas._core_profiles; //Get the slice corresponding to the passed time ids.getSlice(2.0, 2); cout << "Time: " << ids.time << endl; cout << "Value: " << ids.global_quantities.ip << endl; // Close the pulse file imas.close(); } |
Building the code
CXX=g++ COPTS = -g `pkg-config imas-cpp --cflags` LIBS =`pkg-config imas-cpp --libs` all: ids_get.exe ids_put.exe ids_getSlice.exe ids_putSlice.exe %.exe: %.cpp $(CXX) $(COPTS) -o $@ $< $(LIBS) clean: rm -f *.o *.exe