source: trunk/SRC/ReadWrite/writebat.pro @ 236

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

replace some print by some report in some .pro #2

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1;+
2;
3; @file_comments
4; write the bathymetry ASCII file of OPA
5;
6; @categories
7; For OPA
8;
9; @param ZBAT {in}{required}
10; the bathymetry, a 2d array
11;
12; @param FILENAME {in}{required}{type=string}
13; It contains the filename
14;
15; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
16;                      Sept 30, 2003
17;    based on batsav2.pro, written by Maurice Imbard, March 17, 1998
18;
19; @version $Id$
20;-
21;
22PRO writebat, zbat, filename
23;
24  compile_opt idl2, strictarrsubs
25;
26; basic checks
27  IF n_params() NE 2 THEN BEGIN
28    ras = report( 'bad number of arguments in the call of writebat')
29    return
30  ENDIF
31  IF size(filename, /type) NE 7 THEN BEGIN
32    ras = report( 'the filename should be a string')
33    return
34  ENDIF
35  sbat = size(zbat)
36  IF sbat[0] NE 2 THEN BEGIN
37    ras = report( 'bathymetry array should be 2d array')
38    return
39  ENDIF
40;
41  jpi2 = sbat[1]
42  jpj2 = sbat[2]
43; parameters def
44  ifreq  = 40
45  ifin   = jpi2/ifreq+1
46  irest  = jpi2-(ifin-1)*ifreq
47  zbati  = intarr(ifreq)
48  zbati2 = intarr(irest)
49  i0     = intarr(ifreq/5)
50  i1     = intarr(max([1, irest/5]))
51;
52  openw, iunit, filename, /get_lun
53;;
54;; fill the file
55;;
56  printf, iunit, FORMAT = '(1x," bathy IDL     ",2i8)', jpi2, jpj2
57  printf, iunit, FORMAT = '(/)'
58  il1 = 0
59  FOR jn = 1, ifin-1 DO BEGIN
60    printf, iunit, FORMAT = '(/)'
61    il2 = min([ jpi2-1, il1+ifreq-1] )
62    i0[0] = il1+1
63    FOR jj = 1, ifreq/5-1 DO BEGIN
64      i0[jj] = i0[jj-1]+5
65    END
66    printf, iunit, FORMAT = '(3x,13(i3,12x))', i0
67    printf, iunit, FORMAT = '(/)'
68    il3 = il2-(jn-1)*ifreq
69    iformat = string('(', il3+2, 'i3)')
70    FOR jj =  jpj2-1, 0, -1  DO BEGIN
71      zbati[0:il3] = zbat[il1:il2, jj]
72      printf, iunit, FORMAT = iformat, jj+1, zbati
73    END
74    il1 = il1 + ifreq
75  END
76  printf, iunit, FORMAT = '(/)'
77  il2 = min([ jpi2-1, il1+ifreq-1] )
78  i1[0] = il1+1
79  FOR jj = 1, irest/5-1 DO BEGIN
80    i1[jj] = i1[jj-1]+5
81  END
82  printf, iunit, FORMAT = '(3x,13(i3,12x))', i1
83  printf, iunit, FORMAT = '(/)'
84  il3 = il2-(ifin-1)*ifreq
85  iformat = string('(', il3+2, 'i3)')
86  FOR jj =  jpj2-1, 0, -1  DO BEGIN
87    zbati2[0:irest-1] = 0
88    zbati2[0:il3] = zbat[il1:il2, jj]
89    printf, iunit, FORMAT = iformat, jj+1, zbati2
90  END
91;;
92;; end
93;;
94  close, iunit
95  free_lun, iunit
96;
97  return
98end
Note: See TracBrowser for help on using the repository browser.