Skip to content

Commit 73ad673

Browse files
committed
Code Tidying
1 parent 6d8ecdd commit 73ad673

25 files changed

+175
-140
lines changed

src/common/m_boundary_common.fpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,9 +1028,9 @@ contains
10281028
integer, intent(in) :: bc_dir, bc_loc
10291029
integer, intent(in) :: k, l
10301030

1031+
#ifdef MFC_SIMULATION
10311032
integer :: j, i
10321033

1033-
#ifdef MFC_SIMULATION
10341034
if (bc_dir == 1) then !< x-direction
10351035
if (bc_loc == -1) then !bc_x%beg
10361036
do i = 1, sys_size
@@ -1520,7 +1520,7 @@ contains
15201520

15211521
character(LEN=*), intent(in) :: step_dirpath
15221522

1523-
integer :: dir, loc, i
1523+
integer :: dir, loc
15241524
character(len=path_len) :: file_path
15251525

15261526
character(len=10) :: status
@@ -1561,12 +1561,10 @@ contains
15611561
integer :: dir, loc
15621562
character(len=path_len) :: file_loc, file_path
15631563

1564-
character(len=10) :: status
1565-
15661564
#ifdef MFC_MPI
15671565
integer :: ierr
15681566
integer :: file_id
1569-
integer :: offset
1567+
integer(KIND=MPI_ADDRESS_KIND) :: offset
15701568
character(len=7) :: proc_rank_str
15711569
logical :: dir_check
15721570

@@ -1625,8 +1623,6 @@ contains
16251623
logical :: file_exist
16261624
character(len=path_len) :: file_path
16271625

1628-
character(len=10) :: status
1629-
16301626
! Read bc_types
16311627
file_path = trim(step_dirpath)//'/bc_type.dat'
16321628
inquire (FILE=trim(file_path), EXIST=file_exist)
@@ -1668,12 +1664,10 @@ contains
16681664
integer :: dir, loc
16691665
character(len=path_len) :: file_loc, file_path
16701666

1671-
character(len=10) :: status
1672-
16731667
#ifdef MFC_MPI
16741668
integer :: ierr
16751669
integer :: file_id
1676-
integer :: offset
1670+
integer(KIND=MPI_ADDRESS_KIND) :: offset
16771671
character(len=7) :: proc_rank_str
16781672
logical :: dir_check
16791673

@@ -1696,7 +1690,7 @@ contains
16961690
file_path = trim(file_loc)//'/bc_'//trim(proc_rank_str)//'.dat'
16971691
call MPI_File_open(MPI_COMM_SELF, trim(file_path), MPI_MODE_RDONLY, MPI_INFO_NULL, file_id, ierr)
16981692

1699-
offset = 0
1693+
offset = int(0, KIND=MPI_ADDRESS_KIND)
17001694

17011695
! Read bc_types
17021696
do dir = 1, num_dims
@@ -1788,9 +1782,9 @@ contains
17881782
!! boundary locations and cell-width distributions, based on
17891783
!! the boundary conditions.
17901784
subroutine s_populate_grid_variables_buffers
1791-
1785+
#ifndef MFC_PRE_PROCESS
17921786
integer :: i !< Generic loop iterator
1793-
1787+
#endif
17941788
#ifdef MFC_SIMULATION
17951789
! Required for compatibility between codes
17961790
type(int_bounds_info) :: offset_x, offset_y, offset_z

src/common/m_checker_common.fpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,9 @@ contains
316316
!> Checks constraints on the surface tension parameters.
317317
!! Called by s_check_inputs_common for all three stages
318318
impure subroutine s_check_inputs_surface_tension
319-
319+
#ifdef MFC_PRE_PROCESS
320320
integer :: i
321+
#endif MFC_PRE_PROCESS
321322

322323
@:PROHIBIT(surface_tension .and. sigma < 0._wp, &
323324
"sigma must be greater than or equal to zero")

src/common/m_finite_differences.fpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,20 @@ contains
6767
!! @param s_cc Locations of the cell-centers in the s-coordinate direction
6868
!! @param fd_coeff_s Finite-diff. coefficients in the s-coordinate direction
6969
pure subroutine s_compute_finite_difference_coefficients(q, s_cc, fd_coeff_s, buff_size, &
70-
fd_number_in, fd_order_in, offset_s)
70+
fd_order_in, fd_number_in, offset_s)
7171
7272
integer :: lB, lE !< loop bounds
7373
integer, intent(IN) :: q
74-
integer, intent(IN) :: buff_size, fd_number_in, fd_order_in
74+
integer, intent(IN) :: buff_size, fd_order_in
75+
integer, optional, intent(IN) :: fd_number_in
76+
7577
type(int_bounds_info), optional, intent(IN) :: offset_s
7678
real(wp), allocatable, dimension(:, :), intent(INOUT) :: fd_coeff_s
7779
7880
real(wp), &
7981
dimension(-buff_size:q + buff_size), &
8082
intent(IN) :: s_cc
81-
83+
integer :: fd_number
8284
integer :: i !< Generic loop iterator
8385
8486
if (present(offset_s)) then
@@ -88,6 +90,11 @@ contains
8890
lB = 0
8991
lE = q
9092
end if
93+
if (present(fd_number_in)) then
94+
fd_number = fd_number_in
95+
else
96+
fd_number = 2
97+
end if
9198
9299
#ifdef MFC_POST_PROCESS
93100
if (allocated(fd_coeff_s)) deallocate (fd_coeff_s)

src/common/m_helper_basic.f90

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module m_helper_basic
2121
!> This procedure checks if two floating point numbers of wp are within tolerance.
2222
!! @param a First number.
2323
!! @param b Second number.
24-
!! @param tol_input Relative error (default = 1.e-10_wp).
24+
!! @param tol_input Relative error (default = 1.e-10_wp for double precision and 1e-6 for single).
2525
!! @return Result of the comparison.
2626
logical pure elemental function f_approx_equal(a, b, tol_input) result(res)
2727
!$acc routine seq
@@ -32,7 +32,11 @@ logical pure elemental function f_approx_equal(a, b, tol_input) result(res)
3232
if (present(tol_input)) then
3333
tol = tol_input
3434
else
35-
tol = 1.e-10_wp
35+
if (wp == selected_real_kind(15, 307)) then
36+
tol = 1.e-10_wp ! Double Precision
37+
else if (wp == selected_real_kind(6, 37)) then
38+
tol = 1.e-6_wp ! Single Precision
39+
end if
3640
end if
3741

3842
if (a == b) then
@@ -47,7 +51,7 @@ end function f_approx_equal
4751
!> This procedure checks if the point numbers of wp belongs to another array are within tolerance.
4852
!! @param a First number.
4953
!! @param b Array that contains several point numbers.
50-
!! @param tol_input Relative error (default = 1e-10_wp).
54+
!! @param tol_input Relative error (default = 1.e-10_wp for double precision and 1e-6 for single).
5155
!! @return Result of the comparison.
5256
logical pure function f_approx_in_array(a, b, tol_input) result(res)
5357
!$acc routine seq
@@ -62,7 +66,11 @@ logical pure function f_approx_in_array(a, b, tol_input) result(res)
6266
if (present(tol_input)) then
6367
tol = tol_input
6468
else
65-
tol = 1e-10_wp
69+
if (wp == selected_real_kind(15, 307)) then
70+
tol = 1.e-10_wp ! Double Precision
71+
else if (wp == selected_real_kind(6, 37)) then
72+
tol = 1.e-6_wp ! Single Precision
73+
end if
6674
end if
6775

6876
do i = 1, size(b)

src/common/m_mpi_common.fpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,17 @@ contains
130130
type(scalar_field), intent(in), optional :: beta
131131
132132
integer, dimension(num_dims) :: sizes_glb, sizes_loc
133-
integer, dimension(1) :: airfoil_glb, airfoil_loc, airfoil_start
133+
#ifndef MFC_POST_PROCESS
134134
135+
integer, dimension(1) :: airfoil_glb, airfoil_loc, airfoil_start
136+
#endif
135137
#ifdef MFC_MPI
136138
137139
! Generic loop iterator
138-
integer :: i, j
140+
integer :: i
141+
#ifndef MFC_POST_PROCESS
142+
integer :: j
143+
#endif
139144
140145
!Altered system size for the lagrangian subgrid bubble model
141146
integer :: alt_sys
@@ -363,6 +368,11 @@ contains
363368
real(wp), intent(out) :: vcfl_max_glb
364369
real(wp), intent(out) :: Rc_min_glb
365370
371+
! Initiate the global variables to the local values to avoid warnings
372+
icfl_max_glb = icfl_max_loc
373+
vcfl_max_glb = vcfl_max_loc
374+
Rc_min_glb = Rc_min_loc
375+
366376
#ifdef MFC_SIMULATION
367377
#ifdef MFC_MPI
368378

src/common/m_nvtx.f90

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,24 @@ end subroutine nvtxRangePop
5555

5656
subroutine nvtxStartRange(name, id)
5757
character(kind=c_char, len=*), intent(IN) :: name
58-
integer, intent(IN), optional :: id
58+
integer, intent(in), optional :: id
59+
integer :: id_color
60+
#if defined(MFC_OpenACC) && defined(__PGI)
5961
type(nvtxEventAttributes) :: event
62+
#endif
63+
if (present(id)) then
64+
id_color = col(mod(id, 7) + 1)
65+
end if
66+
tempName = trim(name)//c_null_char
6067

6168
#if defined(MFC_OpenACC) && defined(__PGI)
6269

63-
tempName = trim(name)//c_null_char
64-
65-
if (.not. present(id)) then
66-
call nvtxRangePush(tempName)
67-
else
68-
event%color = col(mod(id, 7) + 1)
70+
if (present(id)) then
71+
event%color = id_color
6972
event%message = c_loc(tempName)
7073
call nvtxRangePushEx(event)
74+
else
75+
call nvtxRangePush(tempName)
7176
end if
7277

7378
#endif

0 commit comments

Comments
 (0)