00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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 #include "constants.hh"
00041 #include "ioroutines.hh"
00042 #include "conversion.hh"
00043 #include "refsystems.hh"
00044 #include "utilities.hh"
00045 #include "slcimage.hh"
00046 #include "productinfo.hh"
00047 #include "exceptions.hh"
00048
00049
00050
00051 #include <fstream>
00052 #include <strstream>
00053 #include <cstring>
00054 #include <iomanip>
00055 #include <cstdlib>
00056 #include <cctype>
00057 #include <cstdarg>
00058 #include <algorithm>
00059 #include <cstdio>
00060 #include <ctime>
00061 char *strptime(const char *s, const char *format, struct tm *tm);
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 void printcpu(
00080 bool init)
00081 {
00082 TRACE_FUNCTION("printcpu (BK 11-Dec-1998)")
00083 time_t nseconds = time(NULL);
00084 char *tijd = ctime(&nseconds);
00085 INFO << "Current time: " << tijd;
00086 INFO.print();
00087
00088
00089
00090
00091
00092
00093
00094
00095 static clock_t cput_last = clock();
00096 clock_t cput_process = clock() - cput_last;
00097 static real4 cput_total = 0.0;
00098
00099 static time_t wct_last = time(NULL);
00100 time_t wct_process = time(NULL) - wct_last;
00101 static int32 wct_total = 0;
00102
00103 if (init)
00104 return;
00105
00106 cput_total += (real4(cput_process))/real4(CLOCKS_PER_SEC);
00107 cput_last = clock();
00108
00109 wct_total += int32(wct_process);
00110 wct_last = time(NULL);
00111
00112 const int32 cputmin = int32(floor(cput_total/60));
00113 const real4 cputsec = cput_total - cputmin*60;
00114 DEBUG << " cputime used for process: \t"
00115 << setw(6) << real4(cput_process)/real4(CLOCKS_PER_SEC)
00116 << " sec (total: "
00117 << setw(4) << cputmin << " min "
00118 << setw(3) << cputsec << " sec)\n"
00119 << "\t wallclock: \t\t\t"
00120 << setw(6) << wct_process
00121 << " sec (total: "
00122 << setw(4) << wct_total/60 << " min "
00123 << setw(3) << wct_total%60 << " sec)";
00124 DEBUG.print();
00125 cerr << "total cpu: \t"
00126 << setw(4) << cputmin << " min "
00127 << setw(3) << cputsec << " sec\n";
00128 }
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 void inittest()
00145 {
00146 TRACE_FUNCTION("inittest (BK 11-Dec-1998)")
00147
00148 #ifdef __DEBUG
00149 DEBUG.print("\"__DEBUG\" defined (extra verbose)");
00150 #else
00151 DEBUG.print("\"__DEBUG\" not defined (extra verbose)");
00152 #endif
00153 #ifdef __DEBUGMAT1
00154 DEBUG.print("\"__DEBUGMAT1\" defined (range checking matrix class)");
00155 #else
00156 DEBUG.print("\"__DEBUGMAT1\" not defined (range checking matrix class)");
00157 #endif
00158 #ifdef __DEBUGMAT2
00159 DEBUG.print("\"__DEBUGMAT2\" defined (verbose matrix class)");
00160 #else
00161 DEBUG.print("\"__DEBUGMAT2\" not defined (verbose matrix class)");
00162 #endif
00163 #ifdef __USE_FFTW_LIBRARY__
00164 DEBUG.print("\"__USE_FFTW_LIBRARY__\" defined (using fftw routines)");
00165 #else
00166 DEBUG.print("\"__USE_FFTW_LIBRARY__\" not defined (not using fftw routines)");
00167 #endif
00168 #ifdef __USE_VECLIB_LIBRARY__
00169 DEBUG.print("\"__USE_VECLIB_LIBRARY__\" defined (using library routines)");
00170 #else
00171 DEBUG.print("\"__USE_VECLIB_LIBRARY__\" not defined (using internal routines)");
00172 #endif
00173 #ifdef __USE_LAPACK_LIBRARY__
00174 DEBUG.print("\"__USE_LAPACK_LIBRARY__\" defined (using library routines)");
00175 #else
00176 DEBUG.print("\"__USE_LAPACK_LIBRARY__\" not defined (using internal routines)");
00177 #endif
00178 #ifdef __GplusplusCOMPILER__
00179 DEBUG.print("\"__GplusplusCOMPILER__\" defined (GNU c++ compiler)");
00180 WARNING.print("NOT USED ANYMORE. since v3.8");
00181 #else
00182 DEBUG.print("\"__GplusplusCOMPILER__\" not defined (no GNU c++ compiler)");
00183 #endif
00184 #ifdef __GNUC__
00185 DEBUG << "\"__GNUC__\": " << __GNUC__;
00186 DEBUG.print();
00187 #endif
00188 #ifdef __GNUC_MINOR__
00189 DEBUG << "\"__GNUC_MINOR__\": " << __GNUC_MINOR__;
00190 DEBUG.print();
00191 #endif
00192
00193 DEBUG.print("Testing endianness.");
00194 int i;
00195 int littleendian=0;
00196 char test[64]={0};
00197 for (i=0;i<32;i++) test[i]=0;
00198 test[0]=0x01;
00199 if (0x0001==*(int *)(&test[0])) littleendian=1;
00200 #ifdef __X86PROCESSOR__
00201 DEBUG.print("\"__X86PROCESSOR__\" defined (little Endian machine)");
00202 if (littleendian == 1)
00203 INFO.print("Little Endian machine defined and this is correct.");
00204 else
00205 WARNING.print("Little Endian machine defined and this is NOT correct.");
00206 #else
00207 DEBUG.print("\"__X86PROCESSOR__\" not defined (big Endian machine)");
00208 if (littleendian == 0)
00209 INFO.print("Big Endian machine defined and this is correct.");
00210 else
00211 WARNING.print("Big Endian machine defined and this is NOT correct.");
00212 #endif
00213
00214 #ifdef __NO_STRPTIME
00215 DEBUG.print("\"__NO_STRPTIME\" defined (using internal routine)");
00216 #else
00217 DEBUG.print("\"__NO_STRPTIME\" not defined (using library routine)");
00218 #endif
00219
00220 DEBUG.print("Testing strptime function.");
00221 struct tm tm_ref;
00222 char utc_ref[100] = "05-JAN-1985 01:02:03.000";
00223 strptime(utc_ref,"%d-%b-%Y %T",&tm_ref);
00224 int status = 0;
00225 if (tm_ref.tm_mday != 5) status=1;
00226 if (tm_ref.tm_mon != 0) status=1;
00227 if (tm_ref.tm_year != 85) status=1;
00228 if (tm_ref.tm_hour != 1) status=1;
00229 if (tm_ref.tm_min != 2) status=1;
00230 if (tm_ref.tm_sec != 3) status=1;
00231 if (status == 0)
00232 INFO.print("strptime function works fine.");
00233 else
00234 WARNING.print("strptime function seems NOT TO BE OK.");
00235
00236
00237
00238 if (sizeof(int16) != 2)
00239 {
00240 PRINT_ERROR("code: 900: sizeof int16(short) != 2: see typedefs in constants.h")
00241 throw(some_error);
00242 }
00243 if (sizeof(int32) != 4)
00244 {
00245 PRINT_ERROR("code: 900: sizeof int32(int) != 4: see typedefs in constants.h")
00246 throw(some_error);
00247 }
00248 if (sizeof(uint) != 4)
00249 {
00250 PRINT_ERROR("code: 900: sizeof uint(unsigned int) != 4: see typedefs in constants.h")
00251 throw(some_error);
00252 }
00253 if (sizeof(real8) != 8)
00254 {
00255 PRINT_ERROR("code: 900: sizeof real8(double) != 8: see typedefs in constants.h")
00256 throw(some_error);
00257 }
00258 if (sizeof(real4) != 4)
00259 {
00260 PRINT_ERROR("code: 900: sizeof real4(float) != 4: see typedefs in constants.h")
00261 throw(some_error);
00262 }
00263 if (sizeof(compli16) != 4)
00264 {
00265 PRINT_ERROR("code: 900: sizeof compli16(complex short) != 4: see typedefs in constants.h")
00266 throw(some_error);
00267 }
00268 if (sizeof(compli32) != 8)
00269 {
00270 PRINT_ERROR("code: 900: sizeof compli32(complex int) != 8: see typedefs in constants.h")
00271 throw(some_error);
00272 }
00273 if (sizeof(complr4) != 8)
00274 {
00275 PRINT_ERROR("code: 900: sizeof complr4(complex float) != 8: see typedefs in constants.h")
00276 throw(some_error);
00277 }
00278 if (sizeof(complr8) != 16)
00279 {
00280 PRINT_ERROR("code: 900: sizeof complr16(complex double) != 16: see typedefs in constants.h")
00281 throw(some_error);
00282 }
00283 if (int32(7.5) != 7)
00284 {
00285 PRINT_ERROR("code: 900: it is assumed that int(7.5)==7")
00286 throw(some_error);
00287 }
00288 if (complr4(1.1) != complr4(1.1,0))
00289 {
00290 PRINT_ERROR("code: ???: it is assumed that complr4(7.5) == 7.5 + 0.0i")
00291 throw(some_error);
00292 }
00293 DEBUG.print("test somewhere also memory,diskspace.");
00294
00295
00296 DEBUG.print("Testing coordinate class:");
00297 cn P; P.test();
00298
00299 DEBUG.print("Testing window class:");
00300 window W; W.test();
00301
00302 DEBUG.print("Testing ellips class:");
00303 input_ell E; E.test();
00304 }
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322 bool doinitwrite(
00323 input_gen &generalinput,
00324 int16 imageid)
00325 {
00326 TRACE_FUNCTION("doinitwrite (BK 15-Dec-1998)")
00327
00328 if (imageid == MASTERID)
00329 {
00330 if (!(generalinput.process[pr_m_readfiles] ||
00331 generalinput.process[pr_m_crop] ||
00332
00333 generalinput.process[pr_m_oversample] ||
00334
00335 generalinput.process[pr_m_porbits] ||
00336 generalinput.process[pr_m_filtazi] ||
00337 generalinput.process[pr_m_filtrange] ||
00338 generalinput.process[pr_m_EXTRA] ))
00339 return false;
00340 }
00341 else if (imageid == SLAVEID)
00342 {
00343 if (!(generalinput.process[pr_s_readfiles] ||
00344 generalinput.process[pr_s_crop] ||
00345
00346 generalinput.process[pr_s_oversample] ||
00347
00348 generalinput.process[pr_s_porbits] ||
00349 generalinput.process[pr_s_resample] ||
00350 generalinput.process[pr_s_filtazi] ||
00351 generalinput.process[pr_s_filtrange] ||
00352 generalinput.process[pr_s_EXTRA] ))
00353 return false;
00354 }
00355 else if (imageid == INTERFID)
00356 {
00357 if (!(generalinput.process[pr_i_coarse] ||
00358 generalinput.process[pr_i_coarse2] ||
00359 generalinput.process[pr_i_fine] ||
00360 generalinput.process[pr_i_coregpm] ||
00361 generalinput.process[pr_i_comprefpha] ||
00362 generalinput.process[pr_i_subtrrefpha] ||
00363 generalinput.process[pr_i_comprefdem] ||
00364 generalinput.process[pr_i_subtrrefdem] ||
00365 generalinput.process[pr_i_interfero] ||
00366 generalinput.process[pr_i_coherence] ||
00367 generalinput.process[pr_i_filtphase] ||
00368 generalinput.process[pr_i_unwrap] ||
00369 generalinput.process[pr_i_slant2h] ||
00370 generalinput.process[pr_i_geocoding] ||
00371 generalinput.process[pr_i_dinsar] ||
00372 generalinput.process[pr_i_EXTRA2] ))
00373 return false;
00374 }
00375 else
00376 {
00377 PRINT_ERROR("code 901: wrong input.")
00378 throw(some_error);
00379 }
00380 return true;
00381 }
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398 void initwrite(
00399 const char* file,
00400 int16 fileid)
00401 {
00402 TRACE_FUNCTION("initwrite (BK 11-Dec-1998)")
00403 #ifndef SWNAME
00404 DEBUG.print("SWNAME NOT DEFINED.");
00405 #endif
00406 #ifndef SWVERSION
00407 DEBUG.print("SWVERSION NOT DEFINED.");
00408 #endif
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421 time_t nseconds = time(NULL);
00422 char *tijd = ctime(&nseconds);
00423
00424
00425 bool ofilenew = true;
00426 if (existed(file)) ofilenew = false;
00427
00428 ofstream ofile;
00429 ofile.open(file, ios::out | ios::app);
00430 bk_assert(ofile,file,__FILE__,__LINE__);
00431
00432
00433 DEBUG.print("Writing (updating) of file (initwrite).");
00434 if (ofilenew)
00435 {
00436 ofile
00437 << "=====================================================";
00438 switch (fileid)
00439 {
00440 case LOGID:
00441 ofile << "\n LOGFILE: " << file;
00442 break;
00443 case MASTERID:
00444 ofile << "\n MASTER RESULTFILE: " << file;
00445 break;
00446 case SLAVEID:
00447 ofile << "\n SLAVE RESULTFILE: " << file;
00448 break;
00449 case INTERFID:
00450 ofile << "\n INTERFEROGRAM RESULTFILE: " << file;
00451 break;
00452 default:
00453 PRINT_ERROR("panic: code 901:initwrite, internal fileid not ok!")
00454 throw(unhandled_case_error);
00455 }
00456 ofile << "\n\nCreated by:"
00457 << "\nInSAR Processor: " << SWNAME
00458 << "\nVersion: " << SWVERSION
00459 #if defined (__DEBUG) || defined (__DEBUGMAT1) || defined (__DEBUGMAT2)
00460 << " (debug)"
00461 #else
00462 << " (optimal)"
00463 #endif
00464 #ifdef __USE_FFTW_LIBRARY__
00465 << "\nFFTW library: " << "used"
00466 #else
00467 << "\nFFTW library: " << "not used"
00468 #endif
00469 #ifdef __USE_VECLIB_LIBRARY__
00470 << "\nVECLIB library: " << "used"
00471 #else
00472 << "\nVECLIB library: " << "not used"
00473 #endif
00474 #ifdef __USE_LAPACK_LIBRARY__
00475 << "\nLAPACK library: " << "used"
00476 #else
00477 << "\nLAPACK library: " << "not used"
00478 #endif
00479 << "\nCompiled at: " << __DATE__ << " " << __TIME__;
00480 #ifdef __GNUC__
00481 ofile << "\nBy GNU gcc: " << __GNUC__;
00482 #ifdef __GNUC_MINOR__
00483 ofile << "." << __GNUC_MINOR__;
00484 #ifdef __GNUG__
00485 ofile << "." << __GNUG__;
00486 #endif
00487 #endif
00488 #endif
00489 ofile << "\nFile creation at: " << tijd
00490 << "\n --------------------------------------------------"
00491 << "\n| Delft institute of Earth-oriented Space research |"
00492 << "\n| Delft University of Technology |"
00493 << "\n| http://www.geo.tudelft.nl/doris/ |"
00494 << "\n| |"
00495 << "\n| Author: Bert Kampes |"
00496 << "\n --------------------------------------------------\n\n";
00497
00498
00499 switch (fileid)
00500 {
00501
00502
00503 case MASTERID:
00504 ofile << "\nStart_process_control\n"
00505 << processcontrol[pr_m_readfiles] << " \t\t0\n"
00506 << processcontrol[pr_m_porbits] << " \t0\n"
00507 << processcontrol[pr_m_crop] << " \t\t\t0\n"
00508
00509 << processcontrol[pr_m_oversample] << " \t\t0\n"
00510
00511 << processcontrol[pr_m_filtazi] << " \t\t0\n"
00512 << processcontrol[pr_m_filtrange] << " \t\t0\n"
00513 << processcontrol[pr_m_EXTRA] << " \t\t0\n"
00514 << "End_process_control\n";
00515 break;
00516
00517
00518 case SLAVEID:
00519 ofile << "\nStart_process_control\n"
00520 << processcontrol[pr_s_readfiles] << " \t\t0\n"
00521 << processcontrol[pr_s_porbits] << " \t0\n"
00522 << processcontrol[pr_s_crop] << " \t\t\t0\n"
00523
00524 << processcontrol[pr_s_oversample] << " \t\t0\n"
00525
00526 << processcontrol[pr_s_resample] << " \t\t0\n"
00527 << processcontrol[pr_s_filtazi] << " \t\t0\n"
00528 << processcontrol[pr_s_filtrange] << " \t\t0\n"
00529 << processcontrol[pr_s_EXTRA] << " \t\t0\n"
00530 << "End_process_control\n";
00531 break;
00532
00533
00534 case INTERFID:
00535 ofile << "\nStart_process_control\n"
00536 << processcontrol[pr_i_coarse] << " \t\t0\n"
00537 << processcontrol[pr_i_coarse2] << " \t\t0\n"
00538 << processcontrol[pr_i_fine] << " \t\t0\n"
00539 << processcontrol[pr_i_coregpm] << " \t\t0\n"
00540 << processcontrol[pr_i_interfero] << " \t\t0\n"
00541 << processcontrol[pr_i_coherence] << " \t0\n"
00542 << processcontrol[pr_i_comprefpha] << " \t\t0\n"
00543 << processcontrol[pr_i_subtrrefpha] << " \t\t0\n"
00544 << processcontrol[pr_i_comprefdem] << " \t\t0\n"
00545 << processcontrol[pr_i_subtrrefdem] << " \t\t0\n"
00546 << processcontrol[pr_i_filtphase] << " \t\t0\n"
00547 << processcontrol[pr_i_unwrap] << " \t\t0\n"
00548 << processcontrol[pr_i_slant2h] << " \t\t0\n"
00549 << processcontrol[pr_i_geocoding] << " \t\t0\n"
00550 << processcontrol[pr_i_dinsar] << " \t\t\t0\n"
00551 << processcontrol[pr_i_EXTRA2] << " \t\t0\n"
00552 << "End_process_control\n";
00553 break;
00554
00555 default:
00556 ;
00557 }
00558 }
00559
00560 else
00561 {
00562 ofile << endl << endl
00563 << " *====================================================================*\n"
00564 << " | |\n"
00565 << " Following part is appended at: " << tijd
00566 << " | |\n"
00567 << " *--------------------------------------------------------------------*\n\n";
00568 }
00569
00570
00571 ofile.close();
00572 }
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 void updatefile(
00592 const char* sfile,
00593 const char* lfile)
00594 {
00595 TRACE_FUNCTION("updatefile (BK 11-Dec-1998)")
00596
00597 char dummyline[4*ONE27];
00598
00599 ifstream scratchfile(sfile, ios::in);
00600 bk_assert(scratchfile,sfile,__FILE__,__LINE__);
00601
00602 ofstream logfile(lfile, ios::out | ios::app);
00603 bk_assert(logfile,lfile,__FILE__,__LINE__);
00604
00605
00606 scratchfile.getline(dummyline,4*ONE27,'\n');
00607 while (scratchfile)
00608 {
00609 logfile << dummyline << endl;
00610 scratchfile.getline(dummyline,4*ONE27,'\n');
00611 }
00612
00613
00614 time_t nseconds = time(NULL);
00615 char *tijd = ctime(&nseconds);
00616 logfile << "\n Current time: " << tijd;
00617
00618
00619 logfile.close();
00620 scratchfile.close();
00621 if (remove(sfile))
00622 WARNING.print("Could not remove file.");
00623
00624 DEBUG << "File: " << lfile
00625 << " has been updated by file: " << sfile << " (removed.)";
00626 DEBUG.print();
00627 }
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642 void getanswer(
00643 )
00644 {
00645 TRACE_FUNCTION("getanswer (BK 11-Dec-1998)")
00646 char dummychar;
00647 cerr << "\n Press <ENTER> to continue.";
00648 cin.unsetf(ios::skipws);
00649 cin >> dummychar;
00650 cerr << " continuing...\n";
00651 }
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678 bool readres(
00679 char* returnword,
00680 const int16 sizeofrw,
00681 const char* file,
00682 const char* pattern,
00683 const int16 skipwords)
00684 {
00685 TRACE_FUNCTION("readres (BK 11-Dec-1998)")
00686 char dummyline[ONE27];
00687 char word[EIGHTY];
00688 bool foundword = false;
00689
00690
00691 ifstream infile(file, ios::in);
00692 bk_assert(infile,file,__FILE__,__LINE__);
00693
00694
00695
00696 returnword[0] = '\0';
00697 char ch = '\t';
00698 while (infile)
00699 {
00700 infile >> word;
00701 if (strcmp(pattern,word))
00702 {
00703 infile.getline(dummyline,ONE27,'\n');
00704 }
00705 else
00706 {
00707 for (register int32 i=0; i<skipwords; i++)
00708 infile >> word;
00709 int32 tin;
00710 while (isspace(tin=ch))
00711 {
00712 infile.get(ch);
00713 if (ch == '\n')
00714 {
00715 WARNING.print("Found identifier, but not so desired word!, exiting routine...");
00716 break;
00717 }
00718 }
00719
00720
00721 foundword = true;
00722
00723
00724
00725
00726 for (int ii=0; ii<sizeofrw; ++ii)
00727 {
00728 if (ch == '\n')
00729 {
00730 returnword[ii] = '\0';
00731 break;
00732 }
00733 else
00734 {
00735 returnword[ii] = ch;
00736 }
00737 infile.get(ch);
00738 }
00739
00740 break;
00741 }
00742 }
00743
00744
00745 if (foundword)
00746 {
00747 DEBUG << "read: \"" << returnword << "\" as word " << skipwords << " after \""
00748 << pattern << "\"";
00749 DEBUG.print();
00750 }
00751 else
00752 {
00753 ERROR << "readres: could not find pattern: \"" << pattern
00754 << "\" in file: " << file;
00755 PRINT_ERROR(ERROR.get_str());
00756 throw(file_error);
00757 }
00758
00759 infile.close();
00760 return foundword;
00761 }
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776 void updateprocesscontrol(
00777 const char* file,
00778 int16 fileid)
00779 {
00780 TRACE_FUNCTION("updateprocesscontrol (BK 14-Dec-1998)")
00781
00782
00783 int16 checkprocess[NUMPROCESSES+1];
00784
00785
00786 char dummyline[ONE27];
00787
00788
00789
00790
00791 if (!existed(file))
00792 return;
00793
00794
00795 ofstream tmpfile("scratchcopy", ios::out | ios::trunc);
00796 bk_assert(tmpfile,"updateprocesscontrol: scratchcopy",__FILE__,__LINE__);
00797
00798 ifstream resfile(file, ios::in);
00799 bk_assert(resfile,file,__FILE__,__LINE__);
00800
00801
00802 for (register int32 i=0;i<NUMPROCESSES;i++)
00803 checkprocess[i]=0;
00804 resfile.getline(dummyline,ONE27,'\n');
00805 while(resfile)
00806 {
00807 tmpfile << dummyline << endl;
00808 fillcheckprocess(dummyline,checkprocess,fileid);
00809 resfile.getline(dummyline,ONE27,'\n');
00810 }
00811 resfile.close();
00812 tmpfile.close();
00813
00814
00815
00816
00817 ifstream tmpfile2("scratchcopy", ios::in);
00818 bk_assert(tmpfile2,"updateprocesscontrols: scratchcopy",__FILE__,__LINE__);
00819 ofstream resfile2(file, ios::out | ios::trunc);
00820 bk_assert(resfile2,file,__FILE__,__LINE__);
00821
00822
00823
00824 while (strcmp(dummyline,"Start_process_control"))
00825 {
00826 tmpfile2.getline(dummyline,ONE27,'\n');
00827 resfile2 << dummyline << endl;
00828 }
00829
00830
00831 char word[EIGHTY]=" ";
00832 for (;;)
00833 {
00834 tmpfile2 >> word;
00835 resfile2 << word;
00836 tmpfile2.getline(dummyline,ONE27,'\n');
00837 if (!strcmp(word,"End_process_control"))
00838 {
00839 resfile2 << endl;
00840 break;
00841 }
00842
00843 switch (fileid)
00844 {
00845 case MASTERID:
00846 if (!strcmp(word,processcontrol[pr_m_readfiles]))
00847 (checkprocess[pr_m_readfiles]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00848 else if (!strcmp(word,processcontrol[pr_m_porbits]))
00849 (checkprocess[pr_m_porbits]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00850 else if (!strcmp(word,processcontrol[pr_m_crop]))
00851 (checkprocess[pr_m_crop]) ? resfile2 << "\t\t\t1\n" : resfile2 << "\t\t\t0\n";
00852
00853 else if (!strcmp(word,processcontrol[pr_m_oversample]))
00854 (checkprocess[pr_m_oversample]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00855
00856 else if (!strcmp(word,processcontrol[pr_m_filtazi]))
00857 (checkprocess[pr_m_filtazi]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00858 else if (!strcmp(word,processcontrol[pr_m_filtrange]))
00859 (checkprocess[pr_m_filtrange]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00860 else if (!strcmp(word,processcontrol[pr_m_EXTRA]))
00861 (checkprocess[pr_m_EXTRA]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00862 else
00863 {
00864 ERROR << "PANIC: forgotten to update routine? " << word
00865 << " not recognized in master resultfile.";
00866 PRINT_ERROR(ERROR.get_str())
00867 throw(unhandled_case_error);
00868 }
00869 break;
00870
00871 case SLAVEID:
00872 if (!strcmp(word,processcontrol[pr_s_readfiles]))
00873 (checkprocess[pr_s_readfiles]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00874 else if (!strcmp(word,processcontrol[pr_s_porbits]))
00875 (checkprocess[pr_s_porbits]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00876 else if (!strcmp(word,processcontrol[pr_s_crop]))
00877 (checkprocess[pr_s_crop]) ? resfile2 << "\t\t\t1\n" : resfile2 << "\t\t\t0\n";
00878
00879 else if (!strcmp(word,processcontrol[pr_s_oversample]))
00880 (checkprocess[pr_s_oversample]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00881
00882 else if (!strcmp(word,processcontrol[pr_s_resample]))
00883 (checkprocess[pr_s_resample]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00884 else if (!strcmp(word,processcontrol[pr_s_filtazi]))
00885 (checkprocess[pr_s_filtazi]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00886 else if (!strcmp(word,processcontrol[pr_s_filtrange]))
00887 (checkprocess[pr_s_filtrange]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00888 else if (!strcmp(word,processcontrol[pr_s_EXTRA]))
00889 (checkprocess[pr_s_EXTRA]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00890 else
00891 {
00892 ERROR << "PANIC: forgotten to update routine? " << word
00893 << " not recognized in slave resultfile.";
00894 PRINT_ERROR(ERROR.get_str())
00895 throw(unhandled_case_error);
00896 }
00897 break;
00898
00899 case INTERFID:
00900 if (!strcmp(word,processcontrol[pr_i_coarse]))
00901 (checkprocess[pr_i_coarse]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00902 else if (!strcmp(word,processcontrol[pr_i_coarse2]))
00903 (checkprocess[pr_i_coarse2]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00904 else if (!strcmp(word,processcontrol[pr_i_fine]))
00905 (checkprocess[pr_i_fine]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00906 else if (!strcmp(word,processcontrol[pr_i_coregpm]))
00907 (checkprocess[pr_i_coregpm]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00908 else if (!strcmp(word,processcontrol[pr_i_interfero]))
00909 (checkprocess[pr_i_interfero]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00910 else if (!strcmp(word,processcontrol[pr_i_coherence]))
00911 (checkprocess[pr_i_coherence]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00912 else if (!strcmp(word,processcontrol[pr_i_comprefpha]))
00913 (checkprocess[pr_i_comprefpha]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00914 else if (!strcmp(word,processcontrol[pr_i_subtrrefpha]))
00915 (checkprocess[pr_i_subtrrefpha]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00916 else if (!strcmp(word,processcontrol[pr_i_comprefdem]))
00917 (checkprocess[pr_i_comprefdem]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00918 else if (!strcmp(word,processcontrol[pr_i_subtrrefdem]))
00919 (checkprocess[pr_i_subtrrefdem]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00920 else if (!strcmp(word,processcontrol[pr_i_filtphase]))
00921 (checkprocess[pr_i_filtphase]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00922 else if (!strcmp(word,processcontrol[pr_i_unwrap]))
00923 (checkprocess[pr_i_unwrap]) ? resfile2 << "\t\t\t1\n" : resfile2 << "\t\t\t0\n";
00924 else if (!strcmp(word,processcontrol[pr_i_slant2h]))
00925 (checkprocess[pr_i_slant2h]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00926 else if (!strcmp(word,processcontrol[pr_i_geocoding]))
00927 (checkprocess[pr_i_geocoding]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00928 else if (!strcmp(word,processcontrol[pr_i_dinsar]))
00929 (checkprocess[pr_i_dinsar]) ? resfile2 << "\t\t\t1\n" : resfile2 << "\t\t\t0\n";
00930 else if (!strcmp(word,processcontrol[pr_i_EXTRA2]))
00931 (checkprocess[pr_i_EXTRA2]) ? resfile2 << "\t\t1\n" : resfile2 << "\t\t0\n";
00932 else
00933 {
00934 ERROR << "PANIC: forgotten to update routine? " << word
00935 << " not recognized in interferogram resultfile.";
00936 PRINT_ERROR(ERROR.get_str())
00937 throw(unhandled_case_error);
00938 }
00939 break;
00940
00941 default:
00942 PRINT_ERROR("PANIC, impossible wrong.")
00943 throw(unhandled_case_error);
00944 }
00945 }
00946
00947
00948
00949 tmpfile2.getline(dummyline,ONE27,'\n');
00950 while(tmpfile2)
00951 {
00952 resfile2 << dummyline << endl;
00953 tmpfile2.getline(dummyline,ONE27,'\n');
00954 }
00955 resfile2.close();
00956 tmpfile2.close();
00957
00958
00959
00960
00961 if (remove("scratchcopy"))
00962 WARNING.print("Could not remove file: scratchcopy.");
00963 }
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989 void checkprocessing(
00990 const input_gen &generalinput,
00991 int16 checkprocess[NUMPROCESSES])
00992 {
00993 TRACE_FUNCTION("checkprocessing (BK 14-Dec-1998)")
00994 char dummyline[ONE27] = " ";
00995
00996 const char* file;
00997 int16 checkprocess2[NUMPROCESSES+1];
00998
00999 checkprocess2[NUMPROCESSES]=0;
01000 register int32 i;
01001 for (i=0;i<NUMPROCESSES;i++)
01002 {
01003 checkprocess[i]=0;
01004 checkprocess2[i]=0;
01005 }
01006
01007
01008 for (int32 fileid=MASTERID; fileid<=INTERFID; fileid++)
01009 {
01010 if (fileid == MASTERID)
01011 file=generalinput.m_resfile;
01012 else if (fileid == SLAVEID)
01013 file=generalinput.s_resfile;
01014 else if (fileid == INTERFID)
01015 file=generalinput.i_resfile;
01016 else
01017 {
01018 PRINT_ERROR("checkprocessing, PANIC, wrong input")
01019 throw(input_error);
01020 }
01021
01022 if (existed(file))
01023 {
01024 int32 breakit=0;
01025 while(breakit<3)
01026 {
01027 ifstream resfile;
01028
01029 resfile.open(file, ios::in);
01030 bk_assert(resfile,file,__FILE__,__LINE__);
01031
01032 int32 linecnt=0;
01033 while (strcmp(dummyline,"Start_process_control"))
01034 {
01035 resfile.getline(dummyline,ONE27,'\n');
01036 DEBUG << "read line: " << dummyline << ends;
01037 DEBUG.print();
01038 linecnt++;
01039 if (linecnt==200)
01040 {
01041 WARNING.print("Checked first 200 lines, did not find: \"Start_process_control\".");
01042 break;
01043 }
01044 }
01045
01046
01047 linecnt=0;
01048 while (strcmp(dummyline,"End_process_control"))
01049 {
01050 resfile.getline(dummyline,ONE27,'\n');
01051 DEBUG << "read line: " << dummyline;
01052 DEBUG.print();
01053 fillprocessed(dummyline,checkprocess,fileid);
01054 linecnt++;
01055 if (linecnt==200)
01056 {
01057 WARNING.print("Checked first 200 lines, did not find: \"End_process_control\".");
01058 break;
01059 }
01060 }
01061
01062
01063 resfile.getline(dummyline,ONE27,'\n');
01064 while(resfile)
01065 {
01066 fillcheckprocess(dummyline,checkprocess2,fileid);
01067 resfile.getline(dummyline,ONE27,'\n');
01068 DEBUG << "read line: " << dummyline;
01069 DEBUG.print();
01070 }
01071 resfile.close();
01072
01073
01074 bool dofixprocesscontrol=false;
01075 for (i=0;i<NUMPROCESSES;i++)
01076 {
01077 if (checkprocess[i] != checkprocess2[i])
01078 {
01079 dofixprocesscontrol=true;
01080 WARNING << "Step: " << i << " (" << processcontrol[i]
01081 << ") ";
01082 if (checkprocess[i]==1)
01083 WARNING << "in process control flag, but result is not in \""
01084 << file << "\".";
01085 else
01086 WARNING << "not in process control flag, but result is in \""
01087 << file << "\".";
01088 WARNING.print();
01089 if (generalinput.interactive) getanswer();
01090 }
01091 }
01092
01093
01094 if (dofixprocesscontrol)
01095 {
01096 if (breakit == 1)
01097 {
01098 cerr << "\nAlready tried to fix process controls. Should I try again?\n";
01099 getanswer();
01100 }
01101 updateprocesscontrol(file, fileid);
01102 breakit += 1;
01103 }
01104 else
01105 breakit = 10;
01106 }
01107 }
01108 }
01109
01110
01111
01112
01113 int16 checkprocesstmp[NUMPROCESSES];
01114 for (i=0; i<NUMPROCESSES; i++)
01115 checkprocesstmp[i]=checkprocess[i];
01116
01117
01118
01119
01120
01121 if (generalinput.process[pr_m_readfiles])
01122 checkrequest(pr_m_readfiles,checkprocesstmp,0);
01123 if (generalinput.process[pr_m_crop])
01124 checkrequest(pr_m_crop,checkprocesstmp,
01125 1,pr_m_readfiles);
01126
01127
01128 if (generalinput.process[pr_m_oversample])
01129 checkrequest(pr_m_oversample,checkprocesstmp,1,pr_m_crop);
01130
01131 if (generalinput.process[pr_m_porbits])
01132 checkrequest(pr_m_porbits,checkprocesstmp, 1,pr_m_readfiles);
01133 if (checkprocess2[NUMPROCESSES])
01134 DEBUG.print("orbits from leader file will be deleted.");
01135 if (generalinput.process[pr_m_filtazi])
01136 checkrequest(pr_m_filtazi,checkprocesstmp,
01137 1,pr_m_crop);
01138 if (generalinput.process[pr_m_EXTRA])
01139 checkrequest(pr_m_EXTRA,checkprocesstmp,0);
01140
01141
01142 if (generalinput.process[pr_s_readfiles])
01143 checkrequest(pr_s_readfiles,checkprocesstmp,0);
01144 if (generalinput.process[pr_s_crop])
01145 checkrequest(pr_s_crop,checkprocesstmp,
01146 1,pr_s_readfiles);
01147
01148 if (generalinput.process[pr_s_oversample])
01149 checkrequest(pr_s_oversample,checkprocesstmp,1,pr_s_crop);
01150
01151 if (generalinput.process[pr_s_porbits])
01152 checkrequest(pr_s_porbits,checkprocesstmp,
01153 1,pr_s_readfiles);
01154 if (checkprocess2[NUMPROCESSES])
01155 DEBUG.print("orbits from leader file will be deleted.");
01156 if (generalinput.process[pr_s_filtazi])
01157 checkrequest(pr_s_filtazi,checkprocesstmp,
01158 1,pr_s_crop);
01159 if (generalinput.process[pr_s_EXTRA])
01160 checkrequest(pr_s_EXTRA,checkprocesstmp,0);
01161
01162
01163 if (generalinput.process[pr_i_coarse])
01164 checkrequest(pr_i_coarse,checkprocesstmp,
01165 2,pr_m_crop,pr_s_crop);
01166 if (generalinput.process[pr_i_coarse2])
01167 checkrequest(pr_i_coarse2,checkprocesstmp,
01168 2,pr_m_crop,pr_s_crop);
01169
01170 if (generalinput.process[pr_m_filtrange])
01171 checkrequest(pr_m_filtrange,checkprocesstmp,
01172 2,pr_m_crop,pr_i_coarse2);
01173
01174
01175
01176
01177
01178
01179
01180 if (generalinput.process[pr_i_fine])
01181 checkrequest(pr_i_fine,checkprocesstmp,
01182 2,pr_m_crop,pr_s_crop);
01183 if (generalinput.process[pr_i_coregpm])
01184 checkrequest(pr_i_coregpm,checkprocesstmp,
01185 1,pr_i_fine);
01186
01187
01188
01189 if (generalinput.process[pr_s_resample])
01190 checkrequest(pr_s_resample,checkprocesstmp,
01191 1,pr_i_coregpm);
01192
01193 if (generalinput.process[pr_i_interfero])
01194 checkrequest(pr_i_interfero,checkprocesstmp,
01195 1,pr_s_resample);
01196 if (generalinput.process[pr_i_coherence])
01197 checkrequest(pr_i_coherence,checkprocesstmp,
01198 1,pr_s_resample);
01199 if (generalinput.process[pr_i_comprefpha])
01200 checkrequest(pr_i_comprefpha,checkprocesstmp,
01201 2,pr_m_readfiles,pr_s_readfiles);
01202 if (generalinput.process[pr_i_subtrrefpha])
01203 checkrequest(pr_i_subtrrefpha,checkprocesstmp,
01204 1,pr_i_interfero);
01205
01206 if (generalinput.process[pr_i_comprefdem])
01207 checkrequest(pr_i_comprefdem,checkprocesstmp,
01208 2,pr_m_readfiles,pr_s_readfiles);
01209 if (generalinput.process[pr_i_subtrrefdem])
01210 checkrequest(pr_i_subtrrefdem,checkprocesstmp,
01211 2,pr_i_comprefdem,pr_i_interfero);
01212 if (generalinput.process[pr_i_filtphase])
01213 checkrequest(pr_i_filtphase,checkprocesstmp,
01214 1,pr_i_interfero);
01215 if (generalinput.process[pr_i_unwrap])
01216 checkrequest(pr_i_unwrap,checkprocesstmp,
01217 1,pr_i_interfero);
01218 if (generalinput.process[pr_i_slant2h])
01219 checkrequest(pr_i_slant2h,checkprocesstmp,
01220 1,pr_i_unwrap);
01221 if (generalinput.process[pr_i_geocoding])
01222 checkrequest(pr_i_geocoding,checkprocesstmp,
01223 1,pr_i_slant2h);
01224 if (generalinput.process[pr_i_dinsar])
01225 checkrequest(pr_i_dinsar,checkprocesstmp,
01226 1,pr_i_interfero);
01227 if (generalinput.process[pr_i_EXTRA2])
01228 checkrequest(pr_i_EXTRA2,checkprocesstmp,0);
01229
01230
01231 }
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250 void checkrequest(
01251 int16 step,
01252 int16 alreadyprocess[NUMPROCESSES],
01253 ...)
01254 {
01255 TRACE_FUNCTION("checkrequest (BK 16-Dec-1998)")
01256
01257
01258 if (alreadyprocess[step])
01259 {
01260 ERROR << "Results of step: "
01261 << step << " (" << processcontrol[step]
01262 << ") already in result file.";
01263 PRINT_ERROR(ERROR.get_str())
01264 throw(input_error);
01265 }
01266 alreadyprocess[step]=1;
01267
01268
01269
01270
01271 va_list arglist;
01272 va_start(arglist,alreadyprocess);
01273
01274
01275
01276
01277
01278 int16 N = va_arg(arglist, int);
01279
01280 int16 requiredstep;
01281 for (register int32 i=0; i<N; i++)
01282 {
01283
01284
01285
01286
01287 requiredstep = va_arg(arglist, int);
01288
01289 if (!(alreadyprocess[requiredstep]))
01290 {
01291 WARNING << "Requested step: "
01292 << step << " (" << processcontrol[step]
01293 << ") seems impossible, because step "
01294 << requiredstep << " (" << processcontrol[requiredstep]
01295 << ") is not in resultfile.";
01296 WARNING.print();
01297 }
01298 }
01299 va_end(arglist);
01300 }
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322 void fillcheckprocess(
01323 const char *line,
01324 int16 checkprocess[NUMPROCESSES+1],
01325 int16 fileid)
01326 {
01327 TRACE_FUNCTION("fillcheckprocess (BK 16-Dec-1998)")
01328 if (line[0] != '*')
01329 return;
01330
01331
01332
01333 char *endnormal[NUMPROCESSES];
01334 char mread[ONE27];
01335 strcpy(mread,"* End_");
01336 strcat(mread,processcontrol[pr_m_readfiles]);
01337 strcat(mread,"_NORMAL");
01338 endnormal[pr_m_readfiles]=&mread[0];
01339
01340 char mcrop[ONE27];
01341 strcpy(mcrop,"* End_");
01342 strcat(mcrop,processcontrol[pr_m_crop]);
01343 strcat(mcrop,"_NORMAL");
01344 endnormal[pr_m_crop]=&mcrop[0];
01345
01346
01347 char moversample[ONE27];
01348 strcpy(moversample,"* End_");
01349 strcat(moversample,processcontrol[pr_m_oversample]);
01350 strcat(moversample,"_NORMAL");
01351 endnormal[pr_m_oversample]=&moversample[0];
01352
01353
01354 char mporbits[ONE27];
01355 strcpy(mporbits,"* End_");
01356 strcat(mporbits,processcontrol[pr_m_porbits]);
01357 strcat(mporbits,"_NORMAL");
01358 endnormal[pr_m_porbits]=&mporbits[0];
01359
01360 char mfiltazi[ONE27];
01361 strcpy(mfiltazi,"* End_");
01362 strcat(mfiltazi,processcontrol[pr_m_filtazi]);
01363 strcat(mfiltazi,"_NORMAL");
01364 endnormal[pr_m_filtazi]=&mfiltazi[0];
01365
01366 char mfiltrange[ONE27];
01367 strcpy(mfiltrange,"* End_");
01368 strcat(mfiltrange,processcontrol[pr_m_filtrange]);
01369 strcat(mfiltrange,"_NORMAL");
01370 endnormal[pr_m_filtrange]=&mfiltrange[0];
01371
01372 char mEXTRA[ONE27];
01373 strcpy(mEXTRA,"* End_");
01374 strcat(mEXTRA,processcontrol[pr_m_EXTRA]);
01375 strcat(mEXTRA,"_NORMAL");
01376 endnormal[pr_m_EXTRA]=&mEXTRA[0];
01377
01378 char sread[ONE27];
01379 strcpy(sread,"* End_");
01380 strcat(sread,processcontrol[pr_s_readfiles]);
01381 strcat(sread,"_NORMAL");
01382 endnormal[pr_s_readfiles]=&sread[0];
01383
01384 char scrop[ONE27];
01385 strcpy(scrop,"* End_");
01386 strcat(scrop,processcontrol[pr_s_crop]);
01387 strcat(scrop,"_NORMAL");
01388 endnormal[pr_s_crop]=&scrop[0];
01389
01390
01391 char soversample[ONE27];
01392 strcpy(soversample,"* End_");
01393 strcat(soversample,processcontrol[pr_s_oversample]);
01394 strcat(soversample,"_NORMAL");
01395 endnormal[pr_s_oversample]=&soversample[0];
01396
01397
01398 char sporbits[ONE27];
01399 strcpy(sporbits,"* End_");
01400 strcat(sporbits,processcontrol[pr_s_porbits]);
01401 strcat(sporbits,"_NORMAL");
01402 endnormal[pr_s_porbits]=&sporbits[0];
01403
01404 char sfiltazi[ONE27];
01405 strcpy(sfiltazi,"* End_");
01406 strcat(sfiltazi,processcontrol[pr_s_filtazi]);
01407 strcat(sfiltazi,"_NORMAL");
01408 endnormal[pr_s_filtazi]=&sfiltazi[0];
01409
01410 char sfiltrange[ONE27];
01411 strcpy(sfiltrange,"* End_");
01412 strcat(sfiltrange,processcontrol[pr_s_filtrange]);
01413 strcat(sfiltrange,"_NORMAL");
01414 endnormal[pr_s_filtrange]=&sfiltrange[0];
01415
01416 char sresample[ONE27];
01417 strcpy(sresample,"* End_");
01418 strcat(sresample,processcontrol[pr_s_resample]);
01419 strcat(sresample,"_NORMAL");
01420 endnormal[pr_s_resample]=&sresample[0];
01421
01422 char sEXTRA[ONE27];
01423 strcpy(sEXTRA,"* End_");
01424 strcat(sEXTRA,processcontrol[pr_s_EXTRA]);
01425 strcat(sEXTRA,"_NORMAL");
01426 endnormal[pr_s_EXTRA]=&sEXTRA[0];
01427
01428 char icoarse[ONE27];
01429 strcpy(icoarse,"* End_");
01430 strcat(icoarse,processcontrol[pr_i_coarse]);
01431 strcat(icoarse,"_NORMAL");
01432 endnormal[pr_i_coarse]=&icoarse[0];
01433
01434 char icoarse2[ONE27];
01435 strcpy(icoarse2,"* End_");
01436 strcat(icoarse2,processcontrol[pr_i_coarse2]);
01437 strcat(icoarse2,"_NORMAL");
01438 endnormal[pr_i_coarse2]=&icoarse2[0];
01439
01440 char ifine[ONE27];
01441 strcpy(ifine,"* End_");
01442 strcat(ifine,processcontrol[pr_i_fine]);
01443 strcat(ifine,"_NORMAL");
01444 endnormal[pr_i_fine]=&ifine[0];
01445
01446 char icoregpm[ONE27];
01447 strcpy(icoregpm,"* End_");
01448 strcat(icoregpm,processcontrol[pr_i_coregpm]);
01449 strcat(icoregpm,"_NORMAL");
01450 endnormal[pr_i_coregpm]=&icoregpm[0];
01451
01452 char iinterfero[ONE27];
01453 strcpy(iinterfero,"* End_");
01454 strcat(iinterfero,processcontrol[pr_i_interfero]);
01455 strcat(iinterfero,"_NORMAL");
01456 endnormal[pr_i_interfero]=&iinterfero[0];
01457
01458 char icoherence[ONE27];
01459 strcpy(icoherence,"* End_");
01460 strcat(icoherence,processcontrol[pr_i_coherence]);
01461 strcat(icoherence,"_NORMAL");
01462 endnormal[pr_i_coherence]=&icoherence[0];
01463
01464 char icomprefpha[ONE27];
01465 strcpy(icomprefpha,"* End_");
01466 strcat(icomprefpha,processcontrol[pr_i_comprefpha]);
01467 strcat(icomprefpha,"_NORMAL");
01468 endnormal[pr_i_comprefpha]=&icomprefpha[0];
01469
01470 char isubtrrefpha[ONE27];
01471 strcpy(isubtrrefpha,"* End_");
01472 strcat(isubtrrefpha,processcontrol[pr_i_subtrrefpha]);
01473 strcat(isubtrrefpha,"_NORMAL");
01474 endnormal[pr_i_subtrrefpha]=&isubtrrefpha[0];
01475
01476 char icomprefdem[ONE27];
01477 strcpy(icomprefdem,"* End_");
01478 strcat(icomprefdem,processcontrol[pr_i_comprefdem]);
01479 strcat(icomprefdem,"_NORMAL");
01480 endnormal[pr_i_comprefdem]=&icomprefdem[0];
01481
01482 char isubtrrefdem[ONE27];
01483 strcpy(isubtrrefdem,"* End_");
01484 strcat(isubtrrefdem,processcontrol[pr_i_subtrrefdem]);
01485 strcat(isubtrrefdem,"_NORMAL");
01486 endnormal[pr_i_subtrrefdem]=&isubtrrefdem[0];
01487
01488 char ifiltphase[ONE27];
01489 strcpy(ifiltphase,"* End_");
01490 strcat(ifiltphase,processcontrol[pr_i_filtphase]);
01491 strcat(ifiltphase,"_NORMAL");
01492 endnormal[pr_i_filtphase]=&ifiltphase[0];
01493
01494 char iunwrap[ONE27];
01495 strcpy(iunwrap,"* End_");
01496 strcat(iunwrap,processcontrol[pr_i_unwrap]);
01497 strcat(iunwrap,"_NORMAL");
01498 endnormal[pr_i_unwrap]=&iunwrap[0];
01499
01500 char islant2h[ONE27];
01501 strcpy(islant2h,"* End_");
01502 strcat(islant2h,processcontrol[pr_i_slant2h]);
01503 strcat(islant2h,"_NORMAL");
01504 endnormal[pr_i_slant2h]=&islant2h[0];
01505
01506 char igeocoding[ONE27];
01507 strcpy(igeocoding,"* End_");
01508 strcat(igeocoding,processcontrol[pr_i_geocoding]);
01509 strcat(igeocoding,"_NORMAL");
01510 endnormal[pr_i_geocoding]=&igeocoding[0];
01511
01512 char idinsar[ONE27];
01513 strcpy(idinsar,"* End_");
01514 strcat(idinsar,processcontrol[pr_i_dinsar]);
01515 strcat(idinsar,"_NORMAL");
01516 endnormal[pr_i_dinsar]=&idinsar[0];
01517
01518 char iEXTRA2[ONE27];
01519 strcpy(iEXTRA2,"* End_");
01520 strcat(iEXTRA2,processcontrol[pr_i_EXTRA2]);
01521 strcat(iEXTRA2,"_NORMAL");
01522 endnormal[pr_i_EXTRA2]=&iEXTRA2[0];
01523
01524
01525 if (fileid == MASTERID)
01526 {
01527
01528
01529 if (!strcmp(line,endnormal[pr_m_readfiles]))
01530 checkprocess[pr_m_readfiles]=1;
01531 else if (!strcmp(line,"* End_leader_datapoints:_NORMAL"))
01532 checkprocess[NUMPROCESSES]=1;
01533 else if (!strcmp(line,endnormal[pr_m_porbits]))
01534 checkprocess[pr_m_porbits]=1;
01535 else if (!strcmp(line,endnormal[pr_m_crop]))
01536 checkprocess[pr_m_crop]=1;
01537
01538 else if (!strcmp(line,endnormal[pr_m_oversample]))
01539 checkprocess[pr_m_oversample]=1;
01540
01541 else if (!strcmp(line,endnormal[pr_m_filtazi]))
01542 checkprocess[pr_m_filtazi]=1;
01543 else if (!strcmp(line,endnormal[pr_m_filtrange]))
01544 checkprocess[pr_m_filtrange]=1;
01545 else if (!strcmp(line,endnormal[pr_m_EXTRA]))
01546 checkprocess[pr_m_EXTRA]=1;
01547 }
01548
01549 else if (fileid == SLAVEID)
01550 {
01551 if (!strcmp(line,endnormal[pr_s_readfiles]))
01552 checkprocess[pr_s_readfiles]=1;
01553 else if (!strcmp(line,"* End_leader_datapoints:_NORMAL"))
01554 checkprocess[NUMPROCESSES]=1;
01555 else if (!strcmp(line,endnormal[pr_s_porbits]))
01556 checkprocess[pr_s_porbits]=1;
01557 else if (!strcmp(line,endnormal[pr_s_crop]))
01558 checkprocess[pr_s_crop]=1;
01559
01560 else if (!strcmp(line,endnormal[pr_s_oversample]))
01561 checkprocess[pr_s_oversample]=1;
01562
01563 else if (!strcmp(line,endnormal[pr_s_filtazi]))
01564 checkprocess[pr_s_filtazi]=1;
01565 else if (!strcmp(line,endnormal[pr_s_filtrange]))
01566 checkprocess[pr_s_filtrange]=1;
01567 else if (!strcmp(line,endnormal[pr_s_resample]))
01568 checkprocess[pr_s_resample]=1;
01569 else if (!strcmp(line,endnormal[pr_s_EXTRA]))
01570 checkprocess[pr_s_EXTRA]=1;
01571 }
01572
01573 else if (fileid == INTERFID)
01574 {
01575
01576 if (!strcmp(line,endnormal[pr_i_coarse]))
01577 checkprocess[pr_i_coarse]=1;
01578 else if (!strcmp(line,endnormal[pr_i_coarse2]))
01579 checkprocess[pr_i_coarse2]=1;
01580 else if (!strcmp(line,endnormal[pr_i_fine]))
01581 checkprocess[pr_i_fine]=1;
01582 else if (!strcmp(line,endnormal[pr_i_coregpm]))
01583 checkprocess[pr_i_coregpm]=1;
01584 else if (!strcmp(line,endnormal[pr_i_interfero]))
01585 checkprocess[pr_i_interfero]=1;
01586 else if (!strcmp(line,endnormal[pr_i_coherence]))
01587 checkprocess[pr_i_coherence]=1;
01588 else if (!strcmp(line,endnormal[pr_i_comprefpha]))
01589 checkprocess[pr_i_comprefpha]=1;
01590 else if (!strcmp(line,endnormal[pr_i_subtrrefpha]))
01591 checkprocess[pr_i_subtrrefpha]=1;
01592 else if (!strcmp(line,endnormal[pr_i_comprefdem]))
01593 checkprocess[pr_i_comprefdem]=1;
01594 else if (!strcmp(line,endnormal[pr_i_subtrrefdem]))
01595 checkprocess[pr_i_subtrrefdem]=1;
01596 else if (!strcmp(line,endnormal[pr_i_filtphase]))
01597 checkprocess[pr_i_filtphase]=1;
01598 else if (!strcmp(line,endnormal[pr_i_unwrap]))
01599 checkprocess[pr_i_unwrap]=1;
01600 else if (!strcmp(line,endnormal[pr_i_slant2h]))
01601 checkprocess[pr_i_slant2h]=1;
01602 else if (!strcmp(line,endnormal[pr_i_geocoding]))
01603 checkprocess[pr_i_geocoding]=1;
01604 else if (!strcmp(line,endnormal[pr_i_dinsar]))
01605 checkprocess[pr_i_dinsar]=1;
01606 else if (!strcmp(line,endnormal[pr_i_EXTRA2]))
01607 checkprocess[pr_i_EXTRA2]=1;
01608 }
01609 else
01610 {
01611 PRINT_ERROR("wrong input.")
01612 throw(unhandled_case_error);
01613 }
01614 }
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638 void fillprocessed(
01639 const char *line,
01640 int16 checkprocess[NUMPROCESSES+1],
01641 int16 fileid)
01642 {
01643 TRACE_FUNCTION("fillprocessed (BK 16-Dec-1998)")
01644 bool space=false;
01645 char ch='\t';
01646 int32 tin;
01647
01648 int32 linesz = strlen(line);
01649 if (linesz > 30)
01650 return;
01651 char word[ONE27];
01652
01653 for (register int32 i=0;i<linesz;i++)
01654 {
01655 ch = line[i];
01656 word[i]=ch;
01657 if (isspace(tin=ch))
01658 {
01659 space = true;
01660 if (line[i-1]==':')
01661 {
01662 word[i]='\0';
01663 break;
01664 }
01665 else
01666 {
01667 return;
01668 }
01669 }
01670 }
01671 if (!space) return;
01672
01673 int16 processflag;
01674 if (line[linesz-1]=='0')
01675 processflag=0;
01676 else if (line[linesz-1]=='1')
01677 processflag=1;
01678 else
01679 return;
01680
01681
01682 switch (fileid)
01683 {
01684 case MASTERID:
01685 if (!strcmp(word,processcontrol[pr_m_readfiles]))
01686 checkprocess[pr_m_readfiles]=processflag;
01687 else if (!strcmp(word,processcontrol[pr_m_porbits]))
01688 checkprocess[pr_m_porbits]=processflag;
01689 else if (!strcmp(word,processcontrol[pr_m_crop]))
01690 checkprocess[pr_m_crop]=processflag;
01691
01692 else if (!strcmp(word,processcontrol[pr_m_oversample]))
01693 checkprocess[pr_m_oversample]=processflag;
01694
01695 else if (!strcmp(word,processcontrol[pr_m_filtazi]))
01696 checkprocess[pr_m_filtazi]=processflag;
01697 else if (!strcmp(word,processcontrol[pr_m_filtrange]))
01698 checkprocess[pr_m_filtrange]=processflag;
01699 else if (!strcmp(word,processcontrol[pr_m_EXTRA]))
01700 checkprocess[pr_m_EXTRA]=processflag;
01701 else
01702 DEBUG.print("(Strange, also a word ending on :), not correct word.");
01703 break;
01704
01705 case SLAVEID:
01706 if (!strcmp(word,processcontrol[pr_s_readfiles]))
01707 checkprocess[pr_s_readfiles]=processflag;
01708 else if (!strcmp(word,processcontrol[pr_s_porbits]))
01709 checkprocess[pr_s_porbits]=processflag;
01710 else if (!strcmp(word,processcontrol[pr_s_crop]))
01711 checkprocess[pr_s_crop]=processflag;
01712
01713 else if (!strcmp(word,processcontrol[pr_s_oversample]))
01714 checkprocess[pr_s_oversample]=processflag;
01715
01716 else if (!strcmp(word,processcontrol[pr_s_filtazi]))
01717 checkprocess[pr_s_filtazi]=processflag;
01718 else if (!strcmp(word,processcontrol[pr_s_filtrange]))
01719 checkprocess[pr_s_filtrange]=processflag;
01720 else if (!strcmp(word,processcontrol[pr_s_resample]))
01721 checkprocess[pr_s_resample]=processflag;
01722 else if (!strcmp(word,processcontrol[pr_s_EXTRA]))
01723 checkprocess[pr_s_EXTRA]=processflag;
01724 else
01725 DEBUG.print("(Strange, also a word ending on :), not correct word.");
01726 break;
01727
01728
01729 case INTERFID:
01730 if (!strcmp(word,processcontrol[pr_i_coarse]))
01731 checkprocess[pr_i_coarse]=processflag;
01732 else if (!strcmp(word,processcontrol[pr_i_coarse2]))
01733 checkprocess[pr_i_coarse2]=processflag;
01734 else if (!strcmp(word,processcontrol[pr_i_fine]))
01735 checkprocess[pr_i_fine]=processflag;
01736 else if (!strcmp(word,processcontrol[pr_i_coregpm]))
01737 checkprocess[pr_i_coregpm]=processflag;
01738 else if (!strcmp(word,processcontrol[pr_i_interfero]))
01739 checkprocess[pr_i_interfero]=processflag;
01740 else if (!strcmp(word,processcontrol[pr_i_coherence]))
01741 checkprocess[pr_i_coherence]=processflag;
01742 else if (!strcmp(word,processcontrol[pr_i_comprefpha]))
01743 checkprocess[pr_i_comprefpha]=processflag;
01744 else if (!strcmp(word,processcontrol[pr_i_subtrrefpha]))
01745 checkprocess[pr_i_subtrrefpha]=processflag;
01746 else if (!strcmp(word,processcontrol[pr_i_comprefdem]))
01747 checkprocess[pr_i_comprefdem]=processflag;
01748 else if (!strcmp(word,processcontrol[pr_i_subtrrefdem]))
01749 checkprocess[pr_i_subtrrefdem]=processflag;
01750 else if (!strcmp(word,processcontrol[pr_i_filtphase]))
01751 checkprocess[pr_i_filtphase]=processflag;
01752 else if (!strcmp(word,processcontrol[pr_i_unwrap]))
01753 checkprocess[pr_i_unwrap]=processflag;
01754 else if (!strcmp(word,processcontrol[pr_i_slant2h]))
01755 checkprocess[pr_i_slant2h]=processflag;
01756 else if (!strcmp(word,processcontrol[pr_i_geocoding]))
01757 checkprocess[pr_i_geocoding]=processflag;
01758 else if (!strcmp(word,processcontrol[pr_i_dinsar]))
01759 checkprocess[pr_i_dinsar]=processflag;
01760 else if (!strcmp(word,processcontrol[pr_i_EXTRA2]))
01761 checkprocess[pr_i_EXTRA2]=processflag;
01762 else
01763 DEBUG.print("(Strange, also a word ending on :), not correct word.");
01764 break;
01765
01766 default:
01767 PRINT_ERROR("wrong input.")
01768 throw(unhandled_case_error);
01769 }
01770 }
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785 int32 filelines(
01786 const char *file)
01787 {
01788 TRACE_FUNCTION("filelines (BK 10-Jun-1999)")
01789 char dummyline[ONE27];
01790 register int32 nlines = 0;
01791
01792 ifstream ifile(file, ios::in);
01793 bk_assert(ifile,file,__FILE__,__LINE__);
01794 while (ifile)
01795 {
01796 ifile.getline(dummyline,ONE27,'\n');
01797 nlines++;
01798 }
01799 ifile.clear();
01800 ifile.close();
01801 return nlines-1;
01802 }
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816 bool existed(
01817 const char *file)
01818 {
01819 bool exists = false;
01820
01821 ifstream ifile(file, ios::in);
01822 if (ifile)
01823 {
01824 exists = true;
01825 DEBUG << "file: " << file << " does exist.";
01826 }
01827 else
01828 {
01829 DEBUG << "file: " << file << " does not exist.";
01830 }
01831 DEBUG.print();
01832
01833 ifile.close();
01834 return exists;
01835
01836 }
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852 void removedatleader(
01853 const char* file)
01854 {
01855 TRACE_FUNCTION("removedatleader (BK 07-Jan-1999)")
01856
01857
01858
01859
01860 ifstream ifile(file, ios::in);
01861 bk_assert(ifile,file,__FILE__,__LINE__);
01862 ofstream tmpfile("scratchtmp", ios::out | ios::trunc);
01863 bk_assert(tmpfile,"removedatleader: scratchtmp",__FILE__,__LINE__);
01864
01865
01866 char dummyline[ONE27];
01867
01868 ifile.getline(dummyline,ONE27,'\n');
01869 while (ifile && strcmp(dummyline,"*_Start_leader_datapoints"))
01870 {
01871 tmpfile << dummyline << endl;
01872 ifile.getline(dummyline,ONE27,'\n');
01873 }
01874 if (!ifile) return;
01875
01876
01877 while (ifile && strcmp(dummyline,"* End_leader_datapoints:_NORMAL"))
01878 {
01879 ifile.getline(dummyline,ONE27,'\n');
01880 }
01881 ifile.getline(dummyline,ONE27,'\n');
01882
01883
01884 while (ifile)
01885 {
01886 tmpfile << dummyline << endl;
01887 ifile.getline(dummyline,ONE27,'\n');
01888 }
01889
01890
01891 ifile.close();
01892 tmpfile.close();
01893 if (rename("scratchtmp",file))
01894 {
01895 ERROR << "Could not rename file: scratchtmp to: " << file;
01896 PRINT_ERROR(ERROR.get_str())
01897 throw(file_error);
01898 }
01899 }
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914 uint filesize(
01915 const char* file)
01916 {
01917 TRACE_FUNCTION("filesize (BK 08-Jan-1999)")
01918
01919
01920
01921 ifstream ifile(file, ios::in);
01922 #ifdef __DEBUG
01923 bk_assert(ifile,file,__FILE__,__LINE__);
01924 #endif
01925 ifile.seekg(0,ios::end);
01926
01927 return ifile.tellg();
01928 }
01929
01930
01931
01932
01933
01934
01935
01936
01937 window getoverlap(
01938 const window &master,
01939 const window &slave)
01940 {
01941 TRACE_FUNCTION("getoverlap (BK 10-Mar-1999)")
01942 window overlap = slave;
01943 if (master.linelo>overlap.linelo) overlap.linelo=master.linelo;
01944 if (master.linehi<overlap.linehi) overlap.linehi=master.linehi;
01945 if (master.pixlo >overlap.pixlo) overlap.pixlo =master.pixlo;
01946 if (master.pixhi <overlap.pixhi) overlap.pixhi =master.pixhi;
01947 return overlap;
01948 }
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958 window getoverlap(
01959 const slcimage &master,
01960 const slcimage &slave,
01961 const matrix<real8> &cpmL,
01962 const matrix<real8> &cpmP)
01963 {
01964 TRACE_FUNCTION("getoverlap (BK 10-Mar-1999)")
01965
01966
01967 const real8 minL = master.originalwindow.linelo;
01968 const real8 maxL = master.originalwindow.linehi;
01969 const real8 minP = master.originalwindow.pixlo;
01970 const real8 maxP = master.originalwindow.pixhi;
01971
01972 INFO << "getoverlap: polynomial normalized by factors: "
01973 << minL << " " << maxL << " " << minP << " " << maxP
01974 << " to [-2,2]";
01975 INFO.print();
01976
01977
01978
01979
01980
01981 real8 approxoffL = cpmL(0,0);
01982 real8 approxoffP = cpmP(0,0);
01983
01984
01985
01986
01987
01988 const real8 sL00 = slave.currentwindow.linelo -
01989 polyval(normalize(real8(slave.currentwindow.linelo)-approxoffL,minL,maxL),
01990 normalize(real8(slave.currentwindow.pixlo) -approxoffP,minP,maxP),
01991 cpmL);
01992 const real8 sP00 = slave.currentwindow.pixlo -
01993 polyval(normalize(real8(slave.currentwindow.linelo)-approxoffL,minL,maxL),
01994 normalize(real8(slave.currentwindow.pixlo) -approxoffP,minP,maxP),
01995 cpmP);
01996 const real8 sL0N = slave.currentwindow.linelo -
01997 polyval(normalize(real8(slave.currentwindow.linelo)-approxoffL,minL,maxL),
01998 normalize(real8(slave.currentwindow.pixhi) -approxoffP,minP,maxP),
01999 cpmL);
02000 const real8 sP0N = slave.currentwindow.pixhi -
02001 polyval(normalize(real8(slave.currentwindow.linelo)-approxoffL,minL,maxL),
02002 normalize(real8(slave.currentwindow.pixhi) -approxoffP,minP,maxP),
02003 cpmP);
02004 const real8 sLN0 = slave.currentwindow.linehi -
02005 polyval(normalize(real8(slave.currentwindow.linehi)-approxoffL,minL,maxL),
02006 normalize(real8(slave.currentwindow.pixlo) -approxoffP,minP,maxP),
02007 cpmL);
02008 const real8 sPN0 = slave.currentwindow.pixlo -
02009 polyval(normalize(real8(slave.currentwindow.linehi)-approxoffL,minL,maxL),
02010 normalize(real8(slave.currentwindow.pixlo) -approxoffP,minP,maxP),
02011 cpmP);
02012 const real8 sLNN = slave.currentwindow.linehi -
02013 polyval(normalize(real8(slave.currentwindow.linehi)-approxoffL,minL,maxL),
02014 normalize(real8(slave.currentwindow.pixhi) -approxoffP,minP,maxP),
02015 cpmL);
02016 const real8 sPNN = slave.currentwindow.pixhi -
02017 polyval(normalize(real8(slave.currentwindow.linehi)-approxoffL,minL,maxL),
02018 normalize(real8(slave.currentwindow.pixhi) -approxoffP,minP,maxP),
02019 cpmP);
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033 window win;
02034 win.linelo = max(int32(master.currentwindow.linelo),
02035 int32(ceil(max(sL00,sL0N))));
02036 win.linehi = min(int32(master.currentwindow.linehi),
02037 int32(floor(min(sLN0,sLNN))));
02038 win.pixlo = max(int32(master.currentwindow.pixlo),
02039 int32(ceil(max(sP00,sPN0))));
02040 win.pixhi = min(int32(master.currentwindow.pixhi),
02041 int32(floor(min(sP0N,sPNN))));
02042
02043 #ifdef __DEBUG
02044 DEBUG.print("Finished getoverlap");
02045 DEBUG.print("Approximate overlap master/slave window:");
02046 win.disp();
02047 #endif
02048 return win;
02049 }
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070 matrix<real8> readcoeff(
02071 const char* file,
02072 const char* pattern,
02073 const int16 Ncoeff)
02074 {
02075 TRACE_FUNCTION("readcoeff (BK 12-Mar-1999)")
02076 char dummyline[ONE27];
02077 char word[EIGHTY];
02078 bool foundword = false;
02079 matrix<real8> coeffs(Ncoeff,1);
02080
02081
02082
02083 ifstream infile(file, ios::in);
02084 bk_assert(infile,file,__FILE__,__LINE__);
02085
02086
02087 while (infile)
02088 {
02089 infile >> word;
02090 if (strcmp(pattern,word))
02091 {
02092 infile.getline(dummyline,ONE27,'\n');
02093 }
02094 else
02095 {
02096 infile.getline(dummyline,ONE27,'\n');
02097 foundword = true;
02098 for (register int32 i=0;i<Ncoeff;i++)
02099 {
02100 infile >> coeffs(i,0);
02101 infile.getline(dummyline,ONE27,'\n');
02102 }
02103 break;
02104 }
02105 }
02106 infile.close();
02107
02108 if (!foundword)
02109 {
02110 ERROR << "readcoeff: file: " << file
02111 << ": could not find string \"" << pattern << "\".";
02112 PRINT_ERROR(ERROR.get_str());
02113 throw(file_error);
02114 }
02115 else
02116 {
02117 INFO << "read: " << Ncoeff << " coefficients after: \""
02118 << pattern << "\"";
02119 INFO.print();
02120 }
02121
02122 return coeffs;
02123 }
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139 void openfstream(
02140 ifstream &stream,
02141 const char* ifilename)
02142 {
02143 TRACE_FUNCTION("openfstream (BK 11-Sep-2004)")
02144 DEBUG << "Opening input file: " << ifilename;
02145 DEBUG.print();
02146 #ifdef __NO_IOS_BINARY__
02147 stream.open(ifilename, ios::in);
02148 #else
02149 stream.open(ifilename, ios::in | ios::binary);
02150 #endif
02151 }
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166
02167
02168 void openfstream(
02169 ofstream &stream,
02170 const char* ofilename,
02171 const bool overwrite)
02172 {
02173 TRACE_FUNCTION("openfstream (BK 11-Sep-2004)")
02174 DEBUG << "Opening output file: " << ofilename;
02175 DEBUG.print();
02176 if (overwrite == true)
02177 {
02178 #ifdef __NO_IOS_BINARY__
02179 stream.open(ofilename, ios::out | ios::trunc);
02180 #else
02181 stream.open(ofilename, ios::out | ios::binary | ios::trunc);
02182 #endif
02183 }
02184 else
02185 {
02186 if (existed(ofilename) == true)
02187 {
02188 ERROR << "output file \": "
02189 << ofilename << "\" exists, use OVERWRITE ON";
02190 PRINT_ERROR(ERROR.get_str())
02191 throw(file_error);
02192 }
02193 else
02194 {
02195 #ifdef __NO_IOS_BINARY__
02196 stream.open(ofilename, ios::out);
02197 #else
02198 stream.open(ofilename, ios::out | ios::binary);
02199 #endif
02200 }
02201 }
02202 }
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221 void bk_assert(
02222 const ifstream &stream,
02223 const char* ofilename,
02224 const char* callingfile,
02225 int32 linenumber)
02226 {
02227 TRACE_FUNCTION("bk_assert (BK 04-Jun-1999)")
02228 DEBUG << "Opened input file: " << ofilename;
02229 DEBUG.print();
02230 if (!stream)
02231 {
02232 ERROR << "Unable to open input file: " << ofilename
02233 << " in source file: " << callingfile
02234 << " at line: " << linenumber;
02235 PRINT_ERROR(ERROR.get_str());
02236 throw(file_error);
02237 }
02238 }
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255 void bk_assert(
02256 const ofstream &stream,
02257 const char* ofilename,
02258 const char* callingfile,
02259 int32 linenumber)
02260 {
02261 TRACE_FUNCTION("bk_assert (BK 04-Jun-1999)")
02262 DEBUG << "Opened output file: " << ofilename;
02263 DEBUG.print();
02264 if (!stream)
02265 {
02266 ERROR << "Unable to open output file: " << ofilename
02267 << " in source file: " << callingfile
02268 << " at line: " << linenumber
02269 << " (OVERWRIT OFF/non existing directory?)";
02270 PRINT_ERROR(ERROR.get_str());
02271 throw(file_error);
02272 }
02273 }
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287 void tolower(char *s)
02288 {
02289 TRACE_FUNCTION("tolower (BK 06-Sep-1999)")
02290 while (*s != '\0')
02291 *s++ = tolower(*s);
02292 }
02293
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305 void toupper(char *s)
02306 {
02307 TRACE_FUNCTION("toupper (BK 06-Sep-1999)")
02308 while (*s != '\0')
02309 *s++ = toupper(*s);
02310 }
02311
02312