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

Last change on this file since 121 was 114, checked in by smasson, 18 years ago

new compilation options (compile_opt idl2, strictarrsubs) in each routine

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