source: trunk/examples/extended/parallel/ParN02/ParGNUmakefile@ 807

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

update

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