int
saf_describe_state_group(SAF_ParMode pmode, /* The parallel mode. */
SAF_StateGrp *state_grp, /* The state group to be described. */
char **name, /* [OUT] Returned name of the state group. Pass NULL if you do not want this
* value returned. */
SAF_Suite *suite, /* [OUT] Returned suite the state group is associated with. */
SAF_StateTmpl *stmpl, /* [OUT] Returned state template. Pass NULL if you do not want this value
* returned. */
SAF_Quantity *quantity, /* [OUT] The returned quantity associated with the axis of the
* parametric space. For example, SAF_TIME_QUANTITY. */
SAF_Unit *unit, /* [OUT] The returned units associated with the axis of the parametric
* space. */
hid_t *coord_data_type,/* [OUT] The returned data type of the coordinates of the parametric
* space. */
int *num_states /* [OUT] Returned number of states that have been written to this state
* group. Pass NULL if you do not want this value returned. */
)
{
SAF_ENTER(saf_describe_state_group, SAF_PRECONDITION_ERROR);
int num_stategrp_state_comp;
int index[1];
SAF_Field *coord;
SAF_Field *coords;
SAF_Field *param_coord;
SAF_Field *stategrp_state;
SAF_Field *stategrp_contents;
SAF_FieldTmpl param_coord_tmpl;
SAF_FieldTmpl tmp_field_tmpl[1];
hid_t stategrp_state_type;
size_t stategrp_state_size;
saf_describe_field(pmode, state_grp, NULL, name, suite,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL);
/* the stategrp blob should contain two field handles:
* the first is the indirect coord field containing the mesh_coords, and param_coord
* the second is the state field containing the fields stored at this suite_index */
stategrp_contents = NULL;
index[0] = 0;
saf_read_field (pmode, state_grp, NULL, 1, SAF_TUPLES, index, (void **)(&stategrp_contents));
coord = &(stategrp_contents[0]);
stategrp_state = &(stategrp_contents[1]);
/* now read the coord field and get the mesh coord and the param coord (dump times) */
coords = NULL;
saf_read_field (pmode, coord, NULL, 1, SAF_TUPLES, index, (void **)(&coords));
param_coord = &(coords[0]);
/* get information from the param_coord field */
saf_describe_field(pmode, param_coord, ¶m_coord_tmpl, NULL, NULL, unit,
NULL, NULL, NULL, NULL, NULL, NULL,
coord_data_type, NULL, NULL, NULL, NULL);
saf_describe_field_tmpl( pmode, ¶m_coord_tmpl, NULL, NULL, NULL,
quantity, NULL, NULL);
/* get the state template for the stategrp_state */
saf_describe_field(pmode, stategrp_state, tmp_field_tmpl,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL);
saf_describe_field_tmpl(pmode, tmp_field_tmpl+0, NULL, NULL, NULL, NULL,
&num_stategrp_state_comp, NULL);
if( stmpl != NULL ) {
*stmpl = tmp_field_tmpl[0];
}
if( num_states != NULL ) {
/* get the count for the stategrp_state field */
saf_get_count_and_type_for_field(pmode, stategrp_state, NULL, &stategrp_state_size, &stategrp_state_type);
*num_states = stategrp_state_size / num_stategrp_state_comp;
}
_saf_free(coords);
_saf_free(stategrp_contents);
SAF_LEAVE(0);
}