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

Last change on this file since 163 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

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