init_norm Subroutine

public subroutine init_norm()

Arguments

None

Contents

Source Code


Source Code

    subroutine init_norm()
        ! initialize the norm_psi, norm_psi_squared
        implicit none
        integer(int64) :: j
        real(dp) :: sgn(lenof_sign)
        logical :: tIsStateDeterm

        norm_psi_squared = 0.0_dp
        norm_semistoch_squared = 0.0_dp
        ! has to be set only once, if it changes in one iteration, it is reset in every iteration
        tIsStateDeterm = .false.
        do j = 1, TotWalkers
            ! get the sign
            call extract_sign(CurrentDets(:, j), sgn)
            if (tSemiStochastic) tIsStateDeterm = test_flag_multi(CurrentDets(:, j), flag_deterministic)
            call addNormContribution(sgn, tIsStateDeterm)
        end do

        ! sum up the norm over the procs
        call MPISumAll(norm_psi_squared, all_norm_psi_squared)

        ! assign the sqrt norm
#ifdef CMPLX_
        norm_psi = sqrt(sum(all_norm_psi_squared))
        norm_semistoch = sqrt(sum(norm_semistoch_squared))
#else
        norm_psi = sqrt(all_norm_psi_squared)
        norm_semistoch = sqrt(norm_semistoch_squared)
#endif

        old_norm_psi = norm_psi

        all_norms = all_norm_psi_squared
    end subroutine init_norm