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