rmsvec Subroutine

private subroutine rmsvec(n, v, vrms, vmax)

compute root-mean-square and max norms of a vector.

Arguments

Type IntentOptional Attributes Name
integer(kind=ip), intent(in) :: n
real(kind=rp), intent(in), dimension(n) :: v
real(kind=rp), intent(inout) :: vrms
real(kind=rp), intent(inout) :: vmax

Called by

proc~~rmsvec~~CalledByGraph proc~rmsvec rmsvec proc~jacobi_diis_solver jacobi_diis_solver proc~jacobi_diis_solver->proc~rmsvec proc~polarization polarization proc~polarization->proc~jacobi_diis_solver proc~polelec_geomgrad polelec_geomgrad proc~polelec_geomgrad->proc~polarization proc~ommp_get_polelec_energy ommp_get_polelec_energy proc~ommp_get_polelec_energy->proc~polarization proc~ommp_set_external_field ommp_set_external_field proc~ommp_set_external_field->proc~polarization proc~ommp_polelec_geomgrad ommp_polelec_geomgrad proc~ommp_polelec_geomgrad->proc~polelec_geomgrad proc~c_ommp_get_polelec_energy C_ommp_get_polelec_energy proc~c_ommp_get_polelec_energy->proc~ommp_get_polelec_energy proc~ommp_get_full_ele_energy ommp_get_full_ele_energy proc~ommp_get_full_ele_energy->proc~ommp_get_polelec_energy proc~ommp_set_external_field_nomm ommp_set_external_field_nomm proc~ommp_set_external_field_nomm->proc~ommp_set_external_field proc~ommp_full_geomgrad ommp_full_geomgrad proc~ommp_full_geomgrad->proc~polelec_geomgrad proc~c_ommp_set_external_field_nomm C_ommp_set_external_field_nomm proc~c_ommp_set_external_field_nomm->proc~ommp_set_external_field proc~c_ommp_set_external_field C_ommp_set_external_field proc~c_ommp_set_external_field->proc~ommp_set_external_field proc~c_ommp_polelec_geomgrad C_ommp_polelec_geomgrad proc~c_ommp_polelec_geomgrad->proc~ommp_polelec_geomgrad proc~c_ommp_full_geomgrad C_ommp_full_geomgrad proc~c_ommp_full_geomgrad->proc~ommp_full_geomgrad proc~c_ommp_get_full_ele_energy C_ommp_get_full_ele_energy proc~c_ommp_get_full_ele_energy->proc~ommp_get_full_ele_energy proc~ommp_get_full_energy ommp_get_full_energy proc~ommp_get_full_energy->proc~ommp_get_full_ele_energy proc~c_ommp_get_full_energy C_ommp_get_full_energy proc~c_ommp_get_full_energy->proc~ommp_get_full_energy

Contents

Source Code


Source Code

    subroutine rmsvec( n, v, vrms, vmax )
        !! compute root-mean-square and max norms of a vector.
        implicit none
    
        integer(ip), intent(in) :: n
        real(rp), dimension(n), intent(in) :: v
        real(rp), intent(inout) :: vrms, vmax
    
        integer(ip) :: i
    
        ! initialize
        vrms = 0.0_rp
        vmax = 0.0_rp
        
        ! loop over entries
        do i = 1, n
            ! max norm
            vmax = max(vmax,abs(v(i)))
            ! rms norm
            vrms = vrms + v(i)*v(i)
        enddo
        
        vrms = sqrt(vrms/dble(n))
    end subroutine rmsvec