Commit f70d8032 authored by Cristian Constantin Lalescu's avatar Cristian Constantin Lalescu
Browse files

Merge branch 'feature/py-package-version' into develop

parents 6bdd1e1d 86c9752e
Pipeline #109516 passed with stages
in 14 minutes and 36 seconds
......@@ -51,7 +51,14 @@ project(TurTLE)
find_program(PYTHON_EXECUTABLE
python3)
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/get_version.py OUTPUT_VARIABLE TURTLE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/get_version.py
OUTPUT_VARIABLE TURTLE_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/get_version_long.py
OUTPUT_VARIABLE TURTLE_VERSION_LONG
OUTPUT_STRIP_TRAILING_WHITESPACE)
project(TurTLE
VERSION ${TURTLE_VERSION}
......@@ -479,12 +486,25 @@ if(EXISTS "${PROJECT_BINARY_DIR}/bash_setup_for_TurTLE.sh")
DESTINATION "lib/"
)
endif()
install(FILES "${PROJECT_SOURCE_DIR}/TurTLE/test/B32p1e4_checkpoint_0.h5" DESTINATION share/TurTLE-${TURTLE_VERSION_LONG})
install(DIRECTORY "${PROJECT_SOURCE_DIR}/TurTLE/test/particle_set" DESTINATION share/TurTLE-${TURTLE_VERSION_LONG}/)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/TurTLE/test/profiler" DESTINATION share/TurTLE-${TURTLE_VERSION_LONG}/)
#####################################################################################
## Install the python3 wrapper
# copy command
# copy python package
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/TurTLE ${PROJECT_BINARY_DIR}/python/TurTLE/)")
# install __init__
configure_file(
"${PROJECT_SOURCE_DIR}/TurTLE/__init__.py.in"
"${PROJECT_BINARY_DIR}/python/TurTLE/__init__.py"
@ONLY)
# update setup.py
configure_file(
"${PROJECT_SOURCE_DIR}/setup.py.in"
"${PROJECT_BINARY_DIR}/python/setup.py"
@ONLY)
if(EXISTS "${PROJECT_BINARY_DIR}/host_info.py")
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/host_info.py ${PROJECT_BINARY_DIR}/python/TurTLE/)")
else()
......@@ -494,7 +514,7 @@ else()
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/pc_host_info.py ${PROJECT_BINARY_DIR}/python/TurTLE/host_info.py)")
endif()
endif()
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/setup.py install --force --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python/)")
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/setup.py install --force --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python/)")
#####################################################################################
......@@ -514,6 +534,11 @@ if (BUILD_TESTING)
COMMAND turtle.test_Parseval
WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
### basic particle functionality
add_test(
NAME test_particles
COMMAND turtle.test_particles p2p_sampling on
WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
set_tests_properties(test_particles PROPERTIES TIMEOUT 2000)
add_test(
NAME test_tracer_set
COMMAND turtle TEST test_tracer_set -n 32 --np 2 --ntpp 2 --simname tracer_set_testsim
......@@ -521,7 +546,7 @@ if (BUILD_TESTING)
### compare DNS output to stored results
add_test(
NAME test_NSVEparticles
COMMAND turtle.test_NSVEparticles --np 2 --ntpp 2 --cpp_random_particles 0
COMMAND turtle.test_NSVEparticles --np 2 --ntpp 2
WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
set_tests_properties(test_NSVEparticles PROPERTIES TIMEOUT 2000)
### check whether data is messed up by p2p calculations
......
......@@ -24,20 +24,11 @@
import os
import sys
import pickle
import pkg_resources
__version__ = '@TURTLE_VERSION_LONG@'
__version__ = pkg_resources.require('TurTLE')[0].version
data_dir = os.path.join('@CMAKE_INSTALL_PREFIX@', 'share/TurTLE-@TURTLE_VERSION_LONG@')
_dist = pkg_resources.get_distribution('TurTLE')
dist_loc = os.path.realpath(_dist.location)
here = os.path.normcase(__file__)
header_dir = os.path.join(os.path.join(dist_loc, 'TurTLE'), 'cpp')
lib_dir = os.path.join(dist_loc, 'TurTLE')
homefolder = os.path.expanduser('~')
from .host_info import host_info
from .DNS import DNS
......
......@@ -11,8 +11,8 @@ import TurTLE._base
import TurTLE.DNS
from TurTLE._code import _code
cpp_location = os.path.join(os.path.join(
TurTLE.lib_dir, 'test'), 'profiler')
cpp_location = os.path.join(
TurTLE.data_dir, 'profiler')
class ADNS(TurTLE.DNS):
......
......@@ -11,8 +11,8 @@ import TurTLE._base
import TurTLE.DNS
from TurTLE._code import _code
cpp_location = os.path.join(os.path.join(
TurTLE.lib_dir, 'test'), 'particle_set')
cpp_location = os.path.join(
TurTLE.data_dir, 'particle_set')
class ADNS(TurTLE.DNS):
......
......@@ -20,7 +20,7 @@ def main():
['NSVE',
'-n', '32',
'--src-simname', 'B32p1e4',
'--src-wd', TurTLE.lib_dir + '/test',
'--src-wd', TurTLE.data_dir,
'--src-iteration', '0',
'--simname', 'dns_test',
'--np', '4',
......
......@@ -43,7 +43,7 @@ def basic_test():
c.simname = 'basic_cloud_test'
f0 = h5py.File(
os.path.join(
os.path.join(TurTLE.lib_dir, 'test'),
TurTLE.data_dir,
'B32p1e4_checkpoint_0.h5'),
'r')
ic_file = h5py.File(c.get_checkpoint_0_fname(), 'a')
......@@ -55,7 +55,7 @@ def basic_test():
'-n', '32',
'--src-simname', 'B32p1e4',
'--forcing_type', 'linear',
'--src-wd', TurTLE.lib_dir + '/test',
'--src-wd', TurTLE.data_dir,
'--src-iteration', '0',
'--simname', c.simname,
'--np', '4',
......@@ -70,7 +70,7 @@ def basic_test():
'--wd', './'])
f0 = h5py.File(
os.path.join(
os.path.join(TurTLE.lib_dir, 'test'),
TurTLE.data_dir,
'B32p1e4_checkpoint_0.h5'),
'r')
f1 = h5py.File(c.get_checkpoint_0_fname(), 'r')
......@@ -118,7 +118,7 @@ def nasty_test():
'--src-simname', 'B32p1e4',
'--simname', c.simname,
'--forcing_type', 'linear',
'--src-wd', TurTLE.lib_dir + '/test',
'--src-wd', TurTLE.data_dir,
'--src-iteration', '0',
'--np', '4',
'--ntpp', '2',
......
......@@ -27,7 +27,7 @@ def main():
['NSVEcomplex_particles',
'-n', '32',
'--src-simname', 'B32p1e4',
'--src-wd', TurTLE.lib_dir + '/test',
'--src-wd', TurTLE.data_dir,
'--src-iteration', '0',
'--np', '4',
'--ntpp', '1',
......@@ -37,6 +37,7 @@ def main():
'--checkpoints_per_file', '{0}'.format(3),
'--nparticles', '{0}'.format(nparticles),
'--particle-rand-seed', '2',
'--cpp_random_particles', '0',
'--njobs', '{0}'.format(njobs),
'--wd', './'] +
sys.argv[3:])
......
......@@ -49,7 +49,7 @@ def main_basic():
['NSVE',
'-n', '32',
'--src-simname', 'B32p1e4',
'--src-wd', TurTLE.lib_dir + '/test',
'--src-wd', TurTLE.data_dir,
'--src-iteration', '0',
'--simname', 'nsve_for_comparison',
'--np', '4',
......@@ -130,7 +130,7 @@ def main_long():
['NSVE',
'-n', '64',
'--src-simname', 'B32p1e4',
'--src-wd', TurTLE.lib_dir + '/test',
'--src-wd', TurTLE.data_dir,
'--src-iteration', '0',
'--simname', 'nsve_for_long_comparison',
'--np', '4',
......
......@@ -57,7 +57,7 @@ def main():
['NSVEparticles',
'-n', '32',
'--src-simname', 'B32p1e4',
'--src-wd', TurTLE.lib_dir + '/test',
'--src-wd', TurTLE.data_dir,
'--src-iteration', '0',
'--simname', 'dns_nsveparticles',
'--np', '4',
......@@ -69,12 +69,13 @@ def main():
'--checkpoints_per_file', '{0}'.format(3),
'--nparticles', '{0}'.format(nparticles),
'--particle-rand-seed', '2',
'--cpp_random_particles', '0',
'--njobs', '{0}'.format(njobs),
'--wd', './'] +
sys.argv[1:])
f0 = h5py.File(
os.path.join(
os.path.join(TurTLE.lib_dir, 'test'),
TurTLE.data_dir,
'B32p1e4_checkpoint_0.h5'),
'r')
f1 = h5py.File(c.get_checkpoint_0_fname(), 'r')
......
......@@ -48,8 +48,10 @@ enum kspace_dealias_type {ONE_HALF, TWO_THIRDS, SMOOTH};
* - has methods for filtering.
* - has CLOOP methods, useful for computing arbitrary formulas over the
* Fourier space grid (i.e. use lambda expressions).
*
* \tparam be field backend, currently only FFTW is possible.
* \tparam dt dealiasing mode, either ONE_HALF, TWO_THIRDS or SMOOTH.
*/
template <field_backend be,
kspace_dealias_type dt>
class kspace
......@@ -85,6 +87,10 @@ class kspace
typename fftw_interface<rnumber>::complex *__restrict__ a,
const double kmax);
/**
* \tparam rnumber type of real number, float or double.
* \tparam fc field components, ONE, THREE or THREExTHREE.
*/
template <typename rnumber,
field_components fc>
void Gauss_filter(
......@@ -103,6 +109,11 @@ class kspace
typename fftw_interface<rnumber>::complex *__restrict__ a,
const double sigma);
/**
* \tparam rnumber type of real number, float or double.
* \tparam fc field components, ONE, THREE or THREExTHREE.
* \return exit mode (integer), EXIT_SUCCESS or arbitrary value for failure.
*/
template <typename rnumber,
field_components fc>
int filter(
......
################################################################################
# #
# Copyright 2019 Max Planck Institute for Dynamics and Self-Organization #
# #
# This file is part of TurTLE. #
# #
# TurTLE is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published #
# by the Free Software Foundation, either version 3 of the License, #
# or (at your option) any later version. #
# #
# TurTLE is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with TurTLE. If not, see <http://www.gnu.org/licenses/> #
# #
# Contact: Cristian.Lalescu@ds.mpg.de #
# #
################################################################################
import datetime
import subprocess
def main():
# get current time
now = datetime.datetime.now()
# obtain version
try:
git_branch = subprocess.check_output(['git',
'rev-parse',
'--abbrev-ref',
'HEAD']).strip().split()[-1].decode()
git_revision = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip()
git_date = datetime.datetime.fromtimestamp(int(subprocess.check_output(['git', 'log', '-1', '--format=%ct']).strip()))
except:
git_revision = ''
git_branch = ''
git_date = now
if git_branch == '':
# there's no git available or something
VERSION = '{0:0>4}{1:0>2}{2:0>2}.{3:0>2}{4:0>2}{5:0>2}'.format(
git_date.year, git_date.month, git_date.day,
git_date.hour, git_date.minute, git_date.second)
VERSION_py = VERSION
else:
VERSION = subprocess.check_output(['git', 'describe', '--tags']).strip().decode().split('-')[0]
if (('develop' in git_branch) or
('feature' in git_branch) or
('bugfix' in git_branch)):
VERSION_py = subprocess.check_output(
['git', 'describe', '--tags', '--dirty']).strip().decode().replace('-g', '+g').replace('-dirty', '.dirty').replace('-', '.post')
else:
VERSION_py = VERSION
print(VERSION_py)
return VERSION_py
if __name__ == '__main__':
main()
......@@ -26,65 +26,20 @@
AUTHOR = 'Cristian C Lalescu'
AUTHOR_EMAIL = 'Cristian.Lalescu@ds.mpg.de'
import os
import shutil
import datetime
import sys
import subprocess
import pickle
### package versioning
import get_version
VERSION = get_version.main()
VERSION = '@TURTLE_VERSION_LONG@'
print('This is TurTLE version ' + VERSION)
import distutils.cmd
class CompileLibCommand(distutils.cmd.Command):
description = 'Compile TurTLE library.'
user_options = [
('timing-output=', None, 'Toggle timing output.'),
('fftw-estimate=', None, 'Use FFTW ESTIMATE.'),
('split-fftw-many=', None, 'Turn on SPLIT_FFTW_MANY.'),
('disable-fftw-omp=', None, 'Turn Off FFTW OpenMP.'),
]
def initialize_options(self):
self.timing_output = 0
self.fftw_estimate = 0
self.disable_fftw_omp = 0
self.split_fftw_many = 0
return None
def finalize_options(self):
self.timing_output = (int(self.timing_output) == 1)
self.split_fftw_many = (int(self.split_fftw_many) == 1)
self.fftw_estimate = (int(self.fftw_estimate) == 1)
self.disable_fftw_omp = (int(self.disable_fftw_omp) == 1)
return None
def run(self):
### save compiling information
pickle.dump(
{'install_date' : now,
'VERSION' : VERSION,
'git_revision' : git_revision},
open('turtle/install_info.pickle', 'wb'),
protocol = 2)
return None
from setuptools import setup
setup(
name = 'TurTLE',
packages = ['TurTLE', 'TurTLE/test'],
install_requires = ['numpy>=1.8', 'h5py>=2.2.1'],
package_data = {'TurTLE': ['test/B32p1e4_checkpoint_0.h5',
'test/particle_set/NSVEparticle_set.hpp',
'test/particle_set/NSVEparticle_set.cpp',
'test/profiler/scalar_evolution.hpp',
'test/profiler/scalar_evolution.cpp',
'test/profiler/Kraichnan_scalar_v1.hpp',
'test/profiler/Kraichnan_scalar_v1.cpp',
]},
# package data is installed by CMake
#package_data = {'TurTLE': []},
entry_points = {
'console_scripts': [
'turtle = TurTLE.__main__:main',
......
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