source: trunk/SRC/ReadWrite/read_oasis.pro @ 269

Last change on this file since 269 was 238, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

  • Property svn:keywords set to Id
File size: 1.7 KB
RevLine 
[44]1;+
[232]2;
[130]3; @file_comments
[136]4; read the f77 unformatted files used in Oasis (version < 2.5)
[44]5;
[157]6; @categories
7; Reading
[44]8;
[238]9; @param FILENAME {in}{required}
[136]10; the filename
[44]11;
[238]12; @param VARNAME {in}{required}
[136]13; the name of the variable to be read
[130]14;
[163]15; @param JPI {in}{required}
[130]16;
17; @param jpj {in}{required}
18; the size of the 2d array to be read
19;
20; @keyword I2
21; @keyword I4
22; @keyword I8
23; @keyword R4
[121]24; to change the default format (R8) of the data to be read.
[44]25;
[238]26; @returns
27; a 2d array
[44]28;
[106]29; @examples
[44]30; IDL> a=read_oasis('grids_orca_t106','a106.lon',320,160)
31; IDL> m=read_oasis('masks_orca_t106','or1t.msk',182,149,/i4)
32;
33; see also IDL> scanoasis,'grids_orca_t106'
34;
[238]35; @history
36; Sebastien Masson (smasson\@lodyc.jussieu.fr)
[44]37;                      July 01, 2002
[238]38; @version
39; $Id$
40;
[44]41;-
[231]42;
[107]43FUNCTION read_oasis, filename, varname, jpi, jpj, I2 = I2, I4 = i4, I8 = i8, R4 = r4
[114]44;
45  compile_opt idl2, strictarrsubs
46;
[44]47
48   openr, unit, filename, /f77_unformatted, /get_lun, /swap_if_little_endian $
49    , error=err
50   if err ne 0 then begin
[236]51      ras = report(!err_string)
[44]52      return, -1
53   endif
54
55   char8 = '12345678'
56   readu, unit, char8
57;   print, char8
58   found = char8 EQ varname
59
60   WHILE NOT EOF(unit) AND found NE 1 DO BEGIN
61      readu, unit
62      if EOF(unit) then begin
[236]63         ras = report(varname+' not found in '+filename)
[44]64         return, -1
65      endif
66      readu, unit, char8
67;      print, char8
68      found = char8 EQ varname
69   ENDWHILE
70   case 1 of
71      keyword_set(i2):res = intarr(jpi, jpj)
72      keyword_set(i4):res = lonarr(jpi, jpj)
73      keyword_set(i8):res = lon64arr(jpi, jpj)
74      keyword_set(r4):res = fltarr(jpi, jpj)
75      ELSE:res = dblarr(jpi, jpj)
76   endcase
[130]77
[44]78   readu, unit, res
[130]79
[44]80   free_lun,unit
81
82   return, res
83end
Note: See TracBrowser for help on using the repository browser.