# the following are some notes about the compilation of tracy on sumo-metis and
# the CCRT for SOLEIL
# orblancog
# 2023aug28

# First of all, let me apologize as this is not a script, but some notes you
# will need to read and understand in order to build tracy.
# Tracy depends on external non-standard libraries, and because of it and the
# lack of a git repository for the external libraries, we will need to get a
# copy from Laurent Nadolsky.


# There two main parts :
  - numerical recipes (ask Laurent)
  - tracy3 (on gitlab)

If you have numerical recipes and tracy inside the same folder, you could just
copy 'buildtracy.sh' to that folder and launch it. There is one for sumo-metis
and one for the CCRT.
The first time 'buildtracy.sh' is launch it might stop due to a problem with
make distclean inside make_for_tracy3.h. My advice is to comment that line
in the first compilation, which would reset the project, and decomment that line
for the next compilations.
The goal with 'buildtracy.sh' is to produce a folder called 'build' with the
binaries for a new module.

Most of the time the above is enough. However, here below there is more detail.

I have added a script 'set-vars-sumo-metis.sh' that creates few environment
variables that are common to both numerical recipes and tracy3
during compilation.
My advise is to source it.

--- NUMERICAL RECIPES
The code has at least two versions. We will use here the c-ansi.
On sumo metis:
   The compiler will be gcc because icc is incompatible with matlab.
   See jira ticket https://jira.synchrotron-soleil.fr/jira/browse/CTRLDESK-21799
   We should load tools/gcc/9.2.0, (it is a module visible from sumo or sumo-metis).
   In numerical_recipes/c-ansi/ there is a Makefile.
   I leave here a copy of that Makefile "Makefile_numerical_recipes_c-ansi".
   It seems to me that the Makefile in (numerical_recipes_c-ansi)/recipes was also
   modified sometime ago, I will leave a copy of it "Makefile_numerical_recipes_c-ansi_recipes".
On the CCRT :
   The compiler is gnu/11.1.0 because we want to keep compatibility with elegant
   I had to modify the Makefile in the CCRT to make it work with the gcc
   version 11. I leave here the copies "CCRT_Makefile_numerical_recipes_c-ansi", and
   "CCRT_Makefile_numerical_recipes_c-ansi_recipes".
   I also needed to modify anneal.c to to use new libraries instead of deprecated no
   available in gcc ([TGCC #135313] /usr/include/bits/huge_val.h);
   I leave here a copy "CCRT_anneal.c".

--- tracy3
On sumo metis:
   Check the branch compilation2022apr of this project
   https://gitlab.synchrotron-soleil.fr/PA/optics/tracy3/-/commits/compilation2022apr
   It contains the most up-to-date modifications of the code
On the CCRT:
   I leave a static copy of the code at
   /nfs/ruche/sources/physmach/blanco-garcia/backup_CCRT/work/public/progs/tracy3soleil/compileTracy