Commit 2e50d5f8 authored by Johannes Spazier's avatar Johannes Spazier

- A simple build system that uses the GNU Autotools was introduced.

- A directory "tools/" was added. It includes programs that can be used to display the results created by EasyWave.
- A directory "tests/" was added that contains some python scripts for testing different versions of EasyWave.
parent d3825031
SUBDIRS = src
install-exec-hook:
cp -f bin/* $(prefix)/bin
cp -f utils/* $(prefix)/utils
EXTRA_DIST = bin utils
dist-hook:
rm -rf `find $(distdir)/bin -type d -name .svn`
rm -rf `find $(distdir)/utils -type d -name .svn`
AC_INIT([easyWave], [1.0], [babeyko@gfz-potsdam.de])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AC_PROG_CXX
AC_PROG_CC
AC_LANG(C++)
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_CHECK_HEADERS([stdlib.h])
AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_FUNC_MALLOC
AC_CHECK_FUNCS([floor pow sqrt memset strchr strdup strstr clock_gettime])
AC_ARG_ENABLE( [cuda],
[AS_HELP_STRING([--disable-cuda], [Disable CUDA support.])],
[enable_cuda="no"],
[enable_cuda="yes"]
)
AC_MSG_NOTICE($enable_cuda)
AC_ARG_VAR([NVCC], [nvcc compiler to use])
AC_PATH_PROG([NVCC], [nvcc], [no])
AM_CONDITIONAL([ENABLE_CUDA], [test "$NVCC" != "no" && test "$enable_cuda" = "yes"])
AC_CHECK_LIB([cudart], [cudaLaunch], [cudart="yes"], [cudart="no"])
AC_CHECK_LIB([cuda], [cuInit], [cuda="yes"], [cuda="no"])
AC_MSG_NOTICE($cudart)
AC_MSG_NOTICE($cuda)
AC_PREFIX_DEFAULT([/usr/local/EasyWave])
AC_OUTPUT
.cu.o:
$(NVCC) -O2 -c -I. -x cu -o $@ -c $<
......@@ -7,7 +7,9 @@
#include <utilits.h>
#include "easywave.h"
#ifdef __CUDACC__
#include "ewGpuNode.cuh"
#endif
CNode *gNode;
......@@ -50,7 +52,9 @@ int main( int argc, char **argv )
Log.print( "%s", buf );
if( Par.gpu ) {
#ifdef __CUDACC__
gNode = new CGpuNode();
#endif
} else {
gNode = new CStructNode();
//gNode = new CArrayNode();
......
This diff is collapsed.
include $(top_srcdir)/cuda.mk
bin_PROGRAMS = EasyWave
EasyWave_SOURCES = cOgrd.cpp \
cOkadaEarthquake.cpp \
cOkadaFault.cpp \
cSphere.cpp \
ewGrid.cpp \
ewOut2D.cpp \
ewParam.cpp \
ewPOIs.cpp \
ewReset.cpp \
ewSource.cpp \
ewStep.cpp \
okada.cpp \
utilits.cpp \
cOgrd.h \
cOkadaEarthquake.h \
cOkadaFault.h \
cSphere.h \
easywave.h \
ewNode.h \
utilits.h
EasyWaveGen.cu: EasyWave.cpp
@cp EasyWave.cpp EasyWaveGen.cu
BUILT_SOURCES = EasyWaveGen.cu
CLEANFILES = EasyWaveGen.cu
if ENABLE_CUDA
EasyWave_SOURCES += ewCudaKernels.cu \
ewCudaKernels.cuh \
ewGpuNode.cu \
ewGpuNode.cuh \
EasyWaveGen.cu
EasyWave_LINK = $(NVCC) -O2 -o EasyWave
else
EasyWave_SOURCES += EasyWave.cpp
EasyWave_LINK = $(CXX) $(CXXFLAGS) -o EasyWave
endif
......@@ -151,6 +151,7 @@ __device__ int4 c_MinMax = {0,0,0,0};
__global__ void runGridExtendKernel1( KernelData data ) {
#if (__CUDA_ARCH__ >= 130)
Params& dp = data.params;
int id = blockIdx.x * blockDim.x + threadIdx.x + 1;
......@@ -172,6 +173,7 @@ __global__ void runGridExtendKernel1( KernelData data ) {
if( fabsf(data.h[data.idx(id,dp.jMax-2)]) > dp.sshClipThreshold )
atomicAdd( &c_MinMax.w, 1 );
}
#endif
}
......@@ -183,6 +185,8 @@ __global__ void runGridExtendKernel2( KernelData data ) {
if( id == 0 ) {
#if (__CUDA_ARCH__ >= 130)
if( c_MinMax.x )
dp.iMin = max( dp.iMin-1, 2 );
......@@ -199,13 +203,50 @@ __global__ void runGridExtendKernel2( KernelData data ) {
c_MinMax.y = 0;
c_MinMax.z = 0;
c_MinMax.w = 0;
}
int4 tmp;
tmp.x = dp.iMin;
tmp.y = dp.iMax;
tmp.z = dp.jMin;
tmp.w = dp.jMax;
#else
for( int j = dp.jMin; j <= dp.jMax; j++ ) {
if( fabsf(data.h[data.idx(dp.iMin+2,j)]) > dp.sshClipThreshold ) {
dp.iMin = max( dp.iMin-1, 2 );
break;
}
}
for( int j = dp.jMin; j <= dp.jMax; j++ ) {
if( fabsf(data.h[data.idx(dp.iMax-2,j)]) > dp.sshClipThreshold ) {
dp.iMax = min( dp.iMax+1, dp.nI-1 );
break;
}
}
for( int i = dp.iMin; i <= dp.iMax; i++ ) {
if( fabsf(data.h[data.idx(i,dp.jMin+2)]) > dp.sshClipThreshold ) {
dp.jMin = max( dp.jMin-1, 2 );
break;
}
}
for( int i = dp.iMin; i <= dp.iMax; i++ ) {
if( fabsf(data.h[data.idx(i,dp.jMax-2)]) > dp.sshClipThreshold ) {
dp.jMax = min( dp.jMax+1, dp.nJ-1 );
break;
}
}
#endif
int4 tmp;
tmp.x = dp.iMin;
tmp.y = dp.iMax;
tmp.z = dp.jMin;
tmp.w = dp.jMax;
*(data.g_MinMax) = tmp;
}
*(data.g_MinMax) = tmp;
}
#!/usr/bin/env python
import sys
import struct
fileA = open( sys.argv[1], 'r' )
fileB = open( sys.argv[2], 'r' )
numDiff = 0
maxDiff = 0.0
bufSize = 1024
fileA.read(56)
fileB.read(56)
while True:
strfA = fileA.read(bufSize)
if strfA == "":
break
strfB = fileB.read(bufSize)
if len(strfA) != len(strfB):
print 'The files have different sizes!'
sys.exit(1)
count = len(strfA) / 4
bufA = struct.unpack( '%uf' % count, strfA )
bufB = struct.unpack( '%uf' % count, strfB )
for valA, valB in zip(bufA, bufB):
if valA != valB:
numDiff += 1
maxDiff = max( maxDiff, abs( valA - valB ) )
if fileB.read(1) != "":
print 'File A is shorter than file B!'
print 'Differences: %u' % numDiff
print 'Max difference: %f' % maxDiff
fileA.close()
fileB.close()
@../src/EasyWave; @../src/EasyWave -gpu
-grid @grids/e2Asean.grd -source @faults/BengkuluSept2007.flt -time 300
-grid @grids/e2Indian.grd -source @faults/BengkuluSept2007.flt -time 300
-grid @grids/g08Indonesia.grd -source @faults/BengkuluSept2007.flt -time 300
-grid @grids/g08Japan.grd -source @faults/uz.Tohoku11.grd -time 300
-grid @grids/g08Lisboa.grd -source @faults/faultPortugal.inp -time 300
-grid @grids/e2r4Pacific.grd -source @faults/uz.Tohoku11.grd -time 300
#!/usr/bin/env python
import sys
import os
import tempfile
import datetime
import subprocess
import glob
import re
sdir = os.path.dirname( os.path.abspath( sys.argv[0] ) )
def start( cmd ):
tmp_path = tempfile.mkdtemp()
os.chdir( tmp_path )
print tmp_path
print cmd
# starts easywave and counts time differential between start and end
t0 = datetime.datetime.now()
ewrun = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
ewrun.wait()
delta_t = ( datetime.datetime.now() - t0 )
print 'Runtime: %u.%u sec' % (delta_t.seconds, delta_t.microseconds)
cmds[ cmd ] = tmp_path
def compareCmds( cmd ):
path = []
files = []
maxDiff = 0.0
for i in range( 0, 2 ):
path.append( cmds[ cmd[i] ] )
files.append( glob.glob( path[i] + "/*.ssh" ) )
files[i] += glob.glob( path[i] + "/*.sshmax" )
#files[i] += glob.glob( path[i] + "/*.time" )
for f in files[0]:
basef = os.path.basename( f )
fnext = path[1] + '/' + basef
if fnext in files[1]:
#compare.py
compare = subprocess.Popen( sdir + '/compare.py %s %s' % (f, fnext), shell=True, stdout=subprocess.PIPE )
compare.wait()
diff = float( re.search( 'Max difference: (.*)\n', compare.stdout.read() ).group(1) )
maxDiff = max( maxDiff, diff )
if verbose:
print basef + ": %f" % diff
files[1].remove( fnext )
else:
print 'File "' + basef + '" is missing in 1.'
for f in files[1]:
print 'File "' + basef + '" is missing in 0.'
if maxDiff > tolerance:
print "\033[91mFailed:\033[0m",
else:
print "\033[92mSuccessful:\033[0m",
print '%f' % maxDiff
cfg_path = sdir + "/config.cfg"
scs_path = sdir + "/scenarios.cfg"
runs = []
scenarios = []
cmds = {}
tolerance = 0.02
verbose = True
# read config file to get a list of programs to compare
f = open( cfg_path, 'r' )
for line in f:
if line.lstrip()[0] != '#':
progs = line.replace('\n','').replace('@',sdir+'/').split( ';' )
if len( progs ) > 2:
print 'Warning: Can compare only two programs at a time. Ignoring additional entries.'
del progs[2:]
runs.append( progs )
f.close()
# read scenario file to get a list of scenarios used to compare the given programs
f = open( scs_path, 'r' )
for line in f:
if line.lstrip()[0] != '#':
scenarios.append( line.replace('\n','').replace('@',sdir+'/') )
f.close()
# input was read successfully
for run in runs:
for sc in scenarios:
cmd = []
for prog in run:
cmd.append( prog + ' ' + sc )
start( cmd[-1] )
compareCmds( cmd )
\ No newline at end of file
#!/bin/bash
EWPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../utils" && pwd )"
SSHFILE=eWave.poi.summary
FONT=$EWPATH/FreeMonoBold.ttf
while test $# -gt 0; do
case "$1" in
-h|--help)
echo ""
echo "Usage: poi2png.cmd poi-filename"
echo " e.g., poi2png.cmd poiIndonesia.poi"
exit 0
;;
-grd)
shift
if test $# -gt 0; then
f=$1
else
echo "Error: no grid specified."
exit 1
fi
shift
;;
*)
break
;;
esac
done
# Check command line parameters
if [ $# -eq 1 ]; then
POIFILE=$1
else
echo "Error: no poi file specified."
exit 1
fi
# Check number of grd-files in current directory
# We assume presence of a single grd -- bathymetry
ngrids=0
if test "$f" = ""; then
for f in *.grd
do
let ngrids+=1
done
if [ $ngrids -gt 1 ]; then
echo "More than one grid. Do not know which one to use!"
exit 2
fi
fi
# Execute converter
$EWPATH/poi2png -grdB $f -palB $EWPATH/topo4sshmaxBW.cpt -poi $POIFILE -ssh $SSHFILE -levels 0.1 0.5 3.0 -font $FONT
# GMT colour palette table (cpt)
# for SSH, absolute
# COLOR_MODEL = RGB
-0.5 0 0 1 -0.05 1 1 1
-0.05 1 1 1 0.05 1 1 1
0.05 1 1 1 0.3 1 0 0
0.3 1 0 0 0.5 0.33 0 0
# GMT colour palette table (cpt)
# for SSH, relative
# COLOR_MODEL = RGB
0.0 0 0 1 0.45 1 1 1
0.45 1 1 1 0.55 1 1 1
0.55 1 1 1 0.8 1 0 0
0.8 1 0 0 1 0.33 0 0
#!/bin/bash
EWPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../utils" && pwd )"
FONT=$EWPATH/FreeMonoBold.ttf
VMAX=0.5
while test $# -gt 0; do
case "$1" in
-h|--help)
echo ""
echo "Usage: ssh2png.cmd <timelabel|all> [scaleMax]"
echo " where optional scale is given in meters, default scale- from -0.5 to 0.5 m"
echo "e.g., ssh2png.cmd 01800 10"
echo " to present data from eWave.2D.01800.ssh using 10 meter scale"
echo " ssh2png.cmd all"
echo " use 'all' to create a mpg-movie over all available time frames"
exit 0
;;
-grd)
shift
if test $# -gt 0; then
f=$1
else
echo "Error: no grid specified."
exit 1
fi
shift
;;
*)
break
;;
esac
done
# Check command line parameters
if [ $# -eq 1 ]; then
SSHFILE=eWave.2D.$1.ssh
else
echo "Error: no ssh file specified."
exit 1
fi
# Check number of grd-files in current directory
# We assume presence of a single grd -- bathymetry
ngrids=0
if test "$f" = ""; then
for f in *.grd
do
let ngrids+=1
done
if [ $ngrids -gt 1 ]; then
echo "More than one grid. Do not know which one to use!"
exit 2
fi
fi
# Execute converter
if [ "$1" == "all" ]; then
echo "Batch processing to movie"
echo "Enter frame rate [fps]: "
read fps
nmb=0
for s in *.ssh
do
let nmb+=1
OUTFILE=ssh$(printf "%.3d" "$nmb")
echo "$s -> $OUTFILE.png"
$EWPATH/ew2png -grdB $f -palB $EWPATH/topo.cpt -transparency 0.01 -grdW $s -palW $EWPATH/ssh.rel.cpt -log -minmax -$VMAX $VMAX -legend scale+time -font $FONT -output $OUTFILE
convert $OUTFILE.png -depth 8 $OUTFILE.png
done
OUTFILE=ssh.mp4
if [ -f $OUTFILE ]
then
rm $OUTFILE
fi
echo "NOW: Merging frames into a movie file $OUTFILE"
avconv -qscale 5 -r $fps -i ssh%3d.png $OUTFILE
echo "NOW: Removing png-frames"
rm ssh*.png
else
$EWPATH/ew2png -grdB $f -palB $EWPATH/topo.cpt -transparency 0.01 -grdW $SSHFILE -palW $EWPATH/ssh.rel.cpt -log -minmax -$VMAX $VMAX -legend range+scale+time -font $FONT
fi
# GMT colour palette table (cpt)
# for SSH max, logarithmic, relative
# COLOR_MODEL = RGB
0.0 0 0 0.67 0.2 1 1 0
0.2 1 1 0 0.4 1 0 0
0.4 1 0 0 0.6 0.67 0 0
0.6 0.67 0 0 0.8 1 0 1
0.8 1 0 1 1 0.33 0 0.33
#!/bin/bash
EWPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../utils" && pwd )"
SSHFILE=eWave.2D.sshmax
FONT=$EWPATH/FreeMonoBold.ttf
# Check command line parameters
VMIN=0.1
VMAX=10.
while test $# -gt 0; do
case "$1" in
-h|--help)
echo ""
echo "Usage: sshmax2png.sh [scaleMin scaleMax]"
echo " where optional scale is given in meters, default scale- from 0.1 to 10 m"
echo " avoid using 0 as ScaleMin because of logarithmic scale!"
exit 0
;;
-grd)
shift
if test $# -gt 0; then
f=$1
else
echo "Error: no grid specified."
exit 1
fi
shift
;;
-ssh)
shift
if test $# -gt 0; then
SSHFILE=$1
else
echo "Error: no ssh file specified."
exit 1
fi
esac
done
# Check number of grd-files in current directory
# We assume presence of a single grd -- bathymetry
ngrids=0
if test "$f" = ""; then
for f in *.grd
do
ngrids=$((ngrids+1))
done
if [ $ngrids -gt 1 ]; then
echo "More than one grid. Do not know which one to use!"
exit 2
fi
fi
# Execute converter
$EWPATH/ew2png -grdB $f -palB $EWPATH/topo4sshmaxBW.cpt -transparency 0.001 -grdW $SSHFILE -palW $EWPATH/sshmax.rel.cpt -log -minmax $VMIN $VMAX -legend scale+range -font $FONT
# cpt file for topography
#COLOR_MODEL = RGB
#
-1 255 255 255 0 255 255 255
0 0 97 71 50 16 122 47
50 16 122 47 500 232 215 125
500 232 215 125 1200 161 67 0
1200 161 67 0 1700 158 0 0
1700 158 0 0 2800 110 110 110
2800 110 110 110 4000 180 180 180
4000 180 180 180 5000 210 210 210
# cpt file for topography
#COLOR_MODEL = RGB
#
-1 0 0 170 0 0 0 170
0 0 97 71 50 16 122 47
50 16 122 47 500 232 215 125
500 232 215 125 1200 161 67 0
1200 161 67 0 1700 158 0 0
1700 158 0 0 2800 110 110 110
2800 110 110 110 4000 180 180 180
4000 180 180 180 5000 210 210 210
# cpt file for topography
#COLOR_MODEL = RGB
#
-1. 0 0 0.67 0. 0 0 0.67
0. 0.5 0.5 0.5 2250. 0.8 0.8 0.8
2250. 0.8 0.8 0.8 4500. 0.9 0.9 0.9
4500 0.9 0.9 0.9 6750. 1.0 1.0 1.0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment