Commits

Jed Brown  committed 8178e8b

Fortran: updates for 64-bit indices

We can never pass numeric literals to functions in Fortran.

  • Participants
  • Parent commits 6c87e7e

Comments (0)

Files changed (7)

File src/dm/impls/plex/examples/tests/ex1f90.F

       PetscInt, pointer :: pES(:)
       PetscInt c,d, firstCell, numCells
       PetscInt v, numVertices, numPoints
+      PetscInt i0,i4
       PetscErrorCode ierr
 
+      i0 = 0
+      i4 = 4
+
       call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
       call DMPlexCreate(PETSC_COMM_WORLD, dm, ierr)
       firstCell = 0
       numCells = 2
       numVertices = 6
       numPoints = numCells+numVertices
-      call DMPlexSetChart(dm, 0, numPoints, ierr)
+      call DMPlexSetChart(dm, i0, numPoints, ierr)
       do c=firstCell,numCells-1
-         call DMPlexSetConeSize(dm, c, 4, ierr)
+         call DMPlexSetConeSize(dm, c, i4, ierr)
       end do
       call DMSetUp(dm, ierr)
 

File src/dm/impls/plex/examples/tests/ex2f90.F

       PetscInt, pointer :: nJoin(:)
       PetscInt, pointer :: nMeet(:)
       PetscInt       dim, cell, size
+      PetscInt i0,i1,i2,i3,i4,i5,i6,i7
+      PetscInt i8,i9,i10,i11
       PetscErrorCode ierr
 
+      i0 = 0
+      i1 = 1
+      i2 = 2
+      i3 = 3
+      i4 = 4
+      i5 = 5
+      i6 = 6
+      i7 = 7
+      i8 = 8
+      i9 = 9
+      i10 = 10
+      i11 = 11
+
       call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
       CHKERRQ(ierr)
       call DMPlexCreate(PETSC_COMM_WORLD, dm, ierr)
 ! Make Doublet Mesh from Fig 2 of Flexible Representation of Computational Meshes,
 ! except indexing is from 0 instead of 1 and we obey the new restrictions on
 ! numbering: cells, vertices, faces, edges
-      call DMPlexSetChart(dm, 0, 11, ierr)
+      call DMPlexSetChart(dm, i0, i11, ierr)
       CHKERRQ(ierr)
 !     cells
-      call DMPlexSetConeSize(dm, 0, 3, ierr)
+      call DMPlexSetConeSize(dm, i0, i3, ierr)
       CHKERRQ(ierr)
-      call DMPlexSetConeSize(dm, 1, 3, ierr)
+      call DMPlexSetConeSize(dm, i1, i3, ierr)
       CHKERRQ(ierr)
 !     edges
-      call DMPlexSetConeSize(dm,  6, 2, ierr)
+      call DMPlexSetConeSize(dm,  i6, i2, ierr)
       CHKERRQ(ierr)
-      call DMPlexSetConeSize(dm,  7, 2, ierr)
+      call DMPlexSetConeSize(dm,  i7, i2, ierr)
       CHKERRQ(ierr)
-      call DMPlexSetConeSize(dm,  8, 2, ierr)
+      call DMPlexSetConeSize(dm,  i8, i2, ierr)
       CHKERRQ(ierr)
-      call DMPlexSetConeSize(dm,  9, 2, ierr)
+      call DMPlexSetConeSize(dm,  i9, i2, ierr)
       CHKERRQ(ierr)
-      call DMPlexSetConeSize(dm, 10, 2, ierr)
+      call DMPlexSetConeSize(dm, i10, i2, ierr)
       CHKERRQ(ierr)
 
       call DMSetUp(dm, ierr)
       EC(2) = 7
       EC(3) = 8
       pEC => EC
-      call DMPlexSetCone(dm, 0, pEC, ierr)
+      call DMPlexSetCone(dm, i0, pEC, ierr)
       CHKERRQ(ierr)
       EC(1) = 7
       EC(2) = 9
       EC(3) = 10
       pEC => EC
-      call DMPlexSetCone(dm, 1 , pEC, ierr)
+      call DMPlexSetCone(dm, i1 , pEC, ierr)
       CHKERRQ(ierr)
 
       VE(1) = 2
       VE(2) = 3
       pVE => VE
-      call DMPlexSetCone(dm, 6 , pVE, ierr)
+      call DMPlexSetCone(dm, i6 , pVE, ierr)
       CHKERRQ(ierr)
       VE(1) = 3
       VE(2) = 4
       pVE => VE
-      call DMPlexSetCone(dm, 7 , pVE, ierr)
+      call DMPlexSetCone(dm, i7 , pVE, ierr)
       CHKERRQ(ierr)
       VE(1) = 4
       VE(2) = 2
       pVE => VE
-      call DMPlexSetCone(dm, 8 , pVE, ierr)
+      call DMPlexSetCone(dm, i8 , pVE, ierr)
       CHKERRQ(ierr)
       VE(1) = 3
       VE(2) = 5
       pVE => VE
-      call DMPlexSetCone(dm, 9 , pVE, ierr)
+      call DMPlexSetCone(dm, i9 , pVE, ierr)
       CHKERRQ(ierr)
       VE(1) = 5
       VE(2) = 4
       pVE => VE
-      call DMPlexSetCone(dm, 10 , pVE, ierr)
+      call DMPlexSetCone(dm, i10 , pVE, ierr)
       CHKERRQ(ierr)
 
       call DMPlexSymmetrize(dm,ierr)

File src/ksp/ksp/examples/tutorials/ex13f90.F

       Mat     A
       Vec     b,x
       KSP    ksp
-      PetscInt Ntot
+      PetscInt Ntot,five,one
 
 
 !  Here we assume use of a grid of size m x n, with all points on the
       hy2 = (n+1)*(n+1)
       Ntot = m*n
 
+      five = 5
+      one = 1
+
 !  Create the sparse matrix. Preallocate 5 nonzeros per row.
 
-      call MatCreateSeqAIJ(PETSC_COMM_SELF,Ntot,Ntot,5,                  &
+      call MatCreateSeqAIJ(PETSC_COMM_SELF,Ntot,Ntot,five,              &
      &     PETSC_NULL_INTEGER,A,ierr)
 !
 !  Create vectors. Here we create vectors with no memory allocated.
 !  This way, we can use the data structures already in the program
 !  by using VecPlaceArray() subroutine at a later stage.
 !
-      call VecCreateSeqWithArray(PETSC_COMM_SELF,1,Ntot,                  &
+      call VecCreateSeqWithArray(PETSC_COMM_SELF,one,Ntot,              &
      &     PETSC_NULL_SCALAR,b,ierr)
       call VecDuplicate(b,x,ierr)
 

File src/ksp/ksp/examples/tutorials/ex45f.F

 #include <finclude/petscdmda.h>
 
        PetscInt is,js,iw,jw
+       PetscInt one,three
        PetscErrorCode ierr
        KSP ksp
        DM dm
        external ComputeRHS,ComputeMatrix,ComputeInitialGuess
 
+       one = 1
+       three = 3
+
        call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
        call KSPCreate(MPI_COMM_WORLD,ksp,ierr)
-       call DMDACreate2D(MPI_COMM_WORLD, DMDA_BOUNDARY_NONE,              &
-     &    DMDA_BOUNDARY_NONE, DMDA_STENCIL_STAR, -3,-3, PETSC_DECIDE,       &
-     &    PETSC_DECIDE,1,1, PETSC_NULL_INTEGER, PETSC_NULL_INTEGER,       &
-     &    dm, ierr)
+       call DMDACreate2D(MPI_COMM_WORLD, DMDA_BOUNDARY_NONE,            &
+     &    DMDA_BOUNDARY_NONE, DMDA_STENCIL_STAR,-three,-three,          &
+     &    PETSC_DECIDE,PETSC_DECIDE,one,one, PETSC_NULL_INTEGER,        &
+     &    PETSC_NULL_INTEGER, dm, ierr)
        call KSPSetDM(ksp,dm,ierr)
        call KSPSetComputeInitialGuess(ksp,ComputeInitialGuess,             &
      &                                PETSC_NULL_OBJECT,ierr)

File src/ksp/ksp/examples/tutorials/output/ex45f_1.out

   0 KSP Residual norm 65 
-  1 KSP Residual norm 5.21863 
-  2 KSP Residual norm 0.0654116 
-  3 KSP Residual norm 0.00204869 
-  4 KSP Residual norm 5.18298e-05 
+  1 KSP Residual norm 5.08845 
+  2 KSP Residual norm 0.0636589 
+  3 KSP Residual norm 0.00190718 
+  4 KSP Residual norm 4.89213e-05 

File src/snes/examples/tutorials/ex40f90.F90

       SNES             snes
       PetscErrorCode   ierr
       DM               da
+      PetscInt         ten,two,one
       external         FormFunctionLocal
 
 
       call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
 
+      ten = 10
+      one = 1
+      two = 2
+
       call DMDACreate2d(PETSC_COMM_WORLD,                               &
      &     DMDA_BOUNDARY_NONE,DMDA_BOUNDARY_NONE,                       &
      &                DMDA_STENCIL_BOX,                                 &
-     &                -10,-10,PETSC_DECIDE,PETSC_DECIDE,2,1,            &
+     &                -ten,-ten,PETSC_DECIDE,PETSC_DECIDE,two,one,      &
      &                PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,da,ierr)
 
 

File src/snes/examples/tutorials/output/ex40f90.out

   1 SNES Function norm 21.1059 
   2 SNES Function norm 1.48792 
   3 SNES Function norm 0.0100219 
-  4 SNES Function norm 4.69212e-07 
+  4 SNES Function norm 4.69213e-07 
 SNES Object: 1 MPI processes
-  type: ls
+  type: newtonls
   maximum iterations=50, maximum function evaluations=10000
   tolerances: relative=1e-08, absolute=1e-50, solution=1e-08
   total number of linear solver iterations=4
   total number of function evaluations=22
+  SNESLineSearch Object:   1 MPI processes
+    type: bt
+      interpolation: cubic
+      alpha=1.000000e-04
+    maxstep=1.000000e+08, minlambda=1.000000e-12
+    tolerances: relative=1.000000e-08, absolute=1.000000e-15, lambda=1.000000e-08
+    maximum iterations=40
   KSP Object:   1 MPI processes
     type: fgmres
       GMRES: restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement
         type: lu
           LU: out-of-place factorization
           tolerance for zero pivot 2.22045e-14
+          using diagonal shift on blocks to prevent zero pivot
           matrix ordering: nd
           factor fill ratio given 5, needed 2.38265
             Factored matrix follows:
     Down solver (pre-smoother) on level 1 -------------------------------
       KSP Object:      (mg_levels_1_)       1 MPI processes
         type: chebyshev
-          Chebyshev: eigenvalue estimates:  min = 0.955071, max = 10.5058
+          Chebyshev: eigenvalue estimates:  min = 0.327737, max = 3.60511
           Chebyshev: estimated using:  [0 0.1; 0 1.1]
-          KSP Object:           1 MPI processes
+          KSP Object:          (mg_levels_1_est_)           1 MPI processes
             type: gmres
               GMRES: restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement
               GMRES: happy breakdown tolerance 1e-30
       total: nonzeros=12100, allocated nonzeros=12100
       total number of mallocs used during MatSetValues calls =0
         using I-node routines: found 361 nodes, limit used is 5
-  SNESLineSearch Object:   1 MPI processes
-    type: bt
-      interpolation: cubic
-      alpha=1.000000e-04
-    maxstep=1.000000e+08, minlambda=1.000000e-12
-    tolerances: relative=1.000000e-08, absolute=1.000000e-15, lambda=1.000000e-08
-    maximum iterations=40