Actual source code: dlregistao.c

petsc-3.11.2 2019-05-18
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 or shared libraries, this function is called from the
 26:   first entry to TaoCreate(); when using shared or static libraries, it is called
 27:   from PetscDLLibraryRegister_tao()

 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("TaoObjGradEval",   TAO_CLASSID,&TAO_ObjGradEval);
 52:   PetscLogEventRegister("TaoHessianEval",   TAO_CLASSID,&TAO_HessianEval);
 53:   PetscLogEventRegister("TaoConstrEval",    TAO_CLASSID,&TAO_ConstraintsEval);
 54:   PetscLogEventRegister("TaoJacobianEval",  TAO_CLASSID,&TAO_JacobianEval);
 55:   /* Process info exclusions */
 56:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);
 57:   if (opt) {
 58:     PetscStrInList("tao",logList,',',&pkg);
 59:     if (pkg) {PetscInfoDeactivateClass(TAO_CLASSID);}
 60:   }
 61:   /* Process summary exclusions */
 62:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
 63:   if (opt) {
 64:     PetscStrInList("tao",logList,',',&pkg);
 65:     if (pkg) {PetscLogEventExcludeClass(TAO_CLASSID);}
 66:   }
 67:   /* Register package finalizer */
 68:   PetscRegisterFinalize(TaoFinalizePackage);
 69:   return(0);
 70: }

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

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

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

 84: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_tao(void)
 85: {

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

 94: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */