├── .clang-format ├── .flake8 ├── .gitignore ├── .vscode ├── c_cpp_properties.json ├── settings.json └── tasks.json ├── README-for-ADIOS2.txt ├── README.txt ├── Tutorial ├── brusselator │ ├── .gitignore │ ├── README │ └── src │ │ ├── Makefile │ │ ├── Makefile.inc │ │ ├── README │ │ ├── adios2.xml │ │ ├── analysis │ │ ├── Makefile │ │ ├── bru_plot.py │ │ ├── bru_plot_scott.py │ │ ├── decomp.py │ │ ├── feature_detection.py │ │ ├── norm_calc.cpp │ │ └── norm_calc2.cpp │ │ └── simulation │ │ ├── 2decomp_fft │ │ ├── Makefile │ │ ├── README │ │ ├── doc │ │ │ └── DOC_2DECOMP_FFT.html │ │ ├── examples │ │ │ ├── Makefile │ │ │ ├── README.examples │ │ │ ├── fft_test_c2c │ │ │ │ ├── Makefile │ │ │ │ ├── README │ │ │ │ ├── c06fxfe.r │ │ │ │ └── fft_test_c2c.f90 │ │ │ ├── fft_test_r2c │ │ │ │ ├── Makefile │ │ │ │ ├── README │ │ │ │ └── fft_test_r2c.f90 │ │ │ ├── ga_test │ │ │ │ ├── Makefile │ │ │ │ ├── README │ │ │ │ └── ga_test.f90 │ │ │ ├── halo_test │ │ │ │ ├── Makefile │ │ │ │ ├── README │ │ │ │ └── halo_test.f90 │ │ │ ├── io_test │ │ │ │ ├── Makefile │ │ │ │ ├── README │ │ │ │ ├── io_bench.f90 │ │ │ │ ├── io_plane_test.f90 │ │ │ │ ├── io_read.f90 │ │ │ │ ├── io_test.f90 │ │ │ │ ├── io_var_test.f90 │ │ │ │ └── run_test.sh │ │ │ ├── non_blocking │ │ │ │ ├── Makefile │ │ │ │ ├── README │ │ │ │ ├── blocking.f90 │ │ │ │ └── non_blocking.f90 │ │ │ ├── p3dfft │ │ │ │ ├── Makefile │ │ │ │ ├── README │ │ │ │ └── p3dfft.f90 │ │ │ ├── tecplot_view │ │ │ │ ├── 2decomp_decomp.png │ │ │ │ ├── Makefile │ │ │ │ ├── README │ │ │ │ └── tecplot_view.f90 │ │ │ ├── test2d │ │ │ │ ├── Makefile │ │ │ │ ├── README │ │ │ │ └── test2d.f90 │ │ │ └── timing │ │ │ │ ├── Makefile │ │ │ │ ├── README │ │ │ │ └── timing.f90 │ │ └── src │ │ │ ├── Makefile │ │ │ ├── Makefile.inc.BlueGene │ │ │ ├── Makefile.inc.Cray_XE │ │ │ ├── Makefile.inc.Fujitsu_SPARC64_VIIIfx │ │ │ ├── Makefile.inc.x86 │ │ │ ├── acml_plan.f90 │ │ │ ├── alloc.f90 │ │ │ ├── alloc_shm.c │ │ │ ├── decomp_2d.f90 │ │ │ ├── factor.f90 │ │ │ ├── fft_acml.f90 │ │ │ ├── fft_common.f90 │ │ │ ├── fft_common_3d.f90 │ │ │ ├── fft_essl.f90 │ │ │ ├── fft_ffte.f90 │ │ │ ├── fft_fftpack5.f90 │ │ │ ├── fft_fftw3.f90 │ │ │ ├── fft_fftw3_f03.f90 │ │ │ ├── fft_generic.f90 │ │ │ ├── fft_mkl.f90 │ │ │ ├── glassman.f90 │ │ │ ├── halo.f90 │ │ │ ├── halo_common.f90 │ │ │ ├── io.f90 │ │ │ ├── io_read_one.f90 │ │ │ ├── io_read_var.f90 │ │ │ ├── io_write_every.f90 │ │ │ ├── io_write_one.f90 │ │ │ ├── io_write_plane.f90 │ │ │ ├── io_write_var.f90 │ │ │ ├── transpose_x_to_y.f90 │ │ │ ├── transpose_y_to_x.f90 │ │ │ ├── transpose_y_to_z.f90 │ │ │ └── transpose_z_to_y.f90 │ │ ├── Makefile │ │ ├── README │ │ ├── brusselator.f90 │ │ ├── getgrid.f90 │ │ ├── initialdata.f90 │ │ ├── linear.f90 │ │ ├── nonlinear1.f90 │ │ ├── nonlinear2.f90 │ │ └── savedata.f90 ├── gray-scott │ ├── .clang-format │ ├── .gitignore │ ├── CMakeLists.txt │ ├── README.md │ ├── adios2.xml │ ├── analysis │ │ ├── curvature.cpp │ │ ├── find_blobs.cpp │ │ ├── isosurface.cpp │ │ └── pdf_calc.cpp │ ├── cleanup.sh │ ├── common │ │ └── timer.hpp │ ├── img │ │ ├── example1.jpg │ │ ├── example2.jpg │ │ ├── example3.jpg │ │ ├── example4.jpg │ │ └── example5.jpg │ ├── plot │ │ ├── decomp.py │ │ ├── gsplot.py │ │ ├── pdfplot.py │ │ └── render_isosurface.cpp │ ├── simulation │ │ ├── LICENSE │ │ ├── gray-scott.cpp │ │ ├── gray-scott.h │ │ ├── json.hpp │ │ ├── main.cpp │ │ ├── settings-files.json │ │ ├── settings-staging.json │ │ ├── settings.cpp │ │ ├── settings.h │ │ ├── writer.cpp │ │ └── writer.h │ ├── visit-bp4.session │ ├── visit-bp4.session.gui │ ├── visit-sst.session │ └── visit-sst.session.gui ├── gs-adios2 │ ├── .clang-format │ ├── .gitignore │ ├── .vscode │ │ ├── c_cpp_properties.json │ │ └── settings.json │ ├── CMakeLists.txt │ ├── README.md │ ├── adios2.xml │ ├── analysis │ │ └── pdf-calc.cpp │ ├── cleanup.sh │ ├── img │ │ ├── example1.jpg │ │ ├── example2.jpg │ │ ├── example3.jpg │ │ ├── example4.jpg │ │ └── example5.jpg │ ├── plot │ │ ├── decomp.py │ │ ├── gsplot.py │ │ ├── gsplot_rra.py │ │ ├── gsread_mpi.py │ │ └── pdfplot.py │ └── simulation │ │ ├── LICENSE │ │ ├── gray-scott.cpp │ │ ├── gray-scott.h │ │ ├── json.hpp │ │ ├── main.cpp │ │ ├── settings-files.json │ │ ├── settings-staging.json │ │ ├── settings.cpp │ │ ├── settings.h │ │ ├── writer.cpp │ │ └── writer.h ├── gs-mpiio │ ├── .clang-format │ ├── .gitignore │ ├── .vscode │ │ ├── c_cpp_properties.json │ │ └── settings.json │ ├── CMakeLists.txt │ ├── README.md │ ├── adios2.xml │ ├── analysis │ │ └── pdf-calc.cpp │ ├── cleanup.sh │ ├── img │ │ ├── example1.jpg │ │ ├── example2.jpg │ │ ├── example3.jpg │ │ ├── example4.jpg │ │ └── example5.jpg │ ├── plot │ │ ├── gsplot.py │ │ └── gsread_mpi.py │ └── simulation │ │ ├── LICENSE │ │ ├── gray-scott.cpp │ │ ├── gray-scott.h │ │ ├── json.hpp │ │ ├── main.cpp │ │ ├── settings-files.json │ │ ├── settings.cpp │ │ ├── settings.h │ │ ├── writer.cpp │ │ └── writer.h ├── gs-noio │ ├── .clang-format │ ├── .gitignore │ ├── .vscode │ │ ├── c_cpp_properties.json │ │ └── settings.json │ ├── CMakeLists.txt │ ├── HOWTO-adios.md │ ├── README.md │ ├── adios2.xml │ ├── analysis │ │ └── pdf-calc.cpp │ ├── cleanup.sh │ ├── img │ │ ├── example1.jpg │ │ ├── example2.jpg │ │ ├── example3.jpg │ │ ├── example4.jpg │ │ └── example5.jpg │ ├── plot │ │ └── gsread_mpi.py │ └── simulation │ │ ├── LICENSE │ │ ├── gray-scott.cpp │ │ ├── gray-scott.h │ │ ├── json.hpp │ │ ├── main.cpp │ │ ├── settings-files.json │ │ ├── settings.cpp │ │ ├── settings.h │ │ ├── writer.cpp │ │ └── writer.h └── heat2d │ ├── cpp │ ├── Makefile │ ├── ReadMe.md │ ├── adios2.xml │ ├── analysis │ │ ├── AnalysisSettings.cpp │ │ ├── AnalysisSettings.h │ │ └── heatAnalysis.cpp │ ├── make.settings │ ├── runtimecfg │ │ ├── adios1.xml │ │ ├── bpfile.xml │ │ ├── dataman.xml │ │ ├── hdf5.xml │ │ ├── insitumpi.xml │ │ └── sst.xml │ ├── simulation │ │ ├── HeatTransfer.cpp │ │ ├── HeatTransfer.h │ │ ├── IO.h │ │ ├── IO_adios2.cpp │ │ ├── Settings.cpp │ │ ├── Settings.h │ │ └── heatSimulation.cpp │ └── visualization │ │ ├── VizOutput.h │ │ ├── VizOutputPrint.cpp │ │ ├── VizOutputVtkm.cpp │ │ ├── VizSettings.cpp │ │ ├── VizSettings.h │ │ └── heatVisualization.cpp │ ├── fortran │ ├── .gitignore │ ├── Makefile │ ├── README │ ├── README.MixedDemo │ ├── adios2.xml │ ├── analysis │ │ ├── Makefile │ │ ├── heatAnalysis_adios2_file.F90 │ │ ├── heatAnalysis_adios2_stream.F90 │ │ ├── heatAnalysis_hdf5_file.F90 │ │ ├── heatAnalysis_phdf5_file.F90 │ │ └── print.F90 │ ├── make.settings │ └── simulation │ │ ├── Makefile │ │ ├── heatSimulation.F90 │ │ ├── heat_vars.F90 │ │ ├── io_adios2.F90 │ │ ├── io_fort.F90 │ │ ├── io_hdf5_a.F90 │ │ ├── io_hdf5_b.F90 │ │ └── io_phdf5.F90 │ └── python │ ├── .obsolete │ ├── heat_all.py │ ├── heat_read_only.py │ ├── heat_read_write.py │ └── simple_steps.py │ ├── decomp.py │ └── heat_plot.py ├── heat_stability ├── CMakeLists.txt ├── ReadMe.md ├── heat_bp5.xml ├── heat_bp5_mgard.xml ├── heat_bp5_zfp.xml ├── plot_error.py ├── plot_heat.py └── write │ ├── CMakeLists.txt │ ├── HeatTransfer.cpp │ ├── HeatTransfer.h │ ├── IO.h │ ├── IO_adios2.cpp │ ├── Settings.cpp │ ├── Settings.h │ └── main.cpp ├── ssh_config ├── test_pbdR.r ├── vimrc └── xgc-f0-compression ├── .clang-format ├── .vscode ├── c_cpp_properties.json └── settings.json ├── CMakeLists.txt ├── adios2.xml ├── nrmse.cpp ├── xgc-f0-compression-adioscompression.cpp ├── xgc-f0-compression-cpu.cpp ├── xgc-f0-compression-vec.cpp └── xgc-f0-compression.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: LLVM 3 | BreakBeforeBraces: Custom 4 | ConstructorInitializerIndentWidth: 0 5 | IndentWidth: 4 6 | ContinuationIndentWidth: 4 7 | AccessModifierOffset: -4 8 | AlwaysBreakTemplateDeclarations: true 9 | CompactNamespaces: false 10 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 11 | FixNamespaceComments: false 12 | Standard: Cpp11 13 | ColumnLimit: 132 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AlignEscapedNewlines: Right 16 | AlignAfterOpenBracket: Align 17 | SortUsingDeclarations: false 18 | BraceWrapping: 19 | AfterClass: true 20 | AfterControlStatement: true 21 | AfterEnum: true 22 | AfterExternBlock: false 23 | AfterFunction: true 24 | AfterNamespace: true 25 | AfterStruct: true 26 | AfterUnion: true 27 | BeforeCatch: true 28 | BeforeElse: true 29 | SplitEmptyFunction: true 30 | SplitEmptyRecord: true 31 | SplitEmptyNamespace: false 32 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 100 3 | max-complexity = 1000 4 | format = pylint 5 | ignore = E302,F401,F403,F405,F999,W504 6 | exclude = thirdparty/,.gitlab/config/SpackCIBridge.py 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | 4 | # Libraries 5 | *.lib 6 | *.a 7 | *.la 8 | 9 | # Shared objects (inc. Windows DLLs) 10 | *.dll 11 | *.so 12 | *.so.* 13 | *.dylib 14 | *.mod 15 | 16 | # Executables 17 | *.exe 18 | *.out 19 | *.app 20 | *.pyc 21 | 22 | # BP files 23 | *.bp 24 | *.bp.dir 25 | 26 | 27 | # http://www.gnu.org/software/autoconf 28 | 29 | autom4te.cache 30 | aclocal.m4 31 | /compile 32 | /depcomp 33 | /install-sh 34 | /missing 35 | config.log 36 | config.status 37 | config/depcomp 38 | stamp-h1 39 | config.h.in 40 | config.h 41 | configure 42 | 43 | # all crap 44 | *.~ 45 | .~* 46 | *.*~ 47 | *.fh 48 | *.ch 49 | *.pyc 50 | \#* 51 | .DS_Store 52 | *.dSYM 53 | 54 | # gtags/rtags/ctags files 55 | GPATH 56 | GRTAGS 57 | GTAGS 58 | tags 59 | TAGS 60 | 61 | # exceptions from all crap 62 | #!examples/Fortran/*/*.fh 63 | 64 | 65 | #compiled files 66 | 67 | 68 | # Eclipse files and directories 69 | .cproject 70 | .project 71 | .settings 72 | .ptp-sync 73 | .ptp-sync-folder 74 | .pydevproject 75 | 76 | # VIM 77 | *.sw? 78 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "/opt/adios2/2.9.2/include", 8 | "/opt/c-blosc-2/2.4.3/include", 9 | "/opt/hdf5-parallel/default/include", 10 | "/usr/include/x86_64-linux-gnu/mpi/", 11 | "/home/adios/ADIOS2/thirdparty/GTest/googletest/googletest/include", 12 | "/home/adios/ADIOS2/thirdparty/yaml-cpp/yaml-cpp/include", 13 | "/opt/kokkos/3.7.1/include", 14 | "/opt/zfp/include" 15 | ], 16 | "defines": [ 17 | "ADIOS2_USE_MPI=1", 18 | "ADIOS2_HAVE_BLOSC=1", 19 | "ADIOS2_HAVE_BLOSC2=1", 20 | "ADIOS2_HAVE_ZFP=1" 21 | ], 22 | "compilerPath": "/usr/bin/gcc", 23 | "cStandard": "gnu17", 24 | "cppStandard": "gnu++14", 25 | "intelliSenseMode": "gcc-x64", 26 | "compileCommands": "${workspaceFolder}/.vscode/compile_commands.json" 27 | } 28 | ], 29 | "version": 4 30 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cmake.configureOnOpen": false, 3 | "clang-format.executable": "/home/adios/bin/clang-format", 4 | "editor.formatOnSave": true, 5 | "files.associations": { 6 | "array": "cpp", 7 | "atomic": "cpp", 8 | "bit": "cpp", 9 | "*.tcc": "cpp", 10 | "cctype": "cpp", 11 | "chrono": "cpp", 12 | "clocale": "cpp", 13 | "cmath": "cpp", 14 | "complex": "cpp", 15 | "condition_variable": "cpp", 16 | "cstdarg": "cpp", 17 | "cstddef": "cpp", 18 | "cstdint": "cpp", 19 | "cstdio": "cpp", 20 | "cstdlib": "cpp", 21 | "cstring": "cpp", 22 | "ctime": "cpp", 23 | "cwchar": "cpp", 24 | "cwctype": "cpp", 25 | "deque": "cpp", 26 | "map": "cpp", 27 | "set": "cpp", 28 | "unordered_map": "cpp", 29 | "unordered_set": "cpp", 30 | "vector": "cpp", 31 | "exception": "cpp", 32 | "algorithm": "cpp", 33 | "functional": "cpp", 34 | "iterator": "cpp", 35 | "memory": "cpp", 36 | "memory_resource": "cpp", 37 | "numeric": "cpp", 38 | "optional": "cpp", 39 | "random": "cpp", 40 | "ratio": "cpp", 41 | "string": "cpp", 42 | "string_view": "cpp", 43 | "system_error": "cpp", 44 | "tuple": "cpp", 45 | "type_traits": "cpp", 46 | "utility": "cpp", 47 | "fstream": "cpp", 48 | "future": "cpp", 49 | "initializer_list": "cpp", 50 | "iomanip": "cpp", 51 | "iosfwd": "cpp", 52 | "iostream": "cpp", 53 | "istream": "cpp", 54 | "limits": "cpp", 55 | "mutex": "cpp", 56 | "new": "cpp", 57 | "ostream": "cpp", 58 | "sstream": "cpp", 59 | "stdexcept": "cpp", 60 | "streambuf": "cpp", 61 | "thread": "cpp", 62 | "typeinfo": "cpp", 63 | "list": "cpp", 64 | "cinttypes": "cpp", 65 | "forward_list": "cpp", 66 | "valarray": "cpp" 67 | }, 68 | "git.ignoreLimitWarning": true, 69 | "C_Cpp.clang_format_path": "/home/adios/bin/clang-format" 70 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "type": "cppbuild", 5 | "label": "C/C++: gcc build active file", 6 | "command": "/usr/bin/gcc", 7 | "args": [ 8 | "-fdiagnostics-color=always", 9 | "-g", 10 | "${file}", 11 | "-o", 12 | "${fileDirname}/${fileBasenameNoExtension}" 13 | ], 14 | "options": { 15 | "cwd": "${fileDirname}" 16 | }, 17 | "problemMatcher": [ 18 | "$gcc" 19 | ], 20 | "group": { 21 | "kind": "build", 22 | "isDefault": true 23 | }, 24 | "detail": "Task generated by Debugger." 25 | } 26 | ], 27 | "version": "2.0.0" 28 | } -------------------------------------------------------------------------------- /README-for-ADIOS2.txt: -------------------------------------------------------------------------------- 1 | 2 | Download 3 | ======== 4 | 5 | First time: 6 | $ cd ~/Software 7 | $ git clone https://github.com/ornladios/ADIOS2.git 8 | $ cd ADIOS2 9 | $ git checkout master 10 | $ mkdir build 11 | 12 | Later: 13 | $ cd ~/Software/ADIOS2 14 | $ git pull 15 | 16 | 17 | Build 18 | ===== 19 | $ cd build 20 | $ cmake -DCMAKE_INSTALL_PREFIX=/opt/adios2 \ 21 | -DCMAKE_BUILD_TYPE=Release \ 22 | -DCMAKE_PREFIX_PATH="/opt/blosc;/opt/zfp/0.5.5;/opt/SZ/2.0.2.1;/opt/MGARD;/opt/hdf5-parallel" \ 23 | -DADIOS2_USE_MPI=ON \ 24 | -DADIOS2_USE_Python=ON \ 25 | -DADIOS2_USE_Profiling=ON \ 26 | -DADIOS2_BUILD_TESTING=OFF \ 27 | .. 28 | 29 | It should produce 30 | 31 | ADIOS2 build configuration: 32 | ADIOS Version: 2.5.0 33 | C++ Compiler : GNU 5.4.0 34 | /usr/bin/c++ 35 | 36 | Fortran Compiler : GNU 5.4.0 37 | /usr/bin/f95 38 | 39 | Installation prefix: /opt/adios2 40 | bin: bin 41 | lib: lib 42 | include: include 43 | cmake: lib/cmake/adios2 44 | python: lib/python3.5/site-packages 45 | 46 | Features: 47 | Library Type: shared 48 | Build Type: Release 49 | Testing: OFF 50 | Examples: ON 51 | Build Options: 52 | Blosc : ON 53 | BZip2 : ON 54 | ZFP : ON 55 | SZ : ON 56 | MGARD : ON 57 | PNG : ON 58 | MPI : ON 59 | DataMan : ON 60 | Table : ON 61 | SSC : ON 62 | SST : ON 63 | DataSpaces: OFF 64 | ZeroMQ : ON 65 | HDF5 : ON 66 | Python : ON 67 | Fortran : ON 68 | SysVShMem: ON 69 | Profiling: ON 70 | Endian_Reverse: OFF 71 | RDMA Transport for Staging: Unconfigured 72 | -- Configuring done 73 | -- Generating done 74 | -- Build files have been written to: /home/adios/Software/ADIOS2/build 75 | 76 | 77 | 78 | $ make -j 4 79 | 80 | Run Heat Transfer example 81 | ========================= 82 | $ cd ~/Software/ADIOS2/build 83 | $ mpirun -np 12 ./bin/heatTransfer_write_adios2 heat 4 3 100 100 5 100 84 | $ visit -o heat.bp 85 | 86 | 87 | -------------------------------------------------------------------------------- /Tutorial/brusselator/.gitignore: -------------------------------------------------------------------------------- 1 | *.mod 2 | *.o 3 | 4 | *Brusselator 5 | *norm_calc 6 | 7 | -------------------------------------------------------------------------------- /Tutorial/brusselator/README: -------------------------------------------------------------------------------- 1 | The Brusselator equation solver is in src/simulation/ . 2 | Analysis codes are in src/analysis/ . 3 | 4 | Compilation: 5 | ------------ 6 | cd src/ and follow the README 7 | 8 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.inc 2 | 3 | .PHONY: all simulation analysis clean cleanall 4 | 5 | all : var_checks simulation analysis 6 | @echo -n "\n------ Simulation and analysis built in their respective directories ------\n" 7 | 8 | simulation: var_checks 9 | cd simulation; ${MAKE} 10 | 11 | analysis: var_checks 12 | @set -e; cd analysis; ${MAKE} 13 | 14 | clean: 15 | cd simulation; ${MAKE} clean 16 | cd analysis; ${MAKE} clean 17 | 18 | cleanall: 19 | cd simulation; ${MAKE} cleanall 20 | cd analysis; ${MAKE} cleanall 21 | 22 | clean-data: 23 | rm -rf *.bp* *.h5 *.sst *.png 24 | 25 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/README: -------------------------------------------------------------------------------- 1 | Compilation 2 | ------------ 3 | 4 | Edit Makefile.inc to set compiler, flags, and the location of the FFTW and ADIOS2 libraries. 5 | Run `make`. 6 | 7 | This will build the simulation and the analysis codes in their respective directories. 8 | 9 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/analysis/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.inc 2 | 3 | all: var_checks norm_calc norm_calc2 4 | @echo -n "\n------ DONE BUILDING ANALYSIS analysis/norm_calc ------\n" 5 | 6 | norm_calc: var_checks norm_calc.cpp 7 | @set -e; ${CXX} ${CXXFLAGS} norm_calc.cpp -o norm_calc ${ADIOS2_CXXFLAGS} ${ADIOS2_CXXLIB} 8 | 9 | norm_calc2: var_checks norm_calc2.cpp 10 | @set -e; ${CXX} ${CXXFLAGS} norm_calc2.cpp -o norm_calc2 ${ADIOS2_CXXFLAGS} ${ADIOS2_CXXLIB} 11 | 12 | clean: 13 | rm -f *.o norm_calc norm_calc2 14 | cleanall: clean 15 | 16 | .PHONY: all clean cleanall 17 | 18 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/analysis/decomp.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def Locate(rank, nproc, datasize): 5 | extra = 0 6 | if (rank == nproc - 1): 7 | extra = datasize % nproc 8 | num = datasize // nproc 9 | start = num * rank 10 | size = num + extra 11 | return start, size 12 | 13 | 14 | class MPISetup(object): 15 | 16 | readargs = [] 17 | size = 1 18 | rank = {'world': 0, 19 | 'x': 0, 20 | 'y': 0} 21 | 22 | 23 | def __init__(self, args): 24 | 25 | self.nx = args.nx 26 | self.ny = args.ny 27 | 28 | if not args.nompi: 29 | 30 | from mpi4py import MPI 31 | 32 | color = 3 33 | self.comm_world = MPI.COMM_WORLD.Split(color, MPI.COMM_WORLD.Get_rank()) 34 | self.size = self.comm_world.Get_size() 35 | self.rank['world'] = self.comm_world.Get_rank() 36 | if self.size != (self.nx * self.ny): 37 | raise ValueError("nx * ny != num processes") 38 | 39 | if (self.ny > 1) and (self.nx > 1): 40 | comm_x = self.comm_world.Split(self.rank['world'] % self.nx, self.rank['world']) 41 | else: 42 | comm_x = self.comm_world.Split(self.rank['world'] / self.nx, self.rank['world']) 43 | comm_y = self.comm_world.Split(self.rank['world']/self.ny, self.rank['world']) 44 | 45 | self.rank['x'] = comm_x.Get_rank() 46 | self.rank['y'] = comm_y.Get_rank() 47 | 48 | self.readargs.append(self.comm_world) 49 | 50 | else: 51 | if self.nx != 1: 52 | raise ValueError("nx must = 1 without MPI") 53 | if self.ny != 1: 54 | raise ValueError("ny must = 1 without MPI") 55 | 56 | # self.readargs.extend([args.xmlfile, "heat"]) 57 | 58 | 59 | def Partition(self, fp, args): 60 | datashape = np.zeros(3, dtype=np.int64) 61 | start = np.zeros(3, dtype=np.int64) 62 | size = np.zeros(3, dtype=np.int64) 63 | 64 | #print("dir fp {0}".format(dir(fp))) 65 | var = fp.availablevariables() 66 | # print("var {0}".format(var)) 67 | # print('key') 68 | # print('type {0}'.format(type(var))) 69 | #print("args varname {0}".format(args.varname)) 70 | #print('var keys') 71 | # print(var.keys()) 72 | data = var[str(args.varname)] 73 | dshape = var[str(args.varname)]['Shape'].split(',') 74 | for i in range(len(dshape)): 75 | datashape[i] = int(dshape[i]) 76 | 77 | start[0], size[0] = Locate(self.rank['y'], self.ny, datashape[0]) 78 | start[1], size[1] = Locate(self.rank['x'], self.nx, datashape[1]) 79 | 80 | return start, size, datashape 81 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/Makefile: -------------------------------------------------------------------------------- 1 | 2DECOMP_DIR=$(CURDIR) 2 | 3 | .PHONY: src clean 4 | 5 | all: src 6 | 7 | src: 8 | mkdir -p lib include 9 | cd src; $(MAKE) 10 | 11 | clean: 12 | cd src; $(MAKE) $@ 13 | rm -rf include/* lib/* 14 | 15 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/README: -------------------------------------------------------------------------------- 1 | 2DECOMP&FFT - Library for 2D pencil decomposition and highly scalable 2 | distributed 3D Fast Fourier Transforms 3 | 4 | Version 1.5 5 | 6 | Copyright (C) 2009-2012 Ning Li 7 | The Numerical Algorithms Group (NAG) 8 | 9 | http://www.2decomp.org 10 | 11 | 2DECOMP&FFT is part of the Open Petascale Libraries. 12 | 13 | http://www.openpetascale.org/2decomp 14 | 15 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: test2d fft_test_c2c fft_test_r2c timing halo_test io_test 2 | 3 | # Just build the examples 4 | examples: test2d fft_test_c2c fft_test_r2c timing halo_test io_test 5 | @echo "Built the examples" 6 | 7 | test2d: 8 | cd test2d; $(MAKE) $@ 9 | fft_test_c2c: 10 | cd fft_test_c2c; $(MAKE) $@ 11 | fft_test_r2c: 12 | cd fft_test_r2c; $(MAKE) $@ 13 | timing: 14 | cd timing; $(MAKE) $@ 15 | halo_test: 16 | cd halo_test; $(MAKE) $@ 17 | io_test: 18 | cd io_test; $(MAKE) $@ 19 | 20 | # test all the examples (individual Makefiels should take care of updating) 21 | basic_test: 22 | cd test2d; $(MAKE) $@ 23 | cd fft_test_c2c; $(MAKE) $@ 24 | cd fft_test_r2c; $(MAKE) $@ 25 | cd timing; $(MAKE) $@ 26 | cd halo_test; $(MAKE) $@ 27 | cd io_test; $(MAKE) $@ 28 | 29 | clean: 30 | cd test2d; $(MAKE) $@ 31 | cd fft_test_c2c; $(MAKE) $@ 32 | cd fft_test_r2c; $(MAKE) $@ 33 | cd timing; $(MAKE) $@ 34 | cd halo_test; $(MAKE) $@ 35 | cd io_test; $(MAKE) $@ 36 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/README.examples: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | test2d - to test the base 2D pencil decomposition module 5 | 6 | fft_test_c2c - to test the complex-to-complex FFTs 7 | 8 | fft_test_r2c - to test the real-to-complex/complex-to-real FFTs 9 | 10 | timing - to benchmark the FFT library 11 | 12 | halo_test - to test the halo-cell exchange code 13 | 14 | io_test - to test various IO functions 15 | 16 | p3dfft - to crosscheck the library against P3DFFT 17 | 18 | non_blocking - to test the idea of overlap communication and computation 19 | 20 | tecplot_view - to generate Tecplot visualisation of the decomposition 21 | 22 | 23 | Some examples may require external libraries to be built first. Refer to the 24 | README files for each example for details. 25 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/fft_test_c2c/Makefile: -------------------------------------------------------------------------------- 1 | include ../../src/Makefile.inc 2 | 3 | INCLUDE = -I../../include 4 | LIBS = -L../../lib -l2decomp_fft $(LIBFFT) 5 | 6 | OBJ = fft_test_c2c.o 7 | 8 | fft_test_c2c: $(OBJ) 9 | $(F90) -o $@ $(OBJ) $(LIBS) 10 | 11 | clean: 12 | rm -f *.o fft_test_c2c 13 | 14 | %.o : %.f90 15 | $(F90) $(INCLUDE) $(OPTIONS) $(F90FLAGS) -c $< 16 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/fft_test_c2c/README: -------------------------------------------------------------------------------- 1 | fft_test_c2c 2 | ------------ 3 | 4 | This example demonstrates the use of the FFT c2c interface. The test uses the 5 | input of NAG routine 'c06fxf' (also for c2c transform) and attempts to 6 | reproduce the output. 7 | 8 | To run: use 4 MPI processes. 9 | 10 | What to expect: the output should match what is in 'c06fxfe.r'. 11 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/fft_test_c2c/c06fxfe.r: -------------------------------------------------------------------------------- 1 | C06FXF Example Program Results 2 | 3 | Original data values 4 | 5 | z(i,j,k) for i = 1 6 | 7 | Real 1.000 0.999 0.987 0.936 8 | Imag 0.000 -0.040 -0.159 -0.352 9 | 10 | Real 0.994 0.989 0.963 0.891 11 | Imag -0.111 -0.151 -0.268 -0.454 12 | 13 | Real 0.903 0.885 0.823 0.694 14 | Imag -0.430 -0.466 -0.568 -0.720 15 | 16 | z(i,j,k) for i = 2 17 | 18 | Real 0.500 0.499 0.487 0.436 19 | Imag 0.500 0.040 0.159 0.352 20 | 21 | Real 0.494 0.489 0.463 0.391 22 | Imag 0.111 0.151 0.268 0.454 23 | 24 | Real 0.403 0.385 0.323 0.194 25 | Imag 0.430 0.466 0.568 0.720 26 | 27 | Components of discrete Fourier transform 28 | 29 | z(i,j,k) for i = 1 30 | 31 | Real 3.292 0.051 0.113 0.051 32 | Imag 0.102 -0.042 0.102 0.246 33 | 34 | Real 0.143 0.016 -0.024 -0.050 35 | Imag -0.086 0.153 0.127 0.086 36 | 37 | Real 0.143 -0.050 -0.024 0.016 38 | Imag 0.290 0.118 0.077 0.051 39 | 40 | z(i,j,k) for i = 2 41 | 42 | Real 1.225 0.355 0.000 -0.355 43 | Imag -1.620 0.083 0.162 0.083 44 | 45 | Real 0.424 0.020 0.013 -0.007 46 | Imag 0.320 -0.115 -0.091 -0.080 47 | 48 | Real -0.424 0.007 -0.013 -0.020 49 | Imag 0.320 -0.080 -0.091 -0.115 50 | 51 | Original sequence as restored by inverse transform 52 | 53 | z(i,j,k) for i = 1 54 | 55 | Real 1.000 0.999 0.987 0.936 56 | Imag 0.000 -0.040 -0.159 -0.352 57 | 58 | Real 0.994 0.989 0.963 0.891 59 | Imag -0.111 -0.151 -0.268 -0.454 60 | 61 | Real 0.903 0.885 0.823 0.694 62 | Imag -0.430 -0.466 -0.568 -0.720 63 | 64 | z(i,j,k) for i = 2 65 | 66 | Real 0.500 0.499 0.487 0.436 67 | Imag 0.500 0.040 0.159 0.352 68 | 69 | Real 0.494 0.489 0.463 0.391 70 | Imag 0.111 0.151 0.268 0.454 71 | 72 | Real 0.403 0.385 0.323 0.194 73 | Imag 0.430 0.466 0.568 0.720 74 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/fft_test_r2c/Makefile: -------------------------------------------------------------------------------- 1 | include ../../src/Makefile.inc 2 | 3 | INCLUDE = -I../../include 4 | LIBS = -L../../lib -l2decomp_fft $(LIBFFT) 5 | 6 | OBJ = fft_test_r2c.o 7 | 8 | fft_test_r2c: $(OBJ) 9 | $(F90) -o $@ $(OBJ) $(LIBS) 10 | 11 | clean: 12 | rm -f *.o fft_test_r2c 13 | 14 | %.o : %.f90 15 | $(F90) $(INCLUDE) $(OPTIONS) $(F90FLAGS) -c $< 16 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/fft_test_r2c/README: -------------------------------------------------------------------------------- 1 | fft_test_r2c 2 | ------------ 3 | 4 | This example demonstrates the use of the FFT r2c/c2r interface. It generates 5 | random input and computes a serial 3D r2c transform on rank 0 to generate 6 | reference results. It then performs parallel computations of the same transform 7 | on distributed data. There are two separate tests, with input data distributed 8 | in X-pencil and Z-pencil, respectively. In each test, a r2c transform is 9 | performed first and its results on rank 0 printed out. Then an inverse c2r 10 | transform is followed which should recover the input to machine accuracy. 11 | 12 | To run: use 4 MPI processes. 13 | 14 | What to expect: 15 | - The output from the distributed computations should contain a subset of 16 | numbers as in the serial output. 17 | - The error reported should be around machine accuracy (~ 10^-6 for single 18 | precision and 10^-15 for double) 19 | 20 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/ga_test/Makefile: -------------------------------------------------------------------------------- 1 | include ../../src/Makefile.inc 2 | 3 | # customise the PATHs for FFTW and Gloal Arrays toolkit as needed 4 | 5 | FFTW3_PATH=$(HOME)/software/build/fftw-3.3 6 | GA_PATH=$(HOME)/software/build/ga-5-0-2 7 | INCLUDE = -I../../include -I$(FFTW3_PATH)/include -I$(GA_PATH)/include 8 | 9 | LIBS = -L../../lib -l2decomp_fft -L$(FFTW3_PATH)/lib -lfftw3 -lfftw3f -L$(GA_PATH)/lib -lga 10 | 11 | all: ga_test 12 | 13 | ga_test: ga_test.o 14 | $(F90) -o $@ $@.o $(LIBS) 15 | 16 | clean: 17 | rm -f *.o ga_test 18 | 19 | %.o : %.f90 20 | $(F90) $(INCLUDE) $(OPTIONS) $(F90FLAGS) -c $< 21 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/ga_test/README: -------------------------------------------------------------------------------- 1 | ga_test 2 | ------- 3 | 4 | This folder contains an applications using the Global Arrays toolkit (GA) to 5 | implement a 3D FFT. While the data is still distributed via 2DECOMP&FFT's 6 | decomposition library, there are no global transpositions. All comminications 7 | are done via GA, who encapsulated the communications and gives a shared-memory 8 | view of the global data. 9 | 10 | To build this application, GA has to be installed first, and its path given in 11 | the Makefile. 12 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/halo_test/Makefile: -------------------------------------------------------------------------------- 1 | include ../../src/Makefile.inc 2 | 3 | INCLUDE = -I../../include 4 | LIBS = -L../../lib -l2decomp_fft 5 | 6 | OBJ = halo_test.o 7 | 8 | halo_test: $(OBJ) 9 | $(F90) -o $@ $(OBJ) $(LIBS) 10 | 11 | clean: 12 | rm -f *.o halo_test 13 | 14 | %.o : %.f90 15 | $(F90) $(INCLUDE) $(OPTIONS) $(F90FLAGS) -c $< 16 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/halo_test/README: -------------------------------------------------------------------------------- 1 | halo_test 2 | --------- 3 | 4 | This example demonstrates the use of the halo-cell support API. It calculates 5 | the divergency of an arbitrary field, which contains evaluation of spatial 6 | derivatives in all three dimensions. The calculation was first implemented via 7 | the global transposition routines, then via halo-cell exchanges. Identical 8 | results are to be expected regardless of the communication algorithm. The 9 | computation is based on an explicit finite difference method so clearly using 10 | the halo-cell support API is more efficient. 11 | 12 | To run: use 12 MPI processes. 13 | 14 | What to expect: the output using different communication algorithms should be 15 | exactly the same. 16 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/io_test/Makefile: -------------------------------------------------------------------------------- 1 | include ../../src/Makefile.inc 2 | 3 | INCLUDE = -I../../include 4 | LIBS = -L../../lib -l2decomp_fft 5 | ifneq (,$(findstring DT3PIO,$(OPTIONS))) 6 | LIBS+= -L$(T3PIO_PATH)/lib -lt3pio 7 | endif 8 | 9 | all: io_test io_read io_var_test io_plane_test io_bench 10 | 11 | io_test: io_test.o 12 | $(F90) -o $@ $@.o $(LIBS) 13 | 14 | io_read: io_read.o 15 | $(F90) -o $@ $@.o $(LIBS) 16 | 17 | io_var_test: io_var_test.o 18 | $(F90) -o $@ $@.o $(LIBS) 19 | 20 | io_plane_test: io_plane_test.o 21 | $(F90) -o $@ $@.o $(LIBS) 22 | 23 | io_bench: io_bench.o 24 | $(F90) -o $@ $@.o $(LIBS) 25 | 26 | clean: 27 | rm -f *.o io_test io_read io_var_test io_plane_test io_bench 28 | 29 | realclean: clean 30 | rm -f *.dat io_var_data.* 31 | 32 | %.o : %.f90 33 | $(F90) $(INCLUDE) $(OPTIONS) $(ARG) $(F90FLAGS) -c $< 34 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/io_test/README: -------------------------------------------------------------------------------- 1 | io_test 2 | ------- 3 | 4 | This folder contains several applications to thoroughly test 2DECOMP&FFT's 5 | IO library. 6 | 7 | To run: If interactive run is possible on your system, adapt the script 8 | provided to run all the tests in one go. 9 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/io_test/io_bench.f90: -------------------------------------------------------------------------------- 1 | program io_bench 2 | 3 | use decomp_2d 4 | use decomp_2d_io 5 | use MPI 6 | 7 | implicit none 8 | 9 | integer, parameter :: nx=100, ny=100, nz=100 10 | integer, parameter :: p_row=4, p_col=4 11 | 12 | real(mytype), allocatable, dimension(:,:,:) :: u1 13 | 14 | double precision :: t1, t2 15 | integer :: ierror 16 | 17 | call MPI_INIT(ierror) 18 | call decomp_2d_init(nx,ny,nz,p_row,p_col) 19 | 20 | allocate(u1(xstart(1):xend(1), xstart(2):xend(2), xstart(3):xend(3))) 21 | call random_number(u1) 22 | 23 | t1 = MPI_WTIME() 24 | call decomp_2d_write_one(1,u1,'io.dat') 25 | t2 = MPI_WTIME() 26 | 27 | if (nrank==0) write(*,*) 'I/O time: ', t2-t1 28 | 29 | call decomp_2d_finalize 30 | call MPI_FINALIZE(ierror) 31 | deallocate(u1) 32 | 33 | end program io_bench 34 | 35 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/io_test/io_read.f90: -------------------------------------------------------------------------------- 1 | program io_read 2 | 3 | use decomp_2d 4 | use decomp_2d_io 5 | 6 | implicit none 7 | 8 | integer, parameter :: nx=17, ny=13, nz=11 9 | ! use different number of processes 10 | integer, parameter :: p_row=3, p_col=2 11 | 12 | #ifdef COMPLEX_TEST 13 | complex(mytype), dimension(nx,ny,nz) :: data1 14 | 15 | complex(mytype), allocatable, dimension(:,:,:) :: u1b, u2b, u3b 16 | #else 17 | real(mytype), dimension(nx,ny,nz) :: data1 18 | 19 | real(mytype), allocatable, dimension(:,:,:) :: u1b, u2b, u3b 20 | #endif 21 | 22 | real(mytype), parameter :: eps = 1.0E-7_mytype 23 | 24 | integer :: i,j,k, m, ierror 25 | 26 | call MPI_INIT(ierror) 27 | call decomp_2d_init(nx,ny,nz,p_row,p_col) 28 | 29 | ! ***** global data ***** 30 | m = 1 31 | do k=1,nz 32 | do j=1,ny 33 | do i=1,nx 34 | #ifdef COMPLEX_TEST 35 | data1(i,j,k) = cmplx(real(m,mytype), real(nx*ny*nz-m,mytype)) 36 | #else 37 | data1(i,j,k) = real(m,mytype) 38 | #endif 39 | m = m+1 40 | end do 41 | end do 42 | end do 43 | 44 | allocate(u1b(xstart(1):xend(1), xstart(2):xend(2), xstart(3):xend(3))) 45 | allocate(u2b(ystart(1):yend(1), ystart(2):yend(2), ystart(3):yend(3))) 46 | allocate(u3b(zstart(1):zend(1), zstart(2):zend(2), zstart(3):zend(3))) 47 | 48 | ! read back to different arrays 49 | call decomp_2d_read_one(1,u1b,'u1.dat') 50 | call decomp_2d_read_one(2,u2b,'u2.dat') 51 | call decomp_2d_read_one(3,u3b,'u3.dat') 52 | 53 | ! Check against the global data array 54 | do k=xstart(3),xend(3) 55 | do j=xstart(2),xend(2) 56 | do i=xstart(1),xend(1) 57 | if (abs((data1(i,j,k)-u1b(i,j,k))) > eps) stop 4 58 | end do 59 | end do 60 | end do 61 | 62 | do k=ystart(3),yend(3) 63 | do j=ystart(2),yend(2) 64 | do i=ystart(1),yend(1) 65 | if (abs((data1(i,j,k)-u2b(i,j,k))) > eps) stop 5 66 | end do 67 | end do 68 | end do 69 | 70 | do k=zstart(3),zend(3) 71 | do j=zstart(2),zend(2) 72 | do i=zstart(1),zend(1) 73 | if (abs((data1(i,j,k)-u3b(i,j,k))) > eps) stop 6 74 | end do 75 | end do 76 | end do 77 | 78 | call decomp_2d_finalize 79 | call MPI_FINALIZE(ierror) 80 | deallocate(u1b,u2b,u3b) 81 | 82 | end program io_read 83 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/io_test/run_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | make 4 | if [ $? -ne 0 ] ; then 5 | echo "=================================================" 6 | echo "Failed to build the applications. Fix them first!" 7 | echo "=================================================" 8 | exit 1 9 | fi 10 | 11 | echo " " 12 | echo "writing data files using MPI-IO..." 13 | echo "mpirun -np 12 ./io_test" 14 | mpirun -np 12 ./io_test 15 | 16 | echo " " 17 | echo "reading data files back (different number of processes)..." 18 | echo "mpirun -np 6 ./io_read" 19 | mpirun -np 6 ./io_read 20 | 21 | # The files written by MPI-IO should be independent on # processes 22 | echo " " 23 | echo "*** testing write_var..." 24 | echo "mpirun -np 20 ./io_var_test 5 4" 25 | mpirun -np 20 ./io_var_test 5 4 26 | echo "mpirun -np 12 ./io_var_test 4 3" 27 | mpirun -np 12 ./io_var_test 4 3 28 | echo "mpirun -np 6 ./io_var_test 3 2" 29 | mpirun -np 6 ./io_var_test 3 2 30 | echo "mpirun -np 2 ./io_var_test 2 1" 31 | mpirun -np 2 ./io_var_test 2 1 32 | diff -s io_var_data.020 io_var_data.012 33 | diff -s io_var_data.020 io_var_data.006 34 | diff -s io_var_data.020 io_var_data.002 35 | 36 | echo " " 37 | echo "*** testing write_plane..." 38 | echo "mpirun -np 12 ./io_plane_test" 39 | mpirun -np 12 ./io_plane_test 40 | diff -s x_pencil-x_plane.dat y_pencil-x_plane.dat 41 | diff -s x_pencil-x_plane.dat z_pencil-x_plane.dat 42 | diff -s x_pencil-y_plane.dat y_pencil-y_plane.dat 43 | diff -s x_pencil-y_plane.dat z_pencil-y_plane.dat 44 | diff -s x_pencil-z_plane.dat y_pencil-z_plane.dat 45 | diff -s x_pencil-z_plane.dat z_pencil-z_plane.dat 46 | 47 | echo " " 48 | echo "Tests PASSED, unless errors reported" 49 | 50 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/non_blocking/Makefile: -------------------------------------------------------------------------------- 1 | include ../../src/Makefile.inc 2 | 3 | # customise the PATHs for FFTW and libNBC as needed 4 | 5 | FFTW3_PATH=$(HOME)/software/build/fftw-3.3 6 | INCLUDE = -I../../include -I$(FFTW3_PATH)/include 7 | LIBNBC_PATH = $(HOME)/software/build/libNBC-1.1.1-thread 8 | 9 | LIBS = -L../../lib -l2decomp_fft $(LIBNBC_PATH)/lib/libnbc.a -lstdc++ -lmpi_cxx -L$(FFTW3_PATH)/lib -lfftw3 10 | 11 | all: blocking non_blocking 12 | 13 | blocking: blocking.o 14 | $(F90) -o $@ $@.o $(LIBS) 15 | 16 | non_blocking: non_blocking.o 17 | $(F90) -o $@ $@.o $(LIBS) 18 | 19 | clean: 20 | rm -f *.o blocking non_blocking 21 | 22 | %.o : %.f90 23 | $(F90) $(INCLUDE) $(OPTIONS) $(F90FLAGS) -c $< 24 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/non_blocking/README: -------------------------------------------------------------------------------- 1 | This folder contains two sample applications to compute multiple independent 2 | FFTs. The first application - 'blocking.f90' - uses the standard blocking 3 | version of MPI communication code to transpose the data among different stages 4 | of the computation. The second - 'non_blocking.f90' - performs the same 5 | computation using the non-blocking communication code supplied by 2DECOMP&FFT. 6 | 7 | Please note that the non-blocking communication was realised using libNBC, 8 | a library implementing non-blocking MPI collectives (such as IALLTOALL) using 9 | existing MPI 1 functions. Such functionality is expected to be part of the 10 | MPI 3 standard. 11 | 12 | To build the non-blocking test application, user needs to obtain a copy of 13 | libNBC at http://www.unixer.de/research/nbcoll/libnbc/, compile it, and link it 14 | to 2DECOMP&FFT and the object code of the test application. 15 | 16 | To demonstrate the idea of overlap communication and computation, the 3D FFT 17 | is implemented using multiple 1D FFTs (without using the advanced interface of 18 | FFTW) so that MPI_TEST calls can be easily inserted in the computational part 19 | of the code. This is required because the communication has to be explicitly 20 | progressed when running on the same thread as the computation. 21 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/p3dfft/Makefile: -------------------------------------------------------------------------------- 1 | include ../../src/Makefile.inc 2 | 3 | P3DFFT_HOME=$(HOME)/software/build/p3dfft-2.5.1-dimsc 4 | FFTW3_HOME=$(HOME)/software/build/fftw-3.3 5 | 6 | INCLUDE = -I../../include -I$(P3DFFT_HOME)/include 7 | LIBS = -L../../lib -l2decomp_fft -L$(P3DFFT_HOME)/lib -lp3dfft $(LIBFFT) -L$(FFTW3_HOME)/lib -lfftw3 8 | 9 | OBJ = p3dfft.o 10 | 11 | p3dfft: $(OBJ) 12 | $(F90) -o $@ $(OBJ) $(LIBS) 13 | 14 | clean: 15 | rm -f *.o p3dfft 16 | 17 | %.o : %.f90 18 | $(F90) $(INCLUDE) $(OPTIONS) $(F90FLAGS) -c $< 19 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/p3dfft/README: -------------------------------------------------------------------------------- 1 | p3dfft 2 | ------ 3 | 4 | This program 5 | 6 | * Crosschecks the results computed by 2DECOMP&FFT and P3DFFT. 7 | * Compares the performance of 2DECOMP&FFT and P3DFFT. 8 | 9 | Prerequisite: 10 | 11 | * P3DFFT version 2.5.1 required (API not compatible with older versions) 12 | * P3DFFT is installed at $P3DFFT_HOME and path set properly in Makefile. 13 | * Both P3DFFT and 2DECOMP&FFT are built in double precision. 14 | * P3DFFT is built with -DDIMS_C flag (same decomposition as 2DECOMP&FFT) 15 | * P3DFFT is built against FFTW; 2DECOMP&FFT can use any FFT engine. 16 | 17 | What to expect: 18 | 19 | * Results from P3DFFT and 2DECOMP&FFT should be almost the same, even when 20 | different FFT engines are used. As we are comparing large numbers (>>1), 21 | the difference should be small but not as small as machine accuracy. 22 | * Each library should recover the input after one forward and one backward 23 | transform with errors reported close to machine accuracy. 24 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/tecplot_view/2decomp_decomp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/brusselator/src/simulation/2decomp_fft/examples/tecplot_view/2decomp_decomp.png -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/tecplot_view/Makefile: -------------------------------------------------------------------------------- 1 | include ../../src/Makefile.inc 2 | 3 | INCLUDE = -I../../include 4 | LIBS = -L../../lib -l2decomp_fft 5 | 6 | OBJ = tecplot_view.o 7 | 8 | tecplot_view: $(OBJ) 9 | $(F90) -o $@ $(OBJ) $(LIBS) 10 | 11 | clean: 12 | rm -f *.o tecplot_view 13 | 14 | %.o : %.f90 15 | $(F90) $(INCLUDE) $(OPTIONS) $(F90FLAGS) -c $< 16 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/tecplot_view/README: -------------------------------------------------------------------------------- 1 | tecplot_view 2 | ------------ 3 | 4 | This program generates data to visualise the 2D decomposition options. 5 | 6 | To run: use 12 MPI processes. 7 | 8 | What to expect: several data files are written to disk. These are in the 9 | standard format that can be read by Tecplot (a visualisation package popular 10 | in the CFD community). 11 | 12 | There is also an interactive web page at http://www.2decomp.org/decomp.php 13 | to demonstrate the data distribution in a 2D decomposition. 14 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/test2d/Makefile: -------------------------------------------------------------------------------- 1 | include ../../src/Makefile.inc 2 | 3 | INCLUDE = -I../../include 4 | LIBS = -L../../lib -l2decomp_fft 5 | 6 | OBJ = test2d.o 7 | 8 | test2d: $(OBJ) 9 | $(F90) -o $@ $(OBJ) $(LIBS) 10 | 11 | clean: 12 | rm -f *.o test2d u*.dat 13 | 14 | %.o : %.f90 15 | $(F90) $(INCLUDE) $(OPTIONS) $(F90FLAGS) -c $< 16 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/test2d/README: -------------------------------------------------------------------------------- 1 | test2d 2 | ------ 3 | 4 | This program is to validate the 2D pencil decomposition library. It transposes 5 | a set of data into different storage formats so that all communication routines 6 | are tested. The test code also demonstrates to use of the I/O library. 7 | 8 | To run: use 12 MPI processes. 9 | 10 | What to expect: many files are written to disk. Regardless of the pencil- 11 | orientation of the distributed data, files written collectively by all MPI 12 | processes should contain identical information. For example, u1.dat, u2.dat, 13 | u3.dat, u2b.dat and u1b.dat should be all identical. 14 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/timing/Makefile: -------------------------------------------------------------------------------- 1 | include ../../src/Makefile.inc 2 | 3 | INCLUDE = -I../../include 4 | LIBS = -L../../lib -l2decomp_fft $(LIBFFT) 5 | 6 | OBJ = timing.o 7 | 8 | timing: $(OBJ) 9 | $(F90) -o $@ $(OBJ) $(LIBS) 10 | 11 | clean: 12 | rm -f *.o timing 13 | 14 | %.o : %.f90 15 | $(F90) $(INCLUDE) $(OPTIONS) $(F90FLAGS) -c $< 16 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/examples/timing/README: -------------------------------------------------------------------------------- 1 | timing 2 | ------ 3 | 4 | This program can be used to benchmark the performance of the FFT library. 5 | Timings for both c2c and r2c/c2r transforms are collected. Also the FFT 6 | library is validated as the input data should be recovered to machine 7 | accuracy after a forward and a backward transform and proper normalisation. 8 | 9 | To run: set a proper problem size and number of MPI processes to use (these 10 | are hardware dependent). 11 | 12 | What to expect: 13 | - The timing results 14 | - The error reported should be around machine accuracy (~ 10^-6 for single 15 | precision and 10^-15 for double) 16 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/src/Makefile: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # Makefile for building the 2DECOMP&FFT library 3 | ######################################################################## 4 | 5 | # Normally, do not change anything here. Modify the platform-dependent 6 | # Makefile.inc file instead 7 | 8 | include ../../../Makefile.inc 9 | 10 | SRCS = decomp_2d.f90 io.f90 glassman.f90 fft_$(FFT).f90 11 | 12 | # special treatment for shared-memory code 13 | ifneq (,$(findstring DSHM,$(OPTIONS))) 14 | SRCS := FreeIPC.f90 $(SRCS) 15 | OBJS = $(SRCS:.f90=.o) alloc_shm.o FreeIPC_c.o 16 | else 17 | OBJS = $(SRCS:.f90=.o) 18 | endif 19 | 20 | # special treatment for Intel MKL (need to build MKL mod files) 21 | MKL_MOD= 22 | ifeq ($(FFT),mkl) 23 | MKL_MOD=mkl_mod 24 | endif 25 | 26 | all: lib examples 27 | 28 | lib: includes lib2decomp_fft.a 29 | cp lib2decomp_fft.a ../lib 30 | 31 | includes: lib2decomp_fft.a 32 | cp *.mod ../include 33 | 34 | lib2decomp_fft.a: $(MKL_MOD) $(OBJS) 35 | ar qc $@ $(OBJS) 36 | 37 | alloc_shm.o: alloc_shm.c 38 | $(CC) $(CFLAGS) -c $< 39 | 40 | FreeIPC_c.o: FreeIPC_c.c 41 | $(CC) $(CFLAGS) -c $< 42 | 43 | .PHONY: mkl_mod 44 | mkl_mod: 45 | echo Building Intel MKL mod files... 46 | $(IFORT) -c $(MKL_PATH)/include/mkl_dfti.f90 47 | 48 | .PHONY: examples 49 | examples: lib 50 | 51 | .PHONY: test 52 | test: examples 53 | 54 | .PHONY: clean 55 | clean: 56 | rm -f *.o *.mod lib*.a 57 | 58 | .PHONY: realclean 59 | realclean: clean 60 | rm -f *~ \#*\# 61 | 62 | %.o : %.f90 63 | $(F90) $(OPTIONS) $(F90FLAGS) -c $< 64 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/src/Makefile.inc.BlueGene: -------------------------------------------------------------------------------- 1 | # Configurations for IBM BlueGene systems 2 | # using IBM XL compilers 3 | 4 | # 2DECOMP&FFT options 5 | #==================== 6 | 7 | # Choose pre-processing options 8 | # -DDOUBLE_PREC - use double-precision (default single) 9 | # -DEVEN - for evenly distributed data, use ALLTOALL 10 | # -DOVERWRITE - allow FFT input to be overwritten (save memory) 11 | # -DOCC - use API for overlap communication and computation 12 | OPTION=-DDOUBLE_PREC -DOVERWRITE 13 | 14 | # Choose one FFT engine, available options are: 15 | # essl - IBM Engineering and Scientific Subroutine Library 16 | # fftw3 - FFTW version 3.x 17 | # fftw3_f03 - FFTW 3.3-beta1 or later (with Fortran 2003 interface) 18 | # generic - A general FFT algorithm (no 3rd-party library needed) 19 | FFT=generic 20 | 21 | # Platform-dependent information 22 | #=============================== 23 | 24 | # special syntax for IBM XL compiler's preprocessing 25 | # instead of using "-DTAG1 -DTAG2", XL needs "-WF,-DTAG1 -WF,-DTAG2" 26 | from:=-D 27 | to:=-WF,-D 28 | TMP=$(subst $(from),$(to),$(OPTION)) 29 | OPTIONS=$(TMP) 30 | 31 | # The path of the base BlueGene system software 32 | BGP_SYS=/bgsys/drivers/V1R4M1_460_2009-091110P/ppc/comm/xl 33 | 34 | # Inlcude path 35 | INC= 36 | 37 | #----------------------- Fortran Compiler ---------------------------- 38 | F90=$(BGP_SYS)/bin/mpixlf90_r 39 | 40 | # enable preprocessing 41 | CPPFLAGS=-qsuffix=cpp=f90 42 | 43 | # enable Cray pointer support if needed 44 | CRAYPTR= 45 | 46 | # optimisation or debugging flags 47 | OPTIM=-O3 -qarch=450d -qtune=450 48 | 49 | F90FLAGS=$(OPTIM) $(CRAYPTR) $(CPPFLAGS) $(INC) 50 | LDFLAGS=$(OPTIM) 51 | 52 | #--------------------------C Compiler--------------------------------- 53 | CC=mpixlc_r 54 | CFLAGS=-O3 55 | 56 | #-----------------------External Library------------------------------ 57 | 58 | # for FFTW 59 | LIB_FFTW3=-lfftw3f -lfftw3 -L # supply path to FFTW3 here 60 | 61 | # for ESSL 62 | LIB_ESSL=-L$(BGP_SYS)/lib -L/opt/ibmmath/lib -lesslbg 63 | 64 | ifeq ($(FFT),generic) 65 | LIBFFT= 66 | else ifeq ($(FFT),fftw3) 67 | LIBFFT=$(LIB_FFTW3) 68 | else ifeq ($(FFT),fftw3_f03) 69 | LIBFFT=$(LIB_FFTW3) 70 | else ifeq ($(FFT),essl) 71 | LIBFFT=$(LIB_ESSL) 72 | endif 73 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/src/Makefile.inc.Cray_XE: -------------------------------------------------------------------------------- 1 | # Configurations for Cray XT/XE systems 2 | # using PGI/PathScale/GNU/Cray compilers 3 | 4 | # 2DECOMP&FFT options 5 | #==================== 6 | 7 | # Choose pre-processing options 8 | # -DDOUBLE_PREC - use double-precision (default single) 9 | # -DEVEN - for evenly distributed data, use ALLTOALL 10 | # -DSHM - enable shared-memory implementation 11 | # -DOVERWRITE - allow FFT input to be overwritten (save memory) 12 | # -DOCC - use API for overlap communication and computation 13 | OPTIONS=-DDOUBLE_PREC -DOVERWRITE 14 | 15 | # Choose one FFT engine, available options are: 16 | # acml - AMD Core Math Library 17 | # fftw3 - FFTW version 3.x 18 | # fftw3_f03 - FFTW 3.3-beta1 or later (with Fortran 2003 interface) 19 | # generic - A general FFT algorithm (no 3rd-party library needed) 20 | FFT=fftw3 21 | 22 | # Platform-dependent information 23 | #=============================== 24 | 25 | # Choose compiler suite - valid options: PGI, PathScale, GNU, Cray, Intel 26 | COMPILER=PGI 27 | 28 | # Inlcude path not set, relying on Cray's modules 29 | INC= 30 | 31 | #----------------------- Fortran Compiler ---------------------------- 32 | F90=ftn 33 | 34 | # enable preprocessing 35 | ifeq ($(COMPILER),PGI) 36 | CPPFLAGS=-Mpreprocess 37 | else ifeq ($(COMPILER),PathScale) 38 | CPPFLAGS=-cpp 39 | else ifeq ($(COMPILER),GNU) 40 | CPPFLAGS=-cpp 41 | else ifeq ($(COMPILER),Cray) 42 | CPPFLAGS=-e Fm 43 | else ifeq ($(COMPILER),Intel) 44 | CPPFLAGS=-fpp 45 | endif 46 | 47 | # enable Cray pointer support if needed 48 | ifeq ($(COMPILER),GNU) 49 | CRAYPTR=-fcray-pointer 50 | else 51 | CRAYPTR= 52 | endif 53 | 54 | # optimisation or debugging flags 55 | ifeq ($(COMPILER),PGI) 56 | OPTIM=-O3 57 | else ifeq ($(COMPILER),PathScale) 58 | OPTIM=-O3 59 | else ifeq ($(COMPILER),GNU) 60 | #OPTIM=-g -fbounds-check 61 | OPTIM=-O3 62 | else ifeq ($(COMPILER),Cray) 63 | OPTIM=-O3 64 | else ifeq ($(COMPILER),Intel) 65 | OPTIM=-O3 # no -fast as IPA cause problem 66 | endif 67 | F90FLAGS=$(OPTIM) $(CRAYPTR) $(CPPFLAGS) $(INC) 68 | LDFLAGS=$(OPTIM) 69 | 70 | #--------------------------C Compiler--------------------------------- 71 | CC=cc 72 | CFLAGS=-O3 73 | 74 | #-----------------------External Library------------------------------ 75 | 76 | # Do not need any as this is all handled by the 'module' system 77 | 78 | LIBFFT= 79 | 80 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/src/Makefile.inc.Fujitsu_SPARC64_VIIIfx: -------------------------------------------------------------------------------- 1 | # Configurations for SPARC64 servers using Fujitsu compiler 2 | # configutation tested on a SPARC64 VIIIfx machine 3 | 4 | # 2DECOMP&FFT options 5 | #==================== 6 | 7 | # Choose pre-processing options 8 | # -DDOUBLE_PREC - use double-precision (default single) 9 | # -DEVEN - for evenly distributed data, use ALLTOALL 10 | # -DOVERWRITE - allow FFT input to be overwritten (save memory) 11 | # -DOCC - use API for overlap communication and computation 12 | OPTIONS=-DDOUBLE_PREC -DOVERWRITE 13 | 14 | # Choose one FFT engine, available options are: 15 | # ffte - FFTE 16 | # fftw3 - FFTW version 3.x 17 | # fftw3_f03 - FFTW 3.3-beta1 or later (with Fortran 2003 interface) 18 | # generic - A general FFT algorithm (no 3rd-party library needed) 19 | FFT=generic 20 | 21 | # Platform-dependent information - compiler, external library etc 22 | #================================================================ 23 | 24 | # Inlcude path if necessary 25 | # Need to compile a copy of FFTW version 3.x using the same Fujitsu compiler 26 | FFTW_PATH= 27 | ifeq ($(FFT),fftw3) 28 | INC=-I$(FFTW_PATH)/include 29 | else ifeq ($(FFT),fftw3_f03) 30 | INC=-I$(FFTW_PATH)/include 31 | else 32 | INC= 33 | endif 34 | 35 | #----------------------- Fortran Compiler ---------------------------- 36 | F90=mpifrtpx 37 | 38 | # enable preprocessing 39 | CPPFLAGS=-Cpp 40 | # enable Cray pointer support if needed 41 | CRAYPTR= 42 | # optimisation or debugging flags 43 | #OPTIM=-g 44 | OPTIM=-Kfast 45 | 46 | F90FLAGS=$(OPTIM) $(CRAYPTR) $(CPPFLAGS) $(INC) 47 | LDFLAGS=$(OPTIM) 48 | 49 | #--------------------------C Compiler--------------------------------- 50 | CC=mpifccpx 51 | CFLAGS=-Kfast 52 | 53 | #-----------------------External Library------------------------------ 54 | 55 | # For FFTW 56 | LIB_FFTW3=-L$(FFTW_PATH)/lib -lfftw3f -lfftw3 57 | 58 | # For FFTE 59 | FFTE_PATH=path/to/ffte-4.1 # compile FFTE using the same compiler 60 | LIB_FFTE=$(FFTE_PATH)/libffte.a 61 | 62 | ifeq ($(FFT),generic) 63 | LIBFFT= 64 | else ifeq ($(FFT),ffte) 65 | LIBFFT=$(LIB_FFTE) 66 | else ifeq ($(FFT),fftw3) 67 | LIBFFT=$(LIB_FFTW3) 68 | else ifeq ($(FFT),fftw3_f03) 69 | LIBFFT=$(LIB_FFTW3) 70 | endif 71 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/src/factor.f90: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2012 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! A few utility routines to find factors of integer numbers 13 | 14 | subroutine findfactor(num, factors, nfact) 15 | 16 | implicit none 17 | 18 | integer, intent(IN) :: num 19 | integer, intent(OUT), dimension(*) :: factors 20 | integer, intent(OUT) :: nfact 21 | integer :: i, m 22 | 23 | ! find the factors <= sqrt(num) 24 | m = int(sqrt(real(num))) 25 | nfact = 1 26 | do i=1,m 27 | if (num/i*i == num) then 28 | factors(nfact) = i 29 | nfact = nfact + 1 30 | end if 31 | end do 32 | nfact = nfact - 1 33 | 34 | ! derive those > sqrt(num) 35 | if (factors(nfact)**2/=num) then 36 | do i=nfact+1, 2*nfact 37 | factors(i) = num / factors(2*nfact-i+1) 38 | end do 39 | nfact = nfact * 2 40 | else 41 | do i=nfact+1, 2*nfact-1 42 | factors(i) = num / factors(2*nfact-i) 43 | end do 44 | nfact = nfact * 2 - 1 45 | endif 46 | 47 | return 48 | 49 | end subroutine findfactor 50 | 51 | 52 | subroutine primefactors(num, factors, nfact) 53 | 54 | implicit none 55 | 56 | integer, intent(IN) :: num 57 | integer, intent(OUT), dimension(*) :: factors 58 | integer, intent(INOUT) :: nfact 59 | 60 | integer :: i, n 61 | 62 | i = 2 63 | nfact = 1 64 | n = num 65 | do 66 | if (mod(n,i) == 0) then 67 | factors(nfact) = i 68 | nfact = nfact + 1 69 | n = n / i 70 | else 71 | i = i + 1 72 | end if 73 | if (n == 1) then 74 | nfact = nfact - 1 75 | exit 76 | end if 77 | end do 78 | 79 | return 80 | 81 | end subroutine primefactors 82 | 83 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/src/io_read_one.f90: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2012 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain common code to be included by subroutines 13 | ! 'mpiio_read_one_...' in io.f90 14 | 15 | ! Using MPI-IO to write a distributed 3D array into a file 16 | 17 | if (present(opt_decomp)) then 18 | decomp = opt_decomp 19 | else 20 | call get_decomp_info(decomp) 21 | end if 22 | 23 | ! determine subarray parameters 24 | sizes(1) = decomp%xsz(1) 25 | sizes(2) = decomp%ysz(2) 26 | sizes(3) = decomp%zsz(3) 27 | 28 | if (ipencil == 1) then 29 | subsizes(1) = decomp%xsz(1) 30 | subsizes(2) = decomp%xsz(2) 31 | subsizes(3) = decomp%xsz(3) 32 | starts(1) = decomp%xst(1)-1 ! 0-based index 33 | starts(2) = decomp%xst(2)-1 34 | starts(3) = decomp%xst(3)-1 35 | else if (ipencil == 2) then 36 | subsizes(1) = decomp%ysz(1) 37 | subsizes(2) = decomp%ysz(2) 38 | subsizes(3) = decomp%ysz(3) 39 | starts(1) = decomp%yst(1)-1 40 | starts(2) = decomp%yst(2)-1 41 | starts(3) = decomp%yst(3)-1 42 | else if (ipencil == 3) then 43 | subsizes(1) = decomp%zsz(1) 44 | subsizes(2) = decomp%zsz(2) 45 | subsizes(3) = decomp%zsz(3) 46 | starts(1) = decomp%zst(1)-1 47 | starts(2) = decomp%zst(2)-1 48 | starts(3) = decomp%zst(3)-1 49 | endif 50 | 51 | call MPI_TYPE_CREATE_SUBARRAY(3, sizes, subsizes, starts, & 52 | MPI_ORDER_FORTRAN, data_type, newtype, ierror) 53 | call MPI_TYPE_COMMIT(newtype,ierror) 54 | call MPI_FILE_OPEN(MPI_COMM_WORLD, filename, & 55 | MPI_MODE_RDONLY, MPI_INFO_NULL, & 56 | fh, ierror) 57 | disp = 0_MPI_OFFSET_KIND 58 | call MPI_FILE_SET_VIEW(fh,disp,data_type, & 59 | newtype,'native',MPI_INFO_NULL,ierror) 60 | call MPI_FILE_READ_ALL(fh, var, & 61 | subsizes(1)*subsizes(2)*subsizes(3), & 62 | data_type, MPI_STATUS_IGNORE, ierror) 63 | call MPI_FILE_CLOSE(fh,ierror) 64 | call MPI_TYPE_FREE(newtype,ierror) 65 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/src/io_read_var.f90: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2012 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain common code to be included by subroutines 13 | ! 'read_var_...' in io.f90 14 | 15 | ! Using MPI-IO to read a distributed 3D variable from a file. File 16 | ! operations (open/close) need to be done in calling application. This 17 | ! allows multiple variables to be read from a single file. Together 18 | ! with the corresponding write operation, this is the perfect solution 19 | ! for applications to perform restart/checkpointing. 20 | 21 | if (present(opt_decomp)) then 22 | decomp = opt_decomp 23 | else 24 | call get_decomp_info(decomp) 25 | end if 26 | 27 | ! Create file type and set file view 28 | sizes(1) = decomp%xsz(1) 29 | sizes(2) = decomp%ysz(2) 30 | sizes(3) = decomp%zsz(3) 31 | if (ipencil == 1) then 32 | subsizes(1) = decomp%xsz(1) 33 | subsizes(2) = decomp%xsz(2) 34 | subsizes(3) = decomp%xsz(3) 35 | starts(1) = decomp%xst(1)-1 ! 0-based index 36 | starts(2) = decomp%xst(2)-1 37 | starts(3) = decomp%xst(3)-1 38 | else if (ipencil == 2) then 39 | subsizes(1) = decomp%ysz(1) 40 | subsizes(2) = decomp%ysz(2) 41 | subsizes(3) = decomp%ysz(3) 42 | starts(1) = decomp%yst(1)-1 43 | starts(2) = decomp%yst(2)-1 44 | starts(3) = decomp%yst(3)-1 45 | else if (ipencil == 3) then 46 | subsizes(1) = decomp%zsz(1) 47 | subsizes(2) = decomp%zsz(2) 48 | subsizes(3) = decomp%zsz(3) 49 | starts(1) = decomp%zst(1)-1 50 | starts(2) = decomp%zst(2)-1 51 | starts(3) = decomp%zst(3)-1 52 | endif 53 | 54 | call MPI_TYPE_CREATE_SUBARRAY(3, sizes, subsizes, starts, & 55 | MPI_ORDER_FORTRAN, data_type, newtype, ierror) 56 | call MPI_TYPE_COMMIT(newtype,ierror) 57 | call MPI_FILE_SET_VIEW(fh,disp,data_type, & 58 | newtype,'native',MPI_INFO_NULL,ierror) 59 | call MPI_FILE_READ_ALL(fh, var, & 60 | subsizes(1)*subsizes(2)*subsizes(3), & 61 | data_type, MPI_STATUS_IGNORE, ierror) 62 | call MPI_TYPE_FREE(newtype,ierror) 63 | 64 | ! update displacement for the next read operation 65 | disp = disp + sizes(1)*sizes(2)*sizes(3)*mytype_bytes 66 | if (data_type == complex_type) then 67 | disp = disp + sizes(1)*sizes(2)*sizes(3)*mytype_bytes 68 | end if 69 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/src/io_write_one.f90: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2012 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain common code to be included by subroutines 13 | ! 'mpiio_write_one_...' in io.f90 14 | 15 | ! Using MPI-IO to write a distributed 3D array into a file 16 | 17 | if (present(opt_decomp)) then 18 | decomp = opt_decomp 19 | else 20 | call get_decomp_info(decomp) 21 | end if 22 | 23 | ! determine subarray parameters 24 | sizes(1) = decomp%xsz(1) 25 | sizes(2) = decomp%ysz(2) 26 | sizes(3) = decomp%zsz(3) 27 | 28 | if (ipencil == 1) then 29 | subsizes(1) = decomp%xsz(1) 30 | subsizes(2) = decomp%xsz(2) 31 | subsizes(3) = decomp%xsz(3) 32 | starts(1) = decomp%xst(1)-1 ! 0-based index 33 | starts(2) = decomp%xst(2)-1 34 | starts(3) = decomp%xst(3)-1 35 | else if (ipencil == 2) then 36 | subsizes(1) = decomp%ysz(1) 37 | subsizes(2) = decomp%ysz(2) 38 | subsizes(3) = decomp%ysz(3) 39 | starts(1) = decomp%yst(1)-1 40 | starts(2) = decomp%yst(2)-1 41 | starts(3) = decomp%yst(3)-1 42 | else if (ipencil == 3) then 43 | subsizes(1) = decomp%zsz(1) 44 | subsizes(2) = decomp%zsz(2) 45 | subsizes(3) = decomp%zsz(3) 46 | starts(1) = decomp%zst(1)-1 47 | starts(2) = decomp%zst(2)-1 48 | starts(3) = decomp%zst(3)-1 49 | endif 50 | 51 | #ifdef T3PIO 52 | call MPI_INFO_CREATE(info, ierror) 53 | gs = ceiling(real(sizes(1),mytype)*real(sizes(2),mytype)* & 54 | real(sizes(3),mytype)/1024./1024.) 55 | call t3pio_set_info(MPI_COMM_WORLD, info, "./", ierror, & 56 | GLOBAL_SIZE=gs, factor=1) 57 | #endif 58 | 59 | call MPI_TYPE_CREATE_SUBARRAY(3, sizes, subsizes, starts, & 60 | MPI_ORDER_FORTRAN, data_type, newtype, ierror) 61 | call MPI_TYPE_COMMIT(newtype,ierror) 62 | #ifdef T3PIO 63 | call MPI_FILE_OPEN(MPI_COMM_WORLD, filename, & 64 | MPI_MODE_CREATE+MPI_MODE_WRONLY, info, fh, ierror) 65 | #else 66 | call MPI_FILE_OPEN(MPI_COMM_WORLD, filename, & 67 | MPI_MODE_CREATE+MPI_MODE_WRONLY, MPI_INFO_NULL, & 68 | fh, ierror) 69 | #endif 70 | filesize = 0_MPI_OFFSET_KIND 71 | call MPI_FILE_SET_SIZE(fh,filesize,ierror) ! guarantee overwriting 72 | disp = 0_MPI_OFFSET_KIND 73 | call MPI_FILE_SET_VIEW(fh,disp,data_type, & 74 | newtype,'native',MPI_INFO_NULL,ierror) 75 | call MPI_FILE_WRITE_ALL(fh, var, & 76 | subsizes(1)*subsizes(2)*subsizes(3), & 77 | data_type, MPI_STATUS_IGNORE, ierror) 78 | call MPI_FILE_CLOSE(fh,ierror) 79 | call MPI_TYPE_FREE(newtype,ierror) 80 | #ifdef T3PIO 81 | call MPI_INFO_FREE(info,ierror) 82 | #endif 83 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/2decomp_fft/src/io_write_var.f90: -------------------------------------------------------------------------------- 1 | !======================================================================= 2 | ! This is part of the 2DECOMP&FFT library 3 | ! 4 | ! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil) 5 | ! decomposition. It also implements a highly scalable distributed 6 | ! three-dimensional Fast Fourier Transform (FFT). 7 | ! 8 | ! Copyright (C) 2009-2012 Ning Li, the Numerical Algorithms Group (NAG) 9 | ! 10 | !======================================================================= 11 | 12 | ! This file contain common code to be included by subroutines 13 | ! 'write_var_...' in io.f90 14 | 15 | ! Using MPI-IO to write a distributed 3D variable to a file. File 16 | ! operations (open/close) need to be done in calling application. This 17 | ! allows multiple variables to be written to a single file. Together 18 | ! with the corresponding read operation, this is the perfect solution 19 | ! for applications to perform restart/checkpointing. 20 | 21 | if (present(opt_decomp)) then 22 | decomp = opt_decomp 23 | else 24 | call get_decomp_info(decomp) 25 | end if 26 | 27 | ! Create file type and set file view 28 | sizes(1) = decomp%xsz(1) 29 | sizes(2) = decomp%ysz(2) 30 | sizes(3) = decomp%zsz(3) 31 | if (ipencil == 1) then 32 | subsizes(1) = decomp%xsz(1) 33 | subsizes(2) = decomp%xsz(2) 34 | subsizes(3) = decomp%xsz(3) 35 | starts(1) = decomp%xst(1)-1 ! 0-based index 36 | starts(2) = decomp%xst(2)-1 37 | starts(3) = decomp%xst(3)-1 38 | else if (ipencil == 2) then 39 | subsizes(1) = decomp%ysz(1) 40 | subsizes(2) = decomp%ysz(2) 41 | subsizes(3) = decomp%ysz(3) 42 | starts(1) = decomp%yst(1)-1 43 | starts(2) = decomp%yst(2)-1 44 | starts(3) = decomp%yst(3)-1 45 | else if (ipencil == 3) then 46 | subsizes(1) = decomp%zsz(1) 47 | subsizes(2) = decomp%zsz(2) 48 | subsizes(3) = decomp%zsz(3) 49 | starts(1) = decomp%zst(1)-1 50 | starts(2) = decomp%zst(2)-1 51 | starts(3) = decomp%zst(3)-1 52 | endif 53 | 54 | call MPI_TYPE_CREATE_SUBARRAY(3, sizes, subsizes, starts, & 55 | MPI_ORDER_FORTRAN, data_type, newtype, ierror) 56 | call MPI_TYPE_COMMIT(newtype,ierror) 57 | call MPI_FILE_SET_VIEW(fh,disp,data_type, & 58 | newtype,'native',MPI_INFO_NULL,ierror) 59 | call MPI_FILE_WRITE_ALL(fh, var, & 60 | subsizes(1)*subsizes(2)*subsizes(3), & 61 | data_type, MPI_STATUS_IGNORE, ierror) 62 | call MPI_TYPE_FREE(newtype,ierror) 63 | 64 | ! update displacement for the next write operation 65 | disp = disp + sizes(1)*sizes(2)*sizes(3)*mytype_bytes 66 | if (data_type == complex_type) then 67 | disp = disp + sizes(1)*sizes(2)*sizes(3)*mytype_bytes 68 | end if 69 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/Makefile: -------------------------------------------------------------------------------- 1 | # Set options to allow for conditional compilation, use only one of the options below 2 | # These are processed using the C pre-processor 3 | # 4 | # 5 | 6 | include ../Makefile.inc 7 | 8 | SOURCES = brusselator.f90 initialdata.f90 savedata.f90 getgrid.f90 \ 9 | linear.f90 nonlinear1.f90 nonlinear2.f90 10 | 11 | OBJECTS = brusselator.o initialdata.o savedata.o getgrid.o \ 12 | linear.o nonlinear1.o nonlinear2.o 13 | 14 | all : var_checks Brusselator 15 | @echo -n "\n------ DONE BUILDING SIMULATION simulation/Brusselator ------\n" 16 | 17 | 2decomp_fft: var_checks 18 | cd 2decomp_fft; $(MAKE) 19 | 20 | Brusselator: var_checks 2decomp_fft $(OBJECTS) 21 | ${FC} -o Brusselator $(OBJECTS) $(LIBS) 22 | 23 | brusselator.o : brusselator.f90 savedata.o 24 | ${FC} -c $(FFLAGS) $(INCLUDES) brusselator.f90 25 | 26 | savedata.o : savedata.f90 27 | ${FC} -c $(FFLAGS) $(INCLUDES) savedata.f90 28 | 29 | initialdata.o : initialdata.f90 30 | ${FC} -c $(FFLAGS) $(INCLUDES) initialdata.f90 31 | 32 | getgrid.o : savedata.o getgrid.f90 33 | ${FC} -c $(FFLAGS) $(INCLUDES) getgrid.f90 34 | 35 | linear.o : linear.f90 36 | ${FC} -c $(FFLAGS) $(INCLUDES) linear.f90 37 | 38 | nonlinear1.o : nonlinear1.f90 39 | ${FC} -c $(FFLAGS) $(INCLUDES) nonlinear1.f90 40 | 41 | nonlinear2.o : nonlinear2.f90 42 | ${FC} -c $(FFLAGS) $(INCLUDES) nonlinear2.f90 43 | 44 | clean: 45 | rm -f *.o *.mod 46 | rm -f Brusselator 47 | 48 | cleanall: clean 49 | cd 2decomp_fft; ${MAKE} clean 50 | 51 | .PHONY: 2decomp_fft clean cleanall 52 | 53 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/README: -------------------------------------------------------------------------------- 1 | The Brusselator source code has been forked from https://github.com/openmichigan/PSNM. 2 | Its dependency - 2decomp_fft, has been downloaded from http://www.2decomp.org. Current version of 2decomp_fft is 1.5.847. 3 | 4 | Run 5 | --- 6 | 7 | Example: 8 | `mpirun -np 4 ./Brusselator output nx ny nz steps plotgap(seconds)` 9 | 10 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/initialdata.f90: -------------------------------------------------------------------------------- 1 | SUBROUTINE initialdata(Nx,Ny,Nz,x,y,z,u,v,decomp) 2 | !-------------------------------------------------------------------- 3 | ! 4 | ! 5 | ! PURPOSE 6 | ! 7 | ! This subroutine gets initial data for Brusselator equation 8 | ! in 3 dimensions 9 | ! u_t = a + u^2v - (b+1)u + Du u_xx 10 | ! v_t = bu - u^2v + Dv v_xx 11 | ! 12 | ! The boundary conditions are u(x=-Lx*\pi,y,z)=u(x=Lx*\pi,y,z), 13 | ! u(x,y=-Ly*\pi,z)=u(x,y=Ly*\pi,z),u(x,y,z=-Ly*\pi)=u(x,y,z=Ly*\pi) 14 | ! The initial condition is 15 | ! u=0.5+exp(-1.0-(x**2+y**2+z**2)) 16 | ! v=0.1+exp(-1.0-(x**2+y**2+z**2)) 17 | ! 18 | ! INPUT 19 | ! 20 | ! .. Parameters .. 21 | ! Nx = number of modes in x - power of 2 for FFT 22 | ! Ny = number of modes in y - power of 2 for FFT 23 | ! Nz = number of modes in z - power of 2 for FFT 24 | ! .. Vectors .. 25 | ! x = x locations 26 | ! y = y locations 27 | ! z = z locations 28 | ! .. Special Structures .. 29 | ! decomp = contains information on domain decomposition 30 | ! see http://www.2decomp.org/ for more information 31 | ! OUTPUT 32 | ! 33 | ! .. Arrays .. 34 | ! u = initial solution 35 | ! uold = approximate solution based on time derivative of 36 | ! initial solution 37 | ! 38 | ! LOCAL VARIABLES 39 | ! 40 | ! .. Scalars .. 41 | ! i = loop counter in x direction 42 | ! j = loop counter in y direction 43 | ! k = loop counter in z direction 44 | ! 45 | ! REFERENCES 46 | ! 47 | ! ACKNOWLEDGEMENTS 48 | ! 49 | ! ACCURACY 50 | ! 51 | ! ERROR INDICATORS AND WARNINGS 52 | ! 53 | ! FURTHER COMMENTS 54 | ! Check that the initial iterate is consistent with the 55 | ! boundary conditions for the domain specified 56 | !-------------------------------------------------------------------- 57 | ! External routines required 58 | ! 59 | ! External libraries required 60 | ! 2DECOMP&FFT -- Domain decomposition and Fast Fourier Library 61 | ! (http://www.2decomp.org/index.html) 62 | ! MPI library 63 | USE decomp_2d 64 | IMPLICIT NONE 65 | INCLUDE 'mpif.h' 66 | ! Declare variables 67 | INTEGER(KIND=4), INTENT(IN) :: Nx,Ny,Nz 68 | TYPE(DECOMP_INFO), INTENT(IN) :: decomp 69 | REAL(KIND=8), DIMENSION(decomp%xst(1):decomp%xen(1)), INTENT(IN) :: x 70 | REAL(KIND=8), DIMENSION(decomp%xst(2):decomp%xen(2)), INTENT(IN) :: y 71 | REAL(KIND=8), DIMENSION(decomp%xst(3):decomp%xen(3)), INTENT(IN) :: z 72 | COMPLEX(KIND=8), DIMENSION(decomp%xst(1):decomp%xen(1),& 73 | decomp%xst(2):decomp%xen(2),& 74 | decomp%xst(3):decomp%xen(3)),& 75 | INTENT(OUT) :: u,v 76 | INTEGER(kind=4) :: i,j,k 77 | 78 | DO k=decomp%xst(3),decomp%xen(3); DO j=decomp%xst(2),decomp%xen(2); DO i=decomp%xst(1),decomp%xen(1) 79 | u(i,j,k)=15.0d0+8.0d0*sin(2.0*x(i))*cos(2.0*y(j))*cos(4.0*z(k)) !*exp(-4.0*(x(i)**2+y(j)**2+0.0d0*z(k)**2)) 80 | v(i,j,k)=0.10d0 +0.75d0*exp(-4.0d0*(x(i)**2+y(j)**2+1.0d0*z(k)**2)) 81 | END DO; END DO; END DO 82 | END SUBROUTINE initialdata 83 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/nonlinear1.f90: -------------------------------------------------------------------------------- 1 | SUBROUTINE nonlinear1(dt,coef,u,v,decomp) 2 | !-------------------------------------------------------------------- 3 | ! 4 | ! 5 | ! PURPOSE 6 | ! 7 | ! This subroutine solves the first nonlinear equation in a splitting 8 | ! method for the Brusselator equation in 3 dimensions 9 | ! u_t = a + u^2v - (b+1)u + Du u_xx 10 | ! v_t = bu - u^2v + Dv v_xx 11 | ! 12 | ! 13 | ! INPUT 14 | ! 15 | ! .. Parameters .. 16 | ! dt = timestep 17 | ! coef = (complex) timestep coeffcient 18 | ! .. Arrays .. 19 | ! u = u field 20 | ! v = v field 21 | ! .. Special Structures .. 22 | ! decomp = contains information on domain decomposition 23 | ! see http://www.2decomp.org/ for more information 24 | ! OUTPUT 25 | ! 26 | ! .. Arrays .. 27 | ! u = updated u field 28 | ! 29 | ! LOCAL VARIABLES 30 | ! 31 | ! .. Scalars .. 32 | ! i = loop counter in x direction 33 | ! j = loop counter in y direction 34 | ! k = loop counter in z direction 35 | ! temp = temporary storage variable 36 | ! REFERENCES 37 | ! 38 | ! ACKNOWLEDGEMENTS 39 | ! 40 | ! ACCURACY 41 | ! 42 | ! ERROR INDICATORS AND WARNINGS 43 | ! 44 | ! FURTHER COMMENTS 45 | ! Check that the initial iterate is consistent with the 46 | ! boundary conditions for the domain specified 47 | !-------------------------------------------------------------------- 48 | ! External routines required 49 | ! 50 | ! External libraries required 51 | ! 2DECOMP&FFT -- Domain decomposition and Fast Fourier Library 52 | ! (http://www.2decomp.org/index.html) 53 | ! MPI library 54 | USE decomp_2d 55 | IMPLICIT NONE 56 | INCLUDE 'mpif.h' 57 | ! Declare variables 58 | TYPE(DECOMP_INFO), INTENT(IN) :: decomp 59 | REAL(KIND=8), INTENT(IN) :: dt 60 | COMPLEX(KIND=8), INTENT(IN) :: coef 61 | COMPLEX(KIND=8), DIMENSION(decomp%xst(1):decomp%xen(1),& 62 | decomp%xst(2):decomp%xen(2),& 63 | decomp%xst(3):decomp%xen(3)),& 64 | INTENT(INOUT) :: u 65 | COMPLEX(KIND=8), DIMENSION(decomp%xst(1):decomp%xen(1),& 66 | decomp%xst(2):decomp%xen(2),& 67 | decomp%xst(3):decomp%xen(3)),& 68 | INTENT(IN) :: v 69 | INTEGER(kind=4) :: i,j,k 70 | COMPLEX(kind=8) :: temp 71 | DO k=decomp%xst(3),decomp%xen(3); DO j=decomp%xst(2),decomp%xen(2); DO i=decomp%xst(1),decomp%xen(1) 72 | temp=u(i,j,k) 73 | u(i,j,k)=temp/(1-temp*v(i,j,k)*coef*dt) 74 | END DO; END DO; END DO 75 | END SUBROUTINE nonlinear1 76 | -------------------------------------------------------------------------------- /Tutorial/brusselator/src/simulation/nonlinear2.f90: -------------------------------------------------------------------------------- 1 | SUBROUTINE nonlinear2(dt,coef,u,v,decomp) 2 | !-------------------------------------------------------------------- 3 | ! 4 | ! 5 | ! PURPOSE 6 | ! 7 | ! This subroutine solves the second nonlinear equation in a splitting 8 | ! method for the Brusselator equation in 3 dimensions 9 | ! u_t = a + u^2v - (b+1)u + Du u_xx 10 | ! v_t = bu - u^2v + Dv v_xx 11 | ! 12 | ! 13 | ! INPUT 14 | ! 15 | ! .. Parameters .. 16 | ! dt = timestep 17 | ! coef = (complex) timestep coeffcient 18 | ! .. Arrays .. 19 | ! u = u field 20 | ! v = v field 21 | ! .. Special Structures .. 22 | ! decomp = contains information on domain decomposition 23 | ! see http://www.2decomp.org/ for more information 24 | ! OUTPUT 25 | ! 26 | ! .. Arrays .. 27 | ! v = updated v field 28 | ! 29 | ! LOCAL VARIABLES 30 | ! 31 | ! .. Scalars .. 32 | ! i = loop counter in x direction 33 | ! j = loop counter in y direction 34 | ! k = loop counter in z direction 35 | ! REFERENCES 36 | ! 37 | ! ACKNOWLEDGEMENTS 38 | ! 39 | ! ACCURACY 40 | ! 41 | ! ERROR INDICATORS AND WARNINGS 42 | ! 43 | ! FURTHER COMMENTS 44 | ! Check that the initial iterate is consistent with the 45 | ! boundary conditions for the domain specified 46 | !-------------------------------------------------------------------- 47 | ! External routines required 48 | ! 49 | ! External libraries required 50 | ! 2DECOMP&FFT -- Domain decomposition and Fast Fourier Library 51 | ! (http://www.2decomp.org/index.html) 52 | ! MPI library 53 | USE decomp_2d 54 | IMPLICIT NONE 55 | INCLUDE 'mpif.h' 56 | ! Declare variables 57 | TYPE(DECOMP_INFO), INTENT(IN) :: decomp 58 | REAL(KIND=8), INTENT(IN) :: dt 59 | COMPLEX(KIND=8), INTENT(IN) :: coef 60 | COMPLEX(KIND=8), DIMENSION(decomp%xst(1):decomp%xen(1),& 61 | decomp%xst(2):decomp%xen(2),& 62 | decomp%xst(3):decomp%xen(3)),& 63 | INTENT(IN) :: u 64 | COMPLEX(KIND=8), DIMENSION(decomp%xst(1):decomp%xen(1),& 65 | decomp%xst(2):decomp%xen(2),& 66 | decomp%xst(3):decomp%xen(3)),& 67 | INTENT(INOUT) :: v 68 | INTEGER(kind=4) :: i,j,k 69 | DO k=decomp%xst(3),decomp%xen(3); DO j=decomp%xst(2),decomp%xen(2); DO i=decomp%xst(1),decomp%xen(1) 70 | v(i,j,k)=v(i,j,k)*exp(-1.0d0*dt*coef*u(i,j,k)**2) 71 | END DO; END DO; END DO 72 | END SUBROUTINE nonlinear2 73 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: LLVM 3 | BreakBeforeBraces: Custom 4 | ConstructorInitializerIndentWidth: 0 5 | IndentWidth: 4 6 | ContinuationIndentWidth: 4 7 | AccessModifierOffset: -4 8 | AlwaysBreakTemplateDeclarations: true 9 | CompactNamespaces: false 10 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 11 | FixNamespaceComments: false 12 | Standard: Cpp11 13 | ColumnLimit: 80 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AlignEscapedNewlines: Right 16 | AlignAfterOpenBracket: Align 17 | SortUsingDeclarations: false 18 | BraceWrapping: 19 | AfterClass: true 20 | AfterControlStatement: true 21 | AfterEnum: true 22 | AfterExternBlock: false 23 | AfterFunction: true 24 | AfterNamespace: true 25 | AfterStruct: true 26 | AfterUnion: true 27 | BeforeCatch: true 28 | BeforeElse: true 29 | SplitEmptyFunction: true 30 | SplitEmptyRecord: true 31 | SplitEmptyNamespace: false 32 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/e313e296c1e284d908adcb95bf4f2812617d4de1/C++.gitignore 2 | 3 | # Prerequisites 4 | *.d 5 | 6 | # Compiled Object files 7 | *.slo 8 | *.lo 9 | *.o 10 | *.obj 11 | 12 | # Precompiled Headers 13 | *.gch 14 | *.pch 15 | 16 | # Compiled Dynamic libraries 17 | *.so 18 | *.dylib 19 | *.dll 20 | 21 | # Fortran module files 22 | *.mod 23 | *.smod 24 | 25 | # Compiled Static libraries 26 | *.lai 27 | *.la 28 | *.a 29 | *.lib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | 36 | 37 | ### https://raw.github.com/github/gitignore/e313e296c1e284d908adcb95bf4f2812617d4de1/CMake.gitignore 38 | 39 | CMakeLists.txt.user 40 | CMakeCache.txt 41 | CMakeFiles 42 | CMakeScripts 43 | Testing 44 | Makefile 45 | cmake_install.cmake 46 | install_manifest.txt 47 | compile_commands.json 48 | CTestTestfile.cmake 49 | 50 | build/ 51 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(CMAKE_CXX_STANDARD 11) 4 | # ENABLE ADIOS2_ROOT 5 | if(POLICY CMP0074) 6 | cmake_policy(SET CMP0074 NEW) 7 | endif() 8 | 9 | project(gray-scott C CXX) 10 | 11 | find_package(MPI REQUIRED) 12 | find_package(ADIOS2 REQUIRED) 13 | 14 | option(USE_TIMERS "Use profiling timers") 15 | if(USE_TIMERS) 16 | message(STATUS "Enabling profiling timers") 17 | add_definitions(-DENABLE_TIMERS) 18 | endif() 19 | 20 | # We are not using the C++ API of MPI, this will stop the compiler look for it 21 | add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) 22 | 23 | add_executable(gray-scott 24 | simulation/main.cpp 25 | simulation/gray-scott.cpp 26 | simulation/settings.cpp 27 | simulation/writer.cpp 28 | ) 29 | target_link_libraries(gray-scott adios2::adios2 MPI::MPI_C) 30 | 31 | add_executable(pdf_calc analysis/pdf_calc.cpp) 32 | target_link_libraries(pdf_calc adios2::adios2 MPI::MPI_C) 33 | 34 | option(VTK "Build VTK apps") 35 | if (VTK_ROOT) 36 | set(VTK ON) 37 | endif(VTK_ROOT) 38 | 39 | if (VTK) 40 | message(STATUS "Configuring VTK apps") 41 | 42 | find_package(VTK COMPONENTS 43 | vtkFiltersCore 44 | vtkIOImage 45 | vtkIOXML 46 | ) 47 | 48 | if(VTK_FOUND) 49 | add_executable(isosurface analysis/isosurface.cpp) 50 | target_link_libraries(isosurface adios2::adios2 ${VTK_LIBRARIES} 51 | MPI::MPI_C) 52 | endif(VTK_FOUND) 53 | 54 | find_package(VTK COMPONENTS 55 | vtkFiltersCore 56 | vtkFiltersGeometry 57 | ) 58 | 59 | if(VTK_FOUND) 60 | add_executable(find_blobs analysis/find_blobs.cpp) 61 | target_link_libraries(find_blobs adios2::adios2 ${VTK_LIBRARIES} 62 | MPI::MPI_C) 63 | endif(VTK_FOUND) 64 | 65 | find_package(VTK COMPONENTS 66 | vtkFiltersGeneral 67 | ) 68 | 69 | if(VTK_FOUND) 70 | add_executable(compute_curvature analysis/curvature.cpp) 71 | target_link_libraries(compute_curvature adios2::adios2 ${VTK_LIBRARIES} 72 | MPI::MPI_C) 73 | endif(VTK_FOUND) 74 | 75 | 76 | find_package(VTK COMPONENTS 77 | vtkRenderingOpenGL2 78 | vtkViewsInfovis 79 | ) 80 | 81 | if(VTK_FOUND) 82 | add_executable(render_isosurface plot/render_isosurface.cpp) 83 | target_link_libraries(render_isosurface adios2::adios2 ${VTK_LIBRARIES} 84 | MPI::MPI_C) 85 | endif(VTK_FOUND) 86 | endif(VTK) 87 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Cmds: help data code all 4 | cmd=${1:-help} 5 | 6 | fail=yes 7 | 8 | if [ "x$cmd" == "xcode" -o "x$cmd" == "xall" ]; then 9 | echo "== cleanup code in build/" 10 | cd build 11 | make clean 12 | cd - 13 | fail=no 14 | fi 15 | if [ "x$cmd" == "xdata" -o "x$cmd" == "xall" ]; then 16 | echo "== cleanup data" 17 | rm -rf *.bp *.bp.dir *.h5 18 | rm -rf *.sst *.ssc *_insitumpi_* 19 | rm -rf *.png *.pnm *.jpg 20 | rm -rf *.log 21 | fail=no 22 | fi 23 | 24 | 25 | if [ "x$cmd" == "xhelp" -o "x$cmd" == "xh" -o "$fail" == "yes" ]; then 26 | echo "./cleanup.sh [ data | code | all ]" 27 | fi 28 | 29 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/common/timer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __TIMER_HPP__ 2 | #define __TIMER_HPP__ 3 | 4 | #include 5 | 6 | class Timer 7 | { 8 | private: 9 | bool _is_running; 10 | std::chrono::steady_clock::time_point _start; 11 | std::chrono::steady_clock::duration _total; 12 | 13 | double _to_millis(std::chrono::steady_clock::duration duration) const 14 | { 15 | std::chrono::duration duration_ms(duration); 16 | return duration_ms.count(); 17 | } 18 | 19 | public: 20 | Timer() 21 | : _is_running(false), _total(std::chrono::steady_clock::duration::zero()) 22 | { 23 | } 24 | 25 | void start() 26 | { 27 | _is_running = true; 28 | _start = std::chrono::steady_clock::now(); 29 | } 30 | 31 | double stop() 32 | { 33 | _is_running = false; 34 | 35 | const auto elapsed = std::chrono::steady_clock::now() - _start; 36 | 37 | _total += elapsed; 38 | 39 | return _to_millis(elapsed); 40 | } 41 | 42 | void reset() 43 | { 44 | _is_running = false; 45 | _total = std::chrono::steady_clock::duration::zero(); 46 | } 47 | 48 | bool is_running() const { return _is_running; } 49 | 50 | double elapsed() const { return _to_millis(_total); } 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/img/example1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gray-scott/img/example1.jpg -------------------------------------------------------------------------------- /Tutorial/gray-scott/img/example2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gray-scott/img/example2.jpg -------------------------------------------------------------------------------- /Tutorial/gray-scott/img/example3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gray-scott/img/example3.jpg -------------------------------------------------------------------------------- /Tutorial/gray-scott/img/example4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gray-scott/img/example4.jpg -------------------------------------------------------------------------------- /Tutorial/gray-scott/img/example5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gray-scott/img/example5.jpg -------------------------------------------------------------------------------- /Tutorial/gray-scott/simulation/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Keichi Takahashi 2 | Copyright (c) 2018 Hiroshi Watanabe 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/simulation/settings-files.json: -------------------------------------------------------------------------------- 1 | { 2 | "L": 64, 3 | "Du": 0.2, 4 | "Dv": 0.1, 5 | "F": 0.01, 6 | "k": 0.05, 7 | "dt": 2.0, 8 | "plotgap": 10, 9 | "steps": 1000, 10 | "noise": 0.0000001, 11 | "output": "gs.bp", 12 | "checkpoint": false, 13 | "checkpoint_freq": 10, 14 | "checkpoint_output": "gs_ckpt.bp", 15 | "adios_config": "adios2.xml", 16 | "adios_span": false, 17 | "adios_memory_selection": true, 18 | "mesh_type": "image" 19 | } 20 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/simulation/settings-staging.json: -------------------------------------------------------------------------------- 1 | { 2 | "L": 64, 3 | "Du": 0.2, 4 | "Dv": 0.1, 5 | "F": 0.01, 6 | "k": 0.05, 7 | "dt": 2.0, 8 | "plotgap": 10, 9 | "steps": 60000, 10 | "noise": 0.0000001, 11 | "output": "gs.bp", 12 | "checkpoint": false, 13 | "checkpoint_freq": 10, 14 | "checkpoint_output": "gs_ckpt.bp", 15 | "adios_config": "adios2.xml", 16 | "adios_span": false, 17 | "adios_memory_selection": true, 18 | "mesh_type": "image" 19 | } 20 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/simulation/settings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "json.hpp" 4 | #include "settings.h" 5 | 6 | void to_json(nlohmann::json &j, const Settings &s) 7 | { 8 | j = nlohmann::json{{"L", s.L}, 9 | {"steps", s.steps}, 10 | {"plotgap", s.plotgap}, 11 | {"F", s.F}, 12 | {"k", s.k}, 13 | {"dt", s.dt}, 14 | {"Du", s.Du}, 15 | {"Dv", s.Dv}, 16 | {"noise", s.noise}, 17 | {"output", s.output}, 18 | {"checkpoint", s.checkpoint}, 19 | {"checkpoint_freq", s.checkpoint_freq}, 20 | {"checkpoint_output", s.checkpoint_output}, 21 | {"adios_config", s.adios_config}, 22 | {"adios_span", s.adios_span}, 23 | {"adios_memory_selection", s.adios_memory_selection}, 24 | {"mesh_type", s.mesh_type}}; 25 | } 26 | 27 | void from_json(const nlohmann::json &j, Settings &s) 28 | { 29 | j.at("L").get_to(s.L); 30 | j.at("steps").get_to(s.steps); 31 | j.at("plotgap").get_to(s.plotgap); 32 | j.at("F").get_to(s.F); 33 | j.at("k").get_to(s.k); 34 | j.at("dt").get_to(s.dt); 35 | j.at("Du").get_to(s.Du); 36 | j.at("Dv").get_to(s.Dv); 37 | j.at("noise").get_to(s.noise); 38 | j.at("output").get_to(s.output); 39 | j.at("checkpoint").get_to(s.checkpoint); 40 | j.at("checkpoint_freq").get_to(s.checkpoint_freq); 41 | j.at("checkpoint_output").get_to(s.checkpoint_output); 42 | j.at("adios_config").get_to(s.adios_config); 43 | j.at("adios_span").get_to(s.adios_span); 44 | j.at("adios_memory_selection").get_to(s.adios_memory_selection); 45 | j.at("mesh_type").get_to(s.mesh_type); 46 | } 47 | 48 | Settings::Settings() 49 | { 50 | L = 128; 51 | steps = 20000; 52 | plotgap = 200; 53 | F = 0.04; 54 | k = 0.06075; 55 | dt = 0.2; 56 | Du = 0.05; 57 | Dv = 0.1; 58 | noise = 0.0; 59 | output = "foo.bp"; 60 | checkpoint = false; 61 | checkpoint_freq = 2000; 62 | checkpoint_output = "gs_ckpt.bp"; 63 | adios_config = "adios2.xml"; 64 | adios_span = false; 65 | adios_memory_selection = false; 66 | mesh_type = "image"; 67 | } 68 | 69 | Settings Settings::from_json(const std::string &fname) 70 | { 71 | std::ifstream ifs(fname); 72 | nlohmann::json j; 73 | 74 | ifs >> j; 75 | 76 | return j.get(); 77 | } 78 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/simulation/settings.h: -------------------------------------------------------------------------------- 1 | #ifndef __SETTINGS_H__ 2 | #define __SETTINGS_H__ 3 | 4 | #include 5 | 6 | struct Settings 7 | { 8 | size_t L; 9 | int steps; 10 | int plotgap; 11 | double F; 12 | double k; 13 | double dt; 14 | double Du; 15 | double Dv; 16 | double noise; 17 | std::string output; 18 | bool checkpoint; 19 | int checkpoint_freq; 20 | std::string checkpoint_output; 21 | std::string adios_config; 22 | bool adios_span; 23 | bool adios_memory_selection; 24 | std::string mesh_type; 25 | 26 | Settings(); 27 | static Settings from_json(const std::string &fname); 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/simulation/writer.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRITER_H__ 2 | #define __WRITER_H__ 3 | 4 | #include 5 | #include 6 | 7 | #include "gray-scott.h" 8 | #include "settings.h" 9 | 10 | class Writer 11 | { 12 | public: 13 | Writer(const Settings &settings, const GrayScott &sim, adios2::IO io); 14 | void open(const std::string &fname); 15 | void write(int step, const GrayScott &sim); 16 | void close(); 17 | 18 | protected: 19 | Settings settings; 20 | 21 | adios2::IO io; 22 | adios2::Engine writer; 23 | adios2::Variable var_u; 24 | adios2::Variable var_v; 25 | adios2::Variable var_step; 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/visit-bp4.session.gui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 3.0.0b 4 | 5 | 6 | gs.bp 7 | * 8 | true 9 | true 10 | true 11 | false 12 | 13 | "gs.bp" 14 | 15 | 16 | 17 | true 18 | #c0c0c0 19 | #000000 20 | Helvetica,12,-1,5,50,0,0,0,0,0 21 | gtk 22 | 0 23 | #000000 24 | #efefef 25 | "Sans Serif,9,-1,5,50,0,0,0,0,0" 26 | Fusion 27 | 0 28 | 29 | false 30 | 31 | 4 32 | 52 33 | 398 34 | 2104 35 | 0 0.544259 0.4537178 36 | 37 | 38 | 2742 39 | 916 40 | 498 41 | 832 42 | false 43 | false 44 | 45 | "localhost:gs.bp/md.0" 46 | 47 | Cycles 48 | 5 49 | 50 | false 51 | true 52 | true 53 | 54 | 55 | -------------------------------------------------------------------------------- /Tutorial/gray-scott/visit-sst.session.gui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 3.0.0b 4 | 5 | 6 | /home/adios/Tutorial/share 7 | * 8 | true 9 | true 10 | true 11 | false 12 | 13 | "/home/adios/Tutorial/share" 14 | 15 | 16 | 17 | true 18 | #c0c0c0 19 | #000000 20 | Helvetica,12,-1,5,50,0,0,0,0,0 21 | gtk 22 | 0 23 | #000000 24 | #efefef 25 | "Sans Serif,9,-1,5,50,0,0,0,0,0" 26 | Fusion 27 | 0 28 | 29 | false 30 | 31 | 4 32 | 52 33 | 398 34 | 2104 35 | 0 0.544259 0.4537178 36 | 37 | 38 | 2378 39 | 1078 40 | 498 41 | 832 42 | false 43 | false 44 | 45 | "localhost:gs.bp.sst" 46 | 47 | Cycles 48 | 5 49 | 50 | false 51 | true 52 | true 53 | 54 | 55 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: LLVM 3 | BreakBeforeBraces: Custom 4 | ConstructorInitializerIndentWidth: 0 5 | IndentWidth: 4 6 | ContinuationIndentWidth: 4 7 | AccessModifierOffset: -4 8 | AlwaysBreakTemplateDeclarations: true 9 | CompactNamespaces: false 10 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 11 | FixNamespaceComments: false 12 | Standard: Cpp11 13 | ColumnLimit: 80 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AlignEscapedNewlines: Right 16 | AlignAfterOpenBracket: Align 17 | SortUsingDeclarations: false 18 | BraceWrapping: 19 | AfterClass: true 20 | AfterControlStatement: true 21 | AfterEnum: true 22 | AfterExternBlock: false 23 | AfterFunction: true 24 | AfterNamespace: true 25 | AfterStruct: true 26 | AfterUnion: true 27 | BeforeCatch: true 28 | BeforeElse: true 29 | SplitEmptyFunction: true 30 | SplitEmptyRecord: true 31 | SplitEmptyNamespace: false 32 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/e313e296c1e284d908adcb95bf4f2812617d4de1/C++.gitignore 2 | 3 | # Prerequisites 4 | *.d 5 | 6 | # Compiled Object files 7 | *.slo 8 | *.lo 9 | *.o 10 | *.obj 11 | 12 | # Precompiled Headers 13 | *.gch 14 | *.pch 15 | 16 | # Compiled Dynamic libraries 17 | *.so 18 | *.dylib 19 | *.dll 20 | 21 | # Fortran module files 22 | *.mod 23 | *.smod 24 | 25 | # Compiled Static libraries 26 | *.lai 27 | *.la 28 | *.a 29 | *.lib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | 36 | 37 | ### https://raw.github.com/github/gitignore/e313e296c1e284d908adcb95bf4f2812617d4de1/CMake.gitignore 38 | 39 | CMakeLists.txt.user 40 | CMakeCache.txt 41 | CMakeFiles 42 | CMakeScripts 43 | Testing 44 | Makefile 45 | cmake_install.cmake 46 | install_manifest.txt 47 | compile_commands.json 48 | CTestTestfile.cmake 49 | 50 | build/ 51 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "/opt/adios2/include", 8 | "/usr/include/x86_64-linux-gnu/mpi" 9 | ], 10 | "defines": [ 11 | "ENABLE_TIMERS", 12 | "ADIOS2_USE_MPI=1" 13 | ], 14 | "compilerPath": "/usr/bin/gcc", 15 | "cStandard": "gnu17", 16 | "cppStandard": "gnu++14", 17 | "intelliSenseMode": "gcc-x64", 18 | "configurationProvider": "ms-vscode.cmake-tools" 19 | } 20 | ], 21 | "version": 4 22 | } 23 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.includePath": [${default}], 3 | "cmake.configureOnOpen": false, 4 | "clang-format.executable": "/home/adios/bin/clang-format", 5 | "editor.formatOnSave": true, 6 | } -------------------------------------------------------------------------------- /Tutorial/gs-adios2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(CMAKE_CXX_STANDARD 11) 4 | if(POLICY CMP0074) 5 | cmake_policy(SET CMP0074 NEW) 6 | endif() 7 | 8 | project(gray-scott C CXX) 9 | 10 | find_package(MPI REQUIRED) 11 | find_package(ADIOS2 REQUIRED) 12 | 13 | # We are not using the C++ API of MPI, this will stop the compiler look for it 14 | add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) 15 | 16 | add_executable(gray-scott 17 | simulation/main.cpp 18 | simulation/gray-scott.cpp 19 | simulation/settings.cpp 20 | simulation/writer.cpp 21 | ) 22 | target_link_libraries(gray-scott adios2::cxx11_mpi MPI::MPI_C) 23 | 24 | add_executable(pdf-calc analysis/pdf-calc.cpp) 25 | target_link_libraries(pdf-calc adios2::cxx11_mpi MPI::MPI_C) 26 | 27 | 28 | # 29 | # Install commands 30 | # 31 | install(TARGETS gray-scott 32 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) 33 | install(TARGETS pdf-calc 34 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) 35 | 36 | install(FILES "adios2.xml" 37 | "simulation/settings-files.json" 38 | "simulation/settings-staging.json" 39 | "plot/decomp.py" "plot/gsplot.py" "plot/pdfplot.py" 40 | "README.md" 41 | DESTINATION ${CMAKE_INSTALL_PREFIX}) 42 | 43 | 44 | install(PROGRAMS "cleanup.sh" 45 | DESTINATION ${CMAKE_INSTALL_PREFIX}) 46 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Cmds: help data code all 4 | cmd=${1:-help} 5 | 6 | fail=yes 7 | 8 | if [ "x$cmd" == "xcode" -o "x$cmd" == "xall" ]; then 9 | echo "== cleanup code in build/" 10 | cd build 11 | make clean 12 | cd - 13 | fail=no 14 | fi 15 | if [ "x$cmd" == "xdata" -o "x$cmd" == "xall" ]; then 16 | echo "== cleanup data" 17 | rm -rf *.bp *.bp.dir *.h5 18 | rm -rf *.sst *.ssc *_insitumpi_* 19 | rm -rf *.png *.pnm *.jpg 20 | rm -rf *.log 21 | fail=no 22 | fi 23 | 24 | 25 | if [ "x$cmd" == "xhelp" -o "x$cmd" == "xh" -o "$fail" == "yes" ]; then 26 | echo "./cleanup.sh [ data | code | all ]" 27 | fi 28 | 29 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/img/example1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-adios2/img/example1.jpg -------------------------------------------------------------------------------- /Tutorial/gs-adios2/img/example2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-adios2/img/example2.jpg -------------------------------------------------------------------------------- /Tutorial/gs-adios2/img/example3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-adios2/img/example3.jpg -------------------------------------------------------------------------------- /Tutorial/gs-adios2/img/example4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-adios2/img/example4.jpg -------------------------------------------------------------------------------- /Tutorial/gs-adios2/img/example5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-adios2/img/example5.jpg -------------------------------------------------------------------------------- /Tutorial/gs-adios2/plot/gsread_mpi.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from __future__ import absolute_import, division, print_function, unicode_literals 3 | import adios2 4 | import argparse 5 | from time import sleep 6 | from mpi4py import MPI 7 | import numpy as np 8 | 9 | def SetupArgs(): 10 | parser = argparse.ArgumentParser() 11 | parser.add_argument("--instream", "-i", help="Name of the input stream", required=True) 12 | parser.add_argument("--varname", "-v", help="Name of variable read", default="U") 13 | args = parser.parse_args() 14 | return args 15 | 16 | def OpenStream(comm_app, streamname): 17 | # ADIOS2 open stream 18 | fr = adios2.open(streamname, "r", comm_app, "adios2.xml", "SimulationOutput") 19 | return fr 20 | 21 | def InquireStep(fr_step, varname, read_step): 22 | # ADIOS2 processing info 23 | cur_step = fr_step.current_step() 24 | vars_info = fr_step.available_variables() 25 | # ### print (vars_info) 26 | 27 | shape3_str = vars_info[args.varname]["Shape"].split(',') 28 | fullshape = list(map(int,shape3_str)) 29 | sim_step = fr_step.read("step") 30 | return fullshape, cur_step, sim_step 31 | 32 | def ReadData(fr_step, varname, rank, read_step): 33 | # ADIOS2 read data 34 | data = fr.read(args.varname, start, count) 35 | return data 36 | 37 | def CloseStream(): 38 | # ADIOS2 close stream 39 | fr.close() 40 | return 41 | 42 | 43 | if __name__ == "__main__": 44 | args = SetupArgs() 45 | 46 | # Setup up communicators if MPI is installed 47 | comm_app = MPI.COMM_WORLD.Split(3, MPI.COMM_WORLD.Get_rank()) 48 | comm_size = comm_app.Get_size() 49 | rank = comm_app.Get_rank() 50 | 51 | fr = OpenStream(comm_app, args.instream) 52 | 53 | # Read through the steps, one at a time 54 | read_step = 0 55 | for fr_step in fr: 56 | 57 | fullshape, cur_step, sim_step = InquireStep(fr_step, args.varname, read_step) 58 | 59 | # 1D decomposition of the 3D array 60 | count1 = int(fullshape[0]/comm_size) 61 | start1 = count1 * rank 62 | if (rank == comm_size - 1): 63 | # last process need to read all the rest of slices 64 | count1 = fullshape[0] - count1 * (comm_size - 1) 65 | start = [ start1, 0, 0] 66 | count = [ count1, fullshape[1], fullshape[2] ] 67 | 68 | if rank == 0: 69 | print("Read step {0} processing simulation output step {1} or computation step {2}".format(read_step,cur_step, sim_step), flush=True) 70 | sleep(0.1) 71 | comm_app.Barrier() 72 | 73 | data = ReadData(fr_step, args.varname, rank, read_step) 74 | 75 | print("step {0} rank {1} data min = {2} max = {3}".format(read_step, rank, data.min(), data.max()), flush=True) 76 | 77 | read_step = read_step + 1 78 | sleep(0.1) 79 | comm_app.Barrier() 80 | 81 | if read_step == 1: 82 | for i in range(0, count1-1): 83 | for j in range(0, fullshape[1]): 84 | print(data[i,j,:]) 85 | break 86 | 87 | CloseStream() 88 | 89 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/simulation/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Keichi Takahashi 2 | Copyright (c) 2018 Hiroshi Watanabe 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/simulation/settings-files.json: -------------------------------------------------------------------------------- 1 | { 2 | "L": 64, 3 | "Du": 0.2, 4 | "Dv": 0.1, 5 | "F": 0.01, 6 | "k": 0.05, 7 | "dt": 2.0, 8 | "plotgap": 10, 9 | "steps": 1000, 10 | "noise": 0.01, 11 | "output": "gs.bp", 12 | "adios_config": "adios2.xml" 13 | } 14 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/simulation/settings-staging.json: -------------------------------------------------------------------------------- 1 | { 2 | "L": 64, 3 | "Du": 0.2, 4 | "Dv": 0.1, 5 | "F": 0.02, 6 | "k": 0.048, 7 | "dt": 2.0, 8 | "plotgap": 10, 9 | "steps": 60000, 10 | "noise": 0.01, 11 | "output": "gs.bp", 12 | "adios_config": "adios2.xml" 13 | } 14 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/simulation/settings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "json.hpp" 4 | #include "settings.h" 5 | 6 | void to_json(nlohmann::json &j, const Settings &s) 7 | { 8 | j = nlohmann::json{ 9 | {"L", s.L}, 10 | {"steps", s.steps}, 11 | {"plotgap", s.plotgap}, 12 | {"F", s.F}, 13 | {"k", s.k}, 14 | {"dt", s.dt}, 15 | {"Du", s.Du}, 16 | {"Dv", s.Dv}, 17 | {"noise", s.noise}, 18 | {"output", s.output}, 19 | {"adios_config", s.adios_config}, 20 | }; 21 | } 22 | 23 | void from_json(const nlohmann::json &j, Settings &s) 24 | { 25 | j.at("L").get_to(s.L); 26 | j.at("steps").get_to(s.steps); 27 | j.at("plotgap").get_to(s.plotgap); 28 | j.at("F").get_to(s.F); 29 | j.at("k").get_to(s.k); 30 | j.at("dt").get_to(s.dt); 31 | j.at("Du").get_to(s.Du); 32 | j.at("Dv").get_to(s.Dv); 33 | j.at("noise").get_to(s.noise); 34 | j.at("output").get_to(s.output); 35 | j.at("adios_config").get_to(s.adios_config); 36 | } 37 | 38 | Settings::Settings() 39 | { 40 | L = 128; 41 | steps = 20000; 42 | plotgap = 200; 43 | F = 0.04; 44 | k = 0.06075; 45 | dt = 0.2; 46 | Du = 0.05; 47 | Dv = 0.1; 48 | noise = 0.0; 49 | output = "foo.bp"; 50 | adios_config = "adios2.xml"; 51 | } 52 | 53 | Settings Settings::from_json(const std::string &fname) 54 | { 55 | std::ifstream ifs(fname); 56 | nlohmann::json j; 57 | 58 | ifs >> j; 59 | 60 | return j.get(); 61 | } 62 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/simulation/settings.h: -------------------------------------------------------------------------------- 1 | #ifndef __SETTINGS_H__ 2 | #define __SETTINGS_H__ 3 | 4 | #include 5 | 6 | struct Settings 7 | { 8 | size_t L; 9 | int steps; 10 | int plotgap; 11 | double F; 12 | double k; 13 | double dt; 14 | double Du; 15 | double Dv; 16 | double noise; 17 | std::string output; 18 | std::string adios_config; 19 | 20 | Settings(); 21 | static Settings from_json(const std::string &fname); 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/simulation/writer.cpp: -------------------------------------------------------------------------------- 1 | #include "writer.h" 2 | 3 | #include 4 | 5 | Writer::Writer(const Settings &settings, const GrayScott &sim, adios2::IO io) 6 | : settings(settings), io(io) 7 | { 8 | io.DefineAttribute("F", settings.F); 9 | io.DefineAttribute("k", settings.k); 10 | io.DefineAttribute("dt", settings.dt); 11 | io.DefineAttribute("Du", settings.Du); 12 | io.DefineAttribute("Dv", settings.Dv); 13 | io.DefineAttribute("noise", settings.noise); 14 | 15 | var_u = 16 | io.DefineVariable("U", {settings.L, settings.L, settings.L}, 17 | {sim.offset_z, sim.offset_y, sim.offset_x}, 18 | {sim.size_z, sim.size_y, sim.size_x}); 19 | 20 | var_v = 21 | io.DefineVariable("V", {settings.L, settings.L, settings.L}, 22 | {sim.offset_z, sim.offset_y, sim.offset_x}, 23 | {sim.size_z, sim.size_y, sim.size_x}); 24 | 25 | var_step = io.DefineVariable("step"); 26 | } 27 | 28 | void Writer::open(const std::string &fname) 29 | { 30 | writer = io.Open(fname, adios2::Mode::Write); 31 | } 32 | 33 | void Writer::write(int step, const GrayScott &sim) 34 | { 35 | const std::vector &u = sim.u_noghost(); 36 | const std::vector &v = sim.v_noghost(); 37 | 38 | writer.BeginStep(); 39 | writer.Put(var_step, &step); 40 | writer.Put(var_u, u.data()); 41 | writer.Put(var_v, v.data()); 42 | writer.EndStep(); 43 | } 44 | 45 | void Writer::close() { writer.Close(); } 46 | 47 | void Writer::print_settings() 48 | { 49 | std::cout << "Simulation writes data using engine type: " 50 | << io.EngineType() << std::endl; 51 | } 52 | -------------------------------------------------------------------------------- /Tutorial/gs-adios2/simulation/writer.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRITER_H__ 2 | #define __WRITER_H__ 3 | 4 | #include 5 | #include 6 | 7 | #include "gray-scott.h" 8 | #include "settings.h" 9 | 10 | class Writer 11 | { 12 | public: 13 | Writer(const Settings &settings, const GrayScott &sim, adios2::IO io); 14 | void open(const std::string &fname); 15 | void write(int step, const GrayScott &sim); 16 | void close(); 17 | 18 | void print_settings(); 19 | 20 | protected: 21 | const Settings &settings; 22 | 23 | adios2::IO io; 24 | adios2::Engine writer; 25 | adios2::Variable var_u; 26 | adios2::Variable var_v; 27 | adios2::Variable var_step; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: LLVM 3 | BreakBeforeBraces: Custom 4 | ConstructorInitializerIndentWidth: 0 5 | IndentWidth: 4 6 | ContinuationIndentWidth: 4 7 | AccessModifierOffset: -4 8 | AlwaysBreakTemplateDeclarations: true 9 | CompactNamespaces: false 10 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 11 | FixNamespaceComments: false 12 | Standard: Cpp11 13 | ColumnLimit: 80 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AlignEscapedNewlines: Right 16 | AlignAfterOpenBracket: Align 17 | SortUsingDeclarations: false 18 | BraceWrapping: 19 | AfterClass: true 20 | AfterControlStatement: true 21 | AfterEnum: true 22 | AfterExternBlock: false 23 | AfterFunction: true 24 | AfterNamespace: true 25 | AfterStruct: true 26 | AfterUnion: true 27 | BeforeCatch: true 28 | BeforeElse: true 29 | SplitEmptyFunction: true 30 | SplitEmptyRecord: true 31 | SplitEmptyNamespace: false 32 | -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/e313e296c1e284d908adcb95bf4f2812617d4de1/C++.gitignore 2 | 3 | # Prerequisites 4 | *.d 5 | 6 | # Compiled Object files 7 | *.slo 8 | *.lo 9 | *.o 10 | *.obj 11 | 12 | # Precompiled Headers 13 | *.gch 14 | *.pch 15 | 16 | # Compiled Dynamic libraries 17 | *.so 18 | *.dylib 19 | *.dll 20 | 21 | # Fortran module files 22 | *.mod 23 | *.smod 24 | 25 | # Compiled Static libraries 26 | *.lai 27 | *.la 28 | *.a 29 | *.lib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | 36 | 37 | ### https://raw.github.com/github/gitignore/e313e296c1e284d908adcb95bf4f2812617d4de1/CMake.gitignore 38 | 39 | CMakeLists.txt.user 40 | CMakeCache.txt 41 | CMakeFiles 42 | CMakeScripts 43 | Testing 44 | Makefile 45 | cmake_install.cmake 46 | install_manifest.txt 47 | compile_commands.json 48 | CTestTestfile.cmake 49 | 50 | build/ 51 | -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "/opt/adios2/include", 8 | "/usr/include/x86_64-linux-gnu/mpi" 9 | ], 10 | "defines": [ 11 | "ENABLE_TIMERS", 12 | "ADIOS2_USE_MPI=1" 13 | ], 14 | "compilerPath": "/usr/bin/gcc", 15 | "cStandard": "gnu17", 16 | "cppStandard": "gnu++14", 17 | "intelliSenseMode": "gcc-x64", 18 | "configurationProvider": "ms-vscode.cmake-tools" 19 | } 20 | ], 21 | "version": 4 22 | } 23 | -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.includePath": [${default}], 3 | "cmake.configureOnOpen": false, 4 | "clang-format.executable": "/home/adios/bin/clang-format", 5 | "editor.formatOnSave": true, 6 | } -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(CMAKE_CXX_STANDARD 11) 4 | if(POLICY CMP0074) 5 | cmake_policy(SET CMP0074 NEW) 6 | endif() 7 | 8 | project(gray-scott C CXX) 9 | 10 | find_package(MPI REQUIRED) 11 | # #IO# look for ADIOS2 12 | find_package(ADIOS2 REQUIRED) 13 | 14 | # We are not using the C++ API of MPI, this will stop the compiler look for it 15 | add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) 16 | 17 | add_executable(gray-scott 18 | simulation/main.cpp 19 | simulation/gray-scott.cpp 20 | simulation/settings.cpp 21 | simulation/writer.cpp 22 | ) 23 | # #IO# add link dependency adios2::cxx11_mpi 24 | target_link_libraries(gray-scott adios2::cxx11_mpi MPI::MPI_C) 25 | 26 | add_executable(pdf-calc analysis/pdf-calc.cpp) 27 | # #IO# add link dependency adios2::cxx11_mpi 28 | target_link_libraries(pdf-calc adios2::cxx11_mpi MPI::MPI_C) 29 | 30 | 31 | # 32 | # Install commands 33 | # 34 | install(TARGETS gray-scott 35 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) 36 | install(TARGETS pdf-calc 37 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) 38 | 39 | install(FILES "adios2.xml" 40 | "simulation/settings-files.json" 41 | "plot/gsplot.py" 42 | "README.md" 43 | DESTINATION ${CMAKE_INSTALL_PREFIX}) 44 | 45 | 46 | install(PROGRAMS "cleanup.sh" 47 | DESTINATION ${CMAKE_INSTALL_PREFIX}) 48 | -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/README.md: -------------------------------------------------------------------------------- 1 | # gray-scott with MPI-IO 2 | 3 | This is a 3D 7-point stencil code to simulate the following [Gray-Scott 4 | reaction diffusion model](https://doi.org/10.1126/science.261.5118.189): 5 | 6 | ``` 7 | u_t = Du * (u_xx + u_yy + u_zz) - u * v^2 + F * (1 - u) 8 | v_t = Dv * (v_xx + v_yy + v_zz) + u * v^2 - (F + k) * v 9 | ``` 10 | 11 | ## How to build 12 | 13 | Make sure MPI is installed 14 | 15 | ``` 16 | $ mkdir build 17 | $ cd build 18 | $ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. 19 | $ make 20 | $ cd .. 21 | ``` 22 | 23 | ## How to run 24 | 25 | ``` 26 | $ mpirun -n 4 build/gray-scott simulation/settings-files.json 27 | ======================================== 28 | grid: 64x64x64 29 | steps: 1000 30 | plotgap: 10 31 | F: 0.01 32 | k: 0.05 33 | dt: 2 34 | Du: 0.2 35 | Dv: 0.1 36 | noise: 1e-07 37 | output: data 38 | adios_config: adios2.xml 39 | process layout: 2x2x1 40 | local grid size: 32x32x64 41 | ======================================== 42 | Simulation at step 10 writing output step 1 43 | Simulation at step 20 writing output step 2 44 | Simulation at step 30 writing output step 3 45 | Simulation at step 40 writing output step 4 46 | ... 47 | 48 | 49 | $ python3 plot/gsplot.py -i data.u 50 | 51 | ``` 52 | 53 | ## Analysis example how to run 54 | 55 | ``` 56 | $ mpirun -n 4 build/gray-scott simulation/settings-files.json 57 | $ mpirun -n 2 build/pdf-calc data.u data 100 58 | $ ls -l data* 59 | 60 | ``` 61 | 62 | ## How to change the parameters 63 | 64 | Edit settings.json to change the parameters for the simulation. 65 | 66 | | Key | Description | 67 | | ------------- | ------------------------------------- | 68 | | L | Size of global array (L x L x L cube) | 69 | | Du | Diffusion coefficient of U | 70 | | Dv | Diffusion coefficient of V | 71 | | F | Feed rate of U | 72 | | k | Kill rate of V | 73 | | dt | Timestep | 74 | | steps | Total number of steps to simulate | 75 | | plotgap | Number of steps between output | 76 | | noise | Amount of noise to inject | 77 | | output | Output file/stream name | 78 | | adios_config | ADIOS2 XML file name | 79 | 80 | Decomposition is automatically determined by MPI_Dims_create. 81 | 82 | ## Examples 83 | 84 | | D_u | D_v | F | k | Output 85 | | ----|-----|------|------- | -------------------------- | 86 | | 0.2 | 0.1 | 0.02 | 0.048 | ![](img/example1.jpg?raw=true) | 87 | | 0.2 | 0.1 | 0.03 | 0.0545 | ![](img/example2.jpg?raw=true) | 88 | | 0.2 | 0.1 | 0.03 | 0.06 | ![](img/example3.jpg?raw=true) | 89 | | 0.2 | 0.1 | 0.01 | 0.05 | ![](img/example4.jpg?raw=true) | 90 | | 0.2 | 0.1 | 0.02 | 0.06 | ![](img/example5.jpg?raw=true) | 91 | 92 | 93 | -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Cmds: help data code all 4 | cmd=${1:-help} 5 | 6 | fail=yes 7 | 8 | if [ "x$cmd" == "xcode" -o "x$cmd" == "xall" ]; then 9 | echo "== cleanup code in build/" 10 | cd build 11 | make clean 12 | cd - 13 | fail=no 14 | fi 15 | if [ "x$cmd" == "xdata" -o "x$cmd" == "xall" ]; then 16 | echo "== cleanup data" 17 | rm -rf *.bp *.bp.dir *.h5 18 | rm -rf *.sst *.ssc *_insitumpi_* 19 | rm -rf *.png *.pnm *.jpg 20 | rm -rf *.log 21 | rm -rf data data.* 22 | fail=no 23 | fi 24 | 25 | 26 | if [ "x$cmd" == "xhelp" -o "x$cmd" == "xh" -o "$fail" == "yes" ]; then 27 | echo "./cleanup.sh [ data | code | all ]" 28 | fi 29 | 30 | -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/img/example1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-mpiio/img/example1.jpg -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/img/example2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-mpiio/img/example2.jpg -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/img/example3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-mpiio/img/example3.jpg -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/img/example4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-mpiio/img/example4.jpg -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/img/example5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-mpiio/img/example5.jpg -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/simulation/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Keichi Takahashi 2 | Copyright (c) 2018 Hiroshi Watanabe 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/simulation/settings-files.json: -------------------------------------------------------------------------------- 1 | { 2 | "L": 64, 3 | "Du": 0.2, 4 | "Dv": 0.1, 5 | "F": 0.01, 6 | "k": 0.05, 7 | "dt": 2.0, 8 | "plotgap": 10, 9 | "steps": 1000, 10 | "noise": 0.01, 11 | "output": "data", 12 | "adios_config": "adios2.xml" 13 | } 14 | -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/simulation/settings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "json.hpp" 4 | #include "settings.h" 5 | 6 | void to_json(nlohmann::json &j, const Settings &s) 7 | { 8 | j = nlohmann::json{ 9 | {"L", s.L}, 10 | {"steps", s.steps}, 11 | {"plotgap", s.plotgap}, 12 | {"F", s.F}, 13 | {"k", s.k}, 14 | {"dt", s.dt}, 15 | {"Du", s.Du}, 16 | {"Dv", s.Dv}, 17 | {"noise", s.noise}, 18 | {"output", s.output}, 19 | {"adios_config", s.adios_config}, 20 | }; 21 | } 22 | 23 | void from_json(const nlohmann::json &j, Settings &s) 24 | { 25 | j.at("L").get_to(s.L); 26 | j.at("steps").get_to(s.steps); 27 | j.at("plotgap").get_to(s.plotgap); 28 | j.at("F").get_to(s.F); 29 | j.at("k").get_to(s.k); 30 | j.at("dt").get_to(s.dt); 31 | j.at("Du").get_to(s.Du); 32 | j.at("Dv").get_to(s.Dv); 33 | j.at("noise").get_to(s.noise); 34 | j.at("output").get_to(s.output); 35 | j.at("adios_config").get_to(s.adios_config); 36 | } 37 | 38 | Settings::Settings() 39 | { 40 | L = 128; 41 | steps = 20000; 42 | plotgap = 200; 43 | F = 0.04; 44 | k = 0.06075; 45 | dt = 0.2; 46 | Du = 0.05; 47 | Dv = 0.1; 48 | noise = 0.0; 49 | output = "foo.bp"; 50 | adios_config = "adios2.xml"; 51 | } 52 | 53 | Settings Settings::from_json(const std::string &fname) 54 | { 55 | std::ifstream ifs(fname); 56 | nlohmann::json j; 57 | 58 | ifs >> j; 59 | 60 | return j.get(); 61 | } 62 | -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/simulation/settings.h: -------------------------------------------------------------------------------- 1 | #ifndef __SETTINGS_H__ 2 | #define __SETTINGS_H__ 3 | 4 | #include 5 | 6 | struct Settings 7 | { 8 | size_t L; 9 | int steps; 10 | int plotgap; 11 | double F; 12 | double k; 13 | double dt; 14 | double Du; 15 | double Dv; 16 | double noise; 17 | std::string output; 18 | std::string adios_config; 19 | 20 | Settings(); 21 | static Settings from_json(const std::string &fname); 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Tutorial/gs-mpiio/simulation/writer.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRITER_H__ 2 | #define __WRITER_H__ 3 | 4 | // #IO# include IO library 5 | #include 6 | 7 | #include "gray-scott.h" 8 | #include "settings.h" 9 | 10 | class Writer 11 | { 12 | public: 13 | Writer(const Settings &settings, const GrayScott &sim, const MPI_Comm comm); 14 | void open(const std::string &fname); 15 | void write(int step, const GrayScott &sim); 16 | void close(); 17 | 18 | void print_settings(); 19 | 20 | protected: 21 | const Settings &settings; 22 | MPI_Comm comm; 23 | int nproc, rank; 24 | int err, cmode; 25 | MPI_File fh; 26 | MPI_Datatype filetype; 27 | 28 | struct header 29 | { 30 | // original coder used z as slowest dim, x as fastest!!! 31 | unsigned long long z; 32 | unsigned long long y; 33 | unsigned long long x; 34 | }; 35 | 36 | // #IO# declare ADIOS variables for engine, io, variables 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Tutorial/gs-noio/.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: LLVM 3 | BreakBeforeBraces: Custom 4 | ConstructorInitializerIndentWidth: 0 5 | IndentWidth: 4 6 | ContinuationIndentWidth: 4 7 | AccessModifierOffset: -4 8 | AlwaysBreakTemplateDeclarations: true 9 | CompactNamespaces: false 10 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 11 | FixNamespaceComments: false 12 | Standard: Cpp11 13 | ColumnLimit: 80 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AlignEscapedNewlines: Right 16 | AlignAfterOpenBracket: Align 17 | SortUsingDeclarations: false 18 | BraceWrapping: 19 | AfterClass: true 20 | AfterControlStatement: true 21 | AfterEnum: true 22 | AfterExternBlock: false 23 | AfterFunction: true 24 | AfterNamespace: true 25 | AfterStruct: true 26 | AfterUnion: true 27 | BeforeCatch: true 28 | BeforeElse: true 29 | SplitEmptyFunction: true 30 | SplitEmptyRecord: true 31 | SplitEmptyNamespace: false 32 | -------------------------------------------------------------------------------- /Tutorial/gs-noio/.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/e313e296c1e284d908adcb95bf4f2812617d4de1/C++.gitignore 2 | 3 | # Prerequisites 4 | *.d 5 | 6 | # Compiled Object files 7 | *.slo 8 | *.lo 9 | *.o 10 | *.obj 11 | 12 | # Precompiled Headers 13 | *.gch 14 | *.pch 15 | 16 | # Compiled Dynamic libraries 17 | *.so 18 | *.dylib 19 | *.dll 20 | 21 | # Fortran module files 22 | *.mod 23 | *.smod 24 | 25 | # Compiled Static libraries 26 | *.lai 27 | *.la 28 | *.a 29 | *.lib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | 36 | 37 | ### https://raw.github.com/github/gitignore/e313e296c1e284d908adcb95bf4f2812617d4de1/CMake.gitignore 38 | 39 | CMakeLists.txt.user 40 | CMakeCache.txt 41 | CMakeFiles 42 | CMakeScripts 43 | Testing 44 | Makefile 45 | cmake_install.cmake 46 | install_manifest.txt 47 | compile_commands.json 48 | CTestTestfile.cmake 49 | 50 | build/ 51 | -------------------------------------------------------------------------------- /Tutorial/gs-noio/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "/opt/adios2/include", 8 | "/usr/include/x86_64-linux-gnu/mpi" 9 | ], 10 | "defines": [ 11 | "ENABLE_TIMERS" 12 | ], 13 | "compilerPath": "/usr/bin/gcc", 14 | "cStandard": "gnu17", 15 | "cppStandard": "gnu++14", 16 | "intelliSenseMode": "gcc-x64", 17 | "configurationProvider": "ms-vscode.cmake-tools" 18 | } 19 | ], 20 | "version": 4 21 | } -------------------------------------------------------------------------------- /Tutorial/gs-noio/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.includePath": [${default}], 3 | "cmake.configureOnOpen": false, 4 | "clang-format.executable": "/home/adios/bin/clang-format", 5 | "editor.formatOnSave": true, 6 | } -------------------------------------------------------------------------------- /Tutorial/gs-noio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(CMAKE_CXX_STANDARD 11) 4 | if(POLICY CMP0074) 5 | cmake_policy(SET CMP0074 NEW) 6 | endif() 7 | 8 | project(gray-scott C CXX) 9 | 10 | find_package(MPI REQUIRED) 11 | 12 | 13 | # We are not using the C++ API of MPI, this will stop the compiler look for it 14 | add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) 15 | 16 | add_executable(gray-scott 17 | simulation/main.cpp 18 | simulation/gray-scott.cpp 19 | simulation/settings.cpp 20 | simulation/writer.cpp 21 | ) 22 | target_link_libraries(gray-scott MPI::MPI_C) 23 | 24 | add_executable(pdf-calc analysis/pdf-calc.cpp) 25 | target_link_libraries(pdf-calc MPI::MPI_C) 26 | 27 | # 28 | # Install commands 29 | # 30 | install(TARGETS gray-scott 31 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) 32 | install(TARGETS pdf-calc 33 | RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) 34 | 35 | install(FILES "adios2.xml" 36 | "simulation/settings-files.json" 37 | "README.md" 38 | DESTINATION ${CMAKE_INSTALL_PREFIX}) 39 | 40 | 41 | install(PROGRAMS "cleanup.sh" 42 | DESTINATION ${CMAKE_INSTALL_PREFIX}) 43 | -------------------------------------------------------------------------------- /Tutorial/gs-noio/README.md: -------------------------------------------------------------------------------- 1 | # gray-scott 2 | 3 | This is a 3D 7-point stencil code to simulate the following [Gray-Scott 4 | reaction diffusion model](https://doi.org/10.1126/science.261.5118.189): 5 | 6 | ``` 7 | u_t = Du * (u_xx + u_yy + u_zz) - u * v^2 + F * (1 - u) 8 | v_t = Dv * (v_xx + v_yy + v_zz) + u * v^2 - (F + k) * v 9 | ``` 10 | 11 | ## How to build 12 | 13 | Make sure MPI is installed 14 | 15 | ``` 16 | $ mkdir build 17 | $ cd build 18 | $ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. 19 | $ make 20 | $ cd .. 21 | ``` 22 | 23 | ## How to run 24 | 25 | ``` 26 | $ mpirun -n 4 build/gray-scott simulation/settings-files.json 27 | ======================================== 28 | grid: 64x64x64 29 | steps: 1000 30 | plotgap: 10 31 | F: 0.01 32 | k: 0.05 33 | dt: 2 34 | Du: 0.2 35 | Dv: 0.1 36 | noise: 1e-07 37 | output: gs.bp 38 | adios_config: adios2.xml 39 | process layout: 2x2x1 40 | local grid size: 32x32x64 41 | ======================================== 42 | Simulation at step 10 writing output step 1 43 | Simulation at step 20 writing output step 2 44 | Simulation at step 30 writing output step 3 45 | Simulation at step 40 writing output step 4 46 | ... 47 | ``` 48 | 49 | ## Analysis example how to run 50 | 51 | ``` 52 | $ mpirun -n 4 build/gray-scott simulation/settings-files.json 53 | $ mpirun -n 2 build/pdf-calc gs.bp pdf.bp 100 54 | ``` 55 | 56 | ## How to change the parameters 57 | 58 | Edit settings.json to change the parameters for the simulation. 59 | 60 | | Key | Description | 61 | | ------------- | ------------------------------------- | 62 | | L | Size of global array (L x L x L cube) | 63 | | Du | Diffusion coefficient of U | 64 | | Dv | Diffusion coefficient of V | 65 | | F | Feed rate of U | 66 | | k | Kill rate of V | 67 | | dt | Timestep | 68 | | steps | Total number of steps to simulate | 69 | | plotgap | Number of steps between output | 70 | | noise | Amount of noise to inject | 71 | | output | Output file/stream name | 72 | | adios_config | ADIOS2 XML file name | 73 | 74 | Decomposition is automatically determined by MPI_Dims_create. 75 | 76 | ## Examples 77 | 78 | | D_u | D_v | F | k | Output 79 | | ----|-----|------|------- | -------------------------- | 80 | | 0.2 | 0.1 | 0.02 | 0.048 | ![](img/example1.jpg?raw=true) | 81 | | 0.2 | 0.1 | 0.03 | 0.0545 | ![](img/example2.jpg?raw=true) | 82 | | 0.2 | 0.1 | 0.03 | 0.06 | ![](img/example3.jpg?raw=true) | 83 | | 0.2 | 0.1 | 0.01 | 0.05 | ![](img/example4.jpg?raw=true) | 84 | | 0.2 | 0.1 | 0.02 | 0.06 | ![](img/example5.jpg?raw=true) | 85 | 86 | 87 | -------------------------------------------------------------------------------- /Tutorial/gs-noio/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Cmds: help data code all 4 | cmd=${1:-help} 5 | 6 | fail=yes 7 | 8 | if [ "x$cmd" == "xcode" -o "x$cmd" == "xall" ]; then 9 | echo "== cleanup code in build/" 10 | cd build 11 | make clean 12 | cd - 13 | fail=no 14 | fi 15 | if [ "x$cmd" == "xdata" -o "x$cmd" == "xall" ]; then 16 | echo "== cleanup data" 17 | rm -rf *.bp *.bp.dir *.h5 18 | rm -rf *.sst *.ssc *_insitumpi_* 19 | rm -rf *.png *.pnm *.jpg 20 | rm -rf *.log 21 | fail=no 22 | fi 23 | 24 | 25 | if [ "x$cmd" == "xhelp" -o "x$cmd" == "xh" -o "$fail" == "yes" ]; then 26 | echo "./cleanup.sh [ data | code | all ]" 27 | fi 28 | 29 | -------------------------------------------------------------------------------- /Tutorial/gs-noio/img/example1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-noio/img/example1.jpg -------------------------------------------------------------------------------- /Tutorial/gs-noio/img/example2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-noio/img/example2.jpg -------------------------------------------------------------------------------- /Tutorial/gs-noio/img/example3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-noio/img/example3.jpg -------------------------------------------------------------------------------- /Tutorial/gs-noio/img/example4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-noio/img/example4.jpg -------------------------------------------------------------------------------- /Tutorial/gs-noio/img/example5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pnorbert/adiosvm/d947a9ae372395b63a94a82ac12ef30f4ce1010a/Tutorial/gs-noio/img/example5.jpg -------------------------------------------------------------------------------- /Tutorial/gs-noio/simulation/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Keichi Takahashi 2 | Copyright (c) 2018 Hiroshi Watanabe 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /Tutorial/gs-noio/simulation/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // #IO# include IO library 7 | #include 8 | 9 | #include "gray-scott.h" 10 | #include "writer.h" 11 | 12 | void print_settings(const Settings &s) 13 | { 14 | std::cout << "grid: " << s.L << "x" << s.L << "x" << s.L 15 | << std::endl; 16 | std::cout << "steps: " << s.steps << std::endl; 17 | std::cout << "plotgap: " << s.plotgap << std::endl; 18 | std::cout << "F: " << s.F << std::endl; 19 | std::cout << "k: " << s.k << std::endl; 20 | std::cout << "dt: " << s.dt << std::endl; 21 | std::cout << "Du: " << s.Du << std::endl; 22 | std::cout << "Dv: " << s.Dv << std::endl; 23 | std::cout << "noise: " << s.noise << std::endl; 24 | std::cout << "output: " << s.output << std::endl; 25 | std::cout << "adios_config: " << s.adios_config << std::endl; 26 | } 27 | 28 | void print_simulator_settings(const GrayScott &s) 29 | { 30 | std::cout << "process layout: " << s.npx << "x" << s.npy << "x" << s.npz 31 | << std::endl; 32 | std::cout << "local grid size: " << s.size_x << "x" << s.size_y << "x" 33 | << s.size_z << std::endl; 34 | } 35 | 36 | int main(int argc, char **argv) 37 | { 38 | MPI_Init(&argc, &argv); 39 | int rank, procs, wrank; 40 | 41 | MPI_Comm_rank(MPI_COMM_WORLD, &wrank); 42 | 43 | const unsigned int color = 1; 44 | MPI_Comm comm; 45 | MPI_Comm_split(MPI_COMM_WORLD, color, wrank, &comm); 46 | 47 | MPI_Comm_rank(comm, &rank); 48 | MPI_Comm_size(comm, &procs); 49 | 50 | if (argc < 2) 51 | { 52 | if (rank == 0) 53 | { 54 | std::cerr << "Too few arguments" << std::endl; 55 | std::cerr << "Usage: gray-scott settings.json" << std::endl; 56 | } 57 | MPI_Abort(MPI_COMM_WORLD, -1); 58 | } 59 | 60 | Settings settings = Settings::from_json(argv[1]); 61 | 62 | GrayScott sim(settings, comm); 63 | sim.init(); 64 | 65 | // #IO# Need to initialize IO library 66 | // 67 | 68 | Writer writer(settings, sim); 69 | 70 | writer.open(settings.output); 71 | 72 | if (rank == 0) 73 | { 74 | writer.print_settings(); 75 | std::cout << "========================================" << std::endl; 76 | print_settings(settings); 77 | print_simulator_settings(sim); 78 | std::cout << "========================================" << std::endl; 79 | } 80 | 81 | for (int i = 0; i < settings.steps;) 82 | { 83 | for (int j = 0; j < settings.plotgap; j++) 84 | { 85 | sim.iterate(); 86 | i++; 87 | } 88 | 89 | if (rank == 0) 90 | { 91 | std::cout << "Simulation at step " << i 92 | << " publishing output step " << i / settings.plotgap 93 | << std::endl; 94 | } 95 | writer.write(i, sim); 96 | } 97 | 98 | writer.close(); 99 | MPI_Finalize(); 100 | } 101 | -------------------------------------------------------------------------------- /Tutorial/gs-noio/simulation/settings-files.json: -------------------------------------------------------------------------------- 1 | { 2 | "L": 64, 3 | "Du": 0.2, 4 | "Dv": 0.1, 5 | "F": 0.01, 6 | "k": 0.05, 7 | "dt": 2.0, 8 | "plotgap": 10, 9 | "steps": 100, 10 | "noise": 0.01, 11 | "output": "gs.bp", 12 | "adios_config": "adios2.xml" 13 | } 14 | -------------------------------------------------------------------------------- /Tutorial/gs-noio/simulation/settings.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "json.hpp" 4 | #include "settings.h" 5 | 6 | void to_json(nlohmann::json &j, const Settings &s) 7 | { 8 | j = nlohmann::json{ 9 | {"L", s.L}, 10 | {"steps", s.steps}, 11 | {"plotgap", s.plotgap}, 12 | {"F", s.F}, 13 | {"k", s.k}, 14 | {"dt", s.dt}, 15 | {"Du", s.Du}, 16 | {"Dv", s.Dv}, 17 | {"noise", s.noise}, 18 | {"output", s.output}, 19 | {"adios_config", s.adios_config}, 20 | }; 21 | } 22 | 23 | void from_json(const nlohmann::json &j, Settings &s) 24 | { 25 | j.at("L").get_to(s.L); 26 | j.at("steps").get_to(s.steps); 27 | j.at("plotgap").get_to(s.plotgap); 28 | j.at("F").get_to(s.F); 29 | j.at("k").get_to(s.k); 30 | j.at("dt").get_to(s.dt); 31 | j.at("Du").get_to(s.Du); 32 | j.at("Dv").get_to(s.Dv); 33 | j.at("noise").get_to(s.noise); 34 | j.at("output").get_to(s.output); 35 | j.at("adios_config").get_to(s.adios_config); 36 | } 37 | 38 | Settings::Settings() 39 | { 40 | L = 128; 41 | steps = 20000; 42 | plotgap = 200; 43 | F = 0.04; 44 | k = 0.06075; 45 | dt = 0.2; 46 | Du = 0.05; 47 | Dv = 0.1; 48 | noise = 0.0; 49 | output = "foo.bp"; 50 | adios_config = "adios2.xml"; 51 | } 52 | 53 | Settings Settings::from_json(const std::string &fname) 54 | { 55 | std::ifstream ifs(fname); 56 | nlohmann::json j; 57 | 58 | ifs >> j; 59 | 60 | return j.get(); 61 | } 62 | -------------------------------------------------------------------------------- /Tutorial/gs-noio/simulation/settings.h: -------------------------------------------------------------------------------- 1 | #ifndef __SETTINGS_H__ 2 | #define __SETTINGS_H__ 3 | 4 | #include 5 | 6 | struct Settings 7 | { 8 | size_t L; 9 | int steps; 10 | int plotgap; 11 | double F; 12 | double k; 13 | double dt; 14 | double Du; 15 | double Dv; 16 | double noise; 17 | std::string output; 18 | std::string adios_config; 19 | 20 | Settings(); 21 | static Settings from_json(const std::string &fname); 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Tutorial/gs-noio/simulation/writer.cpp: -------------------------------------------------------------------------------- 1 | #include "writer.h" 2 | 3 | #include 4 | 5 | Writer::Writer(const Settings &settings, const GrayScott &sim) 6 | : settings(settings) 7 | { 8 | // #IO# make initializations, declarations as necessary 9 | // information from settings 10 | // ("F", settings.F); 11 | // ("k", settings.k); 12 | // ("dt", settings.dt); 13 | // ("Du", settings.Du); 14 | // ("Dv", settings.Dv); 15 | // ("noise", settings.noise); 16 | 17 | // 3D variables 18 | // U, V 19 | // global dimensions: {settings.L, settings.L, settings.L}, 20 | // starting offset: {sim.offset_z, sim.offset_y, sim.offset_x}, 21 | // local block size: {sim.size_z, sim.size_y, sim.size_x} 22 | 23 | // u and v has ghost cells 24 | // local memory block size: {sim.size_z + 2, sim.size_y + 2, sim.size_x + 2} 25 | // output data starts at offset: {1, 1, 1} 26 | 27 | // information: step is a single value 28 | } 29 | 30 | void Writer::open(const std::string &fname) 31 | { 32 | // #IO# Create the output 33 | std::cout << "Create output stream: " << fname << std::endl; 34 | } 35 | 36 | void Writer::write(int step, const GrayScott &sim) 37 | { 38 | // #IO# Write the output in a given step 39 | /* sim.u_ghost() provides access to the U variable as is */ 40 | /* sim.u_noghost() provides a contiguous copy without the ghost cells */ 41 | const std::vector &u = sim.u_ghost(); 42 | const std::vector &v = sim.v_ghost(); 43 | } 44 | 45 | void Writer::close() 46 | { 47 | // #IO# Close the stream 48 | std::cout << "Close output stream: " << std::endl; 49 | } 50 | 51 | void Writer::print_settings() 52 | { 53 | // #IO# Just print information at the beginning about the IO setup 54 | std::cout << "Simulation writes data using engine type: " 55 | << "NONE" << std::endl; 56 | } -------------------------------------------------------------------------------- /Tutorial/gs-noio/simulation/writer.h: -------------------------------------------------------------------------------- 1 | #ifndef __WRITER_H__ 2 | #define __WRITER_H__ 3 | 4 | // #IO# include IO library 5 | #include 6 | 7 | #include "gray-scott.h" 8 | #include "settings.h" 9 | 10 | class Writer 11 | { 12 | public: 13 | Writer(const Settings &settings, const GrayScott &sim); 14 | void open(const std::string &fname); 15 | void write(int step, const GrayScott &sim); 16 | void close(); 17 | 18 | void print_settings(); 19 | 20 | protected: 21 | const Settings &settings; 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/Makefile: -------------------------------------------------------------------------------- 1 | include make.settings 2 | 3 | ## Set ADIOS2_DIR here or before doing make 4 | override ADIOS2_INC=`${ADIOS2_DIR}/bin/adios2-config --cxx-flags` 5 | override ADIOS2_LIB=`${ADIOS2_DIR}/bin/adios2-config --cxx-libs` 6 | #-L/opt/libfabric/1.6.0/lib -lfabric 7 | 8 | default: help 9 | all: heatSimulation heatAnalysis heatVisualization 10 | 11 | 12 | INC=${ADIOS2_INC} 13 | 14 | 15 | help: 16 | @echo "Make targets: " 17 | @echo " all: build the examples " 18 | @echo " clean-code: delete files from the build process" 19 | @echo " clean-data: delete files from running the examples" 20 | @echo " distclean: clean-code and clean-data" 21 | 22 | 23 | %.o : %.cpp 24 | ${CXX} ${CXXFLAGS} -c ${INC} -o $@ $< 25 | 26 | 27 | heatSimulation: simulation/HeatTransfer.o simulation/IO_adios2.o simulation/Settings.o simulation/heatSimulation.o 28 | ${CXX} ${CXXFLAGS} -o heatSimulation $^ ${ADIOS2_LIB} 29 | 30 | 31 | heatAnalysis: analysis/heatAnalysis.o analysis/AnalysisSettings.o 32 | ${CXX} ${CXXFLAGS} -o heatAnalysis $^ ${ADIOS2_LIB} 33 | 34 | 35 | USE_VTKM_FLAG := $(strip $(USE_VTKM)) 36 | 37 | ifeq ($(USE_VTKM_FLAG),ON) 38 | 39 | override CXXFLAGS += -DHAVE_VTKM 40 | override INC += ${VTKM_INC} 41 | 42 | heatVisualization: visualization/heatVisualization.o visualization/VizSettings.o visualization/VizOutputVtkm.o 43 | ${CXX} ${CXXFLAGS} -o heatVisualization $^ ${ADIOS2_LIB} ${VTKM_LIB} 44 | 45 | else 46 | 47 | heatVisualization: visualization/heatVisualization.o visualization/VizSettings.o visualization/VizOutputPrint.o 48 | ${CXX} ${CXXFLAGS} -o heatVisualization $^ ${ADIOS2_LIB} 49 | 50 | endif 51 | 52 | 53 | clean-code: 54 | rm -f simulation/*.o analysis/*.o visualization/*.o core.* 55 | rm -f heatSimulation heatAnalysis heatVisualization 56 | 57 | clean-data: 58 | rm -f *.png *.pnm T.txt core core.* 59 | rm -rf *.bp *.bp.dir 60 | rm -f *.h5 61 | rm -f *.sst *.insitumpi 62 | rm -f conf *.bpflx 63 | 64 | clean: clean-code 65 | 66 | distclean: clean-code clean-data 67 | 68 | 69 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/ReadMe.md: -------------------------------------------------------------------------------- 1 | Heat Transfer 2D example 2 | 3 | This example solves a 2D Poisson equation for temperature in homogeneous media 4 | using finite differences. This examples shows a straight-forward way to hook 5 | an application to the ADIOS2 library for its IO. 6 | 7 | 8 | 1. simulation: illustrates the Write API 9 | 10 | 2. analysis: illustrates the Read API that allows running the reader either as 11 | 12 | * post-mortem to read all output steps 13 | * in situ to read step by step as the writer outputs them 14 | (need to run with a suitable engine) 15 | 16 | 3. visualization: illustrates the Read API and use of VTK-M to produce 2D images 17 | 18 | 19 | 20 | Example 21 | 22 | 23 | 1. Simulation: produce an output 24 | 25 | Simulation usage: heatSimulation output N M nx ny steps iterations span 26 | output: name of output data file/stream 27 | N: number of processes in X dimension 28 | M: number of processes in Y dimension 29 | nx: local array size in X dimension per processor 30 | ny: local array size in Y dimension per processor 31 | steps: the total number of steps to output 32 | iterations: one step consist of this many iterations 33 | span: optional flag to use adios buffer to reduce memory footprint 34 | 35 | The executables needs an XML config file named "adios2.xml" to select the Engine used for the output. 36 | The engines are: BPFile, ADIOS1, HDF5, SST, DataMan, InSituMPI 37 | (example XML config files are available in runtimecfg/). 38 | 39 | 40 | ```bash 41 | $ mpirun -n 12 ./heatSimulation sim.bp 4 3 5 10 10 10 42 | ``` 43 | 44 | 2. Analysis: read the output step-by-step, calculate new data, and produce another output 45 | 46 | Analysis Usage: heatAnalysis input output N M 47 | input: name of input data file/stream 48 | output: name of output data file/stream 49 | N: number of processes in X dimension 50 | M: number of processes in Y dimension 51 | 52 | 53 | ```bash 54 | $ mpirun -n 2 ./heatAnalysis sim.bp analysis.bp 2 1 55 | 56 | ``` 57 | 58 | Notes: 59 | 1. Engines for file-based output and post-mortem reading: 60 | 61 | * BPFile 62 | * HDF5 63 | * ADIOS1 64 | 65 | 2. Engines for in situ execution 66 | * SST 67 | * InSituMPI - Must run the codes together with one mpirun command (MPMD style), e.g. 68 | 69 | ```bash 70 | $ mpirun -n 12 ./heatSimulation sim.bp 4 3 5 10 10 10 : \ 71 | -n 2 ./heatAnalysis sim.bp analysis.bp 2 1 72 | ``` 73 | * DataMan - Only for N-to-N data transfers. 74 | (Must run writer and reader with the same number of processes and same decomposition) 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/adios2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 30 | 31 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/analysis/AnalysisSettings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * AnalysisSettings.cpp 6 | * 7 | * Created on: Dec 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #include "AnalysisSettings.h" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | static unsigned int convertToUint(std::string varName, char *arg) 20 | { 21 | char *end; 22 | int retval = std::strtoll(arg, &end, 10); 23 | if (end[0] || errno == ERANGE) 24 | { 25 | throw std::invalid_argument("Invalid value given for " + varName + 26 | ": " + std::string(arg)); 27 | } 28 | if (retval < 0) 29 | { 30 | throw std::invalid_argument("Negative value given for " + varName + 31 | ": " + std::string(arg)); 32 | } 33 | return (unsigned int)retval; 34 | } 35 | 36 | AnalysisSettings::AnalysisSettings(int argc, char *argv[], int rank, int nproc) 37 | : rank{rank} 38 | { 39 | if (argc < 5) 40 | { 41 | throw std::invalid_argument("Not enough arguments"); 42 | } 43 | this->nproc = (unsigned int)nproc; 44 | 45 | //configfile = argv[1]; 46 | inputfile = argv[1]; 47 | outputfile = argv[2]; 48 | npx = convertToUint("N", argv[3]); 49 | npy = convertToUint("M", argv[4]); 50 | 51 | if (npx * npy != this->nproc) 52 | { 53 | throw std::invalid_argument("N*M must equal the number of processes"); 54 | } 55 | posx = rank % npx; 56 | posy = rank / npx; 57 | } 58 | 59 | void AnalysisSettings::DecomposeArray(int gndx, int gndy) 60 | { 61 | // 2D decomposition of global array reading 62 | size_t ndx = gndx / npx; 63 | size_t ndy = gndy / npy; 64 | size_t offsx = ndx * posx; 65 | size_t offsy = ndy * posy; 66 | if (posx == npx - 1) 67 | { 68 | // right-most processes need to read all the rest of rows 69 | ndx = gndx - ndx * (npx - 1); 70 | } 71 | 72 | if (posy == npy - 1) 73 | { 74 | // bottom processes need to read all the rest of columns 75 | ndy = gndy - ndy * (npy - 1); 76 | } 77 | readsize.push_back(ndx); 78 | readsize.push_back(ndy); 79 | offset.push_back(offsx); 80 | offset.push_back(offsy); 81 | 82 | std::cout << "rank " << rank << " reads 2D slice " << ndx << " x " << ndy 83 | << " from offset (" << offsx << "," << offsy << ")" << std::endl; 84 | } 85 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/analysis/AnalysisSettings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * AnalysisSettings.h 6 | * 7 | * Created on: Dec 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #ifndef ANALYSISSETTINGS_H_ 12 | #define ANALYSISSETTINGS_H_ 13 | 14 | #include 15 | #include 16 | 17 | class AnalysisSettings 18 | { 19 | 20 | public: 21 | // user arguments 22 | const std::string configfile = "adios2.xml"; 23 | std::string inputfile; 24 | std::string outputfile; 25 | unsigned int npx; // Number of processes in X (slow) dimension 26 | unsigned int npy; // Number of processes in Y (fast) dimension 27 | 28 | int rank; 29 | int nproc; 30 | 31 | // Calculated in constructor 32 | unsigned int posx; // Position of this process in X dimension 33 | unsigned int posy; // Position of this process in Y dimension 34 | 35 | // Calculated in DecomposeArray 36 | std::vector 37 | readsize; // Local array size in X-Y dimensions per process 38 | std::vector 39 | offset; // Offset of local array in X-Y dimensions on this process 40 | 41 | AnalysisSettings(int argc, char *argv[], int rank, int nproc); 42 | void DecomposeArray(int gndx, int gndy); 43 | }; 44 | 45 | #endif /* ANALYSISSETTINGS_H_ */ 46 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/make.settings: -------------------------------------------------------------------------------- 1 | ## Setup for your system to build the C++ examples 2 | # 3 | # We need the following information: 4 | # - location of the ADIOS v2 installation 5 | # - the C++ compiler, C++-11 compatible 6 | # - this should be the MPI C++ compiler if you built ADIOS with MPI 7 | # - compiler flags if necessary to make the build work on your system 8 | # - linker flags if necessary to make the build work on your system 9 | # 10 | # Optional information to build more stuff 11 | # - location of the VTK-m installation 12 | 13 | # 14 | # ADIOS v2 installation 15 | # 16 | ADIOS2_DIR=/opt/adios2 17 | 18 | # 19 | # C++ settings 20 | # 21 | CXX=mpic++ 22 | CXXFLAGS=-g -std=gnu++11 -O2 23 | LDFLAGS=-g -O2 24 | 25 | # 26 | # VTK-m settings (need separate include and libraries) 27 | # 28 | # set USE_VTKM to OFF if you don't have VTK-m 29 | USE_VTKM=OFF 30 | override VTKM_DIR=/opt/vtk-m 31 | override VTKM_INC=-I${VTKM_DIR}/include/vtkm-1.2 32 | override VTKM_LIB=-L${VTKM_DIR}/lib -lvtkm_rendering-1.2 -lvtkm_cont-1.2 33 | 34 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/runtimecfg/adios1.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/runtimecfg/bpfile.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/runtimecfg/dataman.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/runtimecfg/hdf5.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/runtimecfg/insitumpi.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 15 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/runtimecfg/sst.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/simulation/HeatTransfer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * HeatTransfer.h 6 | * 7 | * Created on: Feb 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #ifndef HEATTRANSFER_H_ 12 | #define HEATTRANSFER_H_ 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include "Settings.h" 19 | 20 | class HeatTransfer 21 | { 22 | public: 23 | HeatTransfer(const Settings &settings); // Create two 2D arrays with ghost 24 | // cells to compute 25 | ~HeatTransfer(); 26 | void init(bool init_with_rank, MPI_Comm comm); // set up array values with either rank or 27 | // real demo values 28 | void iterate(); // one local calculation step 29 | void heatEdges(); // reset the heat values at the global edge 30 | void exchange(MPI_Comm comm); // send updates to neighbors 31 | 32 | // return a single value at index i,j. 0 <= i <= ndx+2, 0 <= j <= ndy+2 33 | double T(int i, int j) const { return m_TCurrent[i][j]; }; 34 | // return (1D) pointer to current T data, ndx+2 * ndy+2 elements 35 | double *data() const { return m_TCurrent[0]; }; 36 | // return (1D) pointer to current T data without ghost cells, ndx*ndy 37 | // elements 38 | std::vector data_noghost() const; 39 | // return (1D) pointer to current T data without ghost cells, ndx*ndy 40 | // elements, version that takes a pre-allocated memory space 41 | void data_noghost(double* d) const; 42 | 43 | void printT(std::string message, 44 | MPI_Comm comm) const; // debug: print local TCurrent on stdout 45 | 46 | private: 47 | const double edgetemp = 100.0; // temperature at the edges of the global plate 48 | const double omega = 49 | 0.8; // weight for current temp is (1-omega) in iteration 50 | double **m_T1; // 2D array (ndx+2) * (ndy+2) size, including ghost cells 51 | double **m_T2; // another 2D array 52 | double **m_TCurrent; // pointer to T1 or T2 53 | double **m_TNext; // pointer to T2 or T1 54 | const Settings &m_s; 55 | void switchCurrentNext(); // switch the current array with the next array 56 | }; 57 | 58 | #endif /* HEATTRANSFER_H_ */ 59 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/simulation/IO.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * IO.h 6 | * 7 | * Created on: Feb 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #ifndef IO_H_ 12 | #define IO_H_ 13 | 14 | #include "HeatTransfer.h" 15 | #include "Settings.h" 16 | 17 | #include 18 | 19 | class IO 20 | { 21 | public: 22 | IO(const Settings &s, MPI_Comm comm); 23 | ~IO(); 24 | void write(int step, const HeatTransfer &ht, const Settings &s, 25 | MPI_Comm comm); 26 | }; 27 | 28 | #endif /* IO_H_ */ 29 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/simulation/Settings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * Settings.cpp 6 | * 7 | * Created on: Feb 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #include "Settings.h" 12 | 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | 19 | static unsigned int convertToUint(std::string varName, char *arg) 20 | { 21 | char *end; 22 | int retval = std::strtoll(arg, &end, 10); 23 | if (end[0] || errno == ERANGE) 24 | { 25 | throw std::invalid_argument("Invalid value given for " + varName + 26 | ": " + std::string(arg)); 27 | } 28 | if (retval < 0) 29 | { 30 | throw std::invalid_argument("Negative value given for " + varName + 31 | ": " + std::string(arg)); 32 | } 33 | return (unsigned int)retval; 34 | } 35 | 36 | Settings::Settings(int argc, char *argv[], int rank, int nproc) : rank{rank} 37 | { 38 | if (argc < 8) 39 | { 40 | throw std::invalid_argument("Not enough arguments"); 41 | } 42 | this->nproc = (unsigned int)nproc; 43 | 44 | //configfile = argv[1]; 45 | outputfile = argv[1]; 46 | npx = convertToUint("N", argv[2]); 47 | npy = convertToUint("M", argv[3]); 48 | ndx = convertToUint("nx", argv[4]); 49 | ndy = convertToUint("ny", argv[5]); 50 | steps = convertToUint("steps", argv[6]); 51 | iterations = convertToUint("iterations", argv[7]); 52 | 53 | if(argc == 9) 54 | { 55 | const std::string spanOption(argv[8]); 56 | if(spanOption == "span") 57 | { 58 | span = true; 59 | } 60 | else 61 | { 62 | throw std::invalid_argument("Invalid option: " + spanOption + 63 | " last optional argument should be span"); 64 | } 65 | } 66 | 67 | if (npx * npy != this->nproc) 68 | { 69 | throw std::invalid_argument("N*M must equal the number of processes"); 70 | } 71 | 72 | // calculate global array size and the local offsets in that global space 73 | gndx = npx * ndx; 74 | gndy = npy * ndy; 75 | posx = rank % npx; 76 | posy = rank / npx; 77 | offsx = posx * ndx; 78 | offsy = posy * ndy; 79 | 80 | // determine neighbors 81 | if (posx == 0) 82 | rank_up = -1; 83 | else 84 | rank_up = rank - 1; 85 | 86 | if (posx == npx - 1) 87 | rank_down = -1; 88 | else 89 | rank_down = rank + 1; 90 | 91 | if (posy == 0) 92 | rank_left = -1; 93 | else 94 | rank_left = rank - npx; 95 | 96 | if (posy == npy - 1) 97 | rank_right = -1; 98 | else 99 | rank_right = rank + npx; 100 | } 101 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/simulation/Settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * Settings.h 6 | * 7 | * Created on: Feb 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #ifndef SETTINGS_H_ 12 | #define SETTINGS_H_ 13 | 14 | #include 15 | 16 | class Settings 17 | { 18 | 19 | public: 20 | // user arguments 21 | const std::string configfile = "adios2.xml"; 22 | std::string outputfile; 23 | unsigned int npx; // Number of processes in X (slow) dimension 24 | unsigned int npy; // Number of processes in Y (fast) dimension 25 | unsigned int ndx; // Local array size in X dimension per process 26 | unsigned int ndy; // Local array size in y dimension per process 27 | unsigned int steps; // Number of output steps 28 | unsigned int iterations; // Number of computing iterations between steps 29 | bool span = false; 30 | 31 | // calculated values from those arguments and number of processes 32 | unsigned int gndx; // Global array size in slow dimension 33 | unsigned int gndy; // Global array size in fast dimension 34 | // X dim positions: rank 0, npx, 2npx... are in the same X position 35 | // Y dim positions: npx number of consecutive processes belong to one row 36 | // (npx 37 | // columns) 38 | unsigned int posx; // Position of this process in X dimension 39 | unsigned int posy; // Position of this process in Y dimension 40 | unsigned int offsx; // Offset of local array in X dimension on this process 41 | unsigned int offsy; // Offset of local array in Y dimension on this process 42 | 43 | int rank; // MPI rank 44 | unsigned int nproc; // number of processors 45 | 46 | // neighbors by their MPI ranks, -1 if there is no such neighbor 47 | int rank_left; 48 | int rank_right; 49 | int rank_up; 50 | int rank_down; 51 | 52 | /** true: std::async Write, false (default): sync */ 53 | bool async = false; 54 | 55 | Settings(int argc, char *argv[], int rank, int nproc); 56 | }; 57 | 58 | #endif /* SETTINGS_H_ */ 59 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/visualization/VizOutput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * VizOutput.h 6 | * 7 | * Created on: Jan 2018 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #ifndef VIZOUTPUT_H_ 12 | #define VIZOUTPUT_H_ 13 | 14 | #include "adios2.h" 15 | 16 | #include "VizSettings.h" 17 | 18 | void OutputVariable(const adios2::Variable &var, 19 | const std::vector &data, VizSettings &settings, 20 | const int step); 21 | 22 | #endif /* VIZOUTPUT_H_ */ 23 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/visualization/VizOutputPrint.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * VizOutputPrint.h 6 | * 7 | * Created on: Jan 2018 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "VizOutput.h" 19 | 20 | void OutputVariable(const adios2::Variable &var, 21 | const std::vector &data, VizSettings &settings, 22 | const int step) 23 | { 24 | // void printDataStep(double *xy, T *size, T *offset, int rank, int step) 25 | std::ofstream myfile; 26 | std::string filename = var.Name() + ".txt"; 27 | if (step == 0) 28 | { 29 | myfile.open(filename); 30 | } 31 | else 32 | { 33 | myfile.open(filename, std::ios::app); 34 | } 35 | const double *buf = data.data(); 36 | uint64_t nelems = std::accumulate(var.Count().begin(), var.Count().end(), var.Sizeof(), std::multiplies()); 37 | myfile << "size=" << var.Shape()[0] << "x" << var.Shape()[1] 38 | << " step=" << step << std::endl; 39 | 40 | myfile << " time row columns 0 ..." << var.Shape()[1] - 1 << std::endl; 41 | myfile << " "; 42 | for (int j = 0; j < var.Shape()[1]; j++) 43 | { 44 | myfile << std::setw(9) << j; 45 | } 46 | myfile << std::endl; 47 | myfile << "------------------------------------------------------------" 48 | "--\n"; 49 | for (int i = 0; i < var.Shape()[0]; i++) 50 | { 51 | myfile << std::setw(5) << step << std::setw(5) << i; 52 | for (int j = 0; j < var.Shape()[1]; j++) 53 | { 54 | myfile << std::setw(9) << std::setprecision(4) 55 | << buf[i * var.Shape()[1] + j]; 56 | } 57 | myfile << std::endl; 58 | } 59 | buf += nelems; 60 | myfile.close(); 61 | } 62 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/visualization/VizSettings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * VizSettings.cpp 6 | * 7 | * Created on: Dec 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #include "VizSettings.h" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | static double convertToDouble(std::string varName, char *arg) 20 | { 21 | char *end; 22 | double retval = std::strtod(arg, &end); 23 | if (end[0]) 24 | { 25 | throw std::invalid_argument("Invalid floating point value given for " + 26 | varName + ": " + std::string(arg)); 27 | } 28 | else if (errno == ERANGE) 29 | { 30 | std::cerr << "Value overflow/underflow for argument " << varName 31 | << ". We will use instead the value " << retval << std::endl; 32 | } 33 | return retval; 34 | } 35 | 36 | static unsigned int convertToUint(std::string varName, char *arg) 37 | { 38 | char *end; 39 | int retval = std::strtoll(arg, &end, 10); 40 | if (end[0] || errno == ERANGE) 41 | { 42 | throw std::invalid_argument("Invalid non-negative integer given for " + 43 | varName + ": " + std::string(arg)); 44 | } 45 | if (retval < 0) 46 | { 47 | throw std::invalid_argument("Negative value given for " + varName + 48 | ": " + std::string(arg)); 49 | } 50 | return (unsigned int)retval; 51 | } 52 | 53 | VizSettings::VizSettings(int argc, char *argv[]) 54 | { 55 | if (argc < 2) 56 | { 57 | throw std::invalid_argument("Not enough arguments"); 58 | } 59 | 60 | //configfile = argv[1]; 61 | inputfile = argv[1]; 62 | if (argc > 2) 63 | { 64 | minValue = convertToDouble("min", argv[2]); 65 | } 66 | if (argc > 3) 67 | { 68 | maxValue = convertToDouble("max", argv[3]); 69 | } 70 | if (argc > 4) 71 | { 72 | width = convertToUint("width", argv[4]); 73 | } 74 | if (argc > 5) 75 | { 76 | height = convertToUint("height", argv[5]); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Tutorial/heat2d/cpp/visualization/VizSettings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * VizSettings.h 6 | * 7 | * Created on: Dec 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #ifndef VIZSETTINGS_H_ 12 | #define VIZSETTINGS_H_ 13 | 14 | #include 15 | #include 16 | 17 | class VizSettings 18 | { 19 | 20 | public: 21 | /* User arguments */ 22 | 23 | const std::string configfile = "adios2.xml"; 24 | std::string inputfile; 25 | 26 | // Min/Max of color value range 27 | double minValue = 0.0; 28 | double maxValue = 200.0; 29 | 30 | // Size of image 31 | unsigned int width = 512; 32 | unsigned int height = 512; 33 | 34 | 35 | /* App settings */ 36 | 37 | std::string outputfile; 38 | 39 | 40 | VizSettings(int argc, char *argv[]); 41 | }; 42 | 43 | #endif /* VIZSETTINGS_H_ */ 44 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/.gitignore: -------------------------------------------------------------------------------- 1 | heat_transfer_adios1 2 | heat_transfer_adios2 3 | heat_transfer_fort 4 | heat_transfer_noxml 5 | heat_transfer_hdf5_a 6 | heat_transfer_hdf5_b 7 | heat_transfer_phdf5 8 | heat_vars.mod 9 | heat_io.mod 10 | query/test_range 11 | read/heat_print.mod 12 | read/heat_read_adios 13 | read/heat_read_steps 14 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: 3 | @echo "Make targets :" 4 | @echo " adios2 : build ADIOS examples" 5 | @echo " hdf5 : build HDF5 examples" 6 | @echo " clean-code : recursively delete objects and binaries" 7 | @echo " clean-data : recursively delete files created by the examples" 8 | @echo " distclean : clean-code and clean-data" 9 | 10 | all: default 11 | help: default 12 | 13 | adios2: 14 | cd simulation; make adios2 15 | cd analysis; make adios2_file adios2_stream 16 | 17 | hdf5: 18 | cd simulation; make phdf5 hdf5_a hdf5_b 19 | cd analysis; make hdf5_file phdf5_file 20 | 21 | subdirs = simulation analysis 22 | 23 | clean-data: 24 | rm -f *.o *.mod *.fh core.* 25 | rm -f fort.* 26 | rm -f *.png *.pnm minmax 27 | rm -rf *.bp *.bp.dir *.idx 28 | rm -f *.h5 29 | rm -f conf *.sst *_insitumpi_* 30 | for dir in $(subdirs); do echo "Clean $${dir}"; (cd $${dir}; make clean-data); done 31 | 32 | clean-code: 33 | rm -f *.o *.mod *.fh core.* 34 | for dir in $(subdirs); do echo "Clean $${dir}"; (cd $${dir}; make clean-code); done 35 | 36 | distclean: clean-code clean-data 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/README: -------------------------------------------------------------------------------- 1 | 2D Heat Transfer example 2 | Fortran 90 code, 2D array with 2D decomposition 3 | 4 | 1. Build 5 | -------- 6 | Edit make.settings 7 | - compiler and compiler options 8 | - ADIOS 2.x installation directory 9 | - optionally 10 | ADIOS 1.x installation directory 11 | Parallel HDF5 installation directory 12 | 13 | $ cd simulation 14 | $ make adios2 15 | $ cd .. 16 | 17 | $ cd analysis 18 | $ make adios2_stream adios2_file 19 | $ cd .. 20 | 21 | 2. Run Simulation 22 | ----------------- 23 | 24 | $ simulation/heatSimulation_adios2 25 | Usage: heat_transfer output N M nx ny steps iterations 26 | output: name of output file 27 | N: number of processes in X dimension 28 | M: number of processes in Y dimension 29 | nx: local array size in X dimension per processor 30 | ny: local array size in Y dimension per processor 31 | steps: the total number of steps to output 32 | iterations: one step consist of this many iterations 33 | 34 | $ mpirun -n 12 simulation/heatSimulation_adios2 heat.bp 4 3 256 256 6 500 35 | 36 | will perform the calculation 37 | - on 12 processes 38 | - on a 4*256 x 3*256 2D array (Fortran column-major ordering) 39 | - for 6*500 iterations, 40 | - producing an output of 6 steps stored in heat.bp 41 | 42 | $ bpls -l heat.bp 43 | double T 6*{768, 1024} = 0 / 200 44 | 45 | $ python3 ../python/heat_plot.py -i heat.bp -o T 46 | $ eog . 47 | 48 | 49 | 3. Run Analysis 50 | --------------- 51 | 52 | $ ./analysis/heatAnalysis_adios2_file 53 | Usage: heat_read input 54 | input: name of input file 55 | 56 | $ mpirun -n 3 analysis/heatAnalysis_adios2_file heat.bp 57 | Input file: heat.bp 58 | Using BPFile engine for input 59 | Global array size: 1024x768 60 | Available steps = 6 61 | Read step = 0 62 | ... 63 | Read step = 5 64 | 65 | will perform reading the data step by step from the simulation output on 3 processes and 66 | each process will print its part of the data array into a separate text file (fort.*) 67 | 68 | 69 | $ mpirun -n 3 analysis/heatAnalysis_adios2_stream heat.bp 70 | Input file: heat.bp 71 | Using BPFile engine for input 72 | Process step: 0 73 | Global array size: 1024x768 74 | Process step: 1 75 | ... 76 | Process step: 5 77 | 78 | 79 | will read each step in heat.bp one by one and print the data into text files (fort.*) 80 | 81 | --------------- 82 | Staging demos 83 | --------------- 84 | 85 | A 100 output step on less processes, with more computation between steps. 86 | In adios2.xml, use "SST" for engine of the io group "SimulationOutput" 87 | 88 | In two terminal windows: 89 | 90 | $ mpirun -n 12 simulation/heatSimulation_adios2 heat.bp 4 3 256 256 100 500 91 | $ mpirun -n 2 analysis/heatAnalysis_adios2_stream heat.bp 92 | 93 | or 94 | 95 | $ mpirun -n 12 simulation/heatSimulation_adios2 heat.bp 4 3 256 256 100 500 96 | $ mpirun -n 2 /opt/adios2/bin/adios_reorganize heat.bp staged.bp SST "" BPFile "" 2 1 97 | 98 | 99 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/README.MixedDemo: -------------------------------------------------------------------------------- 1 | 2 | Fortran simulation - C++ analysis - Python plotter 3 | 4 | In adios2.xml, set the engines for 5 | SimulationOutput: SSC 6 | AnalysisOutput: SST 7 | VizInput: SST 8 | 9 | This will plot on screen. No data file will be produced. 10 | 11 | $ mpirun -n 4 simulation/heatSimulation_adios2 heat.bp 2 2 40 50 100 1000 : \ 12 | -n 2 ../cpp/heatAnalysis heat.bp analysis.bp 2 1 : \ 13 | -n 1 ../python/heat_plot.py --in analysis.bp 14 | 15 | 16 | The demo also works with SST for all IO. i 17 | Make sure to use BP marshalling for the simulation output. 18 | In adios2.xml, set the engines for 19 | SimulationOutput: 20 | 21 | 22 | 23 | AnalysisOutput: SST 24 | VizInput: SST 25 | 26 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/adios2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 40 | 41 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 65 | 66 | 67 | 68 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/analysis/Makefile: -------------------------------------------------------------------------------- 1 | include ../make.settings 2 | 3 | override ADIOS2_FINC=`${ADIOS2_DIR}/bin/adios2-config --fortran-flags` 4 | override ADIOS2_FLIB=`${ADIOS2_DIR}/bin/adios2-config --fortran-libs` 5 | 6 | default: 7 | @echo "Make targets: adios2_stream adios2_file hdf5_file" 8 | @echo " adios2_stream: build example with ADIOS 2.x step-by-step reading (heatAnalysis_adios2_stream.F90)" 9 | @echo " adios2_file: build example with ADIOS 2.x for file-only read (heatAnalysis_adios2_file.F90)" 10 | @echo " hdf5_file: build example with HDF5 for file-only read (heatAnalysis_hdf5_file.F90)" 11 | @echo " phdf5_file: build example with PHDF5 for file-only read (heatAnalysis_phdf5_file.F90)" 12 | 13 | 14 | all: default 15 | help: default 16 | 17 | print.o : print.F90 18 | ${FC} ${FFLAGS} -c $< 19 | 20 | hdf5_file: print.o heatAnalysis_hdf5_file.F90 21 | libtool --mode=link --tag=FC ${FC} ${FFLAGS} ${HDF5_FINC} -o heatAnalysis_hdf5_file $^ ${HDF5_FLIB} 22 | 23 | phdf5_file: print.o heatAnalysis_phdf5_file.F90 24 | libtool --mode=link --tag=FC ${FC} ${FFLAGS} ${PHDF5_FINC} -o heatAnalysis_phdf5_file $^ ${PHDF5_FLIB} 25 | 26 | adios2_file: print.o heatAnalysis_adios2_file.F90 27 | adios2_file: print.o heatAnalysis_adios2_file.F90 28 | ${FC} ${FFLAGS} -o heatAnalysis_adios2_file ${ADIOS2_FINC} $^ ${ADIOS2_FLIB} 29 | 30 | adios2_stream: print.o heatAnalysis_adios2_stream.F90 31 | ${FC} ${FFLAGS} -o heatAnalysis_adios2_stream ${ADIOS2_FINC} $^ ${ADIOS2_FLIB} 32 | 33 | 34 | clean-code: 35 | rm -f *.o *.mod *.fh core.* fort.* 36 | rm -f heatAnalysis_adios2_file heatAnalysis_adios2_stream 37 | rm -f heatAnalysis_hdf5_file heatAnalysis_phdf5_file 38 | rm -rf .libs 39 | 40 | clean-data: 41 | rm -rf *.png *.pnm *.bp *.bp.dir 42 | 43 | distclean: clean-code clean-data 44 | clean: clean-code clean-data 45 | 46 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/analysis/print.F90: -------------------------------------------------------------------------------- 1 | 2 | ! ADIOS is freely available under the terms of the BSD license described 3 | ! in the COPYING file in the top level directory of this source distribution. 4 | ! 5 | ! Copyright (c) 2008 - 2009. UT-BATTELLE, LLC. All rights reserved. 6 | ! 7 | ! 8 | ! Write an ADIOS BP file 9 | ! 10 | ! (c) Oak Ridge National Laboratory, 2009 11 | ! Author: Norbert Podhorszki 12 | ! 13 | module heat_print 14 | 15 | contains 16 | 17 | subroutine print_array(xy,offset,rank, step) 18 | implicit none 19 | include 'mpif.h' 20 | real*8, dimension(:,:), intent(in) :: xy 21 | integer*8, dimension(2), intent(in) :: offset 22 | integer, intent(in) :: rank, step 23 | 24 | integer :: size1,size2 25 | integer :: i,j 26 | 27 | size1 = size(xy,1) 28 | size2 = size(xy,2) 29 | 30 | write (100+rank, '("rank=",i0," size=",i0,"x",i0," offsets=",i0,":",i0," step=",i0)') & 31 | rank, size1, size2, offset(1), offset(2), step 32 | write (100+rank, '(" time row columns ",i0,"...",i0)'), offset(2), offset(2)+size2-1 33 | write (100+rank, '(" ",$)') 34 | do j=1,size2 35 | write (100+rank, '(i9,$)'), offset(2)+j-1 36 | enddo 37 | write (100+rank, '(" ")') 38 | write (100+rank, '("--------------------------------------------------------------")') 39 | do i=1,size1 40 | write (100+rank, '(2i5,$)') step,offset(1)+i-1 41 | do j=1,size2 42 | write (100+rank, '(f9.2,$)') xy(i,j) 43 | enddo 44 | write (100+rank, '(" ")') 45 | enddo 46 | 47 | end subroutine print_array 48 | 49 | end module heat_print 50 | 51 | 52 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/make.settings: -------------------------------------------------------------------------------- 1 | # 2 | # Set compiler options and library locations here 3 | # before doing make 4 | # 5 | 6 | ## Location of the ADIOS 2.x libraries 7 | ADIOS2_DIR=/opt/adios2 8 | 9 | ## Location of the ADIOS 1.x libraries 10 | override ADIOS1_DIR=/opt/adios1 11 | 12 | #Location of the (sequential) HDF5 libraries 13 | HDF5_DIR=/opt/hdf5-serial 14 | 15 | #Location of the Parallel HDF5 libraries 16 | PHDF5_DIR=/opt/hdf5-parallel 17 | 18 | ## mpicc and mpif90 SETTINGS 19 | CC=mpicc 20 | # if ADIOS 1.x has C++ dependencies (FastBit, Alacrity) then we need C++ to link 21 | #OMPI_CXX=g++-5 22 | #LINKER=mpic++ 23 | LINKER=mpicc 24 | FC=mpif90 25 | CFLAGS=-g -O2 26 | LDFLAGS=-g -O2 27 | FFLAGS=-g -O2 28 | 29 | ## cc/ftn SETTINGS 30 | #CC=cc 31 | #FC=ftn 32 | #CFLAGS = -O3 33 | #LDFLAGS = 34 | 35 | # 36 | # settings that may need modification 37 | # 38 | # HDF5 39 | HDF5_CINC=-I$(HDF5_DIR)/include 40 | HDF5_FINC=-I$(HDF5_DIR)/include 41 | HDF5_CLIB=$(HDF5_DIR)/lib/libhdf5.la 42 | HDF5_FLIB=$(HDF5_DIR)/lib/libhdf5_fortran.la 43 | # Parallel HDF5 44 | PHDF5_CINC=-I$(PHDF5_DIR)/include 45 | PHDF5_FINC=-I$(PHDF5_DIR)/include 46 | PHDF5_CLIB=$(PHDF5_DIR)/lib/libhdf5.la 47 | PHDF5_FLIB=$(PHDF5_DIR)/lib/libhdf5_fortran.la 48 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/simulation/Makefile: -------------------------------------------------------------------------------- 1 | include ../make.settings 2 | 3 | override ADIOS2_FINC=`${ADIOS2_DIR}/bin/adios2-config --fortran-flags` 4 | override ADIOS2_FLIB=`${ADIOS2_DIR}/bin/adios2-config --fortran-libs` 5 | 6 | default: 7 | @echo "Make targets: fort hdf5_a hdf5_b phdf5 adios2" 8 | @echo " fort: build example with text output(io_fort.F90)" 9 | @echo " hdf5_a: build example with HDF5, separate timesteps (io_hdf5_a.F90)" 10 | @echo " hdf5_b: build example with HDF5, combined timesteps (io_hdf5_b.F90)" 11 | @echo " phdf5: build example with Parallel HDF5 (io_phdf5.F90)" 12 | @echo " adios2: build example with ADIOS 2.x (io_adios2.F90)" 13 | 14 | all: default 15 | help: default 16 | 17 | 18 | io_hdf5_a.o : io_hdf5_a.F90 19 | ${FC} ${FFLAGS} -c ${HDF5_FINC} $< 20 | 21 | io_hdf5_b.o : io_hdf5_b.F90 22 | ${FC} ${FFLAGS} -c ${HDF5_FINC} $< 23 | 24 | io_phdf5.o : io_phdf5.F90 25 | ${FC} ${FFLAGS} -c ${PHDF5_FINC} $< 26 | 27 | io_adios2.o : io_adios2.F90 28 | ${FC} ${FFLAGS} -c ${ADIOS2_FINC} $< 29 | 30 | heat_vars.o : heat_vars.F90 31 | ${FC} ${FFLAGS} -c $< 32 | 33 | fort: heat_vars.o io_fort.o heatSimulation.o 34 | ${FC} ${FFLAGS} -o heatSimulation_fort $^ 35 | 36 | hdf5_a: heat_vars.o io_hdf5_a.o heatSimulation.F90 37 | libtool --mode=link --tag=FC ${FC} ${FFLAGS} -o heatSimulation_hdf5_a ${HDF5_INC} $^ ${HDF5_FLIB} 38 | 39 | hdf5_b: heat_vars.o io_hdf5_b.o heatSimulation.F90 40 | libtool --mode=link --tag=FC ${FC} ${FFLAGS} -o heatSimulation_hdf5_b ${HDF5_INC} $^ ${HDF5_FLIB} 41 | 42 | phdf5: heat_vars.o io_phdf5.o heatSimulation.F90 43 | libtool --mode=link --tag=FC ${FC} ${FFLAGS} -o heatSimulation_phdf5 ${PHDF5_FINC} $^ ${PHDF5_FLIB} 44 | 45 | adios2: heat_vars.o io_adios2.o heatSimulation.F90 46 | ${FC} ${FFLAGS} -o heatSimulation_adios2 ${ADIOS2_FINC} $^ ${ADIOS2_FLIB} 47 | 48 | clean-code: 49 | rm -f *.o *.mod *.fh core.* 50 | rm -f heatSimulation_fort 51 | rm -f heatSimulation_adios2 52 | rm -f heatSimulation_hdf5_a heatSimulation_hdf5_b heatSimulation_phdf5 53 | rm -rf .libs 54 | 55 | clean-data: 56 | rm -f fort.* 57 | rm -f *.png *.pnm minmax 58 | rm -rf *.bp *.bp.dir *.idx 59 | rm -f *.h5 60 | rm -f conf 61 | 62 | distclean: clean-code clean-data 63 | clean: clean-code clean-data 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/simulation/heat_vars.F90: -------------------------------------------------------------------------------- 1 | 2 | ! ADIOS is freely available under the terms of the BSD license described 3 | ! in the COPYING file in the top level directory of this source distribution. 4 | ! 5 | ! Copyright (c) 2008 - 2009. UT-BATTELLE, LLC. All rights reserved. 6 | ! 7 | ! 8 | ! Global variables for the heat_transfer example 9 | ! 10 | ! (c) Oak Ridge National Laboratory, 2014 11 | ! Author: Norbert Podhorszki 12 | ! 13 | module heat_vars 14 | ! arguments 15 | character(len=256) :: outputfile, inputfile 16 | integer :: npx, npy ! # of processors in x-y direction 17 | integer :: ndx, ndy ! size of array per processor (without ghost cells) 18 | integer :: steps ! number of steps to write 19 | integer :: iters ! number of iterations between steps 20 | 21 | integer :: gndx, gndy ! size of the global array (without ghost cells) 22 | integer :: offx,offy ! offsets of local array in the global array 23 | integer :: posx, posy ! position index in the array 24 | 25 | real*8, dimension(:,:,:), allocatable :: T ! data array 26 | real*8, dimension(:,:), allocatable :: dT ! data array 27 | 28 | ! MPI COMM_WORLD is for all codes started up at once on Cray XK6 29 | integer :: wrank, wnproc 30 | 31 | ! MPI 'world' for this app variables 32 | integer :: app_comm, color 33 | integer :: rank, nproc 34 | integer :: ierr 35 | integer :: rank_left, rank_right, rank_up, rank_down ! neighbours' ranks 36 | 37 | integer :: err 38 | 39 | real*8 :: start_time, end_time, total_time,gbs,sz 40 | real*8 :: io_start_time, io_end_time, io_total_time 41 | 42 | ! heat parameter 43 | real*8, parameter :: edgetemp = 100.0 44 | 45 | end module heat_vars 46 | 47 | 48 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/simulation/io_fort.F90: -------------------------------------------------------------------------------- 1 | 2 | ! ADIOS is freely available under the terms of the BSD license described 3 | ! in the COPYING file in the top level directory of this source distribution. 4 | ! 5 | ! Copyright (c) 2008 - 2009. UT-BATTELLE, LLC. All rights reserved. 6 | ! 7 | ! 8 | ! Write fort. text files, one per process 9 | ! 10 | ! (c) Oak Ridge National Laboratory, 2014 11 | ! Author: Norbert Podhorszki 12 | ! 13 | module heat_io 14 | 15 | contains 16 | 17 | subroutine io_init() 18 | end subroutine io_init 19 | 20 | subroutine io_finalize() 21 | end subroutine io_finalize 22 | 23 | subroutine io_write(tstep,curr) 24 | use heat_vars 25 | implicit none 26 | include 'mpif.h' 27 | integer, intent(in) :: tstep 28 | integer, intent(in) :: curr 29 | 30 | integer :: i,j 31 | 32 | if (tstep==0) then 33 | write (100+rank, '("rank=",i0," size=",i0,"x",i0," offsets=",i0,":",i0," step=",i0)') & 34 | rank, ndx, ndy, offx, offy, tstep 35 | write (100+rank, '(" time row columns ",i0,"...",i0)'), offy, offy+ndy-1 36 | write (100+rank, '(" ",$)') 37 | do j=1,ndy 38 | write (100+rank, '(i9,$)'), offy+j-1 39 | enddo 40 | write (100+rank, '(" ")') 41 | write (100+rank, '("--------------------------------------------------------------")') 42 | else 43 | write (100+rank, '(" ")') 44 | endif 45 | 46 | do i=1,ndx 47 | write (100+rank, '(2i5,$)') tstep,offx+i-1 48 | do j=1,ndy 49 | write (100+rank, '(f9.2,$)') T(i,j,curr) 50 | enddo 51 | write (100+rank, '(" ")') 52 | enddo 53 | end subroutine io_write 54 | 55 | end module heat_io 56 | 57 | 58 | -------------------------------------------------------------------------------- /Tutorial/heat2d/fortran/simulation/io_hdf5_a.F90: -------------------------------------------------------------------------------- 1 | 2 | ! ADIOS is freely available under the terms of the BSD license described 3 | ! in the COPYING file in the top level directory of this source distribution. 4 | ! 5 | ! Copyright (c) 2008 - 2009. UT-BATTELLE, LLC. All rights reserved. 6 | ! 7 | ! 8 | ! HDF5 based I/O for the heat_transfer example, 9 | ! producing one file per process per step 10 | ! 11 | ! (c) Oak Ridge National Laboratory, 2014 12 | ! Author: Jeremy Logan 13 | ! 14 | module heat_io 15 | 16 | contains 17 | 18 | subroutine io_init() 19 | use heat_vars 20 | use HDF5 21 | 22 | ! Initialize FORTRAN interface 23 | call h5open_f(err) 24 | 25 | end subroutine io_init 26 | 27 | subroutine io_finalize() 28 | use heat_vars 29 | use HDF5 30 | 31 | ! Close FORTRAN interface. 32 | call h5close_f(err) 33 | 34 | end subroutine io_finalize 35 | 36 | subroutine io_write(tstep,curr) 37 | use heat_vars 38 | use HDF5 39 | implicit none 40 | include 'mpif.h' 41 | integer, intent(in) :: tstep 42 | integer, intent(in) :: curr 43 | 44 | integer :: ndims 45 | integer*8, dimension(1:2) :: dims 46 | 47 | integer*8 io_size 48 | 49 | INTEGER(HID_T) :: file_id 50 | INTEGER(HID_T) :: dset_id 51 | INTEGER(HID_T) :: dspace_id 52 | 53 | character (len=200) :: filename 54 | character(2) :: mode = "w" 55 | 56 | 57 | write(filename,'(a,".",i3.3,".",i3.3,".h5")') trim(outputfile), rank, tstep 58 | print '("rank ",i0," writes to: ",a)', rank, trim(filename) 59 | 60 | call MPI_BARRIER(app_comm, err) 61 | io_start_time = MPI_WTIME() 62 | 63 | ndims = 2 64 | dims(1) = ndx 65 | dims(2) = ndy 66 | 67 | call h5fcreate_f (filename, H5F_ACC_TRUNC_F, file_id, err) 68 | call h5screate_simple_f(ndims, dims, dspace_id, err) 69 | call h5dcreate_f(file_id, "T", H5T_NATIVE_DOUBLE, dspace_id, & 70 | dset_id, err) 71 | 72 | io_size = 11*4 + 2*8*ndx*ndy 73 | 74 | call h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, T(1:ndx,1:ndy,curr), dims, err) 75 | 76 | 77 | ! close dataset 78 | call h5dclose_f(dset_id, err) 79 | 80 | ! close dataspace 81 | call h5sclose_f(dspace_id, err) 82 | 83 | ! close file 84 | call h5fclose_f(file_id, err) 85 | 86 | call MPI_BARRIER(app_comm ,err) 87 | io_end_time = MPI_WTIME() 88 | io_total_time = io_end_time - io_start_time 89 | sz = io_size * nproc/1024.d0/1024.d0/1024.d0 !size in GB 90 | gbs = sz/io_total_time 91 | if (rank==0) print '("Step ",i3,": ",a20,f12.4,2x,f12.3,2x,f12.3)', & 92 | tstep,filename,sz,io_total_time,gbs 93 | end subroutine io_write 94 | 95 | end module heat_io 96 | 97 | 98 | -------------------------------------------------------------------------------- /Tutorial/heat2d/python/.obsolete/simple_steps.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import absolute_import, division, print_function, unicode_literals 3 | 4 | import adios2 5 | import argparse 6 | import numpy as np 7 | from mpi4py import MPI 8 | 9 | varname = 'T' 10 | infile = 'heat.bp' 11 | outfile = 'delta.bp' 12 | 13 | # Open file for reading 14 | fr = adios2.open(infile, "r", MPI.COMM_WORLD, "adios2.xml", "SimulationOutput") 15 | 16 | # Get the list of variables 17 | var = fr.available_variables() 18 | print(var) 19 | 20 | # Get the dimensions of T in string format 21 | dshapestr = var['T']['Shape'].split(',') 22 | 23 | # convert into int array 24 | dims = np.zeros(2, dtype=np.int64) 25 | for i in range(len(dshapestr)): 26 | dims[i] = int(dshapestr[i]) 27 | 28 | 29 | # Open file for writing 30 | fw = adios2.open(outfile, "w", MPI.COMM_WORLD, "adios2.xml", "AnalysisOutput") 31 | 32 | # Read through the steps, one at a time 33 | step = 0 34 | while (not fr.eof()): 35 | data = fr.read(varname, [0,0], dims, endl=True) 36 | 37 | # Print a couple simple diagnostics 38 | avg = np.average(data) 39 | std = np.std(data) 40 | print("step:{0}, start: {3}, dims: {4}, avg: {1:.3f}, std: {2:.3f}".format(step, avg, std, [0,0], dims)) 41 | 42 | # Calculate difference 43 | if (step > 0): 44 | dt = data - olddata 45 | fw.write("d{0}".format(varname), dt, dims, [0,0], dims, endl=True) 46 | olddata = np.copy(data) 47 | 48 | step += 1 49 | 50 | fr.close() 51 | fw.close() 52 | -------------------------------------------------------------------------------- /Tutorial/heat2d/python/decomp.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def Locate(rank, nproc, datasize): 5 | extra = 0 6 | if (rank == nproc - 1): 7 | extra = datasize % nproc 8 | num = datasize // nproc 9 | start = num * rank 10 | size = num + extra 11 | return start, size 12 | 13 | 14 | class MPISetup(object): 15 | 16 | readargs = [] 17 | size = 1 18 | rank = {'world': 0, 19 | 'x': 0, 20 | 'y': 0} 21 | 22 | 23 | def __init__(self, args): 24 | 25 | self.nx = args.nx 26 | self.ny = args.ny 27 | 28 | if not args.nompi: 29 | 30 | from mpi4py import MPI 31 | 32 | color = 3 33 | self.comm_world = MPI.COMM_WORLD.Split(color, MPI.COMM_WORLD.Get_rank()) 34 | self.size = self.comm_world.Get_size() 35 | self.rank['world'] = self.comm_world.Get_rank() 36 | if self.size != (self.nx * self.ny): 37 | raise ValueError("nx * ny != num processes") 38 | 39 | if (self.ny > 1) and (self.nx > 1): 40 | comm_x = self.comm_world.Split(self.rank['world'] % self.nx, self.rank['world']) 41 | else: 42 | comm_x = self.comm_world.Split(self.rank['world'] / self.nx, self.rank['world']) 43 | comm_y = self.comm_world.Split(self.rank['world']/self.ny, self.rank['world']) 44 | 45 | self.rank['x'] = comm_x.Get_rank() 46 | self.rank['y'] = comm_y.Get_rank() 47 | 48 | self.readargs.append(self.comm_world) 49 | 50 | else: 51 | if self.nx != 1: 52 | raise ValueError("nx must = 1 without MPI") 53 | if self.ny != 1: 54 | raise ValueError("ny must = 1 without MPI") 55 | 56 | # self.readargs.extend([args.xmlfile, "heat"]) 57 | 58 | 59 | def Partition(self, fp, args): 60 | datashape = np.zeros(2, dtype=np.int64) 61 | start = np.zeros(2, dtype=np.int64) 62 | size = np.zeros(2, dtype=np.int64) 63 | 64 | var = fp.available_variables() 65 | print("Available variables: ") 66 | for name, info in var.items(): 67 | print("variable_name: " + name) 68 | for key, value in info.items(): 69 | print("\t" + key + ": " + value) 70 | print("\n") 71 | 72 | dshape = var[args.varname]['Shape'].split(',') 73 | for i in range(len(dshape)): 74 | datashape[i] = int(dshape[i]) 75 | 76 | start[0], size[0] = Locate(self.rank['y'], self.ny, datashape[0]) 77 | start[1], size[1] = Locate(self.rank['x'], self.nx, datashape[1]) 78 | 79 | return start, size, datashape 80 | -------------------------------------------------------------------------------- /heat_stability/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Distributed under the OSI-approved Apache License, Version 2.0. See 3 | # accompanying file Copyright.txt for details. 4 | #------------------------------------------------------------------------------# 5 | 6 | cmake_minimum_required(VERSION 3.12) 7 | project(HeatTransfer) 8 | 9 | cmake_minimum_required(VERSION 3.12) 10 | 11 | set(CMAKE_CXX_STANDARD 17) 12 | if(POLICY CMP0074) 13 | cmake_policy(SET CMP0074 NEW) 14 | endif() 15 | 16 | project(HeatTransfer C CXX) 17 | 18 | find_package(MPI REQUIRED) 19 | find_package(ADIOS2 REQUIRED) 20 | 21 | # We are not using the C++ API of MPI, this will stop the compiler look for it 22 | add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) 23 | 24 | add_subdirectory(write) 25 | -------------------------------------------------------------------------------- /heat_stability/ReadMe.md: -------------------------------------------------------------------------------- 1 | ### ADIOS2 heatTransfer example 2 | 3 | This example solves a 2D Poisson equation for temperature in homogeneous media 4 | using finite differences. This examples shows a straight-forward way to hook 5 | an application to the ADIOS2 library for its IO. 6 | 7 | 8 | #### Example 9 | 10 | ##### 1. Build the example 11 | $ mkdir build 12 | $ cd build 13 | $ cmake -DCMAKE_PREFIX_PATH= -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release .. 14 | $ make -j 8 15 | $ cd .. 16 | 17 | ##### 1. Produce an output 18 | 19 | ``` 20 | Writer usage: heatTransfer config output N M nx ny steps iterations 21 | config: XML config file to use 22 | output: name of output data file/stream 23 | N: number of processes in X dimension 24 | M: number of processes in Y dimension 25 | nx: local array size in X dimension per processor 26 | ny: local array size in Y dimension per processor 27 | steps: the total number of steps to output 28 | iterations: one step consist of this many iterations 29 | ``` 30 | 31 | $ mpirun -n 4 ./build/write/heatTransferWrite heat_bp5.xml heat.bp 2 2 128 128 200 1 1 32 | 33 | ###### 2. Plot the results 34 | $ python3 ./plot_heat.py -i heat.bp -o T 35 | see image files as T0\*.png 36 | 37 | -------------------------------------------------------------------------------- /heat_stability/heat_bp5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /heat_stability/heat_bp5_mgard.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /heat_stability/heat_bp5_zfp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /heat_stability/write/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # Distributed under the OSI-approved Apache License, Version 2.0. See 3 | # accompanying file Copyright.txt for details. 4 | #------------------------------------------------------------------------------# 5 | 6 | add_executable(heatTransferWrite 7 | main.cpp 8 | HeatTransfer.cpp 9 | Settings.cpp 10 | IO_adios2.cpp 11 | ) 12 | 13 | target_link_libraries(heatTransferWrite adios2::cxx11_mpi MPI::MPI_CXX) 14 | install(TARGETS heatTransferWrite RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 15 | 16 | -------------------------------------------------------------------------------- /heat_stability/write/HeatTransfer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * HeatTransfer.h 6 | * 7 | * Created on: Feb 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #ifndef HEATTRANSFER_H_ 12 | #define HEATTRANSFER_H_ 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | #include "Settings.h" 20 | 21 | class HeatTransfer 22 | { 23 | public: 24 | HeatTransfer(const Settings &settings); // Create two 2D arrays with ghost 25 | // cells to compute 26 | ~HeatTransfer() = default; 27 | void init(MPI_Comm comm, bool init_with_rank); // set up array values with either rank or 28 | // real demo values 29 | void iterate(); // one local calculation step 30 | void heatEdges(); // reset the heat values at the global edge 31 | void exchange(MPI_Comm comm); // send updates to neighbors 32 | 33 | // return a single value at index i,j. 0 <= i <= ndx+2, 0 <= j <= ndy+2 34 | double T(int i, int j) const { return m_TCurrent[i][j]; }; 35 | // return (1D) pointer to current T data, ndx+2 * ndy+2 elements 36 | double *data() const { return m_TCurrent[0]; }; 37 | // return (1D) pointer to current T data without ghost cells, ndx*ndy 38 | // elements 39 | std::vector data_noghost() const; 40 | 41 | // overwrite local data with data provided 42 | void set_data_noghost(std::vector v); 43 | 44 | void printT(std::string message, 45 | MPI_Comm comm) const; // debug: print local TCurrent on stdout 46 | 47 | private: 48 | const Settings &m_s; 49 | 50 | const double edgetemp = 3.0; // temperature at the edges of the global plate 51 | const double omega = 0.8; // weight for current temp is (1-omega) in iteration 52 | 53 | // 2D data arrays (ndx+2) * (ndy+2) size, including ghost cells 54 | std::unique_ptr m_T1Buf; 55 | std::unique_ptr m_T2Buf; 56 | 57 | // Double indexable view into the data arrays to allow for m_T1[i][j] 58 | std::unique_ptr m_T1; 59 | std::unique_ptr m_T2; 60 | 61 | // Track which data array is active 62 | double **m_TCurrent; 63 | double **m_TNext; 64 | }; 65 | 66 | #endif /* HEATTRANSFER_H_ */ 67 | -------------------------------------------------------------------------------- /heat_stability/write/IO.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * IO.h 6 | * 7 | * Created on: Feb 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #ifndef IO_H_ 12 | #define IO_H_ 13 | 14 | #include "HeatTransfer.h" 15 | #include "Settings.h" 16 | 17 | #include 18 | 19 | class IO 20 | { 21 | public: 22 | IO(const Settings &s, MPI_Comm comm); 23 | ~IO(); 24 | void write(unsigned int iteration, const HeatTransfer &ht, const Settings &s, MPI_Comm comm); 25 | unsigned int read(HeatTransfer &ht, const unsigned int expected_step, const Settings &s, MPI_Comm comm); 26 | 27 | private: 28 | std::string m_outputfilename; 29 | }; 30 | 31 | #endif /* IO_H_ */ 32 | -------------------------------------------------------------------------------- /heat_stability/write/Settings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * Settings.cpp 6 | * 7 | * Created on: Feb 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #include "Settings.h" 12 | 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | 19 | static unsigned int convertToUint(std::string varName, char *arg) 20 | { 21 | char *end; 22 | long retval = std::strtol(arg, &end, 10); 23 | if (end[0] || errno == ERANGE) 24 | { 25 | throw std::invalid_argument("Invalid value given for " + varName + ": " + std::string(arg)); 26 | } 27 | if (retval < 0) 28 | { 29 | throw std::invalid_argument("Negative value given for " + varName + ": " + std::string(arg)); 30 | } 31 | return static_cast(retval); 32 | } 33 | 34 | Settings::Settings(int argc, char *argv[], int rank, int nproc) : rank{rank} 35 | { 36 | if (argc < 10) 37 | { 38 | throw std::invalid_argument("Not enough arguments"); 39 | } 40 | this->nproc = (unsigned int)nproc; 41 | 42 | configfile = argv[1]; 43 | outputfile = argv[2]; 44 | npx = convertToUint("N", argv[3]); 45 | npy = convertToUint("M", argv[4]); 46 | ndx = convertToUint("nx", argv[5]); 47 | ndy = convertToUint("ny", argv[6]); 48 | iterations = convertToUint("iterations", argv[7]); 49 | write_freq = convertToUint("write_freq", argv[8]); 50 | read_freq = convertToUint("read_freq", argv[9]); 51 | 52 | if (npx * npy != this->nproc) 53 | { 54 | throw std::invalid_argument("N*M must equal the number of processes"); 55 | } 56 | 57 | // calculate global array size and the local offsets in that global space 58 | gndx = npx * ndx; 59 | gndy = npy * ndy; 60 | posx = rank % npx; 61 | posy = rank / npx; 62 | offsx = posx * ndx; 63 | offsy = posy * ndy; 64 | 65 | // determine neighbors 66 | if (posx == 0) 67 | rank_up = -1; 68 | else 69 | rank_up = rank - 1; 70 | 71 | if (posx == npx - 1) 72 | rank_down = -1; 73 | else 74 | rank_down = rank + 1; 75 | 76 | if (posy == 0) 77 | rank_left = -1; 78 | else 79 | rank_left = rank - npx; 80 | 81 | if (posy == npy - 1) 82 | rank_right = -1; 83 | else 84 | rank_right = rank + npx; 85 | } 86 | -------------------------------------------------------------------------------- /heat_stability/write/Settings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the OSI-approved Apache License, Version 2.0. See 3 | * accompanying file Copyright.txt for details. 4 | * 5 | * Settings.h 6 | * 7 | * Created on: Feb 2017 8 | * Author: Norbert Podhorszki 9 | */ 10 | 11 | #ifndef SETTINGS_H_ 12 | #define SETTINGS_H_ 13 | 14 | #include 15 | 16 | class Settings 17 | { 18 | 19 | public: 20 | // user arguments 21 | std::string configfile; 22 | std::string outputfile; 23 | unsigned int npx; // Number of processes in X (slow) dimension 24 | unsigned int npy; // Number of processes in Y (fast) dimension 25 | unsigned int ndx; // Local array size in X dimension per process 26 | unsigned int ndy; // Local array size in y dimension per process 27 | // unsigned int steps; // Number of output steps 28 | unsigned int iterations; // Number of computing iterations 29 | unsigned int write_freq; // Output step per N iterations 30 | unsigned int read_freq; // Read back data per M iterations 31 | 32 | // calculated values from those arguments and number of processes 33 | unsigned int gndx; // Global array size in slow dimension 34 | unsigned int gndy; // Global array size in fast dimension 35 | // X dim positions: rank 0, npx, 2npx... are in the same X position 36 | // Y dim positions: npx number of consecutive processes belong to one row 37 | // (npx 38 | // columns) 39 | unsigned int posx; // Position of this process in X dimension 40 | unsigned int posy; // Position of this process in Y dimension 41 | unsigned int offsx; // Offset of local array in X dimension on this process 42 | unsigned int offsy; // Offset of local array in Y dimension on this process 43 | 44 | int rank; // MPI rank 45 | unsigned int nproc; // number of processors 46 | 47 | // neighbors by their MPI ranks, -1 if there is no such neighbor 48 | int rank_left; 49 | int rank_right; 50 | int rank_up; 51 | int rank_down; 52 | 53 | /** true: std::async Write, false (default): sync */ 54 | bool async = false; 55 | 56 | Settings(int argc, char *argv[], int rank, int nproc); 57 | }; 58 | 59 | #endif /* SETTINGS_H_ */ 60 | -------------------------------------------------------------------------------- /ssh_config: -------------------------------------------------------------------------------- 1 | Host github 2 | Hostname github.com 3 | User git 4 | IdentityFile /home/adios/.ssh/id_dsa_github 5 | # ProxyCommand corkscrew snowman.ornl.gov 3128 %h %p 6 | 7 | Host bitbucket 8 | Hostname bitbucket.org 9 | User git 10 | IdentityFile /home/adios/.ssh/id_dsa_github 11 | # ProxyCommand corkscrew snowman.ornl.gov 3128 %h %p 12 | 13 | Host * 14 | ServerAliveInterval 120 15 | ServerAliveCountMax 10 16 | # ControlMaster auto 17 | # ControlPath /home/adios/.ssh/ssh_%h 18 | 19 | 20 | -------------------------------------------------------------------------------- /test_pbdR.r: -------------------------------------------------------------------------------- 1 | library(pbdMPI, quiet = TRUE) 2 | init() 3 | x <- comm.rank() 4 | comm.print(x, all.rank = TRUE) 5 | finalize() 6 | -------------------------------------------------------------------------------- /vimrc: -------------------------------------------------------------------------------- 1 | " Use Vim settings, rather then Vi settings (much better!). 2 | " This must be first, because it changes other options as a side effect. 3 | set nocompatible 4 | 5 | " allow backspacing over everything in insert mode 6 | set backspace=indent,eol,start 7 | 8 | set autoindent 9 | set cindent 10 | " use space instead of TABs, 4 spaces each 11 | set shiftwidth=4 12 | set softtabstop=4 13 | set expandtab 14 | " for Makefiles, use real tab characters 15 | "autocmd FileType make setlocal noexpandtab 16 | " remap Shift+Tab to insert real TAB character 17 | inoremap 18 | 19 | 20 | " statusline that displays the current cursor position 21 | set ruler 22 | 23 | " briefly jump to a brace/parenthese/bracket's match 24 | " whenever you type a closing or opening brace/parenthese/bracket 25 | set showmatch 26 | 27 | " syntax highlighting 28 | syntax enable 29 | 30 | " Search options 31 | " -------------- 32 | " case insensitive search for small-case strings 33 | set ignorecase 34 | " but case sensitive search if capitals are given in the search string 35 | set smartcase 36 | " highlight all occurences of the searched string 37 | set hlsearch 38 | " jump to first occurence when typing a search string 39 | set incsearch 40 | 41 | " remember positions in files and jump there when opening again 42 | if has("autocmd") 43 | autocmd BufReadPost * 44 | \ if line("'\"") > 0 && line("'\"") <= line("$") | 45 | \ exe "normal g`\"" | 46 | \ endif 47 | endif 48 | -------------------------------------------------------------------------------- /xgc-f0-compression/.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: LLVM 3 | BreakBeforeBraces: Custom 4 | ConstructorInitializerIndentWidth: 0 5 | IndentWidth: 4 6 | ContinuationIndentWidth: 4 7 | AccessModifierOffset: -4 8 | AlwaysBreakTemplateDeclarations: true 9 | CompactNamespaces: false 10 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 11 | FixNamespaceComments: false 12 | Standard: Cpp11 13 | ColumnLimit: 110 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AlignEscapedNewlines: Right 16 | AlignAfterOpenBracket: Align 17 | SortUsingDeclarations: false 18 | BraceWrapping: 19 | AfterClass: true 20 | AfterControlStatement: true 21 | AfterEnum: true 22 | AfterExternBlock: false 23 | AfterFunction: true 24 | AfterNamespace: true 25 | AfterStruct: true 26 | AfterUnion: true 27 | BeforeCatch: true 28 | BeforeElse: true 29 | SplitEmptyFunction: true 30 | SplitEmptyRecord: true 31 | SplitEmptyNamespace: false 32 | -------------------------------------------------------------------------------- /xgc-f0-compression/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "/opt/adios2/include", 8 | "/opt/kokkos/3.7.1/include", 9 | "/opt/mgard/include", 10 | "/usr/include/x86_64-linux-gnu/mpi" 11 | ], 12 | "defines": [ 13 | "ENABLE_TIMERS", 14 | "ADIOS2_USE_MPI=1" 15 | ], 16 | "compilerPath": "/usr/bin/gcc", 17 | "cStandard": "gnu17", 18 | "cppStandard": "gnu++14", 19 | "intelliSenseMode": "gcc-x64", 20 | "configurationProvider": "ms-vscode.cmake-tools" 21 | } 22 | ], 23 | "version": 4 24 | } -------------------------------------------------------------------------------- /xgc-f0-compression/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.includePath": [${default 3 | } 4 | ], 5 | "cmake.configureOnOpen": false, 6 | "clang-format.executable": "/home/adios/bin/clang-format", 7 | "editor.formatOnSave": true, 8 | } -------------------------------------------------------------------------------- /xgc-f0-compression/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.10) 2 | project (XGCF0CompressionTest) 3 | 4 | find_package(Kokkos REQUIRED) 5 | find_package(MGARD REQUIRED) 6 | find_package(ZFP REQUIRED) 7 | find_package(ADIOS2 REQUIRED COMPONENTS CXX MPI) 8 | 9 | add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX) 10 | 11 | 12 | add_executable(xgc-f0-compression xgc-f0-compression.cpp) 13 | target_link_libraries(xgc-f0-compression Kokkos::kokkos mgard::mgard adios2::adios2 MPI::MPI_C) 14 | 15 | add_executable(xgc-f0-compression-cpu xgc-f0-compression-cpu.cpp) 16 | target_link_libraries(xgc-f0-compression-cpu Kokkos::kokkos adios2::adios2 MPI::MPI_C) 17 | 18 | add_executable(xgc-f0-compression-vec xgc-f0-compression-vec.cpp) 19 | target_link_libraries(xgc-f0-compression-vec Kokkos::kokkos adios2::adios2 MPI::MPI_C) 20 | 21 | add_executable(xgc-f0-compression-adioscompression xgc-f0-compression-adioscompression.cpp) 22 | target_link_libraries(xgc-f0-compression-adioscompression Kokkos::kokkos adios2::adios2 MPI::MPI_C) 23 | 24 | add_executable(nrmse nrmse.cpp) 25 | target_link_libraries(nrmse adios2::cxx11) 26 | -------------------------------------------------------------------------------- /xgc-f0-compression/adios2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 33 | 34 | 35 | 36 | 37 | --------------------------------------------------------------------------------