diff -r b7ce119910a6 src/vec/is/examples/tutorials/ex1f90.F --- a/src/vec/is/examples/tutorials/ex1f90.F Wed Jan 04 13:25:35 2012 -0600 +++ b/src/vec/is/examples/tutorials/ex1f90.F Wed Jan 04 15:06:11 2012 -0600 @@ -14,21 +14,36 @@ ! petscis.h90 - to allow access to Fortran90 features of index sets ! program main + + + +#define PETSC_USE_FORTRAN_MODULES +#if defined(PETSC_USE_FORTRAN_MODULES) +#include +#include + use petscvec implicit none - +#else + implicit none #include #include #include +#endif - PetscErrorCode ierr - PetscInt indices(5),n - PetscInt five - PetscMPIInt rank + + PetscErrorCode :: ierr + PetscInt :: indices(5),n + PetscInt :: five + PetscMPIInt :: rank PetscInt, pointer :: idx(:) - IS is +#if defined(PETSC_USE_FORTRAN_DATATYPES) + Type(IS) :: myis +#else + IS :: myis +#endif five = 5 - call PetscInitialize(PETSC_NULL_CHARACTER,ierr) + call PetscInitialize(PETSC_NULL_CHARACTER,ierr);CHKERRQ(ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr) ! Create an index set with 5 entries. Each processor creates @@ -40,19 +55,19 @@ indices(4) = rank + 4 indices(5) = rank + 5 call ISCreateGeneral(PETSC_COMM_SELF,five,indices, & - & PETSC_COPY_VALUES,is,ierr) + & PETSC_COPY_VALUES,myis,ierr);CHKERRQ(ierr) ! Print the index set to stdout - call ISView(is,PETSC_VIEWER_STDOUT_SELF,ierr) + call ISView(myis,PETSC_VIEWER_STDOUT_SELF,ierr);CHKERRQ(ierr) ! Get the number of indices in the set - call ISGetLocalSize(is,n,ierr) + call ISGetLocalSize(myis,n,ierr);CHKERRQ(ierr) ! Get the indices in the index set - call ISGetIndicesF90(is,idx,ierr) + call ISGetIndicesF90(myis,idx,ierr);CHKERRQ(ierr) if (associated(idx)) then write (*,*) 'Association check passed' @@ -72,14 +87,14 @@ ! Once we no longer need access to the indices they should ! returned to the system - call ISRestoreIndicesF90(is,idx,ierr) + call ISRestoreIndicesF90(myis,idx,ierr);CHKERRQ(ierr) ! All PETSc objects should be destroyed once they are ! no longer needed - call ISDestroy(is,ierr) + call ISDestroy(myis,ierr);CHKERRQ(ierr) call PetscFinalize(ierr) - end + end program main