subroutine form_r1_nc(Fov,cFoo,cFov,cFvv,r1) ! Form residues for t1 in non-canonical CCSD implicit none ! Input variables double precision,intent(in) :: Fov(spin_occ_num,spin_vir_num) double precision,intent(in) :: cFoo(spin_occ_num,spin_occ_num) double precision,intent(in) :: cFov(spin_occ_num,spin_vir_num) double precision,intent(in) :: cFvv(spin_vir_num,spin_vir_num) ! Local variables integer :: i,j,m,n integer :: a,b,e,f ! Output variables double precision,intent(out) :: r1(spin_occ_num,spin_vir_num) r1(:,:) = Fov(:,:) do i=1,spin_occ_num do a=1,spin_vir_num do e=1,spin_vir_num r1(i,a) = r1(i,a) + t1_cc(i,e)*cFvv(a,e) end do do m=1,spin_occ_num r1(i,a) = r1(i,a) - t1_cc(m,a)*cFoo(m,i) end do do m=1,spin_occ_num do e=1,spin_vir_num r1(i,a) = r1(i,a) + t2_cc(i,m,a,e)*cFov(m,e) end do end do do n=1,spin_occ_num do f=1,spin_vir_num r1(i,a) = r1(i,a) - t1_cc(n,f)*OVOV(n,a,i,f) end do end do do m=1,spin_occ_num do e=1,spin_vir_num do f=1,spin_vir_num r1(i,a) = r1(i,a) - 0.5d0*t2_cc(i,m,e,f)*OVVV(m,a,e,f) end do end do end do do m=1,spin_occ_num do n=1,spin_occ_num do e=1,spin_vir_num r1(i,a) = r1(i,a) - 0.5d0*t2_cc(m,n,a,e)*OOVO(n,m,e,i) end do end do end do end do end do ! Final expression for t1 residue r1(:,:) = delta_ov(:,:)*t1_cc(:,:) - r1(:,:) end subroutine form_r1_nc