Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge berkeleylab fork upstream #31

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
1fffb72
Add new CI yaml file to build and test with LLVM Flang from a
ktras Sep 3, 2024
fdb04c8
Merge pull request #15 from BerkeleyLab/add-flang-to-ci
rouson Sep 7, 2024
a7632f4
Merge pull request #18 from BerkeleyLab/increment-version
rouson Sep 10, 2024
09f0fcd
doc(README): fix flang-new testing instructions
rouson Sep 21, 2024
4939b58
fix(CI): edit workflow to pass fpm flags
rouson Sep 21, 2024
f115d56
fix(CI): export FPM_FC and FPM_FFLAGS
rouson Sep 21, 2024
49966b2
fix(CI): update GitHub Actions versions
rouson Sep 21, 2024
c05dd95
Merge pull request #19 from BerkeleyLab/fix-n-doc-test-workflow
rouson Sep 21, 2024
33ac9fc
doc(README): instruct to export FPM_{FC,FFLAGS)
rouson Sep 21, 2024
1ab6b65
Merge pull request #20 from BerkeleyLab/update-README
rouson Sep 21, 2024
54c3b6e
fix(test_t): work around flang-new line-wrap bug
rouson Sep 22, 2024
2f5ed5a
build: define & use language-feature macros
rouson Sep 22, 2024
3a02b5d
fix(test/main.F90): fix edit descriptor
rouson Sep 22, 2024
1eb98b8
Merge pull request #21 from BerkeleyLab/flang-issue-109589
rouson Sep 22, 2024
c761b15
feat(string_t): read character-array json values
rouson Oct 24, 2024
a06c827
fix(string_test):no string-array reads if gfortran
rouson Oct 25, 2024
5ab3443
Merge pull request #22 from BerkeleyLab/extract-string-array
rouson Oct 25, 2024
7c42253
chore(julienne_m):rm redundant "public" statements
rouson Oct 26, 2024
09b170c
chore: add copyright headers
rouson Oct 26, 2024
3ef050f
feat(string_t): bracketing type-bound procedure
rouson Oct 26, 2024
e9253e8
feat(string_t): operator(.csv.), operator(.sv.)
rouson Oct 27, 2024
e2c7e50
fix: work around gfortran bug
rouson Oct 27, 2024
ed308b1
Merge pull request #23 from BerkeleyLab/string-bracketing-csv-json-array
rouson Oct 27, 2024
0b0f566
fix(test_t): prevent subject wrapping in report
rouson Oct 27, 2024
c6c6a83
Merge pull request #24 from BerkeleyLab/fix-test-subject-print
rouson Oct 27, 2024
022e441
fix(fpm.toml): update version number to 1.5.2
rouson Oct 27, 2024
8acc443
fix(file_t): format write_lines output
rouson Oct 27, 2024
4e09b77
chore(fpm.toml): update version to 1.5.3
rouson Oct 27, 2024
814fa6a
Merge pull request #25 from BerkeleyLab/fix-file_t-line-wrap
rouson Oct 27, 2024
34db8b1
test(command_line_t): improve test robustness
rouson Dec 17, 2024
d0376f3
fix(command_line_test): support gfortran
rouson Dec 17, 2024
45441b5
fix(CI): update macOS version from 12 to 13
rouson Dec 17, 2024
17f85c5
fix(command_line_t): flag_value() for missing vals
rouson Dec 17, 2024
9a87a92
fix(.gitignore): add .smod submodule extension
rouson Dec 17, 2024
5886f35
chore(julienne_test_m): preprocess
rouson Dec 19, 2024
0be1298
Merge pull request #26 from BerkeleyLab/fix-commmand-line-tests
rouson Dec 19, 2024
00d1a02
refact(test_result): replace string_t with char
rouson Dec 30, 2024
9e57328
test(test_description_t): check substring search
rouson Dec 30, 2024
d3f11bc
test(CI): upgrade to macos-13
rouson Dec 30, 2024
0749e47
fix(test_description_test): work around gfortran
rouson Dec 31, 2024
f9e1a36
Merge pull request #27 from BerkeleyLab/simplify-julienne_test_t
rouson Dec 31, 2024
b3fdef6
refac(test_description):replace string_t with char
rouson Dec 31, 2024
2dbdaf6
build(fpm): update to assert 2.0.0
rouson Dec 31, 2024
ab70ef2
chore(diagnosis_t): assert diagnostics allocated
rouson Jan 1, 2025
4839127
feat(string_t): add double-precision constructor
rouson Jan 1, 2025
d373a7f
fix(diagnosis_s): preprocess file
rouson Jan 1, 2025
5b32be0
fix(CI): rm redundant gfortran install
rouson Jan 1, 2025
73e0809
fix(test_description): preprocess file
rouson Jan 1, 2025
4826593
chore(diagnosis): rename to test_diagnosis
rouson Jan 1, 2025
9344def
test(test_description): search test descriptions
rouson Jan 1, 2025
937c638
feat(example):demo test failure, diagnostic output
rouson Jan 1, 2025
d84b455
chore(test_result_s): indent diagnostic output
rouson Jan 1, 2025
40752a1
build(example): work around gfortran bug
rouson Jan 1, 2025
efdb7ac
doc(uml): add class diagram
rouson Jan 2, 2025
ba600c8
doc(uml): class diagram for recommended use case
rouson Jan 2, 2025
f00b8c6
chore(subject): rename result variable
rouson Jan 2, 2025
f3301a3
doc(example): add sequene diagram
rouson Jan 2, 2025
d379d91
Merge pull request #28 from BerkeleyLab/diagnostic-output
rouson Jan 2, 2025
6ec72be
feat(string_t): construct from logical & complex
rouson Jan 4, 2025
b78112a
Merge pull request #30 from BerkeleyLab/more-string_t-constructors
rouson Jan 4, 2025
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
11 changes: 3 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12, ubuntu-24.04]
os: [macos-13, ubuntu-24.04]

steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v4

- uses: fortran-lang/setup-fpm@v4
- uses: fortran-lang/setup-fpm@v6.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -23,11 +23,6 @@ jobs:
sudo apt update
sudo apt install -y build-essential gfortran-14 g++-14

- name: Install Dependencies on macOS
if: contains(matrix.os, 'macos')
run: |
brew install gfortran

- name: Build and Run unit tests
run: |
fpm test --compiler gfortran-14
32 changes: 32 additions & 0 deletions .github/workflows/build-with-flang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build with LLVM Flang

on: [push, pull_request]


jobs:
Build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04]
fail-fast: true
container: gmao/llvm-flang:latest
env:
FC: flang-new

steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: fortran-lang/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Test with LLVM Flang
if: contains(matrix.os, 'ubuntu')
run: |
fpm --version
$FC --version
export FPM_FC=$FC
export FPM_FFLAGS="-mmlir -allow-assumed-rank -O3"
fpm test
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Dependencies Ubuntu
run: |
Expand All @@ -21,7 +21,7 @@ jobs:
ford ford.md
- name: Upload Documentation
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: documentation
path: doc/html
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.smod
*.mod
*.o
a.out
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ fpm test --compiler nagfor --flag -fpp
```

### LLVM Flang
**Experimental**
```
fpm test --compiler flang-new --flag "-mmlir -allow-assumed-rank"
export FPM_FC=flang-new
export FPM_FFLAGS="-mmlir -allow-assumed-rank"
fpm test # Warning: Do not override the FPM_FC or FPM_FFLAGS variables with --compiler or --flag
```
where the flags `-mmlir -allow-assumed-rank` turn on LLVM Flang's experimental support for Fortran's assumed-rank dummy arguments.
where the flags turn on LLVM Flang's experimental support for Fortran assumed-rank dummy arguments.
Flang's capabilities are evolving rapidly so we recommend building a recent version of the main branch of llvm-project.
A script that might be helpful for doing so is in the [handy-dandy] repository.

Expand Down
39 changes: 39 additions & 0 deletions doc/uml/class-diagram.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Julienne Unit Testing Classes
-----------------------------
```mermaid
classDiagram

test_t --> test_result_t : produces
test_description_t --> test_diagnosis_t : "uses to construct test_result_t"
test_result_t --> test_diagnosis_t : "accepts as constructor argument"

class test_t{
<<abstract>>
+ subject() character *
+ results() test_result_t *
+ report(passes : integer, tests : integer)
}

class test_result_t{
- description_ : character
- diagnostics_ : character
- passed : logical
+ test_result_t(description : character, passed : test_diagnosis_t) test_result_t
+ characterize() : character
+ description_contains(character) : logical
+ passed() : logical
}

class test_diagnosis_t{
- test_passed_ : logical
- diagnostics_string_ : character
+ test_diagnosis_t(test_passed : logical, diagnostics_string : character) test_diagnosis_t
}

class test_description_t{
- description_ : character
- diagnosis_function : procecure(diagnosis_function_i), pointer
+ test_description_t(description : character, diagnosis_function : procedure(diagnosis_function_i))
+ run() test_result_t
+ contains_text(character) logical
}
13 changes: 13 additions & 0 deletions doc/uml/sequence-diagram.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Example Sequence Diagram
------------------------
```mermaid
sequenceDiagram
main->>specimen_test_t: report(passes, tests)
test_t ->>command_line_t: flag_value("--contains")
command_line_t ->> specimen_test_t : test_description_substring
test_t ->> test_t : subject
test_t ->> test_t : results
test_t ->> test_description_t : construct
test_t ->> test_result_t : construct
test_t ->> test_result_t : characterize
test_t ->> test_result_t : passed
51 changes: 51 additions & 0 deletions example/example-test-suite/main.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
! Copyright (c) 2024, The Regents of the University of California and Sourcery Institute
! Terms of use are as specified in LICENSE.txt

#include "language-support.F90"

program main
!! Example test main program to demonstrate the printing of diagnostic output when a test fails
use julienne_m, only : command_line_t
use specimen_test_m, only : specimen_test_t
implicit none

type(specimen_test_t) specimen_test
integer :: passes=0, tests=0

call print_usage_and_stop_if_help_requested
call specimen_test%report(passes, tests)
call report_tally_and_error_stop_if_test_fails

contains

subroutine print_usage_and_stop_if_help_requested
type(command_line_t) command_line
if (command_line%argument_present([character(len=len("--help"))::"--help","-h"])) then
print *
print '(a)', 'Usage: fpm run --example main -- [--help] | [--contains <substring>]'
print *
print '(a)', 'where square brackets ([]) denote optional arguments, a pipe (|) separates alternative arguments,'
print '(a)', 'angular brackets (<>) denote a user-provided value, and passing a substring limits execution to'
print '(a)', 'the tests with test subjects or test descriptions containing the user-specified substring.'
stop
else
print *
print "(a)", "Append '-- --help' or '-- -h' to your `fpm test` command to display usage information."
end if
end subroutine

subroutine report_tally_and_error_stop_if_test_fails

#if HAVE_MULTI_IMAGE_SUPPORT
if (this_image()==1) then
#endif
print *
print '(*(a,:,g0))', "_________ In total, ",passes," of ",tests, " tests pass. _________"
if (passes /= tests) error stop "Some tests failed."
#if HAVE_MULTI_IMAGE_SUPPORT
end if
#endif

end subroutine

end program
19 changes: 19 additions & 0 deletions example/example-test-suite/specimen_m.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
! Copyright (c) 2024, The Regents of the University of California and Sourcery Institute
! Terms of use are as specified in LICENSE.txt
module specimen_m
!! Example test specimen corresponding to the test defined in specimen_test_m.F90
implicit none

type specimen_t
contains
procedure, nopass :: zero
end type

contains

pure function zero() result(incorrect_value)
integer incorrect_value
incorrect_value = 1
end function

end module
80 changes: 80 additions & 0 deletions example/example-test-suite/specimen_test_m.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
! Copyright (c) 2024, The Regents of the University of California and Sourcery Institute
! Terms of use are as specified in LICENSE.txt

#include "language-support.F90"

module specimen_test_m
!! Example unit test for the specimen_t test subject
use specimen_m, only : specimen_t
use julienne_m, only : &
string_t, &
test_t, &
test_result_t, &
test_description_t, &
test_description_substring, &
test_diagnosis_t
#if ! HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY
use julienne_m, only : diagnosis_function_i ! work around gfortran's missing Fortran 2008 feature
#endif

implicit none

private
public :: specimen_test_t

type, extends(test_t) :: specimen_test_t
contains
procedure, nopass :: subject
procedure, nopass :: results
end type

contains

pure function subject() result(specimen_description)
character(len=:), allocatable :: specimen_description
specimen_description = "A specimen_t object"
end function

function results() result(test_results)
type(test_result_t), allocatable :: test_results(:)
type(test_description_t), allocatable :: test_descriptions(:)

#if HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY
test_descriptions = [ &
test_description_t("the type-bound function zero() producing a result of 0", check_zero) &
]
#else
! work around gfortran's missing Fortran 2008 feature
procedure(diagnosis_function_i), pointer :: check_zero_ptr
check_zero_ptr => check_zero

test_descriptions = [ &
test_description_t("the type-bound function zero() producing a result of 0", check_zero_ptr) &
]
#endif
#ifndef __GFORTRAN__
associate(test_subset => pack(test_descriptions, test_descriptions%contains_text(test_description_substring) .or. index(subject(), test_description_substring)/=0))
test_results = test_subset%run()
end associate
#else

test_descriptions = pack(test_descriptions, test_descriptions%contains_text(test_description_substring) .or. index(subject(), test_description_substring)/=0)
test_results = test_descriptions%run()
#endif

end function

function check_zero() result(test_diagnosis)
type(test_diagnosis_t) test_diagnosis
type(specimen_t) specimen
integer, parameter :: expected_value = 0

associate(actual_value => specimen%zero())
test_diagnosis = test_diagnosis_t( &
test_passed = actual_value == expected_value &
,diagnostics_string = "expected value " // string_t(expected_value) //", actual value " // string_t(actual_value) &
)
end associate
end function

end module
4 changes: 2 additions & 2 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name = "julienne"
version = "1.3.0"
version = "1.5.3"
license = "license"
author = "Damian Rouson, Brad Richardson, Patrick Raynaud, Katherine Rasmussen"
maintainer = "[email protected]"
copyright = "Copyright 2024, Sourcery Institute and Berkeley Lab"

[dependencies]
assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.7.0"}
assert = {git = "https://github.com/sourceryinstitute/assert", tag = "2.0.0"}

[install]
library = true
33 changes: 33 additions & 0 deletions include/language-support.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
! Copyright (c), The Regents of the University of California
! Terms of use are as specified in LICENSE.txt

#ifndef HAVE_SELECTED_LOGICAL_KIND
! Define whether the compiler supports standard intrinsic function selected_logical_kind(),
! a feature introduced in Fortran 2023 clause 16.9.182.
#if defined(_CRAYFTN) || defined(NAGFOR) || defined(__flang__)
#define HAVE_SELECTED_LOGICAL_KIND 1
#else
#define HAVE_SELECTED_LOGICAL_KIND 0
#endif
#endif

#ifndef HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY
! Define whether the compiler supports associating a procedure pointer dummy argument with an
! actual argument that is a valid target for the pointer dummy in a procedure assignment, a
! feature introduced in Fortran 2008 and described in Fortran 2023 clause 15.5.2.10 paragraph 5.
#if defined(_CRAYFTN) || defined(__INTEL_COMPILER) || defined(NAGFOR) || defined(__flang__)
#define HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY 1
#else
#define HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY 0
#endif
#endif

#ifndef HAVE_MULTI_IMAGE_SUPPORT
! Define whether the compiler supports the statements and intrinsic procedures that support
! multi-image execution, e.g., this_image(), sync all, etc.
#if defined(_CRAYFTN) || defined(__INTEL_COMPILER) || defined(NAGFOR) || defined(__GFORTRAN__)
#define HAVE_MULTI_IMAGE_SUPPORT 1
#else
#define HAVE_MULTI_IMAGE_SUPPORT 0
#endif
#endif
2 changes: 2 additions & 0 deletions src/julienne/julienne_bin_m.f90
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
! Copyright (c) 2024, The Regents of the University of California and Sourcery Institute
! Terms of use are as specified in LICENSE.txt
module julienne_bin_m
!! distribute item numbers across bins such that the number of items differs by at most 1 between any two bins
implicit none
Expand Down
2 changes: 2 additions & 0 deletions src/julienne/julienne_bin_s.f90
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
! Copyright (c) 2024, The Regents of the University of California and Sourcery Institute
! Terms of use are as specified in LICENSE.txt
submodule(julienne_bin_m) julienne_bin_s
use assert_m, only : assert, intrinsic_array_t
implicit none
Expand Down
3 changes: 2 additions & 1 deletion src/julienne/julienne_command_line_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ module function argument_present(acceptable_argument) result(found)
end function

module function flag_value(flag)
!! result is the value passed adjacent to a command-line flag
!! result = { the value passed immediately after a command-line flag if the flag is present or
!! { an empty string otherwise.
implicit none
character(len=*), intent(in) :: flag
character(len=:), allocatable :: flag_value
Expand Down
Loading