├── .clang-format ├── .clang-tidy ├── .gitignore ├── .mailmap ├── CMakeLists.txt ├── LICENSE ├── README.md ├── checksum ├── checksum_GHJUB2013SRGHJUB2017SIMSR_fourdbin ├── checksum__filemake ├── checksum_bigns_concatenate ├── checksum_bigns_creadwrite ├── checksum_bigns_makerep ├── checksum_bigns_minmax ├── checksum_bigns_segsort ├── checksum_medium_concatenate ├── checksum_medium_creadwrite ├── checksum_medium_makerep ├── checksum_medium_minmax ├── checksum_medium_segsort ├── checksum_one_concatenate ├── checksum_one_creadwrite ├── checksum_one_makerep ├── checksum_one_minmax ├── checksum_one_segsort ├── checksum_small_concatenate ├── checksum_small_creadwrite ├── checksum_small_makerep ├── checksum_small_minmax ├── checksum_small_segsort ├── checksum_zero_concatenate ├── checksum_zero_creadwrite ├── checksum_zero_makerep ├── checksum_zero_minmax └── checksum_zero_segsort ├── compare.sh ├── compiler.cfg ├── doc ├── CMakeLists.txt ├── Doxyfile.in ├── dissemination │ ├── EAGE_Upstream_2017.pdf │ ├── Rice_HPC_O&G_2017.pdf │ └── Rice_HPC_O&G_2018_Poster.pdf ├── namespaces.dox └── parse_example.cmake ├── examples ├── CMakeLists.txt ├── README.md ├── creadwrite.c ├── example1.c ├── example1.cc ├── example2.c ├── exampleCreateFile.c ├── exampleCreateFile.cc ├── exampleFilterTaper.cc ├── exampleSort.c ├── exampleSort.cc ├── hello_world.c ├── minmax.c ├── minmax.cc ├── modprm.c ├── sort.c └── sort.cc ├── include └── ExSeisDat │ ├── Flow.h │ ├── Flow.hh │ ├── Flow │ ├── Cache.hh │ ├── CacheElem.hh │ ├── FileDesc.hh │ ├── FuncOpt.hh │ ├── GatherState.hh │ ├── Op.hh │ ├── OpOpt.hh │ ├── OpParent.hh │ ├── RadonGatherState.hh │ ├── Set.hh │ └── TraceBlock.hh │ ├── PIOL.h │ ├── PIOL.hh │ ├── PIOL │ ├── CommunicatorInterface.hh │ ├── CommunicatorMPI.hh │ ├── DataInterface.hh │ ├── DataMPIIO.hh │ ├── ExSeis.hh │ ├── ExSeisPIOL.hh │ ├── Logger.hh │ ├── Meta.h │ ├── Model3dInterface.hh │ ├── ObjectInterface.hh │ ├── ObjectSEGY.hh │ ├── Param.h │ ├── ReadDirect.hh │ ├── ReadInterface.hh │ ├── ReadModel.hh │ ├── ReadSEGY.hh │ ├── ReadSEGYModel.hh │ ├── Rule.hh │ ├── RuleEntry.hh │ ├── SEGYRuleEntry.hh │ ├── SortType.h │ ├── Tr.h │ ├── Verbosity.h │ ├── WriteDirect.hh │ ├── WriteInterface.hh │ ├── WriteSEGY.hh │ ├── makeFile.hh │ ├── operations │ │ ├── gather.hh │ │ ├── minmax.h │ │ ├── sort.hh │ │ └── temporalfilter.hh │ ├── param_utils.hh │ └── segy_utils.hh │ └── utils │ ├── Distributed_vector.hh │ ├── c_api_utils.h │ ├── decomposition │ └── block_decomposition.h │ ├── encoding │ ├── character_encoding.hh │ └── number_encoding.hh │ ├── mpi │ ├── MPI_Distributed_vector.hh │ ├── MPI_error_to_string.hh │ ├── MPI_max_array_length.hh │ └── MPI_type.hh │ ├── signal_processing │ ├── AGC.h │ ├── Gain_function.h │ ├── Taper_function.h │ └── taper.h │ └── typedefs.h ├── scripts ├── format.sh ├── lint.sh ├── mod_gnu ├── mod_intel ├── run_format.sh └── run_lint.sh ├── src ├── CommunicatorMPI.cc ├── DataMPIIO.cc ├── ExSeis.cc ├── ExSeisPIOL.cc ├── Flow │ ├── Cache.cc │ ├── Flow_C_bindings.cc │ ├── RadonGatherState.cc │ └── Set.cc ├── Logger.cc ├── ObjectInterface.cc ├── ObjectSEGY.cc ├── PIOL_C_bindings.cc ├── Param.cc ├── ReadDirect.cc ├── ReadInterface.cc ├── ReadModel.cc ├── ReadSEGY.cc ├── ReadSEGYModel.cc ├── Rule.cc ├── WriteDirect.cc ├── WriteInterface.cc ├── WriteSEGY.cc ├── gather.cc ├── minmax.cc ├── not_null.hh ├── param_utils.cc ├── segy_utils.cc ├── sort.cc ├── temporalfilter.cc └── utils │ ├── decomposition │ └── block_decomposition.cc │ ├── encoding │ ├── character_encoding.cc │ └── number_encoding.cc │ ├── mpi │ └── MPI_error_to_string.cc │ └── signal_processing │ ├── AGC.cc │ ├── Gain_function.cc │ ├── Taper_function.cc │ └── taper.cc ├── systest ├── README ├── example_combo0 ├── example_combo1 ├── extra_testmatrix_0param ├── extra_testmatrix_1param ├── farm.sh ├── genfiles.pbs ├── main.cc ├── make.sh ├── makefile ├── md5sum.sh ├── process.sh ├── que.sh ├── runtest.pbs ├── temp │ └── .gitignore ├── test_0_cexample1.sh ├── test_0_example1.sh ├── test_0_filemake.sh ├── test_1_cexample2.sh ├── test_1_concatenate.sh ├── test_1_creadwrite.sh ├── test_1_makerep.sh ├── test_1_minmax.sh ├── test_1_segsort.sh ├── test_2_fourdbin.sh ├── testmatrix_0param ├── testmatrix_1param ├── testmatrix_2param └── warncheck.sh ├── test ├── CMakeLists.txt ├── README.md ├── cwraptests │ └── main.c ├── extract.c ├── genfiles.c ├── googletest-release-1.8.0.zip ├── spectests │ ├── data.cc │ ├── datampiioread.cc │ ├── datampiiotest.hh │ ├── datampiiowrite.cc │ ├── datatype.cc │ ├── dynsegymd.cc │ ├── dynsegymdtest.hh │ ├── file.cc │ ├── filesegyintegread.cc │ ├── filesegyintegwrite.cc │ ├── filesegyread.cc │ ├── filesegytest.hh │ ├── filesegywrite.cc │ ├── main.cc │ ├── objsegyintegread.cc │ ├── objsegyintegwrite.cc │ ├── objsegymeta.cc │ ├── objsegyread.cc │ ├── objsegytest.hh │ ├── objsegywrite.cc │ ├── opstest.cc │ ├── segy.cc │ ├── segymd.cc │ ├── segymdextra.cc │ ├── segymdextra.hh │ ├── selftests.cc │ ├── set.cc │ ├── settest.hh │ ├── tglobal.cc │ └── tglobal.hh └── wraptests │ ├── checkreturnlistener.cc │ ├── checkreturnlistener.hh │ ├── compare_symbols.sh │ ├── exseis.cc │ ├── exseiswraptest.cc │ ├── exseiswraptest.hh │ ├── getminmax.cc │ ├── getminmaxwraptests.cc │ ├── getminmaxwraptests.hh │ ├── googletest_variable_instances.cc │ ├── googletest_variable_instances.hh │ ├── intercepted_c_bindings.cc │ ├── mockexseis.cc │ ├── mockexseis.hh │ ├── mockgetminmax.cc │ ├── mockgetminmax.hh │ ├── mockparam.cc │ ├── mockparam.hh │ ├── mockreaddirect.cc │ ├── mockreaddirect.hh │ ├── mockrule.cc │ ├── mockrule.hh │ ├── mockset.cc │ ├── mockset.hh │ ├── mockwritedirect.cc │ ├── mockwritedirect.hh │ ├── param.cc │ ├── paramwraptests.cc │ ├── paramwraptests.hh │ ├── printers.cc │ ├── printers.hh │ ├── readdirect.cc │ ├── readdirectwraptests.cc │ ├── readdirectwraptests.hh │ ├── rule.cc │ ├── rulewraptests.cc │ ├── rulewraptests.hh │ ├── set.cc │ ├── setwraptests.cc │ ├── setwraptests.hh │ ├── wraptests.cc │ ├── wraptests.h │ ├── wraptesttools.cc │ ├── wraptesttools.hh │ ├── writedirect.cc │ ├── writedirectwraptests.cc │ └── writedirectwraptests.hh └── util ├── 4d.hh ├── 4dcore.cc ├── 4dcore.hh ├── 4dio.cc ├── 4dio.hh ├── CMakeLists.txt ├── assess.cc ├── concatenate.cc ├── cropen.c ├── filemake.cc ├── fourdbin.cc ├── makerep.cc ├── metaseg ├── minmax.cc ├── radon.cc ├── segy2kml.cc ├── sglobal.cc ├── sglobal.hh ├── sort.cc ├── traceanalysis.cc └── verifysort.cc /.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: 'clang-diagnostic-*,clang-analyzer-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-security.insecureAPI.rand,readability-braces-around-statements,readability-avoid-const-params-in-decls,readability-redundant-string-init,readability-container-size-empty,readability-implicit-bool-conversion' 3 | WarningsAsErrors: '' 4 | HeaderFilterRegex: '' 5 | AnalyzeTemporaryDtors: false 6 | FormatStyle: none 7 | User: ExSeisDat 8 | CheckOptions: 9 | - key: google-readability-braces-around-statements.ShortStatementLines 10 | value: '1' 11 | - key: google-readability-function-size.StatementThreshold 12 | value: '800' 13 | - key: google-readability-namespace-comments.ShortNamespaceLines 14 | value: '10' 15 | - key: google-readability-namespace-comments.SpacesBeforeComments 16 | value: '2' 17 | - key: modernize-loop-convert.MaxCopySize 18 | value: '16' 19 | - key: modernize-loop-convert.MinConfidence 20 | value: reasonable 21 | - key: modernize-loop-convert.NamingStyle 22 | value: CamelCase 23 | - key: modernize-pass-by-value.IncludeStyle 24 | value: llvm 25 | - key: modernize-replace-auto-ptr.IncludeStyle 26 | value: llvm 27 | - key: modernize-use-nullptr.NullMacros 28 | value: 'NULL' 29 | - key: readability-braces-around-statements.ShortStatementLines 30 | value: '0' 31 | - key: readability-implicit-bool-conversion.AllowIntegerConditions 32 | value: '0' 33 | - key: readability-implicit-bool-conversion.AllowPointerConditions 34 | value: '0' 35 | ... 36 | 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Vim swap files 2 | *.swp 3 | 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | 2 | Cathal O Broin Cathal 3 | Cathal O Broin Cathal O Broin 4 | 5 | 6 | -------------------------------------------------------------------------------- /checksum/checksum_GHJUB2013SRGHJUB2017SIMSR_fourdbin: -------------------------------------------------------------------------------- 1 | b9a6d2be8e00f6f4e0b94d212d3aba8d 2 | aa46866d0b75350bd239de208b8b213b 3 | -------------------------------------------------------------------------------- /checksum/checksum__filemake: -------------------------------------------------------------------------------- 1 | c7f6025cee2fcdc1808e3611d85a1a5f 2 | -------------------------------------------------------------------------------- /checksum/checksum_bigns_concatenate: -------------------------------------------------------------------------------- 1 | b097c4764f49a08ed6c1fabb0eea1239 2 | -------------------------------------------------------------------------------- /checksum/checksum_bigns_creadwrite: -------------------------------------------------------------------------------- 1 | cce480afd06cb35aa0db2a65d2904e8f 2 | -------------------------------------------------------------------------------- /checksum/checksum_bigns_makerep: -------------------------------------------------------------------------------- 1 | a88913d80bb8b846898d0571933c89e1 2 | -------------------------------------------------------------------------------- /checksum/checksum_bigns_minmax: -------------------------------------------------------------------------------- 1 | 51eccc43ce1aac637bf16aabb6cdc3f9 2 | -------------------------------------------------------------------------------- /checksum/checksum_bigns_segsort: -------------------------------------------------------------------------------- 1 | 81ce8b3bcf4ce90f81509f92ad3fdc75 2 | -------------------------------------------------------------------------------- /checksum/checksum_medium_concatenate: -------------------------------------------------------------------------------- 1 | c855d9805f53b95a197d0e7ef66aac63 2 | -------------------------------------------------------------------------------- /checksum/checksum_medium_creadwrite: -------------------------------------------------------------------------------- 1 | 0ac4824967d5f04445ac686b15b34a91 2 | -------------------------------------------------------------------------------- /checksum/checksum_medium_makerep: -------------------------------------------------------------------------------- 1 | b02d071e8b0098a054fa59f9ebaedf77 2 | -------------------------------------------------------------------------------- /checksum/checksum_medium_minmax: -------------------------------------------------------------------------------- 1 | c551ea8ee0f83a8907dd2b41cd859bfe 2 | -------------------------------------------------------------------------------- /checksum/checksum_medium_segsort: -------------------------------------------------------------------------------- 1 | 81c425f37c676f0ede507d9a65d7b55b 2 | -------------------------------------------------------------------------------- /checksum/checksum_one_concatenate: -------------------------------------------------------------------------------- 1 | 8a68a37d7f1c7f68d865853800850de3 2 | -------------------------------------------------------------------------------- /checksum/checksum_one_creadwrite: -------------------------------------------------------------------------------- 1 | 5aeb248b8f6deca0d337fa7349bc0d15 2 | -------------------------------------------------------------------------------- /checksum/checksum_one_makerep: -------------------------------------------------------------------------------- 1 | 0708e9cd43e1710180bff2130de03f10 2 | -------------------------------------------------------------------------------- /checksum/checksum_one_minmax: -------------------------------------------------------------------------------- 1 | 5a1e40abace0169e92cea7a8dee2c75b 2 | -------------------------------------------------------------------------------- /checksum/checksum_one_segsort: -------------------------------------------------------------------------------- 1 | a384172f0d621ee04b7f4e6ae34f42f0 2 | -------------------------------------------------------------------------------- /checksum/checksum_small_concatenate: -------------------------------------------------------------------------------- 1 | 80268e35c6725ff8028b4f4b9c3c2043 2 | -------------------------------------------------------------------------------- /checksum/checksum_small_creadwrite: -------------------------------------------------------------------------------- 1 | c1eefa6e17e1ad328d025efccb8c7e52 2 | -------------------------------------------------------------------------------- /checksum/checksum_small_makerep: -------------------------------------------------------------------------------- 1 | 0bc56ac30982b00682fb399d8207d02e 2 | -------------------------------------------------------------------------------- /checksum/checksum_small_minmax: -------------------------------------------------------------------------------- 1 | da5752652a558dff19ca456c3fa426ec 2 | -------------------------------------------------------------------------------- /checksum/checksum_small_segsort: -------------------------------------------------------------------------------- 1 | 8bca7da79d02e687966072a54af47201 2 | -------------------------------------------------------------------------------- /checksum/checksum_zero_concatenate: -------------------------------------------------------------------------------- 1 | 4bb331445d4f058b587ae2423f6114ed 2 | -------------------------------------------------------------------------------- /checksum/checksum_zero_creadwrite: -------------------------------------------------------------------------------- 1 | 38351c8145e91390214da0b12148c564 2 | -------------------------------------------------------------------------------- /checksum/checksum_zero_makerep: -------------------------------------------------------------------------------- 1 | bbcc5200adab24d87e0ccd69eef79181 2 | -------------------------------------------------------------------------------- /checksum/checksum_zero_minmax: -------------------------------------------------------------------------------- 1 | f24b90329db7526a94a52e75f0173bf4 2 | -------------------------------------------------------------------------------- /checksum/checksum_zero_segsort: -------------------------------------------------------------------------------- 1 | bbcc5200adab24d87e0ccd69eef79181 2 | -------------------------------------------------------------------------------- /compare.sh: -------------------------------------------------------------------------------- 1 | dd if=$1 bs=4096k | { dd bs=3600 count=1 of=/dev/null; dd bs=4096k of=bench.segy; } 2 | dd if=$2 bs=4096k | { dd bs=3600 count=1 of=/dev/null; dd bs=4096k of=bench2.segy; } 3 | 4 | size=$(stat --print="%s" bench.segy) 5 | md5sum bench.segy 6 | 7 | split -b $size bench2.segy splitout. 8 | md5sum splitout.* 9 | 10 | rm bench.segy bench2.segy splitout.* 11 | 12 | md5sum $2 13 | -------------------------------------------------------------------------------- /compiler.cfg: -------------------------------------------------------------------------------- 1 | # Basic settings 2 | # TODO: profiler guided optimisation (PGO) 3 | # 4 | SHELL := /bin/bash 5 | System=$(PIOL_SYSTEM) 6 | #CXX=mpicxx 7 | 8 | CXX=mpicxx 9 | CC=mpicc 10 | 11 | ICONV_LIB_FLAG=-liconv 12 | 13 | ifeq "$(strip $(I_MPI_CXX))" "icpc" #intel 14 | LOWER_PRECISION = -fp-model fast=2 -no-prec-sqrt -fimf-precision:low 15 | OPTIMISATIONS = -align -xHost -O3 -fopenmp -fno-alias -qopt-report=5 -qopt-report-phase=vec # -ipo $(LOWER_PRECISION) # 16 | FFTW_LIB_FLAG=-mkl 17 | LIB_FLAG=-shared-intel -shared-libgcc $(FFTW_LIB_FLAG) 18 | else #gnu 19 | OPTIMISATIONS = -mtune=native -march=native -O1 -funroll-loops -fopenmp 20 | #OPTIMISATIONS = -O0 -fopenmp -ffloat-store 21 | FFTW_LIB_FLAG=-lfftw3f 22 | LIB_FLAG=$(FFTW_LIB_FLAG) $(ICONV_LIB_FLAG) 23 | endif 24 | 25 | WARNINGS = -Wall -Wextra -pedantic 26 | DEBUG = -g #-DDEBUG 27 | CXXSTANDARD=-std=c++17 28 | CSTANDARD=-std=c99 29 | COLLECTIVES=-DMPIIO_COLLECTIVES 30 | 31 | API_FOLDER=-I../api/ 32 | CXXINC_FOLDER=-I../include/ $(COLLECTIVES) $(API_FOLDER) 33 | CINC_FOLDER=-I../include/ $(API_FOLDER) 34 | 35 | #CXXFLAGS = $(CXXSTANDARD) $(WARNINGS) $(DEBUG) $(OPTIMISATIONS) $(CXXINC_FOLDER) -fprofile-arcs -ftest-coverage -fmax-errors=1 -Werror=implicit-function-declaration -fsanitize=address -fno-omit-frame-pointer 36 | #CFLAGS = $(CSTANDARD) $(WARNINGS) $(DEBUG) $(OPTIMISATIONS) -fprofile-arcs -ftest-coverage -fmax-errors=1 -Werror=implicit-function-declaration -fsanitize=address 37 | 38 | #CXXFLAGS = $(CXXSTANDARD) $(WARNINGS) $(DEBUG) $(OPTIMISATIONS) $(CXXINC_FOLDER) -fprofile-arcs -ftest-coverage -fmax-errors=1 -Werror=implicit-function-declaration -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls 39 | CXXFLAGS = $(CXXSTANDARD) $(WARNINGS) $(DEBUG) $(OPTIMISATIONS) $(CXXINC_FOLDER) -fprofile-arcs -ftest-coverage -fmax-errors=1 -Werror=implicit-function-declaration -Wno-ignored-qualifiers 40 | #CFLAGS = $(CSTANDARD) $(WARNINGS) $(DEBUG) $(OPTIMISATIONS) -fprofile-arcs -ftest-coverage -fmax-errors=1 -Werror=implicit-function-declaration -fsanitize=address 41 | CFLAGS = $(CSTANDARD) $(WARNINGS) $(DEBUG) $(OPTIMISATIONS) -fprofile-arcs -ftest-coverage -fmax-errors=1 -Werror=implicit-function-declaration 42 | 43 | ifeq "$(strip $(System))" "Tullow" 44 | ##Work arounds for Tullow's Marine cluster: 45 | TULLOW_LIBS=/apps/intel/2016/compilers_and_libraries_2016.0.109/linux/compiler/lib/intel64/libintlc.so.5 46 | endif 47 | 48 | LIBS=-L../lib -lpiol -lipiol $(TULLOW_LIBS) $(FFTW_LIB_FLAG) $(ICONV_LIB_FLAG) #-lOpenCL 49 | CXXLDFLAGS=$(LIBS) $(IMELD_FLAG) $(CXXINC_FOLDER) 50 | CLDFLAGS=$(LIBS) $(CINC_FOLDER) 51 | 52 | LIB_DIR=../lib 53 | 54 | 55 | -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Doxygen REQUIRED) 2 | 3 | # Write a Doxyfile including the main doc/Doxyfile. 4 | # This sets the @INCLUDE_PATH variable to the project root. 5 | configure_file( 6 | ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in 7 | ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 8 | @ONLY 9 | ) 10 | 11 | # Get list of examples (files ending in .c or .cc) 12 | file( 13 | GLOB EXSEISDAT_EXAMPLES 14 | RELATIVE ${CMAKE_SOURCE_DIR}/examples/ 15 | ${CMAKE_SOURCE_DIR}/examples/*.c 16 | ${CMAKE_SOURCE_DIR}/examples/*.cc 17 | ) 18 | 19 | # Loop over examples files, adding rules to turn them into their documented and 20 | # clean versions. 21 | # Keep a list of the documented versions so we can add them as dependencies to 22 | # the documentation generation. 23 | set(EXSEISDAT_DOCUMENTED_EXAMPLES) 24 | foreach(example IN LISTS EXSEISDAT_EXAMPLES) 25 | 26 | # Add documented and clean example generation rule 27 | add_custom_command( 28 | OUTPUT 29 | ${CMAKE_CURRENT_BINARY_DIR}/examples/documented/${example}.md 30 | ${CMAKE_CURRENT_BINARY_DIR}/examples/clean/${example} 31 | 32 | COMMAND 33 | ${CMAKE_COMMAND} 34 | -DINPUT_FILENAME=${CMAKE_SOURCE_DIR}/examples/${example} 35 | -DOUTPUT_DOC_FILENAME=${CMAKE_CURRENT_BINARY_DIR}/examples/documented/${example}.md 36 | -DOUTPUT_CLEAN_FILENAME=${CMAKE_CURRENT_BINARY_DIR}/examples/clean/${example} 37 | -P ${CMAKE_CURRENT_SOURCE_DIR}/parse_example.cmake 38 | 39 | MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/examples/${example} 40 | ) 41 | 42 | # Add documented file to the list 43 | list( 44 | APPEND EXSEISDAT_DOCUMENTED_EXAMPLES 45 | ${CMAKE_CURRENT_BINARY_DIR}/examples/documented/${example}.md 46 | ) 47 | endforeach(example IN LISTS EXSEISDAT_EXAMPLES) 48 | 49 | # Custom command to run doxygen on build/doc/Doxyfile in the build/doc dir. 50 | # Running doxygen is tied to the html/index.html file. 51 | # TODO: The main dependency is currently doc/Doxyfile, but there should be 52 | # a depencency on *every* file being documented! 53 | add_custom_command( 54 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html 55 | COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" 56 | MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in 57 | DEPENDS ${EXSEISDAT_DOCUMENTED_EXAMPLES} 58 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 59 | COMMENT "Building the documentation..." 60 | ) 61 | 62 | # Target to wire up building the documentation to the ALL target. 63 | add_custom_target( 64 | doc ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/index.html 65 | ) 66 | 67 | # Set install target 68 | # Pro tip: To build and install just the documentation, 69 | install( 70 | DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html 71 | DESTINATION ${EXSEISDAT_INSTALL_DOCDIR} 72 | ) 73 | -------------------------------------------------------------------------------- /doc/Doxyfile.in: -------------------------------------------------------------------------------- 1 | # Doxyfile 1.8.13 2 | 3 | # 4 | # This is a template file used for configuration in doc/CMakeLists.txt. 5 | # 6 | 7 | PROJECT_NAME = ExSeisDat 8 | 9 | # The PROJECT_NUMBER tag can be used to enter a project or revision number. This 10 | # could be handy for archiving the generated documentation or if some version 11 | # control system is used. 12 | 13 | PROJECT_NUMBER = @ExSeisDat_VERSION@ 14 | 15 | # Extraction options 16 | EXTRACT_PRIVATE = YES 17 | EXTRACT_PACKAGE = YES 18 | EXTRACT_STATIC = YES 19 | EXTRACT_LOCAL_METHODS = YES 20 | EXTRACT_ANON_NSPACES = YES 21 | 22 | # Generate case sensitive filenames 23 | CASE_SENSE_NAMES = YES 24 | 25 | # Warning options 26 | # Warn on everything possible, and fail on warning 27 | QUIET = NO 28 | WARNINGS = YES 29 | WARN_IF_UNDOCUMENTED = YES 30 | WARN_IF_DOC_ERROR = YES 31 | WARN_NO_PARAMDOC = YES 32 | WARN_AS_ERROR = YES 33 | 34 | # Input directories 35 | INPUT = \ 36 | @CMAKE_SOURCE_DIR@/doc/namespaces.dox \ 37 | @CMAKE_SOURCE_DIR@/src \ 38 | @CMAKE_SOURCE_DIR@/include \ 39 | @CMAKE_SOURCE_DIR@/api \ 40 | @CMAKE_SOURCE_DIR@/util \ 41 | @CMAKE_SOURCE_DIR@/README.md \ 42 | @CMAKE_CURRENT_BINARY_DIR@/examples/documented \ 43 | @CMAKE_SOURCE_DIR@/examples/README.md 44 | 45 | EXAMPLE_PATH = \ 46 | @CMAKE_CURRENT_BINARY_DIR@/examples/clean 47 | 48 | RECURSIVE = YES 49 | 50 | # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that 51 | # is part of the input, its contents will be placed on the main page 52 | # (index.html). This can be useful if you have a project on for instance GitHub 53 | # and want to reuse the introduction page also for the doxygen output. 54 | 55 | USE_MDFILE_AS_MAINPAGE = @CMAKE_SOURCE_DIR@/README.md 56 | 57 | # Documentation presentation options 58 | SOURCE_BROWSER = YES 59 | INLINE_SOURCES = YES 60 | 61 | # HTML output options 62 | GENERATE_HTML = YES 63 | HTML_OUTPUT = html 64 | HTML_FILE_EXTENSION = .html 65 | GENERATE_TREEVIEW = YES 66 | 67 | # Latex font size 68 | FORMULA_FONTSIZE = 10 69 | 70 | # Latex rendering: use images 71 | USE_MATHJAX = NO 72 | 73 | # Make search engine without server 74 | SEARCHENGINE = YES 75 | SERVER_BASED_SEARCH = NO 76 | 77 | # Don't generate latex or manpage, but we might in future 78 | GENERATE_LATEX = NO 79 | GENERATE_MAN = NO 80 | 81 | # Macro options 82 | ENABLE_PREPROCESSING = YES 83 | MACRO_EXPANSION = YES 84 | PREDEFINED = __cplusplus 85 | SEARCH_INCLUDES = YES 86 | INCLUDE_PATH = 87 | -------------------------------------------------------------------------------- /doc/dissemination/EAGE_Upstream_2017.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ICHEC/ExSeisDat/3c6acb883985043293d8a40caaca743e7b8eaa33/doc/dissemination/EAGE_Upstream_2017.pdf -------------------------------------------------------------------------------- /doc/dissemination/Rice_HPC_O&G_2017.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ICHEC/ExSeisDat/3c6acb883985043293d8a40caaca743e7b8eaa33/doc/dissemination/Rice_HPC_O&G_2017.pdf -------------------------------------------------------------------------------- /doc/dissemination/Rice_HPC_O&G_2018_Poster.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ICHEC/ExSeisDat/3c6acb883985043293d8a40caaca743e7b8eaa33/doc/dissemination/Rice_HPC_O&G_2018_Poster.pdf -------------------------------------------------------------------------------- /doc/namespaces.dox: -------------------------------------------------------------------------------- 1 | // This file contains the documentation for the various namespaces in the 2 | // ExSeisDat project. 3 | 4 | /// 5 | /// @namespace exseis 6 | /// 7 | /// @brief The ExSeisDat library: High-Performance, Parallel Processing of 8 | /// Seismic Data. 9 | /// 10 | 11 | /// 12 | /// @namespace exseis::utils 13 | /// 14 | /// @brief Utility classes and functions. 15 | /// 16 | /// @details The exseis::utils class contains utility functions for parallel 17 | /// programming, seismic data processing, converting between data types 18 | /// etc. 19 | /// 20 | 21 | /// 22 | /// @namespace exseis::PIOL 23 | /// 24 | /// @brief %ExSeisPIOL: A High-Performance Parallel Seismic file I/O library. 25 | /// 26 | /// @details The %ExSeisPIOL library is an 27 | /// Extreme-scale 28 | /// Seismic 29 | /// Parallel 30 | /// I/O 31 | /// Library. 32 | /// It primarily handles high-performance, parallel I/O of seismic data 33 | /// files. 34 | /// 35 | 36 | /// 37 | /// @namespace exseis::Flow 38 | /// 39 | /// @brief %ExSeisFlow: A High-Performance, Parallel Seismic Workflow library. 40 | /// 41 | /// @details The ExSeisFlow library is a seismic data workflow library that 42 | /// leverages %ExSeisPIOL for fast, parallel I/O, and uses workflow 43 | /// optimizations and smart caching to minimize I/O bandwidth and 44 | /// memory usage. 45 | /// 46 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Add the example executables 3 | # 4 | 5 | # Link exseisdat to all executables defined here 6 | link_libraries(exseisdat) 7 | 8 | # Macro calls add_executable with the passed arguments, and adds the executable 9 | # target to EXSEISDAT_EXAMPLE_EXES. 10 | set(EXSEISDAT_EXAMPLE_EXES) 11 | macro(examples_add_executable) 12 | add_executable(${ARGV}) 13 | list(APPEND EXSEISDAT_EXAMPLE_EXES ${ARGV0}) 14 | endmacro(examples_add_executable) 15 | 16 | examples_add_executable(hello_world hello_world.c) 17 | 18 | examples_add_executable(creadwrite creadwrite.c) 19 | 20 | examples_add_executable(example1 example1.cc) 21 | examples_add_executable(cexample1 example1.c) 22 | 23 | examples_add_executable(cexample2 example2.c) 24 | 25 | examples_add_executable(minmax minmax.cc) 26 | examples_add_executable(cminmax minmax.c) 27 | 28 | examples_add_executable(modprm modprm.c) 29 | 30 | examples_add_executable(sort sort.cc) 31 | examples_add_executable(csort sort.c) 32 | 33 | examples_add_executable(exampleCreateFile exampleCreateFile.cc) 34 | examples_add_executable(cexampleCreateFile exampleCreateFile.c) 35 | 36 | examples_add_executable(exampleFilterTaper exampleFilterTaper.cc) 37 | 38 | examples_add_executable(cexampleSort exampleSort.c) 39 | examples_add_executable(exampleSort exampleSort.cc) 40 | 41 | 42 | # 43 | # Install the example executables 44 | # 45 | set( 46 | EXSEISDAT_INSTALL_EXAMPLES OFF CACHE BOOL 47 | "Set whether or not the ExSeisDat example programs should be installed." 48 | ) 49 | if(EXSEISDAT_INSTALL_EXAMPLES) 50 | set( 51 | EXSEISDAT_EXAMPLES_BINDIR 52 | ${CMAKE_INSTALL_LIBEXECDIR}/exseisdat/examples CACHE STRING 53 | "The directory to install the ExSeisDat example programs to." 54 | ) 55 | 56 | install( 57 | TARGETS ${EXSEISDAT_EXAMPLE_EXES} 58 | RUNTIME DESTINATION ${EXSEISDAT_EXAMPLES_BINDIR} 59 | ) 60 | 61 | endif(EXSEISDAT_INSTALL_EXAMPLES) 62 | -------------------------------------------------------------------------------- /examples/example1.cc: -------------------------------------------------------------------------------- 1 | /// 2 | /// Example: example1.cc {#examples_example1_cc} 3 | /// ==================== 4 | /// 5 | /// @todo DOCUMENT ME - Finish documenting example. 6 | /// 7 | /// This example shows how to make a new file with the file api is complete. 8 | /// 9 | 10 | #include "ExSeisDat/PIOL.hh" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace exseis::utils; 19 | using namespace exseis::PIOL; 20 | 21 | int main(int argc, char** argv) 22 | { 23 | std::string opt = "o:"; // TODO: uses a GNU extension 24 | std::string name; 25 | for (int c = getopt(argc, argv, opt.c_str()); c != -1; 26 | c = getopt(argc, argv, opt.c_str())) { 27 | if (c == 'o') { 28 | name = optarg; 29 | } 30 | else { 31 | std::cerr << "One of the command line arguments is invalid" 32 | << std::endl; 33 | return -1; 34 | } 35 | } 36 | assert(!name.empty()); 37 | 38 | // Initialise the PIOL by creating an ExSeisPIOL object 39 | auto piol = ExSeis::New(); 40 | 41 | // Create a SEGY file object 42 | WriteDirect file(piol, name); 43 | 44 | // nt is the number of traces, ns the number of samples per trace 45 | size_t nt = 40000, ns = 1000; 46 | // inc is the increment step between traces (microseconds) 47 | double inc = 4.0; 48 | 49 | auto dec = block_decomposition(nt, piol->getNumRank(), piol->getRank()); 50 | size_t offset = dec.global_offset; 51 | size_t lnt = dec.local_size; 52 | 53 | // Write some header parameters 54 | file.writeNs(ns); 55 | file.writeNt(nt); 56 | file.writeInc(inc); 57 | file.writeText("Test file\n"); 58 | 59 | // Set and write some trace parameters 60 | Param prm(lnt); 61 | for (size_t j = 0; j < lnt; j++) { 62 | float k = offset + j; 63 | param_utils::setPrm(j, PIOL_META_xSrc, 1600.0 + k, &prm); 64 | param_utils::setPrm(j, PIOL_META_ySrc, 2400.0 + k, &prm); 65 | param_utils::setPrm(j, PIOL_META_xRcv, 100000.0 + k, &prm); 66 | param_utils::setPrm(j, PIOL_META_yRcv, 3000000.0 + k, &prm); 67 | param_utils::setPrm(j, PIOL_META_xCmp, 10000.0 + k, &prm); 68 | param_utils::setPrm(j, PIOL_META_yCmp, 4000.0 + k, &prm); 69 | param_utils::setPrm(j, PIOL_META_il, 2400 + k, &prm); 70 | param_utils::setPrm(j, PIOL_META_xl, 1600 + k, &prm); 71 | param_utils::setPrm(j, PIOL_META_tn, offset + j, &prm); 72 | } 73 | file.writeParam(offset, lnt, &prm); 74 | 75 | // Set and write some traces 76 | std::vector trc(lnt * ns); 77 | for (size_t j = 0; j < lnt * ns; j++) { 78 | trc[j] = float(offset * ns + j); 79 | } 80 | file.writeTrace(offset, lnt, trc.data()); 81 | return 0; 82 | } 83 | -------------------------------------------------------------------------------- /examples/exampleCreateFile.c: -------------------------------------------------------------------------------- 1 | /// 2 | /// Example: exampleCreateFile.c {#examples_exampleCreateFile_c} 3 | /// ============================ 4 | /// 5 | /// @todo DOCUMENT ME - Finish documenting example. 6 | /// 7 | 8 | #include "ExSeisDat/PIOL.h" 9 | 10 | #include 11 | #include 12 | 13 | void createFile(const char* name, size_t nt, size_t ns, size_t inc) 14 | { 15 | // Initialise the PIOL by creating an ExSeis object 16 | PIOL_ExSeis* piol = PIOL_ExSeis_new(PIOL_VERBOSITY_NONE); 17 | 18 | // Create a SEGY file object 19 | PIOL_File_WriteDirect* fh = PIOL_File_WriteDirect_new(piol, name); 20 | 21 | // Perform some decomposition (user decides how they will decompose) 22 | struct exseis_Contiguous_decomposition dec = exseis_block_decomposition( 23 | nt, PIOL_ExSeis_getNumRank(piol), PIOL_ExSeis_getRank(piol)); 24 | 25 | // The offset for the local process 26 | size_t offset = dec.global_offset; 27 | // The number of traces for the local process to handle 28 | size_t lnt = dec.local_size; 29 | 30 | // Write some header parameters 31 | PIOL_File_WriteDirect_writeNs(fh, ns); 32 | PIOL_File_WriteDirect_writeNt(fh, nt); 33 | PIOL_File_WriteDirect_writeInc(fh, inc); 34 | PIOL_File_WriteDirect_writeText(fh, "Test file\n"); 35 | 36 | // Set some trace parameters 37 | PIOL_File_Param* prm = PIOL_File_Param_new(NULL, lnt); 38 | for (size_t j = 0; j < lnt; j++) { 39 | float k = offset + j; 40 | PIOL_File_setPrm_double(j, PIOL_META_xSrc, 1600.0 + k, prm); 41 | PIOL_File_setPrm_double(j, PIOL_META_ySrc, 2400.0 + k, prm); 42 | PIOL_File_setPrm_double(j, PIOL_META_xRcv, 100000.0 + k, prm); 43 | PIOL_File_setPrm_double(j, PIOL_META_yRcv, 3000000.0 + k, prm); 44 | PIOL_File_setPrm_double(j, PIOL_META_xCmp, 10000.0 + k, prm); 45 | PIOL_File_setPrm_double(j, PIOL_META_yCmp, 4000.0 + k, prm); 46 | PIOL_File_setPrm_Integer(j, PIOL_META_il, 2400 + offset + j, prm); 47 | PIOL_File_setPrm_Integer(j, PIOL_META_xl, 1600 + offset + j, prm); 48 | PIOL_File_setPrm_Integer(j, PIOL_META_tn, offset + j, prm); 49 | } 50 | 51 | // Set some traces 52 | assert(lnt * ns > 0); 53 | float* trc = calloc(lnt * ns, sizeof(float)); 54 | for (size_t j = 0; j < lnt * ns; j++) { 55 | trc[j] = (float)(offset * ns + j); 56 | } 57 | 58 | // Write the traces and trace parameters 59 | PIOL_File_WriteDirect_writeTrace(fh, offset, lnt, trc, prm); 60 | 61 | // Free the data 62 | PIOL_File_Param_delete(prm); 63 | free(trc); 64 | 65 | // Close the file handle and free the piol 66 | PIOL_File_WriteDirect_delete(fh); 67 | PIOL_ExSeis_delete(piol); 68 | } 69 | 70 | 71 | int main(void) 72 | { 73 | // Set output file name, number of traces, number of samples per trace, and 74 | // sampling rate 75 | const char* name = "CreateFileOutputC"; 76 | size_t nt = 8000; 77 | size_t ns = 4000; 78 | double inc = .01; 79 | 80 | createFile(name, nt, ns, inc); 81 | return 0; 82 | } 83 | -------------------------------------------------------------------------------- /examples/exampleCreateFile.cc: -------------------------------------------------------------------------------- 1 | /// 2 | /// Example: exampleCreateFile.cc {#examples_exampleCreateFile_cc} 3 | /// ============================= 4 | /// 5 | /// @todo DOCUMENT ME - Finish documenting example. 6 | /// 7 | /// This example shows how to make a new file with the file api is complete. 8 | /// 9 | 10 | #include "ExSeisDat/PIOL.hh" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace exseis::utils; 19 | using namespace exseis::PIOL; 20 | 21 | void createFile(std::string name, size_t nt, size_t ns, double inc) 22 | { 23 | // Initialize PIOL by creating an ExSeisPIOL object 24 | auto piol = ExSeis::New(); 25 | 26 | // Create new SEGY file 27 | WriteDirect file(piol, name); 28 | 29 | auto dec = block_decomposition(nt, piol->getNumRank(), piol->getRank()); 30 | size_t offset = dec.global_offset; 31 | size_t lnt = dec.local_size; 32 | 33 | // Write some header parameters 34 | file.writeNs(ns); 35 | file.writeNt(nt); 36 | file.writeInc(inc); 37 | file.writeText("Test file\n"); 38 | 39 | // Set and write some trace parameters 40 | Param prm(lnt); 41 | for (size_t j = 0; j < lnt; j++) { 42 | float k = offset + j; 43 | param_utils::setPrm(j, PIOL_META_xSrc, 1600.0 + k, &prm); 44 | param_utils::setPrm(j, PIOL_META_ySrc, 2400.0 + k, &prm); 45 | param_utils::setPrm(j, PIOL_META_xRcv, 100000.0 + k, &prm); 46 | param_utils::setPrm(j, PIOL_META_yRcv, 3000000.0 + k, &prm); 47 | param_utils::setPrm(j, PIOL_META_xCmp, 10000.0 + k, &prm); 48 | param_utils::setPrm(j, PIOL_META_yCmp, 4000.0 + k, &prm); 49 | param_utils::setPrm(j, PIOL_META_il, 2400 + k, &prm); 50 | param_utils::setPrm(j, PIOL_META_xl, 1600 + k, &prm); 51 | param_utils::setPrm(j, PIOL_META_tn, offset + j, &prm); 52 | } 53 | file.writeParam(offset, lnt, &prm); 54 | 55 | // Set and write some traces 56 | std::vector trc(lnt * ns); 57 | for (size_t j = 0; j < lnt * ns; j++) { 58 | trc[j] = float(offset * ns + j); 59 | } 60 | file.writeTrace(offset, lnt, trc.data()); 61 | } 62 | 63 | 64 | int main(void) 65 | { 66 | // Set output file name, number of traces, number of samples per trace, and 67 | // sampling rate 68 | std::string name = "CreateFileOutputCPP"; 69 | size_t nt = 8000; 70 | size_t ns = 4000; 71 | double inc = .01; 72 | 73 | createFile(name, nt, ns, inc); 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /examples/exampleFilterTaper.cc: -------------------------------------------------------------------------------- 1 | /// 2 | /// Example: exampleFilterTaper.cc {#examples_exampleFilterTaper_cc} 3 | /// ============================== 4 | /// 5 | /// @todo DOCUMENT ME - Finish documenting example. 6 | /// 7 | /// Sort a file in 9 lines 8 | /// 9 | 10 | #include "ExSeisDat/Flow.hh" 11 | 12 | #include 13 | 14 | using namespace exseis::PIOL; 15 | using namespace exseis::Flow; 16 | 17 | int main(void) 18 | { 19 | auto piol = ExSeis::New(); 20 | Set set(piol, "Line_*", "LowpassTime"); 21 | std::vector c = {3.5, 0}; 22 | set.temporalFilter( 23 | FltrType::Lowpass, FltrDmn::Time, PadType::Symmetric, 30.f, 4LU, c); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /examples/exampleSort.c: -------------------------------------------------------------------------------- 1 | /// 2 | /// Example: exampleSort.c {#examples_exampleSort_c} 3 | /// ====================== 4 | /// 5 | /// @todo DOCUMENT ME - Finish documenting example. 6 | /// 7 | 8 | #include "ExSeisDat/Flow.h" 9 | 10 | int main(void) 11 | { 12 | PIOL_ExSeis* piol = PIOL_ExSeis_new(PIOL_VERBOSITY_NONE); 13 | PIOL_Set* set = PIOL_Set_new(piol, "/ichec/work/exseisdat/*dat/10*/b*"); 14 | PIOL_Set_output(set, "presort"); 15 | PIOL_Set_sort(set, PIOL_SORTTYPE_OffLine); 16 | PIOL_Set_output(set, "postsort"); 17 | PIOL_Set_delete(set); 18 | PIOL_ExSeis_delete(piol); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /examples/exampleSort.cc: -------------------------------------------------------------------------------- 1 | /// 2 | /// Example: exampleSort.cc {#examples_exampleSort_cc} 3 | /// ======================= 4 | /// 5 | /// @todo DOCUMENT ME - Finish documenting example. 6 | /// 7 | /// Sort a file in 9 lines 8 | /// 9 | 10 | #include "ExSeisDat/Flow.hh" 11 | 12 | using namespace exseis::PIOL; 13 | using namespace exseis::Flow; 14 | 15 | int main(void) 16 | { 17 | auto piol = ExSeis::New(); 18 | Set set(piol, "/ichec/work/exseisdat/*dat/10*/b*", "temp"); 19 | set.sort(PIOL_SORTTYPE_OffLine); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /examples/hello_world.c: -------------------------------------------------------------------------------- 1 | /// 2 | /// Example: Hello, World! {#examples_hello_world_c} 3 | /// ===================== 4 | /// 5 | /// @todo DOCUMENT ME - Finish documenting example. 6 | /// 7 | /// In this example, we'll look at initializing a PIOL object, potentially 8 | /// across multiple processes, and do some operation on just one of those 9 | /// processes. 10 | /// 11 | /// 12 | /// Implementation 13 | /// -------------- 14 | /// 15 | /// First, our boilerplate. 16 | /// We'll include the ExSeisDat header, and any extras we need. 17 | /// We also define a `main()` function. 18 | /// 19 | 20 | #include "ExSeisDat/PIOL.h" 21 | 22 | #include 23 | 24 | int main() 25 | { 26 | 27 | /// We initialize the ExSeis object, frequently referred to in this project 28 | /// as the PIOL object. 29 | 30 | // Initialize the PIOL 31 | PIOL_ExSeis* piol = PIOL_ExSeis_new(PIOL_VERBOSITY_NONE); 32 | 33 | /// Here, we've initialized the PIOL with the lowest verbosity setting. 34 | /// By default, this will initialize using MPI over MPI_COMM_WORLD. 35 | /// That means any operations run using this PIOL object will run on all 36 | /// the launched processes. 37 | /// 38 | /// Next, we'll run some code on just one process. In this case, we'll get 39 | /// process 0 to print the number of processes available. 40 | 41 | // Run on rank 0. 42 | if (!PIOL_ExSeis_getRank(piol)) { 43 | // Get num ranks for the PIOL and print to stdout. 44 | size_t num = PIOL_ExSeis_getNumRank(piol); 45 | if (num == 1) { 46 | printf("Hello, World! There is 1 process\n"); 47 | } 48 | else { 49 | printf("Hello, World! There are %zu processes\n", num); 50 | } 51 | } 52 | 53 | /// Having process 0 do serial operations is a common occurrence in MPI, 54 | /// and indeed many parallel codes. Process 0 is, then, often referred to as 55 | /// the master process. 56 | /// 57 | /// Having done the work we set out to do, we will now delete the PIOL 58 | /// object. This step is important to ensure files and caches are shut down 59 | /// properly when the program closes. 60 | 61 | // Cleanup the PIOL. 62 | PIOL_ExSeis_delete(piol); 63 | 64 | /// And finally, return 0 to indicate success. 65 | 66 | return 0; 67 | } 68 | /// 69 | /// Complete Code 70 | /// ------------- 71 | /// 72 | /// @include hello_world.c 73 | -------------------------------------------------------------------------------- /examples/minmax.c: -------------------------------------------------------------------------------- 1 | /// 2 | /// Example minmax.c {#examples_minmax_c} 3 | /// ================ 4 | /// 5 | /// @todo DOCUMENT ME - Finish documenting example. 6 | /// 7 | 8 | #include "ExSeisDat/Flow.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | int main(int argc, char** argv) 17 | { 18 | // Initialise the PIOL by creating an ExSeisPIOL object 19 | PIOL_ExSeis* piol = PIOL_ExSeis_new(PIOL_VERBOSITY_NONE); 20 | 21 | char* opt = "i:"; // TODO: uses a GNU extension 22 | char* name = NULL; 23 | for (int c = getopt(argc, argv, opt); c != -1; 24 | c = getopt(argc, argv, opt)) { 25 | 26 | const size_t optarg_length = strlen(optarg) + 1; 27 | 28 | if (c == 'i') { 29 | free(name); 30 | name = malloc(optarg_length * sizeof(char)); 31 | 32 | strncpy(name, optarg, optarg_length); 33 | } 34 | else { 35 | fprintf(stderr, "One of the command line arguments is invalid\n"); 36 | } 37 | } 38 | assert(name); 39 | 40 | PIOL_Set* set = PIOL_Set_new(piol, name); 41 | 42 | struct PIOL_CoordElem minmax[12]; 43 | PIOL_Set_getMinMax(set, PIOL_META_xSrc, PIOL_META_ySrc, &minmax[0]); 44 | PIOL_Set_getMinMax(set, PIOL_META_xRcv, PIOL_META_yRcv, &minmax[4]); 45 | PIOL_Set_getMinMax(set, PIOL_META_xCmp, PIOL_META_yCmp, &minmax[8]); 46 | 47 | if (!PIOL_ExSeis_getRank(piol)) { 48 | printf( 49 | "x Src %e (%zu) -> %e (%zu)\n", minmax[0].val, minmax[0].num, 50 | minmax[1].val, minmax[1].num); 51 | printf( 52 | "y Src %e (%zu) -> %e (%zu)\n", minmax[2].val, minmax[2].num, 53 | minmax[3].val, minmax[3].num); 54 | printf( 55 | "x Rcv %e (%zu) -> %e (%zu)\n", minmax[4].val, minmax[4].num, 56 | minmax[5].val, minmax[5].num); 57 | printf( 58 | "y Rcv %e (%zu) -> %e (%zu)\n", minmax[6].val, minmax[6].num, 59 | minmax[7].val, minmax[7].num); 60 | printf( 61 | "x Cmp %e (%zu) -> %e (%zu)\n", minmax[8].val, minmax[8].num, 62 | minmax[9].val, minmax[9].num); 63 | printf( 64 | "y Cmp %e (%zu) -> %e (%zu)\n", minmax[10].val, minmax[10].num, 65 | minmax[11].val, minmax[11].num); 66 | } 67 | 68 | PIOL_Set_delete(set); 69 | free(name); 70 | PIOL_ExSeis_delete(piol); 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /examples/minmax.cc: -------------------------------------------------------------------------------- 1 | /// 2 | /// Example: minmax.cc {#examples_minmax_cc} 3 | /// ================== 4 | /// 5 | /// @todo DOCUMENT ME - Finish documenting example. 6 | /// 7 | /// This is an example of using minmax through the Set API is complete. 8 | /// 9 | 10 | #include "ExSeisDat/Flow.hh" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace exseis::PIOL; 18 | using namespace exseis::Flow; 19 | 20 | int main(int argc, char** argv) 21 | { 22 | auto piol = ExSeis::New(); 23 | 24 | std::string opt = "i:"; // TODO: uses a GNU extension 25 | std::string iname; 26 | for (int c = getopt(argc, argv, opt.c_str()); c != -1; 27 | c = getopt(argc, argv, opt.c_str())) { 28 | if (c == 'i') { 29 | iname = optarg; 30 | } 31 | else { 32 | std::cerr << "One of the command line arguments is invalid.\n"; 33 | } 34 | } 35 | assert(!iname.empty()); 36 | 37 | Set set(piol, iname); 38 | 39 | CoordElem minmax[12]; 40 | set.getMinMax(PIOL_META_xSrc, PIOL_META_ySrc, &minmax[0]); 41 | set.getMinMax(PIOL_META_xRcv, PIOL_META_yRcv, &minmax[4]); 42 | set.getMinMax(PIOL_META_xCmp, PIOL_META_yCmp, &minmax[8]); 43 | 44 | if (piol->getRank() == 0) { 45 | std::cout << "x Src " << minmax[0].val << " (" << minmax[0].num 46 | << ") -> " << minmax[1].val << " (" << minmax[1].num << ")\n"; 47 | std::cout << "y Src " << minmax[2].val << " (" << minmax[2].num 48 | << ") -> " << minmax[3].val << " (" << minmax[3].num << ")\n"; 49 | std::cout << "x Rcv " << minmax[4].val << " (" << minmax[4].num 50 | << ") -> " << minmax[5].val << " (" << minmax[5].num << ")\n"; 51 | std::cout << "y Rcv " << minmax[6].val << " (" << minmax[6].num 52 | << ") -> " << minmax[7].val << " (" << minmax[7].num << ")\n"; 53 | std::cout << "x Cmp " << minmax[8].val << " (" << minmax[8].num 54 | << ") -> " << minmax[9].val << " (" << minmax[9].num << ")\n"; 55 | std::cout << "y Cmp " << minmax[10].val << " (" << minmax[10].num 56 | << ") -> " << minmax[11].val << " (" << minmax[11].num 57 | << ")\n"; 58 | } 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /examples/sort.c: -------------------------------------------------------------------------------- 1 | /// 2 | /// Example: sort.c {#examples_sort_c} 3 | /// =============== 4 | /// 5 | /// @todo DOCUMENT ME - Finish documenting example. 6 | /// 7 | 8 | #include "ExSeisDat/Flow.h" 9 | 10 | int main(void) 11 | { 12 | PIOL_ExSeis* piol = PIOL_ExSeis_new(PIOL_VERBOSITY_NONE); 13 | PIOL_Set* set = PIOL_Set_new(piol, "/ichec/work/exseisdat/*dat/10*/b*"); 14 | PIOL_Set_output(set, "presort"); 15 | PIOL_Set_sort(set, PIOL_SORTTYPE_OffLine); 16 | PIOL_Set_output(set, "postsort"); 17 | PIOL_Set_delete(set); 18 | PIOL_ExSeis_delete(piol); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /examples/sort.cc: -------------------------------------------------------------------------------- 1 | /// 2 | /// Example: sort.cc {#examples_sort_cc} 3 | /// ================ 4 | /// 5 | /// @todo DOCUMENT ME - Finish documenting example. 6 | /// 7 | /// Sort a file in 9 lines 8 | /// 9 | 10 | #include "ExSeisDat/Flow.hh" 11 | 12 | using namespace exseis::PIOL; 13 | using namespace exseis::Flow; 14 | 15 | int main(void) 16 | { 17 | auto piol = ExSeis::New(); 18 | Set set(piol, "/ichec/work/exseisdat/*dat/10*/b*", "temp"); 19 | set.sort(PIOL_SORTTYPE_OffLine); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /include/ExSeisDat/Flow.hh: -------------------------------------------------------------------------------- 1 | #ifndef EXSEISDAT_FLOW_HH 2 | #define EXSEISDAT_FLOW_HH 3 | 4 | #include "ExSeisDat/PIOL.hh" 5 | 6 | #include "ExSeisDat/Flow/Cache.hh" 7 | #include "ExSeisDat/Flow/CacheElem.hh" 8 | #include "ExSeisDat/Flow/FileDesc.hh" 9 | #include "ExSeisDat/Flow/FuncOpt.hh" 10 | #include "ExSeisDat/Flow/GatherState.hh" 11 | #include "ExSeisDat/Flow/Op.hh" 12 | #include "ExSeisDat/Flow/OpOpt.hh" 13 | #include "ExSeisDat/Flow/OpParent.hh" 14 | #include "ExSeisDat/Flow/RadonGatherState.hh" 15 | #include "ExSeisDat/Flow/Set.hh" 16 | #include "ExSeisDat/Flow/TraceBlock.hh" 17 | 18 | #endif // EXSEISDAT_FLOW_HH 19 | -------------------------------------------------------------------------------- /include/ExSeisDat/Flow/CacheElem.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef EXSEISDAT_FLOW_CACHEELEM_HH 5 | #define EXSEISDAT_FLOW_CACHEELEM_HH 6 | 7 | #include "ExSeisDat/Flow/FileDesc.hh" 8 | #include "ExSeisDat/Flow/TraceBlock.hh" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace exseis { 15 | namespace Flow { 16 | 17 | /*! A structure to store cache elements of traces and parameters corresponding 18 | * to a collection of files 19 | */ 20 | struct CacheElem { 21 | /// Typedef for passing in a list of FileDesc objects. 22 | typedef std::deque> FileDeque; 23 | 24 | /// A deque of unique pointers to file descriptors 25 | FileDeque desc; 26 | 27 | /// The cached data 28 | std::shared_ptr block; 29 | 30 | /*! Construct the cache element with the given parameter structure. 31 | * @param[in] desc_ A deque of unique pointers to file descriptors 32 | * @param[inout] prm_ A unique_ptr to the parameter structure. The cache 33 | * element takes ownership. 34 | */ 35 | CacheElem(FileDeque& desc_, std::unique_ptr prm_) 36 | { 37 | desc = desc_; 38 | block = std::make_shared(); 39 | block->prm = std::move(prm_); 40 | } 41 | 42 | /*! Construct the cache element with the given parameter structure. 43 | * @param[in] desc_ A deque of unique pointers to file descriptors 44 | * @param[in] trc_ A vector of traces for caching. 45 | * @param[inout] prm_ A unique_ptr to the parameter structure. The cache 46 | * element takes ownership if it exists. 47 | */ 48 | CacheElem( 49 | FileDeque& desc_, 50 | std::vector& trc_, 51 | std::unique_ptr prm_ = nullptr) 52 | { 53 | desc = desc_; 54 | block = std::make_shared(); 55 | block->trc = std::move(trc_); 56 | block->prm = std::move(prm_); 57 | } 58 | 59 | /*! Check if the given element has cached parameters 60 | * @param[in] desc_ A deque of unique pointers to file descriptors 61 | * @return Return true if the parameters are cached. 62 | */ 63 | bool checkPrm(const FileDeque& desc_) const 64 | { 65 | return desc == desc_ && !block && block->prm; 66 | } 67 | 68 | /*! Check if the given element has cached traces 69 | * @param[in] desc_ A deque of unique pointers to file descriptors 70 | * @return Return true if the traces are cached. 71 | */ 72 | bool checkTrc(const FileDeque& desc_) const 73 | { 74 | return desc == desc_ && !block && !block->trc.empty(); 75 | } 76 | }; 77 | 78 | } // namespace Flow 79 | } // namespace exseis 80 | 81 | #endif // EXSEISDAT_FLOW_CACHEELEM_HH 82 | -------------------------------------------------------------------------------- /include/ExSeisDat/Flow/FileDesc.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef EXSEISDAT_FLOW_FILEDESC_HH 5 | #define EXSEISDAT_FLOW_FILEDESC_HH 6 | 7 | #include "ExSeisDat/PIOL/ReadInterface.hh" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace exseis { 14 | namespace Flow { 15 | 16 | /*! A file-descriptor structure which describes an input file and the 17 | * decomposition for the set layer 18 | */ 19 | struct FileDesc { 20 | /// The file interface 21 | std::unique_ptr ifc; 22 | 23 | /// The size of this corresponds to the local decomposition 24 | std::vector ilst; 25 | 26 | /// The size of this corresponds to the local decomposition 27 | std::vector olst; 28 | }; 29 | 30 | } // namespace Flow 31 | } // namespace exseis 32 | 33 | #endif // EXSEISDAT_FLOW_FILEDESC_HH 34 | -------------------------------------------------------------------------------- /include/ExSeisDat/Flow/FuncOpt.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef EXSEISDAT_FLOW_FUNCOPT_HH 5 | #define EXSEISDAT_FLOW_FUNCOPT_HH 6 | 7 | #include 8 | 9 | namespace exseis { 10 | namespace Flow { 11 | 12 | /*! Enum class for the various function options. 13 | */ 14 | enum class FuncOpt : size_t { 15 | // Data type dependencies 16 | 17 | /// Metadata required to be read. 18 | NeedMeta, 19 | 20 | /// Trace values required to be read. 21 | NeedTrcVal, 22 | 23 | // Modification level: 24 | 25 | /// Traces are added by the operation. 26 | AddTrc, 27 | 28 | /// Traces are deleted by the operation. 29 | DelTrc, 30 | 31 | /// Trace values are modified by the operation. 32 | ModTrcVal, 33 | 34 | /// Trace lengths are modified by the operation. 35 | ModTrcLen, 36 | 37 | /// Metadata values are modified by the operation. 38 | ModMetaVal, 39 | 40 | /// Traces are reordered by the operation. 41 | ReorderTrc, 42 | 43 | // Modification dependencies 44 | 45 | /// There is a dependency on the number of traces. 46 | DepTrcCnt, 47 | 48 | /// There is a dependency on the order of traces. 49 | DepTrcOrder, 50 | 51 | /// There is a dependency on the value of traces. 52 | DepTrcVal, 53 | 54 | /// There is a dependency on the metadata values. 55 | DepMetaVal, 56 | 57 | // Comms level: 58 | 59 | /// Each output trace requires info from one input trace. 60 | SingleTrace, 61 | 62 | /// Each output trace requires info from traces in the same gather. 63 | Gather, 64 | 65 | /// Each output trace requires info from all traces in a subset of files. 66 | SubSetOnly, 67 | 68 | /// Each output trace requires info from all traces in the set. 69 | AllTraces, 70 | 71 | /// Management of traces is complicated and custom. 72 | OwnIO 73 | }; 74 | 75 | } // namespace Flow 76 | } // namespace exseis 77 | 78 | #endif // EXSEISDAT_FLOW_FUNCOPT_HH 79 | -------------------------------------------------------------------------------- /include/ExSeisDat/Flow/GatherState.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef EXSEISDAT_FLOW_GATHERSTATE_HH 5 | #define EXSEISDAT_FLOW_GATHERSTATE_HH 6 | 7 | #include "ExSeisDat/PIOL/operations/gather.hh" 8 | #include "ExSeisDat/utils/Distributed_vector.hh" 9 | 10 | #include 11 | #include 12 | 13 | namespace exseis { 14 | namespace Flow { 15 | 16 | /*! A parent class to allow gather operations to maintain a state. 17 | */ 18 | struct GatherState { 19 | /// Virtual destructor 20 | virtual ~GatherState() = default; 21 | 22 | /*! A virtual function which can be overridden to create the 23 | * gather-operation state. 24 | * @param[in] offset A list of gather-numbers to be processed by the local 25 | * process. 26 | * @param[in] gather The global array of gathers. 27 | */ 28 | virtual void makeState( 29 | const std::vector& offset, 30 | const exseis::utils::Distributed_vector& 31 | gather) = 0; 32 | }; 33 | 34 | } // namespace Flow 35 | } // namespace exseis 36 | 37 | #endif // EXSEISDAT_FLOW_GATHERSTATE_HH 38 | -------------------------------------------------------------------------------- /include/ExSeisDat/Flow/Op.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef EXSEISDAT_FLOW_OP_HH 5 | #define EXSEISDAT_FLOW_OP_HH 6 | 7 | #include "ExSeisDat/Flow/OpParent.hh" 8 | 9 | #include "ExSeisDat/Flow/GatherState.hh" 10 | #include "ExSeisDat/Flow/OpOpt.hh" 11 | #include "ExSeisDat/PIOL/Rule.hh" 12 | 13 | #include 14 | 15 | namespace exseis { 16 | namespace Flow { 17 | 18 | /*! Template for creating a structure for a particular operation type. 19 | */ 20 | template 21 | struct Op : public OpParent { 22 | /// The particular std::function object for the operaton 23 | T func; 24 | 25 | /*! Construct. 26 | * @param[in] opt_ Operation options. 27 | * @param[in] rule_ Rules parameter rules for the operation 28 | * @param[in] state_ Gather state object if applicable. 29 | * @param[in] func_ The particular std::function implementation. 30 | */ 31 | Op( 32 | OpOpt& opt_, 33 | std::shared_ptr rule_, 34 | std::shared_ptr state_, 35 | T func_) : 36 | OpParent(opt_, rule_, state_), 37 | func(func_) 38 | { 39 | } 40 | }; 41 | 42 | } // namespace Flow 43 | } // namespace exseis 44 | 45 | #endif // EXSEISDAT_FLOW_OP_HH 46 | -------------------------------------------------------------------------------- /include/ExSeisDat/Flow/OpOpt.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef EXSEISDAT_FLOW_OPOPT_HH 5 | #define EXSEISDAT_FLOW_OPOPT_HH 6 | 7 | #include "ExSeisDat/Flow/FuncOpt.hh" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace exseis { 14 | namespace Flow { 15 | 16 | /*! A structure to hold operation options. 17 | */ 18 | class OpOpt { 19 | /// A list of the function options. 20 | std::vector optList; 21 | 22 | public: 23 | /*! Empty constructor. 24 | */ 25 | OpOpt(void) {} 26 | 27 | /*! Initialise the options list with an initialiser list. 28 | * @param[in] list An initialiser list of options. 29 | */ 30 | OpOpt(std::initializer_list list) : optList(list) {} 31 | 32 | /*! Check if an option is present in the list. 33 | * @param[in] opt The function option. 34 | * @return Return true if the option is present in the list. 35 | */ 36 | bool check(FuncOpt opt) 37 | { 38 | auto it = std::find(optList.begin(), optList.end(), opt); 39 | return it != optList.end(); 40 | } 41 | 42 | /*! Add an option to the list. 43 | * @param[in] opt The function option. 44 | */ 45 | void add(FuncOpt opt) { optList.push_back(opt); } 46 | }; 47 | 48 | } // namespace Flow 49 | } // namespace exseis 50 | 51 | #endif // EXSEISDAT_FLOW_OPOPT_HH 52 | -------------------------------------------------------------------------------- /include/ExSeisDat/Flow/OpParent.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef EXSEISDAT_FLOW_OPPARENT_HH 5 | #define EXSEISDAT_FLOW_OPPARENT_HH 6 | 7 | #include "ExSeisDat/Flow/GatherState.hh" 8 | #include "ExSeisDat/Flow/OpOpt.hh" 9 | #include "ExSeisDat/PIOL/Rule.hh" 10 | 11 | #include 12 | 13 | namespace exseis { 14 | namespace Flow { 15 | 16 | /*! Operations parents. Specific classes of operations inherit from this parent 17 | */ 18 | struct OpParent { 19 | /// Operation options. 20 | OpOpt opt; 21 | 22 | /// Relevant parameter rules for the operation. 23 | std::shared_ptr rule; 24 | 25 | /// Gather state if applicable. 26 | std::shared_ptr state; 27 | 28 | /*! Construct. 29 | * @param[in] opt_ Operation options. 30 | * @param[in] rule_ Rules parameter rules for the operation 31 | * @param[in] state_ Gather state object if applicable. 32 | */ 33 | OpParent( 34 | OpOpt& opt_, 35 | std::shared_ptr rule_, 36 | std::shared_ptr state_) : 37 | opt(opt_), 38 | rule(rule_), 39 | state(state_) 40 | { 41 | } 42 | 43 | /*! Virtual destructor for unique_ptr polymorphism. 44 | */ 45 | virtual ~OpParent(void) {} 46 | }; 47 | 48 | } // namespace Flow 49 | } // namespace exseis 50 | 51 | #endif // EXSEISDAT_FLOW_OPPARENT_HH 52 | -------------------------------------------------------------------------------- /include/ExSeisDat/Flow/RadonGatherState.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef EXSEISDAT_FLOW_RADONGATHERSTATE_HH 5 | #define EXSEISDAT_FLOW_RADONGATHERSTATE_HH 6 | 7 | #include "ExSeisDat/Flow/GatherState.hh" 8 | 9 | #include "ExSeisDat/PIOL/ExSeisPIOL.hh" 10 | #include "ExSeisDat/PIOL/operations/gather.hh" 11 | #include "ExSeisDat/utils/Distributed_vector.hh" 12 | #include "ExSeisDat/utils/typedefs.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace exseis { 20 | namespace Flow { 21 | 22 | using namespace exseis::utils::typedefs; 23 | 24 | /*! The radon state structure. 25 | */ 26 | struct RadonGatherState : public GatherState { 27 | /// The piol object. 28 | std::shared_ptr piol; 29 | 30 | /// The name of the Velocity Model (VM) file. 31 | std::string vmname; 32 | 33 | /// Trace data read from the VM file. 34 | std::vector vtrc; 35 | 36 | /// A list of inlines corresponding to the VM data read. 37 | std::vector il; 38 | 39 | /// A list of crosslines corresponding to the VM data read. 40 | std::vector xl; 41 | 42 | /// The number of samples per trace for the VM. 43 | size_t vNs; 44 | 45 | /// The binning factor to be used. 46 | size_t vBin; 47 | 48 | /// The number of traces per gather in the angle output. 49 | size_t oGSz; 50 | 51 | /// The increment between samples in the VM file. 52 | exseis::utils::Floating_point vInc; 53 | 54 | /// The increment between samples in the output file (radians). 55 | exseis::utils::Floating_point oInc; 56 | 57 | /*! Constructor for the radon state. 58 | * @param[in] piol_ The piol object. 59 | * @param[in] vmname_ The VM file. 60 | * @param[in] vBin_ The velocity model bin parameter 61 | * @param[in] oGSz_ The number of traces in the angle output. 62 | * @param[in] oInc_ The number of increments. 63 | */ 64 | RadonGatherState( 65 | std::shared_ptr piol_, 66 | std::string vmname_, 67 | const size_t vBin_, 68 | const size_t oGSz_, 69 | const exseis::utils::Floating_point oInc_) : 70 | piol(piol_), 71 | vmname(vmname_), 72 | vNs(0), 73 | vBin(vBin_), 74 | oGSz(oGSz_), 75 | vInc(0), 76 | oInc(oInc_) 77 | { 78 | } 79 | 80 | void makeState( 81 | const std::vector& offset, 82 | const exseis::utils::Distributed_vector& 83 | gather) override; 84 | }; 85 | 86 | } // namespace Flow 87 | } // namespace exseis 88 | 89 | #endif // EXSEISDAT_FLOW_RADONGATHERSTATE_HH 90 | -------------------------------------------------------------------------------- /include/ExSeisDat/Flow/TraceBlock.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef EXSEISDAT_FLOW_TRACEBLOCK_HH 5 | #define EXSEISDAT_FLOW_TRACEBLOCK_HH 6 | 7 | #include "ExSeisDat/PIOL/Param.h" 8 | #include "ExSeisDat/utils/typedefs.h" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace exseis { 15 | namespace Flow { 16 | 17 | using namespace exseis::utils::typedefs; 18 | 19 | /*! The structure for holding all trace data. 20 | */ 21 | struct TraceBlock { 22 | /// Number of traces 23 | size_t nt; 24 | 25 | /// Number of samples per trace 26 | size_t ns; 27 | 28 | /// Increment between trace samples 29 | exseis::utils::Floating_point inc; 30 | 31 | /// Gather number (if applicable) 32 | size_t gNum; 33 | 34 | /// Number of gathers (if applicable) 35 | size_t numG; 36 | 37 | /// unique pointer to parameter structure (if applicable) 38 | std::unique_ptr prm; 39 | 40 | /// traces (if applicable) 41 | std::vector trc; 42 | }; 43 | 44 | } // namespace Flow 45 | } // namespace exseis 46 | 47 | #endif // EXSEISDAT_FLOW_TRACEBLOCK_HH 48 | -------------------------------------------------------------------------------- /include/ExSeisDat/PIOL.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @details Primary C++ API header 4 | //////////////////////////////////////////////////////////////////////////////// 5 | #ifndef EXSEISDAT_PIOL_HH 6 | #define EXSEISDAT_PIOL_HH 7 | 8 | #include "ExSeisDat/PIOL/CommunicatorInterface.hh" 9 | #include "ExSeisDat/PIOL/CommunicatorMPI.hh" 10 | #include "ExSeisDat/PIOL/DataInterface.hh" 11 | #include "ExSeisDat/PIOL/DataMPIIO.hh" 12 | #include "ExSeisDat/PIOL/ExSeis.hh" 13 | #include "ExSeisDat/PIOL/ExSeisPIOL.hh" 14 | #include "ExSeisDat/PIOL/Logger.hh" 15 | #include "ExSeisDat/PIOL/Meta.h" 16 | #include "ExSeisDat/PIOL/Model3dInterface.hh" 17 | #include "ExSeisDat/PIOL/ObjectInterface.hh" 18 | #include "ExSeisDat/PIOL/ObjectSEGY.hh" 19 | #include "ExSeisDat/PIOL/Param.h" 20 | #include "ExSeisDat/PIOL/ReadDirect.hh" 21 | #include "ExSeisDat/PIOL/ReadInterface.hh" 22 | #include "ExSeisDat/PIOL/ReadModel.hh" 23 | #include "ExSeisDat/PIOL/ReadSEGY.hh" 24 | #include "ExSeisDat/PIOL/ReadSEGYModel.hh" 25 | #include "ExSeisDat/PIOL/Rule.hh" 26 | #include "ExSeisDat/PIOL/RuleEntry.hh" 27 | #include "ExSeisDat/PIOL/SEGYRuleEntry.hh" 28 | #include "ExSeisDat/PIOL/SortType.h" 29 | #include "ExSeisDat/PIOL/Tr.h" 30 | #include "ExSeisDat/PIOL/Verbosity.h" 31 | #include "ExSeisDat/PIOL/WriteDirect.hh" 32 | #include "ExSeisDat/PIOL/WriteInterface.hh" 33 | #include "ExSeisDat/PIOL/WriteSEGY.hh" 34 | #include "ExSeisDat/PIOL/makeFile.hh" 35 | #include "ExSeisDat/PIOL/operations/gather.hh" 36 | #include "ExSeisDat/PIOL/operations/minmax.h" 37 | #include "ExSeisDat/PIOL/operations/sort.hh" 38 | #include "ExSeisDat/PIOL/operations/temporalfilter.hh" 39 | #include "ExSeisDat/PIOL/param_utils.hh" 40 | #include "ExSeisDat/PIOL/segy_utils.hh" 41 | #include "ExSeisDat/utils/Distributed_vector.hh" 42 | #include "ExSeisDat/utils/decomposition/block_decomposition.h" 43 | #include "ExSeisDat/utils/encoding/character_encoding.hh" 44 | #include "ExSeisDat/utils/encoding/number_encoding.hh" 45 | #include "ExSeisDat/utils/mpi/MPI_error_to_string.hh" 46 | #include "ExSeisDat/utils/signal_processing/AGC.h" 47 | #include "ExSeisDat/utils/signal_processing/taper.h" 48 | #include "ExSeisDat/utils/typedefs.h" 49 | 50 | #endif // EXSEISDAT_PIOL_HH 51 | -------------------------------------------------------------------------------- /include/ExSeisDat/PIOL/ExSeis.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief 4 | /// @details The \c ExSeis class 5 | //////////////////////////////////////////////////////////////////////////////// 6 | #ifndef EXSEISDAT_PIOL_EXSEIS_HH 7 | #define EXSEISDAT_PIOL_EXSEIS_HH 8 | 9 | #include "ExSeisDat/PIOL/ExSeisPIOL.hh" 10 | 11 | #include "ExSeisDat/utils/typedefs.h" 12 | 13 | 14 | namespace exseis { 15 | namespace PIOL { 16 | 17 | /*! This class provides access to the ExSeisPIOL class but with a simpler API 18 | */ 19 | class ExSeis : public ExSeisPIOL { 20 | public: 21 | /*! Constructor with optional maxLevel and which initialises MPI. 22 | * @param[in] comm The MPI communicator 23 | * @param[in] maxLevel The maximum log level to be recorded. 24 | * @return A shared pointer to a PIOL object. 25 | */ 26 | static std::shared_ptr New( 27 | Verbosity maxLevel = PIOL_VERBOSITY_NONE, MPI_Comm comm = MPI_COMM_WORLD) 28 | { 29 | return std::shared_ptr(new ExSeis(maxLevel, comm)); 30 | } 31 | 32 | /*! ExSeis Deleter. 33 | */ 34 | ~ExSeis(); 35 | 36 | /*! Shortcut to get the commrank. 37 | * @return The comm rank. 38 | */ 39 | size_t getRank() const; 40 | 41 | /*! Shortcut to get the number of ranks. 42 | * @return The comm number of ranks. 43 | */ 44 | size_t getNumRank() const; 45 | 46 | /*! Shortcut for a communication barrier 47 | */ 48 | void barrier() const; 49 | 50 | /*! Return the maximum value amongst the processes 51 | * @param[in] n The value to take part in the reduction 52 | * @return Return the maximum value amongst the processes 53 | */ 54 | size_t max(size_t n) const; 55 | 56 | /*! @brief A function to check if an error has occured in the PIOL. If an 57 | * error has occured the log is printed, the object destructor is 58 | * called and the code aborts. 59 | * @param[in] msg A message to be printed to the log. 60 | */ 61 | void isErr(const std::string& msg = "") const; 62 | 63 | private: 64 | /// The constructor is private! Use the ExSeis::New(...) function. 65 | /// @copydetails ExSeis::New 66 | ExSeis( 67 | Verbosity maxLevel = PIOL_VERBOSITY_NONE, MPI_Comm comm = MPI_COMM_WORLD); 68 | }; 69 | 70 | } // namespace PIOL 71 | } // namespace exseis 72 | 73 | #endif // EXSEISDAT_PIOL_EXSEIS_HH 74 | -------------------------------------------------------------------------------- /include/ExSeisDat/PIOL/ExSeisPIOL.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief The \c ExSeisPIOL class. This holds data shared by most classes 4 | /// in the library. 5 | //////////////////////////////////////////////////////////////////////////////// 6 | #ifndef EXSEISDAT_PIOL_EXSEISPIOL_HH 7 | #define EXSEISDAT_PIOL_EXSEISPIOL_HH 8 | 9 | #include "ExSeisDat/PIOL/CommunicatorMPI.hh" 10 | #include "ExSeisDat/PIOL/Logger.hh" 11 | #include "ExSeisDat/PIOL/Verbosity.h" 12 | 13 | #include 14 | #include 15 | 16 | namespace exseis { 17 | namespace PIOL { 18 | 19 | /*! @brief The ExSeisPIOL structure. A single instance of this structure should 20 | * be created and passed to each subsequent PIOL object which is 21 | * created. 22 | */ 23 | class ExSeisPIOL { 24 | 25 | protected: 26 | /*! Constructor which initialized the logging level and MPI. 27 | * @param[in] copt An options structure for MPI 28 | * @param[in] maxLevel The maximum log level to be recorded. 29 | */ 30 | ExSeisPIOL( 31 | Verbosity maxLevel = PIOL_VERBOSITY_NONE, 32 | const CommunicatorMPI::Opt& copt = CommunicatorMPI::Opt()); 33 | 34 | public: 35 | /// The ExSeisPIOL logger 36 | std::unique_ptr log; 37 | 38 | /// The ExSeisPIOL communication 39 | std::unique_ptr comm; 40 | 41 | /*! @brief A function to check if an error has occured in the PIOL. If an 42 | * error has occured the log is printed, the object destructor is 43 | * called and the code aborts. 44 | * @param[in] msg A message to be printed to the log. 45 | */ 46 | void isErr(const std::string& msg = "") const; 47 | }; 48 | 49 | } // namespace PIOL 50 | } // namespace exseis 51 | 52 | #endif // EXSEISDAT_PIOL_EXSEISPIOL_HH 53 | -------------------------------------------------------------------------------- /include/ExSeisDat/PIOL/ReadModel.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief 4 | /// @details The \c ReadModel class 5 | /// @todo document me 6 | //////////////////////////////////////////////////////////////////////////////// 7 | #ifndef EXSEISDAT_PIOL_READMODEL_HH 8 | #define EXSEISDAT_PIOL_READMODEL_HH 9 | 10 | #include "ExSeisDat/PIOL/ExSeisPIOL.hh" 11 | #include "ExSeisDat/PIOL/ReadDirect.hh" 12 | #include "ExSeisDat/PIOL/operations/gather.hh" 13 | 14 | #include 15 | #include 16 | 17 | namespace exseis { 18 | namespace PIOL { 19 | 20 | /// @todo document me 21 | class ReadModel : public ReadDirect { 22 | public: 23 | /// @param[in] piol_ This PIOL ptr is not modified but is used to 24 | /// instantiate another shared_ptr. 25 | /// @param[in] name_ The name of the file associated with the instantiation. 26 | ReadModel(std::shared_ptr piol_, std::string name_); 27 | 28 | /// @todo DOCUMENT brief and return type 29 | /// @param[in] gOffset DOCUMENT ME 30 | /// @param[in] numGather DOCUMENT ME 31 | /// @param[in] gather DOCUMENT ME 32 | /// @return DOCUMENT ME 33 | std::vector virtual readModel( 34 | size_t gOffset, 35 | size_t numGather, 36 | exseis::utils::Distributed_vector& gather); 37 | }; 38 | 39 | } // namespace PIOL 40 | } // namespace exseis 41 | 42 | #endif // EXSEISDAT_PIOL_READMODEL_HH 43 | -------------------------------------------------------------------------------- /include/ExSeisDat/PIOL/ReadSEGYModel.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief The \c ReadSEGYModel class reads SEGY velocity models. 4 | //////////////////////////////////////////////////////////////////////////////// 5 | #ifndef EXSEISDAT_PIOL_READSEGYMODEL_HH 6 | #define EXSEISDAT_PIOL_READSEGYMODEL_HH 7 | 8 | #include "ExSeisDat/PIOL/Model3dInterface.hh" 9 | #include "ExSeisDat/PIOL/ReadSEGY.hh" 10 | #include "ExSeisDat/utils/Distributed_vector.hh" 11 | 12 | namespace exseis { 13 | namespace PIOL { 14 | 15 | /*! A SEGY class for seismic velocity models 16 | * 17 | * Velocity models indicate the velocity anomolies within a subsurface, which 18 | * indicate areas with high velocity anomolies correspond to denser material, 19 | * while lower velocities correspond to materials that are less dense. 20 | */ 21 | class ReadSEGYModel : public Model3dInterface, public ReadSEGY { 22 | public: 23 | /*! @brief The SEG-Y Model options structure. 24 | */ 25 | struct Opt : public ReadSEGY::Opt { 26 | /// The Type of the class this structure is nested in 27 | typedef ReadSEGYModel Type; 28 | }; 29 | 30 | /*! The Constructor, uses the default options. 31 | * @param[in] piol_ The piol object. 32 | * @param[in] name_ The name of the file. 33 | * @param[in] obj_ A shared pointer for the object layer object. 34 | */ 35 | ReadSEGYModel( 36 | std::shared_ptr piol_, 37 | std::string name_, 38 | std::shared_ptr obj_); 39 | 40 | /*! The Constructor. 41 | * @param[in] piol_ The piol object. 42 | * @param[in] name_ The name of the file. 43 | * @param[in] opt The ReadSEGYModel options. 44 | * @param[in] obj_ A shared pointer for the object layer object. 45 | */ 46 | ReadSEGYModel( 47 | std::shared_ptr piol_, 48 | std::string name_, 49 | const ReadSEGYModel::Opt& opt, 50 | std::shared_ptr obj_); 51 | 52 | std::vector readModel( 53 | size_t offset, 54 | size_t sz, 55 | const exseis::utils::Distributed_vector& gather) override; 56 | 57 | std::vector readModel( 58 | size_t sz, 59 | const size_t* offset, 60 | const exseis::utils::Distributed_vector& gather) override; 61 | }; 62 | 63 | } // namespace PIOL 64 | } // namespace exseis 65 | 66 | #endif // EXSEISDAT_PIOL_READSEGYMODEL_HH 67 | -------------------------------------------------------------------------------- /include/ExSeisDat/PIOL/RuleEntry.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief The \c RuleEntry class, representing where and how in a file a 4 | /// particular trace parameter should be written. 5 | //////////////////////////////////////////////////////////////////////////////// 6 | #ifndef EXSEISDAT_PIOL_RULEENTRY_HH 7 | #define EXSEISDAT_PIOL_RULEENTRY_HH 8 | 9 | #include 10 | 11 | namespace exseis { 12 | namespace PIOL { 13 | 14 | /*! An instantiation of this structure corresponds to a single metadata rule 15 | */ 16 | struct RuleEntry { 17 | /// The type of data 18 | enum class MdType : size_t { 19 | /// Long int data 20 | Long, 21 | /// Short int data 22 | Short, 23 | /// Floating point data 24 | Float, 25 | /// For indexing purposes 26 | Index, 27 | /// Copy all relevant headers. Not file format agnostic. 28 | Copy 29 | }; 30 | 31 | /// A counter showing this is the numth rule for the given data type. 32 | size_t num; 33 | 34 | /// The memory location for the primary data. 35 | size_t loc; 36 | 37 | /*! The constructor for storing the rule number and location. 38 | * @param[in] num_ The numth rule of the given type for indexing 39 | * @param[in] loc_ The location of the primary data 40 | */ 41 | RuleEntry(const size_t num_, const size_t loc_) : num(num_), loc(loc_) {} 42 | 43 | /*! Virtual destructor to allow overriding by derived classes. 44 | */ 45 | virtual ~RuleEntry() = default; 46 | 47 | /*! Pure virtual function to return the minimum location stored, in derived 48 | * cases, more data can be stored than just loc 49 | * @return the minimum location 50 | */ 51 | virtual size_t min(void) = 0; 52 | 53 | /*! Pure virtual function to return the maximum location stored up to, in 54 | * derived cases, more data can be stored than just loc 55 | * @return the maximum location 56 | */ 57 | virtual size_t max(void) = 0; 58 | 59 | /*! Pure virtual function to return the datatype. 60 | * @return The MdType associated with the derived class. 61 | */ 62 | virtual MdType type(void) = 0; 63 | }; 64 | 65 | } // namespace PIOL 66 | } // namespace exseis 67 | 68 | #endif // EXSEISDAT_PIOL_RULEENTRY_HH 69 | -------------------------------------------------------------------------------- /include/ExSeisDat/PIOL/SortType.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef EXSEISDAT_PIOL_SORTTYPE_H 5 | #define EXSEISDAT_PIOL_SORTTYPE_H 6 | 7 | #include 8 | 9 | /*! An enum class of the different types of sorting operation. 10 | */ 11 | typedef size_t PIOL_SortType; 12 | 13 | #ifdef __cplusplus 14 | namespace exseis { 15 | namespace PIOL { 16 | /// @copydoc PIOL_SortType 17 | typedef PIOL_SortType SortType; 18 | } // namespace PIOL 19 | } // namespace exseis 20 | #endif // __cplusplus 21 | 22 | /// An enumeration of the different types of sorting operation. 23 | enum { 24 | /// Sort by source x, source y, receiver x, receiver y 25 | PIOL_SORTTYPE_SrcRcv = 35, 26 | 27 | /// Sort by source x, source y, calcuated offset 28 | PIOL_SORTTYPE_SrcOff = 36, 29 | 30 | /// Sort by source x, source y, offset read from file 31 | PIOL_SORTTYPE_SrcROff = 37, 32 | 33 | /// Sort by receiver x, receiver y, calculate offset 34 | PIOL_SORTTYPE_RcvOff = 38, 35 | 36 | /// Sort by receiver x, receiver y, offset read from file 37 | PIOL_SORTTYPE_RcvROff = 39, 38 | 39 | /// Sort by inline, crossline, calculated offset 40 | PIOL_SORTTYPE_LineOff = 40, 41 | 42 | /// Sort by inline, crossline, offset read from file 43 | PIOL_SORTTYPE_LineROff = 41, 44 | 45 | /// Sort by calculated offset, inline, crossline 46 | PIOL_SORTTYPE_OffLine = 42, 47 | 48 | /// Sort by offset read from file, inline, crossline 49 | PIOL_SORTTYPE_ROffLine = 43 50 | }; 51 | 52 | #endif // EXSEISDAT_PIOL_SORTTYPE_H 53 | -------------------------------------------------------------------------------- /include/ExSeisDat/PIOL/Verbosity.h: -------------------------------------------------------------------------------- 1 | #ifndef EXSEISDAT_PIOL_VERBOSITY_H 2 | #define EXSEISDAT_PIOL_VERBOSITY_H 3 | 4 | #include 5 | 6 | /// @copydoc PIOL::Verbosity 7 | typedef size_t PIOL_Verbosity; 8 | 9 | #ifdef __cplusplus 10 | namespace exseis { 11 | namespace PIOL { 12 | /// The enumeration for the verbosity level of records 13 | typedef PIOL_Verbosity Verbosity; 14 | } // namespace PIOL 15 | } // namespace exseis 16 | #endif 17 | 18 | /// Record no information beyond fatal errors and explicit requests 19 | #define PIOL_VERBOSITY_NONE ((PIOL_Verbosity)0) 20 | /// Record essential information including other errors and warnings 21 | #define PIOL_VERBOSITY_MINIMAL ((PIOL_Verbosity)1) 22 | /// Record some non-warnings 23 | #define PIOL_VERBOSITY_EXTENDED ((PIOL_Verbosity)2) 24 | /// Record a high level of information 25 | #define PIOL_VERBOSITY_VERBOSE ((PIOL_Verbosity)3) 26 | /// Maximum Verbosity level. (for debugging) 27 | #define PIOL_VERBOSITY_MAX ((PIOL_Verbosity)4) 28 | 29 | #endif // EXSEISDAT_PIOL_VERBOSITY_H 30 | -------------------------------------------------------------------------------- /include/ExSeisDat/PIOL/makeFile.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief Functions for creating instances of ReadInterface and WriteInterface 4 | //////////////////////////////////////////////////////////////////////////////// 5 | #ifndef EXSEISDAT_PIOL_MAKEFILE_HH 6 | #define EXSEISDAT_PIOL_MAKEFILE_HH 7 | 8 | #include "ExSeisDat/PIOL/ReadInterface.hh" 9 | #include "ExSeisDat/PIOL/WriteInterface.hh" 10 | 11 | #include "ExSeisDat/PIOL/ObjectInterface.hh" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | namespace exseis { 19 | namespace PIOL { 20 | 21 | /*! Construct ReadSEGY objects with default object and MPI-IO layers. 22 | * @tparam T The type of the file layer. 23 | * @param[in] piol The piol shared object. 24 | * @param[in] name The name of the file. 25 | * @return Return a pointer of the respective file type. 26 | */ 27 | template 28 | std::unique_ptr< 29 | typename std::enable_if::value, T>::type> 30 | makeFile(std::shared_ptr piol, const std::string& name) 31 | { 32 | return std::make_unique( 33 | piol, name, makeDefaultObj(piol, name, FileMode::Read)); 34 | } 35 | 36 | /*! Construct WriteSEGY objects with default object and MPI-IO layers 37 | * @tparam T The type of the file layer 38 | * @param[in] piol The piol shared object 39 | * @param[in] name The name of the file 40 | * @return Return a pointer of the respective file type. 41 | */ 42 | template 43 | std::unique_ptr< 44 | typename std::enable_if::value, T>::type> 45 | makeFile(std::shared_ptr piol, const std::string& name) 46 | { 47 | return std::make_unique( 48 | piol, name, makeDefaultObj(piol, name, FileMode::Write)); 49 | } 50 | 51 | } // namespace PIOL 52 | } // namespace exseis 53 | 54 | #endif // EXSEISDAT_PIOL_MAKEFILE_HH 55 | -------------------------------------------------------------------------------- /include/ExSeisDat/PIOL/operations/gather.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief 4 | /// @todo Note, these functions are intentionally specific because we need 5 | /// further use cases to generalise the functionality. 6 | //////////////////////////////////////////////////////////////////////////////// 7 | 8 | #ifndef EXSEISDAT_PIOL_OPERATIONS_GATHER_HH 9 | #define EXSEISDAT_PIOL_OPERATIONS_GATHER_HH 10 | 11 | #include "ExSeisDat/PIOL/ExSeisPIOL.hh" 12 | #include "ExSeisDat/PIOL/ReadInterface.hh" 13 | #include "ExSeisDat/utils/Distributed_vector.hh" 14 | #include "ExSeisDat/utils/typedefs.h" 15 | 16 | namespace exseis { 17 | namespace PIOL { 18 | 19 | using namespace exseis::utils::typedefs; 20 | 21 | /// A struct containing information about a seismic gather. 22 | struct Gather_info { 23 | /// The number of traces in the gather. 24 | size_t num_traces; 25 | 26 | /// The inline coordinate of the gather (inline_ because of reserved word). 27 | exseis::utils::Integer inline_; 28 | 29 | /// The crossline coordinate of the gather. 30 | exseis::utils::Integer crossline; 31 | }; 32 | 33 | 34 | /// Find the inline/crossline for each il/xl gather and the number of traces per 35 | /// gather using the parameters from the file provided. 36 | /// 37 | /// @param[in] piol The piol object. 38 | /// @param[in] file The file which has il/xl gathers. 39 | /// 40 | /// @return Return an 'array' of tuples. Each tuple corresponds to each gather. 41 | /// Tuple elements: 1) Number of traces in the gather, 2) inline, 3) 42 | /// crossline. 43 | /// 44 | exseis::utils::Distributed_vector getIlXlGathers( 45 | ExSeisPIOL* piol, ReadInterface* file); 46 | 47 | } // namespace PIOL 48 | } // namespace exseis 49 | 50 | #endif // EXSEISDAT_PIOL_OPERATIONS_GATHER_HH 51 | -------------------------------------------------------------------------------- /include/ExSeisDat/utils/c_api_utils.h: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file 3 | /// @brief This file contains a number of macros for cleanly defining the C 4 | /// and C++ APIs side by side. 5 | /// 6 | #ifndef EXSEISDAT_UTILS_C_API_UTILS_H 7 | #define EXSEISDAT_UTILS_C_API_UTILS_H 8 | 9 | /// Includes the macro arguments in the file only if it's being processed by 10 | /// a C++ compiler. 11 | /// 12 | /// This is used for specifying C and C++ interfaces side-by-side in the same 13 | /// file without lots of ifdef __cplusplus everywhere. 14 | /// It's particularly clear for adding things line `extern "C"` in front of 15 | /// functions in the C API. 16 | #ifdef __cplusplus 17 | #define EXSEISDAT_CXX_ONLY(X) X 18 | #else 19 | #define EXSEISDAT_CXX_ONLY(X) 20 | #endif // __cplusplus 21 | 22 | #endif // EXSEISDAT_UTILS_C_API_UTILS_H 23 | -------------------------------------------------------------------------------- /include/ExSeisDat/utils/encoding/character_encoding.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief Functions to convert between EBCDIC and ASCII encoding. 4 | //////////////////////////////////////////////////////////////////////////////// 5 | #ifndef EXSEISDAT_UTILS_ENCODING_CHARACTER_ENCODING_HH 6 | #define EXSEISDAT_UTILS_ENCODING_CHARACTER_ENCODING_HH 7 | 8 | /// 9 | /// @namespace exseis::utils::character_encoding 10 | /// 11 | /// @brief Functions for managing and converting between character encodings. 12 | /// 13 | 14 | namespace exseis { 15 | namespace utils { 16 | inline namespace character_encoding { 17 | 18 | 19 | /// @brief Convert an EBCDIC encoded character to an ASCII encoded character. 20 | /// 21 | /// Returns the ASCII SUB character if there is no ASCII equivalent. 22 | /// 23 | /// @param[in] ebcdic_char An EBCDIC encoded character. 24 | /// 25 | /// @return An ASCII encoded character. 26 | /// 27 | unsigned char to_ASCII_from_EBCDIC(unsigned char ebcdic_char); 28 | 29 | 30 | /// @brief Convert an ASCII encoded character to an EBCDIC encoded character. 31 | /// 32 | /// Returns the EBCDIC SUB character if there is no EBCDIC equivalent. 33 | /// 34 | /// @param[in] ascii_char An ASCII encoded character. 35 | /// 36 | /// @return An EBCDIC encoded character. 37 | /// 38 | unsigned char to_EBCDIC_from_ASCII(unsigned char ascii_char); 39 | 40 | 41 | /// @brief Determine whether an input character is a printable ASCII character. 42 | /// 43 | /// @param[in] ascii_char The character to test. 44 | /// 45 | /// @return Whether \c ascii_char represents a printable ASCII character. 46 | /// 47 | bool is_printable_ASCII(unsigned char ascii_char); 48 | 49 | 50 | /// @brief Determine whether an input character is a printable EBCDIC character. 51 | /// 52 | /// @param[in] ebcdic_char The character to test. 53 | /// 54 | /// @return Whether \c ebcdic_char represents a printable EBCDIC character. 55 | /// 56 | bool is_printable_EBCDIC(unsigned char ebcdic_char); 57 | 58 | 59 | } // namespace character_encoding 60 | } // namespace utils 61 | } // namespace exseis 62 | 63 | #endif // EXSEISDAT_UTILS_ENCODING_CHARACTER_ENCODING_HH 64 | -------------------------------------------------------------------------------- /include/ExSeisDat/utils/mpi/MPI_error_to_string.hh: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file 3 | /// @brief Routines for turning MPI Errors into human readable strings. 4 | /// 5 | #ifndef EXSEISDAT_UTILS_MPI_MPI_ERROR_TO_STRING_HH 6 | #define EXSEISDAT_UTILS_MPI_MPI_ERROR_TO_STRING_HH 7 | 8 | #include 9 | #include 10 | 11 | namespace exseis { 12 | namespace utils { 13 | 14 | /// @brief Generate a human readable MPI error message from an MPI error code 15 | /// and status object. 16 | /// 17 | /// @param[in] mpi_error The MPI error code 18 | /// @param[in] mpi_status The MPI status object (optional). 19 | /// 20 | /// @return A human readable string detailing the error code and the status. 21 | /// 22 | std::string MPI_error_to_string( 23 | int mpi_error, const MPI_Status* mpi_status = MPI_STATUS_IGNORE); 24 | 25 | } // namespace utils 26 | } // namespace exseis 27 | 28 | #endif // EXSEISDAT_UTILS_MPI_MPI_ERROR_TO_STRING_HH 29 | -------------------------------------------------------------------------------- /include/ExSeisDat/utils/mpi/MPI_max_array_length.hh: -------------------------------------------------------------------------------- 1 | /// 2 | /// @file 3 | /// @brief Routines for finding the maximum array length supported by Intel MPI. 4 | /// 5 | #ifndef EXSEISDAT_UTILS_MPI_MPI_MAX_ARRAY_LENGTH_HH 6 | #define EXSEISDAT_UTILS_MPI_MPI_MAX_ARRAY_LENGTH_HH 7 | 8 | namespace exseis { 9 | namespace utils { 10 | 11 | /// @brief Return the known limit for the array length for Intel MPI on Fionn 12 | /// for a type of the given size. 13 | /// 14 | /// @param[in] type_size The datatype size to find the array length limit for. 15 | /// 16 | /// @return The maximum array length of the given type. 17 | /// 18 | constexpr size_t MPI_max_array_length(size_t type_size) 19 | { 20 | // If you aren't (4096 - Chunk)/Chunk from the limit, intel mpi breaks on 21 | // Fionn. Probably something to do with pages. 22 | return (std::numeric_limits::max() - (4096U - type_size)) / type_size; 23 | } 24 | 25 | /// @brief Return the known limit for the array length for Intel MPI on Fionn 26 | /// for a given type. 27 | /// 28 | /// @tparam T The type to find the array length limit for. 29 | /// 30 | /// @return The size in counts 31 | /// 32 | template 33 | constexpr size_t MPI_max_array_length() 34 | { 35 | // If you aren't (4096 - Chunk)/Chunk from the limit, intel mpi breaks on 36 | // Fionn. Probably something to do with pages. 37 | return MPI_max_array_length(sizeof(T)); 38 | } 39 | 40 | } // namespace utils 41 | } // namespace exseis 42 | 43 | #endif // EXSEISDAT_UTILS_MPI_MPI_MAX_ARRAY_LENGTH_HH 44 | -------------------------------------------------------------------------------- /include/ExSeisDat/utils/signal_processing/AGC.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief The Automatic Gain Control Operation 4 | /// @details This function allows for automatic gain control to be applied to 5 | /// traces in order to equalize signal amplitude for display purposes. 6 | /// It uses a user defined window to adjust the gain using a user 7 | /// defined normalization value. 8 | /// 9 | /// Gain is normalised against one of: 10 | /// a) RMS amplitude 11 | /// b) RMS amplitude with triangle window 12 | /// c) Mean Absolute Value amplitude 13 | /// d) Median amplitude. 14 | /// 15 | /// AGC is intended to be applied to trace data. 16 | /// AGC can be performed on individual traces or entire gathers, where 17 | /// the same gain is applied to the jth sample in every trace. The 18 | /// window has a spatial componet. 19 | //////////////////////////////////////////////////////////////////////////////// 20 | #ifndef EXSEISDAT_UTILS_SIGNAL_PROCESSING_AGC_H 21 | #define EXSEISDAT_UTILS_SIGNAL_PROCESSING_AGC_H 22 | 23 | #include "ExSeisDat/utils/c_api_utils.h" 24 | #include "ExSeisDat/utils/signal_processing/Gain_function.h" 25 | #include "ExSeisDat/utils/typedefs.h" 26 | 27 | 28 | /// 29 | /// @namespace exseis::utils::signal_processing 30 | /// 31 | /// @brief Functions for processing seismic signals. 32 | /// 33 | 34 | 35 | #ifdef __cplusplus 36 | namespace exseis { 37 | namespace utils { 38 | inline namespace signal_processing { 39 | #endif // __cplusplus 40 | 41 | 42 | /// @brief Apply automatic gain control to a set of tapers --> used for actual 43 | /// operation during output 44 | /// 45 | /// @param[in] signal_size The number of samples in a signal 46 | /// @param[inout] signal Array of the signal data. 47 | /// @param[in] gain_function Statistical function which returns a scaled 48 | /// value for a signal. 49 | /// @param[in] window_size Length of the agc window 50 | /// @param[in] target_amplitude Value to which signal are normalised 51 | /// 52 | /// @remark C API: \ref exseis_AGC 53 | /// 54 | #ifdef __cplusplus 55 | void AGC( 56 | size_t signal_size, 57 | Trace_value* signal, 58 | Gain_function gain_function, 59 | size_t window_size, 60 | Trace_value target_amplitude); 61 | #endif // __cplusplus 62 | 63 | /// @name C API 64 | /// @{ 65 | 66 | /// @brief C API interface for \ref AGC 67 | /// @copydoc AGC 68 | EXSEISDAT_CXX_ONLY(extern "C") 69 | void exseis_AGC( 70 | size_t signal_size, 71 | exseis_Trace_value* signal, 72 | exseis_Gain_function gain_function, 73 | size_t window_size, 74 | exseis_Trace_value target_amplitude); 75 | 76 | /// @} C API 77 | 78 | #ifdef __cplusplus 79 | } // inline namespace signal_processing 80 | } // namespace utils 81 | } // namespace exseis 82 | #endif // __cplusplus 83 | 84 | #endif // EXSEISDAT_UTILS_SIGNAL_PROCESSING_AGC_H 85 | -------------------------------------------------------------------------------- /include/ExSeisDat/utils/signal_processing/taper.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief The `taper` function, applies a taper to a signal. 4 | //////////////////////////////////////////////////////////////////////////////// 5 | #ifndef EXSEISDAT_UTILS_SIGNAL_PROCESSING_TAPER_H 6 | #define EXSEISDAT_UTILS_SIGNAL_PROCESSING_TAPER_H 7 | 8 | #include "ExSeisDat/utils/c_api_utils.h" 9 | #include "ExSeisDat/utils/signal_processing/Taper_function.h" 10 | #include "ExSeisDat/utils/typedefs.h" 11 | 12 | #ifdef __cplusplus 13 | namespace exseis { 14 | namespace utils { 15 | inline namespace signal_processing { 16 | #endif // __cplusplus 17 | 18 | 19 | /// @brief Apply a taper to a signal. 20 | /// 21 | /// This taper_function will drop any initial zeros in the signal and apply the 22 | /// taper beginning from the first non-zero entry. 23 | /// 24 | /// @param[in] signal_size The number of samples in the signal 25 | /// @param[in] signal An array of amplitudes 26 | /// @param[in] taper_function Weight function for the taper ramp 27 | /// @param[in] left_tail_size Length of the left tail of the taper 28 | /// @param[in] right_tail_size Length of the right tail of the taper 29 | /// 30 | /// @note C API: exseis_taper 31 | /// 32 | #ifdef __cplusplus 33 | void taper( 34 | size_t signal_size, 35 | Trace_value* signal, 36 | Taper_function taper_function, 37 | size_t left_tail_size, 38 | size_t right_tail_size); 39 | #endif // __cplusplus 40 | 41 | /// @name C API 42 | /// @{ 43 | 44 | /// @copydoc exseis::utils::signal_processing::taper 45 | EXSEISDAT_CXX_ONLY(extern "C") 46 | void exseis_taper( 47 | size_t signal_size, 48 | exseis_Trace_value* signal, 49 | exseis_Taper_function taper_function, 50 | size_t left_tail_size, 51 | size_t right_tail_size); 52 | 53 | /// @} C API 54 | 55 | 56 | #ifdef __cplusplus 57 | } // inline namespace signal_processing 58 | } // namespace utils 59 | } // namespace exseis 60 | #endif // __cplusplus 61 | 62 | #endif // EXSEISDAT_UTILS_SIGNAL_PROCESSING_TAPER_H 63 | -------------------------------------------------------------------------------- /include/ExSeisDat/utils/typedefs.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief Typedefs used extensively throughout ExSeisDat. 4 | //////////////////////////////////////////////////////////////////////////////// 5 | #ifndef EXSEISDAT_UTILS_TYPEDEFS_H 6 | #define EXSEISDAT_UTILS_TYPEDEFS_H 7 | 8 | #include "stddef.h" 9 | 10 | #ifdef __cplusplus 11 | #include 12 | #endif // __cplusplus 13 | 14 | 15 | /// 16 | /// @namespace exseis::utils::typedefs 17 | /// 18 | /// @brief Aliases for fundamental types used throughout the ExSeisDat project. 19 | /// 20 | 21 | 22 | /// @copydoc exseis::utils::typedefs::Integer 23 | typedef long long int exseis_Integer; 24 | 25 | #ifdef __cplusplus 26 | namespace exseis { 27 | namespace utils { 28 | inline namespace typedefs { 29 | 30 | /// A fundamental signed integer type. 31 | /// 32 | /// This is used where fundamental integer type is needed, large enough to hold 33 | /// whatever value we might need it to, without explicitly specifying the size. 34 | /// 35 | using Integer = long long int; 36 | 37 | static_assert( 38 | std::is_same::value, 39 | "exseis::utils::Integer and exseis_Integer are not the same type!"); 40 | 41 | } // namespace typedefs 42 | } // namespace utils 43 | } // namespace exseis 44 | #endif // __cplusplus 45 | 46 | 47 | /// @copydoc exseis::utils::typedefs::Floating_point 48 | typedef double exseis_Floating_point; 49 | 50 | #ifdef __cplusplus 51 | namespace exseis { 52 | namespace utils { 53 | inline namespace typedefs { 54 | 55 | /// A fundamental signed floating-point type. 56 | /// 57 | /// This is used where fundamental floating-point type is needed, large enough 58 | /// to hold whatever value we might need it to, without explicitly specifying 59 | /// the size. 60 | /// 61 | using Floating_point = double; 62 | 63 | static_assert( 64 | std::is_same::value, 65 | "exseis::utils::Floating_point and exseis_Floating_point are not the same type!"); 66 | 67 | } // namespace typedefs 68 | } // namespace utils 69 | } // namespace exseis 70 | #endif // __cplusplus 71 | 72 | 73 | /// @copydoc exseis::utils::typedefs::Trace_value 74 | typedef float exseis_Trace_value; 75 | 76 | #ifdef __cplusplus 77 | namespace exseis { 78 | namespace utils { 79 | inline namespace typedefs { 80 | 81 | /// The floating-point type used to store trace values. 82 | /// 83 | /// Traces values are usually stored in a lossy, compressed form. 84 | /// As a result, we don't need a high-precision storage type. 85 | /// 86 | using Trace_value = float; 87 | 88 | static_assert( 89 | std::is_same::value, 90 | "exseis::utils::Trace_value and exseis_Trace_value are not the same type!"); 91 | 92 | } // namespace typedefs 93 | } // namespace utils 94 | } // namespace exseis 95 | #endif // __cplusplus 96 | 97 | #endif // EXSEISDAT_UTILS_TYPEDEFS_H 98 | -------------------------------------------------------------------------------- /scripts/format.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Run clang format with a few modifications. 5 | # In particular, we don't want pragma directives touched. 6 | # 7 | 8 | set -o errexit 9 | 10 | # The clang-format executable. 11 | : ${CLANG_FORMAT_EXECUTABLE:=$(which clang-format)} 12 | export CLANG_FORMAT_EXECUTABLE 13 | 14 | file="$1" 15 | tmpfile="$(mktemp)" 16 | 17 | # Make sure tmpfile is cleaned up on exit 18 | trap "rm -f \"${tmpfile}\"" EXIT 19 | 20 | # Run clang format over file with changes, write to tmpfile 21 | cat "${file}" \ 22 | | sed 's|#pragma omp|//@#pragma omp|' \ 23 | | ${CLANG_FORMAT_EXECUTABLE} -style=file \ 24 | | sed 's|//@#pragma omp|#pragma omp|' \ 25 | > "${tmpfile}" 26 | 27 | # Swap file for tmpfile, but only if there's a change 28 | set +o errexit 29 | if cmp --quiet "${tmpfile}" "${file}" 30 | then 31 | echo "Formatting ${file}: No Change..." 32 | rm "${tmpfile}" 33 | else 34 | echo "Formatting ${file}: Updating..." 35 | mv "${tmpfile}" "${file}" 36 | fi 37 | -------------------------------------------------------------------------------- /scripts/lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ $# -ne 2 ]] 4 | then 5 | echo "usage: $(basename "$0") BUILD_DIRECTORY TARGET_FILE" 6 | 7 | exit 1 8 | fi 9 | 10 | build_dir="$1" 11 | target_file="$2" 12 | 13 | 14 | # Add clang-tidy and clang-apply-replacements to $PATH 15 | case $(uname) in 16 | # On macOS, expect clang-tidy to be installed with HomeBrew 17 | # in the llvm package. This isn't added to the PATH by default because 18 | # of name clashes, but we're not worried about that here. 19 | Darwin) 20 | export PATH=$(brew --prefix llvm)/bin:$PATH 21 | ;; 22 | esac 23 | 24 | 25 | # Assume this file is in exseisdat/scripts. 26 | script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 27 | source_dir="$( cd "${script_dir}/.." && pwd)" 28 | 29 | echo "Linting (clang-tidy) ${target_file}" 30 | # cd into exseisdat project directory. 31 | # This ensures clang-tidy finds the .clang-tidy file. 32 | pushd ${source_dir} >/dev/null 33 | clang-tidy "${target_file}" \ 34 | -p "${build_dir}" \ 35 | --header-filter="${source_dir}" \ 36 | --quiet 37 | popd > /dev/null 38 | -------------------------------------------------------------------------------- /scripts/mod_gnu: -------------------------------------------------------------------------------- 1 | module load dev intel/2016-u3 gcc/5.3.0 2 | module load doxygen 3 | module load libs fftw/gcc_threads/3.3.6_single 4 | module load cmake/intel/3.5.2 5 | export CXX=g++ 6 | export CC=gcc 7 | export PIOL_SYSTEM=Fionn 8 | -------------------------------------------------------------------------------- /scripts/mod_intel: -------------------------------------------------------------------------------- 1 | module load dev intel/2016-u3 gcc/5.3.0 2 | module load doxygen 3 | module load libs fftw/intel/3.3.4 4 | module load cmake/intel/3.5.2 5 | export CXX=icpc 6 | export CC=icc 7 | export PIOL_SYSTEM=Fionn 8 | -------------------------------------------------------------------------------- /scripts/run_format.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Exit on first error 4 | set -o errexit 5 | 6 | # Assume current script is in exseisdat/scripts 7 | script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 8 | source_dir=${script_dir}/.. 9 | 10 | # Get the format script 11 | FORMAT_EXECUTABLE="${script_dir}/format.sh" 12 | 13 | cd ${source_dir} 14 | 15 | # All the directories containing source files 16 | source_dirs="examples include src systest test util" 17 | 18 | # All the extensions of source files 19 | source_exts="cc c hh h" 20 | 21 | # Number of processes to run in parallel 22 | nprocs=20 23 | 24 | for dir in $source_dirs 25 | do 26 | for ext in $source_exts 27 | do 28 | # Run clang-format on all the files with the given extension in each 29 | # directory 30 | find $dir -iname "*.${ext}" -print0 \ 31 | | xargs -n 1 -0 -P "${nprocs}" ${FORMAT_EXECUTABLE} 32 | done 33 | done 34 | -------------------------------------------------------------------------------- /scripts/run_lint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Set number of processes to use 4 | nprocs=1 5 | 6 | # Exit on first error 7 | set -o errexit 8 | 9 | 10 | # Get the build directory from the command line 11 | if [[ $# == 1 ]] 12 | then 13 | # Get absolute path of build_dir from first argument. 14 | build_dir="$(cd "$1" && pwd)" 15 | echo 16 | echo "BUILD_DIRECTORY: ${build_dir}" 17 | echo 18 | else 19 | echo 20 | echo "Error: wrong number of arguments" 21 | echo 22 | echo "usage: $(basename $0) BUILD_DIRECTORY" 23 | echo 24 | 25 | exit 1 26 | fi 27 | 28 | 29 | script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 30 | source_dir="$( cd "${script_dir}/.." && pwd)" 31 | 32 | # All the directories containing source files 33 | source_dirs="examples include src test util" 34 | 35 | # Workaround a false-positive in googletest / googlemock 36 | # 37 | # Add "// NOLINT" to the end of the offending line. 38 | # Also try to delete any " // NOLINT" that's already there, so we don't 39 | # end up with " // NOLINT // NOLINT // ..." from running this script multiple 40 | # times. 41 | gmock_problem_file=$(find ${build_dir} -name gmock-spec-builders.h) 42 | 43 | # We use cp and sed because the inline options for sed are different on 44 | # macOS and Linux. 45 | cp ${gmock_problem_file} ${gmock_problem_file}.bak 46 | sed '1272 s#\( // NOLINT\)*$# // NOLINT#' "${gmock_problem_file}.bak" \ 47 | > "${gmock_problem_file}" 48 | rm -f "${gmock_problem_file}.bak" 49 | 50 | # Run lint.sh on every source file in ExSeisDat. 51 | # 52 | # Find all the .cc files in the project and run clang-tidy on them. 53 | # Need to cd into source_dir because source_dirs are defined relative to that. 54 | # 55 | cd "${source_dir}" 56 | find ${source_dirs} \( \ 57 | -iname "*.cc" -o -iname "*.c" \ 58 | \) -print0 \ 59 | | xargs -0 -n 1 -P "${nprocs}" "${script_dir}/lint.sh" "${build_dir}" 60 | -------------------------------------------------------------------------------- /src/ExSeis.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief Implementation for \c ExSeis 4 | //////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "ExSeisDat/PIOL/ExSeis.hh" 7 | 8 | namespace exseis { 9 | namespace PIOL { 10 | 11 | ExSeis::ExSeis(const Verbosity maxLevel, MPI_Comm comm) : 12 | ExSeisPIOL(maxLevel, CommunicatorMPI::Opt{comm}) 13 | { 14 | } 15 | 16 | ExSeis::~ExSeis() = default; 17 | 18 | size_t ExSeis::getRank(void) const 19 | { 20 | return comm->getRank(); 21 | } 22 | 23 | size_t ExSeis::getNumRank(void) const 24 | { 25 | return comm->getNumRank(); 26 | } 27 | 28 | void ExSeis::barrier(void) const 29 | { 30 | comm->barrier(); 31 | } 32 | 33 | size_t ExSeis::max(size_t n) const 34 | { 35 | return comm->max(n); 36 | } 37 | 38 | void ExSeis::isErr(const std::string& msg) const 39 | { 40 | ExSeisPIOL::isErr(msg); 41 | } 42 | 43 | } // namespace PIOL 44 | } // namespace exseis 45 | -------------------------------------------------------------------------------- /src/ExSeisPIOL.cc: -------------------------------------------------------------------------------- 1 | #include "ExSeisDat/PIOL/ExSeisPIOL.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | ExSeisPIOL::ExSeisPIOL( 7 | const Verbosity maxLevel, const CommunicatorMPI::Opt& copt) 8 | { 9 | log = std::make_unique(maxLevel); 10 | comm = std::make_unique(log.get(), copt); 11 | } 12 | 13 | void ExSeisPIOL::isErr(const std::string& msg) const 14 | { 15 | if (log->isErr()) { 16 | log->record( 17 | "", Logger::Layer::PIOL, Logger::Status::Error, 18 | "Fatal Error in PIOL. " + msg + ". Dumping Log", PIOL_VERBOSITY_NONE); 19 | log->~Logger(); 20 | comm->~CommunicatorMPI(); 21 | std::_Exit(EXIT_FAILURE); 22 | } 23 | } 24 | 25 | } // namespace PIOL 26 | } // namespace exseis 27 | -------------------------------------------------------------------------------- /src/Flow/Flow_C_bindings.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief 4 | /// @details Functions etc for C Flow API 5 | //////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include "ExSeisDat/Flow.h" 8 | #include "ExSeisDat/Flow/Set.hh" 9 | 10 | #include "not_null.hh" 11 | 12 | #include 13 | #include 14 | 15 | extern "C" { 16 | 17 | PIOL_Set* PIOL_Set_new(const PIOL_ExSeis* piol, const char* ptrn) 18 | { 19 | assert(not_null(piol)); 20 | assert(not_null(ptrn)); 21 | 22 | return new exseis::Flow::Set(*piol, ptrn); 23 | } 24 | 25 | void PIOL_Set_delete(PIOL_Set* set) 26 | { 27 | delete set; 28 | } 29 | 30 | void PIOL_Set_getMinMax( 31 | PIOL_Set* set, PIOL_Meta m1, PIOL_Meta m2, struct PIOL_CoordElem* minmax) 32 | { 33 | assert(not_null(set)); 34 | assert(not_null(minmax)); 35 | 36 | set->getMinMax(m1, m2, minmax); 37 | } 38 | 39 | void PIOL_Set_sort(PIOL_Set* set, PIOL_SortType type) 40 | { 41 | assert(not_null(set)); 42 | 43 | set->sort(type); 44 | } 45 | 46 | void PIOL_Set_sort_fn( 47 | PIOL_Set* set, 48 | bool (*const func)(const PIOL_File_Param* param, size_t i, size_t j)) 49 | { 50 | assert(not_null(set)); 51 | assert(func != nullptr); 52 | 53 | set->sort(func); 54 | } 55 | 56 | void PIOL_Set_taper( 57 | PIOL_Set* set, 58 | exseis_Taper_function taper_function, 59 | size_t ntpstr, 60 | size_t ntpend) 61 | { 62 | assert(not_null(set)); 63 | assert(taper_function != nullptr); 64 | 65 | set->taper(taper_function, ntpstr, ntpend); 66 | } 67 | 68 | void PIOL_Set_AGC( 69 | PIOL_Set* set, 70 | exseis_Gain_function type, 71 | size_t window, 72 | exseis_Trace_value target_amplitude) 73 | { 74 | assert(not_null(set)); 75 | 76 | set->AGC(type, window, target_amplitude); 77 | } 78 | 79 | void PIOL_Set_output(PIOL_Set* set, const char* oname) 80 | { 81 | assert(not_null(set)); 82 | assert(not_null(oname)); 83 | 84 | set->output(oname); 85 | } 86 | 87 | void PIOL_Set_text(PIOL_Set* set, const char* outmsg) 88 | { 89 | assert(not_null(set)); 90 | assert(not_null(outmsg)); 91 | 92 | set->text(outmsg); 93 | } 94 | 95 | void PIOL_Set_summary(const PIOL_Set* set) 96 | { 97 | assert(not_null(set)); 98 | 99 | set->summary(); 100 | } 101 | 102 | void PIOL_Set_add(PIOL_Set* set, const char* name) 103 | { 104 | assert(not_null(set)); 105 | assert(not_null(name)); 106 | 107 | set->add(name); 108 | } 109 | 110 | } // extern "C" 111 | -------------------------------------------------------------------------------- /src/Flow/RadonGatherState.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | #include "ExSeisDat/Flow/RadonGatherState.hh" 6 | 7 | #include "ExSeisDat/PIOL/ReadSEGYModel.hh" 8 | #include "ExSeisDat/PIOL/makeFile.hh" 9 | 10 | using namespace exseis::PIOL; 11 | 12 | namespace exseis { 13 | namespace Flow { 14 | 15 | void RadonGatherState::makeState( 16 | const std::vector& offset, 17 | const utils::Distributed_vector& gather) 18 | { 19 | // TODO: DON'T USE MAGIC NAME 20 | std::unique_ptr vm = makeFile(piol, vmname); 21 | vNs = vm->readNs(); 22 | vInc = vm->readInc(); 23 | 24 | vtrc = vm->readModel(offset.size(), offset.data(), gather); 25 | 26 | il.resize(offset.size()); 27 | xl.resize(offset.size()); 28 | 29 | for (size_t i = 0; i < offset.size(); i++) { 30 | auto gval = gather[offset[i]]; 31 | il[i] = gval.inline_; 32 | xl[i] = gval.crossline; 33 | } 34 | } 35 | 36 | } // namespace Flow 37 | } // namespace exseis 38 | -------------------------------------------------------------------------------- /src/Logger.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | #include "ExSeisDat/PIOL/Logger.hh" 6 | 7 | #include 8 | 9 | namespace exseis { 10 | namespace PIOL { 11 | 12 | void Logger::record( 13 | const std::string file, 14 | const Logger::Layer layer, 15 | const Logger::Status stat, 16 | const std::string msg, 17 | const Verbosity verbosity, 18 | bool condition) 19 | { 20 | if (condition) { 21 | record(file, layer, stat, msg, verbosity); 22 | } 23 | } 24 | 25 | void Logger::record( 26 | const std::string file, 27 | const Logger::Layer layer, 28 | const Logger::Status stat, 29 | const std::string msg, 30 | const Verbosity verbosity) 31 | { 32 | if (verbosity <= maxLevel) { 33 | loglist_.push_front({file, layer, stat, msg, verbosity}); 34 | } 35 | 36 | if (stat == Logger::Status::Error) { 37 | error = true; 38 | } 39 | } 40 | 41 | size_t Logger::numStat(const Logger::Status stat) const 42 | { 43 | size_t sz = 0; 44 | for (auto& item : loglist_) { 45 | // The spec guarantees this is one if the equality holds 46 | if (item.stat == stat) { 47 | sz++; 48 | } 49 | } 50 | 51 | return sz; 52 | } 53 | 54 | bool Logger::isErr(void) const 55 | { 56 | return error; 57 | } 58 | 59 | void Logger::procLog(void) 60 | { 61 | for (auto& item : loglist_) { 62 | std::cerr << item.file << " " << static_cast(item.layer) << " " 63 | << static_cast(item.stat) << " " << item.msg << " " 64 | << static_cast(item.vrbsy) << std::endl; 65 | } 66 | 67 | loglist_.clear(); 68 | } 69 | 70 | } // namespace PIOL 71 | } // namespace exseis 72 | -------------------------------------------------------------------------------- /src/ObjectInterface.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @author Cathal O Broin - cathal@ichec.ie - first commit 4 | /// @copyright TBD. Do not distribute 5 | /// @date July 2016 6 | /// @brief 7 | /// @details 8 | //////////////////////////////////////////////////////////////////////////////// 9 | 10 | #include "ExSeisDat/PIOL/DataInterface.hh" 11 | #include "ExSeisDat/PIOL/ObjectInterface.hh" 12 | #include "ExSeisDat/PIOL/ObjectSEGY.hh" 13 | 14 | namespace exseis { 15 | namespace PIOL { 16 | 17 | std::shared_ptr makeDefaultObj( 18 | std::shared_ptr piol, std::string name, FileMode mode) 19 | { 20 | auto data = std::make_shared(piol, name, mode); 21 | return std::make_shared(piol, name, data, mode); 22 | } 23 | 24 | size_t ObjectInterface::getFileSz(void) const 25 | { 26 | return data_->getFileSz(); 27 | } 28 | 29 | void ObjectInterface::setFileSz(const size_t sz) const 30 | { 31 | return data_->setFileSz(sz); 32 | } 33 | 34 | } // namespace PIOL 35 | } // namespace exseis 36 | -------------------------------------------------------------------------------- /src/Param.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief 4 | //////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "ExSeisDat/PIOL/Param.h" 7 | #include "ExSeisDat/PIOL/segy_utils.hh" 8 | 9 | namespace exseis { 10 | namespace PIOL { 11 | 12 | Param::Param(std::shared_ptr r_, const size_t sz_) : r(r_), sz(sz_) 13 | { 14 | f.resize(sz * r->numFloat); 15 | i.resize(sz * r->numLong); 16 | s.resize(sz * r->numShort); 17 | t.resize(sz * r->numIndex); 18 | 19 | // @todo: This must be file format agnostic 20 | c.resize(sz * (r->numCopy != 0 ? SEGY_utils::getMDSz() : 0)); 21 | } 22 | 23 | Param::Param(const size_t sz_) : 24 | Param::Param(std::make_shared(true, true), sz_) 25 | { 26 | } 27 | 28 | Param::~Param() = default; 29 | 30 | size_t Param::size(void) const 31 | { 32 | return sz; 33 | } 34 | 35 | bool Param::operator==(struct Param& p) const 36 | { 37 | return f == p.f && i == p.i && s == p.s && t == p.t && c == p.c; 38 | } 39 | 40 | size_t Param::memUsage(void) const 41 | { 42 | return f.capacity() * sizeof(exseis::utils::Floating_point) 43 | + i.capacity() * sizeof(exseis::utils::Integer) 44 | + s.capacity() * sizeof(int16_t) + t.capacity() * sizeof(size_t) 45 | + c.capacity() * sizeof(unsigned char) + sizeof(Param) 46 | + r->memUsage(); 47 | } 48 | 49 | } // namespace PIOL 50 | } // namespace exseis 51 | -------------------------------------------------------------------------------- /src/ReadDirect.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief Implementation for \c ReadDirect 4 | //////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "ExSeisDat/PIOL/ReadDirect.hh" 7 | 8 | #include "ExSeisDat/PIOL/DataMPIIO.hh" 9 | #include "ExSeisDat/PIOL/ExSeisPIOL.hh" 10 | #include "ExSeisDat/PIOL/ObjectSEGY.hh" 11 | #include "ExSeisDat/PIOL/ReadSEGY.hh" 12 | 13 | namespace exseis { 14 | namespace PIOL { 15 | 16 | ReadDirect::ReadDirect(std::shared_ptr piol, const std::string name) 17 | { 18 | const ReadSEGY::Opt f; 19 | const ObjectSEGY::Opt o; 20 | const DataMPIIO::Opt d; 21 | auto data = std::make_shared(piol, name, d, FileMode::Read); 22 | auto obj = 23 | std::make_shared(piol, name, o, data, FileMode::Read); 24 | file = std::make_shared(piol, name, f, obj); 25 | } 26 | 27 | ReadDirect::ReadDirect(std::shared_ptr file_) : file(file_) {} 28 | 29 | ReadDirect::~ReadDirect() = default; 30 | 31 | const std::string& ReadDirect::readText(void) const 32 | { 33 | return file->readText(); 34 | } 35 | 36 | size_t ReadDirect::readNs(void) const 37 | { 38 | return file->readNs(); 39 | } 40 | 41 | size_t ReadDirect::readNt(void) const 42 | { 43 | return file->readNt(); 44 | } 45 | 46 | exseis::utils::Floating_point ReadDirect::readInc(void) const 47 | { 48 | return file->readInc(); 49 | } 50 | 51 | void ReadDirect::readParam( 52 | const size_t offset, const size_t sz, Param* prm) const 53 | { 54 | file->readParam(offset, sz, prm); 55 | } 56 | 57 | void ReadDirect::readTrace( 58 | const size_t offset, 59 | const size_t sz, 60 | exseis::utils::Trace_value* trace, 61 | Param* prm) const 62 | { 63 | file->readTrace(offset, sz, trace, prm); 64 | } 65 | 66 | void ReadDirect::readTraceNonContiguous( 67 | const size_t sz, 68 | const size_t* offset, 69 | exseis::utils::Trace_value* trace, 70 | Param* prm) const 71 | { 72 | file->readTraceNonContiguous(sz, offset, trace, prm); 73 | } 74 | 75 | void ReadDirect::readTraceNonMonotonic( 76 | const size_t sz, 77 | const size_t* offset, 78 | exseis::utils::Trace_value* trace, 79 | Param* prm) const 80 | { 81 | file->readTraceNonMonotonic(sz, offset, trace, prm); 82 | } 83 | 84 | void ReadDirect::readParamNonContiguous( 85 | const size_t sz, const size_t* offset, Param* prm) const 86 | { 87 | file->readParamNonContiguous(sz, offset, prm); 88 | } 89 | 90 | } // namespace PIOL 91 | } // namespace exseis 92 | -------------------------------------------------------------------------------- /src/ReadInterface.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @author Cathal O Broin - cathal@ichec.ie - first commit 4 | /// @copyright TBD. Do not distribute 5 | /// @date July 2016 6 | /// @brief 7 | /// @details 8 | //////////////////////////////////////////////////////////////////////////////// 9 | 10 | #include "ExSeisDat/PIOL/ReadInterface.hh" 11 | 12 | namespace exseis { 13 | namespace PIOL { 14 | 15 | const exseis::utils::Trace_value* TRACE_NULL = (exseis::utils::Trace_value*)1; 16 | 17 | // TODO: Unit test 18 | void ReadInterface::readParam( 19 | const size_t offset, const size_t sz, Param* prm, const size_t skip) const 20 | { 21 | readTrace( 22 | offset, sz, const_cast(TRACE_NULL), prm, 23 | skip); 24 | } 25 | 26 | void ReadInterface::readParamNonContiguous( 27 | const size_t sz, const size_t* offsets, Param* prm, const size_t skip) const 28 | { 29 | readTraceNonContiguous( 30 | sz, offsets, const_cast(TRACE_NULL), prm, 31 | skip); 32 | } 33 | 34 | const std::string& ReadInterface::readText(void) const 35 | { 36 | return text; 37 | } 38 | 39 | size_t ReadInterface::readNs(void) const 40 | { 41 | return ns; 42 | } 43 | 44 | exseis::utils::Floating_point ReadInterface::readInc(void) const 45 | { 46 | return inc; 47 | } 48 | 49 | } // namespace PIOL 50 | } // namespace exseis 51 | -------------------------------------------------------------------------------- /src/ReadModel.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief 4 | /// @details Implementation for \c ReadModel 5 | //////////////////////////////////////////////////////////////////////////////// 6 | 7 | #include "ExSeisDat/PIOL/ReadModel.hh" 8 | 9 | #include "ExSeisDat/PIOL/DataMPIIO.hh" 10 | #include "ExSeisDat/PIOL/ObjectSEGY.hh" 11 | #include "ExSeisDat/PIOL/ReadSEGYModel.hh" 12 | 13 | namespace exseis { 14 | namespace PIOL { 15 | 16 | ReadModel::ReadModel(std::shared_ptr piol, const std::string name) : 17 | ReadDirect( 18 | piol, name, DataMPIIO::Opt(), ObjectSEGY::Opt(), ReadSEGYModel::Opt()) 19 | { 20 | } 21 | 22 | std::vector ReadModel::readModel( 23 | size_t gOffset, 24 | size_t numGather, 25 | utils::Distributed_vector& gather) 26 | { 27 | return std::dynamic_pointer_cast(file)->readModel( 28 | gOffset, numGather, gather); 29 | } 30 | 31 | } // namespace PIOL 32 | } // namespace exseis 33 | -------------------------------------------------------------------------------- /src/WriteDirect.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief Implementation for \c WriteDirect 4 | //////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "ExSeisDat/PIOL/WriteDirect.hh" 7 | 8 | #include "ExSeisDat/PIOL/DataMPIIO.hh" 9 | #include "ExSeisDat/PIOL/ObjectSEGY.hh" 10 | #include "ExSeisDat/PIOL/WriteSEGY.hh" 11 | 12 | namespace exseis { 13 | namespace PIOL { 14 | 15 | WriteDirect::WriteDirect( 16 | std::shared_ptr piol, const std::string name) 17 | { 18 | const WriteSEGY::Opt f; 19 | const ObjectSEGY::Opt o; 20 | const DataMPIIO::Opt d; 21 | 22 | auto data = std::make_shared(piol, name, d, FileMode::Write); 23 | 24 | auto obj = 25 | std::make_shared(piol, name, o, data, FileMode::Write); 26 | 27 | file = std::make_shared(piol, name, f, obj); 28 | } 29 | 30 | WriteDirect::WriteDirect(std::shared_ptr file_) : file(file_) {} 31 | 32 | WriteDirect::~WriteDirect() = default; 33 | 34 | 35 | void WriteDirect::writeParam( 36 | const size_t offset, const size_t sz, const Param* prm) 37 | { 38 | file->writeParam(offset, sz, prm); 39 | } 40 | 41 | void WriteDirect::writeTrace( 42 | const size_t offset, 43 | const size_t sz, 44 | exseis::utils::Trace_value* trace, 45 | const Param* prm) 46 | { 47 | file->writeTrace(offset, sz, trace, prm); 48 | } 49 | 50 | void WriteDirect::writeTraceNonContiguous( 51 | const size_t sz, 52 | const size_t* offset, 53 | exseis::utils::Trace_value* trace, 54 | const Param* prm) 55 | { 56 | file->writeTraceNonContiguous(sz, offset, trace, prm); 57 | } 58 | 59 | void WriteDirect::writeParamNonContiguous( 60 | const size_t sz, const size_t* offset, const Param* prm) 61 | { 62 | file->writeParamNonContiguous(sz, offset, prm); 63 | } 64 | 65 | void WriteDirect::writeText(const std::string text_) 66 | { 67 | file->writeText(text_); 68 | } 69 | 70 | void WriteDirect::writeNs(const size_t ns_) 71 | { 72 | file->writeNs(ns_); 73 | } 74 | 75 | void WriteDirect::writeNt(const size_t nt_) 76 | { 77 | file->writeNt(nt_); 78 | } 79 | 80 | void WriteDirect::writeInc(const exseis::utils::Floating_point inc_) 81 | { 82 | file->writeInc(inc_); 83 | } 84 | 85 | } // namespace PIOL 86 | } // namespace exseis 87 | -------------------------------------------------------------------------------- /src/WriteInterface.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief Implementation for \c WriteInterface 4 | //////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "ExSeisDat/PIOL/WriteInterface.hh" 7 | 8 | namespace exseis { 9 | namespace PIOL { 10 | 11 | void WriteInterface::writeParam( 12 | const size_t offset, const size_t sz, const Param* prm, const size_t skip) 13 | { 14 | writeTrace( 15 | offset, sz, const_cast(TRACE_NULL), prm, 16 | skip); 17 | } 18 | 19 | void WriteInterface::writeParamNonContiguous( 20 | const size_t sz, const size_t* offset, const Param* prm, const size_t skip) 21 | { 22 | writeTraceNonContiguous( 23 | sz, offset, const_cast(TRACE_NULL), prm, 24 | skip); 25 | } 26 | 27 | } // namespace PIOL 28 | } // namespace exseis 29 | -------------------------------------------------------------------------------- /src/minmax.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | 5 | #include "ExSeisDat/PIOL/operations/minmax.h" 6 | #include "ExSeisDat/PIOL/param_utils.hh" 7 | #include "ExSeisDat/utils/typedefs.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace exseis { 14 | namespace PIOL { 15 | 16 | void getMinMax( 17 | ExSeisPIOL* piol, 18 | size_t offset, 19 | size_t lnt, 20 | Meta m1, 21 | Meta m2, 22 | const Param* prm, 23 | CoordElem* minmax) 24 | { 25 | std::vector vprm; 26 | // TODO: Just add the two meta options to the rules with defaults? 27 | for (size_t i = 0; i < lnt; i++) { 28 | vprm.emplace_back(prm->r, 1LU); 29 | param_utils::cpyPrm(i, prm, 0, &vprm.back()); 30 | } 31 | 32 | getMinMax( 33 | piol, offset, lnt, vprm.data(), 34 | [m1](const Param& a) -> exseis::utils::Floating_point { 35 | return param_utils::getPrm( 36 | 0LU, m1, &a); 37 | }, 38 | [m2](const Param& a) -> exseis::utils::Floating_point { 39 | return param_utils::getPrm( 40 | 0LU, m2, &a); 41 | }, 42 | minmax); 43 | } 44 | 45 | } // namespace PIOL 46 | } // namespace exseis 47 | -------------------------------------------------------------------------------- /src/not_null.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief 4 | /// @details Tests for nullness and emptiness of pointers and shared_ptrs. 5 | //////////////////////////////////////////////////////////////////////////////// 6 | #ifndef EXSEISDAT_SRC_NOT_NULL_HH 7 | #define EXSEISDAT_SRC_NOT_NULL_HH 8 | 9 | #include 10 | 11 | /// Test if a pointer is null 12 | /// @param t The pointer to test for nullness. 13 | /// @return Returns true if \c t is null. 14 | template 15 | static inline bool not_null(const T* t) 16 | { 17 | return t != nullptr; 18 | } 19 | 20 | /// Test if a shared_ptr pointer is null, and test if its contents 21 | /// is null. 22 | /// @param t The pointer to shared_ptr to test for nullness. 23 | /// @return Returns true if \c t is null, and its contents are not null. 24 | template 25 | static inline bool not_null(const std::shared_ptr* t) 26 | { 27 | return t != nullptr && not_null(t->get()); 28 | } 29 | 30 | #endif // EXSEISDAT_SRC_NOT_NULL_HH 31 | -------------------------------------------------------------------------------- /src/utils/mpi/MPI_error_to_string.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief Implementation of MPI_error_to_string. 4 | //////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "ExSeisDat/utils/mpi/MPI_error_to_string.hh" 7 | 8 | 9 | namespace exseis { 10 | namespace utils { 11 | 12 | 13 | /// @brief Helper function to get the string associated with an MPI error code. 14 | /// 15 | /// @param[in] mpi_error The MPI error code 16 | /// 17 | /// @return The result from MPI_Error_string for the string, if there is one. 18 | /// Otherwise a message noting there is no string. 19 | static std::string get_error_string(int mpi_error) 20 | { 21 | // Buffer for getting the string from MPI_Error_string. 22 | char buffer[MPI_MAX_ERROR_STRING] = {0}; 23 | int buffer_size = MPI_MAX_ERROR_STRING; 24 | 25 | int err = MPI_Error_string(mpi_error, buffer, &buffer_size); 26 | 27 | // Make sure the buffer is terminated. 28 | buffer[buffer_size - 1] = '\0'; 29 | 30 | // On failure, or if the buffer is zero length, assume there is no 31 | // message string. 32 | if (err != MPI_SUCCESS || buffer_size == 0 || strlen(buffer) == 0) { 33 | return "***Error string missing***"; 34 | } 35 | 36 | return buffer; 37 | } 38 | 39 | std::string MPI_error_to_string(int mpi_error, const MPI_Status* mpi_status) 40 | { 41 | using namespace std::string_literals; 42 | 43 | // Fix argument for user passing in a nullptr instead of MPI_STATUS_IGNORE. 44 | if (mpi_status == nullptr) { 45 | mpi_status = MPI_STATUS_IGNORE; 46 | } 47 | 48 | int mpi_error_class = 0; 49 | int err = MPI_Error_class(mpi_error, &mpi_error_class); 50 | 51 | // MPI_Error_class shouldn't fail!! 52 | if (err != MPI_SUCCESS) { 53 | return "*** MPI_error_to_string: MPI_Error_class: "s 54 | + get_error_string(err) + " ***"s; 55 | } 56 | 57 | // Special return case: Success 58 | if (mpi_error_class == MPI_SUCCESS) { 59 | return "MPI_SUCCESS"; 60 | } 61 | 62 | // Special return case: Error in status. 63 | if (mpi_error_class == MPI_ERR_IN_STATUS) { 64 | 65 | if (mpi_status == MPI_STATUS_IGNORE || mpi_status == nullptr) { 66 | // Error: status needed, but status omitted. 67 | return "MPI_Error: MPI_ERR_IN_STATUS, but status was OMITTED!"s; 68 | } 69 | else { 70 | return MPI_error_to_string(mpi_status->MPI_ERROR); 71 | } 72 | } 73 | 74 | // Build basic error message 75 | return "MPI Error code: "s + std::to_string(mpi_error) + ": "s 76 | + get_error_string(mpi_error) + "; MPI Error class: "s 77 | + std::to_string(mpi_error_class) + ": "s 78 | + get_error_string(mpi_error_class); 79 | } 80 | 81 | } // namespace utils 82 | } // namespace exseis 83 | -------------------------------------------------------------------------------- /src/utils/signal_processing/Taper_function.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief Implementation of the built in `Taper_function`s. 4 | //////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "ExSeisDat/utils/signal_processing/Taper_function.h" 7 | 8 | #include 9 | 10 | namespace exseis { 11 | namespace utils { 12 | inline namespace signal_processing { 13 | 14 | 15 | Trace_value linear_taper(Trace_value weight, Trace_value ramp) 16 | { 17 | return 1.0f - std::abs((weight - ramp) / ramp); 18 | } 19 | 20 | extern "C" exseis_Trace_value exseis_linear_taper( 21 | exseis_Trace_value weight, exseis_Trace_value ramp) 22 | { 23 | return linear_taper(weight, ramp); 24 | } 25 | 26 | 27 | Trace_value cosine_taper(Trace_value weight, Trace_value ramp) 28 | { 29 | constexpr Trace_value pi = 3.14159265358979323846264338327950288; 30 | return 0.5f + 0.5f * std::cos(pi * (weight - ramp) / ramp); 31 | } 32 | 33 | extern "C" exseis_Trace_value exseis_cosine_taper( 34 | exseis_Trace_value weight, exseis_Trace_value ramp) 35 | { 36 | return cosine_taper(weight, ramp); 37 | } 38 | 39 | 40 | Trace_value cosine_square_taper(Trace_value weight, Trace_value ramp) 41 | { 42 | return std::pow(cosine_taper(weight, ramp), 2); 43 | } 44 | 45 | extern "C" exseis_Trace_value exseis_cosine_square_taper( 46 | exseis_Trace_value weight, exseis_Trace_value ramp) 47 | { 48 | return cosine_square_taper(weight, ramp); 49 | } 50 | 51 | 52 | } // namespace signal_processing 53 | } // namespace utils 54 | } // namespace exseis 55 | -------------------------------------------------------------------------------- /src/utils/signal_processing/taper.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @brief Implementation of the taper function. 4 | //////////////////////////////////////////////////////////////////////////////// 5 | 6 | #include "ExSeisDat/utils/signal_processing/taper.h" 7 | 8 | #include 9 | #include 10 | 11 | namespace exseis { 12 | namespace utils { 13 | inline namespace signal_processing { 14 | 15 | 16 | void taper( 17 | size_t signal_size, 18 | Trace_value* signal, 19 | Taper_function taper_function, 20 | size_t left_taper_size, 21 | size_t right_taper_size) 22 | { 23 | assert(signal_size > left_taper_size && signal_size > right_taper_size); 24 | 25 | // Drop muted trace region at the start, if it's there, and call this 26 | // function again for the truncated region. 27 | if (signal[0] == 0) { 28 | 29 | // Find the first non-zero entry 30 | const auto non_zero = [](auto v) { return v != 0; }; 31 | 32 | auto* truncated_signal = 33 | std::find_if(signal, signal + signal_size, non_zero); 34 | assert(truncated_signal[0] != 0); 35 | 36 | 37 | // Find the new sizes 38 | const auto truncated_signal_size = 39 | signal_size - std::distance(signal, truncated_signal); 40 | 41 | const auto truncated_left = 42 | std::min(left_taper_size, truncated_signal_size); 43 | 44 | const auto truncated_right = 45 | std::min(right_taper_size, truncated_signal_size); 46 | 47 | 48 | // Call this function again with the new range 49 | return taper( 50 | truncated_signal_size, truncated_signal, taper_function, 51 | truncated_left, truncated_right); 52 | } 53 | 54 | 55 | // Apply the left taper 56 | for (size_t j = 0; j < left_taper_size; j++) { 57 | signal[j] *= taper_function(j + 1, left_taper_size); 58 | } 59 | 60 | // Apply the right taper 61 | for (size_t j = 0; j < right_taper_size; j++) { 62 | const auto offset = signal_size - right_taper_size; 63 | 64 | signal[offset + j] *= 65 | taper_function(right_taper_size - j, right_taper_size); 66 | } 67 | } 68 | 69 | extern "C" void exseis_taper( 70 | size_t signal_size, 71 | exseis_Trace_value* signal, 72 | exseis_Taper_function taper_function, 73 | size_t left_tail_size, 74 | size_t right_tail_size) 75 | { 76 | taper(signal_size, signal, taper_function, left_tail_size, right_tail_size); 77 | } 78 | 79 | 80 | } // namespace signal_processing 81 | } // namespace utils 82 | } // namespace exseis 83 | -------------------------------------------------------------------------------- /systest/README: -------------------------------------------------------------------------------- 1 | 1. git clone https://github.com/Microsoft/pict 2 | 2. Use pict to generate a file of combinations: testmatrix 3 | Tullow Only: Add a hosts.txt with a list of the available nodes 4 | 3. Run que.sh 5 | a. use testmatrix to generate a list of parameters for a specific node count 6 | b. que jobs corresponding to the node counts 7 | 4. After the jobs finish running, process them by "bash process.sh" 8 | 9 | 10 | -------------------------------------------------------------------------------- /systest/example_combo0: -------------------------------------------------------------------------------- 1 | NODE_COUNT: 1, 5 2 | NODE_PPN: 1, 23, 24 3 | MPI: openmpi, mvapich, intelmpi 4 | TEST_NAMES: filemake 5 | INPUT: EMPTY 6 | STRIPE_COUNT: 10 7 | COMPILER: intel, gnu 8 | -------------------------------------------------------------------------------- /systest/example_combo1: -------------------------------------------------------------------------------- 1 | NODE_COUNT: 1, 5 2 | NODE_PPN: 1, 23, 24 3 | MPI: openmpi, mvapich, intelmpi 4 | TEST_NAMES: creadwrite, minmax, makerep, concatenate 5 | INPUT: /ichec/work/exseisdat/dat/10/zero.segy, /ichec/work/exseisdat/dat/10/one.segy, /ichec/work/exseisdat/dat/10/bigns.segy, /ichec/work/exseisdat/dat/10/small.segy, /ichec/work/exseisdat/dat/10/medium.segy, /ichec/work/exseisdat/dat/10/large.segy 6 | STRIPE_COUNT: 10 7 | COMPILER: intel, gnu 8 | -------------------------------------------------------------------------------- /systest/extra_testmatrix_0param: -------------------------------------------------------------------------------- 1 | 1 1 intel filemake 10 gnu 2 | 5 23 intel filemake 10 intel 3 | 1 23 openmpi/gcc/1.8.4 filemake 10 gnu 4 | 5 13 openmpi/gcc/1.8.4 filemake 10 gnu 5 | 1 24 intel filemake 10 intel 6 | 5 24 mvapich2/intel/2.1a filemake 10 intel 7 | -------------------------------------------------------------------------------- /systest/extra_testmatrix_1param: -------------------------------------------------------------------------------- 1 | 1 23 openmpi/gcc/1.8.4 concatenate 10 gnu /ichec/work/exseisdat/dat/10/bigns.segy 2 | 5 24 intel minmax 10 intel /ichec/work/exseisdat/dat/10/small.segy 3 | 5 23 mvapich2/intel/2.1a makerep 10 intel /ichec/work/exseisdat/dat/10/bigns.segy 4 | 1 24 intel makerep 10 gnu /ichec/work/exseisdat/dat/10/one.segy 5 | 5 24 mvapich2/intel/2.1a concatenate 10 intel /ichec/work/exseisdat/dat/10/zero.segy 6 | 1 24 openmpi/gcc/1.8.4 creadwrite 10 gnu /ichec/work/exseisdat/dat/10/bigns.segy 7 | 1 23 mvapich2/intel/2.1a creadwrite 10 intel /ichec/work/exseisdat/dat/10/zero.segy 8 | 1 23 intel concatenate 10 gnu /ichec/work/exseisdat/dat/10/one.segy 9 | 1 24 mvapich2/intel/2.1a makerep 10 gnu /ichec/work/exseisdat/dat/10/small.segy 10 | 1 24 intel segsort 10 intel /ichec/work/exseisdat/dat/10/bigns.segy 11 | 1 24 intel creadwrite 10 intel /ichec/work/exseisdat/dat/10/small.segy 12 | 5 23 intel segsort 10 intel /ichec/work/exseisdat/dat/10/small.segy 13 | 1 24 mvapich2/intel/2.1a concatenate 10 intel /ichec/work/exseisdat/dat/10/small.segy 14 | 1 24 mvapich2/intel/2.1a creadwrite 10 intel /ichec/work/exseisdat/dat/10/one.segy 15 | 5 23 intel makerep 10 gnu /ichec/work/exseisdat/dat/10/zero.segy 16 | 5 24 mvapich2/intel/2.1a minmax 10 gnu /ichec/work/exseisdat/dat/10/one.segy 17 | 5 23 mvapich2/intel/2.1a minmax 10 gnu /ichec/work/exseisdat/dat/10/bigns.segy 18 | 5 23 intel creadwrite 10 intel /ichec/work/exseisdat/dat/10/medium.segy 19 | 1 24 mvapich2/intel/2.1a segsort 10 gnu /ichec/work/exseisdat/dat/10/medium.segy 20 | 1 24 openmpi/intel/1.8.3 makerep 10 intel /ichec/work/exseisdat/dat/10/medium.segy 21 | 1 24 intel concatenate 10 gnu /ichec/work/exseisdat/dat/10/medium.segy 22 | 5 23 mvapich2/intel/2.1a minmax 10 intel /ichec/work/exseisdat/dat/10/medium.segy 23 | -------------------------------------------------------------------------------- /systest/farm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #TODO: More safety checks 3 | 4 | read -r NODE_COUNT NODE_PPN MPI NAME STRIPE_COUNT MODULE FILENAME1 FILENAME2 < <(echo "$@") 5 | 6 | echo Line: $NODE_COUNT $NODE_PPN $MPI $NAME $STRIPE_COUNT $MODULE $FILENAME1 $FILENAME2 7 | 8 | #global variables 9 | source /etc/profile.d/modules.sh #So we can use the module command 10 | source ../mod_$MODULE 11 | 12 | if [ $MPI != "intel" ]; then 13 | module load $MPI 14 | fi 15 | 16 | export MPI_BASE=$(echo $MPI | cut -d \/ -f 1) 17 | 18 | if [ $MPI_BASE == "openmpi" ]; then 19 | PPN_COMMAND="--map-by ppr:$NODE_PPN:node" 20 | else 21 | PPN_COMMAND="-ppn $NODE_PPN" 22 | fi 23 | 24 | if [ $MODULE == "intel" -o $MODULE == "tullow" ]; then 25 | export MPICH_CXX=icpc 26 | export MPICH_CC=icc 27 | fi 28 | 29 | #########SETTINGS######### 30 | DIR_NAME=$TEST_DIR/$(date +%s)$$ 31 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DIR_NAME/lib 32 | export LIBRARY_PATH=$LIBRARY_PATH:$DIR_NAME/lib 33 | export C_INCLUDE_PATH=$C_INCLUDE_PATH:$PWD/api:$PIOL_DIR/include 34 | export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$PWD/api:$PIOL_DIR/include 35 | #########END SETTINGS######### 36 | 37 | # Make test directory 38 | mkdir $DIR_NAME 39 | # Making sub-directories 40 | cp make.sh $DIR_NAME/ 41 | cd $DIR_NAME 42 | mkdir src dat api util lib 43 | mkdir src/obj api/obj util/obj 44 | 45 | if [ $PIOL_SYSTEM != "Tullow" ]; then 46 | lfs setstripe -c $STRIPE_COUNT dat 47 | else 48 | #TODO: I am not aware of any panasas ability to set stripe counts 49 | # on a per file basis. 50 | echo Can not set stripes to $STRIPE_COUNT - Panasas 51 | fi 52 | 53 | bash make.sh $NAME 54 | 55 | # run the test 56 | mv util/$NAME . 57 | 58 | set -f 59 | echo $(which time) -f "%e %I %O %M %W" mpirun $PPN_COMMAND $NAME $ARGUMENTS > ARGUMENTS 60 | set +f 61 | 62 | if [ -f $NAME ]; then 63 | if [ $PIOL_SYSTEM == "Tullow" ]; then 64 | head -n $NODES hosts.txt > hostsfinal.txt 65 | set -f 66 | $(which time) -f "%e %I %O %M %W" mpirun -f hostsfinal.txt $PPN_COMMAND $NAME $ARGUMENTS 2> TIME > MSG 67 | set +f 68 | else 69 | set -f 70 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib $(which time) -f "%e %I %O %M %W" mpirun $PPN_COMMAND $NAME $ARGUMENTS 2> TIME > MSG 71 | set +f 72 | fi 73 | else 74 | echo FILE DID NOT COMPILE 75 | fi 76 | 77 | if [[ -n $FILENAME1 ]]; then 78 | FILENAME1=$(basename $FILENAME1 .segy) 79 | fi 80 | if [[ -n $FILENAME2 ]]; then 81 | FILENAME2=$(basename $FILENAME2 .segy) 82 | fi 83 | 84 | cat $PIOL_DIR/checksum/checksum_$FILENAME1${FILENAME2}_$NAME > CMP_CHECKSUM 85 | FILENAME=$FILENAME1${FILENAME2} 86 | if [[ -z $FILENAME ]]; then 87 | FILENAME=EMPTY 88 | fi 89 | 90 | if [ -z $PBS_NODEFILE ]; then 91 | echo -n $NAME$NODE_COUNT$NODE_PPN$MPI_BASE$STRIPE_COUNT$MODULE $FILENAME $NODE_PPN $(expr $NODES \* $NODE_PPN) > CHECK 92 | else 93 | echo -n $NAME$NODE_COUNT$NODE_PPN$MPI_BASE$STRIPE_COUNT$MODULE $FILENAME $NODE_PPN $(wc -l $PBS_NODEFILE | cut -d ' ' -f 1) > CHECK 94 | fi 95 | -------------------------------------------------------------------------------- /systest/genfiles.pbs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #PBS -l nodes=1:ppn=24 3 | #PBS -l walltime=0:00:10:00 4 | #PBS -N genfiles 5 | #PBS -A lero 6 | #PBS -r n 7 | #PBS -j oe 8 | #PBS -m bea 9 | 10 | if [ -n "$PBS_O_WORKDIR" ]; then 11 | cd $PBS_O_WORKDIR 12 | fi 13 | 14 | source /etc/profile.d/modules.sh #So we can use the module command 15 | 16 | if [ "$PIOL_SYSTEM" == "Tullow" ]; then 17 | dat=/panfs/gpt2/MODELLING/DEVELOP/piotest/dat/ 18 | else 19 | source ../mod_intel 20 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/ichec/work/staff/cathal/ExSeisDat/lib 21 | dat=/ichec/work/exseisdat/dat/10/ 22 | fi 23 | 24 | date 25 | #time ../util/filemake -s 200 -t 0 -m 2048 -i 0.04 -o $dat/zero.segy 26 | #time ../util/filemake -s 200 -t 1 -m 2048 -i 0.04 -o $dat/one.segy 27 | #time ../util/filemake -s 32767 -t 100 -m 2048 -i 0.04 -o $dat/bigns.segy 28 | #time ../util/filemake -s 800 -t 1000 -m 2048 -i 0.04 -o $dat/small.segy 29 | time mpirun -ppn 24 ../util/filemake -s 1000 -t 50648198 -m 1024 -i 0.04 -o $dat/medium2.segy 30 | #time mpirun -ppn 24 ../util/filemake -s 1000 -t 1006481980 -m 2048 -i 0.04 -o $dat/large.segy 31 | date 32 | -------------------------------------------------------------------------------- /systest/main.cc: -------------------------------------------------------------------------------- 1 | #include "gmock/gmock.h" 2 | #include "gtest/gtest.h" 3 | 4 | using namespace testing; 5 | 6 | int main(int argc, char** argv) 7 | { 8 | InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } 11 | -------------------------------------------------------------------------------- /systest/make.sh: -------------------------------------------------------------------------------- 1 | # copy src files and the utility 2 | #C 3 | 4 | if [ -z $PIOL_DIR ] 5 | then 6 | echo PIOL_DIR is not defined 7 | fi 8 | 9 | cp $PIOL_DIR/util/*.c util/ 10 | cp $PIOL_DIR/util/*.h util/ 11 | cp $PIOL_DIR/util/*.cc util/ 12 | cp $PIOL_DIR/util/*.hh util/ 13 | cp $PIOL_DIR/util/makefile util/ 14 | 15 | cp $PIOL_DIR/api/*.cc api/ 16 | cp $PIOL_DIR/api/*.hh api/ 17 | cp $PIOL_DIR/api/*.h api/ 18 | cp $PIOL_DIR/api/makefile api/ 19 | if [ $PIOL_SYSTEM == "Tullow" ]; then 20 | cp $PIOL_DIR/systest/hosts.txt . 21 | fi 22 | cp $PIOL_DIR/src/*.cc src/ 23 | cp $PIOL_DIR/src/makefile src/ 24 | 25 | cp $PIOL_DIR/makefile . 26 | cp $PIOL_DIR/compiler.cfg . 27 | 28 | cd src 29 | make -j 23 > /dev/null 30 | cd ../api 31 | make > /dev/null 32 | cd ../util 33 | make -j 24 $1 > /dev/null 34 | 35 | -------------------------------------------------------------------------------- /systest/makefile: -------------------------------------------------------------------------------- 1 | LDFLAGS=gmock-all.o gtest-all.o $(TULLOW_LIBS) 2 | TEST_FRAM=-I../googletest/googletest/include/ -I../googletest/googlemock/include/ 3 | 4 | include ../compiler.cfg 5 | 6 | .PHONY: all 7 | all: libgmock.a test 8 | 9 | GCOMP=$(CXX) 10 | GTEST_DIR=../googletest/googletest 11 | GMOCK_DIR=../googletest/googlemock 12 | 13 | libgmock.a: 14 | $(GCOMP) -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \ 15 | -isystem ${GMOCK_DIR}/include -I${GMOCK_DIR} \ 16 | -pthread -c ${GTEST_DIR}/src/gtest-all.cc 17 | $(GCOMP) -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \ 18 | -isystem ${GMOCK_DIR}/include -I${GMOCK_DIR} \ 19 | -pthread -c ${GMOCK_DIR}/src/gmock-all.cc 20 | ar -rv libgmock.a gtest-all.o gmock-all.o 21 | 22 | test: tests.o main.o 23 | $(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $+ 24 | 25 | .PHONY: clean 26 | clean: 27 | rm -f test tests.o main.o *.optrpt 28 | 29 | googleclean: 30 | rm -f libgmock.a gtest-all.o gmock-all.o 31 | 32 | %.o: %.cc 33 | $(CXX) $(CXXFLAGS) $(TEST_FRAM) -c $< -o $@ 34 | 35 | -------------------------------------------------------------------------------- /systest/md5sum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ $PIOL_SYSTEM == "Tullow" ]; then 3 | TEST_DIR=/panfs/gpt2/SEAM_DATA/temp/$USER 4 | else 5 | TEST_DIR=/ichec/work/exseisdat/test/$USER 6 | fi 7 | 8 | for file in $TEST_DIR/* 9 | do 10 | cd $file 11 | pwd 12 | if [ -d util ]; then 13 | read -r str < <(head -n 1 CHECK) 14 | set -- $str 15 | if [[ $# == 4 ]]; then 16 | md5sum dat/* | cut -d ' ' -f 1 > newChecksum 17 | if [ ! -f CMP_CHECKSUM ]; then 18 | RET=4 19 | else 20 | cmp newChecksum CMP_CHECKSUM 21 | RET=$? 22 | fi 23 | echo " " $RET >> CHECK 24 | fi 25 | else 26 | echo Skip $file 27 | fi 28 | cd .. 29 | done 30 | 31 | -------------------------------------------------------------------------------- /systest/process.sh: -------------------------------------------------------------------------------- 1 | # For each line, create a google-test function 2 | if [ -z $PIOL_SYSTEM ]; then 3 | echo Please load relevant modules. 4 | exit 5 | fi 6 | 7 | if [ $PIOL_SYSTEM == Tullow ]; then 8 | TEST_DIR=/panfs/gpt2/SEAM_DATA/temp/$USER 9 | else 10 | TEST_DIR=/ichec/work/exseisdat/test/$USER 11 | fi 12 | 13 | cat > tests.cc << EOL 14 | #include "gtest/gtest.h" 15 | #include "gmock/gmock.h" 16 | EOL 17 | j=0 18 | for dir in $TEST_DIR/* 19 | do 20 | export NAME 21 | 22 | if [ -f $dir/CHECK ]; then 23 | read -r NAME FILE PPN PPNN SUCCESS < <(head -n 1 $dir/CHECK) 24 | else 25 | NAME=FAIL$j 26 | FILE=FAIL 27 | SUCCESS=3 28 | PPN=0 29 | PPNN=0 30 | j=${j+1} 31 | fi 32 | 33 | if [ -f $dir/TIME ]; then 34 | read -r TIME < <(tail -n 1 $dir/TIME | cut -d ' ' -f 1) 35 | else 36 | TIME=NAN 37 | fi 38 | 39 | cat >> tests.cc << EOL 40 | TEST($NAME, $(basename $FILE .segy)${PPN}${PPNN}) 41 | { 42 | ASSERT_EQ(0, $SUCCESS); 43 | std::cout << "runtime " << "$TIME" << std::endl; 44 | } 45 | EOL 46 | done 47 | 48 | #compile 49 | make -j 2 > /dev/null 50 | 51 | #run 52 | ./test 53 | 54 | #remove & cleanup 55 | make clean > /dev/null 56 | if [ -n $TEST_DIR ]; then 57 | echo rm -r -I "$TEST_DIR/*" 58 | rm -r -I $TEST_DIR/* 59 | echo rm -r -I "TEST*" 60 | rm -r -I TEST* 61 | fi 62 | 63 | rm -f tests.cc 64 | 65 | -------------------------------------------------------------------------------- /systest/que.sh: -------------------------------------------------------------------------------- 1 | rm -f temp/* 2 | 3 | for file in testmatrix_*param; do 4 | num=$(echo $file | tr -dc '0-9') 5 | awk "{ print \$0 > \"temp/util_${num}_\"\$1\".sh\" }" $file 6 | done 7 | 8 | while read -r NODES ; do 9 | { 10 | if [ $PIOL_SYSTEM == "Tullow" ]; then 11 | NODES=$NODES bash runtest.pbs 12 | else 13 | qsub -v NODES=$NODES -l nodes=$NODES:ppn=24,walltime=0:02:00:00 runtest.pbs 14 | fi 15 | } 16 | done < <(ls temp/* | cut -d "_" -f 3 | cut -d "." -f 1 | sort -u) 17 | 18 | shopt -s nocasematch 19 | if [[ -n "$1" ]]; then 20 | if [[ $1 == "n" ]]; then 21 | exit 22 | fi 23 | fi 24 | 25 | shopt -u nocasematch 26 | 27 | if [[ $PIOL_SYSTEM == "Tullow" ]]; then 28 | echo Skip makefile check 29 | exit 30 | fi 31 | 32 | source /etc/profile.d/modules.sh 33 | source ../mod_gnu 34 | export PIOL_DIR=$PWD/.. 35 | export TEST_DIR=/ichec/work/exseisdat/test/$USER 36 | bash warncheck.sh 37 | -------------------------------------------------------------------------------- /systest/runtest.pbs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #PBS -N piolsystest 3 | #PBS -A lero 4 | #PBS -r n 5 | #PBS -o /dev/null 6 | #PBS -e /dev/null 7 | #PBS -m bea 8 | 9 | if [ -z $PBS_O_WORKDIR ]; then 10 | PBS_O_WORKDIR=$PWD 11 | fi 12 | cd $PBS_O_WORKDIR 13 | 14 | export PIOL_DIR=$PBS_O_WORKDIR/.. 15 | 16 | if [ $PIOL_SYSTEM == "Tullow" ]; then 17 | export TEST_DIR=/panfs/gpt2/SEAM_DATA/temp/$USER 18 | else 19 | export TEST_DIR=/ichec/work/exseisdat/test/$USER 20 | fi 21 | 22 | export OUTPUT=test.segy 23 | 24 | for file in temp/util_*_$NODES.sh; do 25 | num=$(echo $file | cut -d "_" -f 2) 26 | while read -r all; do 27 | { 28 | set -- $all 29 | if [ ! -e test_${num}_$4.sh ]; then 30 | echo script test_${num}_$4.sh does not exist >> TEST$PBS_JOBID 31 | exit -1 32 | fi 33 | 34 | set -f 35 | source test_${num}_$4.sh $7 $8 $OUTPUT 36 | set +f 37 | bash farm.sh "$@" >> TEST$PBS_JOBID 2>&1 38 | } < /dev/null 39 | done < $file 40 | done 41 | -------------------------------------------------------------------------------- /systest/temp/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /systest/test_0_cexample1.sh: -------------------------------------------------------------------------------- 1 | export ARGUMENTS="-o dat/$1" 2 | -------------------------------------------------------------------------------- /systest/test_0_example1.sh: -------------------------------------------------------------------------------- 1 | export ARGUMENTS="-o dat/$1" 2 | -------------------------------------------------------------------------------- /systest/test_0_filemake.sh: -------------------------------------------------------------------------------- 1 | export ARGUMENTS="-s 800 -t 1000 -m 2048 -i 0.04 -o dat/$1" 2 | -------------------------------------------------------------------------------- /systest/test_1_cexample2.sh: -------------------------------------------------------------------------------- 1 | export ARGUMENTS="-i $1 -o dat/$2" 2 | -------------------------------------------------------------------------------- /systest/test_1_concatenate.sh: -------------------------------------------------------------------------------- 1 | export ARGUMENTS="-i ${1/10/10*} -o dat/$2" 2 | -------------------------------------------------------------------------------- /systest/test_1_creadwrite.sh: -------------------------------------------------------------------------------- 1 | export ARGUMENTS="-i $1 -o dat/$2 -m Test" 2 | -------------------------------------------------------------------------------- /systest/test_1_makerep.sh: -------------------------------------------------------------------------------- 1 | export ARGUMENTS="-i $1 -o dat/$2 -v standard -r 3 " 2 | -------------------------------------------------------------------------------- /systest/test_1_minmax.sh: -------------------------------------------------------------------------------- 1 | export ARGUMENTS="-i $1 -o dat/$2" 2 | -------------------------------------------------------------------------------- /systest/test_1_segsort.sh: -------------------------------------------------------------------------------- 1 | export ARGUMENTS="-i ${1/10/10*} -o dat/$2" 2 | -------------------------------------------------------------------------------- /systest/test_2_fourdbin.sh: -------------------------------------------------------------------------------- 1 | export ARGUMENTS="-a $1 -b $2 -c dat/test -d dat/test2 -t 1 -p" 2 | -------------------------------------------------------------------------------- /systest/testmatrix_0param: -------------------------------------------------------------------------------- 1 | 1 1 intel filemake 10 gnu 2 | 5 23 intel filemake 10 intel 3 | 1 23 openmpi/gcc/1.8.4 filemake 10 gnu 4 | 5 13 openmpi/gcc/1.8.4 filemake 10 gnu 5 | 1 24 intel filemake 10 intel 6 | 5 24 mvapich2/intel/2.1a filemake 10 intel 7 | -------------------------------------------------------------------------------- /systest/testmatrix_1param: -------------------------------------------------------------------------------- 1 | 1 23 openmpi/gcc/1.8.4 concatenate 10 gnu /ichec/work/exseisdat/dat/10/bigns.segy 2 | 5 24 intel minmax 10 intel /ichec/work/exseisdat/dat/10/small.segy 3 | 5 23 mvapich2/intel/2.1a makerep 10 intel /ichec/work/exseisdat/dat/10/bigns.segy 4 | 1 24 intel makerep 10 gnu /ichec/work/exseisdat/dat/10/one.segy 5 | 5 24 mvapich2/intel/2.1a concatenate 10 intel /ichec/work/exseisdat/dat/10/zero.segy 6 | 1 24 openmpi/gcc/1.8.4 creadwrite 10 gnu /ichec/work/exseisdat/dat/10/bigns.segy 7 | 1 23 mvapich2/intel/2.1a creadwrite 10 intel /ichec/work/exseisdat/dat/10/zero.segy 8 | 1 23 intel concatenate 10 gnu /ichec/work/exseisdat/dat/10/one.segy 9 | 1 24 mvapich2/intel/2.1a makerep 10 gnu /ichec/work/exseisdat/dat/10/small.segy 10 | 1 24 intel segsort 10 intel /ichec/work/exseisdat/dat/10/bigns.segy 11 | 1 24 intel creadwrite 10 intel /ichec/work/exseisdat/dat/10/small.segy 12 | 5 23 intel segsort 10 intel /ichec/work/exseisdat/dat/10/small.segy 13 | 1 24 mvapich2/intel/2.1a concatenate 10 intel /ichec/work/exseisdat/dat/10/small.segy 14 | 1 24 mvapich2/intel/2.1a creadwrite 10 intel /ichec/work/exseisdat/dat/10/one.segy 15 | 5 23 intel makerep 10 gnu /ichec/work/exseisdat/dat/10/zero.segy 16 | 5 24 mvapich2/intel/2.1a minmax 10 gnu /ichec/work/exseisdat/dat/10/one.segy 17 | 5 23 mvapich2/intel/2.1a minmax 10 gnu /ichec/work/exseisdat/dat/10/bigns.segy 18 | 5 23 intel creadwrite 10 intel /ichec/work/exseisdat/dat/10/medium.segy 19 | 1 24 mvapich2/intel/2.1a segsort 10 gnu /ichec/work/exseisdat/dat/10/medium.segy 20 | 1 24 openmpi/intel/1.8.3 makerep 10 intel /ichec/work/exseisdat/dat/10/medium.segy 21 | 1 24 intel concatenate 10 gnu /ichec/work/exseisdat/dat/10/medium.segy 22 | 5 23 mvapich2/intel/2.1a minmax 10 intel /ichec/work/exseisdat/dat/10/medium.segy 23 | -------------------------------------------------------------------------------- /systest/testmatrix_2param: -------------------------------------------------------------------------------- 1 | 8 24 intel fourdbin 10 intel /ichec/work/exseisdat/dat/10/GHJUB2013SR.segy /ichec/work/exseisdat/dat/10/GHJUB2017SIMSR.segy 2 | -------------------------------------------------------------------------------- /systest/warncheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source /etc/profile.d/modules.sh #So we can use the module command 3 | 4 | DIR_NAME=$TEST_DIR/$(date +%s)$$ 5 | 6 | mkdir $DIR_NAME 7 | 8 | cp -r $PIOL_DIR/src $DIR_NAME/ 9 | cp -r $PIOL_DIR/compiler.cfg $DIR_NAME/ 10 | ln -s $PIOL_DIR/include $DIR_NAME/ 11 | mkdir $DIR_NAME/lib 12 | cd $PIOL_DIR/src 13 | 14 | red='\e[31m' 15 | DIR=$(pwd) 16 | gfile=$PIOL_DIR/systest/temp/gnuwarnings 17 | ifile=$PIOL_DIR/systest/temp/intelwarnings 18 | 19 | cd $DIR_NAME/src 20 | 21 | module purge 22 | source $PIOL_DIR/mod_intel 23 | make -s clean 24 | make -j 24 -s 2> $ifile 25 | 26 | module purge 27 | source $PIOL_DIR/mod_gnu 28 | make -s clean 29 | make -j 24 -s 2> $gfile 30 | 31 | RET=0 32 | if [ -s $ifile ]; then 33 | echo $red Intel warnings not removed 34 | RET=1 35 | cat $ifile 36 | fi 37 | 38 | if [ -s $gfile ]; then 39 | RET=$RET+2 40 | echo $red GNU warnings not removed 41 | cat $gfile 42 | fi 43 | 44 | module purge 45 | 46 | echo WarningsTest SRC 0 0 $RET > ../CHECK 47 | echo 0 0 0 0 0 0 0 0 > ../TIME 48 | 49 | -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | Time Sinks: 2 | Google Mock has limitations when it comes to death tests. Do not expect mock 3 | expectations to be handled correctly in a death test as the newly spawned threads 4 | appear to play havok with the correct deallocation of the mock. 5 | 6 | When running the `spectests` test, `spectests --gtest_filter=-*Farm*` lets you skip all the heavy unit tests that should be task farmed. 7 | -------------------------------------------------------------------------------- /test/extract.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char** argv) 8 | { 9 | assert(argc > 1); 10 | FILE* fs = fopen(argv[1], "r"); 11 | unsigned char cns[2U]; 12 | fseek(fs, 3220U, SEEK_SET); 13 | fread(cns, sizeof(char), 2U, fs); 14 | int64_t ns = cns[0] << 8 | cns[1]; 15 | fprintf(stderr, "int16_t ns = %" PRId64 "\n", ns); 16 | 17 | fseek(fs, 0U, SEEK_END); 18 | 19 | int64_t fsz = ftell(fs); 20 | fprintf(stderr, "uint64_t fsz = %" PRId64 "\n", fsz); 21 | 22 | size_t nt = (fsz - 3600U) / (sizeof(float) * ns + 240U); 23 | assert(!((fsz - 3600U) % (sizeof(float) * ns + 240U))); 24 | 25 | fseek(fs, 3840U, SEEK_SET); 26 | 27 | size_t rnt = (nt > 100 ? 100 : nt); 28 | 29 | assert(ns > 0); 30 | uint32_t* traces = malloc(ns * sizeof(uint32_t)); 31 | assert(traces); 32 | 33 | printf("#include \n#include \n"); 34 | printf("std::vector rawTraces = {"); 35 | for (size_t i = 0; i < rnt; i++) { 36 | fread(traces, sizeof(uint32_t), ns, fs); 37 | fseek(fs, 240U, SEEK_CUR); 38 | printf(" 0x%x, ", traces[0]); 39 | 40 | for (int64_t j = 1U; j < ns - 1U; j++) { 41 | printf("0x%x, ", traces[j]); 42 | } 43 | 44 | if (i == rnt - 1) { 45 | printf("0x%x\n", traces[ns - 1]); 46 | } 47 | else { 48 | printf("0x%x,\n", traces[ns - 1]); 49 | } 50 | } 51 | printf("};\n"); 52 | 53 | free(traces); 54 | fclose(fs); 55 | } 56 | -------------------------------------------------------------------------------- /test/googletest-release-1.8.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ICHEC/ExSeisDat/3c6acb883985043293d8a40caaca743e7b8eaa33/test/googletest-release-1.8.0.zip -------------------------------------------------------------------------------- /test/spectests/data.cc: -------------------------------------------------------------------------------- 1 | #include "gmock/gmock.h" 2 | #include "gtest/gtest.h" 3 | 4 | #include "tglobal.hh" 5 | 6 | #include "ExSeisDat/PIOL/CommunicatorMPI.hh" 7 | #include "ExSeisDat/PIOL/DataInterface.hh" 8 | #include "ExSeisDat/PIOL/ExSeis.hh" 9 | 10 | #include 11 | 12 | using namespace testing; 13 | using namespace exseis::PIOL; 14 | 15 | class DataTest : public Test { 16 | protected: 17 | std::shared_ptr piol = ExSeis::New(); 18 | }; 19 | 20 | struct FakeData : public DataInterface { 21 | FakeData(const std::shared_ptr piol_, const std::string name_) : 22 | DataInterface(piol_, name_) 23 | { 24 | } 25 | 26 | size_t getFileSz() const { return 0U; } 27 | 28 | void read(const size_t, const size_t, unsigned char*) const {} 29 | void read( 30 | const size_t, 31 | const size_t, 32 | const size_t, 33 | const size_t, 34 | unsigned char*) const 35 | { 36 | } 37 | void read(const size_t, const size_t, const size_t*, unsigned char*) const 38 | { 39 | } 40 | void setFileSz(const size_t) const {} 41 | void write(const size_t, const size_t, const unsigned char*) const {} 42 | void write( 43 | const size_t, 44 | const size_t, 45 | const size_t, 46 | const size_t, 47 | const unsigned char*) const 48 | { 49 | } 50 | void write( 51 | const size_t, const size_t, const size_t*, const unsigned char*) const 52 | { 53 | } 54 | }; 55 | 56 | TEST_F(DataTest, Constructor) 57 | { 58 | FakeData fake(piol, notFile); 59 | EXPECT_EQ(piol, fake.piol()); 60 | EXPECT_EQ(notFile, fake.name()); 61 | } 62 | -------------------------------------------------------------------------------- /test/spectests/dynsegymdtest.hh: -------------------------------------------------------------------------------- 1 | #include "gmock/gmock.h" 2 | #include "gtest/gtest.h" 3 | 4 | #include "tglobal.hh" 5 | 6 | #include "ExSeisDat/PIOL/Param.h" 7 | #include "ExSeisDat/PIOL/SEGYRuleEntry.hh" 8 | 9 | #include 10 | 11 | using namespace testing; 12 | using namespace exseis::PIOL; 13 | 14 | struct RuleFix : public Test { 15 | std::shared_ptr rule; 16 | RuleFix(void) { rule = NULL; } 17 | ~RuleFix(void) {} 18 | }; 19 | 20 | struct RuleFixList : public RuleFix { 21 | std::vector meta; 22 | std::vector locs; 23 | RuleFixList(void) 24 | { 25 | locs = {PIOL_TR_xSrc, PIOL_TR_ySrc, PIOL_TR_xRcv, PIOL_TR_yRcv}; 26 | meta = {PIOL_META_xSrc, PIOL_META_ySrc, PIOL_META_xRcv, PIOL_META_yRcv}; 27 | rule = std::make_shared( 28 | std::initializer_list{PIOL_META_xSrc, PIOL_META_ySrc, 29 | PIOL_META_xRcv, PIOL_META_yRcv}, 30 | false); 31 | rule->rmRule(PIOL_META_ltn); 32 | rule->rmRule(PIOL_META_gtn); 33 | } 34 | }; 35 | 36 | struct RuleFixEmpty : public RuleFix { 37 | RuleFixEmpty(void) { rule = std::make_shared(false, false); } 38 | }; 39 | 40 | 41 | struct RuleFixDefault : public RuleFix { 42 | RuleFixDefault(void) { rule = std::make_shared(true, true); } 43 | }; 44 | -------------------------------------------------------------------------------- /test/spectests/objsegymeta.cc: -------------------------------------------------------------------------------- 1 | #include "objsegytest.hh" 2 | 3 | TEST_F(ObjSpecTest, TestBypassConstructor) 4 | { 5 | makeSEGY(); 6 | EXPECT_EQ(piol, obj->piol()); 7 | EXPECT_EQ(notFile, obj->name()); 8 | EXPECT_EQ(mock, obj->data()); 9 | } 10 | 11 | TEST_F(ObjIntegTest, zeroSEGYFileSize) 12 | { 13 | makeRealSEGY(zeroFile); 14 | piol->isErr(); 15 | EXPECT_NE(nullptr, obj->data()); 16 | EXPECT_EQ(0U, obj->getFileSz()); 17 | piol->isErr(); 18 | } 19 | 20 | TEST_F(ObjIntegTest, SmallSEGYFileSize) 21 | { 22 | makeRealSEGY(smallFile); 23 | piol->isErr(); 24 | EXPECT_NE(nullptr, obj->data()); 25 | EXPECT_EQ(smallSize, obj->getFileSz()); 26 | piol->isErr(); 27 | } 28 | 29 | TEST_F(ObjIntegTest, BigSEGYFileSize) 30 | { 31 | makeRealSEGY(largeFile); 32 | piol->isErr(); 33 | EXPECT_NE(nullptr, obj->data()); 34 | EXPECT_EQ(largeSize, obj->getFileSz()); 35 | piol->isErr(); 36 | } 37 | 38 | TEST_F(ObjSpecTest, ZeroSEGYFileSize) 39 | { 40 | makeSEGY(); 41 | SEGYFileSizeTest(0U); 42 | } 43 | 44 | TEST_F(ObjSpecTest, SmallSEGYFileSize) 45 | { 46 | makeSEGY(); 47 | SEGYFileSizeTest(40U * prefix(2U)); 48 | } 49 | 50 | TEST_F(ObjSpecTest, BigSEGYFileSize) 51 | { 52 | makeSEGY(); 53 | SEGYFileSizeTest(8U * prefix(4U)); 54 | } 55 | -------------------------------------------------------------------------------- /test/spectests/segy.cc: -------------------------------------------------------------------------------- 1 | #include "tglobal.hh" 2 | 3 | #include "ExSeisDat/PIOL/segy_utils.hh" 4 | 5 | using namespace exseis::PIOL; 6 | 7 | TEST(SEGYSizes, All) 8 | { 9 | ASSERT_EQ(3600U, SEGY_utils::getHOSz()); 10 | ASSERT_EQ(240U, SEGY_utils::getMDSz()); 11 | ASSERT_EQ( 12 | 3600U + (1111U * 4U + 240U) * 3333U, SEGY_utils::getDOLoc(3333, 1111)); 13 | } 14 | -------------------------------------------------------------------------------- /test/spectests/selftests.cc: -------------------------------------------------------------------------------- 1 | #include "gmock/gmock.h" 2 | #include "gtest/gtest.h" 3 | 4 | #include "tglobal.hh" 5 | 6 | // Tests to make sure that functions only used in testing are as expected 7 | 8 | TEST(Prefix, SizeCheck) 9 | { 10 | size_t pow = 1U; 11 | EXPECT_EQ(pow, prefix(0)); 12 | for (size_t i = 1; i <= 6; i++) { 13 | pow *= 1024U; 14 | EXPECT_EQ(pow, prefix(i)); 15 | } 16 | } 17 | 18 | TEST(Files, SelfTest) 19 | { 20 | EXPECT_NE(static_cast(0), magicNum1); 21 | EXPECT_EQ(static_cast(0), magicNum1 / 0xFF); 22 | struct stat stats; 23 | EXPECT_EQ(0, stat(zeroFile.c_str(), &stats)); 24 | EXPECT_EQ(0, stat(smallFile.c_str(), &stats)); 25 | EXPECT_EQ(0, stat(largeFile.c_str(), &stats)); 26 | EXPECT_EQ(0, stat(plargeFile.c_str(), &stats)); 27 | } 28 | -------------------------------------------------------------------------------- /test/spectests/tglobal.cc: -------------------------------------------------------------------------------- 1 | #include "tglobal.hh" 2 | 3 | template bool testing::internal::TypeIdHelper::dummy_; 4 | template bool testing::internal::TypeIdHelper::dummy_; 5 | template bool testing::internal::TypeIdHelper::dummy_; 6 | template bool testing::internal::TypeIdHelper::dummy_; 7 | template bool testing::internal::TypeIdHelper::dummy_; 8 | template bool testing::internal::TypeIdHelper::dummy_; 9 | template bool testing::internal::TypeIdHelper::dummy_; 10 | 11 | template typename testing::DefaultValue::ValueProducer* 12 | testing::DefaultValue::producer_; 13 | template typename testing::DefaultValue::ValueProducer* 14 | testing::DefaultValue::producer_; 15 | -------------------------------------------------------------------------------- /test/wraptests/checkreturnlistener.cc: -------------------------------------------------------------------------------- 1 | #include "checkreturnlistener.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | void CheckReturnListener::OnTestPartResult( 7 | const ::testing::TestPartResult& test_part_result) 8 | { 9 | if (test_part_result.failed() && expecting_return_value) { 10 | std::cout 11 | << std::endl 12 | << "*** Failure while awaiting call to wraptest_ok() for return value: " 13 | << std::endl 14 | << "\t" << return_value << std::endl 15 | << std::endl; 16 | } 17 | } 18 | 19 | void CheckReturnListener::expect_return_value(std::string return_value) 20 | { 21 | this->return_value = return_value; 22 | expecting_return_value = true; 23 | } 24 | 25 | void CheckReturnListener::got_expected_return_value() 26 | { 27 | return_value.clear(); 28 | expecting_return_value = false; 29 | } 30 | 31 | } // namespace PIOL 32 | } // namespace exseis 33 | -------------------------------------------------------------------------------- /test/wraptests/checkreturnlistener.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSCHECKRETURNLISTENER_HEADER_GUARD 2 | #define PIOLWRAPTESTSCHECKRETURNLISTENER_HEADER_GUARD 3 | 4 | #include "googletest_variable_instances.hh" 5 | #include "gtest/gtest.h" 6 | 7 | namespace exseis { 8 | namespace PIOL { 9 | 10 | class CheckReturnListener : public ::testing::EmptyTestEventListener { 11 | public: 12 | // Called after EXPECT_CALL throws 13 | virtual void OnTestPartResult( 14 | const ::testing::TestPartResult& test_part_result); 15 | 16 | // When expecting the wrapped side to check a return value, 17 | // call this with a pretty printed string of the return value. 18 | // If a gtest exception is thrown while expecting a return value 19 | // (likely from an out-of-order mock call), 20 | // the listener will print the return_value it was waiting on. 21 | void expect_return_value(std::string return_value); 22 | 23 | // Call this when the expected return value has been successfully tested. 24 | void got_expected_return_value(); 25 | 26 | private: 27 | // A flag to say if the listener is awaiting a return value. 28 | bool expecting_return_value = false; 29 | 30 | // A pretty string representing the expected return value. 31 | std::string return_value; 32 | }; 33 | 34 | } // namespace PIOL 35 | } // namespace exseis 36 | 37 | #endif // PIOLWRAPTESTSCHECKRETURNLISTENER_HEADER_GUARD 38 | -------------------------------------------------------------------------------- /test/wraptests/compare_symbols.sh: -------------------------------------------------------------------------------- 1 | #!/ usr / bin / env bash 2 | 3 | # 4 | #Usage :./ compare_symbols.sh 5 | # 6 | #List all the symbols that differ between cwraptests and piolstub. 7 | #missing : in piolstub and not in cwraptests 8 | #different : in cwraptests and not in piolstub 9 | # 10 | 11 | #cd into this script directory 12 | cd "$(dirname " $ 13 | { 14 | BASH_SOURCE[0] 15 | } 16 | ")" 17 | 18 | 19 | #Parse PIOL::*symbols from bin / cwraptests executable 20 | #Pipeline: 21 | #nm - get all symbols 22 | #| grep PIOL - get symbols defined by PIOL 23 | #| grep - v _gcov _asan - strip debugging symbols 24 | #| grep ^[hex]{16 } ' - get only lines for symbols (i.e. addresses) 25 | #| sed 's/^[address] [type]//' - strip address and symbol type info 26 | #| gc ++ filt - demangle symbols 27 | #| grep - v lambda - strip lambda function symbols 28 | #| grep - v __func__ - strip function name symbols(from asserts) 29 | #| grep - v vtable - strip vtable symbols 30 | #| grep - v typeinfo - strip vtable symbols 31 | function 32 | PIOL_symbols() 33 | { 34 | nm "$@" | grep '_ZN4PIOL' | grep - v '_gcov' | grep - v '_asan' 35 | | grep '^.\{16\} ' | sed 's/^.\{16\} [[:alpha:]] //' | gc++ filt - _ 36 | | grep - v 'lambda(' | grep - v '::__func__' | grep - v '^vtable' 37 | | grep - v '^typeinfo' 38 | } 39 | 40 | 41 | #test_symbols piol_lib pattern 42 | #Show the difference between cwraptests and piol_lib for the given pattern 43 | function test_symbols() 44 | { 45 | symbol_pattern = "$1" 46 | 47 | piol_tmp_file = $(mktemp) cwrap_tmp_file = 48 | $(mktemp) 49 | 50 | #Get cwrap symbols 51 | #Uniq needed for non - unique output from c++ filt, i.e.from multiple 52 | #types of constructors(i.e.C1, C2, C3). 53 | PIOL_symbols.. 54 | / bin / wraptests.so 55 | | grep "${symbol_pattern}" | sort | uniq > $ 56 | { 57 | cwrap_tmp_file 58 | } 59 | 60 | #Get ipiol symbols 61 | PIOL_symbols../ bin / piolstub.so | grep "${symbol_pattern}" | sort 62 | | uniq > ${piol_tmp_file} 63 | 64 | diff ${piol_tmp_file} ${cwrap_tmp_file} 65 | | sed 's/^/different:/' 67 | 68 | rm 69 | - f ${cwrap_tmp_file} $ 70 | { 71 | piol_tmp_file 72 | } 73 | } 74 | 75 | 76 | #Prm.*(for the param_utils::cpyPrm etc.free functions. 77 | for 78 | ns in "::ExSeis::" 79 | "::ReadDirect::" 80 | "::WriteDirect::" 81 | "::Param::" 82 | "Prm.*(" 83 | "::ReadModel::" 84 | "::Set::" do echo echo echo "=" echo "= ${ns}" echo "=" echo test_symbols 85 | "${ns}" 86 | | sed 's/^\([[:alnum:]]*:\).*[^,] PIOL::/\1 PIOL::/' done 87 | -------------------------------------------------------------------------------- /test/wraptests/exseis.cc: -------------------------------------------------------------------------------- 1 | #include "mockexseis.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | ExSeis::ExSeis(const PIOL::Verbosity maxLevel, MPI_Comm comm) 7 | { 8 | mockExSeis().ctor(this, maxLevel, comm); 9 | } 10 | 11 | ExSeis::~ExSeis() 12 | { 13 | mockExSeis().dtor(this); 14 | } 15 | 16 | size_t ExSeis::getRank() const 17 | { 18 | return mockExSeis().getRank(this); 19 | } 20 | 21 | size_t ExSeis::getNumRank() const 22 | { 23 | return mockExSeis().getNumRank(this); 24 | } 25 | 26 | void ExSeis::barrier() const 27 | { 28 | mockExSeis().barrier(this); 29 | } 30 | 31 | size_t ExSeis::max(size_t n) const 32 | { 33 | return mockExSeis().max(this, n); 34 | } 35 | 36 | void ExSeis::isErr(const std::string& msg) const 37 | { 38 | mockExSeis().isErr(this, msg); 39 | } 40 | 41 | } // namespace PIOL 42 | } // namespace exseis 43 | -------------------------------------------------------------------------------- /test/wraptests/exseiswraptest.cc: -------------------------------------------------------------------------------- 1 | #include "exseiswraptest.hh" 2 | 3 | #include "mockexseis.hh" 4 | #include "wraptesttools.hh" 5 | 6 | #include "gtest/gtest.h" 7 | 8 | #include 9 | 10 | 11 | using namespace testing; 12 | using namespace exseis::PIOL; 13 | 14 | std::shared_ptr test_PIOL_ExSeis() 15 | { 16 | auto exseis_ptr = std::make_shared(); 17 | EXPECT_CALL(mockExSeis(), ctor(_, PIOL_VERBOSITY_NONE, _)) 18 | .WillOnce(SaveArg<0>(exseis_ptr)); 19 | 20 | const Verbosity verbosities[] = { 21 | PIOL_VERBOSITY_NONE, PIOL_VERBOSITY_MINIMAL, PIOL_VERBOSITY_EXTENDED, 22 | PIOL_VERBOSITY_VERBOSE, PIOL_VERBOSITY_MAX}; 23 | 24 | for (auto verbosity : verbosities) { 25 | EXPECT_CALL(mockExSeis(), ctor(_, verbosity, _)); 26 | } 27 | 28 | EXPECT_CALL(mockExSeis(), getRank(_)).WillOnce(CheckReturn(0)); 29 | EXPECT_CALL(returnChecker(), Call()).WillOnce(ClearCheckReturn()); 30 | 31 | EXPECT_CALL(mockExSeis(), getNumRank(_)).WillOnce(CheckReturn(10)); 32 | EXPECT_CALL(returnChecker(), Call()).WillOnce(ClearCheckReturn()); 33 | 34 | EXPECT_CALL(mockExSeis(), barrier(_)); 35 | 36 | EXPECT_CALL(mockExSeis(), max(_, 0)).WillOnce(CheckReturn(30)); 37 | EXPECT_CALL(returnChecker(), Call()).WillOnce(ClearCheckReturn()); 38 | EXPECT_CALL(mockExSeis(), max(_, 40)).WillOnce(CheckReturn(50)); 39 | EXPECT_CALL(returnChecker(), Call()).WillOnce(ClearCheckReturn()); 40 | 41 | EXPECT_CALL(mockExSeis(), isErr(_, "")); 42 | EXPECT_CALL(mockExSeis(), isErr(_, "Test isErr message")); 43 | 44 | for (size_t i = 0; i < 5; i++) { 45 | EXPECT_CALL(mockExSeis(), dtor(_)); 46 | } 47 | 48 | return exseis_ptr; 49 | } 50 | -------------------------------------------------------------------------------- /test/wraptests/exseiswraptest.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSEXSEISWRAPTEST_HEADER_GUARD 2 | #define PIOLWRAPTESTSEXSEISWRAPTEST_HEADER_GUARD 3 | 4 | #include "mockexseis.hh" 5 | #include 6 | 7 | std::shared_ptr test_PIOL_ExSeis(); 8 | 9 | #endif // PIOLWRAPTESTSEXSEISWRAPTEST_HEADER_GUARD 10 | -------------------------------------------------------------------------------- /test/wraptests/getminmax.cc: -------------------------------------------------------------------------------- 1 | #include "mockgetminmax.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | void getMinMax( 7 | ExSeisPIOL* piol, 8 | size_t offset, 9 | size_t sz, 10 | Meta m1, 11 | Meta m2, 12 | const Param* prm, 13 | CoordElem* minmax) 14 | { 15 | return mockGetMinMax().getMinMax(piol, offset, sz, m1, m2, prm, minmax); 16 | } 17 | 18 | } // namespace PIOL 19 | } // namespace exseis 20 | -------------------------------------------------------------------------------- /test/wraptests/getminmaxwraptests.cc: -------------------------------------------------------------------------------- 1 | #include "getminmaxwraptests.hh" 2 | #include "mockgetminmax.hh" 3 | #include "wraptesttools.hh" 4 | 5 | using namespace testing; 6 | using namespace exseis::PIOL; 7 | 8 | void test_PIOL_File_getMinMax( 9 | std::shared_ptr piol, std::shared_ptr param) 10 | { 11 | EXPECT_CALL( 12 | mockGetMinMax(), getMinMax( 13 | EqDeref(piol), 520, 530, PIOL_META_COPY, 14 | PIOL_META_COPY, EqDeref(param), _)) 15 | .WillOnce(DoAll( 16 | WithArg<6>(Invoke([](auto coordElem) { 17 | EXPECT_FLOAT_EQ(coordElem->val, 500.0); 18 | EXPECT_EQ(coordElem->num, 510u); 19 | 20 | coordElem->val = 540.0; 21 | coordElem->num = 550.0; 22 | })), 23 | CheckInOutParam(CoordElem{540.0, 550}))); 24 | 25 | EXPECT_CALL(returnChecker(), Call()).WillOnce(ClearCheckReturn()); 26 | } 27 | -------------------------------------------------------------------------------- /test/wraptests/getminmaxwraptests.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSGETMINMAX_INCLUDE_GUARD 2 | #define PIOLWRAPTESTSGETMINMAX_INCLUDE_GUARD 3 | 4 | #include "mockexseis.hh" 5 | #include "mockparam.hh" 6 | #include 7 | 8 | void test_PIOL_File_getMinMax( 9 | std::shared_ptr piol, 10 | std::shared_ptr param); 11 | 12 | #endif // PIOLWRAPTESTSGETMINMAX_INCLUDE_GUARD 13 | -------------------------------------------------------------------------------- /test/wraptests/googletest_variable_instances.cc: -------------------------------------------------------------------------------- 1 | #include "googletest_variable_instances.hh" 2 | 3 | template testing::DefaultValue::ValueProducer* 4 | testing::DefaultValue::producer_; 5 | 6 | template testing::DefaultValue::ValueProducer* 7 | testing::DefaultValue::producer_; 8 | 9 | template testing::DefaultValue::ValueProducer* 10 | testing::DefaultValue::producer_; 11 | 12 | template testing::DefaultValue::ValueProducer* 13 | testing::DefaultValue::producer_; 14 | 15 | template testing::DefaultValue::ValueProducer* 16 | testing::DefaultValue::producer_; 17 | 18 | template testing::DefaultValue::ValueProducer* 19 | testing::DefaultValue::producer_; 20 | 21 | template const std::string* testing::DefaultValue::address_; 22 | 23 | template testing::DefaultValue::ValueProducer* 24 | testing::DefaultValue::producer_; 25 | 26 | template testing::DefaultValue>::ValueProducer* 27 | testing::DefaultValue>::producer_; 28 | -------------------------------------------------------------------------------- /test/wraptests/intercepted_c_bindings.cc: -------------------------------------------------------------------------------- 1 | // 2 | // We want to inject some definitions into the cfileapi.cc file. 3 | // Specifically, we want to make a number of template functions call 4 | // external functions so we can intercept them with mock functions. 5 | // 6 | 7 | // Externed templates defined in the appropriate headers 8 | #include "mockparam.hh" 9 | 10 | // Include the C bindings from src/ which call the templated functions 11 | #include "Flow/Flow_C_bindings.cc" 12 | #include "PIOL_C_bindings.cc" 13 | -------------------------------------------------------------------------------- /test/wraptests/mockexseis.cc: -------------------------------------------------------------------------------- 1 | #include "mockexseis.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | ::testing::StrictMock& mockExSeis() 7 | { 8 | static ::testing::StrictMock mockExSeis; 9 | return mockExSeis; 10 | } 11 | 12 | } // namespace PIOL 13 | } // namespace exseis 14 | -------------------------------------------------------------------------------- /test/wraptests/mockexseis.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSMOCKEXSEIS_HEADER_GUARD 2 | #define PIOLWRAPTESTSMOCKEXSEIS_HEADER_GUARD 3 | 4 | #include "googletest_variable_instances.hh" 5 | #include "gmock/gmock.h" 6 | 7 | #include "ExSeisDat/PIOL/ExSeis.hh" 8 | 9 | 10 | namespace exseis { 11 | namespace PIOL { 12 | 13 | class MockExSeis; 14 | class ::testing::StrictMock& mockExSeis(); 15 | 16 | class MockExSeis { 17 | public: 18 | MOCK_METHOD3( 19 | ctor, void(ExSeis*, const PIOL::Verbosity maxLevel, MPI_Comm comm)); 20 | 21 | MOCK_METHOD1(dtor, void(ExSeis*)); 22 | 23 | MOCK_CONST_METHOD1(getRank, size_t(const ExSeis*)); 24 | 25 | MOCK_CONST_METHOD1(getNumRank, size_t(const ExSeis*)); 26 | 27 | MOCK_CONST_METHOD1(barrier, void(const ExSeis*)); 28 | 29 | MOCK_CONST_METHOD2(max, size_t(const ExSeis*, size_t n)); 30 | 31 | MOCK_CONST_METHOD2(isErr, void(const ExSeis*, const std::string& msg)); 32 | }; 33 | 34 | } // namespace PIOL 35 | } // namespace exseis 36 | 37 | #endif // PIOLWRAPTESTSMOCKEXSEIS_HEADER_GUARD 38 | -------------------------------------------------------------------------------- /test/wraptests/mockgetminmax.cc: -------------------------------------------------------------------------------- 1 | #include "mockgetminmax.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | ::testing::StrictMock& mockGetMinMax() 7 | { 8 | static ::testing::StrictMock mockGetMinMax; 9 | return mockGetMinMax; 10 | } 11 | 12 | } // namespace PIOL 13 | } // namespace exseis 14 | -------------------------------------------------------------------------------- /test/wraptests/mockgetminmax.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSMOCKMINMAX_HEADER_GUARD 2 | #define PIOLWRAPTESTSMOCKMINMAX_HEADER_GUARD 3 | 4 | #include "googletest_variable_instances.hh" 5 | #include "gmock/gmock.h" 6 | 7 | #include "ExSeisDat/PIOL/operations/minmax.h" 8 | 9 | namespace exseis { 10 | namespace PIOL { 11 | 12 | class MockGetMinMax; 13 | ::testing::StrictMock& mockGetMinMax(); 14 | 15 | class MockGetMinMax { 16 | public: 17 | MOCK_METHOD7( 18 | getMinMax, 19 | void( 20 | ExSeisPIOL* piol, 21 | size_t offset, 22 | size_t sz, 23 | Meta m1, 24 | Meta m2, 25 | const Param* prm, 26 | CoordElem* minmax)); 27 | }; 28 | 29 | } // namespace PIOL 30 | } // namespace exseis 31 | 32 | #endif // PIOLWRAPTESTSMOCKMINMAX_HEADER_GUARD 33 | -------------------------------------------------------------------------------- /test/wraptests/mockparam.cc: -------------------------------------------------------------------------------- 1 | #include "mockparam.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | ::testing::StrictMock& mockParam() 7 | { 8 | static ::testing::StrictMock mockParam; 9 | return mockParam; 10 | } 11 | 12 | ::testing::StrictMock& mockParamFreeFunctions() 13 | { 14 | static ::testing::StrictMock mockParamFreeFunctions; 15 | return mockParamFreeFunctions; 16 | } 17 | 18 | } // namespace PIOL 19 | } // namespace exseis 20 | -------------------------------------------------------------------------------- /test/wraptests/mockparam.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTMOCKPARAM_HEADER_GUARD 2 | #define PIOLWRAPTESTMOCKPARAM_HEADER_GUARD 3 | 4 | #include "ExSeisDat/PIOL/Param.h" 5 | #include "ExSeisDat/PIOL/param_utils.hh" 6 | 7 | #include "printers.hh" 8 | 9 | #include "googletest_variable_instances.hh" 10 | #include "gmock/gmock.h" 11 | 12 | namespace exseis { 13 | namespace PIOL { 14 | 15 | using namespace exseis::utils::typedefs; 16 | 17 | namespace param_utils { 18 | // Specify extern templates for templated functions so we can capture them 19 | template<> 20 | int16_t getPrm(size_t i, Meta entry, const Param* prm); 21 | 22 | template<> 23 | exseis::utils::Integer getPrm( 24 | size_t i, Meta entry, const Param* prm); 25 | 26 | template<> 27 | exseis::utils::Floating_point getPrm( 28 | size_t i, Meta entry, const Param* prm); 29 | 30 | 31 | template<> 32 | void setPrm(size_t i, Meta entry, int16_t ret, Param* prm); 33 | 34 | template<> 35 | void setPrm( 36 | size_t i, Meta entry, exseis::utils::Integer ret, Param* prm); 37 | 38 | template<> 39 | void setPrm( 40 | size_t i, Meta entry, exseis::utils::Floating_point ret, Param* prm); 41 | 42 | } // namespace param_utils 43 | 44 | 45 | class MockParam; 46 | ::testing::StrictMock& mockParam(); 47 | 48 | class MockParamFreeFunctions; 49 | ::testing::StrictMock& mockParamFreeFunctions(); 50 | 51 | class MockParam { 52 | public: 53 | MOCK_METHOD3(ctor, void(Param*, std::shared_ptr r_, size_t sz)); 54 | MOCK_METHOD2(ctor, void(Param*, size_t sz)); 55 | MOCK_METHOD1(dtor, void(Param*)); 56 | 57 | MOCK_CONST_METHOD1(size, size_t(const Param*)); 58 | 59 | MOCK_CONST_METHOD1(memUsage, size_t(const Param*)); 60 | }; 61 | 62 | class MockParamFreeFunctions { 63 | public: 64 | MOCK_METHOD4( 65 | cpyPrm, void(size_t j, const Param* src, size_t k, Param* dst)); 66 | 67 | MOCK_METHOD3( 68 | getPrm_int16_t, int16_t(size_t i, Meta entry, const Param* prm)); 69 | 70 | MOCK_METHOD3( 71 | getPrm_Integer, 72 | exseis::utils::Integer(size_t i, Meta entry, const Param* prm)); 73 | 74 | MOCK_METHOD3( 75 | getPrm_Floating_point, 76 | exseis::utils::Floating_point(size_t i, Meta entry, const Param* prm)); 77 | 78 | MOCK_METHOD4( 79 | setPrm_int16_t, void(size_t i, Meta entry, int16_t ret, Param* prm)); 80 | 81 | MOCK_METHOD4( 82 | setPrm_Integer, 83 | void(size_t i, Meta entry, exseis::utils::Integer ret, Param* prm)); 84 | 85 | MOCK_METHOD4( 86 | setPrm_Floating_point, 87 | void( 88 | size_t i, Meta entry, exseis::utils::Floating_point ret, Param* prm)); 89 | }; 90 | 91 | } // namespace PIOL 92 | } // namespace exseis 93 | 94 | #endif // PIOLWRAPTESTMOCKPARAM_HEADER_GUARD 95 | -------------------------------------------------------------------------------- /test/wraptests/mockreaddirect.cc: -------------------------------------------------------------------------------- 1 | #include "mockreaddirect.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | ::testing::StrictMock& mockReadDirect() 7 | { 8 | static ::testing::StrictMock mockReadDirect; 9 | return mockReadDirect; 10 | } 11 | 12 | } // namespace PIOL 13 | } // namespace exseis 14 | -------------------------------------------------------------------------------- /test/wraptests/mockreaddirect.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSMOCKREADDIRECT_HEADER_GUARD 2 | #define PIOLWRAPTESTSMOCKREADDIRECT_HEADER_GUARD 3 | 4 | #include "googletest_variable_instances.hh" 5 | #include "gmock/gmock.h" 6 | 7 | #include "ExSeisDat/PIOL/ReadDirect.hh" 8 | 9 | namespace exseis { 10 | namespace PIOL { 11 | 12 | class MockReadDirect; 13 | ::testing::StrictMock& mockReadDirect(); 14 | 15 | class MockReadDirect { 16 | public: 17 | MOCK_METHOD3( 18 | ctor, 19 | void( 20 | ReadDirect*, std::shared_ptr piol, const std::string name)); 21 | 22 | MOCK_METHOD2(ctor, void(ReadDirect*, std::shared_ptr file)); 23 | 24 | MOCK_METHOD1(dtor, void(ReadDirect*)); 25 | 26 | MOCK_CONST_METHOD1(readText, const std::string&(const ReadDirect*)); 27 | 28 | MOCK_CONST_METHOD1(readNs, size_t(const ReadDirect*)); 29 | 30 | MOCK_CONST_METHOD1(readNt, size_t(const ReadDirect*)); 31 | 32 | MOCK_CONST_METHOD1( 33 | readInc, exseis::utils::Floating_point(const ReadDirect*)); 34 | 35 | MOCK_CONST_METHOD5( 36 | readTrace, 37 | void( 38 | const ReadDirect*, 39 | const size_t offset, 40 | const size_t sz, 41 | exseis::utils::Trace_value* trace, 42 | Param* prm)); 43 | 44 | MOCK_CONST_METHOD4( 45 | readParam, 46 | void( 47 | const ReadDirect*, const size_t offset, const size_t sz, Param* prm)); 48 | 49 | MOCK_CONST_METHOD5( 50 | readTraceNonContiguous, 51 | void( 52 | const ReadDirect*, 53 | const size_t sz, 54 | const size_t* offset, 55 | exseis::utils::Trace_value* trace, 56 | Param* prm)); 57 | 58 | MOCK_CONST_METHOD5( 59 | readTraceNonMonotonic, 60 | void( 61 | const ReadDirect*, 62 | const size_t sz, 63 | const size_t* offset, 64 | exseis::utils::Trace_value* trace, 65 | Param* prm)); 66 | 67 | MOCK_CONST_METHOD4( 68 | readParamNonContiguous, 69 | void( 70 | const ReadDirect*, const size_t sz, const size_t* offset, Param* prm)); 71 | }; 72 | 73 | } // namespace PIOL 74 | } // namespace exseis 75 | 76 | #endif // PIOLWRAPTESTSMOCKREADDIRECT_HEADER_GUARD 77 | -------------------------------------------------------------------------------- /test/wraptests/mockrule.cc: -------------------------------------------------------------------------------- 1 | #include "mockrule.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | ::testing::StrictMock& mockRule() 7 | { 8 | static ::testing::StrictMock mockRule; 9 | return mockRule; 10 | } 11 | 12 | } // namespace PIOL 13 | } // namespace exseis 14 | -------------------------------------------------------------------------------- /test/wraptests/mockrule.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSMOCKRULE_HEADER_GUARD 2 | #define PIOLWRAPTESTSMOCKRULE_HEADER_GUARD 3 | 4 | #include "googletest_variable_instances.hh" 5 | #include "gmock/gmock.h" 6 | 7 | #include "ExSeisDat/PIOL/Rule.hh" 8 | #include "ExSeisDat/PIOL/RuleEntry.hh" 9 | 10 | namespace exseis { 11 | namespace PIOL { 12 | 13 | class MockRule; 14 | ::testing::StrictMock& mockRule(); 15 | 16 | class MockRule { 17 | public: 18 | MOCK_METHOD4(ctor, void(Rule*, bool full, bool defaults, bool extras)); 19 | 20 | MOCK_METHOD5( 21 | ctor, 22 | void( 23 | Rule*, 24 | const std::vector& m, 25 | bool full, 26 | bool defaults, 27 | bool extras)); 28 | 29 | MOCK_METHOD3(ctor, void(Rule*, Rule::RuleMap translate_, bool full)); 30 | 31 | MOCK_METHOD1(dtor, void(Rule*)); 32 | 33 | MOCK_METHOD2(addRule, bool(Rule*, Meta m)); 34 | 35 | MOCK_METHOD2(addRule, bool(Rule*, const Rule& r)); 36 | 37 | MOCK_METHOD3(addLong, void(Rule*, Meta m, Tr loc)); 38 | 39 | MOCK_METHOD4(addSEGYFloat, void(Rule*, Meta m, Tr loc, Tr scalLoc)); 40 | 41 | MOCK_METHOD3(addShort, void(Rule*, Meta m, Tr loc)); 42 | 43 | MOCK_METHOD2(addIndex, void(Rule*, Meta m)); 44 | 45 | MOCK_METHOD1(addCopy, void(Rule*)); 46 | 47 | MOCK_METHOD2(rmRule, void(Rule*, Meta m)); 48 | 49 | MOCK_METHOD1(extent, size_t(Rule*)); 50 | 51 | MOCK_CONST_METHOD1(memUsage, size_t(const Rule*)); 52 | 53 | MOCK_CONST_METHOD1(paramMem, size_t(const Rule*)); 54 | 55 | MOCK_METHOD2(getEntry, RuleEntry*(Rule*, Meta entry)); 56 | }; 57 | 58 | } // namespace PIOL 59 | } // namespace exseis 60 | 61 | #endif // PIOLWRAPTESTSMOCKRULE_HEADER_GUARD 62 | -------------------------------------------------------------------------------- /test/wraptests/mockset.cc: -------------------------------------------------------------------------------- 1 | #include "mockset.hh" 2 | 3 | namespace exseis { 4 | namespace Flow { 5 | 6 | ::testing::StrictMock& mockSet() 7 | { 8 | static ::testing::StrictMock mockSet; 9 | return mockSet; 10 | } 11 | 12 | } // namespace Flow 13 | } // namespace exseis 14 | -------------------------------------------------------------------------------- /test/wraptests/mockwritedirect.cc: -------------------------------------------------------------------------------- 1 | #include "mockwritedirect.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | ::testing::StrictMock& mockWriteDirect() 7 | { 8 | static ::testing::StrictMock mockWriteDirect; 9 | return mockWriteDirect; 10 | } 11 | 12 | } // namespace PIOL 13 | } // namespace exseis 14 | -------------------------------------------------------------------------------- /test/wraptests/mockwritedirect.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSMOCKWRITEDIRECT_HEADER_GUARD 2 | #define PIOLWRAPTESTSMOCKWRITEDIRECT_HEADER_GUARD 3 | 4 | #include "googletest_variable_instances.hh" 5 | #include "gmock/gmock.h" 6 | 7 | #include "ExSeisDat/PIOL/WriteDirect.hh" 8 | 9 | namespace exseis { 10 | namespace PIOL { 11 | 12 | class MockWriteDirect; 13 | ::testing::StrictMock& mockWriteDirect(); 14 | 15 | class MockWriteDirect { 16 | public: 17 | MOCK_METHOD3( 18 | ctor, 19 | void( 20 | WriteDirect*, 21 | std::shared_ptr piol, 22 | const std::string name)); 23 | 24 | MOCK_METHOD2( 25 | ctor, void(WriteDirect*, std::shared_ptr file)); 26 | 27 | MOCK_METHOD1(dtor, void(WriteDirect*)); 28 | 29 | MOCK_METHOD2(writeText, void(WriteDirect*, const std::string text_)); 30 | 31 | MOCK_METHOD2(writeNs, void(WriteDirect*, const size_t ns_)); 32 | 33 | MOCK_METHOD2(writeNt, void(WriteDirect*, const size_t nt_)); 34 | 35 | MOCK_METHOD2( 36 | writeInc, void(WriteDirect*, const exseis::utils::Floating_point inc_)); 37 | 38 | MOCK_METHOD5( 39 | writeTrace, 40 | void( 41 | WriteDirect*, 42 | const size_t offset, 43 | const size_t sz, 44 | exseis::utils::Trace_value* trace, 45 | const Param* prm)); 46 | 47 | MOCK_METHOD4( 48 | writeParam, 49 | void( 50 | WriteDirect*, const size_t offset, const size_t sz, const Param* prm)); 51 | 52 | MOCK_METHOD5( 53 | writeTraceNonContiguous, 54 | void( 55 | WriteDirect*, 56 | const size_t sz, 57 | const size_t* offset, 58 | exseis::utils::Trace_value* trace, 59 | const Param* prm)); 60 | 61 | MOCK_METHOD4( 62 | writeParamNonContiguous, 63 | void( 64 | WriteDirect*, const size_t sz, const size_t* offset, const Param* prm)); 65 | }; 66 | 67 | } // namespace PIOL 68 | } // namespace exseis 69 | 70 | #endif // PIOLWRAPTESTSMOCKWRITEDIRECT_HEADER_GUARD 71 | -------------------------------------------------------------------------------- /test/wraptests/param.cc: -------------------------------------------------------------------------------- 1 | #include "mockparam.hh" 2 | 3 | using namespace exseis::utils; 4 | 5 | namespace exseis { 6 | namespace PIOL { 7 | 8 | Param::Param(std::shared_ptr r_, const size_t sz) 9 | { 10 | mockParam().ctor(this, r_, sz); 11 | } 12 | 13 | Param::Param(const size_t sz) 14 | { 15 | mockParam().ctor(this, sz); 16 | } 17 | 18 | Param::~Param() 19 | { 20 | mockParam().dtor(this); 21 | } 22 | 23 | size_t Param::size(void) const 24 | { 25 | return mockParam().size(this); 26 | } 27 | 28 | size_t Param::memUsage(void) const 29 | { 30 | return mockParam().memUsage(this); 31 | } 32 | 33 | void param_utils::cpyPrm( 34 | const size_t j, const Param* src, const size_t k, Param* dst) 35 | { 36 | mockParamFreeFunctions().cpyPrm(j, src, k, dst); 37 | } 38 | 39 | 40 | template<> 41 | int16_t param_utils::getPrm(size_t i, Meta entry, const Param* prm) 42 | { 43 | return mockParamFreeFunctions().getPrm_int16_t(i, entry, prm); 44 | } 45 | 46 | template<> 47 | exseis::utils::Integer param_utils::getPrm( 48 | size_t i, Meta entry, const Param* prm) 49 | { 50 | return mockParamFreeFunctions().getPrm_Integer(i, entry, prm); 51 | } 52 | 53 | template<> 54 | exseis::utils::Floating_point 55 | param_utils::getPrm( 56 | size_t i, Meta entry, const Param* prm) 57 | { 58 | return mockParamFreeFunctions().getPrm_Floating_point(i, entry, prm); 59 | } 60 | 61 | template<> 62 | void param_utils::setPrm( 63 | const size_t i, const Meta entry, int16_t ret, Param* prm) 64 | { 65 | mockParamFreeFunctions().setPrm_int16_t(i, entry, ret, prm); 66 | } 67 | 68 | template<> 69 | void param_utils::setPrm( 70 | const size_t i, const Meta entry, exseis::utils::Integer ret, Param* prm) 71 | { 72 | mockParamFreeFunctions().setPrm_Integer(i, entry, ret, prm); 73 | } 74 | 75 | template<> 76 | void param_utils::setPrm( 77 | const size_t i, 78 | const Meta entry, 79 | exseis::utils::Floating_point ret, 80 | Param* prm) 81 | { 82 | mockParamFreeFunctions().setPrm_Floating_point(i, entry, ret, prm); 83 | } 84 | 85 | } // namespace PIOL 86 | } // namespace exseis 87 | -------------------------------------------------------------------------------- /test/wraptests/paramwraptests.cc: -------------------------------------------------------------------------------- 1 | #include "mockparam.hh" 2 | #include "paramwraptests.hh" 3 | #include "rulewraptests.hh" 4 | #include "wraptesttools.hh" 5 | 6 | using namespace testing; 7 | using namespace exseis::PIOL; 8 | 9 | 10 | std::shared_ptr test_PIOL_File_Param(std::shared_ptr test_rule) 11 | { 12 | auto param_ptr = std::make_shared(); 13 | EXPECT_CALL(mockParam(), ctor(_, GetEqDeref(test_rule), 300)) 14 | .WillOnce(SaveArg<0>(param_ptr)); 15 | 16 | auto param_ptr_2 = std::make_shared(); 17 | EXPECT_CALL(mockParam(), ctor(_, 310)).WillOnce(SaveArg<0>(param_ptr_2)); 18 | 19 | EXPECT_CALL(mockParam(), size(EqDeref(param_ptr))) 20 | .WillOnce(CheckReturn(320)); 21 | EXPECT_CALL(returnChecker(), Call()).WillOnce(ClearCheckReturn()); 22 | EXPECT_CALL(mockParam(), memUsage(EqDeref(param_ptr))) 23 | .WillOnce(CheckReturn(330)); 24 | EXPECT_CALL(returnChecker(), Call()).WillOnce(ClearCheckReturn()); 25 | 26 | EXPECT_CALL( 27 | mockParamFreeFunctions(), 28 | getPrm_int16_t(340, PIOL_META_COPY, EqDeref(param_ptr))) 29 | .WillOnce(CheckReturn(350)); 30 | EXPECT_CALL(returnChecker(), Call()).WillOnce(ClearCheckReturn()); 31 | 32 | EXPECT_CALL( 33 | mockParamFreeFunctions(), 34 | getPrm_Integer(360, PIOL_META_COPY, EqDeref(param_ptr))) 35 | .WillOnce(CheckReturn(370)); 36 | EXPECT_CALL(returnChecker(), Call()).WillOnce(ClearCheckReturn()); 37 | 38 | EXPECT_CALL( 39 | mockParamFreeFunctions(), 40 | getPrm_Floating_point(380, PIOL_META_COPY, EqDeref(param_ptr))) 41 | .WillOnce(CheckReturn(390.0)); 42 | EXPECT_CALL(returnChecker(), Call()).WillOnce(ClearCheckReturn()); 43 | 44 | EXPECT_CALL( 45 | mockParamFreeFunctions(), 46 | setPrm_int16_t(400, PIOL_META_COPY, 410, EqDeref(param_ptr))); 47 | EXPECT_CALL( 48 | mockParamFreeFunctions(), 49 | setPrm_Integer(420, PIOL_META_COPY, 430, EqDeref(param_ptr))); 50 | EXPECT_CALL( 51 | mockParamFreeFunctions(), 52 | setPrm_Floating_point( 53 | 440, PIOL_META_COPY, DoubleEq(450.0), EqDeref(param_ptr))); 54 | 55 | EXPECT_CALL( 56 | mockParamFreeFunctions(), 57 | cpyPrm(460, EqDeref(param_ptr), 470, EqDeref(param_ptr_2))); 58 | 59 | EXPECT_CALL(mockParam(), dtor(EqDeref(param_ptr_2))); 60 | 61 | return param_ptr; 62 | } 63 | -------------------------------------------------------------------------------- /test/wraptests/paramwraptests.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSPARAMWRAPTEST_HEADER_GUARD 2 | #define PIOLWRAPTESTSPARAMWRAPTEST_HEADER_GUARD 3 | 4 | #include "mockparam.hh" 5 | #include "mockrule.hh" 6 | 7 | #include "googletest_variable_instances.hh" 8 | 9 | std::shared_ptr test_PIOL_File_Param( 10 | std::shared_ptr test_rule); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /test/wraptests/printers.cc: -------------------------------------------------------------------------------- 1 | #include "printers.hh" 2 | 3 | #include "ExSeisDat/PIOL/Param.h" 4 | #include "ExSeisDat/PIOL/operations/minmax.h" 5 | 6 | ::std::ostream& operator<<(::std::ostream& os, const PIOL_CoordElem& value) 7 | { 8 | os << "exseis::PIOL::CoordElem { " 9 | << ".val = " << value.val << ", " 10 | << ".num = " << value.num << " }"; 11 | return os; 12 | } 13 | 14 | namespace exseis { 15 | namespace PIOL { 16 | 17 | ::std::ostream& operator<<(::std::ostream& os, Param* value) 18 | { 19 | os << "exseis::PIOL::Param* " << static_cast(value); 20 | return os; 21 | } 22 | 23 | ::std::ostream& operator<<(::std::ostream& os, const Param* value) 24 | { 25 | os << "const exseis::PIOL::Param* " << static_cast(value); 26 | return os; 27 | } 28 | 29 | } // namespace PIOL 30 | } // namespace exseis 31 | 32 | namespace std { 33 | 34 | ::std::ostream& operator<<( 35 | ::std::ostream& os, const std::shared_ptr& value) 36 | { 37 | os << "std::shared_ptr " 38 | << static_cast(value.get()); 39 | return os; 40 | } 41 | 42 | } // namespace std 43 | -------------------------------------------------------------------------------- /test/wraptests/printers.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSPRINTERS_INCLUDE_GUARD 2 | #define PIOLWRAPTESTSPRINTERS_INCLUDE_GUARD 3 | 4 | #include 5 | #include 6 | 7 | extern "C" struct PIOL_CoordElem; 8 | 9 | ::std::ostream& operator<<(::std::ostream& os, const PIOL_CoordElem& value); 10 | 11 | namespace exseis { 12 | namespace PIOL { 13 | 14 | struct Rule; 15 | struct Param; 16 | 17 | ::std::ostream& operator<<(::std::ostream& os, Param* value); 18 | ::std::ostream& operator<<(::std::ostream& os, const Param* value); 19 | 20 | } // namespace PIOL 21 | } // namespace exseis 22 | 23 | namespace std { 24 | 25 | ::std::ostream& operator<<( 26 | ::std::ostream& os, const std::shared_ptr& value); 27 | 28 | } // namespace std 29 | 30 | #endif // PIOLWRAPTESTSPRINTERS_INCLUDE_GUARD 31 | -------------------------------------------------------------------------------- /test/wraptests/readdirect.cc: -------------------------------------------------------------------------------- 1 | #include "mockreaddirect.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | ReadDirect::ReadDirect(std::shared_ptr piol, const std::string name) 7 | { 8 | mockReadDirect().ctor(this, piol, name); 9 | } 10 | 11 | ReadDirect::ReadDirect(std::shared_ptr file) 12 | { 13 | mockReadDirect().ctor(this, file); 14 | } 15 | 16 | ReadDirect::~ReadDirect() 17 | { 18 | mockReadDirect().dtor(this); 19 | } 20 | 21 | const std::string& ReadDirect::readText() const 22 | { 23 | return mockReadDirect().readText(this); 24 | } 25 | 26 | size_t ReadDirect::readNs() const 27 | { 28 | return mockReadDirect().readNs(this); 29 | } 30 | 31 | size_t ReadDirect::readNt() const 32 | { 33 | return mockReadDirect().readNt(this); 34 | } 35 | 36 | exseis::utils::Floating_point ReadDirect::readInc() const 37 | { 38 | return mockReadDirect().readInc(this); 39 | } 40 | 41 | void ReadDirect::readTrace( 42 | const size_t offset, 43 | const size_t sz, 44 | exseis::utils::Trace_value* trace, 45 | Param* prm) const 46 | { 47 | mockReadDirect().readTrace(this, offset, sz, trace, prm); 48 | } 49 | 50 | void ReadDirect::readParam( 51 | const size_t offset, const size_t sz, Param* prm) const 52 | { 53 | mockReadDirect().readParam(this, offset, sz, prm); 54 | } 55 | 56 | void ReadDirect::readTraceNonContiguous( 57 | const size_t sz, 58 | const size_t* offset, 59 | exseis::utils::Trace_value* trace, 60 | Param* prm) const 61 | { 62 | mockReadDirect().readTraceNonContiguous(this, sz, offset, trace, prm); 63 | } 64 | 65 | void ReadDirect::readTraceNonMonotonic( 66 | const size_t sz, 67 | const size_t* offset, 68 | exseis::utils::Trace_value* trace, 69 | Param* prm) const 70 | { 71 | mockReadDirect().readTraceNonMonotonic(this, sz, offset, trace, prm); 72 | } 73 | 74 | void ReadDirect::readParamNonContiguous( 75 | const size_t sz, const size_t* offset, Param* prm) const 76 | { 77 | mockReadDirect().readParamNonContiguous(this, sz, offset, prm); 78 | } 79 | 80 | } // namespace PIOL 81 | } // namespace exseis 82 | -------------------------------------------------------------------------------- /test/wraptests/readdirectwraptests.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSREADDIRECTWRAPTESTS_INCLUDE_GUARD 2 | #define PIOLWRAPTESTSREADDIRECTWRAPTESTS_INCLUDE_GUARD 3 | 4 | #include "mockexseis.hh" 5 | #include "mockparam.hh" 6 | 7 | #include 8 | 9 | void test_PIOL_File_ReadDirect( 10 | std::shared_ptr piol, 11 | std::shared_ptr param); 12 | 13 | #endif // PIOLWRAPTESTSREADDIRECTWRAPTESTS_INCLUDE_GUARD 14 | -------------------------------------------------------------------------------- /test/wraptests/rule.cc: -------------------------------------------------------------------------------- 1 | #include "mockrule.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | Rule::Rule(bool full, bool defaults, bool extras) 7 | { 8 | mockRule().ctor(this, full, defaults, extras); 9 | } 10 | 11 | Rule::Rule(const std::vector& m, bool full, bool defaults, bool extras) 12 | { 13 | mockRule().ctor(this, m, full, defaults, extras); 14 | } 15 | 16 | Rule::Rule(RuleMap translate_, bool full) 17 | { 18 | mockRule().ctor(this, translate_, full); 19 | } 20 | 21 | Rule::~Rule() 22 | { 23 | mockRule().dtor(this); 24 | } 25 | 26 | bool Rule::addRule(Meta m) 27 | { 28 | return mockRule().addRule(this, m); 29 | } 30 | 31 | bool Rule::addRule(const Rule& r) 32 | { 33 | return mockRule().addRule(this, r); 34 | } 35 | 36 | void Rule::addLong(Meta m, Tr loc) 37 | { 38 | mockRule().addLong(this, m, loc); 39 | } 40 | 41 | void Rule::addSEGYFloat(Meta m, Tr loc, Tr scalLoc) 42 | { 43 | mockRule().addSEGYFloat(this, m, loc, scalLoc); 44 | } 45 | 46 | void Rule::addShort(Meta m, Tr loc) 47 | { 48 | mockRule().addShort(this, m, loc); 49 | } 50 | 51 | void Rule::addIndex(Meta m) 52 | { 53 | mockRule().addIndex(this, m); 54 | } 55 | 56 | void Rule::addCopy() 57 | { 58 | mockRule().addCopy(this); 59 | } 60 | 61 | void Rule::rmRule(Meta m) 62 | { 63 | mockRule().rmRule(this, m); 64 | } 65 | 66 | size_t Rule::extent() 67 | { 68 | return mockRule().extent(this); 69 | } 70 | 71 | size_t Rule::memUsage() const 72 | { 73 | return mockRule().memUsage(this); 74 | } 75 | 76 | size_t Rule::paramMem() const 77 | { 78 | return mockRule().paramMem(this); 79 | } 80 | 81 | RuleEntry* Rule::getEntry(Meta entry) 82 | { 83 | return mockRule().getEntry(this, entry); 84 | } 85 | 86 | } // namespace PIOL 87 | } // namespace exseis 88 | -------------------------------------------------------------------------------- /test/wraptests/rulewraptests.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSRULEWRAPTEST_HEADER_GUARD 2 | #define PIOLWRAPTESTSRULEWRAPTEST_HEADER_GUARD 3 | 4 | #include "mockrule.hh" 5 | 6 | #include 7 | 8 | std::shared_ptr test_PIOL_File_Rule(); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /test/wraptests/setwraptests.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSSETWRAPTESTS_INCLUDE_GUARD 2 | #define PIOLWRAPTESTSSETWRAPTESTS_INCLUDE_GUARD 3 | 4 | #include "mockexseis.hh" 5 | 6 | #include 7 | 8 | void test_PIOL_Set(std::shared_ptr piol); 9 | 10 | #endif // PIOLWRAPTESTSSETWRAPTESTS_INCLUDE_GUARD 11 | -------------------------------------------------------------------------------- /test/wraptests/wraptests.cc: -------------------------------------------------------------------------------- 1 | #include "wraptests.h" 2 | #include "wraptesttools.hh" 3 | 4 | #include "gmock/gmock.h" 5 | #include "gtest/gtest.h" 6 | 7 | #include "mockexseis.hh" 8 | #include "mockparam.hh" 9 | #include "mockrule.hh" 10 | 11 | #include "exseiswraptest.hh" 12 | #include "getminmaxwraptests.hh" 13 | #include "paramwraptests.hh" 14 | #include "readdirectwraptests.hh" 15 | #include "rulewraptests.hh" 16 | #include "setwraptests.hh" 17 | #include "writedirectwraptests.hh" 18 | 19 | extern "C" { 20 | 21 | void init_wraptests() 22 | { 23 | // Initialize GoogleTest 24 | 25 | // Argc and argv. 26 | int argc = 1; 27 | 28 | // const char* needed for string literal, non-const char* needed for 29 | // google test. 30 | const char* program_name = "cwraptests"; 31 | auto program_name_v = 32 | std::vector{program_name, program_name + strlen(program_name) + 1}; 33 | char* program_name_ptr = program_name_v.data(); 34 | 35 | // Throw so TestBuilder has something to catch and report. 36 | testing::GTEST_FLAG(throw_on_failure) = true; 37 | 38 | testing::InitGoogleTest(&argc, &program_name_ptr); 39 | 40 | // Disable GoogleTest printing exceptions. 41 | testing::TestEventListeners& listeners = 42 | testing::UnitTest::GetInstance()->listeners(); 43 | listeners.Release(listeners.default_result_printer()); 44 | 45 | // Setup and add the CheckReturnListener 46 | exseis::PIOL::checkReturnListener() = new exseis::PIOL::CheckReturnListener; 47 | listeners.Append(exseis::PIOL::checkReturnListener()); 48 | 49 | //::testing::FLAGS_gmock_verbose = "info"; 50 | ::testing::FLAGS_gmock_verbose = "error"; 51 | 52 | // Add test initializers here 53 | testing::InSequence s; 54 | auto test_exseis = test_PIOL_ExSeis(); 55 | auto test_rule = test_PIOL_File_Rule(); 56 | auto test_param = test_PIOL_File_Param(test_rule); 57 | test_PIOL_File_getMinMax(test_exseis, test_param); 58 | test_PIOL_File_ReadDirect(test_exseis, test_param); 59 | test_PIOL_File_WriteDirect(test_exseis, test_param); 60 | test_PIOL_Set(test_exseis); 61 | 62 | // Add cleanup 63 | EXPECT_CALL(exseis::PIOL::mockParam(), dtor(EqDeref(test_param))); 64 | EXPECT_CALL(exseis::PIOL::mockRule(), dtor(EqDeref(test_rule))); 65 | EXPECT_CALL(exseis::PIOL::mockExSeis(), dtor(EqDeref(test_exseis))); 66 | } 67 | 68 | void wraptest_ok() 69 | { 70 | exseis::PIOL::returnChecker().Call(); 71 | } 72 | 73 | } // extern "C" 74 | -------------------------------------------------------------------------------- /test/wraptests/wraptests.h: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSWRAPTESTS_HEADER_GUARD 2 | #define PIOLWRAPTESTSWRAPTESTS_HEADER_GUARD 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | void init_wraptests(); 9 | void fail_wraptests(); 10 | void wraptest_ok(); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /test/wraptests/wraptesttools.cc: -------------------------------------------------------------------------------- 1 | #include "wraptesttools.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | CheckReturnListener*& checkReturnListener() 7 | { 8 | static PIOL::CheckReturnListener* checkReturnListener = nullptr; 9 | return checkReturnListener; 10 | } 11 | 12 | ::testing::StrictMock<::testing::MockFunction>& returnChecker() 13 | { 14 | static ::testing::StrictMock<::testing::MockFunction> returnChecker; 15 | return returnChecker; 16 | } 17 | 18 | } // namespace PIOL 19 | } // namespace exseis 20 | -------------------------------------------------------------------------------- /test/wraptests/wraptesttools.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSWRAPTESTTOOLS_HEADER_GUARD 2 | #define PIOLWRAPTESTSWRAPTESTTOOLS_HEADER_GUARD 3 | 4 | #include "checkreturnlistener.hh" 5 | #include "printers.hh" 6 | 7 | #include "googletest_variable_instances.hh" 8 | #include "gmock/gmock.h" 9 | 10 | 11 | namespace exseis { 12 | namespace PIOL { 13 | 14 | // A global instance of CheckReturnListener. 15 | // This should be set to the pointer passed into the gtest listeners. 16 | CheckReturnListener*& checkReturnListener(); 17 | 18 | // Returns a mocked function which, when called, will call 19 | // checkReturnListener->got_expected_return_value(); 20 | ::testing::StrictMock<::testing::MockFunction>& returnChecker(); 21 | 22 | } // namespace PIOL 23 | } // namespace exseis 24 | 25 | 26 | // EqDeref(p): *p == arg 27 | MATCHER_P(EqDeref, p, "EqDeref") 28 | { 29 | return *p == arg; 30 | } 31 | 32 | // GetEqDeref(p) *p == arg.get() 33 | MATCHER_P(GetEqDeref, p, "GetEqDeref") 34 | { 35 | return *p == arg.get(); 36 | } 37 | 38 | // AddressEqDeref(p): *p == &arg 39 | MATCHER_P(AddressEqDeref, p, "AddressEqDeref") 40 | { 41 | return *p == &arg; 42 | } 43 | 44 | 45 | ACTION_P(CheckReturn, v) 46 | { 47 | exseis::PIOL::checkReturnListener()->expect_return_value( 48 | testing::PrintToString(v)); 49 | return v; 50 | } 51 | 52 | ACTION_P(CheckInOutParam, v) 53 | { 54 | exseis::PIOL::checkReturnListener()->expect_return_value( 55 | testing::PrintToString(v)); 56 | } 57 | 58 | ACTION(ClearCheckReturn) 59 | { 60 | exseis::PIOL::checkReturnListener()->got_expected_return_value(); 61 | } 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /test/wraptests/writedirect.cc: -------------------------------------------------------------------------------- 1 | #include "mockwritedirect.hh" 2 | 3 | namespace exseis { 4 | namespace PIOL { 5 | 6 | WriteDirect::WriteDirect( 7 | std::shared_ptr piol, const std::string name) 8 | { 9 | mockWriteDirect().ctor(this, piol, name); 10 | } 11 | 12 | WriteDirect::WriteDirect(std::shared_ptr file) 13 | { 14 | mockWriteDirect().ctor(this, file); 15 | } 16 | 17 | WriteDirect::~WriteDirect() 18 | { 19 | mockWriteDirect().dtor(this); 20 | } 21 | 22 | void WriteDirect::writeText(const std::string text_) 23 | { 24 | mockWriteDirect().writeText(this, text_); 25 | } 26 | 27 | void WriteDirect::writeNs(const size_t ns_) 28 | { 29 | mockWriteDirect().writeNs(this, ns_); 30 | } 31 | 32 | void WriteDirect::writeNt(const size_t nt_) 33 | { 34 | mockWriteDirect().writeNt(this, nt_); 35 | } 36 | 37 | void WriteDirect::writeInc(const exseis::utils::Floating_point inc_) 38 | { 39 | mockWriteDirect().writeInc(this, inc_); 40 | } 41 | 42 | void WriteDirect::writeTrace( 43 | const size_t offset, 44 | const size_t sz, 45 | exseis::utils::Trace_value* trace, 46 | const Param* prm) 47 | { 48 | mockWriteDirect().writeTrace(this, offset, sz, trace, prm); 49 | } 50 | 51 | void WriteDirect::writeParam( 52 | const size_t offset, const size_t sz, const Param* prm) 53 | { 54 | mockWriteDirect().writeParam(this, offset, sz, prm); 55 | } 56 | 57 | void WriteDirect::writeTraceNonContiguous( 58 | const size_t sz, 59 | const size_t* offset, 60 | exseis::utils::Trace_value* trace, 61 | const Param* prm) 62 | { 63 | mockWriteDirect().writeTraceNonContiguous(this, sz, offset, trace, prm); 64 | } 65 | 66 | void WriteDirect::writeParamNonContiguous( 67 | const size_t sz, const size_t* offset, const Param* prm) 68 | { 69 | mockWriteDirect().writeParamNonContiguous(this, sz, offset, prm); 70 | } 71 | 72 | } // namespace PIOL 73 | } // namespace exseis 74 | -------------------------------------------------------------------------------- /test/wraptests/writedirectwraptests.cc: -------------------------------------------------------------------------------- 1 | #include "mockwritedirect.hh" 2 | #include "wraptesttools.hh" 3 | #include "writedirectwraptests.hh" 4 | 5 | using namespace testing; 6 | using namespace exseis::PIOL; 7 | 8 | const auto writeText_return = std::string{"Test WriteDirect Text"}; 9 | 10 | void test_PIOL_File_WriteDirect( 11 | std::shared_ptr piol, std::shared_ptr param) 12 | { 13 | 14 | auto write_direct_ptr = std::make_shared(); 15 | 16 | EXPECT_CALL( 17 | mockWriteDirect(), ctor(_, GetEqDeref(piol), "Test_WriteDirect_filename")) 18 | .WillOnce(SaveArg<0>(write_direct_ptr)); 19 | 20 | EXPECT_CALL( 21 | mockWriteDirect(), 22 | writeText(EqDeref(write_direct_ptr), StrEq("Test WriteDirect Text"))); 23 | 24 | const size_t ns = 700; 25 | EXPECT_CALL(mockWriteDirect(), writeNs(EqDeref(write_direct_ptr), ns)); 26 | 27 | EXPECT_CALL(mockWriteDirect(), writeNt(EqDeref(write_direct_ptr), 710)); 28 | 29 | EXPECT_CALL( 30 | mockWriteDirect(), writeInc(EqDeref(write_direct_ptr), DoubleEq(720.0))); 31 | 32 | EXPECT_CALL( 33 | mockWriteDirect(), 34 | writeParam(EqDeref(write_direct_ptr), 730, 740, EqDeref(param))); 35 | 36 | 37 | EXPECT_CALL( 38 | mockWriteDirect(), writeParamNonContiguous( 39 | EqDeref(write_direct_ptr), 750, _, EqDeref(param))) 40 | .WillOnce(WithArg<2>(Invoke([](const size_t* offsets) { 41 | for (size_t i = 0; i < 750; i++) { 42 | EXPECT_EQ(offsets[i], i); 43 | } 44 | }))); 45 | 46 | 47 | EXPECT_CALL( 48 | mockWriteDirect(), 49 | writeTrace(EqDeref(write_direct_ptr), 760, 770, _, EqDeref(param))) 50 | .WillOnce(WithArg<3>(Invoke([](float* trace) { 51 | for (size_t i = 0; i < ns * 770; i++) { 52 | EXPECT_FLOAT_EQ(trace[i], i * 1.0); 53 | } 54 | }))); 55 | 56 | 57 | EXPECT_CALL( 58 | mockWriteDirect(), 59 | writeTraceNonContiguous( 60 | EqDeref(write_direct_ptr), 780, _, _, EqDeref(param))) 61 | .WillOnce(WithArgs<2, 3>(Invoke([](const size_t* offsets, float* trace) { 62 | for (size_t i = 0; i < 780; i++) { 63 | EXPECT_EQ(offsets[i], i); 64 | } 65 | for (size_t i = 0; i < ns * 780; i++) { 66 | EXPECT_FLOAT_EQ(trace[i], i * 1.0); 67 | } 68 | }))); 69 | 70 | EXPECT_CALL(mockWriteDirect(), dtor(EqDeref(write_direct_ptr))); 71 | } 72 | -------------------------------------------------------------------------------- /test/wraptests/writedirectwraptests.hh: -------------------------------------------------------------------------------- 1 | #ifndef PIOLWRAPTESTSWRITEDIRECTWRAPTESTS_INCLUDE_GUARD 2 | #define PIOLWRAPTESTSWRITEDIRECTWRAPTESTS_INCLUDE_GUARD 3 | 4 | #include "mockexseis.hh" 5 | #include "mockparam.hh" 6 | 7 | #include 8 | 9 | void test_PIOL_File_WriteDirect( 10 | std::shared_ptr piol, 11 | std::shared_ptr param); 12 | 13 | #endif // PIOLWRAPTESTSWRITEDIRECTWRAPTESTS_INCLUDE_GUARD 14 | -------------------------------------------------------------------------------- /util/4d.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | //////////////////////////////////////////////////////////////////////////////// 4 | #ifndef EXSEISDAT_UTIL_4D_HH 5 | #define EXSEISDAT_UTIL_4D_HH 6 | 7 | #include "ExSeisDat/PIOL/ExSeisPIOL.hh" 8 | 9 | #include 10 | 11 | /// Constant for alignment reasons. 12 | #define ALIGN 32U 13 | 14 | /// A typedef for the precision used for coordinates during the 4dbin 15 | typedef float fourd_t; 16 | 17 | /*! Structure for 4d binning options 18 | */ 19 | struct FourDOpt { 20 | /// Be verbose in the output 21 | bool verbose = false; 22 | 23 | /// print the dsr value to the SEG-Y output files 24 | bool printDsr = true; 25 | 26 | /// Constrain by inline and crossline 27 | bool ixline = false; 28 | }; 29 | 30 | namespace exseis { 31 | namespace PIOL { 32 | 33 | /*! Every process will call this function and process 0 will print the string. 34 | * @param[in] piol The piol object. 35 | * @param[in] msg The string to print. 36 | */ 37 | void cmsg(ExSeisPIOL* piol, std::string msg); 38 | 39 | } // namespace PIOL 40 | } // namespace exseis 41 | 42 | #endif // EXSEISDAT_UTIL_4D_HH 43 | -------------------------------------------------------------------------------- /util/4dcore.hh: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @author Cathal O Broin - cathal@ichec.ie - first commit 4 | /// @date January 2017 5 | /// @brief 6 | /// @details 7 | //////////////////////////////////////////////////////////////////////////////// 8 | 9 | #include "4dio.hh" 10 | 11 | #include 12 | 13 | namespace exseis { 14 | namespace PIOL { 15 | namespace FOURD { 16 | 17 | /*! Error check the mpi error value. 18 | * @param[in] err The mpi error value. 19 | */ 20 | inline void MPIErr(int err) 21 | { 22 | assert(err == MPI_SUCCESS); 23 | } 24 | 25 | /*! For each trace, insert into min the trace number from coords2 (distributed) 26 | * that minimise the difference between the respective src/rcv coordinates. 27 | * @param[in] piol The piol object. 28 | * @param[in] dsrmax The maximum possible distance an acceptable solution can 29 | * be away from the coords1 trace. The smaller the value, 30 | * the quicker the search but the lower the tolerance in a 31 | * match. 32 | * @param[in] coords1 The coordinates for each trace in file 1. The coordinates 33 | * should be distributed across all processes. 34 | * @param[in] coords2 The coordinates for each trace in file 2. The coordinates 35 | * should be distributed across all processes. 36 | * @param[in] opt Options 37 | * @param[out] min After the function is called this vector will contain in the 38 | * entry for each trace the minimum trace. A minimum trace may 39 | * not be present if the only acceptable trace was more than 40 | * dsrmax away. 41 | * @param[out] minrs The dsr value associated with the trace match in min. 42 | */ 43 | void calc4DBin( 44 | ExSeisPIOL* piol, 45 | fourd_t dsrmax, 46 | const Coords* coords1, 47 | const Coords* coords2, 48 | FourDOpt opt, 49 | std::vector& min, 50 | std::vector& minrs); 51 | 52 | } // namespace FOURD 53 | } // namespace PIOL 54 | } // namespace exseis 55 | -------------------------------------------------------------------------------- /util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Link libexseisdat to all the executables. 2 | link_libraries(exseisdat) 3 | 4 | # 5 | # Setup all the utility executables 6 | # 7 | 8 | # Macro calls add_executable with the passed arguments, and adds the executable 9 | # target to EXSEISDAT_UTILITIES_EXES. 10 | set(EXSEISDAT_UTILITIES_EXES) 11 | macro(util_add_executable) 12 | add_executable(${ARGV}) 13 | list(APPEND EXSEISDAT_UTILITIES_EXES ${ARGV0}) 14 | endmacro(util_add_executable) 15 | 16 | 17 | util_add_executable(exseis-cropen cropen.c) 18 | 19 | util_add_executable(exseis-traceanalysis traceanalysis.cc) 20 | 21 | util_add_executable(exseis-radon radon.cc sglobal.cc) 22 | 23 | util_add_executable(exseis-assess assess.cc sglobal.cc) 24 | 25 | util_add_executable(exseis-versort verifysort.cc sglobal.cc) 26 | 27 | util_add_executable(exseis-concatenate concatenate.cc sglobal.cc) 28 | 29 | util_add_executable(exseis-creadwrite concatenate.cc sglobal.cc) 30 | 31 | util_add_executable(exseis-segsort sort.cc) 32 | 33 | util_add_executable(exseis-fourdbin fourdbin.cc 4dio.cc 4dcore.cc sglobal.cc) 34 | 35 | util_add_executable(exseis-filemake filemake.cc sglobal.cc) 36 | 37 | util_add_executable(exseis-makerep makerep.cc sglobal.cc) 38 | 39 | util_add_executable(exseis-makerepn1 makerep.cc sglobal.cc) 40 | 41 | util_add_executable(exseis-makerepn2 makerep.cc sglobal.cc) 42 | 43 | util_add_executable(exseis-minmax minmax.cc sglobal.cc) 44 | 45 | util_add_executable(exseis-segy2kml segy2kml.cc sglobal.cc) 46 | 47 | 48 | # 49 | # Install the utility executables 50 | # 51 | set( 52 | EXSEISDAT_INSTALL_UTILITIES ON CACHE BOOL 53 | "Set whether or not the ExSeisDat utility programs should be installed." 54 | ) 55 | if(EXSEISDAT_INSTALL_UTILITIES) 56 | set( 57 | EXSEISDAT_UTILITIES_BINDIR ${EXSEISDAT_INSTALL_BINDIR} CACHE STRING 58 | "The directory to install the ExSeisDat utility programs to." 59 | ) 60 | 61 | install( 62 | TARGETS ${EXSEISDAT_UTILITIES_EXES} 63 | RUNTIME DESTINATION ${EXSEISDAT_UTILITIES_BINDIR} 64 | ) 65 | 66 | endif(EXSEISDAT_INSTALL_UTILITIES) 67 | -------------------------------------------------------------------------------- /util/assess.cc: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | /// @file 3 | /// @author Cathal O Broin - cathal@ichec.ie - first commit 4 | /// @date January 2017 5 | /// @brief 6 | /// @details This utility searches for files matching a wildcard, filters out 7 | /// the SEGY matches and provides details about what is in the files. 8 | //////////////////////////////////////////////////////////////////////////////// 9 | 10 | #include "ExSeisDat/PIOL/ExSeis.hh" 11 | #include "ExSeisDat/PIOL/ReadDirect.hh" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace exseis::PIOL; 18 | 19 | /*! Main function for assess. 20 | * @param[in] argc The number of arguments. Should be at least 2. 21 | * @param[in] argv The cstring array. The second array should be a globbing 22 | * pattern. 23 | * @todo Switch globbing with regex 24 | * @return Return 0 on success, -1 on failure 25 | */ 26 | int main(int argc, char** argv) 27 | { 28 | if (argc < 2) { 29 | std::cout << "Too few arguments\n"; 30 | return -1; 31 | } 32 | auto piol = ExSeis::New(); 33 | 34 | glob_t globs; 35 | std::cout << "Pattern: " << argv[1] << "\n"; 36 | int err = glob(argv[1], GLOB_TILDE | GLOB_MARK, NULL, &globs); 37 | if (err != 0) { 38 | return -1; 39 | } 40 | 41 | std::regex reg( 42 | ".*se?gy$", std::regex_constants::icase | std::regex_constants::optimize 43 | | std::regex::extended); 44 | 45 | std::cout << "File Count: " << globs.gl_pathc << "\n"; 46 | for (size_t i = 0; i < globs.gl_pathc; i++) { 47 | if (std::regex_match(globs.gl_pathv[i], reg)) { 48 | std::cout << "File: " << globs.gl_pathv[i] << "\n"; 49 | 50 | ReadDirect file(piol, globs.gl_pathv[i]); 51 | piol->isErr(); 52 | std::cout << "-\tNs: " << file.readNs() << "\n"; 53 | std::cout << "-\tNt: " << file.readNt() << "\n"; 54 | std::cout << "-\tInc: " << file.readInc() << "\n"; 55 | std::cerr << "-\tText: " << file.readText() << "\n"; 56 | } 57 | } 58 | 59 | globfree(&globs); 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /util/metaseg: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd "${0%/*}" #cd to metaseg directory 3 | set -o noglob 4 | ./assess $1 5 | set +o noglob 6 | -------------------------------------------------------------------------------- /util/radon.cc: -------------------------------------------------------------------------------- 1 | // POSIX includes 2 | #define _POSIX_C_SOURCE 200809L 3 | 4 | #include "ExSeisDat/Flow/Set.hh" 5 | #include "ExSeisDat/PIOL/ExSeis.hh" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace exseis::PIOL; 12 | using namespace exseis::Flow; 13 | 14 | int main(int argc, char** argv) 15 | { 16 | auto piol = ExSeis::New(); 17 | std::string opt = "i:o:v:b:a:"; // TODO: uses a GNU extension 18 | 19 | std::string radon; 20 | std::string angle; 21 | std::string velocity; 22 | 23 | auto vBin = 20LU; 24 | auto oInc = 60LU; 25 | for (int c = getopt(argc, argv, opt.c_str()); c != -1; 26 | c = getopt(argc, argv, opt.c_str())) { 27 | switch (c) { 28 | case 'i': 29 | radon = optarg; 30 | break; 31 | 32 | case 'v': 33 | velocity = optarg; 34 | break; 35 | 36 | case 'o': 37 | angle = optarg; 38 | break; 39 | 40 | case 'b': 41 | vBin = std::stoul(optarg); 42 | break; 43 | 44 | case 'a': 45 | oInc = std::stoul(optarg); 46 | break; 47 | 48 | default: 49 | std::cerr << "One of the command line arguments is invalid\n"; 50 | break; 51 | } 52 | } 53 | 54 | assert(!radon.empty() && !angle.empty() && !velocity.empty()); 55 | 56 | if (piol->getRank() == 0) { 57 | std::cout << "Radon to Angle Transformation" 58 | << "\n-\tInput radon file:\t" << radon 59 | << "\n-\tVelocity model file:\t" << velocity 60 | << "\n-\tOutput angle file:\t" << angle 61 | << "\n-\tIncrement:\t\t" << oInc << "\n-\tvBin:\t\t\t" << vBin 62 | << std::endl; 63 | } 64 | Set set(piol, radon, angle); 65 | piol->isErr(); 66 | set.toAngle(velocity, vBin, oInc); 67 | 68 | piol->isErr(); 69 | if (piol->getRank() == 0) { 70 | std::cout << "Begin output\n"; 71 | } 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /util/sglobal.cc: -------------------------------------------------------------------------------- 1 | #include "sglobal.hh" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | std::vector lobdecompose( 9 | exseis::PIOL::ExSeisPIOL* piol, size_t sz, size_t numRank, size_t rank) 10 | { 11 | double total = (numRank * (numRank + 1U)) / 2U; 12 | rank++; 13 | size_t lnt = std::lround(double(sz * rank) / total); 14 | 15 | auto rem = sz - piol->comm->sum(lnt); 16 | if (rank == 1) { 17 | lnt += rem; 18 | } 19 | 20 | auto nts = piol->comm->gather(lnt); 21 | size_t biggest = *std::max_element(nts.begin(), nts.end()); 22 | assert(sz == std::accumulate(nts.begin(), nts.end(), 0U)); 23 | 24 | if (rank == 1) { 25 | return std::vector{0U, lnt, biggest}; 26 | } 27 | else { 28 | return std::vector{ 29 | std::accumulate(nts.begin(), nts.begin() + rank - 1U, 0U), lnt, 30 | biggest}; 31 | } 32 | } 33 | 34 | exseis::utils::Contiguous_decomposition blockDecomp( 35 | size_t sz, size_t bsz, size_t numRank, size_t rank, size_t off) 36 | { 37 | // Size of the first block 38 | size_t rstart = bsz - off % bsz; 39 | // Size of the last block 40 | size_t rend = (off + sz) % bsz; 41 | // The total number of blocks, +2 accounts for start+end 42 | size_t bcnt = (sz - rstart - rend) / bsz + 2; 43 | 44 | // Make sure there isn't any leftover, this shouldn't be possible 45 | assert(!((sz - rstart - rend) % bsz)); 46 | 47 | // Do a regular decomposition of the blocks 48 | auto newdec = exseis::utils::block_decomposition(bcnt, numRank, rank); 49 | 50 | newdec.global_offset *= bsz; 51 | newdec.local_size *= bsz; 52 | if (newdec.local_size == 0) { 53 | return {sz, 0}; 54 | } 55 | 56 | // Now we compensate for the fact that the start and end block sizes can be 57 | // different. 58 | if (rank == 0) { 59 | // If the rank is zero, we shrink the first block by the leftover 60 | newdec.local_size -= bsz - rstart; 61 | } 62 | else { 63 | // The subtraction above means every block is shifted 64 | newdec.global_offset -= bsz - rstart; 65 | } 66 | 67 | // The last rank with work must remove the leftover of its last block 68 | if ( 69 | newdec.local_size != 0 70 | && ((newdec.global_offset + newdec.local_size) > sz)) { 71 | newdec.local_size -= bsz - rend; 72 | } 73 | 74 | return newdec; 75 | } 76 | -------------------------------------------------------------------------------- /util/sglobal.hh: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_SGLOBALHH_INCLUDE_GUARD 2 | #define UTIL_SGLOBALHH_INCLUDE_GUARD 3 | 4 | // POSIX includes 5 | #define _POSIX_C_SOURCE 200809L 6 | 7 | #include "ExSeisDat/PIOL/ExSeisPIOL.hh" 8 | #include "ExSeisDat/utils/decomposition/block_decomposition.h" 9 | #include "ExSeisDat/utils/typedefs.h" 10 | 11 | #include 12 | 13 | /*! Decomposition which takes account that the data may come in logical blocks 14 | * @param[in] sz The size of the problem. 15 | * @param[in] bsz The block size 16 | * @param[in] numRank The total number of ranks. 17 | * @param[in] rank The rank during the function call, generally the rank of the 18 | * calling MPI process. 19 | * @return Return an extent, a starting point (generally for a 'for' loop) and 20 | * the number of iterations. 21 | */ 22 | exseis::utils::Contiguous_decomposition blockDecomp( 23 | size_t sz, size_t bsz, size_t numRank, size_t rank, size_t off = 0); 24 | 25 | /*! Unequal decomposition, weights towards the lower ranks. Useful for testing 26 | * purposes 27 | * @param[in] sz The size of the problem. 28 | * @param[in] numRank The total number of ranks. 29 | * @param[in] rank The rank during the function call, generally the rank of the 30 | * calling MPI process. 31 | * @return Return an extent, a starting point (generally for a 'for' loop) and 32 | * the number of iterations. 33 | */ 34 | std::vector lobdecompose( 35 | exseis::PIOL::ExSeisPIOL* piol, size_t sz, size_t numRank, size_t rank); 36 | 37 | #endif // UTIL_SGLOBALHH_INCLUDE_GUARD 38 | -------------------------------------------------------------------------------- /util/sort.cc: -------------------------------------------------------------------------------- 1 | // POSIX includes 2 | #define _POSIX_C_SOURCE 200809L 3 | 4 | #include "ExSeisDat/Flow/Set.hh" 5 | #include "ExSeisDat/PIOL/ExSeis.hh" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace exseis::PIOL; 12 | using namespace exseis::Flow; 13 | 14 | int main(int argc, char** argv) 15 | { 16 | auto piol = ExSeis::New(); 17 | std::string opt = "i:o:t:"; // TODO: uses a GNU extension 18 | 19 | std::string name1; 20 | std::string name2; 21 | 22 | SortType type = PIOL_SORTTYPE_SrcRcv; 23 | for (int c = getopt(argc, argv, opt.c_str()); c != -1; 24 | c = getopt(argc, argv, opt.c_str())) { 25 | switch (c) { 26 | case 'i': 27 | name1 = optarg; 28 | break; 29 | 30 | case 'o': 31 | name2 = optarg; 32 | break; 33 | 34 | case 't': 35 | type = static_cast(std::stoul(optarg)); 36 | break; 37 | 38 | default: 39 | std::cerr << "One of the command line arguments is invalid\n"; 40 | break; 41 | } 42 | } 43 | 44 | assert(!name1.empty() && !name2.empty()); 45 | 46 | Set set(piol, name1, name2); 47 | set.sort(type); 48 | piol->isErr(); 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /util/verifysort.cc: -------------------------------------------------------------------------------- 1 | #include "sglobal.hh" 2 | 3 | #include "ExSeisDat/PIOL/ExSeis.hh" 4 | #include "ExSeisDat/PIOL/ReadDirect.hh" 5 | #include "ExSeisDat/PIOL/operations/sort.hh" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace exseis::utils; 16 | using namespace exseis::PIOL; 17 | 18 | int main(int argc, char** argv) 19 | { 20 | auto piol = ExSeis::New(); 21 | 22 | std::string opt = "i:o:t:d"; // TODO: uses a GNU extension 23 | std::string name1; 24 | SortType type = PIOL_SORTTYPE_SrcRcv; 25 | for (int c = getopt(argc, argv, opt.c_str()); c != -1; 26 | c = getopt(argc, argv, opt.c_str())) { 27 | switch (c) { 28 | case 'i': 29 | name1 = optarg; 30 | break; 31 | 32 | case 't': 33 | type = static_cast(std::stoul(optarg)); 34 | break; 35 | 36 | default: 37 | fprintf( 38 | stderr, "One of the command line arguments is invalid\n"); 39 | break; 40 | } 41 | } 42 | 43 | assert(!name1.empty()); 44 | 45 | ReadDirect src(piol, name1); 46 | 47 | // Perform the decomposition and read coordinates of interest. 48 | auto dec = block_decomposition( 49 | src.readNt(), piol->comm->getNumRank(), piol->comm->getRank()); 50 | 51 | if (checkOrder(src, dec, type)) { 52 | std::cout << "Success\n"; 53 | } 54 | else { 55 | std::cerr << "Failure\n"; 56 | } 57 | 58 | return 0; 59 | } 60 | --------------------------------------------------------------------------------