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

Last change on this file since 238 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
RevLine 
[44]1;+
2;
[130]3; @file_comments
4; write the bathymetry ASCII file of OPA
[44]5;
[238]6; @categories
[157]7; For OPA
[44]8;
[238]9; @param ZBAT {in}{required}
[136]10; the bathymetry, a 2d array
[44]11;
[163]12; @param FILENAME {in}{required}{type=string}
13; It contains the filename
[136]14;
[238]15; @history
16;  Sebastien Masson (smasson\@lodyc.jussieu.fr)
[44]17;                      Sept 30, 2003
18;    based on batsav2.pro, written by Maurice Imbard, March 17, 1998
[130]19;
[238]20; @version
21; $Id$
22;
[44]23;-
[231]24;
[44]25PRO writebat, zbat, filename
[114]26;
27  compile_opt idl2, strictarrsubs
28;
[44]29; basic checks
30  IF n_params() NE 2 THEN BEGIN
[236]31    ras = report( 'bad number of arguments in the call of writebat')
[44]32    return
33  ENDIF
34  IF size(filename, /type) NE 7 THEN BEGIN
[236]35    ras = report( 'the filename should be a string')
[44]36    return
37  ENDIF
38  sbat = size(zbat)
39  IF sbat[0] NE 2 THEN BEGIN
[236]40    ras = report( 'bathymetry array should be 2d array')
[44]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
[114]74      zbati[0:il3] = zbat[il1:il2, jj]
[44]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
[114]90    zbati2[0:irest-1] = 0
91    zbati2[0:il3] = zbat[il1:il2, jj]
[44]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.