source: trunk/SRC/ReadWrite/readbat.pro @ 272

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

improvements/corrections of some *.pro headers

  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1;+
2;
3; @file_comments
4; reading the bathymetry ASCII file of OPA
5;
6; @categories
7; For OPA
8;
9; @param FILENAME {in}{required}{type=string}
10; It contains the filename,
11;
12; @keyword ZERO to put 0 on land instead of negatives values for the islands.
13;
14; @returns
15; a 2d array
16;
17; @history
18; Sebastien Masson (smasson\@lodyc.jussieu.fr)
19;                      May 31, 2002
20;    based on batlec2.pro, written by Maurice Imbard, March 17, 1998
21;
22; @version
23;  $Id$
24;
25;-
26;
27FUNCTION readbat, filename, ZERO = zero
28;
29  compile_opt idl2, strictarrsubs
30;
31
32   ;;
33   ;; lecture de la bathymetrie
34   ;;
35   iname_file = findfile(filename)
36   if iname_file[0] EQ '' then begin
37      ras = report( 'Bad file name')
38      return, -1
39   ENDIF ELSE iname_file = iname_file[0]
40   openr, iunit, iname_file, /get_lun
41;   readf, iunit, FORMAT = '(16x,2i8)', iim, ijm
42;   iim = long(iim)
43;   ijm = long(ijm)
44   tmp = ''
45   readf, iunit, tmp
46   tmp = strsplit(tmp,' ',/extract)
47   iim = long(tmp[n_elements(tmp)-2])
48   ijm = long(tmp[n_elements(tmp)-1])
49; print, iim, ijm
50   ifreq = 40L
51   ifin  = iim/ifreq+1
52   irest = iim-(ifin-1)*ifreq
53; print, ifin,irest,ifreq
54   zbati  = intarr(ifreq)
55   zbati2 = intarr(irest)
56   zbat    = intarr(iim,ijm)
57;
58   readf, iunit, FORMAT = '(/)'
59   readf, iunit, FORMAT = '(/)'
60   il1 = 0
61   FOR jn = 1, ifin-1 DO BEGIN
62      readf, iunit, FORMAT = '(/)'
63      readf, iunit, FORMAT = '(/)'
64      il2 = min([ iim-1, il1+ifreq-1] )
65      readf, iunit, FORMAT = '(/)'
66      readf, iunit, FORMAT = '(/)'
67      readf, iunit, FORMAT = '(/)'
68      il3 = il2-(jn-1)*ifreq
69      iformat = string('(', il3+2, 'i3)')
70;    print,jn,il1,il2,il3,ifreq-1
71      FOR jj =  ijm-1, 0, -1  DO BEGIN
72         readf, iunit, FORMAT = iformat, ij, zbati
73         zbat[il1:il2, jj] = zbati
74      ENDFOR
75      il1 = il1 + ifreq
76   ENDFOR
77   readf, iunit, FORMAT = '(/)'
78   readf, iunit, FORMAT = '(/)'
79   il2 = min([ iim-1, il1+ifreq-1] )
80   readf, iunit, FORMAT = '(/)'
81   readf, iunit, FORMAT = '(/)'
82   readf, iunit, FORMAT = '(/)'
83   il3 = il2-(ifin-1)*ifreq
84   iformat = string('(', il3+2, 'i3)')
85;    print, irest-1,il1,il2,il3
86   FOR jj =  ijm-1, 0, -1  DO BEGIN
87      readf, iunit, FORMAT = iformat, ij, zbati2
88      zbat[il1:il2, jj] = zbati2
89   ENDFOR
90   close, iunit
91   free_lun, iunit
92   ;;
93   if keyword_set(zero) then zbat = 0 > zbat
94   return, zbat
95end
Note: See TracBrowser for help on using the repository browser.