Actual source code: ex7f.F
petsc-3.7.5 2017-01-01
1: !
2: !
3: subroutine ex7f(vec,comm)
5: #include <petsc/finclude/petscsys.h>
6: #include <petsc/finclude/petscvec.h>
7: !
8: ! This routine demonstates how a computational module may be written
9: ! in Fortran and called from a C routine, passing down PETSc objects.
10: !
12: PetscScalar two
13: Vec vec
14: MPI_Comm comm
15: PetscErrorCode ierr
16: PetscMPIInt rank
18: two = 2.0
20: !
21: ! The Objects vec,comm created in a C routine are now
22: ! used in fortran routines.
23: !
24: call VecSet(vec,two,ierr)
25: call MPI_Comm_rank(comm,rank,ierr)
26: call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
28: !
29: ! Now call C routine from Fortran, passing in the vector, communicator
30: !
31: call ex7c(vec,comm,ierr)
32: !
33: ! IO from the fortran routines may cause all kinds of
34: !
35: ! 100 format ('[',i1,']',' Calling VecView from Fortran')
36: ! write(6,100) rank
37: !
38: ! Now Call a Petsc Routine from Fortran
39: !
40: call VecView(vec,PETSC_VIEWER_STDOUT_WORLD,ierr)
41: return
42: end