Skip to content

Commit 23822da

Browse files
authored
Merge branch 'master' into prcode
2 parents 052b161 + 635d86f commit 23822da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+4700
-4490
lines changed

.github/workflows/lint-source.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@ jobs:
2929
run: pip install fortitude-lint ansi2txt
3030

3131
- name: Lint the source code
32-
run: fortitude check --ignore=E001,S001,S101,M011,F001,S041,T001 ./src/*/* || true
32+
run: fortitude check --file-extensions=f90,fpp,fypp --ignore=E001,S001,S101,M011,F001,S041,T001,S101 ./src/** || true
33+
34+
- name: Ensure kind is specified
35+
run: fortitude check --file-extensions=f90,fpp,fypp --select=P001 ./src/**
36+
37+
- name: No double precision intrinsics
38+
run: |
39+
! grep -iR 'dexp\|dlog\|dble\|dabs\|double\ precision\|real(8)\|real(4)\|dprod\|dmin\|dmax\|dfloat\|dreal\|dcos\|dsin\|dtan\|dsign\|dtanh\|dsinh\|dcosh\|\.d0\|\dd0' --exclude-dir=syscheck ./src/*

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
matrix:
2727
os: ['ubuntu', 'macos']
2828
mpi: ['mpi']
29+
precision: ['']
2930
debug: ['debug', 'no-debug']
3031
intel: [true, false]
3132
exclude:
@@ -35,6 +36,7 @@ jobs:
3536
include:
3637
- os: ubuntu
3738
mpi: no-mpi
39+
precision: single
3840
debug: no-debug
3941
intel: false
4042

@@ -84,7 +86,7 @@ jobs:
8486
- name: Build
8587
run: |
8688
if [ '${{ matrix.intel }}' == 'true' ]; then . /opt/intel/oneapi/setvars.sh; fi
87-
/bin/bash mfc.sh build -j $(nproc) --${{ matrix.debug }} --${{ matrix.mpi }}
89+
/bin/bash mfc.sh build -j $(nproc) --${{ matrix.debug }} --${{ matrix.mpi }} --${{ matrix.precision }}
8890
8991
- name: Test
9092
run: |
@@ -138,4 +140,4 @@ jobs:
138140
if: always()
139141
with:
140142
name: logs-${{ strategy.job-index }}-${{ matrix.device }}
141-
path: test-${{ matrix.device }}.out
143+
path: test-${{ matrix.device }}.out

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ option(MFC_POST_PROCESS "Build post_process" OFF
2626
option(MFC_SYSCHECK "Build syscheck" OFF)
2727
option(MFC_DOCUMENTATION "Build documentation" OFF)
2828
option(MFC_ALL "Build everything" OFF)
29+
option(MFC_SINGLE_PRECISION "Build single precision" OFF)
2930

3031
if (MFC_ALL)
3132
set(MFC_PRE_PROCESS ON FORCE)
@@ -34,6 +35,12 @@ if (MFC_ALL)
3435
set(MFC_DOCUMENTATION ON FORCE)
3536
endif()
3637

38+
if (MFC_SINGLE_PRECISION)
39+
add_compile_definitions(MFC_SINGLE_PRECISION)
40+
else()
41+
add_compile_definitions(MFC_DOUBLE_PRECISION)
42+
endif()
43+
3744

3845
# CMake Library Imports
3946

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ They are organized below. Just click the drop-downs!
161161
* \>66K AMD GPUs on the first exascale computer, [OLCF Frontier](https://www.olcf.ornl.gov/frontier/) (AMD MI250X-based)
162162
* Near compute roofline behavior
163163
* RDMA (remote data memory access; GPU-GPU direct communication) via GPU-aware MPI on NVIDIA (CUDA-aware MPI) and AMD GPU systems
164+
* Optional single-precision computation and storage
164165
</details>
165166

166167
<details>

docs/documentation/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ MFC can be built with support for various (compile-time) features:
126126
| **Debug** | `--debug` | `--no-debug` | Off | Requests the compiler build MFC in debug mode. |
127127
| **GCov** | `--gcov` | `--no-gcov` | Off | Builds MFC with coverage flags on. |
128128
| **Unified Memory** | `--unified` | `--no-unified` | Off | Builds MFC with unified CPU/GPU memory (GH-200 superchip only) |
129+
| **Single** | `--single` | `--no-single` | Off | Builds MFC in single precision
129130

130131
_⚠️ The `--gpu` option requires that your compiler supports OpenACC for Fortran for your target GPU architecture._
131132

misc/m_silo_proxy.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ function DBPUTQM(dbid, name, lname, xname, lxname, yname, lyname, & !! -
189189
integer, intent(IN) :: lyname
190190
character(LEN=*), intent(IN) :: zname
191191
integer, intent(IN) :: lzname
192-
real(kind(0d0)), dimension(:), intent(IN) :: x
193-
real(kind(0d0)), dimension(:), intent(IN) :: y
194-
real(kind(0d0)), dimension(:), intent(IN) :: z
192+
real(wp), dimension(:), intent(IN) :: x
193+
real(wp), dimension(:), intent(IN) :: y
194+
real(wp), dimension(:), intent(IN) :: z
195195
integer, dimension(:), intent(IN) :: dims
196196
integer, intent(IN) :: ndims
197197
integer, intent(IN) :: datatype
@@ -215,8 +215,8 @@ function DBPUTCURVE(dbid, curvename, lcurvename, xvals, yvals, & !! ----
215215
integer, intent(IN) :: dbid
216216
character(LEN=*), intent(IN) :: curvename
217217
integer, intent(IN) :: lcurvename
218-
real(kind(0d0)), dimension(:), intent(IN) :: xvals
219-
real(kind(0d0)), dimension(:), intent(IN) :: yvals
218+
real(wp), dimension(:), intent(IN) :: xvals
219+
real(wp), dimension(:), intent(IN) :: yvals
220220
integer, intent(IN) :: datatype
221221
integer, intent(IN) :: npoints
222222
integer, intent(IN) :: optlist_id
@@ -264,7 +264,7 @@ function DBPUTQV1(dbid, name, lname, meshname, lmeshname, var, & !! ----
264264
integer, intent(IN) :: lname
265265
character(LEN=*), intent(IN) :: meshname
266266
integer, intent(IN) :: lmeshname
267-
real(kind(0d0)), dimension(:, :, :), intent(IN) :: var
267+
real(wp), dimension(:, :, :), intent(IN) :: var
268268
integer, dimension(:), intent(IN) :: dims
269269
integer, intent(IN) :: ndims
270270
integer, intent(IN) :: mixvar

src/common/include/macros.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@
9292
end if
9393
#:enddef
9494

95-
#define t_vec3 real(kind(0d0)), dimension(1:3)
96-
#define t_mat4x4 real(kind(0d0)), dimension(1:4,1:4)
95+
#define t_vec3 real(wp), dimension(1:3)
96+
#define t_mat4x4 real(wp), dimension(1:4,1:4)
9797

9898
#:def ASSERT(predicate, message = None)
9999
if (.not. (${predicate}$)) then

src/common/m_checker_common.fpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module m_checker_common
1818

1919
implicit none
2020

21-
private; public :: s_check_inputs_common
21+
private; public :: s_check_inputs_common, wp
2222

2323
contains
2424

@@ -61,7 +61,7 @@ contains
6161
!! Called by s_check_inputs_common for simulation and post-processing
6262
subroutine s_check_inputs_time_stepping
6363
if (cfl_dt) then
64-
@:PROHIBIT(cfl_target < 0 .or. cfl_target > 1d0)
64+
@:PROHIBIT(cfl_target < 0 .or. cfl_target > 1._wp)
6565
@:PROHIBIT(t_stop <= 0)
6666
@:PROHIBIT(t_save <= 0)
6767
@:PROHIBIT(t_save > t_stop)
@@ -157,10 +157,10 @@ contains
157157
@:PROHIBIT(relax .and. model_eqns /= 3, "phase change requires model_eqns = 3")
158158
@:PROHIBIT(relax .and. relax_model < 0, "relax_model must be in between 0 and 6")
159159
@:PROHIBIT(relax .and. relax_model > 6, "relax_model must be in between 0 and 6")
160-
@:PROHIBIT(relax .and. palpha_eps <= 0d0, "palpha_eps must be positive")
161-
@:PROHIBIT(relax .and. palpha_eps >= 1d0, "palpha_eps must be less than 1")
162-
@:PROHIBIT(relax .and. ptgalpha_eps <= 0d0, "ptgalpha_eps must be positive")
163-
@:PROHIBIT(relax .and. ptgalpha_eps >= 1d0, "ptgalpha_eps must be less than 1")
160+
@:PROHIBIT(relax .and. palpha_eps <= 0._wp, "palpha_eps must be positive")
161+
@:PROHIBIT(relax .and. palpha_eps >= 1._wp, "palpha_eps must be less than 1")
162+
@:PROHIBIT(relax .and. ptgalpha_eps <= 0._wp, "ptgalpha_eps must be positive")
163+
@:PROHIBIT(relax .and. ptgalpha_eps >= 1._wp, "ptgalpha_eps must be less than 1")
164164
@:PROHIBIT((.not. relax) .and. &
165165
((relax_model /= dflt_int) .or. (.not. f_is_default(palpha_eps)) .or. (.not. f_is_default(ptgalpha_eps))), &
166166
"relax is not set as true, but other phase change parameters have been modified. " // &
@@ -275,27 +275,27 @@ contains
275275

276276
do i = 1, num_fluids
277277
call s_int_to_str(i, iStr)
278-
@:PROHIBIT(.not. f_is_default(fluid_pp(i)%gamma) .and. fluid_pp(i)%gamma <= 0d0, &
278+
@:PROHIBIT(.not. f_is_default(fluid_pp(i)%gamma) .and. fluid_pp(i)%gamma <= 0._wp, &
279279
"fluid_pp("//trim(iStr)//")%gamma must be positive")
280280

281281
@:PROHIBIT(model_eqns == 1 .and. (.not. f_is_default(fluid_pp(i)%gamma)), &
282282
"model_eqns = 1 does not support fluid_pp("//trim(iStr)//")%gamma")
283283

284-
@:PROHIBIT((i <= num_fluids + bub_fac .and. fluid_pp(i)%gamma <= 0d0) .or. &
284+
@:PROHIBIT((i <= num_fluids + bub_fac .and. fluid_pp(i)%gamma <= 0._wp) .or. &
285285
(i > num_fluids + bub_fac .and. (.not. f_is_default(fluid_pp(i)%gamma))), &
286286
"for fluid_pp("//trim(iStr)//")%gamma")
287287

288-
@:PROHIBIT(.not. f_is_default(fluid_pp(i)%pi_inf) .and. fluid_pp(i)%pi_inf < 0d0, &
288+
@:PROHIBIT(.not. f_is_default(fluid_pp(i)%pi_inf) .and. fluid_pp(i)%pi_inf < 0._wp, &
289289
"fluid_pp("//trim(iStr)//")%pi_inf must be non-negative")
290290

291291
@:PROHIBIT(model_eqns == 1 .and. (.not. f_is_default(fluid_pp(i)%pi_inf)), &
292292
"model_eqns = 1 does not support fluid_pp("//trim(iStr)//")%pi_inf")
293293

294-
@:PROHIBIT((i <= num_fluids + bub_fac .and. fluid_pp(i)%pi_inf < 0d0) .or. &
294+
@:PROHIBIT((i <= num_fluids + bub_fac .and. fluid_pp(i)%pi_inf < 0._wp) .or. &
295295
(i > num_fluids + bub_fac .and. (.not. f_is_default(fluid_pp(i)%pi_inf))), &
296296
"for fluid_pp("//trim(iStr)//")%pi_inf")
297297

298-
@:PROHIBIT(fluid_pp(i)%cv < 0d0, &
298+
@:PROHIBIT(fluid_pp(i)%cv < 0._wp, &
299299
"fluid_pp("//trim(iStr)//")%cv must be positive")
300300
end do
301301
end subroutine s_check_inputs_stiffened_eos
@@ -306,7 +306,7 @@ contains
306306

307307
integer :: i
308308

309-
@:PROHIBIT(surface_tension .and. sigma < 0d0, &
309+
@:PROHIBIT(surface_tension .and. sigma < 0._wp, &
310310
"sigma must be greater than or equal to zero")
311311

312312
@:PROHIBIT(surface_tension .and. sigma == dflt_real, &
@@ -334,9 +334,9 @@ contains
334334
!! Called by s_check_inputs_common for all three stages
335335
subroutine s_check_inputs_moving_bc
336336
#:for X, VB2, VB3 in [('x', 'vb2', 'vb3'), ('y', 'vb3', 'vb1'), ('z', 'vb1', 'vb2')]
337-
if (any((/bc_${X}$%vb1, bc_${X}$%vb2, bc_${X}$%vb3/) /= 0d0)) then
337+
if (any((/bc_${X}$%vb1, bc_${X}$%vb2, bc_${X}$%vb3/) /= 0._wp)) then
338338
if (bc_${X}$%beg == -15) then
339-
if (any((/bc_${X}$%${VB2}$, bc_${X}$%${VB3}$/) /= 0d0)) then
339+
if (any((/bc_${X}$%${VB2}$, bc_${X}$%${VB3}$/) /= 0._wp)) then
340340
call s_mpi_abort("bc_${X}$%beg must be -15 if "// &
341341
"bc_${X}$%${VB2}$ or bc_${X}$%${VB3}$ "// &
342342
"is set. Exiting ...")
@@ -349,9 +349,9 @@ contains
349349
#:endfor
350350

351351
#:for X, VE2, VE3 in [('x', 've2', 've3'), ('y', 've3', 've1'), ('z', 've1', 've2')]
352-
if (any((/bc_${X}$%ve1, bc_${X}$%ve2, bc_${X}$%ve3/) /= 0d0)) then
352+
if (any((/bc_${X}$%ve1, bc_${X}$%ve2, bc_${X}$%ve3/) /= 0._wp)) then
353353
if (bc_${X}$%end == -15) then
354-
if (any((/bc_${X}$%${VE2}$, bc_${X}$%${VE3}$/) /= 0d0)) then
354+
if (any((/bc_${X}$%${VE2}$, bc_${X}$%${VE3}$/) /= 0._wp)) then
355355
call s_mpi_abort("bc_${X}$%end must be -15 if "// &
356356
"bc_${X}$%${VE2}$ or bc_${X}$%${VE3}$ "// &
357357
"is set. Exiting ...")

src/common/m_constants.fpp

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

55
module m_constants
66

7+
use m_precision_select
8+
79
character, parameter :: dflt_char = ' ' !< Default string value
810

9-
real(kind(0d0)), parameter :: dflt_real = -1d6 !< Default real value
10-
real(kind(0d0)), parameter :: sgm_eps = 1d-16 !< Segmentation tolerance
11-
real(kind(0d0)), parameter :: small_alf = 1d-11 !< Small alf tolerance
12-
real(kind(0d0)), parameter :: pi = 3.141592653589793d0 !< Pi
13-
real(kind(0d0)), parameter :: verysmall = 1.d-12 !< Very small number
11+
real(wp), parameter :: dflt_real = -1e6_wp !< Default real value
12+
real(wp), parameter :: sgm_eps = 1e-16_wp !< Segmentation tolerance
13+
real(wp), parameter :: small_alf = 1e-11_wp !< Small alf tolerance
14+
real(wp), parameter :: pi = 3.141592653589793_wp !< Pi
15+
real(wp), parameter :: verysmall = 1.e-12_wp !< Very small number
1416

1517
integer, parameter :: num_stcls_min = 5 !< Minimum # of stencils
1618
integer, parameter :: path_len = 400 !< Maximum path length
@@ -22,21 +24,21 @@ module m_constants
2224
integer, parameter :: num_patches_max = 10
2325
integer, parameter :: pathlen_max = 400
2426
integer, parameter :: nnode = 4 !< Number of QBMM nodes
25-
real(kind(0d0)), parameter :: capillary_cutoff = 1e-6 !< color function gradient magnitude at which to apply the surface tension fluxes
26-
real(kind(0d0)), parameter :: acoustic_spatial_support_width = 2.5d0 !< Spatial support width of acoustic source, used in s_source_spatial
27-
real(kind(0d0)), parameter :: dflt_vcfl_dt = 100d0 !< value of vcfl_dt when viscosity is off for computing adaptive timestep size
28-
real(kind(0d0)), parameter :: broadband_spectral_level_constant = 20d0 !< The constant to scale the spectral level at the lower frequency bound
29-
real(kind(0d0)), parameter :: broadband_spectral_level_growth_rate = 10d0 !< The spectral level constant to correct the magnitude at each frqeuency to ensure the source is overall broadband
27+
real(wp), parameter :: capillary_cutoff = 1e-6 !< color function gradient magnitude at which to apply the surface tension fluxes
28+
real(wp), parameter :: acoustic_spatial_support_width = 2.5_wp !< Spatial support width of acoustic source, used in s_source_spatial
29+
real(wp), parameter :: dflt_vcfl_dt = 100._wp !< value of vcfl_dt when viscosity is off for computing adaptive timestep size
30+
real(wp), parameter :: broadband_spectral_level_constant = 20._wp !< The constant to scale the spectral level at the lower frequency bound
31+
real(wp), parameter :: broadband_spectral_level_growth_rate = 10._wp !< The spectral level constant to correct the magnitude at each frqeuency to ensure the source is overall broadband
3032

3133
! IBM+STL interpolation constants
3234
integer, parameter :: Ifactor_2D = 50 !< Multiple factor of the ratio (edge to cell width) for interpolation along edges for 2D models
3335
integer, parameter :: Ifactor_3D = 5 !< Multiple factor of the ratio (edge to cell width) for interpolation along edges for 3D models
3436
integer, parameter :: Ifactor_bary_3D = 20 !< Multiple factor of the ratio (triangle area to cell face area) for interpolation on triangle facets for 3D models
3537
integer, parameter :: num_ray = 20 !< Default number of rays traced per cell
36-
real(kind(0d0)), parameter :: ray_tracing_threshold = 0.9d0 !< Threshold above which the cell is marked as the model patch
37-
real(kind(0d0)), parameter :: threshold_vector_zero = 1d-10 !< Threshold to treat the component of a vector to be zero
38-
real(kind(0d0)), parameter :: threshold_edge_zero = 1d-10 !< Threshold to treat two edges to be overlapped
39-
real(kind(0d0)), parameter :: threshold_bary = 1d-1 !< Threshold to interpolate a barycentric facet
40-
real(kind(0d0)), parameter :: initial_distance_buffer = 1d12 !< Initialized levelset distance for the shortest path pair algorithm
38+
real(wp), parameter :: ray_tracing_threshold = 0.9_wp !< Threshold above which the cell is marked as the model patch
39+
real(wp), parameter :: threshold_vector_zero = 1e-10 !< Threshold to treat the component of a vector to be zero
40+
real(wp), parameter :: threshold_edge_zero = 1e-10 !< Threshold to treat two edges to be overlapped
41+
real(wp), parameter :: threshold_bary = 1e-1 !< Threshold to interpolate a barycentric facet
42+
real(wp), parameter :: initial_distance_buffer = 1e12_wp !< Initialized levelset distance for the shortest path pair algorithm
4143

4244
end module m_constants

src/common/m_delay_file_access.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module m_delay_file_access
2+
use m_precision_select
23
implicit none
34
private
45

@@ -14,7 +15,7 @@ subroutine DelayFileAccess(ProcessRank)
1415
integer, intent(in) :: ProcessRank
1516

1617
integer :: iDelay, nFileAccessDelayIterations
17-
real(kind(0d0)) :: Number, Dummy
18+
real(wp) :: Number, Dummy
1819

1920
nFileAccessDelayIterations &
2021
= (ProcessRank/N_PROCESSES_FILE_ACCESS)*FILE_ACCESS_DELAY_UNIT

0 commit comments

Comments
 (0)