      SUBROUTINE SETDDF(RET,TL,CT)                          
C                                                                       
C     SUBROUTINE SETDDF HAS BEEN ADAPTED FROM SUBROUTINE SETDDF WRITEN  
C     BY CARMEN M. BENKOVITZ                                            
C        BROOKHAVEN NATIONAL LABORATORY                                 
C        UPTON, N.Y. 11973                                              
C        JUNE 1976                                                      
C                                                                       
C     THIS ADAPTATION WAS WRITEN FOR THE PDP 11/70                      
C     BY JOHN C. BOWER                                                  
C        BATTELLE PACIFIC NORTHWEST LABORATORY                          
C        RICHLAND, WA. 99352                                            
C        APRIL 1978                                                     
C                                                                       
C     THIS ROUTINE FORMATS THE LEADER FOR THE DATA DEFINITION FILE (DDF)
C     THE FIRST FILE TO BE WRITEN TO AN IWGDE ANSI EXTENDED FORMAT TAPE.
C                                                                       
C     PARAMATERS ARE AS FOLLOWS:                                        
C     RET = RETURN FLAG, VALUES ARE:                                    
C           0 - NO ERRORS                                               
C           1 - REDUNDANT CALL                                          
C          -1 - INVALID SUBSYSTEM CONTROL                               
C          -2 - INVALID CHARACTER SET CONTROL                           
C          -3 - INVALID FIELD CONTROL COUNT                             
C          -4 - INVALID TAG LENGTH                                      
C          -5 - INVALID CHARACTER TYPE                                  
C                                                                       
C     SSC = SUBSYSTEM CONTROL, 1 LEFT JUSTIFIED DISPLAY CODE CHARACTER  
C           (CURRENTLY ONLY 2/0 IMPLEMENTED)                            
C     CSC = CHARACTER SET CONTROL, TWO LEFT JUSTIFIED DISPLAY CODE      
C           CHARACTERS (CURRENTL ONLY 2/0 2/0 IMPLEMENTED)              
C     FCC = FIELD CONTROL COUNT, TWO LEFT JUSTIFIED DISPLAY CODE        
C           CHARACTERS (CURRENTLY ONLY 00 - 09 ARE ALLOWED)             
C     TL  = TAG LENGTH, INTEGER (1 TO 7)                                
C     CT  = CHARACTER TYPE, INTEGER, 0=INPUT, DATA IS ASCII, 1=INPUT    
C           DATA IS DISPLAY CODE (CURRENTLY ONLY CT=1 IS IMPLIMENTED)   
C     DEFAULT VALUES ARE AS FOLLOWS:                                    
C     CSC = SPACES (ASCII 2/0)                                          
C     FCC = 00                                                          
C     TL = 3                                                            
C     CT = 1                                                            
C                                                                       
C     BRIEF PROCEEDURE DESCRIPTION:                                     
C     AN IMAGE OF A LEADER WITH DEFAULT VALUES HAS BEEN ASSEMBLED IN ARR
C     LEAD.  WHEN THIS ROUTINE IS CALLED, ARGUMENT VALUES OVERIDE DEFAUL
C     THE ROUTINE ABORTS IF ANY OF THE FOLLOWING ERROR CONDITIONS ARE   
C     ENCOUNTERED:                                                      
C     1. REDUNDANT CALL TO ROUTINE.                                     
C     2. INVALID VALUE FOR ANY OF THE ARGUMENTS.                        
C                                                                       
      LOGICAL*1 SCHK(2)                                                 
      INTEGER       TL,CT,     RET,ALPH00,  BLANK,
     $ALPH09 
      EQUIVALENCE (SSC,SCHK(1))
      INCLUDE 'SY:DDFCOM.FTN'                                              
      INCLUDE 'SY:FLGCM.FTN'
      DATA LCHCSC/2/                                                    
      DATA LSSC/1/
      DATA LFLG/1/
      DATA LCHSSC/1/                                                    
      DATA LCHFCC/6/                                                    
      DATA LFCC/2/
      DATA BLANK/' '/                                                   
      DATA ALPH00/'00'/                                                 
      DATA ALPH09/'09'/                                                 
      IF(DEBUG) TYPE 2000
 2000 FORMAT(' SETDDF')
      RET=0
C                                                                       
C     CHECK FOR REDUNDANT CALL TO THIS ROUTINE.                         
C                                                                       
      IF(LFLG.EQ.0) GO TO 900                                           
C                                                                       
C     SUBSYSTEM CONTROL (SSC)                                           
C                                                                       
C     TEST FOR BLANK IN CHARACTER ONE                                   
C                                                                       
      IF(SSC.NE.BLANK) GO TO 910                                   
C                                                                       
C     PUT SSC IN LEADER                                                 
C                                                                       
      CALL STRMOV(SSC,LEAD(LCHSSC),LSSC)                                
C                                                                       
C     CHARACTER SET CONTROL                                             
C                                                                       
C     CHECK FOR BLANKS IN BOTH CHARACTERS THEN STORE IN LEADER          
C                                                                       
      IF(CSC.NE.BLANK) GO TO 920                                        
      CALL STRMOV(CSC,LEAD(LCHCSC),LCSC)                                
C     FIELD CONTROL COUNT                                               
C                                                                       
C     IS FIELD CONTROL COUNT IN THE RANGE 0-9> IF SO STORE IN LEADER    
C                                                                       
      IF(FCC.LT.ALPH00.OR.FCC.GT.ALPH09) GO TO 930                      
      CALL STRMOV(FCC,LEAD(LCHFCC),LFCC)                                
C                                                                       
C     IS TAG LENGTH OK>                                                 
C                                                                       
      IF(TL.LT.0.OR.TL.GT.7) GO TO 940                                  
      LTG=TL                                                            
C                                                                       
C     IS CHARACTER TYPE ACCEPTABLE>                                     
C                                                                       
      IF(CT.LT.0.OR.CT.GT.1) GO TO 950                                  
      IF(CT.NE.1) GO TO 960                                             
      RETURN                                                            
C                                                                       
C     ERRORS IN DDF PARAMATERS                                          
C                                                                       
  900 TYPE 901                                                         
  901 FORMAT(//1X,'-----REDUNDANT CALL TO DDFW, IGNORED.-----')          
      RET=1                                                             
      RETURN                                                            
C                                                                       
  910 TYPE 911, SSC                                                 
  911 FORMAT(//1X,'---SUBSYSTEM CONTROL = ',1X,A1,' NOT IMPLEMENTED---')
      RET=-1                                                            
      GO TO 990                                                         
C                                                                       
  920 TYPE 921,CSC                                                     
  921 FORMAT(//1X,'-----CHARACTER SET CONTROL=',1X,A2,                     
     $' NOT IMPLEMENTED-----')                                          
      RET=-2                                                            
      GO TO 990                                                         
C                                                                       
  930 TYPE 931                                                         
  931 FORMAT(//1X,'-----ILLEGAL FIELD CONTROL COUNT-----')               
      RET=-3                                                            
      GO TO 990                                                         
C                                                                       
  940 TYPE 941                                                         
  941 FORMAT(//1X,'-----ILLEGAL TAG LENGTH-----')                        
      RET=-4                                                            
      GO TO 990                                                         
C                                                                       
  950 TYPE 951                                                         
  951 FORMAT(//1X,'-----ILLEGAL CHARACTER TYPE-----')                    
      RET=-5                                                            
      GO TO 990                                                         
C                                                                       
  960 TYPE 961                                                         
  961 FORMAT(//1X,'-----ASCII CHARACTER IMPLEMENTATION NOT COMPLETE---') 
      RET=-5                                                            
      GO TO 990                                                         
C                                                                       
  990 CONTINUE                                                            
      LFLG=0
      RETURN
      END                                                               
