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

Last change on this file since 269 was 238, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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