anchor.diff:          call check( nf90_close(ncid), filename)
       end subroutine io_write6d
       
  -    ! write a data array to a file with a given variable name
  +    !>------------------------------------------------------------
  +    !! Same as io_write6d but for 3-dimensional data
  +    !!
  +    !! Write a 3-dimensional variable to a netcdf file
  +    !!
  +    !! Create a netcdf file:filename with a variable:varname and write data_out to it
  +    !!
  +    !! @param   filename    Name of NetCDF file to write/create
  +    !! @param   varname     Name of the NetCDF variable to write
  +    !! @param   data_out    3-dimensional array to write to the file
  +    !!
  +    !!------------------------------------------------------------
       subroutine io_write3d(filename,varname,data_out)
           implicit none
           ! This is the name of the file and variable we will write. 
  
positive.code:     end subroutine io_read2di
  
  
      ! write a data array to a file with a given variable name
      subroutine io_write6d(filename,varname,data_out)
          implicit none
          ! This is the name of the file and variable we will write. 
          character(len=*), intent(in) :: filename, varname
          real,intent(in) :: data_out(:,:,:,:,:,:)
          
          ! We are reading 6D data, a nx, nz, ny, na, nb, nc grid. 
          integer :: nx,ny,nz, na,nb,nc
          integer, parameter :: ndims = 6
          ! This will be the netCDF ID for the file and data variable.
  
negative.code:         integer, parameter :: LUN_MIN=10, LUN_MAX=1000
          logical :: opened
          integer :: lun
          
          io_newunit=-1
          ! loop over all possible units until a non-open unit is found, then exit
          ! this should be re-written as a while loop instead of a do loop with an exit
          ! but it ain't broke so...
          do lun=LUN_MIN,LUN_MAX
              inquire(unit=lun,opened=opened)
              if (.not. opened) then
  