~jdpipe/ascend/trunk-old

« back to all changes in this revision

Viewing changes to ascxx/simulation.cpp

  • Committer: jpye
  • Date: 2014-07-10 03:28:36 UTC
  • Revision ID: svn-v4:f15cd148-d149-4907-926e-73cf92b3ee03:trunk:2792
pass filename to Simulation::write instead of file pointer, overcome cross-platform issues.

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
        A general purpose routine for reporting from simulations.
151
151
*/
152
152
void
153
 
Simulation::write(FILE *fp, const char *type) const{
 
153
Simulation::write(const char *fname, const char *type) const{
154
154
        int res;
155
155
 
156
156
#if 0
167
167
 
168
168
        if(type==NULL){
169
169
                CONSOLE_DEBUG("Writing simroot...");
170
 
                simroot.write(fp);
 
170
                simroot.write(fname);
171
171
                return;
172
172
        }else if(string(type) == "dot"){
173
173
                if(!sys)throw runtime_error("Can't write DOT file: simulation not built");
174
174
                CONSOLE_DEBUG("Writing graph...");
 
175
                FILE *fp = fopen(fname, "wb");
175
176
                if(!fp){
176
 
                        throw runtime_error("Need a file to write to in Simulation::write");
 
177
                        throw runtime_error("Unable to open file for writing");
177
178
                }
178
179
                res = system_write_graph(sys, fp, "png");
 
180
                fclose(fp);
179
181
                if(res){
180
182
                        stringstream ss;
181
183
                        ss << "Error running system_write_graph (err " << res << ")";