Skip to content

Commit 136c163

Browse files
authored
Merge pull request #178 from BerkeleyLab/julienne-2.4.0
Use Julienne 2.4.0 idioms in subdomain_t unit tests
2 parents a62961a + 856dce3 commit 136c163

5 files changed

Lines changed: 44 additions & 35 deletions

File tree

fpm.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
name = "matcha"
2-
version = "0.1.0"
3-
license = "see LICENSE.txt"
4-
author = "Damian Rouson, David Torres, Dominick Martinez, Jeremiah Bailey, and Brad Richardson"
5-
maintainer = "rouson@lbl.gov"
62

73
[dependencies]
84
assert = {git = "https://github.com/berkeleylab/assert", tag = "2.1.0"}
9-
julienne = {git = "https://github.com/BerkeleyLab/julienne", tag = "2.0.0"}
10-
sourcery = {git = "https://github.com/sourceryinstitute/sourcery", tag = "4.5.1"}
5+
julienne = {git = "https://github.com/BerkeleyLab/julienne", tag = "2.4.0"}

include/language-support.F90

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,28 @@
55
! Define whether the compiler supports associating a procedure pointer dummy argument with an
66
! actual argument that is a valid target for the pointer dummy in a procedure assignment, a
77
! 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
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
1213
#endif
14+
15+
#ifndef HAVE_CRITICAL
16+
! Define whether the compiler supports the `critical` and `end critical` statements
17+
# if defined(_CRAYFTN) || defined(__INTEL_COMPILER) || defined(NAGFOR) || defined(__GFORTRAN__)
18+
# define HAVE_CRITICAL 1
19+
# else
20+
# define HAVE_CRITICAL 0
21+
# endif
1322
#endif
1423

1524
#ifndef HAVE_MULTI_IMAGE_SUPPORT
1625
! Define whether the compiler supports the statements and intrinsic procedures that support
1726
! 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
27+
# if defined(_CRAYFTN) || defined(__INTEL_COMPILER) || defined(NAGFOR) || defined(__GFORTRAN__)
28+
# define HAVE_MULTI_IMAGE_SUPPORT 1
29+
# else
30+
# define HAVE_MULTI_IMAGE_SUPPORT 0
31+
# endif
2332
#endif

src/matcha/subdomain_s.F90

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55

66
submodule(subdomain_m) subdomain_s
77
use assert_m
8-
use sourcery_m, only : data_partition_t
8+
use julienne_m, only : bin_t
99
use intrinsic_array_m, only : intrinsic_array_t
1010
implicit none
1111

1212
real, allocatable :: halo_x(:,:,:)[:]
1313
integer, parameter :: west=1, east=2
1414

15-
type(data_partition_t) data_partition
16-
1715
real dx_, dy_, dz_
1816
integer my_nx, nx, ny, nz, me, num_subdomains, my_internal_west, my_internal_east
1917
real, allocatable :: increment(:,:,:)
@@ -44,8 +42,9 @@
4442
me = this_image()
4543
num_subdomains = num_images()
4644

47-
call data_partition%define_partitions(nx)
48-
my_nx = data_partition%last(me) - data_partition%first(me) + 1
45+
associate(bin => bin_t(num_items=nx, num_bins=num_subdomains, bin_number=me))
46+
my_nx = bin%last() - bin%first() + 1
47+
end associate
4948

5049
if (allocated(self%s_)) deallocate(self%s_)
5150
allocate(self%s_(my_nx, ny, nz))

src/matcha_s.F90

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
submodule(matcha_m) matcha_s
44
use t_cell_collection_m, only : t_cell_collection_t
55
use distribution_m, only : distribution_t
6-
use sourcery_m, only : data_partition_t
6+
use julienne_m, only : bin_t
77
implicit none
88

99
contains
@@ -25,12 +25,10 @@
2525
type(distribution_t) distribution
2626
integer, parameter :: nveldim = 4
2727
integer step
28-
type(data_partition_t) data_partition
2928

30-
call data_partition%define_partitions(cardinality=ncells)
31-
3229
associate(me => this_image())
33-
associate(my_num_cells => data_partition%last(me) - data_partition%first(me) + 1)
30+
associate(bin => bin_t(num_items=ncells, num_bins=num_images(), bin_number=me))
31+
associate(my_num_cells => bin%last() - bin%first() + 1)
3432

3533
call random_init(repeatable=.true., image_distinct=.true.)
3634

@@ -55,6 +53,7 @@
5553
end associate
5654
end associate
5755
end associate
56+
end associate
5857
end associate
5958
end block
6059
end associate

test/subdomain_test_m.F90

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
! Copyright (c), The Regents of the University of California
22
! Terms of use are as specified in LICENSE.txt
3+
4+
#include "language-support.F90"
5+
36
module subdomain_test_m
47
!! Define subdomain tests and procedures required for reporting results
58
use julienne_m, only : &
69
diagnosis_function_i &
10+
,operator(.all.) &
11+
,operator(.approximates.) &
12+
,operator(.and.) &
713
,operator(.csv.) &
14+
,operator(.isAtLeast.) &
15+
,operator(.isAtMost.) &
16+
,operator(.within.) &
817
,string_t &
918
,test_t &
1019
,test_description_t &
@@ -38,7 +47,7 @@ function results() result(test_results)
3847
test_descriptions = [ &
3948
test_description_t("computing a concave Laplacian for a spatially constant operand with a step down at boundaries", concave_laplacian) &
4049
,test_description_t("reaching the correct steady state solution", correct_steady_state) &
41-
,test_description_t("functional pattern results matching procedural results" functional_matches_procedural) &
50+
,test_description_t("functional pattern results matching procedural results", functional_matches_procedural) &
4251
]
4352
#else
4453
procedure(diagnosis_function_i), pointer :: &
@@ -63,13 +72,17 @@ subroutine output(v)
6372
real, intent(in) :: v(:,:,:)
6473
integer j, k
6574
sync all
75+
#ifdef HAVE_CRITICAL
6676
critical
77+
#endif
6778
do j = 1, size(v,2)
6879
do k = 1, size(v,3)
6980
print *,"image ",this_image(),": ",j,k,v(:,j,k)
7081
end do
7182
end do
83+
#ifdef HAVE_CRITICAL
7284
end critical
85+
#endif
7386
sync all
7487
end subroutine
7588

@@ -184,10 +197,7 @@ function correct_steady_state() result(test_diagnosis)
184197
end associate
185198

186199
associate(residual => T%values() - T_steady)
187-
test_diagnosis = test_diagnosis_t( &
188-
test_passed = all(residual >= 0. .and. residual <= tolerance) &
189-
,diagnostics_string = "expected 0 <= " & ! // string_t(residual) // "<= "// string_t(tolerance) &
190-
)
200+
test_diagnosis = .all. ((residual .isAtLeast. 0.) .and. (residual .isAtMost. tolerance))
191201
end associate
192202
end function
193203

@@ -200,13 +210,10 @@ function functional_matches_procedural() result(test_diagnosis)
200210

201211
associate( T_f => T_functional(), T_p => T_procedural())
202212
associate(L_infinity_norm => maxval(abs(T_f - T_p)))
203-
test_diagnosis = test_diagnosis_t( &
204-
test_passed = L_infinity_norm < tolerance &
205-
,diagnostics_string = "expected " // string_t(L_infinity_norm) // " < " // string_t(tolerance) &
206-
)
213+
test_diagnosis = .all. (T_f .approximates. T_p .within. tolerance)
207214
end associate
208215
end associate
209-
&
216+
210217
contains
211218

212219
function T_functional()

0 commit comments

Comments
 (0)