Paste from node at 2021-07-07 19:40:11I want to paste
program main
implicit none
!90*10/3=300
integer,parameter::node=90,group=300
integer::idx(3,group)
integer::i,j,ix,iy,gx,gy,tmp,iter
real(8)::r1
!! 1 -10 (1,2,3)
!! 11-20 (4,5,6)
!! ......
!! 290-300 (88,89,90)
do i=0,node/3-1
do j=1,10
idx(1,i*10+j)=i*3+1
idx(2,i*10+j)=i*3+2
idx(3,i*10+j)=i*3+3
end do
end do
!! iterator times
do iter=1,10
do gx=group,2,-1
!! change idx(ix,gx) and idx(iy,gy)
call random_number(r1)
gy=ceiling(r1*gx)
call random_number(r1)
ix=ceiling(r1*3)
call random_number(r1)
iy=ceiling(r1*3)
!! judge , idx(ix,gx)/= idx(:,gy)
!! idx(iy,gy)/= idx(:,gx) no same nodes
if(all(idx(ix,gx)/=idx(pack([1,2,3],iy/=[1,2,3]),gy))&
&.and.all(idx(iy,gy)/=idx(pack([1,2,3],ix/=[1,2,3]),gx)))then
tmp=idx(ix,gx)
idx(ix,gx)=idx(iy,gy)
idx(iy,gy)=tmp
end if
end do
end do
open(10,file="1.txt")
write(10,"(3I4)")idx
close(10)
end program main