This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.10) | |
project(foo LANGUAGES C) | |
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | |
# use add_compile_options() instead of setting CMAKE_C_FLAGS to ensure the user flags come last, | |
# that is the user flags take precedence | |
add_compile_options( | |
"$<$<COMPILE_LANGUAGE:C>:-Ofast;-march=native;-ftree-vectorize>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.19) | |
project(DemoCppCheck LANGUAGES C CXX) | |
option(cppcheck "Run CppCheck static code analysis") | |
if(cppcheck) | |
find_program(cppcheck_exe NAMES cppcheck REQUIRED) | |
set(cppcheck_opts --enable=all --inline-suppr --quiet --suppressions-list=${PROJECT_SOURCE_DIR}/cppcheck.supp) | |
set(CMAKE_C_CPPCHECK ${cppcheck_exe} --std=c11 ${cppcheck_opts}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} --version | |
OUTPUT_VARIABLE gen_ver) | |
string(REGEX REPLACE "\n" ";" gen_ver "${gen_ver}") | |
list(GET gen_ver 0 gen_ver) | |
message(STATUS "${CMAKE_GENERATOR} | |
${CMAKE_MAKE_PROGRAM} | |
${gen_ver}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
tee output to screen and buffer variable simultaneously, | |
so that user sees terminal output while a long-running process | |
executes. The full text buffer is retained to check for messages etc. | |
https://stackoverflow.com/a/25755038 | |
""" | |
from io import StringIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Strip Jupyter notebook outputs as Git pre-commit hook | |
""" | |
import subprocess | |
from pathlib import Path | |
files_changed = subprocess.check_output(["git", "diff", "--staged", "--name-only"], text=True).split("\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.19) | |
project(FortranInclude LANGUAGES Fortran) | |
message(STATUS "${CMAKE_SYSTEM_NAME} CMake ${CMAKE_VERSION} ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION}") | |
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} --version OUTPUT_VARIABLE gver OUTPUT_STRIP_TRAILING_WHITESPACE) | |
message(STATUS "${CMAKE_GENERATOR} ${CMAKE_MAKE_PROGRAM} ${gver}") | |
if(APPLE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> /* C23: SIZE_WIDTH, PTRDIFF_WIDTH */ | |
#include <stddef.h> | |
#include <stdio.h> | |
#define ssize_t ptrdiff_t | |
int main(void){ | |
size_t s; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Assumes executable "amender.bin" exists in the Python package and you want to resolve its full path and run it. | |
""" | |
import os | |
import subprocess | |
import importlib.resources as impr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program main | |
!! prints local machine timezone offset from UTC in hours | |
!! based on https://github.com/wavebitscientific/datetime-fortran/pull/80/files | |
use, intrinsic :: iso_fortran_env, only: real64 | |
implicit none | |
character(len=5) :: zone | |
integer :: values(8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
read Madrigal GNSS LOS file | |
based on http://cedar.openmadrigal.org/static/siteSpecific/programming_tips.pdf | |
""" | |
import time | |
import h5py | |
import numpy | |
import argparse | |