      SUBROUTINE CONVTC (NUM,NCHAR, LOC)                                        
C***********************************************************************        
C  LIBRARY SUBROUTINE                                                           
C                                                                               
C  MODULE NAME: CONVTC                                                          
C                                                                               
C  VERSION    : 1.0                                                             
C                                                                               
C  PROGRAMMER : LUCY LIU AND MICHAEL PENG, STX, AUGUST 1990                     
C                                                                               
C  PURPOSE: TO CONVERT FIRST NCHAR DIGITS OF AN INTEGER INTO A CHARACTER        
C           OR A STRING. (NOTE: NCHAR DOESN'T INCLUDE THE SIGN IF NUM           
C           IS NEGATIVE)                                                        
C                                                                               
C  CALLING SEQUENCE: CONVTC (NUM,NCHAR, LOC)                                    
C                                                                               
C  SUBROUTINES CALLED: NONE                                                     
C                                                                               
C  INTRINSIC FUNCTIONS USED: CHAR, ICHAR, IABS                                  
C                                                                               
C  COMMON BLOCKS USED: NONE                                                     
C                                                                               
C  ARGUMENTS AND LOCAL VARIABLES:                                               
C                                                                               
C      NAME    TYPE  I/O  DESCRIPTIONS                                          
C   ---------  ----  ---  ----------------------------------------------        
C   NUM        I*4    I   INTEGER NUMBER FOR CONVERSION                         
C   NCHAR      I*4    I   NUMBER OF CHARS TO BE CONVERTED                       
C   LOC        C*X    O   CHAR VARIABLE OR ARRAY (STRING)                       
C   ISTART     I*4        START POSITION OF INTEGRAL CHAR STRING:               
C                         1 FOR POSITIVE INTEGER; 2 FOR NEGATIVE INTEGER        
C   IREM       I*4        ABSOLUTE VALUE OR REMAINDER BY 10                     
C   ITEMP      I*4        TEMPORARY BUFFER                                      
C***********************************************************************        
C                                                                               
C --- ARGUMENTS                                                                 
C                                                                               
      INTEGER   NUM, NCHAR                                                      
      CHARACTER LOC(1)                                                          
C                                                                               
C --- LOCAL VARIABLES                                                           
C                                                                               
      INTEGER   ISTART, IREM, ITEMP                                             
C                                                                               
      IREM = IABS (NUM )                                                        
      ISTART = 1                                                                
C                                                                               
C --- KEEP THE SIGN IF THE INTEGER IS NEGATIVE                                  
C                                                                               
      IF (NUM.LT.0) THEN                                                        
         NCHAR = NCHAR + 1                                                      
         LOC(1) = '-'                                                           
         ISTART = ISTART + 1                                                    
      ENDIF                                                                     
C                                                                               
C --- CONVERT DIGIT BY DIGIT STARTING WITH THE LEAST SIGNIFICANT DIGIT          
C                                                                               
      DO 100 I = NCHAR, ISTART, -1                                              
         ITEMP = IREM / 10                                                      
         LOC(I) = CHAR (IREM - ITEMP * 10 + ICHAR('0'))                         
         IREM = ITEMP                                                           
 100  CONTINUE                                                                  
C                                                                               
C --- PUT AN ASTERISK AT THE FIRST POSITION IF THE ACTUAL NUMBER OF             
C --- DIGITS IN THE INTEGER IS FOUND GREATER THAN NCHAR                         
C                                                                               
      IF (IREM.NE.0) LOC(1) = '*'                                               
C                                                                               
      RETURN                                                                    
      END                                                                       
