;+ ; ; @file_comments ; read the f77 unformatted files used in Oasis (version < 2.5) ; ; @categories ; Reading ; ; @param FILENAME {in}{required} ; the filename ; ; @param VARNAME {in}{required} ; the name of the variable to be read ; ; @param JPI {in}{required} ; ; @param jpj {in}{required} ; the size of the 2d array to be read ; ; @keyword I2 ; @keyword I4 ; @keyword I8 ; @keyword R4 ; to change the default format (R8) of the data to be read. ; ; @returns ; a 2d array ; ; @examples ; IDL> a=read_oasis('grids_orca_t106','a106.lon',320,160) ; IDL> m=read_oasis('masks_orca_t106','or1t.msk',182,149,/i4) ; ; see also IDL> scanoasis,'grids_orca_t106' ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; July 01, 2002 ; @version ; $Id$ ; ;- ; FUNCTION read_oasis, filename, varname, jpi, jpj, I2 = I2, I4 = i4, I8 = i8, R4 = r4 ; compile_opt idl2, strictarrsubs ; openr, unit, filename, /f77_unformatted, /get_lun, /swap_if_little_endian $ , error=err if err ne 0 then begin ras = report(!err_string) return, -1 endif char8 = '12345678' readu, unit, char8 ; print, char8 found = char8 EQ varname WHILE NOT EOF(unit) AND found NE 1 DO BEGIN readu, unit if EOF(unit) then begin ras = report(varname+' not found in '+filename) return, -1 endif readu, unit, char8 ; print, char8 found = char8 EQ varname ENDWHILE case 1 of keyword_set(i2):res = intarr(jpi, jpj) keyword_set(i4):res = lonarr(jpi, jpj) keyword_set(i8):res = lon64arr(jpi, jpj) keyword_set(r4):res = fltarr(jpi, jpj) ELSE:res = dblarr(jpi, jpj) endcase readu, unit, res free_lun,unit return, res end