Skip to content

Commit 6eaea45

Browse files
committed
Add fac as module level variable.
1 parent 83d46a8 commit 6eaea45

File tree

1 file changed

+58
-57
lines changed

1 file changed

+58
-57
lines changed

test/constants/test_constants.f90

Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module test_constants
1818
STANDARD_ACCELERATION_OF_GRAVITY
1919
implicit none
2020
private
21+
real(dp) :: fac
2122
public :: collect_constants
2223

2324
contains
@@ -56,10 +57,10 @@ subroutine collect_constants(testsuite)
5657
end subroutine
5758

5859
subroutine test_year(error)
59-
type(error_type), allocatable, intent(out) :: error
60-
60+
type(error_type), allocatable, intent(out) :: error
61+
6162
integer(int32) :: value, expected, diff
62-
63+
6364
expected = 2022
6465
value = YEAR
6566
diff = expected - value
@@ -68,8 +69,8 @@ subroutine test_year(error)
6869
end subroutine
6970

7071
subroutine test_ALPHA_PARTICLE_ELECTRON_MASS_RATIO(error)
71-
type(error_type), allocatable, intent(out) :: error
72-
real(dp) :: value, expected, diff, fac
72+
type(error_type), allocatable, intent(out) :: error
73+
real(dp) :: value, expected, diff
7374
fac = 1.0d0
7475
expected = 7294.29954171d0 * fac
7576
value = ALPHA_PARTICLE_ELECTRON_MASS_RATIO%to_real(fac) * fac
@@ -79,8 +80,8 @@ subroutine test_ALPHA_PARTICLE_ELECTRON_MASS_RATIO(error)
7980
end subroutine
8081

8182
subroutine test_ALPHA_PARTICLE_MASS(error)
82-
type(error_type), allocatable, intent(out) :: error
83-
real(dp) :: value, expected, diff, fac
83+
type(error_type), allocatable, intent(out) :: error
84+
real(dp) :: value, expected, diff
8485
fac = 1.0d27
8586
expected = 6.6446573450d-27 * fac
8687
value = ALPHA_PARTICLE_MASS%to_real(fac) * fac
@@ -90,8 +91,8 @@ subroutine test_ALPHA_PARTICLE_MASS(error)
9091
end subroutine
9192

9293
subroutine test_ATOMIC_MASS_CONSTANT(error)
93-
type(error_type), allocatable, intent(out) :: error
94-
real(dp) :: value, expected, diff, fac
94+
type(error_type), allocatable, intent(out) :: error
95+
real(dp) :: value, expected, diff
9596
fac = 1.0d27
9697
expected = 1.66053906892d-27 * fac
9798
value = ATOMIC_MASS_CONSTANT%to_real(fac) * fac
@@ -101,8 +102,8 @@ subroutine test_ATOMIC_MASS_CONSTANT(error)
101102
end subroutine
102103

103104
subroutine test_AVOGADRO_CONSTANT(error)
104-
type(error_type), allocatable, intent(out) :: error
105-
real(dp) :: value, expected, diff, fac
105+
type(error_type), allocatable, intent(out) :: error
106+
real(dp) :: value, expected, diff
106107
fac = 1.0d-23
107108
expected = 6.02214076d23 * fac
108109
value = AVOGADRO_CONSTANT%to_real(fac) * fac
@@ -112,8 +113,8 @@ subroutine test_AVOGADRO_CONSTANT(error)
112113
end subroutine
113114

114115
subroutine test_BOLTZMANN_CONSTANT(error)
115-
type(error_type), allocatable, intent(out) :: error
116-
real(dp) :: value, expected, diff, fac
116+
type(error_type), allocatable, intent(out) :: error
117+
real(dp) :: value, expected, diff
117118
fac = 1.0d23
118119
expected = 1.380649d-23 * fac
119120
value = BOLTZMANN_CONSTANT%to_real(fac) * fac
@@ -123,8 +124,8 @@ subroutine test_BOLTZMANN_CONSTANT(error)
123124
end subroutine
124125

125126
subroutine test_ELECTRON_VOLT(error)
126-
type(error_type), allocatable, intent(out) :: error
127-
real(dp) :: value, expected, diff, fac
127+
type(error_type), allocatable, intent(out) :: error
128+
real(dp) :: value, expected, diff
128129
fac = 1.0d19
129130
expected = 1.602176634d-19 * fac
130131
value = ELECTRON_VOLT%to_real(fac) * fac
@@ -134,8 +135,8 @@ subroutine test_ELECTRON_VOLT(error)
134135
end subroutine
135136

136137
subroutine test_ELEMENTARY_CHARGE(error)
137-
type(error_type), allocatable, intent(out) :: error
138-
real(dp) :: value, expected, diff, fac
138+
type(error_type), allocatable, intent(out) :: error
139+
real(dp) :: value, expected, diff
139140
fac = 1.0d19
140141
expected = 1.602176634d-19 * fac
141142
value = ELEMENTARY_CHARGE%to_real(fac) * fac
@@ -145,8 +146,8 @@ subroutine test_ELEMENTARY_CHARGE(error)
145146
end subroutine
146147

147148
subroutine test_FARADAY_CONSTANT(error)
148-
type(error_type), allocatable, intent(out) :: error
149-
real(dp) :: value, expected, diff, fac
149+
type(error_type), allocatable, intent(out) :: error
150+
real(dp) :: value, expected, diff
150151
fac = 1.0d0
151152
expected = 96485.33212d0 * fac
152153
value = FARADAY_CONSTANT%to_real(fac) * fac
@@ -156,8 +157,8 @@ subroutine test_FARADAY_CONSTANT(error)
156157
end subroutine
157158

158159
subroutine test_MOLAR_MASS_CONSTANT(error)
159-
type(error_type), allocatable, intent(out) :: error
160-
real(dp) :: value, expected, diff, fac
160+
type(error_type), allocatable, intent(out) :: error
161+
real(dp) :: value, expected, diff
161162
fac = 1.0d3
162163
expected = 1.00000000105d-3 * fac
163164
value = MOLAR_MASS_CONSTANT%to_real(fac) * fac
@@ -167,8 +168,8 @@ subroutine test_MOLAR_MASS_CONSTANT(error)
167168
end subroutine
168169

169170
subroutine test_MOLAR_VOLUME_NTP(error)
170-
type(error_type), allocatable, intent(out) :: error
171-
real(dp) :: value, expected, diff, fac
171+
type(error_type), allocatable, intent(out) :: error
172+
real(dp) :: value, expected, diff
172173
fac = 1.0d3
173174
expected = 22.41396954d-3 * fac
174175
value = MOLAR_VOLUME_OF_IDEAL_GAS_273_15_K_101_325_KPA%to_real(fac) * fac
@@ -178,8 +179,8 @@ subroutine test_MOLAR_VOLUME_NTP(error)
178179
end subroutine
179180

180181
subroutine test_PLANCK_CONSTANT(error)
181-
type(error_type), allocatable, intent(out) :: error
182-
real(dp) :: value, expected, diff, fac
182+
type(error_type), allocatable, intent(out) :: error
183+
real(dp) :: value, expected, diff
183184
fac = 1.0d34
184185
expected = 6.62607015d-34 * fac
185186
value = PLANCK_CONSTANT%to_real(fac) * fac
@@ -189,8 +190,8 @@ subroutine test_PLANCK_CONSTANT(error)
189190
end subroutine
190191

191192
subroutine test_SPEED_OF_LIGHT(error)
192-
type(error_type), allocatable, intent(out) :: error
193-
real(dp) :: value, expected, diff, fac
193+
type(error_type), allocatable, intent(out) :: error
194+
real(dp) :: value, expected, diff
194195
fac = 1.0d0
195196
expected = 299792458.0d0 * fac
196197
value = SPEED_OF_LIGHT_IN_VACUUM%to_real(fac) * fac
@@ -200,19 +201,19 @@ subroutine test_SPEED_OF_LIGHT(error)
200201
end subroutine
201202

202203
subroutine test_STANDARD_ACCELERATION_OF_GRAVITY(error)
203-
type(error_type), allocatable, intent(out) :: error
204-
real(dp) :: value, expected, diff, fac
204+
type(error_type), allocatable, intent(out) :: error
205+
real(dp) :: value, expected, diff
205206
fac = 1.0d0
206207
expected = 9.80665d0 * fac
207-
value = STANDARD_ACCELERATION_OF_GRAVITY%to_real(fac) * fac
208+
value = STANDARD_ACCELERATION_OF_GRAVITY%to_real(fac) * fac
208209
diff = expected - value
209210
call check(error, diff, 0.0d0)
210211
if (allocated(error)) return
211212
end subroutine
212213

213214
subroutine test_U_ALPHA_PARTICLE_ELECTRON_MASS_RATIO(error)
214-
type(error_type), allocatable, intent(out) :: error
215-
real(dp) :: value, expected, diff, fac
215+
type(error_type), allocatable, intent(out) :: error
216+
real(dp) :: value, expected, diff
216217
fac = 1.0d7
217218
expected = 0.00000017d0 * fac
218219
value = ALPHA_PARTICLE_ELECTRON_MASS_RATIO%to_real(fac, uncertainty=.true.) * fac
@@ -222,8 +223,8 @@ subroutine test_U_ALPHA_PARTICLE_ELECTRON_MASS_RATIO(error)
222223
end subroutine
223224

224225
subroutine test_U_ALPHA_PARTICLE_MASS(error)
225-
type(error_type), allocatable, intent(out) :: error
226-
real(dp) :: value, expected, diff, fac
226+
type(error_type), allocatable, intent(out) :: error
227+
real(dp) :: value, expected, diff
227228
fac = 1.0d36
228229
expected = 0.0000000021d-27 * fac
229230
value = ALPHA_PARTICLE_MASS%to_real(fac, uncertainty=.true.) * fac
@@ -233,8 +234,8 @@ subroutine test_U_ALPHA_PARTICLE_MASS(error)
233234
end subroutine
234235

235236
subroutine test_U_ATOMIC_MASS_CONSTANT(error)
236-
type(error_type), allocatable, intent(out) :: error
237-
real(dp) :: value, expected, diff, fac
237+
type(error_type), allocatable, intent(out) :: error
238+
real(dp) :: value, expected, diff
238239
fac = 1.0d37
239240
expected = 0.00000000052d-27 * fac
240241
value = ATOMIC_MASS_CONSTANT%to_real(fac, uncertainty=.true.) * fac
@@ -244,8 +245,8 @@ subroutine test_U_ATOMIC_MASS_CONSTANT(error)
244245
end subroutine
245246

246247
subroutine test_U_AVOGADRO_CONSTANT(error)
247-
type(error_type), allocatable, intent(out) :: error
248-
real(dp) :: value, expected, diff, fac
248+
type(error_type), allocatable, intent(out) :: error
249+
real(dp) :: value, expected, diff
249250
fac = 1.0d0
250251
expected = 0.0d0 * fac
251252
value = AVOGADRO_CONSTANT%to_real(fac, uncertainty=.true.) * fac
@@ -255,8 +256,8 @@ subroutine test_U_AVOGADRO_CONSTANT(error)
255256
end subroutine
256257

257258
subroutine test_U_BOLTZMANN_CONSTANT(error)
258-
type(error_type), allocatable, intent(out) :: error
259-
real(dp) :: value, expected, diff, fac
259+
type(error_type), allocatable, intent(out) :: error
260+
real(dp) :: value, expected, diff
260261
fac = 1.0d0
261262
expected = 0.0d0 * fac
262263
value = BOLTZMANN_CONSTANT%to_real(fac, uncertainty=.true.) * fac
@@ -266,8 +267,8 @@ subroutine test_U_BOLTZMANN_CONSTANT(error)
266267
end subroutine
267268

268269
subroutine test_U_ELECTRON_VOLT(error)
269-
type(error_type), allocatable, intent(out) :: error
270-
real(dp) :: value, expected, diff, fac
270+
type(error_type), allocatable, intent(out) :: error
271+
real(dp) :: value, expected, diff
271272
fac = 1.0d0
272273
expected = 0.0d0 * fac
273274
value = ELECTRON_VOLT%to_real(fac, uncertainty=.true.) * fac
@@ -277,8 +278,8 @@ subroutine test_U_ELECTRON_VOLT(error)
277278
end subroutine
278279

279280
subroutine test_U_ELEMENTARY_CHARGE(error)
280-
type(error_type), allocatable, intent(out) :: error
281-
real(dp) :: value, expected, diff, fac
281+
type(error_type), allocatable, intent(out) :: error
282+
real(dp) :: value, expected, diff
282283
fac = 1.0d0
283284
expected = 0.0d0 * fac
284285
value = ELEMENTARY_CHARGE%to_real(fac, uncertainty=.true.) * fac
@@ -288,8 +289,8 @@ subroutine test_U_ELEMENTARY_CHARGE(error)
288289
end subroutine
289290

290291
subroutine test_U_FARADAY_CONSTANT(error)
291-
type(error_type), allocatable, intent(out) :: error
292-
real(dp) :: value, expected, diff, fac
292+
type(error_type), allocatable, intent(out) :: error
293+
real(dp) :: value, expected, diff
293294
fac = 1.0d0
294295
expected = 0.0d0 * fac
295296
value = FARADAY_CONSTANT%to_real(fac, uncertainty=.true.) * fac
@@ -299,8 +300,8 @@ subroutine test_U_FARADAY_CONSTANT(error)
299300
end subroutine
300301

301302
subroutine test_U_MOLAR_MASS_CONSTANT(error)
302-
type(error_type), allocatable, intent(out) :: error
303-
real(dp) :: value, expected, diff, fac
303+
type(error_type), allocatable, intent(out) :: error
304+
real(dp) :: value, expected, diff
304305
fac = 1.0d13
305306
expected = 0.00000000031d-3 * fac
306307
value = MOLAR_MASS_CONSTANT%to_real(fac, uncertainty=.true.) * fac
@@ -310,8 +311,8 @@ subroutine test_U_MOLAR_MASS_CONSTANT(error)
310311
end subroutine
311312

312313
subroutine test_U_MOLAR_VOLUME_NTP(error)
313-
type(error_type), allocatable, intent(out) :: error
314-
real(dp) :: value, expected, diff, fac
314+
type(error_type), allocatable, intent(out) :: error
315+
real(dp) :: value, expected, diff
315316
fac = 1.0d0
316317
expected = 0.0d0 * fac
317318
value = MOLAR_VOLUME_OF_IDEAL_GAS_273_15_K_101_325_KPA%to_real(fac, uncertainty=.true.) * fac
@@ -321,8 +322,8 @@ subroutine test_U_MOLAR_VOLUME_NTP(error)
321322
end subroutine
322323

323324
subroutine test_U_PLANCK_CONSTANT(error)
324-
type(error_type), allocatable, intent(out) :: error
325-
real(dp) :: value, expected, diff, fac
325+
type(error_type), allocatable, intent(out) :: error
326+
real(dp) :: value, expected, diff
326327
fac = 1.0d0
327328
expected = 0.0d0 * fac
328329
value = PLANCK_CONSTANT%to_real(fac, uncertainty=.true.) * fac
@@ -332,8 +333,8 @@ subroutine test_U_PLANCK_CONSTANT(error)
332333
end subroutine
333334

334335
subroutine test_U_SPEED_OF_LIGHT(error)
335-
type(error_type), allocatable, intent(out) :: error
336-
real(dp) :: value, expected, diff, fac
336+
type(error_type), allocatable, intent(out) :: error
337+
real(dp) :: value, expected, diff
337338
fac = 1.0d0
338339
expected = 0.0d0 * fac
339340
value = SPEED_OF_LIGHT_IN_VACUUM%to_real(fac, uncertainty=.true.) * fac
@@ -343,8 +344,8 @@ subroutine test_U_SPEED_OF_LIGHT(error)
343344
end subroutine
344345

345346
subroutine test_U_STANDARD_ACCELERATION_OF_GRAVITY(error)
346-
type(error_type), allocatable, intent(out) :: error
347-
real(dp) :: value, expected, diff, fac
347+
type(error_type), allocatable, intent(out) :: error
348+
real(dp) :: value, expected, diff
348349
fac = 1.0d0
349350
expected = 0.0d0 * fac
350351
value = STANDARD_ACCELERATION_OF_GRAVITY%to_real(fac, uncertainty=.true.) * fac
@@ -378,4 +379,4 @@ program tester
378379
error stop
379380
end if
380381

381-
end program
382+
end program

0 commit comments

Comments
 (0)