我一直在努力编写一个程序来计算数百万个偶极 - 偶极相互作用张量及其衍生物.因为这些张量可以简单地并行化,并且经常退化,所以我决定构建一个查找表(LUT)并分配工作.最终,它们将组合成一个大矩阵并对角化(我最终将使用scalapack.现在,diag适合nersc的节点).为了跟踪fortran中的所有索引,我构建了一些派生数据类型.
type dtlrdr_lut
sequence
integer p
integer q
integer s
integer i
integer ind
real(dp), dimension(3,3) :: dtlrdr
end type dtlrdr_lut
type dtlrdh_lut
sequence
integer p
integer q
integer ind
real(dp), dimension(3, 3) :: TLR
real(dp), dimension(3, 3, 3, 3) :: dTLRdh
end type dtlrdh_lut
Run Code Online (Sandbox Code Playgroud)
在我想要并行化所有这些的子例程中,我有:
type(dtlrdr_lut), dimension(:), allocatable :: my_dtlrdr, collected_dtlrdr
type(dtlrdh_lut), dimension(:), allocatable :: my_dtlrdh, collected_dtlrdh
integer :: dh_dtype, dr_dtype, dh_types(5), dr_types(6), dh_blocks(5), dr_blocks(6)
INTEGER(KIND=MPI_ADDRESS_KIND) :: dh_offsets(5), dr_offsets(6)
if(.not.allocated(my_dtlrdh)) allocate(my_dtlrdh(my_num_pairs))
if(.not.allocated(my_dtlrdr)) allocate(my_dtlrdr(my_num_pairs*3*nat))
if(me_image.eq.root_image) then
if(.not.allocated(collected_dtlrdh)) allocate(collected_dtlrdh(num_pairs)) …Run Code Online (Sandbox Code Playgroud)