Skip to content

Commit 557e45d

Browse files
Merge pull request #74 from nextsimdg/develop
Minimum Viable Model from develop.
2 parents f27de8c + e839aca commit 557e45d

File tree

151 files changed

+8119
-614
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+8119
-614
lines changed

.clang-format

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: WebKit
4+
AccessModifierOffset: -4
5+
AlignAfterOpenBracket: DontAlign
6+
AlignConsecutiveMacros: None
7+
AlignConsecutiveAssignments: None
8+
AlignConsecutiveBitFields: None
9+
AlignConsecutiveDeclarations: None
10+
AlignEscapedNewlines: Right
11+
AlignOperands: DontAlign
12+
AlignTrailingComments: false
13+
AllowAllArgumentsOnNextLine: true
14+
AllowAllConstructorInitializersOnNextLine: true
15+
AllowAllParametersOfDeclarationOnNextLine: true
16+
AllowShortEnumsOnASingleLine: true
17+
AllowShortBlocksOnASingleLine: Empty
18+
AllowShortCaseLabelsOnASingleLine: false
19+
AllowShortFunctionsOnASingleLine: All
20+
AllowShortLambdasOnASingleLine: All
21+
AllowShortIfStatementsOnASingleLine: Never
22+
AllowShortLoopsOnASingleLine: false
23+
AlwaysBreakAfterDefinitionReturnType: None
24+
AlwaysBreakAfterReturnType: None
25+
AlwaysBreakBeforeMultilineStrings: false
26+
AlwaysBreakTemplateDeclarations: MultiLine
27+
AttributeMacros:
28+
- __capability
29+
BinPackArguments: true
30+
BinPackParameters: true
31+
BraceWrapping:
32+
AfterCaseLabel: false
33+
AfterClass: false
34+
AfterControlStatement: Never
35+
AfterEnum: false
36+
AfterFunction: true
37+
AfterNamespace: false
38+
AfterObjCDeclaration: false
39+
AfterStruct: false
40+
AfterUnion: false
41+
AfterExternBlock: false
42+
BeforeCatch: false
43+
BeforeElse: false
44+
BeforeLambdaBody: false
45+
BeforeWhile: false
46+
IndentBraces: false
47+
SplitEmptyFunction: true
48+
SplitEmptyRecord: true
49+
SplitEmptyNamespace: true
50+
BreakBeforeBinaryOperators: All
51+
BreakBeforeConceptDeclarations: true
52+
BreakBeforeBraces: WebKit
53+
BreakBeforeInheritanceComma: false
54+
BreakInheritanceList: BeforeColon
55+
BreakBeforeTernaryOperators: true
56+
BreakConstructorInitializersBeforeComma: false
57+
BreakConstructorInitializers: BeforeComma
58+
BreakAfterJavaFieldAnnotations: false
59+
BreakStringLiterals: true
60+
ColumnLimit: 100
61+
CommentPragmas: '^ IWYU pragma:'
62+
CompactNamespaces: false
63+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
64+
ConstructorInitializerIndentWidth: 4
65+
ContinuationIndentWidth: 4
66+
Cpp11BracedListStyle: false
67+
DeriveLineEnding: true
68+
DerivePointerAlignment: false
69+
DisableFormat: false
70+
EmptyLineBeforeAccessModifier: LogicalBlock
71+
ExperimentalAutoDetectBinPacking: false
72+
FixNamespaceComments: false
73+
ForEachMacros:
74+
- foreach
75+
- Q_FOREACH
76+
- BOOST_FOREACH
77+
StatementAttributeLikeMacros:
78+
- Q_EMIT
79+
IncludeBlocks: Preserve
80+
IncludeCategories:
81+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
82+
Priority: 2
83+
SortPriority: 0
84+
CaseSensitive: false
85+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
86+
Priority: 3
87+
SortPriority: 0
88+
CaseSensitive: false
89+
- Regex: '.*'
90+
Priority: 1
91+
SortPriority: 0
92+
CaseSensitive: false
93+
IncludeIsMainRegex: '(Test)?$'
94+
IncludeIsMainSourceRegex: ''
95+
IndentCaseLabels: false
96+
IndentCaseBlocks: false
97+
IndentGotoLabels: true
98+
IndentPPDirectives: None
99+
IndentExternBlock: AfterExternBlock
100+
IndentRequires: false
101+
IndentWidth: 4
102+
IndentWrappedFunctionNames: false
103+
InsertTrailingCommas: None
104+
JavaScriptQuotes: Leave
105+
JavaScriptWrapImports: true
106+
KeepEmptyLinesAtTheStartOfBlocks: true
107+
MacroBlockBegin: ''
108+
MacroBlockEnd: ''
109+
MaxEmptyLinesToKeep: 1
110+
NamespaceIndentation: Inner
111+
ObjCBinPackProtocolList: Auto
112+
ObjCBlockIndentWidth: 4
113+
ObjCBreakBeforeNestedBlockParam: true
114+
ObjCSpaceAfterProperty: true
115+
ObjCSpaceBeforeProtocolList: true
116+
PenaltyBreakAssignment: 2
117+
PenaltyBreakBeforeFirstCallParameter: 19
118+
PenaltyBreakComment: 300
119+
PenaltyBreakFirstLessLess: 120
120+
PenaltyBreakString: 1000
121+
PenaltyBreakTemplateDeclaration: 10
122+
PenaltyExcessCharacter: 1000000
123+
PenaltyReturnTypeOnItsOwnLine: 60
124+
PenaltyIndentedWhitespace: 0
125+
PointerAlignment: Left
126+
ReflowComments: true
127+
SortIncludes: true
128+
SortJavaStaticImport: Before
129+
SortUsingDeclarations: true
130+
SpaceAfterCStyleCast: false
131+
SpaceAfterLogicalNot: false
132+
SpaceAfterTemplateKeyword: true
133+
SpaceBeforeAssignmentOperators: true
134+
SpaceBeforeCaseColon: false
135+
SpaceBeforeCpp11BracedList: true
136+
SpaceBeforeCtorInitializerColon: true
137+
SpaceBeforeInheritanceColon: true
138+
SpaceBeforeParens: ControlStatements
139+
SpaceAroundPointerQualifiers: Default
140+
SpaceBeforeRangeBasedForLoopColon: true
141+
SpaceInEmptyBlock: true
142+
SpaceInEmptyParentheses: false
143+
SpacesBeforeTrailingComments: 1
144+
SpacesInAngles: false
145+
SpacesInConditionalStatement: false
146+
SpacesInContainerLiterals: true
147+
SpacesInCStyleCastParentheses: false
148+
SpacesInParentheses: false
149+
SpacesInSquareBrackets: false
150+
SpaceBeforeSquareBrackets: false
151+
BitFieldColonSpacing: Both
152+
Standard: Latest
153+
StatementMacros:
154+
- Q_UNUSED
155+
- QT_REQUIRE_VERSION
156+
TabWidth: 8
157+
UseCRLF: false
158+
UseTab: Never
159+
WhitespaceSensitiveMacros:
160+
- STRINGIZE
161+
- PP_STRINGIZE
162+
- BOOST_PP_STRINGIZE
163+
- NS_SWIFT_NAME
164+
- CF_SWIFT_NAME
165+
...
166+
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: compile code and tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop, issue15_CI_workflow ]
6+
pull_request:
7+
branches: [ main, develop, issue15_CI_workflow ]
8+
9+
jobs:
10+
11+
clang-on-mac:
12+
13+
runs-on: macos-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: clang
18+
run: |
19+
brew install clang-format
20+
cd core/src
21+
clang-format --dry-run -Werror *cpp include/*hpp
22+
cd -
23+
for component in physics
24+
do
25+
cd $component/src
26+
clang-format --dry-run -Werror *cpp include/*hpp
27+
cd -
28+
done
29+
30+
31+
build-on-ubuntu:
32+
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- uses: actions/checkout@v2
37+
- name: installs
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install netcdf-bin libnetcdf-c++4-dev libboost-all-dev cmake
41+
git clone -b v2.x https://github.com/catchorg/Catch2.git
42+
cd Catch2
43+
cmake -Bbuild -H. -DBUILD_TESTING=OFF
44+
sudo cmake --build build/ --target install
45+
cd ..
46+
- name: make
47+
run: |
48+
cmake .
49+
make
50+
51+
build-on-mac:
52+
53+
runs-on: macos-latest
54+
55+
steps:
56+
- uses: actions/checkout@v2
57+
- name: installs
58+
run: |
59+
brew install netcdf
60+
brew install boost
61+
brew install catch2
62+
brew install cmake
63+
- name: make
64+
run: |
65+
cmake .
66+
make
67+
68+
69+
70+
tests-on-mac:
71+
72+
runs-on: macos-latest
73+
74+
steps:
75+
- uses: actions/checkout@v2
76+
- name: installs
77+
run: |
78+
brew install netcdf
79+
brew install boost
80+
brew install catch2
81+
brew install cmake
82+
- name: make
83+
run: |
84+
cmake .
85+
make
86+
- name: run tests
87+
run: |
88+
cd core/test
89+
for file in $(ls test*); do ./$file; done
90+
cd -
91+
for component in physics
92+
do
93+
cd $component/test
94+
for file in $(ls test*); do ./$file; done
95+
cd -
96+
done
97+
98+
99+
tests-on-ubuntu:
100+
101+
runs-on: ubuntu-latest
102+
103+
steps:
104+
- uses: actions/checkout@v2
105+
- name: installs
106+
run: |
107+
sudo apt-get update
108+
sudo apt-get install netcdf-bin libnetcdf-c++4-dev libboost-all-dev cmake
109+
git clone -b v2.x https://github.com/catchorg/Catch2.git
110+
cd Catch2
111+
cmake -Bbuild -H. -DBUILD_TESTING=OFF
112+
sudo cmake --build build/ --target install
113+
cd ..
114+
- name: make
115+
run: |
116+
cmake .
117+
make
118+
- name: run tests
119+
run: |
120+
cd core/test
121+
for file in $(ls test*); do ./$file; done
122+
cd -
123+
for component in physics
124+
do
125+
cd $component/test
126+
for file in $(ls test*); do ./$file; done
127+
cd -
128+
done

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
/build/
22
/.cproject
33
/.project
4-
/.settings/*
4+
/.pydevproject
5+
/.settings/*
6+
/src/modules/generated/moduleLoader*.ipp
7+
/*/src/modules/generated/moduleLoader*.ipp
8+
/run/restart.nc
9+
/run/nextsim
10+
/run/.DS_Store

CMakeLists.txt

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,68 @@
1-
cmake_minimum_required(VERSION 3.1.0)
1+
cmake_minimum_required(VERSION 3.12)
22

33
set(CMAKE_CXX_STANDARD 11)
44

55
project(framework_dg)
66

7+
set (NETCDF_CXX "YES")
78
find_package(netCDF REQUIRED)
8-
find_package(Boost REQUIRED)
9+
if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin")
10+
set(NSDG_NetCDF_Library "netcdf-cxx4")
11+
else()
12+
set(NSDG_NetCDF_Library "netcdf_c++4")
13+
endif()
14+
find_package(Boost COMPONENTS program_options REQUIRED)
915
find_package(Catch2 REQUIRED)
1016

1117
# To add netCDF to a target:
1218
# target_include_directories(target PUBLIC ${netCDF_INCLUDE_DIR})
1319
# target_link_directories(target PUBLIC ${netCDF_LIB_DIR})
14-
# target_link_libraries(target LINK_PUBLIC netcdf-cxx4)
20+
# target_link_libraries(target LINK_PUBLIC "${NSDG_NetCDF_Library}")
1521

16-
# Build the main model
17-
add_subdirectory(src)
22+
# Set the location of the ipp files used by ModuleLoader for the main build
23+
set(ModuleLoaderIppTargetDirectory
24+
"${CMAKE_CURRENT_SOURCE_DIR}/core/src/modules/generated/")
1825

19-
# Testing
20-
if (NOT(CMAKE_BUILD_TYPE STREQUAL "Release"))
21-
add_subdirectory(test)
22-
endif()
26+
file(MAKE_DIRECTORY "${ModuleLoaderIppTargetDirectory}")
27+
# Set the list of components that define modules. Component subdirectories are
28+
# contained in this directory level and contain src/modules/ and
29+
# src/modules/include/ subdirectories
30+
set(ModularComponents
31+
"physics"
32+
)
33+
34+
# Set the components which provide source or object code to the main model
35+
set(CodeComponents
36+
"physics"
37+
#"dynamics"
38+
)
39+
40+
# Set an empty list of sources
41+
set(NextsimSources "")
42+
43+
# Set an empty list of include directories
44+
set(NextsimIncludeDirs "")
45+
46+
# Build the core model. Defines the 'parse_modules' target
47+
add_subdirectory(core)
48+
49+
# Build all components
50+
foreach(compo ${CodeComponents})
51+
add_subdirectory("${compo}")
52+
endforeach()
53+
54+
# Link the model
55+
add_executable(nextsim "${NextsimSources}")
56+
57+
target_include_directories(nextsim PRIVATE
58+
"${CMAKE_CURRENT_SOURCE_DIR}"
59+
"${Boost_INCLUDE_DIRS}"
60+
"${ModuleLoaderIppTargetDirectory}"
61+
"${NextsimIncludeDirs}"
62+
"${netCDF_INCLUDE_DIR}"
63+
)
64+
target_link_directories(nextsim PUBLIC "${netCDF_LIB_DIR}")
65+
target_link_libraries(nextsim LINK_PUBLIC ${Boost_LIBRARIES} "${NSDG_NetCDF_Library}")
66+
67+
#The parse_modules target is inherited from src
68+
add_dependencies(nextsim parse_modules)

0 commit comments

Comments
 (0)