diff --git a/.gitignore b/.gitignore index 1a97f45af8..b07adcede1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.o *.obj +*.mod *.a *.so *.out.* @@ -46,7 +47,10 @@ src/test/sstruct_fac src/test/struct src/test/struct_migrate src/test/zboxloop -src/examples/ex[0-9] -src/examples/ex1[0-6] -src/examples/ex5f +src/examples/ex0[0-9] +src/examples/ex1[0-8] +src/examples/ex05big +src/examples/ex15big +src/examples/ex18comp +src/examples/ex05f src/examples/ex12f diff --git a/src/examples/Makefile b/src/examples/Makefile index 5c75153d73..fd1897d707 100644 --- a/src/examples/Makefile +++ b/src/examples/Makefile @@ -3,299 +3,226 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -######################################################################## -# Compiler and external dependences -######################################################################## -CC = mpicc -F77 = mpif77 -CXX = mpicxx -F90 = mpif90 -CUF = mpixlcuf -LINK_CC = ${CC} -LINK_CXX = ${CXX} -LINK_FC = ${F77} -LINK_CUF = ${CUF} +#################################################################### +# Compiler and External Dependencies +#################################################################### -XL_DIR=$(dir $(shell which xlc)).. - -HYPRE_DIR = ../hypre - -######################################################################## -# CUDA -######################################################################## -ifeq ($(use_cuda), 1) - CUDA_INCL = -I${CUDA_HOME}/include - CUDA_LIBS = -L${CUDA_HOME}/lib64 -lcudart -lcublas -lcusparse -lcurand -lstdc++ -L$(XL_DIR)/xlC/16.1.1/lib -libmc++ - CUDA_ARCH = -gencode arch=compute_60,code=sm_60 -gencode arch=compute_70,code=sm_70 - NVCC_LDFLAGS = -ccbin=${CXX} ${CUDA_ARCH} - COPTS_CUDA = -DHYPRE_EXAMPLE_USING_CUDA - FOPTS_CUDA = -DHYPRE_EXAMPLE_USING_CUDA -qsuppress=cmpmsg -endif +# Include the main Makefile configuration +include ../config/Makefile.config +# CUDA fortran (cuf) compiler ifeq ($(use_cuf), 1) - CUDA_LIBS = -L${CUDA_HOME}/lib64 -lcudart -lcublas -lcusparse -lcurand -lstdc++ -L$(XL_DIR)/xlC/16.1.1/lib -libmc++ + CUF = mpixlcuf + LINK_CUF = ${CUF} + CUFFLAGS = $(FFLAGS) -qcuda endif -######################################################################## -# Device OMP -######################################################################## -ifeq ($(use_domp), 1) - DOMP_LIBS = -L${CUDA_HOME}/lib64 -lcudart -lcublas -lcusparse -lcurand -lstdc++ -L$(XL_DIR)/xlC/16.1.1/lib -libmc++ - COPTS_DOMP = -DHYPRE_EXAMPLE_USING_DEVICE_OMP - FOPTS_DOMP = -qoffload -W@,-v -qsmp=omp -qinfo=omperrtrace -DHYPRE_EXAMPLE_USING_DEVICE_OMP - LOPTS_DOMP = -qoffload -W@,-v -qsmp=omp -endif +#################################################################### +# Compiler and Linker Flags +#################################################################### -######################################################################## -# Compiling and linking options -######################################################################## -CINCLUDES = -I$(HYPRE_DIR)/include $(CUDA_INCL) -#CDEFS = -DHYPRE_EXVIS -CDEFS = -COPTS = -g -Wall $(COPTS_CUDA) $(COPTS_DOMP) -FOPTS = -g $(FOPTS_CUDA) $(FOPTS_DOMP) -CFLAGS = $(COPTS) $(CINCLUDES) $(CDEFS) -FINCLUDES = $(CINCLUDES) -FFLAGS = $(FOPTS) $(FINCLUDES) -CUFFLAGS = -qcuda -CXXOPTS = $(COPTS) -Wno-deprecated -CXXINCLUDES = $(CINCLUDES) -I.. -CXXDEFS = $(CDEFS) -IFLAGS_BXX = -CXXFLAGS = $(CXXOPTS) $(CXXINCLUDES) $(CXXDEFS) $(IFLAGS_BXX) -IF90FLAGS = -F90FLAGS = $(FFLAGS) $(IF90FLAGS) - -LINKOPTS = $(LOPTS_CUDA) $(LOPTS_DOMP) -LIBS = -L$(HYPRE_DIR)/lib -lHYPRE -lm $(CUDA_LIBS) $(DOMP_LIBS) -LFLAGS = $(LINKOPTS) $(LIBS) -LFLAGS_B =\ - -L${HYPRE_DIR}/lib\ - -lbHYPREClient-C\ - -lbHYPREClient-CX\ - -lbHYPREClient-F\ - -lbHYPRE\ - -lsidl -ldl -lxml2 -LFLAGS77 = $(LFLAGS) -LFLAGS90 = +# Compiler Definitions +ifeq ($(with_vis), 1) + CDEFS = -DHYPRE_EXVIS +endif +CDEFS += -DHYPRE_TIMING +CXXDEFS += $(CDEFS) +FDEFS += -DHYPRE_FORTRAN + +# Include Paths +CINCLUDES = -I${HYPRE_BUILD_DIR}/include\ + $(INCLUDES)\ + $(MPIINCLUDE)\ + $(SUPERLU_INCLUDE)\ + $(DSUPERLU_INCLUDE) + +CXXINCLUDES = -I${HYPRE_BUILD_DIR}/include\ + -I$(srcdir)/../FEI_mv/fei-base\ + $(INCLUDES)\ + $(MPIINCLUDE)\ + $(SUPERLU_INCLUDE)\ + $(DSUPERLU_INCLUDE) + +# Hypre library +LIBS = -L$(HYPRE_BUILD_DIR)/lib -lHYPRE -lm + +# GPU Options +GPUOPTS = + +# Set specific GPU options according to the backend +ifdef HYPRE_CUDA_INCLUDE + GPUOPTS += -DHYPRE_EXAMPLE_USING_CUDA $(HYPRE_CUDA_INCLUDE) + LIBS += $(HYPRE_CUDA_LIBS) -lstdc++ + use_cuda = 1 + +else ifdef HYPRE_HIP_INCLUDE + GPUOPTS += -DHYPRE_EXAMPLE_USING_HIP -D__HIP_PLATFORM_AMD__ $(HYPRE_HIP_INCLUDE) + LIBS += $(HYPRE_HIP_LIBS) -lstdc++ + +else ifdef HYPRE_SYCL_INCLUDE + GPUOPTS += -DHYPRE_EXAMPLE_USING_SYCL $(HYPRE_SYCL_INCLUDE) + LIBS += $(HYPRE_SYCL_LIBS) + +else ifdef HYPRE_RAJA_INCLUDE + LIBS += $(HYPRE_RAJA_LIB) + +else ifdef HYPRE_KOKKOS_INCLUDE + LIBS += $(HYPRE_KOKKOS_LIB) +endif -######################################################################## -# Rules for compiling the source files -######################################################################## -.SUFFIXES: .c .f .cuf .cxx +# Compiler Flags +CFLAGS += $(GPUOPTS) $(CDEFS) $(CINCLUDES) +CXXFLAGS += $(GPUOPTS) $(CXXDEFS) $(CXXINCLUDES) +FFLAGS += $(GPUOPTS) $(FDEFS) $(CINCLUDES) -.c.o: - $(CC) $(CFLAGS) -c $< -.f.o: - $(F77) $(FFLAGS) -c $< -.f.mod: - $(F77) $(FFLAGS) -c $< -.cuf.o: - $(CUF) $(FFLAGS) $(CUFFLAGS) -c $< -.cxx.o: - $(CXX) $(CXXFLAGS) -c $< +# Dependency libraries +LIBS += $(CALIPER_LIBS)\ + $(HYPRE_UMPIRE_LIB)\ + $(HYPRE_MAGMA_LIB) +LFLAGS = $(LIBS) -######################################################################## -# List of all programs to be compiled -######################################################################## -ALLPROGS = ex1 ex2 ex3 ex4 ex5 ex5f ex6 ex7 ex8 ex9 ex11 ex12 ex12f \ - ex13 ex14 ex15 ex16 -BIGINTPROGS = ex5big ex15big -FORTRANPROGS = ex5f ex12f -MAXDIMPROGS = ex17 ex18 -COMPLEXPROGS = ex18comp +#################################################################### +# Target Definitions +#################################################################### -all: $(ALLPROGS) +# C Example Executables +C_EXAMPLES = ex01 ex02 ex03 ex04 ex05 ex06 ex07 ex08\ + ex09 ex11 ex12 ex13 ex14 ex15 ex16 +FORTRAN_EXAMPLES = ex05f ex12f +BIGINT_EXAMPLES = ex05big ex15big +MAXDIM_EXAMPLES = ex17 ex18 +COMPLEX_EXAMPLES = ex18comp -default: all +EXAMPLES = $(C_EXAMPLES) $(FORTRAN_EXAMPLES) $(BIGINT_EXAMPLES)\ + $(MAXDIM_EXAMPLES) $(COMPLEX_EXAMPLES) -gpu: all +#################################################################### +# Build Targets +#################################################################### -bigint: $(BIGINTPROGS) +all: $(C_EXAMPLES) -fortran: $(FORTRANPROGS) +default: all -maxdim: $(MAXDIMPROGS) +gpu: $(C_EXAMPLES) $(FORTRAN_EXAMPLES) -complex: $(COMPLEXPROGS) +bigint: $(BIGINT_EXAMPLES) -######################################################################## -# Example 1 -######################################################################## -ex1: ex1.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +fortran: $(FORTRAN_EXAMPLES) -######################################################################## -# Example 2 -######################################################################## -ex2: ex2.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +maxdim: $(MAXDIM_EXAMPLES) -######################################################################## -# Example 3 -######################################################################## -ex3: ex3.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +complex: $(COMPLEX_EXAMPLES) -######################################################################## -# Example 4 -######################################################################## -ex4: ex4.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +#################################################################### +# Compilation Rules +#################################################################### -######################################################################## -# Example 5 -######################################################################## -ex5: ex5.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +# Compilation Rules for C Programs +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ -######################################################################## -# Example 5 with 64-bit integers -######################################################################## -ex5big: ex5big.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +# Compilation Rules for C++ Programs +%.o: %.cxx + $(CXX) $(CXXFLAGS) -c $< -o $@ -######################################################################## -# Example 5 Fortran 77 -######################################################################## -ifeq ($(use_cuda), 1) -ex5f_cptr.o : ex5f_cptr.f cudaf.mod +# Compilation Rules for Fortran Programs +.f.mod: $(F77) $(FFLAGS) -c $< -ex5f: ex5f_cptr.o cudaf.o - $(LINK_FC) -o $@ $^ $(LFLAGS77) -else -ifeq ($(use_cuf), 1) -ex5f: ex5cuf.o - $(LINK_CUF) -o $@ $^ $(LFLAGS77) -else -ex5f: ex5f.o - $(LINK_FC) -o $@ $^ $(LFLAGS77) -endif -endif +%.mod: cudaf.f + $(F77) $(FFLAGS) -c $< +.cuf.o: + $(CUF) $(FFLAGS) $(CUFFLAGS) -c $< -######################################################################## -# Example 6 -######################################################################## -ex6: ex6.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +#################################################################### +# Linking Rules +#################################################################### -######################################################################## -# Example 7 -######################################################################## -ex7: ex7.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +# Linking C Executables +$(C_EXAMPLES): %: %.o + @echo "Building $@ ..." + $(LINK_CC) -o $@ $< $(LFLAGS) -######################################################################## -# Example 8 -######################################################################## -ex8: ex8.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +$(BIGINT_EXAMPLES): %: %.o + @echo "Building $@ ..." + $(LINK_CC) -o $@ $< $(LFLAGS) -######################################################################## -# Example 9 -######################################################################## -ex9: ex9.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +$(MAXDIM_EXAMPLES): %: %.o + @echo "Building $@ ..." + $(LINK_CC) -o $@ $< $(LFLAGS) -######################################################################## -# Example 10 -######################################################################## -ex10: ex10.o +# Linking C++ Executables +$(CXX_EXAMPLES): %: cxx_%.o + @echo "Building $@ ..." $(LINK_CXX) -o $@ $^ $(LFLAGS) -######################################################################## -# Example 11 -######################################################################## -ex11: ex11.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +#################################################################### +# Installation Target +#################################################################### -######################################################################## -# Example 12 -######################################################################## -ex12: ex12.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +install: all + @echo "Installing examples..." + @mkdir -p $(HYPRE_INSTALL_DIR)/bin + @cp -f $(EXAMPLES) $(HYPRE_INSTALL_DIR)/bin/ + @chmod +x $(HYPRE_INSTALL_DIR)/bin/* + @echo "Installation complete." -######################################################################## -# Example 12 Fortran 77 -######################################################################## +#################################################################### +# Example-Specific Rules +#################################################################### + +# Example 7 Fortran with CUDA or CUF Support +ifeq ($(use_cuda), 1) +ex05f_cptr.o : ex05f_cptr.f cudaf.mod + $(F77) $(FFLAGS) -c $< +ex05f: ex05f_cptr.o cudaf.o + $(LINK_FC) -o $@ $^ $(LFLAGS) +else +ifeq ($(use_cuf), 1) +ex05f: ex05cuf.o + $(LINK_CUF) -o $@ $^ $(LFLAGS) +else +ex05f: ex05f.o + $(LINK_FC) -o $@ $^ $(LFLAGS) +endif +endif + +# Example 12 Fortran with CUDA or CUF Support ifeq ($(use_cuda), 1) ex12f_cptr.o : ex12f_cptr.f cudaf.mod $(F77) $(FFLAGS) -c $< ex12f: ex12f_cptr.o cudaf.o - $(LINK_FC) -o $@ $^ $(LFLAGS77) + $(LINK_FC) -o $@ $^ $(LFLAGS) else ifeq ($(use_cuf), 1) ex12f: ex12cuf.o - $(LINK_CUF) -o $@ $^ $(LFLAGS77) + $(LINK_CUF) -o $@ $^ $(LFLAGS) else ex12f: ex12f.o - $(LINK_FC) -o $@ $^ $(LFLAGS77) + $(LINK_FC) -o $@ $^ $(LFLAGS) endif endif -######################################################################## -# Example 13 -######################################################################## -ex13: ex13.o - $(LINK_CC) -o $@ $^ $(LFLAGS) +# Add more specific rules as needed +# Ensure that dependencies like cudaf.mod are correctly handled ######################################################################## -# Example 14 -######################################################################## -ex14: ex14.o - $(LINK_CC) -o $@ $^ $(LFLAGS) - -######################################################################## -# Example 15 -######################################################################## -ex15: ex15.o - $(LINK_CC) -o $@ $^ $(LFLAGS) - -######################################################################## -# Example 15 with 64-bit integers -######################################################################## -ex15big: ex15big.o - $(LINK_CC) -o $@ $^ $(LFLAGS) - -######################################################################## -# Example 16 -######################################################################## -ex16: ex16.o - $(LINK_CC) -o $@ $^ $(LFLAGS) - -######################################################################## -# Example 17 -######################################################################## -ex17: ex17.o - $(LINK_CC) -o $@ $^ $(LFLAGS) - -######################################################################## -# Example 18 -######################################################################## -ex18: ex18.o - $(LINK_CC) -o $@ $^ $(LFLAGS) - -######################################################################## -# Example 18 (complex) -######################################################################## -ex18comp: ex18comp.o - $(LINK_CC) -o $@ $^ $(LFLAGS) - -######################################################################## -# Clean up +# Clean Targets ######################################################################## clean: - rm -f $(ALLPROGS:=.o) - rm -f $(BIGINTPROGS:=.o) - rm -f $(FORTRANPROGS:=.o) - rm -f $(MAXDIMPROGS:=.o) - rm -f $(COMPLEXPROGS:=.o) - rm -f cudaf.o cudaf.mod ex*.o - cd vis; make clean + @rm -fv $(EXAMPLES:=.o) + @rm -fv $(BIGINT_EXAMPLES:=.o) + @rm -fv $(FORTRAN_EXAMPLES:=.o) + @rm -fv $(MAXDIM_EXAMPLES:=.o) + @rm -fv $(COMPLEX_EXAMPLES:=.o) + @rm -fv cudaf.o cudaf.mod ex*.o + @cd vis; make clean + distclean: clean - rm -f $(ALLPROGS) $(ALLPROGS:=*~) - rm -f $(BIGINTPROGS) $(BIGINTPROGS:=*~) - rm -f $(FORTRANLPROGS) $(FORTRANPROGS:=*~) - rm -f $(MAXDIMPROGS) $(MAXDIMPROGS:=*~) - rm -f $(COMPLEXPROGS) $(COMPLEXPROGS:=*~) - rm -fr README* + @rm -fv $(EXAMPLES) $(EXAMPLES:=*~) + @rm -fv $(BIGINT_EXAMPLES) $(BIGINT_EXAMPLES:=*~) + @rm -fv $(FORTRAN_EXAMPLES) $(FORTRAN_EXAMPLES:=*~) + @rm -fv $(MAXDIM_EXAMPLES) $(MAXDIM_EXAMPLES:=*~) + @rm -fv $(COMPLEX_EXAMPLES) $(COMPLEX_EXAMPLES:=*~) + +.PHONY: clean distclean install diff --git a/src/examples/README.md b/src/examples/README.md new file mode 100644 index 0000000000..94070a543a --- /dev/null +++ b/src/examples/README.md @@ -0,0 +1,65 @@ + + +# HYPRE Examples + +This directory contains example codes demonstrating the usage of HYPRE, a library for solving large, sparse linear systems of equations on massively parallel computers. + +## Requirements + +1. The examples are designed to be built independently of HYPRE. +2. Each example is well-documented with references to the user manual. +3. These examples mimic application codes, serving as starting templates for users. + +## Building and Running + +To build the examples: + +```bash +cd $HYPRE_DIR/src/examples +make +``` + +To run an example (ex02): + +```bash +mpirun -np 2 ./ex02 +``` + +## Example Descriptions + +| Example | Interface | Problem Type | Solver(s) | +|---------|-----------|--------------|-----------| +| ex01 | Struct | Basic demonstration | - | +| ex02 | Struct | 2D Poisson | SMG-PCG | +| ex03 | Struct | NxN 2D Poisson | SMG, SMG-PCG | +| ex04 | Struct | NxN 2D Convection-Reaction-Diffusion | SMG/PFMG - CG/GMRES | +| ex05 | IJ | NxN 2D Poisson | AMG-PCG | +| ex06 | SStruct | 2D Poisson | SMG-PCG | +| ex07 | SStruct | NxN 2D Convection-Reaction-Diffusion | SMG/PFMG - CG/GMRES | +| ex08 | SStruct | 3-parts 2D Poisson | Split-PCG | +| ex09 | SStruct | 2D biharmonic | sysPFMG | +| ex11 | IJ | NxN 2D Poisson eigenvalue problem | AMG-LOBPCG | +| ex12 | SStruct | Nodal 2D Poisson | PFMG, AMG | +| ex13 | SStruct | 6-parts 2D Poisson | AMG | +| ex14 | SStruct | 6-parts 2D Poisson SStruct FEM | AMG | +| ex15 | SStruct | 3D electromagnetic diffusion | AMS | +| ex16 | SStruct | 2D high order Q3 FEM Poisson | AMG | +| ex17 | Struct | 4D Poisson | CG | +| ex18 | SStruct | 4D Poisson | CG | + +## GPU Support + +GPU support is available for CUDA, HIP, and SYCL. To use GPU acceleration: + +1. Ensure HYPRE is built with the appropriate GPU backend +2. Set the corresponding environment variables (e.g., CUDA_HOME for CUDA) +3. Use the `gpu` target when building: `make gpu` + +Note: +1. Running examples on GPUs requires that hypre is built with Unified Memory. +2. Current GPU usage in these examples is suboptimal due to arrays being allocated in small sizes for setting up matrix coefficients per row. For better GPU utilization, matrices and vectors should be filled in larger blocks of data. diff --git a/src/examples/docs/2d-bi.htm b/src/examples/docs/2d-bi.htm index 715324cd9e..e7c7c964cb 100644 --- a/src/examples/docs/2d-bi.htm +++ b/src/examples/docs/2d-bi.htm @@ -3,7 +3,7 @@
- +diff --git a/src/examples/docs/2d-con-reac-diff.htm b/src/examples/docs/2d-con-reac-diff.htm index 65dba4c199..cce29dd9fe 100644 --- a/src/examples/docs/2d-con-reac-diff.htm +++ b/src/examples/docs/2d-con-reac-diff.htm @@ -3,8 +3,8 @@
- - + +diff --git a/src/examples/docs/2d-laplace.htm b/src/examples/docs/2d-laplace.htm index a80c9b2ac4..49c3ae7784 100644 --- a/src/examples/docs/2d-laplace.htm +++ b/src/examples/docs/2d-laplace.htm @@ -3,10 +3,10 @@
- - - - + + + + diff --git a/src/examples/docs/5pt.htm b/src/examples/docs/5pt.htm index f4b2e22ed3..e81b31907e 100644 --- a/src/examples/docs/5pt.htm +++ b/src/examples/docs/5pt.htm @@ -3,14 +3,14 @@5-Point Stencil Example Codes
- - - - - - - - + + + + + + + +diff --git a/src/examples/docs/9pt.htm b/src/examples/docs/9pt.htm index 6531b24682..c7b12a3434 100644 --- a/src/examples/docs/9pt.htm +++ b/src/examples/docs/9pt.htm @@ -3,7 +3,7 @@9-Point Stencil Example Codes
- +diff --git a/src/examples/docs/amg.htm b/src/examples/docs/amg.htm index f72ad6f6cc..ce8328f098 100644 --- a/src/examples/docs/amg.htm +++ b/src/examples/docs/amg.htm @@ -3,8 +3,8 @@BoomerAMG Example Codes
- - + + diff --git a/src/examples/docs/c.htm b/src/examples/docs/c.htm index c4bcdb845a..b3c24c7f1a 100644 --- a/src/examples/docs/c.htm +++ b/src/examples/docs/c.htm @@ -3,15 +3,15 @@C Example Codes
- - - - - - - - - + + + + + + + + + diff --git a/src/examples/docs/ex1.htm b/src/examples/docs/ex01.htm similarity index 100% rename from src/examples/docs/ex1.htm rename to src/examples/docs/ex01.htm diff --git a/src/examples/docs/ex2.htm b/src/examples/docs/ex02.htm similarity index 100% rename from src/examples/docs/ex2.htm rename to src/examples/docs/ex02.htm diff --git a/src/examples/docs/ex3.htm b/src/examples/docs/ex03.htm similarity index 100% rename from src/examples/docs/ex3.htm rename to src/examples/docs/ex03.htm diff --git a/src/examples/docs/ex4.htm b/src/examples/docs/ex04.htm similarity index 100% rename from src/examples/docs/ex4.htm rename to src/examples/docs/ex04.htm diff --git a/src/examples/docs/ex5.htm b/src/examples/docs/ex05.htm similarity index 100% rename from src/examples/docs/ex5.htm rename to src/examples/docs/ex05.htm diff --git a/src/examples/docs/ex5big.htm b/src/examples/docs/ex05big.htm similarity index 100% rename from src/examples/docs/ex5big.htm rename to src/examples/docs/ex05big.htm diff --git a/src/examples/docs/ex5f.htm b/src/examples/docs/ex05f.htm similarity index 100% rename from src/examples/docs/ex5f.htm rename to src/examples/docs/ex05f.htm diff --git a/src/examples/docs/ex6.htm b/src/examples/docs/ex06.htm similarity index 100% rename from src/examples/docs/ex6.htm rename to src/examples/docs/ex06.htm diff --git a/src/examples/docs/ex7.htm b/src/examples/docs/ex07.htm similarity index 100% rename from src/examples/docs/ex7.htm rename to src/examples/docs/ex07.htm diff --git a/src/examples/docs/ex8.htm b/src/examples/docs/ex08.htm similarity index 100% rename from src/examples/docs/ex8.htm rename to src/examples/docs/ex08.htm diff --git a/src/examples/docs/ex9.htm b/src/examples/docs/ex09.htm similarity index 100% rename from src/examples/docs/ex9.htm rename to src/examples/docs/ex09.htm diff --git a/src/examples/docs/flexgmres-amg.htm b/src/examples/docs/flexgmres-amg.htm index 5ebc9af846..61dce217e1 100644 --- a/src/examples/docs/flexgmres-amg.htm +++ b/src/examples/docs/flexgmres-amg.htm @@ -3,7 +3,7 @@Flexible GMRES-AMG Example Codes
- +diff --git a/src/examples/docs/gmres-amg.htm b/src/examples/docs/gmres-amg.htm index 8795117c79..c0ab94f408 100644 --- a/src/examples/docs/gmres-amg.htm +++ b/src/examples/docs/gmres-amg.htm @@ -3,7 +3,7 @@GMRES-AMG Example Codes
- +diff --git a/src/examples/docs/gmres-pfmg.htm b/src/examples/docs/gmres-pfmg.htm index 0f0ae15f20..3369896ba8 100644 --- a/src/examples/docs/gmres-pfmg.htm +++ b/src/examples/docs/gmres-pfmg.htm @@ -3,8 +3,8 @@GMRES-PFMG Example Codes
- - + +diff --git a/src/examples/docs/gmres-smg.htm b/src/examples/docs/gmres-smg.htm index 66106b5dd5..3d8b25228c 100644 --- a/src/examples/docs/gmres-smg.htm +++ b/src/examples/docs/gmres-smg.htm @@ -3,8 +3,8 @@GMRES-SMG Example Codes
- - + +diff --git a/src/examples/docs/gmres-syspfmg.htm b/src/examples/docs/gmres-syspfmg.htm index f66b4f34a5..00b7c0f8c2 100644 --- a/src/examples/docs/gmres-syspfmg.htm +++ b/src/examples/docs/gmres-syspfmg.htm @@ -3,7 +3,7 @@GMRES-SysPFMG Example Codes
- +diff --git a/src/examples/docs/ij.htm b/src/examples/docs/ij.htm index 39f51bfaf6..cf9b598f92 100644 --- a/src/examples/docs/ij.htm +++ b/src/examples/docs/ij.htm @@ -3,7 +3,7 @@IJ Interface Example Codes
- +diff --git a/src/examples/docs/index.htm b/src/examples/docs/index.htm index 0ce58cf18c..15ecd1828e 100644 --- a/src/examples/docs/index.htm +++ b/src/examples/docs/index.htm @@ -77,17 +77,17 @@Programming language
All example codes
-
- Example 1: the simplest Struct example
-- Example 2: a simple two processor Struct example
-- Example 3: a Struct solver for the 5-pt discretization of the 2D Laplace equation
-- Example 4: several Struct solvers for a variable coefficient 2D Convection-Reaction-Diffusion equation
-- Example 5: unstructured solvers for the 5-pt discretization of the 2D Laplace equation
-- Example 5big: a 64-bit version of Example 5
-- Example 5f: Fortran version of Example 5
-- Example 6: a simple two processor SStruct example
-- Example 7: several SStruct solvers for a variable coefficient 2D Convection-Reaction-Diffusion equation
-- Example 8: two processor SStruct example with multiple parts
-- Example 9: a SStruct example for the biharmonic problem treated as a system of equations
+- Example 1: the simplest Struct example
+- Example 2: a simple two processor Struct example
+- Example 3: a Struct solver for the 5-pt discretization of the 2D Laplace equation
+- Example 4: several Struct solvers for a variable coefficient 2D Convection-Reaction-Diffusion equation
+- Example 5: unstructured solvers for the 5-pt discretization of the 2D Laplace equation
+- Example 5big: a 64-bit version of Example 5
+- Example 5f: Fortran version of Example 5
+- Example 6: a simple two processor SStruct example
+- Example 7: several SStruct solvers for a variable coefficient 2D Convection-Reaction-Diffusion equation
+- Example 8: two processor SStruct example with multiple parts
+- Example 9: a SStruct example for the biharmonic problem treated as a system of equations
- Example 10: FEI example with bilinear finite elements for the 2D Laplace equation
- Example 11: eigensolver for the 5-pt discretization of the 2D Laplace equation
- Example 12: nodal version of Example 1
diff --git a/src/examples/docs/pcg-amg.htm b/src/examples/docs/pcg-amg.htm index 641f2d94ca..28862eb41b 100644 --- a/src/examples/docs/pcg-amg.htm +++ b/src/examples/docs/pcg-amg.htm @@ -3,7 +3,7 @@PCG-AMG Example Codes
- + diff --git a/src/examples/docs/pcg-parasails.htm b/src/examples/docs/pcg-parasails.htm index 542b827a08..be40d0a4f4 100644 --- a/src/examples/docs/pcg-parasails.htm +++ b/src/examples/docs/pcg-parasails.htm @@ -3,7 +3,7 @@PCG-ParaSails Example Codes
- +diff --git a/src/examples/docs/pcg-pfmg.htm b/src/examples/docs/pcg-pfmg.htm index a13dc86234..0a827523ef 100644 --- a/src/examples/docs/pcg-pfmg.htm +++ b/src/examples/docs/pcg-pfmg.htm @@ -3,8 +3,8 @@PCG-PFMG Example Codes
- - + +diff --git a/src/examples/docs/pcg-smg.htm b/src/examples/docs/pcg-smg.htm index d728d14f7d..1ea0584b86 100644 --- a/src/examples/docs/pcg-smg.htm +++ b/src/examples/docs/pcg-smg.htm @@ -3,11 +3,11 @@PCG-SMG Example Codes
- - - - - + + + + +diff --git a/src/examples/docs/pcg-split-smg.htm b/src/examples/docs/pcg-split-smg.htm index ea0739ad7b..5a67691667 100644 --- a/src/examples/docs/pcg-split-smg.htm +++ b/src/examples/docs/pcg-split-smg.htm @@ -3,7 +3,7 @@ PCG-split-SMG Example Codes
- +diff --git a/src/examples/docs/pcg.htm b/src/examples/docs/pcg.htm index f632fdc44c..f3c8a05d3f 100644 --- a/src/examples/docs/pcg.htm +++ b/src/examples/docs/pcg.htm @@ -3,10 +3,10 @@CG Example Codes
- - - - + + + +diff --git a/src/examples/docs/pfmg.htm b/src/examples/docs/pfmg.htm index ec9276035a..473c84542a 100644 --- a/src/examples/docs/pfmg.htm +++ b/src/examples/docs/pfmg.htm @@ -3,8 +3,8 @@PFMG Example Codes
- - + +diff --git a/src/examples/docs/smg.htm b/src/examples/docs/smg.htm index 05ff12bdbf..fdc87d7248 100644 --- a/src/examples/docs/smg.htm +++ b/src/examples/docs/smg.htm @@ -3,9 +3,9 @@SMG Example Codes
- - - + + +diff --git a/src/examples/docs/sstruct.htm b/src/examples/docs/sstruct.htm index 7ea585335d..1fba97912a 100644 --- a/src/examples/docs/sstruct.htm +++ b/src/examples/docs/sstruct.htm @@ -3,10 +3,10 @@SStruct Interface Example Codes
- - - - + + + + diff --git a/src/examples/docs/struct.htm b/src/examples/docs/struct.htm index b7927ffbe1..5621dc604f 100644 --- a/src/examples/docs/struct.htm +++ b/src/examples/docs/struct.htm @@ -3,10 +3,10 @@Struct Interface Example Codes
- - - - + + + +diff --git a/src/examples/docs/syspfmg.htm b/src/examples/docs/syspfmg.htm index 246b1b4a03..23fed63543 100644 --- a/src/examples/docs/syspfmg.htm +++ b/src/examples/docs/syspfmg.htm @@ -3,7 +3,7 @@SysPFMG Example Codes
- +diff --git a/src/examples/ex.h b/src/examples/ex.h index 8b2324c170..3786430df8 100644 --- a/src/examples/ex.h +++ b/src/examples/ex.h @@ -14,13 +14,18 @@ #include-#if defined(HYPRE_EXAMPLE_USING_CUDA) - -#include - +#if defined(HYPRE_EXAMPLE_USING_CUDA) || defined(HYPRE_EXAMPLE_USING_HIP) #ifndef HYPRE_USING_UNIFIED_MEMORY #error *** Running the examples on GPUs requires Unified Memory. Please reconfigure and rebuild with --enable-unified-memory *** #endif +#define custom_malloc(size) gpu_malloc(size) +#define custom_calloc(num, size) gpu_calloc(num, size) +#define custom_free(ptr) gpu_free((void**) &(ptr)) +#endif + +#if defined(HYPRE_EXAMPLE_USING_CUDA) + +#include static inline void* gpu_malloc(size_t size) @@ -39,9 +44,47 @@ gpu_calloc(size_t num, size_t size) return ptr; } -#define malloc(size) gpu_malloc(size) -#define calloc(num, size) gpu_calloc(num, size) -#define free(ptr) ( cudaFree(ptr), ptr = NULL ) -#endif /* #if defined(HYPRE_EXAMPLE_USING_CUDA) */ -#endif /* #ifndef HYPRE_EXAMPLES_INCLUDES */ +static inline void +gpu_free(void** ptr) +{ + cudaFree(*ptr); + *ptr = NULL; +} + +#elif defined(HYPRE_EXAMPLE_USING_HIP) + +#include + +static inline void* +gpu_malloc(size_t size) +{ + void *ptr = NULL; + hipMallocManaged(&ptr, size, hipMemAttachGlobal); + return ptr; +} + +static inline void* +gpu_calloc(size_t num, size_t size) +{ + void *ptr = NULL; + hipMallocManaged(&ptr, num * size, hipMemAttachGlobal); + hipMemset(ptr, 0, num * size); + return ptr; +} + +static inline void +gpu_free(void** ptr) +{ + hipFree(*ptr); + *ptr = NULL; +} + +#else + +/* Host: Default malloc, calloc, and free */ +#define custom_malloc(size) malloc(size) +#define custom_calloc(num, size) calloc(num, size) +#define custom_free(ptr) (free(ptr), ptr = NULL) +#endif +#endif /* #ifdef HYPRE_EXAMPLES_INCLUDES */ diff --git a/src/examples/ex1.c b/src/examples/ex01.c similarity index 91% rename from src/examples/ex1.c rename to src/examples/ex01.c index 4014768d06..6050fff49d 100644 --- a/src/examples/ex1.c +++ b/src/examples/ex01.c @@ -10,9 +10,9 @@ Interface: Structured interface (Struct) - Compile with: make ex1 (may need to edit HYPRE_DIR in Makefile) + Compile with: make ex01 (may need to edit HYPRE_DIR in Makefile) - Sample run: mpirun -np 2 ex1 + Sample run: mpirun -np 2 ex01 Description: This is a two processor example. Each processor owns one box in the grid. For reference, the two grid boxes are those @@ -32,7 +32,7 @@ /* Struct linear solvers header */ #include "HYPRE_struct_ls.h" -#include "ex.h" +#include "ex.h" /* custom_malloc, custom_calloc, custom_free */ #ifdef HYPRE_EXVIS #include "vis.c" @@ -174,7 +174,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 30; /* 6 grid points, each with 5 stencil entries */ /* double values[30]; OK to use constant-length arrays for CPUs */ - double *values = (double *) malloc(30 * sizeof(double)); + double *values = (double *) custom_malloc(30 * sizeof(double)); /* We have 6 grid points, each with 5 stencil entries */ for (i = 0; i < nvalues; i += nentries) @@ -189,7 +189,7 @@ int main (int argc, char *argv[]) HYPRE_StructMatrixSetBoxValues(A, ilower, iupper, nentries, stencil_indices, values); - free(values); + custom_free(values); } else if (myid == 1) { @@ -198,7 +198,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 60; /* 12 grid points, each with 5 stencil entries */ /* double values[60]; OK to use constant-length arrays for CPUs */ - double *values = (double *) malloc(60 * sizeof(double)); + double *values = (double *) custom_malloc(60 * sizeof(double)); for (i = 0; i < nvalues; i += nentries) { @@ -212,14 +212,14 @@ int main (int argc, char *argv[]) HYPRE_StructMatrixSetBoxValues(A, ilower, iupper, nentries, stencil_indices, values); - free(values); + custom_free(values); } /* Set the coefficients reaching outside of the boundary to 0 */ if (myid == 0) { /* double values[3]; OK to use constant-length arrays for CPUs */ - double *values = (double *) malloc(3 * sizeof(double)); + double *values = (double *) custom_malloc(3 * sizeof(double)); for (i = 0; i < 3; i++) { values[i] = 0.0; @@ -245,12 +245,12 @@ int main (int argc, char *argv[]) HYPRE_StructMatrixSetBoxValues(A, ilower, iupper, 1, stencil_indices, values); } - free(values); + custom_free(values); } else if (myid == 1) { /* double values[4]; OK to use constant-length arrays for CPUs */ - double *values = (double *) malloc(4 * sizeof(double)); + double *values = (double *) custom_malloc(4 * sizeof(double)); for (i = 0; i < 4; i++) { values[i] = 0.0; @@ -284,7 +284,7 @@ int main (int argc, char *argv[]) HYPRE_StructMatrixSetBoxValues(A, ilower, iupper, 1, stencil_indices, values); } - free(values); + custom_free(values); } /* This is a collective call finalizing the matrix assembly. @@ -308,7 +308,7 @@ int main (int argc, char *argv[]) { int ilower[2] = {-3, 1}, iupper[2] = {-1, 2}; /* double values[6]; OK to use constant-length arrays for CPUs */ - double *values = (double *) malloc(6 * sizeof(double)); /* 6 grid points */ + double *values = (double *) custom_malloc(6 * sizeof(double)); /* 6 grid points */ for (i = 0; i < 6; i ++) { @@ -321,13 +321,13 @@ int main (int argc, char *argv[]) values[i] = 0.0; } HYPRE_StructVectorSetBoxValues(x, ilower, iupper, values); - free(values); + custom_free(values); } else if (myid == 1) { int ilower[2] = {0, 1}, iupper[2] = {2, 4}; /* double values[12]; OK to use constant-length arrays for CPUs */ - double *values = (double *) malloc(12 * sizeof(double)); /* 12 grid points */ + double *values = (double *) custom_malloc(12 * sizeof(double)); /* 12 grid points */ for (i = 0; i < 12; i ++) { @@ -340,7 +340,7 @@ int main (int argc, char *argv[]) values[i] = 0.0; } HYPRE_StructVectorSetBoxValues(x, ilower, iupper, values); - free(values); + custom_free(values); } /* This is a collective call finalizing the vector assembly. @@ -364,13 +364,13 @@ int main (int argc, char *argv[]) HYPRE_StructPCGSolve(solver, A, b, x); } - /* Save the solution for GLVis visualization, see vis/glvis-ex1.sh */ + /* Save the solution for GLVis visualization, see vis/glvis-ex01.sh */ if (vis) { #ifdef HYPRE_EXVIS - GLVis_PrintStructGrid(grid, "vis/ex1.mesh", myid, NULL, NULL); - GLVis_PrintStructVector(x, "vis/ex1.sol", myid); - GLVis_PrintData("vis/ex1.data", myid, num_procs); + GLVis_PrintStructGrid(grid, "vis/ex01.mesh", myid, NULL, NULL); + GLVis_PrintStructVector(x, "vis/ex01.sol", myid); + GLVis_PrintData("vis/ex01.data", myid, num_procs); #endif } diff --git a/src/examples/ex2.c b/src/examples/ex02.c similarity index 92% rename from src/examples/ex2.c rename to src/examples/ex02.c index 3e80377cad..a0ddffbbd3 100644 --- a/src/examples/ex2.c +++ b/src/examples/ex02.c @@ -10,9 +10,9 @@ Interface: Structured interface (Struct) - Compile with: make ex2 + Compile with: make ex02 - Sample run: mpirun -np 2 ex2 + Sample run: mpirun -np 2 ex02 Description: This is a two processor example and is similar to the previous structured interface example (Example 1). However, in @@ -31,7 +31,7 @@ /* Struct linear solvers header */ #include "HYPRE_struct_ls.h" -#include "ex.h" +#include "ex.h" /* custom_malloc, custom_calloc, custom_free */ #ifdef HYPRE_EXVIS #include "vis.c" @@ -192,7 +192,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 30; /* 6 grid points, each with 5 stencil entries */ /* double values[30]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(30 * sizeof(double)); + double *values = (double *) custom_malloc(30 * sizeof(double)); int stencil_indices[5]; for (j = 0; j < nentries; j++) /* label the stencil indices - @@ -214,7 +214,7 @@ int main (int argc, char *argv[]) HYPRE_StructMatrixSetBoxValues(A, ilower, iupper, nentries, stencil_indices, values); - free(values); + custom_free(values); } /* Set the matrix coefficients for some set of stencil entries @@ -226,7 +226,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 60; /* 12 grid points, each with 5 stencil entries */ /* double values[60]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(60 * sizeof(double)); + double *values = (double *) custom_malloc(60 * sizeof(double)); int stencil_indices[5]; for (j = 0; j < nentries; j++) @@ -246,7 +246,7 @@ int main (int argc, char *argv[]) HYPRE_StructMatrixSetBoxValues(A, ilower, iupper, nentries, stencil_indices, values); - free(values); + custom_free(values); } } else if (myid == 1) @@ -260,7 +260,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 80; /* 16 grid points, each with 5 stencil entries */ /* double values[80]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(80 * sizeof(double)); + double *values = (double *) custom_malloc(80 * sizeof(double)); int stencil_indices[5]; for (j = 0; j < nentries; j++) @@ -280,7 +280,7 @@ int main (int argc, char *argv[]) HYPRE_StructMatrixSetBoxValues(A, ilower, iupper, nentries, stencil_indices, values); - free(values); + custom_free(values); } } @@ -290,7 +290,7 @@ int main (int argc, char *argv[]) { int maxnvalues = 6; /* double values[6]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(6 * sizeof(double)); + double *values = (double *) custom_malloc(6 * sizeof(double)); for (i = 0; i < maxnvalues; i++) { @@ -353,13 +353,13 @@ int main (int argc, char *argv[]) stencil_indices, values); } - free(values); + custom_free(values); } else if (myid == 1) { int maxnvalues = 4; /* double values[4]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(4 * sizeof(double)); + double *values = (double *) custom_malloc(4 * sizeof(double)); for (i = 0; i < maxnvalues; i++) { @@ -399,7 +399,7 @@ int main (int argc, char *argv[]) stencil_indices, values); } - free(values); + custom_free(values); } /* This is a collective call finalizing the matrix assembly. @@ -426,7 +426,7 @@ int main (int argc, char *argv[]) int nvalues = 6; /* 6 grid points */ /* double values[6]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(6 * sizeof(double)); + double *values = (double *) custom_malloc(6 * sizeof(double)); for (i = 0; i < nvalues; i ++) { @@ -440,7 +440,7 @@ int main (int argc, char *argv[]) } HYPRE_StructVectorSetBoxValues(x, ilower, iupper, values); - free(values); + custom_free(values); } /* Set the vector coefficients over the gridpoints in my second box */ @@ -450,7 +450,7 @@ int main (int argc, char *argv[]) int nvalues = 12; /* 12 grid points */ /* double values[12]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(12 * sizeof(double)); + double *values = (double *) custom_malloc(12 * sizeof(double)); for (i = 0; i < nvalues; i ++) { @@ -464,7 +464,7 @@ int main (int argc, char *argv[]) } HYPRE_StructVectorSetBoxValues(x, ilower, iupper, values); - free(values); + custom_free(values); } } else if (myid == 1) @@ -476,7 +476,7 @@ int main (int argc, char *argv[]) int nvalues = 16; /* 16 grid points */ /* double values[16]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(16 * sizeof(double)); + double *values = (double *) custom_malloc(16 * sizeof(double)); for (i = 0; i < nvalues; i ++) { @@ -490,7 +490,7 @@ int main (int argc, char *argv[]) } HYPRE_StructVectorSetBoxValues(x, ilower, iupper, values); - free(values); + custom_free(values); } } @@ -527,13 +527,13 @@ int main (int argc, char *argv[]) HYPRE_StructPCGSolve(solver, A, b, x); } - /* Save the solution for GLVis visualization, see vis/glvis-ex2.sh */ + /* Save the solution for GLVis visualization, see vis/glvis-ex02.sh */ if (vis) { #ifdef HYPRE_EXVIS - GLVis_PrintStructGrid(grid, "vis/ex2.mesh", myid, NULL, NULL); - GLVis_PrintStructVector(x, "vis/ex2.sol", myid); - GLVis_PrintData("vis/ex2.data", myid, num_procs); + GLVis_PrintStructGrid(grid, "vis/ex02.mesh", myid, NULL, NULL); + GLVis_PrintStructVector(x, "vis/ex02.sol", myid); + GLVis_PrintData("vis/ex02.data", myid, num_procs); #endif } diff --git a/src/examples/ex3.c b/src/examples/ex03.c similarity index 95% rename from src/examples/ex3.c rename to src/examples/ex03.c index 9b4596bc1f..65802ff3fc 100644 --- a/src/examples/ex3.c +++ b/src/examples/ex03.c @@ -10,11 +10,11 @@ Interface: Structured interface (Struct) - Compile with: make ex3 + Compile with: make ex03 - Sample run: mpirun -np 16 ex3 -n 33 -solver 0 -v 1 1 + Sample run: mpirun -np 16 ex03 -n 33 -solver 0 -v 1 1 - To see options: ex3 -help + To see options: ex03 -help Description: This code solves a system corresponding to a discretization of the Laplace equation -Delta u = 1 with zero boundary @@ -48,7 +48,7 @@ #include #include #include "HYPRE_struct_ls.h" -#include "ex.h" +#include "ex.h" /* custom_malloc, custom_calloc, custom_free */ #ifdef HYPRE_EXVIS #include "vis.c" @@ -218,7 +218,7 @@ int main (int argc, char *argv[]) /* Indicate that the matrix coefficients are ready to be set */ HYPRE_StructMatrixInitialize(A); - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); for (j = 0; j < nentries; j++) { @@ -239,7 +239,7 @@ int main (int argc, char *argv[]) HYPRE_StructMatrixSetBoxValues(A, ilower, iupper, nentries, stencil_indices, values); - free(values); + custom_free(values); } /* 4. Incorporate the zero boundary conditions: go along each edge of @@ -254,7 +254,7 @@ int main (int argc, char *argv[]) double *values; int stencil_indices[1]; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); for (j = 0; j < nvalues; j++) { values[j] = 0.0; @@ -321,7 +321,7 @@ int main (int argc, char *argv[]) stencil_indices, values); } - free(values); + custom_free(values); } /* This is a collective call finalizing the matrix assembly. @@ -333,7 +333,7 @@ int main (int argc, char *argv[]) int nvalues = n * n; double *values; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); /* Create an empty vector object */ HYPRE_StructVectorCreate(MPI_COMM_WORLD, grid, &b); @@ -356,7 +356,7 @@ int main (int argc, char *argv[]) } HYPRE_StructVectorSetBoxValues(x, ilower, iupper, values); - free(values); + custom_free(values); /* This is a collective call finalizing the vector assembly. The vector is now ``ready to be used'' */ @@ -424,7 +424,7 @@ int main (int argc, char *argv[]) HYPRE_StructSMGDestroy(solver); } - /* Save the solution for GLVis visualization, see vis/glvis-ex3.sh */ + /* Save the solution for GLVis visualization, see vis/glvis-ex03.sh */ if (vis) { #ifdef HYPRE_EXVIS @@ -432,12 +432,12 @@ int main (int argc, char *argv[]) char filename[255]; int k, nvalues = n * n; - double *values = (double*) calloc(nvalues, sizeof(double)); + double *values = (double*) custom_calloc(nvalues, sizeof(double)); /* get the local solution */ HYPRE_StructVectorGetBoxValues(x, ilower, iupper, values); - sprintf(filename, "%s.%06d", "vis/ex3.sol", myid); + sprintf(filename, "%s.%06d", "vis/ex03.sol", myid); if ((file = fopen(filename, "w")) == NULL) { printf("Error: can't open output file %s\n", filename); @@ -455,12 +455,12 @@ int main (int argc, char *argv[]) fflush(file); fclose(file); - free(values); + custom_free(values); /* save global finite element mesh */ if (myid == 0) { - GLVis_PrintGlobalSquareMesh("vis/ex3.mesh", N * n - 1); + GLVis_PrintGlobalSquareMesh("vis/ex03.mesh", N * n - 1); } #endif } diff --git a/src/examples/ex4.c b/src/examples/ex04.c similarity index 97% rename from src/examples/ex4.c rename to src/examples/ex04.c index 202f0278bd..c15128b3c9 100644 --- a/src/examples/ex4.c +++ b/src/examples/ex04.c @@ -10,11 +10,11 @@ Interface: Structured interface (Struct) - Compile with: make ex4 + Compile with: make ex04 - Sample run: mpirun -np 16 ex4 -n 33 -solver 10 -K 3 -B 0 -C 1 -U0 2 -F 4 + Sample run: mpirun -np 16 ex04 -n 33 -solver 10 -K 3 -B 0 -C 1 -U0 2 -F 4 - To see options: ex4 -help + To see options: ex04 -help Description: This example differs from the previous structured example (Example 3) in that a more sophisticated stencil and @@ -58,7 +58,7 @@ #include #include "HYPRE_krylov.h" #include "HYPRE_struct_ls.h" -#include "ex.h" +#include "ex.h" /* custom_malloc, custom_calloc, custom_free */ #ifdef M_PI #define PI M_PI @@ -111,6 +111,8 @@ double K(double x, double y) /* Convection vector, first component */ double B1(double x, double y) { + (void) x; + (void) y; switch (optionB) { case 0: @@ -129,6 +131,8 @@ double B1(double x, double y) /* Convection vector, second component */ double B2(double x, double y) { + (void) x; + (void) y; switch (optionB) { case 0: @@ -147,6 +151,8 @@ double B2(double x, double y) /* Reaction coefficient */ double C(double x, double y) { + (void) x; + (void) y; switch (optionC) { case 0: @@ -475,7 +481,7 @@ int main (int argc, char *argv[]) HYPRE_StructVectorInitialize(b); HYPRE_StructVectorInitialize(x); - values = (double*) calloc((n * n), sizeof(double)); + values = (double*) custom_calloc((n * n), sizeof(double)); /* Set the values of b in left-to-right, bottom-to-top order */ for (k = 0, j = 0; j < n; j++) @@ -492,7 +498,7 @@ int main (int argc, char *argv[]) } HYPRE_StructVectorSetBoxValues(x, ilower, iupper, values); - free(values); + custom_free(values); /* Assembling is postponed since the vectors will be further modified */ } @@ -516,7 +522,7 @@ int main (int argc, char *argv[]) to the offsets */ double *values; - values = (double*) calloc(5 * (n * n), sizeof(double)); + values = (double*) custom_calloc(5 * (n * n), sizeof(double)); /* The order is left-to-right, bottom-to-top */ for (k = 0, j = 0; j < n; j++) @@ -540,14 +546,14 @@ int main (int argc, char *argv[]) HYPRE_StructMatrixSetBoxValues(A, ilower, iupper, 5, stencil_indices, values); - free(values); + custom_free(values); } else /* Symmetric storage */ { int stencil_indices[3] = {0, 1, 2}; double *values; - values = (double*) calloc(3 * (n * n), sizeof(double)); + values = (double*) custom_calloc(3 * (n * n), sizeof(double)); /* The order is left-to-right, bottom-to-top */ for (k = 0, j = 0; j < n; j++) @@ -563,7 +569,7 @@ int main (int argc, char *argv[]) HYPRE_StructMatrixSetBoxValues(A, ilower, iupper, 3, stencil_indices, values); - free(values); + custom_free(values); } } @@ -587,8 +593,8 @@ int main (int argc, char *argv[]) nentries = 3; } - values = (double*) calloc(nentries * n, sizeof(double)); - bvalues = (double*) calloc(n, sizeof(double)); + values = (double*) custom_calloc(nentries * n, sizeof(double)); + bvalues = (double*) custom_calloc(n, sizeof(double)); /* The stencil at the boundary nodes is 1-0-0-0-0. Because we have I x_b = u_0; */ @@ -872,8 +878,8 @@ int main (int argc, char *argv[]) HYPRE_StructVectorAddToBoxValues(b, bc_ilower, bc_iupper, bvalues); } - free(values); - free(bvalues); + custom_free(values); + custom_free(bvalues); } /* Finalize the vector and matrix assembly */ @@ -1211,7 +1217,7 @@ int main (int argc, char *argv[]) } } - /* Save the solution for GLVis visualization, see vis/glvis-ex4.sh */ + /* Save the solution for GLVis visualization, see vis/glvis-ex04.sh */ if (vis) { #ifdef HYPRE_EXVIS @@ -1219,12 +1225,12 @@ int main (int argc, char *argv[]) char filename[255]; int nvalues = n * n; - double *values = (double*) calloc(nvalues, sizeof(double)); + double *values = (double*) custom_calloc(nvalues, sizeof(double)); /* get the local solution */ HYPRE_StructVectorGetBoxValues(x, ilower, iupper, values); - sprintf(filename, "%s.%06d", "vis/ex4.sol", myid); + sprintf(filename, "%s.%06d", "vis/ex04.sol", myid); if ((file = fopen(filename, "w")) == NULL) { printf("Error: can't open output file %s\n", filename); @@ -1242,12 +1248,12 @@ int main (int argc, char *argv[]) fflush(file); fclose(file); - free(values); + custom_free(values); /* save global finite element mesh */ if (myid == 0) { - GLVis_PrintGlobalSquareMesh("vis/ex4.mesh", N * n - 1); + GLVis_PrintGlobalSquareMesh("vis/ex04.mesh", N * n - 1); } #endif } diff --git a/src/examples/ex5.c b/src/examples/ex05.c similarity index 95% rename from src/examples/ex5.c rename to src/examples/ex05.c index 7afa32ce79..dceb7283f2 100644 --- a/src/examples/ex5.c +++ b/src/examples/ex05.c @@ -10,9 +10,9 @@ Interface: Linear-Algebraic (IJ) - Compile with: make ex5 + Compile with: make ex05 - Sample run: mpirun -np 4 ex5 + Sample run: mpirun -np 4 ex05 Description: This example solves the 2-D Laplacian problem with zero boundary conditions on an n x n grid. The number of unknowns is N=n^2. @@ -30,7 +30,7 @@ #include "HYPRE_krylov.h" #include "HYPRE.h" #include "HYPRE_parcsr_ls.h" -#include "ex.h" +#include "ex.h" /* custom_malloc, custom_calloc, custom_free */ #ifdef HYPRE_EXVIS #include "vis.c" @@ -196,9 +196,9 @@ int main (int argc, char *argv[]) double values[5]; int cols[5]; */ - double *values = (double *) malloc(5 * sizeof(double)); - int *cols = (int *) malloc(5 * sizeof(int)); - int *tmp = (int *) malloc(2 * sizeof(int)); + double *values = (double *) custom_malloc(5 * sizeof(double)); + int *cols = (int *) custom_malloc(5 * sizeof(int)); + int *tmp = (int *) custom_malloc(2 * sizeof(int)); for (i = ilower; i <= iupper; i++) { @@ -247,9 +247,9 @@ int main (int argc, char *argv[]) HYPRE_IJMatrixSetValues(A, 1, &tmp[0], &tmp[1], cols, values); } - free(values); - free(cols); - free(tmp); + custom_free(values); + custom_free(cols); + custom_free(tmp); } /* Assemble after setting the coefficients */ @@ -287,9 +287,9 @@ int main (int argc, char *argv[]) double *rhs_values, *x_values; int *rows; - rhs_values = (double*) calloc(local_size, sizeof(double)); - x_values = (double*) calloc(local_size, sizeof(double)); - rows = (int*) calloc(local_size, sizeof(int)); + rhs_values = (double*) custom_calloc(local_size, sizeof(double)); + x_values = (double*) custom_calloc(local_size, sizeof(double)); + rows = (int*) custom_calloc(local_size, sizeof(int)); for (i = 0; i < local_size; i++) { @@ -301,9 +301,9 @@ int main (int argc, char *argv[]) HYPRE_IJVectorSetValues(b, local_size, rows, rhs_values); HYPRE_IJVectorSetValues(x, local_size, rows, x_values); - free(x_values); - free(rhs_values); - free(rows); + custom_free(x_values); + custom_free(rhs_values); + custom_free(rows); } @@ -575,7 +575,7 @@ int main (int argc, char *argv[]) if (myid == 0) { printf("Invalid solver id specified.\n"); } } - /* Save the solution for GLVis visualization, see vis/glvis-ex5.sh */ + /* Save the solution for GLVis visualization, see vis/glvis-ex05.sh */ if (vis) { #ifdef HYPRE_EXVIS @@ -583,8 +583,8 @@ int main (int argc, char *argv[]) char filename[255]; int nvalues = local_size; - int *rows = (int*) calloc(nvalues, sizeof(int)); - double *values = (double*) calloc(nvalues, sizeof(double)); + int *rows = (int*) custom_calloc(nvalues, sizeof(int)); + double *values = (double*) custom_calloc(nvalues, sizeof(double)); for (i = 0; i < nvalues; i++) { @@ -594,7 +594,7 @@ int main (int argc, char *argv[]) /* get the local solution */ HYPRE_IJVectorGetValues(x, nvalues, rows, values); - sprintf(filename, "%s.%06d", "vis/ex5.sol", myid); + sprintf(filename, "%s.%06d", "vis/ex05.sol", myid); if ((file = fopen(filename, "w")) == NULL) { printf("Error: can't open output file %s\n", filename); @@ -611,13 +611,13 @@ int main (int argc, char *argv[]) fflush(file); fclose(file); - free(rows); - free(values); + custom_free(rows); + custom_free(values); /* save global finite element mesh */ if (myid == 0) { - GLVis_PrintGlobalSquareMesh("vis/ex5.mesh", n - 1); + GLVis_PrintGlobalSquareMesh("vis/ex05.mesh", n - 1); } #endif } @@ -649,8 +649,7 @@ int main (int argc, char *argv[]) int hypre_FlexGMRESModifyPCAMGExample(void *precond_data, int iterations, double rel_residual_norm) { - - + (void) iterations; if (rel_residual_norm > .1) { HYPRE_BoomerAMGSetNumSweeps((HYPRE_Solver)precond_data, 10); @@ -660,6 +659,5 @@ int hypre_FlexGMRESModifyPCAMGExample(void *precond_data, int iterations, HYPRE_BoomerAMGSetNumSweeps((HYPRE_Solver)precond_data, 1); } - return 0; } diff --git a/src/examples/ex5big.c b/src/examples/ex05big.c similarity index 99% rename from src/examples/ex5big.c rename to src/examples/ex05big.c index 29bc872d4c..199d58075f 100644 --- a/src/examples/ex5big.c +++ b/src/examples/ex05big.c @@ -10,9 +10,9 @@ Interface: Linear-Algebraic (IJ) - Compile with: make ex5big + Compile with: make ex05big - Sample run: mpirun -np 4 ex5big + Sample run: mpirun -np 4 ex05big Description: This example is a slight modification of Example 5 that illustrates the 64-bit integer support in hypre needed to run diff --git a/src/examples/ex5cuf.cuf b/src/examples/ex05cuf.cuf similarity index 100% rename from src/examples/ex5cuf.cuf rename to src/examples/ex05cuf.cuf diff --git a/src/examples/ex5f.f b/src/examples/ex05f.f similarity index 100% rename from src/examples/ex5f.f rename to src/examples/ex05f.f diff --git a/src/examples/ex5f_cptr.f b/src/examples/ex05f_cptr.f similarity index 100% rename from src/examples/ex5f_cptr.f rename to src/examples/ex05f_cptr.f diff --git a/src/examples/ex6.c b/src/examples/ex06.c similarity index 94% rename from src/examples/ex6.c rename to src/examples/ex06.c index 14c5297730..46c1e6292e 100644 --- a/src/examples/ex6.c +++ b/src/examples/ex06.c @@ -10,9 +10,9 @@ Interface: Semi-Structured interface (SStruct) - Compile with: make ex6 + Compile with: make ex06 - Sample run: mpirun -np 2 ex6 + Sample run: mpirun -np 2 ex06 Description: This is a two processor example and is the same problem as is solved with the structured interface in Example 2. @@ -32,7 +32,7 @@ /* SStruct linear solvers headers */ #include "HYPRE_sstruct_ls.h" -#include "ex.h" +#include "ex.h" /* custom_malloc, custom_calloc, custom_free */ #ifdef HYPRE_EXVIS #include "vis.c" @@ -264,7 +264,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 30; /* 6 grid points, each with 5 stencil entries */ /* double values[30]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(30 * sizeof(double)); + double *values = (double *) custom_malloc(30 * sizeof(double)); int stencil_indices[5]; for (j = 0; j < nentries; j++) /* label the stencil indices - @@ -287,7 +287,7 @@ int main (int argc, char *argv[]) var, nentries, stencil_indices, values); - free(values); + custom_free(values); } /* Set the matrix coefficients for some set of stencil entries @@ -299,7 +299,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 60; /* 12 grid points, each with 5 stencil entries */ /* double values[60]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(60 * sizeof(double)); + double *values = (double *) custom_malloc(60 * sizeof(double)); int stencil_indices[5]; for (j = 0; j < nentries; j++) @@ -320,7 +320,7 @@ int main (int argc, char *argv[]) var, nentries, stencil_indices, values); - free(values); + custom_free(values); } } else if (myid == 1) @@ -334,7 +334,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 80; /* 16 grid points, each with 5 stencil entries */ /* double values[80]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(80 * sizeof(double)); + double *values = (double *) custom_malloc(80 * sizeof(double)); int stencil_indices[5]; for (j = 0; j < nentries; j++) @@ -355,7 +355,7 @@ int main (int argc, char *argv[]) var, nentries, stencil_indices, values); - free(values); + custom_free(values); } } @@ -365,7 +365,7 @@ int main (int argc, char *argv[]) { int maxnvalues = 6; /* double values[6]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(6 * sizeof(double)); + double *values = (double *) custom_malloc(6 * sizeof(double)); for (i = 0; i < maxnvalues; i++) { @@ -433,13 +433,13 @@ int main (int argc, char *argv[]) stencil_indices, values); } - free(values); + custom_free(values); } else if (myid == 1) { int maxnvalues = 4; /* double values[4]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(4 * sizeof(double)); + double *values = (double *) custom_malloc(4 * sizeof(double)); for (i = 0; i < maxnvalues; i++) { @@ -482,7 +482,7 @@ int main (int argc, char *argv[]) stencil_indices, values); } - free(values); + custom_free(values); } /* This is a collective call finalizing the matrix assembly. @@ -522,7 +522,7 @@ int main (int argc, char *argv[]) int nvalues = 6; /* 6 grid points */ /* double values[6]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(6 * sizeof(double)); + double *values = (double *) custom_malloc(6 * sizeof(double)); for (i = 0; i < nvalues; i ++) { @@ -536,7 +536,7 @@ int main (int argc, char *argv[]) } HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); } /* Set the vector coefficients over the gridpoints in my second box */ @@ -546,7 +546,7 @@ int main (int argc, char *argv[]) int nvalues = 12; /* 12 grid points */ /* double values[12]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(12 * sizeof(double)); + double *values = (double *) custom_malloc(12 * sizeof(double)); for (i = 0; i < nvalues; i ++) { @@ -560,7 +560,7 @@ int main (int argc, char *argv[]) } HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); } } else if (myid == 1) @@ -572,7 +572,7 @@ int main (int argc, char *argv[]) int nvalues = 16; /* 16 grid points */ /* double values[16]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(16 * sizeof(double)); + double *values = (double *) custom_malloc(16 * sizeof(double)); for (i = 0; i < nvalues; i ++) { @@ -586,7 +586,7 @@ int main (int argc, char *argv[]) } HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); } } @@ -634,13 +634,13 @@ int main (int argc, char *argv[]) HYPRE_StructPCGSolve(solver, sA, sb, sx); } - /* Save the solution for GLVis visualization, see vis/glvis-ex6.sh */ + /* Save the solution for GLVis visualization, see vis/glvis-ex06.sh */ if (vis) { #ifdef HYPRE_EXVIS - GLVis_PrintSStructGrid(grid, "vis/ex6.mesh", myid, NULL, NULL); - GLVis_PrintSStructVector(x, 0, "vis/ex6.sol", myid); - GLVis_PrintData("vis/ex6.data", myid, num_procs); + GLVis_PrintSStructGrid(grid, "vis/ex06.mesh", myid, NULL, NULL); + GLVis_PrintSStructVector(x, 0, "vis/ex06.sol", myid); + GLVis_PrintData("vis/ex06.data", myid, num_procs); #endif } diff --git a/src/examples/ex7.c b/src/examples/ex07.c similarity index 97% rename from src/examples/ex7.c rename to src/examples/ex07.c index a00344d568..b19d337f6c 100644 --- a/src/examples/ex7.c +++ b/src/examples/ex07.c @@ -10,11 +10,11 @@ Interface: SStructured interface (SStruct) - Compile with: make ex7 + Compile with: make ex07 - Sample run: mpirun -np 16 ex7 -n 33 -solver 10 -K 3 -B 0 -C 1 -U0 2 -F 4 + Sample run: mpirun -np 16 ex07 -n 33 -solver 10 -K 3 -B 0 -C 1 -U0 2 -F 4 - To see options: ex7 -help + To see options: ex07 -help Description: This example uses the sstruct interface to solve the same problem as was solved in Example 4 with the struct interface. @@ -52,7 +52,7 @@ #include #include "HYPRE_krylov.h" #include "HYPRE_sstruct_ls.h" -#include "ex.h" +#include "ex.h" /* custom_malloc, custom_calloc, custom_free */ #ifdef M_PI #define PI M_PI @@ -105,6 +105,8 @@ double K(double x, double y) /* Convection vector, first component */ double B1(double x, double y) { + (void) x; + (void) y; switch (optionB) { case 0: @@ -123,6 +125,8 @@ double B1(double x, double y) /* Convection vector, second component */ double B2(double x, double y) { + (void) x; + (void) y; switch (optionB) { case 0: @@ -141,6 +145,8 @@ double B2(double x, double y) /* Reaction coefficient */ double C(double x, double y) { + (void) x; + (void) y; switch (optionC) { case 0: @@ -533,7 +539,7 @@ int main (int argc, char *argv[]) HYPRE_SStructVectorInitialize(b); HYPRE_SStructVectorInitialize(x); - values = (double*) calloc((n * n), sizeof(double)); + values = (double*) custom_calloc((n * n), sizeof(double)); /* Set the values of b in left-to-right, bottom-to-top order */ for (k = 0, j = 0; j < n; j++) @@ -550,7 +556,7 @@ int main (int argc, char *argv[]) } HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); /* Assembling is postponed since the vectors will be further modified */ } @@ -584,7 +590,7 @@ int main (int argc, char *argv[]) to the offsets */ double *values; - values = (double*) calloc(5 * (n * n), sizeof(double)); + values = (double*) custom_calloc(5 * (n * n), sizeof(double)); /* The order is left-to-right, bottom-to-top */ for (k = 0, j = 0; j < n; j++) @@ -609,14 +615,14 @@ int main (int argc, char *argv[]) var, 5, stencil_indices, values); - free(values); + custom_free(values); } else /* Symmetric storage */ { int stencil_indices[3] = {0, 1, 2}; double *values; - values = (double*) calloc(3 * (n * n), sizeof(double)); + values = (double*) custom_calloc(3 * (n * n), sizeof(double)); /* The order is left-to-right, bottom-to-top */ for (k = 0, j = 0; j < n; j++) @@ -633,7 +639,7 @@ int main (int argc, char *argv[]) var, 3, stencil_indices, values); - free(values); + custom_free(values); } } @@ -662,8 +668,8 @@ int main (int argc, char *argv[]) nentries = 3; } - values = (double*) calloc(nentries * n, sizeof(double)); - bvalues = (double*) calloc(n, sizeof(double)); + values = (double*) custom_calloc(nentries * n, sizeof(double)); + bvalues = (double*) custom_calloc(n, sizeof(double)); /* The stencil at the boundary nodes is 1-0-0-0-0. Because we have I x_b = u_0; */ @@ -959,8 +965,8 @@ int main (int argc, char *argv[]) HYPRE_SStructVectorAddToBoxValues(b, part, bc_ilower, bc_iupper, var, bvalues); } - free(values); - free(bvalues); + custom_free(values); + custom_free(bvalues); } /* Finalize the vector and matrix assembly */ @@ -1312,7 +1318,7 @@ int main (int argc, char *argv[]) } - /* Save the solution for GLVis visualization, see vis/glvis-ex7.sh */ + /* Save the solution for GLVis visualization, see vis/glvis-ex07.sh */ if (vis) { #ifdef HYPRE_EXVIS @@ -1321,13 +1327,13 @@ int main (int argc, char *argv[]) int part = 0, var = 0; int nvalues = n * n; - double *values = (double*) calloc(nvalues, sizeof(double)); + double *values = (double*) custom_calloc(nvalues, sizeof(double)); /* get all local data (including a local copy of the shared values) */ HYPRE_SStructVectorGetBoxValues(x, part, ilower, iupper, var, values); - sprintf(filename, "%s.%06d", "vis/ex7.sol", myid); + sprintf(filename, "%s.%06d", "vis/ex07.sol", myid); if ((file = fopen(filename, "w")) == NULL) { printf("Error: can't open output file %s\n", filename); @@ -1345,12 +1351,12 @@ int main (int argc, char *argv[]) fflush(file); fclose(file); - free(values); + custom_free(values); /* save global finite element mesh */ if (myid == 0) { - GLVis_PrintGlobalSquareMesh("vis/ex7.mesh", N * n - 1); + GLVis_PrintGlobalSquareMesh("vis/ex07.mesh", N * n - 1); } #endif } diff --git a/src/examples/ex8.c b/src/examples/ex08.c similarity index 95% rename from src/examples/ex8.c rename to src/examples/ex08.c index c4ebd475a7..19152209da 100644 --- a/src/examples/ex8.c +++ b/src/examples/ex08.c @@ -10,9 +10,9 @@ Interface: Semi-Structured interface (SStruct) - Compile with: make ex8 + Compile with: make ex08 - Sample run: mpirun -np 2 ex8 + Sample run: mpirun -np 2 ex08 Description: This is a two processor example which solves a similar problem to the one in Example 2, and Example 6 (The grid @@ -31,7 +31,7 @@ /* SStruct linear solvers headers */ #include "HYPRE_sstruct_ls.h" -#include "ex.h" +#include "ex.h" /* custom_malloc, custom_calloc, custom_free */ #ifdef HYPRE_EXVIS #include "vis.c" @@ -382,7 +382,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 30; /* 6 grid points, each with 5 stencil entries */ /* double values[30]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(30 * sizeof(double)); + double *values = (double *) custom_malloc(30 * sizeof(double)); int stencil_indices[5]; for (j = 0; j < nentries; j++) /* label the stencil indices - @@ -406,7 +406,7 @@ int main (int argc, char *argv[]) var, nentries, stencil_indices, values); - free(values); + custom_free(values); } /* Set the matrix coefficients for some set of stencil entries @@ -418,7 +418,7 @@ int main (int argc, char *argv[]) int nentries = 9; int nvalues = 108; /* 12 grid points, each with 5 stencil entries */ /* double values[108]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(108 * sizeof(double)); + double *values = (double *) custom_malloc(108 * sizeof(double)); int stencil_indices[9]; for (j = 0; j < nentries; j++) @@ -440,7 +440,7 @@ int main (int argc, char *argv[]) var, nentries, stencil_indices, values); - free(values); + custom_free(values); } } else if (myid == 1) @@ -454,7 +454,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 80; /* 16 grid points, each with 5 stencil entries */ /* double values[80]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(80 * sizeof(double)); + double *values = (double *) custom_malloc(80 * sizeof(double)); int stencil_indices[5]; for (j = 0; j < nentries; j++) @@ -476,7 +476,7 @@ int main (int argc, char *argv[]) var, nentries, stencil_indices, values); - free(values); + custom_free(values); } } @@ -487,7 +487,7 @@ int main (int argc, char *argv[]) int nentries = 6; int nvalues = 24; /* 4 grid points, each with 6 stencil entries */ /* double values[24]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(24 * sizeof(double)); + double *values = (double *) custom_malloc(24 * sizeof(double)); part = 1; @@ -525,7 +525,7 @@ int main (int argc, char *argv[]) stencil_indices, values); } - free(values); + custom_free(values); } /* For each box, set any coefficients that reach ouside of the @@ -534,7 +534,7 @@ int main (int argc, char *argv[]) { int maxnvalues = 9; /* double values[9]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(9 * sizeof(double)); + double *values = (double *) custom_malloc(9 * sizeof(double)); for (i = 0; i < maxnvalues; i++) { @@ -618,13 +618,13 @@ int main (int argc, char *argv[]) stencil_indices, values); } - free(values); + custom_free(values); } else if (myid == 1) { int maxnvalues = 4; /* double values[4]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(4 * sizeof(double)); + double *values = (double *) custom_malloc(4 * sizeof(double)); for (i = 0; i < maxnvalues; i++) { @@ -669,7 +669,7 @@ int main (int argc, char *argv[]) stencil_indices, values); } - free(values); + custom_free(values); } /* This is a collective call finalizing the matrix assembly. @@ -706,7 +706,7 @@ int main (int argc, char *argv[]) int nvalues = 6; /* 6 grid points */ /* double values[6]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(6 * sizeof(double)); + double *values = (double *) custom_malloc(6 * sizeof(double)); part = 0; @@ -722,7 +722,7 @@ int main (int argc, char *argv[]) } HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); } /* Set the vector coefficients over the gridpoints in my second box */ @@ -732,7 +732,7 @@ int main (int argc, char *argv[]) int nvalues = 12; /* 12 grid points */ /* double values[12]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(12 * sizeof(double)); + double *values = (double *) custom_malloc(12 * sizeof(double)); part = 1; @@ -748,7 +748,7 @@ int main (int argc, char *argv[]) } HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); } } else if (myid == 1) @@ -760,7 +760,7 @@ int main (int argc, char *argv[]) int nvalues = 16; /* 16 grid points */ /* double values[16]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(16 * sizeof(double)); + double *values = (double *) custom_malloc(16 * sizeof(double)); part = 2; @@ -776,7 +776,7 @@ int main (int argc, char *argv[]) } HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); } } @@ -813,13 +813,13 @@ int main (int argc, char *argv[]) HYPRE_SStructPCGSolve(solver, A, b, x); } - /* Save the solution for GLVis visualization, see vis/glvis-ex8.sh */ + /* Save the solution for GLVis visualization, see vis/glvis-ex08.sh */ if (vis) { #ifdef HYPRE_EXVIS - GLVis_PrintSStructGrid(grid, "vis/ex8.mesh", myid, NULL, NULL); - GLVis_PrintSStructVector(x, 0, "vis/ex8.sol", myid); - GLVis_PrintData("vis/ex8.data", myid, num_procs); + GLVis_PrintSStructGrid(grid, "vis/ex08.mesh", myid, NULL, NULL); + GLVis_PrintSStructVector(x, 0, "vis/ex08.sol", myid); + GLVis_PrintData("vis/ex08.data", myid, num_procs); #endif } diff --git a/src/examples/ex9.c b/src/examples/ex09.c similarity index 95% rename from src/examples/ex9.c rename to src/examples/ex09.c index a21441e198..533cdc6f57 100644 --- a/src/examples/ex9.c +++ b/src/examples/ex09.c @@ -10,11 +10,11 @@ Interface: Semi-Structured interface (SStruct) - Compile with: make ex9 + Compile with: make ex09 - Sample run: mpirun -np 16 ex9 -n 33 -solver 0 -v 1 1 + Sample run: mpirun -np 16 ex09 -n 33 -solver 0 -v 1 1 - To see options: ex9 -help + To see options: ex09 -help Description: This code solves a system corresponding to a discretization of the biharmonic problem treated as a system of equations @@ -44,7 +44,7 @@ #include #include "HYPRE_sstruct_ls.h" #include "HYPRE_krylov.h" -#include "ex.h" +#include "ex.h" //* custom_malloc, custom_calloc, custom_free *// #ifdef HYPRE_EXVIS #include "vis.c" @@ -329,7 +329,7 @@ int main (int argc, char *argv[]) /* First the u-u connections */ nentries = 5; nvalues = nentries * n * n; - u_values = (double*) calloc(nvalues, sizeof(double)); + u_values = (double*) custom_calloc(nvalues, sizeof(double)); for (i = 0; i < nvalues; i += nentries) { @@ -343,12 +343,12 @@ int main (int argc, char *argv[]) HYPRE_SStructMatrixSetBoxValues(A, part, ilower, iupper, var, nentries, u_u_indices, u_values); - free(u_values); + custom_free(u_values); /* Next the u-v connections */ nentries = 1; nvalues = nentries * n * n; - u_values = (double*) calloc(nvalues, sizeof(double)); + u_values = (double*) custom_calloc(nvalues, sizeof(double)); for (i = 0; i < nvalues; i++) { @@ -359,7 +359,7 @@ int main (int argc, char *argv[]) var, nentries, u_v_indices, u_values); - free(u_values); + custom_free(u_values); } /* Now set the v-stencil entries */ @@ -373,7 +373,7 @@ int main (int argc, char *argv[]) /* the v-v connections */ nentries = 5; nvalues = nentries * n * n; - v_values = (double*) calloc(nvalues, sizeof(double)); + v_values = (double*) custom_calloc(nvalues, sizeof(double)); for (i = 0; i < nvalues; i += nentries) { @@ -388,7 +388,7 @@ int main (int argc, char *argv[]) var, nentries, v_v_indices, v_values); - free(v_values); + custom_free(v_values); /* There are no v-u connections to set */ } @@ -409,7 +409,7 @@ int main (int argc, char *argv[]) int part = 0; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); for (j = 0; j < nvalues; j++) { values[j] = 0.0; @@ -509,7 +509,7 @@ int main (int argc, char *argv[]) stencil_indices, values); } - free(values); + custom_free(values); } /* This is a collective call finalizing the matrix assembly. @@ -523,7 +523,7 @@ int main (int argc, char *argv[]) int part = 0; int var; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); /* Create an empty vector object */ HYPRE_SStructVectorCreate(MPI_COMM_WORLD, grid, &b); @@ -560,7 +560,7 @@ int main (int argc, char *argv[]) var = 1; HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); /* This is a collective call finalizing the vector assembly. The vector is now ``ready to be used'' */ @@ -671,7 +671,7 @@ int main (int argc, char *argv[]) HYPRE_BoomerAMGSetStrongThreshold(par_precond, 0.25); HYPRE_BoomerAMGSetTol(par_precond, 0.0); HYPRE_BoomerAMGSetPrintLevel(par_precond, 1); - HYPRE_BoomerAMGSetPrintFileName(par_precond, "ex9.out.log"); + HYPRE_BoomerAMGSetPrintFileName(par_precond, "ex09.out.log"); HYPRE_BoomerAMGSetMaxIter(par_precond, 1); /* set the preconditioner */ @@ -702,7 +702,7 @@ int main (int argc, char *argv[]) HYPRE_BoomerAMGSetStrongThreshold(par_solver, 0.25); HYPRE_BoomerAMGSetTol(par_solver, 1.9e-6); HYPRE_BoomerAMGSetPrintLevel(par_solver, 1); - HYPRE_BoomerAMGSetPrintFileName(par_solver, "ex9.out.log"); + HYPRE_BoomerAMGSetPrintFileName(par_solver, "ex09.out.log"); HYPRE_BoomerAMGSetMaxIter(par_solver, 50); /* do the setup */ @@ -740,14 +740,14 @@ int main (int argc, char *argv[]) int k, part = 0, var; int nvalues = n * n; - double *values = (double*) calloc(nvalues, sizeof(double)); + double *values = (double*) custom_calloc(nvalues, sizeof(double)); /* save local solution for variable u */ var = 0; HYPRE_SStructVectorGetBoxValues(x, part, ilower, iupper, var, values); - sprintf(filename, "%s.%06d", "vis/ex9-u.sol", myid); + sprintf(filename, "%s.%06d", "vis/ex09-u.sol", myid); if ((file = fopen(filename, "w")) == NULL) { printf("Error: can't open output file %s\n", filename); @@ -771,7 +771,7 @@ int main (int argc, char *argv[]) HYPRE_SStructVectorGetBoxValues(x, part, ilower, iupper, var, values); - sprintf(filename, "%s.%06d", "vis/ex9-v.sol", myid); + sprintf(filename, "%s.%06d", "vis/ex09-v.sol", myid); if ((file = fopen(filename, "w")) == NULL) { printf("Error: can't open output file %s\n", filename); @@ -790,12 +790,12 @@ int main (int argc, char *argv[]) fflush(file); fclose(file); - free(values); + custom_free(values); /* save global finite element mesh */ if (myid == 0) { - GLVis_PrintGlobalSquareMesh("vis/ex9.mesh", N * n - 1); + GLVis_PrintGlobalSquareMesh("vis/ex09.mesh", N * n - 1); } #endif } diff --git a/src/examples/ex10.cxx b/src/examples/ex10.cxx index 35ebff83f3..2363e41b47 100644 --- a/src/examples/ex10.cxx +++ b/src/examples/ex10.cxx @@ -33,7 +33,6 @@ #include #include "_hypre_utilities.h" #include "LLNL_FEI_Impl.h" -#include "ex.h" using namespace std; diff --git a/src/examples/ex11.c b/src/examples/ex11.c index dc432a5c39..91fb5c4347 100644 --- a/src/examples/ex11.c +++ b/src/examples/ex11.c @@ -31,7 +31,7 @@ #include "HYPRE.h" #include "HYPRE_parcsr_ls.h" #include "HYPRE_krylov.h" -#include "ex.h" +#include "ex.h" //* custom_malloc, custom_calloc, custom_free *// /* lobpcg stuff */ #include "HYPRE_lobpcg.h" @@ -179,8 +179,8 @@ int main (int argc, char *argv[]) int nnz; /* double values[5]; * int cols[5]; OK to use constant-length arrays for CPUs */ - double *values = (double *) malloc(5 * sizeof(double)); - int *cols = (int *) malloc(5 * sizeof(int)); + double *values = (double *) custom_malloc(5 * sizeof(double)); + int *cols = (int *) custom_malloc(5 * sizeof(int)); for (i = ilower; i <= iupper; i++) { @@ -227,8 +227,8 @@ int main (int argc, char *argv[]) HYPRE_IJMatrixSetValues(A, 1, &nnz, &i, cols, values); } - free(values); - free(cols); + custom_free(values); + custom_free(cols); } /* Assemble after setting the coefficients */ @@ -279,7 +279,7 @@ int main (int argc, char *argv[]) } /* define an interpreter for the ParCSR interface */ - interpreter = (mv_InterfaceInterpreter *) calloc(1, sizeof(mv_InterfaceInterpreter)); + interpreter = (mv_InterfaceInterpreter *) custom_calloc(1, sizeof(mv_InterfaceInterpreter)); HYPRE_ParCSRSetupInterpreter(interpreter); HYPRE_ParCSRSetupMatvec(&matvec_fn); @@ -289,7 +289,7 @@ int main (int argc, char *argv[]) mv_MultiVectorSetRandom (eigenvectors, lobpcgSeed); /* eigenvalues - allocate space */ - eigenvalues = (double*) calloc( blockSize, sizeof(double) ); + eigenvalues = (double*) custom_calloc( blockSize, sizeof(double) ); HYPRE_LOBPCGCreate(interpreter, &matvec_fn, &lobpcg_solver); HYPRE_LOBPCGSetMaxIter(lobpcg_solver, maxIterations); @@ -320,8 +320,8 @@ int main (int argc, char *argv[]) /* clean-up */ HYPRE_BoomerAMGDestroy(precond); HYPRE_LOBPCGDestroy(lobpcg_solver); - free(eigenvalues); - free(interpreter); + custom_free(eigenvalues); + custom_free(interpreter); } /* Save the solution for GLVis visualization, see vis/glvis-ex11.sh */ diff --git a/src/examples/ex12.c b/src/examples/ex12.c index b1d08940f7..0b4fb4abd5 100644 --- a/src/examples/ex12.c +++ b/src/examples/ex12.c @@ -34,7 +34,7 @@ #include "HYPRE_sstruct_ls.h" #include "HYPRE_parcsr_ls.h" #include "HYPRE_krylov.h" -#include "ex.h" +#include "ex.h" //* custom_malloc, custom_calloc, custom_free *// #ifdef HYPRE_EXVIS #include "vis.c" @@ -235,7 +235,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 60; /* 12 grid points, each with 5 stencil entries */ /* double values[60]; OK to use constant-length arrays for CPUs */ - double *values = (double *) malloc(60 * sizeof(double)); + double *values = (double *) custom_malloc(60 * sizeof(double)); for (i = 0; i < nvalues; i += nentries) { @@ -249,7 +249,7 @@ int main (int argc, char *argv[]) HYPRE_SStructMatrixSetBoxValues(A, part, ilower, iupper, var, nentries, stencil_indices, values); - free(values); + custom_free(values); } else if (myid == 1) { @@ -258,7 +258,7 @@ int main (int argc, char *argv[]) int nentries = 5; int nvalues = 100; /* 20 grid points, each with 5 stencil entries */ /* double values[100]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(100 * sizeof(double)); + double *values = (double *) custom_malloc(100 * sizeof(double)); for (i = 0; i < nvalues; i += nentries) { @@ -272,7 +272,7 @@ int main (int argc, char *argv[]) HYPRE_SStructMatrixSetBoxValues(A, part, ilower, iupper, var, nentries, stencil_indices, values); - free(values); + custom_free(values); } /* Set the coefficients reaching outside of the boundary to 0. Note that @@ -280,7 +280,7 @@ int main (int argc, char *argv[]) if (myid == 0) { /* double values[4]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(4 * sizeof(double)); + double *values = (double *) custom_malloc(4 * sizeof(double)); for (i = 0; i < 4; i++) { values[i] = 0.0; @@ -307,12 +307,12 @@ int main (int argc, char *argv[]) stencil_indices, values); } - free(values); + custom_free(values); } else if (myid == 1) { /* double values[5]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(5 * sizeof(double)); + double *values = (double *) custom_malloc(5 * sizeof(double)); for (i = 0; i < 5; i++) { values[i] = 0.0; @@ -347,7 +347,7 @@ int main (int argc, char *argv[]) stencil_indices, values); } - free(values); + custom_free(values); } /* This is a collective call finalizing the matrix assembly. @@ -376,7 +376,7 @@ int main (int argc, char *argv[]) { int ilower[2] = {-4, 0}, iupper[2] = {-1, 2}; /* double values[12]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(12 * sizeof(double)); /* 12 grid points */ + double *values = (double *) custom_malloc(12 * sizeof(double)); /* 12 grid points */ for (i = 0; i < 12; i ++) { @@ -390,13 +390,13 @@ int main (int argc, char *argv[]) } HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); } else if (myid == 1) { int ilower[2] = {0, 1}, iupper[2] = {2, 4}; /* double values[20]; OK to use constant-length array for CPUs */ - double *values = (double *) malloc(20 * sizeof(double)); /* 20 grid points */ + double *values = (double *) custom_malloc(20 * sizeof(double)); /* 20 grid points */ for (i = 0; i < 20; i ++) { @@ -410,7 +410,7 @@ int main (int argc, char *argv[]) } HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); } /* This is a collective call finalizing the vector assembly. diff --git a/src/examples/ex12f.f b/src/examples/ex12f.f index b772ae1f16..7c72e8d492 100644 --- a/src/examples/ex12f.f +++ b/src/examples/ex12f.f @@ -71,7 +71,7 @@ program ex12f integer*8 solver integer*8 precond - character*32 matfile +! character*32 matfile ! We only have one part and one variable nparts = 1 @@ -239,6 +239,8 @@ program ex12f iupper(2) = 4 ! 12 grid points, each with 5 stencil entries nvalues = 100 + else + nvalues = 0 endif do i = 1, nvalues, nentries diff --git a/src/examples/ex12f_cptr.f b/src/examples/ex12f_cptr.f index f43ad505d4..3d175446da 100644 --- a/src/examples/ex12f_cptr.f +++ b/src/examples/ex12f_cptr.f @@ -78,7 +78,7 @@ program ex12f integer*8 solver integer*8 precond - character*32 matfile +! character*32 matfile stat = device_malloc_managed(int(100 * 8, int64), p_values) @@ -248,6 +248,8 @@ program ex12f iupper(2) = 4 ! 12 grid points, each with 5 stencil entries nvalues = 100 + else + nvalues = 0 endif do i = 1, nvalues, nentries diff --git a/src/examples/ex13.c b/src/examples/ex13.c index 164591b71e..4ea5c1b542 100644 --- a/src/examples/ex13.c +++ b/src/examples/ex13.c @@ -84,7 +84,7 @@ #include "HYPRE_sstruct_mv.h" #include "HYPRE_sstruct_ls.h" #include "HYPRE.h" -#include "ex.h" +#include "ex.h" //* custom_malloc, custom_calloc, custom_free *// #ifndef M_PI #define M_PI 3.14159265358979 @@ -442,9 +442,9 @@ int main (int argc, char *argv[]) { /* local stifness matrix and load vector */ /* double F[4]; OK to use constant-length arrays for CPUs */ - double *F = (double *) malloc(4 * sizeof(double)); + double *F = (double *) custom_malloc(4 * sizeof(double)); /*double S[4][4]; OK to use constant-length arrays for CPUs */ - double *S_flat = (double *) malloc(16 * sizeof(double)); + double *S_flat = (double *) custom_malloc(16 * sizeof(double)); double *S[4]; S[0] = S_flat; S[1] = S[0] + 4; S[2] = S[1] + 4; S[3] = S[2] + 4; @@ -574,8 +574,8 @@ int main (int argc, char *argv[]) HYPRE_SStructVectorAddToValues(b, part, index, var, &F[k]); } } - free(F); - free(S_flat); + custom_free(F); + custom_free(S_flat); } } @@ -596,7 +596,7 @@ int main (int argc, char *argv[]) int ilower[2] = {0, 0}; int iupper[2] = {n, n}; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); /* Create an empty vector object */ HYPRE_SStructVectorCreate(MPI_COMM_WORLD, grid, &x); @@ -607,7 +607,7 @@ int main (int argc, char *argv[]) /* Set the values for the initial guess */ HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); /* Finalize the vector assembly */ HYPRE_SStructVectorAssemble(x); @@ -662,7 +662,7 @@ int main (int argc, char *argv[]) int i, part = myid, var = 0; int nvalues = (n + 1) * (n + 1); - double *values = (double*) calloc(nvalues, sizeof(double)); + double *values = (double*) custom_calloc(nvalues, sizeof(double)); int ilower[2] = {0, 0}; int iupper[2] = {n, n}; @@ -692,7 +692,7 @@ int main (int argc, char *argv[]) fflush(file); fclose(file); - free(values); + custom_free(values); /* save local finite element mesh */ GLVis_PrintLocalRhombusMesh("vis/ex13.mesh", n, myid, gamma); diff --git a/src/examples/ex14.c b/src/examples/ex14.c index bfe35fdaa6..37e05a8d3b 100644 --- a/src/examples/ex14.c +++ b/src/examples/ex14.c @@ -82,7 +82,7 @@ #include "HYPRE_sstruct_mv.h" #include "HYPRE_sstruct_ls.h" #include "HYPRE.h" -#include "ex.h" +#include "ex.h" //* custom_malloc, custom_calloc, custom_free *// #ifndef M_PI #define M_PI 3.14159265358979 @@ -430,8 +430,8 @@ int main (int argc, char *argv[]) /* local stifness matrix and load vector */ /* OK to use constant-length arrays for CPUs */ /* double S[4][4], F[4]; */ - double *F = (double *) malloc(4 * sizeof(double)); - double *S_flat = (double *) malloc(16 * sizeof(double)); + double *F = (double *) custom_malloc(4 * sizeof(double)); + double *S_flat = (double *) custom_malloc(16 * sizeof(double)); double *S[4]; S[0] = S_flat; S[1] = S[0] + 4; S[2] = S[1] + 4; S[3] = S[2] + 4; @@ -530,8 +530,8 @@ int main (int argc, char *argv[]) HYPRE_SStructVectorAddFEMValues(b, part, index, F); } } - free(F); - free(S_flat); + custom_free(F); + custom_free(S_flat); } } @@ -552,7 +552,7 @@ int main (int argc, char *argv[]) int ilower[2] = {0, 0}; int iupper[2] = {n, n}; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); /* Create an empty vector object */ HYPRE_SStructVectorCreate(MPI_COMM_WORLD, grid, &x); @@ -563,7 +563,7 @@ int main (int argc, char *argv[]) /* Set the values for the initial guess */ HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); - free(values); + custom_free(values); /* Finalize the vector assembly */ HYPRE_SStructVectorAssemble(x); @@ -618,7 +618,7 @@ int main (int argc, char *argv[]) int i, part = myid, var = 0; int nvalues = (n + 1) * (n + 1); - double *values = (double*) calloc(nvalues, sizeof(double)); + double *values = (double*) custom_calloc(nvalues, sizeof(double)); int ilower[2] = {0, 0}; int iupper[2] = {n, n}; @@ -648,7 +648,7 @@ int main (int argc, char *argv[]) fflush(file); fclose(file); - free(values); + custom_free(values); /* save local finite element mesh */ GLVis_PrintLocalRhombusMesh("vis/ex14.mesh", n, myid, gamma); diff --git a/src/examples/ex15.c b/src/examples/ex15.c index efdc9cc634..14e28d2aca 100644 --- a/src/examples/ex15.c +++ b/src/examples/ex15.c @@ -46,7 +46,7 @@ #include "HYPRE_sstruct_mv.h" #include "HYPRE_sstruct_ls.h" #include "HYPRE.h" -#include "ex.h" +#include "ex.h" //* custom_malloc, custom_calloc, custom_free *// #ifdef HYPRE_EXVIS #include "vis.c" @@ -555,8 +555,8 @@ int main (int argc, char *argv[]) /* local stiffness matrix and load vector */ /* OK to use constant-length arrays for CPUs */ /* double S[12][12], F[12]; */ - double *F = (double *) malloc(12 * sizeof(double)); - double *S_flat = (double *) malloc(12 * 12 * sizeof(double)); + double *F = (double *) custom_malloc(12 * sizeof(double)); + double *S_flat = (double *) custom_malloc(12 * 12 * sizeof(double)); double *S[12]; int i, j, k; @@ -674,8 +674,8 @@ int main (int argc, char *argv[]) } } } - free(F); - free(S_flat); + custom_free(F); + custom_free(S_flat); } /* Collective calls finalizing the matrix and vector assembly */ @@ -757,7 +757,7 @@ int main (int argc, char *argv[]) double *values; int stencil_indices[2] = {0, 1}; /* the nodes of each edge */ - values = (double*) calloc(2 * nedges, sizeof(double)); + values = (double*) custom_calloc(2 * nedges, sizeof(double)); /* The edge orientation is fixed: from first to second node */ for (i = 0; i < nedges; i++) @@ -794,7 +794,7 @@ int main (int argc, char *argv[]) values); } - free(values); + custom_free(values); } /* Finalize the matrix assembly */ @@ -808,7 +808,7 @@ int main (int argc, char *argv[]) int part = 0; int var = 0; /* the node variable */ int index[3]; - double *xyzval = (double *) malloc(3 * sizeof(double)); + double *xyzval = (double *) custom_malloc(3 * sizeof(double)); /* Create empty vector objects */ HYPRE_SStructVectorCreate(MPI_COMM_WORLD, node_grid, &xcoord); @@ -843,7 +843,7 @@ int main (int argc, char *argv[]) HYPRE_SStructVectorAssemble(xcoord); HYPRE_SStructVectorAssemble(ycoord); HYPRE_SStructVectorAssemble(zcoord); - free(xyzval); + custom_free(xyzval); } /* 5. Set up a SStruct Vector for the solution vector x */ @@ -852,7 +852,7 @@ int main (int argc, char *argv[]) int nvalues = n * (n + 1) * (n + 1); double *values; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); /* Create an empty vector object */ HYPRE_SStructVectorCreate(MPI_COMM_WORLD, edge_grid, &x); @@ -883,7 +883,7 @@ int main (int argc, char *argv[]) HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); } - free(values); + custom_free(values); /* Finalize the vector assembly */ HYPRE_SStructVectorAssemble(x); @@ -1028,9 +1028,9 @@ int main (int argc, char *argv[]) int nvalues = n * (n + 1) * (n + 1); double *xvalues, *yvalues, *zvalues; - xvalues = (double*) calloc(nvalues, sizeof(double)); - yvalues = (double*) calloc(nvalues, sizeof(double)); - zvalues = (double*) calloc(nvalues, sizeof(double)); + xvalues = (double*) custom_calloc(nvalues, sizeof(double)); + yvalues = (double*) custom_calloc(nvalues, sizeof(double)); + zvalues = (double*) custom_calloc(nvalues, sizeof(double)); /* Get local solution in the x-edges */ { @@ -1105,9 +1105,9 @@ int main (int argc, char *argv[]) fflush(file); fclose(file); - free(xvalues); - free(yvalues); - free(zvalues); + custom_free(xvalues); + custom_free(yvalues); + custom_free(zvalues); /* Save local finite element mesh */ GLVis_PrintLocalCubicMesh("vis/ex15.mesh", n, n, n, h, diff --git a/src/examples/ex15big.c b/src/examples/ex15big.c index 6c1301c058..49fa1355b3 100644 --- a/src/examples/ex15big.c +++ b/src/examples/ex15big.c @@ -41,7 +41,7 @@ #include "HYPRE_sstruct_mv.h" #include "HYPRE_sstruct_ls.h" #include "HYPRE.h" -#include "ex.h" +#include "ex.h" //* custom_malloc, custom_calloc, custom_free *// int optionAlpha, optionBeta; diff --git a/src/examples/ex16.c b/src/examples/ex16.c index 02a7cbb76c..a8942fb59e 100644 --- a/src/examples/ex16.c +++ b/src/examples/ex16.c @@ -31,7 +31,7 @@ #include "HYPRE_sstruct_mv.h" #include "HYPRE_sstruct_ls.h" #include "HYPRE.h" -#include "ex.h" +#include "ex.h" //* custom_malloc, custom_calloc, custom_free *// #ifdef HYPRE_EXVIS #include "vis.c" @@ -517,7 +517,7 @@ int main (int argc, char *argv[]) int nvalues = (n + 1) * (n + 1); double *values; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); /* Create an empty vector object */ HYPRE_SStructVectorCreate(MPI_COMM_WORLD, grid, &x); @@ -551,7 +551,7 @@ int main (int argc, char *argv[]) HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var, values); } - free(values); + custom_free(values); /* Finalize the vector assembly */ HYPRE_SStructVectorAssemble(x); @@ -612,7 +612,7 @@ int main (int argc, char *argv[]) /* GLVis-to-hypre local renumbering */ int g2h[16] = {0, 3, 15, 12, 1, 2, 7, 11, 14, 13, 8, 4, 5, 6, 9, 10}; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); nvalues = 0; for (j = 1; j <= n; j++) @@ -656,7 +656,7 @@ int main (int argc, char *argv[]) fflush(file); fclose(file); - free(values); + custom_free(values); /* Save local finite element mesh */ GLVis_PrintLocalSquareMesh("vis/ex16.mesh", n, n, h, diff --git a/src/examples/ex17.c b/src/examples/ex17.c index 1ed86bbd59..556091ba44 100644 --- a/src/examples/ex17.c +++ b/src/examples/ex17.c @@ -24,7 +24,7 @@ #include #include #include "HYPRE_struct_ls.h" -#include "ex.h" +#include "ex.h" //* custom_malloc, custom_calloc, custom_free *// #define NDIM 4 #define NSTENC (2*NDIM+1) @@ -191,7 +191,7 @@ int main (int argc, char *argv[]) /* Indicate that the matrix coefficients are ready to be set */ HYPRE_StructMatrixInitialize(A); - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); for (j = 0; j < nentries; j++) { @@ -211,7 +211,7 @@ int main (int argc, char *argv[]) HYPRE_StructMatrixSetBoxValues(A, ilower, iupper, nentries, stencil_indices, values); - free(values); + custom_free(values); } /* 4. Incorporate zero boundary conditions: go along each edge of the domain @@ -225,7 +225,7 @@ int main (int argc, char *argv[]) double *values; int stencil_indices[1]; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); for (j = 0; j < nvalues; j++) { values[j] = 0.0; @@ -260,7 +260,7 @@ int main (int argc, char *argv[]) stencil_indices[0]++; } - free(values); + custom_free(values); } /* This is a collective call finalizing the matrix assembly. @@ -272,7 +272,7 @@ int main (int argc, char *argv[]) int nvalues = nvol; double *values; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); /* Create an empty vector object */ HYPRE_StructVectorCreate(MPI_COMM_WORLD, grid, &b); @@ -295,7 +295,7 @@ int main (int argc, char *argv[]) } HYPRE_StructVectorSetBoxValues(x, ilower, iupper, values); - free(values); + custom_free(values); /* This is a collective call finalizing the vector assembly. The vector is now ``ready to be used'' */ diff --git a/src/examples/ex18.c b/src/examples/ex18.c index 6ae68cf6c3..a248bb5497 100644 --- a/src/examples/ex18.c +++ b/src/examples/ex18.c @@ -24,7 +24,7 @@ #include #include #include "HYPRE_sstruct_ls.h" -#include "ex.h" +#include "ex.h" //* custom_malloc, custom_calloc, custom_free *// #define NDIM 4 #define NPARTS 1 @@ -242,7 +242,7 @@ int main (int argc, char *argv[]) /* Get ready to set values */ HYPRE_SStructMatrixInitialize(A); - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); /* Set intra-variable values; fix boundaries later */ for (j = 0; j < nentries; j++) @@ -280,7 +280,7 @@ int main (int argc, char *argv[]) HYPRE_SStructMatrixSetBoxValues(A, part, ilower, iupper, var1, nentries, stencil_indices, values); - free(values); + custom_free(values); } /* 5. Incorporate zero boundary conditions: go along each edge of the domain @@ -296,7 +296,7 @@ int main (int argc, char *argv[]) double *values; int stencil_indices[1]; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); for (j = 0; j < nvalues; j++) { values[j] = 0.0; @@ -349,7 +349,7 @@ int main (int argc, char *argv[]) } } - free(values); + custom_free(values); } /* The matrix is now ready to use */ @@ -362,7 +362,7 @@ int main (int argc, char *argv[]) int nvalues = NVARS * nvol; double *values; - values = (double*) calloc(nvalues, sizeof(double)); + values = (double*) custom_calloc(nvalues, sizeof(double)); /* Create an empty vector object */ HYPRE_SStructVectorCreate(MPI_COMM_WORLD, grid, &b); @@ -391,7 +391,7 @@ int main (int argc, char *argv[]) HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var0, values); HYPRE_SStructVectorSetBoxValues(x, part, ilower, iupper, var1, values); - free(values); + custom_free(values); /* The vector is now ready to use */ HYPRE_SStructVectorAssemble(b); diff --git a/src/examples/vis/Makefile b/src/examples/vis/Makefile index 84c86cdc83..ac1c789e6e 100644 --- a/src/examples/vis/Makefile +++ b/src/examples/vis/Makefile @@ -4,4 +4,4 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) clean: - rm -f *mesh* *sol* *data* + @rm -fv *mesh* *sol* *data* diff --git a/src/examples/vis/glvis-ex1.sh b/src/examples/vis/glvis-ex01.sh similarity index 88% rename from src/examples/vis/glvis-ex1.sh rename to src/examples/vis/glvis-ex01.sh index 166a3c47d4..d40d0174d6 100755 --- a/src/examples/vis/glvis-ex1.sh +++ b/src/examples/vis/glvis-ex01.sh @@ -5,9 +5,10 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -ex=ex1 +ex=ex01 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -27,4 +28,4 @@ fi np=`cat $dir/$ex.data | head -n 1 | awk '{ print $2 }'` -glvis -np $np -m $mesh -g $sol -k $keys +${glvis} -np $np -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex2.sh b/src/examples/vis/glvis-ex02.sh similarity index 88% rename from src/examples/vis/glvis-ex2.sh rename to src/examples/vis/glvis-ex02.sh index 5e99fa13d8..6c97bd0d62 100755 --- a/src/examples/vis/glvis-ex2.sh +++ b/src/examples/vis/glvis-ex02.sh @@ -5,9 +5,10 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -ex=ex2 +ex=ex02 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -27,4 +28,4 @@ fi np=`cat $dir/$ex.data | head -n 1 | awk '{ print $2 }'` -glvis -np $np -m $mesh -g $sol -k $keys +${glvis} -np $np -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex7.sh b/src/examples/vis/glvis-ex03.sh similarity index 91% rename from src/examples/vis/glvis-ex7.sh rename to src/examples/vis/glvis-ex03.sh index 564a6eb774..4a3b7929c8 100755 --- a/src/examples/vis/glvis-ex7.sh +++ b/src/examples/vis/glvis-ex03.sh @@ -5,9 +5,10 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -ex=ex7 +ex=ex03 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -32,4 +33,4 @@ echo "Ordering: 0" >> $sol echo "" >> $sol find $dir -name "$ex.sol.??????" | sort | xargs cat | sort | awk '{ print $2 }' >> $sol -glvis -m $mesh -g $sol -k $keys +${glvis} -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex3.sh b/src/examples/vis/glvis-ex04.sh similarity index 91% rename from src/examples/vis/glvis-ex3.sh rename to src/examples/vis/glvis-ex04.sh index a452f8e379..6755126d50 100755 --- a/src/examples/vis/glvis-ex3.sh +++ b/src/examples/vis/glvis-ex04.sh @@ -5,9 +5,10 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -ex=ex3 +ex=ex04 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -32,4 +33,4 @@ echo "Ordering: 0" >> $sol echo "" >> $sol find $dir -name "$ex.sol.??????" | sort | xargs cat | sort | awk '{ print $2 }' >> $sol -glvis -m $mesh -g $sol -k $keys +${glvis} -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex5.sh b/src/examples/vis/glvis-ex05.sh similarity index 91% rename from src/examples/vis/glvis-ex5.sh rename to src/examples/vis/glvis-ex05.sh index deedf0ab30..2c389601a8 100755 --- a/src/examples/vis/glvis-ex5.sh +++ b/src/examples/vis/glvis-ex05.sh @@ -5,9 +5,10 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -ex=ex5 +ex=ex05 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -32,4 +33,4 @@ echo "Ordering: 0" >> $sol echo "" >> $sol find $dir -name "$ex.sol.??????" | sort | xargs cat >> $sol -glvis -m $mesh -g $sol -k $keys +${glvis} -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex8.sh b/src/examples/vis/glvis-ex06.sh similarity index 88% rename from src/examples/vis/glvis-ex8.sh rename to src/examples/vis/glvis-ex06.sh index e15b4eee5b..bd378cbd8a 100755 --- a/src/examples/vis/glvis-ex8.sh +++ b/src/examples/vis/glvis-ex06.sh @@ -5,9 +5,10 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -ex=ex8 +ex=ex06 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -27,4 +28,4 @@ fi np=`cat $dir/$ex.data | head -n 1 | awk '{ print $2 }'` -glvis -np $np -m $mesh -g $sol -k $keys +${glvis} -np $np -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex4.sh b/src/examples/vis/glvis-ex07.sh similarity index 91% rename from src/examples/vis/glvis-ex4.sh rename to src/examples/vis/glvis-ex07.sh index 592e116ea7..ac3645d6af 100755 --- a/src/examples/vis/glvis-ex4.sh +++ b/src/examples/vis/glvis-ex07.sh @@ -5,9 +5,10 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -ex=ex4 +ex=ex07 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -32,4 +33,4 @@ echo "Ordering: 0" >> $sol echo "" >> $sol find $dir -name "$ex.sol.??????" | sort | xargs cat | sort | awk '{ print $2 }' >> $sol -glvis -m $mesh -g $sol -k $keys +${glvis} -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex6.sh b/src/examples/vis/glvis-ex08.sh similarity index 88% rename from src/examples/vis/glvis-ex6.sh rename to src/examples/vis/glvis-ex08.sh index 0eb025aff2..8868453d96 100755 --- a/src/examples/vis/glvis-ex6.sh +++ b/src/examples/vis/glvis-ex08.sh @@ -5,9 +5,10 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -ex=ex6 +ex=ex08 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -27,4 +28,4 @@ fi np=`cat $dir/$ex.data | head -n 1 | awk '{ print $2 }'` -glvis -np $np -m $mesh -g $sol -k $keys +${glvis} -np $np -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex9.sh b/src/examples/vis/glvis-ex09.sh similarity index 94% rename from src/examples/vis/glvis-ex9.sh rename to src/examples/vis/glvis-ex09.sh index f6d3bda6fe..4662093316 100755 --- a/src/examples/vis/glvis-ex9.sh +++ b/src/examples/vis/glvis-ex09.sh @@ -5,9 +5,10 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -ex=ex9 +ex=ex09 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -43,4 +44,4 @@ echo "Ordering: 0" >> $solv echo "" >> $solv find $dir -name "$ex-v.sol.??????" | sort | xargs cat | sort | awk '{ print $2 }' >> $solv -glvis -m $mesh -g $solv -k $keys +${glvis} -m $mesh -g $solv -k $keys diff --git a/src/examples/vis/glvis-ex10.sh b/src/examples/vis/glvis-ex10.sh index 0029802ec7..defed322e4 100755 --- a/src/examples/vis/glvis-ex10.sh +++ b/src/examples/vis/glvis-ex10.sh @@ -8,6 +8,7 @@ ex=ex10 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -27,5 +28,4 @@ fi np=`cat $dir/$ex.data | head -n 1 | awk '{ print $2 }'` -glvis -np $np -m $mesh -g $sol -k $keys - +${glvis} -np $np -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex11.sh b/src/examples/vis/glvis-ex11.sh index d0123ef0f0..dd3640c824 100755 --- a/src/examples/vis/glvis-ex11.sh +++ b/src/examples/vis/glvis-ex11.sh @@ -8,6 +8,7 @@ ex=ex11 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -32,4 +33,4 @@ echo "Ordering: 0" >> $sol echo "" >> $sol find $dir -name "$ex.sol.??????" | sort | xargs cat >> $sol -glvis -m $mesh -g $sol -k $keys +${glvis} -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex12.sh b/src/examples/vis/glvis-ex12.sh index 90dc07bc3c..04e49d4d64 100755 --- a/src/examples/vis/glvis-ex12.sh +++ b/src/examples/vis/glvis-ex12.sh @@ -8,6 +8,7 @@ ex=ex12 dir=`basename \`pwd\`` keys=Aaamc +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -27,4 +28,4 @@ fi np=`cat $dir/$ex.data | head -n 1 | awk '{ print $2 }'` -glvis -np $np -m $mesh -g $sol -k $keys +${glvis} -np $np -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex13.sh b/src/examples/vis/glvis-ex13.sh index 5fab1f573e..bbe124801c 100755 --- a/src/examples/vis/glvis-ex13.sh +++ b/src/examples/vis/glvis-ex13.sh @@ -8,6 +8,7 @@ ex=ex13 dir=`basename \`pwd\`` keys=AbjRl************ +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -27,5 +28,4 @@ fi np=`cat $dir/$ex.data | head -n 1 | awk '{ print $2 }'` -glvis -np $np -m $mesh -g $sol -k $keys - +${glvis} -np $np -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex14.sh b/src/examples/vis/glvis-ex14.sh index 849da057bf..d5c128589e 100755 --- a/src/examples/vis/glvis-ex14.sh +++ b/src/examples/vis/glvis-ex14.sh @@ -8,6 +8,7 @@ ex=ex14 dir=`basename \`pwd\`` keys=AbjRl************ +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -27,5 +28,4 @@ fi np=`cat $dir/$ex.data | head -n 1 | awk '{ print $2 }'` -glvis -np $np -m $mesh -g $sol -k $keys - +${glvis} -np $np -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex15.sh b/src/examples/vis/glvis-ex15.sh index 328cdc177e..6c49c57b5f 100755 --- a/src/examples/vis/glvis-ex15.sh +++ b/src/examples/vis/glvis-ex15.sh @@ -8,6 +8,7 @@ ex=ex15 dir=`basename \`pwd\`` keys=AaamcVooof +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -27,5 +28,4 @@ fi np=`cat $dir/$ex.data | head -n 1 | awk '{ print $2 }'` -glvis -np $np -m $mesh -g $sol -k $keys - +${glvis} -np $np -m $mesh -g $sol -k $keys diff --git a/src/examples/vis/glvis-ex16.sh b/src/examples/vis/glvis-ex16.sh index 056acf6b09..7c3993d46b 100755 --- a/src/examples/vis/glvis-ex16.sh +++ b/src/examples/vis/glvis-ex16.sh @@ -8,6 +8,7 @@ ex=ex16 dir=`basename \`pwd\`` keys=Aaamciiii +glvis=${1:-"glvis"} if [ "$dir" = "vis" ]; then dir=. @@ -27,5 +28,4 @@ fi np=`cat $dir/$ex.data | head -n 1 | awk '{ print $2 }'` -glvis -np $np -m $mesh -g $sol -k $keys - +${glvis} -np $np -m $mesh -g $sol -k $keys