C Input file = 'd08XXXX.pad' ; Output file = 'd08XXXX.lis' c XXXX = CRRES Orbiter Number (0015 - 1067) for this data set C PROTEL - One minute average sorted by pitch angle dependent L C (derived from *.min files) C C 05/02/2001: Modified for non-SGI UNIX by J. F. Cooper c 09/11/2002: Modified for Windows PC Fortran by J. F. Cooper c PROGRAM READ_PAD INTEGER*2 NOBF(24,19),KLEG,KSH INTEGER*4 IORBIT,ICH,JORBIT,IYEAR,IDAY,NREC,MAXBIN,KSEC REAL*4 ENERGY(24),FLUX(24,19) CHARACTER*11 INFILE,OUTFILE DATA INFILE/'d08XXXX.pad'/ PRINT*,' ENTER ORBIT NUMBER:' READ(*,*) IORBIT PRINT*,' ENTER CHANNEL NUMBER:(1-24)' READ(*,*) ICH C WRITE(INFILE(4:7),'(I4.4)') IORBIT WRITE(6,*) INFILE OUTFILE = INFILE(1:8)//'lis' WRITE(6,*) OUTFILE C c Input data records are SGI binary - this routine reads these on other platforms c Use the following open statement for Windows PC (RECL in bytes) OPEN(1,FILE=INFILE,ACCESS='DIRECT',RECL=2744,ERR=100) ! Windows PC c Use the following open statement for non-SGI UNIX (RECL in 4-byte words) c OPEN(1,FILE=INFILE,ACCESS='DIRECT',RECL=686,ERR=100) ! Non-SGI UNIX WRITE(6,*) ' OPENED INPUT FILE' OPEN(2,FILE=OUTFILE,STATUS='UNKNOWN') WRITE(6,*) ' OPENED OUTPUT FILE' C Read header record READ(1,REC=1,err=100)JORBIT,iyear,iday,nrec,maxbin,ENERGY CALL BYTIN4(JORBIT) CALL BYTIN4(IYEAR) CALL BYTIN4(IDAY) CALL BYTIN4(NREC) CALL BYTIN4(MAXBIN) DO I=1,24 CALL BYTFL4(ENERGY(I)) ENDDO WRITE(2,22)JORBIT,IYEAR,IDAY,ENERGY(ICH) 22 FORMAT(/,' ORBIT=',I4,' YEAR=',I2,' DAY=',I3,' MeV=',F6.2) WRITE(2,*) ' NREC,MAXBIN = ',NREC,MAXBIN C Read data records DO 10 iREC=2,nrec+1 READ(1,REC=iREC,ERR=100)kleg,ksh,ksec,FLUX,NOBF C Comment out the following statements for SGI UNIX platforms CALL BYTIN2(KLEG) CALL BYTIN2(KSH) CALL BYTIN4(KSEC) DO IICH=1,24 DO IPA=1,19 CALL BYTFL4(FLUX(IICH,IPA)) CALL BYTIN2(NOBF(IICH,IPA)) ENDDO ENDDO SH = KSH*0.05 + 0.95 WRITE(2,23)KLEG,SH,KSEC 23 FORMAT(/,' LEG=',I2,' L-SHELL=',F5.2,' UT=',I7,/) WRITE(2,24) 24 FORMAT(' PITCH ANGLE FLUX OBS') DO 20 IPA=1,19 WRITE(2,25)IPA*5-5,FLUX(ICH,IPA),NOBF(ICH,IPA) 25 FORMAT(I8,E13.4,I6) 20 CONTINUE 10 CONTINUE 100 CONTINUE STOP END C SUBROUTINE BYTIN4(A) C Reverse byte order for INTEGER*4 INTEGER*4 A,IX,IY BYTE FBYTEI(4),RBYTEI(4) EQUIVALENCE (IX,FBYTEI(1)),(IY,RBYTEI(1)) IX = A DO I = 1,4 J = 5 - I RBYTEI(J) = FBYTEI(I) ENDDO A = IY RETURN END c SUBROUTINE BYTIN2(A) C Reverse byte order for INTEGER*2 INTEGER*2 A,IX,IY BYTE FBYTEI(2),RBYTEI(2) EQUIVALENCE (IX,FBYTEI(1)),(IY,RBYTEI(1)) IX = A DO I = 1,2 J = 3 - I RBYTEI(J) = FBYTEI(I) ENDDO A = IY RETURN END c SUBROUTINE BYTFL4(A) C Reverse byte order for REAL*4 REAL*4 A,X,Y BYTE FBYTEF(4),RBYTEF(4) EQUIVALENCE (X,FBYTEF(1)),(Y,RBYTEF(1)) X = A DO I = 1,4 J = 5 - I RBYTEF(J) = FBYTEF(I) ENDDO A = Y RETURN END