Actual source code: tao_init.c

  1: #include "taosolver.h"   /*I "taosolver.h" I*/

  3: PetscBool TaoInitializeCalled = PETSC_FALSE;
  4: PetscBool TaoBeganPetsc = PETSC_FALSE;

  6: static int tao_one=1;
  7: static char* tao_executable = (char*)"tao";
  8: static char** tao_executablePtr = &tao_executable;
 11: /*@C 
 12:   TaoInitialize - Initializes the TAO component and many of the packages associated with it.

 14:    Collective on MPI_COMM_WORLD

 16:    Input Parameters:
 17: +  argc - [optional] count of number of command line arguments
 18: .  args - [optional] the command line arguments
 19: .  file - [optional] PETSc database file, defaults to ~username/.petscrc
 20:           (use PETSC_NULL for default)
 21: -  help - [optional] Help message to print, use PETSC_NULL for no message

 23:    Note:
 24:    TaoInitialize() should always be called near the beginning of your 
 25:    program.  This routine will call PetscInitialize() if it has not yet been
 26:    called.

 28:    Level: beginner

 30: .seealso: TaoFinalize(), PetscInitialize()
 31: @*/
 32: PetscErrorCode TaoInitialize(int *argc, char ***args, const char file[], 
 33:                              const char help[])
 34: {

 37:   if (TaoInitializeCalled) {
 38:     return(0);
 39:   }
 40:   if (PetscInitializeCalled) {
 41:     ierr=PetscInfo(0,"TAO successfully initialized.\n"); 
 42:   } else {
 43:     if (argc&&args) {
 44:       PetscInitialize(argc,args,file,help); 
 45:     } else {
 46:       PetscInitialize(&tao_one,&tao_executablePtr,0,0); 
 47:     }
 48:     TaoBeganPetsc=PETSC_TRUE;
 49:   }
 50:   if (!PetscInitializeCalled) {
 51:     printf("Error initializing PETSc -- aborting.\n");
 52:     exit(1);
 53:   }
 54:   TaoInitializeCalled = PETSC_TRUE;
 55:   return 0;
 56: }

 60: /*@
 61:    TaoFinalize - Finalizes interfaces with other packages.

 63:    Collective on MPI_COMM_WORLD

 65:    Level: beginner

 67: .seealso: TaoInitialize(), PetscFinalize()
 68: @*/
 69: PetscErrorCode TaoFinalize()
 70: {
 71:   if (TaoBeganPetsc) {
 72:     PetscFinalize();
 73:   } 
 74:   return(0);
 75: }