GCC Code Coverage Report


Directory: ./
File: tests/unit/05_api/fortran_api_barrier_00.f90
Date: 2026-12-01 10:07:21
Exec Total Coverage
Lines: 6 26 23.1%
Functions: 2 2 100.0%
Branches: 2 24 8.3%

Line Branch Exec Source
1 !-------------------------------------------------------------------------------!
2 ! Copyright 2009-2023 Barcelona Supercomputing Center !
3 ! !
4 ! This file is part of the DLB library. !
5 ! !
6 ! DLB is free software: you can redistribute it and/or modify !
7 ! it under the terms of the GNU Lesser General Public License as published by !
8 ! the Free Software Foundation, either version 3 of the License, or !
9 ! (at your option) any later version. !
10 ! !
11 ! DLB is distributed in the hope that it will be useful, !
12 ! but WITHOUT ANY WARRANTY; without even the implied warranty of !
13 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !
14 ! GNU Lesser General Public License for more details. !
15 ! !
16 ! You should have received a copy of the GNU Lesser General Public License !
17 ! along with DLB. If not, see <https://www.gnu.org/licenses/>. !
18 !-------------------------------------------------------------------------------!
19
20 1 program test
21 use iso_c_binding
22 implicit none
23 include 'dlbf.h'
24 include 'dlbf_drom.h'
25 integer, parameter :: N = 100
26 integer :: num_cpus
27 integer :: err
28 type(c_ptr) :: dlb_barrier_1, dlb_barrier_2
29
30 ! Skip test on systems with fewer than 3 CPUs (3 max barriers)
31 1 num_cpus = 0
32 1 err = dlb_drom_getnumcpus(num_cpus)
33
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (err /= DLB_SUCCESS) error stop "dlb_drom_getnumcpus failed"
34
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (num_cpus < 3) stop
35
36 ✗ err = DLB_Init(0, C_NULL_PTR, "--barrier")
37 ✗ if (err /= DLB_SUCCESS) error stop "dlb_init failed"
38
39 ✗ dlb_barrier_1 = DLB_BarrierNamedRegister("barrier 1", DLB_BARRIER_LEWI_OFF)
40 ✗ if (.not. c_associated(dlb_barrier_1)) error stop "dlb_barriernamedregister (1) failed"
41 ✗ dlb_barrier_2 = DLB_BarrierNamedRegister("barrier 2", DLB_BARRIER_LEWI_ON)
42 ✗ if (.not. c_associated(dlb_barrier_2)) error stop "dlb_barriernamedregister (2) failed"
43
44 ✗ err = DLB_BarrierNamedAttach(dlb_barrier_2)
45 ✗ if (err /= DLB_ERR_PERM) error stop "dlb_barriernamedattach failed"
46
47 ✗ err = DLB_BarrierNamed(dlb_barrier_2)
48 ✗ if (err /= DLB_SUCCESS) error stop "dlb_barriernamed failed"
49
50 ✗ err = DLB_Printshmem(0, DLB_COLOR_AUTO)
51 ✗ if (err /= DLB_SUCCESS) error stop "dlb_printshmem failed"
52
53 ✗ err = DLB_BarrierNamedDetach(dlb_barrier_1)
54 ✗ if (err /= DLB_SUCCESS) error stop "dlb_barriernameddetach failed"
55
56 ✗ err = DLB_BarrierNamed(dlb_barrier_1)
57 ✗ if (err /= DLB_NOUPDT) error stop "dlb_barriernamed failed"
58
59 ✗ err = DLB_Printshmem(0, DLB_COLOR_AUTO)
60 ✗ if (err /= DLB_SUCCESS) error stop "dlb_printshmem failed"
61
62 ✗ err = DLB_Finalize()
63 ✗ if (err /= DLB_SUCCESS) error stop "dlb_finalize failed"
64 1 end program test
65