;******************************************************************** ;NAME : nkrsave (procedure) ;FUNCTION : save header and image as norikura formatted file ; K.I. '91/10/31 ; K.I. '93/08/31 ;==================================================================== pro nkrsave,file,h0,img,append=append,nocheck=nocheck,giveup=giveup,hdmod=hdmod ; file -- filename ; h0 -- header structure ; img -- image array ; /append -- append ; /nocheck -- skip check of file existence ; giveup -- return the result. 0.ok 1.writing error ; hdmod -- check h.nx, h.ny, h.nbyt consistence with img array on_ioerror,errhndl rep=10 count=1 giveup=0 h=h0 if(keyword_set(hdmod)) then begin s=size(img) h.nx=fix(s(1)) h.ny=fix(s(2)) case s(0) of 2: begin h.nf=1 h.nbyt=fix(s(3)) end 3: begin h.nf=s(3) h.nbyt=fix(s(4)) end endcase endif ff=findfile(file) if (ff(0) ne '') and (not keyword_set(append)) then begin if keyword_set(nocheck) then begin spawn,'rm '+file endif else begin ok='' print,format='("nkrsave: ",A," exists, overwrite ok (y/n) ? ",$)',file read,ok if ok eq 'n' then return endelse endif get_lun,unit if (keyword_set(append)) then openw,unit,file,error=err,/append $ else openw,unit,file,error=err ff=fstat(unit) ; file status structure lab1: writenh,unit,h writeu,unit,img close,unit free_lun,unit return errhndl: count=count+1 if(count le rep) then begin print,'!! write error in [nkrsave]. trying again...' point_lun,unit,ff.cur_ptr goto,lab1 endif else begin print,'give up ',file,' !!' giveup=1 close,unit free_lun,unit return endelse end