void make_direct_temperature_field(void)
{
SAF_Unit ukelvin; /* Handle to the units for the field. */
SAF_FieldTmpl temp_d0_ftmpl, /* Handle to the field template on domain0. */
temp_d1_ftmpl; /* Handle to the field template on domain1. */
/* Temperature values. */
float domain0_temps[] = { 0., 1., 1.414213562373095,
1., 1., 1.414213562373095,
1.732050807568877,
1.414213562373095},
domain1_temps[] = { 1., 2., 2.23606797749979,
1.414213562373095,
1.414213562373095,
2.23606797749979,
2.449489742783177,
1.732050807568877};
void *pdomain0_temps = &domain0_temps[0],
*pdomain1_temps = &domain1_temps[0];
/*
---------------------------------------------------------------------------
* DECLARE FIELD TEMPLATES
---------------------------------------------------------------------------
*/
/* on domain0 */
saf_declare_field_tmpl(SAF_ALL, db, "temp_on_domain0", SAF_ALGTYPE_SCALAR,
SAF_UNITY, SAF_QTEMP, 1, NULL, &temp_d0_ftmpl);
/* on domain1 */
saf_declare_field_tmpl(SAF_ALL, db, "temp_on_domain1", SAF_ALGTYPE_SCALAR,
SAF_UNITY, SAF_QTEMP, 1, NULL, &temp_d1_ftmpl);
/*
---------------------------------------------------------------------------
* DECLARE AND WRITE FIELDS
---------------------------------------------------------------------------
*/
/* Get the handle to the units for the field. */
saf_find_one_unit(db, "kelvin", &ukelvin);
/* on domain0 */
saf_declare_field(SAF_ALL, db, &temp_d0_ftmpl, "temperature", &domain0, &ukelvin,
SAF_SELF(db), SAF_NODAL(&nodes, &zones), SAF_FLOAT,
NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL, &temp_d0);
saf_write_field(SAF_ALL, &temp_d0, SAF_WHOLE_FIELD, 1, H5I_INVALID_HID,
&pdomain0_temps, db);
/* on domain1 */
saf_declare_field(SAF_ALL, db, &temp_d1_ftmpl, "temperature", &domain1, &ukelvin,
SAF_SELF(db), SAF_NODAL(&nodes, &zones), SAF_FLOAT,
NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL, &temp_d1);
saf_write_field(SAF_ALL, &temp_d1, SAF_WHOLE_FIELD, 1, H5I_INVALID_HID,
&pdomain1_temps, db);
return;
}