;+ ;PROCEDURE: print_cdf_info2 ;PURPOSE: prints information about a specified cdf file ;INPUT: ; filename: The name of the file for which info is desired. ;KEYWORDS: ; printatt: ; var_detail: ; ;CREATED BY: D. Larson ;MODIFIED BY: T. Hori ;LAST MODIFICATION: @(#)print_cdf_info2.pro 1.00 09/02/09 ;- PRO print_cdf_info2,filename,printatt=printatt,var_detail=var_detail if keyword_set(filename) eq 0 then filename = dialog_pickfile() print,'File: ',filename id=cdf_open(filename) info=cdf_info(id) printdat,info,nstr=1 ;print,'dim=',info.dim Print,'VARIABLES:' print_struct,info.vars q= !quiet ;print,'number or records=',info.num_recs ;help,info,/st cdf_doc,id,v,r,c ;print,v,r,c natt_all= info.inq.natts natt_g= 0L natt_v= 0L fstidx_v= -1L endidx_v= natt_all-1L IF KEYWORD_SET(var_detail) THEN printatt=1 ;to count natt_* and *idx_v if keyword_set(printatt) then begin print,"ATTRIBUTES:" PRINT, '### Global scope ###' ; gatts = cdf_var_atts(id,attri=allatt) for a=0,info.inq.natts-1 do begin cdf_control,id,att=a,get_attr_info=ai cdf_attinq,id,a,name,scope,maxrent,maxzent scp = strmid(scope,0,1) if scp eq 'G' then begin for gentry = 0,ai.maxgentry do begin if cdf_attexists(id,a,gentry) then begin cdf_attget,id,a,gentry,value print,a,gentry,name,value,format='(i3," ",i2," ",a," --> ",a)' ; printdat,value endif endfor natt_g ++ endif if scp eq 'V' then begin IF natt_v EQ 0 THEN PRINT, '### Variable scope ###' print,a,name,ai.numrentries,ai.numzentries,format='(i3," "," "," ",a," (",i0,",",i0,")")' natt_v ++ if fstidx_v EQ -1 THEN fstidx_v = LONG(a) endif endfor endif ;Dump details of attributes of each variable IF KEYWORD_SET(var_detail) THEN BEGIN ;------------------------------ ;Set !quiet=1, otherwise CDF_ATTGET gives an warning when reading a byte value quiet_org= !quiet !quiet= 1 vt=['Rvar','Zvar'] PRINT, '' PRINT, '---------- Variable attributes ----------' FOR i=0L,info.nv-1 DO BEGIN PRINT, '###########################################################' PRINT, i, FORMAT='( "-------------------- Variable ", i3, " --------------------" )' print_struct, info.vars[i] PRINT, '' ; blank line IF info.vars[i].is_zvar THEN zvarflg=1 ELSE zvarflg=0 FOR j=fstidx_v, endidx_v DO BEGIN cdf_control,id,att=j,get_attr_info=ai cdf_attinq,id,j,name,scope,maxrent,maxzent rslt= CDF_ATTEXISTS(id,j,i, ZVAR=zvarflg) IF rslt EQ 0 THEN BEGIN PRINT, j-fstidx_v, name, ' ', $ FORMAT='( I3, ": ", A, " : ", A )' ENDIF ELSE BEGIN CDF_ATTGET, id, j, i, val, CDF_TYPE=type, ZVAR=zvarflg IF SIZE(val,/TYPE) EQ 1 THEN val= FIX(val) PRINT, j-fstidx_v, name, STRJOIN(STRING(val)), type, $ FORMAT='( I3, ": ", A, " : ", A, " (", A, ")" )' ;help, val, type tmp1=temporary(val) & tmp1=temporary(type) ; vanish them ENDELSE ENDFOR PRINT, '' ; blank line ENDFOR !quiet= quiet_org ; recover the original value ENDIF ;-------------------------------------------------------------- if 0 then begin Print,'VARIABLES:' print,format='(" mrec ","rec"," Z"," VAR NAME"," TYPE"," ELEM", " VARY"," DIMVAR")' ;help,cdf_varinq(id,0),/str for itest =0,info.nvars-1 do begin !quiet =1 cdf_control,id,var=itest,get_var_info=info !quiet = q vinq = cdf_varinq(id,itest) print,info.maxrec,format='(i5," ",$)' print,itest,vinq,format='(i3,i2,a18,a12,i5,a7,5z)' endfor for itest =0,info.nzvars-1 do begin !quiet =1 cdf_control,id,var=itest,get_var_info=info,/zvar !quiet = q vinq = cdf_varinq(id,itest, /zvariable) print,info.maxrec,format='(i5," ",$)' print,itest,vinq,format='(i3,i2,a18,a12,i5, a7, i7,i7,i7,i7)' endfor endif cdf_close,id end