GCC Code Coverage Report


Directory: ./
File: src/eps/tests/test7f.F90
Date: 2026-02-22 03:58:10
Exec Total Coverage
Lines: 64 66 97.0%
Functions: 2 2 100.0%
Branches: 43 80 53.8%

Line Branch Exec Source
1 !
2 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3 ! SLEPc - Scalable Library for Eigenvalue Problem Computations
4 ! Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain
5 !
6 ! This file is part of SLEPc.
7 ! SLEPc is distributed under a 2-clause BSD license (see LICENSE).
8 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9 !
10 ! Program usage: mpiexec -n <np> ./test7f [-help] [-n <n>] [all SLEPc options]
11 !
12 ! Description: Simple example that solves an eigensystem with the EPS object.
13 ! Same problem as ex1f but with simplified output.
14 !
15 ! The command line options are:
16 ! -n <n>, where <n> = number of grid points = matrix size
17 !
18 ! ----------------------------------------------------------------------
19 !
20 #include <slepc/finclude/slepceps.h>
21 77 program test7f
22 5 use slepceps
23 implicit none
24
25 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
26 ! Declarations
27 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
28
29 Mat :: A ! operator matrix
30 EPS :: eps ! eigenproblem solver context
31 EPSType :: tname
32 PetscInt :: n, i, Istart, Iend
33 PetscInt :: nev, nini
34 PetscInt :: col(3)
35 PetscInt :: i0, i1, i2, i3
36 PetscMPIInt :: rank
37 PetscErrorCode :: ierr
38 PetscBool :: flg
39 PetscScalar :: val(3)
40 Vec :: v
41 PetscScalar, parameter :: one = 1.0
42
43 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
44 ! Beginning of program
45 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46
47
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(SlepcInitialize(PETSC_NULL_CHARACTER, ierr))
48
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallMPIA(MPI_Comm_rank(PETSC_COMM_WORLD, rank, ierr))
49 5 n = 30
50
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(PetscOptionsGetInt(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, '-n', n, flg, ierr))
51
52
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (rank == 0) then
53 5 write (*, '(/a,i3,a)') '1-D Laplacian Eigenproblem, n =', n, ' (Fortran)'
54 end if
55
56 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
57 ! Compute the operator matrix that defines the eigensystem, Ax=kx
58 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59
60
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(MatCreate(PETSC_COMM_WORLD, A, ierr))
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(MatSetSizes(A, PETSC_DECIDE, PETSC_DECIDE, n, n, ierr))
62
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(MatSetFromOptions(A, ierr))
63
64 5 i0 = 0
65 5 i1 = 1
66 5 i2 = 2
67 5 i3 = 3
68
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(MatGetOwnershipRange(A, Istart, Iend, ierr))
69
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (Istart == 0) then
70 5 i = 0
71 5 col(1) = 0
72 5 col(2) = 1
73 5 val(1) = 2.0
74 5 val(2) = -1.0
75
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
10 PetscCallA(MatSetValues(A, i1, [i], i2, col, val, INSERT_VALUES, ierr))
76 5 Istart = Istart + 1
77 end if
78
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (Iend == n) then
79 5 i = n - 1
80 5 col(1) = n - 2
81 5 col(2) = n - 1
82 5 val(1) = -1.0
83 5 val(2) = 2.0
84
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
10 PetscCallA(MatSetValues(A, i1, [i], i2, col, val, INSERT_VALUES, ierr))
85 5 Iend = Iend - 1
86 end if
87 5 val(1) = -1.0
88 5 val(2) = 2.0
89 5 val(3) = -1.0
90
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
145 do i = Istart, Iend - 1
91 140 col(1) = i - 1
92 140 col(2) = i
93 140 col(3) = i + 1
94
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
285 PetscCallA(MatSetValues(A, i1, [i], i3, col, val, INSERT_VALUES, ierr))
95 end do
96
97
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY, ierr))
98
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY, ierr))
99
100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(MatCreateVecs(A, v, PETSC_NULL_VEC, ierr))
101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (Istart == 0) then
102 PetscCallA(VecSetValue(v, i0, one, INSERT_VALUES, ierr))
103 end if
104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(VecAssemblyBegin(v, ierr))
105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(VecAssemblyEnd(v, ierr))
106
107 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
108 ! Create the eigensolver and display info
109 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
110
111 ! ** Create eigensolver context
112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(EPSCreate(PETSC_COMM_WORLD, eps, ierr))
113
114 ! ** Set operators. In this case, it is a standard eigenvalue problem
115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(EPSSetOperators(eps, A, PETSC_NULL_MAT, ierr))
116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(EPSSetProblemType(eps, EPS_HEP, ierr))
117
118 ! ** Set solver parameters at runtime
119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(EPSSetFromOptions(eps, ierr))
120
121 ! ** Set initial vectors
122 5 nini = 1
123
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
10 PetscCallA(EPSSetInitialSpace(eps, nini, [v], ierr))
124
125 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
126 ! Solve the eigensystem
127 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
128
129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(EPSSolve(eps, ierr))
130
131 ! ** Optional: Get some information from the solver and display it
132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(EPSGetType(eps, tname, ierr))
133
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (rank == 0) then
134 5 write (*, '(a,a)') ' Solution method: ', tname
135 end if
136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(EPSGetDimensions(eps, nev, PETSC_NULL_INTEGER, PETSC_NULL_INTEGER, ierr))
137
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (rank == 0) then
138 5 write (*, '(a,i2)') ' Number of requested eigenvalues:', nev
139 end if
140
141 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
142 ! Display solution and clean up
143 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
144
145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(EPSErrorView(eps, EPS_ERROR_RELATIVE, PETSC_NULL_VIEWER, ierr))
146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(EPSDestroy(eps, ierr))
147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(MatDestroy(A, ierr))
148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 PetscCallA(VecDestroy(v, ierr))
149
150
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
5 PetscCallA(SlepcFinalize(ierr))
151 end program test7f
152
153 !/*TEST
154 !
155 ! test:
156 ! suffix: 1
157 ! args: -eps_nev 4 -eps_ncv 19
158 ! filter: sed -e "s/83791/83792/"
159 !
160 !TEST*/
161