2003-08-11 21:25:28 +02:00
|
|
|
/**********
|
|
|
|
|
Copyright 1992 Regents of the University of California. All rights reserved.
|
|
|
|
|
Author: 1992 David A. Gates, U. C. Berkeley CAD Group
|
|
|
|
|
**********/
|
|
|
|
|
|
2011-08-20 19:27:09 +02:00
|
|
|
#include <ngspice/ngspice.h>
|
|
|
|
|
#include <ngspice/fteext.h>
|
2003-08-11 21:25:28 +02:00
|
|
|
/* #include "ftedata.h" */
|
2011-08-20 19:27:09 +02:00
|
|
|
#include <ngspice/cidersupt.h>
|
2003-08-11 21:25:28 +02:00
|
|
|
|
|
|
|
|
struct plot *
|
2010-07-03 22:37:00 +02:00
|
|
|
DBread( char *fileName )
|
2003-08-11 21:25:28 +02:00
|
|
|
{
|
|
|
|
|
struct plot *plot;
|
|
|
|
|
|
|
|
|
|
plot = raw_read( fileName );
|
|
|
|
|
|
|
|
|
|
return(plot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double *
|
2010-07-03 22:37:00 +02:00
|
|
|
DBgetData(struct plot *plot, char *name, int lengthWanted)
|
2003-08-11 21:25:28 +02:00
|
|
|
{
|
|
|
|
|
struct dvec *v;
|
|
|
|
|
double *data;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
v = vec_fromplot(name,plot);
|
|
|
|
|
|
|
|
|
|
if (!v) {
|
|
|
|
|
fprintf( stderr, "Error: cannot locate variable '%s'\n", name );
|
|
|
|
|
return(NULL);
|
|
|
|
|
}
|
|
|
|
|
if (v->v_length != lengthWanted ) {
|
|
|
|
|
fprintf( stderr, "Error: vector '%s' has incorrect length\n", name );
|
|
|
|
|
return(NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-28 21:32:34 +02:00
|
|
|
data = TMALLOC(double, v->v_length);
|
2003-08-11 21:25:28 +02:00
|
|
|
if (isreal(v)) {
|
2010-11-02 18:07:57 +01:00
|
|
|
bcopy(v->v_realdata, data, sizeof (double) * (size_t) v->v_length);
|
2003-08-11 21:25:28 +02:00
|
|
|
} else {
|
|
|
|
|
for (i=0; i < v->v_length; i++) {
|
|
|
|
|
data[i] = realpart(&v->v_compdata[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2010-07-03 22:37:00 +02:00
|
|
|
DBfree(struct plot *plot)
|
2003-08-11 21:25:28 +02:00
|
|
|
{
|
|
|
|
|
struct dvec *v, *nextv;
|
|
|
|
|
struct plot *pl, *nextpl;
|
|
|
|
|
|
|
|
|
|
for (pl = plot; pl; pl = nextpl) {
|
|
|
|
|
nextpl = pl->pl_next;
|
|
|
|
|
tfree( pl->pl_title );
|
|
|
|
|
tfree( pl->pl_date );
|
|
|
|
|
tfree( pl->pl_name );
|
|
|
|
|
tfree( pl->pl_typename );
|
|
|
|
|
for (v = pl->pl_dvecs; v; v = nextv) {
|
|
|
|
|
nextv = v->v_next;
|
|
|
|
|
vec_free( v );
|
|
|
|
|
}
|
|
|
|
|
wl_free( pl->pl_commands );
|
|
|
|
|
/* XXX Environment variables (pl->pl_env) will leak. */
|
|
|
|
|
}
|
|
|
|
|
}
|