Skip to content

Commit

Permalink
Adding some debug/cmake settings for vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
smillerc committed Jun 23, 2020
1 parent 6f2c58d commit 0471f06
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/alpine-3.10-git
{
"name": "Fortran+MPI",
"image": "smillerc/ifort-mpi-dev",
"image": "smillerc/gfortran-dev:latest",
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"fortran-ls.executablePath": "/miniconda/bin/fortls"
},
"postAttachCommand": "pip install fortran-language-server jsonrpc2 --user",
"extensions": [
"ms-vscode.cmake-tools",
"twxs.cmake",
"krvajalm.fortran",
"hansec.fortran-ls",
"eamodio.gitlens",
"gimly81.fortran"
]
}
14 changes: 5 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Fortran Launch (GDB)",
"name": "(gdb) Launcher",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/cato.x",
"args": [
"input.ini"
],
"miDebuggerPath": "/usr/bin/gdb",
"stopAtEntry": false,
"cwd": "${workspaceFolder}/tests/integrated/double_shear",
"cwd": "${workspaceFolder}/tests/integrated/sod_1d",
"environment": [],
"externalConsole": true,
// "preLaunchTask": "/usr/local/bin/gfortran-9"
},
"externalConsole": false,
"MIMode": "gdb",
}
]
}
39 changes: 39 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Config Debug GCC",
"command": "cmake",
"args": [
"..",
"-DCMAKE_BUILD_TYPE='Debug'",
"-DENABLE_TESTING=NO",
"-DUSE_OPENMP=YES",
"-DENABLE_PROFILING=NO",
],
"options": {
"cwd": "${workspaceFolder}/build",
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "Build",
"command": "make",
"args": [
"-j"
],
"options": {
"cwd": "${workspaceFolder}/build",
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
61 changes: 61 additions & 0 deletions cmake-variants.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
buildType:
default: debug
choices:
debug:
short: Debug
long: Emit debug information
buildType: Debug
release:
short: Release
long: Optimize generated code
buildType: Release
asan:
short: Asan
long: Instrument with Address Sanitizer
buildType: Asan
tsan:
short: Tsan
long: Instrument with Thread Sanitizer
buildType: Tsan

# EnableOpenMP:
# default: "yes"
# short: Enable OpenMP Testing
# choices:
# yes:
# short: OpenMP
# long: Enable OpenMP
# settings:
# USE_OPENMP: yes
# no:
# short: OpenMP
# long: Disable OpenMP
# settings:
# USE_OPENMP: no
EnableOpenMP:
default: yes
choices:
yes:
short: With_OpenMP
long: Enable PFUnit Unit testing
settings:
USE_OPENMP: YES
no:
short: Without_OpenMP
long: Disable PFUnit Unit testing
settings:
USE_OPENMP: NO

EnableTesting:
default: no
choices:
yes:
short: With_PFUnit
long: Enable PFUnit Unit testing
settings:
DENABLE_TESTING: YES
no:
short: Without_PFUnit
long: Disable PFUnit Unit testing
settings:
DENABLE_TESTING: NO
18 changes: 16 additions & 2 deletions cmake/SetFortranFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,19 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)

set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -funroll-loops -finline-functions ${GNUNATIVE}")

if(ENABLE_PROFILING)
# set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fsanitize=leak -fsanitize=address")
if(NOT USE_ASAN)
set(USE_ASAN Off)
endif()

if(NOT USE_TSAN)
set(USE_TSAN Off)
endif()

if(USE_ASAN)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fsanitize=leak -fsanitize=address")
endif()

if(USE_TSAN)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fsanitize=thread")
endif()

Expand All @@ -65,6 +76,9 @@ endif()
# ifort
if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)

if (USE_ASAN or USE_TSAN)
message(FATAL_ERROR "Cannot enable USE_ASAN or USE_TSAN with the Intel Fortran Compiler, this is a GCC/Clang feature")
endif()
# if(SERIAL_BUILD) set(IFORT_COARRAY "-coarray=single") elseif(SHARED_MEMORY) set(IFORT_COARRAY
# "-coarray=shared") elseif(DISTRIBUTED_MEMORY) set(IFORT_COARRAY "-coarray=distributed") endif()

Expand Down

0 comments on commit 0471f06

Please sign in to comment.