program inner_product !********************************************************************** ! * . . . ! * PROGRAM: INNER_PRODUCT ! * PRGMMR: M. ZUPANSKI ORG: CIRA/CSU DATE: 2003-10-21 ! * ! * ABSTRACT: CALCULATE INNER PRODUCT BETWEEN TWO VECTORS ! * ! * PROGRAM LOG: ! * ! * 10/21/2003 ..... M. ZUPANSKI: ! * ! ********************************************************************** !---------------------------------- ! INPUT: ! x_1 - 1st vector ! x_2 - 2nd vector ! ! OUTPUT: ! product - inner product: (x_1**T)*x_2 ! !---------------------------------- !----- integer,parameter::ifile1=20 ! input file # integer,parameter::inner=51 ! output file # !----- integer :: N_dim,NN real :: product real,dimension(:),allocatable::x_1 !----- !==============start calculation=================== !-- read 1st file rewind ifile1 read(ifile1) N_dim allocate(x_1(1:N_dim)) read(ifile1) x_1 write(*,*) "N_obs=",N_dim !-- Inner product -------------------- product=0.0 do i=1,N_dim product=product+x_1(i)*x_1(i) end do write(*,*) "Raw product=",product product=product/float(N_dim) write(*,*) "Normalized product=",product !! product=sqrt(product) !! write(*,*) "Normalized sqrt product=",product rewind inner write(inner,100) product 100 format(E20.10) stop end