File indexing completed on 2024-04-06 12:14:00
0001
0002
0003
0004 subroutine crmc_set_f(iEvent,iSeed,pproj,ptarg,
0005 $ ipart,itarg,imodel,itab,ilheout,lheoutfile,param)
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 implicit none
0025 include "epos.inc"
0026
0027
0028 integer iSeed,ipart,itarg,imodel,itab,ilheout,iEvent,iout
0029 double precision pproj, ptarg
0030 character*1000 param,lheoutfile,output
0031 common/lheoutput/iout,output
0032
0033 real m1,m2
0034 double precision iecms,e1,e2
0035
0036 double precision ycm2det
0037 common/boostvars/ycm2det
0038
0039 common/producetab/ producetables !used to link CRMC
0040 logical producetables !with EPOS and QII
0041
0042
0043 call aaset(0)
0044
0045
0046 producetables=.false.
0047 if(itab.eq.1)producetables=.true.
0048
0049
0050 iout=ilheout
0051 output=lheoutfile
0052
0053
0054 call idmass(1120,m2) !target mass = proton
0055 m1=m2 !projectile mass
0056 if(abs(itarg).eq.120)call idmass(120,m2) !if pion as targ or proj
0057 if(abs(ipart).eq.120)call idmass(120,m1)
0058 e2=dsqrt(dble(m1)**2+ptarg**2)
0059 e1=dsqrt(dble(m2)**2+pproj**2)
0060 iecms=dsqrt((e1+e2)**2-(pproj+ptarg)**2)
0061
0062
0063 ycm2det=0
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076 call IniEpos(iEvent,iSeed,ipart,itarg,iecms,imodel)
0077
0078
0079
0080 call EposInput(param) !(it can be commented)
0081
0082
0083
0084
0085
0086 end
0087
0088 subroutine crmc_init_f()
0089
0090
0091
0092
0093
0094 implicit none
0095 integer iout
0096 character*1000 output
0097 common/lheoutput/iout,output
0098
0099
0100 call ainit
0101
0102
0103
0104
0105 if(iout.eq.1)call EposOutput(output)
0106
0107 end
0108
0109
0110 subroutine crmc_f(iout,ievent,noutpart,impactpar,outpart,outpx
0111 + ,outpy,outpz,oute,outm,outstat)
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127 implicit none
0128 include "epos.inc"
0129
0130 integer noutpart,iout,ievent
0131 double precision impactpar
0132 integer outpart(*)
0133 double precision outpx(*), outpy(*), outpz(*)
0134 double precision oute(*), outm(*)
0135 integer outstat(*)
0136
0137 double precision boostvec1,boostvec2,boostvec3,boostvec4,boostvec5
0138 double precision ycm2det
0139 common/boostvars/ycm2det !is this common block needed?
0140
0141 integer i!,k
0142
0143
0144 call aepos(-1)
0145
0146
0147 call afinal
0148
0149
0150 call hepmcstore
0151
0152
0153 call astati
0154 if(ish.ge.1) call bfinal
0155
0156
0157 if(nhep.gt.nmxhep)then
0158 print *,'Warning : produced number of particles is too high'
0159 print *,' increase nmxhep : ',nhep,' > ',nmxhep
0160
0161 endif
0162 noutpart=nhep
0163 impactpar=dble(bimevt)
0164
0165 boostvec1=0d0
0166 boostvec2=0d0
0167 boostvec3=dsinh(dble(ycm2det))
0168 boostvec4=dcosh(dble(ycm2det))
0169 boostvec5=1d0
0170
0171 do i=1,nhep
0172
0173 call utlob2(-1,boostvec1,boostvec2,boostvec3
0174 + ,boostvec4,boostvec5
0175 + ,vhep(1,i),vhep(2,i),vhep(3,i),vhep(4,i),-99)
0176 call utlob5dbl(-ycm2det
0177 + ,phep(1,i), phep(2,i), phep(3,i), phep(4,i), phep(5,i))
0178 outpart(i)=idhep(i)
0179 outpx(i)=phep(1,i)
0180 outpy(i)=phep(2,i)
0181 outpz(i)=phep(3,i)
0182 oute(i)=phep(4,i)
0183 outm(i)=phep(5,i)
0184 outstat(i)=isthep(i)
0185
0186 enddo
0187
0188
0189 if(iout.eq.1)call lhesave(ievent)
0190
0191 end
0192
0193
0194
0195 subroutine IniEpos(iEvent,iSeed,ipart,itarg,iecms,iModel)
0196
0197
0198
0199
0200
0201 implicit none
0202 include "epos.inc"
0203
0204 double precision iecms
0205 integer iSeed,ipart,itarg,iModel,iadd,idtrafo,iEvent
0206 character*4 lhct
0207
0208 iframe=11 !11 puts it always in nucleon nucleon reference
0209 !frame. This is ok because we use ecms
0210 !which is calculated in crmc_f.
0211
0212 model=max(1,iModel) ! epos = 0,1 / qgsjet01 = 2 / gheisha = 3
0213 ! / pythia = 4 / hijing = 5 / sibyll 2.1
0214 ! = 6 / qgsjetII.04 = 7 / phojet = 8
0215 ! qgsjetII.03 = 11
0216 if(iModel.eq.0)then
0217 call LHCparameters !LHC tune for EPOS
0218 isigma=1 !use analytic cross section for nuclear xs
0219 ionudi=1
0220 lhct=".lhc"
0221 iadd=4
0222 else
0223 isigma=2 !use pseudo-MC cross section for nuclear xs (slow)
0224 ionudi=3
0225 lhct=""
0226 iadd=0
0227 endif
0228
0229 nfnii=15 ! epos tab file name lenght
0230 fnii="tabs/epos.initl" ! epos tab file name
0231 nfnid=15
0232 fnid="tabs/epos.inidi"
0233 nfnie=15
0234 fnie="tabs/epos.iniev"
0235 nfnrj=15+iadd
0236 fnrj="tabs/epos.inirj"//lhct
0237 nfncs=15+iadd
0238 fncs="tabs/epos.inics"//lhct
0239
0240
0241 seedi=1.d0 !seed for random number generator: at start program
0242 seedj=iSeed !seed for random number generator: for first event
0243 jwseed=0 !print out seed in see file (1) or not
0244
0245
0246
0247 nrnody=0 !number of particle types without decay
0248 !(if 0 (default) : all unstable
0249 !particles decay (at the end only
0250 !(anti)nucleons, (anti)electrons and
0251 !muons)
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314 iecho=0 !"silent" reading mode
0315
0316
0317 ish=0 !debug level
0318 ifch=6 !debug output (screen)
0319
0320
0321
0322
0323
0324 nevent=iEvent !number of events
0325 modsho = 100000000 !printout every modsho events
0326
0327 ecms=sngl(iecms) !center of mass energy in GeV/c2
0328
0329
0330 infragm=2 !nuclear fragmentation (realistic)
0331
0332
0333 if (abs(ipart) .eq. 1) then
0334
0335 idprojin = sign(1120,ipart) !proton
0336 laproj = sign(1,ipart) !proj Z
0337 maproj = 1 !proj A
0338 elseif (ipart .eq. 12) then
0339
0340 idprojin=1120
0341 laproj = 6 !proj Z
0342 maproj = 12 !proj A
0343 elseif (ipart .eq. 208) then
0344
0345 idprojin=1120
0346 laproj = 82 !proj Z
0347 maproj = 208 !proj A
0348 elseif (ipart .eq. 120) then
0349
0350 idprojin = ipart !pi+
0351 laproj = -1 !proj Z
0352 maproj = 1 !proj A
0353 elseif (ipart .eq. -120) then
0354
0355 idprojin = ipart !pi-
0356 laproj = -1 !proj Z
0357 maproj = 1 !proj A
0358
0359 elseif (ipart.gt.10000)then
0360 idprojin=1120
0361 maproj=mod(ipart,10000)/10 !proj A
0362 laproj=mod(ipart,10000000)/10000 !proj Z
0363
0364 else
0365 idprojin=idtrafo('pdg','nxs',ipart)
0366 laproj = -1 !proj Z
0367 maproj = 1 !proj A
0368 endif
0369
0370 if(idprojin.eq.99)then
0371 print *,'Warning : projectile particle not known : ',ipart
0372 print *,' id particle must be +/-120(pi+/-)'
0373 print *,' 1(proton) 12(carbon) 208(lead) or PDG'
0374 stop
0375 endif
0376
0377
0378
0379
0380
0381
0382 if ( itarg .eq. 1 ) then
0383
0384 idtargin = sign(1120,itarg)
0385 latarg = sign(1,itarg) !targ Z
0386 matarg = 1 !targ A
0387 elseif ( itarg .eq. 12 ) then
0388
0389 idtargin=1120
0390 latarg = 6 !targ Z
0391 matarg = 12 !targ A
0392 elseif (ipart .eq. 120) then
0393
0394 idprojin = ipart !pi+
0395 laproj = -1 !proj Z
0396 maproj = 1 !proj A
0397 elseif (ipart .eq. -120) then
0398
0399 idprojin = ipart !pi-
0400 laproj = -1 !proj Z
0401 maproj = 1 !proj A
0402 elseif ( itarg .eq. 208 ) then
0403
0404 idtargin=1120
0405 latarg = 82 !targ Z
0406 matarg = 208 !targ A
0407
0408 elseif (itarg.gt.10000)then
0409 idtargin=1120
0410 matarg=mod(itarg,10000)/10 !targ A
0411 latarg=mod(itarg,10000000)/10000 !targ Z
0412
0413 elseif (abs(itarg).eq.2112.or.abs(itarg).eq.2212)then
0414 idtargin=idtrafo('pdg','nxs',itarg)
0415 latarg = -1 !targ Z
0416 matarg = 1 !targ A
0417 else
0418 print *,'Warning : target particle not known : ',itarg
0419 print *,' id particle must be +/-120(pi+/-)'
0420 print *,' 1(proton) 12(carbon) 208(lead) or PDG'
0421 stop
0422
0423 endif
0424
0425 if ( model.eq.1 ) then !model variable has no eposLHC
0426 istmax = 1 !final and mother particles (istmax=1 includes
0427 !mother particles)
0428 else
0429 istmax=0
0430 endif
0431
0432 end
0433
0434
0435 subroutine lhesave(n)
0436
0437
0438
0439
0440
0441
0442
0443
0444 include 'epos.inc'
0445
0446 integer id
0447 real taugm
0448
0449 INTEGER MAXNUP
0450 PARAMETER (MAXNUP=nmxhep) !extend array for file production
0451
0452 INTEGER NUP,IDPRUP,IDUP,ISTUP,MOTHUP,ICOLUP
0453 DOUBLE PRECISION XWGTUP,SCALUP,AQEDUP,AQCDUP,PUP,VTIMUP,SPINUP
0454 COMMON/HEPEUP/NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP,IDUP(MAXNUP),
0455 &ISTUP(MAXNUP),MOTHUP(2,MAXNUP),ICOLUP(2,MAXNUP),PUP(5,MAXNUP),
0456 &VTIMUP(MAXNUP),SPINUP(MAXNUP)
0457 SAVE /HEPEUP/
0458
0459
0460
0461 NUP=nhep !number of particles
0462 IDPRUP=nint(typevt) !type of event (ND,DD,SD)
0463 XWGTUP=1d0 !weight of event
0464 SCALUP=-1d0 !scale for PDF (not used)
0465 AQEDUP=-1d0 !alpha QED (not relevant)
0466 AQCDUP=-1d0 !alpha QCD (not relevant)
0467
0468
0469
0470 write(ifdt,'(A)') '<event>'
0471 write(ifdt,*)NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP
0472 DO 220 i=1,nhep
0473
0474
0475 IDUP(i)=idhep(i)
0476 if(isthep(i).eq.4)then
0477 ISTUP(i)=-9 !incoming particle
0478 else
0479 ISTUP(i)=isthep(i) !in LHEF:1=final, 2=decayed
0480 endif
0481 MOTHUP(1,i)=jmohep(1,i)
0482 MOTHUP(2,i)=jmohep(2,i)
0483 ICOLUP(1,i)=0 !color flow
0484 ICOLUP(2,i)=0 !color flow
0485 do J=1,5 !particle momentum (GeV/c)
0486 PUP(J,i)=phep(J,i)
0487 enddo
0488 id=idtrafo('pdg','nxs',idhep(i))
0489 call idtau(id,sngl(phep(4,i)),sngl(phep(5,i)),taugm)
0490 VTIMUP(i)=dble(taugm*(-alog(rangen())))*1d-12 !life time c*tau in mm
0491 if(VTIMUP(i).gt.dble(ainfin)
0492 & .or.VTIMUP(i).ne.VTIMUP(i))VTIMUP(i)=ainfin
0493 SPINUP(i)=9 !polarization (not known)
0494 write(ifdt,*)IDUP(i),ISTUP(i),
0495 & MOTHUP(1,i),MOTHUP(2,i),ICOLUP(1,i),ICOLUP(2,i),
0496 & (PUP(J,i),J=1,5),VTIMUP(i),SPINUP(i)
0497 220 CONTINUE
0498
0499
0500 write(ifdt,*)'#geometry',bimevt,phievt
0501
0502 write(ifdt,'(A)') '</event>'
0503
0504 if(n.eq.nevent)then
0505
0506 write(ifdt,'(A)') '</LesHouchesEvents>'
0507 write(ifdt,'(A)') ' '
0508 close(ifdt)
0509 endif
0510
0511 return
0512 end
0513
0514
0515
0516 subroutine EposOutput(iFile)
0517
0518
0519
0520 include "epos.inc"
0521 character*1000 iFile
0522
0523 istore=4
0524 nfndt=index(iFile,'.lhe')+4 !'.lhe' extension added in bstora
0525 fndt(1:nfndt)=iFile(1:nfndt)
0526 kdtopen=0
0527
0528 call bstora
0529
0530
0531
0532
0533
0534
0535 end
0536
0537
0538 subroutine EposInput(iParam)
0539
0540
0541
0542
0543
0544 include "epos.inc"
0545 character*1000 iParam
0546
0547 nopen=0
0548 ifop=52
0549 open(unit=ifop,file=TRIM(iParam),status='old')
0550 call aread
0551 close(ifop)
0552 end
0553
0554
0555
0556 subroutine utLob5dbl(yboost,x1,x2,x3,x4,x5)
0557
0558
0559
0560 implicit none
0561 double precision yboost,y,amt,x1,x2,x3,x4,x5
0562 amt=dsqrt(x5**2+x1**2+x2**2)
0563 y=dsign(1D0,x3)*dlog((x4+dabs(x3))/amt)
0564 y=y-yboost
0565 x4=amt*dcosh(y)
0566 x3=amt*dsinh(y)
0567 return
0568 end
0569
0570
0571 subroutine crmc_xsection_f(xsigtot,xsigine,xsigela,xsigdd,xsigsd
0572 & ,xsloela,xsigtotaa,xsigineaa,xsigelaaa)
0573
0574
0575
0576 implicit none
0577 include 'epos.inc'
0578 double precision xsigtot,xsigine,xsigela,xsigdd,xsigsd
0579 & ,xsloela,xsigtotaa,xsigineaa,xsigelaaa
0580
0581 xsigtot = dble( sigtot )
0582 xsigine = dble( sigine )
0583 xsigela = dble( sigela )
0584 xsigdd = dble( sigdd )
0585 xsigsd = dble( sigsd )
0586 xsloela = dble( sloela )
0587
0588 xsigtotaa = 0d0
0589 xsigineaa = 0d0
0590 xsigelaaa = 0d0
0591 if(maproj.gt.1.or.matarg.gt.1)then
0592 if(model.eq.1)then
0593 call crseaaEpos(sigtotaa,sigineaa,sigcutaa,sigelaaa)
0594 else
0595 call crseaaModel(sigtotaa,sigineaa,sigcutaa,sigelaaa)
0596 endif
0597 xsigtotaa = dble( sigtotaa )
0598 xsigineaa = dble( sigineaa )
0599 xsigelaaa = dble( sigelaaa )
0600 endif
0601
0602 return
0603 end
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639
0640
0641
0642
0643
0644
0645
0646
0647
0648
0649
0650
0651
0652
0653
0654 DOUBLE PRECISION FUNCTION DRANF(dummy)
0655
0656
0657
0658
0659
0660
0661
0662 implicit none
0663 common/eporansto2/irndmseq
0664 integer irndmseq
0665 double precision uni(1),dummy
0666
0667
0668 call RMMARD( uni,1,irndmseq)
0669
0670 DRANF = UNI(1)
0671 UNI(1) = dummy !to avoid warning
0672
0673 RETURN
0674 END
0675
0676
0677
0678 subroutine ranfgt(seed)
0679
0680
0681
0682
0683
0684
0685
0686 IMPLICIT NONE
0687 INTEGER KSEQ
0688 PARAMETER (KSEQ = 2)
0689 COMMON /CRRANMA3/CD,CINT,CM,TWOM24,TWOM48,MODCNS
0690 DOUBLE PRECISION CD,CINT,CM,TWOM24,TWOM48
0691 INTEGER MODCNS
0692 COMMON /CRRANMA4/C,U,IJKL,I97,J97,NTOT,NTOT2,JSEQ
0693 DOUBLE PRECISION C(KSEQ),U(97,KSEQ)
0694 INTEGER IJKL(KSEQ),I97(KSEQ),J97(KSEQ),
0695 * NTOT(KSEQ),NTOT2(KSEQ),JSEQ
0696 common/eporansto/diu0(100),iiseed(3)
0697 double precision seed,diu0
0698 integer iiseed,i
0699
0700 iiseed(1)=IJKL(1)
0701 iiseed(2)=NTOT(1)
0702 iiseed(3)=NTOT2(1)
0703 seed=dble(iiseed(3))*dble(MODCNS)+dble(iiseed(2))
0704 diu0(1)=C(1)
0705 do i=2,98
0706 diu0(i)=U(i-1,1)
0707 enddo
0708 diu0(99)=dble(I97(1))
0709 diu0(100)=dble(J97(1))
0710 return
0711 end
0712
0713
0714 subroutine ranfst(seed)
0715
0716
0717
0718
0719
0720
0721
0722 IMPLICIT NONE
0723 INTEGER KSEQ
0724 PARAMETER (KSEQ = 2)
0725 COMMON /CRRANMA3/CD,CINT,CM,TWOM24,TWOM48,MODCNS
0726 DOUBLE PRECISION CD,CINT,CM,TWOM24,TWOM48
0727 INTEGER MODCNS
0728 COMMON /CRRANMA4/C,U,IJKL,I97,J97,NTOT,NTOT2,JSEQ
0729 DOUBLE PRECISION C(KSEQ),U(97,KSEQ)
0730 INTEGER IJKL(KSEQ),I97(KSEQ),J97(KSEQ),
0731 * NTOT(KSEQ),NTOT2(KSEQ),JSEQ
0732 common/eporansto/diu0(100),iiseed(3)
0733 double precision seedi,seed,diu0
0734 integer i,iiseed
0735
0736 seedi=seed
0737 IJKL(1)=iiseed(1)
0738 NTOT(1)=iiseed(2)
0739 NTOT2(1)=iiseed(3)
0740 C(1)=diu0(1)
0741 do i=2,98
0742 U(i-1,1)=diu0(i)
0743 enddo
0744 I97(1)=nint(diu0(99))
0745 J97(1)=nint(diu0(100))
0746 return
0747 end
0748
0749
0750 subroutine ranflim(seed)
0751
0752 double precision seed
0753 if(seed.gt.1d9)stop'seed larger than 1e9 not possible !'
0754 end
0755
0756
0757 subroutine ranfcv(seed)
0758
0759
0760
0761
0762
0763 IMPLICIT NONE
0764 COMMON /CRRANMA3/CD,CINT,CM,TWOM24,TWOM48,MODCNS
0765 DOUBLE PRECISION CD,CINT,CM,TWOM24,TWOM48
0766 INTEGER MODCNS
0767 common/eporansto/diu0(100),iiseed(3)
0768 double precision seed,diu0
0769 integer iiseed
0770
0771 iiseed(3)=nint(seed/dble(MODCNS))
0772 iiseed(2)=nint(mod(seed,dble(MODCNS)))
0773
0774 return
0775 end
0776
0777
0778 subroutine ranfini(seed,iseq,iqq)
0779
0780
0781
0782
0783
0784
0785
0786 IMPLICIT NONE
0787 COMMON /CRRANMA3/CD,CINT,CM,TWOM24,TWOM48,MODCNS
0788 DOUBLE PRECISION CD,CINT,CM,TWOM24,TWOM48
0789 INTEGER MODCNS
0790 common/eporansto/diu0(100),iiseed(3)
0791 double precision seed,diu0
0792 integer iiseed
0793 common/eporansto2/irndmseq
0794 integer irndmseq
0795 integer iseed(3),iseq,iqq,iseqdum
0796
0797 if(iqq.eq.0)then
0798 irndmseq=iseq
0799 elseif(iqq.eq.-1)then
0800 iseqdum=0
0801 call RMMAQD(iseed,iseqdum,'R') !first initialization
0802 elseif(iqq.eq.2)then
0803 irndmseq=iseq
0804 if(seed.ge.dble(MODCNS))then
0805 write(*,'(a,1p,e8.1)')'seedj larger than',dble(MODCNS)
0806 stop 'Forbidden !'
0807 endif
0808 iiseed(1)=nint(mod(seed,dble(MODCNS)))
0809
0810 call RMMAQD(iiseed,iseq,'S') !initialize random number generator
0811 elseif(iqq.eq.1)then !dummy sequence for EPOS initialization
0812 irndmseq=iseq
0813 if(seed.ge.dble(MODCNS))then
0814 write(*,'(a,1p,e8.1)')'seedi larger than',dble(MODCNS)
0815 stop 'Forbidden !'
0816 endif
0817 iseed(1)=nint(mod(seed,dble(MODCNS)))
0818 iseed(2)=0
0819 iseed(3)=0
0820 call RMMAQD(iseed,iseq,'S') !initialize random number generator
0821 endif
0822 return
0823 end
0824
0825
0826
0827 SUBROUTINE RMMARD( RVEC,LENV,ISEQ )
0828
0829
0830
0831
0832
0833
0834
0835
0836
0837
0838
0839
0840
0841
0842
0843
0844
0845
0846
0847
0848
0849 IMPLICIT NONE
0850 INTEGER KSEQ
0851 PARAMETER (KSEQ = 2)
0852 COMMON /CRRANMA3/CD,CINT,CM,TWOM24,TWOM48,MODCNS
0853 DOUBLE PRECISION CD,CINT,CM,TWOM24,TWOM48
0854 INTEGER MODCNS
0855 COMMON /CRRANMA4/C,U,IJKL,I97,J97,NTOT,NTOT2,JSEQ
0856 DOUBLE PRECISION C(KSEQ),U(97,KSEQ),UNI
0857 INTEGER IJKL(KSEQ),I97(KSEQ),J97(KSEQ),
0858 * NTOT(KSEQ),NTOT2(KSEQ),JSEQ
0859
0860 DOUBLE PRECISION RVEC(*)
0861 INTEGER ISEQ,IVEC,LENV
0862 SAVE
0863
0864
0865
0866 IF ( ISEQ .GT. 0 .AND. ISEQ .LE. KSEQ ) JSEQ = ISEQ
0867
0868 DO IVEC = 1, LENV
0869 UNI = U(I97(JSEQ),JSEQ) - U(J97(JSEQ),JSEQ)
0870 IF ( UNI .LT. 0.D0 ) UNI = UNI + 1.D0
0871 U(I97(JSEQ),JSEQ) = UNI
0872 I97(JSEQ) = I97(JSEQ) - 1
0873 IF ( I97(JSEQ) .EQ. 0 ) I97(JSEQ) = 97
0874 J97(JSEQ) = J97(JSEQ) - 1
0875 IF ( J97(JSEQ) .EQ. 0 ) J97(JSEQ) = 97
0876 C(JSEQ) = C(JSEQ) - CD
0877 IF ( C(JSEQ) .LT. 0.D0 ) C(JSEQ) = C(JSEQ) + CM
0878 UNI = UNI - C(JSEQ)
0879 IF ( UNI .LT. 0.D0 ) UNI = UNI + 1.D0
0880
0881 IF ( UNI .EQ. 0.D0 ) UNI = TWOM48
0882 RVEC(IVEC) = UNI
0883 ENDDO
0884
0885 NTOT(JSEQ) = NTOT(JSEQ) + LENV
0886 IF ( NTOT(JSEQ) .GE. MODCNS ) THEN
0887 NTOT2(JSEQ) = NTOT2(JSEQ) + 1
0888 NTOT(JSEQ) = NTOT(JSEQ) - MODCNS
0889 ENDIF
0890
0891 RETURN
0892 END
0893
0894
0895
0896 SUBROUTINE RMMAQD( ISEED, ISEQ, CHOPT )
0897
0898
0899
0900
0901
0902
0903
0904
0905
0906
0907
0908
0909
0910
0911
0912
0913
0914
0915
0916
0917 IMPLICIT NONE
0918 INTEGER KSEQ
0919 PARAMETER (KSEQ = 2)
0920 COMMON /CRRANMA3/CD,CINT,CM,TWOM24,TWOM48,MODCNS
0921 DOUBLE PRECISION CD,CINT,CM,TWOM24,TWOM48
0922 INTEGER MODCNS
0923 COMMON /CRRANMA4/C,U,IJKL,I97,J97,NTOT,NTOT2,JSEQ
0924 DOUBLE PRECISION C(KSEQ),U(97,KSEQ),UNI
0925 INTEGER IJKL(KSEQ),I97(KSEQ),J97(KSEQ),
0926 * NTOT(KSEQ),NTOT2(KSEQ),JSEQ
0927
0928 DOUBLE PRECISION CC,S,T,UU(97)
0929 INTEGER ISEED(3),I,IDUM,II,II97,IJ,IJ97,IORNDM,
0930 * ISEQ,J,JJ,K,KL,L,LOOP2,M,NITER
0931 CHARACTER CHOPT*(*), CCHOPT*12
0932 LOGICAL FIRST
0933 SAVE
0934 DATA FIRST / .TRUE. /, IORNDM/11/, JSEQ/1/
0935
0936
0937
0938
0939 IF ( FIRST ) THEN
0940 TWOM24 = 2.D0**(-24)
0941 TWOM48 = 2.D0**(-48)
0942 CD = 7654321.D0*TWOM24
0943 CM = 16777213.D0*TWOM24
0944 CINT = 362436.D0*TWOM24
0945 MODCNS = 1000000000
0946 FIRST = .FALSE.
0947 JSEQ = 1
0948 ENDIF
0949 CCHOPT = CHOPT
0950 IF ( CCHOPT .EQ. ' ' ) THEN
0951 ISEED(1) = 54217137
0952 ISEED(2) = 0
0953 ISEED(3) = 0
0954 CCHOPT = 'S'
0955 JSEQ = 1
0956 ENDIF
0957
0958 IF ( INDEX(CCHOPT,'S') .NE. 0 ) THEN
0959 IF ( ISEQ .GT. 0 .AND. ISEQ .LE. KSEQ ) JSEQ = ISEQ
0960 IF ( INDEX(CCHOPT,'V') .NE. 0 ) THEN
0961 READ(IORNDM,'(3Z8)') IJKL(JSEQ),NTOT(JSEQ),NTOT2(JSEQ)
0962 READ(IORNDM,'(2Z8,Z16)') I97(JSEQ),J97(JSEQ),C(JSEQ)
0963 READ(IORNDM,'(24(4Z16,/),Z16)') U
0964 IJ = IJKL(JSEQ)/30082
0965 KL = IJKL(JSEQ) - 30082 * IJ
0966 I = MOD(IJ/177, 177) + 2
0967 J = MOD(IJ, 177) + 2
0968 K = MOD(KL/169, 178) + 1
0969 L = MOD(KL, 169)
0970 CD = 7654321.D0 * TWOM24
0971 CM = 16777213.D0 * TWOM24
0972 ELSE
0973 IJKL(JSEQ) = ISEED(1)
0974 NTOT(JSEQ) = ISEED(2)
0975 NTOT2(JSEQ) = ISEED(3)
0976 IJ = IJKL(JSEQ) / 30082
0977 KL = IJKL(JSEQ) - 30082*IJ
0978 I = MOD(IJ/177, 177) + 2
0979 J = MOD(IJ, 177) + 2
0980 K = MOD(KL/169, 178) + 1
0981 L = MOD(KL, 169)
0982 DO II = 1, 97
0983 S = 0.D0
0984 T = 0.5D0
0985 DO JJ = 1, 48
0986 M = MOD(MOD(I*J,179)*K, 179)
0987 I = J
0988 J = K
0989 K = M
0990 L = MOD(53*L+1, 169)
0991 IF ( MOD(L*M,64) .GE. 32 ) S = S + T
0992 T = 0.5D0 * T
0993 ENDDO
0994 UU(II) = S
0995 ENDDO
0996 CC = CINT
0997 II97 = 97
0998 IJ97 = 33
0999
1000 NITER = MODCNS
1001 DO LOOP2 = 1, NTOT2(JSEQ)+1
1002 IF ( LOOP2 .GT. NTOT2(JSEQ) ) NITER = NTOT(JSEQ)
1003 DO IDUM = 1, NITER
1004 UNI = UU(II97) - UU(IJ97)
1005 IF ( UNI .LT. 0.D0 ) UNI = UNI + 1.D0
1006 UU(II97) = UNI
1007 II97 = II97 - 1
1008 IF ( II97 .EQ. 0 ) II97 = 97
1009 IJ97 = IJ97 - 1
1010 IF ( IJ97 .EQ. 0 ) IJ97 = 97
1011 CC = CC - CD
1012 IF ( CC .LT. 0.D0 ) CC = CC + CM
1013 ENDDO
1014 ENDDO
1015 I97(JSEQ) = II97
1016 J97(JSEQ) = IJ97
1017 C(JSEQ) = CC
1018 DO JJ = 1, 97
1019 U(JJ,JSEQ) = UU(JJ)
1020 ENDDO
1021 ENDIF
1022 ELSEIF ( INDEX(CCHOPT,'R') .NE. 0 ) THEN
1023 IF ( ISEQ .GT. 0 ) THEN
1024 JSEQ = ISEQ
1025 ELSE
1026 ISEQ = JSEQ
1027 ENDIF
1028 IF ( INDEX(CCHOPT,'V') .NE. 0 ) THEN
1029 WRITE(IORNDM,'(3Z8)') IJKL(JSEQ),NTOT(JSEQ),NTOT2(JSEQ)
1030 WRITE(IORNDM,'(2Z8,Z16)') I97(JSEQ),J97(JSEQ),C(JSEQ)
1031 WRITE(IORNDM,'(24(4Z16,/),Z16)') U
1032 ELSE
1033 ISEED(1) = IJKL(JSEQ)
1034 ISEED(2) = NTOT(JSEQ)
1035 ISEED(3) = NTOT2(JSEQ)
1036 ENDIF
1037 ENDIF
1038
1039 RETURN
1040 END