From a2f94771320aa8e106ccbec5e1fcf2633136ffdf Mon Sep 17 00:00:00 2001
From: Uwe Schulzweida <uwe.schulzweida@mpimet.mpg.de>
Date: Fri, 27 Mar 2015 14:51:46 +0000
Subject: [PATCH] gribapiScanTimestep1: fixed bug from previous merge of
 branches/cdi_fileDrivenInput (GRIB2 read failed)

---
 ChangeLog            | 4 ++++
 src/stream_gribapi.c | 2 +-
 src/stream_record.c  | 6 +++---
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a2af0ef58..f293b0cb1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-27  Uwe Schulzweida
+
+	* gribapiScanTimestep1: fixed bug from previous merge of branches/cdi_fileDrivenInput (GRIB2 read failed)
+
 2015-03-26  Uwe Schulzweida
 
         * merged changes from branches/cdi_fileDrivenInput
diff --git a/src/stream_gribapi.c b/src/stream_gribapi.c
index 00125b431..e158f6de2 100644
--- a/src/stream_gribapi.c
+++ b/src/stream_gribapi.c
@@ -960,7 +960,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
   vlistDefTaxis(vlistID, taxisID);
 
   int nrecords = streamptr->tsteps[0].nallrecs;
-  if ( nrecords > streamptr->tsteps[0].recordSize )
+  if ( nrecords < streamptr->tsteps[0].recordSize )
     {
       streamptr->tsteps[0].recordSize = nrecords;
       streamptr->tsteps[0].records =
diff --git a/src/stream_record.c b/src/stream_record.c
index e231f0254..073b0cf56 100644
--- a/src/stream_record.c
+++ b/src/stream_record.c
@@ -47,7 +47,7 @@ int recordNewEntry(stream_t *streamptr, int tsID)
       if ( records == NULL )
 	{
           Message("recordSize = %d", recordSize);
-	  SysError("Allocation of record_tTABLE failed");
+	  SysError("Allocation of records failed");
 	}
 
       for ( i = 0; i < recordSize; i++ )
@@ -74,7 +74,7 @@ int recordNewEntry(stream_t *streamptr, int tsID)
       if ( records == NULL )
 	{
           Message("recordSize = %d", recordSize);
-	  SysError("Reallocation of record_tTABLE failed");
+	  SysError("Reallocation of records failed");
 	}
       recordID = recordSize/2;
 
@@ -443,7 +443,7 @@ void cdi_create_records(stream_t *streamptr, int tsID)
 
   if ( destTstep->records ) return;
 
-  int vlistID  = streamptr->vlistID;
+  int vlistID = streamptr->vlistID;
 
   if ( tsID == 0 )
     {
-- 
GitLab