Hi,
I am a new IDL user. For the purposes of my work I need to read a large number of binary files in a loop and then save them as ascii files. I was hoping you could help me with that. The program that I am using can only read one file at a time 'fpname' and then spit out 4 output variables on the screen: swdnsrf,lwdnsrf,swupsrf,lwupsrf.
To execute the code I run the command: read_fluxes, './app_n025_2011350_1400.SurfFluxes',swdnsrf, lwdnsrf, swupsrf, lwupsrf
where '
app_n025_2011350_1400.SurfFluxes' is the file that I am trying to read, and
swdnsrf, lwdnsrf, swupsrf, lwupsrf are the variables coming from that file.
Now, I need to modify the code so it would read the whole cluster of files for other time steps "j", where
j goes from 001,350
app_n025_2011"j"_1400.SurfFluxes
Could you please look at my program below that works for reading one file and writing
4 variables on the screen and suggest how it needs to be modified to output ascii files and read many files in a do loop? Thanks
pro read_fluxes, fpname, swdnsrf,lwdnsrf,swupsrf,lwupsrf
; Input:
; fpname: Input file full path name, string, e.g. 'app_n025_2011161_1400.SurfFluxes'.
;
; Output:
; swdnsrf: Downwelling shortwave radiation at the surface (W/m^2)
; lwdnsrf: Downwelling longwave radiation at the surface (W/m^2)
; swupsrf: Upwelling shortwave radiation at the surface (W/m^2)
; lwupsrf: Upwelling longwave radiation at the surface (W/m^2)
;
openr, uin, fpname, /get_lun
ncols= fix(0)
nrows=fix(0)
readu,uin,ncols, nrows
swdnsrf = fltarr(ncols,nrows)
lwdnsrf = fltarr(ncols,nrows)
swupsrf = fltarr(ncols,nrows)
lwupsrf = fltarr(ncols,nrows)
readu,uin,swdnsrf
readu,uin,lwdnsrf
readu,uin,swupsrf
readu,uin,lwupsrf
close,uin & free_lun,uin
end
|