├── Makefile.inc ├── README.md ├── diffusion ├── Makefile ├── answer │ ├── Makefile │ ├── diffusionc-mpi-nonblocking.c │ ├── diffusionc-mpi.c │ └── diffusionf-mpi.f90 ├── diffusion.c └── diffusion.f90 ├── hydroc ├── Makefile ├── allocmultid.c ├── allocmultid.h ├── answer │ ├── Makefile │ ├── allocmultid.c │ ├── allocmultid.h │ ├── hydro.c │ ├── plot.c │ ├── plot.h │ ├── ppm.c │ ├── ppm.h │ ├── solver.c │ └── solver.h ├── hydro.c ├── mpi │ ├── Makefile │ ├── allocmultid.c │ ├── allocmultid.h │ ├── hydro.c │ ├── plot.c │ ├── plot.h │ ├── ppm.c │ ├── ppm.h │ ├── solver.c │ └── solver.h ├── plot.c ├── plot.h ├── ppm.c ├── ppm.h ├── solver.c └── solver.h ├── hydrof ├── Makefile ├── answer │ ├── Makefile │ ├── hydro.f90 │ ├── plot.f90 │ ├── ppm.f90 │ └── solver.f90 ├── hydro.f90 ├── mpi │ ├── Makefile │ ├── hydro.f90 │ ├── plot.f90 │ ├── ppm.f90 │ └── solver.f90 ├── plot.f90 ├── ppm.f90 └── solver.f90 ├── mpi-intro ├── .diffusion.f.swp ├── Makefile ├── fifthmessage.c ├── minmeanmax-allreduce.f90 ├── minmeanmax-mpi.c ├── minmeanmax-mpi.f90 ├── minmeanmax.c ├── minmeanmax.f90 ├── secondmessage.c └── secondmessage.f90 ├── nbodyc ├── Makefile ├── allocmultid.c ├── allocmultid.h ├── nbody.c ├── nbody_omp.c └── nox ├── nbodyf ├── Makefile └── nbody.f90 ├── presentation ├── images │ ├── Another_collective_operation.png │ ├── BUFFERING.png │ ├── Communicators_1.png │ ├── Communicators_2.png │ ├── Create_new_communicator_with_new_topology.png │ ├── Cute_way_for_Periodic_BCs.png │ ├── Data_dependencies.png │ ├── Data_structure-1.png │ ├── Data_structure-2.png │ ├── Discretizing_Derivatives (2).png │ ├── Discretizing_Derivatives.png │ ├── Displaying_Data.png │ ├── Equations_of_Hydrodynamics.png │ ├── Finite_Volume_Method.png │ ├── Guard_cell_fill.png │ ├── Guardcells (2).png │ ├── Guardcells-2.png │ ├── How_would_we_get_this_data_Allgather.png │ ├── Implementing_in_MPI-10.png │ ├── Implementing_in_MPI-11.png │ ├── Implementing_in_MPI-12.png │ ├── Implementing_in_MPI-13.png │ ├── Implementing_in_MPI-14.png │ ├── Implementing_in_MPI-15.png │ ├── Implementing_in_MPI-16.png │ ├── Implementing_in_MPI-17.png │ ├── Implementing_in_MPI-18.png │ ├── Implementing_in_MPI-19.png │ ├── Implementing_in_MPI-2.png │ ├── Implementing_in_MPI-20.png │ ├── Implementing_in_MPI-21.png │ ├── Implementing_in_MPI-22.png │ ├── Implementing_in_MPI-23.png │ ├── Implementing_in_MPI-24.png │ ├── Implementing_in_MPI-25.png │ ├── Implementing_in_MPI-26.png │ ├── Implementing_in_MPI-28.png │ ├── Implementing_in_MPI-29.png │ ├── Implementing_in_MPI-3.png │ ├── Implementing_in_MPI-30.png │ ├── Implementing_in_MPI-31.png │ ├── Implementing_in_MPI-32.png │ ├── Implementing_in_MPI-33.png │ ├── Implementing_in_MPI-34.png │ ├── Implementing_in_MPI-35.png │ ├── Implementing_in_MPI-36.png │ ├── Implementing_in_MPI-37.png │ ├── Implementing_in_MPI-38.png │ ├── Implementing_in_MPI-39.png │ ├── Implementing_in_MPI-4.png │ ├── Implementing_in_MPI-40.png │ ├── Implementing_in_MPI-41.png │ ├── Implementing_in_MPI-42.png │ ├── Implementing_in_MPI-5.png │ ├── Implementing_in_MPI-6.png │ ├── Implementing_in_MPI-7.png │ ├── Implementing_in_MPI-8.png │ ├── Implementing_in_MPI-9.png │ ├── Implementing_in_MPI.png │ ├── Implementing_in_MPI_1.png │ ├── Implementperiodicboundary.png │ ├── Laid_out_in_memory_(C).png │ ├── Laid_out_in_memory_(FORTRAN).png │ ├── MPIing_the_Code-2.png │ ├── MPIing_the_Code.png │ ├── Next.png │ ├── Other_stuff_about_the_nbody_code.png │ ├── OverlappingComputation.png │ ├── Overlapping_Communication_Computation-2.png │ ├── Overlapping_Communication_Computation.png │ ├── Pipeline-2.png │ ├── Pipeline-3.png │ ├── Pipeline-4.png │ ├── Pipeline.png │ ├── Pipeline_Formula-1.png │ ├── Pipeline_Formula-2.png │ ├── Plotting_to_file.png │ ├── Plotting_to_screen.png │ ├── Problem_I_remains_memory.png │ ├── Single-Processor_hydro_code-2.png │ ├── Single-Processor_hydro_code-3.png │ ├── Single-Processor_hydro_code.png │ ├── What_if_not_same_#_of_particles-2.png │ ├── What_if_not_same_#_of_particles.png │ ├── bettersumming.png │ ├── bettersumming_eq.png │ ├── collectiveoperation.png │ ├── deadlock.png │ ├── deadlock_1.png │ ├── diffusion.png │ ├── diffusion_eq.png │ ├── diffusionequationmpi.png │ ├── domain_decomposition.png │ ├── guardcells.png │ ├── guardcells_1.png │ ├── hello.png │ ├── helloworld_c.png │ ├── helloworld_fortran.png │ ├── id_diffusion.png │ ├── inefficient.png │ ├── message_passing.png │ ├── messages.png │ ├── min,mean,max.png │ ├── mpicc.png │ ├── mpif77.png │ ├── mpirun.png │ ├── nonblockindrecv.png │ ├── nonblocking.png │ ├── nonblockingsends.png │ ├── processvie_1.png │ ├── processview.png │ ├── processview_2.png │ ├── sendreciev.png │ ├── sendreciev_1.png │ ├── sendrecv_args.png │ └── sendrecv_args2.png ├── images2 │ ├── Another_collective_operation.png │ ├── BUFFERING.png │ ├── Communicators_1.png │ ├── Communicators_2.png │ ├── Create_new_communicator_with_new_topology.png │ ├── Cute_way_for_Periodic_BCs.png │ ├── Data_dependencies.png │ ├── Data_structure-1.png │ ├── Data_structure-2.png │ ├── Discretizing_Derivatives │ ├── Discretizing_Derivatives.png │ ├── Displaying_Data.png │ ├── Equations_of_Hydrodynamics.png │ ├── Finite_Volume_Method.png │ ├── Guard_cell_fill.png │ ├── Guardcells │ ├── Guardcells-2.png │ ├── How_would_we_get_this_data_Allgather.png │ ├── Implementing_in_MPI-10.png │ ├── Implementing_in_MPI-11.png │ ├── Implementing_in_MPI-12.png │ ├── Implementing_in_MPI-13.png │ ├── Implementing_in_MPI-14.png │ ├── Implementing_in_MPI-15.png │ ├── Implementing_in_MPI-16.png │ ├── Implementing_in_MPI-17.png │ ├── Implementing_in_MPI-18.png │ ├── Implementing_in_MPI-19.png │ ├── Implementing_in_MPI-2.png │ ├── Implementing_in_MPI-20.png │ ├── Implementing_in_MPI-21.png │ ├── Implementing_in_MPI-22.png │ ├── Implementing_in_MPI-23.png │ ├── Implementing_in_MPI-24.png │ ├── Implementing_in_MPI-25.png │ ├── Implementing_in_MPI-26.png │ ├── Implementing_in_MPI-28.png │ ├── Implementing_in_MPI-29.png │ ├── Implementing_in_MPI-3.png │ ├── Implementing_in_MPI-30.png │ ├── Implementing_in_MPI-31.png │ ├── Implementing_in_MPI-32.png │ ├── Implementing_in_MPI-33.png │ ├── Implementing_in_MPI-34.png │ ├── Implementing_in_MPI-35.png │ ├── Implementing_in_MPI-36.png │ ├── Implementing_in_MPI-37.png │ ├── Implementing_in_MPI-38.png │ ├── Implementing_in_MPI-39.png │ ├── Implementing_in_MPI-4.png │ ├── Implementing_in_MPI-40.png │ ├── Implementing_in_MPI-41.png │ ├── Implementing_in_MPI-42.png │ ├── Implementing_in_MPI-5.png │ ├── Implementing_in_MPI-6.png │ ├── Implementing_in_MPI-7.png │ ├── Implementing_in_MPI-8.png │ ├── Implementing_in_MPI-9.png │ ├── Implementing_in_MPI.png │ ├── Implementing_in_MPI_1.png │ ├── Implementperiodicboundary.png │ ├── Laid_out_in_memory_(C).png │ ├── Laid_out_in_memory_(FORTRAN).png │ ├── MPIing_the_Code-2.png │ ├── MPIing_the_Code.png │ ├── Next.png │ ├── Other_stuff_about_the_nbody_code.png │ ├── OverlappingComputation.png │ ├── Overlapping_Communication_Computation-2.png │ ├── Overlapping_Communication_Computation.png │ ├── Pipeline-2.png │ ├── Pipeline-3.png │ ├── Pipeline-4.png │ ├── Pipeline.png │ ├── Pipeline_Formula-1.png │ ├── Pipeline_Formula-2.png │ ├── Plotting_to_file.png │ ├── Plotting_to_screen.png │ ├── Problem_I_remains_memory.png │ ├── Single-Processor_hydro_code-2.png │ ├── Single-Processor_hydro_code-3.png │ ├── Single-Processor_hydro_code.png │ ├── What_if_not_same_#_of_particles-2.png │ ├── What_if_not_same_#_of_particles.png │ ├── bettersumming.png │ ├── bettersumming_eq.png │ ├── collectiveoperation.png │ ├── deadlock.png │ ├── deadlock_1.png │ ├── diffusion.png │ ├── diffusion_eq.png │ ├── diffusionequationmpi.png │ ├── domain_decomposition.png │ ├── guardcells.png │ ├── guardcells_1.png │ ├── hello.png │ ├── helloworld_c.png │ ├── helloworld_fortran.png │ ├── id_diffusion.png │ ├── inefficient.png │ ├── message_passing.png │ ├── messages.png │ ├── min,mean,max.png │ ├── mpicc.png │ ├── mpif77.png │ ├── mpirun.png │ ├── nonblockindrecv.png │ ├── nonblocking.png │ ├── nonblockingsends.png │ ├── processvie_1.png │ ├── processview.png │ ├── processview_2.png │ ├── sendreciev.png │ ├── sendreciev_1.png │ ├── sendrecv_args.png │ └── sendrecv_args2.png ├── presentation.md └── presentation.pdf └── setup /Makefile.inc: -------------------------------------------------------------------------------- 1 | ROOTDIR=${HOME}/mpi 2 | 3 | USEPGPLOT = -DPGPLOT 4 | PGPLIBS = -L/usr/X11R6/lib64 -L${PGPLOT_DIR} -lcpgplot -lpgplot -lX11 -lpng 5 | 6 | INCLUDES=-I${PGPLOT_DIR} 7 | 8 | CC=gcc 9 | F77=gfortran 10 | F90=gfortran 11 | CFLAGS=-std=c99 -O3 -Wall ${USEPGPLOT} ${INCLUDES} 12 | FFLAGS=-O3 -Wall ${INCLUDES} -g -fbounds-check 13 | CFLAGS_FAST=-std=c99 -O3 ${USEPGPLOT} ${INCLUDES} 14 | CLIBS=-lm 15 | LDFLAGS=-lm 16 | 17 | OMPCC=gcc 18 | OMPF77=gfortran 19 | OMPCFLAGS=${CFLAGS} -fopenmp 20 | OMPCFLAGS_FAST = ${CFLAGS_FAST} -fopenmp 21 | OMPFFLAGS=-fopenmp 22 | OMPLDFLAGS=${LDFLAGS} -fopenmp 23 | 24 | MPICC=mpicc 25 | MPIF90=mpif90 26 | MPIF77=mpif90 27 | MPIUTILS= 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MPI Tutorial 2 | ============ 3 | 4 | 1.5 day MPI tutorial for those with some C/Fortran knowledge. 5 | Presentation slides can be found in the presentation directory, as 6 | [Online-viewable Markdown](presentation/presentation.md) or 7 | [PDF](presentation/presentation.pdf). 8 | 9 | TODO: refactor to start with collectives. 10 | -------------------------------------------------------------------------------- /diffusion/Makefile: -------------------------------------------------------------------------------- 1 | all: diffusionf diffusionc 2 | 3 | USEPGPLOT=-DPGPLOT 4 | 5 | include ../Makefile.inc 6 | 7 | MPICC=mpicc 8 | MPIF77=mpif90 9 | 10 | diffusionf: diffusion.f90 11 | ${F77} ${FFLAGS} -o $@ $< ${USEPGPLOT} ${PGPLIBS} 12 | 13 | diffusionc: diffusion.c 14 | ${CC} ${CFLAGS} -g -c -o diffusionc.o $< ${USEPGPLOT} ${PGPLIBS} 15 | ${F77} ${FFLAGS} -g -o $@ diffusionc.o ${USEPGPLOT} ${PGPLIBS} 16 | 17 | diffusionf-mpi: diffusionf-mpi.f90 18 | ${MPIF77} ${FFLAGS} -o $@ $< ${PGPLIBS} 19 | 20 | diffusionc-mpi: diffusionc-mpi.c 21 | ${MPICC} ${CFLAGS} -c -o diffusionc-mpi.o $< ${PGPLIBS} 22 | ${MPIF77} ${FFLAGS} -o $@ diffusionc-mpi.o ${USEPGPLOT} ${PGPLIBS} 23 | 24 | new-diffusionc-mpi: new-diffusionc-mpi.c 25 | ${MPICC} ${CFLAGS} -c -o new-diffusionc-mpi.o $< ${PGPLIBS} 26 | ${MPIF77} ${FFLAGS} -o $@ new-diffusionc-mpi.o ${USEPGPLOT} ${PGPLIBS} 27 | 28 | diffusionc-mpi-nonblocking: diffusionc-mpi-nonblocking.c 29 | ${MPICC} ${CFLAGS} -c -o diffusionc-mpi-nonblocking.o $< ${PGPLIBS} 30 | ${MPIF77} ${FFLAGS} -o $@ diffusionc-mpi-nonblocking.o ${USEPGPLOT} ${PGPLIBS} 31 | 32 | diffusionf-mpi-nonblocking: diffusionf-mpi-nonblocking.f90 33 | ${MPIF77} ${FFLAGS} -o $@ $< ${PGPLIBS} 34 | 35 | 36 | clean: 37 | rm -rf diffusionf 38 | rm -rf diffusionc 39 | rm -rf diffusionf-mpi 40 | rm -rf diffusionc-mpi 41 | rm -rf diffusionf-mpi-nonblocking 42 | rm -rf diffusionc-mpi-nonblocking 43 | rm -rf *.o 44 | rm -rf *~ 45 | -------------------------------------------------------------------------------- /diffusion/answer/Makefile: -------------------------------------------------------------------------------- 1 | all: diffusionc-mpi diffusionc-mpi-nonblocking 2 | 3 | include ../Makefile.inc 4 | 5 | USEPGPLOT= 6 | 7 | diffusionf: diffusion.f90 8 | ${F77} ${FFLAGS} -o $@ $< ${USEPGPLOT} ${PGPLIBS} 9 | 10 | diffusionc: diffusion.c 11 | ${CC} ${CFLAGS} -c -o diffusionc.o $< ${USEPGPLOT} ${PGPLIBS} 12 | ${F77} ${FFLAGS} -o $@ diffusionc.o ${USEPGPLOT} ${PGPLIBS} 13 | 14 | diffusionf-mpi: diffusionf-mpi.f90 15 | mpefc -mpilog ${FFLAGS} -o $@ $< ${PGPLIBS} 16 | 17 | diffusionc-mpi: diffusionc-mpi.c 18 | mpecc -mpilog ${CFLAGS} -c -o diffusionc-mpi.o $< ${PGPLIBS} 19 | mpefc -mpilog ${FFLAGS} -o $@ diffusionc-mpi.o ${USEPGPLOT} ${PGPLIBS} 20 | 21 | new-diffusionc-mpi: new-diffusionc-mpi.c 22 | ${MPICC} ${CFLAGS} -c -o new-diffusionc-mpi.o $< ${PGPLIBS} 23 | ${MPIF77} ${FFLAGS} -o $@ new-diffusionc-mpi.o ${USEPGPLOT} ${PGPLIBS} 24 | 25 | diffusionc-mpi-nonblocking: diffusionc-mpi-nonblocking.c 26 | mpecc -mpilog ${CFLAGS} -c -o diffusionc-mpi-nonblocking.o $< ${PGPLIBS} 27 | mpefc -mpilog ${FFLAGS} -o $@ diffusionc-mpi-nonblocking.o ${USEPGPLOT} ${PGPLIBS} 28 | 29 | diffusionf-mpi-nonblocking: diffusionf-mpi-nonblocking.f90 30 | ${MPIF77} ${FFLAGS} -o $@ $< ${PGPLIBS} 31 | 32 | 33 | clean: 34 | rm -rf diffusionf 35 | rm -rf diffusionc 36 | rm -rf diffusionf-mpi 37 | rm -rf diffusionc-mpi 38 | rm -rf diffusionf-mpi-nonblocking 39 | rm -rf diffusionc-mpi-nonblocking 40 | rm -rf *.o 41 | rm -rf *~ 42 | -------------------------------------------------------------------------------- /diffusion/answer/diffusionc-mpi-nonblocking.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "cpgplot.h" 6 | 7 | int main(int argc, char **argv) { 8 | /* simulation parameters */ 9 | const int totpoints=10000000; 10 | int locpoints; 11 | int starti, endi; 12 | const float xleft = -12., xright = +12.; 13 | float locxleft, locxright; 14 | const float kappa = 1.; 15 | 16 | const int nsteps=1000; 17 | const int plotsteps=50; 18 | const int righttag = 1; 19 | const int lefttag = 2; 20 | 21 | /* data structures */ 22 | float *x; 23 | float **temperature; 24 | float *theory; 25 | 26 | /* parameters of the original temperature distribution */ 27 | const float ao=1., sigmao=1.; 28 | float a, sigma; 29 | 30 | float fixedlefttemp, fixedrighttemp; 31 | 32 | int old, new; 33 | int step, i; 34 | int red, grey,white; 35 | float time; 36 | float dt, dx; 37 | float error; 38 | 39 | int ierr; 40 | int size, rank; 41 | int leftneighbour, rightneighbour; 42 | MPI_Status statuses[4]; 43 | MPI_Request request[4]; 44 | float globalerror; 45 | const int printtask=0; 46 | 47 | ierr = MPI_Init(&argc, &argv); 48 | ierr = MPI_Comm_size(MPI_COMM_WORLD, &size); 49 | ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); 50 | 51 | locpoints = totpoints/size; 52 | 53 | starti = locpoints*rank; 54 | endi = starti+locpoints-1; 55 | if (rank == size-1) { 56 | endi = totpoints-1; 57 | locpoints = endi-starti+1; 58 | } 59 | 60 | leftneighbour = rank - 1; 61 | rightneighbour = rank + 1; 62 | if (leftneighbour < 0) leftneighbour = MPI_PROC_NULL; 63 | if (rightneighbour > size-1) rightneighbour = MPI_PROC_NULL; 64 | 65 | 66 | /* set parameters */ 67 | 68 | dx = (xright-xleft)/(totpoints-1); 69 | dt = dx*dx * kappa/10.; 70 | 71 | locxleft = starti*dx + xleft; 72 | locxleft = starti*dx + xleft; 73 | locxright = endi*dx + xleft; 74 | locxright = endi*dx + xleft; 75 | /* 76 | * allocate data, including ghost cells: old and new timestep 77 | * theory doesn't need ghost cells, but we include it for simplicity 78 | */ 79 | 80 | theory = (float *)malloc((locpoints+2)*sizeof(float)); 81 | x = (float *)malloc((locpoints+2)*sizeof(float)); 82 | temperature = (float **)malloc(2 * sizeof(float *)); 83 | temperature[0] = (float *)malloc((locpoints+2)*sizeof(float)); 84 | temperature[1] = (float *)malloc((locpoints+2)*sizeof(float)); 85 | old = 0; 86 | new = 1; 87 | 88 | 89 | /* setup initial conditions */ 90 | 91 | time = 0.; 92 | for (i=0; i 2 | #include 3 | #include 4 | #include "cpgplot.h" 5 | #include 6 | 7 | int main(int argc, char **argv) { 8 | /* simulation parameters */ 9 | const int totpoints=1000; 10 | int locpoints; 11 | const float xleft = -12., xright = +12.; 12 | float locxleft, locxright; 13 | const float kappa = 1.; 14 | 15 | const int nsteps=100000; 16 | const int plotsteps=50; 17 | 18 | /* data structures */ 19 | float *x; 20 | float **temperature; 21 | float *theory; 22 | 23 | /* parameters of the original temperature distribution */ 24 | const float ao=1., sigmao=1.; 25 | float a, sigma; 26 | 27 | float fixedlefttemp, fixedrighttemp; 28 | 29 | int old, new; 30 | int step, i; 31 | int red, grey,white; 32 | float time; 33 | float dt, dx; 34 | float error; 35 | 36 | int ierr; 37 | int rank, size; 38 | int start,end; 39 | int left, right; 40 | int lefttag=1, righttag=2; 41 | MPI_Status status; 42 | 43 | /* MPI Initialization */ 44 | ierr = MPI_Init(&argc, &argv); 45 | ierr = MPI_Comm_size(MPI_COMM_WORLD,&size); 46 | ierr = MPI_Comm_rank(MPI_COMM_WORLD,&rank); 47 | 48 | locpoints = totpoints/size; 49 | start = rank*locpoints; 50 | end = (rank+1)*locpoints - 1; 51 | if (rank == size-1) 52 | end = totpoints-1; 53 | locpoints = end-start+1; 54 | 55 | left = rank-1; 56 | if (left < 0) left = MPI_PROC_NULL; 57 | right= rank+1; 58 | if (right >= size) right = MPI_PROC_NULL; 59 | 60 | /* set parameters */ 61 | 62 | dx = (xright-xleft)/(totpoints-1); 63 | dt = dx*dx * kappa/10.; 64 | 65 | locxleft = xleft + start*dx; 66 | locxright = xleft + end*dx; 67 | /* 68 | * allocate data, including ghost cells: old and new timestep 69 | * theory doesn't need ghost cells, but we include it for simplicity 70 | */ 71 | 72 | theory = (float *)malloc((locpoints+2)*sizeof(float)); 73 | x = (float *)malloc((locpoints+2)*sizeof(float)); 74 | temperature = (float **)malloc(2 * sizeof(float *)); 75 | temperature[0] = (float *)malloc((locpoints+2)*sizeof(float)); 76 | temperature[1] = (float *)malloc((locpoints+2)*sizeof(float)); 77 | old = 0; 78 | new = 1; 79 | 80 | /* setup initial conditions */ 81 | 82 | time = 0.; 83 | for (i=0; i= comsize) right = MPI_PROC_NULL 60 | ! 61 | ! set parameters 62 | ! 63 | dx = (xright-xleft)/(totpoints-1) 64 | dt = dx**2 * kappa/10. 65 | 66 | locxleft = xleft + dx*(startn-1) 67 | locxright= xleft + dx*endn 68 | 69 | ! 70 | ! allocate data, including ghost cells: old and new timestep 71 | ! theory doesn't need ghost cells, but we include it for simplicity 72 | ! 73 | allocate(temperature(locpoints+2,2)) 74 | allocate(theory(locpoints+2)) 75 | allocate(x(locpoints+2)) 76 | ! 77 | ! setup initial conditions 78 | ! 79 | old => temperature(:,1) 80 | new => temperature(:,2) 81 | time = 0. 82 | x = locxleft + [((i-1)*dx,i=1,locpoints+2)] 83 | old = ao*exp(-(x)**2 / (2.*sigmao**2)) 84 | theory= ao*exp(-(x)**2 / (2.*sigmao**2)) 85 | 86 | call pgbeg(0, "/xwindow", 1, 1) 87 | call pgask(0) 88 | call pgenv(locxleft, locxright, 0., 1.5*ao, 0, 0) 89 | call pglab('x', 'Temperature', 'Diffusion Test') 90 | red = 2 91 | call pgscr(red,1.,0.,0.) 92 | grey = 3 93 | call pgscr(grey,.2,.2,.2) 94 | white = 4 95 | call pgscr(white,1.,1.,1.) 96 | 97 | 98 | call pgsls(1) 99 | call pgsci(white) 100 | call pgline(locpoints, x, theory(2:locpoints+1)) 101 | call pgsls(2) 102 | call pgsci(red) 103 | call pgline(locpoints, x(2:locpoints+1), old(2:locpoints+1)) 104 | 105 | ! 106 | ! evolve 107 | ! 108 | do step=1, nsteps 109 | ! 110 | ! boundary conditions: keep endpoint temperatures fixed. 111 | ! 112 | new(1) = old(1) 113 | new(locpoints+2) = old(locpoints+2) 114 | 115 | call MPI_Sendrecv(old(locpoints+1), 1, MPI_REAL, right, righttag, & 116 | old(1), 1, MPI_REAL, left, righttag, MPI_COMM_WORLD, rstatus, ierr) 117 | 118 | call MPI_Sendrecv(old(2), 1, MPI_REAL, left, lefttag, & 119 | old(locpoints+2), 1, MPI_REAL, right, lefttag, MPI_COMM_WORLD, rstatus, ierr) 120 | ! 121 | ! update solution 122 | ! 123 | forall (i=2:locpoints+1) 124 | new(i) = old(i) + dt*kappa/(dx**2) * & 125 | (old(i+1) - 2*old(i) + old(i-1)) 126 | end forall 127 | time = time + dt 128 | 129 | if (mod(step, plotsteps) == 0) then 130 | call pgbbuf() 131 | call pgeras 132 | call pgsls(2) !dashed 133 | call pgslw(12) !thick 134 | call pgsci(red) 135 | call pgline(locpoints, x(2:locpoints+1), new(2:locpoints+1)) 136 | endif 137 | ! 138 | ! update correct solution 139 | ! 140 | sigma = sqrt(2.*kappa*time + sigmao**2) 141 | a = ao*sigmao/sigma 142 | theory = a*exp(-(x)**2 / (2.*sigma**2)) 143 | 144 | if (mod(step, plotsteps) == 0) then 145 | call pgsls(1) 146 | call pgslw(6) 147 | call pgsci(white) 148 | call pgline(locpoints, x(2:locpoints+1), theory(2:locpoints+1)) 149 | call pgebuf() 150 | endif 151 | error = sqrt(sum((theory(1:locpoints+1) - new(1:locpoints+1))**2)) 152 | print *, 'Step = ', step, 'Time = ', time, ' Err = ', error 153 | 154 | tmp => old 155 | old => new 156 | new => tmp 157 | enddo 158 | 159 | call pgend 160 | deallocate(temperature) 161 | deallocate(theory) 162 | deallocate(x) 163 | call MPI_Finalize(ierr) 164 | end program diffuse 165 | -------------------------------------------------------------------------------- /diffusion/diffusion.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "cpgplot.h" 5 | 6 | int main(int argc, char **argv) { 7 | /* simulation parameters */ 8 | const int totpoints=1000; 9 | const float xleft = -12., xright = +12.; 10 | const float kappa = 1.; 11 | 12 | const int nsteps=100000; 13 | const int plotsteps=50; 14 | 15 | /* data structures */ 16 | float *x; 17 | float **temperature; 18 | float *theory; 19 | 20 | /* parameters of the original temperature distribution */ 21 | const float ao=1., sigmao=1.; 22 | float a, sigma; 23 | 24 | float fixedlefttemp, fixedrighttemp; 25 | 26 | int old, new; 27 | int step, i; 28 | int red, grey,white; 29 | float time; 30 | float dt, dx; 31 | float error; 32 | 33 | /* set parameters */ 34 | 35 | dx = (xright-xleft)/(totpoints-1); 36 | dt = dx*dx * kappa/10.; 37 | 38 | /* 39 | * allocate data, including ghost cells: old and new timestep 40 | * theory doesn't need ghost cells, but we include it for simplicity 41 | */ 42 | 43 | theory = (float *)malloc((totpoints+2)*sizeof(float)); 44 | x = (float *)malloc((totpoints+2)*sizeof(float)); 45 | temperature = (float **)malloc(2 * sizeof(float *)); 46 | temperature[0] = (float *)malloc((totpoints+2)*sizeof(float)); 47 | temperature[1] = (float *)malloc((totpoints+2)*sizeof(float)); 48 | old = 0; 49 | new = 1; 50 | 51 | /* setup initial conditions */ 52 | 53 | time = 0.; 54 | for (i=0; i temperature(:,1) 53 | new => temperature(:,2) 54 | time = 0. 55 | x = xleft + [((i-1+0.5)*dx,i=1,totpoints+2)] 56 | old = ao*exp(-(x)**2 / (2.*sigmao**2)) 57 | theory= ao*exp(-(x)**2 / (2.*sigmao**2)) 58 | 59 | fixedlefttemp = ao*exp(-(xleft-dx)**2 / (2.*sigmao**2)) 60 | fixedrighttemp= ao*exp(-(xright+dx)**2 / (2.*sigmao**2)) 61 | 62 | call pgbeg(0, "/xwindow", 1, 1) 63 | call pgask(0) 64 | call pgenv(xleft, xright, 0., 1.5*ao, 0, 0) 65 | call pglab('x', 'Temperature', 'Diffusion Test') 66 | red = 2 67 | call pgscr(red,1.,0.,0.) 68 | grey = 3 69 | call pgscr(grey,.2,.2,.2) 70 | white = 4 71 | call pgscr(white,1.,1.,1.) 72 | 73 | 74 | call pgsls(1) 75 | call pgsci(white) 76 | call pgline(totpoints, x(2), theory(2)) 77 | call pgsls(2) 78 | call pgsci(red) 79 | call pgline(totpoints, x(2), old(2)) 80 | 81 | ! 82 | ! evolve 83 | ! 84 | do step=1, nsteps 85 | ! 86 | ! boundary conditions: keep endpoint temperatures fixed. 87 | ! 88 | old(1) = fixedlefttemp 89 | old(totpoints+2) = fixedrighttemp 90 | ! 91 | ! update solution 92 | ! 93 | forall (i=2:totpoints+1) 94 | new(i) = old(i) + dt*kappa/(dx**2) * & 95 | (old(i+1) - 2*old(i) + old(i-1)) 96 | end forall 97 | time = time + dt 98 | 99 | if (mod(step, plotsteps) == 0) then 100 | call pgbbuf() 101 | call pgeras 102 | call pgsls(2) !dashed 103 | call pgslw(12) !thick 104 | call pgsci(red) 105 | call pgline(totpoints, x(2), new(2)) 106 | endif 107 | ! 108 | ! update correct solution 109 | ! 110 | sigma = sqrt(2.*kappa*time + sigmao**2) 111 | a = ao*sigmao/sigma 112 | theory = a*exp(-(x)**2 / (2.*sigma**2)) 113 | 114 | if (mod(step, plotsteps) == 0) then 115 | call pgsls(1) 116 | call pgslw(6) 117 | call pgsci(white) 118 | call pgline(totpoints, x(2), theory(2)) 119 | call pgebuf() 120 | endif 121 | error = sqrt(sum((theory(1:totpoints+1) - new(1:totpoints+1))**2)) 122 | print *, 'Step = ', step, 'Time = ', time, ' Err = ', error 123 | 124 | tmp => old 125 | old => new 126 | new => tmp 127 | enddo 128 | 129 | call pgend 130 | deallocate(temperature) 131 | deallocate(theory) 132 | deallocate(x) 133 | end 134 | -------------------------------------------------------------------------------- /hydroc/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.inc 2 | 3 | hydro: hydro.o ppm.o solver.o allocmultid.o plot.o 4 | $(FC) -o $@ $^ $(FFLAGS) $(CLIBS) $(PGPLIBS) 5 | 6 | clean: 7 | rm -f hydro *.o *.dat *~ *pbm *ppm 8 | -------------------------------------------------------------------------------- /hydroc/allocmultid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float ***alloc3d_float(int n, int m, int l) { 4 | float *data = malloc(n*m*l*sizeof(float)); 5 | if (!data) return NULL; 6 | 7 | float ***array = (float ***)malloc(n*sizeof(float **)); 8 | for (int i=0; i 2 | 3 | float ***alloc3d_float(int n, int m, int l) { 4 | float *data = malloc(n*m*l*sizeof(float)); 5 | if (!data) return NULL; 6 | 7 | float ***array = (float ***)malloc(n*sizeof(float **)); 8 | for (int i=0; i 11 | #include 12 | #include 13 | #include "ppm.h" 14 | #include "plot.h" 15 | #include "solver.h" 16 | #include "allocmultid.h" 17 | 18 | int main(int argc, char **argv) { 19 | int n, nx, ny; 20 | float t, dt; 21 | int iter; 22 | float ***u; 23 | int ierr, size, rank; 24 | MPI_Comm commcart; 25 | int gridsize[2]; 26 | int gridcoords[2]; 27 | int periods[2] = {1,1}; 28 | int locnx; 29 | int left,right; 30 | int start,end; 31 | char filename[30]; 32 | 33 | ierr = MPI_Init(&argc, &argv); 34 | ierr = MPI_Comm_size(MPI_COMM_WORLD, &size); 35 | gridsize[0] = size; gridsize[1] = 1; 36 | ierr = MPI_Cart_create(MPI_COMM_WORLD, 2, gridsize, 37 | periods, 1, &commcart); 38 | ierr = MPI_Comm_rank(commcart, &rank); 39 | ierr = MPI_Cart_shift(commcart, 0, 1, &left, &right); 40 | ierr = MPI_Cart_coords(commcart, rank, 2, gridcoords); 41 | 42 | if (argc != 2) { 43 | printf("Usage: %s n, where n is size of domain.\n", argv[0]); 44 | exit(-1); 45 | } else { 46 | n = atoi(argv[1]); 47 | if (n < 2 || n > 500) { 48 | n = 100; 49 | printf("%s: invalid n = %s; using %d.\n", argv[0], argv[1], n); 50 | } 51 | } 52 | 53 | locnx = n/gridsize[0]; 54 | start = rank*locnx; 55 | end = rank*locnx + locnx-1; 56 | if (gridcoords[0] == gridsize[0]-1) end = n-1; 57 | locnx = end-start+1; 58 | 59 | nx = locnx+2*NGUARD; /* guardcells on either side for BCs */ 60 | ny = n+2*NGUARD; 61 | u = alloc3d_float(ny,nx,NVARS); 62 | 63 | initialconditions(u, nx, ny, n, start); 64 | sprintf(filename,"%d-ics.ppm",rank); 65 | outputppm(u,nx,ny,NVARS,filename,IDENS); 66 | outputppm_mpiio(u,nx,ny,n,start,NVARS,"ics.ppm",IDENS); 67 | t=0.; 68 | for (iter=0; iter < 12*n; iter++) { 69 | timestep(u,nx,ny,&dt,commcart,left,right); 70 | t += 2*dt; 71 | if ((iter % 10) == 0) { 72 | if (rank == 0) 73 | printf("%4d dt = %f, t = %f\n", iter, dt, t); 74 | plot(u, nx, ny, start); 75 | } 76 | } 77 | sprintf(filename,"%d-dens.ppm",rank); 78 | outputppm(u,nx,ny,NVARS,filename,IDENS); 79 | outputppm_mpiio(u,nx,ny,n,start,NVARS,"dens.ppm",IDENS); 80 | closeplot(); 81 | 82 | free3d_float(u,ny); 83 | MPI_Finalize(); 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /hydroc/answer/plot.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "solver.h" 4 | 5 | #ifdef PGPLOT 6 | #include 7 | #endif 8 | 9 | #define NCONTOURS 5 10 | 11 | int plot(float ***u, const int nx, const int ny, const int start) { 12 | 13 | #ifdef PGPLOT 14 | const int ng=NGUARD; 15 | double xl, xr, yl, yr, dx, dy; 16 | float denscontours[NCONTOURS], prescontours[NCONTOURS]; 17 | float *dens, *pres; 18 | double maxd=-1e19, mind=+1e-19; 19 | double maxp=-1e19, minp=+1e-19; 20 | double globmaxd, globmind, globmaxp, globminp; 21 | static int called = 0; 22 | int i, j, count; 23 | float tr[6] = {0.,0.,0.,0.,0.,0.}; 24 | 25 | xl = start*1.; xr = start+nx-2*ng-1; 26 | yl = 0.; yr = ny-2*ng-1; 27 | dx = 1.; dy = 1.; 28 | 29 | dens = (float *)malloc((nx-2*ng)*(ny-2*ng)*sizeof(float)); 30 | pres = (float *)malloc((nx-2*ng)*(ny-2*ng)*sizeof(float)); 31 | count = 0; 32 | for (j=ny-ng-1; j>=ng; j--) { 33 | for (i=ng; i maxd) maxd = dens[count]; 39 | if (dens[count] < mind) mind = dens[count]; 40 | if (pres[count] > maxp) maxp = pres[count]; 41 | if (pres[count] < minp) minp = pres[count]; 42 | count++; 43 | } 44 | } 45 | 46 | MPI_Allreduce(&mind, &globmind,1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); 47 | MPI_Allreduce(&minp, &globminp,1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); 48 | MPI_Allreduce(&maxd, &globmaxd,1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); 49 | MPI_Allreduce(&maxp, &globmaxp,1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); 50 | 51 | for (i=0; i 2 | #include 3 | #include "allocmultid.h" 4 | #include "solver.h" 5 | 6 | void color(float val, float lo, float hi, char *rgb) { 7 | float scaleval = (val-lo)/(hi-lo) * 255.; 8 | int red; 9 | int green; 10 | 11 | red = (int)(scaleval*3); 12 | if (red > 255) red = 255; 13 | rgb[0] = (char)red; 14 | 15 | green = (int)scaleval; 16 | 17 | rgb[1] = (char)green; 18 | rgb[2] = (char)0; 19 | } 20 | 21 | void outputppm(float ***data, int nx, int ny, int nvars, const char *filename, const int varnum) { 22 | FILE *out; 23 | char ***rgb; 24 | float lo, hi; 25 | float globlo, globhi; 26 | int i, j; 27 | 28 | lo = 1e19; 29 | hi = -1e19; 30 | for (j=0; j hi) hi = data[j][i][varnum]; 34 | } 35 | } 36 | 37 | MPI_Allreduce(&lo,&globlo, 1, MPI_FLOAT, MPI_MIN, MPI_COMM_WORLD); 38 | MPI_Allreduce(&hi,&globhi, 1, MPI_FLOAT, MPI_MAX, MPI_COMM_WORLD); 39 | rgb = alloc3d_char(ny,nx,3); 40 | for (i=0; i hi) hi = data[j][i][varnum]; 78 | } 79 | } 80 | 81 | MPI_Allreduce(&lo,&globlo, 1, MPI_FLOAT, MPI_MIN, MPI_COMM_WORLD); 82 | MPI_Allreduce(&hi,&globhi, 1, MPI_FLOAT, MPI_MAX, MPI_COMM_WORLD); 83 | rgb = alloc3d_char(n, nx-2*NGUARD, 3); 84 | for (j=NGUARD; j 11 | #include 12 | #include "ppm.h" 13 | #include "plot.h" 14 | #include "solver.h" 15 | #include "allocmultid.h" 16 | 17 | int main(int argc, char **argv) { 18 | int n, nx, ny; 19 | float t, dt; 20 | int iter; 21 | float ***u; 22 | 23 | if (argc != 2) { 24 | printf("Usage: %s n, where n is size of domain.\n", argv[0]); 25 | exit(-1); 26 | } else { 27 | n = atoi(argv[1]); 28 | if (n < 2 || n > 500) { 29 | n = 100; 30 | printf("%s: invalid n = %s; using %d.\n", argv[0], argv[1], n); 31 | } 32 | } 33 | 34 | nx = n+4; /* two cells on either side for BCs */ 35 | ny = n+4; 36 | u = alloc3d_float(ny,nx,NVARS); 37 | 38 | initialconditions(u, nx, ny); 39 | outputppm(u,nx,ny,NVARS,"ics.ppm",IDENS); 40 | t=0.; 41 | for (iter=0; iter < 6*nx; iter++) { 42 | timestep(u,nx,ny,&dt); 43 | t += 2*dt; 44 | if ((iter % 10) == 1) { 45 | printf("%4d dt = %f, t = %f\n", iter, dt, t); 46 | plot(u, nx, ny); 47 | } 48 | } 49 | outputppm(u,nx,ny,NVARS,"dens.ppm",IDENS); 50 | closeplot(); 51 | 52 | free3d_float(u,ny); 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /hydroc/mpi/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.inc 2 | 3 | CC=mpicc 4 | CFLAGS+=-g -Wall -O0 5 | 6 | hydro: hydro.o ppm.o solver.o allocmultid.o plot.o 7 | $(MPICC) -o $@ $^ $(FFLAGS) $(CLIBS) $(PGPLIBS) -lgfortran -lm 8 | 9 | clean: 10 | rm -f hydro *.o *.dat *~ *pbm *ppm 11 | -------------------------------------------------------------------------------- /hydroc/mpi/allocmultid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float ***alloc3d_float(int n, int m, int l) { 4 | float *data = malloc(n*m*l*sizeof(float)); 5 | if (!data) return NULL; 6 | 7 | float ***array = (float ***)malloc(n*sizeof(float **)); 8 | for (int i=0; i 11 | #include 12 | #include 13 | #include "ppm.h" 14 | #include "plot.h" 15 | #include "solver.h" 16 | #include "allocmultid.h" 17 | 18 | int main(int argc, char **argv) { 19 | int n, nx, ny; 20 | float t, dt; 21 | int iter; 22 | float ***u; 23 | int ierr, size, rank; 24 | MPI_Comm commcart; 25 | int gridsize[2]; 26 | int gridcoords[2]; 27 | int periods[2] = {1,1}; 28 | int locnx; 29 | int left,right; 30 | int start,end; 31 | char filename[30]; 32 | 33 | ierr = MPI_Init(&argc, &argv); 34 | ierr = MPI_Comm_size(MPI_COMM_WORLD, &size); 35 | gridsize[0] = size; gridsize[1] = 1; 36 | ierr = MPI_Cart_create(MPI_COMM_WORLD, 2, gridsize, 37 | periods, 1, &commcart); 38 | ierr = MPI_Comm_rank(commcart, &rank); 39 | ierr = MPI_Cart_shift(commcart, 0, 1, &left, &right); 40 | ierr = MPI_Cart_coords(commcart, rank, 2, gridcoords); 41 | 42 | if (argc != 2) { 43 | printf("Usage: %s n, where n is size of domain.\n", argv[0]); 44 | exit(-1); 45 | } else { 46 | n = atoi(argv[1]); 47 | if (n < 2 || n > 500) { 48 | n = 100; 49 | printf("%s: invalid n = %s; using %d.\n", argv[0], argv[1], n); 50 | } 51 | } 52 | 53 | /* calculate an nx and ny from n, rank */ 54 | locnx = n/gridsize[0]; 55 | start = rank*locnx; 56 | end = rank*locnx + locnx-1; 57 | if (gridcoords[0] == gridsize[0]-1) end = n-1; 58 | locnx = end-start+1; 59 | 60 | nx = locnx+2*NGUARD; /* guardcells on either side for BCs */ 61 | ny = n+2*NGUARD; 62 | u = alloc3d_float(ny,nx,NVARS); 63 | 64 | initialconditions(u, nx, ny, n, start); 65 | sprintf(filename,"%d-ics.ppm",rank); 66 | outputppm(u,nx,ny,NVARS,filename,IDENS); 67 | //outputppm_mpiio(u,nx,ny,n,start,NVARS,"ics.ppm",IDENS); 68 | t=0.; 69 | for (iter=0; iter < 12*n; iter++) { 70 | timestep(u,nx,ny,&dt,commcart,left,right); 71 | t += 2*dt; 72 | if ((iter % 10) == 0) { 73 | if (rank == 0) 74 | printf("%4d dt = %f, t = %f\n", iter, dt, t); 75 | plot(u, nx, ny, start); 76 | } 77 | } 78 | sprintf(filename,"%d-dens.ppm",rank); 79 | outputppm(u,nx,ny,NVARS,filename,IDENS); 80 | //outputppm_mpiio(u,nx,ny,n,start,NVARS,"dens.ppm",IDENS); 81 | closeplot(); 82 | 83 | free3d_float(u,ny); 84 | MPI_Finalize(); 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /hydroc/mpi/plot.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "solver.h" 4 | 5 | #ifdef PGPLOT 6 | #include 7 | #endif 8 | 9 | #define NCONTOURS 5 10 | 11 | int plot(float ***u, const int nx, const int ny, const int start) { 12 | 13 | #ifdef PGPLOT 14 | const int ng=NGUARD; 15 | double xl, xr, yl, yr, dx, dy; 16 | float denscontours[NCONTOURS], prescontours[NCONTOURS]; 17 | float *dens, *pres; 18 | double maxd=-1e19, mind=+1e-19; 19 | double maxp=-1e19, minp=+1e-19; 20 | double globmaxd, globmind, globmaxp, globminp; 21 | static int called = 0; 22 | int i, j, count; 23 | float tr[6] = {0.,0.,0.,0.,0.,0.}; 24 | 25 | xl = start*1.; xr = start+nx-2*ng-1; 26 | yl = 0.; yr = ny-2*ng-1; 27 | dx = 1.; dy = 1.; 28 | 29 | dens = (float *)malloc((nx-2*ng)*(ny-2*ng)*sizeof(float)); 30 | pres = (float *)malloc((nx-2*ng)*(ny-2*ng)*sizeof(float)); 31 | count = 0; 32 | for (j=ny-ng-1; j>=ng; j--) { 33 | for (i=ng; i maxd) maxd = dens[count]; 39 | if (dens[count] < mind) mind = dens[count]; 40 | if (pres[count] > maxp) maxp = pres[count]; 41 | if (pres[count] < minp) minp = pres[count]; 42 | count++; 43 | } 44 | } 45 | 46 | MPI_Allreduce(&mind, &globmind,1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); 47 | MPI_Allreduce(&minp, &globminp,1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); 48 | MPI_Allreduce(&maxd, &globmaxd,1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); 49 | MPI_Allreduce(&maxp, &globmaxp,1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); 50 | 51 | for (i=0; i 2 | #include 3 | #include "allocmultid.h" 4 | #include "solver.h" 5 | 6 | void color(float val, float lo, float hi, char *rgb) { 7 | float scaleval = (val-lo)/(hi-lo) * 255.; 8 | int red; 9 | int green; 10 | 11 | red = (int)(scaleval*3); 12 | if (red > 255) red = 255; 13 | rgb[0] = (char)red; 14 | 15 | green = (int)scaleval; 16 | 17 | rgb[1] = (char)green; 18 | rgb[2] = (char)0; 19 | } 20 | 21 | void outputppm(float ***data, int nx, int ny, int nvars, const char *filename, const int varnum) { 22 | FILE *out; 23 | char ***rgb; 24 | float lo, hi; 25 | float globlo, globhi; 26 | int i, j; 27 | 28 | lo = 1e19; 29 | hi = -1e19; 30 | for (j=0; j hi) hi = data[j][i][varnum]; 34 | } 35 | } 36 | 37 | /* get globhi, globlo from hi, lo */ 38 | globhi = hi; 39 | globlo = lo; 40 | 41 | rgb = alloc3d_char(ny,nx,3); 42 | for (i=0; i hi) hi = data[j][i][varnum]; 76 | } 77 | } 78 | 79 | /* get globhi, globlo from hi, lo */ 80 | globhi = hi; 81 | globlo = lo; 82 | 83 | rgb = alloc3d_char(n, nx-2*NGUARD, 3); 84 | for (j=NGUARD; j 2 | #include "solver.h" 3 | 4 | #ifdef PGPLOT 5 | #include 6 | #endif 7 | 8 | #define NCONTOURS 5 9 | 10 | int plot(float ***u, const int nx, const int ny) { 11 | 12 | #ifdef PGPLOT 13 | const int ng=2; 14 | double xl, xr, yl, yr, dx, dy; 15 | float denscontours[NCONTOURS], prescontours[NCONTOURS]; 16 | float *dens, *pres; 17 | double maxd=-1e19, mind=+1e-19; 18 | double maxp=-1e19, minp=+1e-19; 19 | static int called = 0; 20 | int i, j, count; 21 | float tr[6] = {0.,0.,0.,0.,0.,0.}; 22 | 23 | xl = 0.; xr = nx-2*ng-1; 24 | yl = 0.; yr = ny-2*ng-1; 25 | dx = 1.; dy = 1.; 26 | 27 | dens = (float *)malloc((nx-2*ng)*(ny-2*ng)*sizeof(float)); 28 | pres = (float *)malloc((nx-2*ng)*(ny-2*ng)*sizeof(float)); 29 | count = 0; 30 | for (j=ny-ng; j>ng; j--) { 31 | for (i=ng; i maxd) maxd = dens[count]; 37 | if (dens[count] < mind) mind = dens[count]; 38 | if (pres[count] > maxp) maxp = pres[count]; 39 | if (pres[count] < minp) minp = pres[count]; 40 | count++; 41 | } 42 | } 43 | 44 | tr[0] = xl; tr[3] = yl; 45 | tr[1] = dx; tr[5] = dy; 46 | 47 | for (i=0; i 2 | #include "allocmultid.h" 3 | 4 | void color(float val, float lo, float hi, int rgb[3]) { 5 | float scaleval = (val-lo)/(hi-lo) * 255.; 6 | 7 | rgb[0] = (int)(scaleval*3); 8 | if (rgb[0] > 255) rgb[0] = 255; 9 | 10 | rgb[1] = (int)(scaleval); 11 | rgb[2] = 0; 12 | } 13 | 14 | void outputppm(float ***data, int nx, int ny, int nvars, const char *filename, const int varnum) { 15 | FILE *out; 16 | int ***rgb; 17 | float lo, hi; 18 | int i, j; 19 | 20 | lo = 1e19; 21 | hi = -1e19; 22 | for (j=0; j hi) hi = data[j][i][varnum]; 26 | } 27 | } 28 | 29 | rgb = alloc3d_int(nx,ny,3); 30 | for (i=0; i=0; j--) { 39 | for (i=0; i 2 | #include 3 | #include "solver.h" 4 | #include "allocmultid.h" 5 | 6 | const float eosgamma=5./3.; 7 | 8 | #define MAX(x,y) ((y) > (x) ? (y) : (x)) 9 | 10 | void periodicBCs(float ***u, const int nx, const int ny, const char xydim) { 11 | 12 | if (xydim == 'y') { 13 | int n = ny; 14 | for (int j=0; j vx) v=vy; 45 | float p = (u[j][i][IENER] - 0.5*(vx*vx+vy*vy)*u[j][i][IDENS])*(eosgamma-1.); 46 | float cloc = v + sqrtf(fabsf(p*eosgamma/u[j][i][IDENS])); 47 | c = MAX(c,cloc); 48 | } 49 | } 50 | 51 | return (1./c); 52 | } 53 | 54 | void initialconditions(float ***u,const int nx, const int ny) { 55 | int i, j; 56 | const float backgrounddens=1., projdens=50., projvel=4., p0=1.; 57 | float r; 58 | int n = MAX(nx,ny); 59 | float x,y; 60 | 61 | for (j=0;j 0.) { 101 | for (int i=0; i= n) irshift -= n; 135 | for (int var=0; var= n) irshift -= n; 161 | int ilshift = i-1; 162 | if (ilshift < 0) ilshift += n; 163 | for (int var=0; var 0.) 168 | dfr[i][var] = (2.*(dfrp*dfrm)/(dfrp+dfrm)); 169 | } 170 | } 171 | 172 | dfl = alloc2d_float(n, NVARS); 173 | for (int i=0; i= n) irshift -= n; 176 | int irrshift = i+2; 177 | if (irrshift >= n) irrshift -= n; 178 | for (int var=0; var 0.) 183 | dfl[i][var] = (2.*(dflp*dflm)/(dflp+dflm)); 184 | } 185 | } 186 | 187 | for (int i=0; i= n) irshift -= n; 190 | for (int var=0; var500) then 50 | print *, 'invalid n = ', n, ' try again.' 51 | else 52 | exit 53 | endif 54 | enddo 55 | else 56 | call get_command_argument(1, arg) 57 | read( arg,'(I30)'), n 58 | if (n < 2 .or. n > 500) then 59 | print *,'invalid n = ', trim(arg), ' using 100' 60 | n = 100 61 | endif 62 | endif 63 | 64 | locnx = n/comsize 65 | startn= rank*locnx+1 66 | endn = (rank+1)*locnx 67 | if (gridcoords(1) == comsize-1) endn = n 68 | locnx = endn - startn + 1 69 | 70 | nx = locnx+2*nguard ! boundary condition zones on each side 71 | ny = n+2*nguard 72 | allocate(u(nvars,nx,ny)) 73 | 74 | call initialconditions(u,n,startn) 75 | call outputppm(u,trim(rankstr)//'-ics.ppm',idens) 76 | call outputppm_mpiio(u,n,startn,'ics.ppm',idens) 77 | call openplot(locnx, ny) 78 | t=0 79 | timesteps: do iter=1,n*12 80 | call timestep(u,dt,commcart,left,right) 81 | t = t + 2*dt 82 | if (mod(iter,10) == 1) then 83 | if (rank == 0) print *, iter, 'dt = ', dt, ' t = ', t 84 | call showplot(u, startn) 85 | endif 86 | end do timesteps 87 | call outputppm(u,trim(rankstr)//'-dens.ppm',idens) 88 | call outputppm_mpiio(u,n,startn,'dens.ppm',idens) 89 | 90 | deallocate(u) 91 | call MPI_Finalize(ierr) 92 | end 93 | -------------------------------------------------------------------------------- /hydrof/answer/plot.f90: -------------------------------------------------------------------------------- 1 | module plot 2 | 3 | integer, parameter, private :: ncontours=5 4 | public :: openplot, showplot, closeplot 5 | 6 | contains 7 | subroutine openplot(nx, ny) 8 | use solver, only : nguard, idens, iener, imomx, imomy 9 | implicit none 10 | integer, intent(in) :: nx, ny 11 | real :: xl, xr, yl, yr 12 | 13 | xl = 1. 14 | yl = 1. 15 | xr = nx - 2*nguard 16 | yr = ny - 2*nguard 17 | 18 | call pgbeg(0, "/XWINDOW", 1, 1); 19 | call pgask(0) 20 | call pgenv(xl, xr, yl, yr, 1, 1) 21 | end subroutine openplot 22 | 23 | 24 | subroutine showplot(u, startn) 25 | use solver 26 | implicit none 27 | real, dimension(:,:,:), intent(IN) :: u 28 | integer, intent(IN) :: startn 29 | integer :: nx, ny 30 | 31 | real, dimension(ncontours) :: denscontours, prescontours 32 | real, dimension(:,:), allocatable :: dens, pres 33 | real :: maxd, mind, maxp, minp 34 | real :: globmaxd, globmind, globmaxp, globminp 35 | real,dimension(6) :: tr 36 | integer :: i, ierr 37 | 38 | nx = size(u,2) 39 | ny = size(u,3) 40 | 41 | allocate(dens((nx-2*nguard),(ny-2*nguard))) 42 | allocate(pres((nx-2*nguard),(ny-2*nguard))) 43 | dens = u(idens, nguard+1:nx-nguard, nguard+1:ny-nguard) 44 | pres = u(iener, nguard+1:nx-nguard, nguard+1:ny-nguard) - & 45 | 0.5*((u(imomx, nguard+1:nx-nguard, nguard+1:ny-nguard)**2)/dens + & 46 | (u(imomy, nguard+1:nx-nguard, nguard+1:ny-nguard)**2)/dens) 47 | mind = minval(dens) 48 | maxd = maxval(dens) 49 | minp = minval(pres) 50 | maxp = maxval(pres) 51 | call MPI_Allreduce(mind, globmind, 1, MPI_REAL, MPI_MIN, MPI_COMM_WORLD, ierr) 52 | call MPI_Allreduce(maxd, globmaxd, 1, MPI_REAL, MPI_MAX, MPI_COMM_WORLD, ierr) 53 | call MPI_Allreduce(minp, globminp, 1, MPI_REAL, MPI_MIN, MPI_COMM_WORLD, ierr) 54 | call MPI_Allreduce(maxp, globmaxp, 1, MPI_REAL, MPI_MAX, MPI_COMM_WORLD, ierr) 55 | 56 | tr = [startn*1.,1.,0.,0.,0.,1.] 57 | 58 | denscontours = [(globmind+(i*(globmaxd-globmind)/(ncontours+1)), i=1,ncontours)] 59 | prescontours = [(globminp+(i*(globmaxp-globminp)/(ncontours+1)), i=1,ncontours)] 60 | 61 | call pgenv(startn+1., startn+nx-2.*nguard , 1., ny-2.*nguard, 1, 1) 62 | call pgsci(2) 63 | call pgcont(dens, nx-2*nguard, ny-2*nguard, 1, nx-2*nguard, 1, ny-2*nguard, & 64 | denscontours, ncontours, tr) 65 | if (minp /= maxp) then 66 | call pgsci(3) 67 | call pgcont(pres, nx-2*nguard, ny-2*nguard, 1, nx-2*nguard, 1, ny-2*nguard, & 68 | prescontours, ncontours, tr) 69 | endif 70 | call pgsci(1) 71 | deallocate(dens,pres) 72 | end subroutine showplot 73 | 74 | subroutine closeplot 75 | call pgend() 76 | end subroutine closeplot 77 | 78 | end module plot 79 | -------------------------------------------------------------------------------- /hydrof/answer/ppm.f90: -------------------------------------------------------------------------------- 1 | module ppm 2 | use mpi 3 | implicit none 4 | 5 | private :: color 6 | public :: outputppm, outputppm_mpiio 7 | 8 | contains 9 | 10 | pure function color(val, lo, hi) result(rgb) 11 | implicit none 12 | character, dimension(3) :: rgb 13 | real, intent(IN) :: val, lo, hi 14 | 15 | real :: scaleval 16 | integer :: tmp 17 | 18 | scaleval = (val-lo)/(hi-lo) * 255. 19 | tmp = scaleval*3 20 | if (tmp > 255) tmp = 255 21 | rgb(1) = achar(tmp) 22 | rgb(2) = achar(int(scaleval)) 23 | rgb(3) = achar(0) 24 | end function color 25 | 26 | subroutine outputppm(var,filename,varnum) 27 | use solver, only : nguard 28 | implicit none 29 | character(len=*), intent(IN), optional :: filename 30 | integer, intent(IN), optional :: varnum 31 | real, dimension(:,:,:), intent(IN) :: var 32 | character, dimension(:,:,:), allocatable :: rgb 33 | real :: lo, hi 34 | real :: globlo, globhi 35 | integer :: c, i,j 36 | integer :: nx, ny, nvars 37 | character(len=30) :: chosenfilename 38 | integer :: chosenvarnum 39 | integer :: ierr 40 | 41 | if (present(varnum)) then 42 | chosenvarnum = varnum 43 | else 44 | chosenvarnum = 1 45 | endif 46 | if (present(filename)) then 47 | chosenfilename = filename 48 | else 49 | chosenfilename = 'output.ppm' 50 | endif 51 | 52 | nvars = size(var,1) 53 | nx = size(var,2) 54 | ny = size(var,3) 55 | 56 | if (chosenvarnum > nvars) then 57 | print *, 'Invalid variable number ', chosenvarnum 58 | else 59 | allocate(rgb(3,nx,ny)) 60 | 61 | lo = minval(var(chosenvarnum,:,:)) 62 | call MPI_Allreduce(lo, globlo, 1, MPI_REAL, MPI_MIN, MPI_COMM_WORLD, ierr) 63 | hi = maxval(var(chosenvarnum,:,:)) 64 | call MPI_Allreduce(hi, globhi, 1, MPI_REAL, MPI_MAX, MPI_COMM_WORLD, ierr) 65 | 66 | forall (i=1:nx, j=1:ny) 67 | rgb(1:3,i,j) = color(var(chosenvarnum,i,j), globlo, globhi) 68 | end forall 69 | 70 | open(unit=44,file=chosenfilename) 71 | write(44,'(A)') 'P6' 72 | write(44,'(2(1x,i4))') nx, ny 73 | write(44,'(i3)'), 255 74 | write(44,'(9999999A1)',advance='no') (((rgb(c,i,j),c=1,3), i=1,nx),j=ny,1,-1) 75 | close(44) 76 | 77 | deallocate(rgb) 78 | endif 79 | end subroutine outputppm 80 | 81 | 82 | subroutine outputppm_mpiio(var,n,start,filename,varnum) 83 | use solver, only : nguard 84 | implicit none 85 | character(len=*), intent(IN), optional :: filename 86 | integer, intent(IN) :: n, start 87 | integer, intent(IN), optional :: varnum 88 | real, dimension(:,:,:), intent(IN) :: var 89 | character, dimension(:,:,:), allocatable :: rgb 90 | real :: lo, hi 91 | real :: globlo, globhi 92 | integer :: i,j 93 | integer :: nx, ny, nvars 94 | character(len=30) :: chosenfilename 95 | integer :: chosenvarnum 96 | integer :: fileregion 97 | integer :: rank 98 | integer :: ierr 99 | integer :: fh 100 | integer(MPI_OFFSET_KIND) :: offset 101 | integer, dimension(MPI_STATUS_SIZE) :: rstatus 102 | 103 | if (present(varnum)) then 104 | chosenvarnum = varnum 105 | else 106 | chosenvarnum = 1 107 | endif 108 | if (present(filename)) then 109 | chosenfilename = filename 110 | else 111 | chosenfilename = 'output.ppm' 112 | endif 113 | 114 | nvars = size(var,1) 115 | nx = size(var,2) 116 | ny = size(var,3) 117 | 118 | call MPI_Type_create_subarray(2, [3*n,n], [3*(nx-2*nguard), n], [3*(start-1), 0], & 119 | MPI_ORDER_FORTRAN, MPI_CHARACTER, fileregion, ierr) 120 | call MPI_Type_commit(fileregion, ierr) 121 | 122 | call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr) 123 | 124 | if (chosenvarnum > nvars) then 125 | print *, 'Invalid variable number ', chosenvarnum 126 | else 127 | allocate(rgb(3,nx-2*nguard,ny-2*nguard)) 128 | 129 | lo = minval(var(chosenvarnum,:,:)) 130 | call MPI_Allreduce(lo, globlo, 1, MPI_REAL, MPI_MIN, MPI_COMM_WORLD, ierr) 131 | hi = maxval(var(chosenvarnum,:,:)) 132 | call MPI_Allreduce(hi, globhi, 1, MPI_REAL, MPI_MAX, MPI_COMM_WORLD, ierr) 133 | 134 | forall (i=1:nx-2*nguard, j=1:ny-2*nguard) 135 | rgb(1:3,i,j) = color(var(chosenvarnum,i+nguard,j+nguard), globlo, globhi) 136 | end forall 137 | 138 | if (rank == 0) then 139 | open(unit=44,file=chosenfilename) 140 | write(44,'(A)') 'P6' 141 | write(44,'(2(1x,i4))') n, n 142 | write(44,'(i3)'), 255 143 | close(44) 144 | endif 145 | call MPI_File_open(MPI_COMM_WORLD, chosenfilename, ior(MPI_MODE_WRONLY, MPI_MODE_APPEND), & 146 | MPI_INFO_NULL, fh, ierr) 147 | offset = 18 148 | call MPI_File_set_view(fh, offset, MPI_CHARACTER, fileregion, "native", MPI_INFO_NULL, ierr) 149 | call MPI_File_write_all(fh, rgb, 3*(nx-2*nguard)*(ny-2*nguard), MPI_CHARACTER, rstatus, ierr) 150 | call MPI_File_close(fh, ierr) 151 | deallocate(rgb) 152 | endif 153 | end subroutine outputppm_mpiio 154 | 155 | end module ppm 156 | -------------------------------------------------------------------------------- /hydrof/answer/solver.f90: -------------------------------------------------------------------------------- 1 | module solver 2 | use mpi 3 | implicit none 4 | 5 | integer, parameter :: idens=1, iener=4, imomx=2, imomy=3, nvars=4 6 | integer, parameter :: nguard = 2 7 | real, parameter :: gamma=5./3. 8 | 9 | public :: initialconditions, timestep, nguard, gamma 10 | private:: cfl, xytranspose, xsweep, tvd1d, hydroflux 11 | 12 | contains 13 | 14 | subroutine periodicBCs(u,xydim) 15 | implicit none 16 | real, dimension(:,:,:), intent(INOUT) :: u 17 | character, intent(IN) :: xydim 18 | integer :: n 19 | 20 | if (xydim == 'y') then 21 | n = size(u,3) 22 | u(:,:,1:2) = u(:,:,n-3:n-2) 23 | u(:,:,n-1:n) = u(:,:,3:4) 24 | else if (xydim == 'x') then 25 | n = size(u,2) 26 | u(:,1:2,:) = u(:,n-3:n-2,:) 27 | u(:,n-1:n,:) = u(:,3:4,:) 28 | endif 29 | end subroutine periodicBCs 30 | 31 | subroutine bufferGuardcells(u,xydim,commcart,left,right) 32 | real, dimension(:,:,:), intent(INOUT) :: u 33 | character, intent(IN) :: xydim 34 | integer, intent(IN) :: commcart,left,right 35 | integer :: nx, ny 36 | integer :: datasize 37 | real, dimension(:), allocatable:: sendbuffer, rcvbuffer 38 | integer :: ierr 39 | integer :: righttag, lefttag 40 | integer, dimension(MPI_STATUS_SIZE) :: rstatus 41 | 42 | nx = size(u,2) 43 | ny = size(u,3) 44 | 45 | lefttag = 1 46 | righttag = 2 47 | 48 | datasize = (ny-2*nguard)*nguard*nvars 49 | allocate(sendbuffer(datasize),rcvbuffer(datasize)) 50 | 51 | sendbuffer = reshape(u(:, nx-2*nguard+1:nx-nguard, nguard:ny-nguard), [datasize]) 52 | call MPI_Sendrecv(sendbuffer, datasize, MPI_REAL, right, righttag, & 53 | rcvbuffer, datasize, MPI_REAL, left, righttag, commcart, rstatus, ierr) 54 | u(:, 1:nguard, nguard+1:ny-nguard) = reshape(rcvbuffer, [nvars, nguard, ny-2*nguard]) 55 | 56 | sendbuffer = reshape(u(:, nguard+1:2*nguard, nguard:ny-nguard), [datasize]) 57 | call MPI_Sendrecv(sendbuffer, datasize, MPI_REAL, left, lefttag, & 58 | rcvbuffer, datasize, MPI_REAL, right, lefttag, commcart, rstatus, ierr) 59 | u(:, nx-nguard+1:nx, nguard+1:ny-nguard) = reshape(rcvbuffer, [nvars, nguard, ny-2*nguard]) 60 | 61 | deallocate(sendbuffer,rcvbuffer) 62 | end subroutine bufferGuardcells 63 | 64 | subroutine vectorGuardcells(u,xydim,commcart,left,right) 65 | real, dimension(:,:,:), intent(INOUT) :: u 66 | character, intent(IN) :: xydim 67 | integer, intent(IN) :: commcart, left, right 68 | integer :: nx, ny 69 | integer :: xbctype 70 | integer :: lefttag, righttag 71 | integer :: ierr 72 | integer, dimension(MPI_STATUS_SIZE) :: rstatus 73 | 74 | nx = size(u,2) 75 | ny = size(u,3) 76 | 77 | lefttag = 1 78 | righttag = 2 79 | 80 | call MPI_Type_vector(ny, nguard*nvars, nx*nvars, MPI_REAL, xbctype, ierr) 81 | call MPI_Type_commit(xbctype, ierr) 82 | call MPI_Sendrecv(u(1,nx-2*nguard+1,1), 1, xbctype, right, righttag, & 83 | u(1,1,1), 1, xbctype, left, righttag, commcart, rstatus, ierr) 84 | 85 | call MPI_Sendrecv(u(1,nguard+1,1), 1, xbctype, left, lefttag, & 86 | u(1,nx-nguard+1,1), 1, xbctype, right, lefttag, commcart, rstatus, ierr) 87 | 88 | call MPI_Type_free(xbctype, ierr) 89 | end subroutine vectorGuardcells 90 | 91 | subroutine timestep(u,dt,commcart,left,right) 92 | implicit none 93 | real, dimension(:,:,:), intent(INOUT) :: u 94 | real, intent(OUT) :: dt 95 | integer, intent(in) :: commcart,left,right 96 | 97 | real, dimension(nvars,size(u,3),size(u,2)) :: ut 98 | 99 | dt=0.25*cfl(u) 100 | ! the x sweep 101 | call vectorGuardcells(u,'x',commcart,left,right) 102 | call xsweep(u,dt) 103 | ! the y sweeps 104 | call xytranspose(ut,u) 105 | call periodicBCs(ut,'x') 106 | call xsweep(ut,dt) 107 | call periodicBCs(ut,'x') 108 | call xsweep(ut,dt) 109 | ! 2nd x sweep 110 | call xytranspose(u,ut) 111 | call vectorGuardcells(u,'x',commcart,left,right) 112 | call xsweep(u,dt) 113 | end subroutine timestep 114 | 115 | real function cfl(u) 116 | implicit none 117 | real, intent(IN) :: u(:,:,:) 118 | real, dimension(size(u,2),size(u,3)) :: v, p 119 | real :: c 120 | real :: globc 121 | integer :: ierr 122 | 123 | v = abs(u(imomx,:,:)/u(idens,:,:)) 124 | where (v < abs(u(imomy,:,:))/u(idens,:,:)) 125 | v = abs(u(imomy,:,:)/u(idens,:,:)) 126 | endwhere 127 | 128 | p = (u(iener,:,:)-0.5*(u(imomx,:,:)**2+u(imomy,:,:)**2)/u(idens,:,:))*(gamma-1.) 129 | c = maxval(v+sqrt(abs((gamma*p))/u(idens,:,:))) 130 | 131 | call MPI_Allreduce(c, globc, 1, MPI_REAL, MPI_MAX, MPI_COMM_WORLD, ierr) 132 | cfl=1./globc 133 | end function cfl 134 | 135 | subroutine initialconditions(u,n,startn) 136 | implicit none 137 | real, intent(OUT) :: u(:,:,:) 138 | integer, intent(IN) :: n, startn 139 | integer :: nx, ny 140 | 141 | integer :: i,j 142 | real, parameter :: backgrounddens=1., projdens=50., projvel=4., p0=1. 143 | real :: r(size(u,2), size(u,3)) 144 | 145 | nx = size(u,2) 146 | ny = size(u,3) 147 | 148 | forall (i=1:nx,j=1:ny) 149 | r(i,j) =sqrt((j*1-n/2.)**2. + ((i+startn-1)*1.-n/2.)**2) 150 | endforall 151 | 152 | where (r < 0.1*sqrt(n*n+n*n*1.)) 153 | u(idens,:,:) =projdens 154 | u(imomx,:,:) =projdens*projvel 155 | u(imomy,:,:) =0 156 | u(iener,:,:) =0.5*(projdens*projvel*projvel)+p0/(gamma-1.) 157 | elsewhere 158 | u(idens,:,:) =backgrounddens 159 | u(imomx,:,:) =0. 160 | u(imomy,:,:) =0. 161 | u(iener,:,:) =p0/(gamma-1.) 162 | endwhere 163 | 164 | end subroutine initialconditions 165 | 166 | subroutine xsweep(u,dt) 167 | implicit none 168 | real, intent(INOUT), dimension(:,:,:) :: u 169 | real, intent(IN) :: dt 170 | integer :: j 171 | 172 | do j=1,size(u,3) 173 | call tvd1d(u(:,:,j),dt) 174 | enddo 175 | end subroutine xsweep 176 | 177 | subroutine tvd1d(u,dt) 178 | implicit none 179 | real, intent(IN) :: dt 180 | real, dimension(:,:), intent(INOUT) :: u 181 | 182 | real, dimension(size(u,1),size(u,2)) :: v, u1, wr, wl 183 | real, dimension(size(u,1),size(u,2)) :: dfrp, dfrm, dflm, dflp 184 | real, dimension(size(u,1),size(u,2)) :: dfl, dfr 185 | real, dimension(size(u,1),size(u,2)) :: flux 186 | real, dimension(size(u,1),size(u,2)) :: du 187 | real :: c 188 | real, parameter :: smallp = 1.e-3 189 | integer :: i, n 190 | 191 | n = size(u,2) 192 | 193 | call hydroflux(v,c,u) 194 | wr = u+v 195 | wl = u-v 196 | flux=c*(wr - eoshift(wl,1,dim=2))/2. 197 | u1 = u - (flux - eoshift(flux,-1,dim=2))*dt/2. 198 | 199 | call hydroflux(v,c,u1) 200 | wr = u1+v 201 | wl = u1-v 202 | 203 | dfrp = c*(eoshift(wr,1,dim=2)-wr)/2. 204 | dfrm = c*(wr-eoshift(wr,-1,dim=2))/2. 205 | where (dfrp*dfrm > 0) 206 | dfr = 2*dfrp*dfrm/(dfrp+dfrm) 207 | elsewhere 208 | dfr = 0 209 | endwhere 210 | 211 | dflp = c*(eoshift(wl,1,dim=2)-eoshift(wl,2,dim=2))/2. 212 | dflm = c*(wl-eoshift(wl,1,dim=2))/2. 213 | where (dflp*dflm > 0) 214 | dfl = 2*dflp*dflm/(dflp+dflm) 215 | elsewhere 216 | dfl = 0 217 | endwhere 218 | 219 | flux = (c*(wr-eoshift(wl,1,dim=2)) + (dfr-dfl))/2. 220 | du = (flux-eoshift(flux,-1,dim=2))*dt 221 | u(:,3:n-2) = u(:,3:n-2) - du(:,3:n-2) 222 | 223 | do i=1,n 224 | if ( ((u(iener,i)-0.5*(u(imomx,i)**2+u(imomy,i)**2)/u(idens,i))*(gamma-1.)) < smallp ) & 225 | u(iener,i) = 0.5*(u(imomx,i)**2+u(imomy,i)**2)/u(idens,i) + smallp/(gamma-1.) 226 | enddo 227 | end subroutine tvd1d 228 | 229 | subroutine hydroflux(v,c,u) 230 | implicit none 231 | real, intent(OUT) :: c 232 | real, dimension(:,:), intent(IN) :: u 233 | real, dimension(:,:), intent(OUT) :: v 234 | real, dimension(size(u,2)) :: vx, p 235 | 236 | c = 0. 237 | vx = u(imomx,:)/u(idens,:) 238 | p = (u(iener,:)-(u(imomx,:)**2+u(imomy,:)**2)/u(idens,:)/2)*(gamma-1) 239 | 240 | v(idens,:)=u(imomx,:) 241 | v(imomx,:)=u(imomx,:)*vx + p 242 | v(imomy,:)=u(imomy,:)*vx 243 | v(iener,:)=(u(iener,:)+p)*vx 244 | 245 | c=maxval(abs(vx)+sqrt(abs(gamma*p/u(idens,:)))) 246 | if (c > 0) v = v/c 247 | end subroutine hydroflux 248 | 249 | subroutine xytranspose(ut,u) 250 | implicit none 251 | real, dimension(:,:,:), intent(IN) :: u 252 | real, dimension(:,:,:), intent(OUT) :: ut 253 | 254 | ut(idens,:,:)=transpose(u(idens,:,:)) 255 | ut(imomx,:,:)=transpose(u(imomy,:,:)) 256 | ut(imomy,:,:)=transpose(u(imomx,:,:)) 257 | ut(iener,:,:)=transpose(u(iener,:,:)) 258 | end subroutine xytranspose 259 | 260 | end module solver 261 | -------------------------------------------------------------------------------- /hydrof/hydro.f90: -------------------------------------------------------------------------------- 1 | ! 2 | ! F77-ized version of a Fortran90 TVD split MHD code 3 | ! 4 | ! Original F90 code copyright (C) 2001,2003, Ue-Li Pen 5 | ! written November 2001 by Ue-Li Pen, pen@cita.utoronto.ca 6 | ! 7 | ! see http://arxiv.org/abs/astro-ph/0305088 8 | ! or http://www.cita.utoronto.ca/~pen/MHD 9 | ! 10 | ! This code is licencensed under the GPL 11 | ! 12 | program hydro 13 | use ppm, only : outputppm 14 | use solver, only : nvars, timestep, idens, initialconditions, nguard 15 | use plot, only : openplot, showplot, closeplot 16 | 17 | implicit none 18 | integer :: n,nx,ny 19 | real :: t,dt 20 | integer :: iter 21 | real, allocatable, dimension(:,:,:) :: u 22 | character(len=30) :: arg 23 | 24 | ! get domain size from command line; if nothing 25 | ! on command line, prompt user 26 | 27 | if (command_argument_count() < 1) then 28 | print *,'Enter size of domain, in pixels ' 29 | do 30 | read *, n 31 | if (n < 2 .or. n>500) then 32 | print *, 'invalid n = ', n, ' try again.' 33 | else 34 | exit 35 | endif 36 | enddo 37 | else 38 | call get_command_argument(1, arg) 39 | read( arg,'(I30)'), n 40 | if (n < 2 .or. n > 500) then 41 | print *,'invalid n = ', trim(arg), ' using 100' 42 | n = 100 43 | endif 44 | endif 45 | nx = n+2*nguard ! boundary condition zones on each side 46 | ny = n+2*nguard 47 | allocate(u(nvars,nx,ny)) 48 | 49 | call initialconditions(u) 50 | call outputppm(u,'ics.ppm',idens) 51 | call openplot(nx, ny) 52 | t=0 53 | timesteps: do iter=1,nx*12 54 | call timestep(u,dt) 55 | t = t + 2*dt 56 | if (mod(iter,10) == 1) then 57 | print *, iter, 'dt = ', dt, ' t = ', t 58 | call showplot(u) 59 | endif 60 | end do timesteps 61 | call outputppm(u,'dens.ppm',idens) 62 | 63 | deallocate(u) 64 | end 65 | -------------------------------------------------------------------------------- /hydrof/mpi/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.inc 2 | 3 | .SUFFIXES:.mod 4 | 5 | FFLAGS+=-g 6 | hydro: hydro.o ppm.o solver.o plot.o 7 | $(MPIF90) -o $@ $^ $(FFLAGS) $(PGPLIBS) 8 | 9 | hydro.o: hydro.f90 ppm.mod solver.mod plot.mod 10 | $(MPIF90) -c hydro.f90 $(FFLAGS) 11 | 12 | ppm.mod: ppm.f90 solver.mod 13 | $(MPIF90) -c $^ $(FFLAGS) 14 | 15 | plot.o: plot.f90 solver.mod 16 | $(MPIF90) -c $^ $(FFLAGS) 17 | 18 | %.mod: %.f90 19 | $(MPIF90) -c $^ $(FFLAGS) 20 | 21 | %.o: %.f90 22 | $(MPIF90) -c $^ $(FFLAGS) 23 | 24 | clean: 25 | rm -f hydro *.o *.dat *.mod *~ *ppm 26 | -------------------------------------------------------------------------------- /hydrof/mpi/hydro.f90: -------------------------------------------------------------------------------- 1 | ! 2 | ! F77-ized version of a Fortran90 TVD split MHD code 3 | ! 4 | ! Original F90 code copyright (C) 2001,2003, Ue-Li Pen 5 | ! written November 2001 by Ue-Li Pen, pen@cita.utoronto.ca 6 | ! 7 | ! see http://arxiv.org/abs/astro-ph/0305088 8 | ! or http://www.cita.utoronto.ca/~pen/MHD 9 | ! 10 | ! This code is licencensed under the GPL 11 | ! 12 | program hydro 13 | use mpi 14 | use ppm, only : outputppm, outputppm_mpiio 15 | use solver, only : nvars, timestep, idens, initialconditions, nguard 16 | use plot, only : openplot, showplot, closeplot 17 | implicit none 18 | 19 | integer :: n,nx,ny 20 | real :: t,dt 21 | integer :: iter 22 | real, allocatable, dimension(:,:,:) :: u 23 | character(len=30) :: arg 24 | character(len=3) :: rankstr 25 | 26 | integer :: ierr 27 | integer :: rank, comsize 28 | integer :: commcart 29 | integer :: left, right 30 | integer :: gridcoords(2) 31 | integer :: startn, endn, locnx 32 | 33 | call MPI_Init(ierr) 34 | call MPI_Comm_size(MPI_COMM_WORLD, comsize, ierr) 35 | call MPI_Cart_create(MPI_COMM_WORLD, 2, [comsize,1], & 36 | [.true.,.true.], .true., commcart, ierr) 37 | call MPI_Comm_rank(commcart, rank, ierr) 38 | call MPI_Cart_shift(commcart, 0, 1, left, right, ierr) 39 | call MPI_Cart_coords(commcart, rank, 2, gridcoords, ierr) 40 | 41 | write(rankstr,fmt='(I0)') rank 42 | ! get domain size from command line; if nothing 43 | ! on command line, prompt user 44 | 45 | if (command_argument_count() < 1) then 46 | print *,'Enter size of domain, in pixels ' 47 | do 48 | read *, n 49 | if (n < 2 .or. n>500) then 50 | print *, 'invalid n = ', n, ' try again.' 51 | else 52 | exit 53 | endif 54 | enddo 55 | else 56 | call get_command_argument(1, arg) 57 | read( arg,'(I30)'), n 58 | if (n < 2 .or. n > 500) then 59 | print *,'invalid n = ', trim(arg), ' using 100' 60 | n = 100 61 | endif 62 | endif 63 | 64 | ! calculate an nx and an ny from n, rank 65 | locnx = n/comsize 66 | startn= rank*locnx+1 67 | endn = (rank+1)*locnx 68 | if (gridcoords(1) == comsize-1) endn = n 69 | locnx = endn - startn + 1 70 | 71 | nx = locnx+2*nguard 72 | ny = n+2*nguard 73 | allocate(u(nvars,nx,ny)) 74 | 75 | call initialconditions(u,n,startn) 76 | call outputppm(u,trim(rankstr)//'-ics.ppm',idens) 77 | !call outputppm_mpiio(u,n,startn,'ics.ppm',idens) 78 | call openplot(locnx, ny) 79 | t=0 80 | timesteps: do iter=1,n*12 81 | call timestep(u,dt,commcart,left,right) 82 | t = t + 2*dt 83 | if (mod(iter,10) == 1) then 84 | if (rank == 0) print *, iter, 'dt = ', dt, ' t = ', t 85 | call showplot(u, startn) 86 | endif 87 | end do timesteps 88 | call outputppm(u,trim(rankstr)//'-dens.ppm',idens) 89 | !call outputppm_mpiio(u,n,startn,'dens.ppm',idens) 90 | 91 | deallocate(u) 92 | call MPI_Finalize(ierr) 93 | end 94 | -------------------------------------------------------------------------------- /hydrof/mpi/plot.f90: -------------------------------------------------------------------------------- 1 | module plot 2 | 3 | integer, parameter, private :: ncontours=5 4 | public :: openplot, showplot, closeplot 5 | 6 | contains 7 | subroutine openplot(nx, ny) 8 | use solver, only : nguard, idens, iener, imomx, imomy 9 | implicit none 10 | integer, intent(in) :: nx, ny 11 | real :: xl, xr, yl, yr 12 | 13 | xl = 1. 14 | yl = 1. 15 | xr = nx - 2*nguard 16 | yr = ny - 2*nguard 17 | 18 | call pgbeg(0, "/XWINDOW", 1, 1); 19 | call pgask(0) 20 | call pgenv(xl, xr, yl, yr, 1, 1) 21 | end subroutine openplot 22 | 23 | 24 | subroutine showplot(u, startn) 25 | use solver 26 | implicit none 27 | real, dimension(:,:,:), intent(IN) :: u 28 | integer, intent(IN) :: startn 29 | integer :: nx, ny 30 | 31 | real, dimension(ncontours) :: denscontours, prescontours 32 | real, dimension(:,:), allocatable :: dens, pres 33 | real :: maxd, mind, maxp, minp 34 | real :: globmaxd, globmind, globmaxp, globminp 35 | real,dimension(6) :: tr 36 | integer :: i, ierr 37 | 38 | nx = size(u,2) 39 | ny = size(u,3) 40 | 41 | allocate(dens((nx-2*nguard),(ny-2*nguard))) 42 | allocate(pres((nx-2*nguard),(ny-2*nguard))) 43 | dens = u(idens, nguard+1:nx-nguard, nguard+1:ny-nguard) 44 | pres = u(iener, nguard+1:nx-nguard, nguard+1:ny-nguard) - & 45 | 0.5*((u(imomx, nguard+1:nx-nguard, nguard+1:ny-nguard)**2)/dens + & 46 | (u(imomy, nguard+1:nx-nguard, nguard+1:ny-nguard)**2)/dens) 47 | mind = minval(dens) 48 | maxd = maxval(dens) 49 | minp = minval(pres) 50 | maxp = maxval(pres) 51 | 52 | ! get globmind, globmaxd, mind, maxd from mind/maxd/minp/maxp 53 | globmind = mind 54 | globminp = minp 55 | globmaxd = maxd 56 | globmaxp = maxp 57 | 58 | tr = [startn*1.,1.,0.,0.,0.,1.] 59 | 60 | denscontours = [(globmind+(i*(globmaxd-globmind)/(ncontours+1)), i=1,ncontours)] 61 | prescontours = [(globminp+(i*(globmaxp-globminp)/(ncontours+1)), i=1,ncontours)] 62 | 63 | call pgenv(startn+1., startn+nx-2.*nguard , 1., ny-2.*nguard, 1, 1) 64 | call pgsci(2) 65 | call pgcont(dens, nx-2*nguard, ny-2*nguard, 1, nx-2*nguard, 1, ny-2*nguard, & 66 | denscontours, ncontours, tr) 67 | if (minp /= maxp) then 68 | call pgsci(3) 69 | call pgcont(pres, nx-2*nguard, ny-2*nguard, 1, nx-2*nguard, 1, ny-2*nguard, & 70 | prescontours, ncontours, tr) 71 | endif 72 | call pgsci(1) 73 | deallocate(dens,pres) 74 | end subroutine showplot 75 | 76 | subroutine closeplot 77 | call pgend() 78 | end subroutine closeplot 79 | 80 | end module plot 81 | -------------------------------------------------------------------------------- /hydrof/mpi/ppm.f90: -------------------------------------------------------------------------------- 1 | module ppm 2 | use mpi 3 | implicit none 4 | 5 | private :: color 6 | public :: outputppm, outputppm_mpiio 7 | 8 | contains 9 | 10 | pure function color(val, lo, hi) result(rgb) 11 | implicit none 12 | character, dimension(3) :: rgb 13 | real, intent(IN) :: val, lo, hi 14 | 15 | real :: scaleval 16 | integer :: tmp 17 | 18 | scaleval = (val-lo)/(hi-lo) * 255. 19 | tmp = scaleval*3 20 | if (tmp > 255) tmp = 255 21 | rgb(1) = achar(tmp) 22 | rgb(2) = achar(int(scaleval)) 23 | rgb(3) = achar(0) 24 | end function color 25 | 26 | subroutine outputppm(var,filename,varnum) 27 | use solver, only : nguard 28 | implicit none 29 | character(len=*), intent(IN), optional :: filename 30 | integer, intent(IN), optional :: varnum 31 | real, dimension(:,:,:), intent(IN) :: var 32 | character, dimension(:,:,:), allocatable :: rgb 33 | real :: lo, hi 34 | real :: globlo, globhi 35 | integer :: c, i,j 36 | integer :: nx, ny, nvars 37 | character(len=30) :: chosenfilename 38 | integer :: chosenvarnum 39 | integer :: ierr 40 | 41 | if (present(varnum)) then 42 | chosenvarnum = varnum 43 | else 44 | chosenvarnum = 1 45 | endif 46 | if (present(filename)) then 47 | chosenfilename = filename 48 | else 49 | chosenfilename = 'output.ppm' 50 | endif 51 | 52 | nvars = size(var,1) 53 | nx = size(var,2) 54 | ny = size(var,3) 55 | 56 | if (chosenvarnum > nvars) then 57 | print *, 'Invalid variable number ', chosenvarnum 58 | else 59 | allocate(rgb(3,nx,ny)) 60 | 61 | lo = minval(var(chosenvarnum,:,:)) 62 | hi = maxval(var(chosenvarnum,:,:)) 63 | ! get globhi, globlo from hi, lo 64 | globhi = hi 65 | globlo = lo 66 | 67 | forall (i=1:nx, j=1:ny) 68 | rgb(1:3,i,j) = color(var(chosenvarnum,i,j), globlo, globhi) 69 | end forall 70 | 71 | open(unit=44,file=chosenfilename) 72 | write(44,'(A)') 'P6' 73 | write(44,'(2(1x,i4))') nx, ny 74 | write(44,'(i3)'), 255 75 | write(44,'(9999999A1)',advance='no') (((rgb(c,i,j),c=1,3), i=1,nx),j=ny,1,-1) 76 | close(44) 77 | 78 | deallocate(rgb) 79 | endif 80 | end subroutine outputppm 81 | 82 | 83 | subroutine outputppm_mpiio(var,n,start,filename,varnum) 84 | use solver, only : nguard 85 | implicit none 86 | character(len=*), intent(IN), optional :: filename 87 | integer, intent(IN) :: n, start 88 | integer, intent(IN), optional :: varnum 89 | real, dimension(:,:,:), intent(IN) :: var 90 | character, dimension(:,:,:), allocatable :: rgb 91 | real :: lo, hi 92 | real :: globlo, globhi 93 | integer :: i,j 94 | integer :: nx, ny, nvars 95 | character(len=30) :: chosenfilename 96 | integer :: chosenvarnum 97 | integer :: fileregion 98 | integer :: rank 99 | integer :: ierr 100 | integer :: fh 101 | integer(MPI_OFFSET_KIND) :: offset 102 | integer, dimension(MPI_STATUS_SIZE) :: rstatus 103 | 104 | if (present(varnum)) then 105 | chosenvarnum = varnum 106 | else 107 | chosenvarnum = 1 108 | endif 109 | if (present(filename)) then 110 | chosenfilename = filename 111 | else 112 | chosenfilename = 'output.ppm' 113 | endif 114 | 115 | nvars = size(var,1) 116 | nx = size(var,2) 117 | ny = size(var,3) 118 | 119 | ! create fileregion type for describing "my" part of array 120 | call MPI_Type_commit(fileregion, ierr) 121 | 122 | call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr) 123 | 124 | if (chosenvarnum > nvars) then 125 | print *, 'Invalid variable number ', chosenvarnum 126 | else 127 | allocate(rgb(3,nx-2*nguard,ny-2*nguard)) 128 | 129 | lo = minval(var(chosenvarnum,:,:)) 130 | hi = maxval(var(chosenvarnum,:,:)) 131 | ! get globhi, globlo from hi, lo 132 | globhi = hi 133 | globlo = lo 134 | 135 | forall (i=1:nx-2*nguard, j=1:ny-2*nguard) 136 | rgb(1:3,i,j) = color(var(chosenvarnum,i+nguard,j+nguard), globlo, globhi) 137 | end forall 138 | 139 | ! output header 140 | if (rank == 0) then 141 | open(unit=44,file=chosenfilename) 142 | write(44,'(A)') 'P6' 143 | write(44,'(2(1x,i4))') n, n 144 | write(44,'(i3)'), 255 145 | close(44) 146 | endif 147 | ! do MPI-IO stuff 148 | deallocate(rgb) 149 | endif 150 | end subroutine outputppm_mpiio 151 | 152 | end module ppm 153 | -------------------------------------------------------------------------------- /hydrof/mpi/solver.f90: -------------------------------------------------------------------------------- 1 | module solver 2 | use mpi 3 | implicit none 4 | 5 | integer, parameter :: idens=1, iener=4, imomx=2, imomy=3, nvars=4 6 | integer, parameter :: nguard = 2 7 | real, parameter :: gamma=5./3. 8 | 9 | public :: initialconditions, timestep, nguard, gamma 10 | private:: cfl, xytranspose, xsweep, tvd1d, hydroflux 11 | 12 | contains 13 | 14 | subroutine periodicBCs(u,xydim) 15 | implicit none 16 | real, dimension(:,:,:), intent(INOUT) :: u 17 | character, intent(IN) :: xydim 18 | integer :: n 19 | 20 | if (xydim == 'y') then 21 | n = size(u,3) 22 | u(:,:,1:2) = u(:,:,n-3:n-2) 23 | u(:,:,n-1:n) = u(:,:,3:4) 24 | else if (xydim == 'x') then 25 | n = size(u,2) 26 | u(:,1:2,:) = u(:,n-3:n-2,:) 27 | u(:,n-1:n,:) = u(:,3:4,:) 28 | endif 29 | end subroutine periodicBCs 30 | 31 | subroutine bufferGuardcells(u,xydim,commcart,left,right) 32 | real, dimension(:,:,:), intent(INOUT) :: u 33 | character, intent(IN) :: xydim 34 | integer, intent(IN) :: commcart,left,right 35 | integer :: nx, ny 36 | integer :: datasize 37 | real, dimension(:), allocatable:: sendbuffer, rcvbuffer 38 | integer :: ierr 39 | integer :: righttag, lefttag 40 | integer, dimension(MPI_STATUS_SIZE) :: rstatus 41 | 42 | nx = size(u,2) 43 | ny = size(u,3) 44 | 45 | lefttag = 1 46 | righttag = 2 47 | 48 | datasize = (ny-2*nguard)*nguard*nvars 49 | allocate(sendbuffer(datasize),rcvbuffer(datasize)) 50 | 51 | ! rightward 52 | ! Copy data into buffer 53 | ! 54 | ! call MPI_Sendrecv(sendbuffer, datasize, ..? 55 | ! rcvbuffer, datasize, ..? 56 | ! copy data out of buffer. 57 | 58 | ! leftward 59 | ! Copy data into buffer 60 | ! 61 | ! call MPI_Sendrecv(sendbuffer, datasize, ..? 62 | ! rcvbuffer, datasize, ..? 63 | ! copy data out of buffer. 64 | 65 | 66 | deallocate(sendbuffer,rcvbuffer) 67 | end subroutine bufferGuardcells 68 | 69 | subroutine vectorGuardcells(u,xydim,commcart,left,right) 70 | real, dimension(:,:,:), intent(INOUT) :: u 71 | character, intent(IN) :: xydim 72 | integer, intent(IN) :: commcart, left, right 73 | integer :: nx, ny 74 | integer :: xbctype 75 | integer :: lefttag, righttag 76 | integer :: ierr 77 | integer, dimension(MPI_STATUS_SIZE) :: rstatus 78 | 79 | nx = size(u,2) 80 | ny = size(u,3) 81 | 82 | lefttag = 1 83 | righttag = 2 84 | 85 | ! call MPI_Type_vector(...?) 86 | call MPI_Type_commit(xbctype, ierr) 87 | 88 | ! call MPI_Sendrecv(...? 89 | ! call MPI_Sendrecv(...? 90 | 91 | call MPI_Type_free(xbctype, ierr) 92 | end subroutine vectorGuardcells 93 | 94 | subroutine timestep(u,dt,commcart,left,right) 95 | implicit none 96 | real, dimension(:,:,:), intent(INOUT) :: u 97 | real, intent(OUT) :: dt 98 | integer, intent(in) :: commcart,left,right 99 | 100 | real, dimension(nvars,size(u,3),size(u,2)) :: ut 101 | 102 | dt=0.25*cfl(u) 103 | ! the x sweep 104 | call periodicBCs(u,'x') 105 | !call vectorGuardcells(u,'x',commcart,left,right) 106 | call xsweep(u,dt) 107 | ! the y sweeps 108 | call xytranspose(ut,u) 109 | call periodicBCs(ut,'x') 110 | call xsweep(ut,dt) 111 | call periodicBCs(ut,'x') 112 | call xsweep(ut,dt) 113 | ! 2nd x sweep 114 | call xytranspose(u,ut) 115 | call periodicBCs(u,'x') 116 | !call vectorGuardcells(u,'x',commcart,left,right) 117 | call xsweep(u,dt) 118 | end subroutine timestep 119 | 120 | real function cfl(u) 121 | implicit none 122 | real, intent(IN) :: u(:,:,:) 123 | real, dimension(size(u,2),size(u,3)) :: v, p 124 | real :: c 125 | real :: globc 126 | integer :: ierr 127 | 128 | v = abs(u(imomx,:,:)/u(idens,:,:)) 129 | where (v < abs(u(imomy,:,:))/u(idens,:,:)) 130 | v = abs(u(imomy,:,:)/u(idens,:,:)) 131 | endwhere 132 | 133 | p = (u(iener,:,:)-0.5*(u(imomx,:,:)**2+u(imomy,:,:)**2)/u(idens,:,:))*(gamma-1.) 134 | c = maxval(v+sqrt(abs((gamma*p))/u(idens,:,:))) 135 | 136 | ! find global max of all c's 137 | call MPI_Allreduce(c, globc, 1, MPI_REAL, MPI_MAX, MPI_COMM_WORLD, ierr) 138 | cfl=1./globc 139 | end function cfl 140 | 141 | subroutine initialconditions(u,n,startn) 142 | implicit none 143 | real, intent(OUT) :: u(:,:,:) 144 | integer, intent(IN) :: n, startn 145 | integer :: nx, ny 146 | 147 | integer :: i,j 148 | real, parameter :: backgrounddens=1., projdens=50., projvel=4., p0=1. 149 | real :: r(size(u,2), size(u,3)) 150 | 151 | nx = size(u,2) 152 | ny = size(u,3) 153 | 154 | forall (i=1:nx,j=1:ny) 155 | r(i,j) =sqrt((j*1-n/2.)**2. + ((i+startn-1)*1.-n/2.)**2) 156 | endforall 157 | 158 | where (r < 0.1*sqrt(n*n+n*n*1.)) 159 | u(idens,:,:) =projdens 160 | u(imomx,:,:) =projdens*projvel 161 | u(imomy,:,:) =0 162 | u(iener,:,:) =0.5*(projdens*projvel*projvel)+p0/(gamma-1.) 163 | elsewhere 164 | u(idens,:,:) =backgrounddens 165 | u(imomx,:,:) =0. 166 | u(imomy,:,:) =0. 167 | u(iener,:,:) =p0/(gamma-1.) 168 | endwhere 169 | 170 | end subroutine initialconditions 171 | 172 | subroutine xsweep(u,dt) 173 | implicit none 174 | real, intent(INOUT), dimension(:,:,:) :: u 175 | real, intent(IN) :: dt 176 | integer :: j 177 | 178 | do j=1,size(u,3) 179 | call tvd1d(u(:,:,j),dt) 180 | enddo 181 | end subroutine xsweep 182 | 183 | subroutine tvd1d(u,dt) 184 | implicit none 185 | real, intent(IN) :: dt 186 | real, dimension(:,:), intent(INOUT) :: u 187 | 188 | real, dimension(size(u,1),size(u,2)) :: v, u1, wr, wl 189 | real, dimension(size(u,1),size(u,2)) :: dfrp, dfrm, dflm, dflp 190 | real, dimension(size(u,1),size(u,2)) :: dfl, dfr 191 | real, dimension(size(u,1),size(u,2)) :: flux 192 | real, dimension(size(u,1),size(u,2)) :: du 193 | real :: c 194 | real, parameter :: smallp = 1.e-3 195 | integer :: i, n 196 | 197 | n = size(u,2) 198 | 199 | call hydroflux(v,c,u) 200 | wr = u+v 201 | wl = u-v 202 | flux=c*(wr - eoshift(wl,1,dim=2))/2. 203 | u1 = u - (flux - eoshift(flux,-1,dim=2))*dt/2. 204 | 205 | call hydroflux(v,c,u1) 206 | wr = u1+v 207 | wl = u1-v 208 | 209 | dfrp = c*(eoshift(wr,1,dim=2)-wr)/2. 210 | dfrm = c*(wr-eoshift(wr,-1,dim=2))/2. 211 | where (dfrp*dfrm > 0) 212 | dfr = 2*dfrp*dfrm/(dfrp+dfrm) 213 | elsewhere 214 | dfr = 0 215 | endwhere 216 | 217 | dflp = c*(eoshift(wl,1,dim=2)-eoshift(wl,2,dim=2))/2. 218 | dflm = c*(wl-eoshift(wl,1,dim=2))/2. 219 | where (dflp*dflm > 0) 220 | dfl = 2*dflp*dflm/(dflp+dflm) 221 | elsewhere 222 | dfl = 0 223 | endwhere 224 | 225 | flux = (c*(wr-eoshift(wl,1,dim=2)) + (dfr-dfl))/2. 226 | du = (flux-eoshift(flux,-1,dim=2))*dt 227 | u(:,3:n-2) = u(:,3:n-2) - du(:,3:n-2) 228 | 229 | do i=1,n 230 | if ( ((u(iener,i)-0.5*(u(imomx,i)**2+u(imomy,i)**2)/u(idens,i))*(gamma-1.)) < smallp ) & 231 | u(iener,i) = 0.5*(u(imomx,i)**2+u(imomy,i)**2)/u(idens,i) + smallp/(gamma-1.) 232 | enddo 233 | end subroutine tvd1d 234 | 235 | subroutine hydroflux(v,c,u) 236 | implicit none 237 | real, intent(OUT) :: c 238 | real, dimension(:,:), intent(IN) :: u 239 | real, dimension(:,:), intent(OUT) :: v 240 | real, dimension(size(u,2)) :: vx, p 241 | 242 | c = 0. 243 | vx = u(imomx,:)/u(idens,:) 244 | p = (u(iener,:)-(u(imomx,:)**2+u(imomy,:)**2)/u(idens,:)/2)*(gamma-1) 245 | 246 | v(idens,:)=u(imomx,:) 247 | v(imomx,:)=u(imomx,:)*vx + p 248 | v(imomy,:)=u(imomy,:)*vx 249 | v(iener,:)=(u(iener,:)+p)*vx 250 | 251 | c=maxval(abs(vx)+sqrt(abs(gamma*p/u(idens,:)))) 252 | if (c > 0) v = v/c 253 | end subroutine hydroflux 254 | 255 | subroutine xytranspose(ut,u) 256 | implicit none 257 | real, dimension(:,:,:), intent(IN) :: u 258 | real, dimension(:,:,:), intent(OUT) :: ut 259 | 260 | ut(idens,:,:)=transpose(u(idens,:,:)) 261 | ut(imomx,:,:)=transpose(u(imomy,:,:)) 262 | ut(imomy,:,:)=transpose(u(imomx,:,:)) 263 | ut(iener,:,:)=transpose(u(iener,:,:)) 264 | end subroutine xytranspose 265 | 266 | end module solver 267 | -------------------------------------------------------------------------------- /hydrof/plot.f90: -------------------------------------------------------------------------------- 1 | module plot 2 | 3 | integer, parameter, private :: ncontours=5 4 | public :: openplot, showplot, closeplot 5 | 6 | contains 7 | subroutine openplot(nx, ny) 8 | use solver, only : nguard, idens, iener, imomx, imomy 9 | implicit none 10 | integer, intent(in) :: nx, ny 11 | real :: xl, xr, yl, yr 12 | 13 | xl = 1. 14 | yl = 1. 15 | xr = nx - 2*nguard 16 | yr = ny - 2*nguard 17 | 18 | call pgbeg(0, "/XWINDOW", 1, 1); 19 | call pgask(0) 20 | call pgenv(xl, xr, yl, yr, 1, 1) 21 | end subroutine openplot 22 | 23 | 24 | subroutine showplot(u) 25 | use solver 26 | implicit none 27 | real, dimension(:,:,:), intent(IN) :: u 28 | integer :: nx, ny 29 | 30 | real, dimension(ncontours) :: denscontours, prescontours 31 | real, dimension(:,:), allocatable :: dens, pres 32 | real :: maxd, mind, maxp, minp 33 | real,dimension(6) :: tr 34 | integer :: i 35 | 36 | nx = size(u,2) 37 | ny = size(u,3) 38 | 39 | allocate(dens((nx-2*nguard),(ny-2*nguard))) 40 | allocate(pres((nx-2*nguard),(ny-2*nguard))) 41 | dens = u(idens, nguard+1:nx-nguard, nguard+1:ny-nguard) 42 | pres = u(iener, nguard+1:nx-nguard, nguard+1:ny-nguard) - & 43 | 0.5*((u(imomx, nguard+1:nx-nguard, nguard+1:ny-nguard)**2)/dens + & 44 | (u(imomy, nguard+1:nx-nguard, nguard+1:ny-nguard)**2)/dens) 45 | mind = minval(dens) 46 | maxd = maxval(dens) 47 | minp = minval(pres) 48 | maxp = maxval(pres) 49 | 50 | tr = [0.,1.,0.,0.,0.,1.] 51 | 52 | denscontours = [(mind+(i*(maxd-mind)/(ncontours+1)), i=1,ncontours)] 53 | prescontours = [(minp+(i*(maxp-minp)/(ncontours+1)), i=1,ncontours)] 54 | 55 | call pgenv(1., nx-2.*nguard , 1., nx-2.*nguard, 1, 1) 56 | call pgsci(2) 57 | call pgcont(dens, nx-2*nguard, ny-2*nguard, 1, nx-2*nguard, 1, ny-2*nguard, & 58 | denscontours, ncontours, tr) 59 | if (minp /= maxp) then 60 | call pgsci(3) 61 | call pgcont(pres, nx-2*nguard, ny-2*nguard, 1, nx-2*nguard, 1, ny-2*nguard, & 62 | prescontours, ncontours, tr) 63 | endif 64 | call pgsci(1) 65 | deallocate(dens,pres) 66 | end subroutine showplot 67 | 68 | subroutine closeplot 69 | call pgend() 70 | end subroutine closeplot 71 | 72 | end module plot 73 | -------------------------------------------------------------------------------- /hydrof/ppm.f90: -------------------------------------------------------------------------------- 1 | module ppm 2 | implicit none 3 | 4 | private :: color 5 | public :: outputppm 6 | 7 | contains 8 | 9 | pure function color(val, lo, hi) result(rgb) 10 | implicit none 11 | character, dimension(3) :: rgb 12 | real, intent(IN) :: val, lo, hi 13 | integer :: tmp 14 | 15 | real :: scaleval 16 | 17 | scaleval = (val-lo)/(hi-lo) * 255. 18 | tmp = int(scaleval*3) 19 | if (tmp > 255) tmp = 255 20 | rgb(1) = achar(tmp) 21 | rgb(2) = achar(int(scaleval)) 22 | rgb(3) = achar(0) 23 | end function color 24 | 25 | subroutine outputppm(var,filename,varnum) 26 | implicit none 27 | character(len=*), intent(IN), optional :: filename 28 | integer, intent(IN), optional :: varnum 29 | real, dimension(:,:,:), intent(IN) :: var 30 | character, dimension(:,:,:), allocatable :: rgb 31 | real :: lo, hi 32 | integer :: i,j,c 33 | integer :: nx, ny, nvars 34 | character(len=30) :: chosenfilename 35 | integer :: chosenvarnum 36 | 37 | if (present(varnum)) then 38 | chosenvarnum = varnum 39 | else 40 | chosenvarnum = 1 41 | endif 42 | if (present(filename)) then 43 | chosenfilename = filename 44 | else 45 | chosenfilename = 'output.ppm' 46 | endif 47 | 48 | nvars = size(var,1) 49 | nx = size(var,2) 50 | ny = size(var,3) 51 | 52 | if (chosenvarnum > nvars) then 53 | print *, 'Invalid variable number ', chosenvarnum 54 | else 55 | allocate(rgb(3,nx,ny)) 56 | 57 | lo = minval(var(chosenvarnum,:,:)) 58 | hi = maxval(var(chosenvarnum,:,:)) 59 | 60 | forall (i=1:nx,j=1:ny) 61 | rgb(1:3,i,j) = color(var(chosenvarnum,i,j), lo, hi) 62 | end forall 63 | 64 | open(unit=44,file=chosenfilename) 65 | write(44,'(A)') 'P6' 66 | write(44,'(2(1x,i4))') nx, ny 67 | write(44,'(i3)'), 255 68 | write(44,'(9999999A1)',advance='no') (((rgb(c,i,j),c=1,3), i=1,nx),j=ny,1,-1) 69 | 70 | deallocate(rgb) 71 | close(44) 72 | endif 73 | end subroutine outputppm 74 | 75 | end module ppm 76 | -------------------------------------------------------------------------------- /hydrof/solver.f90: -------------------------------------------------------------------------------- 1 | module solver 2 | implicit none 3 | 4 | integer, parameter :: idens=1, iener=4, imomx=2, imomy=3, nvars=4 5 | integer, parameter :: nguard = 2 6 | real, parameter :: gamma=5./3. 7 | 8 | public :: initialconditions, timestep, nguard, gamma 9 | private:: cfl, xytranspose, xsweep, tvd1d, hydroflux 10 | 11 | contains 12 | 13 | pure subroutine periodicBCs(u,xydim) 14 | implicit none 15 | real, dimension(:,:,:), intent(INOUT) :: u 16 | character, intent(IN) :: xydim 17 | integer :: n 18 | 19 | if (xydim == 'y') then 20 | n = size(u,3) 21 | u(:,:,1:2) = u(:,:,n-3:n-2) 22 | u(:,:,n-1:n) = u(:,:,3:4) 23 | else if (xydim == 'x') then 24 | n = size(u,2) 25 | u(:,1:2,:) = u(:,n-3:n-2,:) 26 | u(:,n-1:n,:) = u(:,3:4,:) 27 | endif 28 | end subroutine periodicBCs 29 | 30 | pure subroutine timestep(u,dt) 31 | implicit none 32 | real, dimension(:,:,:), intent(INOUT) :: u 33 | real, intent(OUT) :: dt 34 | 35 | real, dimension(nvars,size(u,3),size(u,2)) :: ut 36 | 37 | dt=0.25*cfl(u) 38 | ! the x sweep 39 | call periodicBCs(u,'x') 40 | call xsweep(u,dt) 41 | ! the y sweeps 42 | call xytranspose(ut,u) 43 | call periodicBCs(ut,'x') 44 | call xsweep(ut,dt) 45 | call periodicBCs(ut,'x') 46 | call xsweep(ut,dt) 47 | ! 2nd x sweep 48 | call xytranspose(u,ut) 49 | call periodicBCs(u,'x') 50 | call xsweep(u,dt) 51 | end subroutine timestep 52 | 53 | pure real function cfl(u) 54 | implicit none 55 | real, intent(IN) :: u(:,:,:) 56 | real, dimension(size(u,2),size(u,3)) :: v, p 57 | real :: c 58 | 59 | v = abs(u(imomx,:,:)/u(idens,:,:)) 60 | where (v < abs(u(imomy,:,:))/u(idens,:,:)) 61 | v = abs(u(imomy,:,:)/u(idens,:,:)) 62 | endwhere 63 | 64 | ! or even 65 | ! v = maxval(abs(u(imomx:imomy,:,:))/spread(u(idens,:,:),1,2),dim=1) 66 | 67 | p = (u(iener,:,:)-0.5*(u(imomx,:,:)**2+u(imomy,:,:)**2)/u(idens,:,:))*(gamma-1.) 68 | c = maxval(v+sqrt(abs((gamma*p))/u(idens,:,:))) 69 | 70 | cfl=1./c 71 | end function cfl 72 | 73 | pure subroutine initialconditions(u) 74 | implicit none 75 | real, intent(OUT) :: u(:,:,:) 76 | 77 | integer :: nx,ny 78 | integer :: i,j 79 | real, parameter :: backgrounddens=1., projdens=50., projvel=4., p0=1. 80 | real :: r(size(u,2), size(u,3)) 81 | 82 | nx = size(u,2) 83 | ny = size(u,3) 84 | 85 | forall (i=1:nx,j=1:ny) 86 | r(i,j) =sqrt((j*1-ny/2.)**2. + (i*1.-nx/2.)**2) 87 | endforall 88 | 89 | where (r < 0.1*sqrt(nx*nx*1.+ny*ny)) 90 | u(idens,:,:) =projdens 91 | u(imomx,:,:) =projdens*projvel 92 | u(imomy,:,:) =0 93 | u(iener,:,:) =0.5*(projdens*projvel*projvel)+p0/(gamma-1.) 94 | elsewhere 95 | u(idens,:,:) =backgrounddens 96 | u(imomx,:,:) =0. 97 | u(imomy,:,:) =0. 98 | u(iener,:,:) =p0/(gamma-1.) 99 | endwhere 100 | 101 | end subroutine initialconditions 102 | 103 | pure subroutine xsweep(u,dt) 104 | implicit none 105 | real, intent(INOUT), dimension(:,:,:) :: u 106 | real, intent(IN) :: dt 107 | integer :: j 108 | 109 | do j=1,size(u,3) 110 | call tvd1d(u(:,:,j),dt) 111 | enddo 112 | end subroutine xsweep 113 | 114 | pure subroutine tvd1d(u,dt) 115 | implicit none 116 | real, intent(IN) :: dt 117 | real, dimension(:,:), intent(INOUT) :: u 118 | 119 | real, dimension(size(u,1),size(u,2)) :: v, u1, wr, wl 120 | real, dimension(size(u,1),size(u,2)) :: dfrp, dfrm, dflm, dflp 121 | real, dimension(size(u,1),size(u,2)) :: dfl, dfr 122 | real, dimension(size(u,1),size(u,2)) :: flux 123 | real, dimension(size(u,1),size(u,2)) :: du 124 | real, parameter :: smallp = 1.e-3 125 | real :: c 126 | integer :: i, n 127 | 128 | n = size(u,2) 129 | 130 | call hydroflux(v,c,u) 131 | wr = u+v 132 | wl = u-v 133 | flux=c*(wr - eoshift(wl,1,dim=2))/2. 134 | u1 = u - (flux - eoshift(flux,-1,dim=2))*dt/2. 135 | 136 | call hydroflux(v,c,u1) 137 | wr = u1+v 138 | wl = u1-v 139 | 140 | dfrp = c*(eoshift(wr,1,dim=2)-wr)/2. 141 | dfrm = c*(wr-eoshift(wr,-1,dim=2))/2. 142 | where (dfrp*dfrm > 0) 143 | dfr = 2*dfrp*dfrm/(dfrp+dfrm) 144 | elsewhere 145 | dfr = 0 146 | endwhere 147 | 148 | dflp = c*(eoshift(wl,1,dim=2)-eoshift(wl,2,dim=2))/2. 149 | dflm = c*(wl-eoshift(wl,1,dim=2))/2. 150 | where (dflp*dflm > 0) 151 | dfl = 2*dflp*dflm/(dflp+dflm) 152 | elsewhere 153 | dfl = 0 154 | endwhere 155 | 156 | flux = (c*(wr-eoshift(wl,1,dim=2)) + (dfr-dfl))/2. 157 | du = (flux-eoshift(flux,-1,dim=2))*dt 158 | u(:,3:n-2) = u(:,3:n-2) - du(:,3:n-2) 159 | 160 | do i=1,n 161 | if ( ((u(iener,i)-0.5*(u(imomx,i)**2+u(imomy,i)**2)/u(idens,i))*(gamma-1.)) < smallp ) & 162 | u(iener,i) = 0.5*(u(imomx,i)**2+u(imomy,i)**2)/u(idens,i) + smallp/(gamma-1.) 163 | enddo 164 | 165 | end subroutine tvd1d 166 | 167 | pure subroutine hydroflux(v,c,u) 168 | implicit none 169 | real, intent(OUT) :: c 170 | real, dimension(:,:), intent(IN) :: u 171 | real, dimension(:,:), intent(OUT) :: v 172 | real, dimension(size(u,2)) :: vx, p 173 | 174 | c = 0. 175 | vx = u(imomx,:)/u(idens,:) 176 | p = (u(iener,:)-(u(imomx,:)**2+u(imomy,:)**2)/u(idens,:)/2)*(gamma-1) 177 | 178 | v(idens,:)=u(imomx,:) 179 | v(imomx,:)=u(imomx,:)*vx + p 180 | v(imomy,:)=u(imomy,:)*vx 181 | v(iener,:)=(u(iener,:)+p)*vx 182 | 183 | c=maxval(abs(vx)+sqrt(abs(gamma*p/u(idens,:)))) 184 | if (c > 0) v = v/c 185 | end subroutine hydroflux 186 | 187 | pure subroutine xytranspose(ut,u) 188 | implicit none 189 | real, dimension(:,:,:), intent(IN) :: u 190 | real, dimension(:,:,:), intent(OUT) :: ut 191 | 192 | ut(idens,:,:)=transpose(u(idens,:,:)) 193 | ut(imomx,:,:)=transpose(u(imomy,:,:)) 194 | ut(imomy,:,:)=transpose(u(imomx,:,:)) 195 | ut(iener,:,:)=transpose(u(iener,:,:)) 196 | end subroutine xytranspose 197 | 198 | end module solver 199 | -------------------------------------------------------------------------------- /mpi-intro/.diffusion.f.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/mpi-intro/.diffusion.f.swp -------------------------------------------------------------------------------- /mpi-intro/Makefile: -------------------------------------------------------------------------------- 1 | all: minmeanmax minmeanmax-allreduce minmeanmax-mpi 2 | include ../Makefile.inc 3 | 4 | minmeanmax: minmeanmax.f90 5 | ${F77} ${FFLAGS} -o $@ $< 6 | 7 | minmeanmax-mpi: minmeanmax-mpi.f90 8 | ${MPIF77} ${FFLAGS} -g -o $@ $< 9 | 10 | minmeanmax-allreduce: minmeanmax-allreduce.f90 11 | ${MPIF77} ${FFLAGS} -o $@ $< 12 | 13 | 14 | clean: 15 | rm -rf minmeanmax 16 | rm -rf minmeanmax-mpi 17 | rm -rf minmeanmax-allreduce 18 | rm -rf *.o 19 | rm -rf *~ 20 | -------------------------------------------------------------------------------- /mpi-intro/fifthmessage.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char **argv) { 5 | int rank, size, ierr; 6 | int left, right; 7 | int tag=1; 8 | double msgsent, msgrcvd; 9 | MPI_Status rstatus; 10 | 11 | ierr = MPI_Init(&argc, &argv); 12 | ierr = MPI_Comm_size(MPI_COMM_WORLD, &size); 13 | ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); 14 | 15 | left = rank-1; 16 | if (left < 0) left = size-1; 17 | right = rank+1; 18 | if (right >= size) right = 0; 19 | 20 | msgsent = rank*rank; 21 | msgrcvd = -999.; 22 | 23 | ierr = MPI_Sendrecv(&msgsent, 1, MPI_DOUBLE, right, tag, 24 | &msgrcvd, 1, MPI_DOUBLE, left, tag, 25 | MPI_COMM_WORLD, &rstatus); 26 | 27 | printf("%d: Sent %lf and got %lf\n", 28 | rank, msgsent, msgrcvd); 29 | 30 | ierr = MPI_Finalize(); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /mpi-intro/minmeanmax-allreduce.f90: -------------------------------------------------------------------------------- 1 | program randomdata 2 | use mpi 3 | implicit none 4 | 5 | integer,parameter :: nx=1500 6 | real, allocatable :: dat(:) 7 | 8 | integer :: i,n 9 | real :: datamin, datamax, datamean 10 | real :: globmin, globmax, globmean 11 | integer :: rank, comsize, ierr 12 | 13 | call MPI_INIT(ierr) 14 | call MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) 15 | call MPI_COMM_SIZE(MPI_COMM_WORLD,comsize,ierr) 16 | 17 | ! 18 | ! random data 19 | ! 20 | allocate(dat(nx)) 21 | call random_seed(size=n) 22 | call random_seed(put=[(rank,i=1,n)]) 23 | call random_number(dat) 24 | dat = 2*dat - 1. 25 | 26 | ! 27 | ! find local min/mean/max 28 | ! 29 | datamin = minval(dat) 30 | datamax = maxval(dat) 31 | datamean= (1.*sum(dat))/nx 32 | deallocate(dat) 33 | 34 | print *,rank,': min/mean/max = ', datamin, datamean, datamax 35 | ! 36 | ! combine data 37 | ! 38 | call MPI_ALLREDUCE(datamin, globmin, 1, MPI_REAL, MPI_MIN, & 39 | MPI_COMM_WORLD, ierr) 40 | ! 41 | ! to just send to task 0: 42 | ! call MPI_REDUCE(datamin, globmin, 1, MPI_REAL, MPI_MIN, 43 | ! & 0, MPI_COMM_WORLD, ierr) 44 | ! 45 | call MPI_ALLREDUCE(datamax, globmax, 1, MPI_REAL, MPI_MAX, & 46 | MPI_COMM_WORLD, ierr) 47 | call MPI_ALLREDUCE(datamean, globmean, 1, MPI_REAL, MPI_SUM, & 48 | MPI_COMM_WORLD, ierr) 49 | globmean = globmean/comsize 50 | if (rank == 0) then 51 | print *, rank,': Global min/mean/max=',globmin,globmean,globmax 52 | endif 53 | 54 | call MPI_FINALIZE(ierr) 55 | end program randomdata 56 | -------------------------------------------------------------------------------- /mpi-intro/minmeanmax-mpi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv) { 6 | const int nx=1500; 7 | float *dat; 8 | int i; 9 | float datamin, datamax, datamean; 10 | float minmeanmax[3]; 11 | float globminmeanmax[3]; 12 | int ierr; 13 | int rank, size; 14 | int tag=1; 15 | int masterproc=0; 16 | MPI_Status status; 17 | 18 | 19 | ierr = MPI_Init(&argc, &argv); 20 | ierr = MPI_Comm_size(MPI_COMM_WORLD,&size); 21 | ierr = MPI_Comm_rank(MPI_COMM_WORLD,&rank); 22 | 23 | /* 24 | * generate random data 25 | */ 26 | 27 | dat = (float *)malloc(nx * sizeof(float)); 28 | srand(0); 29 | for (i=0;i datamax) datamax=dat[i]; 44 | datamean += dat[i]; 45 | } 46 | datamean /= nx; 47 | free(dat); 48 | 49 | minmeanmax[0] = datamin; 50 | minmeanmax[2] = datamax; 51 | minmeanmax[1] = datamean; 52 | 53 | if (rank != masterproc) { 54 | ierr = MPI_Ssend( /* ... ? ... */ ); 55 | } else { 56 | globminmeanmax[0] = datamin; 57 | globminmeanmax[2] = datamax; 58 | globminmeanmax[1] = datamean; 59 | for (i=1;i globminmeanmax[2]) 68 | globminmeanmax[2] = minmeanmax[2]; 69 | 70 | } 71 | globminmeanmax[1] /= size; 72 | printf("Min/mean/max = %f,%f,%f\n", globminmeanmax[0], 73 | globminmeanmax[1],globminmeanmax[2]); 74 | } 75 | 76 | ierr = MPI_Finalize(); 77 | 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /mpi-intro/minmeanmax-mpi.f90: -------------------------------------------------------------------------------- 1 | program randomdata 2 | use mpi 3 | implicit none 4 | integer,parameter :: nx=1500 5 | real, allocatable :: dat(:) 6 | 7 | integer :: i,n 8 | real :: datamin, datamax, datamean 9 | real :: globmin, globmax, globmean 10 | integer :: ierr, rank, comsize 11 | integer :: ourtag=5 12 | real, dimension(3) :: sendbuffer, recvbuffer 13 | integer, dimension(MPI_STATUS_SIZE) :: status 14 | 15 | call MPI_INIT(ierr) 16 | call MPI_COMM_SIZE(MPI_COMM_WORLD, comsize, ierr) 17 | call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) 18 | ! 19 | ! random data 20 | ! 21 | allocate(dat(nx)) 22 | call random_seed(size=n) 23 | call random_seed(put=[(rank,i=1,n)]) 24 | call random_number(dat) 25 | dat = 2*dat - 1. 26 | 27 | ! 28 | ! find min/mean/max 29 | ! 30 | datamin = minval(dat) 31 | datamax = maxval(dat) 32 | datamean= (1.*sum(dat))/nx 33 | deallocate(dat) 34 | 35 | if (rank /= 0) then 36 | sendbuffer(1) = datamin 37 | sendbuffer(2) = datamean 38 | sendbuffer(3) = datamax 39 | call MPI_SSEND() ! stuff goes here 40 | else 41 | globmin = datamin 42 | globmax = datamax 43 | globmean = datamean 44 | do i=2,comsize 45 | call MPI_RECV() ! stuff goes here 46 | if (recvbuffer(1) < globmin) globmin=recvbuffer(1) 47 | if (recvbuffer(3) > globmax) globmax=recvbuffer(3) 48 | globmean = globmean + recvbuffer(2) 49 | enddo 50 | globmean = globmean / comsize 51 | endif 52 | 53 | print *,rank, ': min/mean/max = ', datamin, datamean, datamax 54 | 55 | if (rank==0) then 56 | print *, 'global min/mean/max = ', globmin, globmean, globmax 57 | endif 58 | 59 | call MPI_FINALIZE(ierr) 60 | end 61 | -------------------------------------------------------------------------------- /mpi-intro/minmeanmax.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char **argv) { 5 | const int nx=1500; 6 | float *dat; 7 | int i; 8 | float datamin, datamax, datamean; 9 | 10 | /* 11 | * generate random data 12 | */ 13 | 14 | dat = (float *)malloc(nx * sizeof(float)); 15 | srand(0); 16 | for (i=0;i datamax) datamax=dat[i]; 32 | datamean += dat[i]; 33 | } 34 | datamean /= nx; 35 | free(dat); 36 | 37 | printf("Min/mean/max = %f,%f,%f\n", datamin,datamean,datamax); 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /mpi-intro/minmeanmax.f90: -------------------------------------------------------------------------------- 1 | program randomdata 2 | implicit none 3 | integer,parameter :: nx=1500 4 | real, allocatable :: dat(:) 5 | 6 | integer :: i,n 7 | real :: datamin, datamax, datamean 8 | 9 | ! 10 | ! random data 11 | ! 12 | allocate(dat(nx)) 13 | call random_seed(size=n) 14 | call random_seed(put=[(i,i=1,n)]) 15 | call random_number(dat) 16 | dat = 2*dat - 1. 17 | 18 | ! 19 | ! find min/mean/max 20 | ! 21 | datamin = minval(dat) 22 | datamax = maxval(dat) 23 | datamean= (1.*sum(dat))/nx 24 | 25 | deallocate(dat) 26 | 27 | print *,'min/mean/max = ', datamin, datamean, datamax 28 | 29 | return 30 | end 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /mpi-intro/secondmessage.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char **argv) { 5 | int rank, size, ierr; 6 | int left, right; 7 | int tag=1; 8 | double msgsent, msgrcvd; 9 | MPI_Status rstatus; 10 | 11 | ierr = MPI_Init(&argc, &argv); 12 | ierr = MPI_Comm_size(MPI_COMM_WORLD, &size); 13 | ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); 14 | 15 | left = rank-1; 16 | if (left < 0) left = MPI_PROC_NULL; 17 | right = rank+1; 18 | if (right >= size) right = MPI_PROC_NULL; 19 | 20 | msgsent = rank*rank; 21 | msgrcvd = -999.; 22 | 23 | ierr = MPI_Ssend(&msgsent, 1, MPI_DOUBLE, right, 24 | tag, MPI_COMM_WORLD); 25 | ierr = MPI_Recv(&msgrcvd, 1, MPI_DOUBLE, left, 26 | tag, MPI_COMM_WORLD, &rstatus); 27 | 28 | printf("%d: Sent %lf and got %lf\n", 29 | rank, msgsent, msgrcvd); 30 | 31 | ierr = MPI_Finalize(); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /mpi-intro/secondmessage.f90: -------------------------------------------------------------------------------- 1 | program secondmessage 2 | implicit none 3 | include 'mpif.h' 4 | 5 | integer :: ierr, rank, comsize 6 | integer :: left, right 7 | integer :: tag 8 | integer :: status(MPI_STATUS_SIZE) 9 | double precision :: msgsent, msgrcvd 10 | 11 | call MPI_INIT(ierr) 12 | call MPI_COMM_RANK(MPI_COMM_WORLD,rank,ierr) 13 | call MPI_COMM_SIZE(MPI_COMM_WORLD,comsize,ierr) 14 | 15 | left = rank-1 16 | if (left < 0) left = MPI_PROC_NULL 17 | right = rank+1 18 | if (right >= comsize) right = MPI_PROC_NULL 19 | 20 | msgsent = rank*rank 21 | msgrcvd = -999. 22 | tag = 1 23 | 24 | call MPI_Ssend(msgsent, 1, MPI_DOUBLE_PRECISION, right, & 25 | tag, MPI_COMM_WORLD, ierr) 26 | call MPI_Recv(msgrcvd, 1, MPI_DOUBLE_PRECISION, left, & 27 | tag, MPI_COMM_WORLD, status, ierr) 28 | 29 | print *, rank, 'Sent ', msgsent, 'and recvd ', msgrcvd 30 | 31 | call MPI_FINALIZE(ierr) 32 | 33 | end program secondmessage 34 | -------------------------------------------------------------------------------- /nbodyc/Makefile: -------------------------------------------------------------------------------- 1 | CPROGS = nbody nbody_omp 2 | 3 | all: $(CPROGS) 4 | 5 | include ../Makefile.inc 6 | 7 | OPENMP=-fopenmp 8 | UTILS=allocmultid.o 9 | 10 | %.o:%.c 11 | $(CC) -g $(CFLAGS) $(OPENMP) -c $< -o $@ 12 | 13 | nbody: nbody.o allocmultid.c 14 | 15 | nbody-allgather.o: nbody-allgather.c 16 | $(MPICC) $(CFLAGS) -c $< 17 | 18 | nbody-pipeline.o: nbody-pipeline.c 19 | $(MPICC) $(CFLAGS) -c $< 20 | 21 | nbody-nonblocking-pipeline.o: nbody-nonblocking-pipeline.c 22 | $(MPICC) $(CFLAGS) -c $< 23 | 24 | nbody-gridparticles.o: nbody-gridparticles.c 25 | $(MPICC) $(CFLAGS) -c $< 26 | 27 | nbody: nbody.o $(UTILS) 28 | $(F77) $(CFLAGS) nbody.o -g $(UTILS) -o $@ $(CLIBS) $(PGPLIBS) -lm 29 | 30 | nbody_omp: nbody_omp.o $(UTILS) 31 | $(F77) $(CFLAGS) nbody_omp.o -g -fopenmp $(UTILS) -o $@ $(CLIBS) $(PGPLIBS) -lm 32 | 33 | nbody-allgather: nbody-allgather.o $(UTILS) $(MPIUTILS) 34 | $(MPIF77) $(CFLAGS) nbody-allgather.o $(UTILS) -o $@ $(CLIBS) $(PGPLIBS) -lm 35 | 36 | nbody-pipeline: nbody-pipeline.o $(UTILS) $(MPIUTILS) 37 | $(MPIF77) $(CFLAGS) nbody-pipeline.o $(UTILS) -o $@ $(CLIBS) $(PGPLIBS) -lm 38 | 39 | nbody-nonblocking-pipeline: nbody-nonblocking-pipeline.o $(UTILS) $(MPIUTILS) 40 | $(MPIF77) $(CFLAGS) nbody-nonblocking-pipeline.o $(UTILS) -o $@ $(CLIBS) $(PGPLIBS) -lm 41 | 42 | nbody-gridparticles: nbody-gridparticles.o $(UTILS) $(MPIUTILS) 43 | $(MPIF77) $(CFLAGS) nbody-gridparticles.o $(UTILS) -o $@ $(CLIBS) $(PGPLIBS) -lm 44 | 45 | clean: 46 | rm -f *.o 47 | rm -f $(CPROGS) 48 | rm -f myparticles.txt 49 | -------------------------------------------------------------------------------- /nbodyc/allocmultid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float ***alloc3d_float(int n, int m, int l) { 4 | float *data = malloc(n*m*l*sizeof(float)); 5 | if (!data) return NULL; 6 | 7 | float ***array = (float ***)malloc(n*sizeof(float **)); 8 | for (int i=0; i 0) .and. (ii <= npix) .and. (jj > 0) .and. (jj <= npix) ) then 203 | plot(ii,jj) = plot(ii,jj) - 1. 204 | endif 205 | enddo 206 | 207 | call pgimag(plot,npix,npix,1,npix,1,npix,-5.0,.0,tr) 208 | return 209 | end subroutine display_particles 210 | 211 | end program 212 | 213 | -------------------------------------------------------------------------------- /presentation/images/Another_collective_operation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Another_collective_operation.png -------------------------------------------------------------------------------- /presentation/images/BUFFERING.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/BUFFERING.png -------------------------------------------------------------------------------- /presentation/images/Communicators_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Communicators_1.png -------------------------------------------------------------------------------- /presentation/images/Communicators_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Communicators_2.png -------------------------------------------------------------------------------- /presentation/images/Create_new_communicator_with_new_topology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Create_new_communicator_with_new_topology.png -------------------------------------------------------------------------------- /presentation/images/Cute_way_for_Periodic_BCs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Cute_way_for_Periodic_BCs.png -------------------------------------------------------------------------------- /presentation/images/Data_dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Data_dependencies.png -------------------------------------------------------------------------------- /presentation/images/Data_structure-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Data_structure-1.png -------------------------------------------------------------------------------- /presentation/images/Data_structure-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Data_structure-2.png -------------------------------------------------------------------------------- /presentation/images/Discretizing_Derivatives (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Discretizing_Derivatives (2).png -------------------------------------------------------------------------------- /presentation/images/Discretizing_Derivatives.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Discretizing_Derivatives.png -------------------------------------------------------------------------------- /presentation/images/Displaying_Data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Displaying_Data.png -------------------------------------------------------------------------------- /presentation/images/Equations_of_Hydrodynamics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Equations_of_Hydrodynamics.png -------------------------------------------------------------------------------- /presentation/images/Finite_Volume_Method.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Finite_Volume_Method.png -------------------------------------------------------------------------------- /presentation/images/Guard_cell_fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Guard_cell_fill.png -------------------------------------------------------------------------------- /presentation/images/Guardcells (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Guardcells (2).png -------------------------------------------------------------------------------- /presentation/images/Guardcells-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Guardcells-2.png -------------------------------------------------------------------------------- /presentation/images/How_would_we_get_this_data_Allgather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/How_would_we_get_this_data_Allgather.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-10.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-11.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-12.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-13.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-14.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-15.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-16.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-17.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-18.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-19.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-2.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-20.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-21.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-22.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-23.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-24.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-25.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-26.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-28.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-29.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-3.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-30.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-31.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-32.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-33.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-34.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-35.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-36.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-37.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-38.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-39.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-4.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-40.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-41.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-42.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-5.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-6.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-7.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-8.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI-9.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI.png -------------------------------------------------------------------------------- /presentation/images/Implementing_in_MPI_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementing_in_MPI_1.png -------------------------------------------------------------------------------- /presentation/images/Implementperiodicboundary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Implementperiodicboundary.png -------------------------------------------------------------------------------- /presentation/images/Laid_out_in_memory_(C).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Laid_out_in_memory_(C).png -------------------------------------------------------------------------------- /presentation/images/Laid_out_in_memory_(FORTRAN).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Laid_out_in_memory_(FORTRAN).png -------------------------------------------------------------------------------- /presentation/images/MPIing_the_Code-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/MPIing_the_Code-2.png -------------------------------------------------------------------------------- /presentation/images/MPIing_the_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/MPIing_the_Code.png -------------------------------------------------------------------------------- /presentation/images/Next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Next.png -------------------------------------------------------------------------------- /presentation/images/Other_stuff_about_the_nbody_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Other_stuff_about_the_nbody_code.png -------------------------------------------------------------------------------- /presentation/images/OverlappingComputation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/OverlappingComputation.png -------------------------------------------------------------------------------- /presentation/images/Overlapping_Communication_Computation-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Overlapping_Communication_Computation-2.png -------------------------------------------------------------------------------- /presentation/images/Overlapping_Communication_Computation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Overlapping_Communication_Computation.png -------------------------------------------------------------------------------- /presentation/images/Pipeline-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Pipeline-2.png -------------------------------------------------------------------------------- /presentation/images/Pipeline-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Pipeline-3.png -------------------------------------------------------------------------------- /presentation/images/Pipeline-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Pipeline-4.png -------------------------------------------------------------------------------- /presentation/images/Pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Pipeline.png -------------------------------------------------------------------------------- /presentation/images/Pipeline_Formula-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Pipeline_Formula-1.png -------------------------------------------------------------------------------- /presentation/images/Pipeline_Formula-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Pipeline_Formula-2.png -------------------------------------------------------------------------------- /presentation/images/Plotting_to_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Plotting_to_file.png -------------------------------------------------------------------------------- /presentation/images/Plotting_to_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Plotting_to_screen.png -------------------------------------------------------------------------------- /presentation/images/Problem_I_remains_memory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Problem_I_remains_memory.png -------------------------------------------------------------------------------- /presentation/images/Single-Processor_hydro_code-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Single-Processor_hydro_code-2.png -------------------------------------------------------------------------------- /presentation/images/Single-Processor_hydro_code-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Single-Processor_hydro_code-3.png -------------------------------------------------------------------------------- /presentation/images/Single-Processor_hydro_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/Single-Processor_hydro_code.png -------------------------------------------------------------------------------- /presentation/images/What_if_not_same_#_of_particles-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/What_if_not_same_#_of_particles-2.png -------------------------------------------------------------------------------- /presentation/images/What_if_not_same_#_of_particles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/What_if_not_same_#_of_particles.png -------------------------------------------------------------------------------- /presentation/images/bettersumming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/bettersumming.png -------------------------------------------------------------------------------- /presentation/images/bettersumming_eq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/bettersumming_eq.png -------------------------------------------------------------------------------- /presentation/images/collectiveoperation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/collectiveoperation.png -------------------------------------------------------------------------------- /presentation/images/deadlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/deadlock.png -------------------------------------------------------------------------------- /presentation/images/deadlock_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/deadlock_1.png -------------------------------------------------------------------------------- /presentation/images/diffusion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/diffusion.png -------------------------------------------------------------------------------- /presentation/images/diffusion_eq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/diffusion_eq.png -------------------------------------------------------------------------------- /presentation/images/diffusionequationmpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/diffusionequationmpi.png -------------------------------------------------------------------------------- /presentation/images/domain_decomposition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/domain_decomposition.png -------------------------------------------------------------------------------- /presentation/images/guardcells.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/guardcells.png -------------------------------------------------------------------------------- /presentation/images/guardcells_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/guardcells_1.png -------------------------------------------------------------------------------- /presentation/images/hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/hello.png -------------------------------------------------------------------------------- /presentation/images/helloworld_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/helloworld_c.png -------------------------------------------------------------------------------- /presentation/images/helloworld_fortran.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/helloworld_fortran.png -------------------------------------------------------------------------------- /presentation/images/id_diffusion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/id_diffusion.png -------------------------------------------------------------------------------- /presentation/images/inefficient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/inefficient.png -------------------------------------------------------------------------------- /presentation/images/message_passing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/message_passing.png -------------------------------------------------------------------------------- /presentation/images/messages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/messages.png -------------------------------------------------------------------------------- /presentation/images/min,mean,max.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/min,mean,max.png -------------------------------------------------------------------------------- /presentation/images/mpicc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/mpicc.png -------------------------------------------------------------------------------- /presentation/images/mpif77.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/mpif77.png -------------------------------------------------------------------------------- /presentation/images/mpirun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/mpirun.png -------------------------------------------------------------------------------- /presentation/images/nonblockindrecv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/nonblockindrecv.png -------------------------------------------------------------------------------- /presentation/images/nonblocking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/nonblocking.png -------------------------------------------------------------------------------- /presentation/images/nonblockingsends.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/nonblockingsends.png -------------------------------------------------------------------------------- /presentation/images/processvie_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/processvie_1.png -------------------------------------------------------------------------------- /presentation/images/processview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/processview.png -------------------------------------------------------------------------------- /presentation/images/processview_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/processview_2.png -------------------------------------------------------------------------------- /presentation/images/sendreciev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/sendreciev.png -------------------------------------------------------------------------------- /presentation/images/sendreciev_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/sendreciev_1.png -------------------------------------------------------------------------------- /presentation/images/sendrecv_args.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/sendrecv_args.png -------------------------------------------------------------------------------- /presentation/images/sendrecv_args2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images/sendrecv_args2.png -------------------------------------------------------------------------------- /presentation/images2/Another_collective_operation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Another_collective_operation.png -------------------------------------------------------------------------------- /presentation/images2/BUFFERING.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/BUFFERING.png -------------------------------------------------------------------------------- /presentation/images2/Communicators_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Communicators_1.png -------------------------------------------------------------------------------- /presentation/images2/Communicators_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Communicators_2.png -------------------------------------------------------------------------------- /presentation/images2/Create_new_communicator_with_new_topology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Create_new_communicator_with_new_topology.png -------------------------------------------------------------------------------- /presentation/images2/Cute_way_for_Periodic_BCs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Cute_way_for_Periodic_BCs.png -------------------------------------------------------------------------------- /presentation/images2/Data_dependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Data_dependencies.png -------------------------------------------------------------------------------- /presentation/images2/Data_structure-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Data_structure-1.png -------------------------------------------------------------------------------- /presentation/images2/Data_structure-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Data_structure-2.png -------------------------------------------------------------------------------- /presentation/images2/Discretizing_Derivatives: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Discretizing_Derivatives -------------------------------------------------------------------------------- /presentation/images2/Discretizing_Derivatives.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Discretizing_Derivatives.png -------------------------------------------------------------------------------- /presentation/images2/Displaying_Data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Displaying_Data.png -------------------------------------------------------------------------------- /presentation/images2/Equations_of_Hydrodynamics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Equations_of_Hydrodynamics.png -------------------------------------------------------------------------------- /presentation/images2/Finite_Volume_Method.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Finite_Volume_Method.png -------------------------------------------------------------------------------- /presentation/images2/Guard_cell_fill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Guard_cell_fill.png -------------------------------------------------------------------------------- /presentation/images2/Guardcells: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Guardcells -------------------------------------------------------------------------------- /presentation/images2/Guardcells-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Guardcells-2.png -------------------------------------------------------------------------------- /presentation/images2/How_would_we_get_this_data_Allgather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/How_would_we_get_this_data_Allgather.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-10.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-11.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-12.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-13.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-14.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-15.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-16.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-17.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-18.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-19.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-2.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-20.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-21.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-22.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-23.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-24.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-25.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-26.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-28.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-29.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-3.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-30.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-31.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-32.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-33.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-34.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-35.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-36.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-37.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-38.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-39.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-4.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-40.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-41.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-42.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-5.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-6.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-7.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-8.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI-9.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI.png -------------------------------------------------------------------------------- /presentation/images2/Implementing_in_MPI_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementing_in_MPI_1.png -------------------------------------------------------------------------------- /presentation/images2/Implementperiodicboundary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Implementperiodicboundary.png -------------------------------------------------------------------------------- /presentation/images2/Laid_out_in_memory_(C).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Laid_out_in_memory_(C).png -------------------------------------------------------------------------------- /presentation/images2/Laid_out_in_memory_(FORTRAN).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Laid_out_in_memory_(FORTRAN).png -------------------------------------------------------------------------------- /presentation/images2/MPIing_the_Code-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/MPIing_the_Code-2.png -------------------------------------------------------------------------------- /presentation/images2/MPIing_the_Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/MPIing_the_Code.png -------------------------------------------------------------------------------- /presentation/images2/Next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Next.png -------------------------------------------------------------------------------- /presentation/images2/Other_stuff_about_the_nbody_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Other_stuff_about_the_nbody_code.png -------------------------------------------------------------------------------- /presentation/images2/OverlappingComputation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/OverlappingComputation.png -------------------------------------------------------------------------------- /presentation/images2/Overlapping_Communication_Computation-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Overlapping_Communication_Computation-2.png -------------------------------------------------------------------------------- /presentation/images2/Overlapping_Communication_Computation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Overlapping_Communication_Computation.png -------------------------------------------------------------------------------- /presentation/images2/Pipeline-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Pipeline-2.png -------------------------------------------------------------------------------- /presentation/images2/Pipeline-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Pipeline-3.png -------------------------------------------------------------------------------- /presentation/images2/Pipeline-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Pipeline-4.png -------------------------------------------------------------------------------- /presentation/images2/Pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Pipeline.png -------------------------------------------------------------------------------- /presentation/images2/Pipeline_Formula-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Pipeline_Formula-1.png -------------------------------------------------------------------------------- /presentation/images2/Pipeline_Formula-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Pipeline_Formula-2.png -------------------------------------------------------------------------------- /presentation/images2/Plotting_to_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Plotting_to_file.png -------------------------------------------------------------------------------- /presentation/images2/Plotting_to_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Plotting_to_screen.png -------------------------------------------------------------------------------- /presentation/images2/Problem_I_remains_memory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Problem_I_remains_memory.png -------------------------------------------------------------------------------- /presentation/images2/Single-Processor_hydro_code-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Single-Processor_hydro_code-2.png -------------------------------------------------------------------------------- /presentation/images2/Single-Processor_hydro_code-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Single-Processor_hydro_code-3.png -------------------------------------------------------------------------------- /presentation/images2/Single-Processor_hydro_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/Single-Processor_hydro_code.png -------------------------------------------------------------------------------- /presentation/images2/What_if_not_same_#_of_particles-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/What_if_not_same_#_of_particles-2.png -------------------------------------------------------------------------------- /presentation/images2/What_if_not_same_#_of_particles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/What_if_not_same_#_of_particles.png -------------------------------------------------------------------------------- /presentation/images2/bettersumming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/bettersumming.png -------------------------------------------------------------------------------- /presentation/images2/bettersumming_eq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/bettersumming_eq.png -------------------------------------------------------------------------------- /presentation/images2/collectiveoperation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/collectiveoperation.png -------------------------------------------------------------------------------- /presentation/images2/deadlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/deadlock.png -------------------------------------------------------------------------------- /presentation/images2/deadlock_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/deadlock_1.png -------------------------------------------------------------------------------- /presentation/images2/diffusion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/diffusion.png -------------------------------------------------------------------------------- /presentation/images2/diffusion_eq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/diffusion_eq.png -------------------------------------------------------------------------------- /presentation/images2/diffusionequationmpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/diffusionequationmpi.png -------------------------------------------------------------------------------- /presentation/images2/domain_decomposition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/domain_decomposition.png -------------------------------------------------------------------------------- /presentation/images2/guardcells.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/guardcells.png -------------------------------------------------------------------------------- /presentation/images2/guardcells_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/guardcells_1.png -------------------------------------------------------------------------------- /presentation/images2/hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/hello.png -------------------------------------------------------------------------------- /presentation/images2/helloworld_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/helloworld_c.png -------------------------------------------------------------------------------- /presentation/images2/helloworld_fortran.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/helloworld_fortran.png -------------------------------------------------------------------------------- /presentation/images2/id_diffusion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/id_diffusion.png -------------------------------------------------------------------------------- /presentation/images2/inefficient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/inefficient.png -------------------------------------------------------------------------------- /presentation/images2/message_passing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/message_passing.png -------------------------------------------------------------------------------- /presentation/images2/messages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/messages.png -------------------------------------------------------------------------------- /presentation/images2/min,mean,max.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/min,mean,max.png -------------------------------------------------------------------------------- /presentation/images2/mpicc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/mpicc.png -------------------------------------------------------------------------------- /presentation/images2/mpif77.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/mpif77.png -------------------------------------------------------------------------------- /presentation/images2/mpirun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/mpirun.png -------------------------------------------------------------------------------- /presentation/images2/nonblockindrecv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/nonblockindrecv.png -------------------------------------------------------------------------------- /presentation/images2/nonblocking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/nonblocking.png -------------------------------------------------------------------------------- /presentation/images2/nonblockingsends.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/nonblockingsends.png -------------------------------------------------------------------------------- /presentation/images2/processvie_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/processvie_1.png -------------------------------------------------------------------------------- /presentation/images2/processview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/processview.png -------------------------------------------------------------------------------- /presentation/images2/processview_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/processview_2.png -------------------------------------------------------------------------------- /presentation/images2/sendreciev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/sendreciev.png -------------------------------------------------------------------------------- /presentation/images2/sendreciev_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/sendreciev_1.png -------------------------------------------------------------------------------- /presentation/images2/sendrecv_args.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/sendrecv_args.png -------------------------------------------------------------------------------- /presentation/images2/sendrecv_args2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/images2/sendrecv_args2.png -------------------------------------------------------------------------------- /presentation/presentation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljdursi/mpi-tutorial/e1cd0bce5707d688604d622d8871af17073a4f4c/presentation/presentation.pdf -------------------------------------------------------------------------------- /setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | module purge 3 | module load gcc openmpi/1.4.4-gcc-v4.6.1 pgplot/5.2.2-gcc extras nano 4 | export OMPI_MCA_btl="self,sm,tcp" 5 | --------------------------------------------------------------------------------