;******************************************************************** ; ; idl_binary ; ; IDL routine to convert formatted line-by-line data to binary form ; ; Read in data in GLA 'fm93' format --- all files from dir ../data ; Write data into IDL binary format --- creating files dir ../idl ; ; reads parameters nlyrs, nlvls, and nbnds from each data file ; ; TIPS: (1) first setenv DISPLAY machine_IP_number:0 ; (2) enter IDL ; (3) type .rnew idl_binary ; (4) type .rnew idl_plot ; ; Bill Ridgway, Applied Research Corporation & ; NASA Goddard Laboratory for Atmospheres ; Email: ridgway@climate.gsfc.nasa.gov ; Phone: (301) 286-9138 ; ; V1.0 New routine designed to convert all fm93 files to binary ; Using modified design of IDL binary file ; Created directory structure convention for file names ; May 26, 1993 ; ;******************************************************************** spawn,'ls -1 ../data',filelist nfiles = n_elements(filelist) for j=0,nfiles-1 do begin inname='../data/'+filelist(j) outname='../idl_data/'+filelist(j) ; Read in line-by-line data in GLA 'fm93' format and ; write as IDL binary ; reads nlyrs, nlvls, and nbnds from datafile ; Open input file openr, 11, inname ; Open output file openw, 12, outname ; read initial header, extract key variables text = strarr(1) for i= 1,13 do readf, 11, text ; 13 lines of header readf, 11, text & nsav = strmid(text,30,10) & nlyrs = fix(nsav(0)) readf, 11, text & nsav = strmid(text,30,10) & nlvls = fix(nsav(0)) readf, 11, text & nsav = strmid(text,30,10) & nbnds = fix(nsav(0)) readf, 11, text & nsav = strmid(text,30,10) & psfc = float(nsav(0)) readf, 11, text & nsav = strmid(text,30,10) & tsfc = float(nsav(0)) readf, 11, text & nsav = strmid(text,30,10) & ptrp = float(nsav(0)) for i=20,29 do readf, 11, text ; 12 lines of unneed variables readf, 11, text & nsav = strmid(text,30,10) & vfrst = float(nsav(0)) readf, 11, text & nsav = strmid(text,30,10) & vlast = float(nsav(0)) readf, 11, text & nsav = strmid(text,30,10) & fusfc = float(nsav(0)) readf, 11, text & nsav = strmid(text,30,10) & fdsfc = float(nsav(0)) readf, 11, text & nsav = strmid(text,30,10) & futrp = float(nsav(0)) readf, 11, text & nsav = strmid(text,30,10) & fdtrp = float(nsav(0)) readf, 11, text & nsav = strmid(text,30,10) & futoa = float(nsav(0)) data1 = fltarr(6,nlyrs) data2 = fltarr(5,nlvls) for i= 1, 2 do readf, 11, text ; skip profile data header readf, 11, data1 for i= 1, 2 do readf, 11, text ; skip profile data header readf, 11, data2 ; print key variables print,'...................................' print,'..... Data conversion for file : ',inname print,'...................................' print,'..... nlyrs =',nlyrs print,'..... nlvls =',nlvls print,'..... nbnds =',nbnds print,'..... psfc =',psfc print,'..... tsfc =',tsfc print,'..... ptrp =',ptrp print,'...................................' print,'..... vfrst =',vfrst print,'..... vlast =',vlast print,'..... fusfc =',fusfc print,'..... fdsfc =',fdsfc print,'..... futrp =',futrp print,'..... fdtrp =',fdtrp print,'..... futoa =',futoa print,'...................................' ; write header for binary IDL file writeu, 12, nlyrs, nlvls, nbnds, psfc, tsfc, ptrp writeu, 12, vfrst,vlast,fusfc,fdsfc,futrp,fdtrp,futoa writeu, 12, data1 writeu, 12, data2 ; read and output spectral band data fup = fltarr(nlvls) fdn = fltarr(nlvls) fnt = fltarr(nlvls) htr = fltarr(nlyrs) for i=0,nbnds-1 do begin readf, 11, vfrst, vlast readf, 11, fusfc,fdsfc,futrp,fdtrp,futoa readf, 11, format='(5e15.6)', fup readf, 11, format='(5e15.6)', fdn readf, 11, format='(5e15.6)', fnt readf, 11, format='(5e15.6)', htr writeu, 12, vfrst,vlast,fusfc,fdsfc,futrp,fdtrp,futoa writeu, 12, fup writeu, 12, fdn writeu, 12, fnt writeu, 12, htr endfor print,'..... Data conversion complete : ',outname print,'...................................' print,' ' print,' ' print,' ' close,11,12 endfor end