1: /* 2: file: splicer_defaults.c 3: 4: These functions are used for reading and writing the 5: default files for splicer programs. 6: 7: */ 8: #include <stdio.h> 9: #include <stdlib.h> 10: #include <Xm/Xm.h> 11: #include <malloc.h> 12: #include <math.h> 13: #include <string.h> 14: #include "splicer-creation-c.h" 15: #include "splicer_vars.h" 16: 17: #define MAXLINE (1000) 18: 19: void Spcheck_defaults() 20: { 21: /* this function will eventually check for valid defaults */ 22: } 23: 24: /* Function Name: Spread_defaults 25: * 26: * Description: This function reads the set defaults from the 27: * supplied input file. 28: * 29: * 30: * Arguments: char *filename: name of defaults file 31: */ 32: int Spread_defaults(filename) 33: char *filename; 34: { 35: FILE *fptr; 36: char line[MAXLINE],flag[MAXLINE],equal[2],value[MAXLINE]; 37: /* set automatic defaults */ 38: if((outdata_filename= (char*)calloc(25,CHAR_SIZE))==NULL) 39: SpBadMemAlloc("Spread_defaults 0"); 40: (void)strcpy(outdata_filename,"out.dat"); 41: if((outdata_dirname= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 42: SpBadMemAlloc("Spread_defaults 0a"); 43: (void)strcpy(outdata_dirname,current_path); 44: if((outspdata_filename= (char*)calloc(50,CHAR_SIZE))==NULL) 45: SpBadMemAlloc("Spread_defaults 0b"); 46: (void)strcpy(outspdata_filename,"splice.dat"); 47: if((outspdata_dirname= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 48: SpBadMemAlloc("Spread_defaults 0c"); 49: (void)strcpy(outspdata_dirname,current_path); 50: if((outstrat.filename= (char*)calloc(50,CHAR_SIZE))==NULL) 51: SpBadMemAlloc("Spread_defaults 0d"); 52: (void)strcpy(outstrat.filename,"strat.dat"); 53: if((outstrat.dirname= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 54: SpBadMemAlloc("Spread_defaults 0e"); 55: (void)strcpy(outstrat.dirname,current_path); 56: if((report_filename= (char*)calloc((int)strlen(current_path)+20,CHAR_SIZE))==NULL) 57: SpBadMemAlloc("Spread_defaults 0d"); 58: (void)sprintf(report_filename,"%s/splicer.rpt", current_path); 59: if((report_dirname= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 60: SpBadMemAlloc("Spread_defaults 0e"); 61: (void)strcpy(report_dirname,current_path); 62: 63: /* smooth values */ 64: smooth.method=NONE; 65: smooth.plot=UNSMOOTHED; 66: smooth.width=9; 67: smooth.width_units=POINTS; 68: /* decimate_value */ 69: decimate_value=1; 70: /* affine table values */ 71: if((affine.filename= (char*)calloc(50,CHAR_SIZE))==NULL) 72: SpBadMemAlloc("Spread_defaults 1"); 73: (void)strcpy(affine.filename,"aff.out"); 74: if((affine.dirname= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 75: SpBadMemAlloc("SpInitialize 2"); 76: (void)strcpy(affine.dirname,current_path); 77: affine.usetable=FALSE; 78: /* cull values */ 79: cull.method=CULL_PARAMETERS; 80: cull.top=5.0; 81: cull.max_core=999; 82: cull.by_core_num=False; 83: if((cull.filename= (char*)calloc(50,CHAR_SIZE))==NULL) 84: SpBadMemAlloc("Spread_defaults 0b"); 85: (void)strcpy(cull.filename,"culltable.dat"); 86: if((cull.dirname= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 87: SpBadMemAlloc("Spread_defaults 0c"); 88: (void)strcpy(cull.dirname,current_path); 89: cull.grape.sign1=LESS_THAN_OR_EQUAL_TO; 90: cull.grape.sign2=GREATER_THAN_OR_EQUAL_TO; 91: cull.grape.join=OR; 92: cull.grape.value1=1.03; 93: cull.grape.value2=2.8; 94: cull.pwave.sign1=LESS_THAN; 95: cull.pwave.sign2=GREATER_THAN_OR_EQUAL_TO; 96: cull.pwave.join=ONLY; 97: cull.pwave.value1=1500.0; 98: cull.pwave.value2=99999.0; 99: cull.pwave_signal_max=167.0; 100: cull.susceptibility.sign1=LESS_THAN; 101: cull.susceptibility.sign2=GREATER_THAN; 102: cull.susceptibility.join=ONLY; 103: cull.susceptibility.value1=-10.0; 104: cull.susceptibility.value2=99999.0; 105: cull.naturalgamma.sign1=LESS_THAN; 106: cull.naturalgamma.sign2=GREATER_THAN_OR_EQUAL_TO; 107: cull.naturalgamma.join=ONLY; 108: cull.naturalgamma.value1=0.0; 109: cull.naturalgamma.value2=99999.0; 110: cull.reflectance.sign1=LESS_THAN_OR_EQUAL_TO; 111: cull.reflectance.sign2=GREATER_THAN_OR_EQUAL_TO; 112: cull.reflectance.join=OR; 113: cull.reflectance.value1=0.0; 114: cull.reflectance.value2=100.0; 115: cull.otherodp.sign1=LESS_THAN; 116: cull.otherodp.sign2=GREATER_THAN; 117: cull.otherodp.join=OR; 118: cull.otherodp.value1=-99999.0; 119: cull.otherodp.value2=99999.0; 120: /* data type */ 121: openfileinfo.in_data_type=GRAPE; 122: /* data format */ 123: openfileinfo.in_data_format=MST95REPORT; 124: /* open data directory */ 125: if((open_data_directory= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 126: SpBadMemAlloc("SpInitialize 6a"); 127: (void)strcpy(open_data_directory,current_path); 128: /* splicer table file */ 129: if((splicertable.filename= (char*)calloc(50,CHAR_SIZE))==NULL) 130: SpBadMemAlloc("SpInitialize 5"); 131: (void)strcpy(splicertable.filename,"splicertable.dat"); 132: if((splicertable.dirname= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 133: SpBadMemAlloc("SpInitialize 6"); 134: (void)strcpy(splicertable.dirname,current_path); 135: /* strat directory */ 136: if((default_strat_dirname= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 137: SpBadMemAlloc("SpInitialize 6"); 138: (void)strcpy(default_strat_dirname,current_path); 139: /*age model file and directory */ 140: if((inagemodel_dirname= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 141: SpBadMemAlloc("SpInitialize 6"); 142: (void)strcpy(inagemodel_dirname,current_path); 143: if((inagemodel_filename= (char*)calloc((int)strlen(current_path)+20,CHAR_SIZE))==NULL) 144: SpBadMemAlloc("SpInitialize 6"); 145: (void)strcpy(inagemodel_filename,current_path); 146: (void)strcat(inagemodel_filename, "/age.out"); 147: if((outagemodel_dirname= (char*)calloc((int)strlen(inagemodel_dirname)+5,CHAR_SIZE))==NULL) 148: SpBadMemAlloc("SpInitialize 6"); 149: (void)strcpy(outagemodel_dirname,inagemodel_dirname); 150: if((outagemodel_filename= (char*)calloc((int)strlen(inagemodel_filename)+2,CHAR_SIZE))==NULL) 151: SpBadMemAlloc("SpInitialize 6"); 152: (void)strcpy(outagemodel_filename,inagemodel_filename); 153: /*time series filename and directory */ 154: if((timeseries.dirname= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 155: SpBadMemAlloc("SpInitialize 6"); 156: (void)strcpy(timeseries.dirname,current_path); 157: if((timeseries.filename= (char*)calloc((int)strlen(current_path)+20,CHAR_SIZE))==NULL) 158: SpBadMemAlloc("SpInitialize 6"); 159: (void)strcpy(timeseries.filename,current_path); 160: (void)strcat(timeseries.filename, "/berger.orb"); 161: /* splice vs age filename and directory */ 162: if((outsplicetoage_dirname= (char*)calloc((int)strlen(current_path)+5,CHAR_SIZE))==NULL) 163: SpBadMemAlloc("SpInitialize 6"); 164: (void)strcpy(outsplicetoage_dirname,current_path); 165: if((outsplicetoage_filename= (char*)calloc((int)strlen(current_path)+20,CHAR_SIZE))==NULL) 166: SpBadMemAlloc("SpInitialize 6"); 167: (void)strcpy(outsplicetoage_filename,current_path); 168: (void)strcat(outsplicetoage_filename, "/splice.age"); 169: /* text report*/ 170: if((report.name = (char*)calloc(25,CHAR_SIZE))==NULL) 171: SpBadMemAlloc("SpInitialize 6b"); 172: (void)strcpy(report.name,"splicer.rpt"); 173: /* color stuff */ 174: colorset = CUSTOME_COLORSET; 175: (void)strcpy(cust_color[BG_COLOR],"black"); 176: (void)strcpy(cust_color[LABEL_COLOR],"white"); 177: (void)strcpy(cust_color[MBSF_COLOR],"yellow"); 178: (void)strcpy(cust_color[MCD_COLOR],"green"); 179: (void)strcpy(cust_color[SMOOTH_COLOR],"pink"); 180: (void)strcpy(cust_color[SPLICE_COLOR],"turquoise"); 181: (void)strcpy(cust_color[SPLICELOCATION_COLOR],"white"); 182: (void)strcpy(cust_color[TIEPTFIXED_COLOR],"red"); 183: (void)strcpy(cust_color[TIEPTSHIFT_COLOR],"green"); 184: (void)strcpy(cust_color[TIELINE_COLOR],"orange"); 185: (void)strcpy(cust_color[OVERLAYINCORR_COLOR],"turquoise"); 186: (void)strcpy(cust_color[OVERLAYOUTCORR_COLOR],"green"); 187: (void)strcpy(cust_color[PALEOMAG_COLOR],"red"); 188: (void)strcpy(cust_color[DIATOM_COLOR],"limegreen"); 189: (void)strcpy(cust_color[RAD_COLOR],"white"); 190: (void)strcpy(cust_color[FORAM_COLOR],"pink"); 191: (void)strcpy(cust_color[NANNO_COLOR],"lightblue"); 192: (void)strcpy(cust_color[CORRCOEF_COLOR],"lightblue"); 193: (void)strcpy(cust_color[BESTCORR_COLOR],"yellow"); 194: (void)strcpy(cust_color[DEPOFFLINE_COLOR],"white"); 195: (void)strcpy(cust_color[DEPOFFHOLE1_COLOR],"pink"); 196: (void)strcpy(cust_color[DEPOFFHOLE2_COLOR],"green"); 197: (void)strcpy(cust_color[DEPOFFHOLE3_COLOR],"yellow"); 198: (void)strcpy(cust_color[DEPOFFHOLE4_COLOR],"blue"); 199: (void)strcpy(cust_color[DEPOFFHOLE5_COLOR],"orange"); 200: (void)strcpy(cust_color[DEPOFFHOLE6_COLOR],"violet"); 201: (void)strcpy(cust_color[DEPOFFHOLE7_COLOR],"red"); 202: (void)strcpy(cust_color[DEPOFFHOLE8_COLOR],"brown"); 203: (void)strcpy(cust_color[DEPOFFHOLE9_COLOR],"turquoise"); 204: (void)strcpy(cust_color[DEPOFFHOLE10_COLOR],"darkgreen"); 205: (void)strcpy(cust_color[DEPOFFHOLE11_COLOR],"lightblue"); 206: (void)strcpy(cust_color[AGEDEPHANDPICK_COLOR], "yellow"); 207: (void)strcpy(cust_color[AGEDEPLINE_COLOR], "red"); 208: (void)strcpy(cust_color[SEDRATE_COLOR], "green"); 209: (void)strcpy(cust_color[DATUMLOC_COLOR], "yellow"); 210: (void)strcpy(cust_color[TIMESERIES_COLOR], "red"); 211: clip = CLIP; 212: 213: /* open defaults file */ 214: if((fptr=fopen(filename,"r"))==NULL) 215: return(FALSE); 216: 217: /* loop through defaults file */ 218: while(fgets(line,MAXLINE,fptr)!=NULL) 219: { 220: /* check if valid defaults file */ 221: if(line[0]!= '#' && (int)strlen(line)>0) 222: { 223: if(sscanf(line,"%s %s %s",flag,equal,value)==3 && !strcmp(equal,"=")) 224: { 225: /* set default values */ 226: /* smoothing defaults */ 227: if(!strcmp(flag,"SMOOTH_METHOD")) 228: smooth.method= atoi(value); 229: else if(!strcmp(flag,"SMOOTH_PLOT")) 230: smooth.plot= atoi(value); 231: else if(!strcmp(flag,"SMOOTH_WIDTH")) 232: smooth.width=atoi(value); 233: else if(!strcmp(flag,"SMOOTH_WIDTH_UNITS")) 234: smooth.width_units=atoi(value); 235: /* decimate_values */ 236: else if(!strcmp(flag,"DECIMATE_VALUE")) 237: decimate_value=atoi(value); 238: /* affine table values */ 239: else if(!strcmp(flag,"USE_AFFINE_TABLE")) 240: affine.usetable=atoi(value); 241: else if(!strcmp(flag,"AFFINE_TABLE")) 242: { 243: if((charptr=(char*)realloc((char*)affine.filename,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 244: SpBadMemAlloc("SpInitialize 7"); 245: else 246: { 247: affine.filename=charptr; 248: (void)strcpy(affine.filename,value); 249: } 250: } 251: else if(!strcmp(flag,"AFFINE_DIRECTORY")) 252: { 253: if((charptr=(char*)realloc((char*)affine.dirname,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 254: SpBadMemAlloc("SpInitialize 8"); 255: else 256: { 257: affine.dirname=charptr; 258: (void)strcpy(affine.dirname,value); 259: } 260: } 261: /* cull values */ 262: else if(!strcmp(flag,"CULL_METHOD")) 263: cull.method=atoi(value); 264: else if(!strcmp(flag,"CULL_TOP")) 265: (void)sscanf(value,"%f",&cull.top); 266: else if(!strcmp(flag,"CULL_BY_CORE_NUM")) 267: (void)sscanf(value,"%d",&cull.by_core_num); 268: else if(!strcmp(flag,"CULL_CORE_MAX")) 269: (void)sscanf(value,"%d",&cull.max_core); 270: else if(!strcmp(flag,"CULL_TABLE")) 271: { 272: if((charptr=(char*)realloc((char*)cull.filename,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 273: SpBadMemAlloc("SpInitialize 9"); 274: else 275: { 276: cull.filename=charptr; 277: (void)strcpy(cull.filename,value); 278: } 279: } 280: else if(!strcmp(flag,"CULL_DIRECTORY")) 281: { 282: if((charptr=(char*)realloc((char*)cull.dirname,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 283: SpBadMemAlloc("SpInitialize 10"); 284: else 285: { 286: cull.dirname=charptr; 287: (void)strcpy(cull.dirname,value); 288: } 289: } 290: else if(!strcmp(flag,"PWAVE_SIGNAL_MAX")) 291: cull.pwave_signal_max=(float)atof(value); 292: else if(!strcmp(flag,"GRAPE_EQUATION_1")) 293: cull.grape.sign1=atoi(value); 294: else if(!strcmp(flag,"GRAPE_EQUATION_2")) 295: cull.grape.sign2=atoi(value); 296: else if(!strcmp(flag,"GRAPE_JOIN")) 297: cull.grape.join=atoi(value); 298: else if(!strcmp(flag,"GRAPE_VALUE_1")) 299: cull.grape.value1=(float)atof(value); 300: else if(!strcmp(flag,"GRAPE_VALUE_2")) 301: cull.grape.value2=(float)atof(value); 302: else if(!strcmp(flag,"PWAVE_EQUATION_1")) 303: cull.pwave.sign1=atoi(value); 304: else if(!strcmp(flag,"PWAVE_EQUATION_2")) 305: cull.pwave.sign2=atoi(value); 306: else if(!strcmp(flag,"PWAVE_JOIN")) 307: cull.pwave.join=atoi(value); 308: else if(!strcmp(flag,"PWAVE_VALUE_1")) 309: cull.pwave.value1=(float)atof(value); 310: else if(!strcmp(flag,"PWAVE_VALUE_2")) 311: cull.pwave.value2=(float)atof(value); 312: else if(!strcmp(flag,"SUSCEPTIBILITY_EQUATION_1")) 313: cull.susceptibility.sign1=atoi(value); 314: else if(!strcmp(flag,"SUSCEPTIBILITY_EQUATION_2")) 315: cull.susceptibility.sign2=atoi(value); 316: else if(!strcmp(flag,"SUSCEPTIBILITY_JOIN")) 317: cull.susceptibility.join=atoi(value); 318: else if(!strcmp(flag,"SUSCEPTIBILITY_VALUE_1")) 319: cull.susceptibility.value1=(float)atof(value); 320: else if(!strcmp(flag,"SUSCEPTIBILITY_VALUE_2")) 321: cull.susceptibility.value2=(float)atof(value); 322: else if(!strcmp(flag,"NATURALGAMMA_EQUATION_1")) 323: cull.naturalgamma.sign1=atoi(value); 324: else if(!strcmp(flag,"NATURALGAMMA_EQUATION_2")) 325: cull.naturalgamma.sign2=atoi(value); 326: else if(!strcmp(flag,"NATURALGAMMA_JOIN")) 327: cull.naturalgamma.join=atoi(value); 328: else if(!strcmp(flag,"NATURALGAMMA_VALUE_1")) 329: cull.naturalgamma.value1=(float)atof(value); 330: else if(!strcmp(flag,"NATURALGAMMA_VALUE_2")) 331: cull.naturalgamma.value2=(float)atof(value); 332: else if(!strcmp(flag,"REFLECTANCE_EQUATION_1")) 333: cull.reflectance.sign1=atoi(value); 334: else if(!strcmp(flag,"REFLECTANCE_EQUATION_2")) 335: cull.reflectance.sign2=atoi(value); 336: else if(!strcmp(flag,"REFLECTANCE_JOIN")) 337: cull.reflectance.join=atoi(value); 338: else if(!strcmp(flag,"REFLECTANCE_VALUE_1")) 339: cull.reflectance.value1=(float)atof(value); 340: else if(!strcmp(flag,"REFLECTANCE_VALUE_2")) 341: cull.reflectance.value2=(float)atof(value); 342: else if(!strcmp(flag,"OTHERODP_EQUATION_1")) 343: cull.otherodp.sign1=atoi(value); 344: else if(!strcmp(flag,"OTHERODP_EQUATION_2")) 345: cull.otherodp.sign2=atoi(value); 346: else if(!strcmp(flag,"OTHERODP_JOIN")) 347: cull.otherodp.join=atoi(value); 348: else if(!strcmp(flag,"OTHERODP_VALUE_1")) 349: cull.otherodp.value1=(float)atof(value); 350: else if(!strcmp(flag,"OTHERODP_VALUE_2")) 351: cull.otherodp.value2=(float)atof(value); 352: /* data type */ 353: else if(!strcmp(flag,"DATA_TYPE")) 354: openfileinfo.in_data_type=atoi(value); 355: /* data format */ 356: else if(!strcmp(flag,"IN_DATA_FORMAT")) 357: openfileinfo.in_data_format=atoi(value); 358: /* open data directory */ 359: else if(!strcmp(flag,"OPEN_DATA_DIRECTORY")) 360: { 361: if((charptr=(char*)realloc((char*)open_data_directory,((int)strlen(value)+2)*CHAR_SIZE 362: ))==NULL) 363: SpBadMemAlloc("SpInitialize 11a"); 364: else 365: { 366: open_data_directory=charptr; 367: (void)strcpy(open_data_directory,value); 368: } 369: } 370: /* splicer table */ 371: else if(!strcmp(flag,"SPLICER_TABLE")) 372: { 373: if((charptr=(char*)realloc((char*)splicertable.filename,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 374: SpBadMemAlloc("SpInitialize 11"); 375: else 376: { 377: splicertable.filename=charptr; 378: (void)strcpy(splicertable.filename,value); 379: } 380: } 381: else if(!strcmp(flag,"SPLICER_DIRECTORY")) 382: { 383: if((charptr=(char*)realloc((char*)splicertable.dirname,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 384: SpBadMemAlloc("SpInitialize 12"); 385: else 386: { 387: splicertable.dirname=charptr; 388: (void)strcpy(splicertable.dirname,value); 389: } 390: } 391: else if(!strcmp(flag,"STRAT_DIRECTORY")) 392: { 393: if((charptr=(char*)realloc((char*)default_strat_dirname,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 394: SpBadMemAlloc("SpInitialize 12"); 395: else 396: { 397: default_strat_dirname=charptr; 398: (void)strcpy(default_strat_dirname,value); 399: } 400: } 401: else if(!strcmp(flag,"AGEMODEL_FILE")) 402: { 403: if((charptr=(char*)realloc((char*)inagemodel_filename,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 404: SpBadMemAlloc("SpInitialize 12"); 405: else 406: { 407: inagemodel_filename=charptr; 408: (void)strcpy(inagemodel_filename,value); 409: if((charptr=(char*)realloc((char*)outagemodel_filename,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 410: SpBadMemAlloc("SpInitialize 12"); 411: else 412: { 413: outagemodel_filename=charptr; 414: (void)strcpy(outagemodel_filename,value); 415: } 416: } 417: } 418: else if(!strcmp(flag,"AGEMODEL_DIRECTORY")) 419: { 420: if((charptr=(char*)realloc((char*)inagemodel_dirname,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 421: SpBadMemAlloc("SpInitialize 12"); 422: else 423: { 424: inagemodel_dirname=charptr; 425: (void)strcpy(inagemodel_dirname,value); 426: if((charptr=(char*)realloc((char*)outagemodel_dirname,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 427: SpBadMemAlloc("SpInitialize 12"); 428: else 429: { 430: outagemodel_dirname=charptr; 431: (void)strcpy(outagemodel_dirname,value); 432: } 433: } 434: } 435: else if(!strcmp(flag,"TIMESERIES_FILE")) 436: { 437: if((charptr=(char*)realloc((char*)timeseries.filename,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 438: SpBadMemAlloc("SpInitialize 12"); 439: else 440: { 441: timeseries.filename=charptr; 442: (void)strcpy(timeseries.filename,value); 443: } 444: } 445: else if(!strcmp(flag,"TIMESERIES_DIRECTORY")) 446: { 447: if((charptr=(char*)realloc((char*)timeseries.dirname,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 448: SpBadMemAlloc("SpInitialize 12"); 449: else 450: { 451: timeseries.dirname=charptr; 452: (void)strcpy(timeseries.dirname,value); 453: } 454: } 455: else if(!strcmp(flag,"COMPOSITE_DATA_FILE")) 456: { 457: if((charptr=(char*)realloc((char*)outdata_filename,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 458: SpBadMemAlloc("SpInitialize 12"); 459: else 460: { 461: outdata_filename=charptr; 462: (void)strcpy(outdata_filename,value); 463: } 464: } 465: else if(!strcmp(flag,"COMPOSITE_DATA_DIRECTORY")) 466: { 467: if((charptr=(char*)realloc((char*)outdata_dirname,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 468: SpBadMemAlloc("SpInitialize 12"); 469: else 470: { 471: outdata_dirname=charptr; 472: (void)strcpy(outdata_dirname,value); 473: } 474: } 475: else if(!strcmp(flag,"SPLICE_FILE")) 476: { 477: if((charptr=(char*)realloc((char*)outspdata_filename,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 478: SpBadMemAlloc("SpInitialize 12"); 479: else 480: { 481: outspdata_filename=charptr; 482: (void)strcpy(outspdata_filename,value); 483: } 484: } 485: else if(!strcmp(flag,"SPLICE_DIRECTORY")) 486: { 487: if((charptr=(char*)realloc((char*)outspdata_dirname,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 488: SpBadMemAlloc("SpInitialize 12"); 489: else 490: { 491: outspdata_dirname=charptr; 492: (void)strcpy(outspdata_dirname,value); 493: } 494: } 495: else if(!strcmp(flag,"SPLICEVSAGE_FILE")) 496: { 497: if((charptr=(char*)realloc((char*)outsplicetoage_filename,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 498: SpBadMemAlloc("SpInitialize 12"); 499: else 500: { 501: outsplicetoage_filename=charptr; 502: (void)strcpy(outsplicetoage_filename,value); 503: } 504: } 505: else if(!strcmp(flag,"SPLICEVSAGE_DIRECTORY")) 506: { 507: if((charptr=(char*)realloc((char*)outsplicetoage_dirname,((int)strlen(value)+2)*CHAR_SIZE))==NULL) 508: SpBadMemAlloc("SpInitialize 12"); 509: else 510: { 511: outsplicetoage_dirname=charptr; 512: (void)strcpy(outsplicetoage_dirname,value); 513: } 514: } 515: 516: /* color defaults */ 517: else if(!strcmp(flag,"COLORSET")) 518: colorset = atoi(value); 519: else if(!strcmp(flag,"BG_COLOR")) 520: (void)strcpy(cust_color[BG_COLOR],value); 521: else if(!strcmp(flag,"LABEL_COLOR")) 522: (void)strcpy(cust_color[LABEL_COLOR],value); 523: else if(!strcmp(flag,"MBSF_COLOR")) 524: (void)strcpy(cust_color[MBSF_COLOR],value); 525: else if(!strcmp(flag,"MCD_COLOR")) 526: (void)strcpy(cust_color[MCD_COLOR],value); 527: else if(!strcmp(flag,"SMOOTH_COLOR")) 528: (void)strcpy(cust_color[SMOOTH_COLOR],value); 529: else if(!strcmp(flag,"SPLICE_COLOR")) 530: (void)strcpy(cust_color[SPLICE_COLOR],value); 531: else if(!strcmp(flag,"SPLICELOCATION_COLOR")) 532: (void)strcpy(cust_color[SPLICELOCATION_COLOR],value); 533: else if(!strcmp(flag,"TIEPTFIXED_COLOR")) 534: (void)strcpy(cust_color[TIEPTFIXED_COLOR],value); 535: else if(!strcmp(flag,"TIEPTSHIFT_COLOR")) 536: (void)strcpy(cust_color[TIEPTSHIFT_COLOR],value); 537: else if(!strcmp(flag,"TIELINE_COLOR")) 538: (void)strcpy(cust_color[TIELINE_COLOR],value); 539: else if(!strcmp(flag,"OVERLAYINCORR_COLOR")) 540: (void)strcpy(cust_color[OVERLAYINCORR_COLOR],value); 541: else if(!strcmp(flag,"OVERLAYOUTCORR_COLOR")) 542: (void)strcpy(cust_color[OVERLAYOUTCORR_COLOR],value); 543: else if(!strcmp(flag,"PALEOMAG_COLOR")) 544: (void)strcpy(cust_color[PALEOMAG_COLOR],value); 545: else if(!strcmp(flag,"DIATOM_COLOR")) 546: (void)strcpy(cust_color[DIATOM_COLOR],value); 547: else if(!strcmp(flag,"RAD_COLOR")) 548: (void)strcpy(cust_color[RAD_COLOR],value); 549: else if(!strcmp(flag,"FORAM_COLOR")) 550: (void)strcpy(cust_color[FORAM_COLOR],value); 551: else if(!strcmp(flag,"NANNO_COLOR")) 552: (void)strcpy(cust_color[NANNO_COLOR],value); 553: else if(!strcmp(flag,"CORRCOEF_COLOR")) 554: (void)strcpy(cust_color[CORRCOEF_COLOR],value); 555: else if(!strcmp(flag,"BESTCORR_COLOR")) 556: (void)strcpy(cust_color[BESTCORR_COLOR],value); 557: else if(!strcmp(flag,"DEPOFFLINE_COLOR")) 558: (void)strcpy(cust_color[DEPOFFLINE_COLOR],value); 559: else if(!strcmp(flag,"DEPOFFHOLE1_COLOR")) 560: (void)strcpy(cust_color[DEPOFFHOLE1_COLOR],value); 561: else if(!strcmp(flag,"DEPOFFHOLE2_COLOR")) 562: (void)strcpy(cust_color[DEPOFFHOLE2_COLOR],value); 563: else if(!strcmp(flag,"DEPOFFHOLE3_COLOR")) 564: (void)strcpy(cust_color[DEPOFFHOLE3_COLOR],value); 565: else if(!strcmp(flag,"DEPOFFHOLE4_COLOR")) 566: (void)strcpy(cust_color[DEPOFFHOLE4_COLOR],value); 567: else if(!strcmp(flag,"DEPOFFHOLE5_COLOR")) 568: (void)strcpy(cust_color[DEPOFFHOLE5_COLOR],value); 569: else if(!strcmp(flag,"DEPOFFHOLE6_COLOR")) 570: (void)strcpy(cust_color[DEPOFFHOLE6_COLOR],value); 571: else if(!strcmp(flag,"DEPOFFHOLE7_COLOR")) 572: (void)strcpy(cust_color[DEPOFFHOLE7_COLOR],value); 573: else if(!strcmp(flag,"DEPOFFHOLE8_COLOR")) 574: (void)strcpy(cust_color[DEPOFFHOLE8_COLOR],value); 575: else if(!strcmp(flag,"DEPOFFHOLE9_COLOR")) 576: (void)strcpy(cust_color[DEPOFFHOLE9_COLOR],value); 577: else if(!strcmp(flag,"DEPOFFHOLE10_COLOR")) 578: (void)strcpy(cust_color[DEPOFFHOLE10_COLOR],value); 579: else if(!strcmp(flag,"DEPOFFHOLE11_COLOR")) 580: (void)strcpy(cust_color[DEPOFFHOLE11_COLOR],value); 581: else if(!strcmp(flag,"AGEDEPHANDPICK_COLOR")) 582: (void)strcpy(cust_color[AGEDEPHANDPICK_COLOR],value); 583: else if(!strcmp(flag,"AGEDEPLINE_COLOR")) 584: (void)strcpy(cust_color[AGEDEPLINE_COLOR],value); 585: else if(!strcmp(flag,"SEDRATE_COLOR")) 586: (void)strcpy(cust_color[SEDRATE_COLOR],value); 587: else if(!strcmp(flag,"DATUMLOC_COLOR")) 588: (void)strcpy(cust_color[DATUMLOC_COLOR],value); 589: else if(!strcmp(flag,"TIMESERIES_COLOR")) 590: (void)strcpy(cust_color[TIMESERIES_COLOR],value); 591: else if(!strcmp(flag,"CLIP")) 592: clip=atoi(value); 593: /* unknown flag */ 594: else 595: (void)fprintf(stderr,"splicer: ERROR: Unknown defaults flag %s.\n",flag); 596: } 597: else 598: { 599: (void)fprintf(stderr,"splicer: ERROR: Unknown defaults file line type: "); 600: (void)fputs(line,stderr); 601: } 602: } 603: } 604: if(fptr!=NULL) fclose(fptr); 605: Spcheck_defaults(); 606: return(TRUE); 607: } 608: 609: 610: /* Function Name: Spwrite_defaults 611: * 612: * Description: This function writes the defaults values to the 613: * specified file. 614: * 615: * 616: * Arguments: FILE *fptr: defaults file pointer 617: */ 618: 619: void Spwrite_defaults(fptr) 620: FILE *fptr; 621: { 622: int len; 623: 624: /* information header */ 625: (void)fprintf(fptr,"#\n# %s\n#\n",SPLICER_VERSION); 626: 627: /* smoothing information */ 628: (void)fprintf(fptr,"SMOOTH_METHOD\t\t\t=\t%d\n",smooth.method); 629: if(smooth.method == NONE) { 630: smooth.plot = UNSMOOTHED; 631: } 632: else if(smooth.method == GAUSSIAN || smooth.method == OTHER) { 633: smooth.plot = SMOOTHEDBOTH; 634: } 635: (void)fprintf(fptr,"SMOOTH_PLOT\t\t\t=\t%d\n",smooth.plot); 636: (void)fprintf(fptr,"SMOOTH_WIDTH\t\t\t=\t%d\n",smooth.width); 637: (void)fprintf(fptr,"SMOOTH_WIDTH_UNITS\t\t=\t%d\n",smooth.width_units); 638: /* decimation information */ 639: (void)fprintf(fptr,"DECIMATE_VALUE\t\t\t=\t%d\n",decimate_value); 640: /* affine table information */ 641: (void)fprintf(fptr,"USE_AFFINE_TABLE\t\t=\t%d\n",affine.usetable); 642: (void)fprintf(fptr,"AFFINE_TABLE\t\t\t=\t%s\n",affine.filename); 643: len = (int)strlen(affine.dirname); 644: if(strcmp(&affine.dirname[len-1], "/") != 0) { 645: strcat(affine.dirname, "/"); 646: } 647: (void)fprintf(fptr,"AFFINE_DIRECTORY\t\t=\t%s\n",affine.dirname); 648: /* cull information */ 649: (void)fprintf(fptr,"CULL_METHOD\t\t\t=\t%d\n",cull.method); 650: (void)fprintf(fptr,"CULL_TOP\t\t\t=\t%.1f\n",cull.top); 651: (void)fprintf(fptr,"CULL_BY_CORE_NUM\t\t=\t%d\n",cull.by_core_num); 652: (void)fprintf(fptr,"CULL_CORE_MAX\t\t\t=\t%d\n",cull.max_core); 653: (void)fprintf(fptr,"CULL_TABLE\t\t\t=\t%s\n",cull.filename); 654: len = (int)strlen(cull.dirname); 655: if(strcmp(&cull.dirname[len-1], "/") != 0) { 656: strcat(cull.dirname, "/"); 657: } 658: (void)fprintf(fptr,"CULL_DIRECTORY\t\t\t=\t%s\n",cull.dirname); 659: (void)fprintf(fptr,"PWAVE_SIGNAL_MAX\t\t=\t%.1f\n",cull.pwave_signal_max); 660: (void)fprintf(fptr,"GRAPE_EQUATION_1\t\t=\t%d\n",cull.grape.sign1); 661: (void)fprintf(fptr,"GRAPE_VALUE_1\t\t\t=\t%.3f\n",cull.grape.value1); 662: (void)fprintf(fptr,"GRAPE_JOIN\t\t\t=\t%d\n",cull.grape.join); 663: (void)fprintf(fptr,"GRAPE_EQUATION_2\t\t=\t%d\n",cull.grape.sign2); 664: (void)fprintf(fptr,"GRAPE_VALUE_2\t\t\t=\t%.3f\n",cull.grape.value2); 665: (void)fprintf(fptr,"PWAVE_EQUATION_1\t\t=\t%d\n",cull.pwave.sign1); 666: (void)fprintf(fptr,"PWAVE_VALUE_1\t\t\t=\t%.3f\n",cull.pwave.value1); 667: (void)fprintf(fptr,"PWAVE_JOIN\t\t\t=\t%d\n",cull.pwave.join); 668: (void)fprintf(fptr,"PWAVE_EQUATION_2\t\t=\t%d\n",cull.pwave.sign2); 669: (void)fprintf(fptr,"PWAVE_VALUE_2\t\t\t=\t%.3f\n",cull.pwave.value2); 670: (void)fprintf(fptr,"SUSCEPTIBILITY_EQUATION_1\t=\t%d\n",cull.susceptibility.sign1); 671: (void)fprintf(fptr,"SUSCEPTIBILITY_VALUE_1\t\t=\t%.3f\n",cull.susceptibility.value1); 672: (void)fprintf(fptr,"SUSCEPTIBILITY_JOIN\t\t=\t%d\n",cull.susceptibility.join); 673: (void)fprintf(fptr,"SUSCEPTIBILITY_EQUATION_2\t=\t%d\n",cull.susceptibility.sign2); 674: (void)fprintf(fptr,"SUSCEPTIBILITY_VALUE_2\t\t=\t%.3f\n",cull.susceptibility.value2); 675: (void)fprintf(fptr,"NATURALGAMMA_EQUATION_1\t\t=\t%d\n",cull.naturalgamma.sign1); 676: (void)fprintf(fptr,"NATURALGAMMA_VALUE_1\t\t=\t%.3f\n",cull.naturalgamma.value1); 677: (void)fprintf(fptr,"NATURALGAMMA_JOIN\t\t=\t%d\n",cull.naturalgamma.join); 678: (void)fprintf(fptr,"NATURALGAMMA_EQUATION_2\t\t=\t%d\n",cull.naturalgamma.sign2); 679: (void)fprintf(fptr,"NATURALGAMMA_VALUE_2\t\t=\t%.3f\n",cull.naturalgamma.value2); 680: (void)fprintf(fptr,"REFLECTANCE_EQUATION_1\t\t=\t%d\n",cull.reflectance.sign1); 681: (void)fprintf(fptr,"REFLECTANCE_VALUE_1\t\t=\t%.3f\n",cull.reflectance.value1); 682: (void)fprintf(fptr,"REFLECTANCE_JOIN\t\t=\t%d\n",cull.reflectance.join); 683: (void)fprintf(fptr,"REFLECTANCE_EQUATION_2\t\t=\t%d\n",cull.reflectance.sign2); 684: (void)fprintf(fptr,"REFLECTANCE_VALUE_2\t\t=\t%.3f\n",cull.reflectance.value2); 685: (void)fprintf(fptr,"OTHERODP_EQUATION_1\t\t=\t%d\n",cull.otherodp.sign1); 686: (void)fprintf(fptr,"OTHERODP_VALUE_1\t\t=\t%.3f\n",cull.otherodp.value1); 687: (void)fprintf(fptr,"OTHERODP_JOIN\t\t\t=\t%d\n",cull.otherodp.join); 688: (void)fprintf(fptr,"OTHERODP_EQUATION_2\t\t=\t%d\n",cull.otherodp.sign2); 689: (void)fprintf(fptr,"OTHERODP_VALUE_2\t\t=\t%.3f\n",cull.otherodp.value2); 690: /* data type */ 691: (void)fprintf(fptr,"DATA_TYPE\t\t\t=\t%d\n",openfileinfo.in_data_type); 692: /* data format*/ 693: (void)fprintf(fptr,"IN_DATA_FORMAT\t\t\t=\t%d\n",openfileinfo.in_data_format); 694: /* open data directory */ 695: len = (int)strlen(open_data_directory); 696: if(strcmp(&open_data_directory[len-1], "/") != 0) { 697: strcat(open_data_directory, "/"); 698: } 699: (void)fprintf(fptr,"OPEN_DATA_DIRECTORY\t\t=\t%s\n",open_data_directory); 700: /* splicer table */ 701: (void)fprintf(fptr,"SPLICER_TABLE\t\t\t=\t%s\n",splicertable.filename); 702: len = (int)strlen(splicertable.dirname); 703: if(strcmp(&splicertable.dirname[len-1], "/") != 0) { 704: strcat(splicertable.dirname, "/"); 705: } 706: (void)fprintf(fptr,"SPLICER_DIRECTORY\t\t=\t%s\n",splicertable.dirname); 707: /* strat directory */ 708: len = (int)strlen(default_strat_dirname); 709: if(strcmp(&default_strat_dirname[len-1], "/") != 0) { 710: strcat(default_strat_dirname, "/"); 711: } 712: (void)fprintf(fptr,"STRAT_DIRECTORY\t\t\t=\t%s\n",default_strat_dirname); 713: /* agemodel file and directory */ 714: (void)fprintf(fptr,"AGEMODEL_FILE\t\t\t=\t%s\n",outagemodel_filename); 715: len = (int)strlen(outagemodel_dirname); 716: if(strcmp(&outagemodel_dirname[len-1], "/") != 0) { 717: strcat(outagemodel_dirname, "/"); 718: } 719: (void)fprintf(fptr,"AGEMODEL_DIRECTORY\t\t=\t%s\n",outagemodel_dirname); 720: /* time series file and directory */ 721: (void)fprintf(fptr,"TIMESERIES_FILE\t\t\t=\t%s\n",timeseries.filename); 722: len = (int)strlen(timeseries.dirname); 723: if(strcmp(×eries.dirname[len-1], "/") != 0) { 724: strcat(timeseries.dirname, "/"); 725: } 726: (void)fprintf(fptr,"TIMESERIES_DIRECTORY\t\t=\t%s\n",timeseries.dirname); 727: /* composite data file and directory */ 728: (void)fprintf(fptr,"COMPOSITE_DATA_FILE\t\t=\t%s\n",outdata_filename); 729: len = (int)strlen(outdata_dirname); 730: if(strcmp(&outdata_dirname[len-1], "/") != 0) { 731: strcat(outdata_dirname, "/"); 732: } 733: (void)fprintf(fptr,"COMPOSITE_DATA_DIRECTORY\t=\t%s\n",outdata_dirname); 734: /* splice file and directory */ 735: (void)fprintf(fptr,"SPLICE_FILE\t\t\t=\t%s\n",outspdata_filename); 736: len = (int)strlen(outspdata_dirname); 737: if(strcmp(&outspdata_dirname[len-1], "/") != 0) { 738: strcat(outspdata_dirname, "/"); 739: } 740: (void)fprintf(fptr,"SPLICE_DIRECTORY\t\t=\t%s\n",outspdata_dirname); 741: /* splice vs age file and directory */ 742: (void)fprintf(fptr,"SPLICEVSAGE_FILE\t\t=\t%s\n",outsplicetoage_filename); 743: len = (int)strlen(outsplicetoage_dirname); 744: if(strcmp(&outsplicetoage_dirname[len-1], "/") != 0) { 745: strcat(outsplicetoage_dirname, "/"); 746: } 747: (void)fprintf(fptr,"SPLICEVSAGE_DIRECTORY\t\t=\t%s\n",outsplicetoage_dirname); 748: /* color defaults */ 749: (void)fprintf(fptr,"COLORSET\t\t\t=\t%d\n",colorset); 750: (void)fprintf(fptr,"BG_COLOR\t\t\t=\t%s\n",cust_color[BG_COLOR]); 751: (void)fprintf(fptr,"LABEL_COLOR\t\t\t=\t%s\n",cust_color[LABEL_COLOR]); 752: (void)fprintf(fptr,"MBSF_COLOR\t\t\t=\t%s\n",cust_color[MBSF_COLOR]); 753: (void)fprintf(fptr,"MCD_COLOR\t\t\t=\t%s\n",cust_color[MCD_COLOR]); 754: (void)fprintf(fptr,"SMOOTH_COLOR\t\t\t=\t%s\n",cust_color[SMOOTH_COLOR]); 755: (void)fprintf(fptr,"SPLICE_COLOR\t\t\t=\t%s\n",cust_color[SPLICE_COLOR]); 756: (void)fprintf(fptr,"SPLICELOCATION_COLOR\t\t=\t%s\n",cust_color[SPLICELOCATION_COLOR]); 757: (void)fprintf(fptr,"TIEPTFIXED_COLOR\t\t=\t%s\n",cust_color[TIEPTFIXED_COLOR]); 758: (void)fprintf(fptr,"TIEPTSHIFT_COLOR\t\t=\t%s\n",cust_color[TIEPTSHIFT_COLOR]); 759: (void)fprintf(fptr,"TIELINE_COLOR\t\t\t=\t%s\n",cust_color[TIELINE_COLOR]); 760: (void)fprintf(fptr,"OVERLAYINCORR_COLOR\t\t=\t%s\n",cust_color[OVERLAYINCORR_COLOR]); 761: (void)fprintf(fptr,"OVERLAYOUTCORR_COLOR\t\t=\t%s\n",cust_color[OVERLAYOUTCORR_COLOR]); 762: (void)fprintf(fptr,"PALEOMAG_COLOR\t\t\t=\t%s\n",cust_color[PALEOMAG_COLOR]); 763: (void)fprintf(fptr,"DIATOM_COLOR\t\t\t=\t%s\n",cust_color[DIATOM_COLOR]); 764: (void)fprintf(fptr,"RAD_COLOR\t\t\t=\t%s\n",cust_color[RAD_COLOR]); 765: (void)fprintf(fptr,"FORAM_COLOR\t\t\t=\t%s\n",cust_color[FORAM_COLOR]); 766: (void)fprintf(fptr,"NANNO_COLOR\t\t\t=\t%s\n",cust_color[NANNO_COLOR]); 767: (void)fprintf(fptr,"CORRCOEF_COLOR\t\t\t=\t%s\n",cust_color[CORRCOEF_COLOR]); 768: (void)fprintf(fptr,"BESTCORR_COLOR\t\t\t=\t%s\n",cust_color[BESTCORR_COLOR]); 769: (void)fprintf(fptr,"DEPOFFLINE_COLOR\t\t=\t%s\n",cust_color[DEPOFFLINE_COLOR]); 770: (void)fprintf(fptr,"DEPOFFHOLE1_COLOR\t\t=\t%s\n",cust_color[DEPOFFHOLE1_COLOR]); 771: (void)fprintf(fptr,"DEPOFFHOLE2_COLOR\t\t=\t%s\n",cust_color[DEPOFFHOLE2_COLOR]); 772: (void)fprintf(fptr,"DEPOFFHOLE3_COLOR\t\t=\t%s\n",cust_color[DEPOFFHOLE3_COLOR]); 773: (void)fprintf(fptr,"DEPOFFHOLE4_COLOR\t\t=\t%s\n",cust_color[DEPOFFHOLE4_COLOR]); 774: (void)fprintf(fptr,"DEPOFFHOLE5_COLOR\t\t=\t%s\n",cust_color[DEPOFFHOLE5_COLOR]); 775: (void)fprintf(fptr,"DEPOFFHOLE6_COLOR\t\t=\t%s\n",cust_color[DEPOFFHOLE6_COLOR]); 776: (void)fprintf(fptr,"DEPOFFHOLE7_COLOR\t\t=\t%s\n",cust_color[DEPOFFHOLE7_COLOR]); 777: (void)fprintf(fptr,"DEPOFFHOLE8_COLOR\t\t=\t%s\n",cust_color[DEPOFFHOLE8_COLOR]); 778: (void)fprintf(fptr,"DEPOFFHOLE9_COLOR\t\t=\t%s\n",cust_color[DEPOFFHOLE9_COLOR]); 779: (void)fprintf(fptr,"DEPOFFHOLE10_COLOR\t\t=\t%s\n",cust_color[DEPOFFHOLE10_COLOR]); 780: (void)fprintf(fptr,"DEPOFFHOLE11_COLOR\t\t=\t%s\n",cust_color[DEPOFFHOLE11_COLOR]); 781: (void)fprintf(fptr,"AGEDEPHANDPICK_COLOR\t\t=\t%s\n",cust_color[AGEDEPHANDPICK_COLOR]); 782: (void)fprintf(fptr,"AGEDEPLINE_COLOR\t\t=\t%s\n",cust_color[AGEDEPLINE_COLOR]); 783: (void)fprintf(fptr,"SEDRATE_COLOR\t\t\t=\t%s\n",cust_color[SEDRATE_COLOR]); 784: (void)fprintf(fptr,"DATUMLOC_COLOR\t\t\t=\t%s\n",cust_color[DATUMLOC_COLOR]); 785: (void)fprintf(fptr,"TIMESERIES_COLOR\t\t=\t%s\n",cust_color[TIMESERIES_COLOR]); 786: (void)fprintf(fptr,"CLIP\t\t\t\t=\t%d\n",clip); 787: } 788: