LCOV - code coverage report
Current view: top level - chem/private - nuclide_set_mod.f90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 95.8 % 48 46
Test Date: 2026-01-06 18:03:11 Functions: 100.0 % 3 3

            Line data    Source code
       1              : ! ***********************************************************************
       2              : !
       3              : !   Copyright (C) 2010  Ed Brown & The MESA Team
       4              : !
       5              : !   This program is free software: you can redistribute it and/or modify
       6              : !   it under the terms of the GNU Lesser General Public License
       7              : !   as published by the Free Software Foundation,
       8              : !   either version 3 of the License, or (at your option) any later version.
       9              : !
      10              : !   This program is distributed in the hope that it will be useful,
      11              : !   but WITHOUT ANY WARRANTY; without even the implied warranty of
      12              : !   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      13              : !   See the GNU Lesser General Public License for more details.
      14              : !
      15              : !   You should have received a copy of the GNU Lesser General Public License
      16              : !   along with this program. If not, see <https://www.gnu.org/licenses/>.
      17              : !
      18              : ! ***********************************************************************
      19              : 
      20              :       module nuclide_set_mod
      21              : 
      22              :       use chem_def
      23              :       use const_def, only: dp
      24              : 
      25              :       implicit none
      26              : 
      27              :       contains
      28              : 
      29       828616 :       function rank_in_set(iso, set)
      30              :          character(len=iso_name_length), intent(in) :: iso
      31              :          type(nuclide_set), dimension(:), intent(in) :: set
      32              :          integer :: rank_in_set
      33              :          integer :: low, high, mid, i
      34              :          integer, parameter :: max_cycles = 20
      35       828616 :          low = 1
      36       828616 :          high = size(set)
      37       828616 :          if (adjustl(iso) < adjustl(set(low)% nuclide) .or. adjustl(iso) > adjustl(set(high)% nuclide)) then
      38           12 :             rank_in_set = nuclide_not_found
      39           12 :             return
      40              :          end if
      41     11430461 :          do i = 1, max_cycles
      42     11430461 :             if (high-low <=1) then
      43       828604 :                if (adjustl(iso) == adjustl(set(high)% nuclide)) then
      44       825493 :                   rank_in_set = set(high)% rank
      45         3111 :                else if (adjustl(iso) == adjustl(set(low)% nuclide)) then
      46           12 :                   rank_in_set = set(low)% rank
      47              :                else
      48              :                   rank_in_set = nuclide_not_found
      49              :                end if
      50       828604 :                return
      51              :             end if
      52     10601857 :             mid = (high+low)/2
      53     10601857 :             if (adjustl(iso) <= adjustl(set(mid)% nuclide)) then
      54              :                high = mid
      55      5077982 :             else if (adjustl(iso) > adjustl(set(mid)% nuclide)) then
      56      5077982 :                low = mid
      57              :             end if
      58              :          end do
      59            0 :          rank_in_set = nuclide_not_found
      60            0 :       end function rank_in_set
      61              : 
      62              : 
      63            3 :       subroutine sort_nuclide_set(set)
      64              :          type(nuclide_set), dimension(:), intent(inout) :: set
      65              :          integer :: n, i, ir, j, l
      66              :          type(nuclide_set) :: ts
      67              : 
      68            3 :          n = size(set)
      69            3 :          if (size(set) < 2) return
      70            3 :          l = n/2+1
      71            3 :          ir = n
      72            3 :          do
      73        35349 :             if (l > 1) then
      74        11784 :                l = l-1
      75        11784 :                ts = set(l)
      76              :             else
      77        23565 :                ts = set(ir)
      78        23565 :                set(ir) = set(1)
      79        23565 :                ir = ir-1
      80        23565 :                if (ir == 1) then
      81            3 :                   set(1) = ts
      82            3 :                   return
      83              :                end if
      84              :             end if
      85        35346 :             i = l
      86        35346 :             j = l+l
      87              :             do
      88       300528 :                if (j > ir) exit
      89       265182 :                if (j < ir) then
      90       265137 :                   if (compare_lt(set(j), set(j+1))) j = j+1
      91              :                end if
      92       300528 :                if (compare_lt(ts, set(j))) then
      93       253512 :                   set(i) = set(j)
      94       253512 :                   i = j
      95       253512 :                   j = j+j
      96              :                else
      97        11670 :                   j = ir + 1
      98              :                end if
      99              :             end do
     100        35346 :             set(i) = ts
     101              :          end do
     102              : 
     103              :          contains
     104              : 
     105       530319 :          logical function compare_lt(a, b)
     106              :             type(nuclide_set), intent(in) :: a, b
     107       530319 :             compare_lt = (adjustl(a% nuclide) < adjustl(b% nuclide))
     108       530319 :          end function compare_lt
     109              : 
     110              :       end subroutine sort_nuclide_set
     111              : 
     112              :       end module nuclide_set_mod
        

Generated by: LCOV version 2.0-1