diff --git a/src/citeme.cpp b/src/citeme.cpp new file mode 100644 index 0000000000..5d6118d28a --- /dev/null +++ b/src/citeme.cpp @@ -0,0 +1,72 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "citeme.h" +#include "version.h" +#include "universe.h" +#include "error.h" + +using namespace LAMMPS_NS; + +static const char cite_header[] = + "This LAMMPS simulation made specific use of work described in the\n" + "following references. See http://lammps.sandia.gov/cite.html\n" + "for details.\n\n"; + +static const char cite_nagline[] = "\nPlease see the log.cite file " + "for references relevant to this simulation\n\n"; + +/* ---------------------------------------------------------------------- */ + +CiteMe::CiteMe(LAMMPS *lmp) : Pointers(lmp) +{ + fp = NULL; + cs = new citeset(); +} + +/* ---------------------------------------------------------------------- + write out nag-line at the end of the regular output and clean up +------------------------------------------------------------------------- */ + +CiteMe::~CiteMe() +{ + if (universe->me) return; + if (cs->size() == 0) return; + + if (screen) fprintf(screen,cite_nagline); + if (logfile) fprintf(logfile,cite_nagline); + + delete cs; + if (fp) fclose(fp); +} + +/* ---------------------------------------------------------------------- + write out and register a citation so it will be written only once +------------------------------------------------------------------------- */ + +void CiteMe::add(const char *ref) +{ + if (universe->me) return; + if (cs->find(ref) != cs->end()) return; + cs->insert(ref); + + if (!fp) { + fp = fopen("log.cite","w"); + if (!fp) error->universe_one(FLERR,"Could not open log.cite file"); + fprintf(fp,cite_header); + fflush(fp); + } + + fprintf(fp,ref); + fflush(fp); +} diff --git a/src/citeme.h b/src/citeme.h new file mode 100644 index 0000000000..625387000b --- /dev/null +++ b/src/citeme.h @@ -0,0 +1,42 @@ +/* -*- c++ -*- ---------------------------------------------------------- + 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 LMP_CITEME_H +#define LMP_CITEME_H + +#include "pointers.h" +#include "stdio.h" +#include + +namespace LAMMPS_NS { + +class CiteMe : protected Pointers { + public: + CiteMe(class LAMMPS *); + virtual ~CiteMe(); + void add(const char *); // print out and register publication + + private: + FILE *fp; // opaque pointer to log.cite file object + typedef std::set citeset; + citeset *cs; // registered set of publications +}; + +} + +#endif + +/* ERROR/WARNING messages: + + +*/ diff --git a/src/lammps.cpp b/src/lammps.cpp index 5d138617b0..a3b56ff8e8 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -39,6 +39,7 @@ #include "modify.h" #include "group.h" #include "output.h" +#include "citeme.h" #include "accelerator_cuda.h" #include "accelerator_omp.h" #include "timer.h" @@ -73,7 +74,9 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) int partscreenflag = 0; int partlogflag = 0; int cudaflag = -1; + int citeflag = 1; int helpflag = 0; + suffix = NULL; suffix_enable = 0; @@ -156,6 +159,10 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) error->universe_all(FLERR,"Cannot use -reorder after -partition"); universe->reorder(arg[iarg+1],arg[iarg+2]); iarg += 3; + } else if (strcmp(arg[iarg],"-nocite") == 0 || + strcmp(arg[iarg],"-nc") == 0) { + citeflag = 0; + iarg++; } else if (strcmp(arg[iarg],"-help") == 0 || strcmp(arg[iarg],"-h") == 0) { if (iarg+1 > narg) @@ -393,6 +400,11 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) MPI_Comm_rank(world,&me); if (cuda && me == 0) error->message(FLERR,"USER-CUDA mode is enabled"); + // allocate CiteMe class if enabled + + if (citeflag) citeme = new CiteMe(this); + else citeme = NULL; + // allocate input class now that MPI is fully setup input = new Input(this,narg,arg); @@ -422,6 +434,8 @@ LAMMPS::~LAMMPS() { destroy(); + delete citeme; + if (universe->nworlds == 1) { if (logfile) fclose(logfile); } else { diff --git a/src/lammps.h b/src/lammps.h index 0feb015b31..e9d79d88e3 100644 --- a/src/lammps.h +++ b/src/lammps.h @@ -1,4 +1,4 @@ -/* ---------------------------------------------------------------------- +/* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov @@ -44,8 +44,11 @@ class LAMMPS { char *suffix; // suffix to add to input script style names int suffix_enable; // 1 if suffix enabled, 0 if disabled + int cite_enable; // 1 if generating log.cite, 0 if disabled class Cuda *cuda; // CUDA accelerator class + class CiteMe *citeme; // citation info + LAMMPS(int, char **, MPI_Comm); ~LAMMPS(); void create(); diff --git a/src/neighbor.cpp b/src/neighbor.cpp index d7ee373a57..5a7c5312a2 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -36,6 +36,7 @@ #include "update.h" #include "respa.h" #include "output.h" +#include "citeme.h" #include "memory.h" #include "error.h" @@ -51,6 +52,19 @@ using namespace LAMMPS_NS; enum{NSQ,BIN,MULTI}; // also in neigh_list.cpp +static const char cite_neigh_multi[] = + "neighbor multi command:\n\n" + "@Article{intveld08,\n" + " author = {P.{\\,}J.~in{\\,}'t~Veld and S.{\\,}J.~Plimpton" + " and G.{\\,}S.~Grest},\n" + " title = {Accurate and Efficient Methods for Modeling Colloidal\n" + " Mixtures in an Explicit Solvent using Molecular Dynamics},\n" + " journal = {Comp.~Phys.~Comm.},\n" + " year = 2008,\n" + " volume = 179,\n" + " pages = {320--329}\n" + "}\n\n"; + //#define NEIGH_LIST_DEBUG 1 /* ---------------------------------------------------------------------- */ @@ -1644,6 +1658,8 @@ void Neighbor::set(int narg, char **arg) else if (strcmp(arg[1],"bin") == 0) style = BIN; else if (strcmp(arg[1],"multi") == 0) style = MULTI; else error->all(FLERR,"Illegal neighbor command"); + + if (style == MULTI && lmp->citeme) lmp->citeme->add(cite_neigh_multi); } /* ----------------------------------------------------------------------