Skip to content

Commit

Permalink
Merge pull request #74 from nextsimdg/develop
Browse files Browse the repository at this point in the history
Minimum Viable Model from develop.
  • Loading branch information
timspainNERSC authored Feb 11, 2022
2 parents f27de8c + e839aca commit 557e45d
Show file tree
Hide file tree
Showing 151 changed files with 8,119 additions and 614 deletions.
166 changes: 166 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: WebKit
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
StatementAttributeLikeMacros:
- Q_EMIT
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
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
...

128 changes: 128 additions & 0 deletions .github/workflows/clang-compile-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: compile code and tests

on:
push:
branches: [ main, develop, issue15_CI_workflow ]
pull_request:
branches: [ main, develop, issue15_CI_workflow ]

jobs:

clang-on-mac:

runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: clang
run: |
brew install clang-format
cd core/src
clang-format --dry-run -Werror *cpp include/*hpp
cd -
for component in physics
do
cd $component/src
clang-format --dry-run -Werror *cpp include/*hpp
cd -
done

build-on-ubuntu:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: installs
run: |
sudo apt-get update
sudo apt-get install netcdf-bin libnetcdf-c++4-dev libboost-all-dev cmake
git clone -b v2.x https://github.com/catchorg/Catch2.git
cd Catch2
cmake -Bbuild -H. -DBUILD_TESTING=OFF
sudo cmake --build build/ --target install
cd ..
- name: make
run: |
cmake .
make
build-on-mac:

runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: installs
run: |
brew install netcdf
brew install boost
brew install catch2
brew install cmake
- name: make
run: |
cmake .
make
tests-on-mac:

runs-on: macos-latest

steps:
- uses: actions/checkout@v2
- name: installs
run: |
brew install netcdf
brew install boost
brew install catch2
brew install cmake
- name: make
run: |
cmake .
make
- name: run tests
run: |
cd core/test
for file in $(ls test*); do ./$file; done
cd -
for component in physics
do
cd $component/test
for file in $(ls test*); do ./$file; done
cd -
done
tests-on-ubuntu:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: installs
run: |
sudo apt-get update
sudo apt-get install netcdf-bin libnetcdf-c++4-dev libboost-all-dev cmake
git clone -b v2.x https://github.com/catchorg/Catch2.git
cd Catch2
cmake -Bbuild -H. -DBUILD_TESTING=OFF
sudo cmake --build build/ --target install
cd ..
- name: make
run: |
cmake .
make
- name: run tests
run: |
cd core/test
for file in $(ls test*); do ./$file; done
cd -
for component in physics
do
cd $component/test
for file in $(ls test*); do ./$file; done
cd -
done
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/build/
/.cproject
/.project
/.settings/*
/.pydevproject
/.settings/*
/src/modules/generated/moduleLoader*.ipp
/*/src/modules/generated/moduleLoader*.ipp
/run/restart.nc
/run/nextsim
/run/.DS_Store
64 changes: 55 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,68 @@
cmake_minimum_required(VERSION 3.1.0)
cmake_minimum_required(VERSION 3.12)

set(CMAKE_CXX_STANDARD 11)

project(framework_dg)

set (NETCDF_CXX "YES")
find_package(netCDF REQUIRED)
find_package(Boost REQUIRED)
if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin")
set(NSDG_NetCDF_Library "netcdf-cxx4")
else()
set(NSDG_NetCDF_Library "netcdf_c++4")
endif()
find_package(Boost COMPONENTS program_options REQUIRED)
find_package(Catch2 REQUIRED)

# To add netCDF to a target:
# target_include_directories(target PUBLIC ${netCDF_INCLUDE_DIR})
# target_link_directories(target PUBLIC ${netCDF_LIB_DIR})
# target_link_libraries(target LINK_PUBLIC netcdf-cxx4)
# target_link_libraries(target LINK_PUBLIC "${NSDG_NetCDF_Library}")

# Build the main model
add_subdirectory(src)
# Set the location of the ipp files used by ModuleLoader for the main build
set(ModuleLoaderIppTargetDirectory
"${CMAKE_CURRENT_SOURCE_DIR}/core/src/modules/generated/")

# Testing
if (NOT(CMAKE_BUILD_TYPE STREQUAL "Release"))
add_subdirectory(test)
endif()
file(MAKE_DIRECTORY "${ModuleLoaderIppTargetDirectory}")
# Set the list of components that define modules. Component subdirectories are
# contained in this directory level and contain src/modules/ and
# src/modules/include/ subdirectories
set(ModularComponents
"physics"
)

# Set the components which provide source or object code to the main model
set(CodeComponents
"physics"
#"dynamics"
)

# Set an empty list of sources
set(NextsimSources "")

# Set an empty list of include directories
set(NextsimIncludeDirs "")

# Build the core model. Defines the 'parse_modules' target
add_subdirectory(core)

# Build all components
foreach(compo ${CodeComponents})
add_subdirectory("${compo}")
endforeach()

# Link the model
add_executable(nextsim "${NextsimSources}")

target_include_directories(nextsim PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${Boost_INCLUDE_DIRS}"
"${ModuleLoaderIppTargetDirectory}"
"${NextsimIncludeDirs}"
"${netCDF_INCLUDE_DIR}"
)
target_link_directories(nextsim PUBLIC "${netCDF_LIB_DIR}")
target_link_libraries(nextsim LINK_PUBLIC ${Boost_LIBRARIES} "${NSDG_NetCDF_Library}")

#The parse_modules target is inherited from src
add_dependencies(nextsim parse_modules)
Loading

0 comments on commit 557e45d

Please # to comment.