diff --git a/LICENCE b/LICENCE index d98cad8d89a828427fa50a271dc8805bf73804fa..775f9ce3980f082c5c48b28e3f90686d20870552 100644 --- a/LICENCE +++ b/LICENCE @@ -1,20 +1,26 @@ The binary_c/nucsyn code LICENCE -------------------------------- -The binary_ code (also known fas 'binary_c/nucsyn') is based on the BSE code of Jarrod Hurley, as rewritten by Robert Izzard (RGI), with many new functions to follow stellar nucleosynthesis, among other things.Many parts have been rewritten in a more modular way, please appreciate thatthe many improvements are always a work in progress. +The binary_c code was originally based on the BSE code of Jarrod Hurley, as rewritten by Robert Izzard (RGI), with many new functions to follow stellar nucleosynthesis, among other exciting physics. Many parts have been rewritten in a more modular way, please appreciate that the many improvements are always a work in progress. -The (current) websites of binary_c are -http://www.ast.cam.ac.uk/~rgi/binary_c.html +The (current) website of binary_c is http://personal.ph.surrey.ac.uk/~ri0005/binary_c.html -The facebook page is +The git repository is at +https://gitlab.eps.surrey.ac.uk/ri0005/binary_c + +[when RGI moves job, this will move, but your search engine of choice will + still find it] + +Social media pages: +https://twitter.com/binary_c_code https://www.facebook.com/groups/149489915089142/?fref=ts There are two mailing lists on google groups, please join them: https://groups.google.com/forum/#!forum/binary_c-nucsyn-announce https://groups.google.com/forum/#!forum/binary_c-nucsyn-devel -To get the code, please email rob at r.izzard@surrey.ac.uk +We also have a very active Slack group. --- @@ -23,7 +29,7 @@ If you use this code, however directly or indirectly, and "this code" includes binary objects, modules etc. that go with it, and go on to use the results for any paper, poster, publication or distribution of information derived from, with or by the use of this code you must contact RGI at -rgi <_a_t_> cam.ac.uk (alternatively rob.izzard <_a_t_> gmail.com) +r.izzard <_a_t_> surrey.ac.uk (alternatively rob.izzard <_a_t_> gmail.com) to discuss whether you should add him to the author list or cite him. You should also contact Jarrod Hurley, since he wrote the original Fortran code - he may want his name on the paper too. It has @@ -32,7 +38,7 @@ it if you let him know you're using his code (by however circuitous a route!). Usually a citation will do, but you know, if RGI helps you a lot and you use his code extensively, it is polite to consider an author slot. You should -*at least ask*! +*at least ask*! (It also keeps him in a job.) If you are required to cite, then usually something along the lines of: @@ -96,7 +102,7 @@ Carlo Abate wrote the Wind-RLOF code and updated the s-process at low metallicit John Eldridge provided his tables of stellar colours for the stellar_colours library. Giovanni Rosotti provided help with the accretion onto binaries as f(q). Adam Jermyn has worked most on the discs code and his help is greatly appreciated. -Holly Preece provided the tables for first dredge up, as used in nucsyn_strip_and_mix and Izzard+ (2017). +Holly Preece provided the tables for first dredge up, as used in nucsyn_strip_and_mix and Izzard+ (2018). Also, thanks to Chris Tout, Onno Pols and John Lattanzio for advice down the years. @@ -104,15 +110,18 @@ Finally, by using binary_c/nucsyn you agree to: * Commit your ongoing work and improvements to the code to the main code repository. Your work cannot be private. -* That your work can be incorporated, as soon as reasonably possible, into the binary_c/nucsyn trunk (and hence branches of users) so that it is available to all binary_c users. You naturally have time to publish your work first. We're a friendly lot (in general!) and would rather work together than in competition. There is no point in reinventing the wheel! +* That your work can be incorporated, as soon as reasonably possible, into binary_c/nucsyn so that it is available to all binary_c users. You naturally have time to publish your work first. We're a friendly lot (in general!) and would rather work together than in direct competition. There is no point in reinventing the wheel. -* The LICENCE is subject to changes and/or updates. By continuing to use binary_c/nucsyn, you agree to the latest LICENCE terms (in the trunk), not those that came with your branch. Please regularly check the trunk LICENCE file for updates. +* The LICENCE is subject to changes and/or updates. By continuing to use binary_c/nucsyn, you agree to the latest LICENCE terms (as updated on the main git server). Please regularly check the LICENCE file for updates. -Look out for the semi-regular binary_c workshops. Check out the website for details. +Look out for the semi-regular binary_c workshops. Check out the website for details, +or visit the videos on YouTube +https://www.youtube.com/watch?v=vskIb_kt0C8&list=PLvEoX7AHHOBglXeT6lEQ-hgAJDt6iIrPj +https://www.youtube.com/watch?v=kmjM3FkTLSc&t=24s thanks for your time! -25/07/2007, last updated 22/01/2019. +Last updated 01/08/2021. ------------------------------------------------------------ diff --git a/binary_c-config b/binary_c-config index 4cbe9a974b7ea3578483533a1e1f02c2acca00b4..047201f8221c1e7de38dcc8f8673d52f4a81d1e8 100755 --- a/binary_c-config +++ b/binary_c-config @@ -106,7 +106,7 @@ while (( $# )); do case $key in --flags|-flags|flags|--cflags|-cflags|cflags) # return build flags - $VER 2>/dev/null | $GREP 'CFLAGS is \"' | $SED -e s/CFLAGS\ is\ // -e 's/^"[[:space:]]*//' -e 's/"[[:space:]]*$//' + $VER 2>/dev/null | $GREP 'CFLAGS is \"' | $SED -e s/CFLAGS\ is\ // -e 's/^"[[:space:]]*//' -e 's/"[[:space:]]*$//' #-e 's#$# -L/home/izzard/progs/stars/binary_c/src -I/home/izzard/progs/stars/binary_c/src#' shift ;; --define_macros|-define_macros|define_macros) @@ -136,7 +136,7 @@ while (( $# )); do ;; --libs|-libs|libs) # show libraries - $VER 2>/dev/null | $GREP 'LIBS is \"' | $SED -e s/LIBS\ is\ // -e 's/-L[^[:space:]]*//g' -e 's/^"[[:space:]]*//' -e 's/"[[:space:]]*$//' -e 's/[[:space:]]\+/ /g' + $VER 2>/dev/null | $GREP 'LIBS is \"' | $SED -e s/LIBS\ is\ // -e 's/-L[^[:space:]]*//g' -e 's/^"[[:space:]]*//' -e 's/"[[:space:]]*$//' -e 's/[[:space:]]\+/ /g' shift ;; --libs_list|-libs_list|libs_list) diff --git a/doc/binary_c-installation.lyx b/doc/binary_c-installation.lyx deleted file mode 100644 index b4259364795d8d45a549bba1b306305e6195dabf..0000000000000000000000000000000000000000 --- a/doc/binary_c-installation.lyx +++ /dev/null @@ -1,3431 +0,0 @@ -#LyX 2.3 created this file. For more info see http://www.lyx.org/ -\lyxformat 544 -\begin_document -\begin_header -\save_transient_properties true -\origin unavailable -\textclass article -\begin_preamble - - \usepackage[usenames,dvipsnames]{xcolor} -\usepackage{eurosym} -%\usepackage{eulervm} -\usepackage{enumitem} -\usepackage{latexsym} -\usepackage{multicol} -\usepackage{setspace} -%\usepackage{lmodern} -\date{} -\usepackage{tikz} -\usetikzlibrary{calc,shadings} -\usepackage[scaled=0.85]{beramono} - -%\usepackage[usenames, dvipsnames]{color} -\definecolor{Sectioncolour2}{RGB}{210,180,180} -\definecolor{Sectioncolour1}{RGB}{179,100,100} -\definecolor{Sectioncolour}{RGB}{159,29,35} - -% background - -%\usepackage{gradientframe} - -%\usepackage[pages=all,color=Sectioncolour,angle=90,hshift=-5cm,scale=1.5,contents={Nucleosynthesis in AGB Stars}]{background} - -%\usepackage{framed} -%\colorlet{shadecolor}{gray!25} % you may try 'blue' here -%\renewenvironment{leftbar}{% - % \def\FrameCommand{% -%{% -%\textcolor{Sectioncolour2}{\vrule width 2pt}% -%\textcolor{Sectioncolour1}{\vrule width 2pt}% -%\textcolor{Sectioncolour}{\vrule width 2pt}% -%\textcolor{Sectioncolour1}{\vrule width 2pt}% -%\textcolor{Sectioncolour2}{\vrule width 2pt}% -%}\hspace{10pt}}% -% \MakeFramed {\advance\hsize-\width \FrameRestore}}% -%{\endMakeFramed} - - -%\rule{0.4pt}{\textheight} - -% try this -%http://www.ctan.org/tex-archive/macros/latex/contrib/eso-pic/ -%http://stackoverflow.com/questions/2986240/latex-how-to-make-a-fullpage-vertical-rule-on-every-page - -\usepackage{eso-pic} -\usepackage{graphicx} -%\newcommand\BackgroundPic{} - -\newcommand\BackgroundPic{% -\put(0,0){% -\parbox[b][\paperheight]{\paperwidth}{% -\vfill -\centering -\includegraphics[width=\paperwidth,height=\paperheight,% -keepaspectratio]{images/falk2-low-lolores.eps}% -\vfill -}}} - -% remove background image (for speed) -%\renewcommand\BackgroundPic{} - -% redefine sections to use red colour -\usepackage{titlesec} -\titleformat{name=\section}% command to alter -{\color{Sectioncolour}\normalfont\itshape\bfseries\large\setstretch{0.5}}%format -{\thesection}%label -{1em}%sep -{}%before code -{}%after code - -% redefine subsections to use red colour -\titleformat{name=\subsection}% command to alter -{\color{Sectioncolour}\normalfont\itshape\bfseries\large\setstretch{0.5}}%format -{\thesubsection}%label -{1em}%sep -{}%before code -{}%after code - - -\def\aj{AJ} % Astronomical Journal -\def\araa{ARA\&A} % Annual Review of Astron and Astrophys -\def\apj{ApJ} % Astrophysical Journal -\def\apjl{ApJ} % Astrophysical Journal, Letters -\def\apjs{ApJS} % Astrophysical Journal, Supplement -\def\apss{Ap\&SS} % Astrophysics and Space Science -\def\aap{A\&A} % Astronomy and Astrophysics -\def\aapr{A\&A~Rev.} % Astronomy and Astrophysics Reviews -\def\aaps{A\&AS} % Astronomy and Astrophysics, Supplement -\def\mnras{MNRAS} % Monthly Notices of the RAS -\def\pra{Phys.~Rev.~A} % Physical Review A: General Physics -\def\prl{Phys.~Rev.~Lett.} % Physical Review Letters -\def\pasa{PASA} % Publications of the ASP -\def\pasp{PASP} % Publications of the ASP -\def\pasj{PASJ} % Publications of the ASJ -\def\nat{Nature} % Nature -\def\aplett{Astrophys.~Lett.} % Astrophysics Letters -\def\physrep{Phys.~Rep.} % Physics Reports% -\def\na{NewA} % new astronomy% - -\usepackage{natbibspacing} -\setlength{\bibspacing}{0mm} - -% header -\usepackage{fancyhdr} -\pagestyle{fancy} -\renewcommand{\headrulewidth}{0pt} -\fancyhead[LE,RO]{\color{Sectioncolour}\normalfont\itshape\bfseries{}} % page number in "outer" position of footer line -\fancyhead[RE,LO]{\color{Sectioncolour}\rightmark} % other info in "inner" position of footer line - -\raggedbottom -\end_preamble -\use_default_options true -\maintain_unincluded_children false -\language british -\language_package default -\inputencoding auto -\fontencoding global -\font_roman "utopia" "default" -\font_sans "default" "default" -\font_typewriter "default" "default" -\font_math "auto" "auto" -\font_default_family rmdefault -\use_non_tex_fonts false -\font_sc false -\font_osf false -\font_sf_scale 100 100 -\font_tt_scale 100 100 -\use_microtype false -\use_dash_ligatures false -\graphics default -\default_output_format default -\output_sync 0 -\bibtex_command default -\index_command default -\paperfontsize 12 -\spacing single -\use_hyperref false -\papersize a4paper -\use_geometry true -\use_package amsmath 1 -\use_package amssymb 1 -\use_package cancel 1 -\use_package esint 1 -\use_package mathdots 1 -\use_package mathtools 1 -\use_package mhchem 1 -\use_package stackrel 1 -\use_package stmaryrd 1 -\use_package undertilde 1 -\cite_engine natbib -\cite_engine_type authoryear -\biblio_style plainnat -\use_bibtopic false -\use_indices false -\paperorientation portrait -\suppress_date false -\justification true -\use_refstyle 1 -\use_minted 0 -\index Index -\shortcut idx -\color #008000 -\end_index -\leftmargin 2cm -\topmargin 3cm -\rightmargin 2cm -\bottommargin 3cm -\secnumdepth 3 -\tocdepth 3 -\paragraph_separation indent -\paragraph_indentation default -\is_math_indent 0 -\math_numbering_side default -\quotes_style english -\dynamic_quotes 0 -\papercolumns 1 -\papersides 2 -\paperpagestyle fancy -\tracking_changes false -\output_changes false -\html_math_output 0 -\html_css_as_file 0 -\html_be_strict false -\end_header - -\begin_body - -\begin_layout Title -This document is deprecated. - Please see binary_c2.lyx/pdf instead. -\end_layout - -\begin_layout Standard -\begin_inset CommandInset line -LatexCommand rule -offset "0.5ex" -width "100col%" -height "1pt" - -\end_inset - - -\end_layout - -\begin_layout Title - -\series bold -Installation guide for -\family typewriter -binary_c -\family default - and -\family typewriter -binary_grid2 -\end_layout - -\begin_layout Standard -\align center - -\series bold -A guide to the installation of -\emph on -binary_c -\emph default - and -\emph on -binary_grid2 -\end_layout - -\begin_layout Standard -\align center - -\series bold -Version 2.1.4+ -\begin_inset Newline newline -\end_inset - - -\end_layout - -\begin_layout Standard -\align center - -\series bold -Warning: Version 2 of the combined -\emph on -binary_c -\emph default - and -\emph on -binary_grid2 -\emph default - is currently under development. - Details are likely to change. - -\end_layout - -\begin_layout Standard -\align center -Please see also other documentation, e.g. - -\end_layout - -\begin_layout Description -binary_cV2 for information about changes in -\emph on -binary_c -\emph default - V2.0+. -\end_layout - -\begin_layout Description -binary_grid2 for population grid instructions. -\end_layout - -\begin_layout Description -getting_binary_c for instructions about how to obtain -\emph on -binary_c -\emph default -. -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Subsection -System Requirements -\end_layout - -\begin_layout Standard -\begin_inset CommandInset label -LatexCommand label -name "subsec:Requirements" - -\end_inset - -The following software is required on your system: -\end_layout - -\begin_layout Itemize -A -\emph on -C -\emph default - compiler. - Binary_c has been tested on -\emph on -gcc -\emph default - and -\emph on -clang -\emph default -. - Other options are available, but probably will not work. -\begin_inset Separator latexpar -\end_inset - - -\end_layout - -\begin_deeper -\begin_layout Itemize - -\emph on -gcc -\emph default - (GNU compiler -\begin_inset Flex URL -status collapsed - -\begin_layout Plain Layout - -http://gcc.gnu.org/ -\end_layout - -\end_inset - -) this comes as standard on most Linux systems and is easily installed on - others. - -\emph on -gcc -\emph default -is free. -\end_layout - -\begin_layout Itemize - -\emph on -clang -\emph default - ( -\emph on -C -\emph default - compiler for LLVM -\begin_inset CommandInset href -LatexCommand href -target "http://clang.llvm.org/" -literal "false" - -\end_inset - -) is also free, and may be faster than -\emph on -gcc -\emph default -. -\end_layout - -\begin_layout Itemize - -\emph on -icc -\emph default - (Intel compiler -\begin_inset Flex URL -status collapsed - -\begin_layout Plain Layout - -http://software.intel.com/en-us/articles/intel-compilers/ -\end_layout - -\end_inset - -) this costs money and -\emph on -binary_c -\emph default - has not been tested with it recently. -\end_layout - -\begin_layout Standard -Your system should include such a compiler unless you're using Windows. - -\emph on -Binary_c -\emph default - has been tested on Linux and various Solaris machines. - Note that (for an unknown reason!) it does not run (but does compile) on - old versions of MacOS X. - If you can fix this problem please let me know! Also, there has been trouble - with -\emph on -gcc -\emph default -on Xeon machines. - This is not my fault, please use -\emph on -icc -\emph default -. -\begin_inset Foot -status collapsed - -\begin_layout Plain Layout -This information may be out of date! Please test the build and let me know. -\end_layout - -\end_inset - - -\end_layout - -\end_deeper -\begin_layout Itemize - -\emph on -Python3 -\emph default -, -\emph on -Meson -\emph default - and -\emph on -Ninja -\emph default - are required for installation. - You can install all of these on your system, e.g. - with the following on -\emph on -Ubuntu 18.04 -\emph default -, -\begin_inset listings -inline false -status open - -\begin_layout Plain Layout - -sudo apt-get install python3 meson ninja-build -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Itemize - -\emph on -Perl -\emph default - - this is required for -\emph on -binary_grid2 -\emph default -. - Perl is usually installed on your system, and for configuration of -\emph on -binary_c -\emph default - this should be sufficient. - You can download Perl at -\begin_inset Flex URL -status collapsed - -\begin_layout Plain Layout - -www.perl.com -\end_layout - -\end_inset - -, or use your system Perl, but I recommend -\emph on -Perlbrew -\emph default - instead. - Please try to use a version of Perl that is 5.16 or later: 5.25 is currently - the standard. -\end_layout - -\begin_layout Itemize - -\emph on -Perlbrew -\emph default - and -\emph on -cpanm -\emph default - are -\emph on -essential -\emph default -if you want to use -\series bold -\emph on -binary_grid2 -\series default -\emph default -. - These are standard tools. - I recommend downloading them on a per-user basis, but they could also be - installed as part of your system. -\end_layout - -\begin_layout Itemize -You will want to use -\emph on -git -\emph default - to get -\emph on -binary_c -\emph default -, see the document -\series bold -\emph on -getting_binary_c.pdf -\end_layout - -\begin_layout Itemize -Probably you want a debugger, e.g. - -\emph on -gdb -\emph default -, to be installed, if you plan to modify (and hence break) -\emph on -binary_c -\emph default -. - You may also want -\emph on -valgrind -\emph default - which is superior in many ways to -\emph on -gdb -\emph default -. -\end_layout - -\begin_layout Itemize -The -\emph on -GNU Scientific Library -\emph default - version 2.4 is required. - You may be able to install this as a system package, or you can get it - from -\begin_inset Flex URL -status collapsed - -\begin_layout Plain Layout - -https://www.gnu.org/software/gsl/ -\end_layout - -\end_inset - -. - I have a modified version at -\begin_inset Flex URL -status collapsed - -\begin_layout Plain Layout - -https://gitlab.eps.surrey.ac.uk/ri0005/GSL-2.4-RGI -\end_layout - -\end_inset - - which has minor fixes: please use this if you can. -\end_layout - -\begin_layout Itemize - -\emph on -libbsd -\emph default - is recommended. - Please install the libbsd-devel package also. - You can also install from the source available at -\begin_inset Flex URL -status collapsed - -\begin_layout Plain Layout - -https://libbsd.freedesktop.org/wiki/ -\end_layout - -\end_inset - -. -\end_layout - -\begin_layout Itemize - -\emph on -libbacktrace -\emph default - is recommended. - See -\begin_inset Flex URL -status open - -\begin_layout Plain Layout - -https://github.com/ianlancetaylor/libbacktrace -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Itemize - -\emph on -libbfd -\emph default - is recommended. - This is part of the Linux -\emph on -binutils -\emph default - package. -\end_layout - -\begin_layout Itemize - -\emph on -libmemoize -\emph default - can be downloaded from -\begin_inset Flex URL -status open - -\begin_layout Plain Layout - -https://gitlab.eps.surrey.ac.uk/ri0005/libmemoize -\end_layout - -\end_inset - - but a version is included in -\emph on -binary_c -\emph default -if you do not have it. -\end_layout - -\begin_layout Itemize - -\emph on -librinterpolate -\emph default - can be downloaded from -\begin_inset Flex URL -status open - -\begin_layout Plain Layout - -https://gitlab.eps.surrey.ac.uk/ri0005/librinterpolate -\end_layout - -\end_inset - - but a version is included in -\emph on -binary_c -\emph default -if you do not have it. -\end_layout - -\begin_layout Standard -By using -\emph on -binary_c -\emph default - and -\emph on -binary_grid2 -\emph default - you are part of a community. - You are therefore jointly responsible for helping with the never-ending - process of improvement and bug fixing. - -\emph on - Binary_c -\emph default - (and its -\emph on -Perl -\emph default -modules, such as -\emph on -binary_grid -\emph default -2) is stored on an -\emph on -git -\emph default - server. - Please read the -\series bold -\emph on -LICENCE -\series default -\emph default - file before use. -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Subsection -binary_c -\end_layout - -\begin_layout Standard -\begin_inset CommandInset label -LatexCommand label -name "sec:binary-c" - -\end_inset - - -\end_layout - -\begin_layout Subsubsection -Getting binary_c -\end_layout - -\begin_layout Itemize -You should obtain -\emph on -binary_c -\emph default - from the -\emph on -git -\emph default - server, currently at -\begin_inset Flex URL -status open - -\begin_layout Plain Layout - -https://gitlab.eps.surrey.ac.uk/ri0005/binary_c -\end_layout - -\end_inset - -. - Please see the document -\emph on -getting_binary_c -\emph default - (available in -\emph on -pdf -\emph default - and -\emph on -lyx -\emph default - formats). - -\end_layout - -\begin_layout Itemize -You should consider joining the mailing lists. -\end_layout - -\begin_layout Subsubsection -Building -\end_layout - -\begin_layout Standard -\begin_inset CommandInset label -LatexCommand label -name "subsec:Building" - -\end_inset - - -\end_layout - -\begin_layout Subsubsection -From git -\end_layout - -\begin_layout Standard -Assuming you have checked out your branch, or the trunk, from the -\emph on -git -\emph default - repository (see section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:SVN-access" - -\end_inset - -), go to that directory (which will be called the -\family typewriter -binary_c -\family default - directory below). -\end_layout - -\begin_layout Subsubsection -From a zip file or tarball -\end_layout - -\begin_layout Standard -If have been given a file zip file -\family typewriter -binary_c.zip, -\family default - or a tarball e.g. - -\family typewriter - binary_c.tar.gz -\family default - or -\family typewriter -binary_c.tar.bz2, -\family default - you should copy it to a directory (hereafter -\family typewriter -binary_c -\family default -, usually I put everything in -\family typewriter - -\begin_inset Formula $\sim$ -\end_inset - -/progs/stars/binary_c -\family default - where -\begin_inset Formula $\sim$ -\end_inset - - is your home directory – if you put it there then all the scripts will - work) and -\emph on -unzip -\emph default - it with one of the following commands (depending on the file you were given): -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -unzip binary_c.zip -\family default - -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -tar -xvzf binary_c.tar.gz -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -tar -xvjf binary_c.tar.bz2 -\end_layout - -\begin_layout Standard -which will unzip the files in the appropriate places. -\end_layout - -\begin_layout Subsubsection -Build with meson -\end_layout - -\begin_layout Standard -From inside -\end_layout - -\begin_layout Standard -Now, from the -\family typewriter -binary_c -\family default - directory, you need to run the configuration script with -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -./configure -\end_layout - -\begin_layout Standard -which creates the -\family typewriter -Makefile -\family default -. - Now type -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -./make -\end_layout - -\begin_layout Standard -to build the code. - The make script is a wrapper around GNU make that executes the build on - as many CPUs as you have, and pretties up the output so that it is more - readable.. -\begin_inset Newline newline -\end_inset - -Note that you may need to use -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -gmake -\end_layout - -\begin_layout Standard -from the -\family typewriter -src -\family default - directory if -\emph on -GNU -\emph default - make is not your default (e.g. - you are on something like Solaris). - -\begin_inset Newline newline -\end_inset - -The code will now build, assuming -\family typewriter -configure -\family default - worked ok. - If configure does -\emph on -not -\emph default - work then please try to fix it before running to me with complaints. - It works on Linux and will revert to -\family typewriter -gcc -\family default - as the default compiler if something goes wrong - it -\emph on -might -\emph default - detect -\family typewriter -icc -\family default - if it's on your system. - It is up to you to make your compiler work properly! -\end_layout - -\begin_layout Standard -The executable is called -\family typewriter -binary_c. -\end_layout - -\begin_layout Standard -Note: -\family typewriter -binary_c -\family default - is built as a single, possibly -\emph on -large -\emph default - (many MB) executable. - The reason for this is purely ease of use when transferring the executable - from one machine to another. - It is possible to build a shared library instead. -\end_layout - -\begin_layout Subsubsection -Building the shared library -\end_layout - -\begin_layout Standard -To build the shared library, run -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -./configure -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -make libbinary_c.so -\end_layout - -\begin_layout Standard -This makes the -\family typewriter -libbinary_c.so -\family default - shared library which can be used, for example, by the -\emph on -C -\emph default - backend to -\emph on -binary_grid -\emph default -2, or to access -\emph on -binary_c -\emph default - through its -\emph on -API -\emph default -. -\end_layout - -\begin_layout Subsubsection -Alternative compiler -\end_layout - -\begin_layout Standard -You can build with another compiler, e.g. - -\emph on -clang -\emph default -, by doing -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -export CC=clang -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -./configure -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -./make -\end_layout - -\begin_layout Subsubsection -Debugging build -\end_layout - -\begin_layout Standard -To enable full debugging, run -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -./configure debug -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -./make -\end_layout - -\begin_layout Subsubsection -Testing binary_c -\end_layout - -\begin_layout Standard -Run the -\emph on -bash -\emph default - script to -\begin_inset Quotes eld -\end_inset - -test binary star evolution -\begin_inset Quotes erd -\end_inset - - called -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -tbse -\family default -\series default - -\begin_inset Newline newline -\end_inset - -You should see output. - -\begin_inset Newline newline -\end_inset - -You may have to symbolically link src/binary_c to binary_c in the directory - to make this work, e.g. -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -cd -\emph on -<binary_c_directory> -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -ln -s src/binary_c -\end_layout - -\begin_layout Subsubsection -tbse commands -\end_layout - -\begin_layout Standard - -\emph on -tbse -\emph default -can take extra arguments, which are usually passed to -\emph on -binary_c -\emph default - directly. -\end_layout - -\begin_layout Standard -There are also many commands which can be given to -\emph on -tbse -\emph default -, e.g. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -echo This outputs (to -\emph on -stdout -\emph default -) the arguments that would have been sent to -\emph on -binary_c -\emph default -. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -args Ignores settings in the -\emph on -tbse -\emph default -file and runs only with the extra arguments given on the command line. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -debug This runs -\emph on -binary_c -\emph default -with the gdb debugger -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -valgrind This runs -\emph on -binary_c -\emph default - through -\emph on -Valgrind -\emph default -'s -\emph on -memcheck -\emph default - tool to detect memory leaks. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -massif This runs -\emph on -binary_c -\emph default - through -\emph on -Valgrind -\emph default -'s -\emph on -massif -\emph default - heap checker. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -callgrind This runs -\emph on -binary_c -\emph default - through -\emph on -Valgrind -\emph default -'s -\emph on -callgrind -\emph default -tool. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -cachegrind This runs -\emph on -binary_c -\emph default - through -\emph on -Valgrind -\emph default -'s -\emph on -cachegrind -\emph default - tool. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -ptrcheck This runs -\emph on - binary_c -\emph default - through -\emph on -Valgrind -\emph default -'s -\emph on -ptrcheck -\emph default - tool. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -sgcheck This runs -\emph on - binary_c -\emph default - through -\emph on -Valgrind -\emph default -'s -\emph on -sgcheck -\emph default - tool. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -drd This runs -\emph on - binary_c -\emph default - through -\emph on -Valgrind -\emph default -'s -\emph on -drd -\emph default - tool. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -gprof This runs -\emph on -binary_c -\emph default - through -\emph on -gprof -\emph default -, the -\emph on -GNU -\emph default - profiler. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -gprof_lines This runs -\emph on -binary_c -\emph default - through -\emph on -gprof -\emph default -, the -\emph on -GNU -\emph default - profiler, doing line-by-line accounting. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -gprof_with_stdout This runs -\emph on -binary_c -\emph default - through -\emph on -gprof -\emph default -, the -\emph on -GNU -\emph default - profiler, showing -\emph on -stdout -\emph default -. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -pgo Profile guided optimization. - This builds -\emph on -binary_c -\emph default - once, runs a number of systems, then rebuilds with extra optimization based - on the profile generated by the runs. - This works for -\emph on -GCC -\emph default - and probably also -\emph on -clang -\emph default -. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -bug This runs -\emph on -binary_c -\emph default - and outputs information which is suitable for reporting a bug to Rob. -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - -multicore This runs -\emph on -binary_c -\emph default - on many CPU cores at once. - Exits immediately on failure, so this is useful for testing e.g. - Monte carlo kicks. - -\end_layout - -\begin_layout Description -tbse -\begin_inset space ~ -\end_inset - - -\emph on -<filename> -\emph default - This runs the set of arguments specified in the file given by -\emph on -filename -\emph default -. -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Subsubsection -binary_grid2 -\end_layout - -\begin_layout Standard -This section describes in some detail the installation of -\emph on -binary_grid2 -\emph default -. - Note that sometimes you will require the latest version of pieces of software, - in particular -\emph on -Perl -\emph default - which should be at least version 5.16. - I show you how to do this -\emph on -without -\emph default - requiring root permissions on your machine. - Should you require packages to be installed that require root permission, - you can always set up -\emph on -binary_c -\emph default - and -\emph on -binary_grid2 -\emph default - on a -\emph on -virtual machine -\emph default - which runs as a guest on your operating system, I do this with -\emph on -Virtualbox -\emph default - ( -\begin_inset CommandInset href -LatexCommand href -target "https://www.virtualbox.org/" -literal "false" - -\end_inset - -). - This would be my advice if you are running on a non-standard operating - system, e.g. - -\emph on -Micro$oft Windows -\emph default -. - You will have the root password for your virtual machine, so there are - never permissions problems. -\end_layout - -\begin_layout Standard -You will need some basic tools installed to make everything work: -\emph on -bash -\emph default -, -\emph on -subversion -\emph default -, -\emph on -perl -\emph default -, -\emph on -gmake -\emph default -, -\emph on -wget -\emph default -, -\emph on -gcc -\emph default -. - These are available on all good operating systems, and come by default - – or after a simple install – with most flavours of Linux/Unix and MacOSX. -\end_layout - -\begin_layout Standard -Some -\emph on -Perl -\emph default -modules also require some other system libraries and development files. - It is difficult to know exactly what these would be for every operating - system. - You may have to use a web search to find out, but that's fine because you - are smart! -\end_layout - -\begin_layout Paragraph -Latest -\emph on -Perl -\emph default -: use -\emph on -perlbrew -\end_layout - -\begin_layout Standard -I highly recommend that you install the latest version of -\emph on -Perl -\emph default -using -\series bold -\emph on -perlbrew -\series default -\emph default - and install modules using -\series bold -\emph on -cpanm -\series default -. - -\emph default - I describe how to do this below, but also please see -\begin_inset CommandInset href -LatexCommand href -target "http://perlbrew.pl/" -literal "false" - -\end_inset - - and -\begin_inset CommandInset href -LatexCommand href -target "http://perlbrew.pl/Perlbrew-and-Friends.html " -literal "false" - -\end_inset - -for further instructions and documentation. -\end_layout - -\begin_layout Paragraph -Installing -\emph on -binary_c -\end_layout - -\begin_layout Standard -Please see Sec. -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:binary-c" - -\end_inset - - above for details about how to install -\emph on -binary_c -\emph default -. - -\end_layout - -\begin_layout Paragraph -Installing -\emph on -binary_grid2 -\end_layout - -\begin_layout Standard -\begin_inset CommandInset label -LatexCommand label -name "subsec:installing binary_grid" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\emph on -binary_grid2 -\emph default - is written in -\emph on -Perl -\emph default - ( -\begin_inset CommandInset href -LatexCommand href -target "http://www.perl.org/" -literal "false" - -\end_inset - -) which is available on almost every modern operating system, although to - my knowledge -\emph on -binary_grid2 -\emph default - has never been tested on anything other than -\emph on -Linux -\emph default - ( -\begin_inset CommandInset href -LatexCommand href -target "http://www.linux.org/" -literal "false" - -\end_inset - -), -\emph on -Solaris -\emph default - and -\emph on -MacOSX -\emph default - (which is [currently] really -\emph on - BSD Unix -\emph default -). -\end_layout - -\begin_layout Standard -The newest -\emph on -binary_grid2 -\emph default - uses features from the latest -\emph on -Perl -\emph default - (5.16 or above, currently testing on 5.25) so you'll need a recent -\emph on -Perl -\emph default - to be installed. - Unfortunately most versions of -\emph on -Linux -\emph default - run an older -\emph on -Perl -\emph default - without support for many of the required features. - You will also need to have the latest versions of a number of -\emph on -Perl -\emph default - modules which come from either from the online resource -\emph on -CPAN -\emph default - -\begin_inset Foot -status open - -\begin_layout Plain Layout - -\emph on -Comprehensive Perl Archive Network -\end_layout - -\end_inset - - ( -\begin_inset CommandInset href -LatexCommand href -target "http://www.cpan.org/" -literal "false" - -\end_inset - -) or as part of the -\emph on -binary_c -\emph default - package. -\end_layout - -\begin_layout Standard -My recommendation is to use -\series bold -\emph on -perlbrew -\series default - -\emph default -to make your own -\emph on -Perl -\emph default - and -\emph on -cpanminus -\emph default - (the command is -\family typewriter -cpanm -\family default -) to install the modules. - -\end_layout - -\begin_layout Standard -You can find -\emph on -perlbrew -\emph default - at -\begin_inset CommandInset href -LatexCommand href -target "http://perlbrew.pl/" -literal "false" - -\end_inset - - : please follow the instructions on that page to install the latest -\emph on -Perl -\emph default - on your system if you do not trust my instructions below. - Typically do the following, but remember you -\emph on -must -\emph default - install -\emph on -perlbrew -\emph default - with -\begin_inset Quotes eld -\end_inset - - -\family typewriter --Dusethreads -\family default - -\begin_inset Quotes erd -\end_inset - - otherwise -\emph on -Perl -\emph default - will not use threads and you will lose the multi-CPU features of -\emph on -binary_grid -\emph default -2. - Please note that I assume you are using the -\emph on -bash -\emph default - shell. -\end_layout - -\begin_layout Enumerate - -\family typewriter -\series bold -wget --no-check-certificate -O - http://install.perlbrew.pl | bash -\begin_inset Newline newline -\end_inset - - -\family default -\series default -\emph on -or -\emph default - -\begin_inset Newline newline -\end_inset - - -\family typewriter -\series bold -curl -kL http://install.perlbrew.pl | bash -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\family default -\series default -If you have problems with -\series bold -\emph on -wget -\series default -\emph default -, try removing the -\series bold -\emph on -–no-check-certificate -\series default -\emph default -. -\end_layout - -\begin_layout Enumerate -Run -\family typewriter -perlbrew available -\family default - to find a list of available versions, you should choose the newest, e.g. - -\family typewriter -perl-5.25 -\family default -, and then run the following command to install -\emph on -Perl -\emph default -: -\begin_inset Newline newline -\end_inset - - -\family typewriter - -\begin_inset Newline newline -\end_inset - - -\begin_inset Box Frameless -position "t" -hor_pos "c" -has_inner_box 1 -inner_pos "t" -use_parbox 0 -use_makebox 0 -width "95col%" -special "none" -height "1in" -height_special "totalheight" -thickness "0.4pt" -separation "3pt" -shadowsize "4pt" -framecolor "black" -backgroundcolor "none" -status open - -\begin_layout Plain Layout - -\family typewriter -\series bold -perlbrew -v install perl-5.25 --thread --multi --64bitall --notest -Dusethreads - -Duselargefiles -Dcccdlflags=-fPIC -Dpager=/usr/bin/sensible-pager -Doptimize=" --O3 -march=native -mtune=native" -Duseshrplib -j 8 -\end_layout - -\end_inset - - -\family default - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -You can use -\family typewriter -\series bold --march=native -mtune=native -\family default -\series default - if you are quite sure you will not use this version of -\emph on -Perl -\emph default -, or its modules, on a machine with a different architecture. - If you are building for use with an -\emph on -HTCondor -\emph default - grid, I highly recommend using the -\family typewriter -generic -\family default - option and this is now the default. -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -Note that the final -\emph on -8 -\emph default - should be replaced by the number of CPUs you wish to use for the build - (it is an option passed to -\emph on -make -\emph default -). -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -Note also that -\family typewriter --Duseshrplib -\family default - may no longer be required. -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -I have recently added -\family typewriter ---thread –-multi –-64bitall -\family default - so if you have trouble, please remove these and try again. -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -In -\emph on -Perl -\emph default - 5.25.5 there is a (known) bug in the test routines which may (or may not) - stop your installation. - For this reason the -\family typewriter ---notest -\family default - flag if set. - Remove this if you want testing back (beware it is slow). -\series bold - -\begin_inset Newline newline -\end_inset - - -\series default - -\begin_inset Newline newline -\end_inset - -The installation process can take a long time, go and have lunch\SpecialChar ldots - then: -\end_layout - -\begin_layout Enumerate -Do what -\emph on -perlbrew -\emph default - suggests with your -\family typewriter -.bashrc -\family default - (or whatever shell initialization script you use) to fix the -\family typewriter -PERLBREW_PATH -\family default -. -\end_layout - -\begin_layout Enumerate -Restart your shell (e.g. - close your terminal and open a new one, or just run -\family typewriter -bash -\family default - again) to update your environment and -\family typewriter -$PATH -\family default -. -\end_layout - -\begin_layout Enumerate -Check you're using the correct -\emph on -Perl -\emph default - with -\begin_inset Newline newline -\end_inset - - -\family typewriter -\series bold -perl -v -\family default -\series default - -\begin_inset Newline newline -\end_inset - -This should say something like -\begin_inset Newline newline -\end_inset - - -\family typewriter -\size small -This is perl 5, version 25, subversion 0 (v5.25.0) built for x86_64-linux-thread-m -ulti -\size default - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\family default -Check that the -\family typewriter --thread- -\family default - is there – without threads, -\emph on -binary_grid2 -\emph default - multi-CPU options will not function. -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -If you have a previous version of -\emph on -Perl -\emph default - installed by -\emph on -perlbrew -\emph default -, you will have to do something like -\begin_inset Newline newline -\end_inset - - -\family typewriter -\series bold -perlbrew switch perl-5.25 -\end_layout - -\begin_layout Enumerate -If the installation was successful, but you see an older -\emph on -Perl -\emph default -, check that your -\family typewriter -$PATH -\family default - variable points to the new -\emph on -Perl -\emph default -, and check that -\family typewriter -$PERLBREW_PATH -\family default - exists. -\end_layout - -\begin_layout Enumerate -Install -\emph on -cpanminus -\emph default - by running -\begin_inset Newline newline -\end_inset - - -\family typewriter -\series bold -perlbrew install-cpanm -\end_layout - -\begin_layout Standard -Now you have the latest -\emph on -Perl -\emph default - and -\emph on -cpanm -\emph default - installed, you can start to install the modules needed for -\emph on -binary_grid -\emph default -2. - (Un?)fortunately, there are many of them, so I have made a script to do - it for you -\end_layout - -\begin_layout Enumerate -From the -\emph on -binary_c -\emph default - directory, go to -\family typewriter -src/perl -\family default - with -\begin_inset Newline newline -\end_inset - - -\family typewriter -\series bold -cd src/perl -\end_layout - -\begin_layout Enumerate -Run the install script which uses -\emph on -cpanminus -\emph default - to install the modules -\begin_inset Newline newline -\end_inset - - -\family typewriter -\series bold -./install_modules.pl -\end_layout - -\begin_layout Enumerate -Wait. - Watch the output flow past your eyes. -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -Note that you can -\emph on -also -\emph default - install the modules yourself from their tarballs in -\family typewriter -src/perl/modules_targz -\family default -., e.g. - -\begin_inset Newline newline -\end_inset - - -\family typewriter -\series bold -cd src/perl/modules_targz -\begin_inset Newline newline -\end_inset - -cpanm ./<modname>.tar.gz -\begin_inset Newline newline -\end_inset - - -\family default -\series default -but please note the -\family typewriter -\series bold -./ -\family default -\series default - in the filename is -\emph on -required -\emph default -. -\end_layout - -\begin_layout Enumerate -In case of errors, try installing the module with verbose logging switched - on -\family typewriter -\series bold - -\begin_inset Newline newline -\end_inset - -cpanm -v ./<modname>.tar.gz -\end_layout - -\begin_layout Enumerate -Check the output. - If there is a failure, it should say. - You will have to fix it by looking at the output to see where it went wrong. - The most common cause of failure is that you need some kind of development - ( -\emph on --dev -\emph default - or -\emph on --devel -\emph default -) packages to be installed on your system, e.g. - through -\emph on -apt -\emph default -, -\emph on -yum -\emph default - or -\emph on -synaptic -\emph default - or the system package manager. - This may require root permission. -\begin_inset Newline newline -\end_inset - -If all else fails, you can ask Rob for help. -\end_layout - -\begin_layout Enumerate -Your installed modules are usually in (for -\emph on -Perl -\emph default - 5.25) -\begin_inset Newline newline -\end_inset - - -\family typewriter - $HOME/perl5/perlbrew/perls/5.25.0/lib/site_perl/5.25. -\family default -0 -\begin_inset Newline newline -\end_inset - -You should not have to set the -\emph on -PERL5LIB -\emph default - environment variable when installing with a modern cpanminus. -\begin_inset Newline newline -\end_inset - -If you -\emph on -do -\emph default - have trouble, try -\begin_inset Newline newline -\end_inset - - -\family typewriter -\series bold -export PERL5LIB=$HOME/perl5/perlbrew/perls/5.25.0/lib/site_perl/5.25.0 -\family default -\series default - -\begin_inset Newline newline -\end_inset - -(or similar). - -\end_layout - -\begin_layout Standard -Now you should have everything installed and be able to run a -\emph on -binary_grid -\emph default - script. -\end_layout - -\begin_layout Paragraph -Troubleshooting -\emph on -Perl -\end_layout - -\begin_layout Description -Module -\begin_inset space ~ -\end_inset - -not -\begin_inset space ~ -\end_inset - -found Check the -\family typewriter -PERL5LIB -\family default - environment variable. - When it is empty, -\emph on -cpanm/perlbrew -\emph default - should find your modules automatically, -\emph on -if -\emph default - they are installed correctly by -\emph on -cpanm -\emph default - (in the -\emph on -site_perl -\emph default - directory, see above). - You can try installing modules again with -\family typewriter -\series bold -cpanm --force --reinstall -\family default -\series default - to force a reinstallation, and with -\family typewriter -\series bold --v -\family default -\series default - for extra logging. -\end_layout - -\begin_layout Description -Module -\begin_inset space ~ -\end_inset - -fails -\begin_inset space ~ -\end_inset - -to -\begin_inset space ~ -\end_inset - -build Try -\family typewriter -\series bold -cpanm --notests -\family default -\series default - to not run all tests. - Sometimes these fail for spurious reasons, e.g. - in the case of -\emph on -binary_grid -\emph default - because there are -\emph on - no tests, -\emph default - but -\emph on - -\emph default -the module still functions. -\end_layout - -\begin_layout Description -Perlbrew -\begin_inset space ~ -\end_inset - -build -\begin_inset space ~ -\end_inset - -flags I would recommend at least -\begin_inset Newline newline -\end_inset - - -\family typewriter --Dusethreads -Duselargefiles -Doptimize="-O3 -march=native -mtune=native" -\begin_inset Newline newline -\end_inset - - -\family default -although you may wish to use -\family typewriter --O2 -\family default - if you feel mathematical precision is key to your application (I have never - noticed a problem with the above). -\begin_inset Newline newline -\end_inset - -I also recommend -\family typewriter --Dcccdlflags=-fPIC -\family default -so that module code is position independent and -\family typewriter --Duseshrplib -\family default - so that the appropriate threading library is used. - (These flags are passed to the -\emph on -C -\emph default - compiler that builds -\emph on -Perl -\emph default -.) -\end_layout - -\begin_layout Description -Rebuild -\begin_inset space ~ -\end_inset - -modules -\begin_inset space ~ -\end_inset - -for -\begin_inset space ~ -\end_inset - -new -\begin_inset space ~ -\end_inset - - -\emph on -Perl -\emph default - Let's say you had an old -\emph on -perl -\emph default -built with perlbrew, have installed a shiny new -\emph on -perl -\emph default - version with perlbrew, and now you want to rebuild all your existing modules. - Try this after the install, but before switching to the new -\emph on -perl -\emph default -, replacing -\family typewriter -5.xx.yy -\family default - with the new -\emph on -perl -\emph default - version: -\begin_inset Newline newline -\end_inset - - -\begin_inset Box Frameless -position "t" -hor_pos "c" -has_inner_box 1 -inner_pos "t" -use_parbox 0 -use_makebox 0 -width "100col%" -special "none" -height "1in" -height_special "totalheight" -thickness "0.4pt" -separation "3pt" -shadowsize "4pt" -framecolor "black" -backgroundcolor "none" -status open - -\begin_layout Plain Layout - -\family typewriter -\series bold -perlbrew list-modules | perlbrew exec --with 5.xx.yy cpanm -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Paragraph - -\emph on -binary_grid2 -\emph default - backends -\end_layout - -\begin_layout Standard -The -\begin_inset Quotes eld -\end_inset - -backend -\begin_inset Quotes erd -\end_inset - - is a set of interface code between -\emph on -binary_c -\emph default - and -\emph on -binary_grid2 -\emph default -. - -\end_layout - -\begin_layout Paragraph -Perl backend -\end_layout - -\begin_layout Standard -In -\emph on -binary_grid -\emph default -version 1, the only backend available was the Perl backend which communicates - with -\emph on -binary_c -\emph default - via a series of Unix pipes. - This is portable and flexible, and hence for many years was the default. - It does not, however, scale very well in multi-CPU architectures. - In binary_grid2 a pure -\emph on -Perl -\emph default -module is also provided, both for backwards compatibility and because the - code is well tested and stable. - The -\emph on -Perl -\emph default -backend is installed by default with -\emph on -binary_grid2 -\emph default -. - -\end_layout - -\begin_layout Standard -It is a simple matter of changing the -\family typewriter -prog -\family default - grid variable if you want to use a different version of -\emph on -binary_c -\emph default - with each grid script. -\end_layout - -\begin_layout Paragraph -C backend -\end_layout - -\begin_layout Standard -New to -\emph on -binary_grid2 -\emph default - is the -\emph on -C -\emph default - backend. - This features simpler code and uses -\emph on -binary_c -\emph default -'s -\emph on -API -\emph default - to access data directly, hence it is a lot faster than the -\emph on -Perl -\emph default - backend, and scales -\series bold -much -\series default -better on multi-core architectures. - The down side is that installation is more difficult, especially if you - have multiple projects. - -\end_layout - -\begin_layout Standard -If you see errors like: -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -perl: symbol lookup error: /.../perl5/perlbrew/perls/perl-5.25.0/lib/site_perl/5.25.0/x -86_64-linux-thread-multi/auto/binary_grid/C/C.so: undefined symbol: new_system -\end_layout - -\begin_layout Standard -then you have failed to build the shared library as required and you are - trying to use the -\emph on -C -\emph default - backend. -\begin_inset Newline newline -\end_inset - -To make the -\emph on -C -\emph default - backend work, you have to -\series bold -\emph on -first -\series default -\emph default - install -\emph on -libbinary_c.so -\emph default - and -\series bold -\emph on -then -\series default -\emph default - install -\emph on -binary_grid2 -\emph default -. - Essentially: -\end_layout - -\begin_layout Enumerate -Build -\emph on -binary_c -\emph default - as normal -\end_layout - -\begin_layout Enumerate -Make the shared library, -\emph on -libbinary_c.so -\emph default - (with -\family typewriter -\series bold -make libbinary_c.so -\family default -\series default -) -\end_layout - -\begin_layout Enumerate -Install -\emph on -binary_grid2 -\end_layout - -\begin_layout Standard -Because this module is written partly in -\emph on -C -\emph default - and partly in -\emph on -Perl -\emph default -, there are more things that can go wrong and it is harder to share installation -s (you cannot just copy the shared library to another filename). - The shared library -\emph on -libbinary_c.so -\emph default -must match with -\emph on -binary_grid2 -\emph default - -\series bold -at compile time -\series default -, and if you change anything in -\emph on -binary_c -\emph default - you probably have to follow the above instructions to reinstall the -\emph on -C -\emph default - backend. - -\end_layout - -\begin_layout Standard -There are ways around this problem. - You can change the name of the shared library by setting the environment - variable -\family typewriter -BINARY_C_LIB -\family default - to the name of the library, and pointing -\family typewriter -BINARY_C_SRC -\family default - to the -\family typewriter -src -\family default - directory in your -\emph on -binary_c -\emph default - tree. - Then rebuild, e.g., -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -export BINARY_C_LIB=binary_c_custom -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -export BINARY_C_SRC=$HOME/binary_c/src -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -./configure -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -make libbinary_c_custom.so -\end_layout - -\begin_layout Standard - -\family typewriter -\series bold -cpanm binary_grid2.tar.gz -\end_layout - -\begin_layout Standard -The -\emph on -binary_grid2 -\emph default - module respects the -\family typewriter -BINARY_C_LIB -\family default - environment variable. - -\end_layout - -\begin_layout Standard -I do not yet know how to have custom -\emph on -C -\emph default - backend modules with different shared libraries. - It is quite possible that you could use the -\family typewriter -PERL_INLINE_DIRECTORY -\family default - environment variable to have multiple builds, and point to the appropriate - one. - Please read -\begin_inset CommandInset href -LatexCommand href -target "http://search.cpan.org/~ingy/Inline-0.44/Inline.pod" -literal "false" - -\end_inset - - especially the section -\emph on -The Inline DIRECTORY -\emph default - for instructions on how it is best to set up production code for multiple - projects. - Let Rob know if it works, so better instructions can be put in here. -\end_layout - -\begin_layout Standard -There are a number of environment variables which can be set when installing - -\emph on -binary_grid2 -\emph default -'s -\emph on -C -\emph default - backend: -\end_layout - -\begin_layout Description -BINARY_GRID2_LIB The name of the shared library. - Usually this is 'binary_c'. -\end_layout - -\begin_layout Description -BINARY_GRID2_CC The name of the compiler used to build the C backend. - Usually 'gcc'. -\end_layout - -\begin_layout Description -BINARY_GRID2_LD The name of the linker used to build the C backend. - Usually 'ld'. -\end_layout - -\begin_layout Description -BINARY_GRID2_INC Include flags for the build. - Defaults to -\family typewriter --I -\emph on -srcdir -\family default - -\emph default -where -\emph on -srcdir -\emph default - is the -\emph on -binary_c -\emph default - -\family typewriter -src -\family default - directory (e.g. - set by -\family typewriter -BINARY_C_SRC -\family default -) -\end_layout - -\begin_layout Description -BINARY_GRID2_EXTRAINC Include flags to be postfixed to the -\emph on -inc -\emph default - flags set above. -\end_layout - -\begin_layout Description -BINARY_GRID2_LIBS Library flags. - Defaults to -\family typewriter --Lsrcdir -lbinary_c -lbfd -\family default -. -\end_layout - -\begin_layout Description -BINARY_GRID2_EXTRALIBS Library flags postfixed to the -\emph on -libs -\emph default - flags set above. -\end_layout - -\begin_layout Description -BINARY_GRID2_CCFLAGS Compiler flags. - Defaults to -\family typewriter --march=native -mtune=native -lm -lc -fPIC -ffunction-sections -lbfd -\end_layout - -\begin_layout Description -BINARY_GRID2_EXTRACCFLAGS C compiler flags postfixed to the -\emph on -ccflags -\emph default -set above. -\end_layout - -\begin_layout Standard -\begin_inset Newpage pagebreak -\end_inset - - -\end_layout - -\begin_layout Subsubsection -when proxies/authentication get in the way -\end_layout - -\begin_layout Standard -Many thanks to George Angelou for this guide to installing at the Max-Planck - Institiut f -\begin_inset ERT -status open - -\begin_layout Plain Layout - - -\backslash - -\begin_inset Quotes erd -\end_inset - - -\end_layout - -\end_inset - -ur Astronomie in Garching. -\begin_inset Newline newline -\end_inset - -We want the -\family typewriter --k -\family default - flag when getting -\emph on -perlbrew -\emph default - and to write to a file -\end_layout - -\begin_layout Standard -\begin_inset listings -inline false -status open - -\begin_layout Plain Layout - - -\backslash -curl -kL -o perlbrew.sh https://install.perlbrew.pl | bash -\end_layout - -\end_inset - -Make it executable -\end_layout - -\begin_layout Standard -\begin_inset listings -inline false -status open - -\begin_layout Plain Layout - -chmod +x perlbrew.sh -\end_layout - -\end_inset - -Edit -\family typewriter -perlbrew.sh -\family default -. - Find: -\end_layout - -\begin_layout Standard -\begin_inset listings -inline false -status open - -\begin_layout Plain Layout - -echo -\end_layout - -\begin_layout Plain Layout - -if type curl >/dev/null 2>&1; then -\end_layout - -\begin_layout Plain Layout - -PERLBREWDOWNLOAD="curl -f -sS -Lo $LOCALINSTALLER $PERLBREWURL" -\end_layout - -\end_inset - -And add the ignore certificate flag -\end_layout - -\begin_layout Standard -\begin_inset listings -inline false -status open - -\begin_layout Plain Layout - -if type curl >/dev/null 2>&1; then -\end_layout - -\begin_layout Plain Layout - -PERLBREWDOWNLOAD="curl -kf -sS -Lo $LOCALINSTALLER $PERLBREWURL" -\end_layout - -\end_inset - -Execute -\family typewriter -perlbrew.sh -\family default - and we should get an error about -\emph on -patchperl -\emph default -Add the following to your -\family typewriter -tcshrc -\family default - (it will print out the -\emph on -bash -\emph default - equivalent on screen) -\end_layout - -\begin_layout Standard -\begin_inset listings -inline false -status open - -\begin_layout Plain Layout - -source ~/perl5/perlbrew/etc/cshrc -\end_layout - -\end_inset - -Close the terminal and open a new window. - -\begin_inset Newline newline -\end_inset - -Get -\emph on -patchperl -\emph default - manually: -\end_layout - -\begin_layout Standard -\begin_inset listings -inline false -status open - -\begin_layout Plain Layout - - -\backslash -curl -kL https://raw.github.com/gugod/patchperl-packing/master/patchperl -\backslash - -\end_layout - -\begin_layout Plain Layout - - > $PERLBREW_ROOT/bin/patchperl -\end_layout - -\begin_layout Plain Layout - -chmod 755 $PERLBREW_ROOT/bin/patchperl -\end_layout - -\end_inset - - -\family typewriter -$PERLBREW_ROOT -\family default - is the path where -\emph on -perlbrew -\emph default - has been installed. - Follow Rob’s command for installing -\emph on -perl -\emph default - in -\emph on -multithread -\emph default - mode. - Hopefully this will install with no problems. - -\end_layout - -\begin_layout Standard -Make -\emph on -perl -\emph default - point to your new -\emph on -perlbrew -\end_layout - -\begin_layout Standard -\begin_inset listings -inline false -status open - -\begin_layout Plain Layout - -perlbrew switch perl.x.x.x -\end_layout - -\end_inset - -Install -\emph on -cpanminus -\emph default - manually -\end_layout - -\begin_layout Standard -\begin_inset listings -inline false -status open - -\begin_layout Plain Layout - -curl -kL https://cpanmin.us | perl - App::cpanminus -\end_layout - -\end_inset - -Make sure all is fine -\end_layout - -\begin_layout Standard -\begin_inset listings -inline false -status open - -\begin_layout Plain Layout - -perlbrew list-modules -\end_layout - -\end_inset - -And hopefully you see -\family typewriter -App::cpanminus -\family default - and -\family typewriter - Perl -\end_layout - -\begin_layout Standard -Good luck! -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -Installing robs perl modules -\end_layout - -\begin_layout Standard -Running his script it failed on -\family typewriter -Inline::C. - -\family default - Its on the list twice anyway so I reran and got as far as Sys::Info -\emph on -. - MPA -\emph default - has its own OS that the module does not like and thinks is fake. - I edited the install_modules.pl file and commented out this module. - Rob says he doesn’t use it anymore so hopefully that will be fine. - -\end_layout - -\begin_layout Standard -It also failed at binning so I went into -\family typewriter -modules_targz -\family default - and used the install script there. - At first there are errors at it searches for the packages online then it - installs them locally. - -\family typewriter -perlbrew list-modules -\family default - suggests they are installed. - Going to scripts and testing the -\family typewriter -CNgrids.pl -\family default - I seem to get output. - So I assume all worked. -\end_layout - -\end_body -\end_document diff --git a/doc/binary_c-installation.pdf b/doc/binary_c-installation.pdf deleted file mode 100644 index 1a02d23883300fe36d40b02b4cf26afa1e6c1eae..0000000000000000000000000000000000000000 Binary files a/doc/binary_c-installation.pdf and /dev/null differ diff --git a/doc/binary_c2.lyx b/doc/binary_c2.lyx index 425cb50dae0abb583bd3a01627a712e95e175b5c..5bb03af5f242519a55a229a696db21851c436b93 100644 --- a/doc/binary_c2.lyx +++ b/doc/binary_c2.lyx @@ -1180,7 +1180,7 @@ Ubuntu status open \begin_layout Plain Layout -ubuntu_install.sh +ubuntu_install_binary_c.sh \end_layout \end_inset @@ -1210,17 +1210,17 @@ status open \begin_layout Plain Layout -wget http://personal.ph.surrey.ac.uk/~ri0005/ubuntu_install.sh +wget http://personal.ph.surrey.ac.uk/~ri0005/ubuntu_install_binary_c.sh \end_layout \begin_layout Plain Layout -chmod +x ubuntu_install.sh +chmod +x ubuntu_install_binary_c.sh \end_layout \begin_layout Plain Layout -./ubuntu_install.sh +./ubuntu_install_binary_c.sh \end_layout \end_inset @@ -3661,7 +3661,7 @@ noprefix "false" \begin_inset Formula $\binaryc$ \end_inset - is describe in section + is described in section \begin_inset space ~ \end_inset diff --git a/doc/getting_binary_c.lyx b/doc/getting_binary_c.lyx index 3eb0002b74567be8cc8faad9ae596ac51db590d9..076b92264e1083887cfa7a6b99e529d7506a1d0a 100644 --- a/doc/getting_binary_c.lyx +++ b/doc/getting_binary_c.lyx @@ -391,7 +391,155 @@ End \begin_body \begin_layout Subsubsection -Getting the source code +Getting the +\begin_inset Formula $\binaryc$ +\end_inset + + source code +\end_layout + +\begin_layout Description +With +\begin_inset space ~ +\end_inset + +git download the source code from +\begin_inset CommandInset href +LatexCommand href +target "https://gitlab.eps.surrey.ac.uk/ri0005/binary_c" +literal "false" + +\end_inset + +, e.g. +\begin_inset space ~ +\end_inset + +from the command line, +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +git clone https://gitlab.eps.surrey.ac.uk/ri0005/binary_c.git +\end_layout + +\end_inset + +or, if you have set up +\begin_inset Flex Software +status open + +\begin_layout Plain Layout +SSH +\end_layout + +\end_inset + + keys on the +\begin_inset Flex Software +status open + +\begin_layout Plain Layout +gitlab +\end_layout + +\end_inset + + server, +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +git clone gitlab@gitlab.eps.surrey.ac.uk:ri0005/binary_c.git +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Description +As +\begin_inset space ~ +\end_inset + +a +\begin_inset space ~ +\end_inset + +zip +\begin_inset space ~ +\end_inset + +file you can either download a release, e.g., +\begin_inset Newline newline +\end_inset + + +\begin_inset Flex URL +status open + +\begin_layout Plain Layout + +https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/archive/2.1.6/binary_c-2.1.6.zip +\end_layout + +\end_inset + + +\begin_inset Newline newline +\end_inset + + +\begin_inset Flex URL +status open + +\begin_layout Plain Layout + +https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/archive/2.1.6/binary_c-2.1.6.tar.gz +\end_layout + +\end_inset + + +\begin_inset Newline newline +\end_inset + + +\begin_inset Flex URL +status open + +\begin_layout Plain Layout + +https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/archive/2.1.6/binary_c-2.1.6.tar.bz2 +\end_layout + +\end_inset + + +\begin_inset Newline newline +\end_inset + +or get the latest master branch from +\begin_inset Flex URL +status open + +\begin_layout Plain Layout + +https://gitlab.eps.surrey.ac.uk/ri0005/binary_c/-/archive/master/binary_c-master.zip +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsubsection +Editing the source code \end_layout \begin_layout Standard @@ -417,8 +565,8 @@ literal "false" \end_inset . - Access requires permission which is done on a user-by-user basis and currently - only works easily if you have a Gmail account. + Write access requires permission which is done on a user-by-user basis + and currently only works easily if you have a Gmail account. If you don't, we can probably arrange something. \end_layout @@ -454,7 +602,16 @@ your account is locked! \end_layout \begin_layout Enumerate -Email me at r.izzard@surrey.ac.uk and tell me your account is +Email me at +\begin_inset CommandInset href +LatexCommand href +name "r.izzard@surrey.ac.uk" +type "mailto:" +literal "false" + +\end_inset + + and tell me your account is \begin_inset Quotes eld \end_inset @@ -596,9 +753,17 @@ You can access \emph default through +\begin_inset Flex Software +status open + +\begin_layout Plain Layout + \emph on docker -\emph default +\end_layout + +\end_inset + \begin_inset Foot status open @@ -620,14 +785,30 @@ target "https://www.docker.com/" \begin_layout Enumerate I assume you have installed and signed in to +\begin_inset Flex Software +status open + +\begin_layout Plain Layout + \emph on docker -\emph default +\end_layout + +\end_inset + . I cannot provide support for +\begin_inset Flex Software +status open + +\begin_layout Plain Layout + \emph on Docker -\emph default +\end_layout + +\end_inset + ! \end_layout @@ -702,8 +883,18 @@ docker pull robizzard/binary_c:master2.0pre32 \end_layout \begin_layout Enumerate -When you run Docker it inherits your stack settings, which may be too small - for binary_c to run. +When you run +\begin_inset Flex Software +status open + +\begin_layout Plain Layout +Docker +\end_layout + +\end_inset + + it inherits your stack settings, which may be too small for binary_c to + run. Use \begin_inset listings lstparams "language=bash" diff --git a/meson.build b/meson.build index 6f255f2559515c14d3f294511402de37faae0ca0..c65bc87848955118decdaafff678c172cd0bd65a 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ ########################################################### # meson build file for binary_c # -# (c) Robert Izzard 12/11/2020 +# (c) Robert Izzard 04/08/2021 # # Known to work with binary_c 2.2.pre1 using gcc and clang. # @@ -64,6 +64,7 @@ message('Meson process ID ' + pid) # paths in it (using the make_compile_commands_json.sh # script) # + run_command('/bin/bash', 'meson/background.sh', 'meson/wait_for_exit.sh', @@ -197,7 +198,6 @@ foreach buggy_perl_version : buggy_perls endif endforeach - ############################################################ # compiler object # @@ -363,6 +363,7 @@ _other_cflags = [ '-Wno-variadic-macros', # let these errors pass '-fstack-protector-all', # stack smashing checks (slows runtime) '-rdynamic', + '-fsignaling-nans', # probably required ] # clang-specific if compiler.get_id() == 'clang' @@ -410,12 +411,36 @@ if get_option('valgrind') == true 'avx512ifma', 'avx512vbmi', ] + cflags += [ '-DVALGRIND' ] foreach cflag : _instruction_sets __cflag = '-mno-' + cflag if compiler.has_argument( __cflag ) cflags += [ __cflag ] endif endforeach + # flags to give more debugging output for valgrind (or gdb) + _gflags = [ + 'gdb3', + 'split-dwarf', + 'describe-dies', + 'pubnames', + ] + foreach cflag : _gflags + __cflag = '-g' + cflag + if compiler.has_argument( __cflag ) + cflags += [ __cflag ] + endif + endforeach + _fflags = [ + 'var-tracking', + 'var-tracking-assignments', + ] + foreach cflag : _fflags + __cflag = '-f' + cflag + if compiler.has_argument( __cflag ) + cflags += [ __cflag ] + endif + endforeach endif ############################################################ @@ -446,25 +471,33 @@ if get_option('accurate') == true ] else optional_flags += [ - '-fno-associative-math', + + ############################################################ # these are what -ffast-math does without -funsafe-math-optimizations + # + # Note: we disable some of them + '-fno-associative-math', '-fno-math-errno', - '-ffinite-math-only', + '-ffinite-math-only', # not good '-fno-rounding-math', - '-fno-signaling-nans', + '-fno-signaling-nans', # should be off : nan-signalling is required '-fcx-limited-range', '-fexcess-precision=fast', # never allow unsafe math optimizations '-fno-unsafe-math-optimizations', + ############################################################ ] endif +# note: +# -fno-finite-math-only and -fsignaling-nans cause +# library-naming problems with gcc 10.3 + optional_flags += [ '-fno-finite-math-only', - '-fsignaling-nans', - '-fomit-frame-pointer', - '-fvisibility=hidden', '-fasynchronous-unwind-tables', + '-fomit-frame-pointer', # not good for debugging? + '-fvisibility=hidden', '-rdynamic', '-export-dynamic', ] @@ -1342,11 +1375,12 @@ if get_option('usepch') == true _opt, _pic, _incdirs, + '-shared', # required to prevent MESA SDK errors '-MT', 'binary_c.h.gch', '-MMD', '-MP', '-MF', _depfile_path, - '-x', 'c-header' + '-x', 'c-header', ] pch_sourcefiles = [ _gch ] cflags += [ @@ -1405,21 +1439,6 @@ cflags += [ '-DMESON_PROJECT_VERSION=' + meson.project_version(), ] -############################################################ - -############################################################ -# command to make the compile_commands.json -# -if unix - compile_commands_json = [ - '../meson/compile_commands.json' - ] -else - compile_commands_json = [ - 'echo','"Cannot generate compile_commands.json on this operating system"' - ] -endif - ############################################################ # make gtags database gtags = find_program('gtags',required:false) @@ -1454,12 +1473,20 @@ if unix '&&', '../meson/list_shared_symbols.sh',libname, ] + + # and show the version number after the build + # using binary_c-config (tests that this works) + binary_c_legacy_install_cmd += [ + '&&', + 'echo','-n','built binary_c ', + '&&', + '../binary_c-config','version', + ] else binary_c_legacy_install_cmd = [ 'echo','"Legacy install not supported on this operating system"' ] endif -binary_c_legacy_install_cmd += compile_commands_json ############################################################ # @@ -1467,7 +1494,6 @@ binary_c_legacy_install_cmd += compile_commands_json # hence touch (and rebuild) it when the shared library is # rebuild # - if os == 'linux' and \ run_command('sh','-c','meson/check_binary_grid2.sh').returncode() == 0 binary_grid2_file = run_command( @@ -1644,7 +1670,14 @@ binary_c_shared_library = shared_library( ], link_args : [ libs, - '-fvisibility=hidden', + #'-fvisibility=hidden', + # this fails '-Wl,-soname,libbinary_c', + #'-Wl,-soname,libbinary_c', + + # this fails too + #'-Wl,-soname,libbinary_c.so', + + #'-Wl,-export-dynamic', ], link_with: [ binary_c_objects diff --git a/src/binary_c.h b/src/binary_c.h index 17433903635e7b67ab545ed8908332df41dfae2a..9ea3855e4057c346331cd5080080c476caa6be8f 100644 --- a/src/binary_c.h +++ b/src/binary_c.h @@ -92,12 +92,3 @@ #endif //BINARY_C_H - -/* -#define __dummy_function_concat(A,B) A##B -#define __dummy_function2(A) \ - static void MAYBE_UNUSED __dummy_function_concat(__dummy_name,A)(void); \ - static void MAYBE_UNUSED __dummy_function_concat(__dummy_name,A)(void){return;} -#define __dummy_function __dummy_function2(__COUNTER__) -__dummy_function -*/ diff --git a/src/binary_c_debug.h b/src/binary_c_debug.h index 092f34a167ef7e10a55e8402835494371c4a4212..2de8d9e5ce5e5c4a94377957b9de1673d54b27fd 100644 --- a/src/binary_c_debug.h +++ b/src/binary_c_debug.h @@ -106,7 +106,7 @@ * this is not shown. */ -#define Debug_show_expression " %d %d ",stardata->star[0].stellar_type,stardata->star[1].stellar_type +#define Debug_show_expression " " //#undef Debug_show_expression /* diff --git a/src/binary_c_error_codes.h b/src/binary_c_error_codes.h index d7c00f5261eaed070fb0491f1624383145d30d55..d33e78735cf2cac0af2e14dfee3568b2bd9726dd 100644 --- a/src/binary_c_error_codes.h +++ b/src/binary_c_error_codes.h @@ -41,4 +41,12 @@ static char * binary_c_error_code_strings[] MAYBE_UNUSED = { BINARY_C_ERROR_CODE #undef X +#define Binary_c_error_code_is_bad(CODE) ( \ + (CODE)!=BINARY_C_NORMAL_EXIT && \ + (CODE)!=BINARY_C_QUIET_EXIT && \ + (CODE)!=BINARY_C_SPECIAL_EXIT && \ + (CODE)!=BINARY_C_NORMAL_BATCHMODE_EXIT \ + ) + + #endif // BINARY_C_ERROR_CODES_H diff --git a/src/binary_c_maths.h b/src/binary_c_maths.h index 6cff7d724302e2c9909d11e17794ec207c77fc7b..2dcdcb7c10422aeb41ca2c64f529578767c20c02 100644 --- a/src/binary_c_maths.h +++ b/src/binary_c_maths.h @@ -22,7 +22,9 @@ * mathematical in nature. */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif //_GNU_SOURCE #include <math.h> #include <float.h> #include <stdarg.h> diff --git a/src/binary_c_parameters.h b/src/binary_c_parameters.h index dcf45b9e92efd776ae8ebf2d805b5bfc06621f3a..04660e8e891b4cf2015af47e834dc0051a3d629c 100644 --- a/src/binary_c_parameters.h +++ b/src/binary_c_parameters.h @@ -64,7 +64,7 @@ * * Post-MS evolution has not yet been implemented. */ -#define MINT +//#define MINT /************************************************************ diff --git a/src/debug/backtrace-symbols.c b/src/debug/backtrace-symbols.c index 61648e7110ab0fcf5c1d6a19b9c53cf012e8b95b..bcf9b85453a6cb4adecc3688173b6271d9c0fe46 100644 --- a/src/debug/backtrace-symbols.c +++ b/src/debug/backtrace-symbols.c @@ -1,6 +1,9 @@ #define __BINARY_C_LINT_SKIP #define __NATIVE_ALL__ + +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif // _GNU_SOURCE #include "binary_c_code_options.h" #include "binary_c_debug.h" #include "../binary_c.h" diff --git a/src/debug/debug_prototypes.h b/src/debug/debug_prototypes.h index ca98ed5a07df2bf878345f87019f313f9dad0344..e9cad65b843ea2f578e3a44e354cfbff1d107082 100644 --- a/src/debug/debug_prototypes.h +++ b/src/debug/debug_prototypes.h @@ -29,4 +29,8 @@ void diff_stardata(struct stardata_t * const stardata MAYBE_UNUSED); #include "libbacktrace_prototypes.h" #endif +#ifndef VALGRIND +void test_for_valgrind(void); +#endif + #endif // DEBUG_PROTOTYPES_H diff --git a/src/debug/test_for_valgrind.c b/src/debug/test_for_valgrind.c new file mode 100644 index 0000000000000000000000000000000000000000..fda156b5a447d44225ff826aa1369790a1a41a73 --- /dev/null +++ b/src/debug/test_for_valgrind.c @@ -0,0 +1,53 @@ +#include "binary_c.h" +No_empty_translation_unit_warning; + + +#ifndef VALGRIND + +#undef exit + +#ifdef __HAVE_VALGRIND__ +#include "valgrind/valgrind.h" +#endif//__HAVE_VALGRIND__ + +void test_for_valgrind(void) +{ + /* + * Test for whether we are running undef Valgrind. + * + * If we are, and we haven't built binary_c using + * "meson -Dvalgrind=true" (or similar) stop running + * because we are likely to crash. + */ + Boolean running_under_valgrind = FALSE; + +#ifdef __HAVE_VALGRIND__ + /* + * If we have valgrind development files installed, + * use the RUNNING_ON_VALGRIND macro to do the detection. + */ + if(RUNNING_ON_VALGRIND) running_under_valgrind = TRUE; +#endif//__HAVE_VALGRIND__ + + /* + * Fallback: test LD_PRELOAD + */ + char * ld_preload = getenv("LD_PRELOAD"); + if(ld_preload && + ( + strstr(ld_preload, "/valgrind/") != NULL + || + strstr(ld_preload, "/vgpreload") != NULL) + ) + { + running_under_valgrind = TRUE; + } + + + if(running_under_valgrind == TRUE) + { + printf("You are trying to run binary_c through valgrind without building with valgrind support. On some architectures this will fail, so please configure binary_c with something like\n\nmeson -Dvalgrind=true builddir\n\nand rebuild.\n"); + exit(1); + } +} +#endif // VALGRIND diff --git a/src/evolution/set_next_timestep.c b/src/evolution/set_next_timestep.c index e1ca855c001c2f467595c65f904ccc178bd41fbd..3d28b44030ab87062c2453cf2e1a3fa7f84d1ff7 100644 --- a/src/evolution/set_next_timestep.c +++ b/src/evolution/set_next_timestep.c @@ -37,6 +37,17 @@ void set_next_timestep(struct stardata_t * RESTRICT const stardata) stardata->model.dtm); } + /* + * Apply nonstellar timestep + */ + double dtm = time_remaining; + nonstellar_timestep(stardata,&dtm); + stardata->model.dtm = + Is_zero(stardata->model.dtm) ? + dtm : + Min(stardata->model.dtm, + dtm); + Dprint("nonstellar timestep %g\n",stardata->model.dtm); /* * Save the timestep on the first diff --git a/src/exit_binaryc.c b/src/exit_binaryc.c index 3070294702302cf4851be32c425895160d37de19..5a3a3fe24f9f830fae726c2238076c54a930824b 100644 --- a/src/exit_binaryc.c +++ b/src/exit_binaryc.c @@ -4,7 +4,6 @@ * * Note the unusual header file list: please do not change it! :) */ - #include <stdlib.h> #include <stdarg.h> @@ -94,6 +93,7 @@ void Gnu_format_args(6,7) #endif //BATCHMODE } + Dprint("calling exit_binary_c_handler\n"); va_list args,dummy MAYBE_UNUSED; va_start(args,format); va_start(dummy,format); @@ -264,10 +264,7 @@ static void No_return Gnu_format_args(8,0) * Non-batchmode or batchmode is off : actually exit */ Dprint("binary_c : we really want to exit (not a batchmode long jump)\n"); - if((binary_c_error_code!=BINARY_C_NORMAL_EXIT && - binary_c_error_code!=BINARY_C_QUIET_EXIT && - binary_c_error_code!=BINARY_C_SPECIAL_EXIT && - binary_c_error_code!=BINARY_C_NORMAL_BATCHMODE_EXIT) || (DEBUG)) + if(Binary_c_error_code_is_bad(binary_c_error_code) || (DEBUG)) { /* * If stdout is not a terminal, e.g. it's a file, @@ -321,7 +318,9 @@ static void No_return Gnu_format_args(8,0) /* * Free all allocated memory, including the preferences, store and tmpstore */ + printf("try to free memory\n");fflush(NULL); if(stardata!=NULL) free_memory(&stardata,TRUE,TRUE,TRUE,TRUE,TRUE); + printf("now try to exit\n");fflush(NULL); #undef exit diff --git a/src/logging/logfile_string.c b/src/logging/logfile_string.c index 45d0c37773edba4bbc4631e4b2ea507e3dc63caf..aba948b6bf485c48ad586a11823cc0d86717fed3 100644 --- a/src/logging/logfile_string.c +++ b/src/logging/logfile_string.c @@ -128,7 +128,7 @@ char * logfile_string(const double time, #else snprintf(logstring, LOGSTRINGLENGTH, - "%s%11.4lf%s%9.3lf%s%s%9.3lf%s%s%3s%s%s%3s%s%s%13.5g%s%s%8.3g%c%s%s%6.2lf%s%s%s%s%8.3lf%s%s%s%8.3lf%s %s%s%s", + "%s%11.4lf%s%9.3lf%s%s%9.3lf%s%s%3s%s%s%3s%s%s%13.5g%s%s%9.3g%c%s%s%6.2lf%s%s%s%s%8.3lf%s%s%s%8.3lf%s %s%s%s", File_log_colour(stardata->store->colours[ORANGE]), time, File_log_colour(stardata->store->colours[RED]), diff --git a/src/logging/open_log_files.c b/src/logging/open_log_files.c index 3ad788844776fd993c72c9772a01b5225ac1471a..896e4ddb5bdaa83022944533b6e0d7421d80974a 100644 --- a/src/logging/open_log_files.c +++ b/src/logging/open_log_files.c @@ -45,7 +45,7 @@ void open_log_files(FILE *(*log_fp), { /* redirect output to stdout */ *log_fp=stdout; - fprintf(*log_fp,"%s TIME M1 M2 K1 K2 SEP%s PER%s ECC%s R1/ROL1 R2/ROL2 TYPE", + fprintf(*log_fp,"%s TIME M1 M2 K1 K2 SEP%s PER%s ECC%s R1/ROL1 R2/ROL2 TYPE", File_log_colour(stardata->store->colours[WHITE]), logspace, logspace, @@ -64,7 +64,7 @@ void open_log_files(FILE *(*log_fp), { /* redirect output to stderr */ *log_fp=stderr; - fprintf(*log_fp," TIME M1%s M2%s K1%s K2%s SEP%s PER%s ECC%s R1/ROL1%s R2/ROL2%s TYPE%s", + fprintf(*log_fp," TIME M1%s M2%s K1%s K2%s SEP%s PER%s ECC%s R1/ROL1%s R2/ROL2%s TYPE%s", File_log_colour(stardata->store->colours[WHITE]), logspace, logspace, @@ -105,7 +105,7 @@ void open_log_files(FILE *(*log_fp), else { fprintf(*log_fp, - "%s TIME M1%s M2%s K1%s K2%s SEP%s PER%s ECC%s R1/ROL1%s R2/ROL2%s TYPE RANDOM_SEED=%ld RANDOM_COUNT=%ld%s", + "%s TIME M1%s M2%s K1%s K2%s SEP%s PER%s ECC%s R1/ROL1%s R2/ROL2%s TYPE RANDOM_SEED=%ld RANDOM_COUNT=%ld%s", File_log_colour(stardata->store->colours[WHITE]), logspace, logspace, diff --git a/src/main.c b/src/main.c index 27f4f0f3585b2ebb72f129815e6cedd53baaa726..acd9f049121f166251e4e2fdaf475214c53e1914 100644 --- a/src/main.c +++ b/src/main.c @@ -36,7 +36,6 @@ static void vector_tests(void); // will be removed! int main (int argc, char ** argv) { - /* * This is binary_c's entry point when called on the * command line. @@ -45,6 +44,10 @@ int main (int argc, * options, make a stardata, then call binary_c main * with the stardata. */ +#ifndef VALGRIND + test_for_valgrind(); +#endif + #ifdef ALTSTACK char * altstack = setup_segfaults(); #endif @@ -86,7 +89,6 @@ static int binary_c_main(int argc, * * First, do the main memory allocations and build the store */ - main_allocations(&stardata, NULL, &preferences, diff --git a/src/massive/COCoreToProtoMassDelayed.c b/src/massive/COCoreToProtoMassDelayed.c deleted file mode 100644 index 0aa7c7aa79914d4fdd502fabde15d1c341d02b9e..0000000000000000000000000000000000000000 --- a/src/massive/COCoreToProtoMassDelayed.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "../binary_c.h" -No_empty_translation_unit_warning; - - -double Constant_function COCoreToProtoMassDelayed(const double COCoreMass) -{ - /* - Equation 18 in Fryer et al 2012 - - Parameters - ----------- - COCoreMass : double - Mass of the CO core in Msol - - Returns - -------- - Mproto : double - Mass of the Fe/Ni proto core in Msol - - -- Simon Stevenson - */ - return - COCoreMass < 3.5 ? 1.2 : - COCoreMass < 6.0 ? 1.3 : - COCoreMass < 11.0 ? 1.4 : - 1.6; -} diff --git a/src/massive/COCoreToProtoMassRapid.c b/src/massive/COCoreToProtoMassRapid.c index e31dd4f028bd27db384bb190209fbabc5421380a..2744b6202c4550b87bf8aee1d11027fdcc439f69 100644 --- a/src/massive/COCoreToProtoMassRapid.c +++ b/src/massive/COCoreToProtoMassRapid.c @@ -4,19 +4,19 @@ No_empty_translation_unit_warning; double Constant_function COCoreToProtoMassRapid(const double COCoreMass) { - /* +/* Equation 10 in Fryer et al 2012 - + Parameters ------------ COCoreMass : double Carbon Oxygen (CO) core mass in Msol - + Returns -------- Mproto : double Mass of Fe/Ni proto core in Msol - + -- Simon Stevenson */ if(COCoreMass < 4.82) @@ -34,6 +34,5 @@ double Constant_function COCoreToProtoMassRapid(const double COCoreMass) else { return 0.37 * COCoreMass - 0.07; - } + } } - diff --git a/src/massive/Fryer2012.c b/src/massive/Fryer2012.c new file mode 100644 index 0000000000000000000000000000000000000000..397611431f48e067bf69dba995ad5eee3fd564c7 --- /dev/null +++ b/src/massive/Fryer2012.c @@ -0,0 +1,234 @@ +#include "../binary_c.h" +No_empty_translation_unit_warning; + +/* + * Fryer et al. (ApJ 749,91 2012) functions + * + * https://iopscience.iop.org/article/10.1088/0004-637X/749/1/91/pdf + * + * The notation in here follows the paper, and I while + * have written a few comments, you should check the paper + * for details. + * + * Startrack algorithm: Eqs 10-14 + * Rapid algorithm: Eqs 15-17 + * Delayed algorithm: Eqs 18-20 + */ + +/* + * Startrack algorithm + */ +double Constant_function Fryer2012_Eq10(const double Mc_CO) +{ + /* + * Final Fe/Ni core mass, M_proto, based on + * Hurley et al. (2000) and Timmes et al. (1996) + */ + return + Mc_CO < 4.82 ? 1.50 : + Mc_CO < 6.31 ? 2.11 : + Mc_CO < 6.75 ? (0.69 * Mc_CO - 2.26) : + (0.37 * Mc_CO - 0.07); +} + +double Constant_function Fryer2012_Eq11(const double M, + const double Mc_CO, + const double M_proto) +{ + /* + * Fallback mass, M_fb, as a function of core mass. + */ + const double M_fb = + Mc_CO < 5.0 ? 0.0 : + ( + (M - M_proto) * + ( + Mc_CO < 7.6 ? (0.378 * Mc_CO - 1.889) : + 1.0 + ) + ); + return Limit_range(M_fb,0.0,M - M_proto); +} + +double Constant_function Fryer2012_Eq12(const double M_proto, + const double M_fb) +{ + /* + * Remnant baryonic mass + */ + return M_proto + M_fb; +} + +double Constant_function Fryer2012_Eq13(const double M_remnant_baryonic) +{ + /* + * Remnant gravitational mass of neutron stars + */ + return M_remnant_baryonic - 0.075 * Pow2(M_remnant_baryonic); +} + +double Constant_function Fryer2012_Eq14(const double M_remnant) +{ + /* + * Remnant gravitational mass of black holes + */ + return M_remnant * 0.9; +} + +double Constant_function Fryer2012_remnant_gravitational_mass(const struct stardata_t * const stardata, + const double M_remnant_baryonic) +{ + /* + * Wrapper for Eqs. 13,14 to act based on stellar type + */ + return + M_remnant_baryonic < stardata->preferences->max_neutron_star_mass ? + Fryer2012_Eq13(M_remnant_baryonic): /* NS */ + Fryer2012_Eq14(M_remnant_baryonic); /* BH */ +} + +/* + * Rapid algorithm + */ +double Constant_function Fryer2012_Eq15(const double Mc_CO MAYBE_UNUSED) +{ + /* + * Proto-compact object mass + */ + return 1.0; +} + +double Constant_function Fryer2012_Eq16(const double M, + const double Mc_CO, + const double M_proto) +{ + /* + * Fallback mass, M_fb + */ + + /* this is in the Fryer paper */ +//#define Eq16_a1 (0.25 - (1.275/M - M_proto)) + /* but it probably should be this, as in Spera+2015 */ +#define Eq16_a1 (0.25 - (1.275/(M - M_proto))) + +#define Eq16_b1 (-11.0 * Eq16_a1 + 1.0) + const double M_fb = + Mc_CO < 2.5 ? 0.2 : + Mc_CO < 6.0 ? (0.286 * Mc_CO - 0.514) : + ( + (M - M_proto) * ( + Mc_CO < 7.0 ? 1.0 : + Mc_CO < 11.0 ? (Eq16_a1 * Mc_CO + Eq16_b1) : + 1.0 + ) + ); + return Limit_range(M_fb,0.0,M - M_proto); +} + +double Constant_function Fryer2012_Eq17(const double M_proto, + const double M_fb) +{ + /* + * Remnant baryonic mass + */ + return M_proto + M_fb; +} + + +/* + * Delayed algorithm + */ +double Constant_function Fryer2012_Eq18(const double Mc_CO) +{ + /* + * M_proto + */ + return + Mc_CO < 3.5 ? 1.2 : + Mc_CO < 6.0 ? 1.3 : + Mc_CO < 11.0 ? 1.4 : + 1.6; +} + +double Constant_function Fryer2012_Eq19(const double M, + const double Mc_CO, + const double M_proto) +{ + +/* this is in the paper */ +//#define Eq19_a2 (0.133 - (0.093/M - M_proto)) + +/* but it probably should be this */ +#define Eq19_a2 (0.133 - (0.093/(M - M_proto))) + +#define Eq19_b2 (-11.0*Eq19_a2 + 1.0) + const double M_fb = + Mc_CO < 2.5 ? 0.2 : + Mc_CO < 3.5 ? (0.5 * Mc_CO - 1.05) : + ( + (M - M_proto) * + ( + Mc_CO < 11.0 ? (Eq19_a2 * Mc_CO + Eq19_b2) : + 1.0 + ) + ); + return Limit_range(M_fb, 0.0, M - M_proto); +} + +double Constant_function Fryer2012_Eq20(const double M_proto, + const double M_fb) +{ + /* + * Remnant baryonic mass + */ + return M_proto + M_fb; +} + +/* + * Wrapper functions + * + * Use these to select based on which of the three prescriptions + * you wish to use. + */ +double Fryer2012_M_fb(struct stardata_t * const stardata, + const double M, + const double Mc_CO, + const double M_proto) +{ + return + stardata->preferences->BH_prescription==BH_FRYER12_DELAYED ? + Fryer2012_Eq19(M,Mc_CO,M_proto) : + stardata->preferences->BH_prescription==BH_FRYER12_RAPID ? + Fryer2012_Eq16(M,Mc_CO,M_proto) : + stardata->preferences->BH_prescription==BH_FRYER12_STARTRACK ? + Fryer2012_Eq11(M,Mc_CO,M_proto) : + 0.0; +} + +double Fryer2012_M_proto(struct stardata_t * const stardata, + const double Mc_CO) +{ + return + stardata->preferences->BH_prescription==BH_FRYER12_DELAYED ? + Fryer2012_Eq18(Mc_CO) : + stardata->preferences->BH_prescription==BH_FRYER12_RAPID ? + Fryer2012_Eq15(Mc_CO) : + stardata->preferences->BH_prescription==BH_FRYER12_STARTRACK ? + Fryer2012_Eq10(Mc_CO) : + 0.0; +} + +double Fryer2012_f_fb(struct stardata_t * const stardata, + const double M, + const double Mc_CO) +{ + /* + * Fallback fraction + */ + const double M_proto = + Fryer2012_M_proto(stardata,Mc_CO); + const double M_fb = + Fryer2012_M_fb(stardata,M,Mc_CO,M_proto); + + return Limit_range(M_fb / (M - M_proto), 0.0, 1.0); +} diff --git a/src/massive/baryonicRemnantMassGeneral.c b/src/massive/baryonicRemnantMassGeneral.c deleted file mode 100644 index 92517375abd94247f630243e923bb54c9ca134de..0000000000000000000000000000000000000000 --- a/src/massive/baryonicRemnantMassGeneral.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "../binary_c.h" -No_empty_translation_unit_warning; - - -double Constant_function baryonicRemnantMassGeneral(const double Mproto, - const double Mfb) -{ - /* - Equation 12 in Fryer et al 2012 - - Parameters - ----------- - Mproto : double - Mass of proto compact object in Msol - Mfb : double - Mass falling back onto proto compact object Mfb = fb*(MpreSN - Mproto) - - Returns - -------- - Mremnant, baryonic : double - Baryonic mass of remnant - - -- Simon Stevenson - */ - return Mproto + Mfb; //Mfb = fb*(MpreSN - Mproto); -} diff --git a/src/massive/massive_prototypes.h b/src/massive/massive_prototypes.h index 90bd3608d11c110c71ebe93d3ae9549503158746..9df82b6107cb64edf6046312e8b7134b3d53ec15 100644 --- a/src/massive/massive_prototypes.h +++ b/src/massive/massive_prototypes.h @@ -3,19 +3,37 @@ #define MASSIVE_PROTOTYPES_H +double Constant_function Fryer2012_Eq10(const double Mc_CO); +double Constant_function Fryer2012_Eq11(const double M, + const double Mc_CO, + const double M_proto); +double Constant_function Fryer2012_Eq12(const double M_proto, + const double M_fb); +double Constant_function Fryer2012_Eq13(const double M_remnant_baryonic); +double Constant_function Fryer2012_Eq14(const double M_remnant); +double Constant_function Fryer2012_Eq15(const double Mc_CO MAYBE_UNUSED); +double Constant_function Fryer2012_Eq16(const double M, + const double Mc_CO, + const double M_proto); +double Constant_function Fryer2012_Eq17(const double M_proto, + const double M_fb); +double Constant_function Fryer2012_Eq18(const double Mc_CO); +double Constant_function Fryer2012_Eq19(const double M, + const double Mc_CO, + const double M_proto); +double Constant_function Fryer2012_Eq20(const double M_proto, + const double M_fb); +double Constant_function Fryer2012_remnant_gravitational_mass(const struct stardata_t * const stardata, + const double M_baryon); -double Constant_function fallbackDelayed(const double MpreSN, - const double Mproto, - const double COCoreMass); -double Constant_function fallbackRapid(const double MpreSN, - const double Mproto, - const double COCoreMass); -double Constant_function COCoreToProtoMassRapid(const double COCoreMass); -double Constant_function COCoreToProtoMassDelayed(const double COCoreMass); -double Constant_function massFallbackGeneral(const double MpreSN, - const double Mproto, - const double fb); -double Constant_function baryonicRemnantMassGeneral(const double Mproto, - const double Mfb); +double Fryer2012_M_fb(struct stardata_t * const stardata, + const double M, + const double Mc_CO, + const double M_proto); +double Fryer2012_M_proto(struct stardata_t * const stardata, + const double Mc_CO); +double Fryer2012_f_fb(struct stardata_t * const stardata, + const double M, + const double Mc_CO); #endif // MASSIVE_PROTOTYPES_H diff --git a/src/memory/free_memory.c b/src/memory/free_memory.c index 1610becb4112a6ede216684556f626ef97952b77..9fcc16d4d6eb80fc2f08d5434696d7e757c908c2 100644 --- a/src/memory/free_memory.c +++ b/src/memory/free_memory.c @@ -46,12 +46,14 @@ void free_memory(struct stardata_t ** RESTRICT const sp, * Free persistent data including calls to routines * to output the data if required. */ - if(free_persistent == TRUE) + if(stardata != NULL && free_persistent == TRUE) { FMDebug("persistent_data %p\n",(void*)stardata->persistent_data); - free_persistent_data(*sp); + free_persistent_data(stardata); } + FMDebug("done that\n"); + #ifdef MEMMAP FMDebug("Call munmap\n"); munmap(stardata->biglog,BIGLOG_SIZE); diff --git a/src/memory/free_persistent_data.c b/src/memory/free_persistent_data.c index 8bd9e6b5a119fbb56674c4a5ee529715dee6e63a..b278e2a32b7808076ce4429ff35015340f28c26c 100644 --- a/src/memory/free_persistent_data.c +++ b/src/memory/free_persistent_data.c @@ -13,6 +13,7 @@ void free_persistent_data(struct stardata_t * const stardata) (void*)stardata, (void*)(stardata?stardata->persistent_data:NULL)); + if(stardata != NULL && stardata->persistent_data != NULL) { @@ -24,14 +25,20 @@ void free_persistent_data(struct stardata_t * const stardata) #ifdef STELLAR_POPULATIONS_ENSEMBLE Dprint("free ensemble hash at %p ?\n", (void*)stardata->persistent_data->ensemble_hash); + if(stardata->persistent_data->ensemble_hash != NULL) { Dprint("call ensemble log\n"); + stardata->model.ensemble_hash = stardata->persistent_data->ensemble_hash; - ensemble_log(stardata,TRUE); + if(!Binary_c_error_code_is_bad(stardata->error_code)) + { + ensemble_log(stardata,TRUE); + } RCHash_free(stardata->persistent_data->ensemble_hash); Dprint("freed: hash is now %p\n", (void*)stardata->persistent_data->ensemble_hash); + stardata->persistent_data->ensemble_hash = NULL; stardata->model.ensemble_hash = NULL; } @@ -40,12 +47,15 @@ void free_persistent_data(struct stardata_t * const stardata) Dprint("freeing stardata=%p -> persistent_data = %p\n", (void*)stardata, (void*)stardata->persistent_data); + Safe_free(stardata->persistent_data); + } else { Dprint("free persistent data called on stardata = %p stardata->persistent_data = %p\n", (void*)stardata, (void*)(stardata->persistent_data)); + } } diff --git a/src/nucsyn/nucsyn_helium_checkfunction.c b/src/nucsyn/nucsyn_helium_checkfunction.c index e59f3ca0e71682829d4a38e3501638fdaa4c6b8d..59a5b702c34c4f77ca3f0dc82df9396c8d646b8a 100644 --- a/src/nucsyn/nucsyn_helium_checkfunction.c +++ b/src/nucsyn/nucsyn_helium_checkfunction.c @@ -1,6 +1,7 @@ #include "../binary_c.h" No_empty_translation_unit_warning; +#ifdef NUCSYN Boolean nucsyn_helium_checkfunction(struct stardata_t * const stardata MAYBE_UNUSED, double * const N, const double temperature, @@ -13,3 +14,4 @@ Boolean nucsyn_helium_checkfunction(struct stardata_t * const stardata MAYBE_UNU */ return (N[XHe4]>TINY && temperature >= 0.8e8) ? TRUE : FALSE; } +#endif//NUCSYN diff --git a/src/nucsyn/nucsyn_hydrogen_checkfunction.c b/src/nucsyn/nucsyn_hydrogen_checkfunction.c index 95a599caee5bc9e9940b2e443f474e760fbfe1bf..4fc2669ed43efeb3caa8c7d0af301013b8c0d33c 100644 --- a/src/nucsyn/nucsyn_hydrogen_checkfunction.c +++ b/src/nucsyn/nucsyn_hydrogen_checkfunction.c @@ -1,6 +1,8 @@ #include "../binary_c.h" No_empty_translation_unit_warning; +#ifdef NUCSYN + Boolean nucsyn_hydrogen_pp_checkfunction(struct stardata_t * const stardata MAYBE_UNUSED, double * const N, const double temperature, @@ -55,3 +57,5 @@ Boolean nucsyn_hydrogen_NeNaMgAl_checkfunction(struct stardata_t * const stardat N[XAl26]>TINY) && temperature >= 1e6) ? TRUE : FALSE; } + +#endif//NUCSYN diff --git a/src/perl/modules_targz/Binning-0.03.tar.gz b/src/perl/modules_targz/Binning-0.03.tar.gz index f1651bce2b184e47aa933a329a424c6a99d35a09..e91706941e37da728c9838ae956ef4dd0245a924 100644 Binary files a/src/perl/modules_targz/Binning-0.03.tar.gz and b/src/perl/modules_targz/Binning-0.03.tar.gz differ diff --git a/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz b/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz index b5f0b0af9efcfe48fd04bfb28aa9c434fba4dc4f..68a8d2ddde6e55fba514e62f475ef337a6b78372 100644 Binary files a/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz and b/src/perl/modules_targz/Data-Serializer-RobJSON-0.05.tar.gz differ diff --git a/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz b/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz index 2f4b339b77e6462a9eaa14129f510be98268b740..771a95e61e5ef274710ee6f0aa2d8ef60f75391b 100644 Binary files a/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz and b/src/perl/modules_targz/Hash-RobMerge-0.14.tar.gz differ diff --git a/src/perl/modules_targz/Histogram-0.01.tar.gz b/src/perl/modules_targz/Histogram-0.01.tar.gz index 316bce9d5ac2ab00cc663fdb103faf1efe2acd8b..0d628fcf7f8c5767ea8c7b7090d43a4028a24773 100644 Binary files a/src/perl/modules_targz/Histogram-0.01.tar.gz and b/src/perl/modules_targz/Histogram-0.01.tar.gz differ diff --git a/src/perl/modules_targz/IMF-0.05.tar.gz b/src/perl/modules_targz/IMF-0.05.tar.gz index 0c2d72ad48f75fbc6a60102421b119c4bcdb5eee..d5b99f0833cfd9666a5f50fb4c08fe3c66632909 100644 Binary files a/src/perl/modules_targz/IMF-0.05.tar.gz and b/src/perl/modules_targz/IMF-0.05.tar.gz differ diff --git a/src/perl/modules_targz/Maths_Double-0.01.tar.gz b/src/perl/modules_targz/Maths_Double-0.01.tar.gz index 95851d56a29a43d614c3e35b9911da8227e8fe9c..15b02ce0400deaf649c2077531bffb43bbbf02a7 100644 Binary files a/src/perl/modules_targz/Maths_Double-0.01.tar.gz and b/src/perl/modules_targz/Maths_Double-0.01.tar.gz differ diff --git a/src/perl/modules_targz/binary_grid-v2.1.7.tar.gz b/src/perl/modules_targz/binary_grid-v2.1.7.tar.gz index 314dedf2edc1b1b74550e89de899e30e434a475b..99f559af75498e271185bbe383bed49733a0bd85 100644 Binary files a/src/perl/modules_targz/binary_grid-v2.1.7.tar.gz and b/src/perl/modules_targz/binary_grid-v2.1.7.tar.gz differ diff --git a/src/perl/modules_targz/binary_stars-0.05.tar.gz b/src/perl/modules_targz/binary_stars-0.05.tar.gz index cdc1cb96a526001be784ba3a235f43368a2e81f3..2d6e56f3c1273aeadf86b75f6fbb88603f151efb 100644 Binary files a/src/perl/modules_targz/binary_stars-0.05.tar.gz and b/src/perl/modules_targz/binary_stars-0.05.tar.gz differ diff --git a/src/perl/modules_targz/cosmology-0.01.tar.gz b/src/perl/modules_targz/cosmology-0.01.tar.gz index b9b69634e9802bc8ac7fe11f564cf0840aab3fea..a6a10f151f12338202cd7388e5862575d4f0597e 100644 Binary files a/src/perl/modules_targz/cosmology-0.01.tar.gz and b/src/perl/modules_targz/cosmology-0.01.tar.gz differ diff --git a/src/perl/modules_targz/distribution_functions-0.06.tar.gz b/src/perl/modules_targz/distribution_functions-0.06.tar.gz index bc4746f381822d4367836deefe60396553db63db..ea220ab9710142f97aee89824ecb3a0375f143cc 100644 Binary files a/src/perl/modules_targz/distribution_functions-0.06.tar.gz and b/src/perl/modules_targz/distribution_functions-0.06.tar.gz differ diff --git a/src/perl/modules_targz/rinterpolate-1.5.tar.gz b/src/perl/modules_targz/rinterpolate-1.5.tar.gz index cf390ac5c303c6aea018761cd7e13a6f2e62c13e..7244fa2fc84e5e1b6b0285e1d54e734203477c05 100644 Binary files a/src/perl/modules_targz/rinterpolate-1.5.tar.gz and b/src/perl/modules_targz/rinterpolate-1.5.tar.gz differ diff --git a/src/perl/modules_targz/rob_misc-0.17.tar.gz b/src/perl/modules_targz/rob_misc-0.17.tar.gz index 7fa8831b5ac2123662d9ef446c9f57d8e47d5bf4..d84844d8746cd33b655111dfe0c4592c87722897 100644 Binary files a/src/perl/modules_targz/rob_misc-0.17.tar.gz and b/src/perl/modules_targz/rob_misc-0.17.tar.gz differ diff --git a/src/perl/modules_targz/robqueue-0.05.tar.gz b/src/perl/modules_targz/robqueue-0.05.tar.gz index 0a68162d73e1bf5a0ad5ab31c74b9fcf76526cdc..66b173f758b6fd55a0bd3b54bb9b7c59f4522988 100644 Binary files a/src/perl/modules_targz/robqueue-0.05.tar.gz and b/src/perl/modules_targz/robqueue-0.05.tar.gz differ diff --git a/src/perl/modules_targz/spacing_functions-0.02.tar.gz b/src/perl/modules_targz/spacing_functions-0.02.tar.gz index 1727f72db8c69137788f20c205a169732b5b9a1b..8d984a19f902c0b39d72d33404de738a9b734a88 100644 Binary files a/src/perl/modules_targz/spacing_functions-0.02.tar.gz and b/src/perl/modules_targz/spacing_functions-0.02.tar.gz differ diff --git a/test_random.pl b/src/perl/scripts2/test_random.pl similarity index 66% rename from test_random.pl rename to src/perl/scripts2/test_random.pl index 44802000aa321a1bffc2b790a42e45b69944febf..c2ccef4f65d6763f6e68a37275e7528271c47200 100755 --- a/test_random.pl +++ b/src/perl/scripts2/test_random.pl @@ -1,5 +1,6 @@ #!/usr/bin/env perl $|=1; + use strict; use IO::Select; use rob_misc; @@ -11,6 +12,7 @@ use Term::ReadKey; use Term::ANSIScreen qw(cls :cursor); use Text::ANSITable; binmode(STDOUT, ":utf8"); +use Time::HiRes qw/sleep/; use Term::ANSIColor; # @@ -20,6 +22,12 @@ use Term::ANSIColor; # which is a little slow. # +my %colours = ( + 'cyan' => color('bright_cyan'), + 'yellow' => color('bright_yellow'), + 'red' => color('bright_red'), + 'reset' => color('reset') +); my ($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize(); my $args = "@ARGV"; @@ -33,24 +41,29 @@ my $logtimes = ($args=~/logtimes/) ? 1 : 0; my $ignore_time = ($args=~/ignore_time=(\S+)/)[0] // 2.0; # do not log time if < this my $exit_on_error = ($args=~/exit_on_error/) // 0; my $newlogs = ($args=~/newlogs/) ? 1 : 0; +my $errorlogdir = ($args=~/errorlogdir=(\S+)/)[0] // '/tmp/binary_c_errorlogs'; +mkdirhier($errorlogdir); my $opener = $newlogs ? '>' : '>>'; open(my $log,$opener,"$ENV{HOME}/binary_c_test_random.log")||die; open(my $logtimes_file,$opener,"$ENV{HOME}/binary_c_test_random.logtimes")||die; my $locklog :shared; $log->autoflush(1); +my $errorcount : shared; +$errorcount = 0; my @screenlog : shared; my $settle = ($args=~/(settle)/)[0] // 10; # wait this many seconds before output -my $sleeptime = ($args=~/sleeptime=(\S+)/)[0] // 0.25; # number of s to wait between checking for binary_c output +my $sleeptime = ($args=~/sleeptime=(\S+)/)[0] // 0.25; # number of s to wait between checking for binary_c output +my $updatetime = ($args=~/updatetime=(\S+)/)[0] // 1.0; # time between screen updates my $twarn = ($args=~/twarn=(\S+)/)[0] // 180.0; # warn if no output for this time my $warn_every = ($args=~/warn_every=(\S+)/)[0] // 10.0; # warn every this many seconds my $n_binary_c_threads = ($args=~/threads=cpu/i) ? (rob_misc::ncpus()-1) : ($args=~/threads=(\d+)/)[0] // 1; my $nstore = ($args=~/nstore=(\d+)/)[0] // 1000;# store this many lines of output -print "Options : +print "Options : valgrind $valgrind nice : $nice timeout : $timeout -repeat : $repeat +repeat : $repeat logtimes : $logtimes ignore_time : $ignore_time settle : $settle @@ -70,8 +83,6 @@ my $q = robqueue->new( ); my $tsincewarn = 0; - - while(1) { $q->q(1); @@ -82,19 +93,23 @@ $q->end(); sub runsystem { my $n = shift; + my $pid = 0; if($n==0) { - # first thread + # first thread + sleep 1; while(1) { - sleep 1; + sleep $updatetime; outscreenlog(); } } else { my $s = IO::Select->new(); - my $cmd = "stdbuf -i 0 -e 0 -o 0 $nice $timeout tbse $valgrind --repeat $repeat --random_systems 1 --log_filename /tmp/c_log-$n.dat 2>\&1 "; + my $cmd = "env VALGRIND_ARGS=\"--log-file=/dev/stdout\" stdbuf -i 0 -e 0 -o 0 $nice $timeout tbse $valgrind --repeat $repeat --random_systems 1 --log_filename /tmp/c_log-$n.dat 2>&1 "; + #print "CMD \n$cmd\n"; + my $args; my $logfile = "/tmp/binary_c_test_random_log.$n"; open(my $outlog,'>',$logfile)||confess("cannot open $logfile for output"); @@ -107,13 +122,16 @@ sub runsystem my $tsincewarn = $warn_every; while(defined $f && $f) { + my $haveset = 0; my @can = $s->can_read(0.25); + #print localtime(),"Can ? ",scalar @can," \x0d"; if(scalar @can) { my $l = <$f>; + #print "L: $l"; if(!defined $l) { - # EOF : command has finished + # EOF : command has finished close $f; $f = undef; } @@ -121,7 +139,7 @@ sub runsystem { # line of data : process print {$outlog} $l; - + push(@r,$l); # if we've exceeded the number of saved lines, remove the top one @@ -129,11 +147,16 @@ sub runsystem { shift @r; } - + if($l=~/(--M_1.*)/g) { $args = $1; - setlog($n,$tsince,"$args\n"); + setlog($n,$tsince,$pid,"$args\n"); + $haveset = 1; + } + elsif($l=~/==(\d+)==/) + { + $pid = $1; } elsif($l=~/runtime\s+=\s+(\S+)/) { @@ -142,7 +165,7 @@ sub runsystem { state $logtimes_lock : shared; printf {$logtimes_file} "%s %s\n", - $runtime, + $runtime, $args; } } @@ -152,37 +175,55 @@ sub runsystem else { $tsince += $sleeptime; - + if($tsince >= $twarn) { if($tsincewarn >= $warn_every ) { $tsincewarn = 0; - setlog($n,$tsince,"Warning : thread $n has had no output for $tsince seconds\n"); + setlog($n, + $tsince, + $pid, + "Warning : thread $n has had no output for $tsince seconds\n"); + $haveset = 1; } else { - $tsincewarn += $sleeptime; + $tsincewarn += $sleeptime; } } } + if(!$haveset) + { + setlog($n,$tsince,$pid,"$args\n"); + } } close $f if(defined $f); my $status = $?; - setlog($n, 0, "thread $n finished with status $status\n"); + setlog($n, 0, $pid, "thread $n finished with status $status\n"); my $r = join("\n",@r); if($status!=0 || $r =~ /Exit\ binary/ || $r =~ /action on error/ || $r =~ /jump or move depends on uninit/ || - $r =~ /definitely lost/) + $r =~ /definitely lost/ || + #$r =~/vgdb me/|| + $r =~/SIGSEGV/) { my $file = '/tmp/test_random_error'.$n.'.out'; print "Error on thread $n (see $file)\n\n$args\n\n"; dumpfile($file,$r); - print {$log} "\n# Error on thread $n :\n# $args\n\n"; - + + # dump to the errorlogdir also + if(defined $errorlogdir) + { + lock $locklog; + $file = "$errorlogdir/$errorcount.log"; + print {$log} "\n# Error on thread $n (count $errorcount) :\n# $args\n\n"; + dumpfile($file,$r); + $errorcount++; + } if($exit_on_error) { exit(0); @@ -202,14 +243,10 @@ sub memuse if($t > $first) { $mem = mem_usage(1,$$,1); - if($mem!=$prev) - { - printf "MEM %s MB\n",$mem; - } if(!defined $prev || $mem>$prev) { lock $locklog; - printf {$log} "%s %s\n",time(),$mem; + printf {$log} "MEM %s %s %s\n",time(),$mem,scalar localtime(); $prev = $mem; } } @@ -232,27 +269,42 @@ sub setlog { # set log grid string state $setlog_lock : shared; - lock $setlog_lock; - my ($n, $tsince, $s) = @_; + lock $setlog_lock; + my ($n, $tsince, $pid, $s) = @_; chomp $s; - $screenlog[$n] = shared_clone([$tsince,$s]); + my $colour = + $tsince >= 5.0 ? $colours{'red'} : + $tsince >= 1.0 ? $colours{'yellow'} : + $colours{'cyan'}; + my $tstring = sprintf '%s%6.2f', + $colour, + $tsince; + $screenlog[$n] = shared_clone([$tstring,$pid,$s]); } sub outscreenlog { # output log grid to screen state $setlog_lock : shared; - lock $setlog_lock; + lock $setlog_lock; my $h = 'test_random.pl '.$args.' : '.sprintf("%s",memuse()//'unknown'); my $t = Text::ANSITable->new; - $t->border_style('Default::bold'); # if not, a nice default is picked - $t->columns(["Thread","Tsince","Status"]); + #$t->border_style('Default::bold'); # if not, a nice default is picked + $t->border_style('UTF8::Brick'); + $t->columns(["Thread","Tsince","PID","Status"]); $t->set_column_style('Status',wrap=>0); - for(my $i=1;$i<=$#screenlog;$i++) + if(defined $screenlog[1]) { - $t->add_row([$i,$screenlog[$i]->[0],substr($screenlog[$i]->[1],0,$wchar-30)]); + for(my $i=1;$i<=$#screenlog;$i++) + { + $t->add_row([ + $i, + $screenlog[$i]->[0], + $screenlog[$i]->[1], + substr($screenlog[$i]->[2],0,$wchar-30)]); + } + print cls(),locate(0,0),$h,"\n",$t->draw(); } - print cls(),locate(0,0),$h,"\n",$t->draw(); } sub check_ps @@ -265,4 +317,3 @@ sub check_ps exit; } } - diff --git a/src/setup/cmd_line_args_list.h b/src/setup/cmd_line_args_list.h index eed98060308df66c7e02ec2e1524a6397852f76f..2566c7f8c6f834116b54990aedea31497dd3d103 100644 --- a/src/setup/cmd_line_args_list.h +++ b/src/setup/cmd_line_args_list.h @@ -1453,7 +1453,7 @@ BATCHMODE_ARGS { ARG_SECTION_STARS, "BH_prescription", - "Black hole mass prescrition: relates the mass of a newly formed black hole to its progenitor's (CO) core mass. 0=Hurley et al 2000/2002, 1=Belczynski (early 2000s).", + "Black hole mass prescrition: relates the mass of a newly formed black hole to its progenitor's (CO) core mass. BH_HURLEY2002 = 0 = Hurley et al 2000/2002, BH_BELCZYNSKI = 1 = Belczynski (early 2000s), BH_SPERA2015 = Spera+ 2015, BH_FRYER12_DELAYED = 3 = Fryer et al. (2012) delayed prescription, BH_FRYER12_RAPID = 4 = Fryer et al. (2012) rapid prescription, BH_FRYER12_STARTRACK = 5 = Fryer et al. (2012) startrack prescription.", ARG_INTEGER , WTTS_USE_DEFAULT, Var(stardata->preferences->BH_prescription), diff --git a/src/setup/version.c b/src/setup/version.c index acd05b5aed7a5d61059300026ef391ecb1c9d971..5fde506714940e6517e460aed58860759f541180 100644 --- a/src/setup/version.c +++ b/src/setup/version.c @@ -1272,6 +1272,7 @@ void version(struct stardata_t * RESTRICT const stardata) Show_int_macro(MAX_EXIT_STATEMENT_PRINT_SIZE); #endif Macrotest(FLUSH_LOG); + Macrotest(VALGRIND); Macrotest(__HAVE_VALGRIND__); Macrotest(__HAVE_LIBGSL__); Macrotest(__HAVE_LIBBFD__); diff --git a/src/stellar_structure/stellar_structure_AGB.c b/src/stellar_structure/stellar_structure_AGB.c index caf4e338e2865148cfca5a4086d97d8a9ad973f3..3867874e4a4bc8fe1d5b5dd4e873bd864e3fcf41 100644 --- a/src/stellar_structure/stellar_structure_AGB.c +++ b/src/stellar_structure/stellar_structure_AGB.c @@ -152,8 +152,6 @@ Stellar_type stellar_structure_AGB(struct star_t * const oldstar, force_supernova = FALSE; } /* - * RGI - * * Only allow stars with CO core mass less than the * maximum_CO_mass_for_thermal_pulses to have thermal pulses, or * those that are already thermally pulsing. @@ -161,10 +159,15 @@ Stellar_type stellar_structure_AGB(struct star_t * const oldstar, * This is because more massive stars should explode * soon after the AGB begins, and probably don't ever * have thermal pulses. + * + * We also check that TPAGB stars have core masses + * < MCh: if not, treat them as EAGB i.e. allow + * them to explode */ else if((newstar->stellar_type == TPAGB || (Is_not_zero(newstar->core_mass[CORE_CO]) && - newstar->core_mass[CORE_He] < MCh && + (newstar->stellar_type == EAGB || + newstar->core_mass[CORE_He] < MCh) && newstar->core_mass[CORE_CO] < maximum_degenerate_CO_mcbagb))) { /* TPAGB star */ diff --git a/src/stellar_timescales/stellar_timescales_high_mass_GB.c b/src/stellar_timescales/stellar_timescales_high_mass_GB.c index 011639dd41f5bbe809375687097bb857e26463d9..9b98ea774a6860f8f314fe3b545e6bddfd34e591 100644 --- a/src/stellar_timescales/stellar_timescales_high_mass_GB.c +++ b/src/stellar_timescales/stellar_timescales_high_mass_GB.c @@ -2,7 +2,7 @@ No_empty_translation_unit_warning; #ifdef BSE -void stellar_timescales_high_mass_GB(struct stardata_t * const stardata, +void stellar_timescales_high_mass_GB(struct stardata_t * const stardata MAYBE_UNUSED, const double mass, const double mp2, double * const timescales, diff --git a/src/supernovae/bh_prescriptions.def b/src/supernovae/bh_prescriptions.def index cf0d88cccc8c4832e6691f4b6ec46afee4e79c13..0a3b63830581baf4077fb48326c6e786e31820a8 100644 --- a/src/supernovae/bh_prescriptions.def +++ b/src/supernovae/bh_prescriptions.def @@ -7,7 +7,7 @@ X( BELCZYNSKI ) \ X( SPERA2015 ) \ X( FRYER12_DELAYED ) \ - X( FRYER12_RAPID ) - + X( FRYER12_RAPID ) \ + X( FRYER12_STARTRACK ) #endif // BH_PRESCRIPTIONS_DEF diff --git a/src/supernovae/ns_bh_mass.c b/src/supernovae/ns_bh_mass.c index 6e25039c3ff9e5454654bbb08897e61d97e4e592..a91088e244b178188e2b26520a316f2a017df480 100644 --- a/src/supernovae/ns_bh_mass.c +++ b/src/supernovae/ns_bh_mass.c @@ -1,23 +1,25 @@ #include "../binary_c.h" No_empty_translation_unit_warning; - - -double Pure_function ns_bh_mass(const double m, - const double mc_CO, +double Pure_function ns_bh_mass(const double M, + const double Mc_CO, struct stardata_t * RESTRICT const stardata, const struct star_t * RESTRICT const star) { /* * Function to evaluate the NS/BH remnant mass given - * total mass m and CO Core mass mc_CO + * total mass, M, and CO Core mass, Mc_CO. + * + * Note that, where we have the choice, we return the + * gravitational mass because this is the mass that goes + * into orbital calculations. */ - double mbh; + double M_remnant; /* * If we are a TPAGB star, assume the core collapses to * a NS in an electron capture supernova. This should - * only happen in unusual circumstances, or as an STPAGB star. + * only happen in unusual circumstances or as an STPAGB star. */ if(star->stellar_type==TPAGB) return star->core_mass[CORE_He]; @@ -26,37 +28,21 @@ double Pure_function ns_bh_mass(const double m, /* * Chris' NS/BH formula as in Hurley+ 2000, 2002 */ - mbh = 1.170 + 0.090*mc_CO; + M_remnant = 1.170 + 0.090 * Mc_CO; } else if(stardata->preferences->BH_prescription==BH_BELCZYNSKI) { /* * Use NS/BH mass given by Belczynski et al. 2002, ApJ, 572, 407. */ - // First set mcx - double mcx; - if(mc_CO<2.5) - { - mcx = 0.1617670*mc_CO + 1.0670550; - } - else - { - mcx = 0.3141540*mc_CO + 0.6860880; - } - // Then set the remnant mass - if(mc_CO<=5.0) - { - mbh = mcx; - } - else if(mc_CO<7.60) - { - mbh = mcx + (mc_CO - 5.0)*(m - mcx)/2.60; - } - else - { - mbh = m; - } - //printf("Mc_CO=%g, Mcx=%g, Mbh=%g\n", mc_CO, mcx, mbh); + const double Mc_x = + Mc_CO < 2.5 ? (0.1617670 * Mc_CO + 1.0670550): + (0.3141540 * Mc_CO + 0.6860880); + + M_remnant = + Mc_CO <= 5.0 ? Mc_x : + Mc_CO < 7.60 ? (Mc_x + (Mc_CO - 5.0) * (M - Mc_x) / 2.60) : + M; } else if(stardata->preferences->BH_prescription==BH_SPERA2015) { @@ -72,21 +58,21 @@ double Pure_function ns_bh_mass(const double m, if(stardata->common.metallicity<=5e-4) { /* Z < 5e-4 */ - p = -2.333 + 0.1559 * mc_CO + 0.2700 * mc_CO * mc_CO; // Eq. C2 - if(mc_CO <= 5.0) + p = -2.333 + 0.1559 * Mc_CO + 0.2700 * Mc_CO * Mc_CO; // Eq. C2 + if(Mc_CO <= 5.0) { - mbh = Max(p,1.27); // Eq. C1 MCO < 5 + M_remnant = Max(p,1.27); // Eq. C1 MCO < 5 } - else if(mc_CO < 10.0) + else if(Mc_CO < 10.0) { - mbh = p; // Eq. C1 5 < MCO < 10 + M_remnant = p; // Eq. C1 5 < MCO < 10 } else { - double mZ = -6.476e2 * stardata->common.metallicity + 1.911; // Eq. C3 - double qZ = 2.300e3 * stardata->common.metallicity + 11.67; // Eq. C3 - double f = mZ * mc_CO + qZ; // Eq. C2 - mbh = Min(p,f); // Eq. C1 MCO > 10 + const double mZ = -6.476e2 * stardata->common.metallicity + 1.911; // Eq. C3 + const double qZ = 2.300e3 * stardata->common.metallicity + 11.67; // Eq. C3 + const double f = mZ * Mc_CO + qZ; // Eq. C2 + M_remnant = Min(p,f); // Eq. C1 MCO > 10 } } else @@ -115,15 +101,14 @@ double Pure_function ns_bh_mass(const double m, } /* Eq. C5 */ - const double h = A1 + (A2 - A1) / (1.0 + exp10( (L - mc_CO) * eta)); - - if(mc_CO <= 5.0) + const double h = A1 + (A2 - A1) / (1.0 + exp10( (L - Mc_CO) * eta)); + if(Mc_CO <= 5.0) { - mbh = Max(h,1.27); // Eq. C4 MCO < 5 + M_remnant = Max(h,1.27); // Eq. C4 MCO < 5 } - else if(mc_CO < 10.0) + else if(Mc_CO < 10.0) { - mbh = h; // Eq. C4 5 < MCO < 10 + M_remnant = h; // Eq. C4 5 < MCO < 10 } else { @@ -148,92 +133,79 @@ double Pure_function ns_bh_mass(const double m, qZ = 2.300e3 * stardata->common.metallicity + 11.67; } - const double f = mZ * mc_CO + qZ; // Eq. C5 - mbh = Max(h,f); // Eq. C4 MCO > 10 + const double f = mZ * Mc_CO + qZ; // Eq. C5 + M_remnant = Max(h,f); // Eq. C4 MCO > 10 } } /* BH mass cannot exceed the total stellar mass */ - mbh = Min(m, mbh); + M_remnant = Min(M, M_remnant); } - else if(stardata->preferences->BH_prescription==BH_FRYER12_RAPID) + else if(stardata->preferences->BH_prescription==BH_FRYER12_STARTRACK) { - /* - Function to put together the various functions above based on users choice of SN engine. - - Parameters - ----------- - MpreSN : double - Pre-supernova total mass of the star in Msol - COCoreMass : double - CO Core mass at time of the SN in Msol - fallbackFraction : double - Fraction of mass [0,1] falling back onto proto compact object - engine : int - Which supernova engine to use - - Returns - -------- - Mrem : double - Remnant mass in Msol - - -- Simon Stevenson - */ - - - double Mproto = 0.0; - double fb = 0.0; - double Mfb = 0.0; - double Mrem_grav MAYBE_UNUSED = 0.0; - - // Calculate Mproto - Mproto = COCoreToProtoMassRapid(mc_CO); - - // Calculate fb, Mfb - fb = fallbackRapid(m, Mproto, mc_CO); - - Mfb = massFallbackGeneral(m, Mproto, fb); - - // Calculate Mremnant, baryonic - mbh = baryonicRemnantMassGeneral(Mproto, Mfb); - - //MATHIEU_WARNING:DEBUG - //printf("fb=%e Mfb=%e\n",fb,Mfb); + * Fryer et al. (ApJ 749,91 2012) startrack prescription + */ + const double M_proto = Fryer2012_Eq10(Mc_CO); + const double M_fallback = Fryer2012_Eq11(M,Mc_CO,M_proto); + const double M_BH_baryonic = Fryer2012_Eq12(M_proto,M_fallback); + M_remnant = Fryer2012_remnant_gravitational_mass(stardata,M_BH_baryonic); + Dprint("Fryer startrack Mc_CO %g M %g -> M_proto %g, M_fallback %g, M_BH_baryonic %g -> M_remn-ant(grav) = %g\n", + Mc_CO, + M, + M_proto, + M_fallback, + M_BH_baryonic, + M_remnant); + } + else if(stardata->preferences->BH_prescription==BH_FRYER12_RAPID) + { /* - Mrem_grav = gravitationalRemnantMassGeneral(mbh); - mbh = Mrem_grav - */ + * Fryer et al. (ApJ 749,91 2012) rapid prescription + */ + const double M_proto = Fryer2012_Eq15(Mc_CO); + const double M_fallback = Fryer2012_Eq16(M,Mc_CO,M_proto); + const double M_BH_baryonic = Fryer2012_Eq17(M_proto,M_fallback); + M_remnant = Fryer2012_remnant_gravitational_mass(stardata,M_BH_baryonic); + Dprint("Fryer rapid Mc_CO %g M %g -> M_proto %g, M_fallback %g, M_BH_baryonic %g -> M_remn-ant(grav) = %g\n", + Mc_CO, + M, + M_proto, + M_fallback, + M_BH_baryonic, + M_remnant); } else if(stardata->preferences->BH_prescription==BH_FRYER12_DELAYED) { - double Mproto = 0.0; - double fb = 0.0; - double Mfb = 0.0; - double Mrem_bary MAYBE_UNUSED = 0.0; - - // Calculate Mproto - Mproto = COCoreToProtoMassDelayed(mc_CO); - - // Calculate fb, Mfb - fb = fallbackDelayed(m, Mproto, mc_CO); - - Mfb = massFallbackGeneral(m, Mproto, fb); - - // Calculate Mremnant, baryonic, Mremnant, gravitational - mbh = baryonicRemnantMassGeneral(Mproto, Mfb); - - /* Mrem_grav = gravitationalRemnantMassGeneral(mbh); */ - //MATHIEU_WARNING:DEBUG - //printf("fb=%e Mfb=%e\n",fb,Mfb); + /* + * Fryer et al. (ApJ 749,91 2012) delayed prescription + */ + const double M_proto = Fryer2012_Eq18(Mc_CO); + const double M_fallback = Fryer2012_Eq19(M,Mc_CO,M_proto); + const double M_BH_baryonic = Fryer2012_Eq20(M_proto,M_fallback); + M_remnant = Fryer2012_remnant_gravitational_mass(stardata,M_BH_baryonic); + Dprint("Fryer delayed Mc_CO %g M %g -> M_proto %g, M_fallback %g, M_BH_baryonic %g -> M_remn-ant(grav) = %g\n", + Mc_CO, + M, + M_proto, + M_fallback, + M_BH_baryonic, + M_remnant); } else { // no prescription! - mbh=0; + M_remnant=0; } - Dprint("BH_MASS M = %g MCO = %g Z = %g -> MBH = %g\n",m,mc_CO,stardata->common.metallicity,mbh); + /* + * Make sure non-physical solutions cannot happen + */ + Clamp(M_remnant, + 0.0, + M); + + Dprint("NS/BH mass from M = %g, MCO = %g, Z = %g -> M_remn-ant = %g\n",M,Mc_CO,stardata->common.metallicity,M_remnant); - return(mbh); + return M_remnant; } diff --git a/src/supernovae/set_kick_velocity.c b/src/supernovae/set_kick_velocity.c index d0c19106d5ab1e5e05bf8736d40917c8b478117a..23b8724f86713faa3b760b4f019043b1cfbb8424 100644 --- a/src/supernovae/set_kick_velocity.c +++ b/src/supernovae/set_kick_velocity.c @@ -64,15 +64,12 @@ void set_kick_velocity(struct stardata_t * const stardata, * fallback (Mathieu Renzo 2016) */ if(stardata->preferences->BH_prescription==BH_FRYER12_DELAYED || - stardata->preferences->BH_prescription==BH_FRYER12_RAPID) + stardata->preferences->BH_prescription==BH_FRYER12_RAPID || + stardata->preferences->BH_prescription==BH_FRYER12_STARTRACK) { - double Mproto = stardata->preferences->BH_prescription==BH_FRYER12_DELAYED ? - COCoreToProtoMassDelayed(pre_explosion_star->core_mass[CORE_CO]) : - 1.0; // was COCoreToProtoMassRapid(pre_explosion_star->core_mass[CORE_CO]); - double fb = - stardata->preferences->BH_prescription==BH_FRYER12_DELAYED ? - fallbackDelayed(pre_explosion_star->mass, Mproto, pre_explosion_star->core_mass[CORE_CO]) : - fallbackRapid(pre_explosion_star->mass, Mproto, pre_explosion_star->core_mass[CORE_CO]); + const double fb = Fryer2012_f_fb(stardata, + pre_explosion_star->mass, + pre_explosion_star->core_mass[CORE_CO]); vk *= 1.0 - fb; /* diff --git a/src/timestep/nonstellar_timestep.c b/src/timestep/nonstellar_timestep.c new file mode 100644 index 0000000000000000000000000000000000000000..b21d544bb722b4c2e0f44558054521149e55edb4 --- /dev/null +++ b/src/timestep/nonstellar_timestep.c @@ -0,0 +1,34 @@ +#include "../binary_c.h" +No_empty_translation_unit_warning; + +#include "timestep.h" + +void nonstellar_timestep(struct stardata_t * const stardata, + double * const dtm) +{ + /* + * Timesteps that don't depend on the properties + * of the stars. + */ + + + /* + * Fixed timesteps: associate these with star 0 + * which will always exist + */ + timestep_fixed_timesteps(stardata, + &stardata->star[0], + dtm); + + + /* + * Hard wired minimum : do not apply + * if the timestep is limited by a fixed timestep + */ + if(stardata->model.fixed_timestep_triggered == FALSE && + stardata->star[0].dtlimiter != DT_LIMIT_FIXED_TIMESTEP) + { + *dtm = Max(*dtm, + MINIMUM_STELLAR_TIMESTEP); + } +} diff --git a/src/timestep/stellar_timestep.c b/src/timestep/stellar_timestep.c index 2081677c1f2645d9707efdba1b9c6729f0eb1008..01b0ea9dc6bdbcaaaa6750fe78cdc240e7a59770 100644 --- a/src/timestep/stellar_timestep.c +++ b/src/timestep/stellar_timestep.c @@ -131,15 +131,14 @@ void stellar_timestep(Timestep_prototype_args) } } + nonstellar_timestep(stardata,dt); timestep_limits(Timestep_call_args); timestep_logging(Timestep_call_args); - timestep_fixed_timesteps(Timestep_call_args); timestep_modulation(Timestep_call_args); timestep_hard_limits(Timestep_call_args); star->stellar_timestep = *dt; - if(stardata->preferences->timestep_logging == TRUE) { fprintf(stdout, diff --git a/src/timestep/timestep.h b/src/timestep/timestep.h index 01f0db99763b002a517e7e20d57a3aea22e70b92..7e52d2a3ff83c296f4439a21c247ee4e103d031c 100644 --- a/src/timestep/timestep.h +++ b/src/timestep/timestep.h @@ -117,36 +117,70 @@ enum { FIXED_TIMESTEPS_LIST }; * a new logging variable. */ -#define Set_timestep(DT,TO,IN,WHY) \ - { \ - (DT)=(TO); \ - Dprint("Set timestep to %g why %d\n", \ - (TO), \ - (WHY)); \ - if(WHY!=DT_LIMIT_MAXIMUM_TIMESTEP && \ - WHY!=DT_LIMIT_MINIMUM_TIMESTEP) \ - { \ - (IN)->dtlimiter=(WHY); \ - } \ +#define Set_timestep(DT,TO,IN,WHY) \ + { \ + (DT)=Max(stardata->preferences->minimum_timestep, \ + (TO)); \ + Dprint("Set timestep to %g why %d\n", \ + (TO), \ + (WHY)); \ + if(WHY!=DT_LIMIT_MAXIMUM_TIMESTEP && \ + WHY!=DT_LIMIT_MINIMUM_TIMESTEP) \ + { \ + (IN)->dtlimiter=(WHY); \ + } \ } -#define Limit_timestep(DT,TO,IN,WHY) \ - __extension__ \ - ({ \ - Boolean _limited; \ - if((DT)>(TO)) \ - { \ - Dprint("Limit timestep to %g why %d\n", \ - (TO), \ - (WHY)); \ - Set_timestep((DT),(TO),(IN),(WHY)); \ - _limited = TRUE; \ - } \ - else \ - { \ - _limited = FALSE; \ - } \ - _limited; \ +#define Set_timestep_no_minimum(DT,TO,IN,WHY) \ + { \ + (DT)=(TO); \ + Dprint("Set timestep to %g why %d\n", \ + (TO), \ + (WHY)); \ + if(WHY!=DT_LIMIT_MAXIMUM_TIMESTEP && \ + WHY!=DT_LIMIT_MINIMUM_TIMESTEP) \ + { \ + (IN)->dtlimiter=(WHY); \ + } \ + } + +#define Limit_timestep(DT,TO,IN,WHY) \ + __extension__ \ + ({ \ + Boolean _limited; \ + if((DT)>Max(stardata->preferences->minimum_timestep, \ + (TO))) \ + { \ + Dprint("Limit timestep to %g why %d\n", \ + (TO), \ + (WHY)); \ + Set_timestep((DT),(TO),(IN),(WHY)); \ + _limited = TRUE; \ + } \ + else \ + { \ + _limited = FALSE; \ + } \ + _limited; \ + }) + +#define Limit_timestep_no_minimum(DT,TO,IN,WHY) \ + __extension__ \ + ({ \ + Boolean _limited; \ + if((DT)>(TO)) \ + { \ + Dprint("Limit timestep to %g why %d\n", \ + (TO), \ + (WHY)); \ + Set_timestep_no_minimum((DT),(TO),(IN),(WHY)); \ + _limited = TRUE; \ + } \ + else \ + { \ + _limited = FALSE; \ + } \ + _limited; \ }) #define Floor_timestep(DT,TO,IN,WHY) \ diff --git a/src/timestep/timestep_fixed_timesteps.c b/src/timestep/timestep_fixed_timesteps.c index d78a862be22e7b63e089a7cdbb037954f648a47d..90cfb12912759a7a324cd48c9b3d97364faf9420 100644 --- a/src/timestep/timestep_fixed_timesteps.c +++ b/src/timestep/timestep_fixed_timesteps.c @@ -2,7 +2,9 @@ No_empty_translation_unit_warning; -void timestep_fixed_timesteps(Timestep_prototype_args) +void timestep_fixed_timesteps(struct stardata_t * const stardata, + struct star_t * const star, + double * const dtm) { /* * Limit the timestep according to the various @@ -11,7 +13,7 @@ void timestep_fixed_timesteps(Timestep_prototype_args) int i; for(i=0;i<FIXED_TIMESTEP_NUMBER;i++) { - struct binary_c_fixed_timestep_t * t = stardata->model.fixed_timesteps + i; + struct binary_c_fixed_timestep_t * const t = stardata->model.fixed_timesteps + i; if(t->enabled == TRUE) { @@ -36,14 +38,22 @@ void timestep_fixed_timesteps(Timestep_prototype_args) dtlim = (t->logarithmic ? exp10(t->next) : t->next) - stardata->model.time; } - Dprint("Set dtlim = %30.20g : next time will be %30.20g : Times_are_equal? %s\n", + Dprint("At t = %g : Set dtlim = %30.20g : next time will be %30.20g : Times_are_equal? %s\n", + T, dtlim, - log10(stardata->model.time + dtlim), + t->logarithmic ? log10(stardata->model.time + dtlim) : (stardata->model.time + dtlim), Yesno(Times_are_equal(t->next, log10(stardata->model.time + dtlim))) ); - Limit_timestep(*dt,dtlim,star,DT_LIMIT_FIXED_TIMESTEP); + /* + * Limit the timestep, but do not impose + * the stardata->preferences->minimum_timestep + */ + Limit_timestep_no_minimum(*dtm, + dtlim, + star, + DT_LIMIT_FIXED_TIMESTEP); } } } diff --git a/src/timestep/timestep_fixed_trigger.c b/src/timestep/timestep_fixed_trigger.c index 5b55e9af17e08d95a82f8528f4f2dd8a588e7a62..e4bb103b1a2a840429ddea8e9054cccfa17392c5 100644 --- a/src/timestep/timestep_fixed_trigger.c +++ b/src/timestep/timestep_fixed_trigger.c @@ -7,15 +7,15 @@ Boolean timestep_fixed_trigger(struct stardata_t * RESTRICT const stardata, const int i) { /* - * Check if fixed timestep i should be triggered. + * Check if fixed timestep i should be triggered. * Return TRUE if it should be, FALSE otherwise. * * If the timestep is disabled, return FALSE. - * + * * If we're beyond the end time, or before the start time, * this can never be true. * - * If we're at max_evolution_time and t->final is TRUE, then return TRUE. + * If we're at max_evolution_time and t->final is TRUE, then return TRUE. */ Boolean ret; struct binary_c_fixed_timestep_t * t = stardata->model.fixed_timesteps + i; @@ -30,10 +30,10 @@ Boolean timestep_fixed_trigger(struct stardata_t * RESTRICT const stardata, else { const double T = t->logarithmic ? log10(stardata->model.time) : stardata->model.time; - + if(!In_range(T,t->begin,t->end)) { - /* + /* * Out of time range of the trigger so cannot trigger */ ret = FALSE; @@ -50,7 +50,7 @@ Boolean timestep_fixed_trigger(struct stardata_t * RESTRICT const stardata, else { /* - * Check if the time equals, or is more than, the next + * Check if the time equals, or is more than, the next * trigger time */ ret = Boolean_(Times_more_or_equal(T,t->next)); diff --git a/src/timestep/timestep_hard_limits.c b/src/timestep/timestep_hard_limits.c index e1d249e992bcc65381d830f6adb646f2677e0390..234a398e129ad2c92e8aff3db618c7803cbc9142 100644 --- a/src/timestep/timestep_hard_limits.c +++ b/src/timestep/timestep_hard_limits.c @@ -39,7 +39,7 @@ void timestep_hard_limits(Timestep_prototype_args) /* * If there has been an event, perhaps limit the next timestep? */ - if(0 && stardata->common.n_events > 0) + if(0&&stardata->common.n_events > 0) { Limit_timestep(*dt, stardata->preferences->minimum_timestep, @@ -47,12 +47,11 @@ void timestep_hard_limits(Timestep_prototype_args) DT_LIMIT_MAXIMUM_TIMESTEP); } - Star_number k; - Nuclear_burning_Starloop(k) + if(NUCLEAR_BURNING(star->stellar_type)) { Limit_timestep(*dt, stardata->preferences->maximum_nuclear_burning_timestep, - &stardata->star[k], + star, DT_LIMIT_MAXIMUM_TIMESTEP); } @@ -74,8 +73,7 @@ void timestep_hard_limits(Timestep_prototype_args) /* * If there has been an event, force a small timestep */ - if(0 && - (star->SN_type != SN_NONE || + if((star->SN_type != SN_NONE || stardata->previous_stardata->star[star->starnum].SN_type != SN_NONE)) { Limit_timestep(*dt, @@ -109,16 +107,4 @@ void timestep_hard_limits(Timestep_prototype_args) star, DT_LIMIT_TIME_REMAINING); } - - /* - * Hard wired minimum : do not apply - * if the timestep is limited by a fixed timestep - */ - if(stardata->model.fixed_timestep_triggered == FALSE && - star->dtlimiter != DT_LIMIT_FIXED_TIMESTEP) - { - *dt = Max(*dt, - MINIMUM_STELLAR_TIMESTEP); - } - } diff --git a/src/timestep/timestep_limits.c b/src/timestep/timestep_limits.c index 3fa81b4e54ff627d8f8d891238271897487fb717..dee8310405e8525a9277f1f54c9357b8ed664fbf 100644 --- a/src/timestep/timestep_limits.c +++ b/src/timestep/timestep_limits.c @@ -648,8 +648,7 @@ void timestep_limits(Timestep_prototype_args) * if dt_zoomfac < 1, don't let the timestep be > * 1.2 * dt_zoomfac * (this or previous timestep) */ - if(0 && - Use_timestep(DT_LIMIT_ZOOMFAC) && + if(Use_timestep(DT_LIMIT_ZOOMFAC) && stardata->previous_stardata && stardata->model.dt_zoomfac - 1.0 < -TINY) { diff --git a/src/timestep/timestep_prototypes.h b/src/timestep/timestep_prototypes.h index 01db4b7c5f18c76b96b9b9c5a9048693f7fbc31b..e51867ce0387bf7a9cd095344c3ece7653f98737 100644 --- a/src/timestep/timestep_prototypes.h +++ b/src/timestep/timestep_prototypes.h @@ -23,7 +23,8 @@ void timestep_logging(Timestep_prototype_args); void timestep_modulation(Timestep_prototype_args); void timestep_hard_limits(Timestep_prototype_args); void timestep_RLOF(Timestep_prototype_args); - +void nonstellar_timestep(struct stardata_t * const stardata, + double * const dt); #ifdef DISCS double Pure_function timestep_disc(struct stardata_t * const stardata, @@ -31,7 +32,9 @@ double Pure_function timestep_disc(struct stardata_t * const stardata, #endif // DISCS void setup_fixed_timesteps(struct stardata_t * RESTRICT const stardata); -void timestep_fixed_timesteps(Timestep_prototype_args); +void timestep_fixed_timesteps(struct stardata_t * const stardata, + struct star_t * const star, + double * const dt); void timestep_increment_fixed_timesteps(struct stardata_t * RESTRICT const stardata); Boolean timestep_fixed_trigger(struct stardata_t * RESTRICT stardata, const int i); diff --git a/src/zfuncs/fallbackDelayed.c b/src/zfuncs/fallbackDelayed.c deleted file mode 100644 index c988f790745511576f573f5dab1ce499ea989df7..0000000000000000000000000000000000000000 --- a/src/zfuncs/fallbackDelayed.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "../binary_c.h" -No_empty_translation_unit_warning; - - - -double Constant_function fallbackDelayed(const double MpreSN, - const double Mproto, - const double COCoreMass) -{ - /* - Calculate fallback using the delayed prescription - - Equation 19 of Fryer et al 2012 - - Parameters - ----------- - MpreSN : double - Pre supernova stellar mass in Msol - Mproto : double - Fe/Ni proto compact object mass in Msol - COCoreMass : double - Pre supernova CO core mass in Msol - - Returns - -------- - fb : double, must be in the range 0 to 1 - Fallback - - -- Simon Stevenson - */ - double fb; - if(COCoreMass < 2.5) - { - fb = 0.2/(MpreSN - Mproto); - } - else if(COCoreMass < 3.5) - { - fb = (0.5 * COCoreMass - 1.05)/(MpreSN - Mproto); - } - else if(COCoreMass < 11.0) - { - double a2 = 0.133 - (0.093)/(MpreSN - Mproto); - double b2 = -11.0 * a2 + 1.0; - fb = a2 * COCoreMass + b2; - } - else - { - fb = 1.0; - } - - Clamp(fb,0.0,1.0); - - return fb; -} - diff --git a/src/zfuncs/fallbackRapid.c b/src/zfuncs/fallbackRapid.c deleted file mode 100644 index 4a9b7aa3644621b33abf08c8e0212e130809dcde..0000000000000000000000000000000000000000 --- a/src/zfuncs/fallbackRapid.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "../binary_c.h" -No_empty_translation_unit_warning; - - -double Constant_function fallbackRapid(const double MpreSN, - const double Mproto, - const double COCoreMass) -{ - /* - Calculate fallback using the rapid prescription - - Equations 15 & 16 from Fryer et al 2012 - - Parameters - ----------- - MpreSN : double - Pre supernova stellar mass in Msol - Mproto : double - Fe/Ni proto compact object mass in Msol - COCoreMass : double - Pre supernova CO core mass in Msol - - Returns - --------- - fb : double - Fraction of mass falling back onto proto object - - -- Simon Stevenson - */ - - double fb; - if(COCoreMass < 2.5) - { - fb = 0.2/(MpreSN - Mproto); - } - else if(COCoreMass < 6.0) - { - fb = (0.286 * COCoreMass - 0.514)/(MpreSN - Mproto); - } - else if(COCoreMass < 7.0) - { - fb = 1.0; - } - else if(COCoreMass < 11.0) - { - double a1 = 0.25 - (1.275/(MpreSN - Mproto)); - double b1 = -11.0 * a1 + 1.0; - fb = a1 * COCoreMass + b1; - } - else - { - fb = 1.0; - } - - Clamp(fb,0.0,1.0); - return fb; -} diff --git a/src/zfuncs/massFallbackGeneral.c b/src/zfuncs/massFallbackGeneral.c deleted file mode 100644 index d043ff94ee38bfef929224b0071fe504ca7e68bd..0000000000000000000000000000000000000000 --- a/src/zfuncs/massFallbackGeneral.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "../binary_c.h" -No_empty_translation_unit_warning; - - -double Constant_function massFallbackGeneral(const double MpreSN, - const double Mproto, - const double fb) -{ - /* - Equation 11 in Fryer et al 2012 - - Parameters - ----------- - MpreSN : double - Pre supernova stellar mass in Msol - COCoreMass : double - Pre supernova Carbon Oxygen (CO) core mass in Msol - fb : double - Fallback [0,1] - - Returns - -------- - Mfb : double - Mass falling back onto proto object - - -- Simon Stevenson - */ - return fb * (MpreSN - Mproto); -} diff --git a/tbse b/tbse index 2b4b0da9d022f24fb912aad99893d6f3f38fb063..09b6d2017b512b9d32f6f577c2ff96b6e92043de 100755 --- a/tbse +++ b/tbse @@ -1194,6 +1194,7 @@ MASS_ACCRETION_FOR_ELD=-1 # BH_SPERA2015 = 2: Spera+ 2015 # BH_FRYER12_DELAYED = 3: Fryer 2012 (delayed) # BH_FRYER12_RAPID = 4: Fryer 2012 (rapid) +# BH_FRYER12_STARTRACK = 5: Fryer 2012 (startrack) BH_PRESCRIPTION=BH_FRYER12_DELAYED # Type Ia supernovae @@ -2635,7 +2636,7 @@ $ORBITING_OBJECTS \ VALGRIND_MAX_STACKFRAME=30000000 VALGRIND_MAIN_STACKSIZE=30000000 VALGRIND="valgrind --main-stacksize=$VALGRIND_MAIN_STACKSIZE --max-stackframe=$VALGRIND_MAX_STACKFRAME" -VALGRIND_OPTS="--read-var-info=yes --track-origins=yes --tool=memcheck --leak-check=full --show-reachable=yes --freelist-vol=100000000 --partial-loads-ok=no --undef-value-errors=yes -v --vgdb-error=1 " +VALGRIND_OPTS="--read-var-info=yes --track-origins=yes --tool=memcheck --leak-check=full --show-reachable=yes --freelist-vol=100000000 --partial-loads-ok=no --undef-value-errors=yes -v " if [[ ! -z "$VALGRIND_LOG" ]]; then VALGRIND_OPTS="$VALGRIND_OPTS --log-file=$VALGRIND_LOG" fi @@ -2670,6 +2671,13 @@ then echo "$VALGRIND $VALGRIND_OPTS" exit fi + + if [ "$RUNMODE" == "valgrind" ]; then + if [ -z `$BIN_C --version |grep 'VALGRIND is on'` ]; then + echo -e "You are trying to run binary_c through valgrind without building with valgrind support. On some architectures this will fail, so please configure binary_c with something like\n\nmeson -Dvalgrind=true builddir\n\nand rebuild.\n" + exit + fi + fi elif [ "$RUNMODE" == "massif" ]; then # run through valgrind's massif diff --git a/ubuntu_install.sh b/ubuntu_install.sh deleted file mode 100644 index d6c6cf8bca6d22f17d607010fa24ab194c96b8c5..0000000000000000000000000000000000000000 --- a/ubuntu_install.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash - -############################################################ -# -# script to install binary_c -# -# tested on Ubuntu 20.10 -# -# Note: this will ask you to choose python3.9 -# as your default python. You do NOT have to -# do this, but some software is only tested -# on python3.9. -# -# We default to using gcc-10 for the compilation. -# -############################################################ - - - -# update and install a KDE desktop :) -#sudo apt-get install synaptic kubuntu-desktop -#balooctl disable - -# update system -sudo apt-get update -sudo apt-get upgrade - -# install required packages -sudo apt-get install bash zip gcc-10 libgcc-10-dev gdb valgrind gawk python3.9 pipenv kcachegrind meson ninja-build emacs perl libgsl-dev global libbsd-dev binutils-dev libiberty-dev libjemalloc-dev zlib1g-dev unzip wget curl -sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 -sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2 -sudo update-alternatives --config python # >>> choose python3.9 <<< -pip install --upgrade meson -pip install --upgrade ninja - -# set up environment -export CC=gcc-10 -export BINARY_C=$HOME/progs/stars/binary_c - -if [ ! grep -q 'binary_c paths do not alter' ~/.bashrc ] -then - # set up bash paths : do this only once! - echo '# binary_c paths do not alter' >> ~/.bashrc - echo 'export LD_LIBRARY_PATH=$HOME/lib:$BINARY_C:$BINARY_C/src' >> ~/.bashrc # do this only once! - echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc # do this only once! -fi -export LD_LIBRARY_PATH=$HOME/lib:$BINARY_C:$BINARY_C/src -export PATH=$HOME/bin:$PATH - -# Install librinterpolate, libmemoize, librchash -cd $HOME -mkdir git -cd $HOME/git -wget https://gitlab.eps.surrey.ac.uk/ri0005/librinterpolate/-/archive/master/librinterpolate-master.zip -O librinterpolate-master.zip -unzip -o librinterpolate-master.zip -cd librinterpolate-master/ -meson --prefix=$HOME --buildtype=release builddir -ninja -C builddir install -cd .. - -wget https://gitlab.eps.surrey.ac.uk/ri0005/libmemoize/-/archive/master/libmemoize-master.zip -O libmemoize-master.zip -unzip -o libmemoize-master.zip -cd libmemoize-master/ -meson --prefix=$HOME --buildtype=release builddir -ninja -C builddir install -cd .. - -wget https://gitlab.eps.surrey.ac.uk/ri0005/librchash/-/archive/master/librchash-master.zip -O librchash-master.zip -unzip -o librchash-master.zip -cd librchash-master/ -meson --prefix=$HOME --buildtype=release builddir -ninja -C builddir install -cd .. - -# download and install binary_c -mkdir -p $BINARY_C -cd $BINARY_C/.. -wget http://personal.ph.surrey.ac.uk/~ri0005/binary_c-master.zip -O binary_c-master.zip -unzip -o binary_c-master.zip -rmdir binary_c -mv binary_c-master binary_c -cd binary_c -meson -Dbuildtype=release -Dvalgrind=true builddir -ninja -C builddir binary_c_install -./tbse - - -# install perlbrew and binary_grid -cd $HOME -\curl -L https://install.perlbrew.pl | bash - -if [ ! grep -q 'perlbrew paths do not alter' ~/.bashrc ] -then - echo "# perlbrew paths do not alter" >> ~/.bashrc - echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.bashrc # only do this once! -fi -source ~/perl5/perlbrew/etc/bashrc - - -export NTHREADS=`cat /proc/cpuinfo |grep cpu\ famil|wc -l` -export LATEST_PERL=`perlbrew available | grep "^[[:space:]]\+perl" | head -1` -perlbrew -v install $LATEST_PERL --thread --multi --64bitall --notest -Dusethreads -Duselargefiles -Dcccdlflags=-fPIC -Dpager=/usr/bin/sensible-pager -Doptimize="-O3 -mtune=generic" -Duseshrplib -j $NTHREADS -perlbrew switch $LATEST_PERL -perlbrew install-cpanm -cd $BINARY_C/src/perl/modules_targz -./install_all.pl - -# run a test population -cd $BINARY_C -LD_PRELOAD=./src/libbinary_c.so ./src/perl/scripts2/template.pl diff --git a/ubuntu_install_binary_c.sh b/ubuntu_install_binary_c.sh new file mode 100755 index 0000000000000000000000000000000000000000..c0f393ebf90bf56ce371c6d5b2f9cbcf54e83560 --- /dev/null +++ b/ubuntu_install_binary_c.sh @@ -0,0 +1,434 @@ +#!/bin/bash + +############################################################ +# +# script to install binary_c +# +# tested on Ubuntu 20.10/21.04, binary_c 2.2 +# +# Note: this will ask you to choose python3.9 +# as your default python. You do NOT have to +# do this, but some software is only tested +# on python3.9. +# +# Environment variables: +# +# CC : the C compiler, we default to gcc-10, but +# gcc should be fine. +# +# BINARY_C : the location of the binary_c root directory. +# +# GITROOT : the location in which we download the source code +# of libraries we require. +# +############################################################ +set -e # fail -> exit + +# Defaults for the environment variables that control +# installation locations, compiler etc. + +# set up compiler +: "${CC:="gcc-10"}" +# set up location of binary_c +: "${BINARY_C:="$HOME/binary_c"}" +# git download location +: "${GITROOT:="$HOME/git"}" + +export CC +export BINARY_C +export GITROOT + +GITLAB="gitlab.eps.surrey.ac.uk/ri0005" + +echo +echo "#########################################################" +echo "Binary_c installation script for Ubuntu/Kubuntu 20/21+" +echo "#########################################################" +echo +echo "Press CTRL-C to exit at any time" +echo +echo "C compiler is set in CC" +echo "CC = $CC" +echo +echo "BINARY_C is the directory where binary_c will be installed" +echo "BINARY_C = $BINARY_C" +echo +echo "GITROOT is where source code for support libraries is downloaded" +echo "GITROOT = $GITROOT" +echo +echo "#########################################################" +echo +echo "Does the above look correct? (y/n)" +select s in "Yes" "No"; do + case $s in + "Yes" ) break;; + "No" ) exit; break;; + esac +done + +# Install librinterpolate, libmemoize, librchash +mkdir -p $GITROOT +cd $GITROOT + +############################################################ +# commands +WGET="wget --no-check-certificate" + +############################################################ +versionsorter() { + [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ] +} + +function setup_bash +{ + # set up bash and .bashrc + BASHRC="$HOME/.bashrc" + if ! grep -q 'binary_c paths do not alter' $BASHRC + then + # set up bash paths : do this only once! + echo '# binary_c paths do not alter' >> $BASHRC + echo "export BINARY_C=\"$BINARY_C\"" >> $BASHRC + echo 'export LD_LIBRARY_PATH=$HOME/lib:$BINARY_C:$BINARY_C/src' >> $BASHRC # do this only once! + echo 'export PATH=.:$HOME/bin:$HOME/.local/bin:$PATH' >> $BASHRC # do this only once! + + # psb, psbb, git functions etc. and completion of binary_c arguments + printf '%s' ' + +# source perlbrewbinary_c +source $HOME/perl5/perlbrew/etc/bashrc + +# function to switch to progs/stars/binary_c +function psb +{ + cd $BINARY_C +} +function psbb +{ + cd $BINARY_C/builddir +} + +# git function for review number +git_rev () +{ + d=`date +%Y%m%d` + c=`git rev-list --full-history --all --abbrev-commit | /usr/bin/wc -l | /bin/sed -e "s/^ *//"` + h=`git rev-list --full-history --all --abbrev-commit | head -1` + echo ${c}:${d}:${h} +} + +alias new="ls -lrt |head -10" + +# git function to find the repository url +git_url () +{ + git config --get remote.origin.url +} + +# source autocompletion library +if [ -n "$BASH_VERSION" ]; then + [ -f /etc/bash_completion ] && . /etc/bash_completion +fi + +# completion of binary_c arguments +_binary_c() +{ + COMPREPLY=() + cmd="${COMP_WORDS[0]}" + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + binaryc_opts=$($BINARY_C_ROOT/binary_c help |/bin/grep -A2 "where the arguments are a selection of :"|tail -1|tr " " "\n") + # check if we match a binary_c argument + subcmd=( $(compgen -W "$binaryc_opts" "$prev") ) + if [[ $subcmd ]] ; then + # we do match an argument : try to get sub options + subopts=$($BINARY_C_ROOT/binary_c argopts $subcmd) + COMPREPLY=( $(compgen -W "$subopts" -- ${cur}) ) + else + # we do not, so list the arguments + COMPREPLY=( $(compgen -W "$binaryc_opts" -- ${cur}) ) + fi + return 0 +} +complete -F _binary_c binary_c +complete -F _binary_c tbse +complete -F _binary_c tbse.mint +complete -F _binary_c tbse.IRAS + +# for binarycpython +export GSL_DIR=`gsl-config --prefix` + +' >> $BASHRC + fi + + # some of the above we require now + export LD_LIBRARY_PATH="$HOME/lib:$BINARY_C:$BINARY_C/src" + export LIBRARY_PATH="$LD_LIBRARY_PATH" + export PATH=$HOME/bin:$HOME/.local/bin:$PATH + if [ -f $HOME/perl5/perlbrew/etc/bashrc ]; + then + source $HOME/perl5/perlbrew/etc/bashrc + fi +} + + +function install_from_surrey_git +{ + PACKAGE=$1 + + # download and install $PACKAGE + mkdir -p $GITROOT + cd $GITROOT + $WGET https://$GITLAB/$PACKAGE/-/archive/master/$PACKAGE-master.zip -O $PACKAGE-master.zip + unzip -o $PACKAGE-master.zip + cd $PACKAGE-master/ + if [ -d builddir ]; + then + rm -r builddir + fi + meson --prefix=$HOME --buildtype=release builddir + ninja -C builddir install +} + +function install_binary_c_from_zip +{ + # download and install binary_c + if [ -d $BINARY_C ]; + then + echo "Directory $BINARY_C already exists: please remove any old binary_c installation before installing a new one" + exit + fi + cd /tmp # work from /tmp + $WGET https://$GITLAB/binary_c/-/archive/master/binary_c-master.zip -O binary_c-master.zip + unzip -o binary_c-master.zip + rm binary_c-master.zip + mv binary_c-master $BINARY_C + cd $BINARY_C + meson -Dbuildtype=release -Dvalgrind=true builddir + ninja -C builddir binary_c_install + ./tbse + cd $HOME +} + +function install_binary_c_from_git_https +{ + # download and install binary_c + echo "Install to BINARY_C=$BINARY_C" + git clone --branch master --single-branch https://$GITLAB/binary_c.git $BINARY_C + rm -rf $BINARY_C/builddir 2>/dev/null + cd $BINARY_C + meson -Dbuildtype=release -Dvalgrind=true $BINARY_C/builddir + ninja -C $BINARY_C/builddir binary_c_install + $BINARY_C/binary_c-config version +} + + +function install_binary_c_from_git_ssh +{ + # download and install binary_c + cd $BINARY_C/.. + git clone gitlab@gitlab.eps.surrey.ac.uk:ri0005/binary_c.git + cd binary_c + meson -Dbuildtype=release -Dvalgrind=true builddir + ninja -C builddir binary_c_install + ./binary_c-config version +} + +function run_test_population +{ + # run a test population + cd $BINARY_C + LD_PRELOAD=./src/libbinary_c.so ./src/perl/scripts2/template.pl +} + +function install_binary_c_perl_modules +{ + # install the binary_c Perl modules + cd $BINARY_C/src/perl/modules_targz + ./install_all.pl +} + +function install_perl +{ + # install perlbrew and binary_grid + cd $HOME + \curl -L https://install.perlbrew.pl | bash + + if ! grep -q 'perlbrew paths do not alter' ~/.bashrc + then + echo "# perlbrew paths do not alter" >> ~/.bashrc + echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.bashrc # only do this once! + fi + source ~/perl5/perlbrew/etc/bashrc 2>&1 || true + export NTHREADS=`cat /proc/cpuinfo |grep cpu\ famil|wc -l` + export CURRENT_PERL=`perl -e '$v=$^V;$v=~s/v//;print "perl-$v\n";'` + export LATEST_PERL=`perlbrew available | grep "^[[:space:]i]\+perl" | sed s/^i// | sed s/^[[:space:]]*// | sed s/[[:space:]]*\\$// | head -1` + echo "CURRENT_PERL = \"$CURRENT_PERL\"" + echo "LATEST_PERL = \"$LATEST_PERL\"" + + if [ "$CURRENT_PERL" == "$LATEST_PERL" ]; + then + echo "You already have the latest Perl" + else + NEWER_PERL=`echo -e "$CURRENT_PERL\n$LATEST_PERL" | sort -Vr | head -1` + if [ "$NEWER_PERL" == "$LATEST_PERL" ]; + then + echo "Installing $LATEST_PERL" + perlbrew -v install $LATEST_PERL --thread --multi --64bitall --notest -Dusethreads -Duselargefiles -Dcccdlflags=-fPIC -Dpager=/usr/bin/sensible-pager -Doptimize="-O3 -mtune=generic" -Duseshrplib -j $NTHREADS + # clean the build + echo "Cleaning perlbrew/build" + rm -rf $HOME/perl5/perlbrew/build 2>/dev/null + else + echo "No newer Perl has been found : sticking with $CURRENT_PERL" + fi + echo "Source perlbrew" + source ~/perl5/perlbrew/etc/bashrc 2>&1 || true + echo "Switch to use $LATEST_PERL" + perlbrew switch $LATEST_PERL + fi + + source ~/perl5/perlbrew/etc/bashrc 2>&1 || true + echo "Install cpanm" + perlbrew -f install-cpanm +} + +function install_binary_c_python +{ + # install the binary_c Python module + export LIBRARY_PATH=$LD_LIBRARY_PATH + pip3 install -U pip setuptools + # pip3 install git+https://$GITLAB/binary_c-python.git + pip3 install git+https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python.git@development_version/2.1.7 +} + +function update_packages +{ + # update and install a KDE desktop :) + #sudo apt-get install synaptic kubuntu-desktop + #balooctl disable + + # update system + sudo apt-get update + sudo apt-get upgrade + + # install required packages + sudo apt-get install bash zip gcc-10 libgcc-10-dev gdb valgrind gawk python3.9 pipenv kcachegrind meson ninja-build emacs perl libgsl-dev global libbsd-dev binutils-dev libiberty-dev libjemalloc-dev zlib1g-dev unzip wget curl git + sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 + # sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2 2>/dev/null + echo "You should normally choose Python 3.9" + sudo update-alternatives --config python # >>> choose python3.9 <<< + sudo apt-get clean + pip install --upgrade meson + pip install --upgrade ninja +} + +function download_MINT_data +{ + # download MINT data + mkdir -p $HOME/data/MINT + cd $HOME/data/MINT + rm -f sync + $WGET http://personal.ph.surrey.ac.uk/~ri0005/MINT/sync + chmod +x sync + ./sync +} + +############################################################ + +# set up bash (always do this) +setup_bash + +# install/check system packages +echo "Do you wish to check and, if necessary, install system packages? (requires sudo permissions)" +select yn in "Yes" "No"; do + case $yn in + Yes ) update_packages; break;; + No ) break;; + esac +done + +# now we can set GSL_DIR because GSL has been installed +# (or at least should have been) +export GSL_DIR=`gsl-config --prefix` + +# install perl from perlbrew +echo "Install perlbrew and custom Perl?" +select yn in "Yes" "No"; do + case $yn in + Yes ) install_perl; break;; + No ) break;; + esac +done + +# install librinterpolate +echo "Install librinterpolate?" +select yn in "Yes" "No"; do + case $yn in + Yes ) install_from_surrey_git librinterpolate; break;; + No ) break;; + esac +done + +# install libmemoize +echo "Install libmemoize?" +select yn in "Yes" "No"; do + case $yn in + Yes ) install_from_surrey_git libmemoize; break;; + No ) break;; + esac +done + +# install librchash +echo "Install librchash?" +select yn in "Yes" "No"; do + case $yn in + Yes ) install_from_surrey_git librchash; break;; + No ) break;; + esac +done + +# install binary_c +echo "Install binary_c from ... ?" +select s in "git (https)" "git (ssh, keys must be set up)" "git (zip, no version control)" "No"; +do case $s in + "git (https)" ) install_binary_c_from_git_https; break;; + "git (ssh, keys must be set up)" ) install_binary_c_from_git_ssh; break;; + "git (zip, no version control)" ) install_binary_c_from_zip; break;; + "No" ) break;; + esac +done + +# install binary_c's perl modules +echo "Install binary_c Perl modules?" +select yn in "Yes" "No"; do + case $yn in + Yes ) install_binary_c_perl_modules; break;; + No ) break;; + esac +done + +echo "Install binary_c-python?" +select yn in "Yes" "No"; do + case $yn in + Yes ) install_binary_c_python; break;; + No ) break;; + esac +done + + +# install MINT data? +echo "Download MINT data?" +select yn in "Yes" "No"; do + case $yn in + Yes ) download_MINT_data; break;; + No ) break;; + esac +done + +# run test population +echo "Run a test binary_grid stellar population to make sure everything works?" +select yn in "Yes" "No"; do + case $yn in + Yes ) run_test_population; break;; + No ) break;; + esac +done