calc_cc_quad_norm Subroutine

private subroutine calc_cc_quad_norm(hash_table, hash_size)

Arguments

Type IntentOptional Attributes Name
type(cc_hash), intent(in), pointer :: hash_table(:)
integer, intent(in) :: hash_size

Contents

Source Code


Source Code

    subroutine calc_cc_quad_norm(hash_table, hash_size)
        ! need specific routine to calculate the quads norm, since it is
        ! stored in a hash-table format
        type(cc_hash), pointer, intent(in) :: hash_table(:)
        integer, intent(in) :: hash_size
        integer :: i, n_test
        type(cc_hash), pointer :: temp_node

        n_test = 0
        cc_amp_norm(:, 4) = 0.0_dp

        do i = 1, hash_size
            temp_node => hash_table(i)

            if (temp_node%found) then
                ! for now check if the loop over the hash table works:
                n_test = n_test + 1
                cc_amp_norm(1, 4) = cc_amp_norm(1, 4) + abs(temp_node%amp)
                cc_amp_norm(2, 4) = cc_amp_norm(2, 4) + temp_node%amp**2

            end if

            do while (associated(temp_node%next))
                temp_node => temp_node%next

                if (temp_node%found) then
                    n_test = n_test + 1

                    cc_amp_norm(1, 4) = cc_amp_norm(1, 4) + abs(temp_node%amp)
                    cc_amp_norm(2, 4) = cc_amp_norm(2, 4) + temp_node%amp**2

                end if
            end do
        end do

        root_print "checking if loop over hash table works as intented: "
        print *, "counted quads: ", n_test, "on Proc: ", iProcIndex
        print *, "L0 norm quads: ", cc_amp_norm(0, 4), "on proc: ", iProcIndex

        ! and apply square root to L2 Norm
        cc_amp_norm(2, 4) = sqrt(cc_amp_norm(2, 4))

    end subroutine calc_cc_quad_norm