4040#include < regex>
4141#include < string>
4242
43- #ifndef DGCOMP
44- #define DGCOMP 6 // Define to prevent errors from static analysis tools
45- #error "Number of DG components (DGCOMP) not defined" // But throw an error anyway
46- #endif
47-
48- #ifndef DGSTRESSCOMP
49- #define DGSTRESSCOMP 8 // Define to prevent errors from static analysis tools
50- #error "Number of DG stress components (DGSTRESSCOMP) not defined" // But throw an error anyway
51- #endif
52-
5343#ifndef CGDEGREE
5444#define CGDEGREE 2 // Define to prevent errors from static analysis tools
5545#error "CG degree (CGDEGREE) not defined" // But throw an error anyway
@@ -255,21 +245,17 @@ void Xios::configureServer()
255245 // Initialize 'nextSIM-DG' context
256246 cxios_context_initialize (contextId.c_str (), contextId.length (), &clientComm_F);
257247
258- // Initialize calendar wrapper for 'nextSIM-DG' context
248+ // Set the calendar timestep for the 'nextSIM-DG' context
249+ // NOTE: The calendar itself is set up in iodef.xml
259250 cxios_get_current_calendar_wrapper (&clientCalendar);
260- cxios_set_calendar_wrapper_type (clientCalendar, calendarType.c_str (), calendarType.length ());
261251 ModelMetadata& metadata = ModelMetadata::getInstance ();
262252 cxios_set_calendar_wrapper_timestep (
263253 clientCalendar, convertDurationToXios (metadata.stepLength ()));
264- cxios_create_calendar (clientCalendar);
265254 cxios_update_calendar_timestep (clientCalendar);
266255 if (!cxios_is_defined_calendar_wrapper_timestep (clientCalendar)) {
267256 throw std::runtime_error (" Xios: Calendar timestep has not been set" );
268257 }
269258
270- // Set default calendar origin
271- setCalendarOrigin (TimePoint (" 1970-01-01T00:00:00Z" )); // Unix epoch
272-
273259 // Set start time from configuration file
274260 setCalendarStart (metadata.startTime ());
275261}
@@ -357,17 +343,6 @@ cxios_duration Xios::convertDurationToXios(const Duration duration)
357343 return cxios_duration ({ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , duration.seconds () });
358344}
359345
360- /* !
361- * Set calendar origin
362- *
363- * @param origin
364- */
365- void Xios::setCalendarOrigin (const TimePoint origin)
366- {
367- cxios_date datetime = convertStringToXiosDatetime (origin.format (), true );
368- cxios_set_calendar_wrapper_date_time_origin (clientCalendar, datetime);
369- }
370-
371346/* !
372347 * Set calendar start date
373348 *
@@ -391,21 +366,6 @@ void Xios::setCalendarStep(const int stepNumber) { cxios_update_calendar(stepNum
391366 */
392367void Xios::incrementCalendar () { setCalendarStep (getCalendarStep () + 1 ); }
393368
394- /* !
395- * Get calendar origin
396- *
397- * @return calendar origin
398- */
399- TimePoint Xios::getCalendarOrigin ()
400- {
401- if (!cxios_is_defined_calendar_wrapper_time_origin (clientCalendar)) {
402- throw std::runtime_error (" Xios: Calendar origin has not been set" );
403- }
404- cxios_date calendar_origin;
405- cxios_get_calendar_wrapper_date_time_origin (clientCalendar, &calendar_origin);
406- return TimePoint (convertXiosDatetimeToString (calendar_origin, true ));
407- }
408-
409369/* !
410370 * Get calendar start date
411371 *
@@ -440,22 +400,6 @@ TimePoint Xios::getCurrentDate()
440400 return TimePoint (convertXiosDatetimeToString (xiosDate, true ));
441401}
442402
443- /* !
444- * Get the axis_definition group
445- *
446- * @return a pointer to the XIOS CAxisGroup object
447- */
448- xios::CAxisGroup* Xios::getAxisGroup ()
449- {
450- const std::string groupId = " axis_definition" ;
451- xios::CAxisGroup* group = NULL ;
452- cxios_axisgroup_handle_create (&group, groupId.c_str (), groupId.length ());
453- if (!group) {
454- throw std::runtime_error (" Xios: Null pointer for group 'axis_definition'" );
455- }
456- return group;
457- }
458-
459403/* !
460404 * Get the axis associated with a given ID
461405 *
@@ -477,47 +421,6 @@ xios::CAxis* Xios::getAxis(const std::string axisId)
477421 return axis;
478422}
479423
480- /* !
481- * Create an axis with some ID.
482- *
483- * @param the axis ID
484- */
485- void Xios::createAxis (const std::string axisId)
486- {
487- bool exists;
488- cxios_axis_valid_id (&exists, axisId.c_str (), axisId.length ());
489- if (exists) {
490- throw std::runtime_error (" Xios: Axis '" + axisId + " ' already exists" );
491- }
492- xios::CAxis* axis = NULL ;
493- cxios_xml_tree_add_axis (getAxisGroup (), &axis, axisId.c_str (), axisId.length ());
494- if (!axis) {
495- throw std::runtime_error (" Xios: Null pointer for axis '" + axisId + " '" );
496- }
497- cxios_axis_valid_id (&exists, axisId.c_str (), axisId.length ());
498- if (!exists) {
499- throw std::runtime_error (" Xios: Failed to create axis '" + axisId + " '" );
500- }
501- }
502-
503- /* !
504- * Set the size of a given axis (the number of global points)
505- *
506- * @param the axis ID
507- * @param the size to set
508- */
509- void Xios::setAxisSize (const std::string axisId, const size_t size)
510- {
511- xios::CAxis* axis = getAxis (axisId);
512- if (cxios_is_defined_axis_n_glo (axis)) {
513- Logged::warning (" Xios: Size already set for axis '" + axisId + " '" );
514- }
515- cxios_set_axis_n_glo (axis, (int )size);
516- if (!cxios_is_defined_axis_n_glo (axis)) {
517- throw std::runtime_error (" Xios: Failed to set size for axis '" + axisId + " '" );
518- }
519- }
520-
521424/* !
522425 * Get the size of a given axis (the number of global points)
523426 *
@@ -705,8 +608,8 @@ void Xios::setupDomains()
705608 auto & metadata = ModelMetadata::getInstance ();
706609
707610 ModelArray::setNComponents (ModelArray::Type::VERTEX, ModelArray::nCoords);
708- ModelArray::setNComponents (ModelArray::Type::DG, DGCOMP );
709- ModelArray::setNComponents (ModelArray::Type::DGSTRESS, DGSTRESSCOMP );
611+ ModelArray::setNComponents (ModelArray::Type::DG, getAxisSize ( " DGAxis " ) );
612+ ModelArray::setNComponents (ModelArray::Type::DGSTRESS, getAxisSize ( " DGSAxis " ) );
710613 for (auto entry : domainIds) {
711614 ModelArray::Type type = entry.first ;
712615 const std::string domainId = entry.second ;
@@ -830,29 +733,6 @@ void Xios::setupDomains()
830733 }
831734}
832735
833- /* !
834- * @brief Create XIOS axes for each ModelArray type
835- *
836- * @details This function sets up the XIOS axes for each field type based on the configuration
837- * in the axisIds map and in the ModelArray class.
838- */
839- void Xios::setupAxes ()
840- {
841- for (auto entry : axisIds) {
842- ModelArray::Type type = entry.first ;
843- const std::string axisId = entry.second ;
844- ModelArray::Dimension dim = ModelArray::componentMap.at (type);
845- createAxis (axisId);
846- setAxisSize (axisId, ModelArray::size (dim));
847- xios::CAxis* axis = getAxis (axisId);
848- const std::string axisName = axisNames[axisId];
849- cxios_set_axis_dim_name (axis, axisName.c_str (), axisName.length ());
850- if (!cxios_is_defined_axis_dim_name (axis)) {
851- throw std::runtime_error (" Xios: Failed to set name for axis '" + axisId + " '" );
852- }
853- }
854- }
855-
856736/* !
857737 * @brief Create XIOS grids for each ModelArray type
858738 *
@@ -865,35 +745,13 @@ void Xios::setupGrids()
865745 for (auto entry : gridIds) {
866746 ModelArray::Type type = entry.first ;
867747 const std::string gridId = entry.second ;
868- createGrid (gridId);
869748 xios::CGrid* grid = getGrid (gridId);
870- if (axisIds.count (type) > 0 ) {
871- const std::string axisId = axisIds[type];
872- xios::CAxis* axis = getAxis (axisId);
873- cxios_xml_tree_add_axistogrid (grid, &axis, axisId.c_str (), axisId.length ());
874- }
875749 const std::string domainId = domainIds[type];
876750 xios::CDomain* domain = getDomain (domainId);
877751 cxios_xml_tree_add_domaintogrid (grid, &domain, domainId.c_str (), domainId.length ());
878752 }
879753}
880754
881- /* !
882- * Get the grid_definition group
883- *
884- * @return a pointer to the XIOS CGridGroup object
885- */
886- xios::CGridGroup* Xios::getGridGroup ()
887- {
888- const std::string groupId = " grid_definition" ;
889- xios::CGridGroup* group = NULL ;
890- cxios_gridgroup_handle_create (&group, groupId.c_str (), groupId.length ());
891- if (!group) {
892- throw std::runtime_error (" Xios: Null pointer for group 'grid_definition'" );
893- }
894- return group;
895- }
896-
897755/* !
898756 * Get the grid associated with a given ID
899757 *
@@ -915,56 +773,6 @@ xios::CGrid* Xios::getGrid(const std::string gridId)
915773 return grid;
916774}
917775
918- /* !
919- * Create a grid with some ID
920- *
921- * @param the grid ID
922- */
923- void Xios::createGrid (const std::string gridId)
924- {
925- bool exists;
926- cxios_grid_valid_id (&exists, gridId.c_str (), gridId.length ());
927- if (exists) {
928- throw std::runtime_error (" Xios: Grid '" + gridId + " ' already exists" );
929- }
930- xios::CGrid* grid = NULL ;
931- cxios_xml_tree_add_grid (getGridGroup (), &grid, gridId.c_str (), gridId.length ());
932- if (!grid) {
933- throw std::runtime_error (" Xios: Null pointer for grid '" + gridId + " '" );
934- }
935- cxios_grid_valid_id (&exists, gridId.c_str (), gridId.length ());
936- if (!exists) {
937- throw std::runtime_error (" Xios: Failed to create grid '" + gridId + " '" );
938- }
939- cxios_set_grid_name (grid, gridId.c_str (), gridId.length ());
940- if (!cxios_is_defined_grid_name (grid)) {
941- throw std::runtime_error (" Xios: Failed to set name for grid '" + gridId + " '" );
942- }
943- }
944-
945- /* !
946- * Associate an axis with a grid
947- *
948- * @param the grid ID
949- * @param the axis ID
950- */
951- void Xios::gridAddAxis (const std::string gridId, const std::string axisId)
952- {
953- xios::CAxis* axis = getAxis (axisId);
954- cxios_xml_tree_add_axistogrid (getGrid (gridId), &axis, axisId.c_str (), axisId.length ());
955- }
956-
957- /* !
958- * Get all axis IDs associated with a given grid
959- *
960- * @param the grid ID
961- * @return all axis IDs associated with the grid
962- */
963- std::vector<std::string> Xios::getGridAxisIds (const std::string gridId)
964- {
965- return getGrid (gridId)->getAxisList ();
966- }
967-
968776/* !
969777 * Get the field_definition group
970778 *
@@ -1603,7 +1411,7 @@ std::vector<std::string> Xios::fileGetFieldIds(const std::string fileId)
16031411{
16041412 std::vector<xios::CField*> fields = getFile (fileId)->getAllFields ();
16051413 std::vector<std::string> fieldIds (fields.size ());
1606- for (int i = 0 ; i < fields.size (); i++) {
1414+ for (size_t i = 0 ; i < fields.size (); i++) {
16071415 fieldIds[i] = fields[i]->getId ();
16081416 }
16091417 return fieldIds;
0 commit comments