\name{ConfigFileSave}
\alias{ConfigFileSave}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
%%  ~~function to do ... ~~
}
\description{
%%  ~~ A concise (1-5 lines) description of what the function does. ~~
}
\usage{
ConfigFileSave(configuration, file_path)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{configuration}{
%%     ~~Describe \code{configuration} here~~
}
  \item{file_path}{
%%     ~~Describe \code{file_path} here~~
}
}
\details{
%%  ~~ If necessary, more details than the description above ~~
}
\value{
%%  ~Describe the value returned
%%  If it is a LIST, use
%%  \item{comp1 }{Description of 'comp1'}
%%  \item{comp2 }{Description of 'comp2'}
%% ...
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
%%  ~~who you are~~
}
\note{
%%  ~~further notes~~
}

%% ~Make other sections like Warning with \section{Warning }{....} ~

\seealso{
%% ~~objects to See Also as \code{\link{help}}, ~~~
}
\examples{
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (configuration, file_path) 
{
    file_conn <- file(file_path)
    file_text <- c("# s2dverification configuration file", "#", 
        "# Check ?ConfigFileOpen after loading s2dverification for detailed ", 
        "# documentation on this configuration file.", "", "#########################", 
        "!!2-dimensional variables", "#########################")
    file_text <- c(file_text, configuration$two_d_vars)
    file_text <- c(file_text, "", "#######################", 
        "!!global mean variables", "#######################")
    file_text <- c(file_text, configuration$global_mean_vars)
    table_names <- c("file_per_startdate_experiments", "file_per_member_experiments", 
        "file_per_month_observations", "file_per_member_observations", 
        "file_per_dataset_observations")
    for (table_name in table_names) {
        if (table_name \%in\% c("file_per_startdate_experiments", 
            "file_per_member_experiments")) {
            dataset_type <- "exp"
        }
        else {
            dataset_type <- "obs"
        }
        file_text <- c(file_text, "", paste(rep("#", nchar(table_name) + 
            14), collapse = ""), paste0("!!", gsub("_", " ", 
            table_name), " definitions"), paste(rep("#", nchar(table_name) + 
            14), collapse = ""))
        if (table_name == "file_per_startdate_experiments") {
            defaults <- configuration$definitions[grep("^DEFAULT_", 
                names(configuration$definitions))]
            definitions <- configuration$definitions[-grep("^DEFAULT_", 
                names(configuration$definitions))]
            file_text <- c(file_text, as.vector(paste(names(defaults), 
                unlist(defaults), sep = " = ")))
            file_text <- c(file_text, as.vector(paste(names(definitions), 
                unlist(definitions), sep = " = ")))
        }
        file_text <- c(file_text, "", paste(rep("#", nchar(table_name) + 
            11), collapse = ""), paste0("!!table of ", gsub("_", 
            " ", table_name)), paste(rep("#", nchar(table_name) + 
            11), collapse = ""), paste0("#", dataset_type, "_name, var_name[, ", 
            dataset_type, "_main_path[, ", dataset_type, "_file_path[, ", 
            ifelse(dataset_type == "exp", "grid[, ", ""), "nc_var_name[, suffix[, var_min[, var_max]]]", 
            ifelse(dataset_type == "exp", "]", ""), "]]]"))
        file_text <- c(file_text, unlist(lapply(configuration[[table_name]], 
            function(x) lapply(x, function(y) paste(unlist(y), 
                collapse = ", ")))))
    }
    writeLines(file_text, file_conn)
    close(file_conn)
  }
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ ~kwd1 }
\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
