GCC Code Coverage Report


Directory: ./
File: src/sys/classes/ds/tests/test14f.F90
Date: 2025-10-04 04:19:13
Exec Total Coverage
Lines: 41 44 93.2%
Functions: 3 3 100.0%
Branches: 29 52 55.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> ./test14f [-help] [-n <n>] [all SLEPc options]
11 !
12 ! Description: Simple example that tests solving a DSNHEP problem.
13 !
14 ! The command line options are:
15 ! -n <n>, where <n> = matrix size
16 !
17 ! ----------------------------------------------------------------------
18 !
19 3 program main
20 #include <slepc/finclude/slepcds.h>
21 2 use slepcds
22 implicit none
23
24 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25 ! Declarations
26 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
27 !
28 ! Variables:
29 ! A problem matrix
30 ! ds dense solver context
31
32 Mat A
33 DS ds
34 PetscInt n, i, ld, zero
35 PetscMPIInt rank
36 PetscErrorCode ierr
37 PetscBool flg
38 PetscScalar wr(100), wi(100)
39 PetscReal re, im
40 2 PetscScalar, pointer :: aa(:,:)
41
42 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
43 ! Beginning of program
44 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
45
46 2 zero = 0
47
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(SlepcInitialize(PETSC_NULL_CHARACTER,ierr))
48
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (ierr .ne. 0) then
49 print*,'SlepcInitialize failed'
50 stop
51 endif
52
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallMPIA(MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr))
53 2 n = 10
54
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(PetscOptionsGetInt(PETSC_NULL_OPTIONS,PETSC_NULL_CHARACTER,'-n',n,flg,ierr))
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (n .gt. 100) then; SETERRA(PETSC_COMM_SELF,1,'Program currently limited to n=100'); endif
56
57
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (rank .eq. 0) then
58 2 write(*,110) n
59 endif
60 110 format (/'Solve a Dense System of type NHEP, n =',I3,' (Fortran)')
61
62 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63 ! Create DS object
64 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
65
66
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(DSCreate(PETSC_COMM_WORLD,ds,ierr))
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(DSSetType(ds,DSNHEP,ierr))
68
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(DSSetFromOptions(ds,ierr))
69 2 ld = n
70
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(DSAllocate(ds,ld,ierr))
71
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(DSSetDimensions(ds,n,zero,zero,ierr))
72
73 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
74 ! Fill with Grcar matrix
75 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
76
77
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(DSGetMat(ds,DS_MAT_A,A,ierr))
78
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(MatDenseGetArray(A,aa,ierr))
79
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 call FillUpMatrix(n,aa)
80
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(MatDenseRestoreArray(A,aa,ierr))
81
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(DSRestoreMat(ds,DS_MAT_A,A,ierr))
82
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(DSSetState(ds,DS_STATE_INTERMEDIATE,ierr))
83
84 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
85 ! Solve the problem and show eigenvalues
86 ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
87
88
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(DSSolve(ds,wr,wi,ierr))
89 ! PetscCallA(DSSort(ds,wr,wi,PETSC_NULL_SCALAR,PETSC_NULL_SCALAR,PETSC_NULL_INTEGER,ierr))
90
91
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (rank .eq. 0) then
92 2 write(*,*) 'Computed eigenvalues ='
93
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
22 do i=1,n
94 #if defined(PETSC_USE_COMPLEX)
95 re = PetscRealPart(wr(i))
96 im = PetscImaginaryPart(wr(i))
97 #else
98 20 re = wr(i)
99 20 im = wi(i)
100 #endif
101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
22 if (abs(im).lt.1.d-10) then
102 write(*,120) re
103 else
104 20 write(*,130) re, im
105 endif
106 end do
107 endif
108 120 format (' ',F8.5)
109 130 format (' ',F8.5,SP,F8.5,'i')
110
111 ! *** Clean up
112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 PetscCallA(DSDestroy(ds,ierr))
113
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
4 PetscCallA(SlepcFinalize(ierr))
114
115 contains
116
117 ! -----------------------------------------------------------------
118
119 2 subroutine FillUpMatrix(n,X)
120 PetscInt n,i,j
121 PetscScalar X(n,n)
122
123
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
20 do i=2,n
124 20 X(i,i-1) = -1.d0
125 end do
126
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
10 do j=0,3
127
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
78 do i=1,n-j
128 76 X(i,i+j) = 1.d0
129 end do
130 end do
131
132 2 end
133
134 end program main
135
136 !/*TEST
137 !
138 ! test:
139 ! suffix: 1
140 ! requires: !complex
141 !
142 !TEST*/
143