Index: trunk/BNC/upload/bncrtnetuploadcaster.cpp
===================================================================
--- trunk/BNC/upload/bncrtnetuploadcaster.cpp	(revision 3591)
+++ 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 3591)
+++ trunk/BNC/upload/bncrtnetuploadcaster.h	(revision 3753)
@@ -59,4 +59,5 @@
   bncClockRinex* _rnx;
   bncSP3*        _sp3;
+  QMap<QString, t_eph*>* _usedEph;
 };
 
