Actual source code: ex7f.F

1: !
2: !
3: subroutine ex7f(vec,comm)
5: #include include/finclude/petsc.h
6: #include include/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)
27: !
28: ! Now call C routine from Fortran, passing in the vector, communicator
29: !
30: call ex7c(vec,comm,ierr)
31: !
32: ! IO from the fortran routines may cause all kinds of
33: !
34: 100 format ('[',i1,']',' Calling VecView from Fortran')
35: write(6,100) rank
36: !
37: ! Now Call a Petsc Routine from Fortran
38: !
39: call VecView(vec,PETSC_VIEWER_STDOUT_WORLD,ierr)
40: return
41: end
43: