From e12f52de11eb70b5491940828ca78094562000d5 Mon Sep 17 00:00:00 2001
From: Antoine Cyril David Hoffmann <ahoffman@spcpc606.epfl.ch>
Date: Mon, 12 Apr 2021 11:20:10 +0200
Subject: [PATCH] New scripts to run on Izar cluster

---
 matlab/write_sbash_izar.m | 46 +++++++++++++++++++++
 wk/izar_run.m             | 86 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 132 insertions(+)
 create mode 100644 matlab/write_sbash_izar.m
 create mode 100644 wk/izar_run.m

diff --git a/matlab/write_sbash_izar.m b/matlab/write_sbash_izar.m
new file mode 100644
index 00000000..01c7334c
--- /dev/null
+++ b/matlab/write_sbash_izar.m
@@ -0,0 +1,46 @@
+% Write the input script "fort.90" with desired parameters
+INPUT = 'setup_and_run.sh';
+fid = fopen(INPUT,'wt');
+
+fprintf(fid,[...
+'#!/bin/bash\n',...
+'mkdir -p $SCRATCH/ahoffman/HeLaZ/wk\n',...
+...
+'cd $SCRATCH/ahoffman/HeLaZ/wk/\n',...
+...
+'mkdir -p ', BASIC.RESDIR,'\n',...
+'cd ',BASIC.RESDIR,'\n',...
+'cp $HOME/HeLaZ/wk/fort.90 .\n',...
+'cp $HOME/HeLaZ/wk/batch_script.sh .\n',...
+...
+'sbatch batch_script.sh\n',...
+'echo tail -f $SCRATCH/ahoffman/HeLaZ/results/',BASIC.SIMID,'/',BASIC.PARAMS,'/out.txt']);
+
+fclose(fid);
+system(['cp setup_and_run.sh ',BASIC.RESDIR,'/.']);
+
+% Write the sbatch script
+INPUT = 'batch_script.sh';
+fid = fopen(INPUT,'wt');
+
+fprintf(fid,[...
+'#!/bin/bash\n',...
+'#SBATCH --chdir $SCRATCH/ahoffman/HeLaZ/results/',BASIC.SIMID,'/',BASIC.PARAMS,'\n',...
+'#SBATCH --job-name ',CLUSTER.JNAME,'\n',...
+'#SBATCH --time ', CLUSTER.TIME,'\n',...
+'#SBATCH --nodes ', CLUSTER.NODES,'\n',...
+'#SBATCH --cpus-per-task ', CLUSTER.CPUPT,'\n',...
+'#SBATCH --ntasks-per-node ', CLUSTER.NTPN,'\n',...
+'#SBATCH --mem ', CLUSTER.MEM,'\n',...
+'#SBATCH --partition ',CLUSTER.PART,'\n',...
+'module purge\n',...
+'module load intel/19.0.5\n',...
+'module load intel-mpi/2019.5.281\n',...
+'module load fftw/3.3.8-mpi-openmp\n',...
+'module load hdf5/1.10.6-mpi\n',...
+'srun --cpu-bind=cores ./../../../bin/helaz ',num2str(NP_P),' ',num2str(NP_KR)]);
+
+fclose(fid);
+system(['cp batch_script.sh ',BASIC.RESDIR,'/.']);
+
+system('scp {fort.90,setup_and_run.sh,batch_script.sh} ahoffman@izar.epfl.ch:/home/ahoffman/HeLaZ/wk');
\ No newline at end of file
diff --git a/wk/izar_run.m b/wk/izar_run.m
new file mode 100644
index 00000000..168f6911
--- /dev/null
+++ b/wk/izar_run.m
@@ -0,0 +1,86 @@
+%clear all;
+addpath(genpath('../matlab')) % ... add
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Set Up parameters
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% CLUSTER PARAMETERS
+CLUSTER.TIME  = '00:15:00'; % allocation time hh:mm:ss
+CLUSTER.PART  = 'gpu';     % debug/gpu
+CLUSTER.MEM   = '4G';     % Memory
+CLUSTER.JNAME = 'gamma_inf';% Job name
+NP_P          = 1;          % MPI processes along p (nodes)
+NP_KR         = 20;         % MPI processes along kr (cpu)
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% PHYSICAL PARAMETERS
+NU      = 0.1;   % Collision frequency
+ETAB    = 0.6;   % Magnetic gradient
+NU_HYP  = 1.0;   % Hyperdiffusivity coefficient
+%% GRID PARAMETERS
+N       = 50;   % Frequency gridpoints (Nkr = N/2)
+L       = 10;   % Size of the squared frequency domain
+P       = 04;    % Electron and Ion highest Hermite polynomial degree
+J       = 04;    % Electron and Ion highest Laguerre polynomial degree
+MU_P    = 0;     % Hermite  hyperdiffusivity -mu_p*(d/dvpar)^4 f
+MU_J    = 0;     % Laguerre hyperdiffusivity -mu_j*(d/dvperp)^4 f
+%% TIME PARAMETERS
+TMAX    = 200;  % Maximal time unit
+DT      = 1e-2;  % Time step
+SPS0D   = 1;     % Sampling per time unit for profiler
+SPS2D   = 1;     % Sampling per time unit for 2D arrays
+SPS5D   = 1/50;  % Sampling per time unit for 5D arrays
+SPSCP   = 0;     % Sampling per time unit for checkpoints
+RESTART = 1;     % To restart from last checkpoint
+JOB2LOAD= 0;
+%% OPTIONS
+% SIMID   = ['HeLaZ_v2.5_eta_',num2str(ETAB),'_nu_%0.0e'];  % Name of the simulation
+% SIMID   = sprintf(SIMID,NU);
+SIMID   = 'izar_setup';  % Name of the simulation
+PREFIX  =[];
+% PREFIX  = sprintf('%d_%d_',NP_P, NP_KR);
+% (0 : L.Bernstein, 1 : Dougherty, 2: Sugama, 3 : Full Couloumb ; +/- for GK/DK)
+CO      = 1;
+CLOS    = 0;   % Closure model (0: =0 truncation, 1: semi coll, 2: Copy closure J+1 = J, P+2 = P)
+NL_CLOS = 1;   % nonlinear closure model (0: =0 nmax = jmax, 1: nmax = jmax-j, >1 : nmax = NL_CLOS)
+KERN    = 0;   % Kernel model (0 : GK)
+INIT_PHI= 1;   % Start simulation with a noisy phi and moments
+%% OUTPUTS
+W_DOUBLE = 1;
+W_GAMMA  = 1;
+W_PHI    = 1;
+W_NA00   = 1;
+W_NAPJ   = 1;
+W_SAPJ   = 0;
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% fixed parameters (for current study)
+KR0KH   = 0; A0KH = 0; % Background phi mode to drive Ray-Tay inst.
+KREQ0   = 0;      % put kr = 0
+KPAR    = 0.0;    % Parellel wave vector component
+LAMBDAD = 0.0;
+NON_LIN = 1 *(1-KREQ0);   % activate non-linearity (is cancelled if KREQ0 = 1)
+PMAXE   = P;    % Highest electron Hermite polynomial degree
+JMAXE   = J;     % Highest ''       Laguerre ''
+PMAXI   = P;     % Highest ion      Hermite polynomial degree
+JMAXI   = J;     % Highest ''       Laguerre ''
+kmax    = N*pi/L;% Highest fourier mode
+HD_CO   = 0.5;    % Hyper diffusivity cutoff ratio
+MU      = NU_HYP/(HD_CO*kmax)^4 % Hyperdiffusivity coefficient
+NOISE0  = 1.0e-5;
+ETAT    = 0.0;    % Temperature gradient
+ETAN    = 1.0;    % Density gradient
+TAU     = 1.0;    % e/i temperature ratio
+% Compute processes distribution
+Ntot = NP_P * NP_KR;
+Nnodes = ceil(Ntot/48);
+Nppn   = Ntot/Nnodes; 
+CLUSTER.NODES =  num2str(Nnodes);  % MPI process along p
+CLUSTER.NTPN  =  num2str(Nppn); % MPI process along kr
+CLUSTER.CPUPT = '1';        % CPU per task
+%% Run file management scripts
+setup
+write_sbash_izar
+system('rm fort.90 setup_and_run.sh batch_script.sh');
+disp('done');
+if(mod(NP_P*NP_KR,20)~= 0)
+    disp('WARNING : unused cores (ntot cores must be a 20 multiple)');
+end
\ No newline at end of file
-- 
GitLab