~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to src/io/GenericFile.cpp

  • Committer: Niclas Jansson
  • Date: 2011-06-10 14:33:43 UTC
  • Revision ID: njansson@csc.kth.se-20110610143343-d21p4am8rghiojfm
Added rudimentary header to binary files

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
#include <stdio.h>
9
9
 
10
10
#include <dolfin/log/dolfin_log.h>
11
 
#include "GenericFile.h"
12
 
 
 
11
#include <dolfin/io/GenericFile.h>
 
12
#include <dolfin/main/MPI.h>
13
13
using namespace dolfin;
14
14
 
15
15
//-----------------------------------------------------------------------------
161
161
  write_not_impl("Graph");
162
162
}
163
163
//-----------------------------------------------------------------------------
 
164
void GenericFile::operator<< (std::vector<std::pair<Function*, std::string> >& f)
 
165
{
 
166
  write_not_impl("Function");
 
167
}
 
168
//-----------------------------------------------------------------------------
164
169
void GenericFile::read()
165
170
{
166
171
  opened_read = true;
168
173
//-----------------------------------------------------------------------------
169
174
void GenericFile::write()
170
175
{
 
176
 
 
177
 
171
178
  if ( !opened_write ) {
172
 
    // Clear file
173
 
    FILE* fp = fopen(filename.c_str(), "w");
174
 
    fclose(fp);
 
179
    //FIXME: temporary fix, only rank == 0 is allowed to clear the file
 
180
    if(type == "VTK" ) {
 
181
      if(MPI::processNumber() == 0) {
 
182
        // Clear file
 
183
        FILE* fp = fopen(filename.c_str(), "w");
 
184
        fclose(fp);
 
185
      }
 
186
    }
 
187
    else {
 
188
      FILE* fp = fopen(filename.c_str(), "w");
 
189
      fclose(fp);
 
190
    }
175
191
  }
176
192
  
177
193
  opened_write = true;