    	SUBROUTINE NAMEXT( NAME1, NAME2, EXT )
C
C  PROGRAMMER: R.S. ZHOU
C
C  	THIS ROUTINE EXTRACTS FILENAME FROM "NAME1" AND
C	ATTACHES THE FILE EXTENSION "EXT" TO IT AND
C	STORES THE FILESPEC TO "NAME2".
C
    	CHARACTER NAME1*(*), NAME2*(*), EXT*(*)

    	IF( NAME1.EQ.' ' .OR. EXT.EQ.' ' ) RETURN
     	NAME2 = NAME1
    	N1 = INDEX( NAME2, ']' )
    	N2 = INDEX( NAME2(N1+1:), '.' )
    	IF( N2.EQ.0 ) THEN
    	    N1 = INDEX( NAME2, ' ' )
    	    NAME2(N1:N1) = '.'
    	ELSE
    	    N1 = N1 + N2
    	ENDIF
    	N1 = N1 + 1
    	NAME2(N1:) = EXT
    	RETURN
    	END
