Index: /trunk/BNC/bncpppclient.cpp
===================================================================
--- /trunk/BNC/bncpppclient.cpp	(revision 3752)
+++ /trunk/BNC/bncpppclient.cpp	(revision 3753)
@@ -328,4 +328,17 @@
   }
 
+  //// beg test
+  QMapIterator<QString, t_corr*> ic(_corr);
+  while (ic.hasNext()) {
+    ic.next();
+    const t_corr* corr = ic.value();
+    cout.setf(ios::fixed);
+    cout << corr->prn.toAscii().data() << " " 
+         << setw(3) << corr->iod << " "
+         << setw(8) << setprecision(3) << corr->dClk * t_CST::c << " "
+         << corr->tRao.datestr() << " " << corr->tRao.timestr() << "     "    
+         << corr->tClk.datestr() << " " << corr->tClk.timestr() << endl;
+  }
+  //// end test
 }
 
Index: /trunk/BNC/rinex/bncpostprocess.cpp
===================================================================
--- /trunk/BNC/rinex/bncpostprocess.cpp	(revision 3752)
+++ /trunk/BNC/rinex/bncpostprocess.cpp	(revision 3753)
@@ -132,4 +132,7 @@
     ++nEpo;
 
+    cout << "process " << epo->tt.datestr() << " "
+         << epo->tt.timestr() << endl;
+
     // Get Corrections
     // ---------------
Index: /trunk/BNC/rinex/rnxnavfile.cpp
===================================================================
--- /trunk/BNC/rinex/rnxnavfile.cpp	(revision 3752)
+++ /trunk/BNC/rinex/rnxnavfile.cpp	(revision 3753)
@@ -166,5 +166,5 @@
     bncTime ephTime(eph->GPSweek(), eph->GPSweeks());
     double dt = ephTime - tt;
-    if (dt < 4*3600.0) {
+    if (dt < 2*3600.0) {
       _ephs.pop();
       return eph;
Index: /trunk/BNC/upload/bncrtnetuploadcaster.cpp
===================================================================
--- /trunk/BNC/upload/bncrtnetuploadcaster.cpp	(revision 3752)
+++ /trunk/BNC/upload/bncrtnetuploadcaster.cpp	(revision 3753)
@@ -46,4 +46,10 @@
   int         sampl = settings.value("uploadSampl").toInt();
   _samplOrb = settings.value("uploadSamplOrb").toDouble();
+  if (_samplOrb == 0.0) {
+    _usedEph = 0;
+  }
+  else {
+    _usedEph = new QMap<QString, t_eph*>;
+  }
 
   // Raw Output
@@ -190,4 +196,5 @@
   delete _sp3;
   delete _ephUser;
+  delete _usedEph;
 }
 
@@ -267,13 +274,37 @@
     }
 
+    t_eph* eph = 0;
     const bncEphUser::t_ephPair* ephPair = _ephUser->ephPair(prn);
     if (ephPair) {
-      t_eph* eph = ephPair->last;
-
-// receptDateTime() not (yet?) defined 
-//      if (ephPair->prev && 
-//           eph->receptDateTime().secsTo(QDateTime::currentDateTime()) < 60) {
-//        eph = ephPair->prev;
-//      }
+
+      // Make sure the clock messages refer to same IOD as orbit messages
+      // ----------------------------------------------------------------
+      eph = ephPair->last;
+      if (_usedEph) {
+        if (fmod(epoTime.gpssec(), _samplOrb) == 0.0) {
+          (*_usedEph)[prn] = eph;
+        }
+        else {
+          eph = 0;
+          if (_usedEph->contains(prn)) {
+            t_eph* usedEph = _usedEph->value(prn);
+            if      (usedEph == ephPair->last) {
+              eph = ephPair->last;
+            }
+            else if (usedEph == ephPair->prev) {
+              eph = ephPair->prev;
+            }
+          }
+        }
+      }
+
+      // receptDateTime() not (yet?) defined 
+      //      if (ephPair->prev && 
+      //           eph->receptDateTime().secsTo(QDateTime::currentDateTime()) < 60) {
+      //        eph = ephPair->prev;
+      //      }
+    }
+
+    if (eph) {
 
       in >> xx(1) >> xx(2) >> xx(3) >> xx(4) >> xx(5) 
Index: /trunk/BNC/upload/bncrtnetuploadcaster.h
===================================================================
--- /trunk/BNC/upload/bncrtnetuploadcaster.h	(revision 3752)
+++ /trunk/BNC/upload/bncrtnetuploadcaster.h	(revision 3753)
@@ -59,4 +59,5 @@
   bncClockRinex* _rnx;
   bncSP3*        _sp3;
+  QMap<QString, t_eph*>* _usedEph;
 };
 
