Statistics
| Branch: | Revision:

root / synthbench / euroben-dm / mod2as / getmatvec.f @ 0:839f52ef7657

History | View | Annotate | Download (2.4 kB)

1
      Subroutine getmatvec( ncols, nrows, nelmts, indx, rowp, matvals,
2
     &                      invec )
3
! ----------------------------------------------------------------------
4
! --- 'getmatvec' makes the data of the CRS matrix and the input vector.
5
!     The number of non-zero elements/row may randomly vary by 20%.
6
! ----------------------------------------------------------------------
7
      Use                      numerics
8
      Use                      dist_module
9
      Use                      ran_module
10
      Implicit                 None
11
      Include                  'mpif.h'
12

    
13
      Integer               :: ncols, nrows, nelmts
14
      Integer               :: indx(nelmts), rowp(nrows)
15
      Real(l_)              :: matvals(nelmts), invec(ncols)
16
      Real(l_), Allocatable :: varelts(:)
17
      Integer               :: felprow, i, mdim, nvarelts
18
! ----------------------------------------------------------------------
19
      Allocate ( varelts(nelmts) )
20
      felprow = Int( (0.80*nelmts)/nrows ) + 1
21
      nvarelts = felprow/2 + 1
22
      x1       = 1999*me + 1
23
      x2       = 1999*me + 2003
24
      Call rinit
25
      Call ranfil( varelts, nelmts )
26
! ----------------------------------------------------------------------
27
! --- Generate the rowpointers subject to a variability of 20% in the
28
!     number of elements per row.
29
! ----------------------------------------------------------------------
30
      rowp(1) = 1
31
      Do i = 2, nrows
32
         rowp(i) = rowp(i-1) + Int( felprow + 
33
     &                         nvarelts*(varelts(i) - 0.5d0) ) + 1
34
      End Do
35
! ----------------------------------------------------------------------
36
! --- Be sure that the last rowpointers is <= nelmts.
37
! ----------------------------------------------------------------------
38
      rowp(nrows) = Min( rowp(nrows), nelmts )
39
! ----------------------------------------------------------------------
40
! --- Generate the index array 'indx'.
41
! ----------------------------------------------------------------------     
42
      Call random_number( varelts )
43
      indx = Int( ncols*varelts ) + 1
44
! ----------------------------------------------------------------------
45
! --- Generate the matrix array 'matvals' and input vector 'invec'.
46
! ----------------------------------------------------------------------
47
      matvals = 1.0_l_
48
      invec   = 1.0_l_
49
      Deallocate(  varelts )
50
! ----------------------------------------------------------------------
51
      End Subroutine getmatvec