TABLE OF CONTENTS


ABINIT/m_timana [ Modules ]

[ Top ] [ Modules ]

NAME

  m_timana

FUNCTION

 Analyse the timing, and print in unit ab_out. Some discussion of the

COPYRIGHT

  Copyright (C) 1998-2018 ABINIT group (XG, GMR)
  This file is distributed under the terms of the
  GNU General Public License, see ~abinit/COPYING
  or http://www.gnu.org/copyleft/gpl.txt .

PARENTS

CHILDREN

SOURCE

21 #if defined HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24 
25 #include "abi_common.h"
26 
27 module m_timana
28 
29  use defs_basis
30  use m_abicore
31  use m_xmpi
32  use m_xomp
33 
34  use m_time,        only : time_accu, timab, TIMER_SIZE
35  use defs_abitypes, only : MPI_type
36 
37  implicit none
38 
39  private

ABINIT/timana [ Functions ]

[ Top ] [ Functions ]

NAME

 timana

FUNCTION

 Analyse the timing, and print in unit ab_out. Some discussion of the
 number of calls to different routines is also provided, as comments,
 at the end of the routine, as well as, in the single dataset mode (ndtset<2),
 a detailed analysis of the time-consuming routines.

INPUTS

  mpi_enreg=information about MPI parallelization
  natom=number of atoms in cell.
  nband(nkpt*nsppol)=number of bands at each k point, for each polarization
  ndtset=number of datasets
  nfft=(effective) number of FFT grid points (for this processor)
  nkpt=number of k points
  npwtot(nkpt)=number of planewaves in basis at this k point
  nsppol=1 for unpolarized, 2 for spin-polarized
  timopt= if >0, write short analysis, if <0, write full analysis
          if timopt>=2, or timopt==-2 do not time the timer

OUTPUT

  (only writing)

NOTES

 *) One can suppress the cpu timer call in timein.f, if line 315 of the present routine is uncommented.

 *) The number of fourwf and nonlop calls can be computed as follows, in the
    groud-state case, with no reading of wavefunctions (irdwfk==0 and the like),
    and iscf>0 :

    1) For fourwf.f

    In each cgwf call, there will be
    1 call (isign=+1 and -1) for the first gradient calculation,
    and iline calls for the line minimizations,
    minus the number of ffts skipped because some wfs are sufficiently converged
    (there is a counter for that, see the log file)

    There are nband*nkpt*(nstep+2) calls to cgwf presently, where the
    (nstep+2) comes from the number of the presence of 2 nonscf loops
    in the first 2 steps.
    Thus, the number of fourwf calls in cgwf is
    nband*nkpt*(nstep+2)*(1+iline) - nskip_fourwf_in_cgwf

    To compute the density (either in vtowfk or in vtorho - by a mkrho call - )
    at each step, there will be nband*nkpt one-way calls,
    minus the number of bands skipped because the occupation number
    is too small (smaller than 1.0d-14). There is another counter for that.
    Thus, the number of fourwf calls for the density is
    nband*nkpt*nstep - nskip_fourwf_for_density

    For example, for Si with nline=3, nkpt=2, nband=4, nstep=10, and supposing
    no fourwf calls are skipped, there will be
    at most 4*2*12=96 calls to cgwf, with 4 two-way fft,
    that is 384 two-way ffts,
    and 4*2*10=80 one-way ffts to make the density.
    Altogether 464-nskip one-way ffts at most.

    2) For nonlop.f

    Presently, there are three different types of call to nonlop :
    for energy and gradient wrt wavefunctions (choice=1), for forces (choice=2),
    and for stresses (choice=3).

    In each cgwf call, there will be one nonlop call for two fourwf calls
    (independently of the number of skipped fourwf calls, since
    nonlop is also skipped then). These are the only calls with choice=1.
    Thus the number will be
    nband*nkpt*(nstep+2)*(1+iline) - nskip_fourwf_in_cgwf

    The number of choice=2 nonlop calls is equal to the number of fourwf calls
    to make the density, that is
    nband*nkpt*nstep - nskip_fourwf_for_density

    The number of choice=8 calls is equal to the number of occupied bands
    at the end of the calculation :
    nband(occupied)*nkpt
    The number of bands skipped then is not counted.

    NOTE : the number of fourwf calls is equal to
    the # of nonlop (choice=1) calls + the # of nonlop (choice=2) calls

PARENTS

      abinit

CHILDREN

      timab,time_accu,wrtout,xmpi_sum

SOURCE

 140 subroutine timana(mpi_enreg,natom,nband,ndtset,nfft,nkpt,npwtot,nsppol,timopt)
 141 
 142 
 143 !This section has been created automatically by the script Abilint (TD).
 144 !Do not modify the following lines by hand.
 145 #undef ABI_FUNC
 146 #define ABI_FUNC 'timana'
 147 !End of the abilint section
 148 
 149  implicit none
 150 
 151 !Arguments ------------------------------------
 152 !scalars
 153  integer,intent(in) :: natom,ndtset,nfft,nkpt,nsppol,timopt
 154  type(MPI_type),intent(in) :: mpi_enreg
 155 !arrays
 156  integer,intent(in) :: nband(nkpt*nsppol),npwtot(nkpt)
 157 
 158 !Local variables-------------------------------
 159 !scalars
 160  integer :: aslot,bslot,cslot,flag_count,flag_write,ierr,ii,ikpt,ipart
 161  integer :: ilist,isort,islot,isppol,itim,itimab,ltimab,maxii,me
 162  integer :: npart,nlist,nothers,nproc,nthreads,return_ncount
 163  integer(i8b) :: npwmean,npwnbdmean
 164  integer :: spaceworld,temp_list,totcount,tslot,utimab,ount
 165  real(dp) :: cpunm,lflops,other_cpu,other_wal,percent_limit,subcpu,subwal,timab_cpu,timab_wall,wallnm
 166  character(len=500) :: message
 167 !arrays
 168  integer(i8b) :: basic(TIMER_SIZE),ndata(TIMER_SIZE),tslots(TIMER_SIZE)
 169  integer :: ncount(TIMER_SIZE)
 170  integer,allocatable :: list(:)
 171  real(dp) :: ftimes(2,TIMER_SIZE),ftsec(2),mflops(TIMER_SIZE),nflops(TIMER_SIZE),times(2,TIMER_SIZE),tsec(2),my_tsec(2)
 172  character(len=32) :: names(-1:TIMER_SIZE),entry_name
 173  character(len=*),parameter :: format01040 ="('- ',a24,f12.3,f6.1,f11.3,f6.1,i15,16x,f7.2,1x,f10.2)"
 174  character(len=*),parameter :: format01041 ="('- ',a24,f12.3,f6.1,f11.3,f6.1,i15,3x,g12.3,1x,f7.2,1x,f10.2)"
 175  character(len=*),parameter :: format01042 ="('- ',a24,f12.3,f6.1,f11.3,g12.3,i15)"
 176  character(len=*),parameter :: format01045 ="('-',i3,a19,f15.3,f6.1,f11.3,f6.1)"
 177  !character(len=*),parameter ::  format01200 ="('- subtotal     ',f15.3,f6.1,f11.3,f6.1)"
 178 
 179 ! *************************************************************************
 180 
 181  01200 format('- subtotal             ',f15.3,f6.1,f11.3,f6.1,31x,f7.2,1x,f10.2)
 182  01201 format(/,'- subtotal             ',f15.3,f6.1,f11.3,f6.1,31x,f7.2,1x,f10.2)
 183 
 184  ount = ab_out
 185 
 186  call timab(49,1,tsec)
 187 
 188 !The means are computed as integers, for later compatibility
 189  npwmean=0; npwnbdmean=0
 190  do isppol=1,nsppol
 191    do ikpt=1,nkpt
 192      npwmean=npwmean+npwtot(ikpt)
 193      npwnbdmean=npwnbdmean+npwtot(ikpt)*nband(ikpt+(isppol-1)*nkpt)
 194    end do
 195  end do
 196 
 197 !initialize ftime, valgrind complains on line 832 = sum up of all Gflops
 198  ftimes=zero
 199 
 200  npwmean=dble(npwmean)/dble(nkpt*nsppol)
 201  npwnbdmean=dble(npwnbdmean)/dble(nkpt*nsppol)
 202 
 203 !List of timed subroutines, eventual initialisation of the number of data, and declaration of a slot as being "basic"
 204 !Channels 1 to 299 are for optdriver=0 (GS), 1 (RF) and 2 (Suscep), at random
 205 !Channels 300 to 399 are for optdriver=3 (Screening)
 206 !Channels 400 to 499 are for optdriver=4 (Sigma)
 207 !Channels 500 to 529 are for optdriver=5 (Nonlinear)
 208 !Channels 530 to 549 are for various counters
 209 !Channels 550 to 599 are for PAW
 210 !Channels 600 to 619 are for Recursion Method
 211 !Channels 620 to 639 are for DMFT
 212 !Channels 650 to 699 are for bethe_salpeter code.
 213 !Channels 700 to 799 are for optdriver=0 (again ...)
 214 !Channels 800 to 899 are for the detailed analysis of fourwf
 215 !Channels 900 to 1499 are for optdriver=0 (again ...)
 216 !Channels 1500 to 1519 are for Hartree-Fock.
 217 !Channels 1700 to 1747 are for GWLS.
 218 !Channels 1520 and beyond are not yet attributed.
 219 
 220  names(1:TIMER_SIZE)='***                             '
 221 !Basic slots are not overlapping. Their sum should cover most of the code.
 222 !WARNING : the slots from 1 to 99 should be avoided in the future ... They are hard to track.
 223  basic(1:TIMER_SIZE)=0
 224  names(1)='abinit                          '
 225  names(5)='ewald                           ' ; basic(5)=1
 226  names(6)='setsym                          ' ; basic(6)=1
 227  names(9)='fourdp                          ' ; basic(9)=1 ;    ndata(9)=nfft
 228  names(10)='hartre                          '
 229  names(11)='xc:pot/=fourdp                  '; basic(11)=1;    ndata(11)=nfft*nsppol
 230  names(12)='mkcore                          '; basic(12)=1
 231  names(13)='mkresi                          '
 232  names(14)='rwwf                            '; basic(13)=1
 233  names(15)='pspini                          '; basic(15)=1
 234  names(16)='mkffnl                          '
 235  names(17)='symrhg(no FFT)                  '; basic(17)=1
 236  names(19)='inwffil                         '
 237 
 238  names(22)='cgwf                            '
 239  names(23)='kpgsph                          '; basic(23)=1   ! Actually, should not be basic ... too complicated, too much overlap ...
 240  names(28)='vtowfk                          '
 241  names(30)='vtowfk  (afterloop)             '
 242  names(31)='vtowfk  (1)                     '; basic(31)=1
 243  names(32)='gstate                          '
 244  names(33)='gstate->kpgsph                  '
 245  names(34)='gstate  (2)                     '
 246  names(35)='gstate(...scfcv)                '
 247  names(36)='gstate  (3)                     '
 248  names(37)='stress                          '; basic(37)=1   ! Actually, should not be basic !
 249  names(38)='ewald2 (+vdw_dftd)              '; basic(38)=1
 250  names(39)='vtowfk (loop)                   '
 251  names(40)='cgwf-O(npw)                     '
 252  names(41)='abinit(1)                       '
 253  names(42)='abinit(2)                       '; basic(42)=1
 254  names(43)='indefo+macroin+invars2m         '
 255  names(44)='abinit(4)                       '
 256  names(45)='abinit(5)                       '
 257  names(46)='abinit(6)                       '
 258  names(47)='ingeo/symgroup                  '
 259  names(48)='communic.MPI                    '
 260  names(49)='timana(1)                       '
 261  names(50)='timing timab                    '; basic(50)=1
 262  names(51)='total timab                     '
 263  names(52)='scfcv-scprqt                    '; basic(52)=1
 264  names(53)='forces-mkcore                   '
 265  names(54)='scfcv_core(1)                   '
 266  names(55)='stress-mkcore                   '
 267  names(56)='scfcv_core-read                 '
 268  names(57)='rhotov                          '
 269  names(59)='energy                          '
 270  names(60)='scfcv_core(etotfor)             '
 271  names(61)='scfcv_core :synchro             '
 272  names(62)='kpgio :synchro                  '
 273  names(63)='mkrho :synchro                  '
 274  names(64)='strkin:synchro                  '
 275  names(65)='forstrnps:synchr                '
 276  names(66)='vtorho:synchro                  '; basic(66)=1
 277  names(67)='wfsinp:synchro                  '
 278  names(68)='scfcv_core(mix den - newrho)     '
 279  names(69)='forces                          '; basic(69)=1 ! Actually, should not be basic !
 280  names(70)='vtorho(symrhg)                  '
 281  names(71)='mkrho :MPIrhor                  '
 282  names(72)='mklocl(2)                       '
 283  names(73)='status                          '; basic(73)=1
 284  names(74)='newocc                          '
 285  names(75)='nonlop(apply)                   '; basic(75)=1; ndata(75)=npwmean*natom
 286  names(76)='nonlop(forces)                  '; basic(76)=1; ndata(76)=npwmean*natom
 287  names(77)='nonlop(forstr)                  '; basic(77)=1; ndata(77)=npwmean*natom
 288  names(78)='nonlop(dyfrnl)                  '
 289  names(79)='nonlop(ddk)                     '
 290  names(80)='etotfor/=forces                 '
 291  names(81)='xc:pot                          ' ! rhotoxc_coll, except the call to hartre.f
 292  names(82)='xc:fourdp                       '
 293  names(83)='newvtr/rho(3):io                '; basic(83)=1
 294  names(84)='suscep                          '
 295  names(85)='suscep:MPI                      '; basic(85)=1
 296  names(86)='suscep:synchro                  '; basic(86)=1
 297  names(87)='suskXX:loop(1)                  '
 298  names(88)='suskXX:loop(2)                  '
 299  names(89)='suscep:other                    '
 300  names(90)='dielmt                          '; basic(90)=1
 301  names(91)='setvtr                          '
 302  names(92)='setvtr:mkcore                   '
 303  names(93)='newvtr                          '
 304  names(94)='newrho                          '
 305  names(95)='tddft                           '
 306  names(96)='dieltcel                        '; basic(96)=1
 307  names(97)='nonlop(total)                   '
 308  names(98)='getghc-other                    '; basic(98)=1
 309 
 310  names(101)='dfpt_nstdy                      '
 311  names(102)='dfpt_nstwf                      '
 312  names(108)='dfpt_vtowfk(contrib)            '; basic(108)=1
 313  names(118)='dfpt_vtorho (1)                 '; basic(118)=1
 314  names(120)='dfpt_scfcv                      '
 315  names(121)='dfpt_vtorho                     '
 316  names(122)='dfpt_cgwf                       '
 317  names(124)='dfpt_vtorho (1)(2)              '
 318  names(125)='dfpt_vtorho (2)                 '
 319  names(126)='dfpt_vtorho-kpt loop            '; basic(126)=1
 320  names(127)='dfpt_vtorho (4)                 '
 321  names(128)='dfpt_vtowfk                     '
 322  names(129)='dfpt_vtorho:MPI                 '; basic(129)=1
 323  names(130)='dfpt_vtowfk (3)                 '; basic(130)=1
 324  names(131)='dfpt_vtowfk (1)                 '; basic(131)=1
 325  names(132)='respfn                          '
 326  names(133)='respfn(kpgio)                   '
 327  names(134)='respfn(pspini)                  '
 328  names(135)='respfn(inwffil)                 '
 329  names(136)='respfn(frozen)                  '
 330  names(137)='respfn(dfpt_dyxc1+bef.dfpt_lop) '
 331  names(138)='respfn(after dfpt_loper)        '
 332  names(139)='dfpt_vtowfk (loop)              '
 333  names(140)='dfpt_cgwf-O(npw)                '; basic(140)=1
 334  names(141)='dfpt_loper                      '
 335  names(142)='dfpt_loper(kpgio)               '
 336  names(143)='dfpt_loper(getmpw)              '
 337  names(144)='dfpt_loper(inwffil)             '
 338  names(146)='dfpt_loper(outwf)               '
 339  names(147)='dfpt_loper(eig2tot)             '
 340  names(148)='eig2tot                         '; basic(148)=1
 341  names(150)='dfpt_nselt/nstdy/nstpaw         '
 342  names(152)='dfpt_scfcv-scprqt               '
 343  names(154)='dfpt_scfcv  (1)                 '; basic(154)=1
 344  names(157)='dfpt_rhotov                     '
 345  names(158)='dfpt_newvtr                     '
 346  names(159)='d2frnl                          '
 347  names(160)='dfpt_scfcv (6)                  '
 348  names(161)='dfpt_nstdy:synchro              '; basic(161)=1
 349  names(166)='dfpt_vtorho:synchro             '; basic(166)=1
 350  names(181)='dfpt_mkvxc                      '
 351  names(182)='dfpt_dyxc1                      '; basic(182)=1
 352 !names(184)='dfpt_dyxc1(analysis)            '
 353 
 354  names(191)='invars2                         '; basic(191)=1
 355  names(192)='inkpts                          '
 356  names(193)='fresid                          '
 357 
 358  names(197)='getgh1c%dfpt_cgwf               '
 359  names(198)='getgh1c%dfpt_nstwf              '
 360  names(199)='getgh1c%dfpt_nstpaw             '
 361 
 362  names(200)='getghc                          '
 363  names(201)='getghc%cgwf                     '
 364  names(202)='getghc%dfpt_cgwf                '
 365  names(203)='getghc%mkresi                   '
 366  names(204)='getghc%kss_ddiago               '
 367  names(205)='getghc%lobpcgwf                 '
 368  names(206)='getghc%prep_getghc              '
 369  names(207)='getghc%other lobpcg             '
 370  names(208)='getghc%update_mmat              '
 371 
 372  names(210)='projbd                          '; basic(210)=1;    ndata(210)=npwnbdmean
 373  names(211)='projbd%cgwf                     '
 374  names(212)='projbd%dfpt_cgwf                '
 375  names(213)='projbd%dfpt_nstpaw              '
 376  names(214)='corrmetalwf1%dfpt_vtowfk        '
 377 
 378  names(220)='nonlop%(other)                  '
 379  names(221)='nonlop%getghc                   '
 380  names(222)='nonlop%vtowfk                   '
 381  names(223)='nonlop%energy                   '
 382  names(224)='nonlop%forstrnps                '
 383  names(225)='nonlop%dfpt_nstwf               '
 384  names(226)='nonlop%d2frnl                   '
 385  names(227)='nonlop%dfpt_cgwf !2             '
 386  names(228)='nonlop%dfpt_cgwf !5             '
 387  names(229)='nonlop%outkss                   '
 388  names(230)='nonlop%vtowfk(rhoij)            '
 389  names(231)='nonlop%prep_nonl%vtowfk         '
 390  names(232)='nonlop%prep_nonl%forstrn        '
 391  names(233)='nonlop%appinvovl                '
 392  names(234)='nonlop%prep_nonl%energy         '
 393 
 394  names(238)='scfcv_core                      '
 395  names(239)='scfcv_core(Berry)               '
 396  names(240)='scfcv_core(iniloop, setvtr  )   '
 397  names(241)='scfcv_core(loop, PAW)           '
 398  names(242)='scfcv_core(vtorho(f))           '
 399  names(243)='scfcv_core(rhotov)              '
 400  names(244)='scfcv_core(qui loop)            '
 401  names(245)='scfcv_core(mix pot)             '
 402  names(246)='scfcv_core(just after scf)      '
 403  names(247)='scfcv_core(afterscfloop)        '
 404  names(248)='scfcv_core(outscfcv)            '
 405  names(249)='scfcv_core(free)                '
 406 
 407  names(250)='afterscfloop                    '
 408  names(251)='afterscfloop(wvl)               '
 409  names(252)='afterscfloop(pol/magn)          '
 410  names(253)='afterscfloop(grad/lapl)         '
 411  names(254)='afterscfloop(kin.en.den)        '
 412  names(255)='afterscfloop(elf)               '
 413  names(256)='afterscfloop(forstr)            '
 414  names(257)='afterscfloop(final)             '
 415 
 416  names(260)='fourdp%(other)                  '
 417  names(261)='fourdp%rhotwg%ch                '
 418  names(262)='fourdp%rhotwg%si                '
 419  names(263)='fourdp%ckxcldag                 '
 420  names(264)='fourdp%fftwfn%ch                '
 421  names(265)='fourdp%fftwfn%si                '
 422  names(266)='fourdp%rec%rho                  '
 423  names(267)='fourdp%rec%ek                   '
 424  names(268)='fourdp%newvtr                   '
 425  names(269)='fourdp%newrho                   '
 426 
 427  names(270)='rwwf%(other)                    '
 428  names(271)='rwwf%vtorho                     '
 429  names(272)='rwwf%initwf(GS)                 '
 430  names(273)='rwwf%energy                     '
 431  names(274)='rwwf%wfsinp(GS)                 '
 432  names(275)='rwwf%mkrho                      '
 433  names(276)='rwwf%outwf                      '
 434  names(277)='rwwf%strnps                     '
 435  names(278)='rwwf%tddft                      '
 436  names(279)='rwwf%suscep                     '
 437  names(281)='rwwf%wfsinp(RF)                 '
 438  names(282)='rwwf%mkrho2                     '
 439  names(283)='rwwf%outwf2                     '
 440  names(284)='rwwf%dfpt_dyfnl                 '
 441  names(285)='rwwf%dfpt_mkrho                 '
 442  names(286)='rwwf%dfpt_nstwf                 '
 443  names(287)='rwwf%dfpt_vtorho                '
 444  names(288)='rwwf%dfpt_vtowfk                '
 445  names(289)='rwwf%dfpt_nstdy                 '
 446  names(290)='rwwf%initwf(RF)                 '
 447  names(291)='rwwf%newkpt(GS)                 '
 448  names(292)='rwwf%newkpt(RF)                 '
 449 
 450  names(301)='screening                       '
 451  names(302)='screening(init1)                '
 452  names(304)='screening(KS=>QP[wfrg])         '
 453  names(305)='screening(density)              '
 454  names(306)='screening(q-loop,init )         '
 455  names(307)='screening(cchi0q0)              '
 456  names(308)='screening(cchi0)                '
 457  names(309)='screening(q-loop,end)           '
 458  names(310)='screening(wrt scr files)        '
 459  names(315)='screening(pawin)                '
 460  names(316)='screening(wfs)                  '
 461  names(319)='screening(1)                    '
 462  names(320)='screening(paw)                  '; basic(320)=1
 463  names(321)='screening(2)                    '
 464 
 465  names(331)='cchi0                           '
 466  names(332)='cchi0(rho_tw_g)                 '
 467  names(333)='cchi0(assembly)                 '
 468 
 469  names(401)='sigma                           '
 470  names(402)='sigma(Init1)                    '
 471  names(403)='setup_sigma                     '
 472  names(404)='sigma(rdkss)                    '
 473  names(405)='sigma(Init2)                    '
 474  names(406)='sigma(make_vhxc)                '
 475  names(407)='sigma(vHxc_me)                  '
 476  names(408)='sigma(hqp_init)                 '
 477  names(409)='sigma(getW)                     '
 478  names(410)='sigma/=fourdp                   '; basic(410)=1
 479 
 480  names(421)='sigma(calc_sigx_me)             '
 481  names(423)='sigma(cohsex_me)                '
 482  names(424)='sigma(calc_sigc_me)             '
 483  names(425)='sigma(solve_dyson)              '
 484  names(426)='sigma(finalize)                 '
 485 
 486  names(430)='calc_sigx_me                    '
 487 
 488  names(431)='calc_sigc_me                    '
 489  names(432)='calc_sigc_me(Init)              '
 490  names(433)='calc_sigc_me(Init spin)         '
 491  names(434)='calc_sigc_me(Init q)            '
 492  names(435)='calc_sigc_me(eet_sigma)         '
 493  names(436)='calc_sigc_me(1)                 '
 494  names(437)='calc_sigc_me(rho_tw_g)          '
 495  names(438)='calc_sigc_me(2)                 '
 496  names(439)='calc_sigc_me(sigma_me)          '
 497  names(440)='calc_sigc_me(wfd_barrier        '
 498  names(441)='calc_sigc_me(xmpi_sum)          '
 499  names(442)='calc_sigc_me(final ops)         '
 500 
 501  names(445)='calc_sigc_me(loop)              '
 502 
 503  names(490)='solve_dyson                     '
 504  names(491)='cohsex_me                       '
 505 
 506  names(501)='nonlinear                       '
 507  names(502)='pead_nl_loop                    '
 508  names(503)='dfptnl_loop                     '
 509  names(511)='dfptnl_mv                       '; basic(511)=1
 510  names(512)='pead_nl_resp                    '; basic(512)=1
 511  names(513)='dfptnl_pert                     '
 512  names(514)='rf2_init                        '
 513 
 514  names(520)='lobpcgwf(init)                  '; if(abs(timopt)==4)basic(520)=1
 515  names(521)='lobpcgwf(bef.getghc 1           '; if(abs(timopt)==4)basic(521)=1
 516  names(522)='lobpcgwf(aft.getghc 1           '; if(abs(timopt)==4)basic(522)=1
 517  names(523)='lobpcgwf(bef.getghc 2           '; if(abs(timopt)==4)basic(523)=1
 518  names(524)='lobpcgwf(aft.getghc 2           '; if(abs(timopt)==4)basic(524)=1
 519  names(525)='lobpcgwf(aft.loop)              '; if(abs(timopt)==4)basic(525)=1
 520  names(526)='lobpcgwf(prep-getghc)           '
 521 
 522  names(530)='lobpcgwf                        '
 523  names(532)='xgemm%lobpcg                    '
 524  names(533)='xmpi_sum%lobpcg                 '
 525  names(535)='xorthon-xtrsm                   '
 526  names(536)='xprecon%lobpcg                  '
 527  names(537)='prep_fourwf%vtow                '
 528  names(538)='prep_fourwf%mkrh                '
 529  names(539)='prep_fourwf                     '
 530 
 531  names(540)='sg_fourwf%fourwf                '
 532  names(541)='back_wf%sg_fourw                '
 533  names(542)='forw_wf%sg_fourw                '
 534  names(543)='alltoall%back_wf                '
 535  names(544)='alltoall%forw_wf                '
 536  names(545)='prep_getghc(alltoall)           '
 537  names(547)='alltoall%prep_fo                '
 538  names(548)='allgather%prep_f                '
 539  names(549)='symrhg%mkrho                    '
 540 
 541  names(550)='forces:pawatm2ff                '
 542  names(551)='stress:pawatm2ff                '
 543  names(552)='setvtr:pawatm2ff                '
 544  names(553)='pawinit                         '; basic(553)=1
 545  names(554)='vtowfk:rhoij                    '
 546  names(555)='vtorho:pawmkrhoij               '; basic(555)=1
 547  names(556)='pawmkrho                        '; basic(556)=1
 548  names(557)='pawmkrho:symrhoij               '; basic(557)=1
 549  names(558)='scfcv_core:mknhat               '
 550  names(559)='nhatgrid                        '; basic(559)=1
 551  names(560)='pawdenpot                       '; basic(560)=1
 552  names(561)='pawdij/symdij                   '; basic(561)=1
 553  names(562)='respfn:pawatm2ff                '; basic(562)=1
 554  names(563)='dfpt_dyfro:pawatm2ff            '; basic(563)=1
 555  names(564)='dfpt_scfcv:dfpt_mknhat          '; basic(564)=1
 556  names(565)='getgsc                          '
 557  names(566)='dfpt_nstpaw                     '; basic(566)=1
 558  names(567)='pawnstd2e                       '
 559  names(568)='stress%strhar                   '
 560 
 561  names(570)='prep_nonlop                     '
 562  names(572)='prep_nonlop%vtowfk              '
 563  names(573)='prep_nonlop%forstrnps           '
 564 
 565  names(575)='prep_bandfft_tabs               '; basic(575)=1
 566 
 567  names(581)='prep_nonlop(alltoall)           '
 568  names(583)='vtowfk(pw_orthon)               '
 569  names(584)='xcopy%lobpcg                    '
 570  names(585)='vtowfk(subdiago)                '
 571  names(586)='vtowfk(nonlocalpart)            '
 572  names(587)='zheegv-dsyegv                   '
 573 
 574  names(588)='vtowfk(ssdiag)                  '; basic(588)=1
 575  names(589)='vtowfk(contrib)                 '; basic(589)=1
 576  names(590)='vtowfk(2)                       '
 577  names(591)='vtowfk(3)                       '
 578 
 579  names(593)='set_paw_pert                    '
 580  names(594)='get_exchange_atom               '
 581  names(595)='pawrhoij_redistribute           '
 582  names(596)='paw_ij_redistribute             '
 583  names(597)='paw_an_redistribute             '
 584  names(598)='pawfgrtab_redistribute          '
 585 
 586  names(600)='vtorhorec                       '
 587  names(601)='Definitions                     '
 588  names(602)='getngrec                        '
 589  names(603)='green_kernel                    '
 590  names(604)='transgrid (c->f)                '
 591  names(605)='recursion (other)               '
 592  names(606)='recursion (den)                 '
 593  names(607)='recursion (cuda)                '
 594  names(608)='recursion_nl                    '
 595  names(609)='fermisolverec                   '
 596  names(610)='entropyrec                      '
 597  names(611)='gran_potrec                     '
 598  names(612)='nonlocal-energy                 '
 599  names(613)='sync. cpu (wait)                '
 600  names(614)='sync. gpu (wait)                '
 601  names(615)='vn_nl_rec                       '
 602  names(616)='null recursion                  '
 603  names(617)='recursion (other_cuda)          '
 604 
 605  names(620)='datafordmft                     '
 606  names(621)='initialize dmft loop            '
 607  names(622)='impurity_solve                  '
 608  names(623)='Dyson                           '
 609  names(624)='compute_green                   '
 610  names(625)='integrate_green                 '
 611  names(626)='dmft-other                      '
 612  names(627)='Print/Read self                 '
 613 
 614  names(630)='prep_getghc                     '
 615  names(631)='prep_getghc(before if)          '
 616  names(632)='prep_getghc(bef. getghc)        '
 617  names(633)='prep_getghc(betw getghc)        '
 618  names(634)='prep_getghc(aft. getghc)        '
 619  names(635)='prep_getghc(getghc - 1 )        '
 620  names(636)='prep_getghc(getghc - 2 )        '
 621  names(637)='prep_getghc(getghc - 3 )        '
 622  names(638)='prep_getghc(getghc - 4 )        '
 623 
 624  names(640)='driver                          '
 625  names(641)='driver(bef. loop dtset)         '
 626  names(642)='driver(bef. select case)        '
 627  names(643)='driver(aft. select case)        '
 628  names(644)='driver(aft. loop dtset)         '
 629 
 630  names(650)='bse                             '
 631  names(651)='bse(Init1)                      '; basic(651)=1
 632  names(652)='setup_bse                       '; basic(652)=1
 633  names(653)='bse(rdkss)                      '; basic(653)=1
 634  names(654)='bse(rdmkeps^-1)                 '; basic(654)=1
 635  names(655)='bse(mkrho)                      '; basic(655)=1
 636  names(656)='bse(mkexcham)                   '; basic(656)=1
 637  names(657)='bse(mkexceps)                   '; basic(657)=1
 638  names(658)='bse(wfd_wave_free)              '; basic(658)=1
 639  names(659)='bse(mk_pawhur_t)                '; basic(659)=1
 640  names(660)='bse(exc_diago_driver)           '; basic(660)=1
 641  names(661)='bse(exc_haydock_driver)         '; basic(661)=1
 642 
 643 
 644  names(670)='exc_build_ham                   '
 645  names(671)='exc_build_ham(q=0)              '
 646  names(672)='exc_build_ham(block-res)        '
 647  names(673)='exc_build_ham(block-coupling)   '
 648 
 649  names(680)='exc_build_block                 '
 650  names(681)='exc_build_block(init,read)      '
 651  names(682)='exc_build_block(Coulomb)        '
 652  names(683)='exc_build_block(exchange)       '
 653  names(684)='exc_build_block(synchro)        '
 654  names(685)='exc_build_block(write_ha        '
 655  names(686)='exc_build_block(exch.spi        '
 656 
 657  names(690)='exc_haydock_driver              '
 658  names(691)='exc_haydock_driver(read)        '
 659  names(692)='exc_haydock_driver(prep)        '
 660  names(693)='exc_haydock_driver(wo lf        '
 661  names(694)='exc_haydock_driver(apply)       '
 662  names(695)='exc_haydock_driver(end)         '
 663  names(696)='exc_haydock_driver(inter        '
 664  names(697)='exc_haydock_driver(matmul)      '
 665 !Slots up to 699 are reserved for bethe_salpeter code.
 666 
 667  names(700)='gstateimg                       '
 668  names(701)='gstate(pspini)                  '
 669  names(702)='gstateimg(leave_test)           '
 670  names(703)='gstateimg(init)                 '
 671  names(704)='gstateimg(bef. loop img)        '
 672  names(705)='gstateimg(bef. gstate)          '
 673  names(706)='gstateimg(aft. gstate)          '
 674  names(707)='gstateimg(aft. loop img)        '
 675  names(708)='gstateimg(finalize)             '
 676 
 677 
 678  names(710)='inwffil                         '
 679  names(711)='inwffil(read header)            '
 680  names(712)='inwffil(init params)            '
 681  names(713)='inwffil(prepa wfsinp)           '
 682  names(714)='inwffil(call wfsinp)            '
 683  names(715)='inwffil(after wfsinp)           '
 684  names(716)='inwffil(spin convert)           '
 685  names(717)='inwffil(call newkpt)            '
 686  names(718)='inwffil(excl. calls)            '; basic(718)=1
 687 
 688  names(720)='wfsinp                          '
 689  names(721)='wfsinp(before loop)             '
 690  names(722)='wfsinp(find kpt)                '
 691  names(723)='wfsinp(prepa initwf)            '
 692  names(724)='wfsinp(call  initwf)            '
 693  names(725)='wfsinp(transfer of wfs)         '
 694  names(726)='wfsinp(call rwwf)               '
 695  names(727)='wfsinp(wfconv section)          '
 696  names(728)='wfsinp(excl. calls)             '; basic(728)=1
 697 
 698  names(740)='suscep_stat                     '
 699  names(741)='suscep_stat(init)               '
 700  names(742)='suscep_stat(bef. susk-mm        '
 701  names(743)='suscep_stat(susk-mm)            '
 702  names(744)='suscep_stat(extrapol)           '
 703  names(745)='suscep_stat:synchro             '
 704  names(746)='suscep_stat:MPI                 '
 705  names(747)='suscep_stat(symmetries)         '
 706 
 707  names(750)='susk                            '
 708  names(751)='susk (init)                     '; basic(751)=1
 709  names(752)='susk (loop)                     '
 710  names(753)='susk:MPI (1)                    '; basic(753)=1
 711  names(754)='susk (accumul.)                 '
 712  names(755)='susk:MPI (2)                    '; basic(755)=1
 713  names(756)='susk (loop except FFT)          '; basic(756)=1
 714  names(757)='susk (accumul.except FFT        '; basic(757)=1
 715 
 716  names(760)='suskmm                          '
 717  names(761)='suskmm (init)                   '; basic(761)=1
 718  names(762)='suskmm (loop : part1)           '
 719  names(763)='suskmm (loop : part2)           '
 720  names(764)='suskmm(loop1 except FFT)        '; basic(764)=1
 721  names(765)='suskmm(loop2 except FFT)        '; basic(765)=1
 722 
 723  names(770)='initwf                          '
 724  names(771)='initwf(before rwwf)             '; basic(771)=1
 725  names(772)='initwf(after rwwf)              '; basic(772)=1
 726 
 727  names(780)='newkpt                          '
 728  names(781)='newkpt(before loop)             '
 729  names(782)='newkpt(before rwwf)             '
 730  names(783)='newkpt(after rwwf)              '
 731  names(784)='newkpt(call wfconv)             '
 732  names(785)='newkpt(finalize loop)           '
 733  names(786)='newkpt(after loop   )           '
 734  names(787)='newkpt:synchro                  '
 735  names(788)='newkpt(excl. rwwf   )           '; basic(788)=1
 736 
 737  names(790)='mkrho                           '
 738  names(791)='mkrho%gstate                    '
 739  names(792)='mkrho%vtorho                    '
 740  names(793)='mkrho%energy                    '
 741  names(794)='mkrho%respfn                    '
 742  names(795)='mkrho%afterscfloop              '
 743  names(796)='mkrho%scfcv_core                '
 744  names(798)='mkrho/=                         '; basic(798)=1
 745  names(799)='mkrho/=+fourwf                  '
 746 
 747  names(801)='fourwf                          '
 748  names(802)='fourwf%(pot)                    '; basic(802)=1;    ndata(802)=2*nfft
 749  names(803)='fourwf%(den)                    '; basic(803)=1;    ndata(803)=nfft
 750  names(804)='fourwf%(G->r)                   '; basic(804)=1
 751  names(805)='fourwf%(r->G)                   '; basic(805)=1
 752 
 753 
 754  names(840)='fourwf%(other)                  '
 755  names(841)='fourwf%getghc                   '
 756  names(842)='fourwf%vtowfk                   '
 757  names(843)='fourwf%mkrho                    '
 758  names(844)='fourwf%dfpt_cgwf                '
 759  names(845)='fourwf%dfpt_accrho%dfpt_vtowfk  '
 760  names(846)='fourwf%mkrho2                   '
 761  names(847)='fourwf%dfpt_mkrho               '
 762  names(854)='fourwf%tddft                    '
 763  names(855)='fourwf%outkss                   '
 764  names(856)='fourwf%prep_four                '
 765  names(858)='fourwf%dfpt_accrho%idfpt_nstpaw '
 766  names(861)='fourwf%suskmm !0 part 1         '
 767  names(862)='fourwf%suskmm !0 part 2         '
 768  names(871)='fourwf%suskmm !3 part 1         '
 769  names(872)='fourwf%suskmm !3 part 2         '
 770 
 771  names(901)='newvtr(before selection)        '
 772  names(902)='newvtr(bef. prcref_PMA)         '
 773  names(903)='newvtr(call prcref_PMA)         '
 774  names(904)='newvtr(aft. prcref_PMA)         '
 775  names(905)='newvtr(mean potential)          '
 776 
 777  names(910)='forstr                          '
 778  names(911)='forstr(forstrnps)               '
 779  names(912)='forstr(pawgrnl)                 '
 780  names(913)='forstr(forces)                  '
 781  names(914)='forstr(stress)                  '
 782 
 783  names(920)='forstrnps                       '
 784  names(921)='forstrnps(bef.loop spin)        '
 785  names(922)='forstrnps(bef.loop band)        '
 786  names(923)='forstrnps(copy)                 '
 787  names(924)='forstrnps(kinetic contr)        '
 788  names(925)='forstrnps(aft.loop kptsp        '
 789  names(926)='forstrnps(nonlop+prep_ba        '
 790  names(927)='forstrnps(bef.loop kpt)         '
 791 
 792  names(933)='outkss                          '
 793  names(934)='outkss(Gsort+hd)                '
 794  names(935)='outkss(k-loop)                  '
 795  names(936)='outkss(diago)                   '; basic(936)=1
 796  names(937)='outkss(MPI_exch)                '; basic(937)=1
 797  names(938)='outkss(write)                   '
 798 
 799  names(940)='rhotov                          '
 800  names(941)='rhotov(rhotoxc)                 '
 801  names(942)='rhotov(dotprod_vn)              '
 802  names(943)='rhotov(PSolver_rhohxc)          '
 803  names(944)='rhotov(rhohxcpositron)          '
 804  names(945)='rhotov(other)                   '
 805 
 806  names(950)='outscfcv                        '
 807  names(951)='outscfcv(mlwfovlp)              '
 808  names(952)='outscfcv([PAW]prtden)           '
 809  names(953)='outscfcv(prtelf)                '
 810  names(954)='outscfcv(prt[g,k,l]den)         '
 811  names(955)='outscfcv(prtwf)                 '
 812  names(956)='outscfcv(prtpot)                '
 813  names(957)='outscfcv(prt geo misc.)         '
 814  names(958)='outscfcv(prt stm,vha,..)        '
 815  names(959)='outscfcv(prtdos)                '
 816  names(960)='outscfcv(calcdensph)            '
 817  names(961)='outscfcv(pawprt)                '
 818  names(962)='outscfcv(optics)                '
 819  names(963)='outscfcv(pawmkaewf)             '
 820  names(964)='outscfcv(outkss)                '
 821  names(965)='outscfcv(poslifetime)           '
 822  names(966)='outscfcv(outwant)               '
 823  names(967)='outscfcv(cal[cs,efg,fc])        '
 824  names(968)='outscfcv(prt[surf,nest])        '
 825  names(969)='outscfcv(misc.)                 '
 826 
 827  names(980)='vtorho                          '
 828  names(981)='vtorho(bef. spin loop)          '
 829  names(982)='vtorho(bef. kpt  loop)          '
 830  names(983)='vtorho(Berry)                   '
 831  names(984)='vtorho(bef. vtowfk)             '
 832  names(985)='vtorho(aft. vtowfk)             '
 833  names(986)='vtorho(aft. kpt loop)           '
 834  names(987)='vtorho(leave_test)              '; basic(987)=1
 835  names(988)='vtorho(aft. spin loop)          '
 836  names(989)='vtorho(MPI)                     '; basic(989)=1
 837  names(990)='vtorho(newocc)                  '
 838  names(991)='vtorho(DMFT)                    '
 839  names(992)='vtorho(mkrho 1)                 '
 840  names(993)='vtorho(highest occ. eig)        '
 841  names(994)='vtorho(mkrho 2)                 '
 842  names(995)='vtorho(tddft)                   '
 843  names(996)='vtorho(suscep_stat)             '
 844  names(997)='vtorho(init kpt loop)           '
 845 
 846  names(1001)='initberry                       '; basic(1001)=1
 847  names(1002)='initberry(before listkk)        '
 848  names(1003)='initberry(call listkk)          '
 849  names(1004)='initberry(after listkk)         '
 850  names(1005)='initberry(find neighb.)         '
 851  names(1006)='initberry(build strings)        '
 852  names(1007)='initberry(PAW on-site)          '
 853  names(1008)='initberry(pwind)                '
 854  names(1009)='initberry(MPI stuff)            '
 855  names(1021)='listkk                          '
 856 
 857 ! CMartins : TEST for HF
 858  names(1501)='HF_init                         '; basic(1501)=1
 859  names(1502)='HF_updatecgocc                  '; basic(1502)=1
 860  names(1503)='HF_updatecgocc-MPI              '; basic(1503)=1
 861  names(1504)='HF_getghc                       '; basic(1504)=1
 862  names(1505)='HF_getghc-init                  '; basic(1505)=1
 863  names(1506)='HF_getghc-kmu_loop              '; basic(1506)=1
 864  names(1507)='HF_getghc-calc_vlocpsi          '; basic(1507)=1
 865  names(1508)='HF_getghc-mult-cwf*cwocc        '; basic(1508)=1
 866  names(1509)='HF_getghc-calc_rhog_munu        '; basic(1509)=1
 867  names(1510)='HF_getghc-calc_vloc             '; basic(1510)=1
 868  names(1511)='HF_getghc-calc_ghc              '; basic(1511)=1
 869 
 870  ! Chebfi
 871  names(1600) = 'chebfi                        '; basic(1601) = 1
 872  names(1601) = 'chebfi(alltoall)              '
 873  names(1602) = 'chebfi(appinvovl)             '
 874  names(1603) = 'chebfi(rotation)              '
 875  names(1604) = 'chebfi(subdiago)              '
 876  names(1605) = 'chebfi(subham)                '
 877  names(1606) = 'chebfi(ortho)                 '
 878  names(1607) = 'chebfi(getghc)                '
 879  names(1608) = 'chebfi(residuals)             '
 880  names(1609) = 'chebfi(update_eigens)         '
 881  names(1610) = 'chebfi(sync)'
 882 
 883  names(1630) = 'chebfi(opernla)               '
 884  names(1631) = 'chebfi(opernlb)               '
 885  names(1632) = 'chebfi(inv_s)                 '
 886 
 887  names(1620) = 'mkinvovl                      '
 888  names(1621) = 'mkinvovl(build_d)             '
 889  names(1622) = 'mkinvovl(build_ptp)           '
 890 
 891  ! lobpcg2
 892  names(1650) = 'lobpcgwf2                     '; basic(1650) = 1
 893  names(1651) = 'lobpcg_init                    '
 894  names(1652) = 'lobpcg_free                    '
 895  names(1653) = 'lobpcg_run                     '
 896  names(1654) = 'lobpcg_getAX_BX                '
 897  names(1655) = 'lobpcg_orthoWrtPrev            '
 898  names(1656) = 'lobpcg_Bortho                  '
 899  names(1657) = 'lobpcg_RayleighRitz            '
 900  names(1658) = 'lobpcg_maxResidu               '
 901  names(1659) = 'lobpcg_run@getAX_BX            '
 902  names(1660) = 'lobpcg_pcond                   '
 903  names(1661) = 'lobpcg_RayleighRitz@hegv       '
 904 
 905  ! xg_t
 906  names(1670) = 'xgBlock_potrf                  '
 907  names(1671) = 'xgBlock_trsm                   '
 908  names(1672) = 'xgBlock_gemm                   '
 909  names(1673) = 'xgBlock_set                    '
 910  names(1674) = 'xgBlock_get                    '
 911  names(1675) = 'xgBlock_heev                   '
 912  names(1676) = 'xgBlock_heevd                  '
 913  names(1677) = 'xgBlock_hpev                   '
 914  names(1678) = 'xgBlock_hpevd                  '
 915  names(1679) = 'xgBlock_hegv                   '
 916  names(1680) = 'xgBlock_hegvx                  '
 917  names(1681) = 'xgBlock_hegvd                  '
 918  names(1682) = 'xgBlock_hpgv                   '
 919  names(1683) = 'xgBlock_hpgvx                  '
 920  names(1684) = 'xgBlock_hpgvd                  '
 921  names(1685) = 'xgBlock_copy                   '
 922  names(1686) = 'xgBlock_cshift                 '
 923  names(1687) = 'xgBlock_pack                   '
 924  names(1690) = 'xgScalapack_init               '
 925  names(1691) = 'xgScalapack_free               '
 926  names(1692) = 'xgScalapack_heev               '
 927  names(1693) = 'xgScalapack_hegv               '
 928  names(1694) = 'xgScalapack_scatter            '
 929 
 930  ! GWLS GW code
 931  names(1701)='gwls_sternheimer                ';basic(1701)=1
 932  names(1702)='exchange and correlation        '
 933  names(1703)='correl. shift lanczos           '
 934  names(1704)='Dielectric matrix               '
 935  names(1705)='Model Dielectric matrix         '
 936  names(1706)='setup proj. sternheimer         '
 937  names(1707)='compute proj.sternheimer        '
 938  names(1708)='eps^{-1} - eps_m^{-1}           '
 939  names(1709)='eps_m^{-1} - 1                  '
 940  names(1710)='Modify Lbasis Coulomb           '
 941  names(1711)='Diag eps^{-1}-eps_m^{-1}        '
 942  names(1712)='exact  AT shift lanczos         '
 943  names(1713)='model  AT shift lanczos         '
 944  names(1714)='exact  BT shift lanczos         '
 945  names(1715)='model  BT shift lanczos         '
 946  names(1716)='compute poles                   '
 947  names(1717)='Sigma_A Lanczos                 '
 948  names(1718)='Sigma_B num. integrands         '
 949 
 950 
 951  names(1719)='gwls: extract_QR                ';basic(1719)=1
 952  names(1720)='gwls: extract_SVD               ';basic(1720)=1
 953 
 954  ! these entry are not in a logical order.
 955  names(1721)='gwls: gstateimg                 '
 956  names(1722)='prepareValenceWfk               '
 957 
 958  names(1723)='gwls: sqmr                      ';basic(1723)=1
 959 
 960 
 961  names(1724)='gwls: Pk                        ';basic(1724)=1
 962  names(1725)='Pk- allocating                  '
 963  names(1726)='Pk- wfk to denpot               '
 964  names(1727)='Pk- wfk product with val        '
 965  names(1728)='Pk- pc_k                        '
 966  names(1729)='Pk- sqmr case 1                 '
 967  names(1730)='Pk- sqmr case 2                 '
 968  names(1731)='Pk- sqmr case 3                 '
 969  names(1732)='Pk-  qmr case 4                 '
 970  names(1733)='Pk- apply H (case 2)            '
 971 
 972 
 973  names(1734)='gwls: Pk_model                  ';basic(1734)=1
 974  names(1735)='Pk_model- allocating            '
 975  names(1736)='Pk_model- wfk to denpot         '
 976  names(1737)='Pk_model- wfk x val             '
 977  names(1738)='Pk_model- pc_k                  '
 978  names(1739)='Pk_model- act with Y            '
 979  names(1740)='Pk_model- add contrib.          '
 980 
 981 
 982  names(1741)='gwls: calc eps_m^-1(w)-1        ';basic(1741)=1
 983  names(1742)='Allocating                      '
 984  names(1743)='modifying Lanczos basis         '
 985  names(1744)='calc <mod_L_1|Y|mod_L_2>        '
 986  names(1745)='    make array hermitian        '
 987  names(1746)='               xsum_mpi         '
 988  names(1747)='inv eps_m and subtract 1        '
 989 
 990 
 991  names(TIMER_SIZE)='(other)                         ' ! This is a generic slot, to compute a complement
 992 
 993 !==================================================================================
 994 
 995  spaceworld= mpi_enreg%comm_world
 996  nproc     = mpi_enreg%nproc
 997  me        = mpi_enreg%me
 998  nthreads  = xomp_get_num_threads(open_parallel=.true.)
 999 
1000  call timab(49,2,tsec)
1001 
1002  if(abs(timopt)==1 .or. timopt==-3 .or. timopt==-4)then ! Time the timing routine (precision should be better than 3%)
1003    ltimab=1
1004    utimab=1000
1005    maxii=20
1006 !  maxii=1    ! Uncomment this line if no timer is provided in timein.f
1007    do ii=1,20
1008 
1009      call timab(50,1,tsec)
1010      do itimab=ltimab,utimab
1011 !      The channel 51 is here used as a dummy channel
1012        call timab(51,1,tsec)
1013        call timab(51,2,tsec)
1014      end do
1015      call timab(50,2,tsec)
1016      call time_accu(50,return_ncount,tsec, lflops, ftsec)
1017 !    Exit the timing loop if the CPU time is bigger than 0.10 second
1018 !    of if the number of calls is too large.
1019 !    Since the accuracy of the timing is expected to be better than 0.01 sec,
1020 !    gives about 10% accuracy
1021      if(tsec(1)>0.10_dp)then
1022        exit
1023      else
1024        ltimab=utimab+1
1025 !      Increase the number of timab calls in a block.
1026 !      This small factor of increase allows to have less than
1027 !      0.15 second for this testing
1028        utimab=(3*utimab)/2
1029      end if
1030    end do
1031 !  Get the time per combined call timab(*,1,tsec) + timab(*,2,tsec)
1032    timab_cpu=tsec(1)/utimab
1033    timab_wall=tsec(2)/utimab
1034    if(timopt<0 .and. me==0 .and. timopt/=-2)then
1035      write(ount,*)
1036      write(ount,*)'Test the timer : '
1037      write(ount,*)' a combined call timab(*,1,tsec) + timab(*,2,tsec) is '
1038      write(ount, '(a,es14.4,a,es14.4,a)' )&
1039 &     '- CPU time =',timab_cpu,' sec,    Wall time =',timab_wall,' sec'
1040    end if
1041  else
1042    timab_cpu=zero; timab_wall=zero
1043  end if
1044 
1045 !Eventually reenable the timab routine
1046  call timab(1,5,tsec)
1047 
1048 !Get overall elapsed cpu and wall clock time
1049  call timab(1,2,tsec)
1050  call time_accu(1,return_ncount,tsec,lflops,ftsec)
1051  ncount(1)=return_ncount
1052 
1053 !Sum over all procs
1054  my_tsec(:)=tsec(:)
1055  call xmpi_sum(my_tsec,tsec,2,spaceworld,ierr)
1056 
1057 !Only the world master writes
1058  if (me==0) then
1059    write(ount,'(/,a,f13.1,f12.2,f11.3)')'- Total cpu        time (s,m,h):',tsec(1),tsec(1)/60._dp,tsec(1)/3600._dp
1060    write(ount,'(a,f13.1,f12.2,f11.3)')  '- Total wall clock time (s,m,h):',tsec(2),tsec(2)/60._dp,tsec(2)/3600._dp
1061  end if
1062 
1063 !Get separate time reports from all timed sections
1064  totcount=0
1065  do itim=1,TIMER_SIZE
1066    call time_accu(itim,return_ncount,times(:,itim),nflops(itim),ftimes(:,itim))
1067    ncount(itim)=return_ncount
1068    totcount=totcount+return_ncount
1069  end do
1070 
1071 !Estimate additional timings.
1072 
1073 !Estimate the values associated with timab, put it in channel 51
1074  ncount(51)=totcount
1075  times(1,51)=timab_cpu*totcount
1076  times(2,51)=timab_wall*totcount
1077 
1078 !Gather the different parts of selected time slots
1079 !Or, alternatively, deduce the value of the complement of some time slots.
1080 !This loop is finished when the default case is hit (see below)
1081  do ii=1,TIMER_SIZE
1082 
1083    tslots(:)=0
1084 
1085 !  List first the time slot in which the result will be accumulated.
1086 !  If this number is negative, the positive value will be used for the time slot, but the ncount will be set to -1 .
1087 !  Then, list the time slots whose value will be either accumulate or subtracted. The latter is obtained by
1088 !  entering a minus sign in front of the time slot number ...
1089 !  If a negative number is present in the list, while the accumulated time slot is positive,
1090 !  then the number of counts will be set to the value of the first routine to be accumulated.
1091    select case(ii)
1092 !    Gather the different parts of nonlop  (SHOULD BE REEXAMINED !)
1093    case(1)
1094      tslots(:5)=(/75, 221,223,229,233/)
1095    case(2)
1096      tslots(:4)=(/76, 222,225,227/)
1097    case(3)
1098      tslots(:2)=(/77, 224/)
1099    case(4)
1100      tslots(:2)=(/78, 226/)
1101    case(5)
1102      tslots(:2)=(/79, 228/)
1103    case(6)
1104 !      Gather the different parts of selected time channels
1105      tslots(:10)=(/97, 75,76,77,78,79,220,230,231,232/)
1106    case(7)
1107 !      Gather the different parts of fourwf (NOTE : should attribute the channel 840 to one of the 4 modes !!!)
1108      tslots(:3)=(/802, 841,844/)
1109    case(8)
1110      tslots(:4)=(/803, 842,843,846/)
1111    case(9)
1112      tslots(:10)=(/804, 845,847,848,850,854,858,859,861,862/)
1113    case(10)
1114      tslots(:6)=(/805, 849,851,857,871,872/)
1115    case(11)
1116 !      In the following, the part coming from the prep_fourwf interface is added to the total.
1117      tslots(:7)=(/801, 802,803,804,805,840,856/)
1118    case(13)
1119 !      Gather the different parts of prep_fourwf
1120      tslots(:3)=(/539, 537,538/)
1121    case(14)
1122 !      Gather the different parts of fourdp
1123      tslots(:11)=(/9, 260,261,262,263,264,265,266,267,268,269/)
1124    case(15)
1125 !      Gather the different parts of getghc
1126      tslots(:9)=(/200, 201,202,203,204,205,206,207,208/)
1127    case(16)
1128 !      Gather the different parts of projbd
1129      tslots(:3)=(/210, 211,212/)
1130    case(17)
1131 !      Gather the different parts of rwwf (wavefunctions read/write)
1132      tslots(:24)=&
1133 &     (/14, 270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292/)
1134    case(18)
1135 !      Estimate the complement of getghc (non fourwf, non nonlop)
1136      tslots(:4)=(/-98, 200,-841,-221/)
1137    case(19)
1138 !      Estimate the complement of cgwf (non getghc,projbd)
1139      tslots(:5)=(/-40, 22,530,-201,-211/)
1140    case(20)
1141 !      Estimate the complement of dfpt_cgwf (non getghc,projbd,nonlop,fourwf)
1142      tslots(:8)=(/-140, 122,-202,-197,-212,-227,-228,-844/)
1143    case(21)
1144 !      Estimate different complements in vtowfk
1145 !      vtowfk(ssdiag) (= vtowfk(loop)    - cgwf )
1146      tslots(:5)=(/-588, 39,-22,-530, -1600/)
1147    case(22)
1148 !      vtowfk(contrib) (= vtowfk (afterloop) - nonlop%vtowfk - fourwf%vtowfk )
1149      tslots(:4)=(/589, 30,-222,-842/)
1150    case(23)
1151 !      vtowfk (1) = vtowfk - vtowfk(loop) - vtowfk(afterloop)
1152      tslots(:4)=(/31, 28,-39,-30/)
1153    case(24)
1154 !      Estimate different complements in dfpt_vtowfk
1155 !      dfpt_vtowfk(contrib) (= vtowfk3(loop) - cgwf - fourwf%vtowfk3 - rwwf%vtowfk3 - corrmetalwf1)
1156      tslots(:6)=(/-108, 139,-122,-845,-288,-214/)
1157    case(25)
1158 !      vtowfk (1) = dfpt_vtowfk - vtowfk3(loop) - vtowfk3 (3)
1159      tslots(:4)=(/ 131, 128,-139,-130/)
1160    case(28)
1161 !      dfpt_vtorho-kpt loop (= dfpt_vtowfk (2) - vtowfk3 - rwwf)
1162      tslots(:4)=(/126,125,-128,-287/)
1163    case(29)
1164 !      Estimate complement in mkrho
1165      tslots(:3)=(/798,799,-843/)
1166    case(30)
1167 !      Estimate complement in dfpt_looppert
1168 !      dfpt_looppert(other) (= loper3 - loper3(kpgio) - loper3(getmpw) - loper3(inwffil)
1169 !      dfpt_scfcv - dfpt_looppert(outwf) -loper3(eigt2tot)
1170      tslots(:8)=(/145,141,-142,-143,-144,-120,-146,-147/)
1171    case(31)
1172 !      Estimate complement in sigma
1173 !      sigma/=fourdp = sigma - fourdp%rhotwg%si - fourdp%fftwfn%si
1174      tslots(:4)=(/410,401,-262,-265/)
1175    case(32)
1176 !      Estimate complement in bethe_salpeter
1177      tslots(:2)=(/699,650/)
1178    case(33)
1179 !      Estimate complement in susk
1180 !      NOTE : fourwf%susk _PAW should actually be split between susk (loop except FFT)
1181 !      and susk (accumul.except FFT . But a renumbering of the fourwf splitting should be done ...
1182 !      susk (loop except FFT) = susk (loop) - fourwf%susk !0 - fourwf%susk !3
1183      tslots(:4)=(/756,752,-848,-849/)
1184    case(34)
1185 !      susk (accumul.except FFT = susk (accumul) - fourwf%susk !3bis - fourwf%susk _PAW
1186      tslots(:4)=(/757,754,-859,-857/)
1187    case(35)
1188 !      Estimate complement in suskmm
1189 !      NOTE : fourwf%susk _PAW should actually be split between susk (loop except FFT)
1190 !      and suskmm (accum.except FFT . But a renumbering of the fourwf splitting should be done ...
1191 !      suskmm (loop except FFT) = suskmm (loop) - fourwf%suskmm !0 part 1 - fourwf%suskmm !3 part 1
1192      tslots(:4)=(/764,762,-861,-871/)
1193    case(36)
1194 !      suskmm (accum.except FFT = suskmm (accumul) - fourwf%suskmm !0 part 2 - fourwf%suskmm !3 part 2 - fourwf%susk _PAW
1195      tslots(:5)=(/765,763,-862,-872,-857/)
1196    case(37)
1197 !      inwffil(excl. calls) = inwffil - inwffil(call wfsinp) - inwffil(call newkpt);
1198      tslots(:4)=(/718,710,-714,-717/)
1199    case(38)
1200 !      wfsinp(excl. calls) = wfsinp - wfsinp(call  initwf) - wfsinp(call rwwf)
1201      tslots(:4)=(/728,720,-724,-727/)
1202    case(39)
1203 !      newkpt(excl. rwwf   )=newkpt(before loop) + newkpt(before rwwf) + newkpt(after rwwf)
1204 !      newkpt(call wfconv) + newkpt(finalize loop) + newkpt(after loop   )
1205      tslots(:7)=(/-788,781,782,783,784,785,786/)
1206    case(40)
1207 !      More complements in vtowfk
1208 !      vtowfk (2) = vtowfk (loop) - cgwf - lobpcg - subdiago - pw_orthon
1209      tslots(:7)=(/-590,39,-22,-530,-585,-583, -1600/)
1210    case(41)
1211 !      vtowfk (3) = vtowfk (afterloop) - nonlop%vtowfk - prep_nonlop%vtowfk - fourwf%vtowfk - prep_fourwf%vtowfk - vtowfk(nonlocalpart)
1212      tslots(:7)=(/-591,30,-222,-572,-842,-537,-586/)
1213    case(43)
1214 !      mkrho = mkrho%gstate + mkrho%vtorho + mkrho%energy + mkrho%respfn + mkrho%afterscfloop + mkrho%scfcv_core
1215      tslots(:7)=(/790,791,792,793,794,795,796/)
1216    case(44)
1217 !      Estimate the complement of dmft (in vtorho, only)
1218      tslots(:9)=(/-626, 991,-620,-621,-622,-623,-624,-625,-627/)
1219 
1220    case default
1221      cycle
1222    end select
1223 
1224    tslot=tslots(1)
1225    aslot=abs(tslot)
1226    ncount(    aslot)=0 ; if (tslot<0)ncount(aslot)=-1
1227    times(1:2, aslot)=zero
1228    nflops(    aslot)=zero
1229    ftimes(1:2,aslot)=zero
1230    flag_count=1
1231    do islot=2,TIMER_SIZE
1232      bslot=tslots(islot)
1233      cslot=abs(bslot)
1234      if(bslot>0)then
1235        if(tslot>0)ncount(aslot)=ncount(aslot)+ncount(cslot)
1236        times(1:2, aslot)=times(1:2, aslot)+times(1:2,cslot)
1237        nflops(    aslot)=nflops(    aslot)+nflops(   cslot)
1238        ftimes(1:2,aslot)=ftimes(1:2,aslot)+ftimes(1:2,cslot)
1239      else if(bslot<0)then
1240        if(tslot>0)flag_count=-1
1241        times(1:2, aslot)=times(1:2, aslot)-times(1:2,cslot)
1242        nflops(    aslot)=nflops(    aslot)-nflops(   cslot)
1243        ftimes(1:2,aslot)=ftimes(1:2,aslot)-ftimes(1:2,cslot)
1244      else if(bslot==0)then
1245        exit
1246      end if
1247    end do
1248    if(flag_count==-1)ncount(aslot)=ncount(abs(tslots(2)))
1249  end do
1250 
1251 !For the following sections, the number of counts is non standard, and thus these sections have not been placed
1252 !in the previous doloop.
1253 
1254 !Compute xc part of rhotoxc and dfpt_mkvxc, minus the calls to fourdp inside that part
1255  ncount(11)=ncount(81)+ncount(181)
1256  times(1:2,11)=times(1:2,81)+times(1:2,181)-times(1:2,82)
1257  ftimes(1:2,11)=ftimes(1:2,81)+ftimes(1:2,181)-ftimes(1:2,82)
1258  nflops(11)=nflops(81)+nflops(181)-nflops(82)
1259 
1260 !Estimate different complements in dfpt_vtorho
1261 !dfpt_vtorho (1) (= vtorho3 (1,2) - vtorho3(2) - vtorho3:synchro )
1262  ncount(118)=ncount(121)
1263  times(1:2,118)=times(1:2,124)-times(1:2,125)-times(1:2,166)
1264  ftimes(1:2,118)=ftimes(1:2,124)-ftimes(1:2,125)-ftimes(1:2,166)
1265  nflops(118)=nflops(124)-nflops(125)-nflops(166)
1266 
1267 
1268 
1269 !Calculating Gigaflops for all cases
1270  do itim=1,TIMER_SIZE
1271    mflops(itim)=-2
1272    if(abs(ftimes(1,itim)) > tol10) then ! VALGRIND complains that here there is a jump on uninitialized values
1273      mflops(itim)=nflops(itim)*1.e-9/ftimes(1,itim)
1274    else
1275      mflops(itim)=-1
1276    end if
1277  end do
1278 
1279 !Warning if the time is negative
1280  do itim=1,TIMER_SIZE
1281    if(times(1,itim)<-tol6 .or. times(2,itim)<-tol6 .or. ncount(itim)<-1 )then
1282      write(message, '(6a,i4,4a,es16.6,a,es16.6,a,i6,a,es16.6)' ) ch10,&
1283 &     ' timana : WARNING -',ch10,&
1284 &     '  One among cpu, wall and ncount is negative.',ch10,&
1285 &     '  Timing section #',itim,', name :  ',names(itim),ch10,&
1286 &     '  CPU =',times(1,itim),', Wall=',times(2,itim),' ncount=',ncount(itim),' flops=',nflops(itim)
1287      call wrtout(std_out,message,'PERS')
1288    end if
1289  end do
1290 
1291 !List of major independent code sections
1292  ABI_ALLOCATE(list,(TIMER_SIZE))
1293  list(:)=0
1294  nlist=0
1295  do itim=1,TIMER_SIZE
1296    if(basic(itim)/=0)then
1297      nlist=nlist+1
1298      list(nlist)=itim
1299    end if
1300  end do
1301 
1302  percent_limit=0.5_dp; if (timopt<0) percent_limit=0.0001_dp
1303 
1304 !In case there is parallelism, report times for node 0
1305 !if (me==0 .and. nproc>1) then
1306  if (me==0) then
1307 
1308 !  Find normalization to report timing as % total time
1309    cpunm=100._dp/tsec(1)
1310    wallnm=100._dp/tsec(2)
1311 
1312 !  (0) Take care of major independent code sections for this account of node 0 timing
1313 
1314    write(ount,  '(a,a,a,a,/,a,a,a)' ) '-',ch10,&
1315 &   '- For major independent code sections,',' cpu and wall times (sec),',&
1316 &   '-  as well as % of the time and number of calls for node 0',&
1317 &   '-'
1318 
1319    write(ount,"(3(a,i0),a)")&
1320 &   "-<BEGIN_TIMER mpi_nprocs = ",nproc,", omp_nthreads = ",nthreads,", mpi_rank = ",me,">"
1321 
1322 !  write(ount,"(2(a,f13.1))")"- tot_cpu_time = ",tsec(1),   ", tot_wall_time = ",tsec(2)
1323    write(ount,"(2(a,f13.1))")"- cpu_time =  ",my_tsec(1),", wall_time =  ",my_tsec(2)
1324    write(ount,"(a)")"-"
1325 
1326    write(ount, '(a,t34,a,t42,a,t50,a,t59,a,t65,a,t82,a,3x,a7,1x,a10)' )&
1327 &   '- routine','cpu','%','wall','%',' number of calls ',' Gflops ', 'Speedup', 'Efficacity'
1328    write(ount,'(a,t35,a,t43,a,t51,a,t60,a,t66,a,t78,a)')&
1329 &   '-                ','   ',' ','    ',' ','  (-1=no count)'
1330 
1331 !  Sort the list by decreasing CPU time
1332    do ii=1,nlist
1333      do ilist=1,nlist-1
1334        if (times(1,list(ilist))<times(1,list(ilist+1))) then
1335          temp_list=list(ilist)
1336          list(ilist)=list(ilist+1)
1337          list(ilist+1)=temp_list
1338        end if
1339      end do
1340    end do
1341 
1342    subcpu=zero; subwal=zero; other_cpu=zero; other_wal=zero; nothers=0
1343 
1344    do ilist=1,nlist
1345      isort = list(ilist)
1346 
1347      if ( (times(1,isort)*cpunm  > percent_limit .and. &
1348 &     times(2,isort)*wallnm > percent_limit) .and. ncount(isort)/=0 ) then ! Timing analysis
1349 
1350        write(ount,format01041)names(isort),&
1351 &       times(1,isort),times(1,isort)*cpunm,times(2,isort),times(2,isort)*wallnm,ncount(isort),mflops(isort), &
1352 &       times(1,isort)/times(2,isort),times(1,isort)/times(2,isort)/nthreads
1353 
1354      else
1355        nothers=nothers+1
1356        other_cpu=other_cpu+times(1,isort)
1357        other_wal=other_wal+times(2,isort)
1358      end if
1359 
1360      subcpu=subcpu+times(1,isort)
1361      subwal=subwal+times(2,isort)
1362    end do
1363 
1364    other_wal = other_wal + tol14
1365    write(entry_name,"(a,i0,a)")"others (",nothers,")"
1366    write(ount,format01041)entry_name,other_cpu,other_cpu*cpunm,other_wal,other_wal*wallnm,-1,-1.0, &
1367 &   other_cpu/other_wal,other_cpu/other_wal/nthreads
1368    write(ount,"(a)")"-<END_TIMER>"
1369 
1370    write(ount,'(a)' ) '-'
1371    subwal = subwal + tol14
1372    write(ount,01200) subcpu,subcpu*cpunm,subwal,subwal*wallnm,subcpu/subwal,subcpu/subwal/nthreads
1373  end if
1374 
1375 !Now, gather all information
1376  call xmpi_sum(times,spaceworld,ierr)
1377  call xmpi_sum(ncount,spaceworld,ierr)
1378  call xmpi_sum(ftimes,spaceworld,ierr)
1379  call xmpi_sum(nflops,spaceworld,ierr)
1380 
1381  if (me==0) then ! Only the world master writes
1382 
1383 !  Find normalization to report timing as % total time
1384    cpunm=100._dp/tsec(1)
1385    wallnm=100._dp/tsec(2)
1386 
1387 !  Calculating Gigaflops for all process
1388    do itim=1,TIMER_SIZE
1389      mflops(itim)=-2
1390      if(abs(ftimes(1,itim)) > tol10) then ! VALGRIND complains that here there is a jump on uninitialized values
1391        mflops(itim)=nflops(itim)*1.e-9/ftimes(1,itim)
1392      else
1393        mflops(itim)=-1
1394      end if
1395    end do
1396 
1397 !  _______________________________________
1398 
1399 !  Write timing output for cpu times
1400 
1401 !  (1) Take care of major independent code sections
1402    write(ount,'(/,a,/,a,/)' )&
1403 &   '- For major independent code sections, cpu and wall times (sec),',&
1404 &   '- as well as % of the total time and number of calls '
1405 
1406    write(ount,"(2(a,i0),a)")&
1407 &   "-<BEGIN_TIMER mpi_nprocs = ",nproc,", omp_nthreads = ",nthreads,", mpi_rank = world>"
1408 
1409    write(ount,"(2(a,f13.1))")"- cpu_time = ",tsec(1),   ", wall_time = ",tsec(2)
1410 !  write(ount,"(2(a,f13.1))")"- my_cpu_time =  ",my_tsec(1),", my_wall_time =  ",my_tsec(2)
1411    write(ount,"(a)")"-"
1412 
1413    write(ount,'(a,t35,a,t43,a,t51,a,t60,a,t66,a,t82,a,3x,a7,1x,a10)')&
1414 &   '- routine        ','cpu','%','wall','%', ' number of calls ',' Gflops ', &
1415    'Speedup', 'Efficacity'
1416    write(ount,'(a,t35,a,t43,a,t51,a,t60,a,t66,a,t78,a)')&
1417 &   '-                ','   ',' ','    ',' ','  (-1=no count)'
1418 
1419 !  Sort the list by decreasing CPU time
1420    do ii=1,nlist
1421      do ilist=1,nlist-1
1422        if(times(1,list(ilist))<times(1,list(ilist+1)))then
1423          temp_list=list(ilist)
1424          list(ilist)=list(ilist+1)
1425          list(ilist+1)=temp_list
1426        end if
1427      end do
1428    end do
1429 
1430    subcpu=zero; subwal=zero; other_cpu=zero; other_wal=zero; nothers=0
1431 
1432    do ilist=1,nlist
1433      isort = list(ilist)
1434      if( (times(1,isort)*cpunm > percent_limit .and.  &
1435 &     times(2,isort)*wallnm> percent_limit) .and. ncount(isort)/=0 )then
1436 
1437        write(ount,format01041)names(isort),&
1438 &       times(1,isort),times(1,isort)*cpunm,times(2,isort),times(2,isort)*wallnm,ncount(isort),mflops(isort), &
1439 &       times(1,isort)/times(2,isort),times(1,isort)/times(2,isort)/nthreads
1440      else
1441        nothers=nothers+1
1442        other_cpu=other_cpu+times(1,isort)
1443        other_wal=other_wal+times(2,isort)
1444      end if
1445      subcpu=subcpu+times(1,isort)
1446      subwal=subwal+times(2,isort)
1447    end do
1448 
1449    other_wal = other_wal + tol14
1450    write(entry_name,"(a,i0,a)")"others (",nothers,")"
1451    write(ount,format01041)entry_name,other_cpu,other_cpu*cpunm,other_wal,other_wal*wallnm,-1,-1.0, &
1452 &   other_cpu/other_wal,other_cpu/other_wal/nthreads
1453 
1454    write(ount,"(a)")"-<END_TIMER>"
1455 
1456    subwal = subwal + tol14
1457    write(ount,01201) subcpu,subcpu*cpunm,subwal,subwal*wallnm,subcpu/subwal,subcpu/subwal/nthreads
1458 
1459 !  (2) Partitionings
1460    if (timopt<0) then
1461 
1462      npart=1000
1463      do ipart=1,npart
1464        list(:)=0
1465        select case(ipart)
1466 
1467        case(1)
1468          list(:11)=(/1,41,42,43,44,45,640,46,49,50,TIMER_SIZE/)      ; message='abinit '
1469        case(2)
1470          list(:13)=(/640,641,642,700,132,84,301,401,501,650,643,644,TIMER_SIZE/)  ; message='driver '
1471        case(3)
1472          list(:13)=(/700,703,704,705,33,701,34,35,36,706,702,707,708/)       ; message='gstateimg+gstate '
1473        case(4)
1474          list(:19)=(/238,54,240,241,56,242,60,52,68,239,243,244,245,246,247,248,61,249,TIMER_SIZE/); message='scfcv_core '
1475        case(5)
1476          list(:7)=(/940,941,942,943,944,945,TIMER_SIZE/)             ; message= 'rhotov '
1477        case(6)
1478          list(:22)=(/980,981,982,983,984,28,985,271,986,987,988,989,990,991,992,993,994,995,996,997,1620,TIMER_SIZE/)
1479          message= 'vtorho '
1480        case(7)
1481          list(:15)=(/28,31,22,530,585,583,590,222,572,842,537,586,591,1600,TIMER_SIZE/) ; message='vtowfk '
1482        case(8)
1483          if(abs(timopt)==3)then
1484            list(:11)=(/530,204,205,571,532,533,630,535,536,584,587/)  ; message='lobpcgwf (abs(timopt)==3)'
1485          else if(abs(timopt)==4)then
1486            list(:8)=(/530,520,521,522,523,524,525,526/)               ; message='lobpcgwf (abs(timopt)==4)'
1487 !            else
1488 !            list(:3)=(/530,204,205/)
1489 !            message='lobpcgwf (light analysis: for a deeper one, use abs(timopt)=3 or 4)'
1490          end if
1491        case(9)
1492          list(:4)=(/22,201,40,211/)                            ; message='cgwf '
1493        case(10)
1494          list(:8)=(/132,133,134,135,136,137,138,141/)          ; message='respfn '
1495        case(11)
1496          list(:8)=(/141,142,143,144,120,146,147,TIMER_SIZE/)         ; message='dfpt_looppert '
1497        case(12)
1498          list(:9)=(/120,154,121,157,152,158,160,150,564/) ; message='dfpt_scfcv '
1499        case(13)
1500          list(:9)=(/121,118,128,126,287,166,129,127,556/)      ; message='dfpt_vtorho '
1501        case(14)
1502          list(:9)=(/128,131,122,845,288,214,108,130,565/)      ; message='dfpt_vtowfk '
1503        case(15)
1504          list(:8)=(/122,140,202,197,212,227,228,844/)          ; message='dfpt_cgwf '
1505        case(16)
1506          list(:4)=(/200,841,221,98/)                           ; message='getghc '
1507        case(17)
1508          list(:20)=(/801,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858/)
1509          message='fourwf (upwards partitioning)'
1510        case(18)
1511          list(:5)=(/933,934,936,937,938/)                      ; message='outkss '
1512        case(19)
1513          list(:14)=(/301,302,315,316,319,304,305,320,321,306,307,308,309,310/)
1514          message='screening '
1515        case(20)
1516          list(:13)=(/401,402,403,404,405,406,407,408,409,421,423,424,425/); message='sigma  '
1517        case(21)
1518          list(:9)=(/431,432,433,434,435,445,440,441,442/)     ; message='calc_sigc_me '
1519        case(23)
1520          list(:11)=(/630,631,632,633,634,545,635,636,637,638,TIMER_SIZE/)         ; message='prep_getghc '
1521        case(24)
1522          list(:4)=(/539,856,547,548/)                          ; message='prep_fourwf '
1523        case(25)
1524          list(:5)=(/570,231,232,581,TIMER_SIZE/)                     ; message='prep_nonlop '
1525        case(26)
1526          list(:6)=(/790,791,792,793,794,795/)                  ; message='mkrho (upwards partitioning)'
1527 !          Disabled (temporarily ?) because the partitioning was not correct
1528 !          case(27);list(:17)=(/600,601,602,603,604,605,617,606,607,608,609,610,611,612,613,614,615/)
1529 !          message='vtorhorec '
1530        case(28)
1531          list(:10)=(/650,651,653,654,655,656,658,659,660,661/)
1532          message='bethe_salpeter '
1533        case(29)
1534          list(:8)=(/740,741,742,743,744,745,746,747/)          ; message='suscep_stat '
1535        case(30)
1536          list(:9)=(/750,751,848,849,753,756,859,757,755/)      ; message='susk '
1537        case(31)
1538          list(:8)=(/760,761,764,861,871,765,862,872/)          ; message='suskmm '
1539        case(32)
1540          list(:8)=(/710,711,712,713,714,715,716,717/)          ; message='inwffil '
1541        case(33)
1542          list(:10)=(/720,721,722,723,724,725,726,727,67,TIMER_SIZE/)  ; message='wfsinp '
1543        case(34)
1544          list(:5)=(/770,771,772,272,290/)                      ; message='initwf '
1545        case(35)
1546          list(:9)=(/780,781,782,783,784,785,786,291,292/)      ; message='newkpt '
1547        case(36)
1548          list(:8)=(/93,901,902,903,904,905,268,TIMER_SIZE/)          ; message='newvtr '
1549        case(37)
1550          list(:2)=(/94,269/)                                   ; message='newrho '
1551        case(38)
1552          list(:11)=(/9,260,261,262,263,264,265,266,267,268,269/) ; message=' fourdp (upwards partitioning)'
1553        case(39)
1554          list(:8)=(/250,251,252,253,254,255,256,257/)          ; message='afterscfloop '
1555        case(40)
1556          list(:5)=(/910,911,912,913,914/)                      ; message='forstr '
1557        case(41)
1558          list(:10)=(/920,921,927,922,923,926,924,65,925,TIMER_SIZE/) ; message='forstrnps '
1559        case(42)
1560          list(:4)=(/670,671,672,673/)                          ; message='exc_build_ham '
1561        case(43)
1562          list(:7)=(/680,681,682,683,684,685,686/)              ; message='exc_build_block'
1563        case(44)
1564          list(:8)=(/690,691,692,693,694,695,696,697/)                  ; message='exc_haydock_driver '
1565        case(45)
1566          list(:20)=(/950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969/)
1567          message='outscfcv '
1568        case(46)
1569          list(:8)=(/620,621,622,623,624,625,626,627/)          ; message='dmft '
1570        case(47)
1571          list(:9)=(/1001,1002,1003,1004,1005,1006,1007,1008,1009/)
1572          message='initberry '
1573        case(50)
1574          list(:12)=(/1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511/)          ; message='hartreefock '
1575        case(60)
1576          list(:13) = (/1600,1607,1630,1631,1632,1601,1603,1604,1605,1606,1608,1609,1610/)
1577          message = 'chebfi'
1578        case(61)
1579          list(:3) = (/1620,1621,1622/)
1580          message = 'mkinvovl'
1581        case(70)
1582          list(:5)=(/1701,1702,1703,1721,1722/)
1583          message='gwls GW code'
1584        case(71)
1585          list(:16)=(/1703,1704,1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718/)
1586          message='gwls: compute_correlations_shift_lanczos'
1587        case(72)
1588          list(:10)=(/1724,1725,1726,1727,1728,1729,1730,1731,1732,1733/)
1589          message='gwls: Applying the susceptibility Pk'
1590        case(73)
1591          list(:7)=(/1734,1735,1736,1737,1738,1739,1740/)
1592          message='gwls: Applying the model susceptibility Pk_model'
1593        case(74)
1594          list(:7)=(/1741,1742,1743,1744,1745,1746,1747/)
1595          message='gwls: computing the matrix elements of eps_model^{-1}(w) -1 '
1596        case(75)
1597          list(:12)=(/1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661/)
1598          message='lobpcgwf2 core engine '
1599        case(76)
1600          list(:18)=(/1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687/)
1601          message='low-level xgBlock type '
1602        case(77)
1603          list(:5)=(/1690,1691,1692,1693,1694/)
1604          message='low-level xgScalapack type '
1605        case default
1606          cycle ! This allows to disable temporarily some partitionings
1607 
1608        end select
1609 
1610        nlist=0
1611        do itim=1,TIMER_SIZE
1612          if(list(itim)/=0)then
1613            nlist=nlist+1
1614          else
1615            exit
1616          end if
1617        end do
1618 
1619        if(nlist==0)then
1620          cycle
1621        end if
1622 
1623        if(ncount(list(1))/=0)then
1624          write(ount,'(/,a,a)')' Partitioning of ',trim(message)
1625          subcpu=zero
1626          subwal=zero
1627          do ilist=1,nlist
1628            isort = list(ilist)
1629 !          When the LAST item is TIMER_SIZE, a complement is evaluated (count number set to -1)
1630            if(ilist==nlist .and. list(nlist)==TIMER_SIZE)then
1631              times(1,TIMER_SIZE)=times(1,list(1))-subcpu
1632              times(2,TIMER_SIZE)=times(2,list(1))-subwal
1633              ncount(TIMER_SIZE)=-1
1634              ftimes(1,TIMER_SIZE)=zero
1635              mflops(TIMER_SIZE)=0
1636 #if defined HAVE_TEST_TIME_PARTITIONING
1637              if(times(2,TIMER_SIZE)>1.2d0 .and. wallnm*times(2,TIMER_SIZE)>3.d0)then
1638                write(ount, '(3a,es16.6,4a,es16.6,2a)')&
1639 &               ' Note : the partitioning does not work well for this routine.',ch10,&
1640 &               '   The (other) Wall time            ',times(2,TIMER_SIZE),ch10,&
1641 &               '   is bigger than 1.2 secs. ',ch10,&
1642 &               '   The (other) Wall time percentage ',wallnm*times(2,TIMER_SIZE),ch10,&
1643 &               '   is bigger than 3% '
1644              else if (times(2,TIMER_SIZE)<0.2d0 .and. wallnm*times(2,TIMER_SIZE)<-0.2d0)then
1645                write(ount, '(3a,es16.6,2a)')&
1646 &               ' Note : the partitioning does not work well for this routine.',ch10,&
1647 &               '   The (other) Wall time percentage ',wallnm*times(2,TIMER_SIZE),ch10,&
1648 &               '   is negative '
1649              end if
1650 #endif
1651            end if
1652            if(ncount(isort)/=0)then
1653              if(times(2,isort)*wallnm>0.02d0 .or. ilist==1)then   ! Does not write a slot if the wall time ratio is below a threshold
1654                if ( times(2,isort) < 0.0001 ) times(2,isort) = -1.d0
1655                write(ount,format01040)names(isort),&
1656 &               times(1,isort),times(1,isort)*cpunm,&
1657 &               times(2,isort),times(2,isort)*wallnm,ncount(isort), &
1658 &               times(1,isort)/times(2,isort),times(1,isort)/times(2,isort)/nthreads
1659              end if
1660              if(ilist/=1)then
1661                subcpu=subcpu+times(1,isort)
1662                subwal=subwal+times(2,isort)
1663              else
1664                write(ount, '(a)' ) ' '
1665              end if
1666            end if
1667          end do
1668 
1669          subwal = subwal + tol14
1670          write(ount, 01201 ) subcpu,subcpu*cpunm,subwal,subwal*wallnm, subcpu/subwal,subcpu/subwal/nthreads
1671 #ifdef HAVE_TEST_TIME_PARTITIONING
1672          if( wallnm*abs(subwal-times(2,list(1)))>1.d0 .and. abs(subwal-times(2,list(1)))>0.2d0 )then
1673            write(ount, '(3a,es16.6,2a,es16.6,4a,es16.6,2a,es16.6,6a,i4)')&
1674 &           ' Note : the partitioning does not work well for this routine.',ch10,&
1675 &           '   The subtotal Wall time            ',subwal,ch10,&
1676 &           '   differs from the total Wall time  ',times(2,list(1)),ch10,&
1677 &           '   by more than 0.2 secs.',ch10,&
1678 &           '   The subtotal Wall time percentage ',wallnm*subwal,ch10,&
1679 &           '   differs from the total Wall time %',wallnm*times(2,list(1)),ch10,&
1680 &           '   by more than 1%. ',ch10,&
1681 &           '   The partitioning might not have been coded properly.',ch10,&
1682 &           '   nlist=',nlist
1683            do ilist=1,nlist
1684              write(ount, '(a,i4,i4,es16.6,i8)' )&
1685 &             ' ilist,list(ilist),wallnm*times(2,list(ilist)),ncount(list(ilist))=',&
1686 &             ilist,isort,wallnm*times(2,isort),ncount(isort)
1687            end do
1688          end if
1689 #endif
1690        end if
1691 
1692      end do ! End of loop on partitionings
1693 
1694 !    For parallel case
1695      if(xmpi_paral==1)then
1696        write(ount, '(a,/,a)' )'-','-Synchronisation (=leave_test) and MPI calls '
1697        nlist=14
1698        list(:14)=(/48,61,62,63,64,65,66,67,71,85,86,543,544,787/)
1699        subcpu=zero; subwal=zero
1700        if(ncount(list(1))/=0)then
1701          do ilist=1,nlist
1702            isort = list(ilist)
1703 !
1704            if (ncount(isort)/=0) then
1705              write(ount,format01040)names(isort),&
1706 &             times(1,isort),times(1,isort)*cpunm,&
1707 &             times(2,isort),times(2,isort)*wallnm,ncount(isort), &
1708 &             times(1,isort)/(tol14+times(2,isort)),times(1,isort)/(times(2,isort)+tol14)/nthreads
1709 
1710              if(ilist/=1)then
1711                subcpu=subcpu+times(1,isort)
1712                subwal=subwal+times(2,isort)
1713              else
1714                write(ount, '(a)' ) '-'
1715              end if
1716            end if !ncount
1717 !
1718          end do !ilist
1719 
1720          subwal = subwal + tol14
1721          write(ount, 01200 ) subcpu,subcpu*cpunm,subwal,subwal*wallnm, subcpu/subwal,subcpu/subwal/nthreads
1722        end if !ncount
1723      end if !xmpi_paral
1724 
1725      nlist=23
1726      list(:23)=(/47,49,51,801,72,73,74,77,78,79,97,82,87,88,436,437,438,439,804,805,331,332,333/)
1727      flag_write=1
1728      do ilist=1,nlist
1729        isort = list(ilist)
1730        if(ncount(isort)/=0)then
1731          if(flag_write==1)then
1732            write(ount, '(/,a)' ) ' Additional information'
1733            flag_write=0
1734          end if
1735          write(ount,format01040)names(isort),&
1736 &         times(1,isort),times(1,isort)*cpunm,times(2,isort),times(2,isort)*wallnm,ncount(isort), &
1737 &         times(1,isort)/(tol14+times(2,isort)),times(1,isort)/(tol14+times(2,isort))/nthreads
1738        end if
1739      end do
1740 
1741      nlist=23
1742      list(:23)=(/550,551,552,553,554,555,556,558,559,560,561,562,563,564,565,566,567,593,594,595,596,597,598/)
1743      flag_write=1
1744      do ilist=1,nlist
1745        isort = list(ilist)
1746        if(ncount(isort)/=0)then
1747          if(flag_write==1)then
1748            write(ount, '(/,a)' ) ' Additional information about PAW segments'
1749            flag_write=0
1750          end if
1751          write(ount,format01040)names(isort),&
1752 &         times(1,isort),times(1,isort)*cpunm,times(2,isort),times(2,isort)*wallnm,ncount(isort), &
1753 &         times(1,isort)/(tol14+times(2,isort)),times(1,isort)/(tol14+times(2,isort))/nthreads
1754        end if
1755      end do
1756 
1757 !    The detailed analysis cannot be done in the multidataset mode
1758      if(ndtset<2)then
1759        write(ount, '(/,/,a,/,a,/,a)' ) &
1760 &       ' Detailed analysis of some time consuming routines ',&
1761 &       '                                  tcpu    ncalls  tcpu/ncalls    ndata tcpu/ncalls/ndata',&
1762 &       '                                 (sec)                (msec)              (microsec)'
1763        nlist=8
1764        list(:8)=(/802,803,9,75,76,77,210,11/)
1765        do ilist=1,nlist
1766          isort = list(ilist)
1767          if(ncount(isort)/=0)then
1768            write(ount, '(a,a24,f12.3,i10,f12.3,i10,f12.3)' )'- ',names(isort),&
1769 &           times(1,isort),ncount(isort),&
1770 &           1000.0_dp*times(1,isort)/dble(ncount(isort)),ndata(isort),&
1771 &           1000000.0_dp*times(1,isort)/dble(ncount(isort)*dble(ndata(isort)))
1772          else
1773            write(ount, '(a,a24,f12.3,i10)' )'- ',names(isort),&
1774 &           times(1,isort),ncount(isort)
1775          end if
1776        end do !ilist
1777      else
1778        write(ount,'(/,a)') ' timana : in multi dataset mode, the more detailed analysis is not done.'
1779      end if !ndtset
1780 
1781    end if ! End the condition of timopt<0
1782 
1783  end if ! me==0
1784 
1785  ABI_DEALLOCATE(list)
1786 
1787 end subroutine timana