Index: trunk/BNC/bncmodel.cpp
===================================================================
--- trunk/BNC/bncmodel.cpp	(revision 3307)
+++ trunk/BNC/bncmodel.cpp	(revision 3308)
@@ -919,5 +919,5 @@
 // Outlier Detection
 ////////////////////////////////////////////////////////////////////////////
-int bncModel::outlierDetection(const SymmetricMatrix& QQsav, 
+int bncModel::outlierDetection(int phase, const SymmetricMatrix& QQsav, 
                                const ColumnVector& vv,
                                QMap<QString, t_satData*>& satDataGPS,
@@ -935,61 +935,66 @@
   int irc = 0;
 
-  // Check GPS Code
-  // --------------
-  if (irc == 0) {
-    findMaxRes(vv,satDataGPS, prnCode, maxResCode, prnPhase, maxResPhase);
-    if (maxResCode > MAXRES_CODE_GPS) {
-      satDataGPS.remove(prnCode);
-      prnRemoved = prnCode;
-      maxRes     = maxResCode;
-      irc        = 1;
-    }
-  }
-
-  // Check Galileo Code
-  // ------------------
-  if (irc == 0) {
-    findMaxRes(vv,satDataGal, prnCode, maxResCode, prnPhase, maxResPhase);
-    if (maxResCode > MAXRES_CODE_GAL) {
-      satDataGal.remove(prnCode);
-      prnRemoved = prnCode;
-      maxRes     = maxResCode;
-      irc        = 1;
-    }
-  }
-
-  // Check Glonass Phase
-  // -------------------
-  if (irc == 0) {
-    findMaxRes(vv,satDataGlo, prnCode, maxResCode, prnPhase, maxResPhase);
-    if (maxResPhase > MAXRES_PHASE_GLO) {
-      satDataGlo.remove(prnPhase);
-      prnRemoved = prnPhase;
-      maxRes     = maxResPhase;
-      irc        = 1;
-    }
-  }
-
-  // Check Galileo Phase
-  // -------------------
-  if (irc == 0) {
-    findMaxRes(vv,satDataGal, prnCode, maxResCode, prnPhase, maxResPhase);
-    if      (maxResPhase > MAXRES_PHASE_GAL) {
-      satDataGal.remove(prnPhase);
-      prnRemoved = prnPhase;
-      maxRes     = maxResPhase;
-      irc        = 1;
-    }
-  }
-
-  // Check GPS Phase
-  // ---------------
-  if (irc == 0) {
-    findMaxRes(vv,satDataGPS, prnCode, maxResCode, prnPhase, maxResPhase);
-    if      (maxResPhase > MAXRES_PHASE_GPS) {
-      satDataGPS.remove(prnPhase);
-      prnRemoved = prnPhase;
-      maxRes     = maxResPhase;
-      irc        = 1;
+  if (phase == 0) {
+
+    // Check GPS Code
+    // --------------
+    if (irc == 0) {
+      findMaxRes(vv,satDataGPS, prnCode, maxResCode, prnPhase, maxResPhase);
+      if (maxResCode > MAXRES_CODE_GPS) {
+        satDataGPS.remove(prnCode);
+        prnRemoved = prnCode;
+        maxRes     = maxResCode;
+        irc        = 1;
+      }
+    }
+    
+    // Check Galileo Code
+    // ------------------
+    if (irc == 0) {
+      findMaxRes(vv,satDataGal, prnCode, maxResCode, prnPhase, maxResPhase);
+      if (maxResCode > MAXRES_CODE_GAL) {
+        satDataGal.remove(prnCode);
+        prnRemoved = prnCode;
+        maxRes     = maxResCode;
+        irc        = 1;
+      }
+    }
+  }
+
+  else {
+    // Check Glonass Phase
+    // -------------------
+    if (irc == 0) {
+      findMaxRes(vv,satDataGlo, prnCode, maxResCode, prnPhase, maxResPhase);
+      if (maxResPhase > MAXRES_PHASE_GLO) {
+        satDataGlo.remove(prnPhase);
+        prnRemoved = prnPhase;
+        maxRes     = maxResPhase;
+        irc        = 1;
+      }
+    }
+    
+    // Check Galileo Phase
+    // -------------------
+    if (irc == 0) {
+      findMaxRes(vv,satDataGal, prnCode, maxResCode, prnPhase, maxResPhase);
+      if      (maxResPhase > MAXRES_PHASE_GAL) {
+        satDataGal.remove(prnPhase);
+        prnRemoved = prnPhase;
+        maxRes     = maxResPhase;
+        irc        = 1;
+      }
+    }
+    
+    // Check GPS Phase
+    // ---------------
+    if (irc == 0) {
+      findMaxRes(vv,satDataGPS, prnCode, maxResCode, prnPhase, maxResPhase);
+      if      (maxResPhase > MAXRES_PHASE_GPS) {
+        satDataGPS.remove(prnPhase);
+        prnRemoved = prnPhase;
+        maxRes     = maxResPhase;
+        irc        = 1;
+      }
     }
   }
@@ -1212,12 +1217,12 @@
 // 
 ///////////////////////////////////////////////////////////////////////////
-void bncModel::printRes(const ColumnVector& vv, 
+void bncModel::printRes(int phase, const ColumnVector& vv, 
                         ostringstream& str, t_satData* satData) {
-  if (satData->indexPhase) {
+  if (phase) {
     str << _time.timestr(1)
         << " RES " << satData->prn.toAscii().data() << "   L3 "
         << setw(9) << setprecision(4) << vv(satData->indexPhase) << endl;
   }
-  if (satData->indexCode) {
+  else {
     str << _time.timestr(1)
         << " RES " << satData->prn.toAscii().data() << "   P3 "
@@ -1261,5 +1266,5 @@
   ColumnVector    vv;
 
-  for (int iPhase = 0; iPhase <= 1; iPhase++) {
+  for (int iPhase = 0; iPhase <= (_usePhase ? 1 : 0); iPhase++) {
 
     do {
@@ -1273,9 +1278,9 @@
           return failure;
         }
+      }
       
-        // Status Prediction
-        // -----------------
-        predict(epoData);
-      }
+      // Status Prediction
+      // -----------------
+      predict(epoData);
       
       // Create First-Design Matrix
@@ -1283,5 +1288,10 @@
       unsigned nPar = _params.size();
       unsigned nObs = 0;
-      nObs = epoData->sizeGPS() + epoData->sizeGal(); // Glonass code not used
+      if (iPhase == 0) {
+        nObs = epoData->sizeGPS() + epoData->sizeGal(); // Glonass code not used
+      }
+      else {
+        nObs = epoData->sizeGPS() + epoData->sizeGal() + epoData->sizeGlo();
+      }
     
       Matrix          AA(nObs, nPar);  // first design matrix
@@ -1300,4 +1310,15 @@
       }
     
+      // Glonass
+      // -------
+      if (iPhase == 1) {
+        QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
+        while (itGlo.hasNext()) {
+          itGlo.next();
+          t_satData* satData = itGlo.value();
+          addObs(iPhase, iObs, satData, AA, ll, PP);
+        }
+      }
+
       // Galileo
       // -------
@@ -1316,5 +1337,5 @@
     
       vv = ll - AA * dx;
-    
+
       // Print Residuals
       // ---------------
@@ -1327,11 +1348,13 @@
           itGPS.next();
           t_satData* satData = itGPS.value();
-          printRes(vv, str, satData);
-        }
-        QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
-        while (itGlo.hasNext()) {
-          itGlo.next();
-          t_satData* satData = itGlo.value();
-          printRes(vv, str, satData);
+          printRes(iPhase, vv, str, satData);
+        }
+        if (iPhase == 1) {
+          QMapIterator<QString, t_satData*> itGlo(epoData->satDataGlo);
+          while (itGlo.hasNext()) {
+            itGlo.next();
+            t_satData* satData = itGlo.value();
+            printRes(iPhase, vv, str, satData);
+          }
         }
         QMapIterator<QString, t_satData*> itGal(epoData->satDataGal);
@@ -1339,10 +1362,10 @@
           itGal.next();
           t_satData* satData = itGal.value();
-          printRes(vv, str, satData);
+          printRes(iPhase, vv, str, satData);
         }
         _log += str.str().c_str();
       }
     
-    } while (outlierDetection(QQsav, vv, epoData->satDataGPS, 
+    } while (outlierDetection(iPhase, QQsav, vv, epoData->satDataGPS, 
                               epoData->satDataGlo, epoData->satDataGal) != 0);
   }
Index: trunk/BNC/bncmodel.h
===================================================================
--- trunk/BNC/bncmodel.h	(revision 3307)
+++ trunk/BNC/bncmodel.h	(revision 3308)
@@ -98,5 +98,5 @@
   void   addObs(int phase, unsigned& iObs, t_satData* satData,
                 Matrix& AA, ColumnVector& ll, DiagonalMatrix& PP);
-  void   printRes(const ColumnVector& vv, 
+  void   printRes(int phase, const ColumnVector& vv, 
                   std::ostringstream& str, t_satData* satData);
   void   findMaxRes(const ColumnVector& vv,
@@ -108,5 +108,5 @@
   void   predict(t_epoData* epoData);
   t_irc  update_p(t_epoData* epoData, ColumnVector& dx);
-  int    outlierDetection(const SymmetricMatrix& QQsav, 
+  int    outlierDetection(int phase, const SymmetricMatrix& QQsav, 
                           const ColumnVector& vv,
                           QMap<QString, t_satData*>& satDataGPS,
Index: trunk/BNC/ppp.gpt
===================================================================
--- trunk/BNC/ppp.gpt	(revision 3307)
+++ trunk/BNC/ppp.gpt	(revision 3308)
@@ -25,5 +25,5 @@
 
 set ylabel "meters"
-set yrange [-0.5:0.5]
+set yrange [-1.0:1.0]
 
 set ytics nomirror
