
      PARAMETER (NGX=241, NGY=86)
      parameter(pi=3.14159)
      DIMENSION WAVEHT(NGX,NGY), WAVEDIR(NGX,NGY), WAVEMFR(NGX,NGY)
      DIMENSION WINDSPD(NGX,NGY), WINDDIR(NGX,NGY), WAVEPFR(NGX,NGY)
      DIMENSION CDG(NGX,NGY), TAUWG(NGX,NGY)
      DIMENSION UCO(NGX,NGY), VCO(NGX,NGY)
      CHARACTER*12 IIDATE
      LOGICAL IEOF, FFLAG(8),FFLAGS(4)

       NX = NGX
       NY = NGY

       OPEN(IUNIT,FILE='MAP020512190000',FORM='UNFORMATTED')
      READ(IUNIT, END=3000) IIDATE, DNGX, DNGY,
     1                      AMOWEP, AMOSOP, AMOEAP, AMONOP

      READ(IUNIT, END=3000) (FFLAG(J),J=1,8)
       print *,fflag
      IF (FFLAG(1))
     1   READ(IUNIT, END=3000) ((WAVEHT(I,K) ,I=1,NX),K=1,NY)
      IF (FFLAG(2))
     1   READ(IUNIT, END=3000) ((WAVEDIR(I,K),I=1,NX),K=1,NY)
      IF (FFLAG(3))
     1   READ(IUNIT, END=3000) ((WAVEMFR(I,K),I=1,NX),K=1,NY)
      IF (FFLAG(4))
     1   READ(IUNIT, END=3000) ((WINDSPD(I,K),I=1,NX),K=1,NY)
      IF (FFLAG(5))
     1   READ(IUNIT, END=3000) ((WINDDIR(I,K),I=1,NX),K=1,NY)
      IF (FFLAG(6))
     1   READ(IUNIT, END=3000) ((WAVEPFR(I,K),I=1,NX),K=1,NY)
      IF (FFLAG(7))
     1   READ(IUNIT, END=3000) ((CDG(I,K),I=1,NX),K=1,NY)
      IF (FFLAG(8))
     1   READ(IUNIT, END=3000) ((TAUWG(I,K),I=1,NX),K=1,NY)

3000  CONTINUE

         DO 3200 K=1,NY
         DO 3200 I=1,NX
            IF (WAVEHT(I,K).LT.0.00001) THEN
               WINDDIR(I,K) = 1.e35
               WINDSPD(I,K) = 1.e35
            END IF
         IF (WINDDIR(I,K).LT.0.) WINDDIR(I,K) = WINDDIR(I,K)+360.
         IF (WAVEDIR(I,K).LT.0.) WAVEDIR(I,K) = WAVEDIR(I,K)+360.

3200    CONTINUE
         DO 4200 K=1,NY
         DO 4200 I=1,NX
          IF ( WINDDIR(I,K).EQ.1.e35) goto 4200
          uco(i,k) = sin(winddir(i,k)*pi/180.)
          vco(i,k) = cos(winddir(i,k)*pi/180.)
c         uco(i,k) = sin(wavedir(i,k)*pi/180.)
c         vco(i,k) = cos(wavedir(i,k)*pi/180.)
4200     CONTINUE


          iuout = 60
          open(60,file='wind.out')
          write(iuout,300) ((windspd(i,ny-j+1),i=1,nx),j=1,ny)
c         write(iuout,300) ((waveht(i,ny-j+1),i=1,nx),j=1,ny)
          write(iuout,300) ((uco(i,ny-j+1),i=1,nx),j=1,ny)
          write(iuout,300) ((vco(i,ny-j+1),i=1,nx),j=1,ny)

 300  FORMAT(8e10.3)

           STOP
           END
