       SUBROUTINE SWAPI4(DATA,N)     
       INTEGER N
       INTEGER*4 DATA(N)
C
C----------------------------------------------------------------------
C
C.IDENTIFICATION: Function   SWAPI4
C.LIBRARY:        GENERAL
C.AUTHOR:         L.Chiappetti - IFCTR Milano
C.VERSIONS:       1.0 -  5 Nov 92 - Original version
C.PURPOSE:        byte-swap an INTEGER*4 or REAL*4 array or scalar (N=1)           
C.METHOD:         use an equivalence with a CHARACTER array
C.SYNTAX:         CALL SWAPI4(DATA,N)                   
C.PARAMETERS:     INTEGER*4 DATA    the stuff to be swapped (in and out)
C-                INTEGER   N       number of elements in array
C.RESTRICTIONS:   none 
C.NOTES:          this code should be portable ... though may be slightly
C                 inefficient
C                 it swaps bytes ABCD --> DCBA   
C.FILES:          none
C.REFERENCES:     none
C---------------------------------------------------------------------------
C
       INTEGER*4    WORK
       CHARACTER    C(4),W                   
       EQUIVALENCE  (WORK,C)
       INTEGER      I
C
       IF(N.LE.0)RETURN
       DO 1 I=1,N
       WORK=DATA(I)
       W=C(1)
       C(1)=C(4)
       C(4)=W
       W=C(2)
       C(2)=C(3)
       C(3)=W
       DATA(I)=WORK
 1     CONTINUE
       RETURN
       END
