	subroutine read_array(uv,y,nx,ny,nv,ntype)
c
c
c	ntype=0;  conventional time series 
c	ntype=1;  real-time (Proteus) RDI data file 
c	ntype=2;  internal memory RDI data file 
c	ntype=3;  x(iv),y paired data
c	ntype=4;  atlas climatology
c       ntype=5;  gpcp satellite rain data
c       ntype=6;  new format composite data (can also read conventional 
c                 time series)
c	ntype=7;  atlas site file
c	ntype=-7  new atlas avg file
c	ntype=8;  TAO ftp hourly met file
c	ntype=9;  CTD (ASCII from CTDLST)
c       ntype=10; 2-d binary file; one dimension is time.
c
c	ntype = -1 or -2 same as above but adjust depths
c
c	
c	nx = number of points in time  (determined from imatdat,lmatdat,xdel)
c	ny = number of points in depth (input for ntype=0)
c	nv = number of variables (input for ntype=0,3.  For RD data
c		determined by logical array lu (read with file name)
c
c
c
c	for ntype=0, nv must be input. For others nv is determined by LU
c
c
        CHARACTER*60 ahead,rform,fnam
        CHARACTER*40 FORM,cast_id
	character*30 rest
	logical lu
c	real*8 ddd,ddelday
        dimension Y(1) 
	COMMON/matrix/ ImatDAT(5),LmatDAT(5),XDEL
        COMMON /log_uv/ lu(6)
        COMMON /INFORM/ FORM,IDATE(5),LDATE(5)
        COMMON/NAME/PROJ(2),MOOR,VNAM,ID,DELT,DEPTH,REST
        common/check/nchk,xbad
	common/flag/xflg(10)
	common /rain_lon/xlon(144)
	common /ctd_name/ cast_id
        common /peprdi/ nrec,NBins,NBout,NBstart,NBend
	common /rdiform/ rform,jin,y0,y1
c
 	dimension u(201,4),uv(1),idata(201,4),zz(10),za(4,10)
	integer jdate(3),ibuf(3),iens,iamp(4),ierr(4),kdate(5),mdate(5)
c
	nydim=201
	sday=60.*1440.
	ldep=0
	if(ntype.lt.0) then
	ntype=iabs(ntype)
	ldep=1
	endif
	lnx=ldep
c----------------------------------------------------------------------
c	CTD data, read from output from EPIC program CTDLST or
c	Hakuho Maru data.  For EPIC data one filename is input,
c	which contains both header and data.  Cast_id is a string
c	to match in the header data (files contain more than one
c	cast.
c
c	For Hakuho Maru data two casts are input.  The first is the
c	header file for the cast and the second (input as cast_id)
c	is the data file name.  Cast_id must contain a "/" to
c	identify it as Hakuho Maru data.
c
c	Uses input parameters imatdat and lmatdat to specify
c	which columns to read (max 9, including pressure).
c	The first 5 column numbers to read are input in imatdat(1 to 5),
c	the next four are input in lmatdat(1 to 4).  The column
c	index for pressure should be repeated in lmatdat(5).
c  
c	Input parameter xdel is used to specify
c	the maximum number of scans in the output array (output as nx)
c
c	Input character string cast_id must match the cast header line
c	between words "CAST" and "DATE"	.
c	pmin and pmax are min and max pressure to read.
c
c	On return, imatdat will contain the time/date of the cast.
c	nx will be the number of scans returned, ny=1, 
c	nv the number of columns read, and xdel=0.0.
c
	if(ntype.eq.9) then
	nx=xdel
	ny=1
	xdel=0.0
	read(5,*) fnam,cast_id,pmin,pmax
	call fopen(1,fnam,'old')
	call ctd_read(uv,nx,nv,cast_id,pmin,pmax)
	close(1)
	return	
	endif
c----------------------------------------------------------------------
c	gpcp satellite rain data.
c	grid is 2.5x2.5, lat/lons are center of box.
c	nx = time, ny = lat, nv = long.
c	xdel may be either 5 (pentad) or 31 (monthy)
c	xdel = -5 or -31 means input file is binary
c
	if(ntype.eq.5) then
        nyin=32
	nvin=144
	nyvin=nyin*nvin
	iasc=0
	if(xdel.lt.0.0) then
	iasc=1
	xdel=abs(xdel)
	endif
	ixdel=nint(xdel)
	if(ixdel.ne.5 .and. ixdel.ne.31) then
	write(6,61) xdel
61	format(f8.2,' is illegal xdel for gpcp data')
	stop
	endif
	kdate(1)=0
	kdate(2)=0
 	linit=0
	if(nx.lt.0) linit=1
        DD=delday(imatdat,lmatdat)
	if(ixdel.eq.5) then
        DD=delday(imatdat,lmatdat)
	nx=DD/XDEL+1.1
	else
	nx=mon_del(imatdat(4),imatdat(5),lmatdat(4),lmatdat(5))+1
c	print*,nx
	endif
	xgrid=2.5
	xlon0=0.
	ylat0=40.
c
c	use room at end of input array for input workspace
c
	read (5,*) fnam,ylat1,ylat2,xlon1,xlon2
	write(6,62) fnam
62	format(/10x,'gpcp input file name: ',a)
	ny=(ylat2-ylat1)/xgrid
	nv=(xlon2-xlon1)/xgrid
	nws=nx*ny*nv+1
	nwe=nws+nyvin-1
	iy1=(ylat0-ylat2)/xgrid+1.0005
	iv1=(xlon1-xlon0)/xgrid+1.0005
c	print*,iy1,iv1
	do n=1,ny
	y(n)=ylat2-(n-.5)*xgrid
	enddo
	do n=1,nv
	xlon(n)=xlon1+(n-.5)*xgrid
	enddo
	if(linit.eq.0) call init_array(uv,nx,ny,nv,xbad)
	if(iasc.eq.0) then
	call fopen(1,FNAM,'OLD')
c
c	FIGURE OUT GPCP format 
c
	read (1,511) idum
	read(1,'(a)') form
	idot1=index(form,'.')
	idot2=index(form(idot1+1:),'.')
	write(form,512) idot2
512	format('(144f',i1,'.1)')
	backspace 1
	backspace 1
	else
	call fopen_dir(-1,FNAM,'OLD',18436)
	irec=0
	endif
510	if(iasc.eq.0) then
	read (1,511,end=590) kdate(5),jd
511	format(2i2)
	read(1,form) (uv(i),i=nws,nwe)
	else
	irec=irec+1
	read(1,rec=irec,end=590) iyypp,(uv(i),i=nws,nwe)
	write(rest(1:4),5111) iyypp
5111	format(i4)
	read(rest(1:4),5112) kdate(5),jd
5112	format(2i2)
	endif
	if(ixdel.eq.5) then
	jd=(jd-1)*xdel+1
	call julian(jd,kdate(3),kdate(4),kdate(5),1)
	DD=delday(imatdat,kDATE)
	if(dd.lt.0.0) go to 510
	IX=DD/XDEL+1.1
	else
	kdate(4)=jd
	kdate(3)=imatdat(3)
	ix=mon_del(imatdat(4),imatdat(5),jd,kdate(5))+1
	endif
	if(ix.lt.1.) go to 510
	if(ix.gt.nx) go to 590
	call add_gpcp(uv,nx,ny,nv,uv(nws),ix,iy1,iv1)
	nin=nin+1
	if(nin.eq.1) then
	call sub_date(kdate,idate)
	else
	call sub_date(kdate,ldate)
	endif
	go to 510
590	close(1)
	return
        endif
c
c-------end of gpcp data
c
c----------------------------------------------------------------------
c	atlas climatology data
c
	if(ntype.eq.4) then
	ny=imatdat(1)
	imatdat(1)=0
	if(ny.le.0) ny=1
	nx=12
	nv=11
	call init_array(uv,nx,ny,nv,xbad)
	do iy=1,ny
	if(ny.gt.1) then
	read(5,*) fnam,y(iy)
	else
	read(5,*) fnam
	endif
	call fOPEN(1,FNAM,'OLD')
	call get_clim(uv,nx,ny,nv,iy)
	close(1)
	enddo
	return
	endif
c
c-------end of atlas climatology data
c
c--------------------------------------------------------------------
c	tabulated data
c
	if(ntype.eq.3) then
	minv=0
	nx=imatdat(1)
	nvx=nx
	nxv=nv
	if(nv.lt.0) then
c
c	data read from inverted table
c
	nxv=nx
	nvx=iabs(nv)
c	nx=nvx
	nv=iabs(nv)
	minv=1
	endif
	ny=1
	if(nxv.gt.10) nxv=10
	read(5,*) fnam,form,nskip,(xflg(iv),iv=1,nxv)
      WRITE (6,99) FNAM
	call fOPEN(1,FNAM,'OLD')
	call init_array(uv,nx,ny,nv,xbad)
	do n=1,nskip
	read(1,101,end=50) idum
	end do
	do ix=1,nvx
	read (1,form,end=50) (zz(i),i=1,nxv)
	if(minv.eq.0) then
	call add_point(uv,nx,ny,nv,zz,ix,ny,xflg)
	else
	call add_point0(uv,nx,ny,nv,zz,ny,ix,xflg)
	endif
	end do
50	close(1)
	return
	endif
c
c-------end of tabulated data
C
c
c-------------------------------------------------------------------
c	any other time series data, ntype=0,1,2,6,7,8,10	
c
	linit=0
c
c	lint is flag to add to existing file
c	lflag is flag for tabulated data
c
	if(nx.lt.0) linit=1
c	lflag=imatdat(5)
c
c	6 May 2000:  Changed lflag imatdat(5) to imatdat(4) for y2k
c	Older scripts should still work, since in most cases both
c	month and year were entered as 0. 
c
	lflag=imatdat(4)
	if(lflag.eq.0) then
	nx=imatdat(1)
	ix=0
	else
        DD=delday(imatdat,lmatdat)
c
c	For non-equally spaced conventional time series
c	enter xdel as -nx. An additional variable will be
c	included which will be days from start time.  
c
	if(xdel.gt.0.0) then
	nx=DD/XDEL+1.001
	nv1=nv
	else
	nx=nint(abs(xdel))
	xdel=0.0
	nv1=nv+1
	endif
	endif
c	print*,nx
	if(ntype.eq.0.or.ntype.eq.7.or.ntype.eq.8) go to 300
        if(ntype.eq.6)go to 600
        if(ntype.eq.10)go to 800
c---------------------------------------------------------------------
c	rdi data
c	
	read(5,*) fnam,lu,nymin,nymax
	if(ldep.eq.0) then
	y0=14.
	y1=8.
	else
	read(5,*) y0,y1
	endif
      WRITE (6,99) FNAM
99    FORMAT (//10X,'INPUT FILENAME: ',A)
	call fOPEN(1,FNAM,'OLD')
	nv=0
	do n=1,6
	if(lu(n)) nv=nv+1
	end do
c
c	ntype=1;  real-time (Proteus) RDI data file 
c
	if(ntype.eq.1) then
	do iv=1,nv
	xflg(iv)=-999.
	end do
	nyin=30
	if(nymin.eq.0) nymin=1
	if(nymax.eq.0.or.nymax.gt.nyin) nymax=nyin
	ny=nymax-nymin+1
	call ylev(y,ny,nymin,y0,y1)
	nin=0
	if(linit.eq.0) call init_array(uv,nx,ny,nv,xbad)
        READ (1,101) PROJ,MOOR,VNAM,ID,DELT,DEPTH,REST
101     FORMAT(4A4,1X,I1,2F6.0,A)
        WRITE (6,102) PROJ,MOOR,VNAM,ID,DELT,DEPTH,REST
102     FORMAT(10X,4A4,1X,I1,2F6.1,A)
110	read(1,111,end=150) nrec,jdate,ibuf,itmp,iens,iamp,ierr
111     format(i6,3i3,2x,3i3,i5,1x,12i3,i4)
	read(1,131) (u(n,1),n=1,nyin),(u(n,2),n=1,nyin),
     1	(u(n,3),n=1,nyin)
131	format(15f4.0)
	if(lflag.eq.0) then
	ix=ix+1
	else
	call cnv_date(jdate,kdate,ntype)
      DD=delday(imatdat,kDATE)
	if(dd.lt.0.0) go to 110
	IX=DD/XDEL+1.1
	endif
	if(ix.lt.1.) go to 110
	if(ix.gt.nx) go to 150
	call add_prof(uv,nx,ny,nv,u,ix,xflg,nymin,nydim)
	nin=nin+1
	if(nin.eq.1) then
	call sub_date(kdate,idate)
	else
	call sub_date(kdate,ldate)
	endif
	go to 110
150	continue
	elseif(ntype.eq.2) then
c
c	ntype=2;  internal memory RDI data file 
c
	do iv=1,nv
	xflg(iv)=512.0
	end do
	ufact=10.
	nydef=37
	if(nymin.eq.0) nymin=1
	if(nymax.eq.0) nymax=nydef
	if(nymax.gt.nydim) nymax=nydim
	ny=nymax-nymin+1
	call ylev(y,ny,nymin,y0,y1)
	nin=0
	call init_array(u,nydim,4,1,xbad)
	if(linit.eq.0) call init_array(uv,nx,ny,nv,xbad)
210     read(1,211,end=250) Nrec,mdate,NBins,NBout,
     1  NBStart,NBEnd,rform
211     format(I6,5I3,4I4,2x,a)
	jin=4
	nb=index(rform,'!')-1
	if(nb.gt.0) read(rform(nb+2:),*) jin
        read(1,rform(1:nb)) ((idata(I,J),J=1,JIN),I=NBStart,NBEnd)
	if(lflag.eq.0) then
	ix=ix+1
	else
	call cnv_date(mdate,kdate,ntype)
	isec=0
c
c	the following section must have been added for single ping data
c	which had seconds in the year place.  It has been commented
c	out for now.....HPF 
c
c	if(kdate(5).lt.60) then
c	isec=kdate(5)
c	kdate(5)=imatdat(5)
c	endif
      DD=delday(imatdat,kDATE)+isec/sday
	if(dd.lt.0.0) go to 210
	IX=DD/XDEL+1.001
	endif
	if(ix.lt.1.) go to 210
	if(ix.gt.nx) go to 250
	do iy=nbstart,nymax
	do iv=1,4
	u(iy,iv)=idata(iy,iv)/ufact
	end do
	end do
	call add_prof(uv,nx,ny,nv,u,ix,xflg,nymin,nydim)
	nin=nin+1
	if(nin.eq.1) then
	call sub_date(kdate,idate)
c
c	check to see if ymin,ydel are after jin
c
	if(nb.gt.0) then
	read(rform(nb+4:),*,err=240) y0,y1
	call ylev(y,ny,nymin,y0,y1)
240	write(6,241) y0,y1
241	format(10x,'ymin,ydel = ',2f7.1)
	endif
	else
	call sub_date(kdate,ldate)
	endif
	go to 210
250	continue
	print*,ix,nx
	endif
	if(nin.eq.1) call sub_date(idate,ldate)
	close(1)
	return
c--------------------------------------------------------------------
c	conventional time series, atlas site files, ftp hourly met files
c
300	if(linit.eq.0) call init_array(uv,nx,ny,nv1,xbad)
	ixmin=nx+1
	ixmax=0
	if(ntype.eq.0.or.ntype.eq.8) then
c---------------------------------------------------------------------
c	conventional
c
	do 340 iy=1,ny
	ix=0
	nread=0
c	print*c,nv
      READ (5,*) FNAM,FORM,YDEP,(xflg(iv),iv=1,nv)
	if(xdel.eq.0.) xflg(nv1)=xflg(nv)
	Y(iy)=YDEP
      WRITE (6,303) Y(iy),FNAM
303    FORMAT (//10X,'INPUT FILENAME FOR Y =',F7.2/10X,A)
	call fOPEN(1,FNAM,'OLD')
	proj(1)=' '
	proj(2)=' '
	moor=' '
	vnam=' '
	id=0
	delt=0.0
	depth=0.0
	rest=' '
	if(ntype.eq.0) then
       	READ (1,101,err=3100) PROJ,MOOR,VNAM,ID,DELT,DEPTH,REST
3100     WRITE (6,102) PROJ,MOOR,VNAM,ID,DELT,DEPTH,REST
	else
c-----------------------------------------------------------------------
c	hourly met input header
c
	nhead=5
	do nh=1,nhead
	read(1,347) ahead
	if(nh.eq.1) read(ahead(12:),101) proj
	write(6,348) ahead
	enddo
	delt=60.
	id=0
	endif
	if(xdel.gt.0.0 .and. 
     1	abs(xdel*1440.-delt).gt.1.0) write(6,309)
309	format(/'---Warning..... input delta-t not what expected') 
310      READ (1,FORM,END=330,err=310) kDATE,(ZZ(K),K=1,nv)
	if(ntype.eq.8) call cnv_date(kdate,kdate,ntype)
      DD=delday(imatdat,kDATE)
	if(dd.lt.0.0) go to 310
	if(xdel.gt.0.0) then
	IX=nint(DD/XDEL+1.001)
c	if(ix.le.5) c,ix,kdate,ddd,(ZZ(K),K=1,nv)
c	if(nx-ix.le.5) print*,ix,kdate,ddd,(ZZ(K),K=1,nv)
	else
	ddl=delday(kdate,lmatdat)
	if(dd.ge.0.0 .and. ddl.ge.0.0) then
	zz(nv1)=dd
	ix=ix+1
	endif
	endif
	if(ix.lt.1) go to 310
	if(ix.gt.nx) then
	if(xdel.gt.0.0) go to 330
	go to 310
	endif
	nread=nread+1
	call add_point(uv,nx,ny,nv1,zz,ix,iy,xflg)
	call sub_date(kdate,ldate)
	if(ix.lt.ixmin) then
	call sub_date(kdate,idate)
	ixmin=ix
	endif
	go to 310
330	print*,nread,nx,ny,nv
	if(nv1.gt.nv) then
	write(6,3301) nv1
3301	format(1x,'Non-equally spaced time series'
     1	/1x,'Time stored as variable ',i2)
	endif
340	CLOSE(1)
	nv=nv1
	else
c------------------------------------------------------------------------
c	atlas site file
c
	nread=0
	read(5,*) FNAM,FORM,nhead,(Y(iy),iy=1,ny),(xflg(iv),iv=1,nv)
      WRITE (6,343) FNAM,(Y(iy),iy=1,ny)
343    FORMAT (//10X,'ATLAS FILENAME: ',a/
     1	10x,'Y =',10F7.2)
	call fOPEN(1,FNAM,'OLD')
	do nh=1,nhead
	read(1,347) ahead
347	format(a)
	write(6,348) ahead
348	format(10x,a)
	enddo
350    	if(lnx.eq.0) then
	READ (1,FORM,END=380) kdate(5),jd,kdate(1),kdate(2),
     1	((za(iv,iy),iy=1,ny),iv=1,nv)
	else
	READ (1,FORM,END=380) kdate(5),jd,kdate(1),kdate(2),
     1	((za(iv,iy),iv=1,nv),iy=1,ny)
	endif
	call julian(jd,kdate(3),kdate(4),kdate(5),1)
        DD=delday(imatdat,kDATE)
	if(dd.lt.0.0) go to 350
	IX=DD/XDEL+1.1
	if(ix.lt.1.) go to 350
	if(ix.gt.nx) go to 390
	nread=nread+1
	do iy=1,ny
	call add_point(uv,nx,ny,nv,za(1,iy),ix,iy,xflg)
	enddo
	call sub_date(kdate,ldate)
	if(ix.lt.ixmin) then
	call sub_date(kdate,idate)
	ixmin=ix
	endif
	go to 350
380	print*,nread
390	CLOSE(1)
	endif
c	print*,nx,ny,nv
        return
c-------------------------------------------------------------------------
c       poly head (new format) composite data
c
600     call ra_poly_head(linit,uv,y,nx,ny,nv,xbad,ixmin,ixmax)
	RETURN
c
c
c
c--------------------------------------------------------------------
c	2-d binary data; one dimension is time
c
800     call ra_bin_plane(linit,uv,y,nx,ny,nv,xbad)
        return
c
c-------end of time series data
c
	END
c===============subroutines===========================================
	subroutine add_point(uv,nx,ny,nv,u,ix,iy,xflg)
c
c	adds one conventional point to matrix array
c
	common/check/nchk,xbad
	dimension uv(nx,ny,nv),u(1),xflg(nv)
	xbig=1.e30
	do iv=1,nv
	if(u(iv).lt.xbig.and.u(iv).ne.xflg(iv).and.uv(ix,iy,iv).eq.xbad)
     1	uv(ix,iy,iv)=u(iv)
	end do
	return
	end
	subroutine add_point0(uv,nx,ny,nv,u,iy,iv,xflg)
c
c	adds one conventional point to matrix array
c
	common/check/nchk,xbad
	dimension uv(nx,ny,nv),u(1),xflg(nx)
	xbig=1.e30
	do ix=1,nx
	if(u(ix).lt.xbig.and.u(ix).ne.xflg(ix).and.uv(ix,iy,iv).eq.xbad)
     1	uv(ix,iy,iv)=u(ix)
	end do
	return
	end
	subroutine add_prof(uv,nx,ny,nv,u,ix,xflg,nymin,nydim)
c
c	adds one rd profile to matrix array
c
	dimension uv(nx,ny,nv),u(nydim,4),xflg(nv)
	logical lu
      COMMON /log_uv/ lu(6)
	iv=0
	do jv=1,6
	if(lu(jv)) then
	iv=iv+1
	do iy=1,ny
	jy=iy+nymin-1
	if(jv.le.4.and.u(jy,iv).ne.xflg(iv)) uv(ix,iy,iv)=u(jy,jv)
	if(jv.eq.5.and.u(jy,1).ne.xflg(1).and.u(jy,2).ne.xflg(2)) 
     1	uv(ix,iy,iv)=uv2spd(u(jy,1),u(jy,2))
	if(jv.eq.6.and.u(jy,1).ne.xflg(1).and.u(jy,2).ne.xflg(2)) 
     1	uv(ix,iy,iv)=uv2dir(u(jy,1),u(jy,2))
	end do
	endif
	end do
	return
	end
	subroutine init_array(u,nx,ny,nv,xfill)
	dimension u(nx,ny,nv)
	do 10 ix=1,nx
	do 10 iy=1,ny
	do 10 iv=1,nv
10	u(ix,iy,iv)=xfill
	return
	end
	subroutine cnv_date(indate,outdate,ntype)
c
c	converts rdi dates to conventional or inverse
c
c	ntype=1;  real-time (Proteus) RDI date 
c	ntype=2;  internal memory RDI date 
c	ntype=8;  ftp hourly met date 
c
c	ntype = negative, then do inverse
c
c
	integer indate(5),outdate(5),tmpdate(5)
	if(ntype.eq.1) then
	outdate(1)=0
	outdate(2)=0
	do n=1,3
	outdate(n+2)=indate(n)
	end do
	elseif(ntype.eq.2) then
        outdate(5)=indate(5)
        outdate(4)=indate(1)
        outdate(3)=indate(2)
        outdate(2)=indate(4)
        outdate(1)=indate(3)
	elseif(ntype.eq.8) then
        tmpdate(5)=indate(1)
        tmpdate(4)=indate(2)
        tmpdate(3)=indate(3)
        tmpdate(2)=indate(5)
        tmpdate(1)=indate(4)
	call sub_date(tmpdate,outdate)
	elseif(ntype.eq.-1) then
	outdate(1)=0
	outdate(2)=0
	do n=3,5
	outdate(n)=indate(n-2)
	end do
	elseif(ntype.eq.-2) then
        outdate(5)=indate(5)
        outdate(1)=indate(4)
        outdate(2)=indate(3)
        outdate(3)=indate(1)
        outdate(4)=indate(2)
	elseif(ntype.eq.-8) then
        tmpdate(4)=indate(1)
        tmpdate(5)=indate(2)
        tmpdate(3)=indate(3)
        tmpdate(2)=indate(4)
        tmpdate(1)=indate(5)
	call sub_date(tmpdate,outdate)
	endif
	return
	end
	subroutine sub_date(indate,outdate)
c
c	equates outdate to indate
c
	integer indate(5),outdate(5)
	do n=1,5
	outdate(n)=indate(n)
	end do
        return
        end
	subroutine ylev(y,ny,nymin,y0,y1)
        dimension y(1) 
	y(1)=y0
	do n=1,ny
	y(n)=y1*(n+nymin-2)+y0
	end do
	return
	end
      function uv2spd(U,V) 
C 
C     speed CALCULATED FROM U AND V
C 
	uv2spd = SQRT(U**2+V**2) 
	return
	end
      function uv2dir(U,V) 
C 
C     direction CALCULATED FROM U AND V
C 
      AAA=180./3.14159
      IF (V) 200,210,200
200   DIR = ATAN2 (U,V)*AAA 
      IF (DIR.LT.0.0) DIR = DIR + 360.
      GO TO 230 
210   IF (U) 211,212,213
211   DIR = 270.
      GO TO 230 
212   DIR = 0.0 
      GO TO 230 
213   DIR = 90. 
230   uv2dir = DIR 
      RETURN
	end
	subroutine get_clim(uv,nx,ny,nv,iy)
	dimension uv(nx,ny,nv)
	if(iy.le.0) iy=1
	do iv=1,nv
	read(1,11,end=9) (uv(ix,iy,iv),ix=1,nx)
11	format(12f6.0)
	enddo
9	return
	end
	subroutine add_gpcp(uv,nx,ny,nv,u,ix,iy1,iv1)
c
c	adds one gpcp rain grid to matrix array
c
	dimension uv(nx,ny,nv),u(144,32)
	do iy=1,ny
	do iv=1,nv
	uv(ix,iy,iv)=u(iv+iv1-1,iy+iy1-1)
	enddo
	enddo
	return
	end



