anchor.diff:          ! allocate(rev_u_LUT(n_spd_values,n_dir_values,n_nsq_values,nxu,nz,ny))
           error = write_var(filename,"uLUT",uLUT, dimnames=[character(len=4) :: "nspd","ndir","nnsq","nxu","nz","ny"], open_new_file=.True.)
           if (error/=0) then
  -            write(*,*) "Error writing LUT file:"//trim(filename)
  +            write(*,*) "Error writing LUT file:"//trim(filename)//" Error code = "//trim(str(error))
               return
           endif
           error = write_var(filename,"vLUT",vLUT, dimnames=[character(len=4) :: "nspd","ndir","nnsq","nx","nz","nyv"])
           if (error/=0) then
  -            write(*,*) "Error writing LUT file:"//trim(filename)
  -            return
  -        endif
  -        
  +            write(*,*) "Error writing LUT file:"//trim(filename)//" Error code = "//trim(str(error))
  +            return
  +        endif
  +
           call io_add_attribute(filename, "dirmax", options%dirmax)
           call io_add_attribute(filename, "spdmax", options%spdmax)
           call io_add_attribute(filename, "spdmin", options%spdmin)
  
positive.code:             ! default_value = test_value
          endif
          ! returns any error
      end function check_real_attribute
      
      function check_integer_attribute(filename, default_value, value_name) result(error)
          implicit none
          character(len=*), intent(in) :: filename
          integer, intent(in) :: default_value
  
negative.code:         character(len=*), intent(in) :: value_name
          integer :: error
          integer :: test_value
  
          ! default return value assumes no error
          error = 0
  
          call io_read_attribute(filename, value_name, test_value)
          if (abs(default_value - test_value)>1e-20) then
              error = 1
  