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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 herr_t
 ss_blob_set_2pio(ss_blob_t *blob,       /* Optional blob to which whose file these settings apply. If no blob is
                                          * specified then the settings apply to SSlib in general and can be overridden
                                          * by individual blobs. */
                  ss_prop_t *props       /* See [Aggregation Properties]. */
                  )
 {
     SS_ENTER(ss_blob_set_2pio, herr_t);
     int                 self, i;
     size_t              size;
     ss_blob_2pio_t      *agg=NULL;
     ss_scope_t          topscope=SS_SCOPE_NULL;
     ss_gblob_t          *gblob=NULL;
     char                *s=NULL;

     if (!blob && !props) {
         /* Broadcast SSLIB_2PIO environment variable from library task zero to all other library tasks */
         if ((self=ss_mpi_comm_rank(sslib_g.comm))<0) SS_ERROR(FAILED);
         if (0==self) {
             const char *s_const = getenv("SSLIB_2PIO");
             size = s_const ? strlen(s_const)+1 : 0;
             if (size) {
                 if (NULL==(s=malloc(size))) SS_ERROR(RESOURCE);
                 strcpy(s, s_const);
             }
         }
         if (ss_mpi_bcast(&size, 1, MPI_SIZE_T, 0, sslib_g.comm)<0) SS_ERROR(FAILED);
         if (size) {
             if (!s && NULL==(s=malloc(size))) SS_ERROR(RESOURCE);
             if (ss_mpi_bcast(s, size, MPI_CHAR, 0, sslib_g.comm)<0) SS_ERROR(FAILED);
         }

         /* Parse the SSLIB_2PIO value to create a property list */
         if (NULL==(props=ss_blob_init_2pio(NULL, "defaults"))) SS_ERROR(FAILED);
         if (NULL==(props=ss_blob_init_2pio(props, s))) SS_ERROR(FAILED);

         /* Use the property list to set properties */
         if (ss_blob_set_2pio(blob, props)<0) SS_ERROR(FAILED);
         if (ss_prop_dest(props)<0) SS_ERROR(FAILED);
         props = NULL;
         s = SS_FREE(s);

     } else {
         SS_ASSERT_TYPE(props, ss_prop_t);
         if (!blob) {
             agg = &ss_blob_2pio_g;
         } else {
             if (!ss_mpi_extras((ss_pers_t**)&blob, &topscope)) SS_ERROR(FAILED);
             gblob = SS_GFILE_LINK(&topscope)->gblob;
             if (gblob->a) SS_ERROR_FMT(USAGE, ("cannot set file properties after I/O occurs"))
             agg = &(gblob->agg);
         }
         if (ss_prop_get(props, "minbufsize",  H5T_NATIVE_SIZE, &size)) agg->minbufsize  = size;
         if (ss_prop_get(props, "alignment",   H5T_NATIVE_SIZE, &size)) agg->alignment   = size;
         if (ss_prop_get(props, "maxaggtasks", H5T_NATIVE_SIZE, &size)) agg->maxaggtasks = size;
         if (ss_prop_get(props, "sendqueue",   H5T_NATIVE_SIZE, &size)) agg->sendqueue   = size;
         if (ss_prop_get(props, "aggbuflimit", H5T_NATIVE_SIZE, &size)) agg->aggbuflimit = size;
         if (ss_prop_get(props, "asynchdf5",   H5T_NATIVE_INT,  &i))    agg->asynchdf5   = i ? TRUE : FALSE;
         if (ss_prop_get(props, "aggbase",     H5T_NATIVE_INT,  &i))    agg->aggbase     = i;
         if (ss_prop_get(props, "tpn",         H5T_NATIVE_INT,  &i))    agg->tpn         = i;
         SS_STATUS_OK; /*ignore failures from ss_prop_get() calls*/
     }

  SS_CLEANUP:
     SS_FREE(s);
     SS_LEAVE(0);
 }