00001
00002
00003
00004
00005
00006
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #include <libs/xml_utils/xml_utils.h>
00055 #include <dsclim.h>
00056
00058 int
00059 load_conf(data_struct *data, char *fileconf) {
00066 FILE *infile;
00067 long int numbytes;
00068
00069 xmlConfig_t *conf;
00070 char setting_name[1000];
00071 xmlChar *val;
00072 int i;
00073 int j;
00074 int ii;
00075 int cat;
00076 int istat;
00077 char *path = NULL;
00078
00079 char *token;
00080 char *saveptr = NULL;
00081 char *catstr;
00082 char *catstrt;
00083
00084 (void) fprintf(stdout, "%s: *** Current Configuration ***\n\n", __FILE__);
00085
00086 (void) strcpy(setting_name, "setting");
00087
00088
00089 data->conf = (conf_struct *) malloc(sizeof(conf_struct));
00090 if (data->conf == NULL) alloc_error(__FILE__, __LINE__);
00091
00094
00095 infile = fopen(fileconf, "r");
00096 if (infile == NULL) {
00097 (void) fprintf(stderr, "%s: Cannot open %s configuration file for reading. Aborting.\n", __FILE__, fileconf);
00098 (void) free(data->conf);
00099 return -1;
00100 }
00101
00102
00103 istat = fseek(infile, 0L, SEEK_END);
00104 if (istat < 0) {
00105 (void) fprintf(stderr, "%s: Cannot seek to end of %s configuration file. Aborting.\n", __FILE__, fileconf);
00106 (void) free(data->conf);
00107 return -1;
00108 }
00109 numbytes = ftell(infile);
00110 if (numbytes < 0) {
00111 (void) fprintf(stderr, "%s: Cannot get file pointer position of %s configuration file. Aborting.\n", __FILE__, fileconf);
00112 (void) free(data->conf);
00113 return -1;
00114 }
00115
00116
00117 istat = fseek(infile, 0L, SEEK_SET);
00118 if (istat < 0) {
00119 (void) fprintf(stderr, "%s: Cannot seek to beginning of %s configuration file. Aborting.\n", __FILE__, fileconf);
00120 (void) free(data->conf);
00121 return -1;
00122 }
00123
00124
00125 data->conf->config = (char *) calloc(numbytes+1, sizeof(char));
00126 if (data->conf->config == NULL) alloc_error(__FILE__, __LINE__);
00127
00128
00129 istat = fread(data->conf->config, sizeof(char), numbytes, infile);
00130 if (istat < 0) {
00131 (void) fprintf(stderr, "%s: Cannot read %s configuration file. Aborting.\n", __FILE__, fileconf);
00132 (void) free(data->conf);
00133 (void) free(data->conf->config);
00134 return -1;
00135 }
00136
00137 data->conf->config[numbytes] = '\0';
00138
00139
00140 istat = fclose(infile);
00141 if (istat < 0) {
00142 (void) fprintf(stderr, "%s: Cannot close properly %s configuration file. Aborting.\n", __FILE__, fileconf);
00143 (void) free(data->conf);
00144 (void) free(data->conf->config);
00145 return -1;
00146 }
00147
00148 #if DEBUG > 7
00149 printf("The file called test.dat contains this text\n\n%s", data->conf->config);
00150 #endif
00151
00152
00153 conf = xml_load_config(fileconf);
00154 if (conf == NULL) {
00155 (void) free(data->conf);
00156 (void) free(data->conf->config);
00157 (void) xmlCleanupParser();
00158 return -1;
00159 }
00160
00161
00162 data->conf->period_ctrl = (period_struct *) malloc(sizeof(period_struct));
00163 if (data->conf->period_ctrl == NULL) alloc_error(__FILE__, __LINE__);
00164 data->info = (info_struct *) malloc(sizeof(info_struct));
00165 if (data->info == NULL) alloc_error(__FILE__, __LINE__);
00166 data->learning = (learning_struct *) malloc(sizeof(learning_struct));
00167 if (data->learning == NULL) alloc_error(__FILE__, __LINE__);
00168 data->reg = (reg_struct *) malloc(sizeof(reg_struct));
00169 if (data->reg == NULL) alloc_error(__FILE__, __LINE__);
00170
00171 data->field = (field_struct *) malloc(NCAT * sizeof(field_struct));
00172 if (data->field == NULL) alloc_error(__FILE__, __LINE__);
00173
00174
00175
00176 for (i=0; i<NCAT; i++) {
00177 data->field[i].time_ls = (double *) malloc(sizeof(double));
00178 if (data->field[i].time_ls == NULL) alloc_error(__FILE__, __LINE__);
00179 data->field[i].time_s = (time_vect_struct *) malloc(sizeof(time_vect_struct));
00180 if (data->field[i].time_s == NULL) alloc_error(__FILE__, __LINE__);
00181
00182 data->field[i].lat_ls = NULL;
00183 data->field[i].lon_ls = NULL;
00184
00185 data->field[i].lat_eof_ls = NULL;
00186 data->field[i].lon_eof_ls = NULL;
00187 }
00188
00189
00190
00191 path = (char *) malloc(MAXPATH * sizeof(char));
00192 if (path == NULL) alloc_error(__FILE__, __LINE__);
00193
00195 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "debug");
00196 val = xml_get_setting(conf, path);
00197 if ( !xmlStrcmp(val, (xmlChar *) "On") )
00198 data->conf->debug = TRUE;
00199 else
00200 data->conf->debug = FALSE;
00201 (void) fprintf(stdout, "%s: debug = %d\n", __FILE__, data->conf->debug);
00202 if (val != NULL)
00203 (void) xmlFree(val);
00204
00206 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "format");
00207 val = xml_get_setting(conf, path);
00208 if (val != NULL) {
00209 data->conf->format = (int) xmlXPathCastStringToNumber(val);
00210 if (data->conf->format != 3 && data->conf->format != 4)
00211 data->conf->format = 3;
00212 (void) xmlFree(val);
00213 }
00214 else
00215 data->conf->format = 3;
00216 if (data->conf->format == 3)
00217 (void) fprintf(stdout, "%s: NetCDF-3 Classic output format.\n", __FILE__);
00218 else
00219 (void) fprintf(stdout, "%s: NetCDF-4 New HDF5-based format with Classic-type output support.\n", __FILE__);
00220
00222 if (data->conf->format == 4) {
00223 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "compression");
00224 val = xml_get_setting(conf, path);
00225 if (val != NULL) {
00226 if ( !xmlStrcmp(val, (xmlChar *) "On") ) {
00227 data->conf->compression = TRUE;
00228 (void) fprintf(stdout, "%s: Compression ACTIVE for NetCDF-4 format\n", __FILE__);
00229 }
00230 else {
00231 data->conf->compression = FALSE;
00232 (void) fprintf(stdout, "%s: Compression DISABLED for NetCDF-4 format\n", __FILE__);
00233 }
00234 (void) xmlFree(val);
00235 }
00236 }
00237 else
00238 data->conf->compression = FALSE;
00239
00241 if (data->conf->compression == TRUE) {
00242 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "compression_level");
00243 val = xml_get_setting(conf, path);
00244 if (val != NULL) {
00245 data->conf->compression_level = (int) xmlXPathCastStringToNumber(val);
00246 if (data->conf->compression_level < 0) {
00247 data->conf->compression_level = 1;
00248 (void) fprintf(stdout,
00249 "%s: WARNING: NetCDF-4 Compression Level invalid value (must be between 1 and 9 inclusively). Forced to %d.\n",
00250 __FILE__, data->conf->compression_level);
00251 }
00252 else if (data->conf->compression_level > 9) {
00253 data->conf->compression_level = 9;
00254 (void) fprintf(stdout,
00255 "%s: WARNING: NetCDF-4 Compression Level invalid value (must be between 1 and 9 inclusively). Forced to %d.\n",
00256 __FILE__, data->conf->compression_level);
00257 }
00258 (void) xmlFree(val);
00259 }
00260 else {
00261 data->conf->compression_level = 1;
00262 (void) fprintf(stdout,
00263 "%s: WARNING: NetCDF-4 Compression Level not set! (must be between 1 and 9 inclusively). Forced to default value of %d.\n",
00264 __FILE__, data->conf->compression_level);
00265 }
00266 (void) fprintf(stdout, "%s: NetCDF-4 Compression Level = %d.\n", __FILE__, data->conf->compression_level);
00267 }
00268 else
00269 data->conf->compression_level = 0;
00270
00272 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "fixtime");
00273 val = xml_get_setting(conf, path);
00274 if (val != NULL) {
00275 if ( !xmlStrcmp(val, (xmlChar *) "On") ) {
00276 data->conf->fixtime = TRUE;
00277 (void) fprintf(stdout, "%s: WARNING: Will fix time coordinate start date using start date in configuration file!\n", __FILE__);
00278 }
00279 else {
00280 data->conf->fixtime = FALSE;
00281 (void) fprintf(stdout, "%s: Will NOT fix time coordinate start date.\n", __FILE__);
00282 }
00283 (void) xmlFree(val);
00284 }
00285
00286 if (data->conf->fixtime == TRUE) {
00288 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "year_begin_ctrl");
00289 val = xml_get_setting(conf, path);
00290 if (val != NULL) {
00291 data->conf->year_begin_ctrl = xmlXPathCastStringToNumber(val);
00292 (void) fprintf(stdout, "%s: year_begin_ctrl = %d\n", __FILE__, data->conf->year_begin_ctrl);
00293 (void) xmlFree(val);
00294 }
00295 else
00296 data->conf->year_begin_ctrl = -1;
00298 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "year_begin_other");
00299 val = xml_get_setting(conf, path);
00300 if (val != NULL) {
00301 data->conf->year_begin_other = xmlXPathCastStringToNumber(val);
00302 (void) fprintf(stdout, "%s: year_begin_other = %d\n", __FILE__, data->conf->year_begin_other);
00303 (void) xmlFree(val);
00304 }
00305 else
00306 data->conf->year_begin_other = -1;
00307 if (data->conf->year_begin_ctrl == -1 || data->conf->year_begin_other == -1) {
00308 (void) fprintf(stderr, "%s: ERROR: must specify year_begin_ctrl and year_begin_other when using the fixtime setting! Aborting.\n", __FILE__);
00309 return -1;
00310 }
00311 }
00312
00314 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "clim_filter_width");
00315 val = xml_get_setting(conf, path);
00316 data->conf->clim_filter_width = (int) xmlXPathCastStringToNumber(val);
00317 if ( data->conf->clim_filter_width < 4 || data->conf->clim_filter_width > 365 )
00318 data->conf->clim_filter_width = 60;
00319 (void) fprintf(stdout, "%s: clim_filter_width = %d\n", __FILE__, data->conf->clim_filter_width);
00320 if (val != NULL)
00321 (void) xmlFree(val);
00322
00324 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "clim_filter_type");
00325 val = xml_get_setting(conf, path);
00326 if ( !xmlStrcmp(val, (xmlChar *) "hanning") )
00327 data->conf->clim_filter_type = strdup("hanning");
00328 else {
00329 (void) fprintf(stderr, "%s: Invalid clim_filter_type value %s in configuration file. Aborting.\n", __FILE__, val);
00330 (void) abort();
00331 }
00332 (void) fprintf(stdout, "%s: clim_filter_type = %s\n", __FILE__, data->conf->clim_filter_type);
00333 if (val != NULL)
00334 (void) xmlFree(val);
00335
00337 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "deltat");
00338 val = xml_get_setting(conf, path);
00339 if (val != NULL)
00340 data->conf->deltat = (double) xmlXPathCastStringToNumber(val);
00341 else
00342 data->conf->deltat = 2.0;
00343 (void) fprintf(stdout, "%s: Absolute difference of temperature for corrections = %lf\n", __FILE__, data->conf->deltat);
00344 if (val != NULL)
00345 (void) xmlFree(val);
00346
00348 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "classif_type");
00349 val = xml_get_setting(conf, path);
00350 if ( !xmlStrcmp(val, (xmlChar *) "euclidian") )
00351 data->conf->classif_type = strdup("euclidian");
00352 else {
00353 (void) fprintf(stderr, "%s: Invalid classif_type value %s in configuration file. Aborting.\n", __FILE__, val);
00354 (void) abort();
00355 }
00356 (void) fprintf(stdout, "%s: classif_type = %s\n", __FILE__, data->conf->classif_type);
00357 if (val != NULL)
00358 (void) xmlFree(val);
00359
00361 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "number_of_partitions");
00362 val = xml_get_setting(conf, path);
00363 if (val != NULL)
00364 data->conf->npartitions = xmlXPathCastStringToNumber(val);
00365 else
00366 data->conf->npartitions = 30;
00367 (void) fprintf(stdout, "%s: Number of partitions = %d\n", __FILE__, data->conf->npartitions);
00368 if (val != NULL)
00369 (void) xmlFree(val);
00370
00372 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "number_of_classifications");
00373 val = xml_get_setting(conf, path);
00374 if (val != NULL)
00375 data->conf->nclassifications = xmlXPathCastStringToNumber(val);
00376 else
00377 data->conf->nclassifications = 1000;
00378 (void) fprintf(stdout, "%s: Number of classifications = %d\n", __FILE__, data->conf->nclassifications);
00379 if (val != NULL)
00380 (void) xmlFree(val);
00381
00383 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "use_downscaled_year");
00384 val = xml_get_setting(conf, path);
00385 if (val != NULL)
00386 data->conf->use_downscaled_year = xmlXPathCastStringToNumber(val);
00387 else
00388 data->conf->use_downscaled_year = 1;
00389 (void) fprintf(stdout, "%s: Use_downscaled_year = %d\n", __FILE__, data->conf->use_downscaled_year);
00390 if (val != NULL)
00391 (void) xmlFree(val);
00392
00394 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "only_wt");
00395 val = xml_get_setting(conf, path);
00396 if (val != NULL)
00397 data->conf->only_wt = xmlXPathCastStringToNumber(val);
00398 else
00399 data->conf->only_wt = 1;
00400 (void) fprintf(stdout, "%s: only_wt = %d\n", __FILE__, data->conf->only_wt);
00401 if (val != NULL)
00402 (void) xmlFree(val);
00403
00405 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "base_time_units");
00406 val = xml_get_setting(conf, path);
00407 if (val != NULL)
00408 data->conf->time_units = strdup((char *) val);
00409 else
00410 data->conf->time_units = strdup("days since 1900-01-01 12:00:00");
00411 (void) fprintf(stdout, "%s: base_time_units = %s\n", __FILE__, data->conf->time_units);
00412 if (val != NULL)
00413 (void) xmlFree(val);
00414
00416 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "base_calendar_type");
00417 val = xml_get_setting(conf, path);
00418 if (val != NULL)
00419 data->conf->cal_type = strdup((char *) val);
00420 else
00421 data->conf->cal_type = strdup("gregorian");
00422 (void) fprintf(stdout, "%s: base_calendar_type = %s\n", __FILE__, data->conf->cal_type);
00423 if (val != NULL)
00424 (void) xmlFree(val);
00425
00427 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "longitude_name_eof");
00428 val = xml_get_setting(conf, path);
00429 if (val != NULL)
00430 data->conf->lonname_eof = strdup((char *) val);
00431 else
00432 data->conf->lonname_eof = strdup("lon");
00433 (void) fprintf(stdout, "%s: longitude_name_eof = %s\n", __FILE__, data->conf->lonname_eof);
00434 if (val != NULL)
00435 (void) xmlFree(val);
00436
00438 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "latitude_name_eof");
00439 val = xml_get_setting(conf, path);
00440 if (val != NULL)
00441 data->conf->latname_eof = strdup((char *) val);
00442 else
00443 data->conf->latname_eof = strdup("lat");
00444 (void) fprintf(stdout, "%s: latitude_name_eof = %s\n", __FILE__, data->conf->latname_eof);
00445 if (val != NULL)
00446 (void) xmlFree(val);
00447
00449 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "dimx_name_eof");
00450 val = xml_get_setting(conf, path);
00451 if (val != NULL)
00452 data->conf->dimxname_eof = strdup((char *) val);
00453 else
00454 data->conf->dimxname_eof = strdup("lon");
00455 (void) fprintf(stdout, "%s: dimx_name_eof = %s\n", __FILE__, data->conf->dimxname_eof);
00456 if (val != NULL)
00457 (void) xmlFree(val);
00458
00460 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "dimy_name_eof");
00461 val = xml_get_setting(conf, path);
00462 if (val != NULL)
00463 data->conf->dimyname_eof = strdup((char *) val);
00464 else
00465 data->conf->dimyname_eof = strdup("lat");
00466 (void) fprintf(stdout, "%s: dimy_name_eof = %s\n", __FILE__, data->conf->dimyname_eof);
00467 if (val != NULL)
00468 (void) xmlFree(val);
00469
00471 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "eof_name");
00472 val = xml_get_setting(conf, path);
00473 if (val != NULL)
00474 data->conf->eofname = strdup((char *) val);
00475 else
00476 data->conf->eofname = strdup("eof");
00477 (void) fprintf(stdout, "%s: eof_name = %s\n", __FILE__, data->conf->eofname);
00478 if (val != NULL)
00479 (void) xmlFree(val);
00480
00482 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "pts_name");
00483 val = xml_get_setting(conf, path);
00484 if (val != NULL)
00485 data->conf->ptsname = strdup((char *) val);
00486 else
00487 data->conf->ptsname = strdup("pts");
00488 (void) fprintf(stdout, "%s: pts_name = %s\n", __FILE__, data->conf->ptsname);
00489 if (val != NULL)
00490 (void) xmlFree(val);
00491
00493 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "clust_name");
00494 val = xml_get_setting(conf, path);
00495 if (val != NULL)
00496 data->conf->clustname = strdup((char *) val);
00497 else
00498 data->conf->clustname = strdup("clust");
00499 (void) fprintf(stdout, "%s: clust_name = %s\n", __FILE__, data->conf->clustname);
00500 if (val != NULL)
00501 (void) xmlFree(val);
00502
00503
00504
00506 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_large_scale", "longitude", "min");
00507 val = xml_get_setting(conf, path);
00508 if (val != NULL)
00509 data->conf->longitude_min = xmlXPathCastStringToNumber(val);
00510 else
00511 data->conf->longitude_min = -15.0;
00512 (void) fprintf(stdout, "%s: Large-scale domain longitude min = %lf\n", __FILE__, data->conf->longitude_min);
00513 if (val != NULL)
00514 (void) xmlFree(val);
00515
00517 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_large_scale", "longitude", "max");
00518 val = xml_get_setting(conf, path);
00519 if (val != NULL)
00520 data->conf->longitude_max = xmlXPathCastStringToNumber(val);
00521 else
00522 data->conf->longitude_max = 20.0;
00523 (void) fprintf(stdout, "%s: Large-scale domain longitude max = %lf\n", __FILE__, data->conf->longitude_max);
00524 if (val != NULL)
00525 (void) xmlFree(val);
00526
00528 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_large_scale", "latitude", "min");
00529 val = xml_get_setting(conf, path);
00530 if (val != NULL)
00531 data->conf->latitude_min = xmlXPathCastStringToNumber(val);
00532 else
00533 data->conf->latitude_min = 35.0;
00534 (void) fprintf(stdout, "%s: Large-scale domain latitude min = %lf\n", __FILE__, data->conf->latitude_min);
00535 if (val != NULL)
00536 (void) xmlFree(val);
00537
00539 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_large_scale", "latitude", "max");
00540 val = xml_get_setting(conf, path);
00541 if (val != NULL)
00542 data->conf->latitude_max = xmlXPathCastStringToNumber(val);
00543 else
00544 data->conf->latitude_max = 60.0;
00545 (void) fprintf(stdout, "%s: Large-scale domain latitude max = %lf\n", __FILE__, data->conf->latitude_max);
00546 if (val != NULL)
00547 (void) xmlFree(val);
00548
00549
00550
00552 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_secondary_large_scale", "longitude", "min");
00553 val = xml_get_setting(conf, path);
00554 if (val != NULL)
00555 data->conf->secondary_longitude_min = xmlXPathCastStringToNumber(val);
00556 else
00557 data->conf->secondary_longitude_min = -15.0;
00558 (void) fprintf(stdout, "%s: Large-scale domain longitude min = %lf\n", __FILE__, data->conf->secondary_longitude_min);
00559 if (val != NULL)
00560 (void) xmlFree(val);
00561
00563 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_secondary_large_scale", "longitude", "max");
00564 val = xml_get_setting(conf, path);
00565 if (val != NULL)
00566 data->conf->secondary_longitude_max = xmlXPathCastStringToNumber(val);
00567 else
00568 data->conf->secondary_longitude_max = 20.0;
00569 (void) fprintf(stdout, "%s: Large-scale domain longitude max = %lf\n", __FILE__, data->conf->secondary_longitude_max);
00570 if (val != NULL)
00571 (void) xmlFree(val);
00572
00574 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_secondary_large_scale", "latitude", "min");
00575 val = xml_get_setting(conf, path);
00576 if (val != NULL)
00577 data->conf->secondary_latitude_min = xmlXPathCastStringToNumber(val);
00578 else
00579 data->conf->secondary_latitude_min = 35.0;
00580 (void) fprintf(stdout, "%s: Large-scale domain latitude min = %lf\n", __FILE__, data->conf->secondary_latitude_min);
00581 if (val != NULL)
00582 (void) xmlFree(val);
00583
00585 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_secondary_large_scale", "latitude", "max");
00586 val = xml_get_setting(conf, path);
00587 if (val != NULL)
00588 data->conf->secondary_latitude_max = xmlXPathCastStringToNumber(val);
00589 else
00590 data->conf->secondary_latitude_max = 60.0;
00591 (void) fprintf(stdout, "%s: Large-scale domain latitude max = %lf\n", __FILE__, data->conf->secondary_latitude_max);
00592 if (val != NULL)
00593 (void) xmlFree(val);
00594
00595
00596 data->secondary_mask = (mask_struct *) malloc(sizeof(mask_struct));
00597 if (data->secondary_mask == NULL) alloc_error(__FILE__, __LINE__);
00599 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_secondary_large_scale_mask", "use_mask");
00600 val = xml_get_setting(conf, path);
00601 if (val != NULL)
00602 data->secondary_mask->use_mask = (int) strtol((char *) val, (char **)NULL, 10);
00603 else
00604 data->secondary_mask->use_mask = FALSE;
00605 if (data->secondary_mask->use_mask != FALSE && data->secondary_mask->use_mask != TRUE) {
00606 (void) fprintf(stderr, "%s: Invalid or missing secondary_mask use_mask value %s in configuration file. Aborting.\n", __FILE__, val);
00607 return -1;
00608 }
00609 (void) fprintf(stdout, "%s: secondary_mask use_mask=%d\n", __FILE__, data->secondary_mask->use_mask);
00610 if (val != NULL)
00611 (void) xmlFree(val);
00612
00613 if (data->secondary_mask->use_mask == TRUE) {
00615 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_secondary_large_scale_mask", "filename");
00616 val = xml_get_setting(conf, path);
00617 if (val != NULL) {
00618 data->secondary_mask->filename = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00619 if (data->secondary_mask->filename == NULL) alloc_error(__FILE__, __LINE__);
00620 (void) strcpy(data->secondary_mask->filename, (char *) val);
00621 (void) fprintf(stdout, "%s: Secondary large-scale fields mask filename = %s\n", __FILE__, data->secondary_mask->filename);
00622 (void) xmlFree(val);
00623
00625 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_secondary_large_scale_mask", "mask_name");
00626 val = xml_get_setting(conf, path);
00627 if (val != NULL) {
00628 data->secondary_mask->maskname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00629 if (data->secondary_mask->maskname == NULL) alloc_error(__FILE__, __LINE__);
00630 (void) strcpy(data->secondary_mask->maskname, (char *) val);
00631 (void) fprintf(stdout, "%s: Secondary large-scale fields mask name = %s\n", __FILE__, data->secondary_mask->maskname);
00632 (void) xmlFree(val);
00633 }
00634 else {
00635 data->secondary_mask->maskname = strdup("mask");
00636 (void) fprintf(stderr, "%s: Default secondary large-scale fields mask name = %s\n", __FILE__,
00637 data->secondary_mask->maskname);
00638 (void) xmlFree(val);
00639 }
00641 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_secondary_large_scale_mask", "longitude_name");
00642 val = xml_get_setting(conf, path);
00643 if (val != NULL) {
00644 data->secondary_mask->lonname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00645 if (data->secondary_mask->lonname == NULL) alloc_error(__FILE__, __LINE__);
00646 (void) strcpy(data->secondary_mask->lonname, (char *) val);
00647 (void) fprintf(stdout, "%s: Secondary large-scale fields mask longitude_name = %s\n", __FILE__, data->secondary_mask->lonname);
00648 (void) xmlFree(val);
00649 }
00650 else {
00651 data->secondary_mask->lonname = strdup("lon");
00652 (void) fprintf(stderr, "%s: Default secondary large-scale fields mask longitude_name = %s\n", __FILE__,
00653 data->secondary_mask->lonname);
00654 (void) xmlFree(val);
00655 }
00657 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_secondary_large_scale_mask", "latitude_name");
00658 val = xml_get_setting(conf, path);
00659 if (val != NULL) {
00660 data->secondary_mask->latname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00661 if (data->secondary_mask->latname == NULL) alloc_error(__FILE__, __LINE__);
00662 (void) strcpy(data->secondary_mask->latname, (char *) val);
00663 (void) fprintf(stdout, "%s: Secondary large-scale fields mask latitude_name = %s\n", __FILE__, data->secondary_mask->latname);
00664 (void) xmlFree(val);
00665 }
00666 else {
00667 data->secondary_mask->latname = strdup("lat");
00668 (void) fprintf(stderr, "%s: Default secondary large-scale fields mask latitude_name = %s\n", __FILE__,
00669 data->secondary_mask->latname);
00670 (void) xmlFree(val);
00671 }
00673 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_secondary_large_scale_mask", "coordinates");
00674 val = xml_get_setting(conf, path);
00675 if (val != NULL)
00676 data->secondary_mask->coords = strdup((char *) val);
00677 else
00678 data->secondary_mask->coords = strdup("2D");
00679 (void) fprintf(stdout, "%s: Secondary large-scale fields mask coords = %s\n", __FILE__, data->secondary_mask->coords);
00680 if (val != NULL)
00681 (void) xmlFree(val);
00683 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_secondary_large_scale_mask", "dimx_name");
00684 val = xml_get_setting(conf, path);
00685 if (val != NULL) {
00686 data->secondary_mask->dimxname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00687 if (data->secondary_mask->dimxname == NULL) alloc_error(__FILE__, __LINE__);
00688 (void) strcpy(data->secondary_mask->dimxname, (char *) val);
00689 (void) fprintf(stdout, "%s: Secondary large-scale fields mask dimx_name = %s\n", __FILE__, data->secondary_mask->dimxname);
00690 (void) xmlFree(val);
00691 }
00692 else {
00693 data->secondary_mask->dimxname = strdup("dimx");
00694 (void) fprintf(stderr, "%s: Default secondary large-scale fields mask dimx_name = %s\n", __FILE__,
00695 data->secondary_mask->dimxname);
00696 (void) xmlFree(val);
00697 }
00699 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_secondary_large_scale_mask", "dimy_name");
00700 val = xml_get_setting(conf, path);
00701 if (val != NULL) {
00702 data->secondary_mask->dimyname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00703 if (data->secondary_mask->dimyname == NULL) alloc_error(__FILE__, __LINE__);
00704 (void) strcpy(data->secondary_mask->dimyname, (char *) val);
00705 (void) fprintf(stdout, "%s: Secondary large-scale fields mask dimy_name = %s\n", __FILE__, data->secondary_mask->dimyname);
00706 (void) xmlFree(val);
00707 }
00708 else {
00709 data->secondary_mask->dimyname = strdup("dimy");
00710 (void) fprintf(stderr, "%s: Default secondary large-scale fields mask dimy_name = %s\n", __FILE__,
00711 data->secondary_mask->dimyname);
00712 (void) xmlFree(val);
00713 }
00715 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_secondary_large_scale_mask", "dim_coordinates");
00716 val = xml_get_setting(conf, path);
00717 if (val != NULL)
00718 data->secondary_mask->dimcoords = strdup((char *) val);
00719 else
00720 data->secondary_mask->dimcoords = strdup("2D");
00721 (void) fprintf(stdout, "%s: Secondary large-scale fields mask dim_coords = %s\n", __FILE__, data->secondary_mask->dimcoords);
00722 if (val != NULL)
00723 (void) xmlFree(val);
00725 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_secondary_large_scale_mask", "projection");
00726 val = xml_get_setting(conf, path);
00727 if (val != NULL) {
00728 data->secondary_mask->proj = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00729 if (data->secondary_mask->proj == NULL) alloc_error(__FILE__, __LINE__);
00730 (void) strcpy(data->secondary_mask->proj, (char *) val);
00731 (void) xmlFree(val);
00732 }
00733 else
00734 data->secondary_mask->proj = strdup("Latitude_Longitude");
00735 (void) fprintf(stdout, "%s: Secondary large-scale fields mask projection = %s\n",
00736 __FILE__, data->secondary_mask->proj);
00737 }
00738 else {
00739 (void) fprintf(stderr, "%s: No secondary large-scale fields mask. Desactivating the use of the mask.\n", __FILE__);
00740 data->secondary_mask->filename = NULL;
00741 data->secondary_mask->use_mask = FALSE;
00742 (void) xmlFree(val);
00743 }
00744 }
00745
00746
00747
00749 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_learning_mask", "longitude", "min");
00750 val = xml_get_setting(conf, path);
00751 if (val != NULL)
00752 data->conf->learning_mask_longitude_min = xmlXPathCastStringToNumber(val);
00753 else
00754 data->conf->learning_mask_longitude_min = -999.0;
00755 (void) fprintf(stdout, "%s: Learning mask domain longitude min = %lf\n", __FILE__, data->conf->learning_mask_longitude_min);
00756 if (val != NULL)
00757 (void) xmlFree(val);
00758
00760 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_learning_mask", "longitude", "max");
00761 val = xml_get_setting(conf, path);
00762 if (val != NULL)
00763 data->conf->learning_mask_longitude_max = xmlXPathCastStringToNumber(val);
00764 else
00765 data->conf->learning_mask_longitude_max = -999.0;
00766 (void) fprintf(stdout, "%s: Learning mask domain longitude max = %lf\n", __FILE__, data->conf->learning_mask_longitude_max);
00767 if (val != NULL)
00768 (void) xmlFree(val);
00769
00771 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_learning_mask", "latitude", "min");
00772 val = xml_get_setting(conf, path);
00773 if (val != NULL)
00774 data->conf->learning_mask_latitude_min = xmlXPathCastStringToNumber(val);
00775 else
00776 data->conf->learning_mask_latitude_min = -999.0;
00777 (void) fprintf(stdout, "%s: Learning mask domain latitude min = %lf\n", __FILE__, data->conf->learning_mask_latitude_min);
00778 if (val != NULL)
00779 (void) xmlFree(val);
00780
00782 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@type=\"%s\"]", "setting", "domain_learning_mask", "latitude", "max");
00783 val = xml_get_setting(conf, path);
00784 if (val != NULL)
00785 data->conf->learning_mask_latitude_max = xmlXPathCastStringToNumber(val);
00786 else
00787 data->conf->learning_mask_latitude_max = -999.0;
00788 (void) fprintf(stdout, "%s: Learning mask domain latitude max = %lf\n", __FILE__, data->conf->learning_mask_latitude_max);
00789 if (val != NULL)
00790 (void) xmlFree(val);
00791
00792
00793 data->conf->learning_maskfile = (mask_struct *) malloc(sizeof(mask_struct));
00794 if (data->conf->learning_maskfile == NULL) alloc_error(__FILE__, __LINE__);
00796 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_learning_maskfile", "use_mask");
00797 val = xml_get_setting(conf, path);
00798 if (val != NULL)
00799 data->conf->learning_maskfile->use_mask = (int) strtol((char *) val, (char **)NULL, 10);
00800 else
00801 data->conf->learning_maskfile->use_mask = FALSE;
00802 if (data->conf->learning_maskfile->use_mask != FALSE && data->conf->learning_maskfile->use_mask != TRUE) {
00803 (void) fprintf(stderr, "%s: Invalid or missing domain_learning_maskfile use_mask value %s in configuration file. Aborting.\n", __FILE__, val);
00804 return -1;
00805 }
00806 (void) fprintf(stdout, "%s: domain_learning_maskfile use_mask=%d\n", __FILE__, data->conf->learning_maskfile->use_mask);
00807 if (val != NULL)
00808 (void) xmlFree(val);
00809
00810 if (data->conf->learning_maskfile->use_mask == TRUE) {
00812 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_learning_maskfile", "filename");
00813 val = xml_get_setting(conf, path);
00814 if (val != NULL) {
00815 data->conf->learning_maskfile->filename = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00816 if (data->conf->learning_maskfile->filename == NULL) alloc_error(__FILE__, __LINE__);
00817 (void) strcpy(data->conf->learning_maskfile->filename, (char *) val);
00818 (void) fprintf(stdout, "%s: Learning domain maskfile filename = %s\n", __FILE__, data->conf->learning_maskfile->filename);
00819 (void) xmlFree(val);
00820
00822 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_learning_maskfile", "mask_name");
00823 val = xml_get_setting(conf, path);
00824 if (val != NULL) {
00825 data->conf->learning_maskfile->maskname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00826 if (data->conf->learning_maskfile->maskname == NULL) alloc_error(__FILE__, __LINE__);
00827 (void) strcpy(data->conf->learning_maskfile->maskname, (char *) val);
00828 (void) fprintf(stdout, "%s: Learning domain maskfile name = %s\n", __FILE__, data->conf->learning_maskfile->maskname);
00829 (void) xmlFree(val);
00830 }
00831 else {
00832 data->conf->learning_maskfile->maskname = strdup("mask");
00833 (void) fprintf(stderr, "%s: Default learning domain maskfile name = %s\n", __FILE__,
00834 data->conf->learning_maskfile->maskname);
00835 (void) xmlFree(val);
00836 }
00838 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_learning_maskfile", "longitude_name");
00839 val = xml_get_setting(conf, path);
00840 if (val != NULL) {
00841 data->conf->learning_maskfile->lonname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00842 if (data->conf->learning_maskfile->lonname == NULL) alloc_error(__FILE__, __LINE__);
00843 (void) strcpy(data->conf->learning_maskfile->lonname, (char *) val);
00844 (void) fprintf(stdout, "%s: Learning domain maskfile longitude_name = %s\n", __FILE__, data->conf->learning_maskfile->lonname);
00845 (void) xmlFree(val);
00846 }
00847 else {
00848 data->conf->learning_maskfile->lonname = strdup("lon");
00849 (void) fprintf(stderr, "%s: Default learning domain maskfile longitude_name = %s\n", __FILE__,
00850 data->conf->learning_maskfile->lonname);
00851 (void) xmlFree(val);
00852 }
00854 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_learning_maskfile", "latitude_name");
00855 val = xml_get_setting(conf, path);
00856 if (val != NULL) {
00857 data->conf->learning_maskfile->latname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00858 if (data->conf->learning_maskfile->latname == NULL) alloc_error(__FILE__, __LINE__);
00859 (void) strcpy(data->conf->learning_maskfile->latname, (char *) val);
00860 (void) fprintf(stdout, "%s: Learning domain maskfile latitude_name = %s\n", __FILE__, data->conf->learning_maskfile->latname);
00861 (void) xmlFree(val);
00862 }
00863 else {
00864 data->conf->learning_maskfile->latname = strdup("lat");
00865 (void) fprintf(stderr, "%s: Default learning domain maskfile latitude_name = %s\n", __FILE__,
00866 data->conf->learning_maskfile->latname);
00867 (void) xmlFree(val);
00868 }
00870 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_learning_maskfile", "coordinates");
00871 val = xml_get_setting(conf, path);
00872 if (val != NULL)
00873 data->conf->learning_maskfile->coords = strdup((char *) val);
00874 else
00875 data->conf->learning_maskfile->coords = strdup("2D");
00876 (void) fprintf(stdout, "%s: Learning domain maskfile coords = %s\n", __FILE__, data->conf->learning_maskfile->coords);
00877 if (val != NULL)
00878 (void) xmlFree(val);
00880 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_learning_maskfile", "dimx_name");
00881 val = xml_get_setting(conf, path);
00882 if (val != NULL) {
00883 data->conf->learning_maskfile->dimxname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00884 if (data->conf->learning_maskfile->dimxname == NULL) alloc_error(__FILE__, __LINE__);
00885 (void) strcpy(data->conf->learning_maskfile->dimxname, (char *) val);
00886 (void) fprintf(stdout, "%s: Learning domain maskfile dimx_name = %s\n", __FILE__, data->conf->learning_maskfile->dimxname);
00887 (void) xmlFree(val);
00888 }
00889 else {
00890 data->conf->learning_maskfile->dimxname = strdup("dimx");
00891 (void) fprintf(stderr, "%s: Default learning domain maskfile dimx_name = %s\n", __FILE__,
00892 data->conf->learning_maskfile->dimxname);
00893 (void) xmlFree(val);
00894 }
00896 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_learning_maskfile", "dimy_name");
00897 val = xml_get_setting(conf, path);
00898 if (val != NULL) {
00899 data->conf->learning_maskfile->dimyname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00900 if (data->conf->learning_maskfile->dimyname == NULL) alloc_error(__FILE__, __LINE__);
00901 (void) strcpy(data->conf->learning_maskfile->dimyname, (char *) val);
00902 (void) fprintf(stdout, "%s: Learning domain maskfile dimy_name = %s\n", __FILE__, data->conf->learning_maskfile->dimyname);
00903 (void) xmlFree(val);
00904 }
00905 else {
00906 data->conf->learning_maskfile->dimyname = strdup("dimy");
00907 (void) fprintf(stderr, "%s: Default learning domain maskfile dimy_name = %s\n", __FILE__,
00908 data->conf->learning_maskfile->dimyname);
00909 (void) xmlFree(val);
00910 }
00912 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_learning_maskfile", "dim_coordinates");
00913 val = xml_get_setting(conf, path);
00914 if (val != NULL)
00915 data->conf->learning_maskfile->dimcoords = strdup((char *) val);
00916 else
00917 data->conf->learning_maskfile->dimcoords = strdup("2D");
00918 (void) fprintf(stdout, "%s: Learning domain maskfile dim_coords = %s\n", __FILE__, data->conf->learning_maskfile->dimcoords);
00919 if (val != NULL)
00920 (void) xmlFree(val);
00922 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "domain_learning_maskfile", "projection");
00923 val = xml_get_setting(conf, path);
00924 if (val != NULL) {
00925 data->conf->learning_maskfile->proj = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
00926 if (data->conf->learning_maskfile->proj == NULL) alloc_error(__FILE__, __LINE__);
00927 (void) strcpy(data->conf->learning_maskfile->proj, (char *) val);
00928 (void) xmlFree(val);
00929 }
00930 else
00931 data->conf->learning_maskfile->proj = strdup("Latitude_Longitude");
00932 (void) fprintf(stdout, "%s: Learning domain maskfile projection = %s\n",
00933 __FILE__, data->conf->learning_maskfile->proj);
00934 }
00935 else {
00936 (void) fprintf(stderr, "%s: No learning domain maskfile. Desactivating the use of the mask.\n", __FILE__);
00937 data->conf->learning_maskfile->filename = NULL;
00938 data->conf->learning_maskfile->use_mask = FALSE;
00939 (void) xmlFree(val);
00940 }
00941 }
00942
00943
00944
00946 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "path");
00947 val = xml_get_setting(conf, path);
00948 if (val != NULL)
00949 data->conf->output_path = strdup((char *) val);
00950 else {
00951 (void) fprintf(stderr, "%s: Missing or invalid output path setting. Aborting.\n", __FILE__);
00952 return -1;
00953 }
00954 (void) fprintf(stdout, "%s: output path = %s\n", __FILE__, data->conf->output_path);
00955 if (val != NULL)
00956 (void) xmlFree(val);
00957
00959 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "month_begin");
00960 val = xml_get_setting(conf, path);
00961 if (val != NULL)
00962 data->conf->output_month_begin = xmlXPathCastStringToNumber(val);
00963 else {
00964 (void) fprintf(stderr, "%s: Missing or invalid output month_begin setting. Aborting.\n", __FILE__);
00965 return -1;
00966 }
00967 (void) fprintf(stdout, "%s: output month_begin = %d\n", __FILE__, data->conf->output_month_begin);
00968 if (val != NULL)
00969 (void) xmlFree(val);
00970
00972 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "title");
00973 val = xml_get_setting(conf, path);
00974 if (val != NULL)
00975 data->info->title = strdup((char *) val);
00976 else {
00977 data->info->title = strdup("Downscaling data from Cerfacs");
00978 }
00979 (void) fprintf(stdout, "%s: output metadata title = %s\n", __FILE__, data->info->title);
00980 if (val != NULL)
00981 (void) xmlFree(val);
00982
00984 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "title_french");
00985 val = xml_get_setting(conf, path);
00986 if (val != NULL)
00987 data->info->title_french = strdup((char *) val);
00988 else {
00989 data->info->title_french = strdup("Donnees de desagregation produites par le Cerfacs");
00990 }
00991 (void) fprintf(stdout, "%s: output metadata title_french = %s\n", __FILE__, data->info->title_french);
00992 if (val != NULL)
00993 (void) xmlFree(val);
00994
00996 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "summary");
00997 val = xml_get_setting(conf, path);
00998 if (val != NULL)
00999 data->info->summary = strdup((char *) val);
01000 else {
01001 data->info->summary = strdup("Downscaling data from Cerfacs");
01002 }
01003 (void) fprintf(stdout, "%s: output metadata summary = %s\n", __FILE__, data->info->summary);
01004 if (val != NULL)
01005 (void) xmlFree(val);
01006
01008 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "summary_french");
01009 val = xml_get_setting(conf, path);
01010 if (val != NULL)
01011 data->info->summary_french = strdup((char *) val);
01012 else {
01013 data->info->summary_french = strdup("Donnees de desagregation produites par le Cerfacs");
01014 }
01015 (void) fprintf(stdout, "%s: output metadata summary_french = %s\n", __FILE__, data->info->summary_french);
01016 if (val != NULL)
01017 (void) xmlFree(val);
01018
01020 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "description");
01021 val = xml_get_setting(conf, path);
01022 if (val != NULL)
01023 data->info->description = strdup((char *) val);
01024 else {
01025 data->info->description = strdup("Downscaling data from Cerfacs");
01026 }
01027 (void) fprintf(stdout, "%s: output metadata description = %s\n", __FILE__, data->info->description);
01028 if (val != NULL)
01029 (void) xmlFree(val);
01030
01032 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "keywords");
01033 val = xml_get_setting(conf, path);
01034 if (val != NULL)
01035 data->info->keywords = strdup((char *) val);
01036 else {
01037 data->info->keywords = strdup("climat,scenarios,desagregation,downscaling,Cerfacs");
01038 }
01039 (void) fprintf(stdout, "%s: output metadata keywords = %s\n", __FILE__, data->info->keywords);
01040 if (val != NULL)
01041 (void) xmlFree(val);
01042
01044 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "processor");
01045 val = xml_get_setting(conf, path);
01046 if (val != NULL)
01047 data->info->processor = strdup((char *) val);
01048 else {
01049 data->info->processor = strdup("C programming language");
01050 }
01051 (void) fprintf(stdout, "%s: output metadata processor = %s\n", __FILE__, data->info->processor);
01052 if (val != NULL)
01053 (void) xmlFree(val);
01054
01055
01056 data->info->software = (char *) malloc(1000 * sizeof(char));
01057 if (data->info->software == NULL) alloc_error(__FILE__, __LINE__);
01058 (void) sprintf(data->info->software, "%s %s", PACKAGE_NAME, PACKAGE_VERSION);
01059
01061 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "institution");
01062 val = xml_get_setting(conf, path);
01063 if (val != NULL)
01064 data->info->institution = strdup((char *) val);
01065 else {
01066 data->info->institution = strdup("Cerfacs");
01067 }
01068 (void) fprintf(stdout, "%s: output metadata institution = %s\n", __FILE__, data->info->institution);
01069 if (val != NULL)
01070 (void) xmlFree(val);
01071
01073 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "creator_email");
01074 val = xml_get_setting(conf, path);
01075 if (val != NULL)
01076 data->info->creator_email = strdup((char *) val);
01077 else {
01078 data->info->creator_email = strdup("globc@cerfacs.fr");
01079 }
01080 (void) fprintf(stdout, "%s: output metadata creator_email = %s\n", __FILE__, data->info->creator_email);
01081 if (val != NULL)
01082 (void) xmlFree(val);
01083
01085 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "creator_url");
01086 val = xml_get_setting(conf, path);
01087 if (val != NULL)
01088 data->info->creator_url = strdup((char *) val);
01089 else {
01090 data->info->creator_url = strdup("http://www.cerfacs.fr/globc/");
01091 }
01092 (void) fprintf(stdout, "%s: output metadata creator_url = %s\n", __FILE__, data->info->creator_url);
01093 if (val != NULL)
01094 (void) xmlFree(val);
01095
01097 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "creator_name");
01098 val = xml_get_setting(conf, path);
01099 if (val != NULL)
01100 data->info->creator_name = strdup((char *) val);
01101 else {
01102 data->info->creator_name = strdup("Global Change Team");
01103 }
01104 (void) fprintf(stdout, "%s: output metadata creator_name = %s\n", __FILE__, data->info->creator_name);
01105 if (val != NULL)
01106 (void) xmlFree(val);
01107
01109 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "version");
01110 val = xml_get_setting(conf, path);
01111 if (val != NULL)
01112 data->info->version = strdup((char *) val);
01113 else {
01114 data->info->version = strdup("1.0");
01115 }
01116 (void) fprintf(stdout, "%s: output metadata version = %s\n", __FILE__, data->info->version);
01117 if (val != NULL)
01118 (void) xmlFree(val);
01119
01121 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "scenario");
01122 val = xml_get_setting(conf, path);
01123 if (val != NULL)
01124 data->info->scenario = strdup((char *) val);
01125 else {
01126 data->info->scenario = strdup("SRESA1B");
01127 }
01128 (void) fprintf(stdout, "%s: output metadata scenario = %s\n", __FILE__, data->info->scenario);
01129 if (val != NULL)
01130 (void) xmlFree(val);
01131
01133 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "scenario_co2");
01134 val = xml_get_setting(conf, path);
01135 if (val != NULL)
01136 data->info->scenario_co2 = strdup((char *) val);
01137 else {
01138 data->info->scenario_co2 = strdup("A1B");
01139 }
01140 (void) fprintf(stdout, "%s: output metadata scenario_co2 = %s\n", __FILE__, data->info->scenario_co2);
01141 if (val != NULL)
01142 (void) xmlFree(val);
01143
01145 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "model");
01146 val = xml_get_setting(conf, path);
01147 if (val != NULL)
01148 data->info->model = strdup((char *) val);
01149 else {
01150 data->info->model = strdup("ARPEGE grille etiree");
01151 }
01152 (void) fprintf(stdout, "%s: output metadata model = %s\n", __FILE__, data->info->model);
01153 if (val != NULL)
01154 (void) xmlFree(val);
01155
01157 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "institution_model");
01158 val = xml_get_setting(conf, path);
01159 if (val != NULL)
01160 data->info->institution_model = strdup((char *) val);
01161 else {
01162 data->info->institution_model = strdup("Meteo-France CNRM/GMGEC");
01163 }
01164 (void) fprintf(stdout, "%s: output metadata institution_model = %s\n", __FILE__, data->info->institution_model);
01165 if (val != NULL)
01166 (void) xmlFree(val);
01167
01169 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "country");
01170 val = xml_get_setting(conf, path);
01171 if (val != NULL)
01172 data->info->country = strdup((char *) val);
01173 else {
01174 data->info->country = strdup("France");
01175 }
01176 (void) fprintf(stdout, "%s: output metadata country = %s\n", __FILE__, data->info->country);
01177 if (val != NULL)
01178 (void) xmlFree(val);
01179
01181 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "member");
01182 val = xml_get_setting(conf, path);
01183 if (val != NULL)
01184 data->info->member = strdup((char *) val);
01185 else {
01186 data->info->member = strdup("1");
01187 }
01188 (void) fprintf(stdout, "%s: output metadata member = %s\n", __FILE__, data->info->member);
01189 if (val != NULL)
01190 (void) xmlFree(val);
01191
01193 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "downscaling_forcing");
01194 val = xml_get_setting(conf, path);
01195 if (val != NULL)
01196 data->info->downscaling_forcing = strdup((char *) val);
01197 else {
01198 data->info->downscaling_forcing = strdup("SAFRAN 1970-2005");
01199 }
01200 (void) fprintf(stdout, "%s: output metadata downscaling_forcing = %s\n", __FILE__, data->info->downscaling_forcing);
01201 if (val != NULL)
01202 (void) xmlFree(val);
01203
01205 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "timestep");
01206 val = xml_get_setting(conf, path);
01207 if (val != NULL)
01208 data->info->timestep = strdup((char *) val);
01209 else {
01210 data->info->timestep = strdup("daily");
01211 }
01212 if ( !strcmp(data->info->timestep, "daily") || !strcmp(data->info->timestep, "hourly"))
01213 (void) fprintf(stdout, "%s: output metadata timestep = %s\n", __FILE__, data->info->timestep);
01214 else {
01215 (void) fprintf(stderr, "%s: Invalid output timestep! Values accepted are either \"hourly\" or \"daily\"! Aborting.\n", __FILE__);
01216 }
01217 if (val != NULL)
01218 (void) xmlFree(val);
01219
01221 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "contact_email");
01222 val = xml_get_setting(conf, path);
01223 if (val != NULL)
01224 data->info->contact_email = strdup((char *) val);
01225 else {
01226 data->info->contact_email = strdup("christian.page@cerfacs.fr");
01227 }
01228 (void) fprintf(stdout, "%s: output metadata contact_email = %s\n", __FILE__, data->info->contact_email);
01229 if (val != NULL)
01230 (void) xmlFree(val);
01231
01233 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "contact_name");
01234 val = xml_get_setting(conf, path);
01235 if (val != NULL)
01236 data->info->contact_name = strdup((char *) val);
01237 else {
01238 data->info->contact_name = strdup("Christian PAGE");
01239 }
01240 (void) fprintf(stdout, "%s: output metadata contact_name = %s\n", __FILE__, data->info->contact_name);
01241 if (val != NULL)
01242 (void) xmlFree(val);
01243
01245 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "other_contact_email");
01246 val = xml_get_setting(conf, path);
01247 if (val != NULL)
01248 data->info->other_contact_email = strdup((char *) val);
01249 else {
01250 data->info->other_contact_email = strdup("laurent.terray@cerfacs.fr");
01251 }
01252 (void) fprintf(stdout, "%s: output metadata other_contact_email = %s\n", __FILE__, data->info->other_contact_email);
01253 if (val != NULL)
01254 (void) xmlFree(val);
01255
01257 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "output", "other_contact_name");
01258 val = xml_get_setting(conf, path);
01259 if (val != NULL)
01260 data->info->other_contact_name = strdup((char *) val);
01261 else {
01262 data->info->other_contact_name = strdup("Laurent TERRAY");
01263 }
01264 (void) fprintf(stdout, "%s: output metadata other_contact_name = %s\n", __FILE__, data->info->other_contact_name);
01265 if (val != NULL)
01266 (void) xmlFree(val);
01267
01268
01269
01270 data->conf->obs_var = (var_struct *) malloc(sizeof(var_struct));
01271 if (data->conf->obs_var == NULL) alloc_error(__FILE__, __LINE__);
01272 data->conf->obs_var->proj = (proj_struct *) malloc(sizeof(proj_struct));
01273 if (data->conf->obs_var->proj == NULL) alloc_error(__FILE__, __LINE__);
01274 data->conf->obs_var->proj->name = NULL;
01275 data->conf->obs_var->proj->grid_mapping_name = NULL;
01276
01278 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "number_of_variables");
01279 val = xml_get_setting(conf, path);
01280 if (val != NULL) {
01281 data->conf->obs_var->nobs_var = (int) xmlXPathCastStringToNumber(val);
01282 (void) xmlFree(val);
01283 (void) fprintf(stdout, "%s: observations: number_of_variables = %d\n", __FILE__, data->conf->obs_var->nobs_var);
01284
01287 data->conf->obs_var->acronym = (char **) malloc(data->conf->obs_var->nobs_var * sizeof(char *));
01288 if (data->conf->obs_var->acronym == NULL) alloc_error(__FILE__, __LINE__);
01289 data->conf->obs_var->netcdfname = (char **) malloc(data->conf->obs_var->nobs_var * sizeof(char *));
01290 if (data->conf->obs_var->netcdfname == NULL) alloc_error(__FILE__, __LINE__);
01291 data->conf->obs_var->name = (char **) malloc(data->conf->obs_var->nobs_var * sizeof(char *));
01292 if (data->conf->obs_var->name == NULL) alloc_error(__FILE__, __LINE__);
01293 data->conf->obs_var->factor = (double *) malloc(data->conf->obs_var->nobs_var * sizeof(double));
01294 if (data->conf->obs_var->factor == NULL) alloc_error(__FILE__, __LINE__);
01295 data->conf->obs_var->delta = (double *) malloc(data->conf->obs_var->nobs_var * sizeof(double));
01296 if (data->conf->obs_var->delta == NULL) alloc_error(__FILE__, __LINE__);
01297 data->conf->obs_var->post = (char **) malloc(data->conf->obs_var->nobs_var * sizeof(char *));
01298 if (data->conf->obs_var->post == NULL) alloc_error(__FILE__, __LINE__);
01299 data->conf->obs_var->clim = (char **) malloc(data->conf->obs_var->nobs_var * sizeof(char *));
01300 if (data->conf->obs_var->clim == NULL) alloc_error(__FILE__, __LINE__);
01301 data->conf->obs_var->output = (char **) malloc(data->conf->obs_var->nobs_var * sizeof(char *));
01302 if (data->conf->obs_var->output == NULL) alloc_error(__FILE__, __LINE__);
01303 data->conf->obs_var->units = (char **) malloc(data->conf->obs_var->nobs_var * sizeof(char *));
01304 if (data->conf->obs_var->units == NULL) alloc_error(__FILE__, __LINE__);
01305 data->conf->obs_var->height = (char **) malloc(data->conf->obs_var->nobs_var * sizeof(char *));
01306 if (data->conf->obs_var->height == NULL) alloc_error(__FILE__, __LINE__);
01307
01308
01309 for (i=0; i<data->conf->obs_var->nobs_var; i++) {
01310
01311 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s[@id=\"%d\"]/@%s", "setting", "observations", "variables", "name", i+1, "acronym");
01312 val = xml_get_setting(conf, path);
01313 if (val != NULL) {
01314 data->conf->obs_var->acronym[i] = strdup((char *) val);
01315 (void) xmlFree(val);
01316 }
01317 else {
01318 (void) fprintf(stderr, "%s: Missing or invalid observation variable acronym setting. Aborting.\n", __FILE__);
01319 return -1;
01320 }
01321
01322 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s[@id=\"%d\"]/@%s", "setting", "observations", "variables", "name", i+1, "netcdfname");
01323 val = xml_get_setting(conf, path);
01324 if (val != NULL) {
01325 data->conf->obs_var->netcdfname[i] = strdup((char *) val);
01326 (void) xmlFree(val);
01327 }
01328 else {
01329 (void) fprintf(stderr, "%s: Missing or invalid observation variable netcdfname setting. Aborting.\n", __FILE__);
01330 return -1;
01331 }
01332
01333 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s[@id=\"%d\"]", "setting", "observations", "variables", "name", i+1);
01334 val = xml_get_setting(conf, path);
01335 if (val != NULL) {
01336 data->conf->obs_var->name[i] = strdup((char *) val);
01337 (void) xmlFree(val);
01338 }
01339 else {
01340 (void) fprintf(stderr, "%s: Missing or invalid observation variable name setting. Aborting.\n", __FILE__);
01341 return -1;
01342 }
01343
01344 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s[@id=\"%d\"]/@%s", "setting", "observations", "variables", "name", i+1, "factor");
01345 val = xml_get_setting(conf, path);
01346 if (val != NULL) {
01347 data->conf->obs_var->factor[i] = (double) xmlXPathCastStringToNumber(val);
01348 (void) xmlFree(val);
01349 }
01350 else {
01351 (void) fprintf(stderr, "%s: Missing or invalid observation variable factor setting. Aborting.\n", __FILE__);
01352 return -1;
01353 }
01354
01355 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s[@id=\"%d\"]/@%s", "setting", "observations", "variables", "name", i+1, "delta");
01356 val = xml_get_setting(conf, path);
01357 if (val != NULL) {
01358 data->conf->obs_var->delta[i] = (double) xmlXPathCastStringToNumber(val);
01359 (void) xmlFree(val);
01360 }
01361 else {
01362 (void) fprintf(stderr, "%s: Missing or invalid observation variable delta setting. Aborting.\n", __FILE__);
01363 return -1;
01364 }
01365
01366 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s[@id=\"%d\"]/@%s", "setting", "observations", "variables", "name", i+1, "postprocess");
01367 val = xml_get_setting(conf, path);
01368 if (val != NULL) {
01369 data->conf->obs_var->post[i] = strdup((char *) val);
01370 (void) xmlFree(val);
01371 }
01372 else {
01373 data->conf->obs_var->post[i] = strdup("no");
01374 }
01375
01376 if ( strcmp(data->conf->obs_var->post[i], "yes") && strcmp(data->conf->obs_var->post[i], "no") ) {
01377 (void) fprintf(stderr, "%s: Invalid observation variable postprocess setting (valid values are \"yes\" or \"no\"). Aborting.\n", __FILE__);
01378 return -1;
01379 }
01380 if (i == 0 && !strcmp(data->conf->obs_var->post[i], "yes")) {
01381 (void) fprintf(stderr, "%s: Invalid observation variable postprocess setting. A variable having a postprocess attribute of \"yes\" must not be the first one in the list. Aborting.\n", __FILE__);
01382 return -1;
01383 }
01384
01385 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s[@id=\"%d\"]/@%s", "setting", "observations", "variables", "name", i+1, "clim");
01386 val = xml_get_setting(conf, path);
01387 if (val != NULL) {
01388 data->conf->obs_var->clim[i] = strdup((char *) val);
01389 (void) xmlFree(val);
01390 }
01391 else {
01392 data->conf->obs_var->clim[i] = strdup("no");
01393 }
01394
01395 if ( strcmp(data->conf->obs_var->clim[i], "yes") && strcmp(data->conf->obs_var->clim[i], "no") ) {
01396 (void) fprintf(stderr, "%s: Invalid observation variable climatology anomaly setting (valid values are \"yes\" or \"no\"). Aborting.\n", __FILE__);
01397 return -1;
01398 }
01399
01400
01401 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s[@id=\"%d\"]/@%s", "setting", "observations", "variables", "name", i+1, "output");
01402 val = xml_get_setting(conf, path);
01403 if (val != NULL) {
01404 data->conf->obs_var->output[i] = strdup((char *) val);
01405 (void) xmlFree(val);
01406 }
01407 else {
01408 data->conf->obs_var->output[i] = strdup("yes");
01409 }
01410
01411 if ( strcmp(data->conf->obs_var->output[i], "yes") && strcmp(data->conf->obs_var->output[i], "no") ) {
01412 (void) fprintf(stderr, "%s: Invalid observation variable output setting (valid values are \"yes\" or \"no\"). Aborting.\n", __FILE__);
01413 return -1;
01414 }
01415
01416
01417 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s[@id=\"%d\"]/@%s", "setting", "observations", "variables", "name", i+1, "units");
01418 val = xml_get_setting(conf, path);
01419 if (val != NULL) {
01420 data->conf->obs_var->units[i] = strdup((char *) val);
01421 (void) xmlFree(val);
01422 }
01423 else {
01424 data->conf->obs_var->units[i] = strdup("unknown");
01425 }
01426 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s[@id=\"%d\"]/@%s", "setting", "observations", "variables", "name", i+1, "height");
01427 val = xml_get_setting(conf, path);
01428 if (val != NULL) {
01429 data->conf->obs_var->height[i] = strdup((char *) val);
01430 (void) xmlFree(val);
01431 }
01432 else {
01433 data->conf->obs_var->height[i] = strdup("unknown");
01434 }
01435
01436 (void) printf("%s: Variable id=%d name=\"%s\" netcdfname=%s acronym=%s factor=%f delta=%f postprocess=%s output=%s\n", __FILE__, i+1, data->conf->obs_var->name[i], data->conf->obs_var->netcdfname[i], data->conf->obs_var->acronym[i], data->conf->obs_var->factor[i], data->conf->obs_var->delta[i], data->conf->obs_var->post[i], data->conf->obs_var->output[i]);
01437 }
01438 }
01439 else {
01440 (void) fprintf(stderr, "%s: Invalid number_of_variables value %s in configuration file. Aborting.\n", __FILE__, val);
01441 return -1;
01442 }
01443
01445 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "frequency");
01446 val = xml_get_setting(conf, path);
01447 if (val != NULL)
01448 data->conf->obs_var->frequency = strdup((char *) val);
01449 else {
01450 (void) fprintf(stderr, "%s: Missing or invalid observations data frequency setting. Aborting.\n", __FILE__);
01451 return -1;
01452 }
01453 if (val != NULL)
01454 (void) xmlFree(val);
01455 if ( strcmp(data->conf->obs_var->frequency, "daily") && strcmp(data->conf->obs_var->frequency, "hourly")) {
01456 (void) fprintf(stderr, "%s: Missing or invalid observations data frequency setting. Aborting.\n", __FILE__);
01457 return -1;
01458 }
01459 if ( !strcmp(data->info->timestep, "hourly") && !strcmp(data->conf->obs_var->frequency, "daily") ) {
01460 (void) fprintf(stderr, "%s: Invalid observations data frequency setting \"daily\" while output timestep is set to \"hourly\"! Aborting.\n", __FILE__);
01461 return -1;
01462 }
01463
01465 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "template");
01466 val = xml_get_setting(conf, path);
01467 if (val != NULL)
01468 data->conf->obs_var->template = strdup((char *) val);
01469 else {
01470 (void) fprintf(stderr, "%s: Missing or invalid output template setting. Aborting.\n", __FILE__);
01471 return -1;
01472 }
01473 (void) fprintf(stdout, "%s: output template = %s\n", __FILE__, data->conf->obs_var->template);
01474 if (val != NULL)
01475 (void) xmlFree(val);
01476
01478 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "year_digits");
01479 val = xml_get_setting(conf, path);
01480 if (val != NULL) {
01481 data->conf->obs_var->year_digits = (int) xmlXPathCastStringToNumber(val);
01482 (void) xmlFree(val);
01483 if (data->conf->obs_var->year_digits != 2 && data->conf->obs_var->year_digits != 4) {
01484 (void) fprintf(stderr, "%s: Invalid observations data year_digits setting %d. Only values of 2 or 4 are valid. Aborting.\n",
01485 __FILE__, data->conf->obs_var->year_digits);
01486 return -1;
01487 }
01488 }
01489 else {
01490 (void) fprintf(stderr, "%s: Missing or invalid observations data year_digits setting. Aborting.\n", __FILE__);
01491 return -1;
01492 }
01493
01495 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "path");
01496 val = xml_get_setting(conf, path);
01497 if (val != NULL)
01498 data->conf->obs_var->path = strdup((char *) val);
01499 else {
01500 (void) fprintf(stderr, "%s: Missing or invalid observations data path setting. Aborting.\n", __FILE__);
01501 return -1;
01502 }
01503 if (val != NULL)
01504 (void) xmlFree(val);
01505
01507 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "month_begin");
01508 val = xml_get_setting(conf, path);
01509 if (val != NULL)
01510 data->conf->obs_var->month_begin = xmlXPathCastStringToNumber(val);
01511 else {
01512 (void) fprintf(stderr, "%s: Missing or invalid observations data month_begin setting. Aborting.\n", __FILE__);
01513 return -1;
01514 }
01515 if (val != NULL)
01516 (void) xmlFree(val);
01517
01519 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "dim_coordinates");
01520 val = xml_get_setting(conf, path);
01521 if (val != NULL)
01522 data->conf->obs_var->dimcoords = strdup((char *) val);
01523 else
01524 data->conf->obs_var->dimcoords = strdup("1D");
01525 (void) fprintf(stdout, "%s: Observations coords = %s\n", __FILE__, data->conf->obs_var->dimcoords);
01526 if (val != NULL)
01527 (void) xmlFree(val);
01528
01530 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "longitude_name");
01531 val = xml_get_setting(conf, path);
01532 if (val != NULL)
01533 data->conf->obs_var->lonname = strdup((char *) val);
01534 else
01535 data->conf->obs_var->lonname = strdup("lon");
01536 (void) fprintf(stdout, "%s: Observations longitude_name = %s\n", __FILE__, data->conf->obs_var->lonname);
01537 if (val != NULL)
01538 (void) xmlFree(val);
01539
01541 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "latitude_name");
01542 val = xml_get_setting(conf, path);
01543 if (val != NULL)
01544 data->conf->obs_var->latname = strdup((char *) val);
01545 else
01546 data->conf->obs_var->latname = strdup("lat");
01547 (void) fprintf(stdout, "%s: Observations latitude_name = %s\n", __FILE__, data->conf->obs_var->latname);
01548 if (val != NULL)
01549 (void) xmlFree(val);
01550
01552 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "dimx_name");
01553 val = xml_get_setting(conf, path);
01554 if (val != NULL)
01555 data->conf->obs_var->dimxname = strdup((char *) val);
01556 else
01557 data->conf->obs_var->dimxname = strdup("lon");
01558 (void) fprintf(stdout, "%s: Observations dimx_name = %s\n", __FILE__, data->conf->obs_var->dimxname);
01559 if (val != NULL)
01560 (void) xmlFree(val);
01561
01563 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "dimy_name");
01564 val = xml_get_setting(conf, path);
01565 if (val != NULL)
01566 data->conf->obs_var->dimyname = strdup((char *) val);
01567 else
01568 data->conf->obs_var->dimyname = strdup("lat");
01569 (void) fprintf(stdout, "%s: Observations dimy_name = %s\n", __FILE__, data->conf->obs_var->dimyname);
01570 if (val != NULL)
01571 (void) xmlFree(val);
01572
01574 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "time_name");
01575 val = xml_get_setting(conf, path);
01576 if (val != NULL)
01577 data->conf->obs_var->timename = strdup((char *) val);
01578 else
01579 data->conf->obs_var->timename = strdup("time");
01580 (void) fprintf(stdout, "%s: Observations time_name = %s\n", __FILE__, data->conf->obs_var->timename);
01581 if (val != NULL)
01582 (void) xmlFree(val);
01583
01585 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "coordinates");
01586 val = xml_get_setting(conf, path);
01587 if (val != NULL)
01588 data->conf->obs_var->proj->coords = strdup((char *) val);
01589 else
01590 data->conf->obs_var->proj->coords = strdup("2D");
01591 (void) fprintf(stdout, "%s: Observations coords = %s\n", __FILE__, data->conf->obs_var->proj->coords);
01592 if (val != NULL)
01593 (void) xmlFree(val);
01594
01596 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "altitude");
01597 val = xml_get_setting(conf, path);
01598 if (val != NULL)
01599 data->conf->obs_var->altitude = strdup((char *) val);
01600 else {
01601 (void) fprintf(stderr, "%s: Missing observations altitude filename. Will not be able to calculate Relative Humidity if specified.\n", __FILE__);
01602 data->conf->obs_var->altitude = strdup("");
01603 }
01604 if (val != NULL)
01605 (void) xmlFree(val);
01606
01608 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "observations", "altitude_name");
01609 val = xml_get_setting(conf, path);
01610 if (val != NULL)
01611 data->conf->obs_var->altitudename = strdup((char *) val);
01612 else
01613 data->conf->obs_var->altitudename = strdup("Altitude");
01614 (void) fprintf(stdout, "%s: Observations altitude_name = %s\n", __FILE__, data->conf->obs_var->altitudename);
01615 if (val != NULL)
01616 (void) xmlFree(val);
01617
01618
01619
01620
01621 data->learning->time_s = (time_vect_struct *) malloc(sizeof(time_vect_struct));
01622 if (data->learning->time_s == NULL) alloc_error(__FILE__, __LINE__);
01623
01625 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "learning_provided");
01626 val = xml_get_setting(conf, path);
01627 if (val != NULL)
01628 data->learning->learning_provided = (int) strtol((char *) val, (char **)NULL, 10);
01629 else
01630 data->learning->learning_provided = -1;
01631 if (data->learning->learning_provided != FALSE && data->learning->learning_provided != TRUE) {
01632 (void) fprintf(stderr, "%s: Invalid or missing learning_provided value %s in configuration file. Aborting.\n", __FILE__, val);
01633 return -1;
01634 }
01635 (void) fprintf(stdout, "%s: learning_provided=%d\n", __FILE__, data->learning->learning_provided);
01636 if (val != NULL)
01637 (void) xmlFree(val);
01638
01640 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "learning_save");
01641 val = xml_get_setting(conf, path);
01642 if (val != NULL)
01643 data->learning->learning_save = (int) strtol((char *) val, (char **)NULL, 10);
01644 else
01645 data->learning->learning_save = FALSE;
01646 if (data->learning->learning_save != FALSE && data->learning->learning_save != TRUE) {
01647 (void) fprintf(stderr, "%s: Invalid learning_save value %s in configuration file. Aborting.\n", __FILE__, val);
01648 return -1;
01649 }
01650 (void) fprintf(stdout, "%s: learning_save=%d\n", __FILE__, data->learning->learning_save);
01651 if (val != NULL)
01652 (void) xmlFree(val);
01653
01655 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "number_of_eofs");
01656 val = xml_get_setting(conf, path);
01657 if (val != NULL) {
01658 data->learning->rea_neof = xmlXPathCastStringToNumber(val);
01659 data->learning->obs_neof = xmlXPathCastStringToNumber(val);
01660 (void) fprintf(stdout, "%s: Number of EOF for learning period for reanalysis data = %d\n", __FILE__, data->learning->rea_neof);
01661 (void) fprintf(stdout, "%s: Number of EOF for learning period for observation data = %d\n", __FILE__, data->learning->obs_neof);
01662 (void) xmlFree(val);
01663 }
01664 else {
01666 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "number_of_obs_eofs");
01667 val = xml_get_setting(conf, path);
01668 if (val != NULL)
01669 data->learning->obs_neof = xmlXPathCastStringToNumber(val);
01670 else
01671 data->learning->obs_neof = 10;
01672 (void) fprintf(stdout, "%s: Number of EOF for learning period for observation data = %d\n", __FILE__, data->learning->obs_neof);
01673 if (val != NULL)
01674 (void) xmlFree(val);
01675
01677 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "number_of_rea_eofs");
01678 val = xml_get_setting(conf, path);
01679 if (val != NULL)
01680 data->learning->rea_neof = xmlXPathCastStringToNumber(val);
01681 else
01682 data->learning->rea_neof = 10;
01683 (void) fprintf(stdout, "%s: Number of EOF for learning period for reanalysis data = %d\n", __FILE__, data->learning->rea_neof);
01684 if (val != NULL)
01685 (void) xmlFree(val);
01686 }
01687
01688
01689 if (data->learning->learning_save == TRUE) {
01690
01692 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "filename_save_weight");
01693 val = xml_get_setting(conf, path);
01694 if (val != NULL) {
01695 data->learning->filename_save_weight = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01696 if (data->learning->filename_save_weight == NULL) alloc_error(__FILE__, __LINE__);
01697 (void) strcpy(data->learning->filename_save_weight, (char *) val);
01698 (void) fprintf(stdout, "%s: Learning filename_save_weight = %s\n", __FILE__, data->learning->filename_save_weight);
01699 (void) xmlFree(val);
01700 }
01701 else {
01702 (void) fprintf(stderr, "%s: Missing learning filename_save_weight setting. Aborting.\n", __FILE__);
01703 (void) xmlFree(val);
01704 return -1;
01705 }
01706
01708 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "filename_save_learn");
01709 val = xml_get_setting(conf, path);
01710 if (val != NULL) {
01711 data->learning->filename_save_learn = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01712 if (data->learning->filename_save_learn == NULL) alloc_error(__FILE__, __LINE__);
01713 (void) strcpy(data->learning->filename_save_learn, (char *) val);
01714 (void) fprintf(stdout, "%s: Learning filename_save_learn = %s\n", __FILE__, data->learning->filename_save_learn);
01715 (void) xmlFree(val);
01716 }
01717 else {
01718 (void) fprintf(stderr, "%s: Missing learning filename_save_learn setting. Aborting.\n", __FILE__);
01719 (void) xmlFree(val);
01720 return -1;
01721 }
01722
01724 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "filename_save_clust_learn");
01725 val = xml_get_setting(conf, path);
01726 if (val != NULL) {
01727 data->learning->filename_save_clust_learn = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01728 if (data->learning->filename_save_clust_learn == NULL) alloc_error(__FILE__, __LINE__);
01729 (void) strcpy(data->learning->filename_save_clust_learn, (char *) val);
01730 (void) fprintf(stdout, "%s: Learning filename_save_clust_learn = %s\n", __FILE__, data->learning->filename_save_clust_learn);
01731 (void) xmlFree(val);
01732 }
01733 else {
01734 (void) fprintf(stderr, "%s: Missing learning filename_save_clust_learn setting. Aborting.\n", __FILE__);
01735 (void) xmlFree(val);
01736 return -1;
01737 }
01738 }
01739
01740
01741 if (data->learning->learning_provided == TRUE) {
01742
01744 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "filename_open_weight");
01745 val = xml_get_setting(conf, path);
01746 if (val != NULL) {
01747 data->learning->filename_open_weight = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01748 if (data->learning->filename_open_weight == NULL) alloc_error(__FILE__, __LINE__);
01749 (void) strcpy(data->learning->filename_open_weight, (char *) val);
01750 (void) fprintf(stdout, "%s: Learning filename_open_weight = %s\n", __FILE__, data->learning->filename_open_weight);
01751 (void) xmlFree(val);
01752 }
01753 else {
01754 (void) fprintf(stderr, "%s: Missing learning filename_open_weight setting. Aborting.\n", __FILE__);
01755 (void) xmlFree(val);
01756 return -1;
01757 }
01758
01760 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "filename_open_learn");
01761 val = xml_get_setting(conf, path);
01762 if (val != NULL) {
01763 data->learning->filename_open_learn = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01764 if (data->learning->filename_open_learn == NULL) alloc_error(__FILE__, __LINE__);
01765 (void) strcpy(data->learning->filename_open_learn, (char *) val);
01766 (void) fprintf(stdout, "%s: Learning filename_open_learn = %s\n", __FILE__, data->learning->filename_open_learn);
01767 (void) xmlFree(val);
01768 }
01769 else {
01770 (void) fprintf(stderr, "%s: Missing learning filename_open_learn setting. Aborting.\n", __FILE__);
01771 (void) xmlFree(val);
01772 return -1;
01773 }
01774
01776 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "filename_open_clust_learn");
01777 val = xml_get_setting(conf, path);
01778 if (val != NULL) {
01779 data->learning->filename_open_clust_learn = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01780 if (data->learning->filename_open_clust_learn == NULL) alloc_error(__FILE__, __LINE__);
01781 (void) strcpy(data->learning->filename_open_clust_learn, (char *) val);
01782 (void) fprintf(stdout, "%s: Learning filename_open_clust_learn = %s\n", __FILE__, data->learning->filename_open_clust_learn);
01783 (void) xmlFree(val);
01784 }
01785 else {
01786 (void) fprintf(stderr, "%s: Missing learning filename_open_clust_learn setting. Aborting.\n", __FILE__);
01787 (void) xmlFree(val);
01788 return -1;
01789 }
01790 }
01791 else {
01792
01793 data->learning->obs = (learning_eof_struct *) malloc(sizeof(learning_eof_struct));
01794 if (data->learning->obs == NULL) alloc_error(__FILE__, __LINE__);
01795 data->learning->rea = (learning_eof_struct *) malloc(sizeof(learning_eof_struct));
01796 if (data->learning->rea == NULL) alloc_error(__FILE__, __LINE__);
01797
01798 data->learning->obs->time_s = (time_vect_struct *) malloc(sizeof(time_vect_struct));
01799 if (data->learning->obs->time_s == NULL) alloc_error(__FILE__, __LINE__);
01800 data->learning->rea->time_s = (time_vect_struct *) malloc(sizeof(time_vect_struct));
01801 if (data->learning->rea->time_s == NULL) alloc_error(__FILE__, __LINE__);
01802
01804 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "filename_obs_eof");
01805 val = xml_get_setting(conf, path);
01806 if (val != NULL) {
01807 data->learning->obs->filename_eof = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01808 if (data->learning->obs->filename_eof == NULL) alloc_error(__FILE__, __LINE__);
01809 (void) strcpy(data->learning->obs->filename_eof, (char *) val);
01810 (void) fprintf(stdout, "%s: Learning filename_obs_eof = %s\n", __FILE__, data->learning->obs->filename_eof);
01811 (void) xmlFree(val);
01812 }
01813 else {
01814 (void) fprintf(stderr, "%s: Missing learning filename_obs_eof setting. Aborting.\n", __FILE__);
01815 (void) xmlFree(val);
01816 return -1;
01817 }
01818
01820 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "filename_rea_eof");
01821 val = xml_get_setting(conf, path);
01822 if (val != NULL) {
01823 data->learning->rea->filename_eof = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01824 if (data->learning->rea->filename_eof == NULL) alloc_error(__FILE__, __LINE__);
01825 (void) strcpy(data->learning->rea->filename_eof, (char *) val);
01826 (void) fprintf(stdout, "%s: Learning filename_rea_eof = %s\n", __FILE__, data->learning->rea->filename_eof);
01827 (void) xmlFree(val);
01828 }
01829 else {
01830 (void) fprintf(stderr, "%s: Missing learning filename_rea_eof setting. Aborting.\n", __FILE__);
01831 (void) xmlFree(val);
01832 return -1;
01833 }
01834
01836 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "filename_rea_sup");
01837 val = xml_get_setting(conf, path);
01838 if (val != NULL) {
01839 data->learning->filename_rea_sup = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01840 if (data->learning->filename_rea_sup == NULL) alloc_error(__FILE__, __LINE__);
01841 (void) strcpy(data->learning->filename_rea_sup, (char *) val);
01842 (void) fprintf(stdout, "%s: Learning filename_rea_sup = %s\n", __FILE__, data->learning->filename_rea_sup);
01843 (void) xmlFree(val);
01844 }
01845 else {
01846 (void) fprintf(stderr, "%s: Missing learning filename_rea_sup setting. Aborting.\n", __FILE__);
01847 (void) xmlFree(val);
01848 return -1;
01849 }
01850
01852 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_obs_eof");
01853 val = xml_get_setting(conf, path);
01854 if (val != NULL) {
01855 data->learning->obs->nomvar_eof = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01856 if (data->learning->obs->nomvar_eof == NULL) alloc_error(__FILE__, __LINE__);
01857 (void) strcpy(data->learning->obs->nomvar_eof, (char *) val);
01858 (void) xmlFree(val);
01859 }
01860 else {
01861 data->learning->obs->nomvar_eof = strdup("pre_pc");
01862 }
01863 (void) fprintf(stdout, "%s: Learning nomvar_eof = %s\n", __FILE__, data->learning->obs->nomvar_eof);
01864
01866 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_rea_eof");
01867 val = xml_get_setting(conf, path);
01868 if (val != NULL) {
01869 data->learning->rea->nomvar_eof = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01870 if (data->learning->rea->nomvar_eof == NULL) alloc_error(__FILE__, __LINE__);
01871 (void) strcpy(data->learning->rea->nomvar_eof, (char *) val);
01872 (void) xmlFree(val);
01873 }
01874 else {
01875 data->learning->rea->nomvar_eof = strdup("psl_pc");
01876 }
01877 (void) fprintf(stdout, "%s: Learning nomvar_eof = %s\n", __FILE__, data->learning->obs->nomvar_eof);
01878
01880 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_obs_sing");
01881 val = xml_get_setting(conf, path);
01882 if (val != NULL) {
01883 data->learning->obs->nomvar_sing = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01884 if (data->learning->obs->nomvar_sing == NULL) alloc_error(__FILE__, __LINE__);
01885 (void) strcpy(data->learning->obs->nomvar_sing, (char *) val);
01886 (void) xmlFree(val);
01887 }
01888 else
01889 data->learning->obs->nomvar_sing = strdup("pre_sing");
01890 (void) fprintf(stdout, "%s: Learning nomvar_obs_sing = %s\n", __FILE__, data->learning->obs->nomvar_sing);
01891
01893 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_rea_sing");
01894 val = xml_get_setting(conf, path);
01895 if (val != NULL) {
01896 data->learning->rea->nomvar_sing = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01897 if (data->learning->rea->nomvar_sing == NULL) alloc_error(__FILE__, __LINE__);
01898 (void) strcpy(data->learning->rea->nomvar_sing, (char *) val);
01899 (void) xmlFree(val);
01900 }
01901 else
01902 data->learning->rea->nomvar_sing = strdup("pre_sing");
01903 (void) fprintf(stdout, "%s: Learning nomvar_rea_sing = %s\n", __FILE__, data->learning->rea->nomvar_sing);
01904
01906 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_rea_sup");
01907 val = xml_get_setting(conf, path);
01908 if (val != NULL) {
01909 data->learning->nomvar_rea_sup = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01910 if (data->learning->nomvar_rea_sup == NULL) alloc_error(__FILE__, __LINE__);
01911 (void) strcpy(data->learning->nomvar_rea_sup, (char *) val);
01912 (void) xmlFree(val);
01913 }
01914 else {
01915 data->learning->nomvar_rea_sup = strdup("tas");
01916 }
01917 (void) fprintf(stdout, "%s: Learning nomvar_sup = %s\n", __FILE__, data->learning->nomvar_rea_sup);
01918
01920 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "rea_coords");
01921 val = xml_get_setting(conf, path);
01922 if (val != NULL) {
01923 data->learning->rea_coords = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01924 if (data->learning->rea_coords == NULL) alloc_error(__FILE__, __LINE__);
01925 (void) strcpy(data->learning->rea_coords, (char *) val);
01926 (void) xmlFree(val);
01927 }
01928 else {
01929 data->learning->rea_coords = strdup("1D");
01930 }
01931 (void) fprintf(stdout, "%s: Learning rea_coords = %s\n", __FILE__, data->learning->rea_coords);
01932
01934 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "rea_gridname");
01935 val = xml_get_setting(conf, path);
01936 if (val != NULL) {
01937 data->learning->rea_gridname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01938 if (data->learning->rea_gridname == NULL) alloc_error(__FILE__, __LINE__);
01939 (void) strcpy(data->learning->rea_gridname, (char *) val);
01940 (void) xmlFree(val);
01941 }
01942 else {
01943 data->learning->rea_gridname = strdup("Latitude_Longitude");
01944 }
01945 (void) fprintf(stdout, "%s: Learning rea_gridname = %s\n", __FILE__, data->learning->rea_gridname);
01946
01948 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "rea_dimx_name");
01949 val = xml_get_setting(conf, path);
01950 if (val != NULL) {
01951 data->learning->rea_dimxname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01952 if (data->learning->rea_dimxname == NULL) alloc_error(__FILE__, __LINE__);
01953 (void) strcpy(data->learning->rea_dimxname, (char *) val);
01954 (void) xmlFree(val);
01955 }
01956 else {
01957 data->learning->rea_dimxname = strdup("lon");
01958 }
01959 (void) fprintf(stdout, "%s: Learning rea_dimx_name = %s\n", __FILE__, data->learning->rea_dimxname);
01960
01962 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "rea_dimy_name");
01963 val = xml_get_setting(conf, path);
01964 if (val != NULL) {
01965 data->learning->rea_dimyname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01966 if (data->learning->rea_dimyname == NULL) alloc_error(__FILE__, __LINE__);
01967 (void) strcpy(data->learning->rea_dimyname, (char *) val);
01968 (void) xmlFree(val);
01969 }
01970 else {
01971 data->learning->rea_dimyname = strdup("lat");
01972 }
01973 (void) fprintf(stdout, "%s: Learning rea_latitude_name = %s\n", __FILE__, data->learning->rea_dimyname);
01974
01976 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "rea_longitude_name");
01977 val = xml_get_setting(conf, path);
01978 if (val != NULL) {
01979 data->learning->rea_lonname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01980 if (data->learning->rea_lonname == NULL) alloc_error(__FILE__, __LINE__);
01981 (void) strcpy(data->learning->rea_lonname, (char *) val);
01982 (void) xmlFree(val);
01983 }
01984 else {
01985 data->learning->rea_lonname = strdup("lon");
01986 }
01987 (void) fprintf(stdout, "%s: Learning rea_longitude_name = %s\n", __FILE__, data->learning->rea_lonname);
01988
01990 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "rea_latitude_name");
01991 val = xml_get_setting(conf, path);
01992 if (val != NULL) {
01993 data->learning->rea_latname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
01994 if (data->learning->rea_latname == NULL) alloc_error(__FILE__, __LINE__);
01995 (void) strcpy(data->learning->rea_latname, (char *) val);
01996 (void) xmlFree(val);
01997 }
01998 else {
01999 data->learning->rea_latname = strdup("lat");
02000 }
02001 (void) fprintf(stdout, "%s: Learning rea_latitude_name = %s\n", __FILE__, data->learning->rea_latname);
02002
02004 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "rea_time_name");
02005 val = xml_get_setting(conf, path);
02006 if (val != NULL) {
02007 data->learning->rea_timename = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02008 if (data->learning->rea_timename == NULL) alloc_error(__FILE__, __LINE__);
02009 (void) strcpy(data->learning->rea_timename, (char *) val);
02010 (void) xmlFree(val);
02011 }
02012 else {
02013 data->learning->rea_timename = strdup("time");
02014 }
02015 (void) fprintf(stdout, "%s: Learning rea_time_name = %s\n", __FILE__, data->learning->rea_timename);
02016
02018 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "obs_dimx_name");
02019 val = xml_get_setting(conf, path);
02020 if (val != NULL) {
02021 data->learning->obs_dimxname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02022 if (data->learning->obs_dimxname == NULL) alloc_error(__FILE__, __LINE__);
02023 (void) strcpy(data->learning->obs_dimxname, (char *) val);
02024 (void) xmlFree(val);
02025 }
02026 else {
02027 data->learning->obs_dimxname = strdup("lon");
02028 }
02029 (void) fprintf(stdout, "%s: Learning obs_dimx_name = %s\n", __FILE__, data->learning->obs_dimxname);
02030
02032 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "obs_dimy_name");
02033 val = xml_get_setting(conf, path);
02034 if (val != NULL) {
02035 data->learning->obs_dimyname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02036 if (data->learning->obs_dimyname == NULL) alloc_error(__FILE__, __LINE__);
02037 (void) strcpy(data->learning->obs_dimyname, (char *) val);
02038 (void) xmlFree(val);
02039 }
02040 else {
02041 data->learning->obs_dimyname = strdup("lat");
02042 }
02043 (void) fprintf(stdout, "%s: Learning obs_dimy_name = %s\n", __FILE__, data->learning->obs_dimyname);
02044
02046 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "obs_longitude_name");
02047 val = xml_get_setting(conf, path);
02048 if (val != NULL) {
02049 data->learning->obs_lonname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02050 if (data->learning->obs_lonname == NULL) alloc_error(__FILE__, __LINE__);
02051 (void) strcpy(data->learning->obs_lonname, (char *) val);
02052 (void) xmlFree(val);
02053 }
02054 else {
02055 data->learning->obs_lonname = strdup("lon");
02056 }
02057 (void) fprintf(stdout, "%s: Learning obs_longitude_name = %s\n", __FILE__, data->learning->obs_lonname);
02058
02060 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "obs_latitude_name");
02061 val = xml_get_setting(conf, path);
02062 if (val != NULL) {
02063 data->learning->obs_latname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02064 if (data->learning->obs_latname == NULL) alloc_error(__FILE__, __LINE__);
02065 (void) strcpy(data->learning->obs_latname, (char *) val);
02066 (void) xmlFree(val);
02067 }
02068 else {
02069 data->learning->obs_latname = strdup("lat");
02070 }
02071 (void) fprintf(stdout, "%s: Learning obs_latitude_name = %s\n", __FILE__, data->learning->obs_latname);
02072
02074 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "obs_time_name");
02075 val = xml_get_setting(conf, path);
02076 if (val != NULL) {
02077 data->learning->obs_timename = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02078 if (data->learning->obs_timename == NULL) alloc_error(__FILE__, __LINE__);
02079 (void) strcpy(data->learning->obs_timename, (char *) val);
02080 (void) xmlFree(val);
02081 }
02082 else {
02083 data->learning->obs_timename = strdup("time");
02084 }
02085 (void) fprintf(stdout, "%s: Learning obs_time_name = %s\n", __FILE__, data->learning->obs_timename);
02086
02088 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "obs_eof_name");
02089 val = xml_get_setting(conf, path);
02090 if (val != NULL) {
02091 data->learning->obs_eofname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02092 if (data->learning->obs_eofname == NULL) alloc_error(__FILE__, __LINE__);
02093 (void) strcpy(data->learning->obs_eofname, (char *) val);
02094 (void) xmlFree(val);
02095 }
02096 else {
02097 data->learning->obs_eofname = strdup("eof");
02098 }
02099 (void) fprintf(stdout, "%s: Learning obs_eof_name = %s\n", __FILE__, data->learning->obs_eofname);
02100 }
02101
02103 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "sup_lonname");
02104 val = xml_get_setting(conf, path);
02105 if (val != NULL) {
02106 data->learning->sup_lonname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02107 if (data->learning->sup_lonname == NULL) alloc_error(__FILE__, __LINE__);
02108 (void) strcpy(data->learning->sup_lonname, (char *) val);
02109 (void) xmlFree(val);
02110 }
02111 else
02112 data->learning->sup_lonname = strdup("lon");
02113 (void) fprintf(stdout, "%s: Learning sup_lonname = %s\n", __FILE__, data->learning->sup_lonname);
02114
02116 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "sup_latname");
02117 val = xml_get_setting(conf, path);
02118 if (val != NULL) {
02119 data->learning->sup_latname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02120 if (data->learning->sup_latname == NULL) alloc_error(__FILE__, __LINE__);
02121 (void) strcpy(data->learning->sup_latname, (char *) val);
02122 (void) xmlFree(val);
02123 }
02124 else
02125 data->learning->sup_latname = strdup("lat");
02126 (void) fprintf(stdout, "%s: Learning sup_latname = %s\n", __FILE__, data->learning->sup_latname);
02127
02129 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_time");
02130 val = xml_get_setting(conf, path);
02131 if (val != NULL) {
02132 data->learning->nomvar_time = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02133 if (data->learning->nomvar_time == NULL) alloc_error(__FILE__, __LINE__);
02134 (void) strcpy(data->learning->nomvar_time, (char *) val);
02135 (void) xmlFree(val);
02136 }
02137 else
02138 data->learning->nomvar_time = strdup("time");
02139 (void) fprintf(stdout, "%s: Learning nomvar_time = %s\n", __FILE__, data->learning->nomvar_time);
02140
02142 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_weight");
02143 val = xml_get_setting(conf, path);
02144 if (val != NULL) {
02145 data->learning->nomvar_weight = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02146 if (data->learning->nomvar_weight == NULL) alloc_error(__FILE__, __LINE__);
02147 (void) strcpy(data->learning->nomvar_weight, (char *) val);
02148 (void) xmlFree(val);
02149 }
02150 else
02151 data->learning->nomvar_weight = strdup("poid");
02152 (void) fprintf(stdout, "%s: Learning nomvar_weight = %s\n", __FILE__, data->learning->nomvar_weight);
02153
02155 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_class_clusters");
02156 val = xml_get_setting(conf, path);
02157 if (val != NULL) {
02158 data->learning->nomvar_class_clusters = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02159 if (data->learning->nomvar_class_clusters == NULL) alloc_error(__FILE__, __LINE__);
02160 (void) strcpy(data->learning->nomvar_class_clusters, (char *) val);
02161 (void) xmlFree(val);
02162 }
02163 else
02164 data->learning->nomvar_class_clusters = strdup("clust_learn");
02165 (void) fprintf(stdout, "%s: Learning nomvar_class_clusters = %s\n", __FILE__, data->learning->nomvar_class_clusters);
02166
02168 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_precip_reg");
02169 val = xml_get_setting(conf, path);
02170 if (val != NULL) {
02171 data->learning->nomvar_precip_reg = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02172 if (data->learning->nomvar_precip_reg == NULL) alloc_error(__FILE__, __LINE__);
02173 (void) strcpy(data->learning->nomvar_precip_reg, (char *) val);
02174 (void) xmlFree(val);
02175 }
02176 else
02177 data->learning->nomvar_precip_reg = strdup("reg");
02178 (void) fprintf(stdout, "%s: Learning nomvar_precip_reg = %s\n", __FILE__, data->learning->nomvar_precip_reg);
02179
02181 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_precip_reg_cst");
02182 val = xml_get_setting(conf, path);
02183 if (val != NULL) {
02184 data->learning->nomvar_precip_reg_cst = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02185 if (data->learning->nomvar_precip_reg_cst == NULL) alloc_error(__FILE__, __LINE__);
02186 (void) strcpy(data->learning->nomvar_precip_reg_cst, (char *) val);
02187 (void) xmlFree(val);
02188 }
02189 else
02190 data->learning->nomvar_precip_reg_cst = strdup("cst");
02191 (void) fprintf(stdout, "%s: Learning nomvar_precip_reg_cst = %s\n", __FILE__, data->learning->nomvar_precip_reg_cst);
02192
02194 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_precip_reg_rsq");
02195 val = xml_get_setting(conf, path);
02196 if (val != NULL) {
02197 data->learning->nomvar_precip_reg_rsq = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02198 if (data->learning->nomvar_precip_reg_rsq == NULL) alloc_error(__FILE__, __LINE__);
02199 (void) strcpy(data->learning->nomvar_precip_reg_rsq, (char *) val);
02200 (void) xmlFree(val);
02201 }
02202 else
02203 data->learning->nomvar_precip_reg_rsq = strdup("rsquare");
02204 (void) fprintf(stdout, "%s: Learning nomvar_precip_reg_rsq = %s\n", __FILE__, data->learning->nomvar_precip_reg_rsq);
02205
02207 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_precip_reg_acor");
02208 val = xml_get_setting(conf, path);
02209 if (val != NULL) {
02210 data->learning->nomvar_precip_reg_acor = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02211 if (data->learning->nomvar_precip_reg_acor == NULL) alloc_error(__FILE__, __LINE__);
02212 (void) strcpy(data->learning->nomvar_precip_reg_acor, (char *) val);
02213 (void) xmlFree(val);
02214 }
02215 else
02216 data->learning->nomvar_precip_reg_acor = strdup("autocor");
02217 (void) fprintf(stdout, "%s: Learning nomvar_precip_reg_acor = %s\n", __FILE__, data->learning->nomvar_precip_reg_acor);
02218
02220 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_precip_reg_vif");
02221 val = xml_get_setting(conf, path);
02222 if (val != NULL) {
02223 data->learning->nomvar_precip_reg_vif = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02224 if (data->learning->nomvar_precip_reg_vif == NULL) alloc_error(__FILE__, __LINE__);
02225 (void) strcpy(data->learning->nomvar_precip_reg_vif, (char *) val);
02226 (void) xmlFree(val);
02227 }
02228 else
02229 data->learning->nomvar_precip_reg_vif = strdup("vif");
02230 (void) fprintf(stdout, "%s: Learning nomvar_precip_reg_vif = %s\n", __FILE__, data->learning->nomvar_precip_reg_vif);
02231
02233 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_precip_reg_dist");
02234 val = xml_get_setting(conf, path);
02235 if (val != NULL) {
02236 data->learning->nomvar_precip_reg_dist = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02237 if (data->learning->nomvar_precip_reg_dist == NULL) alloc_error(__FILE__, __LINE__);
02238 (void) strcpy(data->learning->nomvar_precip_reg_dist, (char *) val);
02239 (void) xmlFree(val);
02240 }
02241 else
02242 data->learning->nomvar_precip_reg_dist = strdup("dist");
02243 (void) fprintf(stdout, "%s: Learning nomvar_precip_reg_dist = %s\n", __FILE__, data->learning->nomvar_precip_reg_dist);
02244
02246 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_precip_reg_err");
02247 val = xml_get_setting(conf, path);
02248 if (val != NULL) {
02249 data->learning->nomvar_precip_reg_err = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02250 if (data->learning->nomvar_precip_reg_err == NULL) alloc_error(__FILE__, __LINE__);
02251 (void) strcpy(data->learning->nomvar_precip_reg_err, (char *) val);
02252 (void) xmlFree(val);
02253 }
02254 else
02255 data->learning->nomvar_precip_reg_err = strdup("err");
02256 (void) fprintf(stdout, "%s: Learning nomvar_precip_reg_err = %s\n", __FILE__, data->learning->nomvar_precip_reg_err);
02257
02259 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_precip_index");
02260 val = xml_get_setting(conf, path);
02261 if (val != NULL) {
02262 data->learning->nomvar_precip_index = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02263 if (data->learning->nomvar_precip_index == NULL) alloc_error(__FILE__, __LINE__);
02264 (void) strcpy(data->learning->nomvar_precip_index, (char *) val);
02265 (void) xmlFree(val);
02266 }
02267 else
02268 data->learning->nomvar_precip_index = strdup("rrd");
02269 (void) fprintf(stdout, "%s: Learning nomvar_precip_index = %s\n", __FILE__, data->learning->nomvar_precip_index);
02270
02272 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_precip_index_obs");
02273 val = xml_get_setting(conf, path);
02274 if (val != NULL) {
02275 data->learning->nomvar_precip_index_obs = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02276 if (data->learning->nomvar_precip_index_obs == NULL) alloc_error(__FILE__, __LINE__);
02277 (void) strcpy(data->learning->nomvar_precip_index_obs, (char *) val);
02278 (void) xmlFree(val);
02279 }
02280 else
02281 data->learning->nomvar_precip_index_obs = strdup("rro");
02282 (void) fprintf(stdout, "%s: Learning nomvar_precip_index_obs = %s\n", __FILE__, data->learning->nomvar_precip_index_obs);
02283
02285 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_sup_index");
02286 val = xml_get_setting(conf, path);
02287 if (val != NULL) {
02288 data->learning->nomvar_sup_index = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02289 if (data->learning->nomvar_sup_index == NULL) alloc_error(__FILE__, __LINE__);
02290 (void) strcpy(data->learning->nomvar_sup_index, (char *) val);
02291 (void) xmlFree(val);
02292 }
02293 else
02294 data->learning->nomvar_sup_index = strdup("ta");
02295 (void) fprintf(stdout, "%s: Learning nomvar_sup_index = %s\n", __FILE__, data->learning->nomvar_sup_index);
02296
02298 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_sup_val");
02299 val = xml_get_setting(conf, path);
02300 if (val != NULL) {
02301 data->learning->nomvar_sup_val = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02302 if (data->learning->nomvar_sup_val == NULL) alloc_error(__FILE__, __LINE__);
02303 (void) strcpy(data->learning->nomvar_sup_val, (char *) val);
02304 (void) xmlFree(val);
02305 }
02306 else
02307 data->learning->nomvar_sup_val = strdup("tad");
02308 (void) fprintf(stdout, "%s: Learning nomvar_sup_val = %s\n", __FILE__, data->learning->nomvar_sup_val);
02309
02311 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_sup_index_mean");
02312 val = xml_get_setting(conf, path);
02313 if (val != NULL) {
02314 data->learning->nomvar_sup_index_mean = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02315 if (data->learning->nomvar_sup_index_mean == NULL) alloc_error(__FILE__, __LINE__);
02316 (void) strcpy(data->learning->nomvar_sup_index_mean, (char *) val);
02317 (void) xmlFree(val);
02318 }
02319 else
02320 data->learning->nomvar_sup_index_mean = strdup("tancp_mean");
02321 (void) fprintf(stdout, "%s: Learning nomvar_sup_index_mean = %s\n", __FILE__, data->learning->nomvar_sup_index_mean);
02322
02324 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_sup_index_var");
02325 val = xml_get_setting(conf, path);
02326 if (val != NULL) {
02327 data->learning->nomvar_sup_index_var = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02328 if (data->learning->nomvar_sup_index_var == NULL) alloc_error(__FILE__, __LINE__);
02329 (void) strcpy(data->learning->nomvar_sup_index_var, (char *) val);
02330 (void) xmlFree(val);
02331 }
02332 else
02333 data->learning->nomvar_sup_index_var = strdup("tancp_var");
02334 (void) fprintf(stdout, "%s: Learning nomvar_sup_index_var = %s\n", __FILE__, data->learning->nomvar_sup_index_var);
02335
02337 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "learning", "nomvar_pc_normalized_var");
02338 val = xml_get_setting(conf, path);
02339 if (val != NULL) {
02340 data->learning->nomvar_pc_normalized_var = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02341 if (data->learning->nomvar_pc_normalized_var == NULL) alloc_error(__FILE__, __LINE__);
02342 (void) strcpy(data->learning->nomvar_pc_normalized_var, (char *) val);
02343 (void) xmlFree(val);
02344 }
02345 else
02346 data->learning->nomvar_pc_normalized_var = strdup("eca_pc_learn");
02347 (void) fprintf(stdout, "%s: Learning nomvar_pc_normalized_var = %s\n", __FILE__, data->learning->nomvar_pc_normalized_var);
02348
02349
02350
02352 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "regression", "filename");
02353 val = xml_get_setting(conf, path);
02354 if (val != NULL) {
02355 data->reg->filename = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02356 if (data->reg->filename == NULL) alloc_error(__FILE__, __LINE__);
02357 (void) strcpy(data->reg->filename, (char *) val);
02358 (void) fprintf(stdout, "%s: Regression points filename = %s\n", __FILE__, data->reg->filename);
02359 (void) xmlFree(val);
02360
02362 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "regression", "dimx_name");
02363 val = xml_get_setting(conf, path);
02364 if (val != NULL) {
02365 data->reg->dimxname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02366 if (data->reg->dimxname == NULL) alloc_error(__FILE__, __LINE__);
02367 (void) strcpy(data->reg->dimxname, (char *) val);
02368 (void) fprintf(stdout, "%s: Regression points dimx_name = %s\n", __FILE__, data->reg->dimxname);
02369 (void) xmlFree(val);
02370 }
02371 else {
02372 data->reg->dimxname = strdup("lon");
02373 (void) fprintf(stderr, "%s: Default regression points dimx_name setting = %s.\n", __FILE__, data->reg->dimxname);
02374 (void) xmlFree(val);
02375 }
02377 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "regression", "dimy_name");
02378 val = xml_get_setting(conf, path);
02379 if (val != NULL) {
02380 data->reg->dimyname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02381 if (data->reg->dimyname == NULL) alloc_error(__FILE__, __LINE__);
02382 (void) strcpy(data->reg->dimyname, (char *) val);
02383 (void) fprintf(stdout, "%s: Regression points dimy_name = %s\n", __FILE__, data->reg->dimyname);
02384 (void) xmlFree(val);
02385 }
02386 else {
02387 data->reg->dimyname = strdup("dimy");
02388 (void) fprintf(stderr, "%s: Default regression points dimy_name setting = %s.\n", __FILE__, data->reg->dimyname);
02389 (void) xmlFree(val);
02390 }
02392 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "regression", "longitude_name");
02393 val = xml_get_setting(conf, path);
02394 if (val != NULL) {
02395 data->reg->lonname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02396 if (data->reg->lonname == NULL) alloc_error(__FILE__, __LINE__);
02397 (void) strcpy(data->reg->lonname, (char *) val);
02398 (void) fprintf(stdout, "%s: Regression points longitude_name = %s\n", __FILE__, data->reg->lonname);
02399 (void) xmlFree(val);
02400 }
02401 else {
02402 data->reg->lonname = strdup("lon");
02403 (void) fprintf(stderr, "%s: Default regression points longitude_name setting = %s.\n", __FILE__, data->reg->lonname);
02404 (void) xmlFree(val);
02405 }
02407 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "regression", "latitude_name");
02408 val = xml_get_setting(conf, path);
02409 if (val != NULL) {
02410 data->reg->latname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02411 if (data->reg->latname == NULL) alloc_error(__FILE__, __LINE__);
02412 (void) strcpy(data->reg->latname, (char *) val);
02413 (void) fprintf(stdout, "%s: Regression points latitude_name = %s\n", __FILE__, data->reg->latname);
02414 (void) xmlFree(val);
02415 }
02416 else {
02417 data->reg->latname = strdup("lat");
02418 (void) fprintf(stderr, "%s: Default regression points latitude_name setting = %s.\n", __FILE__, data->reg->latname);
02419 (void) xmlFree(val);
02420 }
02422 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "regression", "pts_name");
02423 val = xml_get_setting(conf, path);
02424 if (val != NULL) {
02425 data->reg->ptsname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02426 if (data->reg->ptsname == NULL) alloc_error(__FILE__, __LINE__);
02427 (void) strcpy(data->reg->ptsname, (char *) val);
02428 (void) fprintf(stdout, "%s: Regression points pts_name = %s\n", __FILE__, data->reg->ptsname);
02429 (void) xmlFree(val);
02430 }
02431 else {
02432 data->reg->ptsname = strdup("pts");
02433 (void) fprintf(stderr, "%s: Default regression points pts_name setting = %s.\n", __FILE__, data->reg->ptsname);
02434 (void) xmlFree(val);
02435 }
02437 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "regression", "distance");
02438 val = xml_get_setting(conf, path);
02439 if (val != NULL) {
02440 data->reg->dist = xmlXPathCastStringToNumber(val);
02441 (void) xmlFree(val);
02442 (void) fprintf(stdout, "%s: Regression distance in meters for spatial mean = %lf\n", __FILE__, data->reg->dist);
02443 }
02444 else {
02445 data->reg->dist = 40000.0;
02446 (void) fprintf(stdout, "%s: Regression distance in meters for spatial mean = %lf.\n", __FILE__, data->reg->dist);
02447 }
02449 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "regression", "regression_save");
02450 val = xml_get_setting(conf, path);
02451 if (val != NULL)
02452 data->reg->reg_save = (int) strtol((char *) val, (char **)NULL, 10);
02453 else
02454 data->reg->reg_save = FALSE;
02455 if (data->reg->reg_save != FALSE && data->reg->reg_save != TRUE) {
02456 (void) fprintf(stderr, "%s: Invalid regression_save value %s in configuration file. Aborting.\n", __FILE__, val);
02457 return -1;
02458 }
02459 (void) fprintf(stdout, "%s: regression_save=%d\n", __FILE__, data->reg->reg_save);
02460 if (val != NULL)
02461 (void) xmlFree(val);
02462 }
02463 else {
02464 (void) fprintf(stderr, "%s: No regression points. Cannot perform learning or downscale. Can just output data given analog days.\n",
02465 __FILE__);
02466 data->reg->filename = NULL;
02467 (void) xmlFree(val);
02468 }
02469
02470
02471 if (data->reg->reg_save == TRUE) {
02473 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "regression", "filename_save_ctrl_reg");
02474 val = xml_get_setting(conf, path);
02475 if (val != NULL) {
02476 data->reg->filename_save_ctrl_reg = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02477 if (data->reg->filename_save_ctrl_reg == NULL) alloc_error(__FILE__, __LINE__);
02478 (void) strcpy(data->reg->filename_save_ctrl_reg, (char *) val);
02479 (void) fprintf(stdout, "%s: Regression filename_save_ctrl_reg = %s\n", __FILE__, data->reg->filename_save_ctrl_reg);
02480 (void) xmlFree(val);
02481 }
02482 else {
02483 (void) fprintf(stderr, "%s: Missing regression filename_save_ctrl_reg setting. Aborting.\n", __FILE__);
02484 (void) xmlFree(val);
02485 return -1;
02486 }
02488 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "regression", "filename_save_other_reg");
02489 val = xml_get_setting(conf, path);
02490 if (val != NULL) {
02491 data->reg->filename_save_other_reg = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02492 if (data->reg->filename_save_other_reg == NULL) alloc_error(__FILE__, __LINE__);
02493 (void) strcpy(data->reg->filename_save_other_reg, (char *) val);
02494 (void) fprintf(stdout, "%s: Regression filename_save_other_reg = %s\n", __FILE__, data->reg->filename_save_other_reg);
02495 (void) xmlFree(val);
02496 }
02497 else {
02498 (void) fprintf(stderr, "%s: Missing regression filename_save_other_reg setting. Aborting.\n", __FILE__);
02499 (void) xmlFree(val);
02500 return -1;
02501 }
02502
02504 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "regression", "time_name");
02505 val = xml_get_setting(conf, path);
02506 if (val != NULL) {
02507 data->reg->timename = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02508 if (data->reg->timename == NULL) alloc_error(__FILE__, __LINE__);
02509 (void) strcpy(data->reg->timename, (char *) val);
02510 (void) xmlFree(val);
02511 }
02512 else
02513 data->reg->timename = strdup("time");
02514 (void) fprintf(stdout, "%s: Regression time dimension name = %s\n", __FILE__, data->reg->timename);
02515 }
02516
02517
02518
02520 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "number_of_large_scale_fields");
02521 val = xml_get_setting(conf, path);
02522 if (val != NULL)
02523 data->field[0].n_ls = (int) strtol((char *) val, (char **)NULL, 10);
02524 else {
02525 (void) fprintf(stderr, "%s: Missing or invalid number_of_large_scale_fields setting. Aborting.\n", __FILE__);
02526 return -1;
02527 }
02528 if (val != NULL)
02529 (void) xmlFree(val);
02530
02531
02532
02533
02534
02536 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "number_of_large_scale_control_fields");
02537 val = xml_get_setting(conf, path);
02538 if (val != NULL)
02539 data->field[1].n_ls = (int) strtol((char *) val, (char **)NULL, 10);
02540 else {
02541 (void) fprintf(stderr, "%s: Missing or invalid number_of_large_scale_control_fields setting. Aborting.\n", __FILE__);
02542 return -1;
02543 }
02544 if (val != NULL)
02545 (void) xmlFree(val);
02546 if (data->field[1].n_ls == 0) {
02547 (void) fprintf(stderr, "%s: number_of_large_scale_control_fields cannot be 0. Aborting.\n", __FILE__);
02548 return -1;
02549 }
02550
02552 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "number_of_secondary_large_scale_fields");
02553 val = xml_get_setting(conf, path);
02554 if (val != NULL)
02555 data->field[2].n_ls = (int) strtol((char *) val, (char **)NULL, 10);
02556 else
02557 data->field[2].n_ls = 0;
02558 if (val != NULL)
02559 (void) xmlFree(val);
02560 if (data->field[2].n_ls == 0) {
02561 (void) fprintf(stderr, "%s: number_of_secondary_large_scale_fields cannot be 0. Aborting.\n", __FILE__);
02562 return -1;
02563 }
02564
02566 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "number_of_secondary_large_scale_control_fields");
02567 val = xml_get_setting(conf, path);
02568 if (val != NULL)
02569 data->field[3].n_ls = (int) strtol((char *) val, (char **)NULL, 10);
02570 else {
02571 (void) fprintf(stderr, "%s: Missing or invalid number_of_secondary_large_scale_control_fields setting. Aborting.\n", __FILE__);
02572 return -1;
02573 }
02574 if (val != NULL)
02575 (void) xmlFree(val);
02576 if (data->field[3].n_ls == 0) {
02577 (void) fprintf(stderr, "%s: number_of_secondary_large_scale_control_fields cannot be 0. Aborting.\n", __FILE__);
02578 return -1;
02579 }
02580
02581
02582 for (i=0; i<NCAT; i++) {
02583
02584
02585 if (data->field[i].n_ls > 0) {
02586
02587 if (data->field[i].n_ls > 1) {
02588 (void) fprintf(stderr, "%s: WARNING: only 1 large-scale field supported. Going back to one field and ignoring others in the configuration file!!!\n", __FILE__);
02589 data->field[i].n_ls = 1;
02590 }
02591
02592
02593 data->field[i].data = (field_data_struct *) malloc(data->field[i].n_ls * sizeof(field_data_struct));
02594 if (data->field[i].data == NULL) alloc_error(__FILE__, __LINE__);
02595 data->field[i].proj = (proj_struct *) malloc(data->field[i].n_ls * sizeof(proj_struct));
02596 if (data->field[i].proj == NULL) alloc_error(__FILE__, __LINE__);
02597
02598 for (j=0; j<data->field[i].n_ls; j++) {
02599 data->field[i].data[j].info = (info_field_struct *) malloc(sizeof(info_field_struct));
02600 if (data->field[i].data[j].info == NULL) alloc_error(__FILE__, __LINE__);
02601 data->field[i].data[j].clim_info = (clim_info_struct *) malloc(sizeof(clim_info_struct));
02602 if (data->field[i].data[j].clim_info == NULL) alloc_error(__FILE__, __LINE__);
02603 data->field[i].data[j].eof_info = (eof_info_struct *) malloc(sizeof(eof_info_struct));
02604 if (data->field[i].data[j].eof_info == NULL) alloc_error(__FILE__, __LINE__);
02605 data->field[i].data[j].eof_info->info = (info_field_struct *) malloc(sizeof(info_field_struct));
02606 if (data->field[i].data[j].eof_info->info == NULL) alloc_error(__FILE__, __LINE__);
02607 data->field[i].data[j].eof_data = (eof_data_struct *) malloc(sizeof(eof_data_struct));
02608 if (data->field[i].data[j].eof_data == NULL) alloc_error(__FILE__, __LINE__);
02609 data->field[i].data[j].down = (downscale_struct *) malloc(sizeof(downscale_struct));
02610 if (data->field[i].data[j].down == NULL) alloc_error(__FILE__, __LINE__);
02611
02612 data->field[i].proj[j].grid_mapping_name = NULL;
02613 data->field[i].proj[j].name = NULL;
02614 data->field[i].proj[j].coords = NULL;
02615
02616 data->field[i].data[j].field_ls = NULL;
02617 data->field[i].data[j].field_eof_ls = NULL;
02618 data->field[i].data[j].eof_data->eof_ls = NULL;
02619 data->field[i].data[j].eof_data->sing_ls = NULL;
02620 data->field[i].data[j].down->mean_dist = NULL;
02621 data->field[i].data[j].down->var_dist = NULL;
02622 }
02623 }
02624 }
02625
02626
02627 for (cat=0; cat<NCAT; cat++) {
02628
02629
02630 if (cat == 0) {
02631 catstr = strdup("large_scale_fields");
02632 catstrt = strdup("Large-scale fields");
02633 }
02634 else if (cat == 1) {
02635 catstr = strdup("large_scale_control_fields");
02636 catstrt = strdup("Large-scale control fields");
02637 }
02638 else if (cat == 2) {
02639 catstr = strdup("secondary_large_scale_fields");
02640 catstrt = strdup("Large-scale secondary fields");
02641 }
02642 else if (cat == 3) {
02643 catstr = strdup("secondary_large_scale_control_fields");
02644 catstrt = strdup("Large-scale secondary control fields");
02645 }
02646 else {
02647 catstr = strdup("large_scale_fields");
02648 catstrt = strdup("Large-scale fields");
02649 }
02650
02651
02652 if (data->field[cat].n_ls > 0) {
02653
02654 (void) fprintf(stdout, "%s: number_of_%s = %d\n", __FILE__, catstr, data->field[cat].n_ls);
02655
02656
02657
02658 for (i=0; i<data->field[cat].n_ls; i++) {
02659
02660 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "name", i+1);
02661 val = xml_get_setting(conf, path);
02662 if (val != NULL) {
02663 data->field[cat].data[i].nomvar_ls = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02664 if (data->field[cat].data[i].nomvar_ls == NULL) alloc_error(__FILE__, __LINE__);
02665 (void) strcpy( data->field[cat].data[i].nomvar_ls, (char *) val);
02666 (void) xmlFree(val);
02667 }
02668 else {
02669 (void) fprintf(stderr, "%s: Missing name setting %s. Aborting.\n", __FILE__, catstrt);
02670 return -1;
02671 }
02672
02673 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "filename", i+1);
02674 val = xml_get_setting(conf, path);
02675 if (val != NULL) {
02676 data->field[cat].data[i].filename_ls = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02677 if (data->field[cat].data[i].filename_ls == NULL) alloc_error(__FILE__, __LINE__);
02678 (void) strcpy(data->field[cat].data[i].filename_ls, (char *) val);
02679 (void) xmlFree(val);
02680 (void) fprintf(stdout, "%s: %s #%d: name = %s filename = %s\n",
02681 __FILE__, catstrt, i, data->field[cat].data[i].nomvar_ls, data->field[cat].data[i].filename_ls);
02682 }
02683 else {
02684 (void) fprintf(stderr, "%s: Missing filename setting %s. Aborting.\n", __FILE__, catstrt);
02685 return -1;
02686 }
02687
02688 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "dimy_name", i+1);
02689 val = xml_get_setting(conf, path);
02690 if (val != NULL) {
02691 data->field[cat].data[i].dimyname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02692 if (data->field[cat].data[i].dimyname == NULL) alloc_error(__FILE__, __LINE__);
02693 (void) strcpy(data->field[cat].data[i].dimyname, (char *) val);
02694 (void) xmlFree(val);
02695 }
02696 else
02697 data->field[cat].data[i].dimyname = strdup("lat");
02698
02699 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "dimx_name", i+1);
02700 val = xml_get_setting(conf, path);
02701 if (val != NULL) {
02702 data->field[cat].data[i].dimxname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02703 if (data->field[cat].data[i].dimxname == NULL) alloc_error(__FILE__, __LINE__);
02704 (void) strcpy(data->field[cat].data[i].dimxname, (char *) val);
02705 (void) xmlFree(val);
02706 }
02707 else
02708 data->field[cat].data[i].dimxname = strdup("lon");
02709
02710 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "latitude_name", i+1);
02711 val = xml_get_setting(conf, path);
02712 if (val != NULL) {
02713 data->field[cat].data[i].latname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02714 if (data->field[cat].data[i].latname == NULL) alloc_error(__FILE__, __LINE__);
02715 (void) strcpy(data->field[cat].data[i].latname, (char *) val);
02716 (void) xmlFree(val);
02717 }
02718 else
02719 data->field[cat].data[i].latname = strdup("lat");
02720
02721 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "longitude_name", i+1);
02722 val = xml_get_setting(conf, path);
02723 if (val != NULL) {
02724 data->field[cat].data[i].lonname = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02725 if (data->field[cat].data[i].lonname == NULL) alloc_error(__FILE__, __LINE__);
02726 (void) strcpy(data->field[cat].data[i].lonname, (char *) val);
02727 (void) xmlFree(val);
02728 }
02729 else
02730 data->field[cat].data[i].lonname = strdup("lon");
02731
02732 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "time_name", i+1);
02733 val = xml_get_setting(conf, path);
02734 if (val != NULL) {
02735 data->field[cat].data[i].timename = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02736 if (data->field[cat].data[i].timename == NULL) alloc_error(__FILE__, __LINE__);
02737 (void) strcpy(data->field[cat].data[i].timename, (char *) val);
02738 (void) xmlFree(val);
02739 }
02740 else
02741 data->field[cat].data[i].timename = strdup("time");
02742
02743
02744 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "projection", i+1);
02745 val = xml_get_setting(conf, path);
02746 if (val != NULL) {
02747 data->field[cat].proj[i].name = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02748 if (data->field[cat].proj[i].name == NULL) alloc_error(__FILE__, __LINE__);
02749 (void) strcpy(data->field[cat].proj[i].name, (char *) val);
02750 (void) xmlFree(val);
02751 (void) fprintf(stdout, "%s: %s #%d: name = %s projection = %s\n",
02752 __FILE__, catstrt, i, data->field[cat].data[i].nomvar_ls, data->field[cat].proj[i].name);
02753 }
02754 else
02755 data->field[cat].proj[i].name = strdup("unknown");
02756
02757
02758 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "coordinates", i+1);
02759 val = xml_get_setting(conf, path);
02760 if (val != NULL) {
02761 data->field[cat].proj[i].coords = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02762 if (data->field[cat].proj[i].coords == NULL) alloc_error(__FILE__, __LINE__);
02763 (void) strcpy(data->field[cat].proj[i].coords, (char *) val);
02764 (void) xmlFree(val);
02765 (void) fprintf(stdout, "%s: %s #%d: name = %s coordinates = %s\n",
02766 __FILE__, catstrt, i, data->field[cat].data[i].nomvar_ls, data->field[cat].proj[i].coords);
02767 }
02768 else
02769 data->field[cat].proj[i].coords = strdup("2D");
02770
02771
02775 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "clim_remove", i+1);
02776 val = xml_get_setting(conf, path);
02777 if (val != NULL)
02778 data->field[cat].data[i].clim_info->clim_remove = (int) xmlXPathCastStringToNumber(val);
02779 else
02780 data->field[cat].data[i].clim_info->clim_remove = FALSE;
02781 (void) fprintf(stdout, "%s: clim_remove = %d\n", __FILE__, data->field[cat].data[i].clim_info->clim_remove);
02782 if (val != NULL)
02783 (void) xmlFree(val);
02784
02786 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "clim_provided", i+1);
02787 val = xml_get_setting(conf, path);
02788 if (val != NULL) {
02789 if ( !xmlStrcmp(val, (xmlChar *) "1") )
02790 data->field[cat].data[i].clim_info->clim_provided = TRUE;
02791 else
02792 data->field[cat].data[i].clim_info->clim_provided = FALSE;
02793 (void) fprintf(stdout, "%s: clim_provided #%d = %d\n", __FILE__, i+1, data->field[cat].data[i].clim_info->clim_provided);
02794 (void) xmlFree(val);
02795
02796
02797 if (data->field[cat].data[i].clim_info->clim_provided == TRUE) {
02798
02800 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "clim_openfilename",i+1);
02801 val = xml_get_setting(conf, path);
02802 if (val != NULL) {
02803 data->field[cat].data[i].clim_info->clim_filein_ls = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02804 if (data->field[cat].data[i].clim_info->clim_filein_ls == NULL) alloc_error(__FILE__, __LINE__);
02805 (void) strcpy(data->field[cat].data[i].clim_info->clim_filein_ls, (char *) val);
02806 (void) fprintf(stdout, "%s: Climatology input filename #%d = %s\n", __FILE__, i+1,
02807 data->field[cat].data[i].clim_info->clim_filein_ls);
02808 (void) xmlFree(val);
02809 }
02810 else {
02811 (void) fprintf(stderr, "%s: Missing clim_openfilename setting %s. Aborting.\n", __FILE__, catstrt);
02812 return -1;
02813 }
02814 }
02815 }
02816 else
02817 data->field[cat].data[i].clim_info->clim_provided = FALSE;
02818
02820 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "clim_save", i+1);
02821 val = xml_get_setting(conf, path);
02822 if (val != NULL) {
02823 if ( !xmlStrcmp(val, (xmlChar *) "1") )
02824 data->field[cat].data[i].clim_info->clim_save = TRUE;
02825 else
02826 data->field[cat].data[i].clim_info->clim_save = FALSE;
02827 (void) fprintf(stdout, "%s: clim_save #%d = %d\n", __FILE__, i+1, data->field[cat].data[i].clim_info->clim_save);
02828 (void) xmlFree(val);
02829
02830
02831 if (data->field[cat].data[i].clim_info->clim_save == TRUE) {
02832
02833 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "clim_savefilename",i+1);
02834 val = xml_get_setting(conf, path);
02835 if (val != NULL) {
02836 data->field[cat].data[i].clim_info->clim_fileout_ls = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02837 if (data->field[cat].data[i].clim_info->clim_fileout_ls == NULL) alloc_error(__FILE__, __LINE__);
02838 (void) strcpy(data->field[cat].data[i].clim_info->clim_fileout_ls, (char *) val);
02839 (void) fprintf(stdout, "%s: Climatology output filename #%d = %s\n", __FILE__, i+1,
02840 data->field[cat].data[i].clim_info->clim_fileout_ls);
02841 (void) xmlFree(val);
02842 }
02843 else {
02844 (void) fprintf(stderr, "%s: Missing clim_savefilename setting %s. Aborting.\n", __FILE__, catstrt);
02845 return -1;
02846 }
02847 }
02848
02849
02850 if (data->field[cat].data[i].clim_info->clim_save == TRUE || data->field[cat].data[i].clim_info->clim_provided == TRUE) {
02851 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "clim_name", i+1);
02852 val = xml_get_setting(conf, path);
02853 if (val != NULL) {
02854 data->field[cat].data[i].clim_info->clim_nomvar_ls = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02855 if (data->field[cat].data[i].clim_info->clim_nomvar_ls == NULL) alloc_error(__FILE__, __LINE__);
02856 (void) strcpy(data->field[cat].data[i].clim_info->clim_nomvar_ls, (char *) val);
02857 (void) fprintf(stdout, "%s: Climatology variable name #%d = %s\n", __FILE__, i+1,
02858 data->field[cat].data[i].clim_info->clim_nomvar_ls);
02859 (void) xmlFree(val);
02860 }
02861 else {
02862 (void) fprintf(stderr, "%s: Missing clim_name setting %s. Aborting.\n", __FILE__, catstrt);
02863 return -1;
02864 }
02865 }
02866 }
02867 else
02868 data->field[cat].data[i].clim_info->clim_save = FALSE;
02869
02872 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "eof_project", i+1);
02873 val = xml_get_setting(conf, path);
02874 if (val != NULL)
02875 data->field[cat].data[i].eof_info->eof_project = (int) xmlXPathCastStringToNumber(val);
02876 else
02877 data->field[cat].data[i].eof_info->eof_project = FALSE;
02878 (void) fprintf(stdout, "%s: eof_project = %d\n", __FILE__, data->field[cat].data[i].eof_info->eof_project);
02879 if (val != NULL)
02880 (void) xmlFree(val);
02881
02882 if (data->field[cat].data[i].eof_info->eof_project == TRUE) {
02884 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr,
02885 "number_of_eofs", i+1);
02886 val = xml_get_setting(conf, path);
02887 if (val != NULL) {
02888 data->field[cat].data[i].eof_info->neof_ls = (int) xmlXPathCastStringToNumber(val);
02889 if (data->field[cat].data[i].eof_info->neof_ls != data->learning->rea_neof) {
02890 (void) fprintf(stderr,
02891 "%s: Fatal error in configuration. The number of eof for field #%d of category %d is %d and the corresponding learning number of eof is %d. They should be equal!! Aborting.\n",
02892 __FILE__, i, cat, data->field[cat].data[i].eof_info->neof_ls, data->learning->rea_neof);
02893 return -1;
02894 }
02895 (void) fprintf(stdout, "%s: number_of_eofs = %d\n", __FILE__, data->field[cat].data[i].eof_info->neof_ls);
02896 (void) xmlFree(val);
02897 }
02898
02900 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "eof_coordinates", i+1);
02901 val = xml_get_setting(conf, path);
02902 if (val != NULL) {
02903 data->field[cat].data[i].eof_info->eof_coords = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02904 if (data->field[cat].data[i].eof_info->eof_coords == NULL) alloc_error(__FILE__, __LINE__);
02905 (void) strcpy(data->field[cat].data[i].eof_info->eof_coords, (char *) val);
02906 (void) fprintf(stdout, "%s: %s #%d: name = %s eof_coordinates = %s\n",
02907 __FILE__, catstrt, i, data->field[cat].data[i].nomvar_ls, data->field[cat].data[i].eof_info->eof_coords);
02908 (void) xmlFree(val);
02909 }
02910 else
02911 data->field[cat].data[i].eof_info->eof_coords = strdup("2D");
02912
02914 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "eof_openfilename", i+1);
02915 val = xml_get_setting(conf, path);
02916 if (val != NULL) {
02917 data->field[cat].data[i].eof_info->eof_filein_ls = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02918 if (data->field[cat].data[i].eof_info->eof_filein_ls == NULL) alloc_error(__FILE__, __LINE__);
02919 (void) strcpy(data->field[cat].data[i].eof_info->eof_filein_ls, (char *) val);
02920 (void) fprintf(stdout, "%s: EOF/Singular values input filename #%d = %s\n", __FILE__, i+1,
02921 data->field[cat].data[i].eof_info->eof_filein_ls);
02922 (void) xmlFree(val);
02923 }
02924 else {
02925 (void) fprintf(stderr, "%s: Missing eof_openfilename setting. Aborting.\n", __FILE__);
02926 return -1;
02927 }
02928
02930 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "eof_scale", i+1);
02931 val = xml_get_setting(conf, path);
02932 if (val != NULL)
02933 data->field[cat].data[i].eof_info->eof_scale = xmlXPathCastStringToNumber(val);
02934 else
02935 data->field[cat].data[i].eof_info->eof_scale = 1.0;
02936 (void) fprintf(stdout, "%s: units scaling = %lf\n", __FILE__, data->field[cat].data[i].eof_info->eof_scale);
02937 if (val != NULL)
02938 (void) xmlFree(val);
02939
02941 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "eof_weight", i+1);
02942 val = xml_get_setting(conf, path);
02943 if (val != NULL)
02944 data->field[cat].data[i].eof_info->eof_weight = (int) strtol((char *) val, (char **)NULL, 10);
02945 else
02946 data->field[cat].data[i].eof_info->eof_weight = FALSE;
02947 if (data->field[cat].data[i].eof_info->eof_weight != FALSE && data->field[cat].data[i].eof_info->eof_weight != TRUE) {
02948 (void) fprintf(stderr, "%s: Invalid or missing downscaling eof_weight value %s in configuration file. Aborting.\n", __FILE__, val);
02949 return -1;
02950 }
02951 (void) fprintf(stdout, "%s: downscaling eof_weight = %d\n", __FILE__, data->field[cat].data[i].eof_info->eof_weight);
02952 if (val != NULL)
02953 (void) xmlFree(val);
02954
02956 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "eof_name", i+1);
02957 val = xml_get_setting(conf, path);
02958 if (val != NULL) {
02959 data->field[cat].data[i].eof_data->eof_nomvar_ls = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02960 if (data->field[cat].data[i].eof_data->eof_nomvar_ls == NULL) alloc_error(__FILE__, __LINE__);
02961 (void) strcpy(data->field[cat].data[i].eof_data->eof_nomvar_ls, (char *) val);
02962 (void) fprintf(stdout, "%s: EOF variable name #%d = %s\n", __FILE__, i+1, data->field[cat].data[i].eof_data->eof_nomvar_ls);
02963 (void) xmlFree(val);
02964 }
02965 else {
02966 (void) fprintf(stderr, "%s: Missing eof_name setting. Aborting.\n", __FILE__);
02967 return -1;
02968 }
02970 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s[@id=\"%d\"]", "setting", catstr, "sing_name", i+1);
02971 val = xml_get_setting(conf, path);
02972 if (val != NULL) {
02973 data->field[cat].data[i].eof_data->sing_nomvar_ls = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
02974 if (data->field[cat].data[i].eof_data->sing_nomvar_ls == NULL) alloc_error(__FILE__, __LINE__);
02975 (void) strcpy(data->field[cat].data[i].eof_data->sing_nomvar_ls, (char *) val);
02976 (void) fprintf(stdout, "%s: Singular values variable name #%d = %s\n", __FILE__, i+1,
02977 data->field[cat].data[i].eof_data->sing_nomvar_ls);
02978 (void) xmlFree(val);
02979 }
02980 else {
02981 (void) fprintf(stderr, "%s: Missing sing_name setting. Aborting.\n", __FILE__);
02982 return -1;
02983 }
02984 }
02985 }
02986 }
02987 (void) free(catstr);
02988 (void) free(catstrt);
02989 }
02990
02991
02992
02993
02995 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "period_ctrl", "downscale");
02996 val = xml_get_setting(conf, path);
02997 if (val != NULL) {
02998 data->conf->period_ctrl->downscale = xmlXPathCastStringToNumber(val);
02999 (void) fprintf(stdout, "%s: period_ctrl downscale = %d\n", __FILE__, data->conf->period_ctrl->downscale);
03000 (void) xmlFree(val);
03001 }
03002 else
03003 data->conf->period_ctrl->downscale = TRUE;
03004 if (data->conf->period_ctrl->downscale == TRUE) {
03006 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period_ctrl", "period", "year_begin");
03007 val = xml_get_setting(conf, path);
03008 if (val != NULL) {
03009 data->conf->period_ctrl->year_begin = xmlXPathCastStringToNumber(val);
03010 (void) fprintf(stdout, "%s: period_ctrl year_begin = %d\n", __FILE__, data->conf->period_ctrl->year_begin);
03011 (void) xmlFree(val);
03012 }
03013 else
03014 data->conf->period_ctrl->year_begin = -1;
03016 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period_ctrl", "period", "month_begin");
03017 val = xml_get_setting(conf, path);
03018 if (val != NULL) {
03019 data->conf->period_ctrl->month_begin = xmlXPathCastStringToNumber(val);
03020 (void) fprintf(stdout, "%s: period_ctrl month_begin = %d\n", __FILE__, data->conf->period_ctrl->month_begin);
03021 (void) xmlFree(val);
03022 }
03023 else
03024 data->conf->period_ctrl->month_begin = -1;
03026 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period_ctrl", "period", "day_begin");
03027 val = xml_get_setting(conf, path);
03028 if (val != NULL) {
03029 data->conf->period_ctrl->day_begin = xmlXPathCastStringToNumber(val);
03030 (void) fprintf(stdout, "%s: period_ctrl day_begin = %d\n", __FILE__, data->conf->period_ctrl->day_begin);
03031 (void) xmlFree(val);
03032 }
03033 else
03034 data->conf->period_ctrl->day_begin = -1;
03036 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period_ctrl", "period", "year_end");
03037 val = xml_get_setting(conf, path);
03038 if (val != NULL) {
03039 data->conf->period_ctrl->year_end = xmlXPathCastStringToNumber(val);
03040 (void) fprintf(stdout, "%s: period_ctrl year_end = %d\n", __FILE__, data->conf->period_ctrl->year_end);
03041 (void) xmlFree(val);
03042 }
03043 else
03044 data->conf->period_ctrl->year_end = -1;
03046 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period_ctrl", "period", "month_end");
03047 val = xml_get_setting(conf, path);
03048 if (val != NULL) {
03049 data->conf->period_ctrl->month_end = xmlXPathCastStringToNumber(val);
03050 (void) fprintf(stdout, "%s: period_ctrl month_end = %d\n", __FILE__, data->conf->period_ctrl->month_end);
03051 (void) xmlFree(val);
03052 }
03053 else
03054 data->conf->period_ctrl->month_end = -1;
03056 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period_ctrl", "period", "day_end");
03057 val = xml_get_setting(conf, path);
03058 if (val != NULL) {
03059 data->conf->period_ctrl->day_end = xmlXPathCastStringToNumber(val);
03060 (void) fprintf(stdout, "%s: period_ctrl day_end = %d\n", __FILE__, data->conf->period_ctrl->day_end);
03061 (void) xmlFree(val);
03062 }
03063 else
03064 data->conf->period_ctrl->day_end = -1;
03065 }
03066 else {
03067 data->conf->period_ctrl->year_begin = -1;
03068 data->conf->period_ctrl->month_begin = -1;
03069 data->conf->period_ctrl->day_begin = -1;
03070 data->conf->period_ctrl->year_end = -1;
03071 data->conf->period_ctrl->month_end = -1;
03072 data->conf->period_ctrl->day_end = -1;
03073 }
03074
03075
03076
03077
03078 if (data->field[0].n_ls > 0) {
03079 data->conf->nperiods = 1;
03080 data->conf->period = (period_struct *) malloc(sizeof(period_struct));
03081 if (data->conf->period == NULL) alloc_error(__FILE__, __LINE__);
03082 }
03083 else
03084 data->conf->nperiods = 0;
03085
03086
03087 for (i=0; i<data->conf->nperiods; i++) {
03089 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s", "setting", "period", "downscale");
03090 val = xml_get_setting(conf, path);
03091 if (val != NULL) {
03092 data->conf->period[i].downscale = xmlXPathCastStringToNumber(val);
03093 (void) fprintf(stdout, "%s: period downscale = %d\n", __FILE__, data->conf->period[i].downscale);
03094 (void) xmlFree(val);
03095 }
03096 else
03097 data->conf->period[i].downscale = TRUE;
03098 if (data->conf->period[i].downscale == TRUE) {
03100 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period", "period", "year_begin");
03101 val = xml_get_setting(conf, path);
03102 if (val != NULL) {
03103 data->conf->period[i].year_begin = xmlXPathCastStringToNumber(val);
03104 (void) xmlFree(val);
03105 (void) fprintf(stdout, "%s: period #%d year_begin = %d\n", __FILE__, i+1, data->conf->period[i].year_begin);
03106 }
03107 else
03108 data->conf->period[i].year_begin = -1;
03110 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period", "period", "month_begin");
03111 val = xml_get_setting(conf, path);
03112 if (val != NULL) {
03113 data->conf->period[i].month_begin = xmlXPathCastStringToNumber(val);
03114 (void) xmlFree(val);
03115 (void) fprintf(stdout, "%s: period #%d month_begin = %d\n", __FILE__, i+1, data->conf->period[i].month_begin);
03116 }
03117 else
03118 data->conf->period[i].month_begin = -1;
03120 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period", "period", "day_begin");
03121 val = xml_get_setting(conf, path);
03122 if (val != NULL) {
03123 data->conf->period[i].day_begin = xmlXPathCastStringToNumber(val);
03124 (void) xmlFree(val);
03125 (void) fprintf(stdout, "%s: period #%d day_begin = %d\n", __FILE__, i+1, data->conf->period[i].day_begin);
03126 }
03127 else
03128 data->conf->period[i].day_begin = -1;
03130 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period", "period", "year_end");
03131 val = xml_get_setting(conf, path);
03132 if (val != NULL) {
03133 data->conf->period[i].year_end = xmlXPathCastStringToNumber(val);
03134 (void) xmlFree(val);
03135 (void) fprintf(stdout, "%s: period #%d year_end = %d\n", __FILE__, i+1, data->conf->period[i].year_end);
03136 }
03137 else
03138 data->conf->period[i].year_end = -1;
03140 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period", "period", "month_end");
03141 val = xml_get_setting(conf, path);
03142 if (val != NULL) {
03143 data->conf->period[i].month_end = xmlXPathCastStringToNumber(val);
03144 (void) xmlFree(val);
03145 (void) fprintf(stdout, "%s: period #%d month_end = %d\n", __FILE__, i+1, data->conf->period[i].month_end);
03146 }
03147 else
03148 data->conf->period[i].month_end = -1;
03150 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]/%s/%s", "setting", "period", "period", "day_end");
03151 val = xml_get_setting(conf, path);
03152 if (val != NULL) {
03153 data->conf->period[i].day_end = xmlXPathCastStringToNumber(val);
03154 (void) xmlFree(val);
03155 (void) fprintf(stdout, "%s: period #%d day_end = %d\n", __FILE__, i+1, data->conf->period[i].day_end);
03156 }
03157 else
03158 data->conf->period[i].day_end = -1;
03159 }
03160 else {
03161 data->conf->period[i].year_begin = -1;
03162 data->conf->period[i].month_begin = -1;
03163 data->conf->period[i].day_begin = -1;
03164 data->conf->period[i].year_end = -1;
03165 data->conf->period[i].month_end = -1;
03166 data->conf->period[i].day_end = -1;
03167 }
03168 }
03169
03170
03171
03172
03174 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "number_of_seasons");
03175 val = xml_get_setting(conf, path);
03176 if (val != NULL) {
03177 data->conf->nseasons = (int) xmlXPathCastStringToNumber(val);
03178 (void) fprintf(stdout, "%s: number_of_seasons = %d\n", __FILE__, data->conf->nseasons);
03179 (void) xmlFree(val);
03180
03183 data->conf->season = (season_struct *) malloc(data->conf->nseasons * sizeof(season_struct));
03184 if (data->conf->season == NULL) alloc_error(__FILE__, __LINE__);
03185
03186 data->learning->data = (learning_data_struct *) malloc(data->conf->nseasons * sizeof(learning_data_struct));
03187 if (data->learning->data == NULL) alloc_error(__FILE__, __LINE__);
03188
03189
03190 for (cat=0; cat<NCAT; cat++) {
03191
03192 data->field[cat].precip_index = (double **) malloc(data->conf->nseasons * sizeof(double *));
03193 if (data->field[cat].precip_index == NULL) alloc_error(__FILE__, __LINE__);
03194 data->field[cat].analog_days = (analog_day_struct *) malloc(data->conf->nseasons * sizeof(analog_day_struct));
03195 if (data->field[cat].analog_days == NULL) alloc_error(__FILE__, __LINE__);
03196
03197
03198 for (i=0; i<data->field[cat].n_ls; i++) {
03199 if (cat == 0 || cat == 1) {
03200
03201 data->field[cat].data[i].down->mean_dist = (double **) malloc(data->conf->nseasons * sizeof(double *));
03202 if (data->field[cat].data[i].down->mean_dist == NULL) alloc_error(__FILE__, __LINE__);
03203 data->field[cat].data[i].down->var_dist = (double **) malloc(data->conf->nseasons * sizeof(double *));
03204 if (data->field[cat].data[i].down->var_dist == NULL) alloc_error(__FILE__, __LINE__);
03205 data->field[cat].data[i].down->dist = (double **) malloc(data->conf->nseasons * sizeof(double *));
03206 if (data->field[cat].data[i].down->dist == NULL) alloc_error(__FILE__, __LINE__);
03207 data->field[cat].data[i].down->days_class_clusters = (int **) malloc(data->conf->nseasons * sizeof(int *));
03208 if (data->field[cat].data[i].down->days_class_clusters == NULL) alloc_error(__FILE__, __LINE__);
03209 data->field[cat].data[i].down->var_pc_norm = (double *) malloc(data->field[cat].data[i].eof_info->neof_ls * sizeof(double));
03210 if (data->field[cat].data[i].down->var_pc_norm == NULL) alloc_error(__FILE__, __LINE__);
03211 }
03212 else {
03213
03214 data->field[cat].data[i].down->smean_norm = (double **) malloc(data->conf->nseasons * sizeof(double *));
03215 if (data->field[cat].data[i].down->smean_norm == NULL) alloc_error(__FILE__, __LINE__);
03216 data->field[cat].data[i].down->mean = (double *) malloc(data->conf->nseasons * sizeof(double));
03217 if (data->field[cat].data[i].down->mean == NULL) alloc_error(__FILE__, __LINE__);
03218 data->field[cat].data[i].down->var = (double *) malloc(data->conf->nseasons * sizeof(double));
03219 if (data->field[cat].data[i].down->var == NULL) alloc_error(__FILE__, __LINE__);
03220 data->field[cat].data[i].down->delta = (double **) malloc(data->conf->nseasons * sizeof(double *));
03221 if (data->field[cat].data[i].down->delta == NULL) alloc_error(__FILE__, __LINE__);
03222 data->field[cat].data[i].down->delta_dayschoice = (double ***) malloc(data->conf->nseasons * sizeof(double **));
03223 if (data->field[cat].data[i].down->delta_dayschoice == NULL) alloc_error(__FILE__, __LINE__);
03224 data->field[cat].data[i].down->sup_val_norm = (double **) malloc(data->conf->nseasons * sizeof(double));
03225 if (data->field[cat].data[i].down->sup_val_norm == NULL) alloc_error(__FILE__, __LINE__);
03226
03227 if (cat == 3) {
03228 data->field[cat].data[i].down->smean_2d = (double **) malloc(data->conf->nseasons * sizeof(double));
03229 if (data->field[cat].data[i].down->smean_2d == NULL) alloc_error(__FILE__, __LINE__);
03230 data->field[cat].data[i].down->svar_2d = (double **) malloc(data->conf->nseasons * sizeof(double));
03231 if (data->field[cat].data[i].down->svar_2d == NULL) alloc_error(__FILE__, __LINE__);
03232 }
03233 }
03234 }
03235 }
03236
03237
03238 for (i=0; i<data->conf->nseasons; i++) {
03239
03240 data->learning->data[i].time_s = (time_vect_struct *) malloc(sizeof(time_vect_struct));
03241 if (data->learning->data[i].time_s == NULL) alloc_error(__FILE__, __LINE__);
03242
03244 (void) sprintf(path, "/configuration/%s/%s[@id=\"%d\"]", "setting", "number_of_clusters", i+1);
03245 val = xml_get_setting(conf, path);
03246 if (val != NULL) {
03247 data->conf->season[i].nclusters = xmlXPathCastStringToNumber(val);
03248 (void) fprintf(stdout, "%s: season #%d number_of_clusters = %d\n", __FILE__, i+1, data->conf->season[i].nclusters);
03249 (void) xmlFree(val);
03250 }
03251 else
03252 data->conf->season[i].nclusters = -1;
03253
03255 (void) sprintf(path, "/configuration/%s/%s[@id=\"%d\"]", "setting", "number_of_regression_vars", i+1);
03256 val = xml_get_setting(conf, path);
03257 if (val != NULL) {
03258 data->conf->season[i].nreg = xmlXPathCastStringToNumber(val);
03259 (void) fprintf(stdout, "%s: season #%d number_of_regression_vars = %d\n", __FILE__, i+1, data->conf->season[i].nreg);
03260 (void) xmlFree(val);
03261 }
03262 else
03263 data->conf->season[i].nreg = -1;
03264
03265 if ( ! ((data->conf->season[i].nreg == data->conf->season[i].nclusters) ||
03266 ( data->conf->season[i].nreg == data->conf->season[i].nclusters+1 ) ) ) {
03267 (void) fprintf(stderr, "%s: For season=%d, invalid correspondence between number_of_clusters=%d and number_of_regression_vars=%d. number_of_regression_vars should be equal to number_of_clusters or number_of_clusters+1 (temperature as supplemental regression variable). Aborting.\n",
03268 __FILE__, i, data->conf->season[i].nclusters, data->conf->season[i].nreg);
03269 return -1;
03270 }
03271
03273 (void) sprintf(path, "/configuration/%s/%s[@id=\"%d\"]", "setting", "number_of_days_search", i+1);
03274 val = xml_get_setting(conf, path);
03275 if (val != NULL) {
03276 data->conf->season[i].ndays = xmlXPathCastStringToNumber(val);
03277 (void) fprintf(stdout, "%s: season #%d number_of_days_search = %d\n", __FILE__, i+1, data->conf->season[i].ndays);
03278 (void) xmlFree(val);
03279 }
03280 else
03281 data->conf->season[i].ndays = 10;
03282
03284 (void) sprintf(path, "/configuration/%s/%s[@id=\"%d\"]", "setting", "number_of_days_choices", i+1);
03285 val = xml_get_setting(conf, path);
03286 if (val != NULL) {
03287 data->conf->season[i].ndayschoices = xmlXPathCastStringToNumber(val);
03288 (void) fprintf(stdout, "%s: season #%d number_of_days_choices = %d\n", __FILE__, i+1, data->conf->season[i].ndayschoices);
03289 (void) xmlFree(val);
03290 }
03291 else
03292 if (i == 0 || i == 1)
03293 data->conf->season[i].ndayschoices = 16;
03294 else
03295 data->conf->season[i].ndayschoices = 11;
03296
03298 (void) sprintf(path, "/configuration/%s/%s[@id=\"%d\"]", "setting", "number_of_days_choices_min", i+1);
03299 val = xml_get_setting(conf, path);
03300 if (val != NULL) {
03301 data->conf->season[i].ndayschoices_min = xmlXPathCastStringToNumber(val);
03302 (void) fprintf(stdout, "%s: season #%d number_of_days_choices_min = %d\n", __FILE__, i+1, data->conf->season[i].ndayschoices_min);
03303 (void) xmlFree(val);
03304 }
03305 else
03306 data->conf->season[i].ndayschoices_min = 5;
03307 if (data->conf->season[i].ndayschoices_min > data->conf->season[i].ndayschoices) {
03308 (void) fprintf(stderr, "%s: WARNING: number_of_days_choices_min (%d) > number_of_days_choices (%d). Setting number_of_days_choices_min = number_of_days_choices (%d)\n", __FILE__, data->conf->season[i].ndayschoices_min, data->conf->season[i].ndayschoices, data->conf->season[i].ndayschoices);
03309 data->conf->season[i].ndayschoices_min = data->conf->season[i].ndayschoices;
03310 }
03311
03313 (void) sprintf(path, "/configuration/%s/%s[@id=\"%d\"]", "setting", "days_shuffle", i+1);
03314 val = xml_get_setting(conf, path);
03315 if (val != NULL) {
03316 data->conf->season[i].shuffle = xmlXPathCastStringToNumber(val);
03317 (void) fprintf(stdout, "%s: season #%d days_shuffle = %d\n", __FILE__, i+1, data->conf->season[i].shuffle);
03318 (void) xmlFree(val);
03319 }
03320 else
03321 if (i == 0 || i == 1)
03322 data->conf->season[i].shuffle = TRUE;
03323 else
03324 data->conf->season[i].shuffle = FALSE;
03325
03327 (void) sprintf(path, "/configuration/%s/%s[@id=\"%d\"]", "setting", "secondary_field_choice", i+1);
03328 val = xml_get_setting(conf, path);
03329 if (val != NULL) {
03330 data->conf->season[i].secondary_choice = xmlXPathCastStringToNumber(val);
03331 (void) fprintf(stdout, "%s: season #%d secondary_field_choice = %d\n", __FILE__, i+1, data->conf->season[i].secondary_choice);
03332 (void) xmlFree(val);
03333 }
03334 else
03335 if (i == 0 || i == 1)
03336 data->conf->season[i].secondary_choice = FALSE;
03337 else
03338 data->conf->season[i].secondary_choice = TRUE;
03339
03341 (void) sprintf(path, "/configuration/%s/%s[@id=\"%d\"]", "setting", "secondary_field_main_choice", i+1);
03342 val = xml_get_setting(conf, path);
03343 if (val != NULL) {
03344 data->conf->season[i].secondary_main_choice = xmlXPathCastStringToNumber(val);
03345 (void) fprintf(stdout, "%s: season #%d secondary_field_main_choice = %d\n", __FILE__, i+1, data->conf->season[i].secondary_main_choice);
03346 (void) xmlFree(val);
03347 }
03348 else
03349 if (data->conf->season[i].secondary_choice == FALSE)
03350 data->conf->season[i].secondary_main_choice = TRUE;
03351 else
03352 data->conf->season[i].secondary_main_choice = FALSE;
03353
03355 (void) sprintf(path, "/configuration/%s/%s[@id=\"%d\"]", "setting", "secondary_covariance", i+1);
03356 val = xml_get_setting(conf, path);
03357 if (val != NULL) {
03358 data->conf->season[i].secondary_cov = xmlXPathCastStringToNumber(val);
03359 (void) fprintf(stdout, "%s: season #%d secondary_covariance = %d\n", __FILE__, i+1, data->conf->season[i].secondary_cov);
03360 (void) xmlFree(val);
03361 }
03362 else
03363 data->conf->season[i].secondary_cov = FALSE;
03364
03366 (void) sprintf(path, "/configuration/%s/%s[@id=\"%d\"]/@nmonths", "setting", "season", i+1);
03367 val = xml_get_setting(conf, path);
03368 if (val != NULL) {
03369 data->conf->season[i].nmonths = xmlXPathCastStringToNumber(val);
03370 (void) fprintf(stdout, "%s: season #%d number_of_months = %d\n", __FILE__, i+1, data->conf->season[i].nmonths);
03371 data->conf->season[i].month = (int *) malloc(data->conf->season[i].nmonths * sizeof(int));
03372 if (data->conf->season[i].month == NULL) alloc_error(__FILE__, __LINE__);
03373 (void) sprintf(path, "/configuration/%s/%s[@id=\"%d\"]", "setting", "season", i+1);
03374 (void) xmlFree(val);
03375 val = xml_get_setting(conf, path);
03376 if (val != NULL) {
03377 token = NULL;
03378 token = strtok_r((char *) val, " ", &saveptr);
03379 for (j=0; j<data->conf->season[i].nmonths; j++) {
03380 if (token != NULL) {
03381 (void) sscanf(token, "%d", &(data->conf->season[i].month[j]));
03382 (void) fprintf(stdout, "%s: season #%d month=%d\n", __FILE__, i+1, data->conf->season[i].month[j]);
03383 token = strtok_r(NULL, " ", &saveptr);
03384 }
03385 }
03386 (void) xmlFree(val);
03387 }
03388 }
03389 else
03390 data->conf->season[i].nmonths = 0;
03391 }
03392 }
03393 else {
03394 (void) fprintf(stderr, "%s: Invalid number_of_seasons value %s in configuration file. Aborting.\n", __FILE__, val);
03395 return -1;
03396 }
03397
03398
03399
03401 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "output_only");
03402 val = xml_get_setting(conf, path);
03403 if (val != NULL)
03404 data->conf->output_only = (int) strtol((char *) val, (char **)NULL, 10);
03405 else
03406 data->conf->output_only = FALSE;
03407 if (data->conf->output_only != FALSE && data->conf->output_only != TRUE) {
03408 (void) fprintf(stderr, "%s: Invalid or missing analog data output_only value %s in configuration file. Aborting.\n", __FILE__, val);
03409 return -1;
03410 }
03411 (void) fprintf(stdout, "%s: analog data output_only=%d\n", __FILE__, data->conf->output_only);
03412 if (val != NULL)
03413 (void) xmlFree(val);
03414 if (data->conf->output_only == TRUE) {
03415 if (data->learning->learning_provided == FALSE) {
03416 (void) fprintf(stderr, "%s: WARNING: Desactivating learning process because option for output only has been set!\n", __FILE__);
03417 data->learning->learning_provided = TRUE;
03418 }
03419 if (data->learning->learning_save == TRUE) {
03420 (void) fprintf(stderr, "%s: WARNING: Desactivating learning save process because option for output only has been set!\n", __FILE__);
03421 data->learning->learning_save = FALSE;
03422 }
03423 if (data->conf->learning_maskfile->use_mask == TRUE) {
03424 (void) fprintf(stderr, "%s: WARNING: Desactivating use_mask for learning because option for output only has been set!\n", __FILE__);
03425 data->conf->learning_maskfile->use_mask = FALSE;
03426 }
03427 if (data->reg->reg_save == TRUE) {
03428 (void) fprintf(stderr, "%s: WARNING: Desactivating regression save process because option for output only has been set!\n", __FILE__);
03429 data->reg->reg_save = FALSE;
03430 }
03431 if (data->secondary_mask->use_mask == TRUE) {
03432 (void) fprintf(stderr, "%s: WARNING: Desactivating use_mask for secondary large-scale fields because option for output only has been set!\n", __FILE__);
03433 data->secondary_mask->use_mask = FALSE;
03434 }
03435 }
03436
03438 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "output_downscaling_data");
03439 val = xml_get_setting(conf, path);
03440 if (val != NULL)
03441 data->conf->output = (int) strtol((char *) val, (char **)NULL, 10);
03442 else
03443 data->conf->output = TRUE;
03444 if (data->conf->output != FALSE && data->conf->output != TRUE) {
03445 (void) fprintf(stderr, "%s: Invalid or missing downscaling output_downscaling_data value %s in configuration file. Aborting.\n", __FILE__, val);
03446 return -1;
03447 }
03448 (void) fprintf(stdout, "%s: downscaling output_downscaling_data=%d\n", __FILE__, data->conf->output);
03449 if (val != NULL)
03450 (void) xmlFree(val);
03451
03453 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "analog_save");
03454 val = xml_get_setting(conf, path);
03455 if (val != NULL)
03456 data->conf->analog_save = (int) strtol((char *) val, (char **)NULL, 10);
03457 else
03458 data->conf->analog_save = FALSE;
03459 if (data->conf->analog_save != FALSE && data->conf->analog_save != TRUE) {
03460 (void) fprintf(stderr, "%s: Invalid or missing analog data analog_save value %s in configuration file. Aborting.\n", __FILE__, val);
03461 return -1;
03462 }
03463 (void) fprintf(stdout, "%s: analog data analog_save=%d\n", __FILE__, data->conf->analog_save);
03464 if (val != NULL)
03465 (void) xmlFree(val);
03466
03468 if ( (data->conf->analog_save == TRUE || data->conf->output_only == TRUE) && data->conf->period_ctrl->downscale == TRUE) {
03469 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "analog_file_ctrl");
03470 val = xml_get_setting(conf, path);
03471 if (val != NULL) {
03472 data->conf->analog_file_ctrl = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
03473 if (data->conf->analog_file_ctrl == NULL) alloc_error(__FILE__, __LINE__);
03474 (void) strcpy(data->conf->analog_file_ctrl, (char *) val);
03475 (void) fprintf(stdout, "%s: analog_file_ctrl = %s\n", __FILE__, data->conf->analog_file_ctrl);
03476 (void) xmlFree(val);
03477 }
03478 else {
03479 (void) fprintf(stderr, "%s: Missing analog_file_ctrl setting. Aborting.\n", __FILE__);
03480 (void) xmlFree(val);
03481 return -1;
03482 }
03483 }
03484
03486 if (data->conf->analog_save == TRUE || data->conf->output_only == TRUE) {
03487 (void) sprintf(path, "/configuration/%s[@name=\"%s\"]", "setting", "analog_file_other");
03488 val = xml_get_setting(conf, path);
03489 if (val != NULL) {
03490 data->conf->analog_file_other = (char *) malloc((xmlStrlen(val)+1) * sizeof(char));
03491 if (data->conf->analog_file_other == NULL) alloc_error(__FILE__, __LINE__);
03492 (void) strcpy(data->conf->analog_file_other, (char *) val);
03493 (void) fprintf(stdout, "%s: analog_file_other = %s\n", __FILE__, data->conf->analog_file_other);
03494 (void) xmlFree(val);
03495 }
03496 else {
03497 (void) fprintf(stderr, "%s: Missing analog_file_other setting. Aborting.\n", __FILE__);
03498 (void) xmlFree(val);
03499 return -1;
03500 }
03501 }
03502
03503
03504 for (i=0; i<data->conf->obs_var->nobs_var; i++) {
03505 if (strcmp(data->conf->obs_var->netcdfname[i], "rsds") && strcmp(data->conf->obs_var->clim[i], "no") )
03506 for (ii=0; ii<data->conf->nseasons; ii++)
03507 if (data->conf->season[ii].ndays > 10)
03508 fprintf(stderr, "%s: WARNING: Number of days to search around downscaled date is greater than 10 at +-%d days and Global Solar Radiation output variable has not the clim setting set to yes.\n", __FILE__, data->conf->season[i].ndays);
03509 }
03510
03511
03512 (void) xml_free_config(conf);
03513 (void) xmlCleanupParser();
03514 (void) free(path);
03515
03516
03517 return 0;
03518 }