NCL Home> Application examples> File IO || Data files for examples

Output binary data

    fbinrecwrite : multiple unformatted sequential records

    fbindirwrite : specified direct record

    fbinwrite    : single unformatted sequential record

    cbinwrite    : mimics a C block IO write
    
    begin 
    ; read in a netCDF variable and output to binary
      fi   = addfile ("./01-11.nc", "r") 
      t    = fi->T                        ; read in netCDF variable

      file_out = "example.bin"            ; the "bin" extension is arbitrary
      system ("/usr/bin/rm " + file_out)  ; remove any previously exist file
    ;************************************************************
    ; note the -1 indicates to just add on to the end of the file
    ; the (/.../) syntax means output the values only with no meta
    ; data
    ;************************************************************
      fbinrecwrite (file_out,-1, (/ fi->lat /))     
      fbinrecwrite (file_out,-1, (/ fi->lon /))
      fbinrecwrite (file_out,-1, (/ t(0,:,1,:) /))  ; output subsection 
    end