From 63795ebbcc75460ffa1ab204f0acc94dc8946acc Mon Sep 17 00:00:00 2001 From: sjplimp Date: Mon, 4 Nov 2013 15:10:54 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@10925 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/image.cpp | 6 +----- src/write_dump.cpp | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/image.cpp b/src/image.cpp index ff01e7d367..75c3825a94 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -1090,11 +1090,7 @@ void Image::write_PPM(FILE *fp) int x,y; for (y = height-1; y >= 0; y --) - for (x = 0; x < width; x ++) - fprintf(fp,"%c%c%c", - writeBuffer[0 + x*3 + y*width*3], - writeBuffer[1 + x*3 + y*width*3], - writeBuffer[2 + x*3 + y*width*3]); + fwrite(&writeBuffer[y*width*3],3,width,fp); } /* ---------------------------------------------------------------------- diff --git a/src/write_dump.cpp b/src/write_dump.cpp index 04f161a822..39c8ac2e43 100644 --- a/src/write_dump.cpp +++ b/src/write_dump.cpp @@ -28,42 +28,50 @@ using namespace LAMMPS_NS; void WriteDump::command(int narg, char **arg) { + if (narg < 3) error->all(FLERR,"Illegal write_dump command"); - if (atom->tag_enable == 0) - error->all(FLERR,"Must have atom IDs for write_dump command"); - - // modindex = index in args of "modify", narg if doesn't exist + // modindex = index in args of "modify" keyword + // will be narg if "modify" is not present int modindex; for (modindex = 0; modindex < narg; modindex++) if (strcmp(arg[modindex],"modify") == 0) break; // create the Dump instance + // create dump command line with extra required args Dump *dump; + char **dumpargs = new char*[modindex+2]; + dumpargs[0] = (char *) "WRITE_DUMP"; // dump id + dumpargs[1] = arg[0]; // group + dumpargs[2] = arg[1]; // dump style + dumpargs[3] = (char *) "0"; // dump frequency + + for (int i = 2; i < modindex; ++i) + dumpargs[i+2] = arg[i]; + if (0) return; // dummy line to enable else-if macro expansion #define DUMP_CLASS #define DumpStyle(key,Class) \ - else if (strcmp(arg[2],#key) == 0) dump = new Class(lmp,modindex,arg); + else if (strcmp(arg[2],#key) == 0) dump = new Class(lmp,modindex+2,dumpargs); #include "style_dump.h" #undef DUMP_CLASS else error->all(FLERR,"Invalid dump style"); - // pass additional args to modify_params - if (modindex < narg) dump->modify_params(narg-modindex-1,&arg[modindex+1]); - // write the current snapshot to dump file + // write out one frame and then delete the dump again dump->init(); dump->write(); - // delete the Dump instance + // delete the Dump instance and local storage delete dump; + delete[] dumpargs; }