278 rhoa, rhob, norm_drhoa, norm_drhob, rho_1_3, rhoa_1_3, &
279 rhob_1_3, laplace_rho, laplace_rhoa, laplace_rhob, drhoa, drhob, rho_cutoff, &
280 drho_cutoff, tau_cutoff, tau, tau_a, tau_b, local_bounds)
282 LOGICAL,
INTENT(in),
OPTIONAL :: can_return_null
283 REAL(kind=
dp),
DIMENSION(:, :, :),
OPTIONAL, &
286 REAL(kind=
dp),
DIMENSION(:, :, :),
OPTIONAL, &
287 POINTER :: norm_drho, rhoa, rhob, norm_drhoa, &
288 norm_drhob, rho_1_3, rhoa_1_3, &
289 rhob_1_3, laplace_rho, laplace_rhoa, &
292 REAL(kind=
dp),
INTENT(out),
OPTIONAL :: rho_cutoff, drho_cutoff, tau_cutoff
293 REAL(kind=
dp),
DIMENSION(:, :, :),
OPTIONAL, &
294 POINTER :: tau, tau_a, tau_b
295 INTEGER,
DIMENSION(2, 3),
INTENT(OUT),
OPTIONAL :: local_bounds
298 LOGICAL :: my_can_return_null
300 my_can_return_null = .false.
301 IF (
PRESENT(can_return_null)) my_can_return_null = can_return_null
303 IF (
PRESENT(rho))
THEN
305 cpassert(my_can_return_null .OR.
ASSOCIATED(rho))
307 IF (
PRESENT(drho))
THEN
309 drho(i)%array => rho_set%drho(i)%array
310 cpassert(my_can_return_null .OR.
ASSOCIATED(rho_set%drho(i)%array))
313 IF (
PRESENT(norm_drho))
THEN
314 norm_drho => rho_set%norm_drho
315 cpassert(my_can_return_null .OR.
ASSOCIATED(norm_drho))
317 IF (
PRESENT(laplace_rho))
THEN
318 laplace_rho => rho_set%laplace_rho
319 cpassert(my_can_return_null .OR.
ASSOCIATED(laplace_rho))
321 IF (
PRESENT(rhoa))
THEN
323 cpassert(my_can_return_null .OR.
ASSOCIATED(rhoa))
325 IF (
PRESENT(rhob))
THEN
327 cpassert(my_can_return_null .OR.
ASSOCIATED(rhob))
329 IF (
PRESENT(drhoa))
THEN
331 drhoa(i)%array => rho_set%drhoa(i)%array
332 cpassert(my_can_return_null .OR.
ASSOCIATED(rho_set%drhoa(i)%array))
335 IF (
PRESENT(drhob))
THEN
337 drhob(i)%array => rho_set%drhob(i)%array
338 cpassert(my_can_return_null .OR.
ASSOCIATED(rho_set%drhob(i)%array))
341 IF (
PRESENT(laplace_rhoa))
THEN
342 laplace_rhoa => rho_set%laplace_rhoa
343 cpassert(my_can_return_null .OR.
ASSOCIATED(laplace_rhoa))
345 IF (
PRESENT(laplace_rhob))
THEN
346 laplace_rhob => rho_set%laplace_rhob
347 cpassert(my_can_return_null .OR.
ASSOCIATED(laplace_rhob))
349 IF (
PRESENT(norm_drhoa))
THEN
350 norm_drhoa => rho_set%norm_drhoa
351 cpassert(my_can_return_null .OR.
ASSOCIATED(norm_drhoa))
353 IF (
PRESENT(norm_drhob))
THEN
354 norm_drhob => rho_set%norm_drhob
355 cpassert(my_can_return_null .OR.
ASSOCIATED(norm_drhob))
357 IF (
PRESENT(rho_1_3))
THEN
358 rho_1_3 => rho_set%rho_1_3
359 cpassert(my_can_return_null .OR.
ASSOCIATED(rho_1_3))
361 IF (
PRESENT(rhoa_1_3))
THEN
362 rhoa_1_3 => rho_set%rhoa_1_3
363 cpassert(my_can_return_null .OR.
ASSOCIATED(rhoa_1_3))
365 IF (
PRESENT(rhob_1_3))
THEN
366 rhob_1_3 => rho_set%rhob_1_3
367 cpassert(my_can_return_null .OR.
ASSOCIATED(rhob_1_3))
369 IF (
PRESENT(tau))
THEN
371 cpassert(my_can_return_null .OR.
ASSOCIATED(tau))
373 IF (
PRESENT(tau_a))
THEN
374 tau_a => rho_set%tau_a
375 cpassert(my_can_return_null .OR.
ASSOCIATED(tau_a))
377 IF (
PRESENT(tau_b))
THEN
378 tau_b => rho_set%tau_b
379 cpassert(my_can_return_null .OR.
ASSOCIATED(tau_b))
381 IF (
PRESENT(rho_cutoff)) rho_cutoff = rho_set%rho_cutoff
382 IF (
PRESENT(drho_cutoff)) drho_cutoff = rho_set%drho_cutoff
383 IF (
PRESENT(tau_cutoff)) tau_cutoff = rho_set%tau_cutoff
384 IF (
PRESENT(local_bounds)) local_bounds = rho_set%local_bounds
418 rhoa, rhob, norm_drhoa, norm_drhob, rho_1_3, rhoa_1_3, &
419 rhob_1_3, laplace_rho, laplace_rhoa, laplace_rhob, drhoa, drhob, &
422 TYPE(
pw_r3d_rs_type),
DIMENSION(3),
OPTIONAL,
INTENT(OUT) :: drho, drhoa, drhob
423 TYPE(
pw_r3d_rs_type),
OPTIONAL,
POINTER :: rho, norm_drho, rhoa, rhob, norm_drhoa, &
424 norm_drhob, rho_1_3, rhoa_1_3, &
425 rhob_1_3, laplace_rho, laplace_rhoa, &
426 laplace_rhob, tau, tau_a, tau_b
429 LOGICAL,
INTENT(OUT) :: owns_data
433 IF (
PRESENT(rho))
THEN
436 CALL xc_rho_set_recover_pw_low(rho, rho_set%rho, pw_grid, pw_pool)
437 NULLIFY (rho_set%rho)
438 owns_data = rho_set%owns%rho
440 IF (
PRESENT(drho))
THEN
442 CALL xc_rho_set_recover_pw_low(drho(i), rho_set%drho(i)%array, pw_grid, pw_pool, rho_set%drhoa(i)%array,&
443 & rho_set%drhob(i)%array)
447 IF (
PRESENT(norm_drho))
THEN
450 CALL xc_rho_set_recover_pw_low(norm_drho, rho_set%norm_drho, pw_grid, pw_pool)
451 NULLIFY (rho_set%norm_drho)
452 owns_data = rho_set%owns%norm_drho
454 IF (
PRESENT(rhoa))
THEN
457 CALL xc_rho_set_recover_pw_low(rhoa, rho_set%rhoa, pw_grid, pw_pool)
458 NULLIFY (rho_set%rhoa)
459 owns_data = rho_set%owns%rho_spin
461 IF (
PRESENT(rhob))
THEN
464 CALL xc_rho_set_recover_pw_low(rhob, rho_set%rhob, pw_grid, pw_pool)
465 NULLIFY (rho_set%rhob)
466 owns_data = rho_set%owns%rho_spin
468 IF (
PRESENT(norm_drhoa))
THEN
470 ALLOCATE (norm_drhoa)
471 CALL xc_rho_set_recover_pw_low(norm_drhoa, rho_set%norm_drhoa, pw_grid, pw_pool)
472 NULLIFY (rho_set%norm_drhoa)
473 owns_data = rho_set%owns%norm_drho_spin
475 IF (
PRESENT(norm_drhob))
THEN
477 ALLOCATE (norm_drhob)
478 CALL xc_rho_set_recover_pw_low(norm_drhob, rho_set%norm_drhob, pw_grid, pw_pool)
479 NULLIFY (rho_set%norm_drhob)
480 owns_data = rho_set%owns%norm_drho_spin
482 IF (
PRESENT(rho_1_3))
THEN
485 CALL xc_rho_set_recover_pw_low(rho_1_3, rho_set%rho_1_3, pw_grid, pw_pool)
486 NULLIFY (rho_set%rho_1_3)
487 owns_data = rho_set%owns%rho_1_3
489 IF (
PRESENT(rhoa_1_3))
THEN
492 CALL xc_rho_set_recover_pw_low(rhoa_1_3, rho_set%rhoa_1_3, pw_grid, pw_pool)
493 NULLIFY (rho_set%rhoa_1_3)
494 owns_data = rho_set%owns%rho_spin_1_3
496 IF (
PRESENT(rhob_1_3))
THEN
499 CALL xc_rho_set_recover_pw_low(rhob_1_3, rho_set%rhob_1_3, pw_grid, pw_pool)
500 NULLIFY (rho_set%rhob_1_3)
501 owns_data = rho_set%owns%rho_spin_1_3
503 IF (
PRESENT(laplace_rho))
THEN
504 NULLIFY (laplace_rho)
505 ALLOCATE (laplace_rho)
506 CALL xc_rho_set_recover_pw_low(laplace_rho, rho_set%laplace_rho, pw_grid, pw_pool)
507 NULLIFY (rho_set%laplace_rho)
508 owns_data = rho_set%owns%laplace_rho
510 IF (
PRESENT(laplace_rhoa))
THEN
511 NULLIFY (laplace_rhoa)
512 ALLOCATE (laplace_rhoa)
513 CALL xc_rho_set_recover_pw_low(laplace_rhoa, rho_set%laplace_rhoa, pw_grid, pw_pool)
514 NULLIFY (rho_set%laplace_rhoa)
515 owns_data = rho_set%owns%laplace_rho_spin
517 IF (
PRESENT(laplace_rhob))
THEN
518 NULLIFY (laplace_rhob)
519 ALLOCATE (laplace_rhob)
520 CALL xc_rho_set_recover_pw_low(laplace_rhob, rho_set%laplace_rhob, pw_grid, pw_pool)
521 NULLIFY (rho_set%laplace_rhob)
522 owns_data = rho_set%owns%laplace_rho_spin
524 IF (
PRESENT(drhoa))
THEN
526 CALL xc_rho_set_recover_pw_low(drhoa(i), rho_set%drhoa(i)%array, pw_grid, pw_pool)
528 owns_data = rho_set%owns%drho_spin
530 IF (
PRESENT(drhob))
THEN
532 CALL xc_rho_set_recover_pw_low(drhob(i), rho_set%drhob(i)%array, pw_grid, pw_pool)
534 owns_data = rho_set%owns%drho_spin
536 IF (
PRESENT(tau))
THEN
539 CALL xc_rho_set_recover_pw_low(tau, rho_set%tau, pw_grid, pw_pool)
540 NULLIFY (rho_set%tau)
541 owns_data = rho_set%owns%tau
543 IF (
PRESENT(tau_a))
THEN
546 CALL xc_rho_set_recover_pw_low(tau_a, rho_set%tau_a, pw_grid, pw_pool)
547 NULLIFY (rho_set%tau_a)
548 owns_data = rho_set%owns%tau_spin
550 IF (
PRESENT(tau_b))
THEN
553 CALL xc_rho_set_recover_pw_low(tau_b, rho_set%tau_b, pw_grid, pw_pool)
554 NULLIFY (rho_set%tau_b)
555 owns_data = rho_set%owns%tau_spin
690 xc_deriv_method_id, xc_rho_smooth_id, pw_pool, spinflip)
696 INTEGER,
INTENT(IN) :: xc_deriv_method_id, xc_rho_smooth_id
698 LOGICAL,
OPTIONAL :: spinflip
700 REAL(kind=
dp),
PARAMETER :: f13 = (1.0_dp/3.0_dp)
702 INTEGER :: i, idir, ispin, j, k, nspins
703 LOGICAL :: gradient_f, my_rho_g_local, &
704 needs_laplace, needs_rho_g, do_sf
705 REAL(kind=
dp) :: rho_cutoff
712 IF (
PRESENT(spinflip)) do_sf = spinflip
714 IF (any(rho_set%local_bounds /= pw_pool%pw_grid%bounds_local)) &
715 cpabort(
"pw_pool cr3d have different size than expected")
717 rho_set%local_bounds = rho_r(1)%pw_grid%bounds_local
718 rho_cutoff = 0.5*rho_set%rho_cutoff
720 my_rho_g_local = .false.
724 IF (.NOT. do_sf)
THEN
725 cpassert(.NOT. needs%rho_spin)
726 cpassert(.NOT. needs%drho_spin)
727 cpassert(.NOT. needs%norm_drho_spin)
728 cpassert(.NOT. needs%rho_spin_1_3)
729 cpassert(.NOT. needs%tau_spin)
730 cpassert(.NOT. needs%laplace_rho_spin)
732 cpassert(.NOT. needs%rho)
733 cpassert(.NOT. needs%drho)
734 cpassert(.NOT. needs%rho_1_3)
735 cpassert(.NOT. needs%tau)
736 cpassert(.NOT. needs%laplace_rho)
739 cpassert(.NOT. needs%rho)
740 cpassert(.NOT. needs%drho)
741 cpassert(.NOT. needs%rho_1_3)
742 cpassert(.NOT. needs%tau)
743 cpassert(.NOT. needs%laplace_rho)
745 cpabort(
"Unknown number of spin states")
748 CALL xc_rho_set_clean(rho_set, pw_pool=pw_pool)
750 needs_laplace = (needs%laplace_rho .OR. needs%laplace_rho_spin)
751 gradient_f = (needs%drho_spin .OR. needs%norm_drho_spin .OR. &
752 needs%drho .OR. needs%norm_drho .OR. &
756 xc_deriv_method_id ==
xc_deriv_pw)) .AND. (gradient_f .OR. needs_laplace)
757 IF ((gradient_f .AND. needs_laplace) .AND. &
759 CALL cp_abort(__location__, &
760 "MGGA functionals that require the Laplacian are "// &
761 "only compatible with 'XC_DERIV PW' and 'XC_SMOOTH_RHO NONE'")
764 IF (needs_rho_g)
THEN
765 CALL pw_pool%create_pw(tmp_g)
768 CALL pw_pool%create_pw(my_rho_r(ispin))
771 IF (needs_rho_g)
THEN
772 IF (
ASSOCIATED(rho_g))
THEN
773 my_rho_g_local = .false.
774 my_rho_g = rho_g(ispin)
778 CALL pw_copy(rho_r(ispin), my_rho_r(ispin))
780 CALL xc_pw_smooth(rho_r(ispin), my_rho_r(ispin), xc_rho_smooth_id)
788 CALL pw_pool%create_pw(drho_r(idir, ispin))
790 IF (needs_rho_g)
THEN
791 IF (.NOT.
ASSOCIATED(my_rho_g%pw_grid))
THEN
792 my_rho_g_local = .true.
793 CALL pw_pool%create_pw(my_rho_g)
796 IF (.NOT. my_rho_g_local .AND. (xc_deriv_method_id ==
xc_deriv_spline2 .OR. &
798 CALL pw_pool%create_pw(my_rho_g)
799 my_rho_g_local = .true.
800 CALL pw_copy(rho_g(ispin), my_rho_g)
803 IF (needs%laplace_rho .OR. needs%laplace_rho_spin)
THEN
804 CALL pw_pool%create_pw(laplace_rho_r(ispin))
805 CALL xc_pw_laplace(my_rho_g, pw_pool, xc_deriv_method_id, laplace_rho_r(ispin), tmp_g=tmp_g)
807 CALL xc_pw_gradient(my_rho_r(ispin), my_rho_g, tmp_g, drho_r(:, ispin), xc_deriv_method_id)
809 IF (needs_rho_g)
THEN
810 IF (my_rho_g_local)
THEN
811 my_rho_g_local = .false.
812 CALL pw_pool%give_back_pw(my_rho_g)
824 IF (
ASSOCIATED(tmp_g%pw_grid))
THEN
825 CALL pw_pool%give_back_pw(tmp_g)
830 IF (.NOT. do_sf)
THEN
831 IF (needs%rho_1_3)
THEN
832 CALL pw_pool%create_cr3d(rho_set%rho_1_3)
834 DO k = rho_set%local_bounds(1, 3), rho_set%local_bounds(2, 3)
835 DO j = rho_set%local_bounds(1, 2), rho_set%local_bounds(2, 2)
836 DO i = rho_set%local_bounds(1, 1), rho_set%local_bounds(2, 1)
837 rho_set%rho_1_3(i, j, k) = max(my_rho_r(1)%array(i, j, k), 0.0_dp)**f13
841 rho_set%owns%rho_1_3 = .true.
842 rho_set%has%rho_1_3 = .true.
845 rho_set%rho => my_rho_r(1)%array
846 NULLIFY (my_rho_r(1)%array)
847 rho_set%owns%rho = .true.
848 rho_set%has%rho = .true.
850 IF (needs%norm_drho)
THEN
851 CALL pw_pool%create_cr3d(rho_set%norm_drho)
853 DO k = rho_set%local_bounds(1, 3), rho_set%local_bounds(2, 3)
854 DO j = rho_set%local_bounds(1, 2), rho_set%local_bounds(2, 2)
855 DO i = rho_set%local_bounds(1, 1), rho_set%local_bounds(2, 1)
856 rho_set%norm_drho(i, j, k) = sqrt( &
857 drho_r(1, 1)%array(i, j, k)**2 + &
858 drho_r(2, 1)%array(i, j, k)**2 + &
859 drho_r(3, 1)%array(i, j, k)**2)
863 rho_set%owns%norm_drho = .true.
864 rho_set%has%norm_drho = .true.
866 IF (needs%laplace_rho)
THEN
867 rho_set%laplace_rho => laplace_rho_r(1)%array
868 NULLIFY (laplace_rho_r(1)%array)
869 rho_set%owns%laplace_rho = .true.
870 rho_set%has%laplace_rho = .true.
875 rho_set%drho(idir)%array => drho_r(idir, 1)%array
876 NULLIFY (drho_r(idir, 1)%array)
878 rho_set%owns%drho = .true.
879 rho_set%has%drho = .true.
882 IF (needs%norm_drho)
THEN
883 CALL pw_pool%create_cr3d(rho_set%norm_drho)
885 DO k = rho_set%local_bounds(1, 3), rho_set%local_bounds(2, 3)
886 DO j = rho_set%local_bounds(1, 2), rho_set%local_bounds(2, 2)
887 DO i = rho_set%local_bounds(1, 1), rho_set%local_bounds(2, 1)
888 rho_set%norm_drho(i, j, k) = sqrt( &
889 drho_r(1, 1)%array(i, j, k)**2 + &
890 drho_r(2, 1)%array(i, j, k)**2 + &
891 drho_r(3, 1)%array(i, j, k)**2)
895 rho_set%owns%norm_drho = .true.
896 rho_set%has%norm_drho = .true.
898 IF (needs%rho_spin)
THEN
900 rho_set%rhoa => my_rho_r(1)%array
901 NULLIFY (my_rho_r(1)%array)
903 rho_set%owns%rho_spin = .true.
904 rho_set%has%rho_spin = .true.
906 IF (needs%norm_drho_spin)
THEN
907 CALL pw_pool%create_cr3d(rho_set%norm_drhoa)
909 DO k = rho_set%local_bounds(1, 3), rho_set%local_bounds(2, 3)
910 DO j = rho_set%local_bounds(1, 2), rho_set%local_bounds(2, 2)
911 DO i = rho_set%local_bounds(1, 1), rho_set%local_bounds(2, 1)
912 rho_set%norm_drhoa(i, j, k) = sqrt( &
913 drho_r(1, 1)%array(i, j, k)**2 + &
914 drho_r(2, 1)%array(i, j, k)**2 + &
915 drho_r(3, 1)%array(i, j, k)**2)
919 rho_set%owns%norm_drho_spin = .true.
920 rho_set%has%norm_drho_spin = .true.
922 IF (needs%laplace_rho_spin)
THEN
923 rho_set%laplace_rhoa => laplace_rho_r(1)%array
924 NULLIFY (laplace_rho_r(1)%array)
926 rho_set%owns%laplace_rho_spin = .true.
927 rho_set%has%laplace_rho_spin = .true.
929 IF (needs%drho_spin)
THEN
931 rho_set%drhoa(idir)%array => drho_r(idir, 1)%array
932 NULLIFY (drho_r(idir, 1)%array)
934 rho_set%owns%drho_spin = .true.
935 rho_set%has%drho_spin = .true.
939 IF (needs%rho_spin_1_3)
THEN
940 CALL pw_pool%create_cr3d(rho_set%rhoa_1_3)
943 DO k = rho_set%local_bounds(1, 3), rho_set%local_bounds(2, 3)
944 DO j = rho_set%local_bounds(1, 2), rho_set%local_bounds(2, 2)
945 DO i = rho_set%local_bounds(1, 1), rho_set%local_bounds(2, 1)
946 rho_set%rhoa_1_3(i, j, k) = max(my_rho_r(1)%array(i, j, k), 0.0_dp)**f13
950 CALL pw_pool%create_cr3d(rho_set%rhob_1_3)
953 DO k = rho_set%local_bounds(1, 3), rho_set%local_bounds(2, 3)
954 DO j = rho_set%local_bounds(1, 2), rho_set%local_bounds(2, 2)
955 DO i = rho_set%local_bounds(1, 1), rho_set%local_bounds(2, 1)
956 rho_set%rhob_1_3(i, j, k) = max(my_rho_r(2)%array(i, j, k), 0.0_dp)**f13
960 rho_set%owns%rho_spin_1_3 = .true.
961 rho_set%has%rho_spin_1_3 = .true.
963 IF (needs%norm_drho)
THEN
965 CALL pw_pool%create_cr3d(rho_set%norm_drho)
967 DO k = rho_set%local_bounds(1, 3), rho_set%local_bounds(2, 3)
968 DO j = rho_set%local_bounds(1, 2), rho_set%local_bounds(2, 2)
969 DO i = rho_set%local_bounds(1, 1), rho_set%local_bounds(2, 1)
970 rho_set%norm_drho(i, j, k) = sqrt( &
971 (drho_r(1, 1)%array(i, j, k) + drho_r(1, 2)%array(i, j, k))**2 + &
972 (drho_r(2, 1)%array(i, j, k) + drho_r(2, 2)%array(i, j, k))**2 + &
973 (drho_r(3, 1)%array(i, j, k) + drho_r(3, 2)%array(i, j, k))**2)
978 rho_set%owns%norm_drho = .true.
979 rho_set%has%norm_drho = .true.
981 IF (needs%rho_spin)
THEN
983 rho_set%rhoa => my_rho_r(1)%array
984 NULLIFY (my_rho_r(1)%array)
986 rho_set%rhob => my_rho_r(2)%array
987 NULLIFY (my_rho_r(2)%array)
989 rho_set%owns%rho_spin = .true.
990 rho_set%has%rho_spin = .true.
992 IF (needs%norm_drho_spin)
THEN
994 CALL pw_pool%create_cr3d(rho_set%norm_drhoa)
996 DO k = rho_set%local_bounds(1, 3), rho_set%local_bounds(2, 3)
997 DO j = rho_set%local_bounds(1, 2), rho_set%local_bounds(2, 2)
998 DO i = rho_set%local_bounds(1, 1), rho_set%local_bounds(2, 1)
999 rho_set%norm_drhoa(i, j, k) = sqrt( &
1000 drho_r(1, 1)%array(i, j, k)**2 + &
1001 drho_r(2, 1)%array(i, j, k)**2 + &
1002 drho_r(3, 1)%array(i, j, k)**2)
1007 CALL pw_pool%create_cr3d(rho_set%norm_drhob)
1008 rho_set%owns%norm_drho_spin = .true.
1010 DO k = rho_set%local_bounds(1, 3), rho_set%local_bounds(2, 3)
1011 DO j = rho_set%local_bounds(1, 2), rho_set%local_bounds(2, 2)
1012 DO i = rho_set%local_bounds(1, 1), rho_set%local_bounds(2, 1)
1013 rho_set%norm_drhob(i, j, k) = sqrt( &
1014 drho_r(1, 2)%array(i, j, k)**2 + &
1015 drho_r(2, 2)%array(i, j, k)**2 + &
1016 drho_r(3, 2)%array(i, j, k)**2)
1021 rho_set%owns%norm_drho_spin = .true.
1022 rho_set%has%norm_drho_spin = .true.
1024 IF (needs%laplace_rho_spin)
THEN
1025 rho_set%laplace_rhoa => laplace_rho_r(1)%array
1026 NULLIFY (laplace_rho_r(1)%array)
1028 rho_set%laplace_rhob => laplace_rho_r(2)%array
1029 NULLIFY (laplace_rho_r(2)%array)
1031 rho_set%owns%laplace_rho_spin = .true.
1032 rho_set%has%laplace_rho_spin = .true.
1034 IF (needs%drho_spin)
THEN
1036 rho_set%drhoa(idir)%array => drho_r(idir, 1)%array
1037 NULLIFY (drho_r(idir, 1)%array)
1038 rho_set%drhob(idir)%array => drho_r(idir, 2)%array
1039 NULLIFY (drho_r(idir, 2)%array)
1041 rho_set%owns%drho_spin = .true.
1042 rho_set%has%drho_spin = .true.
1046 DO ispin = 1, nspins
1047 IF (needs%laplace_rho .OR. needs%laplace_rho_spin)
THEN
1048 CALL pw_pool%give_back_pw(laplace_rho_r(ispin))
1051 CALL pw_pool%give_back_pw(drho_r(idir, ispin))
1054 DO ispin = 1, nspins
1055 CALL pw_pool%give_back_pw(my_rho_r(ispin))
1059 IF (needs%tau .OR. needs%tau_spin)
THEN
1060 cpassert(
ASSOCIATED(tau))
1061 DO ispin = 1, nspins
1062 cpassert(
ASSOCIATED(tau(ispin)%array))
1066 rho_set%tau => tau(1)%array
1067 rho_set%owns%tau = .false.
1068 rho_set%has%tau = .true.
1070 IF (needs%tau_spin)
THEN
1071 rho_set%tau_a => tau(1)%array
1072 rho_set%tau_b => tau(2)%array
1073 rho_set%owns%tau_spin = .false.
1074 rho_set%has%tau_spin = .true.