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

Last change on this file since 150 was 130, checked in by pinsard, 18 years ago

improvements of ReadWrite/?*.pro header

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