Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SCM syntax highlighting & preventing 3-way merges
pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ x64

# test artifacts:
/*.pdf
/*.py
/*.py
/coverage

# pixi environments
.pixi/*
!.pixi/config.toml
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NumDiff -- Numerical Differentiation Library
https://github.com/jacobwilliams/NumDiff

Copyright (c) 2016-2022, Jacob Williams
Copyright (c) 2016-2026, Jacob Williams
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
67 changes: 67 additions & 0 deletions coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash
# Script to run tests with coverage and generate reports

set -e

COV_DIR="coverage"

# Find the correct gcov (matching gfortran version)
GCOV=$(dirname $(which gfortran))/gcov

echo "Using gcov: $GCOV"
echo ""
echo "================================================"
echo "Running tests with coverage..."
echo "================================================"

# Clear the execution counts of any previous run (so they don't accumulate)
find build -name "*.gcda" -delete 2>/dev/null || true

# Build and run tests with coverage flags
fpm test --flag "--coverage"

echo ""
echo "================================================"
echo "Generating coverage report with lcov..."
echo "================================================"

# Create a fresh coverage directory and copy the build artifacts into it. Only
# from the build just made: older coverage builds (with a different build-flag
# hash, e.g. after an fpm.toml change) hold stale data for the same files.
LATEST_GCNO=$(ls -t build/gfortran_*/*/*.gcno | head -1)
BUILD_DIR=$(dirname "$(dirname "$LATEST_GCNO")")
echo "Using build directory: $BUILD_DIR"
rm -rf "$COV_DIR"
mkdir -p "$COV_DIR"
cp -r "$BUILD_DIR"/*/* "$COV_DIR/" 2>/dev/null || true
# don't show coverage of test/examples programs:
rm -rf "$COV_DIR"/test_*
rm -rf "$COV_DIR"/example_*
# we want to skip the files that start with 'build_dependencies' because they are not part of the source code
find "$COV_DIR" -name "build_dependencies*" -exec rm -rf {} +

# Capture initial coverage (baseline)
lcov --ignore-errors inconsistent --gcov-tool "$GCOV" --capture --initial --base-directory . --directory "$COV_DIR" --output-file "$COV_DIR/coverage.base" --quiet

# Capture test execution coverage
lcov --ignore-errors inconsistent --gcov-tool "$GCOV" --capture --base-directory . --directory "$COV_DIR" --output-file "$COV_DIR/coverage.capture" --quiet

# Combine baseline and test coverage
lcov --add-tracefile "$COV_DIR/coverage.base" --add-tracefile "$COV_DIR/coverage.capture" --output-file "$COV_DIR/coverage.info" --quiet

echo ""
echo "================================================"
echo "Coverage Summary"
echo "================================================"

# Display summary
lcov --summary "$COV_DIR/coverage.info"

echo ""
echo "Coverage data saved to: $COV_DIR/coverage.info"
echo ""
echo "generate HTML report:"

genhtml $COV_DIR/coverage.info --output-directory $COV_DIR/html --dark-mode

echo ""
25 changes: 5 additions & 20 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name = "NumDiff"
version = "1.5.1"
version = "1.8.2"
author = "Jacob Williams"
maintainer = "Jacob Williams"
copyright = "Copyright (c) 2016-2022, Jacob Williams"
copyright = "Copyright (c) 2016-2026, Jacob Williams"
license = "BSD-3"
description = "Modern Fortran Numerical Differentiation Library"
homepage = "https://github.com/jacobwilliams/NumDiff"
Expand All @@ -14,24 +14,9 @@ source-dir = "src"
library = true

[build]
auto-executables = false
auto-examples = false
auto-tests = false
auto-executables = true
auto-examples = true
auto-tests = true

[dev-dependencies]
pyplot-fortran = { git="https://github.com/jacobwilliams/pyplot-fortran.git", tag = "3.2.1" }

[[test]]
name = "dsm_test"
source-dir = "tests"
main = "dsm_test.f90"

[[test]]
name = "test1"
source-dir = "tests"
main = "test1.f90"

[[test]]
name = "test2"
source-dir = "tests"
main = "test2.f90"
2,229 changes: 2,229 additions & 0 deletions pixi.lock

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[workspace]
authors = ["Jacob Williams <jacobwilliams@users.noreply.github.com>"]
channels = ["conda-forge"]
name = "NumDiff"
platforms = ["osx-arm64"]
version = "1.8.2"

[tasks]

[dependencies]
gfortran = "15.*"
fpm = ">=0.13.0,<0.14"
python = ">=3.14.7,<3.15"
graphviz = ">=14.1.2,<15"
ford = ">=7.0.13,<8"
matplotlib = ">=3.11.2,<4"
lcov = ">=2.5,<3"
4 changes: 2 additions & 2 deletions src/cache_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ subroutine initialize_cache(me,isize,n,m,chunk_size)
me%m = m

if (present(chunk_size)) then
me%chunk_size = chunk_size
me%chunk_size = max(1,chunk_size)
else
me%chunk_size = 100
end if
Expand All @@ -95,7 +95,7 @@ subroutine print_cache(me,iunit)
write(iunit,'(A)') ''
write(iunit,'(A)') '------------------------'
if (allocated(me%c)) then
do i = 1, size(me%c)
do i = lbound(me%c,1), ubound(me%c,1) ! note: the table is 0-based
if (allocated(me%c(i)%x)) then
write(iunit,'(A)') ''
write(iunit,'(A,1X,I10)') 'Entry ',i
Expand Down
8 changes: 6 additions & 2 deletions src/dsm_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ subroutine dsm(m,n,Npairs,Indrow,Indcol,Ngrp,Maxgrp,Mingrp,Info,Ipntr,Jpntr)
!! note that `jpntr(n+1)-1` is then the number of non-zero
!! elements of the matrix `a`.

integer,dimension(max(m,6*n)) :: iwa !! an integer work array
integer,dimension(:),allocatable :: iwa !! an integer work array
integer :: i , ir , j , jp , k , maxclq , nnz , numgrp

allocate(iwa(max(m,6*n)))

! check the input data.

Info = 0
Expand Down Expand Up @@ -395,7 +397,9 @@ subroutine ido(m,n,Indrow,Jpntr,Indcol,Ipntr,Ndeg,List,Maxclq, &
do ir = 1 , m
maxlst = maxlst + (Ipntr(ir+1)-Ipntr(ir))**2
enddo
maxlst = maxlst/n
! at least one column must be examined, otherwise
! jcol would not be set in the selection loop below:
maxlst = max(1,maxlst/n)
Maxclq = 0
numord = 1

Expand Down
Loading
Loading