C
C	$Id: trassn.f.sed,v 1.2 2008-07-27 00:59:05 haley Exp $
C                                                                      
C                Copyright (C)  2000
C        University Corporation for Atmospheric Research
C                All Rights Reserved
C
C The use of this Software is governed by a License Agreement.
C
      SUBROUTINE TRASSN(IOS,STATUS)
C
C  THIS ROUTINE ASSIGNS THE PROPER TRANSLATOR BASED ON THE DATA TYPE
C  FIELD FOUND IN THE CURRENT METAFILE RECORD.
C
C  OUTPUT
C     IOS    --  The I/O status which is valid only if STATUS
C                is set to an I/O error.
C     STATUS --  The error status defined in COMMON TREROR.
C
      COMMON /TRTYPE/ METMIN, METEXT, METPRT, METHED, MIOPCL, MXOPCL,
     1                MIOPID, MXOPID, ASCDEC, ASCHEX, ASCOCT, BINARY,
     2                GAHNOR, GALEFT, GACENT, GARITE, GAVNOR, GATOP ,
     3                GACAP , GAHALF, GABASE, GABOTT, GRIGHT, GLEFT ,
     4                GUP   ,
     5                GDOWN , CINDEX, CDIRCT, PENUP , PENDN , FLAGVL,
     6                SEPRVL, ASCTEK, TYPRGB, TYPBGR,
     7                TYPHLS, TYPMON, SOLID , DASHED, INVSBL, SOLPAT,
     8                ASFIND, ASFBND, ASFLNT, ASFLNW, ASFLNC, ASFMRT,
     9                ASFMRS, ASFMRC, ASFFIS, ASFFHI, ASFFPI, ASFFCO,
     A                ASFFPT, ASFFPW, ASFFPC, ASFTFI, ASFTPR, ASFTCX,
     B                ASFTCS, ASFTCO, ASCFLT, PHOLLO, PSOLID, PPATTR,
     C                PHATCH, PEMPTY, HHORIZ, HVERTI, HPOSLP, HNESLP,
     D                HHOAVE, HPOANE
      INTEGER         METMIN, METEXT, METPRT, METHED, MIOPCL, MXOPCL,
     1                MIOPID, MXOPID, ASCDEC, ASCHEX, ASCOCT, BINARY,
     2                GAHNOR, GALEFT, GACENT, GARITE, GAVNOR, GATOP ,
     3                GACAP , GAHALF, GABASE, GABOTT, GRIGHT, GLEFT ,
     4                GUP   ,
     5                GDOWN , CINDEX, CDIRCT, PENUP , PENDN , FLAGVL,
     6                SEPRVL, ASCTEK, TYPRGB, TYPBGR,
     7                TYPHLS, TYPMON, SOLID , DASHED, INVSBL, SOLPAT,
     8                ASFIND, ASFBND, ASFLNT, ASFLNW, ASFLNC, ASFMRT,
     9                ASFMRS, ASFMRC, ASFFIS, ASFFHI, ASFFPI, ASFFCO,
     A                ASFFPT, ASFFPW, ASFFPC, ASFTFI, ASFTPR, ASFTCX,
     B                ASFTCS, ASFTCO, ASCFLT, PHOLLO, PSOLID, PPATTR,
     C                PHATCH, PEMPTY, HHORIZ, HVERTI, HPOSLP, HNESLP,
     D                HHOAVE, HPOANE
      COMMON /PTRBUFR/ METBIT, MBUFER, MDTYPE, METREC, MRECLN,
     1                MCONTF, MOPRST, LNGFLG, MERGFL
      INTEGER MNWRDS, RECLOC, RECSIZ, DTLOC, DTSIZ, MBITST, MBUFOF,
     1        MINSBD, MERLOC, MERSIZ
#if defined(cray)
      PARAMETER (MNWRDS=180, RECLOC=0, RECSIZ=16, DTLOC=16, DTSIZ=4
#else
      PARAMETER (MNWRDS=360, RECLOC=0, RECSIZ=16, DTLOC=16, DTSIZ=4
#endif
     1          ,MBITST=32, MBUFOF=32, MINSBD=16, MERLOC=23, MERSIZ=1)
      INTEGER METBIT, MBUFER(MNWRDS), MDTYPE, METREC, MRECLN, MOPRST
      LOGICAL MCONTF, LNGFLG, MERGFL
      COMMON/TREROR/ ALLOK, MFRCHK, MTOPER, METRDC, REDERR, TYPCHG
     1             ,INVTYP, MINVLD, TYPERR, FRMEND, ENCINT, IVDCDT
     2             ,GCOERR, GCRERR, GCCERR, FCOERR, FCRERR, FCCERR
     3             ,PLIDXG, PMIDXG, TXIDXG, PGIDXG, INVLMT, CELERR
     4             ,COIERR, COLNRM, UNKNOW, UNKOPC, ENDMTF, VNEROR
     5             ,BADRSZ, DEVOUT, NOVERS, BADFNT, PGMERR, FASERR
     6             ,HINERR, VDWERR, RDWERR, RIXLIM
      INTEGER        ALLOK, MFRCHK, MTOPER, METRDC, REDERR, TYPCHG
     1             ,INVTYP, MINVLD, TYPERR, FRMEND, ENCINT, IVDCDT
     2             ,GCOERR, GCRERR, GCCERR, FCOERR, FCRERR, FCCERR
     3             ,PLIDXG, PMIDXG, TXIDXG, PGIDXG, INVLMT, CELERR
     4             ,COIERR, COLNRM, UNKNOW, UNKOPC, ENDMTF, VNEROR
     5             ,BADRSZ, DEVOUT, NOVERS, BADFNT, PGMERR, FASERR
     6             ,HINERR, VDWERR, RDWERR, RIXLIM
      COMMON/TRINOT/ IPTR, MBUFOT, MAXBYT, DEVUNT, METUNT,
     1          METIPT, ERRUNT, FNTUNT
      INTEGER MAXCNT
      PARAMETER (MAXCNT=200)
      INTEGER IPTR, MBUFOT(MAXCNT), MAXBYT, DEVUNT, METUNT, ERRUNT,
     1        FNTUNT
      LOGICAL METIPT
C
      INTEGER IOS, STATUS
C
C  SET THE DEFAULT OPERAND LENGTHS BEFORE READING ANY INSTRUCTIONS
C
      CALL XMOPDF
C
C  BRANCH TO THE PROPER TRANSLATOR
C
 10   CONTINUE
      STATUS = 0
      IF (MDTYPE .EQ. METEXT) THEN
C
C       THE EXTENDED METACODE TRANSLATOR
C
        STATUS = TYPCHG
      ELSE IF (MDTYPE .EQ. METMIN) THEN
C
C       THE MINIMAL METACODE TRANSLATOR
C
        CALL TRLATE(IOS,STATUS)
      ELSE IF ((MDTYPE.EQ.METPRT) .OR. (MDTYPE.EQ.METHED)) THEN
C
C       THE PRINTER TRANSLATOR
C       GET ANOTHER RECORD
C
        CALL METRED(IOS,STATUS)
        IF (STATUS .EQ. ALLOK) STATUS = TYPCHG
      ELSE
C
C       NOT MINIMAL METACODE
C
C       GET ANOTHER RECORD
C
        CALL METRED(IOS,STATUS)
        IF (STATUS.EQ.ALLOK) STATUS = TYPCHG
      END IF
C
C  CHECK IF STATUS REQUESTING A NEW TRANSLATOR
C
      IF (STATUS .EQ. TYPCHG) GO TO 10
C
      RETURN
      END
