From df6bbf4f51418a0f733fe3931f05a95711f50999 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 22 Jul 2026 14:45:12 +0000 Subject: [PATCH 1/2] Fix all compilation warnings in debug mode by removing unused variables, using the right integer kinds for photon loop counters, making single precision conversions explicit, and not warning about unused dummy arguments and functions that are required by shared interfaces or compiler workarounds --- configure | 7 ++++++- configure.ac | 7 ++++++- fortranlib | 2 +- src/dust/dust_type_4elem.f90 | 1 - src/grid/grid_geometry_cylindrical_3d.f90 | 2 +- src/grid/grid_geometry_octree.f90 | 2 -- src/grid/grid_geometry_voronoi.f90 | 14 +++----------- src/grid/grid_mrw_3d.f90 | 1 - src/grid/grid_physics_3d.f90 | 1 - src/images/image_type.f90 | 2 +- src/main/iter_final.f90 | 8 ++++---- src/main/iter_final_mono.f90 | 6 +++--- src/main/iter_lucy.f90 | 4 ++-- src/main/iter_raytracing.f90 | 2 +- 14 files changed, 28 insertions(+), 31 deletions(-) diff --git a/configure b/configure index 5a4eba53..8fd223c0 100755 --- a/configure +++ b/configure @@ -1808,7 +1808,12 @@ if test "$enable_debug" == "yes" then debug_nag='-C=all -gline -nan' debug_ifort='-check all -warn all -warn nodec -warn interfaces -gen_interfaces -traceback -g' - debug_gfortran='-Wall -fbounds-check -g' + # Unused dummy arguments are not warned about because many procedures have + # to conform to interfaces shared between the different grid geometries, + # and unused functions are not warned about because some private library + # functions are intentionally unused (including empty contained subroutines + # that work around a PGI compiler bug). + debug_gfortran='-Wall -Wno-unused-dummy-argument -Wno-unused-function -fbounds-check -g' debug_g95='-Wall -fbounds-check -g' debug_pgi='-Mbounds -traceback -g' else diff --git a/configure.ac b/configure.ac index 54349bf9..4c00ab88 100644 --- a/configure.ac +++ b/configure.ac @@ -49,7 +49,12 @@ if test "$enable_debug" == "yes" then debug_nag='-C=all -gline -nan' debug_ifort='-check all -warn all -warn nodec -warn interfaces -gen_interfaces -traceback -g' - debug_gfortran='-Wall -fbounds-check -g' + # Unused dummy arguments are not warned about because many procedures have + # to conform to interfaces shared between the different grid geometries, + # and unused functions are not warned about because some private library + # functions are intentionally unused (including empty contained subroutines + # that work around a PGI compiler bug). + debug_gfortran='-Wall -Wno-unused-dummy-argument -Wno-unused-function -fbounds-check -g' debug_g95='-Wall -fbounds-check -g' debug_pgi='-Mbounds -traceback -g' else diff --git a/fortranlib b/fortranlib index d34e82fc..7e72a3d6 160000 --- a/fortranlib +++ b/fortranlib @@ -1 +1 @@ -Subproject commit d34e82fcfa77be7d48cfde31fd8d7df2d7346f12 +Subproject commit 7e72a3d612c1899933aa45eb56cfeb15728cc49b diff --git a/src/dust/dust_type_4elem.f90 b/src/dust/dust_type_4elem.f90 index 61722d0c..5558f513 100644 --- a/src/dust/dust_type_4elem.f90 +++ b/src/dust/dust_type_4elem.f90 @@ -87,7 +87,6 @@ subroutine dust_setup(group,d,beta) character(len=100) :: path character(len=4) :: sublimation type(version) :: python_version - integer :: dust_version ! Read dust file diff --git a/src/grid/grid_geometry_cylindrical_3d.f90 b/src/grid/grid_geometry_cylindrical_3d.f90 index 0dd5ae33..ada3f35f 100644 --- a/src/grid/grid_geometry_cylindrical_3d.f90 +++ b/src/grid/grid_geometry_cylindrical_3d.f90 @@ -444,7 +444,7 @@ logical function in_correct_cell(p) type(photon),intent(in) :: p type(grid_cell) :: icell_actual - real(dp) :: phi,frac,dphi,r_sq,w_sq + real(dp) :: phi,frac,dphi,w_sq real(dp),parameter :: threshold = 1.e-3_dp icell_actual = find_cell(p) diff --git a/src/grid/grid_geometry_octree.f90 b/src/grid/grid_geometry_octree.f90 index 4a9ac5f8..696dda86 100644 --- a/src/grid/grid_geometry_octree.f90 +++ b/src/grid/grid_geometry_octree.f90 @@ -194,7 +194,6 @@ subroutine setup_grid_geometry(group) integer(hid_t),intent(in) :: group - real(dp) :: x, y, z, dx, dy, dz integer :: ic, iv ! FIX - issue with reading 64-bit 1D column with 32-bit variables @@ -370,7 +369,6 @@ end function next_cell_wall_id logical function in_correct_cell(p) implicit none type(photon),intent(in) :: p - type(grid_cell) :: curr type(grid_cell) :: icell_actual real(dp) :: frac,frac1, frac2, frac3 icell_actual = find_cell(p) diff --git a/src/grid/grid_geometry_voronoi.f90 b/src/grid/grid_geometry_voronoi.f90 index 6af303fc..a3402064 100644 --- a/src/grid/grid_geometry_voronoi.f90 +++ b/src/grid/grid_geometry_voronoi.f90 @@ -45,7 +45,6 @@ module grid_geometry_specific public :: setup_grid_geometry type(grid_geometry_desc),public,target :: geo - integer :: n_filled = 0 ! Declare here otherwise pointer becomes corrupt real(dp),allocatable, target :: points(:,:) @@ -103,7 +102,6 @@ subroutine setup_grid_geometry(group) real(dp), allocatable :: x(:), y(:), z(:) integer, allocatable :: sparse_neighs(:), sparse_idx(:) real(dp),allocatable :: bb_min(:,:), bb_max(:,:) - type(cell),pointer :: c ! Read geometry file call mp_read_keyword(group, '.', "geometry", geo%id) @@ -261,8 +259,6 @@ recursive type(grid_cell) function next_cell_int(cell, direction, intersection) type(grid_cell),intent(in) :: cell integer,intent(in) :: direction type(vector3d_dp),optional,intent(in) :: intersection - type(grid_cell) :: parent_cell - integer :: subcell_id ! wall ID = cell ID c = new_grid_cell(direction, geo) end function next_cell_int @@ -278,9 +274,6 @@ end function next_cell_wall_id logical function in_correct_cell(p) implicit none type(photon),intent(in) :: p - type(grid_cell) :: curr - type(grid_cell) :: icell_actual - real(dp) :: frac,frac1, frac2, frac3 real(dp) :: point(3) type(kdtree2_result) :: results(2) ! TODO - only check the second result if it's close to the first @@ -293,7 +286,6 @@ subroutine random_position_cell(icell,pos) implicit none type(grid_cell),intent(in) :: icell type(vector3d_dp), intent(out) :: pos - type(grid_cell) :: icell_actual type(kdtree2_result) :: results(1) real(dp) :: point(3) @@ -322,8 +314,8 @@ end subroutine random_position_cell real(dp) function distance_to_closest_wall(p) result(d) implicit none type(photon),intent(in) :: p - real(dp) :: d1,d2,d3,d4,d5,d6 call error("distance_to_closest_wall", "not implemented for Voronoi grid") + d = 0._dp ! TODO: is this the second nearest neighbor? end function distance_to_closest_wall @@ -346,8 +338,8 @@ subroutine find_wall(p,radial,tmin,id_min) integer :: i, n_neighbors - type(vector3d_dp) :: r0, ri, rmid, n - real(dp) :: t, tx, ty, tz + type(vector3d_dp) :: rmid, n + real(dp) :: t icell => geo%cells(p%icell%ic) diff --git a/src/grid/grid_mrw_3d.f90 b/src/grid/grid_mrw_3d.f90 index e3ec2c79..6a6e4d26 100644 --- a/src/grid/grid_mrw_3d.f90 +++ b/src/grid/grid_mrw_3d.f90 @@ -18,7 +18,6 @@ module grid_mrw public :: grid_do_mrw_noenergy public :: mrw_peeloff - logical :: debug = .false. integer,parameter :: ncdf = 100 real(dp) :: xcdf(ncdf), ycdf(ncdf) diff --git a/src/grid/grid_physics_3d.f90 b/src/grid/grid_physics_3d.f90 index c3ce4948..6cd0249b 100644 --- a/src/grid/grid_physics_3d.f90 +++ b/src/grid/grid_physics_3d.f90 @@ -61,7 +61,6 @@ module grid_physics integer :: id integer :: idx - logical :: debug = .false. type(pdf_discrete_dp) :: absorption diff --git a/src/images/image_type.f90 b/src/images/image_type.f90 index ccd6e5ba..558fb82b 100644 --- a/src/images/image_type.f90 +++ b/src/images/image_type.f90 @@ -163,7 +163,7 @@ subroutine image_setup(handle,path,img,n_view,n_sources,n_dust,use_exact_nu,freq real(dp) :: wav_min, wav_max integer :: io_bytes logical :: compute_stokes - integer :: ig, n_filt + integer :: ig character(len=100) :: group_name img%n_view = n_view diff --git a/src/main/iter_final.f90 b/src/main/iter_final.f90 index 58f175db..38d86c88 100644 --- a/src/main/iter_final.f90 +++ b/src/main/iter_final.f90 @@ -68,7 +68,7 @@ subroutine do_final(n_photons_tot,n_photons_chunk,peeloff_scattering_only) integer(idp) :: n_photons, n_photons_curr ! Photon object and variable to loop over photons - integer :: ip + integer(idp) :: ip type(photon) :: p ! Whether to only peeloff scattered photons @@ -153,10 +153,10 @@ subroutine propagate(p,peeloff_scattering_only) integer(idp) :: interactions real(dp) :: tau_achieved, tau, tau_escape type(photon) :: p_tmp - real(dp) :: xi, weight + real(dp) :: weight logical :: killed - integer :: mrw_steps - integer :: ia + integer(idp) :: mrw_steps + integer(idp) :: ia ! Propagate photon do interactions=1, n_inter_max+1 diff --git a/src/main/iter_final_mono.f90 b/src/main/iter_final_mono.f90 index d35dd18f..b5e3fe20 100644 --- a/src/main/iter_final_mono.f90 +++ b/src/main/iter_final_mono.f90 @@ -69,7 +69,7 @@ subroutine do_final_mono(n_photons_sources,n_photons_thermal,n_photons_chunk, pe integer(idp) :: n_photons, n_photons_curr ! Photon object and variable to loop over photons - integer :: ip + integer(idp) :: ip type(photon) :: p integer :: inu @@ -237,9 +237,9 @@ subroutine propagate(p) integer(idp) :: interactions real(dp) :: tau_achieved, tau, tau_escape type(photon) :: p_tmp - real(dp) :: xi, weight + real(dp) :: weight logical :: killed - integer :: ia + integer(idp) :: ia logical, parameter :: force_scatter = .true. real(dp) :: energy_initial diff --git a/src/main/iter_lucy.f90 b/src/main/iter_lucy.f90 index 5778ce52..dd7cbeb0 100644 --- a/src/main/iter_lucy.f90 +++ b/src/main/iter_lucy.f90 @@ -74,11 +74,11 @@ subroutine do_lucy(n_photons_tot,n_photons_chunk) integer(idp) :: n_photons, n_photons_curr ! Photon object and variable to loop over photons - integer :: ip, ia + integer(idp) :: ip, ia type(photon) :: p ! Number of interactions - integer :: interactions,mrw_steps + integer(idp) :: interactions,mrw_steps ! Optical depth to travel real(dp) :: tau diff --git a/src/main/iter_raytracing.f90 b/src/main/iter_raytracing.f90 index bc998ff2..2a629436 100644 --- a/src/main/iter_raytracing.f90 +++ b/src/main/iter_raytracing.f90 @@ -39,7 +39,7 @@ subroutine do_raytracing(n_photons_sources,n_photons_thermal,n_photons_chunk) integer(idp) :: n_photons, n_photons_curr ! Photon object and variable to loop over photons - integer :: ip + integer(idp) :: ip type(photon) :: p n_photons_curr = 0 From 48f77eff6ef25e6b7336df87b46da740b1d8ea28 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Wed, 22 Jul 2026 21:17:51 +0000 Subject: [PATCH 2/2] Update fortranlib to the merged main branch which includes the compiler warning fixes --- fortranlib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortranlib b/fortranlib index 7e72a3d6..60fd094d 160000 --- a/fortranlib +++ b/fortranlib @@ -1 +1 @@ -Subproject commit 7e72a3d612c1899933aa45eb56cfeb15728cc49b +Subproject commit 60fd094d3e137137ce00ec120b085e9b23ebf68b