for (r in 1:1000){ ## copy data from.file<-paste('/pscratch/zzhang4/Private/LCSM/data/simdata-N',NSIM,'-T',TSIM,'-',r,'.txt', sep='') to.file<-paste('/pscratch/zzhang4/Private/LCSM/analysis/N',NSIM,'T',TSIM,'/data.txt', sep='') file.copy(from.file, to.file,overwrite =TRUE) runtry<-try(system('/pscratch/zzhang4/Private/bugs/bin/OpenBUGS < script.txt > out.txt')) if (class(runtry) != "try-error"){ ## save the output ## copy the DIC to.file<-paste('/pscratch/zzhang4/Private/LCSM/results/N',NSIM,'T',TSIM,'/DIC-',r,'.txt', sep='') file.copy('out.txt', to.file) ## copy the coda file to.file<-paste('/pscratch/zzhang4/Private/LCSM/results/N',NSIM,'T',TSIM,'/CODA-',r,'.txt', sep='') file.copy('codaCODAchain1.txt', to.file) } unlink('data.txt') unlink('out.txt') unlink('codaCODAchain1.txt') unlink('codaCODAindex.txt') }