COSMOS v7.655  COSMOSv7655
(AirShowerMC)
smashSkel.f File Reference

Go to the source code of this file.

Functions/Subroutines

program __smashskel.f__
 
subroutine distribute (n)
 
subroutine memoforcpu (n)
 
subroutine issuemsg (n)
 
subroutine sortbyerg
 
subroutine movetrack (f, t)
 

Function/Subroutine Documentation

◆ __smashskel.f__()

program __smashskel.f__ ( )

Definition at line 45 of file smashSkel.f.

References cerrormsg(), copenf(), copenfw2(), cpupw(), distribute(), i, issuemsg(), kgetenv2(), klena(), ksplit(), maxp, memoforcpu(), movetrack(), n, sortbyerg(), and true.

45  type(child):: cc
Definition: Zprivate.h:25
Here is the call graph for this function:

◆ distribute()

subroutine distribute ( integer  n)

Definition at line 315 of file smashSkel.f.

References cerrormsg(), cpupw(), erg, idx(), idxlocal(), kqsortd(), ksortinv(), sumergi(), and sumergw().

Referenced by __smashskel.f__(), __smashskelsmallfileno.f__(), and __smashskeltrial.f__().

315  implicit none
316 #include "Ztrack.h"
317  include "../../SkelFlesh/Zprivate.h"
318  include "Zprivate2.h"
319  integer i, k
320  integer n, j
321 
322  do i = 1, ncpu
323  sumergi(i)= 0.
324  sumergw(i) = 0.
325  noncpu(i) = 0
326  enddo
327  do i = 1, n
328 ! max energy ptcl for i-th cpu
329  sumergi(i) = erg(idx(i))
330  sumergw(i) = erg(idx(i)) / cpupw(i)
331  noncpu(i) = 1
332  idxlist(1, i) = idx(i)
333  idxlocal(i) = i
334  enddo
335 ! if all cpupw =1, next two not needed
336  call kqsortd(sumergw, idxlocal, n)
337  call ksortinv(idxlocal, n)
338 
339 !///////////
340 ! write(0,*) ' top E=',(sumergi(i), i=1, n)
341 ! write(0,*) ' idx=',(idx(i), i=1, n)
342 !////////
343 ! next explanation is for cpupw = 1
344 ! erg idx sumergi idxlocal nOnCpu idxlist
345 ! 1,1
346 ! 1 9 5 30 1 1 5
347 ! 2 1 3 18 2 1 3
348 ! n 3 18 7 15 3 1 7
349 ! 4 5 8
350 ! 5 30 1
351 ! 6 4 4
352 ! 7 15
353 ! 8 13
354 ! .
355 ! .
356 ! . 6
357 ! ctc . 2
358 !
359 ! after j= 4
360 ! sumergi idxlocal nOnCpu idxlist
361 ! 1 2
362 ! 30 1 1 5
363 ! 18 2 1 3
364 ! 28 3 2 7 8
365 ! after j=5
366 ! sumergi idxlocal nOnCpu idxlist
367 ! 1 2
368 ! 30 1 1 5
369 ! 27 3 2 3 1
370 ! 28 2 2 7 8
371 ! after j=6
372 ! sumergi idxlocal nOnCpu idxlist
373 ! 1 2 3
374 ! 30 1 1 5
375 ! 32 3 3 3 1 4
376 ! 28 2 2 7 8
377 !
378  do j = n+1, ctc
379  if(n .ge. 2) then
380  if( sumergw( idxlocal(n) ) .gt.
381  * sumergw( idxlocal(n-1) ) ) then
382  call kqsortd(sumergw, idxlocal, n)
383  call ksortinv(idxlocal, n)
384  endif
385  endif
386  k = idxlocal(n)
387  noncpu( k ) = noncpu( k ) + 1
388  if( noncpu( k ) .gt. maxptclpercpu ) then
389  write(msg, *)
390  * '# of ptcls on a cpu', k, ' exceeded limit=',
391  * maxptclpercpu
392  call cerrormsg(msg, 1)
393  call cerrormsg('Enlarge MaxPtclPerCpu in Zprivate2.h',0)
394  endif
395  idxlist( noncpu(k), k ) = idx(j)
396  sumergw(k) = sumergw(k) + erg(idx(j))/cpupw(k)
397  sumergi(k) = sumergi(k) + erg(idx(j))
398  enddo
399 
subroutine cerrormsg(msg, needrtn)
Definition: cerrorMsg.f:4
nodes i
averg real * sumergi(MaxCPU)
averg real MaxCPU integer idx(Maxp)
********************block data cblkHeavy ********************integer j data *HeavyG2symbol *data *HeavyG2code kiron data j
Definition: cblkHeavy.h:36
subroutine kqsortd(A, ORD, N)
Definition: kqsortd.f:23
subroutine ksortinv(idx, n)
Definition: ksortinv.f:2
averg real sumergw(MaxCPU)
averg real MaxCPU integer idxlocal(MaxCPU) integer numba(MaxCPU) integer ctc
float erg[maxp]
Definition: Zprivate.h:7
averg real cpupw(MaxCPU) integer nOnCpu(MaxCPU) integer idxlist(MaxPtclPerCpu
integer n
Definition: Zcinippxc.h:1
Here is the call graph for this function:
Here is the caller graph for this function:

◆ issuemsg()

subroutine issuemsg ( integer  n)

Definition at line 503 of file smashSkel.f.

References cerrormsg(), cpupw(), and sumergi().

Referenced by __smashskel.f__(), __smashskelsmallfileno.f__(), and __smashskeltrial.f__().

503  implicit none
504 #include "Ztrack.h"
505  include "../../SkelFlesh/Zprivate.h"
506  include "Zprivate2.h"
507 
508  integer n
509  integer i
510 
511  msg = ' cpu# cpuPW Sum E # of ptcls'
512 ! msg = 'cpu# Sum E # of ptcls'
513  call cerrormsg(msg, 1)
514  do i = 1, n
515  write(msg,'(i6, f7.1, g16.7, i9)')
516 ! write(msg,'(i3, g16.7, i9)')
517  * numba(i), cpupw(i), sumergi(i), noncpu(i)
518 ! * i, sumergi(i), nOnCpu(i)
519  call cerrormsg(msg, 1)
520  enddo
subroutine cerrormsg(msg, needrtn)
Definition: cerrorMsg.f:4
nodes i
averg real * sumergi(MaxCPU)
averg real cpupw(MaxCPU) integer nOnCpu(MaxCPU) integer idxlist(MaxPtclPerCpu
integer n
Definition: Zcinippxc.h:1
Here is the call graph for this function:
Here is the caller graph for this function:

◆ memoforcpu()

subroutine memoforcpu ( integer  n)

Definition at line 403 of file smashSkel.f.

References rndc().

Referenced by __smashskel.f__(), __smashskelsmallfileno.f__(), and __smashskeltrial.f__().

403  implicit none
404 #include "Ztrack.h"
405  include "../../SkelFlesh/Zprivate.h"
406  include "Zprivate2.h"
407 
408  integer n
409  integer navob, navobc, navobx
410  integer i, j, icon
411  real avob, resob
412  real*8 u
413  integer cpuc
414  type(track)::zfirst ! name is some reason
415 
416 ! we distribute Np observed ptcls (at skeleton making time)
417 ! almost equally to Mcpu cpu (not to Margin);
418 ! If some hosts fails, observed ones will be lost since
419 ! hosts of Margin have no observed ptcls. This may not have
420 ! any dangour since, observed ptcls will be only at the core
421 ! region and we don't need such region for detector simulation
422 ! number of average ptcls
423 
424  avob = np
425  avob = avob/mcpu
426 ! navobx = max(Np/Ncpu, 1)
427  navobx = np/mcpu
428 ! if( Np .eq. 0 ) navobx = 0
429 
430  resob = avob-navobx ! 0<= resob< 1
431 
432  navobc = 0
433 !/////////////////
434  write(0,*) ' navobx=', navobx, ' resob=',resob
435 !///////////
436  cpuc = 0
437  do i = 1, ncpu
438  if(numba(i) .lt. 0 ) then
439  cpuc = cpuc + 1
440  navob = navobx
441  call rndc(u)
442  if( u .lt. resob) then
443  navob = navobx + 1
444  endif
445  if(navobc+navob .gt. np .or. cpuc .eq. mcpu ) then
446  navob = np - navobc
447  endif
448 #if defined (AVOIDFOOL)
449  open(basefn+i, file=skelfile(i), position="append",
450 #else
451  open(basefn+i, file=skelfile(i), access="append",
452 #endif
453  * form="unformatted", iostat=icon)
454  if(icon .eq. 0) then
455 !/////////////
456  write(0,*) ' cpu ',i, ' cpuc=',cpuc, ' obs=',navob
457 !//////////////
458  write(basefn+i) navob
459 !
460 
461  do j = navobc +1, navobc+navob
462  write(basefn+i) oo(j)
463  enddo
464  navobc = navobc + navob
465  else
466  write(0,*) ' skelfile=', skelfile(i), " cannot be opened"
467  stop 11111
468  endif
469 
470 ! *** enddo
471 ! *** do i = 1, Ncpu
472 !cc if(i .eq. 1) then
473 ! for the first skeleton, put observed ptcls
474 !c write(basefn+i) Np
475 !c do j = 1, Np
476 !c write(basefn+1) oo(j)
477 !c enddo
478 !c else
479 !c write(basefn+i) 0
480 !c endif
481 !////////////////
482  write(0,*)' i=', i, ' nOnCpu(i)=',noncpu(i)
483 ! j = 1
484 ! write(0,*)'j=1 code=',ct( idxlist(j, i)).p.code,
485 ! * ' where=', ct( idxlist(j, i)).where
486 !///////////////////
487  write(basefn+i) noncpu(i)
488  do j = 1, noncpu(i)
489 #if defined (AVOIDFOOL)
490  zfirst = ct( idxlist(j, i) )
491  write(basefn+i)
492 #include "ZavoidUnionMap.h"
493 #else
494  write(basefn+i) ct( idxlist(j, i) )
495 #endif
496  enddo
497 
498  close(basefn+i)
499  endif
500  enddo
nodes i
Definition: Ztrack.h:44
subroutine rndc(u)
Definition: rnd.f:91
********************block data cblkHeavy ********************integer j data *HeavyG2symbol *data *HeavyG2code kiron data j
Definition: cblkHeavy.h:36
Definition: Zpos.h:16
integer n
Definition: Zcinippxc.h:1
Here is the call graph for this function:
Here is the caller graph for this function:

◆ movetrack()

subroutine movetrack ( type(child f,
type(track t 
)

Definition at line 560 of file smashSkel.f.

References asflag, charge, code, colheight, cresetdirec(), depth, height, mass, p, r, radiallen, subcode, sys, wgt, and xyz.

Referenced by __smashskel.f__(), __smashskelsmallfileno.f__(), and __smashskeltrial.f__().

560  implicit none
561 #include "Ztrack.h"
562 #include "Zearth.h"
563  include "../../SkelFlesh/Zprivate.h"
564  include "Zprivate2.h"
565 
566  type(child):: f
567  type(track):: t
568 
569  t.p.code = f.code
570  t.p.subcode = f.subcode
571  t.p.charge = f.charge
572  t.p.fm.p(1) = f.fm(1)
573  t.p.fm.p(2) = f.fm(2)
574  t.p.fm.p(3) = f.fm(3)
575  t.p.fm.p(4) = f.fm(4)
576  t.p.mass = f.mass
577  t.pos.xyz.r(1) = pp.posx
578  t.pos.xyz.r(2) = pp.posy
579  t.pos.xyz.r(3) = pp.posz
580 
581  t.pos.depth = pp.depth
582  t.pos.height = pp.height
583  t.pos.colheight = pp.colheight
584  t.t = pp.atime
585  t.where = pp.where
586  t.pos.radiallen =
587  * eradius + pp.height
588  t.pos.xyz.sys = 'xyz'
589  t.vec.w.sys = 'xyz'
590  t.wgt = 1.0
591  t.asflag = 0
592 ! t.user = pp.user
593  call cresetdirec( t )
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz *Zfirst pos *Zfirst pos depth
Definition: ZavoidUnionMap.h:1
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz *Zfirst pos *Zfirst pos Zfirst pos *Zfirst pos colheight
Definition: ZavoidUnionMap.h:1
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz r
Definition: ZavoidUnionMap.h:1
latitude latitude this system is used *****************************************************************! type coord sequence union map real z z in m endmap xyz map real ! latitude in deg is to the north ! longitude in deg is to the east *h ! height in m endmap llh map real ! polar angle ! azimuthal angle *radius ! radial distance endmap sph endunion character *sys ! which system xyz
Definition: Zcoord.h:25
Definition: Ztrack.h:44
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz sys
Definition: ZavoidUnionMap.h:1
subroutine cresetdirec(aTrack)
Definition: cresetDirec.f:5
********************block data cblkHeavy ********************integer j data *HeavyG2symbol p
Definition: cblkHeavy.h:7
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz *Zfirst pos *Zfirst pos Zfirst pos *Zfirst pos *Zfirst Zfirst vec w *Zfirst vec w Zfirst vec *Zfirst Zfirst Zfirst asflag
Definition: ZavoidUnionMap.h:1
*Zfirst p fm *Zfirst p Zfirst p code
Definition: ZavoidUnionMap.h:1
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz *Zfirst pos *Zfirst pos Zfirst pos height
Definition: ZavoidUnionMap.h:1
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p charge
Definition: ZavoidUnionMap.h:1
Definition: Zprivate.h:25
nodes t
*Zfirst p fm *Zfirst p mass
Definition: ZavoidUnionMap.h:1
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz *Zfirst pos *Zfirst pos Zfirst pos *Zfirst pos *Zfirst Zfirst vec w *Zfirst vec w Zfirst vec *Zfirst wgt
Definition: ZavoidUnionMap.h:1
*Zfirst p fm *Zfirst p Zfirst p Zfirst p subcode
Definition: ZavoidUnionMap.h:1
dE dx *! Nuc Int sampling table f
Definition: cblkMuInt.h:130
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz Zfirst pos xyz *Zfirst pos radiallen
Definition: ZavoidUnionMap.h:1
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sortbyerg()

subroutine sortbyerg ( )

Definition at line 525 of file smashSkel.f.

References cerrormsg(), erg, idx(), kqsortd(), ksortinv(), and p.

Referenced by __smashskel.f__(), __smashskelsmallfileno.f__(), and __smashskeltrial.f__().

525  implicit none
526 #include "Ztrack.h"
527  include "../../SkelFlesh/Zprivate.h"
528  include "Zprivate2.h"
529 
530  integer i
531 
532  averg = 0.
533  do i = 1, ctc
534  erg(i) = ct(i).p.fm.p(4)
535  averg = averg + erg(i)
536  enddo
537  call kqsortd(erg, idx, ctc)
538 ! high to low
539  call ksortinv(idx, ctc)
540  if(ctc .gt. 0.) then
541 ! average total energy on 1 cpu
542  averg = averg/ctc * ncpu
543  else
544  call cerrormsg('no child',1)
545  return
546  endif
547  if( erg(idx(ctc) ) .gt. averg*1.1 ) then
548 ! max energy is too large. issue
549 ! warning
550  write(msg,*) 'WARGNING: max E=', erg(idx(i)),
551  * ' is > average total energy for 1 cpu=',
552  * averg
553  call cerrormsg(msg, 1)
554  endif
subroutine cerrormsg(msg, needrtn)
Definition: cerrorMsg.f:4
nodes i
averg real MaxCPU integer idx(Maxp)
********************block data cblkHeavy ********************integer j data *HeavyG2symbol p
Definition: cblkHeavy.h:7
subroutine kqsortd(A, ORD, N)
Definition: kqsortd.f:23
subroutine ksortinv(idx, n)
Definition: ksortinv.f:2
float erg[maxp]
Definition: Zprivate.h:7
Here is the call graph for this function:
Here is the caller graph for this function: