~fluidity-core/fluidity/sea-ice-branch

« back to all changes in this revision

Viewing changes to femtools/Petsc_Tools.F90

  • Committer: Simon Mouradian
  • Date: 2012-10-19 10:35:59 UTC
  • mfrom: (3520.32.371 fluidity)
  • Revision ID: simon.mouradian06@imperial.ac.uk-20121019103559-y36qa47phc69q8sc
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
  use profiler
41
41
#ifdef HAVE_PETSC_MODULES
42
42
  use petsc 
43
 
#if PETSC_VERSION_MINOR==0
44
 
  use petscvec 
45
 
  use petscmat 
46
 
  use petscksp 
47
 
  use petscpc 
48
 
  use petscis 
49
 
  use petscmg  
50
 
#endif
51
43
#endif
52
44
  implicit none
53
45
#include "petscversion.h"
54
46
#ifdef HAVE_PETSC_MODULES
55
 
#if PETSC_VERSION_MINOR==0
56
 
#include "finclude/petscvecdef.h"
57
 
#include "finclude/petscmatdef.h"
58
 
#include "finclude/petsckspdef.h"
59
 
#include "finclude/petscpcdef.h"
60
 
#include "finclude/petscviewerdef.h"
61
 
#include "finclude/petscisdef.h"
62
 
#else
63
47
#include "finclude/petscdef.h"
64
 
#endif
65
48
#else
66
49
#include "finclude/petsc.h"
67
 
#if PETSC_VERSION_MINOR==0
68
 
#include "finclude/petscvec.h"
69
 
#include "finclude/petscmat.h"
70
 
#include "finclude/petscksp.h"
71
 
#include "finclude/petscpc.h"
72
 
#include "finclude/petscviewer.h"
73
 
#include "finclude/petscis.h"
74
 
#endif
75
50
#endif
76
51
 
77
52
  PetscReal, parameter, private :: dummy_petsc_real = 0.0
139
114
  public addup_global_assembly
140
115
  ! for petsc_numbering:
141
116
  public incref, decref, addref
142
 
  
 
117
#if PETSC_VERSION_MINOR>=3
 
118
#define MatCreateSeqAIJ myMatCreateSeqAIJ
 
119
#define MatCreateMPIAIJ myMatCreateMPIAIJ
 
120
#define MatCreateSeqBAIJ myMatCreateSeqBAIJ
 
121
#define MatCreateMPIBAIJ myMatCreateMPIBAIJ
 
122
  public MatCreateSeqAIJ, MatCreateMPIAIJ, MatCreateSeqBAIJ, MatCreateMPIBAIJ
 
123
#endif
143
124
contains
144
125
 
145
126
  ! Note about definitions in this module:
1467
1448
    PetscErrorCode :: ierr
1468
1449
    call PetscInitialize(PETSC_NULL_CHARACTER, ierr); CHKERRQ(ierr);
1469
1450
  end subroutine Initialize_Petsc
1470
 
  
 
1451
 
 
1452
! In petsc-3.3 the MatCreate[B]{Seq|MPI}() routines have changed to MatCreate[B]Aij
 
1453
! and MatSetup always needs to be called
 
1454
#if PETSC_VERSION_MINOR>=3
 
1455
  subroutine MatCreateSeqAIJ(MPI_Comm, nrows, ncols, &
 
1456
      nz, nnz, M, ierr)
 
1457
    integer, intent(in):: MPI_Comm
 
1458
    PetscInt, intent(in):: nrows, ncols, nz
 
1459
    PetscInt, dimension(:), intent(in):: nnz
 
1460
    Mat, intent(out):: M
 
1461
    PetscErrorCode, intent(out):: ierr
 
1462
 
 
1463
    call MatCreateAij(MPI_Comm, nrows, ncols, nrows, ncols, &
 
1464
      nz, nnz, 0, PETSC_NULL_INTEGER, M, ierr)
 
1465
    call MatSetup(M, ierr)
 
1466
 
 
1467
  end subroutine MatCreateSeqAIJ
 
1468
 
 
1469
  subroutine MatCreateMPIAIJ(MPI_Comm, nprows, npcols, &
 
1470
      nrows, ncols, &
 
1471
      dnz, dnnz, onz, onnz, M, ierr)
 
1472
    integer, intent(in):: MPI_Comm
 
1473
    PetscInt, intent(in):: nprows, npcols,nrows, ncols, dnz, onz
 
1474
    PetscInt, dimension(:), intent(in):: dnnz, onnz
 
1475
    Mat, intent(out):: M
 
1476
    PetscErrorCode, intent(out):: ierr
 
1477
 
 
1478
    call MatCreateAij(MPI_Comm, nprows, npcols, nrows, ncols, &
 
1479
      dnz, dnnz, onz, onnz, M, ierr)
 
1480
    call MatSetup(M, ierr)
 
1481
 
 
1482
  end subroutine MatCreateMPIAIJ
 
1483
 
 
1484
  subroutine MatCreateSeqBAIJ(MPI_Comm, bs, nrows, ncols, &
 
1485
      nz, nnz, M, ierr)
 
1486
    integer, intent(in):: MPI_Comm
 
1487
    PetscInt, intent(in):: bs, nrows, ncols, nz
 
1488
    PetscInt, dimension(:), intent(in):: nnz
 
1489
    Mat, intent(out):: M
 
1490
    PetscErrorCode, intent(out):: ierr
 
1491
 
 
1492
    call MatCreateBAij(MPI_Comm, bs, nrows, ncols, nrows, ncols, &
 
1493
      nz, nnz, 0, PETSC_NULL_INTEGER, M, ierr)
 
1494
    call MatSetup(M, ierr)
 
1495
 
 
1496
  end subroutine MatCreateSeqBAIJ
 
1497
 
 
1498
  subroutine MatCreateMPIBAIJ(MPI_Comm, bs, nprows, npcols, &
 
1499
      nrows, ncols, &
 
1500
      dnz, dnnz, onz, onnz, M, ierr)
 
1501
    integer, intent(in):: MPI_Comm
 
1502
    PetscInt, intent(in):: bs, nprows, npcols,nrows, ncols, dnz, onz
 
1503
    PetscInt, dimension(:), intent(in):: dnnz, onnz
 
1504
    Mat, intent(out):: M
 
1505
    PetscErrorCode, intent(out):: ierr
 
1506
 
 
1507
    call MatCreateBAij(MPI_Comm, bs, nprows, npcols, nrows, ncols, &
 
1508
      dnz, dnnz, onz, onnz, M, ierr)
 
1509
    call MatSetup(M, ierr)
 
1510
 
 
1511
  end subroutine MatCreateMPIBAIJ
 
1512
#endif
 
1513
 
1471
1514
#include "Reference_count_petsc_numbering_type.F90"
1472
1515
end module Petsc_Tools
1473
1516
 
1477
1520
! this routine calls MatGetInfo with an implicit interface.
1478
1521
subroutine myMatGetInfo(A, flag, info, ierr)
1479
1522
#include "finclude/petsc.h"
1480
 
#if PETSC_VERSION_MINOR==0
1481
 
#include "finclude/petscmat.h"
1482
 
#endif
1483
1523
Mat, intent(in):: A
1484
1524
MatInfoType, intent(in):: flag
1485
1525
double precision, dimension(:), intent(out):: info