Commit 2ccb79be authored by James Willis's avatar James Willis
Browse files

Merge remote-tracking branch 'origin/master' into FOF

parents f83c75dc 6e0b12e0
...@@ -26,35 +26,26 @@ examples/swift ...@@ -26,35 +26,26 @@ examples/swift
examples/swift_mpi examples/swift_mpi
examples/fof examples/fof
examples/fof_mpi examples/fof_mpi
examples/*/*.xmf
examples/*/*.h5
examples/*/*.png
examples/*/*.mp4
examples/*/*.txt
examples/*/*.dot
examples/*/restart/*
examples/*/used_parameters.yml
examples/*/unused_parameters.yml
examples/*/*/*.xmf examples/*/*/*.xmf
examples/*/*/*.png examples/*/*/*.png
examples/*/*/*.mp4 examples/*/*/*.mp4
examples/*/*/*.txt examples/*/*/*.txt
examples/*/*/*.dot
examples/*/*/*.rst examples/*/*/*.rst
examples/*/*/*.hdf5 examples/*/*/*.hdf5
examples/*/snapshots* examples/*/*/restart/*
examples/*/restart/*
examples/*/*/used_parameters.yml examples/*/*/used_parameters.yml
examples/*/err_file*
examples/*/out_file*
examples/*/stf_output* examples/*/stf_output*
examples/*/stf.* examples/*/stf.*
examples/*/*.slurm
examples/*/fof_output* examples/*/fof_output*
examples/*/log* examples/*/log*
examples/*/*/unused_parameters.yml examples/*/*/unused_parameters.yml
examples/*/*.mpg examples/*/*.mpg
examples/*/gravity_checks_*.dat examples/*/*/gravity_checks_*.dat
examples/*/*/coolingtables.tar.gz
examples/*/*/coolingtables
examples/Cooling/CoolingRates/cooling_rates
examples/Cooling/CoolingRates/cooling_element_*.dat
examples/Cooling/CoolingRates/cooling_output.dat
tests/testActivePair tests/testActivePair
tests/testActivePair.sh tests/testActivePair.sh
...@@ -110,6 +101,7 @@ tests/testInteractions ...@@ -110,6 +101,7 @@ tests/testInteractions
tests/testInteractions.sh tests/testInteractions.sh
tests/testSymmetry tests/testSymmetry
tests/testMaths tests/testMaths
tests/testRandom
tests/testThreadpool tests/testThreadpool
tests/testParser tests/testParser
tests/parser_output.yml tests/parser_output.yml
...@@ -148,6 +140,7 @@ tests/testCosmology ...@@ -148,6 +140,7 @@ tests/testCosmology
tests/testOutputList tests/testOutputList
tests/testCbrt tests/testCbrt
tests/testFormat.sh tests/testFormat.sh
tests/testCooling
theory/latex/swift.pdf theory/latex/swift.pdf
theory/SPH/Kernels/kernels.pdf theory/SPH/Kernels/kernels.pdf
...@@ -164,6 +157,7 @@ theory/Multipoles/potential_long.pdf ...@@ -164,6 +157,7 @@ theory/Multipoles/potential_long.pdf
theory/Multipoles/potential_short.pdf theory/Multipoles/potential_short.pdf
theory/Multipoles/force_short.pdf theory/Multipoles/force_short.pdf
theory/Cosmology/cosmology.pdf theory/Cosmology/cosmology.pdf
theory/Cooling/eagle_cooling.pdf
m4/libtool.m4 m4/libtool.m4
m4/ltoptions.m4 m4/ltoptions.m4
......
...@@ -138,14 +138,15 @@ before you can build it. ...@@ -138,14 +138,15 @@ before you can build it.
===================== =====================
- METIS: - METIS/ParMETIS:
a build of the METIS library can be optionally used to a build of the METIS or ParMETIS library should be used to
optimize the load between MPI nodes (requires an MPI optimize the load between MPI nodes. This should be found in the
library). This should be found in the standard installation standard installation directories, or pointed at using the
directories, or pointed at using the "--with-metis" "--with-metis" or "--with-parmetis" configuration options.
configuration option. In this case the top-level installation In this case the top-level installation directory of the build
directory of the METIS build should be given. Note to use should be given. Note to use METIS or ParMETIS you should supply at
METIS you should supply at least "--with-metis". least "--with-metis". ParMETIS is preferred over METIS when there
is a choice.
- libNUMA: - libNUMA:
a build of the NUMA library can be used to pin the threads to a build of the NUMA library can be used to pin the threads to
...@@ -154,6 +155,12 @@ before you can build it. ...@@ -154,6 +155,12 @@ before you can build it.
distributing the threads among the different cores on each distributing the threads among the different cores on each
computing node. computing node.
Note that if you have libNUMA outside of the system include
directories it may fail to compile as the headers do not pass
the -Wstrict-prototype check of GCC. In that case you will need
to use --enable-compiler-warnings=yes configure option to stop
this being an error.
- tcmalloc / jemalloc / TBBmalloc: - tcmalloc / jemalloc / TBBmalloc:
a build of the tcmalloc library (part of gperftools), jemalloc a build of the tcmalloc library (part of gperftools), jemalloc
or TBBmalloc can be used be used to obtain faster and more or TBBmalloc can be used be used to obtain faster and more
......
...@@ -19,7 +19,10 @@ ...@@ -19,7 +19,10 @@
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
# Show the way... # Show the way...
SUBDIRS = src examples doc tests tools SUBDIRS = src argparse examples doc tests tools
if HAVEEAGLECOOLING
SUBDIRS += examples/Cooling/CoolingRates
endif
# Non-standard files that should be part of the distribution. # Non-standard files that should be part of the distribution.
EXTRA_DIST = INSTALL.swift .clang-format format.sh EXTRA_DIST = INSTALL.swift .clang-format format.sh
Welcome to the cosmological hydrodynamical code Welcome to the cosmological hydrodynamical code
______ _________________ ______ _________________
/ ___/ | / / _/ ___/_ __/ / ___/ | / / _/ ___/_ __/
\__ \| | /| / // // /_ / / \__ \| | /| / // // /_ / /
___/ /| |/ |/ // // __/ / / ___/ /| |/ |/ // // __/ / /
/____/ |__/|__/___/_/ /_/ /____/ |__/|__/___/_/ /_/
SPH With Inter-dependent Fine-grained Tasking SPH With Inter-dependent Fine-grained Tasking
Website: www.swiftsim.com Website: www.swiftsim.com
...@@ -11,39 +11,63 @@ ...@@ -11,39 +11,63 @@
See INSTALL.swift for install instructions. See INSTALL.swift for install instructions.
Usage: swift [OPTION]... PARAMFILE Usage: swift [options] [[--] param-file]
swift_mpi [OPTION]... PARAMFILE or: swift [options] param-file
or: swift_mpi [options] [[--] param-file]
or: swift_mpi [options] param-file
Valid options are: Parameters:
-a Pin runners using processor affinity.
-c Run with cosmological time integration.
-C Run with cooling.
-d Dry run. Read the parameter file, allocate memory but does not read
the particles from ICs and exit before the start of time integration.
Allows user to check validity of parameter and IC files as well as memory limits.
-D Always drift all particles even the ones far from active particles. This emulates
Gadget-[23] and GIZMO's default behaviours.
-e Enable floating-point exceptions (debugging mode).
-f {int} Overwrite the CPU frequency (Hz) to be used for time measurements.
-g Run with an external gravitational potential.
-G Run with self-gravity.
-M Reconstruct the multipoles every time-step.
-n {int} Execute a fixed number of time steps. When unset use the time_end parameter to stop.
-o {str} Generate a default output parameter file.
-P {sec:par:val} Set parameter value and overwrites values read from the parameters file. Can be used more than once.
-r Continue using restart files.
-s Run with hydrodynamics.
-S Run with stars.
-b Run with stars feedback.
-t {int} The number of threads to use on each MPI rank. Defaults to 1 if not specified.
-T Print timers every time-step.
-v [12] Increase the level of verbosity:
1: MPI-rank 0 writes,
2: All MPI-ranks write.
-x Run with structure finding.
-y {int} Time-step frequency at which task graphs are dumped.
-Y {int} Time-step frequency at which threadpool tasks are dumped.
-h Print this help message and exit.
See the file parameter_example.yml for an example of parameter file. -h, --help show this help message and exit
Simulation options:
-b, --feedback Run with stars feedback.
-c, --cosmology Run with cosmological time integration.
--temperature Run with temperature calculation.
-C, --cooling Run with cooling (also switches on --with-temperature).
-D, --drift-all Always drift all particles even the ones
far from active particles. This emulates
Gadget-[23] and GIZMO's default behaviours.
-F, --star-formation Run with star formation.
-g, --external-gravity Run with an external gravitational potential.
-G, --self-gravity Run with self-gravity.
-M, --multipole-reconstruction Reconstruct the multipoles every time-step.
-s, --hydro Run with hydrodynamics.
-S, --stars Run with stars.
-x, --velociraptor Run with structure finding.
--limiter Run with time-step limiter.
Control options:
-a, --pin Pin runners using processor affinity.
-d, --dry-run Dry run. Read the parameter file, allocates
memory but does not read the particles
from ICs. Exits before the start of time
integration. Checks the validity of
parameters and IC files as well as memory
limits.
-e, --fpe Enable floating-point exceptions (debugging
mode).
-f, --cpu-frequency=<str> Overwrite the CPU frequency (Hz) to be
used for time measurements.
-n, --steps=<int> Execute a fixed number of time steps.
When unset use the time_end parameter
to stop.
-o, --output-params=<str> Generate a default output parameter
file.
-P, --param=<str> Set parameter value, overiding the value
read from the parameter file. Can be used
more than once {sec:par:value}.
-r, --restart Continue using restart files.
-t, --threads=<int> The number of threads to use on each MPI
rank. Defaults to 1 if not specified.
-T, --timers=<int> Print timers every time-step.
-v, --verbose=<int> Run in verbose mode, in MPI mode 2 outputs
from all ranks.
-y, --task-dumps=<int> Time-step frequency at which task analysis
files and/or tasks are dumped.
-Y, --threadpool-dumps=<int> Time-step frequency at which threadpool
tasks are dumped.
See the file examples/parameter_example.yml for an example of parameter file.
...@@ -49,9 +49,9 @@ are highly encouraged. ...@@ -49,9 +49,9 @@ are highly encouraged.
Welcome to the cosmological hydrodynamical code Welcome to the cosmological hydrodynamical code
______ _________________ ______ _________________
/ ___/ | / / _/ ___/_ __/ / ___/ | / / _/ ___/_ __/
\__ \| | /| / // // /_ / / \__ \| | /| / // // /_ / /
___/ /| |/ |/ // // __/ / / ___/ /| |/ |/ // // __/ / /
/____/ |__/|__/___/_/ /_/ /____/ |__/|__/___/_/ /_/
SPH With Inter-dependent Fine-grained Tasking SPH With Inter-dependent Fine-grained Tasking
Website: www.swiftsim.com Website: www.swiftsim.com
...@@ -59,38 +59,63 @@ are highly encouraged. ...@@ -59,38 +59,63 @@ are highly encouraged.
See INSTALL.swift for install instructions. See INSTALL.swift for install instructions.
Usage: swift [OPTION]... PARAMFILE Usage: swift [options] [[--] param-file]
swift_mpi [OPTION]... PARAMFILE or: swift [options] param-file
or: swift_mpi [options] [[--] param-file]
Valid options are: or: swift_mpi [options] param-file
-a Pin runners using processor affinity.
-c Run with cosmological time integration. Parameters:
-C Run with cooling.
-d Dry run. Read the parameter file, allocate memory but does not read -h, --help show this help message and exit
the particles from ICs and exit before the start of time integration.
Allows user to check validity of parameter and IC files as well as memory limits. Simulation options:
-D Always drift all particles even the ones far from active particles. This emulates
Gadget-[23] and GIZMO's default behaviours. -b, --feedback Run with stars feedback.
-e Enable floating-point exceptions (debugging mode). -c, --cosmology Run with cosmological time integration.
-f {int} Overwrite the CPU frequency (Hz) to be used for time measurements. --temperature Run with temperature calculation.
-g Run with an external gravitational potential. -C, --cooling Run with cooling (also switches on --with-temperature).
-G Run with self-gravity. -D, --drift-all Always drift all particles even the ones
-M Reconstruct the multipoles every time-step. far from active particles. This emulates
-n {int} Execute a fixed number of time steps. When unset use the time_end parameter to stop. Gadget-[23] and GIZMO's default behaviours.
-o {str} Generate a default output parameter file. -F, --star-formation Run with star formation.
-P {sec:par:val} Set parameter value and overwrites values read from the parameters file. Can be used more than once. -g, --external-gravity Run with an external gravitational potential.
-r Continue using restart files. -G, --self-gravity Run with self-gravity.
-s Run with hydrodynamics. -M, --multipole-reconstruction Reconstruct the multipoles every time-step.
-S Run with stars. -s, --hydro Run with hydrodynamics.
-t {int} The number of threads to use on each MPI rank. Defaults to 1 if not specified. -S, --stars Run with stars.
-T Print timers every time-step. -x, --velociraptor Run with structure finding.
-v [12] Increase the level of verbosity: --limiter Run with time-step limiter.
1: MPI-rank 0 writes,
2: All MPI-ranks write. Control options:
-x Run with structure finding.
-y {int} Time-step frequency at which task graphs are dumped. -a, --pin Pin runners using processor affinity.
-Y {int} Time-step frequency at which threadpool tasks are dumped. -d, --dry-run Dry run. Read the parameter file, allocates
-h Print this help message and exit. memory but does not read the particles
from ICs. Exits before the start of time
integration. Checks the validity of
parameters and IC files as well as memory
limits.
-e, --fpe Enable floating-point exceptions (debugging
mode).
-f, --cpu-frequency=<str> Overwrite the CPU frequency (Hz) to be
used for time measurements.
-n, --steps=<int> Execute a fixed number of time steps.
When unset use the time_end parameter
to stop.
-o, --output-params=<str> Generate a default output parameter
file.
-P, --param=<str> Set parameter value, overiding the value
read from the parameter file. Can be used
more than once {sec:par:value}.
-r, --restart Continue using restart files.
-t, --threads=<int> The number of threads to use on each MPI
rank. Defaults to 1 if not specified.
-T, --timers=<int> Print timers every time-step.
-v, --verbose=<int> Run in verbose mode, in MPI mode 2 outputs
from all ranks.
-y, --task-dumps=<int> Time-step frequency at which task analysis
files and/or tasks are dumped.
-Y, --threadpool-dumps=<int> Time-step frequency at which threadpool
tasks are dumped.
See the file examples/parameter_example.yml for an example of parameter file. See the file examples/parameter_example.yml for an example of parameter file.
```
# FAQs
## Why removing parsed command-line switches/options?
It destroys the original `argv` array, not compatible with other arguments parsing
library.
This is because this library is used for short-lived programs, e.g. cli tools
at beginning. It's very convenient to process remain arguments if we remove
parsed command-line arguments, e.g. `<comamnd> [-[s]|--switch]... arguments`.
If you want keep original `argc/argv`, you can make a copy, then pass them to
`argparse_parse`, e.g.
```c
int copy_argc = argc;
const char **copy_argv = argv;
copy_argv = malloc(copy_argc * sizeof(char *));
for (int i = 0; i < argc; i++) {
copy_argv[i] = (char *)argv[i];
}
argparse_parse(&argparse, copy_argc, copy_argv);
```
Issues:
- https://github.com/cofyc/argparse/issues/3
- https://github.com/cofyc/argparse/issues/9
## Why using `intptr_t` to hold associated data? Why not `void *`?
I choose `intptr_t` because it's a integer type which also can be used to hold
a pointer value. Most of the time, we only need a integer to hold
user-provided value, see `OPT_BIT` as example. If you want to provide a pointer
which points to a large amount of data, you can cast it to `intptr_t` and cast
it back to original pointer in callback function.
The MIT License (MIT)
Copyright (c) 2012-2013 Yecheng Fu <cofyc.jackson@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# This file is part of SWIFT.
# Copyright (c) 2018 Peter W. Draper (p.w.draper@durham.ac.uk)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
lib_LTLIBRARIES = libargparse.la
include_HEADERS = argparse.h
AM_SOURCES = argparse.c
# Sources and flags for regular library
libargparse_la_SOURCES = $(AM_SOURCES)
libargparse_la_CFLAGS = $(AM_CFLAGS)
libargparse_la_LDFLAGS = $(AM_LDFLAGS)
EXTRA_DIST = LICENSE README.md
approvers:
- cofyc
# argparse [![Build Status](https://travis-ci.org/cofyc/argparse.png)](https://travis-ci.org/cofyc/argparse)
argparse - A command line arguments parsing library in C (compatible with C++).
## Description
This module is inspired by parse-options.c (git) and python's argparse
module.
Arguments parsing is common task in cli program, but traditional `getopt`
libraries are not easy to use. This library provides high-level arguments
parsing solutions.
The program defines what arguments it requires, and `argparse` will figure
out how to parse those out of `argc` and `argv`, it also automatically
generates help and usage messages and issues errors when users give the
program invalid arguments.
## Features
- handles both optional and positional arguments
- produces highly informative usage messages
- issues errors when given invalid arguments
There are basically three types of options:
- boolean options
- options with mandatory argument
- options with optional argument
There are basically two forms of options:
- short option consist of one dash (`-`) and one alphanumeric character.
- long option begin with two dashes (`--`) and some alphanumeric characters.
Short options may be bundled, e.g. `-a -b` can be specified as `-ab`.
Options are case-sensitive.
Options and non-option arguments can clearly be separated using the `--` option.
## Examples
```c
#include "argparse.h"
static const char *const usage[] = {
"test_argparse [options] [[--] args]",
"test_argparse [options]",
NULL,
};
#define PERM_READ (1<<0)
#define PERM_WRITE (1<<1)
#define PERM_EXEC (1<<2)
int
main(int argc, const char **argv)
{
int force = 0;
int test = 0;
int num = 0;
const char *path = NULL;
int perms = 0;
struct argparse_option options[] = {
OPT_HELP(),
OPT_GROUP("Basic options"),
OPT_BOOLEAN('f', "force", &force, "force to do"),
OPT_BOOLEAN('t', "test", &test, "test only"),
OPT_STRING('p', "path", &path, "path to read"),
OPT_INTEGER('n', "num", &num, "selected num"),
OPT_GROUP("Bits options"),
OPT_BIT(0, "read", &perms, "read perm", NULL, PERM_READ, OPT_NONEG),
OPT_BIT(0, "write", &perms, "write perm", NULL, PERM_WRITE),
OPT_BIT(0, "exec", &perms, "exec perm", NULL, PERM_EXEC),
OPT_END(),
};
struct argparse argparse;
argparse_init(&argparse, options, usage, 0);
argparse_describe(&argparse, "\nA brief description of what the program does and how it works.", "\nAdditional description of the program after the description of the arguments.");
argc = argparse_parse(&argparse, argc, argv);
if (force != 0)
printf("force: %d\n", force);
if (test != 0)
printf("test: %d\n", test);
if (path != NULL)
printf("path: %s\n", path);
if (num != 0)
printf("num: %d\n", num);
if (argc != 0) {
printf("argc: %d\n", argc);
int i;
for (i = 0; i < argc; i++) {
printf("argv[%d]: %s\n", i, *(argv + i));
}
}
if (perms) {
printf("perms: %d\n", perms);
}
return 0;
}
```
/**
* Copyright (C) 2012-2015 Yecheng Fu <cofyc.jackson at gmail dot com>
* All rights reserved.
*
* Use of this source code is governed by a MIT-style license that can be found
* in the LICENSE file.
*/
#include "../config.h"
#include "argparse.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define OPT_UNSET 1
#define OPT_LONG (1 << 1)
static const char *prefix_skip(const char *str, const char *prefix) {
size_t len = strlen(prefix);
return strncmp(str, prefix, len) ? NULL : str + len;
}
static int prefix_cmp(const char *str, const char *prefix) {
for (;; str++, prefix++)
if (!*prefix) {
return 0;
} else if (*str != *prefix) {
return (unsigned char)*prefix - (unsigned char)*str;
}
}
static void argparse_error(struct argparse *self,
const struct argparse_option *opt,
const char *reason, int flags) {
(void)self;
if (flags & OPT_LONG) {
fprintf(stderr, "error: option `--%s` %s\n", opt->long_name, reason);
} else {
fprintf(stderr, "error: option `-%c` %s\n", opt->short_name, reason);
}
exit(1);
}
static int argparse_getvalue(struct argparse *self,
const struct argparse_option *opt, int flags) {
const char *s = NULL;
if (!opt->value) goto skipped;
switch (opt->type) {
case ARGPARSE_OPT_BOOLEAN:
if (flags & OPT_UNSET) {
*(int *)opt->value = *(int *)opt->value - 1;
} else {
*(int *)opt->value = *(int *)opt->value + 1;
}
if (*(int *)opt->value < 0) {
*(int *)opt->value = 0;
}
break;
case ARGPARSE_OPT_BIT:
if (flags & OPT_UNSET) {