C
      subroutine initial_conditions
	 include 'CASCO.DIM'
	 include 'errors.h'
	 include 'observes.h'
	 include 'deltabcs.h'
	 include 'gradcost.h'
	 include 'wind.h'

	 integer i, k, nr  
	 real    rms1
	 real    rms2

C  functions
	 integer nelev_bcs
	 real    rms_2vec, rms_1vec

C initialize the error arrays 
	 do i = 1, nobs
	    uerr_best(i) = uobs(i) 
	    verr_best(i) = vobs(i) 
	    uerror(i) = 0.
	    verror(i) = 0.
         enddo

	 do i = 1, n_eobs
	    eerr_best(i) =  eobs(i)
	    eerror(i) = 0. 
	 enddo

C Need to add a scalar rms to rms.f to compute initial rms error. 

	 rms1 = rms_2vec(uerr_best,verr_best,nobs)
	 rms2 = rms_1vec(eerr_best,n_eobs)

	 write(*,*)'**Initial Conditions.'
	 write(*,*)' rms velocity error = ',rms1
	 write(*,*)' rms elevation error = ',rms2


C initialize the dbc arrays
         nr = nelev_bcs() 
         do k = 1, ntbc
	    do i = 1, nr
               dbc_best(i,k) = 0.0  
	       dbc(i,k) = 0.0  
	    enddo
         enddo

C initialize the dbcA arrays
         do L=1,w_nseries
	  L0=(L-1)*Nlags
          do k = 1, nlags
	   do i = 1, nr
            dbcA_best(i,k+L0) = 0.0  
	    dbcA(i,k+L0) = 0.0  
	   enddo
          enddo
         enddo

C initialize the gradient of the cost function arrays 
         do k = 1, ntbc
	    do i = 1, nr
               DomegaDrho(i,k) = 0.0  
	    enddo
         enddo

      return 
      end

