From 6331866e849cdb606bb5b85b27500bdeefb5c573 Mon Sep 17 00:00:00 2001
From: Guillaume Demesy <guillaume.demesy@fresnel.fr>
Date: Thu, 22 Sep 2022 22:33:45 +0200
Subject: [PATCH] GNU parallel script for M matrix as function of polar angle
 and wavelength

---
 .../grating3D_parallel_Mmatrix.sh             | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 DiffractionGratings/grating3D_parallel_Mmatrix.sh

diff --git a/DiffractionGratings/grating3D_parallel_Mmatrix.sh b/DiffractionGratings/grating3D_parallel_Mmatrix.sh
new file mode 100644
index 0000000..1efafd1
--- /dev/null
+++ b/DiffractionGratings/grating3D_parallel_Mmatrix.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+export OPENBLAS_NUM_THREADS=1
+export OMP_NUM_THREADS=1
+
+export NPROC=64
+export nb_phi=64
+export myDir="res_Matrix_nb_phi"$nb_phi
+export myFile="run_phideg_values_"$nb_phi".out"
+
+rm -r $myDir
+rm $myFile
+mkdir $myDir
+
+myfunc() {
+    local mysubDir=$myDir/run$1_psi$2
+    mkdir $mysubDir
+    cp grating3D.geo grating3D.pro grating3D_data_halfellipsoid.geo grating3D_data.geo grating3D_materials.pro $mysubDir
+    local phi=$(echo "scale=10;360/($nb_phi)*$1" | bc )
+    if [ $2 -eq 0 ]; then echo $1"  "$phi >> $myDir/$myFile ; fi
+    cd $mysubDir
+    echo gmsh grating3D.pro -setstring test_case halfellipsoid -setnumber thetadeg 50 -setnumber phideg $phi -setnumber psideg $2 -setstring Solver.SocketName id$1$2 -
+    if [ $2 -eq  0 ]; then cp res3D/rs.txt ../r_pin_sout_phi$1.out ; fi
+    if [ $2 -eq  0 ]; then cp res3D/rp.txt ../r_pin_pout_phi$1.out ; fi
+    if [ $2 -eq 90 ]; then cp res3D/rs.txt ../r_sin_sout_phi$1.out ; fi
+    if [ $2 -eq 90 ]; then cp res3D/rp.txt ../r_sin_pout_phi$1.out ; fi
+    cd ../..
+}
+
+export -f myfunc
+# parallel --lb -j $NPROC myfunc ::: $(seq 1 $nb_phi) ::: 0 90
+parallel -j $NPROC myfunc ::: $(seq 1 $nb_phi) ::: 0 90
-- 
GitLab