| 
									
										
										
										
											2023-08-17 08:09:43 +08:00
										 |  |  | #!/bin/bash
 | 
					
						
							| 
									
										
										
										
											2022-04-06 07:19:51 +08:00
										 |  |  | # Copyright (c) 1998 Lawrence Livermore National Security, LLC and other | 
					
						
							| 
									
										
										
										
											2019-07-08 10:26:24 +08:00
										 |  |  | # HYPRE Project Developers. See the top-level COPYRIGHT file for details. | 
					
						
							| 
									
										
										
										
											2015-01-21 06:54:12 +08:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2019-07-08 10:26:24 +08:00
										 |  |  | # SPDX-License-Identifier: (Apache-2.0 OR MIT) | 
					
						
							| 
									
										
										
										
											2015-01-21 06:54:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | testname=`basename $0 .sh` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-27 08:22:21 +08:00
										 |  |  | drivers="ij sstruct struct ams_driver maxwell_unscaled sstruct_fac ij_mv struct_migrate" | 
					
						
							| 
									
										
										
										
											2016-03-18 23:16:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-21 06:54:12 +08:00
										 |  |  | # Echo usage information | 
					
						
							|  |  |  | case $1 in | 
					
						
							|  |  |  |    -h|-help) | 
					
						
							|  |  |  |       cat <<EOF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    $0 [-h] {src_dir} [options] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    where: {src_dir}     is the hypre source directory | 
					
						
							|  |  |  |           -co: <opts>   configuration options | 
					
						
							|  |  |  |           -mo: <opts>   make options | 
					
						
							|  |  |  |           -ro: <opts>   call the run script with these options | 
					
						
							|  |  |  |           -eo: <opts>   call the examples script with these options | 
					
						
							|  |  |  |           -h|-help      prints this usage information and exits | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This script uses cmake to configure and compile the source in {src_dir}, then | 
					
						
							|  |  |  |    optionally runs driver and example tests. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-16 02:30:49 +08:00
										 |  |  |    Example usage: $0 ../src -co -DCMAKE_BUILD_TYPE=Debug -ro: -ij | 
					
						
							| 
									
										
										
										
											2015-01-21 06:54:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  |       exit | 
					
						
							|  |  |  |       ;; | 
					
						
							|  |  |  | esac | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Set src_dir | 
					
						
							| 
									
										
										
										
											2016-01-19 09:05:14 +08:00
										 |  |  | src_dir=`cd $1; pwd` | 
					
						
							|  |  |  | shift | 
					
						
							| 
									
										
										
										
											2015-01-21 06:54:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Parse the rest of the command line | 
					
						
							| 
									
										
										
										
											2019-08-21 02:20:30 +08:00
										 |  |  | copts="-DHYPRE_BUILD_TESTS=ON" | 
					
						
							| 
									
										
										
										
											2015-01-21 06:54:12 +08:00
										 |  |  | mopts="" | 
					
						
							|  |  |  | ropts="" | 
					
						
							|  |  |  | eopts="" | 
					
						
							|  |  |  | while [ "$*" ] | 
					
						
							|  |  |  | do | 
					
						
							|  |  |  |    case $1 in | 
					
						
							|  |  |  |       -co:) | 
					
						
							|  |  |  |          opvar="copts"; shift | 
					
						
							|  |  |  |          ;; | 
					
						
							|  |  |  |       -mo:) | 
					
						
							|  |  |  |          opvar="mopts"; shift | 
					
						
							|  |  |  |          ;; | 
					
						
							|  |  |  |       -ro:) | 
					
						
							|  |  |  |          opvar="ropts"; rset="yes"; shift | 
					
						
							|  |  |  |          ;; | 
					
						
							|  |  |  |       -eo:) | 
					
						
							|  |  |  |          opvar="eopts"; eset="yes"; shift | 
					
						
							|  |  |  |          ;; | 
					
						
							|  |  |  |       *) | 
					
						
							|  |  |  |          eval $opvar=\"\$$opvar $1\" | 
					
						
							|  |  |  |          shift | 
					
						
							|  |  |  |          ;; | 
					
						
							|  |  |  |    esac | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Setup | 
					
						
							|  |  |  | test_dir=`pwd` | 
					
						
							|  |  |  | output_dir=`pwd`/$testname.dir | 
					
						
							|  |  |  | rm -fr $output_dir | 
					
						
							|  |  |  | mkdir -p $output_dir | 
					
						
							| 
									
										
										
										
											2015-01-21 07:53:37 +08:00
										 |  |  | cd $src_dir | 
					
						
							|  |  |  | src_dir=`pwd` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Clean up the cmbuild directories (do it from src_dir as a precaution) | 
					
						
							|  |  |  | cd $src_dir | 
					
						
							|  |  |  | rm -fr `echo cmbuild/* | sed 's/[^ ]*README.txt//g'` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Clean up the previous install | 
					
						
							|  |  |  | cd $src_dir | 
					
						
							|  |  |  | rm -fr hypre | 
					
						
							| 
									
										
										
										
											2015-01-21 06:54:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Configure | 
					
						
							|  |  |  | cd $src_dir/cmbuild | 
					
						
							| 
									
										
										
										
											2021-05-20 04:39:57 +08:00
										 |  |  | eval cmake $copts .. | 
					
						
							| 
									
										
										
										
											2015-01-21 06:54:12 +08:00
										 |  |  | make $mopts install | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Make | 
					
						
							| 
									
										
										
										
											2019-08-21 02:20:30 +08:00
										 |  |  | cd $src_dir/cmbuild/test | 
					
						
							| 
									
										
										
										
											2015-01-21 06:54:12 +08:00
										 |  |  | make $mopts | 
					
						
							| 
									
										
										
										
											2019-08-21 02:20:30 +08:00
										 |  |  | mv -f $drivers ../../test | 
					
						
							| 
									
										
										
										
											2015-01-21 06:54:12 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | cd $test_dir | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Run | 
					
						
							|  |  |  | if [ -n "$rset" ]; then | 
					
						
							|  |  |  |    ./test.sh run.sh $src_dir $ropts | 
					
						
							|  |  |  |    mv -f run.??? $output_dir | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Examples | 
					
						
							|  |  |  | if [ -n "$eset" ]; then | 
					
						
							|  |  |  |    ./test.sh examples.sh $src_dir $eopts | 
					
						
							|  |  |  |    mv -f examples.??? $output_dir | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Echo to stderr all nonempty error files in $output_dir | 
					
						
							|  |  |  | for errfile in $( find $output_dir ! -size 0 -name "*.err" ) | 
					
						
							|  |  |  | do | 
					
						
							|  |  |  |    echo $errfile >&2 | 
					
						
							|  |  |  | done | 
					
						
							| 
									
										
										
										
											2016-03-18 23:16:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Clean up | 
					
						
							|  |  |  | cd $src_dir | 
					
						
							|  |  |  | rm -fr `echo cmbuild/* | sed 's/[^ ]*README.txt//g'` | 
					
						
							|  |  |  | rm -fr hypre | 
					
						
							| 
									
										
										
										
											2017-05-17 02:26:35 +08:00
										 |  |  | ( cd $src_dir/test; rm -f $drivers; ./cleantest.sh ) | 
					
						
							| 
									
										
										
										
											2016-03-18 23:16:00 +08:00
										 |  |  | 
 |