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: int main(int argc,char **argv)
 12: {
 13:   int        ierr;
 14:   PetscTruth flg;
 15:   char       *string,filename[256];
 16:   void       *handle;

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

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

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

 53:   PetscFinalize();
 54:   return 0;
 55: }