##### ##### NMST440: Advanced Aspects of the R Environment ##### ##### --------------------------------------------------------------------- ##### ##### Write (many) scripts to start (many) simulations of a cluster ##### ##### --------------------------------------------------------------------- ##### ##### Arnošt Komárek ##### https://www2.karlin.mff.cuni.cz/~komarek ##### komarek@karlin.mff.cuni.cz ##### ##### ====================================================================== ROOT <- "/home/komarek/teach/mff_2021/nmst440_AdvRko/Tutorial10" CLSDIR <- paste(ROOT, "/ClScripts/", sep = "") ### Definitions of scenarios ### +++++++++++++++++++++++++++ nsplit <- 4 ### number of splits M <- 25000 ### Monte Carlo size in each split n <- c(100, 250, 500) ### sample sizes beta0 <- 0 ### intercept beta1 <- 1 ### slope sigma.x <- c(0.1, 0.2) ### std. deviation for covariate sigma.eps <- c(0.1, 0.2) ### std. deviation for the error term ### In total, we will have 3 * 2 * 2 = 12 scenarios ### Write bash scripts ### ++++++++++++++++++ ### Master script to start them all sink(paste(ROOT, "/start_cluster.sh", sep = "")) cat("#! /bin/bash\n\n") sink() for (sx in sigma.x){ for (seps in sigma.eps){ for (nn in n){ for (i in 1:nsplit){ ### File name of the shell script flname <- paste("errvar-", nn, "-", beta0, "-", beta1, "-", sx*10, "-", seps*10, "_", i, ".sh", sep = "") ### Task name (shorter file name) taskname <- paste("ev-", nn, "-", sx*10, "-", seps*10, "_", i, sep = "") ### Shell script sink(paste(CLSDIR, "/", flname, sep = "")) cat("#! /bin/bash\n") cat("#\n") cat("#SBATCH -p express3\n") cat("#SBATCH --job-name=", taskname, "\n", sep = "") cat("#SBATCH -n4\n\n") #cat("module load R\n") cat("Rscript /usr/users/komarek/NMST440/Simul01/nmst440-simul_errvar.R", i, M, nn, beta0, beta1, sx, seps, "\n", sep = " ") sink() ### Row in the master script sink(paste(ROOT, "/start_cluster.sh", sep = ""), append = TRUE) cat("sbatch /usr/users/komarek/NMST440/Simul01/ClScripts/", flname, "\n", sep = "") sink() } } } }