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

Last change on this file since 150 was 136, checked in by pinsard, 18 years ago

some improvements and corrections in some .pro file according to
aspell and idldoc log file

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