这是一个巨大的do循环,我将许多变量私有化以避免出现竞争情况。但是,值与序列代码不匹配,我尝试打印出 proc_num ,并观察到只有8个线程(0,1)被激活。我想粘贴整个代码,但是太长了。
OUTPUT:代码正在运行,但是我只得到错误的值,而proc_num的值仅输出0和1。
thread_num = 8
!$ call omp_set_num_threads (thread_num)
.
.
.
.
!$OMP parallel do private(A_inc,T_star_tr,temp33,B_alpha,C_alpha,C_alpha_vec,&
!$OMP del_CRSS,iter_out,iter_in,del_T_star_tau,RSS_alpha,&
!$OMP del_gam_tau,G_n,Schmid_dum,J_n, J_n_inv,correction,&
!$OMP check,EXP_N,CRSS_c_tau,temp12,checkouter,flag,Fp_det,Fe_det)
do vk=1,npts3
do vj=1,npts2
do vi=1,npts1
A_inc = 0.d0
do vii = 1,3
do vjj = 1,3
do vmm = 1,3
do vpp = 1,3
do voo = 1,3
A_inc(vii,vjj)= A_inc(vii,vjj) + Fp_inv_t(vmm,vii,vi,vj,vk)* &
F_tau(vpp,vmm,vi,vj,vk)*F_tau(vpp,voo,vi,vj,vk)*Fp_inv_t(voo,vjj,vi,vj,vk)
end do
end do
end do
end do
end do
!$OMP critical
!$ proc_num = omp_get_thread_num()
print *, proc_num, A_inc
!$OMP end critical
T_star_tr = 0.d0
do vii = 1,3
do vjj = 1,3
do vkk = 1,3
do vll = 1,3
T_star_tr(vii,vjj) = T_star_tr(vii,vjj) +&
Stiff_sam(vii,vjj,vkk,vll,vi,vj,vk)*0.5*(A_inc(vkk,vll) - IDEN_2(vkk,vll))
end do
end do
end do
end do
.
.
.