From bafc5100832666779f80332d293262b78df136f1 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (laptop)" <j.wuttke@fz-juelich.de>
Date: Fri, 18 Mar 2011 17:49:42 +0100
Subject: [PATCH] finish _SCR implementation; debmsg for interpolation in
 _SCR_INTP

---
 pub/src/curve.cpp | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/pub/src/curve.cpp b/pub/src/curve.cpp
index bc0682ca..d7385f7f 100644
--- a/pub/src/curve.cpp
+++ b/pub/src/curve.cpp
@@ -117,7 +117,8 @@ ask_again:
             "  - 1*int:    the number of data points N\n"
             "  - N*double: the data points\n"
             "- write to stdout a whitespace separated list of:\n"
-            "  - N*double: the curve values\n"
+            "  - N*double: N lines with curve values y\n"
+//            "  - N*double: the curve values\n"
             "- write to error messages to stderr\n";
         goto ask_again;
     } else if ( resp=="hci" ) {
@@ -127,7 +128,8 @@ ask_again:
             "  - 1*int:      the number of parameters M\n"
             "  - M*double:   the parameters\n"
             "- write to stdout a whitespace separated list of:\n"
-            "  - N*2*double: a sequence of data pairs: x0 y0 x1 y1 x2 y2 ...\n"
+            "  - N*2*double: N lines with pairs x y\n"
+//            "  - N*2*double: a sequence of data pairs: x0 y0 x1 y1 x2 y2 ...\n"
             "- write to error messages to stderr\n";
         goto ask_again;
     } else if ( resp=="c" ) {
@@ -216,18 +218,29 @@ void COlc::curve_val_vec( vector<double>* ret, const vector<double>& vt,
 
         CSpec S;
         double x, y;
-
         FILE *F;
         if( !(F = fopen( ret_fifonam.c_str(), "r")) )
             throw "BUG: cannot read results of system call";
-        while( fscanf( F, "%lg %lg\n", &x, &y )==2 )
-            S.push_xy( x, y );
+
+        if ( evaMode==_SCR ) {
+            for ( uint i=0; i<vt.size(); ++i ) {
+                if ( fscanf( F, "%lg\n", &y )!=1 )
+                    throw "script returns no value for t["+
+                        strg(i)+"]="+strg(vt[i]);
+                S.push_xy( vt[i], y );
+            }
+        } else {
+            while ( fscanf( F, "%lg %lg\n", &x, &y )==2 )
+                S.push_xy( x, y );
+            // interpolation:
+            if ( S.size()<2 )
+                throw "script returns only " + strg(S.size()) + " lines";
+            cout << "DEB call intpol " << vt.front() << " .. " << vt.back() 
+                 << "\n";
+            S.intpol( vt, *ret );
+        }
         fclose( F );
         
-        // interpolation:
-        if( S.size()<2 )
-            throw "script returns only " + strg(S.size()) + " lines";
-        S.intpol( vt, *ret );
     } else
         throw "BUG: unexpected evaluation mode";
 }
-- 
GitLab