! ! module mymodule #include use iso_c_binding interface subroutine fillupvector(vaddr,ierr) bind ( C, name = "fillupvector" ) use iso_c_binding integer(c_long_long) vaddr integer(c_int) ierr end subroutine fillupvector end interface end module #include use petscvec use mymodule implicit none ! ! This routine demonstates how to call a C function from Fortran Vec v PetscErrorCode ierr call PetscInitialize(PETSC_NULL_CHARACTER,ierr) call VecCreate(PETSC_COMM_WORLD,v,ierr);CHKERRA(ierr) call VecSetSizes(v,PETSC_DECIDE,5,ierr);CHKERRA(ierr) call VecSetFromOptions(v,ierr);CHKERRA(ierr) ! ! Now Call a Petsc Routine from Fortran ! call fillupvector(v%v,ierr);CHKERRA(ierr) call VecView(v,PETSC_VIEWER_STDOUT_WORLD,ierr);CHKERRA(ierr) call VecDestroy(v,ierr);CHKERRA(ierr) call PetscFinalize(ierr) return end