Actual source code: init.c

petsc-3.3-p7 2013-05-11
  1: /*

  3:    This file defines part of the initialization of PETSc

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

  9: #include <petscsys.h>        /*I  "petscsys.h"   I*/

 11: #if defined(PETSC_HAVE_SYS_SYSINFO_H)
 12: #include <sys/sysinfo.h>
 13: #endif
 14: #if defined(PETSC_HAVE_UNISTD_H)
 15: #include <unistd.h>
 16: #endif
 17: #if defined(PETSC_HAVE_STDLIB_H)
 18: #include <stdlib.h>
 19: #endif
 20: #if defined(PETSC_HAVE_MALLOC_H)
 21: #include <malloc.h>
 22: #endif
 23: #if defined(PETSC_HAVE_VALGRIND)
 24: #  include <valgrind/valgrind.h>
 25: #  define PETSC_RUNNING_ON_VALGRIND RUNNING_ON_VALGRIND
 26: #else
 27: #  define PETSC_RUNNING_ON_VALGRIND PETSC_FALSE
 28: #endif

 30: /* ------------------------Nasty global variables -------------------------------*/
 31: /*
 32:      Indicates if PETSc started up MPI, or it was 
 33:    already started before PETSc was initialized.
 34: */
 35: PetscBool    PetscBeganMPI         = PETSC_FALSE;
 36: PetscBool    PetscInitializeCalled = PETSC_FALSE;
 37: PetscBool    PetscFinalizeCalled   = PETSC_FALSE;
 38: PetscMPIInt  PetscGlobalRank = -1;
 39: PetscMPIInt  PetscGlobalSize = -1;

 41: #if defined(PETSC_USE_COMPLEX)
 42: #if defined(PETSC_COMPLEX_INSTANTIATE)
 43: template <> class std::complex<double>; /* instantiate complex template class */
 44: #endif
 45: #if !defined(PETSC_HAVE_MPI_C_DOUBLE_COMPLEX)
 46: MPI_Datatype   MPIU_C_DOUBLE_COMPLEX;
 47: MPI_Datatype   MPIU_C_COMPLEX;
 48: #endif
 49: PetscScalar    PETSC_i;
 50: #else
 51: PetscScalar    PETSC_i = 0.0;
 52: #endif
 53: #if defined(PETSC_USE_REAL___FLOAT128)
 54: MPI_Datatype   MPIU___FLOAT128 = 0;
 55: #endif
 56: MPI_Datatype   MPIU_2SCALAR = 0;
 57: MPI_Datatype   MPIU_2INT = 0;

 59: /*
 60:        Function that is called to display all error messages
 61: */
 62: PetscErrorCode  (*PetscErrorPrintf)(const char [],...)          = PetscErrorPrintfDefault;
 63: PetscErrorCode  (*PetscHelpPrintf)(MPI_Comm,const char [],...)  = PetscHelpPrintfDefault;
 64: #if defined(PETSC_HAVE_MATLAB_ENGINE)
 65: PetscErrorCode  (*PetscVFPrintf)(FILE*,const char[],va_list)    = PetscVFPrintf_Matlab;
 66: #else
 67: PetscErrorCode  (*PetscVFPrintf)(FILE*,const char[],va_list)    = PetscVFPrintfDefault;
 68: #endif
 69: /*
 70:   This is needed to turn on/off cusp synchronization 
 71: */
 72: PetscBool   PetscCUSPSynchronize = PETSC_FALSE;

 74: /* pthread_key for PetscStack */
 75: #if defined(PETSC_HAVE_PTHREADCLASSES) && !defined(PETSC_PTHREAD_LOCAL)
 76: pthread_key_t petscstack_key;
 77: #endif

 79: /* ------------------------------------------------------------------------------*/
 80: /* 
 81:    Optional file where all PETSc output from various prints is saved
 82: */
 83: FILE *petsc_history = PETSC_NULL;

 87: PetscErrorCode  PetscOpenHistoryFile(const char filename[],FILE **fd)
 88: {
 90:   PetscMPIInt    rank,size;
 91:   char           pfile[PETSC_MAX_PATH_LEN],pname[PETSC_MAX_PATH_LEN],fname[PETSC_MAX_PATH_LEN],date[64];
 92:   char           version[256];

 95:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
 96:   if (!rank) {
 97:     char        arch[10];
 98:     int         err;
 99:     PetscViewer viewer;

101:     PetscGetArchType(arch,10);
102:     PetscGetDate(date,64);
103:     PetscGetVersion(version,256);
104:     MPI_Comm_size(PETSC_COMM_WORLD,&size);
105:     if (filename) {
106:       PetscFixFilename(filename,fname);
107:     } else {
108:       PetscGetHomeDirectory(pfile,240);
109:       PetscStrcat(pfile,"/.petschistory");
110:       PetscFixFilename(pfile,fname);
111:     }

113:     *fd = fopen(fname,"a"); if (!fd) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Cannot open file: %s",fname);
114:     PetscFPrintf(PETSC_COMM_SELF,*fd,"---------------------------------------------------------\n");
115:     PetscFPrintf(PETSC_COMM_SELF,*fd,"%s %s\n",version,date);
116:     PetscGetProgramName(pname,PETSC_MAX_PATH_LEN);
117:     PetscFPrintf(PETSC_COMM_SELF,*fd,"%s on a %s, %d proc. with options:\n",pname,arch,size);
118:     PetscViewerASCIIOpenWithFILE(PETSC_COMM_WORLD,*fd,&viewer);
119:     PetscOptionsView(viewer);
120:     PetscViewerDestroy(&viewer);
121:     PetscFPrintf(PETSC_COMM_SELF,*fd,"---------------------------------------------------------\n");
122:     err = fflush(*fd);
123:     if (err) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SYS,"fflush() failed on file");
124:   }
125:   return(0);
126: }

130: PetscErrorCode  PetscCloseHistoryFile(FILE **fd)
131: {
133:   PetscMPIInt    rank;
134:   char           date[64];
135:   int            err;

138:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
139:   if (!rank) {
140:     PetscGetDate(date,64);
141:     PetscFPrintf(PETSC_COMM_SELF,*fd,"---------------------------------------------------------\n");
142:     PetscFPrintf(PETSC_COMM_SELF,*fd,"Finished at %s\n",date);
143:     PetscFPrintf(PETSC_COMM_SELF,*fd,"---------------------------------------------------------\n");
144:     err = fflush(*fd);
145:     if (err) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SYS,"fflush() failed on file");
146:     err = fclose(*fd);
147:     if (err) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SYS,"fclose() failed on file");
148:   }
149:   return(0);
150: }

152: /* ------------------------------------------------------------------------------*/

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

158:     This is so MPI errors in the debugger will leave all the stack 
159:   frames. The default MP_Abort() cleans up and exits thus providing no useful information
160:   in the debugger hence we call abort() instead of MPI_Abort().
161: */

165: void Petsc_MPI_AbortOnError(MPI_Comm *comm,PetscMPIInt *flag)
166: {
168:   (*PetscErrorPrintf)("MPI error %d\n",*flag);
169:   abort();
170: }

174: void Petsc_MPI_DebuggerOnError(MPI_Comm *comm,PetscMPIInt *flag)
175: {

179:   (*PetscErrorPrintf)("MPI error %d\n",*flag);
180:   PetscAttachDebugger();
181:   if (ierr) { /* hopeless so get out */
182:     MPI_Abort(*comm,*flag);
183:   }
184: }

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

192:    Collective on PETSC_COMM_WORLD

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

196:    Level: advanced

198:    Note:
199:    See PetscInitialize() for more general runtime options.

201: .seealso: PetscInitialize(), PetscOptionsView(), PetscMallocDump(), PetscMPIDump(), PetscFinalize()
202: @*/
203: PetscErrorCode  PetscEnd(void)
204: {
206:   PetscFinalize();
207:   exit(0);
208:   return 0;
209: }

211: PetscBool    PetscOptionsPublish = PETSC_FALSE;
212: extern PetscErrorCode        PetscSetUseTrMalloc_Private(void);
213: extern PetscBool  petscsetmallocvisited;
214: static char       emacsmachinename[256];

216: PetscErrorCode (*PetscExternalVersionFunction)(MPI_Comm) = 0;
217: PetscErrorCode (*PetscExternalHelpFunction)(MPI_Comm)    = 0;

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

226:    Input Parameter:
227: +  help - the help function (may be PETSC_NULL)
228: -  version - the version function (may be PETSC_NULL)

230:    Level: developer

232:    Concepts: package help message

234: @*/
235: PetscErrorCode  PetscSetHelpVersionFunctions(PetscErrorCode (*help)(MPI_Comm),PetscErrorCode (*version)(MPI_Comm))
236: {
238:   PetscExternalHelpFunction    = help;
239:   PetscExternalVersionFunction = version;
240:   return(0);
241: }

243: #if defined(PETSC_HAVE_PTHREADCLASSES)
244: extern PetscErrorCode PetscOptionsCheckInitial_Private_Pthread(void);
245: #endif

247: #if defined(PETSC_HAVE_CUDA)
248: #include <cublas.h>
249: #endif

253: PetscErrorCode  PetscOptionsCheckInitial_Private(void)
254: {
255:   char           string[64],mname[PETSC_MAX_PATH_LEN],*f;
256:   MPI_Comm       comm = PETSC_COMM_WORLD;
257:   PetscBool      flg1 = PETSC_FALSE,flg2 = PETSC_FALSE,flg3 = PETSC_FALSE,flg4 = PETSC_FALSE,flag;
259:   PetscReal      si;
260:   int            i;
261:   PetscMPIInt    rank;
262:   char           version[256];
263: #if defined(PETSC_USE_SERVER)
264:   PetscBool      flgz;
265: #endif

268:   MPI_Comm_rank(PETSC_COMM_WORLD,&rank);

270:   /*
271:       Setup the memory management; support for tracing malloc() usage 
272:   */
273:   PetscOptionsHasName(PETSC_NULL,"-malloc_log",&flg3);
274: #if defined(PETSC_USE_DEBUG)
275:   PetscOptionsGetBool(PETSC_NULL,"-malloc",&flg1,&flg2);
276:   if ((!flg2 || flg1) && !petscsetmallocvisited) {
277:     if (flg2 || !(PETSC_RUNNING_ON_VALGRIND)) {
278:       /* turn off default -malloc if valgrind is being used */
279:       PetscSetUseTrMalloc_Private();
280:     }
281:   }
282: #else
283:   PetscOptionsGetBool(PETSC_NULL,"-malloc_dump",&flg1,PETSC_NULL);
284:   PetscOptionsGetBool(PETSC_NULL,"-malloc",&flg2,PETSC_NULL);
285:   if (flg1 || flg2 || flg3) {PetscSetUseTrMalloc_Private();}
286: #endif
287:   if (flg3) {
288:     PetscMallocSetDumpLog();
289:   }
290:   flg1 = PETSC_FALSE;
291:   PetscOptionsGetBool(PETSC_NULL,"-malloc_debug",&flg1,PETSC_NULL);
292:   if (flg1) {
293:     PetscSetUseTrMalloc_Private();
294:     PetscMallocDebug(PETSC_TRUE);
295:   }
296:   flg1 = PETSC_FALSE;
297:   PetscOptionsGetBool(PETSC_NULL,"-malloc_test",&flg1,PETSC_NULL);
298: #if defined(PETSC_USE_DEBUG)
299:   if (flg1 && !PETSC_RUNNING_ON_VALGRIND) {
300:     PetscSetUseTrMalloc_Private();
301:     PetscMallocSetDumpLog();
302:     PetscMallocDebug(PETSC_TRUE);
303:   }
304: #endif

306:   flg1 = PETSC_FALSE;
307:   PetscOptionsGetBool(PETSC_NULL,"-malloc_info",&flg1,PETSC_NULL);
308:   if (!flg1) {
309:     flg1 = PETSC_FALSE;
310:     PetscOptionsGetBool(PETSC_NULL,"-memory_info",&flg1,PETSC_NULL);
311:   }
312:   if (flg1) {
313:     PetscMemorySetGetMaximumUsage();
314:   }

316:   /*
317:       Set the display variable for graphics
318:   */
319:   PetscSetDisplay();

321:   /*
322:       Print the PETSc version information
323:   */
324:   PetscOptionsHasName(PETSC_NULL,"-v",&flg1);
325:   PetscOptionsHasName(PETSC_NULL,"-version",&flg2);
326:   PetscOptionsHasName(PETSC_NULL,"-help",&flg3);
327:   if (flg1 || flg2 || flg3){

329:     /*
330:        Print "higher-level" package version message 
331:     */
332:     if (PetscExternalVersionFunction) {
333:       (*PetscExternalVersionFunction)(comm);
334:     }

336:     PetscGetVersion(version,256);
337:     (*PetscHelpPrintf)(comm,"--------------------------------------------\
338: ------------------------------\n");
339:     (*PetscHelpPrintf)(comm,"%s\n",version);
340:     (*PetscHelpPrintf)(comm,"%s",PETSC_AUTHOR_INFO);
341:     (*PetscHelpPrintf)(comm,"See docs/changes/index.html for recent updates.\n");
342:     (*PetscHelpPrintf)(comm,"See docs/faq.html for problems.\n");
343:     (*PetscHelpPrintf)(comm,"See docs/manualpages/index.html for help. \n");
344:     (*PetscHelpPrintf)(comm,"Libraries linked from %s\n",PETSC_LIB_DIR);
345:     (*PetscHelpPrintf)(comm,"--------------------------------------------\
346: ------------------------------\n");
347:   }

349:   /*
350:        Print "higher-level" package help message 
351:   */
352:   if (flg3){
353:     if (PetscExternalHelpFunction) {
354:       (*PetscExternalHelpFunction)(comm);
355:     }
356:   }

358:   /*
359:       Setup the error handling
360:   */
361:   flg1 = PETSC_FALSE;
362:   PetscOptionsGetBool(PETSC_NULL,"-on_error_abort",&flg1,PETSC_NULL);
363:   if (flg1) {
364:     MPI_Errhandler_set(PETSC_COMM_WORLD,MPI_ERRORS_ARE_FATAL);
365:     PetscPushErrorHandler(PetscAbortErrorHandler,0);
366:   }
367:   flg1 = PETSC_FALSE;
368:   PetscOptionsGetBool(PETSC_NULL,"-on_error_mpiabort",&flg1,PETSC_NULL);
369:   if (flg1) { PetscPushErrorHandler(PetscMPIAbortErrorHandler,0);}
370:   flg1 = PETSC_FALSE;
371:   PetscOptionsGetBool(PETSC_NULL,"-mpi_return_on_error",&flg1,PETSC_NULL);
372:   if (flg1) {
373:     MPI_Errhandler_set(comm,MPI_ERRORS_RETURN);
374:   }
375:   flg1 = PETSC_FALSE;
376:   PetscOptionsGetBool(PETSC_NULL,"-no_signal_handler",&flg1,PETSC_NULL);
377:   if (!flg1) {PetscPushSignalHandler(PetscDefaultSignalHandler,(void*)0);}
378:   flg1 = PETSC_FALSE;
379:   PetscOptionsGetBool(PETSC_NULL,"-fp_trap",&flg1,PETSC_NULL);
380:   if (flg1) {PetscSetFPTrap(PETSC_FP_TRAP_ON);}

382:   /*
383:       Setup debugger information
384:   */
385:   PetscSetDefaultDebugger();
386:   PetscOptionsGetString(PETSC_NULL,"-on_error_attach_debugger",string,64,&flg1);
387:   if (flg1) {
388:     MPI_Errhandler err_handler;

390:     PetscSetDebuggerFromString(string);
391:     MPI_Errhandler_create((MPI_Handler_function*)Petsc_MPI_DebuggerOnError,&err_handler);
392:     MPI_Errhandler_set(comm,err_handler);
393:     PetscPushErrorHandler(PetscAttachDebuggerErrorHandler,0);
394:   }
395:   PetscOptionsGetString(PETSC_NULL,"-debug_terminal",string,64,&flg1);
396:   if (flg1) { PetscSetDebugTerminal(string); }
397:   PetscOptionsGetString(PETSC_NULL,"-start_in_debugger",string,64,&flg1);
398:   PetscOptionsGetString(PETSC_NULL,"-stop_for_debugger",string,64,&flg2);
399:   if (flg1 || flg2) {
400:     PetscMPIInt    size;
401:     PetscInt       lsize,*nodes;
402:     MPI_Errhandler err_handler;
403:     /*
404:        we have to make sure that all processors have opened 
405:        connections to all other processors, otherwise once the 
406:        debugger has stated it is likely to receive a SIGUSR1
407:        and kill the program. 
408:     */
409:     MPI_Comm_size(PETSC_COMM_WORLD,&size);
410:     if (size > 2) {
411:       PetscMPIInt dummy = 0;
412:       MPI_Status  status;
413:       for (i=0; i<size; i++) {
414:         if (rank != i) {
415:           MPI_Send(&dummy,1,MPI_INT,i,109,PETSC_COMM_WORLD);
416:         }
417:       }
418:       for (i=0; i<size; i++) {
419:         if (rank != i) {
420:           MPI_Recv(&dummy,1,MPI_INT,i,109,PETSC_COMM_WORLD,&status);
421:         }
422:       }
423:     }
424:     /* check if this processor node should be in debugger */
425:     PetscMalloc(size*sizeof(PetscInt),&nodes);
426:     lsize = size;
427:     PetscOptionsGetIntArray(PETSC_NULL,"-debugger_nodes",nodes,&lsize,&flag);
428:     if (flag) {
429:       for (i=0; i<lsize; i++) {
430:         if (nodes[i] == rank) { flag = PETSC_FALSE; break; }
431:       }
432:     }
433:     if (!flag) {
434:       PetscSetDebuggerFromString(string);
435:       PetscPushErrorHandler(PetscAbortErrorHandler,0);
436:       if (flg1) {
437:         PetscAttachDebugger();
438:       } else {
439:         PetscStopForDebugger();
440:       }
441:       MPI_Errhandler_create((MPI_Handler_function*)Petsc_MPI_AbortOnError,&err_handler);
442:       MPI_Errhandler_set(comm,err_handler);
443:     }
444:     PetscFree(nodes);
445:   }

447:   PetscOptionsGetString(PETSC_NULL,"-on_error_emacs",emacsmachinename,128,&flg1);
448:   if (flg1 && !rank) {PetscPushErrorHandler(PetscEmacsClientErrorHandler,emacsmachinename);}

450: #if defined(PETSC_USE_SERVER)
451:   PetscOptionsHasName(PETSC_NULL,"-server", &flgz);
452:   if (flgz){
453:     PetscInt port = PETSC_DECIDE;
454:     PetscOptionsGetInt(PETSC_NULL,"-server",&port,PETSC_NULL);
455:     PetscWebServe(PETSC_COMM_WORLD,(int)port);
456:   }
457: #endif

459:   /*
460:         Setup profiling and logging
461:   */
462: #if defined (PETSC_USE_INFO)
463:   {
464:     char logname[PETSC_MAX_PATH_LEN]; logname[0] = 0;
465:     PetscOptionsGetString(PETSC_NULL,"-info",logname,250,&flg1);
466:     if (flg1 && logname[0]) {
467:       PetscInfoAllow(PETSC_TRUE,logname);
468:     } else if (flg1) {
469:       PetscInfoAllow(PETSC_TRUE,PETSC_NULL);
470:     }
471:   }
472: #endif
473: #if defined(PETSC_USE_LOG)
474:   mname[0] = 0;
475:   PetscOptionsGetString(PETSC_NULL,"-history",mname,PETSC_MAX_PATH_LEN,&flg1);
476:   if (flg1) {
477:     if (mname[0]) {
478:       PetscOpenHistoryFile(mname,&petsc_history);
479:     } else {
480:       PetscOpenHistoryFile(0,&petsc_history);
481:     }
482:   }
483: #if defined(PETSC_HAVE_MPE)
484:   flg1 = PETSC_FALSE;
485:   PetscOptionsHasName(PETSC_NULL,"-log_mpe",&flg1);
486:   if (flg1) PetscLogMPEBegin();
487: #endif
488:   flg1 = PETSC_FALSE;
489:   flg2 = PETSC_FALSE;
490:   flg3 = PETSC_FALSE;
491:   PetscOptionsGetBool(PETSC_NULL,"-log_all",&flg1,PETSC_NULL);
492:   PetscOptionsGetBool(PETSC_NULL,"-log",&flg2,PETSC_NULL);
493:   PetscOptionsHasName(PETSC_NULL,"-log_summary",&flg3);
494:   PetscOptionsHasName(PETSC_NULL,"-log_summary_python",&flg4);
495:   if (flg1)                      {  PetscLogAllBegin(); }
496:   else if (flg2 || flg3 || flg4) {  PetscLogBegin();}
497: 
498:   PetscOptionsGetString(PETSC_NULL,"-log_trace",mname,250,&flg1);
499:   if (flg1) {
500:     char name[PETSC_MAX_PATH_LEN],fname[PETSC_MAX_PATH_LEN];
501:     FILE *file;
502:     if (mname[0]) {
503:       sprintf(name,"%s.%d",mname,rank);
504:       PetscFixFilename(name,fname);
505:       file = fopen(fname,"w");
506:       if (!file) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to open trace file: %s",fname);
507:     } else {
508:       file = PETSC_STDOUT;
509:     }
510:     PetscLogTraceBegin(file);
511:   }
512: #endif

514:   /*
515:       Setup building of stack frames for all function calls
516:   */
517: #if defined(PETSC_USE_DEBUG)
518:   PetscThreadLocalRegister(petscstack); /* Creates petscstack_key if needed */
519:   PetscStackCreate();
520: #endif

522:   PetscOptionsGetBool(PETSC_NULL,"-options_gui",&PetscOptionsPublish,PETSC_NULL);

524: #if defined(PETSC_HAVE_CUDA)
525:   PetscOptionsHasName(PETSC_NULL,"-cuda_show_devices",&flg1);
526:   if (flg1) {
527:     struct cudaDeviceProp prop;
528:     int devCount;
529:     int device;

531:     cudaGetDeviceCount(&devCount);
532:     for(device = 0; device < devCount; ++device) {
533:       cudaGetDeviceProperties(&prop, device);
534:       PetscPrintf(PETSC_COMM_WORLD, "CUDA device %d: %s\n", device, prop.name);
535:     }
536:   }
537:   {
538:     int size;
539:     MPI_Comm_size(PETSC_COMM_WORLD,&size);
540:     if (size>1) {
541:       int devCount, device, rank;
542:       cudaGetDeviceCount(&devCount);
543:       MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
544:       device = rank % devCount;
545:       cudaSetDevice(device);
546:     }
547:     else {
548:       int device;
549:       /* the code below works for serial GPU simulations */
550:       PetscOptionsGetInt(PETSC_NULL,"-cuda_set_device", &device, &flg1);
551:       if (flg1) {
552:         cudaSetDevice(device);
553:       }
554:     }
555:   }
556: #endif


559: #if defined(PETSC_HAVE_PTHREADCLASSES)
560:   PetscOptionsCheckInitial_Private_Pthread();
561: #endif
562:   /*
563:        Print basic help message
564:   */
565:   PetscOptionsHasName(PETSC_NULL,"-help",&flg1);
566:   if (flg1) {
567:     (*PetscHelpPrintf)(comm,"Options for all PETSc programs:\n");
568:     (*PetscHelpPrintf)(comm," -help: prints help method for each option\n");
569:     (*PetscHelpPrintf)(comm," -on_error_abort: cause an abort when an error is detected. Useful \n ");
570:     (*PetscHelpPrintf)(comm,"       only when run in the debugger\n");
571:     (*PetscHelpPrintf)(comm," -on_error_attach_debugger [gdb,dbx,xxgdb,ups,noxterm]\n");
572:     (*PetscHelpPrintf)(comm,"       start the debugger in new xterm\n");
573:     (*PetscHelpPrintf)(comm,"       unless noxterm is given\n");
574:     (*PetscHelpPrintf)(comm," -start_in_debugger [gdb,dbx,xxgdb,ups,noxterm]\n");
575:     (*PetscHelpPrintf)(comm,"       start all processes in the debugger\n");
576:     (*PetscHelpPrintf)(comm," -on_error_emacs <machinename>\n");
577:     (*PetscHelpPrintf)(comm,"    emacs jumps to error file\n");
578:     (*PetscHelpPrintf)(comm," -debugger_nodes [n1,n2,..] Nodes to start in debugger\n");
579:     (*PetscHelpPrintf)(comm," -debugger_pause [m] : delay (in seconds) to attach debugger\n");
580:     (*PetscHelpPrintf)(comm," -stop_for_debugger : prints message on how to attach debugger manually\n");
581:     (*PetscHelpPrintf)(comm,"                      waits the delay for you to attach\n");
582:     (*PetscHelpPrintf)(comm," -display display: Location where graphics and debuggers are displayed\n");
583:     (*PetscHelpPrintf)(comm," -no_signal_handler: do not trap error signals\n");
584:     (*PetscHelpPrintf)(comm," -mpi_return_on_error: MPI returns error code, rather than abort on internal error\n");
585:     (*PetscHelpPrintf)(comm," -fp_trap: stop on floating point exceptions\n");
586:     (*PetscHelpPrintf)(comm,"           note on IBM RS6000 this slows run greatly\n");
587:     (*PetscHelpPrintf)(comm," -malloc_dump <optional filename>: dump list of unfreed memory at conclusion\n");
588:     (*PetscHelpPrintf)(comm," -malloc: use our error checking malloc\n");
589:     (*PetscHelpPrintf)(comm," -malloc no: don't use error checking malloc\n");
590:     (*PetscHelpPrintf)(comm," -malloc_info: prints total memory usage\n");
591:     (*PetscHelpPrintf)(comm," -malloc_log: keeps log of all memory allocations\n");
592:     (*PetscHelpPrintf)(comm," -malloc_debug: enables extended checking for memory corruption\n");
593:     (*PetscHelpPrintf)(comm," -options_table: dump list of options inputted\n");
594:     (*PetscHelpPrintf)(comm," -options_left: dump list of unused options\n");
595:     (*PetscHelpPrintf)(comm," -options_left no: don't dump list of unused options\n");
596:     (*PetscHelpPrintf)(comm," -tmp tmpdir: alternative /tmp directory\n");
597:     (*PetscHelpPrintf)(comm," -shared_tmp: tmp directory is shared by all processors\n");
598:     (*PetscHelpPrintf)(comm," -not_shared_tmp: each processor has separate tmp directory\n");
599:     (*PetscHelpPrintf)(comm," -memory_info: print memory usage at end of run\n");
600:     (*PetscHelpPrintf)(comm," -server <port>: Run PETSc webserver (default port is 8080) see PetscWebServe()\n");
601: #if defined(PETSC_USE_LOG)
602:     (*PetscHelpPrintf)(comm," -get_total_flops: total flops over all processors\n");
603:     (*PetscHelpPrintf)(comm," -log[_all _summary _summary_python]: logging objects and events\n");
604:     (*PetscHelpPrintf)(comm," -log_trace [filename]: prints trace of all PETSc calls\n");
605: #if defined(PETSC_HAVE_MPE)
606:     (*PetscHelpPrintf)(comm," -log_mpe: Also create logfile viewable through upshot\n");
607: #endif
608:     (*PetscHelpPrintf)(comm," -info <optional filename>: print informative messages about the calculations\n");
609: #endif
610:     (*PetscHelpPrintf)(comm," -v: prints PETSc version number and release date\n");
611:     (*PetscHelpPrintf)(comm," -options_file <file>: reads options from file\n");
612:     (*PetscHelpPrintf)(comm," -petsc_sleep n: sleeps n seconds before running program\n");
613:     (*PetscHelpPrintf)(comm,"-----------------------------------------------\n");
614:   }

616:   PetscOptionsGetReal(PETSC_NULL,"-petsc_sleep",&si,&flg1);
617:   if (flg1) {
618:     PetscSleep(si);
619:   }

621:   PetscOptionsGetString(PETSC_NULL,"-info_exclude",mname,PETSC_MAX_PATH_LEN,&flg1);
622:   PetscStrstr(mname,"null",&f);
623:   if (f) {
624:     PetscInfoDeactivateClass(0);
625:   }

627: #if defined(PETSC_HAVE_CUSP)
628:   PetscOptionsHasName(PETSC_NULL,"-log_summary",&flg3);
629:   if (flg3) flg1 = PETSC_TRUE;
630:   else flg1 = PETSC_FALSE;
631:   PetscOptionsGetBool(PETSC_NULL,"-cusp_synchronize",&flg1,PETSC_NULL);
632:   if (flg1) PetscCUSPSynchronize = PETSC_TRUE;
633: #endif

635:   return(0);
636: }