// Public Methods void InOut::writeToFile( double time, const ParticleArray &particles ) { static bool first_call = true; switch ( outputinfo ) { case OUTPUT_NOTHING: // Do nothing. break; case OUTPUT_POSITIONS: writePositions( first_call, time, particles ); break; default: std::cout << "ERROR: Unknown outputtype."; break; } first_call = false; }
void scanFile(FILE *fp, Args *args){ char *tag; int numRead, *lengths; Profile *profiles; int n; tag = (char *)emalloc(3*sizeof(char)); numRead = fread(tag,sizeof(char),3,fp); assert(numRead == 3); while(!feof(fp)){ if(strcmp(tag,"sum")==0){ numRead = fread(&n,sizeof(int),1,fp); assert(numRead == 1); profiles = (Profile *)emalloc(n*sizeof(Profile)); numRead = fread(profiles,sizeof(Profile),n,fp); assert(numRead == n); writeProfiles(profiles, n); free(profiles); }else if(strcmp(tag,"con")==0){ numRead = fread(&n,sizeof(int),1,fp); assert(numRead == 1); lengths = (int *)emalloc(n*sizeof(int)); numRead = fread(lengths,sizeof(int),n,fp); assert(numRead == n); writeLengths(lengths, n); free(lengths); }else if(strcmp(tag,"pos")==0){ writePositions(fp); }else if(strcmp(tag,"lik")==0){ writeLikelihoods(fp); }else assert(0); numRead = fread(tag,sizeof(char),3,fp); } free(tag); }