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