	SUBROUTINE GET_LUN(NEW_LUN)

**-	SUBROUTINE GET_LUN(NEW_LUN)
**- get free logical unit
**- output parameters:	new_lun<i> - free logical unit number

        LOGICAL ISOPEN
	INTEGER START_LUN,NEW_LUN
	
	START_LUN=99

        INQUIRE(START_LUN,OPENED=ISOPEN)
	DO WHILE (ISOPEN)
	  START_LUN=START_LUN-1
	  IF (START_LUN.EQ.10) STOP 'NO FREE LUN'
          INQUIRE(START_LUN,OPENED=ISOPEN)
        ENDDO
	NEW_LUN=START_LUN

	RETURN
	END

	SUBROUTINE FREE_LUN(OLD_LUN)

**-	SUBROUTINE FREE_LUN(OLD_LUN)
**- relese logical unit (VAX compatibility)
**- input parameters:	old_lun<i> - logical unit number

        INTEGER OLD_LUN

	RETURN
	END

	SUBROUTINE GET_USERNAM(USERNAME,NLEN)

**-	SUBROUTINE GET_USERNAM(USERNAME,NLEN)
**- get username
**- output parameters:	username<c> - username
**-			nlen<i> - lenght of the username

	INTEGER*4 NLEN
	CHARACTER USERNAME*(*)
        
	CALL GETLOG(USERNAME)
	NLEN=LEN(USERNAME)

	RETURN
	END

	SUBROUTINE GET_I(PROMPT,I)

**-	SUBROUTINE GET_I(PROMPT,I)
**- get integer
**- input parameters:	prompt<c>
**- output parameters:	i<i> - integer

	INTEGER I
	CHARACTER PROMPT*(*)

	PRINT '($,5X,A)',PROMPT
	READ *,I

	RETURN
	END

	SUBROUTINE GET_R(PROMPT,R)

**-	SUBROUTINE GET_R(PROMPT,R)
**- get real 
**- input parameters:	prompt<c>
**- output parameters:	r<r> - real

	REAL R
	CHARACTER PROMPT*(*)

	PRINT '($,5X,A)',PROMPT
	READ *,R

	RETURN
	END

	SUBROUTINE GET_R8(PROMPT,R)

**-	SUBROUTINE GET_R8(PROMPT,R)
**- get real*8 
**- input parameters:	prompt<c>
**- output parameters:	r<r8> - real

	REAL*8 R
	CHARACTER PROMPT*(*)

	PRINT '($,5X,A)',PROMPT
	READ *,R

	RETURN
	END

	SUBROUTINE GET_C(PROMPT,C)

**-	SUBROUTINE GET_C(PROMPT,C)
**- get integer
**- input parameters:	prompt<c>
**- output parameters:	c<c> - character

	CHARACTER C*(*),PROMPT*(*)

	PRINT '($,5X,A)',PROMPT
	READ '(A)',C

	RETURN
	END

	SUBROUTINE SWAP2(I1)

**-	SUBROUTINE SWAP2(I1)
**- swap integer*2

        BYTE T,I1(2)

        T=I1(1)
	I1(1)=I1(2)
	I1(2)=T	
	
	RETURN
	END

	SUBROUTINE SWAP2N(I1,N)

**-	SUBROUTINE SWAP2N(I1)
**- swap N integer*2

        BYTE T,I1(2,*)
        INTEGER N,I

        DO I=1,N
          T=I1(1,I)
	  I1(1,I)=I1(2,I)
	  I1(2,I)=T	
	ENDDO
	
	RETURN
	END

	SUBROUTINE SWAP4(I1)

**-	SUBROUTINE SWAP2(I1)
**- swap integer*4

        BYTE T,I1(4)

        T=I1(1)
	I1(1)=I1(4)
	I1(4)=T	
        T=I1(2)
	I1(2)=I1(3)
	I1(3)=T	
	
	RETURN
	END

	SUBROUTINE SWAP4N(I1,N)

**-	SUBROUTINE SWAP4N(I1)
**- swap N integer*4

        BYTE T,I1(4,*)
        INTEGER N,I

        DO I=1,N
          T=I1(1,I)
	  I1(1,I)=I1(4,I)
	  I1(4,I)=T	
          T=I1(2,I)
          I1(2,I)=I1(3,I)
	  I1(3,I)=T	
	ENDDO
	
	RETURN
	END
