      subroutine openfiles
c                            date - 7/31/96   pgmr - Anita C. Brenner
c function - open all files required to read and interpret ocean
c  pathfinder collinear data base
      integer*4 nreclephm,nreclmss,nreclsshfl,nrecltime,ncycles
      integer*4 numrevs,nrecldir,nperiod
      integer*4 in5,iout6,inephm,inssh,intime,inflag,inmss
      character*80 sshfile,mssfile,flagfile,timefile,ephmfile,dirfile
      common/cmission/nreclephm,nreclmss,nreclsshfl,nrecltime,nrecldir,
     . ncycles,numrevs,nperiod
      common/cfnamersr/sshfile,mssfile,flagfile,timefile,ephmfile,
     .   dirfile
      common/cunits/in5,iout6,inephm,inssh,intime,inflag,inmss,indir
      save
c open file with reference orbits
      open(inephm,file=ephmfile,access='direct',recl=nreclephm,
     .  form='unformatted',status='old',iostat=ios,err=1999)
      write(iout6,10000)ephmfile,inephm,nreclephm
c open mean sea surface file
      open(inmss,file=mssfile,access='direct',recl=nreclmss,
     .  form='unformatted',status='old',iostat=ios,err=2999)
      write(iout6,10000)mssfile,inmss,nreclmss
c open flag word file
      open(inflag,file=flagfile,access='direct',recl=nreclsshfl,
     .  form='unformatted',status='old',iostat=ios,err=3999)
      write(iout6,10000)flagfile,inflag,nreclsshfl
c open time file
      open(intime,file=timefile,access='direct',recl=nrecltime,
     .  form='unformatted',status='old',iostat=ios,err=4999)
      write(iout6,10000)timefile,intime,nrecltime
c open residual sea surface height file
      open(inssh,file=sshfile,access='direct',recl=nreclsshfl,
     .  form='unformatted',status='old',iostat=ios,err=5999)
      write(iout6,10000)sshfile,inssh,nreclsshfl
c open directory file
      open(indir,file=dirfile,access='direct',recl=nrecldir,
     .  form='unformatted',status='old',iostat=ios,err=6999)
      write(iout6,10000)dirfile,indir,nrecldir
      return
1999  write(iout6,20000)ephmfile,inephm,ios
      stop 16
2999  write(iout6,20000)mssfile,inmss,ios
      stop 16
3999  write(iout6,20000)flagfile,inflag,ios
      stop 16
4999  write(iout6,20000)timefile,intime,ios
      stop 16      
5999  write(iout6,20000)sshfile,inssh,ios
      stop 16
6999  write(iout6,20000)dirfile,indir,ios
      stop 16
10000 format(' opened file: '/a/' on unit ',i3,' with record length',
     .  i8)
20000 format(' i/o error occured opening file '/a/' on unit ',i3,
     .  ' error number (iostat) is ',i5)
      end
     
