RMS <- function(ens, obs, limits = NULL, siglev = 0.95, conf = TRUE) {       

  
  #
  #  RMS & its confidence interval computation
  # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  #
  if (conf) {
    
    conf_low <- (1 - siglev) / 2
    conf_high <- 1 - conf_low
  }

     dif <- rowMeans(ens) - obs
     enlrms <- mean(dif ** 2, na.rm = TRUE) ** 0.5
      if (conf) {
        eno <- Eno(dif, 1)
        
                        ndat <- length(sort(dif))
                        conf.int <- c((eno * enlrms ** 2 / qchisq(conf_high, eno - 1)) ** 0.5,
                        (eno * enlrms ** 2 / qchisq(conf_low, eno - 1)) ** 0.5)
                        names(conf.int) <- c("conf_low","conf_high")
      } else {
        conf.int <- c()
        names(conf.int) <- c() }

 results <- c(enlrms,conf.int) 
 names(results) <- c("rms",names(conf.int))
 return(results)
  
}
