;+ ; NAME: ; DMSPCNVT ; PURPOSE: ; Convert a file of DMSP SSJ/4 data copied from PL (in fixed 512-byte ; records) to fixed 5280-byte records. ; CATEGORY: ; DMSP processing ; CALLING SEQUENCE: ; DMSPCNVT, NAME [, /TEST] ; INPUTS: ; NAME: The name of the SSJ/4 file to be processed. ; OPTIONAL INPUTS: ; None. ; KEYWORD PARAMETERS: ; /TEST: Set if you wish to process a small portion of the file and ; inspect the results. ; OUTPUTS: ; None. ; OPTIONAL OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; The file NAME is opened and read. A file called TMP.DAT is created to ; hold the data, organized in variable length records. This file is ; renamed NAME (with an incremented generation number). Another file ; TMP.DAT (empty but with the correct file structure) is created, and ; the VAX/VMS CONVERT utility is called to copy NAME to TMP.DAT with ; fixed 5280-byte records. Finally TMP.DAT is renamed NAME, and the ; older generations of NAME are purged. ; RESTRICTIONS: ; File NAME must exist and have fixed-length 512-byte record structure. ; PROCEDURE: ; File name is read into memory in segments of 165 512-byte records. ; Then 16 5280-byte records are written to TMP.DAT. The process is ; repeated as long as there is more data in NAME, and any records that ; are not all zero are written to TMP.DAT. Then the command procedure ; DMSPCNVT.COM is SPAWNed to complete the process. ; EXAMPLE: ; ; SEE ALSO: ; DMSPCNVT.COM, DMSPCOPY.PRO, DMSPOLAR.PRO ; MODIFICATION HISTORY: ; Written by: DPS, ISR, 950519 ;- PRO dmspcnvt,name,test=test OPENR,ilun,name,/GET_LUN stat=FSTAT(ilun) nbytes=stat.SIZE nrec=nbytes/5280 & PRINT,'nrec=',nrec nblock=nbytes/512 & PRINT,'nblock=',nblock OPENW,olun,'tmp.dat',/GET_LUN block=BYTARR(512) record=BYTARR(5280) nblocki=0L nreco=0L ON_IOERROR,continue ncycles=(nrec+15)/16 ; ensures last records get processed IF KEYWORD_SET(test) THEN ncycles=1 FOR i=0,ncycles-1 DO BEGIN store=REPLICATE(0B,16L*5280) FOR j=0,164 DO BEGIN IF j EQ 165 THEN STOP IF EOF(ilun) THEN block=REPLICATE(0B,512) ELSE BEGIN READU,ilun,block nblocki=nblocki+1 ENDELSE CONTINUE: IF j EQ 165 THEN STOP store(512L*j)=block ENDFOR FOR k=0,15 DO BEGIN ptr=5280L*k record=store(ptr:ptr+5280-1) IF MAX(record) GT 0 THEN BEGIN WRITEU,olun,record nreco=nreco+1 ENDIF ENDFOR PRINT,FORMAT='("#",$)' IF ((i+1) MOD 80) EQ 0 THEN PRINT,FORMAT='()' ENDFOR PRINT,FORMAT='()' FREE_LUN,ilun FREE_LUN,olun PRINT,'nblocki=',nblocki PRINT,'nreco=',nreco PRINT,'SPAWNing DMSPCNVT.COM to finish the process' SPAWN,'@dmspcnvt '+name RETURN END