I'm trying to vectorize this loop using !$OMP SIMD instruction:
!$OMP SIMD private(drx, dry, drz, dist, delta_i_sum_Wab) reduction(+:i_sum_Wab)
loop_j2_count: do kk=1,npart_cell
call add_particle%distance(particle_in_cell(kk), container_size,2.*block%global%h, dist, drx, dry, drz)
call particle_interaction(add_particle, particle_in_cell(kk),visc_dt,dist, drx,dry,drz,&
block%global%cs0,block%global%p_backGround,block%global%rho0,block%global%const_ker,block%global%viscos_val, block%global%csi,.false., &
delta_i_ax, delta_i_ay, delta_i_az, delta_i_ar, delta_i_deltax, delta_i_deltay, delta_i_deltaz, delta_i_div_pos, delta_i_sum_Wab, delta_i_n_neibou, shifting_enabled)
#ifdef SUMWAB
i_sum_Wab=i_sum_Wab+delta_i_sum_Wab
#endif
enddo loop_j2_count
!$OMP END SIMD
the problem seems to be the type-bound procedure distance which is defined as follows:
pure subroutine distance(vec1,vec2,container_size, cell_size, dist, drx, dry, drz)
implicit none
class(Type_particle_or), intent(in):: vec1
class(Type_particle_or), intent(in):: vec2
real(R8P), intent(in) :: container_size(3)
real(R_P), intent(in) :: cell_size
real(R8P), intent(out) :: dist
real(R8P), intent(out) :: drx, dry, drz
logical :: plot
drx=vec1%xp-vec2%xp
dry=vec1%yp-vec2%yp
drz=vec1%zp-vec2%zp
plot=.false.
call periodicityCorrection(drx,container_size(1),cell_size, plot)
call periodicityCorrection(dry,container_size(2),cell_size, plot)
call periodicityCorrection(drz,container_size(3),cell_size, plot)
dist=sqrt(drx*drx+dry*dry+drz*drz)
end subroutine distance
this distance subroutine is bound to the following type:
type, public:: Type_particle_or
real(R8P):: xp = 0._R8P !< x coords.
real(R8P):: yp = 0._R8P !< y coords.
real(R8P):: zp = 0._R8P !< z coords.
real(R_P):: up = 0._R_P !< v_x
real(R_P):: vp = 0._R_P !< v_y
real(R_P):: wp = 0._R_P !< v_z
real(R_P):: pm = 0._R_P !< mass
real(R_P):: rhop = 0._R_P !< density
real(R_P):: p = 0._R_P !< pressure
real(R_P):: hp = 0._R_P !< smoothing length
integer(I_P) :: i=0_I_P
contains
procedure :: assign_particle => assign_particle_or
procedure :: modify_size_particle_or
procedure :: plot_particle
procedure, public :: distance
end type Type_particle_or
Looking at the optimization report file produced by the compiler with flags -qopt-report=5 -qopt-report-phase=all it seems that the compiler is not able to inline type bound procedures and this creates problems when I try to vectorize the code.
thank you very much for your help