Actual source code: tao_init.c

  1: /*$Id$*/

  3: #include "tao_solver.h"   /*I  "tao_solver.h" I*/

  5: int TaoRegisterEvents();

  7: /* ------------------------Nasty global variables -------------------------------*/
  8: int TaoInitializeCalled = 0;
  9: int TAO_COOKIE = 0;

 11: static int  TaoGlobalArgc   = 0;
 12: static char **TaoGlobalArgs = 0;

 16: /*@C 
 17:   TaoInitialize - Initializes the TAO component and many of the packages associated with it.

 19:    Collective on MPI_COMM_WORLD

 21:    Input Parameters:
 22: +  argc - [optional] count of number of command line arguments
 23: .  args - [optional] the command line arguments
 24: .  file - [optional] PETSc database file, defaults to ~username/.petscrc
 25:           (use TAO_NULL for default)
 26: -  help - [optional] Help message to print, use TAO_NULL for no message

 28:    Note:
 29:    TaoInitialize() should always be called near the beginning of your 
 30:    program.  However, this command should come after PetscInitialize()

 32:    Note:
 33:    The input arguments are required if the options database is to be used.

 35:    Level: beginner

 37: .keywords: TAO_SOLVER, initialize

 39: .seealso: TaoInitializeFortran(), TaoFinalize(), PetscInitialize()
 40: @*/
 41: int TaoInitialize(int *argc,char ***args,char file[],const char help[])
 42: {
 43:   int info=0;

 45:   TaoFunctionBegin;

 47:   if (TaoInitializeCalled){ TaoFunctionReturn(0);}
 48:   TaoInitializeCalled++;

 50:   if (argc && args){
 51:     TaoGlobalArgc = *argc;
 52:     TaoGlobalArgs = *args;
 53:   }

 55:   TAO_COOKIE = 0;
 56:   info=TaoLogClassRegister(&TAO_COOKIE,"TAO Solver"); CHKERRQ(info);

 58:   info = TaoRegisterEvents(); CHKERRQ(info);
 59:   info = TaoStandardRegisterAll();CHKERRQ(info);
 60:   info = PetscInfo(0,"TaoInitialize:TAO successfully started\n"); CHKERRQ(info);
 61:   TaoFunctionReturn(info);
 62: }

 66: /*@
 67:    TaoFinalize - Checks for options at the end of the TAO program
 68:    and finalizes interfaces with other packages.

 70:    Collective on MPI_COMM_WORLD

 72:    Level: beginner

 74: .keywords: finalize, exit, end

 76: .seealso: TaoInitialize(), PetscFinalize()
 77: @*/
 78: int TaoFinalize(void)
 79: {
 80:   int info;
 81:   
 82:   TaoFunctionBegin;
 83:   TaoInitializeCalled--;
 84:   if (TaoInitializeCalled==0){
 85:     info = PetscInfo(0,"TaoFinalize:Tao successfully ended!\n"); 
 86:            CHKERRQ(info);
 87:     info = TaoRegisterDestroy(); CHKERRQ(info);
 88:   }
 89:   TaoFunctionReturn(0);
 90: }


 95: // int Tao_Solve, Tao_LineSearch;
 96: /*
 97:    TaoRegisterEvents - Registers TAO events for use in performance logging.
 98: */
 99: int TaoRegisterEvents()
100: {
101:   TaoFunctionBegin;
102:   TaoFunctionReturn(0);
103: }

107: /*@C
108:    TaoGetArgs - Allows you to access the raw command line arguments anywhere
109:      after TaoInitialize() is called but before TaoFinalize().

111:    Not Collective

113:    Output Parameters:
114: +  argc - count of number of command line arguments
115: -  args - the command line arguments

117:    Level: developer

119:    Notes:
120:       This is usually used to pass the command line arguments into other 
121:       libraries that are called internally deep in TAO or the application.

123: .keywords: command line arguments
124:    
125: .seealso: TaoFinalize(), TaoInitializeFortran()

127: @*/
128: int TaoGetArgs(int *argc,char ***args)
129: {
130:   TaoFunctionBegin;
131:   if (!TaoGlobalArgs) {
132:     SETERRQ(1,"You must call after TaoInitialize()");
133:   }
134:   if (argc && args){
135:     *argc = TaoGlobalArgc;
136:     *args = TaoGlobalArgs;
137:   }
138:   TaoFunctionReturn(0);
139: }