From 4e199e822f4abe75ae1fd2313f440d0c7610b409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Wed, 12 Jun 2019 14:53:50 +0300 Subject: [PATCH] Parallel bash for loop to lattices tutorial. Former-commit-id: 065638f79fbe8f37f681dd10f93b9914883c9577 --- lattices.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lattices.md b/lattices.md index cb4d6e0..9ebb1d3 100644 --- a/lattices.md +++ b/lattices.md @@ -80,7 +80,16 @@ This pre-calculates the translation operators for a simple (one particle per uni 621 nm × 571 nm rectangular lattice inside a medium with refractive index 1.52, up to the octupole (`lMax` = 3) order, yielding one file per frequency. This can take some time and -it makes sense to run a parallelised `for`-loop instead. +it makes sense to run a parallelised `for`-loop instead; this is a stupid but working +way to do it in bash: +``` + N=4 # number of parallel processes + for omega in $(cat omegalist); do + ((i=i%N)); ((i++==0)) && wait + ew_gen_kin $omega 621e-9 0 0 571e-9 3 w_$omega 1.52 1 0 0 < klist + echo $omega # optional, to follow progress + done +``` When this is done, we convert all the text output files into numpy's binary format in order to speed up loading in the following steps. @@ -94,7 +103,7 @@ is the destination path for the converted data (this will be a directory), and the remaining arguments are paths to the files generated by `ew_gen_kin`. In the case above, one could use ``` - processWfiles_sortnames.py 1 all s_* + processWfiles_sortnames.py 1 all w_* ``` which would create a directory named `all` containing several .npy files.