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.\n\n";

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

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

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

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

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