diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000000000000000000000000000000000..e5eccc50d08c706317b1a16ebb8135ac0bd7ee9e --- /dev/null +++ b/.clang-format @@ -0,0 +1,191 @@ +--- +Language: Cpp +# BasedOnStyle: GNU +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveMacros: None +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: All +AlwaysBreakAfterReturnType: AllDefinitions +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +AttributeMacros: + - __capability +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: All +BreakBeforeConceptDeclarations: true +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +QualifierAlignment: Leave +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: BinPack +BasedOnStyle: '' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +AllowAllConstructorInitializersOnNextLine: true +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: None +IndentExternBlock: false +IndentRequires: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertTrailingCommas: None +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +LambdaBodyIndentation: Signature +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 100 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PenaltyIndentedWhitespace: 0 +PointerAlignment: Right +PPIndentWidth: -1 +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: Never +SortJavaStaticImport: Before +SortUsingDeclarations: true +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + BeforeNonEmptyParentheses: false +SpaceAroundPointerQualifiers: Default +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Never +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +BitFieldColonSpacing: Both +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE + - NS_SWIFT_NAME + - CF_SWIFT_NAME +... diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..17f9f7aa08a40428145912a626ed411175025f08 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,44 @@ +stages: + - build_and_test + +gcc11: + stage: build_and_test + before_script: + - . /sw/etc/profile.levante && module use /sw/spack-levante/spack/modules && module list + script: + - module load gcc/11.2.0-gcc-11.2.0 + - mkdir gcc112 + - cd gcc112 + - /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_C_COMPILER=gcc -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_CXX_COMPILER=g++ + - make VERBOSE=1 + - make test + tags: + - xen, levante + +intel22: + stage: build_and_test + before_script: + - . /sw/etc/profile.levante && module use /sw/spack-levante/spack/modules && module list + script: + - module load gcc/11.2.0-gcc-11.2.0 intel-oneapi-compilers/2022.0.1-gcc-11.2.0 + - mkdir intel22 + - cd intel22 + - /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_C_COMPILER=icc -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_CXX_COMPILER=icpc -DCMAKE_BUILD_RPATH=/sw/spack-levante/gcc-11.2.0-bcn7mb/lib64 + - make VERBOSE=1 + - make test + tags: + - xen, levante + +nvhpc: + stage: build_and_test + before_script: + - . /sw/etc/profile.levante && module use /sw/spack-levante/spack/modules && module list + script: + - module load gcc/11.2.0-gcc-11.2.0 nvhpc/22.5-gcc-11.2.0 + - mkdir nvhpc + - cd nvhpc + - /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_C_COMPILER=nvc -DCMAKE_Fortran_COMPILER=nvfortran -DCMAKE_CXX_COMPILER=nvc++ + - make VERBOSE=1 + - make test + tags: + - xen, levante \ No newline at end of file diff --git a/src/util_arithmetic_expr.hpp b/src/util_arithmetic_expr.hpp index 541cacdbc109dc895a8a68784c974612df51b1d7..8aa75f7f0fc0249d1c8a55f681ff435bef756562 100644 --- a/src/util_arithmetic_expr.hpp +++ b/src/util_arithmetic_expr.hpp @@ -5,45 +5,35 @@ #define NUM_FCT 9 #define MAX_NAME_LEN 32 -#ifdef __cplusplus -extern "C" { -#endif - -int priority(char op); - -#ifdef __cplusplus -} -#endif - typedef enum { VARIABLE, VALUE, OPERATOR, FUNCTION } expr_type; typedef enum { - EXP = 0, - LOG = 1, - SIN = 2, - COS = 3, - MIN = 4, - MAX = 5, - IF = 6, - SQRT = 7, - ERF = 8 + EXP = 0, + LOG = 1, + SIN = 2, + COS = 3, + MIN = 4, + MAX = 5, + IF = 6, + SQRT = 7, + ERF = 8 } fct_type; extern const char *const fct_name[NUM_FCT]; /* Data type for postfix stack and queue (shunting yard algorithm) */ struct t_item { - expr_type type; + expr_type type; - char op; - double val; - fct_type fct; - char field[MAX_NAME_LEN]; + char op; + double val; + fct_type fct; + char field[MAX_NAME_LEN]; }; /* Data type for stack or queue. */ struct t_list { - int size; - struct t_item list[1024]; + int size; + struct t_item list[1024]; }; /* takes a string as input and generates a post-fix parse tree. */ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a0523101b0bf8ddc82d40fa02b9edf55799c7e6e..497cca3447c2daedba07c80ac7351bf8800bebcb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,12 +1,13 @@ +include(FetchContent) +if ("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.24") + cmake_policy(SET CMP0135 NEW) +endif() + enable_language(CXX) find_package(GTest 1.13) if(NOT GTest_FOUND) - if ("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.24") - cmake_policy(SET CMP0135 NEW) - endif() message(CHECK_START "Fetching external GTest") - include(FetchContent) FetchContent_Declare(googletest URL https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz URL_HASH MD5=95b29f0038ec84a611df951d74d99897 @@ -16,10 +17,10 @@ if(NOT GTest_FOUND) message(CHECK_PASS "done") endif() -add_executable(UtilArithmeticExprTest util_arithmetic_expr.cpp) -target_link_libraries(UtilArithmeticExprTest - PRIVATE - fortran-support::fortran-support - GTest::gtest_main +message(CHECK_START "Fetching external FortUTF") +FetchContent_Declare(fortutf + URL https://github.com/artemis-beta/FortUTF/archive/9f70d03c5d92c4023b1eab312af18ff56790c00a.tar.gz + URL_HASH MD5=143941264dc552599ab7b32fd17c4195 ) -add_test(NAME UtilArithmeticExprTest COMMAND UtilArithmeticExprTest) +FetchContent_MakeAvailable(fortutf) +message(CHECK_PASS "done") \ No newline at end of file diff --git a/test/util_arithmetic_expr.cpp b/test/util_arithmetic_expr.cpp deleted file mode 100644 index bf826065e64c2fd67334f0716d14bc2108809da1..0000000000000000000000000000000000000000 --- a/test/util_arithmetic_expr.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include <gtest/gtest.h> - -#include <util_arithmetic_expr.hpp> - -class UtilArithmeticExprTest : public ::testing::Test {}; - -TEST_F(UtilArithmeticExprTest, CanReturnPriority) { - const char *op = "+"; - EXPECT_NO_THROW(int x = priority(*op)); -} - -TEST_F(UtilArithmeticExprTest, PriorityIsCorrect) { - const char *op_parentheses = "("; - const char *op_greater = ">"; - const char *op_lesser = "<"; - const char *op_plus = "+"; - const char *op_minus = "-"; - const char *op_divide = "/"; - const char *op_multiply = "*"; - const char *op_power = "^"; - - int parentheses = priority(*op_parentheses); - int greater = priority(*op_greater); - int lesser = priority(*op_lesser); - int plus = priority(*op_plus); - int minus = priority(*op_minus); - int divide = priority(*op_divide); - int multiply = priority(*op_multiply); - int power = priority(*op_power); - - EXPECT_EQ(parentheses, 0); - EXPECT_EQ(greater, 1); - EXPECT_EQ(lesser, 1); - EXPECT_EQ(plus, 2); - EXPECT_EQ(minus, 2); - EXPECT_EQ(divide, 3); - EXPECT_EQ(multiply, 3); - EXPECT_EQ(power, 4); -}