1! 2! 3 subroutine ex7f(vec,comm) 4#include <petsc/finclude/petscvec.h> 5 use petscvec 6 implicit none 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! 11 12 PetscScalar, parameter :: two = 2.0 13 Vec vec 14 MPI_Comm comm 15 PetscErrorCode ierr 16 PetscMPIInt rank 17 18! 19! The Objects vec,comm created in a C routine are now 20! used in fortran routines. 21! 22 call VecSet(vec,two,ierr) 23 call MPI_Comm_rank(comm,rank,ierr) 24 call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) 25 26! 27! Now call C routine from Fortran, passing in the vector, communicator 28! 29 call ex7c(vec,comm,ierr) 30! 31! IO from the fortran routines may cause all kinds of 32! 33! 100 format ('[',i1,']',' Calling VecView from Fortran') 34! write(6,100) rank 35! 36! Now Call a Petsc Routine from Fortran 37! 38 call VecView(vec,PETSC_VIEWER_STDOUT_WORLD,ierr) 39 return 40 end 41 42 43