anchor.diff:          end do
           deallocate(time_data)
       end function io_nearest_time_step
  -        
  -
  -    ! Read the dimensions of a variable in a given netcdf file
  -    ! return a rank 1 array N=ndims+1, dims[1]=ndims, dims[i+1]=length of dimension i for a given variable
  +    
  +
  +    !>------------------------------------------------------------
  +    !! Read the dimensions of a variable in a given netcdf file
  +    !!
  +    !! @param   filename    Name of NetCDF file to look at
  +    !! @param   varname     Name of the NetCDF variable to find the dimensions of
  +    !! @param[out] dims     Allocated array to store output
  +    !! @retval dims(:) dims[1]=ndims, dims[i+1]=length of dimension i for a given variable
  +    !!
  +    !!------------------------------------------------------------
       subroutine io_getdims(filename,varname,dims)
           implicit none
           character(len=*), intent(in) :: filename,varname
           integer,intent(out) :: dims(:)
           
  -        integer :: ncid, varid,numDims,dimlen,i
  +        ! internal variables
  +        integer :: ncidvarid,numDims,dimlen,i
           integer,dimension(io_maxDims) :: dimIds
           
  -!       open the netcdf file
  +        ! open the netcdf file
           call check(nf90_open(filename, NF90_NOWRITE, ncid),filename)
  -        ! Get the varid of the data_in variable, based on its name.
  +        ! Get the varid of the variable, based on its name.
           call check(nf90_inq_varid(ncid, varname, varid),varname)
  +        ! find the number of dimensions
           call check(nf90_inquire_variable(ncid, varid, ndims = numDims),varname)
  +        ! find the dimension IDs
           call check(nf90_inquire_variable(ncid, varid, dimids = dimIds(:numDims)),varname)
           dims(1)=numDims
  +        ! finally, find the length of each dimension
           do i=1,numDims
               call check(nf90_inquire_dimension(ncid, dimIds(i), len = dimlen))
               dims(i+1)=dimlen
  
positive.code:         call check( nf90_close(ncid), filename)
      end subroutine io_write6d
      
      ! write a data array to a file with a given variable name
      subroutine io_write3d(filename,varname,data_out)
          implicit none
          ! This is the name of the file and variable we will write. 
  
negative.code:         
      end subroutine io_read6d
  
      !>------------------------------------------------------------
      !! Same as io_read6d but for 3-dimensional data
      !!
      !! Reads in a variable from a netcdf file, allocating memory in data_in for it.  
      !!
      !! if extradim is provided specifies this index for any extra dimensions (dims>3)
      !!   e.g. we may only want one time slice from a 3d variable
      !!
      !! @param   filename    Name of NetCDF file to look at
      !! @param   varname     Name of the NetCDF variable to read
      !! @param[out] data_in     Allocatable 3-dimensional array to store output
      !! @param   extradim    OPTIONAL: specify the position to read for any extra (e.g. time) dimension
      !! @retval data_in     Allocated 3-dimensional array with the netCDF data
      !!
      !!------------------------------------------------------------
      subroutine io_read3d(filename,varname,data_in,extradim)
          implicit none
          ! This is the name of the data_in file and variable we will read. 
  