From 656f670b671296f61fc06751d9d14093eb2f4e83 Mon Sep 17 00:00:00 2001 From: Antoine Hoffmann <antoine.hoffmann@epfl.ch> Date: Fri, 3 May 2024 15:36:17 +0200 Subject: [PATCH] move scripts and improve them --- new_prob.sh | 32 ++-- .../parameter_files}/parameters_CBC.in | 0 scripts/parameter_files/parameters_Ricci.in | 93 +++++++++++ .../parameter_files}/parameters_Zpinch.in | 0 .../python_utilities/fourier.py | 0 .../python_utilities/load_data.py | 44 ++++- .../python_utilities/minimal_analysis.py | 2 +- scripts/python_utilities/movie.py | 86 ++++++++++ .../python_utilities/plot_stdout_fluxes.py | 17 +- .../python_utilities/tools.py | 3 +- .../shell_scripts}/continue.sh | 0 .../shell_scripts}/job_scan_pipeline.sh | 0 .../shell_scripts}/load_spcpc_modules.sh | 0 .../shell_scripts}/submit_marconi_example.cmd | 0 scripts/tutorials/spcpc_installation_auto.sh | 156 ++++++++++++++++++ .../spcpc_installation_procedure.md | 0 .../tutorials}/tutorial.md | 0 17 files changed, 398 insertions(+), 35 deletions(-) rename {basic_scripts => scripts/parameter_files}/parameters_CBC.in (100%) create mode 100644 scripts/parameter_files/parameters_Ricci.in rename {basic_scripts => scripts/parameter_files}/parameters_Zpinch.in (100%) rename {basic_scripts => scripts}/python_utilities/fourier.py (100%) rename {basic_scripts => scripts}/python_utilities/load_data.py (73%) rename {basic_scripts => scripts}/python_utilities/minimal_analysis.py (98%) create mode 100644 scripts/python_utilities/movie.py rename {basic_scripts => scripts}/python_utilities/plot_stdout_fluxes.py (67%) rename {basic_scripts => scripts}/python_utilities/tools.py (92%) rename {basic_scripts => scripts/shell_scripts}/continue.sh (100%) rename {basic_scripts => scripts/shell_scripts}/job_scan_pipeline.sh (100%) rename {basic_scripts => scripts/shell_scripts}/load_spcpc_modules.sh (100%) rename {basic_scripts => scripts/shell_scripts}/submit_marconi_example.cmd (100%) create mode 100644 scripts/tutorials/spcpc_installation_auto.sh rename {basic_scripts => scripts/tutorials}/spcpc_installation_procedure.md (100%) rename {basic_scripts => scripts/tutorials}/tutorial.md (100%) diff --git a/new_prob.sh b/new_prob.sh index d80a955..9375345 100644 --- a/new_prob.sh +++ b/new_prob.sh @@ -1,26 +1,31 @@ #!/bin/bash gyacomo_dir=$(pwd) -echo "Setup of a new problem in the simulations directory..." # Check if an argument is provided if [ $# -ne 1 ]; then - echo "- using CBC parameter" - echo " (you can ask for a Zpinch base case by adding "ZBC" after the call of the script)" - inputfile=$gyacomo_dir/basic_scripts/parameters_CBC.in + echo "- using 2D Z-pinch parameter" + echo " (you can ask for a cyclone base case by adding "CBC" after the call of the script)" + inputfile=$gyacomo_dir/scripts/parameter_files/parameters_Zpinch.in else # Check the value of the argument - if [ "$1" = "CBC" ]; then + if [ "$1" = "help" ]; then + echo "This script setup a new simulation directory in /simulation" + echo "The basic setup is a small 2D z-pinch simulation." + echo "You can ask a cyclone base case (more expensive) by typing sh new_prob.sh CBC" + exit 1 + elif [ "$1" = "CBC" ]; then echo "- using CBC parameter" - inputfile=$gyacomo_dir/basic_scripts/parameters_CBC.in + inputfile=$gyacomo_dir/scripts/parameter_files/parameters_CBC.in elif [ "$1" = "ZBC" ]; then echo "- using Zpinch parameter" - inputfile=$gyacomo_dir/basic_scripts/parameters_Zpinch.in + inputfile=$gyacomo_dir/scripts/parameter_files/parameters_Zpinch.in else - echo "- using CBC parameter" - echo "(you can ask for a Zpinch test by adding "ZBC" after the call of the script)" - inputfile=$gyacomo_dir/basic_scripts/parameters_CBC.in + echo "ERROR STOP unknown entry" + echo "(usage: sh new_prob.sh [CBC or ZBC (opt)])" + exit 1 fi fi +echo "Setup of a new problem in the simulations directory..." mkdir -p $gyacomo_dir/simulations cd $gyacomo_dir/simulations @@ -65,16 +70,17 @@ mkdir -p "$folder_name" cp $inputfile "$folder_name/params.in" # Copy the marconi job submission example -cp $gyacomo_dir/basic_scripts/submit_marconi_example.cmd "$folder_name/submit_marconi.cmd" +cp $gyacomo_dir/scripts/parameter_files/submit_marconi_example.cmd "$folder_name/submit_marconi.cmd" # Copy tutorial file -cp $gyacomo_dir/basic_scripts/tutorial.md "$folder_name/." +cp $gyacomo_dir/scripts/tutorials/tutorial.md "$folder_name/." # Create a symbolic link to the executable ln -s $gyacomo_dir/bin/gyacomo23_dp "$folder_name/gyacomo.exe" # Create a symbolic link to the basic python analysis script -ln -s $gyacomo_dir/basic_scripts/python_utilities/minimal_analysis.py "$folder_name/." +ln -s $gyacomo_dir/scripts/python_utilities/minimal_analysis.py "$folder_name/." +ln -s $gyacomo_dir/scripts/python_utilities/movie.py "$folder_name/." echo "- folder 'simulations/$folder_name' created with symbolic link to the executable." echo "- check the tutorial file in there!" diff --git a/basic_scripts/parameters_CBC.in b/scripts/parameter_files/parameters_CBC.in similarity index 100% rename from basic_scripts/parameters_CBC.in rename to scripts/parameter_files/parameters_CBC.in diff --git a/scripts/parameter_files/parameters_Ricci.in b/scripts/parameter_files/parameters_Ricci.in new file mode 100644 index 0000000..11f1ed7 --- /dev/null +++ b/scripts/parameter_files/parameters_Ricci.in @@ -0,0 +1,93 @@ +&BASIC + nrun = 99999999 ! number of time step to perform + dt = 0.00025 ! time step (not adaptive) + tmax = 0.5 ! maximal time [c_s/R] + maxruntime = 72000 ! maximal wallclock runtime [sec] + job2load = -1 ! index of the previous run to restart (-1:start a new run) + VERBOSE_LVL= -1 +/ +&GRID + pmax = 0 ! maximal degree of the Hermite basis (parallel velocity) + jmax = 0 ! maximal degree of the Laguerre basis (magnetic moment) + Nx = 186!186 ! number of points in the radial direction + Lx = 400 ! size of the box in the radial direction [rho_s] + Ny = 188!188 ! bumber of points in the binormal direction + Ly = 400 ! size of the box in the binormal direction [rho_s] + Nz = 1 ! number of points in the magnetic field direction + SG = .f. ! use a staggered grid in z (experimental) + Nexc = -1 ! to fullfill the sheared boundary condition (set -1 for automatic) +/ +&GEOMETRY + geom = 'Z-pinch' ! geometry model (Z-pinch,s-alpha,miller,circular) + q0 = 0.0 ! safety factor + shear = 0.0 ! magnetic shear + eps = 0.0 ! inverse aspect ratio + kappa = 1.0 ! elongation + s_kappa= 0.0 ! elongation derivative + delta = 0.0 ! triangularity + s_delta= 0.0 ! triangularity derivative + zeta = 0.0 ! squareness + s_zeta = 0.0 ! squareness derivative + parallel_bc = 'dirichlet' ! to change the type of parallel boundary condition (experimental) + shift_y= 0.0 ! to add a shift in the parallel BC (experimental) + Npol = 1.0 ! set the length of the z domain (-pi N_pol < z < pi N_pol) +/ +&DIAGNOSTICS + dtsave_0d = 0.01 ! period of 0D diagnostics (time traces) + dtsave_1d = -1 ! period of 1D diagnostics (nothing) + dtsave_2d = -1 ! period of 2D diagnostics (nothing) + dtsave_3d = 0.005 ! period of 3D diagnostics (phi, Aparallel, fluid moments etc.) + dtsave_5d = 10 ! period of 5D diagnostics (full set of GMs) +/ +&MODEL + LINEARITY = 'nonlinear' ! set if we solve the linear or nonlinear problem + Na = 2 ! number of species (this sets the number of species namelists to be read) + mu_x = 10.0 ! numerical diffusion parameter in the radial direction + mu_y = 10.0 ! numerical diffusion parameter in the binormal direction + N_HD = 2 ! degree of the numerical diffusion + mu_z = 0.0 ! numerical diffusion parameter in the parallel direction (fourth order only) + HYP_V = 'hypcoll' ! numerical diffusion scheme in the velocity space (experimental) + mu_p = 0.0 ! numerical diffusion parameter in the parallel velocity (experimental) + mu_j = 0.0 ! numerical diffusion parameter in the magnetic moment (experimental) + nu = 0.0 ! collision rate, ~0.5 GENE parameter (better to use it instead of num. diff. in velocities) + beta = 0.0 ! plasma beta (not in percent) + ADIAB_E = .f. ! Use an adiabatic electron model (required if Na = 1) + ADIAB_I = .f. ! Use an adiabatic ion model (experimental) + ExBrate = 0 + k_gB = 1 + k_cB = 1 +/ +&CLOSURE + hierarchy_closure='truncation' ! closure scheme + dmax = -1 ! set the maximal degree of moment to evolve (-1 evolves all th) + nonlinear_closure='anti_laguerre_aliasing' ! set the truncation of the Laguerre convolution (truncation,full_sum,anti_laguerre_aliasing) + nmax = -1 ! set the maximal degree in the truncation of the Laguerre convolution (experimental) +/ +&SPECIES ! Defines the species a (out of Na species) + name_ = 'ions' ! name of the species a + tau_ = 1.0 ! temperature (Ta/Te) + sigma_= 1.0 ! sqrt mass ratio (sqrt(ma/mi)) + q_ = 1.0 ! charge (qa/e) + k_N_ = 0.0 ! density background gradient, grad ln N (omn in GENE) + k_T_ = 0.0 ! temperature background gradient, grad ln T (omT in GENE) +/ +&SPECIES ! defines electrons (if not, use ADIAB_E = true) + ! electrons + name_ = 'electrons' + tau_ = 1.0 + sigma_= 0.075 + q_ =-1.0 + k_N_ = 0.0 + k_T_ = 0.0 +/ +&COLLISION + collision_model = 'DG' !LB/DG/SG/PA/LD (Lenhard-Bernstein, Dougherty, Sugama, pitch angle, Landau) + GK_CO = .f. ! gyrokinetic version of the collision operator (or longwavelength only) +/ +&INITIAL + INIT_OPT = 'ricci' ! initilization of the system ('phi' put noise in electrostatic, 'blob' is like 'ppj' in GENE) + init_amp = 100 +/ +&TIME_INTEGRATION + numerical_scheme = 'RK3' ! numerical scheme for time integration (RK2,3,4 etc.) +/ diff --git a/basic_scripts/parameters_Zpinch.in b/scripts/parameter_files/parameters_Zpinch.in similarity index 100% rename from basic_scripts/parameters_Zpinch.in rename to scripts/parameter_files/parameters_Zpinch.in diff --git a/basic_scripts/python_utilities/fourier.py b/scripts/python_utilities/fourier.py similarity index 100% rename from basic_scripts/python_utilities/fourier.py rename to scripts/python_utilities/fourier.py diff --git a/basic_scripts/python_utilities/load_data.py b/scripts/python_utilities/load_data.py similarity index 73% rename from basic_scripts/python_utilities/load_data.py rename to scripts/python_utilities/load_data.py index 938f679..6b3825f 100644 --- a/basic_scripts/python_utilities/load_data.py +++ b/scripts/python_utilities/load_data.py @@ -1,6 +1,7 @@ import h5py import numpy as np import tools + def load_data_0D(filename,dname): with h5py.File(filename, 'r') as file: # Load time data @@ -19,12 +20,22 @@ def load_data_3D_frame(filename,dname,tframe): iframe = tools.closest_index(time,tframe) tf = time[iframe] # Load data - if dname == 'Ni00': - data = file[f'data/var3d/Na00/{iframe:06d}'] + try: + data = file[f'data/var3d/{dname}/{iframe:06d}'] + except: + g_ = file[f'data/var3d/'] + print('Dataset: '+f'data/var3d/{dname}/{iframe:06d}'+' not found') + print('Available fields: ') + msg = '' + for key in g_: + msg = msg + key + ', ' + print(msg) + exit() + # Select the first species for species dependent fields + if not (dname == 'phi' or dname == 'psi'): data = data[:,:,:,0] else: - data = file[f'data/var3d/{dname}/{iframe:06d}'] - data = data[:] + data = data[:] data = data['real']+1j*data['imaginary'] # Load the grids kxgrid = file[f'data/grid/coordkx'] @@ -58,6 +69,15 @@ def load_group(filename,group): data[key] = file.get(name)[:] return data +def load_3Dfield(filename,field): + data = {} + with h5py.File(filename, 'r') as file: + g_ = file[f"data/var3d/"+field] + for key in g_.keys(): + name='data/var3d/'+field+'/'+key + data[key] = file.get(name)[:] + return data + def load_params(filename): with h5py.File(filename, 'r') as file: nml_str = file[f"files/STDIN.00"][0] @@ -91,4 +111,18 @@ def read_namelist(nml_str): all_namelists[current_namelist][key] = float(value) else: all_namelists[current_namelist][key] = value - return all_namelists \ No newline at end of file + return all_namelists + +def read_data_std(filename): + t_values = [] + Pxi_values = [] + Qxi_values = [] + dict = {"t":[],"Pxi":[],"Pxe":[],"Qxi":[],"Qxe":[]} + with open(filename, 'r') as file: + for line in file: + a = line.split('|') + for i in a[1:-1]: + b = i.split('=') + dict[b[0].strip()].append(float(b[1])) + + return dict \ No newline at end of file diff --git a/basic_scripts/python_utilities/minimal_analysis.py b/scripts/python_utilities/minimal_analysis.py similarity index 98% rename from basic_scripts/python_utilities/minimal_analysis.py rename to scripts/python_utilities/minimal_analysis.py index a850684..5a00a82 100644 --- a/basic_scripts/python_utilities/minimal_analysis.py +++ b/scripts/python_utilities/minimal_analysis.py @@ -38,7 +38,7 @@ t0D, hflux_x = loader.load_data_0D(filename,'hflux_x') t0D, pflux_x = loader.load_data_0D(filename,'pflux_x') # 3D fields (phi and first gyromoment) t3D, phi, tf = loader.load_data_3D_frame(filename,'phi',10000) -t3D, Ni00,tf = loader.load_data_3D_frame(filename,'Ni00',10000) +t3D, Ni00,tf = loader.load_data_3D_frame(filename,'Na00',10000) # grids of the simulation x,kx,y,ky,z,p,j = loader.load_grids(filename) diff --git a/scripts/python_utilities/movie.py b/scripts/python_utilities/movie.py new file mode 100644 index 0000000..ddbd7d0 --- /dev/null +++ b/scripts/python_utilities/movie.py @@ -0,0 +1,86 @@ +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation +import load_data as loader +from matplotlib.widgets import Slider +import sys +import tools + +def update_mov(frame): + # plt.imshow(data[:, :, frame], cmap='gray',interpolation='quadric') + return [data[:, :, frame]] + +def update_slide(val): + frame = int(slider.val) + im.set_data(data[:, :, frame]) + fig.canvas.draw_idle() + +# Parameters (default values) +option = 'movie' +filename = 'outputs_00.h5' +fieldname = 'Tpar' +if len(sys.argv) > 1: + option = sys.argv[1] + if option == 'help': + print("This script produces a movie of a field in a 2D perpendicular plane") + print("Usage: python3 movie.py [movie/slider (opt), outfilename (opt), phi/dens/Tpar etc. (opt)]") + sys.exit(1) +if len(sys.argv) > 2: + filename = sys.argv[2] +if len(sys.argv) > 3: + fieldname = sys.argv[3] +if len(sys.argv) > 4: + print("Usage: python3 movie.py [movie/slider (opt), outputs_XX.h5 (opt), phi/dens/Tpar etc. (opt)]") + sys.exit(1) + +# Load grids +x,kx,y,ky,z,p,j = loader.load_grids(filename) +x0 = x[0]; x1 = x[-1]; y0 = y[0]; y1 = y[-1] +# Load first frame +t3D, field, tf = loader.load_data_3D_frame(filename,fieldname,0) +field = tools.zkxky_to_xy_const_z(field,-1) +shape = np.shape(field) +Nt = np.size(t3D) +# Build the movie +data = np.zeros([shape[0],shape[1],Nt]) +it = 0 +for t_ in t3D: + t3D, field, tf = loader.load_data_3D_frame(filename,fieldname,t_) + field = tools.zkxky_to_xy_const_z(field,-1) + fmax = np.max(np.abs(field)) + if fmax == 0: fmax = 1 + data[:,:,it] = field/fmax + it = it + 1 + +# Create figure and axis +fig, ax = plt.subplots() +plt.title(fieldname) +plt.xlabel(r'$x/\rho_s$') +plt.ylabel(r'$y/\rho_s$') + +# Display the first frame +im = ax.imshow(data[:, :, 0], cmap='seismic',interpolation='quadric',extent=[x0,x1,y0,y1]) +im.set_clim(-1, 1) + +if option == 'movie' or option == 'save': + # Define the animation + # ani = animation.FuncAnimation(fig, update_mov, frames=data.shape[2], interval=50) + ims = [] + for i in range(Nt): + im = ax.imshow(data[:, :, i], cmap='seismic',interpolation='quadric',extent=[x0,x1,y0,y1]) + ims.append([im]) + ani = animation.ArtistAnimation(fig, ims, interval=50, blit=True) +elif option == 'slider': + # Add slider widget + slider_ax = plt.axes([0.1, 0.01, 0.8, 0.03]) + slider = Slider(slider_ax, 'Time', 0, data.shape[2]-1, valinit=0, valstep=t3D[1]-t3D[0]) + slider.on_changed(update_slide) +else: + print("Usage: python3 movie.py [movie, slider (opt)]") + sys.exit(1) + +if option == 'save': + ani.save('movie_'+fieldname+'.mov', fps=30) + +# Show the animation +plt.show() \ No newline at end of file diff --git a/basic_scripts/python_utilities/plot_stdout_fluxes.py b/scripts/python_utilities/plot_stdout_fluxes.py similarity index 67% rename from basic_scripts/python_utilities/plot_stdout_fluxes.py rename to scripts/python_utilities/plot_stdout_fluxes.py index 04835c9..cce127a 100644 --- a/basic_scripts/python_utilities/plot_stdout_fluxes.py +++ b/scripts/python_utilities/plot_stdout_fluxes.py @@ -1,20 +1,7 @@ import sys import re import matplotlib.pyplot as plt - -def read_data(filename): - t_values = [] - Pxi_values = [] - Qxi_values = [] - dict = {"t":[],"Pxi":[],"Pxe":[],"Qxi":[],"Qxe":[]} - with open(filename, 'r') as file: - for line in file: - a = line.split('|') - for i in a[1:-1]: - b = i.split('=') - dict[b[0].strip()].append(float(b[1])) - - return dict +import load_data as loader if __name__ == "__main__": if len(sys.argv) != 2: @@ -22,7 +9,7 @@ if __name__ == "__main__": sys.exit(1) filename = sys.argv[1] - dict = read_data(filename) + dict = loader.read_data_std(filename) time = dict["t"] dict.pop('t',None) diff --git a/basic_scripts/python_utilities/tools.py b/scripts/python_utilities/tools.py similarity index 92% rename from basic_scripts/python_utilities/tools.py rename to scripts/python_utilities/tools.py index 3504bc6..f25e46a 100644 --- a/basic_scripts/python_utilities/tools.py +++ b/scripts/python_utilities/tools.py @@ -11,6 +11,7 @@ def zkxky_to_xy_const_z(array, iz): array = fourier.kx_to_x(array,Nkx,-2) array = fourier.ky_to_y(array,Nky-1,-1) array = np.transpose(array) + array = np.flip(np.fft.fftshift(array)) return array def closest_index(array, v): @@ -19,7 +20,7 @@ def closest_index(array, v): # Find the index of the minimum difference closest_index = np.argmin(absolute_diff) - + closest_index = max(closest_index,1) return closest_index def is_convertible_to_float(s): diff --git a/basic_scripts/continue.sh b/scripts/shell_scripts/continue.sh similarity index 100% rename from basic_scripts/continue.sh rename to scripts/shell_scripts/continue.sh diff --git a/basic_scripts/job_scan_pipeline.sh b/scripts/shell_scripts/job_scan_pipeline.sh similarity index 100% rename from basic_scripts/job_scan_pipeline.sh rename to scripts/shell_scripts/job_scan_pipeline.sh diff --git a/basic_scripts/load_spcpc_modules.sh b/scripts/shell_scripts/load_spcpc_modules.sh similarity index 100% rename from basic_scripts/load_spcpc_modules.sh rename to scripts/shell_scripts/load_spcpc_modules.sh diff --git a/basic_scripts/submit_marconi_example.cmd b/scripts/shell_scripts/submit_marconi_example.cmd similarity index 100% rename from basic_scripts/submit_marconi_example.cmd rename to scripts/shell_scripts/submit_marconi_example.cmd diff --git a/scripts/tutorials/spcpc_installation_auto.sh b/scripts/tutorials/spcpc_installation_auto.sh new file mode 100644 index 0000000..c130830 --- /dev/null +++ b/scripts/tutorials/spcpc_installation_auto.sh @@ -0,0 +1,156 @@ +#! /bin/bash +# This tutorial helps you install Gyacomo on an SPC medusa PC, based on OpenSUSE and intel compiler. You will be guided from the cloning of the repository to the first run. + +echo '==============================================' +echo ' ______ ' +echo ' / ____/_ ______ __________ ____ ___ ____ ' +echo ' / / __/ / / / __ `/ ___/ __ \/ __ `__ \/ __ \' +echo '/ /_/ / /_/ / /_/ / /__/ /_/ / / / / / / /_/ /' +echo '\____/\__, /\__,_/\___/\____/_/ /_/ /_/\____/ ' +echo ' /____/ ' +echo 'This is the GYACOMO code auto installer' +echo '==============================================' + +# 1. Prelude +# 1.1 - First, we clone the repository. +echo -- 1. Clone the directory +git clone https://gitlab.epfl.ch/ahoffman/gyacomo.git > gyacomo_clone.out +cd gyacomo + +# 1.2 - Then we purge and load the following modules (the default one may be of older intel compiler version, which will not work with FFTW3). +echo -- Purge and load the modules +module purge +module load intel_comp/19.1 impi/5.0.3 mumps/4.10.0 hdf5/1.8.9 + +# 1.3 - Now we navigate to the `gyacomo` directory. +# cd gyacomo + +# 1.4 - Finally, we make a `lib` directory (here we make it in `/gyacomo` but it can be anywhere as long as the path to it is set correctly in `gyacomo/local/dirs.inc`). +echo -- make lib directory +mkdir lib +# **Important:** Verify that the `gyacomo/local/dirs.inc` file points to your `gyacomo` folder in the `PREFIX` variable and to your `lib` folder in the `LIBDIR` variable. + +# 1.5 - We can do a first test the installation and linkage by typing `make` in `/gyacomo`. The compilation should halt with an error at the call of `futils` routines in `src/parallel_mod.F90`. This is normal, let us continue. + +## Install Libraries +# Now you will be guided to install the three libraries required by Gyacomo: +# - Futils, a wrapper library to handle easily h5 outputs (developped by T.M.Tran at SPC) +# - FM, an arbitrary precision library used to compute the Laguerre-Laguerre product coefficients `$d_{njs}$` without accuracy loss (see [coeff module](Sources/coeff)). +# - FFTW3, the Fastest Fourier Transform in the West version 3, which enables us to compute the nonlinear term using a pseudo-spectral approach (see [fourier module](Sources/fourier)). +# Each of these libraries must be installed in the `/lib` folder (here `/gyacomo/lib`). + +### 2. Futils installation +# 2.1 - We navigate to our `lib` folder and clone first the `futils` library. +echo -- 2. Installing Futils +cd lib +git clone https://c4science.ch/diffusion/FUTILS/futils.git > futils_clone.out +# **Note:** if you do not have the access, contact me and I will provide a .zip file. + +# 2.2 - Then, we navigate to the `src` directory. +cd futils/src + +# 2.3 - You have to adapt the makefile because some compilation options are not available with the intel compiler (we put a simple -O3 option). +sed -i '37s/.*/OPT = -O3/' Makefile +# **Note:** the Makefile is also assuming that the Hdf5 library path is stored in a `$(HDF5)` variable and that the `mpif90` compiler is defined. If you are on Marconi HPCC, you may have to change line 34 to `F90 = mpiifort` and line 35 to `HDF5 = $(HDF5_HOME)` (having prealably loaded the Hdf5 module) + +# 2.4 - We can now compile the library. +make lib + +# 2.5 - We create necessary directories to store our library files. +mkdir -p include/O +mkdir -p include/g +mkdir -p lib/O +mkdir -p lib/g + +# 2.6 - Time now to install the library (this will put the library files in the previously made directories). +echo -- compiling... +make install > futils_make_install.out + +# 2.7 - We can test now the installation and linkage of futils by typing `make` in `/gyacomo`. The compilation should pass the previously observed error and halt now with an error at the call of `fftw` routines in `src.fourier_mod.F90`. +echo -- ----Futils installed---- +cd ../../ + +### 3. FFTW3 installation +echo -- 3. Installing FFTW3 +# 3.1 - We download the `fftw` zip directory, unzip it, and navigate to the directory. +wget http://www.fftw.org/fftw-3.3.10.tar.gz > wget_fftw3.out +tar -xvf fftw-3.3.10.tar.gz > tar_fftw3.out +cd fftw-3.3.10 + +# 3.2 - We configure the installation and make the double-precision version. +echo -- configure double precision mpi... +./configure --enable-mpi --prefix=$PWD > configure_mpi.out +echo -- compile double precision mpi... +make > make.out + +# 3.3 - We can now install it. +echo -- installing... +make install > make_install.out + +# 3.4 - For single-precision runs, we also configure and install the single-precision version. +echo -- configure single precision mpi... +./configure --enable-float --enable-mpi --prefix=$PWD > configure_float.out +echo -- compile single precision mpi... +make > make_float.out +echo -- installing... +make install > make_install_float.out + +# 3.5 - We gather the library files in a new `lib` subdirectory. +mkdir lib +cp lib64/* lib/. +cp *.la lib/. + +# 3.7 - We go back to `/gyacomo` and verify that `FFTW3DIR = $(LIBDIR)/fftw-3.3.10` in `/gyacomo/local/dirs.inc` when `ENVTYPE = Linux`. +cd ../ + +# 3.8 - We test the installation and linkage by typing `make` in `/gyacomo`. The compilation should halt with an error at the call of `FM` routines in the `src/coeff_mod.F90` file. +echo -- ----FFTW3 installed---- + +## 4. FM installation +echo -- ----Installing FM---- + +# 4.1 - Navigate back to the main `lib` directory (e.g., `/gyacomo/lib/`) and download the zipped folder. +wget https://dmsmith.lmu.build/FM1.4/FM_files.zip > wget_FM.out + +# 4.2 - Unzip and enter the folder. +unzip FM_files.zip > unzip_FM.out +mv FM_files FM +cd FM + +# 4.3 - Copy the source file with a `.f95` to `.F90`extension. This is required to use the intel compiler (gfortran compilation here will not work if Gyacomo is compiled with mpiifort). +for file in *.f95 ; do cp "$file" "${file%.*}.F90" ; done + +# 4.4 - We compile manually (some compilation may take ~5min). +echo '-- compiling... (give it 5min)' +ifort fmsave.F90 -c -O3 +ifort fm.F90 -c -O3 +ifort fmzm90.F90 -c -O3 +ifort TestFM.F90 -c -O3 +ifort SampleFM.F90 -c -O3 +ifort fmsave.o fm.o fmzm90.o TestFM.o -o TestFM +ifort fmsave.o fm.o fmzm90.o SampleFM.o -o SampleFM +echo -- done +# 4.5 We can test the installation. +./TestFM +./SampleFM + +# 4.6 The library file is put together and moved to a local `lib` directory. +mkdir lib +ar r libfm.a fm.o fmsave.o fmzm90.o +mv libfm.a lib + +# 4.7 Move the `.mod` files to a `mod` local directory. +mkdir mod +mv *.mod mod + +cd ../ + +# 5 compilation of GYACOMO +cd ../ +echo -- we now compile the code... +make +echo -- done +make new_prob +echo -- ------ +echo -- GYACOMO is ready, you can test running it in simulations/problem_01 +echo -- ------ \ No newline at end of file diff --git a/basic_scripts/spcpc_installation_procedure.md b/scripts/tutorials/spcpc_installation_procedure.md similarity index 100% rename from basic_scripts/spcpc_installation_procedure.md rename to scripts/tutorials/spcpc_installation_procedure.md diff --git a/basic_scripts/tutorial.md b/scripts/tutorials/tutorial.md similarity index 100% rename from basic_scripts/tutorial.md rename to scripts/tutorials/tutorial.md -- GitLab