check_number_of_dependent_verifications <- function(recipe) {
  # Number of verifications depends on the variables and indicators requested
  # and the order of the workflow:
  # workflow: correction + indicator --> only 1 variable is calibrated
  # workflow: indicator + correction --> the indicator and the ecv are calibrated
  independent_verifications <- NULL
  dependent_verifications <- NULL
  dep <- 1
  # check workflow order:
  if (all(c('Calibration', 'Indicators') %in% names(recipe$Analysis$Workflow))) {
    cal_pos <- which(names(recipe$Analysis$Workflow) == 'Calibration')
    ind_pos <- which(names(recipe$Analysis$Workflow) == 'Indicators')
    if (cal_pos < ind_pos) {
      workflow_independent <- FALSE
    } else {
      workflow_independent <- TRUE
    }
  }
  if (workflow_independent) {
    independent_verifications <- append(recipe$Analysis$Variables$ECVs,
                                        recipe$Analysis$Variables$Indicators)
  } else { 
    if (is.null(recipe$Analysis$Variables$Indicators) || 
       (length(recipe$Analysis$Variables$Indicators) == 1 && 
        is.null(recipe$Analysis$Variables$ECVs))) {
      independent_verifications <- append(recipe$Analysis$Variables$ECVs,
                                          recipe$Analysis$Variables$Indicators)
    } else { 
      ecvs <- recipe$Analysi$Variables$ECVs
      inds <- recipe$Analysi$Variables$Indicators
      ind_table <- read_yaml(paste0(recipe$Run$code_dir,
                             "conf/indicators_table.yml"))
      # first, loop on ecvs if any and compare to indicators
      done <- NULL # to gather the indicators reviewed
      if (!is.null(ecvs)) {
        for (i in 1:length(ecvs)) {
          dependent <- list(ecvs[[i]])
          for (j in 1:length(inds)) {
            if (ind_table[inds[[j]]$name][[1]]$ECVs == ecvs[[i]]$name) {
              if (ind_table[inds[[j]]$name][[1]]$freq == ecvs[[i]]$freq) {
              # they are dependent
                dependent <- append(dependent, inds[[j]])
                done <- append(done, inds[[j]])
              }
            }
          }
          if (length(dependent) == 1) {
            dependent <- NULL
            independent_verifications <- append(independent_verifications,
                                              list(ecvs[[i]]))
          } else {
            dependent_verifications <- append(dependent_verifications,
                                              list(dependent))
          }  
        }
        # There are indicators not reviewed yet?
        if (length(done) < length(inds)) {
          if (length(inds) == 1) {
            independent_verifications <- append(independent_verifications,
                                                inds)
          } else {
            done <- NULL
            for (i in 1:(length(inds) - 1)) {
              dependent <- list(inds[[i]]$name)
              if (is.na(match(unlist(dependent), unlist(done)))) {
                for (j in (i+1):length(inds)) {
                  if (ind_table[inds[[i]]$name][[1]]$ECVs == 
                      ind_table[inds[[j]]$name][[1]]$ECVs) {
                    if (ind_table[inds[[i]]$name][[1]]$freq ==
                        ind_table[inds[[j]]$name][[1]]$freq) {
                      dependent <- append(dependent, inds[[j]]$name)
                      done <- dependent
                    }
                  }
                }
              } 
              if (length(dependent) == 1) {
                independent_verifications <- dependent
                dependent <- NULL     
              } else {
                dependent_verifications <- dependent
              }
            } 
          }
        }
      } else { # there are only Indicators:
        done <- NULL
        for (i in 1:(length(inds) - 1)) {
          dependent <- list(inds[[i]]$name)
          if (is.na(match(unlist(dependent), unlist(done)))) {
            for (j in (i+1):length(inds)) {
              if (ind_table[inds[[i]]$name][[1]]$ECVs ==
                  ind_table[inds[[j]]$name][[1]]$ECVs) {
                if (ind_table[inds[[i]]$name][[1]]$freq ==
                    ind_table[inds[[j]]$name][[1]]$freq) {
                  dependent <- append(dependent, inds[[j]]$name)
                  done <- dependent
                }
              }
            }
          }
          if (length(dependent) == 1) {
            independent_verifications <- dependent
            dependent <- NULL
          } else {
            dependent_verifications <- dependent
          }
        }
      } 
    }
  }
  if (!is.null(independent_verifications)) {   
    info(logger, paste("The variables for independent verification are ", 
         paste(independent_verifications, collapse = " ")))
  }
  if (!is.null(dependent_verifications)) {
    info(logger, paste("The variables for dependent verification are: ",
         paste(dependent_verifications, collapse = " ")))
  }
  # remove unnecessary names in objects to be removed
  return(list(independent = independent_verifications, 
              dependent = dependent_verifications))
}
#workflow <- list(Calibration = list(method = 'SBC'),
#                 Skill = list(metric = 'RPSS'))
#ApplyWorkflow <- function(workflow) {

#res <- do.call('CST_BiasCorrection',
#               args = list(exp = lonlat_data$exp,
#                           obs = lonlat_data$obs))
   



