Actual source code: ex2f.h

  1: !  This file contains include statements and a user-defined
  2: !  common block for application-specific data.  This file is
  3: !  included in each routine within the program ex2f.
  4: !
  5: !  The following include statements are generally used in TS Fortran
  6: !  programs:
  7: !     petscsys.h       - base PETSc routines
  8: !     petscvec.h    - vectors
  9: !     petscmat.h    - matrices
 10: !     petscksp.h    - Krylov subspace methods
 11: !     petscpc.h     - preconditioners
 12: !     petscsnes.h   - SNES interface
 13: !     petscts.h     - TS interface
 14: !     petscviewer.h - viewers
 15: !     petscdraw.h   - drawing
 16: !  In addition, we need the following for use of distributed arrays
 17: !     petscda.h     - distributed arrays (DAs)
 18: !  Other include statements may be needed if using additional PETSc
 19: !  routines in a Fortran program, e.g.,
 20: !     petscis.h     - index sets

 22:  #include finclude/petscsys.h
 23:  #include finclude/petscvec.h
 24:  #include finclude/petscda.h
 25:  #include finclude/petscmat.h
 26:  #include finclude/petscksp.h
 27:  #include finclude/petscpc.h
 28:  #include finclude/petscsnes.h
 29:  #include finclude/petscts.h
 30:  #include finclude/petscviewer.h
 31:  #include finclude/petscdraw.h

 33: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 34: !
 35: !  The application context to contain data needed by the
 36: !  application-provided call-back routines, RHSFunction(),
 37: !  RHSJacobian(), Monitor().  In this example the application context
 38: !  is a Fortran common block, /appctx/.  Note that we can store
 39: !  (pointers to) PETSc objects within this common block.
 40: !    appctx:  M         - total number of grid points
 41: !             da        - distributed array
 42: !             localwork - local work vector (including ghost points)
 43: !             solution  - solution vector
 44: !             comm      - communicator
 45: !             rank      - processor rank within communicator
 46: !             size      - number of processors
 47: !             debug     - flag (1 indicates debugging printouts)
 48: !
 49: !  Store other misc problem parameters in common block /params/
 50: !             h         - mesh width h = 1/(M-1)
 51: !
 52: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 53: !  Common block data:
 54:       DA    da
 55:       Vec   localwork,solution
 56:       Vec   u_local
 57:       PetscInt   M
 58:       PetscTruth debug
 59:       PetscMPIInt size,rank
 60:       PetscReal  zero_d0,one_d0
 61:       PetscReal  two_d0,four_d0
 62:       MPI_Comm   comm
 63:       PetscReal  h

 65:       common /params/ zero_d0,one_d0,two_d0,four_d0,h
 66:       common /appctx/ localwork,solution,da,u_local
 67:       common /appctx/ comm,rank,size,debug,M

 69: ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -