Skip to content

Commit a62961a

Browse files
authored
Merge pull request #176 from BerkeleyLab/julienne-2.0.0
Switch to Julienne 2.0.0 and Assert 2.1.0
2 parents 66624e9 + 829e2d6 commit a62961a

18 files changed

Lines changed: 561 additions & 443 deletions

.github/workflows/deploy-docs.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ name: Build and Deploy Documentation
22

33
on: [push, pull_request]
44

5-
65
jobs:
76
Build:
8-
runs-on: ubuntu-latest
9-
10-
env:
11-
FC: gfortran
12-
GCC_V: 14
7+
runs-on: ubuntu-22.04
138

149
steps:
1510
- name: Checkout code
@@ -18,17 +13,13 @@ jobs:
1813
- name: Install Dependencies Ubuntu
1914
run: |
2015
sudo apt-get update
21-
sudo apt install -y gfortran-${GCC_V} python3-dev python3 build-essential numdiff graphviz
22-
sudo pip install ford markdown
23-
echo "---------"
24-
gfortran --version
25-
echo "---------"
16+
sudo apt install -y python3-dev python3 build-essential graphviz
17+
sudo python3 -m pip install ford
18+
2619
- name: Build Developer Documenation
2720
run: |
28-
# Turn warnings into errors
29-
ford ford.md > ford_output.txt
30-
cat ford_output.txt; if grep -q -i Warning ford_output.txt; then exit 1; fi
31-
cp ./README.md ./doc/html
21+
ford ford.md
22+
3223
- name: Upload Documentation
3324
uses: actions/upload-artifact@v4
3425
with:

fpm.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ maintainer = "rouson@lbl.gov"
66

77
[dependencies]
88
assert = {git = "https://github.com/berkeleylab/assert", tag = "2.1.0"}
9-
julienne = {git = "https://github.com/BerkeleyLab/julienne", tag = "1.8.4"}
9+
julienne = {git = "https://github.com/BerkeleyLab/julienne", tag = "2.0.0"}
1010
sourcery = {git = "https://github.com/sourceryinstitute/sourcery", tag = "4.5.1"}

include/language-support.F90

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
! Copyright (c), The Regents of the University of California
2+
! Terms of use are as specified in LICENSE.txt
3+
4+
#ifndef HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY
5+
! Define whether the compiler supports associating a procedure pointer dummy argument with an
6+
! actual argument that is a valid target for the pointer dummy in a procedure assignment, a
7+
! feature introduced in Fortran 2008 and described in Fortran 2023 clause 15.5.2.10 paragraph 5.
8+
#if defined(_CRAYFTN) || defined(__INTEL_COMPILER) || defined(NAGFOR) || defined(__flang__)
9+
#define HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY 1
10+
#else
11+
#define HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY 0
12+
#endif
13+
#endif
14+
15+
#ifndef HAVE_MULTI_IMAGE_SUPPORT
16+
! Define whether the compiler supports the statements and intrinsic procedures that support
17+
! multi-image execution, e.g., this_image(), sync all, etc.
18+
#if defined(_CRAYFTN) || defined(__INTEL_COMPILER) || defined(NAGFOR) || defined(__GFORTRAN__)
19+
#define HAVE_MULTI_IMAGE_SUPPORT 1
20+
#else
21+
#define HAVE_MULTI_IMAGE_SUPPORT 0
22+
#endif
23+
#endif

src/matcha/distribution_s.F90

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
! Copyright (c), The Regents of the University of California
22
! Terms of use are as specified in LICENSE.tx
3+
4+
#include "assert_macros.h"
5+
36
submodule(distribution_m) distribution_s
7+
use assert_m
48
use intrinsic_array_m, only : intrinsic_array_t
5-
use do_concurrent_m, only : do_concurrent_sampled_speeds, do_concurrent_my_velocities
6-
use assert_m, only : assert
79
implicit none
810

911
contains
@@ -18,54 +20,57 @@ pure function monotonically_increasing(f) result(monotonic)
1820
module procedure construct
1921
integer i
2022

21-
call assert(all(sample_distribution(:,2)>=0.D0), "distribution_t%construct: sample_distribution>=0.", &
22-
intrinsic_array_t(sample_distribution))
23+
call_assert_diagnose(all(sample_distribution(:,2)>=0.D0), "distribution_t%construct: sample_distribution>=0.", intrinsic_array_t(sample_distribution))
2324

2425
associate(nintervals => size(sample_distribution,1))
2526
distribution%vel_ = [(sample_distribution(i,1), i =1, nintervals)] ! Assign speeds to each distribution bin
2627
distribution%cumulative_distribution_ = [0.D0, [(sum(sample_distribution(1:i,2)), i=1, nintervals)]]
27-
28-
call assert(monotonically_increasing(distribution%cumulative_distribution_), &
29-
"distribution_t: monotonically_increasing(distribution%cumulative_distribution_)", &
30-
intrinsic_array_t(distribution%cumulative_distribution_))
3128
end associate
3229

30+
call_assert_diagnose(monotonically_increasing(distribution%cumulative_distribution_), "distribution_t: monotonically increasing cumulative distribution", intrinsic_array_t(distribution%cumulative_distribution_))
31+
3332
end procedure construct
3433

3534
module procedure cumulative_distribution
36-
call assert(allocated(self%cumulative_distribution_), &
37-
"distribution_t%cumulative_distribution: allocated(cumulative_distribution_)")
35+
call_assert(allocated(self%cumulative_distribution_))
3836
my_cumulative_distribution = self%cumulative_distribution_
3937
end procedure
4038

4139
module procedure velocities
4240

4341
double precision, allocatable :: sampled_speeds(:,:), dir(:,:,:)
44-
integer step
42+
integer cell, step, k
4543

46-
call assert(allocated(self%cumulative_distribution_), &
47-
"distribution_t%cumulative_distribution: allocated(cumulative_distribution_)")
48-
call assert(allocated(self%vel_), "distribution_t%cumulative_distribution: allocated(vel_)")
44+
call_assert(allocated(self%cumulative_distribution_))
45+
call_assert(allocated(self%vel_))
4946

50-
! Sample from the distribution
51-
call do_concurrent_sampled_speeds(speeds, self%vel_, self%cumulative_distribution(), sampled_speeds)
52-
53-
associate(nsteps => size(speeds,2))
47+
! Sample from the distribution
48+
associate(ncells => size(speeds,1), nsteps => size(speeds,2))
49+
allocate(sampled_speeds(ncells,nsteps))
50+
do concurrent(cell = 1:ncells, step = 1:nsteps)
51+
k = findloc(speeds(cell,step) >= self%cumulative_distribution(), value=.false., dim=1)-1
52+
sampled_speeds(cell,step) = self%vel_(k)
53+
end do
54+
55+
! Create unit vectors
56+
dir = directions(:,1:nsteps,:)
5457

55-
! Create unit vectors
56-
dir = directions(:,1:nsteps,:)
58+
associate(dir_mag => sqrt(dir(:,:,1)**2 +dir(:,:,2)**2 + dir(:,:,3)**2))
59+
associate(dir_mag_ => merge(dir_mag, epsilon(dir_mag), dir_mag/=0.))
60+
dir(:,:,1) = dir(:,:,1)/dir_mag_
61+
dir(:,:,2) = dir(:,:,2)/dir_mag_
62+
dir(:,:,3) = dir(:,:,3)/dir_mag_
63+
end associate
64+
end associate
5765

58-
associate(dir_mag => sqrt(dir(:,:,1)**2 +dir(:,:,2)**2 + dir(:,:,3)**2))
59-
associate(dir_mag_ => merge(dir_mag, epsilon(dir_mag), dir_mag/=0.))
60-
dir(:,:,1) = dir(:,:,1)/dir_mag_
61-
dir(:,:,2) = dir(:,:,2)/dir_mag_
62-
dir(:,:,3) = dir(:,:,3)/dir_mag_
63-
end associate
64-
end associate
65-
66-
call do_concurrent_my_velocities(nsteps, dir, sampled_speeds, my_velocities)
67-
68-
end associate
66+
allocate(my_velocities, mold=dir)
67+
68+
do concurrent(step=1:nsteps)
69+
my_velocities(:,step,1) = sampled_speeds(:,step)*dir(:,step,1)
70+
my_velocities(:,step,2) = sampled_speeds(:,step)*dir(:,step,2)
71+
my_velocities(:,step,3) = sampled_speeds(:,step)*dir(:,step,3)
72+
end do
73+
end associate
6974

7075
end procedure
7176

src/matcha/do_concurrent_m.f90

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/matcha/do_concurrent_s.f90

Lines changed: 0 additions & 96 deletions
This file was deleted.

src/matcha/output_m.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pure module function construct(input, history) result(output)
3333

3434
interface
3535

36-
module function simulated_distribution(self) result(output_distribution)
36+
pure module function simulated_distribution(self) result(output_distribution)
3737
!! The result is a histogram calculated from the simulation output
3838
implicit none
3939
class(output_t), intent(in) :: self

0 commit comments

Comments
 (0)