Actual source code: init.c

  1: /*

  3:    This file defines part of the initialization of PETSc

  5:   This file uses regular malloc and free because it cannot know 
  6:   what malloc is being used until it has already processed the input.
  7: */

 9:  #include petsc.h
 10:  #include petscsys.h
 11: #if defined(PETSC_HAVE_STDLIB_H)
 12: #include <stdlib.h>
 13: #endif
 14: #if defined(PETSC_HAVE_MALLOC_H) && !defined(__cplusplus)
 15: #include <malloc.h>
 16: #endif
 17: #include "petscfix.h"

 19: /* ------------------------Nasty global variables -------------------------------*/
 20: /*
 21:      Indicates if PETSc started up MPI, or it was 
 22:    already started before PETSc was initialized.
 23: */
 24: PetscTruth  PetscBeganMPI         = PETSC_FALSE;
 25: PetscTruth  PetscInitializeCalled = PETSC_FALSE;
 26: PetscMPIInt PetscGlobalRank = -1,PetscGlobalSize = -1;
 27: MPI_Comm    PETSC_COMM_WORLD = 0;
 28: MPI_Comm    PETSC_COMM_SELF  = 0;

 30: #if defined(PETSC_USE_COMPLEX)
 31: #if defined(PETSC_COMPLEX_INSTANTIATE)
 32: template <> class std::complex<double>; /* instantiate complex template class */
 33: #endif
 34: MPI_Datatype  MPIU_COMPLEX;
 35: PetscScalar   PETSC_i;
 36: #else
 37: PetscScalar   PETSC_i = 0.0;
 38: #endif
 39: MPI_Datatype  MPIU_2SCALAR = 0;
 40: MPI_Datatype  MPIU_2INT = 0;
 41: /*
 42:      These are needed by petscbt.h
 43: */
 44: char      _BT_mask = ' ',_BT_c = ' ';
 45: PetscInt  _BT_idx  = 0;

 47: /*
 48:        Function that is called to display all error messages
 49: */
 50: EXTERN PetscErrorCode  PetscErrorPrintfDefault(const char [],...);
 51: EXTERN PetscErrorCode  PetscHelpPrintfDefault(MPI_Comm,const char [],...);
 52: PetscErrorCode (*PetscErrorPrintf)(const char [],...)          = PetscErrorPrintfDefault;
 53: PetscErrorCode (*PetscHelpPrintf)(MPI_Comm,const char [],...)  = PetscHelpPrintfDefault;

 55: /* ------------------------------------------------------------------------------*/
 56: /* 
 57:    Optional file where all PETSc output from various prints is saved
 58: */
 59: FILE *petsc_history = PETSC_NULL;

 63: PetscErrorCode PetscLogOpenHistoryFile(const char filename[],FILE **fd)
 64: {
 66:   PetscMPIInt    rank,size;
 67:   char           pfile[PETSC_MAX_PATH_LEN],pname[PETSC_MAX_PATH_LEN],fname[PETSC_MAX_PATH_LEN],date[64];
 68:   char           version[256];

 71:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
 72:   if (!rank) {
 73:     char arch[10];
 74:     PetscGetArchType(arch,10);
 75:     PetscGetDate(date,64);
 76:     PetscGetVersion(&version);
 77:     MPI_Comm_size(PETSC_COMM_WORLD,&size);
 78:     if (filename) {
 79:       PetscFixFilename(filename,fname);
 80:     } else {
 81:       PetscGetHomeDirectory(pfile,240);
 82:       PetscStrcat(pfile,"/.petschistory");
 83:       PetscFixFilename(pfile,fname);
 84:     }

 86:     *fd = fopen(fname,"a"); if (!fd) SETERRQ1(PETSC_ERR_FILE_OPEN,"Cannot open file: %s",fname);
 87:     PetscFPrintf(PETSC_COMM_SELF,*fd,"---------------------------------------------------------\n");
 88:     PetscFPrintf(PETSC_COMM_SELF,*fd,"%s %s\n",version,date);
 89:     PetscGetProgramName(pname,PETSC_MAX_PATH_LEN);
 90:     PetscFPrintf(PETSC_COMM_SELF,*fd,"%s on a %s, %d proc. with options:\n",pname,arch,size);
 91:     PetscOptionsPrint(*fd);
 92:     PetscFPrintf(PETSC_COMM_SELF,*fd,"---------------------------------------------------------\n");
 93:     fflush(*fd);
 94:   }
 95:   return(0);
 96: }

100: PetscErrorCode PetscLogCloseHistoryFile(FILE **fd)
101: {
103:   PetscMPIInt    rank;
104:   char           date[64];

107:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
108:   if (!rank) {
109:     PetscGetDate(date,64);
110:     PetscFPrintf(PETSC_COMM_SELF,*fd,"---------------------------------------------------------\n");
111:     PetscFPrintf(PETSC_COMM_SELF,*fd,"Finished at %s\n",date);
112:     PetscFPrintf(PETSC_COMM_SELF,*fd,"---------------------------------------------------------\n");
113:     fflush(*fd);
114:     fclose(*fd);
115:   }
116:   return(0);
117: }

119: /* ------------------------------------------------------------------------------*/

121: PetscTruth PetscCompare          = PETSC_FALSE;
122: PetscReal  PetscCompareTolerance = 1.e-10;

126: /*@C
127:    PetscCompareInt - Compares integers while running with PETScs incremental
128:    debugger.

130:    Collective on PETSC_COMM_WORLD

132:    Input Parameter:
133: .  d - integer to compare

135:    Options Database Key:
136: .  -compare - Activates PetscCompareDouble(), PetscCompareInt(), and PetscCompareScalar()

138:    Level: advanced

140: .seealso: PetscCompareDouble(), PetscCompareScalar()
141: @*/
142: PetscErrorCode PetscCompareInt(PetscInt d)
143: {
145:   PetscInt       work = d;

148:   MPI_Bcast(&work,1,MPIU_INT,0,MPI_COMM_WORLD);
149:   if (d != work) {
150:     SETERRQ(PETSC_ERR_PLIB,"Inconsistent integer");
151:   }
152:   return(0);
153: }

157: /*@C
158:    PetscCompareDouble - Compares doubles while running with PETScs incremental
159:    debugger.

161:    Collective on PETSC_COMM_WORLD

163:    Input Parameter:
164: .  d - double precision number to compare

166:    Options Database Key:
167: .  -compare - Activates PetscCompareDouble(), PetscCompareInt(), and PetscCompareScalar()

169:    Level: advanced

171: .seealso: PetscCompareInt(), PetscComparseScalar()
172: @*/
173: PetscErrorCode PetscCompareDouble(double d)
174: {
175:   double         work = d;

179:   MPI_Bcast(&work,1,MPIU_REAL,0,MPI_COMM_WORLD);
180:   if (!d && !work) return(0);
181:   if (PetscAbsReal(work - d)/PetscMax(PetscAbsReal(d),PetscAbsReal(work)) > PetscCompareTolerance) {
182:     SETERRQ(PETSC_ERR_PLIB,"Inconsistent double");
183:   }
184:   return(0);
185: }

189: /*@C
190:    PetscCompareScalar - Compares scalars while running with PETScs incremental
191:    debugger.

193:    Collective on PETSC_COMM_WORLD

195:    Input Parameter:
196: .  d - scalar to compare

198:    Options Database Key:
199: .  -compare - Activates PetscCompareDouble(), PetscCompareInt(), and PetscCompareScalar()

201:    Level: advanced

203: .seealso: PetscCompareInt(), PetscComparseDouble()
204: @*/
205: PetscErrorCode PetscCompareScalar(PetscScalar d)
206: {
207:   PetscScalar    work = d;

211:   MPI_Bcast(&work,2,MPIU_REAL,0,MPI_COMM_WORLD);
212:   if (!PetscAbsScalar(d) && !PetscAbsScalar(work)) return(0);
213:   if (PetscAbsScalar(work - d)/PetscMax(PetscAbsScalar(d),PetscAbsScalar(work)) >= PetscCompareTolerance) {
214:     SETERRQ(PETSC_ERR_PLIB,"Inconsistent scalar");
215:   }
216:   return(0);
217: }

221: /*
222:     PetscCompareInitialize - If there is a command line option -compare then
223:     this routine calls MPI_Init() and sets up two PETSC_COMM_WORLD, one for 
224:     each program being compared.

226:     Note: 
227:     Only works with C programs.
228: */
229: PetscErrorCode PetscCompareInitialize(double tol)
230: {
232:   PetscMPIInt    rank,size,i,*gflag,mysize;
233:   char           pname[PETSC_MAX_PATH_LEN],bname[PETSC_MAX_PATH_LEN];
234:   MPI_Group      group_all,group_sub;
235:   PetscTruth     work;

238:   PetscGetProgramName(pname,PETSC_MAX_PATH_LEN);
239:   PetscCompareTolerance = tol;

241:   MPI_Comm_rank(MPI_COMM_WORLD,&rank);
242:   MPI_Comm_size(MPI_COMM_WORLD,&size);
243:   if (!rank) {
244:     PetscStrcpy(bname,pname);
245:   }

247:   /* broadcase name from first processor to all processors */
248:   MPI_Bcast(bname,PETSC_MAX_PATH_LEN,MPI_CHAR,0,MPI_COMM_WORLD);

250:   /* determine what processors belong to my group */
251:   PetscStrcmp(pname,bname,&work);

253:   gflag = (int*)malloc(size*sizeof(PetscMPIInt));
254:   MPI_Allgather(&work,1,MPI_INT,gflag,1,MPI_INT,MPI_COMM_WORLD);
255:   mysize = 0;
256:   for (i=0; i<size; i++) {
257:     if ((int) work == gflag[i]) gflag[mysize++] = i;
258:   }
259:   if (!mysize || mysize == size) {
260:     SETERRQ(PETSC_ERR_ARG_IDN,"Need two different programs to compare");
261:   }

263:   /* create a new communicator for each program */
264:   MPI_Comm_group(MPI_COMM_WORLD,&group_all);
265:   MPI_Group_incl(group_all,mysize,gflag,&group_sub);
266:   MPI_Comm_create(MPI_COMM_WORLD,group_sub,&PETSC_COMM_WORLD);
267:   MPI_Group_free(&group_all);
268:   MPI_Group_free(&group_sub);
269:   free(gflag);

271:   PetscCompare = PETSC_TRUE;
272:   PetscLogInfo(0,"PetscCompareInitialize:Configured to compare two programs\n");
273:   return(0);
274: }
275: /* ------------------------------------------------------------------------------------*/

277: 
278: /* 
279:    This is ugly and probably belongs somewhere else, but I want to 
280:   be able to put a true MPI abort error handler with command line args.

282:     This is so MPI errors in the debugger will leave all the stack 
283:   frames. The default abort cleans up and exits.
284: */

288: void Petsc_MPI_AbortOnError(MPI_Comm *comm,PetscMPIInt *flag)
289: {
291:   (*PetscErrorPrintf)("MPI error %d\n",(int)*flag);
292:   abort();
293: }

297: void Petsc_MPI_DebuggerOnError(MPI_Comm *comm,PetscMPIInt *flag)
298: {

302:   (*PetscErrorPrintf)("MPI error %d\n",(int)*flag);
303:   PetscAttachDebugger();
304:   if (ierr) { /* hopeless so get out */
305:     MPI_Finalize();
306:     exit(*flag);
307:   }
308: }

312: /*@C 
313:    PetscEnd - Calls PetscFinalize() and then ends the program. This is useful if one 
314:      wishes a clean exit somewhere deep in the program.

316:    Collective on PETSC_COMM_WORLD

318:    Options Database Keys are the same as for PetscFinalize()

320:    Level: advanced

322:    Note:
323:    See PetscInitialize() for more general runtime options.

325: .seealso: PetscInitialize(), PetscOptionsPrint(), PetscTrDump(), PetscMPIDump(), PetscFinalize()
326: @*/
327: PetscErrorCode PetscEnd(void)
328: {
330:   PetscFinalize();
331:   exit(0);
332:   return 0;
333: }

335: PetscTruth   PetscOptionsPublish = PETSC_FALSE;
336: EXTERN PetscErrorCode        PetscSetUseTrMalloc_Private(void);
338: static char       emacsmachinename[256];

340: PetscErrorCode (*PetscExternalVersionFunction)(MPI_Comm) = 0;
341: PetscErrorCode (*PetscExternalHelpFunction)(MPI_Comm)    = 0;

345: /*@C 
346:    PetscSetHelpVersionFunctions - Sets functions that print help and version information
347:    before the PETSc help and version information is printed. Must call BEFORE PetscInitialize().
348:    This routine enables a "higher-level" package that uses PETSc to print its messages first.

350:    Input Parameter:
351: +  help - the help function (may be PETSC_NULL)
352: -  version - the version function (may be PETSc null)

354:    Level: developer

356:    Concepts: package help message

358: @*/
359: PetscErrorCode PetscSetHelpVersionFunctions(PetscErrorCode (*help)(MPI_Comm),PetscErrorCode (*version)(MPI_Comm))
360: {
362:   PetscExternalHelpFunction    = help;
363:   PetscExternalVersionFunction = version;
364:   return(0);
365: }

369: PetscErrorCode PetscOptionsCheckInitial_Private(void)
370: {
371:   char           string[64],mname[PETSC_MAX_PATH_LEN],*f;
372:   MPI_Comm       comm = PETSC_COMM_WORLD;
373:   PetscTruth     flg1,flg2,flg3,flag;
375:   PetscInt       si;
376:   int            i;
377:   PetscMPIInt    rank;
378:   char           version[256];

381:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);

383:   /*
384:       Setup the memory management; support for tracing malloc() usage 
385:   */
386:   PetscOptionsHasName(PETSC_NULL,"-trmalloc_log",&flg3);
387: #if defined(PETSC_USE_BOPT_g)
388:   PetscOptionsGetLogical(PETSC_NULL,"-trmalloc",&flg1,&flg2);
389:   if ((!flg2 || flg1) && !petscsetmallocvisited) {
390:     PetscSetUseTrMalloc_Private();
391:   }
392: #else
393:   PetscOptionsHasName(PETSC_NULL,"-trdump",&flg1);
394:   PetscOptionsHasName(PETSC_NULL,"-trmalloc",&flg2);
395:   if (flg1 || flg2 || flg3) {PetscSetUseTrMalloc_Private();}
396: #endif
397:   if (flg3) {
398:     PetscTrLog();
399:   }
400:   PetscOptionsHasName(PETSC_NULL,"-trdebug",&flg1);
401:   if (flg1) {
402:     PetscSetUseTrMalloc_Private();
403:     PetscTrDebug(PETSC_TRUE);
404:   }

406:   /*
407:       Set the display variable for graphics
408:   */
409:   PetscSetDisplay();

411:   /*
412:       Print the PETSc version information
413:   */
414:   PetscOptionsHasName(PETSC_NULL,"-v",&flg1);
415:   PetscOptionsHasName(PETSC_NULL,"-version",&flg2);
416:   PetscOptionsHasName(PETSC_NULL,"-help",&flg3);
417:   if (flg1 || flg2 || flg3){

419:     /*
420:        Print "higher-level" package version message 
421:     */
422:     if (PetscExternalVersionFunction) {
423:       (*PetscExternalVersionFunction)(comm);
424:     }

426:     PetscGetVersion(&version);
427:     (*PetscHelpPrintf)(comm,"--------------------------------------------\
428: ------------------------------\n");
429:     (*PetscHelpPrintf)(comm,"%s\n",version);
430:     (*PetscHelpPrintf)(comm,"%s",PETSC_AUTHOR_INFO);
431:     (*PetscHelpPrintf)(comm,"See docs/copyright.html for copyright information\n");
432:     (*PetscHelpPrintf)(comm,"See docs/changes/index.html for recent updates.\n");
433:     (*PetscHelpPrintf)(comm,"See docs/troubleshooting.html for problems.\n");
434:     (*PetscHelpPrintf)(comm,"See docs/manualpages/index.html for help. \n");
435:     (*PetscHelpPrintf)(comm,"Libraries linked from %s\n",PETSC_LIB_DIR);
436:     (*PetscHelpPrintf)(comm,"--------------------------------------------\
437: ------------------------------\n");
438:   }

440:   /*
441:        Print "higher-level" package help message 
442:   */
443:   if (flg3){
444:     if (PetscExternalHelpFunction) {
445:       (*PetscExternalHelpFunction)(comm);
446:     }
447:   }

449:   /*
450:       Setup the error handling
451:   */
452:   PetscOptionsHasName(PETSC_NULL,"-fp_trap",&flg1);
453:   if (flg1) { PetscSetFPTrap(PETSC_FP_TRAP_ON); }
454:   PetscOptionsHasName(PETSC_NULL,"-on_error_abort",&flg1);
455:   if (flg1) { PetscPushErrorHandler(PetscAbortErrorHandler,0);CHKERRQ(ierr)}
456:   PetscOptionsHasName(PETSC_NULL,"-on_error_stop",&flg1);
457:   if (flg1) { PetscPushErrorHandler(PetscStopErrorHandler,0);CHKERRQ(ierr)}
458:   PetscOptionsHasName(PETSC_NULL,"-mpi_return_on_error",&flg1);
459:   if (flg1) {
460:     MPI_Errhandler_set(comm,MPI_ERRORS_RETURN);
461:   }
462:   PetscOptionsHasName(PETSC_NULL,"-no_signal_handler",&flg1);
463:   if (!flg1) { PetscPushSignalHandler(PetscDefaultSignalHandler,(void*)0);CHKERRQ(ierr) }

465:   /*
466:       Setup debugger information
467:   */
468:   PetscSetDefaultDebugger();
469:   PetscOptionsGetString(PETSC_NULL,"-on_error_attach_debugger",string,64,&flg1);
470:   if (flg1) {
471:     MPI_Errhandler err_handler;

473:     PetscSetDebuggerFromString(string);
474:     MPI_Errhandler_create((MPI_Handler_function*)Petsc_MPI_DebuggerOnError,&err_handler);
475:     MPI_Errhandler_set(comm,err_handler);
476:     PetscPushErrorHandler(PetscAttachDebuggerErrorHandler,0);
477:   }
478:   PetscOptionsGetString(PETSC_NULL,"-start_in_debugger",string,64,&flg1);
479:   PetscOptionsGetString(PETSC_NULL,"-stop_for_debugger",string,64,&flg2);
480:   if (flg1 || flg2) {
481:     PetscMPIInt    size;
482:     PetscInt       lsize,*nodes;
483:     MPI_Errhandler err_handler;
484:     /*
485:        we have to make sure that all processors have opened 
486:        connections to all other processors, otherwise once the 
487:        debugger has stated it is likely to receive a SIGUSR1
488:        and kill the program. 
489:     */
490:     MPI_Comm_size(PETSC_COMM_WORLD,&size);
491:     if (size > 2) {
492:       PetscMPIInt dummy;
493:       MPI_Status  status;
494:       for (i=0; i<size; i++) {
495:         MPI_Send(&dummy,1,MPI_INT,i,109,PETSC_COMM_WORLD);
496:       }
497:       for (i=0; i<size; i++) {
498:         MPI_Recv(&dummy,1,MPI_INT,i,109,PETSC_COMM_WORLD,&status);
499:       }
500:     }
501:     /* check if this processor node should be in debugger */
502:     PetscMalloc(size*sizeof(PetscInt),&nodes);
503:     lsize = size;
504:     PetscOptionsGetIntArray(PETSC_NULL,"-debugger_nodes",nodes,&lsize,&flag);
505:     if (flag) {
506:       for (i=0; i<lsize; i++) {
507:         if (nodes[i] == rank) { flag = PETSC_FALSE; break; }
508:       }
509:     }
510:     if (!flag) {
511:       PetscSetDebuggerFromString(string);
512:       PetscPushErrorHandler(PetscAbortErrorHandler,0);
513:       if (flg1) {
514:         PetscAttachDebugger();
515:       } else {
516:         PetscStopForDebugger();
517:       }
518:       MPI_Errhandler_create((MPI_Handler_function*)Petsc_MPI_AbortOnError,&err_handler);
519:       MPI_Errhandler_set(comm,err_handler);
520:     }
521:     PetscFree(nodes);
522:   }

524:   PetscOptionsGetString(PETSC_NULL,"-on_error_emacs",emacsmachinename,128,&flg1);
525:   if (flg1 && !rank) {PetscPushErrorHandler(PetscEmacsClientErrorHandler,emacsmachinename);CHKERRQ(ierr)}

527:   /*
528:         Setup profiling and logging
529:   */
530: #if defined(PETSC_USE_LOG)
531:   mname[0] = 0;
532:   PetscOptionsGetString(PETSC_NULL,"-log_history",mname,PETSC_MAX_PATH_LEN,&flg1);
533:   if (flg1) {
534:     if (mname[0]) {
535:       PetscLogOpenHistoryFile(mname,&petsc_history);
536:     } else {
537:       PetscLogOpenHistoryFile(0,&petsc_history);
538:     }
539:   }
540:   PetscOptionsHasName(PETSC_NULL,"-log_info",&flg1);
541:   if (flg1) {
542:     char logname[PETSC_MAX_PATH_LEN]; logname[0] = 0;
543:     PetscOptionsGetString(PETSC_NULL,"-log_info",logname,250,&flg1);
544:     if (logname[0]) {
545:       PetscLogInfoAllow(PETSC_TRUE,logname);
546:     } else {
547:       PetscLogInfoAllow(PETSC_TRUE,PETSC_NULL);
548:     }
549:   }
550: #if defined(PETSC_HAVE_MPE)
551:   PetscOptionsHasName(PETSC_NULL,"-log_mpe",&flg1);
552:   if (flg1) PetscLogMPEBegin();
553: #endif
554:   PetscOptionsHasName(PETSC_NULL,"-log_all",&flg1);
555:   PetscOptionsHasName(PETSC_NULL,"-log",&flg2);
556:   PetscOptionsHasName(PETSC_NULL,"-log_summary",&flg3);
557:   if (flg1)              {  PetscLogAllBegin(); }
558:   else if (flg2 || flg3) {  PetscLogBegin();}
559: 
560:   PetscOptionsGetString(PETSC_NULL,"-log_trace",mname,250,&flg1);
561:   if (flg1) {
562:     char name[PETSC_MAX_PATH_LEN],fname[PETSC_MAX_PATH_LEN];
563:     FILE *file;
564:     if (mname[0]) {
565:       sprintf(name,"%s.%d",mname,rank);
566:       PetscFixFilename(name,fname);
567:       file = fopen(fname,"w");
568:       if (!file) {
569:         SETERRQ1(PETSC_ERR_FILE_OPEN,"Unable to open trace file: %s",fname);
570:       }
571:     } else {
572:       file = stdout;
573:     }
574:     PetscLogTraceBegin(file);
575:   }
576: #endif

578:   /*
579:       Setup building of stack frames for all function calls
580:   */
581: #if defined(PETSC_USE_STACK)
582: #if defined(PETSC_USE_BOPT_g)
583:   PetscStackCreate();
584: #else
585:   PetscOptionsHasName(PETSC_NULL,"-log_stack",&flg1);
586:   if (flg1) {
587:     PetscStackCreate();
588:   }
589: #endif
590: #endif


593:   /*
594:        Print basic help message
595:   */
596:   PetscOptionsHasName(PETSC_NULL,"-help",&flg1);
597:   if (flg1) {
598:     (*PetscHelpPrintf)(comm,"Options for all PETSc programs:\n");
599:     (*PetscHelpPrintf)(comm," -on_error_abort: cause an abort when an error is");
600:     (*PetscHelpPrintf)(comm," detected. Useful \n       only when run in the debugger\n");
601:     (*PetscHelpPrintf)(comm," -on_error_attach_debugger [gdb,dbx,xxgdb,ups,noxterm]\n");
602:     (*PetscHelpPrintf)(comm,"       start the debugger in new xterm\n");
603:     (*PetscHelpPrintf)(comm,"       unless noxterm is given\n");
604:     (*PetscHelpPrintf)(comm," -start_in_debugger [gdb,dbx,xxgdb,ups,noxterm]\n");
605:     (*PetscHelpPrintf)(comm,"       start all processes in the debugger\n");
606:     (*PetscHelpPrintf)(comm," -on_error_emacs <machinename>\n");
607:     (*PetscHelpPrintf)(comm,"    emacs jumps to error file\n");
608:     (*PetscHelpPrintf)(comm," -debugger_nodes [n1,n2,..] Nodes to start in debugger\n");
609:     (*PetscHelpPrintf)(comm," -debugger_pause [m] : delay (in seconds) to attach debugger\n");
610:     (*PetscHelpPrintf)(comm," -stop_for_debugger : prints message on how to attach debugger manually\n");
611:     (*PetscHelpPrintf)(comm,"                      waits the delay for you to attach\n");
612:     (*PetscHelpPrintf)(comm," -display display: Location where graphics and debuggers are displayed\n");
613:     (*PetscHelpPrintf)(comm," -no_signal_handler: do not trap error signals\n");
614:     (*PetscHelpPrintf)(comm," -mpi_return_on_error: MPI returns error code, rather than abort on internal error\n");
615:     (*PetscHelpPrintf)(comm," -fp_trap: stop on floating point exceptions\n");
616:     (*PetscHelpPrintf)(comm,"           note on IBM RS6000 this slows run greatly\n");
617:     (*PetscHelpPrintf)(comm," -trdump <optional filename>: dump list of unfreed memory at conclusion\n");
618:     (*PetscHelpPrintf)(comm," -trmalloc: use our error checking malloc\n");
619:     (*PetscHelpPrintf)(comm," -trmalloc no: don't use error checking malloc\n");
620:     (*PetscHelpPrintf)(comm," -trinfo: prints total memory usage\n");
621:     (*PetscHelpPrintf)(comm," -trdebug: enables extended checking for memory corruption\n");
622:     (*PetscHelpPrintf)(comm," -options_table: dump list of options inputted\n");
623:     (*PetscHelpPrintf)(comm," -options_left: dump list of unused options\n");
624:     (*PetscHelpPrintf)(comm," -options_left no: don't dump list of unused options\n");
625:     (*PetscHelpPrintf)(comm," -tmp tmpdir: alternative /tmp directory\n");
626:     (*PetscHelpPrintf)(comm," -shared_tmp: tmp directory is shared by all processors\n");
627:     (*PetscHelpPrintf)(comm," -not_shared_tmp: each processor has seperate tmp directory\n");
628:     (*PetscHelpPrintf)(comm," -get_resident_set_size: print memory usage at end of run\n");
629: #if defined(PETSC_USE_LOG)
630:     (*PetscHelpPrintf)(comm," -get_total_flops: total flops over all processors\n");
631:     (*PetscHelpPrintf)(comm," -log[_all _summary]: logging objects and events\n");
632:     (*PetscHelpPrintf)(comm," -log_trace [filename]: prints trace of all PETSc calls\n");
633: #if defined(PETSC_HAVE_MPE)
634:     (*PetscHelpPrintf)(comm," -log_mpe: Also create logfile viewable through upshot\n");
635: #endif
636:     (*PetscHelpPrintf)(comm," -log_info <optional filename>: print informative messages about the calculations\n");
637: #endif
638:     (*PetscHelpPrintf)(comm," -v: prints PETSc version number and release date\n");
639:     (*PetscHelpPrintf)(comm," -options_file <file>: reads options from file\n");
640:     (*PetscHelpPrintf)(comm," -petsc_sleep n: sleeps n seconds before running program\n");
641:     (*PetscHelpPrintf)(comm,"-----------------------------------------------\n");
642:   }

644:   /*
645:       Setup advanced compare feature for allowing comparison to two running PETSc programs
646:   */
647:   PetscOptionsHasName(PETSC_NULL,"-compare",&flg1);
648:   if (flg1) {
649:      PetscReal tol = 1.e-12;
650:      PetscOptionsGetReal(PETSC_NULL,"-compare",&tol,&flg1);
651:      PetscCompareInitialize(tol);
652:   }
653:   PetscOptionsGetInt(PETSC_NULL,"-petsc_sleep",&si,&flg1);
654:   if (flg1) {
655:     PetscSleep(si);
656:   }

658:   PetscOptionsGetString(PETSC_NULL,"-log_info_exclude",mname,PETSC_MAX_PATH_LEN,&flg1);
659:   PetscStrstr(mname,"null",&f);
660:   if (f) {
661:     PetscLogInfoDeactivateClass(PETSC_NULL);
662:   }

664:   return(0);
665: }