/[PAMELA software]/gpamela/garfield/src/heed101garf.car
ViewVC logotype

Annotation of /gpamela/garfield/src/heed101garf.car

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3.1 - (hide annotations) (download)
Thu Jul 11 16:02:05 2002 UTC (22 years, 7 months ago) by cafagna
Branch point for: v3r0, MAIN
Initial revision

1 cafagna 3.1 +TITLE.
2     HEED 1.01 /00 960118 00.00
3     *
4     * HEED, written by Igor Smirnov (St Petersburg) with an
5     * interface for use with Garfield.
6     *
7     +PATCH,*HEEDGARF. Pilot patch
8     +USE,HEEDCOM.
9     +USE,HEEDINT.
10     +USE,HEEDSUB.
11     +USE,EHEED.
12     +PATCH,DOC,IF=DOC.
13     +DECK,DOC,IF=DOC.
14    
15    
16    
17     --------------------------------------------------
18     HEED, an ionization loss simulation program
19     User's guide
20     Version 1.01 (preliminary)
21     --------------------------------------------------
22    
23     Igor Smirnov
24    
25     06.02.97
26    
27    
28     Introduction
29     ------------
30    
31    
32     The program HEED is intended for detailed calculations of the
33     ionization energy loss of fast charged particles in gases. The program
34     works for solids also, but with less accuracy.
35     The program can also simulate the absorption of the photons in the
36     detector.
37     The program can be applied to simulations of the detectors of the
38     high energy charged particles which register ionization produced by
39     particles in the gases.
40     The algorithm is based on a Monte-Carlo simulation of the energy
41     transfers from the incident particle to atomic electrons. After knocking
42     out of a primary delta-electron a vacancy remains in the atomic shell. The
43     number of shell with vacancy and the type of atom in the gas mixture are
44     specified for every energy transfer. It allows to calculate the
45     delta-electron energy and generate a cascade of secondary particles
46     emitted by the excited atom (the Auger electrons and the fluorescence
47     photons). The calculations include simulation of both absorption of them
48     in the matter and creation of conduction electrons.
49    
50     The program is written in fortran-77. It is tested on several UNIX
51     platforms.
52    
53     The program can be run as a stand-alone program and as subroutines
54     There are two variants: subroutine calculating an average ionization
55     and a cluster-sizes distribution and subroutine for generation of the
56     track, i.e. electron positions. In the both subroutine-forms the program
57     is restricted in choice of geometry and others. Interface to the subroutines
58     is much simpler, therefore we begin from explanation of how to call them, all
59     the following text being almost unnecessary for that users who exploit only
60     the subroutines. The user's guide followes by two additional chapters
61     expounding how to build the executable program from CMZ source text,
62     and giving a test results.
63    
64     --------------------------------------------------------
65     Copyright notice
66     ----------------
67    
68     Copyright Igor Smirnov, 1995, all rights reserved.
69    
70     HEED, an ionization loss simulation program.
71    
72     Copyright and any other appropriate legal protection of this computer
73     program and associated documentation reserved in all countries of the
74     world.
75    
76     This program or documentation may not be reproduced and/or redistributed
77     by any method without prior written consent of the author.
78    
79     Permission for the scientific usage of the program described herein is
80     granted apriori to all institution of Russian Academy of Scienses and to
81     those scientific institutes associated with the CERN experimental program
82     or with whom CERN has concluded a scientific collaboration agreement.
83    
84     Commercial utilisation requires explicit a priory permission from the author
85     and will be subjected to payment of a license fee.
86    
87    
88     ------------------------------------------------------
89    
90     The author can not warrant correct functioning of any part of the
91     program, it is the duty of the user to check that the accuracy of the
92     results is adequate for his/her purposes.
93     Any messages about errors, inaccuracies, and any other problems
94     are welcome. Suggestions for improvement are welcome.
95     Author are looking for any data on photoabsorption cross section,
96     especially for molecules and will be appreciate for sending him any such
97     data or references to them.
98     Author greatly appreciate receiving a copy of any note or
99     publication for which this program has been used.
100    
101     Author's e-mails:
102    
103     Igor.Smirnov@cern.ch
104     ismirnov@hep486.pnpi.spb.ru
105    
106     Igor Smirnov,
107     High Energy Physics Division,
108     Petersburg Nuclear Physics Institute.
109     Gatchina, 188350
110     St.-Petersburg
111     Russia
112    
113    
114    
115     --------------------------------------------------------
116    
117     Installation and compilation of CMZ-version
118     -------------------------------------------
119    
120     For CMZ the HEED program is placed into a car-file,
121     a CMZ Ascii Readable file. For installation we recommend the following
122     sequence of steps. First run the CMZ. Then type the next commands:
123     create heed
124     import/arc heed.car
125     seq -O //heed/PROGRAM
126    
127     There are seven possible ways of using the program HEED.
128     1. Run it as a stand-alone program with users
129     subroutines IniHeed, UBegEvent, UEndEvent.
130     2. Run the example of stand-alone program HEED.
131     3. Calling the subroutine SHEED.
132     4. Run the program PSHEED which is designed as an example of call of SHEED
133     and serves for testing of SHEED.
134     5. Calling the HEED from another user's program. The HEED is called as
135     subroutines
136     6. Run the program PEHEED which is designed as an example of call of HEED
137     in the form of subroutines and serves for testing of HEED.
138     7. Somebody can want to extract text documentation.
139     To ensure this possibilities some of the decks were equipped with
140     select control options, which allow to extract, compile and link only that
141     decks which is relevant for given task without explicit enumerating of
142     their names. The next options have to be swiched on for each mentioned
143     above case:
144     1. E
145     2. E,E1
146     3. SHEED
147     4. PSHEED, SHEED
148     5. EHEED
149     6. PEHEED, EHEED
150     7. DOC
151     This can be done by the command
152     select option_name
153    
154     The compilation is executed by commands
155     cc *
156     ,after that all the necessary object files are in a temporary file,
157     and the link can be executed by usual command depening on operating system.
158     For example, on our computer IBM RISC with operating system AIX
159     the temporary files is cmfor.f and cmfor.o, the program is linked by command
160     xlf -O -g -C -o HEED.e cmfor.o -L$CRNLIB -lpacklib -lkernlib
161     where the environment variable CRNLIB points to libraries.
162    
163    
164    
165    
166     Test results: average ionization loss
167     -------------------------------------
168    
169     Although the calculation of mean ionization loss (KeV and number
170     of pairs) and number of clusters does not involve all the routines of this
171     package, it uses a range of very important routines, results are numbers
172     and all these numbers can be compared with another calculation and
173     experimental values. This allows partially to check the program both from
174     principal and from technical point of view.
175     Below are the table listing for all predefined gases another
176     calculation by simular model [U.A.Budagov et al. Ionization effects in
177     high energy physics, Energoatomizdat, Moscow, 1988, Russian.](the first
178     line in each item), some experimental data (the second line in each item),
179     and our results (the third line in each item) calculated by subroutine
180     SHEED. The table illustrates the extent of exactness of the program and
181     can serve as a pattern of its results when testing proper execution of the
182     program on another computer.
183    
184     ------------------------------------------
185     Molecule dE/dx Npairs Nclusters
186     (KeV)
187     ------------------------------------------
188     He 0.322 7.6 3.3 calc. of U.A.Budagov et al
189     - - 3.57 - 5.02 experimental data
190     0.2847 6.943 3.38 our calculation
191    
192     Ne 1.452 39.9 10.9 so on
193     - - 11.7 - 12.4
194     1.446 40.84 11.7
195    
196     Ar 2.541 96.6 24.8
197     - - 22 - 28
198     2.517 96.81 26.1
199    
200     Kr 4.750 197.5 33.0
201     - - 34.65
202     4.611 192.1 24.5
203    
204     Xe 6.862 313.3 44.8
205     - - 48.41
206     6.947 315.8 52.3
207    
208     H2 0.342 9.4 4.7
209     - - 4.7
210     0.3362 9.087 7.85
211    
212     N2 2.097 60.5 20.8
213     - - -
214     2.004 57.25 27.4
215    
216     O2 2.360 76.5 23.2
217     - - -
218     2.285 73.7 24.3
219    
220     NH3 1.586 59.8 -
221     - - -
222     1.518 57.08 30.1
223    
224     N2O 3.275 100.6 -
225     - - -
226     3.146 96.5 39.8
227    
228     CO2 3.280 100.0 33.6
229     - - 33
230     3.133 94.95 34.7
231    
232     CF4 - - -
233     - - 51
234     6.049 176.4 59.7
235    
236     CH4 1.608 59.3 24.8
237     - - 25 - 26
238     1.537 56.3 31.6
239    
240     C2H2 2.339 90.8 31.5
241     - - -
242     2.046 79.3 33
243    
244     C2H4 2.696 104.5 40.4
245     - - -
246     2.388 92.58 42.9
247    
248     C2H6 2.870 117.7 40.5
249     - - 41 - 51
250     2.731 109.2 53
251    
252     C3H8 4.138 176.5 67.6
253     - - 63 - 74
254     3.925 163.5 75
255    
256     i-C4H10 5.402 232.8 83.6
257     - - 84 - 93
258     5.119 218.8 96
259     ----------------------------------------
260    
261    
262     The subroutine SHEED
263     --------------------
264    
265     The subroutine SHEED is created on the base of the program HEED
266     for solution of one particular but very important task: calculation of
267     cluster size distribution, and so as to do it in the form of a subroutine
268     calling from another program and receiving all the entering data in the
269     form of subroutine parameters.
270     Therefore the main program MainHEED, and the subroutine IniHeed was
271     converted into the subroutine SHEED. There is no need for user to provide
272     any additional subroutines as it must be done in the case of standart
273     applications of program HEED.
274     The form of calling is:
275     call SHEED
276     + (qmol, nmol, wmol, pres, temp,
277     + tkener, mas, maxnum, soo, oo, debug,
278     + density,dedx, ntotal, nclust, clprob, ierror)
279    
280     Input parameters:
281     integer qmol ! Quantity of different molecules
282     ! in the gas mixture.
283     integer nmol(pqMol) ! Their numbers from molecules.inc.
284     ! Use only the named constants
285     ! for compartibility with future versions.
286     real wmol(pqMol) ! Their weights
287     ! (relative quantities of molecules).
288     real pres ! Pressure in Torr.
289     real temp ! Temperature in K.
290     real tkener ! Kinetic energy of incident particle (MeV)
291     real mas ! Mass of incident particle(MeV)
292     integer maxnum ! Maximum size of cluster(not used now).
293     integer soo ! Flag allowing to write.
294     integer oo ! Output stream number.
295     integer debug ! Flag allowing to write
296     ! more amount of information.
297    
298     Output parameters:
299     real density ! Density of the gas.
300     ! It calculates for ideal gas.
301     real dedx ! Mean dE/dx, mean energy loss, KeV/cm.
302     real ntotal ! Average total number of
303     ! liberated conduction electrons.
304     real nclust ! number of clusters per cm.
305     real clprob(msize) ! Probability of the clusters,
306     ! Size=index.
307     integer ierror ! Sign of error( 0 -- no error ).
308    
309     For pointing to molecules the user is suggested to use the named
310     constants (only in symbolic form) defined in the file molecules.inc The
311     named constant pqMol is defined into the file molecules.inc.
312     The weights may not be nolmalized. The subroutine does this
313     itself. Some of the weights may be zero. The subroutine excludes such
314     items.
315     If pres=0, the standart atmosferic pressure, 760 Torr is substituted.
316     If temp=0, the standart atmosferic temperature, 293 K is substituted.
317     If pmas=0, the proton mass, 938 MeV is substituted
318     If tkener=0, the 'mip' is generated, gamma=4, tkener=pmas*3.
319    
320     The named constant msize is defined into file hs.inc, now it is
321     10000, that is the maximum cluster size, for which the probability is
322     calculated. This is just a formal approach, in real life such a big cluster
323     either will be like to a big cloud of ionization, or to a track going to
324     outside of the gas volume.
325     The probabilities for the clusters up to 20 electrons are calculated
326     by method Monte-Carlo with 1000 events. The probabilities for more large
327     clusters is calculated by an analitical approach, taking into account only
328     the cross section of energy transfers and dividing the transferred energy
329     on the mean work per pair production. The mean energy loss and total
330     electron number are computed analitically from integral of cross section.
331     The number of clusters is restored from Monte-Carlo and it may be affected by
332     a little statistical fluctuations, as soon as probabilities of the first
333     20 clusters. Note, all of this is related only to SHEED subroutine, solving
334     the partial problem.
335     The output parameter ierror is 1 if error is detected. All the
336     other output results is to be eliminated in this case. Any error messages
337     are printed to stream 'oo' regardless of value of the flag 'soo'. The
338     usual HEED listing is printed to the same stream provided that soo=1. A
339     little listing is printed if debug=0 or 1 and a very big listing useful
340     only for developers is printed if debug>=2.
341     The subroutine can be called several times from one program.
342    
343    
344     Calling HEED in the form of subroutines
345     ---------------------------------------
346    
347     The program was developed for using as a stand-alone program.
348     However, generating initial ionization it can not watch for its drift
349     to electrodes, and it may be necessary to combine it with another
350     chamber-simulation package. There are three ways of doing this:
351     to link a drift-simulation subroutine to HEED,
352     to link the HEED in the form of subroutines to a drift-simulation program,
353     or to connect two separate programs through intermediate file or stream.
354     The first and the last way are opened for user, while the second requires
355     some little changes in the program. Moreover, the process of initialization
356     may seem not enough simple for a user who wants to solve a simplest task with
357     one-layer geometry. To make the second way available and simple we
358     developed some interface subroutines, which get all setup information as
359     simple parameters. The generated ionization can be taken from well
360     discribed common blocks.
361     Unfortunately, it is difficult to return the output information
362     through the parameters, becouse of large amount of it.
363     The user has to extract what he needs from common blocks.
364     Therefore he may need to get familiar with the following general manual.
365     Only one gas can be initialized when using HEED by this way.
366     The work is naturally divided into initialization stage and event
367     processing stage. So as to reduce the number of the parameters of the
368     initializating subroutine, we split the subroutine into several ones.
369    
370     Initialization of the matter:
371     call IMHEED
372     + (qmol, nmol, wmol, pres, temp, soo, oo, debug,
373     + density, ierror)
374     All these parameters have the same type and sense as for SHEED:
375     Input parameters:
376     integer qmol ! Quantity of different molecules
377     ! in the gas mixture.
378     integer nmol(pqMol) ! Their numbers from molecules.inc.
379     ! Use only the named constants
380     ! for compartibility with future versions.
381     real wmol(pqMol) ! Their weights
382     ! (relative quantities of molecules).
383     real pres ! Pressure in Torr.
384     real temp ! Temperature in K.
385     integer soo ! Flag allowing to write to stream oo.
386     integer oo ! Output stream number.
387     integer debug ! Flag allowing to write
388     ! more amount of information.
389    
390     Output parameters:
391     real density ! Density of the gas.
392     ! It calculates for ideal gas.
393     integer ierror ! Sign of error( 0 -- no error ).
394    
395     For pointing to molecules user is sugested to use the named
396     constants (only in symbolic form) defined in the file molecules.inc The
397     named constant pqMol is defined into the file molecules.inc.
398     The weights may not be nolmalized. The subroutine does this
399     itself. Some of the weights may be zero. The subroutine excludes such
400     items.
401     If pres=0, the standart atmosferic pressure, 760 Torr is substituted.
402     If temp=0, the standart atmosferic temperature, 293 K is substituted.
403    
404    
405     Initialization of the volume:
406     It is doing by standart routines from HEED. User can build any number
407     of volumes, but since only one gas can be initalized, usually only
408     one volume can be necessary (there is no any restrictions in stand-alone
409     form). It is initialized by:
410     call IniFVolume(0, 1, 1, 1, left_borber, width )
411     where left_borber and widt are real amd measured in cm.
412    
413    
414     Initialization of the particle:
415     call IPHEED
416     + (tkener, mas, debug,
417     + ierror)
418    
419     real tkener ! Kinetic energy of incident particle (MeV)
420     real mas ! Mass of incident particle(MeV)
421     If pmas=0, the proton mass, 938 MeV is substituted
422     If tkener=0, the 'mip' is generated, gamma=4, tkener=pmas*3.
423     This subroutine defines the parameters of the particle which is
424     automatically generated later at the begin of simulation of each event.
425    
426    
427    
428     Initialization of the track:
429     The track can be initialized by the program IniRTrack.
430     call IniRTrack(ystart1, ystart2, pang, pphiang)
431     real ystart1 and ystart2 - bounds of interval on y-axis,
432     where the start point can be. The start point
433     is randomly placed inside these bounds.
434     They can be equal and the point will be fixed.
435     real pang - theta angle between the traectory and the z - axis
436     real pphiang - phi angle (turn around z-axis relativaly x-axis)
437     The track can be initialised one or more times. The next track
438     initialization deletes the old track.
439    
440    
441     The output parameter ierror is 1 if error is detected. All the
442     other output results is to be eliminated in this case. Any error messages
443     are printed to stream 'oo' regardless of value of the flag 'soo'. The
444     usual HEED listing is printed to the same stream provided that soo=1. A
445     little listing is printed if debug=0 or 1 and a very big listing useful
446     only for developers is printed if debug>=2.
447     The subroutines can be called several times from one program.
448    
449     The simulation of the events is done by
450     call GoEventn(nevt,qevt) ! Simulation of one event
451     Here nevt is number of the current event and qevt is the number
452     of the events ordered. In principal the standart GoEvent can be called,
453     if to include into user's program GoEvent.inc
454     The GoEvent must know the number of the current event
455     and the total ordered event number. If there was an overflow
456     of any controlled array - arrays with delta-electrons,
457     conduction electrons, real photons, virtual photons,
458     the GoEvent prints the wornings and auxiliary information
459     to the 'oo' after the last event generated. Therefore it must know which
460     event is last. So as to avoid including of GoEvent.inc ,
461     where the event number nevt and quantity of events qevt are stored,
462     user can call GoEventn ,that takes nevt and qevt as arguments and
463     simulates ONE event.
464    
465     So as to reduce the required memory, it is sensible to
466     reduce the maximal numbers of volumes of every kind (see volume.inc)
467     to 1. To have a possibility to treat volume woth more width,
468     the number of the conduction electrons (pqcel in cel.inc) can be increased.
469     The major comsumer of the memory is cel.inc.
470    
471     This is the end of the manual of calling of HEED in the form of subroutines.
472    
473    
474     Geometry
475     --------
476    
477     The detector is represented by a structure of geometrical volumes.
478     The volumes is filled with different materials. Each volume represents a
479     part of the detector. Having considered the practical applications we
480     formulated a simple geometrical model, ensuring simple and fast tracking.
481     The allowed geometrical configuration is a 3-dimensional space divided by
482     a parallel planes into a sequence of volumes. The widths and the number of
483     the volumes are arbitrary. Their dimensions along the planes are infinite.
484     The first and the last plane are the borders of the detector.
485     For example, the detector may consist of one or several multiwire
486     proportional chambers with insensitive solid plates and a sensitive gas
487     between them.
488     The coordinate system is oriented by such a way that z-axis is
489     perpendicular to the planes. Thus the volumes are considered to be
490     infinite along x- and y-directions.
491     The angle between z-axis and the direction of moving of the
492     incident particle is denoted theta. The polar angle is measured relatively
493     x-axis (around z-axis) and denoted phi. The theta angle must be less than pi/2. The
494     phi-angle is arbitrary. Thus the incoming particle comes from z=-infinity
495     and traverses the layers consequently from left to right.
496     The incident particle can move by a straight trajectory or by a
497     broken line determined by the multiple scattering. The photons (primary or
498     secondary) and all the secondary particles are thoroughly tracked through
499     the multi-layer structure.
500    
501    
502     Structure of the program
503     ------------------------
504    
505     Logically, there are three phases of the algorithm:
506     -Initialization
507     -Event processing
508     -Termination
509     The initialization phase consists of computing and storing of some
510     auxiliary data, which are necessary during event processing. The source
511     text of the program does not imply a concrete geometry, materials and any
512     other conditions related to particular problems. These data must be
513     allocated in common blocks during the initialization phase. To do this the
514     program calls the subroutine IniHeed. This subroutine has to be provided
515     by the user. It has to consist of the following steps, most of them
516     performed through calls to another HEED subroutines:
517     - set general parameters
518     - parameters for HBOOK
519     - output
520     - energy mesh
521     - atoms
522     - molecules
523     - materials
524     - incident particle
525     - cross sections
526     - track
527     All the data recorded to the common blocks during this phase
528     are kept there till end of run.
529     The processing of every event is also divided into three simular
530     phases:
531     - Event initialization
532     - Event processing
533     - Termination
534     During the event initialisation phase the information
535     about the previous event is deleted and the memory is prepared to record
536     the new event. The standart event initialisation does not require user
537     interventions. For non-standart cases the subroutine UBegEvent is called
538     after the standart initialisation have been done. This subroutine has to
539     be provided by the user. For example, it can initialize another user's
540     common blocks or generate an external photons or delta-electrons. For
541     trivial applications this subroutine may be empty. Having simulated each
542     event the program fills the predefined histograms and calls the subroutine
543     UEndEvent. This subroutine has to be provided by the user. Any treatment
544     of the information about the event can be carried out in it, all the
545     information being accessible here. The user defined histograms are to be
546     filled in this subroutine. For trivial applications this subroutine may
547     also be empty.
548     During the program termination phase all the histograms are
549     written into disk file.
550     Thus, the user has to prepare 3 subroutines: IniHeed, UBegEvent,
551     UEndEvent. The last two ones may be empty.
552     The program makes use two output streams and no input stream. The
553     text data, wornings, messages about errors and debug information are
554     directed to stream with logical number denoted 'oo', which has to be
555     determined by the user. There is possibility to ban all the output except
556     the messages about errors. Another output stream has the number 34 and it
557     is used only for saving of the histograms. This number is determined via
558     the parameter statament and it can be changed by the user. The filling and
559     saving of the histograms can be forbiden.
560     In case of errors the program prints a message and either
561     continues working or stops through the STOP operator.
562     The program is linked with the program libraries packlib and
563     kernlib.
564    
565    
566     Allocation of data
567     ------------------
568    
569     All the important information is stored in common blocks. Data
570     base systems are not used. Dimensions of arrays is usually specified as
571     named constants, i.e. by names which are given to constants by the
572     PARAMETER statements. In the case of problems the values of these
573     constants can be changed by the user.
574     Each common block together with declarations of types of variables
575     is decribed in an only place. Before beginning of the compilation they
576     have to be included in the subroutines by a text processor. At the
577     developing phase, the INCLUDE compiler directive is used, it makes the
578     fortran compiler include the external file into the source text. This
579     directive is provided in majority of contemporary fortran compilers,
580     although it is not provided by the standart. The common blocks are placed
581     in separate files and included in relevant places of the text. To ensure a
582     maximum mobility, the program is converted into CMZ car-file, and in that
583     form it is presented for applications. The convertion is executed by
584     specially developed utulite, that provides copying every source file into
585     CMZ-deck with changing INCLUDE compiler directives to +SEQ
586     CMZ-directives and every included file is copying into a sequence. However
587     we continue to use the terms 'source file' and 'included file' in this
588     manual and in comments in program. Working with CMS-version it need to
589     remember that instead of included file, for example, 'myfilename.inc' one
590     should operate with sequence with the same, no more than 8-characters name
591     without extension '.inc': 'myfilena'. Analogously, 'myfilename.f' would
592     turn to deck 'myfilena'.
593     The IMPLICIT NONE statament is used in every routine. The types of
594     names are determined explicitly. There are some rules we attempt to follow
595     choosing the names. Two of them need to be mentioned here, since they
596     differ from conventional ones and they are used throughout the program:
597     -Variables with first character 'q' mean usially quantity(number)
598     of somethings and they are integer.
599     -Variables with first characters 'pq' mean usially maximum allowed
600     quantity of something, they are names of integer constant, their values
601     are determined by the PARAMETER statements, they are usually used as the
602     dimensions of the arrays.
603     The sense of common blocks variables and arrays is explaned in
604     comments placed near the type declarations. Values of all these variables
605     can be printed out in a readable form by special subroutines, each common
606     block being printed by separate subroutine. Also there are separate
607     subroutines for initialization of common blocks.
608    
609    
610     The Dimensional Units
611     ---------------------
612    
613     Unless otherwise specified, the following units are used throughout
614     the program:
615     GRAMM, CENTIMETER, MEV, MEV/C, RADIAN, TORR, K
616    
617    
618     The included files
619     ------------------
620    
621     The included files contain the text of the definitions of the
622     common blocks followed by the specifications of the types of the incoming
623     variables and the specifications of types and values of the named
624     constants. Usually all these variables are kept in one common block,
625     rarely in two, the named constants do not allocated in common blocks at
626     all. Since the common block names are not mentioned in the source text of
627     the program, they are only of technical importance (they must not coincide
628     one with another and so on). Therefore speaking about the common blocks we
629     will mean rather groups of defined in one include file variables and
630     constants, and we will denote them by the names of the included files,
631     where they are defined. If such a file is included in subroutine, all the
632     variables, arrays and constants discribed there become accessible, and no
633     matter where and how they are allocated.
634     The following table contains the included file names and the their
635     destination. The character 'i' means that the contents are changed
636     (initialized) during initialisation phase. The character 'e' means that
637     the program recordes data there during the event processing. The character
638     'w' means that the user have to assing values to some variables from this
639     included file using the assignment statement (=).
640    
641     -----------------------------------------------------------------
642     The included files
643     -----------------------------------------------------------------
644     w i e r | GoEvent.inc Main control variables
645     | LibAtMat.inc Numbers of atoms
646     e | abs.inc Photons which is ready to absorb
647     i | atoms.inc Atomic data
648     i e | bdel.inc information about delta electrons tracking
649     | cbdeldat.inc fit of elastic electron cross sections
650     | cconst.inc world constants
651     e r | cel.inc conduction electrons information
652     i | crosec.inc cross sections of energy transfer of ionization loss
653     e | del.inc delta-electrons information
654     i | ener.inc energy mesh for ionization loss and photon absorbtion
655     w i | hist.inc histograms
656     e | lsgvga.inc ionization energy transfers
657     | (used only for filling of histograms)
658     w i | matters.inc matters data
659     i | molecdef.inc molecular information
660     r | molecules.inc list of molecular numbers
661     i r | part.inc primary particle data
662     e | raffle.inc auxiliary common for the ionization loss simulation
663     w i e | random.inc auxiliary data for random number generator
664     e | rga.inc real photons
665     i | shellfi.inc auxiliary, for communication Iniatom with shellfi
666     i | shl.inc shell information - probability of channels and
667     | energies of secondary particles
668     |
669     i | tpasc.inc auxiliary, for communication Iniatom with tpasc.f
670     i e | track.inc primary particle track information
671     i r | volume.inc information about volumes
672     ------------------------------------------------------------------
673    
674     There are four included files with several variables needed to be
675     asigned and this required only at initialisation of the program.
676    
677     ---------------------------------------------------------------------
678     GoEvent.inc:
679     integer soo ! Flag, allowing to print
680     ! to stream 'oo'
681     ! If it is 0, no print will be at all,
682     ! except the case of serious problems.
683     integer oo ! The output stream logical number.
684     integer qevt ! Quantity of events to produce.
685     integer ssimioni ! Sign to simulate ionization loss,
686     ! 0 - no ionization,
687     ! 1 - normal ionization.
688    
689     hist.inc:
690     integer sHist ! Sign to fill histograms
691     character*100 HistFile ! File name for file
692     ! with histograms.
693     real maxhisampl ! maximum amplitude for histograms
694     real maxhisampl2 ! reduced maximum amplitude for histograms
695     real maxhisample ! maximum amplitude for histograms
696     ! in units of numbers of the electrons.
697     integer pqhisampl ! quantity for histograms with amplitude.
698     integer shfillrang ! sign to fill special histogram nh2_rd
699     ! with practical range of delta electron
700     ! It takes some computer time.
701     random.inc:
702     integer sseed ! Sign to start first event
703     ! from seed point of random number generator.
704     integer seed(2) ! Form for writting and inputting
705     ! without modification during
706     ! binary to demical transformation.
707     matters.inc:
708     real Cur_Pressure ! Current pressure for initializing medium.
709     ! During gas initialization
710     ! subroutine gasdens uses it for
711     ! calculating of density.
712     real Cur_Temper ! Current temperature for initializing medium.
713     ! During gas initialization
714     ! subroutine gasdens uses it for
715     ! calculating of density.
716     -----------------------------------------------------------------------
717    
718    
719     All the other common blocks are filled automatically and allowed for
720     reading only. There are two reasons why user may need to be familiar with
721     them:
722     - to check the initialisation and working of the program
723     - to obtain the results of calculations.
724     However, so as to avoid updating the manual after each little
725     modification in them, we do not want to include their listings into this
726     manual so far. Users are invited to print the common blocks marked with
727     character 'r' from his/her current version, they are of the first interest,
728     all the variables being thoroughly explained in the comments.
729    
730    
731     Simplified Program Flow Chart
732     -----------------------------
733    
734     program MainHEED
735    
736     call IniHeed ! User's subroutine,
737     ! initialization of the detector.
738    
739     do nevt=1,qevt ! Loop over events.
740    
741     call GoEvent ! Simulation of one event.
742    
743     enddo
744    
745     end
746    
747     subroutine GoEvent
748    
749     call UBegEvent ! User's subroutine.
750    
751     ... ! Simulation of event.
752    
753     call UEndEvent ! User's subroutine,
754     ! any treatment of
755     ! the event information.
756    
757     end
758    
759    
760    
761     The main program
762     ----------------
763    
764     ------------------------------------------------------------------------
765     Listing . The main program, file MainHEED.f
766     ------------------------------------------------------------------------
767    
768    
769     program HEED
770     c
771     c The main program for HEED package
772     c
773     implicit none
774    
775     integer NPW
776     PARAMETER (NPW = 2000000)
777     real H
778     COMMON /PAWC/ H(NPW)
779    
780     include 'GoEvent.inc'
781     include 'volume.inc'
782     include 'hist.inc'
783    
784    
785     CALL HLIMIT(NPW)
786    
787     call Iniranfl ! Initialization of the counter of
788     ! random number generator calls
789     call IniHeed ! User's subroutine,
790     ! Initialization of the detector
791    
792     if(sHist.eq.1)then
793     call IniHist ! Initialization of inbilt histograms
794     endif
795    
796    
797     do nevt=1,qevt ! Loop over events
798    
799     call GoEvent ! Simulation of one event
800    
801     enddo
802    
803    
804    
805     if(sHist.eq.1)then
806     call WHist ! Writting of histograms
807     endif
808    
809    
810     call Priranfl ! Print the number of calls of
811     ! random number generator
812     end
813    
814     -----------------------------------------------------------------------
815    
816    
817     The event processor
818     -------------------
819    
820     -----------------------------------------------------------------------
821     Listing 2. The event processor, file GoEvent.f
822     -----------------------------------------------------------------------
823    
824    
825     subroutine GoEvent
826     c
827     c Event processor. It is called from MainHEED.
828     c
829     implicit none
830    
831     include 'GoEvent.inc'
832     include 'abs.inc'
833     include 'rga.inc'
834     include 'volume.inc'
835     include 'hist.inc'
836     include 'random.inc'
837    
838     integer iempty
839    
840    
841     c if(nevt.le.ninfo)then
842     if(soo.eq.1)then
843     write(oo,*)
844     write(oo,*)' Event number ',nevt
845     endif
846     if(nevt.eq.1.and.sseed.eq.1)then
847     call randset ! Set the start point of
848     endif ! the random number generator.
849     if(soo.eq.1)then
850     call randget
851     call randpri(oo) ! Print the current point of
852     endif ! the random number generator.
853     c endif
854    
855     call IniNTrack ! Generate the next track.
856     if(nevt.le.ninfo)then
857     call PriMTrack(0) ! Print debug information
858     call PriMTrack(1)
859     call PriMTrack(2)
860     call PriMTrack(3)
861     call PriMTrack(4)
862     endif
863    
864     call IniLsgvga ! Initialize gvga.inc
865     call Iniabs ! Initialize abs.inc
866     call Inirga ! Initialize rga.inc
867     call Inidel ! Initialize del.inc
868     call Inicel ! Initialize cel.inc
869    
870     call UBegEvent ! User's subroutine
871    
872     if(ssimioni.eq.1)call rafflev ! Generate the primary energy transfers
873     ! from incoming particle
874    
875     if(soo.eq.1)then
876     if(nevt.le.ninfo)then
877     write(oo,*)
878     call PriLsgvga ! Print debug information
879     endif
880     endif
881    
882     do iempty=1,10000
883    
884     if(soo.eq.1)then
885     if(nevt.le.ninfo)then
886     write(oo,*)
887     write(oo,*)' before absorption of virtual photons:'
888     call Priabs ! Print debug information
889    
890     endif
891     endif
892    
893     call AbsGam ! Absorb the virtual photons
894    
895     if(soo.eq.1)then
896     if(nevt.le.ninfo)then ! Print debug information
897     write(oo,*)
898     write(oo,*)' after absorption of virtual photons:'
899    
900     c call Priabs
901     call Prirga
902     call Pridel
903    
904     endif
905     endif
906    
907     call GoGam ! Absorb the photons
908    
909     if(soo.eq.1)then
910     if(nevt.le.ninfo)then ! Print debug information
911     write(oo,*)
912     write(oo,*)' after absorption of photons:'
913    
914     call Priabs
915     c call Prirga
916     call PrirgaF
917    
918     endif
919     endif
920    
921     if(ctagam.gt.qtagam.and.crga.gt.qrga)then
922     ! There are neither real no
923     ! virtual photons to trace.
924     goto 50 ! Exit the loop.
925     endif
926    
927     enddo
928    
929     50 continue
930    
931    
932     call treatdel ! Track the delta-electrons
933     ! and generate the conduction electrons.
934     call treatcel ! Treat the cel.inc
935     if(soo.eq.1)then
936     if(nevt.le.ninfo)then ! since there are calculation of ranges
937     ! which in wroute to del inside treatdel
938     write(oo,*)
939     call Pridel
940     endif
941     endif
942    
943     if(sHist.eq.1)then
944     call Fhist ! Fill predetermined histograms
945     endif
946    
947     call UEndEvent ! User's subroutine
948    
949     if(soo.eq.1)then
950     if(nevt.eq.qevt)then
951     write(oo,*)
952     write(oo,*)nevt,' events is done'
953     ! Printing the wornings about overful
954     call WorPrirga
955     call WorPriabs
956     call WorPridel
957     call WorPricel
958    
959     endif
960     endif
961    
962    
963     end
964    
965    
966     Initialization
967     --------------
968    
969     As was said above the duty to provide the initialization
970     subroutine is imposed upon the user. We can present here only an example
971     of such subroutine and we hope that it is enough clear for understanding
972     and the user will not meet troubles making use it as a 'fish' for
973     preparation of his own analogous subroutine.
974    
975     ---------------------------------------------------------------------------
976     listing 1 Example of IniHeed
977     ---------------------------------------------------------------------------
978    
979    
980    
981     subroutine IniHeed
982     c
983     c
984    
985     implicit none
986    
987     include 'GoEvent.inc'
988     include 'hist.inc'
989    
990     include 'ener.inc'
991     include 'atoms.inc'
992     include 'matters.inc'
993    
994     include 'cconst.inc'
995     include 'volume.inc'
996     include 'part.inc'
997     include 'h31.inc'
998     include 'random.inc'
999    
1000     real tkener,mas,momentum
1001    
1002     integer i
1003     integer j
1004    
1005    
1006     real wid
1007    
1008     real amc
1009     integer na
1010    
1011    
1012     soo=1 ! To allow (1) or to ban (0) printing to stream oo.
1013     oo=10 ! set logical number of output stream.
1014     open(oo,FILE='heed.out') ! open output disk file.
1015    
1016     sret_err = 0 ! Stop if error is detected
1017    
1018     c Auxiliary variables for histograms (from hist.inc)
1019     sHist=1 ! To allow (1) or to ban (0) dealing with histograms.
1020     HistFile='heed.hist' ! File name, where they are written to.
1021     maxhisampl=40.0e-3 ! Maximum aplitude.
1022     maxhisampl2=20.0e-3 ! Reduced maximum aplitude.
1023     maxhisample=150 ! Maximum aplitude in unit of number of elect.
1024     pqhisampl=100 ! Number of bins.
1025     shfillrang=1 ! To allow (1) or to ban (0) filling histogram nh2_rd.
1026    
1027    
1028     c Random number genarator
1029     sseed=0 ! To make the generator start from seed point (1)
1030     ! or from default point (0).
1031     seed(1)=1121517854 ! this is example for sseed=1
1032     seed(2)=612958528
1033    
1034    
1035     qevt=1000 ! Quantity of events to generate
1036    
1037     ssimioni=1 ! To allow ionization loss (1) or to ban it (0)
1038     ninfo=0 ! Number of first events with output listing
1039    
1040    
1041    
1042    
1043    
1044    
1045    
1046    
1047     call Inishl ! Cascade from excited atom
1048    
1049     call IniEner(150,3e-6,0.2) ! Energy mesh
1050     c call PriEner
1051    
1052     call AtomsByDefault ! Library of atoms
1053     c call PriAtoms(0)
1054    
1055     Cur_Pressure=Atm_Pressure
1056     Cur_Temper=Atm_Temper
1057    
1058     call CO250CF420Ar30(1) ! Material from LibAtMat
1059    
1060     c call PriMatter(0)
1061    
1062     wid=0.5
1063    
1064    
1065     call IniFVolume(1, 1, 1, 0, 0.0, wid ) ! Volume
1066    
1067     c call PriVolume
1068    
1069    
1070    
1071    
1072    
1073     mas=105.0 ! muon
1074     momentum=100000.0
1075     tkener=sqrt(mas*mas+momentum*momentum)-mas
1076    
1077     call IniPart(tkener,mas) ! Particle
1078     call PriPart
1079    
1080    
1081     call IniRTrack(0.0, 0.0, 0.0, 0.0) ! Track
1082     call PriTrack
1083    
1084     call IniCrosec ! Cross sections
1085     c call PriCrosec(1,4)
1086    
1087    
1088     call InisBdel ! Data for tracking of delta-electrons
1089    
1090     call PriBdel(0)
1091    
1092    
1093    
1094     end
1095    
1096     ---------------------------------------------------------------------------
1097    
1098     This example is so simple that subroutins UBegEvent and UEndEvent
1099     do not need to do anything. They can be just empty. Therefore they are not
1100     printed here. The results of calculations are histograms contained in the
1101     file 'heed.hist'.
1102    
1103    
1104     The program is using some information about the secondary
1105     radiation from exited atom. It is saved in the common block from "shl.inc".
1106     This information has a difficulte structure, which is initialized by
1107     special program "Inishl". One should just call the subroutine "Inishl"
1108     before any others. Users are strongly recommended to begin their
1109     simulation with the parameters as stored by Inishl. Users who want to
1110     modify any of these parameters must be sure they understand their function
1111     in the program and the implications of a change.
1112    
1113    
1114     The subroutine IniEne initializes the energy mesh for internal
1115     calculations. It is used in calculations of ionization loss and photon
1116     absorption. The points are equally spaced on a logarifmic scale.
1117     call IniEne(q,emin,emax)
1118     int q - quantity of the points. 100-200 is recomended.
1119     real emin - the minimum energy. It must be less than minimum for
1120     photo absorbtion cross section. 5 eV is recomended.
1121     real emax - the maximum energy. It must be several times more than
1122     maximum of the shell energies. 200 KeV is recomended.
1123     This subroutine initializes the common block from file "ener.inc" .
1124    
1125     Almost all the arrays with atomic, matters, cross-section information
1126     corresponds to the centers of the energy intervals, each value being the
1127     overage of a parameter on this interval.
1128    
1129    
1130     Initialisation of the atoms
1131     ---------------------------
1132    
1133     The atomic information is allocated in the file atom.inc. The
1134     atoms are assigned numbers. The numbers are indexes of array elements,
1135     where the atomic information is saved. These numbers are used as the
1136     pointers to the atoms throughout the program. The atoms can be initialized
1137     in arbitrary order. The empty places are allowed. The program uses the
1138     variable Zat (charge of atomic nucleus) as a sign of whethere the atom is
1139     initialized, the atom being initialized if it is positive, nonzero. An
1140     attempt to refere to an empty place or to initialize the atom twice
1141     usually causes the program stop immediately, the error message being
1142     printed.
1143    
1144    
1145     There is a list of the predetermined atoms, it contains all the
1146     most often used atoms, see LibAtMat.inc. It is initialized by
1147     call AtomsByDefault .
1148     If the necessary atom is not included in
1149     this list, it need to increase parameter pQAt (atoms.inc) and initialize
1150     the new atoms in free places, calling the subroutine IniAtom. (The IniAtom
1151     knows the atom numbers from LibAtMat.inc and it carried out a special
1152     algorithms for some of them. Thus, even if AtomsByDefault is not called,
1153     the new atoms have to be initializaed on different places.) The subroutine
1154     IniAtom initializes the atomic data.
1155     call IniAtom(num,z,a)
1156     int num - internal number of the atom. It can not be
1157     less than zero and larger than pQAt-maximun
1158     quantity of the atoms.
1159     pQAt is set in atoms.inc and can be changed.
1160     There are no possibility to define atom with
1161     the same number second time. The program terminates if
1162     one of these errors are occured.
1163     int z - charge
1164     real a - atomic weight
1165     The information is writting to the 'atoms.inc'. Use subroutine PriAtoms
1166     so as to print all the atoms to the standart unit 'oo'.
1167    
1168    
1169     Initialisation of the materials
1170     --------------------------------
1171    
1172     The information about materials is allocated in the file
1173     matters.inc. The matters are assigned numbers by the user.
1174     The numbers have the same meaning as the atom numbers.
1175     These numbers are used as the pointers to the matters throughout the program.
1176     The matters can be initialized in arbitrary order.
1177     The empty places are allowed. The program uses the variable QAtMat
1178     as a sign of whethere the matter is initialized, the matter being
1179     initialized if it is positive. An attempt to refere to an empty place or
1180     to initialize the atom twice usually causes the program stop immediately,
1181     the error message being printed.
1182    
1183     There is a library of subroutines initializing various matters,
1184     mainly gases. They are placed in the file LibAtMat.f. The only argument of
1185     these subroutines is matter number. They use the atoms initialized by call
1186     AtomsByDefault.
1187    
1188     There is a special package intended for initialisation of an
1189     arbitrary gas mixture. There are a list of predeterminated molecules in
1190     file molecules.inc. This list will be increased in the future. The gas
1191     mixture can be arbitrary mixture of these molecules. The subroutine
1192     molecdef initializes these molecules. The information is allocated in
1193     molecdef.inc and can be printed by call Primolec. The subroutine Inigas
1194     initializes a gas mixture:
1195     subroutine Inigas( nmat, qmol, nmol, pwmol, pres, temp)
1196     integer nmat ! Number of material
1197     integer qmol ! Quantity of different molecules
1198     ! in the gas mixture.
1199     integer nmol(pqMol) ! Their numbers in molecdef.inc
1200     ! accordingly with molecules.inc
1201     real pwmol(pqMol) ! Their weights
1202     ! (relative quantities of molecules).
1203     real pres ! Pressure in Torr.
1204     real temp ! Temperature in K.
1205    
1206    
1207     Finnally there is a basical subroutine IniMatter, capable to
1208     create any solid or gas.
1209     The subroutine IniMatter initializes the material.
1210     call IniMatter(num,Atom,Weight,q,dens)
1211     int num - internal number of the matter. It can not be
1212     less than zero and larger than pQMat-maximun
1213     quantity of the matters.
1214     pQMat is set in matters.inc and can be changed.
1215     There are no possibility to define matter with
1216     the same number second time. The program terminates if
1217     one of these error are occured.
1218     int Atom(*) - array of the atomic numbers(internal-see above).
1219     real Weight(*) - quantity of the atoms in the mixture.
1220     The sum may be not equal to one.
1221     int q - quantity of atoms.
1222     real dens - density of the matter.
1223     The information is writting to the 'matters.inc'.
1224     Use subr. PriMatter so as to print all the matters to the standart unit
1225     oo. The weights of atoms stored in matters.inc are corrected by the subr.
1226     IniMatter so as their sum is equal to 1.
1227    
1228    
1229     The function gasdens calculates the density of the gas. Pressure
1230     and temperature is taken from variables Cur_Pressure and Cur_Temper placed
1231     in matters.inc. The density is calculated by law of ideal gas.
1232     dens=gasdens(A,Weight,q)
1233     real dens - density in g/sm**3
1234     real A(*) - array of the molecular weights
1235     real Weight(*) - quantity of the molecules in the gase mixture
1236     The sum may be not equal to one.
1237     int q - quantity of the molecules
1238    
1239    
1240    
1241    
1242     Initialization of the Geometry
1243     ------------------------------
1244    
1245     The geometrical model and the coordinate system is defined in
1246     section geometry at the begin of this document.
1247     The volumes is initialised consequently from right to left.
1248     There are three types of volumes here. There are two keys
1249     to define it, one combination is not allowed.
1250     They are:
1251     sSens - sign that it is sensitive volume i.e. proportional chamber.
1252     sIon - sign that the ionization loss must be here.
1253     Some of these sorts of volumes could refer to 0 as number of the matter.
1254     The following combinations are allowed:
1255     ---------------------------------
1256     matter number sSens sIon
1257     ---------------------------------
1258     0,any 0 0
1259     not 0 0 1
1260     not 0 1 1
1261     ---------------------------------
1262     Ionization loss may not be calculated anywhere since it can be too long.
1263     It is sensible to calculate them only in chamber gas and in special cases
1264     in the poliethilene or mylar around it. Zero matter number in all cases
1265     except last means vacuum. Therefore ionization or sensitive volume can not
1266     include vacuum.
1267    
1268     The subroutine IniVolume initializes the first or the next volume
1269     on the right of the previous. The next two subroutins are more convinient.
1270     call IniVolume(nmat,sSens,sIon,sTran,cwall1,cwall2,wide)
1271     int nmat - number of the material
1272     int sSens - sign of the sesitivity.
1273     int sIon - sign of ionization loss.
1274     int sTran - sign of the transition radiator. Not using in LSG.
1275     real cwall1 - z-coordinate of the left side of the volume.
1276     It using only for the first volume.
1277     real cwall2 - z-coordinate of the right side of the volume.
1278     real wide - wide. Not using now.
1279    
1280     Initialization of the first volume:
1281     call IniFVolume(nmat,sSens,sIon,sTran,cwall1,wide)
1282    
1283     Initialization of the next volume:
1284     call IniNVolume(nmat,sSens,sIon,sTran,wide)
1285    
1286     The quantity of the volumes can't be more than pqvol - max.
1287     quantity of the volumes. pqvol is defined in volume.inc and can be
1288     changed. All the volume parameters are saved in the volume.inc. You can
1289     print all the volume parameters by the program PriVolume.
1290     The convinuent possibility to calculate of the total radiation
1291     lenght is take a look into output listing. But for LST output must be done
1292     after IniLst so as to take into account radiator.
1293    
1294    
1295     Other Initializations
1296     ---------------------
1297    
1298     The particle is initialized by
1299     call IniPart(tkener,mas)
1300     real tkener - kinetic energy (MeV)
1301     real mas - mass (MeV)
1302     Particle can be initialized one or more times. After each initialization
1303     the call IniCrosec is needed.
1304    
1305    
1306     The calculations of the energy transfer cross sections are made by
1307     subr. IniCrosec.
1308     call IniCrosec
1309     It calculates the cross section only for those matter, which are contined
1310     in the sensitive volumes and only for initialized particle. If you
1311     initialize the new particle you must call IniCrosec again.
1312    
1313    
1314     The initializations of data for delta-electrons tracing must be
1315     done by call InisBdel.
1316    
1317    
1318     The track can be initialized by the program IniRTrack.
1319     call IniRTrack(ystart1, ystart2, pang, pphiang)
1320     real ystart1 and ystart2 - bounds of interval on y-axis,
1321     where the start point can be. The start point
1322     is randomly placed inside these bounds.
1323     They can be equal and the point will be fixed.
1324     real pang - theta angle between the traectory and the z - axis
1325     real pphiang - phi angle (turn around z-axis relativaly x-axis)
1326     The track can be initialised one or more times. The next track
1327     initialization deletes the old track. Call IniCrosec is not need again.
1328    
1329    
1330     Initialization of the Histograms
1331     --------------------------------
1332    
1333     There are several predefined histograms, described in files
1334     hist.inc and hist.f. They are treated automatically. The user program can
1335     define and fill any additional histograms, calling relevant HBOOK
1336     subroutines.
1337    
1338    
1339     Random Numbers Generators
1340     -------------------------
1341    
1342     The only uniform random number generator is called throughout the
1343     program: function ranfl. It is just intermediate function intended for
1344     connection with one of the standart random number generators and allows to
1345     change it in case of need. But one ought to be careful, the correlations
1346     between the current and the next rundom numbers are found to worse the
1347     results. To pass from current generator to another one it need only to
1348     change the call of it inside the body of the function ranfl and to change
1349     three auxiliary functions in the same file:
1350     randset - set start point
1351     randget - get current point
1352     randpri - print current point.
1353     Since all the generators of the non-uniform numbers use uniform
1354     random number generator as well, we extracted all the necessary routines
1355     from CERNLIB and modified them inserting the call of ranfl:
1356     lranor - random numbers following Gauss distribution
1357     (modified rannor)
1358     lspois - Poisson distribution
1359     (modified poissn),(also a little error is corrected)
1360     hisran - random numbers following histogram
1361     (the same name as in CERNLIB)
1362     All of them is contined in file random.inc.
1363     Thus there is the only random number sequence used in all the
1364     program. Therefore the program can repeat the simulations starting from
1365     any event. For this purpose, at the begin of each event the program prints
1366     the seed numbers.
1367    
1368    
1369     Files With Text of Program
1370     --------------------------
1371    
1372    
1373     PSHEED.f # check of SHEED
1374     SHEED.f # the main subroutine instead of program,
1375     # cluster size distibution
1376     UEventS.f # subroutine for SHEED
1377     MainHEED.f # main program
1378     GoEvent.f # generate one event
1379     IniHeed1.f # users routine for setup initialization
1380     UEvent1.f # users routine for work with event
1381     IniEner.f # energy net initialization
1382     logscale.f # function for logariphmic scale generation
1383     Inishl.f # atomic channels genaration
1384     LibAtMat.f # library of some atoms and matters
1385     molecdef.f
1386     Inigas.f
1387     IniAtom.f # atomic data initialization
1388     tpasc.f
1389     shellfi.f # subroutines for atomic data files reading
1390     line.f # auxiliary functions for straight line integration
1391     # and steps integration
1392     IniMatter.f # matter data initialization
1393     gasdens.f # gas density calculation
1394     IniVolume.f # volumes initialization
1395     IniTrack.f # track initializatin
1396     IniPart.f # particle initialization
1397     IniCrosec.f # ionization cross section initialization
1398     IniLsgvga.f # common lsgvga.inc initialization
1399     Inirga.f # common rga.inc initialization
1400     Iniabs.f # common abs.inc initialization
1401     raffle.f # ionization loss generator, filling abs.inc and lsgvga.inc
1402     GoGam.f # photons tracing till absorbtion, fills abs.inc
1403     AbsGam.f # photons absorbtion, fills del.inc and rga.inc
1404     IniBdel5.f # common bdel.inc initialization
1405     lstrel1.f
1406     Inidel.f # common del.inc initialization
1407     treatdel.f # treat delta-electrons and fill cel.inc
1408     Inicel.f # common cel.inc initialization
1409     treatcel.f # treat current electrons
1410     SourcePhot.f # auxiliary source of photons
1411     SourceDelEl.f # auxiliary source of delta-electrons
1412     vectors.f # vector algebra subroutins
1413     random.f # random number generators
1414     hist.f # histogram initialization and fill
1415    
1416    
1417    
1418     +PATCH,HEEDCOM.
1419     +KEEP,molecule.
1420     integer pqMol ! Quantity of sorts of molecules.
1421     parameter (pqMol=25)
1422    
1423     integer numm_He
1424     parameter (numm_He= 1)
1425    
1426     integer numm_Ne
1427     parameter (numm_Ne= 2)
1428    
1429     integer numm_Ar
1430     parameter (numm_Ar= 3)
1431    
1432     integer numm_Kr
1433     parameter (numm_Kr= 4)
1434    
1435     integer numm_Xe
1436     parameter (numm_Xe= 5)
1437    
1438     integer numm_H2
1439     parameter (numm_H2= 6)
1440    
1441     integer numm_N2
1442     parameter (numm_N2= 7)
1443    
1444     integer numm_O2
1445     parameter (numm_O2= 8)
1446    
1447     integer numm_NH3
1448     parameter (numm_NH3= 9)
1449    
1450     integer numm_N2O
1451     parameter (numm_N2O= 10)
1452    
1453     integer numm_CO2
1454     parameter (numm_CO2= 11)
1455    
1456     integer numm_CF4
1457     parameter (numm_CF4= 12)
1458    
1459     integer numm_CH4
1460     parameter (numm_CH4= 13)
1461    
1462     integer numm_C2H2
1463     parameter (numm_C2H2= 14)
1464    
1465     integer numm_C2H4
1466     parameter (numm_C2H4= 15)
1467    
1468     integer numm_C2H6
1469     parameter (numm_C2H6= 16)
1470    
1471     integer numm_C3H8
1472     parameter (numm_C3H8= 17)
1473    
1474     integer numm_iC4H10
1475     parameter (numm_iC4H10= 18)
1476    
1477     integer numm_C ! for debug
1478     parameter (numm_C = 19)
1479     *** Additions (RV 4/9/98).
1480     integer numm_DME
1481     parameter (numm_DME= 20)
1482    
1483     integer numm_H2O
1484     parameter (numm_H2O= 21)
1485     *** Additions (RV 20/9/99).
1486     integer numm_SF6
1487     parameter (numm_SF6= 22)
1488    
1489     integer numm_C2F4H2
1490     parameter (numm_C2F4H2= 23)
1491    
1492     *** Addition (RV 14/1/00).
1493     integer numm_C5H12
1494     parameter (numm_C5H12= 24)
1495    
1496     *** Addition (RV 25/2/00).
1497     integer numm_C2F5H
1498     parameter (numm_C2F5H= 25)
1499     *** End of additions.
1500    
1501     c integer numm_CClF3
1502     c parameter (numm_CClF3= 19)
1503    
1504     c integer numm_CClF2
1505     c parameter (numm_CClF2= 20)
1506    
1507     c integer numm_CBrF3
1508     c parameter (numm_CBrF3= 21)
1509    
1510     c integer numm_SF6
1511     c parameter (numm_SF6= 22)
1512     +KEEP,molecdef.
1513     integer pqSAtMol ! Max. allowed quantity of sorts of atoms
1514     ! in a molecule.
1515     parameter (pqSAtMol=3)
1516     integer qSAtMol ! Quantity of sorts of atoms in a molecules.
1517     integer nAtMol ! Number of atom in atoms.inc,
1518     ! see LibAtMat.inc.
1519     integer qAtMol ! Quantity of atoms of given sort in molecule
1520     real weiMol ! Molecular weight
1521     real WWWMol ! Mean work for pair production
1522     real FFFMol ! Parammeter Fano
1523     common / cmodef /
1524     + qSAtMol(pqMol),
1525     + nAtMol(pqSAtMol,pqMol),
1526     + qAtMol(pqSAtMol,pqMol),
1527     + weiMol(pqMol),
1528     + WWWMol(pqMol),
1529     + FFFMol(pqMol)
1530     save / cmodef /
1531     +KEEP,hs.
1532     integer msize
1533     parameter (msize=10000)
1534    
1535     real prob,meanprob,meanvga,meanvgal
1536     real prob1
1537     integer qe
1538     common / h31 /
1539     + prob(msize),meanprob,meanvga,meanvgal,
1540     + prob1(msize)
1541     +KEEP,GoEvent.
1542     c Main control variables
1543    
1544    
1545     integer soo ! Flag, allowing to print
1546     ! to stream 'oo'
1547     ! If it is 0, no print will be at all,
1548     ! except the case of serious problems.
1549     integer oo ! The output stream logical number.
1550     integer qevt ! Quantity of events to produce.
1551     integer nevt ! Current number of the event.
1552     integer ninfo ! Quantity of the first events
1553     ! to print debug info.
1554     integer ssimioni ! Flag to simulate ionization loss,
1555     ! 0 - no ionization,
1556     ! 1 - to simulate ionization.
1557     !
1558     !
1559     !
1560     integer srandoff ! Flag to swich off the randomization
1561     ! in function treatdel.
1562     ! It is for debug and without guarantee.
1563     parameter (srandoff=0) ! Normal regim with randommization.
1564    
1565     integer pqup ! dimensions of arrays of auxiliary
1566     ! parameters in abs.inc, rga.inc,
1567     ! del.inc
1568     parameter (pqup=1)
1569    
1570    
1571     integer sret_err ! Sign to return the control from current
1572     ! subroutine to which is called it if error is occured.
1573     ! 1 - to return, 0 - to stop.
1574     ! It is intended for handling with subroutine SHEED.
1575     ! In the case of error it can return the control instead of
1576     ! stop. But not for every possible errors return is done.
1577     ! Some of the most original errors could lead to stop.
1578     ! When working with HEED program, sret_err must be zero.
1579     integer s_err ! Sign of error.
1580     ! 1 - error, 0 - no error
1581    
1582     character*9 TaskName ! Name of task, using for generating
1583     ! file names.
1584     character*40 OutputFile ! Name of file with output listing.
1585     ! Using only in IniHeed.
1586     common / cGoEve /
1587     + soo, oo,
1588     + qevt,nevt,ninfo,
1589     + ssimioni,
1590     + sret_err, s_err,
1591     + TaskName,
1592     + OutputFile
1593    
1594     save / cGoEve /
1595    
1596     +KEEP,ener.
1597     c Energy mesh
1598    
1599     integer pqener,qener ! Max. quantity and quantity of bins.
1600     ! Quantity must not be more than pqener - 1.
1601     PARAMETER (pqener=501)
1602     real ener,enerc ! The left edges and the centers
1603     ! of the energy intervals.
1604     ! ener(qener+1) is the right edge
1605     ! of the last interval.
1606     C
1607     COMMON / coEner /
1608     + qener, ener(pqener), enerc(pqener)
1609     save / coEner /
1610     +KEEP,atoms.
1611    
1612    
1613     integer pQAt ! Max. quantity of atoms.
1614     parameter (pQAt=19)
1615     integer KeyTeor ! Key to use only theor. photo-absorbtion
1616     ! cross section with thresholds and
1617     ! weights from the subroutine shteor.
1618     ! If 0 then they are used only for
1619     ! the atoms which are absent
1620     ! in the subroutine readPas and
1621     ! in the subroutine shellfi.
1622     integer Zat ! Atomic number (charge of atomic nucleus).
1623     real Aat ! Atomic weight.
1624     integer pQShellAt ! Max. quantity of atomic shells.
1625     parameter (pQShellAt=17)
1626     integer QShellAt ! Quantity of atomic shells.
1627     real cphoAt ! Integral of photo-absorbtion
1628     ! cross secton for one atom.
1629     real ThresholdAt ! Threshold and
1630     real WeightShAt ! Weight of atomic shells for the
1631     ! photo-absorbtion cross secton
1632     ! relatively cphoAt.
1633     real PWeightShAt ! Initial integral of
1634     ! photo-absorbtion cross secton.
1635     real PhotAt ! Photo-absorbtion cross secton.
1636     real PhotIonAt ! Photo-ionization cross secton.
1637     c The physical definition of two previous arrays of values:
1638     c mean values of cross sections for each energy interval.
1639     real RLenAt ! Radiation lengt*density for dens=1
1640     real RuthAt ! Const for Rutherford cross cection
1641     ! (dimensionless).
1642     c integer num_at_mol ! Number for atoms in several special
1643     c ! molecules, now obsolete.
1644     real ISPhotBAt ! Shell integral of cs before normalization
1645     real IAPhotBAt ! Atomic integral of cs before normalization
1646     real ISPhotAt ! Shell integral of cs
1647     real IAPhotAt ! Atomic integral of cs
1648     real ISPhotIonAt ! Shell integral of cs
1649     real IAPhotIonAt ! Atomic integral of cs
1650     real MinThresholdAt ! Minimal ionization potential of atom.
1651     integer NshMinThresholdAt ! Number of shell with minimal energy,
1652     ! it must be the last shell ( see AbsGam.f)
1653     integer Min_ind_E_At, Max_ind_E_At ! Indexes of energy intervals
1654     ! where program adds excitation to cs
1655     ! They placed in common only to print and check.
1656     integer nseqAt ! Sequensed pointer in order of increasing Zat
1657     ! atom number nsAt(1) is least charged.
1658     integer QseqAt ! Quantity of initialized atoms
1659    
1660     common / catoms /
1661     + KeyTeor,
1662     + Zat(pQAt), Aat(pQAt),
1663     + QShellAt(pQAt), cphoAt(pQAt),
1664     + ThresholdAt(pQShellAt,pQAt), WeightShAt(pQShellAt,pQAt),
1665     + PWeightShAt(pQShellAt,pQAt),
1666     + PhotAt(pqener,pQShellAt,pQAt),
1667     + PhotIonAt(pqener,pQShellAt,pQAt),
1668     + ISPhotBAt(pQShellAt,pQAt),
1669     + IAPhotBAt(pQAt),
1670     + ISPhotAt(pQShellAt,pQAt),
1671     + IAPhotAt(pQAt),
1672     + ISPhotIonAt(pQShellAt,pQAt),
1673     + IAPhotIonAt(pQAt),
1674     + MinThresholdAt(pQAt),
1675     + NshMinThresholdAt(pQAt),
1676     + Min_ind_E_At(pQAt), Max_ind_E_At(pQAt),
1677     + RLenAt(pQAt),
1678     + RuthAt(pQAt),
1679     + nseqAt(pQAt),
1680     + QseqAt
1681     save / catoms /
1682     +KEEP,matters.
1683     integer pQMat ! Max. quantity of matters.
1684     parameter (pQMat=10)
1685     integer QAtMat ! Quantity of atoms in matter.
1686     integer AtMAt ! Number of atom in matter
1687     ! (the pointer to atoms.inc).
1688     real WeightAtMat ! Weight of atom in matter.
1689     real A_Mean ! Average A.
1690     real Z_Mean ! Average Z.
1691     real DensMat ! Density (g/cm3).
1692     real DensMatDL ! Density (g/cm3) for energy loss of deltaelect.
1693     real DensMatDS ! Density (g/cm3) for mult. scat. of deltaelect.
1694     real ElDensMat ! Electron density(MeV3).
1695     real XElDensMat ! Longitud. Electron Dens. for x=1cm(MeV2/cm)
1696     real wplaMat ! Plasm frequancy.
1697     real RLenMat ! Radiation Lengt.
1698     real RuthMat ! Const for Rutherford cross section (1/cm3).
1699     real PhotMat ! Photoabsirbtion cross section per one atom.
1700     real PhotIonMat ! Photoionization cross section per one atom.
1701     real epsip ! plasm dielectric constant.
1702     real epsi1 ! real part of dielectric constant.
1703     real epsi2 ! imaginary part of dielectric constant.
1704     real min_ioniz_pot ! Minimum ionization potential,
1705     ! it is using only for switching off
1706     ! the Cherenkov radiation below it.
1707     real Atm_Pressure ! Standart atmosferic pressure.
1708     parameter (Atm_Pressure=760.0)
1709     real Cur_Pressure ! Current pressure for initialized medium.
1710     ! During gas initialization
1711     ! the subroutine gasdens uses it for
1712     ! calculating of density.
1713     real Pressure ! Pressure for given medium.
1714     real Atm_Temper ! Standart atmosferic temperature.
1715     parameter (Atm_Temper=293.0)
1716     real Cur_Temper ! Current temperature for initialized medium.
1717     ! During gas initialization
1718     ! the subroutine gasdens uses it for
1719     ! calculating of density.
1720     real Temper ! Temperature for given medium.
1721     real WWW ! The mean work per pair production.
1722     real FFF ! Fano parameter.
1723     common / cmatte /
1724     + QAtMat(pQMat),
1725     + AtMat(pQAt,pQMat),
1726     + WeightAtMat(pQAt,pQMat),
1727     + A_Mean(pQMat),Z_Mean(pQMat),
1728     + DensMat(pQMat),ElDensMat(pQMat),XElDensMat(pQMat),
1729     + DensMatDL(pQMat),DensMatDS(pQMat),
1730     + wplaMat(pQMat),
1731     + RLenMat(pQMat),
1732     + RuthMat(pQMat),
1733     + PhotMat(pqener,pQMat),
1734     + PhotIonMat(pqener,pQMat),
1735     + epsip(pqener,pQMat),
1736     + epsi1(pqener,pQMat),
1737     + epsi2(pqener,pQMat),
1738     + min_ioniz_pot(pQMat),
1739     + Cur_Pressure,Pressure(pQMat),
1740     + Cur_Temper,Temper(pQMat),
1741     + WWW(pQMat),FFF(pQMat)
1742     save / cmatte /
1743     +KEEP,crosec.
1744     integer pQShellC ! Max quantity of shells for all atoms
1745     ! in one material
1746     parameter (pQShellC=20)
1747     c integer MatC ! Matter number
1748     integer sMatC ! Sign to calculate sross section
1749     ! for this matter
1750     integer QShellC ! Quantity of shells for all atoms
1751     ! in this matter
1752     c real ksi ! Help Landau constant
1753     c ! (it seems it is't used)
1754     real log1C ! first log
1755     real log2C ! second log
1756     real chereC
1757     real chereCangle
1758     real addaC ! energy tranfer cross section
1759     real quanC ! it's integral,
1760     ! or quantity of energy transfers,
1761     ! or primary cluster number.
1762     real meanC ! first moment,
1763     ! or restricted mean energy loss, Mev.
1764     real meanC1 ! first moment with whole additional tail
1765     ! to emax - kinematically allowed transition.
1766     ! Now it is calculated only for heavy particles
1767     ! because the integral for electrons is not
1768     ! trivial,
1769     ! or mean energy loss, Mev.
1770     real meaneleC ! expected restricted quantity of
1771     ! secondary ionization.
1772     real meaneleC1 ! expected quantity of secondary ionization.
1773     integer NAtMC ! number of atom in the matter
1774     ! for shell with corr. index
1775     integer NAtAC ! number of atom
1776     integer NSheC ! number of shell
1777    
1778     real flog1
1779     real flog2
1780     real cher
1781     real rezer
1782     real frezer
1783     real adda
1784     real fadda
1785     real quan
1786     real mean
1787    
1788     complex*16 pocaz ! it is help
1789     ! coefficient at y
1790     ! the value of imajinary part
1791     ! corresponsd to with of wave front
1792    
1793     common / ccrosec /
1794     + pocaz(pqener,pQMat),
1795     + sMatC(pQMat),
1796     + QShellC(pQMat),
1797     c + ksi(pQMat),
1798     + log1C(pqener,pQMat),
1799     + log2C(pqener,pQMat),
1800     + chereC(pqener,pQMat),
1801     + chereCangle(pqener,pQMat),
1802     + addaC(pqener,pQMat),
1803     + quanC(pQMat),
1804     + meanC(pQMat),
1805     + meanC1(pQMat),
1806     + meaneleC(pQMat),
1807     + meaneleC1(pQMat),
1808     c
1809     + NAtMC(pQShellC,pQMat),
1810     + NAtAC(pQShellC,pQMat),
1811     + NSheC(pQShellC,pQMat),
1812     c
1813     + flog1(pqener,pQShellC,pQMat),
1814     + flog2(pqener,pQShellC,pQMat),
1815     + cher(pqener,pQShellC,pQMat),
1816     + rezer(pqener,pQShellC,pQMat),
1817     + frezer(pqener,pQShellC,pQMat),
1818     + adda(pqener,pQShellC,pQMat),
1819     + fadda(pqener,pQShellC,pQMat),
1820     + quan(pQShellC,pQMat),
1821     + mean(pQShellC,pQMat)
1822     save / ccrosec /
1823    
1824     +KEEP,cconst.
1825     real*8 ELMAS ! Electron mass (MeV)
1826     parameter (ELMAS=0.51099906)
1827     real*8 FSCON ! Fine ctructure constant
1828     parameter (FSCON=137.0359895)
1829     real*8 ELRAD ! Electron radius (1/MeV)
1830     parameter (ELRAD=1.0/(FSCON*ELMAS))
1831     real*8 PI
1832     parameter (PI=3.14159265358979323846)
1833     real*8 PI2
1834     parameter (PI2=PI*PI)
1835     real*8 AVOGADRO
1836     parameter (AVOGADRO=6.0221367e23)
1837     real*8 PLANK ! Plank constant (J*sec)
1838     parameter (PLANK=6.6260755e-34)
1839     real*8 ELCHARGE ! Electron charge (C)
1840     parameter (ELCHARGE=1.60217733e-19)
1841     real*8 CLIGHT ! Light vel.(sm/sec)
1842     parameter (CLIGHT=2.99792458e10)
1843     c real pionener
1844     c parameter (pionener=0.000026)
1845    
1846     +KEEP,volume.
1847     c descriptions of the geometry of the setup
1848    
1849     integer pqvol ! Max. quantity of volumes
1850     parameter (pqvol=150)
1851     integer pQSVol ! Max. quantity of sensitive volumes
1852     parameter (pQSVol=130)
1853     integer pQIVol ! Max. quantity of ionization volumes
1854     parameter (pQIVol=130)
1855     integer QSVol
1856     integer QIVol
1857     integer qvol ! quantity of volumes
1858     integer upVol ! user's volume parameter
1859     integer nMatVol ! Material number for volume
1860     integer sSensit ! Sign of sensitivity
1861     integer sIonizat ! Sign of ionization
1862     real*8 wall1,wall2,wide ! Left, right side and wide of volume
1863     integer numSensVol,numVolSens ! pass from Volume number
1864     ! to Sensitive volume number
1865     integer numIoniVol,numVolIoni ! The same for ionization
1866     real RLenRVol, RLenRAVol ! Radiation lengt for each volumes
1867     ! and for whole detector.
1868     integer xxxVol ! dummy, for efficient alignment
1869     common / cvolum /
1870     + qvol,
1871     + QSVol,QIVol, xxxVol,
1872     + upVol(pqvol), nMatVol(pqvol), sSensit(pqvol),
1873     + sIonizat(pqvol),
1874     + wall1(pqvol),wall2(pqvol),wide(pqvol),
1875     + numSensVol(pqvol),numVolSens(pQSVol),
1876     + numIoniVol(pqvol),numVolIoni(pQIVol),
1877     + RLenRVol(pqvol),RLenRAVol
1878     save / cvolum /
1879     +KEEP,part.
1880     c The incoming particle.
1881     c After changing the particle you have
1882     c to recalculate crossec
1883     real tkin,mass ! Kin.energy
1884     real*8 beta2,beta12 ! Beta**2 and 1.0-Beta**2
1885     real emax ! Max. energy of delta electron
1886     real bem ! beta2/emax
1887     real coefPa ! help const
1888     c It is in energy transfer cross sections:
1889     c Alpha
1890     c ----------
1891     c beta2 * pi
1892     real partgamma ! gamma factor
1893     real partmom,partmom2 ! momentum and momentum**2
1894     integer s_pri_elec ! Sign that primary particle is electron.
1895     ! It is recognized by mass near to 0.511
1896     ! In some parts of program the direct condition
1897     ! like mass < 0.512 is used.
1898     common / cpart /
1899     + tkin,mass,
1900     + beta2,beta12,
1901     + partgamma,
1902     + partmom,partmom2,
1903     + emax,
1904     c + ecut,
1905     + bem ,
1906     + coefPa,
1907     + s_pri_elec
1908     save / cpart /
1909     +KEEP,hist.
1910    
1911    
1912     integer sHist ! Sign to fill histograms
1913     character*100 HistFile ! File name for file
1914     ! with histograms.
1915     integer HistLun ! Logical number of stream to write
1916     ! this file.
1917     parameter (HistLun=34)
1918    
1919     real maxhisampl ! maximum amplitude for histograms
1920     real maxhisample ! maximum amplitude for histograms
1921     ! in units of electrons
1922     real maxhisampl2 ! reduced maximum amplitude for histograms
1923     integer pqhisampl ! quantity for histograms with amplitude.
1924     integer pqh
1925     parameter (pqh=100) ! usual number of divisions
1926     integer pqh2
1927     parameter (pqh2=200) ! increased number of divisions
1928    
1929     integer shfillrang ! sign to fill special histogram nh2_rd
1930     ! with practical range of delta electron
1931     ! It spends some computer time.
1932     integer MaxHistQSVol
1933     parameter (MaxHistQSVol=50) ! Maximum number of volumes,
1934     ! used at initilisation of histograms.
1935     ! If the number of the sensitive volumes
1936     ! is more,
1937     ! only MaxHistQSVol histograms will be created
1938     ! and they will represent
1939     ! the first MaxHistQSVol volumes
1940     integer hQSVol ! working number -- minimum of
1941     ! MaxHistQSVol end QSVol
1942     ! Defined in Inihist
1943    
1944     c Determination of histogram numbers:
1945    
1946     c Notation nh1 is number of 1-dimension histogram
1947     c Notation nh2 is number of 2-dimension histogram
1948    
1949    
1950     integer nh1_ampK
1951     parameter (nh1_ampK=100) ! amplitude (KeV)
1952     ! Some fluctuations may be here if
1953     ! each single bin of this histogram corresponds
1954     ! to differrent numbers of bins of
1955     ! nh1_ampN histogram.
1956     integer nh1_ampKR
1957     parameter (nh1_ampKR=150) ! amplitude (KeV)
1958     ! Special treatment is applyed to smooth
1959     ! the fluctuations mentioned above.
1960     ! It increases the mean square dispersion
1961     ! on a little value sqrt(1/12)* w .
1962     integer nh1_ampN
1963     parameter (nh1_ampN=200)! amplitude in numbers of conduction electrons.
1964    
1965     integer nh1_cdx ! charge distribution along x
1966     parameter (nh1_cdx=300)
1967     integer nh1_cdy ! charge distribution along y
1968     parameter (nh1_cdy=500)
1969     integer nh1_cdz ! charge distribution along z
1970     parameter (nh1_cdz=700)
1971    
1972     integer nh2_ard ! Actual range of delta-electron(cm)
1973     parameter (nh2_ard=900) ! vs energy(MeV).
1974     integer nh2_rd ! Range along initial direction of
1975     parameter (nh2_rd=901) ! delta-electron vs energy.
1976     integer nh1_rd ! Range along initial direction of
1977     parameter (nh1_rd=902) ! delta-electron (cm).
1978    
1979     common / chist /
1980     + sHist,
1981     + maxhisampl,
1982     + maxhisample,
1983     + maxhisampl2,
1984     + pqhisampl,
1985     + shfillrang,
1986     + hQSVol
1987     save / chist /
1988     common / chhist /
1989     + HistFile
1990     save / chhist /
1991    
1992     +KEEP,random.
1993     real*8 iranfl
1994    
1995     integer sseed ! Flag to start first event
1996     ! from seed point of random number generator.
1997     real*8 rseed ! Place for seed.
1998     integer seed(2) ! Form for writting and inputting
1999     ! without modification during
2000     ! binary to demical transformation.
2001     equivalence (rseed,seed(1))
2002    
2003     common / comran /
2004     + iranfl,
2005     + rseed, sseed
2006    
2007     save / comran /
2008    
2009     +KEEP,del.
2010     c Delta electrons
2011    
2012     integer pqdel ! Max. q. of electrons
2013     parameter (pqdel=120000)
2014     integer qdel ! Q. of electrons
2015     C integer cdel ! Current electron (not used, RV 27/2/97)
2016     ! number of el. which must be treated next
2017     real veldel ! direction of the velocity
2018     real*8 pntdel ! point
2019    
2020     real zdel, edel ! charge of current electrons
2021     ! which must be produced and energy of Delta
2022     integer Stdel ! Generation number
2023     integer Ptdel ! pointer to parent virtual photon
2024     integer updel ! additional parameters
2025     integer SOdel ! 1 for ouger electrons 0 for other
2026     integer nVoldel ! Number of volume
2027     real*8 rangedel ! range
2028     real*8 rangepdel ! practical range
2029     integer qstepdel ! quantity of steps of simulation
2030     ! of stopping
2031     integer sOverflowDel ! sign of overflow in the current event
2032     integer qsOverflowDel ! quantity of the overflows in all events
2033     integer qOverflowDel ! quantity of the lossed electrons
2034     ! in all events
2035     integer ii1del ! not used. only for alingment.
2036     common / comdel /
2037     + qdel, ii1del,
2038     + pntdel(3,pqdel), veldel(3,pqdel),
2039     + rangedel(pqdel),rangepdel(pqdel), qstepdel(pqdel),
2040     + zdel(pqdel), edel(pqdel), nVoldel(pqdel),
2041     + Stdel(pqdel), Ptdel(pqdel), updel(pqup,pqdel), SOdel(pqdel),
2042     + sOverflowDel, qsOverflowDel,qOverflowDel
2043     save / comdel /
2044    
2045     +KEEP,cel.
2046     c Conductin electrons in sensitive volumes
2047     c Currently each the electron is considered as cluster
2048    
2049     integer pqcel ! Max. q of clusters
2050     parameter (pqcel=5000)
2051     c parameter (pqcel=1000000) ! If this, reduce numbers of volumes
2052     c parameter (pqcel=100000) ! If this, reduce numbers of volumes
2053     integer qcel ! Q. of clusters
2054     real*8 pntcel ! point of cluster
2055     real zcel ! charge in unit of quantity of electron
2056     ! in this cluster (now it is always 1)
2057     real szcel ! sum quantity of charge in the volume
2058     integer Ndelcel ! number of parent delta electron
2059     integer sOverflowCel ! sign of overflow in the current event
2060     integer qsOverflowCel ! quantity of the overflows in all events
2061     integer qOverflowCel ! quantity of the lossed electrons
2062     ! in all events
2063     integer sactcel ! auxiliary sing.
2064     ! It set to one if the delta-electron either
2065     ! was born in an insensitive lawer or
2066     ! after it had flied through an insensitive lawer.
2067     common / comcel /
2068     + pntcel(3,pqcel,pQSVol),
2069     + qcel(pQSVol),
2070     + zcel(pqcel,pQSVol),
2071     + szcel(pQSVol),
2072     + Ndelcel(pqcel,pQSVol),
2073     + sactcel(pqcel,pQSVol),
2074     + sOverflowCel(pQSVol), qsOverflowCel(pQSVol),qOverflowCel(pQSVol)
2075     save / comcel /
2076     +KEEP,lsgvga.
2077     c Results of ionization loss calculations
2078     c It is used only for hist filling
2079    
2080     integer pqgvga
2081     parameter (pqgvga=1000)
2082     integer qgvga,ganumat,ganumshl
2083     real esgvga,egvga,velgvga
2084     real*8 pntgvga
2085     common / clsgva /
2086     + qgvga(pQIVol),
2087     + esgvga(pQIVol),
2088     + egvga(pqgvga,pQIVol),
2089     + pntgvga(3,pqgvga,pQIVol),
2090     + velgvga(3,pqgvga,pQIVol),
2091     + ganumat(pqgvga,pQIVol),
2092     + ganumshl(pqgvga,pQIVol)
2093     save / clsgva /
2094     +KEEP,abs.
2095    
2096     c Gamma which is ready to absorb
2097     c There are two sorts of gamma
2098     c Real gamma after their absorbtion points are known and
2099     c virtual gamma from ionization loss
2100     integer pqtagam ! Max quantity of absorbtion gamma
2101     parameter (pqtagam=100000)
2102     integer qtagam, ctagam ! Full quantity and current number
2103     ! of gamma which will be treat next.
2104     ! If ctagam>qtagam then
2105     ! there is no gamma to treat.
2106     real etagam, vtagam ! Energy, and velocity
2107     ! direction of absorbtion gamma
2108     real*8 rtagam ! position of absorbtion gamma
2109     integer nVolagam ! Volume number for this point
2110     integer nAtagam,nshlagam ! Number of atom and shell
2111     ! which absorbe this photon
2112     integer Stagam ! Generation number
2113     integer upagam ! additional parameters
2114     integer sOverflowagam ! sign of overflow in the current event
2115     integer qsOverflowagam ! quantity of the overflows in all events
2116     integer qOverflowagam ! quantity of the lossed electrons
2117     ! in all events
2118    
2119     common / comabs /
2120     + qtagam, ctagam, etagam(pqtagam),
2121     + rtagam(3,pqtagam), vtagam(3,pqtagam),
2122     + nVolagam(pqtagam),nAtagam(pqtagam),nShlagam(pqtagam),
2123     + Stagam(pqtagam), upagam(pqup,pqtagam),
2124     + sOverflowagam, qsOverflowagam,qOverflowagam
2125     save / comabs /
2126     +KEEP,rga.
2127     c Real photons
2128    
2129     integer pqrga
2130     parameter (pqrga=1000)
2131     integer qrga, crga
2132     real velrga, erga
2133     real*8 pntrga
2134     integer Strga ! generation
2135     integer Ptrga ! pointer to parent
2136     integer uprga ! number of trans vol
2137     integer SFrga ! sign of fly out
2138     integer nVolrga
2139     integer sOverflowrga ! sign of overflow in the current event
2140     integer qsOverflowrga ! quantity of the overflows in all events
2141     integer qOverflowrga ! quantity of the lossed photons
2142     ! in all events
2143    
2144     common / comrga /
2145     + qrga, crga,
2146     + pntrga(3,pqrga), velrga(3,pqrga), erga(pqrga),
2147     + nVolrga(pqrga), Strga(pqrga), Ptrga(pqrga), uprga(pqup,pqrga),
2148     + SFrga(pqrga),
2149     + sOverflowrga, qsOverflowrga,qOverflowrga
2150     save / comrga /
2151     +KEEP,h1.
2152     integer qhis ! Quantity of the divisions in
2153     ! the additional histograms
2154     ! with numbers started from 30000
2155     parameter (qhis=500)
2156     real hhis ! step by coordinate
2157     real mhis ! maximal coordinate shift
2158     parameter (mhis=200.0)
2159     integer pqamp ! maximal quantity of the amplitude cuts
2160     parameter (pqamp=11)
2161     integer qamp ! real quantity of the amplitude cuts
2162     real amp
2163     real ampc ! values of the amplitude cuts
2164     integer npp ! number of events passed through cuts
2165    
2166     ! The following two arrays:
2167     ! During event processing
2168     ! pp1 - sum of the coordinates of the centers
2169     ! pp2 - sum of the square of
2170     ! the coordinates of the centers
2171     ! After the last event processed
2172     ! they become:
2173     ! pp1 - mean coordinate
2174     ! pp2 - mean square deviation
2175     real*8 pp1
2176     real*8 pp2
2177     ! The following two arrays are filled after
2178     ! the last event processed and they have the same
2179     ! meaning, but different type.
2180     ! They are intended for filling of histograms
2181     real rpp1
2182     real rpp2
2183     real prob ! probability of the clusters
2184     real meanprob ! mean number of ionization
2185     real meanvga ! mean number of the energy transfers
2186     real meanvgal ! mean energy loss, KeV
2187     integer qe
2188     common / h31 /
2189     + pp1(1000,2,pqamp), pp2(1000,2,pqamp),hhis, npp(1000,2,pqamp),
2190     + rpp1(1000,2,pqamp), rpp2(1000,2,pqamp),
2191     + amp(pqamp),ampc(pqamp),qamp,
2192     + prob(1000),meanprob,meanvga,meanvgal,
2193     + qe
2194     +KEEP,shl.
2195     integer pqschl,pqshl,pqatm,pqsel,pqsga
2196     parameter (pqschl=3) ! Max. q. of channels
2197     parameter (pqshl=7) ! Max. q. of shells
2198     parameter (pqatm=20) ! Max. q. of atoms
2199     parameter (pqsel=3) ! Max. q. of secondary electrons in
2200     ! one channel
2201     parameter (pqsga=3) ! Max. q. of secondary photons in
2202     ! one channel
2203     integer qschl,qshl,qatm,qsel,qsga
2204     real charge ! charge of atom
2205     real eshell ! energy of shells
2206     ! The distanse must be bigger the
2207     ! threshold in the atom.inc
2208     ! if secondary photons is generated
2209     real secprobch ! Probubility function for channels
2210     ! Attention!!! - Probubility function
2211     ! i.e. last channel prob must be 1
2212     real secenel ! Energies of secondary electrons
2213     real secenga ! Energies of secondary photons
2214     common / comshl /
2215     + charge(pqatm),
2216     + qschl(pqshl,pqatm),qshl(pqatm),qatm,
2217     + qsel(pqschl,pqshl,pqatm),qsga(pqschl,pqshl,pqatm),
2218     + eshell(pqshl,pqatm),secprobch(pqschl,pqshl,pqatm),
2219     + secenel(pqsel,pqschl,pqshl,pqatm),
2220     + secenga(pqsga,pqschl,pqshl,pqatm)
2221     save / comshl /
2222     +KEEP,LibAtMat.
2223     c Numbers(pointers) of atoms in atom.inc.
2224    
2225     c Since for some of them a special treatment is provided
2226     c in subroutine Iniatom and this subroutine recognize them by number,
2227     c the user must not initialize another atoms on these places,
2228     c even if subroutine AtomsByDefault is not called.
2229     c Another atoms can be initialized on free places.
2230    
2231     integer num_H
2232     integer num_H3
2233     integer num_H4
2234     integer num_He
2235     integer num_Li
2236     integer num_C
2237     integer num_C1
2238     integer num_C2
2239     integer num_C3
2240     c integer num_C4
2241     integer num_N
2242     integer num_O
2243     integer num_F
2244     integer num_Ne
2245     integer num_Al
2246     integer num_Si
2247     integer num_Ar
2248     integer num_Kr
2249     integer num_Xe
2250     parameter (num_H = 1 )
2251     parameter (num_H3 = 2 )
2252     parameter (num_H4 = 3 )
2253     parameter (num_He = 4 )
2254     parameter (num_Li = 5 )
2255     parameter (num_C = 6 )
2256     parameter (num_N = 7 )
2257     parameter (num_O = 8 )
2258     parameter (num_F = 9 )
2259     parameter (num_Ne =10 )
2260     parameter (num_Al = 11 )
2261     parameter (num_Si = 12 )
2262     parameter (num_Ar = 13 )
2263     parameter (num_Kr = 14 )
2264     parameter (num_Xe = 15 )
2265     parameter (num_C1 = 16 ) ! C in CO2
2266     parameter (num_C2 = 17 ) ! C in CF4
2267     parameter (num_C3 = 18 ) ! C in CH4
2268     *** Additions (RV 20/9/99).
2269     integer num_S
2270     parameter (num_S = 19)
2271     *** End of additions.
2272     +KEEP,shellfi.
2273     integer pqash ! Max. q. of shells
2274     parameter (pqash=7)
2275     integer zato ! Z of atom
2276     integer qash ! quantity of shells
2277     real athreshold,aweight ! threshold and weight of shells
2278     integer pqaener,qaener ! Max. and just q. of shell energy
2279     parameter (pqaener=500)
2280     real aener ! Energy
2281     real aphot ! Photoabsorbtion crossection
2282     ! for this point of energy
2283     common / cshellfi /
2284     + zato,
2285     + qash,
2286     + athreshold(pqash),aweight(pqash),
2287     + qaener(pqash),
2288     + aener(pqaener,pqash),aphot(pqaener,pqash)
2289     save / cshellfi /
2290     +KEEP,tpasc.
2291     integer pqshPas
2292     parameter (pqshPas=5)
2293     integer qshPas
2294     integer lPas
2295     real E0Pas,EthPas,ywPas,yaPas,PPas,sigma0Pas
2296     common / Pascom /
2297     + qshPas(pQAt),
2298     + lPas(pqshPas,pQAt),
2299     + E0Pas(pqshPas,pQAt),EthPas(pqshPas,pQAt),ywPas(pqshPas,pQAt),
2300     + yaPas(pqshPas,pQAt),PPas(pqshPas,pQAt),sigma0Pas(pqshPas,pQAt)
2301     save / Pascom /
2302    
2303    
2304     +KEEP,henke6.
2305     qash=2
2306    
2307     qaener(1)=10
2308     athreshold(1)=291
2309     aener(1,1)=311.7
2310     aphot(1,1)=0.839895
2311     aener(2,1)=392.4
2312     aphot(2,1)=0.49875
2313     aener(3,1)=452.2
2314     aphot(3,1)=0.35112
2315     aener(4,1)=676.8
2316     aphot(4,1)=0.127082
2317     aener(5,1)=776.2
2318     aphot(5,1)=0.0887775
2319     aener(6,1)=1011.7
2320     aphot(6,1)=0.0428925
2321     aener(7,1)=2984.3
2322     aphot(7,1)=0.00183341
2323     aener(8,1)=5414.7
2324     aphot(8,1)=0.000293265
2325     aener(9,1)=9886.4
2326     aphot(9,1)=4.2693e-05
2327     aener(10,1)=29779
2328     aphot(10,1)=1.04339e-06
2329    
2330     qaener(2)=13
2331     athreshold(2)=8.9
2332     aener(1,2)=10.2
2333     aphot(1,2)=5.9052
2334     aener(2,2)=13
2335     aphot(2,2)=11.97
2336     aener(3,2)=15
2337     aphot(3,2)=13.965
2338     aener(4,2)=21.2
2339     aphot(4,2)=12.0299
2340     aener(5,2)=30.5
2341     aphot(5,2)=6.00495
2342     aener(6,2)=49.3
2343     aphot(6,2)=2.0349
2344     aener(7,2)=72.4
2345     aphot(7,2)=0.96558
2346     aener(8,2)=108.5
2347     aphot(8,2)=0.408975
2348     aener(9,2)=114
2349     aphot(9,2)=0.369075
2350     aener(10,2)=132.8
2351     aphot(10,2)=0.265335
2352     aener(11,2)=192.6
2353     aphot(11,2)=0.112119
2354     aener(12,2)=220.1
2355     aphot(12,2)=0.0776055
2356     aener(13,2)=277
2357     aphot(13,2)=0.039102
2358     +KEEP,track.
2359     c The track information about the primary particle
2360    
2361     integer sign_ang ! sign to run the part. with effective angle
2362     real ang ! teta
2363     real phiang ! phi
2364     real ystart ! start Y coordinate
2365     integer srandtrack ! sign to randomize the Y coordinate
2366     ! between ystart1 and ystart2
2367     ! It is done by call IniNTrack from GoEvent
2368     ! if the track initialization was done by
2369     ! call IniRTrack
2370     real ystart1
2371     real ystart2
2372     real sigmaang ! sigma of begin angle distribution
2373     !Currently, if sigmaang>0, the rundomization
2374     ! is doing around the 0 angle.
2375     ! So the values of pang and pphiang are ignored
2376     ! It can be changed by modernization
2377     ! of IniNTrack
2378     real e1ang,e2ang,e3ang ! coordinates of new orts in the old
2379     integer sigmtk ! sign of multiple scatering
2380     integer pQmtk ! max. quantity of the break point of the track
2381     ! plus one
2382     parameter (pQmtk=10000)
2383     integer Qmtk ! actual quantity for current event
2384     real*8 pntmtk ! break point coordinates
2385     real velmtk ! directions of velocity
2386     real*8 lenmtk ! lengt of way for straight till next break
2387     real Tetamtk ! turn angle
2388     integer nVolmtk ! number of volume for given point,
2389     ! the point on the frantier is correspond
2390     ! to next volume of zero for end.
2391     real*8 vlenmtk ! lengt of way inside the volume
2392     integer nmtkvol1,nmtkvol2 ! numbers of first point in volume
2393     ! and the previous for end point
2394     real*8 xdvmtk,ydvmtk ! deviations from strate line
2395     ! using only for histograms
2396    
2397     ! service data. They are using at initialization of the track.
2398     integer sruthmtk ! key to use Rutherford cross section
2399     integer nmtk ! current number of point.
2400     ! After initialization it must be equal to Qmtk+1
2401     integer sgnmtk ! sign to go to next volume
2402     integer sturnmtk ! sign to turn
2403     real*8 lammtk ! mean free path
2404     real mlammtk ! minimum mean lengt of range
2405     ! multiplied by density. sm*gr/sm**3 = gr/sm**2
2406     real mTetacmtk ! minimum threshold turn angle
2407     real Tetacmtk ! threshold turn angle
2408     real rTetacmtk ! restiction due to atomic shell
2409     real*8 CosTetac12mtk ! cos(tetac/2)
2410     real*8 SinTetac12mtk ! sin(tetac/2)
2411     c real CosTetac12mtk ! cos(tetac/2)
2412     c real SinTetac12mtk ! sin(tetac/2)
2413     real msigmtk ! msig without sqrt(x)
2414     real e1mtk,e2mtk,e3mtk
2415     common / ctrack /
2416     + sign_ang, ang, phiang, ystart, srandtrack, ystart1, ystart2,
2417     + e1ang(3),e2ang(3),e3ang(3),
2418     + sigmtk,
2419     + sruthmtk,
2420     + Qmtk, nmtk,
2421     + pntmtk(3,pQmtk), velmtk(3,pQmtk), lenmtk(pQmtk), Tetamtk(pQmtk),
2422     + nVolmtk(pQmtk), vlenmtk(pQVol),
2423     + nmtkvol1(pQVol), nmtkvol2(pQVol),
2424     + xdvmtk(pQSVol),ydvmtk(pQSVol),
2425     + sgnmtk, sturnmtk,
2426     + lammtk(pQMat), mlammtk, mTetacmtk,
2427     + Tetacmtk(pQMat),
2428     + rTetacmtk(pQMat),
2429     + CosTetac12mtk(pQMat), SinTetac12mtk(pQMat), msigmtk,
2430     + e1mtk(3,pQmtk),e2mtk(3,pQmtk),e3mtk(3,pQmtk),
2431     + sigmaang
2432     save / ctrack /
2433     +KEEP,raffle.
2434     integer pQGRaf ! Max. quantity of energy transfer
2435     parameter (pQGRaf=10000)
2436     integer QGRaf ! Quantity of energy transfers
2437     integer NAtGRaf,NShAtGRaf ! Numbers of atom and shell
2438     real ESGRaf,EGRaf ! Cumulative energy and just energy
2439     real pntraf,velraf
2440    
2441     common / craffle /
2442     + QGRaf,
2443     + ESGRaf,
2444     + EGRaf(pQGRaf),
2445     + NAtGRaf(pQGRaf),
2446     + NShAtGRaf(pQGRaf) ,
2447     + pntraf(3,pQGRaf), velraf(3,pQGRaf)
2448    
2449    
2450     save / craffle /
2451     +KEEP,bdel.
2452     c Information about tracing of current delta-electron
2453     c
2454    
2455     real eMinBdel ! some condition step by energy
2456     ! (the name is obsolete)
2457     ! If step is larger than eMinBdel and 0.1*eBdel
2458     ! the step is equate to 0.1*eBdel
2459     ! In this case step can not be less than eMinBdel
2460     ! and larger than eBdel
2461     integer iMinBdel ! not using now
2462     real eLossBdel ! array with energy loss for
2463     ! all the matters
2464     real betaBdel
2465     real beta2Bdel
2466     real momentumBdel
2467     real momentum2Bdel
2468     real*8 lamaBdel
2469     real msigBdel
2470     integer nBdel ! number of the delta-electron
2471     ! in the del.inc, which is
2472     ! traced now
2473     real eBdel ! the current energy
2474     real*8 pntBdel,npntBdel ! current point and next point
2475     ! Next is calc. in
2476     ! subroutine SstepBdel
2477     ! and moved to current in
2478     ! subroutine treatdel
2479     real*8 stepBdel ! step - sm
2480     real estepBdel ! and MeV
2481     real velBdel ! direction of the velocity
2482     real e1Bdel, e2Bdel, e3Bdel ! coordinate axises,
2483     ! e3Bdel is along to velocity
2484     ! e2Bdel is perpend. to e3Bdel and x
2485     ! e1Bdel is perpend to e2Bdel and e3Bdel
2486     integer nVolBdel,sgonextBdel ! number of current volume
2487     ! and sign to go to next volume
2488     integer sturnBdel ! sign of turn
2489     real TetacBdel,TetaBdel ! threshold turn angle and
2490     ! actual angle
2491     real CosTetac12Bdel,SinTetac12Bdel
2492     real rTetacBdel ! restiction due to atomic shell
2493     real*8 lamBdel ! mean lengt of range
2494     real mlamBdel ! minimum mean lengt of range
2495     ! multiplied by density. sm*gr/sm**3 = gr/sm**2
2496     real mTetacBdel ! minimum threshold turn angle
2497     ! For Rutherford:
2498     ! The interactions with less angle will not take
2499     ! into account. The actual threshold angle can be
2500     ! larger. The second restriction is going
2501     ! from restriction of atomic shell.
2502     ! The third one is from mlamBdel.
2503     ! For usial multiple scatering:
2504     ! Assuming that sigma = mTetacBdel
2505     ! the paht lengt is calculating.
2506     ! If mlamBdel/density is less then the last is using.
2507     integer iBdel ! index of current energy
2508     ! in the enerc array
2509     integer StBdel ! Origin and generation sign
2510     ! <10000 - origin is ionization loss
2511     ! >=10000 - origin is transition radiation
2512     ! 1 or 10000 first generation
2513     ! 2 or 10001 second generation
2514     ! 3 or 10002 third, et al.
2515     integer NtvBdel ! Only for transition gammas:
2516     ! number of transition volume, where it was born
2517     integer SOBdel ! 1 for ouger electrons 0 for other
2518    
2519     real*8 rangBdel ! whole delta-electron range
2520     real*8 rangpBdel ! mean projection of delta-electron range
2521     ! The maximum projection lengt of
2522     ! current electron point on the
2523     ! primary velocity.
2524     integer sruthBdel ! sign of use
2525     ! 1 - Rutherford cross-section
2526     ! 0 - usial multiple scatering formula
2527     integer sisferBdel ! sign that the mean or the cut turn angle
2528     ! is so big that there are no sense to turn
2529     ! the particle. Insterd that the sferical simmetric
2530     ! velocity is genegating. It is much more faster.
2531     integer sisferaBdel
2532     real cuteneBdel
2533     integer nstepBdel
2534     parameter (cuteneBdel=1.0e-3)
2535     common / cbdel /
2536     + lamaBdel(pqener,pQMat),
2537     + pntBdel(3),npntBdel(3),
2538     + stepBdel, lamBdel,
2539     + rangBdel,rangpBdel,
2540     + eMinBdel, iMinBdel,
2541     + eLossBdel(pqener,pQMat),
2542     + betaBdel(pqener), beta2Bdel(pqener),
2543     + momentumBdel(pqener), momentum2Bdel(pqener),
2544     + msigBdel(pqener),
2545     + rTetacBdel(pqener,pQMat),
2546     + nBdel,eBdel,
2547     + estepBdel,
2548     + velBdel(3),
2549     + e1Bdel(3),e2Bdel(3),e3Bdel(3),
2550     + nVolBdel,sgonextBdel,sturnBdel,
2551     + TetacBdel(pqener,pQMat),
2552     + CosTetac12Bdel(pqener,pQMat),
2553     + SinTetac12Bdel(pqener,pQMat),
2554     + TetaBdel,
2555     + mlamBdel,mTetacBdel,
2556     + iBdel,
2557     + StBdel,NtvBdel,SOBdel,
2558     + sruthBdel,
2559     + sisferBdel,
2560     + sisferaBdel(pqener,pQMat),
2561     + nstepBdel
2562     save / cbdel /
2563    
2564     c below there are the values for exact elastic
2565     c scatering
2566     integer pqanCBdel
2567     parameter (pqanCBdel=31)
2568     integer qanCBdel
2569     parameter (qanCBdel=30)
2570     real anCBdel
2571     real ancCBdel
2572    
2573     integer pqeaCBdel
2574     parameter (pqeaCBdel=10)
2575     integer qeaCBdel
2576     parameter (qeaCBdel=9)
2577     real enerCBdel, enercCBdel
2578     real sign_ACBdel ! sign that the parameters are read
2579     real ACBdel ! parameters
2580     real CCBdel
2581     real BCBdel
2582     real sCBdel ! cross section, Angstrem**2 / strd
2583     real sRCBdel ! Rutherford cross section for comparison
2584     real sRmCBdel ! maximum of Rutherford die to cut
2585     real sRcmCBdel ! the cut angle again
2586     real smaCBdel ! cross section for material per one av. atom,
2587     ! in MeV**-2/rad
2588     real smatCBdel ! cross section for material per one av. atom,
2589     ! in MeV**-2/rad, for working energy mesh
2590     real ismatCBdel ! normalized integral
2591     real tsmatCBdel ! integral
2592     real gammaCBdel
2593     real beta2CBdel
2594     real momentum2CBdel
2595     real rrCBdel ! range by usual formula
2596     real koefredCBdel ! koef for derivation of step
2597     ! from usual formula
2598     parameter (koefredCBdel=0.02)
2599     common / cbdel1 /
2600     + anCBdel(pqanCBdel), ancCBdel(pqanCBdel),
2601     + enerCBdel(pqeaCBdel), enercCBdel(pqeaCBdel),
2602     + sign_ACBdel(pqAt),
2603     + ACBdel(4,pqeaCBdel,pqAt), CCBdel(0:6,pqeaCBdel,pqAt),
2604     + BCBdel(pqeaCBdel,pqAt),
2605     + sCBdel(pqanCBdel,pqeaCBdel,pqAt),
2606     + sRCBdel(pqanCBdel,pqeaCBdel,pqAt),
2607     + sRmCBdel(pqeaCBdel,pqAt),
2608     + sRcmCBdel(pqeaCBdel,pqAt),
2609     + smaCBdel(pqanCBdel,pqeaCBdel,pQMat),
2610     + smatCBdel(pqanCBdel,pqener,pQMat),
2611     + ismatCBdel(pqanCBdel,pqener,pQMat),
2612     + tsmatCBdel(pqener,pQMat),
2613     + gammaCBdel(pqeaCBdel), beta2CBdel(pqeaCBdel),
2614     + momentum2CBdel(pqeaCBdel),
2615     + rrCBdel(pqener,pQMat)
2616     save / cbdel1 /
2617    
2618     real MagForFBdel
2619     real EleForFBdel
2620     real veloBdel
2621     common / cbdel2 /
2622     + MagForFBdel(3), EleForFBdel(3),
2623     + veloBdel(3)
2624     save / cbdel2 /
2625    
2626    
2627    
2628    
2629     +KEEP,cbdeldat.
2630     data ZsCBdel(1)/ 1 /
2631     data (AsCBdel( 1 , i, 1 ),i=1,9)/
2632     + -0.9007, -0.6539, -0.3655, -0.5499, -0.0196,
2633     + 0.04526, -0.658, 0.008393, -0.3739 /
2634     data (AsCBdel( 2 , i, 1 ),i=1,9)/
2635     + 0.3975, 0.338, 0.2884, 0.3151, 0.2809,
2636     + 0.2774, 0.3126, 0.2787, 0.2928 /
2637     data (AsCBdel( 3 , i, 1 ),i=1,9)/
2638     + 0.002344, 0.003208, 0.00294, 0.001429, 0.0009329,
2639     + 0.00041, 3.017e-05, 0.0001038, 1.757e-05 /
2640     data (AsCBdel( 4 , i, 1 ),i=1,9)/
2641     + -3.534e-05, -1.59e-05, -5.392e-06, 9.522e-06, 8.538e-07,
2642     + -4.278e-08, 7.506e-07, 4.492e-09, 3.551e-08 /
2643     data (CsCBdel( 0 , i, 1 ),i=1,9)/
2644     + 1.105, 0.8986, 0.6487, 0.8062, 0.01901,
2645     + -0.09682, 0.9669, -0.1011, 0.4769 /
2646     data (CsCBdel( 1 , i, 1 ),i=1,9)/
2647     + 1.172, 1.05, 0.9256, 0.9955, 0.02643,
2648     + -0.1263, 1.229, -0.141, 0.6287 /
2649     data (CsCBdel( 2 , i, 1 ),i=1,9)/
2650     + 0.7611, 0.7519, 0.8045, 0.751, 0.02258,
2651     + -0.1017, 0.9513, -0.1224, 0.5042 /
2652     data (CsCBdel( 3 , i, 1 ),i=1,9)/
2653     + 0.4001, 0.4377, 0.5676, 0.4597, 0.01605,
2654     + -0.06736, 0.5969, -0.08834, 0.3282 /
2655     data (CsCBdel( 4 , i, 1 ),i=1,9)/
2656     + 0.1718, 0.2092, 0.3277, 0.2304, 0.009861,
2657     + -0.03748, 0.3072, -0.05421, 0.176 /
2658     data (CsCBdel( 5 , i, 1 ),i=1,9)/
2659     + 0.05558, 0.07568, 0.1426, 0.08723, 0.004891,
2660     + -0.0164, 0.1202, -0.02652, 0.07261 /
2661     data (CsCBdel( 6 , i, 1 ),i=1,9)/
2662     + 0.01031, 0.01571, 0.03491, 0.01878, 0.00171,
2663     + -0.004697, 0.02774, -0.008267, 0.0182 /
2664     data (BsCBdel( i, 1 ),i=1,9)/
2665     + 0.008057, 0.004506, 0.002592, 0.001872, 0.0008431,
2666     + 0.0003444, 0.0003049, 8.926e-05, 6.648e-05 /
2667     data ZsCBdel(2)/ 2 /
2668     data (AsCBdel( 1 , i, 2 ),i=1,9)/
2669     + 0.0327, -0.4242, -0.6746, -0.6343, -0.2289,
2670     + -0.3277, -0.2001, -1.227, -0.3022 /
2671     data (AsCBdel( 2 , i, 2 ),i=1,9)/
2672     + 0.3427, 0.3746, 0.363, 0.3388, 0.2998,
2673     + 0.298, 0.2891, 0.3407, 0.2914 /
2674     data (AsCBdel( 3 , i, 2 ),i=1,9)/
2675     + -0.00727, -0.002397, -0.001851, -0.0009558, 0.001271,
2676     + 0.0006719, 0.000343, -9.27e-05, 7.883e-05 /
2677     data (AsCBdel( 4 , i, 2 ),i=1,9)/
2678     + 5.556e-05, 2.941e-06, 3.477e-06, 9.459e-07, 1.384e-11,
2679     + 1.73e-07, -7.566e-14, 6.887e-07, 4.899e-08 /
2680     data (CsCBdel( 0 , i, 2 ),i=1,9)/
2681     + -0.09725, 0.4519, 0.8681, 0.8734, 0.3088,
2682     + 0.4817, 0.2759, 1.81, 0.3546 /
2683     data (CsCBdel( 1 , i, 2 ),i=1,9)/
2684     + -0.1434, 0.4205, 0.9635, 1.028, 0.3654,
2685     + 0.6172, 0.3678, 2.294, 0.4574 /
2686     data (CsCBdel( 2 , i, 2 ),i=1,9)/
2687     + -0.1141, 0.2335, 0.6551, 0.7411, 0.2638,
2688     + 0.4836, 0.3015, 1.763, 0.3535 /
2689     data (CsCBdel( 3 , i, 2 ),i=1,9)/
2690     + -0.06887, 0.1, 0.3606, 0.4342, 0.1544,
2691     + 0.3089, 0.2039, 1.09, 0.2158 /
2692     data (CsCBdel( 4 , i, 2 ),i=1,9)/
2693     + -0.03233, 0.03143, 0.1606, 0.2074, 0.07401,
2694     + 0.1633, 0.1164, 0.5456, 0.1024 /
2695     data (CsCBdel( 5 , i, 2 ),i=1,9)/
2696     + -0.01082, 0.00537, 0.05227, 0.0725, 0.0269,
2697     + 0.0664, 0.05306, 0.2027, 0.0328 /
2698     data (CsCBdel( 6 , i, 2 ),i=1,9)/
2699     + -0.00182, -0.000404, 0.008547, 0.01166, 0.005736,
2700     + 0.01634, 0.01557, 0.04167, 0.006162 /
2701     data (BsCBdel( i, 2 ),i=1,9)/
2702     + 0.01206, 0.007727, 0.00318, 0.001359, 0.001657,
2703     + 0.0008551, 0.0004051, 0.0003179, 0.0001234 /
2704     data ZsCBdel(3)/ 3 /
2705     data (AsCBdel( 1 , i, 3 ),i=1,9)/
2706     + 1.427, 1.875, 1.99, 1.699, 1.07,
2707     + 0.6406, -0.4004, -0.3638, -1.191 /
2708     data (AsCBdel( 2 , i, 3 ),i=1,9)/
2709     + 0.05527, 0.09522, 0.1452, 0.1939, 0.2375,
2710     + 0.2604, 0.3007, 0.2984, 0.3292 /
2711     data (AsCBdel( 3 , i, 3 ),i=1,9)/
2712     + -0.0002502, -0.0006965, -0.0008232, -0.000703, -0.0005227,
2713     + -0.0003072, -0.0002339, -0.0001217, -0.0001381 /
2714     data (AsCBdel( 4 , i, 3 ),i=1,9)/
2715     + 2.705e-05, 1.05e-05, 4.396e-06, 1.701e-06, 6.296e-07,
2716     + 1.826e-07, 7.576e-08, 2.354e-08, 3.617e-08 /
2717     data (CsCBdel( 0 , i, 3 ),i=1,9)/
2718     + -1.541, -2.386, -2.805, -2.555, -1.683,
2719     + -1.062, 0.5774, 0.4788, 1.77 /
2720     data (CsCBdel( 1 , i, 3 ),i=1,9)/
2721     + -1.472, -2.601, -3.317, -3.176, -2.153,
2722     + -1.397, 0.7406, 0.6022, 2.303 /
2723     data (CsCBdel( 2 , i, 3 ),i=1,9)/
2724     + -0.8666, -1.737, -2.391, -2.401, -1.672,
2725     + -1.115, 0.5758, 0.4548, 1.815 /
2726     data (CsCBdel( 3 , i, 3 ),i=1,9)/
2727     + -0.4155, -0.9407, -1.395, -1.469, -1.047,
2728     + -0.718, 0.3605, 0.2727, 1.152 /
2729     data (CsCBdel( 4 , i, 3 ),i=1,9)/
2730     + -0.1638, -0.4176, -0.6643, -0.7343, -0.5343,
2731     + -0.3768, 0.1825, 0.1288, 0.5931 /
2732     data (CsCBdel( 5 , i, 3 ),i=1,9)/
2733     + -0.04905, -0.1403, -0.2385, -0.2776, -0.2048,
2734     + -0.1487, 0.06829, 0.04247, 0.2284 /
2735     data (CsCBdel( 6 , i, 3 ),i=1,9)/
2736     + -0.00851, -0.02708, -0.04885, -0.06059, -0.04461,
2737     + -0.03362, 0.01358, 0.006216, 0.05031 /
2738     data (BsCBdel( i, 3 ),i=1,9)/
2739     + 0.004125, 0.002188, 0.001189, 0.0006433, 0.000348,
2740     + 0.0001781, 9.893e-05, 5.406e-05, 5.406e-05 /
2741     data ZsCBdel(4)/ 6 /
2742     data (AsCBdel( 1 , i, 4 ),i=1,9)/
2743     + -0.2288, -0.158, -0.002296, 0.1188, -0.113,
2744     + -0.1099, -0.2114, -0.321, -0.3712 /
2745     data (AsCBdel( 2 , i, 4 ),i=1,9)/
2746     + 0.1755, 0.1774, 0.1813, 0.1927, 0.2573,
2747     + 0.2617, 0.2751, 0.2829, 0.286 /
2748     data (AsCBdel( 3 , i, 4 ),i=1,9)/
2749     + -0.000567, 0.001007, 0.0005522, -0.0002222, -0.0006304,
2750     + -0.0003796, -0.0002618, -0.0001435, -7.271e-05 /
2751     data (AsCBdel( 4 , i, 4 ),i=1,9)/
2752     + -2.822e-06, -6.323e-06, -1.751e-06, 8.23e-08, 7.391e-06,
2753     + 2.077e-06, 6.244e-07, 1.488e-07, 3.304e-08 /
2754     data (CsCBdel( 0 , i, 4 ),i=1,9)/
2755     + 0.5481, 0.5514, 0.4277, 0.2874, 0.4173,
2756     + 0.4084, 0.4764, 0.5723, 0.5971 /
2757     data (CsCBdel( 1 , i, 4 ),i=1,9)/
2758     + 0.7001, 0.8468, 0.8727, 0.8116, 0.7996,
2759     + 0.8204, 0.8368, 0.9077, 0.9267 /
2760     data (CsCBdel( 2 , i, 4 ),i=1,9)/
2761     + 0.5164, 0.6987, 0.8691, 0.9514, 0.8364,
2762     + 0.9003, 0.8566, 0.8596, 0.8603 /
2763     data (CsCBdel( 3 , i, 4 ),i=1,9)/
2764     + 0.3055, 0.4423, 0.6429, 0.7965, 0.6723,
2765     + 0.7587, 0.695, 0.6525, 0.6395 /
2766     data (CsCBdel( 4 , i, 4 ),i=1,9)/
2767     + 0.1493, 0.2224, 0.3722, 0.5125, 0.4275,
2768     + 0.5034, 0.4532, 0.3989, 0.381 /
2769     data (CsCBdel( 5 , i, 4 ),i=1,9)/
2770     + 0.05661, 0.08288, 0.1587, 0.2398, 0.2002,
2771     + 0.2435, 0.2194, 0.1783, 0.1645 /
2772     data (CsCBdel( 6 , i, 4 ),i=1,9)/
2773     + 0.01273, 0.01736, 0.03764, 0.06171, 0.05196,
2774     + 0.06335, 0.05949, 0.04171, 0.0395 /
2775     data (BsCBdel( i, 4 ),i=1,9)/
2776     + 0.005592, 0.003821, 0.0019, 0.0004467, 0.00118,
2777     + 0.0005983, 0.0003049, 0.0001453, 6.647e-05 /
2778     data ZsCBdel(5)/ 7 /
2779     data (AsCBdel( 1 , i, 5 ),i=1,9)/
2780     + -0.2683, -0.1095, -0.2076, 1.155, 1.192,
2781     + 1.083, 0.6177, 0.6945, 0.1072 /
2782     data (AsCBdel( 2 , i, 5 ),i=1,9)/
2783     + 0.1794, 0.1917, 0.2207, 0.1476, 0.1849,
2784     + 0.2177, 0.2517, 0.2517, 0.2784 /
2785     data (AsCBdel( 3 , i, 5 ),i=1,9)/
2786     + -0.002106, -0.001189, 0.001094, 0.001768, 0.0006366,
2787     + 0.0001047, -0.0001064, -1.845e-05, -5.791e-05 /
2788     data (AsCBdel( 4 , i, 5 ),i=1,9)/
2789     + 8.363e-06, 2.424e-06, 6.217e-05, 4.937e-07, 3.26e-06,
2790     + 1.638e-06, 7.072e-07, 8.12e-08, 4.488e-08 /
2791     data (CsCBdel( 0 , i, 5 ),i=1,9)/
2792     + 0.587, 0.3883, 0.5649, -1.409, -1.614,
2793     + -1.596, -0.9572, -1.143, -0.2718 /
2794     data (CsCBdel( 1 , i, 5 ),i=1,9)/
2795     + 0.7239, 0.5554, 0.865, -1.48, -1.836,
2796     + -1.934, -1.17, -1.441, -0.327 /
2797     data (CsCBdel( 2 , i, 5 ),i=1,9)/
2798     + 0.5231, 0.4279, 0.73, -0.9541, -1.274,
2799     + -1.429, -0.8647, -1.105, -0.2408 /
2800     data (CsCBdel( 3 , i, 5 ),i=1,9)/
2801     + 0.2991, 0.2539, 0.4765, -0.4998, -0.7137,
2802     + -0.8552, -0.5104, -0.6825, -0.1421 /
2803     data (CsCBdel( 4 , i, 5 ),i=1,9)/
2804     + 0.1378, 0.1199, 0.2486, -0.2148, -0.3255,
2805     + -0.419, -0.2401, -0.3423, -0.06744 /
2806     data (CsCBdel( 5 , i, 5 ),i=1,9)/
2807     + 0.0478, 0.04201, 0.09691, -0.06986, -0.1112,
2808     + -0.1557, -0.08076, -0.1293, -0.02457 /
2809     data (CsCBdel( 6 , i, 5 ),i=1,9)/
2810     + 0.00979, 0.008339, 0.02151, -0.01307, -0.02128,
2811     + -0.03377, -0.01323, -0.02937, -0.006507 /
2812     data (BsCBdel( i, 5 ),i=1,9)/
2813     + 0.005535, 0.002575, 0.005228, 0.002104, 0.00129,
2814     + 0.0007012, 0.0003761, 0.0001529, 8.43e-05 /
2815     data ZsCBdel(6)/ 8 /
2816     data (AsCBdel( 1 , i, 6 ),i=1,9)/
2817     + -0.3151, -0.4143, -0.3378, 0.775, 1.151,
2818     + 1.043, 0.8495, 0.6484, 0.6268 /
2819     data (AsCBdel( 2 , i, 6 ),i=1,9)/
2820     + 0.1565, 0.2123, 0.228, 0.1668, 0.1769,
2821     + 0.2119, 0.2388, 0.2526, 0.2555 /
2822     data (AsCBdel( 3 , i, 6 ),i=1,9)/
2823     + 0.005179, 0.0008074, 0.002091, 0.00213, 0.001118,
2824     + 0.0003669, 5.394e-05, 5.051e-06, 1.052e-05 /
2825     data (AsCBdel( 4 , i, 6 ),i=1,9)/
2826     + -7.102e-05, -1.079e-05, 5.928e-05, 6.685e-12, 7.192e-07,
2827     + 1.642e-06, 7.253e-07, 1.528e-07, 1.002e-08 /
2828     data (CsCBdel( 0 , i, 6 ),i=1,9)/
2829     + 0.6907, 0.8183, 0.7333, -0.8508, -1.514,
2830     + -1.489, -1.311, -1.053, -1.081 /
2831     data (CsCBdel( 1 , i, 6 ),i=1,9)/
2832     + 0.8607, 1.068, 1.04, -0.8104, -1.685,
2833     + -1.755, -1.622, -1.305, -1.363 /
2834     data (CsCBdel( 2 , i, 6 ),i=1,9)/
2835     + 0.6281, 0.8144, 0.8428, -0.4708, -1.148,
2836     + -1.259, -1.224, -0.9807, -1.045 /
2837     data (CsCBdel( 3 , i, 6 ),i=1,9)/
2838     + 0.3597, 0.4966, 0.5392, -0.2198, -0.6336,
2839     + -0.728, -0.7484, -0.5893, -0.6437 /
2840     data (CsCBdel( 4 , i, 6 ),i=1,9)/
2841     + 0.1652, 0.2472, 0.28, -0.08269, -0.2864,
2842     + -0.3417, -0.3747, -0.2827, -0.3206 /
2843     data (CsCBdel( 5 , i, 6 ),i=1,9)/
2844     + 0.05686, 0.09356, 0.11, -0.02291, -0.09803,
2845     + -0.1195, -0.1422, -0.09731, -0.1192 /
2846     data (CsCBdel( 6 , i, 6 ),i=1,9)/
2847     + 0.01108, 0.02049, 0.02459, -0.003431, -0.01939,
2848     + -0.02313, -0.03158, -0.01668, -0.02626 /
2849     data (BsCBdel( i, 6 ),i=1,9)/
2850     + 0.01527, 0.006677, 0.006234, 0.002632, 0.001398,
2851     + 0.0008426, 0.0004476, 0.0002062, 7.411e-05 /
2852     data ZsCBdel(7)/ 9 /
2853     data (AsCBdel( 1 , i, 7 ),i=1,9)/
2854     + -0.271, -0.1705, -0.4203, -0.08103, 0.847,
2855     + 1.032, 0.9064, 0.737, 0.7296 /
2856     data (AsCBdel( 2 , i, 7 ),i=1,9)/
2857     + 0.06297, 0.1982, 0.2525, 0.2293, 0.1892,
2858     + 0.2059, 0.2323, 0.247, 0.251 /
2859     data (AsCBdel( 3 , i, 7 ),i=1,9)/
2860     + 0.0192, -0.001907, 0.001649, -0.0005853, 0.001314,
2861     + 0.0006477, 0.0002021, 6.899e-05, 2.812e-05 /
2862     data (AsCBdel( 4 , i, 7 ),i=1,9)/
2863     + -1.458e-05, 6.353e-06, 0.0001059, 4.938e-07, 1.198e-13,
2864     + 1e-06, 7.184e-07, 1.568e-07, 3.663e-09 /
2865     data (CsCBdel( 0 , i, 7 ),i=1,9)/
2866     + 0.8256, 0.4602, 0.7589, 0.3443, -1.043,
2867     + -1.44, -1.373, -1.174, -1.261 /
2868     data (CsCBdel( 1 , i, 7 ),i=1,9)/
2869     + 1.154, 0.6192, 0.9765, 0.5852, -1.093,
2870     + -1.665, -1.676, -1.445, -1.601 /
2871     data (CsCBdel( 2 , i, 7 ),i=1,9)/
2872     + 0.92, 0.4733, 0.7312, 0.5192, -0.6998,
2873     + -1.174, -1.249, -1.08, -1.243 /
2874     data (CsCBdel( 3 , i, 7 ),i=1,9)/
2875     + 0.5763, 0.2837, 0.4353, 0.3475, -0.3624,
2876     + -0.6677, -0.7544, -0.6459, -0.7811 /
2877     data (CsCBdel( 4 , i, 7 ),i=1,9)/
2878     + 0.2949, 0.1363, 0.2107, 0.1826, -0.1537,
2879     + -0.3085, -0.3728, -0.309, -0.3993 /
2880     data (CsCBdel( 5 , i, 7 ),i=1,9)/
2881     + 0.1166, 0.04879, 0.07714, 0.07063, -0.04901,
2882     + -0.1063, -0.1396, -0.1066, -0.1488 /
2883     data (CsCBdel( 6 , i, 7 ),i=1,9)/
2884     + 0.0272, 0.009832, 0.01628, 0.01543, -0.009001,
2885     + -0.02032, -0.0305, -0.01865, -0.03074 /
2886     data (BsCBdel( i, 7 ),i=1,9)/
2887     + 0.02583, 0.004772, 0.007849, 0.001104, 0.001634,
2888     + 0.0009459, 0.0005241, 0.0002429, 7.913e-05 /
2889     data ZsCBdel(8)/ 13 /
2890     data (AsCBdel( 1 , i, 8 ),i=1,9)/
2891     + -0.4378, -0.3167, -0.2708, -0.212, -0.2487,
2892     + -0.2509, -0.234, -0.265, -0.2887 /
2893     data (AsCBdel( 2 , i, 8 ),i=1,9)/
2894     + 0.0923, 0.1454, 0.1968, 0.2238, 0.244,
2895     + 0.2547, 0.2598, 0.2632, 0.2677 /
2896     data (AsCBdel( 3 , i, 8 ),i=1,9)/
2897     + -0.001988, -0.003033, -0.00252, -0.001545, -0.0008717,
2898     + -0.0004561, -0.0002297, -0.0001108, -5.184e-05 /
2899     data (AsCBdel( 4 , i, 8 ),i=1,9)/
2900     + 3.912e-05, 3.749e-05, 1.642e-05, 5.325e-06, 1.526e-06,
2901     + 3.975e-07, 9.745e-08, 2.235e-08, 4.724e-09 /
2902     data (CsCBdel( 0 , i, 8 ),i=1,9)/
2903     + 0.9154, 0.7984, 0.7195, 0.6202, 0.6319,
2904     + 0.6121, 0.571, 0.5794, 0.5696 /
2905     data (CsCBdel( 1 , i, 8 ),i=1,9)/
2906     + 1.089, 1.079, 1.064, 1.001, 1.008,
2907     + 0.9975, 0.9718, 0.9775, 0.9695 /
2908     data (CsCBdel( 2 , i, 8 ),i=1,9)/
2909     + 0.8455, 0.8439, 0.8883, 0.9071, 0.9025,
2910     + 0.9105, 0.9213, 0.9188, 0.9192 /
2911     data (CsCBdel( 3 , i, 8 ),i=1,9)/
2912     + 0.5493, 0.5267, 0.5759, 0.645, 0.6283,
2913     + 0.6424, 0.6721, 0.6653, 0.6698 /
2914     data (CsCBdel( 4 , i, 8 ),i=1,9)/
2915     + 0.3033, 0.2718, 0.2962, 0.3698, 0.3493,
2916     + 0.3588, 0.3856, 0.3802, 0.3813 /
2917     data (CsCBdel( 5 , i, 8 ),i=1,9)/
2918     + 0.1342, 0.1092, 0.1121, 0.1589, 0.1442,
2919     + 0.1474, 0.1612, 0.1593, 0.1552 /
2920     data (CsCBdel( 6 , i, 8 ),i=1,9)/
2921     + 0.03585, 0.02589, 0.02376, 0.03845, 0.03347,
2922     + 0.03359, 0.0368, 0.03715, 0.03315 /
2923     data (BsCBdel( i, 8 ),i=1,9)/
2924     + 0.006753, 0.004403, 0.002434, 0.001282, 0.0006546,
2925     + 0.0003271, 0.0001599, 7.58e-05, 3.417e-05 /
2926     data ZsCBdel(9)/ 14 /
2927     data (AsCBdel( 1 , i, 9 ),i=1,9)/
2928     + -0.482, -0.3436, 1.032, 1.099, -0.2834,
2929     + 0.7271, 0.4975, -0.3009, -0.3203 /
2930     data (AsCBdel( 2 , i, 9 ),i=1,9)/
2931     + 0.1315, 0.1377, 0.1022, 0.1591, 0.2496,
2932     + 0.2229, 0.2438, 0.2875, 0.2946 /
2933     data (AsCBdel( 3 , i, 9 ),i=1,9)/
2934     + -0.005324, -0.002923, -0.0008502, -0.000928, -0.001066,
2935     + -0.0003526, -0.000212, -0.0002344, -0.0001483 /
2936     data (AsCBdel( 4 , i, 9 ),i=1,9)/
2937     + 0.0001555, 4.879e-05, 9.499e-06, 4.498e-06, 2.597e-06,
2938     + 3.532e-07, 1.095e-07, 1.34e-07, 5.275e-08 /
2939     data (CsCBdel( 0 , i, 9 ),i=1,9)/
2940     + 0.7947, 0.8286, -1.163, -1.429, 0.6795,
2941     + -1.002, -0.6834, 0.5116, 0.4764 /
2942     data (CsCBdel( 1 , i, 9 ),i=1,9)/
2943     + 0.7724, 1.09, -1.231, -1.651, 1.068,
2944     + -1.165, -0.7525, 0.7734, 0.7112 /
2945     data (CsCBdel( 2 , i, 9 ),i=1,9)/
2946     + 0.5181, 0.8414, -0.8242, -1.192, 0.9573,
2947     + -0.8474, -0.5102, 0.6779, 0.6173 /
2948     data (CsCBdel( 3 , i, 9 ),i=1,9)/
2949     + 0.2907, 0.5252, -0.4605, -0.7067, 0.6767,
2950     + -0.5094, -0.2811, 0.4676, 0.4236 /
2951     data (CsCBdel( 4 , i, 9 ),i=1,9)/
2952     + 0.1401, 0.2746, -0.2163, -0.3463, 0.3866,
2953     + -0.2545, -0.1267, 0.257, 0.2332 /
2954     data (CsCBdel( 5 , i, 9 ),i=1,9)/
2955     + 0.05502, 0.1131, -0.0786, -0.1295, 0.1657,
2956     + -0.09712, -0.04289, 0.1034, 0.09503 /
2957     data (CsCBdel( 6 , i, 9 ),i=1,9)/
2958     + 0.01353, 0.02768, -0.01661, -0.02797, 0.03978,
2959     + -0.02127, -0.008133, 0.02257, 0.02181 /
2960     data (BsCBdel( i, 9 ),i=1,9)/
2961     + 0.009832, 0.005141, 0.002487, 0.001379, 0.0008077,
2962     + 0.0003422, 0.0001768, 0.0001453, 8.163e-05 /
2963     data ZsCBdel(10)/ 18 /
2964     data (AsCBdel( 1 , i, 10 ),i=1,9)/
2965     + 0.07435, -0.5446, -0.4682, 0.7745, 0.7001,
2966     + 0.3434, 0.5462, 0.5349, 0.7525 /
2967     data (AsCBdel( 2 , i, 10 ),i=1,9)/
2968     + 0.1468, 0.2051, 0.1962, 0.1519, 0.2065,
2969     + 0.2461, 0.244, 0.2528, 0.2519 /
2970     data (AsCBdel( 3 , i, 10 ),i=1,9)/
2971     + -0.0171, -0.009645, -0.004136, -0.001032, -0.001017,
2972     + -0.0007181, -0.0002647, -0.0001264, -4.787e-05 /
2973     data (AsCBdel( 4 , i, 10 ),i=1,9)/
2974     + 0.001165, 0.0003634, 9.998e-05, 2.092e-05, 8.324e-06,
2975     + 2.704e-06, 4.327e-07, 8.662e-08, 1.365e-08 /
2976     data (CsCBdel( 0 , i, 10 ),i=1,9)/
2977     + -0.1127, 0.7818, 0.9303, -0.8353, -0.8852,
2978     + -0.4207, -0.7605, -0.7908, -1.209 /
2979     data (CsCBdel( 1 , i, 10 ),i=1,9)/
2980     + -0.3553, 0.6983, 1.183, -0.8358, -0.9938,
2981     + -0.4465, -0.8634, -0.901, -1.464 /
2982     data (CsCBdel( 2 , i, 10 ),i=1,9)/
2983     + -0.2223, 0.3838, 0.8746, -0.525, -0.7013,
2984     + -0.3085, -0.6144, -0.6357, -1.093 /
2985     data (CsCBdel( 3 , i, 10 ),i=1,9)/
2986     + -0.1378, 0.1706, 0.515, -0.2731, -0.4069,
2987     + -0.1814, -0.3613, -0.365, -0.661 /
2988     data (CsCBdel( 4 , i, 10 ),i=1,9)/
2989     + -0.06122, 0.06301, 0.2496, -0.1187, -0.1946,
2990     + -0.0904, -0.1764, -0.171, -0.3252 /
2991     data (CsCBdel( 5 , i, 10 ),i=1,9)/
2992     + -0.02011, 0.01852, 0.09367, -0.03974, -0.07045,
2993     + -0.03483, -0.0657, -0.05986, -0.1192 /
2994     data (CsCBdel( 6 , i, 10 ),i=1,9)/
2995     + -0.003889, 0.003374, 0.02073, -0.00764, -0.0145,
2996     + -0.007855, -0.01405, -0.01164, -0.02465 /
2997     data (BsCBdel( i, 10 ),i=1,9)/
2998     + 0.02169, 0.01125, 0.005761, 0.002826, 0.001516,
2999     + 0.0007845, 0.0003452, 0.0001566, 6.648e-05 /
3000     data ZsCBdel(11)/ 54 /
3001     data (AsCBdel( 1 , i, 11 ),i=1,9)/
3002     + 0.2544, 0.004937, 0.4132, 0.6066, 1.275,
3003     + 1.901, 2.456, 2.576, 2.764 /
3004     data (AsCBdel( 2 , i, 11 ),i=1,9)/
3005     + -0.01013, 0.01016, 0.007881, 0.03123, 0.03961,
3006     + 0.06741, 0.1035, 0.1455, 0.1742 /
3007     data (AsCBdel( 3 , i, 11 ),i=1,9)/
3008     + 0.0004744, -3.434e-05, 0.0001231, -5.982e-05, -2.316e-05,
3009     + -3.843e-05, -4.707e-05, -4.937e-05, -2.956e-05 /
3010     data (AsCBdel( 4 , i, 11 ),i=1,9)/
3011     + 8.157e-07, 4.271e-08, 6.323e-08, 8.043e-07, 1.212e-08,
3012     + 1.6e-08, 1.522e-08, 1.106e-08, 2.676e-09 /
3013     data (CsCBdel( 0 , i, 11 ),i=1,9)/
3014     + -0.299, 0.1747, -0.3684, -0.5942, -1.543,
3015     + -2.5, -3.457, -3.721, -4.118 /
3016     data (CsCBdel( 1 , i, 11 ),i=1,9)/
3017     + -0.4626, 0.1589, -0.5238, -0.7772, -1.885,
3018     + -3.017, -4.248, -4.562, -5.088 /
3019     data (CsCBdel( 2 , i, 11 ),i=1,9)/
3020     + -0.2444, 0.3334, -0.2262, -0.5135, -1.412,
3021     + -2.28, -3.275, -3.508, -3.943 /
3022     data (CsCBdel( 3 , i, 11 ),i=1,9)/
3023     + -0.3055, 0.08116, -0.1946, -0.3306, -0.8995,
3024     + -1.426, -2.084, -2.212, -2.495 /
3025     data (CsCBdel( 4 , i, 11 ),i=1,9)/
3026     + -0.04217, 0.1795, -0.07936, -0.178, -0.4912,
3027     + -0.7426, -1.099, -1.146, -1.288 /
3028     data (CsCBdel( 5 , i, 11 ),i=1,9)/
3029     + -0.154, 0.05137, -0.02414, -0.07568, -0.2145,
3030     + -0.2989, -0.4425, -0.4457, -0.4933 /
3031     data (CsCBdel( 6 , i, 11 ),i=1,9)/
3032     + -0.01718, 0.02234, -0.004597, -0.01957, -0.05626,
3033     + -0.07006, -0.1017, -0.09934, -0.1057 /
3034     data (BsCBdel( i, 11 ),i=1,9)/
3035     + 0.009027, 0.001564, 0.002333, 0.001623, 0.0004254,
3036     + 0.0002607, 0.000166, 0.0001006, 4.482e-05 /
3037     +PATCH,HEEDINT.
3038     +DECK,GASHEE.
3039     SUBROUTINE GASHEE(IFAIL)
3040     *-----------------------------------------------------------------------
3041     * GASHEE - Sets the gas composition for HEED
3042     * (Last changed on 14/ 1/00.)
3043     *-----------------------------------------------------------------------
3044     implicit none
3045     +SEQ,DIMENSIONS.
3046     +SEQ,GASDATA.
3047     +SEQ,PRINTPLOT.
3048     +SEQ,molecule.
3049     +SEQ,goevent.
3050     REAL pwmol(pqmol),FRTOT,AUX
3051     INTEGER qmol,nmol(pqmol),IFAIL,INPTYP,INPCMP,IFAIL1,IERROR,
3052     - INEXT,NWORD,I,IOS
3053     LOGICAL USED(pqmol)
3054     EXTERNAL INPTYP,INPCMP
3055     +SELF,IF=SAVE.
3056     SAVE qmol,nmol,pwmol
3057     +SELF.
3058     *** Identify.
3059     IF(LIDENT)PRINT *,' /// ROUTINE GASHEE ///'
3060     PRINT *,' ------ GASHEE MESSAGE : Heed version 1.01,'//
3061     - ' interface last changed on 14/1/00.'
3062     *** Assume the routine will fail.
3063     IFAIL=1
3064     *** Initialise the gas mix.
3065     DO 20 I=1,pqmol
3066     USED(I)=.FALSE.
3067     20 CONTINUE
3068     qmol=0
3069     *** Determine number of words.
3070     CALL INPNUM(NWORD)
3071     *** Loop over the input.
3072     INEXT=2
3073     DO 10 I=2,NWORD
3074     IF(I.LT.INEXT)GOTO 10
3075     *** Fractions, first Argon.
3076     IF(INPCMP(I,'AR#GON').NE.0)THEN
3077     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3078     CALL INPMSG(I,'Argument invalid or missing. ')
3079     ELSEIF(USED(numm_Ar))THEN
3080     CALL INPMSG(I,'Gas already referenced.')
3081     ELSE
3082     CALL INPCHK(I+1,2,IFAIL1)
3083     CALL INPRDR(I+1,AUX,0.0)
3084     qmol=qmol+1
3085     nmol(qmol)=numm_Ar
3086     pwmol(qmol)=AUX
3087     USED(numm_Ar)=.TRUE.
3088     ENDIF
3089     INEXT=I+2
3090     * Methane.
3091     ELSEIF(INPCMP(I,'METHA#NE')+INPCMP(I,'CH4').NE.0)THEN
3092     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3093     CALL INPMSG(I,'Argument invalid or missing. ')
3094     ELSEIF(USED(numm_CH4))THEN
3095     CALL INPMSG(I,'Gas already referenced.')
3096     ELSE
3097     CALL INPCHK(I+1,2,IFAIL1)
3098     CALL INPRDR(I+1,AUX,0.0)
3099     qmol=qmol+1
3100     nmol(qmol)=numm_CH4
3101     pwmol(qmol)=AUX
3102     USED(numm_CH4)=.TRUE.
3103     ENDIF
3104     INEXT=I+2
3105     * Nitrogen.
3106     ELSEIF(INPCMP(I,'NI#TROGEN')+INPCMP(I,'N2').NE.0)THEN
3107     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3108     CALL INPMSG(I,'Argument invalid or missing. ')
3109     ELSEIF(USED(numm_N2))THEN
3110     CALL INPMSG(I,'Gas already referenced.')
3111     ELSE
3112     CALL INPCHK(I+1,2,IFAIL1)
3113     CALL INPRDR(I+1,AUX,0.0)
3114     qmol=qmol+1
3115     nmol(qmol)=numm_N2
3116     pwmol(qmol)=AUX
3117     USED(numm_N2)=.TRUE.
3118     ENDIF
3119     INEXT=I+2
3120     * CO2.
3121     ELSEIF(INPCMP(I,'CO2')+
3122     - INPCMP(I,'CARB#ON-DIOX#IDE').NE.0)THEN
3123     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3124     CALL INPMSG(I,'Argument invalid or missing. ')
3125     ELSEIF(USED(numm_CO2))THEN
3126     CALL INPMSG(I,'Gas already referenced.')
3127     ELSE
3128     CALL INPCHK(I+1,2,IFAIL1)
3129     CALL INPRDR(I+1,AUX,0.0)
3130     qmol=qmol+1
3131     nmol(qmol)=numm_CO2
3132     pwmol(qmol)=AUX
3133     USED(numm_CO2)=.TRUE.
3134     ENDIF
3135     INEXT=I+2
3136     * Helium 4.
3137     ELSEIF(INPCMP(I,'HE#LIUM-#4').NE.0)THEN
3138     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3139     CALL INPMSG(I,'Argument invalid or missing. ')
3140     ELSEIF(USED(numm_He))THEN
3141     CALL INPMSG(I,'Gas already referenced.')
3142     ELSE
3143     CALL INPCHK(I+1,2,IFAIL1)
3144     CALL INPRDR(I+1,AUX,0.0)
3145     qmol=qmol+1
3146     nmol(qmol)=numm_He
3147     pwmol(qmol)=AUX
3148     USED(numm_He)=.TRUE.
3149     ENDIF
3150     INEXT=I+2
3151     * Helium 3.
3152     ELSEIF(INPCMP(I,'HE#LIUM-3').NE.0)THEN
3153     CALL INPMSG(I,'Not yet in HEED.')
3154     INEXT=I+2
3155     * Neon.
3156     ELSEIF(INPCMP(I,'NEON').NE.0)THEN
3157     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3158     CALL INPMSG(I,'Argument invalid or missing. ')
3159     ELSEIF(USED(numm_Ne))THEN
3160     CALL INPMSG(I,'Gas already referenced.')
3161     ELSE
3162     CALL INPCHK(I+1,2,IFAIL1)
3163     CALL INPRDR(I+1,AUX,0.0)
3164     qmol=qmol+1
3165     nmol(qmol)=numm_Ne
3166     pwmol(qmol)=AUX
3167     USED(numm_Ne)=.TRUE.
3168     ENDIF
3169     INEXT=I+2
3170     * Ethane.
3171     ELSEIF(INPCMP(I,'ETHA#NE')+INPCMP(I,'C2H6').NE.0)THEN
3172     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3173     CALL INPMSG(I,'Argument invalid or missing. ')
3174     ELSEIF(USED(numm_C2H6))THEN
3175     CALL INPMSG(I,'Gas already referenced.')
3176     ELSE
3177     CALL INPCHK(I+1,2,IFAIL1)
3178     CALL INPRDR(I+1,AUX,0.0)
3179     qmol=qmol+1
3180     nmol(qmol)=numm_C2H6
3181     pwmol(qmol)=AUX
3182     USED(numm_C2H6)=.TRUE.
3183     ENDIF
3184     INEXT=I+2
3185     * Propane.
3186     ELSEIF(INPCMP(I,'PROPA#NE')+INPCMP(I,'C3H8').NE.0)THEN
3187     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3188     CALL INPMSG(I,'Argument invalid or missing. ')
3189     ELSEIF(USED(numm_C3H8))THEN
3190     CALL INPMSG(I,'Gas already referenced.')
3191     ELSE
3192     CALL INPCHK(I+1,2,IFAIL1)
3193     CALL INPRDR(I+1,AUX,0.0)
3194     qmol=qmol+1
3195     nmol(qmol)=numm_C3H8
3196     pwmol(qmol)=AUX
3197     USED(numm_C3H8)=.TRUE.
3198     ENDIF
3199     INEXT=I+2
3200     * Isobutane.
3201     ELSEIF(INPCMP(I,'ISO#BUTANE')+INPCMP(I,'C4H10').NE.0)THEN
3202     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3203     CALL INPMSG(I,'Argument invalid or missing. ')
3204     ELSEIF(USED(numm_iC4H10))THEN
3205     CALL INPMSG(I,'Gas already referenced.')
3206     ELSE
3207     CALL INPCHK(I+1,2,IFAIL1)
3208     CALL INPRDR(I+1,AUX,0.0)
3209     qmol=qmol+1
3210     nmol(qmol)=numm_iC4H10
3211     pwmol(qmol)=AUX
3212     USED(numm_iC4H10)=.TRUE.
3213     ENDIF
3214     INEXT=I+2
3215     * Pentane.
3216     ELSEIF(INPCMP(I,'PENT#ANE')+INPCMP(I,'C5H12')+
3217     - INPCMP(I,'N#EO-PENT#ANE')+INPCMP(I,'N#EO-C5H12').NE.0)THEN
3218     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3219     CALL INPMSG(I,'Argument invalid or missing. ')
3220     ELSEIF(USED(numm_C5H12))THEN
3221     CALL INPMSG(I,'Gas already referenced.')
3222     ELSE
3223     CALL INPCHK(I+1,2,IFAIL1)
3224     CALL INPRDR(I+1,AUX,0.0)
3225     qmol=qmol+1
3226     nmol(qmol)=numm_C5H12
3227     pwmol(qmol)=AUX
3228     USED(numm_C5H12)=.TRUE.
3229     ENDIF
3230     INEXT=I+2
3231     * Methylal.
3232     ELSEIF(INPCMP(I,'METHY#LAL')+INPCMP(I,'C3H8O2').NE.0)THEN
3233     CALL INPMSG(I,'Not yet in HEED.')
3234     INEXT=I+2
3235     * Xenon.
3236     ELSEIF(INPCMP(I,'XE#NON').NE.0)THEN
3237     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3238     CALL INPMSG(I,'Argument invalid or missing. ')
3239     ELSEIF(USED(numm_Xe))THEN
3240     CALL INPMSG(I,'Gas already referenced.')
3241     ELSE
3242     CALL INPCHK(I+1,2,IFAIL1)
3243     CALL INPRDR(I+1,AUX,0.0)
3244     qmol=qmol+1
3245     nmol(qmol)=numm_Xe
3246     pwmol(qmol)=AUX
3247     USED(numm_Xe)=.TRUE.
3248     ENDIF
3249     INEXT=I+2
3250     * Krypton.
3251     ELSEIF(INPCMP(I,'KR#YPTON').NE.0)THEN
3252     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3253     CALL INPMSG(I,'Argument invalid or missing. ')
3254     ELSEIF(USED(numm_Kr))THEN
3255     CALL INPMSG(I,'Gas already referenced.')
3256     ELSE
3257     CALL INPCHK(I+1,2,IFAIL1)
3258     CALL INPRDR(I+1,AUX,0.0)
3259     qmol=qmol+1
3260     nmol(qmol)=numm_Kr
3261     pwmol(qmol)=AUX
3262     USED(numm_Kr)=.TRUE.
3263     ENDIF
3264     INEXT=I+2
3265     * CF4.
3266     ELSEIF(INPCMP(I,'CF4').NE.0)THEN
3267     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3268     CALL INPMSG(I,'Argument invalid or missing. ')
3269     ELSEIF(USED(numm_CF4))THEN
3270     CALL INPMSG(I,'Gas already referenced.')
3271     ELSE
3272     CALL INPCHK(I+1,2,IFAIL1)
3273     CALL INPRDR(I+1,AUX,0.0)
3274     qmol=qmol+1
3275     nmol(qmol)=numm_CF4
3276     pwmol(qmol)=AUX
3277     USED(numm_CF4)=.TRUE.
3278     ENDIF
3279     INEXT=I+2
3280     * Oxygen.
3281     ELSEIF(INPCMP(I,'OX#YGEN')+INPCMP(I,'O2').NE.0)THEN
3282     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3283     CALL INPMSG(I,'Argument invalid or missing. ')
3284     ELSEIF(USED(numm_O2))THEN
3285     CALL INPMSG(I,'Gas already referenced.')
3286     ELSE
3287     CALL INPCHK(I+1,2,IFAIL1)
3288     CALL INPRDR(I+1,AUX,0.0)
3289     qmol=qmol+1
3290     nmol(qmol)=numm_O2
3291     pwmol(qmol)=AUX
3292     USED(numm_O2)=.TRUE.
3293     ENDIF
3294     INEXT=I+2
3295     * DME.
3296     ELSEIF(INPCMP(I,'DME').NE.0)THEN
3297     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3298     CALL INPMSG(I,'Argument invalid or missing. ')
3299     ELSEIF(USED(numm_DME))THEN
3300     CALL INPMSG(I,'Gas already referenced.')
3301     ELSE
3302     CALL INPCHK(I+1,2,IFAIL1)
3303     CALL INPRDR(I+1,AUX,0.0)
3304     qmol=qmol+1
3305     nmol(qmol)=numm_DME
3306     pwmol(qmol)=AUX
3307     USED(numm_DME)=.TRUE.
3308     ENDIF
3309     INEXT=I+2
3310     * Ethene.
3311     ELSEIF(INPCMP(I,'ETHE#NE')+INPCMP(I,'C2H4').NE.0)THEN
3312     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3313     CALL INPMSG(I,'Argument invalid or missing. ')
3314     ELSEIF(USED(numm_C2H4))THEN
3315     CALL INPMSG(I,'Gas already referenced.')
3316     ELSE
3317     CALL INPCHK(I+1,2,IFAIL1)
3318     CALL INPRDR(I+1,AUX,0.0)
3319     qmol=qmol+1
3320     nmol(qmol)=numm_C2H4
3321     pwmol(qmol)=AUX
3322     USED(numm_C2H4)=.TRUE.
3323     ENDIF
3324     INEXT=I+2
3325     * Acetylene.
3326     ELSEIF(INPCMP(I,'ACETYL#ENE')+INPCMP(I,'C2H2').NE.0)THEN
3327     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3328     CALL INPMSG(I,'Argument invalid or missing. ')
3329     ELSEIF(USED(numm_C2H2))THEN
3330     CALL INPMSG(I,'Gas already referenced.')
3331     ELSE
3332     CALL INPCHK(I+1,2,IFAIL1)
3333     CALL INPRDR(I+1,AUX,0.0)
3334     qmol=qmol+1
3335     nmol(qmol)=numm_C2H2
3336     pwmol(qmol)=AUX
3337     USED(numm_C2H2)=.TRUE.
3338     ENDIF
3339     INEXT=I+2
3340     * Nitric oxide (NO).
3341     ELSEIF(INPCMP(I,'NITRI#C-OX#IDE')+INPCMP(I,'NO').NE.0)THEN
3342     CALL INPMSG(I,'Not yet in HEED.')
3343     INEXT=I+2
3344     * Nitrous oxide (N2O).
3345     ELSEIF(INPCMP(I,'NITRO#US-OX#IDE')+INPCMP(I,'N2O').NE.0)THEN
3346     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3347     CALL INPMSG(I,'Argument invalid or missing. ')
3348     ELSEIF(USED(numm_N2O))THEN
3349     CALL INPMSG(I,'Gas already referenced.')
3350     ELSE
3351     CALL INPCHK(I+1,2,IFAIL1)
3352     CALL INPRDR(I+1,AUX,0.0)
3353     qmol=qmol+1
3354     nmol(qmol)=numm_N2O
3355     pwmol(qmol)=AUX
3356     USED(numm_N2O)=.TRUE.
3357     ENDIF
3358     INEXT=I+2
3359     * Hydrogen gas.
3360     ELSEIF(INPCMP(I,'HYDR#OGEN')+INPCMP(I,'H2').NE.0)THEN
3361     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3362     CALL INPMSG(I,'Argument invalid or missing. ')
3363     ELSEIF(USED(numm_H2))THEN
3364     CALL INPMSG(I,'Gas already referenced.')
3365     ELSE
3366     CALL INPCHK(I+1,2,IFAIL1)
3367     CALL INPRDR(I+1,AUX,0.0)
3368     qmol=qmol+1
3369     nmol(qmol)=numm_H2
3370     pwmol(qmol)=AUX
3371     USED(numm_H2)=.TRUE.
3372     ENDIF
3373     INEXT=I+2
3374     * Ammonia gas.
3375     ELSEIF(INPCMP(I,'AMMO#NIA')+INPCMP(I,'NH3').NE.0)THEN
3376     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3377     CALL INPMSG(I,'Argument invalid or missing. ')
3378     ELSEIF(USED(numm_NH3))THEN
3379     CALL INPMSG(I,'Gas already referenced.')
3380     ELSE
3381     CALL INPCHK(I+1,2,IFAIL1)
3382     CALL INPRDR(I+1,AUX,0.0)
3383     qmol=qmol+1
3384     nmol(qmol)=numm_NH3
3385     pwmol(qmol)=AUX
3386     USED(numm_NH3)=.TRUE.
3387     ENDIF
3388     INEXT=I+2
3389     * Water vapour.
3390     ELSEIF(INPCMP(I,'H2O')+INPCMP(I,'WAT#ER').NE.0)THEN
3391     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3392     CALL INPMSG(I,'Argument invalid or missing. ')
3393     ELSEIF(USED(numm_H2O))THEN
3394     CALL INPMSG(I,'Gas already referenced.')
3395     ELSE
3396     CALL INPCHK(I+1,2,IFAIL1)
3397     CALL INPRDR(I+1,AUX,0.0)
3398     qmol=qmol+1
3399     nmol(qmol)=numm_H2O
3400     pwmol(qmol)=AUX
3401     USED(numm_H2O)=.TRUE.
3402     ENDIF
3403     INEXT=I+2
3404     * SF6.
3405     ELSEIF(INPCMP(I,'SF6').NE.0)THEN
3406     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3407     CALL INPMSG(I,'Argument invalid or missing. ')
3408     ELSEIF(USED(numm_SF6))THEN
3409     CALL INPMSG(I,'Gas already referenced.')
3410     ELSE
3411     CALL INPCHK(I+1,2,IFAIL1)
3412     CALL INPRDR(I+1,AUX,0.0)
3413     qmol=qmol+1
3414     nmol(qmol)=numm_SF6
3415     pwmol(qmol)=AUX
3416     USED(numm_SF6)=.TRUE.
3417     ENDIF
3418     INEXT=I+2
3419     * C2F4H2 (1,1,1,2 tetrafluoroethane, HFC-134a).
3420     ELSEIF(INPCMP(I,'C2F4H2')+INPCMP(I,'C2H2F4')+
3421     - INPCMP(I,'CH2FCF3')+
3422     - INPCMP(I,'HFC-134A').NE.0)THEN
3423     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3424     CALL INPMSG(I,'Argument invalid or missing. ')
3425     ELSEIF(USED(numm_C2F4H2))THEN
3426     CALL INPMSG(I,'Gas already referenced.')
3427     ELSE
3428     CALL INPCHK(I+1,2,IFAIL1)
3429     CALL INPRDR(I+1,AUX,0.0)
3430     qmol=qmol+1
3431     nmol(qmol)=numm_C2F4H2
3432     pwmol(qmol)=AUX
3433     USED(numm_C2F4H2)=.TRUE.
3434     ENDIF
3435     INEXT=I+2
3436     * C2F5H (?).
3437     ELSEIF(INPCMP(I,'C2F5H')+INPCMP(I,'C2HF5').NE.0)THEN
3438     IF(INPTYP(I+1).NE.1.AND.INPTYP(I+1).NE.2.OR.I.GE.NWORD)THEN
3439     CALL INPMSG(I,'Argument invalid or missing. ')
3440     ELSEIF(USED(numm_C2F5H))THEN
3441     CALL INPMSG(I,'Gas already referenced.')
3442     ELSE
3443     CALL INPCHK(I+1,2,IFAIL1)
3444     CALL INPRDR(I+1,AUX,0.0)
3445     qmol=qmol+1
3446     nmol(qmol)=numm_C2F5H
3447     pwmol(qmol)=AUX
3448     USED(numm_C2F5H)=.TRUE.
3449     ENDIF
3450     INEXT=I+2
3451     * All the rest is not known.
3452     ELSE
3453     CALL INPMSG(I,'Not a known keyword.')
3454     ENDIF
3455     10 CONTINUE
3456     *** Print the error messages accumulated sofar.
3457     CALL INPERR
3458     *** Renormalise the fractions.
3459     FRTOT=0.0
3460     DO 120 I=1,qmol
3461     IF(pwmol(I).LT.0)pwmol(I)=0.0
3462     FRTOT=FRTOT+pwmol(I)
3463     120 CONTINUE
3464     IF(FRTOT.LE.0.0)THEN
3465     PRINT *,' !!!!!! GASHEE WARNING : Please have at least'//
3466     - ' one gas in your mixture; nothing done.'
3467     IFAIL=1
3468     RETURN
3469     ELSE
3470     DO 130 I=1,qmol
3471     pwmol(I)=pwmol(I)/FRTOT
3472     130 CONTINUE
3473     ENDIF
3474     *** Debugging information.
3475     IF(LDEBUG)THEN
3476     WRITE(LUNOUT,'('' ++++++ GASHEE DEBUG : Gas mix'',
3477     - '' composed as follows:'')')
3478     DO 30 I=1,qmol
3479     IF(nmol(i).eq.numm_He)THEN
3480     WRITE(LUNOUT,'(26X,''Helium '',F10.3,'' %'')')
3481     - 100*pwmol(I)
3482     ELSEIF(nmol(i).eq.numm_Ne)THEN
3483     WRITE(LUNOUT,'(26X,''Neon '',F10.3,'' %'')')
3484     - 100*pwmol(I)
3485     ELSEIF(nmol(i).eq.numm_Ar)THEN
3486     WRITE(LUNOUT,'(26X,''Argon '',F10.3,'' %'')')
3487     - 100*pwmol(I)
3488     ELSEIF(nmol(i).eq.numm_Kr)THEN
3489     WRITE(LUNOUT,'(26X,''Krypton '',F10.3,'' %'')')
3490     - 100*pwmol(I)
3491     ELSEIF(nmol(i).eq.numm_Xe)THEN
3492     WRITE(LUNOUT,'(26X,''Xenon '',F10.3,'' %'')')
3493     - 100*pwmol(I)
3494     ELSEIF(nmol(i).eq.numm_H2)THEN
3495     WRITE(LUNOUT,'(26X,''H2 '',F10.3,'' %'')')
3496     - 100*pwmol(I)
3497     ELSEIF(nmol(i).eq.numm_N2)THEN
3498     WRITE(LUNOUT,'(26X,''N2 '',F10.3,'' %'')')
3499     - 100*pwmol(I)
3500     ELSEIF(nmol(i).eq.numm_O2)THEN
3501     WRITE(LUNOUT,'(26X,''O2 '',F10.3,'' %'')')
3502     - 100*pwmol(I)
3503     ELSEIF(nmol(i).eq.numm_NH3)THEN
3504     WRITE(LUNOUT,'(26X,''NH3 '',F10.3,'' %'')')
3505     - 100*pwmol(I)
3506     ELSEIF(nmol(i).eq.numm_N2O)THEN
3507     WRITE(LUNOUT,'(26X,''N2O '',F10.3,'' %'')')
3508     - 100*pwmol(I)
3509     ELSEIF(nmol(i).eq.numm_CO2)THEN
3510     WRITE(LUNOUT,'(26X,''CO2 '',F10.3,'' %'')')
3511     - 100*pwmol(I)
3512     ELSEIF(nmol(i).eq.numm_CF4)THEN
3513     WRITE(LUNOUT,'(26X,''CF4 '',F10.3,'' %'')')
3514     - 100*pwmol(I)
3515     ELSEIF(nmol(i).eq.numm_CH4)THEN
3516     WRITE(LUNOUT,'(26X,''CH4 '',F10.3,'' %'')')
3517     - 100*pwmol(I)
3518     ELSEIF(nmol(i).eq.numm_C2H2)THEN
3519     WRITE(LUNOUT,'(26X,''C2H2 '',F10.3,'' %'')')
3520     - 100*pwmol(I)
3521     ELSEIF(nmol(i).eq.numm_C2H4)THEN
3522     WRITE(LUNOUT,'(26X,''C2H4 '',F10.3,'' %'')')
3523     - 100*pwmol(I)
3524     ELSEIF(nmol(i).eq.numm_C2H6)THEN
3525     WRITE(LUNOUT,'(26X,''C2H6 '',F10.3,'' %'')')
3526     - 100*pwmol(I)
3527     ELSEIF(nmol(i).eq.numm_C3H8)THEN
3528     WRITE(LUNOUT,'(26X,''C3H8 '',F10.3,'' %'')')
3529     - 100*pwmol(I)
3530     ELSEIF(nmol(i).eq.numm_iC4H10)THEN
3531     WRITE(LUNOUT,'(26X,''iC4H10 '',F10.3,'' %'')')
3532     - 100*pwmol(I)
3533     ELSEIF(nmol(i).eq.numm_C5H12)THEN
3534     WRITE(LUNOUT,'(26X,''C5H12 '',F10.3,'' %'')')
3535     - 100*pwmol(I)
3536     ELSEIF(nmol(i).eq.numm_DME)THEN
3537     WRITE(LUNOUT,'(26X,''DME '',F10.3,'' %'')')
3538     - 100*pwmol(I)
3539     ELSEIF(nmol(i).eq.numm_H2O)THEN
3540     WRITE(LUNOUT,'(26X,''H2O '',F10.3,'' %'')')
3541     - 100*pwmol(I)
3542     ELSEIF(nmol(i).eq.numm_SF6)THEN
3543     WRITE(LUNOUT,'(26X,''SF6 '',F10.3,'' %'')')
3544     - 100*pwmol(I)
3545     ELSEIF(nmol(i).eq.numm_C2F4H2)THEN
3546     WRITE(LUNOUT,'(26X,''C2F4H2 '',F10.3,'' %'')')
3547     - 100*pwmol(I)
3548     ELSEIF(nmol(i).eq.numm_C2F5H)THEN
3549     WRITE(LUNOUT,'(26X,''C2F5H '',F10.3,'' %'')')
3550     - 100*pwmol(I)
3551     ELSE
3552     WRITE(LUNOUT,'(26X,''# Unknown # '',F10.3,'' %'')')
3553     - 100*pwmol(I)
3554     ENDIF
3555     30 CONTINUE
3556     WRITE(LUNOUT,'(26X,''Pressure: '',F10.3,'' torr''/
3557     - 26X,''Temperature: '',F10.3,'' K'')') PGAS,TGAS
3558     ENDIF
3559     *** Set HEED printing and error monitoring flags.
3560     IF(LDEBUG)THEN
3561     soo=1
3562     ELSE
3563     soo=0
3564     ENDIF
3565     oo=LUNOUT
3566     s_err=0
3567     *** Call the HEED gas routine.
3568     ierror=0
3569     CALL imheed(
3570     - qmol, ! Different gas components
3571     - nmol, ! Names of gasses present in mixture
3572     - pwmol, ! Gas fractions
3573     - PGAS, ! Pressure [torr]
3574     - TGAS, ! Temperature [K]
3575     - 1, ! 0 or 1: Do/don't generate output
3576     - 6, ! Output logical unit
3577     - 1, ! 1/2 Short/Medium listing
3578     - GASDEN, ! (Output) computed density
3579     - ierror) ! Error indicator.
3580     IF(LDEBUG)WRITE(LUNOUT,'('' ++++++ GASHEE DEBUG :'',
3581     - '' HEED density: '',F10.3,'' g/l, error code: '',I3)')
3582     - 1000*GASDEN,ierror
3583     *** Return error code.
3584     IF(ierror.NE.0)THEN
3585     PRINT *,' !!!!!! GASHEE WARNING : Gas preparation by'//
3586     - ' HEED failed ; tracks can not be generated.'
3587     IFAIL=1
3588     HEEDOK=.FALSE.
3589     ELSE
3590     IFAIL=0
3591     HEEDOK=.TRUE.
3592     ENDIF
3593     RETURN
3594     *** Write the tables.
3595     ENTRY GASHWR(IFAIL)
3596     * Assume for the moment that writing will work.
3597     IFAIL=0
3598     * See whether iniialisation has been performed.
3599     WRITE(12,'('' Heed initialisation done: '',L1)',ERR=2010,
3600     - IOSTAT=IOS) HEEDOK
3601     IF(HEEDOK)THEN
3602     * Write the composition.
3603     WRITE(12,'('' Gas components: '',I5)',ERR=2010,
3604     - IOSTAT=IOS) qmol
3605     DO 200 I=1,qmol
3606     WRITE(12,'(2X,I10,E15.8)',ERR=2010,IOSTAT=IOS)
3607     - nmol(I),pwmol(I)
3608     200 CONTINUE
3609     ENDIF
3610     RETURN
3611     * Errors during I/O.
3612     2010 CONTINUE
3613     PRINT *,' !!!!!! GASHWR WARNING : I/O error occurred while'//
3614     - ' writing Heed initialisation data.'
3615     CALL INPIOS(IOS)
3616     IFAIL=1
3617     RETURN
3618     *** Retrieve initialisation data.
3619     ENTRY GASHGT(IFAIL)
3620     * Assume for the moment that reading will work.
3621     IFAIL=0
3622     * See whether initialisation should be performed.
3623     READ(12,'(28X,L1)',ERR=2015,IOSTAT=IOS) HEEDOK
3624     IF(HEEDOK)THEN
3625     * Read the composition.
3626     READ(12,'(18X,I5)',ERR=2015,IOSTAT=IOS) qmol
3627     IF(qmol.LT.0.OR.qmol.GT.pqmol)THEN
3628     PRINT *,' !!!!!! GASHGT WARNING : Number of gas'//
3629     - ' components < 0 or > current maximum; Heed'//
3630     - ' initialisation not performed.'
3631     RETURN
3632     ENDIF
3633     DO 210 I=1,qmol
3634     READ(12,'(2X,I10,E15.8)',ERR=2015,IOSTAT=IOS)
3635     - nmol(I),pwmol(I)
3636     210 CONTINUE
3637     * Perform the initialisation.
3638     ierror=0
3639     CALL imheed(
3640     - qmol, ! Different gas components
3641     - nmol, ! Names of gasses present in mixture
3642     - pwmol, ! Gas fractions
3643     - PGAS, ! Pressure [torr]
3644     - TGAS, ! Temperature [K]
3645     - 1, ! 0 or 1: Do/don't generate output
3646     - 6, ! Output logical unit
3647     - 1, ! 1/2 Short/Medium listing
3648     - GASDEN, ! (Output) computed density
3649     - ierror) ! Error indicator.
3650     IF(LDEBUG)WRITE(LUNOUT,'('' ++++++ GASHEE DEBUG :'',
3651     - '' HEED density: '',F10.3,'' g/l, error code: '',I3)')
3652     - 1000*GASDEN,ierror
3653     * Return error code.
3654     IF(ierror.NE.0)THEN
3655     PRINT *,' !!!!!! GASHGT WARNING : Gas preparation by'//
3656     - ' HEED failed ; tracks can not be generated.'
3657     IFAIL=1
3658     HEEDOK=.FALSE.
3659     ELSE
3660     IFAIL=0
3661     HEEDOK=.TRUE.
3662     ENDIF
3663     ENDIF
3664     RETURN
3665     * Errors during I/O.
3666     2015 CONTINUE
3667     PRINT *,' !!!!!! GASHGT WARNING : I/O error occurred while'//
3668     - ' retrieving Heed initialisation data.'
3669     CALL INPIOS(IOS)
3670     IFAIL=1
3671     END
3672     +DECK,TRAINT
3673     SUBROUTINE TRAINT
3674     *-----------------------------------------------------------------------
3675     * TRAINT - Initialises the track.
3676     * (Last changed on 14/ 5/99.)
3677     *-----------------------------------------------------------------------
3678     implicit none
3679     +SEQ,DIMENSIONS.
3680     +SEQ,PARAMETERS.
3681     INTEGER I
3682     *** Reset all the track flags.
3683     DO 10 I=1,10
3684     TRFLAG(I)=.FALSE.
3685     10 CONTINUE
3686     *** Set the track type (fixed number of points).
3687     ITRTYP=0
3688     *** Set default number of lines.
3689     NTRLIN=20
3690     TRFLAG(3)=.TRUE.
3691     *** Default number of samples.
3692     NTRSAM=100
3693     TRFLAG(5)=.TRUE.
3694     *** Default number of flux lines.
3695     NTRFLX=20
3696     TRFLAG(6)=.TRUE.
3697     *** Default flux interval.
3698     TRFLUX=10
3699     TRFLAG(7)=.TRUE.
3700     *** Set some track.
3701     XT0=0.0
3702     YT0=0.0
3703     ZT0=0.0
3704     XT1=0.0
3705     YT1=0.0
3706     ZT1=0.0
3707     TRTH=0
3708     TRPHI=0
3709     *** Reset the options.
3710     LTRMS =.FALSE.
3711     LTRDEL=.TRUE.
3712     LTRINT=.FALSE.
3713     LTREXB=.TRUE.
3714     *** Reset the track interpolation table.
3715     CALL DLCTRR
3716     *** Set a default particle type and energy (a 1 GeV mu-)
3717     TRMASS=105.658389
3718     TRCHAR=-1.0
3719     TRENER=1000.0
3720     *** Particle identifier.
3721     PARTID='Unknown'
3722     PNAME='Unknown'
3723     NCPNAM=7
3724     END
3725     +DECK,TRACLS.
3726     SUBROUTINE TRACLS(XCLS,YCLS,ZCLS,ECLS,NPAIR,DONE,IFAIL)
3727     *-----------------------------------------------------------------------
3728     * TRACLS - Generates new clusters along the track.
3729     * TRACLI - Initialisation.
3730     * (Last changed on 24/ 9/00.)
3731     *-----------------------------------------------------------------------
3732     implicit none
3733     +SEQ,DIMENSIONS.
3734     +SEQ,GASDATA.
3735     +SEQ,PARAMETERS.
3736     +SEQ,PRINTPLOT.
3737     +SEQ,CONSTANTS.
3738     +SEQ,volume.
3739     +SEQ,goevent.
3740     +SEQ,del.
3741     +SEQ,cel.
3742     +SEQ,abs.
3743     +SEQ,rga.
3744     +SEQ,lsgvga.
3745     REAL XCLS,YCLS,ZCLS,ECLS,TRALEN,DIST,RNDEXP,RNDM,XAUX,YAUX,ZAUX,
3746     - DISVGA(pqgvga),EDELTA,ETOT,XP,YP,ZP,Q,FLXSUM,FLXCOO(MXLIST),
3747     - FLXTAB(MXLIST),DIVDIF,XL,XL0FLX,XL1FLX
3748     DOUBLE PRECISION XRAN
3749     INTEGER NPAIR,NTOT,NDELTA,IVGA,ICEL,I,J,IERROR,IFAIL,IPRINT,
3750     - NCAUX,NV,ISIGN,JPRINT
3751     LOGICAL DONE,OK
3752     CHARACTER*20 AUX
3753     EXTERNAL RNDEXP,RNDM
3754     +SELF,IF=SAVE.
3755     SAVE NTOT,TRALEN,DIST,OK,IVGA,ICEL,ETOT,FLXCOO,FLXTAB,FLXSUM,
3756     - XL0FLX,XL1FLX
3757     +SELF.
3758     DATA OK/.FALSE./
3759     *** Identify the routine if requested.
3760     IF(LIDENT)PRINT *,' /// ROUTINE TRACLS ///'
3761     *** Initial settings.
3762     XCLS=0
3763     YCLS=0
3764     ZCLS=0
3765     ECLS=0
3766     NPAIR=0
3767     DONE=.TRUE.
3768     IFAIL=1
3769     *** Make sure the routine is in the proper state.
3770     IF(.NOT.OK)THEN
3771     PRINT *,' !!!!!! TRACLS WARNING : Track initialisation'//
3772     - ' not done or track complete; no clusters.'
3773     RETURN
3774     *** Verify that track parameters are available.
3775     ELSEIF(.NOT.TRFLAG(1))THEN
3776     PRINT *,' !!!!!! TRACLS WARNING : Track location is not'//
3777     - ' set; no clusters.'
3778     RETURN
3779     ENDIF
3780     *** Handle the case of a fixed number of clusters.
3781     IF(ITRTYP.EQ.1)THEN
3782     * Ensure that the number is reasonable.
3783     IF(.NOT.TRFLAG(3))THEN
3784     PRINT *,' !!!!!! TRACLS WARNING : Number of points'//
3785     - ' on the track not defined; no clusters.'
3786     RETURN
3787     ENDIF
3788     * Increment cluster counter.
3789     NTOT=NTOT+1
3790     * Compute new cluster position.
3791     IF(NTRLIN.GT.1)THEN
3792     XCLS=XT0+REAL(NTOT-1)*(XT1-XT0)/REAL(NTRLIN-1)
3793     YCLS=YT0+REAL(NTOT-1)*(YT1-YT0)/REAL(NTRLIN-1)
3794     ZCLS=ZT0+REAL(NTOT-1)*(ZT1-ZT0)/REAL(NTRLIN-1)
3795     ELSE
3796     XCLS=0.5*(XT0+XT1)
3797     YCLS=0.5*(YT0+YT1)
3798     ZCLS=0.5*(ZT0+ZT1)
3799     ENDIF
3800     * Set cluster size and energy.
3801     NPAIR=1
3802     ECLS=-1
3803     * See whether we were already done.
3804     IF(NTOT.GT.NTRLIN)THEN
3805     DONE=.TRUE.
3806     OK=.FALSE.
3807     ELSE
3808     DONE=.FALSE.
3809     ENDIF
3810     *** Fixed number of clusters at weighted positions.
3811     ELSEIF(ITRTYP.EQ.5)THEN
3812     * Ensure that the number is reasonable.
3813     IF(.NOT.TRFLAG(4))THEN
3814     PRINT *,' !!!!!! TRACLS WARNING : Weighting function'//
3815     - ' on the track not defined; no clusters.'
3816     RETURN
3817     ELSEIF(.NOT.TRFLAG(5))THEN
3818     PRINT *,' !!!!!! TRACLS WARNING : Number of points'//
3819     - ' on the track not defined; no clusters.'
3820     RETURN
3821     ENDIF
3822     * Increment cluster counter.
3823     NTOT=NTOT+1
3824     * Compute new cluster position.
3825     CALL HISRAD(WGT,MXLIST,0.0D0,1.0D0/MXLIST,XRAN)
3826     XCLS=XT0+REAL(XRAN)*(XT1-XT0)
3827     YCLS=YT0+REAL(XRAN)*(YT1-YT0)
3828     ZCLS=ZT0+REAL(XRAN)*(ZT1-ZT0)
3829     * Set cluster size and energy.
3830     NPAIR=1
3831     ECLS=-1
3832     * See whether we were already done.
3833     IF(NTOT.GT.NTRSAM)THEN
3834     DONE=.TRUE.
3835     OK=.FALSE.
3836     ELSE
3837     DONE=.FALSE.
3838     ENDIF
3839     *** One cluster at a random location.
3840     ELSEIF(ITRTYP.EQ.6)THEN
3841     * Increment cluster counter.
3842     NTOT=NTOT+1
3843     * Compute new cluster position.
3844     XRAN=DBLE(RNDM(NTOT))
3845     XCLS=XT0+REAL(XRAN)*(XT1-XT0)
3846     YCLS=YT0+REAL(XRAN)*(YT1-YT0)
3847     ZCLS=ZT0+REAL(XRAN)*(ZT1-ZT0)
3848     * Set the cluster size and energy.
3849     IF(GASOK(5))THEN
3850     CALL HISRAD(CLSDIS,NCLS,0.0D0,1.0D0,XRAN)
3851     NPAIR=INT(XRAN)
3852     ECLS=NPAIR*EPAIR
3853     ELSE
3854     NPAIR=1
3855     ECLS=0
3856     ENDIF
3857     * See whether we were already done.
3858     IF(NTOT.GT.1)THEN
3859     DONE=.TRUE.
3860     OK=.FALSE.
3861     ELSE
3862     DONE=.FALSE.
3863     ENDIF
3864     *** Handle the case of equally spaced clusters according to CMEAN.
3865     ELSEIF(ITRTYP.EQ.2)THEN
3866     * Ensure that the appropriate gas data is present.
3867     IF(.NOT.GASOK(5))THEN
3868     PRINT *,' !!!!!! TRACLS WARNING : Clustering data'//
3869     - ' from gas section missing; track not set.'
3870     RETURN
3871     ENDIF
3872     * Store track length.
3873     IF(NTOT.EQ.0)
3874     - TRALEN=SQRT((XT1-XT0)**2+(YT1-YT0)**2+(ZT1-ZT0)**2)
3875     * Increment cluster counter.
3876     NTOT=NTOT+1
3877     * Generate new cluster position.
3878     IF(TRALEN.GT.0)THEN
3879     XCLS=XT0+(REAL(NTOT-1)/CMEAN)*(XT1-XT0)/TRALEN
3880     YCLS=YT0+(REAL(NTOT-1)/CMEAN)*(YT1-YT0)/TRALEN
3881     ZCLS=ZT0+(REAL(NTOT-1)/CMEAN)*(ZT1-ZT0)/TRALEN
3882     ELSE
3883     XCLS=0.5*(XT0+XT1)
3884     YCLS=0.5*(YT0+YT1)
3885     ZCLS=0.5*(ZT0+ZT1)
3886     ENDIF
3887     * See whether we're ready.
3888     IF((XT0-XCLS)*(XCLS-XT1).LT.0.OR.
3889     - (YT0-YCLS)*(YCLS-YT1).LT.0.OR.
3890     - (ZT0-ZCLS)*(ZCLS-ZT1).LT.0.OR.
3891     - (TRALEN.LE.0.AND.NTOT.GT.1))THEN
3892     DONE=.TRUE.
3893     OK=.FALSE.
3894     ELSE
3895     DONE=.FALSE.
3896     ENDIF
3897     * Set the cluster size and energy.
3898     CALL HISRAD(CLSDIS,NCLS,0.0D0,1.0D0,XRAN)
3899     NPAIR=INT(XRAN)
3900     ECLS=NPAIR*EPAIR
3901     *** Handle the case of exponentially spaced clusters.
3902     ELSEIF(ITRTYP.EQ.3)THEN
3903     * Ensure that the appropriate gas data is present.
3904     IF(.NOT.GASOK(5))THEN
3905     PRINT *,' !!!!!! TRACLS WARNING : Clustering data'//
3906     - ' from gas section missing; track not set.'
3907     RETURN
3908     ENDIF
3909     * Store track length.
3910     IF(NTOT.EQ.0)THEN
3911     TRALEN=SQRT((XT1-XT0)**2+(YT1-YT0)**2+(ZT1-ZT0)**2)
3912     DIST=0
3913     ENDIF
3914     * Increment cluster counter.
3915     NTOT=NTOT+1
3916     * Generate new cluster position.
3917     IF(TRALEN.GT.0)THEN
3918     DIST=DIST+RNDEXP(1.0/CMEAN)
3919     XCLS=XT0+DIST*(XT1-XT0)/TRALEN
3920     YCLS=YT0+DIST*(YT1-YT0)/TRALEN
3921     ZCLS=ZT0+DIST*(ZT1-ZT0)/TRALEN
3922     ELSE
3923     XCLS=0.5*(XT0+XT1)
3924     YCLS=0.5*(YT0+YT1)
3925     ZCLS=0.5*(ZT0+ZT1)
3926     ENDIF
3927     * See whether we're ready.
3928     IF((XT0-XCLS)*(XCLS-XT1).LT.0.OR.
3929     - (YT0-YCLS)*(YCLS-YT1).LT.0.OR.
3930     - (ZT0-ZCLS)*(ZCLS-ZT1).LT.0.OR.
3931     - (TRALEN.LE.0.AND.NTOT.GT.1))THEN
3932     DONE=.TRUE.
3933     OK=.FALSE.
3934     ELSE
3935     DONE=.FALSE.
3936     ENDIF
3937     * Set the cluster size and energy.
3938     CALL HISRAD(CLSDIS,NCLS,0.0D0,1.0D0,XRAN)
3939     NPAIR=INT(XRAN)
3940     ECLS=EPAIR*NPAIR
3941     *** And finally deal with the case of HEED generated clusters.
3942     ELSEIF(ITRTYP.EQ.4)THEN
3943     ** Check for zero charge tracks.
3944     IF(TRCHAR.EQ.0)THEN
3945     DONE=.TRUE.
3946     XCLS=0
3947     YCLS=0
3948     ZCLS=0
3949     ECLS=0
3950     NPAIR=0
3951     OK=.FALSE.
3952     IFAIL=0
3953     RETURN
3954     ENDIF
3955     ** If this is a request for the first cluster ...
3956     IF(IVGA.EQ.0)THEN
3957     * Ensure that proper data is available.
3958     IF(.NOT.HEEDOK)THEN
3959     PRINT *,' !!!!!! TRACLS WARNING : HEED gas'//
3960     - ' mix not defined; track not set.'
3961     RETURN
3962     ELSEIF(.NOT.TRFLAG(2))THEN
3963     PRINT *,' !!!!!! TRACLS WARNING : Particle'//
3964     - ' properties not present; no clusters.'
3965     RETURN
3966     ENDIF
3967     * Store track length and rotation angles.
3968     IF((XT1-XT0)**2+(ZT1-ZT0)**2.LE.0)THEN
3969     IF(YT1-YT0.LT.0)THEN
3970     TRTH=-PI/2
3971     ELSEIF(YT1-YT0.GT.0)THEN
3972     TRTH=+PI/2
3973     ELSE
3974     TRTH=0
3975     ENDIF
3976     TRPHI=0
3977     ELSE
3978     TRPHI=ATAN2(XT1-XT0,ZT1-ZT0)
3979     TRTH=ATAN2(YT1-YT0,SQRT((XT1-XT0)**2+
3980     - (ZT1-ZT0)**2))
3981     ENDIF
3982     TRALEN=SQRT((XT1-XT0)**2+(YT1-YT0)**2+(ZT1-ZT0)**2)
3983     IF(TRALEN.LE.0)THEN
3984     PRINT *,' !!!!!! TRACLS WARNING : Track length'//
3985     - ' 0 not compatible with HEED; no clusters.'
3986     RETURN
3987     ENDIF
3988     IF(LDEBUG)THEN
3989     WRITE(LUNOUT,'('' ++++++ TRACLS DEBUG :'',
3990     - '' Transformation matrix:'',3(/26X,3F10.3)/
3991     - 26X,''Track length: '',E15.8,'' cm.'')')
3992     - COS(TRPHI),-SIN(TRPHI)*SIN(TRTH),
3993     - +SIN(TRPHI)*COS(TRTH),0,COS(TRTH),
3994     - +SIN(TRTH),-SIN(TRPHI),-COS(TRPHI)*SIN(TRTH),
3995     - +COS(TRPHI)*COS(TRTH),TRALEN
3996     ENDIF
3997     * Set the HEED error flag to false.
3998     IF(LDEBUG)THEN
3999     soo=1
4000     ELSE
4001     soo=0
4002     ENDIF
4003     oo=LUNOUT
4004     s_err=0
4005     * Set the tracking volume.
4006     CALL IniFVolume(0,1,1,1,0.0,TRALEN)
4007     * Set the particle type.
4008     IF(LDEBUG)THEN
4009     IPRINT=2
4010     ELSE
4011     IPRINT=1
4012     ENDIF
4013     IERROR=0
4014     CALL ipheed(
4015     - TRENER, ! Particle kinetic energy [MeV]
4016     - TRMASS, ! Particle mass [MeV]
4017     - IPRINT, ! 1/2 Short/Medium listing
4018     - IERROR) ! Error indicator.
4019     IF(IERROR.NE.0)THEN
4020     PRINT *,' !!!!!! TRACLS WARNING : Setting the'//
4021     - ' particle properties in HEED failed.'
4022     RETURN
4023     ENDIF
4024     * Set the track.
4025     CALL IniRTrack(
4026     - 0.0,0.0, ! Starting interval, HEED y [cm]
4027     - 0.0,0.0) ! Track orientation
4028     * Optionally add multiple scattering.
4029     IF(LTRMS)CALL IniMTrack(
4030     - 1, ! Sign of Rutherford angle
4031     - 0.01*GASDEN, ! Step
4032     - 0.001) ! Minimum angle
4033     * Generate a track.
4034     CALL GoEventn(1,1)
4035     * Check for overflow.
4036     IF(qsOverflowagam.GT.0)
4037     - PRINT *,' !!!!!! TRACLS WARNING : Overflow of'//
4038     - ' energy deposition buffer in HEED; no clusters.'
4039     IF(qsOverflowrga.GT.0)
4040     - PRINT *,' !!!!!! TRACLS WARNING : Overflow of'//
4041     - ' real photon buffer in HEED; no clusters.'
4042     IF(qsOverflowDel.GT.0)
4043     - PRINT *,' !!!!!! TRACLS WARNING : Overflow of'//
4044     - ' delta electron buffer in HEED; no clusters.'
4045     IF(qsOverflowCel(1).GT.0)
4046     - PRINT *,' !!!!!! TRACLS WARNING : Overflow of'//
4047     - ' deposited electron buffer in HEED; no clusters.'
4048     IF(qsOverflowagam.GT.0.OR.qsOverflowrga.GT.0.OR.
4049     - qsOverflowDel.GT.0.OR.qsOverflowagam.GT.0)THEN
4050     OK=.FALSE.
4051     DONE=.TRUE.
4052     RETURN
4053     ENDIF
4054     * Sort the virtual gamma's by location.
4055     DO 50 I=1,qgvga(1)
4056     DISVGA(I)=pntgvga(3,I,1)
4057     50 CONTINUE
4058     CALL SORTZV(DISVGA,INDPOS,qgvga(1),1,0,0)
4059     * If debugging is on, print the Virtual GAmma's.
4060     IF(LDEBUG)THEN
4061     WRITE(LUNOUT,'('' ++++++ TRACLS DEBUG :'',
4062     - '' Virtual gammas: '',I5,'' total dE='',
4063     - E15.8,'' MeV:''/'' Index'',
4064     - '' x [cm] y [cm]'',
4065     - '' z [cm] dE [MeV]'',
4066     - '' order'')')
4067     - qgvga(1),esgvga(1)
4068     DO 10 I=1,qgvga(1)
4069     JPRINT=0
4070     DO 80 J=1,qgvga(1)
4071     IF(INDPOS(J).EQ.I)JPRINT=J
4072     80 CONTINUE
4073     WRITE(LUNOUT,'(2X,I5,4(1X,E15.8),I6)')
4074     - I,(pntgvga(J,I,1),J=1,3),egvga(I,1),JPRINT
4075     10 CONTINUE
4076     * Same for the delta's.
4077     WRITE(LUNOUT,'('' ++++++ TRACLS DEBUG :'',
4078     - '' Delta + Auger electrons: '',I5/
4079     - '' Index'',
4080     - '' x [cm] y [cm]'',
4081     - '' z [cm] energy [MeV]'',
4082     - '' charge gamma type'')') qdel
4083     DO 20 I=1,qdel
4084     IF(SOdel(I).EQ.0)THEN
4085     WRITE(LUNOUT,'(2X,I5,4(1X,E15.8),F7.1,I6,
4086     - '' delta'')') I,(pntdel(j,i),j=1,3),
4087     - edel(i),zdel(i),ptdel(i)
4088     ELSE
4089     WRITE(LUNOUT,'(2X,I5,4(1X,E15.8),F7.1,I6,
4090     - '' Auger'')') I,(pntdel(j,i),j=1,3),
4091     - edel(i),zdel(i),ptdel(i)
4092     ENDIF
4093     20 CONTINUE
4094     * Same for the real photons.
4095     WRITE(LUNOUT,'('' ++++++ TRACLS DEBUG :'',
4096     - '' Real photons: '',I5/'' Index'',
4097     - '' x [cm] y [cm]'',
4098     - '' z [cm] energy [MeV]'',
4099     - '' gamma'')') qrga
4100     DO 30 I=1,qrga
4101     WRITE(LUNOUT,'(2X,I5,4(1X,E15.8),I6)')
4102     - I,(pntrga(j,i),j=1,3),erga(i),
4103     - ptrga(i)
4104     30 CONTINUE
4105     * And finally also the electrons.
4106     WRITE(LUNOUT,'('' ++++++ TRACLS DEBUG :'',
4107     - '' Electrons: '',I5/'' Index'',
4108     - '' x [cm] y [cm]'',
4109     - '' z [cm]'',
4110     - '' charge delta'')') qcel(1)
4111     DO 40 I=1,qcel(1)
4112     WRITE(LUNOUT,'(2X,I5,3(1X,E15.8),F7.1,I6)')
4113     - I,(pntcel(j,i,1),j=1,3),zcel(i,1),
4114     - ndelcel(i,1)
4115     40 CONTINUE
4116     ENDIF
4117     * Store first virtual gamma and electron to deal with.
4118     IVGA=1
4119     ICEL=0
4120     * Reset total energy.
4121     ETOT=0
4122     ENDIF
4123     ** If delta's have to be taken into account.
4124     IF(LTRDEL)THEN
4125     70 CONTINUE
4126     * Increment the electron counter.
4127     ICEL=ICEL+1
4128     * Check whether we've reached the last electron.
4129     IF(ICEL.GT.qcel(1))THEN
4130     * If so, increment the virtual gamma counter.
4131     IVGA=IVGA+1
4132     ICEL=1
4133     * Check whether we've reached the last virtual gamma.
4134     IF(IVGA.GT.qgvga(1))THEN
4135     DONE=.TRUE.
4136     XCLS=0
4137     YCLS=0
4138     ZCLS=0
4139     ECLS=0
4140     NPAIR=0
4141     OK=.FALSE.
4142     IFAIL=0
4143     RETURN
4144     ELSE
4145     DONE=.FALSE.
4146     ENDIF
4147     ELSE
4148     DONE=.FALSE.
4149     ENDIF
4150     * See whether this electron belongs to the right gamma.
4151     IF(ptdel(ndelcel(ICEL,1)).NE.INDPOS(IVGA))GOTO 70
4152     * Fetch the location of this electron.
4153     XAUX=pntcel(1,ICEL,1)
4154     YAUX=pntcel(2,ICEL,1)
4155     ZAUX=pntcel(3,ICEL,1)
4156     C print *,' Taking electron ',icel,' from gamma ',ivga
4157     * Compute the energy deposited in this electron.
4158     EDELTA=edel(ndelcel(ICEL,1))
4159     NDELTA=0
4160     DO 60 I=1,qcel(1)
4161     IF(ndelcel(I,1).EQ.ndelcel(ICEL,1))NDELTA=NDELTA+1
4162     60 CONTINUE
4163     IF(NDELTA.LE.0)THEN
4164     ECLS=-1
4165     ELSE
4166     ECLS=EDELTA/NDELTA
4167     ENDIF
4168     * Check whether we exceeded the total energy.
4169     ETOT=ETOT+ECLS
4170     IF(ETOT.GT.TRENER)THEN
4171     PRINT *,' ------ TRACLS MESSAGE : Track'//
4172     - ' truncated because the deposited'//
4173     - ' energy exceeds the particle energy.'
4174     DONE=.TRUE.
4175     XCLS=0
4176     YCLS=0
4177     ZCLS=0
4178     ECLS=0
4179     NPAIR=0
4180     OK=.FALSE.
4181     IFAIL=0
4182     RETURN
4183     ENDIF
4184     * There is only 1 electron in this case.
4185     NPAIR=1
4186     ** If we don't want deltas ...
4187     ELSE
4188     * Check whether we've already had all energy deposits.
4189     IF(IVGA.GT.qgvga(1))THEN
4190     DONE=.TRUE.
4191     XCLS=0
4192     YCLS=0
4193     ZCLS=0
4194     ECLS=0
4195     NPAIR=0
4196     OK=.FALSE.
4197     IFAIL=0
4198     RETURN
4199     ELSE
4200     DONE=.FALSE.
4201     ENDIF
4202     * Fetch the location of this deposit.
4203     XAUX=pntgvga(1,INDPOS(IVGA),1)
4204     YAUX=pntgvga(2,INDPOS(IVGA),1)
4205     ZAUX=pntgvga(3,INDPOS(IVGA),1)
4206     * Count the number of electrons associated with it.
4207     NPAIR=0
4208     DO 100 I=1,qcel(1)
4209     IF(ptdel(ndelcel(I,1)).EQ.INDPOS(IVGA))NPAIR=NPAIR+1
4210     100 CONTINUE
4211     * Store energy, checking the total energy.
4212     IF(ETOT+egvga(INDPOS(IVGA),1).GT.TRENER)THEN
4213     ECLS=TRENER-ETOT
4214     IVGA=qgvga(1)+1
4215     ELSE
4216     ECLS=egvga(INDPOS(IVGA),1)
4217     ENDIF
4218     ETOT=ETOT+ECLS
4219     * Increment the cluster counter.
4220     IVGA=IVGA+1
4221     ENDIF
4222     ** Rotate the cluster position so that it matches the track.
4223     XCLS=XT0+COS(TRPHI)*XAUX-SIN(TRPHI)*SIN(TRTH)*YAUX+
4224     - SIN(TRPHI)*COS(TRTH)*ZAUX
4225     YCLS=YT0+COS(TRTH)*YAUX+SIN(TRTH)*ZAUX
4226     ZCLS=ZT0-SIN(TRPHI)*XAUX-COS(TRPHI)*SIN(TRTH)*YAUX+
4227     - COS(TRPHI)*COS(TRTH)*ZAUX
4228     *** Fixed number of flux intervals.
4229     ELSEIF(ITRTYP.EQ.7)THEN
4230     * Verify that the number of flux lines has been set.
4231     IF(.NOT.TRFLAG(6))THEN
4232     PRINT *,' !!!!!! TRACLS WARNING : Number of flux'//
4233     - ' lines has not been set; no clusters.'
4234     RETURN
4235     ENDIF
4236     ** On first call, compute the flux intervals.
4237     IF(NTOT.EQ.0)THEN
4238     * Set integration intervals.
4239     NV=5
4240     * Compute the inplane vector normal to the track.
4241     XP=(YT1-YT0)*FPROJC-(ZT1-ZT0)*FPROJB
4242     YP=(ZT1-ZT0)*FPROJA-(XT1-XT0)*FPROJC
4243     ZP=(XT1-XT0)*FPROJB-(YT1-YT0)*FPROJA
4244     * Compute the total flux, accepting positive and negative parts.
4245     CALL FLDIN5(XT0,YT0,ZT1,XT1,YT1,ZT1,XP,YP,ZP,Q,
4246     - 20*NV,0)
4247     IF(Q.GT.0)THEN
4248     ISIGN=+1
4249     ELSE
4250     ISIGN=-1
4251     ENDIF
4252     IF(LDEBUG)WRITE(LUNOUT,'('' ++++++ TRACLS DEBUG :'',
4253     - '' Total flux: '',E15.8,'', selected sign '',I1)')
4254     - Q,ISIGN
4255     * Compute the 1-sided flux in a number of steps.
4256     FLXSUM=0
4257     IERROR=0
4258     XL0FLX=-1
4259     XL1FLX=-1
4260     DO 110 I=1,MXLIST
4261     CALL FLDIN5(
4262     - XT0+REAL(I-1)*(XT1-XT0)/REAL(MXLIST),
4263     - YT0+REAL(I-1)*(YT1-YT0)/REAL(MXLIST),
4264     - ZT0+REAL(I-1)*(ZT1-ZT0)/REAL(MXLIST),
4265     - XT0+REAL(I)*(XT1-XT0)/REAL(MXLIST),
4266     - YT0+REAL(I)*(YT1-YT0)/REAL(MXLIST),
4267     - ZT0+REAL(I)*(ZT1-ZT0)/REAL(MXLIST),
4268     - XP,YP,ZP,Q,NV,ISIGN)
4269     FLXCOO(I)=REAL(I)/REAL(MXLIST)
4270     IF(Q.GT.0)THEN
4271     FLXSUM=FLXSUM+Q
4272     IF(XL0FLX.LT.-0.5)XL0FLX=REAL(I-1)/REAL(MXLIST)
4273     XL1FLX=REAL(I)/REAL(MXLIST)
4274     ENDIF
4275     IF(Q.LT.0)IERROR=IERROR+1
4276     FLXTAB(I)=FLXSUM
4277     110 CONTINUE
4278     * Make sure that the sum is positive.
4279     IF(LDEBUG)WRITE(LUNOUT,'('' ++++++ TRACLS DEBUG :'',
4280     - '' Used flux: '',E15.8,'' V''/26X,''Start: '',
4281     - F10.3,'' End: '',F10.3)') FLXSUM,XL0FLX,XL1FLX
4282     IF(FLXSUM.LE.0)THEN
4283     PRINT *,' !!!!!! TRACLS WARNING : 1-Sided flux'//
4284     - ' integral is not > 0; no clusters.'
4285     RETURN
4286     ELSEIF(XL0FLX.LT.-0.5.OR.XL1FLX.LT.-0.5.OR.
4287     - XL1FLX.LE.XL0FLX)THEN
4288     PRINT *,' !!!!!! TRACLS WARNING : No flux'//
4289     - ' interval without sign change found.'
4290     RETURN
4291     ELSEIF(IERROR.NE.0)THEN
4292     PRINT *,' ------ TRACLS MESSAGE : The flux'//
4293     - ' changes sign over the track; part of'//
4294     - ' the track not used.'
4295     ENDIF
4296     * Normalise the flux.
4297     DO 120 I=1,MXLIST
4298     FLXTAB(I)=REAL(NTRFLX-1)*FLXTAB(I)/FLXSUM
4299     120 CONTINUE
4300     ENDIF
4301     ** Increment cluster counter.
4302     NTOT=NTOT+1
4303     * Compute new cluster position.
4304     IF(NTOT.EQ.1)THEN
4305     XL=XL0FLX
4306     ELSEIF(NTOT.GE.1.AND.NTOT.LT.NTRFLX)THEN
4307     XL=MIN(XL1FLX,MAX(XL0FLX,
4308     - DIVDIF(FLXCOO,FLXTAB,MXLIST,REAL(NTOT-1),1)))
4309     ELSEIF(NTOT.EQ.NTRFLX)THEN
4310     XL=XL1FLX
4311     ELSE
4312     XL=0.5*(XL1FLX-XL0FLX)
4313     ENDIF
4314     XCLS=XT0+XL*(XT1-XT0)
4315     YCLS=YT0+XL*(YT1-YT0)
4316     ZCLS=ZT0+XL*(ZT1-ZT0)
4317     * Set the cluster size and energy.
4318     NPAIR=1
4319     ECLS=0
4320     * See whether we were already done.
4321     IF(NTOT.GT.NTRFLX)THEN
4322     DONE=.TRUE.
4323     OK=.FALSE.
4324     ELSE
4325     DONE=.FALSE.
4326     ENDIF
4327     *** Fixed flux interval.
4328     ELSEIF(ITRTYP.EQ.8)THEN
4329     * Verify that the number of flux lines has been set.
4330     IF(.NOT.TRFLAG(7))THEN
4331     PRINT *,' !!!!!! TRACLS WARNING : The flux interval'//
4332     - ' has not been set; no clusters.'
4333     RETURN
4334     ENDIF
4335     ** On first call, compute the flux intervals.
4336     IF(NTOT.EQ.0)THEN
4337     * Set integration intervals.
4338     NV=5
4339     * Compute the inplane vector normal to the track.
4340     XP=(YT1-YT0)*FPROJC-(ZT1-ZT0)*FPROJB
4341     YP=(ZT1-ZT0)*FPROJA-(XT1-XT0)*FPROJC
4342     ZP=(XT1-XT0)*FPROJB-(YT1-YT0)*FPROJA
4343     * Compute the total flux, accepting positive and negative parts.
4344     CALL FLDIN5(XT0,YT0,ZT1,XT1,YT1,ZT1,XP,YP,ZP,Q,
4345     - NTRFLX*NV,0)
4346     IF(Q.GT.0)THEN
4347     ISIGN=+1
4348     ELSE
4349     ISIGN=-1
4350     ENDIF
4351     IF(LDEBUG)WRITE(LUNOUT,'('' ++++++ TRACLS DEBUG :'',
4352     - '' Total flux: '',E15.8,'' V, sign '',I1)')
4353     - Q,ISIGN
4354     * Compute the 1-sided flux in a number of steps.
4355     FLXSUM=0
4356     IERROR=0
4357     XL0FLX=-1
4358     DO 130 I=1,MXLIST
4359     CALL FLDIN5(
4360     - XT0+REAL(I-1)*(XT1-XT0)/REAL(MXLIST),
4361     - YT0+REAL(I-1)*(YT1-YT0)/REAL(MXLIST),
4362     - ZT0+REAL(I-1)*(ZT1-ZT0)/REAL(MXLIST),
4363     - XT0+REAL(I)*(XT1-XT0)/REAL(MXLIST),
4364     - YT0+REAL(I)*(YT1-YT0)/REAL(MXLIST),
4365     - ZT0+REAL(I)*(ZT1-ZT0)/REAL(MXLIST),
4366     - XP,YP,ZP,Q,NV,ISIGN)
4367     FLXCOO(I)=REAL(I)/REAL(MXLIST)
4368     IF(Q.GT.0)THEN
4369     FLXSUM=FLXSUM+Q
4370     IF(XL0FLX.LT.-0.5)XL0FLX=REAL(I-1)/REAL(MXLIST)
4371     ENDIF
4372     IF(Q.LT.0)IERROR=IERROR+1
4373     FLXTAB(I)=FLXSUM
4374     130 CONTINUE
4375     * Make sure that the sum is positive.
4376     IF(LDEBUG)WRITE(LUNOUT,'('' ++++++ TRACLS DEBUG :'',
4377     - '' Used flux: '',E15.8,'' V ''/26X,
4378     - ''Start offset: '',F10.3)') FLXSUM,XL0FLX
4379     IF(FLXSUM.LE.0)THEN
4380     PRINT *,' !!!!!! TRACLS WARNING : 1-Sided flux'//
4381     - ' integral is not > 0; no clusters.'
4382     RETURN
4383     ELSEIF(XL0FLX.LT.-0.5)THEN
4384     PRINT *,' !!!!!! TRACLS WARNING : No flux'//
4385     - ' interval without sign change found.'
4386     RETURN
4387     ELSEIF(IERROR.NE.0)THEN
4388     PRINT *,' ------ TRACLS MESSAGE : The flux'//
4389     - ' changes sign over the track; part of'//
4390     - ' the track not used.'
4391     ENDIF
4392     ENDIF
4393     ** Increment cluster counter.
4394     NTOT=NTOT+1
4395     * Compute new cluster position.
4396     IF(NTOT.EQ.1)THEN
4397     XL=XL0FLX
4398     DONE=.FALSE.
4399     ELSEIF((NTOT-1)*TRFLUX.LE.FLXSUM)THEN
4400     XL=DIVDIF(FLXCOO,FLXTAB,MXLIST,REAL(NTOT-1)*TRFLUX,1)
4401     DONE=.FALSE.
4402     ELSE
4403     XL=XL0FLX
4404     DONE=.TRUE.
4405     OK=.FALSE.
4406     ENDIF
4407     XCLS=XT0+XL*(XT1-XT0)
4408     YCLS=YT0+XL*(YT1-YT0)
4409     ZCLS=ZT0+XL*(ZT1-ZT0)
4410     * Set the cluster size and energy.
4411     NPAIR=1
4412     ECLS=0
4413     *** Other track types.
4414     ELSE
4415     PRINT *,' !!!!!! TRACLS WARNING : Unknown track type'//
4416     - ' requested; no clusters'
4417     XCLS=0
4418     YCLS=0
4419     ZCLS=0
4420     ECLS=0
4421     NPAIR=0
4422     DONE=.TRUE.
4423     OK=.FALSE.
4424     IFAIL=1
4425     RETURN
4426     ENDIF
4427     *** Seems to have worked, set the IFAIL flag.
4428     IFAIL=0
4429     RETURN
4430     *** Entry point for initialisation.
4431     ENTRY TRACLI
4432     IF(LIDENT)PRINT *,' /// ENTRY TRACLI ///'
4433     * Reset the number of clusters generated sofar.
4434     NTOT=0
4435     IVGA=0
4436     ETOT=0
4437     * Set flag that clustering can proceed.
4438     OK=.TRUE.
4439     *** Set the particle identifier, fixed number.
4440     IF(ITRTYP.EQ.1)THEN
4441     CALL OUTFMT(REAL(NTRLIN),2,AUX,NCAUX,'LEFT')
4442     PARTID=AUX(1:NCAUX)//' equally spaced points'
4443     * Equal.
4444     ELSEIF(ITRTYP.EQ.2)THEN
4445     PARTID='Equally spaced clusters'
4446     * Exponential.
4447     ELSEIF(ITRTYP.EQ.3)THEN
4448     PARTID='Exponentially spaced clusters'
4449     * Heed.
4450     ELSEIF(ITRTYP.EQ.4)THEN
4451     IF(TRENER.LT.0.001)THEN
4452     CALL OUTFMT(TRENER*1000000,2,AUX,NCAUX,'LEFT')
4453     PARTID=PNAME(1:NCPNAM)//', Ekin='//AUX(1:NCAUX)//' eV'
4454     ELSEIF(TRENER.LT.1)THEN
4455     CALL OUTFMT(TRENER*1000,2,AUX,NCAUX,'LEFT')
4456     PARTID=PNAME(1:NCPNAM)//', Ekin='//AUX(1:NCAUX)//' keV'
4457     ELSEIF(TRENER.LT.1000)THEN
4458     CALL OUTFMT(TRENER,2,AUX,NCAUX,'LEFT')
4459     PARTID=PNAME(1:NCPNAM)//', Ekin='//AUX(1:NCAUX)//' MeV'
4460     ELSEIF(TRENER.LT.1000000)THEN
4461     CALL OUTFMT(TRENER/1000,2,AUX,NCAUX,'LEFT')
4462     PARTID=PNAME(1:NCPNAM)//', Ekin='//AUX(1:NCAUX)//' GeV'
4463     ELSE
4464     CALL OUTFMT(TRENER/1000000,2,AUX,NCAUX,'LEFT')
4465     PARTID=PNAME(1:NCPNAM)//', Ekin='//AUX(1:NCAUX)//' TeV'
4466     ENDIF
4467     qgvga(1)=0
4468     qdel=0
4469     qcel(1)=0
4470     qrga=0
4471     * Weighted.
4472     ELSEIF(ITRTYP.EQ.5)THEN
4473     CALL OUTFMT(REAL(NTRSAM),2,AUX,NCAUX,'LEFT')
4474     PARTID=AUX(1:NCAUX)//' samples of '//FCNTRW(1:NCTRW)
4475     * Single cluster.
4476     ELSEIF(ITRTYP.EQ.6)THEN
4477     PARTID='Single cluster'
4478     * Fixed number of flux lines.
4479     ELSEIF(ITRTYP.EQ.7)THEN
4480     CALL OUTFMT(REAL(NTRFLX),2,AUX,NCAUX,'LEFT')
4481     PARTID=AUX(1:NCAUX)//' flux lines'
4482     * Constant flux intervals.
4483     ELSEIF(ITRTYP.EQ.8)THEN
4484     CALL OUTFMT(TRFLUX,2,AUX,NCAUX,'LEFT')
4485     PARTID='Flux intervals of '//AUX(1:NCAUX)//' V'
4486     * Anything else.
4487     ELSE
4488     PARTID='Unknown'
4489     ENDIF
4490     END
4491     +DECK,TRAPLT.
4492     SUBROUTINE TRAPLT
4493     *-----------------------------------------------------------------------
4494     * TRAPLT - Plots the track with the delta electrons.
4495     * (Last changed on 3/10/98.)
4496     *-----------------------------------------------------------------------
4497     implicit none
4498     +SEQ,DIMENSIONS.
4499     +SEQ,PARAMETERS.
4500     +SEQ,GASDATA.
4501     +SEQ,CELLDATA.
4502     +SEQ,volume.
4503     +SEQ,goevent.
4504     +SEQ,del.
4505     +SEQ,cel.
4506     +SEQ,abs.
4507     +SEQ,rga.
4508     +SEQ,lsgvga.
4509     REAL XCLS,YCLS,ZCLS
4510     DOUBLE PRECISION XPLDEL(pqcel),YPLDEL(pqcel),ZPLDEL(pqcel),
4511     - XPLVGA(pqgvga),YPLVGA(pqgvga),ZPLVGA(pqgvga),
4512     - XPL(2),YPL(2),ZPL(2),ETOT
4513     INTEGER NELEC,I,J,K,NPL
4514     *** Apparently a HEED generated track.
4515     IF(HEEDOK.AND.ITRTYP.EQ.4)THEN
4516     ** Pick up relevant portion of the virtual gamma's.
4517     ETOT=0
4518     NPL=0
4519     DO 20 I=1,qgvga(1)
4520     XCLS=XT0+COS(TRPHI)*pntgvga(1,INDPOS(I),1)-
4521     - SIN(TRPHI)*SIN(TRTH)*pntgvga(2,INDPOS(I),1)+
4522     - SIN(TRPHI)*COS(TRTH)*pntgvga(3,INDPOS(I),1)
4523     YCLS=YT0+COS(TRTH)*pntgvga(2,INDPOS(I),1)+
4524     - SIN(TRTH)*pntgvga(3,INDPOS(I),1)
4525     ZCLS=ZT0-SIN(TRPHI)*pntgvga(1,INDPOS(I),1)-
4526     - COS(TRPHI)*SIN(TRTH)*pntgvga(2,INDPOS(I),1)+
4527     - COS(TRPHI)*COS(TRTH)*pntgvga(3,INDPOS(I),1)
4528     ETOT=ETOT+egvga(INDPOS(I),1)
4529     NPL=NPL+1
4530     XPLVGA(NPL)=XCLS
4531     YPLVGA(NPL)=YCLS
4532     ZPLVGA(NPL)=ZCLS
4533     IF(ETOT.GE.TRENER)GOTO 25
4534     20 CONTINUE
4535     * All relevant virtual photons taken.
4536     25 CONTINUE
4537     * Set the appropriate representations.
4538     CALL GRATTS('TRACK','POLYLINE')
4539     CALL GRATTS('TRACK','POLYMARKER')
4540     * Plot the particle trajectory.
4541     IF(POLAR)CALL CF2CTR(XPLVGA,YPLVGA,XPLVGA,YPLVGA,NPL)
4542     IF(NPL.GT.1)THEN
4543     CALL PLAGPL(NPL,XPLVGA,YPLVGA,ZPLVGA)
4544     ELSEIF(NPL.EQ.1)THEN
4545     CALL PLAGPM(NPL,XPLVGA,YPLVGA,ZPLVGA)
4546     ENDIF
4547     ** Next plot each of the deltas and Auger electrons.
4548     ETOT=0
4549     * Loop over the virtual photons.
4550     DO 50 K=1,qgvga(1)
4551     * Loop over the associated delta's.
4552     DO 30 I=1,qdel
4553     IF(ptdel(I).NE.INDPOS(K).OR.edel(I).LE.0)GOTO 30
4554     * Set the attributes depending on the type.
4555     IF(sodel(I).EQ.0)THEN
4556     CALL GRATTS('DELTA-ELECTRON','POLYLINE')
4557     CALL GRATTS('DELTA-ELECTRON','POLYMARKER')
4558     ELSE
4559     CALL GRATTS('AUGER-ELECTRON','POLYLINE')
4560     CALL GRATTS('AUGER-ELECTRON','POLYMARKER')
4561     ENDIF
4562     * Store the starting point.
4563     XCLS=XT0+COS(TRPHI)*pntgvga(1,INDPOS(K),1)-
4564     - SIN(TRPHI)*SIN(TRTH)*pntgvga(2,INDPOS(K),1)+
4565     - SIN(TRPHI)*COS(TRTH)*pntgvga(3,INDPOS(K),1)
4566     YCLS=YT0+COS(TRTH)*pntgvga(2,INDPOS(K),1)+
4567     - SIN(TRTH)*pntgvga(3,INDPOS(K),1)
4568     ZCLS=ZT0-SIN(TRPHI)*pntgvga(1,INDPOS(K),1)-
4569     - COS(TRPHI)*SIN(TRTH)*pntgvga(2,INDPOS(K),1)+
4570     - COS(TRPHI)*COS(TRTH)*pntgvga(3,INDPOS(K),1)
4571     NELEC=1
4572     XPLDEL(NELEC)=XCLS
4573     YPLDEL(NELEC)=YCLS
4574     ZPLDEL(NELEC)=ZCLS
4575     nelec=0
4576     * Find the associated electrons.
4577     DO 40 J=1,qcel(1)
4578     IF(ndelcel(J,1).EQ.I)THEN
4579     NELEC=NELEC+1
4580     XCLS=XT0+COS(TRPHI)*pntcel(1,J,1)-
4581     - SIN(TRPHI)*SIN(TRTH)*pntcel(2,J,1)+
4582     - SIN(TRPHI)*COS(TRTH)*pntcel(3,J,1)
4583     YCLS=YT0+COS(TRTH)*pntcel(2,J,1)+
4584     - SIN(TRTH)*pntcel(3,J,1)
4585     ZCLS=ZT0-SIN(TRPHI)*pntcel(1,J,1)-
4586     - COS(TRPHI)*SIN(TRTH)*pntcel(2,J,1)+
4587     - COS(TRPHI)*COS(TRTH)*pntcel(3,J,1)
4588     XPLDEL(NELEC)=XCLS
4589     YPLDEL(NELEC)=YCLS
4590     ZPLDEL(NELEC)=ZCLS
4591     ENDIF
4592     40 CONTINUE
4593     * Keep track of total energy.
4594     IF(ETOT+edel(I).GT.TRENER)THEN
4595     NELEC=NELEC*(TRENER-ETOT)/edel(I)
4596     ETOT=TRENER+1
4597     ELSE
4598     ETOT=ETOT+edel(I)
4599     ENDIF
4600     * Plot the particle trajectory.
4601     IF(POLAR)CALL CF2CTR(XPLDEL,YPLDEL,XPLDEL,YPLDEL,NELEC)
4602     IF(NELEC.GT.1)THEN
4603     CALL PLAGPL(NELEC,XPLDEL,YPLDEL,ZPLDEL)
4604     ELSEIF(NELEC.EQ.1)THEN
4605     CALL PLAGPM(NELEC,XPLDEL,YPLDEL,ZPLDEL)
4606     ENDIF
4607     * Quit if energy limit reached.
4608     IF(ETOT.GE.TRENER)GOTO 60
4609     * Next delta.
4610     30 CONTINUE
4611     * Next virtual gamma.
4612     50 CONTINUE
4613     * Energy limit.
4614     60 CONTINUE
4615     ** Next plot the real photons.
4616     ETOT=0
4617     * Set attributes.
4618     CALL GRATTS('PHOTON','POLYLINE')
4619     CALL GRATTS('PHOTON','POLYMARKER')
4620     * Loop over virtual gamma's.
4621     DO 150 K=1,qgvga(1)
4622     XCLS=XT0+COS(TRPHI)*pntgvga(1,INDPOS(K),1)-
4623     - SIN(TRPHI)*SIN(TRTH)*pntgvga(2,INDPOS(K),1)+
4624     - SIN(TRPHI)*COS(TRTH)*pntgvga(3,INDPOS(K),1)
4625     YCLS=YT0+COS(TRTH)*pntgvga(2,INDPOS(K),1)+
4626     - SIN(TRTH)*pntgvga(3,INDPOS(K),1)
4627     ZCLS=ZT0-SIN(TRPHI)*pntgvga(1,INDPOS(K),1)-
4628     - COS(TRPHI)*SIN(TRTH)*pntgvga(2,INDPOS(K),1)+
4629     - COS(TRPHI)*COS(TRTH)*pntgvga(3,INDPOS(K),1)
4630     XPL(1)=XCLS
4631     YPL(1)=YCLS
4632     ZPL(1)=ZCLS
4633     * Find the corresponding real photons and plot them.
4634     DO 130 I=1,qrga
4635     IF(ptrga(I).NE.INDPOS(K))GOTO 130
4636     XCLS=XT0+COS(TRPHI)*pntrga(1,I)-
4637     - SIN(TRPHI)*SIN(TRTH)*pntrga(2,I)+
4638     - SIN(TRPHI)*COS(TRTH)*pntrga(3,I)
4639     YCLS=YT0+COS(TRTH)*pntrga(2,I)+
4640     - SIN(TRTH)*pntrga(3,I)
4641     ZCLS=ZT0-SIN(TRPHI)*pntrga(1,I)-
4642     - COS(TRPHI)*SIN(TRTH)*pntrga(2,I)+
4643     - COS(TRPHI)*COS(TRTH)*pntrga(3,I)
4644     XPL(2)=XCLS
4645     YPL(2)=YCLS
4646     ZPL(2)=ZCLS
4647     IF(POLAR)CALL CF2CTR(XPL,YPL,XPL,YPL,2)
4648     CALL PLAGPL(2,XPL,YPL,ZPL)
4649     * Keep track of total energy.
4650     ETOT=ETOT+erga(I)
4651     * Quit if energy limit reached.
4652     IF(ETOT.GE.TRENER)GOTO 160
4653     * Next real photon.
4654     130 CONTINUE
4655     * Next virtual gamma.
4656     150 CONTINUE
4657     * Energy limit.
4658     160 CONTINUE
4659     *** Any other kind of track.
4660     ELSE
4661     * Set the appropriate representations.
4662     CALL GRATTS('TRACK','POLYLINE')
4663     CALL GRATTS('TRACK','POLYMARKER')
4664     * And plot the track as a straight line.
4665     XPL(1)=XT0
4666     YPL(1)=YT0
4667     ZPL(1)=ZT0
4668     XPL(2)=XT1
4669     YPL(2)=YT1
4670     ZPL(2)=ZT1
4671     IF(POLAR)CALL CF2CTR(XPL,YPL,XPL,YPL,2)
4672     CALL PLAGPL(2,XPL,YPL,ZPL)
4673     ENDIF
4674     END
4675     +DECK,TRAREA.
4676     SUBROUTINE TRAREA
4677     *-----------------------------------------------------------------------
4678     * TRAREA - Reads a track definition
4679     * (Last changed on 14/ 5/99.)
4680     *-----------------------------------------------------------------------
4681     implicit none
4682     +SEQ,DIMENSIONS.
4683     +SEQ,PARAMETERS.
4684     +SEQ,PRINTPLOT.
4685     +SEQ,CELLDATA.
4686     +SEQ,GASDATA.
4687     +SEQ,GLOBALS.
4688     INTEGER NWORD,INPCMP,INPTYP,IFAIL1,IFAIL2,IFAIL3,IFAIL4,IFAIL5,
4689     - IFAIL6,NLINR,I,J,INEXT,NCAUX,NRES,NVAR,IENWGT,NCNAME,
4690     - MODVAR(1),NREXP,MODRES(1),NSAMR,IRCOOR,IRWGT,ISCOOR,ISWGT,
4691     - MATSLT,IORD,NC1,NC2,NC3,NC4,NC5,NC6,NFLXR
4692     REAL XMASS,XENER,XDIST,XCHAR,XNORM,XT0D,XT1D,YT0D,YT1D,ZT0D,ZT1D,
4693     - FACT,XDIR,YDIR,ZDIR,RES(1),VAR(1),WGTSUM,FLXR
4694     LOGICAL START,END,DIST,DIR,ENER,MASS,CHARGE,USE(1),OK
4695     EXTERNAL INPCMP,INPTYP,MATSLT
4696     CHARACTER*10 VARLIS(1),NAME
4697     CHARACTER*13 AUX1,AUX2,AUX3,AUX4,AUX5,AUX6
4698     CHARACTER*20 AUX
4699     *** Identify the procedure if requested.
4700     IF(LIDENT)PRINT *,' /// ROUTINE TRAREA ///'
4701     *** Count words.
4702     CALL INPNUM(NWORD)
4703     *** Perhaps only printing has been requested.
4704     IF(NWORD.EQ.1)THEN
4705     * Track location.
4706     IF(TRFLAG(1))THEN
4707     XT0D=XT0
4708     YT0D=YT0
4709     ZT0D=ZT0
4710     XT1D=XT1
4711     YT1D=YT1
4712     ZT1D=ZT1
4713     IF(POLAR)THEN
4714     CALL CFMCTP(XT0D,YT0D,XT0D,YT0D,1)
4715     CALL CFMCTP(XT1D,YT1D,XT1D,YT1D,1)
4716     ENDIF
4717     CALL OUTFMT(XT0D,2,AUX1,NC1,'LEFT')
4718     CALL OUTFMT(YT0D,2,AUX2,NC2,'LEFT')
4719     CALL OUTFMT(ZT0D,2,AUX3,NC3,'LEFT')
4720     CALL OUTFMT(XT1D,2,AUX4,NC4,'LEFT')
4721     CALL OUTFMT(YT1D,2,AUX5,NC5,'LEFT')
4722     CALL OUTFMT(ZT1D,2,AUX6,NC6,'LEFT')
4723     WRITE(LUNOUT,'('' The current track runs from '',
4724     - ''('',A,'','',A,'','',A,'') to '',
4725     - ''('',A,'','',A,'','',A,'').'')')
4726     - AUX1(1:NC1),AUX2(1:NC2),AUX3(1:NC3),
4727     - AUX4(1:NC4),AUX5(1:NC5),AUX6(1:NC6)
4728     ELSE
4729     WRITE(LUNOUT,'('' The location of the track is'',
4730     - '' not yet defined.'')')
4731     ENDIF
4732     * Particle type.
4733     IF(TRFLAG(2))THEN
4734     CALL OUTFMT(TRMASS,2,AUX1,NC1,'LEFT')
4735     CALL OUTFMT(TRENER,2,AUX2,NC2,'LEFT')
4736     CALL OUTFMT(TRCHAR,2,AUX3,NC3,'LEFT')
4737     WRITE(LUNOUT,'('' The particle is a '',A,'' with a'',
4738     - '' mass of '',A,'' MeV,''/'' an energy of '',A,
4739     - '' MeV and a charge of '',A,
4740     - '' proton charges.'')') PNAME(1:NCPNAM),
4741     - AUX1(1:NC1),AUX2(1:NC2),AUX3(1:NC3)
4742     ENDIF
4743     * Clustering type: fixed.
4744     IF(ITRTYP.EQ.1.AND.TRFLAG(3))THEN
4745     CALL OUTFMT(REAL(NTRLIN),2,AUX1,NC1,'LEFT')
4746     WRITE(LUNOUT,'('' There will be '',A,'' equally'',
4747     - '' spaced clusters on the track.'')') AUX1(1:NC1)
4748     ELSEIF(ITRTYP.EQ.1.AND..NOT.TRFLAG(3))THEN
4749     WRITE(LUNOUT,'('' There will be equally'',
4750     - '' spaced clusters on the track.'')')
4751     * Clustering type: equal spacing.
4752     ELSEIF(ITRTYP.EQ.2)THEN
4753     WRITE(LUNOUT,'('' Clusters will be equally spaced'',
4754     - '' respecting the mean from the gas section.'')')
4755     * Clustering type: exponential spacing.
4756     ELSEIF(ITRTYP.EQ.3)THEN
4757     WRITE(LUNOUT,'('' Clusters will be exponentially'',
4758     - '' spaced with a mean distance as entered'',
4759     - '' in the gas section.'')')
4760     * Clustering type: processing by HEED.
4761     ELSEIF(ITRTYP.EQ.4)THEN
4762     WRITE(LUNOUT,'('' Clusters will be generated by'',
4763     - '' HEED,'')')
4764     IF(LTRMS)THEN
4765     WRITE(LUNOUT,'('' the incoming particle'',
4766     - '' undergoes multiple scattering,'')')
4767     ELSE
4768     WRITE(LUNOUT,'('' the incoming particle does'',
4769     - '' not undergo multiple scattering,'')')
4770     ENDIF
4771     IF(LTRDEL)THEN
4772     WRITE(LUNOUT,'('' delta electrons have a'',
4773     - '' spatial extent.'')')
4774     ELSE
4775     WRITE(LUNOUT,'('' delta electrons are'',
4776     - '' compactified onto the main track.'')')
4777     ENDIF
4778     * Weighted cluster location distribution.
4779     ELSEIF(ITRTYP.EQ.5)THEN
4780     CALL OUTFMT(REAL(NTRSAM),2,AUX1,NC1,'LEFT')
4781     WRITE(LUNOUT,'('' There will be '',A,'' clusters'',
4782     - '' at positions weighted according to '',A)')
4783     - AUX1(1:NC1),FCNTRW(1:NCTRW)
4784     * Single cluster.
4785     ELSEIF(ITRTYP.EQ.6)THEN
4786     WRITE(LUNOUT,'('' There will be a single cluster'',
4787     - '' at a random position.'')')
4788     * Equal flux lines.
4789     ELSEIF(ITRTYP.EQ.7)THEN
4790     CALL OUTFMT(REAL(NTRFLX),2,AUX1,NC1,'LEFT')
4791     WRITE(LUNOUT,'('' There will be '',A,'' clusters'',
4792     - '' at equal flux intervals.'')') AUX1(1:NC1)
4793     * Flux intervals.
4794     ELSEIF(ITRTYP.EQ.8)THEN
4795     CALL OUTFMT(TRFLUX,2,AUX1,NC1,'LEFT')
4796     WRITE(LUNOUT,'('' Clusters will be spaced by a'',
4797     - '' flux of '',A,'' V.'')') AUX1(1:NC1)
4798     ENDIF
4799     RETURN
4800     ENDIF
4801     *** Preset flags.
4802     START =.FALSE.
4803     END =.FALSE.
4804     DIST =.FALSE.
4805     DIR =.FALSE.
4806     ENER =.FALSE.
4807     MASS =.FALSE.
4808     CHARGE=.FALSE.
4809     *** Compute default track parameters.
4810     XT0D=XT0
4811     YT0D=YT0
4812     ZT0D=ZT0
4813     XT1D=XT1
4814     YT1D=YT1
4815     ZT1D=ZT1
4816     IF(POLAR)THEN
4817     CALL CFMCTP(XT0D,YT0D,XT0D,YT0D,1)
4818     CALL CFMCTP(XT1D,YT1D,XT1D,YT1D,1)
4819     ENDIF
4820     *** Format: (x0,y0,z0) (x1,y1,z1)
4821     IF(NWORD.GE.7.AND.INPTYP(2).GE.1.AND.INPTYP(3).GE.1.AND.
4822     - INPTYP(4).GE.1.AND.INPTYP(5).GE.1.AND.
4823     - INPTYP(6).GE.1.AND.INPTYP(7).GE.1)THEN
4824     CALL INPCHK(2,2,IFAIL1)
4825     CALL INPCHK(3,2,IFAIL2)
4826     CALL INPCHK(4,2,IFAIL3)
4827     CALL INPCHK(5,2,IFAIL4)
4828     CALL INPCHK(6,2,IFAIL5)
4829     CALL INPCHK(7,2,IFAIL6)
4830     CALL INPRDR(2,XT0D,XT0D)
4831     CALL INPRDR(3,YT0D,YT0D)
4832     CALL INPRDR(4,ZT0D,ZT0D)
4833     CALL INPRDR(5,XT1D,XT1D)
4834     CALL INPRDR(6,YT1D,YT1D)
4835     CALL INPRDR(7,ZT1D,ZT1D)
4836     START=.TRUE.
4837     END=.TRUE.
4838     INEXT=8
4839     *** Format: (x0,y0) (x1,y1)
4840     ELSEIF(NWORD.GE.5.AND.INPTYP(2).GE.1.AND.INPTYP(3).GE.1.AND.
4841     - INPTYP(4).GE.1.AND.INPTYP(5).GE.1)THEN
4842     CALL INPCHK(2,2,IFAIL1)
4843     CALL INPCHK(3,2,IFAIL2)
4844     CALL INPCHK(4,2,IFAIL3)
4845     CALL INPCHK(5,2,IFAIL4)
4846     CALL INPRDR(2,XT0D,XT0D)
4847     CALL INPRDR(3,YT0D,YT0D)
4848     ZT0D=0
4849     CALL INPRDR(4,XT1D,XT1D)
4850     CALL INPRDR(5,YT1D,YT1D)
4851     ZT1D=0
4852     START=.TRUE.
4853     END=.TRUE.
4854     INEXT=6
4855     *** Format: (x0,y0,z0)
4856     ELSEIF(NWORD.GE.4.AND.INPTYP(2).GE.1.AND.INPTYP(3).GE.1.AND.
4857     - INPTYP(4).GE.1)THEN
4858     CALL INPCHK(2,2,IFAIL1)
4859     CALL INPCHK(3,2,IFAIL2)
4860     CALL INPCHK(4,2,IFAIL3)
4861     CALL INPRDR(2,XT0D,XT0D)
4862     CALL INPRDR(3,YT0D,YT0D)
4863     CALL INPRDR(4,ZT0D,ZT0D)
4864     START=.TRUE.
4865     INEXT=5
4866     *** Format: (x0,y0)
4867     ELSEIF(NWORD.GE.3.AND.INPTYP(2).GE.1.AND.INPTYP(3).GE.1)THEN
4868     CALL INPCHK(2,2,IFAIL1)
4869     CALL INPCHK(3,2,IFAIL2)
4870     CALL INPRDR(2,XT0D,XT0D)
4871     CALL INPRDR(3,YT0D,YT0D)
4872     ZT0D=0
4873     START=.TRUE.
4874     INEXT=4
4875     ELSE
4876     INEXT=2
4877     ENDIF
4878     *** Now scan from here on for further arguments.
4879     DO 10 I=1,NWORD
4880     IF(I.LT.INEXT)GOTO 10
4881     * Could be a starting point.
4882     IF(INPCMP(I,'FR#OM')+INPCMP(I,'START#ING-#POINT').NE.0)THEN
4883     IF(NWORD.LT.I+2.OR.
4884     - INPTYP(I+1).LE.0.OR.INPTYP(I+2).LE.0)THEN
4885     CALL INPMSG(I,'Has 2 or 3 real arguments.')
4886     ELSEIF(INPTYP(I+3).LE.0)THEN
4887     CALL INPCHK(I+1,2,IFAIL1)
4888     CALL INPCHK(I+2,2,IFAIL2)
4889     CALL INPRDR(I+1,XT0D,XT0D)
4890     CALL INPRDR(I+2,YT0D,YT0D)
4891     ZT0D=0
4892     START=.TRUE.
4893     INEXT=I+3
4894     ELSE
4895     CALL INPCHK(I+1,2,IFAIL1)
4896     CALL INPCHK(I+2,2,IFAIL2)
4897     CALL INPCHK(I+3,2,IFAIL3)
4898     CALL INPRDR(I+1,XT0D,XT0D)
4899     CALL INPRDR(I+2,YT0D,YT0D)
4900     CALL INPRDR(I+3,ZT0D,ZT0D)
4901     START=.TRUE.
4902     INEXT=I+4
4903     ENDIF
4904     * Could be an end point.
4905     ELSEIF(INPCMP(I,'TO')+INPCMP(I,'END-#POINT').NE.0)THEN
4906     IF(NWORD.LT.I+2.OR.
4907     - INPTYP(I+1).LE.0.OR.INPTYP(I+2).LE.0)THEN
4908     CALL INPMSG(I,'Has 2 or 3 real arguments.')
4909     ELSEIF(INPTYP(I+3).LE.0)THEN
4910     CALL INPCHK(I+1,2,IFAIL1)
4911     CALL INPCHK(I+2,2,IFAIL2)
4912     CALL INPRDR(I+1,XT1D,XT1D)
4913     CALL INPRDR(I+2,YT1D,YT1D)
4914     ZT1D=0
4915     END=.TRUE.
4916     INEXT=I+3
4917     ELSE
4918     CALL INPCHK(I+1,2,IFAIL1)
4919     CALL INPCHK(I+2,2,IFAIL2)
4920     CALL INPCHK(I+3,2,IFAIL3)
4921     CALL INPRDR(I+1,XT1D,XT1D)
4922     CALL INPRDR(I+2,YT1D,YT1D)
4923     CALL INPRDR(I+3,ZT1D,ZT1D)
4924     END=.TRUE.
4925     INEXT=I+4
4926     ENDIF
4927     * Could be a direction vector.
4928     ELSEIF(INPCMP(I,'DIR#ECTION').NE.0)THEN
4929     IF(INPCMP(I+1,'X')+INPCMP(I+1,'POS#ITIVE-X').NE.0)THEN
4930     TRXDIR=+1
4931     TRYDIR= 0
4932     TRZDIR= 0
4933     DIR=.TRUE.
4934     INEXT=I+2
4935     ELSEIF(INPCMP(I+1,'NEG#ATIVE-X').NE.0)THEN
4936     TRXDIR=-1
4937     TRYDIR= 0
4938     TRZDIR= 0
4939     DIR=.TRUE.
4940     INEXT=I+2
4941     ELSEIF(INPCMP(I+1,'Y')+INPCMP(I+1,'POS#ITIVE-Y').NE.0)THEN
4942     TRXDIR= 0
4943     TRYDIR=+1
4944     TRZDIR= 0
4945     DIR=.TRUE.
4946     INEXT=I+2
4947     ELSEIF(INPCMP(I+1,'NEG#ATIVE-Y').NE.0)THEN
4948     TRXDIR= 0
4949     TRYDIR=-1
4950     TRZDIR= 0
4951     DIR=.TRUE.
4952     INEXT=I+2
4953     ELSEIF(INPCMP(I+1,'Z')+INPCMP(I+1,'POS#ITIVE-Z').NE.0)THEN
4954     TRXDIR= 0
4955     TRYDIR= 0
4956     TRZDIR=+1
4957     DIR=.TRUE.
4958     INEXT=I+2
4959     ELSEIF(INPCMP(I+1,'NEG#ATIVE-Z').NE.0)THEN
4960     TRXDIR= 0
4961     TRYDIR= 0
4962     TRZDIR=-1
4963     DIR=.TRUE.
4964     INEXT=I+2
4965     ELSEIF(NWORD.LT.I+2.OR.
4966     - INPTYP(I+1).LE.0.OR.INPTYP(I+2).LE.0)THEN
4967     CALL INPMSG(I,'Has 2 or 3 real arguments.')
4968     ELSEIF(INPTYP(I+3).LE.0)THEN
4969     CALL INPCHK(I+1,2,IFAIL1)
4970     CALL INPCHK(I+2,2,IFAIL2)
4971     CALL INPRDR(I+1,XDIR,0.0)
4972     CALL INPRDR(I+2,YDIR,0.0)
4973     ZDIR=0.0
4974     DIR=.TRUE.
4975     INEXT=I+3
4976     ELSE
4977     CALL INPCHK(I+1,2,IFAIL1)
4978     CALL INPCHK(I+2,2,IFAIL2)
4979     CALL INPCHK(I+3,2,IFAIL3)
4980     CALL INPRDR(I+1,XDIR,0.0)
4981     CALL INPRDR(I+2,YDIR,0.0)
4982     CALL INPRDR(I+3,ZDIR,0.0)
4983     DIR=.TRUE.
4984     INEXT=I+4
4985     ENDIF
4986     IF(DIR)THEN
4987     XNORM=SQRT(XDIR**2+YDIR**2+ZDIR**2)
4988     IF(XNORM.LE.0)THEN
4989     CALL INPMSG(I,'Vector has norm 0')
4990     DIR=.FALSE.
4991     ELSE
4992     XDIR=XDIR/XNORM
4993     YDIR=YDIR/XNORM
4994     ZDIR=ZDIR/XNORM
4995     ENDIF
4996     ENDIF
4997     * Could be a range.
4998     ELSEIF(INPCMP(I,'DIST#ANCE').NE.0.OR.
4999     - INPCMP(I,'RANGE').NE.0)THEN
5000     IF(NWORD.LT.I+1.OR.INPTYP(I+1).LE.0)THEN
5001     CALL INPMSG(I,'Has 1 real argument.')
5002     ELSE
5003     CALL INPCHK(I+1,2,IFAIL1)
5004     CALL INPRDR(I+1,XDIST,-1.0)
5005     IF(XDIST.LT.0)THEN
5006     CALL INPMSG(I+1,'Range is not >= 0.')
5007     ELSE
5008     TRDIST=XDIST
5009     DIST=.TRUE.
5010     ENDIF
5011     INEXT=I+2
5012     ENDIF
5013     * Could be a particle identifier [PDG, Phys Rev D 54 (1996)]
5014     ELSEIF(INPCMP(I,'ELE#CTRON')+INPCMP(I,'E-M#INUS').NE.0)THEN
5015     TRMASS=0.51099907
5016     TRCHAR=-1
5017     MASS=.TRUE.
5018     CHARGE=.TRUE.
5019     PNAME='electron-'
5020     NCPNAM=9
5021     ITRTYP=4
5022     ELSEIF(INPCMP(I,'POS#ITRON')+INPCMP(I,'E-P#LUS')+
5023     - INPCMP(I,'E+').NE.0)THEN
5024     TRMASS=0.51099907
5025     TRCHAR=+1
5026     MASS=.TRUE.
5027     CHARGE=.TRUE.
5028     PNAME='electron+'
5029     NCPNAM=9
5030     ITRTYP=4
5031     ELSEIF(INPCMP(I,'MU#ON-#MINUS').NE.0)THEN
5032     TRMASS=105.658389
5033     TRCHAR=-1
5034     MASS=.TRUE.
5035     CHARGE=.TRUE.
5036     PNAME='mu-'
5037     NCPNAM=3
5038     ITRTYP=4
5039     ELSEIF(INPCMP(I,'MU#ON-P#LUS')+INPCMP(I,'MU+').NE.0)THEN
5040     TRMASS=105.658389
5041     TRCHAR=+1
5042     MASS=.TRUE.
5043     CHARGE=.TRUE.
5044     PNAME='mu+'
5045     NCPNAM=3
5046     ITRTYP=4
5047     ELSEIF(INPCMP(I,'TAU-#MINUS').NE.0)THEN
5048     TRMASS=1777.00
5049     TRCHAR=-1
5050     MASS=.TRUE.
5051     CHARGE=.TRUE.
5052     PNAME='tau-'
5053     NCPNAM=4
5054     ITRTYP=4
5055     ELSEIF(INPCMP(I,'TAU-P#LUS')+INPCMP(I,'TAU+').NE.0)THEN
5056     TRMASS=1777.00
5057     TRCHAR=+1
5058     MASS=.TRUE.
5059     CHARGE=.TRUE.
5060     PNAME='tau+'
5061     NCPNAM=4
5062     ITRTYP=4
5063     ELSEIF(INPCMP(I,'GAMMA')+INPCMP(I,'PHOTON').NE.0)THEN
5064     CALL INPMSG(I,'Photons not yet available.')
5065     ELSEIF(INPCMP(I,'PI#ON-#MINUS').NE.0)THEN
5066     TRMASS=139.56995
5067     TRCHAR=-1
5068     MASS=.TRUE.
5069     CHARGE=.TRUE.
5070     PNAME='pi-'
5071     NCPNAM=3
5072     ITRTYP=4
5073     ELSEIF(INPCMP(I,'PI#ON-0')+INPCMP(I,'PI#ON-Z#ERO')+
5074     - INPCMP(I,'PI0').NE.0)THEN
5075     TRMASS=134.9764
5076     TRCHAR= 0
5077     MASS=.TRUE.
5078     CHARGE=.TRUE.
5079     PNAME='pi0'
5080     NCPNAM=3
5081     ITRTYP=4
5082     ELSEIF(INPCMP(I,'PI#ON-PLUS')+INPCMP(I,'PI+').NE.0)THEN
5083     TRMASS=139.56995
5084     TRCHAR=+1
5085     MASS=.TRUE.
5086     CHARGE=.TRUE.
5087     PNAME='pi+'
5088     NCPNAM=3
5089     ITRTYP=4
5090     ELSEIF(INPCMP(I,'K#AON-#MINUS').NE.0)THEN
5091     TRMASS=493.677
5092     TRCHAR=-1
5093     MASS=.TRUE.
5094     CHARGE=.TRUE.
5095     PNAME='K-'
5096     NCPNAM=2
5097     ITRTYP=4
5098     ELSEIF(INPCMP(I,'K#AON-0-#SHORT')+INPCMP(I,'K#AON-0-#LONG')+
5099     - INPCMP(I,'K0-#SHORT')+INPCMP(I,'K0-#LONG')+
5100     - INPCMP(I,'K#AON-Z#ERO-#SHORT')+
5101     - INPCMP(I,'K#AON-Z#ERO-#LONG')+
5102     - INPCMP(I,'K0-#SHORT')+INPCMP(I,'K0-#LONG').NE.0)THEN
5103     TRMASS=497.672
5104     TRCHAR= 0
5105     MASS=.TRUE.
5106     CHARGE=.TRUE.
5107     PNAME='K0'
5108     NCPNAM=2
5109     ITRTYP=4
5110     ELSEIF(INPCMP(I,'K#AON-P#LUS')+INPCMP(I,'K+').NE.0)THEN
5111     TRMASS=493.677
5112     TRCHAR=-1
5113     MASS=.TRUE.
5114     CHARGE=.TRUE.
5115     PNAME='K+'
5116     NCPNAM=2
5117     ITRTYP=4
5118     ELSEIF(INPCMP(I,'PR#OTON').NE.0)THEN
5119     TRMASS=938.27231
5120     TRCHAR=+1
5121     MASS=.TRUE.
5122     CHARGE=.TRUE.
5123     PNAME='proton'
5124     NCPNAM=6
5125     ITRTYP=4
5126     ELSEIF(INPCMP(I,'ANTI-PR#OTON').NE.0)THEN
5127     TRMASS=938.27231
5128     TRCHAR=-1
5129     MASS=.TRUE.
5130     CHARGE=.TRUE.
5131     PNAME='antiproton'
5132     NCPNAM=10
5133     ITRTYP=4
5134     ELSEIF(INPCMP(I,'N#EUTRON')+INPCMP(I,'ANTI-N#EUTRON').NE.0)THEN
5135     TRMASS=939.56563
5136     TRCHAR= 0
5137     MASS=.TRUE.
5138     CHARGE=.TRUE.
5139     PNAME='neutron'
5140     NCPNAM=7
5141     ITRTYP=4
5142     * Manually described particle, first mass.
5143     ELSEIF(INPCMP(I,'MASS').NE.0)THEN
5144     IF(NWORD.LT.I+1.OR.INPTYP(I+1).LE.0)THEN
5145     CALL INPMSG(I,'Must have 1 real argument')
5146     ELSE
5147     CALL INPCHK(I+1,2,IFAIL1)
5148     CALL INPRDR(I+1,XMASS,TRMASS)
5149     IF(I+2.LE.NWORD.AND.INPCMP(I+2,'EV').NE.0)THEN
5150     FACT=1E-6
5151     INEXT=I+3
5152     ELSEIF(I+2.LE.NWORD.AND.INPCMP(I+2,'KEV').NE.0)THEN
5153     FACT=1E-3
5154     INEXT=I+3
5155     ELSEIF(I+2.LE.NWORD.AND.INPCMP(I+2,'MEV').NE.0)THEN
5156     FACT=1
5157     INEXT=I+3
5158     ELSEIF(I+2.LE.NWORD.AND.INPCMP(I+2,'GEV').NE.0)THEN
5159     FACT=1E+3
5160     INEXT=I+3
5161     ELSEIF(I+2.LE.NWORD.AND.INPCMP(I+2,'TEV').NE.0)THEN
5162     FACT=1E+6
5163     INEXT=I+3
5164     ELSE
5165     FACT=1
5166     INEXT=I+2
5167     ENDIF
5168     IF(XMASS.LT.0)THEN
5169     CALL INPMSG(I+1,'Mass is not >= 0.')
5170     ELSE
5171     TRMASS=FACT*XMASS
5172     MASS=.TRUE.
5173     ITRTYP=4
5174     IF(TRMASS.LE.1)THEN
5175     CALL OUTFMT(ANINT(TRMASS*1000)/1000,2,
5176     - AUX,NCAUX,'LEFT')
5177     ELSE
5178     CALL OUTFMT(ANINT(TRMASS),2,
5179     - AUX,NCAUX,'LEFT')
5180     ENDIF
5181     PNAME='m('//AUX(1:NCAUX)//')'
5182     NCPNAM=MIN(LEN(PNAME),NCAUX+3)
5183     ENDIF
5184     ENDIF
5185     * Charge.
5186     ELSEIF(INPCMP(I,'CH#ARGE').NE.0)THEN
5187     IF(NWORD.LT.I+1.OR.INPTYP(I+1).LE.0)THEN
5188     CALL INPMSG(I,'Must have 1 real argument')
5189     ELSE
5190     CALL INPCHK(I+1,2,IFAIL1)
5191     CALL INPRDR(I+1,XCHAR,TRCHAR)
5192     IF(ABS(XCHAR).LT.0.99.OR.ABS(XCHAR).GT.1.01)THEN
5193     CALL INPMSG(I,'Currently only +1 or -1.')
5194     ELSE
5195     TRCHAR=XCHAR
5196     CHARGE=.TRUE.
5197     ITRTYP=4
5198     ENDIF
5199     INEXT=I+2
5200     ENDIF
5201     * Energy of the particle.
5202     ELSEIF(INPCMP(I,'ENE#RGY').NE.0)THEN
5203     IF(NWORD.LT.I+1.OR.INPTYP(I+1).LE.0)THEN
5204     CALL INPMSG(I,'Must have 1 real argument')
5205     ELSE
5206     CALL INPCHK(I+1,2,IFAIL1)
5207     CALL INPRDR(I+1,XENER,TRENER)
5208     IF(I+2.LE.NWORD.AND.INPCMP(I+2,'EV').NE.0)THEN
5209     FACT=1E-6
5210     INEXT=I+3
5211     ELSEIF(I+2.LE.NWORD.AND.INPCMP(I+2,'KEV').NE.0)THEN
5212     FACT=1E-3
5213     INEXT=I+3
5214     ELSEIF(I+2.LE.NWORD.AND.INPCMP(I+2,'MEV').NE.0)THEN
5215     FACT=1
5216     INEXT=I+3
5217     ELSEIF(I+2.LE.NWORD.AND.INPCMP(I+2,'GEV').NE.0)THEN
5218     FACT=1E+3
5219     INEXT=I+3
5220     ELSEIF(I+2.LE.NWORD.AND.INPCMP(I+2,'TEV').NE.0)THEN
5221     FACT=1E+6
5222     INEXT=I+3
5223     ELSE
5224     FACT=1
5225     INEXT=I+2
5226     ENDIF
5227     IF(XENER.LE.0)THEN
5228     CALL INPMSG(I+1,'Energy is not > 0.')
5229     ELSE
5230     TRENER=FACT*XENER
5231     ENER=.TRUE.
5232     ITRTYP=4
5233     ENDIF
5234     ENDIF
5235     * Delta electrons or not.
5236     ELSEIF(INPCMP(I,'DELTA-#ELECTRONS').NE.0)THEN
5237     LTRDEL=.TRUE.
5238     ITRTYP=4
5239     ELSEIF(INPCMP(I,'NODELTA-#ELECTRONS').NE.0)THEN
5240     LTRDEL=.FALSE.
5241     * Trace delta electrons or not.
5242     ELSEIF(INPCMP(I,'TR#ACE-DELTA-#ELECTRONS').NE.0)THEN
5243     LTREXB=.TRUE.
5244     ITRTYP=4
5245     ELSEIF(INPCMP(I,'NOTR#ACE-DELTA-#ELECTRONS').NE.0)THEN
5246     LTREXB=.FALSE.
5247     * Multiple scattering or not.
5248     ELSEIF(INPCMP(I,'MULT#IPLE-SC#ATTERING').NE.0)THEN
5249     LTRMS=.TRUE.
5250     ITRTYP=4
5251     ELSEIF(INPCMP(I,'NOMULT#IPLE-SC#ATTERING').NE.0)THEN
5252     LTRMS=.FALSE.
5253     * Track interpolation or not.
5254     ELSEIF(INPCMP(I,'INT#ERPOLATE-TR#ACK').NE.0)THEN
5255     LTRINT=.TRUE.
5256     ELSEIF(INPCMP(I,'NOINT#ERPOLATE-TR#ACK').NE.0)THEN
5257     LTRINT=.FALSE.
5258     * Number of points on the track.
5259     ELSEIF(INPCMP(I,'LINE#S')+INPCMP(I,'POINT#S').NE.0)THEN
5260     IF(NWORD.LT.I+1.OR.INPTYP(I+1).LE.0)THEN
5261     CALL INPMSG(I,'Must have 1 integer argument')
5262     ELSE
5263     CALL INPCHK(I+1,1,IFAIL1)
5264     CALL INPRDI(I+1,NLINR,NTRLIN)
5265     IF(NLINR.LT.0)THEN
5266     CALL INPMSG(I+1,'Number is not > 0.')
5267     ELSE
5268     NTRLIN=NLINR
5269     TRFLAG(3)=.TRUE.
5270     ITRTYP=1
5271     ENDIF
5272     INEXT=I+2
5273     ENDIF
5274     * Number of sampling points on the track.
5275     ELSEIF(INPCMP(I,'SAMP#LING')+INPCMP(I,'SAMP#LES').NE.0)THEN
5276     IF(NWORD.LT.I+1.OR.INPTYP(I+1).LE.0)THEN
5277     CALL INPMSG(I,'Must have 1 integer argument')
5278     ELSE
5279     CALL INPCHK(I+1,1,IFAIL1)
5280     CALL INPRDI(I+1,NSAMR,NTRSAM)
5281     IF(NLINR.LT.0)THEN
5282     CALL INPMSG(I+1,'Number is not > 0.')
5283     ELSE
5284     NTRSAM=NSAMR
5285     TRFLAG(5)=.TRUE.
5286     ITRTYP=5
5287     ENDIF
5288     INEXT=I+2
5289     ENDIF
5290     ** Weighting function.
5291     ELSEIF(INPCMP(I,'WEIGHT#ING-F#UNCTION').NE.0)THEN
5292     IF(NWORD.LT.I+1)THEN
5293     CALL INPMSG(I,'Should have an argument')
5294     * In the form of matrices.
5295     ELSEIF(INPCMP(I+2,'VS').NE.0.AND.I+3.LE.NWORD)THEN
5296     * Locate the matrices.
5297     IRCOOR=0
5298     IRWGT=0
5299     CALL INPSTR(I+1,I+1,NAME,NCNAME)
5300     DO 110 J=1,NGLB
5301     IF(GLBMOD(J).EQ.5.AND.GLBVAR(J).EQ.NAME(1:NCNAME))
5302     - IRWGT=NINT(GLBVAL(J))
5303     110 CONTINUE
5304     ISWGT=MATSLT(IRWGT)
5305     CALL INPSTR(I+3,I+3,NAME,NCNAME)
5306     DO 120 J=1,NGLB
5307     IF(GLBMOD(J).EQ.5.AND.GLBVAR(J).EQ.NAME(1:NCNAME))
5308     - IRCOOR=NINT(GLBVAL(J))
5309     120 CONTINUE
5310     ISCOOR=MATSLT(IRCOOR)
5311     IF(ISWGT.EQ.0)CALL INPMSG(I+1,'Not a known matrix.')
5312     IF(ISCOOR.EQ.0)CALL INPMSG(I+3,'Not a known matrix.')
5313     * Carry out interpolation.
5314     IF(ISCOOR.NE.0.AND.ISWGT.NE.0)THEN
5315     IORD=2
5316     WGTSUM=0
5317     OK=.TRUE.
5318     DO 130 J=1,MXLIST
5319     VAR(1)=REAL(J-1)/REAL(MXLIST-1)
5320     CALL MATIN1(IRCOOR,IRWGT,1,VAR(1),RES(1),
5321     - ISCOOR,ISWGT,IORD,IFAIL1)
5322     WGT(J)=MAX(0.0,RES(1))
5323     IF(RES(1).LT.0)OK=.FALSE.
5324     WGTSUM=WGTSUM+WGT(J)
5325     130 CONTINUE
5326     IF(WGTSUM.GT.0.AND.OK)THEN
5327     CALL HISPRD(WGT,MXLIST)
5328     ITRTYP=5
5329     CALL INPSTR(I+1,I+3,FCNTRW,NCTRW)
5330     TRFLAG(4)=.TRUE.
5331     ELSEIF(.NOT.OK)THEN
5332     CALL INPMSG(I+1,'Sometimes < 0.')
5333     ELSE
5334     CALL INPMSG(I+1,'Has a zero norm.')
5335     ENDIF
5336     ENDIF
5337     INEXT=I+4
5338     * In the form of a function.
5339     ELSE
5340     CALL INPSTR(I+1,I+1,FCNTRW,NCTRW)
5341     VARLIS(1)='T'
5342     NVAR=1
5343     CALL ALGPRE(FCNTRW(1:NCTRW),NCTRW,VARLIS,NVAR,
5344     - NRES,USE,IENWGT,IFAIL1)
5345     IF(IFAIL1.NE.0)THEN
5346     CALL INPMSG(I+1,'Not a valid function.')
5347     ELSE
5348     WGTSUM=0
5349     OK=.TRUE.
5350     DO 30 J=1,MXLIST
5351     VAR(1)=REAL(J-1)/REAL(MXLIST-1)
5352     MODVAR(1)=2
5353     NVAR=1
5354     NREXP=1
5355     CALL ALGEXE(IENWGT,VAR,MODVAR,NVAR,RES,
5356     - MODRES,NREXP,IFAIL1)
5357     WGT(J)=MAX(0.0,RES(1))
5358     IF(RES(1).LT.0)OK=.FALSE.
5359     WGTSUM=WGTSUM+WGT(J)
5360     30 CONTINUE
5361     CALL ALGCLR(IENWGT)
5362     CALL ALGERR
5363     IF(WGTSUM.GT.0.AND.OK)THEN
5364     CALL HISPRD(WGT,MXLIST)
5365     ITRTYP=5
5366     TRFLAG(4)=.TRUE.
5367     ELSEIF(.NOT.OK)THEN
5368     CALL INPMSG(I+1,'Sometimes < 0.')
5369     ELSE
5370     CALL INPMSG(I+1,'Has a zero norm.')
5371     ENDIF
5372     ENDIF
5373     INEXT=I+2
5374     ENDIF
5375     * Number of sampling points on the track.
5376     ELSEIF(INPCMP(I,'FL#UX-L#INES').NE.0)THEN
5377     IF(NWORD.LT.I+1.OR.INPTYP(I+1).LE.0)THEN
5378     CALL INPMSG(I,'Must have 1 integer argument')
5379     ELSE
5380     CALL INPCHK(I+1,1,IFAIL1)
5381     CALL INPRDI(I+1,NFLXR,NTRFLX)
5382     IF(NFLXR.LT.2)THEN
5383     CALL INPMSG(I+1,'Number is not > 1.')
5384     ELSE
5385     NTRFLX=NFLXR
5386     TRFLAG(6)=.TRUE.
5387     ITRTYP=7
5388     ENDIF
5389     INEXT=I+2
5390     ENDIF
5391     * Number of sampling points on the track.
5392     ELSEIF(INPCMP(I,'FL#UX-INT#ERVALS').NE.0)THEN
5393     IF(NWORD.LT.I+1.OR.INPTYP(I+1).LE.0)THEN
5394     CALL INPMSG(I,'Must have 1 real argument')
5395     ELSE
5396     CALL INPCHK(I+1,2,IFAIL1)
5397     CALL INPRDR(I+1,FLXR,TRFLUX)
5398     IF(FLXR.LE.0)THEN
5399     CALL INPMSG(I+1,'Interval is not > 0.')
5400     ELSE
5401     TRFLUX=FLXR
5402     TRFLAG(7)=.TRUE.
5403     ITRTYP=8
5404     ENDIF
5405     INEXT=I+2
5406     ENDIF
5407     * Kind of cluster generation.
5408     ELSEIF(INPCMP(I,'FIX#ED-#NUMBER').NE.0)THEN
5409     ITRTYP=1
5410     ELSEIF(INPCMP(I,'EQ#UAL-SP#ACING').NE.0)THEN
5411     ITRTYP=2
5412     ELSEIF(INPCMP(I,'EXP#ONENTIAL-#SPACING').NE.0)THEN
5413     ITRTYP=3
5414     ELSEIF(INPCMP(I,'HEED').NE.0)THEN
5415     ITRTYP=4
5416     ELSEIF(INPCMP(I,'WEIGHT#ED-D#ISTRIBUTION').NE.0)THEN
5417     ITRTYP=5
5418     ELSEIF(INPCMP(I,'SIN#GLE-#CLUSTER').NE.0)THEN
5419     ITRTYP=6
5420     IF(.NOT.GASOK(5))PRINT *,' ------ TRAREA MESSAGE :'//
5421     - ' No cluster size distribution; cluster will'//
5422     - ' have size 1.'
5423     ELSEIF(INPCMP(I,'EQ#UAL-FL#UX-#INTERVALS').NE.0)THEN
5424     ITRTYP=7
5425     ELSEIF(INPCMP(I,'CONS#TANT-FL#UX-#INTERVALS').NE.0)THEN
5426     ITRTYP=8
5427     * Not a known keyword.
5428     ELSE
5429     CALL INPMSG(I,'Not a known keyword.')
5430     ENDIF
5431     10 CONTINUE
5432     * Print the error messages.
5433     CALL INPERR
5434     *** If the cell is polar, then reconvert coordinates.
5435     IF(POLAR)THEN
5436     CALL CFMPTC(XT0D,YT0D,XT0,YT0,1)
5437     CALL CFMPTC(XT1D,YT1D,XT1,YT1,1)
5438     ZT0=ZT0D
5439     ZT1=ZT1D
5440     ELSE
5441     XT0=XT0D
5442     XT1=XT1D
5443     YT0=YT0D
5444     YT1=YT1D
5445     ZT0=ZT0D
5446     ZT1=ZT1D
5447     ENDIF
5448     *** Check completeness, first geometry.
5449     IF(START.AND.END.AND.DIST)THEN
5450     PRINT *,' ------ TRAREA MESSAGE : Both end point'//
5451     - ' and range specified; ignoring range.'
5452     XDIR=XT1-XT0
5453     YDIR=YT1-YT0
5454     ZDIR=ZT1-ZT0
5455     TRDIST=SQRT(XDIR**2+YDIR**2+ZDIR**2)
5456     IF(TRDIST.GT.0)THEN
5457     XDIR=XDIR/TRDIST
5458     YDIR=YDIR/TRDIST
5459     ZDIR=ZDIR/TRDIST
5460     ELSE
5461     XDIR=0
5462     YDIR=0
5463     ZDIR=0
5464     ENDIF
5465     * If neither end point nor direction and distance: assume point.
5466     ELSEIF(START.AND.(.NOT.END).AND.(.NOT.(DIST.AND.DIR)))THEN
5467     PRINT *,' ------ TRAREA MESSAGE : Only start point'//
5468     - ' specified; assuming single point track.'
5469     XT1=XT0
5470     YT1=YT0
5471     ZT1=ZT0
5472     XDIR=0
5473     YDIR=0
5474     ZDIR=0
5475     TRDIST=0
5476     * If end point missing, compute from direction and range.
5477     ELSEIF(START.AND..NOT.END)THEN
5478     XT1=XT0+XDIR*TRDIST
5479     YT1=YT0+YDIR*TRDIST
5480     ZT1=ZT0+ZDIR*TRDIST
5481     * If direction and range missing, compute from end point.
5482     ELSEIF(START)THEN
5483     XDIR=XT1-XT0
5484     YDIR=YT1-YT0
5485     ZDIR=ZT1-ZT0
5486     TRDIST=SQRT(XDIR**2+YDIR**2+ZDIR**2)
5487     IF(TRDIST.GT.0)THEN
5488     XDIR=XDIR/TRDIST
5489     YDIR=YDIR/TRDIST
5490     ZDIR=ZDIR/TRDIST
5491     ELSE
5492     XDIR=0
5493     YDIR=0
5494     ZDIR=0
5495     ENDIF
5496     ENDIF
5497     * Set the track location flag if appropriate, reset preparation.
5498     IF(START)THEN
5499     TRFLAG(1)=.TRUE.
5500     CALL DLCTRR
5501     ENDIF
5502     * Check mass etc.
5503     IF(MASS.OR.CHARGE.OR.ENER)THEN
5504     IF(.NOT.CHARGE)THEN
5505     TRCHAR=-1.0
5506     PRINT *,' ------ TRAREA MESSAGE : Charge not'//
5507     - ' specified; assuming negative charge.'
5508     ENDIF
5509     IF(.NOT.MASS)THEN
5510     TRMASS=105.658389
5511     IF(TRCHAR.LT.0)THEN
5512     PNAME='mu-'
5513     ELSE
5514     PNAME='mu-'
5515     ENDIF
5516     NCPNAM=3
5517     PRINT *,' ------ TRAREA MESSAGE : Mass not'//
5518     - ' specified; assuming a muon.'
5519     ENDIF
5520     IF(.NOT.ENER)THEN
5521     TRENER=1000.0
5522     PRINT *,' ------ TRAREA MESSAGE : Energy not'//
5523     - ' specified; assuming 1 GeV.'
5524     ENDIF
5525     TRFLAG(2)=.TRUE.
5526     ENDIF
5527     *** Debugging output.
5528     IF(LDEBUG)WRITE(LUNOUT,'('' ++++++ TRAREA DEBUG : '',
5529     - ''Start ('',E15.8,'','',E15.8,'','',E15.8,'')''/26X,
5530     - ''To ('',E15.8,'','',E15.8,'','',E15.8,'')''/26X,
5531     - ''Direction ('',E15.8,'','',E15.8,'','',E15.8,'')''/26X,
5532     - ''Range ='',E15.8,'' cm''/26X,
5533     - ''Mass ='',E15.8,'' MeV''/26X,
5534     - ''Energy ='',E15.8,'' MeV''/26X,
5535     - ''Charge ='',E15.8,'' electron charges''/26X,
5536     - ''Lines ='',I5/26X,
5537     - ''Type ='',I5,'' (1=fixed, 2=equal, 3=exp, 4=HEED,'',
5538     - '' 5=weighted, 6=single, 7=flux)''/26X,
5539     - ''Location '',L1,'', particle '',L1,'', lines '',L1/26X,
5540     - ''weighting function '',L1,'', samples '',L1/26X,
5541     - ''flux lines '',L1/26X,
5542     - ''MS '',L1,'', delta '',L1,'', trace delta '',L1,
5543     - '', interpolate '',L1)')
5544     - XT0,YT0,ZT0,XT1,YT1,ZT1,XDIR,YDIR,ZDIR,
5545     - TRDIST,TRMASS,TRENER,TRCHAR,NTRLIN,ITRTYP,
5546     - (TRFLAG(I),I=1,5),LTRMS,LTRDEL,LTREXB,LTRINT
5547     END
5548     +DECK,TRAEXB.
5549     SUBROUTINE TRAEXB(XIN,VIN,XOUT,VOUT,ENERGY,STEP,IFAIL)
5550     *-----------------------------------------------------------------------
5551     * TRAEXB - Traces an electron through an E and B field.
5552     * (Last changed on 10/ 2/97.)
5553     *-----------------------------------------------------------------------
5554     implicit none
5555     +SEQ,DIMENSIONS.
5556     +SEQ,CONSTANTS.
5557     +SEQ,PRINTPLOT.
5558     +SEQ,PARAMETERS.
5559     DOUBLE PRECISION XIN(3),XOUT(3),VEL(3),
5560     - DT,T,WORK(18),SPEED,VNORM,STEP,RADIUS,GAMMA
5561     REAL BX,BY,BZ,BTOT,XPOS,YPOS,ZPOS,VIN(3),VOUT(3),ENERGY
5562     INTEGER I,IFAIL,NSTEP
5563     EXTERNAL TRASUB
5564     COMMON /EXBCOM/ GAMMA
5565     *** For now, assume that the routine will fail.
5566     IFAIL=1
5567     *** Ensure that the energy is larger than 0.
5568     IF(ENERGY.LE.0)THEN
5569     PRINT *,' !!!!!! TRAEXB WARNING : Energy is not > 0;'//
5570     - ' not traced.'
5571     RETURN
5572     ENDIF
5573     *** Compute particle's speed (eV gives m/sec, need MeV to cm/microsec)
5574     SPEED=CLIGHT*SQRT(1-1/(1+(ECHARG*ENERGY)/
5575     - (100*EMASS*CLIGHT**2))**2)
5576     *** Compute gamma factor which we'll need for the trajectory.
5577     GAMMA=1/SQRT(1-(SPEED/CLIGHT)**2)
5578     *** Debugging output.
5579     IF(LDEBUG)WRITE(LUNOUT,'('' ++++++ TRAEXB DEBUG : Energy: '',
5580     - E15.8,'' MeV''/26X,''Speed: '',E15.8,'' cm/microsec''/
5581     - 26X,''Gamma: '',E15.8)') ENERGY,SPEED,GAMMA
5582     *** Establish the speed vector.
5583     VNORM=SQRT(VIN(1)**2+VIN(2)**2+VIN(3)**2)
5584     IF(VNORM.LE.0)THEN
5585     PRINT *,' !!!!!! TRAEXB WARNING : Speed vector has norm'//
5586     - ' 0; not traced.'
5587     RETURN
5588     ENDIF
5589     VEL(1)=SPEED*VIN(1)/VNORM
5590     VEL(2)=SPEED*VIN(2)/VNORM
5591     VEL(3)=SPEED*VIN(3)/VNORM
5592     *** First estimate of the step size to be taken.
5593     NSTEP=10
5594     DT=STEP/(10*SPEED)
5595     *** Estimate bending radius so as to get the scale for integration.
5596     XPOS=XT0+COS(TRPHI)*XIN(1)-
5597     - SIN(TRPHI)*SIN(TRTH)*XIN(2)+
5598     - SIN(TRPHI)*COS(TRTH)*XIN(3)
5599     YPOS=YT0+COS(TRTH)*XIN(2)+
5600     - SIN(TRTH)*XIN(3)
5601     ZPOS=ZT0-SIN(TRPHI)*XIN(1)-
5602     - COS(TRPHI)*SIN(TRTH)*XIN(2)+
5603     - COS(TRPHI)*COS(TRTH)*XIN(3)
5604     CALL BFIELD(XPOS,YPOS,ZPOS,BX,BY,BZ,BTOT)
5605     IF(BTOT.GT.0)THEN
5606     RADIUS=1.0D8*(EMASS*SPEED)/(ECHARG*BTOT)
5607     IF(LDEBUG)WRITE(LUNOUT,'('' ++++++ TRAEXB DEBUG :'',
5608     - '' Bending radius: '',E15.8,'' cm.'')') RADIUS
5609     IF(RADIUS.LT.STEP)THEN
5610     NSTEP=NSTEP*2*NINT(STEP/RADIUS)
5611     DT=DT/(2*NINT(STEP/RADIUS))
5612     ENDIF
5613     ENDIF
5614     *** Starting conditions.
5615     T=0
5616     *** Make steps.
5617     XOUT(1)=XIN(1)
5618     XOUT(2)=XIN(2)
5619     XOUT(3)=XIN(3)
5620     DO 10 I=1,NSTEP
5621     CALL DRKNYS(3,DT,T,XOUT,VEL,TRASUB,WORK)
5622     10 CONTINUE
5623     *** At the end, return the new velocity vector.
5624     VNORM=SQRT(VEL(1)**2+VEL(2)**2+VEL(3)**2)
5625     VOUT(1)=VEL(1)/VNORM
5626     VOUT(2)=VEL(2)/VNORM
5627     VOUT(3)=VEL(3)/VNORM
5628     *** Things seem to have worked properly.
5629     IFAIL=0
5630     END
5631     +DECK,TRASUB.
5632     SUBROUTINE TRASUB(T,X,V,F)
5633     *-----------------------------------------------------------------------
5634     * TRASUB - Called when integrating the orbit of an electron.
5635     * (Last changed on 11/ 2/97.)
5636     *-----------------------------------------------------------------------
5637     implicit none
5638     +SEQ,DIMENSIONS.
5639     +SEQ,CONSTANTS.
5640     +SEQ,PARAMETERS.
5641     DOUBLE PRECISION T,X(3),V(3),F(3),GAMMA
5642     REAL EX,EY,EZ,ETOT,VOLT,BX,BY,BZ,BTOT,XPOS,YPOS,ZPOS,
5643     - EHX,EHY,EHZ,BHX,BHY,BHZ
5644     INTEGER ILOC
5645     COMMON /EXBCOM/ GAMMA
5646     *** Transform from Heed to Garfield coordinates.
5647     XPOS=XT0+COS(TRPHI)*X(1)-
5648     - SIN(TRPHI)*SIN(TRTH)*X(2)+
5649     - SIN(TRPHI)*COS(TRTH)*X(3)
5650     YPOS=YT0+COS(TRTH)*X(2)+SIN(TRTH)*X(3)
5651     ZPOS=ZT0-SIN(TRPHI)*X(1)-
5652     - COS(TRPHI)*SIN(TRTH)*X(2)+
5653     - COS(TRPHI)*COS(TRTH)*X(3)
5654     *** Compute the E and B field at the current position.
5655     CALL EFIELD(XPOS,YPOS,ZPOS,EX,EY,EZ,ETOT,VOLT,0,ILOC)
5656     CALL BFIELD(XPOS,YPOS,ZPOS,BX,BY,BZ,BTOT)
5657     *** Transform the E and B field to Heed coordinates.
5658     EHX= COS(TRPHI)* EX -SIN(TRPHI)* EZ
5659     EHY=-SIN(TRPHI)*SIN(TRTH)*EX+COS(TRTH)*EY-COS(TRPHI)*SIN(TRTH)*EZ
5660     EHZ= SIN(TRPHI)*COS(TRTH)*EX+SIN(TRTH)*EY+COS(TRPHI)*COS(TRTH)*EZ
5661     BHX= COS(TRPHI)* BX -SIN(TRPHI)* BZ
5662     BHY=-SIN(TRPHI)*SIN(TRTH)*BX+COS(TRTH)*BY-COS(TRPHI)*SIN(TRTH)*BZ
5663     BHZ= SIN(TRPHI)*COS(TRTH)*BX+SIN(TRTH)*BY+COS(TRPHI)*COS(TRTH)*BZ
5664     *** Compute the force/mass [from C*V/cm to cm/microsec**2]
5665     F(1)=-1.0D-8*ECHARG*(EHX+V(2)*BHZ-V(3)*BHY)/(EMASS*GAMMA)
5666     F(2)=-1.0D-8*ECHARG*(EHY+V(3)*BHX-V(1)*BHZ)/(EMASS*GAMMA)
5667     F(3)=-1.0D-8*ECHARG*(EHZ+V(1)*BHY-V(2)*BHX)/(EMASS*GAMMA)
5668     END
5669     +PATCH,HEEDSUB.
5670     +DECK,PSHEED,IF=PSHEED.
5671     program PSHEED
5672    
5673     implicit none
5674    
5675     c include 'molecules.inc'
5676     +SEQ,molecule.
5677     c include 'molecdef.inc'
5678     +SEQ,molecdef.
5679     c include 'hs.inc'
5680     +SEQ,hs.
5681    
5682    
5683     integer qmol ! Quantity of different molecules
5684     ! in the gas mixture.
5685     integer nmol(pqMol) ! Their numbers from molecules.inc.
5686     ! Use only the named constants
5687     ! for compartibility with future versions.
5688     real wmol(pqMol) ! Their weights
5689     ! (relative quantities of molecules).
5690     real pres ! Pressure in Torr.
5691     real temp ! Temperature in K.
5692     real tkener ! Kinetic energy of incident particle(MeV).
5693     real mas ! Mass of incident particle(MeV)
5694     integer maxnum ! Maximum size of cluster(not used now).
5695     integer soo ! Flag allowed for writting.
5696     integer oo ! Output stream number.
5697     integer debug ! Flag allowed for writting of
5698     ! more amount of information.
5699    
5700     c Output parameters:
5701     real density ! Density, calculated as for ideal gas, gr/cm3
5702     real dedx ! Mean dE/dx, mean energy loss, KeV/cm.
5703     real ntotal ! Average total number.
5704     real nclust ! number of clusters per cm.
5705     real clprob(msize) ! Probability of the clusters,
5706     ! Size=index.
5707     integer ierror ! Sign of error( 0 -- no error ).
5708    
5709     integer n
5710    
5711     c qmol=1
5712    
5713     c nmol(1)=numm_Ar
5714     c wmol(1)=1.0
5715     c nmol(1)=numm_CF4
5716     c wmol(1)=1.0
5717    
5718     qmol=3
5719     nmol(1)=numm_Ar
5720     wmol(1)=0.30
5721     nmol(2)=numm_CO2
5722     wmol(2)=0.50
5723     nmol(3)=numm_CF4
5724     wmol(3)=0.20
5725    
5726     pres=0.0
5727     temp=0.0
5728     tkener=0.0
5729     mas=0.0
5730     maxnum=0.0
5731    
5732     soo=0
5733     oo=10
5734     open(oo,FILE='Heed.out')
5735    
5736     debug=0
5737    
5738    
5739    
5740    
5741     call SHEED
5742     + (qmol, nmol, wmol, pres, temp,
5743     + tkener, mas, maxnum, soo, oo, debug,
5744     + dedx, ntotal, nclust, clprob, ierror)
5745    
5746     write(oo,*)' mean energy loss(KeV/cm)=',dedx
5747     write(oo,*)' total electron-ion pair number=',ntotal
5748     write(oo,*)' mean cluster number=',nclust
5749     do n=1,msize
5750     write(oo,*)n,clprob(n)
5751     enddo
5752    
5753     end
5754    
5755    
5756     +DECK,SHEED,IF=SHEED.
5757    
5758     subroutine SHEED
5759     + (qmol, nmol, pwmol, ppres, ptemp,
5760     + ptkener, pmas, maxnum, psoo, poo, debug,
5761     + density, dedx, ntotal, nclust, clprob, ierror)
5762     c
5763     c The subroutine for calculation of cluster size table by HEED package
5764     c
5765     implicit none
5766    
5767     c include 'GoEvent.inc'
5768     +SEQ,GoEvent.
5769     c include 'molecules.inc'
5770     +SEQ,molecule.
5771     c include 'molecdef.inc'
5772     +SEQ,molecdef.
5773    
5774    
5775     c include 'ener.inc'
5776     +SEQ,ener.
5777     c include 'atoms.inc'
5778     +SEQ,atoms.
5779     c include 'matters.inc'
5780     +SEQ,matters.
5781     c include 'crosec.inc'
5782     +SEQ,crosec.
5783    
5784     c include 'cconst.inc'
5785     +SEQ,cconst.
5786     c include 'volume.inc'
5787     +SEQ,volume.
5788     c include 'part.inc'
5789     +SEQ,part.
5790     c include 'hist.inc'
5791     +SEQ,hist.
5792    
5793    
5794     c include 'random.inc'
5795     +SEQ,random.
5796    
5797     c include 'hs.inc'
5798     +SEQ,hs.
5799    
5800    
5801    
5802     integer qmol ! Quantity of different molecules
5803     ! in the gas mixture.
5804     integer nmol(pqMol) ! Their numbers from molecules.inc.
5805     ! Use only the named constants
5806     ! for compartibility with the future versions
5807     real pwmol(pqMol) ! Their weights
5808     ! (relative quantities of molecules).
5809     real ppres ! Pressure in Torr.
5810     real ptemp ! Temperature in K.
5811     real ptkener ! Kinetic energy of incident particle(MeV)
5812     real pmas ! Mass of incident particle(MeV)
5813     integer maxnum ! Maximum size of cluster(not used now).
5814     integer psoo ! Flag allowing to write.
5815     integer poo ! Output stream number.
5816     integer debug ! Flag allowing to write
5817     ! more amount of information.
5818    
5819     c Output parameters:
5820     real density ! Density, calculated as for ideal gas, gr/cm3
5821     real dedx ! Mean dE/dx, mean energy loss, KeV/cm.
5822     real ntotal ! Average total number.
5823     real nclust ! number of clusters per cm.
5824     real clprob(msize) ! Probability of the clusters,
5825     ! Size=index.
5826     integer ierror ! Sign of error( 0 -- no error ).
5827    
5828     real wmol(pqMol)
5829    
5830     integer n,nc,i
5831     real s
5832    
5833     real pres ! Pressure in Torr.
5834     real temp ! Temperature in K.
5835     real tkener ! Kinetic energy of incident particle.
5836     real mas ! Mass of incident particle.
5837    
5838     real step_integ_ar
5839     integer tresh
5840     parameter (tresh=20)
5841     real e1,e2
5842    
5843     integer nmat
5844     integer nat
5845    
5846     c restore after previous run
5847    
5848     do nat=1,pQAt
5849     Zat(nat)=0
5850     enddo
5851    
5852     nmat=1
5853    
5854     QAtMat(nmat)=0
5855    
5856    
5857    
5858     c go ahead
5859    
5860     s=0.0
5861     do n=1,qmol
5862     s=s+pwmol(n)
5863     enddo
5864     do n=1,qmol
5865     wmol(n)=pwmol(n)/s
5866     enddo
5867    
5868    
5869     call Iniranfl
5870    
5871     soo=psoo
5872     oo=poo
5873     sret_err=1
5874    
5875     sHist=0 ! To ban operating with historgams
5876     HistFile='heed.hist' ! To make sure. Histograms must not be filled
5877     ! and written here.
5878     maxhisampl=40.0e-3
5879     maxhisampl2=20.0e-3
5880     pqhisampl=100
5881     shfillrang=0
5882    
5883     c Random number genarator
5884     sseed=0
5885     seed(1)=1121517854 ! this is example
5886     seed(2)=612958528
5887    
5888    
5889     qevt=1000 ! Quantity of events to generate
5890    
5891     ssimioni=1 ! Simulate ionization loss
5892     ninfo=3 ! Number of first events with output listing
5893    
5894     call Inishl ! Cascade from excited atom
5895    
5896     call IniEner(150,3e-6,0.2) ! Energy mesh
5897     if(debug.ge.2)call PriEner
5898    
5899     call AtomsByDefault ! Library of atoms
5900     *** Added argument to PriAtoms (RV 13/4/99)
5901     if(debug.ge.2)call PriAtoms(0)
5902     *** End of modification.
5903    
5904     if(ppres.eq.0)then
5905     pres=Atm_Pressure
5906     else
5907     pres=ppres
5908     endif
5909    
5910     if(ptemp.eq.0)then
5911     temp=Atm_Temper
5912     else
5913     temp=ptemp
5914     endif
5915    
5916     call molecdef
5917     if(debug.ge.2)call Primolec
5918    
5919     call Inigas(nmat, qmol, nmol, wmol, pres, temp)
5920     *** Added argument to PriMatter (RV 13/4/99).
5921     if(debug.ge.2)call PriMatter(0)
5922     *** End of modification.
5923     if(s_err.eq.1)then
5924     ierror=1
5925     return
5926     endif
5927     density=DensMat(nmat)
5928    
5929     call IniFVolume(0, nmat, 1, 1, 0.0, 1.0 )
5930     if(debug.ge.2)call PriVolume
5931    
5932     if(pmas.eq.0)then
5933     mas=938
5934     else
5935     mas=pmas
5936     endif
5937    
5938     if(ptkener.eq.0)then
5939     tkener=mas*(4-1) ! 'mip'
5940     else
5941     tkener=ptkener
5942     endif
5943    
5944     call IniPart(tkener,mas) ! Particle
5945     if(debug.ge.2)call Pripart
5946     if(s_err.eq.1)then
5947     ierror=1
5948     return
5949     endif
5950    
5951     call IniRTrack(0.0, 0.0, 0.0, 0.0)
5952    
5953     call IniCrosec ! Cross sections
5954     if(debug.ge.2)call PriCrosec(1,1)
5955    
5956     call InisBdel ! Data for tracing of delta-electrons
5957    
5958     meanprob=0.0
5959     meanvga=0.0
5960     meanvgal=0.0
5961     do i=1,msize
5962     prob(i)=0.0
5963     enddo
5964    
5965    
5966    
5967     do nevt=1,qevt
5968    
5969     call GoEvent
5970    
5971     enddo
5972    
5973    
5974    
5975     s=step_integ_ar
5976     + (ener,addaC(1,nmat),qener,0.0,ener(qener+1))
5977     s=s*XElDensMat(nmat)
5978    
5979     do nc=1,msize
5980    
5981     e1=WWW(nmat)*(nc-0.5)
5982     e2=WWW(nmat)*(nc+0.5)
5983     prob1(nc)=step_integ_ar
5984     + (ener,addaC(1,nmat),qener,e1,e2)
5985     prob1(nc)=prob1(nc)*XElDensMat(nmat)/s
5986    
5987     enddo
5988    
5989     dedx=meanC1(1)*1000.0
5990     ntotal=meaneleC1(1)
5991     nclust=meanvga
5992     do nc=1,tresh
5993     clprob(nc)=prob(nc)
5994     enddo
5995     do nc=tresh+1,msize
5996     clprob(nc)=prob1(nc)
5997     enddo
5998    
5999     end
6000    
6001     +DECK,UEventS,IF=SHEED.
6002     subroutine UBegEvent
6003    
6004     implicit none
6005    
6006     c include 'GoEvent.inc'
6007     +SEQ,GoEvent.
6008     c include 'volume.inc'
6009     +SEQ,volume.
6010    
6011    
6012    
6013     end
6014    
6015     subroutine UEndEvent
6016    
6017     implicit none
6018    
6019     c include 'GoEvent.inc'
6020     +SEQ,GoEvent.
6021     c include 'ener.inc'
6022     +SEQ,ener.
6023     c include 'atoms.inc'
6024     +SEQ,atoms.
6025     c include 'matters.inc'
6026     +SEQ,matters.
6027     c include 'volume.inc'
6028     +SEQ,volume.
6029     c include 'del.inc'
6030     +SEQ,del.
6031     c include 'cel.inc'
6032     +SEQ,cel.
6033     c include 'hs.inc'
6034     +SEQ,hs.
6035     c include 'lsgvga.inc'
6036     +SEQ,lsgvga.
6037    
6038     integer i,j,k,n,nb
6039     integer nc,na,nq
6040     real s
6041    
6042    
6043     n=0
6044     if(qcel(1).eq.0)then
6045     goto 10
6046     endif
6047     nb=Ptdel(Ndelcel(1,1))
6048     k=0
6049     do nc=1,qcel(1)+1
6050     k=0
6051     if(nc.eq.qcel(1)+1)then
6052     k=1
6053     else
6054     if(nc.gt.1.and.Ptdel(Ndelcel(nc,1)).ne.nb)then
6055     k=1
6056     endif
6057     endif
6058     if(k.eq.1)then
6059     if(n.le.0)then
6060     write(oo,*)' n=',n
6061     n=1
6062     endif
6063     if(n.ge.msize+1)then
6064     write(oo,*)' n=',n
6065     n=msize
6066     endif
6067     prob(n)=prob(n)+1
6068     n=1
6069     if(nc.le.qcel(1))then
6070     nb=Ptdel(Ndelcel(nc,1))
6071     endif
6072     else
6073     n=n+1
6074     endif
6075     enddo
6076     meanprob=meanprob+qcel(1)
6077     meanvga=meanvga+qgvga(1)
6078     meanvgal=meanvgal+esgvga(1)
6079    
6080     c write(oo,*)
6081     c + ' mean quantity of energy transfers from inc. part.= ',meanvga
6082     c write(oo,*)
6083     c + ' mean energy loss, Kev = ',
6084     c + meanvgal*1000.0
6085     c write(oo,*)
6086     c + ' mean number of conduction electrons = ',meanprob
6087    
6088     10 continue
6089    
6090     if(nevt.eq.qevt)then
6091     meanprob=meanprob/qevt
6092     meanvga=meanvga/qevt
6093     meanvgal=meanvgal/qevt
6094     s=0.0
6095     do n=1,msize
6096     s = s + prob(n)
6097     enddo
6098     do n=1,msize
6099     prob(n) = prob(n) / s
6100     enddo
6101    
6102     c write(oo,*)
6103     c + ' mean quantity of energy transfers from inc. part.= ',meanvga
6104     c write(oo,*)
6105     c + ' mean energy loss, Kev = ',
6106     c + meanvgal*1000.0
6107     c write(oo,*)
6108     c + ' mean number of conduction electrons = ',meanprob
6109     c write(oo,*)
6110     c + ' number of conduction electrons in cluster vs probability:'
6111     c do n=1,200
6112     c write(oo,*)n,prob(n)
6113     c enddo
6114    
6115    
6116     endif
6117    
6118    
6119     end
6120     +DECK,PEHEED,IF=PEHEED.
6121     program PEHEED
6122    
6123     c Checking the package EHEED
6124    
6125     implicit none
6126    
6127     c include 'molecules.inc'
6128     +SEQ,molecule.
6129     c include 'molecdef.inc'
6130     +SEQ,molecdef.
6131    
6132    
6133     integer qmol ! Quantity of different molecules
6134     ! in the gas mixture.
6135     integer nmol(pqMol) ! Their numbers from molecules.inc.
6136     ! Use only the named constants
6137     ! for compartibility with future versions.
6138     real wmol(pqMol) ! Their weights
6139     ! (relative quantities of molecules).
6140     real pres ! Pressure in Torr.
6141     real temp ! Temperature in K.
6142     real tkener ! Kinetic energy of incident particle(MeV).
6143     real mas ! Mass of incident particle(MeV)
6144     integer soo ! Flag allowed for writting.
6145     integer oo ! Output stream number.
6146     integer debug ! Flag allowed for writting of
6147     ! more amount of information.
6148    
6149     integer qevt ! quantity of events to generate
6150     integer nevt ! current number of events
6151     ! (see comment in EHEED before GoEventn)
6152     c Output parameters:
6153     real density ! Density, calculated as for ideal gas, gr/cm3
6154     integer ierror ! Sign of error( 0 -- no error ).
6155    
6156     integer n
6157    
6158     write(6,*)' PEHEED started'
6159    
6160     c qmol=1
6161    
6162     c nmol(1)=numm_Ar
6163     c wmol(1)=1.0
6164     c nmol(1)=numm_CF4
6165     c wmol(1)=1.0
6166    
6167     qmol=3
6168     nmol(1)=numm_Ar
6169     wmol(1)=0.30
6170     nmol(2)=numm_CO2
6171     wmol(2)=0.50
6172     nmol(3)=numm_CF4
6173     wmol(3)=0.20
6174    
6175     pres=0.0
6176     temp=0.0
6177     tkener=0.0
6178     mas=0.0
6179    
6180     soo=0
6181     oo=10
6182     open(oo,FILE='heed.out')
6183    
6184     debug=2
6185    
6186    
6187     call IMHEED
6188     + (qmol, nmol, wmol, pres, temp, soo, oo, debug,
6189     + density, ierror)
6190     if(ierror.ne.0)then
6191     write(oo,*)' Error in IMHEED'
6192     stop
6193     endif
6194    
6195     call IniFVolume(0, 1, 1, 1, 0.0, 1.0 ) ! Volume
6196    
6197    
6198     call IPHEED
6199     + (tkener, mas, debug,
6200     + ierror)
6201     if(ierror.ne.0)then
6202     write(oo,*)' Error in IMHEED'
6203     stop
6204     endif
6205    
6206     call IniRTrack(0.0, 0.0, 0.0, 0.0) ! Track
6207    
6208     write(oo,*)' density=',density
6209    
6210     qevt=10
6211    
6212     c End of initialization
6213     c Now the GoEvent subroutine can be called
6214     c from any place of user's program.
6215     c For example we just run several events and print ionization positions.
6216    
6217     do nevt=1,qevt ! Loop over events
6218    
6219     call GoEventn(nevt,qevt) ! Simulation of one event
6220     call PriCel ! Print to 'oo' device
6221    
6222     enddo
6223    
6224     end
6225    
6226    
6227     +DECK,EHEED,IF=EHEED.
6228     c Initialization of HEED for simulation event by event
6229     c with calls of HEED from another program.
6230     c Volumes and tracks are to be initialized by usual HEED routines:
6231     c IniFVolume, IniNVolume, and IniRTrack
6232    
6233    
6234     subroutine IMHEED
6235     + (qmol, nmol, pwmol, ppres, ptemp, psoo, poo, debug,
6236     + density, ierror)
6237     c
6238     c The subroutine for initialization of the medium.
6239     c Required are only information about matter.
6240     c Cross sections are to be initialized later, when the particle
6241     c velosity is fixed.
6242     c
6243     implicit none
6244    
6245     c include 'GoEvent.inc'
6246     +SEQ,GoEvent.
6247     c include 'molecules.inc'
6248     +SEQ,molecule.
6249     c include 'molecdef.inc'
6250     +SEQ,molecdef.
6251    
6252    
6253     c include 'ener.inc'
6254     +SEQ,ener.
6255     c include 'atoms.inc'
6256     +SEQ,atoms.
6257     c include 'matters.inc'
6258     +SEQ,matters.
6259     c include 'crosec.inc'
6260     +SEQ,crosec.
6261    
6262     c include 'cconst.inc'
6263     +SEQ,cconst.
6264     c include 'volume.inc'
6265     +SEQ,volume.
6266     c include 'part.inc'
6267     +SEQ,part.
6268     c include 'hist.inc'
6269     +SEQ,hist.
6270    
6271    
6272     c include 'random.inc'
6273     +SEQ,random.
6274     +SEQ,PRINTPLOT.
6275    
6276    
6277    
6278     integer qmol ! Quantity of different molecules
6279     ! in the gas mixture.
6280     integer nmol(pqMol) ! Their numbers from molecules.inc.
6281     ! Use only the named constants
6282     ! for compartibility with the future versions
6283     real pwmol(pqMol) ! Their weights
6284     ! (relative quantities of molecules).
6285     real ppres ! Pressure in Torr.
6286     real ptemp ! Temperature in K.
6287     integer psoo ! Flag allowing to write.
6288     integer poo ! Output stream number.
6289     integer debug ! Flag allowing to write
6290     ! more amount of information.
6291    
6292     c Output parameters:
6293     real density ! Density, calculated as for ideal gas, gr/cm3
6294     integer ierror ! Sign of error( 0 -- no error ).
6295    
6296     real wmol(pqMol)
6297    
6298     C integer nc
6299     integer n,i
6300     real s
6301    
6302     real pres ! Pressure in Torr.
6303     real temp ! Temperature in K.
6304    
6305     c real step_integ_ar
6306     integer tresh
6307     parameter (tresh=20)
6308     c real e1,e2
6309    
6310     integer nmat
6311     integer nat
6312     *** Additional debug output (RV 13/8/98).
6313     IF(LDEBUG)THEN
6314     WRITE(LUNOUT,'('' ++++++ IMHEED DEBUG : '',
6315     - ''Pressure: '',F10.3,'' Torr''/26X,
6316     - ''Temperature: '',F10.3,'' K''/26X,
6317     - ''Gas components: '',I5/26X,
6318     - ''Identifier Fraction'')') ppres,ptemp,qmol
6319     DO I=1,qmol
6320     WRITE(LUNOUT,'(26X,I10,F12.4)') nmol(i),pwmol(i)
6321     ENDDO
6322     ENDIF
6323     *** End of modification.
6324    
6325     c restore after previous run
6326    
6327     do nat=1,pQAt
6328     Zat(nat)=0
6329     enddo
6330    
6331     nmat=1
6332    
6333     QAtMat(nmat)=0
6334    
6335     c go ahead
6336    
6337     s=0.0
6338     do n=1,qmol
6339     s=s+pwmol(n)
6340     enddo
6341     do n=1,qmol
6342     wmol(n)=pwmol(n)/s
6343     enddo
6344    
6345    
6346     call Iniranfl
6347    
6348     soo=psoo
6349     oo=poo
6350     sret_err=1
6351    
6352     sHist=0 ! To ban operating with historgams
6353     HistFile='heed.hist' ! To make sure. Histograms must not be filled
6354     ! and written here.
6355     maxhisampl=40.0e-3
6356     maxhisampl2=20.0e-3
6357     maxhisample=200
6358     pqhisampl=100
6359     shfillrang=0
6360    
6361     c Random number genarator
6362     sseed=0
6363     seed(1)=1121517854 ! this is example
6364     seed(2)=612958528
6365    
6366    
6367     qevt=1 ! Quantity of events to generate
6368    
6369     ssimioni=1 ! Simulate ionization loss
6370     ninfo=0 ! Number of first events with output listing
6371    
6372     call Inishl ! Cascade from excited atom
6373    
6374     call IniEner(150,3e-6,0.2) ! Energy mesh
6375     if(debug.ge.2)call PriEner
6376    
6377     call AtomsByDefault ! Library of atoms
6378     *** Added argument to PriAtoms (RV 13/4/99)
6379     if(debug.ge.2)call PriAtoms(0)
6380     *** End of modification.
6381    
6382     if(ppres.eq.0)then
6383     pres=Atm_Pressure
6384     else
6385     pres=ppres
6386     endif
6387    
6388     if(ptemp.eq.0)then
6389     temp=Atm_Temper
6390     else
6391     temp=ptemp
6392     endif
6393    
6394     call molecdef
6395     if(debug.ge.2)call Primolec
6396    
6397     call Inigas(nmat, qmol, nmol, wmol, pres, temp)
6398     *** Added argument to PriMatter (RV 13/4/99).
6399     if(debug.ge.2)call PriMatter(0)
6400     *** End of modification.
6401     if(s_err.eq.1)then
6402     ierror=1
6403     return
6404     endif
6405     density=DensMat(nmat)
6406    
6407     end
6408    
6409    
6410     subroutine IPHEED
6411     + (ptkener, pmas, debug,
6412     + ierror)
6413    
6414     c Initialization of particle, cross sections,
6415     c and tracing of delta-electrons.
6416     c The volume(s) have to be initialized before!
6417    
6418     implicit none
6419    
6420     c include 'GoEvent.inc'
6421     +SEQ,GoEvent.
6422    
6423     real ptkener ! Kinetic energy of incident particle.
6424     real pmas ! Mass of incident particle.
6425     ! In the case of zero in two above var. the following
6426     ! two ones will be sensible (see text).
6427     real tkener ! Kinetic energy of incident particle.
6428     real mas ! Mass of incident particle.
6429    
6430     integer debug ! Flag allowing to write
6431     ! more amount of information.
6432    
6433     c Output parameters:
6434     integer ierror ! Sign of error( 0 -- no error ).
6435    
6436    
6437     if(pmas.eq.0)then
6438     mas=938
6439     else
6440     mas=pmas
6441     endif
6442    
6443     if(ptkener.eq.0)then
6444     tkener=mas*(4-1) ! 'mip'
6445     else
6446     tkener=ptkener
6447     endif
6448    
6449     call IniPart(tkener,mas) ! Particle
6450     if(debug.ge.2)call Pripart
6451     if(s_err.eq.1)then
6452     ierror=1
6453     return
6454     endif
6455    
6456     call IniCrosec ! Cross sections
6457     if(debug.ge.2)call PriCrosec(1,1)
6458    
6459     call InisBdel ! Data for tracing of delta-electrons
6460    
6461     end
6462    
6463     c After that the track must still be initialized by IniRTrack.
6464    
6465     c The UBegEvent end UEndEvent subroutine can be empty in this case.
6466    
6467     subroutine UBegEvent
6468    
6469     end
6470    
6471     subroutine UEndEvent
6472    
6473     end
6474    
6475     c The GoEvent must know the number of the current event
6476     c and the total ordered event number. If there was an overflow
6477     c of any controlled array - arrays with delta-electrons,
6478     c conduction electrons, real photons, virtual photons,
6479     c the GoEvent prints the wornings and auxiliary information
6480     c to the 'oo' after the last event generated.
6481     c So as avoid of including of GoEvent.inc , where the event number
6482     c nevt and quantity of events qevt are stored, user can call GoEventn ,
6483     c that takes nevt and qevt as arguments and simulates ONE event.
6484    
6485     subroutine GoEventn(pnevt, pqevt)
6486    
6487     implicit none
6488    
6489     c include 'GoEvent.inc'
6490     +SEQ,GoEvent.
6491     integer pnevt, pqevt
6492    
6493     nevt = pnevt
6494     qevt = pqevt
6495    
6496     call GoEvent
6497    
6498     end
6499     +DECK,MainHEED,IF=E.
6500    
6501    
6502     program HEED
6503     c
6504     c The main program for HEED package
6505     c
6506     implicit none
6507    
6508     integer NPW
6509     PARAMETER (NPW = 2000000)
6510     real H
6511     COMMON /PAWC/ H(NPW)
6512    
6513     c include 'GoEvent.inc'
6514     +SEQ,GoEvent.
6515     c include 'volume.inc'
6516     +SEQ,volume.
6517     c include 'hist.inc'
6518     +SEQ,hist.
6519    
6520    
6521     CALL HLIMIT(NPW)
6522    
6523     call Iniranfl ! Initialization of the counter of
6524     ! random number generator calls
6525     call IniHeed ! User's subroutine,
6526     ! Initialization of the detector
6527    
6528     if(sHist.eq.1)then
6529     call IniHist ! Initialization of inbilt histograms
6530     endif
6531    
6532    
6533     do nevt=1,qevt ! Loop over events
6534    
6535     call GoEvent ! Simulation of one event
6536    
6537     enddo
6538    
6539    
6540    
6541     if(sHist.eq.1)then
6542     call WHist ! Writting of histograms
6543     endif
6544    
6545    
6546     call Priranfl ! Print the number of calls of
6547     ! random number generator
6548     end
6549     +DECK,GoEvent.
6550    
6551    
6552     subroutine GoEvent
6553     c
6554     c Event processor. It is called from MainHEED.
6555     c
6556     implicit none
6557    
6558     c include 'GoEvent.inc'
6559     +SEQ,GoEvent.
6560     c include 'abs.inc'
6561     +SEQ,abs.
6562     c include 'rga.inc'
6563     +SEQ,rga.
6564     c include 'volume.inc'
6565     +SEQ,volume.
6566     c include 'hist.inc'
6567     +SEQ,hist.
6568     c include 'random.inc'
6569     +SEQ,random.
6570    
6571     integer iempty
6572    
6573    
6574     c if(nevt.le.ninfo)then
6575     if(soo.eq.1)then
6576     write(oo,*)
6577     write(oo,*)' Event number ',nevt
6578     endif
6579     if(nevt.eq.1.and.sseed.eq.1)then
6580     call randset ! Set the start point of
6581     endif ! the random number generator.
6582     if(soo.eq.1)then
6583     call randget
6584     call randpri(oo) ! Print the current point of
6585     endif ! the random number generator.
6586     c endif
6587    
6588     call IniNTrack ! Generate the next track.
6589     if(nevt.le.ninfo)then
6590     call PriMTrack(0) ! Print debug information
6591     call PriMTrack(1)
6592     call PriMTrack(2)
6593     call PriMTrack(3)
6594     call PriMTrack(4)
6595     endif
6596    
6597     call IniLsgvga ! Initialize gvga.inc
6598     call Iniabs ! Initialize abs.inc
6599     call Inirga ! Initialize rga.inc
6600     call Inidel ! Initialize del.inc
6601     call Inicel ! Initialize cel.inc
6602    
6603     call UBegEvent ! User's subroutine
6604    
6605     if(ssimioni.eq.1)call rafflev ! Generate the primary energy transfers
6606     ! from incoming particle
6607    
6608     if(soo.eq.1)then
6609     if(nevt.le.ninfo)then
6610     write(oo,*)
6611     call PriLsgvga ! Print debug information
6612     endif
6613     endif
6614    
6615     do iempty=1,10000
6616    
6617     if(soo.eq.1)then
6618     if(nevt.le.ninfo)then
6619     write(oo,*)
6620     write(oo,*)' before absorption of virtual photons:'
6621     call Priabs ! Print debug information
6622    
6623     endif
6624     endif
6625    
6626     call AbsGam ! Absorb the virtual photons
6627    
6628     if(soo.eq.1)then
6629     if(nevt.le.ninfo)then ! Print debug information
6630     write(oo,*)
6631     write(oo,*)' after absorption of virtual photons:'
6632    
6633     c call Priabs
6634     call Prirga
6635     call Pridel
6636    
6637     endif
6638     endif
6639    
6640     call GoGam ! Absorb the photons
6641    
6642     if(soo.eq.1)then
6643     if(nevt.le.ninfo)then ! Print debug information
6644     write(oo,*)
6645     write(oo,*)' after absorption of photons:'
6646    
6647     call Priabs
6648     c call Prirga
6649     call PrirgaF
6650    
6651     endif
6652     endif
6653    
6654     if(ctagam.gt.qtagam.and.crga.gt.qrga)then
6655     ! There are neither real no
6656     ! virtual photons to trace.
6657     goto 50 ! Exit the loop.
6658     endif
6659    
6660     enddo
6661    
6662     50 continue
6663    
6664    
6665     call treatdel ! Trace the delta-electrons
6666     ! and generate the conduction electrons.
6667     call treatcel ! Treat the cel.inc
6668     if(soo.eq.1)then
6669     if(nevt.le.ninfo)then ! since there are calculation of ranges
6670     ! which in wroute to del inside treatdel
6671     write(oo,*)
6672     call Pridel
6673     c call Pricel
6674     endif
6675     endif
6676    
6677     if(sHist.eq.1)then
6678     call Fhist ! Fill predetermined histograms
6679     endif
6680    
6681     call UEndEvent ! User's routine
6682    
6683     if(soo.eq.1)then
6684     if(nevt.eq.qevt)then
6685     write(oo,*)
6686     write(oo,*)nevt,' events is done'
6687     ! Printing the wornings about overful
6688     call WorPrirga
6689     call WorPriabs
6690     call WorPridel
6691     call WorPricel
6692    
6693     endif
6694     endif
6695    
6696    
6697     end
6698     +DECK,IniHeed1,IF=E1.
6699    
6700    
6701    
6702     subroutine IniHeed
6703     c
6704     c The program for estimation of the
6705     c ultimate coordinate resolution of the proportional chamber
6706     c
6707     c Also the table of clusters number distribution may be generated.
6708     c
6709    
6710     implicit none
6711    
6712     c include 'GoEvent.inc'
6713     +SEQ,GoEvent.
6714     c include 'hist.inc'
6715     +SEQ,hist.
6716    
6717     c include 'ener.inc'
6718     +SEQ,ener.
6719     c include 'atoms.inc'
6720     +SEQ,atoms.
6721     c include 'matters.inc'
6722     +SEQ,matters.
6723    
6724     c include 'molecules.inc'
6725     +SEQ,molecule.
6726    
6727     c include 'cconst.inc'
6728     +SEQ,cconst.
6729     c include 'volume.inc'
6730     +SEQ,volume.
6731     c include 'part.inc'
6732     +SEQ,part.
6733     c include 'h1.inc'
6734     +SEQ,h1.
6735     c include 'random.inc'
6736     +SEQ,random.
6737    
6738     real tkener,mas,momentum
6739     integer qmol,nmol(3)
6740     real wmol(3)
6741    
6742     integer i
6743     integer j
6744    
6745    
6746     real ystart, an, wid ! the last is widht of the chamber
6747     ! the angle
6748     ! it is calculated from two next values so as
6749     ! the middle was on zero
6750    
6751     real amc
6752     integer na
6753    
6754    
6755     write(6,*)' Initialization started'
6756     soo=1 ! To allow (1) or to ban (0) printing to stream oo.
6757     oo=10 ! set logical number of output stream.
6758     TaskName='heed01_2.'
6759     OutputFile=TaskName//'out'
6760     open(oo,FILE=OutputFile) ! open output disk file.
6761    
6762     sret_err = 0 ! Stop if error is detected
6763    
6764     c Auxiliary variables for histograms (from hist.inc)
6765     sHist=1 ! To allow (1) or to ban (0) dealing with histograms.
6766     HistFile=TaskName//'hist' ! File name, where they are written to.
6767     maxhisampl=40.0e-3 ! Maximum aplitude.
6768     maxhisampl2=20.0e-3 ! Reduced maximum aplitude.
6769     maxhisample=150 ! Maximum aplitude in unit of number of elect.
6770     pqhisampl=100 ! Number of bins.
6771     shfillrang=1 ! To allow (1) or to ban (0) filling histogram nh2_rd.
6772    
6773    
6774     c Random number genarator
6775     sseed=0 ! To make the generator start from seed point (1)
6776     ! or from default point (0).
6777     seed(1)=1121517854 ! this is example for sseed=1
6778     seed(2)=612958528
6779    
6780    
6781     qevt=1000 ! Quantity of events to generate
6782    
6783     ssimioni=1 ! To allow ionization loss (1) or to ban it (0)
6784     ninfo=0 ! Number of first events with output listing
6785    
6786    
6787    
6788    
6789    
6790    
6791    
6792    
6793     call Inishl ! Cascade from excited atom
6794    
6795     call IniEner(150,3e-6,0.2) ! Energy mesh
6796    
6797     c call PriEner
6798    
6799     call AtomsByDefault ! Library of atoms
6800     c call PriAtoms(0)
6801    
6802     Cur_Pressure=Atm_Pressure
6803     Cur_Temper=Atm_Temper
6804    
6805     c call Xenon_dens_Ar (1) ! Materials from LibAtMat
6806     c call Textolite (2)
6807     c call CF4 (1)
6808     c call CF4_without_cor (1)
6809     c call lCO2 (1)
6810     c call CO2_without_cor (1)
6811     c call CO250CF420Ar30(1)
6812     c call Ar80C2H620(1)
6813     c call lArgon (1)
6814     c call Ar93CH407 (1)
6815     c call Oxigen (1)
6816     c call Kripton (1)
6817    
6818     call molecdef
6819     c call Primolec
6820    
6821    
6822     qmol=3
6823     nmol(1)=numm_Ar
6824     wmol(1)=0.30
6825     nmol(2)=numm_CO2
6826     wmol(2)=0.50
6827     nmol(3)=numm_CF4
6828     wmol(3)=0.20
6829    
6830     call Inigas( 1, qmol, nmol, wmol, Cur_Pressure, Cur_Temper)
6831    
6832     c call PriMatter(0)
6833    
6834    
6835    
6836    
6837     wid=1.0 ! width of layer.
6838    
6839     call IniFVolume(0, 1, 1, 1, 0.0, wid )
6840    
6841     call PriVolume
6842    
6843    
6844     c mas=105.0 ! muon
6845     mas=938 ! proton
6846     c momentum=100000.0
6847     c tkener=sqrt(mas*mas+momentum*momentum)-mas
6848     tkener = mas * (4-1) ! 'mip'
6849    
6850     call IniPart(tkener,mas) ! Particle
6851     call PriPart
6852    
6853     c The special iinitialization for track
6854    
6855     c an=30.0
6856     an=0.0
6857     an=an * 2.0 * PI / 360.0 ! go from grad to radians
6858     ystart = wid*tan(an)/2
6859    
6860     call IniRTrack(-ystart, -ystart, an, real(PI/2.0)) ! Track
6861     c call PriTrack
6862    
6863     call IniCrosec ! Cross sections
6864     call PriCrosec(1,1)
6865    
6866    
6867     call InisBdel ! Data for tracing of delta-electrons
6868    
6869    
6870    
6871    
6872    
6873     c Additional histograms
6874    
6875     hhis=mhis/qhis
6876    
6877     qamp=5
6878     c ampc(1)=10.0
6879     c ampc(2)=30.0
6880     c ampc(3)=100.0
6881     c ampc(4)=300.0
6882     c ampc(5)=10000000.0
6883     c amc=19.82
6884     amc=22.29
6885     c amc=49.32
6886     c amc=49.32 * 2
6887     ampc(1)=amc
6888     ampc(2)=2*amc
6889     ampc(3)=3*amc
6890     ampc(4)=5*amc
6891     ampc(5)=10000000.0
6892    
6893     write(oo,*)' ampc=',ampc
6894    
6895    
6896     qe=0
6897    
6898     do na=1,qamp
6899     do j=1,qhis
6900     do i=1,2
6901     npp(j,i,na)=0
6902     pp1(j,i,na)=0.0
6903     pp2(j,i,na)=0.0
6904     enddo
6905     enddo
6906     enddo
6907    
6908     do na=1,qamp
6909     do i=1,2 ! distribution of the centers of gravity
6910     ! of ionization along x (1) and y (2)
6911     call hbook1(30000+10*na+(i-1)+1,' $',
6912     + 2*qhis,-mhis,mhis,0.0)
6913     enddo
6914     do i=3,6
6915     call hbook1(30000+10*na+(i-1)+1,' $',
6916     + qhis,0.0,mhis,0.0)
6917     enddo
6918     enddo
6919     meanprob=0.0
6920     meanvga=0.0
6921     meanvgal=0.0
6922     do i=1,1000
6923     prob(i)=0.0
6924     enddo
6925    
6926    
6927     write(6,*)' Initialization finished'
6928    
6929     end
6930    
6931    
6932    
6933     +DECK,UEvent1,IF=E1.
6934    
6935    
6936    
6937     subroutine UBegEvent
6938    
6939     implicit none
6940    
6941     c include 'GoEvent.inc'
6942     +SEQ,GoEvent.
6943    
6944    
6945     end
6946    
6947     subroutine UEndEvent
6948    
6949     implicit none
6950    
6951     c include 'GoEvent.inc'
6952     +SEQ,GoEvent.
6953     c include 'ener.inc'
6954     +SEQ,ener.
6955     c include 'atoms.inc'
6956     +SEQ,atoms.
6957     c include 'matters.inc'
6958     +SEQ,matters.
6959     c include 'volume.inc'
6960     +SEQ,volume.
6961     c include 'del.inc'
6962     +SEQ,del.
6963     c include 'cel.inc'
6964     +SEQ,cel.
6965     c include 'h1.inc'
6966     +SEQ,h1.
6967     c include 'lsgvga.inc'
6968     +SEQ,lsgvga.
6969    
6970     integer i,j,k,n,nb
6971     integer nc,na,nq
6972     real s,sz
6973     real*8 p(2) ! coordinates of center of gravity
6974     ! along x and y for current event.
6975     real x
6976    
6977    
6978     do i=1,2
6979     p(i)=0.0
6980     enddo
6981     nq=0
6982     sz=0.0
6983     do nc=1,qcel(1)
6984    
6985     nq=nq+1
6986     sz=sz+1
6987     do i=1,2
6988     p(i)=p(i)+pntcel(i,nc,1)*10000.0
6989     enddo
6990    
6991     enddo
6992    
6993     if(nq.gt.0)then
6994    
6995     qe=qe+1
6996    
6997     do i=1,2
6998     p(i)=p(i)/nq
6999     enddo
7000     do na=1,qamp
7001     if(sz.le.ampc(na))then
7002     call hfill(30000+10*na+1,real(p(1)),0.0,1.0)
7003     call hfill(30000+10*na+2,real(p(2)),0.0,1.0)
7004     endif
7005     enddo
7006     do na=1,qamp
7007     if(sz.le.ampc(na))then ! amplitude cut
7008     do j=1,qhis
7009     x=hhis*j
7010     do i=1,2
7011     if(abs(p(i)).le.x)then ! coordinate cut
7012     npp(j,i,na)=npp(j,i,na)+1
7013     pp1(j,i,na)=pp1(j,i,na)+p(i)
7014     pp2(j,i,na)=pp2(j,i,na)+p(i)*p(i)
7015     endif
7016     enddo
7017     enddo
7018     endif
7019     enddo
7020    
7021     endif
7022    
7023     n=0
7024     if(qcel(1).eq.0)then
7025     goto 10
7026     endif
7027     nb=Ptdel(Ndelcel(1,1))
7028     k=0
7029     do nc=1,qcel(1)+1
7030     k=0
7031     if(nc.eq.qcel(1)+1)then
7032     k=1
7033     else
7034     if(nc.gt.1.and.Ptdel(Ndelcel(nc,1)).ne.nb)then
7035     k=1
7036     endif
7037     endif
7038     if(k.eq.1)then
7039     if(n.le.0)then
7040     write(oo,*)' n=',n
7041     n=1
7042     endif
7043     if(n.ge.1001)then
7044     write(oo,*)' n=',n
7045     n=1000
7046     endif
7047     prob(n)=prob(n)+1
7048     n=1
7049     if(nc.le.qcel(1))then
7050     nb=Ptdel(Ndelcel(nc,1))
7051     endif
7052     else
7053     n=n+1
7054     endif
7055     enddo
7056     meanprob=meanprob+qcel(1)
7057     meanvga=meanvga+qgvga(1)
7058     meanvgal=meanvgal+esgvga(1)
7059    
7060     10 continue
7061    
7062     if(nevt.eq.qevt)then
7063     meanprob=meanprob/qevt
7064     meanvga=meanvga/qevt
7065     meanvgal=meanvgal/qevt
7066     s=0.0
7067     do n=1,1000
7068     s = s + prob(n)
7069     enddo
7070     do n=1,1000
7071     prob(n) = prob(n) / s
7072     enddo
7073    
7074     write(oo,*)
7075     + ' mean quantity of energy transfers from inc. part.= ',meanvga
7076     write(oo,*)
7077     + ' mean energy loss, Kev = ',
7078     + meanvgal*1000.0
7079     write(oo,*)
7080     + ' mean number of conduction electrons = ',meanprob
7081     write(oo,*)
7082     + ' number of conduction electrons in cluster vs probability:'
7083     do n=1,200
7084     write(oo,*)n,prob(n)
7085     enddo
7086    
7087     c do na=1,qamp
7088     c do j=1,qhis
7089     c do i=1,2
7090     c write(oo,*)' pp:',j,i,na,npp(j,i,na),pp1(j,i,na),pp2(j,i,na)
7091     c enddo
7092     c enddo
7093     c enddo
7094    
7095     do na=1,qamp
7096     do j=1,qhis
7097     do i=1,2
7098     if(npp(j,i,na).gt.0)then
7099     pp1(j,i,na)=pp1(j,i,na)/npp(j,i,na)
7100     pp2(j,i,na)=pp2(j,i,na)/npp(j,i,na)
7101     pp1(j,i,na)=sqrt(pp2(j,i,na)-pp1(j,i,na)*pp1(j,i,na))
7102     else
7103     pp1(j,i,na)=0.0
7104     endif
7105     enddo
7106     enddo
7107     enddo
7108    
7109     do na=1,qamp
7110     do j=1,qhis
7111     do i=1,2
7112     rpp1(j,i,na)=pp1(j,i,na)
7113     enddo
7114     enddo
7115     enddo
7116    
7117     do na=1,qamp
7118     do i=1,2
7119     call hpak(30002+10*na+i,rpp1(1,i,na))
7120     enddo
7121     enddo
7122    
7123     do na=1,qamp
7124     do j=1,qhis
7125     do i=1,2
7126     rpp2(j,i,na)=qe-npp(j,i,na)
7127     enddo
7128     enddo
7129     enddo
7130    
7131     do na=1,qamp
7132     do i=1,2
7133     call hpak(30004+10*na+i,rpp2(1,i,na))
7134     enddo
7135     enddo
7136    
7137     write(6,*)' The program finished'
7138    
7139     endif
7140    
7141    
7142     end
7143     +DECK,IniEner.
7144     SUBROUTINE IniEner(q,emin,emax)
7145     C
7146     c define the energy mesh for ionization loss
7147     c and photoabsorbtion
7148     c
7149     implicit none
7150    
7151     c include 'ener.inc'
7152     +SEQ,ener.
7153     C
7154     integer q
7155     real emin,emax
7156    
7157    
7158     qener=q
7159     call logscale(q,emin,emax,ener,enerc)
7160    
7161     END
7162    
7163     subroutine PriEner
7164    
7165     c include 'GoEvent.inc'
7166     +SEQ,GoEvent.
7167     c include 'ener.inc'
7168     +SEQ,ener.
7169    
7170     integer i
7171    
7172     if(soo.eq.0)return
7173     write(oo,*)
7174     write(oo,*)' PriEner: Energy mesh'
7175     write(oo,*)' qener=',qener
7176     write(oo,*)' ener, left edges enerc, the centers (MeV)'
7177     do i=1,qener
7178     write(oo,*)ener(i),enerc(i)
7179     enddo
7180    
7181     end
7182     +DECK,logscale.
7183     subroutine logscale(q,xmin,xmax,x,xc)
7184     c
7185     c Make a logariphmic mesh.
7186     c
7187     implicit none
7188     integer q
7189     real xmin,xmax
7190     real x(*),xc(*)
7191    
7192     real rk,xr
7193     integer i
7194     rk=(xmax/xmin)**(1.0/q)
7195     xr=xmin
7196     x(1)=xr
7197    
7198     do i=2,q+1
7199     x(i)=xr*rk
7200     xc(i-1)=(x(i-1)+x(i))*0.5
7201     xr=x(i)
7202     enddo
7203    
7204     end
7205    
7206     subroutine logscale0(q,xmin,xmax,x,xc)
7207     c
7208     c Make a logariphmic mesh with linear begin.
7209     c First, the logariohmic scale is calculated.
7210     c Second, the program tries to prolong it to zero
7211     c with the same number of points.
7212     c So several points of begin of logariphmic scale will be recalculeted.
7213     c
7214     implicit none
7215     integer q
7216     real xmin,xmax
7217     real x(*),xc(*)
7218     integer i,j
7219     real r,h
7220    
7221     call logscale(q,xmin,xmax,x,xc)
7222    
7223     if(q.ge.2)then
7224    
7225     do i=2,q
7226     r = x(i) / ( x(i+1) - x(i) )
7227     if( r .le. i-1 )then
7228     h = x(i) / ( i - 1 )
7229     x(1) = 0.0
7230     do j = 2,i
7231     x(j) = h * ( j - 1 )
7232     xc(j-1) = (x(j) + x(j-1))*0.5
7233     enddo
7234     go to 10
7235     endif
7236     enddo
7237     write(6,*)' error in logscale0'
7238     stop
7239    
7240     else
7241    
7242     write(6,*)' error in logscale0'
7243     stop
7244    
7245     endif
7246    
7247     10 end
7248     +DECK,Inishl.
7249    
7250    
7251    
7252     subroutine Inishl
7253    
7254     c Initialize common comshl
7255     c It will be very difficult
7256     c Modifying is the best way to loss your temper
7257     c Description of channels of getting exiting from atom
7258     c after photoabsorbtion and electron emission
7259    
7260     implicit none
7261    
7262     c include 'shl.inc'
7263     +SEQ,shl.
7264    
7265     integer n
7266    
7267     c qatm=0 !nahui!
7268     qatm=2
7269    
7270     c Argon
7271     charge(1)=18
7272     qshl(1)=5
7273     eshell(1,1)=.3178E-2
7274     eshell(2,1)=.3135E-3
7275     eshell(3,1)=.2479E-3
7276     eshell(4,1)=.2892E-4
7277     eshell(5,1)=.1449E-4
7278     qschl(1,1)=2
7279     qschl(2,1)=2
7280     qschl(3,1)=2
7281     qschl(4,1)=0
7282     qschl(5,1)=0
7283     secprobch(1,1,1)=0.878
7284     secprobch(2,1,1)=1.0
7285     secprobch(1,2,1)=0.999
7286     secprobch(2,2,1)=1.0
7287     secprobch(1,3,1)=0.999
7288     secprobch(2,3,1)=1.0
7289     qsel(1,1,1)=1
7290     qsga(1,1,1)=0
7291     qsel(2,1,1)=0
7292     qsga(2,1,1)=1
7293     qsel(1,2,1)=1
7294     qsga(1,2,1)=0
7295     qsel(2,2,1)=0
7296     qsga(2,2,1)=1
7297     qsel(1,3,1)=1
7298     qsga(1,3,1)=0
7299     qsel(2,3,1)=0
7300     qsga(2,3,1)=1
7301     secenel(1,1,1,1)=eshell(1,1)-2.0*eshell(5,1)
7302     secenga(1,2,1,1)=eshell(1,1)-eshell(5,1)
7303     secenel(1,1,2,1)=eshell(2,1)-2.0*eshell(5,1)
7304     secenga(1,2,2,1)=eshell(2,1)-eshell(5,1)
7305     secenel(1,1,3,1)=eshell(3,1)-2.0*eshell(5,1)
7306     secenga(1,2,3,1)=eshell(3,1)-eshell(5,1)
7307    
7308     c Xenon
7309     n=2
7310     charge(n)=54
7311     qshl(n)=6
7312     eshell(1,n)=0.041328
7313     c eshell(2,n)=0.006199
7314     eshell(2,n)=0.0041
7315     eshell(3,n)=0.000827
7316     eshell(4,n)=0.00031
7317     eshell(5,n)=8.265694e-05
7318     eshell(6,n)=1.239854e-05
7319     qschl(1,n)=2
7320     qschl(2,n)=2
7321     qschl(3,n)=0
7322     qschl(4,n)=0
7323     qschl(5,n)=0
7324     qschl(6,n)=0
7325     secprobch(1,1,n)=0.106
7326     secprobch(2,1,n)=1.0
7327     secprobch(1,2,n)=0.897
7328     secprobch(2,2,n)=1.0
7329     qsel(1,1,n)=1
7330     qsga(1,1,n)=0
7331     qsel(2,1,n)=0
7332     qsga(2,1,n)=1
7333     qsel(1,2,n)=1
7334     qsga(1,2,n)=0
7335     qsel(2,2,n)=0
7336     qsga(2,2,n)=1
7337     secenel(1,1,1,n)=eshell(1,n)-2.0*eshell(6,n)
7338     secenga(1,2,1,n)=eshell(1,n)-eshell(6,n)
7339     secenel(1,1,2,n)=eshell(2,n)-2.0*eshell(6,n)
7340     secenga(1,2,2,n)=eshell(2,n)-eshell(6,n)
7341    
7342    
7343     end
7344    
7345    
7346    
7347    
7348    
7349     subroutine Prishl
7350    
7351     c print the featcher of the mater
7352    
7353     implicit none
7354    
7355     c include 'GoEvent.inc'
7356     +SEQ,GoEvent.
7357     c include 'shl.inc'
7358     +SEQ,shl.
7359    
7360     integer iatm, ishl, ischl, isel, isga
7361    
7362     if(soo.eq.0)return
7363     write(oo,*)
7364     write(oo,*)' Prishl: print materials '
7365     write(oo,*)' qatm=',qatm
7366     do iatm=1,qatm
7367     write(oo,*)' ****atom=',iatm
7368     write(oo,*)' charge()=',charge(iatm),
7369     + ' qshl(iatm)= ',qshl(iatm)
7370     do ishl=1,qshl(iatm)
7371     write(oo,*)' ----number of shell=',ishl
7372     write(oo,*)' eshell(ishl,iatm)=',eshell(ishl,iatm),
7373     + ' qschl(ishl,iatm)=',qschl(ishl,iatm)
7374     do ischl=1,qschl(ishl,iatm)
7375     write(oo,*)' ------number of channel=',ischl
7376     write(oo,*)' qsel(ischl,ishl,iatm)=',qsel(ischl,ishl,iatm),
7377     + ' qsga(ischl,ishl,iatm)=',qsga(ischl,ishl,iatm)
7378     do isel=1,qsel(ischl,ishl,iatm)
7379     write(oo,*)' -------- electron number ',isel
7380     write(oo,*)' secenel(isel,ischl,ishl,iatm)=',
7381     + secenel(isel,ischl,ishl,iatm)
7382     enddo
7383     do isga=1,qsga(ischl,ishl,iatm)
7384     write(oo,*)' -------- photon number ',isga
7385     write(oo,*)' secenga(isga,ischl,ishl,iatm)=',
7386     + secenga(isga,ischl,ishl,iatm)
7387     enddo
7388     enddo
7389     enddo
7390     enddo
7391    
7392    
7393     end
7394     +DECK,LibAtMat.
7395     subroutine AtomsByDefault
7396     c
7397     c Initializations of several atoms
7398     c
7399     implicit none
7400    
7401     c include 'ener.inc'
7402     +SEQ,ener.
7403     c include 'atoms.inc'
7404     +SEQ,atoms.
7405     c include 'LibAtMat.inc'
7406     +SEQ,LibAtMat.
7407    
7408     c integer na
7409    
7410     KeyTeor=0
7411     QseqAt=0 ! It is necessary before run IniAtom
7412     ! ( if memory is not cleaned automatically).
7413     c do na=1,pQAt
7414     c num_at_mol(na)=0
7415     c enddo
7416    
7417    
7418     call IniAtom(num_H , 1, 1.0 ) ! H
7419     call IniAtom(num_H3 , 1, 1.0 ) ! H in CH4
7420     call IniAtom(num_H4 , 1, 1.0 ) ! H in NH3
7421     call IniAtom(num_He , 2, 4.0 ) ! He
7422     call IniAtom(num_Li , 3, 6.94) ! Li
7423     call IniAtom(num_C , 6, 12.01) ! C
7424     c num_at_mol(num_C1)=1
7425     call IniAtom(num_C1 , 6, 12.01) ! C in CO2
7426     c num_at_mol(num_C2)=2
7427     call IniAtom(num_C2 , 6, 12.01) ! C in CF4
7428     call IniAtom(num_C3 , 6, 12.01) ! C in CH4
7429     call IniAtom(num_N , 7, 14.01) ! N
7430     call IniAtom(num_O , 8, 16.0 ) ! O
7431     call IniAtom(num_F , 9, 19.0 ) ! F
7432     call IniAtom(num_Ne , 10, 20.2 ) ! Ne
7433     call IniAtom(num_Al , 13, 26.98) ! Al
7434     call IniAtom(num_Si , 14, 28.09) ! Si
7435     call IniAtom(num_Ar , 18, 40.0 ) ! Ar
7436     call IniAtom(num_Kr , 36, 84.0 ) ! Kr
7437     call IniAtom(num_Xe , 54, 131.3 ) ! Xe
7438     *** Additions (RV, 20/9/99).
7439     call IniAtom(num_S , 16, 32.066) ! S
7440    
7441     end
7442     +DECK,HELIUM,IF=NEVER.
7443     subroutine Helium(nm)
7444     c
7445     c Initialization of Matter
7446     c
7447     implicit none
7448    
7449     integer nm
7450     c include 'LibAtMat.inc'
7451     +SEQ,LibAtMat.
7452    
7453     integer A(10)
7454     real AW(10)
7455     integer q
7456     real Ad(10),AWd(10)
7457     integer qd
7458     real dens
7459     real gasdens
7460    
7461     q=1 ! Helium
7462     A(1)=num_He
7463     AW(1)=1
7464    
7465     qd=1
7466     Ad(1)=4.0
7467     AWd(1)=1
7468     dens=gasdens(Ad,AWd,qd)
7469     call IniMatter(nm,A,AW,q,dens,30.0e-6,0.19)
7470    
7471     end
7472     +DECK,AIR,IF=NEVER.
7473     subroutine Air(nm)
7474     c
7475     c Initialization of Matter
7476     c
7477     implicit none
7478    
7479     integer nm
7480     c include 'LibAtMat.inc'
7481     +SEQ,LibAtMat.
7482    
7483     integer A(10)
7484     real AW(10)
7485     integer q
7486     real Ad(10),AWd(10)
7487     integer qd
7488     real dens
7489     real gasdens
7490    
7491     q=2 ! Air
7492     A(1)=num_N ! N
7493     AW(1)=0.7
7494     A(2)=num_O ! O
7495     AW(1)=0.3
7496    
7497     qd=2
7498     Ad(1)=28.02
7499     AWd(1)=0.7
7500     Ad(2)=32
7501     AWd(2)=0.3
7502     dens=gasdens(Ad,AWd,qd)
7503     call IniMatter(nm,A,AW,q,dens,30.0e-6,0.19)
7504    
7505     end
7506     +DECK,LDME,IF=NEVER.
7507     SUBROUTINE LDME(NM)
7508     *-----------------------------------------------------------------------
7509     * LDME - Initialises DME data
7510     * (Last changed on 18/ 2/97.)
7511     *-----------------------------------------------------------------------
7512     implicit none
7513     +SEQ,LibAtMat.
7514     INTEGER A(10),Q,NM
7515     REAL AW(10),WORK,FANO,DENS
7516     *** Composition.
7517     Q=3
7518     A(1)=num_H
7519     AW(1)=6
7520     A(2)=num_O
7521     AW(2)=1
7522     A(3)=num_C3
7523     AW(3)=2
7524     *** Density.
7525     DENS=0.00191
7526     *** Work for a pair [MeV].
7527     WORK=30E-6
7528     *** Fano factor.
7529     FANO=0.19
7530     *** Initialise.
7531     CALL IniMatter(NM,A,AW,Q,DENS,WORK,FANO)
7532     END
7533     +DECK,N2O69,IF=NEVER.
7534     subroutine N2_0_69Torr(nm)
7535     c
7536     c N2 with presure 0.69 Torr
7537     c Initialization of Matter
7538     c
7539     implicit none
7540    
7541     integer nm
7542     c include 'LibAtMat.inc'
7543     +SEQ,LibAtMat.
7544    
7545     integer A(10)
7546     real AW(10)
7547     integer q
7548     real Ad(10),AWd(10)
7549     integer qd
7550     real dens
7551     real gasdens
7552    
7553     q=1 ! N
7554     A(1)=num_N ! N2
7555     AW(1)=1
7556     qd=1
7557     Ad(1)=2*14.0
7558     AWd(1)=1.0
7559     dens = gasdens(Ad,AWd,qd)
7560     dens = dens * (0.69/760.0)
7561     c dens = dens * (2.8/760.0)
7562     call IniMatter(nm,A,AW,q,dens,30.0e-6,0.19)
7563    
7564     end
7565     +DECK,OXIGEN,IF=NEVER.
7566     subroutine Oxigen(nm)
7567     c
7568     c Initialization of Matter
7569     c
7570     implicit none
7571    
7572     integer nm
7573     c include 'LibAtMat.inc'
7574     +SEQ,LibAtMat.
7575    
7576     integer A(10)
7577     real AW(10)
7578     integer q
7579     real Ad(10),AWd(10)
7580     integer qd
7581     real dens
7582     real gasdens
7583    
7584     q=1 ! O
7585     A(1)=num_O ! O2
7586     AW(1)=1
7587     qd=1
7588     Ad(1)=2*16.0
7589     AWd(1)=1.0
7590     dens=gasdens(Ad,AWd,qd)
7591     call IniMatter(nm,A,AW,q,dens,30.0e-6,0.19)
7592    
7593     end
7594     +DECK,LCO2,IF=NEVER.
7595     subroutine lCO2(nm)
7596     c
7597     c Initialization of Matter
7598     c
7599     implicit none
7600    
7601     integer nm
7602     c include 'LibAtMat.inc'
7603     +SEQ,LibAtMat.
7604    
7605     integer A(10)
7606     real AW(10)
7607     integer q
7608     real Ad(10),AWd(10)
7609     integer qd
7610     real dens
7611     real gasdens
7612    
7613     q=2 ! CO2
7614     A(1)=num_C1 ! C
7615     AW(1)=0.30
7616     A(2)=num_O ! O2
7617     AW(2)=0.60
7618     qd=1
7619     Ad(1) = 12.01 + 2*16.0
7620     AWd(1)= 1
7621     dens=gasdens(Ad,AWd,qd)
7622     call IniMatter(nm,A,AW,q,dens,33.0e-6,0.19)
7623    
7624     end
7625     +DECK,CO2WITHOUT,IF=NEVER.
7626     subroutine CO2_without_cor(nm)
7627     c
7628     c Initialization of Matter
7629     c
7630     implicit none
7631    
7632     integer nm
7633     c include 'LibAtMat.inc'
7634     +SEQ,LibAtMat.
7635    
7636     integer A(10)
7637     real AW(10)
7638     integer q
7639     real Ad(10),AWd(10)
7640     integer qd
7641     real dens
7642     real gasdens
7643    
7644     q=2 ! CO2
7645     A(1)=num_C ! C
7646     AW(1)=0.30
7647     A(2)=num_O ! O2
7648     AW(2)=0.60
7649     qd=1
7650     Ad(1) = 12.01 + 2*16.0
7651     AWd(1)= 1
7652     dens=gasdens(Ad,AWd,qd)
7653     call IniMatter(nm,A,AW,q,dens,33.0e-6,0.19)
7654    
7655     end
7656     +DECK,CF4,IF=NEVER.
7657     subroutine CF4(nm)
7658     c
7659     c Initialization of Matter
7660     c
7661     implicit none
7662    
7663     integer nm
7664     c include 'LibAtMat.inc'
7665     +SEQ,LibAtMat.
7666    
7667     integer A(10)
7668     real AW(10)
7669     integer q
7670     real Ad(10),AWd(10)
7671     integer qd
7672     real dens
7673     real gasdens
7674    
7675     q=2 ! CF4
7676     A(1)=num_C2 ! C
7677     AW(1)=0.30
7678     A(2)=num_F ! F
7679     AW(2)=1.20
7680     qd=1
7681     Ad(1) = 12.01 + 4*19.0
7682     AWd(1)= 1
7683     dens=gasdens(Ad,AWd,qd)
7684     call IniMatter(nm,A,AW,q,dens,34.3e-6,0.19)
7685    
7686     end
7687     +DECK,CF4WITHOUT,IF=NEVER.
7688     subroutine CF4_without_cor(nm)
7689     c
7690     c Initialization of Matter
7691     c
7692     implicit none
7693    
7694     integer nm
7695     c include 'LibAtMat.inc'
7696     +SEQ,LibAtMat.
7697    
7698     integer A(10)
7699     real AW(10)
7700     integer q
7701     real Ad(10),AWd(10)
7702     integer qd
7703     real dens
7704     real gasdens
7705    
7706     q=2 ! CF4
7707     A(1)=num_C ! C
7708     AW(1)=0.30
7709     A(2)=num_F ! F
7710     AW(2)=1.20
7711     qd=1
7712     Ad(1) = 12.01 + 4*19.0
7713     AWd(1)= 1
7714     dens=gasdens(Ad,AWd,qd)
7715     call IniMatter(nm,A,AW,q,dens,34.3e-6,0.19)
7716    
7717     end
7718     +DECK,CO250CF420,IF=NEVER.
7719     subroutine CO250CF420Ar30(nm)
7720     c
7721     c Initialization of Matter
7722     c
7723     implicit none
7724    
7725     integer nm
7726     c include 'LibAtMat.inc'
7727     +SEQ,LibAtMat.
7728    
7729     integer A(10)
7730     real AW(10)
7731     integer q
7732     real Ad(10),AWd(10)
7733     integer qd
7734     real dens
7735     real gasdens
7736     real w
7737    
7738     q=4 ! CO2 50% CF4 20% Ar 30%
7739     A(1)=num_C1 ! C
7740     AW(1)=0.50
7741     A(2)=num_O ! O
7742     AW(2)=1.00
7743     A(1)=num_C2 ! C
7744     AW(1)=0.20
7745     A(3)=num_F ! F
7746     AW(3)=0.8
7747     A(4)=num_Ar ! Ar
7748     AW(4)=0.30
7749     qd=3
7750     Ad(1)=12.0+2*16.0 ! CO2
7751     AWd(1)=0.50
7752     Ad(2)=12.0+4*19.0 ! CF4
7753     AWd(2)=0.20
7754     Ad(3)=40.0 ! Ar
7755     AWd(3)=0.30
7756     dens=gasdens(Ad,AWd,qd)
7757     w=AWd(1)*33.0e-6 + AWd(2)*34.3e-6 + AWd(3)*26.4e-6
7758    
7759     call IniMatter(nm,A,AW,q,dens,w,0.19)
7760    
7761     end
7762     +DECK,LARGON,IF=NEVER.
7763     subroutine lArgon(nm)
7764     c
7765     c Initialization of Matter
7766     c
7767     implicit none
7768    
7769     integer nm
7770     c include 'LibAtMat.inc'
7771     +SEQ,LibAtMat.
7772    
7773     integer A(10)
7774     real AW(10)
7775     integer q
7776     real Ad(10),AWd(10)
7777     integer qd
7778     real dens
7779     real gasdens
7780    
7781     q=1 ! Ar
7782     A(1)=num_Ar ! Ar
7783     AW(1)=1.0
7784     qd=1
7785     Ad(1)=40.0
7786     AWd(1)=1.0
7787     dens=gasdens(Ad,AWd,qd)
7788     call IniMatter(nm,A,AW,q,dens,26.4e-6,0.19)
7789    
7790     end
7791     +DECK,AR95CH405,IF=NEVER.
7792     subroutine Ar95CH405(nm)
7793     c
7794     c Initialization of Matter
7795     c
7796     implicit none
7797    
7798     integer nm
7799     c include 'LibAtMat.inc'
7800     +SEQ,LibAtMat.
7801    
7802     integer A(10)
7803     real AW(10)
7804     integer q
7805     real Ad(10),AWd(10)
7806     integer qd
7807     real dens
7808     real gasdens
7809    
7810     q=3 ! Ar
7811     A(1)=num_Ar ! Ar
7812     AW(1)=0.95
7813     A(2)=num_C ! C
7814     AW(2)=0.05
7815     A(3)=num_H ! H
7816     AW(3)=0.20
7817     qd=2
7818     Ad(1)=40.0
7819     AWd(1)=0.95
7820     Ad(2)=12+4*1
7821     AWd(2)=0.05
7822    
7823     dens=gasdens(Ad,AWd,qd)
7824     call IniMatter(nm,A,AW,q,dens,26.4e-6,0.19)
7825    
7826     end
7827     +DECK,AR93CH407,IF=NEVER.
7828     subroutine Ar93CH407(nm)
7829     c
7830     c Initialization of Matter
7831     c
7832     implicit none
7833    
7834     integer nm
7835     c include 'LibAtMat.inc'
7836     +SEQ,LibAtMat.
7837    
7838     integer A(10)
7839     real AW(10)
7840     integer q
7841     real Ad(10),AWd(10)
7842     integer qd
7843     real dens
7844     real gasdens
7845    
7846     q=3 ! Ar
7847     A(1)=num_Ar ! Ar
7848     AW(1)=0.93
7849     A(2)=num_C ! C
7850     AW(2)=0.07
7851     A(3)=num_H ! H
7852     AW(3)=0.28
7853     qd=2
7854     Ad(1)=40.0
7855     AWd(1)=0.93
7856     Ad(2)=12+4*1
7857     AWd(2)=0.07
7858    
7859     dens=gasdens(Ad,AWd,qd)
7860     call IniMatter(nm,A,AW,q,dens,26.4e-6,0.19)
7861    
7862     end
7863     +DECK,AR90CH410,IF=NEVER.
7864     subroutine Ar90CH410(nm)
7865     c
7866     c Initialization of Matter
7867     c
7868     implicit none
7869    
7870     integer nm
7871     c include 'LibAtMat.inc'
7872     +SEQ,LibAtMat.
7873    
7874     integer A(10)
7875     real AW(10)
7876     integer q
7877     real Ad(10),AWd(10)
7878     integer qd
7879     real dens
7880     real gasdens
7881    
7882     q=3 ! Ar
7883     A(1)=num_Ar ! Ar
7884     AW(1)=0.90
7885     A(2)=num_C ! C
7886     AW(2)=0.10
7887     A(3)=num_H ! H
7888     AW(3)=0.40
7889     qd=2
7890     Ad(1)=40.0
7891     AWd(1)=0.90
7892     Ad(2)=12+4*1
7893     AWd(2)=0.10
7894    
7895     dens=gasdens(Ad,AWd,qd)
7896     call IniMatter(nm,A,AW,q,dens,26.4e-6,0.19)
7897    
7898     end
7899     +DECK,AR80C2H620,IF=NEVER.
7900     subroutine Ar80C2H620(nm)
7901     c
7902     c Initialization of Matter
7903     c
7904     implicit none
7905    
7906     integer nm
7907     c include 'LibAtMat.inc'
7908     +SEQ,LibAtMat.
7909    
7910     integer A(10)
7911     real AW(10)
7912     integer q
7913     real Ad(10),AWd(10)
7914     integer qd
7915     real dens
7916     real gasdens
7917    
7918     q=3 ! Ar
7919     A(1)=num_Ar ! Ar
7920     AW(1)=0.80
7921     A(2)=num_C ! C
7922     AW(2)=0.20*2
7923     A(3)=num_H ! H
7924     AW(3)=0.20*6
7925     qd=2
7926     Ad(1)=40.0
7927     AWd(1)=0.80
7928     Ad(2)=2*12.0+6*1.0
7929     AWd(2)=0.20
7930    
7931     dens=gasdens(Ad,AWd,qd)
7932     call IniMatter(nm,A,AW,q,dens,26.4e-6,0.19)
7933    
7934     end
7935     +DECK,KRIPTON,IF=NEVER.
7936     subroutine Kripton(nm)
7937     c
7938     c Initialization of Matter
7939     c
7940     implicit none
7941    
7942     integer nm
7943     c include 'LibAtMat.inc'
7944     +SEQ,LibAtMat.
7945    
7946     integer A(10)
7947     real AW(10)
7948     integer q
7949     real Ad(10),AWd(10)
7950     integer qd
7951     real dens
7952     real gasdens
7953    
7954     q=1 ! Kr
7955     A(1)=num_Kr ! Kr
7956     AW(1)=1.0
7957     qd=1
7958     Ad(1)=84.0
7959     AWd(1)=1.0
7960     dens=gasdens(Ad,AWd,qd)
7961     call IniMatter(nm,A,AW,q,dens,24.4e-6,0.19)
7962    
7963     end
7964     +DECK,XENON,IF=NEVER.
7965     subroutine Xenon(nm)
7966     c
7967     c Initialization of Matter
7968     c
7969     implicit none
7970    
7971     integer nm
7972     c include 'LibAtMat.inc'
7973     +SEQ,LibAtMat.
7974    
7975     integer A(10)
7976     real AW(10)
7977     integer q
7978     real Ad(10),AWd(10)
7979     integer qd
7980     real dens
7981     real gasdens
7982    
7983     q=1 ! Xe
7984     A(1)=num_Xe ! Xe
7985     AW(1)=1.0
7986     qd=1
7987     Ad(1)=131.3
7988     AWd(1)=1.0
7989     dens=gasdens(Ad,AWd,qd)
7990     call IniMatter(nm,A,AW,q,dens,21.9e-6,0.19)
7991    
7992     end
7993     +DECK,XE90CH410,IF=NEVER.
7994     subroutine Xe90CH410(nm)
7995     c
7996     c Initialization of Matter
7997     c
7998     implicit none
7999    
8000     integer nm
8001     c include 'LibAtMat.inc'
8002     +SEQ,LibAtMat.
8003    
8004     integer A(10)
8005     real AW(10)
8006     integer q
8007     real Ad(10),AWd(10)
8008     integer qd
8009     real dens
8010     real gasdens
8011    
8012     q=3 ! 90% Xe + 10% CH4
8013     A(1)=num_Xe ! Xe
8014     AW(1)=0.90
8015     A(2)=num_C ! C
8016     AW(2)=0.10
8017     A(3)=num_H ! H4
8018     AW(3)=0.40
8019     qd=2
8020     Ad(1)=131.3
8021     AWd(1)=0.90
8022     Ad(2) = 12.01 + 4*1.0
8023     AWd(2)= 0.10
8024     dens=gasdens(Ad,AWd,qd)
8025     call IniMatter(nm,A,AW,q,dens,21.9e-6,0.19)
8026    
8027     end
8028     +DECK,XE95CH405,IF=NEVER.
8029     subroutine Xe95CH405(nm)
8030     c
8031     c Initialization of Matter
8032     c
8033     implicit none
8034    
8035     integer nm
8036     c include 'LibAtMat.inc'
8037     +SEQ,LibAtMat.
8038    
8039     integer A(10)
8040     real AW(10)
8041     integer q
8042     real Ad(10),AWd(10)
8043     integer qd
8044     real dens
8045     real gasdens
8046    
8047     q=3 ! 95% Xe + 05% CH4
8048     A(1)=num_Xe ! Xe
8049     AW(1)=0.95
8050     A(2)=num_C ! C
8051     AW(2)=0.05
8052     A(3)=num_H ! H4
8053     AW(3)=0.20
8054     qd=2
8055     Ad(1)=131.3
8056     AWd(1)=0.95
8057     Ad(2) = 12.01 + 4*1.0
8058     AWd(2)= 0.05
8059     dens=gasdens(Ad,AWd,qd)
8060     call IniMatter(nm,A,AW,q,dens,21.9e-6,0.19)
8061    
8062     end
8063     +DECK,XE70,CH430,IF=NEVER.
8064     subroutine Xe70CH430(nm)
8065     c
8066     c Initialization of Matter
8067     c
8068     implicit none
8069    
8070     integer nm
8071     c include 'LibAtMat.inc'
8072     +SEQ,LibAtMat.
8073    
8074     integer A(10)
8075     real AW(10)
8076     integer q
8077     real Ad(10),AWd(10)
8078     integer qd
8079     real dens
8080     real gasdens
8081    
8082     q=3 ! 70% Xe + 30% CH4
8083     A(1)=num_Xe ! Xe
8084     AW(1)=0.70
8085     A(2)=num_C ! C
8086     AW(2)=0.30
8087     A(3)=num_H ! H4
8088     AW(3)=1.2
8089     qd=2
8090     Ad(1)=131.3
8091     AWd(1)=0.70
8092     Ad(2) = 12.01 + 4*1.0
8093     AWd(2)= 0.30
8094     dens=gasdens(Ad,AWd,qd)
8095     call IniMatter(nm,A,AW,q,dens,21.9e-6,0.19)
8096    
8097     end
8098     +DECK,XE875CH4,IF=NEVER.
8099     subroutine Xe875CH4075C3H805(nm)
8100     c
8101     c Initialization of Matter
8102     c
8103     implicit none
8104    
8105     integer nm
8106     c include 'LibAtMat.inc'
8107     +SEQ,LibAtMat.
8108    
8109     integer A(10)
8110     real AW(10)
8111     integer q
8112     real Ad(10),AWd(10)
8113     integer qd
8114     real dens
8115     real gasdens
8116    
8117     q=3 ! 87.5% Xe + 7.5% CH4 + 5% C3H8
8118     A(1)=num_Xe ! Xe
8119     AW(1)=0.875
8120     A(2)=num_C ! C
8121     AW(2)=0.05*3 + 0.075
8122     A(3)=num_H ! H
8123     AW(3)=0.05*8 + 0.075*4
8124     qd=3
8125     Ad(1)=131.3
8126     AWd(1)=0.875
8127     Ad(2) = 12.01 + 4*1.0
8128     AWd(2)= 0.075
8129     Ad(3) = 3*12.01 + 8*1.0
8130     AWd(3)= 0.05
8131     dens=gasdens(Ad,AWd,qd)
8132     call IniMatter(nm,A,AW,q,dens,21.9e-6,0.19)
8133    
8134     end
8135     +DECK,XE70CO2230,IF=NEVER.
8136     subroutine Xe70CO230(nm)
8137     c
8138     c Initialization of Matter
8139     c
8140     implicit none
8141    
8142     integer nm
8143     c include 'LibAtMat.inc'
8144     +SEQ,LibAtMat.
8145    
8146     integer A(10)
8147     real AW(10)
8148     integer q
8149     real Ad(10),AWd(10)
8150     integer qd
8151     real dens
8152     real gasdens
8153     real w
8154    
8155    
8156     q=3 ! 70% Xe + 30% CO2
8157     A(1)=num_Xe ! Xe
8158     AW(1)=0.70
8159     A(2)=num_C1 ! C
8160     AW(2)=0.30
8161     A(3)=num_O ! O2
8162     AW(3)=0.60
8163     qd=2
8164     Ad(1)=131.3
8165     AWd(1)=0.70
8166     Ad(2) = 12.01 + 2*16.0
8167     AWd(2)= 0.30
8168     dens=gasdens(Ad,AWd,qd)
8169     w=AWd(1)*21.9e-6 + 0.30*33.0e-6
8170     call IniMatter(nm,A,AW,q,dens,w,0.19)
8171    
8172     end
8173     +DECK,XENONAR,IF=NEVER.
8174     subroutine Xenon_dens_Ar(nm)
8175     c
8176     c Initialization of Matter
8177     c
8178     implicit none
8179    
8180     integer nm
8181     c include 'LibAtMat.inc'
8182     +SEQ,LibAtMat.
8183    
8184     integer A(10)
8185     real AW(10)
8186     integer q
8187     real Ad(10),AWd(10)
8188     integer qd
8189     real dens
8190     real gasdens
8191    
8192     q=1 ! Xe with density of Ar
8193     A(1)=num_Xe ! Xe
8194     AW(1)=1.0
8195     qd=1
8196     Ad(1)=40.0
8197     AWd(1)=1.0
8198     dens=gasdens(Ad,AWd,qd)
8199     c qd=1
8200     c Ad(1)=131.3
8201     c AWd(1)=1.0
8202     c dens=gasdens(Ad,AWd,qd)
8203     call IniMatter(nm,A,AW,q,dens,21.9e-6,0.19)
8204    
8205     end
8206     +DECK,LITHIUM,IF=NEVER.
8207     subroutine Lithium(nm)
8208     c
8209     c Initialization of Matter
8210     c
8211     implicit none
8212    
8213     integer nm
8214     c include 'LibAtMat.inc'
8215     +SEQ,LibAtMat.
8216    
8217     integer A(10)
8218     real AW(10)
8219     integer q
8220     real Ad(10),AWd(10)
8221     integer qd
8222     real dens
8223     real gasdens
8224    
8225     q=1 ! Lithium
8226     A(1)=num_Li
8227     AW(1)=1
8228     dens=0.53
8229     call IniMatter(nm,A,AW,q,dens,30.0e-6,0.19)
8230     *** Added argument to PriMatter (RV 13/4/99).
8231     c call PriMatter(0)
8232     *** End of modification.
8233    
8234     end
8235     +DECK,POLYETHYL,IF=NEVER.
8236     subroutine Polyethylene(nm)
8237     c
8238     c Initialization of Matter
8239     c
8240     implicit none
8241    
8242     integer nm
8243     c include 'LibAtMat.inc'
8244     +SEQ,LibAtMat.
8245    
8246     integer A(10)
8247     real AW(10)
8248     integer q
8249     real Ad(10),AWd(10)
8250     integer qd
8251     real dens
8252     real gasdens
8253    
8254     q=2 ! Polyethylene CH2
8255     A(1)=num_H ! H2
8256     AW(1)=2
8257     A(2)=num_C ! C
8258     AW(2)=1
8259     dens=0.925
8260     call IniMatter(nm,A,AW,q,dens,30.0e-6,0.19)
8261    
8262     end
8263     +DECK,MYLAR,IF=NEVER.
8264     subroutine Mylar(nm)
8265     c
8266     c Initialization of Matter
8267     c
8268     implicit none
8269    
8270     integer nm
8271     c include 'LibAtMat.inc'
8272     +SEQ,LibAtMat.
8273    
8274     integer A(10)
8275     real AW(10)
8276     integer q
8277     real Ad(10),AWd(10)
8278     integer qd
8279     real dens
8280     real gasdens
8281    
8282     q=3 ! mylar C5H4O2
8283     A(1)=num_C ! C5
8284     AW(1)=5
8285     A(2)=num_H ! H4
8286     AW(2)=4
8287     A(3)=num_O ! O2
8288     AW(3)=2
8289     dens=1.38
8290     call IniMatter(nm,A,AW,q,dens,30.0e-6,0.19)
8291    
8292     end
8293     +DECK,ALUMINIUM,IF=NEVER.
8294     subroutine Aluminium(nm)
8295     c
8296     c Initialization of Matter
8297     c
8298     implicit none
8299    
8300     integer nm
8301     c include 'LibAtMat.inc'
8302     +SEQ,LibAtMat.
8303    
8304     integer A(10)
8305     real AW(10)
8306     integer q
8307     real Ad(10),AWd(10)
8308     integer qd
8309     real dens
8310     real gasdens
8311    
8312     q=1 ! aluminium
8313     A(1)=num_Al ! Al
8314     AW(1)=1
8315     dens=2.7
8316     call IniMatter(nm,A,AW,q,dens,30.0e-6,0.19)
8317    
8318     end
8319     +DECK,TEXTOLITE,IF=NEVER.
8320     subroutine Textolite(nm)
8321     c
8322     c Initialization of Matter
8323     c
8324     implicit none
8325    
8326     integer nm
8327     c include 'LibAtMat.inc'
8328     +SEQ,LibAtMat.
8329    
8330     integer A(10)
8331     real AW(10)
8332     integer q
8333     real dens
8334     c textolite is SiO2 + epoxidka. The density is 1.7 g/sm**3.
8335     c We know also the density of SiO2 - 2.5 g/sm**3 and the typical
8336     c density of the carbone polimers is 1 g/sm**3.
8337     c "epoxidka"( I don not know its right english name) is
8338     c a class of polimers. One of them is O-3, C-18, H-20.
8339     c We did't know
8340     c the ratio of the components in textolite, but knowing data above
8341     c we can calculate it.
8342     c DATA WTEX/12., 27.0, 18. ,20./
8343     c later comments
8344     c 05.04.95
8345     c If Wi is weight coef. by volume and Di is density than
8346     c W1*D1+(1-W1)*D2=D => W1=(D-D2)/(D1-D2)=0.466
8347     c W2=(D1-D)/(D1-D2)=0.534
8348     c If WKi is weight coef. by volume than
8349     c WK1=D1/A1 * W1=2.5/60 * 0.466 = 0.0194
8350     c WK2=D2/A2 * W2=1.0/284 * 0.534 = 0.00188
8351     c WK1/WK2 = 10.3
8352     c DATA WTEX/10.3, 23.6, 18. ,20./
8353    
8354    
8355    
8356    
8357     q=4 ! textolite
8358     A(1)=num_Si
8359     AW(1)=10.3
8360     A(2)=num_O
8361     AW(2)=23.6
8362     A(3)=num_C
8363     AW(3)=18.
8364     A(4)=num_H
8365     AW(4)=20.
8366     dens=1.7
8367     call IniMatter(nm,A,AW,q,dens,30.0e-6,0.19)
8368    
8369     end
8370     +DECK,molecdef.
8371     subroutine molecdef
8372    
8373     implicit none
8374    
8375     c include 'ener.inc'
8376     +SEQ,ener.
8377     c include 'atoms.inc'
8378     +SEQ,atoms.
8379    
8380     c include 'molecules.inc'
8381     +SEQ,molecule.
8382     c include 'molecdef.inc'
8383     +SEQ,molecdef.
8384     c include 'LibAtMat.inc'
8385     +SEQ,LibAtMat.
8386    
8387     integer n,na
8388     real s
8389    
8390     c Mean work per pair production is accordingly with
8391     c ICRU REPORT 31, Average Energy Required To Produce An Ion Pair, 1979.
8392    
8393    
8394     qSAtMol( numm_He)=1
8395     nAtMol(1,numm_He)=num_He
8396     qAtMol(1,numm_He)=1
8397     WWWMol( numm_He)=41.0e-6
8398     FFFMol( numm_He)=0.19
8399    
8400     qSAtMol( numm_Ne)=1
8401     nAtMol(1,numm_Ne)=num_Ne
8402     qAtMol(1,numm_Ne)=1
8403     WWWMol( numm_Ne)=35.4e-6
8404     FFFMol( numm_Ne)=0.19
8405    
8406     qSAtMol( numm_Ar)=1
8407     nAtMol(1,numm_Ar)=num_Ar
8408     qAtMol(1,numm_Ar)=1
8409     WWWMol( numm_Ar)=26.0e-6
8410     FFFMol( numm_Ar)=0.19
8411    
8412     qSAtMol( numm_Kr)=1
8413     nAtMol(1,numm_Kr)=num_Kr
8414     qAtMol(1,numm_Kr)=1
8415     WWWMol( numm_Kr)=24.0e-6
8416     FFFMol( numm_Kr)=0.19
8417    
8418     qSAtMol( numm_Xe)=1
8419     nAtMol(1,numm_Xe)=num_Xe
8420     qAtMol(1,numm_Xe)=1
8421     WWWMol( numm_Xe)=22.0e-6
8422     FFFMol( numm_Xe)=0.19
8423    
8424     qSAtMol( numm_H2)=1
8425     nAtMol(1,numm_H2)=num_H
8426     qAtMol(1,numm_H2)=2
8427     WWWMol( numm_H2)=37.0e-6
8428     FFFMol( numm_H2)=0.19
8429    
8430     qSAtMol( numm_N2)=1
8431     nAtMol(1,numm_N2)=num_N
8432     qAtMol(1,numm_N2)=2
8433     WWWMol( numm_N2)=35.0e-6
8434     FFFMol( numm_N2)=0.19
8435    
8436     qSAtMol( numm_O2)=1
8437     nAtMol(1,numm_O2)=num_O
8438     qAtMol(1,numm_O2)=2
8439     WWWMol( numm_O2)=31.0e-6
8440     FFFMol( numm_O2)=0.19
8441    
8442     qSAtMol( numm_NH3)=2
8443     nAtMol(1,numm_NH3)=num_N
8444     qAtMol(1,numm_NH3)=1
8445     nAtMol(2,numm_NH3)=num_H4
8446     qAtMol(2,numm_NH3)=3
8447     WWWMol( numm_NH3)=26.6e-6
8448     FFFMol( numm_NH3)=0.19
8449    
8450     qSAtMol( numm_N2O)=2
8451     nAtMol(1,numm_N2O)=num_N
8452     qAtMol(1,numm_N2O)=2
8453     nAtMol(2,numm_N2O)=num_O
8454     qAtMol(2,numm_N2O)=1
8455     WWWMol( numm_N2O)=32.6e-6
8456     FFFMol( numm_N2O)=0.19
8457    
8458     qSAtMol( numm_CO2)=2
8459     nAtMol(1,numm_CO2)=num_C1
8460     qAtMol(1,numm_CO2)=1
8461     nAtMol(2,numm_CO2)=num_O
8462     qAtMol(2,numm_CO2)=2
8463     WWWMol( numm_CO2)=33.0e-6
8464     FFFMol( numm_CO2)=0.19
8465    
8466     qSAtMol( numm_CF4)=2
8467     nAtMol(1,numm_CF4)=num_C2
8468     qAtMol(1,numm_CF4)=1
8469     nAtMol(2,numm_CF4)=num_F
8470     qAtMol(2,numm_CF4)=4
8471     WWWMol( numm_CF4)=34.3e-6
8472     FFFMol( numm_CF4)=0.19
8473    
8474     qSAtMol( numm_CH4)=2
8475     nAtMol(1,numm_CH4)=num_C3
8476     qAtMol(1,numm_CH4)=1
8477     nAtMol(2,numm_CH4)=num_H3
8478     qAtMol(2,numm_CH4)=4
8479     WWWMol( numm_CH4)=27.3e-6
8480     FFFMol( numm_CH4)=0.19
8481    
8482     qSAtMol( numm_C2H2)=2
8483     nAtMol(1,numm_C2H2)=num_C3
8484     qAtMol(1,numm_C2H2)=2
8485     nAtMol(2,numm_C2H2)=num_H3
8486     qAtMol(2,numm_C2H2)=2
8487     WWWMol( numm_C2H2)=25.8e-6
8488     FFFMol( numm_C2H2)=0.19
8489    
8490     qSAtMol( numm_C2H4)=2
8491     nAtMol(1,numm_C2H4)=num_C3
8492     qAtMol(1,numm_C2H4)=2
8493     nAtMol(2,numm_C2H4)=num_H3
8494     qAtMol(2,numm_C2H4)=4
8495     WWWMol( numm_C2H4)=25.8e-6
8496     FFFMol( numm_C2H4)=0.19
8497    
8498     qSAtMol( numm_C2H6)=2
8499     nAtMol(1,numm_C2H6)=num_C3
8500     qAtMol(1,numm_C2H6)=2
8501     nAtMol(2,numm_C2H6)=num_H3
8502     qAtMol(2,numm_C2H6)=6
8503     WWWMol( numm_C2H6)=25.0e-6
8504     FFFMol( numm_C2H6)=0.19
8505    
8506     qSAtMol( numm_C3H8)=2
8507     nAtMol(1,numm_C3H8)=num_C3
8508     qAtMol(1,numm_C3H8)=3
8509     nAtMol(2,numm_C3H8)=num_H3
8510     qAtMol(2,numm_C3H8)=8
8511     WWWMol( numm_C3H8)=24.0e-6
8512     FFFMol( numm_C3H8)=0.19
8513    
8514     qSAtMol( numm_iC4H10)=2
8515     nAtMol(1,numm_iC4H10)=num_C3
8516     qAtMol(1,numm_iC4H10)=4
8517     nAtMol(2,numm_iC4H10)=num_H3
8518     qAtMol(2,numm_iC4H10)=10
8519     WWWMol( numm_iC4H10)=23.4e-6
8520     FFFMol( numm_iC4H10)=0.19
8521    
8522     *** Addition (RV 14/1/00).
8523     qSAtMol( numm_C5H12)=2
8524     nAtMol(1,numm_C5H12)=num_C3
8525     qAtMol(1,numm_C5H12)=5
8526     nAtMol(2,numm_C5H12)=num_H3
8527     qAtMol(2,numm_C5H12)=12
8528     WWWMol( numm_C5H12)=23.2e-6 ! ICRU report 31
8529     FFFMol( numm_C5H12)=0.19
8530     *** End of addition.
8531    
8532     qSAtMol( numm_C)=1 ! for debug
8533     nAtMol(1,numm_C)=num_C
8534     qAtMol(1,numm_C)=1
8535     WWWMol( numm_C)=31.0e-6
8536     FFFMol( numm_C)=0.19
8537    
8538     *** Additions (RV 4/9/98).
8539     qSAtMol( numm_DME)=3
8540     nAtMol(1,numm_DME)=num_C3
8541     qAtMol(1,numm_DME)=2
8542     nAtMol(2,numm_DME)=num_H
8543     qAtMol(2,numm_DME)=6
8544     nAtMol(3,numm_DME)=num_O
8545     qAtMol(3,numm_DME)=1
8546     WWWMol( numm_DME)=45.4e-6
8547     FFFMol( numm_DME)=0.19
8548    
8549     qSAtMol( numm_H2O)=2
8550     nAtMol(1,numm_H2O)=num_H
8551     qAtMol(1,numm_H2O)=2
8552     nAtMol(2,numm_H2O)=num_O
8553     qAtMol(2,numm_H2O)=1
8554     WWWMol( numm_H2O)=29.6e-6 ! ICRU 31 (1/5/79)
8555     FFFMol( numm_H2O)=0.19
8556    
8557     *** Additions (RV 20/9/99).
8558     qSAtMol( numm_SF6)=2
8559     nAtMol(1,numm_SF6)=num_S
8560     qAtMol(1,numm_SF6)=1
8561     nAtMol(2,numm_SF6)=num_F
8562     qAtMol(2,numm_SF6)=6
8563     WWWMol( numm_SF6)=35.75e-6 ! ICRU 31 (1/5/79)
8564     FFFMol( numm_SF6)=0.19
8565    
8566     qSAtMol( numm_C2F4H2)=3
8567     nAtMol(1,numm_C2F4H2)=num_C3
8568     qAtMol(1,numm_C2F4H2)=2
8569     nAtMol(2,numm_C2F4H2)=num_F
8570     qAtMol(2,numm_C2F4H2)=4
8571     nAtMol(3,numm_C2F4H2)=num_H
8572     qAtMol(3,numm_C2F4H2)=2
8573     WWWMol( numm_C2F4H2)=24.0e-6 ! Guess
8574     FFFMol( numm_C2F4H2)=0.19
8575    
8576     qSAtMol( numm_C2F5H)=3
8577     nAtMol(1,numm_C2F5H)=num_C3
8578     qAtMol(1,numm_C2F5H)=2
8579     nAtMol(2,numm_C2F5H)=num_F
8580     qAtMol(2,numm_C2F5H)=5
8581     nAtMol(3,numm_C2F5H)=num_H
8582     qAtMol(3,numm_C2F5H)=1
8583     WWWMol( numm_C2F5H)=24.0e-6 ! Guess
8584     FFFMol( numm_C2F5H)=0.19
8585    
8586     *** End of additions.
8587    
8588     c qSAtMol( numm_CClF3)=2
8589     c nAtMol(1,numm_CClF3)=num_C3
8590     c qAtMol(1,numm_CClF3)=1
8591     c nAtMol(1,numm_CClF3)=num_Cl
8592     c qAtMol(1,numm_CClF3)=1
8593     c nAtMol(2,numm_CClF3)=num_F
8594     c qAtMol(2,numm_CClF3)=3
8595     c WWWMol( numm_CClF3)=24.0e-6
8596     c FFFMol( numm_CClF3)=0.19
8597    
8598    
8599    
8600     do n=1,pqMol
8601     s=0.0
8602     do na=1,qSAtMol(n)
8603     s=s+Aat(nAtMol(na,n))*qAtMol(na,n)
8604     enddo
8605     weiMol(n)=s
8606     enddo
8607    
8608    
8609     end
8610    
8611    
8612    
8613    
8614     subroutine Primolec
8615    
8616     implicit none
8617    
8618     c include 'GoEvent.inc'
8619     +SEQ,GoEvent.
8620     c include 'molecules.inc'
8621     +SEQ,molecule.
8622     c include 'molecdef.inc'
8623     +SEQ,molecdef.
8624     c include 'LibAtMat.inc'
8625     +SEQ,LibAtMat.
8626    
8627     integer n,na
8628    
8629     if(soo.eq.0)return
8630    
8631     write(oo,*)
8632     write(oo,*)' Primolec'
8633     write(oo,*)' pqMol=',pqMol
8634     do n=1,pqMol
8635     write(oo,*)' n=',n,' qSAtMol(n)=',qSAtMol(n)
8636     write(oo,*)' weiMol=',weiMol(n)
8637     write(oo,*)' WWWMol=',WWWMol(n)
8638     write(oo,*)' FFFMol=',FFFMol(n)
8639     do na=1,qSAtMol(n)
8640     write(oo,*)' nAtMol=',nAtMol(na,n),' qAtMol=',qAtMol(na,n)
8641     enddo
8642     enddo
8643    
8644     end
8645    
8646     +DECK,Inigas.
8647     subroutine Inigas( nmat, pqmole, pnmole, pwmole, pres, temp)
8648    
8649     c
8650     c initialization of the gas
8651     c
8652     implicit none
8653    
8654     c include 'GoEvent.inc'
8655     +SEQ,GoEvent.
8656     c include 'ener.inc'
8657     +SEQ,ener.
8658     c include 'atoms.inc'
8659     +SEQ,atoms.
8660     c include 'matters.inc'
8661     +SEQ,matters.
8662     c include 'volume.inc'
8663     +SEQ,volume.
8664     c include 'molecules.inc'
8665     +SEQ,molecule.
8666     c include 'molecdef.inc'
8667     +SEQ,molecdef.
8668    
8669    
8670     integer nmat ! Number of material
8671     integer pqmole ! Quantity of different molecules
8672     ! in the gas mixture.
8673     integer pnmole(pqMol) ! Their numbers in molecdef.inc
8674     ! accordingly with molecules.inc
8675     real pwmole(pqMol) ! Their weights
8676     ! (relative quantities of molecules).
8677     real pres ! Pressure in Torr.
8678     real temp ! Temperature in K.
8679    
8680     integer qmol, qold
8681     integer nmol(pqMol)
8682     real wmol(pqMol)
8683    
8684     integer n
8685     real s
8686     integer na,nm,i
8687    
8688    
8689     integer A(pqAt)
8690     real AW(pqAt)
8691     integer q
8692     real Ad(pqMol)
8693     real dens
8694     real gasdens
8695     real w
8696     real f
8697    
8698     c write(oo,*)' nmat=',nmat
8699     c write(oo,*)' qmol=',qmol
8700     c do n=1,qmol
8701     c write(oo,*)nmol(n),pwmol(n)
8702     c enddo
8703     c write(oo,*)' temp=',temp
8704     c write(oo,*)' pres=',pres
8705    
8706    
8707     c Copy everything
8708     qmol=pqmole
8709     do n=1,qmol
8710     nmol(n)=pnmole(n)
8711     wmol(n)=pwmole(n)
8712     enddo
8713     do n=1,qmol ! Check for negative weights
8714     if(wmol(n).lt.0)then
8715     write(oo,*)' error in Inigas: negative weight: wmol=',
8716     - wmol(n)
8717     if(sret_err.eq.0) stop
8718     s_err=1
8719     return
8720     endif
8721     enddo
8722     s=0.0 ! Compute the sun of weights
8723     do n=1,qmol
8724     s=s+wmol(n)
8725     enddo
8726     if(s.eq.0)then ! Check zero sum
8727     write(oo,*)' error in Inigas: all weights are zero'
8728     if(sret_err.eq.0) stop
8729     s_err=1
8730     return
8731     endif
8732     do n=1,qmol ! Normalize the weights
8733     wmol(n)=wmol(n)/s
8734     enddo
8735     *** Remove components with zero weight, rewritten (RV 9/6/99).
8736     qold=qmol
8737     qmol=0
8738     do n=1,qold
8739     if(wmol(n).gt.0)then
8740     qmol=qmol+1
8741     nmol(qmol)=nmol(n)
8742     wmol(qmol)=wmol(n)
8743     endif
8744     enddo
8745     if(qmol.le.0)then
8746     print *,' !!!!!! INIGAS WARNING : No non-zero weight'//
8747     - ' gas components found; mixture rejected.'
8748     if(sret_err.eq.0) stop
8749     s_err=1
8750     return
8751     endif
8752     *** End of modification.
8753    
8754    
8755     c fill material
8756     q=0
8757     do n=1,qmol ! Take the next molecule
8758     nm=nmol(n) ! Its number in molecdef.inc
8759     c write(oo,*)' nm=',nm,' qSAtMol(nm)=',qSAtMol(nm)
8760     c Check that this molecule exists in list.
8761     if(nm.le.0.or.nm.gt.pqMol)then
8762     write(oo,*)' error in Inigas: the wrong molecule number'
8763     if(sret_err.eq.0) stop
8764     s_err=1
8765     return
8766     endif
8767     do na=1,qSAtMol(nm) ! Loop over atoms of current molecule
8768     do i=1,q ! Loop over enrolled atoms
8769     ! Check if the atom is already enrolled
8770     if(A(i).eq.nAtMol(na,nm))then
8771     goto 10
8772     endif
8773     enddo
8774     q=q+1 ! To enroll it
8775     A(q)=nAtMol(na,nm)
8776     AW(q)=qAtMol(na,nm) * wmol(n) ! The weight of the atom
8777     c write(oo,*)' q=',q,' A(q)=',A(q),' AW(q)=',AW(q)
8778     goto 20
8779     10 continue
8780     AW(i)=AW(i) + qAtMol(na,nm) * wmol(n)
8781     c write(oo,*)' q=',q,' A(q)=',A(q),' AW(q)=',AW(q)
8782     20 continue
8783     enddo
8784     enddo
8785    
8786     do n=1,qmol
8787     nm=nmol(n)
8788     Ad(n)=weiMol(nm)
8789     enddo
8790    
8791     c pressure, temperature
8792    
8793     Cur_Pressure=pres
8794     Cur_Temper=temp
8795    
8796     c density of the ideal gas
8797     dens = gasdens(Ad, wmol, qmol)
8798     if(s_err.eq.1) return
8799    
8800     w=0.0
8801     f=0.0
8802     do n=1,qmol
8803     nm=nmol(n)
8804     w = w + WWWMol(nm) * wmol(n)
8805     f = f + FFFMol(nm) * wmol(n)
8806     enddo
8807    
8808     call IniMatter(nmat,A,AW,q,dens,w,f)
8809     if(s_err.eq.1) return
8810    
8811     *** Added argument to PriMatter (RV 13/4/99).
8812     c call PriMatter(0)
8813    
8814    
8815    
8816     end
8817    
8818    
8819     +DECK,IniAtom.
8820    
8821    
8822     subroutine IniAtom(num,z,a)
8823     c
8824     c The special cases incorporated by fortran code:
8825     c Ar and O : with including exp. data
8826     c and change of part of 3p and 2p shell corespondently.
8827     c C for CO2 (C1) : 2p sift from 8.9 to 13.79
8828     c C for CF4 (C2) : 2p sift from 8.9 to 16.23
8829     c C for CH4 : 2p sift
8830     c c for C2H10 : 2p sift
8831     c
8832     implicit none
8833    
8834     save
8835    
8836     c include 'GoEvent.inc'
8837     +SEQ,GoEvent.
8838     c include 'ener.inc'
8839     +SEQ,ener.
8840     c include 'shellfi.inc'
8841     +SEQ,shellfi.
8842     c include 'atoms.inc'
8843     +SEQ,atoms.
8844     c include 'cconst.inc'
8845     +SEQ,cconst.
8846     c include 'shl.inc'
8847     +SEQ,shl.
8848     c include 'tpasc.inc'
8849     +SEQ,tpasc.
8850     c include 'LibAtMat.inc'
8851     +SEQ,LibAtMat.
8852    
8853     integer num !number of atom in the bank
8854     integer z !charge
8855     real a !atomic weight
8856    
8857     real w,sw,s
8858    
8859     integer qbener
8860     parameter (qbener=138)
8861     real aenerc(qbener),epa(qbener)
8862     integer qbener1
8863     parameter (qbener1=5)
8864     real aenerc1(qbener1),epa1(qbener1)
8865     real e
8866     c integer num_at_mol
8867     c parameter (num_at_mol=2)
8868     real interp_linep_arr
8869    
8870     c include 'shellescar.inc'
8871    
8872     data aenerc(1) / 15.83 /
8873     data epa(1) / 29.2 /
8874     data aenerc(2) / 15.89 /
8875     data epa(2) / 29.5 /
8876     data aenerc(3) / 16.1 /
8877     data epa(3) / 30.3 /
8878     data aenerc(4) / 16.31 /
8879     data epa(4) / 31.1 /
8880     data aenerc(5) / 16.53 /
8881     data epa(5) / 31.8 /
8882     data aenerc(6) / 16.75 /
8883     data epa(6) / 32.5 /
8884     data aenerc(7) / 16.98 /
8885     data epa(7) / 33.1 /
8886     data aenerc(8) / 17.22 /
8887     data epa(8) / 33.7 /
8888     data aenerc(9) / 17.46 /
8889     data epa(9) / 34.2 /
8890     data aenerc(10) / 17.71 /
8891     data epa(10) / 34.7 /
8892     data aenerc(11) / 17.97 /
8893     data epa(11) / 35.1 /
8894     data aenerc(12) / 18.23 /
8895     data epa(12) / 35.5 /
8896     data aenerc(13) / 18.5 /
8897     data epa(13) / 35.8 /
8898     data aenerc(14) / 18.78 /
8899     data epa(14) / 36.1 /
8900     data aenerc(15) / 19.07 /
8901     data epa(15) / 36.3 /
8902     data aenerc(16) / 19.37 /
8903     data epa(16) / 36.5 /
8904     data aenerc(17) / 19.68 /
8905     data epa(17) / 36.3 /
8906     data aenerc(18) / 20 /
8907     data epa(18) / 36.7 /
8908     data aenerc(19) / 20.32 /
8909     data epa(19) / 36.8 /
8910     data aenerc(20) / 20.66 /
8911     data epa(20) / 36.7 /
8912     data aenerc(21) / 21.01 /
8913     data epa(21) / 36.7 /
8914     data aenerc(22) / 21.38 /
8915     data epa(22) / 36.5 /
8916     data aenerc(23) / 21.75 /
8917     data epa(23) / 36.3 /
8918     data aenerc(24) / 22.14 /
8919     data epa(24) / 36.1 /
8920     data aenerc(25) / 22.54 /
8921     data epa(25) / 35.7 /
8922     data aenerc(26) / 22.96 /
8923     data epa(26) / 35.4 /
8924     data aenerc(27) / 23.39 /
8925     data epa(27) / 34.9 /
8926     data aenerc(28) / 23.84 /
8927     data epa(28) / 34.4 /
8928     data aenerc(29) / 24.31 /
8929     data epa(29) / 33.8 /
8930     data aenerc(30) / 24.8 /
8931     data epa(30) / 33.1 /
8932     data aenerc(31) / 25.3 /
8933     data epa(31) / 32.3 /
8934     data aenerc(32) / 25.83 /
8935     data epa(32) / 31.4 /
8936     data aenerc(33) / 26.38 /
8937     data epa(33) / 30.5 /
8938     data aenerc(34) / 26.95 /
8939     data epa(34) / 29.5 /
8940     data aenerc(35) / 27.55 /
8941     data epa(35) / 28.3 /
8942     data aenerc(36) / 28.18 /
8943     data epa(36) / 27.1 /
8944     data aenerc(37) / 28.83 /
8945     data epa(37) / 25.7 /
8946     data aenerc(38) / 29.52 /
8947     data epa(38) / 24.3 /
8948     data aenerc(39) / 30.24 /
8949     data epa(39) / 22.7 /
8950     data aenerc(40) / 30.99 /
8951     data epa(40) / 21 /
8952     data aenerc(41) / 31.79 /
8953     data epa(41) / 19.1 /
8954     data aenerc(42) / 32.63 /
8955     data epa(42) / 17.1 /
8956     data aenerc(43) / 33.51 /
8957     data epa(43) / 15 /
8958     data aenerc(44) / 34.44 /
8959     data epa(44) / 12.8 /
8960     data aenerc(45) / 35.42 /
8961     data epa(45) / 10.3 /
8962     data aenerc(46) / 36.46 /
8963     data epa(46) / 7.77 /
8964     data aenerc(47) / 37.57 /
8965     data epa(47) / 6.1 /
8966     data aenerc(48) / 38.74 /
8967     data epa(48) / 4.62 /
8968     data aenerc(49) / 39.99 /
8969     data epa(49) / 3.41 /
8970     data aenerc(50) / 41.33 /
8971     data epa(50) / 2.47 /
8972     data aenerc(51) / 42.75 /
8973     data epa(51) / 1.77 /
8974     data aenerc(52) / 44.28 /
8975     data epa(52) / 1.3 /
8976     data aenerc(53) / 45.92 /
8977     data epa(53) / 1.03 /
8978     data aenerc(54) / 47.68 /
8979     data epa(54) / 0.914 /
8980     data aenerc(55) / 49.59 /
8981     data epa(55) / 0.916 /
8982     data aenerc(56) / 51.66 /
8983     data epa(56) / 1 /
8984     data aenerc(57) / 53.9 /
8985     data epa(57) / 1.13 /
8986     data aenerc(58) / 56.35 /
8987     data epa(58) / 1.28 /
8988     data aenerc(59) / 59.04 /
8989     data epa(59) / 1.36 /
8990     data aenerc(60) / 61.99 /
8991     data epa(60) / 1.42 /
8992     data aenerc(61) / 65.25 /
8993     data epa(61) / 1.45 /
8994     data aenerc(62) / 68.88 /
8995     data epa(62) / 1.48 /
8996     data aenerc(63) / 72.93 /
8997     data epa(63) / 1.48 /
8998     data aenerc(64) / 77.49 /
8999     data epa(64) / 1.47 /
9000     data aenerc(65) / 82.65 /
9001     data epa(65) / 1.45 /
9002     data aenerc(66) / 88.56 /
9003     data epa(66) / 1.41 /
9004     data aenerc(67) / 95.37 /
9005     data epa(67) / 1.36 /
9006     data aenerc(68) / 103.3 /
9007     data epa(68) / 1.29 /
9008     data aenerc(69) / 112.7 /
9009     data epa(69) / 1.2 /
9010     data aenerc(70) / 124 /
9011     data epa(70) / 1.1 /
9012     data aenerc(71) / 130.5 /
9013     data epa(71) / 1.05 /
9014     data aenerc(72) / 137.8 /
9015     data epa(72) / 0.987 /
9016     data aenerc(73) / 145.9 /
9017     data epa(73) / 0.923 /
9018     data aenerc(74) / 155 /
9019     data epa(74) / 0.856 /
9020     data aenerc(75) / 165.3 /
9021     data epa(75) / 0.785 /
9022     data aenerc(76) / 177.1 /
9023     data epa(76) / 0.709 /
9024     data aenerc(77) / 190.7 /
9025     data epa(77) / 0.63 /
9026     data aenerc(78) / 206.6 /
9027     data epa(78) / 0.547 /
9028     data aenerc(79) / 225.4 /
9029     data epa(79) / 0.461 /
9030     data aenerc(80) / 245 /
9031     data epa(80) / 0.381 /
9032     data aenerc(81) / 248 /
9033     data epa(81) / 4.66 /
9034     data aenerc(82) / 258.3 /
9035     data epa(82) / 4.23 /
9036     data aenerc(83) / 269.5 /
9037     data epa(83) / 3.83 /
9038     data aenerc(84) / 281.8 /
9039     data epa(84) / 3.45 /
9040     data aenerc(85) / 295.2 /
9041     data epa(85) / 3.1 /
9042     data aenerc(86) / 310 /
9043     data epa(86) / 2.76 /
9044     data aenerc(87) / 326.3 /
9045     data epa(87) / 2.45 /
9046     data aenerc(88) / 344.4 /
9047     data epa(88) / 2.16 /
9048     data aenerc(89) / 364.7 /
9049     data epa(89) / 1.89 /
9050     data aenerc(90) / 387.4 /
9051     data epa(90) / 1.64 /
9052     data aenerc(91) / 413.3 /
9053     data epa(91) / 1.41 /
9054     data aenerc(92) / 442.8 /
9055     data epa(92) / 1.2 /
9056     data aenerc(93) / 476.9 /
9057     data epa(93) / 1.01 /
9058     data aenerc(94) / 516.6 /
9059     data epa(94) / 0.836 /
9060     data aenerc(95) / 563.6 /
9061     data epa(95) / 0.682 /
9062     data aenerc(96) / 619.9 /
9063     data epa(96) / 0.546 /
9064     data aenerc(97) / 652.5 /
9065     data epa(97) / 0.484 /
9066     data aenerc(98) / 688.8 /
9067     data epa(98) / 0.426 /
9068     data aenerc(99) / 729.3 /
9069     data epa(99) / 0.373 /
9070     data aenerc(100) / 774.9 /
9071     data epa(100) / 0.324 /
9072     data aenerc(101) / 826.5 /
9073     data epa(101) / 0.278 /
9074     data aenerc(102) / 885.6 /
9075     data epa(102) / 0.237 /
9076     data aenerc(103) / 953.7 /
9077     data epa(103) / 0.199 /
9078     data aenerc(104) / 1044 /
9079     data epa(104) / 0.165 /
9080     data aenerc(105) / 1127 /
9081     data epa(105) / 0.135 /
9082     data aenerc(106) / 1240 /
9083     data epa(106) / 0.108 /
9084     data aenerc(107) / 1305 /
9085     data epa(107) / 0.0955 /
9086     data aenerc(108) / 1378 /
9087     data epa(108) / 0.0842 /
9088     data aenerc(109) / 1459 /
9089     data epa(109) / 0.0736 /
9090     data aenerc(110) / 1550 /
9091     data epa(110) / 0.0639 /
9092     data aenerc(111) / 1653 /
9093     data epa(111) / 0.0549 /
9094     data aenerc(112) / 1771 /
9095     data epa(112) / 0.0467 /
9096     data aenerc(113) / 1907 /
9097     data epa(113) / 0.0393 /
9098     data aenerc(114) / 2066 /
9099     data epa(114) / 0.0326 /
9100     data aenerc(115) / 2254 /
9101     data epa(115) / 0.0266 /
9102     data aenerc(116) / 2480 /
9103     data epa(116) / 0.0213 /
9104     data aenerc(117) / 2755 /
9105     data epa(117) / 0.0166 /
9106     data aenerc(118) / 3100 /
9107     data epa(118) / 0.0126 /
9108     data aenerc(119) / 3204 /
9109     data epa(119) / 0.0117 /
9110     data aenerc(120) / 3263 /
9111     data epa(120) / 0.0959 /
9112     data aenerc(121) / 3444 /
9113     data epa(121) / 0.0827 /
9114     data aenerc(122) / 3646 /
9115     data epa(122) / 0.0706 /
9116     data aenerc(123) / 3874 /
9117     data epa(123) / 0.0598 /
9118     data aenerc(124) / 4133 /
9119     data epa(124) / 0.0501 /
9120     data aenerc(125) / 4428 /
9121     data epa(125) / 0.0414 /
9122     data aenerc(126) / 4768 /
9123     data epa(126) / 0.0338 /
9124     data aenerc(127) / 5166 /
9125     data epa(127) / 0.0271 /
9126     data aenerc(128) / 5635 /
9127     data epa(128) / 0.0213 /
9128     data aenerc(129) / 6199 /
9129     data epa(129) / 0.0164 /
9130     data aenerc(130) / 6888 /
9131     data epa(130) / 0.0123 /
9132     data aenerc(131) / 7749 /
9133     data epa(131) / 0.00889 /
9134     data aenerc(132) / 8856 /
9135     data epa(132) / 0.00616 /
9136     data aenerc(133) / 10330 /
9137     data epa(133) / 0.00403 /
9138     data aenerc(134) / 12400 /
9139     data epa(134) / 0.00244 /
9140     data aenerc(135) / 15500 /
9141     data epa(135) / 0.00132 /
9142     data aenerc(136) / 20660 /
9143     data epa(136) / 0.000599 /
9144     data aenerc(137) / 31000 /
9145     data epa(137) / 0.000196 /
9146     data aenerc(138) / 61990 /
9147     data epa(138) / 2.9e-05 /
9148    
9149    
9150    
9151     c include 'shellesco.inc'
9152    
9153     data aenerc1(1) / 14.2 /
9154     data epa1(1) / 2.51 /
9155     data aenerc1(2) / 16.2 /
9156     data epa1(2) / 3.98 /
9157     data aenerc1(3) / 17.4 /
9158     data epa1(3) / 12.59 /
9159     data aenerc1(4) / 25.1 /
9160     data epa1(4) / 10.72 /
9161     data aenerc1(5) / 31.6 /
9162     data epa1(5) / 10 /
9163    
9164     integer pqnpasc
9165     parameter(pqnpasc=20)
9166     integer nnpasc
9167     integer pqnene
9168     parameter(pqnene=100)
9169     integer nnene
9170     real Tresh_npasc
9171     real nene,npasc
9172    
9173     common / comasc /
9174     + nnpasc,Tresh_npasc(pqnpasc),nnene(pqnpasc),
9175     + nene(pqnene,pqnpasc),npasc(pqnene,pqnpasc)
9176     save / comasc /
9177    
9178    
9179     integer i,iener,n,ne,j,ns,k,nn
9180     c integer ios
9181     real glin_integ_ar, step_integ_ar, sigma_nl
9182     c real lin_integ_ar
9183     c real interp_line_arr
9184     c real alog,sqrt
9185    
9186     if(num.le.0.or.num.gt.pQAt)then
9187     write(oo,*)' Error in IniAtom: Wrong Atom number ',num
9188     stop
9189     endif
9190     if(Zat(num).ne.0)then
9191     write(oo,*)' Error in IniAtom: Atom number ',num,
9192     + 'is initialized already'
9193     stop
9194     endif
9195     do n=1,QseqAt ! fill sequensed number
9196     if(Zat(n).gt.z)then
9197     do nn=QseqAt,n,-1
9198     nseqAt(nn+1)=nseqAt(nn)
9199     enddo
9200     nseqAt(n)=num
9201     QseqAt=QseqAt+1
9202     go to 4
9203     endif
9204     enddo
9205     QseqAt=QseqAt+1
9206     nseqAt(QseqAt)=num
9207     4 continue
9208     Zat(num)=z
9209     Aat(num)=a
9210     cphoAt(num)=2.0*PI2*Zat(num)/(FSCON*ELMAS)
9211     RLenAt(num)=716.4*Aat(num)/
9212     + (Zat(num)*(Zat(num)+1)*alog(287/sqrt(float(Zat(num)))))
9213     RuthAt(num)=4.0*PI*Zat(num)*Zat(num)*ELRAD*ELRAD*ELMAS*ELMAS
9214     zato=zat(num)
9215     if(KeyTeor.eq.0)then
9216    
9217     if(Zat(num).eq.1)then ! H
9218    
9219     QShellAt(num)=1
9220     ThresholdAt(1,num)=16.4e-6 ! ionization potential of H2
9221     c accordingly with At.Data.Nucl.Data.Tables 24,323-371(1979)
9222     if(num.eq.num_H3)then ! for CH4
9223     c ThresholdAt(1,num)=15.2e-06
9224     ThresholdAt(1,num)=12.0e-06
9225     endif
9226     if(num.eq.num_H4)then ! for NH4
9227     ThresholdAt(1,num)=10.0e-06
9228     endif
9229     do ne=1,qener
9230     if(ener(ne+1).gt.ThresholdAt(1,num))then
9231     c PhotAt(ne,1,num)=1.51*0.0535*
9232     PhotAt(ne,1,num)=0.0535*
9233     + ((100.0e-6/
9234     + (enerc(ne) + 16.4e-6 - ThresholdAt(1,num)))**3.228)
9235     if(ener(ne).lt.ThresholdAt(1,num))then
9236     PhotAt(ne,1,num)=PhotAt(ne,1,num)*
9237     + (ThresholdAt(1,num)-ener(ne))/
9238     + (ener(ne+1)-ener(ne))
9239     endif
9240     endif
9241     enddo
9242    
9243     c Now the cross section is generated in Mega-barns.
9244     c Calc. coef for going from 10**-18 sm**2 to Mev-2
9245     s=1.e-18 * 5.07e10 * 5.07e10
9246    
9247     do ne=1,qener
9248     do ns=1,QShellAt(num)
9249     PhotAt(ne,ns,num)=PhotAt(ne,ns,num)*s
9250     enddo
9251     enddo
9252    
9253     do ns=1,QShellAt(num)
9254     WeightShAt(ns,num)=step_integ_ar(ener,PhotAt(1,ns,num),qener,
9255     + ener(1),ener(qener+1))/cphoAt(num)
9256     enddo
9257    
9258    
9259     go to 100
9260    
9261     endif
9262    
9263     if(Zat(num).eq.6)then
9264    
9265     call henke
9266    
9267     QShellAt(num)=qash
9268     do ns=1,QShellAt(num)
9269     ThresholdAt(ns,num)=athreshold(ns)
9270     if(ns.eq.QShellAt(num))then
9271     if(num.eq.num_C1)then
9272     ThresholdAt(ns,num)=13.79e-6 ! CO2
9273     endif
9274     if(num.eq.num_C2)then
9275     ThresholdAt(ns,num)=16.23e-6 ! CF4
9276     endif
9277     if(num.eq.num_C3)then
9278     c ThresholdAt(ns,num)=15.2e-6 ! CH4
9279     ThresholdAt(ns,num)=12.0e-6 ! CH4 and so on
9280     endif
9281     endif
9282     do ne=1,qener
9283     PhotAt(ne,ns,num)=
9284     + interp_linep_arr(aener(1,ns),aphot(1,ns),qaener(ns),
9285     + athreshold(ns),
9286     + (enerc(ne) - (ThresholdAt(ns,num) - athreshold(ns))) )
9287     enddo
9288     enddo
9289    
9290     c Now the cross section is generated in Mega-barns.
9291     c Calc. coef for going from 10**-18 sm**2 to Mev-2
9292     s=1.e-18 * 5.07e10 * 5.07e10
9293    
9294     do ne=1,qener
9295     do ns=1,QShellAt(num)
9296     PhotAt(ne,ns,num)=PhotAt(ne,ns,num)*s
9297     enddo
9298     enddo
9299    
9300     do ns=1,QShellAt(num)
9301     WeightShAt(ns,num)=step_integ_ar(ener,PhotAt(1,ns,num),qener,
9302     + ener(1),ener(qener+1))/cphoAt(num)
9303     enddo
9304    
9305    
9306     go to 100
9307    
9308     endif
9309    
9310    
9311     qshPas(num)=0
9312     call readPas(num)
9313     if(qshPas(num).gt.0)then
9314    
9315    
9316    
9317     QShellAt(num)=qshPas(num)
9318     do ns=1,qshPas(num)
9319     ThresholdAt(ns,num)=EthPas(ns,num)*1.e-6
9320     if(Zat(num).eq.6.and.ns.eq.3.and.
9321     + num.eq.num_C1)then
9322     c + num_at_mol(num).eq.1)then
9323     ThresholdAt(ns,num)=13.79*1.e-6 ! for CO2
9324     endif
9325     if(Zat(num).eq.6.and.ns.eq.3.and.
9326     + num.eq.num_C2)then
9327     c + num_at_mol(num).eq.2)then
9328     ThresholdAt(ns,num)=16.23*1.e-6 ! for CF4
9329     endif
9330     if(Zat(num).eq.6.and.ns.eq.3.and.
9331     + num.eq.num_C3)then
9332     ThresholdAt(ns,num)=15.2*1.e-6 ! for CH4
9333     endif
9334     if(ThresholdAt(ns,num).lt.ener(1))then
9335     write(oo,*)' error in IniAtom:'
9336     write(oo,*)' too high ener(1)=',ener(1)
9337     write(oo,*)' ThresholdAt(ns,num)=',
9338     + ThresholdAt(ns,num)
9339     stop
9340     endif
9341    
9342     enddo
9343    
9344    
9345    
9346     do ne=1,qener
9347     do i=1,qshPas(num)
9348     s=0.0
9349     c do i=5,5
9350     if(Zat(num).eq.18.and.
9351     + i.eq.5.and.
9352     + enerc(ne)*1.e6.gt.EthPas(i,num).and.enerc(ne)*1.e6.le.40)then
9353     j=qbener
9354     do k=2,qbener
9355     if(aenerc(k).ge.enerc(ne)*1.e6)then
9356     j=k-1
9357     go to 5
9358     endif
9359     enddo
9360     5 s=s+ epa(j)+(enerc(ne)*1.e6-aenerc(j))*
9361     + (epa(j+1)-epa(j))/(aenerc(j+1)-aenerc(j))
9362    
9363     elseif(Zat(num).eq.8.and.
9364     + i.eq.3.and.
9365     + enerc(ne)*1.e6.gt.EthPas(i,num).and.enerc(ne)*1.e6.le.25.1)then
9366     j=qbener1
9367     do k=2,qbener1
9368     if(aenerc1(k).ge.enerc(ne)*1.e6)then
9369     j=k-1
9370     go to 6
9371     endif
9372     enddo
9373     6 s=s+ epa1(j)+(enerc(ne)*1.e6-aenerc1(j))*
9374     + (epa1(j+1)-epa1(j))/(aenerc1(j+1)-aenerc1(j))
9375    
9376     else
9377     if(Zat(num).eq.6.and.i.eq.3)then
9378     c if(num.eq.num_C1)then
9379     cc if(num_at_mol(num).eq.1)then
9380     c e=enerc(ne)*1.e6-(13.79-.8987E+01)
9381     c elseif(num.eq.num_C2)then
9382     cc elseif(num_at_mol(num).eq.2)then
9383     c e=enerc(ne)*1.e6-(16.23-.8987E+01)
9384     c else
9385     c e=enerc(ne)*1.e6
9386     c endif
9387     e=enerc(ne) - ThresholdAt(i,num) + .8987E+01*1.0e-6
9388     e=e*1.e6
9389     else
9390     e=enerc(ne)*1.e6
9391     endif
9392    
9393     s=s + sigma_nl
9394     + (e , E0Pas(i,num),EthPas(i,num),
9395     + ywPas(i,num),lPas(i,num),
9396     + yaPas(i,num),PPas(i,num),sigma0Pas(i,num))
9397    
9398    
9399     endif
9400    
9401     PhotAt(ne,i,num)=s
9402    
9403     enddo
9404     enddo
9405    
9406     c Now the cross section is generated in Mega-barns.
9407     c Calc. coef for going from 10**-18 sm**2 to Mev-2
9408     s=1.e-18 * 5.07e10 * 5.07e10
9409    
9410     do ne=1,qener
9411     do i=1,qshPas(num)
9412     PhotAt(ne,i,num)=PhotAt(ne,i,num)*s
9413     enddo
9414     enddo
9415    
9416     do ns=1,qshPas(num)
9417     WeightShAt(ns,num)=step_integ_ar(ener,PhotAt(1,ns,num),qener,
9418     + ener(1),ener(qener+1))/cphoAt(num)
9419     enddo
9420    
9421    
9422     go to 100
9423    
9424     endif ! continuing of old algorithm
9425    
9426    
9427     call shellfi
9428     c call prishellfi
9429     endif
9430     if(qash.eq.0.or.KeyTeor.ne.0)then
9431     call shteor(num)
9432     if(qash.eq.0)then
9433     write(oo,*)' Error in IniAtom:',
9434     + 'can not find atom with z=',z
9435     stop
9436     endif
9437     call GenTheorPhot
9438     c call prishellfi
9439     endif
9440    
9441     call shellfico
9442     c call prishellfi
9443    
9444     QShellAt(num)=qash
9445     do i=1,qatm
9446     if(ZAt(num).eq.charge(i))then
9447     if(QShellAt(num).ne.qshl(i))then
9448     write(oo,*)' Worning of IniAtom:'
9449     write(oo,*)' Quantity of shell is different for shl'
9450     write(oo,*)' In may lead to error'
9451     endif
9452     goto 10
9453     endif
9454     enddo
9455     10 continue
9456     do i=1,QShellAt(num)
9457     ThresholdAt(i,num)=athreshold(i)
9458     if(ThresholdAt(i,num).lt.ener(1))then
9459     write(oo,*)' error in IniAtom:'
9460     write(oo,*)' too high ener(1)=',ener(1)
9461     write(oo,*)' ThresholdAt(ns,num)=',
9462     + ThresholdAt(i,num)
9463     stop
9464     endif
9465     WeightShAt(i,num)=aweight(i)
9466    
9467     do iener=1,qener
9468    
9469     PhotAt(iener,i,num)=
9470     + glin_integ_ar(aener(1,i),aphot(1,i),qaener(i),
9471     + ener(iener),ener(iener+1),ThresholdAt(i,num))/
9472     + (ener(iener+1)-ener(iener))
9473    
9474     enddo
9475    
9476     enddo
9477    
9478     *** Added argument to PriAtoms (RV 13/4/99)
9479     c call PriAtoms(0)
9480     *** End of modification.
9481    
9482     w=0.0
9483     do i=1,QShellAt(num)
9484     w=w+WeightShAt(i,num)
9485     enddo
9486     do i=1,QShellAt(num)
9487     WeightShAt(i,num)=WeightShAt(i,num)/w
9488     enddo
9489     sw=0.0
9490     do i=1,QShellAt(num)
9491     w=step_integ_ar(ener,PhotAt(1,i,num),qener,
9492     + ener(1),ener(qener+1))
9493     PWeightShAt(i,num)=w
9494     sw=sw+w
9495     if(w.lt.0.0)then
9496     do n=1,qener
9497     PhotAt(n,i,num)=0.0
9498     enddo
9499     else
9500     do n=1,qener
9501     PhotAt(n,i,num)=PhotAt(n,i,num)*cphoAt(num)*
9502     + WeightShAt(i,num)/w
9503     enddo
9504     ******* write(oo,*)' koef=',cphoAt(num)*WeightShAt(i,num)/w
9505     endif
9506     enddo
9507     do i=1,QShellAt(num)
9508     PWeightShAt(i,num)=PWeightShAt(i,num)/sw
9509     enddo
9510    
9511     100 continue
9512    
9513     do i=1,qatm
9514     if(ZAt(num).eq.charge(i))then
9515     if(QShellAt(num).ne.qshl(i))then
9516     write(oo,*)' Worning of IniAtom:'
9517     write(oo,*)' Quantity of shell is different for shl'
9518     write(oo,*)' In may lead to error'
9519     endif
9520     goto 20
9521     endif
9522     enddo
9523     20 continue
9524    
9525     s=0.0
9526     do ns=1,QShellAt(num)
9527     c write(oo,*)' start integration'
9528     ISPhotBAt(ns,num)=step_integ_ar
9529     + (ener,PhotAt(1,ns,num),qener,ener(1),ener(qener+1))
9530     s=s+ISPhotBAt(ns,num)
9531     enddo
9532     IAPhotBAt(num)=s
9533     MinThresholdAt(num)=ThresholdAt(QShellAt(num),num)
9534     NshMinThresholdAt(num)=QShellAt(num)
9535     Min_ind_E_At(num)=0
9536     Max_ind_E_At(num)=0
9537    
9538     if(IAPhotBAt(num).gt.cphoAt(num))then
9539     c reduce all shells
9540     s=cphoAt(num)/IAPhotBAt(num)
9541     do ne=1,qener
9542     do ns=1,QShellAt(num)
9543     PhotAt(ne,ns,num)=PhotAt(ne,ns,num)*s
9544     enddo
9545     enddo
9546     c copy absorbtion to ionization
9547     do ne=1,qener
9548     do ns=1,QShellAt(num)
9549     PhotIonAt(ne,ns,num)=PhotAt(ne,ns,num)
9550     enddo
9551     enddo
9552     c reduce weights
9553     do ns=1,QShellAt(num)
9554     WeightShAt(ns,num)=WeightShAt(ns,num)*s
9555     enddo
9556    
9557     elseif(IAPhotBAt(num).lt.cphoAt(num))then
9558     c copy absorbtion to ionzation
9559     do ne=1,qener
9560     do ns=1,QShellAt(num)
9561     PhotIonAt(ne,ns,num)=PhotAt(ne,ns,num)
9562     enddo
9563     enddo
9564     c add excitation part to absorption
9565    
9566    
9567     j=qener
9568     do ne=3,qener
9569     if(ener(ne).gt.MinThresholdAt(num))then
9570     j=ne-1 ! ener(j) in the last point
9571     ! So the last interval has number j-1
9572     go to 25
9573     endif
9574     enddo
9575     25 continue
9576     if(j.le.2)then
9577     write(oo,*)' Error in IniAtom:'
9578     write(oo,*)' cannot insert excitation'
9579     write(oo,*)' too large ener(1)=',ener(1)
9580     write(oo,*)' MinThresholdAt(num)=',
9581     + MinThresholdAt(num)
9582     stop
9583     endif
9584     nn=1
9585     do ne=j-1,1,-1
9586     if(enerc(ne).lt. 0.7*MinThresholdAt(num))then
9587     nn=ne
9588     go to 30
9589     endif
9590     enddo
9591     30 continue
9592     s=(-IAPhotBAt(num)+cphoAt(num))/
9593     + (ener(j) - ener(nn))
9594    
9595     do ne=nn,j-1
9596     PhotAt(ne,NshMinThresholdAt(num),num)=
9597     + PhotAt(ne,NshMinThresholdAt(num),num)+s
9598     enddo
9599     Min_ind_E_At(num)=nn
9600     Max_ind_E_At(num)=j-1
9601    
9602    
9603    
9604     else
9605     c copy absorbtion to ionzation
9606     do ne=1,qener
9607     do ns=1,QShellAt(num)
9608     PhotIonAt(ne,ns,num)=PhotAt(ne,ns,num)
9609     enddo
9610     enddo
9611     c add excitation part to absorption
9612    
9613     endif
9614    
9615     s=0.0
9616     do ns=1,QShellAt(num)
9617     ISPhotAt(ns,num)=step_integ_ar
9618     + (ener,PhotAt(1,ns,num),qener,ener(1),ener(qener+1))
9619     s=s+ISPhotAt(ns,num)
9620     enddo
9621     IAPhotAt(num)=s
9622    
9623     s=0.0
9624     do ns=1,QShellAt(num)
9625     ISPhotIonAt(ns,num)=step_integ_ar
9626     + (ener,PhotIonAt(1,ns,num),qener,
9627     + ener(1),ener(qener+1))
9628     s=s+ISPhotIonAt(ns,num)
9629     enddo
9630     IAPhotIonAt(num)=s
9631    
9632    
9633    
9634     end
9635    
9636    
9637     subroutine GenTheorPhot
9638    
9639     implicit none
9640    
9641     c include 'ener.inc'
9642     +SEQ,ener.
9643     c include 'shellfi.inc'
9644     +SEQ,shellfi.
9645    
9646     integer nsh,nen
9647    
9648     do nsh=1,qash
9649    
9650     qaener(nsh)=qener
9651     do nen=1,qener
9652     aener(nen,nsh)=enerc(nen)
9653     if(athreshold(nsh).lt.ener(nen+1))then
9654     aphot(nen,nsh)=1.0/(enerc(nen)**2.5)
9655     if(athreshold(nsh).gt.ener(nen))then
9656     aphot(nen,nsh)=aphot(nen,nsh)*
9657     + (ener(nen+1)-athreshold(nsh))/
9658     + (ener(nen+1)-ener(nen))
9659     endif
9660     else
9661     aphot(nen,nsh)=0.0
9662     endif
9663     enddo
9664     enddo
9665    
9666     end
9667    
9668    
9669     subroutine shellfico
9670    
9671     implicit none
9672    
9673     c include 'ener.inc'
9674     +SEQ,ener.
9675     c include 'shellfi.inc'
9676     +SEQ,shellfi.
9677    
9678     integer is,iaen,iaens,ien,iens
9679     real np
9680     np=2.5
9681     c the prolongation is needed only for first shell
9682    
9683     do is=1,qash
9684    
9685    
9686     c is=1
9687    
9688     do iaen=qaener(is),1,-1
9689     if(aphot(iaen,is).gt.0)then
9690     iaens=iaen
9691     go to 10
9692     endif
9693     enddo
9694     10 continue
9695    
9696     if(is.ne.1)then
9697     if(aener(iaens,is).eq.aener(1,is-1))then
9698     go to 30
9699     endif
9700     endif
9701    
9702     c same strange empty place in file in some atoms
9703    
9704     if(aener(iaens,is).lt.enerc(qener))then
9705     do ien=1,qener
9706     if(enerc(ien).gt.aener(iaens,is))then
9707     iens=ien
9708     goto 20
9709     endif
9710     enddo
9711     20 continue
9712     iaen=iaens
9713     do ien=iens,qener
9714     iaen=iaen+1
9715     aener(iaen,is)=enerc(ien)
9716     aphot(iaen,is)=aphot(iaens,is)*
9717     + (aener(iaens,is)/enerc(ien))**np
9718     enddo
9719     qaener(is)=iaen
9720     endif
9721    
9722     30 continue
9723    
9724     enddo
9725    
9726     c if(zato.eq.18)then
9727     c call prishellfi
9728     c endif
9729    
9730     end
9731    
9732    
9733     subroutine priatoms(n)
9734    
9735     implicit none
9736    
9737     integer n ! n = 0,1 short output
9738     ! n >= 2 long output
9739     c include 'GoEvent.inc'
9740     +SEQ,GoEvent.
9741     c include 'ener.inc'
9742     +SEQ,ener.
9743     c include 'atoms.inc'
9744     +SEQ,atoms.
9745    
9746     integer nat, nsh, nen, nat1
9747    
9748     if(soo.eq.0)return
9749    
9750     write(oo,*)
9751     write(oo,*)' priatoms: Atomic data'
9752     write(oo,*)' KeyTeor=',KeyTeor
9753     do nat=1,pQAt
9754     if(Zat(nat).gt.0)then
9755     write(oo,*)
9756     write(oo,*)' nat=',nat,' Zat=',Zat(nat),' Aat=',Aat(nat),
9757     + ' QShellAt=',QShellAt(nat)
9758     c write(oo,*)' num_at_mol=',num_at_mol(nat)
9759     write(oo,*)' cphoAt=',cphoAt(nat)
9760     write(oo,*)' RLenAt=',RLenAt(nat)
9761     write(oo,*)' RuthAt=',RuthAt(nat)
9762     do nsh=1,QShellAt(nat)
9763     write(oo,*)' ThresholdAt=',ThresholdAt(nsh,nat),
9764     + ' WeightShAt=',WeightShAt(nsh,nat)
9765     write(oo,*)' PWeightShAt=',PWeightShAt(nsh,nat)
9766     enddo
9767     write(oo,*)' IAPhotBAt IAPhotAt IAPhotIonAt '
9768     write(oo,*)IAPhotBAt(nat), IAPhotAt(nat), IAPhotIonAt(nat)
9769     do nsh=1,QShellAt(nat)
9770     write(oo,*)nsh,
9771     + ISPhotBAt(nsh,nat), ISPhotAt(nsh,nat), ISPhotIonAt(nsh,nat)
9772     enddo
9773     write(oo,*)' MinThresholdAt=',MinThresholdAt(nat)
9774     write(oo,*)' NshMinThresholdAt=',NshMinThresholdAt(nat)
9775     write(oo,*)' Min_ind_E_At=',Min_ind_E_At(nat),
9776     + ' Max_ind_E_At=',Max_ind_E_At(nat)
9777     if(n.ge.2)then
9778     write(oo,*)' energy and photoabs cross sections'
9779     c do nen=1,qener
9780     c write(oo,'(10e12.3)')
9781     c + enerc(nen),(PhotAt(nen,nsh,nat),nsh=1,QShellAt(nat))
9782     c enddo
9783     do nsh=1,QShellAt(nat)
9784     write(oo,*)' shell number=',nsh
9785     write(oo,*)' enerc, PhotAt, PhotIonAt'
9786     do nen=1,qener
9787     write(oo,'(3e10.3)')
9788     + enerc(nen),PhotAt(nen,nsh,nat),PhotIonAt(nen,nsh,nat)
9789     enddo ! nen=1,qener
9790     enddo ! nsh=1,QShellAt(nat)
9791     endif ! if(n.ge.2)
9792     endif ! if(Zat(nat).gt.0)
9793     enddo ! nat=1,pQAt
9794    
9795     write(oo,*)' Sequenced numbers:'
9796     write(oo,*)' nat Zat(nat) nseqAt(nat)'
9797     do nat=1,QseqAt
9798     write(oo,*) nat, Zat(nat), nseqAt(nat)
9799     enddo
9800     write(oo,*)
9801     + ' nat1 nat Zat(nat)'
9802     do nat1=1,QseqAt
9803     nat=nseqAt(nat1)
9804     write(oo,*) nat1, nat, Zat(nat)
9805     enddo
9806    
9807     end
9808    
9809    
9810    
9811     +DECK,henke.
9812     subroutine henke
9813     c
9814     c include Henke's data
9815    
9816     implicit none
9817    
9818     c include 'GoEvent.inc'
9819     +SEQ,GoEvent.
9820     c include 'shellfi.inc'
9821     +SEQ,shellfi.
9822    
9823     integer nae,ns
9824    
9825    
9826     qash=0 !sign of absence
9827    
9828    
9829     c The next code is generated by a computer program
9830     c on the basis of data file 'henke.dat'.
9831    
9832    
9833     if(zato.eq.6)then
9834    
9835     c include 'henke6.inc'
9836     +SEQ,henke6.
9837    
9838     endif
9839    
9840    
9841     c end of computer code
9842    
9843    
9844     do ns=1,qash
9845     athreshold(ns)=athreshold(ns)*1.e-6
9846     do nae=1,qaener(ns)
9847     aener(nae,ns)=aener(nae,ns)*1.e-6
9848     enddo
9849     enddo
9850    
9851    
9852     if(soo.eq.1)then
9853     if(qash.eq.0)then
9854     write(oo,*)' Worning of henke: atom z=',zato,' is not found.'
9855     write(oo,*)
9856     + ' The data will be seached by readPAS, accuracy will be lower.'
9857    
9858     endif
9859     endif
9860    
9861     c call prishellfi
9862    
9863     end
9864    
9865     +DECK,tpasc.
9866    
9867     subroutine readPas(na)
9868    
9869     implicit none
9870    
9871     integer na
9872    
9873     c include 'GoEvent.inc'
9874     +SEQ,GoEvent.
9875     c include 'ener.inc'
9876     +SEQ,ener.
9877     c include 'atoms.inc'
9878     +SEQ,atoms.
9879     c include 'tpasc.inc'
9880     +SEQ,tpasc.
9881    
9882     integer Za,npas
9883    
9884     integer i
9885    
9886     c include 'shelltsc.inc'
9887     integer pq
9888     parameter (pq=10)
9889     integer z(pq)
9890     integer n(pq)
9891     integer pmaxn
9892     parameter (pmaxn=5)
9893     integer l(pq,pmaxn)
9894     real p(pq,pmaxn,6)
9895     data z(1) / 2 /
9896     data n(1) / 1 /
9897     data l(1,1) / 0 /
9898     data p(1,1,1) / 23.42 /
9899     data p(1,1,2) / 2.024 /
9900     data p(1,1,3) / 2578 /
9901     data p(1,1,4) / 9.648 /
9902     data p(1,1,5) / 6.218 /
9903     data p(1,1,6) / 0 /
9904     data z(2) / 3 /
9905     data n(2) / 2 /
9906     data l(2,1) / 0 /
9907     data p(2,1,1) / 59.85 /
9908     data p(2,1,2) / 29.51 /
9909     data p(2,1,3) / 125.2 /
9910     data p(2,1,4) / 73020 /
9911     data p(2,1,5) / 0.9438 /
9912     data p(2,1,6) / 0 /
9913     data l(2,2) / 0 /
9914     data p(2,2,1) / 5.495 /
9915     data p(2,2,2) / 3.466 /
9916     data p(2,2,3) / 47.74 /
9917     data p(2,2,4) / 20.35 /
9918     data p(2,2,5) / 4.423 /
9919     data p(2,2,6) / 0 /
9920     data z(3) / 6 /
9921     data n(3) / 3 /
9922     data l(3,1) / 0 /
9923     data p(3,1,1) / 291 /
9924     data p(3,1,2) / 86.55 /
9925     data p(3,1,3) / 74.21 /
9926     data p(3,1,4) / 54.98 /
9927     data p(3,1,5) / 1.503 /
9928     data p(3,1,6) / 0 /
9929     data l(3,2) / 0 /
9930     data p(3,2,1) / 17.55 /
9931     data p(3,2,2) / 10.26 /
9932     data p(3,2,3) / 4564 /
9933     data p(3,2,4) / 1.568 /
9934     data p(3,2,5) / 10.85 /
9935     data p(3,2,6) / 0 /
9936     data l(3,3) / 1 /
9937     data p(3,3,1) / 8.987 /
9938     data p(3,3,2) / 9.435 /
9939     data p(3,3,3) / 1152 /
9940     data p(3,3,4) / 5.687 /
9941     data p(3,3,5) / 6.336 /
9942     data p(3,3,6) / 0.4474 /
9943     data z(4) / 7 /
9944     data n(4) / 3 /
9945     data l(4,1) / 0 /
9946     data p(4,1,1) / 404.8 /
9947     data p(4,1,2) / 127 /
9948     data p(4,1,3) / 47.48 /
9949     data p(4,1,4) / 138 /
9950     data p(4,1,5) / 1.252 /
9951     data p(4,1,6) / 0 /
9952     data l(4,2) / 0 /
9953     data p(4,2,1) / 23.1 /
9954     data p(4,2,2) / 14.82 /
9955     data p(4,2,3) / 772.2 /
9956     data p(4,2,4) / 2.306 /
9957     data p(4,2,5) / 9.139 /
9958     data p(4,2,6) / 0 /
9959     data l(4,3) / 1 /
9960     data p(4,3,1) / 11.49 /
9961     data p(4,3,2) / 11.64 /
9962     data p(4,3,3) / 10290 /
9963     data p(4,3,4) / 2.361 /
9964     data p(4,3,5) / 8.821 /
9965     data p(4,3,6) / 0.4239 /
9966     data z(5) / 8 /
9967     data n(5) / 3 /
9968     data l(5,1) / 0 /
9969     data p(5,1,1) / 537.3 /
9970     data p(5,1,2) / 177.4 /
9971     data p(5,1,3) / 32.37 /
9972     data p(5,1,4) / 381.2 /
9973     data p(5,1,5) / 1.083 /
9974     data p(5,1,6) / 0 /
9975     data l(5,2) / 0 /
9976     data p(5,2,1) / 29.22 /
9977     data p(5,2,2) / 19.94 /
9978     data p(5,2,3) / 241.5 /
9979     data p(5,2,4) / 3.241 /
9980     data p(5,2,5) / 8.037 /
9981     data p(5,2,6) / 0 /
9982     data l(5,3) / 1 /
9983     data p(5,3,1) / 14.16 /
9984     data p(5,3,2) / 13.91 /
9985     data p(5,3,3) / 122000 /
9986     data p(5,3,4) / 1.364 /
9987     data p(5,3,5) / 11.4 /
9988     data p(5,3,6) / 0.4103 /
9989     data z(6) / 9 /
9990     data n(6) / 3 /
9991     data l(6,1) / 0 /
9992     data p(6,1,1) / 688.3 /
9993     data p(6,1,2) / 239 /
9994     data p(6,1,3) / 22.95 /
9995     data p(6,1,4) / 1257 /
9996     data p(6,1,5) / 0.9638 /
9997     data p(6,1,6) / 0 /
9998     data l(6,2) / 0 /
9999     data p(6,2,1) / 35.93 /
10000     data p(6,2,2) / 25.68 /
10001     data p(6,2,3) / 109.7 /
10002     data p(6,2,4) / 4.297 /
10003     data p(6,2,5) / 7.303 /
10004     data p(6,2,6) / 0 /
10005     data l(6,3) / 1 /
10006     data p(6,3,1) / 17 /
10007     data p(6,3,2) / 16.58 /
10008     data p(6,3,3) / 277500 /
10009     data p(6,3,4) / 1.242 /
10010     data p(6,3,5) / 12.49 /
10011     data p(6,3,6) / 0.3857 /
10012     data z(7) / 10 /
10013     data n(7) / 3 /
10014     data l(7,1) / 0 /
10015     data p(7,1,1) / 858.2 /
10016     data p(7,1,2) / 314.4 /
10017     data p(7,1,3) / 16.64 /
10018     data p(7,1,4) / 204200 /
10019     data p(7,1,5) / 0.845 /
10020     data p(7,1,6) / 0 /
10021     data l(7,2) / 0 /
10022     data p(7,2,1) / 43.24 /
10023     data p(7,2,2) / 32.04 /
10024     data p(7,2,3) / 56.15 /
10025     data p(7,2,4) / 5.808 /
10026     data p(7,2,5) / 6.678 /
10027     data p(7,2,6) / 0 /
10028     data l(7,3) / 1 /
10029     data p(7,3,1) / 20 /
10030     data p(7,3,2) / 20 /
10031     data p(7,3,3) / 16910 /
10032     data p(7,3,4) / 2.442 /
10033     data p(7,3,5) / 10.43 /
10034     data p(7,3,6) / 0.3345 /
10035     data z(8) / 13 /
10036     data n(8) / 5 /
10037     data l(8,1) / 0 /
10038     data p(8,1,1) / 1550 /
10039     data p(8,1,2) / 367 /
10040     data p(8,1,3) / 22.06 /
10041     data p(8,1,4) / 44.05 /
10042     data p(8,1,5) / 1.588 /
10043     data p(8,1,6) / 0 /
10044     data l(8,2) / 0 /
10045     data p(8,2,1) / 119 /
10046     data p(8,2,2) / 55.94 /
10047     data p(8,2,3) / 14.25 /
10048     data p(8,2,4) / 30.94 /
10049     data p(8,2,5) / 4.399 /
10050     data p(8,2,6) / 0 /
10051     data l(8,3) / 1 /
10052     data p(8,3,1) / 80.87 /
10053     data p(8,3,2) / 64.45 /
10054     data p(8,3,3) / 173.5 /
10055     data p(8,3,4) / 11310 /
10056     data p(8,3,5) / 2.762 /
10057     data p(8,3,6) / 0.02337 /
10058     data l(8,4) / 0 /
10059     data p(8,4,1) / 10.16 /
10060     data p(8,4,2) / 12.04 /
10061     data p(8,4,3) / 5.384 /
10062     data p(8,4,4) / 434.1 /
10063     data p(8,4,5) / 4.088 /
10064     data p(8,4,6) / 0 /
10065     data l(8,5) / 1 /
10066     data p(8,5,1) / 4.878 /
10067     data p(8,5,2) / 18.6 /
10068     data p(8,5,3) / 182.8 /
10069     data p(8,5,4) / 2.797 /
10070     data p(8,5,5) / 10.84 /
10071     data p(8,5,6) / 0.3076 /
10072     data z(9) / 14 /
10073     data n(9) / 5 /
10074     data l(9,1) / 0 /
10075     data p(9,1,1) / 1828 /
10076     data p(9,1,2) / 532.2 /
10077     data p(9,1,3) / 11.84 /
10078     data p(9,1,4) / 258 /
10079     data p(9,1,5) / 1.102 /
10080     data p(9,1,6) / 0 /
10081     data l(9,2) / 0 /
10082     data p(9,2,1) / 151.5 /
10083     data p(9,2,2) / 70.17 /
10084     data p(9,2,3) / 11.66 /
10085     data p(9,2,4) / 47.42 /
10086     data p(9,2,5) / 3.933 /
10087     data p(9,2,6) / 0 /
10088     data l(9,3) / 1 /
10089     data p(9,3,1) / 108.2 /
10090     data p(9,3,2) / 78.08 /
10091     data p(9,3,3) / 153.2 /
10092     data p(9,3,4) / 5.765e+06 /
10093     data p(9,3,5) / 2.639 /
10094     data p(9,3,6) / 0.0002774 /
10095     data l(9,4) / 0 /
10096     data p(9,4,1) / 13.61 /
10097     data p(9,4,2) / 14.13 /
10098     data p(9,4,3) / 11.66 /
10099     data p(9,4,4) / 22.88 /
10100     data p(9,4,5) / 5.334 /
10101     data p(9,4,6) / 0 /
10102     data l(9,5) / 1 /
10103     data p(9,5,1) / 6.542 /
10104     data p(9,5,2) / 22.12 /
10105     data p(9,5,3) / 184.5 /
10106     data p(9,5,4) / 3.849 /
10107     data p(9,5,5) / 9.721 /
10108     data p(9,5,6) / 0.2921 /
10109     data z(10) / 18 /
10110     data n(10) / 5 /
10111     data l(10,1) / 0 /
10112     data p(10,1,1) / 3178 /
10113     data p(10,1,2) / 1135 /
10114     data p(10,1,3) / 4.28 /
10115     data p(10,1,4) / 3.285e+07 /
10116     data p(10,1,5) / 0.7631 /
10117     data p(10,1,6) / 0 /
10118     data l(10,2) / 0 /
10119     data p(10,2,1) / 313.5 /
10120     data p(10,2,2) / 130.2 /
10121     data p(10,2,3) / 9.185 /
10122     data p(10,2,4) / 26.93 /
10123     data p(10,2,5) / 4.021 /
10124     data p(10,2,6) / 0 /
10125     data l(10,3) / 1 /
10126     data p(10,3,1) / 247.9 /
10127     data p(10,3,2) / 164.7 /
10128     data p(10,3,3) / 83.72 /
10129     data p(10,3,4) / 54.52 /
10130     data p(10,3,5) / 3.328 /
10131     data p(10,3,6) / 0.627 /
10132     data l(10,4) / 0 /
10133     data p(10,4,1) / 28.92 /
10134     data p(10,4,2) / 25.25 /
10135     data p(10,4,3) / 6.394 /
10136     data p(10,4,4) / 170 /
10137     data p(10,4,5) / 4.223 /
10138     data p(10,4,6) / 0 /
10139     data l(10,5) / 1 /
10140     data p(10,5,1) / 14.49 /
10141     data p(10,5,2) / 38.54 /
10142     data p(10,5,3) / 48.72 /
10143     data p(10,5,4) / 26.4 /
10144     data p(10,5,5) / 6.662 /
10145     data p(10,5,6) / 0.2355 /
10146    
10147    
10148    
10149     Za=Zat(na)
10150    
10151    
10152     do i=1,pq
10153    
10154     if(z(i).eq.Za)then
10155    
10156     qshPas(na)=n(i)
10157     do npas=1,qshPas(na)
10158     lPas(npas,na)=l(i,npas)
10159     EthPas(npas,na)=p(i,npas,1)
10160     E0Pas(npas,na)=p(i,npas,2)
10161     sigma0Pas(npas,na)=p(i,npas,3)
10162     yaPas(npas,na)=p(i,npas,4)
10163     PPas(npas,na)=p(i,npas,5)
10164     ywPas(npas,na)=p(i,npas,6)
10165     enddo
10166     go to 110
10167    
10168     endif
10169     enddo
10170     *** Warning message commented out (RV 29/6/98).
10171     C if(soo.eq.1)then
10172     C write(oo,*)
10173     C + ' Worning of readPas: atom z=',Za,' is not found.'
10174     C write(oo,*)
10175     C + ' The data will be seached by shellfi, accuracy will be lower.'
10176     C endif
10177     *** End of modification.
10178     110 continue
10179    
10180    
10181     end
10182    
10183    
10184    
10185     function sigma_nl(E,E0,Eth,yw,l,ya,P,sigma0)
10186    
10187     implicit none
10188    
10189     real sigma_nl,Fpasc
10190     real E,E0,Eth,yw,ya,P,sigma0
10191     integer l
10192    
10193     real Q,y
10194    
10195     if(E.ge.Eth)then
10196    
10197     Q=5.5+l-0.5*P
10198     y=E/E0
10199     Fpasc=((y-1)*(y-1) + yw*yw) * y**(-Q) * (1.0 + sqrt(y/ya))**(-P)
10200     Fpasc=Fpasc*sigma0
10201    
10202     else
10203    
10204     Fpasc=0.0
10205    
10206     endif
10207    
10208     sigma_nl=Fpasc
10209    
10210     end
10211    
10212     subroutine Pripasc
10213    
10214     implicit none
10215    
10216     c include 'GoEvent.inc'
10217     +SEQ,GoEvent.
10218     c include 'ener.inc'
10219     +SEQ,ener.
10220     c include 'atoms.inc'
10221     +SEQ,atoms.
10222     c include 'tpasc.inc'
10223     +SEQ,tpasc.
10224    
10225     integer na,ns
10226    
10227     if(soo.eq.0)return
10228     write(oo,*)
10229     write(oo,*)' Pripasc:'
10230     do na=1,PQat
10231     if(Zat(na).gt.0)then
10232     write(oo,*)' qshPas(na)=',qshPas(na)
10233     write(oo,*)' l,E0,Eth,yw, ya,P,sigma0:'
10234     do ns=1,qshPas(na)
10235     write(oo,'(1X,i3,6e10.3)')lPas(ns,na),E0Pas(ns,na),
10236     + EthPas(ns,na),ywPas(ns,na),yaPas(ns,na),PPas(ns,na),
10237     + sigma0Pas(ns,na)
10238     enddo
10239     endif
10240    
10241     enddo
10242    
10243     end
10244     +DECK,shellfi.
10245     subroutine shellfi
10246     c
10247     c read shellfi.dat
10248    
10249     implicit none
10250    
10251     c include 'GoEvent.inc'
10252     +SEQ,GoEvent.
10253     c include 'shellfi.inc'
10254     +SEQ,shellfi.
10255    
10256     c integer i,z,n,k,j
10257     integer k1,l
10258     c character*1 a
10259     c integer ios
10260    
10261     qash=0 !sign of absence
10262    
10263    
10264     c The next code is generated by a computer program
10265     c on the basis of data file 'shellfi.dat'.
10266    
10267    
10268     if(zato.eq.3)then
10269     qash=2
10270     athreshold(1)=5.44515e-05
10271     aweight(1)=0.666667
10272     qaener(1)=36
10273     aener(1,1)=45.9
10274     aphot(1,1)=0
10275     aener(2,1)=50.4
10276     aphot(2,1)=809
10277     aener(3,1)=55.4
10278     aphot(3,1)=6080
10279     aener(4,1)=60.9
10280     aphot(4,1)=8810
10281     aener(5,1)=66.9
10282     aphot(5,1)=8700
10283     aener(6,1)=73.5
10284     aphot(6,1)=7210
10285     aener(7,1)=80.8
10286     aphot(7,1)=5530
10287     aener(8,1)=88.8
10288     aphot(8,1)=4420
10289     aener(9,1)=97.6
10290     aphot(9,1)=3840
10291     aener(10,1)=107
10292     aphot(10,1)=3090
10293     aener(11,1)=118
10294     aphot(11,1)=2520
10295     aener(12,1)=129
10296     aphot(12,1)=2040
10297     aener(13,1)=142
10298     aphot(13,1)=1820
10299     aener(14,1)=156
10300     aphot(14,1)=1460
10301     aener(15,1)=172
10302     aphot(15,1)=1050
10303     aener(16,1)=189
10304     aphot(16,1)=866
10305     aener(17,1)=207
10306     aphot(17,1)=717
10307     aener(18,1)=228
10308     aphot(18,1)=594
10309     aener(19,1)=275
10310     aphot(19,1)=407
10311     aener(20,1)=303
10312     aphot(20,1)=337
10313     aener(21,1)=500
10314     aphot(21,1)=25.0178
10315     aener(22,1)=700
10316     aphot(22,1)=10.0856
10317     aener(23,1)=900
10318     aphot(23,1)=5.11698
10319     aener(24,1)=1100
10320     aphot(24,1)=2.97651
10321     aener(25,1)=1300
10322     aphot(25,1)=1.89593
10323     aener(26,1)=1600
10324     aphot(26,1)=1.08229
10325     aener(27,1)=2000
10326     aphot(27,1)=0.592498
10327     aener(28,1)=4000
10328     aphot(28,1)=0.0888748
10329     aener(29,1)=6000
10330     aphot(29,1)=0.0296249
10331     aener(30,1)=8000
10332     aphot(30,1)=0.0148125
10333     aener(31,1)=10000
10334     aphot(31,1)=0.00888748
10335     aener(32,1)=20000
10336     aphot(32,1)=0.00503624
10337     aener(33,1)=30000
10338     aphot(33,1)=0.00444374
10339     aener(34,1)=40000
10340     aphot(34,1)=0.00414749
10341     aener(35,1)=50000
10342     aphot(35,1)=0.00399937
10343     aener(36,1)=80000
10344     aphot(36,1)=0.00355499
10345     athreshold(2)=1e-05
10346     aweight(2)=0.333333
10347     qaener(2)=29
10348     aener(1,2)=8.4
10349     aphot(1,2)=0
10350     aener(2,2)=9.23
10351     aphot(2,2)=2100
10352     aener(3,2)=10.1
10353     aphot(3,2)=16900
10354     aener(4,2)=11.1
10355     aphot(4,2)=25500
10356     aener(5,2)=12.2
10357     aphot(5,2)=22900
10358     aener(6,2)=13.5
10359     aphot(6,2)=17600
10360     aener(7,2)=14.8
10361     aphot(7,2)=15000
10362     aener(8,2)=16.2
10363     aphot(8,2)=10700
10364     aener(9,2)=17.9
10365     aphot(9,2)=8880
10366     aener(10,2)=19.6
10367     aphot(10,2)=7360
10368     aener(11,2)=21.6
10369     aphot(11,2)=6090
10370     aener(12,2)=23.7
10371     aphot(12,2)=5040
10372     aener(13,2)=26
10373     aphot(13,2)=4180
10374     aener(14,2)=28.6
10375     aphot(14,2)=3460
10376     aener(15,2)=31.5
10377     aphot(15,2)=2860
10378     aener(16,2)=34.6
10379     aphot(16,2)=2370
10380     aener(17,2)=38
10381     aphot(17,2)=1960
10382     aener(18,2)=41.7
10383     aphot(18,2)=1630
10384     aener(19,2)=45.9
10385     aphot(19,2)=1350
10386     aener(20,2)=50.4
10387     aphot(20,2)=1110
10388     aener(21,2)=55.4
10389     aphot(21,2)=923
10390     aener(22,2)=60.9
10391     aphot(22,2)=764
10392     aener(23,2)=66.9
10393     aphot(23,2)=633
10394     aener(24,2)=73.5
10395     aphot(24,2)=524
10396     aener(25,2)=80.8
10397     aphot(25,2)=434
10398     aener(26,2)=88.8
10399     aphot(26,2)=359
10400     aener(27,2)=97.6
10401     aphot(27,2)=0.298
10402     aener(28,2)=107
10403     aphot(28,2)=0.00246
10404     aener(29,2)=118
10405     aphot(29,2)=0.000204
10406     endif
10407     if(zato.eq.6)then
10408     qash=2
10409     athreshold(1)=0.000309
10410     aweight(1)=0.423871
10411     qaener(1)=24
10412     aener(1,1)=228
10413     aphot(1,1)=16900
10414     aener(2,1)=251
10415     aphot(2,1)=23300
10416     aener(3,1)=275
10417     aphot(3,1)=30700
10418     aener(4,1)=303
10419     aphot(4,1)=38600
10420     aener(5,1)=333
10421     aphot(5,1)=37200
10422     aener(6,1)=365
10423     aphot(6,1)=31200
10424     aener(7,1)=402
10425     aphot(7,1)=24900
10426     aener(8,1)=441
10427     aphot(8,1)=20900
10428     aener(9,1)=485
10429     aphot(9,1)=18000
10430     aener(10,1)=533
10431     aphot(10,1)=14800
10432     aener(11,1)=586
10433     aphot(11,1)=11400
10434     aener(12,1)=644
10435     aphot(12,1)=8620
10436     aener(13,1)=707
10437     aphot(13,1)=7090
10438     aener(14,1)=777
10439     aphot(14,1)=5440
10440     aener(15,1)=854
10441     aphot(15,1)=3960
10442     aener(16,1)=939
10443     aphot(16,1)=3080
10444     aener(17,1)=1030
10445     aphot(17,1)=2400
10446     aener(18,1)=3500
10447     aphot(18,1)=60
10448     aener(19,1)=4000
10449     aphot(19,1)=33
10450     aener(20,1)=10000
10451     aphot(20,1)=2
10452     aener(21,1)=20000
10453     aphot(21,1)=0.4
10454     aener(22,1)=30000
10455     aphot(22,1)=0.27
10456     aener(23,1)=50000
10457     aphot(23,1)=0.2
10458     aener(24,1)=100000
10459     aphot(24,1)=0.17
10460     athreshold(2)=1.03321e-05
10461     aweight(2)=0.576129
10462     qaener(2)=14
10463     aener(1,2)=6.19927
10464     aphot(1,2)=0
10465     aener(2,2)=8.26569
10466     aphot(2,2)=0
10467     aener(3,2)=10.3321
10468     aphot(3,2)=12.6
10469     aener(4,2)=12.3985
10470     aphot(4,2)=11.2
10471     aener(5,2)=15.4982
10472     aphot(5,2)=9.1
10473     aener(6,2)=20.6642
10474     aphot(6,2)=7.3
10475     aener(7,2)=30.9964
10476     aphot(7,2)=4.4
10477     aener(8,2)=41.3285
10478     aphot(8,2)=2.9
10479     aener(9,2)=61.9927
10480     aphot(9,2)=1.45
10481     aener(10,2)=82.6569
10482     aphot(10,2)=0.88
10483     aener(11,2)=103.321
10484     aphot(11,2)=0.59
10485     aener(12,2)=123.985
10486     aphot(12,2)=0.4
10487     aener(13,2)=154.982
10488     aphot(13,2)=0.24
10489     aener(14,2)=206.642
10490     aphot(14,2)=0.108
10491     endif
10492     if(zato.eq.7)then
10493     qash=2
10494     athreshold(1)=0.000413
10495     aweight(1)=0.318257
10496     qaener(1)=8
10497     aener(1,1)=309.964
10498     aphot(1,1)=0.07
10499     aener(2,1)=413.285
10500     aphot(2,1)=0.68
10501     aener(3,1)=619.927
10502     aphot(3,1)=0.255
10503     aener(4,1)=826.569
10504     aphot(4,1)=0.125
10505     aener(5,1)=1033.21
10506     aphot(5,1)=0.075
10507     aener(6,1)=1239.85
10508     aphot(6,1)=0.047
10509     aener(7,1)=1549.82
10510     aphot(7,1)=0.026
10511     aener(8,1)=2066.42
10512     aphot(8,1)=0.012
10513     athreshold(2)=1.23985e-05
10514     aweight(2)=0.681743
10515     qaener(2)=15
10516     aener(1,2)=6.19927
10517     aphot(1,2)=0
10518     aener(2,2)=8.26569
10519     aphot(2,2)=0
10520     aener(3,2)=10.3321
10521     aphot(3,2)=0
10522     aener(4,2)=12.3985
10523     aphot(4,2)=11.95
10524     aener(5,2)=15.4982
10525     aphot(5,2)=11.9
10526     aener(6,2)=20.6642
10527     aphot(6,2)=9.65
10528     aener(7,2)=30.9964
10529     aphot(7,2)=7.8
10530     aener(8,2)=41.3285
10531     aphot(8,2)=5.4
10532     aener(9,2)=61.9927
10533     aphot(9,2)=2.9
10534     aener(10,2)=82.6569
10535     aphot(10,2)=1.75
10536     aener(11,2)=103.321
10537     aphot(11,2)=1.1
10538     aener(12,2)=123.985
10539     aphot(12,2)=0.65
10540     aener(13,2)=154.982
10541     aphot(13,2)=0.39
10542     aener(14,2)=206.642
10543     aphot(14,2)=0.208
10544     aener(15,2)=309.964
10545     aphot(15,2)=0.07
10546     endif
10547     if(zato.eq.8)then
10548     qash=2
10549     athreshold(1)=0.00062
10550     aweight(1)=0.240404
10551     qaener(1)=20
10552     aener(1,1)=586
10553     aphot(1,1)=13300
10554     aener(2,1)=644
10555     aphot(2,1)=14200
10556     aener(3,1)=707
10557     aphot(3,1)=11800
10558     aener(4,1)=777
10559     aphot(4,1)=9270
10560     aener(5,1)=854
10561     aphot(5,1)=7100
10562     aener(6,1)=939
10563     aphot(6,1)=5880
10564     aener(7,1)=1030
10565     aphot(7,1)=4660
10566     aener(8,1)=1130
10567     aphot(8,1)=3690
10568     aener(9,1)=1250
10569     aphot(9,1)=2790
10570     aener(10,1)=1370
10571     aphot(10,1)=2260
10572     aener(11,1)=1500
10573     aphot(11,1)=1740
10574     aener(12,1)=1650
10575     aphot(12,1)=1340
10576     aener(13,1)=1820
10577     aphot(13,1)=1060
10578     aener(14,1)=3500
10579     aphot(14,1)=187.5
10580     aener(15,1)=4000
10581     aphot(15,1)=118.125
10582     aener(16,1)=10000
10583     aphot(16,1)=6.75
10584     aener(17,1)=20000
10585     aphot(17,1)=0.9
10586     aener(18,1)=30000
10587     aphot(18,1)=0.39375
10588     aener(19,1)=50000
10589     aphot(19,1)=0.255
10590     aener(20,1)=100000
10591     aphot(20,1)=0.19875
10592     athreshold(2)=2.06642e-05
10593     aweight(2)=0.759596
10594     qaener(2)=16
10595     aener(1,2)=6.19927
10596     aphot(1,2)=0
10597     aener(2,2)=8.26569
10598     aphot(2,2)=0
10599     aener(3,2)=10.3321
10600     aphot(3,2)=0
10601     aener(4,2)=12.3985
10602     aphot(4,2)=0
10603     aener(5,2)=15.4982
10604     aphot(5,2)=9
10605     aener(6,2)=20.6642
10606     aphot(6,2)=9.65
10607     aener(7,2)=30.9964
10608     aphot(7,2)=8.75
10609     aener(8,2)=41.3285
10610     aphot(8,2)=7.42
10611     aener(9,2)=61.9927
10612     aphot(9,2)=4.65
10613     aener(10,2)=82.6569
10614     aphot(10,2)=2.7
10615     aener(11,2)=103.321
10616     aphot(11,2)=1.77
10617     aener(12,2)=123.985
10618     aphot(12,2)=1.12
10619     aener(13,2)=154.982
10620     aphot(13,2)=0.7
10621     aener(14,2)=206.642
10622     aphot(14,2)=0.385
10623     aener(15,2)=309.964
10624     aphot(15,2)=0.16
10625     aener(16,2)=413.285
10626     aphot(16,2)=0.065
10627     endif
10628     if(zato.eq.9)then
10629     qash=2
10630     athreshold(1)=0.000827
10631     aweight(1)=0.185727
10632     qaener(1)=6
10633     aener(1,1)=619.927
10634     aphot(1,1)=0.05
10635     aener(2,1)=826.569
10636     aphot(2,1)=0.305
10637     aener(3,1)=1033.21
10638     aphot(3,1)=0.17
10639     aener(4,1)=1239.85
10640     aphot(4,1)=0.115
10641     aener(5,1)=1549.82
10642     aphot(5,1)=0.067
10643     aener(6,1)=2066.42
10644     aphot(6,1)=0.03
10645     athreshold(2)=3.09964e-05
10646     aweight(2)=0.814273
10647     qaener(2)=17
10648     aener(1,2)=6.19927
10649     aphot(1,2)=0
10650     aener(2,2)=8.26569
10651     aphot(2,2)=0
10652     aener(3,2)=10.3321
10653     aphot(3,2)=0
10654     aener(4,2)=12.3985
10655     aphot(4,2)=0
10656     aener(5,2)=15.4982
10657     aphot(5,2)=0
10658     aener(6,2)=20.6642
10659     aphot(6,2)=0
10660     aener(7,2)=30.9964
10661     aphot(7,2)=10.6
10662     aener(8,2)=41.3285
10663     aphot(8,2)=10.1
10664     aener(9,2)=61.9927
10665     aphot(9,2)=6.7
10666     aener(10,2)=82.6569
10667     aphot(10,2)=4.1
10668     aener(11,2)=103.321
10669     aphot(11,2)=2.6
10670     aener(12,2)=123.985
10671     aphot(12,2)=1.8
10672     aener(13,2)=154.982
10673     aphot(13,2)=1.3
10674     aener(14,2)=206.642
10675     aphot(14,2)=0.59
10676     aener(15,2)=309.964
10677     aphot(15,2)=0.245
10678     aener(16,2)=413.285
10679     aphot(16,2)=0.124
10680     aener(17,2)=619.927
10681     aphot(17,2)=0.05
10682     endif
10683     if(zato.eq.10)then
10684     qash=2
10685     athreshold(1)=0.001033
10686     aweight(1)=0.117826
10687     qaener(1)=5
10688     aener(1,1)=826.569
10689     aphot(1,1)=0.03
10690     aener(2,1)=1033.21
10691     aphot(2,1)=0.205
10692     aener(3,1)=1239.85
10693     aphot(3,1)=0.135
10694     aener(4,1)=1549.82
10695     aphot(4,1)=0.077
10696     aener(5,1)=2066.42
10697     aphot(5,1)=0.039
10698     athreshold(2)=3.09964e-05
10699     aweight(2)=0.882174
10700     qaener(2)=18
10701     aener(1,2)=6.19927
10702     aphot(1,2)=0
10703     aener(2,2)=8.26569
10704     aphot(2,2)=0
10705     aener(3,2)=10.3321
10706     aphot(3,2)=0
10707     aener(4,2)=12.3985
10708     aphot(4,2)=0
10709     aener(5,2)=15.4982
10710     aphot(5,2)=0
10711     aener(6,2)=20.6642
10712     aphot(6,2)=5.85
10713     aener(7,2)=30.9964
10714     aphot(7,2)=8.8
10715     aener(8,2)=41.3285
10716     aphot(8,2)=8.7
10717     aener(9,2)=61.9927
10718     aphot(9,2)=7.3
10719     aener(10,2)=82.6569
10720     aphot(10,2)=5.6
10721     aener(11,2)=103.321
10722     aphot(11,2)=4
10723     aener(12,2)=123.985
10724     aphot(12,2)=2.8
10725     aener(13,2)=154.982
10726     aphot(13,2)=1.75
10727     aener(14,2)=206.642
10728     aphot(14,2)=0.91
10729     aener(15,2)=309.964
10730     aphot(15,2)=0.36
10731     aener(16,2)=413.285
10732     aphot(16,2)=0.17
10733     aener(17,2)=619.927
10734     aphot(17,2)=0.063
10735     aener(18,2)=826.569
10736     aphot(18,2)=0.03
10737     endif
10738     if(zato.eq.17)then
10739     qash=4
10740     athreshold(1)=0.003485
10741     aweight(1)=0.117088
10742     qaener(1)=69
10743     aener(1,1)=3365.37
10744     aphot(1,1)=0
10745     aener(2,1)=3536.21
10746     aphot(2,1)=0.050227
10747     aener(3,1)=3715.72
10748     aphot(3,1)=0.0574
10749     aener(4,1)=3904.35
10750     aphot(4,1)=0.051988
10751     aener(5,1)=4102.55
10752     aphot(5,1)=0.047086
10753     aener(6,1)=4310.81
10754     aphot(6,1)=0.042647
10755     aener(7,1)=4529.65
10756     aphot(7,1)=0.038625
10757     aener(8,1)=4759.59
10758     aphot(8,1)=0.034983
10759     aener(9,1)=5001.2
10760     aphot(9,1)=0.031685
10761     aener(10,1)=5255.08
10762     aphot(10,1)=0.028697
10763     aener(11,1)=5521.85
10764     aphot(11,1)=0.025992
10765     aener(12,1)=5802.16
10766     aphot(12,1)=0.023541
10767     aener(13,1)=6096.71
10768     aphot(13,1)=0.021321
10769     aener(14,1)=6406.2
10770     aphot(14,1)=0.019311
10771     aener(15,1)=6731.4
10772     aphot(15,1)=0.01749
10773     aener(16,1)=7073.12
10774     aphot(16,1)=0.015841
10775     aener(17,1)=7432.17
10776     aphot(17,1)=0.014347
10777     aener(18,1)=7809.46
10778     aphot(18,1)=0.012995
10779     aener(19,1)=8205.9
10780     aphot(19,1)=0.011769
10781     aener(20,1)=8622.46
10782     aphot(20,1)=0.01066
10783     aener(21,1)=9060.17
10784     aphot(21,1)=0.009654
10785     aener(22,1)=9520.11
10786     aphot(22,1)=0.008744
10787     aener(23,1)=10003.4
10788     aphot(23,1)=0.00792
10789     aener(24,1)=10511.2
10790     aphot(24,1)=0.007173
10791     aener(25,1)=11044.8
10792     aphot(25,1)=0.006497
10793     aener(26,1)=11605.5
10794     aphot(26,1)=0.005884
10795     aener(27,1)=12194.6
10796     aphot(27,1)=0.005329
10797     aener(28,1)=12813.6
10798     aphot(28,1)=0.004827
10799     aener(29,1)=13464.1
10800     aphot(29,1)=0.004372
10801     aener(30,1)=14147.6
10802     aphot(30,1)=0.003959
10803     aener(31,1)=14865.8
10804     aphot(31,1)=0.003586
10805     aener(32,1)=15620.4
10806     aphot(32,1)=0.003248
10807     aener(33,1)=16413.4
10808     aphot(33,1)=0.002942
10809     aener(34,1)=17246.6
10810     aphot(34,1)=0.002664
10811     aener(35,1)=18122.1
10812     aphot(35,1)=0.002413
10813     aener(36,1)=19042.1
10814     aphot(36,1)=0.002186
10815     aener(37,1)=20008.7
10816     aphot(37,1)=0.00198
10817     aener(38,1)=21024.4
10818     aphot(38,1)=0.001793
10819     aener(39,1)=22091.7
10820     aphot(39,1)=0.001624
10821     aener(40,1)=23213.2
10822     aphot(40,1)=0.001471
10823     aener(41,1)=24391.6
10824     aphot(41,1)=0.001332
10825     aener(42,1)=25629.8
10826     aphot(42,1)=0.001206
10827     aener(43,1)=26930.9
10828     aphot(43,1)=0.001093
10829     aener(44,1)=28298
10830     aphot(44,1)=0.00099
10831     aener(45,1)=29734.5
10832     aphot(45,1)=0.000896
10833     aener(46,1)=31243.9
10834     aphot(46,1)=0.000812
10835     aener(47,1)=32830
10836     aphot(47,1)=0.000735
10837     aener(48,1)=34496.6
10838     aphot(48,1)=0.000666
10839     aener(49,1)=36247.8
10840     aphot(49,1)=0.000603
10841     aener(50,1)=38087.9
10842     aphot(50,1)=0.000546
10843     aener(51,1)=40021.3
10844     aphot(51,1)=0.000495
10845     aener(52,1)=42053
10846     aphot(52,1)=0.000448
10847     aener(53,1)=44187.8
10848     aphot(53,1)=0.000406
10849     aener(54,1)=46430.9
10850     aphot(54,1)=0.000368
10851     aener(55,1)=48787.9
10852     aphot(55,1)=0.000333
10853     aener(56,1)=51264.6
10854     aphot(56,1)=0.000302
10855     aener(57,1)=53867
10856     aphot(57,1)=0.000273
10857     aener(58,1)=56601.5
10858     aphot(58,1)=0.000247
10859     aener(59,1)=59474.8
10860     aphot(59,1)=0.000224
10861     aener(60,1)=62494
10862     aphot(60,1)=0.000203
10863     aener(61,1)=65666.4
10864     aphot(61,1)=0.000184
10865     aener(62,1)=68999.9
10866     aphot(62,1)=0.000166
10867     aener(63,1)=72502.6
10868     aphot(63,1)=0.000151
10869     aener(64,1)=76183.1
10870     aphot(64,1)=0.000137
10871     aener(65,1)=80050.5
10872     aphot(65,1)=0.000124
10873     aener(66,1)=84114.2
10874     aphot(66,1)=0.000112
10875     aener(67,1)=88384.1
10876     aphot(67,1)=0.000101
10877     aener(68,1)=92870.9
10878     aphot(68,1)=9.18846e-05
10879     aener(69,1)=97585.4
10880     aphot(69,1)=8.32209e-05
10881     athreshold(2)=0.000207
10882     aweight(2)=0.635323
10883     qaener(2)=10
10884     aener(1,2)=154.982
10885     aphot(1,2)=0.6
10886     aener(2,2)=206.642
10887     aphot(2,2)=6.4
10888     aener(3,2)=309.964
10889     aphot(3,2)=2.45
10890     aener(4,2)=413.285
10891     aphot(4,2)=1.4
10892     aener(5,2)=619.927
10893     aphot(5,2)=0.45
10894     aener(6,2)=826.569
10895     aphot(6,2)=0.22
10896     aener(7,2)=1033.21
10897     aphot(7,2)=0.123
10898     aener(8,2)=1239.85
10899     aphot(8,2)=0.079
10900     aener(9,2)=1549.82
10901     aphot(9,2)=0.047
10902     aener(10,2)=2066.42
10903     aphot(10,2)=0.0195
10904     athreshold(3)=6.19927e-05
10905     aweight(3)=0.061546
10906     qaener(3)=6
10907     aener(1,3)=41.3285
10908     aphot(1,3)=1.07
10909     aener(2,3)=61.9927
10910     aphot(2,3)=1.35
10911     aener(3,3)=82.6569
10912     aphot(3,3)=1.22
10913     aener(4,3)=103.321
10914     aphot(4,3)=1
10915     aener(5,3)=123.985
10916     aphot(5,3)=0.82
10917     aener(6,3)=154.982
10918     aphot(6,3)=0.6
10919     athreshold(4)=1.54982e-05
10920     aweight(4)=0.186043
10921     qaener(4)=8
10922     aener(1,4)=6.19927
10923     aphot(1,4)=0
10924     aener(2,4)=8.26569
10925     aphot(2,4)=0
10926     aener(3,4)=10.3321
10927     aphot(3,4)=0
10928     aener(4,4)=12.3985
10929     aphot(4,4)=0
10930     aener(5,4)=15.4982
10931     aphot(5,4)=59
10932     aener(6,4)=20.6642
10933     aphot(6,4)=11
10934     aener(7,4)=30.9964
10935     aphot(7,4)=1.35
10936     aener(8,4)=41.3285
10937     aphot(8,4)=1.07
10938     endif
10939     if(zato.eq.18)then
10940     qash=4
10941     athreshold(1)=0.003934
10942     aweight(1)=0.114211
10943     qaener(1)=67
10944     aener(1,1)=3715.72
10945     aphot(1,1)=0
10946     aener(2,1)=3904.35
10947     aphot(2,1)=0.020435
10948     aener(3,1)=4102.55
10949     aphot(3,1)=0.053399
10950     aener(4,1)=4310.81
10951     aphot(4,1)=0.048364
10952     aener(5,1)=4529.65
10953     aphot(5,1)=0.043804
10954     aener(6,1)=4759.59
10955     aphot(6,1)=0.039674
10956     aener(7,1)=5001.2
10957     aphot(7,1)=0.035933
10958     aener(8,1)=5255.08
10959     aphot(8,1)=0.032545
10960     aener(9,1)=5521.85
10961     aphot(9,1)=0.029476
10962     aener(10,1)=5802.16
10963     aphot(10,1)=0.026697
10964     aener(11,1)=6096.71
10965     aphot(11,1)=0.02418
10966     aener(12,1)=6406.2
10967     aphot(12,1)=0.0219
10968     aener(13,1)=6731.4
10969     aphot(13,1)=0.019835
10970     aener(14,1)=7073.12
10971     aphot(14,1)=0.017965
10972     aener(15,1)=7432.17
10973     aphot(15,1)=0.016271
10974     aener(16,1)=7809.46
10975     aphot(16,1)=0.014737
10976     aener(17,1)=8205.9
10977     aphot(17,1)=0.013347
10978     aener(18,1)=8622.46
10979     aphot(18,1)=0.012089
10980     aener(19,1)=9060.17
10981     aphot(19,1)=0.010949
10982     aener(20,1)=9520.11
10983     aphot(20,1)=0.009917
10984     aener(21,1)=10003.4
10985     aphot(21,1)=0.008982
10986     aener(22,1)=10511.2
10987     aphot(22,1)=0.008135
10988     aener(23,1)=11044.8
10989     aphot(23,1)=0.007368
10990     aener(24,1)=11605.5
10991     aphot(24,1)=0.006673
10992     aener(25,1)=12194.6
10993     aphot(25,1)=0.006044
10994     aener(26,1)=12813.6
10995     aphot(26,1)=0.005474
10996     aener(27,1)=13464.1
10997     aphot(27,1)=0.004958
10998     aener(28,1)=14147.6
10999     aphot(28,1)=0.00449
11000     aener(29,1)=14865.8
11001     aphot(29,1)=0.004067
11002     aener(30,1)=15620.4
11003     aphot(30,1)=0.003683
11004     aener(31,1)=16413.4
11005     aphot(31,1)=0.003336
11006     aener(32,1)=17246.6
11007     aphot(32,1)=0.003022
11008     aener(33,1)=18122.1
11009     aphot(33,1)=0.002737
11010     aener(34,1)=19042.1
11011     aphot(34,1)=0.002479
11012     aener(35,1)=20008.7
11013     aphot(35,1)=0.002245
11014     aener(36,1)=21024.4
11015     aphot(36,1)=0.002033
11016     aener(37,1)=22091.7
11017     aphot(37,1)=0.001842
11018     aener(38,1)=23213.2
11019     aphot(38,1)=0.001668
11020     aener(39,1)=24391.6
11021     aphot(39,1)=0.001511
11022     aener(40,1)=25629.8
11023     aphot(40,1)=0.001368
11024     aener(41,1)=26930.9
11025     aphot(41,1)=0.001239
11026     aener(42,1)=28298
11027     aphot(42,1)=0.001122
11028     aener(43,1)=29734.5
11029     aphot(43,1)=0.001017
11030     aener(44,1)=31243.9
11031     aphot(44,1)=0.000921
11032     aener(45,1)=32830
11033     aphot(45,1)=0.000834
11034     aener(46,1)=34496.6
11035     aphot(46,1)=0.000755
11036     aener(47,1)=36247.8
11037     aphot(47,1)=0.000684
11038     aener(48,1)=38087.9
11039     aphot(48,1)=0.00062
11040     aener(49,1)=40021.3
11041     aphot(49,1)=0.000561
11042     aener(50,1)=42053
11043     aphot(50,1)=0.000508
11044     aener(51,1)=44187.8
11045     aphot(51,1)=0.00046
11046     aener(52,1)=46430.9
11047     aphot(52,1)=0.000417
11048     aener(53,1)=48787.9
11049     aphot(53,1)=0.000378
11050     aener(54,1)=51264.6
11051     aphot(54,1)=0.000342
11052     aener(55,1)=53867
11053     aphot(55,1)=0.00031
11054     aener(56,1)=56601.5
11055     aphot(56,1)=0.000281
11056     aener(57,1)=59474.8
11057     aphot(57,1)=0.000254
11058     aener(58,1)=62494
11059     aphot(58,1)=0.00023
11060     aener(59,1)=65666.4
11061     aphot(59,1)=0.000208
11062     aener(60,1)=68999.9
11063     aphot(60,1)=0.000189
11064     aener(61,1)=72502.6
11065     aphot(61,1)=0.000171
11066     aener(62,1)=76183.1
11067     aphot(62,1)=0.000155
11068     aener(63,1)=80050.5
11069     aphot(63,1)=0.00014
11070     aener(64,1)=84114.2
11071     aphot(64,1)=0.000127
11072     aener(65,1)=88384.1
11073     aphot(65,1)=0.000115
11074     aener(66,1)=92870.9
11075     aphot(66,1)=0.000104
11076     aener(67,1)=97585.4
11077     aphot(67,1)=9.43788e-05
11078     athreshold(2)=0.00031
11079     aweight(2)=0.438551
11080     qaener(2)=10
11081     aener(1,2)=206.642
11082     aphot(1,2)=0.55
11083     aener(2,2)=309.964
11084     aphot(2,2)=2.52
11085     aener(3,2)=413.285
11086     aphot(3,2)=1.66
11087     aener(4,2)=619.927
11088     aphot(4,2)=0.62
11089     aener(5,2)=826.569
11090     aphot(5,2)=0.29
11091     aener(6,2)=1033.21
11092     aphot(6,2)=0.16
11093     aener(7,2)=1239.85
11094     aphot(7,2)=0.1
11095     aener(8,2)=1549.82
11096     aphot(8,2)=0.06
11097     aener(9,2)=2066.42
11098     aphot(9,2)=0.026
11099     aener(10,2)=3099.64
11100     aphot(10,2)=0.0085
11101     athreshold(3)=6.19927e-05
11102     aweight(3)=0.092874
11103     qaener(3)=7
11104     aener(1,3)=41.3285
11105     aphot(1,3)=1
11106     aener(2,3)=61.9927
11107     aphot(2,3)=1.52
11108     aener(3,3)=82.6569
11109     aphot(3,3)=1.52
11110     aener(4,3)=103.321
11111     aphot(4,3)=1.33
11112     aener(5,3)=123.985
11113     aphot(5,3)=1.1
11114     aener(6,3)=154.982
11115     aphot(6,3)=0.85
11116     aener(7,3)=206.642
11117     aphot(7,3)=0.55
11118     athreshold(4)=1.54982e-05
11119     aweight(4)=0.354364
11120     qaener(4)=8
11121     aener(1,4)=6.19927
11122     aphot(1,4)=0
11123     aener(2,4)=8.26569
11124     aphot(2,4)=0
11125     aener(3,4)=10.3321
11126     aphot(3,4)=0
11127     aener(4,4)=12.3985
11128     aphot(4,4)=0
11129     aener(5,4)=15.4982
11130     aphot(5,4)=60
11131     aener(6,4)=20.6642
11132     aphot(6,4)=52.5
11133     aener(7,4)=30.9964
11134     aphot(7,4)=2
11135     aener(8,4)=41.3285
11136     aphot(8,4)=1
11137     endif
11138     if(zato.eq.36)then
11139     qash=4
11140     athreshold(1)=0.015498
11141     aweight(1)=0.04453
11142     qaener(1)=4
11143     aener(1,1)=12398.5
11144     aphot(1,1)=0.0032
11145     aener(2,1)=15498.2
11146     aphot(2,1)=0.0205
11147     aener(3,1)=20664.2
11148     aphot(3,1)=0.0079
11149     aener(4,1)=30996.4
11150     aphot(4,1)=0.0022
11151     athreshold(2)=0.00155
11152     aweight(2)=0.262277
11153     qaener(2)=9
11154     aener(1,2)=1239.85
11155     aphot(1,2)=0.22
11156     aener(2,2)=1549.82
11157     aphot(2,2)=0.7
11158     aener(3,2)=2066.42
11159     aphot(3,2)=0.41
11160     aener(4,2)=3099.64
11161     aphot(4,2)=0.14
11162     aener(5,2)=4132.85
11163     aphot(5,2)=0.061
11164     aener(6,2)=6199.27
11165     aphot(6,2)=0.02
11166     aener(7,2)=8265.69
11167     aphot(7,2)=0.0096
11168     aener(8,2)=10332.1
11169     aphot(8,2)=0.0053
11170     aener(9,2)=12398.5
11171     aphot(9,2)=0.0032
11172     athreshold(3)=0.000207
11173     aweight(3)=0.594165
11174     qaener(3)=11
11175     aener(1,3)=82.6569
11176     aphot(1,3)=0.7
11177     aener(2,3)=103.321
11178     aphot(2,3)=1.2
11179     aener(3,3)=123.985
11180     aphot(3,3)=3.4
11181     aener(4,3)=154.982
11182     aphot(4,3)=6.1
11183     aener(5,3)=206.642
11184     aphot(5,3)=6.8
11185     aener(6,3)=309.964
11186     aphot(6,3)=4.4
11187     aener(7,3)=413.285
11188     aphot(7,3)=2.65
11189     aener(8,3)=619.927
11190     aphot(8,3)=0.95
11191     aener(9,3)=826.569
11192     aphot(9,3)=0.54
11193     aener(10,3)=1033.21
11194     aphot(10,3)=0.34
11195     aener(11,3)=1239.85
11196     aphot(11,3)=0.22
11197     athreshold(4)=1.54982e-05
11198     aweight(4)=0.099027
11199     qaener(4)=10
11200     aener(1,4)=6.19927
11201     aphot(1,4)=0
11202     aener(2,4)=8.26569
11203     aphot(2,4)=0
11204     aener(3,4)=10.3321
11205     aphot(3,4)=0
11206     aener(4,4)=12.3985
11207     aphot(4,4)=0
11208     aener(5,4)=15.4982
11209     aphot(5,4)=60
11210     aener(6,4)=20.6642
11211     aphot(6,4)=7.2
11212     aener(7,4)=30.9964
11213     aphot(7,4)=1.75
11214     aener(8,4)=41.3285
11215     aphot(8,4)=1.05
11216     aener(9,4)=61.9927
11217     aphot(9,4)=0.75
11218     aener(10,4)=82.6569
11219     aphot(10,4)=0.7
11220     endif
11221     if(zato.eq.54)then
11222     qash=6
11223     athreshold(1)=0.041328
11224     aweight(1)=0.017971
11225     qaener(1)=3
11226     aener(1,1)=30996.4
11227     aphot(1,1)=0.0013
11228     aener(2,1)=41328.5
11229     aphot(2,1)=0.0046
11230     aener(3,1)=61992.7
11231     aphot(3,1)=0.0015
11232     athreshold(2)=0.006199
11233     aweight(2)=0.114379
11234     qaener(2)=7
11235     aener(1,2)=4132.85
11236     aphot(1,2)=0.071
11237     aener(2,2)=6199.27
11238     aphot(2,2)=0.11
11239     aener(3,2)=8265.69
11240     aphot(3,2)=0.051
11241     aener(4,2)=12398.5
11242     aphot(4,2)=0.017
11243     aener(5,2)=15498.2
11244     aphot(5,2)=0.009
11245     aener(6,2)=20664.2
11246     aphot(6,2)=0.004
11247     aener(7,2)=30996.4
11248     aphot(7,2)=0.0013
11249     athreshold(3)=0.000827
11250     aweight(3)=0.411049
11251     qaener(3)=8
11252     aener(1,3)=619.927
11253     aphot(1,3)=0.63
11254     aener(2,3)=826.569
11255     aphot(2,3)=2.3
11256     aener(3,3)=1033.21
11257     aphot(3,3)=1.8
11258     aener(4,3)=1239.85
11259     aphot(4,3)=1.37
11260     aener(5,3)=1549.82
11261     aphot(5,3)=0.86
11262     aener(6,3)=2066.42
11263     aphot(6,3)=0.42
11264     aener(7,3)=3099.64
11265     aphot(7,3)=0.15
11266     aener(8,3)=4132.85
11267     aphot(8,3)=0.071
11268     athreshold(4)=0.00031
11269     aweight(4)=0.075061
11270     qaener(4)=4
11271     aener(1,4)=206.642
11272     aphot(1,4)=1
11273     aener(2,4)=309.964
11274     aphot(2,4)=1.15
11275     aener(3,4)=413.285
11276     aphot(3,4)=1
11277     aener(4,4)=619.927
11278     aphot(4,4)=0.63
11279     athreshold(5)=8.26569e-05
11280     aweight(5)=0.273675
11281     qaener(5)=6
11282     aener(1,5)=61.9927
11283     aphot(1,5)=0.67
11284     aener(2,5)=82.6569
11285     aphot(2,5)=48
11286     aener(3,5)=103.321
11287     aphot(3,5)=14
11288     aener(4,5)=123.985
11289     aphot(4,5)=2.5
11290     aener(5,5)=154.982
11291     aphot(5,5)=1.1
11292     aener(6,5)=206.642
11293     aphot(6,5)=1
11294     athreshold(6)=1.23985e-05
11295     aweight(6)=0.107866
11296     qaener(6)=9
11297     aener(1,6)=6.19927
11298     aphot(1,6)=0
11299     aener(2,6)=8.26569
11300     aphot(2,6)=0
11301     aener(3,6)=10.3321
11302     aphot(3,6)=0
11303     aener(4,6)=12.3985
11304     aphot(4,6)=110
11305     aener(5,6)=15.4982
11306     aphot(5,6)=37
11307     aener(6,6)=20.6642
11308     aphot(6,6)=10
11309     aener(7,6)=30.9964
11310     aphot(7,6)=2.2
11311     aener(8,6)=41.3285
11312     aphot(8,6)=1.1
11313     aener(9,6)=61.9927
11314     aphot(9,6)=0.67
11315     endif
11316    
11317     c end of computer code
11318    
11319    
11320     do k1=1,qash
11321     do l=1,qaener(k1)
11322    
11323    
11324     aener(l,k1)=aener(l,k1)*1.e-6
11325    
11326     enddo
11327     enddo
11328    
11329    
11330     if(soo.eq.1)then
11331     if(qash.eq.0)then
11332     write(oo,*)' Worning of shellfi: atom z=',zato,' is not found.'
11333     write(oo,*)
11334     + ' The data will be seached by shteor, accuracy will be lower.'
11335    
11336     endif
11337     endif
11338    
11339     c call prishellfi
11340    
11341     end
11342    
11343    
11344     subroutine shteor(num)
11345    
11346     c read shteor.dat
11347    
11348     implicit none
11349    
11350     c include 'shellfi.inc'
11351     +SEQ,shellfi.
11352     c include 'LibAtMat.inc'
11353     +SEQ,LibAtMat.
11354    
11355     integer num
11356    
11357     c character*1 a
11358     c integer i,z,n,k
11359    
11360     qash=0
11361    
11362    
11363     c The next code is generated
11364     c by a computer program
11365     c using a readable data file
11366    
11367    
11368    
11369     if(zato.eq.1)then
11370     c if(num.eq.num_H)then
11371     qash=1
11372     athreshold(1)=1e-05
11373     aweight(1)=1
11374     c endif
11375     if(num.eq.num_H3)then ! for CH4
11376     qash=1
11377     athreshold(1)=15.2e-06
11378     aweight(1)=1
11379     endif
11380     endif
11381     if(zato.eq.2)then
11382     qash=1
11383     athreshold(1)=1.36129e-05
11384     aweight(1)=1
11385     endif
11386     if(zato.eq.3)then
11387     qash=2
11388     athreshold(1)=5.44515e-05
11389     aweight(1)=0.666667
11390     athreshold(2)=1e-05
11391     aweight(2)=0.333333
11392     endif
11393     if(zato.eq.4)then
11394     qash=2
11395     athreshold(1)=0.000123
11396     aweight(1)=0.5
11397     athreshold(2)=1e-05
11398     aweight(2)=0.5
11399     endif
11400     if(zato.eq.5)then
11401     qash=2
11402     athreshold(1)=0.000218
11403     aweight(1)=0.4
11404     athreshold(2)=1e-05
11405     aweight(2)=0.6
11406     endif
11407     if(zato.eq.6)then
11408     qash=2
11409     athreshold(1)=0.00034
11410     aweight(1)=0.333333
11411     athreshold(2)=1.36129e-05
11412     aweight(2)=0.666667
11413     endif
11414     if(zato.eq.7)then
11415     qash=2
11416     athreshold(1)=0.00049
11417     aweight(1)=0.285714
11418     athreshold(2)=2.12701e-05
11419     aweight(2)=0.714286
11420     endif
11421     if(zato.eq.8)then
11422     qash=2
11423     athreshold(1)=0.000667
11424     aweight(1)=0.25
11425     athreshold(2)=3.0629e-05
11426     aweight(2)=0.75
11427     endif
11428     if(zato.eq.9)then
11429     qash=2
11430     athreshold(1)=0.000871
11431     aweight(1)=0.222222
11432     athreshold(2)=4.16894e-05
11433     aweight(2)=0.777778
11434     endif
11435     if(zato.eq.10)then
11436     qash=2
11437     athreshold(1)=0.001103
11438     aweight(1)=0.2
11439     athreshold(2)=5.44515e-05
11440     aweight(2)=0.8
11441     endif
11442     if(zato.eq.11)then
11443     qash=3
11444     athreshold(1)=0.001361
11445     aweight(1)=0.181818
11446     athreshold(2)=8.50804e-05
11447     aweight(2)=0.727273
11448     athreshold(3)=1e-05
11449     aweight(3)=0.090909
11450     endif
11451     if(zato.eq.12)then
11452     qash=3
11453     athreshold(1)=0.001647
11454     aweight(1)=0.166667
11455     athreshold(2)=0.000123
11456     aweight(2)=0.666667
11457     athreshold(3)=1e-05
11458     aweight(3)=0.166667
11459     endif
11460     if(zato.eq.13)then
11461     qash=3
11462     athreshold(1)=0.00196
11463     aweight(1)=0.153846
11464     athreshold(2)=0.000167
11465     aweight(2)=0.615385
11466     athreshold(3)=1e-05
11467     aweight(3)=0.230769
11468     endif
11469     if(zato.eq.14)then
11470     qash=3
11471     athreshold(1)=0.002301
11472     aweight(1)=0.142857
11473     athreshold(2)=0.000218
11474     aweight(2)=0.571429
11475     athreshold(3)=1e-05
11476     aweight(3)=0.285714
11477     endif
11478     if(zato.eq.15)then
11479     qash=3
11480     athreshold(1)=0.002668
11481     aweight(1)=0.133333
11482     athreshold(2)=0.000276
11483     aweight(2)=0.533333
11484     athreshold(3)=1e-05
11485     aweight(3)=0.333333
11486     endif
11487     if(zato.eq.16)then
11488     qash=3
11489     athreshold(1)=0.003063
11490     aweight(1)=0.125
11491     athreshold(2)=0.00034
11492     aweight(2)=0.5
11493     athreshold(3)=1.36129e-05
11494     aweight(3)=0.375
11495     endif
11496     if(zato.eq.17)then
11497     qash=3
11498     athreshold(1)=0.003485
11499     aweight(1)=0.117647
11500     athreshold(2)=0.000412
11501     aweight(2)=0.470588
11502     athreshold(3)=1.85286e-05
11503     aweight(3)=0.411765
11504     endif
11505     if(zato.eq.18)then
11506     qash=3
11507     athreshold(1)=0.003934
11508     aweight(1)=0.111111
11509     athreshold(2)=0.00049
11510     aweight(2)=0.444444
11511     athreshold(3)=2.42007e-05
11512     aweight(3)=0.444444
11513     endif
11514     if(zato.eq.19)then
11515     qash=4
11516     athreshold(1)=0.004411
11517     aweight(1)=0.105263
11518     athreshold(2)=0.000575
11519     aweight(2)=0.421053
11520     athreshold(3)=3.78135e-05
11521     aweight(3)=0.421053
11522     athreshold(4)=1e-05
11523     aweight(4)=0.052632
11524     endif
11525     if(zato.eq.20)then
11526     qash=4
11527     athreshold(1)=0.004914
11528     aweight(1)=0.1
11529     athreshold(2)=0.000667
11530     aweight(2)=0.4
11531     athreshold(3)=5.44515e-05
11532     aweight(3)=0.4
11533     athreshold(4)=1e-05
11534     aweight(4)=0.1
11535     endif
11536     if(zato.eq.21)then
11537     qash=4
11538     athreshold(1)=0.005445
11539     aweight(1)=0.095238
11540     athreshold(2)=0.000766
11541     aweight(2)=0.380952
11542     athreshold(3)=7.41145e-05
11543     aweight(3)=0.380952
11544     athreshold(4)=1e-05
11545     aweight(4)=0.142857
11546     endif
11547     if(zato.eq.22)then
11548     qash=4
11549     athreshold(1)=0.006003
11550     aweight(1)=0.090909
11551     athreshold(2)=0.000871
11552     aweight(2)=0.363636
11553     athreshold(3)=9.68026e-05
11554     aweight(3)=0.363636
11555     athreshold(4)=1e-05
11556     aweight(4)=0.181818
11557     endif
11558     if(zato.eq.23)then
11559     qash=4
11560     athreshold(1)=0.006589
11561     aweight(1)=0.086957
11562     athreshold(2)=0.000984
11563     aweight(2)=0.347826
11564     athreshold(3)=0.000123
11565     aweight(3)=0.347826
11566     athreshold(4)=1e-05
11567     aweight(4)=0.217391
11568     endif
11569     if(zato.eq.24)then
11570     qash=4
11571     athreshold(1)=0.007201
11572     aweight(1)=0.083333
11573     athreshold(2)=0.001103
11574     aweight(2)=0.333333
11575     athreshold(3)=0.000151
11576     aweight(3)=0.333333
11577     athreshold(4)=1e-05
11578     aweight(4)=0.25
11579     endif
11580     if(zato.eq.25)then
11581     qash=4
11582     athreshold(1)=0.007841
11583     aweight(1)=0.08
11584     athreshold(2)=0.001229
11585     aweight(2)=0.32
11586     athreshold(3)=0.000183
11587     aweight(3)=0.32
11588     athreshold(4)=1.04224e-05
11589     aweight(4)=0.28
11590     endif
11591     if(zato.eq.26)then
11592     qash=4
11593     athreshold(1)=0.008508
11594     aweight(1)=0.076923
11595     athreshold(2)=0.001361
11596     aweight(2)=0.307692
11597     athreshold(3)=0.000218
11598     aweight(3)=0.307692
11599     athreshold(4)=1.36129e-05
11600     aweight(4)=0.307692
11601     endif
11602     if(zato.eq.27)then
11603     qash=4
11604     athreshold(1)=0.009202
11605     aweight(1)=0.074074
11606     athreshold(2)=0.001501
11607     aweight(2)=0.296296
11608     athreshold(3)=0.000256
11609     aweight(3)=0.296296
11610     athreshold(4)=1.72288e-05
11611     aweight(4)=0.333333
11612     endif
11613     if(zato.eq.28)then
11614     qash=4
11615     athreshold(1)=0.009924
11616     aweight(1)=0.071429
11617     athreshold(2)=0.001647
11618     aweight(2)=0.285714
11619     athreshold(3)=0.000296
11620     aweight(3)=0.285714
11621     athreshold(4)=2.12701e-05
11622     aweight(4)=0.357143
11623     endif
11624     if(zato.eq.29)then
11625     qash=4
11626     athreshold(1)=0.010672
11627     aweight(1)=0.068966
11628     athreshold(2)=0.0018
11629     aweight(2)=0.275862
11630     athreshold(3)=0.00034
11631     aweight(3)=0.275862
11632     athreshold(4)=2.57368e-05
11633     aweight(4)=0.37931
11634     endif
11635     if(zato.eq.30)then
11636     qash=4
11637     athreshold(1)=0.011448
11638     aweight(1)=0.066667
11639     athreshold(2)=0.00196
11640     aweight(2)=0.266667
11641     athreshold(3)=0.000387
11642     aweight(3)=0.266667
11643     athreshold(4)=3.0629e-05
11644     aweight(4)=0.4
11645     endif
11646     if(zato.eq.31)then
11647     qash=4
11648     athreshold(1)=0.012252
11649     aweight(1)=0.064516
11650     athreshold(2)=0.002127
11651     aweight(2)=0.258065
11652     athreshold(3)=0.000437
11653     aweight(3)=0.258065
11654     athreshold(4)=3.59465e-05
11655     aweight(4)=0.419355
11656     endif
11657     if(zato.eq.32)then
11658     qash=4
11659     athreshold(1)=0.013082
11660     aweight(1)=0.0625
11661     athreshold(2)=0.002301
11662     aweight(2)=0.25
11663     athreshold(3)=0.00049
11664     aweight(3)=0.25
11665     athreshold(4)=4.16894e-05
11666     aweight(4)=0.4375
11667     endif
11668     if(zato.eq.33)then
11669     qash=4
11670     athreshold(1)=0.01394
11671     aweight(1)=0.060606
11672     athreshold(2)=0.002481
11673     aweight(2)=0.242424
11674     athreshold(3)=0.000546
11675     aweight(3)=0.242424
11676     athreshold(4)=4.78577e-05
11677     aweight(4)=0.454545
11678     endif
11679     if(zato.eq.34)then
11680     qash=4
11681     athreshold(1)=0.014824
11682     aweight(1)=0.058824
11683     athreshold(2)=0.002668
11684     aweight(2)=0.235294
11685     athreshold(3)=0.000605
11686     aweight(3)=0.235294
11687     athreshold(4)=5.44515e-05
11688     aweight(4)=0.470588
11689     endif
11690     if(zato.eq.35)then
11691     qash=4
11692     athreshold(1)=0.015736
11693     aweight(1)=0.057143
11694     athreshold(2)=0.002862
11695     aweight(2)=0.228571
11696     athreshold(3)=0.000667
11697     aweight(3)=0.228571
11698     athreshold(4)=6.14706e-05
11699     aweight(4)=0.485714
11700     endif
11701     if(zato.eq.36)then
11702     qash=4
11703     athreshold(1)=0.016676
11704     aweight(1)=0.055556
11705     athreshold(2)=0.003063
11706     aweight(2)=0.222222
11707     athreshold(3)=0.000732
11708     aweight(3)=0.222222
11709     athreshold(4)=6.89152e-05
11710     aweight(4)=0.5
11711     endif
11712     if(zato.eq.37)then
11713     qash=5
11714     athreshold(1)=0.017642
11715     aweight(1)=0.054054
11716     athreshold(2)=0.00327
11717     aweight(2)=0.216216
11718     athreshold(3)=0.0008
11719     aweight(3)=0.216216
11720     athreshold(4)=8.50804e-05
11721     aweight(4)=0.486486
11722     athreshold(5)=1e-05
11723     aweight(5)=0.027027
11724     endif
11725     if(zato.eq.38)then
11726     qash=5
11727     athreshold(1)=0.018636
11728     aweight(1)=0.052632
11729     athreshold(2)=0.003485
11730     aweight(2)=0.210526
11731     athreshold(3)=0.000871
11732     aweight(3)=0.210526
11733     athreshold(4)=0.000103
11734     aweight(4)=0.473684
11735     athreshold(5)=1e-05
11736     aweight(5)=0.052632
11737     endif
11738     if(zato.eq.39)then
11739     qash=5
11740     athreshold(1)=0.019657
11741     aweight(1)=0.051282
11742     athreshold(2)=0.003706
11743     aweight(2)=0.205128
11744     athreshold(3)=0.000945
11745     aweight(3)=0.205128
11746     athreshold(4)=0.000123
11747     aweight(4)=0.461538
11748     athreshold(5)=1e-05
11749     aweight(5)=0.076923
11750     endif
11751     if(zato.eq.40)then
11752     qash=5
11753     athreshold(1)=0.020705
11754     aweight(1)=0.05
11755     athreshold(2)=0.003934
11756     aweight(2)=0.2
11757     athreshold(3)=0.001022
11758     aweight(3)=0.2
11759     athreshold(4)=0.000144
11760     aweight(4)=0.45
11761     athreshold(5)=1e-05
11762     aweight(5)=0.1
11763     endif
11764     if(zato.eq.41)then
11765     qash=5
11766     athreshold(1)=0.021781
11767     aweight(1)=0.04878
11768     athreshold(2)=0.004169
11769     aweight(2)=0.195122
11770     athreshold(3)=0.001103
11771     aweight(3)=0.195122
11772     athreshold(4)=0.000167
11773     aweight(4)=0.439024
11774     athreshold(5)=1e-05
11775     aweight(5)=0.121951
11776     endif
11777     if(zato.eq.42)then
11778     qash=5
11779     athreshold(1)=0.022883
11780     aweight(1)=0.047619
11781     athreshold(2)=0.004411
11782     aweight(2)=0.190476
11783     athreshold(3)=0.001186
11784     aweight(3)=0.190476
11785     athreshold(4)=0.000191
11786     aweight(4)=0.428571
11787     athreshold(5)=1e-05
11788     aweight(5)=0.142857
11789     endif
11790     if(zato.eq.43)then
11791     qash=5
11792     athreshold(1)=0.024013
11793     aweight(1)=0.046512
11794     athreshold(2)=0.004659
11795     aweight(2)=0.186047
11796     athreshold(3)=0.001272
11797     aweight(3)=0.186047
11798     athreshold(4)=0.000218
11799     aweight(4)=0.418605
11800     athreshold(5)=1e-05
11801     aweight(5)=0.162791
11802     endif
11803     if(zato.eq.44)then
11804     qash=5
11805     athreshold(1)=0.02517
11806     aweight(1)=0.045455
11807     athreshold(2)=0.004914
11808     aweight(2)=0.181818
11809     athreshold(3)=0.001361
11810     aweight(3)=0.181818
11811     athreshold(4)=0.000246
11812     aweight(4)=0.409091
11813     athreshold(5)=1e-05
11814     aweight(5)=0.181818
11815     endif
11816     if(zato.eq.45)then
11817     qash=5
11818     athreshold(1)=0.026355
11819     aweight(1)=0.044444
11820     athreshold(2)=0.005176
11821     aweight(2)=0.177778
11822     athreshold(3)=0.001454
11823     aweight(3)=0.177778
11824     athreshold(4)=0.000276
11825     aweight(4)=0.4
11826     athreshold(5)=1.10264e-05
11827     aweight(5)=0.2
11828     endif
11829     if(zato.eq.46)then
11830     qash=5
11831     athreshold(1)=0.027566
11832     aweight(1)=0.043478
11833     athreshold(2)=0.005445
11834     aweight(2)=0.173913
11835     athreshold(3)=0.001549
11836     aweight(3)=0.173913
11837     athreshold(4)=0.000307
11838     aweight(4)=0.391304
11839     athreshold(5)=1.36129e-05
11840     aweight(5)=0.217391
11841     endif
11842     if(zato.eq.47)then
11843     qash=5
11844     athreshold(1)=0.028805
11845     aweight(1)=0.042553
11846     athreshold(2)=0.005721
11847     aweight(2)=0.170213
11848     athreshold(3)=0.001647
11849     aweight(3)=0.170213
11850     athreshold(4)=0.00034
11851     aweight(4)=0.382979
11852     athreshold(5)=1.64716e-05
11853     aweight(5)=0.234043
11854     endif
11855     if(zato.eq.48)then
11856     qash=5
11857     athreshold(1)=0.030071
11858     aweight(1)=0.041667
11859     athreshold(2)=0.006003
11860     aweight(2)=0.166667
11861     athreshold(3)=0.001748
11862     aweight(3)=0.166667
11863     athreshold(4)=0.000375
11864     aweight(4)=0.375
11865     athreshold(5)=1.96025e-05
11866     aweight(5)=0.25
11867     endif
11868     if(zato.eq.49)then
11869     qash=5
11870     athreshold(1)=0.031364
11871     aweight(1)=0.040816
11872     athreshold(2)=0.006293
11873     aweight(2)=0.163265
11874     athreshold(3)=0.001853
11875     aweight(3)=0.163265
11876     athreshold(4)=0.000412
11877     aweight(4)=0.367347
11878     athreshold(5)=2.30058e-05
11879     aweight(5)=0.265306
11880     endif
11881     if(zato.eq.50)then
11882     qash=5
11883     athreshold(1)=0.032685
11884     aweight(1)=0.04
11885     athreshold(2)=0.006589
11886     aweight(2)=0.16
11887     athreshold(3)=0.00196
11888     aweight(3)=0.16
11889     athreshold(4)=0.00045
11890     aweight(4)=0.36
11891     athreshold(5)=2.66812e-05
11892     aweight(5)=0.28
11893     endif
11894     if(zato.eq.51)then
11895     qash=5
11896     athreshold(1)=0.034032
11897     aweight(1)=0.039216
11898     athreshold(2)=0.006892
11899     aweight(2)=0.156863
11900     athreshold(3)=0.002071
11901     aweight(3)=0.156863
11902     athreshold(4)=0.00049
11903     aweight(4)=0.352941
11904     athreshold(5)=3.0629e-05
11905     aweight(5)=0.294118
11906     endif
11907     if(zato.eq.52)then
11908     qash=5
11909     athreshold(1)=0.035407
11910     aweight(1)=0.038462
11911     athreshold(2)=0.007201
11912     aweight(2)=0.153846
11913     athreshold(3)=0.002184
11914     aweight(3)=0.153846
11915     athreshold(4)=0.000532
11916     aweight(4)=0.346154
11917     athreshold(5)=3.48489e-05
11918     aweight(5)=0.307692
11919     endif
11920     if(zato.eq.53)then
11921     qash=5
11922     athreshold(1)=0.036809
11923     aweight(1)=0.037736
11924     athreshold(2)=0.007518
11925     aweight(2)=0.150943
11926     athreshold(3)=0.002301
11927     aweight(3)=0.150943
11928     athreshold(4)=0.000575
11929     aweight(4)=0.339623
11930     athreshold(5)=3.93412e-05
11931     aweight(5)=0.320755
11932     endif
11933     if(zato.eq.54)then
11934     qash=5
11935     athreshold(1)=0.038239
11936     aweight(1)=0.037037
11937     athreshold(2)=0.007841
11938     aweight(2)=0.148148
11939     athreshold(3)=0.00242
11940     aweight(3)=0.148148
11941     athreshold(4)=0.00062
11942     aweight(4)=0.333333
11943     athreshold(5)=4.41057e-05
11944     aweight(5)=0.333333
11945     endif
11946     if(zato.eq.55)then
11947     qash=5
11948     athreshold(1)=0.039695
11949     aweight(1)=0.036364
11950     athreshold(2)=0.008171
11951     aweight(2)=0.145455
11952     athreshold(3)=0.002543
11953     aweight(3)=0.145455
11954     athreshold(4)=0.000667
11955     aweight(4)=0.327273
11956     athreshold(5)=4.91425e-05
11957     aweight(5)=0.345455
11958     endif
11959     if(zato.eq.56)then
11960     qash=5
11961     athreshold(1)=0.041179
11962     aweight(1)=0.035714
11963     athreshold(2)=0.008508
11964     aweight(2)=0.142857
11965     athreshold(3)=0.002668
11966     aweight(3)=0.142857
11967     athreshold(4)=0.000716
11968     aweight(4)=0.321429
11969     athreshold(5)=5.44515e-05
11970     aweight(5)=0.357143
11971     endif
11972     if(zato.eq.57)then
11973     qash=5
11974     athreshold(1)=0.04269
11975     aweight(1)=0.035088
11976     athreshold(2)=0.008852
11977     aweight(2)=0.140351
11978     athreshold(3)=0.002797
11979     aweight(3)=0.140351
11980     athreshold(4)=0.000766
11981     aweight(4)=0.315789
11982     athreshold(5)=6.00328e-05
11983     aweight(5)=0.368421
11984     endif
11985     if(zato.eq.58)then
11986     qash=5
11987     athreshold(1)=0.044228
11988     aweight(1)=0.034483
11989     athreshold(2)=0.009202
11990     aweight(2)=0.137931
11991     athreshold(3)=0.002928
11992     aweight(3)=0.137931
11993     athreshold(4)=0.000818
11994     aweight(4)=0.310345
11995     athreshold(5)=6.58863e-05
11996     aweight(5)=0.37931
11997     endif
11998     if(zato.eq.59)then
11999     qash=6
12000     athreshold(1)=0.045794
12001     aweight(1)=0.033898
12002     athreshold(2)=0.00956
12003     aweight(2)=0.135593
12004     athreshold(3)=0.003063
12005     aweight(3)=0.135593
12006     athreshold(4)=0.000871
12007     aweight(4)=0.305085
12008     athreshold(5)=7.84101e-05
12009     aweight(5)=0.372881
12010     athreshold(6)=1e-05
12011     aweight(6)=0.016949
12012     endif
12013     if(zato.eq.60)then
12014     qash=6
12015     athreshold(1)=0.047386
12016     aweight(1)=0.033333
12017     athreshold(2)=0.009924
12018     aweight(2)=0.133333
12019     athreshold(3)=0.003201
12020     aweight(3)=0.133333
12021     athreshold(4)=0.000927
12022     aweight(4)=0.3
12023     athreshold(5)=9.2023e-05
12024     aweight(5)=0.366667
12025     athreshold(6)=1e-05
12026     aweight(6)=0.033333
12027     endif
12028     if(zato.eq.61)then
12029     qash=6
12030     athreshold(1)=0.049006
12031     aweight(1)=0.032787
12032     athreshold(2)=0.010295
12033     aweight(2)=0.131148
12034     athreshold(3)=0.003341
12035     aweight(3)=0.131148
12036     athreshold(4)=0.000984
12037     aweight(4)=0.295082
12038     athreshold(5)=0.000107
12039     aweight(5)=0.360656
12040     athreshold(6)=1e-05
12041     aweight(6)=0.04918
12042     endif
12043     if(zato.eq.62)then
12044     qash=6
12045     athreshold(1)=0.050653
12046     aweight(1)=0.032258
12047     athreshold(2)=0.010672
12048     aweight(2)=0.129032
12049     athreshold(3)=0.003485
12050     aweight(3)=0.129032
12051     athreshold(4)=0.001042
12052     aweight(4)=0.290323
12053     athreshold(5)=0.000123
12054     aweight(5)=0.354839
12055     athreshold(6)=1e-05
12056     aweight(6)=0.064516
12057     endif
12058     if(zato.eq.63)then
12059     qash=6
12060     athreshold(1)=0.052328
12061     aweight(1)=0.031746
12062     athreshold(2)=0.011057
12063     aweight(2)=0.126984
12064     athreshold(3)=0.003632
12065     aweight(3)=0.126984
12066     athreshold(4)=0.001103
12067     aweight(4)=0.285714
12068     athreshold(5)=0.000139
12069     aweight(5)=0.349206
12070     athreshold(6)=1e-05
12071     aweight(6)=0.079365
12072     endif
12073     if(zato.eq.64)then
12074     qash=6
12075     athreshold(1)=0.054029
12076     aweight(1)=0.03125
12077     athreshold(2)=0.011448
12078     aweight(2)=0.125
12079     athreshold(3)=0.003781
12080     aweight(3)=0.125
12081     athreshold(4)=0.001165
12082     aweight(4)=0.28125
12083     athreshold(5)=0.000157
12084     aweight(5)=0.34375
12085     athreshold(6)=1e-05
12086     aweight(6)=0.09375
12087     endif
12088     if(zato.eq.65)then
12089     qash=6
12090     athreshold(1)=0.055758
12091     aweight(1)=0.030769
12092     athreshold(2)=0.011847
12093     aweight(2)=0.123077
12094     athreshold(3)=0.003934
12095     aweight(3)=0.123077
12096     athreshold(4)=0.001229
12097     aweight(4)=0.276923
12098     athreshold(5)=0.000176
12099     aweight(5)=0.338462
12100     athreshold(6)=1e-05
12101     aweight(6)=0.107692
12102     endif
12103     if(zato.eq.66)then
12104     qash=6
12105     athreshold(1)=0.057514
12106     aweight(1)=0.030303
12107     athreshold(2)=0.012252
12108     aweight(2)=0.121212
12109     athreshold(3)=0.00409
12110     aweight(3)=0.121212
12111     athreshold(4)=0.001294
12112     aweight(4)=0.272727
12113     athreshold(5)=0.000197
12114     aweight(5)=0.333333
12115     athreshold(6)=1e-05
12116     aweight(6)=0.121212
12117     endif
12118     if(zato.eq.67)then
12119     qash=6
12120     athreshold(1)=0.059298
12121     aweight(1)=0.029851
12122     athreshold(2)=0.012663
12123     aweight(2)=0.119403
12124     athreshold(3)=0.004249
12125     aweight(3)=0.119403
12126     athreshold(4)=0.001361
12127     aweight(4)=0.268657
12128     athreshold(5)=0.000218
12129     aweight(5)=0.328358
12130     athreshold(6)=1e-05
12131     aweight(6)=0.134328
12132     endif
12133     if(zato.eq.68)then
12134     qash=6
12135     athreshold(1)=0.061108
12136     aweight(1)=0.029412
12137     athreshold(2)=0.013082
12138     aweight(2)=0.117647
12139     athreshold(3)=0.004411
12140     aweight(3)=0.117647
12141     athreshold(4)=0.00143
12142     aweight(4)=0.264706
12143     athreshold(5)=0.00024
12144     aweight(5)=0.323529
12145     athreshold(6)=1e-05
12146     aweight(6)=0.147059
12147     endif
12148     if(zato.eq.69)then
12149     qash=6
12150     athreshold(1)=0.062946
12151     aweight(1)=0.028986
12152     athreshold(2)=0.013507
12153     aweight(2)=0.115942
12154     athreshold(3)=0.004575
12155     aweight(3)=0.115942
12156     athreshold(4)=0.001501
12157     aweight(4)=0.26087
12158     athreshold(5)=0.000264
12159     aweight(5)=0.318841
12160     athreshold(6)=1.14386e-05
12161     aweight(6)=0.15942
12162     endif
12163     if(zato.eq.70)then
12164     qash=6
12165     athreshold(1)=0.064811
12166     aweight(1)=0.028571
12167     athreshold(2)=0.01394
12168     aweight(2)=0.114286
12169     athreshold(3)=0.004743
12170     aweight(3)=0.114286
12171     athreshold(4)=0.001573
12172     aweight(4)=0.257143
12173     athreshold(5)=0.000288
12174     aweight(5)=0.314286
12175     athreshold(6)=1.36129e-05
12176     aweight(6)=0.171429
12177     endif
12178     if(zato.eq.71)then
12179     qash=6
12180     athreshold(1)=0.066703
12181     aweight(1)=0.028169
12182     athreshold(2)=0.014379
12183     aweight(2)=0.112676
12184     athreshold(3)=0.004914
12185     aweight(3)=0.112676
12186     athreshold(4)=0.001647
12187     aweight(4)=0.253521
12188     athreshold(5)=0.000314
12189     aweight(5)=0.309859
12190     athreshold(6)=1.59762e-05
12191     aweight(6)=0.183099
12192     endif
12193     if(zato.eq.72)then
12194     qash=6
12195     athreshold(1)=0.068622
12196     aweight(1)=0.027778
12197     athreshold(2)=0.014824
12198     aweight(2)=0.111111
12199     athreshold(3)=0.005088
12200     aweight(3)=0.111111
12201     athreshold(4)=0.001723
12202     aweight(4)=0.25
12203     athreshold(5)=0.00034
12204     aweight(5)=0.305556
12205     athreshold(6)=1.85286e-05
12206     aweight(6)=0.194444
12207     endif
12208     if(zato.eq.73)then
12209     qash=6
12210     athreshold(1)=0.070569
12211     aweight(1)=0.027397
12212     athreshold(2)=0.015277
12213     aweight(2)=0.109589
12214     athreshold(3)=0.005265
12215     aweight(3)=0.109589
12216     athreshold(4)=0.0018
12217     aweight(4)=0.246575
12218     athreshold(5)=0.000368
12219     aweight(5)=0.30137
12220     athreshold(6)=2.12701e-05
12221     aweight(6)=0.205479
12222     endif
12223     if(zato.eq.74)then
12224     qash=6
12225     athreshold(1)=0.072543
12226     aweight(1)=0.027027
12227     athreshold(2)=0.015736
12228     aweight(2)=0.108108
12229     athreshold(3)=0.005445
12230     aweight(3)=0.108108
12231     athreshold(4)=0.001879
12232     aweight(4)=0.243243
12233     athreshold(5)=0.000397
12234     aweight(5)=0.297297
12235     athreshold(6)=2.42007e-05
12236     aweight(6)=0.216216
12237     endif
12238     if(zato.eq.75)then
12239     qash=6
12240     athreshold(1)=0.074544
12241     aweight(1)=0.026667
12242     athreshold(2)=0.016203
12243     aweight(2)=0.106667
12244     athreshold(3)=0.005628
12245     aweight(3)=0.106667
12246     athreshold(4)=0.00196
12247     aweight(4)=0.24
12248     athreshold(5)=0.000427
12249     aweight(5)=0.293333
12250     athreshold(6)=2.73203e-05
12251     aweight(6)=0.226667
12252     endif
12253     if(zato.eq.76)then
12254     qash=6
12255     athreshold(1)=0.076572
12256     aweight(1)=0.026316
12257     athreshold(2)=0.016676
12258     aweight(2)=0.105263
12259     athreshold(3)=0.005814
12260     aweight(3)=0.105263
12261     athreshold(4)=0.002043
12262     aweight(4)=0.236842
12263     athreshold(5)=0.000458
12264     aweight(5)=0.289474
12265     athreshold(6)=3.0629e-05
12266     aweight(6)=0.236842
12267     endif
12268     if(zato.eq.77)then
12269     qash=6
12270     athreshold(1)=0.078628
12271     aweight(1)=0.025974
12272     athreshold(2)=0.017156
12273     aweight(2)=0.103896
12274     athreshold(3)=0.006003
12275     aweight(3)=0.103896
12276     athreshold(4)=0.002127
12277     aweight(4)=0.233766
12278     athreshold(5)=0.00049
12279     aweight(5)=0.285714
12280     athreshold(6)=3.41267e-05
12281     aweight(6)=0.246753
12282     endif
12283     if(zato.eq.78)then
12284     qash=6
12285     athreshold(1)=0.080711
12286     aweight(1)=0.025641
12287     athreshold(2)=0.017642
12288     aweight(2)=0.102564
12289     athreshold(3)=0.006195
12290     aweight(3)=0.102564
12291     athreshold(4)=0.002213
12292     aweight(4)=0.230769
12293     athreshold(5)=0.000523
12294     aweight(5)=0.282051
12295     athreshold(6)=3.78135e-05
12296     aweight(6)=0.25641
12297     endif
12298     if(zato.eq.79)then
12299     qash=6
12300     athreshold(1)=0.082821
12301     aweight(1)=0.025316
12302     athreshold(2)=0.018136
12303     aweight(2)=0.101266
12304     athreshold(3)=0.00639
12305     aweight(3)=0.101266
12306     athreshold(4)=0.002301
12307     aweight(4)=0.227848
12308     athreshold(5)=0.000558
12309     aweight(5)=0.278481
12310     athreshold(6)=4.16894e-05
12311     aweight(6)=0.265823
12312     endif
12313     if(zato.eq.80)then
12314     qash=6
12315     athreshold(1)=0.084958
12316     aweight(1)=0.025
12317     athreshold(2)=0.018636
12318     aweight(2)=0.1
12319     athreshold(3)=0.006589
12320     aweight(3)=0.1
12321     athreshold(4)=0.00239
12322     aweight(4)=0.225
12323     athreshold(5)=0.000593
12324     aweight(5)=0.275
12325     athreshold(6)=4.57544e-05
12326     aweight(6)=0.275
12327     endif
12328     if(zato.eq.81)then
12329     qash=6
12330     athreshold(1)=0.087122
12331     aweight(1)=0.024691
12332     athreshold(2)=0.019143
12333     aweight(2)=0.098765
12334     athreshold(3)=0.00679
12335     aweight(3)=0.098765
12336     athreshold(4)=0.002481
12337     aweight(4)=0.222222
12338     athreshold(5)=0.000629
12339     aweight(5)=0.271605
12340     athreshold(6)=5.00084e-05
12341     aweight(6)=0.283951
12342     endif
12343     if(zato.eq.82)then
12344     qash=6
12345     athreshold(1)=0.089314
12346     aweight(1)=0.02439
12347     athreshold(2)=0.019657
12348     aweight(2)=0.097561
12349     athreshold(3)=0.006994
12350     aweight(3)=0.097561
12351     athreshold(4)=0.002574
12352     aweight(4)=0.219512
12353     athreshold(5)=0.000667
12354     aweight(5)=0.268293
12355     athreshold(6)=5.44515e-05
12356     aweight(6)=0.292683
12357     endif
12358     if(zato.eq.83)then
12359     qash=6
12360     athreshold(1)=0.091533
12361     aweight(1)=0.024096
12362     athreshold(2)=0.020178
12363     aweight(2)=0.096386
12364     athreshold(3)=0.007201
12365     aweight(3)=0.096386
12366     athreshold(4)=0.002668
12367     aweight(4)=0.216867
12368     athreshold(5)=0.000706
12369     aweight(5)=0.26506
12370     athreshold(6)=5.90836e-05
12371     aweight(6)=0.301205
12372     endif
12373     if(zato.eq.84)then
12374     qash=6
12375     athreshold(1)=0.093779
12376     aweight(1)=0.02381
12377     athreshold(2)=0.020705
12378     aweight(2)=0.095238
12379     athreshold(3)=0.007411
12380     aweight(3)=0.095238
12381     athreshold(4)=0.002764
12382     aweight(4)=0.214286
12383     athreshold(5)=0.000745
12384     aweight(5)=0.261905
12385     athreshold(6)=6.39049e-05
12386     aweight(6)=0.309524
12387     endif
12388     if(zato.eq.85)then
12389     qash=6
12390     athreshold(1)=0.096052
12391     aweight(1)=0.023529
12392     athreshold(2)=0.021239
12393     aweight(2)=0.094118
12394     athreshold(3)=0.007625
12395     aweight(3)=0.094118
12396     athreshold(4)=0.002862
12397     aweight(4)=0.211765
12398     athreshold(5)=0.000786
12399     aweight(5)=0.258824
12400     athreshold(6)=6.89152e-05
12401     aweight(6)=0.317647
12402     endif
12403     if(zato.eq.86)then
12404     qash=6
12405     athreshold(1)=0.098353
12406     aweight(1)=0.023256
12407     athreshold(2)=0.021781
12408     aweight(2)=0.093023
12409     athreshold(3)=0.007841
12410     aweight(3)=0.093023
12411     athreshold(4)=0.002962
12412     aweight(4)=0.209302
12413     athreshold(5)=0.000828
12414     aweight(5)=0.255814
12415     athreshold(6)=7.41145e-05
12416     aweight(6)=0.325581
12417     endif
12418     if(zato.eq.87)then
12419     qash=6
12420     athreshold(1)=0.100681
12421     aweight(1)=0.022989
12422     athreshold(2)=0.022329
12423     aweight(2)=0.091954
12424     athreshold(3)=0.00806
12425     aweight(3)=0.091954
12426     athreshold(4)=0.003063
12427     aweight(4)=0.206897
12428     athreshold(5)=0.000871
12429     aweight(5)=0.252874
12430     athreshold(6)=7.9503e-05
12431     aweight(6)=0.333333
12432     endif
12433     if(zato.eq.88)then
12434     qash=6
12435     athreshold(1)=0.103036
12436     aweight(1)=0.022727
12437     athreshold(2)=0.022883
12438     aweight(2)=0.090909
12439     athreshold(3)=0.008283
12440     aweight(3)=0.090909
12441     athreshold(4)=0.003166
12442     aweight(4)=0.204545
12443     athreshold(5)=0.000915
12444     aweight(5)=0.25
12445     athreshold(6)=8.50804e-05
12446     aweight(6)=0.340909
12447     endif
12448     if(zato.eq.89)then
12449     qash=6
12450     athreshold(1)=0.105418
12451     aweight(1)=0.022472
12452     athreshold(2)=0.023445
12453     aweight(2)=0.089888
12454     athreshold(3)=0.008508
12455     aweight(3)=0.089888
12456     athreshold(4)=0.00327
12457     aweight(4)=0.202247
12458     athreshold(5)=0.000961
12459     aweight(5)=0.247191
12460     athreshold(6)=9.0847e-05
12461     aweight(6)=0.348315
12462     endif
12463     if(zato.eq.90)then
12464     qash=6
12465     athreshold(1)=0.107828
12466     aweight(1)=0.022222
12467     athreshold(2)=0.024013
12468     aweight(2)=0.088889
12469     athreshold(3)=0.008736
12470     aweight(3)=0.088889
12471     athreshold(4)=0.003377
12472     aweight(4)=0.2
12473     athreshold(5)=0.001007
12474     aweight(5)=0.244444
12475     athreshold(6)=9.68026e-05
12476     aweight(6)=0.355556
12477     endif
12478     if(zato.eq.91)then
12479     qash=7
12480     athreshold(1)=0.110264
12481     aweight(1)=0.021978
12482     athreshold(2)=0.024588
12483     aweight(2)=0.087912
12484     athreshold(3)=0.008968
12485     aweight(3)=0.087912
12486     athreshold(4)=0.003485
12487     aweight(4)=0.197802
12488     athreshold(5)=0.001054
12489     aweight(5)=0.241758
12490     athreshold(6)=0.000109
12491     aweight(6)=0.351648
12492     athreshold(7)=1e-05
12493     aweight(7)=0.010989
12494     endif
12495     if(zato.eq.92)then
12496     qash=7
12497     athreshold(1)=0.112728
12498     aweight(1)=0.021739
12499     athreshold(2)=0.02517
12500     aweight(2)=0.086957
12501     athreshold(3)=0.009202
12502     aweight(3)=0.086957
12503     athreshold(4)=0.003595
12504     aweight(4)=0.195652
12505     athreshold(5)=0.001103
12506     aweight(5)=0.23913
12507     athreshold(6)=0.000123
12508     aweight(6)=0.347826
12509     athreshold(7)=1e-05
12510     aweight(7)=0.021739
12511     endif
12512     if(zato.eq.93)then
12513     qash=7
12514     athreshold(1)=0.115219
12515     aweight(1)=0.021505
12516     athreshold(2)=0.025759
12517     aweight(2)=0.086022
12518     athreshold(3)=0.00944
12519     aweight(3)=0.086022
12520     athreshold(4)=0.003706
12521     aweight(4)=0.193548
12522     athreshold(5)=0.001152
12523     aweight(5)=0.236559
12524     athreshold(6)=0.000137
12525     aweight(6)=0.344086
12526     athreshold(7)=1e-05
12527     aweight(7)=0.032258
12528     endif
12529     if(zato.eq.94)then
12530     qash=7
12531     athreshold(1)=0.117738
12532     aweight(1)=0.021277
12533     athreshold(2)=0.026355
12534     aweight(2)=0.085106
12535     athreshold(3)=0.00968
12536     aweight(3)=0.085106
12537     athreshold(4)=0.003819
12538     aweight(4)=0.191489
12539     athreshold(5)=0.001203
12540     aweight(5)=0.234043
12541     athreshold(6)=0.000151
12542     aweight(6)=0.340426
12543     athreshold(7)=1e-05
12544     aweight(7)=0.042553
12545     endif
12546     if(zato.eq.95)then
12547     qash=7
12548     athreshold(1)=0.120283
12549     aweight(1)=0.021053
12550     athreshold(2)=0.026957
12551     aweight(2)=0.084211
12552     athreshold(3)=0.009924
12553     aweight(3)=0.084211
12554     athreshold(4)=0.003934
12555     aweight(4)=0.189474
12556     athreshold(5)=0.001255
12557     aweight(5)=0.231579
12558     athreshold(6)=0.000167
12559     aweight(6)=0.336842
12560     athreshold(7)=1e-05
12561     aweight(7)=0.052632
12562     endif
12563     if(zato.eq.96)then
12564     qash=7
12565     athreshold(1)=0.122856
12566     aweight(1)=0.020833
12567     athreshold(2)=0.027566
12568     aweight(2)=0.083333
12569     athreshold(3)=0.01017
12570     aweight(3)=0.083333
12571     athreshold(4)=0.004051
12572     aweight(4)=0.1875
12573     athreshold(5)=0.001307
12574     aweight(5)=0.229167
12575     athreshold(6)=0.000183
12576     aweight(6)=0.333333
12577     athreshold(7)=1e-05
12578     aweight(7)=0.0625
12579     endif
12580     if(zato.eq.97)then
12581     qash=7
12582     athreshold(1)=0.125456
12583     aweight(1)=0.020619
12584     athreshold(2)=0.028182
12585     aweight(2)=0.082474
12586     athreshold(3)=0.01042
12587     aweight(3)=0.082474
12588     athreshold(4)=0.004169
12589     aweight(4)=0.185567
12590     athreshold(5)=0.001361
12591     aweight(5)=0.226804
12592     athreshold(6)=0.0002
12593     aweight(6)=0.329897
12594     athreshold(7)=1e-05
12595     aweight(7)=0.072165
12596     endif
12597     if(zato.eq.98)then
12598     qash=7
12599     athreshold(1)=0.128084
12600     aweight(1)=0.020408
12601     athreshold(2)=0.028805
12602     aweight(2)=0.081633
12603     athreshold(3)=0.010672
12604     aweight(3)=0.081633
12605     athreshold(4)=0.004289
12606     aweight(4)=0.183673
12607     athreshold(5)=0.001416
12608     aweight(5)=0.22449
12609     athreshold(6)=0.000218
12610     aweight(6)=0.326531
12611     athreshold(7)=1e-05
12612     aweight(7)=0.081633
12613     endif
12614     if(zato.eq.99)then
12615     qash=7
12616     athreshold(1)=0.130738
12617     aweight(1)=0.020202
12618     athreshold(2)=0.029434
12619     aweight(2)=0.080808
12620     athreshold(3)=0.010928
12621     aweight(3)=0.080808
12622     athreshold(4)=0.004411
12623     aweight(4)=0.181818
12624     athreshold(5)=0.001472
12625     aweight(5)=0.222222
12626     athreshold(6)=0.000236
12627     aweight(6)=0.323232
12628     athreshold(7)=1e-05
12629     aweight(7)=0.090909
12630     endif
12631     if(zato.eq.100)then
12632     qash=7
12633     athreshold(1)=0.13342
12634     aweight(1)=0.02
12635     athreshold(2)=0.030071
12636     aweight(2)=0.08
12637     athreshold(3)=0.011187
12638     aweight(3)=0.08
12639     athreshold(4)=0.004534
12640     aweight(4)=0.18
12641     athreshold(5)=0.00153
12642     aweight(5)=0.22
12643     athreshold(6)=0.000256
12644     aweight(6)=0.32
12645     athreshold(7)=1e-05
12646     aweight(7)=0.1
12647     endif
12648    
12649    
12650     c end of genetared code
12651    
12652    
12653     c call prishellfi
12654    
12655     end
12656    
12657    
12658     subroutine prishellfi
12659    
12660     implicit none
12661    
12662     c include 'GoEvent.inc'
12663     +SEQ,GoEvent.
12664     c include 'shellfi.inc'
12665     +SEQ,shellfi.
12666    
12667     integer i,j
12668    
12669     if(soo.eq.0)return
12670     write(oo,*)
12671     write(oo,*)' prishellfi:'
12672     write(oo,*)' zato=',zato,' qash=',qash
12673     do i=1,qash
12674     write(oo,*)' number of shell=',i
12675     write(oo,*)' aweight=',aweight(i),' athreshold=',athreshold(i),
12676     + ' qaener=',qaener(i)
12677     write(oo,*)' aener aphot'
12678     do j=1,qaener(i)
12679     write(oo,*)aener(j,i),aphot(j,i)
12680     enddo
12681     enddo
12682    
12683     end
12684    
12685     +DECK,line.
12686     c Package for integration and interpolation
12687     c of a function, defined by array.
12688    
12689    
12690     function glin_integ_ar(x,y,q,x1,x2,thresh)
12691     c
12692     c It makes the same work as lin_integ_ar
12693     c but at some conditions it interpolates no the line
12694     c but power function.
12695     c
12696    
12697     implicit none
12698     real glin_integ_ar
12699     real x(*),y(*),x1,x2,thresh
12700     integer q
12701    
12702     integer nr,nrr,n1,i
12703     real xt1,xt2
12704     real xr1,xr2
12705     real a,b
12706     real k,p
12707     real s
12708     s=0
12709     glin_integ_ar=0.0
12710     if(q.le.0)return
12711     if(x2.lt.x1 .or. x2.lt.x(1) .or. x1.gt.x(q))return
12712    
12713     if(x1.lt.x(1))then
12714     xt1=x(1)
12715     else
12716     xt1=x1
12717     endif
12718     do i=2,q
12719     if(x(i).gt.xt1)then
12720     n1=i
12721     goto 10
12722     endif
12723     enddo
12724     10 continue
12725     nr=n1-1
12726     if(x2.gt.x(q))then ! it is not necessary
12727     xt2=x(q)
12728     else
12729     xt2=x2
12730     endif
12731     xr2=xt1
12732     c write(6,*)' x1=',x1,' x2=',x2,' xt1=',xt1,' xt2=',xt2
12733     c write(6,*)' n1=',n1,' n2=',n2,' n1=',n1,' nr=',nr
12734     do nrr=nr,q-1
12735     if(x(nrr).gt.x2)go to 20
12736     xr1=xr2
12737     if(xt2.lt.x(nrr+1))then
12738     xr2=xt2
12739     else
12740     xr2=x(nrr+1)
12741     endif
12742     if(x(nrr).gt.500.0e-6.and.x(nrr).gt.2*thresh.and.
12743     + y(nrr+1).lt.y(nrr).and.y(nrr+1).gt.0.0)then
12744     p=dlog(dble(y(nrr))/y(nrr+1))/
12745     + dlog(dble(x(nrr+1))/x(nrr))
12746     k=y(nrr)*x(nrr)**p
12747     s=s+
12748     + k/(1-p)*(1.0/xr2**(p-1)-1.0/xr1**(p-1))
12749     c write(6,*)' nrr=',nrr,' p=',p,' k=',k,' s=',s
12750     else
12751     a = (y(nrr+1) - y(nrr))/(x(nrr+1) - x(nrr))
12752     b = y(nrr)
12753     s = s+
12754     + 0.5*a*(xr2*xr2 - xr1*xr1) + (b - a*x(nrr))*(xr2 - xr1)
12755     endif
12756     c write(6,*)' nrr=',nrr
12757     c write(6,*)' y(nrr)=',y(nrr),' y(nrr+1)=',y(nrr+1)
12758     c write(6,*)' xr1=',xr1,' xr2=',xr2
12759     c write(6,*)' x(nrr)=',x(nrr),' x(nrr+1)=',x(nrr+1)
12760     c write(6,*)' s=',s
12761     enddo
12762    
12763     20 glin_integ_ar=s
12764    
12765     end
12766    
12767     function lin_integ_ar(x,y,q,x1,x2)
12768    
12769     implicit none
12770     real lin_integ_ar
12771     real x(*),y(*),x1,x2
12772     integer q
12773    
12774     integer nr,nrr,n1,i
12775     real xt1,xt2
12776     real xr1,xr2
12777     real a,b
12778     real s
12779     s=0
12780     lin_integ_ar=0.0
12781     if(q.le.0)return
12782     if(x2.lt.x1 .or. x2.lt.x(1) .or. x1.gt.x(q))return
12783    
12784     if(x1.lt.x(1))then
12785     xt1=x(1)
12786     else
12787     xt1=x1
12788     endif
12789     do i=2,q
12790     if(x(i).gt.xt1)then
12791     n1=i
12792     goto 10
12793     endif
12794     enddo
12795     10 continue
12796     nr=n1-1
12797     if(x2.gt.x(q))then ! it is not necessary
12798     xt2=x(q)
12799     else
12800     xt2=x2
12801     endif
12802     xr2=xt1
12803     c write(6,*)' x1=',x1,' x2=',x2,' xt1=',xt1,' xt2=',xt2
12804     c write(6,*)' n1=',n1,' n2=',n2,' n1=',n1,' nr=',nr
12805     do nrr=nr,q-1
12806     if(x(nrr).gt.x2)go to 20
12807     xr1=xr2
12808     if(xt2.lt.x(nrr+1))then
12809     xr2=xt2
12810     else
12811     xr2=x(nrr+1)
12812     endif
12813     a = (y(nrr+1) - y(nrr))/(x(nrr+1) - x(nrr))
12814     b = y(nrr)
12815     s = s+
12816     + 0.5*a*(xr2*xr2 - xr1*xr1) + (b - a*x(nrr))*(xr2 - xr1)
12817     c write(6,*)' nrr=',nrr
12818     c write(6,*)' y(nrr)=',y(nrr),' y(nrr+1)=',y(nrr+1)
12819     c write(6,*)' xr1=',xr1,' xr2=',xr2
12820     c write(6,*)' x(nrr)=',x(nrr),' x(nrr+1)=',x(nrr+1)
12821     c write(6,*)' s=',s
12822     enddo
12823    
12824     20 lin_integ_ar=s
12825    
12826     end
12827    
12828    
12829     function step_integ_ar(x,y,q,x1,x2)
12830     c
12831     c dimension of y must be q
12832     c dimension of x must be q+1
12833     c the last point means the end of last interval.
12834     c
12835     implicit none
12836     real step_integ_ar
12837     real x(*),y(*),x1,x2
12838     integer q
12839    
12840     integer nr,nrr,n1,i
12841     real xt1,xt2
12842     real xr1,xr2
12843     c real a,b
12844     real s
12845     s=0
12846     step_integ_ar=0.0
12847     c write(6,*)' step:',q,x1,x2,x(1),x(q+1)
12848     if(q.le.0)return
12849     if(x2.lt.x1 .or. x2.lt.x(1) .or. x1.gt.x(q+1))return
12850    
12851     if(x1.lt.x(1))then
12852     xt1=x(1)
12853     else
12854     xt1=x1
12855     endif
12856     do i=2,q+1
12857     if(x(i).gt.xt1)then
12858     n1=i
12859     goto 10
12860     endif
12861     enddo
12862     10 continue
12863     nr=n1-1
12864     if(x2.gt.x(q+1))then ! it is not necessary
12865     xt2=x(q+1)
12866     else
12867     xt2=x2
12868     endif
12869     xr2=xt1
12870    
12871    
12872     do nrr=nr,q
12873     if(x(nrr).gt.x2)go to 20
12874    
12875     xr1=xr2
12876     if(xt2.lt.x(nrr+1))then
12877     xr2=xt2
12878     else
12879     xr2=x(nrr+1)
12880     endif
12881     s = s+ y(nrr)*(xr2-xr1)
12882    
12883     c write(6,*)' nrr=',nrr,' xr=',xr1,xr2
12884     c write(6,*)' y(nrr)=',y(nrr),' s=',s
12885    
12886     enddo
12887    
12888     20 step_integ_ar=s
12889    
12890    
12891     end
12892    
12893     function interp_line_arr(x,y,q,tr,x0)
12894     c
12895     c special code
12896     c If x0<tr => 0
12897     c If tr<x0<x(1) linear interp.
12898     c If x0>x(q) exponential interp., if it go down
12899     c
12900    
12901     implicit none
12902    
12903     real interp_line_arr
12904     integer q ! quantity of elements
12905     real x(*) ! abscissa
12906     real y(*) ! ordin.
12907     real tr ! low treshold
12908     real x0 ! point
12909    
12910     integer n,n1,n2
12911     real p,k
12912     real s
12913    
12914     if(x0.lt.tr)then
12915     interp_line_arr=0.0
12916     return
12917     endif
12918    
12919     if(x0.gt.x(q))then
12920     if(y(q-1).le.y(q))then
12921     interp_line_arr=0.0
12922     return
12923     endif
12924     p = alog(y(q-1)/y(q)) / alog(x(q-1)/x(q))
12925     k = y(q) / (x(q)**p)
12926     s = k * (x0 ** p)
12927     interp_line_arr = s
12928     return
12929     endif
12930    
12931     do n=2,q
12932     if(x0.le.x(n))then
12933     n1=n-1
12934     go to 10
12935     endif
12936     enddo
12937     10 n2=n1+1
12938    
12939     k = (y(n2)-y(n1)) / (x(n2)-x(n1))
12940     s = y(n1) + k * ( x0-x(n1))
12941     interp_line_arr = s
12942     c write(6,*)' n1,n2=',n1,n2
12943     c write(6,*)' x=',x(n1),x(n2)
12944     c write(6,*)' y=',y(n1),y(n2)
12945     c write(6,*)' k,s=',k,s
12946     c stop
12947     return
12948    
12949     end
12950    
12951     function interp_linep_arr(x,y,q,tr,x0)
12952     c
12953     c special code
12954     c If x0<tr => 0
12955     c If tr<x0<x(1) linear interp.
12956     c If x0>x(q) exponential interp., if it go down
12957     c If x(i+1).lt.x(i) then power line
12958     c
12959    
12960     implicit none
12961    
12962     real interp_linep_arr
12963     integer q ! quantity of elements
12964     real x(*) ! abscissa
12965     real y(*) ! ordin.
12966     real tr ! low treshold
12967     real x0 ! point
12968    
12969     integer n,n1,n2
12970     real p,k
12971     real s
12972    
12973     if(x0.lt.tr)then
12974     interp_linep_arr=0.0
12975     return
12976     endif
12977    
12978     if(x0.gt.x(q))then
12979     * if(y(q-1).le.y(q))then
12980     * interp_linep_arr=0.0
12981     * return
12982     * endif
12983     * p = alog(y(q-1)/y(q)) / alog(x(q-1)/x(q))
12984     p=-3.22
12985     k = y(q) / (x(q)**p)
12986     s = k * (x0 ** p)
12987     interp_linep_arr = s
12988     return
12989     endif
12990    
12991     do n=2,q
12992     if(x0.le.x(n))then
12993     n1=n-1
12994     go to 10
12995     endif
12996     enddo
12997     10 n2=n1+1
12998    
12999     if(y(n2).ge.y(n1))then
13000     k = (y(n2)-y(n1)) / (x(n2)-x(n1))
13001     s = y(n1) + k * ( x0-x(n1))
13002     else
13003     p = alog(y(n1)/y(n2)) / alog(x(n1)/x(n2))
13004     k = y(n1) / (x(n1)**p)
13005     s = k * (x0 ** p)
13006     endif
13007     interp_linep_arr = s
13008     c write(6,*)' n1,n2=',n1,n2
13009     c write(6,*)' x=',x(n1),x(n2)
13010     c write(6,*)' y=',y(n1),y(n2)
13011     c write(6,*)' p,k,s=',p,k,s
13012     c stop
13013     return
13014    
13015     end
13016     +DECK,IniMatte.
13017    
13018     subroutine IniMatter(num,Atom,Weight,q,dens,pw,pf)
13019     c
13020     c Initialization of the Matter
13021     c
13022     implicit none
13023    
13024     c include 'GoEvent.inc'
13025     +SEQ,GoEvent.
13026     c include 'cconst.inc'
13027     +SEQ,cconst.
13028     c include 'ener.inc'
13029     +SEQ,ener.
13030     c include 'atoms.inc'
13031     +SEQ,atoms.
13032     c include 'matters.inc'
13033     +SEQ,matters.
13034    
13035     integer num,Atom(*),q
13036     real Weight(*),dens,pw,pf
13037    
13038     integer nat,nsh,nen,i,j
13039     real rms,rm(pQAt)
13040     real sw,ph,ph1
13041     real E,E2,S,EE1,EE2,EP1,EP2
13042    
13043    
13044     if(num.le.0.or.num.gt.pQMat)then
13045     write(oo,*)' Error in IniMatter: Wrong matter number',num
13046     if(sret_err.eq.0) stop
13047     s_err=1
13048     return
13049     endif
13050     if(QAtMat(num).gt.0)then
13051     write(oo,*)' Error in IniMatter: matter number',num,
13052     + ' is initialized already'
13053     if(sret_err.eq.0) stop
13054     s_err=1
13055     return
13056     endif
13057     if(q.le.0)then
13058     write(oo,*)' Error in IniMatter: empty list of atoms',
13059     + ' for matter number ',num
13060     if(sret_err.eq.0) stop
13061     s_err=1
13062     return
13063     endif
13064     QAtMat(num)=q
13065     sw=0.0
13066     if(q.eq.1)then
13067     Weight(1)=1.0
13068     endif
13069     do nat=1,q
13070    
13071     if(Zat(Atom(nat)).le.0)then
13072     write(oo,*)' Error in IniMatter: Atom number',
13073     + nat,' is not initialized'
13074     if(sret_err.eq.0) stop
13075     s_err=1
13076     return
13077     endif
13078     if(Weight(nat).lt.0.0)then
13079     write(oo,*)' Error in IniMatter: Weight is negative'
13080     if(sret_err.eq.0) stop
13081     s_err=1
13082     return
13083     endif
13084    
13085     AtMat(nat,num)=Atom(nat)
13086     WeightAtMat(nat,num)=Weight(nat)
13087     sw=sw+Weight(nat)
13088     enddo
13089    
13090    
13091     do nat=1,q
13092     WeightAtMat(nat,num)=WeightAtMat(nat,num)/sw
13093     enddo
13094     A_Mean(num)=0.0
13095     Z_Mean(num)=0.0
13096     do nat=1,q
13097     A_Mean(num)=A_Mean(num)+Aat(Atom(nat))*WeightAtMat(nat,num)
13098     Z_Mean(num)=Z_Mean(num)+Zat(Atom(nat))*WeightAtMat(nat,num)
13099     enddo
13100    
13101     DensMat(num)=dens
13102    
13103     DensMatDL(num)=DensMat(num)
13104     DensMatDS(num)=DensMat(num) ! if it is not equal
13105     ! than the multiple scatering of the
13106     ! insident particle will be calculated wrongly
13107     c DensMatDS(num)=0.2*DensMat(num)
13108    
13109     Pressure(num)=Cur_Pressure ! It is never used, only for printing
13110    
13111     WWW(num)=pw
13112     FFF(num)=pf
13113    
13114    
13115     do nen=1,qener
13116     ph=0.0
13117     do nat=1,q
13118     ph1=0.0
13119     do nsh=1,QShellAt(Atom(nat))
13120     ph1=ph1+PhotAt(nen,nsh,Atom(nat))
13121     enddo
13122     ph=ph+ph1*WeightAtMat(nat,num)
13123     enddo
13124     PhotMat(nen,num)=ph
13125     enddo
13126    
13127     do nen=1,qener ! the same but with ionization potential
13128     ph=0.0
13129     do nat=1,q
13130     ph1=0.0
13131     do nsh=1,QShellAt(Atom(nat))
13132     ph1=ph1+PhotIonAt(nen,nsh,Atom(nat))
13133     enddo
13134     ph=ph+ph1*WeightAtMat(nat,num)
13135     enddo
13136     PhotIonMat(nen,num)=ph
13137     enddo
13138    
13139     ElDensMat(num)=Z_Mean(num)/A_Mean(num)*AVOGADRO*DensMat(num)/
13140     + ((5.07**3)*1.0e30)
13141     XElDensMat(num)=ElDensMat(num)*5.07e10
13142     wplaMat(num)=ElDensMat(num)*4.0*PI/(ELMAS*FSCON)
13143    
13144     RLenMat(num)=0.0
13145     rms=0.0
13146     do nat=1,QAtMat(num)
13147     rms=rms+Aat(AtMat(nat,num))*WeightAtMat(nat,num)
13148     enddo
13149     do nat=1,QAtMat(num)
13150     rm(nat)=Aat(AtMat(nat,num))*WeightAtMat(nat,num)/rms
13151     enddo
13152     c write(oo,*)' rm(1)=',rm(1)
13153     do nat=1,QAtMat(num)
13154     RLenMat(num)=RLenMat(num)+rm(nat)/RLenAt(AtMat(nat,num))
13155     enddo
13156     RLenMat(num)=1.0/(DensMatDS(num)*RLenMat(num))
13157     c RLenMat(num)=1.0/RLenMat(num)
13158    
13159     RuthMat(num)=0.0
13160     do nat=1,QAtMat(num)
13161     RuthMat(num)=RuthMat(num)+
13162     + WeightAtMat(nat,num)*RuthAt(AtMat(nat,num))
13163     enddo
13164     RuthMat(num)=RuthMat(num)*DensMatDS(num)*AVOGADRO/A_Mean(num)
13165    
13166    
13167     DO nen=1,qener
13168     epsi2(nen,num)=
13169     + (PhotMat(nen,num)/enerc(nen))*ElDensMat(num)/Z_Mean(num)
13170     enddo
13171    
13172     min_ioniz_pot(num)=1.0e30
13173     do nat=1,QAtMat(num)
13174     do nsh=1,QShellAt(Atom(nat))
13175     if(min_ioniz_pot(num).gt.ThresholdAt(nsh,Atom(nat)))then
13176     min_ioniz_pot(num)=ThresholdAt(nsh,Atom(nat))
13177     endif
13178     enddo
13179     enddo
13180    
13181     do i=1,qener
13182     E=ENERC(I)
13183     E2=E*E
13184     EPSIP(I,num)=-WPLAMat(num)/E2
13185     S=0.0
13186     do j=1,qener
13187    
13188     IF(J.NE.I)THEN
13189     S=S+EPSI2(J,num)*ENERC(J)*(ENER(J+1)-ENER(J))/
13190     + (ENERC(J)*ENERC(J)-E2)
13191     ELSE
13192     EE1=(ENER(J)+ENERC(J))/2.0
13193     EE2=(ENER(J+1)+ENERC(J))/2.0
13194     IF(J.GT.1)THEN
13195     EP1=EPSI2(J-1,num)+(EE1-ENERC(J-1))*
13196     + (EPSI2(J,num)-EPSI2(J-1,num))/
13197     + (ENERC(J)-ENERC(J-1))
13198     ELSE
13199     EP1=EPSI2(J,num)+(EE1-ENERC(J))*
13200     + (EPSI2(J+1,num)-EPSI2(J,num))/
13201     + (ENERC(J+1)-ENERC(J))
13202     END IF
13203     IF(J.LT.qener)THEN
13204     EP2=EPSI2(J,num)+(EE2-ENERC(J))*
13205     + (EPSI2(J+1,num)-EPSI2(J,num))/
13206     + (ENERC(J+1)-ENERC(J))
13207     ELSE
13208     EP2=EPSI2(J,num)+(EE2-ENERC(J))*
13209     + (EPSI2(J,num)-EPSI2(J-1,num))/
13210     + (ENERC(J)-ENERC(J-1))
13211     END IF
13212     S=S+EP1*EE1*(ENERC(J)-ENER(J))/
13213     + (EE1*EE1-E2)
13214     S=S+EP2*EE2*(ENER(J+1)-ENERC(J))/
13215     + (EE2*EE2-E2)
13216     END IF
13217     epsi1(i,num)=(2.0/PI)*S
13218     enddo
13219     enddo
13220    
13221     end
13222     +DECK,PRIMATT.
13223     subroutine PriMatter(p)
13224    
13225    
13226     implicit none
13227    
13228     integer p ! p = 0,1 short output
13229     ! p >= 2 long output
13230    
13231     c include 'GoEvent.inc'
13232     +SEQ,GoEvent.
13233     c include 'ener.inc'
13234     +SEQ,ener.
13235     c include 'atoms.inc'
13236     +SEQ,atoms.
13237     c include 'matters.inc'
13238     +SEQ,matters.
13239    
13240     integer nat
13241    
13242     integer nmat,nen
13243    
13244     if(soo.eq.0)return
13245     write(oo,*)
13246     write(oo,*)' PriMatter:'
13247     do nmat=1,pQMat
13248     if(qAtMat(nmat).gt.0)then
13249     write(oo,*)' matter number ',nmat, ' qAtMat=',qAtMat(nmat)
13250     do nat=1,qAtMat(nmat)
13251     write(oo,*)' number of atom is ',AtMat(nat,nmat),
13252     + ' weight=', WeightAtMat(nat,nmat)
13253     enddo
13254     write(oo,*)' A_Mean=',A_Mean(nmat),' Z_mean=',Z_Mean(nmat)
13255     write(oo,*)' DensMat=',DensMat(nmat),
13256     + ' ElDensMat=',ElDensMat(nmat),
13257     + ' XElDensMat=',XElDensMat(nmat)
13258     write(oo,*)' wplaMat=',wplaMat(nmat)
13259     write(oo,*)' plasm energy(sqrt(wplaMat))=',sqrt(wplaMat(nmat))
13260     write(oo,*)' RLenMat=',RLenMat(nmat)
13261     write(oo,*)' RuthMat=',RuthMat(nmat)
13262     write(oo,*)' min_ioniz_pot=',min_ioniz_pot(nmat)
13263     write(oo,*)' Pressure=',Pressure(nmat)
13264     write(oo,*)' WWW=',WWW(nmat),' FFF=',FFF(nmat)
13265     if(p.ge.2)then
13266     write(oo,*)' enerc PhotMat PhotIonMat epsip ',
13267     + ' epsi1 epsi2'
13268     do nen=1,qener
13269     write(oo,'(6E10.3)')enerc(nen),
13270     + PhotMat(nen,nmat),PhotIonMat(nen,nmat),epsip(nen,nmat),
13271     + epsi1(nen,nmat),epsi2(nen,nmat)
13272     enddo ! nen=1,qener
13273     endif
13274     endif ! if(qAtMat(nmat).gt.0)
13275     enddo ! nmat=1,pQMat
13276    
13277     end
13278     +DECK,GRAPHMAT,IF=NEVER.
13279     subroutine GraphMatter(num)
13280     c
13281     c input the data for showing the graphic by PAW
13282     c
13283     implicit none
13284    
13285     c include 'GoEvent.inc'
13286     +SEQ,GoEvent.
13287     c include 'cconst.inc'
13288     +SEQ,cconst.
13289     c include 'ener.inc'
13290     +SEQ,ener.
13291     c include 'atoms.inc'
13292     +SEQ,atoms.
13293     c include 'matters.inc'
13294     +SEQ,matters.
13295    
13296     integer num
13297     integer k,n
13298     real r
13299     real s
13300     c Calc. coef for going from 10**-18 sm**2 to Mev-2
13301     s=1.e-18 * 5.07e10 * 5.07e10
13302    
13303     n=0
13304     open(2,file='matter.grp')
13305     do k=1,qener
13306     if(PhotMat(k,num).gt.0.0)then
13307     c write(2,'(E10.3)')enerc(k)
13308     n=n+1
13309     endif
13310     enddo
13311     do k=1,qener
13312     if(PhotMat(k,num).gt.0.0)then
13313     c r=PhotMat(k,num)*ElDensMat(num)/Z_Mean(num)*5.07E10
13314     c r=1/r
13315     c r=r/DensMat(num)
13316     c write(2,'(2E10.3)')r
13317     c write(2,'(2E10.3)')enerc(k)*1.e6,r
13318     c write(2,'(2E10.3)')enerc(k),alog(r)
13319     write(2,*)enerc(k)*1.0e6, PhotMat(k,num)/s
13320     endif
13321     enddo
13322     close(2)
13323     write(oo,*)' GraphMatter: ',
13324     + 'file matter.grp is writen,n=',n
13325    
13326     end
13327     +DECK,gasdens.
13328     function gasdens(A,Weight,q)
13329     c
13330     c Calc. gas density
13331     c
13332     implicit none
13333    
13334     c include 'GoEvent.inc'
13335     +SEQ,GoEvent.
13336     c include 'ener.inc'
13337     +SEQ,ener.
13338     c include 'atoms.inc'
13339     +SEQ,atoms.
13340     c include 'matters.inc'
13341     +SEQ,matters.
13342    
13343     real gasdens,A(*),Weight(*)
13344     integer q
13345     real powat
13346     real temp
13347     real ridberg
13348     real d,s
13349     integer i
13350     c powat=101325.0
13351     c powat=Cur_Pressure
13352     *** Ensure that an initial value is set (RV 12/2/97)
13353     gasdens=-1
13354     *** End of modification.
13355     if(Cur_Pressure.le.0 .or. Cur_Temper.le.0)then
13356     write(oo,*) ' error in gasdens: negative or',
13357     + ' zero Cur_Pressure or Cur_Temper'
13358     write(oo,*)' Cur_Pressure=',Cur_Pressure
13359     write(oo,*)' Cur_Temper=',Cur_Temper
13360     if(sret_err.eq.0) stop
13361     s_err=1
13362     return
13363     endif
13364     if(q.le.0)then
13365     write(oo,*)' error in gasdens: q<=0'
13366     write(oo,*)' q=',q
13367     if(sret_err.eq.0) stop
13368     s_err=1
13369     return
13370     endif
13371     do i=1,q
13372     if(A(i).le.0 .or. Weight(i).le.0)then
13373     write(oo,*) ' error in gasdens: negative or',
13374     + ' zero A or Weight'
13375     write(oo,*)' i=',i
13376     write(oo,*)' A(i)=',A(i)
13377     write(oo,*)' Weight(i)=',Weight(i)
13378     if(sret_err.eq.0) stop
13379     s_err=1
13380     return
13381     endif
13382     enddo
13383    
13384    
13385     powat=101325.0/760 * Cur_Pressure
13386     c temp=293
13387     temp=Cur_Temper
13388     ridberg=8.314
13389     d=0
13390     do i=1,q
13391     d=d+Weight(i)
13392     enddo
13393     s=0
13394     do i=1,q
13395     s=s+A(i)*Weight(i)
13396     enddo
13397     s=s*powat/(ridberg*temp*d)
13398     s=s*1.e-3*1.e-3
13399     gasdens=s
13400     return
13401     end
13402     +DECK,IniVolum.
13403     subroutine IniFVolume(up,nmat,sSens,sIon,cwall1,cwide)
13404     c
13405     c Init. first volume
13406     c
13407     implicit none
13408     integer up,nmat,sSens,sIon
13409     c integer sTran
13410     real cwall1,cwide
13411     c include 'volume.inc'
13412     +SEQ,volume.
13413    
13414     qvol=0
13415     RLenRAVol=0.0
13416     call IniVolume(up,nmat,sSens,sIon,cwall1,cwall1+cwide,cwide)
13417    
13418     end
13419    
13420     subroutine IniNVolume(up,nmat,sSens,sIon,cwide)
13421     c
13422     c Init. next (not the first) volume
13423     c
13424     implicit none
13425     integer up,nmat,sSens,sIon
13426     c integer sTran
13427     real cwall1,cwide
13428    
13429     c include 'volume.inc'
13430     +SEQ,volume.
13431    
13432     cwall1=wall2(qvol)
13433    
13434     call IniVolume(up,nmat,sSens,sIon,cwall1,cwall1+cwide,cwide)
13435    
13436     end
13437    
13438    
13439     subroutine IniVolume(up,nmat,sSens,sIoni,cwall1,cwall2,cwide)
13440     c
13441     c Init. any volume
13442     c
13443     implicit none
13444    
13445     c include 'GoEvent.inc'
13446     +SEQ,GoEvent.
13447     c include 'volume.inc'
13448     +SEQ,volume.
13449     c include 'ener.inc'
13450     +SEQ,ener.
13451     c include 'atoms.inc'
13452     +SEQ,atoms.
13453     c include 'matters.inc'
13454     +SEQ,matters.
13455    
13456     integer up,nmat,sSens,sIoni
13457     c integer sTran
13458     real cwall1,cwall2,cwide
13459    
13460    
13461     if(qvol.ge.pqvol)then
13462     write(oo,*)' Error in IniVolume: memory is over'
13463     stop
13464     endif
13465     if(qvol.eq.0)then
13466     QSVol=0
13467     QIVol=0
13468     endif
13469     qvol=qvol+1
13470     if(nmat.eq.0.and.sSens.eq.1)then
13471     write(oo,*)' Error in IniVolume: nmat=0 and sSens =1',
13472     + ' simultaniously'
13473     stop
13474     endif
13475     if(sIoni.eq.0.and.sSens.eq.1)then
13476     write(oo,*)' Error in IniVolume: sIoni=0 and sSens =1',
13477     + ' simultaniously'
13478     stop
13479     endif
13480     if(nmat.ne.0)then
13481     if(qAtMat(nmat).eq.0)then
13482     write(oo,*)' Error in IniVolume: matter number',nmat,
13483     + ' is not initialized yet'
13484     stop
13485     endif
13486     endif
13487    
13488     upVol(qvol)=up
13489     nMatVol(qvol)=nmat
13490     sSensit(qvol)=sSens
13491     sIonizat(qvol)=sIoni
13492     if(sSens.ne.0)then
13493     QSVol=QSVol+1
13494     if(QSVol.gt.pQSVol)then
13495     write(oo,*)' Error in IniVolume: too much sens. volumes'
13496     stop
13497     endif
13498     numVolSens(QSVol)=qvol
13499     numSensVol(qvol)=QSVol
13500     else
13501     numSensVol(qvol)=0
13502     endif
13503     if(sIoni.ne.0)then
13504     QIVol=QIVol+1
13505     if(QIVol.gt.pQIVol)then
13506     write(oo,*)' Error in IniVolume: too much ioniz. volumes'
13507     stop
13508     endif
13509     numVolIoni(QIVol)=qvol
13510     numIoniVol(qvol)=QIVol
13511     else
13512     numIoniVol(qvol)=0
13513     endif
13514    
13515     if(qvol.eq.1)then
13516     wall1(qvol)=cwall1
13517     else
13518     wall1(qvol)=wall2(qvol-1)
13519     endif
13520     wide(qvol)=cwide
13521     if(wide(qvol).le.0.0)then
13522     write(oo,*)' Error in IniVolume: wide is negative or zero'
13523     stop
13524     endif
13525     wall2(qvol)=wall1(qvol)+wide(qvol)
13526    
13527     c wall2(qvol)=cwall2
13528     c if(qvol.eq.1)then
13529     c wall1(qvol)=cwall1
13530     c else
13531     c wall1(qvol)=wall2(qvol-1)
13532     c endif
13533     c wide(qvol)=wall2(qvol)-wall1(qvol)
13534     c if(wide(qvol).le.0.0)then
13535     c write(oo,*)' Error in IniVolume: wide is negative or zero'
13536     c stop
13537     c endif
13538    
13539     if(nmat.gt.0)then
13540     RLenRVol(qvol)=wide(qvol)/RLenMat(nmat)
13541     RLenRAVol=RLenRAVol+RLenRVol(qvol)
13542     endif
13543    
13544     end
13545     +DECK,VOLPATHL.
13546     subroutine VolPathLeng(zcoor,veloc, num, mleng)
13547    
13548     c Find path leng in the current mat
13549     c zcoor - z coordinate
13550     c num - number of volume
13551     c veloc - velocity(cosine)
13552    
13553     implicit none
13554    
13555     c include 'volume.inc'
13556     +SEQ,volume.
13557    
13558     real veloc(3)
13559     real*8 zcoor,mleng
13560     real*8 z
13561     integer num
13562    
13563     c write(oo,*)' zcoor=',zcoor
13564     c write(oo,*)' veloc=',veloc
13565     c write(oo,*)' num=',num
13566     z=zcoor
13567     if(veloc(3).eq.0.0)then
13568     mleng=1.e30
13569     else if(veloc(3).gt.0.0)then
13570     mleng=(wall2(num)-z)/veloc(3)
13571     else
13572     mleng=(wall1(num)-z)/veloc(3)
13573     endif
13574    
13575     end
13576     +DECK,VOLNUMZC.
13577     subroutine VolNumZcoor(zcoor,veloc,num)
13578    
13579     c Find number of material for this coor.
13580     c zcoor - z coordinate
13581     c veloc - z velocity
13582     c num - number of volume
13583     c if(num.ne.0) particle go to next lay
13584     c correspodently with its velocity
13585     c if without of vol, returns 0
13586     c if num!=0 at call, go to next mat.
13587    
13588     implicit none
13589    
13590     c include 'volume.inc'
13591     +SEQ,volume.
13592    
13593     real veloc
13594     real*8 zcoor
13595     integer num
13596     integer i
13597    
13598     if(num.ne.0)then
13599     if(veloc.gt.0)then
13600     if(num.lt.qvol)then
13601     num=num+1
13602     return
13603     else
13604     num=0
13605     return
13606     endif
13607     else
13608     if(num.gt.1)then
13609     num=num-1
13610     return
13611     else
13612     num=0
13613     return
13614     endif
13615     endif
13616     endif
13617    
13618     num=0
13619     if(zcoor.lt.wall1(1))then
13620     return
13621     else
13622     if(zcoor.eq.wall1(1))then
13623     if(veloc.gt.0)then
13624     num=1
13625     else
13626     num=0
13627     endif
13628     return
13629     endif
13630     endif
13631     do i=1,qvol
13632     if(zcoor.lt.wall2(i))then
13633     num=i
13634     return
13635     elseif(zcoor.eq.wall2(i))then
13636     if(veloc.gt.0)then
13637     if(i.lt.qvol)then
13638     num=i
13639     return
13640     else
13641     num=0
13642     return
13643     endif
13644     else
13645     if(i.gt.1)then
13646     num=i-1
13647     return
13648     else
13649     num=0
13650     return
13651     endif
13652     endif
13653     endif
13654     enddo
13655     return
13656     end
13657     +DECK,PRIVOLUM.
13658     subroutine PriVolume
13659    
13660     implicit none
13661    
13662     c include 'GoEvent.inc'
13663     +SEQ,GoEvent.
13664     c include 'volume.inc'
13665     +SEQ,volume.
13666     integer i
13667    
13668     if(soo.eq.0)return
13669     write(oo,*)
13670     write(oo,*)' PriVolume: qvol=',qvol
13671     write(oo,*)
13672     + ' nvol upVol nMatVol sSensit sIonizat ',
13673     + 'wall1 wall2 wide RLenRVol'
13674     do i=1,qvol
13675     write(oo,'(I4,4I8,3F10.4,F10.6)')i, upVol(i),nMatVol(i),
13676     + sSensit(i),
13677     + sIonizat(i),
13678     + wall1(i),wall2(i),wide(i),RLenRVol(i)
13679     if(sSensit(i).ne.0)then
13680     write(oo,*)' numSensVol(i)=',numSensVol(i)
13681     write(oo,*)' numVolSens(numSensVol(i))=',
13682     + numVolSens(numSensVol(i))
13683     endif
13684     if(sIonizat(i).ne.0)then
13685     write(oo,*)' numIoniVol(i)=',numIoniVol(i)
13686     write(oo,*)' numVolIoni(numIoniVol(i))=',
13687     + numVolIoni(numIoniVol(i))
13688     endif
13689     enddo ! qvol
13690     write(oo,*)
13691     + ' ',
13692     + ' RLenRAVol=',RLenRAVol
13693    
13694     end
13695     +DECK,IniTrack.
13696     c This package deals with tracks of incident charged particles.
13697     c The particle goes from left plane of the detector to
13698     c the right plane.
13699     c It starts from some starting point and goes to some direction.
13700     c The energy of the particle is constant.
13701    
13702     subroutine IniRATrack(pystart1, pystart2,
13703     + psigmaang)
13704    
13705     c Randomization of the origin point
13706     c with uniform distribution with y-coordinate between
13707     c pystart1 and pystart2 , x=0.0
13708     c and initial direction around theta = 0.0
13709     c with Gauss distribution with sigma = psigmaang
13710    
13711    
13712     implicit none
13713    
13714     real pystart1, pystart2, pang, pphiang, psigmaang
13715     c include 'ener.inc'
13716     +SEQ,ener.
13717     c include 'atoms.inc'
13718     +SEQ,atoms.
13719     c include 'matters.inc'
13720     +SEQ,matters.
13721     c include 'volume.inc'
13722     +SEQ,volume.
13723     c include 'track.inc'
13724     +SEQ,track.
13725    
13726     ystart1=pystart1
13727     ystart2=pystart2
13728     sigmaang=psigmaang
13729     ystart=0.0
13730     pang=0.0
13731     pphiang=0.0
13732     call IniTrack(ystart, pang, pphiang)
13733     sign_ang=1
13734     srandtrack=1
13735     sigmtk = 0
13736    
13737     end
13738     +DECK,INIRTRAC.
13739     subroutine IniRTrack(pystart1, pystart2, pang, pphiang)
13740    
13741     c Randomization of the origin point
13742     c with uniform distribution with y-coordinate between
13743     c pystart1 and pystart2 , x=0.0.
13744     c Initial direction is defined by theta = pang, phi = pphiang
13745    
13746    
13747     implicit none
13748    
13749     real pystart1, pystart2, pang, pphiang
13750     c include 'ener.inc'
13751     +SEQ,ener.
13752     c include 'atoms.inc'
13753     +SEQ,atoms.
13754     c include 'matters.inc'
13755     +SEQ,matters.
13756     c include 'volume.inc'
13757     +SEQ,volume.
13758     c include 'track.inc'
13759     +SEQ,track.
13760    
13761     ystart1=pystart1
13762     ystart2=pystart2
13763     sigmaang=0.0
13764     ystart=0.0
13765     call IniTrack(ystart, pang, pphiang)
13766     sign_ang=1
13767     srandtrack=1
13768     sigmtk = 0
13769    
13770     end
13771     +DECK,ININTRAC.
13772     subroutine IniNTrack
13773    
13774     c
13775     c Generate the next track
13776     c It calls from GoEvent
13777     c If there are no randomization of the track requried
13778     c and the are no multiple scattering, it does nothing
13779     c except filling of some data structure.
13780    
13781     implicit none
13782     c include 'ener.inc'
13783     +SEQ,ener.
13784     c include 'atoms.inc'
13785     +SEQ,atoms.
13786     c include 'matters.inc'
13787     +SEQ,matters.
13788     c include 'volume.inc'
13789     +SEQ,volume.
13790     c include 'track.inc'
13791     +SEQ,track.
13792     c include 'cconst.inc'
13793     +SEQ,cconst.
13794     real r
13795     real ranfl
13796     real pang,pphiang,pystart
13797     real yy,dimmy
13798    
13799     integer n,nv,i
13800    
13801     if(srandtrack.eq.1)then
13802     r=ranfl()
13803     ystart=ystart1+(ystart2-ystart1)*r
13804     if(sigmaang.gt.0.0)then
13805     10 call lranor(yy,dimmy)
13806     if(yy.lt.0.0) yy=-yy
13807     yy=yy*sigmaang
13808     if(yy.gt.1.0)goto 10
13809     ang=yy
13810     yy=ranfl()
13811     phiang=yy*2.0*PI
13812     pang=ang
13813     pphiang=phiang
13814     pystart=ystart
13815     call IniTrack(pystart, pang, pphiang)
13816     srandtrack=1 ! it falled in IniTrack
13817     endif
13818     endif
13819    
13820     if(sigmtk.eq.1)then
13821     call TTrack
13822     else
13823     do nv=1,QVol
13824     pntmtk(3,nv)=wall1(nv)
13825     pntmtk(1,nv)=(wall1(nv)-wall1(1))*e3ang(1)/e3ang(3)
13826     pntmtk(2,nv)=(wall1(nv)-wall1(1))*e3ang(2)/e3ang(3)+ystart
13827     velmtk(1,nv)=e3ang(1)
13828     velmtk(2,nv)=e3ang(2)
13829     velmtk(3,nv)=e3ang(3)
13830     do i=1,3
13831     e1mtk(i,nv)=e1ang(i)
13832     e2mtk(i,nv)=e2ang(i)
13833     e3mtk(i,nv)=e3ang(i)
13834     enddo
13835     enddo
13836     pntmtk(3,qVol+1)=wall2(qVol)
13837     pntmtk(1,qVol+1)=(wall2(qVol)-wall1(1))*e3ang(1)/e3ang(3)
13838     pntmtk(2,qVol+1)=(wall2(qVol)-wall1(1))
13839     + *e3ang(2)/e3ang(3)+ystart
13840     velmtk(1,qVol+1)=e3ang(1)
13841     velmtk(2,qVol+1)=e3ang(2)
13842     velmtk(3,qVol+1)=e3ang(3)
13843     do i=1,3
13844     e1mtk(i,qVol+1)=e1ang(i)
13845     e2mtk(i,qVol+1)=e2ang(i)
13846     e3mtk(i,qVol+1)=e3ang(i)
13847     enddo
13848    
13849     Qmtk=qVol
13850     nmtk=Qmtk+1
13851     do n=1,Qmtk
13852     lenmtk(n)=sqrt((pntmtk(1,n+1)-pntmtk(1,n))**2+
13853     + (pntmtk(2,n+1)-pntmtk(2,n))**2+
13854     + (pntmtk(3,n+1)-pntmtk(3,n))**2 )
13855     enddo
13856     do n=1,Qmtk
13857     Tetamtk(n)=0.0
13858     enddo
13859     do n=1,Qmtk
13860     nVolmtk(n)=n
13861     enddo
13862     nVolmtk(Qmtk+1)=qVol
13863     do n=1,Qmtk
13864     vlenmtk(n)=lenmtk(n)
13865     nmtkvol1(n)=n
13866     nmtkvol2(n)=n
13867     xdvmtk(n)=0.0
13868     ydvmtk(n)=0.0
13869     enddo
13870    
13871     endif
13872    
13873     end
13874     +DECK,INITRACK.
13875     subroutine IniTrack(pystart, pang, pphiang)
13876    
13877     c
13878     c Simple initialization of the track
13879     c
13880    
13881     implicit none
13882    
13883     real pystart, pang, pphiang
13884     c include 'ener.inc'
13885     +SEQ,ener.
13886     c include 'atoms.inc'
13887     +SEQ,atoms.
13888     c include 'matters.inc'
13889     +SEQ,matters.
13890     c include 'volume.inc'
13891     +SEQ,volume.
13892     c include 'track.inc'
13893     +SEQ,track.
13894    
13895     ystart=pystart
13896     srandtrack=0
13897     if(pystart.eq.0.and.pang.eq.0.and.pphiang.eq.0)then
13898     sign_ang=0
13899     e1ang(1)=1
13900     e1ang(2)=0
13901     e1ang(3)=0
13902     e2ang(1)=0
13903     e2ang(2)=1
13904     e2ang(3)=0
13905     e3ang(1)=0
13906     e3ang(2)=0
13907     e3ang(3)=1
13908     else
13909     sign_ang=1
13910     ang=pang
13911     phiang=pphiang
13912     c xstart=pxstart
13913     c this is for geometry without angle phi
13914     c e1ang(1)=cos(ang)
13915     c e1ang(2)=0
13916     c e1ang(3)=-sin(ang)
13917     c e2ang(1)=0
13918     c e2ang(2)=1
13919     c e2ang(3)=0
13920     c e3ang(1)=sin(ang)
13921     c e3ang(2)=0
13922     c e3ang(3)=cos(ang)
13923     c this is for complete geometry
13924     e1ang(1)=cos(ang)*cos(phiang)
13925     e1ang(2)=cos(ang)*sin(phiang)
13926     e1ang(3)=-sin(ang)
13927     e2ang(1)=-sin(phiang)
13928     e2ang(2)=cos(phiang)
13929     e2ang(3)=0
13930     e3ang(1)=sin(ang)*cos(phiang)
13931     e3ang(2)=sin(ang)*sin(phiang)
13932     e3ang(3)=cos(ang)
13933     endif
13934    
13935     end
13936     +DECK,INIMTRAC.
13937     subroutine IniMTrack(psruthmtk, pmlammtk, pmTetacmtk)
13938     c
13939     c initialization of the axiliary variables for multiple
13940     c scatering of the incident particle.
13941     c It have to be called after each initialization of the
13942     c new particle if the multiple scatering is desirable.
13943     c If it is not needed, the subroutine must not be called at all.
13944    
13945     c psruthmtk - sign of Rutherford scattering (1)
13946     c 1 is recomended
13947     c pmlammtk - minimum mean lengt of range
13948     c multiplied by density. sm*gr/sm**3 = gr/sm**2
13949     c pmTetacmtk - minimum threshold turn angle
13950     c The program find the maximum of pmTetacmtk and
13951     c the same angle calculated from pmlammtk, and then,
13952     c the program recalculates mlammtk.
13953     c For psruthmtk = 0 there is another algorithm.
13954     c To have right results pmlammtk have to be
13955     c 10-100 times lower than widht of the detector.
13956     c The pmTetacmtk have to correspont detector resolution.
13957    
13958     c
13959     implicit none
13960    
13961     c include 'GoEvent.inc'
13962     +SEQ,GoEvent.
13963     c include 'ener.inc'
13964     +SEQ,ener.
13965     c include 'atoms.inc'
13966     +SEQ,atoms.
13967     c include 'matters.inc'
13968     +SEQ,matters.
13969     c include 'crosec.inc'
13970     +SEQ,crosec.
13971     c include 'volume.inc'
13972     +SEQ,volume.
13973     c include 'cconst.inc'
13974     +SEQ,cconst.
13975     c include 'track.inc'
13976     +SEQ,track.
13977     c include 'part.inc'
13978     +SEQ,part.
13979    
13980     integer psruthmtk
13981     real pmlammtk, pmTetacmtk
13982    
13983     integer nm
13984     real lam,mT,A
13985     real*8 B
13986     real msig,x
13987     real*8 r
13988    
13989     sigmtk=1
13990     sruthmtk=psruthmtk
13991     mlammtk=pmlammtk
13992     mTetacmtk=pmTetacmtk
13993    
13994     do nm=1,pQMat
13995     if(qAtMat(nm).gt.0)then
13996    
13997     if(sruthmtk.eq.1)then
13998    
13999     lam=mlammtk/DensMat(nm)
14000    
14001     * write(oo,*)' lam=',lam
14002     c Calculate the minimum angle for restriction of field by
14003     c atomic shell
14004     mT=2.0*asin(1.0/
14005     + (2.0*partmom*Z_Mean(nm)*5.07e2))
14006     rTetacmtk(nm)=mT
14007     * write(oo,*)' mT=',mT
14008     if(mT.lt.mTetacmtk)then
14009     mT=mTetacmtk ! Throw out too slow interaction. They
14010     ! do not influent to anything
14011     endif
14012     c Calculate the cut angle due to mean free part
14013     A=RuthMat(nm)/(partmom2*beta2)/(5.07e10)**2
14014     * B=1.0/(lam*A) ! B is double precision
14015     B=(lam*A) ! B is double precision
14016     * Tetacmtk(nm)=acos( (B-1.0) / (B+1.0) )
14017     * B = sqrt( 1.0 / (B+1.0) )
14018     B = sqrt( B / (B+1.0) )
14019     Tetacmtk(nm)=2.0 * asin(B)
14020     c If it too little, reset it. It will lead to increasing
14021     c of lamBdel and decriasing of calculation time.
14022     * write(oo,*)' A=',A,' B=',B,' Tetacmtk(nm)=',Tetacmtk(nm)
14023     if(Tetacmtk(nm).lt.mT)then
14024     Tetacmtk(nm)=mT
14025     B=mT ! B is double precision
14026     c r=cos(B) ! r is double precision
14027     c lam=A*(1.0+r)/(1.0-r)
14028     c lam=1.0/lam
14029     r=sin(B/2.0)
14030     lam=1/A * 2.0 * r*r / ( 1 + cos(B) )
14031     c lam=(partmom2*beta2*sin(Tetacmtk(nm)/2.0)**2) / A
14032     endif
14033     * write(oo,*)' lam=',lam
14034    
14035     lammtk(nm)=lam
14036     B=Tetacmtk(nm)
14037     CosTetac12mtk(nm)=cos(B/2.0)
14038     SinTetac12mtk(nm)=sin(B/2.0)
14039    
14040     else
14041     c gauss formula
14042    
14043     msig=mTetacmtk
14044     x=msig/(sqrt(2.0)*13.6/(sqrt(beta2)*partmom))
14045     x=x*x
14046    
14047     c x=x/DensMat(nm)
14048     x=x*RLenMat(nm)
14049     lam=mlammtk/DensMat(nm)
14050     c write(oo,*)' x=',x,' rleng=',rleng
14051     c reset if it is too large
14052     if(lam.lt.x)lam=x
14053    
14054     lammtk(nm)=lam
14055     msigmtk=sqrt(2.0)*13.6/(sqrt(beta2)*partmom)
14056    
14057     endif
14058    
14059     endif
14060     enddo
14061    
14062     nmtk=1
14063     Qmtk=0
14064     nVolmtk(1)=0
14065    
14066    
14067     end
14068     +DECK,TTRACK.
14069     subroutine TTrack
14070    
14071     implicit none
14072     c include 'GoEvent.inc'
14073     +SEQ,GoEvent.
14074     c include 'ener.inc'
14075     +SEQ,ener.
14076     c include 'atoms.inc'
14077     +SEQ,atoms.
14078     c include 'matters.inc'
14079     +SEQ,matters.
14080     c include 'volume.inc'
14081     +SEQ,volume.
14082     c include 'track.inc'
14083     +SEQ,track.
14084    
14085     real*8 mleng,rleng
14086     integer nsv
14087     real*8 rst(3),rl
14088     integer j
14089    
14090     if(qVol.le.0)then
14091     write(oo,*)' error in TTrack: there are not volumes'
14092     stop
14093     endif
14094    
14095     1 nmtk=1
14096     pntmtk(1,1)=0.0
14097     pntmtk(2,1)=ystart
14098     pntmtk(3,1)=wall1(1)
14099     velmtk(1,1)=e3ang(1)
14100     velmtk(2,1)=e3ang(2)
14101     velmtk(3,1)=e3ang(3)
14102     sgnmtk=1
14103     sturnmtk=0
14104     nmtkvol1(1)=1
14105     vlenmtk(1)=0.0
14106     nVolmtk(nmtk)=0
14107    
14108     10 if(sgnmtk.eq.1)then
14109     call VolNumZcoor(pntmtk(3,nmtk),velmtk(3,nmtk),nVolmtk(nmtk))
14110     sgnmtk=0
14111     if(nVolmtk(nmtk).ne.0)then
14112     vlenmtk(nVolmtk(nmtk))=0.0
14113     endif
14114     endif
14115     if(nVolmtk(nmtk).eq.0)then
14116     go to 100
14117     endif
14118    
14119     call MakeNewSys
14120     + (e1mtk(1,nmtk),e2mtk(1,nmtk),e3mtk(1,nmtk),velmtk(1,nmtk))
14121    
14122     if(sturnmtk.eq.1)then
14123     call TurnTrack
14124     sturnmtk=0
14125     if(velmtk(3,nmtk).le.0.0)then
14126     write(oo,*)' worning in TTrack: particle goes back'
14127     go to 1
14128     endif
14129     endif
14130     call VolPathLeng
14131     + (pntmtk(3,nmtk),velmtk(1,nmtk),nVolmtk(nmtk),mleng)
14132     if(nMatVol(nVolmtk(nmtk)).eq.0)then ! empty volume: no interaction
14133     lenmtk(nmtk)=mleng
14134     sgnmtk=1
14135     sturnmtk=0
14136     else
14137     if(sruthmtk.eq.1)then !lengt to coulomb interaction
14138     call SRLengmtk(rleng)
14139     else
14140     call SMLengmtk(rleng)
14141     endif
14142     if(rleng.le.mleng)then
14143     lenmtk(nmtk)=rleng
14144     sturnmtk=1
14145     sgnmtk=0
14146     else
14147     lenmtk(nmtk)=mleng
14148     sgnmtk=1
14149     if(sruthmtk.eq.1)then
14150     sturnmtk=0
14151     else
14152     sturnmtk=1
14153     endif
14154     endif
14155     endif
14156     do j=1,3
14157     pntmtk(j,nmtk+1)=
14158     + pntmtk(j,nmtk)+lenmtk(nmtk)*velmtk(j,nmtk)
14159     velmtk(j,nmtk+1)=velmtk(j,nmtk)
14160     enddo
14161     vlenmtk(nVolmtk(nmtk))=vlenmtk(nVolmtk(nmtk))+lenmtk(nmtk)
14162     nVolmtk(nmtk+1)=nVolmtk(nmtk)
14163     if(sgnmtk.eq.1)then
14164     nmtkvol2(nVolmtk(nmtk))=nmtk
14165     nmtkvol1(nVolmtk(nmtk)+1)=nmtk+1
14166     if(sSensit(nVolmtk(nmtk)).eq.1)then
14167     nsv=numSensVol(nVolmtk(nmtk))
14168     rst(3)=(wall2(nVolmtk(nmtk))-wall1(1)) ! it was error here
14169     rl=rst(3)/e3ang(3)
14170     rst(1)=e3ang(1)*rl
14171     rst(2)=e3ang(2)*rl
14172     xdvmtk(nsv)=pntmtk(1,nmtk+1)-rst(1)
14173     ydvmtk(nsv)=pntmtk(2,nmtk+1)-rst(2)
14174     endif
14175     endif
14176     if(nmtk.ge.pQmtk-2)then
14177     write(oo,*)' worning of TTrack: '
14178     write(oo,*)
14179     + ' Overflow of mtk. You have increase the common blok'
14180     go to 1
14181     endif
14182     nmtk=nmtk+1
14183     go to 10
14184    
14185    
14186    
14187     100 Qmtk=nmtk-1
14188    
14189     end
14190     +DECK,SRLENGMT.
14191     subroutine SRLengmtk(rleng)
14192     c
14193     c Step lenght limit due to multiple scatering
14194     c The method with Rutherford cross section
14195     c
14196     implicit none
14197    
14198     real ranfl
14199     real*8 rleng
14200    
14201     c include 'GoEvent.inc'
14202     +SEQ,GoEvent.
14203     c include 'ener.inc'
14204     +SEQ,ener.
14205     c include 'atoms.inc'
14206     +SEQ,atoms.
14207     c include 'matters.inc'
14208     +SEQ,matters.
14209     c include 'crosec.inc'
14210     c include 'volume.inc'
14211     +SEQ,volume.
14212     c include 'track.inc'
14213     +SEQ,track.
14214    
14215     real r
14216    
14217     r=ranfl()
14218     if(r.gt.0.99999)then
14219     rleng=1.0e30
14220     return
14221     endif
14222     rleng=-lammtk(nMatVol(nVolmtk(nmtk)))*alog(1.0-r)
14223     c write(oo,*)' SRLengBdel'
14224     c write(oo,*)' r,lamBdel,rleng',r,lamBdel,rleng
14225    
14226     end
14227    
14228     subroutine SMLengmtk(rleng)
14229     c
14230     c Step lenght limit due to multiple scatering
14231     c The method with mean multiple scatering angle form
14232     c
14233     implicit none
14234    
14235     real*8 rleng
14236    
14237     c include 'GoEvent.inc'
14238     +SEQ,GoEvent.
14239     c include 'ener.inc'
14240     +SEQ,ener.
14241     c include 'atoms.inc'
14242     +SEQ,atoms.
14243     c include 'matters.inc'
14244     +SEQ,matters.
14245     c include 'volume.inc'
14246     +SEQ,volume.
14247     c include 'track.inc'
14248     +SEQ,track.
14249    
14250     rleng=lammtk(nMatVol(nVolmtk(nmtk)))
14251    
14252     end
14253     +DECK,TURNTRAC.
14254     subroutine TurnTrack
14255    
14256     implicit none
14257    
14258     c include 'GoEvent.inc'
14259     +SEQ,GoEvent.
14260     c include 'ener.inc'
14261     +SEQ,ener.
14262     c include 'atoms.inc'
14263     +SEQ,atoms.
14264     c include 'matters.inc'
14265     +SEQ,matters.
14266     c include 'crosec.inc'
14267     c include 'volume.inc'
14268     +SEQ,volume.
14269     c include 'part.inc'
14270     +SEQ,part.
14271     c include 'track.inc'
14272     +SEQ,track.
14273     c include 'cconst.inc'
14274     +SEQ,cconst.
14275    
14276     real ranfl
14277     real*8 r,rs,rsin12,rcos12
14278     real*8 x,msig
14279     real rra,rrb
14280    
14281     if(sruthmtk.eq.1)then
14282    
14283     r=ranfl()
14284     c rs=cos(Tetacmtk(nMatVol(nVolmtk(nmtk-1))))
14285     c rs=CosTetacmtk(nMatVol(nVolmtk(nmtk-1)))
14286     c rs=1.0-(1.0-rs)/(1.0-r*0.5*(1.0+rs))
14287     rsin12=SinTetac12mtk(nMatVol(nVolmtk(nmtk-1)))
14288     rcos12=CosTetac12mtk(nMatVol(nVolmtk(nmtk-1)))
14289     rs = 1.0 - r * rcos12 * rcos12
14290     if(rs.eq.0.0)then
14291     Tetamtk(nmtk-1)=PI
14292     else
14293     rs=rsin12 / sqrt( rs )
14294     rs=2.0 * asin(rs)
14295     Tetamtk(nmtk-1)=rs
14296     endif
14297    
14298     else
14299    
14300     x=lenmtk(nmtk-1)/RLenMat(nMatVol(nVolmtk(nmtk-1)))
14301     c it can not be called for first step
14302     c msig=sqrt(2.0)*13.6/(sqrt(beta2)*partmom)*
14303     c + sqrt(x)
14304     msig=msigmtk*
14305     + sqrt(x)
14306     call lranor(rra,rrb)
14307     Tetamtk(nmtk-1)=rra*msig
14308     c write(oo,*)' msig,TetaBdel,rra=',msig,TetaBdel,rra
14309    
14310     endif
14311    
14312     call turnvec
14313     + (e1mtk(1,nmtk-1),e2mtk(1,nmtk-1),e3mtk(1,nmtk-1),Tetamtk(nmtk-1),
14314     + velmtk(1,nmtk))
14315    
14316     end
14317     +DECK,PRITRACK.
14318     subroutine PriTrack
14319    
14320     implicit none
14321     c include 'GoEvent.inc'
14322     +SEQ,GoEvent.
14323     c include 'ener.inc'
14324     +SEQ,ener.
14325     c include 'atoms.inc'
14326     +SEQ,atoms.
14327     c include 'matters.inc'
14328     +SEQ,matters.
14329     c include 'volume.inc'
14330     +SEQ,volume.
14331     c include 'track.inc'
14332     +SEQ,track.
14333    
14334    
14335     if(soo.eq.0)return
14336     write(oo,*)
14337     write(oo,*)' PriTrack:'
14338     write(oo,*)' ystart1,2, ystart=',ystart1,ystart2,ystart
14339     write(oo,*)' srandtrack=',srandtrack
14340     if(sign_ang.eq.0)then
14341     write(oo,*)' parallel track'
14342     else
14343     write(oo,*)' ang=',ang,' phiang=',phiang,
14344     + ' sigmaang=',sigmaang
14345     write(oo,*)' e1ang()=',e1ang(1),e1ang(2),e1ang(3)
14346     write(oo,*)' e2ang()=',e2ang(1),e2ang(2),e2ang(3)
14347     write(oo,*)' e3ang()=',e3ang(1),e3ang(2),e3ang(3)
14348     endif
14349     end
14350     +DECK,PRIMTRAC.
14351     subroutine PriMTrack(k)
14352     c
14353     c k can be equal to 0,1,2,3,4
14354     c
14355    
14356     implicit none
14357    
14358     integer k
14359    
14360     c include 'GoEvent.inc'
14361     +SEQ,GoEvent.
14362     c include 'ener.inc'
14363     +SEQ,ener.
14364     c include 'atoms.inc'
14365     +SEQ,atoms.
14366     c include 'matters.inc'
14367     +SEQ,matters.
14368     c include 'volume.inc'
14369     +SEQ,volume.
14370     c include 'track.inc'
14371     +SEQ,track.
14372    
14373     integer nm,n,i,j,nv,nsv
14374    
14375     if(soo.eq.0)return
14376     write(oo,*)
14377     write(oo,*)' PriMTrack: k=',k
14378     write(oo,*)' sigmtk=',sigmtk
14379     c if(sigmtk.eq.1)then
14380     if(sigmtk.eq.1)then
14381     write(oo,*)' sruthmtk=',sruthmtk
14382     write(oo,*)' mlammtk=',mlammtk,' mTetacmtk=',mTetacmtk
14383     endif
14384     write(oo,*)' qmtk=',qmtk,' nmtk=',nmtk
14385    
14386     if(k.eq.1)then
14387     write(oo,*)' way of particle'
14388     do n=1,nmtk
14389     write(oo,*)' n=',n
14390     write(oo,*)' pntmtk(1,2,3 ',
14391     + ' velmtk(1,2,3'
14392     write(oo,'(6(1X,e12.6))')(pntmtk(j,n),j=1,3),(velmtk(j,n),j=1,3)
14393     write(oo,*)' lenmtk, Tetamtk, nVolmtk'
14394     write(oo,'(1X,e12.6,1X,e12.6,1X,i7)')
14395     + lenmtk(n),Tetamtk(n),nVolmtk(n)
14396     write(oo,*)' e1mtk=',(e1mtk(i,n),i=1,3)
14397     write(oo,*)' e2mtk=',(e2mtk(i,n),i=1,3)
14398     write(oo,*)' e3mtk=',(e3mtk(i,n),i=1,3)
14399     enddo
14400     endif
14401    
14402     if(sigmtk.eq.1)then
14403     if(k.eq.2)then
14404     write(oo,*)' material constants:'
14405     write(oo,*)' msigmtk=',msigmtk
14406     write(oo,*)' nm, lammtk(nmat), Tetacmtk(nmat)',
14407     + ' CosTetac12mtk(nmat), SinTetac12mtk(nmat)'
14408     do nm=1,pQMat
14409     if(qAtMat(nm).gt.0)then
14410     write(oo,*)nm,lammtk(nm),Tetacmtk(nm),rTetacmtk(nm),
14411     + CosTetac12mtk(nm),SinTetac12mtk(nm)
14412     endif
14413     enddo
14414     endif
14415     endif
14416    
14417     if(sigmtk.eq.1)then
14418     if(k.eq.3)then
14419     if(nVolmtk(nmtk).ne.0)then
14420     write(oo,*)' given point:'
14421     write(oo,*)' pntmtk(1,2,3, ',
14422     + ' velmtk(1,2,3'
14423     write(oo,'(6(1X,e12.6))')
14424     + (pntmtk(j,nmtk),j=1,3),(velmtk(j,nmtk),j=1,3)
14425     write(oo,*)' lenmtk, Tetamtk, nVolmtk'
14426     write(oo,'(1X,e12.6,1X,e12.6,1X,i7)')
14427     + lenmtk(nmtk),Tetamtk(nmtk),nVolmtk(nmtk)
14428     write(oo,*)' e1mtk=',(e1mtk(i,nmtk),i=1,3)
14429     write(oo,*)' e2mtk=',(e2mtk(i,nmtk),i=1,3)
14430     write(oo,*)' e3mtk=',(e3mtk(i,nmtk),i=1,3)
14431     endif
14432     endif
14433     endif
14434    
14435     if(k.eq.4)then
14436     if(qmtk.ge.1)then
14437     write(oo,*)' volimes info:'
14438     write(oo,*)
14439     + ' nv, ',
14440     + ' vlenmtk(pQVol), nmtkvol1(pQVol), nmtkvol2(pQVol)'
14441     c write(oo,*)' if sensitive, nsv,xdvmtk(nsv),ydvmtk(nsv)'
14442     do nv=1,qVol
14443     write(oo,*)nv, vlenmtk(nv), nmtkvol1(nv), nmtkvol2(nv)
14444     if(sSensit(nv).eq.1)then
14445     write(oo,*)' sensitive: nsv,xdvmtk(nsv),ydvmtk(nsv)'
14446     nsv=numSensVol(nv)
14447     write(oo,*)' ',nsv,xdvmtk(nsv),ydvmtk(nsv)
14448     endif
14449     enddo
14450     endif
14451     endif
14452    
14453     c endif
14454    
14455     end
14456     +DECK,IniPart.
14457     subroutine IniPart(ptkin,pmass)
14458     c
14459     c Initialize the incident particle
14460     c
14461     implicit none
14462    
14463     c include 'GoEvent.inc'
14464     +SEQ,GoEvent.
14465     c include 'cconst.inc'
14466     +SEQ,cconst.
14467     c include 'part.inc'
14468     +SEQ,part.
14469    
14470     real ptkin,pmass
14471     real*8 gamma,r,rm2,rme
14472     if(ptkin.le.0.0.or.pmass.le.0.0.or.ptkin.lt.1e-3*pmass)then
14473     write(oo,*)' error in IniPart: wrong parameters:'
14474     write(oo,*)' ptkin=',ptkin,' pmass=',pmass
14475     if(sret_err.eq.0) stop
14476     s_err=1
14477     return
14478     endif
14479     tkin=ptkin
14480     mass=pmass
14481     gamma=tkin/mass+1.0
14482     partgamma=gamma
14483     beta2=1.0-1.0/(gamma*gamma)
14484     r=mass/(tkin+mass)
14485     beta12=r*r
14486     partmom2=tkin*tkin+2.0*tkin*mass
14487     partmom=sqrt(partmom2)
14488     if(mass.ge.0.500.and.mass.le.0.515)then
14489     emax=tkin
14490     s_pri_elec=1
14491     else
14492     s_pri_elec=0
14493     rm2=mass*mass
14494     rme=ELMAS
14495     if(1.0-beta2 .gt. 1.0e-10)then
14496     emax=2.0*rm2*ELMAS*beta2/
14497     + ((rm2+rme*rme+2.0*rme*gamma*mass)*(1.0-beta2))
14498     if(emax.gt.tkin)emax=tkin
14499     else
14500     emax=tkin
14501     endif
14502     endif
14503     bem=beta2/emax
14504     coefPa=1.0/(FSCON*beta2*PI)
14505    
14506     end
14507     +DECK,PRIPART.
14508     subroutine PriPart
14509    
14510     implicit none
14511    
14512     c include 'GoEvent.inc'
14513     +SEQ,GoEvent.
14514     c include 'part.inc'
14515     +SEQ,part.
14516    
14517     if(soo.eq.0)return
14518    
14519     write(oo,*)
14520     write(oo,*)' Particle: tkin=',tkin,' mass=',mass
14521     write(oo,*)' beta2=',beta2,' beta12=',beta12
14522     write(oo,*)' emax=',emax,' bem=',bem,' coefPa=',coefPa
14523    
14524     end
14525     +DECK,IniCrose.
14526     Subroutine IniCrosec
14527     c
14528     c Initialization of ionization cross section for all the
14529     c matters which are in "ionization" volumes
14530     c
14531     implicit none
14532    
14533     c include 'GoEvent.inc'
14534     +SEQ,GoEvent.
14535     c include 'ener.inc'
14536     +SEQ,ener.
14537     c include 'atoms.inc'
14538     +SEQ,atoms.
14539     c include 'matters.inc'
14540     +SEQ,matters.
14541     c include 'crosec.inc'
14542     +SEQ,crosec.
14543     c include 'volume.inc'
14544     +SEQ,volume.
14545    
14546     integer nv,nm
14547    
14548     if(qvol.le.0)then
14549     write(oo,*)' You forgot to initialize volumes'
14550     stop
14551     endif
14552     if(QIVol.le.0)then
14553     write(oo,*)' You forgot to initialize ioniz. volumes'
14554     stop
14555     endif
14556    
14557     do nm=1,pQMat
14558     sMatC(nm)=0
14559     enddo
14560    
14561     do nv=1,QIVol
14562     sMatC(nMatVol(numVolIoni(nv)))=1
14563     enddo
14564    
14565     do nm=1,pQMat
14566     if(sMatC(nm).eq.1)then
14567     call IniCrosecm(nm)
14568     endif
14569     enddo
14570    
14571     end
14572     +DECK,INICROSM.
14573     Subroutine IniCrosecm(nmat)
14574     c
14575     c Initialization of ionization cross section for given matter
14576     c
14577     implicit none
14578    
14579     c include 'GoEvent.inc'
14580     +SEQ,GoEvent.
14581     c include 'ener.inc'
14582     +SEQ,ener.
14583     c include 'atoms.inc'
14584     +SEQ,atoms.
14585     c include 'matters.inc'
14586     +SEQ,matters.
14587     c include 'part.inc'
14588     +SEQ,part.
14589     c include 'crosec.inc'
14590     +SEQ,crosec.
14591     c include 'cconst.inc'
14592     +SEQ,cconst.
14593    
14594     integer nmat
14595    
14596     c real spa,sio
14597    
14598     integer i
14599     real*8 r,R0,R1,R2,R3,RR12,RR22
14600     real*8 s,sa
14601     integer k
14602    
14603     c real ALOG,SQRT,ATAN
14604     real fquan,fmean,fmean1
14605     integer nen,nat,nsh,nshc,ne
14606     c integer nat0,nat1,iat
14607    
14608     c real spa(pqener) ! sum of photoabsorption
14609     c ! It is luzy to put it to matter.
14610    
14611     real*8 delta,pg,pg2
14612    
14613     complex*16 eeee
14614     real*8 eee(2)
14615     equivalence (eeee,eee(1))
14616    
14617     c MatC=nmat
14618    
14619     c ksi=0.1534*DensMat(nmat)*Z_Mean(nmat)/(beta2*A_Mean(nmat))
14620    
14621     DO 100 I=1,qener
14622     R=-EPSI1(I,nmat)+(1.0+EPSI1(I,nmat))*BETA12
14623     R=R*R+beta2*beta2*EPSI2(I,nmat)*EPSI2(I,nmat)
14624     R=1.0/SQRT(R)
14625     R=DLOG(R)
14626     LOG1C(I,nmat)=R
14627     100 CONTINUE
14628     C
14629     DO 200 I=1,qener
14630     R=2.0*0.511*beta2/ENERC(I)
14631     if(R.gt.1.0)then
14632     R=DLOG(R)
14633     else
14634     R=0.0
14635     endif
14636     LOG2C(I,nmat)=R
14637     200 continue
14638     c
14639    
14640    
14641     DO 300 I=1,qener
14642     R0=1.0+EPSI1(I,nmat)
14643     R=-EPSI1(I,nmat)+R0*BETA12
14644     RR12=R0*R0
14645     RR22=EPSI2(I,nmat)*EPSI2(I,nmat)
14646     R1=(-R0*R+beta2*RR22)/(RR12+RR22)
14647     R2=EPSI2(I,nmat)*Beta2/R
14648     R3=ATAN(R2)
14649     IF(R.LT.0.0) R3=3.14159+R3
14650    
14651     c R2=R/(EPSI2(I,nmat)*Beta2) ! it is the same as
14652     c previous three lines but less exactly
14653     c if EPSI2 --> 0
14654     c R3=PI/2.0 - ATAN(R2)
14655    
14656     chereCangle(I,nmat)=R3
14657     CHEREC(I,nmat)=(COEFPa/ElDENSMat(nmat))*R1*R3
14658    
14659     c spa=0.0
14660     c sio=0.0
14661     c
14662     c do nat=1,QAtMat(nmat)
14663     c do nsh=1,QShellAt(AtMat(nat,nmat))
14664     c
14665     c spa=spa+PhotAt(I,nsh,nat)
14666     c sio=sio+PhotIonAt(I,nsh,nat)
14667     c
14668     c enddo
14669     c enddo
14670     c if(spa.gt.0.0)then
14671     c CHEREC(I,nmat)=CHEREC(I,nmat)*sio/spa
14672     c endif
14673     300 continue
14674    
14675     c debug:
14676     c write(oo,*)' probb'
14677     c do nen=1,qener
14678     c
14679     c R=log1C(nen,nmat)*coefPa*PhotIonMat(nen,nmat)
14680     c + /(enerc(nen)*Z_Mean(nmat))
14681     c if(PhotMat(nen,nmat).gt.0.0)then
14682     c R1= R + PhotIonMat(nen,nmat)/PhotMat(nen,nmat)*CHEREC(nen,nmat)
14683     c endif
14684     c r2=r1+log2C(nen,nmat)*coefPa*PhotIonMat(nen,nmat)
14685     c + /(enerc(nen)*Z_Mean(nmat))
14686     c write(oo,'(5E10.3)')enerc(nen),R,CHEREC(nen,nmat),R1,r2
14687     c
14688     c enddo
14689     c end debug
14690    
14691    
14692     nshc=0
14693     do 800 nat=1,QAtMat(nmat)
14694    
14695     do 700 nsh=1,QShellAt(AtMat(nat,nmat))
14696    
14697     nshc=nshc+1
14698    
14699     NAtMC(nshc,nmat)=nat
14700     NAtAC(nshc,nmat)=AtMat(nat,nmat)
14701     NSheC(nshc,nmat)=nsh
14702    
14703     do 400 nen=1,qener
14704    
14705     flog1(nen,nshc,nmat)=
14706     + WeightAtMat(nat,nmat)*log1C(nen,nmat)*coefPa*
14707     + PhotIonAt(nen,nsh,AtMat(nat,nmat))/
14708     + (enerc(nen)*Z_Mean(nmat))
14709    
14710     flog2(nen,nshc,nmat)=
14711     + WeightAtMat(nat,nmat)*log2C(nen,nmat)*coefPa*
14712     + PhotIonAt(nen,nsh,AtMat(nat,nmat))/
14713     + (enerc(nen)*Z_Mean(nmat))
14714    
14715     if(PhotMat(nen,nmat).gt.0.0)then
14716    
14717     cher(nen,nshc,nmat)= chereC(nen,nmat)*
14718     + WeightAtMat(nat,nmat)*
14719     + PhotIonAt(nen,nsh,AtMat(nat,nmat))/
14720     + PhotMat(nen,nmat)
14721     c + WeightAtMat(nat,nmat)*chereC(nen,nmat)*
14722     c + WeightShAt(nsh,AtMat(nat,nmat))
14723    
14724     else
14725    
14726     cher(nen,nshc,nmat)=0.0
14727    
14728     endif
14729    
14730     400 continue
14731    
14732     s=0
14733    
14734     do 500 nen=1,qener
14735    
14736     r=PhotAt(nen,nsh,AtMat(nat,nmat))*WeightAtMat(nat,nmat)*
14737     + (ener(nen+1)-ener(nen))
14738     rezer(nen,nshc,nmat)=s+0.5*r
14739     if(enerc(nen).gt.MinThresholdAt(AtMat(nat,nmat))
14740     + .and.
14741     + enerc(nen).lt.emax)then ! kinematical limit
14742     if(s_pri_elec.eq.0)then
14743     frezer(nen,nshc,nmat)=(s+0.5*r)*coefPa/
14744     + (enerc(nen)*enerc(nen)*Z_Mean(nmat))*
14745     + (1.0-beta2*enerc(nen)/emax +
14746     + enerc(nen)*enerc(nen)/
14747     + (2.0*(tkin+mass)*(tkin+mass)))
14748     else
14749     delta=enerc(nen)/mass
14750     pg=partgamma
14751     pg2=pg*pg
14752     frezer(nen,nshc,nmat)=(s+0.5*r)*coefPa/
14753     + Z_Mean(nmat) * beta2/mass *
14754     + 1.0/(pg2-1) *
14755     + ((pg-1)**2 * pg2 / ((delta*(pg-1-delta))**2)
14756     + -
14757     + (2*pg2 + 2*pg - 1)/
14758     + (delta*(pg-1-delta))
14759     + + 1 )
14760    
14761     endif
14762     else
14763     frezer(nen,nshc,nmat)=0.0
14764     endif
14765     s=s+r
14766    
14767     500 continue
14768    
14769     700 continue
14770    
14771     800 continue
14772    
14773     QShellC(nmat)=nshc
14774     r=0.0
14775    
14776     c add cherenkov radiation to lowest energy level shell
14777     c nat0=NAtAC(1)
14778     c iat=1
14779     c nat1=nat0
14780     c nsh=NSheC(1)
14781     c i=1
14782     c850 do nshc=1,QShellC
14783     c if(NAtAC(nshc).eq.nat0)then
14784     c if(NSheC(nshc).gt.nsh)then
14785     c nsh=NSheC(nshc)
14786     c i=nshc
14787     c endif
14788     c else
14789     c if(nshc.gt.iat.and.nat1.eq.nat0)then
14790     c iat=nshc
14791     c nat1=NAtAC(nshc)
14792     c endif
14793     c endif
14794     c enddo
14795     c write(oo,*)' crosec: i,nat0,nat1,nmat,iat='
14796     c write(oo,*)i,nat0,nat1,nmat,iat
14797     c if(nat1.gt.nat0)then
14798     c nat=nat1
14799     c go to 850
14800     c endif
14801    
14802     c The cherenkov is added to last shell
14803     c i=0
14804     c do nat=1,QAtMat(nmat)
14805     c i=i+QShellAt(AtMat(nat,nmat))
14806     c do nen=1,qener
14807     c cher(nen,i,nmat)=
14808     c + WeightAtMat(nat,nmat)*chereC(nen,nmat)
14809     cc write(oo,*)cher(nen,i),WeightAtMat(nat,nmat),
14810     cc + chereC(nen)
14811     c enddo
14812     c enddo
14813    
14814    
14815     do 1000 nen=1,qener
14816    
14817     s=0.0
14818     sa=0.0
14819     k=0.0
14820    
14821     DO nshc=1,QShellC(nmat)
14822     ADDA(nen,nshc,nmat)=FLOG1(nen,nshc,nmat)+
14823     + FLOG2(nen,nshc,nmat)+FREZER(nen,nshc,nmat)
14824     c ADDA(nen,nshc,nmat)=FLOG1(nen,nshc,nmat)+
14825     c + FLOG2(nen,nshc,nmat)
14826     s=s+ADDA(nen,nshc,nmat)
14827    
14828     if(enerc(nen).gt.min_ioniz_pot(nmat))then
14829     ADDA(nen,nshc,nmat)=ADDA(nen,nshc,nmat)+
14830     + cher(nen,nshc,nmat)
14831     if(ADDA(nen,nshc,nmat).lt.0.0)then
14832     write(oo,*)' worning of IniCrosec: negative ADDA'
14833     write(oo,*)' nmat=',nmat,' nshc=',nshc,' nen=',nen
14834     ADDA(nen,nshc,nmat)=0.0
14835     endif
14836     endif
14837    
14838     enddo
14839    
14840     c if(enerc(nen).gt.min_ioniz_pot(nmat))then
14841     c if(s.lt.-chereC(nen,nmat))then
14842     c DO nshc=1,QShellC(nmat)
14843     c ADDA(nen,nshc,nmat)=0.0
14844     c enddo
14845     c else
14846     c s=1.0+chereC(nen,nmat)/s
14847     c DO nshc=1,QShellC(nmat)
14848     c ADDA(nen,nshc,nmat)=ADDA(nen,nshc,nmat)*s
14849     c enddo
14850     c endif
14851     c endif
14852    
14853     s=0.0
14854     DO nshc=1,QShellC(nmat)
14855     s=s+ADDA(nen,nshc,nmat)
14856     enddo
14857     ADDAC(nen,nmat)=s
14858    
14859    
14860     c DO 900 nshc=1,QShellC(nmat)
14861     c R=FLOG1(nen,nshc,nmat)+FLOG2(nen,nshc,nmat)+
14862     c + FREZER(nen,nshc,nmat)
14863     cc IF(CHER(nen,nshc).LT.0.0)THEN
14864     c R=R+CHER(nen,nshc,nmat)
14865     cc END IF
14866     c IF(R.LT.0.0)THEN
14867     c K=1
14868     c SA=SA+R
14869     c ELSE
14870     c S=S+R
14871     c ENDIF
14872     c ADDA(nen,nshc,nmat)=R
14873     c900 ADDAC(nen,nmat)=ADDAC(nen,nmat)+ADDA(nen,nshc,nmat)
14874     c
14875     c IF(K.EQ.1)THEN
14876     c IF(ABS(SA).LT.S)THEN
14877     c DO 906 nshc=1,QShellC(nmat)
14878     c IF(ADDA(nen,nshc,nmat).GT.0.0)THEN
14879     c ADDA(nen,nshc,nmat)=ADDA(nen,nshc,nmat)*(1.0+SA/S)
14880     c ELSE
14881     c ADDA(nen,nshc,nmat)=0.0
14882     c END IF
14883     c906 CONTINUE
14884     c ELSE
14885     c DO 907 nshc=1,QShellC(nmat)
14886     c ADDA(nen,nshc,nmat)=0.0
14887     c907 CONTINUE
14888     c ADDAC(nen,nmat)=0.0
14889     c END IF
14890     c END IF
14891    
14892     1000 continue
14893    
14894     DO nshc=1,QShellC(nmat)
14895    
14896     do nen=1,qener
14897     fadda(nen,nshc,nmat)=adda(nen,nshc,nmat)*
14898     + (ener(nen+1)-ener(nen))
14899     enddo
14900    
14901     call lhispre(fadda(1,nshc,nmat),qener)
14902    
14903     enddo
14904    
14905     quanC(nmat)=fquan(addaC(1,nmat),1.0,nmat)
14906     meanC(nmat)=fmean(addaC(1,nmat),1.0,nmat)
14907    
14908     if(s_pri_elec.eq.0)then
14909     meanC1(nmat)=fmean1(addaC(1,nmat),1.0,nmat)
14910     else
14911     meanC1(nmat)=0.0 ! for electrons it is not calculated
14912     endif
14913    
14914     meaneleC(nmat)=meanC(nmat)/WWW(nmat)
14915     meaneleC1(nmat)=meanC1(nmat)/WWW(nmat)
14916    
14917     do nshc=1,QShellC(nmat)
14918     c quan(nshc)=fquan(adda(1,nshc,nmat),
14919     c + WeightAtMat(NAtMC(nshc),nmat),nmat)
14920     c mean(nshc)=fmean(adda(1,nshc,nmat),
14921     c +WeightAtMat(NAtMC(nshc),nmat),nmat)
14922     quan(nshc,nmat)=fquan(adda(1,nshc,nmat),1.0,nmat)
14923     mean(nshc,nmat)=fmean(adda(1,nshc,nmat),1.0,nmat)
14924     enddo
14925    
14926     do ne=1,qener
14927     eee(1)=dble(1.)+dble(epsi1(ne,nmat))
14928     eee(2)=dble(epsi2(ne,nmat))
14929     c write(oo,*)enerc(ne),eeee
14930     eeee=beta2*eeee - 1.0
14931     c write(oo,*)enerc(ne),eeee
14932     eeee=sqrt(eeee)
14933     c write(oo,*)enerc(ne),eeee
14934     eeee=enerc(ne)/sqrt(beta2) * eeee
14935     c write(oo,*)enerc(ne),eeee
14936     pocaz(ne,nmat)=eeee * 5.07e10
14937     c write(oo,*)enerc(ne),pocaz(ne,nmat)
14938     enddo
14939    
14940    
14941     end
14942     +DECK,FQUAN.
14943     function fquan(ad,weig,nmat)
14944     c
14945     c Calc. mean quantity of energy transfer for 1 sm
14946     c
14947     implicit none
14948    
14949     c include 'ener.inc'
14950     +SEQ,ener.
14951     c include 'atoms.inc'
14952     +SEQ,atoms.
14953     c include 'matters.inc'
14954     +SEQ,matters.
14955    
14956     real fquan,ad(*),weig
14957     integer nmat
14958     real step_integ_ar
14959    
14960     fquan=step_integ_ar(ener,ad,qener,ener(1),ener(qener+1))
14961     fquan=fquan*weig*XElDensMat(nmat)
14962    
14963     end
14964     +DECK,FMEAN.
14965     function fmean(ad,weig,nmat)
14966     c
14967     c Calc. mean energy loss for 1 sm
14968     c
14969     implicit none
14970    
14971     c include 'ener.inc'
14972     +SEQ,ener.
14973     c include 'atoms.inc'
14974     +SEQ,atoms.
14975     c include 'matters.inc'
14976     +SEQ,matters.
14977    
14978     real fmean,ad(*),weig
14979     integer nmat
14980     real step_integ_ar
14981     real addd(pqener)
14982    
14983     integer nen
14984    
14985     do nen=1,qener
14986     addd(nen)=ad(nen)*enerc(nen)
14987     enddo
14988     fmean=step_integ_ar(ener,addd,qener,ener(1),ener(qener+1))
14989     fmean=fmean*weig*XElDensMat(nmat)
14990    
14991     end
14992     +DECK,FMEAN1.
14993     function fmean1(ad,weig,nmat)
14994     c
14995     c Calc. mean energy loss for 1 sm
14996     c
14997     implicit none
14998    
14999     c include 'ener.inc'
15000     +SEQ,ener.
15001     c include 'atoms.inc'
15002     +SEQ,atoms.
15003     c include 'matters.inc'
15004     +SEQ,matters.
15005     c include 'part.inc'
15006     +SEQ,part.
15007     c include 'cconst.inc'
15008     +SEQ,cconst.
15009    
15010     real fmean1,ad(*),weig
15011     integer nmat
15012     real step_integ_ar
15013     real addd(pqener)
15014     real e1,e2
15015    
15016     integer nen
15017    
15018     do nen=1,qener
15019     addd(nen)=ad(nen)*enerc(nen)
15020     enddo
15021     fmean1=step_integ_ar(ener,addd,qener,ener(1),ener(qener+1))
15022     fmean1=fmean1*weig*XElDensMat(nmat)
15023     if(emax.gt.ener(qener+1))then
15024     e1=ener(qener+1)
15025     e2=emax
15026    
15027     fmean1 = fmean1 +
15028     + 2.0 * PI / (FSCON**2 * ELMAS * beta2)
15029     + * weig * XElDensMat(nmat) *
15030     + ( log(e2/e1) - bem * (e2-e1) +
15031     + (e2*e2-e1*e1)/(4.0 * (tkin+mass) * (tkin+mass) ) )
15032    
15033     endif
15034    
15035     end
15036     +DECK,PRICROSE.
15037     subroutine PriCrosec(nmat,lev)
15038    
15039     implicit none
15040    
15041     c include 'GoEvent.inc'
15042     +SEQ,GoEvent.
15043     c include 'ener.inc'
15044     +SEQ,ener.
15045     c include 'atoms.inc'
15046     +SEQ,atoms.
15047     c include 'matters.inc'
15048     +SEQ,matters.
15049     c include 'part.inc'
15050     c include 'crosec.inc'
15051     +SEQ,crosec.
15052     integer nmat
15053     integer lev
15054     integer nen
15055     integer nshc
15056    
15057     if(soo.eq.0)return
15058    
15059     if(lev.ge.1)then
15060     write(oo,*)
15061     write(oo,*)' PriCrosec:'
15062     write(oo,*)' material number ',nmat,
15063     + ' Quantity of shells is',QShellC(nmat)
15064     if(sMatC(nmat).ne.1)then
15065     write(oo,*)' This cross sect. was not initialized'
15066     return
15067     endif
15068     c write(oo,*)' ksi=',ksi
15069     write(oo,*)' quanC=',quanC(nmat)
15070     write(oo,*)' meanC=',meanC(nmat),' meaneleC=',meaneleC(nmat)
15071     write(oo,*)' meanC1=',meanC1(nmat),' meaneleC1=',meaneleC1(nmat)
15072     do nshc=1,QShellC(nmat)
15073     write(oo,*)' NAtMC=',NAtMC(nshc,nmat),' NAtAC=',NAtAC(nshc,nmat),
15074     + ' NSheC=',NSheC(nshc,nmat)
15075     write(oo,*)' quan=',quan(nshc,nmat),' mean=',mean(nshc,nmat)
15076     enddo
15077    
15078     c write(oo,*)' ener,pocaz'
15079     c do nen=1,qener
15080     c write(oo,*)enerc(nen),pocaz(nen,nmat)
15081     c enddo
15082     if(lev.ge.2)then
15083     write(oo,*)' enerc, log1C, log2C',
15084     + ' chereC, addaC, chereCangle'
15085     do nen=1,qener
15086     write(oo,'(6e10.3)')enerc(nen),log1C(nen,nmat),log2C(nen,nmat),
15087     + chereC(nen,nmat),addaC(nen,nmat),chereCangle(nen,nmat)
15088     enddo
15089     if(lev.ge.3)then
15090     do nshc=1,QShellC(nmat)
15091     write(oo,*)' enerc, flog1, flog2, cher, ',
15092     + ' rezer, frezer, adda, fadda'
15093     do nen=1,qener
15094     write(oo,'(8e10.3)')enerc(nen),flog1(nen,nshc,nmat),
15095     + flog2(nen,nshc,nmat),
15096     + cher(nen,nshc,nmat),rezer(nen,nshc,nmat),
15097     + frezer(nen,nshc,nmat),
15098     + adda(nen,nshc,nmat),fadda(nen,nshc,nmat)
15099     enddo
15100     enddo
15101     endif
15102     endif
15103     endif
15104    
15105     end
15106     +DECK,IniLsgvg.
15107     subroutine IniLsgvga
15108    
15109     c Initialize the virt. ioniz. photons
15110    
15111     implicit none
15112    
15113    
15114     c include 'volume.inc'
15115     +SEQ,volume.
15116     c include 'lsgvga.inc'
15117     +SEQ,lsgvga.
15118    
15119     integer n
15120    
15121     do n=1,QSVol
15122     qgvga(n)=0
15123     enddo
15124    
15125     end
15126     +DECK,PRILSGVG.
15127     subroutine PriLsgvga
15128    
15129     c print the virt. ioniz. photons
15130    
15131     implicit none
15132    
15133     c include 'GoEvent.inc'
15134     +SEQ,GoEvent.
15135     c include 'volume.inc'
15136     +SEQ,volume.
15137     c include 'lsgvga.inc'
15138     +SEQ,lsgvga.
15139    
15140     integer k,i,j
15141    
15142     if(soo.eq.0)return
15143    
15144     write(oo,*)
15145     write(oo,*)' PriLsgvga: virtual ionization photons'
15146     do k=1,QSVol
15147     write(oo,*)' number of lay =',k
15148     write(oo,*)' qgvga()= ',qgvga(k),' esgvga()=',esgvga(k)
15149     if(qgvga(k).gt.0)then
15150     write(oo,*)' egvga(i,k) ganumat(i,k) ganumshl(i.k)'
15151     write(oo,*)
15152     + ' pntgvga(1,i,k) pntgvga(2,i,k) pntgvga(3,i,k) ',
15153     + ' velgvga(1,i,k) velgvga(2,i,k) velgvga(3,i,k) '
15154     do i=1,qgvga(k)
15155     write(oo,'(1X,e12.5,2(i12))')
15156     + egvga(i,k),ganumat(i,k),ganumshl(i,k)
15157     write(oo,'(6(1X,e12.5))')(pntgvga(j,i,k),j=1,3),
15158     + (velgvga(j,i,k),j=1,3)
15159     enddo
15160     endif
15161     enddo
15162    
15163     end
15164     +DECK,Inirga.
15165     subroutine Inirga
15166     c
15167     c Init. common with real photons
15168     c
15169     implicit none
15170    
15171     c include 'GoEvent.inc'
15172     +SEQ,GoEvent.
15173     c include 'rga.inc'
15174     +SEQ,rga.
15175    
15176     qrga=0
15177     crga=1
15178     sOverflowrga=0
15179     if(nevt.eq.qevt)then
15180     qOverflowrga=0
15181     qsOverflowrga=0
15182     endif
15183    
15184    
15185     end
15186     +DECK,WORPRIRG.
15187     subroutine WorPrirga
15188    
15189     implicit none
15190    
15191     c include 'GoEvent.inc'
15192     +SEQ,GoEvent.
15193     c include 'rga.inc'
15194     +SEQ,rga.
15195    
15196     c integer i,j
15197    
15198     if(nevt.eq.qevt)then
15199    
15200     if(qOverflowrga.gt.0)then
15201     write(oo,*)
15202     write(oo,*)' WorPrirga: overflow of real photons arrays '
15203     write(oo,*)' sOverflowrga qsOverflowrga qOverflowrga'
15204     write(oo,*)sOverflowrga,qsOverflowrga,qOverflowrga
15205     endif
15206    
15207     endif
15208    
15209     end
15210     +DECK,PRIRGA.
15211     subroutine Prirga
15212    
15213     c print the real photons
15214    
15215     implicit none
15216    
15217     c include 'GoEvent.inc'
15218     +SEQ,GoEvent.
15219     c include 'rga.inc'
15220     +SEQ,rga.
15221    
15222     integer i,j
15223    
15224     if(soo.eq.0)return
15225     write(oo,*)
15226     write(oo,*)' Prirga: real photons'
15227     write(oo,*)' sOverflowrga qsOverflowrga qOverflowrga'
15228     write(oo,*)sOverflowrga,qsOverflowrga,qOverflowrga
15229    
15230     write(oo,*)' qrga= ',qrga,' crga=',crga
15231     if(crga.le.qrga)then
15232     write(oo,*)' erga() nVolrga Strga uprga(1) Ptrga'
15233     write(oo,*)
15234     + ' pntrga(1,i) pntrga(2,i) pntrga(3,i) ',
15235     + ' velrga(1,i) velrga(2,i) velrga(3,i) '
15236     do i=crga,qrga
15237     write(oo,'(1X,e12.5,4(1X,I5))')
15238     + erga(i),nVolrga(i),Strga(i),uprga(1,i),Ptrga(i)
15239     write(oo,'(6(1X,e12.5))')(pntrga(j,i),j=1,3),
15240     + (velrga(j,i),j=1,3)
15241     enddo
15242     endif
15243    
15244     end
15245     +DECK,PRIRGAF.
15246     subroutine PrirgaF
15247    
15248     c print the real photons which fly out
15249    
15250     implicit none
15251    
15252     c include 'GoEvent.inc'
15253     +SEQ,GoEvent.
15254     c include 'rga.inc'
15255     +SEQ,rga.
15256    
15257     integer i,j
15258    
15259     if(soo.eq.0)return
15260     write(oo,*)
15261     write(oo,*)' Prirga: real photons which go out'
15262     write(oo,*)' qrga= ',qrga,' crga=',crga
15263     c if(crga.le.qrga)then
15264     write(oo,*)' erga() nVolrga Strga Ptrga'
15265     write(oo,*)
15266     + ' pntrga(1,i) pntrga(2,i) pntrga(3,i) ',
15267     + ' velrga(1,i) velrga(2,i) velrga(3,i) '
15268     do i=1,qrga
15269     if(SFrga(i).eq.1)then
15270     write(oo,'(1X,e12.5,3(1X,I5))')
15271     + erga(i),nVolrga(i),Strga(i),Ptrga(i)
15272     write(oo,'(6(1X,e12.5))')(pntrga(j,i),j=1,3),
15273     + (velrga(j,i),j=1,3)
15274     endif
15275     enddo
15276     c endif
15277    
15278     end
15279     +DECK,Iniabs.
15280     subroutine Iniabs
15281     c
15282     c Initialize absorbed photons
15283     c
15284     implicit none
15285    
15286     c include 'GoEvent.inc'
15287     +SEQ,GoEvent.
15288     c include 'ener.inc'
15289     +SEQ,ener.
15290     c include 'abs.inc'
15291     +SEQ,abs.
15292    
15293     qtagam=0
15294     ctagam=1
15295     sOverflowagam=0
15296     if(nevt.eq.1)then
15297     qOverflowagam=0
15298     qsOverflowagam=0
15299     endif
15300    
15301     end
15302     +DECK,WORPRIAB.
15303     subroutine WorPriabs
15304    
15305    
15306     implicit none
15307    
15308     c include 'GoEvent.inc'
15309     +SEQ,GoEvent.
15310     c include 'abs.inc'
15311     +SEQ,abs.
15312    
15313     c integer i,j
15314    
15315     if(nevt.eq.qevt)then
15316    
15317     if(qOverflowagam.gt.0)then
15318     write(oo,*)
15319     write(oo,*)' WorPriabs: overflow of absorbtion photons arrays '
15320     write(oo,*)' sOverflowagam qsOverflowagam qOverflowagam'
15321     write(oo,*)sOverflowagam,qsOverflowagam,qOverflowagam
15322     endif
15323    
15324     endif
15325    
15326     end
15327     +DECK,PRIABS.
15328     subroutine Priabs
15329    
15330     implicit none
15331    
15332     c include 'GoEvent.inc'
15333     +SEQ,GoEvent.
15334     c include 'ener.inc'
15335     +SEQ,ener.
15336     c include 'abs.inc'
15337     +SEQ,abs.
15338    
15339     integer i,j
15340    
15341     if(soo.eq.0)return
15342     write(oo,*)
15343     write(oo,*)' Priabs: virtual photons'
15344     write(oo,*)' sOverflowagam qsOverflowagam qOverflowagam'
15345     write(oo,*)sOverflowagam,qsOverflowagam,qOverflowagam
15346    
15347     write(oo,*)' qtagam= ',qtagam,' ctagam=',ctagam
15348     if(ctagam.le.qtagam)then
15349     write(oo,*)' etagam() nVolagam() nAtagam() ',
15350     + 'nShlagam() stagam() upagam()'
15351     write(oo,*)
15352     + ' rtagam(1,i) rtagam(2,i) rtagam(3,i) ',
15353     + ' vtagam(1,i) vtagam(2,i) vtagam(3,i) '
15354     do i=ctagam,qtagam
15355     write(oo,'(1(1X,e12.5),10(1X,i5))')
15356     + etagam(i), nVolagam(i),nAtagam(i),
15357     + nShlagam(i),Stagam(i),(upagam(j,i),j=1,pqup)
15358     write(oo,'(6(1X,e12.5))')(rtagam(j,i),j=1,3),
15359     + (vtagam(j,i),j=1,3)
15360     enddo
15361     endif
15362    
15363     end
15364     +DECK,rafflev.
15365     subroutine rafflev
15366     c
15367     c The main subroutine of ionization loss generator
15368     c
15369     implicit none
15370    
15371     c include 'ener.inc'
15372     +SEQ,ener.
15373     c include 'atoms.inc'
15374     +SEQ,atoms.
15375     c include 'matters.inc'
15376     +SEQ,matters.
15377     c include 'crosec.inc'
15378     +SEQ,crosec.
15379     c include 'raffle.inc'
15380     +SEQ,raffle.
15381     c include 'volume.inc'
15382     +SEQ,volume.
15383     c include 'track.inc'
15384     +SEQ,track.
15385     c include 'lsgvga.inc'
15386     c include 'GoEvent.inc'
15387     +SEQ,GoEvent.
15388    
15389     integer nv,niv,nm
15390     real e
15391    
15392     do niv=1,QIVol
15393    
15394     nv=numVolIoni(niv)
15395     nm=nMatVol(nv)
15396    
15397     if(sign_ang.eq.0)then
15398    
15399     call raffle(nm,real(wide(nv)),e)
15400     call rafflevirt(nv,niv)
15401    
15402     else
15403    
15404     c if(sigmtk.eq.0)then
15405     c call raffle(nm,real(wide(nv)/e3ang(3)),e)
15406     c call rafflevirt1(nv,niv)
15407     c else
15408     call raffle(nm,real(vlenmtk(nv)),e)
15409     call rafflevirt2(nv,niv)
15410     c endif
15411    
15412     endif
15413    
15414    
15415     enddo
15416    
15417     end
15418     +DECK,RAFFLEVI.
15419     subroutine rafflevirt(nv,niv)
15420    
15421     implicit none
15422    
15423     integer nv,niv
15424    
15425     c include 'GoEvent.inc'
15426     +SEQ,GoEvent.
15427     c include 'ener.inc'
15428     +SEQ,ener.
15429     c include 'atoms.inc'
15430     +SEQ,atoms.
15431     c include 'matters.inc'
15432     +SEQ,matters.
15433     c include 'crosec.inc'
15434     +SEQ,crosec.
15435     c include 'raffle.inc'
15436     +SEQ,raffle.
15437     c include 'volume.inc'
15438     +SEQ,volume.
15439     c include 'lsgvga.inc'
15440     +SEQ,lsgvga.
15441     c include 'abs.inc'
15442     +SEQ,abs.
15443    
15444     integer i,j
15445     real ranfl
15446     real F,rr
15447    
15448     esgvga(niv)=ESGRaf
15449     do i=1,QGRaf
15450     egvga(i,niv)=EGRaf(i)
15451     pntraf(1,i)=0.0
15452     pntraf(2,i)=0.0
15453     rr=ranfl()
15454     pntraf(3,i)=wall1(nv)+rr*wide(nv)
15455     F=3.14159*2.0*ranfl()
15456     velraf(1,i)=cos(F)
15457     velraf(2,i)=sin(F)
15458     velraf(3,i)=0.0
15459     if(i.le.pqgvga)then
15460     egvga(i,niv)=EGRaf(i)
15461     do j=1,3
15462     pntgvga(j,i,niv)=pntraf(j,i)
15463     velgvga(j,i,niv)=velraf(j,i)
15464     enddo
15465     ganumat(i,niv)=NAtGRaf(i)
15466     ganumshl(i,niv)=NShAtGRaf(i)
15467     endif
15468    
15469     if(qtagam .eq. pqtagam)then
15470     qOverflowagam=qOverflowagam+1
15471     if(sOverflowagam.eq.0)then
15472     qsOverflowagam=qsOverflowagam+1
15473     sOverflowagam=1
15474     endif
15475     else
15476     qtagam=qtagam+1
15477     etagam(qtagam)=EGRaf(i)
15478     do j=1,3
15479     rtagam(j,qtagam)=pntraf(j,i)
15480     vtagam(j,qtagam)=velraf(j,i)
15481     enddo
15482     nVolagam(qtagam)=nv
15483     nAtagam(qtagam)=NAtGRaf(i)
15484     nShlagam(qtagam)=NShAtGRaf(i)
15485     Stagam(qtagam)=1
15486     endif
15487     enddo
15488    
15489     end
15490     +DECK,RAFFLEV2.
15491     subroutine rafflevirt2(nv,niv)
15492    
15493     implicit none
15494    
15495     integer nv,niv
15496    
15497     c include 'GoEvent.inc'
15498     +SEQ,GoEvent.
15499     c include 'ener.inc'
15500     +SEQ,ener.
15501     c include 'atoms.inc'
15502     +SEQ,atoms.
15503     c include 'matters.inc'
15504     +SEQ,matters.
15505     c include 'crosec.inc'
15506     +SEQ,crosec.
15507     c include 'raffle.inc'
15508     +SEQ,raffle.
15509     c include 'volume.inc'
15510     +SEQ,volume.
15511     c include 'track.inc'
15512     +SEQ,track.
15513     c include 'lsgvga.inc'
15514     +SEQ,lsgvga.
15515     c include 'abs.inc'
15516     +SEQ,abs.
15517    
15518     integer i,j,nmt,nmta
15519     real ranfl
15520     real*8 rr
15521     real*8 rrr
15522    
15523     esgvga(niv)=ESGRaf
15524     if(QGRaf.le.pqgvga)then
15525     qgvga(niv)=QGRaf
15526     else
15527     qgvga(niv)=pqgvga
15528     endif
15529     do i=1,QGRaf
15530     rr=ranfl()
15531     rr=rr*vlenmtk(nv)
15532     rrr=rr
15533     do nmt=nmtkvol1(nv),nmtkvol2(nv)
15534     if(rrr.le.lenmtk(nmt))then
15535     do j=1,3
15536     pntraf(j,i)=pntmtk(j,nmt)+rrr*velmtk(j,nmt)
15537     enddo
15538     nmta=nmt
15539     go to 10
15540     else
15541     rrr=rrr-lenmtk(nmt)
15542     endif
15543     enddo
15544     write(oo,*)' worning in rafflevirt2: strange step'
15545     nmta=nmtkvol2(nv)
15546     do j=1,3
15547     pntraf(j,i)=pntmtk(j,nmta)+
15548     + vlenmtk(nv)*velmtk(j,nmta)
15549     enddo
15550    
15551     10 continue
15552    
15553     call Ncirclesim(
15554     + e1mtk(1,nmta),e2mtk(1,nmta),e3mtk(1,nmta),
15555     + velraf(1,i))
15556    
15557     if(i.le.pqgvga)then
15558     egvga(i,niv)=EGRaf(i)
15559     do j=1,3
15560     pntgvga(j,i,niv)=pntraf(j,i)
15561     velgvga(j,i,niv)=velraf(j,i)
15562     enddo
15563     ganumat(i,niv)=NAtGRaf(i)
15564     ganumshl(i,niv)=NShAtGRaf(i)
15565     endif
15566    
15567     c write(oo,*)' rafflevirt1:'
15568     c write(oo,*)(rst(j),j=1,3)
15569     c write(oo,*)(wid(j),j=1,3)
15570     c write(oo,*)(pntgvga(j,i,nsv),j=1,3)
15571     c write(oo,*)(vel(j),j=1,3)
15572     c write(oo,*)(velgvga(j,i,nsv),j=1,3)
15573     c ganumat(i,niv)=NAtGRaf(i)
15574     c ganumshl(i,niv)=NShAtGRaf(i)
15575    
15576     if(qtagam .eq. pqtagam)then
15577     qOverflowagam=qOverflowagam+1
15578     if(sOverflowagam.eq.0)then
15579     qsOverflowagam=qsOverflowagam+1
15580     sOverflowagam=1
15581     endif
15582     else
15583     qtagam=qtagam+1
15584     etagam(qtagam)=EGRaf(i)
15585     do j=1,3
15586     rtagam(j,qtagam)=pntraf(j,i)
15587     vtagam(j,qtagam)=velraf(j,i)
15588     enddo
15589     nVolagam(qtagam)=nv
15590     nAtagam(qtagam)=NAtGRaf(i)
15591     nShlagam(qtagam)=NShAtGRaf(i)
15592     Stagam(qtagam)=1
15593     endif
15594     enddo !i=1,QGRaf
15595    
15596     end
15597     +DECK,RAFFLE.
15598     subroutine raffle(nm,x,e)
15599    
15600     implicit none
15601    
15602     c include 'GoEvent.inc'
15603     +SEQ,GoEvent.
15604     c include 'ener.inc'
15605     +SEQ,ener.
15606     c include 'atoms.inc'
15607     +SEQ,atoms.
15608     c include 'matters.inc'
15609     +SEQ,matters.
15610     c include 'crosec.inc'
15611     +SEQ,crosec.
15612     c include 'raffle.inc'
15613     +SEQ,raffle.
15614    
15615     integer nm
15616     real x
15617     real e
15618    
15619    
15620     integer nshc,n,ierror
15621     real eran
15622     real xran,dran
15623     integer iran
15624     integer rquan
15625    
15626     QGRaf=0
15627     e=0.0
15628    
15629     do nshc=1,QShellC(nm)
15630    
15631     call lspois(quan(nshc,nm)*x,rquan,ierror)
15632     if(ierror.ne.0)then
15633     write(oo,*)' error in raffle: lspois returned ',
15634     + 'sign of error,'
15635     write(oo,*)' quan(nshc,nm)*x=',quan(nshc,nm)*x
15636     write(oo,*)' quan(nshc,nm)=',quan(nshc,nm)
15637     write(oo,*)' x=',x
15638     write(oo,*)' nshc=',nshc,' nm=',nm
15639     stop 'error in poisson'
15640     endif
15641    
15642     do n=1,rquan
15643    
15644     if(QGRaf.eq.pQGRaf)then
15645     write(oo,*)' Worning og raffle: too much ',
15646     + ' photons: QGRaf=',QGRaf
15647     write(oo,*)' other wiil be ignored'
15648     go to 10
15649     endif
15650    
15651     QGRaf=QGRaf+1
15652    
15653    
15654     call lhisran(fadda(1,nshc,nm),qener,1.0,1.0,xran)
15655    
15656     iran=xran
15657     if(iran.lt.1.or.iran.gt.qener)then
15658     write(oo,*)' Worning of raffle: iran=',iran,
15659     + ' xran=',xran
15660     if(iran.lt.1)then
15661     iran=1
15662     else
15663     iran=qener
15664     endif
15665     endif
15666     dran=xran-iran
15667     eran=ener(iran)+(ener(iran+1)-ener(iran))*dran
15668     c if(nshc.eq.1)then
15669     c write(oo,*)' xran,iran,dran=',xran,iran,dran
15670     c write(oo,*)' ener(iran),ener(iran+1),eran=',
15671     c + ener(iran),ener(iran+1),eran
15672     c endif
15673     e=e+eran
15674     EGRaf(QGRaf)=eran
15675     NAtGRaf(QGRaf)=NAtAC(nshc,nm)
15676     NShAtGRaf(QGRaf)=NSheC(nshc,nm)
15677    
15678     enddo
15679    
15680     enddo
15681    
15682     10 continue
15683    
15684     ESGraf=e
15685    
15686     end
15687     +DECK,PRIRAFFL.
15688     subroutine PriRaffle
15689    
15690     c print the virt. ioniz. photons
15691    
15692     implicit none
15693    
15694     c include 'GoEvent.inc'
15695     +SEQ,GoEvent.
15696     c include 'raffle.inc'
15697     +SEQ,raffle.
15698    
15699     integer i
15700    
15701     if(soo.eq.0)return
15702     write(oo,*)
15703     write(oo,*)' PriRaffle: virt. ioniz. photons'
15704     write(oo,*)' QGRaf= ',QGRaf,' ESGRaf=',ESGRaf
15705     if(QGRaf.gt.0)then
15706     write(oo,*)' EGRaf(i) NAtGRaf(i) NShAtGRaf(i)'
15707     do i=1,QGRaf
15708     write(oo,'(1X,e12.5,2(i12))')
15709     + EGRaf(i), NAtGRaf(i), NShAtGRaf(i)
15710     enddo
15711     endif
15712    
15713     end
15714     +DECK,GoGam.
15715     subroutine GOGam
15716    
15717     c make absorption of the real photon
15718     c and pass it to the virt photon
15719    
15720     implicit none
15721    
15722     c include 'GoEvent.inc'
15723     +SEQ,GoEvent.
15724     c include 'abs.inc'
15725     +SEQ,abs.
15726     c include 'rga.inc'
15727     +SEQ,rga.
15728     integer i,j
15729     integer isabs,nmat,nmshl
15730     c real*8 curpnt(3)
15731     c real dnst
15732     integer num
15733    
15734     do i=crga,qrga
15735     c do j=1,3
15736     c curpnt(j)=pntrga(j,i)
15737     c enddo
15738     num=nVolrga(i)
15739     call lsta_abs1
15740     + (erga(i),i,pntrga(1,i),velrga(1,i),num,
15741     + isabs,nmat,nmshl)
15742     if(isabs.eq.1)then
15743     if(qtagam .eq. pqtagam)then
15744     qOverflowagam=qOverflowagam+1
15745     if(sOverflowagam.eq.0)then
15746     qsOverflowagam=qsOverflowagam+1
15747     sOverflowagam=1
15748     endif
15749     else
15750     qtagam=qtagam+1
15751     etagam(qtagam)=erga(i)
15752     do j=1,3
15753     c rtagam(j,qtagam)=curpnt(j)
15754     rtagam(j,qtagam)=pntrga(j,i)
15755     vtagam(j,qtagam)=velrga(j,i)
15756     enddo
15757     nVolagam(qtagam)=num
15758     nAtagam(qtagam)=nmat
15759     nShlagam(qtagam)=nmshl
15760     Stagam(qtagam)=Strga(i)
15761     c densi(qtagam)=dnst
15762     endif
15763     else
15764     SFrga(i)=1
15765     endif
15766     enddo
15767     crga=qrga+1
15768     end
15769     +DECK,LSTAABS1.
15770     subroutine lsta_abs1(eg,nrga,curpnt,veloc,num,isabs,nmat,nmshl)
15771    
15772     c make step to end of matter or to absorption point
15773     c curpnt - current point of photon
15774     c veloc - cosine
15775     c num - number of volume
15776     c isabs - sign of absorbtion
15777    
15778     implicit none
15779    
15780     c include 'GoEvent.inc'
15781     +SEQ,GoEvent.
15782     c include 'abs.inc'
15783     +SEQ,abs.
15784    
15785     real eg,veloc(3)
15786     real*8 curpnt(3)
15787     integer num
15788     integer nrga,isabs,nmat,nmshl
15789     c real dnst
15790     integer i
15791     real*8 mleng,xleng
15792    
15793    
15794     do i=1,1000 ! number of mat is about 10
15795    
15796     isabs=0
15797     if(i.eq.1.and.num.ne.0)goto 10
15798     call VolNumZcoor(curpnt(3),veloc(3),num)
15799     10 if(num.eq.0)return
15800     call VolPathLeng(curpnt(3),veloc,num,mleng)
15801     c write(oo,*)' num=',num,' mleng=',mleng
15802     call lsta_abs(eg,nrga,num,mleng,isabs,xleng,nmat,nmshl)
15803     curpnt(1)=curpnt(1)+xleng*veloc(1)
15804     curpnt(2)=curpnt(2)+xleng*veloc(2)
15805     curpnt(3)=curpnt(3)+xleng*veloc(3)
15806    
15807     if(isabs.eq.1)return
15808    
15809     enddo
15810    
15811     end
15812    
15813    
15814    
15815     subroutine lsta_abs(eg,nrga,nvol,mleng,
15816     + isabs,xleng,nm_at,nmshl)
15817    
15818     c Raffle the absorbtion in volume number nvol
15819     c eg - energy of the photon
15820     c isabs - sign of absorbtion
15821     c xleng - coord of point of absorbtion
15822     c nm_at and nmshl - numbes of the atom and the shell
15823     implicit none
15824    
15825     c include 'GoEvent.inc'
15826     +SEQ,GoEvent.
15827     c include 'ener.inc'
15828     +SEQ,ener.
15829     c include 'atoms.inc'
15830     +SEQ,atoms.
15831     c include 'matters.inc'
15832     +SEQ,matters.
15833     c include 'volume.inc'
15834     +SEQ,volume.
15835     c include 'rga.inc'
15836     +SEQ,rga.
15837     c include 'shl.inc'
15838     +SEQ,shl.
15839    
15840     real eg
15841     real*8 xleng,mleng
15842     integer nrga,nvol,isabs,nm_at,nmshl
15843     integer nmat
15844     c real dnst
15845     real rrr(100)
15846     integer iarrr(100),isrrr(100)
15847     integer ia,is
15848     real r,s
15849     real ranfl
15850     integer i,j,k
15851     c integer n
15852     real thr
15853     integer iatm,natm
15854    
15855     nmat=nMatVol(nvol)
15856    
15857     if(nmat.eq.0)then
15858     isabs=0
15859     xleng=mleng
15860     return
15861     endif
15862    
15863     r=ranfl()
15864     if(r.gt.0.99999)then
15865     isabs=0
15866     xleng=mleng
15867     return
15868     endif
15869     j=qener+1
15870     do i=2,qener+1
15871     if(eg.lt.ener(i))then
15872     j=i-1
15873     go to 10
15874     endif
15875     enddo
15876     if(j.eq.qener+1)then
15877     isabs=0
15878     xleng=mleng
15879     return
15880     endif
15881     10 k=0
15882     s=0
15883     do ia=1,QAtMat(nmat)
15884     do iatm=1,qatm
15885     if(Zat(AtMat(ia,nmat)).eq.charge(iatm))then
15886     natm=iatm
15887     go to 15
15888     endif
15889     enddo
15890     natm=0
15891     15 do is=1,QShellAt(AtMat(ia,nmat))
15892     c write(oo,*)
15893     c + ' ia,AtMat(ia,nmat),is,ThresholdAt(is,AtMat(ia,nmat))='
15894     c write(oo,*)
15895     c + ia,AtMat(ia,nmat),is,ThresholdAt(is,AtMat(ia,nmat))
15896     if(natm.eq.0)then
15897     thr=ThresholdAt(is,AtMat(ia,nmat))
15898     else
15899     thr=eshell(natm,is)
15900     endif
15901     if(eg.gt.thr)then
15902     k=k+1
15903     rrr(k)=PhotAt(j,is,AtMat(ia,nmat))
15904     + *WeightAtMat(ia,nmat)
15905    
15906     iarrr(k)=ia
15907     isrrr(k)=is
15908     s=s+rrr(k)
15909     c write(oo,*)' PhotAt(j,is,AtMat(ia,nmat))=',
15910     c + PhotAt(j,is,AtMat(ia,nmat))
15911     c write(oo,*)' WeightAtMat(ia,nmat)=',
15912     c + WeightAtMat(ia,nmat)
15913     c write(oo,*)' s=',s
15914     endif
15915     enddo
15916     enddo
15917     c write(oo,*)(rrr(i),i=1,3)
15918     if(k.eq.0)then
15919     isabs=0
15920     xleng=mleng
15921     return
15922     endif
15923     s=s* ElDensMat(nmat)/Z_Mean(nmat) *5.07E10
15924     xleng=-alog(1.0-r)/s
15925    
15926     c write(oo,*)' xleng=',xleng,' r=',r,' j=',j,' nmat=',nmat
15927     c write(oo,*)' k=',k,' eg=',eg,' s=',s
15928     if(xleng.gt.mleng)then
15929     isabs=0
15930     xleng=mleng
15931     else
15932     isabs=1
15933     c r=ranfl()
15934     call lhispre(rrr,k)
15935     c write(oo,*)(rrr(i),i=1,3)
15936     call lhisran(rrr,k,1.0,1.0,r)
15937     c write(oo,*)' r=',r
15938     i=r
15939     if(i.lt.1) i=1
15940     if(i.gt.k)i=k
15941     nm_at=AtMat(iarrr(i),nmat)
15942     nmshl=isrrr(i)
15943     c write(oo,*)' i=',i
15944    
15945     c write(oo,*)' nm_at=',nm_at,' nmshl=',nmshl
15946     c dnst=densit(nmat)
15947    
15948     endif
15949    
15950     end
15951    
15952     +DECK,AbsGam.
15953    
15954    
15955    
15956     subroutine AbsGam
15957    
15958     c make absorption in the knowing point
15959     c of the all photons in the abs.inc
15960     c All of them are transferred to the real photons rga.inc
15961     c and to the delta electrons del.inc
15962     implicit none
15963    
15964     c include 'GoEvent.inc'
15965     +SEQ,GoEvent.
15966     c include 'abs.inc'
15967     +SEQ,abs.
15968    
15969     c real eg,veloc(3),abspnt(3)
15970     c integer numat,numshl
15971     integer i
15972     do i=ctagam,100000
15973     if(i.gt.qtagam)go to 10
15974     call lsta_abs3
15975     + (i,etagam(i),rtagam(1,i),vtagam(1,i),
15976     + nVolagam(i),nAtagam(i),nShlagam(i),Stagam(i),upagam(1,i))
15977    
15978     enddo
15979     10 ctagam=qtagam+1
15980     end
15981    
15982    
15983    
15984     subroutine lsta_abs3(iagam,eg,abspnt,veloc,
15985     + nVolagam,nAtagam,nShlagam,Stagam,upagam)
15986    
15987     c make absorption in the knowing point
15988     c and generate secondaries photons and delta electrons
15989     c eg - enegy of photon
15990     c abspnt - point of absorbtion
15991     c nVolagam - number of matter
15992     c nAtagam - number of atom
15993     c nShlagam - number of shell
15994     c Stagam - sign of source of this photon
15995     c veloc - direction of veloc.
15996    
15997     implicit none
15998    
15999     c include 'GoEvent.inc'
16000     +SEQ,GoEvent.
16001     c include 'rga.inc'
16002     +SEQ,rga.
16003     c include 'del.inc'
16004     +SEQ,del.
16005     c include 'shl.inc'
16006     +SEQ,shl.
16007    
16008     integer iagam
16009     real eg,veloc(3)
16010     real*8 abspnt(3)
16011     integer nVolagam,nAtagam,nShlagam,Stagam,upagam(pqup)
16012     real eedel(pqsel),velocdel(3,pqsel)
16013     real eedga(pqsga),velocdga(3,pqsga)
16014     integer nndel,nndga
16015    
16016     integer i,j
16017     real s
16018    
16019     call lsta_abs2(eg,abspnt,veloc,nVolagam,nAtagam,nShlagam,
16020     + nndel,eedel,velocdel,nndga,eedga,velocdga)
16021    
16022     if(nndga.gt.0.and.Stagam.eq.9999)then
16023     write(oo,*)' Worning of lsta_abs3:'
16024     write(oo,*)' too many generetion of secondary ',
16025     + ' photons, Stagam=',Stagam,' nndga=',nndga
16026     write(oo,*)' Others will be ignored'
16027     go to 10
16028     endif
16029    
16030     s=0.0
16031     do i=1,nndel
16032     s=s+eedel(i)
16033     enddo
16034     do i=1,nndga
16035     s=s+eedga(i)
16036     enddo
16037     c if(s.gt.eg)then
16038     if( (s-eg) .gt. 1.0e-6 * (s+eg) )then
16039     write(oo,*)'worning of lsta_abs3:',
16040     + ' break of energy preservation'
16041     write(oo,*)' eg=',eg,' s=',s
16042     write(oo,*)' nAtagam=',nAtagam,' nShlagam',nShlagam
16043     write(oo,*)' nndel=',nndel
16044     do i=1,nndel
16045     write(oo,*)' eedel(i)=',eedel(i)
16046     enddo
16047     do i=1,nndga
16048     write(oo,*)' eedga(i)=',eedga(i)
16049     enddo
16050     endif
16051    
16052    
16053     do i=1,nndga
16054    
16055     if(qrga .eq. pqrga)then
16056     qOverflowrga=qOverflowrga+1
16057     if(sOverflowrga.eq.0)then
16058     qsOverflowrga=qsOverflowrga+1
16059     sOverflowrga=1
16060     endif
16061     else
16062    
16063     qrga=qrga+1
16064    
16065     c if(qrga.eq.pqrga)then
16066     c write(oo,*)' wroning lsta_abs3:',
16067     c + ' too much of real photons'
16068     c write(oo,*)' other will be ignored'
16069     c go to 10
16070     c endif
16071    
16072     Strga(qrga)=Stagam+1
16073     Ptrga(qrga)=iagam
16074     do j=1,pqup
16075     uprga(j,qrga)=upagam(j)
16076     enddo
16077     SFrga(qrga)=0
16078     do j=1,3
16079     pntrga(j,qrga)=abspnt(j)
16080     enddo
16081     do j=1,3
16082     velrga(j,qrga)=velocdga(j,i)
16083     enddo
16084     erga(qrga)=eedga(i)
16085     nVolrga(qrga)=nVolagam
16086     endif
16087     enddo
16088     10 continue
16089     c write(oo,*)' nndel=',nndel
16090     do i=1,nndel
16091     if(qdel .eq. pqdel)then
16092     qOverflowDel=qOverflowDel+1
16093     if(sOverflowDel.eq.0)then
16094     qsOverflowDel=qsOverflowDel+1
16095     sOverflowDel=1
16096     endif
16097     else
16098    
16099     c if(qdel.eq.pqdel)then
16100     c write(oo,*)' wroning lsta_abs3:',
16101     c + ' too much of delta electr.'
16102     c write(oo,*)' other will not be taken into account'
16103     c go to 20
16104     c endif
16105     qdel=qdel+1
16106     Stdel(qdel)=Stagam
16107     Ptdel(qdel)=iagam
16108     do j=1,pqup
16109     updel(j,qdel)=upagam(j)
16110     enddo
16111     if(i.eq.1)then
16112     SOdel(qdel)=0
16113     else
16114     SOdel(qdel)=1
16115     endif
16116     do j=1,3
16117     pntdel(j,qdel)=abspnt(j)
16118     enddo
16119     do j=1,3
16120     veldel(j,qdel)=velocdel(j,i)
16121     enddo
16122     edel(qdel)=eedel(i)
16123     nVoldel(qdel)=nVolagam
16124     rangepdel(qdel)=0.0
16125     rangedel(qdel)=0.0
16126     endif
16127     enddo
16128    
16129    
16130    
16131     20 end
16132    
16133    
16134    
16135    
16136    
16137     subroutine lsta_abs2(eg,abspnt,veloc,nVolagam,nAtagam,nShlagam,
16138     + nndel,eedel,velocdel,nndga,eedga,velocdga)
16139    
16140    
16141     c make absorption in the knowing point
16142     c and generate secondaries photons and delta electrons
16143     c eg - enegy of photon
16144     c abspnt - point of absorbtion
16145     c veloc - direction of veloc.
16146     c nVolagam - number of matter
16147     c nAtagam - number of atom
16148     c nShlagam - number of shell
16149     c output:
16150     c nndel - quantity of delta-electrons
16151     c eedel - enegies of the delta-electrons
16152     c velocdel - enegies of the delta-electrons
16153     c nndga,eedga,velocdga - the same for secondary photons
16154    
16155     implicit none
16156    
16157     c include 'shl.inc'
16158     +SEQ,shl.
16159     c include 'ener.inc'
16160     +SEQ,ener.
16161     c include 'atoms.inc'
16162     +SEQ,atoms.
16163    
16164     real eg,veloc(3)
16165     real*8 abspnt(3)
16166     integer nVolagam,nAtagam,nShlagam
16167     real eedel(pqsel),velocdel(3,pqsel)
16168     real eedga(pqsga),velocdga(3,pqsga)
16169     integer nndel,nndga
16170    
16171     integer num
16172     integer numat,numshl
16173     integer i,j
16174     real r
16175     real hdist
16176    
16177     real ranfl
16178    
16179     hdist=0.0
16180     c if(numat.lt.0.or.numat.gt.qatm)then
16181     c stop 'wrong numat'
16182     c endif
16183     c if(numat.gt.0)then
16184     c if(numshl.lt.1.or.numshl.gt.qshl(numat))then
16185     c stop 'wrong numshl'
16186     c endif
16187     c endif
16188    
16189    
16190     num=0
16191     c call lsta_fmat(abspnt(3),veloc(3),num)
16192     nndel=0
16193     nndga=0
16194     c write(oo,*)' num=',num
16195     if(nVolagam.eq.0)then
16196     return
16197     endif
16198    
16199     nndel=1
16200     do i=1,3
16201     velocdel(i,nndel)=veloc(i)
16202     enddo
16203     do i=1,qatm
16204     c write(oo,*)' Zat(nAtagam)',Zat(nAtagam)
16205     c write(oo,*)' charge(i)',charge(i)
16206     if(Zat(nAtagam).eq.charge(i))then
16207     numat=i
16208     go to 5
16209     endif
16210     enddo
16211     c The place of question
16212     c Several lines was commented
16213     eedel(nndel)=eg-ThresholdAt(nShlagam,nAtagam)
16214     if(eedel(nndel).le.0.0)then
16215     hdist=-eedel(nndel)
16216     eedel(nndel)=0.0
16217     endif
16218     c
16219     c write(oo,*)' nShlagam=',nShlagam,
16220     c + ' QShellAt(nAtagam)=',QShellAt(nAtagam)
16221     if(nShlagam.lt.QShellAt(nAtagam))then
16222     nndel=nndel+1
16223     eedel(nndel)=ThresholdAt(nShlagam,nAtagam)-hdist-
16224     + 2.0*ThresholdAt(QShellAt(nAtagam),nAtagam)
16225     c eedel(nndel)=ThresholdAt(nShlagam,nAtagam)-hdist
16226     if(eedel(nndel).le.0.0)then
16227     nndel=nndel-1
16228     goto 2
16229     endif
16230     call sfersim(velocdel(1,nndel))
16231     endif
16232     2 continue
16233     return
16234    
16235     5 continue
16236    
16237     c asumed that the last shell is zero energy or 1 eV
16238     c if(nAtagam.ne.0)then
16239     eedel(nndel)=eg-eshell(nShlagam,numat)
16240     c write(oo,*)' eg=',eg,' nShlagam=',nShlagam,' numat=',numat
16241     c write(oo,*)' eedel(nndel)=',eedel(nndel)
16242     c else
16243     c eedel(nndel)=eg-20.0e-6 !avarege energy of last shell
16244     c endif
16245    
16246     if(eedel(nndel).le.0.0)then
16247     hdist=-eedel(nndel)
16248     eedel(nndel)=0.0
16249     endif
16250    
16251     c if(numat.gt.0)then
16252     numshl=nShlagam
16253     if(qschl(numshl,numat).gt.0)then
16254    
16255    
16256     r=ranfl()
16257     j=qschl(numshl,numat)
16258    
16259     if(j.gt.0)then
16260     j=qschl(numshl,numat)
16261     do i=1, qschl(numshl,numat)
16262     if(r.lt.secprobch(i,numshl,numat))then
16263     j=i
16264     go to 10
16265     endif
16266     enddo
16267     10 continue
16268     c write(oo,*)' prob: r=',r,' j=',j
16269    
16270     do i=1,qsel(j,numshl,numat)
16271     nndel=nndel+1
16272     eedel(nndel)=secenel(i,j,numshl,numat)
16273     + -hdist
16274     if(eedel(nndel).lt.0)then
16275     hdist=-eedel(nndel)
16276     eedel(nndel)=0.0
16277     else
16278     hdist=0.0
16279     endif
16280     call sfersim(velocdel(1,nndel))
16281     enddo
16282     do i=1,qsga(j,numshl,numat)
16283     nndga=nndga+1
16284     eedga(nndga)=secenga(i,j,numshl,numat)
16285     + -hdist
16286     if(eedga(nndga).lt.0)then
16287     hdist=-eedga(nndga)
16288     eedga(nndga)=0.0
16289     else
16290     hdist=0.0
16291     endif
16292     call sfersim(velocdga(1,nndga))
16293     enddo
16294    
16295     endif
16296     else
16297     if(nShlagam.lt.QShellAt(nAtagam))then
16298     nndel=nndel+1
16299     eedel(nndel)=eshell(nShlagam,numat)-hdist-
16300     + 2.0*eshell(qshl(numat),numat)
16301     if(eedel(nndel).le.0.0)then
16302     nndel=nndel-1
16303     goto 20
16304     endif
16305     call sfersim(velocdel(1,nndel))
16306     endif
16307     20 continue
16308    
16309     endif
16310    
16311     c endif
16312    
16313     end
16314     +DECK,IniBdel5.
16315    
16316    
16317     c
16318     c Package for tracing of delta-electrons.
16319     c
16320    
16321    
16322     subroutine InisBdel
16323    
16324     c
16325     c This is routine for standart initialization.
16326     c It is strictly recommended.
16327     c
16328     c call IniBdel(1,0.0001, 0.00005*4.0e-3, 0.1)
16329     call IniBdel(2,0.0001, 0.001*4.0e-3, 0.1)
16330    
16331     end
16332    
16333    
16334     subroutine IniBdel(psruthBdel,peMinBdel,pmlamBdel,pmTetacBdel)
16335     c
16336     c Initialization of the delta-eleectron tracing package
16337     c
16338     implicit none
16339    
16340     c include 'GoEvent.inc'
16341     +SEQ,GoEvent.
16342     c include 'ener.inc'
16343     +SEQ,ener.
16344     c include 'atoms.inc'
16345     +SEQ,atoms.
16346     c include 'matters.inc'
16347     +SEQ,matters.
16348     c include 'crosec.inc'
16349     +SEQ,crosec.
16350     c include 'volume.inc'
16351     +SEQ,volume.
16352     c include 'bdel.inc'
16353     +SEQ,bdel.
16354     c include 'cconst.inc'
16355     +SEQ,cconst.
16356    
16357     integer psruthBdel
16358     real peMinBdel,pmlamBdel,pmTetacBdel
16359     integer n,nm,na,na1,nen
16360     real dedx1,sde,sde2
16361     c real dedx,dedx2
16362     real rms,rm(pQAt),adens
16363     real mT,A
16364     real*8 B,r
16365     real msig,x
16366     integer sienred
16367     real rr,ek,cor
16368     real fcalcsCBdel
16369     c real s
16370     integer nang
16371     integer nprev, nnext, qempt
16372     integer nempt(pqAt),nqe
16373     real*8 k,c
16374     real*8 f1,f2,z1,z2
16375     integer nam
16376     real*8 sd,st,st1
16377     integer n1,n2,nener
16378    
16379    
16380     sruthBdel=psruthBdel
16381     eMinBdel=peMinBdel
16382     mlamBdel=pmlamBdel
16383     mTetacBdel=pmTetacBdel
16384     if(eMinBdel.lt.ener(1))then
16385     write(oo,*)' eMinBdel is too small, eMinBdel=',eMinBdel
16386     stop
16387     endif
16388     c do n=2,qener
16389     c if(eMinBdel.lt.ener(n))then
16390     c iMinBdel=n-1
16391     c go to 10
16392     c endif
16393     c enddo
16394     c write(oo,*)' worning: eMinBdel is too hige, eMinBdel=',eMinBdel
16395     c iMinBdel=qener+1
16396     c10 continue
16397     do n=1,3
16398     e1Bdel(n)=0.0
16399     e2Bdel(n)=0.0
16400     e3Bdel(n)=0.0
16401     enddo
16402     sturnBdel=0.0
16403     do nm=1,pQMat
16404     do nen=1,qener
16405     TetacBdel(nen,nm)=0.0
16406     enddo
16407     enddo
16408     TetaBdel=0.0
16409     c do n=iMinBdel,qener
16410     c call IniPart(enerc(n),0.511)
16411     c call IniCrosec
16412     do nm=1,pQMat
16413     if(qAtMat(nm).gt.0)then
16414     c if(sMatC(nm).gt.0)then
16415     rms=0.0
16416     do na=1,QAtMat(nm)
16417     rms=rms+Aat(AtMat(na,nm))*WeightAtMat(na,nm)
16418     enddo
16419     do na=1,QAtMat(nm)
16420     rm(na)=Aat(AtMat(na,nm))*WeightAtMat(na,nm)/rms
16421     enddo
16422     sienred=0
16423     do n=qener+1,1,-1
16424     if(sienred.eq.0)then
16425     sde=0.0
16426     sde2=0.0
16427     do na=1,QAtMat(nm)
16428     adens=DensMat(nm)*rm(na)
16429     c write(oo,*)' adens=',adens
16430     * call lsrelp(
16431     * + Aat(AtMat(na,nm)),float(Zat(AtMat(na,nm))),adens,
16432     * + 2000.0*ener(n)/1000.0,dedx)
16433     * if(dedx.lt.0.0)dedx=0.0
16434    
16435     * call lsrelm(
16436     * + Aat(AtMat(na,nm)),float(Zat(AtMat(na,nm))),adens,
16437     * + 105.65/0.511*ener(n)/1000.0,dedx2)
16438     * if(dedx2.lt.0.0)dedx2=0.0
16439    
16440     * sde=sde+dedx*adens
16441     * sde2=sde2+dedx2*adens
16442    
16443     enddo
16444     * sde=sde*1000.0
16445     * sde2=sde2*1000.0
16446    
16447    
16448     c call lsrelp(
16449     c + A_Mean(nm),Z_Mean(nm),DensMat(nm),
16450     c + 2000.0*enerc(n)/1000.0,dedx)
16451     c dedx=dedx*DensMat(nm)*1000.0
16452     c eLossBdel(n,nm)=sde
16453     call lstREL1(ener(n)/1000.0, -1.0, nm, dedx1)
16454     dedx1=dedx1*1000.0
16455     eLossBdel(n,nm)=dedx1
16456     c write(oo,*)' n=',n,' nm=',nm,' ener(n)=',ener(n)
16457     c write(oo,*)' sde=',sde,
16458     c + ' dedx1=',dedx1 ,' sde2=',sde2
16459     if(n.lt.qener)then
16460     if(eLossBdel(n,nm).lt.0.5*eLossBdel(n+1,nm))then
16461     sienred=1
16462     eLossBdel(n,nm)=0.5*eLossBdel(n+1,nm)
16463     endif
16464     endif
16465     else
16466     eLossBdel(n,nm)=eLossBdel(n+1,nm)
16467     endif
16468     enddo
16469     c endif
16470     endif
16471     enddo
16472     c stop
16473    
16474     do nen=1,qener
16475     beta2Bdel(nen)=
16476     + (2.0*ELMAS*enerc(nen) + enerc(nen)*enerc(nen)) /
16477     + ((ELMAS + enerc(nen)) * (ELMAS + enerc(nen)))
16478     betaBdel(nen) = sqrt(beta2Bdel(nen))
16479     momentum2Bdel(nen)= enerc(nen)*enerc(nen) + 2.0*ELMAS*enerc(nen)
16480     momentumBdel(nen) = sqrt(momentum2Bdel(nen))
16481     enddo
16482    
16483     if(sruthBdel.ne.2)then
16484    
16485     do nm=1,pQMat
16486     if(qAtMat(nm).gt.0)then
16487     do nen=1,qener
16488    
16489     ek=enerc(nen)*1000.0
16490     if(ek.le.10.0)then
16491     rr=1.0e-3 * A_Mean(nm)/Z_Mean(nm) * 3.872e-3 * ek ** 1.492
16492     rr=rr/DensMat(nm)
16493     else
16494     rr=1.0e-3 * 6.97e-3 * ek ** 1.6
16495     rr=rr/DensMat(nm)
16496     endif
16497     rr=rr*0.1
16498     call correctBdel(enerc(nen),cor)
16499    
16500     if(sruthBdel.eq.1)then
16501    
16502     lamBdel=mlamBdel/DensMatDS(nm)
16503     if(lamBdel.lt.rr) lamBdel=rr
16504     lamBdel=lamBdel*cor
16505    
16506     c if(sisferBdel.eq.1)then
16507     c go to 10
16508     c endif
16509     c Calculate the minimum angle for restriction of field by
16510     c atomic shell
16511     mT=2.0*asin(1.0/
16512     + (2.0*momentumBdel(nen)*Z_Mean(nm)*5.07e2))
16513     rTetacBdel(nen,nm)=mT
16514     c write(oo,*)' mT=',mT
16515     if(mT.lt.mTetacBdel)then
16516     mT=mTetacBdel ! Throw out too slow interaction. They
16517     ! do not influent to anything
16518     endif
16519     c Calculate the cut angle due to mean free part
16520     A = RuthMat(nm)/cor/
16521     + (momentum2Bdel(nen)*beta2Bdel(nen))/(5.07e10)**2
16522     B = (lamBdel*A)
16523     B = sqrt( B / (B+1.0) )
16524     TetacBdel(nen,nm) = 2.0 * asin(B)
16525     c TetacBdel = acos( (B-1.0) / (B+1.0) )
16526     c TetacBdel=2.0*asin(sqrt(lamBdel*A))
16527     c if(TetacBdel.lt.0.2)then
16528     c TetacBdel=0.2
16529    
16530     c If it too little, reset it. It will lead to increasing
16531     c of lamBdel and decriasing of calculation time.
16532     if(TetacBdel(nen,nm) .lt. mT)then
16533     TetacBdel(nen,nm)=mT
16534     B=mT ! B is double precision
16535     r=sin(B/2.0)
16536     lamBdel=1/A * 2.0 * r*r / ( 1 + cos(B) )
16537     * r=cos(TetacBdel(nen,nm))
16538     * lamBdel=A*(1.0+r)/(1.0-r)
16539     * lamBdel=1.0/lamBdel
16540     c lamBdel=(p2*bet2*sin(TetacBdel/2.0)**2) / A
16541     endif
16542    
16543     lamaBdel(nen,nm)=lamBdel
16544     B=TetacBdel(nen,nm)
16545     CosTetac12Bdel(nen,nm)=cos(B/2.0)
16546     SinTetac12Bdel(nen,nm)=sin(B/2.0)
16547     if(TetacBdel(nen,nm).gt.1.5)then
16548     sisferaBdel(nen,nm)=1
16549     else
16550     sisferaBdel(nen,nm)=0
16551     endif
16552    
16553     c debug mode:
16554     c lamaBdel(nen,nm)=2.0*lamaBdel(nen,nm)
16555    
16556     elseif( sruthBdel.eq.0)then ! gaus formula
16557    
16558     c calculate paht lengt from mTetacBdel
16559     msig=mTetacBdel
16560     x=msig / ( sqrt(2.0) * 13.6/(betaBdel(nen)*momentumBdel(nen)))
16561     x=x*x
16562    
16563     c x=x/DensMatDS(nMatVol(nVolBdel))
16564     x=x*RLenMat(nm)*cor
16565     lamBdel = mlamBdel/DensMatDS(nm)
16566     if(lamBdel.lt.rr) lamBdel=rr
16567     lamBdel=lamBdel*cor
16568     c write(oo,*)' x=',x,' rleng=',rleng
16569     c reset if it is too large
16570     if(lamBdel.lt.x)lamBdel=x
16571     lamaBdel(nen,nm)=lamBdel
16572     msigBdel(nen)=sqrt(2.0)*13.6/
16573     + (betaBdel(nen)*momentumBdel(nen))
16574    
16575     c debug mode:
16576     c lamaBdel(nen,nm)=2.0*lamaBdel(nen,nm)
16577     c msigBdel(nen)=0.5*msigBdel(nen)
16578     endif
16579    
16580     enddo ! end of nen
16581     endif ! end of if(qAtMat(nm).gt.0)then
16582     enddo ! end of nm
16583     endif ! if(sruthBdel.ne.2)
16584    
16585     if(sruthBdel.eq.2)then
16586    
16587    
16588     call logscale0(qanCBdel,0.03,real(PI),anCBdel,ancCBdel)
16589    
16590     c call readCBdel
16591     call read1CBdel
16592    
16593     enerCBdel( 1) = 0.5E-3
16594     enerCBdel( 2) = 1.5E-3
16595     enerCBdel( 3) = 2.5E-3
16596     enerCBdel( 4) = 5.5E-3
16597     enerCBdel( 5) = 10.5E-3
16598     enerCBdel( 6) = 21.5E-3
16599     enerCBdel( 7) = 42.5E-3
16600     enerCBdel( 8) = 85.5E-3
16601     enerCBdel( 9) = 170.5E-3
16602     enerCBdel(10) = 341.1E-3
16603     enercCBdel( 1) = 1 E-3
16604     enercCBdel( 2) = 2E-3
16605     enercCBdel( 3) = 4E-3
16606     enercCBdel( 4) = 8E-3
16607     enercCBdel( 5) = 16E-3
16608     enercCBdel( 6) = 32E-3
16609     enercCBdel( 7) = 64E-3
16610     enercCBdel( 8) = 128E-3
16611     enercCBdel( 9) = 256E-3
16612    
16613     do nen=1,qeaCBdel
16614     gammaCBdel(nen) = 1.0 + enercCBdel(nen)/ELMAS
16615     beta2CBdel(nen) = ( 2.0 * enercCBdel(nen)/ELMAS
16616     + + (enercCBdel(nen)/ELMAS)**2 ) /
16617     + gammaCBdel(nen)**2
16618     momentum2CBdel(nen) =
16619     + enercCBdel(nen)*enercCBdel(nen) +
16620     + 2.0*ELMAS*enercCBdel(nen)
16621     enddo
16622    
16623    
16624     do na=1,pqAt
16625    
16626     if(Zat(na).gt.0)then ! atom is meant initialized
16627    
16628     do nen=1,qeaCBdel
16629     mT=1.0/
16630     + (2.0*sqrt(momentum2CBdel(nen))*Zat(na)*5.07e2)
16631     sRcmCBdel(nen,nm)=2.0*asin(mT)
16632     sRmCBdel(nen,na)= 1/4. *
16633     + Zat(na)*Zat(na)*ELRAD*ELRAD*ELMAS*ELMAS/
16634     + ( momentum2CBdel(nen) * beta2CBdel(nen) * mT**4 ) /
16635     + ( 5.07E10 ** 2 ) * 1.E16
16636    
16637     do nang=1,qanCBdel
16638    
16639     sRCBdel(nang,nen,na)= 1/4. *
16640     + Zat(na)*Zat(na)*ELRAD*ELRAD*ELMAS*ELMAS/
16641     + ( momentum2CBdel(nen) * beta2CBdel(nen) *
16642     + sin(ancCBdel(nang)/2.0)**4 ) /
16643     + ( 5.07E10 ** 2 ) * 1.E16
16644    
16645     enddo
16646    
16647     enddo
16648    
16649    
16650     if(sign_ACBdel(na).eq.1)then
16651    
16652     do nen=1,qeaCBdel
16653     do nang=1,qanCBdel
16654     sCBdel(nang,nen,na)=fcalcsCBdel(nang,nen,na)
16655     enddo
16656     enddo
16657    
16658     endif
16659    
16660     endif
16661    
16662     enddo
16663    
16664     ! Fill an empty places
16665     nnext = 0
16666     qempt = 0 ! quantity of the empty places is zero
16667    
16668    
16669    
16670     do na1=1,QseqAt
16671     na=nseqAt(na1)
16672     if(Zat(na).eq.0)then ! atom is meant not initialized
16673     write(oo,*)' error in IniBdel'
16674     stop
16675     endif
16676    
16677     if(sign_ACBdel(na).eq.1)then
16678     nprev=nnext
16679     nnext=na
16680     endif
16681     if(sign_ACBdel(na).eq.0)then
16682     qempt=qempt+1 ! add pointer of empty place
16683     nempt(qempt)=na
16684     endif
16685    
16686     if(sign_ACBdel(na).eq.1 .and. qempt.ne.0)then
16687     if(nprev.eq.0)then ! first filled atom
16688     ! fit by k*Z**2
16689     do nen=1,qeaCBdel
16690     do nang=1,qanCBdel
16691     k=sCBdel(nang,nen,nnext) / Zat(nnext)**2
16692     do nqe=1,qempt
16693     sCBdel(nang,nen,nempt(nqe)) =
16694     + k *Zat(nempt(nqe))**2
16695     enddo ! nqe=1,qempt
16696     enddo ! nang=1,qanCBdel
16697     enddo ! nen=1,qeaCBdel
16698     qempt=0
16699    
16700     else ! fit by previous and this filled atom
16701     ! f = k*Z*(Z+c)
16702     do nen=1,qeaCBdel
16703     do nang=1,qanCBdel
16704     f1=sCBdel(nang,nen,nprev)
16705     f2=sCBdel(nang,nen,nnext)
16706     z1=Zat(nprev)
16707     z2=Zat(nnext)
16708     c = (f1 * z2**2 - f2 * z1**2 ) /
16709     + (f2 * z1 - f1 * z2 )
16710     k = f1 / (z1 * ( z1 + c ) )
16711     do nqe=1,qempt
16712     sCBdel(nang,nen,nempt(nqe)) =
16713     + k*Zat(nempt(nqe))*(Zat(nempt(nqe)) + c)
16714     if(sCBdel(nang,nen,nempt(nqe)).lt.0.)
16715     + sCBdel(nang,nen,nempt(nqe)) = 0.
16716     enddo
16717     enddo
16718     enddo
16719     qempt=0
16720    
16721     endif
16722     endif
16723    
16724    
16725     enddo
16726    
16727     if(qempt.ne.0)then
16728     if(nprev.eq.0)then
16729     write(oo,*)' error in IniBdel: wrong nprev'
16730     stop
16731     endif
16732     nnext=nprev ! so as to use the same lines as above
16733     do nen=1,qeaCBdel
16734     do nang=1,qanCBdel
16735     k=sCBdel(nang,nen,nnext) / Zat(nnext)**2
16736     do nqe=1,qempt
16737     sCBdel(nang,nen,nempt(nqe)) =
16738     + k *Zat(nempt(nqe))**2
16739     enddo ! nqe=1,qempt
16740     enddo ! nang=1,qanCBdel
16741     enddo ! nen=1,qeaCBdel
16742     qempt=0
16743     endif
16744    
16745     c On this point all the atomic cross sections are generated.
16746     c Now it is a high time to generate cross sections
16747     c for initialized materials.
16748    
16749     do nm=1,pQMat
16750     if(qAtMat(nm).gt.0)then
16751    
16752     lamBdel=mlamBdel/DensMat(nm)
16753    
16754     c write(oo,*)' lamBdel=',lamBdel,' mlamBdel=',mlamBdel
16755    
16756     do nen=1,qeaCBdel
16757     do nang=1,qanCBdel
16758     sd=0.
16759     do nam=1,qAtMat(nm)
16760     na=AtMAt(nam,nm)
16761     sd = sd + sCBdel(nang,nen,na) * WeightAtMat(nam,nm)
16762     enddo
16763     sd = sd * 1.0E-16 * 5.07E10 * 5.07E10
16764     c Angstrem**2 -> sm**2
16765     c sm**2 -> MeV**-2
16766     sd=sd * 2.0 * PI * sin(ancCBdel(nang))
16767     smaCBdel(nang,nen,nm)=sd
16768    
16769     enddo ! nang=1,qanCBdel
16770     enddo ! nen=1,qeaCBdel
16771    
16772     do nener=1,qener ! go to working mesh
16773     ! ( The enercCBdel is to rare )
16774     if(enerc(nener).lt.500.0e-6)then
16775     do nang=1,qanCBdel
16776     smatCBdel(nang,nener,nm)=0.0
16777     enddo
16778     lamaBdel(nener,nm)=0.0
16779     tsmatCBdel(nener,nm)=0.0
16780     else
16781    
16782     ek=enerc(nener)*1000.0 ! Calculate step lenght by usual formula
16783     if(ek.le.10.0)then
16784     rr = 1.0e-3 * A_Mean(nm)/Z_Mean(nm) *
16785     + 3.872e-3 * ek ** 1.492
16786     rr=rr/DensMat(nm)
16787     else
16788     rr=1.0e-3 * 6.97e-3 * ek ** 1.6
16789     rr=rr/DensMat(nm)
16790     endif
16791     rrCBdel(nener,nm)=rr
16792     rr=rr*koefredCBdel
16793     if(rr.lt.lamBdel) rr=lamBdel
16794     do nen=2,qeaCBdel
16795     if(enercCBdel(nen).gt.enerc(nener))then
16796     n2=nen
16797     goto 100
16798     endif
16799     enddo
16800     n2=qeaCBdel
16801     100 continue
16802     n1=n2-1
16803     do nang=1,qanCBdel
16804     ! Linear interpolation
16805     smatCBdel(nang,nener,nm)=smaCBdel(nang,n1,nm) +
16806     + (smaCBdel(nang,n2,nm) - smaCBdel(nang,n1,nm)) *
16807     + (enerc(nener) - enercCBdel(n1)) /
16808     + (enercCBdel(n2) - enercCBdel(n1))
16809     ismatCBdel(nang,nener,nm)=
16810     + smatCBdel(nang,nener,nm)
16811     + * (anCBdel(nang+1) - anCBdel(nang))
16812     enddo ! nang=1,qanCBdel
16813     rr=1.0/
16814     + (rr*(AVOGADRO/(5.07E10 * 5.07E10))
16815     + *DensMat(nm)/A_mean(nm))
16816     st=0.0 ! restrict low angles
16817     st1=0.0
16818     do nang=qanCBdel,1,-1
16819     st = st + ismatCBdel(nang,nener,nm)
16820     if(st.gt.rr)then
16821     goto 110
16822     else
16823     st1=st
16824     endif
16825     enddo ! nang=qanCBdel,1,-1
16826     nang=0
16827     110 continue
16828     nang=nang+1
16829     TetacBdel(nener,nm)=anCBdel(nang)
16830     tsmatCBdel(nener,nm)=st1
16831     lamaBdel(nener,nm)=1.0/
16832     + (tsmatCBdel(nener,nm)*(AVOGADRO/(5.07E10 * 5.07E10))
16833     + *DensMat(nm)/A_mean(nm))
16834     do n=1,nang-1
16835     ismatCBdel(n,nener,nm)=0.0
16836     enddo
16837     call lhispre(ismatCBdel(1,nener,nm),qanCBdel)
16838     if(TetacBdel(nener,nm).gt.1.0)then
16839     sisferaBdel(nener,nm)=1
16840     endif
16841     endif
16842     enddo ! nener=1,qener
16843    
16844    
16845     endif
16846     enddo
16847    
16848    
16849    
16850     c All done !
16851    
16852     endif ! if(sruthBdel.eq.2)
16853    
16854    
16855     end
16856    
16857     subroutine readCBdel
16858    
16859     implicit none
16860    
16861     c include 'GoEvent.inc'
16862     +SEQ,GoEvent.
16863     c include 'ener.inc'
16864     +SEQ,ener.
16865     c include 'atoms.inc'
16866     +SEQ,atoms.
16867     c include 'matters.inc'
16868     +SEQ,matters.
16869     c include 'crosec.inc'
16870     +SEQ,crosec.
16871     c include 'volume.inc'
16872     +SEQ,volume.
16873     c include 'bdel.inc'
16874     +SEQ,bdel.
16875    
16876     character*1 a
16877     integer ios
16878     integer na,z,i,n,j
16879    
16880     open(1,FILE='cbdel.dat',IOSTAT=ios,STATUS='OLD')
16881     if(ios.ne.0)then
16882     write(oo,*)' readCBdel: can not open file readCBdel.dat'
16883     stop
16884     endif
16885    
16886     do na=1,pqAt
16887    
16888     if(Zat(na).gt.0)then ! atom is meant initialized
16889    
16890     sign_ACBdel(na)=0 ! cleaning
16891    
16892     do n=1,100000
16893     read(1,'(A1)',END=100)a
16894     c write (6,*)a
16895     if(a.eq.'$')then
16896     backspace (1)
16897     read(1,'(A1,I3)')a,z
16898     if(z.eq.Zat(na))then
16899     write(oo,*)a,z
16900     do i=1,4
16901     read(1,*)(ACBdel(i,j,na),j=1,qeaCBdel)
16902     enddo
16903     do i=0,6
16904     read(1,*)(CCBdel(i,j,na),j=1,qeaCBdel)
16905     enddo
16906     read(1,*)(BCBdel(j,na),j=1,qeaCBdel)
16907     sign_ACBdel(na)=1 ! sign of reading
16908     go to 100
16909     endif
16910     endif
16911     enddo
16912     100 rewind(1)
16913    
16914     endif
16915    
16916     enddo
16917    
16918     close(1)
16919    
16920     end
16921    
16922     subroutine read1CBdel
16923     c
16924     c This subroutine must copy data not from external file
16925     c but from internal data arrays (so as to avoid input which
16926     c is often machine-dependent)
16927     c
16928     implicit none
16929    
16930     c include 'GoEvent.inc'
16931     +SEQ,GoEvent.
16932     c include 'ener.inc'
16933     +SEQ,ener.
16934     c include 'atoms.inc'
16935     +SEQ,atoms.
16936     c include 'matters.inc'
16937     +SEQ,matters.
16938     c include 'crosec.inc'
16939     +SEQ,crosec.
16940     c include 'volume.inc'
16941     +SEQ,volume.
16942     c include 'bdel.inc'
16943     +SEQ,bdel.
16944    
16945     c character*1 a
16946     c integer ios
16947     integer na,i,n,j
16948     c integer z
16949    
16950     integer psqAt
16951     parameter (psqAt=11) ! Now only 11 atoms included
16952     integer ZsCBdel(psqAt) ! atomic charge
16953     real AsCBdel(4,pqeaCBdel,psqAt)
16954     real CsCBdel(0:6,pqeaCBdel,psqAt)
16955     real BsCBdel(pqeaCBdel,psqAt)
16956     *** Modified on 6/2/97 RV
16957     C save /ZsCBdel/,/AsCBdel/,/CsCBdel/,/BsCBdel/
16958     save ZsCBdel,AsCBdel,CsCBdel,BsCBdel
16959     *** End of modification.
16960    
16961     c include 'cbdeldat.inc'
16962     +SEQ,cbdeldat.
16963    
16964    
16965     do na=1,pqAt
16966    
16967     if(Zat(na).gt.0)then ! atom is meant initialized
16968    
16969     sign_ACBdel(na)=0 ! cleaning
16970    
16971     do n=1,psqAt
16972     if(ZsCBdel(n).eq.Zat(na))then
16973     c write(oo,*)a,z
16974     do i=1,4
16975     do j=1,qeaCBdel
16976     ACBdel(i,j,na)=AsCBdel(i,j,n)
16977     enddo
16978     enddo
16979     do i=0,6
16980     do j=1,qeaCBdel
16981     CCBdel(i,j,na)=CsCBdel(i,j,n)
16982     enddo
16983     enddo
16984     do j=1,qeaCBdel
16985     BCBdel(j,na)=BsCBdel(j,n)
16986     enddo
16987     sign_ACBdel(na)=1 ! sign of reading
16988     go to 100
16989     endif
16990     enddo
16991     100 continue
16992    
16993     endif
16994    
16995     enddo
16996    
16997     end
16998    
16999     function fcalcsCBdel(nang,nen,na)
17000     c
17001     c calculates elastic cross section per one atom by fit formula
17002     c in Angstrem**2/Srad. (10**-16 sm2 /Srad)
17003     c
17004    
17005     implicit none
17006    
17007     real fcalcsCBdel
17008     integer nang,nen,na
17009    
17010     c include 'GoEvent.inc'
17011     +SEQ,GoEvent.
17012     c include 'cconst.inc'
17013     +SEQ,cconst.
17014     c include 'ener.inc'
17015     +SEQ,ener.
17016     c include 'atoms.inc'
17017     +SEQ,atoms.
17018     c include 'matters.inc'
17019     +SEQ,matters.
17020     c include 'volume.inc'
17021     +SEQ,volume.
17022     c include 'part.inc'
17023     +SEQ,part.
17024     c include 'bdel.inc'
17025     +SEQ,bdel.
17026    
17027     real*8 ang,cang,cang2,cang3,cang4,cang5,cang6,s,r
17028     real*8 coe
17029     c integer n
17030     integer i
17031    
17032     ang=ancCBdel(nang)
17033     c ang=0.0
17034     cang=cos(ang)
17035     cang2=cang *cang
17036     cang3=cang2*cang
17037     cang4=cang3*cang
17038     cang5=cang4*cang
17039     cang6=cang5*cang
17040    
17041     c write(oo,*)' A=',(ACBdel(i,nen,na),i=1,4)
17042     c write(oo,*)' C=',(CCBdel(i,nen,na),i=0,6)
17043     c write(oo,*)' B=',BCBdel(nen,na)
17044    
17045     r=0.0
17046     do i=1,4
17047     r=r+ACBdel(i,nen,na) /
17048     + (1.0-cang+2.0*dble(BCBdel(nen,na)))**i
17049     c write(oo,*)' r=',r
17050     enddo
17051    
17052     r=r+dble(CCBdel(0,nen,na))*
17053     + 1.0
17054     c write(oo,*)' r=',r
17055     r=r+dble(CCBdel(1,nen,na))*
17056     + cang
17057     c write(oo,*)' r=',r
17058     r=r+dble(CCBdel(2,nen,na))*
17059     + 0.5*(3.0*cang2-1.0)
17060     c write(oo,*)' r=',r
17061     r=r+dble(CCBdel(3,nen,na))*
17062     + 0.5*(5.0*cang3 - 3*cang)
17063     c write(oo,*)' r=',r
17064     r=r+dble(CCBdel(4,nen,na))*
17065     + 1.0/8.0 * (35.0*cang4 - 30.0*cang2 + 3.0)
17066     c write(oo,*)' r=',r
17067     r=r+dble(CCBdel(5,nen,na))*
17068     + 1.0/8.0 * (63.0*cang5 - 70.0*cang3 + 15.0*cang)
17069     c write(oo,*)' r=',r
17070     r=r+dble(CCBdel(6,nen,na))*
17071     + 1.0/16.0 * (231.0*cang6 - 315.0*cang4 + 105.0*cang2 -5.0)
17072     c write(oo,*)' r=',r
17073    
17074     s=r
17075    
17076     c beneath is coefficient from erratum.
17077     coe=Zat(na)/(FSCON*FSCON)/(gammaCBdel(nen)*beta2CBdel(nen))
17078    
17079     s=s*coe*coe
17080    
17081     fcalcsCBdel=s
17082    
17083     end
17084    
17085     function fcalcsmCBdel(nang,nen,nm)
17086    
17087     implicit none
17088    
17089     real fcalcsmCBdel
17090     integer nang,nen,nm
17091    
17092     c include 'GoEvent.inc'
17093     +SEQ,GoEvent.
17094     c include 'cconst.inc'
17095     +SEQ,cconst.
17096     c include 'ener.inc'
17097     +SEQ,ener.
17098     c include 'atoms.inc'
17099     +SEQ,atoms.
17100     c include 'matters.inc'
17101     +SEQ,matters.
17102     c include 'volume.inc'
17103     +SEQ,volume.
17104     c include 'part.inc'
17105     +SEQ,part.
17106     c include 'bdel.inc'
17107     +SEQ,bdel.
17108    
17109     real*8 ang,cang,cang2,cang3,cang4,cang5,cang6,s,r
17110     real*8 coe
17111     integer n,na,i
17112    
17113     ang=ancCBdel(nang)
17114     c ang=0.0
17115     cang=cos(ang)
17116     cang2=cang *cang
17117     cang3=cang2*cang
17118     cang4=cang3*cang
17119     cang5=cang4*cang
17120     cang6=cang5*cang
17121     s=0.0
17122     do n=1,QAtMat(nm)
17123     na=AtMat(n,nm)
17124     c write(oo,*)' A=',(ACBdel(i,nen,na),i=1,4)
17125     c write(oo,*)' C=',(CCBdel(i,nen,na),i=0,6)
17126     c write(oo,*)' B=',BCBdel(nen,na)
17127    
17128     r=0.0
17129     do i=1,4
17130     r=r+ACBdel(i,nen,na) /
17131     + (1.0-cang+2.0*dble(BCBdel(nen,na)))**i
17132     write(oo,*)' r=',r
17133     enddo
17134    
17135     r=r+dble(CCBdel(0,nen,na))*
17136     + 1.0
17137     write(oo,*)' r=',r
17138     r=r+dble(CCBdel(1,nen,na))*
17139     + cang
17140     write(oo,*)' r=',r
17141     r=r+dble(CCBdel(2,nen,na))*
17142     + 0.5*(3.0*cang2-1.0)
17143     write(oo,*)' r=',r
17144     r=r+dble(CCBdel(3,nen,na))*
17145     + 0.5*(5.0*cang3 - 3*cang)
17146     write(oo,*)' r=',r
17147     r=r+dble(CCBdel(4,nen,na))*
17148     + 1.0/8.0 * (35.0*cang4 - 30.0*cang2 + 3.0)
17149     write(oo,*)' r=',r
17150     r=r+dble(CCBdel(5,nen,na))*
17151     + 1.0/8.0 * (63.0*cang5 - 70.0*cang3 + 15.0*cang)
17152     write(oo,*)' r=',r
17153     r=r+dble(CCBdel(6,nen,na))*
17154     + 1.0/16.0 * (231.0*cang6 - 315.0*cang4 + 105.0*cang2 -5.0)
17155     write(oo,*)' r=',r
17156    
17157     r=r*WeightAtMat(n,nm)
17158     write(oo,*)' r=',r
17159     s=s+r
17160    
17161     enddo
17162    
17163     coe=Z_Mean(nm)/(FSCON*FSCON)/(gammaCBdel(nen)*beta2CBdel(nen))
17164    
17165     s=s*coe*coe
17166    
17167     fcalcsmCBdel=s
17168    
17169     end
17170    
17171    
17172     subroutine SeLossBdel(nm,e,i,el)
17173     c
17174     c Calculation of the energy loss in 1 sm
17175     c
17176     implicit none
17177    
17178     c include 'ener.inc'
17179     +SEQ,ener.
17180     c include 'atoms.inc'
17181     +SEQ,atoms.
17182     c include 'matters.inc'
17183     +SEQ,matters.
17184     c include 'volume.inc'
17185     +SEQ,volume.
17186     c include 'bdel.inc'
17187     +SEQ,bdel.
17188    
17189     integer nm
17190     real e,el
17191     integer i,i1 ! i is start index i1 is new
17192     integer n
17193    
17194     c if(e.lt.eMinBdel)then
17195     c el=0.0
17196     c i1=0
17197     c return
17198     c endif
17199     if(i.le.0.or.i.gt.qener)then
17200     i=qener
17201     endif
17202     c do n=i,iMinBdel,-1
17203     do n=i,1,-1
17204     if(e.ge.ener(n))then
17205     i1=n
17206     go to 10
17207     endif
17208     enddo
17209     c write(oo,*)' Error in FeLossBdel'
17210     c stop
17211     el=eLossBdel(1,nm)
17212     i=1
17213     return
17214     10 continue
17215     i=i1
17216     el=eLossBdel(i,nm)+(e-ener(i))*
17217     + (eLossBdel(i+1,nm)-eLossBdel(i,nm))/(ener(i+1)-ener(i))
17218     c write(oo,*)' nm,e,i,el=',nm,e,i,el
17219    
17220     end
17221    
17222    
17223     subroutine SstepBdel
17224     c
17225     c Calc. of step lenght
17226     c
17227     implicit none
17228    
17229     c include 'GoEvent.inc'
17230     +SEQ,GoEvent.
17231     c include 'ener.inc'
17232     +SEQ,ener.
17233     c include 'atoms.inc'
17234     +SEQ,atoms.
17235     c include 'matters.inc'
17236     +SEQ,matters.
17237     c include 'crosec.inc'
17238     +SEQ,crosec.
17239     c include 'volume.inc'
17240     +SEQ,volume.
17241     c include 'bdel.inc'
17242     +SEQ,bdel.
17243    
17244     c real pntBdel(3),velBdel(3),step
17245     c integer nv,sgonext
17246     integer i
17247     real*8 mleng
17248     real lossmean
17249     real*8 rleng
17250    
17251     real rr,ek,r,ranfl
17252     integer nm
17253    
17254     if(nVolBdel.eq.0.or.sgonextBdel.eq.1)then !first find the volume
17255     c sisferBdel=0 ! obsolete
17256     call VolNumZcoor(pntBdel(3),velBdel(3),nVolBdel)
17257     if(nVolBdel.eq.0)return !out of geometry
17258     c if(sMatC(nMatVol(nVolBdel)).eq.0)return
17259     endif
17260     c write(oo,*)' pntBdel(3)=',pntBdel(3)
17261     c write(oo,*)' velBdel=',velBdel
17262     c write(oo,*)' nVolBdel=',nVolBdel
17263     c write(oo,*)' mleng=',mleng
17264     call VolPathLeng(pntBdel(3),velBdel,nVolBdel,mleng)
17265     if(nMatVol(nVolBdel).eq.0)then ! empty volume: no interaction
17266     estepBdel=0.0
17267     stepBdel=mleng
17268     sgonextBdel=1
17269     sturnBdel=0
17270     go to 10
17271     endif
17272    
17273     if(eBdel.le.cuteneBdel)then ! the same number in treatdel.f
17274    
17275     nm=nMatVol(nVolBdel)
17276     ek=eBdel*1000.0
17277     if(ek.le.10.0)then
17278     rr=1.0e-3 * A_Mean(nm)/Z_Mean(nm) * 3.872e-3 * ek ** 1.492
17279     rr=rr/DensMat(nm)
17280     else
17281     rr=1.0e-3 * 6.97e-3 * ek ** 1.6
17282     rr=rr/DensMat(nm)
17283     endif
17284     c rr=rr*0.6
17285     r=ranfl()
17286     c rr = rr * (0.3 + 0.8*r)
17287     c rr = rr * (0.4 + 1.0*r)
17288     rr = rr * (0.3 + 0.8*r)
17289     stepBdel=rr
17290     if(stepBdel.lt.mleng)then
17291     estepBdel=eBdel
17292     sgonextBdel=0
17293     else
17294     estepBdel=eBdel*mleng/stepBdel
17295     sgonextBdel=1
17296     endif
17297     sturnBdel=0
17298     go to 10
17299     endif
17300    
17301     call SeLossBdel(nMatVol(nVolBdel),eBdel,iBdel,lossmean)
17302     c if(nevt.eq.1.and.(nBdel.eq.8.or.nBdel.eq.9))then
17303     c write(oo,*)' mleng,lossmean=',mleng,lossmean
17304     c endif
17305     estepBdel=mleng*lossmean
17306     stepBdel=mleng
17307     sgonextBdel=1
17308     sturnBdel=0
17309     c if(srandoff.ne.1)then
17310     if(sruthBdel.eq.1.or.sruthBdel.eq.2)then !lengt to coulomb interaction
17311     call SRLengBdel(rleng)
17312     else
17313     call SMLengBdel(rleng)
17314     c rleng=mlamBdel/DensMatDS(nMatVol(nVolBdel))
17315     endif
17316     if(stepBdel.gt.rleng)then !reduce step to point of turn
17317     stepBdel=rleng
17318     estepBdel=rleng*lossmean
17319     sgonextBdel=0
17320     sturnBdel=1
17321     endif
17322     c endif
17323     c if(nevt.eq.1.and.(nBdel.eq.8.or.nBdel.eq.9))then
17324     c write(oo,*)' rleng,estepBdel=',rleng,estepBdel
17325     c endif
17326     if(estepBdel.gt.eMinBdel)then
17327     if(estepBdel.gt.0.1*eBdel)then
17328     ! reduce the step ...
17329     estepBdel=0.1*eBdel ! Maximum
17330     ! but not too much:
17331     if(estepBdel.lt.eMinBdel)estepBdel=eMinBdel
17332     ! For the case when eBdel<eMinBdel
17333     if(estepBdel.gt.eBdel)estepBdel=eBdel
17334     stepBdel=estepBdel/lossmean
17335     sgonextBdel=0
17336     if(sruthBdel.eq.1.or.sruthBdel.eq.2)then
17337     !since step must be reduced
17338     sturnBdel=0
17339     else
17340     sturnBdel=1
17341     endif
17342     endif
17343     endif
17344     c if(nevt.eq.1.and.(nBdel.eq.8.or.nBdel.eq.9))then
17345     c write(oo,*)' estepBdel=',estepBdel
17346     c endif
17347    
17348     c if(estepBdel.gt.0.1*eBdel)then
17349     c estepBdel=0.1*eBdel
17350     c stepBdel=estepBdel/lossmean
17351     c sgonextBdel=0
17352     c if(sruthBdel.eq.1)then
17353     c sturnBdel=0
17354     c else
17355     c sturnBdel=1
17356     c endif
17357     c endif
17358    
17359     10 do i=1,3
17360     npntBdel(i)=pntBdel(i)+stepBdel*velBdel(i)
17361     enddo
17362    
17363     if(estepBdel.lt.0.0)then
17364     write(oo,*)' error in SstepBdel: estepBdel is negative'
17365     call PriBdel(1)
17366     write(oo,*)' lossmean=',lossmean
17367     write(oo,*)' mleng=',mleng,' rleng=',rleng
17368     stop
17369     endif
17370    
17371     end
17372    
17373    
17374    
17375     subroutine SRLengBdel(rleng)
17376     c
17377     c Step lenght limit due to multiple scatering
17378     c The method with Rutherford cross section
17379     c
17380     implicit none
17381    
17382     c include 'GoEvent.inc'
17383     +SEQ,GoEvent.
17384     c include 'ener.inc'
17385     +SEQ,ener.
17386     c include 'atoms.inc'
17387     +SEQ,atoms.
17388     c include 'matters.inc'
17389     +SEQ,matters.
17390     c include 'crosec.inc'
17391     +SEQ,crosec.
17392     c include 'volume.inc'
17393     +SEQ,volume.
17394     c include 'bdel.inc'
17395     +SEQ,bdel.
17396     c include 'cconst.inc'
17397     +SEQ,cconst.
17398    
17399     real*8 rleng
17400     c real bet2,p2,A,B
17401    
17402     c real asin,acos,sqrt,alog,ranfl
17403     real ranfl
17404     real r
17405     c real mT
17406    
17407     r=ranfl()
17408     if(r.gt.0.99999)then
17409     rleng=1.0e30
17410     return
17411     endif
17412     rleng=-lamaBdel(iBdel,nMatVol(nVolBdel))*alog(1.0-r)
17413     lamBdel=lamaBdel(iBdel,nMatVol(nVolBdel))
17414    
17415    
17416     end
17417    
17418    
17419     subroutine SMLengBdel(rleng)
17420     c
17421     c Step lenght limit due to multiple scatering
17422     c The method with mean multiple scatering angle form
17423     c
17424    
17425     implicit none
17426    
17427     c include 'GoEvent.inc'
17428     +SEQ,GoEvent.
17429     c include 'ener.inc'
17430     +SEQ,ener.
17431     c include 'atoms.inc'
17432     +SEQ,atoms.
17433     c include 'matters.inc'
17434     +SEQ,matters.
17435     c include 'crosec.inc'
17436     +SEQ,crosec.
17437     c include 'volume.inc'
17438     +SEQ,volume.
17439     c include 'bdel.inc'
17440     +SEQ,bdel.
17441     c include 'cconst.inc'
17442     +SEQ,cconst.
17443    
17444     real*8 rleng
17445     c real bet,p,x
17446     c real sqrt
17447     c real msig
17448     c
17449     rleng=lamaBdel(iBdel,nMatVol(nVolBdel))
17450     * go to 100
17451     *c calculate paht lengt from mTetacBdel
17452     * bet=1.0-ELMAS*ELMAS/((ELMAS+eBdel)*(ELMAS+eBdel))
17453     * bet=sqrt(bet)
17454     * p=eBdel*eBdel+2.0*ELMAS*eBdel
17455     * p=sqrt(p)
17456     * msig=mTetacBdel
17457     * x=msig/(sqrt(2.0)*13.6/(bet*p))
17458     * x=x*x
17459     *
17460     *c x=x/DensMat(nMatVol(nVolBdel))
17461     * x=x*RLenMat(nMatVol(nVolBdel))
17462     * rleng=mlamBdel/DensMat(nMatVol(nVolBdel))
17463     *c write(oo,*)' x=',x,' rleng=',rleng
17464     *c reset if it is too large
17465     * if(rleng.lt.x)rleng=x
17466     *
17467     end
17468    
17469    
17470    
17471    
17472     subroutine TurnBdel
17473    
17474     c Turn the vector of velocity of the delta electron
17475    
17476     implicit none
17477    
17478     c include 'GoEvent.inc'
17479     +SEQ,GoEvent.
17480     c include 'del.inc'
17481     +SEQ,del.
17482     c include 'ener.inc'
17483     +SEQ,ener.
17484     c include 'atoms.inc'
17485     +SEQ,atoms.
17486     c include 'matters.inc'
17487     +SEQ,matters.
17488     c include 'crosec.inc'
17489     +SEQ,crosec.
17490     c include 'volume.inc'
17491     +SEQ,volume.
17492     c include 'cel.inc'
17493     +SEQ,cel.
17494     c include 'bdel.inc'
17495     +SEQ,bdel.
17496     c include 'cconst.inc'
17497     +SEQ,cconst.
17498    
17499     real*8 r,rs,rsin12,rcos12
17500     real*8 x,msig
17501    
17502     real ranfl
17503     c real ranfl,sqrt,sin,cos,acos
17504     c real*8 dsqrt
17505     c real rs,rss
17506     c integer n,i
17507     real rra,rrb
17508    
17509     real xran,dran
17510     integer iran
17511    
17512     c if(sisferBdel.eq.0)then
17513    
17514     if(sruthBdel.eq.2)then
17515    
17516     if(enerc(iBdel).lt.500.0e-6 .or.
17517     + sisferaBdel(iBdel,nMatVol(nVolBdel)).eq.1)then
17518     sisferBdel=1
17519     TetaBdel=0.0
17520     else
17521     sisferBdel=0
17522     call lhisran(ismatCBdel(1,iBdel,nMatVol(nVolBdel)),
17523     + qanCBdel, 1.0, 1.0, xran)
17524     iran=xran
17525     if(iran.lt.1.or.iran.gt.qanCBdel)then
17526     write(oo,*)' Worning of TurnBdel: iran=',iran,
17527     + ' xran=',xran
17528     if(iran.lt.1)then
17529     iran=1
17530     else
17531     iran=qanCBdel
17532     endif
17533     endif
17534     dran=xran-iran
17535     TetaBdel=anCBdel(iran)+(anCBdel(iran+1)-anCBdel(iran))*dran
17536     endif
17537    
17538     elseif(sruthBdel.eq.1)then
17539    
17540     if(sisferaBdel(iBdel,nMatVol(nVolBdel)).eq.1)then
17541     sisferBdel=1
17542     TetaBdel=0.0
17543     else
17544     c if(TetacBdel.ge.1.5)then
17545     c sisferBdel=1
17546     c TetaBdel=0.0
17547     c else
17548    
17549     r=ranfl()
17550     rsin12=SinTetac12Bdel(iBdel,nMatVol(nVolBdel))
17551     rcos12=CosTetac12Bdel(iBdel,nMatVol(nVolBdel))
17552     rs = 1.0 - r * rcos12 * rcos12
17553     if(rs.eq.0.0)then
17554     TetaBdel=PI
17555     else
17556     rs=rsin12 / sqrt( rs )
17557     rs=2.0 * asin(rs)
17558     TetaBdel=rs
17559     endif
17560    
17561     c rs=sin(TetacBdel/2.0)/sqrt(1.0-r*cos(TetacBdel/2.0)**2)
17562     c TetaBdel=asin(rs)*2.0
17563     * rs=cos(TetacBdel)
17564     * rs=1.0-(1.0-rs)/(1.0-r*0.5*(1.0+rs))
17565     * TetaBdel=acos(rs)
17566     c write(oo,*)' TetacBdel,TetaBdel,r=',TetacBdel,TetaBdel,r
17567    
17568     endif
17569    
17570     else
17571    
17572     x=stepBdel/RLenMat(nMatVol(nVolBdel))
17573     msig=msigBdel(iBdel)*
17574     + sqrt(x)
17575     if(msig.ge.1.5)then
17576     sisferBdel=1
17577     TetaBdel=0.0
17578     else
17579     call lranor(rra,rrb)
17580     TetaBdel=rra*msig
17581     endif
17582    
17583    
17584     endif ! sruthBdel.eq. ...
17585    
17586     if(sisferBdel.eq.1)then
17587     call sfersim(velBdel)
17588     else
17589     call MakeNewSys(e1Bdel,e2Bdel,e3Bdel,velBdel)
17590     call turnvec(e1Bdel,e2Bdel,e3Bdel,TetaBdel,velBdel)
17591     endif
17592    
17593     end
17594    
17595    
17596    
17597     subroutine correctBdel(e,r)
17598    
17599     implicit none
17600    
17601     real e,r
17602     real a,b,k,x
17603     c b-k*(x-a)**2 = 0 => x= a +- sqrt(b/k)
17604     c k = b / (x - a)**2
17605     a=2.5
17606     b=4
17607     c k=1.0/4.0
17608     x=0.0
17609     k=b/((x-a)*(x-a))
17610     x=e*1000.0
17611     r=b-k*(x-a)*(x-a)
17612     if(r.lt.0.0)then
17613     r=1
17614     else
17615     r=r+1
17616     endif
17617    
17618     end
17619    
17620    
17621     subroutine PriBdel(i)
17622    
17623     implicit none
17624    
17625     c include 'GoEvent.inc'
17626     +SEQ,GoEvent.
17627     c include 'ener.inc'
17628     +SEQ,ener.
17629     c include 'atoms.inc'
17630     +SEQ,atoms.
17631     c include 'matters.inc'
17632     +SEQ,matters.
17633     c include 'crosec.inc'
17634     +SEQ,crosec.
17635     c include 'volume.inc'
17636     +SEQ,volume.
17637     c include 'bdel.inc'
17638     +SEQ,bdel.
17639    
17640     integer i
17641    
17642     integer ne,nm
17643     integer nang,nen,na
17644    
17645     if(soo.eq.0)return
17646    
17647     write(oo,*)
17648     write(oo,*)' PriBdel(',i,'):'
17649     if(i.eq.0)then
17650     c write(oo,*)' eMinBdel=',eMinBdel,' iMinBdel=',iMinBdel
17651     write(oo,*)' eMinBdel=',eMinBdel
17652    
17653     write(oo,*)' ne, enerc, betaBdel,',
17654     + ' beta2Bdel,momentumBdel,momentum2Bdel,msigBdel'
17655     do ne=1,qener
17656     write(oo,'(1X,i5,6(1X,E10.5))')ne,enerc(ne),betaBdel(ne),
17657     + beta2Bdel(ne),
17658     + momentumBdel(ne),momentum2Bdel(ne),msigBdel(ne)
17659     enddo
17660    
17661     do nm=1,pQMat
17662     if(qAtMat(nm).gt.0)then
17663     c if(sMatC(nm).gt.0)then
17664     write(oo,*)' matter number ',nm
17665     write(oo,*)' enerc elossbdel',
17666     + ' lamaBdel rTetacBdel TetacBdel'
17667     write(oo,*)' ',
17668     + ' Cos12TetacBdel Sin12TetacBdel',
17669     + ' sisferaBdel'
17670    
17671     c do ne=iMinBdel,qener
17672     do ne=1,qener
17673     write(oo,'(1X,7(1X,E9.4),1X,I3)')
17674     + enerc(ne),eLossBdel(ne,nm),lamaBdel(ne,nm),
17675     + rTetacBdel(ne,nm),TetacBdel(ne,nm),
17676     + CosTetac12Bdel(ne,nm),SinTetac12Bdel(ne,nm),
17677     + sisferaBdel(ne,nm)
17678     enddo
17679    
17680     c endif
17681     endif
17682     enddo
17683    
17684     elseif(i.eq.2)then
17685    
17686     write(oo,*)' nang anCBdel ancCBdel'
17687     do nang=1,pqanCBdel
17688     write(oo,*)nang,anCBdel(nang),ancCBdel(nang)
17689     enddo
17690     write(oo,*)' nen enerCBdel enercCBdel',
17691     + ' gammaCBdel beta2CBdel'
17692     do nen=1,pqeaCBdel
17693     write(oo,*)nen,enerCBdel(nen),enercCBdel(nen),
17694     + gammaCBdel(nen), beta2CBdel(nen)
17695     enddo
17696     do na=1,pQAt
17697    
17698     if(Zat(na).gt.0)then
17699    
17700     write(oo,*)' atom number ',na
17701     if(sign_ACBdel(na).gt.0)then
17702     do i=1,4
17703     write(oo,'(1X,i1,1X,9E10.3)')i,(ACBdel(i,nen,na),nen=1,qeaCBdel)
17704     enddo
17705     do i=0,6
17706     write(oo,'(1X,i1,1X,9E10.3)')i,(CCBdel(i,nen,na),nen=1,qeaCBdel)
17707     enddo
17708     write(oo,'(1X,i1,1X,9E10.3)')i,(BCBdel(nen,na),nen=1,qeaCBdel)
17709     endif
17710    
17711     write(oo,*)' nang, ancCBdel, differentioal cross sections:'
17712     do nang=1,qanCBdel
17713     write(oo,'(1X,i3,1X,10E10.3)')
17714     + nang,ancCBdel(nang),(sCBdel(nang,nen,na),nen=1,qeaCBdel)
17715     enddo
17716     write(oo,*)' nang, ancCBdel, Ruth. differentioal cross sections:'
17717     write(oo,'(1X,3X,1X,10X,9E10.3)')
17718     + (sRcmCBdel(nen,na),nen=1,qeaCBdel)
17719     write(oo,'(1X,3X,1X,10X,9E10.3)')
17720     + (sRmCBdel(nen,na),nen=1,qeaCBdel)
17721     do nang=1,qanCBdel
17722     write(oo,'(1X,i3,1X,10E10.3)')
17723     + nang,ancCBdel(nang),(sRCBdel(nang,nen,na),nen=1,qeaCBdel)
17724     enddo
17725    
17726     endif ! Zat(na).gt.0
17727     enddo ! na=1,pQAt
17728    
17729     do nm=1,pQMat
17730     if(qAtMat(nm).gt.0)then
17731     write(oo,*)' matter number ',nm
17732     write(oo,*)' nang, ancCBdel, differentioal cross sections:'
17733     do nang=1,qanCBdel
17734     write(oo,'(1X,i3,1X,10E10.3)')
17735     + nang,ancCBdel(nang),(smaCBdel(nang,nen,nm),nen=1,qeaCBdel)
17736     enddo
17737     c smatCBdel and ismatCBdel are not printed now, they is too big.
17738    
17739     write(oo,*)' nen, enerc, tsmatCBdel, lamaBdel, ',
17740     + ' usual range TetacBdel:'
17741     do nen=1,qener
17742     write(oo,'(1X,i3,1X,5E11.3)')
17743     + nen,enerc(nen),tsmatCBdel(nen,nm),lamaBdel(nen,nm),
17744     + rrCBdel(nen,nm),TetacBdel(nen,nm)
17745     enddo
17746     write(oo,*)' Beneth is invers order, energy along vertical'
17747     write(oo,*)' Angles are horizontally:'
17748     write(oo,'(1X,3X,1X,11X,30E11.3)')(ancCBdel(nang),
17749     + nang=1,qanCBdel)
17750     write(oo,*)' nener, ener, smatCBdel(nang,nen,nm)'
17751     do nen=1,qener ! next line fixed to 30 angles
17752     write(oo,'(1X,i3,1X,31E11.3)')
17753     + nen,enerc(nen),(smatCBdel(nang,nen,nm),nang=1,qanCBdel)
17754     enddo
17755     write(oo,*)' nener, ener, ismatCBdel(nang,nen,nm)'
17756     do nen=1,qener ! next line fixed to 30 angles
17757     write(oo,'(1X,i3,1X,31E11.3)')
17758     + nen,enerc(nen),(ismatCBdel(nang,nen,nm),nang=1,qanCBdel)
17759     enddo
17760     c write(oo,'(5X,9E11.3)')
17761     c + (tsmatCBdel(nen,nm),nen=1,qeaCBdel)
17762     c write(oo,*)' nang, ancCBdel, integrated cross sections:'
17763     c do nang=1,qanCBdel
17764     c write(oo,'(1X,i3,1X,10E11.3)')
17765     c + nang,ancCBdel(nang),(ismatCBdel(nang,nen,nm),nen=1,qeaCBdel)
17766     c enddo
17767    
17768     endif ! qAtMat(nm).gt.0
17769     enddo ! nm=1,pQMat
17770    
17771     else ! i=1
17772    
17773    
17774    
17775     write(oo,*)' nBdel=',nBdel,' nstepBdel=',nstepBdel,
17776     + ' eBdel=',eBdel
17777     write(oo,*)' pntBdel=',pntBdel
17778     write(oo,*)' npntBdel=',npntBdel
17779     write(oo,*)' velBdel=',velBdel
17780     write(oo,*)' stepBdel=',stepBdel,' estepBdel=',estepBdel
17781     write(oo,*)' e1Bdel=',e1Bdel
17782     write(oo,*)' e2Bdel=',e2Bdel
17783     write(oo,*)' e3Bdel=',e3Bdel
17784     if(iBdel.ge.1 .and. iBdel.le.qener .and.
17785     + nVolBdel.ge.1 .and. nVolBdel.le.qVol)then
17786     if(nMatVol(nVolBdel).ge.1 .and. nMatVol(nVolBdel).le.pqMat)then
17787     write(oo,*)' TetacBdel(iBdel,.)=',
17788     + TetacBdel(iBdel,nMatVol(nVolBdel)),
17789     + ' TetaBdel=',TetaBdel,' -usually prev.'
17790     else
17791     write(oo,*)' cannot print TetacBdel'
17792     write(oo,*)' nMatVol(nVolBdel)=',nMatVol(nVolBdel)
17793     endif
17794     else
17795     write(oo,*)' cannot print TetacBdel'
17796     write(oo,*)' iBdel=',iBdel,' nVolBdel=',nVolBdel
17797     endif
17798     write(oo,*)' lamBdel=',lamBdel
17799     write(oo,*)' sturnBdel=',sturnBdel
17800     write(oo,*)' sruthBdel=',sruthBdel,' sisferBdel=',sisferBdel
17801     write(oo,*)' nVolBdel=',nVolBdel,' sgonextBdel=',sgonextBdel,
17802     + ' iBdel=',iBdel
17803     endif
17804    
17805    
17806    
17807     end
17808    
17809    
17810     +DECK,lstrel1.
17811     SUBROUTINE lstREL1(EEL,CHARGE,nmat,DEDX)
17812     C.
17813     implicit none
17814    
17815     C. ******************************************************************
17816     C. * *
17817     C. * Compute ion losses for electron/positron *
17818     C. * *
17819     C. * ==>Called by : GDRELA *
17820     C. * Author G.Patrick ********* *
17821     C. * *
17822     C. ******************************************************************
17823     C.
17824     real EEL ! kinetic energy
17825     real CHARGE ! +/-1.
17826     c integer JMA ! =LQ(JMATE-I) I-number of medium
17827     integer nmat ! number of matter
17828     real DEDX ! loss
17829    
17830     c include 'ener.inc'
17831     +SEQ,ener.
17832     c include 'atoms.inc'
17833     +SEQ,atoms.
17834     c include 'matters.inc'
17835     +SEQ,matters.
17836    
17837     integer nat
17838    
17839     real*8 PI,TWOPI, PIBY2,DEGRAD,RADDEG,CLIGHT,BIG,EMASS,
17840     + EMMU,PMASS,AVO
17841     PARAMETER (PI=3.14159265358979324)
17842     PARAMETER (TWOPI=6.28318530717958648)
17843     PARAMETER (PIBY2=1.57079632679489662)
17844     PARAMETER (DEGRAD=0.0174532925199432958)
17845     PARAMETER (RADDEG=57.2957795130823209)
17846     PARAMETER (CLIGHT=29979245800.)
17847     PARAMETER (BIG=10000000000.)
17848     PARAMETER (EMASS=0.0005109990615)
17849     PARAMETER (EMMU=0.105658387)
17850     PARAMETER (PMASS=0.9382723128)
17851     PARAMETER (AVO=0.60221367)
17852    
17853     c PARAMETER (KWBANK=69000,KWWORK=5200)
17854     c COMMON/GCBANK/NZEBRA,GVERSN,ZVERSN,IXSTOR,IXDIV,IXCONS,FENDQ(16)
17855     c + ,LMAIN,LR1,WS(KWBANK)
17856     c DIMENSION IQ(2),Q(2),LQ(8000),IWS(2)
17857     c EQUIVALENCE (Q(1),IQ(1),LQ(9)),(LQ(1),LMAIN),(IWS(1),WS(1))
17858     c EQUIVALENCE (JCG,JGSTAT)
17859    
17860     c COMMON/GCCUTS/CUTGAM,CUTELE,CUTNEU,CUTHAD,CUTMUO,BCUTE,BCUTM
17861     c + ,DCUTE,DCUTM ,PPCUTM,TOFMAX,GCUTS(5)
17862    
17863     real DCUTE
17864     c+SEQ,GCBANK
17865     c+SEQ,GCCUTS
17866     C
17867     real DENS
17868     real GAM, GAM2, T, TCME, BET2, Y, D, D2, D3, D4, F
17869     real POTI, POTL, FAC, C, X0, X1, AA, X, DEL, XA
17870     real S1,S2
17871     real CON2,CON3,CON4,CON5,CON6
17872     real AJ,ZJ, WJ, WJJ(pQAt)
17873     integer IP
17874     real CONS
17875     DATA CONS/0.153536E-3/
17876     C.
17877     C. ------------------------------------------------------------------
17878     C.
17879     DCUTE=1.0e5
17880     DENS=DensMatDL(nmat)
17881     c JPROB=LQ(JMA-4)
17882     C
17883     GAM=EEL/EMASS + 1.
17884     GAM2=GAM*GAM
17885     T=GAM-1.
17886     DEDX=0.
17887     IF(T.LE.0.)GO TO 99
17888     TCME=DCUTE/EMASS
17889     BET2=1.-1./GAM2
17890     C ------------------------------
17891     IF(CHARGE.GT.0.) THEN
17892     Y=1./(1.+GAM)
17893     D=TCME
17894     IF(T.LT.TCME) D=T
17895     D2=D*D/2.
17896     D3=2.*D2*D/3.
17897     D4=D2*D2
17898     F=LOG(T*D)-BET2*(T+2.*D-Y*(3.*D2
17899     * +Y*(D-D3+Y*(D2-T*D3+D4))))/T
17900     C
17901     ELSE
17902     D=TCME
17903     IF(T.LT.2.*TCME) D=0.5*T
17904     F=-1.-BET2+LOG((T-D)*D)+T/(T-D)
17905     * +(0.5*D*D+(1.+2.*T)*LOG(1.-D/T))/GAM2
17906     ENDIF
17907     C
17908     if(QAtMat(nmat).eq.1)then
17909     POTI=16.E-9*ZAt(AtMat(1,nmat))**0.9
17910     S1=Zat(AtMat(1,nmat))/Aat(AtMat(1,nmat))
17911     else
17912     S1=0.0
17913     S2=0.0
17914     do nat=1,QAtMat(nmat)
17915     AJ=Aat(AtMat(nat,nmat))
17916     WJJ(nat)=WeightAtMat(nat,nmat)*AJ
17917     S1=S1+WJJ(nat)
17918     enddo
17919     do nat=1,QAtMat(nmat)
17920     WJJ(nat)=WJJ(nat)/S1
17921     enddo
17922     S1=0.0
17923     do nat=1,QAtMat(nmat)
17924     ZJ=Zat(AtMat(nat,nmat))
17925     AJ=Aat(AtMat(nat,nmat))
17926     WJ=WJJ(nat)
17927     S1=S1+WJ*ZJ/AJ
17928     S2=S2+WJ*ZJ*LOG(ZJ)/AJ
17929     enddo
17930     POTI=16.E-9*EXP(0.9*S2/S1)
17931     endif
17932    
17933     POTL=LOG(POTI/EMASS)
17934     CON2=DENS*S1
17935     FAC=DENS*S1
17936     CON3=1.+2.*LOG(POTI/(28.8E-9*SQRT(CON2)))
17937     C= CON3
17938     C
17939     C Condensed material ?
17940     C (at present that means: DENS.GT.0.05 g/cm**3)
17941     C
17942     IF(DENS.GT.0.05)THEN
17943     IF(POTI.LT.1.E-7)THEN
17944     IF(CON3.LT.3.681)THEN
17945     CON4=0.2
17946     ELSE
17947     CON4=0.326*CON3-1.
17948     ENDIF
17949     CON5=2.
17950     ELSE
17951     IF(CON3.LT.5.215)THEN
17952     CON4=0.2
17953     ELSE
17954     CON4=0.326*CON3-1.5
17955     ENDIF
17956     CON5=3.
17957     ENDIF
17958     ELSE
17959     C
17960     C Gas (T=0 C, P= 1 ATM)
17961     C if T.NE. 0 C and/or P.NE. 1 ATM
17962     C you have to modify the variable X
17963     C X=>X+0.5*LOG((273+T C)/(273*P ATM))
17964     C in the function GDRELE
17965     C ------------------------
17966     C
17967     IF(CON3.LE.12.25)THEN
17968     IP=INT((CON3-10.)/0.5)+1
17969     IF(IP.LT.0) IP=0
17970     IF(IP.GT.4) IP=4
17971     CON4=1.6+0.1*FLOAT(IP)
17972     CON5=4.
17973     ELSE
17974     IF(CON3.LE.13.804)THEN
17975     CON4=2.
17976     CON5=5.
17977     ELSE
17978     CON4=0.326*CON3-2.5
17979     CON5=5.
17980     ENDIF
17981     ENDIF
17982     ENDIF
17983     C
17984     XA=CON3/4.606
17985     CON6=4.606*(XA-CON4)/(CON5-CON4)**3.
17986    
17987     X0=CON4
17988     X1=CON5
17989     AA=CON6
17990     C
17991     X=LOG(GAM2-1.)/4.606
17992     DEL=0.
17993     IF(X.GT.X0)THEN
17994     DEL=4.606*X+C
17995     IF(X.LE.X1)DEL=DEL+AA*(X1-X)**3.
17996     ENDIF
17997     C
17998     DEDX=CONS*FAC*(LOG(2.*T+4.)-2.*POTL+F-DEL)/BET2
17999     IF(DEDX.LT.0.)DEDX=0.
18000     C
18001     99 RETURN
18002     END
18003    
18004    
18005     +DECK,Inidel.
18006     subroutine Inidel
18007     c
18008     c Initialize the delta eleectrons
18009     c
18010     implicit none
18011    
18012     c include 'GoEvent.inc'
18013     +SEQ,GoEvent.
18014     c include 'del.inc'
18015     +SEQ,del.
18016    
18017     qdel=0
18018     sOverflowDel=0
18019     if(nevt.eq.1)then
18020     qOverflowDel=0
18021     qsOverflowDel=0
18022     endif
18023    
18024     end
18025    
18026    
18027     subroutine WorPridel
18028    
18029     implicit none
18030    
18031     c include 'GoEvent.inc'
18032     +SEQ,GoEvent.
18033     c include 'del.inc'
18034     +SEQ,del.
18035    
18036     c integer i,j
18037    
18038     if(nevt.eq.qevt)then
18039    
18040     if(qOverflowDel.gt.0)then
18041     write(oo,*)
18042     write(oo,*)' WorPridel: overflow of delta electrons arrays '
18043     write(oo,*)' sOverflowDel qsOverflowDel qOverflowDel'
18044     write(oo,*)sOverflowDel,qsOverflowDel,qOverflowDel
18045     endif
18046    
18047     endif
18048    
18049     end
18050    
18051     subroutine Pridel
18052    
18053     c print the delta electrons
18054    
18055     implicit none
18056    
18057     c include 'GoEvent.inc'
18058     +SEQ,GoEvent.
18059     c include 'del.inc'
18060     +SEQ,del.
18061    
18062     integer i,j
18063    
18064     if(soo.eq.0)return
18065     write(oo,*)
18066     write(oo,*)' Pridel: delta electron'
18067     write(oo,*)' sOverflowDel qsOverflowDel qOverflowDel'
18068     write(oo,*)sOverflowDel,qsOverflowDel,qOverflowDel
18069    
18070     write(oo,*)' qdel= ',qdel
18071     if(qdel.gt.0)then
18072     write(oo,*)
18073     + ' ndel zdel edel nVoldel Stdel ',
18074     + 'Ptdel updel(1) SOdel',
18075     + ' rangepdel rangedel qstep'
18076     write(oo,*)
18077     + ' pntdel(1,i) pntdel(2,i) pntdel(3,i) ',
18078     + ' veldel(1,i) veldel(2,i) veldel(3,i) '
18079     do i=1,qdel
18080     write(oo,
18081     + '(1X,I5,2(1X,e10.5),1(1X,I3),1(1X,I5),3(1X,I3),2(1X,E9.4),I6)')
18082     + i,zdel(i),edel(i),nVoldel(i),Stdel(i),Ptdel(i),
18083     + updel(1,i),
18084     + SOdel(i),rangepdel(i),rangedel(i),qstepdel(i)
18085     write(oo,'(6(1X,e12.5))')(pntdel(j,i),j=1,3),
18086     + (veldel(j,i),j=1,3)
18087     enddo
18088     endif
18089    
18090     end
18091     +DECK,treatdel.
18092    
18093    
18094     subroutine treatdel
18095     c
18096     c make absorbtion af delta electrons
18097     c write it to the cel.inc
18098    
18099     implicit none
18100    
18101     c include 'GoEvent.inc'
18102     +SEQ,GoEvent.
18103     c include 'hist.inc'
18104     +SEQ,hist.
18105     c include 'del.inc'
18106     +SEQ,del.
18107     c include 'ener.inc'
18108     +SEQ,ener.
18109     c include 'atoms.inc'
18110     +SEQ,atoms.
18111     c include 'matters.inc'
18112     +SEQ,matters.
18113     c include 'crosec.inc'
18114     +SEQ,crosec.
18115     c include 'volume.inc'
18116     +SEQ,volume.
18117     c include 'cel.inc'
18118     +SEQ,cel.
18119     c include 'bdel.inc'
18120     +SEQ,bdel.
18121     c include 'cconst.inc'
18122     +SEQ,cconst.
18123     c include 'hconst.inc'
18124     *** Added TRACK common to select tracing of delta's (RV 21/2/97).
18125     +SEQ,DIMENSIONS.
18126     +SEQ,PARAMETERS.
18127     *** End of modification.
18128     integer id
18129     integer k
18130     integer q
18131     integer j
18132     integer ti
18133     *** Modification for tracking delta's (RV 10/2/97)
18134     INTEGER IFAIL
18135     *** End of modification.
18136     real*8 h
18137     real rra,rrb
18138    
18139     c integer cV
18140     integer cSV
18141     integer qn
18142     c real e,rr(4)
18143     integer sact
18144     real v3
18145     c integer s_change_dir, n_change_dir
18146     *
18147     c data n_change_dir/1/
18148     real*8 s
18149     c real mod_add
18150     c real add(3)
18151     c real ranfl
18152     c real bet,p,x
18153     real msig
18154     c real alog,sqrt
18155    
18156     real WW,FF
18157    
18158     ti=0
18159    
18160     c if(srandoff.eq.1)then
18161     c n_change_dir=10000
18162     c endif
18163     c s_change_dir=n_change_dir
18164     c next 3 lines must be done in Inicel called from GoEvent
18165     c do k=1,QSVol
18166     c qcel(k)=0
18167     c enddo
18168    
18169     do id=1,qdel ! main loop
18170    
18171     c call IniIonen
18172     c write(oo,*)' id=',id
18173     c write(oo,*)' rionener=', rionener
18174    
18175     nBdel=id
18176     ti=0
18177    
18178    
18179     rangBdel=0.0
18180     rangpBdel=0.0
18181     nstepBdel=0
18182     nVolBdel=nVoldel(id)
18183     if(sSensit(nVolBdel) .eq. 0)then
18184     sact=1
18185     else
18186     sact=0
18187     endif
18188     c if(srandoff.eq.1)then
18189     c nVolBdel=6
18190     c eBdel=esimtran
18191     c edel(id)=eBdel
18192     c pntBdel(1)=0.0
18193     c pntBdel(2)=0.0
18194     cc pntBdel(3)=wall1(nVolBdel)+
18195     cc + (wall2(nVolBdel)-wall1(nVolBdel))*0.5
18196     c pntBdel(3)=29.0
18197     c velBdel(1)=0.0
18198     c velBdel(2)=0.0
18199     c velBdel(3)=1.0
18200     c do j=1,3
18201     c pntdel(j,id)=pntBdel(j)
18202     c veldel(j,id)=velBdel(j)
18203     c enddo
18204     c
18205     c else
18206     eBdel=edel(id)
18207     do j=1,3
18208     pntBdel(j)=pntdel(j,id)
18209     velBdel(j)=veldel(j,id)
18210     enddo
18211     if(eBdel.le.2.0*cuteneBdel)then
18212    
18213     c call PriBdel(1)
18214    
18215     c make the turn if the energy is too small
18216     c the electron must be traced by simple formula
18217     c for range without multiple scatering
18218     c so as it could be sensible
18219     if(eBdel.le.cuteneBdel)then
18220     msig=0.4
18221     else
18222     if(eBdel.le.2.0*cuteneBdel)then
18223     msig=0.2
18224     endif
18225     endif
18226     call lranor(rra,rrb)
18227     TetaBdel=rra*msig
18228     call MakeNewSys(e1Bdel,e2Bdel,e3Bdel,velBdel)
18229     call turnvec(e1Bdel,e2Bdel,e3Bdel,TetaBdel,velBdel)
18230    
18231     c call PriBdel(1)
18232    
18233     endif
18234     c endif
18235     sgonextBdel=0
18236     sturnBdel=0
18237     sisferBdel=0
18238     iBdel=0
18239     stepBdel=0.0
18240    
18241     c call MakeNewSys(e1Bdel,e2Bdel,e3Bdel,velBdel)
18242    
18243     if(nVolBdel.eq.0)then
18244     c call lstdelo
18245     go to 20
18246     endif
18247     if(eBdel.le.0.000001)then
18248     c if(eBdel.le.eMinBdel)then
18249     c call lstdelo
18250     go to 20
18251     endif
18252     c if(sMatC(nMatVol(nVolBdel)).eq.0)then
18253     c call lstdelo
18254     c go to 20
18255     c endif
18256    
18257     10 continue
18258     *** Moved next statement after CALL SSTEPBDEL (RV 16/2/99)
18259     C nstepBdel=nstepBdel+1
18260     *** End of modification.
18261     c call PriBdel(1)
18262    
18263     * if(s_change_dir.eq.1)then
18264     * if(sgonextBdel.eq.0.and.stepBdel.gt.0.0)then
18265     **
18266     c e=eBdel
18267     c cV=nVolBdel
18268     c rr(1)=(1.0E-5/DensMat(nMatVol(cV)))
18269     c + *1.0E4*(e*1.0E3)**1.5
18270     c rr(1)=rr(1)/10000.0
18271     c rr(2)=0.71*(e**1.72)/DensMat(nMatVol(cV))
18272     c rr(3)=0.2115*(Z_Mean(nMatVol(cV))**0.26)*
18273     c + e**(1.265-0.0954*alog(e))/DensMat(nMatVol(cV))
18274     c
18275     c e=e*1000
18276     c rr(4)=1.225e-3*e**1.912/DensMat(nMatVol(cV))
18277     c e=e/1000
18278     c write(oo,*)' rr=',rr
18279     c stop
18280    
18281     c bet=1.0-ELMAS*ELMAS/((ELMAS+eBdel)*(ELMAS+eBdel))
18282     c bet=sqrt(bet)
18283     c p=eBdel*eBdel+2.0*ELMAS*eBdel
18284     c p=sqrt(p)
18285     c x=stepBdel/RLenMat(nMatVol(nVolBdel))
18286     c msig=sqrt(2.0)*13.6/(bet*p)*
18287     c + sqrt(x)
18288     *cc msig=sqrt(2.0)*13.6/(bet*p)*
18289     *cc + sqrt(x)*
18290     *cc + (1.0 + 0.20*alog(x))
18291     c write(oo,*)' eBdel,stepBdel=',eBdel,stepBdel
18292     c write(oo,*)' msig=',msig
18293     *
18294     *c call PriBdel(1)
18295     *c write(oo,*)' bet,p=',bet,p
18296     *c write(oo,*)' x,msig=',x,msig
18297     * mod_add=0.1*abs(ranfl())
18298     * if(srandoff.eq.1)then
18299     * mod_add=mod_add*0.001
18300     * endif
18301     * if(mod_add.gt.0.9)mod_add=0.9
18302     * call sfersim(add)
18303     * s=0.0
18304     * do j=1,3
18305     * velBdel(j)=velBdel(j)+mod_add*add(j)
18306     * s=s+velBdel(j)*velBdel(j)
18307     * enddo
18308     * s=sqrt(s)
18309     * do j=1,3
18310     * velBdel(j)=velBdel(j)/s
18311     * enddo
18312     *cc write(oo,*)' next velBdel=',velBdel
18313     * s_change_dir=n_change_dir
18314     *cc irnc=n_change_dir
18315     * endif
18316     * else
18317     * s_change_dir=s_change_dir-1
18318     * endif
18319     *** Modified the following line, original follows (RV 16/2/99).
18320     C call SstepBdel
18321     C if(nVolBdel.eq.0)then ! this is current numbers
18322     C go to 20
18323     C endif
18324     *** New lines, forcing volume search when tracing deltas.
18325     IF(LTREXB)NVOLBDEL=0
18326     CALL SSTEPBDEL
18327     IF(NVOLBDEL.EQ.0)THEN
18328     PRINT *,' !!!!!! TREATD WARNING : Delta electron'//
18329     - ' has left tracking area; delta incomplete.'
18330     GOTO 20
18331     ENDIF
18332     NSTEPBDEL=NSTEPBDEL+1
18333     *** End of modification.
18334    
18335     if(sSensit(nVolBdel) .eq. 0)then
18336     c if(sgonextBdel.eq.1)then
18337     sact=1
18338     endif
18339    
18340     if(estepBdel.gt.0)then
18341    
18342     c if(sMatC(nMatVol(nVolBdel)).eq.0)then
18343     c call lstdelo
18344     c go to 20
18345     c endif
18346     if(srandoff.ne.1)then
18347     if(eBdel.gt.cuteneBdel)then
18348     if(estepBdel.lt.eBdel)then
18349     call lranor(rra,rrb)
18350     if(rra.lt.-2.0)rra=-2.0
18351     if(rra.gt. 2.0)rra= 2.0
18352     estepBdel=estepBdel+0.33333*estepBdel*rra
18353     if(estepBdel.gt.eBdel)estepBdel=eBdel
18354     endif
18355     endif
18356     endif
18357     if(sSensit(nVolBdel).eq.1)then
18358     if(nMatVol(nVolBdel).gt.0)then ! not a vacuum
18359     if(WWW(nMatVol(nVolBdel)).gt.0)then
18360     WW=WWW(nMatVol(nVolBdel))
18361     FF=FFF(nMatVol(nVolBdel))
18362     if(estepBdel.gt.0)then
18363     if(estepBdel.ne.eBdel)then
18364     call lsgcele(estepBdel,WW,FF,q)
18365     else
18366     call lsgcele1(estepBdel,WW,FF,q)
18367     c call lsgcele(estepBdel,WW,FF,q)
18368     endif
18369     if(q.gt.0)then
18370     h=stepBdel/q
18371     cSV=numSensVol(nVolBdel)
18372     c if(cSV.gt.0)then
18373     if((qcel(cSV)+q) .gt. pqcel)then
18374     qOverflowCel(cSV)=qOverflowCel(cSV)+q
18375     if(sOverflowCel(cSV).eq.0)then
18376     qsOverflowCel(cSV)=qsOverflowCel(cSV)+1
18377     sOverflowCel(cSV)=1
18378     endif
18379     else
18380     do k=1,q
18381     qcel(cSV)=qcel(cSV)+1
18382     *** Modification to trace delta's in E and B fields (RV 21/2/97).
18383     IF(LTREXB.AND.LTRDEL)THEN
18384     IF(K.EQ.1)THEN
18385     CALL TRAEXB(pntBdel,velBdel, ! Start
18386     - pntcel(1,qcel(csV),csV),velBdel, ! End
18387     - eBdel,h,IFAIL) ! Energy, step
18388     ELSE
18389     CALL TRAEXB(
18390     - pntcel(1,qcel(csV)-1,csV),velBdel, ! Start
18391     - pntcel(1,qcel(csV),csV),velBdel, ! End
18392     - eBdel-(k-1)*estepBdel/q,h,IFAIL) ! Energy, step
18393     ENDIF
18394     ELSE
18395     do j=1,3
18396     pntcel(j,qcel(cSV),cSV)=
18397     + pntBdel(j)+velBdel(j)*k*h
18398     enddo
18399     ENDIF
18400     *** End of modification.
18401     zcel(qcel(cSV),cSV)=1
18402     Ndelcel(qcel(cSV),cSV)=id
18403     sactcel(qcel(cSV),cSV)=sact
18404     enddo
18405     *** Addition: update the location and reference frame (RV 11/2/97)
18406     IF(LTREXB)THEN
18407     DO J=1,3
18408     npntBdel(j)=pntcel(j,qcel(csV),csV)
18409     ENDDO
18410     call MakeNewSys(e1Bdel,e2Bdel,e3Bdel,velBdel)
18411     ENDIF
18412     *** End of addition.
18413     if(shfillrang.eq.1)then
18414     c make the change only for first and last electrons
18415     s=0.0
18416     qn=q-1
18417     do j=1,3
18418     s = s +
18419     + (pntcel(j,(qcel(cSV)-qn),cSV)
18420     + - pntdel(j,nBdel)) * veldel(j,nBdel)
18421     enddo
18422     if(s.gt.rangpBdel)then
18423     rangpBdel=s
18424     endif
18425     if(q.gt.1)then
18426     s=0.0
18427     do j=1,3
18428     s = s +
18429     + (pntcel(j,qcel(cSV),cSV)
18430     + - pntdel(j,nBdel)) * veldel(j,nBdel)
18431     enddo
18432     if(s.gt.rangpBdel)then
18433     rangpBdel=s
18434     endif
18435     endif
18436     endif
18437     endif
18438     c call Pricel
18439     c if(nevt.eq.17.or.nevt.eq.18)then
18440     c call PriBdel(1)
18441     c write(oo,*)' q=',q,' rangpBdel=',rangpBdel
18442     c endif
18443     endif
18444     endif
18445     endif
18446     endif
18447     endif
18448    
18449     endif
18450    
18451     do j=1,3
18452     pntBdel(j)=npntBdel(j)
18453     enddo
18454     eBdel=eBdel-estepBdel
18455     rangBdel=rangBdel+stepBdel
18456     * if(shfillrang.eq.1)then
18457     c It is enouph to do at the end of each step!
18458     c It was wrong algorithm becouse
18459     c the electrons are created not on the each step
18460     * s=0.0
18461     * do j=1,3
18462     * s=s+(pntBdel(j)-pntdel(j,nBdel))*veldel(j,nBdel)
18463     * enddo
18464     * if(s.gt.rangpBdel)then
18465     * rangpBdel=s
18466     * endif
18467     * endif
18468     c if(eBdel.le.eMinBdel)then
18469     if(eBdel.le.0.000001)then
18470     c call lstdelo
18471     go to 20
18472     endif
18473     c The treatment of the electric and magnetic field
18474     c Now it will be very preliminary.
18475     c Calculate the actual velocity
18476    
18477    
18478     if(sturnBdel.eq.1)then
18479     c if(ti.le.1)then
18480     ti=ti+1
18481     v3=velBdel(3)
18482     call TurnBdel
18483     if(sgonextBdel.eq.1)then
18484     if(v3.lt.0.and.velBdel(3).gt.0)then
18485     sgonextBdel=0
18486     else
18487     if(v3.gt.0.and.velBdel(3).lt.0)then
18488     sgonextBdel=0
18489     endif
18490     endif
18491     endif
18492     c endif
18493     endif
18494    
18495     go to 10
18496    
18497     20 continue
18498    
18499     *** Changed (RV 13/5/97).
18500     C call hfill(nh2_ard,rangBdel,edel(id),1.0)
18501     call hfill(nh2_ard,real(rangBdel),edel(id),1.0)
18502     *** End of change.
18503     rangedel(nBdel)=rangBdel
18504     if(shfillrang.eq.1)then
18505     call hfill(nh2_rd,real(rangpBdel),edel(id),1.0)
18506     call hfill(nh1_rd,real(rangpBdel),0.0,1.0)
18507     rangepdel(nBdel)=rangpBdel
18508     endif
18509    
18510     qstepdel(nBdel)=nstepBdel
18511    
18512     enddo
18513    
18514     end
18515    
18516    
18517    
18518     subroutine lsgcele(e,WW,FF,irn)
18519    
18520     implicit none
18521    
18522     c include 'GoEvent.inc'
18523     +SEQ,GoEvent.
18524     c include 'hconst.inc'
18525     c include 'lsmabs.inc'
18526     real wmabs,fmabs,e,RN,SIGMA,YY,DIMMY,w,wr
18527     real WW,FF
18528     real r
18529     integer irn,i
18530     real ranfl
18531     wmabs=WW
18532     c wmabs=rionener
18533     c wmabs=0.000026
18534     fmabs=FF
18535     c fmabs=0.19
18536     c write(oo,*)' srandoff=',srandoff,' wmabs=',wmabs
18537     if(srandoff.eq.1)then
18538     fmabs=0.0
18539     endif
18540     if(e.gt.0.0)then
18541     RN=E/wmabs
18542     SIGMA=SQRT(fmabs*RN)
18543     CALL LRANOR(YY,DIMMY)
18544     c RN=RN+YY*SIGMA+0.4999
18545     r=YY*SIGMA ! so as to prevent shift
18546     if(r.lt.-RN)then
18547     r=-RN
18548     elseif(r.gt.RN)then
18549     r=RN
18550     endif
18551     c if(r.lt.-1.0)then
18552     c r=-1.0
18553     c elseif(r.gt.1.0)then
18554     c r=1.0
18555     c endif
18556    
18557     RN=RN+r
18558     if(rn.le.0.0)then
18559     irn=0
18560     return
18561     endif
18562     i=rn
18563     w=1.0-(rn-i)
18564     wr=ranfl() ! this is very small random.
18565     ! I don't want to swich it off
18566     c write(oo,*)' e,rn,i,w,wr='
18567     c write(oo,*)e,rn,i,w,wr
18568     if(wr.lt.w)then
18569     rn=i
18570     else
18571     rn=i+1
18572     endif
18573     IF(RN.LT.0.0)RN=0.0
18574     else
18575     RN=0.0
18576     endif
18577     irn=rn
18578     end
18579    
18580    
18581     subroutine lsgcele1(e,WW,FF,irn)
18582    
18583     implicit none
18584    
18585     c include 'GoEvent.inc'
18586     +SEQ,GoEvent.
18587     c include 'hconst.inc'
18588     c include 'lsmabs.inc'
18589     real wmabs,fmabs,e,RN,SIGMA,YY,DIMMY,w,wr
18590     real WW,FF
18591     real vmabs
18592     real r
18593     integer irn,i
18594     real ranfl
18595     wmabs=WW
18596     c wmabs=rionener
18597     c vmabs=0.000028
18598     c vmabs=wmabs*1.5
18599     c vmabs=wmabs
18600     vmabs=wmabs*0.5
18601     c vmabs=0.0000266
18602     if(e.le.vmabs)then
18603     irn=1
18604     return
18605     endif
18606     c wmabs=0.000026
18607     fmabs=FF
18608     c fmabs=0.19
18609     c write(oo,*)' srandoff=',srandoff
18610     if(srandoff.eq.1)then
18611     fmabs=0.0
18612     endif
18613     if(e.gt.0.0)then
18614     RN=(E-vmabs)/wmabs
18615     SIGMA=SQRT(fmabs*RN)
18616     CALL LRANOR(YY,DIMMY)
18617     c RN=RN+YY*SIGMA+0.4999
18618     r=YY*SIGMA ! so as to prevent shift
18619     if(r.lt.-RN)then
18620     r=-RN
18621     elseif(r.gt.RN)then
18622     r=RN
18623     endif
18624     c if(r.lt.-1.0)then
18625     c r=-1.0
18626     c elseif(r.gt.1.0)then
18627     c r=1.0
18628     c endif
18629    
18630     RN=RN+r
18631     if(rn.le.0.0)then
18632     irn=1
18633     return
18634     endif
18635     i=rn
18636     w=1.0-(rn-i)
18637     wr=ranfl() ! this is very small random.
18638     ! I don't want to swich it off
18639     c write(oo,*)' e,rn,i,w,wr='
18640     c write(oo,*)e,rn,i,w,wr
18641     if(wr.lt.w)then
18642     rn=i
18643     else
18644     rn=i+1
18645     endif
18646     IF(RN.LT.0.0)RN=0.0
18647     else
18648     RN=0.0
18649     endif
18650     c IF(RN.LT.1.0)RN=1.0
18651     rn=rn+1
18652     irn=rn
18653     end
18654    
18655     +DECK,Inicel.
18656     subroutine Inicel
18657    
18658     c Initialize the current electrons
18659    
18660     implicit none
18661    
18662     c include 'GoEvent.inc'
18663     +SEQ,GoEvent.
18664     c include 'volume.inc'
18665     +SEQ,volume.
18666     c include 'cel.inc'
18667     +SEQ,cel.
18668    
18669     integer k
18670    
18671     do k=1,QSVol
18672     qcel(k)=0
18673     sOverflowCel(k)=0
18674     enddo
18675    
18676     if(nevt.eq.1)then
18677     do k=1,QSVol
18678     qOverflowCel(k)=0
18679     qsOverflowCel(k)=0
18680     enddo
18681     endif
18682    
18683     end
18684    
18685     subroutine WorPricel
18686    
18687     c print the current electrons
18688    
18689     implicit none
18690    
18691     c include 'GoEvent.inc'
18692     +SEQ,GoEvent.
18693     c include 'volume.inc'
18694     +SEQ,volume.
18695     c include 'cel.inc'
18696     +SEQ,cel.
18697    
18698     integer k
18699    
18700     if(nevt.eq.qevt)then
18701    
18702     do k=1,QSVol
18703     if(qOverflowCel(k).gt.0)then
18704     go to 10
18705     endif
18706     enddo
18707     return
18708    
18709     10 continue
18710    
18711     write(oo,*)
18712     write(oo,*)' WorPricel: overflow of curren electrons arrays '
18713     write(oo,*)' QSVol=',QSVol
18714     do k=1,QSVol
18715     write(oo,*)' number of lay =',k
18716     write(oo,*)' sOverflowCel qsOverflowCel qOverflowCel'
18717     write(oo,*)sOverflowCel(k),qsOverflowCel(k),qOverflowCel(k)
18718     enddo
18719    
18720     endif
18721    
18722     end
18723    
18724     subroutine Pricel
18725    
18726     c print the current electrons
18727    
18728     implicit none
18729    
18730     c include 'GoEvent.inc'
18731     +SEQ,GoEvent.
18732     c include 'volume.inc'
18733     +SEQ,volume.
18734     c include 'cel.inc'
18735     +SEQ,cel.
18736    
18737     integer k,i,j
18738    
18739     if(soo.eq.0)return
18740     write(oo,*)
18741     write(oo,*)' Pricel: curren electrons '
18742     write(oo,*)' QSVol=',QSVol
18743     do k=1,QSVol
18744     write(oo,*)' number of lay =',k
18745     write(oo,*)' sOverflowCel qsOverflowCel qOverflowCel'
18746     write(oo,*)sOverflowCel(k),qsOverflowCel(k),qOverflowCel(k)
18747     if(qcel(k).gt.0)then
18748     write(oo,*)' qcel(k)= ',qcel(k)
18749     write(oo,*)' szcel(k)= ',szcel(k)
18750     write(oo,*)
18751     + ' ncel zcel Ndelcel sactcel'
18752     write(oo,*)
18753     + ' pntcel(1,i,k) pntcel(2,i,k) pntcel(3,i,k) '
18754     do i=1,qcel(k)
18755     write(oo,'(i5,1(1X,e12.5),5(1X,I5))')
18756     + i,zcel(i,k),
18757     + Ndelcel(i,k),sactcel(i,k)
18758     write(oo,'(3(1X,e15.8))')(pntcel(j,i,k),j=1,3)
18759     enddo
18760     endif
18761     enddo
18762    
18763    
18764     end
18765     +DECK,treatcel.
18766     subroutine treatcel
18767     c
18768     c Calculate the total charge
18769     c
18770     implicit none
18771    
18772     c include 'volume.inc'
18773     +SEQ,volume.
18774     c include 'cel.inc'
18775     +SEQ,cel.
18776    
18777     integer i,j
18778     real s
18779     c real r,cr
18780    
18781     do i=1,QSVol
18782    
18783     s=0
18784     do j=1,qcel(i)
18785     s=s+zcel(j,i)
18786     enddo
18787     szcel(i)=s
18788     enddo
18789    
18790     end
18791     +DECK,SourcePh.
18792    
18793    
18794     subroutine SourcePhot(pnt,vel,e)
18795     c
18796     c Source of the photons
18797     c
18798     implicit none
18799    
18800     c include 'GoEvent.inc'
18801     +SEQ,GoEvent.
18802     c include 'rga.inc'
18803     +SEQ,rga.
18804    
18805     real vel(3),e
18806     real*8 pnt(3)
18807     integer i,nv,nqup
18808    
18809     nv=0
18810     call VolNumZcoor(pnt(3),vel(3),nv)
18811     if(nv.eq.0)then
18812     write(oo,*)
18813     + ' worning of SourcePhot: the source can not light out of set'
18814     return
18815     endif
18816    
18817     if(qrga .eq. pqrga)then
18818     qOverflowrga=qOverflowrga+1
18819     if(sOverflowrga.eq.0)then
18820     qsOverflowrga=qsOverflowrga+1
18821     sOverflowrga=1
18822     endif
18823     else
18824    
18825    
18826     qrga=qrga+1
18827     erga(qrga)=e
18828     do i=1,3
18829     pntrga(i,qrga)=pnt(i)
18830     velrga(i,qrga)=vel(i)
18831     enddo
18832     nVolrga(qrga)=nv
18833     c Strga(qrga)=10000 in this case it need to settle
18834     c the number of transition volume
18835     c It is used in lsta_abs
18836     Strga(qrga)=1
18837     Ptrga(qrga)=0
18838     do nqup=1,pqup
18839     uprga(nqup,qrga)=0
18840     enddo
18841     SFrga(qrga)=0
18842    
18843     endif
18844    
18845     end
18846     +DECK,SourceDe.
18847    
18848    
18849     subroutine SourceDelEl(pnt,vel,e)
18850     c
18851     c Auxiliary generator of delta-electron.
18852     c
18853     implicit none
18854    
18855     c include 'GoEvent.inc'
18856     +SEQ,GoEvent.
18857     c include 'del.inc'
18858     +SEQ,del.
18859    
18860     real e,vel(3)
18861     real*8 pnt(3)
18862    
18863     integer nv,j,nqup
18864     c integer i
18865    
18866     nv=0
18867     call VolNumZcoor(pnt(3),vel(3),nv)
18868     if(nv.eq.0)then
18869     write(oo,*)
18870     + ' worning of SourceDelEl: the source can not light out of set'
18871     return
18872     endif
18873    
18874    
18875     if(qdel .eq. pqdel)then
18876     qOverflowDel=qOverflowDel+1
18877     if(sOverflowDel.eq.0)then
18878     qsOverflowDel=qsOverflowDel+1
18879     sOverflowDel=1
18880     endif
18881     else
18882    
18883     qdel=qdel+1
18884     Ptdel(qdel)=0
18885     Stdel(qdel)=1
18886     do nqup=1,pqup
18887     updel(nqup,qdel)=0
18888     enddo
18889     SOdel(qdel)=0
18890     do j=1,3
18891     pntdel(j,qdel)=pnt(j)
18892     enddo
18893     do j=1,3
18894     veldel(j,qdel)=vel(j)
18895     enddo
18896     zdel(qdel)=1
18897     edel(qdel)=e
18898     nVoldel(qdel)=nv
18899     rangepdel(qdel)=0.0
18900     rangedel(qdel)=0.0
18901    
18902     endif
18903    
18904     end
18905     +DECK,vectors.
18906     c several subroutines for vector algebra
18907     c single accuracy
18908    
18909     subroutine GoOldSys(e1,e2,e3,v,ov)
18910     c
18911     c Go to old system
18912     c
18913     implicit none
18914    
18915     real e1(3),e2(3),e3(3) ! coordinates of new orts in the old
18916     real v(3) ! vector in the new system
18917     real ov(3) ! vector in the old system
18918     c real s
18919     c integer i
18920    
18921     ov(1)=v(1)*e1(1) + v(2)*e2(1) + v(3)*e3(1)
18922     ov(2)=v(1)*e1(2) + v(2)*e2(2) + v(3)*e3(2)
18923     ov(3)=v(1)*e1(3) + v(2)*e2(3) + v(3)*e3(3)
18924    
18925     c write(6,*)' GoOldSys'
18926     c write(6,*)' v=',v
18927     c write(6,*)' ov=',ov
18928     c write(6,*)' e1=',e1
18929     c write(6,*)' e2=',e2
18930     c write(6,*)' e3=',e3
18931     c s=0.0
18932     c do i=1,3
18933     c s=s+e1(i)*e1(i)
18934     c enddo
18935     c write(6,*)' abs(e1)=',s
18936     c s=0.0
18937     c do i=1,3
18938     c s=s+e2(i)*e2(i)
18939     c enddo
18940     c write(6,*)' abs(e2)=',s
18941     c s=0.0
18942     c do i=1,3
18943     c s=s+e3(i)*e3(i)
18944     c enddo
18945     c write(6,*)' abs(e3)=',s
18946     c s=0.0
18947     c do i=1,3
18948     c s=s+ov(i)*ov(i)
18949     c enddo
18950     c write(6,*)' abs(ov)=',s
18951    
18952    
18953     end
18954    
18955     subroutine MakeNewSys(e1,e2,e3,v)
18956     c
18957     c Make new system
18958     c
18959     implicit none
18960    
18961     real e1(3),e2(3),e3(3) ! coordinates of new orts in the old
18962    
18963     real v(3) ! vector (equal)
18964    
18965     real s
18966     integer i
18967    
18968     do i=1,3
18969     e3(i)=v(i)
18970     enddo
18971     if(e3(2).eq.0.0.and.e3(3).eq.0.0)then
18972     e1(1)=0.0
18973     e1(2)=0.0
18974     e1(3)=-1.0
18975     e2(1)=0.0
18976     e2(2)=1.0
18977     e2(3)=0.0
18978     c write(6,*)' v=',v
18979     c write(6,*)' e1=',e1
18980     c write(6,*)' e2=',e2
18981     c write(6,*)' e3=',e3
18982     return
18983     endif
18984     e2(1)=0.0
18985     e2(2)=e3(3)
18986     e2(3)=-e3(2)
18987     s=0.0
18988     do i=1,3
18989     s=s+e2(i)*e2(i)
18990     enddo
18991     s=sqrt(s)
18992     do i=1,3
18993     e2(i)=e2(i)/s
18994     enddo
18995    
18996     e1(1)=e2(2)*e3(3)-e3(2)*e2(3)
18997     e1(2)=e3(1)*e2(3)-e2(1)*e3(3)
18998     e1(3)=e2(1)*e3(2)-e3(1)*e2(2)
18999    
19000     s=0.0
19001     do i=1,3
19002     s=s+e1(i)*e1(i)
19003     enddo
19004     s=sqrt(s)
19005     do i=1,3
19006     e1(i)=e1(i)/s
19007     enddo
19008    
19009     c write(6,*)' MakeNewSys'
19010     c write(6,*)' v=',v
19011     c write(6,*)' e1=',e1
19012     c write(6,*)' e2=',e2
19013     c write(6,*)' e3=',e3
19014     c s=0.0
19015     c do i=1,3
19016     c s=s+e1(i)*e1(i)
19017     c enddo
19018     c write(6,*)' abs(e1)=',s
19019     c s=0.0
19020     c do i=1,3
19021     c s=s+e2(i)*e2(i)
19022     c enddo
19023     c write(6,*)' abs(e2)=',s
19024     c s=0.0
19025     c do i=1,3
19026     c s=s+e3(i)*e3(i)
19027     c enddo
19028     c write(6,*)' abs(e3)=',s
19029     c s=0.0
19030     c do i=1,3
19031     c s=s+e1(i)*e2(i)
19032     c enddo
19033     c write(6,*)' e1*e2=',s
19034     c s=0.0
19035     c do i=1,3
19036     c s=s+e2(i)*e3(i)
19037     c enddo
19038     c write(6,*)' e2*e3=',s
19039     c s=0.0
19040     c do i=1,3
19041     c s=s+e3(i)*e1(i)
19042     c enddo
19043     c write(6,*)' e3*e1=',s
19044     c s=0.0
19045     c do i=1,3
19046     c s=s+v(i)*v(i)
19047     c enddo
19048     c write(6,*)' abs(v)=',s
19049    
19050     end
19051    
19052    
19053    
19054     subroutine Ncirclesim(e1,e2,e3,v)
19055     c
19056     c generate vector with circle simmetry in the system
19057     c around e3 axis
19058     implicit none
19059    
19060     real e1(3),e2(3),e3(3) ! coordinates of new orts in the old
19061    
19062     real v(3) ! vector (equal)
19063    
19064     c real ranfl
19065    
19066     real r(3)
19067     c real s
19068     c integer i
19069    
19070     call circlesim(r)
19071     c write(6,*)' Ncirclesim'
19072     c s=0.0
19073     c do i=1,3
19074     c s=s+r(i)*r(i)
19075     c enddo
19076     c write(6,*)' s=',s
19077     call GoOldSys(e1,e2,e3,r,v)
19078     c write(6,*)' Ncirclesim'
19079     c s=0.0
19080     c do i=1,3
19081     c s=s+e3(i)*v(i)
19082     c enddo
19083     c write(6,*)' s=',s
19084     c s=0.0
19085     c do i=1,3
19086     c s=s+v(i)*v(i)
19087     c enddo
19088     c write(6,*)' s=',s
19089     c write(6,*)' e3=',e3
19090     c write(6,*)' v=',v
19091    
19092    
19093     end
19094    
19095    
19096    
19097     subroutine circlesim(v)
19098     c
19099     c generate vector with circle simmetry around e3
19100     c around z axis
19101    
19102     implicit none
19103    
19104     real v(3) ! vector (equal)
19105    
19106     real ranfl
19107    
19108     real F
19109    
19110     F=3.14159*2.0*ranfl()
19111     v(1)=cos(F)
19112     v(2)=sin(F)
19113     v(3)=0.0
19114    
19115     end
19116    
19117    
19118     subroutine sfersim(r)
19119     c
19120     c generate vector with sferical simmetry
19121     c
19122     implicit none
19123     real r(3)
19124     real costeta,sinteta,F
19125     real RANFL
19126     c real RANFL,COS,SIN,sqrt
19127     C SFERICAL SIMMETRY
19128     costeta=1.0-2.0*RANFL()
19129     sinteta=sqrt(1.0-costeta*costeta)
19130     F=3.14159*2.0*RANFL()
19131     r(1)=COS(F)*sinteta
19132     r(2)=SIN(F)*sinteta
19133     r(3)=costeta
19134    
19135     end
19136    
19137    
19138    
19139     subroutine turnvec(e1,e2,e3,teta, v)
19140     c
19141     c turn the vector
19142     c assumed that old vector is along e3 axis
19143     c the angle phi is rundom
19144    
19145     implicit none
19146     c include 'cconst.inc'
19147     +SEQ,cconst.
19148    
19149     real e1(3),e2(3),e3(3) ! coordinates of current orts in the old
19150    
19151     real v(3) ! vector (equal)
19152     real teta
19153     integer n,i
19154     real rad(3),rss
19155     c real sqrt
19156    
19157     if(Teta.lt.0.0)Teta=-Teta
19158     if(Teta.gt.4.0*PI)then
19159     n=Teta/(4.0*PI)
19160     Teta=Teta-n*4.0*PI
19161     endif
19162     if(Teta.gt.2.0*PI)then
19163     Teta=4.0*PI-Teta
19164     endif
19165     if(Teta.eq.PI)then
19166     do i=1,3
19167     v(i)=-e3(i)
19168     enddo
19169     elseif(Teta.eq.0.0)then
19170     do i=1,3
19171     v(i)=e3(i)
19172     enddo
19173     else
19174     call Ncirclesim(e1,e2,e3,rad)
19175     rss=tan(Teta)
19176     if(rss.lt.0.0)then
19177     rss=-rss
19178     n=-1
19179     else
19180     n=1
19181     endif
19182     do i=1,3
19183     rad(i)=rad(i)*rss
19184     v(i)=n*e3(i)+rad(i)
19185     enddo
19186     rss=0.0
19187     do i=1,3
19188     rss=rss+v(i)*v(i)
19189     enddo
19190     rss=sqrt(rss)
19191     do i=1,3
19192     v(i)=v(i)/rss
19193     enddo
19194     endif
19195     c write(6,*)' turnvec'
19196     c write(6,*)' teta=',teta
19197     c write(6,*)' e1=',e1
19198     c write(6,*)' e2=',e2
19199     c write(6,*)' e3=',e3
19200     c write(6,*)' v=',v
19201     c rss=0.0
19202     c do i=1,3
19203     c rss=rss+e3(i)*v(i)
19204     c enddo
19205     c rss=acos(rss)
19206     c write(6,*)' rss=',rss
19207    
19208     end
19209     +DECK,random.
19210     subroutine Iniranfl
19211     c
19212     c Initialize the random numbers generator
19213     c iranfl is intent for calc. of number of call of geenerator
19214     c It is so as it can be possible to figer out, where the
19215     c new circle starts, if the user knows the period.
19216     c
19217     implicit none
19218    
19219     c include 'random.inc'
19220     +SEQ,random.
19221    
19222     c real*8 iranfl
19223     c common / comran / iranfl
19224     c save / comran /
19225    
19226     iranfl=0
19227    
19228     end
19229    
19230    
19231     function ranfl()
19232     c
19233     c Random numbers generator
19234     c
19235     implicit none
19236     real ranfl,ranf
19237     real x
19238    
19239     c include 'random.inc'
19240     +SEQ,random.
19241    
19242    
19243     c real*8 iranfl
19244     c common / comran / iranfl
19245     c save / comran /
19246    
19247    
19248     iranfl=iranfl+3
19249     c The several preliminary calls to avoid correlations
19250     c between the previous and the next value.
19251     x=ranf()
19252     x=ranf()
19253     ranfl=ranf() ! CERNLIB
19254    
19255     return
19256    
19257     end
19258    
19259     subroutine randset
19260     c
19261     c set the start point
19262     c
19263     implicit none
19264    
19265     c include 'random.inc'
19266     +SEQ,random.
19267    
19268     call ranset(rseed)
19269    
19270     end
19271    
19272     subroutine randget
19273     c
19274     c get the current point
19275     c
19276     implicit none
19277    
19278     c include 'random.inc'
19279     +SEQ,random.
19280    
19281     call ranget(rseed)
19282    
19283     end
19284    
19285     subroutine randpri(oo)
19286     c
19287     c print the current point
19288     c
19289     implicit none
19290    
19291     integer oo
19292    
19293     c include 'random.inc'
19294     +SEQ,random.
19295    
19296     write(oo,*)'seed=',seed
19297    
19298     end
19299    
19300    
19301     subroutine Priranfl
19302    
19303     c It is called at the end of program
19304    
19305     implicit none
19306    
19307     c include 'GoEvent.inc'
19308     +SEQ,GoEvent.
19309     c include 'random.inc'
19310     +SEQ,random.
19311    
19312     c real*8 iranfl
19313     c common / comran / iranfl
19314     c save / comran /
19315    
19316     if(soo.eq.0)return
19317     write(oo,*)
19318     write(oo,*)' Priranfl: iranfl=',iranfl
19319    
19320     end
19321    
19322    
19323    
19324     SUBROUTINE LRANOR(A,B)
19325     C.
19326     c Copy of the geant321 routine GRANOR for ranfl generator
19327     C. ******************************************************************
19328     C. * *
19329     C. * To generate 2 numbers A and B following a NORMAL *
19330     C. * distribution (mean=0 sigma=1.) *
19331     C. * Copy of the CERN Library routine RANNOR *
19332     C. * *
19333     C. * ==>Called by : <USER>, many GEANT routines *
19334     C. * Author F.Carminati ********* *
19335     C. * *
19336     C. ******************************************************************
19337     C.
19338     * DIMENSION RNDM(2)
19339     *
19340     * CALL GRNDM(RNDM,2)
19341     Y=ranfl()
19342     Z=ranfl()
19343     X=6.283185*Z
19344     A1=SQRT (-2.0*LOG(Y))
19345     A=A1*SIN (X)
19346     B=A1*COS (X)
19347     RETURN
19348     END
19349    
19350     SUBROUTINE LSPOIS (AMU,N,IERROR)
19351     C
19352     c This is modified library routine poissn.
19353     c One or two errors was corrected here.
19354     c
19355     C POISSON GENERATOR
19356     C CODED FROM LOS ALAMOS REPORT LA-5061-MS
19357     C PROB(N)=EXP(-AMU)*AMU**N/FACT(N)
19358     C WHERE FACT(N) STANDS FOR FACTORIAL OF N
19359     C ON RETURN IERROR.EQ.0 NORMALLY
19360     C IERROR.EQ.1 IF AMU.LE.0.
19361     C
19362     SAVE !my correction
19363     DATA AMUOL/-1./
19364     DATA AMAX/100./
19365     c write(6,*)' amu=',amu
19366     IERROR=0 !my correction
19367     IF(AMU.GT.AMAX) GO TO 500
19368     IF(AMU.EQ.AMUOL) GO TO 200
19369     IF(AMU.GT.0.) GO TO 100
19370     C MEAN SHOULD BE POSITIVE
19371     IERROR=1
19372     N = 0
19373     RETURN
19374     C SAVE EXPONENTIAL FOR FURTHER IDENTICAL REQUESTS
19375     100 IERROR=0
19376     AMUOL=AMU
19377     EXPMA=EXP(-AMU)
19378     200 PIR=1.
19379     c write(6,*)' ierror=',ierror
19380     N=-1
19381     300 N=N+1
19382     c PIR=PIR*RNDM(N)
19383     PIR=PIR*ranfl()
19384     IF(PIR.GT.EXPMA) GO TO 300
19385     RETURN
19386     C NORMAL APPROXIMATION FOR AMU.GT.AMAX
19387     500 CALL LRANOR(RAN,DUMMY)
19388     N=RAN*SQRT(AMU)+AMU+.5
19389     RETURN
19390     C ENTRY FOR USER TO SET AMAX, SWITCHOVER POINT TO NORMAL APPROXIMATION
19391     ENTRY lPOISET(AMU)
19392     PRINT 1001,AMU
19393     1001 FORMAT(77H POISSON RANDOM NUMBER GENERATOR TO SWITCH TO NORMAL APP
19394     CROXIMATION ABOVE AMU= ,F12.2)
19395     AMAX=AMU
19396     RETURN
19397     END
19398    
19399    
19400     SUBROUTINE lHISRAN(Y,N,XLO,XWID,XRAN)
19401    
19402     c corrected for working with program HEED
19403    
19404     C SUBROUTINE TO GENERATE RANDOM NUMBERS
19405     C ACCORDING TO AN EMPIRICAL DISTRIBUTION
19406     C SUPPLIED BY THE USER IN THE FORM OF A HISTOGRAM
19407     C F. JAMES, MAY, 1976
19408     DIMENSION Y(*)
19409     DATA IERR,NTRY,NXHRAN,NXHPRE/0,3HRAN,3HRAN,3HPRE/
19410     IF(Y(N).EQ.1.0) GOTO 200
19411     WRITE(6,1001) Y(N)
19412     1001 FORMAT('0SUBROUTINE HISRAN FINDS Y(N) NOT EQUAL TO 1.0 Y(N)='
19413     +,E15.6/' ASSUMES USER HAS SUPPLIED HISTOGRAM RATHER THAN CUMUL',
19414     +'ATIVE DISTRIBUTION AND HAS FORGOTTEN TO CALL lHISPRE'/)
19415     NTRY=NXHRAN
19416     GOTO 50
19417     C INITIALIZE HISTOGRAM TO FORM CUMULATIVE DISTRIBUTION
19418     C+SELF,IF=CDC,IF=F4.
19419     C ENTRY lHISPRE
19420     C+SELF,IF=-CDC,-F4.
19421     ENTRY lHISPRE(Y,N)
19422     C+SELF.
19423     NTRY=NXHPRE
19424     50 CONTINUE
19425     YTOT = 0.
19426     DO 100 I= 1, N
19427     IF(Y(I).LT.0.) GOTO 900
19428     YTOT = YTOT + Y(I)
19429     100 Y(I) = YTOT
19430     IF(YTOT.LE.0.) GOTO 900
19431     YINV = 1.0/YTOT
19432     DO 110 I= 1, N
19433     110 Y(I) = Y(I) * YINV
19434     Y(N) = 1.0
19435     IF(NTRY.EQ.NXHPRE) RETURN
19436     C NOW GENERATE RANDOM NUMBER BETWEEN 0 AND ONE
19437     200 CONTINUE
19438     c YR = RNDM(-1)
19439     YR=ranfl()
19440     C AND TRANSFORM IT INTO THE CORRESPONDING X-VALUE
19441     L = LOCATF(Y,N,YR)
19442     IF(L.EQ.0) GOTO 240
19443     IF(L.GT.0) GOTO 250
19444     C USUALLY COME HERE.
19445     L = ABS(L)
19446     XRAN = XLO + XWID * (L +((YR-Y(L))/(Y(L+1)-Y(L))))
19447     RETURN
19448     C POINT FALLS IN FIRST BIN. SPECIAL CASE
19449     240 XRAN = XLO + XWID * (YR/Y(1))
19450     RETURN
19451     C GUARD AGAINST SPECIAL CASE OF FALLING ON EMPTY BIN
19452     250 XRAN = XLO + L * XWID
19453     RETURN
19454     900 CONTINUE
19455     IERR = IERR + 1
19456     IF(IERR.LT.6) WRITE(6,1000)NTRY
19457     IF(L.GT.0) GOTO 250
19458     IF(NTRY.EQ.NXHPRE) RETURN
19459     1000 FORMAT('0ERROR IN INPUT DATA FOR HIS',A3,' VALUES NOT ALL >=0'/)
19460     WRITE(6,1002) (Y(K),K=1,N)
19461     1002 FORMAT(1X,10F13.7)
19462     XRAN = 0.
19463     RETURN
19464     END
19465    
19466    
19467     +DECK,hist.
19468    
19469     subroutine IniHist
19470    
19471     c initialize common histograms
19472     c
19473    
19474     implicit none
19475    
19476     c include 'GoEvent.inc'
19477     +SEQ,GoEvent.
19478     c include 'hist.inc'
19479     +SEQ,hist.
19480     c include 'volume.inc'
19481     +SEQ,volume.
19482    
19483    
19484     integer nsv
19485     integer imaxhisample
19486     imaxhisample=maxhisample
19487    
19488     if(QSVol.le.MaxHistQSVol)then
19489     hQSVol=QSVol
19490     else
19491     hQSVol=MaxHistQSVol
19492     endif
19493    
19494    
19495     do nsv=1,hQSVol ! circle over the sensitive volumes
19496    
19497    
19498    
19499     CALL HBOOK1(
19500     + nh1_ampK + nsv,
19501     + ' amplitude (KeV)$',
19502     + pqhisampl, 0.0, maxhisampl*1.0e3, 0.0)
19503     ! it is defined in MeV
19504     CALL HBOOK1(
19505     + nh1_ampKR + nsv,
19506     + ' amplitude (KeV)$',
19507     + pqhisampl, 0.0, maxhisampl*1.0e3, 0.0)
19508     ! it is defined in MeV
19509    
19510     CALL HBOOK1(
19511     + nh1_ampN+nsv,
19512     + ' amplitude in numbers of conduction electrons$',
19513     + imaxhisample, 0.0, maxhisample, 0.0)
19514    
19515    
19516    
19517     CALL HBOOK1(
19518     + nh1_cdx + nsv,
19519     + ' charge distribution along x$',
19520     + pqh2,-0.02,0.02,0.0)
19521    
19522     CALL HBOOK1(
19523     + nh1_cdy + nsv,
19524     + ' charge distribution along y$',
19525     + pqh2,-0.02,0.02,0.0)
19526    
19527     CALL HBOOK1(
19528     + nh1_cdz + nsv,
19529     + ' charge distribution along z$',
19530     + pqh2,
19531     + real(wall1(numVolSens(nsv))),
19532     + real(wall2(numVolSens(nsv))),0.0)
19533    
19534    
19535    
19536    
19537     enddo
19538    
19539    
19540    
19541    
19542     CALL HBOOK2(
19543     + nh2_ard,
19544     + ' Actual range of delta-electron(cm) vs energy(MeV).$',
19545     + pqh,0.0,1.0,
19546     + pqh,0.0,0.002,0.0)
19547     CALL HBOOK2(
19548     + nh2_rd,
19549     + 'Range along initial direction of delta-electron vs energy.$',
19550     + pqh,0.0,0.01,
19551     + pqh,0.0,0.002,0.0)
19552     CALL HBOOK1(
19553     + nh1_rd,
19554     + ' Range along initial direction of delta-electron (cm). $',
19555     + pqh,0.0,0.01,0.0)
19556    
19557    
19558    
19559    
19560    
19561     end
19562    
19563    
19564     subroutine FHist
19565    
19566     c fill histograms
19567     c
19568    
19569     implicit none
19570    
19571     c include 'GoEvent.inc'
19572     +SEQ,GoEvent.
19573     c include 'hist.inc'
19574     +SEQ,hist.
19575     c include 'volume.inc'
19576     +SEQ,volume.
19577     c include 'cel.inc'
19578     +SEQ,cel.
19579     c include 'del.inc'
19580     +SEQ,del.
19581     c include 'rga.inc'
19582     +SEQ,rga.
19583     c include 'abs.inc'
19584     +SEQ,abs.
19585     c include 'lsgvga.inc'
19586     +SEQ,lsgvga.
19587     c include 'ener.inc'
19588     +SEQ,ener.
19589     c include 'atoms.inc'
19590     +SEQ,atoms.
19591     c include 'matters.inc'
19592     +SEQ,matters.
19593     c include 'track.inc'
19594     +SEQ,track.
19595    
19596     integer nsv,ncel,nv,nm
19597    
19598     real ranfl
19599     real r
19600    
19601    
19602     do nsv=1,hqSVol
19603    
19604    
19605     nv=numVolSens(nsv)
19606     nm=nMatVol(nv)
19607    
19608     call hf1(nh1_ampK + nsv,szcel(nsv)*WWW(nm)*1.0e3,1.0)
19609    
19610     r=ranfl()-0.5
19611     r=(szcel(nsv)+r)*WWW(nm)*1.0e3
19612     if(r.lt.0)r=0
19613     call hf1(nh1_ampKR + nsv, r, 1.0)
19614    
19615     call hf1(nh1_ampN + nsv,szcel(nsv),1.0)
19616    
19617    
19618    
19619     do ncel=1,qcel(nsv) ! circle on conduction electrons
19620    
19621     call hf1(
19622     + nh1_cdx + nsv,
19623     + real(pntcel(1,ncel,nsv)), zcel(ncel,nsv))
19624    
19625     call hf1(
19626     + nh1_cdy + nsv,
19627     + real(pntcel(2,ncel,nsv)), zcel(ncel,nsv))
19628    
19629     call hf1(
19630     + nh1_cdz + nsv,
19631     + real(pntcel(3,ncel,nsv)), zcel(ncel,nsv))
19632    
19633     enddo
19634    
19635    
19636    
19637     enddo
19638    
19639    
19640    
19641     end
19642    
19643     SUBROUTINE WHist
19644     C
19645     C-----------------------------------------------------------------
19646     C| |
19647     C| TERMINATION ROUTINE TO PRINT HISTOGRAMS |
19648     C| |
19649     C| |
19650     C| |
19651     C----------------------------------------------------------------|
19652     implicit none
19653    
19654     c include 'GoEvent.inc'
19655     +SEQ,GoEvent.
19656     c include 'hist.inc'
19657     +SEQ,hist.
19658    
19659     c Integer*4 i,j,k,l,m,n
19660     Integer*4 istat,icycle
19661     C
19662     call hropen(HistLun,'mybook',HistFile,'nq',1024,istat) ! rz file
19663     if (istat.ne.0) go to 999 ! if error
19664     call hcdir('//PAWC',' ') ! root directory in memory
19665     call hcdir('//mybook',' ') ! root directory on disk
19666     CALL HROUT(0,icycle,' ') ! write all on disk
19667     C
19668     CALL HREND('mybook')
19669     C
19670     goto 1000
19671     999 continue
19672     write (oo,100)istat
19673     100 format(1x,//,1x,'*** UGLAST: error of writing, ISTAT= ',i6)
19674     1000 continue
19675     CLOSE(HistLun)
19676     RETURN
19677     END
19678     +QUIT.

  ViewVC Help
Powered by ViewVC 1.1.23