Skip to content

Commit 85baf1c

Browse files
author
Damian Rouson
authored
Merge branch 'main' into compile-with-nag
2 parents 994b482 + ccecba2 commit 85baf1c

8 files changed

+391
-116
lines changed

fpm.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ author = ["Damian Rouson"]
55
maintainer = "[email protected]"
66
copyright = "2020 Sourcery Institute"
77

8+
[dependencies]
9+
assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.0.0"}
10+
811
[dev-dependencies]
912
vegetables = {git = "https://gitlab.com/everythingfunctional/vegetables", tag = "v7.2.0"}
1013

src/array_functions_implementation.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
! contract # NRC-HQ-60-17-C-0007
66
!
77
submodule(array_functions_interface) array_functions_implementation
8-
use assertions_interface, only : assert, assertions
8+
use assert_m, only : assert
99
implicit none
1010
contains
1111

1212
module procedure column_vectors
1313
integer i, j, k
1414

1515
associate( n => shape(vector_field) )
16-
if (assertions) call assert(size(n)==4, "3D vector field input")
16+
call assert(size(n)==4, "3D vector field input")
1717
allocate( array_of_3D_column_vectors( n(4), product(n(1:3)) ) )
1818
do concurrent( i=1:n(1), j=1:n(2), k=1:n(3) )
1919
associate( id => (k-1)*PRODUCT(n(1:2)) + (j-1)*n(1) + i )
@@ -34,7 +34,7 @@
3434
associate(cols=>size(a,2)+size(b,2))
3535
associate(a_unrolled=>reshape(a,[size(a)]))
3636
associate(b_unrolled=>reshape(b,[size(b)]))
37-
if (assertions) call assert( rows==size(b,1), "array_functions: compatible shapes")
37+
call assert( rows==size(b,1), "array_functions: compatible shapes")
3838
concatenated = reshape( [a_unrolled, b_unrolled ],[rows, cols] )
3939
end associate; end associate; end associate; end associate
4040
end procedure

src/assertions_implementation.F90

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

src/assertions_interface.F90

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

src/data-partition-implementation.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
submodule(data_partition_interface) data_partition_implementation
2-
use assertions_interface, only : assert, assertions
2+
use assert_m, only : assert
33
#ifdef COMPILER_LACKS_COLLECTIVE_SUBROUTINES
44
use emulated_intrinsics_interface, only: co_sum
55
#endif
@@ -48,12 +48,12 @@ pure function overflow(im, excess) result(extra_datum)
4848
#endif
4949

5050
module procedure first
51-
if (assertions) call assert( allocated(first_datum), "allocated(first_datum)")
51+
call assert( allocated(first_datum), "allocated(first_datum)")
5252
first_index= first_datum( image_number )
5353
end procedure
5454

5555
module procedure last
56-
if (assertions) call assert( allocated(last_datum), "allocated(last_datum)")
56+
call assert( allocated(last_datum), "allocated(last_datum)")
5757
last_index = last_datum( image_number )
5858
end procedure
5959

src/emulated_intrinsics_implementation.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
! contract # NRC-HQ-60-17-C-0007
66
!
77
submodule(emulated_intrinsics_interface) emulated_intrinsics_implementation
8-
use assertions_interface, only : assert
8+
use assert_m, only : assert
99
implicit none
1010

1111
contains

src/units_implementation.F90

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
!
2+
! (c) 2019-2020 Guide Star Engineering, LLC
3+
! This Software was developed for the US Nuclear Regulatory Commission (US NRC) under contract
4+
! "Multi-Dimensional Physics Implementation into Fuel Analysis under Steady-state and Transients (FAST)",
5+
! contract # NRC-HQ-60-17-C-0007
6+
!
7+
submodule(units_interface) units_implementation
8+
use assertions_interface, only : assertions,assert
9+
implicit none
10+
11+
contains
12+
13+
module procedure set_units
14+
!! define units exponents
15+
this%exponents_ = exponents
16+
this%system= system
17+
end procedure
18+
19+
module procedure get_system
20+
system_of_units = this%system
21+
end procedure
22+
23+
module procedure get_units
24+
exponents = this%exponents_
25+
end procedure
26+
27+
module procedure assign_units
28+
lhs%exponents_ = rhs%exponents_
29+
lhs%system = rhs%system
30+
end procedure
31+
32+
module procedure is_dimensionless
33+
nondimensional = all([this%exponents_==0]) .and. this%system==dimensionless
34+
end procedure
35+
36+
module procedure has_length_units
37+
length_units = this%exponents_(m)==1 .and. all(this%exponents_([kg,sec,K])==0)
38+
end procedure
39+
40+
module procedure has_mass_units
41+
mass_units = this%exponents_(kg)==1 .and. all(this%exponents_([m,sec,K])==0)
42+
end procedure
43+
44+
module procedure has_time_units
45+
time_units = this%exponents_(sec)==1 .and. all(this%exponents_([m,kg,K])==0)
46+
end procedure
47+
48+
module procedure has_temperature_units
49+
temperature_units = this%exponents_(K)==1 .and. all(this%exponents_([m,kg,sec])==0)
50+
end procedure
51+
52+
module procedure has_velocity_units
53+
velocity_units = all(this%exponents_([m,sec])==[1,-1]) .and. all(this%exponents_([kg,K])==0)
54+
end procedure
55+
56+
module procedure has_energy_units
57+
energy_units = all(this%exponents_([kg,m,sec])==[1,2,-2]) .and. this%exponents_(K)==0
58+
end procedure
59+
60+
module procedure has_density_units
61+
density_units = all(this%exponents_([kg,m])==[1,-3]) .and. all(this%exponents_([sec,K])==0)
62+
end procedure
63+
64+
module procedure has_specific_energy_units
65+
specific_energy_units = all(this%exponents_([m,sec])==[2,-2]) .and. all(this%exponents_([kg,K])==0)
66+
end procedure
67+
68+
module procedure has_stress_units
69+
stress_units = all(this%exponents_([kg,m,sec])==[1,-1,-2]) .and. this%exponents_(K)==0
70+
end procedure
71+
72+
module procedure has_power_units
73+
power_units = all(this%exponents_([kg,m,sec])==[1,2,-3]) .and. this%exponents_(K)==0
74+
end procedure
75+
76+
module procedure integer_power
77+
this_raised%system = this%system
78+
this_raised%exponents_ = exponent_*this%exponents_
79+
end procedure
80+
81+
module procedure real_power
82+
if (assertions) call assert(this%is_dimensionless(), &
83+
& "units%real_power: an entity raised to a real power must be dimensionless")
84+
!! Require dimensionless operand => result is default-initialized as dimensionless
85+
end procedure
86+
87+
module procedure negate
88+
negative_this%exponents_ = this%exponents_
89+
negative_this%system= this%system
90+
end procedure
91+
92+
module procedure add
93+
if (assertions) then
94+
!! Require consistent operand units
95+
associate(preconditions => [lhs%system==rhs%system, lhs%exponents_==rhs%exponents_] )
96+
call assert( all(preconditions), "units%add: consistent operands units")
97+
end associate
98+
end if
99+
total%exponents_ = lhs%exponents_
100+
total%system = lhs%system
101+
end procedure
102+
103+
module procedure subtract
104+
if (assertions) then
105+
!! Require consistent operand units
106+
associate(preconditions => [lhs%system==rhs%system, lhs%exponents_==rhs%exponents_] )
107+
call assert( all(preconditions), "units%subtract: consistent operand units")
108+
end associate
109+
end if
110+
difference%exponents_ = lhs%exponents_
111+
difference%system = lhs%system
112+
end procedure
113+
114+
module procedure multiply
115+
116+
if (assertions) call assert( lhs%system==rhs%system, "units%multiply: consistent operand units" )
117+
118+
product_%exponents_ = lhs%exponents_ + rhs%exponents_
119+
product_%system = lhs%system
120+
end procedure
121+
122+
module procedure divide
123+
124+
if (assertions) call assert( numerator%system==denominator%system, "units%divide: consistent operand units" )
125+
126+
ratio%exponents_ = numerator%exponents_ - denominator%exponents_
127+
ratio%system = merge(numerator%system,dimensionless,any(ratio%exponents_/=0))
128+
end procedure
129+
130+
end submodule units_implementation

0 commit comments

Comments
 (0)