Actual source code: fnorm.F90

  1: !
  2: !
  3: !    Fortran kernel for the Norm() vector routine
  4: !
  5: #include <petsc/finclude/petscsys.h>
  6: !
  7:       subroutine FortranNormSqr(x,n,sum1)
  8:       implicit none
  9:       PetscScalar x(*)
 10:       PetscReal   sum1
 11:       PetscInt n

 13:       PetscInt i

 15:       PETSC_AssertAlignx(16,x(1))

 17:       do 10,i=1,n
 18:         sum1 = sum1 + PetscRealPart(x(i)*PetscConj(x(i)))
 19:  10   continue

 21:       return
 22:       end

 24:       subroutine FortranNormSqrUnroll(x,n,sum1)
 25:       implicit none
 26:       PetscScalar x(*)
 27:       PetscReal   sum1
 28:       PetscInt n

 30:       PetscInt i

 32:       PETSC_AssertAlignx(16,x(1))

 34:       do 10,i=1,n,4
 35:         sum1 = sum1 + PetscRealPart(x(i)*PetscConj(x(i)))                                         &
 36:      &              + PetscRealPart(x(i+1)*PetscConj(x(i+1)))                                     &
 37:      &              + PetscRealPart(x(i+2)*PetscConj(x(i+2)))                                     &
 38:      &              + PetscRealPart(x(i+3)*PetscConj(x(i+3)))
 39:  10   continue

 41:       return
 42:       end