Michael Uleysky
1 year ago
10 changed files with 105 additions and 64 deletions
@ -1,22 +1,13 @@
|
||||
#pragma once |
||||
#include "BFileW.h" |
||||
#include "ParseArgs.h" |
||||
#include "traits.h" |
||||
#include "actiondep.h" |
||||
#include <memory> |
||||
|
||||
using michlib::BFileW; |
||||
using michlib::Cos; |
||||
using michlib::M_PI; |
||||
|
||||
class ActionGenIntFile |
||||
{ |
||||
public: |
||||
static constexpr const char* name = "genintfile"; |
||||
|
||||
template<class T> static constexpr bool IsSupported = ReadIsGrid<T>; |
||||
|
||||
template<class D> static MString DoAction(const CLArgs& args, D& data); |
||||
}; |
||||
ADD_ACTION(GenIntFile, genintfile, ReadIsGrid<Source>); |
||||
|
||||
template<class D> MString ActionGenIntFile::DoAction(const CLArgs& args, D& ds) |
||||
{ |
@ -0,0 +1,15 @@
|
||||
#pragma once |
||||
#include "actiondep.h" |
||||
#include "merrors.h" |
||||
|
||||
using michlib::message; |
||||
|
||||
ADD_ACTION(Info, info, InfoSupported<Source>); |
||||
|
||||
template<class D> MString ActionInfo::DoAction([[maybe_unused]] const CLArgs& args, D& data) |
||||
{ |
||||
auto info = data.Info(); |
||||
if(!info.Exist()) return "No info"; |
||||
message(info); |
||||
return ""; |
||||
}; |
@ -1,19 +1,11 @@
|
||||
#pragma once |
||||
#include "ParseArgs.h" |
||||
#include "traits.h" |
||||
#include "actiondep.h" |
||||
#include "BFileW.h" |
||||
#include <memory> |
||||
|
||||
using michlib::BFileW; |
||||
|
||||
class ActionTSC |
||||
{ |
||||
public: |
||||
static constexpr const char* name = "tsc"; |
||||
|
||||
template<class T> static constexpr bool IsSupported = ReadPSupported<T> || ReadSupported<T>; |
||||
|
||||
template<class D> static MString DoAction(const CLArgs& args, D& data); |
||||
}; |
||||
ADD_ACTION(TSC, tsc, ReadPSupported<Source> || ReadSupported<Source>); |
||||
|
||||
template<class D> MString ActionTSC::DoAction(const CLArgs& args, D& ds) |
||||
{ |
@ -1,16 +1,11 @@
|
||||
#pragma once |
||||
#include "ParseArgs.h" |
||||
#include "traits.h" |
||||
#include "actiondep.h" |
||||
#include "BFileW.h" |
||||
#include <memory> |
||||
|
||||
class ActionUV |
||||
{ |
||||
public: |
||||
static constexpr const char* name = "uv"; |
||||
|
||||
template<class T> static constexpr bool IsSupported = ReadPSupported<T> || ReadSupported<T>; |
||||
using michlib::BFileW; |
||||
|
||||
template<class D> static MString DoAction(const CLArgs& args, D& data); |
||||
}; |
||||
ADD_ACTION(UV, uv, ReadPSupported<Source> || ReadSupported<Source>); |
||||
|
||||
template<class D> MString ActionUV::DoAction(const CLArgs& args, D& ds) |
||||
{ |
@ -0,0 +1,16 @@
|
||||
#pragma once |
||||
#include "ParseArgs.h" |
||||
#include "traits.h" |
||||
|
||||
#if defined GENACTIONLIST |
||||
#define ADD_ACTION(actclass, actname, suptest) ADD ACTION CLASS: actclass |
||||
#else |
||||
#define ADD_ACTION(actclass, actname, suptest) \ |
||||
class Action##actclass \
|
||||
{ \
|
||||
public: \
|
||||
static constexpr const char* name = #actname; \
|
||||
template<class Source> static constexpr bool IsSupported = (suptest); \
|
||||
template<class Source> static MString DoAction(const CLArgs& args, Source& data); \
|
||||
}; |
||||
#endif |
@ -1,24 +0,0 @@
|
||||
#pragma once |
||||
#include "ParseArgs.h" |
||||
#include "merrors.h" |
||||
#include "traits.h" |
||||
|
||||
using michlib::message; |
||||
|
||||
class ActionInfo |
||||
{ |
||||
public: |
||||
static constexpr const char* name = "info"; |
||||
|
||||
template<class T> static constexpr bool IsSupported = InfoSupported<T>; |
||||
|
||||
template<class D> static MString DoAction(const CLArgs& args, D& data); |
||||
}; |
||||
|
||||
template<class D> MString ActionInfo::DoAction([[maybe_unused]] const CLArgs& args, D& data) |
||||
{ |
||||
auto info = data.Info(); |
||||
if(!info.Exist()) return "No info"; |
||||
message(info); |
||||
return ""; |
||||
}; |
@ -0,0 +1,53 @@
|
||||
#!/bin/bash |
||||
|
||||
DIR="$(dirname $0)/../include" |
||||
COMPILER="$1" |
||||
OUT="$2" |
||||
shift |
||||
shift |
||||
declare -a EXCLUDE_ACTIONS=( $@ ) |
||||
|
||||
included() |
||||
{ |
||||
local name="$1" |
||||
|
||||
local i=0 |
||||
while [ $i -lt ${#EXCLUDE_ACTIONS[@]} ]; do |
||||
if [ "$name" == "${EXCLUDE_ACTIONS[$i]}" ]; then |
||||
return 1 |
||||
fi |
||||
let i++ |
||||
done |
||||
return 0 |
||||
} |
||||
|
||||
if [ -z "$COMPILER" ]; then |
||||
exit 1 |
||||
fi |
||||
|
||||
actlist="" |
||||
echo "">"$OUT" |
||||
|
||||
cdir="$(pwd)" |
||||
pushd "$DIR">/dev/null |
||||
for f in ../actions/action*.h ../actions-add/action*.h; do |
||||
if [ -f "$f" ]; then |
||||
# echo Compiler=$COMPILER |
||||
# echo Exclude list=${EXCLUDE_ACTIONS[@]} |
||||
name="$($COMPILER -E -DGENACTIONLIST "$f" 2>/dev/null| grep "ADD ACTION CLASS: " | sed "s/.*: //")" |
||||
name=${name//;/} |
||||
if included "$name"; then |
||||
pushd "$cdir">/dev/null |
||||
echo "#include \"$f\"">>"$OUT" |
||||
actlist+=" Action$name" |
||||
popd>/dev/null |
||||
fi |
||||
fi |
||||
done |
||||
|
||||
actlist=${actlist## } |
||||
actlist=${actlist%% } |
||||
actlist=${actlist// /,} |
||||
pushd "$cdir">/dev/null |
||||
echo "#define ACTLIST $actlist">>"$OUT" |
||||
popd>/dev/null |
@ -1,13 +1,18 @@
|
||||
set(EXENAME odm) |
||||
set(ACTIONLIST ../include/actionlist.h) |
||||
set(GENALIST ${CMAKE_SOURCE_DIR}/scripts/genactionslist) |
||||
|
||||
find_library(netcdf netcdf REQUIRED) |
||||
find_package(OpenMP REQUIRED) |
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") |
||||
|
||||
include_directories(../michlib/michlib) |
||||
file(GLOB srcs CONFIGURE_DEPENDS *.cpp) |
||||
add_executable(${EXENAME} ${srcs} ${ACTIONLIST}) |
||||
target_include_directories(${EXENAME} PRIVATE ../michlib/michlib ${CMAKE_CURRENT_BINARY_DIR}/../include) |
||||
|
||||
file(GLOB actfiles CONFIGURE_DEPENDS ../actions/action*.h ../actions-add/action*.h) |
||||
add_custom_command(OUTPUT ${ACTIONLIST} COMMAND ${GENALIST} ARGS "${CMAKE_CXX_COMPILER} -I$<JOIN:$<TARGET_PROPERTY:${EXENAME},INCLUDE_DIRECTORIES>, -I>" ${ACTIONLIST} ${EXCLUDE_ACTIONS} DEPENDS ${GENALIST} ${actfiles}) |
||||
|
||||
file(GLOB srcs *.cpp) |
||||
add_executable(${EXENAME} ${srcs}) |
||||
target_link_libraries(${EXENAME} ${linker_options} ${netcdf} OpenMP::OpenMP_CXX teos) |
||||
set_target_properties(${EXENAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) |
||||
install(TARGETS ${EXENAME}) |
||||
|
Loading…
Reference in new issue