Skip to content

Commit

Permalink
Merge pull request #42 from TobiasWeigel/tw-devel
Browse files Browse the repository at this point in the history
read tracking_prefix from tables and prepend to UUID

Seems fair!  merging request #42
  • Loading branch information
dnadeau4 committed Sep 10, 2015
2 parents 96e3489 + deb28c1 commit 8950f80
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Src/cmor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2484,7 +2484,14 @@ int cmor_write(int var_id,void *data, char type, char *suffix, int ntimes_passed
myuuid_str = NULL;
fmt = UUID_FMT_STR;
uuid_export(myuuid,fmt,&myuuid_str,&uuidlen);
strncpy(cmor_current_dataset.tracking_id,(char *)myuuid_str,CMOR_MAX_STRING);
if (cmor_tables[cmor_vars[var_id].ref_table_id].tracking_prefix != '\0') {
strncpy(cmor_current_dataset.tracking_id, cmor_tables[cmor_vars[var_id].ref_table_id].tracking_prefix, CMOR_MAX_STRING);
strcat(cmor_current_dataset.tracking_id, "/");
strcat(cmor_current_dataset.tracking_id, (char *) myuuid_str);
}
else {
strncpy(cmor_current_dataset.tracking_id,(char *)myuuid_str,CMOR_MAX_STRING);
}
cmor_set_cur_dataset_attribute_internal("tracking_id",cmor_current_dataset.tracking_id,0);
free(myuuid_str);
uuid_destroy(myuuid);
Expand Down Expand Up @@ -3347,7 +3354,14 @@ int cmor_write(int var_id,void *data, char type, char *suffix, int ntimes_passed
myuuid_str = NULL;
fmt = UUID_FMT_STR;
uuid_export(myuuid,fmt,&myuuid_str,&uuidlen);
strncpy(cmor_current_dataset.tracking_id,(char *)myuuid_str,CMOR_MAX_STRING);
if (cmor_tables[cmor_vars[var_id].ref_table_id].tracking_prefix != '\0') {
strncpy(cmor_current_dataset.tracking_id, cmor_tables[cmor_vars[var_id].ref_table_id].tracking_prefix, CMOR_MAX_STRING);
strcat(cmor_current_dataset.tracking_id, "/");
strcat(cmor_current_dataset.tracking_id, (char *) myuuid_str);
}
else {
strncpy(cmor_current_dataset.tracking_id,(char *)myuuid_str,CMOR_MAX_STRING);
}
cmor_set_cur_dataset_attribute_internal("tracking_id",cmor_current_dataset.tracking_id,0);

ierr = nc_put_att_text(ncid, NC_GLOBAL, "tracking_id",(int)uuidlen,myuuid_str);
Expand Down
4 changes: 4 additions & 0 deletions Src/cmor_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void cmor_init_table(cmor_table_t *table, int id)
table->interval_warning=.1;
table->interval_error=.2;
table->URL[0]='\0';
table->tracking_prefix[0]='\0';
strcpy(table->product,"output");
table->path[0]='\0';
table->required_gbl_att[0]='\0';
Expand Down Expand Up @@ -112,6 +113,9 @@ int cmor_set_dataset_att(cmor_table_t *table, char att[CMOR_MAX_STRING],char val
else if (strcmp(att,"baseURL")==0) {
strncpy(table->URL,value,CMOR_MAX_STRING);
}
else if (strcmp(att,"tracking_prefix")==0) {
strncpy(table->tracking_prefix,value,CMOR_MAX_STRING);
}
else if (strcmp(att,"forcings")==0) {
cmor_convert_string_to_list(value,'c',(void **)&table->forcings,&table->nforcings);
}
Expand Down
1 change: 1 addition & 0 deletions include/cmor.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ typedef struct cmor_table_ {
float interval_warning;
float interval_error;
char URL[CMOR_MAX_STRING];
char tracking_prefix[CMOR_MAX_STRING];
char product[CMOR_MAX_STRING];
char realm[CMOR_MAX_STRING];
char path[CMOR_MAX_STRING];
Expand Down

0 comments on commit 8950f80

Please sign in to comment.