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

Last change on this file since 72 was 44, checked in by pinsard, 18 years ago

upgrade of LECTURE/ReadWrite according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/ : files

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