1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 void make_temperature_on_ns1_field(void)
 {
    SAF_Unit ukelvin;          /* Handle to the units for the temperature. */
    /* Made up temperatures. */
    float temp1_dof_tuple[] = {100., 150., 150., 100., 75.};
    void *dofs = &temp1_dof_tuple[0];
    /* More made up temperatures. */
    float new_temp1_dof_tuple[] = {375., 415., 225., 195., 150.};
    void *new_dofs = &new_temp1_dof_tuple[0];

    /*
     ---------------------------------------------------------------------------
     *                         DECLARE FIELD TEMPLATES
     ---------------------------------------------------------------------------
     */
    saf_declare_field_tmpl(SAF_ALL,  db,"temp_on_ns1_tmpl", SAF_ALGTYPE_SCALAR,
                           SAF_UNITY, SAF_QTEMP, 1, NULL, &temp1_ftmpl);

    /*
     ---------------------------------------------------------------------------
     *                         DECLARE AND WRITE FIELDS
     *                      (dofs specified in write call)
     ---------------------------------------------------------------------------
     */
    /* Get a handle to the units for this field. */
    saf_find_one_unit(db, "kelvin", &ukelvin);

    /* Declare the field. */
    saf_declare_field(SAF_ALL, db, &temp1_ftmpl, "temperature", &ns1, &ukelvin,
                      SAF_SELF(db), SAF_NODAL(&nodes, &nodes), H5T_NATIVE_FLOAT,
                      NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL, &temps1);

    /* Write the field. */
    saf_write_field(SAF_ALL, &temps1, SAF_WHOLE_FIELD, 1,
                    H5I_INVALID_HID, &dofs, saf_file);

    /*
     ---------------------------------------------------------------------------
     *                             OVERWRITE FIELD
     ---------------------------------------------------------------------------
     */
    saf_write_field(SAF_ALL, &temps1, SAF_WHOLE_FIELD, 1,
                    H5I_INVALID_HID, &new_dofs, saf_file);

    return;
 }