-
Notifications
You must be signed in to change notification settings - Fork 109
Code tidying #907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Code tidying #907
Changes from all commits
73ad673
a60547b
95474cf
e3d0040
082b2ba
7a287ce
9282c6d
249fd15
446d38f
5531fa2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
!> This procedure checks if two floating point numbers of wp are within tolerance. | ||
!! @param a First number. | ||
!! @param b Second number. | ||
!! @param tol_input Relative error (default = 1.e-10_wp). | ||
!! @param tol_input Relative error (default = 1.e-10_wp for double and 1e-6 for single). | ||
!! @return Result of the comparison. | ||
logical pure elemental function f_approx_equal(a, b, tol_input) result(res) | ||
!$acc routine seq | ||
|
@@ -32,7 +32,11 @@ | |
if (present(tol_input)) then | ||
tol = tol_input | ||
else | ||
tol = 1.e-10_wp | ||
if (wp == selected_real_kind(15, 307)) then | ||
tol = 1.e-10_wp | ||
else if (wp == selected_real_kind(6, 37)) then | ||
tol = 1.e-6_wp | ||
end if | ||
end if | ||
|
||
if (a == b) then | ||
|
@@ -47,7 +51,7 @@ | |
!> This procedure checks if the point numbers of wp belongs to another array are within tolerance. | ||
!! @param a First number. | ||
!! @param b Array that contains several point numbers. | ||
!! @param tol_input Relative error (default = 1e-10_wp). | ||
!! @param tol_input Relative error (default = 1.e-10_wp for double and 1e-6 for single). | ||
!! @return Result of the comparison. | ||
logical pure function f_approx_in_array(a, b, tol_input) result(res) | ||
!$acc routine seq | ||
|
@@ -62,7 +66,11 @@ | |
if (present(tol_input)) then | ||
tol = tol_input | ||
else | ||
tol = 1e-10_wp | ||
if (wp == selected_real_kind(15, 307)) then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question here. does this if statement work as expected? wp can be either double or single but does it do what you expect? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the wp does not match any one of the if statement, not tol will be assigned. The program will abort. Also the wp is defined here:
As the tests pass smoothly, I believe this work as expected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change this from |
||
tol = 1.e-10_wp | ||
else if (wp == selected_real_kind(6, 37)) then | ||
tol = 1.e-6_wp | ||
end if | ||
end if | ||
|
||
do i = 1, size(b) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,12 +130,17 @@ contains | |
type(scalar_field), intent(in), optional :: beta | ||
|
||
integer, dimension(num_dims) :: sizes_glb, sizes_loc | ||
integer, dimension(1) :: airfoil_glb, airfoil_loc, airfoil_start | ||
#ifndef MFC_POST_PROCESS | ||
|
||
integer, dimension(1) :: airfoil_glb, airfoil_loc, airfoil_start | ||
#endif | ||
#ifdef MFC_MPI | ||
|
||
! Generic loop iterator | ||
integer :: i, j | ||
integer :: i | ||
#ifndef MFC_POST_PROCESS | ||
integer :: j | ||
#endif | ||
|
||
!Altered system size for the lagrangian subgrid bubble model | ||
integer :: alt_sys | ||
|
@@ -363,6 +368,11 @@ contains | |
real(wp), intent(out) :: vcfl_max_glb | ||
real(wp), intent(out) :: Rc_min_glb | ||
|
||
! Initiate the global variables to the local values to avoid warnings | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change comment to 'Initiate global variables' |
||
icfl_max_glb = icfl_max_loc | ||
vcfl_max_glb = vcfl_max_loc | ||
Rc_min_glb = Rc_min_loc | ||
|
||
#ifdef MFC_SIMULATION | ||
#ifdef MFC_MPI | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,19 +55,24 @@ | |
|
||
subroutine nvtxStartRange(name, id) | ||
character(kind=c_char, len=*), intent(IN) :: name | ||
integer, intent(IN), optional :: id | ||
integer, intent(in), optional :: id | ||
integer :: id_color | ||
#if defined(MFC_OpenACC) && defined(__PGI) | ||
type(nvtxEventAttributes) :: event | ||
#endif | ||
if (present(id)) then | ||
id_color = col(mod(id, 7) + 1) | ||
end if | ||
tempName = trim(name)//c_null_char | ||
|
||
#if defined(MFC_OpenACC) && defined(__PGI) | ||
|
||
tempName = trim(name)//c_null_char | ||
|
||
if (.not. present(id)) then | ||
call nvtxRangePush(tempName) | ||
else | ||
event%color = col(mod(id, 7) + 1) | ||
if (present(id)) then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this work, too? you need to run nsys with cpu and gpu modes to find out |
||
event%color = id_color | ||
event%message = c_loc(tempName) | ||
call nvtxRangePushEx(event) | ||
else | ||
call nvtxRangePush(tempName) | ||
end if | ||
|
||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this even work? have you tested it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I forgot to check the comments. So this one aims to choose tolerance on different precisions, as single precision can only reach to 1e-8. If the tol is not choosen properly, like choose 1e-6 for double precision, will make the test fail. For now this passes both single and double tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i understand its use case, it's a good fix. but please change to the variables
single_precision
anddouble_precision
per my other comment. they're already defined.