Actual source code: ex4.c

  1: /*$Id: ex4.c,v 1.16 2001/03/23 23:21:03 balay Exp $*/

  3: static char help[] = "Prints loadable objects from dynamic library.nn";

  5: /*T
  6:    Concepts: dynamic libraries;
  7:    Processors: n
  8: T*/
  9: 
 10:  #include petsc.h
 11: #undef __FUNCT__
 13: int main(int argc,char **argv)
 14: {
 15:   int        ierr;
 16:   PetscTruth flg;
 17:   char       *string,filename[256];
 18:   void       *handle;

 20:   /*
 21:     Every PETSc routine should begin with the PetscInitialize() routine.
 22:     argc, argv - These command line arguments are taken to extract the options
 23:                  supplied to PETSc and options supplied to MPI.
 24:     help       - When PETSc executable is invoked with the option -help, 
 25:                  it prints the various options that can be applied at 
 26:                  runtime.  The user can use the "help" variable place
 27:                  additional help messages in this printout.
 28:   */
 29:   PetscInitialize(&argc,&argv,(char *)0,help);

 31:   PetscOptionsGetString(PETSC_NULL,"-library",filename,256,&flg);
 32:   if (!flg) {
 33:     SETERRQ(1,"Must indicate library name with -library");
 34:   }

 36: #if defined(USE_DYNAMIC_LIBRARIES)
 37:   PetscDLLibraryOpen(PETSC_COMM_WORLD,filename,&handle);
 38:   PetscDLLibraryGetInfo(handle,"Contents",&string);
 39:   PetscPrintf(PETSC_COMM_WORLD,"Contents:%sn",string);
 40:   PetscDLLibraryGetInfo(handle,"Authors",&string);
 41:   PetscPrintf(PETSC_COMM_WORLD,"Authors:%sn",string);
 42:   PetscDLLibraryGetInfo(handle,"Version",&string);
 43:   PetscPrintf(PETSC_COMM_WORLD,"Version:%sn",string);
 44: #else
 45:   /* just forces string and handle to be used so there are no compiler warnings */
 46:   string = "No dynamic libraries used";
 47:   handle = (void*)string;
 48:   PetscPrintf(PETSC_COMM_WORLD,"%sn",string);
 49:   PetscStrcmp(string,"Never will happen",&flg);
 50:   if (flg) {
 51:     PetscObjectDestroy((PetscObject)handle);
 52:   }
 53: #endif

 55:   PetscFinalize();
 56:   return 0;
 57: }