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