BarryFSmith avatar BarryFSmith committed dff3164

-citations option causes the print out of approriate bibtex citation indices for all packages USED in the run
Most of the appropriate citations still need to be added

Comments (1)

  1. Jed Brown

    Need to initialize flg.

    Better:

    static const char hypreCitation[] = "Hypre";
    

    because we do not need address of pointer (or just use string literal).

    I would move newline handling inside rather than asking caller to do it.

    Might make output refer to our bibtex file.

    Need PetscFunctionBegin. I'm not convinced this should be inlined.

Files changed (7)

include/petscsys.h

  * possible. */
 PETSC_STATIC_INLINE PetscErrorCode PetscSegBufferGetInts(PetscSegBuffer seg,PetscInt count,PetscInt *PETSC_RESTRICT *slot) {return PetscSegBufferGet(seg,count,(void**)slot);}
 
+extern PetscSegBuffer PetscCitationsList;
+PETSC_STATIC_INLINE PetscErrorCode PetscCitationsRegister(const char cit[],PetscBool *set)
+{
+  size_t         len;
+  char           *vstring;
+  PetscErrorCode ierr;
+
+  if (set && *set) return 0;
+  ierr = PetscStrlen(cit,&len);CHKERRQ(ierr);
+  ierr = PetscSegBufferGet(PetscCitationsList,(PetscInt)len,&vstring);CHKERRQ(ierr);
+  ierr = PetscMemcpy(vstring,cit,len);CHKERRQ(ierr);
+  if (set) *set = PETSC_TRUE;
+  return 0;
+}
+
+
 /* Reset __FUNCT__ in case the user does not define it themselves */
 #undef __FUNCT__
 #define __FUNCT__ "User provided function"

src/ksp/pc/impls/hypre/hypre.c

 #include <petsc-private/pcimpl.h>          /*I "petscpc.h" I*/
 #include <../src/dm/impls/da/hypre/mhyp.h>
 
+static PetscBool cite = PETSC_FALSE;
+static const char *hypreCitation = "Hypre\n";
 /*
    Private context (data structure) for the  preconditioner.
 */
   PetscInt           hierr;
 
   PetscFunctionBegin;
+  ierr = PetscCitationsRegister(hypreCitation,&cite);CHKERRQ(ierr);
   if (!jac->applyrichardson) {ierr = VecSet(x,0.0);CHKERRQ(ierr);}
   ierr = VecGetArray(b,&bv);CHKERRQ(ierr);
   ierr = VecGetArray(x,&xv);CHKERRQ(ierr);
   PetscInt           hierr;
 
   PetscFunctionBegin;
+  ierr = PetscCitationsRegister(hypreCitation,&cite);CHKERRQ(ierr);
   ierr = VecSet(x,0.0);CHKERRQ(ierr);
   ierr = VecGetArray(b,&bv);CHKERRQ(ierr);
   ierr = VecGetArray(x,&xv);CHKERRQ(ierr);
   PetscInt       oits;
 
   PetscFunctionBegin;
+  ierr = PetscCitationsRegister(hypreCitation,&cite);CHKERRQ(ierr);
   PetscStackCallStandard(HYPRE_BoomerAMGSetMaxIter,(jac->hsolver,its*jac->maxiter));
   PetscStackCallStandard(HYPRE_BoomerAMGSetTol,(jac->hsolver,rtol));
   jac->applyrichardson = PETSC_TRUE;
   Mat_HYPREStruct *mx = (Mat_HYPREStruct*)(pc->pmat->data);
 
   PetscFunctionBegin;
+  ierr       = PetscCitationsRegister(hypreCitation,&cite);CHKERRQ(ierr);
   ierr       = DMDAGetCorners(mx->da,&ilower[0],&ilower[1],&ilower[2],&iupper[0],&iupper[1],&iupper[2]);CHKERRQ(ierr);
   iupper[0] += ilower[0] - 1;
   iupper[1] += ilower[1] - 1;
   PetscInt       oits;
 
   PetscFunctionBegin;
+  ierr = PetscCitationsRegister(hypreCitation,&cite);CHKERRQ(ierr);
   PetscStackCallStandard(HYPRE_StructPFMGSetMaxIter,(jac->hsolver,its*jac->its));
   PetscStackCallStandard(HYPRE_StructPFMGSetTol,(jac->hsolver,rtol));
 
   PetscInt         i;
 
   PetscFunctionBegin;
+  ierr       = PetscCitationsRegister(hypreCitation,&cite);CHKERRQ(ierr);
   ierr       = DMDAGetCorners(mx->da,&ilower[0],&ilower[1],&ilower[2],&iupper[0],&iupper[1],&iupper[2]);CHKERRQ(ierr);
   iupper[0] += ilower[0] - 1;
   iupper[1] += ilower[1] - 1;
   PetscInt       oits;
 
   PetscFunctionBegin;
+  ierr = PetscCitationsRegister(hypreCitation,&cite);CHKERRQ(ierr);
   PetscStackCallStandard(HYPRE_SStructSysPFMGSetMaxIter,(jac->ss_solver,its*jac->its));
   PetscStackCallStandard(HYPRE_SStructSysPFMGSetTol,(jac->ss_solver,rtol));
   ierr = PCApply_SysPFMG(pc,b,y);CHKERRQ(ierr);

src/mat/impls/aij/mpi/mumps/mumps.c

 #define __FUNCT__ "MatSolve_MUMPS"
 PetscErrorCode MatSolve_MUMPS(Mat A,Vec b,Vec x)
 {
-  Mat_MUMPS      *mumps=(Mat_MUMPS*)A->spptr;
-  PetscScalar    *array;
-  Vec            b_seq;
-  IS             is_iden,is_petsc;
-  PetscErrorCode ierr;
-  PetscInt       i;
+  Mat_MUMPS        *mumps=(Mat_MUMPS*)A->spptr;
+  PetscScalar      *array;
+  Vec              b_seq;
+  IS               is_iden,is_petsc;
+  PetscErrorCode   ierr;
+  PetscInt         i;
+  static PetscBool cite = PETSC_FALSE;
 
   PetscFunctionBegin;
+  ierr = PetscCitationsRegister("MUMPS\n",&cite);CHKERRQ(ierr);
   mumps->id.nrhs = 1;
   b_seq          = mumps->b_seq;
   if (mumps->size > 1) {

src/mat/impls/aij/mpi/superlu_dist/superlu_dist.c

   IS               iden;
   VecScatter       scat;
   int              info; /* SuperLU_Dist info code is ALWAYS an int, even with long long indices */
+  static PetscBool cite = PETSC_FALSE;
 
   PetscFunctionBegin;
+  ierr = PetscCitationsRegister("@article{lidemmel03,\n  author = {Xiaoye S. Li and James W. Demmel},\n  title = {{SuperLU_DIST}: A Scalable Distributed-Memory Sparse Direct\n           Solver for Unsymmetric Linear Systems},\n  journal = {ACM Trans. Mathematical Software},\n  volume = {29},\n  number = {2},\n  pages = {110-140},\n  year = 2003\n}\n",&cite);CHKERRQ(ierr);
   ierr = MPI_Comm_size(PetscObjectComm((PetscObject)A),&size);CHKERRQ(ierr);
   if (size > 1 && lu->MatInputMode == GLOBAL) {
     /* global mat input, convert b to x_seq */

src/mat/impls/aij/seq/seqcusp/aijcusp.cu

 #define __FUNCT__ "MatMult_SeqAIJCUSP"
 PetscErrorCode MatMult_SeqAIJCUSP(Mat A,Vec xx,Vec yy)
 {
-  Mat_SeqAIJ     *a = (Mat_SeqAIJ*)A->data;
-  PetscErrorCode ierr;
-  Mat_SeqAIJCUSP *cuspstruct = (Mat_SeqAIJCUSP*)A->spptr;
+  Mat_SeqAIJ       *a = (Mat_SeqAIJ*)A->data;
+  PetscErrorCode   ierr;
+  Mat_SeqAIJCUSP   *cuspstruct = (Mat_SeqAIJCUSP*)A->spptr;
 #if !defined(PETSC_HAVE_TXPETSCGPU)
-  PetscBool usecprow = a->compressedrow.use;
+  PetscBool        usecprow = a->compressedrow.use;
 #endif
-  CUSPARRAY *xarray=NULL,*yarray=NULL;
+  CUSPARRAY        *xarray=NULL,*yarray=NULL;
+  static PetscBool cite = PETSC_FALSE;
 
   PetscFunctionBegin;
+  ierr = PetscCitationsRegister("@incollection{msk2013,\n  author = {Victor Minden and Barry F. Smith and Matthew G. Knepley},\n  title = {Preliminary Implementation of {PETSc} Using {GPUs}},\n  booktitle = {GPU Solutions to Multi-scale Problems in Science and Engineering},\n  series = {Lecture Notes in Earth System Sciences},\n  editor = {David A. Yuen and Long Wang and Xuebin Chi and Lennart Johnsson and Wei Ge and Yaolin Shi},\n  publisher = {Springer Berlin Heidelberg},\n  pages = {131--140},\n  year = {2013},\n}\n,&cite);CHKERRQ(ierr);
   /* The line below should not be necessary as it has been moved to MatAssemblyEnd_SeqAIJCUSP
      ierr = MatCUSPCopyToGPU(A);CHKERRQ(ierr); */
   ierr = VecCUSPGetArrayRead(xx,&xarray);CHKERRQ(ierr);

src/mat/impls/aij/seq/superlu/superlu.c

 #define __FUNCT__ "MatSolve_SuperLU_Private"
 PetscErrorCode MatSolve_SuperLU_Private(Mat A,Vec b,Vec x)
 {
-  Mat_SuperLU    *lu = (Mat_SuperLU*)A->spptr;
-  PetscScalar    *barray,*xarray;
-  PetscErrorCode ierr;
-  PetscInt       info,i,n;
-  PetscReal      ferr,berr;
+  Mat_SuperLU      *lu = (Mat_SuperLU*)A->spptr;
+  PetscScalar      *barray,*xarray;
+  PetscErrorCode   ierr;
+  PetscInt         info,i,n;
+  PetscReal        ferr,berr;
+  static PetscBool cite = PETSC_FALSE;
 
   PetscFunctionBegin;
   if (lu->lwork == -1) PetscFunctionReturn(0);
+  ierr = PetscCitationsRegister("@article{superlu99,\n  author  = {James W. Demmel and Stanley C. Eisenstat and\n             John R. Gilbert and Xiaoye S. Li and Joseph W. H. Liu},\n  title = {A supernodal approach to sparse partial pivoting},\n  journal = {SIAM J. Matrix Analysis and Applications},\n  year = {1999},\n  volume  = {20},\n  number = {3},\n  pages = {720-755}\n}\n",&cite);CHKERRQ(ierr);
 
   ierr = VecGetLocalSize(x,&n);CHKERRQ(ierr);
   lu->B.ncol = 1;   /* Set the number of right-hand side */

src/sys/objects/pinit.c

 
 int  PetscGlobalArgc   = 0;
 char **PetscGlobalArgs = 0;
+PetscSegBuffer PetscCitationsList; 
 
 #undef __FUNCT__
 #define __FUNCT__ "PetscGetArgs"
   ierr = PetscFPTCreate(10000);CHKERRQ(ierr);
 #endif
 
+  ierr = PetscSegBufferCreate(1,10000,&PetscCitationsList);CHKERRQ(ierr);
+  ierr = PetscCitationsRegister("@TechReport{petsc-user-ref,\n  Author = {Satish Balay and Jed Brown and and Kris Buschelman and Victor Eijkhout\n            and William D.  Gropp and Dinesh Kaushik and Matthew G. Knepley\n            and Lois Curfman McInnes and Barry F. Smith and Hong Zhang},\n  Title = {{PETS}c Users Manual},\n  Number = {ANL-95/11 - Revision 3.4},\n  Institution = {Argonne National Laboratory},\n  Year = {2013}\n}\n",NULL);CHKERRQ(ierr);
+  ierr = PetscCitationsRegister("@InProceedings{petsc-efficient,\n  Author = {Satish Balay and William D. Gropp and Lois Curfman McInnes and Barry F. Smith},\n  Title = {Efficient Management of Parallelism in Object Oriented Numerical Software Libraries},\n  Booktitle = {Modern Software Tools in Scientific Computing},\n  Editor = {E. Arge and A. M. Bruaset and H. P. Langtangen},\n  Pages = {163--202},\n  Publisher = {Birkh{\\\"{a}}user Press},\n  Year = {1997}\n}\n",NULL);CHKERRQ(ierr);
+
   /*
       Once we are completedly initialized then we can set this variables
   */
   PetscMPIInt    rank;
   PetscInt       nopt;
   PetscBool      flg1 = PETSC_FALSE,flg2 = PETSC_FALSE,flg3 = PETSC_FALSE;
-#if defined(PETSC_HAVE_AMS)
-  PetscBool      flg = PETSC_FALSE;
-#endif
+  PetscBool      flg;
 #if defined(PETSC_USE_LOG)
   char           mname[PETSC_MAX_PATH_LEN];
 #endif
   }
   ierr = PetscInfo(NULL,"PetscFinalize() called\n");CHKERRQ(ierr);
 
+  ierr = PetscOptionsGetBool(NULL,"-citations",&flg,NULL);CHKERRQ(ierr);
+  if (flg) {
+    char *cits;
+    ierr = PetscSegBufferGet(PetscCitationsList,1,&cits);CHKERRQ(ierr);
+    cits[0] = 0;
+    ierr = PetscSegBufferExtractAlloc(PetscCitationsList,&cits);CHKERRQ(ierr);
+    ierr = PetscPrintf(PETSC_COMM_WORLD,"If you publish results based on this computation please cite the following:\n");CHKERRQ(ierr);
+    ierr = PetscPrintf(PETSC_COMM_WORLD,"%s",cits);CHKERRQ(ierr);
+    ierr = PetscFree(cits);CHKERRQ(ierr);
+  }
+  ierr = PetscSegBufferDestroy(&PetscCitationsList);CHKERRQ(ierr);
+
 #if defined(PETSC_SERIALIZE_FUNCTIONS)
   ierr = PetscFPTDestroy();CHKERRQ(ierr);
 #endif
 
 
 #if defined(PETSC_HAVE_AMS)
+  flg = PETSC_FALSE;
   ierr = PetscOptionsGetBool(NULL,"-options_gui",&flg,NULL);CHKERRQ(ierr);
   if (flg) {
     ierr = PetscOptionsAMSDestroy();CHKERRQ(ierr);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.