Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

readinput.cc

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999-2003 Bert Kampes
00003  * Copyright (c) 1999-2003 Delft University of Technology, The Netherlands
00004  *
00005  * This file is part of Doris, the Delft o-o radar interferometric software.
00006  *
00007  * Doris program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * Doris is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * Publications that contain results produced by the Doris software should
00022  * contain an acknowledgment. (For example: The interferometric processing
00023  * was performed using the freely available Doris software package developed
00024  * by the Delft Institute for Earth-Oriented Space Research (DEOS), Delft
00025  * University of Technology, or include a reference to: Bert Kampes and
00026  * Stefania Usai. \"Doris: The Delft Object-oriented Radar Interferometric
00027  * software.\" In: proceedings 2nd ITC ORS symposium, August 1999. (cdrom)).
00028  *
00029  */
00030 /****************************************************************
00031  * $Source: /users/kampes/DEVELOP/DORIS/doris/src/RCS/readinput.cc,v $
00032  * $Revision: 3.32 $
00033  * $Date: 2005/04/16 07:03:52 $
00034  * $Author: kampes $
00035  *
00036  * implementation of readinput.
00037  ****************************************************************/
00038 
00039 #include "matrixbk.hh"
00040 #include "constants.hh"         // global constants
00041 #include "refsystems.hh"        // for axis ellipsoid
00042 #include "ioroutines.hh"        // ?
00043 #include "utilities.hh"         // ispower2
00044 #include "conversion.hh"        // rad2deg
00045 #include "exceptions.hh"                 // my exceptions class
00046 
00047 #include <fstream>              // for file streams
00048 #include <strstream>            // for file streams
00049 #include <iomanip>              // for setprecision etc.
00050 #include <cstring>              // for strcmp etc.
00051 #include <cstdlib>              // exit, atoi
00052 #include <cctype>               // isspace
00053 
00054 
00055 
00056 // ______ displevel used in ioroutines.h, changed here ______
00057 char WARNS[6][ONE27];           // remember 6 last warnings in WARNS
00058 int32   beeplevel=1;            // global variable for beeping.
00059                                 // 0:  nobeep; BEEP OFF
00060                                 // -1: beep on error exit ; BEEP ERROR
00061                                 // 1:  beep on error, warnings; BEEP WARNING
00062                                 // 2:  beep on error, warnings, progress;
00063                                 //     BEEP PROGRESS, BEEP [ON]
00064 int32   displevel=30000;        // controls level of screen output
00065                                 // -100 only errors
00066                                 // 0:     warnings and errors
00067                                 // 10000: progress, warn and err
00068                                 // 20000: info, pro, warn and err
00069                                 // 30000: debug, info, pro, warn, err
00070 
00071 
00072 // ______ Checks input prototypes (see below in this file) ______
00073 void checkgeneral     (input_gen               &generalinput, const int16 onlyprocess);
00074 void checkreadfiles   (const input_readfiles   &readfilesinput, const int16 id);
00075 void checkcrop        (const input_crop         &cropinput, const int16 id);
00076 //____RaffaeleNutricato START MODIFICATION SECTION 1
00077 void checkoversample  (const input_oversample  &oversampleinput, const int16 id);
00078 //____RaffaeleNutricato END MODIFICATION SECTION 1
00079 void checkporbits     (const input_pr_orbits   &porbitsinput, const int16 id);
00080 void checkslant2h     (const input_slant2h     &slant2hinput);
00081 void checkunwrap      (const input_unwrap      &unwrapinput);
00082 void checkgeocode     (const input_geocode     &geocodeinput);
00083 void checkcoarsecorr  (const input_coarsecorr  &coarsecorrinput);
00084 void checkfine        (const input_fine        &fineinput);
00085 void checkcoregpm     (const input_coregpm     &coregpminput);
00086 void checkcomprefpha  (const input_comprefpha  &comprefphainput);
00087 void checksubtrrefpha (const input_subtrrefpha &subtrrefphainput);
00088 void checkresample    (const input_resample    &resampleinput);
00089 void checkinterfero   (const input_interfero   &interferoinput);
00090 void checkcoherence   (const input_coherence   &coherenceinput);
00091 void checkcomprefdem  (const input_comprefdem  &comprefdeminput);
00092 void checksubtrrefdem (const input_subtrrefdem &subtrrefdeminput);
00093 void checkfiltrange   (const input_filtrange   &filtrangeinput);
00094 void checkdinsar      (const input_dinsar      &dinsarinput);
00095 void checkfiltphase   (const input_filtphase   &filtphaseinput);
00096 void checkfiltazi     (const input_filtazi     &filtaziinput, const int16 id);
00097 
00098 /****************************************************************
00099  *    writearg                                                  *
00100  * echo arg to screen if debug defined                          *
00101  #%// BK 13-Jul-2000                                            *
00102  ****************************************************************/
00103 template <class Type>
00104 void writearg(const Type argument)
00105   {
00106   TRACE_FUNCTION("writearg");
00107   DEBUG << "Read argument: " << argument;
00108   DEBUG.print();
00109   } // END writearg
00110 
00111 
00112 
00113 /****************************************************************
00114  *    readinput                                                 *
00115  *                                                              *
00116  * Read and interpret                                           *
00117  * "inputoptionsfile" (file in variable: logfile).              *
00118  * Write to logfile (via "scratchreadinput")                    *
00119  * mandatory input is checked on presence by checksums (cs).    *
00120  * If there are more methods, process card switches default     *
00121  *  methodselector (if present) is used later to correct        *
00122  *  see for example unwrap methodeselector                      *
00123  * linecounter only used in case of errors                      *
00124  *                                                              *
00125  * input:                                                       *
00126  *  - struct: general input options                             *
00127  *  - struct: master readfiles input options                    *
00128  *  - struct: slave readfiles input options                     *
00129  *  - struct: master crop input options                         *
00130  *  - struct: slave crop input options                          *
00131  *  - ...                                                       *
00132  * output:                                                      *
00133  *  - (updated input structs)                                   *
00134  *  - (file copy of input)                                      *
00135  *                                                              *
00136  *    Bert Kampes, 11-Dec-1998                                  *
00137  ****************************************************************/
00138 void readinput(
00139         input_gen         &generalinput, 
00140         input_ell         &ellipsinput,
00141         input_pr_orbits   &porbitsinput,
00142         input_readfiles   &m_readfilesinput,
00143         input_crop         &m_cropinput,
00144 //____RaffaeleNutricato START MODIFICATION SECTION 2
00145         input_oversample  &m_oversample, 
00146 //____RaffaeleNutricato END MODIFICATION SECTION 2
00147         input_readfiles   &s_readfilesinput,
00148         input_crop         &s_cropinput,
00149 //____RaffaeleNutricato START MODIFICATION SECTION 3
00150         input_oversample  &s_oversample, 
00151 //____RaffaeleNutricato END MODIFICATION SECTION 3
00152         input_filtazi     &filtaziinput,
00153         input_coarsecorr  &coarsecorrinput,
00154         input_fine        &fineinput,
00155         input_coregpm     &coregpminput,
00156         input_resample    &resampleinput,
00157         input_filtrange   &filtrangeinput,
00158         input_interfero   &interferoinput,
00159         input_coherence   &coherenceinput,
00160         input_comprefpha  &comprefphainput,
00161         input_subtrrefpha &subtrrefphainput,
00162         input_comprefdem  &comprefdeminput,
00163         input_subtrrefdem &subtrrefdeminput,
00164         input_filtphase   &filtphaseinput,
00165         input_dinsar      &dinsarinput,
00166         input_unwrap      &unwrapinput,
00167         input_slant2h     &slant2hinput,
00168         input_geocode     &geocodeinput)
00169   {
00170   TRACE_FUNCTION("readinput (BK 11-Dec-1998)");
00171 
00172   // ______ Set ids ______
00173   m_readfilesinput.fileid = MASTERID;
00174   m_cropinput.fileid      = MASTERID;
00175   s_readfilesinput.fileid = SLAVEID;
00176   s_cropinput.fileid      = SLAVEID;
00177 
00178   // ______ Misuse generalinput.logfile to store name: open file here! ______
00179   //ifstream optionsfile(generalinput.logfile, ios::in | ios::nocreate);
00180   ifstream optionsfile(generalinput.logfile, ios::in);
00181   bk_assert(optionsfile,generalinput.logfile,__FILE__,__LINE__);
00182 
00183   int16                 onlyprocess     = -1;        // flag for ONLYPROCESS card
00184   int16                 linecnt         =  0;        // counter
00185   char                  keyword[EIGHTY];
00186   char                  filename[EIGHTY];            // string for filenames
00187   char                  dummyline[ONE27];
00188 
00189   // ______ Check (multiple) occurence of cards ______
00190   bool                  priorscreen     = false;     // no screen card present
00191   bool                  priormemory     = false;     // check if present for info
00192   bool                  priorbatch      = false;     // check if present for info
00193   bool                  prioroverwrite  = false;     // check if present for info
00194   bool                  priorlistinput  = false;     // check if present for info
00195   bool                  priorrs_fileout = false;     // 
00196 
00197 
00198 // ====== Initialization, defaults ======
00199   bool                  listinput  = true;      // default copy input to log
00200   bool                  ellipsoid  = false;     // set default if no card present
00201   ellipsinput.a                 = WGS84_A;              // later e2, e2b
00202   ellipsinput.b                 = WGS84_B;              // later e2, e2b
00203   strcpy(ellipsinput.name,"WGS84");                     // 
00204 
00205   register int32 i;
00206   for (i=0; i<NUMPROCESSES; i++)
00207     generalinput.process[i] = 0;                         // default no processing step
00208   generalinput.interactive      = true;                 // default interactive mode
00209   generalinput.overwrit         = false;                // default no overwriting
00210   generalinput.memory           = 20000000;             // default memory (20MB)
00211   strcpy(generalinput.logfile,    "log.out");           // default logfile
00212   strcpy(generalinput.m_resfile,  "master_result.out"); // default resultfile
00213   strcpy(generalinput.s_resfile,  "slave_result.out");  // default resultfile
00214   strcpy(generalinput.i_resfile,  "interferogram.out"); // default interf_out
00215   generalinput.orb_interp       = ORB_DEFAULT;          // default polyfit
00216   generalinput.dumpbaselineL    = 0;                    // default no dump
00217   generalinput.dumpbaselineP    = 0;                    // default no dump
00218   generalinput.preview          = 0;                    // default no preview
00219   generalinput.terrain_height   = 0.0;                  // above ellipsoid
00220   generalinput.tiepoint.x       = 0.0;                  // default none
00221   generalinput.tiepoint.y       = 0.0;                  // default none
00222   generalinput.tiepoint.z       = 0.0;                  // default none
00223 
00224   //m_readfilesinput.method     = readfiles_ers;        // default
00225   m_readfilesinput.sensor_id    = SLC_ERS;              // default
00226   setunspecified(m_readfilesinput.volfile);             // check later, then set default
00227   setunspecified(m_readfilesinput.leaderfile);          // check later, then set default
00228   setunspecified(m_readfilesinput.nullfile);            // check later, then set default
00229   setunspecified(m_readfilesinput.datfile);             // check later, then set default
00230   m_readfilesinput.rg_timing_error = 0.0;               // default
00231   m_readfilesinput.az_timing_error = 0.0;               // default
00232   //s_readfilesinput.sensor_id          = readfiles_ers;        // default
00233   s_readfilesinput.sensor_id    = SLC_ERS;              // default
00234   setunspecified(s_readfilesinput.volfile);             // check later, then set default
00235   setunspecified(s_readfilesinput.leaderfile);          // check later, then set default
00236   setunspecified(s_readfilesinput.nullfile);            // check later, then set default
00237   setunspecified(s_readfilesinput.datfile);             // check later, then set default
00238   s_readfilesinput.rg_timing_error = 0.0;               // default
00239   s_readfilesinput.az_timing_error = 0.0;               // default
00240 
00241   setunspecified(porbitsinput.m_orbdir);                // check later, then set default
00242   setunspecified(porbitsinput.s_orbdir);                // check later, then set default
00243   porbitsinput.timeinterval     = 1;                    // default time interval
00244   porbitsinput.timebefore       = 4*porbitsinput.timeinterval;   // default 4 extra datapoints
00245   porbitsinput.dumpmasterorbit  = -1.;                  // default no dump
00246   porbitsinput.dumpslaveorbit   = -1.;                  // default no dump
00247 
00248   strcpy(m_cropinput.idcrop,"master step01");           // default identifier
00249   strcpy(s_cropinput.idcrop,"slave step01");            // default identifier
00250   strcpy(m_cropinput.fileout1,"master.raw");            // default output filename
00251   strcpy(s_cropinput.fileout1,"slave.raw");             // default output filename
00252   m_cropinput.dbow.linelo       = 0;                    // min. line coord. initialization
00253   m_cropinput.dbow.linehi       = 0;                    // max. line coord. initialization
00254   m_cropinput.dbow.pixlo        = 0;                    // min. pixel coord. initialization
00255   m_cropinput.dbow.pixhi        = 0;                    // max. pixel coord. initialization
00256   s_cropinput.dbow.linelo       = 0;                    // min. line coord. initialization
00257   s_cropinput.dbow.linehi       = 0;                    // max. line coord. initialization
00258   s_cropinput.dbow.pixlo        = 0;                    // min. pixel coord. initialization
00259   s_cropinput.dbow.pixhi        = 0;                    // max. pixel coord. initialization
00260   m_cropinput.dbow_geo.linelo   = 0;                    // min. line coord. initialization
00261   m_cropinput.dbow_geo.linehi   = 0;                    // max. line coord. initialization
00262   m_cropinput.dbow_geo.pixlo    = 0;                    // min. pixel coord. initialization
00263   m_cropinput.dbow_geo.pixhi    = 0;                    // max. pixel coord. initialization
00264   s_cropinput.dbow_geo.linelo   = 0;                    // min. line coord. initialization
00265   s_cropinput.dbow_geo.linehi   = 0;                    // max. line coord. initialization
00266   s_cropinput.dbow_geo.pixlo    = 0;                    // min. pixel coord. initialization
00267   s_cropinput.dbow_geo.pixhi    = 0;                    // max. pixel coord. initialization
00268 
00269 //____RaffaeleNutricato START MODIFICATION SECTION 4
00270   m_oversample.OsrRange          = 1;                    // Default for oversampling ratio in range.
00271   m_oversample.OsrAzimuth        = 1;                    // Default for oversampling ratio in azimuth.
00272   m_oversample.FilterSize        = 16;                   // Default for length of the interpolation kernel in range. 
00273   m_oversample.oformatflag       = FORMATCI2;            // Default for output format.
00274   strcpy(m_oversample.fileoutovs,"master_ovs.raw");      // Default output filename.
00275   s_oversample.OsrRange          = 1;                    // Default for oversampling ratio in range.
00276   s_oversample.OsrAzimuth        = 1;                    // Default for oversampling ratio in azimuth.
00277   s_oversample.FilterSize        = 16;                   // Default for length of the interpolation kernel in range. 
00278   s_oversample.oformatflag       = FORMATCI2;            // Default for output format.
00279   strcpy(s_oversample.fileoutovs,"slave_ovs.raw");       // Default output filename.
00280 //____RaffaeleNutricato END MODIFICATION SECTION 4
00281 
00282   filtaziinput.oformatflag      = FORMATCR4;            // default
00283   filtaziinput.fftlength        = 1024;                 // default
00284   filtaziinput.overlap          = -1;                   // default to fftlength/8
00285   filtaziinput.hammingalpha     = 0.75;                 // default (slc)
00286   strcpy(filtaziinput.fomaster,"master.afilter");       // default
00287   strcpy(filtaziinput.foslave,"slave.afilter");         // default
00288 
00289   const int32 def_cc_nwin       = 11;                   // default #windows
00290   setunspecified(coarsecorrinput.ifpositions);          // check later, then set default
00291   coarsecorrinput.MasksizeL     = 64;                   // default correlation size
00292   coarsecorrinput.MasksizeP     = coarsecorrinput.MasksizeL;    // default correlation size
00293   coarsecorrinput.AccL          = 32;                   // default searching limit
00294   coarsecorrinput.AccP          = 8;                    // default searching limit
00295   coarsecorrinput.initoffsetL   = 0;                    // default initial offset
00296   coarsecorrinput.initoffsetP   = 0;                    // default initial offset
00297 
00298   setunspecified(fineinput.ifpositions);                // check later, then set default
00299   const int32 def_fc_nwin       = 101;                  // default #windows
00300   fineinput.MasksizeL           = 32;                   // default correlation size
00301   fineinput.MasksizeP           = fineinput.MasksizeL;  // default correlation size
00302   fineinput.AccL                = 4;                    // default searching limit
00303   fineinput.AccP                = fineinput.AccL;       // default searching limit
00304   fineinput.initoffsetL         = 0;                    // default initial offset
00305   fineinput.initoffsetP         = 0;                    // default initial offset
00306   fineinput.osfactor            = 16;                   // default oversampling factor
00307   fineinput.plotoffsets         = false;                // default no plotting
00308   fineinput.plotmagbg           = false;                // default no plotting
00309   fineinput.plotthreshold       = 0.4;                  // default no plotting
00310 
00311   coregpminput.threshold        = .4;                   // default threshold data
00312   coregpminput.degree           = 1;                    // default degree polynomial
00313   coregpminput.weightflag       = 0;                    // default no weighting of data
00314   coregpminput.maxiter          = 10;                   // default max. 10 outliers removed
00315   coregpminput.k_alpha          = 1.97;                 // critical value for outliers
00316   coregpminput.dumpmodel        = false;                // default no files
00317   coregpminput.plot             = false;                // default no plots
00318   coregpminput.plotmagbg        = false;                // default no plots
00319 
00320   filtrangeinput.method         = rf_adaptive;          // default
00321   filtrangeinput.terrainslope   = 0.;                   // default porbits
00322   filtrangeinput.fftlength      = -999;                 // set default later
00323   filtrangeinput.overlap        = 0;                    // default no overlap
00324   filtrangeinput.nlmean         = 15;                   // default
00325   filtrangeinput.hammingalpha   = 0.75;                 // default
00326   filtrangeinput.SNRthreshold   = 5.;                   // default
00327   filtrangeinput.oversample   = 2;                      // default
00328   filtrangeinput.doweightcorrel = false;                // default
00329   strcpy(filtrangeinput.fomaster,"master.rfilter");     // default
00330   strcpy(filtrangeinput.foslave,"slave.rfilter");       // default
00331   filtrangeinput.oformatflag    = FORMATCR4;            // default
00332 
00333   setunspecified(comprefphainput.ifpositions);          // check later, then set default
00334   const int32 def_fe_Npoints    = 501;                  // default
00335   const int32 def_fe_degree     = 5;                    // default
00336 
00337   strcpy(resampleinput.fileout,"s_resampled.raw");      // default
00338   resampleinput.oformatflag     = FORMATCR4;            // default
00339   resampleinput.dbow.linelo     = 0;                    // min. line coord. initialization
00340   resampleinput.dbow.linehi     = 0;                    // max. line coord. initialization
00341   resampleinput.dbow.pixlo      = 0;                    // min. pixel coord. initialization
00342   resampleinput.dbow.pixhi      = 0;                    // max. pixel coord. initialization
00343   resampleinput.shiftazi        = true;                 // default apply shift
00344 
00345   interferoinput.method         = int_oldmethod;        // default method
00346   setunspecified(interferoinput.focint);                // check later, then set default
00347   setunspecified(interferoinput.foint);                 // use later if specified
00348   //setunspecified(interferoinput.foflatearth);         // check later, then set default
00349   interferoinput.multilookL     = 5;                    // default multilookfactor
00350   interferoinput.multilookP     = 1;                    // default multilookfactor
00351 
00352   coherenceinput.method         = coh_oldmethod;        // default method
00353   setunspecified(coherenceinput.focoh);                 // check later, then set default
00354   setunspecified(coherenceinput.foccoh);                // check later, then set default
00355   coherenceinput.multilookL     = 10;                   // default multilookfactor
00356   coherenceinput.multilookP     = 2;                    // default multilookfactor
00357   coherenceinput.cohsizeL       = coherenceinput.multilookL;    // default windowsize. 
00358   coherenceinput.cohsizeP       = coherenceinput.multilookP;    // default windowsize. 
00359 
00360   subtrrefphainput.method       = srp_polynomial;       // default method
00361   strcpy(subtrrefphainput.forefpha, "refphase.raw");    // default name
00362   strcpy(subtrrefphainput.focint,"cint.minrefpha.raw");// default
00363   subtrrefphainput.multilookL   = 1;                    // default multilookfactor
00364   subtrrefphainput.multilookP   = 1;                    // default multilookfactor
00365   subtrrefphainput.dumponlyrefpha  = false;             // default not
00366 
00367   filtphaseinput.method         = fp_goldstein;         // default method
00368   filtphaseinput.alpha          = 0.2;                  // default
00369   // ______ 32 blocks default for goldstein, kernel as large as possible, ______
00370   // ______ 2Dkernel then specify ______
00371   filtphaseinput.blocksize      = 32;                   // default
00372   filtphaseinput.overlap        = 3;                    // default
00373   // set default later with alpha in name
00374   setunspecified(filtphaseinput.fofiltphase);           // check later, then set default
00375   setunspecified(filtphaseinput.fifiltphase);           // if specified, use it
00376   setunspecified(filtphaseinput.fikernel2d);            // if specified, use it
00377   filtphaseinput.finumlines     = 0;                    // numlines.
00378 
00379   strcpy(dinsarinput.fodinsar,"differentialinterf.raw");// default
00380   setunspecified(dinsarinput.foscaleduint);             // default no output
00381   // ______ set mastertopo file to same as master resfile if not specified ______
00382   setunspecified(dinsarinput.topomasterresfile);        // if specified, use 4 pass
00383   setunspecified(dinsarinput.toposlaveresfile);         // check later, mandatory
00384   setunspecified(dinsarinput.topointresfile);           // check later, mandatory
00385 
00386   setunspecified(comprefdeminput.firefdem);             // check later, mandatory
00387   setunspecified(comprefdeminput.fodem);                // check later, then set default
00388   setunspecified(comprefdeminput.fodemi);               // check later, then set default
00389   setunspecified(comprefdeminput.forefdemhei);          // check later, then set default
00390   strcpy(comprefdeminput.forefdem,"refdem.raw");        // default name
00391   comprefdeminput.iformatflag   = FORMATI2;             // default gtopo30
00392   comprefdeminput.method        = crd_trilinear;        // default method
00393   comprefdeminput.extradense    = 0.5;                  // default (now interpolated in l,p)
00394   comprefdeminput.demrows       = 6000;                 // default gtopo30
00395   comprefdeminput.demcols       = 4800;                 // default gtopo30
00396   comprefdeminput.demnodata     = -9999;                // default gtopo30
00397   comprefdeminput.demdeltalat   = deg2rad(0.00833333333333333333);// default gtopo30
00398   comprefdeminput.demdeltalon   = deg2rad(0.00833333333333333333);// default gtopo30
00399   comprefdeminput.demlatleftupper = deg2rad(89.995833333333333333);     // w020n90.DEM
00400   comprefdeminput.demlonleftupper = deg2rad(-19.995833333333333333);// w020n90.DEM
00401 
00402   strcpy(subtrrefdeminput.focint,"cint.minrefdem.raw"); // default name
00403   subtrrefdeminput.offsetL      = 0;                    // default no offset
00404   subtrrefdeminput.offsetP      = 0;                    // default no offset
00405 
00406   strcpy(unwrapinput.fouint,"unwrapped_interferogram.raw");     // default name
00407   strcpy(unwrapinput.foregions,"regions_unwrapped.raw");        // default name
00408   setunspecified(unwrapinput.seedfile);                 // check later, then set default
00409   unwrapinput.deltaLseed        = 100;                  // default 100 pixels;
00410   unwrapinput.deltaPseed        = unwrapinput.deltaLseed;       // default 100 pixels;
00411   setunspecified(unwrapinput.snaphu_log);// " "
00412   setunspecified(unwrapinput.snaphu_coh);// " "
00413   strcpy(unwrapinput.snaphu_mode,"TOPO");               // default TOPO
00414   strcpy(unwrapinput.snaphu_init,"MST");                // default method
00415   strcpy(unwrapinput.snaphu_verbose,"TRUE");            // default verbose
00416   unwrapinput.oformatflag       = FORMATHGT;
00417 
00418   slant2hinput.Npoints          = 200;                  // default 100 pixels;
00419   slant2hinput.degree1d         = 2;                    // default 2 
00420   slant2hinput.degree2d         = 5;                    // default 5
00421   slant2hinput.Nheights         = slant2hinput.degree1d+1;// minimum
00422   strcpy(slant2hinput.fohei,"hei.raw");                 // default
00423   strcpy(slant2hinput.fophi,"phi.raw");                 // default
00424   strcpy(slant2hinput.folam,"lam.raw");                 // default
00425 
00426   strcpy(geocodeinput.fophi,"geo_phi.raw");             // default name
00427   strcpy(geocodeinput.folam,"geo_lambda.raw");          // default name
00428 
00429 
00430 // ====== (default) Methods ======
00431   const int16 def_cc_method     = cc_magfft;
00432   const int16 def_fc_method     = fc_magfft;
00433   const int16 def_fe_method     = fe_porbits;
00434   const int16 def_rs_method     = rs_cc4p;
00435   const int16 def_uw_method     = uw_method2;// snaphu, system call, see www
00436   const int16 def_s2h_method    = s2h_ambiguity;
00437 
00438 // ______ To check later if default should be used ______
00439   coarsecorrinput.method        = def_cc_method  - 999; // default method (repair later)
00440   coarsecorrinput.Nwin          = def_cc_nwin    + 999; // default #windows
00441   fineinput.method              = def_fc_method  - 999; // default method (repair later)
00442   fineinput.Nwin                = def_fc_nwin    + 999; // default #windows
00443   unwrapinput.method            = def_uw_method  - 999; // default method (repair later)
00444   comprefphainput.method        = def_fe_method  - 999; // default method (repair later)
00445   comprefphainput.degree        = def_fe_degree  - 999; // default degree polynomial
00446   comprefphainput.Npoints       = def_fe_Npoints - 999; // default degree polynomial
00447   resampleinput.method          = def_rs_method  - 999; // default method (repair later)
00448   slant2hinput.method           = def_s2h_method - 999; // default method (repair later)
00449 
00450 
00451 
00452 
00453 
00454 // ====== Process "inputoptionsfile" ======
00455   bool continuereading = true;
00456   while (continuereading)                               // read file until STOP card
00457     {
00458     linecnt++;
00459     optionsfile >> keyword;
00460     DEBUG << linecnt << ": Read keyword: " << keyword;
00461     DEBUG.print();
00462     toupper(keyword);
00463 
00464 // *******************************************************************
00465 // *** GENERAL
00466 // *******************************************************************
00467     if (!strcmp(keyword,"COMMENT") ||
00468         !strcmp(keyword,"C")) 
00469       {
00470       ;                                         // comment: no action 
00471       }
00472     else if (!strncmp(keyword,"//",2) ||        // assume user comments out
00473              !strncmp(keyword,"#",1))           // with // or '#' as delimiter
00474       {                                         // but no blank after keyword
00475       ;                                         // comment: no action
00476       }
00477 //    else if (!strncmp(keyword,'\0',1))        // empty line?
00478 //      {                                               //
00479 //      ;                                               // comment: no action
00480 //      }
00481 
00482 // **********************************************************************
00483     else if (!strcmp(keyword,"BEEP"))   // level of beep output 
00484       {                                 // /progress/[warning]/error/ON/OFF
00485       optionsfile >> keyword;           // argument
00486       //writearg((char*)keyword);
00487       writearg(keyword);
00488       toupper(keyword);
00489       if (!strcmp(keyword,"ERROR"))
00490         {
00491         TRACE.bellrings(0);
00492         DEBUG.bellrings(0);
00493         INFO.bellrings(0);
00494         PROGRESS.bellrings(0);
00495         WARNING.bellrings(0);
00496         ERROR.bellrings(1);
00497         beeplevel = -1;
00498         INFO.print("BEEP: \tbeeping enabled at level: \tERROR");
00499         }
00500       else if (!strcmp(keyword,"PROGRESS"))
00501         {
00502         TRACE.bellrings(0);
00503         DEBUG.bellrings(0);
00504         INFO.bellrings(0);
00505         PROGRESS.bellrings(1);
00506         WARNING.bellrings(2);
00507         ERROR.bellrings(3);
00508         beeplevel =  2;
00509         INFO.print("BEEP: \tbeeping enabled at level: \tPROGRESS");
00510         }
00511       else if (!strcmp(keyword,"WARNING"))
00512         {
00513         TRACE.bellrings(0);
00514         DEBUG.bellrings(0);
00515         INFO.bellrings(0);
00516         PROGRESS.bellrings(0);
00517         WARNING.bellrings(1);
00518         ERROR.bellrings(2);
00519         beeplevel =  1;
00520         INFO.print("BEEP: \tbeeping enabled at level: \tWARNING");
00521         }
00522       else if (!strcmp(keyword,"OFF"))
00523         {
00524         TRACE.bellrings(0);
00525         DEBUG.bellrings(0);
00526         INFO.bellrings(0);
00527         PROGRESS.bellrings(0);
00528         WARNING.bellrings(0);
00529         ERROR.bellrings(0);
00530         beeplevel =  0;
00531         INFO.print("BEEP: \tbeeping disabled");
00532         }
00533       else if (!strcmp(keyword,"ON")    ||
00534                !strncmp(keyword,"//",2) ||      // comment
00535                !strncmp(keyword,"#",1) ||       // comment
00536                !strcmp(keyword,'\0'))           // no keyword
00537 //             !strcmp(keyword,""))             // no keyword
00538         {
00539         TRACE.bellrings(0);
00540         DEBUG.bellrings(0);
00541         INFO.bellrings(0);
00542         PROGRESS.bellrings(1);
00543         WARNING.bellrings(2);
00544         ERROR.bellrings(3);
00545         beeplevel =  2;
00546         INFO.print("BEEP: \tbeeping enabled for all levels: \tON");
00547         }
00548       else
00549         {
00550         beeplevel = 1;
00551         TRACE.bellrings(0);
00552         DEBUG.bellrings(0);
00553         INFO.bellrings(0);
00554         PROGRESS.bellrings(0);
00555         WARNING.bellrings(1);
00556         ERROR.bellrings(2);
00557         WARNING << "BEEP:   line " << linecnt
00558              << ": Argument " << keyword 
00559              << " not recognized."
00560              << " [error/warning/progress/on/off] I used WARNING.";
00561         WARNING.print();
00562         }
00563       } // BEEP key
00564 
00565 // **********************************************************************
00566     else if (!strcmp(keyword,"SCREEN")) // level of screen output 
00567       {                                 // debug/info/progress/warning or error
00568       switch (priorscreen)
00569         {
00570         case true:
00571           WARNING << "SCREEN: line " << linecnt << ": stdout: "
00572                << " ignored due to prior occurence.";
00573           WARNING.print();
00574           break;
00575 
00576         default:
00577           priorscreen = true;
00578           optionsfile >> keyword;                       // argument
00579           writearg(keyword);
00580           toupper(keyword);
00581           if (!strcmp(keyword,"INFO"))
00582             {
00583             TRACE.doprint(0);
00584             DEBUG.doprint(0);
00585             INFO.doprint(1);
00586             PROGRESS.doprint(1);
00587             WARNING.doprint(1);
00588             ERROR.doprint(1);
00589             displevel = 20000 + displevel%10000;        // for cnt #warnings
00590             INFO.print("SCREEN: \tverboseness: \t\t\tINFO");
00591             }
00592           else if (!strcmp(keyword,"PROGRESS"))
00593             {
00594             TRACE.doprint(0);
00595             DEBUG.doprint(0);
00596             INFO.doprint(1);
00597             PROGRESS.doprint(1);
00598             WARNING.doprint(1);
00599             ERROR.doprint(1);
00600             displevel = 10000 + displevel%10000;        // for cnt #warnings
00601             INFO.print("SCREEN: \tverboseness: \t\t\tPROGRESS");
00602             }
00603           else if (!strcmp(keyword,"DEBUG"))
00604             {
00605             TRACE.doprint(0);
00606             DEBUG.doprint(1);
00607             INFO.doprint(1);
00608             PROGRESS.doprint(1);
00609             WARNING.doprint(1);
00610             ERROR.doprint(1);
00611             displevel = 30000 + displevel%10000;        // for cnt #warnings
00612             INFO.print("SCREEN: \tverboseness: \t\t\tDEBUG");
00613             }
00614           else if (!strcmp(keyword,"TRACE"))
00615             {
00616             TRACE.doprint(1);
00617             DEBUG.doprint(1);
00618             INFO.doprint(1);
00619             PROGRESS.doprint(1);
00620             WARNING.doprint(1);
00621             ERROR.doprint(1);
00622             }
00623           else if (!strcmp(keyword,"WARNING"))
00624             {
00625             TRACE.doprint(0);
00626             DEBUG.doprint(0);
00627             INFO.doprint(0);
00628             PROGRESS.doprint(0);
00629             WARNING.doprint(1);
00630             ERROR.doprint(1);
00631             displevel = 0 + displevel%10000;            // for cnt #warnings;
00632             INFO.print("SCREEN: \tverboseness: \t\t\tWARNING");
00633             }
00634           else if (!strcmp(keyword,"ERROR"))
00635             {
00636             TRACE.doprint(0);
00637             DEBUG.doprint(0);
00638             INFO.doprint(0);
00639             PROGRESS.doprint(0);
00640             WARNING.doprint(0);
00641             ERROR.doprint(1);
00642             displevel = -100 + displevel%10000;         // for cnt #warnings
00643             INFO.print("SCREEN: \tverboseness: \t\t\tERROR");
00644             }
00645           else
00646             {
00647             TRACE.doprint(0);
00648             DEBUG.doprint(1);
00649             INFO.doprint(1);
00650             PROGRESS.doprint(1);
00651             WARNING.doprint(1);
00652             ERROR.doprint(1);
00653             WARNING << "SCREEN: line " << linecnt
00654                  << ": Argument " << keyword 
00655                  << " not recognized."
00656                  << " [error/warning/progress/info/debug] I used DEBUG.";
00657             WARNING.print();
00658             displevel = 30000 + displevel%10000;       // for cnt #warnings
00659             }
00660         } // switch
00661       } // SCREEN key
00662 
00663 // **********************************************************************
00664     else if (!strcmp(keyword,"MEMORY"))         // available mem in MB
00665       {
00666       switch (priormemory)
00667         {
00668         case true:
00669           WARNING << "MEMORY: line " << linecnt
00670                << ": ignored due to prior occurence.";
00671           WARNING.print();
00672           break;
00673 
00674         default:
00675           priormemory = true;
00676           optionsfile >> generalinput.memory;
00677           writearg(generalinput.memory);
00678           if (generalinput.memory > 10000)
00679             WARNING.print("MEMORY: > 10000 MB seems unlikely.");
00680           generalinput.memory *= 1000000;                       // in B
00681         } // switch
00682       } // MEMORY card
00683 
00684 // **********************************************************************
00685     else if (!strcmp(keyword,"BATCH"))                  // overrides interactive mode
00686       {
00687       switch (priorbatch)
00688         {
00689         case true:
00690           WARNING << "BATCH: line: " << linecnt << ": "
00691                << "ignored due to prior occurence.";
00692           WARNING.print();
00693           break;
00694         default:
00695           priorbatch = true;                            // flag for occurence
00696           optionsfile >> keyword;                       // argument
00697           writearg(keyword);
00698           toupper(keyword);
00699           if (!strcmp(keyword,"OFF"))
00700             generalinput.interactive = true;
00701           else if (!strcmp(keyword,"ON")    ||
00702                    !strncmp(keyword,"//",2) ||          // comment
00703                    !strncmp(keyword,"#",1)  ||          // comment
00704                    !strcmp(keyword,'\0'))               // no keyword
00705             generalinput.interactive = false;
00706           else
00707             {
00708             generalinput.interactive = true;
00709             WARNING << "BATCH: line: " << linecnt << ": "
00710                  << "argument: " << keyword 
00711                  << " not recognized, interactive processing.";
00712             WARNING.print();
00713             }
00714         } // switch
00715       } // BATCH key
00716 
00717 // **********************************************************************
00718     else if (!strcmp(keyword,"OVERWRITE")) 
00719       {
00720       switch (prioroverwrite)
00721         {
00722         case true:
00723           WARNING << "OVERWRITE: line: " << linecnt << ": "
00724                << "ignored due to prior occurence.";
00725           WARNING.print();
00726           break;
00727         default:
00728           prioroverwrite = true;                                // flag for occurence
00729           optionsfile >> keyword;                               // argument
00730           writearg(keyword);
00731           toupper(keyword);
00732           if (!strcmp(keyword,"OFF")) 
00733             generalinput.overwrit = false;
00734           else if (!strcmp(keyword,"ON")    ||
00735                    !strncmp(keyword,"//",2) ||          // comment
00736                    !strncmp(keyword,"#",1)  ||          // comment
00737                    !strcmp(keyword,'\0'))               // no keyword
00738             generalinput.overwrit = true;
00739           else
00740             {
00741             generalinput.overwrit=false;                    // don't overwrite files
00742             WARNING << "OVERWRITE: line " << linecnt 
00743                  << ": argument: " << keyword 
00744                  << " not recognized, existing files are not overwritten.";
00745             WARNING.print();
00746             }
00747         } // switch
00748       } // OVERWRITE key
00749 
00750 // **********************************************************************
00751     else if (!strcmp(keyword,"LISTINPUT")) 
00752       {
00753       switch (priorlistinput)
00754         {
00755         case true:
00756           WARNING << "LISTINPUT: line: " << linecnt << ": "
00757                << "ignored due to prior occurence.";
00758           WARNING.print();
00759           break;
00760         default:
00761           priorlistinput = true;                                // flag for occurence
00762           optionsfile >> keyword;                               // argument
00763           writearg(keyword);
00764           toupper(keyword);
00765           if (!strcmp(keyword,"OFF")) 
00766             listinput = false;
00767           else if (!strcmp(keyword,"ON")    ||
00768                    !strncmp(keyword,"//",2) ||          // comment
00769                    !strncmp(keyword,"#",1)  ||          // comment
00770                    !strcmp(keyword,'\0'))               // no keyword
00771             listinput = true;
00772           else
00773             {
00774             listinput = true;                                   // default list input
00775             WARNING << "LISTINPUT: line " << linecnt 
00776                  << ": argument: " << keyword 
00777                  << " not recognized, input will be appended to logfile.";
00778             WARNING.print();
00779             }
00780         } // switch
00781       } // LISTINPUT key
00782 
00783 // **********************************************************************
00784     else if (!strcmp(keyword,"ONLYPROCESS"))     // process only one step
00785       {
00786       // Read argument and set onlyprocess to value for filling
00787       //  the flag input array 'process[NUMPROCESSES]' after reading reset input
00788       //  to avoid interference with PROCESS cards (ONLYPROCESS overrides)
00789       //
00790       if (onlyprocess == -1)                             // check multiple occurences
00791         {
00792         optionsfile >> keyword;
00793         writearg(keyword);
00794         toupper(keyword);
00795         if      (!strcmp(keyword,"M_READFILES"))
00796           onlyprocess=pr_m_readfiles;
00797         else if (!strcmp(keyword,"M_CROP"))
00798           onlyprocess=pr_m_crop;
00799 //____RaffaeleNutricato START MODIFICATION SECTION 5
00800         else if (!strcmp(keyword,"M_OVS"))
00801           onlyprocess=pr_m_oversample;
00802 //____RaffaeleNutricato END MODIFICATION SECTION 5
00803         else if (!strcmp(keyword,"M_PORBITS"))
00804           onlyprocess=pr_m_porbits;
00805         else if (!strcmp(keyword,"M_FILTAZI"))
00806           onlyprocess=pr_m_filtazi;
00807         else if (!strcmp(keyword,"FILTRANGE"))
00808           {
00809           onlyprocess=pr_m_filtrange;
00810           onlyprocess=pr_s_filtrange;
00811           }
00812         else if (!strcmp(keyword,"M_EXTRA"))
00813           onlyprocess=pr_m_EXTRA;
00814 
00815         else if (!strcmp(keyword,"S_READFILES"))
00816           onlyprocess=pr_s_readfiles;
00817         else if (!strcmp(keyword,"S_CROP"))
00818           onlyprocess=pr_s_crop;
00819 //____RaffaeleNutricato START MODIFICATION SECTION 6
00820         else if (!strcmp(keyword,"S_OVS"))
00821           onlyprocess=pr_s_oversample;
00822 //____RaffaeleNutricato END MODIFICATION SECTION 6
00823         else if (!strcmp(keyword,"S_PORBITS"))
00824           onlyprocess=pr_s_porbits;
00825         else if (!strcmp(keyword,"S_FILTAZI"))
00826           onlyprocess=pr_s_filtazi;
00827         else if (!strcmp(keyword,"RESAMPLE"))
00828           onlyprocess=pr_s_resample;
00829         else if (!strcmp(keyword,"S_EXTRA"))
00830           onlyprocess=pr_s_EXTRA;
00831 
00832         else if (!strcmp(keyword,"COARSEORB"))
00833           onlyprocess=pr_i_coarse;
00834         else if (!strcmp(keyword,"COARSECORR"))
00835           onlyprocess=pr_i_coarse2;
00836         else if (!strcmp(keyword,"FINE"))
00837           onlyprocess=pr_i_fine;                         // see methodselector
00838         else if (!strcmp(keyword,"COREGPM"))
00839           onlyprocess=pr_i_coregpm;
00840         else if (!strcmp(keyword,"INTERFERO"))
00841           onlyprocess=pr_i_interfero;
00842         else if (!strcmp(keyword,"COHERENCE"))
00843           onlyprocess=pr_i_coherence;
00844         else if (!strcmp(keyword,"FILTPHASE"))
00845           onlyprocess=pr_i_filtphase;
00846         else if (!strcmp(keyword,"COMPREFPHA"))
00847           onlyprocess=pr_i_comprefpha;
00848         else if (!strcmp(keyword,"SUBTRREFPHA"))
00849           onlyprocess=pr_i_subtrrefpha;
00850         else if (!strcmp(keyword,"COMPREFDEM"))
00851           onlyprocess=pr_i_comprefdem;
00852         else if (!strcmp(keyword,"SUBTRREFDEM"))
00853           onlyprocess=pr_i_subtrrefdem;
00854         else if (!strcmp(keyword,"UNWRAP"))
00855           onlyprocess=pr_i_unwrap;                       // see methodselector
00856         else if (!strcmp(keyword,"SLANT2H"))
00857           onlyprocess=pr_i_slant2h;
00858         else if (!strcmp(keyword,"GEOCODE"))
00859           onlyprocess=pr_i_geocoding;
00860         else if (!strcmp(keyword,"DINSAR"))
00861           onlyprocess=pr_i_dinsar;
00862         else if (!strcmp(keyword,"I_EXTRA2"))
00863           onlyprocess=pr_i_EXTRA2;
00864         else
00865           {
00866           ERROR << "ONLYPROCESS: line " << linecnt << ": Argument " 
00867                    << keyword << " not recognized.";
00868           PRINT_ERROR(ERROR.get_str())
00869           throw(keyword_error);
00870           }
00871         INFO << "ONLYPROCESS: \tonly processing step: \t\t" << keyword;
00872         INFO.print();
00873         }
00874       else
00875         {
00876         WARNING << "ONLYPROCESS: more than one occurence of card, ignored line: "
00877                    << linecnt << ".";
00878         WARNING.print();
00879 
00880         }
00881       }
00882 
00883 // **********************************************************************
00884     else if (!strcmp(keyword,"PROCESS"))                 // which routine to run
00885       {
00886       if (onlyprocess+1)                                 // initialized to -1;
00887         {
00888         WARNING << "PROCESS card on line " << linecnt 
00889              << " ignored due to presence of ONLYPROCESS card.";
00890         WARNING.print();
00891         }
00892       else
00893         {
00894         optionsfile >> keyword;                         // argument
00895         writearg(keyword);
00896         toupper(keyword);
00897         if (!strcmp(keyword,"M_READFILES"))
00898           generalinput.process[pr_m_readfiles] = 1;
00899         else if (!strcmp(keyword,"M_CROP"))
00900           generalinput.process[pr_m_crop]   = 1;
00901 //____RaffaeleNutricato START MODIFICATION SECTION 7
00902         else if (!strcmp(keyword,"M_OVS"))
00903           generalinput.process[pr_m_oversample]   = 1; 
00904 //____RaffaeleNutricato END MODIFICATION SECTION 7
00905         else if (!strcmp(keyword,"M_PORBITS"))
00906           generalinput.process[pr_m_porbits]   = 1;
00907         else if (!strcmp(keyword,"M_FILTAZI"))
00908           generalinput.process[pr_m_filtazi]   = 1;
00909         else if (!strcmp(keyword,"FILTRANGE"))
00910           {
00911           generalinput.process[pr_m_filtrange] = 1;     // use for s_ as well
00912           generalinput.process[pr_s_filtrange] = 1;
00913           }
00914         else if (!strcmp(keyword,"M_EXTRA"))
00915           generalinput.process[pr_m_EXTRA] = 1;
00916 
00917         else if (!strcmp(keyword,"S_READFILES"))
00918           generalinput.process[pr_s_readfiles] = 1;
00919         else if (!strcmp(keyword,"S_CROP"))
00920           generalinput.process[pr_s_crop]   = 1;
00921 //____RaffaeleNutricato START MODIFICATION SECTION 8
00922         else if (!strcmp(keyword,"S_OVS"))
00923           generalinput.process[pr_s_oversample]   = 1;
00924 //____RaffaeleNutricato END MODIFICATION SECTION 8
00925         else if (!strcmp(keyword,"S_PORBITS"))
00926           generalinput.process[pr_s_porbits]   = 1;
00927         else if (!strcmp(keyword,"S_FILTAZI"))
00928           generalinput.process[pr_s_filtazi]   = 1;
00929         else if (!strcmp(keyword,"RESAMPLE"))
00930           generalinput.process[pr_s_resample]  = 1;
00931         else if (!strcmp(keyword,"S_EXTRA"))
00932           generalinput.process[pr_s_EXTRA] = 1;
00933 
00934         else if (!strcmp(keyword,"COARSEORB"))
00935           generalinput.process[pr_i_coarse]    = 1;
00936         else if (!strcmp(keyword,"COARSECORR"))
00937           generalinput.process[pr_i_coarse2]   = 1;
00938         else if (!strcmp(keyword,"FINE"))
00939           generalinput.process[pr_i_fine]      = 1;
00940         else if (!strcmp(keyword,"COREGPM"))
00941           generalinput.process[pr_i_coregpm]   = 1;
00942         else if (!strcmp(keyword,"COMPREFPHA"))
00943           generalinput.process[pr_i_comprefpha] = 1;
00944         else if (!strcmp(keyword,"SUBTRREFPHA"))
00945           generalinput.process[pr_i_subtrrefpha] = 1;
00946         else if (!strcmp(keyword,"COMPREFDEM"))
00947           generalinput.process[pr_i_comprefdem] = 1;
00948         else if (!strcmp(keyword,"SUBTRREFDEM"))
00949           generalinput.process[pr_i_subtrrefdem] = 1;
00950         else if (!strcmp(keyword,"INTERFERO"))
00951           generalinput.process[pr_i_interfero] = 1;
00952         else if (!strcmp(keyword,"COHERENCE"))
00953           generalinput.process[pr_i_coherence] = 1;
00954         else if (!strcmp(keyword,"FILTPHASE"))
00955           generalinput.process[pr_i_filtphase] = 1;
00956         else if (!strcmp(keyword,"UNWRAP"))
00957           generalinput.process[pr_i_unwrap]    = 1;
00958         else if (!strcmp(keyword,"SLANT2H"))
00959           generalinput.process[pr_i_slant2h]   = 1;
00960         else if (!strcmp(keyword,"GEOCODE"))
00961           generalinput.process[pr_i_geocoding] = 1;
00962         else if (!strcmp(keyword,"DINSAR"))
00963           generalinput.process[pr_i_dinsar] = 1;
00964 
00965         else if (!strcmp(keyword,"I_EXTRA2"))
00966           generalinput.process[pr_i_EXTRA2] = 1;
00967         else
00968           {
00969           ERROR << "PROCESS: line " << linecnt 
00970                << ": Argument " << keyword 
00971                << " not recognized.";
00972           PRINT_ERROR(ERROR.get_str())
00973           throw(keyword_error);
00974           }
00975         INFO << "PROCESS: \tI will process step: \t\t" << keyword;
00976         INFO.print();
00977         }
00978       }
00979 
00980 // **********************************************************************
00981 // *** NOT OK ? (not used in processing?)
00982     else if (!strcmp(keyword,"ELLIPSOID"))            // ref. system
00983       {                                               //  inputoptionsfile
00984       ellipsoid = true;                               // use below 
00985       optionsfile >> keyword >> filename;
00986       writearg(keyword);
00987       writearg(filename);
00988       toupper(keyword);
00989       if (!strcmp(keyword,"WGS84"))
00990         {
00991         ellipsinput.a = WGS84_A;
00992         ellipsinput.b = WGS84_B;
00993         strcpy(ellipsinput.name,"WGS84");
00994         }
00995 
00996       else if (!strcmp(keyword,"GRS80"))
00997         {
00998         ellipsinput.a = GRS80_A;
00999         ellipsinput.b = GRS80_B;
01000         strcpy(ellipsinput.name,"GRS80");
01001         }
01002 
01003       else if (!strcmp(keyword,"BESSEL"))
01004         {
01005         ellipsinput.a = BESSEL_A;
01006         ellipsinput.b = BESSEL_B;
01007         strcpy(ellipsinput.name,"BESSEL");
01008 cerr << "ellips not ok yet, should helmert transform sat. data points??.\n";      
01009         }
01010 
01011       else if (isdigit(filename[0]))                      // likely to be a,b
01012         {
01013 cerr << "ellips not ok yet, should helmert transform sat. data points??.\n";      
01014         ellipsinput.a = atof(keyword);
01015         ellipsinput.b = atof(filename);
01016         strcpy(ellipsinput.name,"User defined");
01017 
01018         if (ellipsinput.a<ellipsinput.b || ellipsinput.b<EPS)
01019           {
01020           ERROR << "ELLIPSOID keyword (real8A real8B): B==0 or A<B: "
01021                << ellipsinput.a << "<" << ellipsinput.b 
01022                << " at line " << linecnt << ".";
01023           PRINT_ERROR(ERROR.get_str())
01024           throw(keyword_error);
01025           }
01026         }
01027       else
01028         {
01029         PRINT_ERROR("unknown argument for ellipsoid card.")
01030         throw(keyword_error);
01031         }
01032       INFO << "ELLIPSOID: \tsemimajor=" << ellipsinput.a
01033            << ", semiminor=" << ellipsinput.b << "; line " << linecnt << ".";
01034       INFO.print();
01035       }
01036 
01037 // **********************************************************************
01038     else if (!strcmp(keyword,"M_RESFILE"))            // resultfile filename
01039       {                                               
01040       optionsfile >> generalinput.m_resfile;
01041       writearg(generalinput.m_resfile);
01042       }
01043 
01044 // **********************************************************************
01045     else if (!strcmp(keyword,"S_RESFILE"))            // resultfile filename
01046       {                                               
01047       optionsfile >> generalinput.s_resfile;
01048       writearg(generalinput.s_resfile);
01049       }
01050 
01051 // **********************************************************************
01052     else if (!strcmp(keyword,"LOGFILE"))              // logfile filename
01053       {                                               
01054       optionsfile >> generalinput.logfile;
01055       writearg(generalinput.logfile);
01056       }
01057 
01058 // **********************************************************************
01059     else if (!strcmp(keyword,"I_RESFILE"))            // interferogram.out
01060       {                                               
01061       optionsfile >> generalinput.i_resfile;
01062       writearg(generalinput.i_resfile);
01063       }
01064 
01065 // **********************************************************************
01066     else if (!strcmp(keyword,"ORB_INTERP"))           // orbit
01067       {                                               
01068       optionsfile >> keyword;                         // argument
01069       writearg(keyword);
01070       toupper(keyword);
01071       if (!strcmp(keyword,"POLYFIT"))
01072         {
01073         INFO.print("ORB_INTERP:  polynomial fit for interpolation");
01074         generalinput.orb_interp = ORB_DEFAULT;// depends on number of points
01075         // ___ Check second optional argument with degree ___
01076         optionsfile >> keyword;
01077         int32 degree = atoi(keyword);
01078         if (degree > 0)// atoi returns 0 if not convertible
01079           {
01080           generalinput.orb_interp = degree;
01081           INFO << "ORB_INTERP:  second argument read: degree = " << degree;
01082           INFO.print();
01083           }
01084         }
01085       else if (!strcmp(keyword,"SPLINE"))
01086         {
01087         INFO.print("ORB_INTERP:  natural cubic splines used fit interpolation");
01088         generalinput.orb_interp = ORB_SPLINE;// natural cubic splines
01089         }
01090       else
01091         {
01092         WARNING.print("argument ORB_INTERP not reconized, using polyfit");
01093         generalinput.orb_interp = ORB_DEFAULT;// depends on number of points
01094         }
01095       }
01096 
01097 // **********************************************************************
01098     else if (!strcmp(keyword,"DUMPBASELINE"))         // eval on grid
01099       {                                               
01100       optionsfile >> generalinput.dumpbaselineL >> generalinput.dumpbaselineP;
01101       writearg(generalinput.dumpbaselineL);
01102       writearg(generalinput.dumpbaselineP);
01103       if (generalinput.dumpbaselineL==0 || generalinput.dumpbaselineP==0)
01104         {
01105         ERROR << "DUMPBASELINE: " << generalinput.dumpbaselineL
01106              << " " << generalinput.dumpbaselineP << " line: "
01107              << linecnt << ": ==0.\n";
01108         PRINT_ERROR(ERROR.get_str())
01109         throw(keyword_error);
01110         }
01111       }
01112 
01113 // **********************************************************************
01114     else if (!strcmp(keyword,"PREVIEW"))        // system call to cpxfiddle to get SUNraster
01115       {
01116       optionsfile >> keyword;                   // argument
01117       writearg(keyword);
01118       toupper(keyword);
01119       if (!strcmp(keyword,"OFF"))
01120         {
01121         generalinput.preview = 0;
01122         INFO.print("PREVIEW: \tOFF: generation of SUNraster files disabled.");
01123         }
01124       else if (!strcmp(keyword,"XV"))
01125         {
01126         generalinput.preview = 2;
01127         INFO.print("PREVIEW: \tON: generation of SUNraster files enabled + XV sytem call.");
01128         }
01129       else if (!strcmp(keyword,"ON")    ||
01130                !strncmp(keyword,"//",2) ||              // comment
01131                !strncmp(keyword,"#",1)  ||              // comment
01132                !strcmp(keyword,'\0'))                   // no keyword
01133         {
01134         generalinput.preview = 1;
01135         INFO.print("PREVIEW: \tON: generation of SUNraster files enabled.");
01136         }
01137       else
01138         {
01139         generalinput.preview = 0;
01140         WARNING << "PREVIEW: line: " << linecnt << ": "
01141              << "argument: " << keyword 
01142              << " not recognized, no preview generated.";
01143         WARNING.print();
01144         }
01145       } // PREVIEW key
01146 
01147 // **********************************************************************
01148     else if (!strcmp(keyword,"HEIGHT"))               // mean height or for CROP
01149       {
01150       optionsfile >> generalinput.terrain_height;
01151       writearg(generalinput.terrain_height);
01152       }
01153 
01154 // **********************************************************************
01155     else if (!strcmp(keyword,"TIEPOINT"))          // lat/lon/hei dec.degrees
01156       {
01157       optionsfile >> generalinput.tiepoint.x 
01158                   >> generalinput.tiepoint.y 
01159                   >> generalinput.tiepoint.z;
01160       writearg(generalinput.tiepoint.x);
01161       writearg(generalinput.tiepoint.y);
01162       writearg(generalinput.tiepoint.z);
01163       }
01164 
01165 // **********************************************************************
01166     else if (!strcmp(keyword,"STOP"))                 // STOP interpreting input
01167       {
01168       INFO.print("STOP:   \tEncountered.");
01169       DEBUG << "STOP card encountered at line "
01170            << linecnt << endl;
01171       DEBUG.print();
01172       continuereading = false;                        // break while loop
01173       }
01174 
01175 
01176 // *******************************************************************
01177 // *** ?_READFILES
01178 // *******************************************************************
01179     else if (!strcmp(keyword,"M_IN_METHOD"))         // ERS or ASAR ENVISAT
01180       {                                               
01181       optionsfile >> filename;
01182       writearg(filename);
01183       toupper(filename);
01184       if (!strcmp(filename,"ERS"))
01185         m_readfilesinput.sensor_id=SLC_ERS;              // default ers
01186       else if (!strcmp(filename,"ERS-1"))             // ers
01187         m_readfilesinput.sensor_id=SLC_ERS;
01188       else if (!strcmp(filename,"ERS1"))              // ers
01189         m_readfilesinput.sensor_id=SLC_ERS;
01190       else if (!strcmp(filename,"ERS-2"))             // ers
01191         m_readfilesinput.sensor_id=SLC_ERS;
01192       else if (!strcmp(filename,"ERS2"))              // ers
01193         m_readfilesinput.sensor_id=SLC_ERS;
01194       else if (!strcmp(filename,"N1"))                // envisat
01195         m_readfilesinput.sensor_id=SLC_ASAR;
01196       else if (!strcmp(filename,"ASAR"))              // envisat
01197         m_readfilesinput.sensor_id=SLC_ASAR;
01198       else if (!strcmp(filename,"ENVISAT"))           // envisat
01199         m_readfilesinput.sensor_id=SLC_ASAR;
01200       else if (!strcmp(filename,"ATLANTIS"))          // radarsat ceos reader
01201         m_readfilesinput.sensor_id=SLC_RSAT;
01202       else if (!strcmp(filename,"RSAT"))              // radarsat
01203         m_readfilesinput.sensor_id=SLC_RSAT;
01204       else if (!strcmp(filename,"RADARSAT"))          // radarsat
01205         m_readfilesinput.sensor_id=SLC_RSAT;
01206       else if (!strcmp(filename,"RADARSAT-1"))        // radarsat
01207         m_readfilesinput.sensor_id=SLC_RSAT;
01208       else if (!strcmp(filename,"RADARSAT-2"))        // radarsat
01209         m_readfilesinput.sensor_id=SLC_RSAT;
01210       else if (!strcmp(filename,"JERS"))              // jers
01211         m_readfilesinput.sensor_id=SLC_JERS;
01212       else if (!strcmp(filename,"J-ERS"))             // jers
01213         m_readfilesinput.sensor_id=SLC_JERS;
01214       else
01215         {
01216         ERROR << "M_IN_METHOD: method " <<  filename
01217              << " not known for reading input files on line "
01218              << linecnt << ".";
01219         PRINT_ERROR(ERROR.get_str())
01220         throw(keyword_error);
01221         }
01222       }
01223 
01224 // **********************************************************************
01225     else if (!strcmp(keyword,"M_IN_VOL"))            // volumefile filename
01226       {                                               
01227       optionsfile >> m_readfilesinput.volfile;
01228       writearg(m_readfilesinput.volfile);
01229       }
01230 
01231 // **********************************************************************
01232     else if (!strcmp(keyword,"M_IN_LEA"))            // leaderfile filename
01233       {                                               
01234       optionsfile >> m_readfilesinput.leaderfile;
01235       writearg(m_readfilesinput.leaderfile);
01236       }
01237 
01238 // **********************************************************************
01239     else if (!strcmp(keyword,"M_IN_NULL"))           // nullfile filename
01240       {                                               
01241       optionsfile >> m_readfilesinput.nullfile;
01242       writearg(m_readfilesinput.nullfile);
01243       }
01244 
01245 // **********************************************************************
01246     else if (!strcmp(keyword,"M_IN_DAT"))            // datafile filename
01247       {                                               
01248       optionsfile >> m_readfilesinput.datfile;
01249       writearg(m_readfilesinput.datfile);
01250       }
01251 
01252 // **********************************************************************
01253     else if (!strcmp(keyword,"M_RG_T_ERROR"))            // timing error
01254       {                                               
01255       optionsfile >> m_readfilesinput.rg_timing_error;
01256       writearg(m_readfilesinput.rg_timing_error);
01257       }
01258 
01259 // **********************************************************************
01260     else if (!strcmp(keyword,"M_AZ_T_ERROR"))            // timing error
01261       {                                               
01262       optionsfile >> m_readfilesinput.az_timing_error;
01263       writearg(m_readfilesinput.az_timing_error);
01264       }
01265 
01266 // *******************************************************************
01267     else if (!strcmp(keyword,"S_IN_METHOD"))         // ERS or ASAR ENVISAT
01268       {                                               
01269       optionsfile >> filename;
01270       writearg(filename);
01271       toupper(filename);
01272       if (!strcmp(filename,"ERS"))
01273         s_readfilesinput.sensor_id=SLC_ERS;         // default
01274       else if (!strcmp(filename,"ERS-1"))             // ers
01275         s_readfilesinput.sensor_id=SLC_ERS;
01276       else if (!strcmp(filename,"ERS1"))              // ers
01277         s_readfilesinput.sensor_id=SLC_ERS;
01278       else if (!strcmp(filename,"ERS-2"))             // ers
01279         s_readfilesinput.sensor_id=SLC_ERS;
01280       else if (!strcmp(filename,"ERS2"))              // ers
01281         s_readfilesinput.sensor_id=SLC_ERS;
01282       else if (!strcmp(filename,"N1"))                // envisat
01283         s_readfilesinput.sensor_id=SLC_ASAR;
01284       else if (!strcmp(filename,"ASAR"))              // envisat
01285         s_readfilesinput.sensor_id=SLC_ASAR;
01286       else if (!strcmp(filename,"ENVISAT"))           // envisat
01287         s_readfilesinput.sensor_id=SLC_ASAR;
01288       else if (!strcmp(filename,"ATLANTIS"))          // radarsat ceos reader
01289         s_readfilesinput.sensor_id=SLC_RSAT;
01290       else if (!strcmp(filename,"RSAT"))              // radarsat
01291         s_readfilesinput.sensor_id=SLC_RSAT;
01292       else if (!strcmp(filename,"RADARSAT"))          // radarsat
01293         s_readfilesinput.sensor_id=SLC_RSAT;
01294       else if (!strcmp(filename,"RADARSAT-1"))        // radarsat
01295         s_readfilesinput.sensor_id=SLC_RSAT;
01296       else if (!strcmp(filename,"RADARSAT-2"))        // radarsat
01297         s_readfilesinput.sensor_id=SLC_RSAT;
01298       else if (!strcmp(filename,"JERS"))              // jers
01299         s_readfilesinput.sensor_id=SLC_JERS;
01300       else if (!strcmp(filename,"J-ERS"))             // jers
01301         s_readfilesinput.sensor_id=SLC_JERS;
01302       else
01303         {
01304         ERROR << "S_IN_METHOD: method " <<  filename
01305              << " not known for reading input files on line "
01306              << linecnt << ".";
01307         PRINT_ERROR(ERROR.get_str())
01308         throw(keyword_error);
01309         }
01310       }
01311 
01312 // **********************************************************************
01313     else if (!strcmp(keyword,"S_IN_VOL"))            // volumefile filename
01314       {                                               
01315       optionsfile >> s_readfilesinput.volfile;
01316       writearg(s_readfilesinput.volfile);
01317       }
01318 
01319 // **********************************************************************
01320     else if (!strcmp(keyword,"S_IN_LEA"))            // leaderfile filename
01321       {                                               
01322       optionsfile >> s_readfilesinput.leaderfile;
01323       writearg(s_readfilesinput.leaderfile);
01324       }
01325 
01326 // **********************************************************************
01327     else if (!strcmp(keyword,"S_IN_DAT"))            // nullfile filename
01328       {                                               
01329       optionsfile >> s_readfilesinput.datfile;
01330       writearg(s_readfilesinput.datfile);
01331       }
01332 
01333 // **********************************************************************
01334     else if (!strcmp(keyword,"S_IN_NULL"))           // nullfile filename
01335       {                                               
01336       optionsfile >> s_readfilesinput.nullfile;
01337       writearg(s_readfilesinput.nullfile);
01338       }
01339 
01340 // **********************************************************************
01341     else if (!strcmp(keyword,"S_RG_T_ERROR"))            // timing error
01342       {                                               
01343       optionsfile >> s_readfilesinput.rg_timing_error;
01344       writearg(s_readfilesinput.rg_timing_error);
01345       }
01346 
01347 // **********************************************************************
01348     else if (!strcmp(keyword,"S_AZ_T_ERROR"))            // timing error
01349       {                                               
01350       optionsfile >> s_readfilesinput.az_timing_error;
01351       writearg(s_readfilesinput.az_timing_error);
01352       }
01353 
01354 
01355 // **********************************************************************
01356 // *** ?_PORBITS
01357 // **********************************************************************
01358     else if (!strcmp(keyword,"M_ORBDIR"))             // orbitfile filename
01359       {                                               
01360       if (specified(porbitsinput.m_orbdir))
01361         WARNING.print("Prior occurence of M_ORBDIR ignored.");
01362       optionsfile >> porbitsinput.m_orbdir;
01363       writearg(porbitsinput.m_orbdir);
01364       }
01365 
01366 // **********************************************************************
01367     else if (!strcmp(keyword,"M_ORB_INTERVAL") ||      // time interval in sec
01368              !strcmp(keyword,"S_ORB_INTERVAL")) 
01369       {                                               
01370       optionsfile >> porbitsinput.timeinterval;
01371       writearg(porbitsinput.timeinterval);
01372       }
01373 
01374 // **********************************************************************
01375     else if (!strcmp(keyword,"M_ORB_EXTRATIME") ||    // time before 1st line in sec
01376              !strcmp(keyword,"S_ORB_EXTRATIME")) 
01377       {                                               
01378       optionsfile >> porbitsinput.timebefore;
01379       writearg(porbitsinput.timebefore);
01380       }
01381 
01382 // **********************************************************************
01383     else if (!strcmp(keyword,"M_ORB_DUMP"))           // dump orbit with dt
01384       {                                               
01385       optionsfile >> porbitsinput.dumpmasterorbit;
01386       writearg(porbitsinput.dumpmasterorbit);
01387       INFO.print("dumping master orbit to ascii file: masterorbit.dat");
01388       }
01389 
01390 // **********************************************************************
01391     else if (!strcmp(keyword,"S_ORBDIR"))             // orbitfile filename
01392       {                                               
01393       if (specified(porbitsinput.s_orbdir))
01394         WARNING.print("Prior occurence of S_ORBDIR ignored.");
01395       optionsfile >> porbitsinput.s_orbdir;
01396       writearg(porbitsinput.s_orbdir);
01397       }
01398 
01399 // **********************************************************************
01400     else if (!strcmp(keyword,"S_ORB_DUMP"))           // dump orbit with dt
01401       {                                               
01402       optionsfile >> porbitsinput.dumpslaveorbit;
01403       writearg(porbitsinput.dumpslaveorbit);
01404       INFO.print("dumping slave orbit to ascii file: slaveorbit.dat");
01405       }
01406 
01407 
01408 // *******************************************************************
01409 // *** ?_CROP
01410 // *******************************************************************
01411     else if (!strcmp(keyword,"M_CROP_ID"))          // identifier of run
01412       {                                               
01413       optionsfile >> m_cropinput.idcrop;
01414       writearg(m_cropinput.idcrop);
01415       }
01416 
01417 // *******************************************************************   CROP
01418     else if (!strcmp(keyword,"S_CROP_ID"))          // identifier of run
01419       {                                               
01420       optionsfile >> s_cropinput.idcrop;
01421       writearg(s_cropinput.idcrop);
01422       }
01423 
01424 // **********************************************************************
01425     else if (!strcmp(keyword,"M_CROP_IN"))              // SLC input image filename
01426       {                                               
01427       optionsfile >> m_cropinput.filein1;
01428       writearg(m_cropinput.filein1);
01429       }
01430 
01431 // **********************************************************************
01432     else if (!strcmp(keyword,"S_CROP_IN"))              // SLC input image filename
01433       {                                               
01434       optionsfile >> s_cropinput.filein1;
01435       writearg(s_cropinput.filein1);
01436       }
01437 
01438 // **********************************************************************
01439     else if (!strcmp(keyword,"M_CROP_OUT"))             // SLC output image filename
01440       {                                               
01441       optionsfile >> m_cropinput.fileout1;
01442       writearg(m_cropinput.fileout1);
01443       }
01444 
01445 // **********************************************************************
01446     else if (!strcmp(keyword,"S_CROP_OUT"))             // SLC output image filename
01447       {                                               
01448       optionsfile >> s_cropinput.fileout1;
01449       writearg(s_cropinput.fileout1);
01450       }
01451 
01452 // **********************************************************************
01453     else if (!strcmp(keyword,"M_DBOW"))               // min. line coord.
01454       {                                               
01455       optionsfile >> m_cropinput.dbow.linelo
01456                   >> m_cropinput.dbow.linehi
01457                   >> m_cropinput.dbow.pixlo
01458                   >> m_cropinput.dbow.pixhi;
01459       writearg(m_cropinput.dbow.linelo);
01460       writearg(m_cropinput.dbow.linehi);
01461       writearg(m_cropinput.dbow.pixlo);
01462       writearg(m_cropinput.dbow.pixhi);
01463 
01464 // ______initial check, later checked to #lines of image______
01465       if (m_cropinput.dbow.linelo <= 0 || 
01466           m_cropinput.dbow.pixlo <= 0 ||
01467           m_cropinput.dbow.linelo  > m_cropinput.dbow.linehi ||
01468           m_cropinput.dbow.pixlo > m_cropinput.dbow.pixhi)
01469         {
01470         ERROR << "code 300: Arguments of M_DBOW card on line " << linecnt
01471              << " missing. [DBOW  min_line  max_line  min_pixel  max_pixel].";
01472         PRINT_ERROR(ERROR.get_str())
01473         throw(keyword_error);
01474         }
01475       }
01476 
01477 // **********************************************************************
01478     else if (!strcmp(keyword,"S_DBOW"))               // min. line coord.
01479       {                                               
01480       optionsfile >> s_cropinput.dbow.linelo
01481                   >> s_cropinput.dbow.linehi
01482                   >> s_cropinput.dbow.pixlo
01483                   >> s_cropinput.dbow.pixhi;
01484       writearg(s_cropinput.dbow.linelo);
01485       writearg(s_cropinput.dbow.linehi);
01486       writearg(s_cropinput.dbow.pixlo);
01487       writearg(s_cropinput.dbow.pixhi);
01488       // ______initial check, later checked to #lines of image______
01489       if (s_cropinput.dbow.linelo <= 0 || 
01490           s_cropinput.dbow.pixlo <= 0 ||
01491           s_cropinput.dbow.linelo  > s_cropinput.dbow.linehi ||
01492           s_cropinput.dbow.pixlo > s_cropinput.dbow.pixhi)
01493         {
01494         ERROR << "code 300: Arguments of S_DBOW card on line " << linecnt
01495              << " missing. [DBOW  min_line  max_line  min_pixel  max_pixel].";
01496         PRINT_ERROR(ERROR.get_str())
01497         throw(keyword_error);
01498         }
01499       }
01500 
01501 // **********************************************************************
01502     // BK 15-Dec-2003
01503     else if (!strcmp(keyword,"M_DBOW_GEO")) // 1e6*lat_0 [deg], lon_0, height, width [pix]
01504       {                                               
01505       // use dbow to store tmp, compute later in crop if not zero
01506       real8 tmp_lat_0;
01507       real8 tmp_lon_0;
01508       real8 tmp_height;
01509       real8 tmp_width;
01510       optionsfile >> tmp_lat_0 >> tmp_lon_0 >> tmp_height >> tmp_width;
01511       writearg(tmp_lat_0);
01512       writearg(tmp_lon_0);
01513       writearg(tmp_height);
01514       writearg(tmp_width);
01515       m_cropinput.dbow_geo.linelo = uint((360.0+tmp_lat_0)*1e6);
01516       m_cropinput.dbow_geo.linehi = uint((360.0+tmp_lon_0)*1e6);
01517       m_cropinput.dbow_geo.pixlo  = uint(tmp_height);
01518       m_cropinput.dbow_geo.pixhi  = uint(tmp_width);
01519       }
01520 
01521 // **********************************************************************
01522     // BK 15-Dec-2003
01523     else if (!strcmp(keyword,"S_DBOW_GEO")) // 1e6*lat_0 [deg], lon_0, height, width [pix]
01524       {                                               
01525       // use dbow to store tmp, compute later in crop if not zero
01526       real8 tmp_lat_0;
01527       real8 tmp_lon_0;
01528       real8 tmp_height;
01529       real8 tmp_width;
01530       optionsfile >> tmp_lat_0 >> tmp_lon_0 >> tmp_height >> tmp_width;
01531       writearg(tmp_lat_0);
01532       writearg(tmp_lon_0);
01533       writearg(tmp_height);
01534       writearg(tmp_width);
01535       s_cropinput.dbow_geo.linelo = uint((360.0+tmp_lat_0)*1e6);
01536       s_cropinput.dbow_geo.linehi = uint((360.0+tmp_lon_0)*1e6);
01537       s_cropinput.dbow_geo.pixlo  = uint(tmp_height);
01538       s_cropinput.dbow_geo.pixhi  = uint(tmp_width);
01539       }
01540 
01541 //____RaffaeleNutricato START MODIFICATION SECTION 9
01542 // *******************************************************************
01543 // *** ?_OVS
01544 // **********************************************************************
01545     else if (!strcmp(keyword,"M_OVS_OUT"))             // oversampled SLC output image filename
01546       {                                               
01547       optionsfile >> m_oversample.fileoutovs;
01548       writearg(m_oversample.fileoutovs);
01549       }
01550 
01551 // **********************************************************************
01552     else if (!strcmp(keyword,"S_OVS_OUT"))             // oversampled SLC output image filename
01553       {                                               
01554       optionsfile >> s_oversample.fileoutovs;
01555       writearg(s_oversample.fileoutovs);
01556       }
01557 
01558 // *******************************************************************
01559     else if (!strcmp(keyword,"M_OVS_FACT_RNG"))               // Oversampling ratio in the master range direction.
01560       {                                                  
01561       optionsfile >> m_oversample.OsrRange;               
01562       writearg(m_oversample.OsrRange);                    
01563       if (m_oversample.OsrRange < 1)
01564         {
01565         PRINT_ERROR(
01566         "(M_OVS_FACT_RNG < 1) Oversampling ratio must be at least 1.");
01567         throw(keyword_error);
01568         }
01569       }                                                  
01570 
01571 // ********************************************************************** 
01572     else if (!strcmp(keyword,"S_OVS_FACT_RNG"))               // Oversampling ratio in the slave range direction.
01573       {                                                       
01574       optionsfile >> s_oversample.OsrRange;               
01575       writearg(s_oversample.OsrRange);                    
01576       if (s_oversample.OsrRange < 1)
01577         {
01578         PRINT_ERROR(
01579         "(S_OVS_FACT_RNG < 1) Oversampling ratio must be at least 1.");
01580         throw(keyword_error);
01581         }
01582       }                                                  
01583 
01584 // *******************************************************************
01585     else if (!strcmp(keyword,"M_OVS_FACT_AZI"))               // Oversampling ratio in the master azimuth direction.
01586       {                                                  
01587       optionsfile >> m_oversample.OsrAzimuth;               
01588       writearg(m_oversample.OsrAzimuth);                    
01589       if (m_oversample.OsrAzimuth < 1)
01590         {
01591         PRINT_ERROR(
01592         "(M_OVS_FACT_AZI < 1) Oversampling ratio must be at least 1.");
01593         throw(keyword_error);
01594         }
01595       if (m_oversample.OsrAzimuth > 1)
01596         {
01597         PRINT_ERROR(
01598         "(M_OVS_FACT_AZI > 1) Not implemented yet!!!");
01599         throw(keyword_error);
01600         }
01601       }                                                  
01602 
01603 // ********************************************************************** 
01604     else if (!strcmp(keyword,"S_OVS_FACT_AZI"))               // Oversampling ratio in the slave azimuth direction.
01605       {                                                       
01606       optionsfile >> s_oversample.OsrAzimuth;               
01607       writearg(s_oversample.OsrAzimuth);                    
01608       if (s_oversample.OsrAzimuth < 1)
01609         {
01610         PRINT_ERROR(
01611         "(S_OVS_FACT_AZI < 1) Oversampling ratio must be at least 1.");
01612         throw(keyword_error);
01613         }
01614       if (s_oversample.OsrAzimuth > 1)
01615         {
01616         PRINT_ERROR(
01617         "(S_OVS_FACT_AZI > 1) Not implemented yet!!!");
01618         throw(keyword_error);
01619         }
01620       }                                                  
01621 
01622 // ********************************************************************** 
01623     else if (!strcmp(keyword,"M_OVS_KERNELSIZE"))     // Length of the interpolation kernel. 
01624       {                                                  
01625       optionsfile >> m_oversample.FilterSize;        
01626       writearg(m_oversample.FilterSize);             
01627       if (m_oversample.FilterSize < 2)
01628         {
01629         PRINT_ERROR(
01630         "(M_OVS_KERNELSIZE < 2) Interpolation kernel length must be > 1.");
01631         throw(keyword_error);
01632         }
01633       if (m_oversample.FilterSize % 2)
01634         {
01635         PRINT_ERROR(
01636         "(M_OVS_KERNELSIZE not even) Interpolation kernel length must be an even number.");
01637         throw(keyword_error);
01638         }
01639       }                                                  
01640 
01641 // ********************************************************************** 
01642     else if (!strcmp(keyword,"S_OVS_KERNELSIZE"))     // Length of the interpolation kernel. 
01643       {                                                  
01644       optionsfile >> s_oversample.FilterSize;        
01645       writearg(s_oversample.FilterSize);             
01646       if (s_oversample.FilterSize < 2)
01647         {
01648         PRINT_ERROR(
01649         "code ???: (S_OVS_KERNELSIZE < 2) Interpolation kernel length must be > 1.");
01650         throw(keyword_error);
01651         }
01652       if (s_oversample.FilterSize % 2)
01653         {
01654         PRINT_ERROR(
01655         "code ???: (S_OVS_KERNELSIZE not even) Interpolation kernel length must be an even number.");
01656         throw(keyword_error);
01657         }
01658       }                                                  
01659 
01660 // ********************************************************************** 
01661     else if (!strcmp(keyword,"M_OVS_OUT_FORMAT"))         // Output format [cr4] ci16, I suggest [cr4].
01662       {                                                  
01663       optionsfile >> filename;                           
01664       writearg(filename);
01665       toupper(filename);
01666       if (!strcmp(filename,"CR4"))
01667         m_oversample.oformatflag = FORMATCR4;         // default
01668       else if (!strcmp(filename,"CI2"))
01669         m_oversample.oformatflag = FORMATCI2;
01670       else
01671         {  
01672         ERROR << "M_OVS_OUT_FORMAT: output format "
01673              <<  filename
01674              << " not known for master range oversampling. line "
01675              << linecnt << ".";
01676           PRINT_ERROR(ERROR.get_str())      
01677         throw(keyword_error);
01678         }             
01679       }                                                  
01680 
01681 // ********************************************************************** 
01682     else if (!strcmp(keyword,"S_OVS_OUT_FORMAT"))         // Output format [cr4] ci16, I suggest [cr4].
01683       {                                                  
01684       optionsfile >> filename;                           
01685       writearg(filename);
01686       toupper(filename);
01687       if (!strcmp(filename,"CR4"))
01688         s_oversample.oformatflag = FORMATCR4;         // default
01689       else if (!strcmp(filename,"CI2"))
01690         s_oversample.oformatflag = FORMATCI2;
01691       else
01692         {  
01693         ERROR << "S_OVS_OUT_FORMAT: output format "
01694              <<  filename
01695              << " not known for slave range oversampling. line "
01696              << linecnt << ".";
01697           PRINT_ERROR(ERROR.get_str()) 
01698         throw(keyword_error);
01699         }             
01700       }               
01701 //____RaffaeleNutricato END MODIFICATION SECTION 9
01702 
01703 
01704 // **********************************************************************
01705 // *** AZIMUTH FILTERING
01706 // **********************************************************************
01707     else if (!strcmp(keyword,"AF_BLOCKSIZE"))
01708       {
01709       optionsfile >> filtaziinput.fftlength;
01710       writearg(filtaziinput.fftlength);
01711       }
01712 
01713 // **********************************************************************
01714     else if (!strcmp(keyword,"AF_HAMMING"))
01715       {
01716       optionsfile >> filtaziinput.hammingalpha;
01717       writearg(filtaziinput.hammingalpha);
01718       }
01719 
01720 // **********************************************************************
01721     else if (!strcmp(keyword,"AF_OVERLAP"))
01722       {
01723       optionsfile >> filtaziinput.overlap;
01724       writearg(filtaziinput.overlap);
01725       }
01726 
01727 // **********************************************************************
01728     else if (!strcmp(keyword,"AF_OUT_MASTER"))
01729       {
01730       optionsfile >> filtaziinput.fomaster;
01731       writearg(filtaziinput.overlap);
01732       }
01733 
01734 // **********************************************************************
01735     else if (!strcmp(keyword,"AF_OUT_SLAVE"))
01736       {
01737       optionsfile >> filtaziinput.foslave;
01738       writearg(filtaziinput.overlap);
01739       }
01740 
01741 // **********************************************************************
01742     else if (!strcmp(keyword,"AF_OUT_FORMAT"))          // output format
01743       {
01744       optionsfile >> filename;
01745       writearg(filename);
01746       toupper(filename);
01747       if (!strcmp(filename,"CR4"))
01748         filtaziinput.oformatflag = FORMATCR4;         // default
01749       else if (!strcmp(filename,"CI2"))
01750         filtaziinput.oformatflag = FORMATCI2;
01751       else
01752         {
01753         ERROR << "AF_OUT_FORMAT: output format "
01754              <<  filename
01755              << " not known for azimuth filtering. line "
01756              << linecnt << ".";
01757         PRINT_ERROR(ERROR.get_str())
01758         throw(keyword_error);
01759         }
01760       }
01761 
01762 
01763 
01764 // **********************************************************************
01765 // *** COARSE CORR COREGISTRATION
01766 // **********************************************************************
01767     else if (!strcmp(keyword,"CC_METHOD"))            // method selector coarse coreg
01768       {                                               
01769       optionsfile >> filename;
01770       writearg(filename);
01771       toupper(filename);
01772       if (!strcmp(filename,"MAGFFT"))
01773         coarsecorrinput.method=cc_magfft;             // default
01774       else if (!strcmp(filename,"MAGSPACE"))
01775         coarsecorrinput.method=cc_magspace;
01776       else
01777         {
01778         ERROR << "CC_METHOD: method " <<  filename
01779              << " not known for coarse correlation coregistration on line "
01780              << linecnt << ".";
01781         PRINT_ERROR(ERROR.get_str())
01782         throw(keyword_error);
01783         }
01784       }
01785 
01786 // **********************************************************************
01787     else if (!strcmp(keyword,"CC_NWIN"))              // #windows for coarse correlation
01788       {                                               
01789       optionsfile >> coarsecorrinput.Nwin;
01790       writearg(coarsecorrinput.Nwin);
01791       if (coarsecorrinput.Nwin > 1000)
01792         {
01793         PRINT_ERROR(
01794         "Too many windows requested (CC_NWIN > 1000).")
01795         throw(keyword_error);
01796         }
01797       }
01798 
01799 // **********************************************************************
01800     else if (!strcmp(keyword,"CC_IN_POS"))            // file with #windows positions
01801       {                                               
01802       optionsfile >> coarsecorrinput.ifpositions;
01803       writearg(coarsecorrinput.ifpositions);
01804       }
01805 
01806 // **********************************************************************
01807     else if (!strcmp(keyword,"CC_WINSIZE"))           // windowsize for coarse correlation
01808       {                                               
01809       optionsfile >> coarsecorrinput.MasksizeL >> coarsecorrinput.MasksizeP;
01810       writearg(coarsecorrinput.MasksizeL);
01811       writearg(coarsecorrinput.MasksizeP);
01812       if (coarsecorrinput.MasksizeL > 2048 || coarsecorrinput.MasksizeP > 2048)
01813         {
01814         PRINT_ERROR(
01815         "Too large correlation window (CC_WINSIZE > 2048).");
01816         throw(keyword_error);
01817         }
01818       }
01819 
01820 // **********************************************************************
01821     else if (!strcmp(keyword,"CC_ACC"))               // Searchdomain for correlation
01822       {                                               //  coarse correlation
01823       optionsfile >> coarsecorrinput.AccL >> coarsecorrinput.AccP;
01824       writearg(coarsecorrinput.AccL);
01825       writearg(coarsecorrinput.AccP);
01826       if (coarsecorrinput.AccL > 1000 || coarsecorrinput.AccP > 1000)
01827         {
01828         PRINT_ERROR("Too large searchwindow (CC_ACC > 1000).");
01829         throw(keyword_error);
01830         }
01831       if (coarsecorrinput.AccL == 0 || coarsecorrinput.AccP == 0)
01832         {
01833         PRINT_ERROR("Acc = 0 ?(CC_ACC).");
01834         throw(keyword_error);
01835         }
01836       }
01837 
01838 // **********************************************************************
01839     else if (!strcmp(keyword,"CC_INITOFF"))             // Initial offset
01840       {
01841       optionsfile >> keyword >> filename;
01842       writearg(keyword);
01843       writearg(filename);
01844       if (!strcmp(keyword,"ORBIT") ||                   // use value of precise orbits
01845           !strcmp(keyword,"orbit"))
01846         {
01847         coarsecorrinput.initoffsetL = NaN;              // flag used in main
01848         coarsecorrinput.initoffsetP = NaN;              // flag used in main
01849         INFO << "CC_INITOFF: \tInitial offsets from COARSEORB: "
01850              << generalinput.i_resfile;
01851         INFO.print();
01852         }
01853       else if (isdigit(filename[0]) || filename[0]=='-') // likely to be 2 numbers
01854                                                 // BK19/1/00 thanks to m.goos for '-'
01855         {
01856         //coarsecorrinput.initoffsetL = atof(keyword);
01857         //coarsecorrinput.initoffsetP = atof(filename);
01858         coarsecorrinput.initoffsetL = atoi(keyword);
01859         coarsecorrinput.initoffsetP = atoi(filename);
01860         }
01861       else
01862         {
01863         ERROR << "CC_INITOFF: unknown input: "
01864              <<  keyword << ", " << filename
01865              << " on line "
01866              << linecnt << ".";
01867         PRINT_ERROR(ERROR.get_str())
01868         throw(keyword_error);
01869         }
01870       }
01871 
01872 // **********************************************************************
01873 // *** FINE COREGISTRATION
01874 // **********************************************************************
01875     else if (!strcmp(keyword,"FC_NWIN"))              // #windows for fine correlation
01876       {                                               
01877       optionsfile >> fineinput.Nwin;
01878       writearg(fineinput.Nwin);
01879       if (fineinput.Nwin > 10000)
01880         {
01881         PRINT_ERROR("Too many windows requested (FC_NWIN).")
01882         throw(keyword_error);
01883         }
01884       }
01885 
01886 // **********************************************************************
01887     else if (!strcmp(keyword,"FC_IN_POS"))            // file with #windows positions
01888       {                                               
01889       optionsfile >> fineinput.ifpositions;
01890       writearg(fineinput.ifpositions);
01891       }
01892 
01893 // **********************************************************************
01894     else if (!strcmp(keyword,"FC_WINSIZE"))           // windowsize for fine correlation
01895       {                                               
01896       optionsfile >> fineinput.MasksizeL >> fineinput.MasksizeP;
01897       writearg(fineinput.MasksizeL);
01898       writearg(fineinput.MasksizeP);
01899       if (fineinput.MasksizeL > 1024 || fineinput.MasksizeP > 1024)
01900         {
01901         PRINT_ERROR("Too large correlation window (FC_WINSIZE).")
01902         throw(keyword_error);
01903         }
01904       }
01905 
01906 // **********************************************************************
01907     else if (!strcmp(keyword,"FC_ACC"))               // Searchdomain for correlation
01908       {                                               //  fine correlation
01909       optionsfile >> fineinput.AccL >> fineinput.AccP;
01910       writearg(fineinput.AccL);
01911       writearg(fineinput.AccP);
01912       if (fineinput.AccL > 1000 || fineinput.AccP > 1000)
01913         {
01914         PRINT_ERROR("Too large searchwindow (FC_ACC).")
01915         throw(keyword_error);
01916         }
01917       if (fineinput.AccL == 0 || fineinput.AccP == 0)
01918         {
01919         PRINT_ERROR("Acc = 0 ?(FC_ACC).")
01920         throw(keyword_error);
01921         }
01922       }
01923 
01924 // **********************************************************************
01925     else if (!strcmp(keyword,"FC_INITOFF"))             // Initial offset
01926       {
01927       optionsfile >> keyword >> filename;
01928       writearg(keyword);
01929       writearg(filename);
01930       if (!strcmp(keyword,"COARSECORR") ||              // use value of coarse correlation
01931           !strcmp(keyword,"coarsecorr"))
01932         {
01933         fineinput.initoffsetL = NaN;                    // flag used in main
01934         fineinput.initoffsetP = NaN;                    // flag used in main
01935         INFO << "FC_INITOFF: \tInitial offset from COARSECORR: "
01936              << generalinput.i_resfile;
01937         INFO.print();
01938         }
01939       else if (isdigit(filename[0]) || filename[0]=='-') // likely to be 2 numbers
01940                                                 // BK19/1/00 thanks to M.Goos for '-'
01941         {
01942         fineinput.initoffsetL = atoi(keyword);
01943         fineinput.initoffsetP = atoi(filename);
01944         }
01945       else
01946         {
01947         ERROR << "FC_INITOFF: unknown input: "
01948              <<  keyword << ", " << filename
01949              << " on line "
01950              << linecnt << ".";
01951         PRINT_ERROR(ERROR.get_str())
01952         throw(keyword_error);
01953         }
01954       }
01955 
01956 // **********************************************************************
01957     else if (!strcmp(keyword,"FC_METHOD"))            // method selector fine coreg
01958       {                                               
01959       optionsfile >> filename;
01960       writearg(filename);
01961       toupper(filename);
01962       if (!strcmp(filename,"CMPLXFFT"))
01963         {
01964         PRINT_ERROR("CMPLXFFT not implemented in v1.0 of Doris.")
01965         throw(keyword_error);
01966         }
01967 //        fineinput.method=fc_cmplxfft;                 // default
01968       else if (!strcmp(filename,"CMPLXSPACE"))
01969         {
01970         PRINT_ERROR("CMPLXSPACE not implemented in v1.0 of Doris.")
01971         throw(keyword_error);
01972         }
01973 //        fineinput.method=fc_cmplxspace;
01974       else if (!strcmp(filename,"MAGFFT"))
01975         fineinput.method=fc_magfft;
01976       else if (!strcmp(filename,"MAGSPACE"))
01977         fineinput.method=fc_magspace;
01978       else if (!strcmp(filename,"OVERSAMPLE"))
01979         fineinput.method=fc_oversample;
01980       else
01981         {
01982         ERROR << "FC_METHOD: method " <<  filename
01983              << " not known for fine coregistration on line "
01984              << linecnt << ".";
01985         PRINT_ERROR(ERROR.get_str())
01986         throw(keyword_error);
01987         }
01988       }
01989 
01990 // **********************************************************************
01991     else if (!strcmp(keyword,"FC_OSFACTOR"))          // oversampling factor
01992       {                                               
01993       optionsfile >> fineinput.osfactor;
01994       writearg(fineinput.osfactor);
01995       }
01996 
01997 // **********************************************************************
01998     else if (!strcmp(keyword,"FC_PLOT"))              // plotting results
01999       {                                               
02000       fineinput.plotoffsets = true;
02001       optionsfile >> fineinput.plotthreshold;
02002       optionsfile >> filename;
02003       writearg(fineinput.plotthreshold);
02004       writearg(filename);
02005       toupper(filename);
02006       if (!strcmp(filename,"BG"))
02007         fineinput.plotmagbg = true;
02008       else if (!strcmp(filename,"NOBG"))
02009         fineinput.plotmagbg = false;
02010       else if (!strcmp(filename,"ON"))          // actually not allowed...
02011         fineinput.plotoffsets = true;
02012       else if (!strcmp(filename,"OFF"))         // actually not allowed...
02013         fineinput.plotoffsets = false;
02014       else
02015         WARNING.print("FC_PLOT: missing argument(s). (default: 0.4 NOBG)");
02016       }
02017 
02018 
02019 // **********************************************************************
02020 // *** COMPUTATION OF COREGISTRATION PARAMETERS
02021 // **********************************************************************
02022     else if (!strcmp(keyword,"CPM_THRESHOLD"))         // treshhold value
02023       {                                               
02024       optionsfile >> coregpminput.threshold;
02025       writearg(coregpminput.threshold);
02026       if (coregpminput.threshold > 1)
02027         {
02028         PRINT_ERROR("CPM_THRESHOLD: threshold > 1.")
02029         throw(keyword_error);
02030         }
02031       }
02032 
02033 // **********************************************************************
02034     else if (!strcmp(keyword,"CPM_DEGREE"))           // degree of polynomial
02035       {                                               
02036       optionsfile >> coregpminput.degree;
02037       writearg(coregpminput.degree);
02038       if (coregpminput.degree > 4)
02039         WARNING.print("CPM_DEGREE: degree > 4 dangerous at edges?");
02040       }
02041 
02042 // **********************************************************************
02043     else if (!strcmp(keyword,"CPM_WEIGHT"))           // weightmatrix
02044       {                                               
02045       optionsfile >> filename;
02046       writearg(filename);
02047       toupper(filename);
02048       if (!strcmp(filename,"NONE"))
02049         coregpminput.weightflag = 0;          // default
02050       else if (!strcmp(filename,"LINEAR"))
02051         coregpminput.weightflag = 1;
02052       else if (!strcmp(filename,"QUADRATIC"))
02053         coregpminput.weightflag = 2;
02054       else
02055         {
02056         ERROR << "CPM_WEIGHT: data weighting option: "
02057              <<  filename
02058              << " not known for computation of coregistration parameters on line "
02059              << linecnt << ".";
02060         PRINT_ERROR(ERROR.get_str())
02061         throw(keyword_error);
02062         }
02063       }
02064 
02065 // **********************************************************************
02066     else if (!strcmp(keyword,"CPM_MAXITER"))     // max number of offsets to reject
02067       {                                               
02068       optionsfile >> coregpminput.maxiter;
02069       writearg(coregpminput.maxiter);
02070       if (coregpminput.maxiter < 0)
02071         {
02072         WARNING.print("CPM_MAXITER: max. number of points to remove < 0? (using 0)");
02073         coregpminput.maxiter = 0;
02074         }
02075       }
02076 
02077 // **********************************************************************
02078     else if (!strcmp(keyword,"CPM_K_ALPHA"))     // critical value for outlier removal
02079       {                                               
02080       optionsfile >> coregpminput.k_alpha;
02081       writearg(coregpminput.k_alpha);
02082       if (coregpminput.k_alpha < 0)
02083         {
02084         WARNING.print("CPM_K_ALPHA: critical value < 0.0?");
02085         coregpminput.k_alpha = 1.97;
02086         }
02087       }
02088 
02089 // **********************************************************************
02090     else if (!strcmp(keyword,"CPM_DUMP"))               // boolean
02091       {
02092       optionsfile >> keyword;
02093       writearg(keyword);
02094       toupper(keyword);
02095       if (!strcmp(keyword,"OFF")) 
02096         coregpminput.dumpmodel = false;
02097       else if (!strcmp(keyword,"ON")    ||
02098                !strncmp(keyword,"//",2) ||              // comment
02099                !strncmp(keyword,"#",1)  ||              // comment
02100                !strcmp(keyword,'\0'))                   // no keyword
02101         coregpminput.dumpmodel = true;
02102       else
02103         {
02104         WARNING << "CPM_DUMP: line " << linecnt 
02105              << ": argument: " << keyword 
02106              << " not recognized, no dumping to files.";
02107         WARNING.print();
02108         }
02109       }
02110 
02111 // **********************************************************************
02112     else if (!strcmp(keyword,"CPM_PLOT"))           // plotting results
02113       {                                               
02114       coregpminput.plot = true;
02115       optionsfile >> filename;
02116       writearg(filename);
02117       toupper(filename);
02118       if (!strcmp(filename,"BG"))
02119         coregpminput.plotmagbg = true;
02120       else if (!strcmp(filename,"NOBG"))
02121         coregpminput.plotmagbg = false;
02122       else if (!strcmp(filename,"ON"))          // actually not allowed...
02123         coregpminput.plot = true;
02124       else if (!strcmp(filename,"OFF"))         // actually not allowed...
02125         coregpminput.plot = false;
02126       else
02127         WARNING.print("CPM_PLOT: missing argument. (default NOBG magnitude background)");
02128       }
02129 
02130 
02131 // **********************************************************************
02132 // *** RANGE FILTERING
02133 // **********************************************************************
02134     else if (!strcmp(keyword,"RF_METHOD"))            // method range filtering
02135       {
02136       optionsfile >> filename;
02137       writearg(filename);
02138       toupper(filename);
02139       if (!strcmp(filename,"ADAPTIVE"))
02140         filtrangeinput.method = rf_adaptive;
02141       else if (!strcmp(filename,"PORBITS"))
02142         filtrangeinput.method = rf_porbits;
02143       else
02144         {
02145         ERROR << "RF_METHOD: method "
02146              <<  filename
02147              << " not known for range filtering. line "
02148              << linecnt << ".";
02149         PRINT_ERROR(ERROR.get_str())
02150         throw(keyword_error);
02151         }
02152       }
02153 
02154 // **********************************************************************
02155     else if (!strcmp(keyword,"RF_SLOPE"))               // terrain method porbits
02156       {
02157       optionsfile >> filtrangeinput.terrainslope;
02158       writearg(filtrangeinput.terrainslope);
02159       deg2rad(filtrangeinput.terrainslope);
02160       }
02161 
02162 // **********************************************************************
02163     else if (!strcmp(keyword,"RF_THRESHOLD"))           // threshhold value
02164       {
02165       optionsfile >> filtrangeinput.SNRthreshold;
02166       writearg(filtrangeinput.SNRthreshold);
02167       }
02168 
02169 // **********************************************************************
02170     else if (!strcmp(keyword,"RF_HAMMING"))             // alpha
02171       {
02172       optionsfile >> filtrangeinput.hammingalpha;
02173       writearg(filtrangeinput.hammingalpha);
02174       }
02175 
02176 // **********************************************************************
02177     else if (!strcmp(keyword,"RF_WEIGHTCORR"))          // boolean
02178       {
02179       optionsfile >> keyword;
02180       writearg(keyword);
02181       toupper(keyword);
02182       if (!strcmp(keyword,"OFF")) 
02183         filtrangeinput.doweightcorrel = false;
02184       else if (!strcmp(keyword,"ON")    ||
02185                !strncmp(keyword,"//",2) ||              // comment
02186                !strncmp(keyword,"#",1)  ||              // comment
02187                !strcmp(keyword,'\0'))                   // no keyword
02188         filtrangeinput.doweightcorrel = true;
02189       else
02190         {
02191         filtrangeinput.doweightcorrel = false;          // default already...
02192         WARNING << "RF_WEIGHTCORREL: line " << linecnt 
02193              << ": argument: " << keyword 
02194              << " not recognized, weighting correlation set to OFF.";
02195         WARNING.print();
02196         }
02197       }
02198 
02199 // **********************************************************************
02200     else if (!strcmp(keyword,"RF_OVERSAMPLE"))         // int
02201       {
02202       optionsfile >> filtrangeinput.oversample;
02203       writearg(filtrangeinput.oversample);
02204       }
02205 
02206 // **********************************************************************
02207     else if (!strcmp(keyword,"RF_NLMEAN"))              // take mean over nlmean lines
02208       {
02209       optionsfile >> filtrangeinput.nlmean;
02210       writearg(filtrangeinput.nlmean);
02211       }
02212 
02213 // **********************************************************************
02214     else if (!strcmp(keyword,"RF_FFTLENGTH"))           // adaptive length
02215       {
02216       optionsfile >> filtrangeinput.fftlength;
02217       writearg(filtrangeinput.fftlength);
02218       }
02219 
02220 // **********************************************************************
02221     else if (!strcmp(keyword,"RF_OVERLAP"))             // overlap blocks
02222       {
02223       optionsfile >> filtrangeinput.overlap;
02224       writearg(filtrangeinput.overlap);
02225       }
02226 
02227 // **********************************************************************
02228     else if (!strcmp(keyword,"RF_OUT_MASTER"))          // filename
02229       {
02230       optionsfile >> filtrangeinput.fomaster;
02231       writearg(filtrangeinput.fomaster);
02232       }
02233 
02234 // **********************************************************************
02235     else if (!strcmp(keyword,"RF_OUT_SLAVE"))           // filename
02236       {
02237       optionsfile >> filtrangeinput.foslave;
02238       writearg(filtrangeinput.foslave);
02239       }
02240 
02241 // **********************************************************************
02242     else if (!strcmp(keyword,"RF_OUT_FORMAT"))          // output format
02243       {
02244       optionsfile >> filename;
02245       writearg(filename);
02246       toupper(filename);
02247       if (!strcmp(filename,"CR4"))
02248         filtrangeinput.oformatflag = FORMATCR4;         // default
02249       else if (!strcmp(filename,"CI2"))
02250         filtrangeinput.oformatflag = FORMATCI2;
02251       else
02252         {
02253         ERROR << "RF_OUT_FORMAT: output format "
02254              <<  filename
02255              << " not known for range filtering. line "
02256              << linecnt << ".";
02257         PRINT_ERROR(ERROR.get_str())
02258         throw(keyword_error);
02259         }
02260       }
02261 
02262 
02263 // **********************************************************************
02264 // *** FLAT EARTH CORRECTION == compute reference phase since Feb-2000
02265 // **********************************************************************
02266     else if (!strcmp(keyword,"FE_METHOD"))            // method selector flatearth
02267       {                                               
02268       optionsfile >> filename;
02269       writearg(filename);
02270       toupper(filename);
02271       if (!strcmp(filename,"PORBITS"))
02272         comprefphainput.method=fe_porbits;
02273       else if (!strcmp(filename,"METHOD2"))
02274         comprefphainput.method=fe_method2;
02275       else
02276         {
02277         ERROR << "FE_METHOD: argument: " << filename << " not recognized.";
02278         PRINT_ERROR(ERROR.get_str())
02279         throw(keyword_error);
02280         }
02281       }
02282 
02283 // **********************************************************************
02284     else if (!strcmp(keyword,"FE_DEGREE"))            // degree for flat earth correction
02285       {                                               
02286       optionsfile >> comprefphainput.degree;
02287       writearg(comprefphainput.degree);
02288       }
02289 
02290 // **********************************************************************
02291     else if (!strcmp(keyword,"FE_NPOINTS"))           // number of points used 
02292       {                                               //  for estimation of polynomial
02293       optionsfile >> comprefphainput.Npoints;          //  flat earth correction.
02294       writearg(comprefphainput.Npoints);
02295       }
02296 
02297 // **********************************************************************
02298     else if (!strcmp(keyword,"FE_IN_POS"))            // file with #windows positions
02299       {                                               
02300       optionsfile >> comprefphainput.ifpositions;
02301       writearg(comprefphainput.ifpositions);
02302       }
02303 
02304 
02305 // **********************************************************************
02306 // *** RESAMPLING (SLAVE)
02307 // **********************************************************************
02308     else if (!strcmp(keyword,"RS_METHOD"))            // method selector resampling
02309       {
02310       optionsfile >> filename;
02311       writearg(filename);
02312       toupper(filename);
02313       if (!strcmp(filename,"CC4P"))
02314         resampleinput.method = rs_cc4p;                       // default
02315       else if (!strcmp(filename,"CC6P"))
02316         resampleinput.method = rs_cc6p;
02317       else if (!strcmp(filename,"TS6P"))
02318         resampleinput.method = rs_ts6p;
02319       else if (!strcmp(filename,"TS8P"))
02320         resampleinput.method = rs_ts8p;
02321       else if (!strcmp(filename,"TS16P"))
02322         resampleinput.method = rs_ts16p;
02323       else if (!strcmp(filename,"KNAB4P"))
02324         resampleinput.method = rs_knab4p;
02325       else if (!strcmp(filename,"KNAB6P"))
02326         resampleinput.method = rs_knab6p;
02327       else if (!strcmp(filename,"KNAB8P"))
02328         resampleinput.method = rs_knab8p;
02329       else if (!strcmp(filename,"KNAB10P"))
02330         resampleinput.method = rs_knab10p;
02331       else if (!strcmp(filename,"KNAB16P"))
02332         resampleinput.method = rs_knab16p;
02333       else if (!strcmp(filename,"RECT"))
02334         resampleinput.method = rs_rect;
02335       else if (!strcmp(filename,"TRI"))
02336         resampleinput.method = rs_tri;
02337       else
02338         {
02339         ERROR << "RS_METHOD: method "
02340              <<  filename
02341              << " not known for resampling. line "
02342              << linecnt << ".";
02343         PRINT_ERROR(ERROR.get_str())
02344         throw(keyword_error);
02345         }
02346       }
02347 
02348 // **********************************************************************
02349     else if (!strcmp(keyword,"RS_DBOW"))              // database output window
02350       {
02351       optionsfile >> resampleinput.dbow.linelo
02352                   >> resampleinput.dbow.linehi
02353                   >> resampleinput.dbow.pixlo
02354                   >> resampleinput.dbow.pixhi;
02355       writearg(resampleinput.dbow.linelo);
02356       writearg(resampleinput.dbow.linehi);
02357       writearg(resampleinput.dbow.pixlo);
02358       writearg(resampleinput.dbow.pixhi);
02359       if (resampleinput.dbow.linelo <= 0 || 
02360           resampleinput.dbow.pixlo <= 0 ||
02361           resampleinput.dbow.linelo  > resampleinput.dbow.linehi ||
02362           resampleinput.dbow.pixlo > resampleinput.dbow.pixhi)
02363         {
02364         ERROR << "code 300: Arguments of RS_DBOW card on line " << linecnt
02365              << " missing. [RS_DBOW  min_line  max_line  min_pixel  max_pixel].";
02366         PRINT_ERROR(ERROR.get_str())
02367         throw(keyword_error);
02368         }
02369       }
02370 
02371 // **********************************************************************
02372     else if (!strcmp(keyword,"RS_OUT_FILE"))           // name of output file
02373       {
02374       switch (priorrs_fileout)
02375         {
02376         case true:
02377           WARNING << "RS_OUT_FILE: line: " << linecnt << ": "
02378               << "ignored due to prior occurence.";
02379           WARNING.print();
02380           break;
02381         default:
02382           priorrs_fileout = true;
02383           optionsfile >> resampleinput.fileout;
02384           writearg(resampleinput.fileout);
02385         }
02386       }
02387 
02388 // **********************************************************************
02389     else if (!strcmp(keyword,"RS_OUT_FORMAT"))          // output format
02390       {
02391       optionsfile >> filename;
02392       writearg(filename);
02393       toupper(filename);
02394       if (!strcmp(filename,"CR4"))
02395         resampleinput.oformatflag = FORMATCR4;          // default
02396       else if (!strcmp(filename,"CI2"))
02397         resampleinput.oformatflag = FORMATCI2;
02398       else
02399         {
02400         ERROR << "RS_OUT_FORMAT: output format "
02401              <<  filename
02402              << " not known for resampling. line "
02403              << linecnt << ".";
02404         PRINT_ERROR(ERROR.get_str())
02405         throw(keyword_error);
02406         }
02407       }
02408 
02409 // **********************************************************************
02410     else if (!strcmp(keyword,"RS_SHIFTAZI"))            // true: shift before rs.
02411       {
02412       optionsfile >> keyword;
02413       writearg(keyword);
02414       toupper(keyword);
02415       if (!strcmp(keyword,"ON"))
02416         resampleinput.shiftazi = true;
02417       else if (!strcmp(keyword,"OFF")   ||
02418                !strncmp(keyword,"//",2) ||              // comment
02419                !strncmp(keyword,"#",1)  ||              // comment
02420                !strcmp(keyword,'\0'))                   // no keyword
02421         resampleinput.shiftazi = false;
02422       else
02423         {
02424         resampleinput.shiftazi = true;
02425         WARNING << "RS_SHIFTAZI: line: " << linecnt << ": unknown argument: "
02426              << keyword << "; Set to ON (do shift azimuth spectrum).";
02427         WARNING.print();
02428         }
02429       }
02430 
02431 
02432 // **********************************************************************
02433 // *** COMPUTATION OF INTERFEROGRAM
02434 // **********************************************************************
02435     else if (!strcmp(keyword,"INT_METHOD"))            // method selector interfero
02436       {
02437       optionsfile >> filename;
02438       writearg(filename);
02439       toupper(filename);
02440       if (!strcmp(filename,"OLD"))
02441         interferoinput.method = int_oldmethod;
02442       else if (!strcmp(filename,"OVERSAMPLE"))
02443         interferoinput.method = int_oversample;
02444       else
02445         {
02446         ERROR << "INT_METHOD: method "
02447              <<  filename
02448              << " not known for interfero. line "
02449              << linecnt << ".";
02450         PRINT_ERROR(ERROR.get_str())
02451         throw(keyword_error);
02452         }
02453       }
02454 
02455 // **********************************************************************
02456     else if (!strcmp(keyword,"INT_OUT_INT"))           // name of output file
02457       {
02458       optionsfile >> interferoinput.foint;
02459       writearg(interferoinput.foint);
02460       }
02461 
02462 // **********************************************************************
02463     else if (!strcmp(keyword,"INT_OUT_CINT"))          // name of output file
02464       {
02465       optionsfile >> interferoinput.focint;
02466       writearg(interferoinput.focint);
02467       }
02468 
02469 // **********************************************************************
02470 //    else if (!strcmp(keyword,"INT_OUT_FE"))         // name of output file
02471 //      optionsfile >> interferoinput.foflatearth;
02472 
02473 // **********************************************************************
02474     else if (!strcmp(keyword,"INT_MULTILOOK"))        // multilookfactors
02475       {
02476       optionsfile >> interferoinput.multilookL >> interferoinput.multilookP;
02477       writearg(interferoinput.multilookL);
02478       writearg(interferoinput.multilookP);
02479       }
02480 
02481 // **********************************************************************
02482 // *** COMPUTATION OF COHERENCE
02483 // **********************************************************************
02484     else if (!strcmp(keyword,"COH_METHOD"))            // method selector coherence
02485       {
02486       optionsfile >> filename;
02487       writearg(filename);
02488       toupper(filename);
02489       if (!strcmp(filename,"OLD"))
02490         coherenceinput.method = coh_oldmethod;
02491       else if (!strcmp(filename,"NEW"))
02492         coherenceinput.method = coh_newmethod;
02493       else
02494         {
02495         ERROR << "COH_METHOD: method "
02496              <<  filename
02497              << " not known for coherence. line "
02498              << linecnt << ".";
02499         PRINT_ERROR(ERROR.get_str())
02500         throw(keyword_error);
02501         }
02502       }
02503 
02504 // **********************************************************************
02505     else if (!strcmp(keyword,"COH_OUT_COH"))          // name of output file
02506       {
02507       optionsfile >> coherenceinput.focoh;
02508       writearg(coherenceinput.focoh);
02509       }
02510 
02511 // **********************************************************************
02512     else if (!strcmp(keyword,"COH_OUT_CCOH"))          // name of output file
02513       {
02514       optionsfile >> coherenceinput.foccoh;
02515       writearg(coherenceinput.foccoh);
02516       }
02517 
02518 // **********************************************************************
02519     else if (!strcmp(keyword,"COH_MULTILOOK"))        // multilookfactors
02520       {
02521       optionsfile >> coherenceinput.multilookL >> coherenceinput.multilookP;
02522       writearg(coherenceinput.multilookL);
02523       writearg(coherenceinput.multilookP);
02524       }
02525 
02526 // **********************************************************************
02527     else if (!strcmp(keyword,"COH_WINSIZE"))          // estimator winsize
02528       {
02529       optionsfile >> coherenceinput.cohsizeL >> coherenceinput.cohsizeP;
02530       writearg(coherenceinput.cohsizeL);
02531       writearg(coherenceinput.cohsizeP);
02532       }
02533 
02534 // **********************************************************************
02535 // *** SUBTRACTION OF REFERENCE PHASE
02536 // **********************************************************************
02537     else if (!strcmp(keyword,"SRP_METHOD"))           // method selector ref. phase
02538       {
02539       optionsfile >> filename;
02540       writearg(filename);
02541       toupper(filename);
02542       if (!strcmp(filename,"POLYNOMIAL"))
02543         subtrrefphainput.method = srp_polynomial;
02544       else if (!strcmp(filename,"EXACT"))
02545         subtrrefphainput.method = srp_exact;
02546       else
02547         {
02548         ERROR << "SRP_METHOD: method "
02549              <<  filename
02550              << " not known for subtraction of ref. phase. line "
02551              << linecnt << ".";
02552         PRINT_ERROR(ERROR.get_str())
02553         throw(keyword_error);
02554         }
02555       }
02556 
02557 // **********************************************************************
02558     else if (!strcmp(keyword,"SRP_OUT_CINT"))          // name of output file
02559       {
02560       optionsfile >> subtrrefphainput.focint;
02561       writearg(subtrrefphainput.focint);
02562       }
02563 
02564 // **********************************************************************
02565     else if (!strcmp(keyword,"SRP_OUT_REFPHA"))       // name of output file
02566       {
02567       optionsfile >> subtrrefphainput.forefpha;
02568       writearg(subtrrefphainput.forefpha);
02569       }
02570 
02571 // **********************************************************************
02572     else if (!strcmp(keyword,"SRP_DUMPREFPHA"))      // true: dump ref.pha
02573       {
02574       optionsfile >> keyword;
02575       writearg(keyword);
02576       toupper(keyword);
02577       if (!strcmp(keyword,"ON"))
02578         subtrrefphainput.dumponlyrefpha = true;
02579       else if (!strcmp(keyword,"OFF")   ||
02580                !strncmp(keyword,"//",2) ||              // comment
02581                !strncmp(keyword,"#",1)  ||              // comment
02582                !strcmp(keyword,'\0'))                   // no keyword
02583         subtrrefphainput.dumponlyrefpha = false;
02584       else
02585         {
02586         subtrrefphainput.dumponlyrefpha = false;
02587         WARNING << "SRP_DUMPREFPHA: line: " << linecnt << ": unknown argument: "
02588              << keyword << "; Set to OFF (no dump).";
02589         WARNING.print();
02590         }
02591       }
02592 
02593 // **********************************************************************
02594     else if (!strcmp(keyword,"SRP_MULTILOOK"))        // multilookfactors
02595       {
02596       optionsfile >> subtrrefphainput.multilookL >> keyword;
02597       writearg(subtrrefphainput.multilookL);
02598       writearg(keyword);
02599       if (isdigit(keyword[0]))
02600         subtrrefphainput.multilookP = atoi(keyword);
02601       else                                              // default same factor
02602         subtrrefphainput.multilookP = subtrrefphainput.multilookL;
02603       }
02604 
02605 // **********************************************************************
02606 // *** PHASE FILTER
02607 // **********************************************************************
02608     else if (!strcmp(keyword,"PF_METHOD"))           // method selector phase filtering
02609       {
02610       optionsfile >> filename;
02611       writearg(filename);
02612       toupper(filename);
02613       if (!strcmp(filename,"GOLDSTEIN"))
02614         filtphaseinput.method = fp_goldstein;
02615       else if (!strcmp(filename,"SPATIALCONV"))
02616         filtphaseinput.method = fp_spatialconv;
02617       else if (!strcmp(filename,"SPECTRAL"))
02618         filtphaseinput.method = fp_spectral;
02619       else
02620         {
02621         ERROR << "PF_METHOD: method "
02622              <<  filename
02623              << " not known for phase filtering. line "
02624              << linecnt << ".";
02625         PRINT_ERROR(ERROR.get_str())
02626         throw(keyword_error);
02627         }
02628       }
02629 
02630 // **********************************************************************
02631     else if (!strcmp(keyword,"PF_OUT_FILE"))          // filename
02632       {
02633       optionsfile >> filtphaseinput.fofiltphase;
02634       writearg(filtphaseinput.fofiltphase);
02635       }
02636 
02637 // **********************************************************************
02638     else if (!strcmp(keyword,"PF_IN_FILE"))           // filename
02639       {
02640       optionsfile >> filtphaseinput.fifiltphase >> filtphaseinput.finumlines;
02641       writearg(filtphaseinput.fifiltphase);
02642       writearg(filtphaseinput.finumlines);
02643       }
02644 
02645 // **********************************************************************
02646     else if (!strcmp(keyword,"PF_BLOCKSIZE"))         // buffersize
02647       {
02648       optionsfile >> filtphaseinput.blocksize;
02649       writearg(filtphaseinput.blocksize);
02650       }
02651 
02652 // **********************************************************************
02653     else if (!strcmp(keyword,"PF_ALPHA"))             // alpha
02654       {
02655       optionsfile >> filtphaseinput.alpha;
02656       writearg(filtphaseinput.alpha);
02657       }
02658 
02659 // **********************************************************************
02660     else if (!strcmp(keyword,"PF_OVERLAP"))           // overlap
02661       {
02662       optionsfile >> filtphaseinput.overlap;
02663       writearg(filtphaseinput.overlap);
02664       }
02665 
02666 // **********************************************************************
02667     else if (!strcmp(keyword,"PF_KERNEL"))            // conv. kernel e.g. 3 1 1 1
02668       {
02669       optionsfile >> keyword;
02670       const int32 sizekernel = atoi(keyword);
02671       writearg(sizekernel);
02672       if (!(isodd(sizekernel)))
02673         {
02674         PRINT_ERROR("PF_KERNEL: size must be odd! (add 0, center around midpix)")
02675         throw(keyword_error);
02676         }
02677       filtphaseinput.kernel.resize(1,sizekernel);
02678       real4 sum=0.;
02679       for (int32 argnum=0; argnum<sizekernel; ++argnum)
02680         {
02681         optionsfile >> keyword;
02682         if (!(isdigit(keyword[0])))
02683           WARNING.print("kernel seems to be wrong?");
02684         const real4 in = atof(keyword);
02685         writearg(in);
02686         filtphaseinput.kernel(0,argnum) = in;
02687         sum += abs(in);                                 // kernel -1 1
02688         }
02689       if (sum!=1)
02690         filtphaseinput.kernel /= sum;                   // normalize
02691       INFO << "PF_KERNEL: Input kernel normalized by: " <<  sum;
02692       INFO.print();
02693       }
02694 
02695 // **********************************************************************
02696     else if (!strcmp(keyword,"PF_IN_KERNEL2D"))       // filename for ascii 2d kernel
02697       {
02698       optionsfile >> filtphaseinput.fikernel2d;
02699       writearg(filtphaseinput.fikernel2d);
02700       }
02701 
02702 // *******************************************************************
02703 // *** DINSAR
02704 // *******************************************************************
02705     else if (!strcmp(keyword,"DI_OUT_FILE"))            // output filename
02706       {                                               
02707       optionsfile >> dinsarinput.fodinsar;
02708       writearg(dinsarinput.fodinsar);
02709       }
02710 
02711     else if (!strcmp(keyword,"DI_OUT_SCALED"))          // output filename
02712       {                                               
02713       optionsfile >> dinsarinput.foscaleduint;
02714       writearg(dinsarinput.foscaleduint);
02715       }
02716 
02717     else if (!strcmp(keyword,"DI_IN_TOPOMASTER"))       // input resultfilename
02718       {                                               
02719       optionsfile >> dinsarinput.topomasterresfile;
02720       writearg(dinsarinput.fodinsar);
02721       }
02722 
02723     else if (!strcmp(keyword,"DI_IN_TOPOSLAVE"))        // input resultfilename
02724       {                                               
02725       optionsfile >> dinsarinput.toposlaveresfile;
02726       writearg(dinsarinput.fodinsar);
02727       }
02728 
02729     else if (!strcmp(keyword,"DI_IN_TOPOINT"))          // input resultfilename
02730       {                                               
02731       optionsfile >> dinsarinput.topointresfile;
02732       writearg(dinsarinput.fodinsar);
02733       }
02734 
02735 
02736 // **********************************************************************
02737 // *** COMPUTATION OF REFERENCE DEM (phase)
02738 // **********************************************************************
02739     else if (!strcmp(keyword,"CRD_METHOD"))          // name of output file
02740       {
02741       optionsfile >> filename;
02742       writearg(filename);
02743       toupper(filename);
02744       if (!strcmp(filename,"TRILINEAR") || !strcmp(filename,"TRI_LINEAR") ||
02745           !strcmp(filename,"TRILIN") || !strcmp(filename,"TRI_LIN"))
02746         comprefdeminput.method = crd_trilinear;
02747       else if (!strcmp(filename,"NN") || !strcmp(filename,"NEAREST") ||
02748                !strcmp(filename,"NEAREST_NEIGHBOR" ))
02749         comprefdeminput.method = crd_nearest;
02750       else
02751         {
02752         ERROR << "CRD_METHOD: "
02753              <<  filename
02754              << " not known (use TRILINEAR or NEAREST); line "
02755              << linecnt << ".";
02756         PRINT_ERROR(ERROR.get_str())
02757         throw(keyword_error);
02758         }
02759       }
02760 
02761 // **********************************************************************
02762     else if (!strcmp(keyword,"CRD_IN_DEM"))          // input file
02763       {
02764       optionsfile >> comprefdeminput.firefdem;
02765       writearg(comprefdeminput.firefdem);
02766       }
02767 
02768 // **********************************************************************
02769     else if (!strcmp(keyword,"CRD_IN_FORMAT"))       //  format input file
02770       {
02771       optionsfile >> filename;
02772       writearg(filename);
02773       toupper(filename);
02774       if (!strcmp(filename,"R4") || !strcmp(filename,"REAL4"))
02775         comprefdeminput.iformatflag = FORMATR4;
02776       else if (!strcmp(filename,"I2") || !strcmp(filename,"SHORT"))
02777         comprefdeminput.iformatflag = FORMATI2; // default
02778       else if (!strcmp(filename,"I2_BIGENDIAN") || 
02779                !strcmp(filename,"SHORT_BIGENDIAN"))
02780         comprefdeminput.iformatflag = FORMATI2_BIGENDIAN;       // default
02781       else if (!strcmp(filename,"R8") || !strcmp(filename,"REAL8"))
02782         comprefdeminput.iformatflag = FORMATR8;
02783       else
02784         {
02785         ERROR << "CRD_IN_FORMAT: input format "
02786              <<  filename
02787              << " not known (R4 R8 I2 (native) SHORT_BIGENDIAN); line "
02788              << linecnt << ".";
02789         PRINT_ERROR(ERROR.get_str())
02790         throw(keyword_error);
02791         }
02792       }
02793 
02794 // **********************************************************************
02795     else if (!strcmp(keyword,"CRD_IN_SIZE"))         // nrow ncols (lat lon)
02796       {
02797       optionsfile >> comprefdeminput.demrows >> comprefdeminput.demcols;
02798       writearg(comprefdeminput.demrows);
02799       writearg(comprefdeminput.demcols);
02800       }
02801 
02802 // **********************************************************************
02803     else if (!strcmp(keyword,"CRD_IN_DELTA"))        // degrees delta lat lon
02804       {
02805       optionsfile >> comprefdeminput.demdeltalat >> keyword;
02806       writearg(comprefdeminput.demdeltalat);
02807       writearg(keyword);
02808       if (isdigit(keyword[0]) || keyword[0]=='.')    // likely to be 2 numbers
02809         comprefdeminput.demdeltalon = atof(keyword);
02810       else // default same gridsize
02811         comprefdeminput.demdeltalon = comprefdeminput.demdeltalat;
02812 
02813       // ______ Store as radians ______
02814       comprefdeminput.demdeltalat = deg2rad(comprefdeminput.demdeltalat);
02815       comprefdeminput.demdeltalon = deg2rad(comprefdeminput.demdeltalon);
02816       }
02817 
02818 // **********************************************************************
02819     else if (!strcmp(keyword,"CRD_IN_UL"))           // upperleft coordinates
02820       {
02821       optionsfile >> comprefdeminput.demlatleftupper
02822                   >> comprefdeminput.demlonleftupper;
02823       writearg(comprefdeminput.demlatleftupper);
02824       writearg(comprefdeminput.demlonleftupper);
02825       comprefdeminput.demlatleftupper = deg2rad(comprefdeminput.demlatleftupper);
02826       comprefdeminput.demlonleftupper = deg2rad(comprefdeminput.demlonleftupper);
02827       }
02828 
02829 // **********************************************************************
02830     else if (!strcmp(keyword,"CRD_IN_NODATA"))       // flag for no data
02831       {
02832       optionsfile >> comprefdeminput.demnodata;
02833       writearg(comprefdeminput.demnodata);
02834       }
02835 
02836 // **********************************************************************
02837     else if (!strcmp(keyword,"CRD_INCLUDE_FE"))      // true: ref.pha incl. flat earth
02838       {
02839       optionsfile >> keyword;
02840       writearg(keyword);
02841       toupper(keyword);
02842       if (!strcmp(keyword,"OFF"))
02843         comprefdeminput.includerefpha = false;
02844       else if (!strcmp(keyword,"ON")    ||
02845                !strncmp(keyword,"//",2) ||              // comment
02846                !strncmp(keyword,"#",1)  ||              // comment
02847                !strcmp(keyword,'\0'))                   // no keyword
02848         comprefdeminput.includerefpha = true;
02849       else
02850         {
02851         comprefdeminput.includerefpha = false;
02852         WARNING << "CRD_INCLUDE_FE: line: " << linecnt << ": unknown argument: "
02853              << keyword 
02854              << "; Set to OFF (computing pure topo phase w.r.t. flat earth).";
02855         WARNING.print();
02856         }
02857       }
02858 
02859 // **********************************************************************
02860     else if (!strcmp(keyword,"CRD_DENSE"))              // factor
02861       {
02862       optionsfile >> comprefdeminput.extradense;
02863       writearg(comprefdeminput.extradense);
02864       }
02865 
02866 // **********************************************************************
02867     else if (!strcmp(keyword,"CRD_OUT_DEM"))          // name of output file
02868       {
02869       optionsfile >> comprefdeminput.fodem;
02870       writearg(comprefdeminput.fodem);
02871       }
02872 
02873 // **********************************************************************
02874     else if (!strcmp(keyword,"CRD_OUT_DEMI"))          // name of output file
02875       {
02876       optionsfile >> comprefdeminput.fodemi;
02877       writearg(comprefdeminput.fodemi);
02878       }
02879 
02880 // **********************************************************************
02881     else if (!strcmp(keyword,"CRD_OUT_FILE"))          // name of output file
02882       {
02883       optionsfile >> comprefdeminput.forefdem;
02884       writearg(comprefdeminput.forefdem);
02885       }
02886 
02887 // **********************************************************************
02888     else if (!strcmp(keyword,"CRD_OUT_DEM_LP"))        // name of output file
02889       {
02890       optionsfile >> comprefdeminput.forefdemhei;
02891       writearg(comprefdeminput.forefdemhei);
02892       }
02893 
02894 
02895 // **********************************************************************
02896 // *** SUBTRACTION OF REFERENCE DEM (phase)
02897 // **********************************************************************
02898     else if (!strcmp(keyword,"SRD_OUT_CINT"))          // name of output file
02899       {
02900       optionsfile >> subtrrefdeminput.focint;
02901       writearg(subtrrefdeminput.focint);
02902       }
02903 
02904 // **********************************************************************
02905     else if (!strcmp(keyword,"SRD_OFFSET"))          // Line Pixel
02906       {
02907       optionsfile >> subtrrefdeminput.offsetL >> subtrrefdeminput.offsetP;
02908       writearg(subtrrefdeminput.offsetL);
02909       writearg(subtrrefdeminput.offsetP);
02910       }
02911 
02912 //  // **********************************************************************
02913 //  // *** ADDITION OF REFERENCE DEM (phase)
02914 //  // **********************************************************************
02915 //      else if (!strcmp(keyword,"ARD_OUT_CINT"))          // name of output file
02916 //        {
02917 //        optionsfile >> addrefdeminput.focint;
02918 //        }
02919 
02920 // **********************************************************************
02921 // *** UNWRAPPING
02922 // **********************************************************************
02923     else if (!strcmp(keyword,"UW_METHOD"))  // method selector unwrapping
02924       {                                               
02925       optionsfile >> filename;
02926       writearg(filename);
02927       toupper(filename);
02928       if (!strcmp(filename,"RAMON"))
02929         unwrapinput.method = uw_method1;
02930       else if (!strcmp(filename,"SNAPHU"))
02931         unwrapinput.method = uw_method2;//   default
02932       else if (!strcmp(filename,"MCF_DLR"))
02933         unwrapinput.method = uw_method3;
02934       else
02935         {
02936         ERROR << "UW_METHOD: method "
02937              <<  filename
02938              << " not known for unwrapping on line "
02939              << linecnt << ".";
02940         PRINT_ERROR(ERROR.get_str())
02941         throw(keyword_error);
02942         }
02943       }
02944 
02945 // **********************************************************************
02946     else if (!strcmp(keyword,"UW_SEEDS"))             // position of seeds
02947       {
02948       optionsfile >> filename;
02949       writearg(filename);
02950       if (isdigit(filename[0]))
02951         {
02952         unwrapinput.deltaLseed = atoi(filename);
02953         optionsfile >> filename;
02954         writearg(filename);
02955         if (isdigit(filename[0]))
02956           unwrapinput.deltaPseed = atoi(filename);
02957         else
02958           unwrapinput.deltaPseed = unwrapinput.deltaLseed;
02959         }
02960       else      // assume no numbers but filename with seeds
02961         {
02962         strcpy(unwrapinput.seedfile,filename);
02963         }
02964       }
02965 
02966 // **********************************************************************
02967     else if (!strcmp(keyword,"UW_OUT_FILE"))          // filename output unwrapped int.
02968       {
02969       optionsfile >> unwrapinput.fouint;
02970       writearg(unwrapinput.fouint);
02971       }
02972 
02973 // **********************************************************************
02974     else if (!strcmp(keyword,"UW_OUT_FORMAT"))       // output format
02975       {
02976       optionsfile >> filename;
02977       writearg(filename);
02978       toupper(filename);
02979       if (!strcmp(filename,"R4") || !strcmp(filename,"REAL4"))
02980         unwrapinput.oformatflag = FORMATR4;
02981       else if (!strcmp(filename,"CR4") || !strcmp(filename,"COMPLEXR4"))
02982         {
02983         WARNING.print("UW_OUT_FORMAT = CR4 --> Using hgt format");
02984         unwrapinput.oformatflag = FORMATHGT;// default
02985         }
02986       else if (!strcmp(filename,"HGT"))
02987         unwrapinput.oformatflag = FORMATHGT;// default
02988       else
02989         {
02990         unwrapinput.oformatflag = FORMATHGT;// default
02991         WARNING << "UW_OUT_FORMAT: output format "
02992              <<  filename
02993              << " not known (R4 or HGT, using HGT); line "
02994              << linecnt << ".";
02995         WARNING.print();
02996         }
02997       }
02998 
02999 // **********************************************************************
03000     else if (!strcmp(keyword,"UW_OUT_REGIONS"))       // filename output regions
03001       {
03002       optionsfile >> unwrapinput.foregions;
03003       writearg(unwrapinput.foregions);
03004       }
03005 
03006 // **********************************************************************
03007     else if (!strcmp(keyword,"UW_SNAPHU_MODE"))       // filename output regions
03008       {
03009       optionsfile >> filename;
03010       writearg(filename);
03011       toupper(filename);
03012       if (!strcmp(filename,"TOPO"))
03013         strcpy(unwrapinput.snaphu_mode,"TOPO");        // default TOPO
03014       else if (!strcmp(filename,"DEFO"))
03015         strcpy(unwrapinput.snaphu_mode,"DEFO");
03016       else if (!strcmp(filename,"SMOOTH"))
03017         strcpy(unwrapinput.snaphu_mode,"SMOOTH");
03018       else if (!strcmp(filename,"NOSTATCOSTS"))
03019         strcpy(unwrapinput.snaphu_mode,"NOSTATCOSTS");
03020       else
03021         {
03022         ERROR << "UW_SNAPHU_MODE: "
03023              <<  filename
03024              << " not known for unwrapping on line "
03025              << linecnt << ".";
03026         PRINT_ERROR(ERROR.get_str())
03027         throw(keyword_error);
03028         }
03029       }
03030 
03031 // **********************************************************************
03032     else if (!strcmp(keyword,"UW_SNAPHU_INIT"))
03033       {
03034       optionsfile >> filename;
03035       writearg(filename);
03036       toupper(filename);
03037       if (!strcmp(filename,"MST"))
03038         strcpy(unwrapinput.snaphu_init,"MST");     // default mst
03039       else if (!strcmp(filename,"MCF"))
03040         strcpy(unwrapinput.snaphu_init,"MCF");
03041       else
03042         {
03043         WARNING << "UW_SNAPHU_INIT: "
03044              <<  filename
03045              << " not known for unwrapping on line "
03046              << linecnt << " (using MST).";
03047         WARNING.print();
03048         }
03049       }
03050 
03051 // **********************************************************************
03052     else if (!strcmp(keyword,"UW_SNAPHU_LOG"))
03053       {
03054       optionsfile >> unwrapinput.snaphu_log;
03055       writearg(unwrapinput.snaphu_log);
03056       //strcpy(unwrapinput.snaphu_log,"-l ");
03057       //optionsfile >> filename;
03058       //writearg(filename);
03059       //strcat(unwrapinput.snaphu_log,filename);
03060       }
03061 
03062 // **********************************************************************
03063     else if (!strcmp(keyword,"UW_SNAPHU_COH"))
03064       {
03065       optionsfile >> unwrapinput.snaphu_coh;
03066       writearg(unwrapinput.snaphu_coh);
03067       }
03068 
03069 // **********************************************************************
03070     else if (!strcmp(keyword,"UW_SNAPHU_VERBOSE"))
03071       {
03072       optionsfile >> keyword;
03073       writearg(keyword);
03074       toupper(keyword);
03075       if (!strcmp(keyword,"OFF"))
03076         strcpy(unwrapinput.snaphu_verbose,"FALSE");
03077       else if (!strcmp(keyword,"ON")    ||
03078                !strncmp(keyword,"//",2) ||              // comment
03079                !strncmp(keyword,"#",1)  ||              // comment
03080                !strcmp(keyword,'\0'))                   // no keyword
03081         strcpy(unwrapinput.snaphu_verbose,"TRUE");
03082       else
03083         {
03084         strcpy(unwrapinput.snaphu_verbose,"TRUE");
03085         WARNING << "UW_SNAPHU_VERBOSE: line: " 
03086              << linecnt << ": unknown argument: " << keyword 
03087              << "; Set to ON.";
03088         WARNING.print();
03089         }
03090       }
03091 
03092 // **********************************************************************
03093 // *** SLANT to HEIGHT CONVERSION
03094 // **********************************************************************
03095     else if (!strcmp(keyword,"S2H_METHOD"))           // method selector slant2height
03096       {                                               
03097       optionsfile >> filename;
03098       writearg(filename);
03099       toupper(filename);
03100       if (!strcmp(filename,"SCHWABISCH"))
03101         slant2hinput.method = s2h_schwabisch;
03102       else if (!strcmp(filename,"AMBIGUITY"))
03103         slant2hinput.method = s2h_ambiguity;
03104       else if (!strcmp(filename,"RODRIGUEZ"))
03105         slant2hinput.method = s2h_rodriguez;
03106       else
03107         {
03108         ERROR << "S2H_METHOD: method "
03109              <<  filename
03110              << " not known for slant to height conversion, line "
03111              << linecnt << ".";
03112         PRINT_ERROR(ERROR.get_str())
03113         throw(keyword_error);
03114         }
03115       }
03116 
03117 // **********************************************************************
03118     else if (!strcmp(keyword,"S2H_NPOINTS"))          // number of points to use
03119       {
03120       optionsfile >> slant2hinput.Npoints;
03121       writearg(slant2hinput.Npoints);
03122       }
03123 
03124 // **********************************************************************
03125     else if (!strcmp(keyword,"S2H_DEGREE1D"))         // degree of 1d polynomial
03126       {
03127       optionsfile >> slant2hinput.degree1d;
03128       writearg(slant2hinput.degree1d);
03129       }
03130 
03131 // **********************************************************************
03132     else if (!strcmp(keyword,"S2H_DEGREE2D"))          // degree of 2d polynomial
03133       {
03134       optionsfile >> slant2hinput.degree2d;
03135       writearg(slant2hinput.degree2d);
03136       }
03137 
03138 // **********************************************************************
03139     else if (!strcmp(keyword,"S2H_NHEIGHTS"))         // #heights to evaluate ref.pha
03140       {
03141       optionsfile >> slant2hinput.Nheights;
03142       writearg(slant2hinput.Nheights);
03143       }
03144 
03145 // **********************************************************************
03146     else if (!strcmp(keyword,"S2H_OUT_HEI"))          // filename output height
03147       {
03148       optionsfile >> slant2hinput.fohei;
03149       writearg(slant2hinput.fohei);
03150       }
03151 
03152 // **********************************************************************
03153     else if (!strcmp(keyword,"S2H_OUT_PHI"))          // filename output latitude
03154       {
03155       optionsfile >> slant2hinput.fophi;
03156       writearg(slant2hinput.fophi);
03157       }
03158 
03159 // **********************************************************************
03160     else if (!strcmp(keyword,"S2H_OUT_LAM"))          // filename output longitude
03161       {
03162       optionsfile >> slant2hinput.folam;
03163       writearg(slant2hinput.folam);
03164       }
03165 
03166 // **********************************************************************
03167 // *** GEOCODING
03168 // **********************************************************************
03169 //      else if (!strcmp(keyword,"GEO_METHOD"))
03170 //        {
03171 //        optionsfile >> geocodeinput.method;
03172 //        }
03173 
03174 // **********************************************************************
03175     else if (!strcmp(keyword,"GEO_OUT_PHI"))          // output file latitude
03176       {
03177       optionsfile >> geocodeinput.fophi;
03178       writearg(geocodeinput.fophi);
03179       }
03180 
03181 // **********************************************************************
03182     else if (!strcmp(keyword,"GEO_OUT_LAM"))          // output file longitude
03183       {
03184       optionsfile >> geocodeinput.folam;
03185       writearg(geocodeinput.folam);
03186       }
03187 
03188 
03189 // **********************************************************************
03190 // Assume wrong keyword, but if it starts with //, a c, or comment
03191 // then continue with a warning, no blank between key and arg
03192 // **********************************************************************
03193     else if (!strncmp(keyword,"COMMENT",7) ||   // assume user wanted to comment out
03194              !strncmp(keyword,"C",1))           // but forgot a space
03195       {
03196       WARNING << "Unknown keyword: \"" << keyword 
03197            << "\" at line: " << linecnt
03198            << ". (Interpreted as comment, ignored)";
03199       WARNING.print();
03200       }
03201     // ______ Really cannot make anything from your input ______
03202     else
03203       {
03204       ERROR << "Unknown keyword: \"" << keyword 
03205            << "\" at line: " << linecnt << ".";
03206       PRINT_ERROR(ERROR.get_str())
03207       throw(keyword_error);
03208       }
03209     optionsfile.getline(dummyline,ONE27,'\n');          // goto next line
03210     } // end while (file)
03211 
03212 
03213 
03214 
03215 
03216 
03217 // ====== Check input/ info to screen ======
03218   checkgeneral(generalinput, onlyprocess);              // also repair onlyprocess
03219   INFO << "LISTINPUT: \tAppend input to logfile: \t" << listinput;
03220   INFO.print();
03221 
03222 
03223 // ______ info ELLIPSOID card, compute and fill e2, e2b ______
03224   ellipsinput.ecc1st_sqr();
03225   ellipsinput.ecc2nd_sqr();
03226   INFO << "ELLIPSOID: \tEllipsoid used (orbit, output): "
03227        << ellipsinput.name << ".";
03228   INFO.print();
03229   INFO << "ELLIPSOID: a   = " << setw(15) << setprecision(10) << ellipsinput.a;
03230   INFO.print();
03231   INFO << "ELLIPSOID: b   = " << setw(15) << setprecision(10) << ellipsinput.b;
03232   INFO.print();
03233   INFO << "ELLIPSOID: e2  = " << ellipsinput.e2;
03234   INFO.print();
03235   INFO << "ELLIPSOID: e2' = " << ellipsinput.e2b;
03236   INFO.print();
03237   INFO.reset();
03238 
03239 
03240 // ====== Check input of step reading info from files ======
03241   if (generalinput.process[pr_m_readfiles])
03242     checkreadfiles(m_readfilesinput, MASTERID);         // check mandatory cards
03243 
03244   if (generalinput.process[pr_s_readfiles])
03245     checkreadfiles(s_readfilesinput, SLAVEID);          // check mandatory cards
03246 
03247 
03248 // ====== Check input of step conversion slc to raw ======
03249   if (generalinput.process[pr_m_crop])
03250     {
03251     checkcrop(m_cropinput, MASTERID);
03252     if (!strcmp(s_cropinput.fileout1,m_cropinput.fileout1))
03253       {
03254       PRINT_ERROR(
03255       "code 301: same name outputfile CROP_OUT for master and slave not allowed.")
03256       throw(keyword_error);
03257       }
03258     if (generalinput.overwrit)
03259       if (existed(m_cropinput.fileout1))
03260         {
03261         INFO << "OVERWRIT: file " << m_cropinput.fileout1 
03262              << " will be overwritten.";
03263         INFO.print();
03264         }
03265     }
03266 
03267   if (generalinput.process[pr_s_crop])
03268     {
03269     checkcrop(s_cropinput, SLAVEID);
03270     if (!strcmp(s_cropinput.fileout1,m_cropinput.fileout1))
03271       {
03272       PRINT_ERROR(
03273       "code 301: same name outputfile CROP_OUT for master and slave not allowed.")
03274       throw(keyword_error);
03275       }
03276     if (generalinput.overwrit)
03277       if (existed(s_cropinput.fileout1))
03278         {
03279         INFO << "OVERWRIT: file " << s_cropinput.fileout1 
03280              << " will be overwritten.";
03281         INFO.print();
03282         }
03283     }
03284 
03285 //____RaffaeleNutricato START MODIFICATION SECTION 10
03286 // ====== Check input of step oversample master======
03287   if (generalinput.process[pr_m_oversample])
03288     {
03289     checkoversample(m_oversample, MASTERID);
03290     }
03291 // ====== Check input of step oversampling slave ======
03292   if (generalinput.process[pr_s_oversample])
03293     {
03294     checkoversample(s_oversample, SLAVEID);
03295     }
03296 //____RaffaeleNutricato END MODIFICATION SECTION 10
03297 
03298 
03299 // ====== Check input of step porbits ======
03300   if (generalinput.process[pr_m_porbits])
03301     checkporbits(porbitsinput, MASTERID);
03302   if (generalinput.process[pr_s_porbits])
03303     checkporbits(porbitsinput, SLAVEID);
03304 
03305 // ====== Check input of step azimuth filtering ======
03306   if (generalinput.process[pr_m_filtazi] ||
03307       generalinput.process[pr_s_filtazi])
03308     {
03309     // ______ Set defaults ______
03310     if (filtaziinput.overlap == -1)
03311       filtaziinput.overlap = filtaziinput.fftlength/8;  // default
03312     // ______ Check input ______
03313     if (generalinput.process[pr_m_filtazi] &&
03314         generalinput.process[pr_s_filtazi])
03315       checkfiltazi(filtaziinput,MASTERID+SLAVEID);
03316     else if (generalinput.process[pr_m_filtazi])
03317       checkfiltazi(filtaziinput,MASTERID);
03318     else if (generalinput.process[pr_s_filtazi])
03319       checkfiltazi(filtaziinput,SLAVEID);
03320     else 
03321       {
03322       PRINT_ERROR("PANIC, this cannot be")
03323       throw(keyword_error);
03324       }
03325     }
03326 
03327 // ====== Check input of step range filtering ======
03328   if (generalinput.process[pr_m_filtrange])
03329     {
03330     // ______ Check defaults ______
03331     if (filtrangeinput.fftlength==-999) // not specified
03332       {
03333       if (filtrangeinput.method==rf_adaptive)
03334         filtrangeinput.fftlength=64;            // default
03335       else if (filtrangeinput.method==rf_porbits)
03336         filtrangeinput.fftlength=1024;          // default
03337       }
03338     checkfiltrange(filtrangeinput);
03339     }
03340 
03341 // ====== Check input of reserved EXTRA step master/slave ======
03342   if (generalinput.process[pr_m_EXTRA])
03343     {
03344     PRINT_ERROR("extra step master not implemented.")
03345     throw(keyword_error);
03346     }
03347   if (generalinput.process[pr_s_EXTRA])
03348     {
03349     PRINT_ERROR("extra step slave not implemented.")
03350     throw(keyword_error);
03351     }
03352 
03353 // ====== Check input of step coarse (orbits) ======
03354 // ______ no checks required. (no cards as well)
03355   if (generalinput.process[pr_i_coarse])
03356     {
03357     ; // do nothing
03358     }
03359 
03360 
03361 // ====== Check coarse coregistration based on correlation ======
03362 // ______ Check + repair method selector coarse correlation ______
03363   if (generalinput.process[pr_i_coarse2])               // correlation
03364     {
03365     if (coarsecorrinput.method == def_cc_method-999) // see at defaults, no method card used
03366       {
03367       coarsecorrinput.method = def_cc_method;           // default method
03368       INFO.print("Default method will be used for coarse coregistration.");
03369       }
03370     if (specified(coarsecorrinput.ifpositions))         // filename specified
03371       {
03372       if (coarsecorrinput.Nwin != def_cc_nwin+999)      // something is specified
03373         {
03374         WARNING << "CC_NWIN: \t" << coarsecorrinput.Nwin
03375              << " ignored due to existence of input file (CC_IN_POS) "
03376              << coarsecorrinput.ifpositions;
03377         WARNING.print();
03378         }
03379       coarsecorrinput.Nwin = filelines(coarsecorrinput.ifpositions);
03380       }
03381     else if (coarsecorrinput.Nwin == def_cc_nwin+999)   // no inputfile, default
03382       {
03383       coarsecorrinput.Nwin = def_cc_nwin;
03384       INFO.print("Default number of windows will be used for coarse coregistration.");
03385       }
03386     checkcoarsecorr(coarsecorrinput);
03387     }
03388 
03389 
03390 // ====== Check input of step fine ======
03391   if (generalinput.process[pr_i_fine])
03392     {
03393     if (fineinput.method == def_fc_method-999)  // see at defaults, no method card used
03394       {
03395       fineinput.method = def_fc_method;         // default method
03396       INFO.print("Default method will be used for fine coregistration.");
03397       }
03398     if (specified(fineinput.ifpositions))         // filename specified
03399       {
03400       if (fineinput.Nwin != def_fc_nwin+999)    // something is specified
03401         {
03402         WARNING << "FC_NWIN: \t" << fineinput.Nwin
03403              << " ignored due to existence of input file (FC_IN_POS) "
03404              << fineinput.ifpositions;
03405         WARNING.print();
03406         }
03407       fineinput.Nwin = filelines(fineinput.ifpositions);
03408       }
03409     else if (fineinput.Nwin == def_fc_nwin+999) // no inputfile, default
03410       {
03411       fineinput.Nwin = def_fc_nwin;
03412       INFO.print("Default number of windows will be used for fine coregistration.");
03413       }
03414     checkfine(fineinput);
03415     }
03416 
03417 
03418   // ====== Check input step coregpm ======
03419   if (generalinput.process[pr_i_coregpm])
03420     {
03421     checkcoregpm(coregpminput);
03422     }
03423 
03424   // ====== Check + repair method selector resampling ======
03425   if (generalinput.process[pr_s_resample])              // request for process resample
03426     {
03427     if (resampleinput.method == def_rs_method-999)      // see at defaults, no method card used
03428       {
03429       resampleinput.method = def_rs_method;             // default method
03430       INFO.print("RS_METHOD: Using default.");
03431       }
03432     if (!priorrs_fileout)
03433       INFO.print("RS_OUT_FILE: Using default.");
03434     checkresample(resampleinput);
03435     }
03436 
03437   // ====== Check + repair method selector flatearth correction ======
03438   if (generalinput.process[pr_i_comprefpha])
03439     {
03440     if (comprefphainput.method == def_fe_method-999)     // see at defaults, no method card used
03441       {
03442       comprefphainput.method = def_fe_method;            // default method
03443       INFO.print("FE_METHOD: Using default.");
03444       }
03445     if (comprefphainput.Npoints == def_fe_Npoints-999)   // default applies
03446       {
03447       comprefphainput.Npoints = def_fe_Npoints;          // default value
03448       // INFO.print("FE_NPOINTS: Using default.");
03449       }
03450     // ______ if read from file, count number of points ______
03451     if (specified(comprefphainput.ifpositions))         // filename specified
03452       {
03453       INFO.print("FE_IN_POS: Using file to read positions.");
03454       comprefphainput.Npoints = filelines(comprefphainput.ifpositions);
03455       }
03456     if (comprefphainput.degree == def_fe_degree-999)     // default
03457       {
03458       comprefphainput.degree = def_fe_degree;            // default
03459       INFO.print("FE_DEGREE: Using default.");
03460       }
03461     checkcomprefpha(comprefphainput);
03462     }
03463 
03464   // ====== Check input of step interfero ======
03465   if (generalinput.process[pr_i_interfero])
03466     {
03467     checkinterfero(interferoinput);
03468     }
03469 
03470   // ====== Check input of SUBTRREFPHA step interferogram ======
03471   if (generalinput.process[pr_i_subtrrefpha])
03472     checksubtrrefpha(subtrrefphainput);
03473 
03474   // ====== Check input of COMPREFDEM step interferogram ======
03475   if (generalinput.process[pr_i_comprefdem])
03476     {
03477     checkcomprefdem(comprefdeminput);
03478     }
03479 
03480   // ====== Check input of SUBTRDEM step interferogram ======
03481   if (generalinput.process[pr_i_subtrrefdem])
03482     {
03483     checksubtrrefdem(subtrrefdeminput);
03484     }
03485 
03486   // ====== Check input of step coherence ======
03487   if (generalinput.process[pr_i_coherence])
03488     {
03489     checkcoherence(coherenceinput);
03490     }
03491 
03492   // ====== Check input of step phase filtering ======
03493   if (generalinput.process[pr_i_filtphase])
03494     {
03495     if (!specified(filtphaseinput.fofiltphase))  // not specified, use default
03496       {
03497       if (filtphaseinput.method==fp_goldstein)
03498         {
03499         char dummy127[ONE27];
03500         ostrstream omemfo(dummy127,ONE27);
03501         omemfo << "cint." << filtphaseinput.alpha << "filtered" << ends;
03502         strcpy(filtphaseinput.fofiltphase,dummy127);
03503         if (filtphaseinput.kernel.size()==0)
03504           {
03505           INFO.print("PF_KERNEL: Using default kernel [1 2 3 2 1].");
03506           filtphaseinput.kernel.resize(1,5);
03507           filtphaseinput.kernel(0,0) = 1./9.;
03508           filtphaseinput.kernel(0,1) = 2./9.;
03509           filtphaseinput.kernel(0,2) = 3./9.;
03510           filtphaseinput.kernel(0,3) = 2./9.;
03511           filtphaseinput.kernel(0,4) = 1./9.;
03512           }
03513         }
03514       else if (filtphaseinput.method==fp_spatialconv)
03515         {
03516         strcpy(filtphaseinput.fofiltphase,"cint.filtered");
03517         // ______ Set default kernel ______
03518         if (!specified(filtphaseinput.fikernel2d))      // no input file
03519           {
03520           if (filtphaseinput.kernel.size()==0)
03521             {
03522             INFO.print("PF_KERNEL: Using default kernel [1 1 1].");
03523             filtphaseinput.kernel.resize(1,3);
03524             filtphaseinput.kernel(0,0) = 1./3.;
03525             filtphaseinput.kernel(0,1) = 1./3.;
03526             filtphaseinput.kernel(0,2) = 1./3.;
03527             }
03528           }
03529         }
03530       else if (filtphaseinput.method==fp_spectral)
03531         {
03532         strcpy(filtphaseinput.fofiltphase,"cint.filtered");
03533         }
03534       else
03535         {
03536         PRINT_ERROR("Method filtphase not known")
03537         throw(keyword_error);
03538         }
03539       }
03540     checkfiltphase(filtphaseinput);
03541     }
03542 
03543 
03544   // ====== Check input of step unwrapping ======
03545   if (generalinput.process[pr_i_unwrap])                 // request for process unwrapping
03546     {
03547     if (unwrapinput.method == def_uw_method-999)        // see at defaults, no method card used
03548       {
03549       unwrapinput.method = def_uw_method;               // default method
03550       INFO.print("Default method will be used for unwrapping.");
03551       }
03552     checkunwrap(unwrapinput);
03553     }
03554 
03555 
03556   // ====== Check input of step slant2height ======
03557   if (generalinput.process[pr_i_slant2h])
03558     {
03559     if (slant2hinput.method == def_s2h_method-999)
03560       {
03561       slant2hinput.method = def_s2h_method;               // default method
03562       INFO.print("Default method will be used for slant2h.");
03563       }
03564     if (slant2hinput.Nheights <= slant2hinput.degree1d)
03565       {
03566       WARNING << "S2H_NHEIGHTS: \t" << slant2hinput.Nheights 
03567            << " is too large because S2H_DEGREE1D="
03568            << slant2hinput.degree1d 
03569            << "; set S2H_NHEIGHTS = " << slant2hinput.degree1d+1
03570            << " (minimum)";
03571       WARNING.print();
03572       slant2hinput.Nheights = slant2hinput.degree1d + 1;
03573       }
03574     checkslant2h(slant2hinput);
03575     }
03576 
03577 
03578   // ====== Check input of step geocoding ======
03579   if (generalinput.process[pr_i_geocoding])
03580     {
03581     checkgeocode(geocodeinput);
03582     }
03583 
03584   // ====== Check input of dinsar step interferogram ======
03585   if (generalinput.process[pr_i_dinsar])
03586     {
03587     if (!strcmp(dinsarinput.topomasterresfile,generalinput.m_resfile))
03588       setunspecified(dinsarinput.topomasterresfile);    // used in check...
03589     checkdinsar(dinsarinput);
03590     if (!specified(dinsarinput.topomasterresfile))
03591       strcpy(dinsarinput.topomasterresfile,generalinput.m_resfile);
03592     }
03593 
03594   // ====== Check input of reserved EXTRA step interferogram ======
03595   if (generalinput.process[pr_i_EXTRA2])
03596     {
03597     PRINT_ERROR("extra step2 interferogram not implemented.")
03598     throw(keyword_error);
03599     }
03600 
03601 
03602 
03603 // ====== Copy input to logfile (via scratchfile, update in main) ======
03604 //   to avoid problems with not existing file it is always opened here
03605   ofstream scratchreadinput("scratchreadinput", ios::out | ios::trunc);
03606   bk_assert(scratchreadinput,"readinput: scratchreadinput",__FILE__,__LINE__);
03607 
03608   if (listinput)
03609     {
03610     // ______Start writing______
03611     linecnt=0;
03612     scratchreadinput << "\n----------------------------------------------------\n"
03613                      << "      BEGIN: copy of input (non-interpretive).\n"
03614                      << "-line---keyword----argument-------------comment-----\n";
03615     optionsfile.seekg(0,ios::beg);
03616     optionsfile.getline(dummyline,ONE27,'\n');
03617     while (optionsfile)
03618       {
03619       linecnt++;
03620       scratchreadinput << setw(3) << linecnt << ": " << dummyline << endl;
03621       optionsfile.getline(dummyline,ONE27,'\n');
03622       }
03623     scratchreadinput << "\n----------------------------------------------------\n"
03624                      << "      END: copy of input.\n"
03625                      << "----------------------------------------------------\n\n";
03626     DEBUG.print("Finished writing to scratchreadinput.");
03627     }
03628 
03629 // ______Tidy up______
03630   PROGRESS.print("Interpretation inputoptionsfile finished.");
03631   scratchreadinput.close();
03632   optionsfile.close();
03633   } // END READINPUT
03634 
03635 
03636 
03637 /****************************************************************
03638  *    checkgeneral                                              *
03639  *                                                              *
03640  * Checks general cards.                                        *
03641  * Repair process card                                          *
03642  *                                                              *
03643  *    Bert Kampes, 06-Sep-1999                                  *
03644  ****************************************************************/
03645 void checkgeneral(
03646         input_gen &generalinput,
03647         const int16 onlyprocess)
03648   {
03649   TRACE_FUNCTION("checkgeneral (BK 06-Sep-1999)")
03650   register int32 i;
03651   int32 cs_processcard = 0;
03652 
03653 // ______ Repair process control if ONLYPROCESS card was present ______
03654   for (i=0; i<NUMPROCESSES; i++)
03655     cs_processcard += generalinput.process[i];
03656   if (onlyprocess != -1)                                     // initialized to -1;
03657     {
03658     generalinput.interactive=false;
03659     INFO.print("ONLYPROCESS card present, batch processing.");
03660     if (cs_processcard == 1)
03661       WARNING.print("PROCESS card ignored due to presence ONLYPROCESS card.");
03662     if (cs_processcard >  1)
03663       WARNING.print("PROCESS cards ignored due to presence ONLYPROCESS card.");
03664     for (i=0; i<NUMPROCESSES; i++)                      // do not process anything...
03665       generalinput.process[i]=0;
03666     generalinput.process[onlyprocess]=1;                  // exept this one.
03667     }
03668 
03669   else                                                  // check process card presence
03670     {
03671     if (cs_processcard == 0)                            // no cards
03672       {
03673       PRINT_ERROR("code 303: No (ONLY)PROCESS card present, exiting.")
03674       throw(keyword_error);
03675       }
03676     }
03677 
03678   INFO.print("\n\t*** General input cards ***");
03679   INFO << "MEMORY: \tAvailable to Doris [MB]: \t"
03680        << generalinput.memory/1e6;
03681   INFO.print();
03682 
03683   INFO << "M_RESFILE: \tResultfile for master: \t\t"
03684        << generalinput.m_resfile;
03685   INFO.print();
03686   INFO << "S_RESFILE: \tResultfile for slave: \t\t"
03687        << generalinput.s_resfile;
03688   INFO.print();
03689   INFO << "I_RESFILE: \tResultfile for products: \t"
03690        << generalinput.i_resfile;
03691   INFO.print();
03692   INFO << "LOGFILE: \tOut file for logging: \t\t"
03693        << generalinput.logfile;
03694   INFO.print();
03695   INFO << "ORB_INTERP: \tmethod selector value:\t\t"
03696        << generalinput.orb_interp;
03697   INFO.print();
03698   INFO << "DUMPBASELINE: evaluation grid for baseline: \t"
03699        << generalinput.dumpbaselineL << " lines x "
03700        << generalinput.dumpbaselineP << " pixels: ";
03701   INFO.print();
03702   INFO << "HEIGHT: \taverage terrain height:\t\t"
03703        << generalinput.terrain_height;
03704   INFO.print();
03705   INFO << "TIEPOINT: \tlat/lon/hei: "
03706        << generalinput.tiepoint.x << " " 
03707        << generalinput.tiepoint.y << " "
03708        << generalinput.tiepoint.z;
03709   INFO.print();
03710 
03711   if (!strcmp(generalinput.m_resfile,generalinput.s_resfile))
03712     {
03713     PRINT_ERROR("same name master and slave resultfile not allowed.")
03714     throw(keyword_error);
03715     }
03716   if (!strcmp(generalinput.m_resfile,generalinput.i_resfile))
03717     {
03718     PRINT_ERROR("same name master and interferogram resultfile not allowed.");
03719     throw(keyword_error);
03720     }
03721   if (!strcmp(generalinput.m_resfile,generalinput.logfile))
03722     {
03723     PRINT_ERROR("same name master resultfile and logfile not allowed.");
03724     throw(keyword_error);
03725     }
03726   if (!strcmp(generalinput.i_resfile,generalinput.logfile))
03727     {
03728     PRINT_ERROR("same name interferogram resultfile and logfile not allowed.");
03729     throw(keyword_error);
03730     }
03731   } // END checkgeneral
03732 
03733 
03734 /****************************************************************
03735  *    checkreadfiles                                            *
03736  *                                                              *
03737  * Checks cards for step readfiles.                             *
03738  *                                                              *
03739  *    Bert Kampes, 06-Sep-1999                                  *
03740  ****************************************************************/
03741 void checkreadfiles(
03742         const input_readfiles &readfilesinput,
03743         const int16 id)
03744   {
03745   TRACE_FUNCTION("checkreadfiles (BK 06-Sep-1999)")
03746   switch (id)
03747     {
03748     case MASTERID:
03749       INFO.print("\n\t*** Input for step M_READFILES (master) ***");
03750       INFO << "M_IN_METHOD: \tmethod selected for master: \t\t"
03751            << readfilesinput.sensor_id;
03752       INFO.print();
03753       INFO << "M_IN_VOL:    \tVolumefile of master: \t\t"
03754            << readfilesinput.volfile;
03755       INFO.print();
03756       INFO << "M_IN_LEA:    \tLeaderfile of master: \t\t"
03757            << readfilesinput.leaderfile;
03758       INFO.print();
03759       INFO << "M_IN_NULL:   \tNullfile of master:  \t\t"
03760            << readfilesinput.nullfile;
03761       INFO.print();
03762       INFO << "M_IN_DAT:    \tDatfile of master:    \t\t"
03763            << readfilesinput.datfile;
03764       INFO.print();
03765       if (readfilesinput.sensor_id == SLC_ERS)
03766         {
03767         if (!specified(readfilesinput.volfile))
03768           {
03769           PRINT_ERROR("M_IN_VOL not defined");
03770           throw(keyword_error);
03771           }
03772         if (!specified(readfilesinput.leaderfile))
03773           {
03774           PRINT_ERROR("M_IN_LEA not defined");
03775           throw(keyword_error);
03776           }
03777         if (!specified(readfilesinput.nullfile))
03778           WARNING.print("M_IN_NULL not defined");
03779         }
03780       // ___ use datfile for asar input file ___
03781       if (!specified(readfilesinput.datfile))
03782         {
03783         PRINT_ERROR("M_IN_DAT not defined");
03784         throw(keyword_error);
03785         }
03786       break;
03787 
03788     case SLAVEID:
03789       INFO.print("\n\t*** Input for step S_READFILES (slave) ***");
03790       INFO << "S_IN_METHOD: \tmethod selected for slave: \t\t"
03791            << readfilesinput.sensor_id;
03792       INFO.print();
03793       INFO << "S_IN_VOL:    \tvolumefile of slave:  \t\t"
03794            << readfilesinput.volfile;
03795       INFO.print();
03796       INFO << "S_IN_LEA:    \tleaderfile of slave:  \t\t"
03797            << readfilesinput.leaderfile;
03798       INFO.print();
03799       INFO << "S_IN_NULL:   \tnullfile of slave:   \t\t"
03800            << readfilesinput.nullfile;
03801       INFO.print();
03802       INFO << "S_IN_DAT:    \tdatfile of slave:     \t\t"
03803            << readfilesinput.datfile;
03804       INFO.print();
03805       if (readfilesinput.sensor_id == SLC_ERS)
03806         {
03807         if (!specified(readfilesinput.volfile))
03808           {
03809           PRINT_ERROR("S_IN_VOL not defined");
03810           throw(keyword_error);
03811           }
03812         if (!specified(readfilesinput.leaderfile))
03813           {
03814           PRINT_ERROR("S_IN_LEA not defined");
03815           throw(keyword_error);
03816           }
03817         if (!specified(readfilesinput.nullfile))
03818           WARNING.print("S_IN_NULL not defined");
03819         }
03820       // ___ use datfile for asar input file ___
03821       if (!specified(readfilesinput.datfile))
03822         {
03823         PRINT_ERROR("S_IN_DAT not defined");
03824         throw(keyword_error);
03825         }
03826       break;
03827 
03828     default:
03829       PRINT_ERROR("panic: impossible");
03830       throw(keyword_error);
03831     } // switch
03832   if (readfilesinput.sensor_id == SLC_ERS)
03833     {
03834     if (!strcmp(readfilesinput.volfile,readfilesinput.leaderfile))
03835       {
03836       PRINT_ERROR("same file name volume and leader file not allowed.");
03837       throw(keyword_error);
03838       }
03839     if (!strcmp(readfilesinput.volfile,readfilesinput.nullfile))
03840       {
03841       PRINT_ERROR("same file name volume and null file not allowed.");
03842       throw(keyword_error);
03843       }
03844     if (!strcmp(readfilesinput.volfile,readfilesinput.datfile))
03845       {
03846       PRINT_ERROR("same file name volume and data file not allowed.");
03847       throw(keyword_error);
03848       }
03849     if (!strcmp(readfilesinput.leaderfile,readfilesinput.nullfile))
03850       {
03851       PRINT_ERROR("same file name leader and null file not allowed.");
03852       throw(keyword_error);
03853       }
03854     if (!strcmp(readfilesinput.leaderfile,readfilesinput.datfile))
03855       {
03856       PRINT_ERROR("same file name leader and data file not allowed.");
03857       throw(keyword_error);
03858       }
03859     if (!strcmp(readfilesinput.nullfile,readfilesinput.datfile))
03860       {
03861       PRINT_ERROR("same file name null and data file not allowed.");
03862       throw(keyword_error);
03863       }
03864     }
03865   } // END checkreadfiles
03866 
03867 
03868 /****************************************************************
03869  *    checkcrop                                                 *
03870  *                                                              *
03871  * Checks cards for step crop.                          *
03872  *                                                              *
03873  *    Bert Kampes, 06-Sep-1999                                  *
03874  ****************************************************************/
03875 void checkcrop(
03876         const input_crop &cropinput,
03877         const int16 id)
03878   {
03879   TRACE_FUNCTION("checkcrop (BK 06-Sep-1999)")
03880   switch (id)
03881     {
03882     case MASTERID:
03883       INFO.print("\n\t*** Input for step M_CROP (master) ***");
03884       INFO << "M_IDCROP: \tidentifier master write slc data to raster format: \t"
03885            << cropinput.idcrop;
03886       INFO.print();
03887       INFO << "M_CROP_IN: \tslc data inputfile for master:   \t"
03888            << cropinput.filein1;
03889       INFO.print();
03890       INFO << "M_CROP_OUT: \traw data outputfile for master: \t"
03891            << cropinput.fileout1;
03892       INFO.print();
03893       INFO << "M_DBOW: \tProcessing master line "
03894            << cropinput.dbow.linelo << " to "
03895            << cropinput.dbow.linehi << ". pixel "
03896            << cropinput.dbow.pixlo << " to "
03897            << cropinput.dbow.pixhi << ".";
03898       INFO.print();
03899       if (cropinput.dbow_geo.pixhi != 0) 
03900         {
03901         INFO.print("M_DBOW_GEO: overrides M_DBOW! processing: ");
03902         INFO << "center latitude " << cropinput.dbow_geo.linelo/1e6-360.0 <<
03903                 "; center longitude " << cropinput.dbow_geo.linehi/1e6-360.0 <<
03904                 "; height, width: " << cropinput.dbow_geo.pixlo << ", " << 
03905                 cropinput.dbow_geo.pixhi;
03906         INFO.print();
03907         }
03908       break;
03909 
03910     case SLAVEID:
03911       INFO.print("\n\t*** Input for step S_CROP (slave) ***");
03912       INFO << "S_IDCROP: \tidentifier slave write slc data to raster format: \t"
03913            << cropinput.idcrop;
03914       INFO.print();
03915       INFO << "S_CROP_IN: \tslc data inputfile for slave:   \t"
03916            << cropinput.filein1;
03917       INFO.print();
03918       INFO << "S_CROP_OUT: \traw data outputfile for slave: \t"
03919            << cropinput.fileout1;
03920       INFO.print();
03921       INFO << "S_DBOW: \tProcessing slave line "
03922            << cropinput.dbow.linelo << " to "
03923            << cropinput.dbow.linehi << ". pixel "
03924            << cropinput.dbow.pixlo << " to "
03925            << cropinput.dbow.pixhi << ".";
03926       INFO.print();
03927       if (cropinput.dbow_geo.pixhi != 0) 
03928         {
03929         INFO.print("S_DBOW_GEO: overrides S_DBOW! processing: ");
03930         INFO << "center latitude " << cropinput.dbow_geo.linelo/1e6-360.0 <<
03931                 "; center longitude " << cropinput.dbow_geo.linehi/1e6-360.0 <<
03932                 "; height, width: " << cropinput.dbow_geo.pixlo << ", " << 
03933                 cropinput.dbow_geo.pixhi;
03934         INFO.print();
03935         }
03936       break;
03937 
03938     default:
03939       PRINT_ERROR("panic: impossible");
03940       throw(keyword_error);
03941     }
03942   } // END checkcrop
03943 
03944 
03945 //____RaffaeleNutricato START MODIFICATION SECTION 11
03946 /****************************************************************
03947  *    checkoversample                                           *
03948  *                                                              *
03949  * Checks cards for step oversample.                            *
03950  *                                                              *
03951  *    Raffaele Nutricato, 12-Jan-2004                           *
03952  ****************************************************************/
03953 void checkoversample(
03954         const input_oversample  &oversampleinput,
03955         const int16 id)
03956   {
03957   TRACE_FUNCTION("checkoversample (Raffaele Nutricato 12-Jan-2004)")
03958   switch (id)
03959     {
03960     case MASTERID:
03961       INFO.print("\n\t*** Input for step M_OVS (master) ***");
03962       INFO << "M_OVS_OUT: \t\tData output file for ovs master: "
03963            << oversampleinput.fileoutovs; // Output file for the oversampled master
03964       INFO.print(); 
03965       INFO << "M_OVS_FACT_RNG: \tOversampling ratio in the master range direction: "   
03966            << oversampleinput.OsrRange;  // Oversampling ratio in the range direction.
03967       INFO.print(); 
03968       INFO << "M_OVS_FACT_AZI: \tOversampling ratio in the master azimuth direction: "   
03969            << oversampleinput.OsrAzimuth;  // Oversampling ratio in the azimuth direction.
03970       INFO.print(); 
03971       INFO << "M_OVS_KERNELSIZE: \tKernel length for the master oversampling: "   
03972            << oversampleinput.FilterSize;  // Length of the interpolation kernel in range. 
03973       INFO.print(); 
03974       INFO << "M_OVS_OUT_FORMAT: \tOutput data format for the oversampled master: " ;  
03975       if (oversampleinput.oformatflag==FORMATCR4)
03976         INFO << "complex_real4";
03977       if (oversampleinput.oformatflag==FORMATCI2)
03978         INFO << "complex_short";
03979       INFO.print();
03980       break;
03981 
03982     case SLAVEID:
03983       INFO.print("\n\t*** Input for step S_OVS (slave) ***");
03984       INFO << "S_OVS_OUT: \t\tData output file for ovs slave: "
03985            << oversampleinput.fileoutovs; // Output file for the oversampled slave
03986       INFO.print();
03987       INFO << "S_OVS_FACT_RNG: \tOversampling ratio in the slave range direction: "   
03988            << oversampleinput.OsrRange;  // Oversampling ratio in the range direction.
03989       INFO.print(); 
03990       INFO << "S_OVS_FACT_AZI: \tOversampling ratio in the slave azimuth direction: "   
03991            << oversampleinput.OsrAzimuth;  // Oversampling ratio in the azimuth direction.
03992       INFO.print(); 
03993       INFO << "S_OVS_KERNELSIZE: \tKernel length for the slave oversampling: "   
03994            << oversampleinput.FilterSize;  // Length of the interpolation kernel in range. 
03995       INFO.print(); 
03996       INFO << "S_OVS_OUT_FORMAT: \tOutput data format for the oversampled slave: " ;  
03997       if (oversampleinput.oformatflag==FORMATCR4)
03998         INFO << "complex_real4";
03999       if (oversampleinput.oformatflag==FORMATCI2)
04000         INFO << "complex_short";
04001       INFO.print();
04002       break;
04003 
04004     default:
04005       PRINT_ERROR("panic: impossible");
04006       throw(keyword_error);
04007     }
04008   } // END checkoversample
04009 
04010 //____RaffaeleNutricato END MODIFICATION SECTION 11
04011 
04012 
04013 /****************************************************************
04014  *    checkporbits                                              *
04015  *                                                              *
04016  * Checks cards for step porbits.                               *
04017  *                                                              *
04018  *    Bert Kampes, 06-Sep-1999                                  *
04019  ****************************************************************/
04020 void checkporbits(
04021         const input_pr_orbits &porbitsinput,
04022         const int16 id)
04023   {
04024   TRACE_FUNCTION("checkporbits (BK 06-Sep-1999)")
04025   switch (id)
04026     {
04027     case MASTERID:
04028       INFO.print("\n\t*** Input for step M_PORBITS (master) ***");
04029       INFO << "M_ORBDIR: \tPrecise orbits master in: "
04030            << porbitsinput.m_orbdir;
04031       INFO.print();
04032       if (!specified(porbitsinput.m_orbdir))
04033         {
04034         PRINT_ERROR("M_ORBDIR: no directory specified.");
04035         throw(keyword_error);
04036         }
04037       break;
04038 
04039     case SLAVEID:
04040       INFO.print("\n\t*** Input for step S_PORBITS (slave) ***");
04041       INFO << "S_ORBDIR: \tPrecise orbits slave in: "
04042            << porbitsinput.s_orbdir;
04043       INFO.print();
04044       if (!specified(porbitsinput.s_orbdir))
04045         {
04046         PRINT_ERROR("S_ORBDIR: no directory specified.");
04047         throw(keyword_error);
04048         }
04049       break;
04050 
04051     default:
04052       PRINT_ERROR("panic: impossible");
04053       throw(keyword_error);
04054     }
04055   INFO << "ORB_INTERVAL: \ttime between ephemerides: \t"
04056        << porbitsinput.timeinterval;
04057   INFO.print();
04058   INFO << "ORB_EXTRATIME: \ttime before first, after last line: \t"
04059        << porbitsinput.timebefore;
04060   INFO.print();
04061   if (!porbitsinput.dumpmasterorbit<0)
04062     INFO.print("dumping masterorbit to file.");
04063   if (!porbitsinput.dumpslaveorbit<0)
04064     INFO.print("dumping slaveorbit to file.");
04065   } // END checkporbits
04066 
04067 
04068 /****************************************************************
04069  *    checkslant2h                                              *
04070  *                                                              *
04071  * Checks cards for step slant2h.                               *
04072  *                                                              *
04073  *    Bert Kampes, 29-Sep-1999                                  *
04074  ****************************************************************/
04075 void checkslant2h(
04076         const input_slant2h &slant2hinput)
04077   {
04078   TRACE_FUNCTION("checkslant2h (BK 29-Sep-1999)")
04079   INFO.print("\n\t*** Input for step SLANT2H ***");
04080   switch (slant2hinput.method)
04081     {
04082     case s2h_schwabisch:
04083       INFO.print("Method schwabisch is used for slant2height conversion.");
04084 
04085       INFO << "S2H_NPOINTS: \tNumber of points used in computation:   "
04086            << slant2hinput.Npoints;
04087       INFO.print();
04088       INFO << "S2H_DEGREE1D: \tDegree of 1d polynomial at each point: "
04089            << slant2hinput.degree1d;
04090       INFO.print();
04091       INFO << "S2H_DEGREE2D: \tDegree of 2d polynomial to compute     "
04092            << "coefficients of 1D polynomial: "
04093            << slant2hinput.degree2d;
04094       INFO.print();
04095       INFO << "S2H_NHEIGHTS: \t#heights evaluation ref. phase for 1d polynomial: "
04096            << slant2hinput.Nheights;
04097       INFO.print();
04098       break;
04099 
04100     case s2h_ambiguity:
04101       INFO.print("Method exact is used for slant2height conversion.");
04102       INFO << "S2H_OUT_LAM: \tData output file for lambda: "
04103            << slant2hinput.folam;
04104       INFO.print();
04105       INFO << "S2H_OUT_PHI: \tData output file for phi:    "
04106            << slant2hinput.fophi;
04107       INFO.print();
04108       if (!strcmp(slant2hinput.folam,slant2hinput.fophi))
04109         {
04110         PRINT_ERROR("Same filename S2H_OUT_LAM and S2H_OUT_PHI not allowed.");
04111         throw(keyword_error);
04112         }
04113       if (!strcmp(slant2hinput.fohei,slant2hinput.fophi))
04114         {
04115         PRINT_ERROR("Same filename S2H_OUT_HEI and S2H_OUT_PHI not allowed.");
04116         throw(keyword_error);
04117         }
04118       if (!strcmp(slant2hinput.folam,slant2hinput.fohei))
04119         {
04120         PRINT_ERROR("Same filename S2H_OUT_LAM and S2H_OUT_HEI not allowed.");
04121         throw(keyword_error);
04122         }
04123       break;
04124 
04125     case s2h_rodriguez:
04126       DEBUG.print("do some checks here as well.");
04127       break;
04128 
04129     default:
04130       PRINT_ERROR("impossible, unknown method s2h");
04131       throw(keyword_error);
04132     }
04133 
04134     INFO << "S2H_OUT_HEI: Data output file for height:   "
04135          << slant2hinput.fohei;
04136     INFO.print();
04137   } // END checkslant2h
04138 
04139 
04140 /****************************************************************
04141  *    checkunwrap                                               *
04142  *                                                              *
04143  * Checks cards for step unwrap.                                *
04144  *                                                              *
04145  *    Bert Kampes, 29-Sep-1999                                  *
04146  ****************************************************************/
04147 void checkunwrap(
04148         const input_unwrap &unwrapinput)
04149   {
04150   TRACE_FUNCTION("checkunwrap (BK 29-Sep-1999)")
04151   INFO.print("\n\t*** Input for step UNWRAP ***");
04152   INFO << "UW_OUT_FILE: \tOutput data file for unwrapped interferogram: "
04153        << unwrapinput.fouint;
04154   INFO.print();
04155   INFO << "UW_OUT_FORMAT: \tOutput data format for unwrapped interferogram: "
04156        << unwrapinput.oformatflag;
04157   INFO.print();
04158   switch (unwrapinput.method)
04159     {
04160     case uw_method1:
04161       INFO.print("Method 1 is used for unwrapping (treef_ramon unix calls).");
04162       INFO << "UW_SEEDS: ";
04163       if (isspace(unwrapinput.seedfile[0]))     // no file specified
04164         INFO << "Delta seed in line/pixel direction: "
04165              << unwrapinput.deltaLseed << " " << unwrapinput.deltaPseed;
04166       else
04167         INFO << " Input file with seeds for unwrapping: "
04168              << unwrapinput.seedfile;
04169       INFO.print();
04170       INFO << "UW_OUT_REGIONS: \tOutput data file with region numbers: "
04171            << unwrapinput.foregions;
04172       INFO.print();
04173       break;
04174 
04175     case uw_method2:
04176       INFO.print("Method 2: SNAPHU is used for unwrapping.");
04177       INFO.print("Please make sure snaphu is installed.  check results carefuly.");
04178       INFO << "UW_SNAPHU_LOG: \tOutput log file of snaphu: "
04179            << unwrapinput.snaphu_log;
04180       INFO.print();
04181       INFO << "UW_SNAPHU_INIT: \tinitialization method of snaphu: "
04182            << unwrapinput.snaphu_init;
04183       INFO.print();
04184       INFO << "UW_SNAPHU_COH: \tinput coherence file for snaphu: "
04185            << unwrapinput.snaphu_coh;
04186       INFO.print();
04187       INFO << "UW_SNAPHU_MODE: \tsnaphu mode: "
04188            << unwrapinput.snaphu_mode;
04189       INFO.print();
04190       break;
04191 
04192     case uw_method3:
04193       INFO.print("Method 3 is used for unwrapping (???).");
04194       PRINT_ERROR("only for delft, standalone application.");
04195       throw(keyword_error);
04196       break;
04197 
04198     default:
04199       PRINT_ERROR("probably forgot to update this, should not be possible.");
04200       throw(keyword_error);
04201     }
04202   } // END checkunwrap
04203 
04204 
04205 /****************************************************************
04206  *    checkgeocode                                              *
04207  *                                                              *
04208  * Checks cards for step geocode.                               *
04209  *                                                              *
04210  *    Bert Kampes, 29-Sep-1999                                  *
04211  ****************************************************************/
04212 void checkgeocode(
04213         const input_geocode &geocodeinput)
04214   {
04215   TRACE_FUNCTION("checkgeocode (BK 29-Sep-1999)")
04216   INFO.print("\n\t*** Input for step GEOCODE ***");
04217   INFO << "GEO_OUT_PHI: \tOutput file for latitude: \t"
04218        << geocodeinput.fophi;
04219   INFO.print();
04220   INFO << "GEO_OUT_PHI: \tOutput file for longitude: \t"
04221        << geocodeinput.folam;
04222   INFO.print();
04223   if (!strcmp(geocodeinput.fophi,geocodeinput.folam))
04224     {
04225     ERROR << "Same file name GEO_OUT_PHI and GEO_OUT_LAM not allowed.";
04226     PRINT_ERROR(ERROR.get_str())
04227     throw(keyword_error);
04228     }
04229   } // END checkgeocode
04230 
04231 
04232 
04233 /****************************************************************
04234  *    checkcoarsecorr                                           *
04235  *                                                              *
04236  * Checks cards for step coarsecorr.                            *
04237  *                                                              *
04238  *    Bert Kampes, 29-Sep-1999                                  *
04239  ****************************************************************/
04240 void checkcoarsecorr(
04241         const input_coarsecorr &coarsecorrinput)
04242   {
04243   TRACE_FUNCTION("checkcoarsecorr (BK 29-Sep-1999)")
04244   INFO.print("\n\t*** Input for step COARSE_CORR ***");
04245   switch (coarsecorrinput.method)
04246     {
04247     case cc_magfft:
04248       INFO.print("CC_METHOD: \tMAGFFT is used for coarse correlation."); break;
04249     case cc_magspace:
04250       INFO.print("CC_METHOD: \tMAGSPACE is used for coarse correlation."); break;
04251     default:
04252       PRINT_ERROR("panic.");
04253       throw(keyword_error);
04254     }
04255   if (specified(coarsecorrinput.ifpositions))
04256     {
04257     INFO << "CC_IN_POS: \tFile: " <<  coarsecorrinput.ifpositions 
04258          << " containing " << coarsecorrinput.Nwin
04259          << " positions is used.";
04260     INFO.print();
04261     }
04262   else                                          // no input file
04263     {
04264     INFO << "CC_NWIN: \tDistributing "
04265          <<  coarsecorrinput.Nwin 
04266          << " windows for coarse coregistration based on correlation.";
04267     INFO.print();
04268     }
04269   } // END checkcoarsecorr
04270 
04271 
04272 /****************************************************************
04273  *    checkfine                                                 *
04274  *                                                              *
04275  * Checks cards for step fine.                                  *
04276  *                                                              *
04277  *    Bert Kampes, 29-Sep-1999                                  *
04278  ****************************************************************/
04279 void checkfine(
04280         const input_fine &fineinput)
04281   {
04282   TRACE_FUNCTION("checkfine (BK 29-Sep-1999)")
04283   INFO.print("\n\t*** Input for step FINE ***");
04284   switch (fineinput.method)
04285     {
04286 //    case fc_cmplxfft:
04287 //      INFO.print("FC_METHOD: \tCMPLXFFT is used for fine correlation.");
04288 //      break;
04289 //    case fc_cmplxspace:
04290 //      INFO.print("FC_METHOD: \tCMPLXSPACE is used for fine correlation.");
04291 //      break;
04292     case fc_magfft:
04293       INFO.print("FC_METHOD: \tMAGFFT is used for fine correlation.");
04294       break;
04295     case fc_magspace:
04296       INFO.print("FC_METHOD: \tMAGSPACE is used for fine correlation.");
04297       break;
04298     case fc_oversample:
04299       INFO.print("FC_METHOD: \tOVERSAMPLE is used for fine correlation.");
04300       break;
04301     default:
04302       PRINT_ERROR("panic.");
04303       throw(keyword_error);
04304     }
04305 
04306   if (specified(fineinput.ifpositions))
04307     {
04308     INFO << "FC_IN_POS: File: "
04309          <<  fineinput.ifpositions 
04310          << " containing "
04311          << fineinput.Nwin << " positions is used.";
04312     INFO.print();
04313     }
04314   else                                          // no input file
04315     {
04316     INFO << "FC_NWIN: \tDistributing "
04317          <<  fineinput.Nwin 
04318          << " windows for fine coregistration.";
04319     INFO.print();
04320     }
04321   if (fineinput.plotoffsets)
04322     {
04323     INFO << "FC_PLOT " << fineinput.plotthreshold 
04324          << ": Plotting estimated offsets with correlation larger than "
04325          << fineinput.plotthreshold;
04326     INFO.print();
04327     }
04328   else
04329     {
04330     WARNING.print("It is highly recommended to use FC_PLOT to plot the computed FINE offset vectors.");
04331     }
04332   if (fineinput.plotmagbg)
04333     INFO.print("FC_PLOT: magnitude will be in background of plot.");
04334 
04335   INFO << "FC_WINSIZE: (l,p) = ("
04336        <<  fineinput.MasksizeL << ", "
04337        <<  fineinput.MasksizeP << ").";
04338   INFO.print();
04339   INFO << "FC_OSFACTOR: "
04340        <<  fineinput.osfactor
04341        <<  ". Oversampling factor for fine coregistration.";
04342   INFO.print();
04343   if (!ispower2(fineinput.osfactor))
04344     {
04345     ERROR << " no power of 2.";
04346     PRINT_ERROR(ERROR.get_str())
04347     throw(keyword_error);
04348     }
04349   } // END checkfine
04350 
04351 
04352 /****************************************************************
04353  *    checkcoregpm                                              *
04354  *                                                              *
04355  * Checks cards for step coregpm.                               *
04356  *                                                              *
04357  *    Bert Kampes, 29-Sep-1999                                  *
04358  ****************************************************************/
04359 void checkcoregpm(
04360         const input_coregpm &coregpminput)
04361   {
04362   TRACE_FUNCTION("checkcoregpm (BK 29-Sep-1999)")
04363   INFO.print("\n\t*** Input for step COREGPM ***");
04364   INFO << "CPM_THRESHOLD: \tThreshold correlation for model: \t"
04365        <<  coregpminput.threshold;
04366   INFO.print();
04367   INFO << "CPM_DEGREE: \tPolynomial for coregistration: \t"
04368        <<  coregpminput.degree;
04369   INFO.print();
04370   INFO << "CPM_WEIGHT: \tData weighting option: \t"
04371        <<  coregpminput.weightflag
04372        << " (0 none, 1 linear, 2 quadratic) is used in least squares.";
04373   INFO.print();
04374   INFO << "CPM_MAXITER: \tNumber of points to remove (max): \t"
04375        <<  coregpminput.maxiter;
04376   INFO.print();
04377   INFO << "CPM_K_ALPHA: \tCritical value for outlier test: \t"
04378        <<  coregpminput.k_alpha;
04379   INFO.print();
04380   if (coregpminput.dumpmodel)
04381     INFO.print("CPM_DUMP: dumping model to files (see INFO).");
04382   if (coregpminput.plot)
04383     INFO.print("CPM_PLOT: error vectors etc. will be plotted.");
04384   else
04385     WARNING.print("It is higly recommended to use CPM_PLOT to review the estimated model.");
04386   if (coregpminput.plotmagbg)
04387     INFO.print("CPM_PLOT: magnitude will be in background.");
04388   } // END checkcoregpm
04389 
04390 
04391 /****************************************************************
04392  *    checkcomprefpha                                           *
04393  *                                                              *
04394  * Checks cards for step comprefpha.                            *
04395  *                                                              *
04396  *    Bert Kampes, 29-Sep-1999                                  *
04397  ****************************************************************/
04398 void checkcomprefpha(
04399         const input_comprefpha &comprefphainput)
04400   {
04401   TRACE_FUNCTION("checkcomprefpha (BK 29-Sep-1999)")
04402   INFO.print("\n\t*** Input for step COMPREFPHA ***");
04403   switch (comprefphainput.method)
04404     {
04405     case fe_porbits:
04406       INFO.print("FE_METHOD: method for flatearth correction: PORBITS");
04407       // ______ Check points from file or random distributed ______
04408       if (specified(comprefphainput.ifpositions))
04409         {
04410         INFO << "FE_IN_POS: file: "
04411              <<  comprefphainput.ifpositions 
04412              << " containing "
04413              << comprefphainput.Npoints << " positions used for ref. phase estimation.";
04414         INFO.print();
04415         }
04416       else                                              // no input file
04417         {
04418         INFO << "FE_NPOINTS: Using " << comprefphainput.Npoints
04419              << " (random like) distributed points for estimation of refpha polynomial.";
04420         INFO.print();
04421         }
04422       if (comprefphainput.Npoints > 5000)
04423         WARNING.print("FE_NPOINTS: Too many points requested?");
04424       INFO << "FE_DEGREE: Using " << comprefphainput.degree
04425            << " order polynomial for flat Earth correction.";
04426       INFO.print();
04427       if (comprefphainput.degree > 10)
04428         WARNING.print("FE_DEGREE: degree > 10?");
04429       break;
04430     case fe_method2:
04431       INFO.print("FE_METHOD: method for flatearth correction: method2 :NOT IMPLEMENTED");
04432       break;
04433     default:
04434       PRINT_ERROR("impossible, method name is checked while reading cards.");
04435       throw(keyword_error);
04436     }
04437   } // END checkcomprefpha
04438 
04439 
04440 /****************************************************************
04441  *    checksubtrrefpha                                          *
04442  *                                                              *
04443  * Checks cards for step subtrrefpha.                           *
04444  *                                                              *
04445  *    Bert Kampes, 09-Feb-2000                                  *
04446  ****************************************************************/
04447 void checksubtrrefpha(
04448         const input_subtrrefpha &subtrrefphainput)
04449   {
04450   TRACE_FUNCTION("checksubtrrefpha (BK 09-Feb-2000)")
04451   INFO.print("\n\t*** Input for step SUBTRREFPHA ***");
04452   // ______ Print info ______
04453   switch (subtrrefphainput.method)
04454     {
04455     case srp_polynomial:
04456       INFO.print("SRP_METHOD: \tpolynomial: \tPolynomial from COMPREFPHA used.");
04457       break;
04458     case srp_exact:
04459       INFO.print("SRP_METHOD: \texact:      \treference phase computed foreach pixel.");
04460       break;
04461     default:
04462       PRINT_ERROR("impossible, checked above.");
04463       throw(keyword_error);
04464     }
04465   if (subtrrefphainput.dumponlyrefpha==false)
04466     {
04467     INFO << "SRP_OUT_CINT: \toutputfile complex interferogram: \t"
04468        << subtrrefphainput.focint;
04469     INFO.print();
04470     }
04471   INFO << "SRP_MULTILOOK: \tFactors (line pixel): \t" 
04472        << subtrrefphainput.multilookL << " "
04473        << subtrrefphainput.multilookP;
04474   INFO.print();
04475   if (subtrrefphainput.dumponlyrefpha==true)
04476     {
04477     WARNING.print("SRP_DUMPREFPHA: Only dumping reference phase, no subtraction.");
04478     INFO << "SRP_DUMPREFPHA: only dump refphase: "
04479          << subtrrefphainput.dumponlyrefpha;
04480     INFO.print();
04481     INFO << "SRP_OUT_REFPHA: Output file reference phase: "
04482          << subtrrefphainput.forefpha;
04483     INFO.print();
04484     }
04485 
04486   // ______ Check ______
04487   if (subtrrefphainput.multilookL > 100 || subtrrefphainput.multilookP > 100 ||
04488       subtrrefphainput.multilookL < 1   || subtrrefphainput.multilookP < 1 )
04489     WARNING.print("SRP_MULTILOOK: multilookfactor seems very high.");
04490   } // END checksubtrrefpha
04491 
04492 
04493 /****************************************************************
04494  *    checkresample                                             *
04495  *                                                              *
04496  * Checks cards for step resample.                              *
04497  *                                                              *
04498  *    Bert Kampes, 29-Sep-1999                                  *
04499  ****************************************************************/
04500 void checkresample(
04501         const input_resample &resampleinput)
04502   {
04503   TRACE_FUNCTION("checkresample (BK 29-Sep-1999)")
04504   INFO.print("\n\t*** Input for step RESAMPLE ***");
04505   INFO << "RS_OUT_FILE: \toutput filename: \t\t" 
04506        << resampleinput.fileout;
04507   INFO.print();
04508   INFO << "RS_OUT_FORMAT: output format: \t\t";
04509   switch (resampleinput.oformatflag)
04510     {
04511     case FORMATCR4:
04512       INFO << "complex_real4.";
04513       break;
04514     case FORMATCI2:
04515       INFO << "complex_short.";
04516       break;
04517     default:
04518       PRINT_ERROR("totally impossible, checked input.");
04519       throw(keyword_error);
04520     }
04521   INFO.print();
04522   if (resampleinput.dbow.linehi != 0 || resampleinput.dbow.pixhi != 0)
04523     {
04524     INFO << "RS_DBOW: \tOutput window: \t\t\t" 
04525          << resampleinput.dbow.linelo << " " 
04526          << resampleinput.dbow.linehi << " " 
04527          << resampleinput.dbow.pixlo  << " " 
04528          << resampleinput.dbow.pixhi ;
04529     INFO.print();
04530     }
04531   INFO << "RS_SHIFTAZI: \tshift azimuth spectrum: \t" 
04532        << resampleinput.shiftazi ;
04533   INFO.print();
04534   } // END checkresample
04535 
04536 
04537 /****************************************************************
04538  *    checkinterfero                                            *
04539  *                                                              *
04540  * Checks cards for step interfero.                             *
04541  *                                                              *
04542  *    Bert Kampes, 29-Sep-1999                                  *
04543  ****************************************************************/
04544 void checkinterfero(
04545         const input_interfero &interferoinput)
04546   {
04547   TRACE_FUNCTION("checkinterfero (BK 29-Sep-1999)")
04548   INFO.print("\n\t*** Input for step INTERFERO ***");
04549   bool filespecified = false;
04550   bool samefilename  = false;
04551   if (specified(interferoinput.foint))
04552     {
04553     filespecified = true;
04554     INFO << "INT_OUT_INT: \tOutputfile interferogram: \t"
04555          <<  interferoinput.foint;
04556     INFO.print();
04557     if (!(strcmp(interferoinput.foint,interferoinput.focint)))
04558       samefilename = true;
04559     }
04560   if (specified(interferoinput.focint))
04561     {
04562     filespecified = true;
04563     INFO << "INT_OUT_CINT: Outfile complex interferogram: \t"
04564          <<  interferoinput.focint;
04565     INFO.print();
04566     if (!(strcmp(interferoinput.focint,interferoinput.foint)))
04567       samefilename = true;
04568     }
04569 //  if (strcmp(interferoinput.foflatearth," "))         // something is specified
04570 //    {
04571 //    filespecified = true;
04572 //    INFO << "INT_OUT_FE: data outputfile reference phase: \t"
04573 //         <<  interferoinput.foflatearth;
04574 //    INFO.print();
04575 //    if (!(strcmp(interferoinput.foflatearth,interferoinput.foint))  ||
04576 //        !(strcmp(interferoinput.foflatearth,interferoinput.focint)))
04577 //      samefilename = true;
04578 //    }
04579 
04580   INFO << "INT_MULTILOOK: \tFactor (line pixel): \t"
04581        <<  interferoinput.multilookL << " " 
04582        << interferoinput.multilookP;
04583   INFO.print();
04584 
04585   if (interferoinput.multilookL > 100 || interferoinput.multilookP > 100)
04586     {
04587     PRINT_ERROR("code ???: INT_MULTILOOK: > 100.");
04588     throw(keyword_error);
04589     }
04590   if (interferoinput.multilookL < 1 || interferoinput.multilookP < 1)
04591     {
04592     PRINT_ERROR("code ???: INT_MULTILOOK: < 1.");
04593     throw(keyword_error);
04594     }
04595 
04596   if (!filespecified)
04597     {
04598     PRINT_ERROR("code ???: INT_OUT_*: at least one output file must be specified.");
04599     throw(keyword_error);
04600     }
04601   if (samefilename)
04602     {
04603     PRINT_ERROR("code ???: INT_OUT_*: same name output files.");
04604     throw(keyword_error);
04605     }
04606   } // END checkinterfero
04607 
04608 
04609 /****************************************************************
04610  *    checkcoherence                                            *
04611  *                                                              *
04612  * Checks cards for step coherence.                             *
04613  *                                                              *
04614  *    Bert Kampes, 29-Sep-1999                                  *
04615  ****************************************************************/
04616 void checkcoherence(
04617         const input_coherence &coherenceinput)
04618   {
04619   TRACE_FUNCTION("checkcoherence (BK 29-Sep-1999)")
04620   INFO.print("\n\t*** Input for step COHERENCE ***");
04621   bool filespecified = false;
04622   bool samefilename  = false;
04623   if (specified(coherenceinput.foccoh))
04624     {
04625     filespecified = true;
04626     INFO << "COH_OUT_CCOH: \tOutfile complex coherence: \t"
04627          <<  coherenceinput.foccoh;
04628     INFO.print();
04629     if (!(strcmp(coherenceinput.foccoh,coherenceinput.focoh)))
04630       samefilename = true;
04631     }
04632 
04633   if (specified(coherenceinput.focoh))
04634     {
04635     filespecified = true;
04636     INFO << "COH_OUT_COH: \tOutputfile coherence image: "
04637          <<  coherenceinput.focoh;
04638     INFO.print();
04639     if (!(strcmp(coherenceinput.focoh,coherenceinput.foccoh)))
04640       samefilename = true;
04641     }
04642 
04643   INFO << "COH_MULTILOOK: \tFactor (line pixel): \t"
04644        <<  coherenceinput.multilookL << " "
04645        << coherenceinput.multilookP;
04646   INFO.print();
04647   INFO << "COH_WINSIZE: \t window size coh. estimation (l/p): \t"
04648        <<  coherenceinput.cohsizeL << " " << coherenceinput.cohsizeP;
04649   INFO.print();
04650 
04651   if (coherenceinput.multilookL > 100 || coherenceinput.multilookP > 100)
04652     {
04653     PRINT_ERROR("code ???: COH_MULTILOOK: > 100.");
04654     throw(keyword_error);
04655     }
04656   if (coherenceinput.multilookL < 1 || coherenceinput.multilookP < 1)
04657     {
04658     PRINT_ERROR("code ???: COH_MULTILOOK: < 1.");
04659     throw(keyword_error);
04660     }
04661   if (coherenceinput.cohsizeL > 500 || coherenceinput.cohsizeP > 500)
04662     {
04663     PRINT_ERROR("code ???: COH_WINSIZE: > 500.");
04664     throw(keyword_error);
04665     }
04666   if (coherenceinput.cohsizeL < 1 || coherenceinput.cohsizeP < 1)
04667     {
04668     PRINT_ERROR("code ???: COH_WINSIZE: < 1.");
04669     throw(keyword_error);
04670     }
04671 
04672   if (!filespecified)
04673     {
04674     PRINT_ERROR("code ???: COH_OUT_*: at least one output file must be specified.");
04675     throw(keyword_error);
04676     }
04677   if (samefilename)
04678     {
04679     PRINT_ERROR("code ???: COH_OUT_*: same name output files.");
04680     throw(keyword_error);
04681     }
04682   } // END checkcoherence
04683 
04684 
04685 
04686 /****************************************************************
04687  *    checkcomprefdem                                           *
04688  *                                                              *
04689  * Checks cards for step comprefdem.                            *
04690  *                                                              *
04691  *    Bert Kampes, 14-Feb-2000                                  *
04692  ****************************************************************/
04693 void checkcomprefdem(
04694         const input_comprefdem &comprefdeminput)
04695   {
04696   TRACE_FUNCTION("checkcomprefdem (BK 14-Feb-2000)")
04697   INFO.print("\n\t*** Input for step COMPREFDEM ***");
04698   switch (comprefdeminput.method)
04699     {
04700     case crd_nearest:
04701       INFO.print("NEAREST_NEIGHBOR, use DENSE=2 or so.");
04702       break;
04703     case crd_trilinear:
04704       INFO.print("TRI_LINEAR; use DENSE=0.2 for speed.");
04705       break;
04706     default:
04707       PRINT_ERROR("totally impossible, checked input.");
04708       throw(keyword_error);
04709     }
04710   INFO << "CRD_IN_DEM:    \t" << comprefdeminput.firefdem;
04711   INFO.print();
04712   INFO << "CRD_OUT_FILE:  \t" << comprefdeminput.forefdem;
04713   INFO.print();
04714   if (specified(comprefdeminput.forefdemhei))
04715     {
04716     INFO << "CRD_OUT_DEM_LP: \t" << comprefdeminput.forefdemhei
04717        << "; output requested of DEM [m] in radar coordinates.";
04718     INFO.print();
04719     if (!strcmp(comprefdeminput.forefdem,comprefdeminput.forefdemhei))
04720       {
04721       PRINT_ERROR("CRD_OUT_FILE, CRD_OUT_DEM_LP: Same output file name.");
04722       throw(keyword_error);
04723       }
04724     }
04725   if (specified(comprefdeminput.fodem))
04726     {
04727     INFO << "CRD_OUT_DEM:   \t" << comprefdeminput.fodem
04728        << "; output requested of input DEM.";
04729     INFO.print();
04730     if (!strcmp(comprefdeminput.fodemi,comprefdeminput.fodem))
04731       {
04732       PRINT_ERROR("OUT_DEM, OUT_DEMI: Same output file name.");
04733       throw(keyword_error);
04734       }
04735     }
04736   if (specified(comprefdeminput.fodemi))
04737     {
04738     INFO << "CRD_OUT_DEMI:   \t" << comprefdeminput.fodemi
04739          << "; output requested of interpolated DEM.";
04740     INFO.print();
04741     if (!strcmp(comprefdeminput.fodemi,comprefdeminput.fodem))
04742       {
04743       PRINT_ERROR("OUT_DEM, OUT_DEMI: Same output file name.");
04744       throw(keyword_error);
04745       }
04746     }
04747   INFO << "CRD_IN_SIZE:   \t" << comprefdeminput.demrows
04748        << " " << comprefdeminput.demcols
04749        << "; number of rows (latitude), columns (lon) in DEM.";
04750   INFO.print();
04751   INFO << "CRD_IN_UL:     \t" 
04752        << rad2deg(comprefdeminput.demlatleftupper) << " "
04753        << rad2deg(comprefdeminput.demlonleftupper)
04754        << "; coordinates of upper left corner (first row/col).";
04755   INFO.print();
04756   INFO << "CRD_IN_DELTA:  \t"
04757        << rad2deg(comprefdeminput.demdeltalat) << " "
04758        << rad2deg(comprefdeminput.demdeltalon);
04759   INFO.print();
04760   INFO << "CRD_IN_NODATA:  \t" << comprefdeminput.demnodata
04761        << "; this number in DEM will be set to 0 reference phase.";
04762   INFO.print();
04763   INFO << "CRD_DENSE:      \t" << comprefdeminput.extradense
04764        << "; this is the factor for oversampling DEM more than minimum.";
04765   INFO.print();
04766   if (comprefdeminput.includerefpha)
04767     INFO << "CRD_INCLUDE_FE: \tref. dem is computed including flat earth.";
04768   else
04769     INFO << "CRD_INCLUDE_FE: \tref. dem is computed w.r.t. ellipsoid (topo only).";
04770   INFO.print();
04771 
04772   INFO << "CRD_IN_FORMAT: \tinput format DEM: \t";
04773   switch (comprefdeminput.iformatflag)
04774     {
04775     case FORMATR4:
04776       INFO << "real4.";
04777       break;
04778     case FORMATR8:
04779       INFO << "real8.";
04780       break;
04781     case FORMATI2:
04782       INFO << "signed short.";
04783       break;
04784     case FORMATI2_BIGENDIAN:
04785       INFO << "signed short big endian.";
04786       break;
04787     default:
04788       PRINT_ERROR("totally impossible, checked input.");
04789       throw(keyword_error);
04790     }
04791   INFO.print();
04792 
04793 
04794 
04795 // ______ Check some things ______
04796   if (!existed(comprefdeminput.firefdem))
04797     {
04798     ERROR << "CRD_IN_DEM:   \t" << comprefdeminput.firefdem
04799          << " can not be opened.";
04800     PRINT_ERROR(ERROR.get_str())
04801     throw(keyword_error);
04802     }
04803   if (rad2deg(comprefdeminput.demdeltalat)<.0008)
04804     {
04805     WARNING << "CRD_IN_DELTA: \t" << comprefdeminput.demdeltalat
04806          << " seems very small (it should be in decimal degrees).";
04807     WARNING.print();
04808     }
04809   if (comprefdeminput.demrows<1 || comprefdeminput.demrows>10000)
04810     {
04811     WARNING << "CRD_DEM_SIZE: numrows: \t" << comprefdeminput.demrows
04812          << " seems to be wrong.";
04813     WARNING.print();
04814     }
04815   if (comprefdeminput.demcols<1 || comprefdeminput.demcols>10000)
04816     {
04817     WARNING << "CRD_DEM_SIZE: numcols: \t" << comprefdeminput.demcols
04818          << " seems to be wrong.";
04819     WARNING.print();
04820     }
04821   if (comprefdeminput.extradense>5.0)
04822     {
04823     WARNING << "CRD_DENSE:    \t" << comprefdeminput.extradense
04824          << " seems to be quite large.";
04825     WARNING.print();
04826     }
04827   if (comprefdeminput.extradense<0.2)
04828     {
04829     WARNING << "CRD_DENSE:    \t" << comprefdeminput.extradense
04830          << " seems too small.";
04831     WARNING.print();
04832     }
04833   if (rad2deg(comprefdeminput.demdeltalon)<.0008)
04834     {
04835     WARNING << "CRD_IN_DELTA: \t" << comprefdeminput.demdeltalon
04836          << " seems very small (it should be in decimal degrees).";
04837     WARNING.print();
04838     }
04839   if (rad2deg(comprefdeminput.demlatleftupper) < -90. ||
04840       rad2deg(comprefdeminput.demlatleftupper) >  90.   )
04841     {
04842     ERROR << "CRD_IN_LU:    \t" << rad2deg(comprefdeminput.demlatleftupper)
04843          << " out of range (-90:90).";
04844     PRINT_ERROR(ERROR.get_str())
04845     throw(keyword_error);
04846     }
04847   if (rad2deg(comprefdeminput.demlonleftupper) < -180. ||
04848       rad2deg(comprefdeminput.demlonleftupper) >  180.   )
04849     {
04850     WARNING << "CRD_IN_LU:    \t" << rad2deg(comprefdeminput.demlonleftupper)
04851          << " out of range (-180:180).";
04852     WARNING.print();
04853     }
04854   if (!strcmp(comprefdeminput.fodem,comprefdeminput.forefdem))
04855     {
04856     PRINT_ERROR("OUT_DEM, OUT_FILE: Same output file name.");
04857     throw(keyword_error);
04858     }
04859   if (!strcmp(comprefdeminput.firefdem,comprefdeminput.forefdem))
04860     {
04861     PRINT_ERROR("OUT_FILE, IN_DEM: Same file name.");
04862     throw(keyword_error);
04863     }
04864   } // END comprefdem
04865 
04866 
04867 
04868 /****************************************************************
04869  *    checksubtrrefdem                                          *
04870  *                                                              *
04871  * Checks cards for step subtrrefdem.                           *
04872  *                                                              *
04873  *    Bert Kampes, 14-Feb-2000                                  *
04874  ****************************************************************/
04875 void checksubtrrefdem(
04876         const input_subtrrefdem &subtrrefdeminput)
04877   {
04878   TRACE_FUNCTION("checksubtrrefdem (BK 14-Feb-2000)")
04879   INFO.print("\n\t*** Input for step SUBTRREFDEM ***");
04880   INFO << "SRD_OUT_CINT:   \t" << subtrrefdeminput.focint;
04881   INFO.print();
04882   INFO << "SRD_OFFSET:     \t" << subtrrefdeminput.offsetL 
04883        << " " << subtrrefdeminput.offsetP;
04884   INFO.print();
04885   if (abs(subtrrefdeminput.offsetL)>5) 
04886     WARNING.print("Apply offset in azimuth larger than 5 pixels?");
04887   if (abs(subtrrefdeminput.offsetP)>5) 
04888     WARNING.print("Apply offset in range larger than 5 pixels?");
04889   } // END checksubtrrefdem
04890 
04891 
04892 /****************************************************************
04893  *    checkfiltrange                                            *
04894  * Checks cards for step filtrange.                             *
04895  *    Bert Kampes, 14-Feb-2000                                  *
04896  ****************************************************************/
04897 void checkfiltrange(
04898         const input_filtrange &filtrangeinput)
04899   {
04900   TRACE_FUNCTION("checkfiltrange (BK 14-Feb-2000)")
04901   INFO.print("\n\t*** Input for step FILTRANGE ***");
04902   // ______ Give info ______
04903   switch (filtrangeinput.method)
04904     {
04905     case rf_adaptive:
04906       INFO.print("RF_METHOD:        ADAPTIVE \t(estimate fringe freq.)");
04907       INFO << "RF_NLMEAN:     " << filtrangeinput.nlmean;
04908       INFO.print();
04909       INFO << "RF_THRESHOLD:  " << filtrangeinput.SNRthreshold;
04910       INFO.print();
04911       INFO << "RF_OVERSAMPLE: " << filtrangeinput.oversample;
04912       INFO.print();
04913       INFO << "RF_WEIGHTCORR: " << filtrangeinput.doweightcorrel;
04914       INFO.print();
04915       INFO << "RF_OVERLAP:    " << filtrangeinput.overlap;
04916       INFO.print();
04917       if (filtrangeinput.nlmean > 51)
04918         WARNING.print("RF_NLMEAN:     mean over more than 51 lines (?)");
04919       if (filtrangeinput.SNRthreshold<1.99)
04920         WARNING.print("RF_THRESHOLD:  < 2");
04921       if (filtrangeinput.SNRthreshold>10.01)
04922         WARNING.print("RF_THRESHOLD:  > 10 ?");
04923       if (filtrangeinput.oversample<=1)
04924         WARNING.print("RF_OVERSAMPLE: no oversampling.");
04925       if (filtrangeinput.oversample>8)
04926         WARNING.print("RF_OVERSAMPLE: >8 ?");
04927       if (!ispower2(filtrangeinput.oversample))
04928         WARNING.print("RF_OVERSAMPLE: not power of two.");
04929       if (filtrangeinput.doweightcorrel==true)
04930         WARNING.print("RF_WEIGHTCORR: weighting, not sure it has effect.");
04931       if (filtrangeinput.fftlength > 1024)
04932         WARNING.print("RF_FFTLENGTH:  adaptive filterlength > 1024 ?");
04933       if (filtrangeinput.SNRthreshold<0.)
04934         {
04935         PRINT_ERROR(  "RF_THRESHOLD:  < 0.");
04936         throw(keyword_error);
04937         }
04938       break;
04939     case rf_porbits:
04940       INFO.print("RF_METHOD:        PORBITS  \t(based on orbits.)");
04941       INFO << "RF_SLOPE:      " << rad2deg(filtrangeinput.terrainslope)
04942            << "\t[deg] terrainslope.";
04943       INFO.print();
04944       if (filtrangeinput.fftlength < 256)
04945         WARNING.print("RF_FFTLENGTH:  porbits filterlength < 256 (?)");
04946       break;
04947     default:
04948       PRINT_ERROR("totally impossible, checked input.");
04949       throw(keyword_error);
04950     }
04951   // ______ Both methods cards ______
04952   INFO << "RF_FFTLENGTH:  " << filtrangeinput.fftlength;
04953   INFO.print();
04954   INFO << "RF_HAMMING:    " << filtrangeinput.hammingalpha;
04955   INFO.print();
04956   INFO << "RF_OUT_MASTER: " << filtrangeinput.fomaster;
04957   INFO.print();
04958   INFO << "RF_OUT_SLAVE:  " << filtrangeinput.foslave;
04959   INFO.print();
04960   INFO << "RF_OUT_FORMAT: output format: ";
04961   switch (filtrangeinput.oformatflag)
04962     {
04963     case FORMATCR4:
04964       INFO << "complex_real4.";
04965       break;
04966     case FORMATCI2:
04967       INFO << "complex_short.";
04968       break;
04969     default:
04970       PRINT_ERROR("totally impossible, checked input.");
04971       throw(keyword_error);
04972     }
04973   INFO.print();
04974 
04975   // ______ Check input ______
04976   if (filtrangeinput.hammingalpha>0.999)
04977     WARNING.print("RF_HAMMING: no hamming filtering.");
04978   if (existed(filtrangeinput.fomaster))
04979     WARNING.print("RF_OUT_MASTER: file exists.");
04980   if (existed(filtrangeinput.foslave))
04981     WARNING.print("RF_OUT_SLAVE: file exists.");
04982   if (!ispower2(filtrangeinput.fftlength))
04983     {
04984     PRINT_ERROR(  "RF_FFTLENGTH: not power of 2.");
04985     throw(keyword_error);
04986     }
04987   if (filtrangeinput.overlap >= 0.5*filtrangeinput.fftlength)
04988     {
04989     PRINT_ERROR(  "RF_OVERLAP >= 0.5*RF_FFTLENGTH");
04990     throw(keyword_error);
04991     }
04992   if (filtrangeinput.hammingalpha>1. || filtrangeinput.hammingalpha<0.)
04993     {
04994     PRINT_ERROR(  "RF_HAMMING: not e[0,1].");
04995     throw(keyword_error);
04996     }
04997   } // END checkfiltrange
04998 
04999 
05000 
05001 /****************************************************************
05002  *    checkdinsar                                               *
05003  *                                                              *
05004  * Checks cards for step dinsar.                                *
05005  *                                                              *
05006  #%// BK 25-Sep-2000
05007  ****************************************************************/
05008 void checkdinsar(
05009         const input_dinsar &dinsarinput)
05010   {
05011   TRACE_FUNCTION("checkdinsar (BK 25-Sep-2000)")
05012   INFO.print("\n\t*** Input for step DINSAR ***");
05013 
05014   if (!specified(dinsarinput.topomasterresfile))
05015     {
05016     INFO.print("Using 3 pass differential (for 4 pass, see DI_IN_TOPOMASTER card).");
05017     }
05018   else
05019     {
05020     INFO << "DI_IN_TOPOMASTER: \t" << dinsarinput.topomasterresfile
05021          << " (4 pass)";
05022     INFO.print();
05023     }
05024   INFO << "DI_IN_TOPOSLAVE: \t" << dinsarinput.toposlaveresfile;
05025   INFO.print();
05026   INFO << "DI_IN_TOPOINT:   \t" << dinsarinput.topointresfile;
05027   INFO.print();
05028   INFO << "DI_OUT_FILE:     \t" << dinsarinput.fodinsar;
05029   INFO.print();
05030   if (!specified(dinsarinput.foscaleduint))
05031     INFO << "DI_OUT_SCALED: \tNo (debug) output requested scaled topography interf.";
05032   else
05033     INFO << "DI_OUT_SCALED: \t" << dinsarinput.foscaleduint 
05034          << "; debug output requested.";
05035   INFO.print();
05036   if (!specified(dinsarinput.toposlaveresfile))
05037     {
05038     PRINT_ERROR("DI_IN_TOPOSLAVE: result file topo slave not specified.");
05039     throw(keyword_error);
05040     }
05041   if (!specified(dinsarinput.topointresfile))
05042     {
05043     PRINT_ERROR("DI_IN_TOPOINT: result file topo interferogram not specified.");
05044     throw(keyword_error);
05045     }
05046   if (!strcmp(dinsarinput.toposlaveresfile,dinsarinput.topointresfile))
05047     {
05048     PRINT_ERROR("IN_TOPOSLAVE, IN_TOPOINT: Same input file name.");
05049     throw(keyword_error);
05050     }
05051   } // END checkdinsar
05052 
05053 
05054 
05055 /****************************************************************
05056  *    checkfiltphase                                            *
05057  *                                                              *
05058  * Checks cards for step filtphase.                             *
05059  *                                                              *
05060  #%// BK 25-Sep-2000
05061  ****************************************************************/
05062 void checkfiltphase(
05063         const input_filtphase &filtphaseinput)
05064   {
05065   TRACE_FUNCTION("checkfiltphase (BK 25-Sep-2000)")
05066   INFO.print("\n\t*** Input for step FILTPHASE ***");
05067   if (specified(filtphaseinput.fifiltphase))
05068     {
05069     INFO << "PF_IN_FILE: \t" << filtphaseinput.fifiltphase
05070          << " " <<  filtphaseinput.finumlines
05071          << " (this cr4 file will be filtered)";
05072     INFO.print();
05073     if (!existed(filtphaseinput.fifiltphase))
05074       WARNING.print("Impossible? PF input file does not exist?");
05075     }
05076   INFO << "PF_OUT_FILE: \t" << filtphaseinput.fofiltphase 
05077        << " (output filename).";
05078   INFO.print();
05079 
05080   // ______ Method goldstein filter ______
05081   if (filtphaseinput.method==fp_goldstein)
05082     {
05083     INFO.print("FILTPHASE: Method goldstein.");
05084     INFO << "PF_ALPHA: \t" << filtphaseinput.alpha
05085          << " (weigthing parameter for spectrum).";
05086     INFO.print();
05087     INFO << "PF_BLOCKSIZE: " << filtphaseinput.blocksize
05088          << " (size of block to perform filtering on).";
05089     INFO.print();
05090     INFO << "PF_OVERLAP: \t" << filtphaseinput.overlap
05091          << " (half overlap between consequetive blocks).";
05092     INFO.print();
05093 
05094     // ______ Use 1d kernel to smooth amplitude, e.g. 12321 ______
05095     // ______ Which is normalized by me ______
05096     INFO << "PF_KERNEL: \t";
05097     for (int32 ii=0; ii<filtphaseinput.kernel.pixels(); ++ii)
05098       INFO << " " << filtphaseinput.kernel(0,ii);
05099     INFO << " (smooth |spectrum| with this).";
05100     INFO.print();
05101     if (filtphaseinput.kernel.pixels()==1)
05102       INFO.print("No smoothing of amplitude spectrum!");
05103 
05104     // ______ Check errors _____
05105     if (filtphaseinput.alpha<0. || filtphaseinput.alpha>1.)
05106       WARNING.print("PF_ALPHA not 0<a<1");
05107     if (filtphaseinput.blocksize>64 || filtphaseinput.blocksize<16)
05108       WARNING.print("PF_BLOCKSIZE very small or large?");
05109     if (filtphaseinput.kernel.pixels()>11)
05110       WARNING.print("smoothing kernel > 11:  very large?");
05111     if (filtphaseinput.overlap<0)
05112       {
05113       PRINT_ERROR("PF_OVERLAP < 0");
05114       throw(keyword_error);
05115       }
05116     if (2*filtphaseinput.overlap>filtphaseinput.blocksize)
05117       {
05118       PRINT_ERROR("2*PF_OVERLAP > PF_BLOCKSIZE");
05119       throw(keyword_error);
05120       }
05121     if (filtphaseinput.kernel.pixels()>filtphaseinput.blocksize)
05122       {
05123       PRINT_ERROR("smoothing kernel > PF_BLOCKSIZE");
05124       throw(keyword_error);
05125       }
05126     if (!ispower2(filtphaseinput.blocksize))
05127       {
05128       PRINT_ERROR("PF_BLOCKSIZE not a power of 2");
05129       throw(keyword_error);
05130       }
05131     }
05132 
05133   // ______ Method spatial convolution ______
05134   else if (filtphaseinput.method==fp_spatialconv)
05135     {
05136     INFO.print("FILTPHASE: Method spatial convolution.");
05137     if (!specified(filtphaseinput.fikernel2d))
05138       {
05139       INFO.print("Using 1d kernel for spatial convolution (no PF_IN_KERNEL2D).");
05140       INFO << "PF_KERNEL: used: \t";
05141       for (int32 ii=0; ii<filtphaseinput.kernel.pixels(); ++ii)
05142         INFO << " " << filtphaseinput.kernel(0,ii);
05143       INFO.print();
05144       }
05145     else
05146       {
05147       INFO.print("Using 2d kernel for spatial convolution.");
05148       INFO << "PF_IN_KERNEL2D: \t" << filtphaseinput.fikernel2d
05149            << " (ascii input file with 2d kernel).";
05150       INFO.print();
05151       INFO.print("PF_IN_KERNEL2D: \t(input file has 1 line header: numrows numcols scale");
05152       if (filtphaseinput.kernel.size()!=0)
05153         WARNING.print("PF_KERNEL card ignored due to card PF_IN_KERNEL2D.");
05154       if (!existed(filtphaseinput.fikernel2d))
05155         WARNING.print("PF_IN_KERNEL2D infile cannot be found.");
05156       }
05157     }
05158   else if (filtphaseinput.method==fp_spectral)
05159     {
05160     INFO.print("FILTPHASE: Method spectral filter with 2D kernel.");
05161     INFO << "PF_BLOCKSIZE: " << filtphaseinput.blocksize
05162          << " (size of block to perform filtering on).";
05163     INFO.print();
05164     INFO << "PF_OVERLAP: \t" << filtphaseinput.overlap
05165          << " (half overlap between consequetive blocks).";
05166     INFO.print();
05167     if (filtphaseinput.kernel.size()!=0)
05168       WARNING.print("PF_KERNEL card ignored for method spectral.");
05169     if (filtphaseinput.overlap<0)
05170       {
05171       PRINT_ERROR("PF_OVERLAP < 0");
05172       throw(keyword_error);
05173       }
05174     if (2*filtphaseinput.overlap>filtphaseinput.blocksize)
05175       {
05176       PRINT_ERROR("2*PF_OVERLAP > PF_BLOCKSIZE");
05177       throw(keyword_error);
05178       }
05179     if (!ispower2(filtphaseinput.blocksize))
05180       {
05181       PRINT_ERROR("PF_BLOCKSIZE not a power of 2");
05182       throw(keyword_error);
05183       }
05184     if (!specified(filtphaseinput.fikernel2d))
05185       {
05186       PRINT_ERROR("method spectral needs card PF_IN_KERNEL2D");
05187       throw(keyword_error);
05188       }
05189     }
05190   else
05191     {
05192     PRINT_ERROR("Method phasefiltering != {goldstein,spatialconv,spectral}.");
05193     throw(keyword_error);
05194     }
05195   } // END checkfiltphase
05196 
05197 
05198 /****************************************************************
05199  *    checkfiltazi                                              *
05200  * Checks cards for step filtazi.                               *
05201  *    Bert Kampes, 02-Nov-2000                                  *
05202  ****************************************************************/
05203 void checkfiltazi(
05204         const input_filtazi &filtaziinput,
05205         const int16 id)         // either master, slave, or m+s
05206   {
05207   TRACE_FUNCTION("checkfiltazi (BK 02-Nov-2000)")
05208   INFO.print("\n\t*** Input for step FILTAZI ***");
05209   INFO << "AF_BLOCKSIZE:   \t" << filtaziinput.fftlength;
05210   INFO.print();
05211   INFO << "AF_OVERLAP:     \t" << filtaziinput.overlap;
05212   INFO.print();
05213   INFO << "AF_HAMMING:     \t" << filtaziinput.hammingalpha;
05214   INFO.print();
05215   if (filtaziinput.oformatflag==FORMATCR4)
05216     INFO.print("AF_OUT_FORMAT:  \tcomplex_real4");
05217   else if (filtaziinput.oformatflag==FORMATCI2)
05218     INFO.print("AF_OUT_FORMAT:  \tcomplex_short");
05219   else
05220     {
05221     PRINT_ERROR("formatflag not ok for output.");
05222     throw(keyword_error);
05223     }
05224 
05225   if (id!=SLAVEID)
05226     {
05227     INFO << "AF_OUT_MASTER:  \t" << filtaziinput.fomaster;
05228     INFO.print();
05229     }
05230   if (id!=MASTERID)
05231     {
05232     INFO << "AF_OUT_SLAVE:   \t" << filtaziinput.foslave;
05233     INFO.print();
05234     }
05235 
05236   if (filtaziinput.fftlength<256)
05237     WARNING.print("AF_BLOCKSIZE < 256 (too small?)");
05238   if (2*filtaziinput.overlap>0.5*filtaziinput.fftlength)
05239     WARNING.print("2*AF_OVERLAP > .5*AF_BLOCKSIZE (very large?)");
05240   if (filtaziinput.hammingalpha<0 || filtaziinput.hammingalpha>1)
05241     {
05242     PRINT_ERROR("AF_HAMMING not e[0,1]");
05243     throw(keyword_error);
05244     }
05245   if (filtaziinput.overlap<0)
05246     {
05247     PRINT_ERROR("AF_BLOCKSIZE < 0");
05248     throw(keyword_error);
05249     }
05250   if (2*filtaziinput.overlap>filtaziinput.fftlength)
05251     {
05252     PRINT_ERROR("AF_BLOCKSIZE < 2*AF_BLOCKSIZE");
05253     throw(keyword_error);
05254     }
05255   if (!ispower2(filtaziinput.fftlength))
05256     {
05257     PRINT_ERROR("AF_BLOCKSIZE must be power of 2.");
05258     throw(keyword_error);
05259     }
05260   } // END checkfiltazi
05261 
05262 

Generated on Fri Apr 22 15:57:59 2005 for Doris by doxygen 1.3.6