source: trunk/SRC/ReadWrite/writebat.pro

Last change on this file was 325, checked in by pinsard, 16 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

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