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