Actual source code: fnorm.F

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

 13:       PetscInt i

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

 19:       return
 20:       end


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

 29:       PetscInt i

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

 38:       return
 39:       end