Skip to content

Commit 6fa108a

Browse files
committed
auto-commit
1 parent a59c470 commit 6fa108a

File tree

4 files changed

+47
-50
lines changed

4 files changed

+47
-50
lines changed

makefile

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,48 @@
11
all: all-results/all-results.rdata
22

3-
# 1: park previous results with "make park"
4-
# 2: specify computers and threads to use in parallel-pars.r
5-
# 3: split job among computers with "make preparesims"
6-
# 4: --- !!! COMMIT AND PUSH CHANGES !!! ---
7-
# 5: synchronise computers with "make gitsync"
8-
# 6: "make runallsims" to start all the simulations
9-
# 7: harvest results on different computers with "make harvest"
3+
# 1: specify computers and threads to use in parallel-pars.r
4+
# 2: split job among computers with "make preparesims"
5+
# 3: park previous results with "make park"
6+
# 4: "make runallsims" to start all the simulations
7+
# 5: harvest results on different computers with "make harvest"
108
# Check runs with "make checkruns"
11-
# If something wrong: "make killr", to kill all the R processes on all computers, before starting again
9+
# If something goes wrong: "make killr", to kill all the R processes on all computers, before starting again
1210

1311

1412
## collect results from all computers, and append them
15-
all-results/all-results.rdata: parallelisation/gather-results.r
13+
all-results/all-results.rdata: parallelisation/gather-results.r .runallsims
1614
cd parallelisation; Rscript gather-results.r
1715

1816
## Run simulations
19-
runallsims: .compile parallelisation/run-all-sims.r
17+
.runallsims: parallelisation/run-all-sims.r .compile .preparesims
2018
cd parallelisation; Rscript run-all-sims.r
19+
touch .runallsims
2120

2221
## Prepare simulations; split between cores;
2322
## run "make preparsesims a=test" just for testing what's about to be run
24-
preparesims:
23+
.preparesims:
2524
cd parallelisation; Rscript prepare-sims.r $(a)
25+
touch .preparesims
26+
27+
## Byte compile R functions to go a bit faster
28+
.compile: functions.r functions-model.r parallelisation/compile-functions.r
29+
cd parallelisation; Rscript compile-functions.r
30+
touch .compile
2631

2732
## Park previous results (results, all-results)
2833
park:
2934
cd parallelisation; Rscript park-prev.r
3035

31-
## Do a git pull on dfly computers (as in pars_parallel.r)
32-
gitsync:
33-
cd parallelisation; Rscript gitsync.r
3436

3537

3638

3739

40+
### Various utilities
41+
42+
## Do a git pull on dfly computers (as in pars_parallel.r)
43+
gitsync:
44+
cd parallelisation; Rscript gitsync.r
45+
3846
## Kill screens on all dfly computers specified in pars_parallel.r
3947
killscreens:
4048
cd parallelisation; Rscript kill-all-screens.r
@@ -43,12 +51,11 @@ killscreens:
4351
killr:
4452
cd parallelisation; Rscript kill-all-r.r
4553

46-
54+
## Check log of screen on each computer and check R processes running on all computers
4755
checkruns:
4856
cd parallelisation; Rscript check-screens.r
4957
Rscript -e "proc_in_dfly()"
5058

51-
5259
## make tags for emacs
5360
tags:
5461
Rscript -e "rtags(ofile='TAGS', recursive=T)"
@@ -59,6 +66,3 @@ clean:
5966
cleantmp:
6067
rm *~
6168

62-
.compile: functions.r functions-model.r parallelisation/compile-functions.r
63-
cd parallelisation; Rscript compile-functions.r
64-
touch .compile

parallelisation/gather-results.r

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
### Fetch results from all computers ###
22
##########################################
33

4-
rm(list=ls())
54
library(compiler)
65

7-
basefold <- '~/dragonfly/sra-foundations/modelling/bh-dd-k50/'
8-
setwd(basefold)
9-
10-
source('parallel-pars.r')
6+
source('../pars_parallel.r')
117
## source('functions.r')
128
loadcmp('functions_cmp.r')
139

14-
load(datafile)
10+
load(sprintf('../%s', datafile))
11+
data <- eval(parse(text=dataname))
12+
if (dataname != 'data') {rm(dataname); gc()}
1513

1614
load('cores_alloc.rdata')
1715
othercomps <- unique(cores_alloc$comp[!(cores_alloc$comp %in% thiscomp)])
1816

1917
c=othercomps[1]
2018
for (c in othercomps)
2119
{
22-
fold <- sprintf('%s-%s', outputfold, c)
20+
fold <- sprintf('../%s-%s', outputfold, c)
2321
dir.create(fold, showWarnings=F)
2422
## Mount results from other computers
2523
if (!length(dir(fold)))
@@ -35,26 +33,26 @@ folds <- c(outputfold, sprintf('%s-%s', outputfold, othercomps))
3533
for (d in folds) # d='results-taiko' # d='results'
3634
{
3735
cat('\nMerging files in', d, '...\n')
38-
setwd(sprintf('%s%s', basefold, d))
36+
setwd(sprintf('%s/%s/%s/%s', basefold, projectname, runfold, d))
3937

40-
inter <- dir(pattern='.*pars1-steps.*..rdata')
41-
fin <- dir(patter='.*pars-steps.*..rdata')
38+
inter <- dir(pattern='.*incomplete.*..rdata')
39+
fin <- dir(patter='.*finished.*..rdata')
4240

4341
for (f in inter) # f=inter[1]
4442
{
4543
load(f)
46-
resi <- rbind2(resi, pars1)
44+
resi <- rbind2(resi, data1)
4745
}
4846

4947
for (f in fin) # f=fin[2]
5048
{
5149
load(f)
52-
resf <- rbind2(resf, pars)
50+
resf <- rbind2(resf, data)
5351
}
5452
}
5553

5654

57-
setwd(basefold)
55+
setwd(sprintf('%s/%s/%s', basefold, projectname, runfold))
5856

5957
## Unmount other computers
6058
for (c in othercomps) # c='frank'
@@ -64,21 +62,20 @@ for (c in othercomps) # c='frank'
6462
unlink(fold, recursive=T)
6563
}
6664

67-
allresdir <- sprintf('%sall-results', basefold)
68-
dir.create(allresdir, showWarnings=F)
65+
dir.create(allresfold, showWarnings=F)
6966
setwd(allresdir)
7067

7168

7269
## Merge intermediate and final results
73-
resi2 <- resi[!(resi$row %in% resf$row),] # remove finished rows from intermediate results
70+
resi2 <- resi[!(resi[[rowidcol]] %in% resf[[rowidcol]]),] # remove finished rows from intermediate results
7471
res <- rbind(resi2, resf)
7572

76-
res <- res[order(res$row),]
73+
res <- res[order(res[[rowidcol]]),]
7774

7875

7976

8077
## Check missing rows and summarise
81-
missingrows <- dem$row[!(dem$row %in% res$row)]
78+
missingrows <- data[[rowidcol]][!(data[[rowidcol]] %in% res[[rowidcol]])]
8279
if (length(missingrows))
8380
{
8481
mr <- as.numeric(missingrows)
@@ -90,17 +87,11 @@ if (length(missingrows))
9087
}
9188

9289
cat(sprintf('\n%i rows done (%i duplicates) after merging intermediates and final results.
93-
Details:', nrow(res), sum(duplicated(res$row))),'\n')
94-
print(table(res$species))
95-
96-
if ('pbr0' %in% names(res))
97-
cat(sprintf('\n%i PBR values (%0.1f%%) already calculated.\n', sum(!is.na(res$pbr0)),
98-
100*sum(!is.na(res$pbr0))/nrow(res))) else
99-
cat('\nNo PBR values already calculated.\n')
90+
Details:', nrow(res), sum(duplicated(res[[rowidcol]]))),'\n')
10091

10192

10293
### Save appended results
103-
res <- res[order(res$row),]
94+
res <- res[order(res[[rowidcol]]),]
10495

10596
setwd(allresdir)
10697
save(res, file='results_res.rdata')

parallelisation/park-prev.r

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ for (cp in comps)
1414

1515
## results
1616
f <- sprintf('%s/%s/%s/%s', basefold, projectname, runfold, outputfold)
17-
a <- suppressWarnings(system(sprintf('ssh -A %s@%s "ls -d %s" 2>&1', user, cp, f), intern=T))
18-
if (!grepl('^ls:',a))
17+
suppressWarnings(ex <- system(sprintf("ssh %s@%s test -d '%s' && echo TRUE", user, cp, f),
18+
intern=T))
19+
if (length(ex))
1920
{
2021
cmd <- sprintf('ssh -A %s@%s "cd %s/%s/%s; mv %s %s_%s"', user, cp,
2122
basefold, projectname, runfold, outputfold, outputfold, timeflag); cat(cmd,'\n')
@@ -25,8 +26,9 @@ for (cp in comps)
2526

2627
## all-results
2728
f <- sprintf('%s/%s/%s/%s', basefold, projectname, runfold, allresfold)
28-
a <- suppressWarnings(system(sprintf('ssh -A %s@%s "ls -d %s" 2>&1', user, cp, f), intern=T))
29-
if (!grepl('^ls:',a))
29+
suppressWarnings(ex <- system(sprintf("ssh %s@%s test -d '%s' && echo TRUE", user, cp, f),
30+
intern=T))
31+
if (length(ex))
3032
{
3133
cmd <- sprintf('ssh -A %s@%s "cd %s/%s/%s; mv %s %s_%s"', user, cp,
3234
basefold, projectname, runfold, allresfold, allresfold, timeflag); cat(cmd,'\n')

run1.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source('pars_parallel.r')
88
loadcmp('parallelisation/functions_cmp.r')
99
loadcmp('parallelisation/functions-model_cmp.r')
1010

11-
load('data.rdata')
11+
load(datafile)
1212
data <- eval(parse(text=dataname))
1313
if (dataname != 'data') {rm(dataname); gc()}
1414

0 commit comments

Comments
 (0)