1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; write an Oasis file (version < 2.5) |
---|
5 | ; |
---|
6 | ; @param FILENAME {in}{required} |
---|
7 | ; the filename |
---|
8 | ; |
---|
9 | ; @param VARNAME {in}{required} |
---|
10 | ; the name of the variable to be written |
---|
11 | ; |
---|
12 | ; @param Z2D {in}{required} |
---|
13 | ; the variable (2D array) to be written |
---|
14 | ; |
---|
15 | ; @keyword I2 |
---|
16 | ; @keyword I4 |
---|
17 | ; @keyword I8 |
---|
18 | ; @keyword R4 |
---|
19 | ; to change the default format (R8) of the data to be written. |
---|
20 | ; |
---|
21 | ; @keyword APPEND |
---|
22 | ; to open the file with the file pointer at the end of the file, ready for |
---|
23 | ; data to be appended. |
---|
24 | ; |
---|
25 | ; @restrictions |
---|
26 | ; varname is automatically written as a "character*8" |
---|
27 | ; by default z2d is written as an R8 array |
---|
28 | ; |
---|
29 | ; @history |
---|
30 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
31 | ; July 01, 2002 |
---|
32 | ; @version |
---|
33 | ; $Id$ |
---|
34 | ; |
---|
35 | ;- |
---|
36 | PRO write_oasis, filename, varname, z2d, I2=i2, I4=i4, I8=i8, R4=r4, APPEND=append |
---|
37 | ; |
---|
38 | compile_opt idl2, strictarrsubs |
---|
39 | ; |
---|
40 | openw, unit, filename , /F77_UNFORMATTED, /GET_LUN, /SWAP_IF_LITTLE_ENDIAN $ |
---|
41 | , error=err, APPEND = append |
---|
42 | if err ne 0 then begin |
---|
43 | ras = report(!err_string) |
---|
44 | return |
---|
45 | endif |
---|
46 | |
---|
47 | writeu, unit, string(varname, format='(a8)') |
---|
48 | case 1 of |
---|
49 | keyword_set(i2):writeu, unit, fix(z2d) |
---|
50 | keyword_set(i4):writeu, unit, long(z2d) |
---|
51 | keyword_set(i8):writeu, unit, long64(z2d) |
---|
52 | keyword_set(r4):writeu, unit, float(z2d) |
---|
53 | ELSE:writeu, unit, double(z2d) |
---|
54 | endcase |
---|
55 | |
---|
56 | free_lun,unit |
---|
57 | return |
---|
58 | end |
---|