Actual source code: tao_init.c

      1: /*$Id: tao_init.c 1.50 05/05/10 15:21:38-05:00 sarich@zorak.(none) $*/

      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 = TaoInitialize_DynamicLibraries();CHKERRQ(info); */
     60:   info = TaoStandardRegisterAll();CHKERRQ(info);
     61:   info = PetscLogInfo((0,"TaoInitialize:TAO successfully started\n")); CHKERRQ(info);
     62:   TaoFunctionReturn(info);
     63: }

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

     71:    Collective on MPI_COMM_WORLD

     73:    Level: beginner

     75: .keywords: finalize, exit, end

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

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

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

    112:    Not Collective

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

    118:    Level: developer

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

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

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