C+ C NAME: C Bit32 C PURPOSE: C Put the binary representation for a integer*4 into a 32 element C integer*1 array or v.v. C CALLING SEQUENCE: subroutine Bit32(ID,IN,OBIT) C INPUTS: C ID integer 0 : integer ---> binary C 1 : binary ---> integer C INPUTS/OUTPUTS: C IN integer integer to be converted to binary C OBIT(32) integer*1 binary representation for IN C RESTRICTIONS: C If IN is negative, two's complement convention is assumed, i.e. C bit 32 is set to one; the other 31 bits are those of the positive C number IN+2147483648. C PROCEDURE: C The least significant bit of IN is put into OBIT(32), the most C significant in OBIT(1), i.e. if OBIT is printed with format 32I1 C the value of IN in binary results. C MODIFICATION HISTORY: C MAR-1992, Paul Hick (UCSD/CASS; pphick@ucsd.edu) : Rewrite of JBIT16 C- integer ID integer IN integer*1 OBIT(32) if (ID .eq. 0) then IBIT = IN OBIT(1) = 0 if (IBIT .lt. 0) then IBIT = IBIT+1 IBIT = IBIT+2147483647 ! Don't change this !!! OBIT(1) = 1 end if do I=32,2,-1 OBIT(I) = IBIT-IBIT/2*2 IBIT = IBIT/2 end do else IN = 0 do I=2,32 IN = OBIT(I)+2*IN end do if (OBIT(1) .eq. 1) then IN = IN-2147483647 IN = IN-1 ! Don't change this !!! end if end if return end