From 0ed11248f16c266513b8d5ae4df38e958a8477c9 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (laptop)" <j.wuttke@fz-juelich.de> Date: Sat, 1 Nov 2008 10:54:42 +0100 Subject: [PATCH] fixed several bugs --- src/dualplot.cpp | 5 +++++ src/edif.cpp | 22 +++++++++++++++++++++- src/edif.h | 23 ++++++++++++----------- src/file_io.cpp | 2 ++ src/frida2.cpp | 15 +++++++++------ src/opr.cpp | 16 ++++++++++------ 6 files changed, 59 insertions(+), 24 deletions(-) diff --git a/src/dualplot.cpp b/src/dualplot.cpp index 91b5f431..a71f54e9 100644 --- a/src/dualplot.cpp +++ b/src/dualplot.cpp @@ -110,6 +110,11 @@ void CAxis::Ask(const string& quest) printf("! log scale requires range above 0\n"); continue; } + if (!log && ( newR.inf<-3e38 || newR.sup>3e38 ) ) { + printf( "! lin scale exceeds typical PS implementation range " + "(abs<3e38)\n" ); + continue; + } R = newR; return; } diff --git a/src/edif.cpp b/src/edif.cpp index 1268565a..e85701d9 100644 --- a/src/edif.cpp +++ b/src/edif.cpp @@ -330,6 +330,24 @@ void NEdif::DirCoord(void) } +//! Modify file name + +void NEdif::EditFNam() +{ + NOlm::IterateEle eiter; + const CEle *ein; + COlo *f; + string fnam; + while( (ein=eiter()) ) { + f = ein->P(); + fnam = wask( ("Rename " + f->name).c_str(), f->name ); + if ( fnam != f->name ){ + f->lDoc.push_back( "ef " + fnam + " # < " + f->name ); + f->name = fnam; + } + } +} + //! Modify coordinate names and units. void NEdif::EditCoord( string which ) @@ -406,8 +424,10 @@ void NEdif::Save( string fmt ) string quest = "Save as (."+fmt+")"; fnam = wask( quest.c_str(), f->name); if ( fnam==string("") ) return; - if ( fmt=="a01" ) + if ( fnam != f->name && fmt=="y08" ){ + f->lDoc.push_back( "fs " + fnam + " # < " + f->name ); f->name = fnam; + } fnam += "."+fmt; if ( (fd = fopen(fnam.c_str(), "r")) ) { diff --git a/src/edif.h b/src/edif.h index 2fa5c22f..011ec22e 100644 --- a/src/edif.h +++ b/src/edif.h @@ -1,17 +1,18 @@ namespace NEdif { - void Dir(void); - void DirZ(void); - void ListZ(void); - void DirNumpar( void ); - void EditNumpar( void ); - void DirCoord(void); + void Dir(); + void DirZ(); + void ListZ(); + void DirNumpar(); + void EditNumpar(); + void DirCoord(); + void EditFNam(); void EditCoord( string which ); - void EditDoc(void); + void EditDoc(); void Save( string fmt ); - void ReadIn(void); + void ReadIn(); void ReadTab( bool multiblock, bool fromscript ); - void MakeGrid(void); - void Plot(bool add); + void MakeGrid(); + void Plot( bool add ); // private: - int LoadOne(string flong, string fshort); + int LoadOne( string flong, string fshort ); }; diff --git a/src/file_io.cpp b/src/file_io.cpp index f8ff1c3b..8299198d 100644 --- a/src/file_io.cpp +++ b/src/file_io.cpp @@ -22,6 +22,8 @@ using namespace std; namespace NFileIO { + // actually, only FileI is implemented here; + // for FileO, see Edif::Save void Load_08( FILE *F_in, string flong ); void Load_01( FILE *F_in, string flong ); void LoadScan_01( FILE *F_in, CScan* sout, int nz ); diff --git a/src/frida2.cpp b/src/frida2.cpp index 46d5a315..462cfd5d 100644 --- a/src/frida2.cpp +++ b/src/frida2.cpp @@ -181,16 +181,19 @@ int main() NEdif::DirCoord(); } else if ( cmd == "e" ) { - cout << "Edit text parameters:\n" - " en numeric parameters\n" - " ecx x coordinate name and unit (similarly ecy, ecz0, ..)\n" - " ed documentation lines\n"; - } else if (cmd == "en") { - NEdif::EditNumpar(); + cout << "Edit parameters:\n" + " ef file name\n" + " ec<coord> name and unit of <coord>=x,y,z0,..\n" + " ed documentation lines\n" + " en numeric parameters\n"; } else if (cmd.substr(0,2) == "ec") { NEdif::EditCoord( cmd.substr(2) ); } else if (cmd == "ed") { NEdif::EditDoc(); + } else if (cmd == "ef") { + NEdif::EditFNam(); + } else if (cmd == "en") { + NEdif::EditNumpar(); } else if (cmd == "f") { diff --git a/src/opr.cpp b/src/opr.cpp index 4f3cfc48..babc0178 100644 --- a/src/opr.cpp +++ b/src/opr.cpp @@ -1063,14 +1063,14 @@ double NIntOld::Eval(CScan S) switch(mod) { case 2: if (iarg2<0 || iarg2>=n) - return 0; + throw string( "i out of range" ); return S.y[iarg2]; case 3: r0 = 0; for (i=0; i<n; i++) { r0 += S.y[i]; } - return n>0 ? r0/n : 0; + return r0/n; case 4: r0 = 0; s0 = 0; for (i=0; i<n; i++) { @@ -1112,17 +1112,20 @@ double NIntOld::Eval(CScan S) case 10: // integral dx y r0 = 0; for (i=0; i<n-1; i++) { - if (S.x[i+1]<=S.x[i]) return 0; + if (S.x[i+1]<=S.x[i]) + throw string( "x not sorted" ); r0 += (S.x[i+1]-S.x[i])*(S.y[i+1]+S.y[i])/2; } return r0; case 11: r0 = 0; r1 = 0; for (i=0; i<n-1; i++) { - if (S.x[i+1]<=S.x[i]) return 0; + if (S.x[i+1]<=S.x[i]) + throw string( "x not sorted" ); r0 += (S.x[i+1]-S.x[i])*(S.y[i+1]+S.y[i])/2; } - if (r0<=0) return 0; + if (r0<=0) + throw string( "int <= 0" ); for (i=0; i<n-1; i++) { dr = (S.x[i+1]-S.x[i])*(S.y[i+1]+S.y[i])/2; if ((r1+dr)/r0>=arg2) break; @@ -1154,7 +1157,8 @@ double NIntOld::Eval(CScan S) r0 += S.y[i]; r1 += S.y[i] * S.x[i]; } - if( r0<=0 ) return 0; + if( r0<=0 ) + throw string( "r0 <= 0" ); center = r1/r0; for (i=0; i<n; i++) { r2 += S.y[i] * SQR(S.x[i]-center); -- GitLab