pro RD_RHDFINE_MULTI2, filespec, nmu, nsub, data ; ;+ ; NAME: ; RD_RHDFINE_MULTI2 ; ; PURPOSE: ; Read data from FINE files written by RHD code. ; ; CATEGORY: ; Input/Output ; ; CALLING SEQUENCE: ; RD_RHDFINE_MULTI2, filespec, nmu, nsub, data ; ; INPUTS: ; filespec - file specification ; nmu - Number of mu angles in FINE file ; nsub - Number of frequency sub bins in FINE file ; ; OUTPUTS: tags in "data" structure ; itime - Array with time step numbers ; time - Array with times ; kwl - Array with Kurucz bin numbers ; clam - Array with Kurucz bin central wavelengths ; frtop - Array with radiative surface fluxes ; frbot - Array with radiative fluxes at bottom of ?? ; imunu - Array with emergent intensities ; nblock - Total number of blocks (Kurucz ODF bins) ; nstop - Total number of time steps read from file list ; ; EXAMPLE: ; RD_RHDFINE_MULTI2 ; ; MODIFICATION HISTORY: ; 07.09.11 Written by Matthias Steffen, Astrophysik, Potsdam ; 08.09.11 Output packed into IDL structure HGL/LSW, ; filespec introduced ; 15.08.13 Adapted to new fine-file format HGL/LSW ;- ; ; --- Initializiation --- filename=file_search(filespec, count=nfile) nmax = 20 ; maximum number time steps nblock = 2000 ; maximum number of frequency blocks ; line=' ' itime = lonarr(nmax) time = fltarr(nmax) kwl = lonarr(nblock, nmax) clam = fltarr(nblock, nmax) frtop = fltarr(nblock,nmax) frbot = fltarr(nblock,nmax) muval = fltarr(nsub,nblock,nmu,nmax) imunu = fltarr(nsub,nblock,nmu,nmax) dirms = fltarr(nsub,nblock,nmu,nmax) ; format000='(14X, I7, E13.5)' format001='(26X, I4, 3E13.5)' format102='( 7X, F5.3, 1X, E13.5, 4X, E13.5)' ; itimex = 0L timex = 0.0 get_lun, cunit ; ntime = -1L ; for nf=0,nfile-1 do begin ; ; --- Open file on free channel --- openr, cunit, filename(nf) print, 'Loading: ', filename(nf) ; ; --- Read line by line --- readf, cunit, line while (not EOF(cunit)) do begin tst3=strmid(line,0,3) tst5=strmid(line,0,5) if (tst5 eq 'itime') then begin ntime = ntime + 1L reads, line, format=format000, itimex, timex itime(ntime) = itimex time (ntime) = timex nblck = -1L endif if (tst3 eq 'kwl') then begin nblck = nblck + 1L reads, line, format=format001, kwlx, clamx, frbot0x, frtop0x ; print, kwlx, nblck kwl(nblck,ntime) = kwlx clam(nblck,ntime) = clamx frbot(nblck,ntime) = frbot0x frtop(nblck,ntime,0)= frtop0x readf, cunit, line readf, cunit, line readf, cunit, line for nm=0,nmu-1 do begin for nb=0,nsub-1 do begin readf, cunit, format=format102, muvalx, imunux, dirmsx muval(nb,nblck,nm,ntime)=muvalx imunu(nb,nblck,nm,ntime)=imunux dirms(nb,nblck,nm,ntime)=dirmsx endfor endfor endif readf, cunit, line endwhile ; ; --- Close channel --- close, cunit ; endfor ; ; --- Reduce array size to proper size, pack into structure --- data={itime:itime(0:ntime), time:time(0:ntime), $ kwl:kwl(0:nblck,0:ntime), clam:clam(0:nblck,0:ntime), $ frbot:frbot(0:nblck,0:ntime), frtop:frtop(0:nblck,0:ntime), $ muval:reform(muval(0,0:nblck,*,0:ntime)), $ imunu:imunu(*,0:nblck,*,0:ntime), $ dirms:dirms(*,0:nblck,*,0:ntime)} ; free_lun, cunit ; end ; RD_RHDFINE_MULTI2