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

Last change on this file since 232 was 232, 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 a 2d array
15;
16; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
17;                      May 31, 2002
18;    based on batlec2.pro, written by Maurice Imbard, March 17, 1998
19;
20; @version $Id$
21;
22;-
23;
24FUNCTION readbat, filename, ZERO = zero
25;
26  compile_opt idl2, strictarrsubs
27;
28
29   ;;
30   ;; lecture de la bathymetrie
31   ;;
32   iname_file = findfile(filename)
33   if iname_file[0] EQ '' then begin
34      print, 'Bad file name'
35      return, -1
36   ENDIF ELSE iname_file = iname_file[0]
37   openr, iunit, iname_file, /get_lun
38;   readf, iunit, FORMAT = '(16x,2i8)', iim, ijm
39;   iim = long(iim)
40;   ijm = long(ijm)
41   tmp = ''
42   readf, iunit, tmp
43   tmp = strsplit(tmp,' ',/extract)
44   iim = long(tmp[n_elements(tmp)-2])
45   ijm = long(tmp[n_elements(tmp)-1])
46; print, iim, ijm
47   ifreq = 40L
48   ifin  = iim/ifreq+1
49   irest = iim-(ifin-1)*ifreq
50; print, ifin,irest,ifreq
51   zbati  = intarr(ifreq)
52   zbati2 = intarr(irest)
53   zbat    = intarr(iim,ijm)
54;
55   readf, iunit, FORMAT = '(/)'
56   readf, iunit, FORMAT = '(/)'
57   il1 = 0
58   FOR jn = 1, ifin-1 DO BEGIN
59      readf, iunit, FORMAT = '(/)'
60      readf, iunit, FORMAT = '(/)'
61      il2 = min([ iim-1, il1+ifreq-1] )
62      readf, iunit, FORMAT = '(/)'
63      readf, iunit, FORMAT = '(/)'
64      readf, iunit, FORMAT = '(/)'
65      il3 = il2-(jn-1)*ifreq
66      iformat = string('(', il3+2, 'i3)')
67;    print,jn,il1,il2,il3,ifreq-1
68      FOR jj =  ijm-1, 0, -1  DO BEGIN
69         readf, iunit, FORMAT = iformat, ij, zbati
70         zbat[il1:il2, jj] = zbati
71      ENDFOR
72      il1 = il1 + ifreq
73   ENDFOR
74   readf, iunit, FORMAT = '(/)'
75   readf, iunit, FORMAT = '(/)'
76   il2 = min([ iim-1, il1+ifreq-1] )
77   readf, iunit, FORMAT = '(/)'
78   readf, iunit, FORMAT = '(/)'
79   readf, iunit, FORMAT = '(/)'
80   il3 = il2-(ifin-1)*ifreq
81   iformat = string('(', il3+2, 'i3)')
82;    print, irest-1,il1,il2,il3
83   FOR jj =  ijm-1, 0, -1  DO BEGIN
84      readf, iunit, FORMAT = iformat, ij, zbati2
85      zbat[il1:il2, jj] = zbati2
86   ENDFOR
87   close, iunit
88   free_lun, iunit
89   ;;
90   if keyword_set(zero) then zbat = 0 > zbat
91   return, zbat
92end
Note: See TracBrowser for help on using the repository browser.