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

Last change on this file since 325 was 325, checked in by pinsard, 16 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • 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;-
26FUNCTION readbat, filename, ZERO = zero
27;
28  compile_opt idl2, strictarrsubs
29;
30
31   ;;
32   ;; lecture de la bathymetrie
33   ;;
34   iname_file = findfile(filename)
35   if iname_file[0] EQ '' then begin
36      ras = report( 'Bad file name')
37      return, -1
38   ENDIF ELSE iname_file = iname_file[0]
39   openr, iunit, iname_file, /get_lun
40;   readf, iunit, FORMAT = '(16x,2i8)', iim, ijm
41;   iim = long(iim)
42;   ijm = long(ijm)
43   tmp = ''
44   readf, iunit, tmp
45   tmp = strsplit(tmp,' ',/extract)
46   iim = long(tmp[n_elements(tmp)-2])
47   ijm = long(tmp[n_elements(tmp)-1])
48; print, iim, ijm
49   ifreq = 40L
50   ifin  = iim/ifreq+1
51   irest = iim-(ifin-1)*ifreq
52; print, ifin,irest,ifreq
53   zbati  = intarr(ifreq)
54   zbati2 = intarr(irest)
55   zbat    = intarr(iim,ijm)
56;
57   readf, iunit, FORMAT = '(/)'
58   readf, iunit, FORMAT = '(/)'
59   il1 = 0
60   FOR jn = 1, ifin-1 DO BEGIN
61      readf, iunit, FORMAT = '(/)'
62      readf, iunit, FORMAT = '(/)'
63      il2 = min([ iim-1, il1+ifreq-1] )
64      readf, iunit, FORMAT = '(/)'
65      readf, iunit, FORMAT = '(/)'
66      readf, iunit, FORMAT = '(/)'
67      il3 = il2-(jn-1)*ifreq
68      iformat = string('(', il3+2, 'i3)')
69;    print,jn,il1,il2,il3,ifreq-1
70      FOR jj =  ijm-1, 0, -1  DO BEGIN
71         readf, iunit, FORMAT = iformat, ij, zbati
72         zbat[il1:il2, jj] = zbati
73      ENDFOR
74      il1 = il1 + ifreq
75   ENDFOR
76   readf, iunit, FORMAT = '(/)'
77   readf, iunit, FORMAT = '(/)'
78   il2 = min([ iim-1, il1+ifreq-1] )
79   readf, iunit, FORMAT = '(/)'
80   readf, iunit, FORMAT = '(/)'
81   readf, iunit, FORMAT = '(/)'
82   il3 = il2-(ifin-1)*ifreq
83   iformat = string('(', il3+2, 'i3)')
84;    print, irest-1,il1,il2,il3
85   FOR jj =  ijm-1, 0, -1  DO BEGIN
86      readf, iunit, FORMAT = iformat, ij, zbati2
87      zbat[il1:il2, jj] = zbati2
88   ENDFOR
89   close, iunit
90   free_lun, iunit
91   ;;
92   if keyword_set(zero) then zbat = 0 > zbat
93   return, zbat
94end
Note: See TracBrowser for help on using the repository browser.