;+ ; ; @file_comments ; write an Oasis file (version < 2.5) ; ; @param FILENAME {in}{required} ; the filename ; ; @param VARNAME {in}{required} ; the name of the variable to be written ; ; @param Z2D {in}{required} ; the variable (2D array) to be written ; ; @keyword I2 ; @keyword I4 ; @keyword I8 ; @keyword R4 ; to change the default format (R8) of the data to be written. ; ; @keyword APPEND ; to open the file with the file pointer at the end of the file, ready for ; data to be appended. ; ; @restrictions ; varname is automatically written as a "character*8" ; by default z2d is written as an R8 array ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; July 01, 2002 ; @version ; $Id$ ; ;- ; PRO write_oasis, filename, varname, z2d, I2 = i2, I4 = i4, I8 = i8, R4 = r4, APPEND = append ; compile_opt idl2, strictarrsubs ; openw, unit, filename , /F77_UNFORMATTED, /GET_LUN, /SWAP_IF_LITTLE_ENDIAN $ , error=err, APPEND = append if err ne 0 then begin ras = report(!err_string) return endif writeu, unit, string(varname, format='(a8)') case 1 of keyword_set(i2):writeu, unit, fix(z2d) keyword_set(i4):writeu, unit, long(z2d) keyword_set(i8):writeu, unit, long64(z2d) keyword_set(r4):writeu, unit, float(z2d) ELSE:writeu, unit, double(z2d) endcase free_lun,unit return end