IAP GITLAB

Skip to content
Snippets Groups Projects
tabinit.f 14.6 KiB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527
c $Id: tabinit.f,v 1.14 2003/05/02 13:14:46 weber Exp $
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
      subroutine loadwtab (io)
c
c     Revision : 1.0
c
coutput   : information in common-block comwid.f
c
c     load the tabulated branching ratios from disk
c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      implicit none

      include 'comres.f'
      include 'comwid.f'

      integer ios, nsp, io, ver!, i
c      character*35 pwdcmd
      character*10 deftab
      character*8 defexe
      logical b

c set the defaultname of the file, containing the table
      parameter (deftab='tables.dat', defexe='uqmd.exe')

      b=io.eq.1

c get the name of the table from the environment variable
      call getenv('URQMD13_TAB',tabname)
c if it is empty, use the default name
      if (tabname(1:4).eq.'    ') then
         tabname=deftab
      endif

      if(b)write (6,*) 'Looking for the tabulated decay width...'
     &                 ,tabname
c open the table
      open (unit=75,iostat=ios,file=tabname,form='unformatted',
     .      status='old')
c if it fails ...
      if (ios.ne.0) then
c close the file handle
c         close (unit=75, status='delete')
         if(b)write (6,*) 'No file:',tabname,'in this directory'
c get the full path of the executable, ...
c         call getenv('_',pwdcmd)
c         write (6,*) 'pwd:',pwdcmd
         write (6,*) 'tabname:',tabname
c extract the path
c         i=max(index(pwdcmd,defexe),2)
c         write (tabname,*) pwdcmd (1:i-1),deftab
c         tabname=tabname(2:)
         if(b)write (6,*) 'Looking for ',tabname,'...'
c and look for a table in the directory of the executable
         open (unit=75,iostat=ios,file=tabname,
     .         form='unformatted',status='old')
      endif
c if the last 'open' command succeeds read the file
      if (ios.eq.0) then
         if(b)write (6,*) 'O.K.'
         if(b)write (6,*) 'reading...'
c read all tables
         read (unit=75, iostat=ios) ver, nsp, tabx, fbtaby, pbtaby,
     .          fmtaby, pmtaby, bwbarnorm, bwmesnorm,
     .            tabxnd, frrtaby
c caution! the file is unformatted, therefor it is system dependent!
         if(b)write (6,*) 'version=',ver
c if no errors occur ...
         if (ios.eq.0) then
            if(b)write (6,*) 'O.K.'
            wtabflg=3
c check, if the version number is correct
            if (ver.eq.tabver) then
               if(b)write (6,*) 'tabver=',ver,'  O.K.'
            else
               write (6,*) 'wrong table!'
               write (6,*) 'tabver should be',tabver,',instead of',ver
               wtabflg=0
            endif
c check, if the table has the correct 'widnsp'
            if (nsp.eq.widnsp) then
               if(b)write (6,*) 'widnsp=',nsp,'  O.K.'
            else
               write (6,*) 'wrong table!'
               write (6,*) 'widnsp should be',widnsp,', instead of',nsp
                     wtabflg=0
               endif
c if table is O.K. close file
            if (wtabflg.eq.3) then
               close (unit=75, status='keep')
c otherwise ...
            else
c delete the present table
               close (unit=75, status='delete')
               tabname=deftab
c and calculate a new one
               call mkwtab
            endif
c in case of read errors ...
         else
c delete the present table
            close (unit=75, status='delete')
            write (6,*) 'Error while reading ',tabname
            tabname=deftab
c and calculate a new one
            call mkwtab
         endif
c in any other case ...
      else
ctp         tabname=deftab
c calculate an new table
         call mkwtab
      endif

      return
      end





cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
      subroutine savewtab
c
c     Revision : 1.0
c
c     save the tabulated branching ratios to disk
c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      implicit none

      include 'comres.f'
      include 'comwid.f'

      integer ios

      write (6,*) 'Writing new table...'

c try to generate a new file
      open (unit=75,iostat=ios,file=tabname,form='unformatted',
     .      status='new')
c if it succedds ...
      if (ios.eq.0) then
c write the tables into the file
         write (unit=75, iostat=ios) tabver, widnsp, tabx, fbtaby,
     .        pbtaby, fmtaby, pmtaby, bwbarnorm, bwmesnorm,
     .            tabxnd, frrtaby
         if (ios.eq.0) write (6,*) 'O.K.'
c otherwise complain
      else
         write (6,*) 'Error: ',tabname,'exists!'
      endif
c close the file
      close (unit=75, status='keep')

      return
      end





cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
      subroutine mkwtab
c
c     Revision : 1.0
c
coutput   : information in common-block comwid.f
c
c     tabulate the mass dependent branching ratios
c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      implicit none

      include 'comres.f'
      include 'comwid.f'

      real*8 fwidth,m,first,last,delta,abl0,abln,mir,mminit,fbrancx
      real*8 massit,bran,smass,bwnorm,fppfit
      integer i,bchan,itp,isoit,cmin,cmax,i1,i2,i3,i4,ii1

      write (6,*) 'Generating table...'
c this indicates, that all tables are still empty
      wtabflg=0

c high precision splines from mintab to maxtab1
c lower precicision between maxtab1 and maxtab2

c now fill the x-values
c start with 'mintab'
      first=mintab
c 66 % of all fixpoints between mintab and maxtab1
c calculate the steps
      delta=(maxtab1-mintab)/((widnsp-1d0)*2d0/3d0)
      if (delta.le.0d0) then
         write(*,*)'(E) Please allow maxtab1>mintab in comwid'
         stop
      endif
c store the values into 'tabx'
      do 10 i=1,int(widnsp*2./3.)
         m=first+(i-1)*delta
         tabx(i)=m
 10   continue
c 33 % of all fixpoints with larger delta between maxtab1 and maxtab2
      delta=(maxtab2-maxtab1)/((widnsp-1d0)*1d0/3d0)
      if (delta.le.0d0) then
         write(*,*)'(E) Please allow maxtab2>maxtab1 in comwid'
         stop
      endif
c store the values into 'tabx'
        do 11 i=int(widnsp*2./3.)+1,widnsp
         m=maxtab1+(i-1-int(widnsp*2./3.))*delta
         tabx(i)=m
 11   continue

c now fill the y-values of the full branching ratios

c these are the first derivatives at the first an the last point
c of the interpolating function. a value greater than 1E30 signals the
c 'spline' routine to set the boundary condition for a natural spline
c with zero second derivative
      abl0=2D30
      abln=2D30

c loop over all baryons
      do 20 itp=minbar,maxbar
c loop over all x-values
         do 21 i=1,widnsp
c store the values ...
            fbtaby (i,itp,1)=fwidth(itp,isoit(itp),tabx(i))
 21      continue
c calculate the second derivate and store it in 'fbtaby(,,2)'
         call spline (tabx(1),fbtaby(1,itp,1),widnsp,abl0,abln,
     .                fbtaby(1,itp,2))
 20   continue
      write (6,*) '(1/7) ready.'

c loop over all mesons
      do 30 itp=minmes,maxmes
c loop over all x-values
         do 31 i=1,widnsp
c store the values ...
            fmtaby (i,itp,1)=fwidth(itp,isoit(itp),tabx(i))
 31      continue
c calculate the second derivate and store it in 'fmtaby(,,2)'
         call spline (tabx(1),fmtaby(1,itp,1),widnsp,abl0,abln,
     .                fmtaby(1,itp,2))
 30   continue
      write (6,*) '(2/7) ready.'

c the flag indicates, that now all full widths are tabulated
      wtabflg=1

c now fill the y-values of the partial branching ratios

c loop over all baryons
      do 40 itp=minbar,maxbar
c get the mass of this particle
         mir=massit(itp)
c get the range of possible decay channels
         call brange (itp, cmin, cmax)
c check, if there are any decay channels
         if (cmax.gt.0) then
c loop over all decay channels
            do 41 bchan=cmin,cmax
c now get the outgoing particles 'i1' and 'i2' for the channel 'j'
c 'bran' is the mass independent branching ratio (tabulated in blockres)
c 'bflag' indicates, if 'i1', 'i2' or both are broad
               call b3type (itp,bchan,bran,i1,i2,i3,i4)
c check, if decay is allowed

               smass=mminit(i2)
               if(i3.ne.0) smass=smass+mminit(i3)
               if(i4.ne.0) smass=smass+mminit(i4)

               if (bran.gt.1d-9.and.mir.gt.mminit(i1)+smass) then
c loop over all x-values
                  do 42 i=1,widnsp
c store the values

cdh
*        write(*,*)'mkwtab: i,itp,bchan=',i,itp,bchan
*       write(*,*)'mkwtab: isoit,tabx,bran,i1,i2,i3,i4=',
*    &    isoit(itp),tabx(i),bran,i1,i2,i3,i4
cdh

                     pbtaby(i,1,itp,bchan)=
     .                    fbrancx (bchan,itp,isoit(itp),tabx(i),
     .                    bran,i1,i2,i3,i4)
 42               continue
c calculate the second derivate and store it in 'pbtaby(,2,,)'
                  call spline (tabx(1),pbtaby(1,1,itp,bchan),widnsp,
     .                         abl0,abln,pbtaby(1,2,itp,bchan))
               end if
 41         continue
         end if
 40   continue
      write (6,*) '(3/7) ready.'

c loop over all mesons
      do 50 itp=minmes,maxmes
c get the mass of this particle
         mir=massit(itp)
c get the range of possible decay channels
         call brange (itp, cmin, cmax)
c check, if there are any decay channels
         if (cmax.gt.0) then
            do 51 bchan=cmin,cmax
c now get the outgoing particles 'i1' and 'i2' for the channel 'j'
c 'bran' is the mass independent branching ratio (tabulated in blockres)
c 'bflag' indicates, if 'i1', 'i2' or both are broad
               call b3type(itp,bchan,bran,i1,i2,i3,i4)
c!!!
               smass=mminit(i2)
               if(i3.ne.0) smass=smass+mminit(i3)
               if(i4.ne.0) smass=smass+mminit(i4)

               if (bran.gt.1d-9.and.mir.gt.mminit(i1)+smass) then
c loop over all x-values
                  do 52 i=1,widnsp
                     pmtaby(i,1,itp,bchan)=
     .                    fbrancx (bchan,itp,isoit(itp),tabx(i),
     .                    bran,i1,i2,i3,i4)
 52               continue
c calculate the second derivate and store it in 'pmtaby(,2,,)'
                  call spline (tabx(1),pmtaby(1,1,itp,bchan),widnsp,
     .                         abl0,abln,pmtaby(1,2,itp,bchan))
               end if
 51         continue
         end if
 50   continue

      write (6,*) '(4/7) ready.'


c calculate the norm integral of the Breit-Wigner functions
c   with mass dependent widths

c..baryons
        do 60 i=minbar,maxbar
           bwbarnorm(i)=bwnorm(i)
60        continue
      write (6,*) '(5/7) ready.'

c.. mesons
        do 61 i=minmes,maxmes
           bwmesnorm(i)=bwnorm(i)
61        continue
      write (6,*) '(6/7) ready.'

c now all branching ratios and BW-integrals are tabulated
      wtabflg=2

ce tabulate fppfit
c fill the x-values
c range of tabulated cross sections
      first=2d0*massit(nucleon)+massit(pimeson)
        last=maxtab1
c calculate the steps
c the energies are weighted quadratically
      delta=(last-first)/((widnsp-1)*2./3.)**2
c store the values into 'tabx'
c 66 % of all fixpoints between mintab and maxtab1
      do 69 i=1,int(widnsp*2./3.)
         m=first+(i-1)**2*delta
         tabxnd(i)=m
 69   continue
c 33 % of all fixpoints with larger, constant delta between maxtab1 and maxtab2
        delta=(maxtab2-last)/((widnsp-1)*1./3.)
        do 70 i=int(widnsp*2./3.)+1,widnsp
         m=maxtab1+(i-1-int(widnsp*2./3.))*delta
         tabxnd(i)=m
 70   continue


c.. all pp-exit channels
c loop over first out-particle N & D
        do 81 ii1=1,2
          if(ii1.eq.1)i1=minnuc
          if(ii1.eq.2)i1=mindel
c loop over second out-particle N(1440)..maxdel
          do 82 i2=minnuc+1,maxdel
c loop over all x-values
          do 83 i=1,widnsp
c store the values ...
              frrtaby(i,1,ii1,i2)=fppfit(99,tabxnd(i),i1,i2)
83            continue
c calculate the second derivate and store it in 'frrtaby(,,2)'
          call spline (tabxnd(1),frrtaby(1,1,ii1,i2),widnsp,abl0,abln,
     .                frrtaby(1,2,ii1,i2))
82          continue
81        continue


      write (6,*) '(7/7) ready.'

c pp cross sections are now tabulated
        wtabflg=3

c save the table on disk
      call savewtab

      return
      end



cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
      real*8 function splint (xa,ya,y2a,n,x)
c
c     Unit     : general infrastructure
c     Author   : (C) Copr. 1986-92 Numerical Recipes Software
c     Date     : 03/07/96
c     Revision : 1.1
c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc

      implicit none

      include 'comres.f'
      include 'comwid.f'

      integer n
      integer k,khi,klo
      real*8 x,y,xa(n),y2a(n),ya(n)
      real*8 a,b,h

      save khi,klo
      data klo/1/
      data khi/2/

      if(khi.le.n.and.x.ge.xa(klo).and.x.lt.xa(khi))then
      elseif(khi+1.le.n.and.x.ge.xa(klo+1).and.x.lt.xa(khi+1))then
        klo=klo+1
        khi=khi+1
      else

      klo=1
      khi=n
1     if (khi-klo.gt.1) then
         k=(khi+klo)/2d0
         if(xa(k).gt.x)then
            khi=k
         else
            klo=k
         endif
      goto 1
      endif
      endif

      h=xa(khi)-xa(klo)
      if (h.eq.0.) pause 'bad xa input in splint'
      a=(xa(khi)-x)/h
      b=(x-xa(klo))/h
      y=a*ya(klo)+b*ya(khi)+((a*a*a-a)*y2a(klo)+
     .            (b*b*b-b)*y2a(khi))*(h*h)/6d0
      splint=y

      return
      end



cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
      real*8 function splintth (xa,ya,y2a,n,x,th)
c
c     Unit     : general infrastructure
c     Author   : (C) Copr. 1986-92 Numerical Recipes Software
c                modified my H. Weber
c     Date     : 03/07/96
c     Revision : 1.1
c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c     split routine with nice threshold behaviour for cross sections
c

      implicit none

      include 'comres.f'
      include 'comwid.f'

      integer n
      integer k,khi,klo
      real*8 x,y,xa(n),y2a(n),ya(n)
      real*8 a,b,h,th

      save khi,klo
      data klo/1/
      data khi/2/

      if(khi.le.n.and.x.ge.xa(klo).and.x.lt.xa(khi))then
      elseif(khi+1.le.n.and.x.ge.xa(klo+1).and.x.lt.xa(khi+1))then
        klo=klo+1
        khi=khi+1
      else

      klo=1
      khi=n
1     if (khi-klo.gt.1) then
         k=(khi+klo)/2d0
         if(xa(k).gt.x)then
            khi=k
         else
            klo=k
         endif
         goto 1
      endif
      endif
      h=xa(khi)-xa(klo)
      if (h.eq.0.) pause 'bad xa input in splint'
      if (xa(khi).lt.(th+2*h)) then
c linear approximation close to threshold (within 2h)
         splintth=ya(khi)*(x-th)/(xa(khi)-th)
      else
         a=(xa(khi)-x)/h
         b=(x-xa(klo))/h
         y=a*ya(klo)+b*ya(khi)+((a*a*a-a)*y2a(klo)+
     .        (b*b*b-b)*y2a(khi))*(h*h)/6d0
         splintth=y
      endif

      return
      end