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:29:33 2012 -0600 @@ -12,23 +12,32 @@ ! petscsys.h - base PETSc routines ! petscis.h - index sets (IS objects) ! petscis.h90 - to allow access to Fortran90 features of index sets -! - program main +! OR (using fortran modules) +! finclude/petscsysdef.h +! finclude/petscisdef.h + program main + + + +#include +#include + use petscis implicit none -#include -#include -#include - 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) :: set +#else + IS :: set +#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 +49,19 @@ indices(4) = rank + 4 indices(5) = rank + 5 call ISCreateGeneral(PETSC_COMM_SELF,five,indices, & - & PETSC_COPY_VALUES,is,ierr) + & PETSC_COPY_VALUES,set,ierr);CHKERRQ(ierr) ! Print the index set to stdout - call ISView(is,PETSC_VIEWER_STDOUT_SELF,ierr) + call ISView(set,PETSC_VIEWER_STDOUT_SELF,ierr);CHKERRQ(ierr) ! Get the number of indices in the set - call ISGetLocalSize(is,n,ierr) + call ISGetLocalSize(set,n,ierr);CHKERRQ(ierr) ! Get the indices in the index set - call ISGetIndicesF90(is,idx,ierr) + call ISGetIndicesF90(set,idx,ierr);CHKERRQ(ierr) if (associated(idx)) then write (*,*) 'Association check passed' @@ -72,14 +81,14 @@ ! Once we no longer need access to the indices they should ! returned to the system - call ISRestoreIndicesF90(is,idx,ierr) + call ISRestoreIndicesF90(set,idx,ierr);CHKERRQ(ierr) ! All PETSc objects should be destroyed once they are ! no longer needed - call ISDestroy(is,ierr) + call ISDestroy(set,ierr);CHKERRQ(ierr) call PetscFinalize(ierr) - end + end program main