git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@10491 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2013-07-30 19:52:46 +00:00
parent 8fff5ac7a1
commit 059eb04e39
5 changed files with 148 additions and 1 deletions

72
src/citeme.cpp Normal file
View File

@ -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);
}

42
src/citeme.h Normal file
View File

@ -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 <set>
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<const char *> citeset;
citeset *cs; // registered set of publications
};
}
#endif
/* ERROR/WARNING messages:
*/

View File

@ -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 {

View File

@ -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();

View File

@ -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);
}
/* ----------------------------------------------------------------------