Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
source
g3tog4
src
g3tog4.F
Go to the documentation of this file.
1
*
2
* ********************************************************************
3
* * License and Disclaimer *
4
* * *
5
* * The Geant4 software is copyright of the Copyright Holders of *
6
* * the Geant4 Collaboration. It is provided under the terms and *
7
* * conditions of the Geant4 Software License, included in the file *
8
* * LICENSE and available at http://cern.ch/geant4/license . These *
9
* * include a list of copyright holders. *
10
* * *
11
* * Neither the authors of this software system, nor their employing *
12
* * institutes,nor the agencies providing financial support for this *
13
* * work make any representation or warranty, express or implied, *
14
* * regarding this software system or assume any liability for its *
15
* * use. Please see the license in the file LICENSE and URL above *
16
* * for the full disclaimer and the limitation of liability. *
17
* * *
18
* * This code implementation is the result of the scientific and *
19
* * technical work of the GEANT4 collaboration. *
20
* * By using, copying, modifying or distributing the software (or *
21
* * any work based on the software) you agree to acknowledge its *
22
* * use in resulting scientific publications, and indicate your *
23
* * acceptance of all terms of the Geant4 Software license. *
24
* ********************************************************************
25
*
26
*
27
* $Id: g3tog4.F,v 1.5 2006-06-29 18:15:12 gunter Exp $
28
* GEANT4 tag $Name: not supported by cvs2svn $
29
*
30
*
31
* G3toG4
32
*
33
* Package to convert Geant3 Fortran geometry code to a call list
34
* file to be interpreted by the Geant4 geometry call list
35
* interpreter, or alternatively, directly to Geant4 code.
36
*
37
* This set of routines is to be linked in front of, so overriding,
38
* the standard Geant library.
39
*
40
* It is possible to execute the Geant calls while at the same
41
* time building the call list/Geant4 code. In order to do this,
42
* these routines must occupy a different name space to that of
43
* the real Geant routines. This is provided by the CALL_GEANT
44
* cpp flag. If these routines are compiled with this flag,
45
* the routine names begin with K rather than G. eg. GSVOLU
46
* becomes KSVOLU. Routine names in your source code must be so
47
* converted; a perl script is provided to do this.
48
* $$$ provide the script
49
* Under normal circumstances it should *not* be necessary to go
50
* through this; it is only necessary if during the geometry
51
* generation process your code extracts information from Geant
52
* about material already generated.
53
*
54
* Torre Wenaus, LLNL 6/95
55
*
56
* To Do
57
* - option to divide generated Geant4 code into separate files/routines
58
* based on context
59
*
60
************************************************************************
61
*
62
subroutine
g3tog4
(luni,lunc,chopt)
63
************************************************************************
64
*
65
* G3toG4
66
*
67
* Initialization/setup routine
68
*
69
* luni (call list), lunc (C++ code) logical unit numbers:
70
* lun>0: Open output file on unit lun. Filenames used:
71
* g3calls.dat Call list file
72
* g4geom.cc Geant4 C++ geometry code
73
* lun<0: File open has been done by the user. Just write to |lun|
74
* lun=0: Don't generate this output.
75
* ie. luni=0: Don't generate the call list
76
* lunc=0: Don't generate the Geant4 code
77
*
78
* chopt options:
79
* 'G' execute the actual Geant calls as well as building the
80
* code/call list. In case users use info obtained from Geant
81
* during the geometry building process. THIS IS THE DEFAULT
82
* at present:
83
#define CALL_GEANT
84
*
85
************************************************************************
86
implicit none
87
integer
luni, lunc
88
character
chopt*(*)
89
#include "G3toG4.inc"
90
*
91
print
*,
'Initializing Geant3 to Geant4 conversion'
92
#ifdef CALL_GEANT
93
c dogeom = index(chopt,'G') + index(chopt,'g') .ne. 0
94
dogeom = .true.
95
#else
96
dogeom = .false.
97
#endif
98
context
=
'----'
99
if
(luni.eq.0.and.lunc.eq.0)
then
100
print
*,
'G3TOG4: No output requested by user. No output'
//
101
+
' will be generated.'
102
endif
103
lunlist = abs(luni)
104
luncode = abs(lunc)
105
if
(lunlist.ne.0)
then
106
doclist = .true.
107
else
108
doclist = .false.
109
endif
110
if
(luncode.ne.0)
then
111
docode = .true.
112
else
113
docode = .false.
114
endif
115
*** If lun>0, open the file
116
if
(lunlist.gt.0)
then
117
open
(
unit
=lunlist,
file
=
'g3calls.dat'
,
status
=
'unknown'
)
118
endif
119
if
(luncode.gt.0)
then
120
nfile = 1
121
call
g3source
122
endif
123
*
124
end
125
*
126
subroutine
g4init
127
************************************************************************
128
************************************************************************
129
implicit none
130
#include "G3toG4.inc"
131
*
132
if
(luncode.ne.0)
then
133
write
(luncode,
134
+
'('
'//G4GeometryManager* GeoMgr = new G4GeometryManager();'
')'
)
135
* call ctocp('void G3G4init();')
136
endif
137
*
138
end
139
*
140
subroutine
g3header
141
************************************************************************
142
*
143
************************************************************************
144
implicit none
145
call
g4init
146
end
147
148
subroutine
g3source
149
************************************************************************
150
*
151
************************************************************************
152
implicit none
153
#include "G3toG4.inc"
154
character
fname*30
155
if
(luncode.le.0)
return
156
if
(nfile.gt.1)
write
(luncode,
'('
'}'
')'
)
157
close
(luncode)
158
write
(fname,
'('
'G3toG4code_'
',i2.2,'
'.cc'
')'
) nfile
159
open
(
unit
=luncode,
file
=fname,
status
=
'unknown'
)
160
write
(luncode,
'('
'#include "G3toG4.hh"'
')'
)
161
if
(nfile.eq.1) call
g3header
162
write
(luncode,
'(/'
'void G3toG4code_'
',i2.2,'
'()'
')'
) nfile
163
write
(luncode,
'('
'{'
')'
)
164
call
ctocp
(
'// init to 0 avoids "unused" warnings'
)
165
call
ctocp
(
'G4int nd=0,nh=0,nv=0,imate=0,itmed=0,nmat=0,'
)
166
call
ctocp
(
' isvol=0,ifield=0,nwhi=0,nwdi=0,idtyp=0,ipart=0,'
)
167
call
ctocp
(
' itrtyp=0,nlmat=0,npar=0,ndvmx=0,numed=0,iaxis=0,'
)
168
call
ctocp
(
169
+
' ndiv=0,irot=0,ival=0,num=0,nmed=0,nbits[100],mode[6];'
)
170
call
ctocp
(
'G4String chnam[100];'
)
171
call
ctocp
(
'G4String name="",moth="",attr="",only="",shape="";'
)
172
call
ctocp
(
'G4String chset="",chdet="",chali="",chpar="";'
)
173
call
ctocp
(
'G4double amass=0.,charge=0.,tlife=0.,parval=0.;'
)
174
call
ctocp
(
'G4double c0=0.,step=0.,a=0.,dens=0.,radl=0.,x=0.;'
)
175
call
ctocp
(
'G4double y=0.,z=0.,theta1=0.,phi1=0.,theta2=0.;'
)
176
call
ctocp
(
'G4double phi2=0.,theta3=0.,phi3=0.,fieldm=0.;'
)
177
call
ctocp
(
'G4double tmaxfd=0.,stemax=0.,deemax=0.,epsil=0.;'
)
178
call
ctocp
(
'G4double stmin=0.,par[100],fact[100],orig[100];'
)
179
call
ctocp
(
'G4double bratio[6],aa[100],zz[100],wmat[100];'
)
180
call
ctocp
(
'nbits[0]=mode[0]=0;chnam[0]="";par[0]=0.;'
)
181
call
ctocp
(
'fact[0]=orig[0]=bratio[0]=aa[0]=zz[0]=wmat[0]=0.;'
)
182
call
ctocp
(
' '
)
183
if
(nfile.eq.1)
then
184
* call ctocp('G3G4init();')
185
call
ctocp
(
' '
)
186
endif
187
end
188
189
subroutine
g3main
190
************************************************************************
191
************************************************************************
192
implicit none
193
#include "G3toG4.inc"
194
integer
i
195
*
196
close
(luncode)
197
open
(
unit
=luncode,
file
=
'G3toG4code.cc'
,
status
=
'unknown'
)
198
do
i=1,nfile
199
write
(luncode,
'('
' void G3toG4code_'
',i2.2,'
'();'
')'
) i
200
enddo
201
call
ctocp
(
'void G3toG4code()'
)
202
call
ctocp
(
'{'
)
203
do
i=1,nfile
204
write
(luncode,
'('
' G3toG4code_'
',i2.2,'
'();'
')'
) i
205
enddo
206
call
ctocp
(
'}'
)
207
close
(luncode)
208
end
209
210
subroutine
g3context
(cntxt)
211
************************************************************************
212
*
213
* g3context
214
*
215
* Set the current geometry code context. eg. context can be used
216
* to distinguish code for different subdetectors. The Geant4
217
* call list interpreter can then execute the code selectively for
218
* a particular context only, if desired. Spaces not allowed.
219
*
220
************************************************************************
221
implicit none
222
character*(*)
cntxt
223
#include "G3toG4.inc"
224
context
= cntxt
225
end
226
*
227
subroutine
ctocp
(string)
228
************************************************************************
229
************************************************************************
230
implicit none
231
character*(*)
string
232
#include "G3toG4.inc"
233
write
(luncode,*) string
234
end
235
*
236
subroutine
rtocp
(string,x)
237
************************************************************************
238
************************************************************************
239
implicit none
240
character*(*)
string
241
real
x
242
#include "G3toG4.inc"
243
write
(luncode,
'(4x,a,'
' = '
',e14.8,'
';'
')'
)
244
+ string,
x
245
end
246
*
247
subroutine
artocp
(string,ax,n)
248
************************************************************************
249
************************************************************************
250
implicit none
251
character*(*)
string
252
real
ax(*)
253
integer
n
,i
254
#include "G3toG4.inc"
255
do
i=1,
n
256
write
(luncode,
'('
' '
',a,'
'['
',i3,'
'] = '
',e14.8,'
';'
')'
)
257
+ string, i-1, ax(i)
258
enddo
259
end
260
*
261
subroutine
aitocp
(string,ai,n)
262
************************************************************************
263
************************************************************************
264
implicit none
265
character*(*)
string
266
integer
ai(*)
267
integer
n
,i
268
#include "G3toG4.inc"
269
do
i=1,
n
270
write
(luncode,
'('
' '
',a,'
'['
',i3,'
'] = '
',i10,'
';'
')'
)
271
+ string, i-1, ai(i)
272
enddo
273
end
274
*
275
subroutine
astocp
(string,ac,n)
276
************************************************************************
277
************************************************************************
278
implicit none
279
character*(*)
string, ac(*)
280
integer
n
,i
281
#include "G3toG4.inc"
282
c write(luncode,'('' G4String '',a,''['',i3,''];'')') string, n
283
do
i=1,
n
284
write
(luncode,
'('
' '
',a,'
'['
',i3,'
'] = "'
',a,'
'";'
')'
)
285
+ string, i-1, ac(i)
286
enddo
287
end
288
*
289
subroutine
g3ldpar
(par,npar)
290
************************************************************************
291
*
292
* g3ldpar
293
*
294
************************************************************************
295
implicit none
296
*
297
integer
npar, i
298
real
par(*)
299
#include "G3toG4.inc"
300
*
301
if
(npar.gt.0)
then
302
write
(luncode,
'('
' par['
',i4,'
'] = '
',e14.8,'
';'
')'
)
303
+ (i-1,par(i),i=1,npar)
304
endif
305
end
306
*
307
subroutine
check_lines
308
************************************************************************
309
************************************************************************
310
implicit none
311
#include "G3toG4.inc"
312
if
(luncode.ne.0)
then
313
nlines
=
nlines
+1
314
if
(
nlines
.gt.maxlines)
then
315
nfile = nfile +1
316
call
g3source
317
nlines
= 0
318
endif
319
endif
320
end
Generated on Sat May 25 2013 14:33:09 for Geant4 by
1.8.4