Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 29 Feb 2016 17:57:13 +0000 (18:57 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 29 Feb 2016 17:57:13 +0000 (18:57 +0100)
contrib/benchmarking_code_block/Rdhist.R
contrib/benchmarking_code_block/Rhist.R
contrib/benchmarking_code_block/Rplot_hist.R
examples/smpi/replay_multiple/generate_multiple_deployment.sh
tools/jenkins/build.sh

index 76ff210..ac5baa1 100644 (file)
@@ -5,11 +5,8 @@
 # University of Illinois/NCSA Open Source License
 # which accompanies this distribution, and is available at
 # http://opensource.ncsa.illinois.edu/license.html
-#-------------------------------------------------------------------------------
-##--------------------------------------------------------------------------------------------------#
 ##' Variable-width (dagonally cut) histogram
 ##'
-##'
 ##' When constructing a histogram, it is common to make all bars the same width.
 ##' One could also choose to make them all have the same area.
 ##' These two options have complementary strengths and weaknesses; the equal-width histogram oversmooths in regions of high density, and is poor at identifying sharp peaks; the equal-area histogram oversmooths in regions of low density, and so does not identify outliers.
 ##' @return list with two elements, heights of length n and breaks of length n+1 indicating the heights and break points of the histogram bars.
 ##' @author Lorraine Denby, Colin Mallows
 ##' @references Lorraine Denby, Colin Mallows. Journal of Computational and Graphical Statistics. March 1, 2009, 18(1): 21-31. doi:10.1198/jcgs.2009.0002.
-dhist <- function(x, a=5*iqr(x),
-                nbins=nclass.Sturges(x), rx = range(x,na.rm = TRUE),
-                eps=.15, xlab = "x", plot = TRUE,lab.spikes = TRUE)
-{
-
+dhist <- function(x, a=5*iqr(x), nbins=nclass.Sturges(x),
+                  rx = range(x,na.rm = TRUE), eps=.15, xlab = "x", plot = TRUE,lab.spikes = TRUE){
   if(is.character(nbins))
-    nbins <- switch(casefold(nbins),
-                    sturges = nclass.Sturges(x),
-                    fd = nclass.FD(x),
-                    scott = nclass.scott(x),
+    nbins <- switch(casefold(nbins), sturges = nclass.Sturges(x), fd = nclass.FD(x), scott = nclass.scott(x),
                     stop("Nclass method not recognized"))
   else if(is.function(nbins))
     nbins <- nbins(x)
@@ -51,17 +42,14 @@ dhist <- function(x, a=5*iqr(x),
     yupper <- x + (a * (1:n))/n
                                         # upper and lower corners in the ecdf
     ylower <- yupper - a/n
-                                        #
-    cmtx <- cbind(cut(yupper, breaks = ybr), cut(yupper, breaks =
-                                ybr, left.include = TRUE), cut(ylower, breaks = ybr),
+
+    cmtx <- cbind(cut(yupper, breaks = ybr), cut(yupper, breaks = ybr, left.include = TRUE), cut(ylower, breaks = ybr),
                   cut(ylower, breaks = ybr, left.include = TRUE))
     cmtx[1, 3] <- cmtx[1, 4] <- 1
                                         # to replace NAs when default r is used
     cmtx[n, 1] <- cmtx[n, 2] <- nbins
-                                        #
                                         #checksum <- apply(cmtx, 1, sum) %% 4
-    checksum <- (cmtx[, 1] + cmtx[, 2] + cmtx[, 3] + cmtx[, 4]) %%
-    4
+    checksum <- (cmtx[, 1] + cmtx[, 2] + cmtx[, 3] + cmtx[, 4]) %% 4
                                         # will be 2 for obs. that straddle two bins
     straddlers <- (1:n)[checksum == 2]
                                         # to allow for zero counts
@@ -71,13 +59,12 @@ dhist <- function(x, a=5*iqr(x),
       counts <- table(c(1:nbins, cmtx[, 1]))
     }
     counts <- counts - 1
-                                        #
+
     if(length(straddlers) > 0) {
       for(i in straddlers) {
         binno <- cmtx[i, 1]
         theta <- ((yupper[i] - ybr[binno]) * n)/a
-        counts[binno - 1] <- counts[binno - 1] + (
-                                                  1 - theta)
+        counts[binno - 1] <- counts[binno - 1] + (1 - theta)
         counts[binno] <- counts[binno] + theta
       }
     }
@@ -91,8 +78,7 @@ dhist <- function(x, a=5*iqr(x),
       diff.xbr<-abs(diff(xbr))
       amt.spike<-diff.xbr[length(diff.xbr)]
       for (i in rev(2:length(diff.xbr))) {
-        if (diff.xbr[i-1] <= spike&diff.xbr[i] <= spike &
-            !is.na(diff.xbr[i])) {
+        if (diff.xbr[i-1] <= spike&diff.xbr[i] <= spike & !is.na(diff.xbr[i])) {
           amt.spike <- amt.spike+diff.xbr[i-1]
           counts.new[i-1] <- counts.new[i-1]+counts.new[i]
           xbr.new[i] <- NA
@@ -113,8 +99,8 @@ dhist <- function(x, a=5*iqr(x),
     heights <- counts/widths
   }
   bin.size <- length(x)/nbins
-  cut.pt <- unique(c(min(x) - abs(min(x))/1000,
-                     approx(seq(length(x)), x, (1:(nbins - 1)) * bin.size, rule = 2)$y, max(x)))
+  cut.pt <- unique(c(min(x) - abs(min(x))/1000, approx(seq(length(x)), x,
+                                                       (1:(nbins - 1)) * bin.size, rule = 2)$y, max(x)))
   aa <- hist(x, breaks = cut.pt, plot = FALSE, probability = TRUE)
   if(a == Inf) {
     heights <- aa$counts
@@ -132,8 +118,7 @@ dhist <- function(x, a=5*iqr(x),
   amt.txt<-0
   end.y<-(-10000)
   if(plot) {
-    barplot(heights, abs(diff(xbr)), space = 0, density = -1, xlab =
-            xlab, plot = TRUE, xaxt = "n",yaxt='n')
+    barplot(heights, abs(diff(xbr)), space = 0, density = -1, xlab = xlab, plot = TRUE, xaxt = "n",yaxt='n')
     at <- pretty(xbr)
     axis(1, at = at - xbr[1], labels = as.character(at))
     if (lab.spikes) {
@@ -153,20 +138,14 @@ dhist <- function(x, a=5*iqr(x),
                                         sum(counts)*100)),'%',sep='')
             par(xpd = TRUE)
             text(xbr[i+1]-xbr[1],ylim.height-par('cxy')[2]*(amt.txt-1),txt, adj=0)
-          }}
-      }
-      else print('no spikes or more than one spike')
+          }
+        }
+      else print('no spikes or more than one spike')
     }
     invisible(list(heights = heights, xbr = xbr))
-  }
-  else {
-    return(list(heights = heights, xbr = xbr,counts=counts))
-  }
+  } else {return(list(heights = heights, xbr = xbr,counts=counts))}
 }
 #==================================================================================================#
-
-
-#--------------------------------------------------------------------------------------------------#
 ##' Calculate interquartile range
 ##'
 ##' Calculates the 25th and 75th quantiles given a vector x; used in function \link{dhist}.
@@ -178,8 +157,6 @@ iqr <- function(x){
   return(diff(quantile(x, c(0.25, 0.75), na.rm = TRUE)))
 }
 ##==================================================================================================#
-
-##--------------------------------------------------------------------------------------------------#
 ##' Creates empty ggplot object
 ##'
 ##' An empty base plot to which layers created by other functions
@@ -195,11 +172,6 @@ create.base.plot <- function() {
   return(base.plot)
 }
 #==================================================================================================#
-
-
-
-
-##--------------------------------------------------------------------------------------------------#
 ##' Add data to an existing plot or create a new one from \code{\link{create.base.plot}}
 ##'
 ##' Used to add raw data or summary statistics to the plot of a distribution.
@@ -228,25 +200,14 @@ plot.data <- function(trait.data, base.plot = NULL, ymax, color = 'black') {
     ymax <- ymax / 2
   }
   y.pts <- seq(0, ymax, length.out = 1 + n.pts)[-1]
-  plot.data <- data.frame(x = trait.data$Y,
-                          y = y.pts,
-                          se = trait.data$se,
+  plot.data <- data.frame(x = trait.data$Y, y = y.pts, se = trait.data$se,
                           control = !trait.data$trt == 1 & trait.data$ghs == 1)
-  new.plot <- base.plot +
-    geom_point(data = plot.data,
-               aes(x = x, y = y,
-               color = control)) +
-                 geom_segment(data = plot.data,
-                              aes(x = x - se, y = y, xend = x + se, yend = y,
-                                  color = control)) +
-                                    scale_color_manual(values = c('black', 'grey')) +
-                                      opts(legend_position = "none")
+  new.plot <- base.plot + geom_point(data = plot.data, aes(x = x, y = y, color = control)) +
+                 geom_segment(data = plot.data, aes(x = x - se, y = y, xend = x + se, yend = y, color = control)) +
+                     scale_color_manual(values = c('black', 'grey')) + opts(legend_position = "none")
   return(new.plot)
 }
 ##==================================================================================================#
-
-
-#--------------------------------------------------------------------------------------------------#
 ##' Add borders to .. content for \description{} (no empty lines) ..
 ##'
 ##' Has ggplot2 display only specified borders, e.g. ("L"-shaped) borders, rather than a rectangle or no border. Note that the order can be significant; for example, if you specify the L border option and then a theme, the theme settings will override the border option, so you need to specify the theme (if any) before the border option, as above.
@@ -267,47 +228,39 @@ plot.data <- function(trait.data, base.plot = NULL, ymax, color = 'black') {
 ##' ggplot(data=df, aes(x=x, y=y)) + geom_point() + theme_bw() +
 ##' opts(panel.border = theme_border(c("b","l")) )
 ##' }
-theme_border <- function(type = c("left", "right", "bottom", "top",
-                           "none"), colour = "black", size = 1, linetype = 1) {
+theme_border <- function(type = c("left", "right", "bottom", "top", "none"), colour = "black", size = 1, linetype = 1){
   type <- match.arg(type, several.ok=TRUE)
-  structure(
-            function(x = 0, y = 0, width = 1, height = 1, ...) {
-              xlist <- c()
-              ylist <- c()
-              idlist <- c()
-              if ("bottom" %in% type) { # bottom
-                xlist <- append(xlist, c(x, x+width))
-                ylist <- append(ylist, c(y, y))
-                idlist <- append(idlist, c(1,1))
-              }
-              if ("top" %in% type) { # top
-                xlist <- append(xlist, c(x, x+width))
-                ylist <- append(ylist, c(y+height, y+height))
-                idlist <- append(idlist, c(2,2))
-              }
-              if ("left" %in% type) { # left
-                xlist <- append(xlist, c(x, x))
-                ylist <- append(ylist, c(y, y+height))
-                idlist <- append(idlist, c(3,3))
-              }
-              if ("right" %in% type) { # right
-                xlist <- append(xlist, c(x+width, x+width))
-                ylist <- append(ylist, c(y, y+height))
-                idlist <- append(idlist, c(4,4))
-              }
-              polylineGrob(
-                           x=xlist, y=ylist, id=idlist, ..., default.units = "npc",
-                           gp=gpar(lwd=size, col=colour, lty=linetype),
-                           )
-            },
+  structure(function(x = 0, y = 0, width = 1, height = 1, ...) {
+      xlist <- c()
+      ylist <- c()
+      idlist <- c()
+      if ("bottom" %in% type) { # bottom
+          xlist <- append(xlist, c(x, x+width))
+          ylist <- append(ylist, c(y, y))
+          idlist <- append(idlist, c(1,1))
+      }
+      if ("top" %in% type) { # top
+          xlist <- append(xlist, c(x, x+width))
+          ylist <- append(ylist, c(y+height, y+height))
+          idlist <- append(idlist, c(2,2))
+      }
+      if ("left" %in% type) { # left
+          xlist <- append(xlist, c(x, x))
+          ylist <- append(ylist, c(y, y+height))
+          idlist <- append(idlist, c(3,3))
+      }
+      if ("right" %in% type) { # right
+          xlist <- append(xlist, c(x+width, x+width))
+          ylist <- append(ylist, c(y, y+height))
+          idlist <- append(idlist, c(4,4))
+      }
+      polylineGrob(x=xlist, y=ylist, id=idlist, ..., default.units = "npc",
+                   gp=gpar(lwd=size, col=colour, lty=linetype),
+                   )
+  },
             class = "theme",
             type = "box",
             call = match.call()
             )
 }
 #==================================================================================================#
-
-
-####################################################################################################
-### EOF. End of R script file.                         
-####################################################################################################
index 991060e..917be30 100644 (file)
@@ -1,36 +1,29 @@
 # R script that produces histograms from benchmarked values
-
 # Can be called from the bash script with the following code:
 # export R_INPUT=$inputfile
 # export R_OUTPUT=$outputfile
 # export R_TYPE=$hist_type
 
-# R CMD BATCH $this_script.R
-#or
-# Rscript $this_script.R
+# R CMD BATCH $this_script.R or  Rscript $this_script.R
 
-# Use functions from bench.h to benchmark execution time of the desired block,
-# then Rhist.R script to read all timings and produce histograms
-# and finally inject.h to inject values instead of executing block
+# Use functions from bench.h to benchmark execution time of the desired block, then Rhist.R script to read all timings
+# and produce histograms and finally inject.h to inject values instead of executing block
 
 # This is a small function to help merging empty nbins for dhist histograms
-merge_empty_bins <- function (h)
-{
+merge_empty_bins <- function (h){
   i<-1
   j<-1
   counts2<--1
   breaks2<-h$breaks[1]
 
   if (length(h$counts)>1)
-    for(i in 1:(length(h$counts)-1))
-      {
-        if(h$counts[i]!=0 || h$counts[i+1]!=0)
-          {
-            counts2[j]<-h$counts[i]
-            breaks2[j+1]<-h$breaks[i+1];
-            j<-j+1
-          }
+    for(i in 1:(length(h$counts)-1)){
+      if(h$counts[i]!=0 || h$counts[i+1]!=0){
+        counts2[j]<-h$counts[i]
+        breaks2[j+1]<-h$breaks[i+1];
+        j<-j+1
       }
+    }
   
   counts2[j]<-h$counts[length(h$counts)]
   breaks2[j+1]<-h$breaks[length(h$breaks)]
@@ -48,50 +41,39 @@ inputfile<-Sys.getenv("R_INPUT")
 outputfile<-Sys.getenv("R_OUTPUT")
 type<-Sys.getenv("R_TYPE")
 
-if (!(type %in% c("mean","default","sturges","scott")))
-  {
-    stop("Wrong histogram type")
-  }
+if (!(type %in% c("mean","default","sturges","scott"))){stop("Wrong histogram type")}
 
 df<-read.table(inputfile,header=F)
 df<-df[,c(1,4)]
 names(df)<-c("NAME","TIME")
 attach(df)
 
-for(i in unique(NAME))
-{
+for(i in unique(NAME)){
   vector1<-df[NAME==i,2]
-
-  if (length(vector1)==1)
-    {
-      #If there is only one element
+  if (length(vector1)==1){
+    #If there is only one element
+    h<-hist(vector1) # Just for R compatibility reasons
+    h$breaks<-c(vector1,vector1)
+    h$counts<-1
+  } else {
+    if (type=="mean"){
+      #Mean value only
       h<-hist(vector1) # Just for R compatibility reasons
-      h$breaks<-c(vector1,vector1)
-      h$counts<-1
-    }
-  else
-    {
-      if (type=="mean")
-        {
-          #Mean value only
-          h<-hist(vector1) # Just for R compatibility reasons
-          h$breaks<-c(mean(vector1),mean(vector1))
-          h$counts<-length(vector1)
-        }
-      else
-        if (type=="default")
-          #Standard HISTOGRAM:
-          h<-hist(vector1)
-        else
-          {
-            #Dhist:
-            h<-dhist(vector1,nbins=type, plot = FALSE, lab.spikes = FALSE, a=5*iqr(vector1), eps=0.15)
-            h$breaks<-h$xbr
-            h$count<-as.vector(h$counts)
-            h$counts<-h$count
-            h<-merge_empty_bins(h)
-          }
-    }
+      h$breaks<-c(mean(vector1),mean(vector1))
+      h$counts<-length(vector1)
+    } else
+       if (type=="default")
+         #Standard HISTOGRAM:
+         h<-hist(vector1)
+       else {
+         #Dhist:
+         h<-dhist(vector1,nbins=type, plot = FALSE, lab.spikes = FALSE, a=5*iqr(vector1), eps=0.15)
+         h$breaks<-h$xbr
+         h$count<-as.vector(h$counts)
+         h$counts<-h$count
+         h<-merge_empty_bins(h)
+       }
+  }
     
   cat(i, file = outputfile, sep = "\t", append = TRUE)
   cat("\t", file = outputfile,  append = TRUE)
index 1f7487a..18f5f23 100644 (file)
@@ -1,7 +1,5 @@
 # R script showing .pdf file with plots of all injection histograms for a certain file
-
-# Can be called from the command line with:
-# Rscript $this_script.R inputfile
+# Can be called from the command line with: Rscript $this_script.R inputfile
 
 # Necessary libraries
 library(plyr)
@@ -12,28 +10,27 @@ library(grid)
 # Functions for arranging multiple plots
 vp.layout <- function(x, y) viewport(layout.pos.row=x, layout.pos.col=y)
 arrange_ggplot2 <- function(list, nrow=NULL, ncol=NULL, as.table=FALSE) {
-n <- length(list)
-if(is.null(nrow) & is.null(ncol)) { nrow = floor(n/2) ; ncol = ceiling(n/nrow)}
-if(is.null(nrow)) { nrow = ceiling(n/ncol)}
-if(is.null(ncol)) { ncol = ceiling(n/nrow)}
-## NOTE see n2mfrow in grDevices for possible alternative
-grid.newpage()
-pushViewport(viewport(layout=grid.layout(nrow,ncol) ) )
-ii.p <- 1
-for(ii.row in seq(1, nrow)){
-ii.table.row <- ii.row
-if(as.table) {ii.table.row <- nrow - ii.table.row + 1}
-for(ii.col in seq(1, ncol)){
-ii.table <- ii.p
-if(ii.p > n) break
-print(list[[ii.table]], vp=vp.layout(ii.table.row, ii.col))
-ii.p <- ii.p + 1
-}
-}
+  n <- length(list)
+  if(is.null(nrow) & is.null(ncol)) { nrow = floor(n/2) ; ncol = ceiling(n/nrow)}
+  if(is.null(nrow)) { nrow = ceiling(n/ncol)}
+  if(is.null(ncol)) { ncol = ceiling(n/nrow)}
+  ## NOTE see n2mfrow in grDevices for possible alternative
+  grid.newpage()
+  pushViewport(viewport(layout=grid.layout(nrow,ncol) ) )
+  ii.p <- 1
+  for(ii.row in seq(1, nrow)){
+    ii.table.row <- ii.row
+    if(as.table) {ii.table.row <- nrow - ii.table.row + 1}
+    for(ii.col in seq(1, ncol)){
+      ii.table <- ii.p
+      if(ii.p > n) break
+      print(list[[ii.table]], vp=vp.layout(ii.table.row, ii.col))
+      ii.p <- ii.p + 1
+    }
+  }
 }
 
 ### Main
-
 # Reading command line argument with the input file path
 args <- commandArgs(trailingOnly = TRUE)
 fp  <- file(args[1], open = "r")
@@ -42,8 +39,8 @@ plots<-list()
 i<-1
 
 # Reading histograms one by one, line by line
-while (length(oneLine <- readLines(fp, n = 1, warn = FALSE)) > 0)
-{ myVector <- (strsplit(oneLine, "\t")) 
+while (length(oneLine <- readLines(fp, n = 1, warn = FALSE)) > 0){
+  myVector <- (strsplit(oneLine, "\t")) 
   
   dfl <- ldply (myVector, data.frame)
 
@@ -51,22 +48,24 @@ while (length(oneLine <- readLines(fp, n = 1, warn = FALSE)) > 0)
   nbins<-as.numeric(as.character(dfl[4,]))
   allbreaks<-as.numeric(as.character(dfl[5:(5+nbins-1),]))
   
-  dh<-data.frame(Name=as.character(dfl[1,]), Total=as.numeric(as.character(dfl[2,])), Mean=as.numeric(as.character(dfl[3,])), Nbins=as.numeric(as.character(dfl[4,])))
+  dh<-data.frame(Name=as.character(dfl[1,]), Total=as.numeric(as.character(dfl[2,])),
+                 Mean=as.numeric(as.character(dfl[3,])), Nbins=as.numeric(as.character(dfl[4,])))
   dh<-cbind(dh,Bstart=allbreaks[-length(allbreaks)])
   dh<-cbind(dh,Bend=allbreaks[-1])
   dh<-cbind(dh,Density=as.numeric(as.character(dfl[(5+nbins):(5+nbins*2-2),])))
 
   # Plotting single histogram, if it only has one value then use geom_bar
   if (nbins > 2)
-    plots[[i]]<-ggplot(data=data.frame(dh), aes(xmin=Bstart, xmax=Bend, ymin=0, ymax=Density)) + geom_rect(aes(fill=Density)) + theme_bw() + scale_x_continuous("Time [s]", allbreaks) + labs(title=name, y=element_text("Density %"))
+    plots[[i]]<-ggplot(data=data.frame(dh), aes(xmin=Bstart, xmax=Bend, ymin=0, ymax=Density)) +
+        geom_rect(aes(fill=Density)) + theme_bw() + scale_x_continuous("Time [s]", allbreaks) +
+            labs(title=name, y=element_text("Density %"))
   else
-    plots[[i]]<-ggplot(data=data.frame(dh), aes(factor(Bstart))) + geom_bar(aes(fill=Density)) + theme_bw() + labs(title=name, y=element_text("Density %"), x=element_text("Time [s]"))
-
+    plots[[i]]<-ggplot(data=data.frame(dh), aes(factor(Bstart))) + geom_bar(aes(fill=Density)) +
+        theme_bw() + labs(title=name, y=element_text("Density %"), x=element_text("Time [s]"))
   i<-i+1
 }
 
 # Printing all plots together in a table
 arrange_ggplot2(plots, as.table=TRUE)
 
-# End
 write("Done producing a histogram plot. Open Rplots.pdf located in this folder to see the results", stdout())
index de3cd9c..5b1ceed 100755 (executable)
@@ -6,7 +6,6 @@
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the license (GNU LGPL) which comes with this package.
 
-
 #usage to print the way this script should be called
 usage () {
     cat <<EOF
@@ -74,10 +73,6 @@ while [ $# -gt 0 ]; do
     esac
 done
 
-
-##-----------------------------------
-
-
 if [ -z "${HOSTFILE}" ] && [ -z "${PLATFORM}" ] ; then
     echo "No hostfile nor platform specified."
     usage
@@ -105,7 +100,6 @@ if [ "${multiple_processes}" -gt 0 ] ; then
     HOSTFILE=$UNROLLEDHOSTFILE
 fi
 
-
 # Don't use wc -l to compute it to avoid issues with trailing \n at EOF
 hostfile_procs=`grep -c "[a-zA-Z0-9]" $HOSTFILE`
 if [ ${hostfile_procs} = 0 ] ; then
@@ -113,7 +107,6 @@ if [ ${hostfile_procs} = 0 ] ; then
    exit 1
 fi
 
-
 ##-------------------------------- DEFAULT APPLICATION --------------------------------------
 
 APPLICATIONTMP=$(echo ${PROC_ARGS}|cut -d' ' -f2 -s)
@@ -130,18 +123,16 @@ if [ -n "${HOSTFILE}" ] && [ -f ${HOSTFILE} ]; then
     NUMHOSTS=$(cat ${HOSTFILE} | wc -l)
 fi
 
+DESCRIPTIONFILE=$(echo $PROC_ARGS|cut -d' ' -f1)
 
-    DESCRIPTIONFILE=$(echo $PROC_ARGS|cut -d' ' -f1)
-
-    if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then
-        NUMINSTANCES=$(cat ${DESCRIPTIONFILE} | wc -l)
-        replayinstances=$(cat ${DESCRIPTIONFILE})
-        IFS_OLD=$IFS
-        IFS=$'\n'
-        set -f
-        NUMPROCS=0
-        while IFS= read -r line; do
-        
+if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then
+    NUMINSTANCES=$(cat ${DESCRIPTIONFILE} | wc -l)
+    replayinstances=$(cat ${DESCRIPTIONFILE})
+    IFS_OLD=$IFS
+    IFS=$'\n'
+    set -f
+    NUMPROCS=0
+    while IFS= read -r line; do
         # return IFS back if you need to split new line by spaces:
         IFS=$IFS_OLD
         IFS_OLD=
@@ -170,8 +161,6 @@ fi
         fi
         #NUMPROCS=$((${NUMPROCS}+${NUMPROCSMINE}));
         for i in $SEQ1
-        
-
 ##----------------------------------------------------------
 ##  generate application.xml with hostnames from hostfile:
 ##  the name of host_i (1<=i<=p, where -np p) is the line i
@@ -180,54 +169,49 @@ fi
 ##----------------------------------------------------------
 
 ##---- generate <process> tags------------------------------
-
         do
-          if [ -n "${HOSTFILE}" ]; then
-          j=$(( ${NUMPROCS} % ${NUMHOSTS} +1))
-          fi
-          hostname=$(echo $hostnames|cut -d' ' -f$j)
-          if [ -z "${hostname}" ]; then
-            host="host"$($j)
-          else
-            host="${hostname}"
-          fi
+           if [ -n "${HOSTFILE}" ]; then
+               j=$(( ${NUMPROCS} % ${NUMHOSTS} +1))
+            fi
+            hostname=$(echo $hostnames|cut -d' ' -f$j)
+            if [ -z "${hostname}" ]; then
+               host="host"$($j)
+            else
+               host="${hostname}"
+            fi
         
-          echo "  <process host=\"${host}\" function=\"${instance}\"> <!-- function name used only for logging -->" >> ${APPLICATIONTMP}
-          echo "    <argument value=\"${instance}\"/> <!-- instance -->" >> ${APPLICATIONTMP}
-          echo "    <argument value=\"${i}\"/> <!-- rank -->" >> ${APPLICATIONTMP}
-          echo "    <argument value=\"$(echo $hosttrace|cut -d' ' -f$(($i+1)))\"/>" >> ${APPLICATIONTMP}
-       
-          echo "    <argument value=\"${sleeptime}\"/> <!-- delay -->" >> ${APPLICATIONTMP}
-          echo "  </process>" >> ${APPLICATIONTMP}
-          NUMPROCS=$(( ${NUMPROCS} +1))
+            echo "  <process host=\"${host}\" function=\"${instance}\"> <!-- function name used only for logging -->" >> ${APPLICATIONTMP}
+            echo "    <argument value=\"${instance}\"/> <!-- instance -->" >> ${APPLICATIONTMP}
+            echo "    <argument value=\"${i}\"/> <!-- rank -->" >> ${APPLICATIONTMP}
+            echo "    <argument value=\"$(echo $hosttrace|cut -d' ' -f$(($i+1)))\"/>" >> ${APPLICATIONTMP}
+           
+            echo "    <argument value=\"${sleeptime}\"/> <!-- delay -->" >> ${APPLICATIONTMP}
+            echo "  </process>" >> ${APPLICATIONTMP}
+            NUMPROCS=$(( ${NUMPROCS} +1))
         done
         # return IFS back to newline for "for" loop
         IFS_OLD=$IFS
         IFS=$'\n'
-      done < ${DESCRIPTIONFILE}
-
-        # return delimiter to previous value
-      IFS=$IFS_OLD
-      IFS_OLD=
-      else
-        printf "File not found: %s\n", "${APP_TRACES[0]:-\${APP_TRACES[0]\}}" >&2
-        exit 1
-    fi
-
+    done < ${DESCRIPTIONFILE}
 
+    # return delimiter to previous value
+    IFS=$IFS_OLD
+    IFS_OLD=
+else
+    printf "File not found: %s\n", "${APP_TRACES[0]:-\${APP_TRACES[0]\}}" >&2
+    exit 1
+fi
 
 cat >> ${APPLICATIONTMP} <<APPLICATIONFOOT
 </platform>
 APPLICATIONFOOT
 ##-------------------------------- end DEFAULT APPLICATION --------------------------------------
 
-
-    if [ ${HOSTFILETMP} = 1 ] ; then
-        rm ${HOSTFILE}
-    fi
-    if [ ${UNROLLEDHOSTFILETMP} = 1 ] ; then
-        rm ${UNROLLEDHOSTFILE}
-    fi
-
+if [ ${HOSTFILETMP} = 1 ] ; then
+    rm ${HOSTFILE}
+fi
+if [ ${UNROLLEDHOSTFILETMP} = 1 ] ; then
+    rm ${UNROLLEDHOSTFILE}
+fi
 
 exit 0
index 1946b68..ebf9aac 100755 (executable)
@@ -125,7 +125,6 @@ cmake -G"$GENERATOR"\
   -Denable_tracing=ON -Denable_java=ON -Denable_lua=OFF $SRCFOLDER
 #  -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \
 
-
 make -j$NUMBER_OF_PROCESSORS VERBOSE=1
 
 if test "$(uname -o)" != "Msys"; then