File: ex3f90.F.html

package info (click to toggle)
petsc 3.1.dfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 131,360 kB
  • ctags: 491,710
  • sloc: ansic: 288,064; cpp: 66,909; python: 28,799; fortran: 19,153; makefile: 13,945; sh: 3,502; f90: 1,655; xml: 620; csh: 230; java: 13
file content (108 lines) | stat: -rw-r--r-- 7,168 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<center><a href="ex3f90.F">Actual source code: ex3f90.F</a></center><br>

<html>
<head>
<title></title>
<meta name="generator" content="c2html 0.9.5">
<meta name="date" content="2010-04-08T19:26:08+00:00">
</head>

<body bgcolor="#FFFFFF">
<pre width="80"><a name="line1">  1: </a>!
<a name="line2">  2: </a>!    Description:  Creates an index set based on blocks of integers. Views that index set
<a name="line3">  3: </a>!    and then destroys it.
<a name="line4">  4: </a>!
<a name="line5">  5: </a>!<font color="#B22222">/*T</font>
<a name="line6">  6: </a><font color="#B22222">!    Concepts: index sets^manipulating a block index set;</font>
<a name="line7">  7: </a><font color="#B22222">!    Concepts: Fortran90^accessing indices in index set;</font>
<a name="line8">  8: </a><font color="#B22222">!</font>
<a name="line9">  9: </a><font color="#B22222">!T*/</font>
<a name="line10"> 10: </a>!
<a name="line11"> 11: </a>!  The following include statements are required <font color="#4169E1">for</font> Fortran programs
<a name="line12"> 12: </a>!  that use PETSc index sets:
<a name="line13"> 13: </a>!     petscsys.h  - base PETSc routines
<a name="line14"> 14: </a>!     petscis.h     - index sets (<A href="../../../../../docs/manualpages/IS/IS.html#IS">IS</A> objects)
<a name="line15"> 15: </a>!     petscis.h90   - to allow access to Fortran90 features of index sets
<a name="line16"> 16: </a>!
<a name="line17"> 17: </a>      program main
<a name="line18"> 18: </a>      implicit none

<a name="line20"> 20: </a> #include <A href="../../../../../include/finclude/petscsys.h.html">finclude/petscsys.h</A>
<a name="line21"> 21: </a> #include <A href="../../../../../include/finclude/petscis.h.html">finclude/petscis.h</A>
<a name="line22"> 22: </a><font color="#A020F0">#include </font><font color="#666666">"finclude/petscis.h90"</font><font color="#A020F0"></font>

<a name="line24"> 24: </a>      <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> ierr
<a name="line25"> 25: </a>      <A href="../../../../../docs/manualpages/Sys/PetscInt.html#PetscInt">PetscInt</A> n,bs,issize
<a name="line26"> 26: </a>      <A href="../../../../../docs/manualpages/Sys/PetscInt.html#PetscInt">PetscInt</A> inputindices(4)
<a name="line27"> 27: </a>      <A href="../../../../../docs/manualpages/Sys/PetscInt.html#PetscInt">PetscInt</A>, pointer :: indices(:)
<a name="line28"> 28: </a>      <A href="../../../../../docs/manualpages/IS/IS.html#IS">IS</A>       set
<a name="line29"> 29: </a>      <A href="../../../../../docs/manualpages/Sys/PetscTruth.html#PetscTruth">PetscTruth</A> isablock;

<a name="line31"> 31: </a>      n               = 4
<a name="line32"> 32: </a>      bs              = 3
<a name="line33"> 33: </a>      inputindices(1) = 0
<a name="line34"> 34: </a>      inputindices(2) = 3
<a name="line35"> 35: </a>      inputindices(3) = 9
<a name="line36"> 36: </a>      inputindices(4) = 12
<a name="line37"> 37: </a>
<a name="line38"> 38: </a>      call <A href="../../../../../docs/manualpages/Sys/PetscInitialize.html#PetscInitialize">PetscInitialize</A>(PETSC_NULL_CHARACTER,ierr)
<a name="line39"> 39: </a>
<a name="line40"> 40: </a>!
<a name="line41"> 41: </a>!    Create a block index set. The index set has 4 blocks each of size 3.
<a name="line42"> 42: </a>!    The indices are {0,1,2,3,4,5,9,10,11,12,13,14}
<a name="line43"> 43: </a>!    Note each processor is generating its own index set
<a name="line44"> 44: </a>!    (in this <font color="#4169E1">case</font> they are all identical)
<a name="line45"> 45: </a>!
<a name="line46"> 46: </a>      call <A href="../../../../../docs/manualpages/IS/ISCreateBlock.html#ISCreateBlock">ISCreateBlock</A>(<A href="../../../../../docs/manualpages/Sys/PETSC_COMM_SELF.html#PETSC_COMM_SELF">PETSC_COMM_SELF</A>,bs,n,inputindices,set,ierr)
<a name="line47"> 47: </a>      call <A href="../../../../../docs/manualpages/IS/ISView.html#ISView">ISView</A>(set,<A href="../../../../../docs/manualpages/Viewer/PETSC_VIEWER_STDOUT_SELF.html#PETSC_VIEWER_STDOUT_SELF">PETSC_VIEWER_STDOUT_SELF</A>,ierr)

<a name="line49"> 49: </a>!
<a name="line50"> 50: </a>!    Extract indices from set.
<a name="line51"> 51: </a>!
<a name="line52"> 52: </a>      call <A href="../../../../../docs/manualpages/IS/ISGetLocalSize.html#ISGetLocalSize">ISGetLocalSize</A>(set,issize,ierr)
<a name="line53"> 53: </a>      call <A href="../../../../../docs/manualpages/IS/ISGetIndicesF90.html#ISGetIndicesF90">ISGetIndicesF90</A>(set,indices,ierr)
<a name="line54"> 54: </a>      write(6,100)indices
<a name="line55"> 55: </a> 100  format(12I3)
<a name="line56"> 56: </a>      call <A href="../../../../../docs/manualpages/IS/ISRestoreIndicesF90.html#ISRestoreIndicesF90">ISRestoreIndicesF90</A>(set,indices,ierr)

<a name="line58"> 58: </a>!
<a name="line59"> 59: </a>!    Extract the block indices. This returns one index per block.
<a name="line60"> 60: </a>!
<a name="line61"> 61: </a>      call <A href="../../../../../docs/manualpages/IS/ISBlockGetIndicesF90.html#ISBlockGetIndicesF90">ISBlockGetIndicesF90</A>(set,indices,ierr)
<a name="line62"> 62: </a>      write(6,200)indices
<a name="line63"> 63: </a> 200  format(4I3)
<a name="line64"> 64: </a>      call <A href="../../../../../docs/manualpages/IS/ISBlockRestoreIndicesF90.html#ISBlockRestoreIndicesF90">ISBlockRestoreIndicesF90</A>(set,indices,ierr)

<a name="line66"> 66: </a>!
<a name="line67"> 67: </a>!    Check <font color="#4169E1">if</font> this is really a block index set
<a name="line68"> 68: </a>!
<a name="line69"> 69: </a>      call <A href="../../../../../docs/manualpages/IS/ISBlock.html#ISBlock">ISBlock</A>(set,isablock,ierr)
<a name="line70"> 70: </a>      <font color="#4169E1">if</font> (.not. isablock) then
<a name="line71"> 71: </a>        write(6,*) 'Index set is not blocked!'
<a name="line72"> 72: </a>      endif

<a name="line74"> 74: </a>!
<a name="line75"> 75: </a>!    Determine the block size of the index set
<a name="line76"> 76: </a>!
<a name="line77"> 77: </a>      call <A href="../../../../../docs/manualpages/IS/ISBlockGetBlockSize.html#ISBlockGetBlockSize">ISBlockGetBlockSize</A>(set,bs,ierr)
<a name="line78"> 78: </a>      <font color="#4169E1">if</font> (bs .ne. 3) then
<a name="line79"> 79: </a>        write(6,*) 'Blocksize != 3'
<a name="line80"> 80: </a>      endif

<a name="line82"> 82: </a>!
<a name="line83"> 83: </a>!    Get the number of blocks
<a name="line84"> 84: </a>!
<a name="line85"> 85: </a>      call <A href="../../../../../docs/manualpages/IS/ISBlockGetLocalSize.html#ISBlockGetLocalSize">ISBlockGetLocalSize</A>(set,n,ierr)
<a name="line86"> 86: </a>      <font color="#4169E1">if</font> (n .ne. 4) then
<a name="line87"> 87: </a>        write(6,*) 'Number of blocks != 4'
<a name="line88"> 88: </a>      endif

<a name="line90"> 90: </a>      call <A href="../../../../../docs/manualpages/IS/ISDestroy.html#ISDestroy">ISDestroy</A>(set,ierr)
<a name="line91"> 91: </a>      call <A href="../../../../../docs/manualpages/Sys/PetscFinalize.html#PetscFinalize">PetscFinalize</A>(ierr)
<a name="line92"> 92: </a>      end


</pre>
</body>

</html>