source: trunk/examples/extended/parallel/ParN04/ParGNUmakefile@ 1230

Last change on this file since 1230 was 807, checked in by garnier, 17 years ago

update

File size: 3.8 KB
Line 
1# $Id: ParGNUmakefile,v 1.7 2007/05/25 17:25:51 cooperma Exp $
2# --------------------------------------------------------------
3#This file should be included in GNUmakefile of local directory.
4
5#Usage: make [ to compile parallel version ]
6# make run [ to compile and run it ]
7# make run-debug [ to compile and run in gdb ]
8# make parclean [ remove intermediate and executable files ]
9# See `run' target for parameters by which executable is called.
10# This assumes Geant4 environment vars have been defined.
11# See ../info/NEW_APP_INSTALL (number 10) for an example of setting up
12# the Geant4 environment variables.
13
14# MEM_MODEL can be --seq, --mpi, or --pthread in current version of TOP-C.
15MEM_MODEL=--seq
16MEM_MODEL=--mpi
17
18ifndef REMOTE_SHELL
19 REMOTE_SHELL=ssh
20endif
21
22MACROFILE=ParN04.in
23# MACROFILE=ParN04.EMtest.large_N.in
24
25DATAFILE=
26DATAFILE=pythia_event.data
27
28# Everything below here should be set automatically based on
29# your environment variables, the G4TARGET of GNUmakefile, etc.
30# G4TARGET set in the makefile that includes this one.
31
32ifndef PARTARGET
33 PARTARGET = ${G4TARGET}
34endif
35
36ifndef G4INSTALL
37 G4INSTALL = _Environment_variable_G4INSTALL_must_be_defined_
38endif
39
40ifndef G4WORKDIR
41 G4WORKDIR = ${G4INSTALL}
42endif
43
44ifndef G4BIN
45 G4BIN = $$G4WORKDIR/bin
46endif
47ifndef G4BINDIR
48 G4BINDIR = ${G4BIN}/$$G4SYSTEM
49endif
50
51EXECUTABLE=${G4BIN}/$$G4SYSTEM/${PARTARGET}
52
53G4DEBUG = 1
54
55TOPC_LIBS = $(shell topc-config ${MEM_MODEL} --libs)
56TOPC_CFLAGS = -DG4USE_TOPC $(shell topc-config ${MEM_MODEL} --cflags)
57# optionally add: -DTOPC_DEBUG to TOPC_CFLAGS for debugging details.
58TOPC_OPTIONS = --TOPC-verbose
59
60EXTRALIBS=${TOPC_LIBS}
61CPPFLAGS=${TOPC_CFLAGS}
62
63TIMESTAMP=${G4BINDIR}/ParN04.timestamp
64
65# Unfortunately, .../geant4.x.x/config/binmake.gmk has target:
66# $(G4BINDIR)/$(G4TARGET)
67# (for example: ${G4BIN}/$$G4SYSTEM/ParN04)
68# And that rule always triggers due to dependency on .../exe/obj.last
69# Also, G4BINDIR uses shell variables, that are guaranteed to expand
70# only after recursive make.
71compile:
72 @ if [ "$$G4SYSTEM" = "" ]; then \
73 echo '***' Environment variable G4SYSTEM not defined; \
74 echo '***' Make sure G4INSTALL and G4SYSTEM are set; \
75 exit 1; \
76 fi
77 ${MAKE} G4BINDIR=${G4BINDIR} ${TIMESTAMP}
78 @ if which topc-config > /dev/null; then :; \
79 else \
80 echo '***' topc-config is not in your path; \
81 exit 1; \
82 fi
83 @ echo ""
84 @ echo 'To run, now type "make run"'
85 @ echo 'To remove built files, type "make parclean"'
86
87${TIMESTAMP}: *.cc *.icc src/*.cc include/*.hh ParGNUmakefile
88 @ if which topc-config > /dev/null; then :; \
89 else \
90 echo ''; \
91 echo '***' topc-config is not in your path; \
92 exit 1; \
93 fi
94 ${MAKE} all
95 rm -f ${TIMESTAMP}
96 echo "" > ${TIMESTAMP}
97 make -t ${EXECUTABLE}
98
99run: compile
100 pwd
101 echo ${EXECUTABLE}
102 cp -f ${MACROFILE} ${DATAFILE} procgroup `dirname ${EXECUTABLE}`/
103 # ${EXECUTABLE} will use procgroup file in current directory.
104 ( cd `dirname ${EXECUTABLE}`; RSH=${REMOTE_SHELL}; export RSH; \
105 ${EXECUTABLE} ${TOPC_OPTIONS} ${MACROFILE} )
106
107run-debug: compile
108 @ if [ "$$G4DEBUG" = "" ]; then \
109 echo '***' Environment variable G4DEBUG not defined; \
110 echo '***' Set it, make parclean, and re-compile using GDEBUG; \
111 fi
112 # exit 1; \
113 echo ${EXECUTABLE}
114 cp -f ${MACROFILE} ${DATAFILE} procgroup `dirname ${EXECUTABLE}`/
115 rm -f `dirname ${EXECUTABLE}`/tmp.gdb
116 echo 'set args ${TOPC_OPTIONS} ${MACROFILE}' \
117 > `dirname ${EXECUTABLE}`/tmp.gdb
118 echo 'break main' >> `dirname ${EXECUTABLE}`/tmp.gdb
119 echo 'run' >> `dirname ${EXECUTABLE}`/tmp.gdb
120 # ${EXECUTABLE} will use procgroup file in current directory.
121 ( cd `dirname ${EXECUTABLE}`; RSH=${REMOTE_SHELL}; export RSH; \
122 gdb -x tmp.gdb ${EXECUTABLE} )
123parclean:
124 rm -f ${TIMESTAMP}
125 ${MAKE} clean
126pardist: parclean
127 ( dir=`basename $$PWD`; cd ..; tar cvf $$dir.tar ./$$dir; \
128 gzip $$dir.tar && (cd $$dir; ls -l ../$$dir.tar.gz) )
Note: See TracBrowser for help on using the repository browser.