Actual source code: ex4f.F90

  1: !
  2: !    Test AO with on IS with 0 entries - Fortran version of ex4.c
  3: !
  4: program main
  5: #include <petsc/finclude/petscao.h>
  6:   use petscao
  7:   implicit none

  9:   PetscErrorCode ierr
 10:   AO ao
 11:   PetscInt localvert(4), nlocal
 12:   PetscMPIInt rank
 13:   IS is
 14:   PetscInt one, zero

 16: !  Needed to work with 64-bit integers from Fortran
 17:   one = 1
 18:   zero = 0

 20:   PetscCallA(PetscInitialize(ierr))
 21:   PetscCallMPIA(MPI_Comm_rank(PETSC_COMM_WORLD, rank, ierr))

 23:   nlocal = 0
 24:   if (rank == 0) then
 25:     nlocal = 4
 26:     localvert(1) = 0
 27:     localvert(2) = 1
 28:     localvert(3) = 2
 29:     localvert(4) = 3
 30:   end if

 32: !     Test AOCreateBasic()
 33:   PetscCallA(AOCreateBasic(PETSC_COMM_WORLD, nlocal, localvert, PETSC_NULL_INTEGER_ARRAY, ao, ierr))
 34:   PetscCallA(AODestroy(ao, ierr))

 36: !     Test AOCreateMemoryScalable()
 37:   PetscCallA(AOCreateMemoryScalable(PETSC_COMM_WORLD, nlocal, localvert, PETSC_NULL_INTEGER_ARRAY, ao, ierr))
 38:   PetscCallA(AODestroy(ao, ierr))

 40:   PetscCallA(AOCreate(PETSC_COMM_WORLD, ao, ierr))
 41:   PetscCallA(ISCreateStride(PETSC_COMM_WORLD, one, zero, one, is, ierr))
 42:   PetscCallA(AOSetIS(ao, is, is, ierr))
 43:   PetscCallA(AOSetType(ao, AOMEMORYSCALABLE, ierr))
 44:   PetscCallA(ISDestroy(is, ierr))
 45:   PetscCallA(AODestroy(ao, ierr))

 47:   PetscCallA(PetscFinalize(ierr))
 48: end

 50: !/*TEST
 51: !
 52: !   test:
 53: !     output_file: output/empty.out
 54: !
 55: !   test:
 56: !      suffix: 2
 57: !      nsize: 2
 58: !      output_file: output/empty.out
 59: !
 60: !TEST*/