diff -Naur lammps-1Sep09/doc/dump.html lammps-2Sep09/doc/dump.html --- lammps-1Sep09/doc/dump.html 2009-06-30 08:49:32.000000000 -0600 +++ lammps-2Sep09/doc/dump.html 2009-09-02 10:20:52.000000000 -0600 @@ -19,7 +19,7 @@
  • group-ID = ID of the group of atoms to be dumped -
  • style = atom or bond or dcd or xtc or xyz or custom +
  • style = atom or bond or cfg or dcd or xtc or xyz or custom
  • N = dump every this many timesteps @@ -29,6 +29,7 @@
      atom args = none
       bond args = none
    +  cfg args = same as custom args, see below
       dcd args = none
       xtc args = none
       xyz args = none
    @@ -71,6 +72,8 @@
     dump 2 subgroup atom 50 dump.run.bin
     dump 4a all custom 100 dump.myforce.* id type x y vx fx
     dump 4b flow custom 100 dump.%.myforce id type c_myF[3] v_ke
    +dump 2 inner cfg 10 dump.snap.*.cfg id type xs ys zs vx vy vz
    +dump snap all cfg 100 dump.config.*.cfg id type xs ys zs id type c_Stress2
     dump 1 all xtc 1000 file.xtc 
     

    Description: @@ -96,7 +99,9 @@ atom, bond, and custom styles. It is also the case for the xyz style if the dump group is not all. It is not the case for the dcd and xtc styles which always write atoms in sorted order. -So does the xyz style if the dump group is all. +So does the xyz style if the dump group is all. The cfg style +supports the sort option of the dump_modify +command which allows for allows sorting to be turned on or off.


    @@ -152,6 +157,21 @@ the timestep. An explanation of the dump custom quantities is given below.

    +

    Style cfg has the same command syntax as style custom and writes +extended CFG format files, as used by the +AtomEye visualization +package. Since the extended CFG format uses a single snapshot of the +system per file, a wild-card "*" must be included in the filename, as +discussed below. The list of atom attributes for style cfg must +begin with "id tag xs ys zs", since these quantities are needed to +write the CFG files in the appropriate format (though the "id" and +"type" fields do not appear explicitly in the file). Any remaining +attributes will be stored as "auxiliary properties" in the CFG files. +Note that you will typically want to use the dump_modify +element command with CFG-formatted files, to +associate element names with atom types, so that AtomEye can render +atoms appropriately. +

    The dcd style writes DCD files, a standard atomic trajectory format used by the CHARMM, NAMD, and XPlor molecular dynamics packages. DCD files are binary and thus may not be portable to different machines. @@ -243,7 +263,7 @@


    This section explains the atom quantities that can be specified as -part of the custom style. +part of the custom and cfg styles.

    The id, mol, type, vx, vy, vz, fx, fy, fz, q keywords are self-explanatory. diff -Naur lammps-1Sep09/doc/dump.txt lammps-2Sep09/doc/dump.txt --- lammps-1Sep09/doc/dump.txt 2009-06-30 08:49:32.000000000 -0600 +++ lammps-2Sep09/doc/dump.txt 2009-09-02 10:20:52.000000000 -0600 @@ -14,12 +14,13 @@ ID = user-assigned name for the dump :ulb,l group-ID = ID of the group of atoms to be dumped :l -style = {atom} or {bond} or {dcd} or {xtc} or {xyz} or {custom} :l +style = {atom} or {bond} or {cfg} or {dcd} or {xtc} or {xyz} or {custom} :l N = dump every this many timesteps :l file = name of file to write dump info to :l args = list of arguments for a particular style :l {atom} args = none {bond} args = none + {cfg} args = same as {custom} args, see below {dcd} args = none {xtc} args = none {xyz} args = none @@ -61,6 +62,8 @@ dump 2 subgroup atom 50 dump.run.bin dump 4a all custom 100 dump.myforce.* id type x y vx fx dump 4b flow custom 100 dump.%.myforce id type c_myF\[3\] v_ke +dump 2 inner cfg 10 dump.snap.*.cfg id type xs ys zs vx vy vz +dump snap all cfg 100 dump.config.*.cfg id type xs ys zs id type c_Stress[2] dump 1 all xtc 1000 file.xtc :pre [Description:] @@ -86,7 +89,9 @@ {atom}, {bond}, and {custom} styles. It is also the case for the {xyz} style if the dump group is not {all}. It is not the case for the {dcd} and {xtc} styles which always write atoms in sorted order. -So does the {xyz} style if the dump group is {all}. +So does the {xyz} style if the dump group is {all}. The {cfg} style +supports the {sort} option of the "dump_modify"_dump_modify.html +command which allows for allows sorting to be turned on or off. :line @@ -142,6 +147,21 @@ the timestep. An explanation of the dump custom quantities is given below. +Style {cfg} has the same command syntax as style {custom} and writes +extended CFG format files, as used by the +"AtomEye"_http://mt.seas.upenn.edu/Archive/Graphics/A visualization +package. Since the extended CFG format uses a single snapshot of the +system per file, a wild-card "*" must be included in the filename, as +discussed below. The list of atom attributes for style {cfg} must +begin with "id tag xs ys zs", since these quantities are needed to +write the CFG files in the appropriate format (though the "id" and +"type" fields do not appear explicitly in the file). Any remaining +attributes will be stored as "auxiliary properties" in the CFG files. +Note that you will typically want to use the "dump_modify +element"_dump_modify.html command with CFG-formatted files, to +associate element names with atom types, so that AtomEye can render +atoms appropriately. + The {dcd} style writes DCD files, a standard atomic trajectory format used by the CHARMM, NAMD, and XPlor molecular dynamics packages. DCD files are binary and thus may not be portable to different machines. @@ -233,7 +253,7 @@ :line This section explains the atom quantities that can be specified as -part of the {custom} style. +part of the {custom} and {cfg} styles. The {id}, {mol}, {type}, {vx}, {vy}, {vz}, {fx}, {fy}, {fz}, {q} keywords are self-explanatory. diff -Naur lammps-1Sep09/doc/dump_modify.html lammps-2Sep09/doc/dump_modify.html --- lammps-1Sep09/doc/dump_modify.html 2009-08-12 10:45:55.000000000 -0600 +++ lammps-2Sep09/doc/dump_modify.html 2009-09-02 10:20:52.000000000 -0600 @@ -19,23 +19,24 @@

  • one or more keyword/value pairs may be appended -
  • keyword = format or scale or image or flush or unwrap or every or precision or region or thresh +
  • keyword = every or flush or format or image or precision or region or scale or thresh or unwrap -
      format arg = C-style format string for one line of output
    -  scale arg = yes or no
    -  image arg = yes or no
    -  flush arg = yes or no
    -  unwrap arg = yes or no
    +
      element args = E1 E2 ... EN, where N = # of atom types
    +    E1,...,EN = element name, e.g. C or Fe or Ga
       every arg = N
         N = dump every this many timesteps
    +  format arg = C-style format string for one line of output
    +  flush arg = yes or no
    +  image arg = yes or no
       precision arg = power-of-10 value from 10 to 1000000
       region arg = region-ID or "none"
    +  scale arg = yes or no
       thresh args = attribute operation value
         attribute = same attributes (x,fy,etotal,sxx,etc) used by dump custom style
         operation = "<" or "<=" or ">" or ">=" or "==" or "!="
         value = numeric value to compare to
         these 3 args can be replaced by the word "none" to turn off thresholding
    -
    +  unwrap arg = yes or no 
     
    @@ -51,72 +52,83 @@

    Modify the parameters of a previously defined dump command. Not all parameters are relevant to all dump styles.

    +

    The element keyword applies only to the the dump cfg style. It +associates element names (e.g. H, C, Fe) with LAMMPS atom types, so +that the AtomEye +visualization package can render atoms with the appropriate size and +color. An element name is specified for each atom type (1 to Ntype) +in the simulation. The same element name can be given to multiple +atom types. +

    +

    The every keyword changes the dump frequency originally specified by +the dump command to a new value which must be > 0. The +dump frequency cannot be changed for the dump dcd style. +

    +

    The flush keyword determines whether a flush operation in invoked +after a dump snapshot is written to the dump file. A flush insures +the output in that file is current (no buffering by the OS), even if +LAMMPS halts before the simulation completes. Flushes cannot be +performed with dump style xtc. +

    The text-based dump styles have a default C-style format string which simply specifies %d for integers and %g for real values. The format keyword can be used to override the default with a new C-style format string. Do not include a trailing "\n" newline character in the format string. This option has no effect on the dcd and xtc dump -styles since they write binary files. -

    -

    The scale and image keywords apply only to the dump atom style. -

    -

    A scale value of yes means atom coords are written in normalized -units from 0.0 to 1.0 in each box dimension. If the simluation box is -triclinic (tilted), then all atom coords will still be between 0.0 and -1.0. A value of no means they are written in absolute distance -units (e.g. Angstroms or sigma). -

    -

    If the image value is yes, 3 flags are appended to each atom's -coords which are the absolute box image of the atom in each dimension. -For example, an x image flag of -2 with a normalized coord of 0.5 -means the atom is in the center of the box, but has passed thru the -box boundary 2 times and is really 2 box lengths to the left of its +styles since they write binary files. Note that for the cfg style, +the first two fields (atom id and type) are not actually written into +the CFG file, though you must include formats for them in the format +string. +

    +

    The image keyword applies only to the dump atom style. If the +image value is yes, 3 flags are appended to each atom's coords which +are the absolute box image of the atom in each dimension. For +example, an x image flag of -2 with a normalized coord of 0.5 means +the atom is in the center of the box, but has passed thru the box +boundary 2 times and is really 2 box lengths to the left of its current coordinate. Note that for dump style custom these various values can be printed in the dump file by using the appropriate atom attributes in the dump command itself.

    -

    The flush option determines whether a flush operation in invoked -after a dump snapshot is written to the dump file. A flush insures -the output in that file is current (no buffering by the OS), even if -LAMMPS halts before the simulation completes. Flushes cannot be -performed with dump style xtc. -

    -

    The unwrap option only applies to the dump dcd and xtc styles. -If set to yes, coordinates will be written "unwrapped" by the image -flags for each atom. Unwrapped means that if the atom has passed thru -a periodic boundary one or more times, the value is printed for what -the coordinate would be if it had not been wrapped back into the -periodic box. Note that these coordinates may thus be far outside the -box size stored with the snapshot. -

    -

    The every option changes the dump frequency originally specified by -the dump command to a new value which must be > 0. The -dump frequency cannot be changed for the dump dcd style. -

    -

    The precision option only applies to the dump xtc style. A +

    The precision keyword only applies to the dump xtc style. A specified value of N means that coordinates are stored to 1/N nanometer accuracy, e.g. for N = 1000, the coordinates are written to 1/1000 nanometer accuracy.

    -

    The region keyword only applies to the dump custom style. If -specified, only atoms in the region will be written to the dump file. -Only one region can be applied as a filter (the last one specified). -See the region command for more details. Note that a -region can be defined as the "inside" or "outside" of a geometric -shape, and it can be the "union" or "intersection" of a series of -simpler regions. -

    -

    The thresh keyword only applies to the dump custom style. -Multiple thresholds can be specified. Specifying "none" turns off -all threshold criteria. If thresholds are specified, only atoms -whose attributes meet all the threshold criteria are written to the -dump file. The possible attributes that can be tested for are the +

    The region keyword only applies to the dump custom and cfg +styles. If specified, only atoms in the region will be written to the +dump file. Only one region can be applied as a filter (the last one +specified). See the region command for more details. +Note that a region can be defined as the "inside" or "outside" of a +geometric shape, and it can be the "union" or "intersection" of a +series of simpler regions. +

    +

    The scale keyword applies only to the dump atom style. A scale +value of yes means atom coords are written in normalized units from +0.0 to 1.0 in each box dimension. If the simluation box is triclinic +(tilted), then all atom coords will still be between 0.0 and 1.0. A +value of no means they are written in absolute distance units +(e.g. Angstroms or sigma). +

    +

    The thresh keyword only applies to the dump custom and cfg +styles. Multiple thresholds can be specified. Specifying "none" +turns off all threshold criteria. If thresholds are specified, only +atoms whose attributes meet all the threshold criteria are written to +the dump file. The possible attributes that can be tested for are the same as those that can be specified in the dump custom command. Note that different attributes can be output by the dump custom command than are used as threshold criteria by the dump_modify command. E.g. you can output the coordinates and stress of atoms whose energy is above some threshold.

    +

    The unwrap keyword only applies to the dump dcd and xtc styles. +If set to yes, coordinates will be written "unwrapped" by the image +flags for each atom. Unwrapped means that if the atom has passed thru +a periodic boundary one or more times, the value is printed for what +the coordinate would be if it had not been wrapped back into the +periodic box. Note that these coordinates may thus be far outside the +box size stored with the snapshot. +

    Restrictions: none

    Related commands: @@ -125,10 +137,17 @@

    Default:

    -

    The option defaults are format = %d and %g for each integer or -floating point value, scale = yes, image = no, flush = yes (except for -the dump xtc style), unwrap = no, every = whatever it was set to via -the dump command, precision = 1000, region = none, and -thresh = none. +

    The option defaults are

    + diff -Naur lammps-1Sep09/doc/dump_modify.txt lammps-2Sep09/doc/dump_modify.txt --- lammps-1Sep09/doc/dump_modify.txt 2009-08-12 10:45:55.000000000 -0600 +++ lammps-2Sep09/doc/dump_modify.txt 2009-09-02 10:20:52.000000000 -0600 @@ -14,22 +14,23 @@ dump-ID = ID of dump to modify :ulb,l one or more keyword/value pairs may be appended :l -keyword = {format} or {scale} or {image} or {flush} or {unwrap} or {every} or {precision} or {region} or {thresh} :l - {format} arg = C-style format string for one line of output - {scale} arg = {yes} or {no} - {image} arg = {yes} or {no} - {flush} arg = {yes} or {no} - {unwrap} arg = {yes} or {no} +keyword = {every} or {flush} or {format} or {image} or {precision} or {region} or {scale} or {thresh} or {unwrap} :l + {element} args = E1 E2 ... EN, where N = # of atom types + E1,...,EN = element name, e.g. C or Fe or Ga {every} arg = N N = dump every this many timesteps + {format} arg = C-style format string for one line of output + {flush} arg = {yes} or {no} + {image} arg = {yes} or {no} {precision} arg = power-of-10 value from 10 to 1000000 {region} arg = region-ID or "none" + {scale} arg = {yes} or {no} {thresh} args = attribute operation value attribute = same attributes (x,fy,etotal,sxx,etc) used by dump custom style operation = "<" or "<=" or ">" or ">=" or "==" or "!=" value = numeric value to compare to these 3 args can be replaced by the word "none" to turn off thresholding -:pre + {unwrap} arg = {yes} or {no} :pre :ule [Examples:] @@ -44,72 +45,83 @@ Modify the parameters of a previously defined dump command. Not all parameters are relevant to all dump styles. +The {element} keyword applies only to the the dump {cfg} style. It +associates element names (e.g. H, C, Fe) with LAMMPS atom types, so +that the "AtomEye"_http://mt.seas.upenn.edu/Archive/Graphics/A +visualization package can render atoms with the appropriate size and +color. An element name is specified for each atom type (1 to Ntype) +in the simulation. The same element name can be given to multiple +atom types. + +The {every} keyword changes the dump frequency originally specified by +the "dump"_dump.html command to a new value which must be > 0. The +dump frequency cannot be changed for the dump {dcd} style. + +The {flush} keyword determines whether a flush operation in invoked +after a dump snapshot is written to the dump file. A flush insures +the output in that file is current (no buffering by the OS), even if +LAMMPS halts before the simulation completes. Flushes cannot be +performed with dump style {xtc}. + The text-based dump styles have a default C-style format string which simply specifies %d for integers and %g for real values. The {format} keyword can be used to override the default with a new C-style format string. Do not include a trailing "\n" newline character in the format string. This option has no effect on the {dcd} and {xtc} dump -styles since they write binary files. - -The {scale} and {image} keywords apply only to the dump {atom} style. - -A scale value of {yes} means atom coords are written in normalized -units from 0.0 to 1.0 in each box dimension. If the simluation box is -triclinic (tilted), then all atom coords will still be between 0.0 and -1.0. A value of {no} means they are written in absolute distance -units (e.g. Angstroms or sigma). - -If the image value is {yes}, 3 flags are appended to each atom's -coords which are the absolute box image of the atom in each dimension. -For example, an x image flag of -2 with a normalized coord of 0.5 -means the atom is in the center of the box, but has passed thru the -box boundary 2 times and is really 2 box lengths to the left of its +styles since they write binary files. Note that for the {cfg} style, +the first two fields (atom id and type) are not actually written into +the CFG file, though you must include formats for them in the format +string. + +The {image} keyword applies only to the dump {atom} style. If the +image value is {yes}, 3 flags are appended to each atom's coords which +are the absolute box image of the atom in each dimension. For +example, an x image flag of -2 with a normalized coord of 0.5 means +the atom is in the center of the box, but has passed thru the box +boundary 2 times and is really 2 box lengths to the left of its current coordinate. Note that for dump style {custom} these various values can be printed in the dump file by using the appropriate atom attributes in the dump command itself. -The {flush} option determines whether a flush operation in invoked -after a dump snapshot is written to the dump file. A flush insures -the output in that file is current (no buffering by the OS), even if -LAMMPS halts before the simulation completes. Flushes cannot be -performed with dump style {xtc}. - -The {unwrap} option only applies to the dump {dcd} and {xtc} styles. -If set to {yes}, coordinates will be written "unwrapped" by the image -flags for each atom. Unwrapped means that if the atom has passed thru -a periodic boundary one or more times, the value is printed for what -the coordinate would be if it had not been wrapped back into the -periodic box. Note that these coordinates may thus be far outside the -box size stored with the snapshot. - -The {every} option changes the dump frequency originally specified by -the "dump"_dump.html command to a new value which must be > 0. The -dump frequency cannot be changed for the dump {dcd} style. - -The {precision} option only applies to the dump {xtc} style. A +The {precision} keyword only applies to the dump {xtc} style. A specified value of N means that coordinates are stored to 1/N nanometer accuracy, e.g. for N = 1000, the coordinates are written to 1/1000 nanometer accuracy. -The {region} keyword only applies to the dump {custom} style. If -specified, only atoms in the region will be written to the dump file. -Only one region can be applied as a filter (the last one specified). -See the "region"_region.html command for more details. Note that a -region can be defined as the "inside" or "outside" of a geometric -shape, and it can be the "union" or "intersection" of a series of -simpler regions. - -The {thresh} keyword only applies to the dump {custom} style. -Multiple thresholds can be specified. Specifying "none" turns off -all threshold criteria. If thresholds are specified, only atoms -whose attributes meet all the threshold criteria are written to the -dump file. The possible attributes that can be tested for are the +The {region} keyword only applies to the dump {custom} and {cfg} +styles. If specified, only atoms in the region will be written to the +dump file. Only one region can be applied as a filter (the last one +specified). See the "region"_region.html command for more details. +Note that a region can be defined as the "inside" or "outside" of a +geometric shape, and it can be the "union" or "intersection" of a +series of simpler regions. + +The {scale} keyword applies only to the dump {atom} style. A scale +value of {yes} means atom coords are written in normalized units from +0.0 to 1.0 in each box dimension. If the simluation box is triclinic +(tilted), then all atom coords will still be between 0.0 and 1.0. A +value of {no} means they are written in absolute distance units +(e.g. Angstroms or sigma). + +The {thresh} keyword only applies to the dump {custom} and {cfg} +styles. Multiple thresholds can be specified. Specifying "none" +turns off all threshold criteria. If thresholds are specified, only +atoms whose attributes meet all the threshold criteria are written to +the dump file. The possible attributes that can be tested for are the same as those that can be specified in the "dump custom"_dump.html command. Note that different attributes can be output by the dump custom command than are used as threshold criteria by the dump_modify command. E.g. you can output the coordinates and stress of atoms whose energy is above some threshold. +The {unwrap} keyword only applies to the dump {dcd} and {xtc} styles. +If set to {yes}, coordinates will be written "unwrapped" by the image +flags for each atom. Unwrapped means that if the atom has passed thru +a periodic boundary one or more times, the value is printed for what +the coordinate would be if it had not been wrapped back into the +periodic box. Note that these coordinates may thus be far outside the +box size stored with the snapshot. + [Restrictions:] none [Related commands:] @@ -118,8 +130,15 @@ [Default:] -The option defaults are format = %d and %g for each integer or -floating point value, scale = yes, image = no, flush = yes (except for -the dump {xtc} style), unwrap = no, every = whatever it was set to via -the "dump"_dump.html command, precision = 1000, region = none, and -thresh = none. +The option defaults are + +element = "C" for every atom type +every = whatever it was set to via the "dump"_dump.html command +flush = yes (except for the dump {xtc} style) +format = %d and %g for each integer or floating point value +image = no +precision = 1000 +region = none +scale = yes +thresh = none +unwrap = no :ul diff -Naur lammps-1Sep09/src/STUBS/mpi.cpp lammps-2Sep09/src/STUBS/mpi.cpp --- lammps-1Sep09/src/STUBS/mpi.cpp 2007-10-16 12:08:31.000000000 -0600 +++ lammps-2Sep09/src/STUBS/mpi.cpp 2009-09-02 10:24:00.000000000 -0600 @@ -228,6 +228,25 @@ /* ---------------------------------------------------------------------- */ +/* copy values from data1 to data2 */ + +void MPI_Reduce(void *sendbuf, void *recvbuf, int count, + MPI_Datatype datatype, MPI_Op op, + int root, MPI_Comm comm) +{ + int n; + if (datatype == MPI_INT) n = count*sizeof(int); + else if (datatype == MPI_FLOAT) n = count*sizeof(float); + else if (datatype == MPI_DOUBLE) n = count*sizeof(double); + else if (datatype == MPI_CHAR) n = count*sizeof(char); + else if (datatype == MPI_BYTE) n = count*sizeof(char); + else if (datatype == MPI_DOUBLE_INT) n = count*sizeof(double_int); + + memcpy(recvbuf,sendbuf,n); +} + +/* ---------------------------------------------------------------------- */ + void MPI_Scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) { @@ -316,3 +335,22 @@ memcpy(recvbuf,sendbuf,n); } + +/* ---------------------------------------------------------------------- */ + +/* copy values from data1 to data2 */ + +void MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, + void *recvbuf, int *recvcounts, int *displs, + MPI_Datatype recvtype, int root, MPI_Comm comm) +{ + int n; + if (sendtype == MPI_INT) n = sendcount*sizeof(int); + else if (sendtype == MPI_FLOAT) n = sendcount*sizeof(float); + else if (sendtype == MPI_DOUBLE) n = sendcount*sizeof(double); + else if (sendtype == MPI_CHAR) n = sendcount*sizeof(char); + else if (sendtype == MPI_BYTE) n = sendcount*sizeof(char); + else if (sendtype == MPI_DOUBLE_INT) n = sendcount*sizeof(double_int); + + memcpy(recvbuf,sendbuf,n); +} diff -Naur lammps-1Sep09/src/STUBS/mpi.h lammps-2Sep09/src/STUBS/mpi.h --- lammps-1Sep09/src/STUBS/mpi.h 2007-10-16 12:08:31.000000000 -0600 +++ lammps-2Sep09/src/STUBS/mpi.h 2009-09-02 10:24:00.000000000 -0600 @@ -88,6 +88,8 @@ int root, MPI_Comm comm); void MPI_Allreduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm); +void MPI_Reduce(void *sendbuf, void *recvbuf, int count, + MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm); void MPI_Scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm); void MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, @@ -101,5 +103,8 @@ void MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm); +void MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, + void *recvbuf, int *recvcounts, int *displs, + MPI_Datatype recvtype, int root, MPI_Comm comm); #endif diff -Naur lammps-1Sep09/src/dump.cpp lammps-2Sep09/src/dump.cpp --- lammps-1Sep09/src/dump.cpp 2009-07-21 15:04:24.000000000 -0600 +++ lammps-2Sep09/src/dump.cpp 2009-09-02 10:24:00.000000000 -0600 @@ -52,6 +52,8 @@ format = NULL; format_user = NULL; + sort_flag = 0; + maxbuf = 0; buf = NULL; @@ -256,6 +258,12 @@ if (strcmp(id,output->dump[idump]->id) == 0) break; output->dump_every[idump] = n; iarg += 2; + } else if (strcmp(arg[iarg],"sort") == 0) { + if (iarg+2 > narg) error->all("Illegal dump_modify command"); + if (strcmp(arg[iarg+1],"yes") == 0) sort_flag = 1; + else if (strcmp(arg[iarg+1],"no") == 0) sort_flag = 0; + else error->all("Illegal dump_modify command"); + iarg += 2; } else { int n = modify_param(narg-iarg,&arg[iarg]); if (n == 0) error->all("Illegal dump_modify command"); diff -Naur lammps-1Sep09/src/dump.h lammps-2Sep09/src/dump.h --- lammps-1Sep09/src/dump.h 2009-03-16 16:34:07.000000000 -0600 +++ lammps-2Sep09/src/dump.h 2009-09-02 10:24:00.000000000 -0600 @@ -34,6 +34,7 @@ int header_flag; // 0 = item, 2 = xyz int flush_flag; // 0 if no flush, 1 if flush every dump + int sort_flag; // 1 if write in sorted order, 0 if not char *format_default; // default format string char *format_user; // format string set by user diff -Naur lammps-1Sep09/src/dump_cfg.cpp lammps-2Sep09/src/dump_cfg.cpp --- lammps-1Sep09/src/dump_cfg.cpp 1969-12-31 17:00:00.000000000 -0700 +++ lammps-2Sep09/src/dump_cfg.cpp 2009-09-02 10:24:00.000000000 -0600 @@ -0,0 +1,403 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Liang Wan (Chinese Academy of Sciences) +------------------------------------------------------------------------- */ + +#include "stdlib.h" +#include "string.h" +#include "dump_cfg.h" +#include "atom.h" +#include "domain.h" +#include "comm.h" +#include "modify.h" +#include "compute.h" +#include "input.h" +#include "fix.h" +#include "variable.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; + +enum{INT,DOUBLE}; // same as in dump_custom.cpp + +/* ---------------------------------------------------------------------- */ + +DumpCFG::DumpCFG(LAMMPS *lmp, int narg, char **arg) : + DumpCustom(lmp, narg, arg) +{ + if (narg < 10 || + strcmp(arg[5],"id") != 0 || strcmp(arg[6],"type") != 0 || + strcmp(arg[7],"xs") != 0 || strcmp(arg[8],"ys") != 0 || + strcmp(arg[9],"zs") != 0) + error->all("Dump cfg arguments must start with 'id type xs ys zs'"); + + ntypes = atom->ntypes; + typenames = NULL; + + // arrays for data rearrangement + + recvcounts = new int[nprocs]; + displs = new int[nprocs]; + tags = NULL; + rbuf = NULL; + nchosen = nlines = 0; + + // setup auxiliary property name strings + // convert 'X_ID[m]' (X=c,f,v) to 'ID_m' + + if (narg > 10) auxname = new char*[narg-10]; + else auxname = NULL; + + int i = 0; + for (int iarg = 10; iarg < narg; iarg++, i++) { + if (strncmp(arg[iarg],"c_",2) == 0 || + strncmp(arg[iarg],"f_",2) == 0 || + strncmp(arg[iarg],"v_",2) == 0) { + int n = strlen(arg[iarg]); + char *suffix = new char[n]; + strcpy(suffix,&arg[iarg][2]); + + char *ptr = strchr(suffix,'['); + if (ptr) { + if (suffix[strlen(suffix)-1] != ']') + error->all("Invalid keyword in dump cfg command"); + *ptr = '\0'; + *(ptr+2) = '\0'; + auxname[i] = new char[strlen(suffix) + 3]; + strcpy(auxname[i],suffix); + strcat(auxname[i],"_"); + strcat(auxname[i],ptr+1); + } else { + auxname[i] = new char[strlen(suffix) + 1]; + strcpy(auxname[i],suffix); + } + + delete [] suffix; + + } else { + auxname[i] = new char[strlen(arg[iarg]) + 1]; + strcpy(auxname[i],arg[iarg]); + } + } +} + +/* ---------------------------------------------------------------------- */ + +DumpCFG::~DumpCFG() +{ + if (typenames) { + for (int i = 1; i <= ntypes; i++) delete [] typenames[i]; + delete [] typenames; + } + + delete [] recvcounts; + delete [] displs; + + if (tags) memory->sfree(tags); + if (rbuf) memory->destroy_2d_double_array(rbuf); + + if (auxname) { + for (int i = 0; i < nfield-5; i++) delete [] auxname[i]; + delete [] auxname; + } +} + +/* ---------------------------------------------------------------------- */ + +void DumpCFG::init() +{ + if (multifile == 0) + error->all("Dump in CFG format requires one snapshot per file"); + + if (typenames == NULL) { + typenames = new char*[ntypes+1]; + for (int itype = 1; itype <= ntypes; itype++) { + typenames[itype] = new char[3]; + strcpy(typenames[itype],"C"); + } + if (comm->me == 0) + error->warning("All element names have been set to 'C' for dump cfg"); + } + + // setup format strings + + delete [] format; + char *str; + if (format_user) str = format_user; + else str = format_default; + + int n = strlen(str) + 1; + format = new char[n]; + strcpy(format,str); + + // tokenize the format string and add space at end of each format element + + char *ptr; + for (int i = 0; i < size_one; i++) { + if (i == 0) ptr = strtok(format," \0"); + else ptr = strtok(NULL," \0"); + if (ptr == NULL) error->all("Dump cfg user format string error"); + delete [] vformat[i]; + vformat[i] = new char[strlen(ptr) + 2]; + strcpy(vformat[i],ptr); + vformat[i] = strcat(vformat[i]," "); + } + if (strtok(NULL," \0")) + error->all("Dump cfg user format string error"); + + // find current ptr for each compute,fix,variable + // check that fix frequency is acceptable + + int icompute; + for (int i = 0; i < ncompute; i++) { + icompute = modify->find_compute(id_compute[i]); + if (icompute < 0) error->all("Could not find dump cfg compute ID"); + compute[i] = modify->compute[icompute]; + } + + int ifix; + for (int i = 0; i < nfix; i++) { + ifix = modify->find_fix(id_fix[i]); + if (ifix < 0) error->all("Could not find dump cfg fix ID"); + fix[i] = modify->fix[ifix]; + if (nevery % modify->fix[ifix]->peratom_freq) + error->all("Dump cfg and fix not computed at compatible times"); + } + + int ivariable; + for (int i = 0; i < nvariable; i++) { + ivariable = input->variable->find(id_variable[i]); + if (ivariable < 0) error->all("Could not find dump cfg variable name"); + variable[i] = ivariable; + } +} + +/* ---------------------------------------------------------------------- */ + +void DumpCFG::write_header(int n) +{ + if (me == 0 || multiproc) { + fprintf(fp,"Number of particles = %d\n", n); + fprintf(fp,"A = 1.0 Angstrom (basic length-scale)\n"); + fprintf(fp,"H0(1,1) = %g A\n",domain->xprd); + fprintf(fp,"H0(1,2) = 0 A \n"); + fprintf(fp,"H0(1,3) = 0 A \n"); + fprintf(fp,"H0(2,1) = %g A \n",domain->xy); + fprintf(fp,"H0(2,2) = %g A\n",domain->yprd); + fprintf(fp,"H0(2,3) = 0 A \n"); + fprintf(fp,"H0(3,1) = %g A \n",domain->xz); + fprintf(fp,"H0(3,2) = %g A \n",domain->yz); + fprintf(fp,"H0(3,3) = %g A\n",domain->zprd); + fprintf(fp,".NO_VELOCITY.\n"); + fprintf(fp,"entry_count = %d\n",nfield-2); + for (int i = 0; i < nfield-5; i++) + fprintf(fp,"auxiliary[%d] = %s\n",i,auxname[i]); + } + + // calculate total # of data lines to be written on a writing proc + + if (multiproc) nchosen = nmine; + else MPI_Reduce(&nmine,&nchosen,1,MPI_INT,MPI_SUM,0,world); + + // allocate memory needed for data rearrangement on writing proc(s) + + if (multiproc || me == 0) { + if (rbuf) memory->destroy_2d_double_array(rbuf); + rbuf = memory->create_2d_double_array(nchosen,size_one,"dump:rbuf"); + } + + // create a sorted list of atom IDs on writing proc(s) if necessary + + if (sort_flag) create_sorted_tags(); +} + +/* ---------------------------------------------------------------------- + write data lines to file in a block-by-block style + write head of block (mass & element name) only if has atoms of the type +------------------------------------------------------------------------- */ + +void DumpCFG::write_data(int n, double *buf) +{ + int i,j,m,itype; + int tag_i,index; + double *mass = atom->mass; + + // if sort flag is off, transfer data in buf to rbuf directly + // if write by proc 0, transfer chunk by chunk + + if (sort_flag == 0) { + for (i = 0, m = 0; i < n; i++) { + for (j = 0; j < size_one; j++) + rbuf[nlines][j] = buf[m++]; + nlines++; + } + + // write data lines in rbuf to file after transfer is done + + if (nlines == nchosen) { + for (itype = 1; itype <= ntypes; itype++) { + for (i = 0; i < nchosen; i++) + if (rbuf[i][1] == itype) break; + if (i < nchosen) { + fprintf(fp,"%g\n",mass[itype]); + fprintf(fp,"%s\n",typenames[itype]); + for (; i < nchosen; i++) { + if (rbuf[i][1] == itype) { + for (j = 2; j < size_one; j++) { + if (vtype[j] == INT) + fprintf(fp,vformat[j],static_cast (rbuf[i][j])); + else fprintf(fp,vformat[j],rbuf[i][j]); + } + fprintf(fp,"\n"); + } + } + } + } + nlines = 0; + } + + // if sort flag is on, transfer data lines in buf to rbuf & + // rearrange them in a sorted order + // if write by proc 0, transfer chunk by chunk + + } else { + + // sort data lines: + // find the index of the atom ID of each data line within the + // sorted atom IDs array + // transfer the data line to rbuf with its location according + // to this index + + for (i = 0, m = 0; i < n; i++) { + tag_i = static_cast(buf[m]); + for (j = 0; j < nchosen; j++) { + if (tag_i == tags[j]) { + index = j; + break; + } + } + for (j = 0; j < size_one; j++) + rbuf[index][j] = buf[m++]; + } + + // write data lines in rbuf to file after transfer is done + + nlines += n; + if (nlines == nchosen) { + for (itype = 1; itype <= ntypes; itype++) { + for (i = 0; i < nchosen; i++) + if (rbuf[i][1] == itype) break; + if (i < nchosen) { + fprintf(fp,"%g\n",mass[itype]); + fprintf(fp,"%s\n",typenames[itype]); + for (; i < nchosen; i++) { + if (rbuf[i][1] == itype) { + for (j = 2; j < size_one; j++) { + if (vtype[j] == INT) + fprintf(fp,vformat[j],static_cast(rbuf[i][j])); + else fprintf(fp,vformat[j],rbuf[i][j]); + } + fprintf(fp,"\n"); + } + } + } + } + nlines = 0; + } + } +} + +/* ---------------------------------------------------------------------- + create a sorted list of atom IDs on writing proc(s) +------------------------------------------------------------------------- */ + +void DumpCFG::create_sorted_tags() +{ + int index; + int *mytags; + int *tag = atom->tag; + int nlocal = atom->nlocal; + + index = 0; + + // if write by multiproc, each proc has its own atom IDs collected + + if (multiproc) { + if (tags) memory->sfree(tags); + tags = (int *) memory->smalloc(nchosen*sizeof(int),"dump:tags"); + for (int i = 0; i < nlocal; i++) + if (choose[i]) tags[index++] = tag[i]; + + // if write by proc 0, gather atom IDs of all the chosen atoms on proc 0 + + } else { + mytags = (int *) memory->smalloc(nmine*sizeof(int),"dump:mytags"); + for (int i = 0; i < nlocal; i++) + if (choose[i]) mytags[index++] = tag[i]; + MPI_Gather(&nmine,1,MPI_INT,recvcounts,1,MPI_INT,0,world); + if (me == 0) { + if (tags) memory->sfree(tags); + tags = (int *) memory->smalloc(nchosen*sizeof(int),"dump:tags"); + displs[0] = 0; + for (int iproc = 1; iproc < nprocs; iproc++) + displs[iproc] = displs[iproc-1] + recvcounts[iproc-1]; + } + MPI_Gatherv(mytags,nmine,MPI_INT,tags,recvcounts,displs,MPI_INT,0,world); + memory->sfree(mytags); + } + + if (multiproc || me == 0) qsort(tags,nchosen,sizeof(int),tag_compare); +} + +/* ---------------------------------------------------------------------- + compare function for qsort +------------------------------------------------------------------------- */ + +int DumpCFG::tag_compare(const void *itag, const void *jtag) +{ + int tag_i = *((int *) itag); + int tag_j = *((int *) jtag); + + if (tag_i < tag_j) return -1; + else if (tag_i > tag_j) return 1; + return 0; +} + +/* ---------------------------------------------------------------------- */ + +int DumpCFG::modify_param2(int narg, char **arg) +{ + if (strcmp(arg[0],"element") == 0) { + if (narg != ntypes+1) + error->all("Dump modify element names do not match atom types"); + + if (typenames) { + for (int i = 1; i <= ntypes; i++) delete [] typenames[i]; + delete [] typenames; + typenames = NULL; + } + + typenames = new char*[ntypes+1]; + for (int itype = 1; itype <= ntypes; itype++) { + typenames[itype] = new char[3]; + if (strlen(arg[itype]) >= 3) + error->all("Illegal chemical element names"); + strcpy(typenames[itype],arg[itype]); + } + return ntypes+1; + + } else return 0; +} diff -Naur lammps-1Sep09/src/dump_cfg.h lammps-2Sep09/src/dump_cfg.h --- lammps-1Sep09/src/dump_cfg.h 1969-12-31 17:00:00.000000000 -0700 +++ lammps-2Sep09/src/dump_cfg.h 2009-09-02 10:24:00.000000000 -0600 @@ -0,0 +1,47 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#ifndef DUMP_CFG_H +#define DUMP_CFG_H + +#include "dump_custom.h" + +namespace LAMMPS_NS { + +class DumpCFG : public DumpCustom { + public: + DumpCFG(class LAMMPS *, int, char **); + ~DumpCFG(); + void init(); + void write_header(int); + void write_data(int, double *); + int modify_param2(int, char **); + + private: + int ntypes; // # of atom types + char **typenames; // array of element names for each type + char **auxname; // name strings of auxiliary properties + int nchosen; // # of lines to be written on a writing proc + int nlines; // # of lines transferred from buf to rbuf + int *recvcounts; // # of data (tag info) received from all procs + int *displs; // displacement of data (tag info) within buffer + int *tags; // atom IDs of all the chosen atoms collected + double **rbuf; // buf of data lines for data lines rearrangement + + void create_sorted_tags(); + static int tag_compare(const void *, const void *); +}; + +} + +#endif diff -Naur lammps-1Sep09/src/dump_custom.cpp lammps-2Sep09/src/dump_custom.cpp --- lammps-1Sep09/src/dump_custom.cpp 2009-07-22 10:34:52.000000000 -0600 +++ lammps-2Sep09/src/dump_custom.cpp 2009-09-02 10:24:00.000000000 -0600 @@ -1365,6 +1365,12 @@ nthresh++; return 4; + + // pass along params to child class + + } else { + int n = modify_param2(narg,arg); + return n; } return 0; diff -Naur lammps-1Sep09/src/dump_custom.h lammps-2Sep09/src/dump_custom.h --- lammps-1Sep09/src/dump_custom.h 2009-03-16 16:34:07.000000000 -0600 +++ lammps-2Sep09/src/dump_custom.h 2009-09-02 10:24:00.000000000 -0600 @@ -21,11 +21,11 @@ class DumpCustom : public Dump { public: DumpCustom(class LAMMPS *, int, char **); - ~DumpCustom(); - void init(); + virtual ~DumpCustom(); + virtual void init(); double memory_usage(); - private: + protected: int nevery; // dump frequency to check Fix against int iregion; // -1 if no region, else which region int nthresh; // # of defined threshholds @@ -64,16 +64,17 @@ // private methods - void write_header(int); + virtual void write_header(int); int count(); int pack(); - void write_data(int, double *); + virtual void write_data(int, double *); void parse_fields(int, char **); int add_compute(char *); int add_fix(char *); int add_variable(char *); int modify_param(int, char **); + virtual int modify_param2(int, char **) {return 0;} typedef void (DumpCustom::*FnPtrHeader)(int); FnPtrHeader header_choice; // ptr to write header functions diff -Naur lammps-1Sep09/src/style.h lammps-2Sep09/src/style.h --- lammps-1Sep09/src/style.h 2009-08-11 12:59:27.000000000 -0600 +++ lammps-2Sep09/src/style.h 2009-09-02 10:24:00.000000000 -0600 @@ -135,6 +135,7 @@ #ifdef DumpInclude #include "dump_atom.h" +#include "dump_cfg.h" #include "dump_custom.h" #include "dump_dcd.h" #include "dump_xyz.h" @@ -142,6 +143,7 @@ #ifdef DumpClass DumpStyle(atom,DumpAtom) +DumpStyle(cfg,DumpCFG) DumpStyle(custom,DumpCustom) DumpStyle(dcd,DumpDCD) DumpStyle(xyz,DumpXYZ)