diff --git a/.gitignore b/.gitignore
index 797747aa16a2fb9000f5268a91f10e289e07f077..77346fd87e48eca5a70138537312d012fec11328 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
 *.o
+.DS_Store 
+sync.sh
 phase_correction.c
 w-stacking.c
 w-stackingCfftw
diff --git a/Build/Makefile.Magellanus b/Build/Makefile.Magellanus
new file mode 100644
index 0000000000000000000000000000000000000000..c440365f48bd8bc2cbe33011ccaec061bdadb245
--- /dev/null
+++ b/Build/Makefile.Magellanus
@@ -0,0 +1,32 @@
+CC       =  gcc-10
+CXX      =  g++-10
+
+MPICC    =  mpicc
+MPIC++   =  mpiCC
+
+OPTIMIZE =  -O3
+#-ffast-math  -fopt-info-all-omp -fcf-protection=none -fno-stack-protector -foffload=nvptx-none
+
+
+GSL_INCL =  -I/home/taffoni/sw/include #-I/opt/cluster/openmpi/3.1.3/gnu/8.2.0/include
+GSL_LIBS =  -L/home/taffoni/sw/lib #-L/opt/cluster/openmpi/3.1.3/gnu/8.2.0/lib -lmpi
+
+FFTW_INCL=  -I/home/taffoni/sw/include
+FFTW_LIB=  -L/home/taffoni/sw/lib   -lfftw3_mpi -lfftw3
+
+MPI_LIB =
+MPI_INCL=
+HDF5_INCL =
+HDF5_LIB  =
+
+OMP = -fopenmp
+
+NVCC = nvcc
+NVFLAGS = -arch=sm_70 -Xcompiler -std=c++11
+NVLIB = -L/home/taffoni/sw/Linux_x86_64/21.5/cuda/11.3/lib64/ -lcudart -lcuda
+
+CFLAGS += $(OPTIMIZE)
+CFLAGS += -I.
+CFLAGS += -I/home/taffoni/sw/Linux_x86_64/21.5/comm_libs/mpi/include
+CFLAGS += $(FFTW_INCL) $(GSL_INCL)
+CFLAGS += $(FFTW_LIB) -lm
diff --git a/Build/Makefile.Marconi b/Build/Makefile.Marconi
new file mode 100644
index 0000000000000000000000000000000000000000..4fb0d034f58b6a585c7c8846b694822c869ee7d7
--- /dev/null
+++ b/Build/Makefile.Marconi
@@ -0,0 +1,20 @@
+CC       =  gcc
+CXX      =  g++
+
+MPICC    =  mpicc
+MPIC++   =  mpiCC
+
+
+CFLAGS += -O3 -mcpu=native
+CFLAGS += -I.
+FFTW_INCL=  -I/home/taffoni/sw/include
+FFTW_LIB=  -L/home/taffoni/sw/lib 
+
+LIBS = $(FFTW_LIB) -lfftw3_mpi -lfftw3 -lm
+
+NVCC = nvcc
+NVFLAGS = -arch=sm_70 -Xcompiler -mno-float128 -std=c++11
+NVLIB = -L/cineca/prod/opt/compilers/cuda/10.1/none/lib64/ -lcudart -lcuda
+
+
+CFLAGS += -O3 -mtune=native
diff --git a/Build/Makefile.systype b/Build/Makefile.systype
new file mode 100644
index 0000000000000000000000000000000000000000..04922322304924d1c8a5397ede089516d9a1d256
--- /dev/null
+++ b/Build/Makefile.systype
@@ -0,0 +1,24 @@
+CC       =  gcc-10
+CXX      =  g++-10
+
+MPICC    =  mpicc
+MPIC++   =  mpiCC
+
+OPTIMIZE =
+
+
+GSL_INCL =
+GSL_LIB =
+
+FFTW_INCL=
+FFTW_LIB=
+
+NVCC =
+NVFLAGS =
+NVLIB =
+
+CFLAGS +=
+
+MPICHLIB =
+HDF5INCL =
+HDF5LIB  =
diff --git a/Makefile b/Makefile
index 80ba945444a7f245e0d947789cc977ce4b5d8cc0..b0667357d1d1879ff93abdf7c6b447aa894dfb7b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,30 @@
 # comment/uncomment the various options depending hoe you want to build the program
+# Set default values for compiler options if no systype options are given or found
+CC        = mpiCC
+CXX       = mpiCC
+OPTIMIZE  = -std=c++11 -Wall -g -O2
+MPICHLIB  = -lmpich
+SWITCHES =
+
+ifdef SYSTYPE
+SYSTYPE := $(SYSTYPE)
+include Build/Makefile.$(SYSTYPE)
+else
+include Build/Makefile.systype
+endif
+
+
+
+
+
 # create MPI code
 OPT += -DUSE_MPI
+
 # use FFTW (it can be switched on ONLY if MPI is active)
-OPT += -DUSE_FFTW
+ifeq (USE_MPI,$(findstring USE_MPI,$(OPT)))
+   OPT += -DUSE_FFTW
+endif
+
 # perform one-side communication (suggested) instead of reduce (only if MPI is active)
 OPT += -DONE_SIDE
 # write the full 3D cube of gridded visibilities and its FFT transform
@@ -12,23 +34,6 @@ OPT += -DWRITE_IMAGE
 # perform w-stacking phase correction
 # OPT += PHASE_ON
 
-CC = gcc
-CXX = g++
-ifeq (USE_MPI,$(findstring USE_MPI,$(OPT)))
-  CC = mpicc
-  CXX = mpiCC 
-endif
-
-OMP = -fopenmp 
-#OMP = 
-
-CFLAGS += -O3 -mcpu=native
-CFLAGS += -I.
-LIBS = -L$(FFTW_LIB) -lfftw3_mpi -lfftw3 -lm
-
-NVCC = nvcc
-NVFLAGS = -arch=sm_70 -Xcompiler -mno-float128 -std=c++11
-NVLIB = -L/cineca/prod/opt/compilers/cuda/10.1/none/lib64/ -lcudart -lcuda
 
 DEPS = w-stacking.h w-stacking-fftw.c w-stacking.cu phase_correction.cu
 COBJ = w-stacking.o w-stacking-fftw.o phase_correction.o
@@ -39,27 +44,31 @@ w-stacking.c: w-stacking.cu
 phase_correction.c: phase_correction.cu
 	cp phase_correction.cu phase_correction.c
 
+ifeq (USE_MPI,$(findstring USE_MPI,$(OPT)))
+%.o: %.c $(DEPS)
+	$(MPICC)  -c -o $@ $< $(CFLAGS) $(OPT)
+else
 %.o: %.c $(DEPS)
 	$(CC) $(OMP) -c -o $@ $< $(CFLAGS) $(OPT)
+endif
 
 serial: $(COBJ)
-	$(CC) $(OMP) -o w-stackingCfftw_serial $(CFLAGS) $^ -lm
+	$(CC)  -o w-stackingCfftw_serial $(CFLAGS) $^ -lm
 
 serial_cuda:
 	$(NVCC) $(NVFLAGS) -c w-stacking.cu phase_correction.cu $(NVLIB)
 	$(CC) $(CFLAGS) $(OPT) -c w-stacking-fftw.c
 	$(CXX) $(CFLAGS) $(OPT) -o w-stackingfftw_serial w-stacking-fftw.o w-stacking.o phase_correction.o $(NVLIB) -lm
 
-mpi: $(COBJ) 
-	$(CC) $(OMP) -o w-stackingCfftw $(CFLAGS) $^ $(LIBS)
+mpi: $(COBJ)
+	$(MPICC) -o w-stackingCfftw   $^ $(CFLAGS)
 
 mpi_cuda:
 	$(NVCC) $(NVFLAGS) -c w-stacking.cu phase_correction.cu $(NVLIB)
-	$(CC) $(CFLAGS) $(OPT) -c w-stacking-fftw.c
-	$(CXX) $(CFLAGS) $(OPT) -o w-stackingfftw w-stacking-fftw.o w-stacking.o phase_correction.o $(NVLIB) $(LIBS) -lm
+	$(MPICC) $(CFLAGS) $(OPT) -c w-stacking-fftw.c
+	$(MPIC++)  $(OPT)   -o w-stackingfftw w-stacking-fftw.o w-stacking.o phase_correction.o $(NVLIB) $(CFLAGS)
 
 clean:
 	rm *.o
 	rm w-stacking.c
 	rm phase_correction.c
-
diff --git a/scripts/gridfftbin.m b/scripts/gridfftbin.m
index d948638fdc3324cb4c0aad449c90c70b6b9fae09..b4bc237f7d2c3c65e1bc0b309ef5d9c3b18810cb 100644
--- a/scripts/gridfftbin.m
+++ b/scripts/gridfftbin.m
@@ -10,7 +10,8 @@ nplanes = 1;
 % id = '4';
 suffix = '';
 id = '';
-datadir = "/Users/cgheller/Work/Gridding/data/";
+d
+atadir = "/Users/cgheller/Work/Gridding/data/";
 filename1 = strcat(datadir,"fft_real",suffix,id,'.bin');
 filename2 = strcat(datadir,"fft_img",suffix,id,'.bin');
 s = dir(filename1);
@@ -52,4 +53,3 @@ xlabel('cell');
 ylabel('cell');
 pngimage = strcat(datadir,'fft-2freq',suffix,id,'.png');
 saveas(gcf,pngimage);
-
diff --git a/scripts/plotgrid.py b/scripts/plotgrid.py
new file mode 100644
index 0000000000000000000000000000000000000000..2cf1bab67a5c54c9befd586a414eb160fa88800e
--- /dev/null
+++ b/scripts/plotgrid.py
@@ -0,0 +1,27 @@
+#!/usr/bin/python3
+import numpy as np
+import matplotlib.pyplot as plt
+filename1 = "fft_real.bin"
+filename2 = "fft_img.bin"
+nplanes = 1
+
+with open(filename1, 'rb') as f1:
+    vreal  = np.fromfile(f1, dtype=np.float64)
+with open(filename2, 'rb') as f2:
+    vimg  = np.fromfile(f2, dtype=np.float64)
+
+xaxis = int(np.sqrt(vreal.size))
+yaxes = xaxis
+residual = np.vectorize(complex)(vreal, vimg)
+
+cumul2d = residual.reshape((xaxis,yaxes,nplanes), order='F')
+for i in range(nplanes):
+    gridded = np.squeeze(cumul2d[:,:,i])
+    ax = plt.subplot()
+    img = ax.imshow(np.abs(np.fft.fftshift(gridded)), aspect='auto', interpolation='none', origin='lower')
+    ax.set_xlabel('cell')
+    ax.set_ylabel('cell')
+    cbar = plt.colorbar(img)
+    cbar.set_label('norm(FFT)',size=18)
+    figname='grid_image_' + str(i) + '.png'
+    plt.savefig(figname)