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
47
48
 int
 saf_describe_field_tmpl(SAF_ParMode pmode,      /* The parallel mode. */
                         SAF_FieldTmpl *ftmpl,   /* The field template to be described. */
                         char **name,            /* [OUT] The returned name. Pass NULL if you do not want the name returned.
                                                  * (see Returned Strings). */
                         SAF_Algebraic *alg_type,/* [OUT] The returned algebraic type. Pass NULL if you do not want the type
                                                  * returned. */
                         SAF_Basis *basis,       /* [OUT] The returned basis. Pass null if you do not want the basis returned. */
                         SAF_Quantity *quantity, /* [OUT] The returned quantity. Pass null if you do not want the name returned. */
                         int *num_comp,          /* [OUT] The returned number of components. Pass NULL if you do not want the name
                                                  * returned. Note that if the field template is assocaited with an INhomogeneous
                                                  * field, the returned value will always be SAF_NOT_APPLICABLE_INT. */
                         SAF_FieldTmpl **ctmpl   /* [OUT] The returned array of component field template handles.  Pass NULL if you
                                                  * do not want the array returned. If the field template is associated with
                                                  * an INhomogeneous field, the returned value, if requested, will always be
                                                  * NULL. (If the field template does not point to other field templates then
                                                  * this argument will be untouched by this function.) */
                         )
 {
     SAF_ENTER(saf_describe_field_tmpl, SAF_PRECONDITION_ERROR);

     SAF_REQUIRE(_saf_valid_pmode(pmode), SAF_LOW_CHK_COST, SAF_PRECONDITION_ERROR,
                 _saf_errmsg("PMODE must be valid"));
     if (!_saf_is_participating_proc(pmode)) SAF_RETURN(-1);

     SAF_REQUIRE(SS_FIELDTMPL(ftmpl), SAF_LOW_CHK_COST, SAF_PRECONDITION_ERROR,
                 _saf_errmsg("FTMPL must be a valid field template handle"));

     /* Fill in the returned values */
     if (_saf_setupReturned_string(name, ss_string_ptr(SS_FIELDTMPL_P(ftmpl,name))) != SAF_SUCCESS)
         SAF_ERROR(SAF_MEMORY_ERROR, _saf_errmsg("unable to return name for field template %s\n",
                                                 ss_string_ptr(SS_FIELDTMPL_P(ftmpl,name))));
     if (alg_type)
         *alg_type = SS_FIELDTMPL(ftmpl)->algebraic;
     if (basis)
         *basis = SS_FIELDTMPL(ftmpl)->basis;
     if (quantity)
         *quantity = SS_FIELDTMPL(ftmpl)->quantity;
     if (num_comp)
         *num_comp = SS_FIELDTMPL(ftmpl)->num_comps;
     if (ctmpl && ss_array_nelmts(SS_FIELDTMPL_P(ftmpl,ftmpls))>0) {
         /* Only initialize CTMPL if there are stored field template links in this field template. */
         if (NULL==(*ctmpl=ss_array_get(SS_FIELDTMPL_P(ftmpl,ftmpls), ss_pers_tm, (size_t)0, SS_NOSIZE, *ctmpl)))
             SAF_ERROR(SAF_MEMORY_ERROR, _saf_errmsg("cannot read field template's ftmpls array"));
     }

     SAF_LEAVE(SAF_SUCCESS);
 }