PRO dmspb2a,infile ; This routine reads a binary file of DMSP particle data produced ; with DMSPIO.EXE on a VAX/XMS computer, and creates a formatted ; file containing the same data expressed in ASCII format. This ; is necessary to transfer the data files between VAX/VMS and Unix ; machines. ; ; Written: Fri Jul 30 09:04:20 MDT 1993 by DPS ; First define the structure of the data in the binary file. This ; structure definition follows exactly the definitions used to ; create the DMSP particle data files in binary format. LocType={loct, latitude:0.0, longitude:0.0, altitude:0.0} TimeType={tt, time:LONARR(6)} PosType={pt, geodetic:LocType, corrected:LocType, corrgeomag:LocType} CalArrType={cat, data:FLTARR(20)} HeaderType={ht, framect:0L, htime:TimeType, utsecs:0.0 $ , satpos:PosType, sdrnum:0L, olstimcod:0L} DataType={dt, spectrum:CalArrType, totnflux:0.0 $ , toteflux:0.0, avgenergy:0.0} FrameType={ft, eldata:DataType, iondata:DataType} DMSP_Rec={dr, header:HeaderType, frame:MAKE_ARRAY(4,VALUE=FrameType)} ; Then open the input and output files, for reading and writing, ; respectively. OPENR,inunit,infile,/GET_LUN dotpos=STRPOS(infile,'.DAT') outfile=STRMID(infile,0,dotpos)+'.TXT' OPENW,outunit,outfile,/GET_LUN ; Now read an instance of DMSP_Rec in binary format from 'infile', ; and write it out in ASCII format to 'outfile'. Repeat until ; 'infile' has been completely processed. nrecs=0 REPEAT BEGIN READU,inunit,DMSP_Rec nrecs=nrecs+1 PRINTF,outunit,DMSP_Rec.header.framect,FORMAT='(I5)' PRINTF,outunit,DMSP_Rec.header.htime,FORMAT='(6I5)' PRINTF,outunit,DMSP_Rec.header.utsecs,FORMAT='(F9.3)' PRINTF,outunit,DMSP_Rec.header.satpos,FORMAT='(3F11.3)' PRINTF,outunit,DMSP_Rec.header.sdrnum,DMSP_Rec.header.sdrnum $ ,FORMAT='(2I7)' FOR i=0,3 DO BEGIN PRINTF,outunit,DMSP_Rec.frame(i).eldata.spectrum $ ,FORMAT='(5G12.4)' FOR j=1,3 DO PRINTF,outunit,DMSP_Rec.frame(i).eldata.(j) $ ,FORMAT='(G12.4)' PRINTF,outunit,'' PRINTF,outunit,DMSP_Rec.frame(i).iondata.spectrum $ ,FORMAT='(5G12.4)' FOR j=1,3 DO PRINTF,outunit,DMSP_Rec.frame(i).iondata.(j) $ ,FORMAT='(G12.4)' PRINTF,outunit,'' ENDFOR PRINT,nrecs,FORMAT='(I4,$)' IF nrecs MOD 20 EQ 0 THEN PRINT,'' ENDREP UNTIL EOF(inunit) ; Now close 'infile' and 'outfile'. We're done. CLOSE,inunit & FREE_LUN,inunit CLOSE,outunit & FREE_LUN,outunit RETURN END