radiasoft / download

Install scripts for "curl | bash"
Apache License 2.0
3 stars 5 forks source link

fix geant4 on jupyter #684

Closed e-carlin closed 5 months ago

e-carlin commented 5 months ago

No visualization bits needed. Want to be able to run this test script https://gitlab.cern.ch/geant4/geant4/-/raw/master/examples/extended/electromagnetic/TestEm7/README.

Stephen is currently using the below script to build it ( v11.2.1):

#!/bin/bash

#Download Xerces for GDML support
export THISDIR=$PWD
#wget https://ftp.wayne.edu/apache//xerces/c/3/sources/xerces-c-3.2.3.tar.gz
#tar -zxvf xerces-c-3.2.3.tar.gz
#cd xerces-c-3.2.3
#mkdir build
#cd build
#../configure --prefix=$THISDIR/xerces-c-3.2.3/build/.
#make -j5
#make install
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$THISDIR/xerces-c-3.2.3/build/lib

#Get DAWN for visualization
#cd $THISDIR
#wget http://geant4.kek.jp/~tanaka/src/dawn_3_91a.tgz
#tar -zxvf dawn_3_91a.tgz

#cd $THISDIR
rm -rf build
mkdir build
cd build
#
cmake  -DGEANT4_BUILD_MULTITHREADED=ON  -DGEANT4_USE_QT=OFF -DGEANT4_USE_OPENGL_X11=OFF -DGEANT4_USE_HDF5=ON -DCMAKE_PREFIX_PATH=/home/vagrant/jupyter/hdf5/hdf5 ../
#make -j5
e-carlin commented 5 months ago

From stephen

There is no executable, just a bunch of .so libraries, a make install command at the end only places a geant4make.sh script in the bin directory. This sets a bunch of environment variables to point to the data files,. Those paths can be modified to point to a shared area, so we don’t have multiple copies of those files laying around Actually, that script I just sent links against a single-threaded hdf5 library I compiled in my home directory. You could leave the prefix path and USE_HDF5 off if you want

e-carlin commented 5 months ago

Setting USE_HDF5=OFF. If we want to set GEANT4_BUILD_MULTITHREADED=ON and GEANT4_USE_HDF5=ON then hdf5 must be compiled with thread safety turned on. We currently install hdf5 from the fedora repos and it doesn't have thread safety enabled so would be a bit of work to learn to build from source, enable thread safety, and verify this doesn't break other codes using hdf5 (many of them use it).

Success running the example Matt wants:

$ cd /home/vagrant/src/geant4/geant4/examples/extended/electromagnetic/TestEm7
TestEm7 ((HEAD detached at v11.2.1))$ mkdir build
TestEm7 ((HEAD detached at v11.2.1))$ cd build
build ((HEAD detached at v11.2.1))$ cmake ../
-- The C compiler identification is GNU 12.2.1
-- The CXX compiler identification is GNU 12.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found EXPAT: /usr/lib64/libexpat.so (found suitable version "2.5.0", minimum required is "2.5.0")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found Geant4: /home/vagrant/.local/lib/cmake/Geant4/Geant4Config.cmake (found version "11.2.1")
-- Configuring done (1.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/vagrant/src/geant4/geant4/examples/extended/electromagnetic/TestEm7/build
build ((HEAD detached at v11.2.1))$ make -j4 TestEm7
[ 17%] Building CXX object CMakeFiles/TestEm7.dir/TestEm7.cc.o
[ 17%] Building CXX object CMakeFiles/TestEm7.dir/src/DetectorConstruction.cc.o
[ 17%] Building CXX object CMakeFiles/TestEm7.dir/src/DetectorMessenger.cc.o
[ 23%] Building CXX object CMakeFiles/TestEm7.dir/src/G4LindhardPartition.cc.o
[ 29%] Building CXX object CMakeFiles/TestEm7.dir/src/G4ScreenedNuclearRecoil.cc.o
[ 35%] Building CXX object CMakeFiles/TestEm7.dir/src/PhysListEmStandard.cc.o
[ 41%] Building CXX object CMakeFiles/TestEm7.dir/src/PhysListEmStandardNR.cc.o
[ 47%] Building CXX object CMakeFiles/TestEm7.dir/src/PhysicsList.cc.o
[ 52%] Building CXX object CMakeFiles/TestEm7.dir/src/PhysicsListMessenger.cc.o
[ 58%] Building CXX object CMakeFiles/TestEm7.dir/src/PrimaryGeneratorAction.cc.o
[ 64%] Building CXX object CMakeFiles/TestEm7.dir/src/PrimaryGeneratorMessenger.cc.o
[ 70%] Building CXX object CMakeFiles/TestEm7.dir/src/RunAction.cc.o
[ 76%] Building CXX object CMakeFiles/TestEm7.dir/src/StepMax.cc.o
[ 82%] Building CXX object CMakeFiles/TestEm7.dir/src/StepMaxMessenger.cc.o
[ 88%] Building CXX object CMakeFiles/TestEm7.dir/src/SteppingAction.cc.o
[ 94%] Building CXX object CMakeFiles/TestEm7.dir/src/TrackingAction.cc.o
[100%] Linking CXX executable TestEm7
[100%] Built target TestEm7
build ((HEAD detached at v11.2.1))$ GEANT4_DATA_DIR=/home/vagrant/src/radiasoft/download/installers/rpm-code/tmp ./TestEm7 TestEm7.in

**************************************************************
 Geant4 version Name: geant4-11-02-patch-01 [MT]   (16-February-2024)
                       Copyright : Geant4 Collaboration
                      References : NIM A 506 (2003), 250-303
                                 : IEEE-TNS 53 (2006), 270-278
                                 : NIM A 835 (2016), 186-225
                             WWW : http://geant4.org/
**************************************************************
<snip>
================== Deleting memory pools ===================
Number of memory pools allocated: 12; of which, static: 0
Dynamic pools deleted: 12 / Total memory freed: 58 MB
============================================================
build ((HEAD detached at v11.2.1))$ echo $?
0