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

Last change on this file since 107 was 106, checked in by pinsard, 18 years ago

start to modify headers of ReadWrite? *.pro files for better idldoc output

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