; NAME : readm ; PURPOSE : ; read magnetogram file ; CATEGORY : ; solar magnetic field computation package (MAGPACK2) ; CALLING SEQUENCE : ; readm, mparam, rdata, filename=magfile ; INPUTS : ; none ; OPTIONAL INPUT PARAMETERS : ; none ; KEYWORD PARAMETERS : ; filename = magnetogram file name ; if filename is not specified, it should be typed in from keyboard ; list : if specified, parameter values in the header are printed ; OUTPUTS : ; mparam, rdata ; COMMON BLOCKS : none ; SIDE EFFECTS : none ; RESTRICTIONS : none ; PROCEDURE : ; ; MODIFICATION HISTORY : ; T.Sakurai, 1992 ; ;------------------------------------------------------------------------ ; pro readm, mparam, rdata, filename=filename, list=list if keyword_set(filename) then begin magfile = filename endif else begin magfile = ' ' read,'(proc.readm) enter input file name > ',magfile endelse openr, unitm, magfile, /get_lun readmh1, unitm, mparam specs = defspecs(nspec) if keyword_set(list) then begin print,'parameters in ',magfile printmp, mparam endif point_lun,unitm,320 mhdr2 = defmh2( ) nx = mparam.nx ny = mparam.ny nbytem = mparam.nbytem maxdim = 8 rdata = fltarr(nx,ny,maxdim) k = 0 while (not eof(unitm)) do begin readu,unitm, mhdr2 spec=mhdr2.spec factor=float(mhdr2.factor) if ( abs(nbytem) eq 2) then a=intarr(nx,ny) if ( abs(nbytem) eq 4) then a=lonarr(nx,ny) readu, unitm, a if ( nbytem lt 0 ) then byteorder,a nlast = (nbytem*nx*ny) mod 80 if ( nlast ne 0 and not eof(unitm) ) then begin skipstr = replicate(' ', 80 - nlast ) readu,unitm,skipstr end for i=0, nspec-1 do begin if strupcase(strtrim(spec)) eq specs(i) then begin if k eq maxdim then begin print, 'no space left in rdata, ', $ specs(i),' ignored' goto, escape endif rdata(*,*,k) = factor*a mparam.status.(i) = k mparam.factors.(i) = factor if keyword_set(list) then $ print, k, '-th record is ', specs(i),', factor=',factor k = k+1 goto, escape endif endfor print,k,'-th record: invalid spec ',spec escape: endwhile free_lun, unitm end