Actual source code: dlregistao.c

petsc-3.9.4 2018-09-11
Report Typos and Errors
  1: #define TAO_DLL

  3:  #include <petsc/private/taoimpl.h>

  5: static PetscBool TaoPackageInitialized = PETSC_FALSE;

  7: /*@C
  8:   TaoFinalizePackage - This function destroys everything in the PETSc/TAO
  9:   interface to the Tao package. It is called from PetscFinalize().

 11:   Level: developer
 12: @*/
 13: PetscErrorCode TaoFinalizePackage(void)
 14: {

 18:   PetscFunctionListDestroy(&TaoList);
 19:   TaoPackageInitialized = PETSC_FALSE;
 20:   return(0);
 21: }

 23: /*@C
 24:   TaoInitializePackage - This function sets up PETSc to use the Tao
 25:   package.  When using static libraries, this function is called from the
 26:   first entry to TaoCreate(); when using shared libraries, it is called
 27:   from PetscDLLibraryRegister()

 29:   Level: developer

 31: .seealso: TaoCreate()
 32: @*/
 33: PetscErrorCode TaoInitializePackage(void)
 34: {
 35:   char           logList[256];
 36:   PetscBool      opt,pkg;


 41:   if (TaoPackageInitialized) return(0);
 42:   TaoPackageInitialized = PETSC_TRUE;
 43:   /* Register Classes */
 44:   PetscClassIdRegister("Tao",&TAO_CLASSID);
 45:   /* Register Constructors */
 46:   TaoRegisterAll();
 47:   /* Register Events */
 48:   PetscLogEventRegister("TaoSolve",TAO_CLASSID,&Tao_Solve);
 49:   PetscLogEventRegister("TaoObjectiveEval",TAO_CLASSID,&Tao_ObjectiveEval);
 50:   PetscLogEventRegister("TaoGradientEval",TAO_CLASSID,&Tao_GradientEval);
 51:   PetscLogEventRegister("TaoHessianEval",TAO_CLASSID,&Tao_HessianEval);
 52:   PetscLogEventRegister("TaoConstraintsEval",TAO_CLASSID,&Tao_ConstraintsEval);
 53:   PetscLogEventRegister("TaoJacobianEval",TAO_CLASSID,&Tao_JacobianEval);
 54:   /* Process info exclusions */
 55:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);
 56:   if (opt) {
 57:     PetscStrInList("tao",logList,',',&pkg);
 58:     if (pkg) {PetscInfoDeactivateClass(TAO_CLASSID);}
 59:   }
 60:   /* Process summary exclusions */
 61:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
 62:   if (opt) {
 63:     PetscStrInList("tao",logList,',',&pkg);
 64:     if (pkg) {PetscLogEventDeactivateClass(TAO_CLASSID);}
 65:   }
 66:   /* Register package finalizer */
 67:   PetscRegisterFinalize(TaoFinalizePackage);
 68:   return(0);
 69: }

 71: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
 72: /*
 73:   PetscDLLibraryRegister - this function is called when the dynamic library it
 74:   is in is opened.

 76:   This registers all of the Tao methods that are in the libtao
 77:   library.

 79:   Input Parameter:
 80: . path - library path
 81: */

 83: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_tao(void)
 84: {

 88:     TaoInitializePackage();
 89:     TaoLineSearchInitializePackage();
 90:     return(0);
 91: }

 93: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */