text
stringlengths 12
986k
| repo_path
stringlengths 6
121
|
---|---|
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
! See https://llvm.org/LICENSE.txt for license information.
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
!
module mod
type base_t
contains
procedure :: some_proc => baseproc
end type
contains
logical function baseproc(this,this2)
class(base_t) :: this
class(base_t), optional :: this2
if (present(this2)) then
baseproc = .true.
else
baseproc = .false.
endif
end function
end module
program p
USE CHECK_MOD
use mod
logical results(2)
logical expect(2)
data results /.true.,.false./
data expect /.false.,.true./
type(base_t) :: t
results(1) = t%some_proc()
results(2) = t%some_proc(t)
call check(results,expect,2)
end program
| test/f90_correct/src/oop255.f90 |
MODULE GWFBASMODULE
use GLOBAL, only: GLOBALDAT
use PARAMMODULE, only: PARAMDAT
! scalars
INTEGER, SAVE, POINTER ::MSUM
INTEGER, SAVE, POINTER ::IHEDFM,IHEDUN,IDDNFM,IDDNUN,IBOUUN
INTEGER, SAVE, POINTER ::LBHDSV,LBDDSV,LBBOSV
INTEGER, SAVE, POINTER ::IBUDFL,ICBCFL,IHDDFL,IAUXSV,IBDOPT
INTEGER, SAVE, POINTER ::IPRTIM,IPEROC,ITSOC,ICHFLG
INTEGER, SAVE, POINTER ::IDDREF,IDDREFNEW
double precision, SAVE, POINTER ::DELT,PERTIM,TOTIM,HNOFLO,HDRY,STOPER
CHARACTER(LEN=20), SAVE, POINTER ::CHEDFM,CDDNFM,CBOUFM
! arrays
INTEGER, SAVE, DIMENSION(:,:), POINTER ::IOFLG
double precision, SAVE, DIMENSION(:,:), POINTER ::VBVL
CHARACTER(LEN=16), SAVE, DIMENSION(:), POINTER ::VBNM
TYPE GWFBASTYPE
! scalars
INTEGER, POINTER ::MSUM
INTEGER, POINTER ::IHEDFM,IHEDUN,IDDNFM,IDDNUN,IBOUUN
INTEGER, POINTER ::LBHDSV,LBDDSV,LBBOSV
INTEGER, POINTER ::IBUDFL,ICBCFL,IHDDFL,IAUXSV,IBDOPT
INTEGER, POINTER ::IPRTIM,IPEROC,ITSOC,ICHFLG
INTEGER, POINTER ::IDDREF,IDDREFNEW
double precision, POINTER ::DELT,PERTIM,TOTIM,HNOFLO,HDRY,STOPER
CHARACTER(LEN=20), POINTER ::CHEDFM,CDDNFM,CBOUFM
! arrays
INTEGER, DIMENSION(:,:), POINTER ::IOFLG
double precision, DIMENSION(:,:), POINTER ::VBVL
CHARACTER(LEN=16), DIMENSION(:), POINTER ::VBNM
END TYPE
TYPE(GWFBASTYPE), SAVE ::GWFBASDAT(10)
contains
subroutine AllocateGwfBasScalars()
implicit none
!
if (.not. associated(msum)) then
allocate(MSUM)
allocate(IHEDFM,IHEDUN,IDDNFM,IDDNUN,IBOUUN)
allocate(LBHDSV,LBDDSV,LBBOSV)
allocate(IBUDFL,ICBCFL,IHDDFL,IAUXSV,IBDOPT)
allocate(IPRTIM,IPEROC,ITSOC,ICHFLG)
allocate(IDDREF,IDDREFNEW)
allocate(DELT,PERTIM,TOTIM,HNOFLO,HDRY,STOPER)
allocate(CHEDFM,CDDNFM,CBOUFM)
endif
!
return
end subroutine AllocateGwfBasScalars
SUBROUTINE GWF2BAS7DA(IGRID)
!C DEALLOCATE GLOBAL DATA
USE GLOBAL
USE PARAMMODULE
!C
DEALLOCATE(GLOBALDAT(IGRID)%NCOL)
DEALLOCATE(GLOBALDAT(IGRID)%NROW)
DEALLOCATE(GLOBALDAT(IGRID)%NLAY)
DEALLOCATE(GLOBALDAT(IGRID)%NPER)
DEALLOCATE(GLOBALDAT(IGRID)%NBOTM)
DEALLOCATE(GLOBALDAT(IGRID)%NCNFBD)
DEALLOCATE(GLOBALDAT(IGRID)%ITMUNI)
DEALLOCATE(GLOBALDAT(IGRID)%LENUNI)
DEALLOCATE(GLOBALDAT(IGRID)%IXSEC)
DEALLOCATE(GLOBALDAT(IGRID)%ITRSS)
DEALLOCATE(GLOBALDAT(IGRID)%INBAS)
DEALLOCATE(GLOBALDAT(IGRID)%IFREFM)
DEALLOCATE(GLOBALDAT(IGRID)%NODES)
DEALLOCATE(GLOBALDAT(IGRID)%IOUT)
DEALLOCATE(GLOBALDAT(IGRID)%MXITER)
!C
DEALLOCATE(GLOBALDAT(IGRID)%IUNIT)
DEALLOCATE(GLOBALDAT(IGRID)%LAYCBD)
DEALLOCATE(GLOBALDAT(IGRID)%LAYHDT)
DEALLOCATE(GLOBALDAT(IGRID)%LAYHDS)
DEALLOCATE(GLOBALDAT(IGRID)%PERLEN)
DEALLOCATE(GLOBALDAT(IGRID)%NSTP)
DEALLOCATE(GLOBALDAT(IGRID)%TSMULT)
DEALLOCATE(GLOBALDAT(IGRID)%ISSFLG)
DEALLOCATE(GLOBALDAT(IGRID)%DELR)
DEALLOCATE(GLOBALDAT(IGRID)%DELC)
DEALLOCATE(GLOBALDAT(IGRID)%BOTM)
DEALLOCATE(GLOBALDAT(IGRID)%LBOTM)
DEALLOCATE(GLOBALDAT(IGRID)%HNEW)
DEALLOCATE(GLOBALDAT(IGRID)%HOLD)
DEALLOCATE(GLOBALDAT(IGRID)%IBOUND)
DEALLOCATE(GLOBALDAT(IGRID)%CR)
DEALLOCATE(GLOBALDAT(IGRID)%CC)
DEALLOCATE(GLOBALDAT(IGRID)%CV)
DEALLOCATE(GLOBALDAT(IGRID)%HCOF)
DEALLOCATE(GLOBALDAT(IGRID)%RHS)
DEALLOCATE(GLOBALDAT(IGRID)%BUFF)
DEALLOCATE(GLOBALDAT(IGRID)%STRT)
deallocate(globaldat(igrid)%constantdelr)
deallocate(globaldat(igrid)%constantdelc)
deallocate(globaldat(igrid)%cbcfilename)
IF(.NOT.ASSOCIATED(DDREF,STRT)) DEALLOCATE(GLOBALDAT(IGRID)%DDREF)
!C
DEALLOCATE(ICLSUM,IPSUM,INAMLOC,NMLTAR,NZONAR,NPVAL)
DEALLOCATE (PARAMDAT(IGRID)%B)
DEALLOCATE (PARAMDAT(IGRID)%IACTIVE)
DEALLOCATE (PARAMDAT(IGRID)%IPLOC)
DEALLOCATE (PARAMDAT(IGRID)%IPCLST)
DEALLOCATE (PARAMDAT(IGRID)%PARNAM)
DEALLOCATE (PARAMDAT(IGRID)%PARTYP)
DEALLOCATE (PARAMDAT(IGRID)%ZONNAM)
DEALLOCATE (PARAMDAT(IGRID)%MLTNAM)
DEALLOCATE (PARAMDAT(IGRID)%INAME)
DEALLOCATE (PARAMDAT(IGRID)%RMLT)
DEALLOCATE (PARAMDAT(IGRID)%IZON)
!C
DEALLOCATE(GWFBASDAT(IGRID)%MSUM)
DEALLOCATE(GWFBASDAT(IGRID)%IHEDFM)
DEALLOCATE(GWFBASDAT(IGRID)%IHEDUN)
DEALLOCATE(GWFBASDAT(IGRID)%IDDNFM)
DEALLOCATE(GWFBASDAT(IGRID)%IDDNUN)
DEALLOCATE(GWFBASDAT(IGRID)%IBOUUN)
DEALLOCATE(GWFBASDAT(IGRID)%LBHDSV)
DEALLOCATE(GWFBASDAT(IGRID)%LBDDSV)
DEALLOCATE(GWFBASDAT(IGRID)%LBBOSV)
DEALLOCATE(GWFBASDAT(IGRID)%IBUDFL)
DEALLOCATE(GWFBASDAT(IGRID)%ICBCFL)
DEALLOCATE(GWFBASDAT(IGRID)%IHDDFL)
DEALLOCATE(GWFBASDAT(IGRID)%IAUXSV)
DEALLOCATE(GWFBASDAT(IGRID)%IBDOPT)
DEALLOCATE(GWFBASDAT(IGRID)%IPRTIM)
DEALLOCATE(GWFBASDAT(IGRID)%IPEROC)
DEALLOCATE(GWFBASDAT(IGRID)%ITSOC)
DEALLOCATE(GWFBASDAT(IGRID)%ICHFLG)
DEALLOCATE(GWFBASDAT(IGRID)%IDDREF)
DEALLOCATE(GWFBASDAT(IGRID)%IDDREFNEW)
DEALLOCATE(GWFBASDAT(IGRID)%DELT)
DEALLOCATE(GWFBASDAT(IGRID)%PERTIM)
DEALLOCATE(GWFBASDAT(IGRID)%TOTIM)
DEALLOCATE(GWFBASDAT(IGRID)%HNOFLO)
DEALLOCATE(GWFBASDAT(IGRID)%HDRY)
DEALLOCATE(GWFBASDAT(IGRID)%STOPER)
DEALLOCATE(GWFBASDAT(IGRID)%CHEDFM)
DEALLOCATE(GWFBASDAT(IGRID)%CDDNFM)
DEALLOCATE(GWFBASDAT(IGRID)%CBOUFM)
!C
DEALLOCATE(GWFBASDAT(IGRID)%IOFLG)
DEALLOCATE(GWFBASDAT(IGRID)%VBVL)
DEALLOCATE(GWFBASDAT(IGRID)%VBNM)
!C
RETURN
END SUBROUTINE GWF2BAS7DA
SUBROUTINE SGWF2BAS7PSV(IGRID)
!C Save global data for a grid.
USE GLOBAL
USE PARAMMODULE
!C
GLOBALDAT(IGRID)%NCOL=>NCOL
GLOBALDAT(IGRID)%NROW=>NROW
GLOBALDAT(IGRID)%NLAY=>NLAY
GLOBALDAT(IGRID)%NPER=>NPER
GLOBALDAT(IGRID)%NBOTM=>NBOTM
GLOBALDAT(IGRID)%NCNFBD=>NCNFBD
GLOBALDAT(IGRID)%ITMUNI=>ITMUNI
GLOBALDAT(IGRID)%LENUNI=>LENUNI
GLOBALDAT(IGRID)%IXSEC=>IXSEC
GLOBALDAT(IGRID)%ITRSS=>ITRSS
GLOBALDAT(IGRID)%INBAS=>INBAS
GLOBALDAT(IGRID)%IFREFM=>IFREFM
GLOBALDAT(IGRID)%NODES=>NODES
GLOBALDAT(IGRID)%IOUT=>IOUT
GLOBALDAT(IGRID)%MXITER=>MXITER
!C
GLOBALDAT(IGRID)%IUNIT=>IUNIT
GLOBALDAT(IGRID)%LAYCBD=>LAYCBD
GLOBALDAT(IGRID)%LAYHDT=>LAYHDT
GLOBALDAT(IGRID)%LAYHDS=>LAYHDS
GLOBALDAT(IGRID)%PERLEN=>PERLEN
GLOBALDAT(IGRID)%NSTP=>NSTP
GLOBALDAT(IGRID)%TSMULT=>TSMULT
GLOBALDAT(IGRID)%ISSFLG=>ISSFLG
GLOBALDAT(IGRID)%DELR=>DELR
GLOBALDAT(IGRID)%DELC=>DELC
GLOBALDAT(IGRID)%BOTM=>BOTM
GLOBALDAT(IGRID)%LBOTM=>LBOTM
GLOBALDAT(IGRID)%HNEW=>HNEW
GLOBALDAT(IGRID)%HOLD=>HOLD
GLOBALDAT(IGRID)%IBOUND=>IBOUND
GLOBALDAT(IGRID)%CR=>CR
GLOBALDAT(IGRID)%CC=>CC
GLOBALDAT(IGRID)%CV=>CV
GLOBALDAT(IGRID)%HCOF=>HCOF
GLOBALDAT(IGRID)%RHS=>RHS
GLOBALDAT(IGRID)%BUFF=>BUFF
GLOBALDAT(IGRID)%STRT=>STRT
GLOBALDAT(IGRID)%DDREF=>DDREF
globaldat(igrid)%constantdelr => constantdelr
globaldat(igrid)%constantdelc => constantdelc
globaldat(igrid)%cbcfilename => cbcfilename
!C
PARAMDAT(IGRID)%ICLSUM=>ICLSUM
PARAMDAT(IGRID)%IPSUM=>IPSUM
PARAMDAT(IGRID)%INAMLOC=>INAMLOC
PARAMDAT(IGRID)%NMLTAR=>NMLTAR
PARAMDAT(IGRID)%NZONAR=>NZONAR
PARAMDAT(IGRID)%NPVAL=>NPVAL
!C
PARAMDAT(IGRID)%B=>B
PARAMDAT(IGRID)%IACTIVE=>IACTIVE
PARAMDAT(IGRID)%IPLOC=>IPLOC
PARAMDAT(IGRID)%IPCLST=>IPCLST
PARAMDAT(IGRID)%IZON=>IZON
PARAMDAT(IGRID)%RMLT=>RMLT
PARAMDAT(IGRID)%PARNAM=>PARNAM
PARAMDAT(IGRID)%PARTYP=>PARTYP
PARAMDAT(IGRID)%ZONNAM=>ZONNAM
PARAMDAT(IGRID)%MLTNAM=>MLTNAM
PARAMDAT(IGRID)%INAME=>INAME
!C
GWFBASDAT(IGRID)%MSUM=>MSUM
GWFBASDAT(IGRID)%IHEDFM=>IHEDFM
GWFBASDAT(IGRID)%IHEDUN=>IHEDUN
GWFBASDAT(IGRID)%IDDNFM=>IDDNFM
GWFBASDAT(IGRID)%IDDNUN=>IDDNUN
GWFBASDAT(IGRID)%IBOUUN=>IBOUUN
GWFBASDAT(IGRID)%LBHDSV=>LBHDSV
GWFBASDAT(IGRID)%LBDDSV=>LBDDSV
GWFBASDAT(IGRID)%LBBOSV=>LBBOSV
GWFBASDAT(IGRID)%IBUDFL=>IBUDFL
GWFBASDAT(IGRID)%ICBCFL=>ICBCFL
GWFBASDAT(IGRID)%IHDDFL=>IHDDFL
GWFBASDAT(IGRID)%IAUXSV=>IAUXSV
GWFBASDAT(IGRID)%IBDOPT=>IBDOPT
GWFBASDAT(IGRID)%IPRTIM=>IPRTIM
GWFBASDAT(IGRID)%IPEROC=>IPEROC
GWFBASDAT(IGRID)%ITSOC=>ITSOC
GWFBASDAT(IGRID)%ICHFLG=>ICHFLG
GWFBASDAT(IGRID)%IDDREF=>IDDREF
GWFBASDAT(IGRID)%IDDREFNEW=>IDDREFNEW
GWFBASDAT(IGRID)%DELT=>DELT
GWFBASDAT(IGRID)%PERTIM=>PERTIM
GWFBASDAT(IGRID)%TOTIM=>TOTIM
GWFBASDAT(IGRID)%HNOFLO=>HNOFLO
GWFBASDAT(IGRID)%HDRY=>HDRY
GWFBASDAT(IGRID)%STOPER=>STOPER
GWFBASDAT(IGRID)%CHEDFM=>CHEDFM
GWFBASDAT(IGRID)%CDDNFM=>CDDNFM
GWFBASDAT(IGRID)%CBOUFM=>CBOUFM
!C
GWFBASDAT(IGRID)%IOFLG=>IOFLG
GWFBASDAT(IGRID)%VBVL=>VBVL
GWFBASDAT(IGRID)%VBNM=>VBNM
!C
RETURN
END SUBROUTINE SGWF2BAS7PSV
SUBROUTINE SGWF2BAS7PNT(IGRID)
!C Change global data to a different grid.
USE GLOBAL
USE PARAMMODULE
!C
NCOL=>GLOBALDAT(IGRID)%NCOL
NROW=>GLOBALDAT(IGRID)%NROW
NLAY=>GLOBALDAT(IGRID)%NLAY
NPER=>GLOBALDAT(IGRID)%NPER
NBOTM=>GLOBALDAT(IGRID)%NBOTM
NCNFBD=>GLOBALDAT(IGRID)%NCNFBD
ITMUNI=>GLOBALDAT(IGRID)%ITMUNI
LENUNI=>GLOBALDAT(IGRID)%LENUNI
IXSEC=>GLOBALDAT(IGRID)%IXSEC
ITRSS=>GLOBALDAT(IGRID)%ITRSS
INBAS=>GLOBALDAT(IGRID)%INBAS
IFREFM=>GLOBALDAT(IGRID)%IFREFM
NODES=>GLOBALDAT(IGRID)%NODES
IOUT=>GLOBALDAT(IGRID)%IOUT
MXITER=>GLOBALDAT(IGRID)%MXITER
!C
IUNIT=>GLOBALDAT(IGRID)%IUNIT
LAYCBD=>GLOBALDAT(IGRID)%LAYCBD
LAYHDT=>GLOBALDAT(IGRID)%LAYHDT
LAYHDS=>GLOBALDAT(IGRID)%LAYHDS
PERLEN=>GLOBALDAT(IGRID)%PERLEN
NSTP=>GLOBALDAT(IGRID)%NSTP
TSMULT=>GLOBALDAT(IGRID)%TSMULT
ISSFLG=>GLOBALDAT(IGRID)%ISSFLG
DELR=>GLOBALDAT(IGRID)%DELR
DELC=>GLOBALDAT(IGRID)%DELC
BOTM=>GLOBALDAT(IGRID)%BOTM
LBOTM=>GLOBALDAT(IGRID)%LBOTM
HNEW=>GLOBALDAT(IGRID)%HNEW
HOLD=>GLOBALDAT(IGRID)%HOLD
IBOUND=>GLOBALDAT(IGRID)%IBOUND
CR=>GLOBALDAT(IGRID)%CR
CC=>GLOBALDAT(IGRID)%CC
CV=>GLOBALDAT(IGRID)%CV
HCOF=>GLOBALDAT(IGRID)%HCOF
RHS=>GLOBALDAT(IGRID)%RHS
BUFF=>GLOBALDAT(IGRID)%BUFF
STRT=>GLOBALDAT(IGRID)%STRT
DDREF=>GLOBALDAT(IGRID)%DDREF
constantdelr => globaldat(igrid)%constantdelr
constantdelc => globaldat(igrid)%constantdelc
cbcfilename => globaldat(igrid)%cbcfilename
!C
ICLSUM=>PARAMDAT(IGRID)%ICLSUM
IPSUM=>PARAMDAT(IGRID)%IPSUM
INAMLOC=>PARAMDAT(IGRID)%INAMLOC
NMLTAR=>PARAMDAT(IGRID)%NMLTAR
NZONAR=>PARAMDAT(IGRID)%NZONAR
NPVAL=>PARAMDAT(IGRID)%NPVAL
!C
B=>PARAMDAT(IGRID)%B
IACTIVE=>PARAMDAT(IGRID)%IACTIVE
IPLOC=>PARAMDAT(IGRID)%IPLOC
IPCLST=>PARAMDAT(IGRID)%IPCLST
IZON=>PARAMDAT(IGRID)%IZON
RMLT=>PARAMDAT(IGRID)%RMLT
PARNAM=>PARAMDAT(IGRID)%PARNAM
PARTYP=>PARAMDAT(IGRID)%PARTYP
ZONNAM=>PARAMDAT(IGRID)%ZONNAM
MLTNAM=>PARAMDAT(IGRID)%MLTNAM
INAME=>PARAMDAT(IGRID)%INAME
!C
MSUM=>GWFBASDAT(IGRID)%MSUM
IHEDFM=>GWFBASDAT(IGRID)%IHEDFM
IHEDUN=>GWFBASDAT(IGRID)%IHEDUN
IDDNFM=>GWFBASDAT(IGRID)%IDDNFM
IDDNUN=>GWFBASDAT(IGRID)%IDDNUN
IBOUUN=>GWFBASDAT(IGRID)%IBOUUN
LBHDSV=>GWFBASDAT(IGRID)%LBHDSV
LBDDSV=>GWFBASDAT(IGRID)%LBDDSV
LBBOSV=>GWFBASDAT(IGRID)%LBBOSV
IBUDFL=>GWFBASDAT(IGRID)%IBUDFL
ICBCFL=>GWFBASDAT(IGRID)%ICBCFL
IHDDFL=>GWFBASDAT(IGRID)%IHDDFL
IAUXSV=>GWFBASDAT(IGRID)%IAUXSV
IBDOPT=>GWFBASDAT(IGRID)%IBDOPT
IPRTIM=>GWFBASDAT(IGRID)%IPRTIM
IPEROC=>GWFBASDAT(IGRID)%IPEROC
ITSOC=>GWFBASDAT(IGRID)%ITSOC
ICHFLG=>GWFBASDAT(IGRID)%ICHFLG
IDDREF=>GWFBASDAT(IGRID)%IDDREF
IDDREFNEW=>GWFBASDAT(IGRID)%IDDREFNEW
DELT=>GWFBASDAT(IGRID)%DELT
PERTIM=>GWFBASDAT(IGRID)%PERTIM
TOTIM=>GWFBASDAT(IGRID)%TOTIM
HNOFLO=>GWFBASDAT(IGRID)%HNOFLO
HDRY=>GWFBASDAT(IGRID)%HDRY
STOPER=>GWFBASDAT(IGRID)%STOPER
CHEDFM=>GWFBASDAT(IGRID)%CHEDFM
CDDNFM=>GWFBASDAT(IGRID)%CDDNFM
CBOUFM=>GWFBASDAT(IGRID)%CBOUFM
!C
IOFLG=>GWFBASDAT(IGRID)%IOFLG
VBVL=>GWFBASDAT(IGRID)%VBVL
VBNM=>GWFBASDAT(IGRID)%VBNM
!C
RETURN
END SUBROUTINE SGWF2BAS7PNT
function FindHighestActiveLayer(irow,jcol) result (klay)
use GLOBAL, only: NROW, NCOL, NLAY, IBOUND
implicit none
! dummy
integer, intent(in) :: irow, jcol
integer :: klay
! local
integer :: k
!
klay = 0
do k=1,NLAY
if (IBOUND(jcol, irow, k) > 0) then
klay = k
exit
endif
enddo
!
return
end function FindHighestActiveLayer
END MODULE GWFBASMODULE
| utils/mf5to6/src/MF2005/GwfBasModule.f90 |
C %W% %G%
subroutine opents (ia)
C
C This subroutine opens various files needed by the program
c NOTE: the following statements do not conform to the
c FORTRAN-77 standard and may need to be removed for some platforms
c
c disp='delete'
c form='unformatted'
c recordsize=4065
c recordtype=variable
c organization=relative
c
include 'tspinc/blkcom1.inc'
include 'tspinc/files.inc'
include 'tspinc/reread.inc'
common /error_code/ error_code
integer error_code
c
logical debug
integer status, open_file
character type_open * 8
data debug /.false./
c begin begin begin begin begin begin
C
C Master list of files
C
C L1 = scratch files (INPUT and INITAL)
C L2 = scratch files (INPUT and INITAL)
C L3 = Powerflow base data file
C L5 = Swing input data file
c L6 = Swing printout file
C L8 = Swing history file
C L9 = Existing saved swing data file
c L11 = auxiliary (tabular) listing file
C L13 = Debug output file
C L15 = New saved swing data file
c L22 = PDF plot neutral file.
C L23 = PostScript Master file
C
if (is_it_vms() .ne. 0) then
type_open = 'new'
else
type_open = 'unknown'
endif
go to (101,201,301,401,501,601,701,801) ia
C
C Subroutine SWINGM
C
C L1 = scratch files (INPUT and INITAL)
C L2 = scratch files (INPUT and INITAL)
C L3 = Powerflow base data file
C L5 = Swing input data file
c L6 = Swing printout file
C L8 = Swing history file
C
101 if (filefl .ne. ' ') then
status = open_file (l5, ctrlfl, 'F', 'R', iostat)
if (status .ne. 0) then
error_code = 1
call set_exit(error_code)
endif
else
status = open_file (l5, ' ', 'F', 'R', iostat)
endif
if (status .eq. 0) then
inquire (unit=l5, name=ctrlfl)
endif
return
201 if (filefl .ne. ' ') then
status = open_file (l3, bsefl, 'U', 'R', iostat)
if (status .ne. 0) then
error_code = 2
call set_exit(error_code)
endif
else
status = open_file (l3, ' ', 'U', 'R', iostat)
endif
if (status .eq. 0) then
inquire (unit=l3, name=bsefl)
endif
if (filefl .ne. ' ') then
open (unit=l8, file=solfl, status = type_open,
& access = 'DIRECT',
c & recordtype = 'FIXED',
& form = 'UNFORMATTED',
& recl = 4*128)
else
open (unit=l8, status = type_open,
& access = 'DIRECT',
c & recordtype = 'FIXED',
& form = 'UNFORMATTED',
& recl = 4*128)
endif
if (status .eq. 0) then
inquire (unit=l8, name=solfl)
endif
c End VAX VMS version
call inithis ('WRIT')
if (debug) then
call dbgeko2 ('OPENTS - simulation stage - opening solution ',
& 'file.')
call dbgwri (' L8 /unit num/ = ',l8)
call dbgwrc (' SOLFL /file name/ = ',solfl)
endif
C
C For subroutine INPUT1
if (is_it_vms() .eq. 0) then
C
C UNIX version
open(unit=l1,
& status='scratch',
& access='direct',
c & disp='delete',
& form='unformatted')
c & recordtype='fixed',
C & recordsize=4*4000)
c & organization='relative',
c & file = 'stab.scr01')
else
c VAX VMS version
open(unit=l1,
& status='scratch',
& access='direct',
c & disp='delete',
& form='unformatted')
c & recordtype='variable',
c & recordsize=4*4000)
c & organization='relative',
c & file = 'scratch.dat')
endif
C
C For subroutine INPUT3
C
if (is_it_vms() .eq. 0) then
C
C UNIX version
open(unit=l2,
& status='scratch',
& access='direct',
c & disp='delete',
& form='unformatted')
c & recordsize=4*4065)
c & recordtype='fixed',
c & organization='relative',
c & file = 'stab.scr02')
else
c VAX VMS version
c
open(unit=l2,
& status='scratch',
& access='direct',
c & disp='delete',
& form='unformatted')
c & recordsize=4*4065)
c & recordtype='variable',
c & organization='relative',
c & file = 'junk.dat')
endif
return
C
C Subroutine TAPEWK
C
C L9 = Existing saved swing data file
C
301 if (filefl .ne. ' ') then
status = open_file (l9, savifl, 'U', 'R', iostat)
if (status .ne. 0) then
error_code = 3
call set_exit(error_code)
endif
else
status = open_file (l9, ' ', 'U', 'R', iostat)
endif
if (status .eq. 0) then
inquire (unit=l9, name=savifl)
endif
return
C Subroutine TAPEWK
C
C L15 = New saved swing data file
401 if (filefl .ne. ' ') then
status = open_file (15, savofl, 'U', 'W', iostat)
if (status .ne. 0) then
error_code = 4
call set_exit(error_code)
endif
else
status = open_file (15, ' ', 'U', 'W', iostat)
endif
if (status .eq. 0) then
inquire (unit=15, name=savofl)
endif
return
C
C Subroutine NOUT1 - plotting phase
C
C L3 = Powerflow base data file
C L8 = Swing history file
c L11 = auxiliary (tabular) listing file
c L22 = PDF plot neutral file.
C L23 = PostScript Master file
C
501 if (filefl .ne. ' ') then
status = open_file (l3, bsefl, 'U', 'R', iostat)
if (status .ne. 0) then
error_code = 5
call set_exit(error_code)
endif
else
status = open_file (l3, ' ', 'U', 'R', iostat)
endif
if (status .eq. 0) then
inquire (unit=l3, name=bsefl)
endif
if (filefl .ne. ' ') then
open (unit=l8,
& file=solfl,
& status = 'old',
& access = 'direct',
c & recordtype = 'fixed',
& form = 'unformatted',
& recl = 4*128)
else
open (unit=l8,
& status = 'old',
& access = 'direct',
c & recordtype = 'fixed',
& form = 'unformatted',
& recl = 4*128)
endif
if (status .eq. 0) then
inquire (unit=l8, name=solfl)
endif
if (filefl .ne. ' ') then
status = open_file (l11, auxfl, 'F', 'W', iostat)
if (status .ne. 0) then
error_code = 6
call set_exit(error_code)
endif
else
status = open_file (l11, ' ', 'F', 'W', iostat)
endif
if (status .eq. 0) then
inquire (unit=l11, name=auxfl)
endif
if (filefl .ne. ' ') then
status = open_file (l22, pltfl, 'F', 'W', iostat)
if (status .ne. 0) then
error_code = 7
call set_exit(error_code)
endif
else
status = open_file (l22, ' ', 'F', 'W', iostat)
endif
if (status .eq. 0) then
inquire (unit=l22, name=pltfl)
endif
c
c PostScript master file POSTMSTR is optional
c
if (filefl .ne. ' ') then
status = open_file (l23, postmstr, 'F', 'R', iostat)
c if (status .ne. 0) then
c error_code = 7
c call set_exit(error_code)
c endif
else
status = open_file (l23, ' ', 'F', 'R', iostat)
endif
if (status .eq. 0) then
inquire (unit=l23, name=postmstr)
endif
call inithis ('READ')
if (debug) then
call dbgeko2 ('OPENTS - plotting stage - opening solution',
& ' & plot files.')
call dbgwri (' L3 /unit num/ = ',l3)
call dbgwrc (' BSEFL /file name/ = ',bsefl)
call dbgwri (' L8 /unit num/ = ',l8)
call dbgwrc (' SOLFL /file name/ = ',solfl)
call dbgwri (' L22 /unit num/ = ',l22)
call dbgwrc (' PLTFL /file name/ = ',pltfl)
call dbgwri (' L23 /unit num/ = ',l23)
call dbgwrc (' POSTMSTR /file name/ = ',postmstr)
call dbgwri (' L11 /unit num/ = ',l11)
call dbgwrc (' AUXFL /file name/ = ',auxfl)
endif
return
C
C Subroutine PRGMON
C
601 return
c Open printout file
C
c L6 = Swing printout file
C L13 = Debug output file
701 if (filefl .ne. ' ') then
status = open_file (l6, prtfl, 'FF', 'W', iostat)
if (status .ne. 0) then
error_code = 8
call set_exit(error_code)
endif
else
status = open_file (l6, ' ', 'FF', 'W', iostat)
endif
if (status .eq. 0) then
inquire (unit=l6, name=prtfl)
endif
if (filefl .ne. ' ') then
status = open_file (l13, dbgofl, 'F', 'W', iostat)
if (status .ne. 0) then
error_code = 6
call set_exit(error_code)
endif
else
status = open_file (l13, ' ', 'F', 'W', iostat)
endif
if (status .eq. 0) then
inquire (unit=l13, name=dbgofl)
endif
return
c Open file_list file
c Note: file list file contains file names.
801 status = open_file (l1, filefl, 'F', 'R', iostat)
if (status .ne. 0) then
error_code = 9
call set_exit(error_code)
endif
if (status .eq. 0) then
inquire (unit=l1, name=filefl)
endif
return
end
| libtsp/opents.f |
Lambda X . lambda x : X . x | tests/test4.f |
C$Procedure ZZPDCMPL (Planetodetic coordinates, compare latitudes )
SUBROUTINE ZZPDCMPL ( RE, F, P, LAT, REL )
C$ Abstract
C
C SPICE Private routine intended solely for the support of SPICE
C routines. Users should not call this routine directly due to the
C volatile nature of this routine.
C
C Compare the planetodetic latitude of a point in 3-dimensional
C space against a specified value, without converting the point to
C planetodetic coordinates.
C
C$ Disclaimer
C
C THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
C CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
C GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
C ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
C PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
C TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
C WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
C PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
C SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
C SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
C
C IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
C BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
C LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
C INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
C REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
C REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
C
C RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
C THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
C CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
C ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
C
C$ Required_Reading
C
C None.
C
C$ Keywords
C
C COORDINATES
C GEOMETRY
C PLANETODETIC
C LATITUDE
C MATH
C
C$ Declarations
IMPLICIT NONE
DOUBLE PRECISION RE
DOUBLE PRECISION F
DOUBLE PRECISION P ( 3 )
DOUBLE PRECISION LAT
INTEGER REL
INTEGER LT
PARAMETER ( LT = -1 )
INTEGER EQ
PARAMETER ( EQ = 0 )
INTEGER GT
PARAMETER ( GT = 1 )
C$ Brief_I/O
C
C Variable I/O Description
C -------- --- --------------------------------------------------
C RE I Equatorial radius.
C F I Flattening coefficient.
C P I Three-dimensional point.
C LAT I Planetodetic latitude.
C REL O Relation code.
C LT P Code indicating latitude of P < LAT.
C EQ P Code indicating latitude of P = LAT.
C GT P Code indicating latitude of P > LAT.
C
C$ Detailed_Input
C
C RE,
C F are, respectively, the equatorial radius
C and flattening coefficient of a biaxial
C spheroid.
C
C The polar radius RP of the spheroid is
C
C RP = RE * ( 1 - F )
C
C RP may be less than, equal to, or greater than RE.
C
C
C P is a point (equivalently, a vector) in
C three-dimensional space. P is expressed in Cartesian
C coordinates.
C
C The units of P must be consistent with those of RE.
C
C
C LAT is a planetodetic latitude value to be compared
C against the planetodetic latitude of P. Units
C are radians.
C
C$ Detailed_Output
C
C REL is an integer code that indicates the order
C relation between the planetodetic latitude of P
C and LAT. The planetodetic coordinate system is
C defined by the inputs RE and F.
C
C The code <rel> indicates that the relation
C
C <latitude of P> <rel> LAT
C
C is true. See the Parameters section below for
C the parameter names.
C
C
C$ Parameters
C
C LT,
C EQ,
C GT are, respectively, codes indicating the relationship
C of the planetodetic latitude of the input vector to
C the input latitude value. Let LP represent the
C planetodetic latitude of P.
C
C Code LT indicates LP < LAT
C Code EQ indicates LP = LAT
C Code GT indicates LP > LAT
C
C$ Exceptions
C
C 1) If either the equatorial radius or flattening coefficient
C is invalid, the error will be signaled by a routine in the
C call tree of this routine.
C
C$ Files
C
C None.
C
C$ Particulars
C
C This routine performs a planetodetic latitude comparison more
C efficiently than can be done using a rectangular-to-planetodetic
C coordinate conversion.
C
C$ Examples
C
C None.
C
C$ Restrictions
C
C There are some cases for which this routine cannot be applied.
C See the SPICELIB routine ZZPDPLTC and its usage in ZZRYTPDT.
C
C$ Literature_References
C
C None.
C
C$ Author_and_Institution
C
C N.J. Bachman (JPL)
C
C$ Version
C
C- SPICELIB Version 1.0.0, 19-JAN-2017 (NJB)
C
C Original version 22-AUG-2015 (NJB)
C
C-&
C$ Index_Entries
C
C compare planetodetic latitude of vector against value
C compare planetodetic latitude of point against value
C
C-&
C
C SPICELIB functions
C
DOUBLE PRECISION HALFPI
LOGICAL FAILED
LOGICAL RETURN
C
C Local variables
C
DOUBLE PRECISION APEX ( 3 )
DOUBLE PRECISION LON
DOUBLE PRECISION OFFPCL
DOUBLE PRECISION OFFSET ( 3 )
DOUBLE PRECISION R
DOUBLE PRECISION RP
DOUBLE PRECISION XINCPT
DOUBLE PRECISION YINCPT
C
C Saved variables
C
SAVE APEX
C
C Initial values
C
DATA APEX / 3 * 0.D0 /
IF ( RETURN() ) THEN
RETURN
END IF
CALL CHKIN ( 'ZZPDCMPL' )
C
C Treat points on the Z axis as a special case. The
C computations performed in the general case may introduce
C round-off errors that will lead to false results for
C this case.
C
IF ( ( P(1) .EQ. 0.D0 ) .AND. ( P(2) .EQ. 0.D0 ) ) THEN
IF ( P(3) .GT. 0.D0 ) THEN
IF ( LAT .EQ. HALFPI() ) THEN
REL = EQ
ELSE
REL = GT
END IF
ELSE IF ( P(3) .EQ. 0.D0 ) THEN
C
C We consider the latitude of P to be zero.
C
IF ( LAT .GT. 0.D0 ) THEN
REL = LT
ELSE IF ( LAT .EQ. 0.D0 ) THEN
REL = EQ
ELSE
REL = GT
END IF
ELSE
C
C P(3) < 0.
C
IF ( LAT .EQ. -HALFPI() ) THEN
REL = EQ
ELSE
REL = LT
END IF
END IF
CALL CHKOUT ( 'ZZPDCMPL' )
RETURN
END IF
C
C Latitude zero is a special case. The planetodetic latitude of the
C input point has the same sign as the Z component of the point.
C
RP = RE * ( 1.D0 - F )
C
C Get the y-intercept of the latitude cone for LAT. Note that a
C result is defined for LAT = +/- pi/2.
C
CALL ZZELNAXX ( RE, RP, LAT, XINCPT, YINCPT )
IF ( FAILED() ) THEN
CALL CHKOUT ( 'ZZPDCMPL' )
RETURN
END IF
C
C Ideally YINCPT is zero if and only if LAT is zero.
C We'll group these conditions together.
C
IF ( ( LAT .EQ. 0.D0 ) .OR. ( YINCPT .EQ. 0.D0 ) ) THEN
IF ( P(3) .GT. 0.D0 ) THEN
REL = GT
ELSE IF ( P(3) .EQ. 0.D0 ) THEN
REL = EQ
ELSE
REL = LT
END IF
CALL CHKOUT ( 'ZZPDCMPL' )
RETURN
END IF
C
C This is the normal case.
C
C Find the offset of the point from the latitude cone's apex.
C Create a unit-length copy of the offset vector.
C
APEX(3) = YINCPT
CALL VSUB ( P, APEX, OFFSET )
C We'll use the planetocentric [sic] latitude of the offset
C vector for comparison.
C
CALL RECLAT ( OFFSET, R, LON, OFFPCL )
IF ( LAT .GT. 0.D0 ) THEN
IF ( YINCPT .GT. 0 ) THEN
C
C This is the prolate case.
C
IF ( OFFPCL .GT. LAT ) THEN
REL = GT
ELSE IF ( OFFPCL .EQ. LAT ) THEN
REL = EQ
ELSE
REL = LT
END IF
ELSE
C
C YINCPT = 0 was handled previously, so YINCPT < 0.
C
C This is the oblate case.
C
C In addition to the comparison of angles, we need to know
C the input point is above the X-Y plane in order for the
C GT or EQ relations to hold.
C
IF ( P(3) .GT. 0.D0 ) THEN
IF ( OFFPCL .GT. LAT ) THEN
REL = GT
ELSE IF ( OFFPCL .EQ. LAT ) THEN
REL = EQ
ELSE
REL = LT
END IF
ELSE
C
C The input latitude is positive, while the point
C is on or below the X-Y plane.
C
REL = LT
END IF
END IF
ELSE
C
C LAT < 0, since the case LAT = 0 has already been handled.
C
IF ( YINCPT .LT. 0.D0 ) THEN
C
C This is the prolate case.
C
IF ( OFFPCL .GT. LAT ) THEN
REL = GT
ELSE IF ( OFFPCL .EQ. LAT ) THEN
REL = EQ
ELSE
REL = LT
END IF
ELSE
C
C YINCPT > 0, since the case YINCPT = 0 was handled
C previously.
C
C This is the oblate case.
C
IF ( P(3) .LT. 0.D0 ) THEN
IF ( OFFPCL .GT. LAT ) THEN
REL = GT
ELSE IF ( OFFPCL .EQ. LAT ) THEN
REL = EQ
ELSE
REL = LT
END IF
ELSE
C
C The input latitude is negative, while the point
C is on or above the X-Y plane.
C
REL = GT
END IF
END IF
END IF
CALL CHKOUT ( 'ZZPDCMPL' )
RETURN
END
| source/nasa_f/zzpdcmpl.f |
submodule (h5fortran:write) write_scalar
use hdf5, only: h5dwrite_f
implicit none (type, external)
contains
module procedure h5write_scalar
integer(HID_T) :: filespace_id, dset_id, dtype_id
integer(HSIZE_T) :: dims(0)
integer :: ier
if(.not.self%is_open) error stop 'h5fortran:write: file handle is not open'
select type (value)
type is (real(real32))
call hdf_create(self, dname, H5T_NATIVE_REAL, dims, filespace_id, dset_id, compact=compact)
call h5dwrite_f(dset_id, H5T_NATIVE_REAL, value, dims, ier)
type is (real(real64))
call hdf_create(self, dname, H5T_NATIVE_DOUBLE, dims, filespace_id, dset_id, compact=compact)
call h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, value, dims, ier)
type is (integer(int32))
call hdf_create(self, dname, H5T_NATIVE_INTEGER, dims, filespace_id, dset_id, compact=compact)
call h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, value, dims, ier)
type is (integer(int64))
call hdf_create(self, dname, H5T_STD_I64LE, dims, filespace_id, dset_id, compact=compact)
call h5dwrite_f(dset_id, H5T_STD_I64LE, value, dims, ier)
type is (character(*))
call hdf_create(self, dname, H5T_NATIVE_CHARACTER, dims, filespace_id, dset_id, dtype_id, charlen=len(value))
call h5dwrite_f(dset_id, dtype_id, value, dims, ier)
if (ier /= 0) error stop 'h5fortran:write:string: could not write ' // dname // ' to ' // self%filename
call h5tclose_f(dtype_id, ier)
class default
error stop "h5fortran:write: unknown type"
end select
if (ier /= 0) error stop 'h5fortran:write: could not write ' // dname // ' to ' // self%filename
call hdf_wrapup(dset_id, filespace_id)
end procedure h5write_scalar
end submodule write_scalar
| src/write_scalar.f90 |
C Copyright(C) 2008-2017 National Technology & Engineering Solutions of
C Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
C NTESS, the U.S. Government retains certain rights in this software.
C
C Redistribution and use in source and binary forms, with or without
C modification, are permitted provided that the following conditions are
C met:
C
C * Redistributions of source code must retain the above copyright
C notice, this list of conditions and the following disclaimer.
C
C * Redistributions in binary form must reproduce the above
C copyright notice, this list of conditions and the following
C disclaimer in the documentation and/or other materials provided
C with the distribution.
C
C * Neither the name of NTESS nor the names of its
C contributors may be used to endorse or promote products derived
C from this software without specific prior written permission.
C
C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
C
C=======================================================================
SUBROUTINE NXMMAX (ISTEP, MMNUM, IVAR, NVAR, NUM, VAR,
& OLDMIN, OLDMAX, XMIN, XMAX,
& MINSTE, MAXSTE, MINNE, MAXNE, NMIN, NMAX)
C=======================================================================
C --*** NXMMAX *** (GROPE) Find the min/max for this time step
C --
C --NXMMAX finds an incremental minimum and maximum of a variable
C --for this time step. It does not reset the min/max if not on the
C --first step. It may find the min/max that are greater/less than
C --the previous values.
C --
C --Parameters:
C -- ISTEP - IN - the current step number, previous XMIN and XMAX
C -- are overwritten if <=1
C -- MMNUM - IN - number of sequential min/max requests for this
C -- variable, if >1 then find next min/max
C -- IVAR - IN - min/max variable number
C -- NUM - IN - the number of nodes or elements or 1 for global
C -- VAR - IN - the variables for current time step
C -- OLDMIN, OLDMAX - IN/OUT - the last minimum and maximum values,
C -- only if MMNUM > 1
C -- XMIN, XMAX - IN/OUT - the minimum and maximum values
C -- MINSTE, MAXSTE - IN/OUT - the step number where the minimum and
C -- maximum were found
C -- MINNE, MAXNE - IN/OUT - the node or element number where the
C -- minimum and maximum were found
C -- NMIN, NMAX - IN/OUT - the number of values equal to the minimum
C -- and maximum were found
REAL VAR(NUM, NVAR)
IF (ISTEP .LE. 1) THEN
XMIN = 1.0E36
XMAX = - 1.0E36
IF (MMNUM .LE. 1) THEN
OLDMIN = - 1.0E36
OLDMAX = 1.0E36
ELSE
OLDMIN = XMAX
OLDMAX = XMIN
END IF
END IF
DO 100 I = 1, NUM
IF ((XMIN .GT. VAR(I,IVAR))
& .AND. (VAR(I,IVAR) .GT. OLDMIN)) THEN
XMIN = VAR(I,IVAR)
MINSTE = ISTEP
MINNE = I
NMIN = 1
ELSE IF (XMIN .EQ. VAR(I,IVAR)) THEN
NMIN = NMIN + 1
END IF
IF ((XMAX .LT. VAR(I,IVAR))
& .AND. (VAR(I,IVAR) .LT. OLDMAX)) THEN
XMAX = VAR(I,IVAR)
MAXSTE = ISTEP
MAXNE = I
NMAX = 1
ELSE IF (XMAX .EQ. VAR(I,IVAR)) THEN
NMAX = NMAX + 1
END IF
100 CONTINUE
RETURN
END
| packages/seacas/applications/grope/gr_nxmmax.f |
! RUN: %S/test_errors.sh %s %t %flang_fc1
! REQUIRES: shell
!Test for checking data constraints, C882-C887
module m1
type person
integer :: age
character(len=25) :: name
end type
integer, parameter::digits(5) = ( /-11,-22,-33,44,55/ )
integer ::notConstDigits(5)
real, parameter::numbers(5) = ( /-11.11,-22.22,-33.33,44.44,55.55/ )
integer, parameter :: repeat = -1
integer :: myAge = 2
type(person) associated
end
subroutine CheckRepeat
use m1
type(person) myName(6)
!C882
!ERROR: Missing initialization for parameter 'uninitialized'
integer, parameter :: uninitialized
!C882
!ERROR: Repeat count (-1) for data value must not be negative
DATA myName(1)%age / repeat * 35 /
!C882
!ERROR: Repeat count (-11) for data value must not be negative
DATA myName(2)%age / digits(1) * 35 /
!C882
!ERROR: Must be a constant value
DATA myName(3)%age / repet * 35 /
!C885
!ERROR: Must have INTEGER type, but is REAL(4)
DATA myName(4)%age / numbers(1) * 35 /
!C886
!ERROR: Must be a constant value
DATA myName(5)%age / notConstDigits(1) * 35 /
!C887
!ERROR: Must be a constant value
DATA myName(6)%age / digits(myAge) * 35 /
end
subroutine CheckValue
use m1
!ERROR: USE-associated object 'associated' must not be initialized in a DATA statement
data associated / person(1, 'Abcd Ijkl') /
type(person) myName(3)
!OK: constant structure constructor
data myname(1) / person(1, 'Abcd Ijkl') /
!C883
!ERROR: 'persn' is not an array
data myname(2) / persn(2, 'Abcd Efgh') /
!C884
!ERROR: DATA statement value 'person(age=myage,name="Abcd Ijkl ")' for 'myname(3_8)%age' is not a constant
data myname(3) / person(myAge, 'Abcd Ijkl') /
integer, parameter :: a(5) =(/11, 22, 33, 44, 55/)
integer :: b(5) =(/11, 22, 33, 44, 55/)
integer :: i
integer :: x, y, z
!OK: constant array element
data x / a(1) /
!C886, C887
!ERROR: DATA statement value 'a(int(i,kind=8))' for 'y' is not a constant
data y / a(i) /
!ERROR: DATA statement value 'b(1_8)' for 'z' is not a constant
data z / b(1) /
end
| flang/test/Semantics/data01.f90 |
program main
use dyn_tt
integer :: d, rmax, nswp, verb, kickrank, Asize, Ysize
real(8) :: tau
integer, allocatable :: n(:), m(:), ra(:), ry(:)
complex(8), allocatable :: crA(:), crY(:)
integer :: i
open(unit=10,status='old',file='test_ksl.dat',form='unformatted',access='stream')
!open(unit=10,status='old',file='test_eye_ksl.dat',form='unformatted',access='stream')
read(10) d
allocate(n(d))
allocate(m(d))
print *,'d=',d
read(10) n(1:d)
read(10) m(1:d)
allocate(ra(d+1))
allocate(ry(d+1))
read(10) ra(1:d+1)
read(10) ry(1:d+1)
read(10) Asize
allocate(crA(Asize))
read(10) crA(1:Asize)
allocate(crY(Ysize))
read(10) Ysize
read(10) crY(1:Ysize)
read(10) tau,rmax,kickrank,nswp,verb
close(10)
!Test if we read all correctly
print *,'n=',n(1:d)
print *,'m=',m(1:d)
print *,'ra=',ra(1:d+1)
print *,'ry=',ry(1:d+1)
print *,'tau=',tau, 'rmax=',rmax,'kickrank=',kickrank,'nswp=',nswp,'verb=',verb
do while ( 1 > 0 )
call ztt_ksl(d,n,m,ra,crA, crY, ry, tau, rmax, kickrank, nswp, verb)
end do
!Now we can call the main block
!open(unit=10,status='replace',file='test_ksl.dat',form='unformatted')
!write(10) d,n,m,ra,ry,pa(d+1)-1,crA(1:(pa(d+1)-1)),mm-1,crY0(1:mm-1),tau,rmax,kickrank,nswp,verb
!close(10)
!return
end program
| TT-Toolbox/fmex/tt-fort/test_ksl.f90 |
!*******************************************************************
! *
SUBROUTINE EL41INT(JJJA,JJJB,JA,JB,JC,IREZ,JJA,JJB,JJC,JJD, &
ICOLBREI,INTERACT)
! *
! -------------- SECTION METWO SUBPROGRAM 10 ------------- *
! *
! THIS PACKAGE DETERMINES THE VALUES OF MATRIX ELEMENTS *
! OF TWO PARTICLE OPERATOR IN CASE : N'1 = N1 + 1 *
! N'2 = N2 + 1 *
! N'3 = N3 - 2, *
! WHEN IREZ = 1 . . . . . . . . . . . . . . . . . . . *
! N'1 = N1 - 1 *
! N'2 = N2 - 1 *
! N'3 = N3 + 2, *
! WHEN IREZ = 2 . . . . . . . . . . . . . . . . . . . *
! *
! SUBROUTINE CALLED: COULOM,EILE,ITREXG,IXJTIK, *
! JFAZE,PERKO2,RECO,REC3 *
! *
! Written by G. Gaigalas NIST, December 2015 *
! *
!*******************************************************************
!
!-----------------------------------------------
! M o d u l e s
!-----------------------------------------------
USE vast_kind_param, ONLY: DOUBLE
USE CONS_C
USE m_C
USE orb_C
USE trk_C
!-----------------------------------------------
! I n t e r f a c e B l o c k s
!-----------------------------------------------
USE eile_I
USE reco_I
USE rec3_I
USE perko2_I
USE snrc_I
! USE jfaze_I
USE ixjtik_I
USE itrexg_I
USE itrig_I
USE coulom_I
! USE gg1233_I
! USE sixj_I
! USE speak_I
! USE cxk_I
! USE talk_I
IMPLICIT NONE
!-----------------------------------------------
! D u m m y A r g u m e n t s
!-----------------------------------------------
INTEGER, INTENT(IN) :: JJJA,JJJB,JA,JB,JC,IREZ,JJA,JJB, &
JJC,JJD,ICOLBREI
INTEGER, INTENT(OUT) :: INTERACT
! DIMENSION J(3)
! DIMENSION COND(12,20),S(12),IS(4),KAPS(4),KS(4)
!-----------------------------------------------
! L o c a l V a r i a b l e s
!-----------------------------------------------
INTEGER :: IA,IB,IC,II,IIA,IIB,IIC,IBRD,IBRE,IP1,IG1,IP2,IG2, &
IAT,IID,IKK,IFAZ,IFAZP,IFAZFRCS,INN,I2,I3,JB1,JAA, &
JBB,JCC,J12,KRA,L1,L2,L3,ND1,ND2,NE1,NE2,N,NN,NU, &
NUP1,MU
INTEGER :: INTERACT1, INTERACT2
INTEGER, DIMENSION(3) :: J
INTEGER, DIMENSION(4) :: IS,KAPS,KS
! REAL(DOUBLE) :: AA,AB,A1,BB,QM1,QM2,QM3,QM4,SI,RECC
REAL(DOUBLE) :: AA,A1,BB,SI,RECC
! REAL(DOUBLE), DIMENSION(12) :: S
! REAL(DOUBLE), DIMENSION(12,20) :: COND
!-----------------------------------------------
INTERACT=0
CALL EILE(JA,JB,JC,JAA,JBB,JCC)
IF(NPEEL.LE.1)RETURN
CALL RECO(JAA,JCC,JBB,JBB,2,IAT)
IF(IAT.EQ.0)RETURN
IA=JLIST(JA)
IB=JLIST(JB)
IC=JLIST(JC)
IIA=JLIST(JJA)
IIB=JLIST(JJB)
IIC=JLIST(JJC)
IID=JLIST(JJD)
! IF(IREZ.EQ.1) THEN
! QM1=-HALF
! QM2=-HALF
! QM3=HALF
! QM4=HALF
! ELSE
! QM1=HALF
! QM2=HALF
! QM3=-HALF
! QM4=-HALF
! END IF
CALL PERKO2(JA,JB,JC,JA,3)
J(1)=ID1(3)
J(2)=ID2(3)
J(3)=ID3(3)
L1=(J(1)+1)/2
L2=(J(2)+1)/2
L3=(J(3)+1)/2
IF (ICOLBREI .EQ. 2) THEN
IS(1)=IIA
IS(2)=IIB
IS(3)=IIC
IS(4)=IID
KAPS(1)=2*NAK(IS(1))
KAPS(2)=2*NAK(IS(2))
KAPS(3)=2*NAK(IS(3))
KAPS(4)=2*NAK(IS(4))
KS(1)=IABS(KAPS(1))
KS(2)=IABS(KAPS(2))
KS(3)=IABS(KAPS(3))
KS(4)=IABS(KAPS(4))
CALL SNRC(IS,KAPS,KS,ND1,ND2,NE1,NE2,IBRD,IBRE)
IF(IBRD .LE. 0)RETURN
! DO II=1,20
! COND(1,II) =ZERO
! COND(2,II) =ZERO
! COND(3,II) =ZERO
! COND(4,II) =ZERO
! COND(5,II) =ZERO
! COND(6,II) =ZERO
! COND(7,II) =ZERO
! COND(8,II) =ZERO
! COND(9,II) =ZERO
! COND(10,II)=ZERO
! COND(11,II)=ZERO
! COND(12,II)=ZERO
! END DO
END IF
! IFAZP=JFAZE(JC,JA,JB,JC)
! IFAZFRCS = 1
!
! TRANSFORM FANO & RACAH PHASE CONVENTION
! TO CONDON & SHORTLEY PHASE CONVENTION
!
! IFAZ=IK1(5)*IK1(4)+IK2(5)*IK2(4)-ID1(5)*ID1(4)-ID2(5)*ID2(4)+ &
! IK3(5)*IK3(4)-ID3(5)*ID3(4)
! IF((IFAZ/4)*4.NE.IFAZ)IFAZFRCS=-IFAZFRCS
!
! IF(JA.GT.JB) THEN
! JAA=JB
! JBB=JA
! ELSE
! JAA=JA
! JBB=JB
! END IF
! NN=0
! JB1=JBB-1
! DO II=JAA,JB1
! INN=JLIST(II)
! NN=NQ1(INN)+NN
! END DO
! IF((NN/2)*2.EQ.NN)IFAZP=-IFAZP
! * * * * * * * * *
! CASES 3312 + + - - TRANSFORM TO 1233 - - + +
! 3321 1233
! (IREZ = 1)
! OR
! CASES 1233 + + - - TRANSFORM TO 1233 + + - -
! 2133 1233
! (IREZ = 2)
IP1=ITREXG(J(2),J(1),J(3),J(3),IKK)+1
IF(IKK.LE.0)RETURN
IG1=IP1+IKK-1
IP2=ITREXG(J(3),J(1),J(2),J(3),IKK)+1
IF(IKK.LE.0) RETURN
IG2=IP2+IKK-1
DO I2=IP2,IG2,2
KRA=(I2-1)/2
!
IF (ICOLBREI .EQ. 1) THEN
INTERACT1 = 0
IF(IREZ.EQ.2) THEN
CALL COULOM(L1,L2,L3,L3,ID1(5),ID2(5),ID3(5),ID3(5),KRA,A1)
ELSE
CALL COULOM(L3,L3,L1,L2,ID3(5),ID3(5),ID1(5),ID2(5),KRA,A1)
END IF
IF(DABS(A1).LT.EPS) CYCLE
INTERACT1 = 1
END IF
!
! AB=ZERO
INTERACT2 = 0
DO I3=IP1,IG1,2
J12=(I3-1)/2
IFAZ=J(2)-J12+1
IF(IREZ.EQ.2)IFAZ=J(1)-J12+1
IF((IFAZ/2)*2.NE.IFAZ) CYCLE
CALL REC3(JA,JB,JC,J(1),J(2),J12*2,0,IAT,AA)
IF(IAT.EQ.0) CYCLE
IF(IXJTIK(J(3),J(1),KRA*2,J(2),J(3),J12*2).EQ.0) CYCLE
INTERACT2 = INTERACT2 +1
! CALL GG1233(IK1,IK2,IK3,BK1,BK2,BK3,ID1,ID2,ID3,BD1, &
! BD2,BD3,J12,QM1,QM2,QM3,QM4,AA)
! IF(DABS(AA).LT.EPS) CYCLE
! CALL REC3(JA,JB,JC,J(1),J(2),J12*2,1,IAT,RECC)
! AA=AA*RECC
! CALL SIXJ(J(3),J(1),KRA*2,J(2),J(3),J12*2,0,SI)
! AA=AA*SI*DSQRT(DBLE(I3))
! IFAZ=J(3)+J(1)+2*J12+2*KRA
! IF(IREZ.EQ.2)IFAZ=J(2)+J(3)+2*J12+2*KRA
! IF((IFAZ/4)*4.NE.IFAZ)AA=-AA
! AB=AB+AA
END DO
!CIA GG KLAIDA !!!
IF(INTERACT2 .EQ. 0) CYCLE
! IF(DABS(AB).LT.EPS) CYCLE
! AB=-AB*DBLE(IFAZP)
IF (ICOLBREI .EQ. 1) THEN
INTERACT = INTERACT1
IF(INTERACT .GT. 0) RETURN
! BB=A1*AB*DBLE(IFAZFRCS)
! CALL SPEAK(JJJA,JJJB,IIA,IIB,IIC,IID,KRA,BB)
ELSE IF (ICOLBREI .EQ. 2) THEN
INTERACT = 1
RETURN
! NU=KRA
! IF(((NU-ND1)/2)*2 .EQ. (NU-ND1)) THEN
! IF((ITRIG(KS(1),KS(3),NU+NU+1).NE.0) .AND. &
! (ITRIG(KS(2),KS(4),NU+NU+1).NE.0)) THEN
! N=(NU-ND1)/2+1
! IF(NU .GT. 0) THEN
! CALL CXK(S,IS,KAPS,NU,KRA,1,1)
! DO MU = 1,4
! COND(MU,N)=COND(MU,N)+AB*S(MU)
! END DO
! END IF
! END IF
! END IF
! NU=KRA+1
! IF(((NU-ND1)/2)*2 .EQ. (NU-ND1)) THEN
! IF((ITRIG(KS(1),KS(3),NU+NU-1).NE.0) .AND. &
! (ITRIG(KS(2),KS(4),NU+NU-1).NE.0)) THEN
! N=(NU-ND1)/2+1
! IF(N .LE. ND2) THEN
! CALL CXK(S,IS,KAPS,NU,KRA,1,1)
! DO MU = 1,4
! COND(MU,N)=COND(MU,N)+AB*S(MU)
! END DO
! END IF
! END IF
! END IF
! NU=KRA-1
! IF(((NU-ND1)/2)*2 .EQ. (NU-ND1)) THEN
! IF((ITRIG(KS(1),KS(3),NU+NU+3).NE.0) .AND. &
! (ITRIG(KS(2),KS(4),NU+NU+3).NE.0)) THEN
! IF(NU .GE. 0) THEN
! N=(NU-ND1)/2+1
! IF(N .LT. ND2) THEN
! CALL CXK(S,IS,KAPS,NU,KRA,1,1)
! DO MU = 1,12
! COND(MU,N)=COND(MU,N)+AB*S(MU)
! END DO
! END IF
! END IF
! END IF
! END IF
END IF
END DO
! IF (ICOLBREI .EQ. 2) THEN
! DO N = 1,ND2
! NU=ND1+2*(N-1)
! CALL TALK(JJJA,JJJB,NU,IS(1),IS(3),IS(2),IS(4),1,COND(1,N))
! CALL TALK(JJJA,JJJB,NU,IS(3),IS(1),IS(4),IS(2),1,COND(2,N))
! CALL TALK(JJJA,JJJB,NU,IS(1),IS(3),IS(4),IS(2),1,COND(3,N))
! CALL TALK(JJJA,JJJB,NU,IS(3),IS(1),IS(2),IS(4),1,COND(4,N))
! IF(N.EQ.ND2) CYCLE
! NUP1=NU+1
! CALL TALK(JJJA,JJJB,NUP1,IS(1),IS(3),IS(2),IS(4),2,COND(5,N))
! CALL TALK(JJJA,JJJB,NUP1,IS(2),IS(4),IS(1),IS(3),2,COND(6,N))
! CALL TALK(JJJA,JJJB,NUP1,IS(3),IS(1),IS(4),IS(2),2,COND(7,N))
! CALL TALK(JJJA,JJJB,NUP1,IS(4),IS(2),IS(3),IS(1),2,COND(8,N))
! CALL TALK(JJJA,JJJB,NUP1,IS(1),IS(3),IS(4),IS(2),2,COND(9,N))
! CALL TALK(JJJA,JJJB,NUP1,IS(4),IS(2),IS(1),IS(3),2,COND(10,N))
! CALL TALK(JJJA,JJJB,NUP1,IS(3),IS(1),IS(2),IS(4),2,COND(11,N))
! CALL TALK(JJJA,JJJB,NUP1,IS(2),IS(4),IS(3),IS(1),2,COND(12,N))
! END DO
! END IF
RETURN
10 WRITE(99,100)
100 FORMAT(5X,'ERRO IN EL41INT PMGG RAGG')
STOP
END SUBROUTINE EL41INT
| src/appl/rcsfinteract90/el41INT.f90 |
integer :: m = 12, clock,inirand,i,j,k,l,p,dimn,i1,ntm,mtc,q,r
integer counter,i2,nrow,tend,count,tspc,flag,indi,indj,sampsz
integer ii,jj
integer, parameter ::Totrun=10
integer, parameter ::burntim=0
double precision, parameter ::stepszu=1.0d0
integer N,NRHS,LDA,INFO,LDB,tag,marker,Montrun
integer, allocatable,dimension(:) :: iseed,IPIV
double precision x,chi1,chi2,time,sum1,sigma,ratio,chiint,prob,y
double precision pert,sumM,stepsz,sigmal,alpha
double precision, allocatable, dimension(:) ::Delta,thetasave
double precision, allocatable, dimension(:) ::mu2diff,Indic
double precision, allocatable, dimension(:) :: mutreal,mu0real
double precision, allocatable, dimension(:) :: mu1t,mu1diff,mu2t
double precision, allocatable, dimension(:,:) :: Jtreal,J0real,M1
double precision, allocatable, dimension(:,:) :: M2,J1diff,J2diff
integer, allocatable, dimension(:,:) :: M1ind,M2ind
integer, allocatable, dimension(:) :: Accpt,List
double precision, allocatable, dimension(:,:) :: J1,J2,A1,A2
double precision, allocatable, dimension(:,:) :: AVG
double precision, allocatable, dimension(:) :: chisave,EqCORR
double precision, allocatable, dimension(:,:) ::Areal,M1ini
double precision, dimension(10,Totrun) :: chiequli,stdchiequli
integer num_times
cc integer :: pos1 = 1
cc character (len=100) :: t_string
character(len=5),allocatable,dimension(:) :: t_i
integer :: t_i_int
cc call system("wc -m <time.txt > t_len")
cc call system("wc -l <time.txt > num_times")
cc open(unit=11,file='t_len',status='old')
cc read(11,*)t_len
cc close(11)
cc open(unit=11,file='num_times',status='old')
cc read(11,*)num_times
cc close(11)
num_times = 2
ALLOCATE(t_i(num_times))
cc ALLOCATE(t_string(t_len))
open(unit=11,file='time.txt',status='old',action='read')
cc read(unit=11,fmt='(A)')t_string
do j=1,num_times
read(11,*)t_i(j)
end do
close(11)
cc This segment of code below was taken from rosettacode.org. The section is "Tokenize a string", subsection "Fortran"
cc DO z = 1, num_times
cc pos2 = INDEX(t_string(pos1:), " ")
cc IF (pos2 == 0) THEN
cc t_i(z) = t_string(pos1:)
cc EXIT
cc END IF
cc t_i(z) = t_string(pos1:pos1+pos2-2)
cc pos1 = pos2+pos1
cc END DO
cc BEGIN SAYAK's CODE cc
call system("wc -l <avg_new.txt>
& inpl")
call system("awk 'NR==2{print NF}'
& avg_new.txt> inpc")
open(unit=11,file='inpc',status='old')
read(11,*)dimn
close(11)
open(unit=12,file='inpl',status='old')
read(12,*)nrow
close(12)
write(*,*)"row =",nrow
allocate(EqCORR((nrow)*(dimn)**2))
allocate(AVG(nrow,dimn))
open(unit=10,file='equaltime.txt',status='old')
do i=1,((nrow)*(dimn)**2)
read(10,*)EqCORR(i)
c write(*,*)'i =',i
c write(*,*)'EqCorr = ',EqCorr(i)
c call sleep(3)
enddo
close(10)
open(unit=11,file='avg.txt',
& status='old')
do i=1,(nrow)
read(11,*)(AVG(i,j),j=1,dimn)
enddo
close(11)
cc open(unit=12,file='tend.txt',status='old')
cc read(12,*)tend,tspc
cc write(*,*)"tend=",tend,"tspc=",tspc
cc close(12)
tend=1
tspc=1
c This is the part Sayak pointed out needs changing
read(t_i(tend),*) t_i_int1
read(t_i(tend+1),*) t_i_int2
time=t_i_int2-t_i_int1
cc if(tend.eq.1) then
cc time=24.0d0
cc else if(tend.eq.2) then
cc time = 32.0d0
cc else if(tend.eq.3) then
cc time = 64.0d0
cc else if(tend.eq.4) then
cc time = 128.0d0
cc endif
write(*,*)"time =",time
c ******* Initialize the random number generator ********
allocate(iseed(m))
call random_seed(size = m)
call system_clock(COUNT=clock)
iseed = clock + 37 * [(i1, i1 = 0,m-1)]
call random_seed(PUT = iseed)
c **************************************************************
c ************** Allocate arrays **************************
allocate(mutreal(dimn),mu0real(dimn),mu1t(dimn),mu1diff(dimn))
allocate(Jtreal(dimn,dimn),J0real(dimn,dimn),M1(dimn,dimn))
allocate(M2(dimn,dimn),A1(dimn,dimn),A2(dimn,dimn),J1(dimn,dimn))
allocate(J2(dimn,dimn),M1ind(dimn,dimn),M2ind(dimn,dimn))
allocate(J1diff(dimn,dimn),mu2diff(dimn),J2diff(dimn,dimn))
allocate(chisave(Totrun-burntim),mu2t(dimn))
allocate(Areal(dimn,dimn),Delta(dimn),IPIV(dimn))
allocate(M1ini(dimn,dimn),Accpt(Totrun))
allocate(Indic(Totrun))
c ******************************************************************
c ******* Initialize the arrays given from data *******************
mutreal=0.0d0
mu0real=0.0d0
Jtreal=0.0d0
J0real=0.0d0
IPIV=0
c ******************************************************************
c **************** Read initial data *******************************
p=(tend-1)*(dimn)**2+1
do i=1,dimn
mu0real(i)=AVG(tend,i)
mutreal(i)=AVG(tend+tspc,i)
do j=1,dimn
J0real(i,j)=EqCORR(p)
c write(*,*)'p =',p
c write(*,*)'J0real =',J0real(i,j)
Jtreal(i,j)=EqCORR(tspc*(dimn)**2+p)
c write(*,*)'dimn =',dimn
c write(*,*)'Jtreal =',Jtreal(i,j)
c call sleep(5)
p=p+1
enddo
enddo
c write(*,*)"Mmat of J0="
c do i=1,dimn
c write(*,'(1X,512F10.4)')(J0real(i,j),j=1,dimn)
c enddo
c
c write(*,*)"Mmat of Jt="
c do i=1,dimn
c write(*,'(1X,512F10.4)')(Jtreal(i,j),j=1,dimn)
c enddo
c write(*,*)" C0="
c write(*,'(1X,512F10.5)')(mu0real(j),j=1,dimn)
c write(*,*)"C1="
c write(*,'(1X,512F10.5)')(mutreal(j),j=1,dimn)
M1=0.0d0
write(*,*)"dimn=",dimn
open(unit=21,file='Minitial.txt',status='old')
do i=1,dimn
read(21,*)(M1(i,j),j=1,dimn)
enddo
close(21)
cc open(unit=15,file='prob.txt',status='old')
cc read(15,*)prob
cc close(15)
prob = 0.0d0
c open(unit=15,file='step.txt',status='old')
c read(15,*)stepsz
c close(15)
stepsz = 0.01d0
write(*,*)"stepsz= ",stepsz
do i=1,dimn
do j=1,dimn
if(i.ne.j) then
if(M1(i,j).lt.prob) then
M1(i,j)=0.0d0*x
endif
endif
enddo
enddo
do j=1,dimn
sum1=0.0d0
M1(j,j)=0.0d0
do i=1,dimn
sum1=sum1+M1(i,j)
enddo
M1(j,j)=-1.0*sum1
enddo
write(*,*)"Mmat of choice="
do i=1,dimn
write(*,'(1X,512F10.5)')(M1(i,j),j=1,dimn)
enddo
Allocate(List(dimn*dimn))
tag=0
List=0
marker=0
do i=1,dimn
do j=1,dimn
marker=marker+1
c if(i.ne.j) then
if(M1(i,j).ne.0.0) then
tag=tag+1
List(tag)=marker
endif
c endif
enddo
enddo
c Montrun=10000*tag !assigning Monte Carlo Steps
Montrun=1000000
c allocate(thetasave(Montrun))
c *******************************************************************
c ************** Initial distance calculation **********************************
chi1=0.0d0
A1=0.0d0
A1=expm(time,M1,dimn)
mu1t=0.0d0
mu1diff=0.0d0
J1=0.0d0
J1diff=0.0d0
do i=1,dimn
do j=1,dimn
c write(*,*)'A1 =',A1(i,j)
mu1t(i)=mu1t(i)+A1(i,j)*mu0real(j)
c write(*,*)'mu1t =',mu1t(i)
c call sleep(5)
enddo
mu1diff(i)=1.0d0-mu1t(i)/mutreal(i)
c write(*,*)'mu1diff =',mu1diff(i)
c call sleep(5)
enddo
do i=1,dimn
do j=i,dimn
count=count+1
do l=1,dimn
do p=1,dimn
J1(i,j)=J1(i,j)+A1(i,l)*J0real(l,p)*A1(j,p)
c write(*,*)'J1'
c write(*,*)J1(i,j)
enddo
enddo
c write(*,*)'Jtreal =',Jtreal(i,j)
c write(*,*)Jtreal(i,j)
c write(*,*)'J1diff'
J1diff(i,j)=1.0d0-J1(i,j)/Jtreal(i,j)
c write(*,*)'J1diff =',J1diff(i,j)
c call sleep(5)
enddo
enddo
do i=1,dimn
do j=i,dimn
chi1=chi1+J1diff(i,j)**2
c write(*,*)'part 1'
c write(*,*)chi1
enddo
chi1=chi1+mu1diff(i)**2
c write(*,*)'part2'
c write(*,*)chi1
enddo
sigma=10*chi1
write(*,*)"sigma=",sigma
write(*,*)"chi1 =",chi1
alpha=dexp((dlog(0.000001/sigma))/(1.0d0*Totrun))
write(*,*)"alpha= ",alpha
c call sleep(300)
c write(*,*)"tag=",tag
c open(unit=20,file='prob_new.txt',status='old')
c read(20,*)prob
c close(20)
c open(unit=21,file='pert.txt',status='old')
c read(21,*)pert
c close(21)
c ***********************************************************************************
c ********************* Temperature loop *********************************************
c HERE'S SOME THINGS I ALLOCATED IN A DEBUGGING ATTEMPT
c allocate(Indic(1))
allocate(thetasave(1))
c allocate(Accpt(1))
c allocate(chisave(1))
c allocate(
chisave=0.0d0
Accpt=0
chiequli=0.0d0
stdchiequli=0.0d0
Indic=0.0d0
c Beginning of temperture loop
do ntm=1,Totrun
c prog=ntm/Totrun
c write(prog_str,’(F3.1)’)prog
write(*,'(a)',advance='no')"Run "
write(*,'(i4)',advance='no')ntm
write(*,'(a)',advance='no')" out of "
write(*,'(i4)',advance='no')Totrun
thetasave=0.0d0
Indic(ntm)=sigma
if(MOD(ntm,1000)==0) then
write(*,*) ntm
endif
flag=0
sampsz=0
c Beginning of Monte Carlo loop
do mtc=1,Montrun
M2=0.0d0
call random_number(x)
if(MOD(List(int(1.0+1.0d0*(tag)*x)),dimn).eq.0) then
indi=int((1.0d0*List(int(1.0+1.0d0*(tag)*x)))/
& (dimn*1.0d0))
indj=dimn
else
indi= int((1.0d0*List(int(1.0+1.0d0*(tag)*x)))/
& (dimn*1.0d0))+1
indj= int(MOD(List(int(1.0+1.0d0*(tag)*x)),dimn))
endif
c write(*,*)"indi=",indi,"indj=",indj
M2=M1
call random_number(x)
if(indi.eq.indj) then
M2(indi,indj)=M1(indi,indj)+stepsz*(2.0d0*x-1.0d0)
else
c write(*,*)M1(indi,indj)+ stepsz*(2.0d0*x-1.0d0)
if(((M1(indi,indj)+ stepsz*(2.0d0*x-1.0d0)).lt.0.0)
& .OR.((M1(indi,indj)+ stepsz*(2.0d0*x-1.0d0)).gt.1.0))
& then
M2(indi,indj)=M1(indi,indj)
else
M2(indi,indj)=M1(indi,indj)+stepsz*(2.0d0*x-1.0d0))
endif
endif
c write(*,*)"Mmat of M2="
c do i=1,dimn
c write(*,'(1X,512F10.5)')(M2(i,j),j=1,dimn)
c enddo
chi2=0.0d0
A2=0.0d0
A2=expm(time,M2,dimn)
mu2t=0.0d0
mu2diff=0.0d0
J2=0.0d0
J2diff=0.0d0
do i=1,dimn
do j=1,dimn
mu2t(i)=mu2t(i)+A2(i,j)*mu0real(j)
enddo
mu2diff(i)=1.0d0-mu2t(i)/mutreal(i)
enddo
do i=1,dimn
do j=i,dimn
count=count+1
do l=1,dimn
do p=1,dimn
J2(i,j)=J2(i,j)+A2(i,l)*J0real(l,p)
& *A2(j,p)
enddo
enddo
J2diff(i,j)=1.0d0-J2(i,j)/Jtreal(i,j)
enddo
enddo
do i=1,dimn
cccTHIS IS THE SPOT YOU CHANGED TO REMOVE THE COVARIANCE FROM THE COST FUNCTION
do j=i,dimn
chi2=chi2+J2diff(i,j)**2
enddo
chi2=chi2+mu2diff(i)**2
enddo
do j=1,dimn
sumM=0.0d0
do i=1,dimn
sumM=sumM+M2(i,j)
enddo
chi2=chi2+(sumM**2)
enddo
c write(*,*)"chi2= ",chi2
ratio=dexp((-chi2+chi1)/(2.0d0*sigma))
call random_number(x)
c write(*,*)"ratio=",ratio,"x=",x,"chi2=",chi2
if(x.lt.ratio) then
c write(*,*) "yeah"
flag=flag+1
M1=M2
chi1=chi2
endif
if(mtc.gt.Montrun-100000) then
chiequli(int(sampsz/10000)+1,ntm)=
& chiequli(int(sampsz/10000)+1,ntm)+chi1
stdchiequli(int(sampsz/10000)+1,ntm)=
& stdchiequli(int(sampsz/10000)+1,ntm)+chi1**2
sampsz=sampsz+1
endif
c thetasave(mtc)=chi1
enddo !end of Monte Carlo run
sigma=alpha*sigma
Accpt(ntm)=flag
if(ntm.gt.burntim) then
c counter=0
c do i=1,dimn
c do j=1,dimn
c if(i.ne.j) then
c counter=counter+1
c thetasave(ntm-burntim,counter)=M1(i,j)
c endif
c enddo
c enddo
chisave(ntm-burntim)=chi1
endif
write(*,'(a)',advance='no')char(13)
enddo ! end of temperature loop
write(*,*)"sigma=",sigma
open(unit=41,status='unknown')
do i=1,dimn
write(41,'(1X,512F20.10)')(M1(i,j),j=1,dimn)
enddo
close(41)
i2=Totrun-burntim
open(unit=42,status='unknown')
do i=1,i2
c write(*,*)chisave(i)
write(42,'(1X,512F30.10)')chisave(i)
enddo
close(42)
open(unit=40,status='unknown')
do i=1,Totrun
write(40,'(1X,512I7)')Accpt(i)
enddo
close(40)
open(unit=49,status='unknown')
do i=1,10
write(49,'(1X,100000F30.10)')(chiequli(i,j)/10000.0d0,
& j=1,Totrun)
enddo
close(49)
open(unit=59,status='unknown')
do i=1,10
write(59,'(1X,100000F30.10)')(sqrt(stdchiequli(i,j)/10000.0d0
& -(chiequli(i,j)/10000.0d0)**2),j=1,Totrun)
enddo
close(59)
c open(unit=50,status='unknown')
c do i=1,Montrun
c write(50,'(1X,512F20.10)')thetasave(i)
c enddo
c close(50)
open(unit=51,status='unknown')
do i=1,Totrun
write(51,'(1X,512F30.15)')Indic(i)
enddo
close(51)
contains
function expm(t,H,N1) result(expH)
double precision, intent(in):: t
integer, intent(in)::N1
double precision, dimension(N1,N1), intent(in)::H
double precision, dimension(size(H,1),size(H,2)) :: expH
external :: DGPADM
integer, parameter :: ideg = 6
double precision, dimension(4*size(H,1)*size(H,2) + ideg + 1)
& :: wsp
integer, dimension(size(H,1)) :: iwsp
integer :: iexp, ns, iflag, n
if (size(H,1) /= size(H,2)) then
stop 'expm: matrix must be square'
end if
n = size(H,1)
call DGPADM(ideg, n, t, H, n, wsp, size(wsp,1), iwsp, iexp,
& ns,iflag)
expH = reshape(wsp(iexp:iexp+n*n-1), shape(expH))
end function expm
10 end
c----------------------------------------------------------------------|
subroutine DGPADM( ideg,m,t,H,ldh,wsp,lwsp,ipiv,iexph,ns,iflag )
implicit none
integer ideg, m, ldh, lwsp, iexph, ns, iflag, ipiv(m)
double precision t, H(ldh,m), wsp(lwsp)
c-----Purpose----------------------------------------------------------|
c
c Computes exp(t*H), the matrix exponential of a general matrix in
c full, using the irreducible rational Pade approximation to the
c exponential function exp(x) = r(x) = (+/-)( I + 2*(q(x)/p(x)) ),
c combined with scaling-and-squaring.
c
c-----Arguments--------------------------------------------------------|
c
c ideg : (input) the degre of the diagonal Pade to be used.
c a value of 6 is generally satisfactory.
c
c m : (input) order of H.
c
c H(ldh,m) : (input) argument matrix.
c
c t : (input) time-scale (can be < 0).
c
c wsp(lwsp) : (workspace/output) lwsp .ge. 4*m*m+ideg+1.
c
c ipiv(m) : (workspace)
c
c>>>> iexph : (output) number such that wsp(iexph) points to exp(tH)
c i.e., exp(tH) is located at wsp(iexph ... iexph+m*m-1)
c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
c NOTE: if the routine was called with wsp(iptr),
c then exp(tH) will start at wsp(iptr+iexph-1).
c
c ns : (output) number of scaling-squaring used.
c
c iflag : (output) exit flag.
c 0 - no problem
c <0 - problem
c
c----------------------------------------------------------------------|
c Roger B. Sidje ([email protected])
c EXPOKIT: Software Package for Computing Matrix Exponentials.
c ACM - Transactions On Mathematical Software, 24(1):130-156, 1998
c----------------------------------------------------------------------|
c
integer mm,i,j,k,ih2,ip,iq,iused,ifree,iodd,icoef,iput,iget
double precision hnorm,scale,scale2,cp,cq
intrinsic INT,ABS,DBLE,LOG,MAX
c--- check restrictions on input parameters ...
mm = m*m
iflag = 0
if ( ldh.lt.m ) iflag = -1
if ( lwsp.lt.4*mm+ideg+1 ) iflag = -2
if ( iflag.ne.0 ) stop 'bad sizes (in input of DGPADM)'
c
c--- initialise pointers ...
c
icoef = 1
ih2 = icoef + (ideg+1)
ip = ih2 + mm
iq = ip + mm
ifree = iq + mm
c
c--- scaling: seek ns such that ||t*H/2^ns|| < 1/2;
c and set scale = t/2^ns ...
c
do i = 1,m
wsp(i) = 0.0d0
enddo
do j = 1,m
do i = 1,m
wsp(i) = wsp(i) + ABS( H(i,j) )
enddo
enddo
hnorm = 0.0d0
do i = 1,m
hnorm = MAX( hnorm,wsp(i) )
enddo
hnorm = ABS( t*hnorm )
if ( hnorm.eq.0.0d0 ) stop 'Error - null H in input of DGPADM.'
ns = MAX( 0,INT(LOG(hnorm)/LOG(2.0d0))+2 )
scale = t / DBLE(2**ns)
scale2 = scale*scale
c
c--- compute Pade coefficients ...
c
i = ideg+1
j = 2*ideg+1
wsp(icoef) = 1.0d0
do k = 1,ideg
wsp(icoef+k) = (wsp(icoef+k-1)*DBLE( i-k ))/DBLE( k*(j-k) )
enddo
c
c--- H2 = scale2*H*H ...
c
call DGEMM( 'n','n',m,m,m,scale2,H,ldh,H,ldh,0.0d0,wsp(ih2),m )
c
c--- initialize p (numerator) and q (denominator) ...
c
cp = wsp(icoef+ideg-1)
cq = wsp(icoef+ideg)
do j = 1,m
do i = 1,m
wsp(ip + (j-1)*m + i-1) = 0.0d0
wsp(iq + (j-1)*m + i-1) = 0.0d0
enddo
wsp(ip + (j-1)*(m+1)) = cp
wsp(iq + (j-1)*(m+1)) = cq
enddo
c
c--- Apply Horner rule ...
c
iodd = 1
k = ideg - 1
100 continue
iused = iodd*iq + (1-iodd)*ip
call DGEMM( 'n','n',m,m,m, 1.0d0,wsp(iused),m,
. wsp(ih2),m, 0.0d0,wsp(ifree),m )
do j = 1,m
wsp(ifree+(j-1)*(m+1)) = wsp(ifree+(j-1)*(m+1))+wsp(icoef+k-1)
enddo
ip = (1-iodd)*ifree + iodd*ip
iq = iodd*ifree + (1-iodd)*iq
ifree = iused
iodd = 1-iodd
k = k-1
if ( k.gt.0 ) goto 100
c
c--- Obtain (+/-)(I + 2*(p\q)) ...
c
if ( iodd .eq. 1 ) then
call DGEMM( 'n','n',m,m,m, scale,wsp(iq),m,
. H,ldh, 0.0d0,wsp(ifree),m )
iq = ifree
else
call DGEMM( 'n','n',m,m,m, scale,wsp(ip),m,
. H,ldh, 0.0d0,wsp(ifree),m )
ip = ifree
endif
call DAXPY( mm, -1.0d0,wsp(ip),1, wsp(iq),1 )
call DGESV( m,m, wsp(iq),m, ipiv, wsp(ip),m, iflag )
if ( iflag.ne.0 ) stop 'Problem in DGESV (within DGPADM)'
call DSCAL( mm, 2.0d0, wsp(ip), 1 )
do j = 1,m
wsp(ip+(j-1)*(m+1)) = wsp(ip+(j-1)*(m+1)) + 1.0d0
enddo
iput = ip
if ( ns.eq.0 .and. iodd.eq.1 ) then
call DSCAL( mm, -1.0d0, wsp(ip), 1 )
goto 200
endif
c
c-- squaring : exp(t*H) = (exp(t*H))^(2^ns) ...
c
iodd = 1
do k = 1,ns
iget = iodd*ip + (1-iodd)*iq
iput = (1-iodd)*ip + iodd*iq
call DGEMM( 'n','n',m,m,m, 1.0d0,wsp(iget),m, wsp(iget),m,
. 0.0d0,wsp(iput),m )
iodd = 1-iodd
enddo
200 continue
iexph = iput
END
c----------------------------------------------------------------------|
| Monte_Carlo.f |
subroutine cgln_amps
implicit none
include 'mpintp.inc'
include 'spp.inc'
integer l
call multipole_amps
call legendre
if (method_helicity.eq.1) then
ff1 = 0.0
ff2 = 0.0
ff3 = 0.0
ff4 = 0.0
ff5 = 0.0
ff6 = 0.0
do l = 0, wave_L
if(l.lt.2) then
ff1 = ff1 + (l * mp(l) + ep(l)) * pol(l + 1, 1)
else
ff1 = ff1 + (l * mp(l) + ep(l)) * pol(l + 1, 1)&
+ ((l + 1) * mm(l) + em(l)) * pol(l - 1, 1)
endif
enddo
do l = 1, wave_L
ff2 = ff2 + ((l + 1) * mp(l) + l * mm(l)) * pol(l, 1)
if(l.lt.2) then
ff3 = ff3 + (ep(l) - mp(l)) * pol(l + 1, 2)
else
ff3 = ff3 + (ep(l) - mp(l)) * pol(l + 1, 2) + &
(em(l) + mm(l)) * pol(l - 1, 2)
endif
enddo
do l = 2, wave_L
ff4 = ff4 + (mp(l) - ep(l) - mm(l) - em(l)) * pol(l, 2)
enddo
do l = 0, wave_L
if(l.lt.2) then
ff5 = ff5 + (l + 1) * sp(l) * pol(l + 1, 1)
else
ff5 = ff5 + ((l + 1) * sp(l) * pol(l + 1, 1) - l * sm(l) * pol(l - 1, 1))
endif
enddo
do l = 1, wave_L
ff6 = ff6 + (l * sm(l) - (l + 1) * sp(l)) * pol(l, 1)
enddo
else
do l = 0, max_L + 1
ap(l) = 0.0
am(l) = 0.0
bp(l) = 0.0
bm(l) = 0.0
cp(l) = 0.0
cm(l) = 0.0
enddo
do l = 0, max_L
ap(l) = 0.5 * (l * mp(l) + (l + 2) * ep(l))
am(l + 1) = 0.5 * ((l + 2) * mm(l + 1) - l * em(l + 1))
bp(l) = ep(l) - mp(l)
bm(l + 1) = em(l + 1) + mm(l + 1)
cp(l) = (l + 1) * sp(l)
cm(l + 1) = -(l + 1) * sm(l + 1)
enddo
endif
return
end | src/cgln_amps.f90 |
!program reflectance
SUBROUTINE reflectance( &
nrow, ncol, &
rori, &
norm_1, norm_2, &
ref_adj, &
no_data, &
radiance, &
shadow_mask, &
solar_angle, &
sazi_angle, &
view_angle, &
rela_angle, &
slope_angle, &
aspect_angle, &
it_angle, &
et_angle, &
rela_slope, &
a_mod, &
b_mod, &
s_mod, &
fs, &
fv, &
ts, &
edir_h, &
edif_h, &
ref_lm, &
ref_brdf, &
ref_terrain, &
iref_lm, &
iref_brdf, &
iref_terrain, &
norm_solar_zenith)
! Calculates lambertian, brdf corrected and terrain corrected surface
! reflectance.
! input parameters
integer nrow, ncol ! we should be passing in transposed arrays cols = rows and vice versa
real*4 rori ! threshold for terrain correction
real*4 ref_adj ! average reflectance for terrain correction
real*4 no_data ! input & output no data value
real*4 radiance(nrow, ncol) ! at sensor radiance image
integer*1 shadow_mask(nrow, ncol) ! shadow mask
real*4 solar_angle(nrow, ncol) ! solar zenith angle
real*4 sazi_angle(nrow, ncol) ! solar azimuth angle
real*4 view_angle(nrow, ncol) ! view angle (for flat surface)
real*4 rela_angle(nrow, ncol) ! relative azimuth angle (for flat surface)
real*4 slope_angle(nrow, ncol) ! slope angle
real*4 aspect_angle(nrow, ncol) ! aspect angle
real*4 it_angle(nrow, ncol) ! incident angle (for inclined surface)
real*4 et_angle(nrow, ncol) ! exiting angle (for inclined surface)
real*4 rela_slope(nrow, ncol) ! relative angle (for inclined surface)
real*4 a_mod(nrow, ncol) ! modtran output (a)
real*4 b_mod(nrow, ncol) ! modtran output (b)
real*4 s_mod(nrow, ncol) ! modtran output (s)
real*4 fv(nrow, ncol) ! modtran output (fs)
real*4 fs(nrow, ncol) ! modtran output (fv)
real*4 ts(nrow, ncol) ! modtran output (ts)
real*4 edir_h(nrow, ncol) ! modtran output (direct irradiance)
real*4 edif_h(nrow, ncol) ! modtran output (diffuse irradiance)
integer*2 iref_lm(nrow, ncol) ! atmospheric corrected lambertial reflectance
integer*2 iref_brdf(nrow, ncol) ! atmospheric and brdf corrected reflectance
integer*2 iref_terrain(nrow, ncol) ! atmospheric and brdf and terrain corrected reflectance
real norm_solar_zenith ! solar zenith to normalize surface reflectance to
!internal parameters passed as arrays.
real*4 ref_lm(nrow)
real*4 ref_brdf(nrow)
real*4 ref_terrain(nrow)
!f2py depend(nrow), ref_lm, ref_brdf, ref_terrain
!f2py depend(nrow, ncol), radiance, shadow_mask
!f2py depend(nrow, ncol), solar_angle, sazi_angle, view_angle, rela_angle
!f2py depend(nrow, ncol), slope_angle,, aspect_angle, it_angle, et_angle
!f2py depend(nrow, ncol), rela_slope, a_mod, b_mod, s_mod, fv, fs, ts
!f2py depend(nrow, ncol), edir_h, edif_h
!f2py depend(nrow, ncol), iref_lm, iref_brdf, iref_terrain
!f2py intent(in) rori, norm_1, norm_2, ref_adj, no_data
!f2py intent(in) dn_1, shadow_mask, solar_angle,
!f2py intent(in) sazi_angle, view_angle, rela_angle, slope_angle, aspect_angle
!f2py intent(in) it_angle, et_angle, rela_slope, a_mod, b_mod, s_mod, fv, fs, ts, edir_h, edif_h
!f2py intent(in) ref_lm, ref_brdf, ref_terrain, dn
!f2py intent(inout) iref_lm, iref_brdf, iref_terrain
! internal parameters
integer i, j, i_no_data
real pi, pib
real ann_f, aa_viewf, aa_solarf, aa_white
real ann_s, aa_views, aa_solars
real lt, norm_1, norm_2
real solar, sazi, view, slope, aspect, ra_lm, ra_sl, it, et
double precision a_eqf, b_eqf, c_eqf, ref_barf, aa_flat
double precision a_eqs, b_eqs, c_eqs, ref_bars, aa_slope
double precision ref_brdfrealf, ref_brdfreals
double precision bb_angle, cc_angle, tttt
real hb, br, fnn, it_brdf, it_bk, et_brdf, et_bk
real angle_th
real vt, vd,angle, edir_t, eadj, edif_t, rdir, rdif, rtotal
real RL_brdf, black_sky, white_sky
real cosslope, rth
external RL_brdf, black_sky, white_sky
! li-sparse parameters
hb = 2.0
br = 1.0
pi = 4 * atan(1.0)
pib = pi / 180.0
! integer version of the no_data value
i_no_data = int(no_data)
! calculate white sky albedo
aa_white = white_sky(1.0, norm_1, norm_2)
! calcualte BRDF at 45 solar angle and 0 view angle
fnn = RL_brdf(norm_solar_zenith * pib, 0.0, 0.0, hb, br, 1.0, norm_1, norm_2)
! print*,fnn
! Now loop over the cols of the images
do j=1,ncol
!----------------------------------------------------------------------
! now loop over the rows of the images
do i=1,nrow
! radiance value for the pixel
lt = radiance(i, j)
! TODO: check radiance against a better null than 0
! TODO: some at sensor radiance values are < 0
! if valid masks and valid digital number then do the calcs
if (a_mod(i, j) .ge. 0 .and. lt .ne. no_data) then
if (rela_angle(i, j) .gt. 180) rela_angle(i, j) = rela_angle(i, j) - 360
if (rela_slope(i, j) .gt. 180) rela_slope(i, j) = rela_slope(i, j) - 360
! convert angle to radians
solar = solar_angle(i, j) * pib
sazi = sazi_angle(i, j) * pib
view = view_angle(i, j) * pib
slope = slope_angle(i, j) * pib
aspect = aspect_angle(i, j) * pib
ra_lm = rela_angle(i, j) * pib
ra_sl = rela_slope(i, j) * pib
it = it_angle(i, j) * pib
et = et_angle(i, j) * pib
if (it_angle(i, j) .ge. 70.0) then
it_brdf = 70.0 * pib
else
it_brdf = it_angle(i, j) * pib
endif
if (it_angle(i, j) .ge. 80.0) then
it_bk = 80.0 * pib
else
it_bk = it_angle(i, j) * pib
endif
if (et_angle(i, j) .ge. 60.0) then
et_brdf = 60.0 * pib
else
et_brdf = et_angle(i, j) * pib
endif
if (et_angle(i, j) .ge. 80.0) then
et_bk = 80.0 * pib
else
et_bk = et_angle(i, j) * pib
endif
!------------------------------------------------
! for flat surface
! calcualte lambetian reflectance with bilinear average
ref_lm(i) = (lt - b_mod(i, j)) / (a_mod(i, j) + s_mod(i, j) * &
(lt - b_mod(i, j)))
iref_lm(i, j) = ref_lm(i) * 10000 + 0.5
! this is to ensure that lambartian corrected reflectance to not
! exceed above limit of 1.0
if (ref_lm(i) .ge. 1) then
ref_lm(i) = 1.0
iref_lm(i, j) = ref_lm(i) * 10000
endif
! set as small number if atmospheric corrected reflectance
! below 0.0001
if (ref_lm(i).lt. 0.0001) then
ref_lm(i) = 0.0001
ref_brdf(i) = 0.0001
iref_lm(i, j) = 1
iref_brdf(i, j) = 1
else
! calculate normalized BRDF shape function
ann_f = RL_brdf(solar, view, ra_lm, hb, br, 1.0, norm_1, norm_2)
! calculate black sky albedo for sloar angle
aa_solarf = black_sky(1.0, norm_1, norm_2, solar)
! calculate black sky albedo for view angle
aa_viewf = black_sky(1.0, norm_1, norm_2, view)
!
aa_flat = (fv(i, j) * (fs(i, j) * ann_f + (1.0 - fs(i, j)) * &
aa_viewf) + (1.0 - fv(i, j)) * (fs(i, j) * &
aa_solarf + (1.0 - fs(i, j)) * aa_white)) / aa_white
a_eqf = (1 - aa_flat) * s_mod(i, j) * (1 - s_mod(i, j) * &
ref_lm(i))
b_eqf = aa_flat + ref_lm(i) * (1 - aa_flat) * s_mod(i, j)
c_eqf = -ref_lm(i)
if (abs(a_eqf) .lt. 0.0000001) then
ref_barf = -c_eqf / b_eqf
else
ref_barf = (-b_eqf + &
sqrt(b_eqf**2 - 4 * a_eqf * c_eqf)) / &
(2 * a_eqf)
endif
ref_brdfrealf = ann_f * ref_barf / aa_white
ref_brdf(i) = ref_barf * fnn / aa_white
iref_brdf(i, j) = ref_brdf(i) * 10000 + 0.5
! this is to ensure that the brdf correction
! is the same as (or as close as possible to) the original NBAR version
if (ref_brdf(i) .ge. 1) then
ref_brdf(i) = 1.0
iref_brdf(i, j) = ref_brdf(i) * 10000
endif
endif
!-------------------------------------------------------------------
! conduct terrain correction
if ((shadow_mask(i, j) .gt. 0) .and. &
(it_angle(i, j) .lt. 90.0) &
.and. (et_angle(i, j) .lt. 90.0)) then
!----------------------------------------------------------
cosslope = cos(slope)
! calculate vd and vt
vd = 0.5 * (1.0 + cosslope)
vt = 1.0 - vd
!---------------------------------------------------------
! calculate direct irradiance
! Note the account taken of threshold
edir_t = edir_h(i, j) * cos(it) / cos(solar)
! calculate adjacent irradiance for anisotropical surface
! see Iqbal, 1983 "an introduction to solar
! radiation"
eadj = (edir_h(i, j) + edif_h(i, j)) * vt * ref_adj * &
(1.0 + sin(solar / 2.0)**2) * abs(cos(aspect - sazi))
!---------------------------------------------------------------
! sky diffuse irradiation for anisotropical surface
! see Iqbal, 1983 "an introduction to solar
! radiation" Hay model
edif_t = edif_h(i, j) * (ts(i, j) * cos(it) / cos(solar) + &
vd * (1 - ts(i, j))) + eadj
rdir = edir_t / (edir_h(i, j) + edif_h(i, j))
rdif = edif_t / (edir_h(i, j) + edif_h(i, j))
rtotal = (edir_t + edif_t) / (edir_h(i, j) + edif_h(i, j))
rth = (rori - s_mod(i, j) * ref_lm(i)) / (1 - s_mod(i, j) * &
ref_lm(i))
if (rtotal .le. rth) then
bb_angle = fs(i, j) / cos(solar) + (1 - fs(i, j)) * &
ts(i, j) / cos(solar)
cc_angle = -rth + (1.0 - fs(i, j)) * vd * &
(1.0 - ts(i, j)) + &
eadj / (edir_h(i, j) + edif_h(i, j))
tttt = -cc_angle / bb_angle
if (tttt .gt. 1.0) tttt = 1.0
if (tttt .lt. -1.0) tttt = -1.0
angle_th = acos(tttt) * 180.0 / pi
angle = 90.0 - it_angle(i, j) + angle_th
edir_t = edir_h(i, j) * (cos(it) + cos(angle * pib)) / &
(cos(solar) +cos(angle * pib))
rdir = edir_t/(edir_h(i, j)+edif_h(i, j))
rtotal = (edir_t+edif_t)/(edir_h(i, j)+edif_h(i, j))
endif
!----------------------------------------------------------------
! calculate normalized BRDF shape function for sloping surface
ann_s = RL_brdf(it_brdf,et_brdf,ra_sl,hb,br,1.0,norm_1,norm_2)
!----------------------------------------------------------------
! calculate black sky albedo for sloar angle
aa_solars = black_sky(1.0,norm_1,norm_2,it_bk)
!--------------------------------------------------------------
! calculate black sky albedo for view angle
aa_views = black_sky(1.0,norm_1,norm_2,et_bk)
!-------------------------------------------------------------
aa_slope = &
(rdir * (fv(i, j) * ann_s + (1.0-fv(i, j)) * &
aa_solars) + rdif * (fv(i, j) * aa_views + &
(1.0-fv(i, j)) * aa_white)) / aa_white
a_eqs = (rtotal - aa_slope) * s_mod(i, j) * &
(1 - s_mod(i, j) * ref_lm(i))
b_eqs = aa_slope + ref_lm(i) * (1 - aa_slope) * s_mod(i, j)
c_eqs = -ref_lm(i)
if (abs(a_eqs) .lt. 0.00001) then
ref_bars = -c_eqs / b_eqs
else
ref_bars = (-b_eqs + sqrt(b_eqs**2 -4 * a_eqs * c_eqs)) / &
(2*a_eqs)
endif
ref_brdfreals = ann_s * ref_bars / aa_white
ref_terrain(i) = ref_bars * fnn / aa_white
iref_terrain(i, j) = int(ref_terrain(i) * 10000.0 + 0.5)
if (ref_terrain(i) .ge. 1) then
ref_terrain(i) = 1.0
iref_terrain(i, j) = int(ref_terrain(i) * 10000.0 + 0.5)
endif
! set terrain corrected reflectance less than 0.0001 to 0.0001
if (ref_terrain(i) .lt. 0.0001) then
ref_terrain(i) = 0.0001
iref_terrain(i, j) = 1
endif
! Should test for these cases in initial tests! (ie must be lt these)
! presently comments as test for ge 90 in initial one
!
if (it_angle(i, j) .ge. 85.0) then
iref_terrain(i, j) = i_no_data
endif
if (et_angle(i, j) .ge. 85.0) then
iref_terrain(i, j) = i_no_data
endif
! if in masked or otherwise unused area you get here
! put in no_data values to indicate null data
else
iref_terrain(i, j) = i_no_data
endif
else
ref_lm(i) = no_data
ref_brdf(i) = no_data
ref_terrain(i) = no_data
iref_lm(i, j) = i_no_data
iref_brdf(i, j) = i_no_data
iref_terrain(i, j) = i_no_data
endif
enddo
enddo
END SUBROUTINE reflectance
| wagl/f90_sources/surface_reflectance.f90 |
subroutine wraeb(a,b,alpha,xf,yf)
C...wraeb 01/06/75 01/01/80
common/gfbftr/xtr,ytr
a1=abs(a)
b1=abs(b)
delx0=xf-xtr
dely0=yf-ytr
alpha1=alpha*0.01745329
g=b1/a1
delx=delx0*cos(alpha1)+dely0*sin(alpha1)
dely=(-delx0*sin(alpha1)+dely0*cos(alpha1))/g
j=(1.-abs(b)/b)/2.
call arcang(a,delx,dely,j,th0,thf)
call areb1(th0,thf,g,th02,thf2)
call wraea(a,b1,alpha,th02,thf2)
return
end
| ftn/wraeb.f |
SUBROUTINE sor(a,b,c,d,e,f,u,jmax,rjac)
INTEGER jmax,MAXITS
DOUBLE PRECISION rjac,a(jmax,jmax),b(jmax,jmax),c(jmax,jmax),
*d(jmax,jmax),e(jmax,jmax),f(jmax,jmax),u(jmax,jmax),EPS
PARAMETER (MAXITS=1000,EPS=1.d-5)
INTEGER ipass,j,jsw,l,lsw,n
DOUBLE PRECISION anorm,anormf,omega,resid
anormf=0.d0
do 12 j=2,jmax-1
do 11 l=2,jmax-1
anormf=anormf+abs(f(j,l))
11 continue
12 continue
omega=1.d0
do 16 n=1,MAXITS
anorm=0.d0
jsw=1
do 15 ipass=1,2
lsw=jsw
do 14 j=2,jmax-1
do 13 l=lsw+1,jmax-1,2
resid=a(j,l)*u(j+1,l)+b(j,l)*u(j-1,l)+c(j,l)*u(j,l+1)+d(j,
*l)*u(j,l-1)+e(j,l)*u(j,l)-f(j,l)
anorm=anorm+abs(resid)
u(j,l)=u(j,l)-omega*resid/e(j,l)
13 continue
lsw=3-lsw
14 continue
jsw=3-jsw
if(n.eq.1.and.ipass.eq.1) then
omega=1.d0/(1.d0-.5d0*rjac**2)
else
omega=1.d0/(1.d0-.25d0*rjac**2*omega)
endif
15 continue
if(anorm.lt.EPS*anormf)return
16 continue
pause 'MAXITS exceeded in sor'
END
| NR-Functions/Numerical Recipes- Example & Functions/Functions/sor.for |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!
!! FP_ACCELERATOR -- Fixed Point Iteration Accelerator
!!
!! This module implements a Krylov subspace type algorithm that accelerates the
!! convergence of the standard fixed point iteration x_{n+1} = x_{n} - f(x_{n}),
!! for the nonlinear system f(x) = 0. A modified Newton iteration, for example,
!! gives rise to such an iteration.
!!
!! The accelerator must be initialized by calling
!!
!! fpa_init (f, maxv, vtol)
!!
!! f -- Function value vector; it is used ONLY to glean its shape
!! in order to allocate working storage.
!! maxv -- Maximum number of vectors used in the algorithm (>0).
!! vtol -- Tolerance for dropping vectors. Optional; defaults to 0.1.
!!
!! The accelerated correction is computed by
!!
!! fpa_correction (itr, f)
!!
!! itr -- Iteration count. Necessary initialization is done for ITR = 1,
!! but otherwise ITR is ignored.
!! f -- Vector containing f at the current iterate. It is overwritten
!! with the accelerated correction. Note that the unaccelerated
!! correction would be simply f itself.
!!
!! At the end of the iteration, fpa_finish may be called (no arguments)
!! to free the working storage used by the module (this is not required).
!! If it is called, then fpa_init will need to be called before calling
!! fpa_correction again.
!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!
!! Copyright (c) 1997 Neil N. Carlson
!!
!! This file is part of MFE1 which is released under the MIT license. See the
!! file LICENSE or visit http://opensource.org/licenses/MIT for details.
!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module fp_accelerator
use mfe_constants, only: wp
use mfe_types
implicit none
private
public :: fpa_init, fpa_correction, fpa_finish
real(kind=wp), save :: tol
integer, save :: mvec
type(NodeVar), dimension(:,:), allocatable, save :: v, w
real(kind=wp), dimension(:,:), allocatable, save :: h
integer, dimension(:), allocatable, save :: next, prev
contains
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!
!! FPA_INIT
!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine fpa_init (f, maxv, vtol)
type(NodeVar), dimension(:), intent(in) :: f
integer, intent(in) :: maxv
real(kind=wp), intent(in), optional :: vtol
integer :: n
mvec = maxv
n = mvec + 1
allocate (v(size(f),n), w(size(f),n))
allocate (h(n,n), next(n), prev(n))
if (present(vtol)) then
tol = vtol
else
tol = 0.1_wp
end if
end subroutine fpa_init
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!
!! FPA_FINISH
!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine fpa_finish ()
deallocate (v, w, h, next, prev)
end subroutine fpa_finish
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!
!! FPA_CORRECTION
!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine fpa_correction (itr, f)
integer, intent(in) :: itr
type(NodeVar), dimension(:), intent(inout) :: f
! local variables.
real(kind=wp) :: s, hkk, hkj, cj
real(kind=wp), dimension(mvec+1) :: c
integer :: i, j, k, new, nvec
integer, save :: free, first, last
if (itr == 1) then
!!!
!!! FIRST ITERATION
v(:,1) = f ! Save the (unaccelerated) correction.
w(:,1) = f ! Save f to compute the difference on the next call.
first = 1 ! Initialize the linked list.
last = 1
next(1) = 0
prev(1) = 0
free = 2 ! Initialize the free storage linked list.
do k = 2, mvec
next(k) = k + 1
end do
next(mvec+1) = 0
else
!!!
!!! NEXT DIFFERENCE W
w(:,first) = w(:,first) - f
s = 1.0_wp / Norm(w(:,first))
! Normalize w_1 and apply same factor to v_1.
v(:,first) = s * v(:,first)
w(:,first) = s * w(:,first)
k = next(first) ! Update H.
do
if (k == 0) then
exit
end if
h(first,k) = w(:,first) .Dot. w(:,k)
k = next(k)
end do
!!!
!!! CHOLESKI FACTORIZATION OF H
h(first,first) = 1.0_wp
k = next(first)
nvec = 1
do
if (k == 0) then
exit ! No more vectors.
end if
if (nvec == mvec) then ! Retain at most MVEC vectors:
next(last) = free ! truncate the list and
free = k ! update the free storage list.
last = prev(k)
next(last) = 0
exit
end if
hkk = 1.0_wp ! Single stage of Choleski factorization.
j = first
do
if (j == k) then
exit
end if
hkj = h(j,k)
i = first
do
if (i == j) then
exit
end if
hkj = hkj - h(k,i)*h(j,i)
i = next(i)
end do
hkj = hkj / h(j,j)
hkk = hkk - hkj**2
h(k,j) = hkj
j = next(j)
end do
if (hkk > tol**2) then
h(k,k) = sqrt(hkk)
nvec = nvec + 1
else ! The current w nearly lies in the span of the previous set.
next(prev(k)) = next(k) ! Drop the current vector,
if (next(k) == 0) then
last = prev(k)
else
prev(next(k)) = prev(k)
end if
next(k) = free ! update the free storage list,
free = k
k = prev(k) ! and back-up.
endif
k = next(k)
end do
!!!
!!! PROJECT F ONTO THE SPAN OF THE W VECTORS.
j = first
do ! Forward substitution.
if (j == 0) then
exit
end if
!cj = dot_product (f, w(:,:,j)) ! Ackk...
cj = f .Dot. w(:,j)
i = first
do
if (i == j) then
exit
end if
cj = cj - h(j,i)*c(i)
i = next(i)
end do
c(j) = cj / h(j,j)
j = next(j)
end do
j = last
do ! Backward substitution.
if (j == 0) then
exit
end if
cj = c(j)
i = last
do
if (i == j) then
exit
end if
cj = cj - h(i,j)*c(i)
i = prev(i)
end do
c(j) = cj / h(j,j)
j = prev(j)
end do
!!!
!!! ACCELERATED CORRECTION
new = free ! Find storage for the new vectors.
free = next(free)
w(:,new) = f ! Save f for next call.
k = first ! Compute the next correction,
do
f = f - c(k)*w(:,k) + c(k)*v(:,k)
k = next(k)
if (k == 0) then
exit
end if
end do
v(:,new) = f ! and save it for the next call.
prev(new) = 0 ! Prepend the vectors to the list.
next(new) = first
prev(first) = new
first = new
end if
end subroutine fpa_correction
end module fp_accelerator
| src/common/fpa.f90 |
C %W% %G%
subroutine redecs(bm,k,n)
C CDC extended core simulation routine
C Sets BM(I) <-- ECNN(K+I)
C for I = 1 to N if N < MAXECN
C
C Otherwise sets BM(J) <-- ECQ(K+1-MAXECN+J)
C for J = 1 to N
C ECQ is the overflow parking lot for ECNN
C -
include 'tspinc/params.inc'
include 'tspinc/space.inc'
parameter (MAXECQ = 200000) !DEM
common /ecqa/ ecq(MAXECQ)
dimension bm(*)
C -
if (n .eq. 0) then
else if (k .lt. MAXECN) then
C Retrieve from ECN if address <= MAXECN
navail = min0 (n, MAXECN-k)
do i = 1, navail
bm(i) = ecnn(k+i)
end do
C Retrieve overflow from ECQ if address > MAXECN
nreq = k+1-MAXECN
do i = navail+1, n
bm(i) = ecq(i+nreq)
end do
else
nreq = k+1-MAXECN
do i = 1, n
bm(i) = ecq(i+nreq)
end do
endif
return
end
| libtsp/redecs.f |
!#################################################################################################!
!BSD 3-Clause License
!
!Copyright (c) 2017, Ricardo Torres
!All rights reserved.
!
!Redistribution and use in source and binary forms, with or without
!modification, are permitted provided that the following conditions are met:
!
!* Redistributions of source code must retain the above copyright notice, this
! list of conditions and the following disclaimer.
!* Redistributions in binary form must reproduce the above copyright notice,
! this list of conditions and the following disclaimer in the documentation
! and/or other materials provided with the distribution.
!* Neither the name of the copyright holder nor the names of its
! contributors may be used to endorse or promote products derived from
! this software without specific prior written permission.
!
!THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
!AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
!IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
!DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
!FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
!DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
!SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
!CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
!OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
!OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!#################################################################################################!
module Strings_Func_mod
use Types_mod
implicit none
contains
!##################################################################################################################################!
!------------------------------------------------------------------------
! ...Functions to change case of letters...
!------------------------------------------------------------------------
elemental function To_upper(str)
character(*), intent(in) :: str
character(len=len(str)) :: To_upper
integer :: i
To_upper=str
do i = 1, len(str)
select case(str(i:i))
case("a":"z")
To_upper(i:i) = achar(iachar(str(i:i))-32)
end select
end do
end function To_upper
!------------------------------------------------------------------------
elemental function To_lower(str)
character(*), intent(in) :: str
character(len=len(str)) :: To_lower
integer :: i
To_lower=str
do i = 1, len(str)
select case(str(i:i))
case("A":"Z")
To_lower(i:i) = achar(iachar(str(i:i))+32)
end select
end do
end function To_lower
!##################################################################################################################################!
!------------------------------------------------------------------------
! ...function N_Lines: Count number of lines of input file...
!------------------------------------------------------------------------
integer(kind=I32) function N_Lines(filein)
character(len=*), intent(in) :: filein
integer(kind=I8) :: io, nunit
open (newunit=nunit,file=trim(filein),iostat=io)
N_Lines=-1
do while (io==0)
N_Lines = N_Lines + 1
read(nunit,*,iostat=io)
end do
close(nunit)
end function N_Lines
!##################################################################################################################################!
!------------------------------------------------------------------------
! ...subroutine reportLog: Print a message to display...
!------------------------------------------------------------------------
subroutine ReportLog(logmessage)
character(len=*), intent(in) :: logmessage
write(*,*)trim(logmessage)
end subroutine ReportLog
!##################################################################################################################################!
!------------------------------------------------------------------------
! ...subroutine Decomp_Names: decompose the filenamein array in fields...
!------------------------------------------------------------------------
pure subroutine Decomp_Names(filenamein,field_names)
character(len=*), intent(out) :: field_names(:) !string containing the names of the filenamein
character(len=*), intent(in) :: filenamein !input string to be decomposed
integer(kind=I16) :: reset !position of first slash (/)
integer(kind=I16), allocatable :: position_under(:) !positions of the found underscores
integer(kind=I16) :: name_len, name_spaces
integer(kind=I16) :: i
!-----------------------------------------------------------------------------------------------
name_spaces=size(field_names)
allocate(position_under(name_spaces))
reset=scan(trim(filenamein), '/',back=.true.) !To find the last slash
name_len=len(trim(filenamein))
position_under(1) = scan(trim(filenamein(reset+1:name_len)), '_')
position_under(1) = reset + position_under(1)
if( name_spaces > 2 ) then
do i=2,name_spaces-1
position_under(i) = scan(trim(filenamein(sum(position_under(1:i-1))+1:name_len)), '_')
end do
end if
position_under(name_spaces) = scan(trim(filenamein(sum(position_under(1:name_spaces-1))+1:name_len)), '.')
if (position_under(name_spaces) == 0) then
position_under(name_spaces) = len_trim(filenamein) - position_under(name_spaces-1)
end if
field_names(1)=filenamein(reset+1:position_under(1)-1)
if( name_spaces > 1 ) then
do i=2,name_spaces
field_names(i)=filenamein(sum(position_under(1:i-1))+1:sum(position_under(1:i))-1)
end do
end if
deallocate(position_under)
end subroutine Decomp_Names
!##################################################################################################################################!
end module Strings_Func_mod
| src/Strings_Func_mod.f90 |
! -----------------------------------------------------------------------------
! This file was automatically created by SARAH version 4.12.2
! SARAH References: arXiv:0806.0538, 0909.2863, 1002.0840, 1207.0906, 1309.7223
! (c) Florian Staub, 2013
! ------------------------------------------------------------------------------
! File created at 18:24 on 2.10.2017
! ----------------------------------------------------------------------
Module Su3Decays_seesaw1nmssm
Use Control
Use Settings
Use CouplingsForDecays_seesaw1nmssm
Use ThreeBodyPhaseSpaceS
Contains
Subroutine SuThreeBodyDecay(n_in,MAh,MAh2,MCha,MCha2,MChi,MChi2,MFd,MFd2, &
& MFe,MFe2,MFu,MFu2,MFv,MFv2,MGlu,MGlu2,Mhh,Mhh2,MHpm,MHpm2,MSd,MSd2,MSe,MSe2, &
& MSu,MSu2,MSvIm,MSvIm2,MSvRe,MSvRe2,MVWm,MVWm2,MVZ,MVZ2,pG,TW,UM,UP,UV,v, &
& ZA,ZD,ZDL,ZDR,ZE,ZEL,ZER,ZH,ZN,ZP,ZU,ZUL,ZUR,ZVI,ZVR,ZW,ZZ,betaH,g1,g2,g3, &
& Yd,Ye,lam,kap,lamN,Yu,Yv,Td,Te,Tlam,Tk,TLN,Tu,Tv,mq2,ml2,mHd2,mHu2,md2,mu2, &
& me2,mv2,ms2,M1,M2,M3,vd,vu,vS,gSuAhChiFu,gSuAhFdcCha,gSuAhFuGlu,gSuSuChiChi, &
& gSucHpmChiFd,gSuhhChiFu,gSuChiGluSu,gSuSdChicCha,gSuFdFucSd,gSuFdFvcSe,gSuhhFdcCha, &
& gSuSuFdcFd,gSuFdSvImcFe,gSuFdSvRecFe,gSucHpmChaFu,gSuFuFecSe,gSuFuFucSu, &
& gSuFuFvSvIm,gSuFuFvSvRe,gSucChaFuHpm,gSuSdFucFd,gSuFuSecFe,gSuSuFucFu,gSucHpmFdGlu, &
& gSuhhFuGlu,gSuGluGluSu,gSuGluSdcCha,gSuSdFvcFe,gSuSuChacCha,gSuSuFecFe,gSuSuFvFv, &
& epsI,deltaM,CheckRealStates,gT,gPartial,BR)
Implicit None
Real(dp),Intent(in) :: MAh(3),MAh2(3),MCha(2),MCha2(2),MChi(5),MChi2(5),MFd(3),MFd2(3),MFe(3), &
& MFe2(3),MFu(3),MFu2(3),MFv(6),MFv2(6),MGlu,MGlu2,Mhh(3),Mhh2(3),MHpm(2), &
& MHpm2(2),MSd(6),MSd2(6),MSe(6),MSe2(6),MSu(6),MSu2(6),MSvIm(6),MSvIm2(6), &
& MSvRe(6),MSvRe2(6),MVWm,MVWm2,MVZ,MVZ2,TW,v,ZA(3,3),ZH(3,3),ZP(2,2),ZZ(2,2),betaH
Complex(dp),Intent(in) :: pG,UM(2,2),UP(2,2),UV(6,6),ZD(6,6),ZDL(3,3),ZDR(3,3),ZE(6,6),ZEL(3,3),ZER(3,3), &
& ZN(5,5),ZU(6,6),ZUL(3,3),ZUR(3,3),ZVI(6,6),ZVR(6,6),ZW(2,2)
Complex(dp) :: cplAhSucSu(3,6,6),cplcChacFuSdL(2,3,6),cplcChacFuSdR(2,3,6),cplcChaChaAhL(2,2,3), &
& cplcChaChaAhR(2,2,3),cplcChaChahhL(2,2,3),cplcChaChahhR(2,2,3),cplcChaChaVZL(2,2), &
& cplcChaChaVZR(2,2),cplcChaChiHpmL(2,5,2),cplcChaChiHpmR(2,5,2),cplcChaChiVWmL(2,5), &
& cplcChaChiVWmR(2,5),cplcChaFdcSuL(2,3,6),cplcChaFdcSuR(2,3,6),cplcFdChaSuL(3,2,6), &
& cplcFdChaSuR(3,2,6),cplcFdChiSdL(3,5,6),cplcFdChiSdR(3,5,6),cplcFdFdAhL(3,3,3), &
& cplcFdFdAhR(3,3,3),cplcFdFdhhL(3,3,3),cplcFdFdhhR(3,3,3),cplcFdFdVZL(3,3), &
& cplcFdFdVZR(3,3),cplcFdFuHpmL(3,3,2),cplcFdFuHpmR(3,3,2),cplcFdFuVWmL(3,3), &
& cplcFdFuVWmR(3,3),cplcFdGluSdL(3,6),cplcFdGluSdR(3,6),cplcFeChaSvImL(3,2,6), &
& cplcFeChaSvImR(3,2,6),cplcFeChaSvReL(3,2,6),cplcFeChaSvReR(3,2,6),cplcFeChiSeL(3,5,6), &
& cplcFeChiSeR(3,5,6),cplcFeFeAhL(3,3,3),cplcFeFeAhR(3,3,3),cplcFeFehhL(3,3,3), &
& cplcFeFehhR(3,3,3),cplcFeFeVZL(3,3),cplcFeFeVZR(3,3),cplcFeFvHpmL(3,6,2), &
& cplcFeFvHpmR(3,6,2),cplcFeFvVWmL(3,6),cplcFeFvVWmR(3,6),cplcFuChiSuL(3,5,6), &
& cplcFuChiSuR(3,5,6),cplcFuFdcHpmL(3,3,2),cplcFuFdcHpmR(3,3,2),cplcFuFuAhL(3,3,3), &
& cplcFuFuAhR(3,3,3),cplcFuFuhhL(3,3,3),cplcFuFuhhR(3,3,3),cplcFuFuVZL(3,3), &
& cplcFuFuVZR(3,3),cplcFuGluSuL(3,6),cplcFuGluSuR(3,6),cplChaFucSdL(2,3,6), &
& cplChaFucSdR(2,3,6),cplChiChacHpmL(5,2,2),cplChiChacHpmR(5,2,2),cplChiChiAhL(5,5,3), &
& cplChiChiAhR(5,5,3),cplChiChihhL(5,5,3),cplChiChihhR(5,5,3),cplChiChiVZL(5,5), &
& cplChiChiVZR(5,5),cplChiFdcSdL(5,3,6),cplChiFdcSdR(5,3,6),cplChiFecSeL(5,3,6), &
& cplChiFecSeR(5,3,6),cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6),cplChiFvSvImL(5,6,6), &
& cplChiFvSvImR(5,6,6),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6),cplFvChacSeL(6,2,6), &
& cplFvChacSeR(6,2,6),cplFvFvAhL(6,6,3),cplFvFvAhR(6,6,3),cplFvFvhhL(6,6,3), &
& cplFvFvhhR(6,6,3),cplFvFvVZL(6,6),cplFvFvVZR(6,6),cplGluFdcSdL(3,6),cplGluFdcSdR(3,6), &
& cplGluFucSuL(3,6),cplGluFucSuR(3,6),cplhhSucSu(3,6,6),cplSdcHpmcSu(6,2,6), &
& cplSdcSucVWm(6,6),cplSucSuVZ(6,6)
Real(dp),Intent(in) :: g1,g2,g3,mHd2,mHu2,ms2,vd,vu,vS
Complex(dp),Intent(in) :: Yd(3,3),Ye(3,3),lam,kap,lamN(3,3),Yu(3,3),Yv(3,3),Td(3,3),Te(3,3),Tlam, &
& Tk,TLN(3,3),Tu(3,3),Tv(3,3),mq2(3,3),ml2(3,3),md2(3,3),mu2(3,3),me2(3,3), &
& mv2(3,3),M1,M2,M3
Real(dp),Intent(inout) :: gSuAhChiFu(6,3,5,3),gSuAhFdcCha(6,3,3,2),gSuAhFuGlu(6,3,3,1),gSuSuChiChi(6,6,5,5), &
& gSucHpmChiFd(6,2,5,3),gSuhhChiFu(6,3,5,3),gSuChiGluSu(6,5,1,6),gSuSdChicCha(6,6,5,2), &
& gSuFdFucSd(6,3,3,6),gSuFdFvcSe(6,3,6,6),gSuhhFdcCha(6,3,3,2),gSuSuFdcFd(6,6,3,3), &
& gSuFdSvImcFe(6,3,6,3),gSuFdSvRecFe(6,3,6,3),gSucHpmChaFu(6,2,2,3),gSuFuFecSe(6,3,3,6), &
& gSuFuFucSu(6,3,3,6),gSuFuFvSvIm(6,3,6,6),gSuFuFvSvRe(6,3,6,6),gSucChaFuHpm(6,2,3,2), &
& gSuSdFucFd(6,6,3,3),gSuFuSecFe(6,3,6,3),gSuSuFucFu(6,6,3,3),gSucHpmFdGlu(6,2,3,1), &
& gSuhhFuGlu(6,3,3,1),gSuGluGluSu(6,1,1,6),gSuGluSdcCha(6,1,6,2),gSuSdFvcFe(6,6,6,3), &
& gSuSuChacCha(6,6,2,2),gSuSuFecFe(6,6,3,3),gSuSuFvFv(6,6,6,6)
Real(dp) :: gSuAhChiFui(3,5,3),gSuAhFdcChai(3,3,2),gSuAhFuGlui(3,3,1),gSuSuChiChii(6,5,5), &
& gSucHpmChiFdi(2,5,3),gSuhhChiFui(3,5,3),gSuChiGluSui(5,1,6),gSuSdChicChai(6,5,2), &
& gSuFdFucSdi(3,3,6),gSuFdFvcSei(3,6,6),gSuhhFdcChai(3,3,2),gSuSuFdcFdi(6,3,3), &
& gSuFdSvImcFei(3,6,3),gSuFdSvRecFei(3,6,3),gSucHpmChaFui(2,2,3),gSuFuFecSei(3,3,6), &
& gSuFuFucSui(3,3,6),gSuFuFvSvImi(3,6,6),gSuFuFvSvRei(3,6,6),gSucChaFuHpmi(2,3,2), &
& gSuSdFucFdi(6,3,3),gSuFuSecFei(3,6,3),gSuSuFucFui(6,3,3),gSucHpmFdGlui(2,3,1), &
& gSuhhFuGlui(3,3,1),gSuGluGluSui(1,1,6),gSuGluSdcChai(1,6,2),gSuSdFvcFei(6,6,3), &
& gSuSuChacChai(6,2,2),gSuSuFecFei(6,3,3),gSuSuFvFvi(6,6,6)
Real(dp), Intent(inout), Optional :: BR(:,:), gPartial(:,:)
Real(dp), Intent(inout) :: gT(:)
Integer, Intent(in) :: n_in
Real(dp), Intent(in) :: epsI, deltaM
Logical, Intent(in) :: CheckRealStates
Integer :: i_start, i_end, i_run, n_out, n_length, gt1, gt2, gt3, i1
Logical :: check
Iname = Iname +1
NameOfUnit(Iname) = 'SuThreeBodyDecay'
If (CheckRealStates) Then
Else
End If
check=CheckRealStates
If (n_in.Lt.0) Then
i_start = 1
i_end = 6
Else If ( (n_in.Ge.1).And.(n_in.Le. 6) ) Then
i_start = n_in
i_end = n_in
Else
If (ErrorLevel.Ge.-1) Then
Write (ErrCan, *) 'Problem in subroutine'//NameOfUnit(Iname)
Write (ErrCan, *) 'Value of n_in out of range, (n_in,6) = ',n_in,6
End If
If (ErrorLevel.Gt.0) Call TerminateProgram
If (Present(BR)) BR = 0._dp
Iname = Iname - 1
Return
End If
Do i_run = i_start, i_end
Call CouplingsFor_Su_decays_3B(MSu(i_run),i_run,MAh,MAh2,MCha,MCha2,MChi, &
& MChi2,MFd,MFd2,MFe,MFe2,MFu,MFu2,MFv,MFv2,MGlu,MGlu2,Mhh,Mhh2,MHpm,MHpm2, &
& MSd,MSd2,MSe,MSe2,MSu,MSu2,MSvIm,MSvIm2,MSvRe,MSvRe2,MVWm,MVWm2,MVZ,MVZ2, &
& pG,TW,UM,UP,UV,v,ZA,ZD,ZDL,ZDR,ZE,ZEL,ZER,ZH,ZN,ZP,ZU,ZUL,ZUR,ZVI,ZVR,ZW, &
& ZZ,betaH,g1,g2,g3,Yd,Ye,lam,kap,lamN,Yu,Yv,Td,Te,Tlam,Tk,TLN,Tu,Tv,mq2,ml2, &
& mHd2,mHu2,md2,mu2,me2,mv2,ms2,M1,M2,M3,vd,vu,vS,cplAhSucSu,cplcChacFuSdL, &
& cplcChacFuSdR,cplcChaChaAhL,cplcChaChaAhR,cplcChaChahhL,cplcChaChahhR,cplcChaChaVZL, &
& cplcChaChaVZR,cplcChaChiHpmL,cplcChaChiHpmR,cplcChaChiVWmL,cplcChaChiVWmR, &
& cplcChaFdcSuL,cplcChaFdcSuR,cplcFdChaSuL,cplcFdChaSuR,cplcFdChiSdL,cplcFdChiSdR, &
& cplcFdFdAhL,cplcFdFdAhR,cplcFdFdhhL,cplcFdFdhhR,cplcFdFdVZL,cplcFdFdVZR, &
& cplcFdFuHpmL,cplcFdFuHpmR,cplcFdFuVWmL,cplcFdFuVWmR,cplcFdGluSdL,cplcFdGluSdR, &
& cplcFeChaSvImL,cplcFeChaSvImR,cplcFeChaSvReL,cplcFeChaSvReR,cplcFeChiSeL, &
& cplcFeChiSeR,cplcFeFeAhL,cplcFeFeAhR,cplcFeFehhL,cplcFeFehhR,cplcFeFeVZL, &
& cplcFeFeVZR,cplcFeFvHpmL,cplcFeFvHpmR,cplcFeFvVWmL,cplcFeFvVWmR,cplcFuChiSuL, &
& cplcFuChiSuR,cplcFuFdcHpmL,cplcFuFdcHpmR,cplcFuFuAhL,cplcFuFuAhR,cplcFuFuhhL, &
& cplcFuFuhhR,cplcFuFuVZL,cplcFuFuVZR,cplcFuGluSuL,cplcFuGluSuR,cplChaFucSdL, &
& cplChaFucSdR,cplChiChacHpmL,cplChiChacHpmR,cplChiChiAhL,cplChiChiAhR,cplChiChihhL, &
& cplChiChihhR,cplChiChiVZL,cplChiChiVZR,cplChiFdcSdL,cplChiFdcSdR,cplChiFecSeL, &
& cplChiFecSeR,cplChiFucSuL,cplChiFucSuR,cplChiFvSvImL,cplChiFvSvImR,cplChiFvSvReL, &
& cplChiFvSvReR,cplFvChacSeL,cplFvChacSeR,cplFvFvAhL,cplFvFvAhR,cplFvFvhhL, &
& cplFvFvhhR,cplFvFvVZL,cplFvFvVZR,cplGluFdcSdL,cplGluFdcSdR,cplGluFucSuL, &
& cplGluFucSuR,cplhhSucSu,cplSdcHpmcSu,cplSdcSucVWm,cplSucSuVZ,deltaM)
gSuAhChiFui = 0._dp
Call SuToAhChiFu(i_run,MAh,MChi,MFu,MSu,cplAhSucSu,cplcFuFuAhL,cplcFuFuAhR, &
& cplChiChiAhL,cplChiChiAhR,cplChiFucSuL,cplChiFucSuR,deltaM,epsI,check,gSuAhChiFui)
gSuAhChiFu(i_run,:,:,:) = gSuAhChiFui
gT(i_run) = gT(i_run) + Sum(gSuAhChiFui)
gSuAhFdcChai = 0._dp
Call SuToAhFdcCha(i_run,MAh,MFd,MCha,MSu,cplAhSucSu,cplcChaChaAhL,cplcChaChaAhR, &
& cplcChaFdcSuL,cplcChaFdcSuR,cplcFdFdAhL,cplcFdFdAhR,deltaM,epsI,check,gSuAhFdcChai)
gSuAhFdcCha(i_run,:,:,:) = gSuAhFdcChai
gT(i_run) = gT(i_run) + Sum(gSuAhFdcChai)
gSuAhFuGlui = 0._dp
Call SuToAhFuGlu(i_run,MAh,MFu,MGlu,MSu,cplAhSucSu,cplcFuFuAhL,cplcFuFuAhR, &
& cplGluFucSuL,cplGluFucSuR,deltaM,epsI,check,gSuAhFuGlui)
gSuAhFuGlu(i_run,:,:,:) = gSuAhFuGlui
gT(i_run) = gT(i_run) + Sum(gSuAhFuGlui)
gSuSuChiChii = 0._dp
Call SuToSuChiChi(i_run,MSu,MChi,MVZ,MAh,Mhh,MFu,cplAhSucSu,cplhhSucSu, &
& cplSucSuVZ,cplcFuChiSuL,cplcFuChiSuR,cplChiChiAhL,cplChiChiAhR,cplChiChihhL, &
& cplChiChihhR,cplChiChiVZL,cplChiChiVZR,cplChiFucSuL,cplChiFucSuR,deltaM, &
& epsI,check,gSuSuChiChii)
gSuSuChiChi(i_run,:,:,:) = gSuSuChiChii
gT(i_run) = gT(i_run) + Sum(gSuSuChiChii)
gSucHpmChiFdi = 0._dp
Call SuTocHpmChiFd(i_run,MHpm,MChi,MFd,MSd,MFu,MCha,MSu,cplSdcHpmcSu,cplcChaFdcSuL, &
& cplcChaFdcSuR,cplcFuFdcHpmL,cplcFuFdcHpmR,cplChiChacHpmL,cplChiChacHpmR, &
& cplChiFdcSdL,cplChiFdcSdR,cplChiFucSuL,cplChiFucSuR,deltaM,epsI,check,gSucHpmChiFdi)
gSucHpmChiFd(i_run,:,:,:) = gSucHpmChiFdi
gT(i_run) = gT(i_run) + Sum(gSucHpmChiFdi)
gSuhhChiFui = 0._dp
Call SuTohhChiFu(i_run,Mhh,MChi,MFu,MSu,cplhhSucSu,cplcFuFuhhL,cplcFuFuhhR, &
& cplChiChihhL,cplChiChihhR,cplChiFucSuL,cplChiFucSuR,deltaM,epsI,check,gSuhhChiFui)
gSuhhChiFu(i_run,:,:,:) = gSuhhChiFui
gT(i_run) = gT(i_run) + Sum(gSuhhChiFui)
gSuChiGluSui = 0._dp
Call SuToChiGluSu(i_run,MChi,MGlu,MSu,MFu,cplcFuChiSuL,cplcFuChiSuR,cplcFuGluSuL, &
& cplcFuGluSuR,cplChiFucSuL,cplChiFucSuR,cplGluFucSuL,cplGluFucSuR,deltaM, &
& epsI,check,gSuChiGluSui)
gSuChiGluSu(i_run,:,:,:) = gSuChiGluSui
gT(i_run) = gT(i_run) + Sum(gSuChiGluSui)
gSuSdChicChai = 0._dp
Call SuToSdChicCha(i_run,MSd,MChi,MCha,MVWm,MHpm,MFu,MFd,MSu,cplSdcHpmcSu, &
& cplSdcSucVWm,cplcChacFuSdL,cplcChacFuSdR,cplcChaChiHpmL,cplcChaChiHpmR,cplcChaChiVWmL, &
& cplcChaChiVWmR,cplcChaFdcSuL,cplcChaFdcSuR,cplcFdChiSdL,cplcFdChiSdR,cplChiFucSuL, &
& cplChiFucSuR,deltaM,epsI,check,gSuSdChicChai)
gSuSdChicCha(i_run,:,:,:) = gSuSdChicChai
gT(i_run) = gT(i_run) + Sum(gSuSdChicChai)
gSuFdFucSdi = 0._dp
Call SuToFdFucSd(i_run,MFd,MFu,MSd,MCha,MChi,MGlu,MSu,cplcChaFdcSuL,cplcChaFdcSuR, &
& cplChaFucSdL,cplChaFucSdR,cplChiFdcSdL,cplChiFdcSdR,cplChiFucSuL,cplChiFucSuR, &
& cplGluFdcSdL,cplGluFdcSdR,cplGluFucSuL,cplGluFucSuR,deltaM,epsI,check,gSuFdFucSdi)
gSuFdFucSd(i_run,:,:,:) = gSuFdFucSdi
gT(i_run) = gT(i_run) + Sum(gSuFdFucSdi)
gSuFdFvcSei = 0._dp
Call SuToFdFvcSe(i_run,MFd,MFv,MSe,MCha,MSu,cplcChaFdcSuL,cplcChaFdcSuR, &
& cplFvChacSeL,cplFvChacSeR,deltaM,epsI,check,gSuFdFvcSei)
gSuFdFvcSe(i_run,:,:,:) = gSuFdFvcSei
gT(i_run) = gT(i_run) + Sum(gSuFdFvcSei)
gSuhhFdcChai = 0._dp
Call SuTohhFdcCha(i_run,Mhh,MFd,MCha,MSu,cplhhSucSu,cplcChaChahhL,cplcChaChahhR, &
& cplcChaFdcSuL,cplcChaFdcSuR,cplcFdFdhhL,cplcFdFdhhR,deltaM,epsI,check,gSuhhFdcChai)
gSuhhFdcCha(i_run,:,:,:) = gSuhhFdcChai
gT(i_run) = gT(i_run) + Sum(gSuhhFdcChai)
gSuSuFdcFdi = 0._dp
Call SuToSuFdcFd(i_run,MSu,MFd,MVZ,MAh,Mhh,MCha,cplAhSucSu,cplhhSucSu,cplSucSuVZ, &
& cplcChaFdcSuL,cplcChaFdcSuR,cplcFdChaSuL,cplcFdChaSuR,cplcFdFdAhL,cplcFdFdAhR, &
& cplcFdFdhhL,cplcFdFdhhR,cplcFdFdVZL,cplcFdFdVZR,deltaM,epsI,check,gSuSuFdcFdi)
gSuSuFdcFd(i_run,:,:,:) = gSuSuFdcFdi
gT(i_run) = gT(i_run) + Sum(gSuSuFdcFdi)
gSuFdSvImcFei = 0._dp
Call SuToFdSvImcFe(i_run,MFd,MSvIm,MFe,MCha,MSu,cplcChaFdcSuL,cplcChaFdcSuR, &
& cplcFeChaSvImL,cplcFeChaSvImR,deltaM,epsI,check,gSuFdSvImcFei)
gSuFdSvImcFe(i_run,:,:,:) = gSuFdSvImcFei
gT(i_run) = gT(i_run) + Sum(gSuFdSvImcFei)
gSuFdSvRecFei = 0._dp
Call SuToFdSvRecFe(i_run,MFd,MSvRe,MFe,MCha,MSu,cplcChaFdcSuL,cplcChaFdcSuR, &
& cplcFeChaSvReL,cplcFeChaSvReR,deltaM,epsI,check,gSuFdSvRecFei)
gSuFdSvRecFe(i_run,:,:,:) = gSuFdSvRecFei
gT(i_run) = gT(i_run) + Sum(gSuFdSvRecFei)
gSucHpmChaFui = 0._dp
Call SuTocHpmChaFu(i_run,MHpm,MCha,MFu,MSd,MChi,MSu,cplSdcHpmcSu,cplChaFucSdL, &
& cplChaFucSdR,cplChiChacHpmL,cplChiChacHpmR,cplChiFucSuL,cplChiFucSuR,deltaM, &
& epsI,check,gSucHpmChaFui)
gSucHpmChaFu(i_run,:,:,:) = gSucHpmChaFui
gT(i_run) = gT(i_run) + Sum(gSucHpmChaFui)
gSuFuFecSei = 0._dp
Call SuToFuFecSe(i_run,MFu,MFe,MSe,MChi,MSu,cplChiFecSeL,cplChiFecSeR,cplChiFucSuL, &
& cplChiFucSuR,deltaM,epsI,check,gSuFuFecSei)
gSuFuFecSe(i_run,:,:,:) = gSuFuFecSei
gT(i_run) = gT(i_run) + Sum(gSuFuFecSei)
gSuFuFucSui = 0._dp
Call SuToFuFucSu(i_run,MFu,MSu,MChi,MGlu,cplChiFucSuL,cplChiFucSuR,cplGluFucSuL, &
& cplGluFucSuR,deltaM,epsI,check,gSuFuFucSui)
gSuFuFucSu(i_run,:,:,:) = gSuFuFucSui
gT(i_run) = gT(i_run) + Sum(gSuFuFucSui)
gSuFuFvSvImi = 0._dp
Call SuToFuFvSvIm(i_run,MFu,MFv,MSvIm,MChi,MSu,cplChiFucSuL,cplChiFucSuR, &
& cplChiFvSvImL,cplChiFvSvImR,deltaM,epsI,check,gSuFuFvSvImi)
gSuFuFvSvIm(i_run,:,:,:) = gSuFuFvSvImi
gT(i_run) = gT(i_run) + Sum(gSuFuFvSvImi)
gSuFuFvSvRei = 0._dp
Call SuToFuFvSvRe(i_run,MFu,MFv,MSvRe,MChi,MSu,cplChiFucSuL,cplChiFucSuR, &
& cplChiFvSvReL,cplChiFvSvReR,deltaM,epsI,check,gSuFuFvSvRei)
gSuFuFvSvRe(i_run,:,:,:) = gSuFuFvSvRei
gT(i_run) = gT(i_run) + Sum(gSuFuFvSvRei)
gSucChaFuHpmi = 0._dp
Call SuTocChaFuHpm(i_run,MCha,MFu,MHpm,MFd,MChi,MSu,cplcChaChiHpmL,cplcChaChiHpmR, &
& cplcChaFdcSuL,cplcChaFdcSuR,cplcFdFuHpmL,cplcFdFuHpmR,cplChiFucSuL,cplChiFucSuR, &
& deltaM,epsI,check,gSucChaFuHpmi)
gSucChaFuHpm(i_run,:,:,:) = gSucChaFuHpmi
gT(i_run) = gT(i_run) + Sum(gSucChaFuHpmi)
gSuSdFucFdi = 0._dp
Call SuToSdFucFd(i_run,MSd,MFu,MFd,MVWm,MHpm,MChi,MGlu,MSu,cplSdcHpmcSu, &
& cplSdcSucVWm,cplcFdChiSdL,cplcFdChiSdR,cplcFdFuHpmL,cplcFdFuHpmR,cplcFdFuVWmL, &
& cplcFdFuVWmR,cplcFdGluSdL,cplcFdGluSdR,cplChiFucSuL,cplChiFucSuR,cplGluFucSuL, &
& cplGluFucSuR,deltaM,epsI,check,gSuSdFucFdi)
gSuSdFucFd(i_run,:,:,:) = gSuSdFucFdi
gT(i_run) = gT(i_run) + Sum(gSuSdFucFdi)
gSuFuSecFei = 0._dp
Call SuToFuSecFe(i_run,MFu,MSe,MFe,MChi,MSu,cplcFeChiSeL,cplcFeChiSeR,cplChiFucSuL, &
& cplChiFucSuR,deltaM,epsI,check,gSuFuSecFei)
gSuFuSecFe(i_run,:,:,:) = gSuFuSecFei
gT(i_run) = gT(i_run) + Sum(gSuFuSecFei)
gSuSuFucFui = 0._dp
Call SuToSuFucFu(i_run,MSu,MFu,MVZ,MAh,Mhh,MChi,MGlu,cplAhSucSu,cplhhSucSu, &
& cplSucSuVZ,cplcFuChiSuL,cplcFuChiSuR,cplcFuFuAhL,cplcFuFuAhR,cplcFuFuhhL, &
& cplcFuFuhhR,cplcFuFuVZL,cplcFuFuVZR,cplcFuGluSuL,cplcFuGluSuR,cplChiFucSuL, &
& cplChiFucSuR,cplGluFucSuL,cplGluFucSuR,deltaM,epsI,check,gSuSuFucFui)
gSuSuFucFu(i_run,:,:,:) = gSuSuFucFui
gT(i_run) = gT(i_run) + Sum(gSuSuFucFui)
gSucHpmFdGlui = 0._dp
Call SuTocHpmFdGlu(i_run,MHpm,MFd,MGlu,MSd,MFu,MSu,cplSdcHpmcSu,cplcFuFdcHpmL, &
& cplcFuFdcHpmR,cplGluFdcSdL,cplGluFdcSdR,cplGluFucSuL,cplGluFucSuR,deltaM, &
& epsI,check,gSucHpmFdGlui)
gSucHpmFdGlu(i_run,:,:,:) = gSucHpmFdGlui
gT(i_run) = gT(i_run) + Sum(gSucHpmFdGlui)
gSuhhFuGlui = 0._dp
Call SuTohhFuGlu(i_run,Mhh,MFu,MGlu,MSu,cplhhSucSu,cplcFuFuhhL,cplcFuFuhhR, &
& cplGluFucSuL,cplGluFucSuR,deltaM,epsI,check,gSuhhFuGlui)
gSuhhFuGlu(i_run,:,:,:) = gSuhhFuGlui
gT(i_run) = gT(i_run) + Sum(gSuhhFuGlui)
gSuGluGluSui = 0._dp
Call SuToGluGluSu(i_run,MGlu,MSu,MFu,cplcFuGluSuL,cplcFuGluSuR,cplGluFucSuL, &
& cplGluFucSuR,deltaM,epsI,check,gSuGluGluSui)
gSuGluGluSu(i_run,:,:,:) = gSuGluGluSui
gT(i_run) = gT(i_run) + Sum(gSuGluGluSui)
gSuGluSdcChai = 0._dp
Call SuToGluSdcCha(i_run,MGlu,MSd,MCha,MFu,MFd,MSu,cplcChacFuSdL,cplcChacFuSdR, &
& cplcChaFdcSuL,cplcChaFdcSuR,cplcFdGluSdL,cplcFdGluSdR,cplGluFucSuL,cplGluFucSuR, &
& deltaM,epsI,check,gSuGluSdcChai)
gSuGluSdcCha(i_run,:,:,:) = gSuGluSdcChai
gT(i_run) = gT(i_run) + Sum(gSuGluSdcChai)
gSuSdFvcFei = 0._dp
Call SuToSdFvcFe(i_run,MSd,MFv,MFe,MVWm,MHpm,MSu,cplSdcHpmcSu,cplSdcSucVWm, &
& cplcFeFvHpmL,cplcFeFvHpmR,cplcFeFvVWmL,cplcFeFvVWmR,deltaM,epsI,check,gSuSdFvcFei)
gSuSdFvcFe(i_run,:,:,:) = gSuSdFvcFei
gT(i_run) = gT(i_run) + Sum(gSuSdFvcFei)
gSuSuChacChai = 0._dp
Call SuToSuChacCha(i_run,MSu,MCha,MVZ,MAh,Mhh,MFd,cplAhSucSu,cplhhSucSu, &
& cplSucSuVZ,cplcChaChaAhL,cplcChaChaAhR,cplcChaChahhL,cplcChaChahhR,cplcChaChaVZL, &
& cplcChaChaVZR,cplcChaFdcSuL,cplcChaFdcSuR,cplcFdChaSuL,cplcFdChaSuR,deltaM, &
& epsI,check,gSuSuChacChai)
gSuSuChacCha(i_run,:,:,:) = gSuSuChacChai
gT(i_run) = gT(i_run) + Sum(gSuSuChacChai)
gSuSuFecFei = 0._dp
Call SuToSuFecFe(i_run,MSu,MFe,MVZ,MAh,Mhh,cplAhSucSu,cplhhSucSu,cplSucSuVZ, &
& cplcFeFeAhL,cplcFeFeAhR,cplcFeFehhL,cplcFeFehhR,cplcFeFeVZL,cplcFeFeVZR, &
& deltaM,epsI,check,gSuSuFecFei)
gSuSuFecFe(i_run,:,:,:) = gSuSuFecFei
gT(i_run) = gT(i_run) + Sum(gSuSuFecFei)
gSuSuFvFvi = 0._dp
Call SuToSuFvFv(i_run,MSu,MFv,MVZ,MAh,Mhh,cplAhSucSu,cplhhSucSu,cplSucSuVZ, &
& cplFvFvAhL,cplFvFvAhR,cplFvFvhhL,cplFvFvhhR,cplFvFvVZL,cplFvFvVZR,deltaM, &
& epsI,check,gSuSuFvFvi)
gSuSuFvFv(i_run,:,:,:) = gSuSuFvFvi
gT(i_run) = gT(i_run) + Sum(gSuSuFvFvi)
End Do
If (Present(gPartial)) Then
Do i1 = i_start, i_end
n_length=1
Do gt1=2,3
Do gt2=1,5
Do gt3=1,3
gPartial(i1,n_length)= gSuAhChiFu(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=2,3
Do gt2=1,3
Do gt3=1,2
gPartial(i1,n_length)= gSuAhFdcCha(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=2,3
Do gt2=1,3
Do gt3=1,1
gPartial(i1,n_length)= gSuAhFuGlu(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,6
Do gt2=1,5
Do gt3=gt2,5
gPartial(i1,n_length)= gSuSuChiChi(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=2,2
Do gt2=1,5
Do gt3=1,3
gPartial(i1,n_length)= gSucHpmChiFd(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=1,5
Do gt3=1,3
gPartial(i1,n_length)= gSuhhChiFu(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,5
Do gt2=1,1
Do gt3=1,6
gPartial(i1,n_length)= gSuChiGluSu(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,6
Do gt2=1,5
Do gt3=1,2
gPartial(i1,n_length)= gSuSdChicCha(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=1,3
Do gt3=1,6
gPartial(i1,n_length)= gSuFdFucSd(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=1,6
Do gt3=1,6
gPartial(i1,n_length)= gSuFdFvcSe(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=1,3
Do gt3=1,2
gPartial(i1,n_length)= gSuhhFdcCha(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,6
Do gt2=1,3
Do gt3=1,3
gPartial(i1,n_length)= gSuSuFdcFd(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=1,6
Do gt3=1,3
gPartial(i1,n_length)= gSuFdSvImcFe(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=1,6
Do gt3=1,3
gPartial(i1,n_length)= gSuFdSvRecFe(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=2,2
Do gt2=1,2
Do gt3=1,3
gPartial(i1,n_length)= gSucHpmChaFu(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=1,3
Do gt3=1,6
gPartial(i1,n_length)= gSuFuFecSe(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=gt1,3
Do gt3=1,6
gPartial(i1,n_length)= gSuFuFucSu(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=1,6
Do gt3=1,6
gPartial(i1,n_length)= gSuFuFvSvIm(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=1,6
Do gt3=1,6
gPartial(i1,n_length)= gSuFuFvSvRe(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,2
Do gt2=1,3
Do gt3=2,2
gPartial(i1,n_length)= gSucChaFuHpm(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,6
Do gt2=1,3
Do gt3=1,3
gPartial(i1,n_length)= gSuSdFucFd(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=1,6
Do gt3=1,3
gPartial(i1,n_length)= gSuFuSecFe(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,6
Do gt2=1,3
Do gt3=1,3
gPartial(i1,n_length)= gSuSuFucFu(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=2,2
Do gt2=1,3
Do gt3=1,1
gPartial(i1,n_length)= gSucHpmFdGlu(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,3
Do gt2=1,3
Do gt3=1,1
gPartial(i1,n_length)= gSuhhFuGlu(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,1
Do gt2=gt1,1
Do gt3=1,6
gPartial(i1,n_length)= gSuGluGluSu(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,1
Do gt2=1,6
Do gt3=1,2
gPartial(i1,n_length)= gSuGluSdcCha(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,6
Do gt2=1,6
Do gt3=1,3
gPartial(i1,n_length)= gSuSdFvcFe(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,6
Do gt2=1,2
Do gt3=1,2
gPartial(i1,n_length)= gSuSuChacCha(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,6
Do gt2=1,3
Do gt3=1,3
gPartial(i1,n_length)= gSuSuFecFe(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
Do gt1=1,6
Do gt2=1,6
Do gt3=gt2,6
gPartial(i1,n_length)= gSuSuFvFv(i1,gt1,gt2,gt3)
n_length=n_length+1
End Do
End Do
End Do
If (Present(BR).And.(gT(i1).Gt.0._dp)) Then
BR(i1,:)=gPartial(i1,:)/gT(i1)
Else If (Present(BR)) Then
BR(i1,:)=0._dp
End If
End Do
End if
Iname = Iname - 1
End Subroutine SuThreeBodyDecay
Subroutine SuToAhChiFu(iIN,MAh,MChi,MFu,MSu,cplAhSucSu,cplcFuFuAhL,cplcFuFuAhR, &
& cplChiChiAhL,cplChiChiAhR,cplChiFucSuL,cplChiFucSuR,deltaM,epsI,check,g, &
& WriteContributions)
Implicit None
Real(dp),Intent(in) :: MAh(3),MChi(5),MFu(3),MSu(6)
Complex(dp),Intent(in) :: cplAhSucSu(3,6,6),cplcFuFuAhL(3,3,3),cplcFuFuAhR(3,3,3),cplChiChiAhL(5,5,3), &
& cplChiChiAhR(5,5,3),cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 196
Allocate( gSum(3,5,3, Isum) )
Allocate( Contribution(3,5,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=2,3
Do gt2=1,5
Do gt3=1,3
Isum = 0
rk2 = (MChi(gt2)/MSu(iIN))**2
rm2 = (MFu(gt3)/MSu(iIN))**2
rj2 = (MAh(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFu(gt3))+Abs(MChi(gt2))+Abs(MAh(gt1)))) Then
!--------------
! Su
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplAhSucSu(gt1,i1,iIN))
coup(3) = Conjg(cplChiFucSuL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFucSuR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Chi Fu Propagator: Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Su'
End Do
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(gt2,i1,iIN))
coup(1) = Conjg(cplChiFucSuR(gt2,i1,iIN))
coup(4) = Conjg(cplcFuFuAhL(i1,gt3,gt1))
coup(3) = Conjg(cplcFuFuAhR(i1,gt3,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Chi Fu Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fu'
End Do
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt3,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt3,iIN))
coup(4) = Conjg(cplChiChiAhL(i1,gt2,gt1))
coup(3) = Conjg(cplChiChiAhR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Chi Fu Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Su, Su
!--------------
Do i1=1,5
Do i2=i1+1,6
Isum = Isum + 1
resS = 0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i2)
coup(1) = cplAhSucSu(gt1,i1,iIN)
coup(3) = Conjg(cplChiFucSuL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFucSuR(gt2,gt3,i1))
coup(4) = cplAhSucSu(gt1,i2,iIN)
coup(6) = Conjg(cplChiFucSuL(gt2,gt3,i2))
coup(5) = Conjg(cplChiFucSuR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Chi Fu Propagator: Su,Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,Su'
End Do
End Do
!--------------
! Su, Fu
!--------------
Do i1=1,6
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MSu(i1)
mass(1) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i2,iIN)
coup(2) = cplChiFucSuR(gt2,i2,iIN)
coup(4) = Conjg(cplcFuFuAhL(i2,gt3,gt1))
coup(3) = Conjg(cplcFuFuAhR(i2,gt3,gt1))
coup(5) = cplAhSucSu(gt1,i1,iIN)
coup(7) = Conjg(cplChiFucSuL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFucSuR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Chi Fu Propagator: Su,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,Fu'
End Do
End Do
!--------------
! Su, Chi
!--------------
Do i1=1,6
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(2) = MSu(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFucSuL(i2,gt3,iIN)
coup(2) = cplChiFucSuR(i2,gt3,iIN)
coup(4) = Conjg(cplChiChiAhL(i2,gt2,gt1))
coup(3) = Conjg(cplChiChiAhR(i2,gt2,gt1))
coup(5) = cplAhSucSu(gt1,i1,iIN)
coup(7) = Conjg(cplChiFucSuL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFucSuR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Chi Fu Propagator: Su,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,Chi'
End Do
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i1,iIN)
coup(2) = cplChiFucSuR(gt2,i1,iIN)
coup(3) = cplcFuFuAhL(i1,gt3,gt1)
coup(4) = cplcFuFuAhR(i1,gt3,gt1)
coup(5) = cplChiFucSuL(gt2,i2,iIN)
coup(6) = cplChiFucSuR(gt2,i2,iIN)
coup(7) = cplcFuFuAhL(i2,gt3,gt1)
coup(8) = cplcFuFuAhR(i2,gt3,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Chi Fu Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fu,Fu'
End Do
End Do
!--------------
! Fu, Chi
!--------------
Do i1=1,3
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(gt2,i1,iIN)
coup(2) = cplChiFucSuR(gt2,i1,iIN)
coup(3) = cplcFuFuAhL(i1,gt3,gt1)
coup(4) = cplcFuFuAhR(i1,gt3,gt1)
coup(5) = cplChiFucSuL(i2,gt3,iIN)
coup(6) = cplChiFucSuR(i2,gt3,iIN)
coup(7) = cplChiChiAhL(i2,gt2,gt1)
coup(8) = cplChiChiAhR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Chi Fu Propagator: Fu,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fu,Chi'
End Do
End Do
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt3,iIN)
coup(2) = cplChiFucSuR(i1,gt3,iIN)
coup(3) = cplChiChiAhL(i1,gt2,gt1)
coup(4) = cplChiChiAhR(i1,gt2,gt1)
coup(5) = cplChiFucSuL(i2,gt3,iIN)
coup(6) = cplChiFucSuR(i2,gt3,iIN)
coup(7) = cplChiChiAhL(i2,gt2,gt1)
coup(8) = cplChiChiAhR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Chi Fu Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=2,3
Do gt2=1,5
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:196))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToAhChiFu
Subroutine SuToAhFdcCha(iIN,MAh,MFd,MCha,MSu,cplAhSucSu,cplcChaChaAhL,cplcChaChaAhR, &
& cplcChaFdcSuL,cplcChaFdcSuR,cplcFdFdAhL,cplcFdFdAhR,deltaM,epsI,check,g, &
& WriteContributions)
Implicit None
Real(dp),Intent(in) :: MAh(3),MFd(3),MCha(2),MSu(6)
Complex(dp),Intent(in) :: cplAhSucSu(3,6,6),cplcChaChaAhL(2,2,3),cplcChaChaAhR(2,2,3),cplcChaFdcSuL(2,3,6), &
& cplcChaFdcSuR(2,3,6),cplcFdFdAhL(3,3,3),cplcFdFdAhR(3,3,3)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 121
Allocate( gSum(3,3,2, Isum) )
Allocate( Contribution(3,3,2, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=2,3
Do gt2=1,3
Do gt3=1,2
Isum = 0
rk2 = (MFd(gt2)/MSu(iIN))**2
rm2 = (MCha(gt3)/MSu(iIN))**2
rj2 = (MAh(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MCha(gt3))+Abs(MFd(gt2))+Abs(MAh(gt1)))) Then
!--------------
! Su
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplAhSucSu(gt1,i1,iIN))
coup(3) = Conjg(cplcChaFdcSuL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaFdcSuR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fd cCha Propagator: Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Su'
End Do
!--------------
! bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(i1,gt2,iIN))
coup(1) = Conjg(cplcChaFdcSuR(i1,gt2,iIN))
coup(4) = Conjg(cplcChaChaAhL(gt3,i1,gt1))
coup(3) = Conjg(cplcChaChaAhR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fd cCha Propagator: bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
End Do
!--------------
! Fd
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(gt3,i1,iIN))
coup(1) = Conjg(cplcChaFdcSuR(gt3,i1,iIN))
coup(4) = Conjg(cplcFdFdAhL(i1,gt2,gt1))
coup(3) = Conjg(cplcFdFdAhR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fd cCha Propagator: Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fd'
End Do
!--------------
! Su, Su
!--------------
Do i1=1,5
Do i2=i1+1,6
Isum = Isum + 1
resS = 0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i2)
coup(1) = cplAhSucSu(gt1,i1,iIN)
coup(3) = Conjg(cplcChaFdcSuL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaFdcSuR(gt3,gt2,i1))
coup(4) = cplAhSucSu(gt1,i2,iIN)
coup(6) = Conjg(cplcChaFdcSuL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaFdcSuR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fd cCha Propagator: Su,Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,Su'
End Do
End Do
!--------------
! Su, bar[Cha]
!--------------
Do i1=1,6
Do i2=1,2
Isum = Isum + 1
resS = 0._dp
mass(2) = MSu(i1)
mass(1) = MCha(i2)
coup(1) = cplcChaFdcSuL(i2,gt2,iIN)
coup(2) = cplcChaFdcSuR(i2,gt2,iIN)
coup(4) = Conjg(cplcChaChaAhL(gt3,i2,gt1))
coup(3) = Conjg(cplcChaChaAhR(gt3,i2,gt1))
coup(5) = cplAhSucSu(gt1,i1,iIN)
coup(7) = Conjg(cplcChaFdcSuL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaFdcSuR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fd cCha Propagator: Su,bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,bar[Cha]'
End Do
End Do
!--------------
! Su, Fd
!--------------
Do i1=1,6
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MSu(i1)
mass(1) = MFd(i2)
coup(1) = cplcChaFdcSuL(gt3,i2,iIN)
coup(2) = cplcChaFdcSuR(gt3,i2,iIN)
coup(4) = Conjg(cplcFdFdAhL(i2,gt2,gt1))
coup(3) = Conjg(cplcFdFdAhR(i2,gt2,gt1))
coup(5) = cplAhSucSu(gt1,i1,iIN)
coup(7) = Conjg(cplcChaFdcSuL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaFdcSuR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fd cCha Propagator: Su,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,Fd'
End Do
End Do
!--------------
! bar[Cha], bar[Cha]
!--------------
Do i1=1,1
Do i2=i1+1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFdcSuL(i1,gt2,iIN)
coup(2) = cplcChaFdcSuR(i1,gt2,iIN)
coup(3) = cplcChaChaAhL(gt3,i1,gt1)
coup(4) = cplcChaChaAhR(gt3,i1,gt1)
coup(5) = cplcChaFdcSuL(i2,gt2,iIN)
coup(6) = cplcChaFdcSuR(i2,gt2,iIN)
coup(7) = cplcChaChaAhL(gt3,i2,gt1)
coup(8) = cplcChaChaAhR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fd cCha Propagator: bar[Cha],bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
End Do
End Do
!--------------
! bar[Cha], Fd
!--------------
Do i1=1,2
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MFd(i2)
coup(1) = cplcChaFdcSuL(i1,gt2,iIN)
coup(2) = cplcChaFdcSuR(i1,gt2,iIN)
coup(3) = cplcChaChaAhL(gt3,i1,gt1)
coup(4) = cplcChaChaAhR(gt3,i1,gt1)
coup(5) = cplcChaFdcSuL(gt3,i2,iIN)
coup(6) = cplcChaFdcSuR(gt3,i2,iIN)
coup(7) = cplcFdFdAhL(i2,gt2,gt1)
coup(8) = cplcFdFdAhR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fd cCha Propagator: bar[Cha],Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],Fd'
End Do
End Do
!--------------
! Fd, Fd
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i2)
coup(1) = cplcChaFdcSuL(gt3,i1,iIN)
coup(2) = cplcChaFdcSuR(gt3,i1,iIN)
coup(3) = cplcFdFdAhL(i1,gt2,gt1)
coup(4) = cplcFdFdAhR(i1,gt2,gt1)
coup(5) = cplcChaFdcSuL(gt3,i2,iIN)
coup(6) = cplcChaFdcSuR(gt3,i2,iIN)
coup(7) = cplcFdFdAhL(i2,gt2,gt1)
coup(8) = cplcFdFdAhR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fd cCha Propagator: Fd,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fd,Fd'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=2,3
Do gt2=1,3
Do gt3=1,2
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:121))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToAhFdcCha
Subroutine SuToAhFuGlu(iIN,MAh,MFu,MGlu,MSu,cplAhSucSu,cplcFuFuAhL,cplcFuFuAhR, &
& cplGluFucSuL,cplGluFucSuR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MAh(3),MFu(3),MGlu,MSu(6)
Complex(dp),Intent(in) :: cplAhSucSu(3,6,6),cplcFuFuAhL(3,3,3),cplcFuFuAhR(3,3,3),cplGluFucSuL(3,6), &
& cplGluFucSuR(3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 81
Allocate( gSum(3,3,1, Isum) )
Allocate( Contribution(3,3,1, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=2,3
Do gt2=1,3
Isum = 0
rk2 = (MFu(gt2)/MSu(iIN))**2
rm2 = (MGlu/MSu(iIN))**2
rj2 = (MAh(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MGlu)+Abs(MFu(gt2))+Abs(MAh(gt1)))) Then
!--------------
! Su
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplAhSucSu(gt1,i1,iIN))
coup(3) = Conjg(cplGluFucSuL(gt2,i1))
coup(2) = Conjg(cplGluFucSuR(gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fu Glu Propagator: Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)=resD
End If
Contribution(gt1,gt2,1,Isum)='Su'
End Do
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(i1,iIN))
coup(1) = Conjg(cplGluFucSuR(i1,iIN))
coup(4) = Conjg(cplcFuFuAhL(i1,gt2,gt1))
coup(3) = Conjg(cplcFuFuAhR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fu Glu Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)=resD
End If
Contribution(gt1,gt2,1,Isum)='Fu'
End Do
!--------------
! Su, Su
!--------------
Do i1=1,5
Do i2=i1+1,6
Isum = Isum + 1
resS = 0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i2)
coup(1) = cplAhSucSu(gt1,i1,iIN)
coup(3) = Conjg(cplGluFucSuL(gt2,i1))
coup(2) = Conjg(cplGluFucSuR(gt2,i1))
coup(4) = cplAhSucSu(gt1,i2,iIN)
coup(6) = Conjg(cplGluFucSuL(gt2,i2))
coup(5) = Conjg(cplGluFucSuR(gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fu Glu Propagator: Su,Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)= resS
End If
Contribution(gt1,gt2,1,Isum)='Su,Su'
End Do
End Do
!--------------
! Su, Fu
!--------------
Do i1=1,6
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MSu(i1)
mass(1) = MFu(i2)
coup(1) = cplGluFucSuL(i2,iIN)
coup(2) = cplGluFucSuR(i2,iIN)
coup(4) = Conjg(cplcFuFuAhL(i2,gt2,gt1))
coup(3) = Conjg(cplcFuFuAhR(i2,gt2,gt1))
coup(5) = cplAhSucSu(gt1,i1,iIN)
coup(7) = Conjg(cplGluFucSuL(gt2,i1))
coup(6) = Conjg(cplGluFucSuR(gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fu Glu Propagator: Su,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)= resS
End If
Contribution(gt1,gt2,1,Isum)='Su,Fu'
End Do
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplGluFucSuL(i1,iIN)
coup(2) = cplGluFucSuR(i1,iIN)
coup(3) = cplcFuFuAhL(i1,gt2,gt1)
coup(4) = cplcFuFuAhR(i1,gt2,gt1)
coup(5) = cplGluFucSuL(i2,iIN)
coup(6) = cplGluFucSuR(i2,iIN)
coup(7) = cplcFuFuAhL(i2,gt2,gt1)
coup(8) = cplcFuFuAhR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Ah Fu Glu Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)= resS
End If
Contribution(gt1,gt2,1,Isum)='Fu,Fu'
End Do
End Do
Else
gSum(gt1,gt2,1,:)= 0._dp
End If
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=2,3
Do gt2=1,3
g(gt1,gt2,1)=Sum(gSum(gt1,gt2,1,1:81))
If (g(gt1,gt2,1).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,1)=0._dp
End If
End Do
End Do
End Subroutine SuToAhFuGlu
Subroutine SuToSuChiChi(iIN,MSu,MChi,MVZ,MAh,Mhh,MFu,cplAhSucSu,cplhhSucSu, &
& cplSucSuVZ,cplcFuChiSuL,cplcFuChiSuR,cplChiChiAhL,cplChiChiAhR,cplChiChihhL, &
& cplChiChihhR,cplChiChiVZL,cplChiChiVZR,cplChiFucSuL,cplChiFucSuR,deltaM, &
& epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MSu(6),MChi(5),MVZ,MAh(3),Mhh(3),MFu(3)
Complex(dp),Intent(in) :: cplAhSucSu(3,6,6),cplhhSucSu(3,6,6),cplSucSuVZ(6,6),cplcFuChiSuL(3,5,6), &
& cplcFuChiSuR(3,5,6),cplChiChiAhL(5,5,3),cplChiChiAhR(5,5,3),cplChiChihhL(5,5,3), &
& cplChiChihhR(5,5,3),cplChiChiVZL(5,5),cplChiChiVZR(5,5),cplChiFucSuL(5,3,6), &
& cplChiFucSuR(5,3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 100
Allocate( gSum(6,5,5, Isum) )
Allocate( Contribution(6,5,5, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1, iIN-1
Do gt2=1,5
Do gt3=gt2,5
Isum = 0
rk2 = (MChi(gt2)/MSu(iIN))**2
rm2 = (MChi(gt3)/MSu(iIN))**2
rj2 = (MSu(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MChi(gt3))+Abs(MChi(gt2))+Abs(MSu(gt1)))) Then
!--------------
! VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MVZ
mass(2) = MVZ
m_in = MSu(iIN)
coup(1) = Conjg(cplSucSuVZ(gt1,iIN))
coup(3) = Conjg(cplChiChiVZL(gt2,gt3))
coup(2) = Conjg(cplChiChiVZR(gt2,gt3))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MVZ
mass(2) = MVZ
m_in = MSu(iIN)
coup(1) = Conjg(cplSucSuVZ(gt1,iIN))
coup(3) = Conjg(cplChiChiVZL(gt3,gt2))
coup(2) = Conjg(cplChiChiVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: VZ"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'
!--------------
! Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplAhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChiAhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplAhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplChiChiAhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChiAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MAh(i1)
mass(2) = MAh(i1)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplChiChiAhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChiAhR(gt3,gt2,i1))
coup(4) = cplAhSucSu(i1,gt1,iIN)
coup(6) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(5) = Conjg(cplChiChiAhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
End Do
!--------------
! hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplhhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChihhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplhhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplChiChihhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChihhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
coup(1) = cplhhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplChiChihhL(gt3,gt2,i1))
coup(2) = Conjg(cplChiChihhR(gt3,gt2,i1))
coup(4) = cplhhSucSu(i1,gt1,iIN)
coup(6) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(5) = Conjg(cplChiChihhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
End Do
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(gt2,i1,iIN))
coup(1) = Conjg(cplChiFucSuR(gt2,i1,iIN))
coup(4) = Conjg(cplcFuChiSuL(i1,gt3,gt1))
coup(3) = Conjg(cplcFuChiSuR(i1,gt3,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(gt3,i1,iIN))
coup(1) = Conjg(cplChiFucSuR(gt3,i1,iIN))
coup(4) = Conjg(cplcFuChiSuL(i1,gt2,gt1))
coup(3) = Conjg(cplcFuChiSuR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFu(i1)
mass(2) = MFu(i1)
coup(1) = cplChiFucSuL(gt3,i1,iIN)
coup(2) = cplChiFucSuR(gt3,i1,iIN)
coup(3) = cplcFuChiSuL(i1,gt2,gt1)
coup(4) = cplcFuChiSuR(i1,gt2,gt1)
coup(5) = cplChiFucSuL(gt2,i1,iIN)
coup(6) = cplChiFucSuR(gt2,i1,iIN)
coup(7) = cplcFuChiSuL(i1,gt3,gt1)
coup(8) = cplcFuChiSuR(i1,gt3,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fu'
End Do
!--------------
! VZ, Ah
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplChiChiVZL(gt2,gt3))
coup(3) = Conjg(cplChiChiVZR(gt2,gt3))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplChiChiAhL(gt2,gt3,i2))
coup(6) = Conjg(cplChiChiAhR(gt2,gt3,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: VZ,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
End Do
!--------------
! VZ, hh
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplChiChiVZL(gt2,gt3))
coup(3) = Conjg(cplChiChiVZR(gt2,gt3))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplChiChihhL(gt2,gt3,i2))
coup(6) = Conjg(cplChiChihhR(gt2,gt3,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: VZ,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
End Do
!--------------
! VZ, Fu
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ2
mass(1) = MFu2(i2)
coup(1) = cplChiFucSuL(gt2,i2,iIN)
coup(2) = cplChiFucSuR(gt2,i2,iIN)
coup(4) = Conjg(cplcFuChiSuL(i2,gt3,gt1))
coup(3) = Conjg(cplcFuChiSuR(i2,gt3,gt1))
coup(5) = cplSucSuVZ(gt1,iIN)
coup(7) = Conjg(cplChiChiVZL(gt2,gt3))
coup(6) = Conjg(cplChiChiVZR(gt2,gt3))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC ! Color factor
If (resC.ne.resC) resC = 0._dp
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = MVZ2
mass(1) = MFu2(i2)
coup(1) = cplChiFucSuL(gt3,i2,iIN)
coup(2) = cplChiFucSuR(gt3,i2,iIN)
coup(4) = Conjg(cplcFuChiSuL(i2,gt2,gt1))
coup(3) = Conjg(cplcFuChiSuR(i2,gt2,gt1))
coup(5) = cplSucSuVZ(gt1,iIN)
coup(7) = Conjg(cplChiChiVZL(gt2,gt3))
coup(6) = Conjg(cplChiChiVZR(gt2,gt3))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC ! Color factor
If (resC.ne.resC) resC = 0._dp
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: VZ,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Fu'
End Do
!--------------
! Ah, Ah
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChiAhR(gt2,gt3,i1))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplChiChiAhL(gt2,gt3,i2))
coup(5) = Conjg(cplChiChiAhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: Ah,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
End Do
End Do
!--------------
! Ah, hh
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChiAhR(gt2,gt3,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplChiChihhL(gt2,gt3,i2))
coup(5) = Conjg(cplChiChihhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: Ah,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
End Do
End Do
!--------------
! Ah, Fu
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i2,iIN)
coup(2) = cplChiFucSuR(gt2,i2,iIN)
coup(4) = Conjg(cplcFuChiSuL(i2,gt3,gt1))
coup(3) = Conjg(cplcFuChiSuR(i2,gt3,gt1))
coup(5) = cplAhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChiAhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = MAh(i1)
mass(1) = MFu(i2)
coup(1) = cplChiFucSuL(gt3,i2,iIN)
coup(2) = cplChiFucSuR(gt3,i2,iIN)
coup(4) = Conjg(cplcFuChiSuL(i2,gt2,gt1))
coup(3) = Conjg(cplcFuChiSuR(i2,gt2,gt1))
coup(5) = cplAhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplChiChiAhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChiAhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: Ah,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Fu'
End Do
End Do
!--------------
! hh, hh
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(2) = Conjg(cplChiChihhR(gt2,gt3,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplChiChihhL(gt2,gt3,i2))
coup(5) = Conjg(cplChiChihhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: hh,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
End Do
End Do
!--------------
! hh, Fu
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i2,iIN)
coup(2) = cplChiFucSuR(gt2,i2,iIN)
coup(4) = Conjg(cplcFuChiSuL(i2,gt3,gt1))
coup(3) = Conjg(cplcFuChiSuR(i2,gt3,gt1))
coup(5) = cplhhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChihhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(2) = Mhh(i1)
mass(1) = MFu(i2)
coup(1) = cplChiFucSuL(gt3,i2,iIN)
coup(2) = cplChiFucSuR(gt3,i2,iIN)
coup(4) = Conjg(cplcFuChiSuL(i2,gt2,gt1))
coup(3) = Conjg(cplcFuChiSuR(i2,gt2,gt1))
coup(5) = cplhhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplChiChihhL(gt2,gt3,i1))
coup(6) = Conjg(cplChiChihhR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: hh,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Fu'
End Do
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i1,iIN)
coup(2) = cplChiFucSuR(gt2,i1,iIN)
coup(3) = cplcFuChiSuL(i1,gt3,gt1)
coup(4) = cplcFuChiSuR(i1,gt3,gt1)
coup(5) = cplChiFucSuL(gt2,i2,iIN)
coup(6) = cplChiFucSuR(gt2,i2,iIN)
coup(7) = cplcFuChiSuL(i2,gt3,gt1)
coup(8) = cplcFuChiSuR(i2,gt3,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplChiFucSuL(gt3,i1,iIN)
coup(2) = cplChiFucSuR(gt3,i1,iIN)
coup(3) = cplcFuChiSuL(i1,gt2,gt1)
coup(4) = cplcFuChiSuR(i1,gt2,gt1)
coup(5) = cplChiFucSuL(gt2,i2,iIN)
coup(6) = cplChiFucSuR(gt2,i2,iIN)
coup(7) = cplcFuChiSuL(i2,gt3,gt1)
coup(8) = cplcFuChiSuR(i2,gt3,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplChiFucSuL(gt3,i1,iIN)
coup(2) = cplChiFucSuR(gt3,i1,iIN)
coup(3) = cplcFuChiSuL(i1,gt2,gt1)
coup(4) = cplcFuChiSuR(i1,gt2,gt1)
coup(5) = cplChiFucSuL(gt3,i2,iIN)
coup(6) = cplChiFucSuR(gt3,i2,iIN)
coup(7) = cplcFuChiSuL(i2,gt2,gt1)
coup(8) = cplcFuChiSuR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i1,iIN)
coup(2) = cplChiFucSuR(gt2,i1,iIN)
coup(3) = cplcFuChiSuL(i1,gt3,gt1)
coup(4) = cplcFuChiSuR(i1,gt3,gt1)
coup(5) = cplChiFucSuL(gt3,i2,iIN)
coup(6) = cplChiFucSuR(gt3,i2,iIN)
coup(7) = cplcFuChiSuL(i2,gt2,gt1)
coup(8) = cplcFuChiSuR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Chi Chi Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fu,Fu'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1, iIN-1
Do gt2=1,5
Do gt3=gt2,5
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:100))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToSuChiChi
Subroutine SuTocHpmChiFd(iIN,MHpm,MChi,MFd,MSd,MFu,MCha,MSu,cplSdcHpmcSu, &
& cplcChaFdcSuL,cplcChaFdcSuR,cplcFuFdcHpmL,cplcFuFdcHpmR,cplChiChacHpmL,cplChiChacHpmR, &
& cplChiFdcSdL,cplChiFdcSdR,cplChiFucSuL,cplChiFucSuR,deltaM,epsI,check,g, &
& WriteContributions)
Implicit None
Real(dp),Intent(in) :: MHpm(2),MChi(5),MFd(3),MSd(6),MFu(3),MCha(2),MSu(6)
Complex(dp),Intent(in) :: cplSdcHpmcSu(6,2,6),cplcChaFdcSuL(2,3,6),cplcChaFdcSuR(2,3,6),cplcFuFdcHpmL(3,3,2), &
& cplcFuFdcHpmR(3,3,2),cplChiChacHpmL(5,2,2),cplChiChacHpmR(5,2,2),cplChiFdcSdL(5,3,6), &
& cplChiFdcSdR(5,3,6),cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 121
Allocate( gSum(2,5,3, Isum) )
Allocate( Contribution(2,5,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=2,2
Do gt2=1,5
Do gt3=1,3
Isum = 0
rk2 = (MChi(gt2)/MSu(iIN))**2
rm2 = (MFd(gt3)/MSu(iIN))**2
rj2 = (MHpm(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFd(gt3))+Abs(MChi(gt2))+Abs(MHpm(gt1)))) Then
!--------------
! Sd
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MSd(i1)
mass(2) = MSd(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplSdcHpmcSu(i1,gt1,iIN))
coup(3) = Conjg(cplChiFdcSdL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFdcSdR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Chi Fd Propagator: Sd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Sd'
End Do
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(gt2,i1,iIN))
coup(1) = Conjg(cplChiFucSuR(gt2,i1,iIN))
coup(4) = Conjg(cplcFuFdcHpmL(i1,gt3,gt1))
coup(3) = Conjg(cplcFuFdcHpmR(i1,gt3,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Chi Fd Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fu'
End Do
!--------------
! bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(i1,gt3,iIN))
coup(1) = Conjg(cplcChaFdcSuR(i1,gt3,iIN))
coup(4) = Conjg(cplChiChacHpmL(gt2,i1,gt1))
coup(3) = Conjg(cplChiChacHpmR(gt2,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Chi Fd Propagator: bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
End Do
!--------------
! Sd, Sd
!--------------
Do i1=1,5
Do i2=i1+1,6
Isum = Isum + 1
resS = 0._dp
mass(1) = MSd(i1)
mass(2) = MSd(i2)
coup(1) = cplSdcHpmcSu(i1,gt1,iIN)
coup(3) = Conjg(cplChiFdcSdL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFdcSdR(gt2,gt3,i1))
coup(4) = cplSdcHpmcSu(i2,gt1,iIN)
coup(6) = Conjg(cplChiFdcSdL(gt2,gt3,i2))
coup(5) = Conjg(cplChiFdcSdR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Chi Fd Propagator: Sd,Sd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Sd,Sd'
End Do
End Do
!--------------
! Sd, Fu
!--------------
Do i1=1,6
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MSd(i1)
mass(1) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i2,iIN)
coup(2) = cplChiFucSuR(gt2,i2,iIN)
coup(4) = Conjg(cplcFuFdcHpmL(i2,gt3,gt1))
coup(3) = Conjg(cplcFuFdcHpmR(i2,gt3,gt1))
coup(5) = cplSdcHpmcSu(i1,gt1,iIN)
coup(7) = Conjg(cplChiFdcSdL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFdcSdR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Chi Fd Propagator: Sd,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Sd,Fu'
End Do
End Do
!--------------
! Sd, bar[Cha]
!--------------
Do i1=1,6
Do i2=1,2
Isum = Isum + 1
resS = 0._dp
mass(2) = MSd(i1)
mass(1) = MCha(i2)
coup(1) = cplcChaFdcSuL(i2,gt3,iIN)
coup(2) = cplcChaFdcSuR(i2,gt3,iIN)
coup(4) = Conjg(cplChiChacHpmL(gt2,i2,gt1))
coup(3) = Conjg(cplChiChacHpmR(gt2,i2,gt1))
coup(5) = cplSdcHpmcSu(i1,gt1,iIN)
coup(7) = Conjg(cplChiFdcSdL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFdcSdR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Chi Fd Propagator: Sd,bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Sd,bar[Cha]'
End Do
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i1,iIN)
coup(2) = cplChiFucSuR(gt2,i1,iIN)
coup(3) = cplcFuFdcHpmL(i1,gt3,gt1)
coup(4) = cplcFuFdcHpmR(i1,gt3,gt1)
coup(5) = cplChiFucSuL(gt2,i2,iIN)
coup(6) = cplChiFucSuR(gt2,i2,iIN)
coup(7) = cplcFuFdcHpmL(i2,gt3,gt1)
coup(8) = cplcFuFdcHpmR(i2,gt3,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Chi Fd Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fu,Fu'
End Do
End Do
!--------------
! Fu, bar[Cha]
!--------------
Do i1=1,3
Do i2=1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MCha(i2)
coup(1) = cplChiFucSuL(gt2,i1,iIN)
coup(2) = cplChiFucSuR(gt2,i1,iIN)
coup(3) = cplcFuFdcHpmL(i1,gt3,gt1)
coup(4) = cplcFuFdcHpmR(i1,gt3,gt1)
coup(5) = cplcChaFdcSuL(i2,gt3,iIN)
coup(6) = cplcChaFdcSuR(i2,gt3,iIN)
coup(7) = cplChiChacHpmL(gt2,i2,gt1)
coup(8) = cplChiChacHpmR(gt2,i2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Chi Fd Propagator: Fu,bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fu,bar[Cha]'
End Do
End Do
!--------------
! bar[Cha], bar[Cha]
!--------------
Do i1=1,1
Do i2=i1+1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFdcSuL(i1,gt3,iIN)
coup(2) = cplcChaFdcSuR(i1,gt3,iIN)
coup(3) = cplChiChacHpmL(gt2,i1,gt1)
coup(4) = cplChiChacHpmR(gt2,i1,gt1)
coup(5) = cplcChaFdcSuL(i2,gt3,iIN)
coup(6) = cplcChaFdcSuR(i2,gt3,iIN)
coup(7) = cplChiChacHpmL(gt2,i2,gt1)
coup(8) = cplChiChacHpmR(gt2,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Chi Fd Propagator: bar[Cha],bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=2,2
Do gt2=1,5
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:121))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuTocHpmChiFd
Subroutine SuTohhChiFu(iIN,Mhh,MChi,MFu,MSu,cplhhSucSu,cplcFuFuhhL,cplcFuFuhhR, &
& cplChiChihhL,cplChiChihhR,cplChiFucSuL,cplChiFucSuR,deltaM,epsI,check,g, &
& WriteContributions)
Implicit None
Real(dp),Intent(in) :: Mhh(3),MChi(5),MFu(3),MSu(6)
Complex(dp),Intent(in) :: cplhhSucSu(3,6,6),cplcFuFuhhL(3,3,3),cplcFuFuhhR(3,3,3),cplChiChihhL(5,5,3), &
& cplChiChihhR(5,5,3),cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 196
Allocate( gSum(3,5,3, Isum) )
Allocate( Contribution(3,5,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=1,5
Do gt3=1,3
Isum = 0
rk2 = (MChi(gt2)/MSu(iIN))**2
rm2 = (MFu(gt3)/MSu(iIN))**2
rj2 = (Mhh(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFu(gt3))+Abs(MChi(gt2))+Abs(Mhh(gt1)))) Then
!--------------
! Su
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplhhSucSu(gt1,i1,iIN))
coup(3) = Conjg(cplChiFucSuL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFucSuR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Chi Fu Propagator: Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Su'
End Do
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(gt2,i1,iIN))
coup(1) = Conjg(cplChiFucSuR(gt2,i1,iIN))
coup(4) = Conjg(cplcFuFuhhL(i1,gt3,gt1))
coup(3) = Conjg(cplcFuFuhhR(i1,gt3,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Chi Fu Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fu'
End Do
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt3,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt3,iIN))
coup(4) = Conjg(cplChiChihhL(i1,gt2,gt1))
coup(3) = Conjg(cplChiChihhR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Chi Fu Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Su, Su
!--------------
Do i1=1,5
Do i2=i1+1,6
Isum = Isum + 1
resS = 0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i2)
coup(1) = cplhhSucSu(gt1,i1,iIN)
coup(3) = Conjg(cplChiFucSuL(gt2,gt3,i1))
coup(2) = Conjg(cplChiFucSuR(gt2,gt3,i1))
coup(4) = cplhhSucSu(gt1,i2,iIN)
coup(6) = Conjg(cplChiFucSuL(gt2,gt3,i2))
coup(5) = Conjg(cplChiFucSuR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Chi Fu Propagator: Su,Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,Su'
End Do
End Do
!--------------
! Su, Fu
!--------------
Do i1=1,6
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MSu(i1)
mass(1) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i2,iIN)
coup(2) = cplChiFucSuR(gt2,i2,iIN)
coup(4) = Conjg(cplcFuFuhhL(i2,gt3,gt1))
coup(3) = Conjg(cplcFuFuhhR(i2,gt3,gt1))
coup(5) = cplhhSucSu(gt1,i1,iIN)
coup(7) = Conjg(cplChiFucSuL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFucSuR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Chi Fu Propagator: Su,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,Fu'
End Do
End Do
!--------------
! Su, Chi
!--------------
Do i1=1,6
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(2) = MSu(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFucSuL(i2,gt3,iIN)
coup(2) = cplChiFucSuR(i2,gt3,iIN)
coup(4) = Conjg(cplChiChihhL(i2,gt2,gt1))
coup(3) = Conjg(cplChiChihhR(i2,gt2,gt1))
coup(5) = cplhhSucSu(gt1,i1,iIN)
coup(7) = Conjg(cplChiFucSuL(gt2,gt3,i1))
coup(6) = Conjg(cplChiFucSuR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Chi Fu Propagator: Su,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,Chi'
End Do
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i1,iIN)
coup(2) = cplChiFucSuR(gt2,i1,iIN)
coup(3) = cplcFuFuhhL(i1,gt3,gt1)
coup(4) = cplcFuFuhhR(i1,gt3,gt1)
coup(5) = cplChiFucSuL(gt2,i2,iIN)
coup(6) = cplChiFucSuR(gt2,i2,iIN)
coup(7) = cplcFuFuhhL(i2,gt3,gt1)
coup(8) = cplcFuFuhhR(i2,gt3,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Chi Fu Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fu,Fu'
End Do
End Do
!--------------
! Fu, Chi
!--------------
Do i1=1,3
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(gt2,i1,iIN)
coup(2) = cplChiFucSuR(gt2,i1,iIN)
coup(3) = cplcFuFuhhL(i1,gt3,gt1)
coup(4) = cplcFuFuhhR(i1,gt3,gt1)
coup(5) = cplChiFucSuL(i2,gt3,iIN)
coup(6) = cplChiFucSuR(i2,gt3,iIN)
coup(7) = cplChiChihhL(i2,gt2,gt1)
coup(8) = cplChiChihhR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Chi Fu Propagator: Fu,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fu,Chi'
End Do
End Do
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt3,iIN)
coup(2) = cplChiFucSuR(i1,gt3,iIN)
coup(3) = cplChiChihhL(i1,gt2,gt1)
coup(4) = cplChiChihhR(i1,gt2,gt1)
coup(5) = cplChiFucSuL(i2,gt3,iIN)
coup(6) = cplChiFucSuR(i2,gt3,iIN)
coup(7) = cplChiChihhL(i2,gt2,gt1)
coup(8) = cplChiChihhR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Chi Fu Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=1,5
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:196))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuTohhChiFu
Subroutine SuToChiGluSu(iIN,MChi,MGlu,MSu,MFu,cplcFuChiSuL,cplcFuChiSuR, &
& cplcFuGluSuL,cplcFuGluSuR,cplChiFucSuL,cplChiFucSuR,cplGluFucSuL,cplGluFucSuR, &
& deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MChi(5),MGlu,MSu(6),MFu(3)
Complex(dp),Intent(in) :: cplcFuChiSuL(3,5,6),cplcFuChiSuR(3,5,6),cplcFuGluSuL(3,6),cplcFuGluSuR(3,6), &
& cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6),cplGluFucSuL(3,6),cplGluFucSuR(3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 36
Allocate( gSum(5,1,6, Isum) )
Allocate( Contribution(5,1,6, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,5
Do gt3=1, iIN-1
Isum = 0
rk2 = (MChi(gt1)/MSu(iIN))**2
rm2 = (MGlu/MSu(iIN))**2
rj2 = (MSu(gt3)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MSu(gt3))+Abs(MGlu)+Abs(MChi(gt1)))) Then
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(gt1,i1,iIN))
coup(1) = Conjg(cplChiFucSuR(gt1,i1,iIN))
coup(4) = Conjg(cplcFuGluSuL(i1,gt3))
coup(3) = Conjg(cplcFuGluSuR(i1,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Chi Glu Su Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,1,gt3,Isum)= 0._dp
Else
gSum(gt1,1,gt3,Isum)=resD
End If
Contribution(gt1,1,gt3,Isum)='Fu'
End Do
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(i1,iIN))
coup(1) = Conjg(cplGluFucSuR(i1,iIN))
coup(4) = Conjg(cplcFuChiSuL(i1,gt1,gt3))
coup(3) = Conjg(cplcFuChiSuR(i1,gt1,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Chi Glu Su Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,1,gt3,Isum)= 0._dp
Else
gSum(gt1,1,gt3,Isum)=resD
End If
Contribution(gt1,1,gt3,Isum)='Fu'
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplChiFucSuL(gt1,i1,iIN)
coup(2) = cplChiFucSuR(gt1,i1,iIN)
coup(3) = cplcFuGluSuL(i1,gt3)
coup(4) = cplcFuGluSuR(i1,gt3)
coup(5) = cplChiFucSuL(gt1,i2,iIN)
coup(6) = cplChiFucSuR(gt1,i2,iIN)
coup(7) = cplcFuGluSuL(i2,gt3)
coup(8) = cplcFuGluSuR(i2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Chi Glu Su Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,1,gt3,Isum)= 0._dp
Else
gSum(gt1,1,gt3,Isum)= resS
End If
Contribution(gt1,1,gt3,Isum)='Fu,Fu'
End Do
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplChiFucSuL(gt1,i1,iIN)
coup(2) = cplChiFucSuR(gt1,i1,iIN)
coup(3) = cplcFuGluSuL(i1,gt3)
coup(4) = cplcFuGluSuR(i1,gt3)
coup(5) = cplGluFucSuL(i2,iIN)
coup(6) = cplGluFucSuR(i2,iIN)
coup(7) = cplcFuChiSuL(i2,gt1,gt3)
coup(8) = cplcFuChiSuR(i2,gt1,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Chi Glu Su Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,1,gt3,Isum)= 0._dp
Else
gSum(gt1,1,gt3,Isum)= resS
End If
Contribution(gt1,1,gt3,Isum)='Fu,Fu'
End Do
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplGluFucSuL(i1,iIN)
coup(2) = cplGluFucSuR(i1,iIN)
coup(3) = cplcFuChiSuL(i1,gt1,gt3)
coup(4) = cplcFuChiSuR(i1,gt1,gt3)
coup(5) = cplGluFucSuL(i2,iIN)
coup(6) = cplGluFucSuR(i2,iIN)
coup(7) = cplcFuChiSuL(i2,gt1,gt3)
coup(8) = cplcFuChiSuR(i2,gt1,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Chi Glu Su Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,1,gt3,Isum)= 0._dp
Else
gSum(gt1,1,gt3,Isum)= resS
End If
Contribution(gt1,1,gt3,Isum)='Fu,Fu'
End Do
End Do
Else
gSum(gt1,1,gt3,:)= 0._dp
End If
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,5
Do gt3=1, iIN-1
g(gt1,1,gt3)=Sum(gSum(gt1,1,gt3,1:36))
If (g(gt1,1,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,1,gt3)=0._dp
End If
End Do
End Do
End Subroutine SuToChiGluSu
Subroutine SuToSdChicCha(iIN,MSd,MChi,MCha,MVWm,MHpm,MFu,MFd,MSu,cplSdcHpmcSu, &
& cplSdcSucVWm,cplcChacFuSdL,cplcChacFuSdR,cplcChaChiHpmL,cplcChaChiHpmR,cplcChaChiVWmL, &
& cplcChaChiVWmR,cplcChaFdcSuL,cplcChaFdcSuR,cplcFdChiSdL,cplcFdChiSdR,cplChiFucSuL, &
& cplChiFucSuR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MSd(6),MChi(5),MCha(2),MVWm,MHpm(2),MFu(3),MFd(3),MSu(6)
Complex(dp),Intent(in) :: cplSdcHpmcSu(6,2,6),cplSdcSucVWm(6,6),cplcChacFuSdL(2,3,6),cplcChacFuSdR(2,3,6), &
& cplcChaChiHpmL(2,5,2),cplcChaChiHpmR(2,5,2),cplcChaChiVWmL(2,5),cplcChaChiVWmR(2,5), &
& cplcChaFdcSuL(2,3,6),cplcChaFdcSuR(2,3,6),cplcFdChiSdL(3,5,6),cplcFdChiSdR(3,5,6), &
& cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 81
Allocate( gSum(6,5,2, Isum) )
Allocate( Contribution(6,5,2, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,6
Do gt2=1,5
Do gt3=1,2
Isum = 0
rk2 = (MChi(gt2)/MSu(iIN))**2
rm2 = (MCha(gt3)/MSu(iIN))**2
rj2 = (MSd(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MCha(gt3))+Abs(MChi(gt2))+Abs(MSd(gt1)))) Then
!--------------
! conj[VWm]
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MVWm
mass(2) = MVWm
m_in = MSu(iIN)
coup(1) = Conjg(cplSdcSucVWm(gt1,iIN))
coup(3) = Conjg(cplcChaChiVWmL(gt3,gt2))
coup(2) = Conjg(cplcChaChiVWmR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: conj[VWm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm]'
!--------------
! conj[Hpm]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MHpm(i1)
mass(2) = MHpm(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplSdcHpmcSu(gt1,i1,iIN))
coup(3) = Conjg(cplcChaChiHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChiHpmR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: conj[Hpm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm]'
End Do
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(gt2,i1,iIN))
coup(1) = Conjg(cplChiFucSuR(gt2,i1,iIN))
coup(4) = Conjg(cplcChacFuSdL(gt3,i1,gt1))
coup(3) = Conjg(cplcChacFuSdR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fu'
End Do
!--------------
! Fd
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(gt3,i1,iIN))
coup(1) = Conjg(cplcChaFdcSuR(gt3,i1,iIN))
coup(4) = Conjg(cplcFdChiSdL(i1,gt2,gt1))
coup(3) = Conjg(cplcFdChiSdR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fd'
End Do
!--------------
! conj[VWm], conj[Hpm]
!--------------
Do i2=1,2
Isum = Isum + 1
resS = 0._dp
mass(2) = MVWm
mass(1) = MHpm(i2)
coup(1) = cplSdcSucVWm(gt1,iIN)
coup(2) = Conjg(cplcChaChiVWmL(gt3,gt2))
coup(3) = Conjg(cplcChaChiVWmR(gt3,gt2))
coup(4) = cplSdcHpmcSu(gt1,i2,iIN)
coup(5) = Conjg(cplcChaChiHpmL(gt3,gt2,i2))
coup(6) = Conjg(cplcChaChiHpmR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: conj[VWm],conj[Hpm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm],conj[Hpm]'
End Do
!--------------
! conj[VWm], Fu
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVWm2
mass(1) = MFu2(i2)
coup(1) = cplChiFucSuL(gt2,i2,iIN)
coup(2) = cplChiFucSuR(gt2,i2,iIN)
coup(4) = Conjg(cplcChacFuSdL(gt3,i2,gt1))
coup(3) = Conjg(cplcChacFuSdR(gt3,i2,gt1))
coup(5) = cplSdcSucVWm(gt1,iIN)
coup(7) = Conjg(cplcChaChiVWmL(gt3,gt2))
coup(6) = Conjg(cplcChaChiVWmR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: conj[VWm],Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm],Fu'
End Do
!--------------
! conj[VWm], Fd
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVWm2
mass(1) = MFd2(i2)
coup(1) = cplcChaFdcSuL(gt3,i2,iIN)
coup(2) = cplcChaFdcSuR(gt3,i2,iIN)
coup(4) = Conjg(cplcFdChiSdL(i2,gt2,gt1))
coup(3) = Conjg(cplcFdChiSdR(i2,gt2,gt1))
coup(5) = cplSdcSucVWm(gt1,iIN)
coup(7) = Conjg(cplcChaChiVWmL(gt3,gt2))
coup(6) = Conjg(cplcChaChiVWmR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: conj[VWm],Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm],Fd'
End Do
!--------------
! conj[Hpm], conj[Hpm]
!--------------
Do i1=1,1
Do i2=i1+1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MHpm(i1)
mass(2) = MHpm(i2)
coup(1) = cplSdcHpmcSu(gt1,i1,iIN)
coup(3) = Conjg(cplcChaChiHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChiHpmR(gt3,gt2,i1))
coup(4) = cplSdcHpmcSu(gt1,i2,iIN)
coup(6) = Conjg(cplcChaChiHpmL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaChiHpmR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: conj[Hpm],conj[Hpm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm],conj[Hpm]'
End Do
End Do
!--------------
! conj[Hpm], Fu
!--------------
Do i1=1,2
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MHpm(i1)
mass(1) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i2,iIN)
coup(2) = cplChiFucSuR(gt2,i2,iIN)
coup(4) = Conjg(cplcChacFuSdL(gt3,i2,gt1))
coup(3) = Conjg(cplcChacFuSdR(gt3,i2,gt1))
coup(5) = cplSdcHpmcSu(gt1,i1,iIN)
coup(7) = Conjg(cplcChaChiHpmL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChiHpmR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: conj[Hpm],Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm],Fu'
End Do
End Do
!--------------
! conj[Hpm], Fd
!--------------
Do i1=1,2
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MHpm(i1)
mass(1) = MFd(i2)
coup(1) = cplcChaFdcSuL(gt3,i2,iIN)
coup(2) = cplcChaFdcSuR(gt3,i2,iIN)
coup(4) = Conjg(cplcFdChiSdL(i2,gt2,gt1))
coup(3) = Conjg(cplcFdChiSdR(i2,gt2,gt1))
coup(5) = cplSdcHpmcSu(gt1,i1,iIN)
coup(7) = Conjg(cplcChaChiHpmL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChiHpmR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: conj[Hpm],Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm],Fd'
End Do
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplChiFucSuL(gt2,i1,iIN)
coup(2) = cplChiFucSuR(gt2,i1,iIN)
coup(3) = cplcChacFuSdL(gt3,i1,gt1)
coup(4) = cplcChacFuSdR(gt3,i1,gt1)
coup(5) = cplChiFucSuL(gt2,i2,iIN)
coup(6) = cplChiFucSuR(gt2,i2,iIN)
coup(7) = cplcChacFuSdL(gt3,i2,gt1)
coup(8) = cplcChacFuSdR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fu,Fu'
End Do
End Do
!--------------
! Fu, Fd
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFd(i2)
coup(1) = cplChiFucSuL(gt2,i1,iIN)
coup(2) = cplChiFucSuR(gt2,i1,iIN)
coup(3) = cplcChacFuSdL(gt3,i1,gt1)
coup(4) = cplcChacFuSdR(gt3,i1,gt1)
coup(5) = cplcChaFdcSuL(gt3,i2,iIN)
coup(6) = cplcChaFdcSuR(gt3,i2,iIN)
coup(7) = cplcFdChiSdL(i2,gt2,gt1)
coup(8) = cplcFdChiSdR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: Fu,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fu,Fd'
End Do
End Do
!--------------
! Fd, Fd
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i2)
coup(1) = cplcChaFdcSuL(gt3,i1,iIN)
coup(2) = cplcChaFdcSuR(gt3,i1,iIN)
coup(3) = cplcFdChiSdL(i1,gt2,gt1)
coup(4) = cplcFdChiSdR(i1,gt2,gt1)
coup(5) = cplcChaFdcSuL(gt3,i2,iIN)
coup(6) = cplcChaFdcSuR(gt3,i2,iIN)
coup(7) = cplcFdChiSdL(i2,gt2,gt1)
coup(8) = cplcFdChiSdR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Chi cCha Propagator: Fd,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fd,Fd'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,6
Do gt2=1,5
Do gt3=1,2
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:81))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToSdChicCha
Subroutine SuToFdFucSd(iIN,MFd,MFu,MSd,MCha,MChi,MGlu,MSu,cplcChaFdcSuL, &
& cplcChaFdcSuR,cplChaFucSdL,cplChaFucSdR,cplChiFdcSdL,cplChiFdcSdR,cplChiFucSuL, &
& cplChiFucSuR,cplGluFdcSdL,cplGluFdcSdR,cplGluFucSuL,cplGluFucSuR,deltaM, &
& epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MFd(3),MFu(3),MSd(6),MCha(2),MChi(5),MGlu,MSu(6)
Complex(dp),Intent(in) :: cplcChaFdcSuL(2,3,6),cplcChaFdcSuR(2,3,6),cplChaFucSdL(2,3,6),cplChaFucSdR(2,3,6), &
& cplChiFdcSdL(5,3,6),cplChiFdcSdR(5,3,6),cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6), &
& cplGluFdcSdL(3,6),cplGluFdcSdR(3,6),cplGluFucSuL(3,6),cplGluFucSuR(3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 64
Allocate( gSum(3,3,6, Isum) )
Allocate( Contribution(3,3,6, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=1,3
Do gt3=1,6
Isum = 0
rk2 = (MFd(gt1)/MSu(iIN))**2
rm2 = (MFu(gt2)/MSu(iIN))**2
rj2 = (MSd(gt3)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MSd(gt3))+Abs(MFu(gt2))+Abs(MFd(gt1)))) Then
!--------------
! bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(i1,gt1,iIN))
coup(1) = Conjg(cplcChaFdcSuR(i1,gt1,iIN))
coup(4) = Conjg(cplChaFucSdL(i1,gt2,gt3))
coup(3) = Conjg(cplChaFucSdR(i1,gt2,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd Fu cSd Propagator: bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
End Do
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt2,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt2,iIN))
coup(4) = Conjg(cplChiFdcSdL(i1,gt1,gt3))
coup(3) = Conjg(cplChiFdcSdR(i1,gt1,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd Fu cSd Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Glu
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MGlu
mass(2) = MGlu
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(gt2,iIN))
coup(1) = Conjg(cplGluFucSuR(gt2,iIN))
coup(4) = Conjg(cplGluFdcSdL(gt1,gt3))
coup(3) = Conjg(cplGluFdcSdR(gt1,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd Fu cSd Propagator: Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Glu'
!--------------
! bar[Cha], bar[Cha]
!--------------
Do i1=1,1
Do i2=i1+1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFdcSuL(i1,gt1,iIN)
coup(2) = cplcChaFdcSuR(i1,gt1,iIN)
coup(3) = cplChaFucSdL(i1,gt2,gt3)
coup(4) = cplChaFucSdR(i1,gt2,gt3)
coup(5) = cplcChaFdcSuL(i2,gt1,iIN)
coup(6) = cplcChaFdcSuR(i2,gt1,iIN)
coup(7) = cplChaFucSdL(i2,gt2,gt3)
coup(8) = cplChaFucSdR(i2,gt2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd Fu cSd Propagator: bar[Cha],bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
End Do
End Do
!--------------
! bar[Cha], Chi
!--------------
Do i1=1,2
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MChi(i2)
coup(1) = cplcChaFdcSuL(i1,gt1,iIN)
coup(2) = cplcChaFdcSuR(i1,gt1,iIN)
coup(3) = cplChaFucSdL(i1,gt2,gt3)
coup(4) = cplChaFucSdR(i1,gt2,gt3)
coup(5) = cplChiFucSuL(i2,gt2,iIN)
coup(6) = cplChiFucSuR(i2,gt2,iIN)
coup(7) = cplChiFdcSdL(i2,gt1,gt3)
coup(8) = cplChiFdcSdR(i2,gt1,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd Fu cSd Propagator: bar[Cha],Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],Chi'
End Do
End Do
!--------------
! bar[Cha], Glu
!--------------
Do i1=1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MGlu
coup(1) = cplcChaFdcSuL(i1,gt1,iIN)
coup(2) = cplcChaFdcSuR(i1,gt1,iIN)
coup(3) = cplChaFucSdL(i1,gt2,gt3)
coup(4) = cplChaFucSdR(i1,gt2,gt3)
coup(5) = cplGluFucSuL(gt2,iIN)
coup(6) = cplGluFucSuR(gt2,iIN)
coup(7) = cplGluFdcSdL(gt1,gt3)
coup(8) = cplGluFdcSdR(gt1,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd Fu cSd Propagator: bar[Cha],Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],Glu'
End Do
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplChiFdcSdL(i1,gt1,gt3)
coup(4) = cplChiFdcSdR(i1,gt1,gt3)
coup(5) = cplChiFucSuL(i2,gt2,iIN)
coup(6) = cplChiFucSuR(i2,gt2,iIN)
coup(7) = cplChiFdcSdL(i2,gt1,gt3)
coup(8) = cplChiFdcSdR(i2,gt1,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd Fu cSd Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
!--------------
! Chi, Glu
!--------------
Do i1=1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MGlu
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplChiFdcSdL(i1,gt1,gt3)
coup(4) = cplChiFdcSdR(i1,gt1,gt3)
coup(5) = cplGluFucSuL(gt2,iIN)
coup(6) = cplGluFucSuR(gt2,iIN)
coup(7) = cplGluFdcSdL(gt1,gt3)
coup(8) = cplGluFdcSdR(gt1,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 0*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd Fu cSd Propagator: Chi,Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Glu'
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=1,3
Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:64))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToFdFucSd
Subroutine SuToFdFvcSe(iIN,MFd,MFv,MSe,MCha,MSu,cplcChaFdcSuL,cplcChaFdcSuR, &
& cplFvChacSeL,cplFvChacSeR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MFd(3),MFv(6),MSe(6),MCha(2),MSu(6)
Complex(dp),Intent(in) :: cplcChaFdcSuL(2,3,6),cplcChaFdcSuR(2,3,6),cplFvChacSeL(6,2,6),cplFvChacSeR(6,2,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 4
Allocate( gSum(3,6,6, Isum) )
Allocate( Contribution(3,6,6, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=1,6
Do gt3=1,6
Isum = 0
rk2 = (MFd(gt1)/MSu(iIN))**2
rm2 = (MFv(gt2)/MSu(iIN))**2
rj2 = (MSe(gt3)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MSe(gt3))+Abs(MFv(gt2))+Abs(MFd(gt1)))) Then
!--------------
! bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(i1,gt1,iIN))
coup(1) = Conjg(cplcChaFdcSuR(i1,gt1,iIN))
coup(4) = Conjg(cplFvChacSeL(gt2,i1,gt3))
coup(3) = Conjg(cplFvChacSeR(gt2,i1,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd Fv cSe Propagator: bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
End Do
!--------------
! bar[Cha], bar[Cha]
!--------------
Do i1=1,1
Do i2=i1+1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFdcSuL(i1,gt1,iIN)
coup(2) = cplcChaFdcSuR(i1,gt1,iIN)
coup(3) = cplFvChacSeL(gt2,i1,gt3)
coup(4) = cplFvChacSeR(gt2,i1,gt3)
coup(5) = cplcChaFdcSuL(i2,gt1,iIN)
coup(6) = cplcChaFdcSuR(i2,gt1,iIN)
coup(7) = cplFvChacSeL(gt2,i2,gt3)
coup(8) = cplFvChacSeR(gt2,i2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd Fv cSe Propagator: bar[Cha],bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=1,6
Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:4))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToFdFvcSe
Subroutine SuTohhFdcCha(iIN,Mhh,MFd,MCha,MSu,cplhhSucSu,cplcChaChahhL,cplcChaChahhR, &
& cplcChaFdcSuL,cplcChaFdcSuR,cplcFdFdhhL,cplcFdFdhhR,deltaM,epsI,check,g, &
& WriteContributions)
Implicit None
Real(dp),Intent(in) :: Mhh(3),MFd(3),MCha(2),MSu(6)
Complex(dp),Intent(in) :: cplhhSucSu(3,6,6),cplcChaChahhL(2,2,3),cplcChaChahhR(2,2,3),cplcChaFdcSuL(2,3,6), &
& cplcChaFdcSuR(2,3,6),cplcFdFdhhL(3,3,3),cplcFdFdhhR(3,3,3)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 121
Allocate( gSum(3,3,2, Isum) )
Allocate( Contribution(3,3,2, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=1,3
Do gt3=1,2
Isum = 0
rk2 = (MFd(gt2)/MSu(iIN))**2
rm2 = (MCha(gt3)/MSu(iIN))**2
rj2 = (Mhh(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MCha(gt3))+Abs(MFd(gt2))+Abs(Mhh(gt1)))) Then
!--------------
! Su
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplhhSucSu(gt1,i1,iIN))
coup(3) = Conjg(cplcChaFdcSuL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaFdcSuR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fd cCha Propagator: Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Su'
End Do
!--------------
! bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(i1,gt2,iIN))
coup(1) = Conjg(cplcChaFdcSuR(i1,gt2,iIN))
coup(4) = Conjg(cplcChaChahhL(gt3,i1,gt1))
coup(3) = Conjg(cplcChaChahhR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fd cCha Propagator: bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
End Do
!--------------
! Fd
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(gt3,i1,iIN))
coup(1) = Conjg(cplcChaFdcSuR(gt3,i1,iIN))
coup(4) = Conjg(cplcFdFdhhL(i1,gt2,gt1))
coup(3) = Conjg(cplcFdFdhhR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fd cCha Propagator: Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fd'
End Do
!--------------
! Su, Su
!--------------
Do i1=1,5
Do i2=i1+1,6
Isum = Isum + 1
resS = 0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i2)
coup(1) = cplhhSucSu(gt1,i1,iIN)
coup(3) = Conjg(cplcChaFdcSuL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaFdcSuR(gt3,gt2,i1))
coup(4) = cplhhSucSu(gt1,i2,iIN)
coup(6) = Conjg(cplcChaFdcSuL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaFdcSuR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fd cCha Propagator: Su,Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,Su'
End Do
End Do
!--------------
! Su, bar[Cha]
!--------------
Do i1=1,6
Do i2=1,2
Isum = Isum + 1
resS = 0._dp
mass(2) = MSu(i1)
mass(1) = MCha(i2)
coup(1) = cplcChaFdcSuL(i2,gt2,iIN)
coup(2) = cplcChaFdcSuR(i2,gt2,iIN)
coup(4) = Conjg(cplcChaChahhL(gt3,i2,gt1))
coup(3) = Conjg(cplcChaChahhR(gt3,i2,gt1))
coup(5) = cplhhSucSu(gt1,i1,iIN)
coup(7) = Conjg(cplcChaFdcSuL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaFdcSuR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fd cCha Propagator: Su,bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,bar[Cha]'
End Do
End Do
!--------------
! Su, Fd
!--------------
Do i1=1,6
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MSu(i1)
mass(1) = MFd(i2)
coup(1) = cplcChaFdcSuL(gt3,i2,iIN)
coup(2) = cplcChaFdcSuR(gt3,i2,iIN)
coup(4) = Conjg(cplcFdFdhhL(i2,gt2,gt1))
coup(3) = Conjg(cplcFdFdhhR(i2,gt2,gt1))
coup(5) = cplhhSucSu(gt1,i1,iIN)
coup(7) = Conjg(cplcChaFdcSuL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaFdcSuR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fd cCha Propagator: Su,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Su,Fd'
End Do
End Do
!--------------
! bar[Cha], bar[Cha]
!--------------
Do i1=1,1
Do i2=i1+1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFdcSuL(i1,gt2,iIN)
coup(2) = cplcChaFdcSuR(i1,gt2,iIN)
coup(3) = cplcChaChahhL(gt3,i1,gt1)
coup(4) = cplcChaChahhR(gt3,i1,gt1)
coup(5) = cplcChaFdcSuL(i2,gt2,iIN)
coup(6) = cplcChaFdcSuR(i2,gt2,iIN)
coup(7) = cplcChaChahhL(gt3,i2,gt1)
coup(8) = cplcChaChahhR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fd cCha Propagator: bar[Cha],bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
End Do
End Do
!--------------
! bar[Cha], Fd
!--------------
Do i1=1,2
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MFd(i2)
coup(1) = cplcChaFdcSuL(i1,gt2,iIN)
coup(2) = cplcChaFdcSuR(i1,gt2,iIN)
coup(3) = cplcChaChahhL(gt3,i1,gt1)
coup(4) = cplcChaChahhR(gt3,i1,gt1)
coup(5) = cplcChaFdcSuL(gt3,i2,iIN)
coup(6) = cplcChaFdcSuR(gt3,i2,iIN)
coup(7) = cplcFdFdhhL(i2,gt2,gt1)
coup(8) = cplcFdFdhhR(i2,gt2,gt1)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fd cCha Propagator: bar[Cha],Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],Fd'
End Do
End Do
!--------------
! Fd, Fd
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i2)
coup(1) = cplcChaFdcSuL(gt3,i1,iIN)
coup(2) = cplcChaFdcSuR(gt3,i1,iIN)
coup(3) = cplcFdFdhhL(i1,gt2,gt1)
coup(4) = cplcFdFdhhR(i1,gt2,gt1)
coup(5) = cplcChaFdcSuL(gt3,i2,iIN)
coup(6) = cplcChaFdcSuR(gt3,i2,iIN)
coup(7) = cplcFdFdhhL(i2,gt2,gt1)
coup(8) = cplcFdFdhhR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fd cCha Propagator: Fd,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fd,Fd'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=1,3
Do gt3=1,2
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:121))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuTohhFdcCha
Subroutine SuToSuFdcFd(iIN,MSu,MFd,MVZ,MAh,Mhh,MCha,cplAhSucSu,cplhhSucSu, &
& cplSucSuVZ,cplcChaFdcSuL,cplcChaFdcSuR,cplcFdChaSuL,cplcFdChaSuR,cplcFdFdAhL, &
& cplcFdFdAhR,cplcFdFdhhL,cplcFdFdhhR,cplcFdFdVZL,cplcFdFdVZR,deltaM,epsI, &
& check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MSu(6),MFd(3),MVZ,MAh(3),Mhh(3),MCha(2)
Complex(dp),Intent(in) :: cplAhSucSu(3,6,6),cplhhSucSu(3,6,6),cplSucSuVZ(6,6),cplcChaFdcSuL(2,3,6), &
& cplcChaFdcSuR(2,3,6),cplcFdChaSuL(3,2,6),cplcFdChaSuR(3,2,6),cplcFdFdAhL(3,3,3), &
& cplcFdFdAhR(3,3,3),cplcFdFdhhL(3,3,3),cplcFdFdhhR(3,3,3),cplcFdFdVZL(3,3), &
& cplcFdFdVZR(3,3)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 81
Allocate( gSum(6,3,3, Isum) )
Allocate( Contribution(6,3,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1, iIN-1
Do gt2=1,3
Do gt3=1,3
Isum = 0
rk2 = (MFd(gt2)/MSu(iIN))**2
rm2 = (MFd(gt3)/MSu(iIN))**2
rj2 = (MSu(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFd(gt3))+Abs(MFd(gt2))+Abs(MSu(gt1)))) Then
!--------------
! VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MVZ
mass(2) = MVZ
m_in = MSu(iIN)
coup(1) = Conjg(cplSucSuVZ(gt1,iIN))
coup(3) = Conjg(cplcFdFdVZL(gt3,gt2))
coup(2) = Conjg(cplcFdFdVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: VZ"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'
!--------------
! Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplAhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplcFdFdAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
End Do
!--------------
! hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplhhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplcFdFdhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdhhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
End Do
!--------------
! bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(i1,gt2,iIN))
coup(1) = Conjg(cplcChaFdcSuR(i1,gt2,iIN))
coup(4) = Conjg(cplcFdChaSuL(gt3,i1,gt1))
coup(3) = Conjg(cplcFdChaSuR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
End Do
!--------------
! VZ, Ah
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplcFdFdVZL(gt3,gt2))
coup(3) = Conjg(cplcFdFdVZR(gt3,gt2))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplcFdFdAhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFdFdAhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: VZ,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
End Do
!--------------
! VZ, hh
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplcFdFdVZL(gt3,gt2))
coup(3) = Conjg(cplcFdFdVZR(gt3,gt2))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplcFdFdhhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFdFdhhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: VZ,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
End Do
!--------------
! VZ, bar[Cha]
!--------------
Do i2=1,2
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ2
mass(1) = MCha2(i2)
coup(1) = cplcChaFdcSuL(i2,gt2,iIN)
coup(2) = cplcChaFdcSuR(i2,gt2,iIN)
coup(4) = Conjg(cplcFdChaSuL(gt3,i2,gt1))
coup(3) = Conjg(cplcFdChaSuR(gt3,i2,gt1))
coup(5) = cplSucSuVZ(gt1,iIN)
coup(7) = Conjg(cplcFdFdVZL(gt3,gt2))
coup(6) = Conjg(cplcFdFdVZR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: VZ,bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,bar[Cha]'
End Do
!--------------
! Ah, Ah
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcFdFdAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdAhR(gt3,gt2,i1))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcFdFdAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFdFdAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: Ah,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
End Do
End Do
!--------------
! Ah, hh
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcFdFdAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdAhR(gt3,gt2,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcFdFdhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFdFdhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: Ah,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
End Do
End Do
!--------------
! Ah, bar[Cha]
!--------------
Do i1=1,3
Do i2=1,2
Isum = Isum + 1
resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MCha(i2)
coup(1) = cplcChaFdcSuL(i2,gt2,iIN)
coup(2) = cplcChaFdcSuR(i2,gt2,iIN)
coup(4) = Conjg(cplcFdChaSuL(gt3,i2,gt1))
coup(3) = Conjg(cplcFdChaSuR(gt3,i2,gt1))
coup(5) = cplAhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplcFdFdAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFdFdAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: Ah,bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,bar[Cha]'
End Do
End Do
!--------------
! hh, hh
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcFdFdhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFdhhR(gt3,gt2,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcFdFdhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFdFdhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: hh,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
End Do
End Do
!--------------
! hh, bar[Cha]
!--------------
Do i1=1,3
Do i2=1,2
Isum = Isum + 1
resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MCha(i2)
coup(1) = cplcChaFdcSuL(i2,gt2,iIN)
coup(2) = cplcChaFdcSuR(i2,gt2,iIN)
coup(4) = Conjg(cplcFdChaSuL(gt3,i2,gt1))
coup(3) = Conjg(cplcFdChaSuR(gt3,i2,gt1))
coup(5) = cplhhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplcFdFdhhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFdFdhhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: hh,bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,bar[Cha]'
End Do
End Do
!--------------
! bar[Cha], bar[Cha]
!--------------
Do i1=1,1
Do i2=i1+1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFdcSuL(i1,gt2,iIN)
coup(2) = cplcChaFdcSuR(i1,gt2,iIN)
coup(3) = cplcFdChaSuL(gt3,i1,gt1)
coup(4) = cplcFdChaSuR(gt3,i1,gt1)
coup(5) = cplcChaFdcSuL(i2,gt2,iIN)
coup(6) = cplcChaFdcSuR(i2,gt2,iIN)
coup(7) = cplcFdChaSuL(gt3,i2,gt1)
coup(8) = cplcFdChaSuR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fd cFd Propagator: bar[Cha],bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1, iIN-1
Do gt2=1,3
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:81))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToSuFdcFd
Subroutine SuToFdSvImcFe(iIN,MFd,MSvIm,MFe,MCha,MSu,cplcChaFdcSuL,cplcChaFdcSuR, &
& cplcFeChaSvImL,cplcFeChaSvImR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MFd(3),MSvIm(6),MFe(3),MCha(2),MSu(6)
Complex(dp),Intent(in) :: cplcChaFdcSuL(2,3,6),cplcChaFdcSuR(2,3,6),cplcFeChaSvImL(3,2,6),cplcFeChaSvImR(3,2,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 4
Allocate( gSum(3,6,3, Isum) )
Allocate( Contribution(3,6,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=1,6
Do gt3=1,3
Isum = 0
rk2 = (MFd(gt1)/MSu(iIN))**2
rm2 = (MFe(gt3)/MSu(iIN))**2
rj2 = (MSvIm(gt2)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFe(gt3))+Abs(MSvIm(gt2))+Abs(MFd(gt1)))) Then
!--------------
! bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(i1,gt1,iIN))
coup(1) = Conjg(cplcChaFdcSuR(i1,gt1,iIN))
coup(4) = Conjg(cplcFeChaSvImL(gt3,i1,gt2))
coup(3) = Conjg(cplcFeChaSvImR(gt3,i1,gt2))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd SvIm cFe Propagator: bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
End Do
!--------------
! bar[Cha], bar[Cha]
!--------------
Do i1=1,1
Do i2=i1+1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFdcSuL(i1,gt1,iIN)
coup(2) = cplcChaFdcSuR(i1,gt1,iIN)
coup(3) = cplcFeChaSvImL(gt3,i1,gt2)
coup(4) = cplcFeChaSvImR(gt3,i1,gt2)
coup(5) = cplcChaFdcSuL(i2,gt1,iIN)
coup(6) = cplcChaFdcSuR(i2,gt1,iIN)
coup(7) = cplcFeChaSvImL(gt3,i2,gt2)
coup(8) = cplcFeChaSvImR(gt3,i2,gt2)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd SvIm cFe Propagator: bar[Cha],bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=1,6
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:4))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToFdSvImcFe
Subroutine SuToFdSvRecFe(iIN,MFd,MSvRe,MFe,MCha,MSu,cplcChaFdcSuL,cplcChaFdcSuR, &
& cplcFeChaSvReL,cplcFeChaSvReR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MFd(3),MSvRe(6),MFe(3),MCha(2),MSu(6)
Complex(dp),Intent(in) :: cplcChaFdcSuL(2,3,6),cplcChaFdcSuR(2,3,6),cplcFeChaSvReL(3,2,6),cplcFeChaSvReR(3,2,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 4
Allocate( gSum(3,6,3, Isum) )
Allocate( Contribution(3,6,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=1,6
Do gt3=1,3
Isum = 0
rk2 = (MFd(gt1)/MSu(iIN))**2
rm2 = (MFe(gt3)/MSu(iIN))**2
rj2 = (MSvRe(gt2)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFe(gt3))+Abs(MSvRe(gt2))+Abs(MFd(gt1)))) Then
!--------------
! bar[Cha]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(i1,gt1,iIN))
coup(1) = Conjg(cplcChaFdcSuR(i1,gt1,iIN))
coup(4) = Conjg(cplcFeChaSvReL(gt3,i1,gt2))
coup(3) = Conjg(cplcFeChaSvReR(gt3,i1,gt2))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd SvRe cFe Propagator: bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha]'
End Do
!--------------
! bar[Cha], bar[Cha]
!--------------
Do i1=1,1
Do i2=i1+1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MCha(i1)
mass(2) = MCha(i2)
coup(1) = cplcChaFdcSuL(i1,gt1,iIN)
coup(2) = cplcChaFdcSuR(i1,gt1,iIN)
coup(3) = cplcFeChaSvReL(gt3,i1,gt2)
coup(4) = cplcFeChaSvReR(gt3,i1,gt2)
coup(5) = cplcChaFdcSuL(i2,gt1,iIN)
coup(6) = cplcChaFdcSuR(i2,gt1,iIN)
coup(7) = cplcFeChaSvReL(gt3,i2,gt2)
coup(8) = cplcFeChaSvReR(gt3,i2,gt2)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fd SvRe cFe Propagator: bar[Cha],bar[Cha]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='bar[Cha],bar[Cha]'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=1,6
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:4))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToFdSvRecFe
Subroutine SuTocHpmChaFu(iIN,MHpm,MCha,MFu,MSd,MChi,MSu,cplSdcHpmcSu,cplChaFucSdL, &
& cplChaFucSdR,cplChiChacHpmL,cplChiChacHpmR,cplChiFucSuL,cplChiFucSuR,deltaM, &
& epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MHpm(2),MCha(2),MFu(3),MSd(6),MChi(5),MSu(6)
Complex(dp),Intent(in) :: cplSdcHpmcSu(6,2,6),cplChaFucSdL(2,3,6),cplChaFucSdR(2,3,6),cplChiChacHpmL(5,2,2), &
& cplChiChacHpmR(5,2,2),cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 121
Allocate( gSum(2,2,3, Isum) )
Allocate( Contribution(2,2,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=2,2
Do gt2=1,2
Do gt3=1,3
Isum = 0
rk2 = (MCha(gt2)/MSu(iIN))**2
rm2 = (MFu(gt3)/MSu(iIN))**2
rj2 = (MHpm(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFu(gt3))+Abs(MCha(gt2))+Abs(MHpm(gt1)))) Then
!--------------
! Sd
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MSd(i1)
mass(2) = MSd(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplSdcHpmcSu(i1,gt1,iIN))
coup(3) = Conjg(cplChaFucSdL(gt2,gt3,i1))
coup(2) = Conjg(cplChaFucSdR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Cha Fu Propagator: Sd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Sd'
End Do
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt3,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt3,iIN))
coup(4) = Conjg(cplChiChacHpmL(i1,gt2,gt1))
coup(3) = Conjg(cplChiChacHpmR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Cha Fu Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Sd, Sd
!--------------
Do i1=1,5
Do i2=i1+1,6
Isum = Isum + 1
resS = 0._dp
mass(1) = MSd(i1)
mass(2) = MSd(i2)
coup(1) = cplSdcHpmcSu(i1,gt1,iIN)
coup(3) = Conjg(cplChaFucSdL(gt2,gt3,i1))
coup(2) = Conjg(cplChaFucSdR(gt2,gt3,i1))
coup(4) = cplSdcHpmcSu(i2,gt1,iIN)
coup(6) = Conjg(cplChaFucSdL(gt2,gt3,i2))
coup(5) = Conjg(cplChaFucSdR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Cha Fu Propagator: Sd,Sd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Sd,Sd'
End Do
End Do
!--------------
! Sd, Chi
!--------------
Do i1=1,6
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(2) = MSd(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFucSuL(i2,gt3,iIN)
coup(2) = cplChiFucSuR(i2,gt3,iIN)
coup(4) = Conjg(cplChiChacHpmL(i2,gt2,gt1))
coup(3) = Conjg(cplChiChacHpmR(i2,gt2,gt1))
coup(5) = cplSdcHpmcSu(i1,gt1,iIN)
coup(7) = Conjg(cplChaFucSdL(gt2,gt3,i1))
coup(6) = Conjg(cplChaFucSdR(gt2,gt3,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Cha Fu Propagator: Sd,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Sd,Chi'
End Do
End Do
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt3,iIN)
coup(2) = cplChiFucSuR(i1,gt3,iIN)
coup(3) = cplChiChacHpmL(i1,gt2,gt1)
coup(4) = cplChiChacHpmR(i1,gt2,gt1)
coup(5) = cplChiFucSuL(i2,gt3,iIN)
coup(6) = cplChiFucSuR(i2,gt3,iIN)
coup(7) = cplChiChacHpmL(i2,gt2,gt1)
coup(8) = cplChiChacHpmR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Cha Fu Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=2,2
Do gt2=1,2
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:121))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuTocHpmChaFu
Subroutine SuToFuFecSe(iIN,MFu,MFe,MSe,MChi,MSu,cplChiFecSeL,cplChiFecSeR, &
& cplChiFucSuL,cplChiFucSuR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MFu(3),MFe(3),MSe(6),MChi(5),MSu(6)
Complex(dp),Intent(in) :: cplChiFecSeL(5,3,6),cplChiFecSeR(5,3,6),cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 25
Allocate( gSum(3,3,6, Isum) )
Allocate( Contribution(3,3,6, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=1,3
Do gt3=1,6
Isum = 0
rk2 = (MFu(gt1)/MSu(iIN))**2
rm2 = (MFe(gt2)/MSu(iIN))**2
rj2 = (MSe(gt3)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MSe(gt3))+Abs(MFe(gt2))+Abs(MFu(gt1)))) Then
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt1,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt1,iIN))
coup(4) = Conjg(cplChiFecSeL(i1,gt2,gt3))
coup(3) = Conjg(cplChiFecSeR(i1,gt2,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Fe cSe Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt1,iIN)
coup(2) = cplChiFucSuR(i1,gt1,iIN)
coup(3) = cplChiFecSeL(i1,gt2,gt3)
coup(4) = cplChiFecSeR(i1,gt2,gt3)
coup(5) = cplChiFucSuL(i2,gt1,iIN)
coup(6) = cplChiFucSuR(i2,gt1,iIN)
coup(7) = cplChiFecSeL(i2,gt2,gt3)
coup(8) = cplChiFecSeR(i2,gt2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Fe cSe Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=1,3
Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:25))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToFuFecSe
Subroutine SuToFuFucSu(iIN,MFu,MSu,MChi,MGlu,cplChiFucSuL,cplChiFucSuR, &
& cplGluFucSuL,cplGluFucSuR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MFu(3),MSu(6),MChi(5),MGlu
Complex(dp),Intent(in) :: cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6),cplGluFucSuL(3,6),cplGluFucSuR(3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 36
Allocate( gSum(3,3,6, Isum) )
Allocate( Contribution(3,3,6, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=gt1,3
Do gt3=1,6
Isum = 0
rk2 = (MFu(gt1)/MSu(iIN))**2
rm2 = (MFu(gt2)/MSu(iIN))**2
rj2 = (MSu(gt3)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MSu(gt3))+Abs(MFu(gt2))+Abs(MFu(gt1)))) Then
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt1,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt1,iIN))
coup(4) = Conjg(cplChiFucSuL(i1,gt2,gt3))
coup(3) = Conjg(cplChiFucSuR(i1,gt2,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt2,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt2,iIN))
coup(4) = Conjg(cplChiFucSuL(i1,gt1,gt3))
coup(3) = Conjg(cplChiFucSuR(i1,gt1,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MChi(i1)
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplChiFucSuL(i1,gt1,gt3)
coup(4) = cplChiFucSuR(i1,gt1,gt3)
coup(5) = cplChiFucSuL(i1,gt1,iIN)
coup(6) = cplChiFucSuR(i1,gt1,iIN)
coup(7) = cplChiFucSuL(i1,gt2,gt3)
coup(8) = cplChiFucSuR(i1,gt2,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Fu cSu Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Glu
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MGlu
mass(2) = MGlu
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(gt1,iIN))
coup(1) = Conjg(cplGluFucSuR(gt1,iIN))
coup(4) = Conjg(cplGluFucSuL(gt2,gt3))
coup(3) = Conjg(cplGluFucSuR(gt2,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp/3._dp*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MGlu
mass(2) = MGlu
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(gt2,iIN))
coup(1) = Conjg(cplGluFucSuR(gt2,iIN))
coup(4) = Conjg(cplGluFucSuL(gt1,gt3))
coup(3) = Conjg(cplGluFucSuR(gt1,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp/3._dp*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MGlu
mass(2) = MGlu
coup(1) = cplGluFucSuL(gt2,iIN)
coup(2) = cplGluFucSuR(gt2,iIN)
coup(3) = cplGluFucSuL(gt1,gt3)
coup(4) = cplGluFucSuR(gt1,gt3)
coup(5) = cplGluFucSuL(gt1,iIN)
coup(6) = cplGluFucSuR(gt1,iIN)
coup(7) = cplGluFucSuL(gt2,gt3)
coup(8) = cplGluFucSuR(gt2,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 2._dp/3._dp*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Fu cSu Propagator: Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Glu'
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt1,iIN)
coup(2) = cplChiFucSuR(i1,gt1,iIN)
coup(3) = cplChiFucSuL(i1,gt2,gt3)
coup(4) = cplChiFucSuR(i1,gt2,gt3)
coup(5) = cplChiFucSuL(i2,gt1,iIN)
coup(6) = cplChiFucSuR(i2,gt1,iIN)
coup(7) = cplChiFucSuL(i2,gt2,gt3)
coup(8) = cplChiFucSuR(i2,gt2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplChiFucSuL(i1,gt1,gt3)
coup(4) = cplChiFucSuR(i1,gt1,gt3)
coup(5) = cplChiFucSuL(i2,gt1,iIN)
coup(6) = cplChiFucSuR(i2,gt1,iIN)
coup(7) = cplChiFucSuL(i2,gt2,gt3)
coup(8) = cplChiFucSuR(i2,gt2,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplChiFucSuL(i1,gt1,gt3)
coup(4) = cplChiFucSuR(i1,gt1,gt3)
coup(5) = cplChiFucSuL(i2,gt2,iIN)
coup(6) = cplChiFucSuR(i2,gt2,iIN)
coup(7) = cplChiFucSuL(i2,gt1,gt3)
coup(8) = cplChiFucSuR(i2,gt1,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt1,iIN)
coup(2) = cplChiFucSuR(i1,gt1,iIN)
coup(3) = cplChiFucSuL(i1,gt2,gt3)
coup(4) = cplChiFucSuR(i1,gt2,gt3)
coup(5) = cplChiFucSuL(i2,gt2,iIN)
coup(6) = cplChiFucSuR(i2,gt2,iIN)
coup(7) = cplChiFucSuL(i2,gt1,gt3)
coup(8) = cplChiFucSuR(i2,gt1,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Fu cSu Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
!--------------
! Chi, Glu
!--------------
Do i1=1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MGlu
coup(1) = cplChiFucSuL(i1,gt1,iIN)
coup(2) = cplChiFucSuR(i1,gt1,iIN)
coup(3) = cplChiFucSuL(i1,gt2,gt3)
coup(4) = cplChiFucSuR(i1,gt2,gt3)
coup(5) = cplGluFucSuL(gt1,iIN)
coup(6) = cplGluFucSuR(gt1,iIN)
coup(7) = cplGluFucSuL(gt2,gt3)
coup(8) = cplGluFucSuR(gt2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 0*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MGlu
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplChiFucSuL(i1,gt1,gt3)
coup(4) = cplChiFucSuR(i1,gt1,gt3)
coup(5) = cplGluFucSuL(gt1,iIN)
coup(6) = cplGluFucSuR(gt1,iIN)
coup(7) = cplGluFucSuL(gt2,gt3)
coup(8) = cplGluFucSuR(gt2,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 0*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MGlu
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplChiFucSuL(i1,gt1,gt3)
coup(4) = cplChiFucSuR(i1,gt1,gt3)
coup(5) = cplGluFucSuL(gt2,iIN)
coup(6) = cplGluFucSuR(gt2,iIN)
coup(7) = cplGluFucSuL(gt1,gt3)
coup(8) = cplGluFucSuR(gt1,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 0*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MChi(i1)
mass(2) = MGlu
coup(1) = cplChiFucSuL(i1,gt1,iIN)
coup(2) = cplChiFucSuR(i1,gt1,iIN)
coup(3) = cplChiFucSuL(i1,gt2,gt3)
coup(4) = cplChiFucSuR(i1,gt2,gt3)
coup(5) = cplGluFucSuL(gt2,iIN)
coup(6) = cplGluFucSuR(gt2,iIN)
coup(7) = cplGluFucSuL(gt1,gt3)
coup(8) = cplGluFucSuR(gt1,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 0*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Fu cSu Propagator: Chi,Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Glu'
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=gt1,3
Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:36))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToFuFucSu
Subroutine SuToFuFvSvIm(iIN,MFu,MFv,MSvIm,MChi,MSu,cplChiFucSuL,cplChiFucSuR, &
& cplChiFvSvImL,cplChiFvSvImR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MFu(3),MFv(6),MSvIm(6),MChi(5),MSu(6)
Complex(dp),Intent(in) :: cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6),cplChiFvSvImL(5,6,6),cplChiFvSvImR(5,6,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 25
Allocate( gSum(3,6,6, Isum) )
Allocate( Contribution(3,6,6, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=1,6
Do gt3=1,6
Isum = 0
rk2 = (MFu(gt1)/MSu(iIN))**2
rm2 = (MFv(gt2)/MSu(iIN))**2
rj2 = (MSvIm(gt3)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MSvIm(gt3))+Abs(MFv(gt2))+Abs(MFu(gt1)))) Then
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt1,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt1,iIN))
coup(4) = Conjg(cplChiFvSvImL(i1,gt2,gt3))
coup(3) = Conjg(cplChiFvSvImR(i1,gt2,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Fv SvIm Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt1,iIN)
coup(2) = cplChiFucSuR(i1,gt1,iIN)
coup(3) = cplChiFvSvImL(i1,gt2,gt3)
coup(4) = cplChiFvSvImR(i1,gt2,gt3)
coup(5) = cplChiFucSuL(i2,gt1,iIN)
coup(6) = cplChiFucSuR(i2,gt1,iIN)
coup(7) = cplChiFvSvImL(i2,gt2,gt3)
coup(8) = cplChiFvSvImR(i2,gt2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Fv SvIm Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=1,6
Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:25))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToFuFvSvIm
Subroutine SuToFuFvSvRe(iIN,MFu,MFv,MSvRe,MChi,MSu,cplChiFucSuL,cplChiFucSuR, &
& cplChiFvSvReL,cplChiFvSvReR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MFu(3),MFv(6),MSvRe(6),MChi(5),MSu(6)
Complex(dp),Intent(in) :: cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6),cplChiFvSvReL(5,6,6),cplChiFvSvReR(5,6,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 25
Allocate( gSum(3,6,6, Isum) )
Allocate( Contribution(3,6,6, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=1,6
Do gt3=1,6
Isum = 0
rk2 = (MFu(gt1)/MSu(iIN))**2
rm2 = (MFv(gt2)/MSu(iIN))**2
rj2 = (MSvRe(gt3)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MSvRe(gt3))+Abs(MFv(gt2))+Abs(MFu(gt1)))) Then
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt1,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt1,iIN))
coup(4) = Conjg(cplChiFvSvReL(i1,gt2,gt3))
coup(3) = Conjg(cplChiFvSvReR(i1,gt2,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Fv SvRe Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt1,iIN)
coup(2) = cplChiFucSuR(i1,gt1,iIN)
coup(3) = cplChiFvSvReL(i1,gt2,gt3)
coup(4) = cplChiFvSvReR(i1,gt2,gt3)
coup(5) = cplChiFucSuL(i2,gt1,iIN)
coup(6) = cplChiFucSuR(i2,gt1,iIN)
coup(7) = cplChiFvSvReL(i2,gt2,gt3)
coup(8) = cplChiFvSvReR(i2,gt2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Fv SvRe Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=1,6
Do gt3=1,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:25))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToFuFvSvRe
Subroutine SuTocChaFuHpm(iIN,MCha,MFu,MHpm,MFd,MChi,MSu,cplcChaChiHpmL, &
& cplcChaChiHpmR,cplcChaFdcSuL,cplcChaFdcSuR,cplcFdFuHpmL,cplcFdFuHpmR,cplChiFucSuL, &
& cplChiFucSuR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MCha(2),MFu(3),MHpm(2),MFd(3),MChi(5),MSu(6)
Complex(dp),Intent(in) :: cplcChaChiHpmL(2,5,2),cplcChaChiHpmR(2,5,2),cplcChaFdcSuL(2,3,6),cplcChaFdcSuR(2,3,6),&
& cplcFdFuHpmL(3,3,2),cplcFdFuHpmR(3,3,2),cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 64
Allocate( gSum(2,3,2, Isum) )
Allocate( Contribution(2,3,2, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,2
Do gt2=1,3
Do gt3=2,2
Isum = 0
rk2 = (MCha(gt1)/MSu(iIN))**2
rm2 = (MFu(gt2)/MSu(iIN))**2
rj2 = (MHpm(gt3)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MHpm(gt3))+Abs(MFu(gt2))+Abs(MCha(gt1)))) Then
!--------------
! Fd
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(gt1,i1,iIN))
coup(1) = Conjg(cplcChaFdcSuR(gt1,i1,iIN))
coup(4) = Conjg(cplcFdFuHpmL(i1,gt2,gt3))
coup(3) = Conjg(cplcFdFuHpmR(i1,gt2,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cCha Fu Hpm Propagator: Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fd'
End Do
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt2,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt2,iIN))
coup(4) = Conjg(cplcChaChiHpmL(gt1,i1,gt3))
coup(3) = Conjg(cplcChaChiHpmR(gt1,i1,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cCha Fu Hpm Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Fd, Fd
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i2)
coup(1) = cplcChaFdcSuL(gt1,i1,iIN)
coup(2) = cplcChaFdcSuR(gt1,i1,iIN)
coup(3) = cplcFdFuHpmL(i1,gt2,gt3)
coup(4) = cplcFdFuHpmR(i1,gt2,gt3)
coup(5) = cplcChaFdcSuL(gt1,i2,iIN)
coup(6) = cplcChaFdcSuR(gt1,i2,iIN)
coup(7) = cplcFdFuHpmL(i2,gt2,gt3)
coup(8) = cplcFdFuHpmR(i2,gt2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cCha Fu Hpm Propagator: Fd,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fd,Fd'
End Do
End Do
!--------------
! Fd, Chi
!--------------
Do i1=1,3
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MFd(i1)
mass(2) = MChi(i2)
coup(1) = cplcChaFdcSuL(gt1,i1,iIN)
coup(2) = cplcChaFdcSuR(gt1,i1,iIN)
coup(3) = cplcFdFuHpmL(i1,gt2,gt3)
coup(4) = cplcFdFuHpmR(i1,gt2,gt3)
coup(5) = cplChiFucSuL(i2,gt2,iIN)
coup(6) = cplChiFucSuR(i2,gt2,iIN)
coup(7) = cplcChaChiHpmL(gt1,i2,gt3)
coup(8) = cplcChaChiHpmR(gt1,i2,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cCha Fu Hpm Propagator: Fd,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fd,Chi'
End Do
End Do
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplcChaChiHpmL(gt1,i1,gt3)
coup(4) = cplcChaChiHpmR(gt1,i1,gt3)
coup(5) = cplChiFucSuL(i2,gt2,iIN)
coup(6) = cplChiFucSuR(i2,gt2,iIN)
coup(7) = cplcChaChiHpmL(gt1,i2,gt3)
coup(8) = cplcChaChiHpmR(gt1,i2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cCha Fu Hpm Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,2
Do gt2=1,3
Do gt3=2,2
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:64))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuTocChaFuHpm
Subroutine SuToSdFucFd(iIN,MSd,MFu,MFd,MVWm,MHpm,MChi,MGlu,MSu,cplSdcHpmcSu, &
& cplSdcSucVWm,cplcFdChiSdL,cplcFdChiSdR,cplcFdFuHpmL,cplcFdFuHpmR,cplcFdFuVWmL, &
& cplcFdFuVWmR,cplcFdGluSdL,cplcFdGluSdR,cplChiFucSuL,cplChiFucSuR,cplGluFucSuL, &
& cplGluFucSuR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MSd(6),MFu(3),MFd(3),MVWm,MHpm(2),MChi(5),MGlu,MSu(6)
Complex(dp),Intent(in) :: cplSdcHpmcSu(6,2,6),cplSdcSucVWm(6,6),cplcFdChiSdL(3,5,6),cplcFdChiSdR(3,5,6), &
& cplcFdFuHpmL(3,3,2),cplcFdFuHpmR(3,3,2),cplcFdFuVWmL(3,3),cplcFdFuVWmR(3,3), &
& cplcFdGluSdL(3,6),cplcFdGluSdR(3,6),cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6), &
& cplGluFucSuL(3,6),cplGluFucSuR(3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 81
Allocate( gSum(6,3,3, Isum) )
Allocate( Contribution(6,3,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,6
Do gt2=1,3
Do gt3=1,3
Isum = 0
rk2 = (MFu(gt2)/MSu(iIN))**2
rm2 = (MFd(gt3)/MSu(iIN))**2
rj2 = (MSd(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFd(gt3))+Abs(MFu(gt2))+Abs(MSd(gt1)))) Then
!--------------
! conj[VWm]
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MVWm
mass(2) = MVWm
m_in = MSu(iIN)
coup(1) = Conjg(cplSdcSucVWm(gt1,iIN))
coup(3) = Conjg(cplcFdFuVWmL(gt3,gt2))
coup(2) = Conjg(cplcFdFuVWmR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: conj[VWm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm]'
!--------------
! conj[Hpm]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MHpm(i1)
mass(2) = MHpm(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplSdcHpmcSu(gt1,i1,iIN))
coup(3) = Conjg(cplcFdFuHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFuHpmR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: conj[Hpm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm]'
End Do
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt2,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt2,iIN))
coup(4) = Conjg(cplcFdChiSdL(gt3,i1,gt1))
coup(3) = Conjg(cplcFdChiSdR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Glu
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MGlu
mass(2) = MGlu
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(gt2,iIN))
coup(1) = Conjg(cplGluFucSuR(gt2,iIN))
coup(4) = Conjg(cplcFdGluSdL(gt3,gt1))
coup(3) = Conjg(cplcFdGluSdR(gt3,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Glu'
!--------------
! conj[VWm], conj[Hpm]
!--------------
Do i2=1,2
Isum = Isum + 1
resS = 0._dp
mass(2) = MVWm
mass(1) = MHpm(i2)
coup(1) = cplSdcSucVWm(gt1,iIN)
coup(2) = Conjg(cplcFdFuVWmL(gt3,gt2))
coup(3) = Conjg(cplcFdFuVWmR(gt3,gt2))
coup(4) = cplSdcHpmcSu(gt1,i2,iIN)
coup(5) = Conjg(cplcFdFuHpmL(gt3,gt2,i2))
coup(6) = Conjg(cplcFdFuHpmR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: conj[VWm],conj[Hpm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm],conj[Hpm]'
End Do
!--------------
! conj[VWm], Chi
!--------------
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(2) = MVWm2
mass(1) = MChi2(i2)
coup(1) = cplChiFucSuL(i2,gt2,iIN)
coup(2) = cplChiFucSuR(i2,gt2,iIN)
coup(4) = Conjg(cplcFdChiSdL(gt3,i2,gt1))
coup(3) = Conjg(cplcFdChiSdR(gt3,i2,gt1))
coup(5) = cplSdcSucVWm(gt1,iIN)
coup(7) = Conjg(cplcFdFuVWmL(gt3,gt2))
coup(6) = Conjg(cplcFdFuVWmR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: conj[VWm],Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm],Chi'
End Do
!--------------
! conj[VWm], Glu
!--------------
Isum = Isum + 1
resS = 0._dp
mass(2) = MVWm2
mass(1) = MGlu2
coup(1) = cplGluFucSuL(gt2,iIN)
coup(2) = cplGluFucSuR(gt2,iIN)
coup(4) = Conjg(cplcFdGluSdL(gt3,gt1))
coup(3) = Conjg(cplcFdGluSdR(gt3,gt1))
coup(5) = cplSdcSucVWm(gt1,iIN)
coup(7) = Conjg(cplcFdFuVWmL(gt3,gt2))
coup(6) = Conjg(cplcFdFuVWmR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 4._dp/3._dp*resC ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: conj[VWm],Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm],Glu'
!--------------
! conj[Hpm], conj[Hpm]
!--------------
Do i1=1,1
Do i2=i1+1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MHpm(i1)
mass(2) = MHpm(i2)
coup(1) = cplSdcHpmcSu(gt1,i1,iIN)
coup(3) = Conjg(cplcFdFuHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplcFdFuHpmR(gt3,gt2,i1))
coup(4) = cplSdcHpmcSu(gt1,i2,iIN)
coup(6) = Conjg(cplcFdFuHpmL(gt3,gt2,i2))
coup(5) = Conjg(cplcFdFuHpmR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: conj[Hpm],conj[Hpm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm],conj[Hpm]'
End Do
End Do
!--------------
! conj[Hpm], Chi
!--------------
Do i1=1,2
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(2) = MHpm(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFucSuL(i2,gt2,iIN)
coup(2) = cplChiFucSuR(i2,gt2,iIN)
coup(4) = Conjg(cplcFdChiSdL(gt3,i2,gt1))
coup(3) = Conjg(cplcFdChiSdR(gt3,i2,gt1))
coup(5) = cplSdcHpmcSu(gt1,i1,iIN)
coup(7) = Conjg(cplcFdFuHpmL(gt3,gt2,i1))
coup(6) = Conjg(cplcFdFuHpmR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: conj[Hpm],Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm],Chi'
End Do
End Do
!--------------
! conj[Hpm], Glu
!--------------
Do i1=1,2
Isum = Isum + 1
resS = 0._dp
mass(2) = MHpm(i1)
mass(1) = MGlu
coup(1) = cplGluFucSuL(gt2,iIN)
coup(2) = cplGluFucSuR(gt2,iIN)
coup(4) = Conjg(cplcFdGluSdL(gt3,gt1))
coup(3) = Conjg(cplcFdGluSdR(gt3,gt1))
coup(5) = cplSdcHpmcSu(gt1,i1,iIN)
coup(7) = Conjg(cplcFdFuHpmL(gt3,gt2,i1))
coup(6) = Conjg(cplcFdFuHpmR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: conj[Hpm],Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm],Glu'
End Do
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplcFdChiSdL(gt3,i1,gt1)
coup(4) = cplcFdChiSdR(gt3,i1,gt1)
coup(5) = cplChiFucSuL(i2,gt2,iIN)
coup(6) = cplChiFucSuR(i2,gt2,iIN)
coup(7) = cplcFdChiSdL(gt3,i2,gt1)
coup(8) = cplcFdChiSdR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
!--------------
! Chi, Glu
!--------------
Do i1=1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MGlu
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplcFdChiSdL(gt3,i1,gt1)
coup(4) = cplcFdChiSdR(gt3,i1,gt1)
coup(5) = cplGluFucSuL(gt2,iIN)
coup(6) = cplGluFucSuR(gt2,iIN)
coup(7) = cplcFdGluSdL(gt3,gt1)
coup(8) = cplcFdGluSdR(gt3,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 0*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fu cFd Propagator: Chi,Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Glu'
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,6
Do gt2=1,3
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:81))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToSdFucFd
Subroutine SuToFuSecFe(iIN,MFu,MSe,MFe,MChi,MSu,cplcFeChiSeL,cplcFeChiSeR, &
& cplChiFucSuL,cplChiFucSuR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MFu(3),MSe(6),MFe(3),MChi(5),MSu(6)
Complex(dp),Intent(in) :: cplcFeChiSeL(3,5,6),cplcFeChiSeR(3,5,6),cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 25
Allocate( gSum(3,6,3, Isum) )
Allocate( Contribution(3,6,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=1,6
Do gt3=1,3
Isum = 0
rk2 = (MFu(gt1)/MSu(iIN))**2
rm2 = (MFe(gt3)/MSu(iIN))**2
rj2 = (MSe(gt2)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFe(gt3))+Abs(MSe(gt2))+Abs(MFu(gt1)))) Then
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt1,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt1,iIN))
coup(4) = Conjg(cplcFeChiSeL(gt3,i1,gt2))
coup(3) = Conjg(cplcFeChiSeR(gt3,i1,gt2))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Se cFe Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt1,iIN)
coup(2) = cplChiFucSuR(i1,gt1,iIN)
coup(3) = cplcFeChiSeL(gt3,i1,gt2)
coup(4) = cplcFeChiSeR(gt3,i1,gt2)
coup(5) = cplChiFucSuL(i2,gt1,iIN)
coup(6) = cplChiFucSuR(i2,gt1,iIN)
coup(7) = cplcFeChiSeL(gt3,i2,gt2)
coup(8) = cplcFeChiSeR(gt3,i2,gt2)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Fu Se cFe Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=1,6
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:25))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToFuSecFe
Subroutine SuToSuFucFu(iIN,MSu,MFu,MVZ,MAh,Mhh,MChi,MGlu,cplAhSucSu,cplhhSucSu, &
& cplSucSuVZ,cplcFuChiSuL,cplcFuChiSuR,cplcFuFuAhL,cplcFuFuAhR,cplcFuFuhhL, &
& cplcFuFuhhR,cplcFuFuVZL,cplcFuFuVZR,cplcFuGluSuL,cplcFuGluSuR,cplChiFucSuL, &
& cplChiFucSuR,cplGluFucSuL,cplGluFucSuR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MSu(6),MFu(3),MVZ,MAh(3),Mhh(3),MChi(5),MGlu
Complex(dp),Intent(in) :: cplAhSucSu(3,6,6),cplhhSucSu(3,6,6),cplSucSuVZ(6,6),cplcFuChiSuL(3,5,6), &
& cplcFuChiSuR(3,5,6),cplcFuFuAhL(3,3,3),cplcFuFuAhR(3,3,3),cplcFuFuhhL(3,3,3), &
& cplcFuFuhhR(3,3,3),cplcFuFuVZL(3,3),cplcFuFuVZR(3,3),cplcFuGluSuL(3,6),cplcFuGluSuR(3,6),&
& cplChiFucSuL(5,3,6),cplChiFucSuR(5,3,6),cplGluFucSuL(3,6),cplGluFucSuR(3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 169
Allocate( gSum(6,3,3, Isum) )
Allocate( Contribution(6,3,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1, iIN-1
Do gt2=1,3
Do gt3=1,3
Isum = 0
rk2 = (MFu(gt2)/MSu(iIN))**2
rm2 = (MFu(gt3)/MSu(iIN))**2
rj2 = (MSu(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFu(gt3))+Abs(MFu(gt2))+Abs(MSu(gt1)))) Then
!--------------
! VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MVZ
mass(2) = MVZ
m_in = MSu(iIN)
coup(1) = Conjg(cplSucSuVZ(gt1,iIN))
coup(3) = Conjg(cplcFuFuVZL(gt3,gt2))
coup(2) = Conjg(cplcFuFuVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: VZ"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'
!--------------
! Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplAhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplcFuFuAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
End Do
!--------------
! hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplhhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplcFuFuhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuhhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
End Do
!--------------
! Chi
!--------------
Do i1=1,5
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplChiFucSuL(i1,gt2,iIN))
coup(1) = Conjg(cplChiFucSuR(i1,gt2,iIN))
coup(4) = Conjg(cplcFuChiSuL(gt3,i1,gt1))
coup(3) = Conjg(cplcFuChiSuR(gt3,i1,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 3*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Chi'
End Do
!--------------
! Glu
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MGlu
mass(2) = MGlu
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(gt2,iIN))
coup(1) = Conjg(cplGluFucSuR(gt2,iIN))
coup(4) = Conjg(cplcFuGluSuL(gt3,gt1))
coup(3) = Conjg(cplcFuGluSuR(gt3,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Glu'
!--------------
! VZ, Ah
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplcFuFuVZL(gt3,gt2))
coup(3) = Conjg(cplcFuFuVZR(gt3,gt2))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplcFuFuAhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFuFuAhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: VZ,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
End Do
!--------------
! VZ, hh
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplcFuFuVZL(gt3,gt2))
coup(3) = Conjg(cplcFuFuVZR(gt3,gt2))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplcFuFuhhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFuFuhhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: VZ,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
End Do
!--------------
! VZ, Chi
!--------------
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ2
mass(1) = MChi2(i2)
coup(1) = cplChiFucSuL(i2,gt2,iIN)
coup(2) = cplChiFucSuR(i2,gt2,iIN)
coup(4) = Conjg(cplcFuChiSuL(gt3,i2,gt1))
coup(3) = Conjg(cplcFuChiSuR(gt3,i2,gt1))
coup(5) = cplSucSuVZ(gt1,iIN)
coup(7) = Conjg(cplcFuFuVZL(gt3,gt2))
coup(6) = Conjg(cplcFuFuVZR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: VZ,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Chi'
End Do
!--------------
! VZ, Glu
!--------------
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ2
mass(1) = MGlu2
coup(1) = cplGluFucSuL(gt2,iIN)
coup(2) = cplGluFucSuR(gt2,iIN)
coup(4) = Conjg(cplcFuGluSuL(gt3,gt1))
coup(3) = Conjg(cplcFuGluSuR(gt3,gt1))
coup(5) = cplSucSuVZ(gt1,iIN)
coup(7) = Conjg(cplcFuFuVZL(gt3,gt2))
coup(6) = Conjg(cplcFuFuVZR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 4._dp/3._dp*resC ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: VZ,Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Glu'
!--------------
! Ah, Ah
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcFuFuAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuAhR(gt3,gt2,i1))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcFuFuAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFuFuAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: Ah,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
End Do
End Do
!--------------
! Ah, hh
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcFuFuAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuAhR(gt3,gt2,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcFuFuhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFuFuhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: Ah,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
End Do
End Do
!--------------
! Ah, Chi
!--------------
Do i1=1,3
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFucSuL(i2,gt2,iIN)
coup(2) = cplChiFucSuR(i2,gt2,iIN)
coup(4) = Conjg(cplcFuChiSuL(gt3,i2,gt1))
coup(3) = Conjg(cplcFuChiSuR(gt3,i2,gt1))
coup(5) = cplAhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplcFuFuAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFuFuAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: Ah,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Chi'
End Do
End Do
!--------------
! Ah, Glu
!--------------
Do i1=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MGlu
coup(1) = cplGluFucSuL(gt2,iIN)
coup(2) = cplGluFucSuR(gt2,iIN)
coup(4) = Conjg(cplcFuGluSuL(gt3,gt1))
coup(3) = Conjg(cplcFuGluSuR(gt3,gt1))
coup(5) = cplAhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplcFuFuAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFuFuAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: Ah,Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Glu'
End Do
!--------------
! hh, hh
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcFuFuhhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFuFuhhR(gt3,gt2,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcFuFuhhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFuFuhhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: hh,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
End Do
End Do
!--------------
! hh, Chi
!--------------
Do i1=1,3
Do i2=1,5
Isum = Isum + 1
resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MChi(i2)
coup(1) = cplChiFucSuL(i2,gt2,iIN)
coup(2) = cplChiFucSuR(i2,gt2,iIN)
coup(4) = Conjg(cplcFuChiSuL(gt3,i2,gt1))
coup(3) = Conjg(cplcFuChiSuR(gt3,i2,gt1))
coup(5) = cplhhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplcFuFuhhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFuFuhhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: hh,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Chi'
End Do
End Do
!--------------
! hh, Glu
!--------------
Do i1=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MGlu
coup(1) = cplGluFucSuL(gt2,iIN)
coup(2) = cplGluFucSuR(gt2,iIN)
coup(4) = Conjg(cplcFuGluSuL(gt3,gt1))
coup(3) = Conjg(cplcFuGluSuR(gt3,gt1))
coup(5) = cplhhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplcFuFuhhL(gt3,gt2,i1))
coup(6) = Conjg(cplcFuFuhhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: hh,Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Glu'
End Do
!--------------
! Chi, Chi
!--------------
Do i1=1,4
Do i2=i1+1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MChi(i2)
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplcFuChiSuL(gt3,i1,gt1)
coup(4) = cplcFuChiSuR(gt3,i1,gt1)
coup(5) = cplChiFucSuL(i2,gt2,iIN)
coup(6) = cplChiFucSuR(i2,gt2,iIN)
coup(7) = cplcFuChiSuL(gt3,i2,gt1)
coup(8) = cplcFuChiSuR(gt3,i2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 3*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: Chi,Chi"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Chi'
End Do
End Do
!--------------
! Chi, Glu
!--------------
Do i1=1,5
Isum = Isum + 1
resS = 0._dp
mass(1) = MChi(i1)
mass(2) = MGlu
coup(1) = cplChiFucSuL(i1,gt2,iIN)
coup(2) = cplChiFucSuR(i1,gt2,iIN)
coup(3) = cplcFuChiSuL(gt3,i1,gt1)
coup(4) = cplcFuChiSuR(gt3,i1,gt1)
coup(5) = cplGluFucSuL(gt2,iIN)
coup(6) = cplGluFucSuR(gt2,iIN)
coup(7) = cplcFuGluSuL(gt3,gt1)
coup(8) = cplcFuGluSuR(gt3,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 0*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fu cFu Propagator: Chi,Glu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Chi,Glu'
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1, iIN-1
Do gt2=1,3
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:169))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToSuFucFu
Subroutine SuTocHpmFdGlu(iIN,MHpm,MFd,MGlu,MSd,MFu,MSu,cplSdcHpmcSu,cplcFuFdcHpmL, &
& cplcFuFdcHpmR,cplGluFdcSdL,cplGluFdcSdR,cplGluFucSuL,cplGluFucSuR,deltaM, &
& epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MHpm(2),MFd(3),MGlu,MSd(6),MFu(3),MSu(6)
Complex(dp),Intent(in) :: cplSdcHpmcSu(6,2,6),cplcFuFdcHpmL(3,3,2),cplcFuFdcHpmR(3,3,2),cplGluFdcSdL(3,6), &
& cplGluFdcSdR(3,6),cplGluFucSuL(3,6),cplGluFucSuR(3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 81
Allocate( gSum(2,3,1, Isum) )
Allocate( Contribution(2,3,1, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=2,2
Do gt2=1,3
Isum = 0
rk2 = (MFd(gt2)/MSu(iIN))**2
rm2 = (MGlu/MSu(iIN))**2
rj2 = (MHpm(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MGlu)+Abs(MFd(gt2))+Abs(MHpm(gt1)))) Then
!--------------
! Sd
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MSd(i1)
mass(2) = MSd(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplSdcHpmcSu(i1,gt1,iIN))
coup(3) = Conjg(cplGluFdcSdL(gt2,i1))
coup(2) = Conjg(cplGluFdcSdR(gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Fd Glu Propagator: Sd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)=resD
End If
Contribution(gt1,gt2,1,Isum)='Sd'
End Do
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(i1,iIN))
coup(1) = Conjg(cplGluFucSuR(i1,iIN))
coup(4) = Conjg(cplcFuFdcHpmL(i1,gt2,gt1))
coup(3) = Conjg(cplcFuFdcHpmR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Fd Glu Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)=resD
End If
Contribution(gt1,gt2,1,Isum)='Fu'
End Do
!--------------
! Sd, Sd
!--------------
Do i1=1,5
Do i2=i1+1,6
Isum = Isum + 1
resS = 0._dp
mass(1) = MSd(i1)
mass(2) = MSd(i2)
coup(1) = cplSdcHpmcSu(i1,gt1,iIN)
coup(3) = Conjg(cplGluFdcSdL(gt2,i1))
coup(2) = Conjg(cplGluFdcSdR(gt2,i1))
coup(4) = cplSdcHpmcSu(i2,gt1,iIN)
coup(6) = Conjg(cplGluFdcSdL(gt2,i2))
coup(5) = Conjg(cplGluFdcSdR(gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Fd Glu Propagator: Sd,Sd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)= resS
End If
Contribution(gt1,gt2,1,Isum)='Sd,Sd'
End Do
End Do
!--------------
! Sd, Fu
!--------------
Do i1=1,6
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MSd(i1)
mass(1) = MFu(i2)
coup(1) = cplGluFucSuL(i2,iIN)
coup(2) = cplGluFucSuR(i2,iIN)
coup(4) = Conjg(cplcFuFdcHpmL(i2,gt2,gt1))
coup(3) = Conjg(cplcFuFdcHpmR(i2,gt2,gt1))
coup(5) = cplSdcHpmcSu(i1,gt1,iIN)
coup(7) = Conjg(cplGluFdcSdL(gt2,i1))
coup(6) = Conjg(cplGluFdcSdR(gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Fd Glu Propagator: Sd,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)= resS
End If
Contribution(gt1,gt2,1,Isum)='Sd,Fu'
End Do
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplGluFucSuL(i1,iIN)
coup(2) = cplGluFucSuR(i1,iIN)
coup(3) = cplcFuFdcHpmL(i1,gt2,gt1)
coup(4) = cplcFuFdcHpmR(i1,gt2,gt1)
coup(5) = cplGluFucSuL(i2,iIN)
coup(6) = cplGluFucSuR(i2,iIN)
coup(7) = cplcFuFdcHpmL(i2,gt2,gt1)
coup(8) = cplcFuFdcHpmR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->cHpm Fd Glu Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)= resS
End If
Contribution(gt1,gt2,1,Isum)='Fu,Fu'
End Do
End Do
Else
gSum(gt1,gt2,1,:)= 0._dp
End If
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=2,2
Do gt2=1,3
g(gt1,gt2,1)=Sum(gSum(gt1,gt2,1,1:81))
If (g(gt1,gt2,1).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,1)=0._dp
End If
End Do
End Do
End Subroutine SuTocHpmFdGlu
Subroutine SuTohhFuGlu(iIN,Mhh,MFu,MGlu,MSu,cplhhSucSu,cplcFuFuhhL,cplcFuFuhhR, &
& cplGluFucSuL,cplGluFucSuR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: Mhh(3),MFu(3),MGlu,MSu(6)
Complex(dp),Intent(in) :: cplhhSucSu(3,6,6),cplcFuFuhhL(3,3,3),cplcFuFuhhR(3,3,3),cplGluFucSuL(3,6), &
& cplGluFucSuR(3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 81
Allocate( gSum(3,3,1, Isum) )
Allocate( Contribution(3,3,1, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,3
Do gt2=1,3
Isum = 0
rk2 = (MFu(gt2)/MSu(iIN))**2
rm2 = (MGlu/MSu(iIN))**2
rj2 = (Mhh(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MGlu)+Abs(MFu(gt2))+Abs(Mhh(gt1)))) Then
!--------------
! Su
!--------------
Do i1=1,6
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplhhSucSu(gt1,i1,iIN))
coup(3) = Conjg(cplGluFucSuL(gt2,i1))
coup(2) = Conjg(cplGluFucSuR(gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fu Glu Propagator: Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)=resD
End If
Contribution(gt1,gt2,1,Isum)='Su'
End Do
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(i1,iIN))
coup(1) = Conjg(cplGluFucSuR(i1,iIN))
coup(4) = Conjg(cplcFuFuhhL(i1,gt2,gt1))
coup(3) = Conjg(cplcFuFuhhR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fu Glu Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)=resD
End If
Contribution(gt1,gt2,1,Isum)='Fu'
End Do
!--------------
! Su, Su
!--------------
Do i1=1,5
Do i2=i1+1,6
Isum = Isum + 1
resS = 0._dp
mass(1) = MSu(i1)
mass(2) = MSu(i2)
coup(1) = cplhhSucSu(gt1,i1,iIN)
coup(3) = Conjg(cplGluFucSuL(gt2,i1))
coup(2) = Conjg(cplGluFucSuR(gt2,i1))
coup(4) = cplhhSucSu(gt1,i2,iIN)
coup(6) = Conjg(cplGluFucSuL(gt2,i2))
coup(5) = Conjg(cplGluFucSuR(gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fu Glu Propagator: Su,Su"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)= resS
End If
Contribution(gt1,gt2,1,Isum)='Su,Su'
End Do
End Do
!--------------
! Su, Fu
!--------------
Do i1=1,6
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MSu(i1)
mass(1) = MFu(i2)
coup(1) = cplGluFucSuL(i2,iIN)
coup(2) = cplGluFucSuR(i2,iIN)
coup(4) = Conjg(cplcFuFuhhL(i2,gt2,gt1))
coup(3) = Conjg(cplcFuFuhhR(i2,gt2,gt1))
coup(5) = cplhhSucSu(gt1,i1,iIN)
coup(7) = Conjg(cplGluFucSuL(gt2,i1))
coup(6) = Conjg(cplGluFucSuR(gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fu Glu Propagator: Su,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)= resS
End If
Contribution(gt1,gt2,1,Isum)='Su,Fu'
End Do
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplGluFucSuL(i1,iIN)
coup(2) = cplGluFucSuR(i1,iIN)
coup(3) = cplcFuFuhhL(i1,gt2,gt1)
coup(4) = cplcFuFuhhR(i1,gt2,gt1)
coup(5) = cplGluFucSuL(i2,iIN)
coup(6) = cplGluFucSuR(i2,iIN)
coup(7) = cplcFuFuhhL(i2,gt2,gt1)
coup(8) = cplcFuFuhhR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->hh Fu Glu Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,1,Isum)= 0._dp
Else
gSum(gt1,gt2,1,Isum)= resS
End If
Contribution(gt1,gt2,1,Isum)='Fu,Fu'
End Do
End Do
Else
gSum(gt1,gt2,1,:)= 0._dp
End If
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,3
Do gt2=1,3
g(gt1,gt2,1)=Sum(gSum(gt1,gt2,1,1:81))
If (g(gt1,gt2,1).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,1)=0._dp
End If
End Do
End Do
End Subroutine SuTohhFuGlu
Subroutine SuToGluGluSu(iIN,MGlu,MSu,MFu,cplcFuGluSuL,cplcFuGluSuR,cplGluFucSuL, &
& cplGluFucSuR,deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MGlu,MSu(6),MFu(3)
Complex(dp),Intent(in) :: cplcFuGluSuL(3,6),cplcFuGluSuR(3,6),cplGluFucSuL(3,6),cplGluFucSuR(3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 9
Allocate( gSum(1,1,6, Isum) )
Allocate( Contribution(1,1,6, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt3=1, iIN-1
Isum = 0
rk2 = (MGlu/MSu(iIN))**2
rm2 = (MGlu/MSu(iIN))**2
rj2 = (MSu(gt3)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MSu(gt3))+Abs(MGlu)+Abs(MGlu))) Then
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(i1,iIN))
coup(1) = Conjg(cplGluFucSuR(i1,iIN))
coup(4) = Conjg(cplcFuGluSuL(i1,gt3))
coup(3) = Conjg(cplcFuGluSuR(i1,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 16._dp/9._dp*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(i1,iIN))
coup(1) = Conjg(cplGluFucSuR(i1,iIN))
coup(4) = Conjg(cplcFuGluSuL(i1,gt3))
coup(3) = Conjg(cplcFuGluSuR(i1,gt3))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 16._dp/9._dp*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFu(i1)
mass(2) = MFu(i1)
coup(1) = cplGluFucSuL(i1,iIN)
coup(2) = cplGluFucSuR(i1,iIN)
coup(3) = cplcFuGluSuL(i1,gt3)
coup(4) = cplcFuGluSuR(i1,gt3)
coup(5) = cplGluFucSuL(i1,iIN)
coup(6) = cplGluFucSuR(i1,iIN)
coup(7) = cplcFuGluSuL(i1,gt3)
coup(8) = cplcFuGluSuR(i1,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 16._dp/9._dp*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Glu Glu Su Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(1,1,gt3,Isum)= 0._dp
Else
gSum(1,1,gt3,Isum)=resD
End If
Contribution(1,1,gt3,Isum)='Fu'
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplGluFucSuL(i1,iIN)
coup(2) = cplGluFucSuR(i1,iIN)
coup(3) = cplcFuGluSuL(i1,gt3)
coup(4) = cplcFuGluSuR(i1,gt3)
coup(5) = cplGluFucSuL(i2,iIN)
coup(6) = cplGluFucSuR(i2,iIN)
coup(7) = cplcFuGluSuL(i2,gt3)
coup(8) = cplcFuGluSuR(i2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 16._dp/9._dp*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplGluFucSuL(i1,iIN)
coup(2) = cplGluFucSuR(i1,iIN)
coup(3) = cplcFuGluSuL(i1,gt3)
coup(4) = cplcFuGluSuR(i1,gt3)
coup(5) = cplGluFucSuL(i2,iIN)
coup(6) = cplGluFucSuR(i2,iIN)
coup(7) = cplcFuGluSuL(i2,gt3)
coup(8) = cplcFuGluSuR(i2,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 16._dp/9._dp*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplGluFucSuL(i1,iIN)
coup(2) = cplGluFucSuR(i1,iIN)
coup(3) = cplcFuGluSuL(i1,gt3)
coup(4) = cplcFuGluSuR(i1,gt3)
coup(5) = cplGluFucSuL(i2,iIN)
coup(6) = cplGluFucSuR(i2,iIN)
coup(7) = cplcFuGluSuL(i2,gt3)
coup(8) = cplcFuGluSuR(i2,gt3)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 16._dp/9._dp*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplGluFucSuL(i1,iIN)
coup(2) = cplGluFucSuR(i1,iIN)
coup(3) = cplcFuGluSuL(i1,gt3)
coup(4) = cplcFuGluSuR(i1,gt3)
coup(5) = cplGluFucSuL(i2,iIN)
coup(6) = cplGluFucSuR(i2,iIN)
coup(7) = cplcFuGluSuL(i2,gt3)
coup(8) = cplcFuGluSuR(i2,gt3)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 16._dp/9._dp*resC ! Color factor
If (gt1.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Glu Glu Su Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(1,1,gt3,Isum)= 0._dp
Else
gSum(1,1,gt3,Isum)= resS
End If
Contribution(1,1,gt3,Isum)='Fu,Fu'
End Do
End Do
Else
gSum(1,1,gt3,:)= 0._dp
End If
End Do
!----------
!Summing
!----------
g=0._dp
Do gt3=1, iIN-1
g(1,1,gt3)=Sum(gSum(1,1,gt3,1:9))
If (g(1,1,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(1,1,gt3)=0._dp
End If
End Do
End Subroutine SuToGluGluSu
Subroutine SuToGluSdcCha(iIN,MGlu,MSd,MCha,MFu,MFd,MSu,cplcChacFuSdL,cplcChacFuSdR, &
& cplcChaFdcSuL,cplcChaFdcSuR,cplcFdGluSdL,cplcFdGluSdR,cplGluFucSuL,cplGluFucSuR, &
& deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MGlu,MSd(6),MCha(2),MFu(3),MFd(3),MSu(6)
Complex(dp),Intent(in) :: cplcChacFuSdL(2,3,6),cplcChacFuSdR(2,3,6),cplcChaFdcSuL(2,3,6),cplcChaFdcSuR(2,3,6), &
& cplcFdGluSdL(3,6),cplcFdGluSdR(3,6),cplGluFucSuL(3,6),cplGluFucSuR(3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 36
Allocate( gSum(1,6,2, Isum) )
Allocate( Contribution(1,6,2, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt2=1,6
Do gt3=1,2
Isum = 0
rk2 = (MGlu/MSu(iIN))**2
rm2 = (MCha(gt3)/MSu(iIN))**2
rj2 = (MSd(gt2)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MCha(gt3))+Abs(MSd(gt2))+Abs(MGlu))) Then
!--------------
! Fu
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplGluFucSuL(i1,iIN))
coup(1) = Conjg(cplGluFucSuR(i1,iIN))
coup(4) = Conjg(cplcChacFuSdL(gt3,i1,gt2))
coup(3) = Conjg(cplcChacFuSdR(gt3,i1,gt2))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Glu Sd cCha Propagator: Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(1,gt2,gt3,Isum)= 0._dp
Else
gSum(1,gt2,gt3,Isum)=resD
End If
Contribution(1,gt2,gt3,Isum)='Fu'
End Do
!--------------
! Fd
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(gt3,i1,iIN))
coup(1) = Conjg(cplcChaFdcSuR(gt3,i1,iIN))
coup(4) = Conjg(cplcFdGluSdL(i1,gt2))
coup(3) = Conjg(cplcFdGluSdR(i1,gt2))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Glu Sd cCha Propagator: Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(1,gt2,gt3,Isum)= 0._dp
Else
gSum(1,gt2,gt3,Isum)=resD
End If
Contribution(1,gt2,gt3,Isum)='Fd'
End Do
!--------------
! Fu, Fu
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFu(i2)
coup(1) = cplGluFucSuL(i1,iIN)
coup(2) = cplGluFucSuR(i1,iIN)
coup(3) = cplcChacFuSdL(gt3,i1,gt2)
coup(4) = cplcChacFuSdR(gt3,i1,gt2)
coup(5) = cplGluFucSuL(i2,iIN)
coup(6) = cplGluFucSuR(i2,iIN)
coup(7) = cplcChacFuSdL(gt3,i2,gt2)
coup(8) = cplcChacFuSdR(gt3,i2,gt2)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Glu Sd cCha Propagator: Fu,Fu"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(1,gt2,gt3,Isum)= 0._dp
Else
gSum(1,gt2,gt3,Isum)= resS
End If
Contribution(1,gt2,gt3,Isum)='Fu,Fu'
End Do
End Do
!--------------
! Fu, Fd
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFu(i1)
mass(2) = MFd(i2)
coup(1) = cplGluFucSuL(i1,iIN)
coup(2) = cplGluFucSuR(i1,iIN)
coup(3) = cplcChacFuSdL(gt3,i1,gt2)
coup(4) = cplcChacFuSdR(gt3,i1,gt2)
coup(5) = cplcChaFdcSuL(gt3,i2,iIN)
coup(6) = cplcChaFdcSuR(gt3,i2,iIN)
coup(7) = cplcFdGluSdL(i2,gt2)
coup(8) = cplcFdGluSdR(i2,gt2)
Call IntegrateChiChiInterference(mass,m_in,r_outcrossed,coup,smin2,smax2,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Glu Sd cCha Propagator: Fu,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(1,gt2,gt3,Isum)= 0._dp
Else
gSum(1,gt2,gt3,Isum)= resS
End If
Contribution(1,gt2,gt3,Isum)='Fu,Fd'
End Do
End Do
!--------------
! Fd, Fd
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i2)
coup(1) = cplcChaFdcSuL(gt3,i1,iIN)
coup(2) = cplcChaFdcSuR(gt3,i1,iIN)
coup(3) = cplcFdGluSdL(i1,gt2)
coup(4) = cplcFdGluSdR(i1,gt2)
coup(5) = cplcChaFdcSuL(gt3,i2,iIN)
coup(6) = cplcChaFdcSuR(gt3,i2,iIN)
coup(7) = cplcFdGluSdL(i2,gt2)
coup(8) = cplcFdGluSdR(i2,gt2)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 4._dp/3._dp*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Glu Sd cCha Propagator: Fd,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(1,gt2,gt3,Isum)= 0._dp
Else
gSum(1,gt2,gt3,Isum)= resS
End If
Contribution(1,gt2,gt3,Isum)='Fd,Fd'
End Do
End Do
Else
gSum(1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt2=1,6
Do gt3=1,2
g(1,gt2,gt3)=Sum(gSum(1,gt2,gt3,1:36))
If (g(1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(1,gt2,gt3)=0._dp
End If
End Do
End Do
End Subroutine SuToGluSdcCha
Subroutine SuToSdFvcFe(iIN,MSd,MFv,MFe,MVWm,MHpm,MSu,cplSdcHpmcSu,cplSdcSucVWm, &
& cplcFeFvHpmL,cplcFeFvHpmR,cplcFeFvVWmL,cplcFeFvVWmR,deltaM,epsI,check,g, &
& WriteContributions)
Implicit None
Real(dp),Intent(in) :: MSd(6),MFv(6),MFe(3),MVWm,MHpm(2),MSu(6)
Complex(dp),Intent(in) :: cplSdcHpmcSu(6,2,6),cplSdcSucVWm(6,6),cplcFeFvHpmL(3,6,2),cplcFeFvHpmR(3,6,2), &
& cplcFeFvVWmL(3,6),cplcFeFvVWmR(3,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 9
Allocate( gSum(6,6,3, Isum) )
Allocate( Contribution(6,6,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1,6
Do gt2=1,6
Do gt3=1,3
Isum = 0
rk2 = (MFv(gt2)/MSu(iIN))**2
rm2 = (MFe(gt3)/MSu(iIN))**2
rj2 = (MSd(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFe(gt3))+Abs(MFv(gt2))+Abs(MSd(gt1)))) Then
!--------------
! conj[VWm]
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MVWm
mass(2) = MVWm
m_in = MSu(iIN)
coup(1) = Conjg(cplSdcSucVWm(gt1,iIN))
coup(3) = Conjg(cplcFeFvVWmL(gt3,gt2))
coup(2) = Conjg(cplcFeFvVWmR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fv cFe Propagator: conj[VWm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm]'
!--------------
! conj[Hpm]
!--------------
Do i1=1,2
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MHpm(i1)
mass(2) = MHpm(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplSdcHpmcSu(gt1,i1,iIN))
coup(3) = Conjg(cplcFeFvHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFvHpmR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fv cFe Propagator: conj[Hpm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm]'
End Do
!--------------
! conj[VWm], conj[Hpm]
!--------------
Do i2=1,2
Isum = Isum + 1
resS = 0._dp
mass(2) = MVWm
mass(1) = MHpm(i2)
coup(1) = cplSdcSucVWm(gt1,iIN)
coup(2) = Conjg(cplcFeFvVWmL(gt3,gt2))
coup(3) = Conjg(cplcFeFvVWmR(gt3,gt2))
coup(4) = cplSdcHpmcSu(gt1,i2,iIN)
coup(5) = Conjg(cplcFeFvHpmL(gt3,gt2,i2))
coup(6) = Conjg(cplcFeFvHpmR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fv cFe Propagator: conj[VWm],conj[Hpm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[VWm],conj[Hpm]'
End Do
!--------------
! conj[Hpm], conj[Hpm]
!--------------
Do i1=1,1
Do i2=i1+1,2
Isum = Isum + 1
resS = 0._dp
mass(1) = MHpm(i1)
mass(2) = MHpm(i2)
coup(1) = cplSdcHpmcSu(gt1,i1,iIN)
coup(3) = Conjg(cplcFeFvHpmL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFvHpmR(gt3,gt2,i1))
coup(4) = cplSdcHpmcSu(gt1,i2,iIN)
coup(6) = Conjg(cplcFeFvHpmL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeFvHpmR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Sd Fv cFe Propagator: conj[Hpm],conj[Hpm]"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='conj[Hpm],conj[Hpm]'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1,6
Do gt2=1,6
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:9))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToSdFvcFe
Subroutine SuToSuChacCha(iIN,MSu,MCha,MVZ,MAh,Mhh,MFd,cplAhSucSu,cplhhSucSu, &
& cplSucSuVZ,cplcChaChaAhL,cplcChaChaAhR,cplcChaChahhL,cplcChaChahhR,cplcChaChaVZL, &
& cplcChaChaVZR,cplcChaFdcSuL,cplcChaFdcSuR,cplcFdChaSuL,cplcFdChaSuR,deltaM, &
& epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MSu(6),MCha(2),MVZ,MAh(3),Mhh(3),MFd(3)
Complex(dp),Intent(in) :: cplAhSucSu(3,6,6),cplhhSucSu(3,6,6),cplSucSuVZ(6,6),cplcChaChaAhL(2,2,3), &
& cplcChaChaAhR(2,2,3),cplcChaChahhL(2,2,3),cplcChaChahhR(2,2,3),cplcChaChaVZL(2,2), &
& cplcChaChaVZR(2,2),cplcChaFdcSuL(2,3,6),cplcChaFdcSuR(2,3,6),cplcFdChaSuL(3,2,6), &
& cplcFdChaSuR(3,2,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 100
Allocate( gSum(6,2,2, Isum) )
Allocate( Contribution(6,2,2, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1, iIN-1
Do gt2=1,2
Do gt3=1,2
Isum = 0
rk2 = (MCha(gt2)/MSu(iIN))**2
rm2 = (MCha(gt3)/MSu(iIN))**2
rj2 = (MSu(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MCha(gt3))+Abs(MCha(gt2))+Abs(MSu(gt1)))) Then
!--------------
! VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MVZ
mass(2) = MVZ
m_in = MSu(iIN)
coup(1) = Conjg(cplSucSuVZ(gt1,iIN))
coup(3) = Conjg(cplcChaChaVZL(gt3,gt2))
coup(2) = Conjg(cplcChaChaVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: VZ"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'
!--------------
! Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplAhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
End Do
!--------------
! hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplhhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplcChaChahhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChahhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
End Do
!--------------
! Fd
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i1)
m_in = MSu(iIN)
coup(2) = Conjg(cplcChaFdcSuL(gt3,i1,iIN))
coup(1) = Conjg(cplcChaFdcSuR(gt3,i1,iIN))
coup(4) = Conjg(cplcFdChaSuL(i1,gt2,gt1))
coup(3) = Conjg(cplcFdChaSuR(i1,gt2,gt1))
coup(5:8) = coup(1:4)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Fd'
End Do
!--------------
! VZ, Ah
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplcChaChaVZL(gt3,gt2))
coup(3) = Conjg(cplcChaChaVZR(gt3,gt2))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplcChaChaAhL(gt3,gt2,i2))
coup(6) = Conjg(cplcChaChaAhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: VZ,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
End Do
!--------------
! VZ, hh
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplcChaChaVZL(gt3,gt2))
coup(3) = Conjg(cplcChaChaVZR(gt3,gt2))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplcChaChahhL(gt3,gt2,i2))
coup(6) = Conjg(cplcChaChahhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: VZ,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
End Do
!--------------
! VZ, Fd
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ2
mass(1) = MFd2(i2)
coup(1) = cplcChaFdcSuL(gt3,i2,iIN)
coup(2) = cplcChaFdcSuR(gt3,i2,iIN)
coup(4) = Conjg(cplcFdChaSuL(i2,gt2,gt1))
coup(3) = Conjg(cplcFdChaSuR(i2,gt2,gt1))
coup(5) = cplSucSuVZ(gt1,iIN)
coup(7) = Conjg(cplcChaChaVZL(gt3,gt2))
coup(6) = Conjg(cplcChaChaVZR(gt3,gt2))
Call IntegrateVF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
resC = 1*resC ! Color factor
If (resC.ne.resC) resC = 0._dp
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: VZ,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Fd'
End Do
!--------------
! Ah, Ah
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcChaChaAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaChaAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: Ah,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
End Do
End Do
!--------------
! Ah, hh
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcChaChahhL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaChahhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: Ah,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
End Do
End Do
!--------------
! Ah, Fd
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MAh(i1)
mass(1) = MFd(i2)
coup(1) = cplcChaFdcSuL(gt3,i2,iIN)
coup(2) = cplcChaFdcSuR(gt3,i2,iIN)
coup(4) = Conjg(cplcFdChaSuL(i2,gt2,gt1))
coup(3) = Conjg(cplcFdChaSuR(i2,gt2,gt1))
coup(5) = cplAhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplcChaChaAhL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChaAhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: Ah,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Fd'
End Do
End Do
!--------------
! hh, hh
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcChaChahhL(gt3,gt2,i1))
coup(2) = Conjg(cplcChaChahhR(gt3,gt2,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcChaChahhL(gt3,gt2,i2))
coup(5) = Conjg(cplcChaChahhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: hh,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
End Do
End Do
!--------------
! hh, Fd
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = Mhh(i1)
mass(1) = MFd(i2)
coup(1) = cplcChaFdcSuL(gt3,i2,iIN)
coup(2) = cplcChaFdcSuR(gt3,i2,iIN)
coup(4) = Conjg(cplcFdChaSuL(i2,gt2,gt1))
coup(3) = Conjg(cplcFdChaSuR(i2,gt2,gt1))
coup(5) = cplhhSucSu(i1,gt1,iIN)
coup(7) = Conjg(cplcChaChahhL(gt3,gt2,i1))
coup(6) = Conjg(cplcChaChahhR(gt3,gt2,i1))
Call IntegrateSF(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: hh,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,Fd'
End Do
End Do
!--------------
! Fd, Fd
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MFd(i1)
mass(2) = MFd(i2)
coup(1) = cplcChaFdcSuL(gt3,i1,iIN)
coup(2) = cplcChaFdcSuR(gt3,i1,iIN)
coup(3) = cplcFdChaSuL(i1,gt2,gt1)
coup(4) = cplcFdChaSuR(i1,gt2,gt1)
coup(5) = cplcChaFdcSuL(gt3,i2,iIN)
coup(6) = cplcChaFdcSuR(gt3,i2,iIN)
coup(7) = cplcFdChaSuL(i2,gt2,gt1)
coup(8) = cplcFdChaSuR(i2,gt2,gt1)
Call IntegrateFFLM(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Cha cCha Propagator: Fd,Fd"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Fd,Fd'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1, iIN-1
Do gt2=1,2
Do gt3=1,2
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:100))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToSuChacCha
Subroutine SuToSuFecFe(iIN,MSu,MFe,MVZ,MAh,Mhh,cplAhSucSu,cplhhSucSu,cplSucSuVZ, &
& cplcFeFeAhL,cplcFeFeAhR,cplcFeFehhL,cplcFeFehhR,cplcFeFeVZL,cplcFeFeVZR, &
& deltaM,epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MSu(6),MFe(3),MVZ,MAh(3),Mhh(3)
Complex(dp),Intent(in) :: cplAhSucSu(3,6,6),cplhhSucSu(3,6,6),cplSucSuVZ(6,6),cplcFeFeAhL(3,3,3), &
& cplcFeFeAhR(3,3,3),cplcFeFehhL(3,3,3),cplcFeFehhR(3,3,3),cplcFeFeVZL(3,3), &
& cplcFeFeVZR(3,3)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 49
Allocate( gSum(6,3,3, Isum) )
Allocate( Contribution(6,3,3, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1, iIN-1
Do gt2=1,3
Do gt3=1,3
Isum = 0
rk2 = (MFe(gt2)/MSu(iIN))**2
rm2 = (MFe(gt3)/MSu(iIN))**2
rj2 = (MSu(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFe(gt3))+Abs(MFe(gt2))+Abs(MSu(gt1)))) Then
!--------------
! VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MVZ
mass(2) = MVZ
m_in = MSu(iIN)
coup(1) = Conjg(cplSucSuVZ(gt1,iIN))
coup(3) = Conjg(cplcFeFeVZL(gt3,gt2))
coup(2) = Conjg(cplcFeFeVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fe cFe Propagator: VZ"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'
!--------------
! Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplAhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fe cFe Propagator: Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
End Do
!--------------
! hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplhhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplcFeFehhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFehhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fe cFe Propagator: hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
End Do
!--------------
! VZ, Ah
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplcFeFeVZL(gt3,gt2))
coup(3) = Conjg(cplcFeFeVZR(gt3,gt2))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplcFeFeAhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFeFeAhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fe cFe Propagator: VZ,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
End Do
!--------------
! VZ, hh
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplcFeFeVZL(gt3,gt2))
coup(3) = Conjg(cplcFeFeVZR(gt3,gt2))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplcFeFehhL(gt3,gt2,i2))
coup(6) = Conjg(cplcFeFehhR(gt3,gt2,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fe cFe Propagator: VZ,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
End Do
!--------------
! Ah, Ah
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcFeFeAhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeFeAhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fe cFe Propagator: Ah,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
End Do
End Do
!--------------
! Ah, hh
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcFeFeAhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFeAhR(gt3,gt2,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcFeFehhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeFehhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fe cFe Propagator: Ah,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
End Do
End Do
!--------------
! hh, hh
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplcFeFehhL(gt3,gt2,i1))
coup(2) = Conjg(cplcFeFehhR(gt3,gt2,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplcFeFehhL(gt3,gt2,i2))
coup(5) = Conjg(cplcFeFehhR(gt3,gt2,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fe cFe Propagator: hh,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1, iIN-1
Do gt2=1,3
Do gt3=1,3
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:49))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToSuFecFe
Subroutine SuToSuFvFv(iIN,MSu,MFv,MVZ,MAh,Mhh,cplAhSucSu,cplhhSucSu,cplSucSuVZ, &
& cplFvFvAhL,cplFvFvAhR,cplFvFvhhL,cplFvFvhhR,cplFvFvVZL,cplFvFvVZR,deltaM, &
& epsI,check,g,WriteContributions)
Implicit None
Real(dp),Intent(in) :: MSu(6),MFv(6),MVZ,MAh(3),Mhh(3)
Complex(dp),Intent(in) :: cplAhSucSu(3,6,6),cplhhSucSu(3,6,6),cplSucSuVZ(6,6),cplFvFvAhL(6,6,3),cplFvFvAhR(6,6,3),&
& cplFvFvhhL(6,6,3),cplFvFvhhR(6,6,3),cplFvFvVZL(6,6),cplFvFvVZR(6,6)
Real(dp),Intent(inout)::g(:,:,:)
Logical, Intent(in) :: check
Integer, Intent(in) :: iIN
Real(dp), Intent(in) :: epsI, deltaM
Logical, Optional :: WriteContributions
Integer :: i1,i2,gt1,gt2,gt3, Isum
Real(dp) :: resR, res1, res2, resD, m_in
Complex(dp) :: resC, resS
Real(dp), Allocatable :: gSum(:,:,:,:)
Character(len=20), Allocatable :: Contribution(:,:,:,:)
Real(dp)::smin,smax,smin2,smax2,rj2,rk2,rm2
Real(dp)::r_out(3),r_outcrossed(3)
Real(dp)::mass(3)
Complex(dp)::coup(10)
mass(1) = MSu(iIN)
Isum = 49
Allocate( gSum(6,6,6, Isum) )
Allocate( Contribution(6,6,6, Isum) )
gSum = 0._dp
Contribution = ' '
Isum = 0
Do gt1=1, iIN-1
Do gt2=1,6
Do gt3=gt2,6
Isum = 0
rk2 = (MFv(gt2)/MSu(iIN))**2
rm2 = (MFv(gt3)/MSu(iIN))**2
rj2 = (MSu(gt1)/MSu(iIN))**2
smin=2._dp*Sqrt(rk2)
smax=1._dp+rk2-rj2-rm2-2._dp*Sqrt(rj2*rm2)
smin2=2._dp*Sqrt(rm2)
smax2=1._dp+rm2-rj2-rk2-2._dp*Sqrt(rj2*rk2)
m_in=MSu(iIN)
r_out(1)=rj2
r_out(2)=rk2
r_out(3)=rm2
r_outcrossed(1)=rj2
r_outcrossed(2)=rm2
r_outcrossed(3)=rk2
If(Abs(MSu(iIN)).gt.(Abs(MFv(gt3))+Abs(MFv(gt2))+Abs(MSu(gt1)))) Then
!--------------
! VZ
!--------------
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MVZ
mass(2) = MVZ
m_in = MSu(iIN)
coup(1) = Conjg(cplSucSuVZ(gt1,iIN))
coup(3) = Conjg(cplFvFvVZL(gt2,gt3))
coup(2) = Conjg(cplFvFvVZR(gt2,gt3))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MVZ
mass(2) = MVZ
m_in = MSu(iIN)
coup(1) = Conjg(cplSucSuVZ(gt1,iIN))
coup(3) = Conjg(cplFvFvVZL(gt3,gt2))
coup(2) = Conjg(cplFvFvVZR(gt3,gt2))
coup(4:6) = coup(1:3)
Call IntegrateVV(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fv Fv Propagator: VZ"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='VZ'
!--------------
! Ah
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplAhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvAhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MAh(i1)
mass(2) = MAh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplAhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplFvFvAhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvAhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = MAh(i1)
mass(2) = MAh(i1)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplFvFvAhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvAhR(gt3,gt2,i1))
coup(4) = cplAhSucSu(i1,gt1,iIN)
coup(6) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(5) = Conjg(cplFvFvAhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fv Fv Propagator: Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='Ah'
End Do
!--------------
! hh
!--------------
Do i1=1,3
Isum = Isum + 1
resS=0._dp
resD=0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplhhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvhhR(gt2,gt3,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
m_in = MSu(iIN)
coup(1) = Conjg(cplhhSucSu(i1,gt1,iIN))
coup(3) = Conjg(cplFvFvhhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvhhR(gt3,gt2,i1))
coup(4:6) = coup(1:3)
Call IntegrateSaSa(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
mass(1) = Mhh(i1)
mass(2) = Mhh(i1)
coup(1) = cplhhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplFvFvhhL(gt3,gt2,i1))
coup(2) = Conjg(cplFvFvhhR(gt3,gt2,i1))
coup(4) = cplhhSucSu(i1,gt1,iIN)
coup(6) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(5) = Conjg(cplFvFvhhR(gt2,gt3,i1))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
resD = resD + resS
If (resD.ne.resD) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fv Fv Propagator: hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)=resD
End If
Contribution(gt1,gt2,gt3,Isum)='hh'
End Do
!--------------
! VZ, Ah
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = MAh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplFvFvVZL(gt2,gt3))
coup(3) = Conjg(cplFvFvVZR(gt2,gt3))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplFvFvAhL(gt2,gt3,i2))
coup(6) = Conjg(cplFvFvAhR(gt2,gt3,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fv Fv Propagator: VZ,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,Ah'
End Do
!--------------
! VZ, hh
!--------------
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(2) = MVZ
mass(1) = Mhh(i2)
coup(1) = cplSucSuVZ(gt1,iIN)
coup(2) = Conjg(cplFvFvVZL(gt2,gt3))
coup(3) = Conjg(cplFvFvVZR(gt2,gt3))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(5) = Conjg(cplFvFvhhL(gt2,gt3,i2))
coup(6) = Conjg(cplFvFvhhR(gt2,gt3,i2))
If(Abs(mass(1)-mass(2)).lt.0.1) Then
Call IntegrateVSGoldstone(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
Else
Call IntegrateVS(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
End If
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fv Fv Propagator: VZ,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='VZ,hh'
End Do
!--------------
! Ah, Ah
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = MAh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvAhR(gt2,gt3,i1))
coup(4) = cplAhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplFvFvAhL(gt2,gt3,i2))
coup(5) = Conjg(cplFvFvAhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fv Fv Propagator: Ah,Ah"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,Ah'
End Do
End Do
!--------------
! Ah, hh
!--------------
Do i1=1,3
Do i2=1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = MAh(i1)
mass(2) = Mhh(i2)
coup(1) = cplAhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplFvFvAhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvAhR(gt2,gt3,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplFvFvhhL(gt2,gt3,i2))
coup(5) = Conjg(cplFvFvhhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fv Fv Propagator: Ah,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='Ah,hh'
End Do
End Do
!--------------
! hh, hh
!--------------
Do i1=1,2
Do i2=i1+1,3
Isum = Isum + 1
resS = 0._dp
mass(1) = Mhh(i1)
mass(2) = Mhh(i2)
coup(1) = cplhhSucSu(i1,gt1,iIN)
coup(3) = Conjg(cplFvFvhhL(gt2,gt3,i1))
coup(2) = Conjg(cplFvFvhhR(gt2,gt3,i1))
coup(4) = cplhhSucSu(i2,gt1,iIN)
coup(6) = Conjg(cplFvFvhhL(gt2,gt3,i2))
coup(5) = Conjg(cplFvFvhhR(gt2,gt3,i2))
Call IntegrateSaSb(mass,m_in,r_out,coup,smin,smax,epsI,resC)
If (resC.ne.resC) resC = 0._dp
resC = 2._dp*resC
resC = 1*resC ! Color factor
If (gt3.Eq.gt2) Then
resC=resC/2._dp
End If
resS = resS + resC
If (resS.ne.resS) Then
Write(*,*) "NaN appearing in the following diagrams: "
Write(*,*) "Su->Su Fv Fv Propagator: hh,hh"
Write(*,*) "M_in: ",m_in
Write(*,*) "mass: ",mass
Write(*,*) "coup: ",coup
gSum(gt1,gt2,gt3,Isum)= 0._dp
Else
gSum(gt1,gt2,gt3,Isum)= resS
End If
Contribution(gt1,gt2,gt3,Isum)='hh,hh'
End Do
End Do
Else
gSum(gt1,gt2,gt3,:)= 0._dp
End If
End Do
End Do
End Do
!----------
!Summing
!----------
g=0._dp
Do gt1=1, iIN-1
Do gt2=1,6
Do gt3=gt2,6
g(gt1,gt2,gt3)=Sum(gSum(gt1,gt2,gt3,1:49))
If (g(gt1,gt2,gt3).Lt.0._dp) Then
Write (ErrCan,*)'Error in Subroutine'//NameOfUnit(Iname)
g(gt1,gt2,gt3)=0._dp
End If
End Do
End Do
End Do
End Subroutine SuToSuFvFv
End Module Su3Decays_seesaw1nmssm
| Externals/SPheno-4.0.3/shl-seesaw1-nmssm/3-Body-Decays/su.f90 |
You may have seen them passing through the MU, or getting in the way during a high bike traffic part of the day, but you know you love them. UC Davis tours run 7 days a week, providing walking tours to prospective students. Family walking tours depart from the Buehler Alumni & Visitors Center Walter A. Buehler Alumni & Visitor Center Monday thru Friday at 9:00am and 1:00pm. Weekend tours depart at 11:00am. More tours are usually added during the spring and summer, when most prospective students visit. Many students take them before coming to UC Davis and more than likely found the 1.5 hour trek daunting yet exciting! The award winning UC Davis campus tour seems to serve as a gateway into campus life. As well, the tours are led by an amazing team of tour guides who not only point out important aspects of campus and field often obscure questions, but do it all while walking backwards!
interesting tour stories and anecdotes are not only welcomed but encouraged
Students of all ages come on tours of UC Davis. I once took a group of 50 brownie girl scout around the campus, and despite the fact that we had so much diversity in majors, nationally awarded programs, worldrenowned professors, and the largest dining hall on the west coast, the only thing these prospective students cared about were the squirrels...
Users/SteffiChristiana
I once got a question about whether or not there are fights on campus. Realizing that students from high schools may be accustomed to delinquentrelated violence, I assured the group that fights were extremely rare on campus and I had never actually seen one myself. As luck would have it, we were walking through the center of the quad, and there was a group of about fifteen students having a pillow fight. Avert your eyes, ladies and gentlemen, I said melodramatically. Its a fight!
Users/KatherineHarnack
While crossing the street by Cruess Hall, I spotted some money in the middle of the bike circle and commented on it. This was clearly a mistake, as my entire tour group sprinted into the middle of the bike circle and started fighting over the handful of bills. Keep in mind these were grown men, not high schoolers...
20051226 10:03:48 nbsp In the spring whenever they come through the dorm areas, I always have the irresistable urge to say, Observe the freshman in its natural habitat, but be careful. They may become aggressive when threatened. Users/AllisonEriksen
20060411 23:40:09 nbsp Allison, are you even a tour guide? Or are you one of those random people who yell out at the tour groups? Users/ChuckMelton
20060608 21:58:33 nbsp Whenever I see a tour group passing by, I walk into the middle of it and start following the guide... at least for a few blocks. Its fun. I get to learn random trivia about the school, and the touring students seem to find it amusing. Users/NumiaCairaguas
20060609 08:32:11 nbsp Im no tour guide, but I have yet to actually yell at them. Users/AllisonEriksen
20060906 20:47:26 nbsp As a tour guide, I have to admit...we may actually say that once in a while :) Users/SteffiChristiana
20061213 16:05:43 nbsp Allison, I got to give you credit, I say your line on my tours now, and I get laughs everytime! Thanks, Users/EricFriedman
20091119 00:15:47 nbsp how does one apply to be a tour guide? Users/HarrisonNoah
| lab/davisWiki/UC_Davis_Tours.f |
!
! Copyright 2017-2019 SALMON developers
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!
subroutine check_numcpu
use salmon_parallel, only: nproc_size_global
use scf_data
use new_world_sub
implicit none
integer :: j
if(nproc_k*nproc_ob*nproc_Mxin(1)*nproc_Mxin(2)*nproc_Mxin(3)/=nproc_size_global)then
write(*,*) "inumcpu_check error!"
write(*,*) "number of cpu is not correct!"
stop
end if
do j=1,3
if(nproc_Mxin_s(j)<nproc_Mxin(j))then
write(*,*) "inumcpu_check error!"
write(*,*) "nproc_Mxin_s is smaller than nproc_Mxin."
stop
end if
end do
if(nproc_Mxin_s(1)*nproc_Mxin_s(2)*nproc_Mxin_s(3)>nproc_size_global)then
write(*,*) "inumcpu_check error!"
write(*,*) "product of nproc_Mxin_s is larger than nproc."
stop
end if
if(mod(nproc_Mxin_s(1),nproc_Mxin(1))/=0)then
write(*,*) "inumcpu_check error!"
write(*,*) "nproc_Mxin_s(1) is not mutiple of nproc_Mxin(1)."
stop
end if
if(mod(nproc_Mxin_s(2),nproc_Mxin(2))/=0)then
write(*,*) "inumcpu_check error!"
write(*,*) "nproc_Mxin_s(2) is not mutiple of nproc_Mxin(2)."
stop
end if
if(mod(nproc_Mxin_s(3),nproc_Mxin(3))/=0)then
write(*,*) "inumcpu_check error!"
write(*,*) "nproc_Mxin_s(3) is not mutiple of nproc_Mxin(3)."
stop
end if
nproc_Mxin_s_dm(1:3)=nproc_Mxin_s(1:3)/nproc_Mxin(1:3)
if(ilsda==1)then
if(nproc_ob>1)then
write(*,*) "Orbital parallelization is not currently supported. It will be supported in future."
stop
end if
end if
end subroutine check_numcpu
| src/GCEED/common/check_numcpu.f90 |
program main
! 2D model of crystal growth based on diffusion-limited aggregation
implicit none
integer :: clock, n, i
integer, allocatable :: seed(:)
integer, parameter :: map_size_x = 1024, map_size_y = 1024, n_particle = 1000
integer :: map(0:map_size_x - 1, 0:map_size_y - 1)
integer :: x, y
! seed initialization
call SYSTEM_CLOCK(clock)
call RANDOM_SEED(size = n)
allocate(seed(n))
do i = 1, n
seed(i) = clock + 37 * i
end do
call RANDOM_SEED(put = seed)
! map initialization
do x = 0, map_size_x - 1
do y = 0, map_size_y - 1
map(x, y) = 0
end do
end do
map(map_size_x / 2, map_size_y / 2) = 1
open(unit = 1, file = 'crystal.txt', status = 'unknown')
write(1, '(2i5)') map_size_x / 2, map_size_y / 2
close(1)
! particle aggregation
do i = 1, n_particle
do while (.true.)
call INITIAL_POSITION(x, y, map_size_x, map_size_y)
if (map(x, y) == 0) exit
end do
do while (.true.)
call RANDOM_WALK(x, y, map_size_x, map_size_y)
if ((map(modulo(x - 1, map_size_x), y) == 1) &
.or. (map(modulo(x + 1, map_size_x), y) == 1) &
.or. (map(x, modulo(y - 1, map_size_y)) == 1) &
.or. (map(x, modulo(y + 1, map_size_y))) == 1) then
map(x, y) = 1
exit
end if
end do
open(unit = 1, file = 'crystal.txt', status = 'old', position = 'append')
write(1, '(2i5)') x, y
close(1)
end do
close(1)
end program main
subroutine INITIAL_POSITION(x, y, map_size_x, map_size_y)
real :: r
integer, intent(inout) :: x, y
integer, intent(in) :: map_size_x, map_size_y
call RANDOM_NUMBER(r)
if (r < .25d0) then
x = 0
y = floor(r * 4.d0 * dble(map_size_y))
elseif (r < .5d0) then
x = map_size_x - 1
y = floor((r - .25d0) * 4.d0 * dble(map_size_y))
elseif (r < .75d0) then
x = floor((r - .5d0) * 4.d0 * dble(map_size_x))
y = 0
else
x = floor((r - .75d0) * 4.d0 * dble(map_size_x))
y = map_size_y - 1
end if
end subroutine INITIAL_POSITION
subroutine RANDOM_WALK(x, y, map_size_x, map_size_y)
real :: r
integer, intent(inout) :: x, y
integer, intent(in) :: map_size_x, map_size_y
call RANDOM_NUMBER(r)
if (r < .25d0) then
x = modulo(x - 1, map_size_x)
elseif (r < .5d0) then
x = modulo(x + 1, map_size_x)
elseif (r < .75d0) then
y = modulo(y - 1, map_size_y)
else
y = modulo(y + 1, map_size_y)
end if
end subroutine RANDOM_WALK
| Week-13/1-DLA.f90 |
! program demo_lbound
module m_bounds
implicit none
contains
subroutine msub(arr)
!!integer,intent(in) :: arr(*) ! cannot be assumed-size array
integer,intent(in) :: arr(:)
write(*,*)'MSUB: LOWER=',lbound(arr), &
& 'UPPER=',ubound(arr), &
& 'SIZE=',size(arr)
end subroutine msub
end module m_bounds
use m_bounds, only : msub
implicit none
interface
subroutine esub(arr)
integer,intent(in) :: arr(:)
end subroutine esub
end interface
integer :: arr(-10:10)
write(*,*)'MAIN: LOWER=',lbound(arr), &
& 'UPPER=',ubound(arr), &
& 'SIZE=',size(arr)
call csub()
call msub(arr)
call esub(arr)
contains
subroutine csub
write(*,*)'CSUB: LOWER=',lbound(arr), &
& 'UPPER=',ubound(arr), &
& 'SIZE=',size(arr)
end subroutine csub
end
subroutine esub(arr)
implicit none
integer,intent(in) :: arr(:)
! WARNING: IF CALLED WITHOUT AN EXPLICIT INTERFACE
! THIS WILL GIVE UNDEFINED ANSWERS (like 0,0,0)
write(*,*)'ESUB: LOWER=',lbound(arr), &
& 'UPPER=',ubound(arr), &
& 'SIZE=',size(arr)
end subroutine esub
!end program demo_lbound
| example/lbound.f90 |
PROGRAM SCALAR01
REAL X
PRINT *,X
END
| packages/PIPS/validation/UseBeforeSet/scalar01.f |
less_toxic(q1,t1).
less_toxic(dd1,p1).
less_toxic(j1,v1).
less_toxic(kk1,b1).
less_toxic(ll1,t1).
less_toxic(j1,i1).
less_toxic(j1,jj1).
less_toxic(ee1,cc1).
less_toxic(w1,u1).
less_toxic(o1,u1).
less_toxic(j1,z1).
less_toxic(k1,c1).
less_toxic(k1,cc1).
less_toxic(hh1,f1).
less_toxic(i1,f1).
less_toxic(m1,a1).
less_toxic(t1,c1).
less_toxic(cc1,a1).
less_toxic(ee1,f1).
less_toxic(n1,l1).
less_toxic(w1,e1).
less_toxic(cc1,h1).
less_toxic(hh1,e1).
less_toxic(bb1,e1).
less_toxic(g1,dd1).
less_toxic(ll1,d1).
less_toxic(m1,d1).
less_toxic(hh1,c1).
less_toxic(kk1,e1).
less_toxic(g1,z1).
less_toxic(x1,a1).
less_toxic(l1,d1).
less_toxic(b1,dd1).
less_toxic(ii1,u1).
less_toxic(g1,a1).
less_toxic(m1,l1).
less_toxic(ll1,i1).
less_toxic(t1,p1).
less_toxic(w1,f1).
less_toxic(kk1,a1).
less_toxic(m1,aa1).
less_toxic(n1,w1).
less_toxic(bb1,z1).
less_toxic(k1,a1).
| foldsCreator/files/datasets/alzheimer_toxic_0.1noisy/test2.f |
#include "scalar.fpp"
!=====================================================================!
! Newmark-Beta-Gamma Integration Module for first and second order
! systems with adjoint derivative capabilities.
!
! Author: Komahan Boopathy ([email protected])
!=====================================================================!
module nbg_integrator
use integrator_class, only : integrator
use physics_class, only : physics
implicit none
private
public :: NBG
type(scalar), parameter :: ONE = 1.0d0
type(scalar), parameter :: ZERO = 0.0d0
!===================================================================!
! NBG Integrator type
!===================================================================!
type, extends(integrator) :: NBG
! Average Constant Accelearation (second order unconditionally stable)
type(scalar) :: BETA = 0.25d0
type(scalar) :: GAMMA = 0.50d0
!!$ ! Fox & Goodwin (third order & conditionally stable wh=2.45)
!!$ type(scalar) :: BETA = 1.0d0/12.0d0
!!$ type(scalar) :: GAMMA = 0.50d0
!!$
!!$ ! Linear Acceleration (second order & conditionally stable wh=3.46)
!!$ type(scalar) :: BETA = 1.0d0/6.0d0
!!$ type(scalar) :: GAMMA = 0.50d0
!!$
!!$ ! Central Difference (second order & conditionally stable wh=2)
!!$ type(scalar) :: BETA = 1.0d0/2.0d0
!!$ type(scalar) :: GAMMA = 0.50d0
!!$ ! Purely Explicit
!!$ type(scalar) :: BETA = 0.0d0
!!$ type(scalar) :: GAMMA = 0.0d0
type(scalar), allocatable, dimension(:) :: rho
type(scalar), allocatable, dimension(:) :: sigma
contains
! Destructor
procedure, public :: finalize
! Routines for integration
procedure, private :: approximateStates
procedure, private :: getLinearCoeff
! Routines for adjoint gradient
procedure, public :: marchBackwards
procedure, private :: assembleRHS
procedure :: computeTotalDerivative
end type NBG
interface NBG
module procedure initialize
end interface NBG
contains
!===================================================================!
! Initialize the NBG datatype and allocate required variables
!===================================================================!
type(nbg) function initialize( system, tinit, tfinal, h, second_order ) result (this)
class(physics), target :: system
real(dp) , OPTIONAL, intent(in) :: tinit, tfinal
real(dp) , OPTIONAL, intent(in) :: h
logical , OPTIONAL, intent(in) :: second_order
print *, "======================================"
print *, ">> Newmark Beta Gamma (NBG) << "
print *, "======================================"
call this % construct(system, tinit, tfinal, h, second_order)
!-----------------------------------------------------------------!
! Allocate space for auxiliary adjoint variables
!-----------------------------------------------------------------!
allocate(this % rho(this % nsvars))
this % rho = 0.0d0
allocate(this % sigma(this % nsvars))
this % sigma = 0.0d0
!-----------------------------------------------------------------!
! Setup adjoint RHS
!-----------------------------------------------------------------!
this % num_rhs_bins = 2
allocate(this % rhs(this % nsvars))
this % rhs = 0.0d0
end function initialize
!===================================================================!
! Deallocate the allocated variables
!===================================================================!
subroutine finalize( this )
class(NBG) :: this
call this % destruct()
! Clear global states and time
if(allocated(this % rho)) deallocate(this % rho)
if(allocated(this % sigma)) deallocate(this % sigma)
if (allocated(this % rhs)) deallocate(this % rhs)
end subroutine finalize
!===================================================================!
! Approximate the state variables at each step using NBG formula
!===================================================================!
subroutine approximateStates( this )
class(NBG) :: this
integer :: k
type(scalar) :: scale
k = this % current_step
!-----------------------------------------------------------------!
! Assume a UDDOT for the next time step
!-----------------------------------------------------------------!
this % uddot(k,:) = this % uddot(k-1,:)
!-----------------------------------------------------------------!
! Approximate UDOT using NBG
!-----------------------------------------------------------------!
this % udot(k,:) = this % udot(k-1,:)
scale = this % h * (1.0d0 - this % GAMMA)
this % udot(k,:) = this % udot(k,:) + scale*this % uddot(k-1,:)
scale = this % h * this % GAMMA
this % udot(k,:) = this % udot(k,:) + scale*this % uddot(k,:)
!-----------------------------------------------------------------!
! Approximate U using NBG
!-----------------------------------------------------------------!
this % u(k,:) = this % u(k-1,:)
scale = this % h
this % u(k,:) = this % u(k,:) + scale*this % udot(k-1,:)
scale = this % h * this % h * (1.0d0 - 2.0d0 * this % BETA)/2.0d0
this % u(k,:) = this % u(k,:) + scale*this % uddot(k-1,:)
scale = this % h * this % h * this % BETA
this % u(k,:) = this % u(k,:) + scale*this % uddot(k,:)
end subroutine approximateStates
!===================================================================!
! Returns the linearization scalar coefficients: alpha, beta, gamma
!===================================================================!
subroutine getLinearCoeff( this, alpha, beta, gamma )
class(NBG) :: this
type(scalar), intent(out) :: alpha, beta, gamma
integer :: m
if ( this % second_order ) then
gamma = 1.0d0/this % h/ this % h
beta = this % GAMMA/ this % h
alpha = this % BETA
else
stop"Error: Newmark-Beta-Gamma method works for second order systems in current form..."
end if
!!$ gamma = 1.0d0
!!$ beta = this % h * this % GAMMA
!!$ alpha = this % h * this % h * this % BETA
end subroutine getLinearCoeff
!===================================================================!
! Subroutine that marches backwards in time to compute the lagrange
! multipliers (adjoint variables for the function)
! ===================================================================!
subroutine marchBackwards( this )
class(NBG) :: this
integer :: k
integer, parameter :: unit = 88
type(scalar) :: alpha, beta, gamma
open(unit=88, file=trim("nbg_adjoint.dat"))
time: do k = this % num_steps, 2, -1
this % current_step = k
!--------------------------------------------------------------!
! Determine the linearization coefficients for the Jacobian
!--------------------------------------------------------------!
call this % getLinearCoeff(alpha, beta, gamma)
!--------------------------------------------------------------!
! Solve the adjoint equation at each step
!--------------------------------------------------------------!
call this % adjointSolve(this % psi(k,:), alpha, beta, gamma, &
& this % time(k), this % u(k,:), this % udot(k,:), this % uddot(k,:))
write_output: block
type(integer) :: j
! Write the solution as output
write(unit, *) this % time(k), &
& (dble(this % psi(k,j)), j=1,this%nsvars ), &
& (dble(this % rho(j)), j=1,this%nsvars ), &
& (dble(this % sigma(j)), j=1,this%nsvars )
end block write_output
!print*, "k, psi=", k, this % psi(k,:)
end do time
end subroutine marchBackwards
!===================================================================!
! Function that puts together the right hand side of the adjoint
! equation into the supplied rhs vector.
!===================================================================!
subroutine assembleRHS( this, rhs )
class(NBG) :: this
type(scalar), dimension(:), intent(inout) :: rhs
type(scalar), dimension(:,:), allocatable :: jac
type(scalar) :: alpha, beta, gamma
type(integer) :: k
allocate( jac(this % nSVars, this % nSVars) )
k = this % current_step
! Zero the RHS first
rhs = 0.0d0
if ( k .ne. this % num_steps) then
!-----------------------------------------------------!
! Add previous residual contributions to RHS
!-----------------------------------------------------!
gamma = 0.0d0
beta = 1.0d0/this % h
alpha = 0.5d0 + this % GAMMA
! Add the state variable sensitivity from the previous step
call this % system % func % addFuncSVSens(rhs, &
& alpha, beta, gamma, &
& this % time(k+1), &
& this % system % X, &
& this % u(k+1,:), &
& this % udot(k+1,:), &
& this % uddot(k+1,:))
! Add the residual adjoint product from the previous step
call this % system % assembleJacobian(jac, &
& alpha, beta, gamma, &
& this % time(k+1), &
& this % u(k+1,:), &
& this % udot(k+1,:), &
& this % uddot(k+1,:))
rhs = rhs + matmul(transpose(jac(:,:)), this % psi(k+1,:))
!-------------------------------------------------------!
! Add similar contributions to RHS
!-------------------------------------------------------!
rhs = rhs + beta * this % sigma/this % h
rhs = rhs + alpha * this % rho/this % h
!-----------------------------------------------------------!
! Compute NEW THIS % SIGMA (k)
!-----------------------------------------------------------!
this % sigma = this % sigma + this % h * this % rho
gamma = 0.0d0
beta = this % h
alpha = this % h * this % h
! Add the state variable sensitivity from the previous step
call this % system % func % addFuncSVSens(this % sigma, &
& alpha, beta, gamma, &
& this % time(k+1), &
& this % system % X, &
& this % u(k+1,:), &
& this % udot(k+1,:), &
& this % uddot(k+1,:))
! Add the residual adjoint product from the previous step
call this % system % assembleJacobian(jac, &
& alpha, beta, gamma, &
& this % time(k+1), &
& this % u(k+1,:), &
& this % udot(k+1,:), &
& this % uddot(k+1,:))
this % sigma = this % sigma + matmul(transpose(jac(:,:)), this % psi(k+1,:))
!-----------------------------------------------------------!
! Compute THIS % RHO (K)
!-----------------------------------------------------------!
gamma = 0.0d0
beta = 0.0d0
alpha = this % h
! Add the state variable sensitivity from the previous step
call this % system % func % addFuncSVSens(this % rho, &
& alpha, beta, gamma, &
& this % time(k+1), &
& this % system % X, &
& this % u(k+1,:), &
& this % udot(k+1,:), &
& this % uddot(k+1,:))
! Add the residual adjoint product from the previous step
call this % system % assembleJacobian(jac, &
& alpha, beta, gamma, &
& this % time(k+1), &
& this % u(k+1,:), &
& this % udot(k+1,:), &
& this % uddot(k+1,:))
this % rho = this % rho + matmul(transpose(jac(:,:)), this % psi(k+1,:))
end if
! Get the coefficients
call this % getLinearCoeff( alpha, beta, gamma)
! Add the state variable sensitivity
call this % system % func % addFuncSVSens(rhs, &
& alpha, beta, gamma, &
& this % time(k), &
& this % system % X, &
& this % u(k,:), &
& this % udot(k,:), &
& this % uddot(k,:))
! Negate the RHS
rhs = -rhs
if(allocated(jac)) deallocate(jac)
end subroutine assembleRHS
!===================================================================!
! Compute the total derivative of the function with respect to the
! design variables and return the gradient
!===================================================================!
subroutine computeTotalDerivative( this, dfdx )
class(NBG) :: this
type(scalar) , dimension(:), intent(inout) :: dfdx
type(scalar) , dimension(this % nSVars, this % nDVars) :: dRdX
type(scalar) :: scale = 1.0d0
integer :: k
!scale = this % h
dfdx = 0.0d0
!-----------------------------------------------------------------!
! Compute dfdx
!-----------------------------------------------------------------!
do k = 2, this % num_steps
call this % system % func % addFuncDVSens(dfdx, scale, this % time(k), &
& this % system % x, this % u(k,:), this % udot(k,:), this % uddot(k,:) )
end do
! Initial condition
!!$ call this % system % func % addFuncDVSens(dfdx, scale, this % time(1), &
!!$ & this % system % x, this % u(1,:), this % udot(1,:), this % uddot(1,:) )
!-----------------------------------------------------------------!
! Compute the total derivative
!-----------------------------------------------------------------!
do k = 2, this % num_steps
call this % system % getResidualDVSens(dRdX, scale, this % time(k), &
& this % system % x, this % u(k,:), this % udot(k,:), this % uddot(k,:))
dfdx = dfdx + matmul(this % psi(k,:), dRdX) ! check order
end do
!!$ ! Add constraint contribution
!!$ call this % system % getResidualDVSens(dRdX, scale, this % time(1), &
!!$ & this % system % x, this % u(1,:), this % udot(1,:), this % uddot(1,:))
!!$ dfdx = dfdx + matmul(this % psi(2,:), dRdX)
! Finally multiply by the scalar
dfdx = this % h * dfdx
print*, "Check scaling of dfdx, and transpose"
end subroutine computeTotalDerivative
end module nbg_integrator
| src/newmark_beta_gamma.f90 |
!
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
! * *
! * copyright (c) 1998 by UCAR *
! * *
! * University Corporation for Atmospheric Research *
! * *
! * all rights reserved *
! * *
! * Spherepack *
! * *
! * A Package of Fortran77 Subroutines and Programs *
! * *
! * for Modeling Geophysical Processes *
! * *
! * by *
! * *
! * John Adams and Paul Swarztrauber *
! * *
! * of *
! * *
! * the National Center for Atmospheric Research *
! * *
! * Boulder, Colorado (80307) U.S.A. *
! * *
! * which is sponsored by *
! * *
! * the National Science Foundation *
! * *
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
!
!
!
! Subroutine trvsph is used to demonstrate vector data transfer between a coarse
! ten degree equally spaced grid and a higher resolution T42 Global Spectral
! Gaussian grid.
!
! Ten Degree Grid (Mathematical Spherical Coordinates)
!
! The equally spaced vector data, given in mathematical spherical
! coordinates, is stored in 19 X 36 colatitude-longitude arrays (ue, ve). The
! colatitudinal values are stored north to south with increasing colatitude
! subscript values. ue is the east longitudinal component and ve is the
! colatitudinal component of the vector.
!
! Gaussian Grid (Geophysical Spherical Coordinates)
!
! The T42 Gaussian grid vector data is in geophysical spherical coordinates.
! It is stored in 128 X 64 longitude-latitude arrays (ug, vg). Values are
! stored south to north with increasing latitude subscript value. ug
! is the longitudinal component and vg is the latitudinal componenet of the
! vector data.
!
! For testing purposes we use an analytic vector field (u, v). Let t and p
! be colatitude and longitude and x=sin(t)cos(p), y=sint(t)*sin(p), z=cos(t)
! be the cartesian coordinates restricted to the sphere in mathematical
! coordinates. We derive the vector field (u, v) from the stream function
! S and velocity function P given by
!
! y -z x z
! S = e + e , P = e + e
!
! The corresponding vector field has the form
!
! x -z y
! u = -e sin(p) + e sin(t) + e cos(t)sin(p)
!
! y z x
! v = -e cos(p) - e sin(t) + e cos(t)cos(p)
!
!
! in mathematical spherical coordinates. Values in geophysical
! coordinates can be obtained by negating v.
!
! In the code below, (ue, ve) is set equal to (u, v) and trvsph is used to
! transfer (ue, ve) to (ug, vg). (ug, vg) is then compared with (u, v) in
! geophysical coordinates on the T42 Gaussian grid. Finally, trvsph is
! used to transfer (ug, vg) back to (ue, vg) and this is compared with (u, v).
! Output from executing the test program on separate platforms with 32 bit
! and 64 bit floating point arithmetic is listed below. The minimum required
! saved and unsaved workspace lengths were predetermined by an earlier call
! trvsph with nlon_reg=36, nlat_reg=19, nlon_gau=128, nlat_gau=64, lsave=0, lwork=0 and printout
! of lsvmin and lwkmin.
!
!
! **********************************************************************
!
! OUTPUT FROM EXECUTING CODE IN THIS FILE
!
! **********************************************************************
!
! EQUALLY SPACED TO GAUSSIAN GRID TRANSFER
! trvsph input arguments:
! intl = 0
! igrid_reg(1) = -1 igrid_reg(2) = 1
! nlon_reg = 36 nlat_reg = 19
! ive = 1
! igrid_gau(1) = 2 igrid_gau(2) = 0
! nlon_gau = 128 nlat_gau = 64
! ivg = 0
! lsave = 21814 lwork = 75173
!
! trvsph output:
! ier = 0 lsvmin = 21792 lwkmin = 75173
! *** 32 BIT FLOATING POINT ARITHMETIC
! least squares error in u = 0.307E-06
! least squares error in v = 0.272E-06
! *** 64 BIT FLOATING POINT ARITHMETIC
! least squares error in u = 0.841E-12
! least squares error in v = 0.603E-12
!
! GAUSSIAN TO EQUALLY SPACED GRID TRANSFER
! trvsph input arguments:
! intl = 0
! igrid_gau(1) = 2 igrid_gau(2) = 0
! nlon_gau = 128 nlat_gau = 64
! ivg = 0
! igrid_reg(1) = -1 igrid_reg(2) = 1
! nlon_reg = 36 nlat_reg = 19
! ive = 1
! lsave = 21814 lwork = 75173
!
! trvsph output:
! ier = 0 lsvmin = 21814 lwkmin = 75173
! *** 32 BIT FLOATING POINT ARITHMETIC
! least squares error in u = 0.374E-06
! least squares error in v = 0.364E-06
! *** 64 BIT FLOATING POINT ARITHMETIC
! least squares error in u = 0.170E-12
! least squares error in v = 0.161E-12
!
! **********************************************************************
!
! END OF OUTPUT ... CODE FOLLOWS
!
! **********************************************************************
program testrvsph
use, intrinsic :: ISO_Fortran_env, only: &
stdout => OUTPUT_UNIT
use spherepack
! Explicit typing only
implicit none
! Set grid sizes with parameter statements
integer(ip), parameter :: NLAT_GAU = 64, NLON_GAU = 128
integer(ip), parameter :: NLAT_REG = 19, NLON_REG = 36
! Dimension and type data arrays and grid vectors and internal variables
real(wp) :: u_reg(NLAT_REG, NLON_REG), v_reg(NLAT_REG, NLON_REG)
real(wp) :: u_gau(NLON_GAU, NLAT_GAU), v_gau(NLON_GAU, NLAT_GAU)
real(wp) :: theta_gau(NLAT_GAU)
real(wp) :: gaussian_latitudes(NLAT_GAU), gaussian_weights(NLAT_GAU)
integer(ip) :: igrid_reg(2), igrid_gau(2), ivec_reg, ivec_gau
real(wp) :: dlat_reg, dlon_reg, dlon_gau
real(wp) :: theta, phi, cosp, sinp, cost, sint, x, y, z
real(wp) :: erru2, errv2, ex, ey, ez, emz, uee, vee
integer(ip) :: i, j, ib, intl, error_flag
real(wp), parameter :: ZERO = 0.0_wp
! Set equally spaced grid increments
dlat_reg = PI/(NLAT_REG-1)
dlon_reg = TWO_PI/NLON_REG
dlon_gau = TWO_PI/NLON_GAU
! Set initial call flag
intl = 0
! flag (ue, ve) grid as north to south equally spaced
igrid_reg(1) = -1
! flag (ue, ve) as nlat_reg by nlon_reg arrays
igrid_reg(2) = 1
! flag ve as colatitude component of vector
ivec_reg = 1
! flag (ug, vg) as south to north gaussian
igrid_gau(1) = 2
! flag (ug, vg) as nlon_gau by nlat_gau arrays
igrid_gau(2) = 0
! flag vg as latitude component of vector
ivec_gau = 0
! Set vector data in (ue, ve)
do j=1, NLON_REG
phi = real(j - 1, kind=wp)*dlon_reg
cosp = cos(phi)
sinp = sin(phi)
do i=1, NLAT_REG
theta = real(i - 1, kind=wp)*dlat_reg
cost = cos(theta)
sint = sin(theta)
x = sint*cosp
y = sint*sinp
z = cost
ex = exp(x)
ey = exp(y)
ez = exp(z)
emz = exp(-z)
v_reg(i, j) = ex*cost*cosp-ey*cosp-ez*sint
u_reg(i, j) = -ex*sinp + emz*sint + ey*cost*sinp
end do
end do
! print trvsph input arguments
write (stdout, 100) intl, igrid_reg(1), igrid_reg(2), NLON_REG, NLAT_REG, ivec_reg, &
igrid_gau(1), igrid_gau(2), NLON_GAU, NLAT_GAU, ivec_gau
100 format(//' equally spaced to gaussian vector grid transfer ' , &
/' input arguments: ' , &
/' intl = ', i2, &
/' igrid_reg(1) = ', i2, 2x, ' igrid_reg(2) = ', i2, &
/' nlon_reg = ', i3, 2x, ' nlat_reg = ', i3, &
/' ivec_reg = ', i2, &
/' igrid_gau(1) = ', i2, 2x, ' igrid_gau(2) = ', i2, &
/' nlon_gau = ', i3, 2x, ' nlat_gau = ', i3, &
/' ivec_gau = ', i2)
! Transfer (u_reg, v_reg) to (u_gau, v_gau)
call trvsph(intl, igrid_reg, NLON_REG, NLAT_REG, ivec_reg, u_reg, v_reg, &
igrid_gau, NLON_GAU, NLAT_GAU, ivec_gau, u_gau, v_gau, error_flag)
if (error_flag == 0) then
! Compute nlat_gau-many gaussian colatitude points and
! set with south to north orientation in theta_gau
call compute_gaussian_latitudes_and_weights( &
NLAT_GAU, gaussian_latitudes, gaussian_weights, error_flag)
! Reverse array
theta_gau = gaussian_latitudes(NLAT_GAU:1:-1)
! Compute the least squares error in (ug, vg)
! by comparing with exact geophysical vector
errv2 = ZERO
erru2 = ZERO
do j=1, NLON_GAU
phi = real(j - 1, kind=wp) * dlon_gau
cosp = cos(phi)
sinp = sin(phi)
do i=1, NLAT_GAU
theta = theta_gau(i)
cost = cos(theta)
sint = sin(theta)
x = sint*cosp
y = sint*sinp
z = cost
ex = exp(x)
ey = exp(y)
ez = exp(z)
emz = exp(-z)
vee = -ex*cost*cosp+ey*cosp+ez*sint
uee = -ex*sinp + emz*sint + ey*cost*sinp
erru2 = erru2 + (u_gau(j, i)-uee)**2
errv2 = errv2 + (v_gau(j, i)-vee)**2
end do
end do
erru2 = sqrt(erru2/(NLON_GAU*NLAT_GAU))
errv2 = sqrt(errv2/(NLON_GAU*NLAT_GAU))
call print_least_squared_error(erru2, errv2)
end if
! Now transfer (u_gau, v_gau) back to (u_reg, v_reg)
u_reg = ZERO
v_reg = ZERO
write (stdout, 101) intl, igrid_gau(1), igrid_gau(2), NLON_GAU, NLAT_GAU, ivec_gau, &
igrid_reg(1), igrid_reg(2), NLON_REG, NLAT_REG, ivec_reg
101 format(//' gaussian to equally spaced vector grid transfer ' , &
/' input arguments: ' , &
/' intl = ', i2, &
/' igrid_gau(1) = ', i2, 2x, ' igrid_gau(2) = ', i2, &
/' nlon_gau = ', i3, 2x, ' nlat_gau = ', i3, &
/' ivec_gau = ', i2, &
/' igrid_reg(1) = ', i2, 2x, ' igrid_reg(2) = ', i2, &
/' nlon_reg = ', i3, 2x, ' nlat_reg = ', i3, &
/' ivec_reg = ', i2)
call trvsph(intl, igrid_gau, NLON_GAU, NLAT_GAU, ivec_gau, u_gau, v_gau, &
igrid_reg, NLON_REG, NLAT_REG, ivec_reg, u_reg, v_reg, error_flag)
if (error_flag == 0) then
!
! compute the least squares error in (ue, ve)
! by comparing with exact mathematical vector
!
errv2 = ZERO
erru2 = ZERO
do j=1, NLON_REG
phi = real(j-1, kind=wp) * dlon_reg
cosp = cos(phi)
sinp = sin(phi)
do i=1, NLAT_REG
theta = real(i - 1, kind=wp) * dlat_reg
cost = cos(theta)
sint = sin(theta)
x = sint*cosp
y = sint*sinp
z = cost
ex = exp(x)
ey = exp(y)
ez = exp(z)
emz = exp(-z)
vee = ex*cost*cosp-ey*cosp-ez*sint
uee = -ex*sinp + emz*sint + ey*cost*sinp
erru2 = erru2 + (u_reg(i, j)-uee)**2
errv2 = errv2 + (v_reg(i, j)-vee)**2
end do
end do
erru2 = sqrt(erru2/(NLON_REG*NLAT_REG))
errv2 = sqrt(errv2/(NLON_REG*NLAT_REG))
call print_least_squared_error(erru2, errv2)
end if
contains
subroutine print_least_squared_error(erru2, errv2)
! Dummy arguments
real(wp), intent(in) :: erru2, errv2
write (stdout, '(2(a,e10.3/))') &
' least squares error in u = ', erru2, &
' least squares error in v = ', errv2
end subroutine print_least_squared_error
end program testrvsph
| test/testrvsph.f90 |
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
double precision function mandelagol(nintg,R1,R2,x1,x2,y1,y2,c,
. b0,mu,mulimb0,mulimbf,dist)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C Adapted from Mandel and Agol, 2002, ApJ 580, L171
implicit none
integer i,nintg,sflag
double precision R1,R2,x1,x2(nintg),y1,y2(nintg),c(4),
. c1,c2,c3,c4,mulimb0(nintg),mulimbf(nintg,5),rl,b0(nintg),
. mu(nintg),dist(nintg)
mu=0
c1=c(1)
c2=c(2)
c3=c(3)
c4=c(4)
rl=R2/R1
sflag=0
do 10 i=1,nintg
dist(i)=Sqrt((x2(i)-x1)*(x2(i)-x1)+(y2(i)-y1)*(y2(i)-y1))/(R1+R2)
c if(dist(i).ge.1.0d0)then
c sflag=sflag+1
c b0(i)=2.0
c else
b0(i)=(R1+R2)*dist(i)/R1
c endif
10 continue
c write(6,500) "hello",(b0(i),i=1,nintg)
500 format(A5,11(1X,F5.3))
if(sflag.lt.nintg) then
c call occultnl(rl,c1,c2,c3,c4,b0,mulimb0,mulimbf,nintg)
c call occultsmall(rl,c1,c2,c3,c4,nintg,b0,mulimb0)
endif
c if(b0(1).le.1.0) write(6,*)b0(1),mu
C mandelagol=mulimb0(1)
mandelagol=0.0
do 11 i=1,nintg
c mandelagol=mandelagol+mu(i)
c if(dist(i).ge.1.0d0) mulimb0(i)=1.0d0
mandelagol=mandelagol+mulimb0(i)
11 continue
mandelagol=mandelagol/dble(nintg)
c write(6,*) "hello2",mandelagol
return
end
subroutine occultsmall(p,c1,c2,c3,c4,nz,z,mu)
implicit none
integer i,nz
c parameter (nz=201)
real*8 p,c1,c2,c3,c4,z(nz),mu(nz),i1,norm,
& x,tmp,iofr,pi
C This routine approximates the lightcurve for a small
C planet. (See section 5 of Mandel & Agol (2002) for
C details):
C Input:
C p ratio of planet radius to stellar radius
C c1-c4 non-linear limb-darkening coefficients
C z impact parameters (positive number normalized to stellar
C radius)- this is an array which MUST be input to the routine
C NOTE: nz must match the size of z & mu in calling routine
C Output:
C mu flux relative to unobscured source for each z
C
pi=acos(-1.d0)
norm=pi*(1.d0-c1/5.d0-c2/3.d0-3.d0*c3/7.d0-c4/2.d0)
i1=1.d0-c1-c2-c3-c4
do i=1,nz
mu(i)=1.d0
if(z(i).gt.1.d0-p.and.z(i).lt.1.d0+p) then
x=1.d0-(z(i)-p)**2
tmp=(1.d0-c1*(1.d0-0.8d0*x**0.25)
& -c2*(1.d0-2.d0/3.d0*x**0.5)
& -c3*(1.d0-4.d0/7.d0*x**0.75)
& -c4*(1.d0-0.5d0*x))
mu(i)=1.d0-tmp*(p**2*acos((z(i)-1.d0)/p)
& -(z(i)-1.d0)*sqrt(p**2-(z(i)-1.d0)**2))/norm
endif
if(z(i).le.1.d0-p.and.z(i).ne.0.d0) then
mu(i)=1.d0-pi*p**2*iofr(c1,c2,c3,c4,z(i),p)/norm
endif
if(z(i).eq.0.d0) then
mu(i)=1.d0-pi*p**2/norm
endif
enddo
return
end
function iofr(c1,c2,c3,c4,r,p)
implicit none
real*8 r,p,c1,c2,c3,c4,sig1,sig2,iofr
sig1=sqrt(sqrt(1.d0-(r-p)**2))
sig2=sqrt(sqrt(1.d0-(r+p)**2))
iofr=1.d0-c1*(1.d0+(sig2**5-sig1**5)/5.d0/p/r)
& -c2*(1.d0+(sig2**6-sig1**6)/6.d0/p/r)
& -c3*(1.d0+(sig2**7-sig1**7)/7.d0/p/r)
& -c4*(p**2+r**2)
return
end
subroutine occultnl(rl,c1,c2,c3,c4,b0,mulimb0,mulimbf,nb)
c; Please cite Mandel & Agol (2002) if making use of this routine.
implicit none
integer i,j,nb,nr,i1,i2,nmax
parameter (nmax=2**16)
real*8 mulimbf(nb,5),pi,c1,c2,c3,c4,rl,bt0(nb),b0(nb),mulimb0(nb),
& mulimb(nb),mulimbp(nb),dt,t(nmax+1),th(nmax+1),r(nmax+1),
& sig,mulimb1(nb),mulimbhalf(nb),mulimb3half(nb),mulimb2(nb),
& sig1,sig2,omega,dmumax,fac,mu(nb),f1,f2
pi=acos(-1.d0)
C This routine uses the results for a uniform source to
C compute the lightcurve for a limb-darkened source
C (5-1-02 notes)
C Input:
C rl radius of the lens in units of the source radius
C c1-c4 limb-darkening coefficients
C b0 impact parameter normalized to source radius
C Output:
C mulimb0 limb-darkened magnification
C mulimbf lightcurves for each component
C
C First, make grid in radius:
C Call magnification of uniform source:
call occultuniform(b0,rl,mulimb0,nb)
i1=nb
i2=1
fac=0.d0
do i=1,nb
bt0(i)=b0(i)
mulimbf(i,1)=1.d0
mulimbf(i,2)=0.8d0
mulimbf(i,3)=2.d0/3.d0
mulimbf(i,4)=4.d0/7.d0
mulimbf(i,5)=0.5d0
mulimb(i)=mulimb0(i)
if(mulimb0(i).ne.1.d0) then
i1=min(i1,i)
i2=max(i2,i)
endif
fac=max(fac,abs(mulimb0(i)-1.d0))
enddo
C print,rl
omega=4.*((1.d0-c1-c2-c3-c4)/4.+c1/5.+c2/6.+c3/7.+c4/8.)
nr=2
dmumax=1.d0
c write(6,*) 'i1,i2 ',i1,i2
do while (dmumax.gt.fac*1.d-3)
do i=i1,i2
mulimbp(i)=mulimb(i)
enddo
nr=nr*2
c write(6,*) 'nr ',nr
dt=0.5d0*pi/dble(nr)
if(nr+1.gt.nmax) then
write(0,*) "M&A Seg: ",nr+1,b0(1)
return
endif
do j=1,nr+1
t(j) =dt*dble(j-1)
th(j)=t(j)+0.5d0*dt
r(j)=sin(t(j))
enddo
sig=sqrt(cos(th(nr)))
do i=i1,i2
mulimbhalf(i) =sig**3*mulimb0(i)/(1.d0-r(nr))
mulimb1(i) =sig**4*mulimb0(i)/(1.d0-r(nr))
mulimb3half(i)=sig**5*mulimb0(i)/(1.d0-r(nr))
mulimb2(i) =sig**6*mulimb0(i)/(1.d0-r(nr))
enddo
do j=2,nr
do i=1,nb
b0(i)=bt0(i)/r(j)
enddo
C Calculate uniform magnification at intermediate radii:
call occultuniform(b0,rl/r(j),mu,nb)
C Equation (29):
sig1=sqrt(cos(th(j-1)))
sig2=sqrt(cos(th(j)))
dmumax=0.d0
do i=i1,i2
f1=r(j)*r(j)*mu(i)/(r(j)-r(j-1))
f2=r(j)*r(j)*mu(i)/(r(j+1)-r(j))
mulimbhalf(i) =mulimbhalf(i) +f1*sig1**3-f2*sig2**3
mulimb1(i) =mulimb1(i) +f1*sig1**4-f2*sig2**4
mulimb3half(i)=mulimb3half(i)+f1*sig1**5-f2*sig2**5
mulimb2(i) =mulimb2(i) +f1*sig1**6-f2*sig2**6
mulimb(i)=((1.d0-c1-c2-c3-c4)*mulimb0(i)+c1*mulimbhalf(i)*dt
& +c2*mulimb1(i)*dt+c3*mulimb3half(i)*dt+c4*mulimb2(i)*dt)
& /omega
if(mulimb(i)+mulimbp(i).ne.0.d0) then
dmumax=max(dmumax,abs(mulimb(i)-mulimbp(i))/(mulimb(i)+
& mulimbp(i)))
endif
enddo
enddo
enddo
do i=i1,i2
mulimbf(i,1)=mulimb0(i)
mulimbf(i,2)=mulimbhalf(i)*dt
mulimbf(i,3)=mulimb1(i)*dt
mulimbf(i,4)=mulimb3half(i)*dt
mulimbf(i,5)=mulimb2(i)*dt
mulimb0(i)=mulimb(i)
enddo
do i=1,nb
b0(i)=bt0(i)
enddo
return
end
subroutine occultuniform(b0,w,muo1,nb)
implicit none
integer i,nb
real*8 muo1(nb),w,b0(nb),z,pi,lambdae,kap0,kap1
if(abs(w-0.5d0).lt.1.d-3) w=0.5d0
pi=acos(-1.d0)
C This routine computes the lightcurve for occultation
C of a uniform source without microlensing (Mandel & Agol 2002).
C Input:
C
C rs radius of the source (set to unity)
C b0 impact parameter in units of rs
C w occulting star size in units of rs
C
C Output:
C muo1 fraction of flux at each b0 for a uniform source
C
C Now, compute pure occultation curve:
do i=1,nb
C substitute z=b0(i) to shorten expressions
z=b0(i)
C the source is unocculted:
C Table 3, I.
if(z.ge.1.d0+w) then
muo1(i)=1.d0
goto 1
endif
C the source is completely occulted:
C Table 3, II.
if(w.ge.1.d0.and.z.le.w-1.d0) then
muo1(i)=0.d0
goto 1
endif
C the source is partly occulted and the occulting object crosses the limb:
C Equation (26):
if(z.ge.abs(1.d0-w).and.z.le.1.d0+w) then
kap1=acos(min((1.d0-w*w+z*z)/2.d0/z,1.d0))
kap0=acos(min((w*w+z*z-1.d0)/2.d0/w/z,1.d0))
lambdae=w*w*kap0+kap1
lambdae=(lambdae-0.5d0*sqrt(max(4.d0*z*z-(1.d0+z*z-w*w)**2,
& 0.d0)))/pi
muo1(i)=1.d0-lambdae
endif
C the occulting object transits the source star (but doesn't
C completely cover it):
if(z.le.1.d0-w) muo1(i)=1.d0-w*w
1 continue
enddo
C muo1=1.d0-lambdae
return
end
| SOSS/specgen/utils/mandelagol.f |
subroutine solve_backward_euler_system(t, dt, iterate, d_iterate, residual_norm)
! Solve the Netwon system,
! newton_operator(d_iterate) = newton_rhs,
! using BiCGStab.
!
! The implementation is taken from Algorithm 7.7 of Y. Saad, Iterative Methods
! for Sparse Linear Systems, 2nd Ed.
!
! Args:
! t: Time at beginning of the current step.
! dt: Length of the current time step.
! iterate: The current Newton iterate.
! d_iterate: iterate + d_iterate will yield the next Newton iterate.
! Stores newton_rhs on input.
! residual_norm: Returns final norm of the residual
! TODO: Make max_iter a global parameter?
!$ use omp_lib
implicit none
integer :: mx, my, mbc, meqn
double precision :: x_lower, y_lower, dx, dy
common /claw_config/ mx, my, mbc, x_lower, y_lower, dx, dy, meqn
double precision :: cg_tolerance
integer :: cg_verbosity
common /cg_config/ cg_tolerance, cg_verbosity
double precision, intent(in) :: t, dt
double precision, intent(in), dimension(1-mbc:mx+mbc, 1-mbc:my+mbc, meqn) :: iterate
double precision, intent(inout), dimension(1-mbc:mx+mbc, 1-mbc:my+mbc, meqn) :: d_iterate
double precision, intent(out) :: residual_norm
integer :: max_iter, iter, ix, iy, ieqn
double precision, dimension(1-mbc:mx+mbc, 1-mbc:my+mbc, meqn) :: r, r_star, p, s, Ap, As
double precision :: alpha, omega, beta, r_dot_r_star, r_dot_r_star_old
double precision, external :: inner_product
double precision :: denominator
max_iter = 10 * mx * my
do ieqn = 1, meqn
!$omp parallel do private(ix)
do iy = 1, my
do ix = 1, mx
r(ix, iy, ieqn) = d_iterate(ix, iy, ieqn)
r_star(ix, iy, ieqn) = r(ix, iy, ieqn)
p(ix, iy, ieqn) = r(ix, iy, ieqn)
d_iterate(ix, iy, ieqn) = 0.d0
end do
end do
end do
r_dot_r_star = inner_product(r, r_star)
residual_norm = sqrt(r_dot_r_star) ! Using r_star = r
if (residual_norm <= cg_tolerance) then
if (cg_verbosity > 0) then
print '(AE16.10)', 'BiCGStab finished without iterating; residual_norm = ', residual_norm
end if
return
end if
do iter = 1, max_iter
call get_backward_euler_lhs(t, dt, iterate, p, Ap)
denominator = inner_product(Ap, r_star)
alpha = inner_product(r, r_star) / denominator
! TODO: Not sure if this is reasonable.
if (denominator == 0.d0 .or. alpha == 0.d0) then
if (cg_verbosity > 0) then
print '(A,A,E16.10,A)', 'BiCGStab reached degenerate condition, ', &
'. Terminating with residual_norm = ', residual_norm, '.'
end if
return
end if
do ieqn = 1, meqn
!$omp parallel do private(ix)
do iy = 1, my
do ix = 1, mx
s(ix, iy, ieqn) = r(ix, iy, ieqn) - alpha * Ap(ix, iy, ieqn)
end do
end do
end do
call get_backward_euler_lhs(t, dt, iterate, s, As)
omega = inner_product(As, s) / inner_product(As, As)
do ieqn = 1, meqn
!$omp parallel do private(ix)
do iy = 1, my
do ix = 1, mx
d_iterate(ix, iy, ieqn) = d_iterate(ix, iy, ieqn) + &
alpha * p(ix, iy, ieqn) + omega * s(ix, iy, ieqn)
r(ix, iy, ieqn) = s(ix, iy, ieqn) - omega * As(ix, iy, ieqn)
end do
end do
end do
residual_norm = sqrt(inner_product(r, r))
if (residual_norm <= cg_tolerance) then
if (cg_verbosity > 0) then
print '(A,I5,A,E16.10)', 'BiCGStab completed after ', iter, &
' iterations with norm(residual) = ', residual_norm
end if
return
end if
r_dot_r_star_old = r_dot_r_star
r_dot_r_star = inner_product(r, r_star)
beta = r_dot_r_star / r_dot_r_star_old * alpha / omega
do ieqn = 1, meqn
!$omp parallel do private(ix)
do iy = 1, my
do ix = 1, mx
p(ix, iy, ieqn) = r(ix, iy, ieqn) + beta * (p(ix, iy, ieqn) - &
omega * Ap(ix, iy, ieqn))
end do
end do
end do
if (cg_verbosity > 1) then
print '(A,I4,A,E16.10)', 'Iteration ', iter, ': residual_norm = ', &
residual_norm
end if
end do
if (cg_verbosity > 0) then
print '(A,I5,A,E16.10)', 'BiCGStab failed to converge after ', iter-1, &
'iterations. Final residual_norm: ', residual_norm, '.'
end if
end subroutine solve_backward_euler_system
| implicit_claw/2d/solve_backward_euler_system-bicgstab.f90 |
include 'pgapackf.h'
double precision evaluate
integer myMutation
external evaluate, myMutation
integer ctx
integer i, ierror
integer lower(10), upper(10)
do i=1, 10
lower(i) = 1
upper(i) = 10
enddo
call MPI_Init(ierror)
ctx = PGACreate (PGA_DATATYPE_INTEGER, 10, PGA_MAXIMIZE)
call PGASetUserFunction (ctx, PGA_USERFUNCTION_MUTATION,
& myMutation)
call PGASetIntegerInitRange(ctx, lower, upper)
call PGASetUp (ctx)
call PGARun (ctx, evaluate)
call PGADestroy (ctx)
call MPI_Finalize(ierror)
stop
end
integer function myMutation(ctx, p, pop, pm)
include 'pgapackf.h'
integer ctx
integer p, pop
double precision pm
integer stringlen, i, k, count
count = 0
stringlen = PGAGetStringLength(ctx)
do i=1, stringlen
if (PGARandomFlip(ctx, pm) .eq. PGA_TRUE) then
k = PGARandomInterval(ctx, 1, stringlen)
call PGASetIntegerAllele(ctx, p, pop, i, k)
count = count + 1
endif
enddo
myMutation = count
return
end
double precision function evaluate(ctx, p, pop)
include 'pgapackf.h'
integer ctx
integer p, pop
integer stringlen, i, sum
sum = 0
stringlen = PGAGetStringLength(ctx)
do i=1, stringlen
sum = sum + PGAGetIntegerAllele(ctx, p, pop, i)
enddo
evaluate = sum
return
end
| examples/fortran/example.f |
module horiz_interp_spherical_mod
! <CONTACT EMAIL="[email protected]"> Matthew Harrison </CONTACT>
! <CONTACT EMAIL="[email protected]"> Zhi Liang </CONTACT>
! <HISTORY SRC="http://www.gfdl.noaa.gov/fms-cgi-bin/cvsweb.cgi/FMS/"/>
! <OVERVIEW>
! Performs spatial interpolation between grids using inverse-distance-weighted scheme.
! </OVERVIEW>
! <DESCRIPTION>
! This module can interpolate data from rectangular/tripolar grid
! to rectangular/tripolar grid. The interpolation scheme is inverse-distance-weighted
! scheme. There is an optional mask field for missing input data.
! An optional output mask field may be used in conjunction with
! the input mask to show where output data exists.
! </DESCRIPTION>
use mpp_mod, only : mpp_error, FATAL, WARNING, stdout
use mpp_mod, only : mpp_root_pe, mpp_pe
use fms_mod, only : write_version_number, file_exist, close_file
use fms_mod, only : check_nml_error, open_namelist_file
use constants_mod, only : pi
use horiz_interp_type_mod, only : horiz_interp_type, stats
implicit none
private
public :: horiz_interp_spherical_init, horiz_interp_spherical, horiz_interp_spherical_end
integer, parameter :: max_neighbors = 400
real, parameter :: max_dist_default = 0.1 ! radians
integer, parameter :: num_nbrs_default = 4
real, parameter :: large=1.e20
real, parameter :: epsln=1.e-10
integer :: pe, root_pe
!--- namelist interface
!<NAMELIST NAME="horiz_interp_spherical_nml">
! <DATA NAME="search_method" TYPE="character(len=32)">
! indicate the searching method to find the nearest neighbor points. Its value
! can be "radial_search" and "full_search", with default value "radial_search".
! when search_method is "radial_search", the search may be not quite accurate for some cases.
! Normally the search will be ok if you chose suitable max_dist.
! When search_method is "full_search", it will be always accurate, but will be slower
! comparing to "radial_search". Normally these two search algorithm will produce same
! results other than order of operation. "radial_search" are recommended to use.
! The purpose to add "full_search" is in case you think you interpolation results is
! not right, you have other option to verify.
! </DATA>
!</NAMELIST>
character(len=32) :: search_method = "radial_search" ! or "full_search"
namelist /horiz_interp_spherical_nml/ search_method
!-----------------------------------------------------------------------
character(len=128) :: version = '$Id: horiz_interp_spherical.f90,v 13.0 2006/03/28 21:39:46 fms Exp $'
character(len=128) :: tagname = '$Name: latest $'
logical :: do_vers = .true.
logical :: module_is_initialized = .FALSE.
contains
!#######################################################################
! <SUBROUTINE NAME="horiz_interp_spherical_init">
! <OVERVIEW>
! Initialization routine.
! </OVERVIEW>
! <DESCRIPTION>
! Allocates space and initializes a derived-type variable
! that contains pre-computed interpolation indices and weights.
! </DESCRIPTION>
! <TEMPLATE>
! call horiz_interp_spherical_init(Interp, lon_in,lat_in,lon_out,lat_out, num_nbrs, max_dist, src_modulo)
! </TEMPLATE>
!
! <IN NAME="lon_in" TYPE="real, dimension(:,:)" UNITS="radians">
! Longitude (in radians) for source data grid.
! </IN>
! <IN NAME="lat_in" TYPE="real, dimension(:,:)" UNITS="radians">
! Latitude (in radians) for source data grid.
! </IN>
! <IN NAME="lon_out" TYPE="real, dimension(:,:)" UNITS="radians" >
! Longitude (in radians) for source data grid.
! </IN>
! <IN NAME="lat_out" TYPE="real, dimension(:,:)" UNITS="radians" >
! Latitude (in radians) for source data grid.
! </IN>
! <IN NAME="num_nbrs" TYPE="integer, optional">
! Number of nearest neighbors for regridding. When number of neighbors within
! the radius max_dist ( namelist variable) is less than num_nbrs, All the neighbors
! will be used to interpolate onto destination grid. when number of neighbors within
! the radius max_dist ( namelist variable) is greater than num_nbrs, at least "num_nbrs"
! neighbors will be used to remap onto destination grid.
! </IN>
! <IN NAME="max_dist" TYPE="real, optional" UNITS="radians">
! Maximum region of influence around destination grid points.
! </IN>
! <IN NAME="src_modulo" TYPE="logical, optional">
! logical variable to indicate if the boundary condition along zonal boundary
! is cyclic or not. When true, the zonal boundary condition is cyclic.
! </IN>
! <INOUT NAME="Interp" TYPE="type(horiz_interp_type)">
! A derived-type variable containing indices and weights used for subsequent
! interpolations. To reinitialize this variable for a different grid-to-grid
! interpolation you must first use the "horiz_interp_end" interface.
! </INOUT>
subroutine horiz_interp_spherical_init(Interp, lon_in,lat_in,lon_out,lat_out, &
num_nbrs, max_dist, src_modulo)
type(horiz_interp_type), intent(inout) :: Interp
real, intent(in), dimension(:,:) :: lon_in, lat_in, lon_out, lat_out
integer, intent(in), optional :: num_nbrs
real, optional, intent(in) :: max_dist
logical, intent(in), optional :: src_modulo
!------local variables ---------------------------------------
integer :: i, j, n, unit, ierr, io
integer :: map_dst_xsize, map_dst_ysize, map_src_xsize, map_src_ysize
integer :: map_src_size, num_neighbors
real :: max_src_dist, tpi, hpi
logical :: src_is_modulo
real :: min_theta_dst, max_theta_dst, min_phi_dst, max_phi_dst
real :: min_theta_src, max_theta_src, min_phi_src, max_phi_src
integer, dimension(:), allocatable :: ilon, jlat
integer, dimension(:,:,:), allocatable :: map_src_add
integer, dimension(:,:), allocatable :: num_found
real, dimension(:,:,:), allocatable :: map_src_dist
real, dimension(size(lon_out,1),size(lon_out,2)) :: theta_dst, phi_dst
real, dimension(size(lon_in,1)*size(lon_in,2)) :: theta_src, phi_src
!--------------------------------------------------------------
pe = mpp_pe()
root_pe = mpp_root_pe()
if (do_vers) then
call write_version_number (version, tagname)
do_vers = .false.
endif
if (file_exist('input.nml')) then
unit = open_namelist_file ( )
ierr=1; do while (ierr /= 0)
read (unit, nml=horiz_interp_spherical_nml, iostat=io, end=10)
ierr = check_nml_error(io,'horiz_interp_spherical_nml') ! also initializes nml error codes
enddo
10 call close_file (unit)
endif
tpi = 2.0*PI; hpi = 0.5*PI
num_neighbors = num_nbrs_default
if(present(num_nbrs)) num_neighbors = num_nbrs
if (num_neighbors <= 0) call mpp_error(FATAL,'horiz_interp_spherical_mod: num_neighbors must be > 0')
max_src_dist = max_dist_default
if (PRESENT(max_dist)) max_src_dist = max_dist
Interp%max_src_dist = max_src_dist
src_is_modulo = .true.
if (PRESENT(src_modulo)) src_is_modulo = src_modulo
!--- check the grid size comformable
map_dst_xsize=size(lon_out,1);map_dst_ysize=size(lon_out,2)
map_src_xsize=size(lon_in,1); map_src_ysize=size(lon_in,2)
map_src_size = map_src_xsize*map_src_ysize
if (map_dst_xsize /= size(lat_out,1) .or. map_dst_ysize /= size(lat_out,2)) &
call mpp_error(FATAL,'horiz_interp_spherical_mod: destination grids not conformable')
if (map_src_xsize /= size(lat_in,1) .or. map_src_ysize /= size(lat_in,2)) &
call mpp_error(FATAL,'horiz_interp_spherical_mod: source grids not conformable')
theta_src = reshape(lon_in,(/map_src_size/))
phi_src = reshape(lat_in,(/map_src_size/))
theta_dst(:,:) = lon_out(:,:)
phi_dst(:,:) = lat_out(:,:)
min_theta_dst=tpi;max_theta_dst=0.0;min_phi_dst=pi;max_phi_dst=-pi
min_theta_src=tpi;max_theta_src=0.0;min_phi_src=pi;max_phi_src=-pi
where(theta_dst<0.0) theta_dst = theta_dst+tpi
where(theta_dst>tpi) theta_dst = theta_dst-tpi
where(theta_src<0.0) theta_src = theta_src+tpi
where(theta_src>tpi) theta_src = theta_src-tpi
where(phi_dst < -hpi) phi_dst = -hpi
where(phi_dst > hpi) phi_dst = hpi
where(phi_src < -hpi) phi_src = -hpi
where(phi_src > hpi) phi_src = hpi
do j=1,map_dst_ysize
do i=1,map_dst_xsize
min_theta_dst = min(min_theta_dst,theta_dst(i,j))
max_theta_dst = max(max_theta_dst,theta_dst(i,j))
min_phi_dst = min(min_phi_dst,phi_dst(i,j))
max_phi_dst = max(max_phi_dst,phi_dst(i,j))
enddo
enddo
do i=1,map_src_size
min_theta_src = min(min_theta_src,theta_src(i))
max_theta_src = max(max_theta_src,theta_src(i))
min_phi_src = min(min_phi_src,phi_src(i))
max_phi_src = max(max_phi_src,phi_src(i))
enddo
if (min_phi_dst < min_phi_src) print *, '=> WARNING: latitute of dest grid exceeds src'
if (max_phi_dst > max_phi_src) print *, '=> WARNING: latitute of dest grid exceeds src'
! when src is cyclic, no need to print out the following warning.
if(.not. src_is_modulo) then
if (min_theta_dst < min_theta_src) print *, '=> WARNING : longitude of dest grid exceeds src'
if (max_theta_dst > max_theta_src) print *, '=> WARNING : longitude of dest grid exceeds src'
endif
allocate(map_src_add(map_dst_xsize,map_dst_ysize,max_neighbors), &
map_src_dist(map_dst_xsize,map_dst_ysize,max_neighbors), &
num_found(map_dst_xsize,map_dst_ysize), &
ilon(max_neighbors),jlat(max_neighbors) )
! allocate memory to data type
allocate(Interp%i_lon(map_dst_xsize,map_dst_ysize,max_neighbors), &
Interp%j_lat(map_dst_xsize,map_dst_ysize,max_neighbors), &
Interp%src_dist(map_dst_xsize,map_dst_ysize,max_neighbors), &
Interp%num_found(map_dst_xsize,map_dst_ysize) )
map_src_add = 0
map_src_dist = large
num_found = 0
!using radial_search to find the nearest points and corresponding distance.
select case(trim(search_method))
case ("radial_search") ! will be efficient, but may be not so accurate for some cases
call radial_search(theta_src, phi_src, theta_dst, phi_dst, map_src_xsize, map_src_ysize, &
map_src_add, map_src_dist, num_found, num_neighbors,max_src_dist,src_is_modulo)
case ("full_search") ! always accurate, but less efficient.
call full_search(theta_src, phi_src, theta_dst, phi_dst, map_src_add, map_src_dist, &
num_found, num_neighbors,max_src_dist )
case default
call mpp_error(FATAL,"horiz_interp_spherical_init: nml search_method = "// &
trim(search_method)//" is not a valid namelist option")
end select
do j=1,map_dst_ysize
do i=1,map_dst_xsize
do n=1,num_found(i,j)
if(map_src_add(i,j,n) == 0) then
jlat(n) = 0; ilon(n) = 0
else
jlat(n) = map_src_add(i,j,n)/map_src_xsize + 1
ilon(n) = map_src_add(i,j,n) - (jlat(n)-1)*map_src_xsize
if(ilon(n) == 0) then
jlat(n) = jlat(n) - 1
ilon(n) = map_src_xsize
endif
endif
enddo
Interp%i_lon(i,j,:) = ilon(:)
Interp%j_lat(i,j,:) = jlat(:)
Interp%num_found(i,j) = num_found(i,j)
Interp%src_dist(i,j,:) = map_src_dist(i,j,:)
enddo
enddo
Interp%nlon_src = map_src_xsize; Interp%nlat_src = map_src_ysize
Interp%nlon_dst = map_dst_xsize; Interp%nlat_dst = map_dst_ysize
deallocate(map_src_add, map_src_dist, ilon, jlat)
return
end subroutine horiz_interp_spherical_init
! </SUBROUTINE>
!#######################################################################
! <SUBROUTINE NAME="horiz_interp_spherical">
! <OVERVIEW>
! Subroutine for performing the horizontal interpolation between two grids.
! </OVERVIEW>
! <DESCRIPTION>
! Subroutine for performing the horizontal interpolation between two grids.
! horiz_interp_spherical_init must be called before calling this routine.
! </DESCRIPTION>
! <TEMPLATE>
! call horiz_interp_spherical( Interp, data_in, data_out, verbose, mask_in, mask_out, missing_value)
! </TEMPLATE>
!
! <IN NAME="Interp" TYPE="type(horiz_interp_type)">
! Derived-type variable containing interpolation indices and weights.
! Returned by a previous call to horiz_interp_init.
! </IN>
! <IN NAME="data_in" TYPE="real, dimension(:,:)">
! Input data on source grid.
! </IN>
! <IN NAME="verbose" TYPE="integer, optional">
! flag for the amount of print output.
! verbose = 0, no output; = 1, min,max,means; = 2, still more
! </IN>
! <IN NAME="mask_in" TYPE="real, dimension(:,:),optional">
! Input mask, must be the same size as the input data. The real value of
! mask_in must be in the range (0.,1.). Set mask_in=0.0 for data points
! that should not be used or have missing data.
! </IN>
! <IN NAME="missing_value" TYPE="real, optional">
! Use the missing_value to indicate missing data.
! </IN>
! <OUT NAME="data_out" TYPE="real, dimension(:,:)">
! Output data on destination grid.
! </OUT>
! <OUT NAME="mask_out" TYPE="real, dimension(:,:),optional">
! Output mask that specifies whether data was computed.
! </OUT>
subroutine horiz_interp_spherical( Interp, data_in, data_out, verbose, mask_in, mask_out, missing_value)
type (horiz_interp_type), intent(in) :: Interp
real, intent(in), dimension(:,:) :: data_in
real, intent(out), dimension(:,:) :: data_out
integer, intent(in), optional :: verbose
real, intent(in), dimension(:,:), optional :: mask_in
real, intent(out), dimension(:,:), optional :: mask_out
real, intent(in), optional :: missing_value
!--- some local variables ----------------------------------------
real, dimension(Interp%nlon_dst, Interp%nlat_dst,size(Interp%src_dist,3)) :: wt
real, dimension(Interp%nlon_src, Interp%nlat_src) :: mask_src
real, dimension(Interp%nlon_dst, Interp%nlat_dst) :: mask_dst
integer :: nlon_in, nlat_in, nlon_out, nlat_out, num_found
integer :: m, n, i, j, k, miss_in, miss_out, i1, i2, j1, j2, iverbose
real :: min_in, max_in, avg_in, min_out, max_out, avg_out, sum
!-----------------------------------------------------------------
iverbose = 0; if (present(verbose)) iverbose = verbose
nlon_in = Interp%nlon_src; nlat_in = Interp%nlat_src
nlon_out = Interp%nlon_dst; nlat_out = Interp%nlat_dst
if(size(data_in,1) .ne. nlon_in .or. size(data_in,2) .ne. nlat_in ) &
call mpp_error(FATAL,'horiz_interp_spherical_mod: size of input array incorrect')
if(size(data_out,1) .ne. nlon_out .or. size(data_out,2) .ne. nlat_out ) &
call mpp_error(FATAL,'horiz_interp_spherical_mod: size of output array incorrect')
mask_src = 1.0; mask_dst = 1.0
if(present(mask_in)) mask_src = mask_in
do n=1,nlat_out
do m=1,nlon_out
! neighbors are sorted nearest to farthest
! check nearest to see if it is a land point
num_found = Interp%num_found(m,n)
if(num_found == 0 ) then
mask_dst(m,n) = 0.0
else
i1 = Interp%i_lon(m,n,1); j1 = Interp%j_lat(m,n,1)
if (mask_src(i1,j1) .lt. 0.5) then
mask_dst(m,n) = 0.0
endif
if(num_found .gt. 1 ) then
i2 = Interp%i_lon(m,n,2); j2 = Interp%j_lat(m,n,2)
! compare first 2 nearest neighbors -- if they are nearly
! equidistant then use this mask for robustness
if(abs(Interp%src_dist(m,n,2)-Interp%src_dist(m,n,1)) .lt. epsln) then
if((mask_src(i1,j1) .lt. 0.5)) mask_dst(m,n) = 0.0
endif
endif
sum=0.0
do k=1, num_found
if(mask_src(Interp%i_lon(m,n,k),Interp%j_lat(m,n,k)) .lt. 0.5 ) then
wt(m,n,k) = 0.0
else
if (Interp%src_dist(m,n,k) <= epsln) then
wt(m,n,k) = large
sum = sum + large
else if(Interp%src_dist(m,n,k) <= Interp%max_src_dist ) then
wt(m,n,k) = 1.0/Interp%src_dist(m,n,k)
sum = sum+wt(m,n,k)
else
wt(m,n,k) = 0.0
endif
endif
enddo
if (sum > epsln) then
do k = 1, num_found
wt(m,n,k) = wt(m,n,k)/sum
enddo
else
mask_dst(m,n) = 0.0
endif
endif
enddo
enddo
data_out = 0.0
do n=1,nlat_out
do m=1,nlon_out
if(mask_dst(m,n) .gt. 0.5) then
do k=1, Interp%num_found(m,n)
i = Interp%i_lon(m,n,k)
j = Interp%j_lat(m,n,k)
data_out(m,n) = data_out(m,n)+data_in(i,j)*wt(m,n,k)
enddo
else
if(present(missing_value)) then
data_out(m,n) = missing_value
else
data_out(m,n) = 0.0
endif
endif
enddo
enddo
if(present(mask_out)) mask_out = mask_dst
!***********************************************************************
! compute statistics: minimum, maximum, and mean
!-----------------------------------------------------------------------
if (iverbose > 0) then
! compute statistics of input data
call stats (data_in, min_in, max_in, avg_in, miss_in, missing_value, mask=mask_src)
! compute statistics of output data
call stats (data_out, min_out, max_out, avg_out, miss_out, missing_value, mask=mask_dst)
!---- output statistics ----
! root_pe have the information of global mean, min and max
if(pe == root_pe) then
write (*,900)
write (*,901) min_in ,max_in, avg_in
if (present(mask_in)) write (*,903) miss_in
write (*,902) min_out,max_out,avg_out
if (present(mask_out)) write (*,903) miss_out
endif
900 format (/,1x,10('-'),' output from horiz_interp ',10('-'))
901 format (' input: min=',f16.9,' max=',f16.9,' avg=',f22.15)
902 format (' output: min=',f16.9,' max=',f16.9,' avg=',f22.15)
903 format (' number of missing points = ',i6)
endif
return
end subroutine horiz_interp_spherical
! </SUBROUTINE>
!#######################################################################
! <SUBROUTINE NAME="horiz_interp_spherical_end">
! <OVERVIEW>
! Deallocates memory used by "horiz_interp_type" variables.
! Must be called before reinitializing with horiz_interp_init.
! </OVERVIEW>
! <DESCRIPTION>
! Deallocates memory used by "horiz_interp_type" variables.
! Must be called before reinitializing with horiz_interp_init.
! </DESCRIPTION>
! <TEMPLATE>
! call horiz_interp_spherical_end ( Interp )
! </TEMPLATE>
! <INOUT NAME="Interp" TYPE="horiz_interp_type">
! A derived-type variable returned by previous call
! to horiz_interp_init. The input variable must have
! allocated arrays. The returned variable will contain
! deallocated arrays.
! </INOUT>
subroutine horiz_interp_spherical_end( Interp )
type (horiz_interp_type), intent(inout) :: Interp
deallocate ( Interp%src_dist, Interp%num_found, Interp%i_lon, Interp%j_lat )
end subroutine horiz_interp_spherical_end
! </SUBROUTINE>
!#######################################################################
subroutine radial_search(theta_src,phi_src,theta_dst,phi_dst, map_src_xsize, map_src_ysize, &
map_src_add, map_src_dist, num_found, num_neighbors,max_src_dist,src_is_modulo)
real, intent(in), dimension(:) :: theta_src, phi_src
real, intent(in), dimension(:,:) :: theta_dst, phi_dst
integer, intent(in) :: map_src_xsize, map_src_ysize
integer, intent(out), dimension(:,:,:) :: map_src_add
real, intent(out), dimension(:,:,:) :: map_src_dist
integer, intent(inout), dimension(:,:) :: num_found
integer, intent(in) :: num_neighbors
real, intent(in) :: max_src_dist
logical, intent(in) :: src_is_modulo
!---------- local variables ----------------------------------------
integer, parameter :: max_nbrs = 50
integer :: i, j, jj, i0, j0, n, l,i_left, i_right
integer :: map_dst_xsize, map_dst_ysize
integer :: i_left1, i_left2, i_right1, i_right2
integer :: map_src_size, step, step_size, bound, bound_start, bound_end
logical :: continue_search, result, continue_radial_search
real :: d, res
!------------------------------------------------------------------
map_dst_xsize=size(theta_dst,1);map_dst_ysize=size(theta_dst,2)
map_src_size = map_src_xsize*map_src_ysize
do j=1,map_dst_ysize
do i=1,map_dst_xsize
continue_search=.true.
step = 1
step_size = sqrt(real(map_src_size) )
do while (continue_search .and. step_size > 0)
do while (step <= map_src_size .and. continue_search)
! count land points as nearest neighbors
d = spherical_distance(theta_dst(i,j),phi_dst(i,j),theta_src(step),phi_src(step))
if (d <= max_src_dist) then
result = update_dest_neighbors(map_src_add(i,j,:),map_src_dist(i,j,:), &
step,d, num_found(i,j), num_neighbors )
if (result) then
n = 0
i0 = mod(step,map_src_xsize)
if (i0 == 0) i0 = map_src_xsize
res = float(step)/float(map_src_xsize)
j0 = ceiling(res)
continue_radial_search = .true.
do while (continue_radial_search)
continue_radial_search = .false.
n = n+1 ! radial counter
if(n > max_nbrs) exit
! ************** left boundary *******************************
i_left = i0-n
if (i_left <= 0) then
if (src_is_modulo) then
i_left = map_src_xsize + i_left
else
i_left = 1
endif
endif
do l = 0, 2*n
jj = j0 - n - 1 + l
if( jj < 0) then
bound = ( 1 - jj )*map_src_xsize - i_left
else if ( jj >= map_src_ysize ) then
bound = ( 2*map_src_ysize - jj ) * map_src_xsize - i_left
else
bound = jj * map_src_xsize + i_left
endif
d = spherical_distance(theta_dst(i,j),phi_dst(i,j),theta_src(bound),phi_src(bound))
if(d<=max_src_dist) then
result = update_dest_neighbors(map_src_add(i,j,:),map_src_dist(i,j,:), &
bound,d, num_found(i,j), num_neighbors)
if (result) continue_radial_search = .true.
endif
enddo
! ***************************right boundary *******************************
i_right = i0+n
if (i_right > map_src_xsize) then
if (src_is_modulo) then
i_right = i_right - map_src_xsize
else
i_right = map_src_xsize
endif
endif
do l = 0, 2*n
jj = j0 - n - 1 + l
if( jj < 0) then
bound = ( 1 - jj )*map_src_xsize - i_right
else if ( jj >= map_src_ysize ) then
bound = ( 2*map_src_ysize - jj) * map_src_xsize - i_right
else
bound = jj * map_src_xsize + i_right
endif
d = spherical_distance(theta_dst(i,j),phi_dst(i,j),theta_src(bound),phi_src(bound))
if(d<=max_src_dist) then
result = update_dest_neighbors(map_src_add(i,j,:),map_src_dist(i,j,:), &
bound,d, num_found(i,j), num_neighbors)
if (result) continue_radial_search = .true.
endif
enddo
! ************************* bottom boundary **********************************
i_left2 = 0
if( i_left > i_right) then
i_left1 = 1
i_right1 = i_right
i_left2 = i_left
i_right2 = map_src_xsize
else
i_left1 = i_left
i_right1 = i_right
endif
jj = j0 - n - 1
if( jj < 0 ) then
bound_start = ( 1 - jj)*map_src_xsize - i_right1
bound_end = ( 1 - jj)*map_src_xsize - i_left1
else
bound_start = jj * map_src_xsize + i_left1
bound_end = jj * map_src_xsize + i_right1
endif
bound = bound_start
do while (bound <= bound_end)
d = spherical_distance(theta_dst(i,j),phi_dst(i,j),theta_src(bound),phi_src(bound))
if(d<=max_src_dist) then
result = update_dest_neighbors(map_src_add(i,j,:),map_src_dist(i,j,:), &
bound,d, num_found(i,j), num_neighbors)
if (result) continue_radial_search = .true.
endif
bound = bound + 1
enddo
if(i_left2 > 0 ) then
if( jj < 0 ) then
bound_start = ( 1 - jj)*map_src_xsize - i_right2
bound_end = ( 1 - jj)*map_src_xsize - i_left2
else
bound_start = jj * map_src_xsize + i_left2
bound_end = jj * map_src_xsize + i_right2
endif
bound = bound_start
do while (bound <= bound_end)
d = spherical_distance(theta_dst(i,j),phi_dst(i,j),theta_src(bound),phi_src(bound))
if(d<=max_src_dist) then
result = update_dest_neighbors(map_src_add(i,j,:),map_src_dist(i,j,:), &
bound,d, num_found(i,j), num_neighbors)
if (result) continue_radial_search = .true.
endif
bound = bound + 1
enddo
endif
! ************************** top boundary ************************************
jj = j0 + n - 1
if( jj >= map_src_ysize) then
bound_start = ( 2*map_src_ysize - jj ) * map_src_xsize - i_right1
bound_end = ( 2*map_src_ysize - jj ) * map_src_xsize - i_left1
else
bound_start = jj * map_src_xsize + i_left1
bound_end = jj * map_src_xsize + i_right1
endif
bound = bound_start
do while (bound <= bound_end)
d = spherical_distance(theta_dst(i,j),phi_dst(i,j),theta_src(bound),phi_src(bound))
if(d<=max_src_dist) then
result = update_dest_neighbors(map_src_add(i,j,:),map_src_dist(i,j,:), &
bound,d, num_found(i,j), num_neighbors)
if (result) continue_radial_search = .true.
endif
bound = bound + 1
enddo
if(i_left2 > 0) then
if( jj >= map_src_ysize) then
bound_start = ( 2*map_src_ysize - jj ) * map_src_xsize - i_right2
bound_end = ( 2*map_src_ysize - jj ) * map_src_xsize - i_left2
else
bound_start = jj * map_src_xsize + i_left2
bound_end = jj * map_src_xsize + i_right2
endif
bound = bound_start
do while (bound <= bound_end)
d = spherical_distance(theta_dst(i,j),phi_dst(i,j),theta_src(bound),phi_src(bound))
if(d<=max_src_dist) then
result = update_dest_neighbors(map_src_add(i,j,:),map_src_dist(i,j,:), &
bound,d, num_found(i,j), num_neighbors)
if (result) continue_radial_search = .true.
endif
bound = bound + 1
enddo
endif
enddo
continue_search = .false. ! stop looking
endif
endif
step=step+step_size
enddo ! search loop
step = 1
step_size = step_size/2
enddo
enddo
enddo
return
end subroutine radial_search
!#####################################################################
function update_dest_neighbors(map_src_add, map_src_dist, src_add,d, num_found, min_nbrs)
integer, intent(inout), dimension(:) :: map_src_add
real, intent(inout), dimension(:) :: map_src_dist
integer, intent(in) :: src_add
real, intent(in) :: d
integer, intent(inout) :: num_found
integer, intent(in) :: min_nbrs
logical :: update_dest_neighbors, already_exist = .false.
integer :: n,m
update_dest_neighbors = .false.
n = 0
NLOOP : do while ( n .le. num_found )
n = n + 1
DIST_CHK : if (d .le. map_src_dist(n)) then
do m=n,num_found
if (src_add == map_src_add(m)) then
already_exist = .true.
exit NLOOP
endif
enddo
if(num_found < max_neighbors) then
num_found = num_found + 1
else
call mpp_error(FATAL,'update_dest_neighbors: '// &
'number of neighbor points found is greated than maxium neighbor points' )
endif
do m=num_found,n+1,-1
map_src_add(m) = map_src_add(m-1)
map_src_dist(m) = map_src_dist(m-1)
enddo
map_src_add(n) = src_add
map_src_dist(n) = d
update_dest_neighbors = .true.
if( num_found > min_nbrs ) then
if( map_src_dist(num_found) > map_src_dist(num_found-1) ) then
num_found = num_found - 1
endif
if( map_src_dist(min_nbrs+1) > map_src_dist(min_nbrs) ) then
num_found = min_nbrs
endif
endif
exit NLOOP ! n loop
endif DIST_CHK
end do NLOOP
if(already_exist) return
if( .not. update_dest_neighbors ) then
if( num_found < min_nbrs ) then
num_found = num_found + 1
update_dest_neighbors = .true.
map_src_add(num_found) = src_add
map_src_dist(num_found) = d
endif
endif
return
end function update_dest_neighbors
!########################################################################
! function spherical_distance(theta1,phi1,theta2,phi2)
! real, intent(in) :: theta1, phi1, theta2, phi2
! real :: spherical_distance
! real :: r1(3), r2(3), cross(3), s, dot, ang
! this is a simple, enough way to calculate distance on the sphere
! first, construct cartesian vectors r1 and r2
! then calculate the cross-product which is proportional to the area
! between the 2 vectors. The angular distance is arcsin of the
! distancealong the sphere
!
! theta is longitude and phi is latitude
!
! r1(1) = cos(theta1)*cos(phi1);r1(2)=sin(theta1)*cos(phi1);r1(3)=sin(phi1)
! r2(1) = cos(theta2)*cos(phi2);r2(2)=sin(theta2)*cos(phi2);r2(3)=sin(phi2)
! cross(1) = r1(2)*r2(3)-r1(3)*r2(2)
! cross(2) = r1(3)*r2(1)-r1(1)*r2(3)
! cross(3) = r1(1)*r2(2)-r1(2)*r2(1)
! s = sqrt(cross(1)**2.+cross(2)**2.+cross(3)**2.)
! s = min(s,1.0-epsln)
! dot = r1(1)*r2(1) + r1(2)*r2(2) + r1(3)*r2(3)
! if (dot > 0) then
! ang = asin(s)
! else if (dot < 0) then
! ang = pi + asin(s) !? original is pi - asin(s)
! else
! ang = pi/2.
! endif
! spherical_distance = abs(ang) ! in radians
! return
! end function spherical_distance
! The great cycle distance
function spherical_distance(theta1,phi1,theta2,phi2)
real, intent(in) :: theta1, phi1, theta2, phi2
real :: spherical_distance, dot
if(theta1 == theta2 .and. phi1 == phi2) then
spherical_distance = 0.0
return
endif
dot = cos(phi1)*cos(phi2)*cos(theta1-theta2) + sin(phi1)*sin(phi2)
if(dot > 1 ) dot = 1.
if(dot < -1) dot = -1
spherical_distance = acos(dot)
return
end function spherical_distance
!#######################################################################
subroutine full_search(theta_src,phi_src,theta_dst,phi_dst,map_src_add, map_src_dist,num_found, &
num_neighbors,max_src_dist)
real, intent(in), dimension(:) :: theta_src, phi_src
real, intent(in), dimension(:,:) :: theta_dst, phi_dst
integer, intent(out), dimension(:,:,:) :: map_src_add
real, intent(out), dimension(:,:,:) :: map_src_dist
integer, intent(out), dimension(:,:) :: num_found
integer, intent(in) :: num_neighbors
real, intent(in) :: max_src_dist
integer :: i,j,map_src_size, step
integer :: map_dst_xsize,map_dst_ysize
real :: d
logical :: found
map_dst_xsize=size(theta_dst,1);map_dst_ysize=size(theta_dst,2)
map_src_size =size(theta_src(:))
do j=1,map_dst_ysize
do i=1,map_dst_xsize
do step = 1, map_src_size
d = spherical_distance(theta_dst(i,j),phi_dst(i,j),theta_src(step),phi_src(step))
if( d <= max_src_dist) then
found = update_dest_neighbors(map_src_add(i,j,:),map_src_dist(i,j,:), &
step,d,num_found(i,j), num_neighbors )
endif
enddo
enddo
enddo
end subroutine full_search
!#######################################################################
end module horiz_interp_spherical_mod
| fms_dynamical_cores/_fortran/src/shared/horiz_interp/horiz_interp_spherical.f90 |
!=======================================================================
!
! Calculate the rate coefficients for all reactions at the specified
! temperature and visual extinction A_V. The photodissociation of H2
! and CO and the photoionization of CI and SI are treated separately
! in detail (see the routines in photorates.f90). Multiple rates for
! the same reaction (duplicates) are allowed in the ratefile and are
! activated based on their minimum and maximum temperature specified
! in that file. Negative gamma factors are ignored below the minimum
! temperature at which the reaction rate is valid.
!
! X-ray induced reaction rates are calculated following the detailed
! treatment of Meijerink & Spaans (2005, A&A, 436, 397).
!
!-----------------------------------------------------------------------
SUBROUTINE CALCULATE_REACTION_RATES(NRAYS,NSPEC,NREAC,NXSEC,CROSS_SECTION, &
& GAS_TEMPERATURE,DUST_TEMPERATURE,FUV_FIELD, &
& XRAY_FIELD,FUV_SURFACE,AV,COLUMN_DENSITY, &
& REACTANT,PRODUCT,ALPHA,BETA,GAMMA,RTMIN,RTMAX, &
& DUPLICATE,RATE)
USE HEALPIX_TYPES
USE GLOBAL_MODULE
USE FUNCTIONS_MODULE
USE NUM2STR_FUNCTION
USE CROSS_SECTION_MODULE
IMPLICIT NONE
INTEGER(KIND=I4B), INTENT(IN) :: NRAYS,NSPEC,NREAC,NXSEC
TYPE(CROSS_SECTION_TYPE), INTENT(IN) :: CROSS_SECTION(:)
REAL(KIND=DP), INTENT(IN) :: GAS_TEMPERATURE,DUST_TEMPERATURE
REAL(KIND=DP), INTENT(IN) :: FUV_FIELD,XRAY_FIELD
REAL(KIND=DP), INTENT(IN) :: FUV_SURFACE(0:),AV(0:),COLUMN_DENSITY(0:,:)
CHARACTER(LEN=10), INTENT(IN) :: REACTANT(:,:),PRODUCT(:,:)
REAL(KIND=DP), INTENT(IN) :: ALPHA(:),BETA(:),GAMMA(:)
REAL(KIND=DP), INTENT(IN) :: RTMIN(:),RTMAX(:)
INTEGER(KIND=I4B), INTENT(IN) :: DUPLICATE(:)
REAL(KIND=DP), INTENT(OUT) :: RATE(:)
INTEGER(KIND=I4B) :: I,J,K
REAL(KIND=DP) :: PHI_PAH,CION,STICKING,FLUX,YIELD
! Initialize the rate coefficients
RATE=0.0D0
!!$! Calculate the photoreaction rates for species with available cross section data
!!$ DO I=1,NXSEC ! Loop over available cross sections
!!$ IF(CROSS_SECTION(I)%INDEX.NE.0) THEN
!!$ DO K=0,NRAYS-1 ! Loop over all rays
!!$ RATE(CROSS_SECTION(I)%INDEX) = RATE(CROSS_SECTION(I)%INDEX) + PHOTOREACTION_RATE(FUV_SURFACE(K),AV(K),CROSS_SECTION(I))
!!$ END DO ! End of loop over all rays
!!$ END IF
!!$ END DO ! End of loop over available cross sections
! Loop over all reactions
DO I=1,NREAC
! Determine the type of reaction
IF(REACTANT(I,2).EQ."PHOTON") GOTO 1
IF(REACTANT(I,2).EQ."CRP ") GOTO 2
IF(REACTANT(I,2).EQ."CRPHOT") GOTO 3
IF(REACTANT(I,2).EQ."XRAY ") GOTO 4
IF(REACTANT(I,2).EQ."XRSEC ") GOTO 5
IF(REACTANT(I,2).EQ."XRLYA ") GOTO 6
IF(REACTANT(I,2).EQ."XRPHOT") GOTO 6
IF(REACTANT(I,2).EQ."FREEZE") GOTO 7
IF(REACTANT(I,2).EQ."CRH ") GOTO 8
IF(REACTANT(I,2).EQ."PHOTD ") GOTO 9
IF(REACTANT(I,2).EQ."THERM ") GOTO 10
IF(REACTANT(I,2)(1:1).EQ."#") GOTO 11
!-----------------------------------------------------------------------
! Thermal reactions:
! The rate of H2 formation on grains is calculated separately
! by the function H2_FORMATION_RATE (see function for details)
IF((REACTANT(I,1).EQ."H " .AND. REACTANT(I,2).EQ."H " .AND. REACTANT(I,3).EQ."# ") .AND. &
& (PRODUCT(I,1).EQ."H2 " .AND. PRODUCT(I,2).EQ."# ")) THEN
RATE(I)=H2_FORMATION_RATE(GAS_TEMPERATURE,DUST_TEMPERATURE)
GOTO 20
END IF
! Rates for reactions involving PAHs are calculated according to the
! treatment of Wolfire et al. (2003, ApJ, 587, 278; 2008, ApJ, 680, 384)
IF(ANY(REACTANT(I,:).EQ."PAH ") .OR. ANY(REACTANT(I,:).EQ."PAH0 ") .OR. &
& ANY(REACTANT(I,:).EQ."PAH+ ") .OR. ANY(REACTANT(I,:).EQ."PAH- ")) THEN
PHI_PAH=0.4D0
RATE(I)=ALPHA(I)*(GAS_TEMPERATURE/100.0D0)**BETA(I)*PHI_PAH
GOTO 20
END IF
! Check for large negative gamma values that might cause discrepant
! rates at low temperatures. Set these rates to zero when T < RTMIN
IF(DUPLICATE(I).EQ.0) THEN
IF(GAMMA(I).LT.-200.0D0 .AND. GAS_TEMPERATURE.LT.RTMIN(I)) THEN
RATE(I)=0.0D0
ELSE
RATE(I)=ALPHA(I)*(GAS_TEMPERATURE/300.0D0)**BETA(I)*EXP(-(GAMMA(I)/GAS_TEMPERATURE))
END IF
ELSE IF(DUPLICATE(I).EQ.1) THEN
J=I
DO
IF(GAS_TEMPERATURE.LE.RTMAX(J)) THEN
IF(GAMMA(J).LT.-200.0D0 .AND. GAS_TEMPERATURE.LT.RTMIN(J)) THEN
RATE(J)=0.0D0
ELSE
RATE(J)=ALPHA(J)*(GAS_TEMPERATURE/300.0D0)**BETA(J)*EXP(-(GAMMA(J)/GAS_TEMPERATURE))
END IF
EXIT
ELSE IF(DUPLICATE(J+1).LT.DUPLICATE(J)) THEN
IF(GAMMA(J).LT.-200.0D0 .AND. GAS_TEMPERATURE.LT.RTMIN(J)) THEN
RATE(J)=0.0D0
ELSE
RATE(J)=ALPHA(J)*(GAS_TEMPERATURE/300.0D0)**BETA(J)*EXP(-(GAMMA(J)/GAS_TEMPERATURE))
END IF
EXIT
ELSE
RATE(J)=0.0D0
J=J+1
END IF
END DO
END IF
GOTO 20
!-----------------------------------------------------------------------
! FUV photoreactions:
! The rate of H2 photodissociation is calculated separately by the function
! H2_PHOTODISSOCIATION_RATE (see photoreaction_rates.f90 for details)
1 IF(REACTANT(I,1).EQ."H2 " .AND. REACTANT(I,3).EQ." ") THEN
DO K=0,NRAYS-1 ! Loop over all rays
RATE(I)=RATE(I) + H2_PHOTODISSOCIATION_RATE(ALPHA(I),FUV_SURFACE(K),AV(K),COLUMN_DENSITY(K,NH2))
END DO
GOTO 20
END IF
! The rate of HD photodissociation is calculated separately by the function
! H2_PHOTODISSOCIATION_RATE (see photoreaction_rates.f90 for details)
IF(REACTANT(I,1).EQ."HD " .AND. REACTANT(I,3).EQ." ") THEN
DO K=0,NRAYS-1 ! Loop over all rays
RATE(I)=RATE(I) + H2_PHOTODISSOCIATION_RATE(ALPHA(I),FUV_SURFACE(K),AV(K),COLUMN_DENSITY(K,NHD))
END DO
GOTO 20
END IF
! The rate of CO photodissociation is calculated separately by the function
! CO_PHOTODISSOCIATION_RATE (see photoreaction_rates.f90 for details)
IF(REACTANT(I,1).EQ."CO " .AND. REACTANT(I,3).EQ." " .AND. ANY(PRODUCT(I,:).EQ."C ") .AND. ANY(PRODUCT(I,:).EQ."O ")) THEN
DO K=0,NRAYS-1 ! Loop over all rays
RATE(I)=RATE(I) + CO_PHOTODISSOCIATION_RATE(ALPHA(I),FUV_SURFACE(K),AV(K),COLUMN_DENSITY(K,NCO),COLUMN_DENSITY(K,NH2))
END DO
GOTO 20
END IF
! The rate of CI photoionization is calculated separately by the function
! CI_PHOTOIONIZATION_RATE (see photoreaction_rates.f90 for details)
IF(REACTANT(I,1).EQ."C " .AND. REACTANT(I,3).EQ." ") THEN
DO K=0,NRAYS-1 ! Loop over all rays
RATE(I)=RATE(I) + CI_PHOTOIONIZATION_RATE(ALPHA(I),FUV_SURFACE(K),AV(K),GAMMA(I),COLUMN_DENSITY(K,NC),COLUMN_DENSITY(K,NH2),GAS_TEMPERATURE)
END DO
GOTO 20
END IF
! The rate of SI photoionization is calculated separately by the function
! SI_PHOTOIONIZATION_RATE (see photoreaction_rates.f90 for details)
IF(REACTANT(I,1).EQ."S " .AND. REACTANT(I,3).EQ." ") THEN
DO K=0,NRAYS-1 ! Loop over all rays
RATE(I)=RATE(I) + SI_PHOTOIONIZATION_RATE(ALPHA(I),FUV_SURFACE(K),AV(K),GAMMA(I),COLUMN_DENSITY(K,NS))
END DO
GOTO 20
END IF
IF(DUPLICATE(I).EQ.0) THEN
IF(RATE(I).EQ.0.0D0) THEN
DO K=0,NRAYS-1 ! Loop over all rays
RATE(I)=RATE(I) + ALPHA(I)*FUV_SURFACE(K)*EXP(-(GAMMA(I)*AV(K)))
END DO
END IF
ELSE IF(DUPLICATE(I).EQ.1) THEN
J=I
DO
IF(GAS_TEMPERATURE.LE.RTMAX(J)) THEN
IF(RATE(J).EQ.0.0D0) THEN
DO K=0,NRAYS-1 ! Loop over all rays
RATE(J)=RATE(J) + ALPHA(J)*FUV_SURFACE(K)*EXP(-(GAMMA(J)*AV(K)))
END DO
END IF
EXIT
ELSE IF(DUPLICATE(J+1).LT.DUPLICATE(J)) THEN
IF(RATE(J).EQ.0.0D0) THEN
DO K=0,NRAYS-1 ! Loop over all rays
RATE(J)=RATE(J) + ALPHA(J)*FUV_SURFACE(K)*EXP(-(GAMMA(J)*AV(K)))
END DO
END IF
EXIT
ELSE
RATE(J)=0.0D0
J=J+1
END IF
END DO
END IF
GOTO 20
!-----------------------------------------------------------------------
! Cosmic-ray induced ionization:
2 IF(DUPLICATE(I).EQ.0) THEN
RATE(I)=ALPHA(I)*ZETA
ELSE IF(DUPLICATE(I).EQ.1) THEN
J=I
DO
IF(GAS_TEMPERATURE.LE.RTMAX(J)) THEN
RATE(J)=ALPHA(J)*ZETA
EXIT
ELSE IF(DUPLICATE(J+1).LT.DUPLICATE(J)) THEN
RATE(J)=ALPHA(J)*ZETA
EXIT
ELSE
RATE(J)=0.0D0
J=J+1
END IF
END DO
END IF
GOTO 20
!-----------------------------------------------------------------------
! Photoreactions due to cosmic-ray induced secondary photons:
3 IF(DUPLICATE(I).EQ.0) THEN
RATE(I)=ALPHA(I)*ZETA*(GAS_TEMPERATURE/300.0D0)**BETA(I)*GAMMA(I)/(1.0D0-OMEGA)
ELSE IF(DUPLICATE(I).EQ.1) THEN
J=I
DO
IF(GAS_TEMPERATURE.LE.RTMAX(J)) THEN
RATE(J)=ALPHA(J)*ZETA*(GAS_TEMPERATURE/300.0D0)**BETA(J)*GAMMA(J)/(1.0D0-OMEGA)
EXIT
ELSE IF(DUPLICATE(J+1).LT.DUPLICATE(J)) THEN
RATE(J)=ALPHA(J)*ZETA*(GAS_TEMPERATURE/300.0D0)**BETA(J)*GAMMA(J)/(1.0D0-OMEGA)
EXIT
ELSE
RATE(J)=0.0D0
J=J+1
END IF
END DO
END IF
GOTO 20
!-----------------------------------------------------------------------
! X-ray photoreactions:
4 IF(DUPLICATE(I).EQ.0) THEN
RATE(I)=ALPHA(I)
ELSE IF(DUPLICATE(I).EQ.1) THEN
J=I
DO
IF(GAS_TEMPERATURE.LE.RTMAX(J)) THEN
RATE(J)=ALPHA(J)
EXIT
ELSE IF(DUPLICATE(J+1).LT.DUPLICATE(J)) THEN
RATE(J)=ALPHA(J)
EXIT
ELSE
RATE(J)=0.0D0
J=J+1
END IF
END DO
END IF
GOTO 20
!-----------------------------------------------------------------------
! X-ray induced secondary ionization:
5 IF(DUPLICATE(I).EQ.0) THEN
RATE(I)=ALPHA(I)*XRAY_FIELD*(1.0D0/eV) ! Convert from erg to eV
ELSE IF(DUPLICATE(I).EQ.1) THEN
J=I
DO
IF(GAS_TEMPERATURE.LE.RTMAX(J)) THEN
RATE(J)=ALPHA(J)*XRAY_FIELD*(1.0D0/eV)
EXIT
ELSE IF(DUPLICATE(J+1).LT.DUPLICATE(J)) THEN
RATE(J)=ALPHA(J)*XRAY_FIELD*(1.0D0/eV)
EXIT
ELSE
RATE(J)=0.0D0
J=J+1
END IF
END DO
END IF
GOTO 20
!-----------------------------------------------------------------------
! Photoreactions due to X-ray induced secondary photons (both Lyman-alpha and Lyman-Werner):
! For Lyman-alpha photons: k_i = epsilon_Lya * P_i,Lya * x_H * zeta_H / (1 - omega) [s^-1]
! For Lyman-Werner photons: k_i = epsilon_LyW * P_i,LyW * x_H2* zeta_H2/ (1 - omega) [s^-1]
!
! The value of epsilon_Lya or epsilon_LyW is stored in the alpha parameter of each reaction
! The value of P_i,Lya or P_i,LyW is stored in the gamma parameter of each reaction
6 IF(DUPLICATE(I).EQ.0) THEN
RATE(I)=ALPHA(I)*XRAY_FIELD*(1.0D0/eV)*(GAS_TEMPERATURE/300.0D0)**BETA(I)*GAMMA(I)/(1.0D0-OMEGA)
ELSE IF(DUPLICATE(I).EQ.1) THEN
J=I
DO
IF(GAS_TEMPERATURE.LE.RTMAX(J)) THEN
RATE(J)=ALPHA(J)*XRAY_FIELD*(1.0D0/eV)*(GAS_TEMPERATURE/300.0D0)**BETA(J)*GAMMA(J)/(1.0D0-OMEGA)
EXIT
ELSE IF(DUPLICATE(J+1).LT.DUPLICATE(J)) THEN
RATE(J)=ALPHA(J)*XRAY_FIELD*(1.0D0/eV)*(GAS_TEMPERATURE/300.0D0)**BETA(J)*GAMMA(J)/(1.0D0-OMEGA)
EXIT
ELSE
RATE(J)=0.0D0
J=J+1
END IF
END DO
END IF
GOTO 20
!-----------------------------------------------------------------------
! Freeze-out of neutral species and singly charged positive ions:
7 IF(BETA(I).EQ.0.0D0) THEN
CION=1.0D0
ELSE IF(BETA(I).EQ.1.0D0) THEN
CION=1.0D0+16.71D-4/(GRAIN_RADIUS*GAS_TEMPERATURE)
ELSE
CION=0.0D0
END IF
STICKING=0.3D0
RATE(I)=ALPHA(I)*4.57D4*2.4D-22*SQRT(GAS_TEMPERATURE/GAMMA(I))*CION*STICKING
GOTO 20
!-----------------------------------------------------------------------
! Desorption due to cosmic-ray heating:
!!$! Treatment of Hasegawa & Herbst (1993, MNRAS, 261, 83, Equation 15)
!!$ 8 RATE(I)=ALPHA(I)*ZETA
! Treatment of Roberts et al. (2007, MNRAS, 382, 773, Equation 3)
8 IF(GAMMA(I).LE.1210.0D0) THEN
YIELD=1.0D5 ! Number of adsorbed molecules released per cosmic-ray impact
ELSE
YIELD=0.0D0
END IF
FLUX=2.06D-3 ! Flux of iron nuclei cosmic rays (in cm^-2 s^-1)
RATE(I)=FLUX*ZETA*2.4D-22*YIELD
GOTO 20
!-----------------------------------------------------------------------
! Photodesorption:
9 IF(GAS_TEMPERATURE.LT.50.0D0) THEN
YIELD=3.5D-3
ELSE IF(GAS_TEMPERATURE.LT.85.0D0) THEN
YIELD=4.0D-3
ELSE IF(GAS_TEMPERATURE.LT.100.0D0) THEN
YIELD=5.5D-3
ELSE
YIELD=7.5D-3
END IF
FLUX=1.71D8 ! Flux of FUV photons in the unattenuated Draine field (in photons cm^-2 s^-1)
DO K=0,NRAYS-1 ! Loop over all rays
RATE(I)=RATE(I) + FLUX*FUV_SURFACE(K)*EXP(-(GAMMA(I)*AV(K)))*2.4D-22*YIELD
END DO
GOTO 20
!-----------------------------------------------------------------------
! Thermal desorption:
! Treatment of Hasegawa, Herbst & Leung (1992, ApJS, 82, 167, Equations 2 & 3)
10 RATE(I)=SQRT(2.0D0*1.5D15*KB/(PI**2*AU)*ALPHA(I)/GAMMA(I))*EXP(-(ALPHA(I)/DUST_TEMPERATURE))
GOTO 20
!-----------------------------------------------------------------------
! Grain mantle reactions:
11 RATE(I)=ALPHA(I)
GOTO 20
!-----------------------------------------------------------------------
! Check that the rate is physical (0<RATE(I)<1) and produce an error
! message if not. Impose a lower cut-off on all rate coefficients to
! prevent the problem becoming too stiff. Rates lower than 1E-99 are
! set to zero. Grain-surface reactions and desorption mechanisms are
! allowed rates greater than 1.
20 IF(RATE(I).LT.0.0D0) THEN
WRITE(6,*) 'ERROR! Negative rate coefficient for reaction #',TRIM(NUM2STR(I))
WRITE(6,*) 'Rate = ',TRIM(NUM2STR(RATE(I)))
WRITE(6,*)
STOP
END IF
IF(RATE(I).GT.1.0D0 .AND. REACTANT(I,1)(1:1).NE."G" .AND. REACTANT(I,1)(1:1).NE."#") THEN
WRITE(10,*) 'WARNING! Rate coefficient is too large for reaction #',TRIM(NUM2STR(I))
WRITE(10,*) 'Rate = ',TRIM(NUM2STR(RATE(I)))
RATE(I)=1.0D0
END IF
IF(RATE(I).LT.1.0D-99) RATE(I)=0.0D0
! End of loop over reactions
END DO
RETURN
END SUBROUTINE CALCULATE_REACTION_RATES
!=======================================================================
| Source/reaction_rates.f90 |
!
! Copyright 2019-2020 SALMON developers
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!
module init_gs
implicit none
contains
!===================================================================================================================================
SUBROUTINE init_wf(lg,mg,system,info,spsi)
use structures
use inputoutput, only: au_length_aa, method_init_wf
use salmon_global, only: yn_periodic,natom,Rion,yn_jm
use gram_schmidt_orth
implicit none
type(s_rgrid) ,intent(in) :: lg,mg
type(s_dft_system) ,intent(in) :: system
type(s_parallel_info) ,intent(in) :: info
type(s_orbital) :: spsi
!
integer :: ik,io,is,a,ix,iy,iz,ip, ig,ngauss
real(8) :: xx,yy,zz,x1,y1,z1,rr,Xmax,Ymax,Zmax,q(3)
real(8) :: Xzero,Yzero,Zzero
call init_wf_rand
select case(method_init_wf)
case ('gauss' ) ; ngauss=1
case ('gauss2' ) ; ngauss=2
case ('gauss3' ) ; ngauss=3
case ('gauss4' ) ; ngauss=4
case ('gauss5' ) ; ngauss=5
case ('gauss10') ; ngauss=10
end select
! get offset (0-th element) : Xzero means center
if (yn_periodic == 'y') then
Xzero = lg%coordinate(lg%num(1)/2+mod(lg%num(1),2),1)
Yzero = lg%coordinate(lg%num(2)/2+mod(lg%num(2),2),2)
Zzero = lg%coordinate(lg%num(3)/2+mod(lg%num(3),2),3)
else
Xzero = 0d0
Yzero = 0d0
Zzero = 0d0
end if
if(system%if_real_orbital) then
select case(method_init_wf)
case ('random')
call gen_random_rwf
case ('gauss','gauss2','gauss3','gauss4','gauss5','gauss10')
if(yn_jm=='n') then
Xmax=0.d0 ; Ymax=0.d0 ; Zmax=0.d0
do a=1,natom
if ( abs(system%Rion(1,a)) > Xmax ) Xmax=abs(system%Rion(1,a))
if ( abs(system%Rion(2,a)) > Ymax ) Ymax=abs(system%Rion(2,a))
if ( abs(system%Rion(3,a)) > Zmax ) Zmax=abs(system%Rion(3,a))
end do
Xmax=Xmax-Xzero+1.d0/au_length_aa
Ymax=Ymax-Yzero+1.d0/au_length_aa
Zmax=Zmax-Zzero+1.d0/au_length_aa
else
Xmax=( lg%coordinate(lg%ie(1),1)-Xzero )*0.8d0
Ymax=( lg%coordinate(lg%ie(2),2)-Yzero )*0.8d0
Zmax=( lg%coordinate(lg%ie(3),3)-Zzero )*0.8d0
end if
do is=1,system%nspin
do io=1,system%no
do ig=1,ngauss
call random_number(q)
x1=Xmax*(2.d0*q(1)-1.d0)
y1=Ymax*(2.d0*q(2)-1.d0)
z1=Zmax*(2.d0*q(3)-1.d0)
if(info%io_s <= io .and. io <= info%io_e) then
!$OMP parallel do collapse(2) private(iz,iy,ix,xx,yy,zz,rr)
do iz=mg%is(3),mg%ie(3)
do iy=mg%is(2),mg%ie(2)
do ix=mg%is(1),mg%ie(1)
xx=lg%coordinate(ix,1)-Xzero
yy=lg%coordinate(iy,2)-Yzero
zz=lg%coordinate(iz,3)-Zzero
rr=sqrt((xx-x1)**2+(yy-y1)**2+(zz-z1)**2)
if(ig==1) then
spsi%rwf(ix,iy,iz,is,io,1,1) = exp(-0.5d0*(rr*au_length_aa)**2)*(au_length_aa)**(3/2)
else
spsi%rwf(ix,iy,iz,is,io,1,1) = spsi%rwf(ix,iy,iz,is,io,1,1) &
+ exp(-0.5d0*(rr*au_length_aa)**2)*(au_length_aa)**(3/2)
endif
end do
end do
end do
!$omp end parallel do
end if
end do !ig
end do
end do
end select
else
select case(method_init_wf)
case ('random')
call gen_random_zwf
case ('gauss','gauss2','gauss3','gauss4','gauss5','gauss10')
if(yn_jm=='n') then
Xmax = sqrt(sum(system%primitive_a(1:3,1)**2))-Xzero
Ymax = sqrt(sum(system%primitive_a(1:3,2)**2))-Yzero
Zmax = sqrt(sum(system%primitive_a(1:3,3)**2))-Zzero
else
Xmax=( lg%coordinate(lg%ie(1),1)-Xzero )*0.8d0
Ymax=( lg%coordinate(lg%ie(2),2)-Yzero )*0.8d0
Zmax=( lg%coordinate(lg%ie(3),3)-Zzero )*0.8d0
endif
do is=1,system%nspin
do ik=1,system%nk
do io=1,system%no
do ig=1,ngauss
call random_number(q)
x1=Xmax*q(1)
y1=Ymax*q(2)
z1=Zmax*q(3)
if(info%ik_s <= ik .and. ik <= info%ik_e .and. &
info%io_s <= io .and. io <= info%io_e) then
!$OMP parallel do collapse(2) private(iz,iy,ix,xx,yy,zz,rr)
do iz=mg%is(3),mg%ie(3)
do iy=mg%is(2),mg%ie(2)
do ix=mg%is(1),mg%ie(1)
xx=lg%coordinate(ix,1)-Xzero
yy=lg%coordinate(iy,2)-Yzero
zz=lg%coordinate(iz,3)-Zzero
rr=sqrt((xx-x1)**2+(yy-y1)**2+(zz-z1)**2)
if(ig==1) then
spsi%zwf(ix,iy,iz,is,io,ik,1) = exp(-0.5d0*rr**2)
else
spsi%zwf(ix,iy,iz,is,io,ik,1) = spsi%zwf(ix,iy,iz,is,io,ik,1) + exp(-0.5d0*rr**2)
endif
end do
end do
end do
!$omp end parallel do
end if
end do !ig
end do
end do
end do
end select
end if
call gram_schmidt(system, mg, info, spsi)
return
CONTAINS
! cf. RSDFT
subroutine init_wf_rand
use salmon_global, only: iseed_number_change
implicit none
integer :: s,k,n,i,llen
integer,allocatable :: iseed(:)
call random_seed(size = n)
allocate(iseed(n))
llen = product(lg%num)
iseed(:) = (info%ik_s * system%no + info%io_s - 1) * llen &
+ (mg%is(3) - lg%is(3) + 1) * lg%num(2) * lg%num(1) &
+ (mg%is(2) - lg%is(2) + 1) * lg%num(1) &
+ (mg%is(1) - lg%is(1) + 1) + iseed_number_change
call random_seed(put = iseed)
deallocate(iseed)
end subroutine
subroutine gen_random_rwf
implicit none
real(8) :: u(3),v(3)
do ip=lbound(spsi%rwf,7),ubound(spsi%rwf,7)
do ik=lbound(spsi%rwf,6),ubound(spsi%rwf,6)
do io=lbound(spsi%rwf,5),ubound(spsi%rwf,5)
do is=lbound(spsi%rwf,4),ubound(spsi%rwf,4)
do iz=lbound(spsi%rwf,3),ubound(spsi%rwf,3)
do iy=lbound(spsi%rwf,2),ubound(spsi%rwf,2)
do ix=lbound(spsi%rwf,1),ubound(spsi%rwf,1)
v = dble([ix, iy, iz])
call random_number(u)
spsi%rwf(ix,iy,iz,is,io,ik,ip) = product(sign(u(1:3),v(1:3)))
end do
end do
end do
end do
end do
end do
end do
end subroutine
subroutine gen_random_zwf
implicit none
real(8) :: u(2)
do ip=lbound(spsi%zwf,7),ubound(spsi%zwf,7)
do ik=lbound(spsi%zwf,6),ubound(spsi%zwf,6)
do io=lbound(spsi%zwf,5),ubound(spsi%zwf,5)
do is=lbound(spsi%zwf,4),ubound(spsi%zwf,4)
do iz=lbound(spsi%zwf,3),ubound(spsi%zwf,3)
do iy=lbound(spsi%zwf,2),ubound(spsi%zwf,2)
do ix=lbound(spsi%zwf,1),ubound(spsi%zwf,1)
call random_number(u)
spsi%zwf(ix,iy,iz,is,io,ik,ip) = cmplx(u(1),u(2))
end do
end do
end do
end do
end do
end do
end do
end subroutine
END SUBROUTINE init_wf
end module init_gs
| src/gs/init_gs.f90 |
LOGICAL FUNCTION SVROK (WKID, EXPVLS)
C SVROK: true iff current SVR is one of the expected values,
C encoded by character: c-correct, s-simulated, d-deferred.
C E.g. expvls = 'cd' means SVR must be either CORRECT or
C DEFERRED.
C state of visual representation
C correct deferred simulated
INTEGER PVROK, PVRDFR, PVRSIM
PARAMETER (PVROK = 0, PVRDFR = 1, PVRSIM = 2)
INTEGER WKID, ERRIND, ACTSVR
INTEGER IDUM1, IDUM2, IDUM3
CHARACTER EXPVLS*(*), SVRCOD(PVROK:PVRSIM)*1
DATA SVRCOD /'c', 'd', 's'/
CALL PQDUS (WKID, ERRIND, IDUM1, IDUM2, IDUM3, ACTSVR)
CALL CHKINQ ('pqdus', ERRIND)
SVROK = INDEX(EXPVLS, SVRCOD(ACTSVR)) .GT. 0
END
| third_party/Phigs/PVT/PVT_fort/V2LIB/svrok.f |
SUBROUTINE cgsolve(g,q,sol)
!-------------------------------------------------------------
!
! Perform a simple conjugate gradient solution
!
!-------------------------------------------------------------
USE invar
USE solvar
USE timevar
IMPLICIT NONE
INTEGER, INTENT(IN) :: g
INTEGER :: it, neq
REAL*8 :: alf, bet, dfmx, tmp, qnorm
REAL*8, DIMENSION((ordsq*nx*ny)), INTENT(IN) :: q
REAL*8, DIMENSION((ordsq*nx*ny)), INTENT(OUT) :: sol
REAL*8, DIMENSION((ordsq*nx*ny)) :: res, sd, tmp1, sold
! Set the timing point
told = tjmat
neq = ordsq*nx*ny
WRITE (8,*) " Conjugate Gradient iterative solution ..."
WRITE(8,'(2X,A)') "Error based on solution residual"
! Initialize my guess
sol = 0.0
res = q
sd = res
!qnorm = SQRT(DOT_PRODUCT(q,q))
!qnorm = MAXVAL(ABS(q))
tmp = DOT_PRODUCT(res,res)
DO it = 1, itmx
! The CG steps...should be optimized later or use outside solver
tmp1 = MATMUL(jmat,sd)
alf = tmp/(DOT_PRODUCT(sd,tmp1))
sol = sol + alf*sd
res = res-alf*tmp1
bet = 1.0/tmp
tmp = DOT_PRODUCT(res,res)
bet = tmp*bet
sd = res + bet*sd
! Check convergence between the iterates.
! Error based on the residual and possibly the RHS
! dfmx = SQRT(tmp)/qnorm
! dfmx = (MAXVAL(ABS(res)))/qnorm
! dfmx = MAXVAL(ABS(res))
dfmx = SQRT(tmp)
! Get iteration time
CALL CPU_TIME(titer)
IF (dfmx > err .AND. it < itmx) THEN
! DON'T USE THIS WHEN DETERMINING ERROR WITH 2-NORM
! Report the change in the error
! ndx = MAXLOC(ABS(tmp2))
! indx = ndx(1) - 1
! ! Need to back out the values for the position and moments
! jd = (indx/(nx*ordsq)) + 1
! id = (MOD(indx,(nx*ordsq))/ordsq) + 1
! indx2 = indx - ((jd-1)*nx + (id-1))*ordsq
! kd = indx2/order
! ld = MOD(indx2,order)
! WRITE(8,121) g, it, id, jd, kd, ld, dfmx, sol(indx), titer-told
WRITE (8,122) g, it, dfmx, titer-told
! Reset the timing point
told = titer
CYCLE
ELSE IF (dfmx < err) THEN
WRITE(8,*)
WRITE(8,*) " Group ", g, "converged in ", it, " iterations"
WRITE(8,'(2X,A,ES11.3,A,ES11.3)') "Maximum error estimated: ", dfmx, " < ", err
WRITE(8,'(2X,A,F9.3,A)') "Final iteration time ", titer-told, " seconds"
cnvf(g) = 1
EXIT
ELSE IF (it == itmx) THEN
WRITE(8,*)
WRITE(8,*) " Group ", g, " did not converge in maximum number of iterations ", itmx
WRITE(8,*) " Max error = ", dfmx
cnvf(g) = 0
EXIT
END IF
! Error based on successive iterates
! dfmx = -1.0
! DO i = 1, neq
! IF (sold(i) >= tolr) THEN
! df = ABS((sol(i) - sold(i))/sold(i))
! ELSE
! df = ABS(sol(i) - sold(i))
! END IF
! IF (df > dfmx) dfmx = df
! END DO
! IF (dfmx > err .AND. it < itmx) THEN
! res = res - alf*tmp1
! bet = DOT_PRODUCT(res,res)
! bet = bet/tmp
! sd = res + bet*sd
! sold = sol
! CYCLE
! ELSE IF (dfmx < err) THEN
! WRITE (8,*)
! WRITE (8,*) " Group ", g, " converged in ", it, " iterations"
! WRITE (8,'(2X,A,ES11.3,A,ES11.3)') "Maximum error estimated: ", dfmx, " < ", err
! cnvf(g) = 1
! EXIT
! ELSE IF (it == itmx) THEN
! WRITE(8,*)
! WRITE(8,*) " Group ", g, " did not converge in maximum number of iterations ", itmx
! WRITE(8,*) " Max error = ", dfmx
! cnvf(g) = 0
! EXIT
! END IF
END DO
!121 FORMAT(2X,'Gr',I3,' It ',I5,' Pos ',2I4,' Mom ',2I2,' DfMx ',ES11.3,' Flx ',ES11.3, ' Time(s) ', F9.3)
122 FORMAT(2X,'Gr',I3,' It ',I5,' Dfmx ',ES11.3,' Time(s) ',F9.3)
RETURN
END SUBROUTINE cgsolve
| src/transport_spatial_methods/2d/src/cgsolve.f90 |
c
c spatialFilter routine -- Apply a fixed spatial filter (smoother) in lat/lon and then average over times/grids
c
c Designed to be called from python using f2py.
c
c
c Low Pass Filter = 1/9 * [1 1 1 ! normalization = 9
c 1 1 1
c 1 1 1]
c
c Gaussian Filter = 1/16 * [1 2 1 ! normalization = 16
c 2 4 2
c 1 2 1]
c
subroutine spatialFilter_f(var, mask,
& time, lat, lon,
& filter, normalization,
& missingValue,
& verbose,
& vinterp, vcount, status,
& ntime, nlat, nlon)
implicit none
integer*4 ntime, nlat, nlon
c ! prepared 3D array of variable data over time, lon, & lat
real*4 var(ntime, nlat, nlon)
c ! variable to be interpolated, over ntime epochs
integer*1 mask(ntime, nlat, nlon)
c ! pixel quality mask
integer*4 time(ntime)
c ! time epochs to gaussian-interpolate over
real*4 lat(nlat)
! latitude corrdinate vector
real*4 lon(nlon)
! longitude corrdinate vector
cf2py intent(in) var, mask, time, lat, lon !! annotations for f2py processor
integer*4 filter(3, 3)
c ! 3x3 filter coefficients as integers
integer*4 normalization
c ! Normalization factor for the filter, divide by sum of integers
cf2py intent(in) filter, normalization
real*4 missingValue
c ! value to mark missing values in interp result
integer*4 verbose
c ! integer to set verbosity level
cf2py intent(in) missingValue, verbose
real*4 vinterp(nlat, nlon)
c ! interpolated variable using gaussians, missing values not counted
integer*4 vcount(nlat, nlon)
c ! count of good data, might be zero after masking
integer*4 status
c ! negative status indicates error
cf2py intent(out) vinterp, vcount, status
integer*4 iin, jin, kin
integer*4 i, j, fac, count
real*4 val, sum
write(6, *) 'Echoing inputs ...'
write(6, *) 'ntime, nlat, nlon:', ntime, nlat, nlon
write(6, *) 'filter:', filter
write(6, *) 'normalization', normalization
write(6, *) 'missingValue:', missingValue
status = 0
if (verbose .gt. 3) then
write(6, *) 'time:', time
write(6, *) 'lat:', lat
write(6, *) 'lon:', lon
c write(6, *) 'mask(3):', mask(3,:,:)
write(6, *) 'var(3):', var(3,:,:)
end if
do i = 1, nlat
if (verbose .gt. 1) write(6, *) lat(i)
do j = 1, nlon
vinterp(i,j) = 0.0
vcount(i,j) = 0.0
if (verbose .gt. 3) then
write(6, *) '(i,j) = ', i, j
write(6, *) '(lat,lon) = ', lat(i), lon(j)
end if
do kin = 1, ntime
sum = 0.0
count = 0
do iin = -1, +1
if (i+iin .lt. 1 .or. i+iin .gt. nlat) cycle
do jin = -1, +1
if (j+jin .lt. 1 .or. j+jin .gt. nlon) cycle
if (mask(kin,iin,jin) .eq. 0) then
fac = filter(iin+2, jin+2)
val = var(kin,iin,jin)
sum = sum + fac * val
count = count + fac
end if
end do
end do
if (count .gt. 0) then
c ! filter for (i,j) pixel isn't empty
vinterp(i,j) = vinterp(i,j) + sum / normalization
vcount(i,j) = vcount(i,j) + 1
end if
end do
if (vcount(i,j) .gt. 0) then
vinterp(i,j) = vinterp(i,j) / vcount(i,j)
c ! compute mean over number of non-empty times/grids
else
vinterp(i,j) = missingValue
end if
end do
end do
return
end
| climatology/clim/spatialFilter_f.f |
C -------------------------------------------------------------------
C *** GRAD2
C ------------------------------------------------------------------
C
C *** THE GRAD2 FUNCTION SUBPROGRAM COMPUTES THE FOLLOWING DIRECTLY
C *** <P(I)[R.D + F(DELTA)[ P(J)>
C
DOUBLE PRECISION FUNCTION grad2(I,J)
IMPLICIT DOUBLE PRECISION(A-H,O-Z)
CHARACTER*3 el
PARAMETER (NWD=80,NOD=220)
PARAMETER (IWRITE=6)
COMMON /PARAM/H,H1,H3,CH,EH,RHO,Z,TOL,NO,ND,NWF,MASS,NCFG,IB,IC,ID
: ,D0,D1,D2,D3,D4,D5,D6,D8,D10,D12,D16,D30,FINE,NSCF,NCLOSD,RMASS
COMMON /RADIAL/R(NOD),RR(NOD),R2(NOD),YK(NOD),YR(NOD),X(NOD)
POINTER(IQP,P(NOD,1)),(IQN,N(1)),(IQL,L(1)),(IQAZ,AZ(1)),
: (IQMAX,MAX(1))
COMMON /NEL/IQP,IQN,IQL,IQAZ,IQMAX,IQ(7),el(nwd)
DIMENSION Q(NOD)
JJ=I
II=J
DO1K=1,NO
1 Q(K)=P(K,JJ)*R(K)
LI=L(I)
LJ=L(J)
IL = IABS(LI - LJ)
IF (IL .NE. 0 .AND. IL .NE. 2) GO TO 100
A1=(LI+LJ+D2)/((LI+D1)*(LJ+D1))
A2=((LJ+D5)*(LJ+D1)+(LJ+D1+D5)*(LI+D1))/((LI+D1)*(LJ+D1))
A=A1-A2*(LI+LJ+D3)/((LI+LJ+D4)*(LJ+D5))
FACT=(LJ+D5)/(LI+LJ+D3)
G=R(1)**2*P(1,I)*P(1,J)*FACT*(1.+A*Z*R(1))
MM=MIN0(MAX(I)+1,MAX(J)+1,ND)
K=2
F1=D5*(P(K+1,II)-P(K-1,II))
F2=P(K+1,II)-D2*P(K,II)+P(K-1,II)
G0=Q(K)*R(K)
G1=D5*(Q(K+1)*R(K+1)-Q(K-1)*R(K-1))
G2=Q(K+1)*R(K+1)-D2*Q(K)*R(K)+Q(K-1)*R(K-1)
G=G+D2*F1*G0+(D2*F2*G1+F1*G2)/D3
DO2K=4,MM,2
F1=D5*(P(K+1,II)-P(K-1,II))
F2=P(K+1,II)-D2*P(K,II)+P(K-1,II)
F3=D5*(P(K+1,II)-P(K-2,II))-D2*F1
F4=P(K+2,II)+P(K-2,II)-D4*(P(K+1,II)+P(K-1,II))
1 +D6*P(K,II)
G0=Q(K)*R(K)
G1=D5*(Q(K+1)*R(K+1)-Q(K-1)*R(K-1))
G2=Q(K+1)*R(K+1)-D2*Q(K)*R(K)+Q(K-1)*R(K-1)
G3=D5*(Q(K+2)*R(K+2)-Q(K-2)*R(K-2))-D2*G1
G4=Q(K+2)*R(K+2)+Q(K-2)*R(K-2)-D4*(Q(K+1)*R(K+1)
1 +Q(K-1)*R(K-1))+D6*Q(K)*R(K)
G=G+D2*F1*G0+(D2*F2*G1+F1*G2)/D3
1 -(F1*G4-F4*G1+D4*(F2*G3-F3*G2))/90.E0
2 CONTINUE
U=QUADR(JJ,II,0)
G=G-D5*U
DELTA=LJ-LI
IF(DELTA)10,11,12
10 GRAD2=G-(LI-D2)*U
RETURN
11 GRAD2=G+(D1+D5)*U
RETURN
12 GRAD2=G+(LI+D3)*U
RETURN
100 WRITE(6,101) I,J
101 FORMAT(5X,'L(I)-L(J) NOT=0,2 FOR I = ',I2,' AND J = ',I2)
STOP
END
| src/appl/trans/grad2.f |
program main
use LoggerClass
use fem
implicit none
type(FEMDomain_) :: cube
type(Logger_) :: Bob
type(Math_) :: math
integer(int32) :: i
! create an object
call cube%create("Cube3D")
! set channels
call Bob%set("Node3_x",cube%mesh%nodcoord(3,1))
call Bob%set("Node12_y",cube%mesh%nodcoord(12,2))
call Bob%set("Node9_z",cube%mesh%nodcoord(3,3))
! start logger
call Bob%start()
do i=1,100
call cube%move(x=sin(dble(i)/2.0d0/Math%PI ) )
call cube%rotate(x=sin(dble(i)/2.0d0/Math%PI ) )
call Bob%save()
enddo
call Bob%reset()
do i=1,100
call cube%rotate(x=sin(dble(i)/2.0d0/Math%PI ) )
call Bob%save()
enddo
end program main | Tutorial/sim/HowToUseLogger.f90 |
MODULE trdmxl_rst
USE dom_oce
USE trd_oce
USE in_out_manager
USE iom
USE restart
IMPLICIT NONE
PRIVATE
PUBLIC :: trd_mxl_rst_read
PUBLIC :: trd_mxl_rst_write
INTEGER :: nummxlw
CONTAINS
SUBROUTINE trd_mxl_rst_write(kt)
INTEGER, INTENT( IN ) :: kt
CHARACTER(LEN = 35) :: charout
INTEGER :: jk
CHARACTER(LEN = 20) :: clkt
CHARACTER(LEN = 50) :: clname
CHARACTER(LEN = 256) :: clpath
IF (kt == nitrst - 1 .OR. nstock == 1 .OR. (kt == nitend .AND. MOD(nitend - 1, nstock) == 0)) THEN
IF (nitrst > 999999999) THEN
WRITE(clkt, FMT = *) nitrst
ELSE
WRITE(clkt, FMT = '(i8.8)') nitrst
END IF
clname = TRIM(cexper) // "_" // TRIM(ADJUSTL(clkt)) // "_" // TRIM(cn_trdrst_out)
clpath = TRIM(cn_ocerst_outdir)
IF (clpath(LEN_TRIM(clpath) :) /= '/') clpath = TRIM(clpath) // '/'
IF (lwp) THEN
WRITE(numout, FMT = *)
SELECT CASE (jprstlib)
CASE DEFAULT
WRITE(numout, FMT = *) ' open ocean restart_mxl NetCDF file: ' // clname
END SELECT
IF (kt == nitrst - 1) THEN
WRITE(numout, FMT = *) ' kt = nitrst - 1 = ', kt, ' date= ', ndastp
ELSE
WRITE(numout, FMT = *) ' kt = ', kt, ' date= ', ndastp
END IF
END IF
CALL iom_open(TRIM(clpath) // TRIM(clname), nummxlw, ldwrt = .TRUE., kiolib = jprstlib)
END IF
IF (kt == nitrst .AND. lwp) THEN
WRITE(numout, FMT = *)
WRITE(numout, FMT = *) 'trdmxl_rst: output for ML diags. restart, with trd_mxl_rst_write routine kt =', kt
WRITE(numout, FMT = *) '~~~~~~~~~~'
WRITE(numout, FMT = *)
END IF
IF (ln_trdmxl_instant) THEN
CALL iom_rstput(kt, nitrst, nummxlw, 'tmlbb', tmlbb)
CALL iom_rstput(kt, nitrst, nummxlw, 'tmlbn', tmlbn)
CALL iom_rstput(kt, nitrst, nummxlw, 'tmlatfb', tmlatfb)
CALL iom_rstput(kt, nitrst, nummxlw, 'smlbb', smlbb)
CALL iom_rstput(kt, nitrst, nummxlw, 'smlbn', smlbn)
CALL iom_rstput(kt, nitrst, nummxlw, 'smlatfb', smlatfb)
ELSE
CALL iom_rstput(kt, nitrst, nummxlw, 'hmxlbn', hmxlbn)
CALL iom_rstput(kt, nitrst, nummxlw, 'tmlbn', tmlbn)
CALL iom_rstput(kt, nitrst, nummxlw, 'tml_sumb', tml_sumb)
DO jk = 1, jpltrd
IF (jk < 10) THEN
WRITE(charout, FMT = "('tmltrd_csum_ub_', I1)") jk
ELSE
WRITE(charout, FMT = "('tmltrd_csum_ub_', I2)") jk
END IF
CALL iom_rstput(kt, nitrst, nummxlw, charout, tmltrd_csum_ub(:, :, jk))
END DO
CALL iom_rstput(kt, nitrst, nummxlw, 'tmltrd_atf_sumb', tmltrd_atf_sumb)
CALL iom_rstput(kt, nitrst, nummxlw, 'smlbn', smlbn)
CALL iom_rstput(kt, nitrst, nummxlw, 'sml_sumb', sml_sumb)
DO jk = 1, jpltrd
IF (jk < 10) THEN
WRITE(charout, FMT = "('smltrd_csum_ub_', I1)") jk
ELSE
WRITE(charout, FMT = "('smltrd_csum_ub_', I2)") jk
END IF
CALL iom_rstput(kt, nitrst, nummxlw, charout, smltrd_csum_ub(:, :, jk))
END DO
CALL iom_rstput(kt, nitrst, nummxlw, 'smltrd_atf_sumb', smltrd_atf_sumb)
END IF
IF (kt == nitrst) THEN
CALL iom_close(nummxlw)
lrst_oce = .FALSE.
END IF
END SUBROUTINE trd_mxl_rst_write
SUBROUTINE trd_mxl_rst_read
INTEGER :: inum
CHARACTER(LEN = 35) :: charout
INTEGER :: jk
INTEGER :: jlibalt = jprstlib
LOGICAL :: llok
CHARACTER(LEN = 256) :: clpath
IF (lwp) THEN
WRITE(numout, FMT = *)
WRITE(numout, FMT = *) ' trd_mxl_rst_read : read the NetCDF mixed layer trend restart file'
WRITE(numout, FMT = *) ' ~~~~~~~~~~~~~~~~'
END IF
clpath = TRIM(cn_ocerst_indir)
IF (clpath(LEN_TRIM(clpath) :) /= '/') clpath = TRIM(clpath) // '/'
CALL iom_open(TRIM(clpath) // TRIM(cn_trdrst_in), inum, kiolib = jlibalt)
IF (ln_trdmxl_instant) THEN
CALL iom_get(inum, jpdom_autoglo, 'tmlbb', tmlbb)
CALL iom_get(inum, jpdom_autoglo, 'tmlbn', tmlbn)
CALL iom_get(inum, jpdom_autoglo, 'tmlatfb', tmlatfb)
CALL iom_get(inum, jpdom_autoglo, 'smlbb', smlbb)
CALL iom_get(inum, jpdom_autoglo, 'smlbn', smlbn)
CALL iom_get(inum, jpdom_autoglo, 'smlatfb', smlatfb)
ELSE
CALL iom_get(inum, jpdom_autoglo, 'hmxlbn', hmxlbn)
CALL iom_get(inum, jpdom_autoglo, 'tmlbn', tmlbn)
CALL iom_get(inum, jpdom_autoglo, 'tml_sumb', tml_sumb)
DO jk = 1, jpltrd
IF (jk < 10) THEN
WRITE(charout, FMT = "('tmltrd_csum_ub_', I1)") jk
ELSE
WRITE(charout, FMT = "('tmltrd_csum_ub_', I2)") jk
END IF
CALL iom_get(inum, jpdom_autoglo, charout, tmltrd_csum_ub(:, :, jk))
END DO
CALL iom_get(inum, jpdom_autoglo, 'tmltrd_atf_sumb', tmltrd_atf_sumb)
CALL iom_get(inum, jpdom_autoglo, 'smlbn', smlbn)
CALL iom_get(inum, jpdom_autoglo, 'sml_sumb', sml_sumb)
DO jk = 1, jpltrd
IF (jk < 10) THEN
WRITE(charout, FMT = "('smltrd_csum_ub_', I1)") jk
ELSE
WRITE(charout, FMT = "('smltrd_csum_ub_', I2)") jk
END IF
CALL iom_get(inum, jpdom_autoglo, charout, smltrd_csum_ub(:, :, jk))
END DO
CALL iom_get(inum, jpdom_autoglo, 'smltrd_atf_sumb', smltrd_atf_sumb)
CALL iom_close(inum)
END IF
END SUBROUTINE trd_mxl_rst_read
END MODULE trdmxl_rst | trdmxl_rst.f90 |
The HORSE POLO CLUB is managed by the mens and womens UC Davis competitive team members, who have come in first at the Regional Competition for the last 6 years. The team offers weekly clinics to teach anyone how to play the game. It is a great alternative to the Equestrian Center Prices and so much fun! There is absolutely no riding or horse experience necessary. Clinics are available from beginners through advanced, for whether you are interested in learning about horses or in a position on the team. Horses and equipment are provided, bringing boots is suggested, and any other personal equipment (excluding horses) is welcome.
SIGNUP FOR FALL NOW!!
In the FALL: Clinics will be offered MON FRI 5pm9pm
spaces are limited
See Also: Organizations, Student Organizations, Outdoor Activities
Contact MailTo(davishorsepolo AT yahoo DOT com)
To view the team schedule, recent news, or more info visit our website at http://sportclubs.ucdavis.edu/horsepolo/.
Being that this is Davis there is also Bike Polo, not to mention Horse Ball.
| lab/davisWiki/Horse_Polo_Club.f |
Cal Davis Apartments offers one and twobedroom apartments ranging from $950/month to $1050/month April 2009.
Visit our Housing Guide or Apartments page to learn about more housing options within Davis.
20130707 21:59:51 nbsp We have stayed at Cal Davis Apartments for three years. The landlord Bob Hayden is really nice. The only reason we moved out is because we were moving out of the country. He is a landlord who believes in listening to the tenants and returning security deposits. The apartments are clean and well maintained but not fancy. I would highly recommend this place for the location, cleanliness and a great landlord. Users/DivyaAiyar
20140413 21:24:14 nbsp My roommates and I have lived here for 7 months and it is literally the worst living situation that Ive had in my four years here. The apartment is tiny and prett pricy compared to other places nearby. We have been having issues with the wifi, the appliances, bugs, thin walls (we can hear our neighbors phones vibrate) and weve never seen the actual landlord. Ever. He takes forever to respond when we have a problem, and often doesnt respond at all. Honesty, we thought we were getting a deal because the place didnt require a deposit. But its not worth it there are plenty of places much better close by! Users/LeonnaSpilman
| lab/davisWiki/Cal_Davis_Apartments.f |
C ( Last modified on 10 Sepc 2004 at 17:05:38 )
C Correction: 10/Sep/2004: undeclared integer variables declared
C ( Last modified on 23 Dec 2000 at 22:01:38 )
PROGRAM OSLMA
C
C OSL test driver for problems derived from SIF files.
C
INTEGER NMAX , MMAX , M , N
INTEGER MCON , MEQ , LW , LIW
INTEGER NNZMAX, NNZJ , NNZH , NNZTH
INTEGER I , J , IC, IR, ICNH , INDV ,
* INDF , IRNH , MGEQ , NJAC
CHARACTER * 10 PNAME
CTOY PARAMETER ( NMAX = 100, MMAX = 100 )
CMED PARAMETER ( NMAX = 200, MMAX = 200 )
CBIG PARAMETER ( NMAX = 500, MMAX = 500 )
CCUS PARAMETER ( NMAX = 400, MMAX = 300 )
PARAMETER ( NNZMAX = 20 * NMAX )
PARAMETER ( LW = 11000 + 10 * NMAX + 10 * MMAX + NNZMAX )
PARAMETER ( LIW = NMAX + 1 + 4 * NNZMAX )
INTEGER IW ( LIW )
CS REAL X ( NMAX ), BL ( NMAX ), BU( NMAX ),
CD DOUBLE PRECISION X ( NMAX ), BL ( NMAX ), BU( NMAX ),
* G ( NMAX ), C ( MMAX ),
* CL ( MMAX ), CU ( MMAX ), W ( LW )
CS REAL OBJF, GET(34)
CD DOUBLE PRECISION OBJF, GET(34)
LOGICAL EQUATN( MMAX ), LINEAR( MMAX )
INTEGER INPUT, IOUT, RTCOD
LOGICAL DEBUG
PARAMETER ( INPUT = 55, IOUT = 6 )
CS REAL ZERO
CD DOUBLE PRECISION ZERO
CS PARAMETER ( ZERO = 0.0E+0 )
CD PARAMETER ( ZERO = 0.0D+0 )
REAL CPU( 2 ), CALLS( 7 )
DEBUG = .FALSE.
C
C Open the relevant file.
C
OPEN ( INPUT, FILE = 'OUTSDIF.d', FORM = 'FORMATTED',
* STATUS = 'OLD' )
REWIND INPUT
C
C Set up the data structures necessary to hold the problem functions.
C
CALL OSLSE ( INPUT , IOUT , N , M , MGEQ , MEQ , MCON ,
* X , BL, BU , NMAX , EQUATN, LINEAR,
* W , CL, CU , MMAX )
C
C Set up algorithmic input data.
C
C
C Start of main iteration loop.
C
C
C Set X to zero to determine the constant terms and the linear terms for
C the problem functions.
C
OBJF = ZERO
DO 30 I = 1, N
X( I ) = ZERO
W( I ) = ZERO
30 CONTINUE
C
C Evaluate the constant terms of the objective and the linear coefficients.
C
CALL COFG( N , X, OBJF, G(1), .TRUE.)
C
C Partition the integer sparse work vector IW.
C
INDV = 0
INDF = INDV + NNZMAX
IRNH = INDF + NNZMAX
ICNH = IRNH + NMAX
C
C Evaluate the constant and linear terms of the constraint functions
C in a sparse format.
C
CALL CSCFG ( N, M, X, MMAX, C, NNZJ, NJAC, G( N + 1 ),
* IW( INDV + 1 ), IW( INDF + 1 ), .TRUE. )
C
C Set up row bounds
C
DO 40 I = 1, M
CL(I) = CL(I) - C(I)
CU(I) = CU(I) - C(I)
40 CONTINUE
IF ( DEBUG ) THEN
WRITE( 6, 2005 ) ( I, X( I ), BL( I ), BU( I ), I = 1, N )
IF ( MCON .GT. 0 ) WRITE( 6, 2060 ) ( I, C( I ), CL( I ),
* CU( I ), EQUATN( I ), LINEAR( I ), I = 1, MCON )
END IF
C
C Evaluate the Hessian matrix using sparse format.
C
CALL CSH ( N , M , X, MMAX, W, NNZH , NMAX, G( N + NNZJ + 1 ) ,
* IW( IRNH + 1 ), IW( ICNH + 1 ) )
C
C DEBUG output
C
IF ( DEBUG ) THEN
WRITE( 6, 2010 ) OBJF
IF ( M .GT. 0 ) WRITE( 6, 2070 ) ( I, C( I ), I = 1, M )
WRITE( 6, 2080 )
WRITE( 6, 2015 ) ( G( I ), I = 1, N )
DO 11 J = 1, NNZJ
IC = IW( INDV + J )
IR = IW( INDF + J )
WRITE( 6, 2020 ) IR, IC, G( N + J )
11 CONTINUE
DO 12 J = 1, NNZH
IC = IW( ICNH + J )
IR = IW( IRNH + J )
WRITE( 6, 2030 ) IR, IC, G( N + NNZJ + J )
12 CONTINUE
END IF
C
C Fill-in lower half of Hessian
C
NNZTH = NNZH
DO 14 J = 1, NNZTH
IC = IW( ICNH + J )
IR = IW( IRNH + J )
IF ( IR .NE. IC) THEN
NNZH = NNZH + 1
IW( ICNH + NNZH ) = IR
IW( IRNH + NNZH ) = IC
G( N + NNZJ +NNZH ) = G( N + NNZJ + J )
END IF
14 CONTINUE
C
C Describe workspace and allow room for one matrix.
C
CALL EKKDSCA(RTCOD,W, LW,1)
IF ( RTCOD .GT. 0 ) CALL CHKRT('EKKDSCA',RTCOD)
WRITE( 6, 2000 ) N, M, MEQ, MCON, RTCOD
C
C Describe the model. Minimum of 5 blocks are needed for QP.
C
CALL EKKDSCM(RTCOD,W,1,5)
IF (RTCOD.GT.0) CALL CHKRT('EKKDSCM',RTCOD)
C
C Pass linear model with matrix stored by indices.
C
CALL EKKLMDL(RTCOD, W, 1, M, N, NNZJ, G(1), CL(1), CU(1),
* BL(1), BU(1), IW(INDF+1), IW(INDV+1), G(N+1) )
IF (RTCOD.GT.0) CALL CHKRT('EKKLMDL',RTCOD)
C
C Pass quadratic matrix stored by indices.
C
CALL EKKQMDL(RTCOD, W, 1, NNZH, IW(IRNH+1), IW(ICNH+1),
* G( N + NNZJ + 1 ) )
IF (RTCOD.GT.0) CALL CHKRT('EKKQMDL',RTCOD)
C
C Solve the QP using the primal algorithm.
C
CALL EKKQSLV(RTCOD,W,1,1)
IF (RTCOD.GT.0) CALL CHKRT('EKKQSLV',RTCOD)
C
C Print the solution.
C
CALL EKKPRTS(RTCOD,W)
IF (RTCOD.GT.0) CALL CHKRT('EKKPRTS',RTCOD)
C
C Compensate for any nonzero constant in the objective
C
IF (OBJF .NE. ZERO) THEN
CALL EKKRGET(RTCOD,W,GET,18)
IF (RTCOD.GT.0) CALL CHKRT('EKKRGET',RTCOD)
OBJF = GET(18) + OBJF
WRITE(6,2085) OBJF
END IF
C
C Get and print statistics
C
CALL CREPRT( CALLS, CPU )
C CALL CNAMES( N, M, PNAME, XNAME, CNAME )
WRITE ( IOUT, 1500 ) PNAME, N, CALLS(1), CALLS(2), CALLS(3),
* RTCOD, OBJF, CPU(1), CPU(2)
STOP
C
C Non executable statements
C
1500 FORMAT( /, 24('*'), ' CUTEr statistics ', 24('*') //
* ,' Code used : OSL', /
* ,' Problem : ', A10, /
* ,' # variables = ', I10 /
* ,' # objective functions = ', F8.2 /
* ,' # objective gradients = ', F8.2 /
* ,' # objective Hessians = ', F8.2 /
* ' Exit code = ', I10 /
* ,' Final f = ', E15.7 /
* ,' Set up time = ', 0P, F10.2, ' seconds' /
* ' Solve time = ', 0P, F10.2, ' seconds' //
* 66('*') / )
2000 FORMAT( /, ' N = ', I6, ' M = ', I6, ' MEQ = ', I6,
* ' MCON = ', I6, ' RTCOD = ', I6 )
2010 FORMAT( /, ' Objective function constant is ', 1P, D22.14 )
2015 FORMAT( /, ' Objective function linear terms are', /, ( 1P,
* D12.4 ) )
2020 FORMAT( /, ' Constraint function',I6,' linear terms are with',
* ' respect to variable ',
* /, I6, 1P, D12.4 )
2030 FORMAT( /, ' Objective function Hessian terms with respect to',
* ' variables ',
* /, I6, 1P, I6, 1P, D12.4 )
2005 FORMAT( /, ' After projection, the starting point:',
* /, ' I X BL BU', /,
* ( I6, 1P, 3D12.4 ) )
2060 FORMAT( /, ' the constraints:', /,
* ' I MULTIPLIER CL CU EQUALITY? ',
* ' LINEAR? ', /, ( I6, 1P, 3D12.4, 5X, L1, 10X, L1 ) )
2070 FORMAT( /, ' the constraint constant values are:',
* /, ' I C ', /, ( I6, 1P, D12.4 ) )
2080 FORMAT( /, ' Linear terms ' )
2085 FORMAT( /, ' True objective function value ',
* '(OSL ignores constants) ', 1P, D22.14 )
C
C End of OSLMA.
C
END
C
C***********************************************************************
C This subroutine prints the character string RTNAME and the return
C code RTCOD and stops if RTCOD is large enough to indicate that an
C OSL error or severe error has occured.
C***********************************************************************
C
SUBROUTINE CHKRT(RTNAME,RTCOD)
CHARACTER*7 RTNAME
INTEGER*4 RTCOD
C
WRITE(6,9000) RTNAME,RTCOD
IF (RTCOD.GE.200) STOP 16
RETURN
9000 FORMAT (1X,'********** ',A7,' return code of ',I4,' **********')
END
SUBROUTINE OSLSE( INPUT , IOUT , N , M , MGEQ , MEQ ,
* MCON , X , BL, BU , NMAX , EQUATN,
* LINEAR, V , CL, CU , MMAX )
INTEGER INPUT , IOUT , N , M , MGEQ , MEQ , MCON
INTEGER NMAX , MMAX
CS REAL X ( NMAX ), BL ( NMAX ), BU ( NMAX )
CS REAL V ( MMAX ), CL ( MMAX ), CU ( MMAX )
CD DOUBLE PRECISION X ( NMAX ), BL ( NMAX ), BU ( NMAX )
CD DOUBLE PRECISION V ( MMAX ), CL ( MMAX ), CU ( MMAX )
LOGICAL EQUATN( MMAX ), LINEAR( MMAX )
C
C Set up the input data for the the OSL minimizer.
C
C
INTEGER I
C
C Set up the data structures necessary to hold the problem functions.
C
CALL CSETUP ( INPUT , IOUT , N , MCON , X , BL , BU ,
* NMAX , EQUATN, LINEAR, V , CL, CU , MMAX,
* .TRUE., .FALSE., .FALSE. )
C
C Count the number of general equality constraints.
C
M = MCON
MGEQ = 0
DO 20 I = 1, M
IF ( EQUATN( I ) ) MGEQ = MGEQ + 1
20 CONTINUE
C IF ( M .GT. 0 ) WRITE( 6, 2010 ) ( I, V( I ), CL( I ), CU( I ),
C * EQUATN( I ), LINEAR( I ), I = 1, M )
C
MEQ = MGEQ
IF ( M .GT. MMAX ) THEN
IF ( IOUT .GT. 0 )
* WRITE( IOUT, 2000 ) 'EQUATN', 'MMAX ', M - MMAX
STOP
END IF
RETURN
C
C Non-executable statements.
C
2000 FORMAT( /, ' ** Program CSETUP: array length ', A6, ' too small.',
* /, ' -- Miminimization abandoned.',
* /, ' -- Increase the parameter ', A6, ' by at least ', I8,
* ' and restart.' )
C2010 FORMAT( /, ' the constraints:', /,
C * ' I MULTIPLIER CL CU EQUALITY? ',
C * ' LINEAR? ', /, ( I6, 1P, 3D12.4, 5X, L1, 10X, L1 ) )
C
C End of OSLSE.
C
END
| legacy_fortran/galahad-2.3/cuter2/common/src/tools/oslma.f |
! { dg-do compile }
! { dg-options "" }
! (options to disable warnings about statement functions etc.)
!
! PR fortran/44352
!
! Contributed by Vittorio Zecca
!
SUBROUTINE TEST1()
implicit real*8 (a-h,o-z)
character*32 ddname,stmtfnt1
stmtfnt1(x)= 'h810 e=0.01 '
ddname=stmtfnt1(0.d0)
if (ddname /= "h810 e=0.01") STOP 1
END
SUBROUTINE TEST2()
implicit none
character(2) :: ddname,stmtfnt2
real :: x
stmtfnt2(x)= 'x'
ddname=stmtfnt2(0.0)
if(ddname /= 'x') STOP 2
END
SUBROUTINE TEST3()
implicit real*8 (a-h,o-z)
character*32 ddname,dname
character*2 :: c
dname(c) = 'h810 e=0.01 '
ddname=dname("w ")
if (ddname /= "h810 e=0.01") STOP 3
END
SUBROUTINE TEST4()
implicit real*8 (a-h,o-z)
character*32 ddname,dname
character*2 :: c
dname(c) = 'h810 e=0.01 '
c = 'aa'
ddname=dname("w ")
if (ddname /= "h810 e=0.01") STOP 4
if (c /= "aa") STOP 5
END
call test1()
call test2()
call test3()
call test4()
end
| validation_tests/llvm/f18/gfortran.dg/string_4.f90 |
! Contains routines to evaluate XC energy and potential for radial charge distributions
module radial_xc
use xc_f90_types_m
use xc_f90_lib_m
implicit none
! Numerical flag choosing functional type
integer :: flag_functional_type
character(len=120) :: functional_description ! DRB lengthened to contain LibXC names
integer, parameter :: functional_lda_pz81 = 1
integer, parameter :: functional_lda_gth96 = 2
integer, parameter :: functional_lda_pw92 = 3 ! PRB 45, 13244 (1992) + PRL 45, 566 (1980)
integer, parameter :: functional_xalpha = 4 ! Slater/Dirac exchange only ; no correlation
integer, parameter :: functional_hartree_fock = 10 ! Hartree-Fock exact exchange ; no correlation
integer, parameter :: functional_gga_pbe96 = 101 ! Standard PBE
integer, parameter :: functional_gga_pbe96_rev98 = 102 ! revPBE (PBE + Zhang-Yang 1998)
integer, parameter :: functional_gga_pbe96_r99 = 103 ! RPBE (PBE + Hammer-Hansen-Norskov 1999)
integer, parameter :: functional_gga_pbe96_wc = 104 ! WC (Wu-Cohen 2006)
integer, parameter :: functional_hyb_pbe0 = 201 ! PBE0 (hybrid PBE with exx_alpha=0.25)
! LibXC variables
integer :: n_xc_terms
integer, dimension(2) :: i_xc_family
type(xc_f90_pointer_t), dimension(2) :: xc_func, xc_info
logical :: flag_use_libxc
contains
subroutine init_xc
use global_module, ONLY : nspin, flag_dft_d2, iprint
use GenComms, ONLY : inode, ionode, cq_abort
use numbers
implicit none
! Local variables
integer :: vmajor, vminor, vmicro, i, j
integer, dimension(2) :: xcpart
character(len=120) :: name, kind, family, ref
type(xc_f90_pointer_t) :: temp_xc_func
type(xc_f90_pointer_t) :: temp_xc_info
! Test for LibXC or CQ
if(flag_functional_type<0) then
! --------------------------
! LibXC functional specified
! --------------------------
flag_use_libxc = .true.
call xc_f90_version(vmajor, vminor, vmicro)
if(inode==ionode.AND.iprint>0) then
if(vmajor>2) then
write(*,'("LibXC version: ",I1,".",I1,".",I1)') vmajor, vminor, vmicro
else
write(*,'("LibXC version: ",I1,".",I1)') vmajor, vminor
end if
end if
! Identify the functional
if(-flag_functional_type<1000) then ! Only exchange OR combined exchange-correlation
n_xc_terms = 1
xcpart(1) = -flag_functional_type
else ! Separate the two parts
n_xc_terms = 2
! Make exchange first, correlation second for consistency
i = floor(-flag_functional_type/1000.0_double)
! Temporary init to find exchange or correlation
if(nspin==1) then
call xc_f90_func_init(temp_xc_func, temp_xc_info, i, XC_UNPOLARIZED)
else if(nspin==2) then
call xc_f90_func_init(temp_xc_func, temp_xc_info, i, XC_POLARIZED)
end if
select case(xc_f90_info_kind(temp_xc_info))
case(XC_EXCHANGE)
xcpart(1) = i
xcpart(2) = -flag_functional_type - xcpart(1)*1000
case(XC_CORRELATION)
xcpart(2) = i
xcpart(1) = -flag_functional_type - xcpart(2)*1000
end select
call xc_f90_func_end(temp_xc_func)
end if
! Now initialise and output
do i=1,n_xc_terms
if(nspin==1) then
call xc_f90_func_init(xc_func(i), xc_info(i), xcpart(i), XC_UNPOLARIZED)
else if(nspin==2) then
call xc_f90_func_init(xc_func(i), xc_info(i), xcpart(i), XC_POLARIZED)
end if
! Consistent threshold with Conquest
!if(vmajor>2) call xc_f90_func_set_dens_threshold(xc_func(i),RD_ERR)
call xc_f90_info_name(xc_info(i), name)
i_xc_family(i) = xc_f90_info_family(xc_info(i))
if(inode==ionode) then
select case(xc_f90_info_kind(xc_info(i)))
case (XC_EXCHANGE)
write(kind, '(a)') 'an exchange functional'
case (XC_CORRELATION)
write(kind, '(a)') 'a correlation functional'
case (XC_EXCHANGE_CORRELATION)
write(kind, '(a)') 'an exchange-correlation functional'
case (XC_KINETIC)
write(kind, '(a)') 'a kinetic energy functional'
case default
write(kind, '(a)') 'of unknown kind'
end select
select case (i_xc_family(i))
case (XC_FAMILY_LDA);
write(family,'(a)') "LDA"
case (XC_FAMILY_GGA);
write(family,'(a)') "GGA"
case (XC_FAMILY_HYB_GGA);
write(family,'(a)') "Hybrid GGA"
case (XC_FAMILY_MGGA);
write(family,'(a)') "MGGA"
case (XC_FAMILY_HYB_MGGA);
write(family,'(a)') "Hybrid MGGA"
case default;
write(family,'(a)') "unknown"
end select
functional_description = trim(name)
if(iprint>2) then
if(vmajor>2) then
write(*,'("The functional ", a, " is ", a, ", it belongs to the ", a, &
" family and is defined in the reference(s):")') &
trim(name), trim(kind), trim(family)
j = 0
call xc_f90_info_refs(xc_info(i), j, ref)
do while(j >= 0)
write(*, '(a,i1,2a)') '[', j, '] ', trim(ref)
call xc_f90_info_refs(xc_info(i), j, ref)
end do
else
write(*,'("The functional ", a, " is ", a, ", and it belongs to the ", a, &
" family")') &
trim(name), trim(kind), trim(family)
end if
else if(iprint>0) then
write(*,'(2x,"Using the ",a," functional ",a)') trim(family),trim(name)
else
write(*,fmt='(2x,"Using functional ",a)') trim(name)
end if
end if
end do
else
! -----------------------------
! Conquest functional specified
! -----------------------------
flag_use_libxc = .false.
if(nspin==2) then ! Check for spin-compatible functionals
if ( flag_functional_type == functional_lda_pz81 .or. &
flag_functional_type == functional_lda_gth96 ) then
if (inode == ionode) &
write (*,'(/,a,/)') &
'*** WARNING: the chosen xc-functional is not &
&implemented for spin polarised calculation, &
&reverting to LDA-PW92. ***'
flag_functional_type = functional_lda_pw92
end if
end if
select case(flag_functional_type)
case (functional_lda_pz81)
functional_description = 'LDA PZ81'
if(flag_dft_d2) call cq_abort("DFT-D2 only compatible with PBE and rPBE")
case (functional_lda_gth96)
functional_description = 'LDA GTH96'
if(flag_dft_d2) call cq_abort("DFT-D2 only compatible with PBE and rPBE")
case (functional_lda_pw92)
functional_description = 'LSDA PW92'
if(flag_dft_d2) call cq_abort("DFT-D2 only compatible with PBE and rPBE")
case (functional_gga_pbe96)
functional_description = 'GGA PBE96'
case (functional_gga_pbe96_rev98) ! This is PBE with the parameter correction
functional_description = 'GGA revPBE98' ! in Zhang & Yang, PRL 80:4, 890 (1998)
case (functional_gga_pbe96_r99) ! This is PBE with the functional form redefinition
functional_description = 'GGA RPBE99' ! in Hammer et al., PRB 59:11, 7413-7421 (1999)
if(flag_dft_d2) call cq_abort("DFT-D2 only compatible with PBE and rPBE")
case (functional_gga_pbe96_wc) ! Wu-Cohen nonempirical GGA functional
functional_description = 'GGA WC' ! in Wu and Cohen, PRB 73. 235116, (2006)
if(flag_dft_d2) call cq_abort("DFT-D2 only compatible with PBE and rPBE")
case (functional_hyb_pbe0) ! This is PB0E with the functional form redefinition
functional_description = 'hyb PBE0'
if(flag_dft_d2) call cq_abort("DFT-D2 only compatible with PBE and rPBE")
case default
functional_description = 'LSDA PW92'
if(flag_dft_d2) call cq_abort("DFT-D2 only compatible with PBE and rPBE")
end select
if(inode==ionode) write(*,'(/10x, "The functional used will be ", a15)') functional_description
end if ! if selecting LibXC or CQ
end subroutine init_xc
!!***
subroutine get_vxc(n_tot,rr,rho,vxc,exc)
use datatypes
use numbers
use GenComms, ONLY: cq_abort
use mesh, ONLY: make_derivatives
implicit none
! Passed variables
integer :: n_tot
real(double), dimension(n_tot) :: rho, rr,vxc
real(double), OPTIONAL :: exc
real(double), allocatable, dimension(:) :: exc_array
integer :: i, n
logical :: flag_energy, flag_libxc ! This will be in global later
real(double), dimension(:), allocatable :: drho_dr, sigma, vrho, vsigma, loc_rho, d2term
flag_energy = .false.
! Necessary for LibXC
allocate(exc_array(n_tot))
exc_array = zero
if(PRESENT(exc)) then
flag_energy = .true.
exc = zero
end if
vxc = zero
! Choose LibXC or Conquest
if(flag_use_libxc) then
allocate(drho_dr(n_tot),sigma(n_tot),vrho(n_tot),vsigma(n_tot),loc_rho(n_tot),d2term(n_tot))
! Make derivatives
loc_rho = rho/(four*pi)
call make_derivatives(loc_rho, drho_dr, sigma)
do n=1,n_xc_terms
! Call routine
select case (i_xc_family(n))
case(XC_FAMILY_LDA)
call xc_f90_lda_exc_vxc(xc_func(n),n_tot,loc_rho(1),exc_array(1),vrho(1))
vxc = vxc + vrho
case(XC_FAMILY_GGA)
call xc_f90_gga_exc_vxc(xc_func(n),n_tot,loc_rho(1),sigma(1),exc_array(1),vrho(1),vsigma(1))
vxc = vxc + vrho
d2term = zero
vsigma = vsigma*two*drho_dr
call make_derivatives(vsigma,d2term)!drho_dr) ! Re-use variable - we only need sigma
vxc = vxc - (two*vsigma/rr + d2term)!drho_dr) ! Radial part of div.(df/dg)
end select
if(PRESENT(exc)) then
do i = 1, n_tot
exc = exc + exc_array(i)
end do
! Potentially also find Exc correction
end if
end do
deallocate(drho_dr,sigma,vrho,vsigma)
else
select case(flag_functional_type)
case(functional_lda_pz81)
if(flag_energy) then
call vxc_pz_ca(n_tot, rr, rho, vxc, exc_array)
else
call vxc_pz_ca(n_tot, rr, rho, vxc)
end if
case(functional_gga_pbe96)
if(flag_energy) then
call vxc_gga_pbe(n_tot, rr, rho, vxc, exc_array)
else
call vxc_gga_pbe(n_tot, rr, rho, vxc)
end if
end select
if(PRESENT(exc)) then
exc = zero
do i = 1, n_tot
exc = exc + exc_array(i)
end do
! Potentially also find Exc correction
end if
end if
deallocate(exc_array)
end subroutine get_vxc
subroutine vxc_pz_ca(n_tot,rr,rho,vxc,exc)
use datatypes
use numbers
use GenComms, ONLY: cq_abort
implicit none
! Passed variables
integer :: n_tot
real(double), dimension(n_tot) :: rho, rr,vxc
real(double), OPTIONAL, dimension(n_tot) :: exc
! Local variables
integer :: i
real(double) :: dx_sq_over_twelve, qtot, V0
real(double), parameter :: prefac_rs = (three/fourpi)**third
real(double), parameter :: prefac_vx = (three_halves/pi)**(two*third)
real(double), dimension(:), allocatable :: y
real(double) :: denominator, e_correlation, e_exchange, ln_rs, &
numerator, rcp_rs, rh, rs, rs_ln_rs, sq_rs
real(double), parameter :: alpha = -0.45817_double
real(double), parameter :: beta_1 = 1.0529_double
real(double), parameter :: beta_2 = 0.3334_double
real(double), parameter :: gamma = -0.1423_double
real(double), parameter :: p = 0.0311_double
real(double), parameter :: q = -0.048_double
real(double), parameter :: r = 0.0020_double
real(double), parameter :: s = -0.0116_double
do i=1,n_tot
! rho is 4.pi.rho
rh = rho(i)/fourpi
if(rh>1e-8_double) then
rs = prefac_rs*rh**(-third)
if(rs>one) then
sq_rs = sqrt(rs)
denominator = (one + beta_1 * sq_rs + beta_2 * rs)
vxc(i) = -prefac_vx/rs + gamma*(one + seven_sixths*beta_1*sq_rs + &
four_thirds*beta_2*rs)/(denominator*denominator)
if(present(exc)) exc(i) = - 0.75_double*prefac_vx/rs + gamma/denominator
else
ln_rs = log(rs)
vxc(i) = -prefac_vx/rs + p*ln_rs + (q-third*p) + two*third*r*rs*ln_rs + third*(two*s - r)*rs
if(present(exc)) exc(i) = - 0.75_double*prefac_vx/rs + p*ln_rs + q + r*rs*ln_rs + s*rs
end if
else
vxc(i) = zero
if(present(exc)) exc(i) = zero
end if
end do
end subroutine vxc_pz_ca
! It's not necessary to calculate the full set of arrays of derivatives etc for this simple GGA
! implementation - we can simply do it point by point (as it's one dimensional).
subroutine vxc_gga_pbe(n_tot,rr,rho,vxc,exc)
use datatypes
use numbers
use GenComms, ONLY: cq_abort
use mesh, ONLY: drdi, alpha, drdi_squared
implicit none
! Passed variables
integer :: n_tot
real(double), dimension(n_tot) :: rho, rr,vxc
real(double), dimension(n_tot), OPTIONAL :: exc
! Local variables
! rho/4pi, differentials wrt grid (n) and radius (r) and laplacian
real(double) :: rho_sc, drho_dn, d2rho_dn2, drho_dr, d2rho_dr2, lapl_rho
real(double), parameter :: thirty = 30.0_double
real(double), parameter :: prefac_rs = (three/fourpi)**third
real(double), parameter :: prefac_kf = (three *pi*pi)**third
! Parameters for GGA routines
real(double) :: kF, s, t, u, v, rs, zeta, k_s
! GGA exchange energy and potential
real(double) :: ex, vx, ec, vc, h, dvc
integer :: i
! Work on main part first (where we can use FD) and add ends later
do i=3,n_tot-2
! rho is 4.pi.rho
rho_sc = rho(i)/fourpi
! Five point finite differences for differential wrt mesh points (not r)
! First derivative - extra factor of 4pi to scale rho
drho_dn = ( rho(i-2) - eight*rho(i-1) + eight*rho(i+1) - rho(i+2))/(twelve*fourpi)
! Second derivative - extra factor of 4pi to scale rho
d2rho_dn2 = (-rho(i-2) + sixteen*rho(i-1) -thirty*rho(i) + sixteen*rho(i+1) - rho(i+2))/(twelve*fourpi)
! Now differential wrt r
drho_dr = drho_dn/(drdi(i))
! NB the alpha here is from the radial mesh (NOT the alpha defined in the PW92 LDA correlation)
d2rho_dr2 = (d2rho_dn2 - alpha*drho_dn)/drdi_squared(i)
lapl_rho = (d2rho_dn2 + alpha*drho_dn)/drdi_squared(i)
if(rho_sc>1e-10_double) then ! Hamann's tolerance - check
kF = prefac_kF*rho_sc**third
s = abs(drho_dr)/(two * kF * rho_sc)
u = abs(drho_dr)*d2rho_dr2/(rho_sc*rho_sc*eight*kF*kF*kF)
v = lapl_rho/(rho_sc*four*kF*kF)
call pbe_exch(rho_sc,s,u,v,ex,vx)
rs = prefac_rs*rho_sc**(-third)
k_s = sqrt(four*kF/pi) ! NB a0 = 1 as we use atomic units
zeta = zero
t = abs(drho_dr)/(two*k_s*rho_sc) ! Set phi = one as zeta = zero
! Redefine u and v with k_s instead of k_F
u = abs(drho_dr)*d2rho_dr2/(rho_sc*rho_sc*eight*k_s*k_s*k_s)
v = lapl_rho/(rho_sc*four*k_s*k_s)
call pbe_corr(rs,t,u,v,ec,vc,h,dvc) ! No spin
else
vx = zero
vc = zero
dvc = zero
ex = zero
ec = zero
h = zero
end if
vxc(i) = vx + vc + dvc
if(PRESENT(exc)) exc(i) = ex + ec + h
end do
! Assume that the end points are essentially constant
vxc(1) = vxc(3)
vxc(2) = vxc(3)
vxc(n_tot-1) = vxc(n_tot-2)
vxc(n_tot) = vxc(n_tot-2)
if(PRESENT(exc)) then
exc(1) = exc(3)
exc(2) = exc(3)
exc(n_tot-1) = exc(n_tot-2)
exc(n_tot) = exc(n_tot-2)
end if
return
end subroutine vxc_gga_pbe
! From the original PBE routines
subroutine pbe_exch(rho, s, u, v, ex, vx)
use datatypes
use numbers
implicit none
! Passed variables
real(double) :: rho, s, u, v, ex, vx
! Precalculated constants
real(double), parameter :: prefac_ex = -three_quarters * (3/pi)**third
real(double), parameter :: mu = 0.2195149727645171_double ! beta (pi^2)/3 (Eq 12 in paper)
real(double), parameter :: kappa = 0.804_double
! Local variables
real(double) :: ex_lda, ul, p0, Fx, dFds, d2Fds2
ul = mu/kappa
! ------
! Energy
! ------
! LDA exchange
ex_lda = prefac_ex * rho**third
! PBE enhancement
p0 = one + ul * s * s
Fx = one + kappa - kappa / p0
ex = ex_lda * Fx
! ---------
! Potential
! ---------
! Derivatives of Fx wrt s: dFds = (1/s)dF/ds; d2Fds2 = d(dFds)/ds
dFds = two * mu / (p0 * p0)
d2Fds2 = -four * ul * s * dFds / p0
vx = ex_lda * (four * third * Fx - (u - four * third * s * s * s)*d2Fds2 - v * dFds)
end subroutine pbe_exch
subroutine pbe_corr(rs, t, u, v, ec_unif, vc_unif, h, dvc)
use datatypes
use numbers
implicit none
! Passed variables
real(double) :: rs, t, u, v, ec_unif, vc_unif, h, dvc ! Seitz radius !
! Local variables
real(double) :: sq_rs, prefac_ec_lda, log_fac_ec_lda, denominator
real(double) :: d_prefac_ec_lda, d_log_fac_ec_lda, d_denom_drs
real(double) :: t2, t4, t6
real(double) :: F1, F2, A, F3, F4, F6, ec_rs
real(double) :: A2, bg, bec, F5, F8, F9, h_A, h_rs, fact0, fact1, h_BT, h_RST, h_T, fact2, fact3, h_TT
! Precalculated constants
real(double), parameter :: prefac_ex = -three_quarters * (3/pi)**third
real(double), parameter :: k02 = -0.062182_double ! -2*A
real(double), parameter :: k03 = -0.0132882934_double ! -2*A*alpha1
real(double), parameter :: k04 = 0.4723158174_double ! 2*A*beta1
real(double), parameter :: k05 = 0.2230841432_double ! 2*A*beta2
real(double), parameter :: k06 = 0.1018665524_double ! 2*A*beta3
real(double), parameter :: k07 = 0.03065199508_double ! 2*A*beta4
real(double), parameter :: k08 = -0.008858862267_double ! 2*k03/3
real(double), parameter :: k09 = 0.0787193029_double ! k04/6
real(double), parameter :: k10 = 0.074361381067_double ! k05/3
real(double), parameter :: k11 = 0.0509332762_double ! k06/2
real(double), parameter :: k12 = 0.0204346633867_double ! 2*k07/3
real(double), parameter :: beta = 0.066725_double
real(double), parameter :: gamma = 0.031091_double
real(double), parameter :: beta_gamma = 2.146119_double ! beta/gamma
sq_rs = sqrt(rs)
! Local correlation energy Eq 10 PRB 45, 13244
prefac_ec_lda = k02 + k03*rs
denominator = sq_rs * ( k04 + sq_rs * ( k05 + sq_rs * ( k06 + k07 * sq_rs)))
if (denominator > zero) then
log_fac_ec_lda = log( one + one/denominator )
else
log_fac_ec_lda = 0
end if
ec_unif = prefac_ec_lda * log_fac_ec_lda
! Non-local correlation energy
! Original Conquest routines adapted from PRL 77 3865 and PRB 45 13244
F1 = ec_unif / gamma ! -PON
F2 = exp(-F1)
! This is the variable A from the PBE paper Eq 8, NOT the constant in PW92 !
A = beta_gamma / (F2 - one + RD_ERR) ! B in Burke's code
t2 = t*t
t4 = t2*t2
F3 = t2 + A * t4 ! Q5 = 1+A*F3 in Burke; Q4 * t2 = F3 in Burke
F6 = one + A * F3 !Q5
F4 = beta_gamma * F3 / F6 !(one + A * F3)
! Eq 7 with phi = 1, atomic units
h = gamma * log(one + F4)
! Local correlation potential
! ECRS - dec_drs for LDA from PW92 Appendix A
! rtrs == sq_rs
! Q0 == prefac_ec_lda
! Q1 == denominator
! Q2 == log_fac_ec_lda
! Q3 = A*(B1/rtrs + two*B2 + rtrs*(three*B3 + four*B4*rtrs))
! = half*sq_rs*(2A*B1 + 2*2A*B2*sq_rs + 3*2A*B3*rs + 4*2A*B4*rs*sq_rs )/rs
! = half*(k04 + sq_rs*(two*k05 + sq_rs*(three*k06 + four*k07*sq_rs)))/sq_rs
! dec_drs = -2A * A1 * Q2 - Q0 * Q3 /(Q1*(one + Q1))
d_denom_drs = half * (k04 + sq_rs * ( two * k05 + sq_rs * ( three * k06 + four * k07 * sq_rs)))/sq_rs
ec_rs = k03 * log_fac_ec_lda - prefac_ec_lda * d_denom_drs / (denominator * (one + denominator))
vc_unif = ec_unif - rs * third * ec_rs
! Non-local correlation potential
t6 = t2*t4
! In Burke's routines,
! delt = beta/gamma which is beta_gamma here
! G is one if non-spin; F is zero if non-spin
! Q4 = 1 + A * t2
! GZ = zero if non-spin, as are FZ and ECZET
A2 = A*A
bg = -three * A2 * ec_unif * F2/beta
bec = A2*F2/beta
F5 = one + A * t2 !Q4
F8 = F6 * F6 + beta_gamma * F5 * F6 * t2! Q8
F9 = one + two * A * t2 ! Q9
h_A = -beta * A * t6 * (two + A * t2) / F8
h_rs = -third * rs * h_A * bec * ec_rs
fact0 = two*beta_gamma - six * A ! FACT0
fact1 = F6 * F9 + F5 * F9 * F9 ! FACT1 = Q5*Q9+Q4*Q9*Q9
h_BT = two * beta * t4 * (F5 * F6 * fact0 - beta_gamma * fact1)/(F8 * F8)
h_RST = third * rs * t2 * h_BT * bec * ec_rs ! RSTHRD*T2*hBT*BEC*ECRS
h_T = two * beta * F9/F8 !2.d0*BET*G3*Q9/Q8
fact2 = F5 * F6 + A * t2 * (F5 * F9 + F6) !FACT2 = Q4*Q5+B*T2*(Q4*Q9+Q5)
fact3 = two * A * F6 * F9 + beta_gamma * fact2 !FACT3 = 2.D0*B*Q5*Q9+DELT*FACT2
h_TT = four * beta * t * (two * A - F9*fact3/F8)/F8 !hTT = 4.D0*BET*G3*T*(2.D0*B/Q8-(Q9*FACT3/Q8)/Q8)
! Derivative wrt n (I'm pretty sure)
dvc = H + h_rs + h_RST + t2 * h_t / six + seven * t2 * t * h_TT / six !COMM = H+HRS+HRST+T2*HT/6.D0+7.D0*T2*T*HTT/6.D0
! Derivative wrt grad n (again, I'm pretty sure)
dvc = dvc - u * h_TT - v * h_T !COMM = COMM-PREF*ZET-UU*HTT-VV*HT-WW*(HZT-FACT5)
! These are Conquest lines which I will adapt and use to tidy the mess above later !
! Correlation
! (derivative of rho * e_correlation)
! NOTE: d_prefac_ec_lda is actually the derivative of rho*prefac_ec_lda
! d_log_fac_ec_lda is rho times the derivative of log_fac_ec_lda
!d_prefac_ec_lda = k02 + k08*rs
!if (sq_rs > zero) then
! d_log_fac_ec_lda = &
! sq_rs * (k09 + sq_rs*(k10 + sq_rs*(k11 + k12 * sq_rs))) / &
! (denominator * (1 + denominator))
!else
! d_log_fac_ec_lda = 0
!end if
!vc = d_prefac_ec_lda * log_fac_ec_lda + prefac_ec_lda * d_log_fac_ec_lda
!if (present(drhoEps_c)) then
! drs_drho = - (third * rs / rho_tot_r)
! dkF_drho = third * kF / rho_tot_r
! dks_drho = half * ks * dkF_drho / kF
! deps_c_unif_drho = (Vc_unif(1) - eps_c_unif) / rho_tot_r
! dt_drho = (- t) * (dks_drho / ks + one / rho_tot_r)
! ! add RD_ERR to denominator to avoid div by 0
! dF1_drho = F1 * (deps_c_unif_drho / (eps_c_unif + RD_ERR))
! dF2_Drho = (- F2) * dF1_drho
! ! add RD_ERR to denominator to avoid div by 0
! dA_drho = A * dF2_drho / (one - F2 + RD_ERR)
! dF3_drho = (two * t + four * A * t**3) * dt_drho + dA_drho * t**4
! dF4_drho = F4 * (dF3_drho / F3 - &
! (dA_drho * F3 + A * DF3_drho) / (one + A * F3))
!
! dH_drho = gamma * DF4_drho / (one + F4)
!
! ! get drhoEps_c / drho(spin)
! drhoEps_c(0,1) = Vc_unif(1) + H + rho_tot_r * dH_drho
! do ii = 1, 3
! dt_dgrho = (t / mod_grho_tot_r) * grho_tot_r(ii) / mod_grho_tot_r
! dF3_dgrho = dt_dgrho * (two * t + four * A * t**3)
! dF4_dgrho = F4 * dF3_dgrho * (one / F3 - A / (one + A * F3))
! dH_dgrho = gamma * dF4_dgrho / (one + F4)
! drhoEps_c(ii,1) = rho_tot_r * dH_dgrho
! end do
!end if ! present(drhoEps_c)
end subroutine pbe_corr
end module radial_xc
| tools/BasisGeneration/radial_xc_LibXC_v4_module.f90 |
!this module is use to solve the three diag matrix Ax=b
MODULE threediag_mod
IMPLICIT NONE
PUBLIC threediag
CONTAINS
SUBROUTINE threediag(n,a,b,c,d,x)
INTEGER(4),INTENT(IN)::n
REAL(8),DIMENSION(:),INTENT(IN)::a(n),b(n),c(n),d(n)
REAL(8),DIMENSION(:),INTENT(INOUT)::x(n)
REAL(8),ALLOCATABLE::y(:),u(:),l(:)
INTEGER(4)::i
ALLOCATE(y(n))
ALLOCATE(u(n))
ALLOCATE(l(n))
x=0
y=0
u=0
l=0
u(1)=b(1)
y(1)=d(1)
DO i=2,n
l(i)=a(i)/u(i-1)
u(i)=b(i)-l(i)*c(i-1)
y(i)=d(i)-l(i)*y(i-1)
END DO
x(n)=y(n)/u(n)
DO i=n-1,1,-1
x(i)=(y(i)-c(i)*x(i+1))/u(i)
END DO
DEALLOCATE(y)
DEALLOCATE(u)
DEALLOCATE(l)
END SUBROUTINE
END MODULE | CSI/src/threediag_mod.f90 |
program pingpong
! An MPI program to send a message back and forth between two ranks
! using a blocking send mpi_send(), and a blocking
! recieve mpi_recv().
use mpi
implicit none
integer, parameter :: nexchange = 100
integer :: ifail
integer :: rank, size
! Message information (here type MPI_INTEGER)
integer :: sender, recver
integer :: sendbuffer, recvbuffer
integer, dimension(MPI_STATUS_SIZE) :: status
integer, parameter :: my_tag = 9999
! loop counter
integer :: n
call mpi_init(ifail)
call mpi_comm_rank(MPI_COMM_WORLD, rank, ifail)
call mpi_comm_size(MPI_COMM_WORLD, size, ifail)
if (size /= 2) then
write (unit = *, fmt = *) "Must use exactly two MPI tasks"
call mpi_abort(MPI_COMM_WORLD, -1, ifail)
end if
! The message is fixed
sendbuffer = 1
do n = 1, nexchange
! The sender and recver alternate between rank 0 and 1
sender = mod(n, 2)
recver = 1 - sender
if (rank == sender) then
call mpi_send(sendbuffer, 1, MPI_INTEGER, recver, my_tag, &
MPI_COMM_WORLD, ifail)
else
call mpi_recv(recvbuffer, 1, MPI_INTEGER, sender, my_tag, &
MPI_COMM_WORLD, status, ifail)
end if
end do
call mpi_finalize(ifail)
end program pingpong
| Solutions/fortran/ex2-pingpong/pingpong.f90 |
module write_data
implicit none
contains
!--------------------------------------
subroutine write_header()
use M_strings
!--------------------------------------
! The current solution is only for Linux
! as it binds Fortran with Linux shell
! The more appropriate would be connect
! Fortran with C/C++ or Python
!--------------------------------------
implicit none
character(len=120) :: line
character(len=32) :: username
character(len=120), allocatable :: array(:)
integer :: date(8)
write(66, 10)
call system('uname -a > _tmp')
open(unit=1,file='_tmp')
read(1,'(A)') line
close(1)
call system('rm _tmp')
call split(line,array)
call getlog(username)
write(66, '(1X,A,15X,A)') 'User: ',username
write(66, '(1X,A,15X,A,/,1X,A,13X,A,1X,/,1X,A,2X,A)') 'Host: ',array(2),'System: ',trim(array(15)),&
'Hardware platform: ',array(13)
call date_and_time(values=date)
!***************************** Now print them to the output file
write(66,'(1X,A,6X,I4,5(A,I2.2))') 'Date and time :', &
date(1), '/', date(2), '/', date(3), ' ', date(5), ':', &
date(6), ':', date(7)
write(66, 12)
write(66, 13)
10 format(/,4X,'*******************************************************', &
/4X,'~~~~~~~ Effective Hessian: part of NAST package ~~~~~~~', &
/4X,' ~~~~~ v. 2021.1 ~~~~~ ', &
/4X,'*******************************************************',/)
11 format('A')
12 format(/,/,1X,' Effective Hessian is experimental code to construct effective Hessian matrix', &
/,1X,' at the minimum energy crossing point (MECP) of the reaction at study.', &
/,1X,' Working equations and the theory behind them can be found in the NAST manual,', &
/,1X,' distributed with the package.', &
/,1X,' As program distributed free of charge, there is no warranty implied.', &
/,1X,' The code distribution is not allowed without written permission from the authors.')
13 format(/,/,1X,'Authors in alphabetical order:',&
/,1X,'-------------------------------------------------------------', &
/,1X,'Ilya D. Dergachev, University of Nevada, Reno',&
/,1X,'Vsevolod D. Dergachev, University of Nevada, Reno',&
/,1X,'Aleksandr O. Lykhin, University of Nevada, Reno',&
/,1X,'Robert Mauban, University of Nevada, Reno',&
/,1X,'Mitra Rooein, University of Nevada, Reno',&
/,1X,'Sergey A. Varganov University of Nevada, Reno',&
/1X,'-------------------------------------------------------------',/)
end subroutine write_header
!-----------------------------------------------------------------------------------------------
subroutine write_output(input)
use hess_data
!-----------------------------------------------------------------------------------------------
implicit none
character(len=*), intent(in) :: input
integer :: i
double precision :: zpe
!------------------------------------------------------------------------------------------------
write(66,12) trim(input)
!~~~ Write symbols, charges and Cartesian coordinates
write(66,'(/,A,/)') 'Coordinates (bohr):'
do I = 1, number_of_atoms
write(66,13) symbol(i),charge(i),coord(i,1), &
coord(i,2),coord(i,3)
end do
!~~~ Write data
write(66,'(/,A)') ' Effective Hessian data '
write(66,14) gradmean, norm_deltaG
write(66,15) norm_grad1, norm_grad2, lambda
write(66,16) gradslope, intersect_type
write(66,'(/,A,/)') 'Parallel gradient: '
do i = 1, number_of_atoms
write(66,17) symbol(i),charge(i), &
deltaG(i*3-2),deltaG(i*3-1), &
deltaG(i*3)
end do
write(66,'(/,A,/)') 'Principal moments of inertia (amu*bohr**2)'
write(66,18) moments_eig(1), moments_eig(2), moments_eig(3)
write(66,'(/,A,10X,A,/)') 'Frequency (cm-1)', 'Reduced mass (amu)'
zpe = 0.0d0
do i = 1, 3*number_of_atoms
if ( e(i) > 0 .and. freq(i) > 1d-3) then
write(66,19) freq(i), reduced_mass(i)
zpe = zpe + freq(i)
else if ( e(i) < 0 .and. freq(i) > 1d-3) then
write(66,19) -freq(i), reduced_mass(i)
else
write(66,19) 0.0d0, reduced_mass(i)
end if
end do
write(66,'(/,a,1x,f10.7)') 'Reduced mass along the RC (amu):',reduced_mass_rc
zpe = zpe/2 ! final ZPE in wavenumbers
zpe = zpe*0.002859144 ! final ZPE in kcal/mol
write(66,'(/,a,1x,f12.3)') 'zpe in kcal mol-1:',zpe
write(66,'(/,a)') 'Effective Hessian terminated normally.'
!================= FORMATTING OPTIONS ====================!
12 FORMAT(/,'Opening the ',A,' input file')
13 FORMAT(A10,4X,F4.1,3X,F12.9,3X,F12.9,4X,F12.9)
14 FORMAT(/,'Gradmean = ',ES16.9,/,'Norm of parallel gradient = ',ES16.9)
15 FORMAT('Norm of low-spin gradient = ',ES16.9,/,'Norm of high-spin gradient = ',ES16.9, &
/,'Lambda = ',E13.6)
16 FORMAT('Gradients dot product = ',ES16.9,' indicates ',A,' intersection')
17 FORMAT(A8,' ',F3.0,' ',ES17.10,' ',ES17.10,' ',ES17.10)
18 FORMAT(2X,F14.9,1X,F14.9,1X,F14.9)
19 FORMAT(2X,F7.2,20X,F10.7)
end subroutine write_output
!-------------------------------------------------------------------------------
subroutine write_nast_template(input)
use hess_data
implicit none
character(len=*), intent(in) :: input
integer :: i
!--------------------------------------------
open(unit = 44,access='stream',form='formatted',action = "write", file = input)
! Write heading to the output file
write(44,10)
write(44,11)
write(44,55) pack(int(freq),freq > 1d-3)
write(44,'(A,3f16.5)') 'inertX=',moments_eig
write(44,12) reduced_mass_rc, norm_deltaG, gradmean
55 format('freR = ',/,'freX = ',400i5)
10 format('!This is an NAST template input file automatically ',&
'genereated by the Effective Hessian code.',&
/,'!The file contains the MECP part of NAST input.',&
' Check NAST manual to finish the input file.')
11 format(/,"&keys",1x,"zpe=1",1x,"&end",/,&
/,"&inputdata")
12 format("inertR = ",/,"enX = ",1x,"enR = ",/,&
"redmass = ",f10.5,1x,"soc = ",/,"grad = ",f11.6,1x,&
"gradmean = ",f11.6,/,"maxn = 10000",/,"&end")
end subroutine write_nast_template
!-----------------------------------
end module
| tools/effhess/source/write.f90 |
!
! Parallel Sparse BLAS version 3.5
! (C) Copyright 2006, 2010, 2015, 2017
! Salvatore Filippone Cranfield University
! Alfredo Buttari CNRS-IRIT, Toulouse
!
! Redistribution and use in source and binary forms, with or without
! modification, are permitted provided that the following conditions
! are met:
! 1. Redistributions of source code must retain the above copyright
! notice, this list of conditions and the following disclaimer.
! 2. Redistributions in binary form must reproduce the above copyright
! notice, this list of conditions, and the following disclaimer in the
! documentation and/or other materials provided with the distribution.
! 3. The name of the PSBLAS group or the names of its contributors may
! not be used to endorse or promote products derived from this
! software without specific written permission.
!
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
! ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS
! BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! POSSIBILITY OF SUCH DAMAGE.
!
!
!
!
!
!
! Takes a vector x from space map%p_desc_X and maps it onto
! map%p_desc_Y under map%map_X2Y possibly with communication
! due to exch_fw_idx
!
subroutine psb_c_map_X2Y(alpha,x,beta,y,map,info,work)
use psb_base_mod, psb_protect_name => psb_c_map_X2Y
implicit none
type(psb_clinmap_type), intent(in) :: map
complex(psb_spk_), intent(in) :: alpha,beta
complex(psb_spk_), intent(inout) :: x(:)
complex(psb_spk_), intent(out) :: y(:)
integer(psb_ipk_), intent(out) :: info
complex(psb_spk_), optional :: work(:)
!
complex(psb_spk_), allocatable :: xt(:), yt(:)
integer(psb_ipk_) :: i, j, nr1, nc1,nr2, nc2,&
& map_kind, nr, ictxt
character(len=20), parameter :: name='psb_map_X2Y'
info = psb_success_
if (.not.map%is_asb()) then
write(psb_err_unit,*) trim(name),' Invalid map input: unassembled'
info = 1
return
end if
map_kind = map%get_kind()
select case(map_kind)
case(psb_map_aggr_)
ictxt = map%p_desc_Y%get_context()
nr2 = map%p_desc_Y%get_global_rows()
nc2 = map%p_desc_Y%get_local_cols()
allocate(yt(nc2),stat=info)
if (info == psb_success_) call psb_halo(x,map%p_desc_X,info,work=work)
if (info == psb_success_) call psb_csmm(cone,map%map_X2Y,x,czero,yt,info)
if ((info == psb_success_) .and. psb_is_repl_desc(map%p_desc_Y)) then
call psb_sum(ictxt,yt(1:nr2))
end if
if (info == psb_success_) call psb_geaxpby(alpha,yt,beta,y,map%p_desc_Y,info)
if (info /= psb_success_) then
write(psb_err_unit,*) trim(name),' Error from inner routines',info
info = -1
end if
case(psb_map_gen_linear_)
ictxt = map%desc_Y%get_context()
nr1 = map%desc_X%get_local_rows()
nc1 = map%desc_X%get_local_cols()
nr2 = map%desc_Y%get_global_rows()
nc2 = map%desc_Y%get_local_cols()
allocate(xt(nc1),yt(nc2),stat=info)
xt(1:nr1) = x(1:nr1)
if (info == psb_success_) call psb_halo(xt,map%desc_X,info,work=work)
if (info == psb_success_) call psb_csmm(cone,map%map_X2Y,xt,czero,yt,info)
if ((info == psb_success_) .and. psb_is_repl_desc(map%desc_Y)) then
call psb_sum(ictxt,yt(1:nr2))
end if
if (info == psb_success_) call psb_geaxpby(alpha,yt,beta,y,map%desc_Y,info)
if (info /= psb_success_) then
write(psb_err_unit,*) trim(name),' Error from inner routines',info
info = -1
end if
case default
write(psb_err_unit,*) trim(name),' Invalid descriptor input', &
& map_kind, psb_map_aggr_, psb_map_gen_linear_
info = 1
return
end select
end subroutine psb_c_map_X2Y
subroutine psb_c_map_X2Y_vect(alpha,x,beta,y,map,info,work,vtx,vty)
use psb_base_mod, psb_protect_name => psb_c_map_X2Y_vect
implicit none
type(psb_clinmap_type), intent(in) :: map
complex(psb_spk_), intent(in) :: alpha,beta
type(psb_c_vect_type), intent(inout) :: x,y
integer(psb_ipk_), intent(out) :: info
complex(psb_spk_), optional :: work(:)
type(psb_c_vect_type), optional, target, intent(inout) :: vtx,vty
! Local
type(psb_c_vect_type), target :: xt, yt
type(psb_c_vect_type),pointer :: ptx, pty
complex(psb_spk_), allocatable :: xta(:), yta(:)
integer(psb_ipk_) :: i, j, nr1, nc1,nr2, nc2 ,&
& map_kind, nr, ictxt, iam, np
character(len=20), parameter :: name='psb_map_X2Yv'
info = psb_success_
if (.not.map%is_asb()) then
write(psb_err_unit,*) trim(name),' Invalid map input: unassembled'
info = 1
return
end if
map_kind = map%get_kind()
select case(map_kind)
case(psb_map_aggr_)
ictxt = map%p_desc_Y%get_context()
call psb_info(ictxt,iam,np)
nr2 = map%p_desc_Y%get_global_rows()
nc2 = map%p_desc_Y%get_local_cols()
if (present(vty)) then
pty => vty
else
call psb_geasb(yt,map%p_desc_Y,info,scratch=.true.,mold=x%v)
pty => yt
end if
if (info == psb_success_) call psb_halo(x,map%p_desc_X,info,work=work)
if (info == psb_success_) call psb_csmm(cone,map%map_X2Y,x,czero,pty,info)
if ((info == psb_success_) .and. map%p_desc_Y%is_repl().and.(np>1)) then
yta = pty%get_vect()
call psb_sum(ictxt,yta(1:nr2))
call pty%set(yta)
end if
if (info == psb_success_) call psb_geaxpby(alpha,pty,beta,y,map%p_desc_Y,info)
if (info /= psb_success_) then
write(psb_err_unit,*) trim(name),' Error from inner routines',info
info = -1
else
if (.not.present(vty)) call yt%free(info)
end if
case(psb_map_gen_linear_)
ictxt = map%desc_Y%get_context()
call psb_info(ictxt,iam,np)
nr1 = map%desc_X%get_local_rows()
nc1 = map%desc_X%get_local_cols()
nr2 = map%desc_Y%get_global_rows()
nc2 = map%desc_Y%get_local_cols()
if (present(vtx).and.present(vty)) then
ptx => vtx
pty => vty
else
call psb_geasb(xt,map%desc_X,info,scratch=.true.,mold=x%v)
call psb_geasb(yt,map%desc_Y,info,scratch=.true.,mold=x%v)
ptx => xt
pty => yt
end if
call psb_geaxpby(cone,x,czero,ptx,map%desc_X,info)
if (info == psb_success_) call psb_halo(ptx,map%desc_X,info,work=work)
if (info == psb_success_) call psb_csmm(cone,map%map_X2Y,ptx,czero,pty,info)
if ((info == psb_success_) .and. map%desc_Y%is_repl().and.(np>1)) then
yta = pty%get_vect()
call psb_sum(ictxt,yta(1:nr2))
call pty%set(yta)
end if
if (info == psb_success_) call psb_geaxpby(alpha,pty,beta,y,map%desc_Y,info)
if (info /= psb_success_) then
write(psb_err_unit,*) trim(name),' Error from inner routines',info
info = -1
else
if (.not.(present(vtx).and.present(vty) )) then
call xt%free(info)
call yt%free(info)
end if
end if
case default
write(psb_err_unit,*) trim(name),' Invalid descriptor input', &
& map_kind, psb_map_aggr_, psb_map_gen_linear_
info = 1
return
end select
return
end subroutine psb_c_map_X2Y_vect
!
! Takes a vector x from space map%p_desc_Y and maps it onto
! map%p_desc_X under map%map_Y2X possibly with communication
! due to exch_bk_idx
!
subroutine psb_c_map_Y2X(alpha,x,beta,y,map,info,work)
use psb_base_mod, psb_protect_name => psb_c_map_Y2X
implicit none
type(psb_clinmap_type), intent(in) :: map
complex(psb_spk_), intent(in) :: alpha,beta
complex(psb_spk_), intent(inout) :: x(:)
complex(psb_spk_), intent(out) :: y(:)
integer(psb_ipk_), intent(out) :: info
complex(psb_spk_), optional :: work(:)
!
complex(psb_spk_), allocatable :: xt(:), yt(:)
integer(psb_ipk_) :: i, j, nr1, nc1,nr2, nc2,&
& map_kind, nr, ictxt
character(len=20), parameter :: name='psb_map_Y2X'
info = psb_success_
if (.not.map%is_asb()) then
write(psb_err_unit,*) trim(name),' Invalid map input: unassembled'
info = 1
return
end if
map_kind = map%get_kind()
select case(map_kind)
case(psb_map_aggr_)
ictxt = map%p_desc_X%get_context()
nr2 = map%p_desc_X%get_global_rows()
nc2 = map%p_desc_X%get_local_cols()
allocate(yt(nc2),stat=info)
if (info == psb_success_) call psb_halo(x,map%p_desc_Y,info,work=work)
if (info == psb_success_) call psb_csmm(cone,map%map_Y2X,x,czero,yt,info)
if ((info == psb_success_) .and. psb_is_repl_desc(map%p_desc_X)) then
call psb_sum(ictxt,yt(1:nr2))
end if
if (info == psb_success_) call psb_geaxpby(alpha,yt,beta,y,map%p_desc_X,info)
if (info /= psb_success_) then
write(psb_err_unit,*) trim(name),' Error from inner routines',info
info = -1
end if
case(psb_map_gen_linear_)
ictxt = map%desc_X%get_context()
nr1 = map%desc_Y%get_local_rows()
nc1 = map%desc_Y%get_local_cols()
nr2 = map%desc_X%get_global_rows()
nc2 = map%desc_X%get_local_cols()
allocate(xt(nc1),yt(nc2),stat=info)
xt(1:nr1) = x(1:nr1)
if (info == psb_success_) call psb_halo(xt,map%desc_Y,info,work=work)
if (info == psb_success_) call psb_csmm(cone,map%map_Y2X,xt,czero,yt,info)
if ((info == psb_success_) .and. psb_is_repl_desc(map%desc_X)) then
call psb_sum(ictxt,yt(1:nr2))
end if
if (info == psb_success_) call psb_geaxpby(alpha,yt,beta,y,map%desc_X,info)
if (info /= psb_success_) then
write(psb_err_unit,*) trim(name),' Error from inner routines',info
info = -1
end if
case default
write(psb_err_unit,*) trim(name),' Invalid descriptor input'
info = 1
return
end select
end subroutine psb_c_map_Y2X
subroutine psb_c_map_Y2X_vect(alpha,x,beta,y,map,info,work,vtx,vty)
use psb_base_mod, psb_protect_name => psb_c_map_Y2X_vect
implicit none
type(psb_clinmap_type), intent(in) :: map
complex(psb_spk_), intent(in) :: alpha,beta
type(psb_c_vect_type), intent(inout) :: x,y
integer(psb_ipk_), intent(out) :: info
complex(psb_spk_), optional :: work(:)
type(psb_c_vect_type), optional, target, intent(inout) :: vtx,vty
! Local
type(psb_c_vect_type), target :: xt, yt
type(psb_c_vect_type),pointer :: ptx, pty
complex(psb_spk_), allocatable :: xta(:), yta(:)
integer(psb_ipk_) :: i, j, nr1, nc1,nr2, nc2,&
& map_kind, nr, ictxt, iam, np
character(len=20), parameter :: name='psb_map_Y2Xv'
info = psb_success_
if (.not.map%is_asb()) then
write(psb_err_unit,*) trim(name),' Invalid map input: unassembled'
info = 1
return
end if
map_kind = map%get_kind()
select case(map_kind)
case(psb_map_aggr_)
ictxt = map%p_desc_X%get_context()
call psb_info(ictxt,iam,np)
nr2 = map%p_desc_X%get_global_rows()
nc2 = map%p_desc_X%get_local_cols()
if (present(vty)) then
pty => vty
else
call psb_geasb(yt,map%p_desc_X,info,scratch=.true.,mold=x%v)
pty => yt
end if
if (info == psb_success_) call psb_halo(x,map%p_desc_Y,info,work=work)
if (info == psb_success_) call psb_csmm(cone,map%map_Y2X,x,czero,pty,info)
if ((info == psb_success_) .and. map%p_desc_X%is_repl().and.(np>1)) then
yta = pty%get_vect()
call psb_sum(ictxt,yta(1:nr2))
call pty%set(yta)
end if
if (info == psb_success_) call psb_geaxpby(alpha,pty,beta,y,map%p_desc_X,info)
if (info /= psb_success_) then
write(psb_err_unit,*) trim(name),' Error from inner routines',info
info = -1
else
if (.not.present(vty)) call yt%free(info)
end if
case(psb_map_gen_linear_)
ictxt = map%desc_X%get_context()
call psb_info(ictxt,iam,np)
nr1 = map%desc_Y%get_local_rows()
nc1 = map%desc_Y%get_local_cols()
nr2 = map%desc_X%get_global_rows()
nc2 = map%desc_X%get_local_cols()
if (present(vtx).and.present(vty)) then
ptx => vtx
pty => vty
else
call psb_geasb(xt,map%desc_Y,info,scratch=.true.,mold=x%v)
call psb_geasb(yt,map%desc_X,info,scratch=.true.,mold=x%v)
ptx => xt
pty => yt
end if
call psb_geaxpby(cone,x,czero,ptx,map%desc_X,info)
if (info == psb_success_) call psb_halo(ptx,map%desc_Y,info,work=work)
if (info == psb_success_) call psb_csmm(cone,map%map_Y2X,ptx,czero,pty,info)
if ((info == psb_success_) .and. map%desc_X%is_repl().and.(np>1)) then
yta = pty%get_vect()
call psb_sum(ictxt,yta(1:nr2))
call pty%set(yta)
end if
if (info == psb_success_) call psb_geaxpby(alpha,pty,beta,y,map%desc_X,info)
if (info /= psb_success_) then
write(psb_err_unit,*) trim(name),' Error from inner routines',info
info = -1
else
if (.not.(present(vtx).and.present(vty) )) then
call xt%free(info)
call yt%free(info)
end if
end if
case default
write(psb_err_unit,*) trim(name),' Invalid descriptor input'
info = 1
return
end select
end subroutine psb_c_map_Y2X_vect
function psb_c_linmap(map_kind,desc_X, desc_Y, map_X2Y, map_Y2X,iaggr,naggr) &
& result(this)
use psb_base_mod, psb_protect_name => psb_c_linmap
implicit none
type(psb_clinmap_type) :: this
type(psb_desc_type), target :: desc_X, desc_Y
type(psb_cspmat_type), intent(inout) :: map_X2Y, map_Y2X
integer(psb_ipk_), intent(in) :: map_kind
integer(psb_ipk_), intent(in), optional :: iaggr(:), naggr(:)
!
integer(psb_ipk_) :: info
character(len=20), parameter :: name='psb_linmap'
info = psb_success_
select case(map_kind)
case (psb_map_aggr_)
! OK
if (psb_is_ok_desc(desc_X)) then
this%p_desc_X=>desc_X
else
info = psb_err_pivot_too_small_
endif
if (psb_is_ok_desc(desc_Y)) then
this%p_desc_Y=>desc_Y
else
info = psb_err_invalid_ovr_num_
endif
if (present(iaggr)) then
if (.not.present(naggr)) then
info = 7
else
allocate(this%iaggr(size(iaggr)),&
& this%naggr(size(naggr)), stat=info)
if (info == psb_success_) then
this%iaggr(:) = iaggr(:)
this%naggr(:) = naggr(:)
end if
end if
else
allocate(this%iaggr(0), this%naggr(0), stat=info)
end if
case(psb_map_gen_linear_)
if (desc_X%is_ok()) then
call psb_cdcpy(desc_X, this%desc_X,info)
else
info = psb_err_pivot_too_small_
endif
if (desc_Y%is_ok()) then
call psb_cdcpy(desc_Y, this%desc_Y,info)
else
info = psb_err_invalid_ovr_num_
endif
! For a general linear map ignore iaggr,naggr
allocate(this%iaggr(0), this%naggr(0), stat=info)
case default
write(psb_err_unit,*) 'Bad map kind into psb_linmap ',map_kind
info = 1
end select
if (info == psb_success_) call map_X2Y%clone(this%map_X2Y,info)
if (info == psb_success_) call map_Y2X%clone(this%map_Y2X,info)
if (info == psb_success_) then
call this%set_kind(map_kind)
end if
if (info /= psb_success_) then
write(psb_err_unit,*) trim(name),' Invalid descriptor input'
return
end if
end function psb_c_linmap
| base/tools/psb_c_map.f90 |
!!# COMMAND CARD SWITCHBOARD <<CCS_MoCshort>>
MODULE CCS_MoCshort
!!## PURPOSE
!! This is the command card switchboard for the
!! <MoCshort> (<MCS>) package.
!!## CHANGES
!! * v2.23 - ability to read in restart files, detailed angular flux at a given vert
!!## PARAMETER MODULES
USE PAR_MoCshort !!((03-A-PAR_MoCshort.f90))
!!## USER MODULES
USE USR_fdbk !!((08-C-USR_fdbk.f90))
USE USR_SBCharacteristics,ONLY: CWENO_eps,CWENO_order,CWENO_cwt,& !!((26-C-USR_SBCharacteristics.f90))
EdgeInterpolator,KEYS_EdgeInterpolator,&
KIND_qmc
USE USR_FunctionParser !!((05-B-USR_FunctionParser.f90))
USE USR_TransportAnalyticTest !!((56-C-USR_TransportAnalyticTest.f90))
USE USR_TransportAnalyticTest_WIESEL,ONLY: &
ANALYTIC_A,ANALYTIC_C,&
ANALYTIC_D1,ANALYTIC_DX,ANALYTIC_DY,&
ANALYTIC_BX,ANALYTIC_BY
!!## PROCEDURE MODULES
USE SUB_Pause !!((04-B-SUB_Pause.f90))
USE FUN_STR !!((05-B-FUN_STR.f90))
USE FUN_VSTR !!((05-B-FUN_VSTR.f90))
USE FUN_NewFile !!((05-B-FUN_NewFile.f90))
USE SUB_CLEAR !!((04-A-SUB_CLEAR.f90))
USE VAR_TAPACK !!((66-C-VAR_TAPACK.f90))
!!## CARD MODULES
USE CC1_simple,ONLY: & !!((11-A-CC1_simple.f90))
MCSorder =>simple , &
MCSonlygeometry=>simple , &
MCSinteractive =>simple , &
MCSmonotonic =>simple , &
MCSmonolin =>simple , &
MCSsourceorder =>simple , &
MCSsplitting =>simple , &
MCSinterpplane =>simple , &
MCSlogtransform=>simple , &
MCSjiggle =>simple , &
MCSnobacksies =>simple , &
MCSlongchar =>simple , &
MCSsbalance =>simple , &
MCSpackedcache =>simple , &
MCSmingamma =>simple , &
MCSsbedgeinterp=>simple , &
MCScellfunction=>simple , &
MCScache =>simple , &
MCSrestart =>simple , &
MCSdiscorner =>simple, &
MCSnonlinearfixup=>simple
!!## LIBRARY MODULES
USE LIB_Prompts !!((06-B-LIB_Prompts.f90))
USE LIB_GenericPhrases !!((07-B-LIB_GenericPhrases.f90))
!!## TOOLBOXES
USE TBX_SIO !!((10-A-TBX_SIO.f90))
USE TBX_Mesh !!((15-B-TBX_Mesh.f90))
!!## VARIABLE MODULES
USE VAR_MoCshort !!((47-B-VAR_MoCshort.f90))
USE VAR_Mesh !!((46-B-VAR_Mesh.f90))
!!## DEFAULT IMPLICIT
IMPLICIT NONE
!!## DEFAULT ACCESS
PRIVATE
!!## IDENTIFICATION
CHARACTER(*),PARAMETER :: mod_ = "CCS_MoCshort"
CHARACTER(*),PARAMETER :: file_ = "38-B-CCS_MoCshort.f90"
!!## PRE-CALCULATED COMMAND HASHES
INTEGER,PARAMETER :: bc_ = 0000000485
INTEGER,PARAMETER :: interactive_ = 0000386226
INTEGER,PARAMETER :: onlygeometry_ = 0000621844
INTEGER,PARAMETER :: order_ = 0000025877
INTEGER,PARAMETER :: sourceorder_ = 0000486944
INTEGER,PARAMETER :: monotonic_ = 0000213811
INTEGER,PARAMETER :: monolin_ = 0000083170
INTEGER,PARAMETER :: splitting_ = 0000226511
INTEGER,PARAMETER :: interpplane_ = 0000408702
INTEGER,PARAMETER :: explodefix_ = 0000293953
INTEGER,PARAMETER :: jiggle_ = 0000036443
INTEGER,PARAMETER :: logtransform_ = 0000571432
INTEGER,PARAMETER :: nobacksies_ = 0000245457
INTEGER,PARAMETER :: longchar_ = 0000122396
INTEGER,PARAMETER :: testlinsrc_ = 0000315033
INTEGER,PARAMETER :: checksym_ = 0000078274
INTEGER,PARAMETER :: sbalance_ = 0000104524
INTEGER,PARAMETER :: packedcache_ = 0000298670
INTEGER,PARAMETER :: mingamma_ = 0000113356
INTEGER,PARAMETER :: sbopts_ = 0000046721
INTEGER,PARAMETER :: sbedgeinterp_ = 0000442558
INTEGER,PARAMETER :: longpointlist_= 0000781759
INTEGER,PARAMETER :: cellfunction_ = 0000421224
INTEGER,PARAMETER :: nobalcheck_ = 0000245505
INTEGER,PARAMETER :: analyticwarsa_= 0000627403
INTEGER,PARAMETER :: rayinfo_ = 0000082732
INTEGER,PARAMETER :: analyticwiesel_=0000843363
INTEGER,PARAMETER :: cache_ =0000011111
INTEGER,PARAMETER :: options_ =0000091914
INTEGER,PARAMETER :: restart_ =0000082998
INTEGER,PARAMETER :: debugpsiv_ =0000131963
INTEGER,PARAMETER :: discorner_ =0000155473
INTEGER,PARAMETER :: nonlinearfixup_=0001010587
!!## ACCESS
PUBLIC :: SWITCHBOARD_MoCshort
!!## MODULE PROCEDURES
CONTAINS
!!### SWITCHBOARD SUBROUTINE: <SWITCHBOARD_MoCshort>
SUBROUTINE SWITCHBOARD_MoCshort( sio , Mesh , fdbk )
!!#### PURPOSE
!! The command card switchboard for the MoCshort package.
!!#### REQUIRED INPUT/OUTPUT
!! * input/output object <sio>
TYPE(TYPE_sio),POINTER :: sio
!!#### REQUIRED INPUT
TYPE(TYPE_Mesh),INTENT(IN) :: Mesh
!!#### OPTIONAL INPUT/OUTPUT
!! * feedback object <fdbk>
TYPE(TYPE_fdbk),OPTIONAL,INTENT(INOUT) :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_="SWITCHBOARD_MoCshort"
!!#### LOCAL VARIABLES
TYPE(varying_string) :: VS
!!--begin--
!pick routine to execute which loads some data
SELECTCASE(sio%HASH(2))
CASE(interactive_) ; CALL MCSinteractive ( sio , InteractiveAngularflux , fdbk )
CASE(order_) ; CALL MCSorder ( sio , InterpOrder , fdbk )
CASE(sourceorder_) ; CALL MCSsourceorder ( sio , SourceOrder , fdbk )
CASE(monolin_) ; CALL MCSmonolin ( sio , Using_MonoLin , fdbk )
CASE(splitting_) ; CALL MCSsplitting ( sio , Using_Splitting , fdbk )
CASE(onlygeometry_) ; CALL MCSonlygeometry( sio , OnlyGeometry , fdbk )
CASE(bc_) ; CALL MCSbc ( sio , Mesh , BC , FixedAngularFlux , fdbk )
CASE(monotonic_) ; CALL MCSmonotonic ( sio , Using_Monotonization , fdbk )
CASE(interpplane_) ; CALL MCSinterpplane ( sio , InterpPlaneU , fdbk ,KEYS=KEY_InterpPlane)
CASE(logtransform_) ; CALL MCSlogtransform( sio , Using_LogTransform , fdbk )
CASE(jiggle_) ; CALL MCSjiggle ( sio , Using_Jiggle , fdbk )
CASE(nobacksies_) ; CALL MCSnobacksies ( sio , Using_NoBacksies , fdbk )
CASE(explodefix_) ; CALL MCSexplodefix ( sio , Using_ExplodeFix , MIN_AngularFlux , MAX_AngularFlux , fdbk )
CASE(longchar_) ; CALL MCSlongchar ( sio , Using_LongCharacteristics , fdbk )
CASE(testlinsrc_) ; CALL MCStestlinsrc ( sio , Using_LinearSourceTest , Unit_LinearSourceTest , fdbk )
CASE(checksym_) ; CALL MCSchecksym ( sio , Mesh%Ndim , P1sym , P2sym , Unit_AFSymmetryCheck , fdbk )
CASE(sbalance_) ; CALL MCSsbalance ( sio , Using_SBCharacteristics , fdbk )
CASE(packedcache_) ; CALL MCSpackedcache ( sio , Using_PackedCaching , fdbk )
CASE(sbedgeinterp_) ; CALL MCSsbedgeinterp( sio , EdgeInterpolator,fdbk,KEYS=KEYS_EdgeInterpolator)
CASE(sbopts_) ; CALL MCSsbopts ( sio , CWENO_cwt, CWENO_order,CWENO_eps,fdbk)
CASE(longpointlist_) ; CALL MCSlongpointlist( sio , Mesh%NDim , Unit_LongChar , PointList_LongChar , fdbk )
CASE(cellfunction_) ; CALL MCScellfunction( sio , CellFunctionMethod , fdbk , KEYS=MCS_KEY_CellFunction )
CASE(nobalcheck_) ; CALL MCSnobalcheck ( sio , CHECKING_BALANCE , NO_BALANCE_MSG , fdbk )
CASE(analyticwarsa_) ; CALL MCSanalyticwarsa(sio , Using_AnalyticTransportTest , fdbk )
CASE(rayinfo_) ; CALL MCSrayinfo( sio , Print_RayEffectsInfo , rayeffectsfile , fdbk )
CASE(analyticwiesel_) ; CALL MCSanalyticwiesel(sio , Using_AnalyticTransportTest , fdbk )
CASE(cache_) ; CALL MCScache(sio,Using_Cache,fdbk)
CASE(options_) ; CALL MCSoptions(sio,Using_AF_ScaleFactor,fdbk)
CASE(restart_) ; CALL MCSrestart(sio,affile,fdbk)
CASE(debugpsiv_) ; CALL MCSdebugpsiv(sio,Mesh%Ndim,Unit_DebugPsiV , PointList_DebugPsiV,fdbk)
CASE(discorner_) ; CALL MCSdiscorner(sio,Allow_Discontinuous_Corners,fdbk)
CASE(nonlinearfixup_) ; CALL MCSnonlinearfixup( sio , NonlinearFixup , fdbk , &
KEYS=MCS_KEY_NonlinearFixup )
CASE DEFAULT
VS = COMMAND_NOT_RECOGNIZED(sio,mod_,proc_,"")
CALL UPDATE(fdbk_error,fdbk,s=STR(VS))
VS = ""
ENDSELECT
!!--end--
ENDSUBROUTINE
!!### CARD SUBROUTINE <<MCSnobalcheck>>
SUBROUTINE MCSnobalcheck( sio , CHECKING_BALANCE , NO_BALANCE_MSG , fdbk )
!!#### PURPOSE
!! Turn off balance equation checkings.
!!#### REQUIRED INPUT/OUTPUT
TYPE(TYPE_sio) ,POINTER :: sio
LOGICAL ,INTENT(INOUT) :: CHECKING_BALANCE
TYPE(varying_string) :: NO_BALANCE_MSG
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCSnobalcheck"
!!#### LOCAL VARIABLES
TYPE(varying_string) :: file
LOGICAL :: NoBalance
!!--begin--
IF( Writing(sio) )THEN
NoBalance = .NOT.CHECKING_BALANCE
END IF
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , (/"NoBalance" ,&
"MSG "/) , fdbk ,&
nsubarg =(/0 ,0 /) , &
optional=(/.FALSE.,.TRUE./) )
CALL ARGUMENT( sio , NoBalance , fdbk )
CALL ARGUMENT( sio , NO_BALANCE_MSG , fdbk , Default=VSTR("") )
CALL END_ARGUMENTS( sio , fdbk )
IF( Reading(sio) )THEN
CHECKING_BALANCE = .NOT.NoBalance
END IF
!!--end--
END SUBROUTINE
!!### CARD SUBROUTINE <<MCSoptions>>
SUBROUTINE MCSoptions( sio , &
Using_AF_ScaleFactor , fdbk )
!!#### PURPOSE
!! General option passer
!!#### REQUIRED INPUT/OUTPUT
TYPE(TYPE_sio) ,POINTER :: sio
LOGICAL ,INTENT(INOUT) :: Using_AF_ScaleFactor
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCSoptions"
!!#### LOCAL VARIABLES
TYPE(varying_string) :: file
!!--begin--
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , (/"Using_AF_ScaleFactor"/) , fdbk ,&
nsubarg =(/0/) , &
optional=(/.TRUE./) )
CALL ARGUMENT( sio , Using_AF_ScaleFactor , fdbk, Default=Using_AF_ScaleFactor )
CALL END_ARGUMENTS( sio , fdbk )
!!--end--
END SUBROUTINE MCSoptions
!!### CARD SUBROUTINE: <MCSbc>
SUBROUTINE MCSbc( sio , Mesh , BC , FixedAngularFlux , fdbk )
!!#### PURPOSE
!! Read in boundary condition information for the domain.
!!#### REQUIRED INPUT/OUTPUT
!! * boundary conditions <BC>
!! * values for fixed angular fluxes at each boundary <FixedAngularFlux>
TYPE(TYPE_sio),POINTER :: sio
INTEGER ,POINTER :: BC(:)
REAL(KIND_MCs),POINTER :: FixedAngularFlux(:)
!!#### REQUIRED INPUT
TYPE(TYPE_Mesh),INTENT(IN) :: Mesh
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCSbc"
!!#### LOCAL VARIABLES
INTEGER :: i
TYPE(varying_string) :: VS
REAL(KIND_MCs) :: fixedval(1)
CHARACTER(255) :: fixedstr(1),error1
TYPE(varying_string) :: varstr(1)
!!--begin--
IF( IsQr(Mesh%domain%DomainShape) )THEN
!! Setup.
IF( Reading(sio) )ALLOCATE( BC(1:6) )
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , (/"b-r-t-l","u-d "/) , fdbk ,&
nsubarg=(/4,2/) ,&
optional=(/.FALSE.,.TRUE./))
CALL ARGUMENT( sio , BC(1:4) , fdbk , Keys=KEY_BC )
CALL ARGUMENT( sio , BC(5:6) , fdbk , Keys=KEY_BC , Default=(/1,1/) )
CALL END_ARGUMENTS( sio , fdbk )
!! Conditional Datablock.
ALLOCATE( FixedAngularFlux(4) , FunctionAngularFlux(4) )
CALL CLEAR(FixedAngularFlux)
CALL CLEAR(FunctionAngularFlux)
!! Go through the domain boundaries.
DO i=1,4
!boundary conditions are fixed
IF( BC(i)==fixed_ .OR. BC(i)==planewave_ )THEN
CALL DATABLOCK(sio,fixedval,fdbk)
FixedAngularFlux(i) = fixedval(1)
!a function is provided to evaluate boundary conditions
ELSE IF( BC(i)==function_ )THEN
CALL DATABLOCK(sio,varstr,fdbk)
fixedstr(1)=varstr(1)
call s_createfn(fixedstr(1), 'x y z ox oy oz m', &
FunctionAngularFlux(i), error1)
IF( TRIM(error1)/="OK" )THEN
VS = MODPROC(mod_,proc_)//"the submitted function <"//&
TRIM(fixedstr(1))//"> produced the error message "//&
"<"//TRIM(error1)//">."
CALL UPDATE(fdbk_error,fdbk,s=STR(VS))
END IF
END IF
END DO
!! Wrapup.
IF( Writing(sio) )DEALLOCATE( BC )
ELSE
VS = MODPROC(mod_,proc_)//"the boundary conditions are only &
&available for a rectangular domain!"
CALL UPDATE(fdbk_error,fdbk,s=STR(VS))
VS = ""
END IF
!!--end--
END SUBROUTINE
!!### CARD SUBROUTINE: <MCSexplodefix>
SUBROUTINE MCSexplodefix( sio , Using_ExplodeFix , MIN_AngularFlux , MAX_AngularFlux , fdbk )
!!#### PURPOSE
!! Read/write angular flux limits (min/max) for any transport simulation.
!!#### REQUIRED INPUT/OUTPUT
!! * whether to use or not <Using_ExplodeFix>
!! * minimum and maximum for angular fluxes <MIN_AngularFlux,MAX_AngularFlux>
TYPE(TYPE_sio),POINTER :: sio
LOGICAL ,INTENT(INOUT) :: Using_ExplodeFix
REAL(KIND_MCs),INTENT(INOUT) :: MIN_AngularFlux,MAX_AngularFlux
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCSexplodefix"
!!#### LOCAL VARIABLES
REAL(KIND_MCs) :: l(2)
!!--begin--
!! Setup.
IF( Writing(sio) )THEN
l(1) = MIN_AngularFlux
l(2) = MAX_AngularFlux
END IF
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , (/"Using_ExplodeFix ",&
"RANGE_AngularFlux"/) , fdbk ,&
nsubarg=(/0,2/) ,&
optional=(/.FALSE.,.FALSE./))
CALL ARGUMENT( sio , Using_ExplodeFix , fdbk )
CALL ARGUMENT( sio , l , fdbk )
CALL END_ARGUMENTS( sio , fdbk )
!! Wrapup.
IF( Reading(sio) )THEN
MIN_AngularFlux = l(1)
MAX_AngularFlux = l(2)
END IF
!!--end--
END SUBROUTINE
!!### CARD SUBROUTINE: <MCSsbopts>
SUBROUTINE MCSsbopts( sio , CWENO_cwt , CWENO_order , CWENO_eps , fdbk )
!!#### PURPOSE
!! Handle some options for the subcell balance routines.
!!#### REQUIRED INPUT/OUTPUT
TYPE(TYPE_sio),POINTER :: sio
REAL(KIND_qmc),INTENT(INOUT) :: CWENO_cwt
INTEGER ,INTENT(INOUT) :: CWENO_order
REAL(KIND_qmc),INTENT(INOUT) :: CWENO_eps
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCSsbopts"
!!#### LOCAL VARIABLES
REAL(KIND_MCs) :: l(2)
!!--begin--
!! Setup.
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , (/"CWENO_cwt ",&
"CWENO_order",&
"CWENO_eps "/), fdbk ,&
nsubarg=(/0,0,0/) ,&
optional=(/.TRUE.,.TRUE.,.TRUE./) )
CALL ARGUMENT( sio , CWENO_cwt , fdbk , Default=CWENO_cwt )
CALL ARGUMENT( sio , CWENO_order , fdbk , Default=CWENO_order )
CALL ARGUMENT( sio , CWENO_eps , fdbk , Default=CWENO_eps )
CALL END_ARGUMENTS( sio , fdbk )
!! Wrapup.
!!--end--
END SUBROUTINE
!!### CARD SUBROUTINE: <MCStestlinsrc>
SUBROUTINE MCStestlinsrc( sio , Using_LinearSourceTest , Unit_LinearSourceTest , fdbk )
!!#### PURPOSE
!! Test a linear source (has specific requirements on cross sections, bc, etc.)
!! See <EXACT_Psi_LinSrc> for details.
!!#### REQUIRED INPUT/OUTPUT
!! * using a linear source test <Using_LinearSourceTest>
!! * the unit to write columns of data to <Unit_LinearSourceTest>
TYPE(TYPE_sio),POINTER :: sio
LOGICAL ,INTENT(INOUT) :: Using_LinearSourceTest
INTEGER ,INTENT(INOUT) :: Unit_LinearSourceTest
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCStestlinsrc"
!!#### LOCAL VARIABLES
TYPE(varying_string) :: file
!!--begin--
!! Setup.
!IF( Writing(sio) )THEN
!END IF
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , (/"UseLinSrc",&
"file "/) , fdbk ,&
nsubarg=(/0,0/) ,&
optional=(/.FALSE.,.TRUE./))
CALL ARGUMENT( sio , Using_LinearSourceTest , fdbk )
CALL ARGUMENT( sio , file , fdbk , Default=VSTR("") )
CALL END_ARGUMENTS( sio , fdbk )
!! Wrapup.
IF( Reading(sio) )THEN
IF( file/="" )THEN
Unit_LinearSourceTest = NewFile(file)
ELSE
Unit_LinearSourceTest = 0
END IF
END IF
!!--end--
END SUBROUTINE
!!### CARD SUBROUTINE <<MCSchecksym>>
SUBROUTINE MCSchecksym( sio , NDim , P1sym , P2sym , Unit_AFSymmetryCheck , fdbk )
!!#### PURPOSE
!! Test for symmetry in the angular flux.
!!#### REQUIRED INPUT/OUTPUT
!! * number of dimensions <NDim>
!! * first point to define symmetry plane <P1sym>
!! * second point to define symmetry plane <P2sym>
!! * the unit to write to <Unit_AFSymmetryCheck>
INTEGER ,INTENT(IN) :: NDim
TYPE(TYPE_sio),POINTER :: sio
REAL(KIND_MSH),INTENT(INOUT) :: P1sym(NDim),P2sym(NDim)
INTEGER ,INTENT(INOUT) :: Unit_AFSymmetryCheck
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCSchecksym"
!!#### LOCAL VARIABLES
TYPE(varying_string) :: file
!!--begin--
!! Setup.
!IF( Writing(sio) )THEN
!END IF
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , (/"P1sym","P2sym","file "/) , fdbk ,&
nsubarg=(/NDim,NDim,0/) ,&
optional=(/.FALSE.,.FALSE.,.TRUE./))
CALL ARGUMENT( sio , P1sym , fdbk )
CALL ARGUMENT( sio , P2sym , fdbk )
CALL ARGUMENT( sio , file , fdbk , Default=VSTR("") )
CALL END_ARGUMENTS( sio , fdbk )
!! Wrapup.
IF( Reading(sio) )THEN
Using_AFSymmetryCheck = .TRUE.
IF( file/="" )THEN
Unit_AFSymmetryCheck = NewFile(file)
ELSE
Unit_AFSymmetryCheck = 0
END IF
END IF
!!--end--
END SUBROUTINE
!!### CARD SUBROUTINE <<MCSanalyticwarsa>>
SUBROUTINE MCSanalyticwarsa( sio , USING_Test , fdbk )
!!#### PURPOSE
!! Read in parameters for an analytic test devised by Jim Warsa in a 2008 Nuclear
!! Science and Engineering Technical Note (160, 385-400).
!!#### REQUIRED INPUT/OUTPUT
TYPE(TYPE_sio),POINTER :: sio
LOGICAL ,INTENT(INOUT) :: USING_Test
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCSanalyticwarsa"
REAL(KIND_MCS) :: sigt,sigs
!!--begin--
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , (/"Test ",&
"sigmat ",&
"sigmas ",&
"SpatRep"/) , fdbk ,&
nsubarg=(/0,0,0,0/) ,&
optional=(/.FALSE.,.FALSE.,.FALSE.,.FALSE./))
CALL ARGUMENT( sio , USING_Test , fdbk )
CALL ARGUMENT( sio , sigt , fdbk )
CALL ARGUMENT( sio , sigs , fdbk )
CALL ARGUMENT( sio , CellFunctionMethodA , fdbk , KEYS=MCS_KEY_CellFunction , Default=MCS_LINEAR_GAUSS)
CALL END_ARGUMENTS( sio , fdbk )
IF( Using_Test )THEN
CALL SET_AnalyticTest("WARSA",sigt,sigs,fdbk)
END IF
!!--end--
END SUBROUTINE
!!### CARD SUBROUTINE <<MCSanalyticwiesel>>
SUBROUTINE MCSanalyticwiesel( sio , USING_Test , &
fdbk )
!!#### PURPOSE
!! Read in parameters for an analytic test devised by
!! William Wieselquist, William.wieselquist AT gmail.com.
!!#### REQUIRED INPUT/OUTPUT
TYPE(TYPE_sio),POINTER :: sio
LOGICAL ,INTENT(INOUT) :: USING_Test
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCSanalyticwiesel"
REAL(KIND_MCS) :: sigt,sigs
!!--begin--
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , &
(/"Test ",&
"sigmat ",&
"sigmas ",&
"SpatRep",&
"C ",&
"A ",&
"BX ",&
"BY ",&
"D1 ",&
"DX ",&
"DY "/) , fdbk ,&
nsubarg=(/0,0,0,0,&
0,0,0,0,0,0,0/) ,&
optional=(/.FALSE.,.FALSE.,.FALSE.,.FALSE.,&
.TRUE.,.TRUE.,.TRUE.,.TRUE.,.TRUE.,.TRUE.,.TRUE./))
CALL ARGUMENT( sio , USING_Test , fdbk )
CALL ARGUMENT( sio , sigt , fdbk )
CALL ARGUMENT( sio , sigs , fdbk )
CALL ARGUMENT( sio , CellFunctionMethodA , fdbk , KEYS=MCS_KEY_CellFunction , Default=MCS_LINEAR_GAUSS)
CALL ARGUMENT( sio , ANALYTIC_C, fdbk, Default=ANALYTIC_C)
CALL ARGUMENT( sio , ANALYTIC_A, fdbk, Default=ANALYTIC_A)
CALL ARGUMENT( sio , ANALYTIC_BX, fdbk, Default=ANALYTIC_BX)
CALL ARGUMENT( sio , ANALYTIC_BY, fdbk, Default=ANALYTIC_BY)
CALL ARGUMENT( sio , ANALYTIC_D1, fdbk, Default=ANALYTIC_D1)
CALL ARGUMENT( sio , ANALYTIC_DX, fdbk, Default=ANALYTIC_DX)
CALL ARGUMENT( sio , ANALYTIC_DY, fdbk, Default=ANALYTIC_DY)
CALL END_ARGUMENTS( sio , fdbk )
IF( Using_Test )THEN
CALL SET_AnalyticTest("WIESEL",sigt,sigs,fdbk)
END IF
!!--end--
END SUBROUTINE
!!### CARD SUBROUTINE <<MCSlongpointlist>>
SUBROUTINE MCSlongpointlist( sio , NDim , Unit_LongChar , PointList_LongChar , fdbk )
!!#### PURPOSE
!! Read in a list of points for the long characteristics solver
!! to output angular fluxes for.
!!#### REQUIRED INPUT/OUTPUT
!! * number of dimensions <NDim>
!! * first point to define symmetry plane <P1sym>
!! * second point to define symmetry plane <P2sym>
!! * the unit to write to <Unit_AFSymmetryCheck>
INTEGER ,INTENT(IN) :: NDim
TYPE(TYPE_sio),POINTER :: sio
REAL(KIND_MSH),POINTER :: PointList_LongChar(:,:)
INTEGER ,INTENT(INOUT) :: Unit_LongChar
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCSlongpointlist"
!!#### LOCAL VARIABLES
TYPE(varying_string) :: file
INTEGER :: NPts
!!--begin--
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , (/"Npts","file"/) , fdbk ,&
nsubarg=(/0,0/) ,&
optional=(/.FALSE.,.FALSE./))
CALL ARGUMENT( sio , NPts , Fdbk )
CALL ARGUMENT( sio , file , fdbk )
CALL END_ARGUMENTS( sio , fdbk )
CALL DATABLOCK( sio , (/1,Ndim/) , (/1,Npts/) , PointList_LongChar , fdbk )
!! Wrapup.
IF( Reading(sio) )THEN
Unit_LongChar = NewFile(file)
END IF
!!--end--
END SUBROUTINE
!!### CARD SUBROUTINE <<MCSdebugpsiv>>
SUBROUTINE MCSdebugpsiv( sio , NDim , Unit_DebugPsiV , PointList_DebugPsiV , fdbk )
!!#### PURPOSE
!! Read in a list of points for the long characteristics solver
!! to output angular fluxes for.
!!#### REQUIRED INPUT/OUTPUT
!! * number of dimensions <NDim>
INTEGER ,INTENT(IN) :: NDim
TYPE(TYPE_sio),POINTER :: sio
REAL(KIND_MSH),POINTER :: PointList_DebugPsiV(:,:)
INTEGER ,INTENT(INOUT) :: Unit_DebugPsiV
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCSdebugpsiv"
!!#### LOCAL VARIABLES
TYPE(varying_string) :: file
INTEGER :: NPts
!!--begin--
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , (/"Npts","file"/) , fdbk ,&
nsubarg=(/0,0/) ,&
optional=(/.FALSE.,.FALSE./))
CALL ARGUMENT( sio , NPts , Fdbk )
CALL ARGUMENT( sio , file , fdbk )
CALL END_ARGUMENTS( sio , fdbk )
CALL DATABLOCK( sio , (/1,Ndim/) , (/1,Npts/) , PointList_DebugPsiV , fdbk )
!! Wrapup.
IF( Reading(sio) )THEN
Unit_DebugPsiV = NewFile(file)
END IF
!!--end--
END SUBROUTINE
!!### CARD SUBROUTINE <<MCSrayinfo>>
SUBROUTINE MCSrayinfo( sio , Print_RayEffectsInfo , rayeffectsfile , fdbk )
!!#### PURPOSE
!! Read in a list of points for the long characteristics solver
!! to output angular fluxes for.
!!#### REQUIRED INPUT/OUTPUT
TYPE(TYPE_sio),POINTER :: sio
LOGICAL ,INTENT(INOUT) :: Print_RayEffectsInfo
CHARACTER(*) ,INTENT(INOUT) :: rayeffectsfile
!!#### OPTIONAL INPUT/OUTPUT
TYPE(TYPE_fdbk),INTENT(INOUT),OPTIONAL :: fdbk
!!#### IDENTIFICATION
CHARACTER(*),PARAMETER :: proc_ = "MCSrayinfo"
!!#### LOCAL VARIABLES
TYPE(varying_string) :: file
INTEGER :: NPts
!!--begin--
!! Arguments.
CALL BEGIN_ARGUMENTS( sio , (/"Print","file "/) , fdbk ,&
nsubarg=(/0,0/) ,&
optional=(/.FALSE.,.TRUE./))
CALL ARGUMENT( sio , Print_RayEffectsInfo , Fdbk )
CALL ARGUMENT( sio , rayeffectsfile , fdbk , Default="" )
CALL END_ARGUMENTS( sio , fdbk )
!!--end--
END SUBROUTINE
END MODULE
| src/67-B-CCS_MoCshort.f90 |
c a front end to several numerical recipes routines
c for least square fitting - straight line, errors
c in 0, 1, or 2 coords
c lstsq_bootstrap.f is copyright 2006 Benjamin Weiner and released under
c the GNU General Public License. You may modify, you may redistribute,
c you must retain the copyright notice. Please contact me with
c any comments and suggestions.
c See Weiner et al. 2006 (ApJ, in press, astro-ph/------)
c for a discussion of fitting lines to data with intrinsic scatter.
c 4/23/00 - modified to ignore input lines beginning with '#',
c and to allow fitting only a given region
c 3/18/05 - added bootstrap estimation of the parameters/errors
c by sampling with replacement and refitting
c 12/20/05 - allows adding the intrinsic scatter in quadrature.
c following lstsq.f. Note this is redundant with bootstrapping
c for error estimation - once you have the correct intrinsic
c scatter that makes chisq/N=1, the original fit should return
c an error that is very close to the RMS of the bootstraps.
c However, the bootstraps are still useful for looking at the
c covariance of a and b.
c 8/30/06 - added the second plot of the distribution of a vs b
c as fit to the bootstrap resamples.
c Benjamin Weiner, bjw at astro.umd.edu (Astronomy Dept, University
c of Maryland; Steward Observatory as of Sept 2006)
program lstsq_bootstrap
parameter(NMAX=100000)
c parameter(NMAX_XY=1000)
parameter(NMAX_XY=10000)
parameter(NBOOTMAX=10000)
c real x1(NMAX),x2(NMAX),x3(NMAX)x4(NMAX)
c real x1err(NMAX),x2err(NMAX),x3err(NMAX)
real x(NMAX), xerr(NMAX)
real y(NMAX), yerr(NMAX)
real xf(NMAX), xferr(NMAX)
real yf(NMAX), yferr(NMAX)
real xerrbot(NMAX),xerrtop(NMAX)
real yerrbot(NMAX),yerrtop(NMAX)
real xpl(2),ypl(2)
real xftry(NMAX),yftry(NMAX),xftryerr(NMAX),yftryerr(NMAX)
real aboot(NBOOTMAX),bboot(NBOOTMAX)
character fname*40,dline*80
big = 1.e20
write(*,*) "0- plain least squares, 1- errors in y"
write(*,'(" 2- errors in x and y, ",
+ "3- x & y errors and y scatter: "$)')
c write(*,'(" 3- y=y(x1,x2,...) : "$)')
read(*,*) ichoose
c if (ichoose .eq. 3) then
c write(*,'("number of x'es [1-4]: "
c read (*,*) nx
c end if
10 write (*,'("enter file: "$)')
read (*,*) fname
open (2,file=fname,status='old',err=10)
npts = 1
20 continue
read (2,'(a)',end=30) dline
if (dline(1:1) .eq. '#') go to 20
if (ichoose .eq. 0) then
xerr(npts) = 0.
yerr(npts) = 0.
read (dline,*,err=20) x(npts),y(npts)
else if (ichoose .eq. 1) then
xerr(npts) = 0.
read (dline,*,err=20) x(npts),y(npts),yerr(npts)
else if (ichoose .eq. 2 .or. ichoose .eq. 3) then
read (dline,*,err=20) x(npts),xerr(npts),
$ y(npts),yerr(npts)
end if
npts=npts+1
go to 20
30 npts = npts-1
write(*,*) 'Read ', npts, ' points'
close(2)
if (npts .gt. NMAX) then
write(*,*) "Currently dimensioned for only max ",NMAX," points"
end if
if (ichoose .ge. 2 .and. npts .gt. NMAX_XY) then
write(*,*)
+ "Fitting w/both X and Y error will not work for >",NMAX_XY
write(*,*) "points without redimensioning arrays in fitexy.f and"
write(*,*) "other Numerical Recipes subroutines: chixy.f."
end if
c for ichoose = 3, add the scatter in quadrature to the error
c and then continue as if we were doing ichoose=2
if (ichoose .eq. 3) then
write(*,'("intrinsic scatter in y-coord: ",$)')
read (*,*) yintscatt
yintscattsq = yintscatt**2
do i=1,npts
yerr(i) = sqrt(yerr(i)**2 + yintscattsq)
end do
ichoose = 2
end if
c moved plotting points to here
c this is sloppy and works because the errors are 0 if
c they are not supplied
xmin = big
xmax = -big
ymin = big
ymax = -big
do i=1,npts
xerrbot(i) = x(i)-xerr(i)
xerrtop(i) = x(i)+xerr(i)
yerrbot(i) = y(i)-yerr(i)
yerrtop(i) = y(i)+yerr(i)
xmin = min(xmin,xerrbot(i))
xmax = max(xmax,xerrtop(i))
ymin = min(ymin,yerrbot(i))
ymax = max(ymax,yerrtop(i))
end do
xmargin = 0.1*(xmax-xmin)
ymargin = 0.1*(ymax-ymin)
wxmin = xmin-xmargin
wxmax = xmax+xmargin
wymin = ymin-ymargin
wymax = ymax+ymargin
call pgbegin (0,"?",1,1)
call pgask(.false.)
call pgscf(2)
call pgsch(1.1)
call pgenv(wxmin,wxmax,wymin,wymax,0,1)
call pglabel ("x","y","Least squares fit")
call pgpoint (npts,x,y,17)
if(ichoose .eq. 1 .or. ichoose .eq. 2) then
call pgerrb(6,npts,x,y,yerr,1.0)
if (ichoose .eq. 2) then
call pgerrb(5,npts,x,y,xerr,1.0)
end if
end if
c select fitting window
xfmin = wxmin
xfmax = wxmax
write (*,'("Enter xmin, xmax to fit [use all]: ",$)')
read (*,'(a)') dline
if (dline(1:5) .ne. ' ') then
read(dline,*,err=40) xfmin,xfmax
end if
40 continue
nf = 0
do i=1,npts
if(x(i) .gt. xfmin .and. x(i) .lt. xfmax) then
nf = nf+1
xf(nf) = x(i)
yf(nf) = y(i)
xferr(nf) = xerr(i)
yferr(nf) = yerr(i)
end if
end do
write(*,*) "Including ",nf," points"
if(nf .lt.2) go to 666
c do fit
if (ichoose .eq. 0) then
c call fit(x,y,npts,yerr,0,a,b,siga,sigb,chisq,q)
call fit(xf,yf,nf,yferr,0,a,b,siga,sigb,chisq,q)
else if (ichoose .eq. 1) then
c call fit(x,y,npts,yerr,1,a,b,siga,sigb,chisq,q)
call fit(xf,yf,nf,yferr,1,a,b,siga,sigb,chisq,q)
else if (ichoose .eq. 2) then
c call fitexy(x,y,npts,xerr,yerr,a,b,siga,sigb,chisq,q)
c call fitexy_big(xf,yf,nf,xferr,yferr,a,b,siga,sigb,chisq,q)
call big_fitexy(xf,yf,nf,xferr,yferr,a,b,siga,sigb,chisq,q)
end if
c plot fit
xpl(1) = wxmin
ypl(1) = a + b*wxmin
xpl(2) = wxmax
ypl(2) = a + b*wxmax
call pgline(2,xpl,ypl)
write(*,*) 'y = a + bx'
write(*,*) 'a = ',a,' +/- ',siga
write(*,*) 'b = ',b,' +/- ',sigb
write(*,*) 'chisq = ',chisq,' prob. = ',q
c save the best fit values
abest = a
bbest = b
abesterr = siga
bbesterr = sigb
sumsqerr = 0.0
c do i=1,npts
do i=1,nf
sumsqerr = sumsqerr + (y(i)-a-b*x(i))**2
end do
c write (*,*) 'rms error = ',sqrt(sumsqerr/npts)
write (*,*) 'rms error = ',sqrt(sumsqerr/nf)
c write data and fit to file
open(3,file='lstsq.out',status='unknown')
if (ichoose .eq. 0) then
write (3,*) 'xdata ydata yfit'
do i=1,npts
write(3,*) x(i),y(i),a + b*x(i)
end do
else if (ichoose .eq. 1) then
write (3,*) 'xdata ydata yerror yfit'
do i=1,npts
write(3,*) x(i),y(i),yerr(i),a + b*x(i)
end do
else if (ichoose .eq. 2) then
write (3,*)
$ 'xdata xerror ydata yerror yfit'
do i=1,npts
write(3,*) x(i),xerr(i),y(i),yerr(i),a + b*x(i)
end do
end if
close(3)
c initialize random
idum = -1
200 continue
write(*,'("Number of resamples for bootstrap: ",$)')
read (*,*) nboot
if (nboot .gt. NBOOTMAX) then
write(*,*) "max samples ",NBOOTMAX," setting to that"
nboot = NBOOTMAX
end if
asum = 0.0
asumsq = 0.0
bsum = 0.0
bsumsq = 0.0
amax = -1.e10
amin = 1.e10
bmax = -1.e10
bmin = 1.e10
open(3,file='lstsq_bootstrap.out',status='unknown')
c For nboot resamples
do i=1,nboot
c write(*,*) 'Doing resample ',i
c make random resample
do j=1,nf
jrand = int(nf*ran1(idum)) +1
xftry(j) = xf(jrand)
yftry(j) = yf(jrand)
xftryerr(j) = xferr(jrand)
yftryerr(j) = yferr(jrand)
end do
c do fit
if (ichoose .eq. 0) then
c call fit(x,y,npts,yerr,0,a,b,siga,sigb,chisq,q)
call fit(xftry,yftry,nf,yftryerr,0,a,b,siga,sigb,chisq,q)
else if (ichoose .eq. 1) then
c call fit(x,y,npts,yerr,1,a,b,siga,sigb,chisq,q)
call fit(xftry,yftry,nf,yftryerr,1,a,b,siga,sigb,chisq,q)
else if (ichoose .eq. 2) then
c call fitexy(x,y,npts,xerr,yerr,a,b,siga,sigb,chisq,q)
c call fitexy_big(xf,yf,nf,xferr,yferr,a,b,siga,sigb,chisq,q)
call big_fitexy(xftry,yftry,nf,xftryerr,yftryerr,
+ a,b,siga,sigb,chisq,q)
end if
c record parameters
aboot(i) = a
bboot(i) = b
asum = asum + a
asumsq = asumsq + a*a
bsum = bsum + b
bsumsq = bsumsq + b*b
write(3,*) i,a,b
amax = max(amax,a)
amin = min(amin,a)
bmax = max(bmax,b)
bmin = min(bmin,b)
end do
close(3)
c compute mean and rms of parameters
amean = asum /nboot
arms = sqrt(asumsq/nboot - amean**2)
bmean = bsum /nboot
brms = sqrt(bsumsq/nboot - bmean**2)
c Plot the bootstrap realizations' values of a and b -
c useful for seeing covariance
amarg = 0.2*(amax-amin)
bmarg = 0.2*(bmax-bmin)
call pgenv(amin-amarg,amax+amarg,bmin-bmarg,bmax+bmarg,0,1)
call pglabel("a, intercept","b, slope",
$ "y = a + bx, best fit and bootstrap realizations")
call pgpoint(nboot,aboot,bboot,17)
c plot the original best fit point with the error bar from the
c rms of the bootstraps. It might be better to use the 68% range,
c although they should be similar
call pgsch(2.0)
call pgsci(2)
call pgpt1(abest,bbest,12)
call pgerrb(5,1,abest,bbest,arms,1.0)
call pgerrb(6,1,abest,bbest,brms,1.0)
call pgsch(1.1)
call pgsci(1)
c compute median and conf levels. This sorts the aboot and bboot
c arrays so we need to do it last, after plotting and output.
call sort(nboot,aboot)
call sort(nboot,bboot)
if (mod(nboot,2) .eq. 1) then
indx = int(nboot/2) + 1
amed = aboot(indx)
bmed = bboot(indx)
else
indx=nboot/2
amed = (aboot(indx) + aboot(indx+1))/2.0
bmed = (bboot(indx) + bboot(indx+1))/2.0
end if
indx = nint(nboot*(0.5-0.34))
a68lo = aboot(indx)
b68lo = bboot(indx)
indx = nint(nboot*(0.5+0.34))
a68hi = aboot(indx)
b68hi = bboot(indx)
indx = nint(nboot*(0.5-0.477))
a95lo = aboot(indx)
b95lo = bboot(indx)
indx = nint(nboot*(0.5+0.477))
a95hi = aboot(indx)
b95hi = bboot(indx)
write(*,*) "Pars from bootstrap with ",nboot," resamples of ",
+ nf," points"
write(*,*) "mean, rms a = ",amean," +- ",arms
write(*,*) "mean, rms b = ",bmean," +- ",brms
write(*,*) "median and 68%, 95.4% ranges: "
write(*,*) "a: ",amed,a68lo,a68hi,a95lo,a95hi
write(*,*) "b: ",bmed,b68lo,b68hi,b95lo,b95hi
write(*,*) "sigma estimates from 68% and 95%:"
write(*,*) "a sigma: ",(a68hi-a68lo)/2.0,(a95hi-a95lo)/4.0
write(*,*) "b sigma: ",(b68hi-b68lo)/2.0,(b95hi-b95lo)/4.0
666 continue
call pgend()
end
| lstsq_bootstrap.f |
C SUBROUTINE ECH (NEXT)
SUBROUTINE ECH(ZSUM)
C
C ECH - CALCULATES THE MUTUAL IMPEDANCE BETWEEN LINEAR DIPOLE
C ELEMENTS IN ECHELON OF EQUAL LENGTHS.
C SEE THE REFERENCES IN SUBROUTINES GAIN AND COLL.
C
COMPLEX CSU1, CSU2, CSUZP, CSV1, CSV2, CSVZP, CSZ1, ZE, ZSUM
C
COMMON /CON /D2R, DCL, GAMA, PI, PI2, PIO2, R2D, RO, VOFL
C
COMMON /CUR /DIJ, EIL, HIJ, KODE
C
C.......................................................................
D2 = DIJ * * 2
HML = HIJ - EIL
HPL = HIJ + EIL
T = SQRT (D2 + HML * * 2)
UZ = PI2 * (T + HML)
VZ = PI2 * (T - HML)
T = SQRT (D2 + HPL * * 2)
UZP = PI2 * (T - HPL)
VZP = PI2 * (T + HPL)
TS = HIJ
T = SQRT (D2 + TS * * 2)
U1 = PI2 * (T + TS)
V1 = PI2 * (T - TS)
TS = HIJ + 2.0 * EIL
T = SQRT (D2 + TS * * 2)
U2 = PI2 * (T - TS)
V2 = PI2 * (T + TS)
TS = HIJ + 3.0 * EIL
T = SQRT (D2 + TS * * 2)
U4 = PI2 * (T - TS)
V4 = PI2 * (T + TS)
CSU1 = CSZ1 (U1)
CSV1 = CSZ1 (V1)
CSU2 = CSZ1 (U2)
CSV2 = CSZ1 (V2)
CSUZP = CSZ1 (UZP)
CSVZP = CSZ1 (VZP)
ZSUM = CMPLX (0.0, 0.0)
T = PI2 * (EIL - HIJ)
ZE = CMPLX (COS (T), SIN (T))
ZSUM=ZSUM + CONJG(ZE)*(CSZ1(UZ) - CSU1) + ZE*(CSZ1(VZ) - CSV1)
T = PI2 * (EIL + HIJ)
ZE = CMPLX (COS (T), SIN (T))
ZSUM = ZSUM + CONJG (ZE) * (CSUZP - CSU2) + ZE * (CSVZP - CSV2)
T = PI2 * ( - EIL - HIJ)
ZE = CMPLX (COS (T), SIN (T))
ZSUM=ZSUM + CONJG(ZE)*( -CSU1 + CSVZP) + ZE*( -CSV1 + CSUZP)
T = PI2 * (3.0 * EIL + HIJ)
ZE = CMPLX (COS (T), SIN (T))
ZSUM=ZSUM + CONJG(ZE)*( -CSU2+CSZ1(U4)) + ZE*( -CSV2+CSZ1(V4))
TS = 2.0 * COS (PI2 * EIL)
T = PI2 * HIJ
ZE = CMPLX (COS (T), SIN (T))
ZSUM=ZSUM+TS*CONJG(ZE)*(-CSV1+CSUZP)+TS*ZE*(-CSU1+CSVZP)
T = PI2 * (2.0 * EIL + HIJ)
ZE = CMPLX (COS (T), SIN (T))
ZSUM=ZSUM + TS*CONJG(ZE)*(CSUZP - CSU2) + TS*ZE*(CSVZP-CSV2)
IF (KODE .GT. 0) GO TO 100
ZSUM = ZSUM * 15.0
GO TO 105
100 ZSUM = ZSUM * 30.0 / (1.0 - COS (2.0 * PI2 * EIL))
105 RETURN
END
| src/hfmufesw/ech.for |
** Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
** See https://llvm.org/LICENSE.txt for license information.
** SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
* POINTER statements
parameter(N = 5)
integer result(N), expect(N)
double precision dum(2)
double precision d
pointer(ptr, d)
double complex cd
pointer(ptr, cd)
pointer (p1, ib)
pointer (p2, p1)
data expect /
+ 2,
+ 4,
+ 2, 4,
+ 10
+ /
p2 = loc(result(5))
ptr = loc(dum)
dum(1) = 2.0
dum(2) = 4.0
result(1) = d
ptr = ptr + 8
result(2) = d
ptr = ptr - 8
result(3) = real(cd)
result(4) = dimag(cd)
ib = 10 ! two levels of pointer. should be result(5)
call check(result, expect, N)
end
| test/f90_correct/src/bq00.f |
SUBROUTINE READDX(LUNIT,LUN,LUNDX)
C$$$ SUBPROGRAM DOCUMENTATION BLOCK
C
C SUBPROGRAM: READDX
C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
C
C ABSTRACT: THIS SUBROUTINE GENERATES INTERNAL ARRAYS CONTAINING BUFR
C DICTIONARY TABLES WHICH ARE NEEDED TO READ, WRITE, INITIALIZE OR
C APPEND A BUFR FILE. THE INFORMATION USED TO CREATE THE INTERNAL
C DICTIONARY TABLE ARRAYS (IN COMMON BLOCK /TABABD/) AND THE
C DICTIONARY MESSAGE CONTROL WORD PARTITION ARRAYS (IN COMMON BLOCK
C /MSGCWD/) (WHICH ARE ALWAYS THEN ASSOCIATED WITH THE BUFR FILE IN
C LUNIT) MAY COME FROM AN EXTERNAL, USER-SUPPLIED, BUFR DICTIONARY
C TABLE FILE IN CHARACTER FORMAT (I.E., A BUFR MNEMONIC TABLE), FROM
C THE BUFR FILE BEING ACTED UPON (IN WHICH CASE THE FILE MUST BE
C OPENED FOR INPUT PROCESSING AND POSITIONED AT A DICTIONARY TABLE
C MESSAGE SOMEWHERE IN THE FILE), OR FROM ANOTHER CURRENTLY OPENED
C AND DEFINED BUFR FILE. IN THIS LATTER CASE, THE BUFR FILE WOULD
C MOST LIKELY BE OPENED FOR INPUT, HOWEVER THERE IS NOTHING
C PREVENTING THE USE OF A FILE OPEN FOR OUTPUT AS LONG AS IT IS
C ASSOCIATED WITH INTERNAL DICTIONARY ARRAYS THAT CAN BE USED.
C
C PROGRAM HISTORY LOG:
C 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
C 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
C "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
C ROUTINE "BORT"
C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
C INTERDEPENDENCIES
C 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
C DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
C MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
C TERMINATES ABNORMALLY OR FOR INFORMATIONAL
C PURPOSES
C 2009-04-21 J. ATOR -- USE ERRWRT
C
C USAGE: CALL READDX (LUNIT, LUN, LUNDX)
C INPUT ARGUMENT LIST:
C LUNIT - INTEGER: FORTRAN LOGICAL UNIT NUMBER FOR BUFR FILE
C BEING READ, WRITTEN, INITIALIZED OR APPENDED
C LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
C (ASSOCIATED WITH FILE CONNECTED TO LOGICAL UNIT LUNIT)
C LUNDX - INTEGER: FORTRAN LOGICAL UNIT NUMBER CONTAINING
C DICTIONARY TABLE INFORMATION TO BE USED IN READING/
C WRITING FROM/TO LUNIT (DEPENDING ON THE CASE); MAY BE
C SET EQUAL TO LUNIT IF DICTIONARY TABLE INFORMATION IS
C ALREADY EMBEDDED IN LUNIT (BUT ONLY IF LUNIT IS BEING
C READ)
C
C REMARKS:
C THIS ROUTINE CALLS: BORT CPBFDX ERRWRT MAKESTAB
C RDBFDX RDUSDX STATUS
C THIS ROUTINE IS CALLED BY: OPENBF WRITDX
C Normally not called by any application
C programs.
C
C ATTRIBUTES:
C LANGUAGE: FORTRAN 77
C MACHINE: PORTABLE TO ALL PLATFORMS
C
C$$$
COMMON /QUIET/ IPRT
CHARACTER*128 ERRSTR
C-----------------------------------------------------------------------
C-----------------------------------------------------------------------
C GET THE BUFR STATUS OF UNIT LUNDX
C ---------------------------------
CALL STATUS(LUNDX,LUD,ILDX,IMDX)
C READ A DICTIONARY TABLE FROM THE INDICATED SOURCE
C -------------------------------------------------
IF (LUNIT.EQ.LUNDX) THEN
c .... Source is input BUFR file in LUNIT
IF(IPRT.GE.2) THEN
CALL ERRWRT('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
WRITE ( UNIT=ERRSTR, FMT='(A,A,I3,A)' )
. 'BUFRLIB: READDX - READING BUFR DICTIONARY TABLE FROM ',
. 'INPUT BUFR FILE IN UNIT ', LUNDX, ' INTO INTERNAL ARRAYS'
CALL ERRWRT(ERRSTR)
CALL ERRWRT('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
CALL ERRWRT(' ')
ENDIF
REWIND LUNIT
CALL RDBFDX(LUNIT,LUN)
ELSEIF(ILDX.EQ.-1) THEN
c .... Source is input BUFR file in LUNDX
c .... BUFR file in LUNIT may be input or output
IF(IPRT.GE.2) THEN
CALL ERRWRT('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
WRITE ( UNIT=ERRSTR, FMT='(A,A,I3,A,A,I3)' )
. 'BUFRLIB: READDX - COPYING BUFR DCTY TBL FROM INTERNAL ',
. 'ARRAYS ASSOC. W/ INPUT UNIT ', LUNDX, ' TO THOSE ASSOC. ',
. 'W/ UNIT ', LUNIT
CALL ERRWRT(ERRSTR)
CALL ERRWRT('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
CALL ERRWRT(' ')
ENDIF
CALL CPBFDX(LUD,LUN)
CALL MAKESTAB
ELSEIF(ILDX.EQ.1) THEN
c .... Source is output BUFR file in LUNDX
c .... BUFR file in LUNIT may be input or output
IF(IPRT.GE.2) THEN
CALL ERRWRT('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
WRITE ( UNIT=ERRSTR, FMT='(A,A,I3,A,A,I3)' )
. 'BUFRLIB: READDX - COPYING BUFR DCTY TBL FROM INTERNAL ',
. 'ARRAYS ASSOC. W/ OUTPUT UNIT ', LUNDX, ' TO THOSE ASSOC. ',
. 'W/ UNIT ', LUNIT
CALL ERRWRT(ERRSTR)
CALL ERRWRT('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
CALL ERRWRT(' ')
ENDIF
CALL CPBFDX(LUD,LUN)
CALL MAKESTAB
ELSEIF(ILDX.EQ.0) THEN
c .... Source is user-supplied character table in LUNDX
c .... BUFR file in LUNIT may be input or output
IF(IPRT.GE.2) THEN
CALL ERRWRT('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
WRITE ( UNIT=ERRSTR, FMT='(A,A,I3,A)' )
. 'BUFRLIB: READDX - READING BUFR DICTIONARY TABLE FROM ',
. 'USER-SUPPLIED TEXT FILE IN UNIT ', LUNDX,
. ' INTO INTERNAL ARRAYS'
CALL ERRWRT(ERRSTR)
CALL ERRWRT('++++++++++++BUFR ARCHIVE LIBRARY+++++++++++++++')
CALL ERRWRT(' ')
ENDIF
REWIND LUNDX
CALL RDUSDX(LUNDX,LUN)
ELSE
GOTO 900
ENDIF
C EXITS
C -----
RETURN
900 CALL BORT('BUFRLIB: READDX - CANNOT DETERMINE SOURCE OF '//
. 'INPUT DICTIONARY TABLE')
END
| extlibs/ncepBUFR/v10.2.3/readdx.f |
C Copyright(C) 1999-2020 National Technology & Engineering Solutions
C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
C NTESS, the U.S. Government retains certain rights in this software.
C
C See packages/seacas/LICENSE for details
SUBROUTINE MMSCHM (NPER, KKK, LLL, NNN, ML, MS, NSPR, ISLIST,
& NINT, IFLINE, NLPS, ILLIST, LINKL, LINKS, MXNPER, MAXPRM, MAX3,
& MXND, X, Y, NID, NNPS, ANGLE, XN, YN, NUID, LXK, KXL, NXL, LXN,
& IAVAIL, NAVAIL, CCW, REAL, SCHSTR, M1, ERR)
C***********************************************************************
C MMSCHM - "M" MESH SCHEME; CALCULATE A REGULAR RECTANGULAR MESH
C***********************************************************************
DIMENSION ISLIST(NSPR), NINT(ML), IFLINE(MS), NLPS(MS)
DIMENSION ILLIST(MS*3), LINKL(2, ML), LINKS(2, MS)
DIMENSION X(MXNPER), Y(MXNPER), NID(MXNPER*MAXPRM), NNPS(MAX3)
DIMENSION ANGLE(MXNPER), XN(MXND), YN(MXND), NUID(MXND)
DIMENSION LXK(4, MXND), KXL(2, 3*MXND), NXL(2, 3*MXND)
DIMENSION LXN(4, MXND)
CHARACTER*72 SCHSTR
LOGICAL CCW, ERR, NORM, REAL
C CALCULATE THE BASE OF THE RECTANGLE FOR THE REGION
CALL GETM1 (ML, MS, MAX3, NSPR, ISLIST, NINT, IFLINE, NLPS,
& ILLIST, LINKL, LINKS, X, Y, NID, NNPS, ANGLE, NPER, SCHSTR, M1,
& CCW, NORM, REAL, ERR)
IF (NORM) THEN
CALL MESAGE ('FORCED RECTANGLE PRIMITIVE PROCESSING USED')
ELSE
CALL MESAGE ('GENERAL RECTANGLE PRIMITIVE PROCESSING USED')
END IF
M2 = NPER/2 - M1
C CALCULATE A REGULAR MAPPED "RECTANGULAR" MESH
KKKOLD = KKK
LLLOLD = LLL
NNNOLD = NNN
CALL RMESH (NPER, MXND, X, Y, NID, XN, YN, NUID, LXK, KXL, NXL,
& LXN, M1, M2, KKK, KKKOLD, NNN, NNNOLD, LLL, LLLOLD, IAVAIL,
& NAVAIL, ERR)
RETURN
END
| packages/seacas/applications/fastq/mmschm.f |
subroutine deplet
c
c + + + PURPOSE + + +
c This subprogram calculates the depletion level of the soil for the
c current rooting depth and for the soil profile. Also calculates
c an irrigation depth if necessary.
c
c Called from IRRIG
c Author(s): E. R. Kottwitz
c Reference in User Guide: Chapter 12
c
c Changes:
c
c Version: This module recoded from WEPP Version 93.06.
c Date recoded: 07/06/93.
c Recoded by: Charles R. Meyer.
c
c
c + + + PARAMETERS + + +
include 'pmxelm.inc'
include 'pmxhil.inc'
include 'pmxnsl.inc'
include 'pmxpln.inc'
include 'pmxsrg.inc'
include 'pxstep.inc'
c
c + + + COMMON BLOCKS + + +
include 'ccrpout.inc'
c read: rtd(mxplan)
c
include 'chydrol.inc'
c read: rain(mxplan)
c
include 'cirdepl.inc'
c read: deplev(mxplan),irdmin
c modify: iramt
c write: depsev
c
include 'cirfurr.inc'
c read: filrat(mxplan)
c
include 'cirriga.inc'
c read: irsyst
c
include 'cirspri.inc'
c read: aprati(mxplan),irdmax
c
include 'cstruc.inc'
c read: iplane
c
include 'cwater.inc'
c read: st(mxnsl,mxplan),thetdr(mxnsl,mxplan),
c thetfc(mxnsl,mxplan),nsl(mxplan),solthk(mxnsl,mxplan),
c dg(mxnsl,mxplan)
c
include 'cwint.inc'
c read: wmelt(mxplan)
c
include 'cirflg.inc'
c
c + + + LOCAL VARIABLES + + +
integer i,ii
real awtota,awtotb,depla,deplb,iramta,iramtb,sumsta,sumstb
c
c + + + LOCAL DEFINITIONS + + +
c i - do loop counter for summations for soil layers
c ii - flag indicating whether bottom of soil layer is below
c the current rooting depth (0-no, 1-yes)
c awtota - available soil water over the current root depth (m)
c awtotb - available soil water over the entire soil profile (m)
c depla - available soil water depletion over the current root
c depth (m/m)
c deplb - available soil water depletion over the entire soil
c profile (m/m)
c iramta - irrigation amount required to fill the soil profile over
c the current root depth multiplied by the ratio of
c application depth to allowable irrigation depth
c (aprati(mxplan)) (m)
c iramtb - irrigation amount required to fill the soil profile over
c the entire soil profile multiplied by aprati(mxplan) (m)
c sumsta - maximum available soil water over the current root depth
c (m)
c sumstb - maximum available soil water over the entire soil profile
c (m)
c
c + + + END SPECIFICATIONS + + +
c
c Initialize variables
c
irdfg = 1
c
ii = 0
c
sumsta = rain(iplane) + wmelt(iplane)
sumstb = rain(iplane) + wmelt(iplane)
c
c Do a summation of (a) current available soil water (st) and
c maximum available soil water (aw) for the root depth and (b) st
c and aw for all soil layers
c
sumstb = sumstb+st(1,iplane)
awtotb = (thetfc(1,iplane)-thetdr(1,iplane))*dg(1,iplane)
c
if(solthk(1,iplane).le.rtd(iplane))then
sumsta = sumstb
awtota = awtotb
else
sumsta = sumsta+st(1,iplane)*rtd(iplane)/dg(1,iplane)
awtota = (thetfc(1,iplane)-thetdr(1,iplane))*rtd(iplane)
ii = 1
endif
c
do 10 i = 2, nsl(iplane)
sumstb = sumstb+st(i,iplane)
awtotb = awtotb+(thetfc(i,iplane)-thetdr(i,iplane))*dg(i,iplane)
if(ii.eq.0)then
c
if(solthk(i,iplane).le.rtd(iplane))then
sumsta = sumstb
awtota = awtotb
else
sumsta = sumsta+st(i,iplane)*(rtd(iplane)-
1 solthk(i-1,iplane))/dg(i,iplane)
awtota = awtota+(thetfc(i,iplane)-thetdr(i,iplane))*
1 (rtd(iplane)-solthk(i-1,iplane))
ii = 1
endif
c
endif
10 continue
c
c Calculate depletion level for the current rooting depth and for
c all soil layers
c
c
c correction by dcf 8/29/91 - divide by zero when awtota=0
c
c if(rtd(iplane).gt.0.0001 .and. sumsta/awtota.lt.1.0)then
c
if(rtd(iplane).gt.0.0001 .and. awtota.gt.0.0)then
if(sumsta/awtota.lt.1.0)then
depla = 1.0-sumsta/awtota
else
depla = 0.0
endif
else
depla = 0.0
endif
c
if(awtotb.gt.0.0)then
if(sumstb/awtotb.lt.1.0)then
deplb = 1.0-sumstb/awtotb
else
deplb = 0.0
endif
else
deplb = 0.0
endif
c
c If depletion level is greater than allowable then determine
c irrigation parameters
c
c *** M0 IF ***
if(depla.ge.deplev(iplane) .or. deplb.ge.deplev(iplane))then
depsev = (max(depla,deplb)-deplev(iplane))/deplev(iplane)
c
if(irsyst.eq.1)then
c
c Additional calculations for solid-set, side-roll, or hand-
c move irrigation systems
c
iramta = (awtota-sumsta)*aprati(iplane)
iramtb = (awtotb-sumstb)*aprati(iplane)
else
c
c Additional calculations for furrow irrigation systems
c
iramta = (awtota-sumsta)*filrat(iplane)
iramtb = (awtotb-sumstb)*filrat(iplane)
endif
c
iramt = max(iramta,iramtb)
c
if(iramt.lt.irdmin)then
iramt = 0.0
depsev = 0.0
elseif(irsyst.eq.1 .and. iramt.gt.irdmax)then
iramt = irdmax
endif
c
c *** M0 ELSE ***
else
depsev = 0.0
iramt = 0.0
c
c *** M0 ENDIF ***
endif
c
return
end
| src/wepp2010.1/deplet.for |
Hi Welcome to the wiki!
20110825 16:05:45 nbsp Hey there. Store looks cool. Definitely a derth of thrift stores in town.
This page is good for image tips, btw: http://wikispot.org/Help_with_Images
Otherwise, welcome! Users/jefftolentino
| lab/davisWiki/xomario.f |
subroutine Bamp_pmm(q,mc,ms,Bpmm)
c--- u + g -> c + s + d (t-channel single-charm)
************************************************************************
* *
* AUTHORS: R. FREDERIX AND F. TRAMONTANO *
* DATE : 12/17/2008 *
* *
************************************************************************
implicit none
include 'constants.f'
include 'zprods_com.f'
include 'epinv.f'
include 'stopf1inc.f'
double precision q(mxpart,4),dot,cDs,gDs,cDg,mc,ms,
. mc2,ms2,qsq,s,t,u,xsn,xsd,xs
double complex trc,trg,trs,trsgc,zpmm,Bpmm
mc2=mc**2
ms2=ms**2
cDs=dot(q,3,4)+mc2*dot(q,4,2)/2d0/dot(q,3,2)
. +ms2*dot(q,3,2)/2d0/dot(q,4,2)
cDg=dot(q,3,2)
gDs=dot(q,4,2)
qsq=mc2+ms2+2d0*cDs+2d0*cDg+2d0*gDs
s=ms2+2d0*gDs
t=mc2+2d0*cDg
u=mc2+ms2+2d0*cDs
xsn=(1d0-dsqrt(1d0-4d0*ms*mc/(u-(ms-mc)**2)))
xsd=(1d0+dsqrt(1d0-4d0*ms*mc/(u-(ms-mc)**2)))
xs=-xsn/xsd
trg=2d0*za(5,2)*zb(2,1)
trs=2d0*za(5,4)*zb(4,1)+ms**2*za(5,2)*zb(2,1)/gDs
trc=2d0*za(5,3)*zb(3,1)+mc**2*za(5,2)*zb(2,1)/cDg
trsgc=2d0*zb(1,4)*za(4,2)*zb(2,3)*za(3,5)
zpmm=za(2,4)*za(2,3)*zb(4,3)**2
Bpmm = ms*(gDs+cDg)*(mc2*gDs**3*(cDs*(4*trc*gDs**2-2*(trsgc+mc2*t
& rg-2*ms2*trc)*gDs-ms2*(trsgc+3*mc2*trg))+mc2*ms2*(2*(trg-trs)*g
& Ds-trsgc+3*ms2*trg)-4*trg*cDs**2*(gDs+ms2))-cDg**2*gDs*(2*cDs**
& 2*(4*trc*gDs**2-2*trsgc*gDs+2*ms2*(trs+trg+3*trc)*gDs-2*ms2*trs
& gc+ms2**2*trg)+ms2*cDs*(-4*trc*gDs**2+2*(trsgc+mc2*trg-2*ms2*tr
& c)*gDs+ms2*(trsgc+3*mc2*trg))+mc2*ms2**2*(-2*(trs+trg)*gDs+trsg
& c-ms2*trg))+2*cDg*gDs**2*(cDs*(mc2*((2*gDs+3*ms2)*(trc*gDs-ms2*
& trg)+2*ms2*trs*gDs)+mc2*trg*cDs*(2*gDs+3*ms2)-4*trc*cDs*gDs*(gD
& s+ms2)+4*trg*cDs**2*(gDs+ms2))+trsgc*(2*cDs**2*(gDs+ms2)-mc2*cD
& s*gDs-mc2*ms2**2))+2*ms2*cDg**3*cDs*(trc*gDs*(2*gDs+3*ms2)-trsg
& c*(gDs+ms2)))*tr5Xs/(cDg*(cDs-mc*ms)*(cDs+mc*ms)*gDs**3)/2.0d+0
Bpmm = Bpmm-mc2*ms*(gDs+cDg)*(2*mc2**2*trg*cDs*gDs**3+cDg**3*(cD
& s*(-4*mc2*trs*gDs-2*ms2*trc*gDs+ms2*trsgc+3*mc2*ms2*trg)-4*trg*
& cDs**3-2*(trsgc+ms2*trg)*cDs**2+mc2*ms2*(trsgc+ms2*trg))+2*cDg*
& *2*gDs*(mc2**2*(trs*gDs-ms2*trg)+cDs**2*(2*trc*gDs-trsgc+2*mc2*
& trg)+2*trg*cDs**3+mc2*trsgc*cDs)-mc2*cDg*gDs**2*(cDs*(2*trc*gDs
& -trsgc+mc2*trg)+6*trg*cDs**2+mc2*(trsgc-ms2*trg))+cDg**4*(4*trs
& *cDs**2-2*mc2*ms2*trs))*tr5Xc/(cDg**3*(cDs**2-mc2*ms2)*gDs)/2.0
& d+0
Bpmm = ms*(cDg**2*gDs*(2*cDs**2*(4*trc*gDs**2-2*trsgc*gDs+2*ms2*(
& trs+trg+3*trc)*gDs-2*ms2*trsgc+ms2**2*trg)+ms2*cDs*(-4*trc*gDs*
& *2+2*(trsgc+mc2*trg-2*ms2*trc)*gDs+ms2*(trsgc+3*mc2*trg))+mc2*m
& s2**2*(-2*(trs+trg)*gDs+trsgc-ms2*trg))+mc2*gDs**3*(cDs*(-4*trc
& *gDs**2+2*(trsgc+mc2*trg-2*ms2*trc)*gDs+ms2*(trsgc+3*mc2*trg))+
& mc2*ms2*(2*trs*gDs-2*trg*gDs+trsgc-3*ms2*trg)+4*trg*cDs**2*(gDs
& +ms2))+2*cDg*gDs**2*(trsgc*(-2*cDs**2*(gDs+ms2)+mc2*cDs*gDs+mc2
& *ms2**2)-cDs*(mc2*((2*gDs+3*ms2)*(trc*gDs-ms2*trg)+2*ms2*trs*gD
& s)+mc2*trg*cDs*(2*gDs+3*ms2)-4*trc*cDs*gDs*(gDs+ms2)+4*trg*cDs*
& *2*(gDs+ms2)))+2*ms2*cDg**3*cDs*(trsgc*(gDs+ms2)-trc*gDs*(2*gDs
& +3*ms2)))*tr4Xs/(cDg*(cDs-mc*ms)*(cDs+mc*ms)*gDs**2)/2.0d+0+Bp
& mm
Bpmm = mc2*ms*(2*mc2**2*trg*cDs*gDs**3+cDg**3*(cDs*(-4*mc2*trs*gD
& s-2*ms2*trc*gDs+ms2*trsgc+3*mc2*ms2*trg)-4*trg*cDs**3-2*(trsgc+
& ms2*trg)*cDs**2+mc2*ms2*(trsgc+ms2*trg))+2*cDg**2*gDs*(mc2**2*(
& trs*gDs-ms2*trg)+cDs**2*(2*trc*gDs-trsgc+2*mc2*trg)+2*trg*cDs**
& 3+mc2*trsgc*cDs)-mc2*cDg*gDs**2*(cDs*(2*trc*gDs-trsgc+mc2*trg)+
& 6*trg*cDs**2+mc2*(trsgc-ms2*trg))+cDg**4*(4*trs*cDs**2-2*mc2*ms
& 2*trs))*tr4Xc/(cDg**2*(cDs**2-mc2*ms2)*gDs)/2.0d+0+Bpmm
Bpmm = Bpmm-ms*(-2*mc2**3*ms2*trg*gDs**3-2*cDg**2*gDs*(mc2*ms2*(
& -13*(trg+trc)*gDs**2+2*(trsgc+mc2*trg)*gDs+mc2*(trsgc+2*ms2*trg
& ))+mc2*cDs*(mc2*trs*gDs+2*ms2*trc*gDs-ms2*trsgc+mc2*ms2*trg)+cD
& s**2*gDs*(13*(trg+trc)*gDs-2*(trsgc+mc2*trg)))+cDg**3*(6*(2*trg
& -3*trs)*(cDs**2-mc**2*ms**2)*gDs**2+2*((trsgc+ms2*trg)*cDs**2+m
& c2*ms2*(-trsgc-ms2*trg+ms2*trc)+2*mc2**2*ms2*trs)*gDs+mc2*ms2*(
& trsgc*cDs+ms2*trg*cDs-ms2*trsgc+mc2*ms2*trg))-2*cDg**4*(2*mc2*m
& s2*(trs*gDs-ms2*trg)+2*cDs**2*(ms2*trg-trs*gDs)+mc2*ms2*trs*cDs
& )+mc2*cDg*gDs**2*(2*(mc2*ms2*(trg+trc)-trg*cDs**2)*gDs+mc2*(trs
& gc*cDs+5*ms2*trg*cDs-ms2*trsgc+mc2*ms2*trg)))*tr3Xs/(cDg**2*(cD
& s**2-mc**2*ms**2)*gDs)/2.0d+0
Bpmm = ms*(2*cDg**2*gDs*(mc2*cDs*(8*trc*gDs**2-4*trsgc*gDs+12*ms2
& *trc*gDs-3*ms2*trsgc+ms2**2*trg)+mc2*ms2*(3*trc*gDs**2-(trsgc+1
& 3*ms2*trc)*gDs+ms2*(trsgc+3*mc2*trg))+cDs**2*gDs*(-7*trc*gDs+3*
& trsgc+2*mc2*trg+9*ms2*trc)+2*(trs+trg)*cDs**3*gDs)-2*mc2*cDg*gD
& s**2*(mc2*(4*trc*gDs**2+6*ms2*trc*gDs+trsgc*(-2*gDs-ms2)+ms2**2
& *trg)+cDs*(-8*trc*gDs**2+4*(trsgc+mc2*trg-2*ms2*trc)*gDs+2*ms2*
& (trsgc+3*mc2*trg))+cDs**2*(4*(trs+trg)*gDs+trsgc+ms2*trg))+mc2*
& gDs**3*(mc2*(-8*trc*gDs**2+(4*trsgc+4*mc2*trg-11*ms2*trc)*gDs+m
& s2*(2*trsgc+6*mc2*trg+3*ms2*trc))+2*mc2*cDs*(2*(trs+trg)*gDs+tr
& sgc+ms2*trg)+3*trc*cDs**2*(gDs-ms2))+4*cDg**3*(mc2*ms2*(gDs*(2*
& (trs+trg)*gDs+ms2*(trg-3*trc))+trsgc*(2*gDs+ms2))-cDs**2*gDs*(2
& *(trs+trg+trc)*gDs+trsgc+ms2*trg))-8*trg*cDg**4*(cDs-mc*ms)*(cD
& s+mc*ms)*gDs)*tr3Xc/(cDg*(cDs-mc*ms)*(cDs+mc*ms)*gDs**2)/4.0d+0
& +Bpmm
Bpmm = ms*(-mc2*cDg**3*gDs*(mc2*ms2*((36*trs-24*trg+5*trc)*gDs**2
& +(ms2*(2*trs-2*trg+trc)+8*mc2*trs)*gDs+2*ms2**2*(trs+trg))-cDs*
& *2*(3*(12*trs-8*trg+7*trc)*gDs**2-8*trsgc*gDs+ms2*(2*trs-2*trg+
& 9*trc)*gDs+2*ms2**2*(trs+trg))-2*mc2*ms2*cDs*(4*(-trs-trg+trc)*
& gDs-3*trsgc+ms2*(trs+3*trg))+2*(ms2*(trs+3*trg)-3*trsgc)*cDs**3
& )+2*cDg**4*(mc2**2*ms2*(8*trs*gDs**2-(trsgc+ms2*(trs+7*trg+2*tr
& c))*gDs+ms2*(trsgc+ms2*trs))+mc2*cDs**2*(ms2*(trs*gDs+7*trg*gDs
& -trsgc)+gDs*(trsgc-8*trs*gDs)-ms2**2*(trs+3*trc))+cDs**4*(2*(tr
& s+trg)*gDs+3*ms2*trc)+mc2*ms2*cDs*gDs*(3*trc*gDs-trsgc+2*mc2*tr
& s-2*mc2*trg-11*ms2*trc)+cDs**3*gDs*(-7*trc*gDs+3*trsgc+2*mc2*tr
& g+9*ms2*trc))+mc2*cDg**2*gDs**2*(cDs**2*(52*(trg+trc)*gDs**2+(-
& 8*trsgc+ms2*(2*trs-trg+trc)+4*mc2*trs-8*mc2*trg)*gDs-2*(3*mc2*t
& rsgc+ms2**2*(trs+trg)-mc2*ms2*trs))+mc2*ms2*(-52*(trg+trc)*gDs*
& *2+(8*trsgc+ms2*(-2*trs+trg-trc)-4*mc2*(trc-3*trg))*gDs+2*(3*mc
& 2*trsgc+ms2**2*(trs+trg)-mc2*ms2*trs))-mc2*cDs*(8*trc*gDs**2+(5
& *ms2*trc-4*(trsgc+mc2*trs))*gDs+ms2**2*(2*(trs+trg)+3*trc))+cDs
& **3*(trc*gDs+ms2*(2*(trs+trg)+3*trc)))+2*mc2*(cDs-mc*ms)*(cDs+m
& c*ms)*gDs**3*(trs*(cDs+ms2)*(4*gDs**2+ms2*(4*(gDs+cDs)-mc2)+8*c
& Ds*gDs-2*mc2*gDs+4*cDs**2-2*mc2*cDs+ms2**2+mc2**2)+ms2*(trg+trc
& )*gDs*(2*gDs+2*cDs+ms2-mc2))-2*cDg**5*(cDs-mc*ms)*(cDs+mc*ms)*(
& cDs*(2*(trs+trg+2*trc)*gDs+2*trsgc+2*ms2*trg-3*ms2*trc)+gDs*(7*
& trc*gDs-3*trsgc-2*mc2*trg-9*ms2*trc))+2*mc2*cDg*(cDs-mc*ms)*(cD
& s+mc*ms)*gDs**3*((ms2*(4*trs+trg+trc)+2*mc2*trg)*gDs+2*(2*ms2+m
& c2)*trs*cDs+3*ms2*(trg+trc)*cDs+(2*ms2**2+mc2**2)*trs)-4*cDg**6
& *(cDs-mc*ms)*(cDs+mc*ms)*(2*(trs+trg+trc)*gDs+2*trg*cDs+trsgc+m
& s2*trg)-8*trg*cDg**7*(cDs-mc*ms)*(cDs+mc*ms))*lVs/(mc2*cDg**3*(
& mc2*ms2-cDs**2)*gDs**2)/8.0d+0+Bpmm
Bpmm = (-2*cDg**4*(cDs**2*(4*trs*gDs**3+ms2*(6*trc-5*trg)*gDs**2-
& ms2*(3*trsgc+2*mc2*(trs+trg)+ms2*(2*trg+13*trc))*gDs+ms2**2*(2*
& trsgc-mc2*(trs+trg+3*trc)))+mc2*ms2*(-4*trs*gDs**3+ms2*(5*trg-2
& *trc)*gDs**2+ms2*(trsgc+2*ms2*trg+2*mc2*trg+15*ms2*trc)*gDs+ms2
& **2*(mc2*(trs+trg)-2*trsgc))+cDs**3*gDs*(4*trs*gDs+ms2*(3*trc-2
& *(trs+5*trg)))-mc2*ms2*cDs*gDs*(4*trs*gDs+ms2*(trc-8*trg))+3*ms
& 2*trc*cDs**4)-2*cDg**3*gDs*(cDs**2*(6*(2*trg-3*trs)*gDs**3+2*(t
& rsgc-4*mc2*trs+ms2*trg)*gDs**2+mc2*ms2*(5*trs+6*trg-4*trc)*gDs+
& mc2*ms2**2*(trs+trg))-mc2*ms2*(6*(2*trg-3*trs)*gDs**3+2*(trsgc-
& 4*mc2*trs+ms2*trg)*gDs**2+mc2*ms2*(trs+2*trg)*gDs+mc2*ms2**2*(t
& rs+trg))+cDs**3*(6*(2*trg-3*trs)*gDs**2+(-2*trsgc+6*ms2*trg+8*m
& s2*trc)*gDs-ms2*(4*trsgc+mc2*trs+2*mc2*trg))+mc2*ms2*cDs*(-2*(-
& 9*trs+6*trg+4*trc)*gDs**2+(6*trsgc+4*mc2*trs-6*ms2*(trg+2*trc))
& *gDs+ms2*(4*trsgc+mc2*(trs+2*trg))))+cDg**2*gDs**2*(cDs**2*(52*
& (trg+trc)*gDs**3-8*(trsgc+mc2*trg)*gDs**2+mc2*(-8*trsgc+8*mc2*t
& rs+ms2*(-2*trs+trg+10*trc))*gDs-mc2*ms2*(4*trsgc+ms2*(3*trc-2*(
& trs+trg))+2*mc2*(trs+trg)))+mc2*ms2*(-52*(trg+trc)*gDs**3+8*(tr
& sgc+mc2*(trg-trc))*gDs**2-mc2*(4*(mc2*trs-3*trsgc)+ms2*(-2*trs+
& trg+14*trc))*gDs+mc2*ms2*(4*trsgc+ms2*(3*trc-2*(trs+trg))+2*mc2
& *(trs+trg)))+cDs**3*(52*(trg+trc)*gDs**2-8*(trsgc+mc2*trg)*gDs-
& 2*mc2*ms2*(trs+trg+3*trc))+2*mc2*ms2*cDs*(-26*(trg+trc)*gDs**2+
& (4*trsgc+2*mc2*(trs+3*trg-trc))*gDs+mc2*ms2*(trs+trg+3*trc)))-2
& *mc2*(cDs-mc*ms)*(cDs+mc*ms)*gDs**3*(trs*(cDs+ms2)*(4*gDs**2+ms
& 2*(4*(gDs+cDs)-mc2)+8*cDs*gDs-2*mc2*gDs+4*cDs**2-2*mc2*cDs+ms2*
& *2+mc2**2)+ms2*(trg+trc)*gDs*(2*gDs+2*cDs+ms2-mc2))-2*mc2*cDg*(
& cDs-mc*ms)*(cDs+mc*ms)*gDs**3*(-2*trg*gDs**2+cDs*(-2*trg*gDs+ms
& 2*(4*trs+3*(trg+trc))+2*mc2*trs)+ms2*(4*trs+trg+trc)*gDs+mc2*tr
& sgc+2*ms2**2*trs+mc2*ms2*trg)+2*ms2*cDg**5*(mc2*ms2-cDs**2)*(2*
& (3*trs*gDs+2*(trg+trc)*gDs+trsgc+ms2*trg)+3*trc*cDs)+8*ms2*trg*
& cDg**6*(mc2*ms2-cDs**2))*lVc/(cDg**3*(mc2*ms*ms2-ms*cDs**2)*gDs
& **2)/8.0d+0+Bpmm
Bpmm = xs*cDs*(2*trc*cDg*gDs-mc2*trg*gDs-trsgc*cDg)*(mc2*gDs**2-2
& *cDg*cDs*gDs+ms2*cDg**2)*lRcs/(mc*(xs**2-1)*cDg**2*gDs**2)+Bpm
& m
Bpmm = (mc2*cDg**4*(-288*trs*gDs**6-2*cDs*(320*trs*gDs**5-4*ms2*(
& -68*trs+88*trg+199*trc)*gDs**4-2*ms2*(-180*trsgc+mc2*(2*trs-132
& *trg+51*trc)-34*ms2*trs+24*ms2*trg+298*ms2*trc)*gDs**3+ms2**2*(
& 252*trsgc+6*ms2*trs+mc2*(-66*trs+104*trg-123*trc)+64*ms2*trg-90
& *ms2*trc)*gDs**2-2*ms2**2*(mc2*(9*trsgc+2*ms2*(8*(trs+trg)+9*tr
& c))-18*ms2*trsgc)*gDs-9*mc2*ms2**3*(trsgc+ms2*trg))+16*ms2*(-17
& 5*trs+132*trg+6*trc)*gDs**5+2*ms2*(144*trsgc-652*ms2*trs-4*mc2*
& trs+756*ms2*trg+2*mc2*trg+186*ms2*trc+153*mc2*trc)*gDs**4-ms2*(
& mc2*(216*trsgc+104*ms2*trs+854*ms2*trg+785*ms2*trc)-12*ms2**2*(
& 3*trs+21*trg+14*trc)+144*mc2**2*trg)*gDs**3-6*cDs**2*gDs*(2*gDs
& +ms2)*(24*trs*gDs**2+ms2*(24*(trs+trg)+13*trc)*gDs+ms2*(-3*trsg
& c+6*ms2*trg+3*mc2*(trc-2*trg)-22*ms2*trc))-ms2**2*(mc2*(144*trs
& gc+ms2*(50*trs+500*trg+937*trc))-12*ms2*(ms2*(trs+trg)-6*trsgc)
& +4*mc2**2*(5*trs+23*trg))*gDs**2+36*ms2*(trs+trg)*cDs**3*gDs*(2
& *gDs+ms2)-2*mc2*ms2**3*(-9*trsgc+3*ms2*(trs+7*trg+39*trc)+5*mc2
& *trs-13*mc2*trg)*gDs+18*mc2*ms2**4*(trsgc+mc2*trg))-2*mc2*cDg**
& 3*gDs*(216*(2*trg-3*trs)*gDs**6+cDs*(432*(2*trg-3*trs)*gDs**5+8
& *(ms2*(-81*trs+104*trg+50*trc)-28*mc2*trs)*gDs**4-2*ms2*(72*trs
& gc+mc2*(10*trs+274*trg+229*trc)+6*ms2*trs-94*ms2*trg-85*ms2*trc
& )*gDs**3-ms2*(6*ms2*(12*trsgc+ms2*(trs+trg+3*trc))+mc2*(ms2*(-5
& 2*trs+210*trg+319*trc)-180*trsgc)+mc2**2*(26*trs-92*trg))*gDs**
& 2+mc2*ms2**2*(126*trsgc+ms2*(3*trs+32*trg-45*trc)-13*mc2*trs+82
& *mc2*trg)*gDs+18*mc2*ms2**3*(trsgc+mc2*trg))+4*(18*(trsgc-3*mc2
& *trs)+ms2*(-81*trs+536*trg+464*trc))*gDs**5+2*ms2*(-126*trsgc+m
& c2*(656*trs-611*trg+217*trc)-6*ms2*trs+485*ms2*trg+461*ms2*trc)
& *gDs**4+cDs**2*(2*gDs+ms2)*(108*(2*trg-3*trs)*gDs**3-3*(12*(trs
& gc-mc2*trs)+ms2*(12*trg+trc))*gDs**2+ms2*(19*ms2*trc-12*mc2*(tr
& c-3*(trs+trg)))*gDs+9*mc2*ms2*(trsgc+ms2*trg))+ms2*(-3*ms2*(48*
& trsgc+ms2*(-2*trs-5*trg+trc))+mc2*(ms2*(680*trs-1001*trg+154*tr
& c)-396*trsgc)+6*mc2**2*(29*trs-16*trg+12*trc))*gDs**3+ms2*(-3*m
& c2*ms2*(54*trsgc+7*ms2*trs+67*ms2*trg+29*ms2*trc)+mc2**2*(18*tr
& sgc+109*ms2*trs+100*ms2*trg+72*ms2*trc)+6*ms2**3*(trs+trg))*gDs
& **2+8*ms2*trc*cDs**3*gDs*(2*gDs+ms2)+mc2*ms2**2*(mc2*(27*trsgc+
& ms2*(11*trs+92*trg+18*trc))-3*ms2*(ms2*(trs+trg+9*trc)-6*trsgc)
& )*gDs+9*mc2**2*ms2**3*(trsgc+ms2*trg))+mc2*cDg**2*gDs**2*((2*gD
& s+ms2)*(936*(trg+trc)*gDs**5-36*(4*trsgc-9*mc2*trs+10*mc2*trg)*
& gDs**4+4*(-mc2*(45*trsgc+12*ms2*trs+506*ms2*trg+425*ms2*trc)+3*
& ms2**2*(4*trs+trg+trc)+72*mc2**2*trs)*gDs**3+ms2*(3*mc2*(72*trs
& gc+ms2*(-6*trs-trg+trc))+24*ms2**2*trs+mc2**2*(-462*trs+419*trg
& -229*trc))*gDs**2+mc2*ms2*(3*mc2*(78*trsgc+4*ms2*trs+70*ms2*trg
& -3*ms2*trc)-6*ms2**2*(trs+trg)+mc2**2*(46*trg-62*trs))*gDs+27*m
& c2**2*ms2**3*trc)+2*cDs*gDs*(1872*(trg+trc)*gDs**4+72*(-4*trsgc
& +9*mc2*trs+13*ms2*(trg+trc)-10*mc2*trg)*gDs**3+4*(-mc2*(36*trsg
& c+ms2*(-75*trs+245*trg+119*trc))-36*ms2*trsgc+3*ms2**2*(4*trs+3
& *(trg+trc))+108*mc2**2*trs)*gDs**2+ms2*(mc2*(72*trsgc-ms2*(6*tr
& s+304*trg+223*trc))+6*mc2**2*(33*trs+43*trg+5*trc)+6*ms2**2*(4*
& trs+3*(trg+trc)))*gDs+3*mc2*ms2**2*(24*trsgc+ms2*(trs+trg+3*trc
& )+mc2*(-3*trs+43*trg+5*trc)))+cDs**2*(2*gDs+ms2)*(936*(trg+trc)
& *gDs**3-36*(4*trsgc-9*mc2*trs+10*mc2*trg)*gDs**2+3*mc2*(12*trsg
& c+ms2*(12*trg+trc))*gDs-19*mc2*ms2**2*trc)-8*mc2*ms2*trc*cDs**3
& *(2*gDs+ms2))+2*ms2*cDg**5*(mc2*(6*(32*trs+101*trc)*gDs**4+(-14
& 4*trsgc+8*mc2*(9*trs+19*trc)+84*ms2*trs-264*ms2*trg-491*ms2*trc
& )*gDs**3+(2*mc2*(45*trsgc+62*ms2*trs+107*ms2*trg+46*ms2*trc)-ms
& 2*(36*trsgc+6*ms2*trs+132*ms2*trg+865*ms2*trc))*gDs**2+ms2*(mc2
& *(99*trsgc+ms2*(28*trs+181*trg-12*trc))-6*ms2*(ms2*(trs+trg+39*
& trc)-9*trsgc))*gDs+ms2**2*(mc2*(27*trsgc-8*ms2*trs+37*ms2*trg-1
& 0*ms2*trc)+18*ms2*trsgc))+cDs*(-4*(4*mc2*(6*trs+10*trg+3*trc)-9
& *ms2*trc)*gDs**3+2*mc2*(54*trsgc+40*ms2*trs+60*ms2*trg-9*mc2*(t
& rc-4*trg)+207*ms2*trc)*gDs**2+mc2*ms2*(90*trsgc+64*ms2*trs+136*
& ms2*trg-9*mc2*(trc-4*trg)+219*ms2*trc)*gDs+18*mc2*ms2**2*(trsgc
& +ms2*trg))-6*cDs**2*(2*gDs+ms2)*(21*trc*gDs**2+(-9*trsgc-6*mc2*
& trg-22*ms2*trc+9*mc2*trc)*gDs+3*mc2*(trsgc+ms2*trg))+36*(trs+tr
& g)*cDs**3*gDs*(2*gDs+ms2))+2*mc2*cDg*gDs**3*(2*gDs+ms2)*(18*mc2
& *(15*trg+13*trc)*gDs**4+cDs*(12*(2*ms2*trs+mc2*(-2*trs+45*trg+3
& 9*trc))*gDs**3-12*(mc2*(6*trsgc+ms2*(7*trs+trg+trc))-ms2**2*(6*
& trs+trg+trc)+mc2**2*(6*trg-trs))*gDs**2+(-3*mc2**2*(18*trsgc-6*
& ms2*trs+41*ms2*trg+23*ms2*trc)+30*ms2**3*trs+70*mc2**3*trs+9*mc
& 2*ms2**2*(-4*trs+trg+trc))*gDs+18*mc2**2*ms2*(trsgc+mc2*trg))-1
& 2*(mc2*(3*trsgc+ms2*(2*trs+trg+trc))-ms2**2*(2*trs+trg+trc)+3*m
& c2**2*trg)*gDs**3+3*(-3*mc2**2*(6*trsgc+29*ms2*trg+15*ms2*trc)+
& 2*ms2**3*(4*trs+trg+trc)+12*mc2**3*trs+mc2*ms2**2*(-8*trs-3*(tr
& g+trc)))*gDs**2+6*cDs**2*gDs*((8*ms2*trs+mc2*(-8*trs+45*trg+39*
& trc))*gDs-2*mc2*(3*trsgc+5*ms2*trs)+mc2**2*(2*trs-6*trg)+8*ms2*
& *2*trs)-24*(mc-ms)*(ms+mc)*trs*cDs**3*gDs+ms2*(6*ms2**3-6*mc2*m
& s2**2+6*mc2**2*ms2-43*mc2**3)*trs*gDs+18*mc2**3*ms2*(trsgc+ms2*
& trg))+2*mc2**2*gDs**4*(2*gDs+ms2)*(18*mc2*trg*gDs**3+12*(ms2*tr
& s-mc2*trs+3*mc2*trg)*cDs*gDs**2+6*ms2*(ms2-mc2)*(2*trs+trg+trc)
& *gDs**2+6*cDs**2*(3*mc2*trg*gDs+(mc-ms)*(ms+mc)*trs*(-4*gDs-4*m
& s2+mc2))-9*mc2**2*trsgc*(gDs+cDs+ms2)+6*(mc-ms)*(ms+mc)*(mc2*tr
& s-ms2*(6*trs+trg+trc))*cDs*gDs+mc2**2*ms2*(6*trs+2*trg+29*trc)*
& gDs+3*ms2**3*(4*trs+trg+trc)*gDs-6*mc2*ms2**2*(3*trs+trg+trc)*g
& Ds-12*(mc-ms)*(ms+mc)*trs*cDs**3+15*ms2**3*trs*cDs-24*mc2*ms2**
& 2*trs*cDs+5*mc2**3*trs*cDs-3*mc2**2*ms2*(3*trg-4*trs)*cDs-mc2**
& 3*ms2*(11*trs+9*trg)+3*ms2**4*trs-6*mc2*ms2**3*trs+6*mc2**2*ms2
& **2*trs)-2*ms2*cDg**6*(2*gDs+ms2)*(-mc2*((72*(trs+2*trg)+89*trc
& )*gDs**2+(117*trsgc+ms2*(108*trs+234*trg+97*trc)+90*mc2*trg)*gD
& s+2*ms2*(27*trsgc-8*ms2*trs+19*ms2*trg+18*mc2*trg-10*ms2*trc))+
& 6*cDs*(42*trc*gDs**2+(-18*trsgc+3*mc2*(3*trs-trg+5*trc)-49*ms2*
& trc)*gDs+6*mc2*(trsgc+ms2*trg))+36*cDs**2*(2*trc*gDs+trsgc+(ms2
& +mc2)*trg))-36*ms2*cDg**7*(2*gDs+ms2)*(7*trc*gDs**2+cDs*((6*(tr
& s+trg)+8*trc)*gDs+4*(trsgc+(ms2+mc2)*trg))+(2*mc2*(trs-4*trg+tr
& c)-3*(trsgc+3*ms2*trc))*gDs+4*trg*cDs**2+mc2*(trsgc-3*ms2*trg))
& -72*ms2*cDg**8*(2*gDs+ms2)*(2*(trs+trg+trc)*gDs+trg*(4*cDs+ms2+
& mc2)+trsgc)-144*ms2*trg*cDg**9*(2*gDs+ms2))/(mc2*ms*cDg**3*(2*c
& Dg+mc2)*gDs**3*(2*gDs+ms2))/2.4d+1+Bpmm
Bpmm = B0cgsf*(cDg**4*(-2*mc2*(4*trs*gDs**4+ms2*(3*trs-5*trg-11*t
& rc)*gDs**3+ms2*(2*mc2*(trs+trg)+ms2*(trs+5*trc))*gDs**2+ms2**2*
& (2*trsgc+ms2*(trs+13*trc))*gDs-ms2**3*(trsgc+mc2*trg))+cDs*(-2*
& (4*mc2*trs+7*ms2*trc)*gDs**3+ms2*(6*(trsgc+3*ms2*trc)+mc2*(-16*
& trs+16*trg+7*trc))*gDs**2+4*mc2*ms2**2*(2*trs+3*trg+2*trc)*gDs+
& 2*mc2*ms2**2*(trsgc+ms2*trg))+2*ms2*cDs**2*gDs*((2*(trs+trg)-7*
& trc)*gDs+3*trsgc+2*mc2*trg+9*ms2*trc-3*mc2*trc)+4*ms2*(trs+trg)
& *cDs**3*gDs)+mc2*cDg**2*gDs**2*(4*(9*trs+7*trg+13*trc)*gDs**4-(
& 12*trsgc-16*mc2*trs+55*ms2*trg+8*mc2*trg+51*ms2*trc)*gDs**3+cDs
& *gDs*(4*(18*trs+trg+13*trc)*gDs**2-(8*(trsgc+mc2*(trg-3*trs))+m
& s2*(23*trg+22*trc))*gDs+ms2*(8*trsgc+ms2*(2*(trs+trg)+3*trc)-4*
& mc2*trs+12*mc2*trg))+(-mc2*(8*trsgc+ms2*(40*trs-24*trg+7*trc))+
& ms2*(8*trsgc+ms2*(2*trs-trg+trc))+8*mc2**2*trs)*gDs**2+cDs**2*(
& 4*gDs*(9*trs*gDs-6*trg*gDs+trsgc)+4*ms2*trg*gDs-2*ms2**2*trc)-2
& *ms2*(2*mc2*(ms2*(-trs-3*trg+trc)-2*trsgc)+ms2**2*(trs+trg)+4*m
& c2**2*trs)*gDs-ms2*trc*cDs**3+3*mc2*ms2**3*trc)+mc2*cDg**3*gDs*
& (-4*(6*trg-7*trs)*gDs**4-2*cDs*(2*(6*trg-5*trs)*gDs**3-(2*trsgc
& -5*ms2*trs+11*ms2*trg+6*ms2*trc)*gDs**2-ms2*(trsgc-ms2*trs+2*mc
& 2*trs-2*ms2*trg+5*ms2*trc)*gDs+2*ms2**2*(trsgc+mc2*trg))+(-4*tr
& sgc+16*mc2*trs+ms2*(-38*trs+31*trg+8*trc))*gDs**3-cDs**2*(8*trs
& *gDs**2+ms2*(8*trs-8*trg-3*trc)*gDs+2*ms2*(trsgc+ms2*trg))+ms2*
& (8*trsgc+2*ms2*trs-4*mc2*(trg+2*trc)+10*ms2*trg+9*ms2*trc)*gDs*
& *2+2*ms2*(mc2*(trsgc-ms2*(2*trs+9*trg+2*trc))+ms2**2*(trs+trg))
& *gDs-2*mc2*ms2**2*(trsgc+ms2*trg))+2*mc2*cDg*gDs**3*(26*(trg+tr
& c)*gDs**4+cDs*(52*(trg+trc)*gDs**3-2*(4*trsgc+3*mc2*trg)*gDs**2
& +(-2*mc2*(2*trsgc+ms2*(trs+7*trg+5*trc))+ms2**2*(4*trs+3*(trg+t
& rc))+6*mc2**2*trs)*gDs+2*mc2*ms2*(trsgc+mc2*trg))-2*(2*trsgc+mc
& 2*trg)*gDs**3+(-2*mc2*(2*trsgc+ms2*(2*trs+14*trg+11*trc))+ms2**
& 2*(4*trs+trg+trc)+4*mc2**2*trs)*gDs**2+2*cDs**2*gDs*(13*(trg+tr
& c)*gDs-2*(trsgc+mc2*trg))+(2*mc2*ms2*(trsgc-ms2*trs)+mc2**2*(ms
& 2*(trg-2*trs)-trsgc)+2*ms2**3*trs)*gDs+2*mc2**2*ms2*(trsgc+ms2*
& trg))+2*mc2*gDs**4*(2*mc2*trg*gDs**3+4*(ms2*trs+mc2*(trg-trs))*
& cDs*gDs**2+2*ms2*(ms2-mc2)*(2*trs+trg+trc)*gDs**2+2*cDs**2*(mc2
& *trg*gDs+(mc-ms)*(ms+mc)*trs*(-4*gDs-4*ms2+mc2))-mc2**2*trsgc*(
& gDs+cDs+ms2)+2*(mc-ms)*(ms+mc)*(mc2*trs-ms2*(6*trs+trg+trc))*cD
& s*gDs+ms2**3*(4*trs+trg+trc)*gDs-2*mc2*ms2**2*(3*trs+trg+trc)*g
& Ds+mc2**2*ms2*(2*trs+trg+4*trc)*gDs+4*(ms2-mc2)*trs*cDs**3+5*ms
& 2**3*trs*cDs-8*mc2*ms2**2*trs*cDs-mc2**2*ms2*(trg-4*trs)*cDs-mc
& 2**3*ms2*(2*trs+trg)+ms2**4*trs-2*mc2*ms2**3*trs+2*mc2**2*ms2**
& 2*trs)+ms2*cDg**5*(-14*trc*gDs**3+(6*(trsgc+3*ms2*trc)+mc2*(-4*
& trs+12*trg+9*trc))*gDs**2-2*cDs*gDs*(2*(trs+trg+9*trc)*gDs-4*tr
& sgc+2*ms2*trg-4*mc2*trg-18*ms2*trc+3*mc2*trc)-4*cDs**2*(2*trc*g
& Ds+trsgc+ms2*trg)+2*mc2*(3*trsgc+ms2*(6*trs+11*trg+trc))*gDs-2*
& mc2*ms2*(ms2*(trs-2*trg+trc)-3*trsgc))-2*ms2*cDg**6*((4*(trs+tr
& g)+11*trc)*gDs**2+2*cDs*((3*trs+5*trg+4*trc)*gDs+2*(trsgc+ms2*t
& rg))-(trsgc-2*ms2*trg+6*mc2*trg+9*ms2*trc)*gDs+4*trg*cDs**2-4*m
& c2*ms2*trg)-4*ms2*cDg**7*(2*(trs+2*trg+trc)*gDs+4*trg*cDs+trsgc
& +ms2*trg)-8*ms2*trg*cDg**8)/(mc2*ms*cDg**3*gDs**3)/8.0d+0+Bpmm
Bpmm = tr3s00ft*(cDg**2*(12*(2*trg-3*trs)*gDs**4+cDs*(24*(2*trg-3
& *trs)*gDs**3+37*ms2*(trg+trc)*gDs**2-2*ms2*(4*trsgc-9*mc2*trs+8
& *mc2*trg)*gDs+2*mc2*ms2*(trsgc+ms2*trg))+(4*trsgc-16*mc2*trs+10
& 5*ms2*trg+101*ms2*trc)*gDs**3+2*ms2*(mc2*(27*trs-19*trg+trc)-8*
& trsgc)*gDs**2+4*cDs**2*gDs*(-9*trs*gDs+6*trg*gDs-trsgc-ms2*trg)
& +2*mc2*ms2*(-7*trsgc+4*mc2*trs-7*ms2*trg-2*ms2*trc)*gDs+2*mc2*m
& s2**2*(trsgc+mc2*trg))-2*cDg*gDs*(26*(trg+trc)*gDs**4+cDs*(52*(
& trg+trc)*gDs**3-8*(trsgc+mc2*trg)*gDs**2+mc2*(-4*trsgc+2*mc2*tr
& s-17*ms2*trg-13*ms2*trc)*gDs+2*mc2*ms2*(trsgc+mc2*trg))-4*(trsg
& c+mc2*trg)*gDs**3+mc2*(-4*trsgc+4*mc2*trs-27*ms2*trg-19*ms2*trc
& )*gDs**2+2*cDs**2*gDs*(13*(trg+trc)*gDs-2*(trsgc+mc2*trg))+mc2*
& ms2*(2*trsgc-9*mc2*trs+mc2*trg)*gDs+2*mc2**2*ms2*(trsgc+ms2*trg
& ))+cDg**3*(8*trs*gDs**3+2*cDs*(16*trs*gDs**2+ms2*(15*trs-4*trg+
& 4*trc)*gDs+ms2*(4*trsgc-2*mc2*trs+5*ms2*trg+3*ms2*trc))+ms2*(78
& *trs-59*trg-3*trc)*gDs**2+8*trs*cDs**2*gDs-2*ms2*(4*trsgc-7*mc2
& *trs+6*ms2*trg+4*ms2*trc)*gDs+2*ms2**2*(2*trsgc+5*mc2*trg))+2*m
& c2*gDs**2*(-2*trg*gDs**3-4*trg*cDs*gDs**2+(mc2*(trsgc-2*ms2*trg
& -5*ms2*trc)-2*trg*cDs**2)*gDs+mc2*((trsgc+ms2*trg)*cDs+ms2*(trs
& gc+3*mc2*trs+mc2*trg)))+2*ms2*cDg**4*(-5*trs*gDs-4*trs*cDs+7*ms
& 2*trg+ms2*trc))/(ms*cDg**3*gDs)/2.0d+0+Bpmm
Bpmm = lc*(cDg**2*(52*(trg+trc)*gDs**4+2*cDs*(26*(trg+trc)*gDs**3
& +(-4*trsgc+9*mc2*trs-10*mc2*trg)*gDs**2+mc2*(trsgc-7*ms2*trg)*g
& Ds+2*mc2**2*ms2*trg)-2*(4*trsgc-9*mc2*trs+10*mc2*trg)*gDs**3+2*
& mc2*(-5*trsgc+8*mc2*trs-ms2*trg)*gDs**2-6*mc2**2*ms2*trg*gDs+mc
& 2**2*ms2*(trsgc+ms2*trg))-2*cDg**3*(6*(2*trg-3*trs)*gDs**3+2*(t
& rg*(6*cDs+ms2)-3*trs*(3*cDs+mc2)+trsgc)*gDs**2-(mc2*(ms2*(trg+t
& rc)-2*trs*cDs)+2*(trsgc-3*ms2*trg)*cDs)*gDs+mc2*ms2*(-2*trg*(4*
& cDs+ms2)-trsgc+mc2*trs))+2*mc2*cDg*gDs*((15*trg+13*trc)*gDs**3+
& cDs*((15*trg+13*trc)*gDs**2-2*(trsgc+mc2*trg)*gDs-2*mc2*ms2*trg
& )-2*(trsgc+mc2*trg)*gDs**2+mc2*(-3*trsgc+2*mc2*trs+ms2*trg)*gDs
& -mc2**2*ms2*trg)+mc2**2*gDs**2*(2*trg*gDs**2+2*trg*cDs*gDs-mc2*
& trsgc+mc2*ms2*trg)+2*cDg**4*(ms2*((5*trg+trc)*gDs+2*trg*(4*cDs+
& ms2))-trs*(4*gDs*(gDs+cDs)+3*mc2*ms2))-4*ms2*trs*cDg**5)/(ms*cD
& g*(2*cDg+mc2)**2*gDs)/2.0d+0+Bpmm
Bpmm = LsB2*ms*(2*mc2**3*trg*cDs*gDs**4+mc2*cDg**2*gDs**2*(mc2*(2
& *(mc2*trs+ms2*trc)*gDs-ms2*(trsgc+3*mc2*trg))+cDs**2*(4*trc*gDs
& -2*trsgc+6*mc2*trg)+12*trg*cDs**3+3*mc2*(trsgc-ms2*trg)*cDs)+cD
& g**3*gDs*(3*mc2*cDs*(ms2*(trsgc+3*mc2*trg)-2*(mc2*trs+ms2*trc)*
& gDs)-8*trg*cDs**4-12*mc2*trg*cDs**3+2*mc2*(ms2*trg-3*trsgc)*cDs
& **2+mc2**2*ms2*(3*trsgc+ms2*trg))-mc2**2*cDg*gDs**3*(cDs*(2*trc
& *gDs-trsgc+mc2*trg)+8*trg*cDs**2+mc2*(trsgc-ms2*trg))+cDg**4*(2
& *mc2*(6*trs*cDs**2-3*mc2*ms2*trs+ms2**2*trc)*gDs+8*trg*cDs**4+4
& *(trsgc+ms2*trg)*cDs**3-8*mc2*ms2*trg*cDs**2-3*mc2*ms2*(trsgc+m
& s2*trg)*cDs+mc2*ms2**2*(mc2*trg-trsgc))+cDg**5*(6*mc2*ms2*trs*c
& Ds-8*trs*cDs**3))/(cDg**3*(cDs**2-mc2*ms2)*gDs)+Bpmm
Bpmm = Bpmm-ls*ms*(-2*cDg**2*(mc2*(-8*trs*gDs**3+2*(trsgc-2*ms2*
& trs+ms2*trg)*gDs**2+ms2*(3*trsgc-2*ms2*trs-3*ms2*trg)*gDs+ms2**
& 2*(trsgc-ms2*trg))+cDs*gDs*(-14*trc*gDs**2+(6*trsgc+4*mc2*trg+5
& *ms2*trc)*gDs+ms2*(3*trsgc+2*mc2*trg+9*ms2*trc))+2*(trs+trg)*cD
& s**2*gDs*(2*gDs+ms2))-mc2*cDg*gDs*(10*trc*gDs**3+(8*(-2*trs*cDs
& +4*trg*cDs+trsgc)+ms2*trc)*gDs**2+(4*ms2*(-2*trs*cDs+11*trg*cDs
& +3*trsgc)-4*trsgc*cDs-3*ms2**2*trc)*gDs+2*ms2*(-trsgc*cDs+7*ms2
& *trg*cDs+2*ms2*trsgc))+mc2*gDs**2*(trc*cDs*(-2*gDs**2+3*ms2*gDs
& +3*ms2**2)+2*mc2*(2*gDs+ms2)*(-2*trs*gDs+4*trg*gDs-trsgc+3*ms2*
& trg))+2*cDg**3*(2*gDs+ms2)*(2*cDs*((trs+trg+2*trc)*gDs+trsgc+ms
& 2*trg)+gDs*(7*trc*gDs-3*trsgc-2*mc2*trg-9*ms2*trc))+4*cDg**4*(2
& *gDs+ms2)*(2*(trs+trg+trc)*gDs+2*trg*cDs+trsgc+ms2*trg)+8*trg*c
& Dg**5*(2*gDs+ms2))/(mc2*cDg*gDs*(2*gDs+ms2)**2)/4.0d+0
Bpmm = ms*tr3c00fs*(-2*cDg**2*(mc2*(17*trc*gDs**3-2*(2*trsgc+2*mc
& 2*trg+9*ms2*trc)*gDs**2-13*ms2**2*trc*gDs+ms2**2*(trsgc+mc2*trg
& ))+mc2*cDs*(4*(trg+2*trc)*gDs**2+2*ms2*(6*trs+7*trg+2*trc)*gDs+
& ms2*(trsgc+ms2*trg))+cDs**2*gDs*(-7*trc*gDs+3*trsgc+2*mc2*trg)+
& 2*(trs+trg)*cDs**3*gDs)+2*cDg**3*(-mc2*(4*(trs+2*trg+2*trc)*gDs
& **2+(5*trsgc+6*ms2*trs+13*ms2*trg)*gDs+ms2*(3*trsgc-3*ms2*trs-2
& *ms2*trc))+cDs*gDs*(14*trc*gDs-6*trsgc-4*mc2*trg-9*ms2*trc)+2*c
& Ds**2*(2*trc*gDs+trsgc+ms2*trg))+2*mc2*cDg*gDs*(mc2*(4*(trg+trc
& )*gDs**2+(trsgc+3*ms2*trs+6*ms2*trg+2*ms2*trc)*gDs+ms2*(trsgc+m
& s2*trg))+cDs*(-17*trc*gDs**2+4*(trsgc+mc2*trg-2*ms2*trc)*gDs+2*
& ms2*(trsgc+mc2*trg))+cDs**2*(4*(trs+trg)*gDs+trsgc+ms2*trg))+mc
& 2**2*gDs**2*(20*trc*gDs**2+(5*ms2*trc-2*(2*(trs+trg)*cDs+trsgc+
& 2*mc2*trg))*gDs-2*ms2*(trg*(cDs+mc2)+trsgc)-2*trsgc*cDs-3*ms2**
& 2*trc)+2*cDg**4*(7*trc*gDs**2+cDs*((6*(trs+trg)+8*trc)*gDs+4*(t
& rsgc+ms2*trg))-(3*trsgc+10*mc2*trg+9*ms2*trc)*gDs+4*trg*cDs**2-
& 4*mc2*ms2*trg)+4*cDg**5*(2*(trs+trg+trc)*gDs+4*trg*cDs+trsgc+ms
& 2*trg)+8*trg*cDg**6)/(mc2*cDg*gDs**3)/2.0d+0+Bpmm
Bpmm = BfunX*(-ms2*cDg**4*gDs*(mc2*((2*(trs+trg)+3*trc)*gDs**2+ms
& 2*(2*(trs+trg)+trc)*gDs-2*ms2**2*(trs+trg))+cDs*(12*trc*gDs**2+
& mc2*(4*trs+9*trc)*gDs+4*mc2*ms2*(trs+trg))+6*trc*cDs**2*(4*gDs+
& mc2)+12*trc*cDs**3)-mc2*ms2*cDg**2*gDs**2*(gDs*((20*trs+3*trg+7
& *trc)*gDs**2+ms2*(6*trs-5*trg+trc)*gDs-2*ms2**2*(trs+trg))+cDs*
& *2*((4*(trs+trg)+11*trc)*gDs+ms2*trc)+cDs*gDs*(24*trs*gDs+7*trg
& *gDs+17*trc*gDs-2*ms2*trs-2*ms2*trg+6*ms2*trc)+trc*cDs**3)-ms2*
& cDg**5*(-mc2*(trc*gDs**2+2*ms2*(2*(trs+trg)+trc)*gDs+2*ms2**2*(
& trs+trg+trc))+6*trc*cDs*gDs*(4*gDs+mc2)+24*trc*cDs**2*gDs)-mc2*
& ms2*cDg**3*gDs**2*((6*trs+trg+7*trc)*gDs**2+2*cDs*((trs-trg+5*t
& rc)*gDs+ms2*(trs-trg))+2*ms2*(trs+trg+2*trc)*gDs-(4*trs+8*trg+3
& *trc)*cDs**2+2*ms2**2*(trs+trg))-2*mc2*cDg*gDs**4*(2*(gDs+cDs)+
& ms2)*(2*trs*(cDs+2*ms2)*(2*(gDs+cDs)+ms2)+3*ms2*(trg+trc)*(gDs+
& cDs))-2*mc2*gDs**4*(2*(gDs+cDs)+ms2)**2*(trs*(cDs+ms2)*(2*(gDs+
& cDs)+ms2)+ms2*(trg+trc)*gDs)-12*ms2*trc*cDg**6*cDs*gDs)/(mc2*ms
& *cDg**3*gDs**3)/8.0d+0+Bpmm
Bpmm = Bpmm-LsB1*ms*(cDg**2*gDs**2*(mc2*cDs*(12*trc*gDs**2+2*(-3
& *trsgc+3*ms2*trs-ms2*trg+5*ms2*trc)*gDs+ms2*(trsgc-5*ms2*trg))+
& 4*cDs**2*(-2*trc*gDs**2+(trsgc+mc2*trg-2*ms2*trc)*gDs+ms2*(trsg
& c+2*mc2*trg))+mc2*ms2*(-4*trc*gDs**2+2*(trsgc+mc2*trg-2*ms2*trc
& )*gDs+ms2*(mc2*trg-trsgc))+cDs**3*(8*(trg+trc)*gDs-4*trsgc+8*ms
& 2*trg))-cDg**3*gDs*(2*cDs**2*(4*trc*gDs**2-2*trsgc*gDs+2*ms2*(t
& rs+trg+4*trc)*gDs-3*ms2*trsgc+ms2**2*trg)+mc2*ms2*(4*trc*gDs**2
& +2*(ms2*(-trs-trg+trc)-trsgc)*gDs+ms2*(trsgc-ms2*trg))+ms2*cDs*
& (-4*trc*gDs**2+2*(trsgc+mc2*trg-2*ms2*trc)*gDs+ms2*(trsgc+3*mc2
& *trg)))-mc2*cDg*gDs**3*(mc2*(4*trc*gDs**2+2*(ms2*(3*trs-trg+trc
& )-trsgc)*gDs+ms2*(trsgc-5*ms2*trg))+cDs*(-12*trc*gDs**2+6*(trsg
& c+mc2*trg-2*ms2*trc)*gDs+ms2*(3*trsgc+5*mc2*trg))+4*cDs**2*(2*t
& rg*(gDs+ms2)+trc*gDs)+4*trg*cDs**3)+mc2*gDs**4*(-4*mc2*trc*gDs*
& *2+2*mc2*((trs+trg)*cDs+trsgc+mc2*trg-2*ms2*trc)*gDs+2*(mc2*trg
& -trsgc)*cDs**2+mc2*(trsgc+ms2*trg)*cDs+mc2*ms2*(3*trsgc+mc2*trg
& ))+2*ms2*cDg**4*cDs*(trc*gDs*(2*gDs+3*ms2)-trsgc*(gDs+ms2)))/(c
& Dg*(cDs-mc*ms)*(cDs+mc*ms)*gDs**3)
Bpmm = Bpmm-B0csf*ms*(mc2*gDs*(mc2*(2*trc*gDs**2+(-trsgc-mc2*trs
& +ms2*(trg-trs))*gDs+ms2*(ms2+mc2)*trg)+cDs*(2*trc*gDs**2+(-trsg
& c+mc2*(-2*trs-trg+trc)+ms2*trc)*gDs+2*mc2*ms2*trg)+cDs**2*(2*tr
& c*gDs-trg*(2*gDs+ms2+mc2))-2*trg*cDs**3)+cDg*(2*mc2*cDs*(-2*trc
& *gDs**2+(trsgc+ms2*(trs-trg)+mc2*trs)*gDs-ms2*(trsgc+(ms2+mc2)*
& trg))+cDs**2*(-4*trc*gDs**2+2*(trsgc+mc2*(2*trs+trg-trc)-ms2*tr
& c)*gDs+mc2*(trsgc-4*ms2*trg)+ms2*trsgc)+2*cDs**3*(trg*(2*gDs+ms
& 2+mc2)-2*trc*gDs+trsgc)+4*trg*cDs**4-mc2*ms2*(ms2+mc2)*trsgc)+c
& Dg**2*(ms2*cDs*(2*trc*gDs-trsgc+mc2*(2*trs-trg+trc)+ms2*trc)+mc
& 2*ms2*(2*trc*gDs-trsgc+ms2*(trs+trg)+mc2*trs)-4*trs*cDs**3+2*(m
& s2*(-trs-trg+trc)-mc2*trs)*cDs**2))/(cDg*(cDs-mc*ms)*(cDs+mc*ms
& )*gDs)/2.0d+0
Bpmm = tr3s002ft*(6*trs*(2*cDg+mc2)*cDs*((2*cDg+mc2)**2*gDs**2+ms
& 2*cDg**3)+3*ms2*(trg+trc)*cDg**2*gDs*(mc2*(gDs+6*cDs)+10*cDg*cD
& s))/(ms*cDg**3*gDs)/2.0d+0+Bpmm
Bpmm = 3.0d+0*ms*tr3c002fs*(trc*cDg**3*(gDs**2+2*ms2*gDs+2*ms2**2
& )+cDg*cDs*(3*trc*cDs-4*mc2*(trs+trg))*gDs**2-cDg**2*gDs*(3*trc*
& cDs*gDs+2*mc2*ms2*(trs+trg))+gDs**2*(2*mc2**2*(trs+trg)*gDs-trc
& *cDs**3))/(2.0d+0*cDg*gDs**3)+Bpmm
Bpmm = 3.0d+0*ms*tr3c001fs*(-mc2*ms2*trc*cDs**2*gDs**2+2*mc2*cDg*
& gDs**2*(mc2*(trs+trg)*(2*gDs+ms2)-ms2*trc*cDs)-cDg**2*gDs*(8*mc
& 2*(trs+trg)*cDs*(gDs+ms2)+mc2*ms2*trc*gDs-6*ms2*trc*cDs**2)+2*m
& s2*cDg**3*(3*trc*cDs*gDs+mc2*ms2*(trs+trg)))/(2.0d+0*mc2*cDg*gD
& s**3)+Bpmm
Bpmm = epinv*(4*lp*xs*cDs+mc*(ms-ms*xs**2))*(2*trc*cDg*gDs-mc2*tr
& g*gDs-trsgc*cDg)*(mc2*gDs**2-2*cDg*cDs*gDs+ms2*cDg**2)/(mc*(xs*
& *2-1)*cDg**2*gDs**2)/4.0d+0+Bpmm
Bpmm = ms*tr2fu*cDs*(2*trc*cDg*gDs-mc2*trg*gDs-trsgc*cDg)*(mc2*gD
& s**2-2*cDg*cDs*gDs+ms2*cDg**2)/(cDg**2*gDs**2)+Bpmm
Bpmm = tr3s001ft*(3*ms*(trg+trc)*(2*ms2*cDg**3*cDs-gDs**2*(2*mc2*
& cDg*(gDs-3*cDs)+cDg**2*(gDs-7*cDs)+2*mc2**2*gDs))+6*ms*trs*gDs*
& (cDg**3*(gDs+5*cDs)+3*mc2*cDg**2*(gDs+cDs)+3*mc2**2*cDg*gDs+mc2
& **3*gDs))/(cDg**3*gDs)/2.0d+0+Bpmm
Bpmm=Bpmm/zpmm
return
end
| MCFM-JHUGen/src/Stopb/Bpmm.f |
These are reviews of Friendly Cab from before 2009. For more current reviews, visit Friendly Cab the entry.
Im a Tipsy Taxi supervisor and Friendly Cab put my driver in harms way by purposefully trying to run their friendly cab into one of our Tipsy Vans. Id be scared to ride their services. Users/JoAnnaRich
To facilitate safety improvement, it would have been appropriate for JoAnna to report the incident to Friendly management.
Its valuable costwise to know that a group of students might pay less than they would Tipsy Taxi, by riding a nonstudentsubsidized taxi, particularly an 8 passenger Friendly Cab. Users/BruceHansen
20060522 22:39:50 nbsp Probably the best taxi service that has ever blessed me with a drive to the airport! My driver was very friendly and punctual, and even carried on an intersting conversation. My driver even called me when I was waiting at the airport to make sure I made my flight. I recommende Friendly Cab anytime! Users/MickMorrison
20061109 08:20:01 nbsp I scheduled a ride with Friendly Cab for this morning, who was to arrive at 7:00 AM and get us to the Sacramento Airport by 7:30. At 7:08, I called the cab driver to see why he had not arrived yet, and he said that he was just around the corner I called again at 7:18 and he said that he was just a block away, and I asked, so when I called you before you werent around the corner? and he said, well, I was down the road. The road was Pole Line, which goes all the way to Woodland. And judging by how long it took to get to Woodland, he may have been in Woodland when I first called. We arrived at the airport at almost 7:45, and still had to pay the full $35. Next time, Ill take the shuttle. (commenting from the airport) Users/KarlMogel
20070326 11:03:01 nbsp I only rode friendly cab once whilst drunk and getting home from G st Pub. The driver packed about 7 of us in a 4 person cab with someone in the trunk. One of the guys was smoking a blunt in the cab and the driver definately partook while he was driving. There were also open containers in the cab that didnt belong to anyone from the pub. This was about a year and a half ago so I dont know if the driver still works there, but it was definately the scariest and most memorable cab ride ive had in the united states. Users/AllanRae
20070927 10:23:08 nbsp Only good experiences with Friendly Cab. My sister and I were using them a lot a couple weeks ago, when she was sick and needed to go to the hospital/school. Bruce is very nice and prompt (usually picking us up in 57 minutes). They are trying out a Prius because it costefficient and better for the environment. I thought that was cool. Users/CalamityJanie
20080101 19:25:24 nbsp Im hearing some inconsistent points of view here. Users/thelonepiper555
I have had inconsistent experiences, so Im not surprised.Users/AaronRosenberg AR
20080128 20:20:39 nbsp They sucked! I called for them to pick me up at the Amtrak Station in Davis after winter break, and when I arrived with luggage and a bike in tow (I had asked for a car large enough to fit everything) the driver showed up all right, but he was already loading other people / luggage in the car. Obviously, I wouldnt fit, so he just asked me to WAIT there in the RAIN for him to drop off the other folks before coming back to pick me up. I told him to go to hell (okay, not really) and just got a ride from a stranger instead. Users/eda
20080419 20:59:12 nbsp these guys are rude
they were so mean to me on the phone and i would totally get fired if i talked to a customer like that at my job
i wouldnt take them if village cab wasnt such a long ride Users/JackkiCox
20080518 00:28:52 nbsp Not friendly at all. Period. The drivers may be okay, but the dispatcher sounds like hes on drugs, and is just plain rude. Id rather walk. Users/eda
20081209 21:17:25 nbsp I called this morning, and they arrived in about 5~10 minutes. The driver was very friendly too fast, and definitely recommend. :) Users/EvelinaChang
| lab/davisWiki/Pre_2009_Reviews.f |
!=========================================================================
! SUBRUTINA PARA EL CALCULO DE FUERZAS DE INTERACCION Y ENERGIA DE LA
! CONFIGURACION PARA LA SIMULACION DE DINAMICA BROWNIANA
!
! AUTOR : MARTIN ALEJANDRO PAREDES SOSA
!=========================================================================
Subroutine Fuerza(L)
Use cte
Implicit None
Real :: EnePot, U, U2, U3 !ENERGIA
Real :: FXI, FYI, FZI, fxij, fyij, fzij !FUERZAS TEMP
Real :: xij, yij, zij, rij !POSICIONES
Real :: Pres, Pres1
Integer :: i, j, L !CONTADORES ("L" CONTADOR DE LA CONFIGURACION)
Logical :: Ctrl1, Ctrl2
!INICIALIZANDO
EnePot = 0.0
FX = 0.0
FY = 0.0
FZ = 0.0
Pres1 = 0.0
Parti1: Do i = 1, N - 1
FXI = FX(i)
FYI = FY(i)
FZI = FZ(i)
Parti2: Do j = i + 1, N
!SEPARACION
xij = X(i) - X(j)
yij = Y(i) - Y(j)
zij = Z(i) - Z(j)
!CONDICION DE IMAGEN MINIMA
xij = xij - BoxL * Anint( xij / BoxL )
yij = yij - BoxL * Anint( yij / BoxL )
zij = zij - BoxL * Anint( zij / BoxL )
!DISTANCIA
rij = sqrt( xij*xij + yij*yij + zij*zij )
!TRASLAPES
Ctrl1 = rij .LE. 1.0
Traslape : If(Ctrl1) Then
Write(*,*) "TRASLAPE", i, j
End If Traslape
!IMPLEMENTACION DEL POTENCIAL
Ctrl2 = rij .LT. RCut
Potencial: If(Ctrl2) Then
U = Exp( -YukZk * rij )
U2 = YukA * U * (YukZk * rij + 1.0 ) / (rij**3)
U3 = U2 * rij * rij
EnePot = (YukA * U) / rij + EnePot
fxij = xij * U2
fyij = yij * U2
fzij = zij * U2
FXI = FXI + fxij
FYI = FYI + fyij
FZI = FZI + fzij
FX(j) = FX(j) - fxij
FY(j) = FY(j) - fyij
FZ(j) = FZ(j) - fzij
!PRECALCULO DE PRESION
Pres1 = Pres1 + U3
End If Potencial
End Do Parti2
!GUARDANDO FUERZA
FX(i) = FXI
FY(i) = FYI
FZ(i) = FZI
End Do Parti1
!CALCULO DE PRESION
Pres = dens + (dens / (3.0 * real(N) ) ) * Pres1
!GUADANDO TERMALIZACION (ENERGIA POR PARTICULA)
Write(3,*) L , EnePot / Real(N), Pres
If( mod(L , iPrint) == 0 ) Then
Write(*,*) L , EnePot / Real(N) , Pres !MONITOREO EN PANTALLA
End If
End Subroutine Fuerza
| Portafolio_III/Comentarios/Fuerzas.f03 |
*+ graphic_default_grline
subroutine graphic_default_grline( opt, code, s )
C -------------------------------------------------
C
C Setup default grline (graphic line) options
C
C Given:
C grline structure
integer opt(*)
C code to specify type of setting up
C = 0 plot
C = 1 style options
C = 2 file options
C = 3 everything
integer code
C
C Updated:
C error status
integer s
C
C Setup default graphic line (grline) options.
C-
include '../include/plt_basic_defn.inc'
include '../include/plt_grline_defn.inc'
C local variables
integer l
C check status on entry
if (s.ne.0) return
C copy from structure
do l = 1,len_grline
grline(l) = opt(l)
enddo
C setup options (see structure definition)
if (code.eq.2 .or. code.eq.3) then
grline_x_file = 0
grline_y_file = 0
grline_x_col = 1
grline_y_col = 2
grline_ex_file = 0
grline_ex_col = 3
grline_ey_opt = 0
grline_ey_file = 0
grline_ey_col = 3
endif
if (code.eq.1 .or. code.eq.3) then
grline_symbol = 0
grline_type = 1
grline_offset_x = 0.0
grline_offset_y = 0.0
grline_scale_x = 1.0
grline_scale_y = 1.0
grline_auto_x = .false.
grline_auto_y = .false.
grline_ex_opt = 0
grline_ey_opt = 0
grline_ex_top = 1.0
grline_ey_top = 1.0
grline_x_log = .false.
grline_y_log = .false.
call graphic_default_line_opt(grline_line_opt,s)
call graphic_default_line_opt(grline_error_opt,s)
call graphic_default_text_opt(grline_text_opt,s)
grline_key_opt = 1
grline_key_text = 0
endif
if (code.eq.0) then
grline_status = abs(grline_status)
endif
C copy to structure
do l = 1,len_grline
opt(l) = grline(l)
enddo
call cmd_err(s,'graphic_default_grline',' ')
end
| graphic_lib/graphic_default_grline.f |
! *********************************COPYRIGHT************************************
! (C) Crown copyright Met Office. All rights reserved.
! For further details please refer to the file LICENCE.txt
! which you should have received as part of this distribution.
! *********************************COPYRIGHT************************************
!
! This file is part of the UM Shared Library project.
!
! The UM Shared Library is free software: you can redistribute it
! and/or modify it under the terms of the Modified BSD License, as
! published by the Open Source Initiative.
!
! The UM Shared Library is distributed in the hope that it will be
! useful, but WITHOUT ANY WARRANTY; without even the implied warranty
! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! Modified BSD License for more details.
!
! You should have received a copy of the Modified BSD License
! along with the UM Shared Library.
! If not, see <http://opensource.org/licenses/BSD-3-Clause>.
!*******************************************************************************
! Description: Functions to Transform Lat/Long values and Rotate wind vector
! values to Rotated Pole Equatorial Lat/Long coordinates.
!
MODULE f_shum_latlon_eq_grids_mod
USE, INTRINSIC :: ISO_C_BINDING, ONLY: &
C_INT64_T, C_INT32_T, C_FLOAT, C_DOUBLE
USE f_shum_conversions_mod, ONLY: &
shum_pi_over_180_const, &
shum_180_over_pi_const
IMPLICIT NONE
PRIVATE
PUBLIC :: f_shum_latlon_to_eq, f_shum_eq_to_latlon, &
f_shum_latlon_to_eq_vector, f_shum_eq_to_latlon_vector, &
f_shum_latlon_eq_vector_coeff
!------------------------------------------------------------------------------!
! We're going to use the types from the ISO_C_BINDING module, since although !
! the REALs aren't 100% guaranteed to correspond to the sizes we want to !
! enforce, they should be good enough on the majority of systems. !
! !
! Additional protection for the case that FLOAT/DOUBLE do not conform to the !
! sizes we expect is provided via the "precision_bomb" macro-file !
!------------------------------------------------------------------------------!
INTEGER, PARAMETER :: int64 = C_INT64_T
INTEGER, PARAMETER :: int32 = C_INT32_T
INTEGER, PARAMETER :: real64 = C_DOUBLE
INTEGER, PARAMETER :: real32 = C_FLOAT
!------------------------------------------------------------------------------!
INTERFACE f_shum_latlon_to_eq
MODULE PROCEDURE &
f_shum_lltoeq_arg64, &
f_shum_lltoeq_arg64_single, &
f_shum_lltoeq_arg32, &
f_shum_lltoeq_arg32_single
END INTERFACE
INTERFACE f_shum_eq_to_latlon
MODULE PROCEDURE &
f_shum_eqtoll_arg64, &
f_shum_eqtoll_arg64_single, &
f_shum_eqtoll_arg32, &
f_shum_eqtoll_arg32_single
END INTERFACE
INTERFACE f_shum_latlon_eq_vector_coeff
MODULE PROCEDURE &
f_shum_w_coeff_arg64, f_shum_w_coeff_arg32
END INTERFACE
INTERFACE f_shum_latlon_to_eq_vector
MODULE PROCEDURE &
f_shum_w_lltoeq_arg64, f_shum_w_lltoeq_arg32
END INTERFACE
INTERFACE f_shum_eq_to_latlon_vector
MODULE PROCEDURE &
f_shum_w_eqtoll_arg64, f_shum_w_eqtoll_arg32
END INTERFACE
CONTAINS
!------------------------------------------------------------------------------!
! Calculates latitude and longitude on equatorial latitude-longitude (eq) grid
! used in regional models from input arrays of latitude and longitude on
! standard grid. Both input and output latitudes and longitudes are in degrees
FUNCTION f_shum_lltoeq_arg64 &
(phi, lambda, phi_eq, lambda_eq, phi_pole, lambda_pole, message) RESULT(status)
IMPLICIT NONE
REAL(KIND=real64), INTENT(IN) :: phi(:) ! Lat (lat-lon)
REAL(KIND=real64), INTENT(IN) :: lambda(SIZE(phi)) ! Long (lat-lon)
REAL(KIND=real64), INTENT(IN) :: phi_pole ! Lat pole (eq)
REAL(KIND=real64), INTENT(IN) :: lambda_pole ! Long pole (eq)
REAL(KIND=real64), INTENT(OUT) :: phi_eq(SIZE(phi)) ! Lat (eq)
REAL(KIND=real64), INTENT(OUT) :: lambda_eq(SIZE(phi)) ! Long (eq)
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status
REAL(KIND=real64) :: a_lambda
REAL(KIND=real64) :: a_phi
REAL(KIND=real64) :: e_lambda
REAL(KIND=real64) :: e_phi
REAL(KIND=real64) :: sin_phi_pole
REAL(KIND=real64) :: cos_phi_pole
REAL(KIND=real64) :: arg
REAL(KIND=real64) :: term1
REAL(KIND=real64) :: term2
REAL(KIND=real64) :: lambda_zero
REAL(KIND=real64) :: lambda_pole_local
INTEGER(KIND=int64) :: i
REAL(KIND=real64), PARAMETER :: small = 1.0e-5_real64
! Check pole co-ordinates are valid values
IF (ABS(lambda_pole) > 360.0_real64) THEN
message = "Pole longitude invalid (must be between +/- 360.0)"
status = 1
RETURN
END IF
IF (ABS(phi_pole) > 90.0_real64) THEN
message = "Pole latitude invalid (must be between +/- 90.0)"
status = 1
RETURN
END IF
! Ensure longitude of pole is between -180.0 and 180.0
lambda_pole_local = MOD(lambda_pole, 360.0_real64)
IF (ABS(lambda_pole_local) > 180.0_real64) THEN
lambda_pole_local = lambda_pole_local - SIGN(360.0_real64, lambda_pole_local)
END IF
! Latitude of zeroth meridian
lambda_zero = lambda_pole_local + 180.0_real64
! Sine and cosine of latitude of eq pole
IF (ABS(phi_pole) == 90.0_real64) THEN
sin_phi_pole = SIGN(1.0_real64, phi_pole)
cos_phi_pole = SIGN(0.0_real64, phi_pole)
ELSE
sin_phi_pole = SIN(shum_pi_over_180_const*phi_pole)
cos_phi_pole = COS(shum_pi_over_180_const*phi_pole)
END IF
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i, a_lambda, a_phi, arg, term1, term2, e_lambda, e_phi) &
!$OMP& SHARED(lambda, phi, lambda_zero, cos_phi_pole, sin_phi_pole, &
!$OMP& phi_eq, lambda_eq)
DO i=1,SIZE(phi)
! Scale longitude to range -180 to +180 degs
a_lambda = MOD(lambda(i) - lambda_zero, 360.0_real64)
IF (ABS(a_lambda) > 180.0_real64) THEN
a_lambda = a_lambda - SIGN(360.0_real64, a_lambda)
END IF
! Convert latitude & longitude to radians
a_lambda = shum_pi_over_180_const*a_lambda
a_phi = shum_pi_over_180_const*phi(i)
! Compute eq latitude
arg = -cos_phi_pole*COS(a_lambda)*COS(a_phi) &
+ SIN(a_phi)*sin_phi_pole
arg = MIN(arg, 1.0_real64)
arg = MAX(arg,-1.0_real64)
e_phi = ASIN(arg)
phi_eq(i) = shum_180_over_pi_const*e_phi
! Compute eq longitude
term1 = (COS(a_phi)*COS(a_lambda)*sin_phi_pole &
+ SIN(a_phi)*cos_phi_pole)
term2 = COS(e_phi)
IF (term2 < small) THEN
e_lambda = shum_180_over_pi_const*a_lambda
ELSE
arg = term1/term2
arg = MIN(arg, 1.0_real64)
arg = MAX(arg,-1.0_real64)
e_lambda = shum_180_over_pi_const*ACOS(arg)
e_lambda = SIGN(e_lambda,a_lambda)
END IF
! Scale equatorial longitude to range 0 to 360 degs for use
e_lambda = MOD(e_lambda, 360.0_real64)
IF (ABS(e_lambda) < small) THEN
e_lambda = 0.0_real64
ELSE IF (e_lambda < 0.0_real64) THEN
e_lambda = e_lambda + 360.0_real64
END IF
lambda_eq(i)=e_lambda
END DO
!$OMP END PARALLEL DO
status = 0_int64
END FUNCTION f_shum_lltoeq_arg64
!------------------------------------------------------------------------------!
FUNCTION f_shum_lltoeq_arg64_single &
(phi, lambda, phi_eq, lambda_eq, phi_pole, lambda_pole, message) RESULT(status)
IMPLICIT NONE
REAL(KIND=real64), INTENT(IN) :: phi ! Lat (lat-lon)
REAL(KIND=real64), INTENT(IN) :: lambda ! Long (lat-lon)
REAL(KIND=real64), INTENT(IN) :: phi_pole ! Lat pole (eq)
REAL(KIND=real64), INTENT(IN) :: lambda_pole ! Long pole (eq)
REAL(KIND=real64), INTENT(OUT) :: phi_eq ! Lat (eq)
REAL(KIND=real64), INTENT(OUT) :: lambda_eq ! Long (eq)
REAL(KIND=real64) :: phi_arr(1)
REAL(KIND=real64) :: lambda_arr(1)
REAL(KIND=real64) :: phi_eq_arr(1)
REAL(KIND=real64) :: lambda_eq_arr(1)
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status
phi_arr(1) = phi
lambda_arr(1) = lambda
status = f_shum_lltoeq_arg64(phi_arr, lambda_arr, phi_eq_arr, lambda_eq_arr, &
phi_pole, lambda_pole, message)
IF (status == 0_int64) THEN
phi_eq = phi_eq_arr(1)
lambda_eq = lambda_eq_arr(1)
END IF
END FUNCTION f_shum_lltoeq_arg64_single
!------------------------------------------------------------------------------!
FUNCTION f_shum_lltoeq_arg32 &
(phi, lambda, phi_eq, lambda_eq, phi_pole, lambda_pole, message) RESULT(status)
IMPLICIT NONE
REAL(KIND=real32), INTENT(IN) :: phi(:) ! Lat (lat-lon)
REAL(KIND=real32), INTENT(IN) :: lambda(SIZE(phi)) ! Long (lat-lon)
REAL(KIND=real32), INTENT(IN) :: phi_pole ! Lat pole (eq)
REAL(KIND=real32), INTENT(IN) :: lambda_pole ! Long pole (eq)
REAL(KIND=real32), INTENT(OUT) :: phi_eq(SIZE(phi)) ! Lat (eq)
REAL(KIND=real32), INTENT(OUT) :: lambda_eq(SIZE(phi)) ! Long (eq)
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status64
INTEGER(KIND=int32) :: status
REAL(KIND=real64) :: phi64(SIZE(phi))
REAL(KIND=real64) :: lambda64(SIZE(phi))
REAL(KIND=real64) :: phi_pole64
REAL(KIND=real64) :: lambda_pole64
REAL(KIND=real64) :: phi_eq64(SIZE(phi))
REAL(KIND=real64) :: lambda_eq64(SIZE(phi))
INTEGER(KIND=int64) :: i
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(phi, phi64, lambda, lambda64)
DO i = 1, SIZE(phi)
phi64(i) = REAL(phi(i), KIND=real64)
lambda64(i) = REAL(lambda(i), KIND=real64)
END DO
!$OMP END PARALLEL DO
phi_pole64 = REAL(phi_pole, KIND=real64)
lambda_pole64 = REAL(lambda_pole, KIND=real64)
status64 = f_shum_lltoeq_arg64(phi64, lambda64, phi_eq64, lambda_eq64, &
phi_pole64, lambda_pole64, message)
status = INT(status64,KIND=int32)
IF (status == 0_int32) THEN
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(phi_eq, phi_eq64, lambda_eq, lambda_eq64, phi)
DO i = 1, SIZE(phi)
phi_eq(i) = REAL(phi_eq64(i), KIND=real32)
lambda_eq(i) = REAL(lambda_eq64(i), KIND=real32)
END DO
!$OMP END PARALLEL DO
END IF
END FUNCTION f_shum_lltoeq_arg32
!------------------------------------------------------------------------------!
FUNCTION f_shum_lltoeq_arg32_single &
(phi, lambda, phi_eq, lambda_eq, phi_pole, lambda_pole, message) RESULT(status)
IMPLICIT NONE
REAL(KIND=real32), INTENT(IN) :: phi ! Lat (lat-lon)
REAL(KIND=real32), INTENT(IN) :: lambda ! Long (lat-lon)
REAL(KIND=real32), INTENT(IN) :: phi_pole ! Lat pole (eq)
REAL(KIND=real32), INTENT(IN) :: lambda_pole ! Long pole (eq)
REAL(KIND=real32), INTENT(OUT) :: phi_eq ! Lat (eq)
REAL(KIND=real32), INTENT(OUT) :: lambda_eq ! Long (eq)
REAL(KIND=real64) :: phi_arr64(1)
REAL(KIND=real64) :: lambda_arr64(1)
REAL(KIND=real64) :: phi_eq_arr64(1)
REAL(KIND=real64) :: lambda_eq_arr64(1)
REAL(KIND=real64) :: phi_pole64
REAL(KIND=real64) :: lambda_pole64
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status64
INTEGER(KIND=int32) :: status
phi_arr64(1) = REAL(phi, KIND=real64)
lambda_arr64(1) = REAL(lambda, KIND=real64)
phi_pole64 = REAL(phi_pole, KIND=real64)
lambda_pole64 = REAL(lambda_pole, KIND=real64)
status64 = f_shum_lltoeq_arg64(phi_arr64, lambda_arr64, &
phi_eq_arr64, lambda_eq_arr64, &
phi_pole64, lambda_pole64, message)
status = INT(status64,KIND=int32)
IF (status == 0_int32) THEN
phi_eq = REAL(phi_eq_arr64(1), KIND=real32)
lambda_eq = REAL(lambda_eq_arr64(1), KIND=real32)
END IF
END FUNCTION f_shum_lltoeq_arg32_single
!------------------------------------------------------------------------------!
! Calculates latitude and longitude on standard grid from input arrays of
! latitude and longitude on equatorial latitude-longitude (eq) grid used in
! regional models. Both input and output latitudes and longitudes are in
! degrees
FUNCTION f_shum_eqtoll_arg64 &
(phi_eq, lambda_eq, phi, lambda, phi_pole, lambda_pole, message) RESULT(status)
IMPLICIT NONE
REAL(KIND=real64), INTENT(IN) :: phi_eq(:) ! Lat (eq)
REAL(KIND=real64), INTENT(IN) :: lambda_eq(SIZE(phi_eq)) ! Long (eq)
REAL(KIND=real64), INTENT(IN) :: phi_pole ! Lat pole (eq)
REAL(KIND=real64), INTENT(IN) :: lambda_pole ! Long pole (eq)
REAL(KIND=real64), INTENT(OUT) :: phi(SIZE(phi_eq)) ! Lat (lat-lon)
REAL(KIND=real64), INTENT(OUT) :: lambda(SIZE(phi_eq)) ! Long (lat-lon)
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status
REAL(KIND=real64) :: a_lambda
REAL(KIND=real64) :: a_phi
REAL(KIND=real64) :: e_lambda
REAL(KIND=real64) :: e_phi
REAL(KIND=real64) :: sin_phi_pole
REAL(KIND=real64) :: cos_phi_pole
REAL(KIND=real64) :: arg
REAL(KIND=real64) :: term1
REAL(KIND=real64) :: term2
REAL(KIND=real64) :: lambda_zero
REAL(KIND=real64) :: lambda_pole_local
INTEGER(KIND=int64) :: i
REAL(KIND=real64), PARAMETER :: small = 1.0e-5_real64
! Check pole co-ordinates are valid values
IF (ABS(lambda_pole) > 360.0_real64) THEN
message = "Pole longitude invalid (must be between +/- 360.0)"
status = 1
RETURN
END IF
IF (ABS(phi_pole) > 90.0_real64) THEN
message = "Pole latitude invalid (must be between +/- 90.0)"
status = 1
RETURN
END IF
! Ensure longitude of pole is between -180.0 and 180.0
lambda_pole_local = MOD(lambda_pole, 360.0_real64)
IF (ABS(lambda_pole_local) > 180.0_real64) THEN
lambda_pole_local = lambda_pole_local - SIGN(360.0_real64, lambda_pole_local)
END IF
! Latitude of zeroth meridian
lambda_zero = lambda_pole_local + 180.0_real64
! Sine and cosine of latitude of eq pole
IF (ABS(phi_pole) == 90.0_real64) THEN
sin_phi_pole = SIGN(1.0_real64, phi_pole)
cos_phi_pole = SIGN(0.0_real64, phi_pole)
ELSE
sin_phi_pole = SIN(shum_pi_over_180_const*phi_pole)
cos_phi_pole = COS(shum_pi_over_180_const*phi_pole)
END IF
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i, a_lambda, a_phi, arg, term1, term2, e_lambda, e_phi) &
!$OMP& SHARED(lambda, phi, lambda_zero, cos_phi_pole, sin_phi_pole, &
!$OMP& phi_eq, lambda_eq)
DO i=1,SIZE(phi_eq)
! Scale eq longitude to range -180 to +180 degs
e_lambda = MOD(lambda_eq(i), 360.0_real64)
IF (ABS(e_lambda) > 180.0_real64) THEN
e_lambda = e_lambda - SIGN(360.0_real64, e_lambda)
END IF
! Convert eq latitude & longitude to radians
e_lambda = shum_pi_over_180_const*e_lambda
e_phi = shum_pi_over_180_const*phi_eq(i)
! Compute latitude
arg = cos_phi_pole*COS(e_lambda)*COS(e_phi) &
+ SIN(e_phi)*sin_phi_pole
arg = MIN(arg, 1.0_real64)
arg = MAX(arg,-1.0_real64)
a_phi = ASIN(arg)
phi(i) = shum_180_over_pi_const*a_phi
! Compute longitude
term1 = (COS(e_phi)*COS(e_lambda)*sin_phi_pole &
- SIN(e_phi)*cos_phi_pole)
term2 = COS(a_phi)
IF (term2 < small) THEN
a_lambda = 0.0_real64
ELSE
arg = term1/term2
arg = MIN(arg, 1.0_real64)
arg = MAX(arg,-1.0_real64)
a_lambda = shum_180_over_pi_const*ACOS(arg)
a_lambda = SIGN(a_lambda, e_lambda)
a_lambda = a_lambda + lambda_zero
END IF
! Scale longitude to range 0 to 360 degs
a_lambda = MOD(a_lambda, 360.0_real64)
IF (ABS(a_lambda) < small) THEN
a_lambda = 0.0_real64
ELSE IF (a_lambda < 0.0_real64) THEN
a_lambda = a_lambda + 360.0_real64
END IF
lambda(i) = a_lambda
END DO
!$OMP END PARALLEL DO
status = 0_int64
END FUNCTION f_shum_eqtoll_arg64
!------------------------------------------------------------------------------!
FUNCTION f_shum_eqtoll_arg64_single &
(phi_eq, lambda_eq, phi, lambda, phi_pole, lambda_pole, message) RESULT(status)
IMPLICIT NONE
REAL(KIND=real64), INTENT(IN) :: phi_eq ! Lat (eq)
REAL(KIND=real64), INTENT(IN) :: lambda_eq ! Long (eq)
REAL(KIND=real64), INTENT(IN) :: phi_pole ! Lat pole (eq)
REAL(KIND=real64), INTENT(IN) :: lambda_pole ! Long pole (eq)
REAL(KIND=real64), INTENT(OUT) :: phi ! Lat (lat-lon)
REAL(KIND=real64), INTENT(OUT) :: lambda ! Long (lat-lon)
REAL(KIND=real64) :: phi_eq_arr(1)
REAL(KIND=real64) :: lambda_eq_arr(1)
REAL(KIND=real64) :: phi_arr(1)
REAL(KIND=real64) :: lambda_arr(1)
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status
phi_eq_arr(1) = phi_eq
lambda_eq_arr(1) = lambda_eq
status = f_shum_eqtoll_arg64(phi_eq_arr, lambda_eq_arr, phi_arr, lambda_arr, &
phi_pole, lambda_pole, message)
IF (status == 0_int64) THEN
phi = phi_arr(1)
lambda = lambda_arr(1)
END IF
END FUNCTION f_shum_eqtoll_arg64_single
!------------------------------------------------------------------------------!
FUNCTION f_shum_eqtoll_arg32 &
(phi_eq, lambda_eq, phi, lambda, phi_pole, lambda_pole, message) RESULT(status)
IMPLICIT NONE
REAL(KIND=real32), INTENT(IN) :: phi_eq(:) ! Lat (eq)
REAL(KIND=real32), INTENT(IN) :: lambda_eq(SIZE(phi_eq)) ! Long (eq)
REAL(KIND=real32), INTENT(IN) :: phi_pole ! Lat pole (eq)
REAL(KIND=real32), INTENT(IN) :: lambda_pole ! Long pole (eq)
REAL(KIND=real32), INTENT(OUT) :: phi(SIZE(phi_eq)) ! Lat (lat-lon)
REAL(KIND=real32), INTENT(OUT) :: lambda(SIZE(phi_eq)) ! Long (lat-lon)
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status64
INTEGER(KIND=int32) :: status
REAL(KIND=real64) :: phi64(SIZE(phi_eq))
REAL(KIND=real64) :: lambda64(SIZE(phi_eq))
REAL(KIND=real64) :: phi_pole64
REAL(KIND=real64) :: lambda_pole64
REAL(KIND=real64) :: phi_eq64(SIZE(phi_eq))
REAL(KIND=real64) :: lambda_eq64(SIZE(phi_eq))
INTEGER(KIND=int64) :: i
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(phi_eq, phi_eq64, lambda_eq, lambda_eq64)
DO i = 1, SIZE(phi_eq)
phi_eq64(i) = REAL(phi_eq(i), KIND=real64)
lambda_eq64(i) = REAL(lambda_eq(i), KIND=real64)
END DO
!$OMP END PARALLEL DO
phi_pole64 = REAL(phi_pole, KIND=real64)
lambda_pole64 = REAL(lambda_pole, KIND=real64)
status64 = f_shum_eqtoll_arg64(phi_eq64, lambda_eq64, phi64, lambda64, &
phi_pole64, lambda_pole64, message)
status = INT(status64,KIND=int32)
IF (status == 0_int32) THEN
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(phi, phi64, lambda, lambda64, phi_eq)
DO i = 1, SIZE(phi_eq)
phi(i) = REAL(phi64(i), KIND=real32)
lambda(i) = REAL(lambda64(i), KIND=real32)
END DO
!$OMP END PARALLEL DO
END IF
END FUNCTION f_shum_eqtoll_arg32
!------------------------------------------------------------------------------!
FUNCTION f_shum_eqtoll_arg32_single &
(phi_eq, lambda_eq, phi, lambda, phi_pole, lambda_pole, message) RESULT(status)
IMPLICIT NONE
REAL(KIND=real32), INTENT(IN) :: phi_eq ! Lat (eq)
REAL(KIND=real32), INTENT(IN) :: lambda_eq ! Long (eq)
REAL(KIND=real32), INTENT(IN) :: phi_pole ! Lat pole (eq)
REAL(KIND=real32), INTENT(IN) :: lambda_pole ! Long pole (eq)
REAL(KIND=real32), INTENT(OUT) :: phi ! Lat (lat-lon)
REAL(KIND=real32), INTENT(OUT) :: lambda ! Long (lat-lon)
REAL(KIND=real64) :: phi_arr64(1)
REAL(KIND=real64) :: lambda_arr64(1)
REAL(KIND=real64) :: phi_eq_arr64(1)
REAL(KIND=real64) :: lambda_eq_arr64(1)
REAL(KIND=real64) :: phi_pole64
REAL(KIND=real64) :: lambda_pole64
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status64
INTEGER(KIND=int32) :: status
phi_eq_arr64(1) = REAL(phi_eq, KIND=real64)
lambda_eq_arr64(1) = REAL(lambda_eq, KIND=real64)
phi_pole64 = REAL(phi_pole, KIND=real64)
lambda_pole64 = REAL(lambda_pole, KIND=real64)
status64 = f_shum_eqtoll_arg64(phi_eq_arr64, lambda_eq_arr64, &
phi_arr64, lambda_arr64, &
phi_pole64, lambda_pole64, message)
status = INT(status64,KIND=int32)
IF (status == 0_int32) THEN
phi = REAL(phi_arr64(1), KIND=real32)
lambda = REAL(lambda_arr64(1), KIND=real32)
END IF
END FUNCTION f_shum_eqtoll_arg32_single
!------------------------------------------------------------------------------!
! Calculates coefficients used to translate u and v components of wind between
! equatorial (eq) latitude-longitude grid and standard (ll) latitude-longitude
! grid (or vice versa). Input latitudes and longitudes are in degrees.
FUNCTION f_shum_w_coeff_arg64 &
(coeff1, coeff2, lambda, lambda_eq, phi_pole, lambda_pole, message) &
RESULT(status)
IMPLICIT NONE
REAL(KIND=real64), INTENT(IN) :: lambda(:) ! Long (lat-lon)
REAL(KIND=real64), INTENT(IN) :: lambda_eq(SIZE(lambda)) ! Long (eq)
REAL(KIND=real64), INTENT(IN) :: phi_pole ! Lat pole (eq)
REAL(KIND=real64), INTENT(IN) :: lambda_pole ! Long pole (eq)
REAL(KIND=real64), INTENT(OUT) :: coeff1(SIZE(lambda)) ! Rotation coeff 1
REAL(KIND=real64), INTENT(OUT) :: coeff2(SIZE(lambda)) ! Rotation coeff 2
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status
REAL(KIND=real64) :: a_lambda
REAL(KIND=real64) :: e_lambda
REAL(KIND=real64) :: sin_e_lambda
REAL(KIND=real64) :: sin_phi_pole
REAL(KIND=real64) :: cos_phi_pole
REAL(KIND=real64) :: c1
REAL(KIND=real64) :: c2
REAL(KIND=real64) :: lambda_zero
REAL(KIND=real64) :: lambda_pole_local
INTEGER(KIND=int64) :: i
! Check pole co-ordinates are valid values
IF (ABS(lambda_pole) > 360.0_real64) THEN
message = "Pole longitude invalid (must be between +/- 360.0)"
status = 1
RETURN
END IF
IF (ABS(phi_pole) > 90.0_real64) THEN
message = "Pole latitude invalid (must be between +/- 90.0)"
status = 1
RETURN
END IF
! Ensure longitude of pole is between -180.0 and 180.0
lambda_pole_local = MOD(lambda_pole, 360.0_real64)
IF (ABS(lambda_pole_local) > 180.0_real64) THEN
lambda_pole_local = lambda_pole_local - SIGN(360.0_real64, lambda_pole_local)
END IF
! Longitude of zeroth meridian
lambda_zero = lambda_pole_local + 180.0_real64
! Sine and cosine of latitude of eq pole
IF (ABS(phi_pole) == 90.0_real64) THEN
sin_phi_pole = SIGN(1.0_real64, phi_pole)
cos_phi_pole = SIGN(0.0_real64, phi_pole)
ELSE
sin_phi_pole = SIN(shum_pi_over_180_const*phi_pole)
cos_phi_pole = COS(shum_pi_over_180_const*phi_pole)
END IF
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i, a_lambda, e_lambda, sin_e_lambda, c1, c2) &
!$OMP& SHARED(lambda, lambda_zero, lambda_eq, coeff1, coeff2, sin_phi_pole, &
!$OMP& cos_phi_pole)
DO i=1,SIZE(lambda)
! Convert longitudes to radians (and ensure range is correct)
a_lambda = MOD(lambda(i) - lambda_zero, 360.0_real64)
IF (ABS(a_lambda) > 180.0_real64) THEN
a_lambda = a_lambda - SIGN(360.0_real64, a_lambda)
END IF
a_lambda = shum_pi_over_180_const*a_lambda
e_lambda = MOD(lambda_eq(i), 360.0_real64)
IF (ABS(e_lambda) > 180.0_real64) THEN
e_lambda = e_lambda - SIGN(360.0_real64, e_lambda)
END IF
e_lambda = e_lambda*shum_pi_over_180_const
! Take sine of eq lambda
IF (ABS(lambda_eq(i)) == 180.0_real64) THEN
sin_e_lambda = 0.0_real64 ! to avoid spurious c1 result
ELSE
sin_e_lambda = SIN(e_lambda)
END IF
c1 = SIN(a_lambda) * sin_e_lambda * sin_phi_pole &
+ COS(a_lambda) * COS(e_lambda)
! Avoid rounding error problems
IF (ABS(c1) >= 1.0_real64) THEN
c1 = SIGN(1.0_real64, c1)
c2 = 0.0_real64
ELSE
c2 = SQRT(1.0_real64 - c1*c1)
END IF
coeff1(i) = c1
! Set the sign of C2 - the 0.0 case represents an edge-case where there
! are more than one solution; ensure we always get the same answer
IF (ABS(sin_e_lambda*cos_phi_pole) == 0.0_real64) THEN
coeff2(i) = c2
ELSE
coeff2(i) = SIGN(c2, sin_e_lambda*cos_phi_pole)
END IF
END DO
!$OMP END PARALLEL DO
status = 0_int64
END FUNCTION f_shum_w_coeff_arg64
!------------------------------------------------------------------------------!
FUNCTION f_shum_w_coeff_arg32 &
(coeff1, coeff2, lambda, lambda_eq, phi_pole, lambda_pole, message) &
RESULT(status)
IMPLICIT NONE
REAL(KIND=real32), INTENT(IN) :: lambda(:) ! Long (lat-lon)
REAL(KIND=real32), INTENT(IN) :: lambda_eq(SIZE(lambda)) ! Long (eq)
REAL(KIND=real32), INTENT(IN) :: phi_pole ! Lat pole (eq)
REAL(KIND=real32), INTENT(IN) :: lambda_pole ! Long pole (eq)
REAL(KIND=real32), INTENT(OUT) :: coeff1(SIZE(lambda)) ! Rotation coeff 1
REAL(KIND=real32), INTENT(OUT) :: coeff2(SIZE(lambda)) ! Rotation coeff 2
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status64
INTEGER(KIND=int32) :: status
REAL(KIND=real64) :: lambda64(SIZE(lambda))
REAL(KIND=real64) :: lambda_eq64(SIZE(lambda))
REAL(KIND=real64) :: phi_pole64
REAL(KIND=real64) :: lambda_pole64
REAL(KIND=real64) :: coeff1_64(SIZE(lambda))
REAL(KIND=real64) :: coeff2_64(SIZE(lambda))
INTEGER(KIND=int64) :: i
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(lambda, lambda64, lambda_eq, lambda_eq64)
DO i = 1, SIZE(lambda)
lambda64(i) = REAL(lambda(i), KIND=real64)
lambda_eq64(i) = REAL(lambda_eq(i), KIND=real64)
END DO
!$OMP END PARALLEL DO
phi_pole64 = REAL(phi_pole, KIND=real64)
lambda_pole64 = REAL(lambda_pole, KIND=real64)
status64 = f_shum_w_coeff_arg64(coeff1_64, coeff2_64, lambda64, lambda_eq64, &
phi_pole64, lambda_pole64, message)
status = INT(status64,KIND=int32)
IF (status == 0_int32) THEN
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(coeff1, coeff1_64, coeff2, coeff2_64, lambda)
DO i = 1, SIZE(lambda)
coeff1(i) = REAL(coeff1_64(i), KIND=real32)
coeff2(i) = REAL(coeff2_64(i), KIND=real32)
END DO
!$OMP END PARALLEL DO
END IF
END FUNCTION f_shum_w_coeff_arg32
!------------------------------------------------------------------------------!
! Calculates u and v components of wind on standard latitude-longitude (ll) grid
! by rotating wind components on equatorial latitude-longitude (eq) grid.
FUNCTION f_shum_w_eqtoll_arg64 &
(coeff1, coeff2, u_eq, v_eq, u, v, message, mdi) RESULT(status)
IMPLICIT NONE
REAL(KIND=real64), INTENT(IN) :: coeff1(:) ! Rotation coeff 1
REAL(KIND=real64), INTENT(IN) :: coeff2(SIZE(coeff1)) ! Rotation coeff 2
REAL(KIND=real64), INTENT(IN) :: u_eq(SIZE(coeff1)) ! Wind U compt (eq)
REAL(KIND=real64), INTENT(IN) :: v_eq(SIZE(coeff1)) ! Wind V compt (eq)
REAL(KIND=real64), INTENT(OUT) :: u(SIZE(coeff1)) ! Wind U compt (lat-lon)
REAL(KIND=real64), INTENT(OUT) :: v(SIZE(coeff1)) ! Wind U compt (lat-lon)
REAL(KIND=real64), INTENT(IN), OPTIONAL :: mdi ! Missing data value
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status
LOGICAL :: l_mdi ! Was an mdi value provided?
INTEGER(KIND=int64) :: i
! Check if an mdi value has been provided
l_mdi = PRESENT(mdi)
! Apply coefficients (omitting mdi values if required)
IF (l_mdi) THEN
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(coeff1, coeff2, u, v, u_eq, v_eq, mdi)
DO i=1, SIZE(coeff1)
IF ( u_eq(i) == mdi .OR. v_eq(i) == mdi ) THEN
u(i) = mdi
v(i) = mdi
ELSE
u(i) = coeff1(i)*u_eq(i) + coeff2(i)*v_eq(i)
v(i) = coeff1(i)*v_eq(i) - coeff2(i)*u_eq(i)
END IF
END DO
!$OMP END PARALLEL DO
ELSE
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(coeff1, coeff2, u, v, u_eq, v_eq)
DO i=1, SIZE(coeff1)
u(i) = coeff1(i)*u_eq(i) + coeff2(i)*v_eq(i)
v(i) = coeff1(i)*v_eq(i) - coeff2(i)*u_eq(i)
END DO
!$OMP END PARALLEL DO
END IF
status = 0_int64
message = ''
END FUNCTION f_shum_w_eqtoll_arg64
!------------------------------------------------------------------------------!
FUNCTION f_shum_w_eqtoll_arg32 &
(coeff1, coeff2, u_eq, v_eq, u, v, message, mdi) RESULT(status)
IMPLICIT NONE
REAL(KIND=real32), INTENT(IN) :: coeff1(:) ! Rotation coeff 1
REAL(KIND=real32), INTENT(IN) :: coeff2(SIZE(coeff1)) ! Rotation coeff 2
REAL(KIND=real32), INTENT(IN) :: u_eq(SIZE(coeff1)) ! Wind U compt (eq)
REAL(KIND=real32), INTENT(IN) :: v_eq(SIZE(coeff1)) ! Wind V compt (eq)
REAL(KIND=real32), INTENT(OUT) :: u(SIZE(coeff1)) ! Wind U compt (lat-lon)
REAL(KIND=real32), INTENT(OUT) :: v(SIZE(coeff1)) ! Wind U compt (lat-lon)
REAL(KIND=real32), INTENT(IN), OPTIONAL :: mdi ! Missing data value
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status64
INTEGER(KIND=int32) :: status
REAL(KIND=real64) :: coeff1_64(SIZE(coeff1))
REAL(KIND=real64) :: coeff2_64(SIZE(coeff1))
REAL(KIND=real64) :: u_eq_64(SIZE(coeff1))
REAL(KIND=real64) :: v_eq_64(SIZE(coeff1))
REAL(KIND=real64) :: u_64(SIZE(coeff1))
REAL(KIND=real64) :: v_64(SIZE(coeff1))
REAL(KIND=real64) :: mdi_64
INTEGER(KIND=int64) :: i
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(coeff1, coeff1_64, coeff2, coeff2_64, u_eq, u_eq_64, &
!$OMP& v_eq, v_eq_64)
DO i = 1, SIZE(coeff1)
coeff1_64(i) = REAL(coeff1(i), KIND=real64)
coeff2_64(i) = REAL(coeff2(i), KIND=real64)
u_eq_64(i) = REAL(u_eq(i), KIND=real64)
v_eq_64(i) = REAL(v_eq(i), KIND=real64)
END DO
!$OMP END PARALLEL DO
IF (PRESENT(mdi)) THEN
mdi_64 = REAL(mdi, KIND=real64)
status64 = f_shum_w_eqtoll_arg64(coeff1_64, coeff2_64, u_eq_64, v_eq_64, &
u_64, v_64, message, mdi_64)
status = INT(status64,KIND=int32)
ELSE
status64 = f_shum_w_eqtoll_arg64(coeff1_64, coeff2_64, u_eq_64, v_eq_64, &
u_64, v_64, message)
status = INT(status64,KIND=int32)
END IF
IF (status == 0_int32) THEN
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(u, u_64, v, v_64, coeff1)
DO i = 1, SIZE(coeff1)
u(i) = REAL(u_64(i), KIND=real32)
v(i) = REAL(v_64(i), KIND=real32)
END DO
!$OMP END PARALLEL DO
END IF
END FUNCTION f_shum_w_eqtoll_arg32
!------------------------------------------------------------------------------!
! Calculates u and v components of wind on equatorial (eq) latitude-longitude
! grid by rotating wind components on standard latitude-longitude (ll) grid.
FUNCTION f_shum_w_lltoeq_arg64 &
(coeff1, coeff2, u, v, u_eq, v_eq, message, mdi) RESULT(status)
IMPLICIT NONE
REAL(KIND=real64), INTENT(IN) :: coeff1(:) ! Rotation coeff 1
REAL(KIND=real64), INTENT(IN) :: coeff2(SIZE(coeff1)) ! Rotation coeff 2
REAL(KIND=real64), INTENT(IN) :: u(SIZE(coeff1)) ! Wind U compt (lat-lon)
REAL(KIND=real64), INTENT(IN) :: v(SIZE(coeff1)) ! Wind V compt (lat-lon)
REAL(KIND=real64), INTENT(OUT) :: u_eq(SIZE(coeff1)) ! Wind U compt (eq)
REAL(KIND=real64), INTENT(OUT) :: v_eq(SIZE(coeff1)) ! Wind U compt (eq)
REAL(KIND=real64), INTENT(IN), OPTIONAL :: mdi ! Missing data value
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status
LOGICAL :: l_mdi ! Was an mdi value provided?
INTEGER(KIND=int64) :: i
! Check if an mdi value has been provided
l_mdi = PRESENT(mdi)
! Apply coefficients (omitting mdi values if required)
IF (l_mdi) THEN
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(coeff1, coeff2, u, v, u_eq, v_eq, mdi)
DO i=1, SIZE(coeff1)
IF ( u(i) == mdi .OR. v(i) == mdi ) THEN
u_eq(i) = mdi
v_eq(i) = mdi
ELSE
u_eq(i) = coeff1(i)*u(i)-coeff2(i)*v(i)
v_eq(i) = coeff1(i)*v(i)+coeff2(i)*u(i)
END IF
END DO
!$OMP END PARALLEL DO
ELSE
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(coeff1, coeff2, u, v, u_eq, v_eq)
DO i=1, SIZE(coeff1)
u_eq(i) = coeff1(i)*u(i)-coeff2(i)*v(i)
v_eq(i) = coeff1(i)*v(i)+coeff2(i)*u(i)
END DO
!$OMP END PARALLEL DO
END IF
status = 0_int64
message = ''
END FUNCTION f_shum_w_lltoeq_arg64
!------------------------------------------------------------------------------!
FUNCTION f_shum_w_lltoeq_arg32 &
(coeff1, coeff2, u, v, u_eq, v_eq, message, mdi) RESULT(status)
IMPLICIT NONE
REAL(KIND=real32), INTENT(IN) :: coeff1(:) ! Rotation coeff 1
REAL(KIND=real32), INTENT(IN) :: coeff2(SIZE(coeff1)) ! Rotation coeff 2
REAL(KIND=real32), INTENT(IN) :: u(SIZE(coeff1)) ! Wind U compt (lat-lon)
REAL(KIND=real32), INTENT(IN) :: v(SIZE(coeff1)) ! Wind V compt (lat-lon)
REAL(KIND=real32), INTENT(OUT) :: u_eq(SIZE(coeff1)) ! Wind U compt (eq)
REAL(KIND=real32), INTENT(OUT) :: v_eq(SIZE(coeff1)) ! Wind U compt (eq)
REAL(KIND=real32), INTENT(IN), OPTIONAL :: mdi ! Missing data value
CHARACTER(LEN=*) :: message
INTEGER(KIND=int64) :: status64
INTEGER(KIND=int32) :: status
REAL(KIND=real64) :: coeff1_64(SIZE(coeff1))
REAL(KIND=real64) :: coeff2_64(SIZE(coeff1))
REAL(KIND=real64) :: u_eq_64(SIZE(coeff1))
REAL(KIND=real64) :: v_eq_64(SIZE(coeff1))
REAL(KIND=real64) :: u_64(SIZE(coeff1))
REAL(KIND=real64) :: v_64(SIZE(coeff1))
REAL(KIND=real64) :: mdi_64
INTEGER(KIND=int64) :: i
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(coeff1, coeff1_64, coeff2, coeff2_64, u, u_64, v, v_64)
DO i = 1, SIZE(coeff1)
coeff1_64(i) = REAL(coeff1(i), KIND=real64)
coeff2_64(i) = REAL(coeff2(i), KIND=real64)
u_64(i) = REAL(u(i), KIND=real64)
v_64(i) = REAL(v(i), KIND=real64)
END DO
!$OMP END PARALLEL DO
IF (PRESENT(mdi)) THEN
mdi_64 = REAL(mdi, KIND=real64)
status64 = f_shum_w_lltoeq_arg64(coeff1_64, coeff2_64, u_64, v_64, &
u_eq_64, v_eq_64, message, mdi_64)
status = INT(status64,KIND=int32)
ELSE
status64 = f_shum_w_lltoeq_arg64(coeff1_64, coeff2_64, u_64, v_64, &
u_eq_64, v_eq_64, message)
status = INT(status64,KIND=int32)
END IF
IF (status == 0_int32) THEN
!$OMP PARALLEL DO DEFAULT(NONE) SCHEDULE(STATIC) &
!$OMP& PRIVATE(i) SHARED(u_eq, u_eq_64, v_eq, v_eq_64, coeff1)
DO i = 1, SIZE(coeff1)
u_eq(i) = REAL(u_eq_64(i), KIND=real32)
v_eq(i) = REAL(v_eq_64(i), KIND=real32)
END DO
!$OMP END PARALLEL DO
END IF
END FUNCTION f_shum_w_lltoeq_arg32
!------------------------------------------------------------------------------!
END MODULE f_shum_latlon_eq_grids_mod
| shum_latlon_eq_grids/src/f_shum_latlon_eq_grids.f90 |
SUBROUTINE WQSKE1
C
C ORGINALLY CODED BY K.-Y. PARK
C OPTIMIZED AND MODIFIED BY J.M. HAMRICK
C
C CHANGE RECORD
C
C MAJOR REWRITE BY PAUL M. CRAIG JANUARY 12, 2006
USE GLOBAL
IMPLICIT NONE
INTEGER NQ,NS,IZ,IMWQZ,NSTPTMP,M
INTEGER K,L,LE,LN
REAL WQAVGIO,RMULTMP,TIME,RLIGHT1,RLIGHT2
REAL WQGNC,WQGND,WQGNG,WQGNM,WQGPM,WQF1NM,WQGPC,WQGPD,WQGPG
REAL WQF1NC,WQF1ND,WQF1NG,WQKESS,XMRM,YMRM,WQTT1
REAL WQF2IC,WQF2ID,WQF2IG,SADWQ,WQGSD,WQF2IM
REAL UMRM,VMRM,WQVEL,WQLVF,WQF4SC,WQKDOC,WQKHP,WQTTS
REAL WQKHN,WQTTM,TVAL1,TVAL2,TVAL3,TVAL4,TVAL5
REAL RLNSAT1,RLNSAT2,XNUMER,XDENOM,WQLDF,WQTTC,WQTTD,WQTTG
REAL WINDREA,WQWREA,WQVREA,WQA1C,WQVA1C,WQR1C,WQA2D
REAL WQR2D,WQA3G,WQR3G,WQB4,WQA4,WQR4,WQC5,WQA5,WQR5
REAL WQD6,WQA6C,WQA6D,WQA6G,WQA6,WQA6M,WQR6
REAL WQE7,WQA7C,WQA7D,WQA7G,WQA7,WQR7
REAL WQF8,WQA8C,WQA8D,WQA8G,WQA8,WQR8
REAL WQF9,WQA9C,WQA9D,WQA9G,WQA9,WQR9
REAL WQA10C,WQA10D,WQA10G,WQKKL
!REAL WQR10
REAL WQI11,WQA11C,WQA11D,WQA11G,WQA11,WQR11
REAL WQJ12,WQA12C,WQA12D,WQA12G,WQA12,WQR12
REAL WQF13,WQA13C,WQA13D,WQA13G,WQA13,WQR13
REAL WQR14,WQF14,WQA14C,WQA14D,WQA14G,WQA14
REAL WQR15,WQA15C,WQA15D,WQA15G,WQA15,WQB15
REAL WQM16,WQA16D,WQR16,WQR17,WQR18
REAL TMP19,TEMFAC,DTWQxH,DTWQxH2,WQA19C,WQA19D,WQA19G
REAL WQA19,WQA19A,WQSUM,WQRea,WQPOC,WQDOC,WQNH3,WQCOD
REAL WQT20,WQR21,TIMTMP,WQTAMD
REAL PPCDO,WQA22, WQA22C, WQA22D, WQA22G, WQCDDOC
REAL WQCDREA, WQCDSUM
REAL EXPA0,EXPA1 !VARIABLES FOR LIGHT EXTINCTION
REAL WQGCO2M,WQGCO2C,WQGCO2G,WQGCO2D ! CO2 Limitation Consts
REAL,SAVE,ALLOCATABLE,DIMENSION(:)::DZCHP
REAL,SAVE,ALLOCATABLE,DIMENSION(:)::WQISC
REAL,SAVE,ALLOCATABLE,DIMENSION(:)::WQISD
REAL,SAVE,ALLOCATABLE,DIMENSION(:)::WQISG
REAL,SAVE,ALLOCATABLE,DIMENSION(:)::WQISM
REAL,SAVE,ALLOCATABLE,DIMENSION(:)::WQI0TOP
C
! *** 1) CHC - cyanobacteria
! *** 2) CHD - diatom algae
! *** 3) CHG - green algae
! *** 4) ROC - refractory particulate organic carbon
! *** 5) LOC - labile particulate organic carbon
! *** 6) DOC - dissolved organic carbon
! *** 7) ROP - refractory particulate organic phosphorus
! *** 8) LOP - labile particulate organic phosphorus
! *** 9) DOP - dissolved organic phosphorus
! *** 10) P4D - total phosphate
! *** 11) RON - refractory particulate organic nitrogen 23) macroalgae
! *** 12) LON - labile particulate organic nitrogen
! *** 13) DON - dissolved organic nitrogen
! *** 14) NHX - ammonia nitrogen
! *** 15) NOX - nitrate nitrogen
! *** 16) SUU - particulate biogenic silica
! *** 17) SAA - dissolved available silica
! *** 18) COD - chemical oxygen demand
! *** 19) DOX - dissolved oxygen
! *** 20) TAM - total active metal
! *** 21) FCB - fecal coliform bacteria
! *** 22) CO2 - dissolved carbon dioxide
! *** 23) macroalgae
! *** DTWQ - Water quality time step, which is typically in units of days
! *** DTWQO2 = DTWQ*0.5
! *** WQCHL = Chlorophyll a (ug/l)
! *** WQCHLC = carbon-to-chlorophyll ratio for cyanobacteria (mg C / ug Chl)
! *** WQCHLD = carbon-to-chlorophyll ratio for algae diatoms (mg C / ug Chl)
! *** WQCHLG = carbon-to-chlorophyll ratio for algae greens (mg C / ug Chl)
! *** WQKECHL = Light Extinction Coeff for CHLa (1/m per mg/l)
! *** WQKETSS = Light Extinction Coeff for TSS (1/m per mg/l)
! *** WQKEPOM = Light Extinction Coeff for POM (1/m per mg/l)
! *** WQKETOT(L,K) = Total Light Extinction
! *** WQDOPG = Optimal Depth for Growth - Green Algae
! *** RNH4WQ(L) = Ammonia (for Current Layer)
! *** RNO3WQ(L) = Nitrate (for Current Layer)
! *** PO4DWQ(L) = Phosphate (for Current Layer)
! *** RNH4NO3(L) = Total Inorganic Nitrogen (for Current Layer)
! *** WQKHNG = Nitrogen half-saturation for Algae-Greens (mg/L)
! *** WQKHPG = Phosphorus half-saturation for Algae-Greens (mg/L)
! *** WQKHCO2G = CO2 half-saturation for Algae-Greens (mg/L)
! *** XLIMIG = Rate Limiting Factor - Light
! *** XLIMTG = Rate Limiting Factor - Temperature (Lookup Table: WQTDGG)
! *** XLIMNG = Rate Limiting Factor - Nitrogen (Local-WQGNG)
! *** XLIMPG = Rate Limiting Factor - Phosphorus (Local-WQGPG)
! *** XLIMCO2G = Rate Limiting Factor - CO2 (Local-WQGPG)
! *** WQF1NG = Rate Limiting Factor, Minimum of N & P
! *** WQPMG = Maximum Growth Rate for Algae-Greens (1/d)
! *** WQPG = Current Growth Rate for Algae-Greens (1/d)
! *** WQBMG = Current Basal Metabolism Rate for Algae-Greens (1/d)
! *** WQPRG = Current Predation Metabolism Rate for Algae-Greens (1/d)
! *** WQBMRG = Basal Metabolism Rate for Algae-Greens (1/d)
! *** WQPRRG = Predation Rate for Algae-Greens (1/d)
! *** WQTDRG = Lookup Table for Temperature Rate Effect - Algae-Greens
! *** WQPC = Final Net Growth Rate - Cyanobacteria
! *** WQPD = Final Net Growth Rate - Diatoms Algae
! *** WQPG = Final Net Growth Rate - Green Algae
! *** WQPM = Final Net Growth Rate - Macroalgae
! *** WQPNC = Preference for ammonium uptake - Cyanobacteria
! *** WQPND = Preference for ammonium uptake - Diatoms Algae
! *** WQPNG = Preference for ammonium uptake - Green Algae
! *** WQOBTOT = Total Algal Biomass (mg/l)
! *** WQKRC = Minimum Dissolution Rate of Refractory POC (1/day)
! *** WQKLC = Minimum Dissolution Rate of Labile POC (1/day)
! *** WQKLCALG = Constant Refractory POC Dissolution Rate
! *** WQTDHDR = Lookup Table for Temperature Rate Effect for Hydrolysis
! *** WQKRPC = Current Dissolution Rate for POC
! *** WQI0 = SOLAR RADIATION for Current Time
! *** WQI1 = SOLAR RADIATION ON PREVIOUS DAY
! *** WQI2 = SOLAR RADIATION TWO DAYS AGO
! *** WQI3 = SOLAR RADIATION THREE DAYS AGO
! *** WQKHR = DOC Heterotrophic Respiration Rate
! *** WQWSSET = Water quality settling speed L;(L:1) is for top water layer; (L,2) is for lower water layers
! *** WQTTM = Temporary concentration variable
IF(.NOT.ALLOCATED(DZCHP))THEN
ALLOCATE(DZCHP(LCM))
ALLOCATE(WQISC(LCM))
ALLOCATE(WQISD(LCM))
ALLOCATE(WQISG(LCM))
ALLOCATE(WQISM(LCM))
ALLOCATE(WQI0TOP(LCM))
DZCHP=0.0
ENDIF
C
NS=1
WQKESS=0.0
C
C COMPUTE WQCHL,WQTAMP,WQPO4D,WQSAD AT A NEW TIME STEP: WQCHLX=1/WQCHLX
C
! *** Compute WQCHL (Chlorophyll) Using Algal Biomass & factors
DO K=1,KC
DO L=2,LA
WQCHL(L,K)=WQV(L,K,1)*WQCHLC
& +WQV(L,K,2)*WQCHLD
& +WQV(L,K,3)*WQCHLG
ENDDO
ENDDO
C
C INITIALIZE SOLAR RADIATION AND OPTIMAL LIGHT
C
! *** INITIAL SOLAR RADIATION AT TOP OF SURFACE LAYER
IF(USESHADE)THEN
DO L=2,LA
WQI0TOP(L)=WQI0 * PSHADE(L)
ENDDO
ELSE
DO L=2,LA
WQI0TOP(L)=WQI0
ENDDO
ENDIF
! *** COMPUTE THE CURRENT OPTIMAL LIGHT INTENSITY
IF(IWQSUN==2)THEN
WQAVGIO = WQCIA*WQI1 + WQCIB*WQI2 + WQCIC*WQI3
ELSE
WQAVGIO = WQCIA*WQI0 + WQCIB*WQI1 + WQCIC*WQI2
ENDIF
! *** CORRECT TO AVERAGE SOLAR RADIATION DURING DAYLIGHT HOURS
! WQAVGIO = WQAVGIO / (WQFD + 1.E-18) !!!!!!!!!!
! *** DZWQ=1/H (for a layer), VOLWQ=1/VOL (m^-3)
DO K=KC,1,-1
DO L=2,LA
TWQ(L)=TEM(L,K) !layer temperature for WQ calcs
SWQ(L)=MAX(SAL(L,K), 0.0) !layer salinity for WQ calcs
DZCHP(L)=DZC(K)*HP(L) !layer thickness of a cell in meters
DZWQ(L) = 1.0 / DZCHP(L) !inverse layer thickness
VOLWQ(L) = DZWQ(L) / DXYP(L) !inverse volume of each cell in a layer
IMWQZT(L)=IWQZMAP(L,K) !binary map for WQ calcs
ENDDO
! *** ZERO WQWPSL IF FLOWS ARE NEGATIVE. THESE ARE HANDLED IN CALFQC (PMC)
IF(IWQPSL/=2)THEN
DO NQ=1,NQSIJ
IF((QSERCELL(K,NQ)+QSS(K,NQ))<=0.0)WQWPSL(LQS(NQ),K,1:NWQV)=0.0 ! *** ZERO THE FLUX
ENDDO
ENDIF
IF(ISTRWQ(1)==1.OR.ISTRWQ(2)==1.OR.ISTRWQ(3)==1)THEN !EVALUATING THE RATE OF ALGAE LEAVING THE CELL THROUGH SETTLING OR FLOATING
DO L=2,LA
IF(WQWSC(IMWQZT(L))<0.0) THEN !VB PERMITS CYANOBACTERIA TO FLOAT AND/OR SETTLE
IF(K==KC) THEN
WQBCSET(L,1) = 0.0 !ALGAE AT THE WATER SURFACE CANT FLOAT INTO THE CELL ABOVE
ELSE
WQBCSET(L,1) = -WQWSC(IMWQZT(L))*DZWQ(L) ! *** CYANOBACTERIA !NEEDS TO BE A POSITIVE QTY
ENDIF
ELSE
WQBCSET(L,1) = WQWSC(IMWQZT(L))*DZWQ(L) ! *** CYANOBACTERIA
ENDIF
IF(WQWSD(IMWQZT(L))<0.0) THEN !VB PERMITS DIATOMS TO FLOAT AND/OR SETTLE
IF(K==KC) THEN
WQBDSET(L,1) = 0.0
ELSE
WQBDSET(L,1) = -WQWSD(IMWQZT(L))*DZWQ(L) ! *** Diatoms
ENDIF
ELSE
WQBDSET(L,1) = WQWSD(IMWQZT(L))*DZWQ(L) ! *** Diatoms
ENDIF
IF(WQWSG(IMWQZT(L))<0.0) THEN !VB PERMITS GREEN ALGAE TO FLOAT AND/OR SETTLE
IF(K==KC) THEN
WQBGSET(L,1) = 0.0
ELSE
WQBGSET(L,1) = -WQWSG(IMWQZT(L))*DZWQ(L) ! *** ALGAE
ENDIF
ELSE
WQBGSET(L,1) = WQWSG(IMWQZT(L))*DZWQ(L) ! *** ALGAE
ENDIF
ENDDO
ENDIF
! *** ZONE SPECIFIC SETTING VELOCITIES, (m/day)
IF(ISTRWQ(7)==1)WQRPSET(2:LA,1) = WQWSRP(IMWQZT(2:LA))*DZWQ(2:LA) ! *** Refractory POM
IF(ISTRWQ(8)==1)WQLPSET(2:LA,1) = WQWSLP(IMWQZT(2:LA))*DZWQ(2:LA) ! *** Labile POM
! *** SET SETTLING FOR TAM SORPTION: CURRENT LAYER
IF(IWQSRP==1)WQWSSET(2:LA,1) = WQWSS(IMWQZT(2:LA))*DZWQ(2:LA)
IF(K/=KC)IMWQZT1(2:LA)=IWQZMAP(2:LA,K+1)
IF(K/=1)IMWQZT2(2:LA)=IWQZMAP(2:LA,K-1)
IF(ISTRWQ(1)==1.OR.ISTRWQ(2)==1.OR.ISTRWQ(3)==1)THEN
DO L=2,LA
IF(K/=KC)THEN
IF(WQWSC(IMWQZT1(L))<0.0) THEN
WQBCSET(L,2) = 0.0
ELSE
WQBCSET(L,2) = WQWSC(IMWQZT1(L))*DZWQ(L)
ENDIF
IF(WQWSD(IMWQZT1(L))<0.0) THEN
WQBDSET(L,2) = 0.0
ELSE
WQBDSET(L,2) = WQWSD(IMWQZT1(L))*DZWQ(L)
ENDIF
IF(WQWSG(IMWQZT1(L))<0.0) THEN
WQBGSET(L,2) = 0.0
ELSE
WQBGSET(L,2) = WQWSG(IMWQZT1(L))*DZWQ(L)
ENDIF
ENDIF
IF(K/=1)THEN
IF(WQWSC(IMWQZT2(L))<0.0)WQBCSET(L,2) = WQBCSET(L,2)-WQWSC(IMWQZT2(L))*DZWQ(L)
IF(WQWSD(IMWQZT2(L))<0.0)WQBDSET(L,2) = WQBDSET(L,2)-WQWSD(IMWQZT2(L))*DZWQ(L)
IF(WQWSG(IMWQZT2(L))<0.0)WQBGSET(L,2) = WQBGSET(L,2)-WQWSG(IMWQZT2(L))*DZWQ(L)
ENDIF
ENDDO
ENDIF
IF(K/=KC) THEN
DO L=2,LA
WQRPSET(L,2) = WQWSRP(IMWQZT1(L))*DZWQ(L)
WQLPSET(L,2) = WQWSLP(IMWQZT1(L))*DZWQ(L)
ENDDO
ENDIF
! *** SET SETTLING FOR TAM SORPTION: ONE LAYER UP
IF(IWQSRP==1.AND.K/=KC)THEN
DO L=2,LA
WQWSSET(L,2) = WQWSS(IMWQZT1(L))*DZWQ(L)
ENDDO
ENDIF
C
C FIND AN INDEX FOR LOOK-UP TABLE FOR TEMPERATURE DEPENDENCY
C
! *** DSLLC BEGIN BLOCK
DO L=2,LA
IWQT(L)=NINT((TWQ(L)-WQTDMIN)/WQTDINC)+1
ENDDO
DO L=2,LA
IF(IWQT(L)<1 .OR. IWQT(L)>NWQTD)THEN
OPEN(1,FILE='ERROR'//ans(partid2)//'.LOG',POSITION='APPEND',STATUS='UNKNOWN')
WRITE(1,*)' *** ERROR IN WQSKE1:TEMPERATURE LOOKUP TABLE'
WRITE(1,911) TIMEDAY, L, IL(L), JL(L), K, TWQ(L),TEM(L,K)
WRITE(6,600)IL(L),JL(L),K,TWQ(L),TEM(L,K)
IWQT(L)=MAX(IWQT(L),1)
IWQT(L)=MIN(IWQT(L),NWQTD)
CLOSE(1,STATUS='KEEP')
ENDIF
ENDDO
! *** DSLLC END BLOCK
600 FORMAT(' I,J,K,TWQ,TEM = ',3I5,2E13.4)
911 FORMAT('ERROR: TIME, L, I, J, K, TWQ(L),TEM(L,K) = ',
& F10.5, I5, 2I4, I3, 2F10.4,/)
!C NOTE: MRM 04/29/99 ADDED ARRAYS TO KEEP TRACK OF
!C NITROGEN, PHOSPHORUS, LIGHT, AND TEMPERATURE LIMITS
!C FOR ALGAE GROWTH FOR CYANOBACTERIA, DIATOMS, GREENS,
!C AND MACROALGAE. THESE ARE THE ARRAYS:
!C XLIMNX(L,K) = NITROGEN LIMITATION FOR ALGAE GROUP X
!C XLIMPX(L,K) = PHOSPHORUS LIMITATION FOR ALGAE GROUP X
!C XLIMIX(L,K) = LIGHT LIMITATION FOR ALGAE GROUP X
!C XLIMTX(L,K) = TEMPERATURE LIMITATION FOR ALGAE GROUP X
! *** BEGIN HORIZONTAL LOOP FOR ALGAE PARMETERS
DO L=2,LA
RNH4WQ(L) = MAX (WQV(L,K,14), 0.0) ! *** Ammonia
RNO3WQ(L) = MAX (WQV(L,K,15), 0.0) ! *** Nitrate
PO4DWQ(L) = MAX (WQPO4D(L,K), 0.0) ! *** Phosphate
RNH4NO3(L) = RNH4WQ(L) + RNO3WQ(L) ! *** Total Inorganic Nitrogen
IF(ISTRWQ(22)==1)CO2WQ(L) = MAX (WQV(L,K,22), 0.0) ! *** CO2
ENDDO
DO L=2,LA
IF(ISTRWQ(1)==1.OR.ISTRWQ(2)==1.OR.ISTRWQ(3)==1)THEN !Microalgae?
WQGNC = RNH4NO3(L) / (WQKHNC+RNH4NO3(L) + 1.E-18)
WQGND = RNH4NO3(L) / (WQKHND+RNH4NO3(L) + 1.E-18)
WQGNG = RNH4NO3(L) / (WQKHNG+RNH4NO3(L) + 1.E-18)
WQGPC = PO4DWQ(L) / (WQKHPC+PO4DWQ(L) + 1.E-18)
WQGPD = PO4DWQ(L) / (WQKHPD+PO4DWQ(L) + 1.E-18)
WQGPG = PO4DWQ(L) / (WQKHPG+PO4DWQ(L) + 1.E-18)
WQGCO2C = CO2WQ(L) / (WQKHCO2C+CO2WQ(L) + 1.E-18)
WQGCO2D = CO2WQ(L) / (WQKHCO2D+CO2WQ(L) + 1.E-18)
WQGCO2G = CO2WQ(L) / (WQKHCO2G+CO2WQ(L) + 1.E-18)
XLIMNC(L,K) = XLIMNC(L,K) + WQGNC !Cyanobacteria nitrogen limitation
XLIMND(L,K) = XLIMND(L,K) + WQGND !Diatom nitrogen limitation
XLIMNG(L,K) = XLIMNG(L,K) + WQGNG !Green algae nitrogen limitation
XLIMPC(L,K) = XLIMPC(L,K) + WQGPC !Cyanobacteria phosphorus limitation
XLIMPD(L,K) = XLIMPD(L,K) + WQGPD !Diatom phosphorus limitation
XLIMPG(L,K) = XLIMPG(L,K) + WQGPG !Green algae phosphorus limitation
XLIMCO2C(L,K) = XLIMCO2C(L,K) + WQGCO2C !Cyanobacteria CO2 limitation
XLIMCO2D(L,K) = XLIMCO2D(L,K) + WQGCO2D !Diatom CO2 limitation
XLIMCO2G(L,K) = XLIMCO2G(L,K) + WQGCO2G !Green algae CO2 limitation
XLIMTC(L,K) = XLIMTC(L,K) + WQTDGC(IWQT(L)) !Cyanobacteria temperature limitation
XLIMTD(L,K) = XLIMTD(L,K) + WQTDGD(IWQT(L)) !Diatom temperature limitation
XLIMTG(L,K) = XLIMTG(L,K) + WQTDGG(IWQT(L)) !Green algae temperature limitation
IF(ISTRWQ(22)>0)THEN
WQF1NC = MIN(WQGNC, WQGPC, WQGCO2C) !Minimum of the N/P/CO2 Limit: Cyanobacteria
ELSE
WQF1NC = MIN(WQGNC, WQGPC) !Minimum of the N/P Limit: Cyanobacteria
ENDIF
IF(IWQSI==1)THEN !SILICA LIMITATION?
SADWQ = MAX (WQSAD(L,K), 0.0)
WQGSD = SADWQ / (WQKHS+SADWQ+ 1.E-18)
IF(ISTRWQ(22)>0)THEN !CO2 LIMITATION?
WQF1ND = MIN(WQGND, WQGPD, WQGSD, WQGCO2D) !Minimum of the N/P/Si/CO2 Limit: Diatoms
ELSE
WQF1ND = MIN(WQGND, WQGPD, WQGSD) !Minimum of the N/P/Si Limit: Diatoms
ENDIF
ELSEIF(IWQSI==0)THEN
IF(ISTRWQ(22)>0)THEN !CO2 LIMITATON?
WQF1ND = MIN(WQGND, WQGPD, WQGCO2D) !Minimum of the N/P/CO2 Limit: Diatoms
ELSE
WQF1ND = MIN(WQGND, WQGPD) !Minimum of the N/P Limit: Diatom
ENDIF
ENDIF
IF(ISTRWQ(22)>0)THEN
WQF1NG = MIN(WQGNG, WQGPG, WQGCO2G) !Minimum of the N/P/CO2 Limit: Greens
ELSE
WQF1NG = MIN(WQGNG, WQGPG) !Minimum of the N/P Limit: Greens
ENDIF
C
C ALGAL BASAL METABOLISM & PREDATION
C
WQBMC(L) = WQBMRC(IMWQZT(L)) * WQTDRC(IWQT(L))
WQPRC(L) = WQPRRC(IMWQZT(L)) * WQTDRC(IWQT(L))
C
C THE VARIABLE WQTDGP ADJUSTS PREDATION AND BASAL METABOLISM BASED ON A
C LOWER/UPPER OPTIMUM TEMPERATURE FUNCTION. THIS WILL ALLOW DIATOMS TO
C BLOOM IN WINTER IF WQTDGP IS CLOSE TO ZERO.
C
WQBMD(L)=WQBMRD(IMWQZT(L))*WQTDRD(IWQT(L))*WQTDGP(IWQT(L))
WQPRD(L)=WQPRRD(IMWQZT(L))*WQTDRD(IWQT(L))*WQTDGP(IWQT(L))
WQBMG(L) = WQBMRG(IMWQZT(L)) * WQTDRG(IWQT(L))
WQPRG(L) = WQPRRG(IMWQZT(L)) * WQTDRG(IWQT(L))
ENDIF
!***For macroalgae defined in VEGE.INP IDNOTRVA>0
IF(RMAC(L,K)>0.0)THEN !RMAC is the ratio of a layer occupied by macroalgae as calculated in CALTBXY
!***WQGNM is nitrate/ammonium limitation
WQGNM = RNH4NO3(L) / (WQKHNM+RNH4NO3(L) + 1.E-18)
MACLIM(L,K,4) = WQGNM !NO3/NH4 limitation saved
!***WQGPM is phosphate limitation
WQGPM = PO4DWQ(L) / (WQKHPM+PO4DWQ(L) + 1.E-18)
MACLIM(L,K,5) = WQGPM !PO4 limitation saved
!***WQGCO2M is CO2 limitation
!***WQF1NM is total nutrient limitation
IF(ISTRWQ(22)>0)THEN
WQGCO2M = CO2WQ(L) / (WQKHCO2M+CO2WQ(L) + 1.E-18) !CO2 macroalgae limitation
MACLIM(L,K,6) = WQGCO2M !CO2 limitation saved
WQF1NM = MIN(WQGNM, WQGPM, WQGCO2M) !Minimum of the N/P/CO2 Limit: macroalgae
XLIMCO2M(L,K) = XLIMCO2M(L,K) + WQGCO2M !CO2
ELSE
WQF1NM = MIN(WQGNM, WQGPM) !Minimum of the N/P Limit: macroalgae
ENDIF
XLIMNM(L,K) = XLIMNM(L,K) + WQGNM !Macroalgae nitrate/ammonium limitation
XLIMPM(L,K) = XLIMPM(L,K) + WQGPM !Macroalgae phosphorus limitation
XLIMTM(L,K) = XLIMTM(L,K) + WQTDGM(IWQT(L)) !Macroalgae temperature limitation
MACLIM(L,K,3) = WQTDGM(IWQT(L)) !Temperature limitation saved
!C BIOLOGICAL CARRYING CAPACITY LIMITATION
!C FIRST CONVERT FROM MACROALGAE FROM A CONCENTRATION (MG C/M3) TO A DENSITY (MG C/M2).
IF(IWQVLIM>0)THEN !Is biomass carrying capacity a limitation?
XMRM = WQV(L,K,IDNOTRVA)*DZCHP(L)
WQLDF = WQKBP(L) / (WQKBP(L) + XMRM) !Macroalgae biomass carrying capacity limitation
XLIMDM(L,K) = XLIMDM(L,K) + WQLDF
ELSE
WQLDF=1.0 !No macroalgal biomass carrying capacity limitation on growth
ENDIF
!C OPTION 1 FOR VELOCITY LIMITATION ASSUMES MACROALGAE GROWTH
!C IS LIMITED AT LOW VELOCITIES DUE TO REDUCED AVAILABILITY OF
!C NUTRIENTS REACHING THE ALGAE BIOMASS. USES A MICHAELIS-MENTON
!C TYPE OF EQUATION.
IF(IWQVLIM==1)THEN !Is macroalgal growth limited according to the Michaelis-Menton equation?
LE=LEAST(L)
LN=LNC(L)
UMRM = 0.5*( U(L,K) + U(LE,K) )
VMRM = 0.5*( V(L,K) + V(LN, K) )
WQVEL=SQRT(UMRM*UMRM + VMRM*VMRM)
IF(WQVEL>WQKMVMIN(L))THEN
WQLVF = WQVEL / (WQKMV(L) + WQVEL)
ELSE
WQLVF = WQKMVMIN(L) / (WQKMV(L) + WQKMVMIN(L))
ENDIF
!C OPTION 2 FOR VELOCITY LIMITATION APPLIES A FIVE-PARAMETER LOGISTIC
!C FUNCTION THAT CAN BE ADJUSTED TO LIMIT MACROALGAE GROWTH FOR
!C EITHER LOW OR HIGH (SCOUR) VELOCITIES. IN STREAMS WITH LOW NUTRIENTS,
!C THE LOW VELOCITY WILL LIKELY BE LIMITING SINCE AMPLE NUTRIENTS MAY
!C NOT REACH THE ALGAE BIOMASS DUE TO REDUCED FLOW. IN STREAMS WITH
!C ABUNDANT NUTRIENTS, LOW VELOCITIES WILL NOT LIMIT MACROALGAE GROWTH,
!C INSTEAD, HIGH VELOCITIES WILL LIKELY SCOUR THE MACROALGAE AND DETACH
!C IT FROM THE SUBSTRATE.
ELSEIF(IWQVLIM==2)THEN !Is macroalgal growth limited according to a five-parameter logistic equation?
XNUMER = WQKMVA(L) - WQKMVD(L)
XDENOM = 1.0 + (WQVEL/WQKMVC(L))**WQKMVB(L)
WQLVF = WQKMVD(L) + ( XNUMER / (XDENOM**WQKMVE(L)) )
XLIMVM(L,K) = XLIMVM(L,K) + WQLVF !Macroalgae velocity limitation
ELSE !No macroalgal velocity limitation on growth
WQLVF=1.0
ENDIF
! *** USE THE MORE SEVERELY LIMITING OF VELOCITY OR NUTRIENT FACTORS:
WQF1NM = MIN(WQLVF, WQF1NM)
! *** MACROALGAE BASAL METABOLISM AND PREDATION
WQBMM(L) = WQBMRM(IMWQZT(L)) * WQTDRM(IWQT(L))
WQPRM(L) = WQPRRM(IMWQZT(L)) * WQTDRM(IWQT(L))
MACLIM(L,K,7) = WQBMM(L) !Macroalgae basal metabolic rate saved
MACLIM(L,K,8) = WQPRM(L) !Macroalgae predation rate saved
ENDIF !End of macroalgae nutrient, biomass carrying capacity, and velocity limitation calculations
! *** IN C&C, F2IC=F2IC/FCYAN, FACTOR TO ALLOW CYANOBACTERIA MAT FORMATION
! *** COMPUTE TOTAL EXTINCTION COEFFICIENT
! *** LIGHT EXTINCTION (THIS WILL ALWAYS BE TRUE EXCEPT FOR IWQSUN=2)
WQKESS=WQKEB(IMWQZT(L)) !Start with background light extinction
IF(ISTRWQ(4)>0.OR.ISTRWQ(5)>0)WQKESS=WQKESS+WQKEPOM*(WQV(L,K,4)+WQV(L,K,5))*DZCHP(L) !Add any refractory and particulate organic carbon component
IF(ISTRAN(6)>0.OR.ISTRAN(7)>0)WQKESS=WQKESS+WQKETSS*(SEDT(L,K)+SNDT(L,K)) *DZCHP(L) !Add any sediment component
IF(ISTRWQ(1)==1.OR.ISTRWQ(2)==1.OR.ISTRWQ(3)==1)THEN !Add any Chlorophyll component
IF(WQKECHL<0.0)THEN
! *** Compute Extinction Factor as a fn(Chla)
XMRM = 0.054*WQCHL(L,K)**0.6667 + 0.0088*WQCHL(L,K)
ELSE
XMRM = WQKECHL*WQCHL(L,K)
ENDIF
WQKESS = WQKESS+XMRM
ENDIF
IF(RMAC(L,K)>0)WQKESS = WQKESS + WQKECHL*WQV(L,K,IDNOTRVA)*DZCHP(L) !Add any macroalgae component (may need its own light extinction, Ke, variable WQKEMAC)
IF(K==KC)THEN !Specify surface solar radiation intensity
WQITOP(L,K) = WQI0TOP(L)
ELSE !Calculate solar radiation intensity as a function of the layer above's solar radiation intensity
WQITOP(L,K) = WQITOP(L,K+1)*EXP(-WQKESS*DZCHP(L))
ENDIF !SEE DiTORO ET AL. (1971, EQNS. (11)&(12))
! *** NOTE THAT LIGHT LIMITATION IS DUE TO EITHER Cyanobacteria, Diatoms, Green algae, or Macroalgae, BUT THESE ARE NOT ADDITIVE.
! IN SYSTEMS WITH MORE THAT ONE MICROALGAE OR MICROALGAE PLUS MACROALGAE, THIS MUST BE REWRITTEN TO BE ADDITIVE.
IF(WQI0>0.1.AND.(ISTRWQ(1)==1.OR.ISTRWQ(2)==1.OR.ISTRWQ(3)==1))THEN !If there is solar radiation and microalgae
! *** OPTIMAL LIGHT INTENSITY AT OPTIMAL DEPTH
IF(K==KC)THEN
WQISC(L) = MAX( WQAVGIO*EXP(-WQKESS*WQDOPC),WQISMIN)
WQISD(L) = MAX( WQAVGIO*EXP(-WQKESS*WQDOPD),WQISMIN)
WQISG(L) = MAX( WQAVGIO*EXP(-WQKESS*WQDOPG),WQISMIN)
ENDIF
! *** LIGHT GROWTH-LIMITING FACTOR
EXPA0=EXP(-WQITOP(L,K)/WQISC(L))
EXPA1=EXP(-WQITOP(L,K)/WQISC(L)*EXP(-WQKESS*DZCHP(L)))
WQF2IC=EXP(1.0)*WQFD/(DZCHP(L)*WQKESS)*(EXPA1-EXPA0) !Cyanobacteria light limitation
XLIMIC(L,K) = XLIMIC(L,K) + WQF2IC
EXPA0=EXP(-WQITOP(L,K)/WQISD(L))
EXPA1=EXP(-WQITOP(L,K)/WQISD(L)*EXP(-WQKESS*DZCHP(L)))
WQF2ID=EXP(1.0)*WQFD/(DZCHP(L)*WQKESS)*(EXPA1-EXPA0) !Diatom light limitation
XLIMID(L,K) = XLIMID(L,K) + WQF2ID
EXPA0=EXP(-WQITOP(L,K)/WQISG(L))
EXPA1=EXP(-WQITOP(L,K)/WQISG(L)*EXP(-WQKESS*DZCHP(L)))
WQF2IG=EXP(1.0)*WQFD/(DZCHP(L)*WQKESS)*(EXPA1-EXPA0) !Green algae light limitation
XLIMIG(L,K) = XLIMIG(L,K) + WQF2IG
! *** Compute Microalgal Growth Rates due to Limitation Factors
IF(IWQSTOX==1)THEN !Are cyanotoxins considered?
WQF4SC = WQSTOX / (WQSTOX + SWQ(L)*SWQ(L)+1.E-12)
WQPC(L)=WQPMC(IMWQZT(L))*WQF1NC*WQF2IC*WQTDGC(IWQT(L))*WQF4SC
ELSE
WQPC(L) = WQPMC(IMWQZT(L))*WQF1NC*WQF2IC*WQTDGC(IWQT(L))
ENDIF
WQPD(L) = WQPMD(IMWQZT(L))*WQF1ND*WQF2ID*WQTDGD(IWQT(L))
WQPG(L) = WQPMG(IMWQZT(L))*WQF1NG*WQF2IG*WQTDGG(IWQT(L))
ENDIF
! *** MACROALGAE SUBMODEL
IF(WQI0>0.1 .AND. RMAC(L,K)>0.0)THEN !If there is solar radiation and some macroalgae present in this layer
IZ=IWQZMAP(L,K)
WQISM(L) = MAX( WQAVGIO*EXP(-WQKESS*WQDOPM(IZ)), WQISMIN ) !Optimal light
! *** SOLAR RADIATION AT TOP OF THIS LAYER
EXPA0=EXP(-WQITOP(L,K)/WQISM(L)) !Macroalgae
! *** UPDATE SOLAR RADIATION AT BOTTOM OF THIS LAYER
EXPA1=EXP(-WQITOP(L,K)/WQISM(L)*EXP(-WQKESS*DZCHP(L))) !Macroalgae
!*********WQF2IM is the light limitation for macroalgae
WQF2IM=EXP(1.0)*WQFD/(DZCHP(L)*WQKESS)*(EXPA1-EXPA0) !Macroalgae light limitation
XLIMIM(L,K) = XLIMIM(L,K) + WQF2IM !*********XLIMIM is the light limitation for macroalgae
MACLIM(L,K,2) = WQF2IM !light limitation saved
!*** Maximum macroalgae growth rate modulated by WQF2IM (light limitation}, WQF1NM (nutrient limitation), WQTDGM (temperature limitation), and WQLDF (ecological carrying capacity limitation)
WQPM(L)= WQPMM(IMWQZT(L))*WQF2IM*WQF1NM*WQTDGM(IWQT(L))*WQLDF !Macroalgae growth rate f(I)*h(N)*g(T)*ecological carrying capacity (note that velocity limitation was already considered as a component of nutrient limitation)
MACLIM(L,K,1) = WQPM(L) !Macroalgae growth rate saved
!SCJ debug write out!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! if(L==284.and.K==13)then
! print*,(MACLIM(L,K,NQ),NQ=1,5)!!!!!!!!!!!!!!!!!!!!
! print*,'Biomass:',WQV(L,K,IDNOTRVA),WQV(L,K,14),WQV(L,19,14)!!!!!!!!!!!
! endif
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ENDIF
ENDDO
C
C END HORIZONTAL LOOP FOR ALGAE PARMETERS
C
XMRM = 0.0
DO L=2,LA
IZ=IWQZMAP(L,K)
WQOBTOT(L) = WQV(L,K,1)+WQV(L,K,2)+WQV(L,K,3)
WQKRPC(L) = (WQKRC + WQKRCALG*WQOBTOT(L)) * WQTDHDR(IWQT(L))
WQKLPC(L) = (WQKLC + WQKLCALG*WQOBTOT(L)) * WQTDHDR(IWQT(L))
IF(RMAC(L,K)>0.0) !If macroalgae are present in this layer
& XMRM = WQKDCALM(IZ) * WQV(L,K,IDNOTRVA) !Check if it makes sense to multiply by RMAC
C
C M. MORTON 08/28/99: ADDED SPATIALLY VARIABLE DOC HYDROLYSIS RATE WQKDC
C TO ACHIEVE BETTER CONTROL IN SYSTEMS WITH A COMBINATION OF FRESHWAT
C STREAMS AND TIDAL RIVERS WITH DIFFERENT CHARACTERISTICS.
C
WQKDOC=(WQKDC(IZ)+WQKDCALG*WQOBTOT(L) + XMRM)*WQTDMNL(IWQT(L))
O2WQ(L) = MAX(WQV(L,K,19), 0.0)
WQTT1 = WQKDOC / (WQKHORDO + O2WQ(L) + 1.E-18)
WQKHR(L) = WQTT1 * O2WQ(L)
WQDENIT(L)=WQTT1*WQAANOX*RNO3WQ(L)/(WQKHDNN+RNO3WQ(L) + 1.E-18)
ENDDO
C
C 7-10 PHOSPHORUS
C
! *** HYDROLYSIS
DO L=2,LA
WQAPC(L)=1.0/(WQCP1PRM+WQCP2PRM*EXP(-WQCP3PRM*PO4DWQ(L)))
WQKHP = (WQKHPC+WQKHPD+WQKHPG) / 3.0
WQTT1 = WQKHP / (WQKHP+PO4DWQ(L) + 1.E-18) * WQOBTOT(L)
WQKRPP(L) = (WQKRP + WQKRPALG*WQTT1) * WQTDHDR(IWQT(L)) ! *** RPOP--> PO4
WQKLPP(L) = (WQKLP + WQKLPALG*WQTT1) * WQTDHDR(IWQT(L)) ! *** LPOP--> DOP
WQKDOP(L) = (WQKDP + WQKDPALG*WQTT1) * WQTDMNL(IWQT(L)) ! *** DOP --> PO4
ENDDO
! *** PHOSPHATE SETTLING
DO L=2,LA
IF(IWQSRP==1)THEN
WQTTM = WQKPO4P*WQTAMP(L,K)
WQH10(L) = - WQWSSET(L,1) * WQTTM / (1.0+WQTTM)
IF(K/=KC)THEN
WQTTM = WQKPO4P*WQTAMP(L,K+1)
WQT10(L) = WQWSSET(L,2) * WQTTM / (1.0+WQTTM)
ENDIF
ELSEIF(IWQSRP==2)THEN
WQTTS = WQKPO4P*SEDT(L,K)
WQH10(L) = - WSEDO(NS) * WQTTS * DZWQ(L) / (1.0+WQTTS)
IF(K/=KC)THEN
WQTTS = WQKPO4P*SEDT(L,K)
WQT10(L) = WSEDO(NS) * WQTTS * DZWQ(L) / (1.0+WQTTS)
ENDIF
ELSE
WQH10(L) = 0.0
WQT10(L) = 0.0
ENDIF
WQH10(L) = WQH10(L)*DTWQO2
ENDDO
C
C 11-15 NITROGEN
C
! *** HYDROLYSIS
DO L=2,LA
WQKHN = (WQKHNC+WQKHND+WQKHNG) / 3.0
WQTT1 = WQKHN / (WQKHN+RNH4NO3(L) + 1.E-18) * WQOBTOT(L)
WQKRPN(L) = (WQKRN + WQKRNALG*WQTT1) * WQTDHDR(IWQT(L)) ! *** RPON-->NH3
WQKLPN(L) = (WQKLN + WQKLNALG*WQTT1) * WQTDHDR(IWQT(L)) ! *** LON -->DON
WQKDON(L) = (WQKDN + WQKDNALG*WQTT1) * WQTDMNL(IWQT(L)) ! *** DON -->NH3
ENDDO
DO L=2,LA
IF(RNH4NO3(L)==0.0)THEN
WQPNC(L)=0.0
WQPND(L)=0.0
WQPNG(L)=0.0
WQPNM(L)=0.0
ELSE
WQTTC = RNH4WQ(L)/(WQKHNC+RNO3WQ(L) + 1.E-18)
WQTTD = RNH4WQ(L)/(WQKHND+RNO3WQ(L) + 1.E-18)
WQTTG = RNH4WQ(L)/(WQKHNG+RNO3WQ(L) + 1.E-18)
WQTTM = RNH4WQ(L)/(WQKHNM+RNO3WQ(L) + 1.E-18)
WQPNC(L) = (RNO3WQ(L)/(WQKHNC+RNH4WQ(L) + 1.E-18)
& + WQKHNC/(RNH4NO3(L) + 1.E-18)) * WQTTC
WQPND(L) = (RNO3WQ(L)/(WQKHND+RNH4WQ(L) + 1.E-18)
& + WQKHND/(RNH4NO3(L) + 1.E-18)) * WQTTD
WQPNG(L) = (RNO3WQ(L)/(WQKHNG+RNH4WQ(L) + 1.E-18)
& + WQKHNG/(RNH4NO3(L) + 1.E-18)) * WQTTG
WQPNM(L) = (RNO3WQ(L)/(WQKHNM+RNH4WQ(L) + 1.E-18)
& + WQKHNM/(RNH4NO3(L) + 1.E-18)) * WQTTM
ENDIF
WQNIT(L) = O2WQ(L) * WQTDNIT(IWQT(L)) /
& ( (WQKHNDO+O2WQ(L)) * (WQKHNN+RNH4WQ(L)) + 1.E-18)
ENDDO
IF(IWQSI==1)THEN
DO L=2,LA
IF(IWQSRP==1)THEN
WQTTM = WQKSAP*WQTAMP(L,K)
WQN17(L) = - WQWSSET(L,1) * WQTTM / (1.0+WQTTM)
IF(K/=KC)THEN
WQTTM = WQKSAP*WQTAMP(L,K+1)
WQT17(L) = WQWSSET(L,2) * WQTTM / (1.0+WQTTM)
ENDIF
ELSEIF(IWQSRP==2)THEN
WQTTS = WQKSAP*SEDT(L,K)
WQN17(L) = - WSEDO(NS) * WQTTS * DZWQ(L) / (1.0+WQTTS)
IF(K/=KC)THEN
WQTTS = WQKSAP*SEDT(L,K+1)
WQT17(L) = WSEDO(NS) * WQTTS * DZWQ(L) / (1.0+WQTTS)
ENDIF
ELSE
WQN17(L) = 0.0
WQT17(L) = 0.0
ENDIF
ENDDO
WQN17(L) = WQN17(L)*DTWQO2
ENDIF
C
IF(ISTRWQ(22)==1)THEN
PPCDO=-3.45 !PARTIAL PRES OF CO2 IN 10^ppcdo ATM; TEMPORARILY DECLARED HERE. SHOULD BE READ IN FROM INPUT FILE
DO L=2,LA
IZ=IWQZMAP(L,K)
WQO18(L)= -DTWQO2*WQKCOD(IWQT(L),IZ)*O2WQ(L)/
& (WQKHCOD(IZ) + O2WQ(L) + 1.E-18)
C
! *** DO Saturation, MOD BY TT, SEE CHAPRA (1997) PG. 3
! TVAL1=1./(TWQ(L)+273.15)
! TVAL2=TVAL1*TVAL1
! TVAL3=TVAL1*TVAL2
! TVAL4=TVAL2*TVAL2
! RLNSAT1=-139.3441+(1.575701E+5*TVAL1)-(6.642308E+7*TVAL2)
! & +(1.2438E+10*TVAL3)-(8.621949E+11*TVAL4)
! RLNSAT2=RLNSAT1-SWQ(L)*( 1.7674E-2-(1.0754E+1*TVAL1)
! & +(2.1407E+3*TVAL2) )
! WQDOS(L) = EXP(RLNSAT2)
! XDOSAT(L,K) = XDOSAT(L,K) + WQDOS(L)*DTWQ*DZCHP(L)
! *** DO Saturation, Modified by SCJ, see Garcia and Gordon, Limnology and Oceanography 37(6), 1992, Eqn. 8 and Table 1
TVAL1=LOG((298.15-TWQ(L))/(273.15+TWQ(L)))
TVAL2=TVAL1*TVAL1
TVAL3=TVAL1*TVAL2
TVAL4=TVAL1*TVAL3
TVAL5=TVAL1*TVAL4
RLNSAT1=5.80818+3.20684*TVAL1+4.11890*TVAL2+4.93845*TVAL3
& +1.01567*TVAL4+1.41575*TVAL5
RLNSAT2=SWQ(L)*(-7.01211E-3-7.25958E-3*TVAL1-7.93334E-3*TVAL2
& -5.54491E-3*TVAL3)-1.32412E-7*SWQ(L)*SWQ(L)
WQDOS(L) = EXP(RLNSAT1+RLNSAT2)*32E-3 !32E-3 approximately converts micromol/L to mg/L or g/m^3
XDOSAT(L,K) = XDOSAT(L,K) + WQDOS(L)*DTWQ*DZCHP(L)
!************* CO2 parameters
CDOSATIDX(L) = -2385.73/(TWQ(L) + 273.15) - !VB COMPUTING THE pK FOR SAT CONC OF CO2; K - HENRY'S CONST
& 0.0152642 * (TWQ(L) + 273.15) + 14.0184
! K * MOL WT OF CO2 * PARTIAL PRES OF CO2 IN ATM
WQCDOS(L) = 10.**(-CDOSATIDX(L)+PPCDO) * (44.* 1000.) !VB EVALUATING CONC OF CO2 IN G/M^3
!************* CO2 parameters
! *** Compute Reaeration
IF(K==KC)THEN
WINDREA = WINDST(L)
! DO NOT ALLOW WIND SPEEDS ABOVE 11 M/SEC IN THE FOLLOWING EQUATION
WQWREA=0.728*SQRT(WINDREA)+(0.0372*WINDREA-0.317)*WINDREA
C
LE=LEAST(L)
LN=LNC(L)
IF(IWQKA(IZ)==0)THEN
WQVREA = WQKRO(IZ)
WQWREA = 0.0
ELSEIF(IWQKA(IZ)==1)THEN
WQVREA = WQKRO(IZ)
ELSEIF(IWQKA(IZ)==2)THEN
UMRM = 0.5*(U(L,K)+U(LE,K))
VMRM = 0.5*(V(L,K)+V(LN,K))
XMRM = SQRT(UMRM*UMRM + VMRM*VMRM)
! *** WQKRO = 3.933 TYPICALLY
WQVREA = WQKRO(IZ) * XMRM**0.5 / HP(L)**0.5
ELSEIF(IWQKA(IZ)==3)THEN
UMRM = MAX(U(L,K), U(LE,K))
VMRM = MAX(V(L,K), V(LN,K))
XMRM = SQRT(UMRM*UMRM + VMRM*VMRM)
! *** WQKRO = 5.32 TYPICALLY
WQVREA = WQKRO(IZ) * XMRM**0.67 / HP(L)**1.85
ELSEIF(IWQKA(IZ)==4)THEN
! *** MODIFIED OWENS AND GIBBS REAERATION EQUATION:
! *** NOTE: NORMALIZED TO A DEPTH OF 1.0 FT, I.E., THIS EQUATION GIVES THE
! *** SAME REAERATION AS OWENS & GIBBS AT 1.0 FT DEPTH; AT HIGHER
! *** DEPTHS IT GIVES LARGER REAERATION THAN OWENS & GIBBS.
UMRM = MAX(U(L,K), U(LE,K))
VMRM = MAX(V(L,K), V(LN,K))
XMRM = SQRT(UMRM*UMRM + VMRM*VMRM)
YMRM = HP(L)*3.0*(1.0 - HP(L)/(HP(L)+0.1524))
! *** WQKRO = 5.32 TYPICALLY
WQVREA = WQKRO(IZ) * XMRM**0.67 / YMRM**1.85
ELSEIF(IWQKA(IZ)== 5)THEN
UMRM = MAX(U(L,K), U(LEAST(L),K))
VMRM = MAX(V(L,K), V(LNC(L),K))
XMRM = SQRT(UMRM*UMRM + VMRM*VMRM)
WQVREA = 3.7*XMRM
ENDIF
! *** NOW COMBINE REAERATION DUE TO WATER VELOCITY AND WIND STRESS
WQVREA = WQVREA * REAC(IZ)
WQWREA = WQWREA * REAC(IZ)
WQP19(L) = - (WQVREA + WQWREA) * DZWQ(L)* WQTDKR(IWQT(L),IZ)
WQKRDOS(L) = -WQP19(L)*WQDOS(L)
WQP22(L) = WQP19(L)*((32./44.)**0.25) !VB Kr FOR CO2 ANALOGOUS TO WQP19 ; 44 = MOL WT OF CO2
WQKRCDOS(L) = -WQP22(L) * WQCDOS(L) !VB EVALUATING Kr*SAT CONC OF CO2
ELSE
WQP19(L) = 0.0
WQP22(L) = 0.0 !VB Kr FOR CO2 IS ZERO FOR CELLS NOT AT THE SURFACE
ENDIF
ENDDO
IF(IWQSRP==1)THEN
WQR20(2:LA) = WQWPSL(2:LA,K,20)*VOLWQ(2:LA)
& + (WQV(2:LA,K,20) - WQTAMP(2:LA,K)) * WQWSSET(2:LA,1)
IF(K==1)THEN
DO L=2,LA
IF(LMASKDRY(L))THEN
WQR20(L) = WQR20(L)
& + WQTDTAM(IWQT(L))*DZWQ(L)/(WQKHBMF+O2WQ(L) + 1.E-18)
ENDIF
ENDDO
ENDIF
IF(K/=KC)THEN
WQR20(2:LA) = WQR20(2:LA)
& + (WQV(2:LA,K+1,20) - WQTAMP(2:LA,K+1)) * WQWSSET(2:LA,2)
ELSE ! K==KC
WQR20(2:LA)=WQR20(2:LA)+(WQWDSL(2:LA,KC,20)+WQATML(2:LA,KC,20))*VOLWQ(2:LA)
ENDIF
ENDIF
ENDIF
C
! WQA1Cmax=0.0;WQA1Cmin=0.0
DO M=1,MCOUNT !Macroalgae
L=IJLMAC(M,3)
IF(RMAC(L,K)>0.0)THEN
WQA1C = (WQPM(L) - WQBMM(L) - WQPRM(L)-WQWSM*DZWQ(L))*DTWQO2 !RMAC factor
! WQA1Cmax=max(WQA1Cmax,WQA1C);WQA1Cmin=min(WQA1Cmin,WQA1C)
WQVA1C = 1.0 / (1.0 - WQA1C)
WQV(L,K,IDNOTRVA)=(WQV(L,K,IDNOTRVA)+WQA1C*WQV(L,K,IDNOTRVA))*WQVA1C !*SMAC(L) !Macroalgae growth equation
WQV(L,K,IDNOTRVA) = MAX(WQV(L,K,IDNOTRVA),WQMCMIN) !*SMAC(L) !Note the lower bound put on macroalgae from Bmin in C44 of WQ3DWC.INP
WQO(L,IDNOTRVA) = WQVO(L,K,IDNOTRVA)+WQV(L,K,IDNOTRVA)
ENDIF
ENDDO
C
C******************************************************************************
C ***
C *** NOW COMPUTE KINETICS FOR EACH CONSTITUENT
C
C **** PARAM 01 CHC - cyanobacteria
C
IF(ISTRWQ(1).EQ.1)THEN
DO L=2,LA
! *** GROWTH BASAL_METAB PREDATION SETTLING TIME STEP
WQA1C=(WQPC(L)-WQBMC(L)-WQPRC(L)-WQBCSET(L,1))*DTWQO2 !production per unit time multiplied by half time step
WQKK(L) = 1.0 / (1.0 - WQA1C)
! *** PT_SRC_LOADS VOLUME
WQR1C = WQWPSL(L,K,1) * VOLWQ(L) !point source load rate multiplied by inverse cell volume g/m^3/t
WQRR(L) = WQV(L,K,1) + DTWQ*WQR1C + WQA1C*WQV(L,K,1) !transported biomass conc. (CALWQC) + point source load rate * time step + growth rate * previous biomass conc.
ENDDO
IF(K.NE.KC)THEN
! *** Add in settling from above
WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQBCSET(2:LA,2)*WQO(2:LA,1) !biomass conc. + DtX(1/t)* biomass conc.
ELSE !Surface layer: K.EQ.KC
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR1C = (WQWDSL(L,KC,1)+WQATML(L,KC,1))*VOLWQ(L) !atmospheric loading mass per time / cell volume
WQRR(L) = WQRR(L) + DTWQ*WQR1C !biomass conc. + Dt*loading rate per unit volume
ENDDO
ENDIF
WQV(2:LA,K,1)=SCB(2:LA)*(WQRR(2:LA)*WQKK(2:LA))+(1.0-SCB(2:LA))*WQV(2:LA,K,1) !boundary condition implementation. CAN THIS BE REPLACED BY WQRR(2:LA)*WQKK(2:LA) THROUGHOUT THESE CALCULATIONS?
WQO(2:LA,1)= WQVO(2:LA,K,1)+WQV(2:LA,K,1) !depth totaled (column sum) biomass conc = old biomass conc in cell + biomass conc from this iteration
ENDIF
C
C **** PARAM 02 CHD - diatom algae
C
IF(ISTRWQ(2).EQ.1)THEN
DO L=2,LA
! *** GROWTH BASAL_METAB PREDATION SETTLING TIME STEP
WQA2D=(WQPD(L)-WQBMD(L)-WQPRD(L)-WQBDSET(L,1))*DTWQO2
WQKK(L) = 1.0 / (1.0 - WQA2D)
! *** PT_SRC_LOADS VOLUME
WQR2D = WQWPSL(L,K,2) * VOLWQ(L)
WQRR(L) = WQV(L,K,2) + DTWQ*WQR2D + WQA2D*WQV(L,K,2)
ENDDO
IF(K.NE.KC)THEN
! *** Add in settling from above
WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQBDSET(2:LA,2)*WQO(L,2)
ELSE !Surface layer: K.EQ.KC
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR2D = (WQWDSL(L,KC,2)+WQATML(L,KC,2))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR2D
ENDDO
ENDIF
WQV(2:LA,K,2)=SCB(2:LA)*(WQRR(2:LA)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,2)
WQO(2:LA,2)=WQVO(2:LA,K,2)+WQV(2:LA,K,2)
ENDIF
C
C **** PARAM 03 CHG - green algae
C
IF(ISTRWQ(3).EQ.1)THEN
DO L=2,LA
! *** GROWTH BASAL_METAB PREDATION SETTLING TIME STEP
WQA3G=(WQPG(L)-WQBMG(L)-WQPRG(L)-WQBGSET(L,1))*DTWQO2
WQKK(L) = 1.0 / (1.0 - WQA3G)
! *** PT_SRC_LOADS VOLUME
WQR3G = WQWPSL(L,K,3) * VOLWQ(L)
! *** External Internal
WQRR(L) = WQV(L,K,3) + DTWQ*WQR3G + WQA3G*WQV(L,K,3)
ENDDO
IF(K.NE.KC)THEN
! *** Add the Algae settled in from the cell above
WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQBGSET(2:LA,2)*WQO(2:LA,3)
ELSE !Surface layer: K.EQ.KC
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR3G = (WQWDSL(L,KC,3)+WQATML(L,KC,3))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR3G
ENDDO
ENDIF
WQV(2:LA,K,3)=SCB(2:LA)*(WQRR(2:LA)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,3)
WQO(2:LA,3)=WQVO(2:LA,K,3)+WQV(2:LA,K,3)
ENDIF
C
C **** PARAM 04 ROC - refractory particulate organic carbon
C
IF(ISTRWQ(4).EQ.1)THEN
DO L=2,LA
! *** HYDROLYSIS SETTLING
WQB4 = -( WQKRPC(L) + WQRPSET(L,1))*DTWQO2
WQKK(L) = 1.0 / (1.0 - WQB4)
! *** ALGAE PREDATION SOURCE OF RPOC
WQA4 = WQFCRP * (WQPRC(L)*WQO(L,1) + WQPRD(L)*WQO(L,2) + WQPRG(L)*WQO(L,3))
IF(RMAC(L,K)>0.0) !If macroalgae is present in this layer
& WQA4 = WQA4 + WQFCRPM*WQPRM(L)*WQVO(L,K,IDNOTRVA) !RMAC factor?
! *** PT_SRC_LOADS VOLUME
WQR4 = WQWPSL(L,K,4) * VOLWQ(L)
WQRR(L) = WQV(L,K,4) + DTWQ*WQR4 + DTWQO2*WQA4 + WQB4*WQV(L,K,4)
ENDDO
IF(K.NE.KC)THEN
! *** Add in settling from above
WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQRPSET(2:LA,2)*WQO(2:LA,4)
ELSE !Surface layer: K.EQ.KC
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR4 = (WQWDSL(L,KC,4)+WQATML(L,KC,4))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR4
ENDDO
ENDIF
WQV(2:LA,K,4)=SCB(2:LA)*(WQRR(2:LA)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,4)
WQO(2:LA,4)=WQVO(2:LA,K,4)+WQV(2:LA,K,4)
ENDIF
C
C **** PARAM 05 LOC - labile particulate organic carbon
C
IF(ISTRWQ(5).EQ.1)THEN
DO L=2,LA
! *** HYDROLYSIS SETTLING
WQC5 = - (WQKLPC(L) + WQLPSET(L,1))*DTWQO2
WQKK(L) = 1.0 / (1.0 - WQC5)
WQA5 = WQFCLP * (WQPRC(L)*WQO(L,1) + WQPRD(L)*WQO(L,2) + WQPRG(L)*WQO(L,3)) !Predation
IF(RMAC(L,K)>0.0) !If macroalgae is present in this layer
& WQA5 = WQA5 + WQFCLPM * WQPRM(L)*WQVO(L,K,IDNOTRVA) !RMAC factor?
! *** PT_SRC_LOADS VOLUME
WQR5 = WQWPSL(L,K,5) * VOLWQ(L)
WQRR(L) = WQV(L,K,5) + DTWQ*WQR5 + DTWQO2*WQA5 + WQC5*WQV(L,K,5) ! *** PMC
ENDDO
IF(K.NE.KC)THEN
! *** Add in settling from above
WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQLPSET(2:LA,2)*WQO(2:LA,5)
ELSE !Surface layer: K.EQ.KC
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR5 = (WQWDSL(L,K,5)+WQATML(L,KC,5))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR5
ENDDO
ENDIF
WQV(2:LA,K,5)=SCB(L)*(WQRR(2:LA)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,5)
WQO(2:LA,5)=WQVO(2:LA,K,5)+WQV(2:LA,K,5)
ENDIF
C
C **** PARAM 06 DOC - dissolved organic carbon
C
IF(ISTRWQ(6).EQ.1)THEN
DO L=2,LA
! *** RESPIRATION DENITRIFICATION
WQD6 = - ( WQKHR(L) + WQDENIT(L)) *DTWQO2
WQKK(L) = 1.0 / (1.0 - WQD6)
WQA6C=WQFCDC + CFCDCWQ*( WQKHRC/(WQKHRC+O2WQ(L)+ 1.E-18) )
WQA6D=WQFCDD + CFCDDWQ*( WQKHRD/(WQKHRD+O2WQ(L)+ 1.E-18) )
WQA6G=WQFCDG + CFCDGWQ*( WQKHRG/(WQKHRG+O2WQ(L)+ 1.E-18) )
WQA6 = ( WQA6C*WQBMC(L) + WQFCDP*WQPRC(L) )*WQO(L,1)
& + ( WQA6D*WQBMD(L) + WQFCDP*WQPRD(L) )*WQO(L,2)
& + ( WQA6G*WQBMG(L) + WQFCDP*WQPRG(L) )*WQO(L,3)
IF(RMAC(L,K)>0.0)THEN !If macroalgae are present in this layer
IZ=IWQZMAP(L,K) !NOTE THE INCONSISTENCY HERE WHERE ZONATION IS CONSIDERED. IF ZONATION IS IMPLEMENTED, THE CODE MUST BE UPDATED ACCORDINGLY
WQA6M=(WQFCDM+(1.-WQFCDM)*WQKHRM(IZ) / (WQKHRM(IZ) + O2WQ(L) + 1.E-18))*WQBMM(L)
WQA6 = WQA6 + (WQA6M + WQFCDPM*WQPRM(L))*WQVO(L,K,IDNOTRVA)
ENDIF
! *** PT_SRC_LOADS VOLUME
WQR6 = WQWPSL(L,K,6) * VOLWQ(L)
WQRR(L) = WQV(L,K,6) + DTWQ*WQR6 + WQD6*WQV(L,K,6) + DTWQO2*(WQA6 +WQKLPC(L)*WQO(L,5))
ENDDO
IF(K.EQ.KC)THEN
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR6 = (WQWDSL(L,K,6)+WQATML(L,KC,6))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR6
ENDDO
ENDIF
WQV(2:LA,K,6)=SCB(2:LA)*(WQRR(2:LA)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,6)
WQO(2:LA,6)=WQVO(2:LA,K,6)+WQV(2:LA,K,6)
ENDIF
C
C **** PARAM 07 ROP - refractory particulate organic phosphorus
C
IF(ISTRWQ(7).EQ.1)THEN
DO L=2,LA
WQE7 = - (WQKRPP(L)+WQRPSET(L,1))*DTWQO2
WQKK(L) = 1.0 / (1.0 - WQE7)
WQA7C = (WQFPRC*WQBMC(L) + WQFPRP*WQPRC(L)) * WQO(L,1)
WQA7D = (WQFPRD*WQBMD(L) + WQFPRP*WQPRD(L)) * WQO(L,2)
WQA7G = (WQFPRG*WQBMG(L) + WQFPRP*WQPRG(L)) * WQO(L,3)
WQA7 = (WQA7C+WQA7D+WQA7G) * WQAPC(L)
IF(RMAC(L,K)>0.0) !If macroalgae is present in this layer
& WQA7 = WQA7 + (WQFPRM*WQBMM(L) + WQFPRPM*WQPRM(L)) * WQVO(L,K,IDNOTRVA)* WQAPC(L)*WQAPCM
! *** PT_SRC_LOADS VOLUME
WQR7 = WQWPSL(L,K,7) * VOLWQ(L)
WQRR(L) = WQV(L,K,7) + DTWQ*WQR7 + DTWQO2*WQA7 + WQE7*WQV(L,K,7)
ENDDO
IF(K.NE.KC)THEN
! *** Add in settling from above
WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQRPSET(2:LA,2)*WQO(2:LA,7)
ELSE
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR7 = (WQWDSL(L,K,7)+WQATML(L,KC,7))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR7
ENDDO
ENDIF
WQV(2:LA,K,7)=SCB(2:LA)*(WQRR(2:LA)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,7)
WQO(2:LA,7)=WQVO(2:LA,K,7)+WQV(2:LA,K,7)
ENDIF
C
C **** PARAM 08 LOP - labile particulate organic phosphorus
C
IF(ISTRWQ(8).EQ.1)THEN
DO L=2,LA
! *** HYDROLYSIS SETTLING
WQF8 = - (WQKLPP(L)+WQLPSET(L,1))*DTWQO2
WQKK(L) = 1.0 / (1.0 - WQF8)
WQA8C = (WQFPLC*WQBMC(L) + WQFPLP*WQPRC(L)) * WQO(L,1)
WQA8D = (WQFPLD*WQBMD(L) + WQFPLP*WQPRD(L)) * WQO(L,2)
WQA8G = (WQFPLG*WQBMG(L) + WQFPLP*WQPRG(L)) * WQO(L,3)
WQA8 = (WQA8C+WQA8D+WQA8G) * WQAPC(L)
IF(RMAC(L,K)>0.0) !If macroalgae is present in this layer
& WQA8 = WQA8 + (WQFPLM*WQBMM(L) + WQFPLPM*WQPRM(L)) * WQVO(L,K,IDNOTRVA) * WQAPC(L) * WQAPCM
! *** PT_SRC_LOADS VOLUME
WQR8 = WQWPSL(L,K,8) * VOLWQ(L)
WQRR(L) = WQV(L,K,8) + DTWQ*WQR8 + DTWQO2*WQA8 + WQF8*WQV(L,K,8)
ENDDO
IF(K.NE.KC)THEN
! *** Add in settling from above
WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQLPSET(2:LA,2)*WQO(2:LA,8)
ELSE
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR8 = (WQWDSL(L,K,8)+WQATML(L,KC,8))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR8
ENDDO
ENDIF
WQV(2:LA,K,8)=SCB(2:LA)*(WQRR(L)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,8)
WQO(2:LA,8)=WQVO(2:LA,K,8)+WQV(2:LA,K,8)
ENDIF
C
C **** PARAM 09 DOP - dissolved organic phosphorus
C
IF(ISTRWQ(9).EQ.1)THEN
DO L=2,LA
WQF9 = - DTWQO2*WQKDOP(L)
WQKK(L) = 1.0 / (1.0 - WQF9)
WQA9C = (WQFPDC*WQBMC(L) + WQFPDP*WQPRC(L)) * WQO(L,1)
WQA9D = (WQFPDD*WQBMD(L) + WQFPDP*WQPRD(L)) * WQO(L,2)
WQA9G = (WQFPDG*WQBMG(L) + WQFPDP*WQPRG(L)) * WQO(L,3)
WQA9 = (WQA9C+WQA9D+WQA9G) * WQAPC(L)
IF(RMAC(L,K)>0.0) !If macroalgae is present in this layer
& WQA9 = WQA9 + (WQFPDM*WQBMM(L) + WQFPDPM*WQPRM(L)) * WQVO(L,K,IDNOTRVA) * WQAPC(L)*WQAPCM
! *** PT_SRC_LOADS VOLUME
WQR9 = WQWPSL(L,K,9) * VOLWQ(L)
WQRR(L) = WQV(L,K,9) + DTWQ*WQR9 + WQF9*WQV(L,K,9) + DTWQO2*(WQA9 + WQKLPP(L)*WQO(L,8) )
ENDDO
IF(K.EQ.KC)THEN
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR9 = (WQWDSL(L,KC,9)+WQATML(L,KC,9))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR9
ENDDO
ENDIF
WQV(2:LA,K,9)=SCB(2:LA)*(WQRR(2:LA)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,9)
ENDIF
C
C **** PARAM 10 P4D - total phosphate
C
IF(ISTRWQ(10).EQ.1)THEN
DO L=2,LA
WQA10C=(WQFPIC*WQBMC(L)+WQFPIP*WQPRC(L)-WQPC(L))*WQO(L,1)
WQA10D=(WQFPID*WQBMD(L)+WQFPIP*WQPRD(L)-WQPD(L))*WQO(L,2)
WQA10G=(WQFPIG*WQBMG(L)+WQFPIP*WQPRG(L)-WQPG(L))*WQO(L,3)
WQKK(L) = (WQA10C+WQA10D+WQA10G) * WQAPC(L)
IF(RMAC(L,K)>0.0) !If macroalgae is present in this layer
& WQKK(L) = WQKK(L)+(WQFPIM*WQBMM(L)+WQFPIP*WQPRM(L)-WQPM(L))*WQVO(L,K,IDNOTRVA) * WQAPC(L)*WQAPCM !RMAC factor?
! *** PT_SRC_LOADS VOLUME
WQRR(L) = WQWPSL(L,K,10) * VOLWQ(L)
ENDDO
IF(K.EQ.1)THEN
DO L=2,LA
IF(LMASKDRY(L))THEN !NOTE INCONSISTENCY WITH WETTING/DRYING. IF WETTING/DRYING IS ACTIVE, ALL OF THESE CALCULATIONS SHOULD BE UPDATED ACCORDINGLY
WQRR(L) = WQRR(L) + WQBFPO4D(L)*DZWQ(L) ! *** Add in Benthic Flux
ENDIF
ENDDO
ENDIF
IF(K.EQ.KC)THEN
! *** ATM DRY DEP ATM WET DEP VOLUME
! WQR10 = (WQWDSL(L,KC,10)+WQATML(L,KC,10))*VOLWQ(L)
! WQRR(L) = WQRR(L) + WQR10
DO L=2,LA
IF(LMASKDRY(L))THEN
! *** ATM DRY DEP ATM WET DEP VOLUME (THESE ARE WQR10)
WQRR(L) = WQRR(L) + (WQWDSL(L,KC,10)+WQATML(L,KC,10))*VOLWQ(L)
ENDIF
ENDDO
ENDIF
WQRR(2:LA) = WQV(2:LA,K,10) + DTWQ*WQRR(2:LA) + WQH10(2:LA)*WQV(2:LA,K,10)
& + DTWQO2*(WQKK(2:LA) + WQKRPP(2:LA)*WQO(2:LA,7) + WQKDOP(2:LA)*WQO(2:LA,9))
! *** Add in settling from above
IF(K.NE.KC)WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQT10(2:LA)*WQO(2:LA,10)
DO L=2,LA
WQKKL = 1.0 / (1.0 - WQH10(L))
WQV(L,K,10)=SCB(L)*(WQRR(L)*WQKKL)+(1.-SCB(L))*WQV(L,K,10)
WQO(L,10)=WQVO(L,K,10)+WQV(L,K,10)
ENDDO
ENDIF
C
C **** PARAM 11 RON - refractory particulate organic nitrogen
C
IF(ISTRWQ(11).EQ.1)THEN
DO L=2,LA
! *** HYDROLYSIS SETTLING
WQI11 = - (WQKRPN(L) + WQRPSET(L,1))*DTWQO2
WQKK(L) = 1.0 / (1.0 - WQI11)
WQA11C=(WQFNRC*WQBMC(L)+WQFNRP*WQPRC(L))*WQANCC*WQO(L,1)
WQA11D=(WQFNRD*WQBMD(L)+WQFNRP*WQPRD(L))*WQANCD*WQO(L,2)
WQA11G=(WQFNRG*WQBMG(L)+WQFNRP*WQPRG(L))*WQANCG*WQO(L,3)
WQA11 = WQA11C+WQA11D+WQA11G
IF(RMAC(L,K)>0.0) !If macroalgae is in this layer
& WQA11 = WQA11 + (WQFNRM*WQBMM(L)+WQFNRPM*WQPRM(L))*WQANCM*WQVO(L,K,IDNOTRVA)
! *** PT_SRC_LOADS VOLUME
WQR11 = WQWPSL(L,K,11) * VOLWQ(L)
WQRR(L) = WQV(L,K,11) + DTWQ*WQR11 + DTWQO2*WQA11
& + WQI11*WQV(L,K,11)
ENDDO
IF(K.NE.KC)THEN
! *** Add in settling from above
WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQRPSET(2:LA,2)*WQO(2:LA,11)
ELSE ! K.EQ.KC
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR11 = (WQWDSL(L,KC,11)+WQATML(L,KC,11))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR11
ENDDO
ENDIF
WQV(2:LA,K,11)=SCB(2:LA)*(WQRR(2:LA)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,11)
WQO(2:LA,11)=WQVO(2:LA,K,11)+WQV(2:LA,K,11)
ENDIF
C
C **** PARAM 12 LON - labile particulate organic nitrogen
C
IF(ISTRWQ(12).EQ.1)THEN
DO L=2,LA
! *** HYDROLYSIS SETTLING
WQJ12 = - (WQKLPN(L)+WQLPSET(L,1))*DTWQO2
WQKK(L) = 1.0 / (1.0 - WQJ12)
WQA12C=(WQFNLC*WQBMC(L)+WQFNLP*WQPRC(L))*WQANCC*WQO(L,1)
WQA12D=(WQFNLD*WQBMD(L)+WQFNLP*WQPRD(L))*WQANCD*WQO(L,2)
WQA12G=(WQFNLG*WQBMG(L)+WQFNLP*WQPRG(L))*WQANCG*WQO(L,3)
WQA12 = WQA12C+WQA12D+WQA12G
IF(RMAC(L,K)>0.0) !If macroalgae is in this layer
& WQA12 = WQA12 + (WQFNLM*WQBMM(L)+WQFNLPM*WQPRM(L))*WQANCM*WQVO(L,K,IDNOTRVA)
! *** PT_SRC_LOADS VOLUME
WQR12 = WQWPSL(L,K,12) * VOLWQ(L)
WQRR(L) = WQV(L,K,12) + DTWQ*WQR12 + DTWQO2*WQA12 + WQJ12*WQV(L,K,12)
ENDDO
IF(K.NE.KC)THEN
! *** Add in settling from above
WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQLPSET(2:LA,2)*WQO(2:LA,12)
ELSE ! K.EQ.KC
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR12 = (WQWDSL(L,KC,12)+WQATML(L,KC,12))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR12
ENDDO
ENDIF
WQV(2:LA,K,12)=SCB(2:LA)*(WQRR(2:LA)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,12)
WQO(2:LA,12)=WQVO(2:LA,K,12)+WQV(2:LA,K,12)
ENDIF
C
C **** PARAM 13 DON - dissolved organic nitrogen
C
IF(ISTRWQ(13).EQ.1)THEN
DO L=2,LA
WQF13 = - DTWQO2*WQKDON(L)
WQKK(L) = 1.0 / (1.0 - WQF13)
WQA13C=(WQFNDC*WQBMC(L)+WQFNDP*WQPRC(L))*WQANCC*WQO(L,1)
WQA13D=(WQFNDD*WQBMD(L)+WQFNDP*WQPRD(L))*WQANCD*WQO(L,2)
WQA13G=(WQFNDG*WQBMG(L)+WQFNDP*WQPRG(L))*WQANCG*WQO(L,3)
WQA13 = WQA13C+WQA13D+WQA13G
IF(RMAC(L,K)>0.0) !If macroalgae is in this layer
& WQA13 =WQA13 + (WQFNDM*WQBMM(L)+WQFNDPM*WQPRM(L))*WQANCM*WQVO(L,K,IDNOTRVA)
! *** PT_SRC_LOADS VOLUME
WQR13 = WQWPSL(L,K,13) * VOLWQ(L)
WQRR(L) = WQV(L,K,13) + DTWQ*WQR13 + WQF13*WQV(L,K,13) + DTWQO2*(WQA13 + WQKLPN(L)*WQO(L,12))
ENDDO
IF(K.EQ.KC)THEN
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR13 = (WQWDSL(L,KC,13)+WQATML(L,KC,13))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR13
ENDDO
ENDIF
WQV(2:LA,K,13)=SCB(2:LA)*(WQRR(2:LA)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,13)
WQO(2:LA,13)=WQVO(2:LA,K,13)+WQV(2:LA,K,13)
ENDIF
C
C **** PARAM 14 NHX - ammonia nitrogen
C
IF(ISTRWQ(14).EQ.1)THEN
! *** PT_SRC_LOADS VOLUME
WQRR(2:LA) = WQWPSL(2:LA,K,14) * VOLWQ(2:LA)
IF(K.EQ.1)THEN
DO L=2,LA
IF(LMASKDRY(L))THEN
WQRR(L) = WQRR(L) + WQBFNH4(L)*DZWQ(L) ! *** Add in Benthic Flux
ENDIF
ENDDO
ELSEIF(K.EQ.KC)THEN
DO L=2,LA
IF(LMASKDRY(L))THEN
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR14 = (WQWDSL(L,KC,14)+WQATML(L,KC,14))*VOLWQ(L)
WQRR(L) = WQRR(L) + WQR14
ENDIF
ENDDO
ENDIF
DO L=2,LA
WQF14 = - DTWQO2*WQNIT(L)
WQKK(L) = 1.0 / (1.0 - WQF14)
WQA14C=WQFNIC*WQBMC(L)+WQFNIP*WQPRC(L)-WQPNC(L)*WQPC(L)
WQA14D=WQFNID*WQBMD(L)+WQFNIP*WQPRD(L)-WQPND(L)*WQPD(L)
WQA14G=WQFNIG*WQBMG(L)+WQFNIP*WQPRG(L)-WQPNG(L)*WQPG(L)
WQA14 = WQA14C*WQANCC*WQO(L,1) + WQA14D*WQANCD*WQO(L,2) + WQA14G*WQANCG*WQO(L,3)
IF(RMAC(L,K)>0.0) !If macroalgae is in this layer
& WQA14 = WQA14 + (WQFNIM*WQBMM(L)+WQFNIPM*WQPRM(L) - WQPNM(L)*WQPM(L))*WQANCM*WQVO(L,K,IDNOTRVA)
WQRR(L) = WQV(L,K,14) + DTWQ*WQRR(L) + WQF14*WQV(L,K,14) + DTWQO2*(WQA14 + WQKRPN(L)*WQO(L,11) + WQKDON(L)*WQO(L,13))
WQV(L,K,14)=SCB(L)*(WQRR(L)*WQKK(L))+(1.-SCB(L))*WQV(L,K,14)
WQO(L,14)=WQVO(L,K,14)+WQV(L,K,14)
ENDDO
ENDIF
C
C **** PARAM 15 NOX - nitrate nitrogen
C
IF(ISTRWQ(15).EQ.1)THEN
! *** PT_SRC_LOADS VOLUME
WQRR(2:LA) = WQWPSL(2:LA,K,15) * VOLWQ(2:LA)
IF(K.EQ.1)THEN
DO L=2,LA
IF(LMASKDRY(L))THEN
WQRR(L) = WQRR(L) + WQBFNO3(L)*DZWQ(L) ! *** Add in Benthic Flux
ENDIF
ENDDO
ELSEIF(K.EQ.KC)THEN
DO L=2,LA
IF(LMASKDRY(L))THEN
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR15 = (WQWDSL(L,KC,15)+WQATML(L,KC,15))*VOLWQ(L)
WQRR(L) = WQRR(L) + WQR15
ENDIF
ENDDO
ENDIF
DO L=2,LA
WQA15C = (WQPNC(L)-1.0)*WQPC(L) * WQANCC * WQO(L,1)
WQA15D = (WQPND(L)-1.0)*WQPD(L) * WQANCD * WQO(L,2)
WQA15G = (WQPNG(L)-1.0)*WQPG(L) * WQANCG * WQO(L,3)
WQA15 = WQA15C+WQA15D+WQA15G
IF(RMAC(L,K)>0.0) !If macroalgae is in this layer
& WQA15 =WQA15 + (WQPNM(L)-1.0)*WQPM(L)*WQANCM*WQVO(L,K,IDNOTRVA)
WQB15 = WQV(L,K,15) + DTWQ*WQRR(L) + DTWQO2*(WQA15 - WQANDC*WQDENIT(L)*WQO(L,6) + WQNIT(L)*WQO(L,14))
WQV(L,K,15)=SCB(L)*WQB15 + (1.-SCB(L))*WQV(L,K,15)
WQO(L,15)=WQVO(L,K,15)+WQV(L,K,15)
ENDDO
ENDIF
C
C **** PARAM 16 SUU - particulate biogenic silica
C
IF(ISTRWQ(16).EQ.1.AND.IWQSI.EQ.1)THEN
DO L=2,LA
WQM16 = - (WQKSUA(IWQT(L)) + WQBDSET(L,1)) * DTWQO2
WQKK(L) = 1.0 / (1.0 - WQM16)
WQA16D = (WQFSPD*WQBMD(L) + WQFSPP*WQPRD(L)) * WQASCD * WQO(L,2)
! *** PT_SRC_LOADS VOLUME
WQR16 = WQWPSL(L,K,16) * VOLWQ(L)
WQRR(L) = WQV(L,K,16) + DTWQ*WQR16 + DTWQO2*WQA16D + WQM16*WQV(L,K,16)
ENDDO
IF(K.NE.KC)THEN
! *** Add in settling from above
WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQBDSET(2:LA,2)*WQO(2:LA,16) ! *** PMC
ELSE
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR16 = (WQWDSL(L,KC,16)+WQATML(L,KC,16))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR16
ENDDO
ENDIF
WQV(2:LA,K,16)=SCB(2:LA)*WQRR(2:LA)*WQKK(2:LA) + (1.-SCB(2:LA))*WQV(2:LA,K,16)
WQO(2:LA,16)=WQVO(2:LA,K,16)+WQV(2:LA,K,16)
ENDIF
C
C **** PARAM 17 SAA - dissolved available silica
C
IF(ISTRWQ(17).EQ.1.AND.IWQSI.EQ.1)THEN
WQKK(2:LA) = (WQFSID*WQBMD(2:LA) + WQFSIP*WQPRD(2:LA) - WQPD(2:LA)) * WQASCD * WQO(2:LA,2)
! *** PT_SRC_LOADS VOLUME
WQRR(2:LA) = WQWPSL(2:LA,K,17) * VOLWQ(2:LA)
IF(K.EQ.1)THEN
DO L=2,LA
IF(LMASKDRY(L))THEN
WQRR(L) = WQRR(L) + WQBFSAD(L)*DZWQ(L) ! *** Add in Benthic Flux
ENDIF
ENDDO
ENDIF
WQRR(2:LA)= WQV(2:LA,K,17) +
& DTWQ*WQRR(2:LA) +WQN17(2:LA)*WQV(2:LA,K,17) + DTWQO2*(WQKK(2:LA) + WQKSUA(IWQT(2:LA))*WQO(2:LA,16))
IF(K.NE.KC)THEN
WQRR(2:LA) = WQRR(2:LA) + DTWQO2*WQT17(2:LA)*WQO(2:LA,17)
ELSE
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR17 = (WQWDSL(L,KC,17)+WQATML(L,KC,17))*VOLWQ(L)
WQRR(L) = WQRR(L) + DTWQ*WQR17
ENDDO
ENDIF
WQKK(2:LA) = 1.0 / (1.0 - WQN17(2:LA))
WQV(2:LA,K,17)=SCB(2:LA)*WQRR(2:LA)*WQKK(2:LA) + (1.0-SCB(2:LA))*WQV(2:LA,K,17)
WQO(2:LA,17)=WQVO(2:LA,K,17)+WQV(2:LA,K,17)
ENDIF
C
C **** PARAM 18 COD - chemical oxygen demand
C
IF(ISTRWQ(18).EQ.1)THEN
WQKK(2:LA) = 1.0 / (1.0 - WQO18(2:LA))
! *** PT_SRC_LOADS VOLUME
WQRR(2:LA) = WQWPSL(2:LA,K,18) * VOLWQ(2:LA)
IF(K.EQ.1)THEN
DO L=2,LA
IF(LMASKDRY(L))THEN
WQRR(L) = WQRR(L) + WQBFCOD(L)*DZWQ(L) ! *** Add in Benthic Flux
ENDIF
ENDDO
ELSEIF(K.EQ.KC)THEN
DO L=2,LA
! *** ATM DRY DEP ATM WET DEP VOLUME
WQR18 = (WQWDSL(L,KC,18)+WQATML(L,KC,18))*VOLWQ(L)
WQRR(L) = WQRR(L) + WQR18
ENDDO
ENDIF
WQRR(2:LA)=WQV(2:LA,K,18)+DTWQ*WQRR(2:LA)+WQO18(2:LA)*WQV(2:LA,K,18)
WQV(2:LA,K,18)=SCB(2:LA)*(WQRR(2:LA)*WQKK(2:LA))+(1.-SCB(2:LA))*WQV(2:LA,K,18)
WQO(2:LA,18) = WQVO(2:LA,K,18)+WQV(2:LA,K,18)
ENDIF
C
C **** PARAM 19 DOX - dissolved oxygen
C
! *** 1) CHC - cyanobacteria
! *** 2) CHD - diatom algae
! *** 3) CHG - green algae
! *** 4) ROC - refractory particulate organic carbon
! *** 5) LOC - labile particulate organic carbon
! *** 6) DOC - dissolved organic carbon
! *** 7) ROP - refractory particulate organic phosphorus
! *** 8) LOP - labile particulate organic phosphorus
! *** 9) DOP - dissolved organic phosphorus
! *** 10) P4D - total phosphate
! *** 11) RON - refractory particulate organic nitrogen
! *** 12) LON - labile particulate organic nitrogen
! *** 13) DON - dissolved organic nitrogen
! *** 14) NHX - ammonia nitrogen
! *** 15) NOX - nitrate nitrogen
! *** 16) SUU - particulate biogenic silica
! *** 17) SAA - dissolved available silica
! *** 18) COD - chemical oxygen demand
! *** 19) DOX - dissolved oxygen
! *** 20) TAM - total active metal
! *** 21) FCB - fecal coliform bacteria
! *** 22) CO2 - dissolved carbon dioxide
! *** 23) MAC - macroalgae
!C 04/29/99 MRM:
!C THE FOLLOWING ARRAYS WERE ADDED TO KEEP TRACK OF THE VARIOUS COMPONENT
!C OF DISSOLVED OXYGEN. THE INSTANTANEOUS VALUES FOR EACH COMPONENT ARE
!C SUMMED IN THE ARRAYS AND THEN DUMPED TO THE WQDOCOMP.BIN FILE AT THE
!C SAME TIME INTERVAL AS FOR THE WQWCAVG.BIN FILES (I.E., IWQTSDT INTERVA
!C USUALLY DAILY AVERAGES). THE ARRAY DESCRIPTIONS ARE:
!C XDOPSL(L,L) = D.O. COMPONENT FOR POINT SOURCE LOADS
!C XDOSOD(L,K) = D.O. COMPONENT FOR SEDIMENT OXYGEN DEMAND
!C XDOKAR(L,K) = D.O. COMPONENT FOR REAERATION
!C XDODOC(L,K) = D.O. COMPONENT FOR DISS. ORG. CARBON DECAY
!C XDONIT(L,K) = D.O. COMPONENT FOR AMMONIA NITRIFICATION
!C XDOCOD(L,K) = D.O. COMPONENT FOR CHEM. OXY. DEMAND OXIDATION
!C XDOPPB(L,K) = D.O. COMPONENT FOR PHOTOSYNTHESIS OF TOTAL CHLOROPHYLL
!C XDORRB(L,K) = D.O. COMPONENT FOR RESPIRATION OF TOTAL CHLOROPHYLL
!C XDOPPM(L,K) = D.O. COMPONENT FOR PHOTOSYNTHESIS OF MACROALGAE
!C XDORRM(L,K) = D.O. COMPONENT FOR RESPIRATION OF MACROALGAE
!C XDOALL(L,K) = SUM OF THE ABOVE 10 D.O. COMPONENTS
!C NLIM = COUNTER FOR NUMBER OF ITEMS SUMMED IN EACH ARRAY SLOT
IF(ISTRWQ(19).EQ.1)THEN
DO L=2,LA
WQRR(L) = WQWPSL(L,K,19) * VOLWQ(L)
TMP19=WQRR(L)*DTWQ*DZCHP(L)
XDOPSL(L,K) = XDOPSL(L,K) + TMP19
XDOALL(L,K) = XDOALL(L,K) + TMP19
ENDDO
! *** Handle Surface Processes
IF(K.EQ.KC)THEN
DO L=2,LA
WQKK(L) = 1.0 / (1.0 - DTWQO2*WQP19(L))
! *** ATM DRY DEP ATM WET DEP VOLUME
WQRR(L)=WQRR(L)+(WQWDSL(L,KC,19)+WQATML(L,KC,19))*VOLWQ(L) !VJ - volume should multiply both load terms
! *** Reaeration
!WQRR(L) = WQRR(L) - WQP19(L)*(WQDOS(L) - WQV(L,K,19)) !This is the equation from WQ theory manual
! O2-reaeration changes
WQRR(L) = WQRR(L) + WQKRDOS(L) !WQKRDOS=-WQP19*WQDOS SCJ this seems wrong because it allows too much DO if it is produced by a lot of algae
WQV(L,KC,19)=MIN(WQV(L,KC,19),WQDOS(L)) !This does not allow O2 to exceed saturation at the water surface for high density algae systems
ENDDO
ELSE
WQKK(2:LA) = 1.0
ENDIF
! *** Bottom Processes
IF(K.EQ.1)THEN
DO L=2,LA
IF(LMASKDRY(L))THEN
TEMFAC=1.065**(TEM(L,1)-20.)
WQRR(L) = WQRR(L) + TEMFAC*WQBFO2(L)*DZWQ(L) ! *** Add in Benthic Flux
TMP19=TEMFAC*WQBFO2(L)*DTWQ
XDOSOD(L,K) = XDOSOD(L,K) + TMP19
XDOALL(L,K) = XDOALL(L,K) + TMP19
ENDIF
ENDDO
ENDIF
C
DO L=2,LA
DTWQxH = DTWQ*DZCHP(L)
DTWQxH2= DTWQO2*DZCHP(L)
IF(WQI0 .LE. 0.001)THEN
WQTTC = 0.0
WQTTD = 0.0
WQTTG = 0.0
ELSE
WQTTC = (1.3 - 0.3*WQPNC(L)) * WQPC(L)
WQTTD = (1.3 - 0.3*WQPND(L)) * WQPD(L)
WQTTG = (1.3 - 0.3*WQPNG(L)) * WQPG(L)
! *** PHOTOSYNTHESIS OF TOTAL CHLOROPHYLL
TMP19 = WQAOCR*DTWQxH2*
& (WQTTC*WQO(L,1)+WQTTD*WQO(L,2)+WQTTG*WQO(L,3))
XDOPPB(L,K) = XDOPPB(L,K) + TMP19
XDOALL(L,K) = XDOALL(L,K) + TMP19
ENDIF
! *** RESPIRATION OF TOTAL CHLOROPHYLL - CYANOBACTERIA
XMRM = CFCDCWQ*O2WQ(L)*WQBMC(L)/(WQKHRC+O2WQ(L)+ 1.E-18)
WQA19C = WQTTC - XMRM
TMP19 = XMRM*WQO(L,1)*WQAOCR * DTWQxH2
XDORRB(L,K) = XDORRB(L,K) - TMP19
XDOALL(L,K) = XDOALL(L,K) - TMP19
! *** RESPIRATION OF TOTAL CHLOROPHYLL - DIATOMS
XMRM = CFCDDWQ*O2WQ(L)*WQBMD(L)/(WQKHRD+O2WQ(L)+ 1.E-18)
WQA19D = WQTTD - XMRM
TMP19 = XMRM*WQO(L,2)*WQAOCR * DTWQxH2
XDORRB(L,K) = XDORRB(L,K) - TMP19
XDOALL(L,K) = XDOALL(L,K) - TMP19
! *** RESPIRATION OF TOTAL CHLOROPHYLL - GREENS
XMRM = CFCDGWQ*O2WQ(L)*WQBMG(L)/(WQKHRG+O2WQ(L)+ 1.E-18)
WQA19G = WQTTG - XMRM
TMP19 = XMRM*WQO(L,3)*WQAOCR * DTWQxH2
XDORRB(L,K) = XDORRB(L,K) - TMP19
XDOALL(L,K) = XDOALL(L,K) - TMP19
! *** TOTAL NET RESPIRATION/PHOTOSYNTHESIS
WQA19=(WQA19C*WQO(L,1) + WQA19D*WQO(L,2) + WQA19G*WQO(L,3))
& * WQAOCR
! *** MODIFIED BY MRM 05/23/99 TO ALLOW DIFFERENT AOCR CONSTANTS TO BE APPLIED
! *** TO PHOTOSYNTHESIS AND RESPIRATION TERMS FOR MACROALGAE
IF(RMAC(L,K)>0.0)THEN !If macroalgae is in this layer
! *** TRAPEZOIDAL AVERAGE CONCENTRATIONS
WQO(L,IDNOTRVA)=WQVO(L,K,IDNOTRVA)+WQV(L,K,IDNOTRVA)
IZ = IWQZMAP(L,K)
WQTTM = (1.3 - 0.3*WQPNM(L)) * WQPM(L)
XMRM=(1.0-WQFCDM)*O2WQ(L)*WQBMM(L)/(WQKHRM(IZ)+O2WQ(L) + 1.E-18)
WQA19A = WQTTM*WQO(L,IDNOTRVA)*WQAOCRPM - XMRM*WQO(L,IDNOTRVA)*WQAOCRRM
WQA19 = WQA19 + WQA19A
TMP19 = WQTTM*WQO(L,IDNOTRVA)*WQAOCRPM * DTWQxH2
XDOPPM(L,K) = XDOPPM(L,K) + TMP19
XDOALL(L,K) = XDOALL(L,K) + TMP19
TMP19 = XMRM*WQO(L,IDNOTRVA)*WQAOCRRM * DTWQxH2
XDORRM(L,K) = XDORRM(L,K) - TMP19
XDOALL(L,K) = XDOALL(L,K) - TMP19
ENDIF
! *** O2 Mass Balance
! WQA19 ! *** Total Net Respiration/Photosynthesis
WQSUM=DTWQ*WQRR(L) ! *** Sum of Loadings/Demands
WQRea=WQP19(L)*WQV(L,K,19) ! *** Reaeration
WQPOC=WQAOCR*WQKRPC(L)*WQO(L,4) ! *** POC
WQDOC=WQAOCR*WQKHR(L) *WQO(L,6) ! *** DOC
WQNH3=WQAONT*WQNIT(L) *WQO(L,14)! *** Ammonia
WQCOD=WQO18(L)*WQO(L,18) ! *** COD
WQRR(L) = WQV(L,K,19) + WQSUM + WQCOD +
& DTWQO2*(WQA19 - WQPOC - WQDOC - WQNH3 + WQRea)
c WQRR(L) = WQVO(L,K,19) + DTWQ*WQRR(L) +
c & DTWQO2*( WQA19 - WQAOCR*WQKRPC(L)*WQVO(L,K,4)
c & - WQAOCR*WQKHR(L) *WQVO(L,K,6)
c & - WQAONT*WQNIT(L) *WQVO(L,K,14)
c & + WQP19(L)*WQVO(L,K,19) )
c & + WQO18(L)*WQVO(L,K,18)
WQV(L,K,19)=SCB(L)*(WQRR(L)*WQKK(L))+(1.-SCB(L))*WQV(L,K,19) ! *** remove the SCB computations!
C WQV(L,K,19)=SCB(L)*WQRR(L)+(1.-SCB(L))*WQV(L,K,19) ! *** remove the SCB computations!
! *** WQV(L,K,19) After this WQV(L,K,19) can not be < 0.
WQV(L,K,19) = MAX(WQV(L,K,19), 0.0)
!WQVO(L,K,19) = WQVO(L,K,19)+WQV(L,K,19)
C
! *** COMPUTE AND SAVE D.O. DEFICIT:
IF(ISMTSB.LT.ISMTSE)THEN
WQO(L,19)=WQVO(L,K,19)+WQV(L,K,19)
XMRM = WQDOS(L) - WQV(L,K,19)
XDODEF(L,K) = XDODEF(L,K) + XMRM*DTWQ*DZCHP(L)
IF(K.EQ.KC)THEN
TMP19=WQKRDOS(L)*DTWQ*DZCHP(L) +
& WQP19(L)*WQO(L,19)*DTWQxH2
XDOKAR(L,K) = XDOKAR(L,K) + TMP19
XDOALL(L,K) = XDOALL(L,K) + TMP19
ENDIF
TMP19=WQAOCR*WQKHR(L)*WQO(L,6)*DTWQxH2
XDODOC(L,K)=XDODOC(L,K) - TMP19
XDOALL(L,K)=XDOALL(L,K) - TMP19
TMP19=WQAONT*WQNIT(L)*WQO(L,14)*DTWQxH2
XDONIT(L,K)=XDONIT(L,K) - TMP19
XDOALL(L,K)=XDOALL(L,K) - TMP19
TMP19=WQO18(L)*WQO(L,18)*DZCHP(L)
XDOCOD(L,K)=XDOCOD(L,K) - TMP19
XDOALL(L,K)=XDOALL(L,K) - TMP19
XDODZ(L,K) = XDODZ(L,K) + DZCHP(L)
ENDIF
! O2-reaeration changes
! If DO conc. is greater than saturated DO conc., excess DO
! gets released out, which is calculated as XDOOUT.
IF(K==KC)THEN
IF(WQV(L,KC,19)>WQDOS(L))THEN
XDOOUT(L,KC)=(WQV(L,KC,19)-WQDOS(L))*DTWQ*DZCHP(L)
WQV(L,KC,19)=WQDOS(L)
XDOALL(L,K)=XDOALL(L,K)-XDOOUT(L,KC)
ENDIF
ENDIF
ENDDO
ENDIF
C
C **** PARAM 20 TAM - total active metal
C
IF(ISTRWQ(20).EQ.1)THEN
IF(IWQSRP.EQ.1)THEN
DO L=2,LA
WQT20 = - DTWQ*WQWSSET(L,1) ! *** DTWQO2
WQKK(L) = 1.0 / (1.0 - WQT20)
WQRR(L)=WQV(L,K,20)+DTWQ*WQR20(L)+WQT20*WQV(L,K,20)
ENDDO
IF(K.NE.KC)THEN
! *** Add in settling from above
DO L=2,LA
WQRR(L) = WQRR(L) + DTWQO2*WQWSSET(L,2)*WQO(L,20)
ENDDO
ENDIF
WQV(2:LA,K,20)=SCB(2:LA)*( WQRR(2:LA)*WQKK(2:LA) )
& +(1.-SCB(2:LA))*WQV(2:LA,K,20)
WQO(2:LA,20)=WQVO(2:LA,K,20)+WQV(2:LA,K,20)
ENDIF
ENDIF
C
C **** PARAM 21 FCB - fecal coliform bacteria
C
IF(ISTRWQ(21).EQ.1)THEN
IF(IWQFCB.EQ.1)THEN
DO L=2,LA
WQKK(L) = WQTD2FCB(IWQT(L))
C
! *** ATM DRY DEP LOADS VOLUME
WQR21= (WQWDSL(L,K,21)+WQWPSL(L,K,21))*VOLWQ(L)
C
IF(K==KC .AND. LMASKDRY(L))THEN
! *** ATM WET DEP VOLUME
WQR21 = WQR21 + (WQATML(L,KC,21)*VOLWQ(L))
ENDIF
WQRR(L) = WQV(L,K,21)*WQTD1FCB(IWQT(L)) + DTWQ*WQR21
WQV(L,K,21)=SCB(L)*( WQRR(L)*WQKK(L) )
& +(1.-SCB(L))*WQV(L,K,21)
!WQVO(L,K,21) = WQVO(L,K,21)+WQV(L,K,21)
ENDDO
ENDIF
ENDIF
C
C **** PARAM 22 DISSOLVED CARBON DIOXIDE
C
!C THE FOLLOWING ARRAYS WERE ADDED TO KEEP TRACK OF THE VARIOUS COMPONENT
!C OF DISSOLVED CARBON DIOXIDE.
!C THE ARRAY DESCRIPTIONS ARE:
!C XCDOKAR(L,K) = CDO. COMPONENT FOR REAERATION
!C XCDODOC(L,K) = CDO. COMPONENT FOR DISS. ORG. CARBON DECAY
!C XCDOPPB(L,K) = CDO. COMPONENT FOR PHOTOSYNTHESIS OF TOTAL CHLOROPHYLL
!C XCDORRB(L,K) = CDO. COMPONENT FOR RESPIRATION OF TOTAL CHLOROPHYLL
!C XCDOPPM(L,K) = CDO. COMPONENT FOR PHOTOSYNTHESIS OF MACROALGAE
!C XCDORRM(L,K) = CDO. COMPONENT FOR RESPIRATION OF MACROALGAE
!C XCDOALL(L,K) = SUM OF THE ABOVE 6 CDO. COMPONENTS
IF(ISTRWQ(22).EQ.1)THEN
WQRR(2:LA) = WQWPSL(2:LA,K,22) * VOLWQ(2:LA)
! *** Handle Surface Processes
IF(K.EQ.KC)THEN
DO L=2,LA
WQKK(L) = 1.0 / (1.0 - DTWQO2*WQP22(L))
! *** ATM DRY DEP ATM WET DEP VOLUME
WQRR(L)=WQRR(L)+(WQWDSL(L,KC,22)+WQATML(L,KC,22))*VOLWQ(L)
! *** Reaeration
WQRR(L) = WQRR(L) + WQKRCDOS(L)
ENDDO
ELSE
WQKK(2:LA) = 1.0
ENDIF
DO L=2,LA
DTWQxH = DTWQ*DZCHP(L)
DTWQxH2= DTWQO2*DZCHP(L)
IF(WQI0 .LE. 0.001)THEN
WQTTC = 0.0
WQTTD = 0.0
WQTTG = 0.0
ELSE
WQTTC = (1.3 - 0.3*WQPNC(L)) * WQPC(L)
WQTTD = (1.3 - 0.3*WQPND(L)) * WQPD(L)
WQTTG = (1.3 - 0.3*WQPNG(L)) * WQPG(L)
! *** PHOTOSYNTHESIS OF TOTAL CHLOROPHYLL
ENDIF
! *** RESPIRATION OF TOTAL CHLOROPHYLL - CYANOBACTERIA
XMRM = CFCDCWQ*O2WQ(L)*WQBMC(L)/(WQKHRC+O2WQ(L)+ 1.E-18)
WQA22C = WQTTC - XMRM
! *** RESPIRATION OF TOTAL CHLOROPHYLL - DIATOMS
XMRM = CFCDDWQ*O2WQ(L)*WQBMD(L)/(WQKHRD+O2WQ(L)+ 1.E-18)
WQA22D = WQTTD - XMRM
! *** RESPIRATION OF TOTAL CHLOROPHYLL - GREENS
XMRM = CFCDGWQ*O2WQ(L)*WQBMG(L)/(WQKHRG+O2WQ(L)+ 1.E-18)
WQA22G = WQTTG - XMRM
! *** TOTAL NET RESPIRATION/PHOTOSYNTHESIS
WQA22=3.67*(WQA22C*WQO(L,1)+WQA22D*WQO(L,2)+WQA22G*WQO(L,3)) !VB 3.67 CONVERTS g CARBON TO g CO2
! *** MODIFIED BY MRM 05/23/99 TO ALLOW DIFFERENT AOCR CONSTANTS TO BE APPLIED
! *** TO PHOTOSYNTHESIS AND RESPIRATION TERMS FOR MACROALGAE
! *** TRAPEZOIDAL AVERAGE CONCENTRATIONS
! *** CO2 Mass Balance
! WQA22 ! *** Total Net Respiration/Photosynthesis
WQCDSUM=DTWQ*WQRR(L) ! *** Sum of Loadings/Demands
WQCDRea=WQP22(L)*WQV(L,K,22) ! *** Reaeration
WQCDDOC=(WQKHR(L)+WQDENIT(L))*WQO(L,6)*3.67 ! *** DOC FROM HYDROLYSIS AND DENITRIFICATION 3.67 CONVERTS G CARBON TO G CO2
WQRR(L) = WQV(L,K,22) + WQCDSUM +
& DTWQO2*(-WQA22 + WQCDDOC + WQCDRea)
WQV(L,K,22)=SCB(L)*(WQRR(L)*WQKK(L))+(1.-SCB(L))*WQV(L,K,22) ! *** remove the SCB computations!
! *** WQV(L,K,22) After this WQV(L,K,22) can not be < 0.
WQV(L,K,22) = MAX(WQV(L,K,22), 0.0)
ENDDO
ENDIF
ENDDO ! *** END OF THE KC LOOP
C ----------------------------------------------------------------
C
C INCREMENT COUNTER FOR LIMITATION AND XDOXXX DO COMPONENT ARRAYS:
C
IF(ISDYNSTP.EQ.0)THEN
TIMTMP=DT*FLOAT(N)+TCON*TBEGIN
TIMTMP=TIMTMP/TCTMSR
ELSE
TIMTMP=TIMESEC/TCTMSR
ENDIF
TIMESUM3 = TIMESUM3 + TIMTMP
NLIM = NLIM + 1
C PMC - Moved CHLa Computations to the beginning of the WQ Calculations
IF(IWQSRP.EQ.1)THEN
! *** Sorption Option: TAM
DO K=1,KC
DO L=2,LA
O2WQ(L) = MAX(WQV(L,K,19), 0.0)
WQTAMD = MIN( WQTAMDMX*EXP(-WQKDOTAM*O2WQ(L)), WQV(L,K,20) )
WQTAMP(L,K) = WQV(L,K,20) - WQTAMD
WQPO4D(L,K) = WQV(L,K,10) / (1.0 + WQKPO4P*WQTAMP(L,K))
WQSAD(L,K) = WQV(L,K,17) / (1.0 + WQKSAP*WQTAMP(L,K))
ENDDO
ENDDO
ELSE IF(IWQSRP.EQ.2)THEN
! *** Sorption Option: Sediments
WQPO4D(2:LA,1:KC) = WQV(2:LA,1:KC,10) / (1.0 + WQKPO4P*SEDT(2:LA,1:KC))
WQSAD(2:LA,1:KC) = WQV(2:LA,1:KC,17) / (1.0 + WQKSAP*SEDT(2:LA,1:KC))
ELSE
WQPO4D(2:LA,1:KC) = WQV(2:LA,1:KC,10)
WQSAD(2:LA,1:KC) = WQV(2:LA,1:KC,17)
ENDIF
C
C COUPLING TO SEDIMENT MODEL
C EVALUATE DEP. FLUX USING NEW VALUES CAUSE IMPLICIT SCHEME IS USED IN SPM
C
IF(IWQBEN.EQ.1)THEN
DO L=2,LA
IMWQZ = IWQZMAP(L,1)
WQDFBC(L) = SCB(L)*WQWSC(IMWQZ)*WQV(L,1,1)
WQDFBD(L) = SCB(L)*WQWSD(IMWQZ)*WQV(L,1,2)
WQDFBG(L) = SCB(L)*WQWSG(IMWQZ)*WQV(L,1,3)
& +WQWSM*DZWQ(L)*WQV(L,1,IDNOTRVA)
WQDFRC(L) = SCB(L)*WQWSRP(IMWQZ)*WQV(L,1,4)
WQDFLC(L) = SCB(L)*WQWSLP(IMWQZ)*WQV(L,1,5)
WQDFRP(L) = SCB(L)*WQWSRP(IMWQZ)*WQV(L,1,7)
WQDFLP(L) = SCB(L)*WQWSLP(IMWQZ)*WQV(L,1,8)
WQDFRN(L) = SCB(L)*WQWSRP(IMWQZ)*WQV(L,1,11)
WQDFLN(L) = SCB(L)*WQWSLP(IMWQZ)*WQV(L,1,12)
IF(IWQSI.EQ.1) WQDFSI(L) = SCB(L)*WQWSD(IMWQZ)*WQV(L,1,16)
ENDDO
IF(IWQSRP.EQ.1)THEN
DO L=2,LA
IMWQZ = IWQZMAP(L,1)
WQDFLP(L) = SCB(L)*( WQDFLP(L)
& + WQWSS(IMWQZ)*( WQV(L,1,10)-WQPO4D(L,1) ) )
IF(IWQSI.EQ.1) WQDFSI(L) = SCB(L)*( WQDFSI(L)
& + WQWSS(IMWQZ)*( WQV(L,1,17)-WQSAD(L,1) ) )
ENDDO
ELSE IF(IWQSRP.EQ.2)THEN
DO L=2,LA
WQDFLP(L) = SCB(L)*( WQDFLP(L)+WSEDO(NS)*( WQV(L,1,10)
& -WQPO4D(L,1) ) )
IF(IWQSI.EQ.1) WQDFSI(L) = SCB(L)*( WQDFSI(L)
& + WSEDO(NS)*( WQV(L,1,17)-WQSAD(L,1) ) )
ENDDO
ENDIF
ENDIF
C
C DIURNAL DO ANALYSIS
C
IF(NDDOAVG.GE.1.AND.DEBUG)THEN
OPEN(1,FILE='DIURNDO.OUT',POSITION='APPEND')
NDDOCNT=NDDOCNT+1
NSTPTMP=NDDOAVG*NTSPTC/2
RMULTMP=1./FLOAT(NSTPTMP)
DDOMAX(2:LA,1:KC)=MAX(DDOMAX(2:LA,1:KC),WQV(2:LA,1:KC,19))
DDOMIN(2:LA,1:KC)=MIN(DDOMIN(2:LA,1:KC),WQV(2:LA,1:KC,19))
IF(NDDOCNT.EQ.NSTPTMP)THEN
NDDOCNT=0
IF(ISDYNSTP.EQ.0)THEN
TIME=DT*FLOAT(N)+TCON*TBEGIN
TIME=TIME/TCON
ELSE
TIME=TIMESEC/TCON
ENDIF
WRITE(1,1111)N,TIME
DO L=2,LA
WRITE(1,1112)IL(L),JL(L),(DDOMIN(L,K),K=1,KC),
& (DDOMAX(L,K),K=1,KC)
ENDDO
DDOMAX(2:LA,1:KC)=-1.0E6
DDOMIN(2:LA,1:KC)= 1.0E6
ENDIF
CLOSE(1)
ENDIF
! *** LIGHT EXTINCTION ANALYSIS
IF(NDLTAVG.GE.1)THEN
OPEN(1,FILE='LIGHT.OUT',POSITION='APPEND')
NDLTCNT=NDLTCNT+1
NSTPTMP=NDLTAVG*NTSPTC/2
RMULTMP=1./FLOAT(NSTPTMP)
DO K=1,KC
DO L=2,LA
RLIGHT1=WQKEB(IMWQZT(L))+WQKETSS*SEDT(L,K)
XMRM = WQKECHL*WQCHL(L,K)
IF(WQKECHL .LT. 0.0)THEN
XMRM = 0.054*WQCHL(L,K)**0.6667 + 0.0088*WQCHL(L,K)
ENDIF
RLIGHT2 = XMRM
RLIGHTT(L,K)=RLIGHTT(L,K)+RLIGHT1
RLIGHTC(L,K)=RLIGHTC(L,K)+RLIGHT1+RLIGHT2
ENDDO
ENDDO
IF(NDLTCNT.EQ.NSTPTMP)THEN
NDLTCNT=0
IF(ISDYNSTP.EQ.0)THEN
TIME=DT*FLOAT(N)+TCON*TBEGIN
TIME=TIME/TCON
ELSE
TIME=TIMESEC/TCON
ENDIF
RLIGHTT(2:LA,1:KC)=RMULTMP*RLIGHTT(2:LA,1:KC)
RLIGHTC(2:LA,1:KC)=RMULTMP*RLIGHTC(2:LA,1:KC)
WRITE(1,1111)N,TIME
DO L=2,LA
WRITE(1,1113)IL(L),JL(L),(RLIGHTT(L,K),K=1,KC),
& (RLIGHTC(L,K),K=1,KC)
ENDDO
RLIGHTT(2:LA,1:KC)=0.0
RLIGHTC(2:LA,1:KC)=0.0
ENDIF
CLOSE(1)
ENDIF
!PRINT*,WQV(LIJ(17,2),13,15),WQV(LIJ(17,3),13,15),WQV(LIJ(17,10),13,15),WQV(LIJ(17,11),13,15)
1111 FORMAT(I12,F10.4)
1112 FORMAT(2I5,12F7.2)
1113 FORMAT(2I5,12E12.4)
1414 FORMAT(I12,11E12.4)
RETURN
END
| EFDC_src/WQSKE1.f |
!> Module containing interfaces for METIS 5
!> @todo Currently supports only ordering. Should be extended to the other options.
module modmetis
!based on https://glaros.dtc.umn.edu/gkhome/node/877
use iso_fortran_env,only:int32
use iso_c_binding,only:c_int,c_ptr
implicit none
private
public::metis_nodend,metis_setoptions,metis_checkerror
integer(kind=c_int),parameter::METIS_NOPTIONS=40
!options, possible values
integer(kind=c_int),parameter,public::METIS_OPTION_PTYPE=0 ,METIS_PTYPE_RB=0,METIS_PTYPE_KWAY=1
integer(kind=c_int),parameter,public::METIS_OPTION_OBJTYPE=1 ,METIS_OBJTYPE_CUT=1,METIS_OBJTYPE_VOL=1
integer(kind=c_int),parameter,public::METIS_OPTION_CTYPE=2 ,METIS_CTYPE_RM=0,METIS_CTYPE_SHEM=1
integer(kind=c_int),parameter,public::METIS_OPTION_IPTYPE=3 ,METIS_IPTYPE_GROW=0,METIS_IPTYPE_RANDOM=1&
,METIS_IPTYPE_EDGE=2,METIS_IPTYPE_NODE=3
integer(kind=c_int),parameter,public::METIS_OPTION_RTYPE=4 ,METIS_RTYPE_FM=0,METIS_RTYPE_GREEDY=1&
,METIS_RTYPE_SEP2SIDED=2,METIS_RTYPE_SEP1SIDED=3
integer(kind=c_int),parameter,public::METIS_OPTION_DBGLVL=5 ,METIS_DBG_INFO=1,METIS_DBG_TIME=2&
,METIS_DBG_COARSEN=4,METIS_DBG_REFINE=8&
,METIS_DBG_IPART=16,METIS_DBG_MOVEINFO=32,METIS_DBG_SEPINFO=64&
,METIS_DBG_CONNINFO=128,METIS_DBG_CONTIGINFO=256
integer(kind=c_int),parameter,public::METIS_OPTION_NITER=6 !default: 10
integer(kind=c_int),parameter,public::METIS_OPTION_NCUTS=7 !default: 1
integer(kind=c_int),parameter,public::METIS_OPTION_SEED=8
integer(kind=c_int),parameter,public::METIS_OPTION_NO2HOP=9 !0 or 1
integer(kind=c_int),parameter,public::METIS_OPTION_MINCONN=10 !0 or 1
integer(kind=c_int),parameter,public::METIS_OPTION_CONTIG=11 !0 or 1
integer(kind=c_int),parameter,public::METIS_OPTION_COMPRESS=12 !0 or 1
integer(kind=c_int),parameter,public::METIS_OPTION_CCORDER=13 !0 or 1
integer(kind=c_int),parameter,public::METIS_OPTION_PFACTOR=14
integer(kind=c_int),parameter,public::METIS_OPTION_NSEPS=15 !default: 1
integer(kind=c_int),parameter,public::METIS_OPTION_UFACTOR=16 !default: 1 or 30
integer(kind=c_int),parameter,public::METIS_OPTION_NUMBERING=17 !0 or 1
!error values
integer(kind=c_int),parameter::METIS_OK=1,METIS_ERROR_INPUT=-2,METIS_ERROR_MEMORY=-3,METIS_ERROR=-4
interface
function metis_setdefaultoptions(options) result(err) bind(C,name='METIS_SetDefaultOptions')
import c_int,METIS_NOPTIONS
integer(kind=c_int),intent(inout)::options(0:METIS_NOPTIONS)
integer(kind=c_int)::err
end function
!METIS_NodND
!OTPIONS Version 4 -> Version 5
![1] 1(RM) 2(HEM) 3(SHEM) -> CTYPE
![2] 1(edge-based) 2(node-based) -> ?
![3] 1(2-sided node) 2(1-sided node) -> RTYPE
![4] 0
![5] 0(no compress+no order) 1(compress) 2(order) 3(compress + order) -> COMPRESS + CCORDER
![6] remove vertices -> PFACTOR
![7] separators -> NSEPS
function metis_nodend(nvtxs,xadj,adjncy,vwgt,options,perm,iperm) result(err) bind(C,name='METIS_NodeND')
import c_int,c_ptr,METIS_NOPTIONS
integer(kind=c_int),intent(in)::nvtxs
integer(kind=c_int),intent(in)::xadj(*),adjncy(*)
type(c_ptr),intent(in),value::vwgt
integer(kind=c_int),intent(in)::options(0:METIS_NOPTIONS) !options is mandatory for Fortran when array start at pos 1
integer(kind=c_int),intent(out)::perm(*),iperm(*)
integer(kind=c_int)::err
end function
end interface
contains
function metis_setoptions(options&
,ptype,objtype,ctype,iptype,rtype,ncuts&
,nseps,niter,seed,minconn,no2hop,contig&
,compress,ccorder,pfactor,ufactor,dbglvl&
) result(err)
integer(kind=c_int),allocatable,intent(out)::options(:)
integer(kind=c_int),intent(in),optional::ptype,objtype,ctype,iptype,rtype,ncuts,&
nseps,niter,seed,minconn,no2hop,&
contig,compress,ccorder,pfactor,ufactor,dbglvl
integer(kind=c_int)::err
if(allocated(options))deallocate(options)
allocate(options(0:METIS_NOPTIONS))
err=metis_setdefaultoptions(options)
!DEFAULT
options(METIS_OPTION_NUMBERING)=1
!OPTIONAL
if(present(ptype))options(METIS_OPTION_PTYPE)=ptype
if(present(objtype))options(METIS_OPTION_OBJTYPE)=objtype
if(present(ctype))options(METIS_OPTION_CTYPE)=ctype
if(present(iptype))options(METIS_OPTION_IPTYPE)=iptype
if(present(rtype))options(METIS_OPTION_RTYPE)=rtype
if(present(ncuts))options(METIS_OPTION_NCUTS)=ncuts
if(present(nseps))options(METIS_OPTION_NSEPS)=nseps
if(present(niter))options(METIS_OPTION_NITER)=niter
if(present(seed))options(METIS_OPTION_SEED)=seed
if(present(minconn))options(METIS_OPTION_MINCONN)=minconn
if(present(no2hop))options(METIS_OPTION_NO2HOP)=no2hop
if(present(contig))options(METIS_OPTION_CONTIG)=contig
if(present(compress))options(METIS_OPTION_COMPRESS)=compress
if(present(ccorder))options(METIS_OPTION_CCORDER)=ccorder
if(present(pfactor))options(METIS_OPTION_PFACTOR)=pfactor
if(present(ufactor))options(METIS_OPTION_UFACTOR)=ufactor
if(present(dbglvl))options(METIS_OPTION_DBGLVL)=dbglvl
end function
subroutine metis_checkerror(err,unlog)
integer(kind=c_int),intent(in)::err
integer(kind=int32),intent(in),optional::unlog
integer(kind=int32)::un
un=6
if(present(unlog))un=unlog
select case(err)
case(METIS_OK)
!write(un,'(/a/)')' METIS_OK'
case(METIS_ERROR_INPUT)
write(un,'(/a/)')' METIS_ERROR_INPUT'
stop
case(METIS_ERROR_MEMORY)
write(un,'(/a/)')' METIS_ERROR_MEMORY'
stop
case(METIS_ERROR)
write(un,'(/a/)')' METIS_ERROR'
stop
case default
write(un,'(/a/)')' UNKNOWN METIS_ERROR'
stop
end select
end subroutine
end module
| src/modmetis.f90 |
!==============================================================================!
program Generator
!------------------------------------------------------------------------------!
! Block structured mesh generation and unstructured cell refinement. !
!------------------------------------------------------------------------------!
!----------------------------------[Modules]-----------------------------------!
use all_mod
use gen_mod
use Domain_Mod ! domain as defined in ".dom" file.
use Grid_Mod
!------------------------------------------------------------------------------!
implicit none
!-----------------------------------[Locals]-----------------------------------!
type(Domain_Type) :: dom ! domain to be used
type(Grid_Type) :: grid ! grid which will be generated
integer :: c, s, n
!==============================================================================!
! Open with a logo
call Logo
call Load_Domain (dom, grid)
call Compute_Node_Coordinates(dom, grid)
call Distribute_Regions (dom, grid)
call Connect_Blocks (dom, grid)
call Connect_Periodicity (dom, grid)
call Connect_Copy (dom)
! From this point on, domain is not used anymore
call Determine_Grid_Connectivity(grid, .false.) ! trial run
call Compute_Grid_Geometry (grid, .false.)
call Smooth_Grid (grid)
call Refine_Grid (grid)
call Determine_Grid_Connectivity(grid, .true.) ! real run
call Compute_Grid_Geometry (grid, .true.)
! Prepare for saving
do n = 1,grid % n_nodes
NewN(n)=n
end do
do c = -grid % n_bnd_cells,grid % n_cells
NewC(c)=c
end do
do s = 1,grid % n_faces
NewS(s)=s
end do
! Save the grid
call Save_Gmv_Cells(grid, 0, &
grid % n_nodes, &
grid % n_cells) ! save grid for postprocessing
call Save_Gmv_Faces(grid, 0, &
grid % n_nodes) ! save grid for checking b.c.
call Save_Shadows (grid, 0, &
grid % n_cells) ! save shadows
call Save_Cns_Geo(grid, 0, &
grid % n_cells, &
grid % n_faces, &
grid % n_bnd_cells, &
0, 0) ! saved data for processing
! Save links for checking
call Save_Gmv_Links(grid, 0, &
grid % n_nodes, &
grid % n_cells, &
grid % n_faces, &
grid % n_bnd_cells, &
0)
! Save the 1D probe (good for the channel flow)
call Probe_1D_Nodes_Gen(grid)
! Save the 2D probe (good for the channel flow)
call Probe_2D(grid)
! Create output for Fluent
NewC(-grid % n_bnd_cells-1) = -grid % n_bnd_cells-1
call Save_Cas(grid, 0, &
grid % n_nodes, &
grid % n_cells, &
grid % n_faces + grid % n_sh) ! save grid for Fluent
! Make eps figures
call Save_Eps_Cut(grid, grid % dy, grid % dz, 'x')
call Save_Eps_Cut(grid, grid % dz, grid % dx, 'y')
call Save_Eps_Cut(grid, grid % dx, grid % dy, 'z')
call Save_Eps_Whole(grid, grid % n_sh) ! draw the domain with shadows
! Write something on the screen
call Print_Grid_Statistics(grid)
end program
| Sources/Generate/Main.f90 |
SUBROUTINE UMAT(STRESS,STATEV,DDSDDE,SSE,SPD,SCD,
1 RPL,DDSDDT,DRPLDE,DRPLDT,
2 STRAN,DSTRAN,TIME,DTIME,TEMP,DTEMP,PREDEF,DPRED,CMNAME,
3 NDI,NSHR,NTENS,NSTATV,PROPS,NPROPS,COORDS,DROT,PNEWDT,
4 CELENT,DFGRD0,DFGRD1,NOEL,NPT,LAYER,KSPT,KSTEP,KINC)
INCLUDE 'ABA_PARAM.INC'
DIMENSION STRESS(NTENS),STATEV(NSTATV),
1 DDSDDE(NTENS,NTENS),DDSDDT(NTENS),DRPLDE(NTENS),
2 STRAN(NTENS),DSTRAN(NTENS),TIME(2),PREDEF(1),DPRED(1),
3 PROPS(NPROPS),COORDS(3),DROT(3,3),DFGRD0(3,3),DFGRD1(3,3),
4 JSTEP(4)
DOUBLE PRECISION B(6), DET
PARAMETER(ZERO=0.D0, ONE=1.D0, TWO=2.D0, THREE=3.D0, FOUR=4.D0,
1 SIX=6.D0)
mu = PROPS(1)
lam = PROPS(2)
DET=DFGRD1(1, 1)*DFGRD1(2, 2)*DFGRD1(3, 3)
1 -DFGRD1(1, 2)*DFGRD1(2, 1)*DFGRD1(3, 3)
IF(NSHR.EQ.3) THEN
DET=DET+DFGRD1(1, 2)*DFGRD1(2, 3)*DFGRD1(3, 1)
1 +DFGRD1(1, 3)*DFGRD1(3, 2)*DFGRD1(2, 1)
2 -DFGRD1(1, 3)*DFGRD1(3,1)*DFGRD1(2, 2)
3 -DFGRD1(2, 3)*DFGRD1(3, 2)*DFGRD1(1, 1)
END IF
B(1)=DFGRD1(1, 1)**2+DFGRD1(1, 2)**2+DFGRD1(1, 3)**2
B(2)=DFGRD1(2, 1)**2+DFGRD1(2, 2)**2+DFGRD1(2, 3)**2
B(3)=DFGRD1(3, 3)**2+DFGRD1(3, 1)**2+DFGRD1(3, 2)**2
B(4)=DFGRD1(1, 1)*DFGRD1(2, 1)+DFGRD1(1, 2)*DFGRD1(2, 2)
1 +DFGRD1(1, 3)*DFGRD1(2, 3)
IF(NSHR.EQ.3) THEN
B(5)=DFGRD1(1, 1)*DFGRD1(3, 1)+DFGRD1(1, 2)*DFGRD1(3, 2)
1 +DFGRD1(1, 3)*DFGRD1(3, 3)
B(6)=DFGRD1(2, 1)*DFGRD1(3, 1)+DFGRD1(2, 2)*DFGRD1(3, 2)
1 +DFGRD1(2, 3)*DFGRD1(3, 3)
END IF
C
C CALCULATE THE STRESS
C
tp1 = (lam*LOG(det)-mu)/det
tp2 = mu/det
DO i = 1,NDI
STRESS(i) = tp1 + tp2*B(i)
END DO
DO i = NDI+1, NDI+NSHR
STRESS(i) = tp2*B(i)
END DO
tp3 = lam/det
DDSDDE(1, 1) = tp3 + tp2*two*B(1)
DDSDDE(2, 2) = tp3 + tp2*two*B(2)
DDSDDE(3, 3) = tp3 + tp2*two*B(3)
DDSDDE(1, 2) = tp3
DDSDDE(1, 3) = tp3
DDSDDE(2, 3) = tp3
DDSDDE(1, 4) = tp2*B(4)
DDSDDE(2, 4) = tp2*B(4)
DDSDDE(3, 4) = 0.D0
DDSDDE(4, 4) = tp2/two*(B(1)+B(2))
IF(NSHR.EQ.3) THEN
DDSDDE(1, 5) = tp2*B(5)
DDSDDE(2, 5) = 0.D0
DDSDDE(3, 5) = tp2*B(5)
DDSDDE(1, 6) = 0.D0
DDSDDE(2, 6) = tp2*B(6)
DDSDDE(3, 6) = tp2*B(6)
DDSDDE(5, 5) = tp2/two*(B(1)+B(3))
DDSDDE(6, 6) = tp2/two*(B(2)+B(3))
DDSDDE(4, 5) = tp2/two*B(6)
DDSDDE(4, 6) = tp2/two*B(5)
DDSDDE(5, 6) = tp2/two*B(4)
END IF
DO i =1, NTENS
DO j = 1, i-1
DDSDDE(i, j) = DDSDDE(j, i)
END DO
END DO
STATEV(1) = DTIME
RETURN
END
SUBROUTINE SDVINI(STATEV,COORDS,NSTATV,NCRDS,NOEL,NPT,
1 LAYER,KSPT)
C
INCLUDE 'ABA_PARAM.INC'
C
DIMENSION STATEV(NSTATV),COORDS(NCRDS)
STATEV(1) = 1.0D0 ! theta
RETURN
END
| compressible.for |
!
! Copyright (c) 2000-2008, Roland Schmehl. All rights reserved.
!
! This software is distributable under the BSD license. See the terms of the
! BSD license in the documentation provided with this software.
!
MODULE FortranParser
!------- -------- --------- --------- --------- --------- --------- --------- -------
! Fortran 2008 function parser
!------- -------- --------- --------- --------- --------- --------- --------- -------
!
! This is an OOP Fortran 2008 version of the original fparser by Roland Schmehl. This simple class
! wrapping of the original fparser has been developed by Jacopo Chevallard, and it is available on
! the GitHub repository https://github.com/jacopo-chevallard/FortranParser.
!
! For comments and bug reports, please open an issue on
! https://github.com/jacopo-chevallard/FortranParser/issues
!
! This function parser module is intended for applications where a set of mathematical
! fortran-style expressions is specified at runtime and is then evaluated for a large
! number of variable values. This is done by compiling the set of function strings
! into byte code, which is interpreted efficiently for the various variable values.
!
! The source code of the original fparser is available from http://fparser.sourceforge.net
!
! Please send comments, corrections or questions realtive to the original fparser to its author:
! Roland Schmehl <[email protected]>
!
!------- -------- --------- --------- --------- --------- --------- --------- -------
! The function parser concept is based on a C++ class library written by Juha
! Nieminen <[email protected]> available from http://warp.povusers.org/FunctionParser/
!------- -------- --------- --------- --------- --------- --------- --------- -------
USE FortranParser_parameters, ONLY: rn,is ! Import KIND parameters
IMPLICIT NONE
PUBLIC :: EquationParser
!------- -------- --------- --------- --------- --------- --------- --------- -------
PRIVATE
INTEGER(is), PARAMETER :: cImmed = 1, &
cNeg = 2, &
cAdd = 3, &
cSub = 4, &
cMul = 5, &
cDiv = 6, &
cPow = 7, &
cAbs = 8, &
cExp = 9, &
cLog10 = 10, &
cLog = 11, &
cSqrt = 12, &
cSinh = 13, &
cCosh = 14, &
cTanh = 15, &
cSin = 16, &
cCos = 17, &
cTan = 18, &
cAsin = 19, &
cAcos = 20, &
cAtan = 21, &
VarBegin = 22
CHARACTER (LEN=1), DIMENSION(cAdd:cPow), PARAMETER :: Ops = (/ '+', &
'-', &
'*', &
'/', &
'^' /)
CHARACTER (LEN=5), DIMENSION(cAbs:cAtan), PARAMETER :: Funcs = (/ 'abs ', &
'exp ', &
'log10', &
'log ', &
'sqrt ', &
'sinh ', &
'cosh ', &
'tanh ', &
'sin ', &
'cos ', &
'tan ', &
'asin ', &
'acos ', &
'atan ' /)
INTEGER, parameter :: MAX_FUN_LENGTH = 1024
TYPE EquationParser
INTEGER(is), POINTER :: ByteCode(:) => null()
INTEGER :: ByteCodeSize = 0
REAL(rn), POINTER :: Immed(:) => null()
INTEGER :: ImmedSize = 0
REAL(rn), POINTER :: Stack(:) => null()
INTEGER :: StackSize = 0
INTEGER :: StackPtr = 0
INTEGER :: Error = 0
character(len=MAX_FUN_LENGTH) :: funcString = ''
character(len=MAX_FUN_LENGTH) :: funcStringOrig = ''
character(len=MAX_FUN_LENGTH), allocatable :: variableNames(:)
contains
private
procedure, public :: evaluate
procedure:: parse
procedure :: Compile
procedure :: AddCompiledByte
procedure :: CompileSubstr
procedure :: MathItemIndex
procedure :: CheckSyntax
final :: finalize
END TYPE EquationParser
! Class constructor
interface EquationParser
procedure constructor
end interface EquationParser
CONTAINS
!*****************************************************************************************
type (EquationParser) function constructor(FuncStr, Var)
CHARACTER (LEN=*), INTENT(in) :: FuncStr ! Function string
CHARACTER (LEN=*), DIMENSION(:), INTENT(in) :: Var ! Array with variable names
constructor%ByteCode => null()
constructor%Immed => null()
constructor%Stack => null()
constructor%ByteCodeSize = 0
constructor%ImmedSize = 0
constructor%StackSize = 0
constructor%StackPtr = 0
constructor%funcString = FuncStr
constructor%funcStringOrig = FuncStr
allocate(constructor%variableNames(size(Var)))
constructor%variableNames(:) = Var(:)
call constructor%parse()
end function constructor
!*****************************************************************************************
subroutine finalize(this)
type(EquationParser) :: this
if (associated(this%ByteCode)) nullify(this%ByteCode)
if (associated(this%Immed)) nullify(this%Immed)
if (associated(this%Stack)) nullify(this%Stack)
end subroutine finalize
!*****************************************************************************************
SUBROUTINE parse(this)
! Parse ith function string FuncStr and compile it into bytecode
class(EquationParser) :: this
CALL Replace('**','^ ', this%funcString) ! Exponent into 1-Char. format
CALL RemoveSpaces(this%funcString) ! Condense function string
CALL this%CheckSyntax()
CALL this%Compile() ! Compile into bytecode
END SUBROUTINE parse
!*****************************************************************************************
FUNCTION evaluate(this, Val, Error) RESULT (res)
! Evaluate bytecode of ith function for the values passed in array Val(:)
class(EquationParser) :: this
REAL(rn), DIMENSION(:), INTENT(in) :: Val ! Variable values
INTEGER, optional, intent(out):: Error ! Error code
REAL(rn) :: res ! Result
INTEGER :: IP, & ! Instruction pointer
DP, & ! Data pointer
SP ! Stack pointer
REAL(rn), PARAMETER :: zero = 0._rn
integer :: EvalErrType
IF (present(Error)) Error = 0
IF (this%Error /= 0) then
WRITE(*,*)'*** Error: Syntax or compilation error'
IF (present(Error)) Error = this%Error
return
ENDIF
DP = 1
SP = 0
EvalErrType=0
DO IP=1,this%ByteCodeSize
SELECT CASE (this%ByteCode(IP))
CASE (cImmed); SP=SP+1; this%Stack(SP)=this%Immed(DP); DP=DP+1
CASE (cNeg); this%Stack(SP)=-this%Stack(SP)
CASE (cAdd); this%Stack(SP-1)=this%Stack(SP-1)+this%Stack(SP); SP=SP-1
CASE (cSub); this%Stack(SP-1)=this%Stack(SP-1)-this%Stack(SP); SP=SP-1
CASE (cMul); this%Stack(SP-1)=this%Stack(SP-1)*this%Stack(SP); SP=SP-1
CASE (cDiv)
IF (this%Stack(SP)==0._rn) THEN
EvalErrType=1
res=zero
exit
ENDIF
this%Stack(SP-1)=this%Stack(SP-1)/this%Stack(SP); SP=SP-1
CASE (cPow); this%Stack(SP-1)=this%Stack(SP-1)**this%Stack(SP); SP=SP-1
CASE (cAbs); this%Stack(SP)=ABS(this%Stack(SP))
CASE (cExp); this%Stack(SP)=EXP(this%Stack(SP))
CASE (cLog10)
IF (this%Stack(SP)<=0._rn) THEN
EvalErrType=3
res=zero
exit
ENDIF
this%Stack(SP)=LOG10(this%Stack(SP))
CASE (cLog)
IF (this%Stack(SP)<=0._rn) THEN
EvalErrType=3
res=zero
exit
ENDIF
this%Stack(SP)=LOG(this%Stack(SP))
CASE (cSqrt)
IF (this%Stack(SP)<0._rn) THEN
EvalErrType=3
res=zero
exit
ENDIF
this%Stack(SP)=SQRT(this%Stack(SP))
CASE (cSinh); this%Stack(SP)=SINH(this%Stack(SP))
CASE (cCosh); this%Stack(SP)=COSH(this%Stack(SP))
CASE (cTanh); this%Stack(SP)=TANH(this%Stack(SP))
CASE (cSin); this%Stack(SP)=SIN(this%Stack(SP))
CASE (cCos); this%Stack(SP)=COS(this%Stack(SP))
CASE (cTan); this%Stack(SP)=TAN(this%Stack(SP))
CASE (cAsin)
IF ((this%Stack(SP)<-1._rn) .OR. (this%Stack(SP)>1._rn)) THEN
EvalErrType=4
res=zero
exit
ENDIF
this%Stack(SP)=ASIN(this%Stack(SP))
CASE (cAcos);
IF ((this%Stack(SP)<-1._rn).OR.(this%Stack(SP)>1._rn)) THEN
EvalErrType=4
res=zero
exit
ENDIF
this%Stack(SP)=ACOS(this%Stack(SP))
CASE (cAtan); this%Stack(SP)=ATAN(this%Stack(SP))
CASE DEFAULT; SP=SP+1; this%Stack(SP)=Val(this%ByteCode(IP)-VarBegin+1)
END SELECT
END DO
IF (EvalErrType > 0) then
IF (present(Error)) Error = EvalErrType
WRITE(*,*)'*** Error: ',EvalErrMsg(EvalErrType)
else
res = this%Stack(1)
endif
END FUNCTION evaluate
!*****************************************************************************************
SUBROUTINE CheckSyntax(this)
! Check syntax of function string, returns 0 if syntax is ok
class(EquationParser) :: this
INTEGER(is) :: n
CHARACTER (LEN=1) :: c
REAL(rn) :: r
LOGICAL :: err
INTEGER :: ParCnt, & ! Parenthesis counter
j,ib,in,lFunc
IF (this%Error /= 0) return
j = 1
ParCnt = 0
lFunc = LEN_TRIM(this%funcString)
step: DO
IF (j > lFunc) THEN; CALL ParseErrMsg (j, this%funcStringOrig, this%Error); return; ENDIF
c = this%funcString(j:j)
!-- -------- --------- --------- --------- --------- --------- --------- -------
! Check for valid operand (must appear)
!-- -------- --------- --------- --------- --------- --------- --------- -------
IF (c == '-' .OR. c == '+') THEN ! Check for leading - or +
j = j+1
IF (j > lFunc) THEN; CALL ParseErrMsg (j, this%funcStringOrig, this%Error, 'Missing operand'); return; ENDIF
c = this%funcString(j:j)
IF (ANY(c == Ops)) THEN; CALL ParseErrMsg (j, this%funcStringOrig, this%Error, 'Multiple operators'); return; ENDIF
END IF
n = MathFunctionIndex (this%funcString(j:))
IF (n > 0) THEN ! Check for math function
j = j+LEN_TRIM(Funcs(n))
IF (j > lFunc) THEN; CALL ParseErrMsg (j, this%funcStringOrig, this%Error, 'Missing function argument'); return; ENDIF
c = this%funcString(j:j)
IF (c /= '(') THEN; CALL ParseErrMsg (j, this%funcStringOrig, this%Error, 'Missing opening parenthesis'); return; ENDIF
END IF
IF (c == '(') THEN ! Check for opening parenthesis
ParCnt = ParCnt+1
j = j+1
CYCLE step
END IF
IF (SCAN(c,'0123456789.') > 0) THEN ! Check for number
r = RealNum (this%funcString(j:),ib,in,err)
IF (err) THEN; CALL ParseErrMsg (j, this%funcStringOrig, this%Error, 'Invalid number format: '//this%funcString(j+ib-1:j+in-2)); return; ENDIF
j = j+in-1
IF (j > lFunc) EXIT
c = this%funcString(j:j)
ELSE ! Check for variable
n = VariableIndex (this%funcString(j:),this%variableNames,ib,in)
IF (n == 0) THEN; CALL ParseErrMsg (j, this%funcStringOrig, this%Error, 'Invalid element: '//this%funcString(j+ib-1:j+in-2)); return; ENDIF
j = j+in-1
IF (j > lFunc) EXIT
c = this%funcString(j:j)
END IF
DO WHILE (c == ')') ! Check for closing parenthesis
ParCnt = ParCnt-1
IF (ParCnt < 0) THEN; CALL ParseErrMsg (j, this%funcStringOrig, this%Error, 'Mismatched parenthesis'); return; ENDIF
IF (this%funcString(j-1:j-1) == '(') THEN; CALL ParseErrMsg (j-1, this%funcStringOrig, this%Error, 'Empty parentheses'); return; ENDIF
j = j+1
IF (j > lFunc) EXIT
c = this%funcString(j:j)
END DO
!-- -------- --------- --------- --------- --------- --------- --------- -------
! Now, we have a legal operand: A legal operator or end of string must follow
!-- -------- --------- --------- --------- --------- --------- --------- -------
IF (j > lFunc) EXIT
IF (ANY(c == Ops)) THEN ! Check for multiple operators
IF (j+1 > lFunc) THEN; CALL ParseErrMsg (j, this%funcStringOrig, this%Error); return; ENDIF
IF (ANY(this%funcString(j+1:j+1) == Ops)) THEN; CALL ParseErrMsg (j+1, this%funcStringOrig, this%Error, 'Multiple operators'); return; ENDIF
ELSE ! Check for next operand
CALL ParseErrMsg (j, this%funcStringOrig, this%Error, 'Missing operator'); return
END IF
!-- -------- --------- --------- --------- --------- --------- --------- -------
! Now, we have an operand and an operator: the next loop will check for another
! operand (must appear)
!-- -------- --------- --------- --------- --------- --------- --------- -------
j = j+1
END DO step
IF (ParCnt > 0) CALL ParseErrMsg (j, this%funcStringOrig, this%Error, 'Missing )')
END SUBROUTINE CheckSyntax
!*****************************************************************************************
FUNCTION EvalErrMsg(EvalErrType) RESULT (msg)
! Return error message
integer, intent(in) :: EvalErrType
CHARACTER (LEN=*), DIMENSION(4), PARAMETER :: m = (/ 'Division by zero ', &
'Argument of SQRT negative ', &
'Argument of LOG negative ', &
'Argument of ASIN or ACOS illegal' /)
CHARACTER (LEN=LEN(m)) :: msg
!----- -------- --------- --------- --------- --------- --------- --------- -------
IF (EvalErrType < 1 .OR. EvalErrType > SIZE(m)) THEN
msg = ''
ELSE
msg = m(EvalErrType)
ENDIF
END FUNCTION EvalErrMsg
!*****************************************************************************************
SUBROUTINE ParseErrMsg (j, FuncStr, Error, Msg)
! Print error message and terminate program
INTEGER, INTENT(in) :: j
CHARACTER (LEN=*), INTENT(in) :: FuncStr ! Original function string
INTEGER, INTENT(out):: Error
CHARACTER (LEN=*), OPTIONAL, INTENT(in) :: Msg
Error = -1
IF (PRESENT(Msg)) THEN
WRITE(*,*) '*** Error in syntax of function string: '//Msg
ELSE
WRITE(*,*) '*** Error in syntax of function string:'
ENDIF
WRITE(*,*)
WRITE(*,'(A)') ' '//FuncStr
WRITE(*,'(A)') '?'
END SUBROUTINE ParseErrMsg
!*****************************************************************************************
FUNCTION OperatorIndex (c) RESULT (n)
! Return operator index
CHARACTER (LEN=1), INTENT(in) :: c
INTEGER(is) :: n,j
n = 0
DO j=cAdd,cPow
IF (c == Ops(j)) THEN
n = j
EXIT
END IF
END DO
END FUNCTION OperatorIndex
!*****************************************************************************************
FUNCTION MathFunctionIndex (str) RESULT (n)
! Return index of math function beginnig at 1st position of string str
CHARACTER (LEN=*), INTENT(in) :: str
INTEGER(is) :: n,j
INTEGER :: k
CHARACTER (LEN=LEN(Funcs)) :: fun
n = 0
DO j=cAbs,cAtan ! Check all math functions
k = MIN(LEN_TRIM(Funcs(j)), LEN(str))
CALL LowCase (str(1:k), fun)
IF (fun == Funcs(j)) THEN ! Compare lower case letters
n = j ! Found a matching function
EXIT
END IF
END DO
END FUNCTION MathFunctionIndex
!*****************************************************************************************
FUNCTION VariableIndex (str, Var, ibegin, inext) RESULT (n)
!----- -------- --------- --------- --------- --------- --------- --------- -------
! Return index of variable at begin of string str (returns 0 if no variable found)
!----- -------- --------- --------- --------- --------- --------- --------- -------
IMPLICIT NONE
CHARACTER (LEN=*), INTENT(in) :: str ! String
CHARACTER (LEN=*), DIMENSION(:), INTENT(in) :: Var ! Array with variable names
INTEGER(is) :: n ! Index of variable
INTEGER, OPTIONAL, INTENT(out) :: ibegin, & ! Start position of variable name
inext ! Position of character after name
INTEGER :: j,ib,in,lstr
!----- -------- --------- --------- --------- --------- --------- --------- -------
n = 0
lstr = LEN_TRIM(str)
IF (lstr > 0) THEN
DO ib=1,lstr ! Search for first character in str
IF (str(ib:ib) /= ' ') EXIT ! When lstr>0 at least 1 char in str
END DO
DO in=ib,lstr ! Search for name terminators
IF (SCAN(str(in:in),'+-*/^) ') > 0) EXIT
END DO
DO j=1,SIZE(Var)
IF (str(ib:in-1) == Var(j)) THEN
n = j ! Variable name found
EXIT
END IF
END DO
END IF
IF (PRESENT(ibegin)) ibegin = ib
IF (PRESENT(inext)) inext = in
END FUNCTION VariableIndex
!*****************************************************************************************
SUBROUTINE RemoveSpaces (str)
! Remove Spaces from string, remember positions of characters in old string
CHARACTER (LEN=*), INTENT(inout) :: str
INTEGER :: k,lstr
lstr = LEN_TRIM(str)
k = 1
DO WHILE (str(k:lstr) /= ' ')
IF (str(k:k) == ' ') THEN
str(k:lstr) = str(k+1:lstr)//' ' ! Move 1 character to left
k = k-1
END IF
k = k+1
END DO
END SUBROUTINE RemoveSpaces
!*****************************************************************************************
SUBROUTINE Replace (ca,cb,str)
! Replace ALL appearances of character set ca in string str by character set cb
CHARACTER (LEN=*), INTENT(in) :: ca
CHARACTER (LEN=LEN(ca)), INTENT(in) :: cb ! LEN(ca) must be LEN(cb)
CHARACTER (LEN=*), INTENT(inout) :: str
INTEGER :: j,lca
lca = LEN(ca)
DO j=1,LEN_TRIM(str)-lca+1
IF (str(j:j+lca-1) == ca) str(j:j+lca-1) = cb
END DO
END SUBROUTINE Replace
!*****************************************************************************************
SUBROUTINE Compile(this)
! Compile i-th function string F into bytecode
class(EquationParser) :: this
INTEGER :: istat
IF (this%Error /= 0) return
IF (ASSOCIATED(this%ByteCode)) DEALLOCATE ( this%ByteCode, &
this%Immed, &
this%Stack )
this%ByteCodeSize = 0
this%ImmedSize = 0
this%StackSize = 0
this%StackPtr = 0
CALL this%CompileSubstr(1,LEN_TRIM(this%funcString)) ! Compile string to determine size
ALLOCATE ( this%ByteCode(this%ByteCodeSize), &
this%Immed(this%ImmedSize), &
this%Stack(this%StackSize), &
STAT = istat )
IF (istat /= 0) THEN
WRITE(*,*) '*** Parser error: Memmory allocation for byte code failed'
this%Error = -1
ELSE
this%ByteCodeSize = 0
this%ImmedSize = 0
this%StackSize = 0
this%StackPtr = 0
CALL this%CompileSubstr(1,LEN_TRIM(this%funcString)) ! Compile string into bytecode
END IF
END SUBROUTINE Compile
!*****************************************************************************************
SUBROUTINE AddCompiledByte(this, b)
! Add compiled byte to bytecode
class(EquationParser) :: this
INTEGER(is), INTENT(in) :: b ! Value of byte to be added
this%ByteCodeSize = this%ByteCodeSize + 1
IF (ASSOCIATED(this%ByteCode)) then
this%ByteCode(this%ByteCodeSize) = b
endif
END SUBROUTINE AddCompiledByte
!*****************************************************************************************
FUNCTION MathItemIndex(this, b, e) RESULT (n)
! Return math item index, if item is real number, enter it into Comp-structure
class(EquationParser) :: this
INTEGER, INTENT(in) :: b,e ! First and last pos. of substring
INTEGER(is) :: n ! Byte value of math item
n = 0
IF (SCAN(this%funcString(b:b),'0123456789.') > 0) THEN ! Check for begin of a number
this%ImmedSize = this%ImmedSize + 1
IF (ASSOCIATED(this%Immed)) this%Immed(this%ImmedSize) = RealNum(this%funcString(b:e))
n = cImmed
ELSE ! Check for a variable
n = VariableIndex(this%funcString(b:e), this%variableNames)
IF (n > 0) n = VarBegin+n-1
END IF
END FUNCTION MathItemIndex
!*****************************************************************************************
FUNCTION CompletelyEnclosed (F, b, e) RESULT (res)
! Check if function substring F(b:e) is completely enclosed by a pair of parenthesis
CHARACTER (LEN=*), INTENT(in) :: F ! Function substring
INTEGER, INTENT(in) :: b,e ! First and last pos. of substring
LOGICAL :: res
INTEGER :: j,k
res=.false.
IF (F(b:b) == '(' .AND. F(e:e) == ')') THEN
k = 0
DO j=b+1,e-1
IF (F(j:j) == '(') THEN
k = k+1
ELSEIF (F(j:j) == ')') THEN
k = k-1
END IF
IF (k < 0) EXIT
END DO
IF (k == 0) res=.true. ! All opened parenthesis closed
END IF
END FUNCTION CompletelyEnclosed
!*****************************************************************************************
RECURSIVE SUBROUTINE CompileSubstr(this, b, e)
! Compile i-th function string funcString into bytecode
class(EquationParser) :: this
INTEGER, INTENT(in) :: b,e ! Begin and end position substring
INTEGER(is) :: n
INTEGER :: b2,j,k,io
CHARACTER (LEN=*), PARAMETER :: calpha = 'abcdefghijklmnopqrstuvwxyz'// &
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
! Check for special cases of substring
IF (this%funcString(b:b) == '+') THEN ! Case 1: funcString(b:e) = '+...'
! WRITE(*,*)'1. funcString(b:e) = "+..."'
CALL this%CompileSubstr(b+1, e)
RETURN
ELSEIF (CompletelyEnclosed (this%funcString, b, e)) THEN ! Case 2: funcString(b:e) = '(...)'
! WRITE(*,*)'2. funcString(b:e) = "(...)"'
CALL this%CompileSubstr(b+1, e-1)
RETURN
ELSEIF (SCAN(this%funcString(b:b), calpha) > 0) THEN
n = MathFunctionIndex(this%funcString(b:e))
IF (n > 0) THEN
b2 = b+INDEX(this%funcString(b:e),'(')-1
IF (CompletelyEnclosed(this%funcString, b2, e)) THEN ! Case 3: funcString(b:e) = 'fcn(...)'
! WRITE(*,*)'3. funcString(b:e) = "fcn(...)"'
CALL this%CompileSubstr(b2+1, e-1)
CALL this%AddCompiledByte(n)
RETURN
END IF
END IF
ELSEIF (this%funcString(b:b) == '-') THEN
IF (CompletelyEnclosed(this%funcString, b+1, e)) THEN ! Case 4: this%funcString(b:e) = '-(...)'
! WRITE(*,*)'4. this%funcString(b:e) = "-(...)"'
CALL this%CompileSubstr(b+2, e-1)
CALL this%AddCompiledByte(cNeg)
RETURN
ELSEIF (SCAN(this%funcString(b+1:b+1),calpha) > 0) THEN
n = MathFunctionIndex(this%funcString(b+1:e))
IF (n > 0) THEN
b2 = b+INDEX(this%funcString(b+1:e),'(')
IF (CompletelyEnclosed(this%funcString, b2, e)) THEN ! Case 5: this%funcString(b:e) = '-fcn(...)'
! WRITE(*,*)'5. this%funcString(b:e) = "-fcn(...)"'
CALL this%CompileSubstr(b2+1, e-1);
CALL this%AddCompiledByte(n)
CALL this%AddCompiledByte(cNeg)
RETURN
END IF
END IF
ENDIF
END IF
! Check for operator in substring: check only base level (k=0), exclude expr. in ()
DO io=cAdd,cPow ! Increasing priority +-*/^
k = 0
DO j=e,b,-1
IF (this%funcString(j:j) == ')') THEN
k = k+1
ELSEIF (this%funcString(j:j) == '(') THEN
k = k-1
END IF
IF (k == 0 .AND. this%funcString(j:j) == Ops(io) .AND. IsBinaryOp (j, this%funcString)) THEN
IF (ANY(this%funcString(j:j) == Ops(cMul:cPow)) .AND. this%funcString(b:b) == '-') THEN ! Case 6: this%funcString(b:e) = '-...Op...' with Op > -
! WRITE(*,*)'6. this%funcString(b:e) = "-...Op..." with Op > -'
CALL this%CompileSubstr(b+1, e)
CALL this%AddCompiledByte(cNeg)
RETURN
ELSE ! Case 7: this%funcString(b:e) = '...BinOp...'
! WRITE(*,*)'7. Binary operator',this%funcString(j:j)
CALL this%CompileSubstr(b, j-1)
CALL this%CompileSubstr(j+1, e)
CALL this%AddCompiledByte(OperatorIndex(Ops(io)))
this%StackPtr = this%StackPtr - 1
RETURN
END IF
END IF
END DO
END DO
! Check for remaining items, i.e. variables or explicit numbers
b2 = b
IF (this%funcString(b:b) == '-') b2 = b2+1
n = this%MathItemIndex(b2, e)
! WRITE(*,*)'8. AddCompiledByte ',n
CALL this%AddCompiledByte(n)
this%StackPtr = this%StackPtr + 1
IF (this%StackPtr > this%StackSize) this%StackSize = this%StackSize + 1
IF (b2 > b) CALL this%AddCompiledByte(cNeg)
END SUBROUTINE CompileSubstr
!*****************************************************************************************
FUNCTION IsBinaryOp (j, F) RESULT (res)
! Check if operator F(j:j) in string F is binary operator
! Special cases already covered elsewhere: (that is corrected in v1.1)
! - operator character F(j:j) is first character of string (j=1)
INTEGER, INTENT(in) :: j ! Position of Operator
CHARACTER (LEN=*), INTENT(in) :: F ! String
LOGICAL :: res ! Result
INTEGER :: k
LOGICAL :: Dflag,Pflag
res=.true.
IF (F(j:j) == '+' .OR. F(j:j) == '-') THEN ! Plus or minus sign:
IF (j == 1) THEN ! - leading unary operator ?
res = .false.
ELSEIF (SCAN(F(j-1:j-1),'+-*/^(') > 0) THEN ! - other unary operator ?
res = .false.
ELSEIF (SCAN(F(j+1:j+1),'0123456789') > 0 .AND. & ! - in exponent of real number ?
SCAN(F(j-1:j-1),'eEdD') > 0) THEN
Dflag=.false.; Pflag=.false.
k = j-1
DO WHILE (k > 1) ! step to the left in mantissa
k = k-1
IF (SCAN(F(k:k),'0123456789') > 0) THEN
Dflag=.true.
ELSEIF (F(k:k) == '.') THEN
IF (Pflag) THEN
EXIT ! * EXIT: 2nd appearance of '.'
ELSE
Pflag=.true. ! * mark 1st appearance of '.'
ENDIF
ELSE
EXIT ! * all other characters
END IF
END DO
IF (Dflag .AND. (k == 1 .OR. SCAN(F(k:k),'+-*/^(') > 0)) res = .false.
END IF
END IF
END FUNCTION IsBinaryOp
!*****************************************************************************************
FUNCTION RealNum(str, ibegin, inext, error) RESULT (res)
! Get real number from string - Format: [blanks][+|-][nnn][.nnn][e|E|d|D[+|-]nnn]
CHARACTER (LEN=*), INTENT(in) :: str ! String
REAL(rn) :: res ! Real number
INTEGER, OPTIONAL, INTENT(out) :: ibegin, & ! Start position of real number
inext ! 1st character after real number
LOGICAL, OPTIONAL, INTENT(out) :: error ! Error flag
INTEGER :: ib,in,istat
LOGICAL :: Bflag, & ! .T. at begin of number in str
InMan, & ! .T. in mantissa of number
Pflag, & ! .T. after 1st '.' encountered
Eflag, & ! .T. at exponent identifier 'eEdD'
InExp, & ! .T. in exponent of number
DInMan, & ! .T. if at least 1 digit in mant.
DInExp, & ! .T. if at least 1 digit in exp.
err ! Local error flag
!----- -------- --------- --------- --------- --------- --------- --------- -------
Bflag=.true.; InMan=.false.; Pflag=.false.; Eflag=.false.; InExp=.false.
DInMan=.false.; DInExp=.false.
ib = 1
in = 1
DO WHILE (in <= LEN_TRIM(str))
SELECT CASE (str(in:in))
CASE (' ') ! Only leading blanks permitted
ib = ib+1
IF (InMan .OR. Eflag .OR. InExp) EXIT
CASE ('+','-') ! Permitted only
IF (Bflag) THEN
InMan=.true.; Bflag=.false. ! - at beginning of mantissa
ELSEIF (Eflag) THEN
InExp=.true.; Eflag=.false. ! - at beginning of exponent
ELSE
EXIT ! - otherwise STOP
ENDIF
CASE ('0':'9') ! Mark
IF (Bflag) THEN
InMan=.true.; Bflag=.false. ! - beginning of mantissa
ELSEIF (Eflag) THEN
InExp=.true.; Eflag=.false. ! - beginning of exponent
ENDIF
IF (InMan) DInMan=.true. ! Mantissa contains digit
IF (InExp) DInExp=.true. ! Exponent contains digit
CASE ('.')
IF (Bflag) THEN
Pflag=.true. ! - mark 1st appearance of '.'
InMan=.true.; Bflag=.false. ! mark beginning of mantissa
ELSEIF (InMan .AND..NOT.Pflag) THEN
Pflag=.true. ! - mark 1st appearance of '.'
ELSE
EXIT ! - otherwise STOP
END IF
CASE ('e','E','d','D') ! Permitted only
IF (InMan) THEN
Eflag=.true.; InMan=.false. ! - following mantissa
ELSE
EXIT ! - otherwise STOP
ENDIF
CASE DEFAULT
EXIT ! STOP at all other characters
END SELECT
in = in+1
END DO
err = (ib > in-1) .OR. (.NOT.DInMan) .OR. ((Eflag.OR.InExp).AND..NOT.DInExp)
IF (err) THEN
res = 0.0_rn
ELSE
READ(str(ib:in-1),*,IOSTAT=istat) res
err = istat /= 0
END IF
IF (PRESENT(ibegin)) ibegin = ib
IF (PRESENT(inext)) inext = in
IF (PRESENT(error)) error = err
END FUNCTION RealNum
!*****************************************************************************************
SUBROUTINE LowCase (str1, str2)
! Transform upper case letters in str1 into lower case letters, result is str2
IMPLICIT NONE
CHARACTER (LEN=*), INTENT(in) :: str1
CHARACTER (LEN=*), INTENT(out) :: str2
INTEGER :: j,k
CHARACTER (LEN=*), PARAMETER :: lc = 'abcdefghijklmnopqrstuvwxyz'
CHARACTER (LEN=*), PARAMETER :: uc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
str2 = str1
DO j=1,LEN_TRIM(str1)
k = INDEX(uc,str1(j:j))
IF (k > 0) str2(j:j) = lc(k:k)
END DO
END SUBROUTINE LowCase
END MODULE FortranParser
| src/lib/FortranParser.f90 |
version https://git-lfs.github.com/spec/v1
oid sha256:817535975df1b774ef99d0a6195c304e642a1260a5fe650286466252b0ce808d
size 131550
| tensorflow-yolo-ios/dependencies/eigen/blas/testing/cblat3.f |
// Generated Files
${PROJ_DIR}/llink/script/premade_examples/axi_mm_a32_d128_packet_up_rv_2_mem/axi_mm_a32_d128_packet_up_rv_2_mem_slave_top.sv
${PROJ_DIR}/llink/script/premade_examples/axi_mm_a32_d128_packet_up_rv_2_mem/axi_mm_a32_d128_packet_up_rv_2_mem_slave_concat.sv
${PROJ_DIR}/llink/script/premade_examples/axi_mm_a32_d128_packet_up_rv_2_mem/axi_mm_a32_d128_packet_up_rv_2_mem_slave_name.sv
// Logic Link files
-f ${PROJ_DIR}/llink/rtl/llink.f
// Common Files
-f ${PROJ_DIR}/common/rtl/common.f
| llink/script/premade_examples/axi_mm_a32_d128_packet_up_rv_2_mem/axi_mm_a32_d128_packet_up_rv_2_mem_slave.f |
Cari Ham was appointed to the ASUCD ASUCD Senate Senate by Kalen Gallagher in January 2005 after Adam Barr stepped down. She orginally ran as a sophomore in February of 2004 on the Student Focus Slate slate. Her term expired when Adam Barr Barrs would have in February 2005.
Shortly before her new appointment, she served on the Gender and Sexuality Commission and was the Executive Offices Chief of Staff. While working for the Gender and Sexuality Commission Cari http://www.californiaaggie.com/media/storage/paper981/news/2005/01/18/Opinion/Letters.To.The.Editor1319214.shtml?norewrite200606071702&sourcedomainwww.californiaaggie.com allegedly verbally assaulted a conservative attendee of a Generation Sex event (http://media.www.californiaaggie.com/media/storage/paper981/news/2005/01/20/Opinion/Letters.To.The.Editor1319259.shtml?sourcedomainwww.californiaaggie.com&MIIHostmedia.collegepublisher.com Rebuttal).
Her candidate profile from The California Aggie can be found http://www.californiaaggie.com/media/storage/paper981/news/2004/02/19/FrontPage/Candidate.Profile.Cari.Ham1316564.shtml?norewrite200606071659&sourcedomainwww.californiaaggie.com here.
Cari is a graduate of Washington High School in Fremont, CA. She used to make fun of Paul Harms, who also attended WHS (she didnt like Pauls LL Bean lunchbox.)
| lab/davisWiki/Cari_Ham.f |
! Sort integer array a in ascending order.
recursive subroutine sort(a)
implicit none
interface
subroutine partition(a,pivot)
! Array to sort is a.
integer, intent(in out)::a(:)
! Pivot is the pivot point.
integer, intent(out) :: pivot
end subroutine partition
end interface
integer, intent(in out) :: a(:)
! pivot is pivot point.
integer :: pivot
if(size(a) > 1) then
! partition is used to select pivot point
call partition(a, pivot)
! Sort part of a below pivot.
call sort(a(:pivot-1))
! Sort part of a above pivot.
call sort(a(pivot:))
endif
end subroutine sort
! Find pivot point.
subroutine partition(a, pivot)
! Array to sort is a.
integer, intent(in out)::a(:)
! Pivot is the pivot point.
integer, intent(out) :: pivot
! lower is lower bound and upper is upper bound for pivot.
! a values below pivot must not exceed x. a values above
! pivot must not be less than x.
integer :: lower, upper
! The pivot value is x. Hold is used to store value to be exchanged.
integer :: hold,x
x = a(size(a)/2)
! The pivot cannot be less than 0.
lower= 0
! The pivot cannot exceed size(a).
upper= size(a) + 1
do
! Drop upper by 1 for new upper bound on pivot.
upper = upper-1
do
! If a(upper)<=x, then pivot does not exceed upper.
if (a(upper) <= x) exit
! Drop upper by 1 because pivot must be less than upper.
upper = upper-1
end do
! Now check on lower bound.
lower = lower+1
do
if (a(lower) >= x) exit
! Increase lower by 1.
lower = lower+1
end do
if (lower < upper) then
! Exchange a(lower) and a(upper).
hold = a(lower)
a(lower) = a(upper)
a(upper) = hold
else
if (lower == upper) then
pivot = upper+1
return
else
pivot = lower
return
endif
endif
end do
end subroutine partition
| Source/sort.f95 |
C
C $Id: set3.f,v 1.7 2008-07-27 00:17:34 haley Exp $
C
C Copyright (C) 2000
C University Corporation for Atmospheric Research
C All Rights Reserved
C
C The use of this Software is governed by a License Agreement.
C
SUBROUTINE SET3 (XA,XB,YA,YB,ULO,UHI,VLO,VHI,WLO,WHI,EYE)
C
C THREE-DIMENSIONAL LINE DRAWING PACKAGE
C
C
C PURPOSE THREED is a package of subroutines that
C provides line drawing capabilities in
C three-space.
C
C USAGE Each entry point in this package is
C described below.
C
C SET3 (XA,XB,YA,YB,UC,UD,VC,VD,WC,WD,EYE)
C
C XA, XB, YA, YB define the portion of the
C plotting surface into which the user's
C plot will be placed. These values should
C be in the range 0. to 1. For example, if
C one wants the plot to occupy the maximum
C plotting surface, set XA=0., YA=0., XB=1.,
C YB=1.; if one wants the plot to appear in
C the lower left corner of the plotting
C surface, set XA=0., YA=0., XB=.5, YB=.5 .
C
C UC, UD, VC, VD, WC, and WD define a
C volume in user-coordinate space which
C will be transformed onto the plotting
C surface defined by XA, XB, YA, YB.
C
C EYE is an array, 3 words long, containing the
C U, V, and W coordinates of the EYE position.
C All lines in the plot are drawn as viewed
C from the EYE. EYE is specified in user
C coordinates and should be outside the box
C defined by UC, UD, VC, VD, WC, and WD.
C
C CURVE3 (U,V,W,N)
C
C Draws a curve through N points. The
C points are defined by the linear arrays
C U, V, and W which are dimensioned N or
C greater.
C
C LINE3 (UA,VA,WA,UB,VB,WB)
C
C Draws a line connecting the coordinates
C (UA,VA,WA) and (UB,VB,WB).
C
C FRST3 (U,V,W)
C
C Positions the pen to (U,V,W).
C
C VECT3 (U,V,W)
C
C Draws a line between the current pen
C position and the point (U,V,W). The
C current pen position becomes (U,V,W).
C Note that a curve can be drawn by using
C a FRST3 call followed by a sequence of
C VECT3 calls.
C
C POINT3 (U,V,W)
C
C Plots a point at (U,V,W) .
C
C PERIM3 (MAGR1,MINR1,MAGR2,MINR2,IWHICH,VAR)
C
C Draws a perimeter with tick marks.
C
C IWHICH designates the normal vector to the
C perimeter drawn (1=U, 2=V, 3=W).
C
C VAR is the value on the axis specified by
C IWHICH where the perimeter is to be drawn.
C
C MAGR1 and MAGR2 specify the
C number of major tick marks to be drawn in
C the two coordinate directions.
C
C MINR1 and MINR2 specify the number
C of minor ticks between each major tick.
C
C MAGR1, MAGR2, MINR1 and MINR2
C are specified by the number
C of divisions(holes), not the number of
C ticks. So if MAGR1=1, there would be no
C major divisions.
C
C TICK43 (MAGU,MINU,MAGV,MINV,MAGW,MINW)
C
C TICK43 allows program control of tick
C mark length in subroutine PERIM3.
C MAGU, MAGV, MAGW specify the length,
C in plotter address units of major
C division tick marks on the U, V, and W
C axes. MINU, MINV, MINW specify the length,
C in plotter address units of minor
C division tick marks on the U, V, and
C W axes.
C
C FENCE3 (U,V,W,N,IOREN,BOT)
C
C This entry is used to draw a line in three-
C space as well as a "fence" between the
C line and a plane normal to one of the
C coordinate axes.
C
C The arguments U, V, W and N
C are the same as for CURVE3, described above.
C
C IOREN specifies the direction in which the
C fence lines are to be drawn (1 indicates
C parallel to the U-axis, 2 indicates parallel
C to the V-axis, and 3 indicates parallel to
C to the W-axis.)
C
C BOT specifies where the bottom of the fence
C is to be drawn.
C If the fence lines are to be drawn parallel
C to the W-axis, and BOT=2., then the bottom
C of the fence would be the plane W=2.
C
C ON OUTPUT All arguments are unchanged.
C
C NOTE . For drawing characters in conjunction
C with THREED, use the companion routine
C PWRZT.
C
C ENTRY POINTS FENCE3, TRN32T, FRST3, VECT3, LIN3,
C POINT3, CURVE3, PSYM3, PERIM3, LINE3W,
C DRAWT, TICK43, TICK3, THREBD, THREBDX
C
C COMMON BLOCKS TEMPRT, SET31, PWRZ1T, TCK31, PRM31, THRINT
C
C REQUIRED LIBRARY PWRZ and the SPPS
C ROUTINES
C
C REQUIRED GKS LEVEL 0A
C
C HISTORY Written and standardized in November 1973.
C I/O Plots lines.
C
C PRECISION Single
C
C LANGUAGE FORTRAN
C
C ACCURACY + or -.5 plotter address units per call.
C There is no cumulative error.
C
C PORTABILITY ANSI FORTRAN 77
C
C
C
C
C
SAVE
C
COMMON /TEMPRT/ RZERO
C
DIMENSION EYE(3)
C
COMMON /SET31/ ISCALE ,XMIN ,XMAX ,YMIN ,
1 YMAX ,BIGD ,R0 ,NLX ,
2 NBY ,NRX ,NTY
COMMON /PWRZ1T/ UUMIN ,UUMAX ,VVMIN ,VVMAX ,
1 WWMIN ,WWMAX ,DELCRT ,EYEU ,
2 EYEV ,EYEW
C
AVE(A,B) = (A+B)*.5
C
C ARITHMETIC STATEMENT FUNCTION FOR SCALING
C
SU(UTEMP) = UTEMP
SV(VTEMP) = VTEMP
SW(WTEMP) = WTEMP
C
C Do a call forcing a BLOCKDATA to be loaded from a binary library.
C
CALL THREBD
C
C SET UP FRAME SIZE
C
NLX = XA*1023.+1.
NRX = XB*1023.+1.
NBY = YA*1023.+1.
NTY = YB*1023.+1.
C
C CONSTANTS FOR PWRZT
C
UUMIN = ULO
UUMAX = UHI
VVMIN = VLO
VVMAX = VHI
WWMIN = WLO
WWMAX = WHI
EYEU = EYE(1)
EYEV = EYE(2)
EYEW = EYE(3)
C
C FIND CORNERS IN 2-SPACE FOR 3-SPACE BOX CONTAINING OBJECT
C
ISCALE = 0
ATU = AVE(SU(UUMIN),SU(UUMAX))
ATV = AVE(SV(VVMIN),SV(VVMAX))
ATW = AVE(SW(WWMIN),SW(WWMAX))
BIGD = 0.
IF (RZERO .LE. 0.) GO TO 10
C
C RELATIVE SIZE FEATURE IN USE. THIS SECTION OF CODE IS NEVER
C EXECUTED UNLESS RZERO IS SET POSITIVE IN THE CALLING PROGRAM
C VIA COMMON BLOCK TEMPRT. RZERO IS THE DISTANCE BETWEEN THE
C OBSERVER AND THE POINT LOOKED AT (CENTER OF THE BOX BY DEFAULT)
C WHEN THE INPUT BOX IS TO FILL THE SCREEN WHEN VIEWED FROM THE
C DIRECTION WHICH MAKES THE BOX BIGGEST. RZERO IS THUS TO
C BE USED TO DETERMINE THE SHAPE OF THE OBJECT. THIS SECTION
C OF CODE IS TO BE USED WHEN IT IS DESIRED TO KEEP THE VIEWED
C OBJECT IN RELATIVE PERSPECTIVE ACROSS FRAMES--E.G. IN MAKING
C MOVIES.
C
ALPHA = -(VVMIN-ATV)/(UUMIN-ATU)
VVEYE = -RZERO/SQRT(1.+ALPHA*ALPHA)
UUEYE = VVEYE*ALPHA
VVEYE = VVEYE+ATV
UUEYE = UUEYE+ATU
WWEYE = ATW
CALL TRN32T (ATU,ATV,ATW,UUEYE,VVEYE,WWEYE,1)
CALL TRN32T (UUMIN,VVMIN,ATW,XMIN,DUMM,DUMM,2)
CALL TRN32T (UUMAX,VVMIN,WWMIN,DUMM,YMIN,DUMM,2)
CALL TRN32T (UUMAX,VVMAX,ATW,XMAX,DUMM,DUMM,2)
CALL TRN32T (UUMAX,VVMIN,WWMAX,DUMM,YMAX,DUMM,2)
BIGD = SQRT((UUMAX-UUMIN)**2+(VVMAX-VVMIN)**2+(WWMAX-WWMIN)**2)*.5
R0 = RZERO
GO TO 20
10 CALL TRN32T (ATU,ATV,ATW,EYE(1),EYE(2),EYE(3),1)
CALL TRN32T (SU(UUMIN),SV(VVMIN),SW(WWMIN),X1,Y1,DUM,2)
CALL TRN32T (SU(UUMIN),SV(VVMIN),SW(WWMAX),X2,Y2,DUM,2)
CALL TRN32T (SU(UUMIN),SV(VVMAX),SW(WWMIN),X3,Y3,DUM,2)
CALL TRN32T (SU(UUMIN),SV(VVMAX),SW(WWMAX),X4,Y4,DUM,2)
CALL TRN32T (SU(UUMAX),SV(VVMIN),SW(WWMIN),X5,Y5,DUM,2)
CALL TRN32T (SU(UUMAX),SV(VVMIN),SW(WWMAX),X6,Y6,DUM,2)
CALL TRN32T (SU(UUMAX),SV(VVMAX),SW(WWMIN),X7,Y7,DUM,2)
CALL TRN32T (SU(UUMAX),SV(VVMAX),SW(WWMAX),X8,Y8,DUM,2)
XMIN = MIN(X1,X2,X3,X4,X5,X6,X7,X8)
XMAX = MAX(X1,X2,X3,X4,X5,X6,X7,X8)
YMIN = MIN(Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8)
YMAX = MAX(Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8)
C
C ADD RIGHT AMOUNT TO KEEP PICTURE SQUARE
C
20 WIDTH = XMAX-XMIN
HIGHT = YMAX-YMIN
DIF = .5*(WIDTH-HIGHT)
IF (DIF) 30, 50, 40
30 XMIN = XMIN+DIF
XMAX = XMAX-DIF
GO TO 50
40 YMIN = YMIN-DIF
YMAX = YMAX+DIF
50 ISCALE = 1
CALL TRN32T (ATU,ATV,ATW,EYE(1),EYE(2),EYE(3),1)
RETURN
END
| ncarg2d/src/libncarg/threed/set3.f |
!
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2021 Guido Dhondt
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation(version 2);
!
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
subroutine allocation(nload_,nforc_,nboun_,nk_,ne_,nmpc_,
& nset_,nalset_,nmat_,ntmat_,npmat_,norien_,nam_,nprint_,
& mi,ntrans_,set,meminset,rmeminset,ncs_,
& namtot_,ncmat_,memmpc_,ne1d,ne2d,nflow,jobnamec,irstrt,
& ithermal,nener,nstate_,irestartstep,inpc,ipoinp,inp,
& ntie_,nbody_,nprop_,ipoinpc,nevdamp_,npt_,nslavs,nkon_,mcs,
& mortar,ifacecount,nintpoint,infree,nheading_,nobject_,
& iuel,iprestr,nstam,ndamp,nef,nbounold,nforcold,nloadold,
& nbodyold,mpcend,irobustdesign,nfc_,ndc_)
!
! calculates a conservative estimate of the size of the
! fields to be allocated
!
! meminset=total # of terms in sets
! rmeminset=total # of reduced terms (due to use of generate) in
! sets
!
! nstate_ needs only be assigned for
! a. restart (read from file)
! b. initial conditions (defined by *depvar)
!
implicit none
!
logical igen,lin,frequency,cyclicsymmetry,composite,
& tabular,massflow,beamgeneralsection
!
character*1 selabel,sulabel,inpc(*)
character*5 llab
character*8 label
character*20 mpclabel
character*81 set(*),noset,elset,slavset,mastset,noelset,submset,
& surface,slavsets,slavsett,mastsets,mastsett,surfset
character*132 jobnamec(*),textpart(16)
!
integer nload_,nforc_,nboun_,nk_,ne_,nmpc_,nset_,nalset_,
& nmat_,ntmat_,npmat_,norien_,nam_,nprint_,kode,iline,
& istat,n,key,meminset(*),i,js,inoset,mi(*),ii,ipol,inl,
& ibounstart,ibounend,ibound,ntrans_,ntmatl,npmatl,ityp,l,
& ielset,nope,nteller,nterm,ialset(16),ncs_,rmeminset(*),
& islavset,imastset,namtot_,ncmat_,nconstants,memmpc_,j,ipos,
& maxrmeminset,ne1d,ne2d,necper,necpsr,necaxr,nesr,
& neb32,nn,nflow,nradiate,irestartread,irestartstep,icntrl,
& irstrt(*),ithermal(*),nener,nstate_,ipoinp(2,*),inp(3,*),
& ntie_,nbody_,nprop_,ipoinpc(0:*),nevdamp_,npt_,nentries,
& iposs,iposm,nslavs,nlayer,nkon_,nopeexp,iremove,mcs,
& ifacecount,nintpoint,mortar,infree(4),nheading_,icfd,
& multslav,multmast,nobject_,numnodes,iorientation,id,
& irotation,itranslation,nuel,iuel(4,*),number,four,
& iprestr,nstam,ier,ndamp,nef,nbounold,nforcold,nloadold,
& nbodyold,mpcend,irobustdesign(3),iflag,network,
& nsubmodel,nfc_,ndc_
!
real*8 temperature,tempact,xfreq,tpinc,tpmin,tpmax
!
parameter(nentries=18)
!
! icfd=-1: initial value
! =0: pure mechanical analysis
! =1: pure CFD analysis
! =2: mixed mechanical/cfd analysis
!
! mi(1): # of integration points
! mi(2): # of dofs per node
! mi(3): # of layers in the elements
!
icfd=-1
!
ier=0
!
! in the presence of mechanical steps the highest number
! of DOF is at least 3
!
if(ithermal(2).ne.2) mi(2)=3
!
! initialisation of ipoinp
!
do i=1,nentries
if(ipoinp(1,i).ne.0) then
ipol=i
inl=ipoinp(1,i)
iline=inp(1,inl)-1
exit
endif
enddo
!
istat=0
!
nsubmodel=0
nset_=0
maxrmeminset=0
necper=0
necpsr=0
necaxr=0
nesr=0
neb32=0
nradiate=0
nkon_=0
nuel=0
!
four=4
!
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
loop: do
if(istat.lt.0) then
exit
endif
!
if(textpart(1)(1:10).eq.'*AMPLITUDE') then
nam_=nam_+1
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
namtot_=namtot_+4
enddo
elseif(textpart(1)(1:19).eq.'*BEAMGENERALSECTION') then
mi(3)=max(mi(3),2)
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) then
exit
endif
nprop_=nprop_+8
enddo
elseif(textpart(1)(1:12).eq.'*BEAMSECTION') then
mi(3)=max(mi(3),2)
beamgeneralsection=.false.
do i=2,n
if((textpart(i)(1:11).eq.'SECTION=BOX').or.
& (textpart(i)(1:11).eq.'SECTION=PIP').or.
& (textpart(i)(1:11).eq.'SECTION=GEN')) then
beamgeneralsection=.true.
exit
endif
enddo
if(beamgeneralsection) then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) then
exit
endif
nprop_=nprop_+8
enddo
else
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
endif
elseif(textpart(1)(1:10).eq.'*BOUNDARYF') then
nam_=nam_+1
namtot_=namtot_+1
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
!
read(textpart(3)(1:10),'(i10)',iostat=istat) ibounstart
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*BOUNDARYF%",ier)
exit
endif
!
if(textpart(4)(1:1).eq.' ') then
ibounend=ibounstart
else
read(textpart(4)(1:10),'(i10)',iostat=istat) ibounend
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*BOUNDARYF%",ier)
exit
endif
endif
ibound=ibounend-ibounstart+1
ibound=max(1,ibound)
!
read(textpart(1)(1:10),'(i10)',iostat=istat) l
if(istat.eq.0) then
nboun_=nboun_+ibound
if(ntrans_.gt.0) then
nmpc_=nmpc_+ibound
memmpc_=memmpc_+4*ibound
nk_=nk_+1
endif
else
read(textpart(1)(1:80),'(a80)',iostat=istat) elset
elset(81:81)=' '
ipos=index(elset,' ')
!
! check for element set
!
elset(ipos:ipos)='E'
call cident81(set,elset,nset_,id)
i=nset_+1
if(id.gt.0) then
if(set(id).eq.elset) then
i=id
nboun_=nboun_+ibound*meminset(i)
if(ntrans_.gt.0)then
nmpc_=nmpc_+ibound*meminset(i)
memmpc_=memmpc_+4*ibound*meminset(i)
nk_=nk_+meminset(i)
endif
endif
endif
if(i.gt.nset_) then
!
! check for facial surface
!
elset(ipos:ipos)='T'
call cident81(set,elset,nset_,i)
if(i.gt.0) then
if(set(i).eq.elset) then
nboun_=nboun_+ibound*meminset(i)
if(ntrans_.gt.0)then
nmpc_=nmpc_+ibound*meminset(i)
memmpc_=memmpc_+4*ibound*meminset(i)
nk_=nk_+meminset(i)
endif
endif
endif
endif
endif
enddo
elseif(textpart(1)(1:9).eq.'*BOUNDARY') then
nam_=nam_+1
namtot_=namtot_+1
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
!
read(textpart(2)(1:10),'(i10)',iostat=istat) ibounstart
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*BOUNDARY%",ier)
exit
endif
!
if(textpart(3)(1:1).eq.' ') then
ibounend=ibounstart
else
read(textpart(3)(1:10),'(i10)',iostat=istat) ibounend
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*BOUNDARY%",ier)
exit
endif
endif
ibound=ibounend-ibounstart+1
ibound=max(1,ibound)
!
read(textpart(1)(1:10),'(i10)',iostat=istat) l
if(istat.eq.0) then
nboun_=nboun_+ibound
if(ntrans_.gt.0) then
nmpc_=nmpc_+ibound
memmpc_=memmpc_+4*ibound
nk_=nk_+1
endif
else
read(textpart(1)(1:80),'(a80)',iostat=istat) noset
noset(81:81)=' '
ipos=index(noset,' ')
noset(ipos:ipos)='N'
call cident81(set,noset,nset_,i)
if(i.gt.0) then
if(set(i).eq.noset) then
nboun_=nboun_+ibound*meminset(i)
if(ntrans_.gt.0)then
nmpc_=nmpc_+ibound*meminset(i)
memmpc_=memmpc_+4*ibound*meminset(i)
nk_=nk_+meminset(i)
endif
endif
endif
endif
enddo
elseif(textpart(1)(1:4).eq.'*CFD') then
iflag=1
do i=2,n
if(textpart(i)(1:10).eq.'TURBULENCE') then
iflag=iflag+1
endif
enddo
if(iflag.eq.2) mi(2)=max(mi(2),6)
write(*,*) 'mi(2)= ',mi(2)
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:6).eq.'*CFLUX') then
nam_=nam_+1
namtot_=namtot_+1
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
!
read(textpart(1)(1:10),'(i10)',iostat=istat) l
if(istat.eq.0) then
nforc_=nforc_+1
else
read(textpart(1)(1:80),'(a80)',iostat=istat) noset
noset(81:81)=' '
ipos=index(noset,' ')
noset(ipos:ipos)='N'
call cident81(set,noset,nset_,i)
if(i.gt.0) then
if(set(i).eq.noset) then
nforc_=nforc_+meminset(i)
endif
endif
endif
enddo
elseif(textpart(1)(1:6).eq.'*CLOAD') then
nam_=nam_+1
namtot_=namtot_+1
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
!
read(textpart(1)(1:10),'(i10)',iostat=istat) l
if(istat.eq.0) then
if(ntrans_.eq.0) then
nforc_=nforc_+1
else
nforc_=nforc_+3
endif
else
read(textpart(1)(1:80),'(a80)',iostat=istat) noset
noset(81:81)=' '
ipos=index(noset,' ')
noset(ipos:ipos)='N'
call cident81(set,noset,nset_,i)
if(i.gt.0) then
if(set(i).eq.noset) then
if(ntrans_.eq.0) then
nforc_=nforc_+meminset(i)
else
nforc_=nforc_+3*meminset(i)
endif
endif
endif
endif
enddo
elseif((textpart(1)(1:13).eq.'*CONDUCTIVITY').or.
& (textpart(1)(1:8).eq.'*DENSITY').or.
& (textpart(1)(1:10).eq.'*EXPANSION').or.
& (textpart(1)(1:15).eq.'*FLUIDCONSTANTS').or.
& (textpart(1)(1:13).eq.'*SPECIFICHEAT').or.
& (textpart(1)(1:23).eq.'*ELECTRICALCONDUCTIVITY')) then
ntmatl=0
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
enddo
elseif(textpart(1)(1:11).eq.'*CONSTRAINT') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
nobject_=nobject_+1
enddo
elseif(textpart(1)(1:15).eq.'*CONTACTDAMPING') then
ncmat_=max(8,ncmat_)
ntmat_=max(1,ntmat_)
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:12).eq.'*CONTACTPAIR') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntie_=ntie_+1
enddo
elseif(textpart(1)(1:13).eq.'*CONTACTPRINT') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
nprint_=nprint_+n
enddo
elseif(textpart(1)(1:9).eq.'*COUPLING') then
surface(1:1)=' '
iorientation=0
do i=2,n
if(textpart(i)(1:8).eq.'SURFACE=') then
surface=textpart(i)(9:88)
ipos=index(surface,' ')
surface(ipos:ipos)='T'
elseif(textpart(i)(1:12).eq.'ORIENTATION=') then
iorientation=1
endif
enddo
if(surface(1:1).ne.' ') then
surface(ipos:ipos)='T'
call cident81(set,surface,nset_,i)
if(i.gt.0) then
if(set(i).eq.surface) then
numnodes=8*meminset(i)
endif
endif
surface(ipos:ipos)='S'
call cident81(set,surface,nset_,i)
if(i.gt.0) then
if(set(i).eq.surface) then
numnodes=meminset(i)
endif
endif
endif
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:6).eq.'*CREEP') then
ntmatl=0
npmat_=max(2,npmat_)
if(ncmat_.le.2) then
! elastic isotropic
ncmat_=max(9,ncmat_)
else
! elastic anisotropic
ncmat_=max(19,ncmat_)
endif
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
enddo
ntmat_=max(ntmatl,ntmat_)
elseif(textpart(1)(1:16).eq.'*CYCLICHARDENING') then
ntmatl=0
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(3)(1:20),'(f20.0)',iostat=istat)
& temperature
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*CYCLIC HARDENING%",ier)
exit
endif
if(ntmatl.eq.0) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
elseif(temperature.ne.tempact) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
endif
npmatl=npmatl+1
npmat_=max(npmatl,npmat_)
enddo
elseif(textpart(1)(1:20).eq.'*CYCLICSYMMETRYMODEL') then
!
! possible MPC's: static temperature, displacements(velocities)
! and static pressure
!
nk_=nk_+1
!
! change on 11th of Dec. 2020
!
nmpc_=nmpc_+(mi(2)+1)*ncs_
memmpc_=memmpc_+25*(mi(2)+1)*ncs_
ntrans_=ntrans_+1
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
enddo
elseif(textpart(1)(1:8).eq.'*DAMPING') then
do i=2,n
if(textpart(i)(1:11).eq.'STRUCTURAL=') then
ndamp=1
exit
endif
enddo
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:8).eq.'*DASHPOT') then
nmat_=nmat_+1
frequency=.false.
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) then
call inputerror(inpc,ipoinpc,iline,
& "*DASHPOT%",ier)
cycle
endif
read(textpart(2)(1:20),'(f20.0)',iostat=istat)
& xfreq
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*DASHPOT%",ier)
cycle
endif
if(xfreq.gt.0.d0) frequency=.true.
iline=iline-1
if(.not.frequency) then
ntmatl=0
ncmat_=max(2,ncmat_)
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
enddo
else
ntmatl=0
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(3)(1:20),'(f20.0)',iostat=istat)
& temperature
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*DASHPOT%",ier)
exit
endif
if(ntmatl.eq.0) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
elseif(temperature.ne.tempact) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
endif
npmatl=npmatl+1
npmat_=max(npmatl,npmat_)
enddo
if(ncmat_.ge.9) ncmat_=max(19,ncmat_)
endif
elseif(textpart(1)(1:22).eq.'*DEFORMATIONPLASTICITY') then
ncmat_=max(5,ncmat_)
ntmatl=0
!
! the deformation plasticity model does not have internal
! variables. Nevertheless, space is reserved here for an
! equivalent plastic strain (used in sensitivity procedures
! to minimize plasticity)
!
nstate_=max(1,nstate_)
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
enddo
elseif(textpart(1)(1:7).eq.'*DEPVAR') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(1)(1:10),'(i10)',iostat=istat) l
if(istat.lt.0) exit
nstate_=max(l,nstate_)
enddo
elseif(textpart(1)(1:16).eq.'*DESIGNVARIABLES') then
ntie_=ntie_+1
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:15).eq.'*DESIGNRESPONSE') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
nobject_=nobject_+1
enddo
elseif(textpart(1)(1:21).eq.'*DISTRIBUTINGCOUPLING') then
nmpc_=nmpc_+3
memmpc_=memmpc_+3
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
!
read(textpart(1)(1:10),'(i10)',iostat=istat) l
if(istat.eq.0) then
memmpc_=memmpc_+3
else
read(textpart(1)(1:80),'(a80)',iostat=istat) noset
noset(81:81)=' '
ipos=index(noset,' ')
noset(ipos:ipos)='N'
call cident81(set,noset,nset_,i)
if(i.gt.0) then
if(set(i).eq.noset) then
memmpc_=memmpc_+3*meminset(i)
endif
endif
endif
enddo
elseif(textpart(1)(2:13).eq.'DISTRIBUTING') then
irotation=0
itranslation=0
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
!
read(textpart(1)(1:10),'(i10)',iostat=istat) ibounstart
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*BOUNDARY%",ier)
exit
endif
!
if(textpart(2)(1:1).eq.' ') then
ibounend=ibounstart
else
read(textpart(2)(1:10),'(i10)',iostat=istat) ibounend
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*BOUNDARY%",ier)
exit
endif
endif
ibounstart=max(4,ibounstart)
ibounend=min(6,ibounend)
ibound=max(0,ibounend-ibounstart+1)
!
if(itranslation.eq.0) then
!
! translational dofs 3 MPC's + a two-term MPC for each
! participating node
!
npt_=max(npt_,numnodes)
!
nfc_=nfc_+3*numnodes
nforc_=nforc_+3*numnodes
ndc_=ndc_+3
itranslation=1
endif
!
! rotational dofs
!
if(ibound.gt.0) then
ndc_=ndc_+ibound
endif
enddo
!
elseif(textpart(1)(2:18).eq.'DISTRIBUTIONTABLE') then
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(2:13).eq.'DISTRIBUTION') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
norien_=norien_+1
enddo
elseif((textpart(1)(1:6).eq.'*DLOAD').or.
& (textpart(1)(1:7).eq.'*DSLOAD').or.
& (textpart(1)(1:6).eq.'*DFLUX').or.
& (textpart(1)(1:9).eq.'*MASSFLOW').or.
& (textpart(1)(1:5).eq.'*FILM')) then
massflow=.false.
if((textpart(1)(1:5).ne.'*FILM').and.
& (textpart(1)(1:9).ne.'*MASSFLOW')) then
nam_=nam_+1
namtot_=namtot_+1
elseif(textpart(1)(1:9).ne.'*MASSFLOW') then
nam_=nam_+2
namtot_=namtot_+2
else
massflow=.true.
endif
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(2)(1:5),'(a5)',iostat=istat) llab
if((llab.eq.'GRAV ').or.(llab.eq.'CENTR').or.
& (llab.eq.'NEWTO')) then
nbody_=nbody_+1
cycle
endif
read(textpart(1)(1:10),'(i10)',iostat=istat) l
if(istat.eq.0) then
nload_=nload_+1
if(massflow) then
nmpc_=nmpc_+1
memmpc_=memmpc_+3
endif
else
read(textpart(1)(1:80),'(a80)',iostat=istat) elset
elset(81:81)=' '
ipos=index(elset,' ')
!
! check for element set
!
elset(ipos:ipos)='E'
call cident81(set,elset,nset_,id)
i=nset_+1
if(id.gt.0) then
if(set(id).eq.elset) then
i=id
nload_=nload_+meminset(i)
if(massflow) then
nmpc_=nmpc_+meminset(i)
memmpc_=memmpc_+3*meminset(i)
endif
endif
endif
if(i.gt.nset_) then
!
! check for facial surface
!
elset(ipos:ipos)='T'
call cident81(set,elset,nset_,i)
if(i.gt.0) then
if(set(i).eq.elset) then
nload_=nload_+meminset(i)
if(massflow) then
nmpc_=nmpc_+meminset(i)
memmpc_=memmpc_+3*meminset(i)
endif
endif
endif
endif
endif
enddo
elseif((textpart(1)(1:8).eq.'*DYNAMIC').or.
& (textpart(1)(1:32).eq.'*COUPLEDTEMPERATURE-DISPLACEMENT')
& .or.
& (textpart(1)(1:34).eq.
& '*UNCOUPLEDTEMPERATURE-DISPLACEMENT'))then
!
! change of number of integration points except for a pure
! CFD-calculation
!
if(icfd.ne.1) then
if((mi(1).eq.1).or.(mi(1).eq.8)) then
mi(1)=27
elseif(mi(1).eq.4) then
mi(1)=15
elseif(mi(1).eq.2) then
mi(1)=9
endif
endif
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:8).eq.'*ELPRINT') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
nprint_=nprint_+n
enddo
elseif(textpart(1)(1:8).eq.'*ELASTIC') then
ntmatl=0
ityp=2
ncmat_=max(2,ncmat_)
do i=2,n
if(textpart(i)(1:5).eq.'TYPE=') then
if(textpart(i)(6:8).eq.'ISO') then
ityp=2
ncmat_=max(2,ncmat_)
elseif((textpart(i)(6:10).eq.'ORTHO').or.
& (textpart(i)(6:10).eq.'ENGIN')) then
ityp=9
ncmat_=max(9,ncmat_)
elseif(textpart(i)(6:10).eq.'ANISO') then
ityp=21
ncmat_=max(21,ncmat_)
endif
exit
endif
enddo
if(ityp.eq.2) then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
enddo
ntmat_=max(ntmatl,ntmat_)
elseif(ityp.eq.9) then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
iline=iline+1
enddo
ntmat_=max(ntmatl,ntmat_)
elseif(ityp.eq.21) then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
iline=iline+2
enddo
ntmat_=max(ntmatl,ntmat_)
endif
elseif(textpart(1)(1:17).eq.'*ELECTROMAGNETICS') then
mi(2)=max(mi(2),5)
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif((textpart(1)(1:8).eq.'*ELEMENT').and.
& (textpart(1)(1:14).ne.'*ELEMENTOUTPUT')) then
ielset=0
!
loop1: do i=2,n
if(textpart(i)(1:6).eq.'ELSET=') then
elset=textpart(i)(7:86)
elset(81:81)=' '
ipos=index(elset,' ')
elset(ipos:ipos)='E'
ielset=1
call cident81(set,elset,nset_,id)
js=nset_+1
if(id.gt.0) then
if(set(id).eq.elset) js=id
endif
if(js.gt.nset_) then
nset_=nset_+1
do j=nset_,id+2,-1
meminset(j)=meminset(j-1)
rmeminset(j)=rmeminset(j-1)
set(j)=set(j-1)
enddo
js=id+1
set(js)=elset
meminset(js)=0
rmeminset(js)=0
endif
elseif(textpart(i)(1:5).eq.'TYPE=') then
read(textpart(i)(6:13),'(a8)') label
if(label.eq.' ') then
write(*,*)
& '*ERROR in allocation: element type is lacking'
write(*,*) ' '
call inputerror(inpc,ipoinpc,iline,
& "*ELEMENT or *ELEMENT OUTPUT%",ier)
exit
endif
if((label(1:2).eq.'DC').and.(label(1:7).ne.'DCOUP3D'))
& then
label(1:7)=label(2:8)
label(8:8)=' '
endif
!
nopeexp=0
!
if(label.eq.'C3D20 ') then
mi(1)=max(mi(1),27)
nope=20
nopeexp=20
elseif(label(1:8).eq.'C3D20R ') then
mi(1)=max(mi(1),8)
nope=20
nopeexp=20
elseif((label.eq.'C3D8R ').or.(label.eq.'F3D8R '))
& then
mi(1)=max(mi(1),1)
nope=8
nopeexp=8
elseif((label.eq.'C3D10 ').or.
& (label.eq.'C3D10T ')) then
mi(1)=max(mi(1),4)
nope=10
nopeexp=10
elseif((label.eq.'C3D4 ').or.
& (label.eq.'F3D4 ')) then
mi(1)=max(mi(1),1)
nope=4
nopeexp=4
elseif(label.eq.'C3D15 ') then
mi(1)=max(mi(1),9)
nope=15
nopeexp=15
elseif(label.eq.'C3D6 ') then
mi(1)=max(mi(1),2)
nope=6
nopeexp=6
elseif(label.eq.'F3D6 ') then
mi(1)=max(mi(1),1)
nope=6
nopeexp=6
elseif((label.eq.'C3D8 ').or.(label.eq.'F3D8 '))
& then
mi(1)=max(mi(1),8)
nope=8
nopeexp=8
c Bernhardi start
elseif(label.eq.'C3D8I ') then
mi(1)=max(mi(1),8)
nope=8
nopeexp=11
c Bernhardi end
elseif((label.eq.'CPE3 ').or.
& (label.eq.'CPS3 ').or.
& (label.eq.'CAX3 ').or.
& (label.eq.'M3D3 ').or.
& (label.eq.'S3 ')) then
mi(1)=max(mi(1),2)
nope=3
nopeexp=9
elseif((label.eq.'CPE4R ').or.
& (label.eq.'CPS4R ').or.
& (label.eq.'CAX4R ').or.
& (label.eq.'M3D4R ').or.
& (label.eq.'S4R ')) then
mi(1)=max(mi(1),1)
nope=4
nopeexp=12
elseif((label.eq.'CPE4 ').or.
& (label.eq.'CPS4 ').or.
& (label.eq.'CAX4 ').or.
& (label.eq.'M3D4 ')) then
mi(1)=max(mi(1),8)
nope=4
nopeexp=12
elseif(label.eq.'S4 ') then
mi(1)=max(mi(1),8)
nope=4
! modified into C3D8I (11 nodes)
nopeexp=15
elseif((label.eq.'CPE6 ').or.
& (label.eq.'CPS6 ').or.
& (label.eq.'CAX6 ').or.
& (label.eq.'M3D6 ').or.
& (label.eq.'S6 ')) then
mi(1)=max(mi(1),9)
nope=6
nopeexp=21
elseif((label.eq.'CPE8R ').or.
& (label.eq.'CPS8R ').or.
& (label.eq.'CAX8R ').or.
& (label.eq.'M3D8R ').or.
& (label.eq.'S8R ')) then
mi(1)=max(mi(1),8)
nope=8
nopeexp=28
elseif((label.eq.'CPE8 ').or.
& (label.eq.'CPS8 ').or.
& (label.eq.'CAX8 ').or.
& (label.eq.'M3D8 ').or.
& (label.eq.'S8 ')) then
mi(1)=max(mi(1),27)
nope=8
nopeexp=28
elseif((label.eq.'B31 ').or.
& (label.eq.'B21 ').or.
& (label.eq.'T3D2 ').or.
& (label.eq.'T2D2 ')) then
mi(1)=max(mi(1),8)
mi(3)=max(mi(3),2)
nope=2
! modified into C3D8I (11 nodes)
nopeexp=13
elseif(label.eq.'B31R ') then
mi(1)=max(mi(1),1)
nope=2
nopeexp=10
elseif((label.eq.'B32 ').or.
& (label.eq.'T3D3 ')) then
mi(1)=max(mi(1),27)
mi(3)=max(mi(3),2)
nope=3
nopeexp=23
elseif(label.eq.'B32R ') then
mi(1)=max(mi(1),50)
nope=3
nopeexp=23
elseif(label(1:8).eq.'DASHPOTA') then
label='EDSHPTA1'
nope=2
nopeexp=2
elseif(label(1:7).eq.'DCOUP3D') then
nope=1
nopeexp=1
elseif(label(1:1).eq.'D') then
nope=3
nopeexp=3
mi(2)=max(3,mi(2))
elseif(label(1:7).eq.'SPRINGA') then
mi(1)=max(mi(1),1)
label='ESPRNGA1'
nope=2
nopeexp=2
elseif(label(1:7).eq.'SPRING1') then
mi(1)=max(mi(1),1)
label='ESPRNG10'
nope=1
nopeexp=1
ncmat_=max(3,ncmat_)
elseif(label(1:7).eq.'SPRING2') then
mi(1)=max(mi(1),1)
label='ESPRNG21'
nope=2
nopeexp=2
ncmat_=max(4,ncmat_)
elseif(label.eq.'GAPUNI ') then
mi(1)=max(mi(1),1)
label='ESPGAPA1'
nope=2
nopeexp=2
elseif(label(1:4).eq.'MASS') then
nope=1
nopeexp=1
elseif(label(1:1).eq.'U') then
!
! the number uniquely characterizes the
! element name (consisting of 4 freely
! selectable characters in position 2..5)
!
number=ichar(label(2:2))*256**3+
& ichar(label(3:3))*256**2+
& ichar(label(4:4))*256+
& ichar(label(5:5))
nope=-1
call nidentk(iuel,number,nuel,id,four)
if(id.gt.0) then
if(iuel(1,id).eq.number) then
mi(1)=max(mi(1),iuel(2,id))
mi(2)=max(mi(2),iuel(3,id))
nope=iuel(4,id)
nopeexp=nope
endif
endif
if(nope.eq.-1) then
write(*,*) '*ERROR reading *ELEMENT'
write(*,*) ' nonexistent element type:'
write(*,*) ' ',label
call inputerror(inpc,ipoinpc,iline,
& "*ELEMENT%",ier)
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
cycle loop
endif
endif
if(label(1:1).eq.'F') then
mi(2)=max(mi(2),4)
if(icfd.eq.-1) then
icfd=1
elseif(icfd.eq.0) then
icfd=2
endif
else
if(icfd.eq.-1) then
icfd=0
elseif(icfd.eq.1) then
icfd=2
endif
endif
endif
enddo loop1
!
loop2:do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(1)(1:10),'(i10)',iostat=istat) i
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*ELEMENT or *ELEMENT OUTPUT%",ier)
exit
endif
c Bernhardi start
c space for incompatible mode nodes
if(label(1:5).eq.'C3D8I') then
nk_=nk_+3
endif
c Bernhardi end
if(label(1:2).ne.'C3') then
if(label(1:3).eq.'CPE') then
necper=necper+1
elseif(label(1:2).eq.'CP') then
necpsr=necpsr+1
elseif(label(1:1).eq.'C') then
necaxr=necaxr+1
elseif((label(1:1).eq.'S').or.
& ((label(1:1).eq.'M').and.(label(1:4).ne.'MASS')))
& then
nesr=nesr+1
elseif((label(1:1).eq.'B').or.
& (label(1:1).eq.'T')) then
neb32=neb32+1
elseif(label(1:1).eq.'D') then
nflow=nflow+1
elseif(label(1:1).eq.'F') then
nef=nef+1
endif
endif
nteller=n-1
if(nteller.lt.nope) then
do
call getnewline(inpc,textpart,istat,n,key,iline,
& ipol,inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit loop2
if(nteller+n.gt.nope) n=nope-nteller
nteller=nteller+n
if(nteller.eq.nope) exit
enddo
endif
ne_=max(ne_,i)
nkon_=nkon_+nopeexp
if(ielset.eq.1) then
meminset(js)=meminset(js)+1
rmeminset(js)=rmeminset(js)+1
endif
c !
c ! up to 8 new mpc's with 22 terms in each mpc
c ! (21 = 7 nodes x 3 dofs + inhomogeneous term)
c !
enddo loop2
elseif((textpart(1)(1:5).eq.'*NSET').or.
& (textpart(1)(1:6).eq.'*ELSET')) then
if(textpart(1)(1:5).eq.'*NSET')
& then
noelset=textpart(2)(6:85)
noelset(81:81)=' '
ipos=index(noelset,' ')
noelset(ipos:ipos)='N'
kode=0
else
noelset=textpart(2)(7:86)
noelset(81:81)=' '
ipos=index(noelset,' ')
noelset(ipos:ipos)='E'
kode=1
endif
!
! check whether new set name or old one
!
call cident81(set,noelset,nset_,id)
nn=nset_+1
if(id.gt.0) then
if(set(id).eq.noelset) nn=id
endif
if(nn.gt.nset_) then
nset_=nset_+1
do j=nset_,id+2,-1
meminset(j)=meminset(j-1)
rmeminset(j)=rmeminset(j-1)
set(j)=set(j-1)
enddo
nn=id+1
set(nn)=noelset
meminset(nn)=0
rmeminset(nn)=0
endif
!
if((n.gt.2).and.(textpart(3)(1:8).eq.'GENERATE')) then
igen=.true.
else
igen=.false.
endif
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
if(igen) then
if(textpart(2)(1:1).eq.' ')
& textpart(2)=textpart(1)
if(textpart(3)(1:1).eq.' ')
& textpart(3)='1 '
do i=1,3
read(textpart(i)(1:10),'(i10)',iostat=istat)
& ialset(i)
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*NSET or *ELSET%",ier)
exit
endif
enddo
meminset(nn)=meminset(nn)+
& (ialset(2)-ialset(1))/ialset(3)+1
rmeminset(nn)=rmeminset(nn)+3
else
do i=1,n
read(textpart(i)(1:10),'(i10)',iostat=istat)
& ialset(i)
if(istat.gt.0) then
noelset=textpart(i)(1:80)
noelset(81:81)=' '
ipos=index(noelset,' ')
if(kode.eq.0) then
noelset(ipos:ipos)='N'
else
noelset(ipos:ipos)='E'
endif
call cident81(set,noelset,nset_,j)
if(j.gt.0) then
if(set(j).eq.noelset) then
meminset(nn)=meminset(nn)+
& meminset(j)
rmeminset(nn)=rmeminset(nn)+
& rmeminset(j)
endif
endif
else
meminset(nn)=meminset(nn)+1
rmeminset(nn)=rmeminset(nn)+1
endif
enddo
endif
enddo
elseif((textpart(1)(1:9).eq.'*EQUATION').or.
& (textpart(1)(1:10).eq.'*EQUATIONF')) then
iremove=0
do i=2,n
if(textpart(i)(1:6).eq.'REMOVE') iremove=1
enddo
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if(iremove.eq.1) exit
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(1)(1:10),'(i10)',iostat=istat) nterm
if(ntrans_.eq.0) then
nmpc_=nmpc_+1
memmpc_=memmpc_+nterm
else
nmpc_=nmpc_+3
memmpc_=memmpc_+3*nterm
endif
ii=0
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ii=ii+n/3
if(ii.eq.nterm) exit
enddo
enddo
elseif(textpart(1)(1:13).eq.'*FLUIDSECTION') then
nconstants=-1
do i=2,n
if(textpart(i)(1:10).eq.'CONSTANTS=') then
read(textpart(i)(11:20),'(i10)',iostat=istat)
& nconstants
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*FLUID SECTION%",ier)
exit
endif
nprop_=nprop_+nconstants
exit
endif
enddo
if(nconstants.lt.0) nprop_=nprop_+65
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
enddo
elseif(textpart(1)(1:9).eq.'*FRICTION') then
!
! '8' is for Mortar.
!
ncmat_=max(8,ncmat_)
ntmat_=max(1,ntmat_)
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:5).eq.'*GAP ') then
nmat_=nmat_+1
ncmat_=max(6,ncmat_)
ntmat_=max(1,ntmat_)
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
enddo
elseif(textpart(1)(1:15).eq.'*GAPCONDUCTANCE') then
ntmatl=0
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(3)(1:20),'(f20.0)',iostat=istat)
& temperature
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*GAP CONDUCTANCE%",ier)
exit
endif
if(ntmatl.eq.0) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
elseif(temperature.ne.tempact) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
endif
npmatl=npmatl+1
npmat_=max(npmatl,npmat_)
enddo
elseif(textpart(1)(1:18).eq.'*GAPHEATGENERATION') then
ncmat_=max(11,ncmat_)
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:20).eq.'*GEOMETRICCONSTRAINT') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
nobject_ = nobject_ + 1
enddo
elseif(textpart(1)(1:8).eq.'*HEADING') then
if(nheading_.ne.0) then
write(*,*) '*ERROR in allocation: more than 1'
write(*,*) ' *HEADING card in the input deck'
call inputerror(inpc,ipoinpc,iline,
& "*HEADING%",ier)
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
cycle loop
endif
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
nheading_=nheading_+1
enddo
elseif(textpart(1)(1:13).eq.'*HYPERELASTIC') then
ntmatl=0
ityp=-7
do i=2,n
if(textpart(i)(1:12).eq.'ARRUDA-BOYCE') then
ityp=-1
ncmat_=max(3,ncmat_)
elseif(textpart(i)(1:13).eq.'MOONEY-RIVLIN') then
ityp=-2
ncmat_=max(3,ncmat_)
elseif(textpart(i)(1:8).eq.'NEOHOOKE') then
ityp=-3
ncmat_=max(2,ncmat_)
elseif(textpart(i)(1:5).eq.'OGDEN') then
ityp=-4
ncmat_=max(3,ncmat_)
elseif(textpart(i)(1:10).eq.'POLYNOMIAL') then
ityp=-7
ncmat_=max(3,ncmat_)
elseif(textpart(i)(1:17).eq.'REDUCEDPOLYNOMIAL')
& then
ityp=-10
ncmat_=max(2,ncmat_)
elseif(textpart(i)(1:11).eq.'VANDERWAALS') then
ityp=-13
ncmat_=max(5,ncmat_)
elseif(textpart(i)(1:4).eq.'YEOH') then
ityp=-14
ncmat_=max(6,ncmat_)
elseif(textpart(i)(1:2).eq.'N=') then
if(textpart(i)(3:3).eq.'1') then
elseif(textpart(i)(3:3).eq.'2') then
if(ityp.eq.-4) then
ityp=-5
ncmat_=max(6,ncmat_)
elseif(ityp.eq.-7) then
ityp=-8
ncmat_=max(7,ncmat_)
elseif(ityp.eq.-10) then
ityp=-11
ncmat_=max(4,ncmat_)
endif
elseif(textpart(i)(3:3).eq.'3') then
if(ityp.eq.-4) then
ityp=-6
ncmat_=max(9,ncmat_)
elseif(ityp.eq.-7) then
ityp=-9
ncmat_=max(12,ncmat_)
elseif(ityp.eq.-10) then
ityp=-12
ncmat_=max(6,ncmat_)
endif
endif
endif
enddo
if((ityp.ne.-6).and.(ityp.ne.-9)) then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
enddo
else
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
iline=iline+1
enddo
endif
elseif(textpart(1)(1:10).eq.'*HYPERFOAM') then
ntmatl=0
ityp=-15
ncmat_=max(3,ncmat_)
do i=2,n
if(textpart(i)(1:2).eq.'N=') then
if(textpart(i)(3:3).eq.'1') then
elseif(textpart(i)(3:3).eq.'2') then
ityp=-16
ncmat_=max(6,ncmat_)
elseif(textpart(i)(3:3).eq.'3') then
ityp=-17
ncmat_=max(9,ncmat_)
endif
endif
enddo
if(ityp.ne.-17) then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
enddo
else
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
iline=iline+1
enddo
endif
elseif(textpart(1)(2:10).eq.'KINEMATIC') then
npt_=max(npt_,numnodes)
!
! connection of rotational dofs in refnode to
! translational dofs in rotational node
!
nk_=nk_+1
nmpc_=nmpc_+3
memmpc_=memmpc_+6
!
! local system
!
if(iorientation.ne.0) then
nk_=nk_+2*numnodes
nmpc_=nmpc_+3*numnodes
memmpc_=memmpc_+3*6*numnodes
nboun_=nboun_+3*numnodes
endif
!
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
!
read(textpart(1)(1:10),'(i10)',iostat=istat) ibounstart
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*BOUNDARY%",ier)
exit
endif
!
if(textpart(2)(1:1).eq.' ') then
ibounend=ibounstart
else
read(textpart(2)(1:10),'(i10)',iostat=istat) ibounend
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*BOUNDARY%",ier)
exit
endif
endif
ibound=ibounend-ibounstart+1
ibound=max(1,ibound)
ibound=min(3,ibound)
!
if(iorientation.eq.0) then
nk_=nk_+numnodes
nmpc_=nmpc_+ibound*numnodes
memmpc_=memmpc_+6*ibound*numnodes
nboun_=nboun_+ibound*numnodes
else
nmpc_=nmpc_+ibound*numnodes
memmpc_=memmpc_+ibound*6*numnodes
endif
enddo
elseif(textpart(1)(1:21).eq.'*MAGNETICPERMEABILITY') then
ntmatl=0
ityp=2
ncmat_=max(2,ncmat_)
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
enddo
elseif(textpart(1)(1:5).eq.'*MASS') then
nmat_=nmat_+1
ntmat_=max(1,ntmat_)
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:9).eq.'*MATERIAL') then
nmat_=nmat_+1
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:13).eq.'*MODALDAMPING') then
if(textpart(2)(1:8).ne.'RAYLEIGH') then
nevdamp_=0
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(1)(1:10),'(i10)',iostat=istat) i
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*MODAL DAMPING%",ier)
exit
endif
nevdamp_ = max(nevdamp_,i)
read(textpart(2)(1:10),'(i10)',iostat=istat) i
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*MODAL DAMPING%",ier)
exit
endif
nevdamp_ = max(nevdamp_,i)
enddo
else
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
endif
elseif(textpart(1)(1:12).eq.'*MODELCHANGE') then
if(iprestr.ne.2) then
do i=2,n
if(textpart(i)(1:14).eq.'ADD=STRAINFREE') then
iprestr=2
exit
elseif(textpart(i)(1:14).eq.'ADD=WITHSTRAIN') then
elseif(textpart(i)(1:3).eq.'ADD') then
iprestr=2
exit
elseif(textpart(i)(1:20).eq.'MECHSTRAINTORESIDUAL')
& then
iprestr=2
exit
endif
enddo
endif
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:4).eq.'*MPC') then
mpclabel=' '
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
do i=1,n
read(textpart(i)(1:10),'(i10)',iostat=istat) ialset(i)
if(mpclabel.eq.' ') then
mpclabel=textpart(i)(1:20)
if((mpclabel(1:8).ne.'STRAIGHT').and.
& (mpclabel(1:4).ne.'PLANE')) then
nk_=nk_+1
nmpc_=nmpc_+1
nboun_=nboun_+1
memmpc_=memmpc_+1
endif
elseif(istat.gt.0) then
noelset=textpart(i)(1:80)
noelset(81:81)=' '
ipos=index(noelset,' ')
noelset(ipos:ipos)='N'
call cident81(set,noelset,nset_,j)
if(j.gt.0) then
if(set(j).eq.noelset) then
if(mpclabel(1:8).eq.'STRAIGHT') then
nk_=nk_+2*meminset(j)
nmpc_=nmpc_+2*meminset(j)
nboun_=nboun_+2*meminset(j)
memmpc_=memmpc_+14*meminset(j)
elseif(mpclabel(1:5).eq.'PLANE') then
nk_=nk_+meminset(j)
nmpc_=nmpc_+meminset(j)
nboun_=nboun_+meminset(j)
memmpc_=memmpc_+13*meminset(j)
elseif(mpclabel(1:4).eq.'BEAM') then
memmpc_=memmpc_+3*meminset(j)
else
memmpc_=memmpc_+meminset(j)
endif
endif
endif
else
if(mpclabel(1:8).eq.'STRAIGHT') then
nk_=nk_+2
nmpc_=nmpc_+2
nboun_=nboun_+2
memmpc_=memmpc_+14
elseif(mpclabel(1:5).eq.'PLANE') then
nk_=nk_+1
nmpc_=nmpc_+1
nboun_=nboun_+1
memmpc_=memmpc_+13
elseif(mpclabel(1:4).eq.'BEAM') then
memmpc_=memmpc_+3
else
memmpc_=memmpc_+1
endif
endif
enddo
enddo
elseif(textpart(1)(1:11).eq.'*NETWORKMPC') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(1)(1:10),'(i10)',iostat=istat) nterm
if(ntrans_.eq.0) then
nmpc_=nmpc_+1
memmpc_=memmpc_+nterm
else
nmpc_=nmpc_+3
memmpc_=memmpc_+3*nterm
endif
ii=0
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ii=ii+n/3
if(ii.eq.nterm) exit
enddo
enddo
elseif((textpart(1)(1:5).eq.'*NODE').and.
& (textpart(1)(1:10).ne.'*NODEPRINT').and.
& (textpart(1)(1:9).ne.'*NODEFILE').and.
& (textpart(1)(1:11).ne.'*NODEOUTPUT')) then
inoset=0
loop3: do i=2,n
if(textpart(i)(1:5).eq.'NSET=') then
noset=textpart(i)(6:85)
noset(81:81)=' '
ipos=index(noset,' ')
noset(ipos:ipos)='N'
inoset=1
call cident81(set,noset,nset_,id)
js=nset_+1
if(id.gt.0) then
if(set(id).eq.noset) js=id
endif
if(js.gt.nset_) then
nset_=nset_+1
do j=nset_,id+2,-1
meminset(j)=meminset(j-1)
rmeminset(j)=rmeminset(j-1)
set(j)=set(j-1)
enddo
js=id+1
set(js)=noset
meminset(js)=0
rmeminset(js)=0
endif
endif
enddo loop3
!
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(1)(1:10),'(i10)',iostat=istat) i
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*NODE or *NODE PRINT or *NODE FILE or *NODE OUTPUT%",
& ier)
exit
endif
nk_=max(nk_,i)
if(inoset.eq.1) then
meminset(js)=meminset(js)+1
rmeminset(js)=rmeminset(js)+1
endif
enddo
elseif(textpart(1)(1:10).eq.'*NODEPRINT') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
nprint_=nprint_+n
enddo
elseif(textpart(1)(1:10).eq.'*OBJECTIVE') then
nobject_=nobject_+1
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:12).eq.'*ORIENTATION') then
norien_=norien_+1
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
enddo
elseif(textpart(1)(1:8).eq.'*PLASTIC') then
ntmatl=0
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(3)(1:20),'(f20.0)',iostat=istat)
& temperature
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*PLASTIC%",ier)
exit
endif
if(ntmatl.eq.0) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
elseif(temperature.ne.tempact) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
endif
npmatl=npmatl+1
npmat_=max(npmatl,npmat_)
enddo
if(ncmat_.ge.9) ncmat_=max(19,ncmat_)
elseif(textpart(1)(1:19).eq.'*PRE-TENSIONSECTION') then
surface(1:1)=' '
do i=2,n
if(textpart(i)(1:8).eq.'SURFACE=') then
surface=textpart(i)(9:88)
ipos=index(surface,' ')
surface(ipos:ipos)='T'
exit
elseif(textpart(i)(1:8).eq.'ELEMENT=') then
nmpc_=nmpc_+1
memmpc_=memmpc_+7
exit
endif
enddo
if(surface(1:1).ne.' ') then
call cident81(set,surface,nset_,i)
if(i.gt.0) then
if(set(i).eq.surface) then
!
! worst case: 8 nodes per element face
!
nk_=nk_+8*meminset(i)
npt_=npt_+8*meminset(i)
!
! 2 MPC's per node perpendicular to tension direction
! + 1 thermal MPC per node
! + 1 MPC per node in tension direction (the total of
! which is divided into one global tension MPC and the
! rest are MPC's specifying that the distance in tension
! direction in all nodes should be the same)
!
nmpc_=nmpc_+32*meminset(i)+1
!
! 6 terms per MPC perpendicular to tension direction
! + 2 thermal terms per MPC
! + 6 terms * # of nodes +1 parallel to tension
! direction
! + 12 terms per MPC parallel to tension direction
!
memmpc_=memmpc_+96*meminset(i)
& +16*meminset(i)
& +48*meminset(i)+1
& +12*(8*meminset(i)-1)
!
endif
endif
endif
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:8).eq.'*RADIATE') then
nam_=nam_+2
namtot_=namtot_+2
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(2)(1:5),'(a5)',iostat=istat) llab
if((llab.eq.'GRAV ').or.(llab.eq.'CENTR')) exit
read(textpart(1)(1:10),'(i10)',iostat=istat) l
if(istat.eq.0) then
nload_=nload_+1
nradiate=nradiate+1
else
read(textpart(1)(1:80),'(a80)',iostat=istat) elset
elset(81:81)=' '
ipos=index(elset,' ')
elset(ipos:ipos)='E'
call cident81(set,elset,nset_,i)
if(i.gt.0) then
if(set(i).eq.elset) then
nload_=nload_+meminset(i)
nradiate=nradiate+meminset(i)
endif
endif
endif
enddo
elseif(textpart(1)(1:8).eq.'*RESTART') then
irestartread=0
irestartstep=0
do i=1,n
if(textpart(i)(1:4).eq.'READ') then
irestartread=1
endif
if(textpart(i)(1:5).eq.'STEP=') then
read(textpart(i)(6:15),'(i10)',iostat=istat)
& irestartstep
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*RESTART%",ier)
exit
endif
endif
enddo
if(irestartread.eq.1) then
icntrl=1
call restartshort(nset_,nload_,nbody_,nforc_,nboun_,nk_,ne_,
& nmpc_,nalset_,nmat_,ntmat_,npmat_,norien_,nam_,nprint_,
& mi,ntrans_,ncs_,namtot_,ncmat_,memmpc_,
& ne1d,ne2d,nflow,set,meminset,rmeminset,jobnamec,
& irestartstep,icntrl,ithermal,nener,nstate_,ntie_,
& nslavs,nkon_,mcs,nprop_,mortar,ifacecount,nintpoint,
& infree,nef,mpcend,nheading_,network,nfc_,ndc_,iprestr)
irstrt(1)=-1
nbounold=nboun_
nforcold=nforc_
nloadold=nload_
nbodyold=nbody_
else
endif
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:18).eq.'*RETAINEDNODALDOFS') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
!
read(textpart(2)(1:10),'(i10)',iostat=istat) ibounstart
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*BOUNDARY%",ier)
exit
endif
!
if(textpart(3)(1:1).eq.' ') then
ibounend=ibounstart
else
read(textpart(3)(1:10),'(i10)',iostat=istat) ibounend
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*BOUNDARY%",ier)
exit
endif
endif
ibound=ibounend-ibounstart+1
ibound=max(1,ibound)
ibound=min(3,ibound)
!
read(textpart(1)(1:10),'(i10)',iostat=istat) l
if(istat.eq.0) then
nboun_=nboun_+ibound
else
read(textpart(1)(1:80),'(a80)',iostat=istat) noset
noset(81:81)=' '
ipos=index(noset,' ')
noset(ipos:ipos)='N'
call cident81(set,noset,nset_,i)
if(i.gt.0) then
if(set(i).eq.noset) then
nboun_=nboun_+ibound*meminset(i)
endif
endif
endif
enddo
elseif(textpart(1)(1:10).eq.'*RIGIDBODY') then
noset='
&'
elset='
&'
do i=2,n
if(textpart(i)(1:5).eq.'NSET=')
& then
noset=textpart(i)(6:85)
noset(81:81)=' '
ipos=index(noset,' ')
noset(ipos:ipos)='N'
exit
elseif(textpart(i)(1:6).eq.'ELSET=')
& then
elset=textpart(i)(7:86)
elset(81:81)=' '
ipos=index(elset,' ')
elset(ipos:ipos)='E'
exit
endif
enddo
if(noset(1:1).ne.' ') then
call cident81(set,noset,nset_,i)
if(i.gt.0) then
if(set(i).eq.noset) then
nk_=nk_+2+meminset(i)
nmpc_=nmpc_+3*meminset(i)
memmpc_=memmpc_+18*meminset(i)
nboun_=nboun_+3*meminset(i)
endif
endif
elseif(elset(1:1).ne.' ') then
call cident81(set,elset,nset_,i)
if(i.gt.0) then
if(set(i).eq.elset) then
nk_=nk_+2+20*meminset(i)
nmpc_=nmpc_+60*meminset(i)
memmpc_=memmpc_+360*meminset(i)
nboun_=nboun_+60*meminset(i)
endif
endif
endif
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:13).eq.'*ROBUSTDESIGN') then
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
irobustdesign(1)=1
elseif(textpart(1)(1:16).eq.'*SECTIONPRINT') then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
nprint_=nprint_+n
enddo
elseif(textpart(1)(1:13).eq.'*SHELLSECTION') then
composite=.false.
do i=2,n
if(textpart(i)(1:9).eq.'COMPOSITE') then
composite=.true.
nlayer=0
elseif(textpart(i)(1:6).eq.'ELSET=') then
elset=textpart(i)(7:86)
elset(81:81)=' '
ipos=index(elset,' ')
elset(ipos:ipos)='E'
call cident81(set,elset,nset_,id)
js=nset_+1
if(id.gt.0) then
if(set(id).eq.elset) then
js=id
endif
endif
endif
enddo
if(composite) then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) then
!
! conservative upper limit
! "label" is not necessary the label of the
! composite shell element
!
mi(1)=max(mi(1),8*nlayer)
mi(3)=max(mi(3),nlayer)
if(js.le.nset_) then
nk_=nk_+20*nlayer*meminset(js)
nkon_=nkon_+20*nlayer*meminset(js)
endif
exit
endif
nlayer=nlayer+1
enddo
else
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
endif
elseif(textpart(1)(1:7).eq.'*SPRING') then
nmat_=nmat_+1
lin=.true.
do i=2,n
if(textpart(i)(1:9).eq.'NONLINEAR') then
lin=.false.
exit
endif
enddo
if(lin) then
ntmatl=0
ncmat_=max(2,ncmat_)
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
enddo
else
ntmatl=0
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(3)(1:20),'(f20.0)',iostat=istat)
& temperature
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*SPRING%",ier)
exit
endif
if(ntmatl.eq.0) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
elseif(temperature.ne.tempact) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
endif
npmatl=npmatl+1
npmat_=max(npmatl,npmat_)
enddo
if(ncmat_.ge.9) ncmat_=max(19,ncmat_)
endif
elseif(textpart(1)(1:5).eq.'*STEP') then
if(nstam.eq.0) then
do i=1,n
if((textpart(i)(1:14).eq.'AMPLITUDE=STEP').or.
& (textpart(i)(1:14).eq.'AMPLITUDE=RAMP')) then
nam_=nam_+2
namtot_=namtot_+4
nstam=1
exit
endif
enddo
endif
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:9).eq.'*SUBMODEL') then
nsubmodel=nsubmodel+1
ntie_=ntie_+1
nam_=nam_+1
namtot_=namtot_+4
!
! global element set
!
do j=2,n
if(textpart(j)(1:12).eq.'GLOBALELSET=')
& then
mastset(1:80)=textpart(j)(13:92)
mastset(81:81)=' '
ipos=index(mastset,' ')
mastset(ipos:ipos)='E'
call cident81(set,mastset,nset_,id)
i=nset_+1
if(id.gt.0) then
if(set(id).eq.mastset) then
i=id
endif
endif
if(i.le.nset_) then
meminset(i)=meminset(i)+meminset(i)
rmeminset(i)=rmeminset(i)+meminset(i)
endif
elseif(textpart(j)(1:5).eq.'TYPE=') then
if(textpart(j)(6:12).eq.'SURFACE') then
selabel='T'
else
selabel='N'
endif
endif
enddo
!
! local node or element face set
!
submset(1:8)='SUBMODEL'
if(nsubmodel.lt.10) then
submset(9:10)='00'
write(submset(11:11),'(i1)') nsubmodel
elseif(nsubmodel.lt.100) then
submset(9:9)='0'
write(submset(10:11),'(i2)') nsubmodel
elseif(nsubmodel.lt.1000) then
write(submset(9:11),'(i3)') nsubmodel
else
write(*,*) '*ERROR reading *SUBMODEL: no more than 999'
write(*,*) ' submodels allowed'
ier=1
return
endif
submset(12:12)=selabel
do i=13,81
submset(i:i)=' '
enddo
!
call cident81(set,submset,nset_,id)
nset_=nset_+1
do j=nset_,id+2,-1
meminset(j)=meminset(j-1)
rmeminset(j)=rmeminset(j-1)
set(j)=set(j-1)
enddo
js=id+1
set(js)=submset
meminset(js)=0
rmeminset(js)=0
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(1)(1:10),'(i10)',iostat=istat) ialset(1)
if(istat.gt.0) then
noset=textpart(1)(1:80)
noset(81:81)=' '
ipos=index(noset,' ')
noset(ipos:ipos)=selabel
call cident81(set,noset,nset_,i)
if(i.gt.0) then
if(set(i).eq.noset) then
meminset(js)=meminset(js)+meminset(i)
!
! surfaces are stored in expanded form
! (no equivalent to generate)
!
rmeminset(js)=rmeminset(js)+meminset(i)
endif
endif
else
meminset(js)=meminset(js)+1
rmeminset(js)=rmeminset(js)+1
endif
enddo
elseif(textpart(1)(1:9).eq.'*SURFACE ') then
sulabel='T'
do i=2,n
if(textpart(i)(1:5).eq.'NAME=')
& then
surfset=textpart(i)(6:85)
surfset(81:81)=' '
elseif(textpart(i)(1:9).eq.'TYPE=NODE') then
sulabel='S'
endif
enddo
ipos=index(surfset,' ')
surfset(ipos:ipos)=sulabel
call cident81(set,surfset,nset_,id)
nset_=nset_+1
do j=nset_,id+2,-1
meminset(j)=meminset(j-1)
rmeminset(j)=rmeminset(j-1)
set(j)=set(j-1)
enddo
js=id+1
set(js)=surfset
meminset(js)=0
rmeminset(js)=0
!
if(sulabel.eq.'S') then
selabel='N'
else
selabel='E'
endif
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(1)(1:10),'(i10)',iostat=istat) ialset(1)
if(istat.gt.0) then
noset=textpart(1)(1:80)
noset(81:81)=' '
ipos=index(noset,' ')
noset(ipos:ipos)=selabel
call cident81(set,noset,nset_,i)
if(i.gt.0) then
if(set(i).eq.noset) then
meminset(js)=meminset(js)+meminset(i)
!
! surfaces are stored in expanded form
! (no equivalent to generate)
!
rmeminset(js)=rmeminset(js)+meminset(i)
endif
endif
else
meminset(js)=meminset(js)+1
rmeminset(js)=rmeminset(js)+1
endif
enddo
!
! for CFD-calculations: local coordinate systems are
! stored as distributed load
!
if(icfd>0) nload_=nload_+rmeminset(js)
elseif(textpart(1)(1:16).eq.'*SURFACEBEHAVIOR') then
ncmat_=max(4,ncmat_)
ntmat_=max(1,ntmat_)
tabular=.false.
do i=1,n
if(textpart(i)(1:38).eq.'PRESSURE-OVERCLOSURE=TABULAR')
& tabular=.true.
enddo
if(tabular) then
ntmatl=0
do
call getnewline(inpc,textpart,istat,n,key,iline,
& ipol,inl,ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
read(textpart(3)(1:20),'(f20.0)',iostat=istat)
& temperature
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*SURFACE BEHAVIOR%",ier)
exit
endif
if(ntmatl.eq.0) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
elseif(temperature.ne.tempact) then
npmatl=0
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
tempact=temperature
endif
npmatl=npmatl+1
npmat_=max(npmatl,npmat_)
enddo
else
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
endif
elseif(textpart(1)(1:19).eq.'*SURFACEINTERACTION') then
nmat_=nmat_+1
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:12).eq.'*TEMPERATURE') then
nam_=nam_+1
namtot_=namtot_+1
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:4).eq.'*TIE') then
ntie_=ntie_+1
cyclicsymmetry=.false.
do i=1,n
if((textpart(i)(1:14).eq.'CYCLICSYMMETRY').or.
& (textpart(i)(1:10).eq.'MULTISTAGE')) then
cyclicsymmetry=.true.
endif
enddo
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if(.not.cyclicsymmetry) cycle
if((istat.lt.0).or.(key.eq.1)) cycle
!
slavset=textpart(1)(1:80)
slavset(81:81)=' '
iposs=index(slavset,' ')
slavsets=slavset
slavsets(iposs:iposs)='S'
slavsett=slavset
slavsett(iposs:iposs)='T'
!
mastset=textpart(2)(1:80)
mastset(81:81)=' '
iposm=index(mastset,' ')
mastsets=mastset
mastsets(iposm:iposm)='S'
mastsett=mastset
mastsett(iposm:iposm)='T'
!
islavset=0
imastset=0
!
call cident81(set,slavsets,nset_,i)
if(i.gt.0) then
if(set(i).eq.slavsets) then
islavset=i
multslav=1
endif
endif
call cident81(set,slavsett,nset_,i)
if(i.gt.0) then
if(set(i).eq.slavsett) then
islavset=i
multslav=8
endif
endif
call cident81(set,mastsets,nset_,i)
if(i.gt.0) then
if(set(i).eq.mastsets) then
imastset=i
multmast=1
endif
endif
call cident81(set,mastsett,nset_,i)
if(i.gt.0) then
if(set(i).eq.mastsett) then
imastset=i
multmast=8
endif
endif
!
if((islavset.ne.0).and.(imastset.ne.0)) then
ncs_=ncs_+max(multslav*meminset(islavset),
& multmast*meminset(imastset))
else
write(*,*) '*ERROR in allocation: either the slave'
write(*,*) ' surface or the master surface in a'
write(*,*) ' cyclic symmetry *TIE option or both'
write(*,*) ' do not exist or are no nodal surfaces'
write(*,*) ' slave set:',slavset(1:iposs-1)
write(*,*) ' master set:',mastset(1:iposm-1)
call inputerror(inpc,ipoinpc,iline,
& "*TIE%",ier)
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
cycle loop
endif
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:11).eq.'*TIMEPOINTS') then
igen=.false.
nam_=nam_+1
do i=2,n
if(textpart(i)(1:8).eq.'GENERATE') then
igen=.true.
exit
endif
enddo
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
if(igen)then
if(n.lt.3)then
write(*,*)'*ERROR in allocation:'
call inputerror(inpc,ipoinpc,iline,
& "*TIME POINTS%",ier)
exit
else
read(textpart(1)(1:20),'(f20.0)',iostat=istat)
& tpmin
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*TIME POINTS%",ier)
exit
endif
read(textpart(2)(1:20),'(f20.0)',iostat=istat)
& tpmax
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*TIME POINTS%",ier)
exit
endif
read(textpart(3)(1:20),'(f20.0)',iostat=istat)
& tpinc
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*TIME POINTS%",ier)
exit
endif
!
if((tpinc.le.0).or.(tpmin.ge.tpmax)) then
write(*,*) '*ERROR in allocation:'
call inputerror(inpc,ipoinpc,iline,
& "*TIME POINTS%",ier)
exit
else
namtot_=namtot_+2+INT((tpmax-tpmin)/tpinc)
endif
endif
else
namtot_=namtot_+8
endif
enddo
elseif(textpart(1)(1:10).eq.'*TRANSFORM') then
ntrans_=ntrans_+1
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
enddo
elseif(textpart(1)(1:11).eq.'*TRANSFORMF') then
ntrans_=ntrans_+1
surface(1:1)=' '
do i=2,n
if(textpart(i)(1:8).eq.'SURFACE=') then
surface=textpart(i)(9:88)
ipos=index(surface,' ')
surface(ipos:ipos)='T'
exit
endif
enddo
if(surface(1:1).ne.' ') then
call cident81(set,surface,nset_,i)
if(i.gt.0) then
if(set(i).eq.surface) then
nload_=nload_+meminset(i)
endif
endif
endif
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
enddo
elseif(textpart(1)(1:12).eq.'*USERELEMENT') then
call userelements(textpart,n,iuel,nuel,inpc,ipoinpc,iline,
& ier,ipoinp,inp,inl,ipol)
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
elseif(textpart(1)(1:13).eq.'*USERMATERIAL') then
ntmatl=0
do i=2,n
if(textpart(i)(1:10).eq.'CONSTANTS=') then
read(textpart(i)(11:20),'(i10)',iostat=istat)
& nconstants
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*USER MATERIAL%",ier)
exit
endif
ncmat_=max(nconstants,ncmat_)
exit
endif
enddo
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
ntmatl=ntmatl+1
ntmat_=max(ntmatl,ntmat_)
do i=2,nconstants/8+1
call getnewline(inpc,textpart,istat,n,key,iline,ipol,
& inl,ipoinp,inp,ipoinpc)
enddo
enddo
elseif(textpart(1)(1:12).eq.'*USERSECTION') then
nconstants=0
do i=2,n
if(textpart(i)(1:10).eq.'CONSTANTS=') then
read(textpart(i)(11:20),'(i10)',iostat=istat)
& nconstants
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*USER SECTION%",ier)
exit
endif
nprop_=nprop_+nconstants
exit
endif
enddo
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
enddo
else
!
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
endif
enddo loop
!
do i=1,nset_
nalset_=nalset_+rmeminset(i)
maxrmeminset=max(maxrmeminset,rmeminset(i))
enddo
!
! extra space needed for rearrangement in elements.f and
! noelsets.f
!
nalset_=nalset_+maxrmeminset
!
nmpc_=nmpc_+1
memmpc_=memmpc_+1
!
if(irstrt(1).eq.0) then
ne1d=neb32
ne2d=necper+necpsr+necaxr+nesr
endif
!
! introducing a fake tie for axisymmetric elements
! (needed for cavity radiation)
!
if(necaxr.gt.0) ntie_=max(1,ntie_)
!
! providing space for the expansion of shell and beam elements
! to genuine volume elements (no distinction is made between
! linear and quadratic elements. The worst case (quadratic)
! is taken
!
nk_=nk_+3*8*ne2d+8*3*ne1d
if(ne1d.gt.0) then
nboun_=nboun_*9
nforc_=nforc_*9
elseif(ne2d.gt.0) then
nboun_=nboun_*4
nforc_=nforc_*4
endif
!
! providing for rigid nodes (knots)
!
! number of knots: 8*ne2d+3*ne1d
! number of expanded nodes: 3*8*ne2d+8*3*ne1d
!
! number of extra nodes (1 rotational node and
! 1 expansion node per knot
! and one inhomogeneous term node per expanded node)
!
nk_=nk_+(2+3)*8*ne2d+(2+8)*3*ne1d
!
! number of equations (3 per expanded node)
!
nmpc_=nmpc_+3*(3*8*ne2d+8*3*ne1d)
!
! number of terms: 9 per equation
!
memmpc_=memmpc_+9*3*(3*8*ne2d+8*3*ne1d)
!
! number of SPC's: 1 per DOF per expanded node
!
nboun_=nboun_+3*(3*8*ne2d+8*3*ne1d)
!
! temperature DOF in knots
!
nmpc_=nmpc_+(3*8*ne2d+8*3*ne1d)
memmpc_=memmpc_+2*(3*8*ne2d+8*3*ne1d)
!
! extra MPCs to avoid undefinid rotation of rigid body nodes
! lying on a line
!
nmpc_=nmpc_+3*8*ne2d+8*3*ne1d
memmpc_=memmpc_+3*(3*8*ne2d+8*3*ne1d)
!
! extra nodes for the radiation boundary conditions
!
nk_=nk_+nradiate
!
! each layer in each shell has a local orientation
!
norien_=norien_+nesr*mi(3)
!
write(*,*)
write(*,*) ' The numbers below are estimated upper bounds'
write(*,*)
write(*,*) ' number of:'
write(*,*)
write(*,*) ' nodes: ',nk_
write(*,*) ' elements: ',ne_
write(*,*) ' one-dimensional elements: ',ne1d
write(*,*) ' two-dimensional elements: ',ne2d
write(*,*) ' integration points per element: ',mi(1)
write(*,*) ' degrees of freedom per node: ',mi(2)
write(*,*) ' layers per element: ',mi(3)
write(*,*)
write(*,*) ' distributed facial loads: ',nload_
write(*,*) ' distributed volumetric loads: ',nbody_
write(*,*) ' concentrated loads: ',nforc_
write(*,*) ' single point constraints: ',nboun_
write(*,*) ' multiple point constraints: ',nmpc_
write(*,*) ' terms in all multiple point constraints: ',memmpc_
write(*,*) ' tie constraints: ',ntie_
write(*,*) ' dependent nodes tied by cyclic constraints: ',ncs_
write(*,*) ' dependent nodes in pre-tension constraints: ',npt_
write(*,*)
write(*,*) ' sets: ',nset_
write(*,*) ' terms in all sets: ',nalset_
write(*,*)
write(*,*) ' materials: ',nmat_
write(*,*) ' constants per material and temperature: ',ncmat_
write(*,*) ' temperature points per material: ',ntmat_
write(*,*) ' plastic data points per material: ',npmat_
write(*,*)
write(*,*) ' orientations: ',norien_
write(*,*) ' amplitudes: ',nam_
write(*,*) ' data points in all amplitudes: ',namtot_
write(*,*) ' print requests: ',nprint_
write(*,*) ' transformations: ',ntrans_
write(*,*) ' property cards: ',nprop_
write(*,*)
!
if(ier.eq.1) then
write(*,*) '*ERROR in allocation: at least one fatal'
write(*,*) ' error message while reading the'
write(*,*) ' input deck: CalculiX stops.'
write(*,*)
call exit(201)
endif
!
return
end
| ccx_prool/CalculiX/ccx_2.19/src/allocation.f |
program ofmd_fft
use, intrinsic :: iso_fortran_env, only: output_unit
use types, only: dp
use constants, only: i_, K2au, density2gcm3, u2au, s2au, Ha2eV
use md, only: velocity_verlet, positions_random, &
calc_min_distance, positions_fcc, positions_bcc
use ewald_sums, only: ewald_box
use random, only: randn
use utils, only: init_random, stop_error, assert, linspace, clock, loadtxt
use ofdft, only: read_pseudo
use ofdft_fft, only: free_energy_min, radial_potential_fourier, &
reciprocal_space_vectors, real2fourier, fourier2real, logging_info
use interp3d, only: trilinear
use poisson3d_assembly, only: func2quad
implicit none
! All variables are in Hartree atomic units
! XLBOMD parameters:
integer, parameter :: K = 5
real(dp), parameter :: kappa = 1.82_dp, alpha = 0.018_dp
integer, parameter :: c0 = -6, c1 = 14, c2 = -8, c3 = -3, c4 = 4, c5 = -1
integer :: N
integer :: i, j, steps, u
real(dp) :: dt, L, t, rho, scf_eps
real(dp), allocatable :: V(:, :), X(:, :), f(:, :), m(:)
real(dp), allocatable :: R(:), Ven_rad(:), &
G(:, :, :, :), G2(:, :, :)
real(dp), allocatable :: Ven0G(:, :, :)
complex(dp), allocatable :: VenG(:, :, :), neG(:, :, :)
real(dp), allocatable :: ne(:, :, :), R2(:)
real(dp) :: Temp, Ekin, Temp_current, t3, t4
real(dp) :: Ediff, Z, Am
real(dp) :: Een_correction
real(dp) :: Eee, Een, Ts, Exc, Etot, Enn
real(dp), allocatable :: fnn(:, :), q(:), fen(:, :)
integer :: dynamics, functional, Ng, Nspecies, start, Nmesh
integer :: cg_iter
real(dp) :: sigma
real(dp), dimension(:,:,:,:), allocatable :: ne_aux
character(len=10) :: atom_name
real(dp) :: mdt1, mdt2
logging_info = .false. ! Turn of the INFO warnings
call read_input("OFMD.input", Temp, rho, Nspecies, N, Am, atom_name, start, &
dynamics, functional, Ng, scf_eps, steps, dt)
call read_pseudo("fem/" // trim(atom_name) // ".pseudo", R, Ven_rad, Z, Ediff)
allocate(V(3, N), f(3, N), m(N))
allocate(Ven0G(Ng, Ng, Ng), VenG(Ng, Ng, Ng), ne(Ng, Ng, Ng), neG(Ng, Ng, Ng))
allocate(G(Ng, Ng, Ng, 3), G2(Ng, Ng, Ng))
allocate(fnn(3, N), q(N), fen(3, N))
allocate(ne_aux(Ng, Ng, Ng, -K:1))
q = Z
m = Am * u2au ! Using Hydrogen mass in atomic mass units [u]
L = (sum(m) / rho)**(1._dp/3)
print *, "----------------------------------------------------------------"
print *, "Input Summary:"
print *, "N =", N
print *, "Ng =", Ng
print *, "MD steps =", steps
print *, "rho = ", rho, "a.u. =", rho * density2gcm3, "g/cm^3"
print *, "T =", Temp, "a.u. =", Temp / K2au, "K ="
print *, " =", Temp * Ha2eV, "eV"
print "(' dt =', f8.2, ' a.u. = ', es10.2, ' s = ', es10.2, ' ps')", dt, &
dt/s2au, dt/s2au * 1e12_dp
print "(' SCF_eps =', es10.2, ' a.u. = ', es10.2, ' eV')", scf_eps, &
scf_eps * Ha2eV
print *, "Initial position:", start
print *, "Atomic mass:", Am, "u"
print *, "Atomic name: ", trim(atom_name)
print *, "----------------------------------------------------------------"
print *
print *, "Calculated quantities:"
print *, "L =", L, "a.u."
print *
print *, "Converting aperiodic radial Ven to periodic cartesian Ven"
call radial_potential_fourier(R, Ven_rad, L, Z, Ven0G, Een_correction)
print *, " Done."
print *, "Atomic charge Z =", Z
Nmesh = 10000
allocate(R2(Nmesh))
R2 = linspace(0._dp, L/2, Nmesh)
call reciprocal_space_vectors([L, L, L], G, G2)
select case(start)
case (0)
print *, "Initial position: pos.txt"
call loadtxt("pos.txt", X)
call assert(size(X, 1) == 3)
call assert(size(X, 2) == N)
case (3)
print *, "Initial position: FCC"
allocate(X(3, N))
call positions_fcc(X, L)
case (4)
print *, "Initial position: BCC"
allocate(X(3, N))
call positions_bcc(X, L)
case (5)
print *, "Initial position: random"
! Make it deterministic for now
!call init_random()
sigma = 1
allocate(X(3, N))
call positions_random(X, L, 2**(1._dp/6)*sigma, 10)
case default
call stop_error("Invalid initial condition.")
end select
print *, "Positions:"
do i = 1, N
print *, i, X(:, i)
end do
print *, "Distances:"
do i = 2, N
print *, i, calc_min_distance(X(:, :i-1), L, X(:, i))
end do
print *
! Initialize velocities based on Maxwell-Boltzmann distribution
call randn(V)
V = V * sqrt(Temp / spread(m, 1, 3))
Ekin = calc_Ekin(V, m)
Temp_current = 2*Ekin/(3*N)
! The average temperature (i.e. if we average Temp_current for many runs) will
! be Temp. But we want to set it exactly to Temp, so we rescale the velocities.
V = V * sqrt(Temp / Temp_current)
print *, "MD start:"
t = 0
ne = N * Z / L**3
open(newunit=u, file="ofmd_results.txt", status="replace")
call write_results_header(u)
close(u)
t = 0
call cpu_time(t3)
do i = 1, steps
mdt1 = clock()
print *, "Starting MD iteration:", i
if (i > 10) then
! ne_aux(:, :, :, 1) ... n_{i+1}
! ne_aux(:, :, :, 0) ... n_{i}
! ne_aux(:, :, :, -1) ... n_{i-1}
! ne_aux(:, :, :, -2) ... n_{i-2}
! ne_aux(:, :, :, -3) ... n_{i-3}
! ne_aux(:, :, :, -4) ... n_{i-4}
! ne_aux(:, :, :, -5) ... n_{i-5}
if (i < 100) then
ne_aux(:, :, :, 1) = 2*ne - ne_aux(:, :, :, -1) &
+ alpha*(c0*ne &
+ c1*ne_aux(:, :, :, -1) + c2*ne_aux(:, :, :, -2) &
+ c3*ne_aux(:, :, :, -3) + c4*ne_aux(:, :, :, -4) &
+ c5*ne_aux(:, :, :, -5))
else
ne_aux(:, :, :, 1) = 2*ne_aux(:, :, :, 0) - ne_aux(:, :, :, -1) &
+ kappa*(ne-ne_aux(:, :, :, 0)) + alpha*(c0*ne_aux(:, :, :, 0) &
+ c1*ne_aux(:, :, :, -1) + c2*ne_aux(:, :, :, -2) &
+ c3*ne_aux(:, :, :, -3) + c4*ne_aux(:, :, :, -4) &
+ c5*ne_aux(:, :, :, -5))
end if
else
ne_aux(:, :, :, 1) = ne
end if
do j = 0, -K, -1
ne_aux(:, :, :, j) = ne_aux(:, :, :, j+1)
end do
ne = abs(ne_aux(:, :, :, 1))
if (i == 1) then
call forces(X, f)
else
call velocity_verlet(dt, m, L, forces, f, V, X)
end if
Ekin = calc_Ekin(V, m)
Temp_current = 2*Ekin/(3*N)
print *, "Nuclear forces:"
print *, fnn(:, 1)
print *, fnn(:, 2)
print *, fnn(:, 3)
print *, fnn(:, 4)
print *, "Electronic forces:"
print *, fen(:, 1)
print *, fen(:, 2)
print *, fen(:, 3)
print *, fen(:, 4)
print *, "total forces:"
print *, f(:, 1)
print *, f(:, 2)
print *, f(:, 3)
print *, f(:, 4)
mdt2 = clock()
open(newunit=u, file="ofmd_results.txt", position="append", status="old")
call write_results_line(u)
close(u)
call write_results_header(output_unit)
call write_results_line(output_unit)
t = t + dt
end do
call cpu_time(t4)
close(u)
print "('TIMINGS')"
print "('MD run: ', f10.4, 's')", t4-t3
print "('MD step: ', f10.4, 's')", (t4-t3)/steps
contains
subroutine forces(X, f)
real(dp), intent(in) :: X(:, :) ! positions
real(dp), intent(out) :: f(:, :) ! forces
real(dp) :: stress(6)
real(dp) :: fac(Ng, Ng, Ng)
integer :: i
print *, "-------------------------------------"
print *, "Calculating forces"
! Calculate nuclear forces
print *, "Calculating nuclear forces"
call ewald_box(L, X, q, Enn, fnn, stress)
! Calculate the electronic forces
print *, "Calculating VenG"
VenG = 0
do i = 1, N
! Note: we use minus sign in the forward real -> fourier transform.
! Then the following holds:
!
! F[f(x+b)] = F[f(x)]*e^{+i*G*b},
!
! with plus sign in the exponential. Finally, we are expressing
! Ven0(x-X) using the above formula (with b=-X) in terms of Ven0(x),
! i.e.:
!
! F[Ven0(x-X)] = F[Ven0(x)]*e^{-i*G*X},
!
! with minus sign in the exponential.
VenG = VenG - Ven0G * exp(i_ * &
(G(:,:,:,1)*X(1,i) + G(:,:,:,2)*X(2,i) + G(:,:,:,3)*X(3,i)))
end do
call assert(abs(VenG(1, 1, 1)) < epsilon(1._dp)) ! The G=0 component
! Energy calculation
print *, "Minimizing free energy"
call free_energy_min(N*Z, N, L, G2, Temp, VenG, ne, scf_eps, &
Eee, Een, Ts, Exc, Etot, cg_iter)
! Forces calculation
print *, "ne -> neG"
call real2fourier(ne, neG)
Een = Een + Een_correction * real(neG(1, 1, 1), dp) * N
Etot = Eee + Een + Ts + Exc
fen = 0
print *, "Calculating fen"
do i = 1, N
! We have minus sign in the exponential, per the definition of VenG
! above (see the comment there).
fac = L**3*Ven0G*aimag(neG*exp(-i_ * &
(G(:,:,:,1)*X(1,i) + G(:,:,:,2)*X(2,i) + G(:,:,:,3)*X(3,i))))
fen(1, i) = sum(G(:,:,:,1)*fac)
fen(2, i) = sum(G(:,:,:,2)*fac)
fen(3, i) = sum(G(:,:,:,3)*fac)
end do
f = fnn + fen
print *, "Done calculating forces."
print *, "-------------------------------------"
end subroutine
real(dp) pure function calc_Ekin(V, m) result(Ekin)
real(dp), intent(in) :: V(:, :) ! velocities
real(dp), intent(in) :: m(:) ! masses
Ekin = sum(m*sum(V**2, dim=1))/2
end function
subroutine read_input(filename, T, density, Nspecies, N, Am, Aname, &
start, dynamics, functional, Ng, scf_eps, steps, dt)
! Reads the input file, returns values in a.u.
character(len=*), intent(in) :: filename
real(dp), intent(out) :: T, density, dt, scf_eps, Am
character(len=*), intent(out) :: Aname
integer, intent(out) :: Nspecies, N, start, dynamics, functional, Ng, steps
integer :: AN
real(dp) :: AZ
integer :: u
real(dp) :: skip
open(newunit=u, file=filename, status="old")
read(u, *) T, density, Nspecies, N
read(u, *) start
read(u, *) dynamics, functional, Ng, skip, skip, scf_eps
read(u, *) steps, dt
read(u, *) Aname, AZ, Am, AN
close(u)
! Convert to atomic units:
T = T / Ha2eV
density = density / density2gcm3
scf_eps = scf_eps / Ha2eV
if (AN /= N) call stop_error("Inconsistent number of atoms")
end subroutine
subroutine write_results_header(u)
integer, intent(in) :: u
write(u, '(12a17)') "Time [a.u.]", "Fe [eV]", "Unn [eV]", "K [eV]", &
"F [eV]", "T [eV]", "Ts [eV]", "Een [eV]", "Eee [eV]", "Exc [eV]", &
"CG iter", "MD step time [s]"
end subroutine
subroutine write_results_line(u)
integer, intent(in) :: u
write(u, '(10f17.6, i17, f17.6)') &
t, Etot*Ha2eV/N, Enn*Ha2eV/N, Ekin*Ha2eV/N, &
(Etot + Enn + Ekin) * Ha2eV / N, Temp_current * Ha2eV, Ts * Ha2eV / N, &
Een * Ha2eV / N, Eee * Ha2eV / N, Exc * Ha2eV / N, cg_iter, &
mdt2 - mdt1
end subroutine
end program
| src/tests/ofmd_fft.f90 |
Petunia is a Pets pet who lives with Users/SharonZimmerman Sharon and Users/AmyZimmerman Amy Zimmerman, as well as with Users/ScottBiggart Scott Biggart. More importantly she lives with Endora the Rat.
Petunia was added to the family in early April of 2005. She is very small compared to the size of Endora. At first the two didnt get along but then Sharon smeared cream cheese on both of the rats foreheads and they licked it off each other and then liked each other (or at least how each other tasted).
| lab/davisWiki/Petunia_the_Rat.f |
subroutine mprove(a,alud,n,indx,b,x)
c--- Adapted from Numerical Recipes
c--- (extension to complex b)
implicit none
integer n,indx(n)
double precision a(n,n),alud(n,n)
double complex b(n),x(n),sdp,r(n),rout(n)
CU USES zlubksb
integer i,j
do i=1,n
sdp=-b(i)
do j=1,n
sdp=sdp+a(i,j)*x(j)
enddo
r(i)=sdp
enddo
call zlubksb(alud,n,indx,r,rout)
do i=1,n
x(i)=x(i)-rout(i)
enddo
return
end
| MCFM-JHUGen/TensorReduction/ov/mprove.f |
SUBROUTINE BMG3_SymStd_SETUP_fine_stencil( &
& KF, SO, &
& NLx, NLy, NLz, NStncl,&
& iWork, NMSGi, pMSGSO, BUFFER, NMSGr,&
& MPICOMM&
& ) BIND(C, NAME='BMG3_SymStd_SETUP_fine_stencil')
! ======================================================================
! --------------------
! DESCRIPTION:
! --------------------
!
! Perform communication setup (ghosts) for the fine-grid stencil.
!
! ======================================================================
! $license_flag$
! ======================================================================
! --------------------
! INPUT:
! --------------------
!
!
! ======================================================================
! --------------------
! INPUT/OUTPUT:
! --------------------
!
!
! ======================================================================
! --------------------
! OUTPUT:
! --------------------
!
!
! ======================================================================
! --------------------
! LOCAL:
! --------------------
!
!
! ======================================================================
USE ModInterface
IMPLICIT NONE
! -----------------------------
! Includes
!
INCLUDE 'mpif.h'
INCLUDE 'MSG_f90.h'
INCLUDE 'BMG_constants_f90.h'
INCLUDE 'BMG_stencils_f90.h'
INCLUDE 'BMG_workspace_f90.h'
! ---------------------------
! Argument Declarations:
!
integer(c_int), value :: KF, NStncl, MPICOMM
integer(len_t), value :: NLx, NLy, NLz, NMSGi, NMSGr
integer(c_int) :: pMSGSO(NBMG_pMSG,KF)
integer(len_t) :: iWork(NMSGi)
real(real_t) :: BUFFER(NMSGr), SO(NLx+1,NLy+1,NLz+1,NStncl)
! --------------------------
! Local Declarations:
!
INTEGER kst, ptrn, ierror
! ======================================================================
! ------------------------------
! Update halo region:
! ------------------------------
DO kst = 1, NStncl
ptrn = 1
CALL MSG_tbdx_send(SO(1,1,1,kst), buffer, &
& iWork(pMSGSO(ipL_MSG_NumAdjProc,KF)),&
& iWork(pMSGSO(ipL_MSG_Proc,KF)),&
& iWork(pMSGSO(ipL_MSG_Ipr,KF)),&
& iWork(pMSGSO(ipL_MSG_Index,KF)),&
& ptrn, ierror)
CALL MSG_tbdx_receive(SO(1,1,1,kst), buffer,&
& iWork(pMSGSO(ipL_MSG_NumAdjProc,KF)),&
& iWork(pMSGSO(ipL_MSG_Proc,KF)),&
& iWork(pMSGSO(ipL_MSG_Ipr,KF)),&
& iWork(pMSGSO(ipL_MSG_Index,KF)),&
& ptrn, ierror)
CALL MSG_tbdx_close(SO(1,1,1,kst), buffer,&
& iWork(pMSGSO(ipL_MSG_NumAdjProc,KF)),&
& iWork(pMSGSO(ipL_MSG_Proc,KF)),&
& iWork(pMSGSO(ipL_MSG_Ipr,KF)),&
& iWork(pMSGSO(ipL_MSG_Index,KF)),&
& ptrn, ierror)
ENDDO
! ======================================================================
RETURN
END
| src/3d/ftn/mpi/BMG3_SymStd_SETUP_fine_stencil.f90 |
! -*- Mode: Fortran; -*-
!
! (C) 2016 by Argonne National Laboratory.
! See COPYRIGHT in top-level directory.
!
! Portions of this code were written by Intel Corporation.
! Copyright (C) 2011-2016 Intel Corporation. Intel provides this material
! to Argonne National Laboratory subject to Software Grant and Corporate
! Contributor License Agreement dated February 8, 2012.
program main
use mpi_f08
implicit none
integer rank, size
type(MPI_Comm) :: comm_cart, comm_new
integer dims(2), coords(2)
logical periods(2), reorder, remain_dims(2)
integer errs
dims(1:2) = 0
periods(1) = .TRUE.
periods(2) = .FALSE.
reorder = .TRUE.
remain_dims(1) = .TRUE.
remain_dims(2) = .FALSE.
errs = 0
call MTEST_Init()
call MPI_Comm_rank(MPI_COMM_WORLD, rank)
call MPI_Comm_size(MPI_COMM_WORLD, size)
call MPI_Dims_create(size, 2, dims)
call MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, reorder, comm_cart)
call MPI_Comm_rank(comm_cart, rank)
call MPI_Cart_coords(comm_cart, rank, 2, coords)
call MPI_Cart_sub(comm_cart, remain_dims, comm_new)
call MPI_Comm_size(comm_new, size)
call MTEST_Finalize(errs)
end program
| test/mpi/f08/topo/cart_subf90.f90 |
program t
print '(a)','hello ','world'
end program t
| tests/t0020x/t.f |
program dim_assgn_test
integer, private, dimension(2,2) :: a(2,2)
integer, private, dimension(2,2) :: b(2,3)
end program
| tests/warnings/dim_assgn_test.f90 |
!
! Copyright 2003-2008 Henk Krus, Cyclone Fluid Dynamics BV
! All Rights Reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.dolfyn.net/license.html
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an
! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
! either express or implied. See the License for the specific
! language governing permissions and limitations under the License.
!
subroutine GradientPhi(ivar,Phi,dPhidX)
!========================================================================
!
! Main calling subroutine to calculate the gradient of 'phi'.
! Two methods are available:
! 1) using Gauss theorem, and
! 2) the least squares method
!
! Once a gradient has been computed an optional check if the gradient
! is reasonable is possible and if the gradient is too steep then
! it is limited. Names associated to these slope limiters are:
! Barth and Jespersen, Venkatakrishnan, Mavriplis, Aftosmis etc.
! Slope limiters are especially useful for all-tetrahedral meshes
! are used (only four relations for a 3D gradient, near walls the
! the situation is worse), and for bad/awkward meshes.
!
use constants
use geometry
use variables
use watches
real, dimension(Ncel+Nbnd), intent(IN) :: Phi
real, dimension(Ncel+Nbnd,3), intent(OUT) :: dPhidX
integer, intent(IN) :: ivar
!call watch_enter('GradientPhi')
!if( GradAlg == GradLS )then
! call GradientPhiLeastSquares(ivar,Phi,dPhidX)
!else if( GradAlg == GradGauss )then
! call GradientPhiGauss(ivar,Phi,dPhidX)
!else
! stop '*** internal error invalid gradient algorithm'
!endif
if( GradVar(iVar) == GradLS )then
call GradientPhiLeastSquares(ivar,Phi,dPhidX)
else if( GradVar(iVar) == GradGauss )then
call GradientPhiGauss(ivar,Phi,dPhidX)
else
stop '*** internal error invalid gradient algorithm'
endif
if( UseSlopeLimiter(iVar) )then
if( LimiterSlope(iVar) >= SlopeLimiterBJc .and. &
LimiterSlope(iVar) <= SlopeLimiterBJn )then
call GradientPhiLimiterBarthJespersen(ivar,LimiterSlope(iVar),Phi,dPhidX)
else if( LimiterSlope(iVar) >= SlopeLimiterVNc .and. &
LimiterSlope(iVar) <= SlopeLimiterVNn )then
call GradientPhiLimiterVenkatarishnan(ivar,LimiterSlope(iVar),Phi,dPhidX)
else if( LimiterSlope(iVar) >= SlopeLimiterVAc .and. &
LimiterSlope(iVar) <= SlopeLimiterVAn )then
call GradientPhiLimiterAlbada(ivar,LimiterSlope(iVar),Phi,dPhidX)
else if( LimiterSlope(iVar) >= SlopeLimiterP1c .and. &
LimiterSlope(iVar) <= SlopeLimiterP1n )then
call GradientPhiLimiterPolynomial(ivar,LimiterSlope(iVar),Phi,dPhidX)
endif
endif
!call watch_leave('GradientPhi')
end subroutine GradientPhi
subroutine GradientPhiGauss(ivar,Phi,dPhidX)
!========================================================================
use constants
use geometry
use variables
use watches
real, dimension(Ncel+Nbnd) :: Phi
real, dimension(Ncel+Nbnd,3) :: dPhidX
real :: facn, facp
real :: Xac(3), dPhidXac(3)
real, dimension(3) :: Xp, Xn, Xf, Xnorm, Xpac, Xnac, delp, deln
character(len=16) :: string
if( Debug > 3 ) write(IOdef,*)'*** GradientPhiGauss: ',Variable(ivar)
write(IOdbg,*)'*** GradientPhiGauss: ',Variable(ivar),Ngradient
write(string,'(''Gauss'',A11)') Variable(ivar)
call watch_enter(string)
! call watch_enter('GradientPhiGauss')
dPhidXo = 0.0
!
! iterative calculation of gradients
!
gradientloop: do igrad=1,Ngradient
dPhidX = 0.0
faceloop: do i=1,Nfac
ip = Face(i)%cell1
in = Face(i)%cell2
if( in > 0 )then
!
! internal cell face which points to two cells
!
facn = Face(i)%lambda
facp = 1.0 - facn
!
! for the next section see the discussion in the text
!
Xac = Cell(in)%x * facn + Cell(ip)%x * facp
dPhidXac = dPhidXo(in,:) * facn + dPhidXo(ip,:) * facp
!
! now the gradient at the shifted position is known
! correct the value at the cell face center
!
PhiFace = Phi(in) * facn + Phi(ip) * facp ! the standard
delta = dot_product( dPhidXac , Face(i)%x - Xac ) ! correction
PhiFace = PhiFace + delta
!
! now only the value at the face center is known
! multiply it by the area-components
! this is basically Gauss' theorem
!
dPhidX(ip,:) = dPhidX(ip,:) + PhiFace * Face(i)%n ! normal p -> n
dPhidX(in,:) = dPhidX(in,:) - PhiFace * Face(i)%n ! reversed
else
!
! boundary face
!
ib = Face(i)%bnd
PhiFace = Phi(Ncel+ib)
dPhidX(ip,:) = dPhidX(ip,:) + PhiFace * Face(i)%n
endif
end do faceloop
!dPhidX(1:Ncel,1) = dPhidX(1:Ncel,1) / Cell(1:Ncel)%Vol
!dPhidX(1:Ncel,2) = dPhidX(1:Ncel,2) / Cell(1:Ncel)%Vol
!dPhidX(1:Ncel,3) = dPhidX(1:Ncel,3) / Cell(1:Ncel)%Vol
!do i=1,Ncel
! fact = 1.0/Cell(i)%Vol ! not faster
! dPhidX(i,:) = fact*dPhidX(i,:)
!end do
do i=1,Ncel
fact = 1.0/Cell(i)%Vol
dPhidX(i,1) = fact*dPhidX(i,1)
dPhidX(i,2) = fact*dPhidX(i,2)
dPhidX(i,3) = fact*dPhidX(i,3)
end do
dPhidXo = dPhidX
!dPhidXo = dPhidXo + 0.95*( dPhidX - dPhidXo) ! under relaxation
end do gradientloop
if( allocated(DXgrad) ) DXgrad = dPhidX
if( Debug > 2 .and. iVar==VarT )then
write(IOdef,'(1x,1pe10.3,A,e10.3)') &
minval(dPhidX(1:Ncel,1)),' < dPhi/dX < ',maxval(dPhidX(1:Ncel,1))
write(IOdef,'(1x,1pe10.3,A,e10.3)') &
minval(dPhidX(1:Ncel,2)),' < dPhi/dY < ',maxval(dPhidX(1:Ncel,2))
write(IOdef,'(1x,1pe10.3,A,e10.3)') &
minval(dPhidX(1:Ncel,3)),' < dPhi/dZ < ',maxval(dPhidX(1:Ncel,3))
endif
call watch_leave('GradientPhiGauss')
if( Debug > 3 ) write(IOdef,*)'=== GradientPhi: ',Variable(ivar)
end subroutine GradientPhiGauss
subroutine GradientPhiLeastSquares(ivar,Phi,dPhidX)
!========================================================================
use constants
use geometry
use variables
use watches
real, dimension(Ncel+Nbnd) :: Phi
real, dimension(Ncel+Nbnd,3) :: dPhidX
real, dimension(3) :: GradPhi, Xf, Xac, Xp, dX, ds
real, dimension(3,3) :: A
real, dimension(3) :: RHS_A
integer, dimension(3):: IPIV ! LAPACK
character(len=16) :: string
if( Debug > 3 ) write(IOdef,*)'*** GradientPhiLeastSquares ',Variable(ivar)
write(IOdbg,*)'*** GradientPhiLeastSquares ',Variable(ivar)
write(string,'(''Least'',A11)') Variable(ivar)
call watch_enter(string)
!call watch_enter('GradientPhiLeastSquares')
dPhidX = 0.0
do ip=1,Ncel
Xp = Cell(ip)%x
A = 0.0
RHS_A = 0.0
do j=1,Nfaces(ip)
k = CFace(ip,j)
ipp = Face(k)%cell1
ipn = Face(k)%cell2
if( ipn > 0 )then
!
! original method Sum from P to N
!
if( ipp == ip )then
dPhi = Phi(ipn) - Phi(ipp)
dX = Cell(ipn)%x - Cell(ipp)%x
else
dPhi = Phi(ipp) - Phi(ipn)
dX = Cell(ipp)%x - Cell(ipn)%x
endif
A(1,1) = A(1,1) + dX(1)*dX(1)
A(2,1) = A(2,1) + dX(1)*dX(2)
A(3,1) = A(3,1) + dX(1)*dX(3)
A(1,2) = A(2,1)
A(2,2) = A(2,2) + dX(2)*dX(2)
A(3,2) = A(3,2) + dX(2)*dX(3)
A(1,3) = A(3,1)
A(2,3) = A(3,2)
A(3,3) = A(3,3) + dX(3)*dX(3)
RHS_A(1) = RHS_A(1) + dX(1)*dPhi
RHS_A(2) = RHS_A(2) + dX(2)*dPhi
RHS_A(3) = RHS_A(3) + dX(3)*dPhi
else
! boundary face
ib = Face(k)%bnd
ir = Bnd(ib)%rid
it = Reg(ir)%typ
dPhi = Phi(Ncel+ib) - Phi(ipp)
dX = Face(k)%x - Cell(ipp)%x
A(1,1) = A(1,1) + dX(1)*dX(1)
A(2,1) = A(2,1) + dX(1)*dX(2)
A(3,1) = A(3,1) + dX(1)*dX(3)
A(1,2) = A(2,1)
A(2,2) = A(2,2) + dX(2)*dX(2)
A(3,2) = A(3,2) + dX(2)*dX(3)
A(1,3) = A(3,1)
A(2,3) = A(3,2)
A(3,3) = A(3,3) + dX(3)*dX(3)
RHS_A(1) = RHS_A(1) + dX(1)*dPhi
RHS_A(2) = RHS_A(2) + dX(2)*dPhi
RHS_A(3) = RHS_A(3) + dX(3)*dPhi
endif
end do
if( UseLapack )then
call SGESV( 3, 1, A, 3, IPIV, RHS_A, 3, INFO )
if( info /= 0 ) write(IOdef,*)'Lapack (sgesv) info(1):',INFO
GradPhi(1) = RHS_A(1)
GradPhi(2) = RHS_A(2)
GradPhi(3) = RHS_A(3)
dPhidX(ip,:) = GradPhi
else
call A33xB3(A,RHS_A)
GradPhi(1) = RHS_A(1)
GradPhi(2) = RHS_A(2)
GradPhi(3) = RHS_A(3)
dPhidX(ip,:) = GradPhi
endif
end do
!if( allocated(DXdebug) .and. allocated(T) ) DXdebug =T(1:Ncel)
!if( allocated(DXgrad) ) DXgrad = dPhidX
if( Debug > 2 .and. ivar == vart )then
write(IOdef,'(1x,1pe10.3,A,e10.3)') &
minval(dPhidX(1:Ncel,1)),' < dPhi/dX < ',maxval(dPhidX(1:Ncel,1))
write(IOdef,'(1x,1pe10.3,A,e10.3)') &
minval(dPhidX(1:Ncel,2)),' < dPhi/dY < ',maxval(dPhidX(1:Ncel,2))
write(IOdef,'(1x,1pe10.3,A,e10.3)') &
minval(dPhidX(1:Ncel,3)),' < dPhi/dZ < ',maxval(dPhidX(1:Ncel,3))
endif
call watch_leave('GradientPhiLeastSquares')
if( Debug > 3 ) write(IOdef,*)'=== GradientPhiLeastSquares'
end subroutine GradientPhiLeastSquares
subroutine GradientPhiLeastSquaresN(ivar,Phi,dPhidX)
!========================================================================
use constants
use geometry
use variables
real, dimension(Ncel+Nbnd) :: Phi
real, dimension(Ncel+Nbnd,3) :: dPhidX
real, dimension(3) :: GradPhi, Xf, Xac, Xp, dX, ds
real, dimension(3,3) :: A
real, dimension(3) :: RHS_A
integer, dimension(3):: IPIV ! LAPACK
if( Debug > 1 ) write(IOdef,*)'*** GradientPhiLeastSquaresN ',Variable(ivar)
dPhidXo = 0.0
!
! iterative calculation of gradients
!
do igrad=1,Ngradient
write(IOdef,*)'loop ',igrad
dPhidX = 0.0
do ip=1,Ncel
Xp = Cell(ip)%x
A = 0.0
RHS_A = 0.0
do j=1,Nfaces(ip)
k = CFace(ip,j)
ipp = Face(k)%cell1
ipn = Face(k)%cell2
if( ipn > 0 )then
facn = Face(k)%lambda
facp = 1.0 - facn
Xac = Cell(ipn)%x * facn + Cell(ipp)%x * facp
Xf = Face(k)%x
Phiac = Phi(ipn) * facn + Phi(ipp) * facp
GradPhi = dPhidXo(ipn,:) * facn + dPhidXo(ipp,:) * facp
delta = dot_product( GradPhi , Xf - Xac ) ! correction
PhiFace = Phiac + delta
!PhiFace = 0.5*( Phi(ipp) + Phi(ipn) + &
!dot_product( dPhidXo(ipp,:) , Xf - Cell(ipp)%x ) + &
!dot_product( dPhidXo(ipn,:) , Xf - Cell(ipn)%x ) )
if( ipp == ip )then
dPhi = PhiFace - Phi(ipp)
dX = Xf - Cell(ipp)%x
else
dPhi = Phi(ipp) - PhiFace
dX = Cell(ipp)%x - Xf
endif
A(1,1) = A(1,1) + dX(1)*dX(1)
A(2,1) = A(2,1) + dX(1)*dX(2)
A(3,1) = A(3,1) + dX(1)*dX(3)
A(1,2) = A(2,1)
A(2,2) = A(2,2) + dX(2)*dX(2)
A(3,2) = A(3,2) + dX(2)*dX(3)
A(1,3) = A(3,1)
A(2,3) = A(3,2)
A(3,3) = A(3,3) + dX(3)*dX(3)
RHS_A(1) = RHS_A(1) + dX(1)*dPhi
RHS_A(2) = RHS_A(2) + dX(2)*dPhi
RHS_A(3) = RHS_A(3) + dX(3)*dPhi
else
! boundary face
ib = Face(k)%bnd
ir = Bnd(ib)%rid
it = Reg(ir)%typ
dPhi = Phi(Ncel+ib) - Phi(ipp)
dX = Face(k)%x - Cell(ipp)%x
A(1,1) = A(1,1) + dX(1)*dX(1)
A(2,1) = A(2,1) + dX(1)*dX(2)
A(3,1) = A(3,1) + dX(1)*dX(3)
A(1,2) = A(2,1)
A(2,2) = A(2,2) + dX(2)*dX(2)
A(3,2) = A(3,2) + dX(2)*dX(3)
A(1,3) = A(3,1)
A(2,3) = A(3,2)
A(3,3) = A(3,3) + dX(3)*dX(3)
RHS_A(1) = RHS_A(1) + dX(1)*dPhi
RHS_A(2) = RHS_A(2) + dX(2)*dPhi
RHS_A(3) = RHS_A(3) + dX(3)*dPhi
endif
end do
if( UseLapack )then
call SGESV( 3, 1, A, 3, IPIV, RHS_A, 3, INFO )
if( info /= 0 ) write(IOdef,*)'Lapack (sgesv) info(1):',INFO
GradPhi(1) = RHS_A(1)
GradPhi(2) = RHS_A(2)
GradPhi(3) = RHS_A(3)
dPhidX(ip,:) = GradPhi
else
call A33xB3(A,RHS_A)
GradPhi(1) = RHS_A(1)
GradPhi(2) = RHS_A(2)
GradPhi(3) = RHS_A(3)
dPhidX(ip,:) = GradPhi
endif
end do ! cell loop
dPhidXo = dPhidX
!dPhidXo = dPhidXo + 0.75*( dPhidX - dPhidXo) ! under relaxation
if( Debug > 2 )then
write(IOdef,'(1x,1pe10.3,A,e10.3)') &
minval(dPhidX(1:Ncel,1)),' < dPhi/dX < ',maxval(dPhidX(1:Ncel,1))
write(IOdef,'(1x,1pe10.3,A,e10.3)') &
minval(dPhidX(1:Ncel,2)),' < dPhi/dY < ',maxval(dPhidX(1:Ncel,2))
write(IOdef,'(1x,1pe10.3,A,e10.3)') &
minval(dPhidX(1:Ncel,3)),' < dPhi/dZ < ',maxval(dPhidX(1:Ncel,3))
endif
end do ! gradient loop
if( Debug > 3 ) write(IOdef,*)'=== GradientPhiLeastSquaresN'
end subroutine GradientPhiLeastSquaresN
!========================================================================
!========================================================================
!
! S L O P E L I M I T E R S
!
!========================================================================
!========================================================================
subroutine GradientPhiLimiterBarthJespersen(ivar,limiter,Phi,dPhidX)
!========================================================================
!
! AIAA-89-0366, The design and application of upwind schemes
! on unstructured meshes, T.J.Barth, D.C.Jespersen, 1989
!
! Basically: test the calculated gradient against the original
! neighbor values.
!
! Three different approaches are possible:
! 1) Test the gradient in the cell centre against the values
! in the neighboring centroids
! 2) Project the value of the neighbor on to the face center and
! use that value
! 3) Same as 2) but using the nodes instead of the face centres.
!
! Approach 1) damps the gradient, 2) tends to overshoot and
! 3) is somewere in the middle. Because 3) uses the nodes it
! is NOT suited for '2D' cases as the 'model thickness' enters
! the test.
!
use constants
use geometry
use variables
use watches
real, dimension(Ncel+Nbnd), intent(IN) :: Phi
real, dimension(Ncel+Nbnd,3), intent(OUT) :: dPhidX
integer, intent(IN) :: ivar
real, dimension(3) :: dS, xpn
write(IOdbg,*) 'BarthJespersen: ',variable(ivar)
call watch_enter('BarthJespersen')
do ip=1,Ncel
phimax = Phi(ip)
phimin = Phi(ip)
do j=1,Nfaces(ip)
k = CFace(ip,j)
ipp = Face(k)%cell1
ipn = Face(k)%cell2
if( ipn > 0 )then
if( ipp == ip )then
phimax = max(phimax,Phi(ipn))
phimin = min(phimin,Phi(ipn))
else
phimax = max(phimax,Phi(ipp))
phimin = min(phimin,Phi(ipp))
endif
else
ib = Face(k)%bnd
phimax = max(phimax,Phi(Ncel+ib))
phimin = min(phimin,Phi(Ncel+ib))
endif
end do
deltamax = phimax - Phi(ip)
deltamin = phimin - Phi(ip)
alpha = 1.0
ds = 0.0
xpn = 0.0
if( limiter == SlopeLimiterBJN )then
!
! node based
!
do j=1,NItemsFromList(iNodes,ip)
iv = ItemFromList(iNodes,ip,j)
ds = Vert(iv,:) - Cell(ip)%x
delta_face = dot_product( dPhidX(ip,:) , ds )
if( abs(delta_face) < 1.e-6 )then
r = 1.0
else if( delta_face > 0.0 )then
r = deltamax/delta_face
else
r = deltamin/delta_face
endif
alpha = min( alpha , r )
end do
else
!
! face or centroid based
!
do j=1,Nfaces(ip)
k = CFace(ip,j)
if( limiter == SlopeLimiterBJF )then
ds = Face(k)%x - Cell(ip)%x
delta_face = dot_product( dPhidX(ip,:) , ds )
else if( limiter == SlopeLimiterBJC )then
ipp = Face(k)%cell1
ipn = Face(k)%cell2
if( ipn > 0 )then
if( ipp == ip )then
xpn = Cell(ipn)%x - Cell(ipp)%x
else
xpn = Cell(ipp)%x - Cell(ipn)%x
endif
else
xpn = Face(k)%x - Cell(ip)%x
endif
delta_face = dot_product( dPhidX(ip,:) , xpn )
else
write(IOdef,*)'+++ internal error: BJ limiter = ',limiter
delta_face = 0.0
endif
if( abs(delta_face) < 1.e-6 )then
r = 1.0
else if( delta_face > 0.0 )then
r = deltamax/delta_face
else
r = deltamin/delta_face
endif
alpha = min( alpha , r )
end do
endif
dPhidX(ip,:) = alpha*dPhidX(ip,:)
!if( allocated(DXdebug) .and. iVar == VarT ) DXdebug(ip) = alpha
end do
!if( allocated(DXgrad) .and. iVar == VarT ) DXgrad = dPhidX
!if( allocated(DXdebug) .and. iVar == VarT ) &
! write(*,*) minval(DXdebug(1:Ncel)),' < alpha < ',maxval(DXdebug(1:Ncel))
call watch_leave('BarthJespersen')
end subroutine GradientPhiLimiterBarthJespersen
subroutine GradientPhiLimiterVenkatarishnan(ivar,limiter,Phi,dPhidX)
!========================================================================
!
! AIAA-93-0880, On the accuracy of limiters and convergence
! to steady state solutions, V.Venkatakrishnan, 1993
!
! Basically: test the calculated gradient against the original
! neighbor values as with Barth and Jespersen. However BJ uses
! the min-function Venkatarishnan introduces instead of min(1,y):
!
! phi(y) = (y**2+2*y)/(y**2+y+2)
!
! Again three different approaches are possible:
! 1) Test the gradient in the cell centre against the values
! in the neighboring centroids
! 2) Project the value of the neighbor on to the face center and
! use that value
! 3) Same as 2) but using the nodes instead of the face centres.
!
! Approach 1) damps the gradient, 2) tends to overshoot and
! 3) is somewere in the middle. Because 3) uses the nodes it
! is NOT suited for '2D' cases as the 'model thickness' enters
! the test.
!
use constants
use geometry
use variables
use watches
real, dimension(Ncel+Nbnd), intent(IN) :: Phi
real, dimension(Ncel+Nbnd,3), intent(OUT) :: dPhidX
integer, intent(IN) :: ivar
real, dimension(3) :: dS, xpn
write(IOdbg,*) 'Venkatarishnan: ',variable(ivar)
call watch_enter('Venkatarishnan')
alphamin = Large
do ip=1,Ncel
phimax = Phi(ip)
phimin = Phi(ip)
do j=1,Nfaces(ip)
k = CFace(ip,j)
ipp = Face(k)%cell1
ipn = Face(k)%cell2
if( ipn > 0 )then
if( ipp == ip )then
phimax = max(phimax,Phi(ipn))
phimin = min(phimin,Phi(ipn))
else
phimax = max(phimax,Phi(ipp))
phimin = min(phimin,Phi(ipp))
endif
else
ib = Face(k)%bnd
phimax = max(phimax,Phi(Ncel+ib))
phimin = min(phimin,Phi(Ncel+ib))
endif
end do
deltamax = phimax - Phi(ip)
deltamin = phimin - Phi(ip)
alpha = 1.0
ds = 0.0
xpn = 0.0
if( limiter == SlopeLimiterVNN )then
!
! node based
!
do j=1,NItemsFromList(iNodes,ip)
iv = ItemFromList(iNodes,ip,j)
ds = Vert(iv,:) - Cell(ip)%x
delta_face = dot_product( dPhidX(ip,:) , ds )
if( abs(delta_face) < 1.e-6 )then
r = 1000.0
else if( delta_face > 0.0 )then
r = deltamax/delta_face
else
r = deltamin/delta_face
endif
alpha = min( alpha , (r**2+2.0*r)/(r**2+r+2.0) )
end do
else
!
! face or centroid based
!
do j=1,Nfaces(ip)
k = CFace(ip,j)
if( limiter == SlopeLimiterVNF )then
ds = Face(k)%x - Cell(ip)%x
delta_face = dot_product( dPhidX(ip,:) , ds )
else if( limiter == SlopeLimiterVNC )then
ipp = Face(k)%cell1
ipn = Face(k)%cell2
if( ipn > 0 )then
if( ipp == ip )then
xpn = Cell(ipn)%x - Cell(ipp)%x
else
xpn = Cell(ipp)%x - Cell(ipn)%x
endif
else
xpn = Face(k)%x - Cell(ip)%x
endif
delta_face = dot_product( dPhidX(ip,:) , xpn )
else
write(IOdef,*)'+++ internal error: VN limiter = ',limiter
delta_face = 0.0
endif
if( abs(delta_face) < 1.e-6 )then
r = 1000.0
else if( delta_face > 0.0 )then
r = deltamax/delta_face
else
r = deltamin/delta_face
endif
alpha = min( alpha , (r**2+2.0*r)/(r**2+r+2.0) )
end do
endif
dPhidX(ip,:) = alpha*dPhidX(ip,:)
if( allocated(DXdebug) .and. iVar == VarT ) DXdebug(ip) = alpha
alphamin = min(alphamin,alpha)
end do
if( allocated(DXgrad) .and. iVar == VarT ) DXgrad = dPhidX
!if( allocated(DXdebug) .and. iVar == VarT ) &
! write(*,*) minval(DXdebug(1:Ncel)),' < alpha < ',maxval(DXdebug(1:Ncel))
call watch_leave('Venkatarishnan')
end subroutine GradientPhiLimiterVenkatarishnan
subroutine GradientPhiLimiterAlbada(ivar,limiter,Phi,dPhidX)
!========================================================================
!
! AIAA-93-0880, On the accuracy of limiters and convergence
! to steady state solutions, V.Venkatakrishnan, 1993
!
! Basically: test the calculated gradient against the original
! neighbor values as with Barth and Jespersen. Instead of
! BJ min(1,y) use van Albada's:
!
! phi(y) = (y**2+y)/(y**2+1)
!
! Again three different approaches are possible:
! 1) Test the gradient in the cell centre against the values
! in the neighboring centroids
! 2) Project the value of the neighbor on to the face center and
! use that value
! 3) Same as 2) but using the nodes instead of the face centres.
!
! Approach 1) damps the gradient, 2) tends to overshoot and
! 3) is somewere in the middle. Because 3) uses the nodes it
! is NOT suited for '2D' cases as the 'model thickness' enters
! the test.
!
use constants
use geometry
use variables
use watches
real, dimension(Ncel+Nbnd), intent(IN) :: Phi
real, dimension(Ncel+Nbnd,3), intent(OUT) :: dPhidX
integer, intent(IN) :: ivar
real, dimension(3) :: dS, xpn
write(IOdbg,*) 'Albada: ',variable(ivar)
call watch_enter('Albada')
alphamin = Large
do ip=1,Ncel
phimax = Phi(ip)
phimin = Phi(ip)
do j=1,Nfaces(ip)
k = CFace(ip,j)
ipp = Face(k)%cell1
ipn = Face(k)%cell2
if( ipn > 0 )then
if( ipp == ip )then
phimax = max(phimax,Phi(ipn))
phimin = min(phimin,Phi(ipn))
else
phimax = max(phimax,Phi(ipp))
phimin = min(phimin,Phi(ipp))
endif
else
ib = Face(k)%bnd
phimax = max(phimax,Phi(Ncel+ib))
phimin = min(phimin,Phi(Ncel+ib))
endif
end do
deltamax = phimax - Phi(ip)
deltamin = phimin - Phi(ip)
alpha = 1.0
ds = 0.0
xpn = 0.0
if( limiter == SlopeLimiterVAN )then
!
! node based
!
do j=1,NItemsFromList(iNodes,ip)
iv = ItemFromList(iNodes,ip,j)
ds = Vert(iv,:) - Cell(ip)%x
delta_face = dot_product( dPhidX(ip,:) , ds )
if( abs(delta_face) < 1.e-6 )then
r = 1.0
else if( delta_face > 0.0 )then
r = deltamax/delta_face
else
r = deltamin/delta_face
endif
alpha = min( alpha , (r**2+r)/(r**2+1.0) )
end do
else
!
! face or centroid based
!
do j=1,Nfaces(ip)
k = CFace(ip,j)
if( limiter == SlopeLimiterVAF )then
ds = Face(k)%x - Cell(ip)%x
delta_face = dot_product( dPhidX(ip,:) , ds )
else if( limiter == SlopeLimiterVAC )then
ipp = Face(k)%cell1
ipn = Face(k)%cell2
if( ipn > 0 )then
if( ipp == ip )then
xpn = Cell(ipn)%x - Cell(ipp)%x
else
xpn = Cell(ipp)%x - Cell(ipn)%x
endif
else
xpn = Face(k)%x - Cell(ip)%x
endif
delta_face = dot_product( dPhidX(ip,:) , xpn )
else
write(IOdef,*)'+++ internal error: vA limiter = ',limiter
delta_face = 0.0
endif
if( abs(delta_face) < 1.e-6 )then
r = 1.0
else if( delta_face > 0.0 )then
r = deltamax/delta_face
else
r = deltamin/delta_face
endif
alpha = min( alpha , (r**2+r)/(r**2+1.0) )
end do
endif
dPhidX(ip,:) = alpha*dPhidX(ip,:)
if( allocated(DXdebug) .and. iVar == VarT ) DXdebug(ip) = alpha
alphamin = min(alphamin,alpha)
end do
if( allocated(DXgrad) .and. iVar == VarT ) DXgrad = dPhidX
!if( allocated(DXdebug) .and. iVar == VarT ) &
! write(*,*) minval(DXdebug(1:Ncel)),' < alpha < ',maxval(DXdebug(1:Ncel))
call watch_leave('Albada')
end subroutine GradientPhiLimiterAlbada
subroutine GradientPhiLimiterPolynomial(ivar,limiter,Phi,dPhidX)
!========================================================================
!
! K.Michalak, C. Ollivier-Gooch
! Limiters for UnstructuredHigher-Order Accurate
! Solutions of the Euler Equations
!
! cubic polynomial: f(y)= A3 y**3 + A2 * y**2 + A1 * y + A0
!
! target: y=0, f(y)=0 => A0 = 0
! df(y=0)/dy=1 => A1 = 1
!
! switch at point Yc where f(Yc)=1, df(y=Yc)/dy=0
!
! Again three different approaches are possible:
! 1) Test the gradient in the cell centre against the values
! in the neighboring centroids
! 2) Project the value of the neighbor on to the face center and
! use that value
! 3) Same as 2) but using the nodes instead of the face centres.
!
! Approach 1) damps the gradient, 2) tends to overshoot and
! 3) is somewere in the middle. Because 3) uses the nodes it
! is NOT suited for '2D' cases as the 'model thickness' enters
! the test.
!
use constants
use geometry
use variables
use watches
real, dimension(Ncel+Nbnd), intent(IN) :: Phi
real, dimension(Ncel+Nbnd,3), intent(OUT) :: dPhidX
integer, intent(IN) :: ivar
real, dimension(3) :: dS, xpn
write(IOdbg,*) 'Polynomial1: ',variable(ivar)
call watch_enter('Polynomial1')
Xc = 1.5
A3 = (Xc-2)/(Xc**3)
A2 = -1.0*(1.0+3.0*A3*Xc**2)/(2.0*Xc)
alphamin = Large
do ip=1,Ncel
phimax = Phi(ip)
phimin = Phi(ip)
do j=1,Nfaces(ip)
k = CFace(ip,j)
ipp = Face(k)%cell1
ipn = Face(k)%cell2
if( ipn > 0 )then
if( ipp == ip )then
phimax = max(phimax,Phi(ipn))
phimin = min(phimin,Phi(ipn))
else
phimax = max(phimax,Phi(ipp))
phimin = min(phimin,Phi(ipp))
endif
else
ib = Face(k)%bnd
phimax = max(phimax,Phi(Ncel+ib))
phimin = min(phimin,Phi(Ncel+ib))
endif
end do
deltamax = phimax - Phi(ip)
deltamin = phimin - Phi(ip)
alpha = 1.0
ds = 0.0
xpn = 0.0
if( limiter == SlopeLimiterP1N )then
!
! node based
!
do j=1,NItemsFromList(iNodes,ip)
iv = ItemFromList(iNodes,ip,j)
ds = Vert(iv,:) - Cell(ip)%x
delta_face = dot_product( dPhidX(ip,:) , ds )
if( abs(delta_face) < 1.e-6 )then
r = 100.0
else if( delta_face > 0.0 )then
r = deltamax/delta_face
else
r = deltamin/delta_face
endif
if( r >= Xc )then
alpha = min( alpha , 1.0 )
else
alpha = min( alpha , A3*r**3+A2*r**2+r )
endif
end do
else
!
! face or centroid based
!
do j=1,Nfaces(ip)
k = CFace(ip,j)
if( limiter == SlopeLimiterP1F )then
ds = Face(k)%x - Cell(ip)%x
delta_face = dot_product( dPhidX(ip,:) , ds )
else if( limiter == SlopeLimiterP1C )then
ipp = Face(k)%cell1
ipn = Face(k)%cell2
if( ipn > 0 )then
if( ipp == ip )then
xpn = Cell(ipn)%x - Cell(ipp)%x
else
xpn = Cell(ipp)%x - Cell(ipn)%x
endif
else
xpn = Face(k)%x - Cell(ip)%x
endif
delta_face = dot_product( dPhidX(ip,:) , xpn )
else
write(IOdef,*)'+++ internal error: P1 limiter = ',limiter
delta_face = 0.0
endif
if( abs(delta_face) < 1.e-6 )then
r = 100.0
else if( delta_face > 0.0 )then
r = deltamax/delta_face
else
r = deltamin/delta_face
endif
if( r >= Xc )then
alpha = min( alpha , 1.0 )
else
alpha = min( alpha , A3*r**3+A2*r**2+r )
endif
end do
endif
dPhidX(ip,:) = alpha*dPhidX(ip,:)
if( allocated(DXdebug) .and. iVar == VarT ) DXdebug(ip) = alpha
alphamin = min(alphamin,alpha)
end do
if( allocated(DXgrad) .and. iVar == VarT ) DXgrad = dPhidX
!if( allocated(DXdebug) .and. iVar == VarT ) &
! write(*,*) minval(DXdebug(1:Ncel)),' < alpha < ',maxval(DXdebug(1:Ncel))
call watch_leave('Polynomial1')
end subroutine GradientPhiLimiterPolynomial
| src/gradients.f90 |
#include "eiscor.h"
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! ZUFCHF (Zomplex Unitary hessenberg Factored CHeck Factorization)
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! This routine checks the factorization input into ZUFFQR to make sure
! is represents a unitary hessenberg matrix to machine precision.
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! INPUT VARIABLES:
!
! N INTEGER
! dimension of matrix
!
! Q REAL(8) array of dimension (3*(N-1))
! array of generators for givens rotations
!
! D REAL(8) array of dimension (2*N)
! array of generators for complex diagonal matrix
! on output contains the eigenvalues
!
! OUTPUT VARIABLES:
!
! INFO INTEGER
! INFO = 0 implies valid factorization
! INFO = -1 implies N is invalid
! INFO = -2 implies Q is invalid
! INFO = -3 implies D is invalid
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine ZUFCHF(N,Q,D,INFO)
implicit none
! input variables
integer, intent(in) :: N
real(8), intent(inout) :: Q(3*N-3), D(2*N)
integer, intent(inout) :: INFO
! compute variables
integer :: ii
real(8),parameter :: tol = 10d0*epsilon(1d0)
real(8) :: nrm
! initialize INFO
INFO = 0
! check N
call IARNAN(N,INFO)
if (INFO.NE.0) then
! print error in debug mode
if (DEBUG) then
call UARERR(__FILE__,__LINE__,"N is invalid",INFO,INFO)
end if
INFO = -1
return
end if
call IARINF(N,INFO)
if (INFO.NE.0) then
! print error in debug mode
if (DEBUG) then
call UARERR(__FILE__,__LINE__,"N is invalid",INFO,INFO)
end if
INFO = -1
return
end if
if (N < 2) then
INFO = -1
! print error in debug mode
if (DEBUG) then
call UARERR(__FILE__,__LINE__,"N must be at least 2",INFO,INFO)
end if
return
end if
! check Q for NANs and INFs
call DARACH1(3*(N-1),Q,INFO)
if (INFO.NE.0) then
! print error in debug mode
if (DEBUG) then
call UARERR(__FILE__,__LINE__,"Q is invalid",INFO,INFO)
end if
INFO = -2
return
end if
! check Q for orthogonality
do ii=1,(N-1)
nrm = sqrt(Q(3*ii-2)**2 + Q(3*ii-1)**2 + Q(3*ii)**2)
if (abs(nrm-1d0) > tol) then
INFO = -2
! print error in debug mode
if (DEBUG) then
call UARERR(__FILE__,__LINE__,"Q is not unitary",INFO,INFO)
end if
return
end if
end do
! check D
call DARACH1(2*N,D,INFO)
if (INFO.NE.0) then
! print error in debug mode
if (DEBUG) then
call UARERR(__FILE__,__LINE__,"D is invalid",INFO,INFO)
end if
INFO = -3
return
end if
! check D for orthogonality
do ii=1,N
nrm = sqrt(D(2*ii-1)**2 + D(2*ii)**2)
if (abs(nrm-1d0) > tol) then
INFO = -3
! print error in debug mode
if (DEBUG) then
call UARERR(__FILE__,__LINE__,"D is not unitary",INFO,INFO)
end if
return
end if
end do
end subroutine ZUFCHF
| deps/eiscor-master/src/complex_double/ZUFCHF.f90 |
! { dg-do run }
! { dg-additional-sources global_vars_f90_init_driver.c }
module global_vars_f90_init
use, intrinsic :: iso_c_binding, only: c_int
implicit none
integer(c_int), bind(c, name='i') :: I = 2
contains
subroutine test_globals() bind(c)
! the value of I is initialized above
if(I .ne. 2) then
STOP 1
endif
end subroutine test_globals
end module global_vars_f90_init
| validation_tests/llvm/f18/gfortran.dg/global_vars_f90_init.f90 |
MODULE compfn_I
INTERFACE
!...Generated by Pacific-Sierra Research 77to90 4.4G 12:18:48 03/10/06
SUBROUTINE compfn (XPARAM, INT, ESCF, FULSCF, GRAD, LGRAD, W, H, HQ, WJ&
, WK)
USE vast_kind_param,ONLY: DOUBLE
REAL(DOUBLE), DIMENSION(*), INTENT(IN) :: XPARAM
LOGICAL, INTENT(IN) :: INT
REAL(DOUBLE), INTENT(INOUT) :: ESCF
LOGICAL :: FULSCF
REAL(DOUBLE), DIMENSION(*), INTENT(IN) :: GRAD
LOGICAL, INTENT(IN) :: LGRAD
REAL(DOUBLE), DIMENSION(*) :: W, H, HQ, WJ, WK
END SUBROUTINE
END INTERFACE
END MODULE
| 2006_MOPAC7.1/src_interfaces/compfn_I.f90 |
program test_products
use mod_orrb
implicit none
character(len=*), parameter :: fmt="(A40, 'Time: ',ES8.2,', error: ',ES8.2, ', ', A10)"
character(len=40) :: test_name
real(kind=dp) :: t0, t1
integer(kind=int32) :: ma, na, lbwb, ubwb
type(error_info) :: error
real(kind=dp), parameter :: tol=1e-15, c=7.0
!
real(kind=dp), dimension(:,:), allocatable :: b_d, a_d, c0_d, c1_d
complex(kind=dp), dimension(:,:), allocatable :: b_z, a_z, c0_z, c1_z
type(d_ub), allocatable :: ub_d
type(d_bv), allocatable :: bv_d
type(d_wb), allocatable :: wb_d
type(d_bt), allocatable :: bt_d
type(d_ubt), allocatable :: ubt_d
type(d_wbv), allocatable :: wbv_d
type(z_ub), allocatable :: ub_z
type(z_bv), allocatable :: bv_z
type(z_wb), allocatable :: wb_z
type(z_bt), allocatable :: bt_z
type(z_ubt), allocatable :: ubt_z
type(z_wbv), allocatable :: wbv_z
call initialize_errors
print *
print *, "--------------------------------"
print *
print *, "Tests of Real Products"
print *
ma=40; na=10; lbwb=5; ubwb=7
a_d=d_random_matrix(ma,na)
ub_d=d_random_ub(ma,lbwb,ubwb,error=error)
b_d = general(ub_d,error)
call cpu_time(t0)
c0_d=d_product_of_ub_and_general(ub_d,a_d,error)
call cpu_time(t1)
c1_d=matmul(b_d,a_d)
test_name = "Real UB Times Gen. (40x10)"
call d_output_result(test_name,c0_d,c1_d,t0,t1,c*tol,error)
ma=40; na=10; lbwb=5; ubwb=7
a_d=d_random_matrix(ma,na)
bv_d=d_random_bv(ma,lbwb,ubwb,error=error)
b_d = general(bv_d,error)
call cpu_time(t0)
c0_d=d_product_of_bv_and_general(bv_d,a_d,error)
call cpu_time(t1)
c1_d=matmul(b_d,a_d)
test_name = "Real BV Times Gen. (40x10)"
call d_output_result(test_name,c0_d,c1_d,t0,t1,c*tol,error)
ma=40; na=10; lbwb=5; ubwb=7
a_d=d_random_matrix(ma,na)
wb_d=d_random_wb(ma,lbwb,ubwb,error=error)
b_d = general(wb_d,error)
call cpu_time(t0)
c0_d=d_product_of_wb_and_general(wb_d,a_d,error)
call cpu_time(t1)
c1_d=matmul(b_d,a_d)
test_name = "Real WB Times Gen. (40x10)"
call d_output_result(test_name,c0_d,c1_d,t0,t1,c*tol,error)
ma=40; na=10; lbwb=5; ubwb=7
a_d=d_random_matrix(ma,na)
bt_d=d_random_bt(ma,lbwb,ubwb,error=error)
b_d = general(bt_d,error)
call cpu_time(t0)
c0_d=d_product_of_bt_and_general(bt_d,a_d,error)
call cpu_time(t1)
c1_d=matmul(b_d,a_d)
test_name = "Real BT Times Gen. (40x10)"
call d_output_result(test_name,c0_d,c1_d,t0,t1,c*tol,error)
ma=40; na=10; lbwb=5; ubwb=7
a_d=d_random_matrix(ma,na)
ubt_d=d_random_ubt(ma,lbwb,ubwb,error=error)
b_d = general(ubt_d,error)
call cpu_time(t0)
c0_d=d_product_of_ubt_and_general(ubt_d,a_d,error)
call cpu_time(t1)
c1_d=matmul(b_d,a_d)
test_name = "Real UBT Times Gen. (40x10)"
call d_output_result(test_name,c0_d,c1_d,t0,t1,c*tol,error)
ma=40; na=10; lbwb=5; ubwb=7
a_d=d_random_matrix(ma,na)
wbv_d=d_random_wbv(ma,lbwb,ubwb,error=error)
b_d = general(wbv_d,error)
call cpu_time(t0)
c0_d=d_product_of_wbv_and_general(wbv_d,a_d,error)
call cpu_time(t1)
c1_d=matmul(b_d,a_d)
test_name = "Real WBV Times Gen. (40x10)"
call d_output_result(test_name,c0_d,c1_d,t0,t1,c*tol,error)
ma=10; na=40; lbwb=5; ubwb=7
a_d=d_random_matrix(ma,na)
ub_d=d_random_ub(na,lbwb,ubwb,error=error)
b_d = general(ub_d,error)
call cpu_time(t0)
c0_d=d_product_of_general_and_ub(a_d, ub_d,error)
call cpu_time(t1)
c1_d=matmul(a_d,b_d)
test_name = "Real Gen. Times UB. (10x40)"
call d_output_result(test_name,c0_d,c1_d,t0,t1,c*tol,error)
print *
print *, "--------------------------------"
print *
print *, "Tests of Complex Products"
print *
ma=40; na=10; lbwb=5; ubwb=7
a_z=z_random_matrix(ma,na)
ub_z=z_random_ub(ma,lbwb,ubwb,error=error)
b_z = general(ub_z,error)
call cpu_time(t0)
c0_z=z_product_of_ub_and_general(ub_z,a_z,error)
call cpu_time(t1)
c1_z=matmul(b_z,a_z)
test_name = "Complex UB Times Gen. (40x10)"
call z_output_result(test_name,c0_z,c1_z,t0,t1,c*tol,error)
ma=40; na=10; lbwb=5; ubwb=7
a_z=z_random_matrix(ma,na)
bv_z=z_random_bv(ma,lbwb,ubwb,error=error)
b_z = general(bv_z,error)
call cpu_time(t0)
c0_z=z_product_of_bv_and_general(bv_z,a_z,error)
call cpu_time(t1)
c1_z=matmul(b_z,a_z)
test_name = "Complex BV Times Gen. (40x10)"
call z_output_result(test_name,c0_z,c1_z,t0,t1,c*tol,error)
ma=40; na=10; lbwb=5; ubwb=7
a_z=z_random_matrix(ma,na)
wb_z=z_random_wb(ma,lbwb,ubwb,error=error)
b_z = general(wb_z,error)
call cpu_time(t0)
c0_z=z_product_of_wb_and_general(wb_z,a_z,error)
call cpu_time(t1)
c1_z=matmul(b_z,a_z)
test_name = "Complex WB Times Gen. (40x10)"
call z_output_result(test_name,c0_z,c1_z,t0,t1,c*tol,error)
ma=40; na=10; lbwb=5; ubwb=7
a_z=z_random_matrix(ma,na)
bt_z=z_random_bt(ma,lbwb,ubwb,error=error)
b_z = general(bt_z,error)
call cpu_time(t0)
c0_z=z_product_of_bt_and_general(bt_z,a_z,error)
call cpu_time(t1)
c1_z=matmul(b_z,a_z)
test_name = "Complex BT Times Gen. (40x10)"
call z_output_result(test_name,c0_z,c1_z,t0,t1,c*tol,error)
ma=40; na=10; lbwb=5; ubwb=7
a_z=z_random_matrix(ma,na)
ubt_z=z_random_ubt(ma,lbwb,ubwb,error=error)
b_z = general(ubt_z,error)
call cpu_time(t0)
c0_z=z_product_of_ubt_and_general(ubt_z,a_z,error)
call cpu_time(t1)
c1_z=matmul(b_z,a_z)
test_name = "Complex UBT Times Gen. (40x10)"
call z_output_result(test_name,c0_z,c1_z,t0,t1,c*tol,error)
ma=40; na=10; lbwb=5; ubwb=7
a_z=z_random_matrix(ma,na)
wbv_z=z_random_wbv(ma,lbwb,ubwb,error=error)
b_z = general(wbv_z,error)
call cpu_time(t0)
c0_z=z_product_of_wbv_and_general(wbv_z,a_z,error)
call cpu_time(t1)
c1_z=matmul(b_z,a_z)
test_name = "Complex WBV Times Gen. (40x10)"
call z_output_result(test_name,c0_z,c1_z,t0,t1,c*tol,error)
ma=10; na=40; lbwb=5; ubwb=7
a_z=z_random_matrix(ma,na)
ub_z=z_random_ub(na,lbwb,ubwb,error=error)
b_z = general(ub_z,error)
call cpu_time(t0)
c0_z=z_product_of_general_and_ub(a_z, ub_z,error)
call cpu_time(t1)
c1_z=matmul(a_z,b_z)
test_name = "Complex Gen. Times UB. (10x40)"
call z_output_result(test_name,c0_z,c1_z,t0,t1,c*tol,error)
contains
subroutine d_output_result(name,a0,a1,t0,t1,bnd,error)
character(len=*) :: name
real(kind=dp), dimension(:,:) :: a0, a1
real(kind=dp) :: bnd, t0, t1
type(error_info) :: error
real(kind=dp) :: err
character(len=10) :: test_result
if (error%code > 0) then
print *, "Calling error in test: ", name
else
err = maxabs(a1-a0)
if (err < bnd) then
test_result="PASSED"
else
test_result=" FAILED"
end if
write (*,fmt) name, t1-t0, err, test_result
end if
end subroutine d_output_result
subroutine z_output_result(name,a0,a1,t0,t1,bnd,error)
character(len=*) :: name
complex(kind=dp), dimension(:,:) :: a0, a1
real(kind=dp) :: bnd, t0, t1
type(error_info) :: error
real(kind=dp) :: err
character(len=10) :: test_result
if (error%code > 0) then
print *, "Calling error in test: ", name
else
err = maxabs(a1-a0)
if (err < bnd) then
test_result="PASSED"
else
test_result=" FAILED"
end if
write (*,fmt) name, t1-t0, err, test_result
end if
end subroutine z_output_result
end program test_products
| test/test_products.f90 |
SUBROUTINE OUTFSD
IMPLICIT REAL*8 (A-H,O-Z)
REAL*8 NAME
COMMON/ANTENA/ A(10,3),ADOT(10,3),B(10,3),BDOT(10,3),DIN(10,3),
. DINDOT(10,3),DOUT(10,3),DOUTDT(10,3),ZBZ(3,10),
. NELMTS,NDAMPR,MODES(10)
COMMON/IAFSD/DELMAX,DELMIN,KCUT(150),NCUT,NUP
COMMON/IBFSD/HEAD(150,4),NAME(150)
COMMON /ICNTRL/KNTRL(10)
COMMON /JCNTRL/NCNTRL,MCNTRL,MAPCNT(20)
COMMON/IMAIN1/ IDATE,LSAVE,INOPT,IPLOT,NUMEQS,IPLTPE,IORB,ITAPE
COMMON /RMAIN1/DUMMY(5),UPS(150),DNS(150)
COMMON /VARBLS/DEPNDS(150),DERIVS(150)
NEQ=NUMEQS
NELE=NELMTS
NDMPER=NDAMPR
DO 150 I=1,NEQ
150 NCUT=NCUT+KCUT(I)
IF(DELMIN.GT.1.0D7) DELMIN=0.0D0
IF(DELMAX.EQ.0.0) DELMAX=1.0D9
WRITE(6,9998)
9998 FORMAT(1H1,' ******************************* FSD ADAMS-M
*OULTIN INTEGRATOR MESSAGE TABLE ********************
1******')
WRITE(6,10000)NEQ,NELE,NDMPER
WRITE(6,10004) NCUT,NUP,DELMAX,DELMIN
WRITE(6,10001)
LINES=8
WRITE(6,10003)
C
DO 170 I=1,NEQ
WRITE(6,10002) (HEAD(I,N),N=1,4),NAME(I),KCUT(I)
& ,UPS(I),DNS(I),DEPNDS(I),DERIVS(I)
LINES=LINES + 1
IF(LINES.LT.40) GO TO 160
LINES=2
160 IF(MOD(LINES,5).EQ.0) WRITE(6,10003)
170 CONTINUE
C
10000 FORMAT('1',46X,'NUMBER OF EQUATIONS FOR THIS CASE IS ',I3/'0',46X,
. 'NUMBER OF ANTENNA ELEMENTS',I3/'0',46X,
. 'NUMBER OF DAMPER ELEMENTS',I3)
C
10001 FORMAT('0',57X,'INTEGRATION BOUNDS'/' ',53X,'KCUT',6X,
& 'UPPER',12X,'LOWER',8X,'DEPEND',8X,'DERIVE',/)
C
10002 FORMAT(' ',2X,4A8,2X,A8,5X,I5,4(1PE16.6) )
C
10003 FORMAT(1H0)
C
10004 FORMAT('0',46X,'NUMBER OF DELTA T CUT WITHIN THE PHASE',I3,/,
& ' ',46X,'NUMBER OF DELTA T RAISED WITHIN THE PHASE',I3,/,
& ' ',46X,'MAXIMUM DELTA T VALUE WITHIN THE PHASE',1PE13.6
&,/,
& ' ',46X,'MINIMUM DELTA T VALUE WITHIN THE PHASE',1PE13.6
&,/)
C
C
RETURN
END
| gsc-13006/fsd/source/outfsd.for |
! -*- Mode: Fortran; -*-
!
! (C) 2001 by Argonne National Laboratory.
! See COPYRIGHT in top-level directory.
!
program main
implicit none
include 'mpif.h'
! Fortran equivalent of misc.c
! tests various miscellaneous functions.
integer buf(1024), amode, fh, status(MPI_STATUS_SIZE)
logical flag
integer ierr, newtype, i, group
integer etype, filetype, mynod, argc, iargc
integer errs, toterrs
logical verbose
character*7 datarep
character*1024 str ! used to store the filename
integer*8 disp, offset, filesize
errs = 0
verbose = .false.
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, mynod, ierr)
! process 0 takes the file name as a command-line argument and
! broadcasts it to other processes
if (mynod .eq. 0) then
argc = iargc()
i = 0
call getarg(i,str)
do while ((i .lt. argc) .and. (str .ne. '-fname'))
i = i + 1
call getarg(i,str)
end do
if (i .ge. argc) then
print *
print *, '*# Usage: fmisc -fname filename'
print *
call MPI_ABORT(MPI_COMM_WORLD, 1, ierr)
end if
i = i + 1
call getarg(i,str)
call MPI_BCAST(str, 1024, MPI_CHARACTER, 0, &
& MPI_COMM_WORLD, ierr)
else
call MPI_BCAST(str, 1024, MPI_CHARACTER, 0, &
& MPI_COMM_WORLD, ierr)
end if
call MPI_FILE_OPEN(MPI_COMM_WORLD, str, &
& MPI_MODE_CREATE + MPI_MODE_RDWR, MPI_INFO_NULL, fh, ierr)
call MPI_FILE_WRITE(fh, buf, 1024, MPI_INTEGER, status, ierr)
call MPI_FILE_SYNC(fh, ierr)
call MPI_FILE_GET_AMODE(fh, amode, ierr)
if (mynod .eq. 0 .and. verbose) then
print *, ' testing MPI_FILE_GET_AMODE'
end if
if (amode .ne. (MPI_MODE_CREATE + MPI_MODE_RDWR)) then
errs = errs + 1
print *, 'amode is ', amode, ', should be ', MPI_MODE_CREATE &
& + MPI_MODE_RDWR
end if
call MPI_FILE_GET_ATOMICITY(fh, flag, ierr)
if (flag) then
errs = errs + 1
print *, 'atomicity is ', flag, ', should be .FALSE.'
end if
if (mynod .eq. 0 .and. verbose) then
print *, ' setting atomic mode'
end if
call MPI_FILE_SET_ATOMICITY(fh, .TRUE., ierr)
call MPI_FILE_GET_ATOMICITY(fh, flag, ierr)
if (.not. flag) then
errs = errs + 1
print *, 'atomicity is ', flag, ', should be .TRUE.'
end if
call MPI_FILE_SET_ATOMICITY(fh, .FALSE., ierr)
if (mynod .eq. 0 .and. verbose) then
print *, ' reverting back to nonatomic mode'
end if
call MPI_TYPE_VECTOR(10, 10, 20, MPI_INTEGER, newtype, ierr)
call MPI_TYPE_COMMIT(newtype, ierr)
disp = 1000
call MPI_FILE_SET_VIEW(fh, disp, MPI_INTEGER, newtype, 'native', &
& MPI_INFO_NULL, ierr)
if (mynod .eq. 0 .and. verbose) then
print *, ' testing MPI_FILE_GET_VIEW'
end if
disp = 0
call MPI_FILE_GET_VIEW(fh, disp, etype, filetype, datarep, ierr)
if ((disp .ne. 1000) .or. (datarep .ne. 'native')) then
errs = errs + 1
print *, 'disp = ', disp, ', datarep = ', datarep, &
& ', should be 1000, native'
end if
if (mynod .eq. 0 .and. verbose) then
print *, ' testing MPI_FILE_GET_BYTE_OFFSET'
end if
offset = 10
call MPI_FILE_GET_BYTE_OFFSET(fh, offset, disp, ierr)
if (disp .ne. 1080) then
errs = errs + 1
print *, 'byte offset = ', disp, ', should be 1080'
end if
call MPI_FILE_GET_GROUP(fh, group, ierr)
if (mynod .eq. 0 .and. verbose) then
print *, ' setting file size to 1060 bytes'
end if
filesize = 1060
call MPI_FILE_SET_SIZE(fh, filesize, ierr)
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
call MPI_FILE_SYNC(fh, ierr)
filesize = 0
call MPI_FILE_GET_SIZE(fh, filesize, ierr)
if (filesize .ne. 1060) then
errs = errs + 1
print *, 'file size = ', filesize, ', should be 1060'
end if
if (mynod .eq. 0 .and. verbose) then
print *, ' seeking to eof and testing MPI_FILE_GET_POSITION'
end if
offset = 0
call MPI_FILE_SEEK(fh, offset, MPI_SEEK_END, ierr)
call MPI_FILE_GET_POSITION(fh, offset, ierr)
if (offset .ne. 10) then
errs = errs + 1
print *, 'file pointer posn = ', offset, ', should be 10'
end if
if (mynod .eq. 0 .and. verbose) then
print *, ' testing MPI_FILE_GET_BYTE_OFFSET'
end if
call MPI_FILE_GET_BYTE_OFFSET(fh, offset, disp, ierr)
if (disp .ne. 1080) then
errs = errs + 1
print *, 'byte offset = ', disp, ', should be 1080'
end if
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
if (mynod .eq. 0 .and. verbose) then
print *, ' testing MPI_FILE_SEEK with MPI_SEEK_CUR'
end if
offset = -10
call MPI_FILE_SEEK(fh, offset, MPI_SEEK_CUR, ierr)
call MPI_FILE_GET_POSITION(fh, offset, ierr)
call MPI_FILE_GET_BYTE_OFFSET(fh, offset, disp, ierr)
if (disp .ne. 1000) then
errs = errs + 1
print *, 'file pointer posn in bytes = ', disp, &
& ', should be 1000'
end if
if (mynod .eq. 0 .and. verbose) then
print *, ' preallocating disk space up to 8192 bytes'
end if
filesize = 8192
call MPI_FILE_PREALLOCATE(fh, filesize, ierr)
if (mynod .eq. 0 .and. verbose) then
print *, ' closing the file and deleting it'
end if
call MPI_FILE_CLOSE(fh, ierr)
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
if (mynod .eq. 0) then
call MPI_FILE_DELETE(str, MPI_INFO_NULL, ierr)
end if
call MPI_Allreduce( errs, toterrs, 1, MPI_INTEGER, MPI_SUM, &
$ MPI_COMM_WORLD, ierr )
if (mynod .eq. 0) then
if( toterrs .gt. 0 ) then
print *, 'Found ', toterrs, ' errors'
else
print *, ' No Errors'
endif
endif
call MPI_TYPE_FREE(newtype, ierr)
call MPI_TYPE_FREE(filetype, ierr)
call MPI_GROUP_FREE(group, ierr)
call MPI_FINALIZE(ierr)
end
| tools/openmpi-4.0.5/ompi/mca/io/romio321/romio/test/fmisc.f |
program foo
real (kind = 8) :: x = 3.141592_8
end program foo
| test/expr/scalar/expr_real_8.f90 |
module numerical
implicit none
contains
elemental logical function isprime(i)
integer, intent(in) :: i
integer :: j
isprime = .false.
!! trivial tests
if (i<=1) return
if (i==2 .or. i==3) then
isprime = .true.
return
endif
if (modulo(i,2) == 0 .or. modulo(i,3) == 0) return
!! 6k+1 test
do j = 5, int(sqrt(real(i))), 6
if (modulo(i,j) == 0 .or. modulo(i,j+2) == 0) return
enddo
isprime = .true.
end function isprime
end module numerical
| numerical.f90 |
great_ne(ff1,c1).
great_ne(t1,y1).
great_ne(u1,bb1).
great_ne(kk1,c1).
great_ne(cc1,aa1).
great_ne(cc1,x1).
great_ne(jj1,bb1).
great_ne(cc1,k1).
great_ne(hh1,b1).
great_ne(dd1,f1).
great_ne(q1,aa1).
great_ne(t1,a1).
great_ne(hh1,ii1).
great_ne(q1,cc1).
great_ne(hh1,k1).
great_ne(z1,c1).
great_ne(k1,y1).
| foldsCreator/files/datasets/alzheimer_anime_noiseless/incremental5/test10.f |
!=============================================================================!
subroutine rhs(rl, vl)
!
! Generates the RHS for the compressible 2D-3C, N-S equations
!
! Written: 5-10-95
! Revised: 6-19-95
!
!=============================================================================!
use global
use local
implicit none
integer :: ij
real :: rl(ndof,nx*ny), vl(ndof,nx*ny)
real :: fact1, fact2, fact3
!=============================================================================!
fact1 = one / Re
fact2 = gamma / ( Pr * Re )
fact3 = gamma * gamma1 * Ma**2 / Re
!$doacross local(ij)
do ij = 1, nx*ny
!.... continuity
rl(1,ij) = rho(ij) * divu(ij) + grho(1,ij) * u1(ij) + &
grho(2,ij) * u2(ij)
!.... momentum
rl(2,ij) = u1(ij) * gu(1,1,ij) + u2(ij) * gu(1,2,ij) + &
rhoinv(ij) * gp(1,ij) - &
fact1 * ( g1lm(ij) * divu(ij) + lm(ij) * g1divu(ij) + &
two * (g1mu(ij) * S(1,1,ij) + g2mu(ij) * S(1,2,ij) + &
mu(ij) * S1jj(ij) ) ) * rhoinv(ij)
rl(3,ij) = u1(ij) * gu(2,1,ij) + u2(ij) * gu(2,2,ij) + &
rhoinv(ij) * gp(2,ij) - &
fact1 * ( g2lm(ij) * divu(ij) + lm(ij) * g2divu(ij) + &
two * (g1mu(ij) * S(2,1,ij) + g2mu(ij) * S(2,2,ij) + &
mu(ij) * S2jj(ij) ) ) * rhoinv(ij)
rl(4,ij) = u1(ij) * gu(3,1,ij) + u2(ij) * gu(3,2,ij) - &
fact1 * ( two * (g1mu(ij) * S(3,1,ij) + &
g2mu(ij) * S(3,2,ij) + &
mu(ij) * S3jj(ij) ) ) * rhoinv(ij)
!.... temperature
rl(5,ij) = u1(ij) * gt(1,ij) + u2(ij) * gt(2,ij) + &
gamma1 * t(ij) * divu(ij) - rhoinv(ij) * ( &
fact2 * ( g1con(ij) * gt(1,ij) + g2con(ij) * gt(2,ij) + &
con(ij) * Lapt(ij) ) + &
fact3 * ( lm(ij) * divu(ij)**2 + two * mu(ij) * ( &
S(1,1,ij)**2 + S(1,2,ij)**2 + S(1,3,ij)**2 + &
S(2,1,ij)**2 + S(2,2,ij)**2 + S(2,3,ij)**2 + &
S(3,1,ij)**2 + S(3,2,ij)**2 ) ) )
end do
!.... correct the outflow boundaries using Lele & Poinsot BC's
! call rhs_l(rl,vl)
!.... standard sponge
if (ispg .gt. 0) then
if (ispg .eq. 1) then
call spg_it(rl,vl,spg)
else if (ispg .eq. 2) then
!$doacross local(ij)
do ij = 1, nx*ny
rl(1,ij) = rl(1,ij) + (spg(ij) + spg2(ij)) * ( vl(1,ij) - one )
rl(2,ij) = rl(2,ij) + (spg(ij) + spg2(ij)) * ( vl(2,ij) )
rl(3,ij) = rl(3,ij) + (spg(ij) + spg2(ij)) * ( vl(3,ij) )
rl(4,ij) = rl(4,ij) + (spg(ij) + spg2(ij)) * ( vl(4,ij) )
rl(5,ij) = rl(5,ij) + (spg(ij) + spg2(ij)) * ( vl(5,ij) - one )
end do
else
call error('rhs_p$','ispg > 2 is not supported$')
end if
end if
!.... explicit smoother
! if (eps_e .ne. zero) call smoother( rl, vl )
return
end
| src/rhs.f90 |
C @(#)getsvc.f 20.3 2/13/96
integer function getsvc (kt, jt, isvc, vk, qk, dvdq, bkk, msw)
C Input parameters:
C
C KT Internal bus number
C JT Index to TBX array
C ISVC Index to SVC array
C VK Actual voltage at bus
C QK Actual reactive injection at bus
C DVDQ Sensitivity dV/dQ at bus
C BKK Total self-admittance at bus
C MSW Solution state:
C 1 = continuous solution
C 2 = transition to discrete solution
C 3 = discrete solution
C Output parameters:
C BKK Total self-admittance at bus
C GETSVC Return state :
C 0 = no change
C 1 = change
C
include 'ipfinc/parametr.inc'
include 'ipfinc/alpha.inc'
c Global variables used:
c qnetu(r*8), ineti(r*8)
include 'ipfinc/alpha2.inc'
c Global variables used:
c kvolt, volt
include 'ipfinc/blank.inc'
c Global variables used:
c bmva
include 'ipfinc/bus.inc'
c Global variables used:
c None
include 'ipfinc/cbus.inc'
c Global variables used:
c bctbl
include 'ipfinc/ecvar.inc'
c Global variables used:
c kowntb, idswb
include 'ipfinc/intbus.inc'
c Global variables used:
c None
include 'ipfinc/lfiles.inc'
c Global variables used:
c dbug
include 'ipfinc/prt.inc'
c Global variables used:
c None
include 'ipfinc/slnopt.inc'
c Global variables used:
c option
include 'ipfinc/svc.inc'
c Global variables used:
c svc(r*8), numsvc
include 'ipfinc/tbx.inc'
c Global variables used:
c tbx(r*8)
include 'ipfinc/tbxsrt.inc'
c Global variables used:
c None
integer oldity, oldste
getsvc = 0
oldste = svc(2,isvc)
icb = svc(3,isvc)
dqk = qk -qnetu(kt)
C Compute SVC quantities. Recall that SVC(14,*) represents
C generation, whereas INET(*,*) represents load.
svcbkk = bkk - svc(13,isvc)
svcini = -ineti(kt) -svc(14,isvc)
svctot = svcini + svcbkk * vk
oldity = tbx(7,jt)
if (msw .eq. 1 .and. oldity .eq. 1) then
if (abs (dqk) .le. 10.0 * option(7)) then
C Convert SVC bus from state PV to PQ when Q converges
C reasonably.
kvolt(kt) = 0
volt(kt) = 0.0
tbx(7,jt) = 4
getsvc = 2
else
C Adjust voltage to manually sustain state 2
dvk = - 0.5 * dqk * dvdq
vnew = vk + dvk
dvk = dvk - ddim (dble(vnew),svc(10,isvc))
& + ddim (svc(9,isvc),dble(vnew))
if (abs (dvk) .gt. 0.050) dvk = sign (0.050,dvk)
if (abs (dvk) .gt. 1.0e-3) then
kvolt(kt) = kt
volt(kt) = dvk/vk
if (abs (dvk) .gt. 5.0e-3) kowntb = kowntb + 1
endif
endif
else if (msw .eq. 2 .and. oldity .eq. 1) then
C Force conversion of SVC bus from state PV to PQ during
C transition phase.
kvolt(kt) = 0
volt(kt) = 0.0
tbx(7,jt) = 4
getsvc = 2
C Determine by the voltage the domain of the SVC state.
else if (abs(dqk) .lt. 0.005) then
dvk = ddim (dble(vk),svc(10,isvc)) -
& ddim (svc(9,isvc),dble(vk))
if (oldste .eq. 1) then
if (dvk .ge. 0.001) then
C A transition from state 1 to state 2 is necessary.
bkk = bkk - svcbkk + svc(11,isvc)
ineti(kt) = ineti(kt) +svcini - svc(12,isvc)
bctbl(5,icb) = svc(11,numsvc) * bmva
bctbl(3,icb) = -svc(12,numsvc) * bmva
C Note that SVC(12,*) and SVCINI are represented as
C generation, whereas INET(*,*) is represented as
c load.
svc(2,isvc) = 2
getsvc = 2
endif
else if (oldste .eq. 2) then
if (dvk .lt. -0.001) then
C A transition from state 2 to state 1 is necessary.
bkk = bkk - svcbkk + svc(6,isvc)
ineti(kt) = ineti(kt) +svcini
bctbl(5,icb) = svc(6,numsvc) * bmva
bctbl(3,icb) = 0.0
C Note that SVCINI is represented as generation,
c whereas INET(*,*) is represented as load.
svc(2,isvc) = 1
getsvc = 1
else if (dvk .gt. 0.001) then
C A transition from state 2 to state 3 is necessary.
bkk = bkk - svcbkk + svc(5,isvc)
ineti(kt) = ineti(kt) +svcini
bctbl(5,icb) = svc(5,numsvc) * bmva
bctbl(3,icb) = 0.0
C Note that SVCINI is represented as generation,
c whereas INET(*,*) is represented as load.
svc(2,isvc) = 3
getsvc = 3
endif
else
if (dvk .lt. -0.001) then
C A transition from state 3 to state 2 is necessary.
bkk = bkk - svcbkk + svc(11,isvc)
ineti(kt) = ineti(kt) +svcini - svc(12,isvc)
bctbl(5,icb) = svc(11,numsvc) * bmva
bctbl(3,icb) = -svc(12,numsvc) * bmva
C Note that SVC(12,*) and SVCINI are represented as
C generation, whereas INET(*,*) is represented as
c load.
svc(2,isvc) = 2
getsvc = 2
endif
endif
endif
if (idswb .gt. 0) then
write (dbug, 100) isvc, kt, oldity, ifix(sngl(tbx(7,jt))),
1 oldste, ifix(sngl(svc(2,isvc))), vk, dvk, svc(9,isvc),
2 svc(10,isvc), qk, dqk, svcbkk, svcini, svctot
100 format (' GETSVC ', i2, i6, 4i2, 4f8.4, 5e12.5)
endif
return
end
| ipf/getsvc.f |
!! Copyright (C) Stichting Deltares, 2012-2016.
!!
!! This program is free software: you can redistribute it and/or modify
!! it under the terms of the GNU General Public License version 3,
!! as published by the Free Software Foundation.
!!
!! This program is distributed in the hope that it will be useful,
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!! GNU General Public License for more details.
!!
!! You should have received a copy of the GNU General Public License
!! along with this program. If not, see <http://www.gnu.org/licenses/>.
!!
!! contact: [email protected]
!! Stichting Deltares
!! P.O. Box 177
!! 2600 MH Delft, The Netherlands
!!
!! All indications and logos of, and references to registered trademarks
!! of Stichting Deltares remain the property of Stichting Deltares. All
!! rights reserved.
! Date: 5 Oct 1992
! Time: 22:20
! Program: EHCALC.FOR
! Version: 6.00.00
! Programmer: Nicolaas M de Rooij
!
subroutine ehcalc
! ehcalc computes eh from pie of the electron
! procedure equivalent to phcalc
include 'char1.inc'
character*6 el,oh,o2
DATA EL/'EL- '/
DATA oh/'OH- '/
DATA o2/'O2 '/
iel = 0
ihp = 0
ioh = 0
ih2 = 0
ehk = -0.0d+00
do 10 i=1,m
if(nr(i,1).eq.el)iel = i
if(nr(i,1).eq.hplus) ihp = i
if(nr(i,1).eq.oh)ioh = i
if(nr(i,1).eq.h2o)ih2 = i
10 continue
if(iel .ne. 0) then
pda = pie(iel)
goto 100
endif
if(ihp .ne. 0 .and. ioh .ne. 0) then
pda = 2.0d+00*pie(ioh) - 2.0d+00*pie(ihp)
goto 90
endif
if(ihp .ne. 0 .and. ih2 .ne. 0) then
pda = 2.0d+00*pie(ih2) - 4.0d+00*pie(ihp)
goto 90
endif
if(ioh .ne. 0 .and. ih2 .ne. 0) then
pda = -2.0d+00*pie(ih2) + 4.0d+00*pie(ioh)
goto 90
endif
85 continue
return
90 call lookup(o2,lka,1,m,nr)
if(lka .gt. m) go to 85
pda = (pda - pie(lka))/ 4.0d+00
100 ehk =-pda/dlog(10.0d+00)
return
end
| docker/water/delft3d/tags/v6686/src/engines_gpl/waq/packages/waq_kernel/src/charon/ehcalc.f |
great_ne(hh1,a1).
great_ne(p1,i1).
great_ne(x1,b1).
great_ne(bb1,c1).
great_ne(kk1,m1).
great_ne(kk1,k1).
great_ne(y1,c1).
great_ne(k1,w1).
great_ne(dd1,x1).
great_ne(z1,f1).
great_ne(cc1,w1).
great_ne(ee1,x1).
great_ne(jj1,m1).
great_ne(z1,t1).
great_ne(q1,c1).
great_ne(dd1,w1).
great_ne(hh1,y1).
great_ne(f1,h1).
great_ne(ii1,ff1).
great_ne(q1,ii1).
great_ne(m1,ii1).
great_ne(cc1,kk1).
great_ne(cc1,c1).
great_ne(q1,h1).
great_ne(kk1,ii1).
great_ne(dd1,h1).
great_ne(bb1,ff1).
great_ne(kk1,ff1).
great_ne(f1,c1).
great_ne(cc1,h1).
great_ne(t1,i1).
great_ne(p1,v1).
great_ne(cc1,ee1).
great_ne(u1,w1).
| foldsCreator/files/datasets/alzheimer_anime_0.1noisy/test7.f |
! RUN: bbc -emit-fir %s -o - | FileCheck --check-prefixes=CHECK,CHECK-32 -DDEFAULT_INTEGER_SIZE=32 %s
! bbc doesn't have a way to set the default kinds so we use flang-new driver
! RUN: flang-new -fc1 -fdefault-integer-8 -emit-fir %s -o - | FileCheck --check-prefixes=CHECK,CHECK-64 -DDEFAULT_INTEGER_SIZE=64 %s
! CHECK-LABEL: func @_QPexit_test1() {
subroutine exit_test1
call exit()
! CHECK: %[[status:.*]] = arith.constant 0 : i[[DEFAULT_INTEGER_SIZE]]
! CHECK-64: %[[statusConvert:.*]] = fir.convert %[[status]] : (i64) -> i32
! CHECK-32: %{{[0-9]+}} = fir.call @_FortranAExit(%[[status]]) : (i32) -> none
! CHECK-64: %{{[0-9]+}} = fir.call @_FortranAExit(%[[statusConvert]]) : (i32) -> none
end subroutine exit_test1
! CHECK-LABEL: func @_QPexit_test2(
! CHECK-SAME: %[[statusArg:.*]]: !fir.ref<i[[DEFAULT_INTEGER_SIZE]]>{{.*}}) {
subroutine exit_test2(status)
integer :: status
call exit(status)
! CHECK: %[[status:.*]] = fir.load %[[statusArg]] : !fir.ref<i[[DEFAULT_INTEGER_SIZE]]>
! CHECK-64: %[[statusConv:.*]] = fir.convert %[[status]] : (i64) -> i32
! CHECK-32: %{{[0-9]+}} = fir.call @_FortranAExit(%[[status]]) : (i32) -> none
! CHECK-64: %{{[0-9]+}} = fir.call @_FortranAExit(%[[statusConv]]) : (i32) -> none
end subroutine exit_test2
| flang/test/Lower/Intrinsics/exit.f90 |
C++*******************************************************
C Program to compress CFHT images by a factor 2
C Initial size : 680x1024 or 680x1056
C Final size : 340x512
C Version of November 3rd 1987
C--*******************************************************
PROGRAM COMPRESS_CFHT
PARAMETER (IDIM=1100)
REAL*4 IMAGE(IDIM,IDIM)
CHARACTER NAME*40,COMMENTS*80
PRINT 20
20 FORMAT(' COMPRESSION OF AN IMAGE BY A FACTOR 2')
C Inquire the format of the file :
CALL JLP_INQUIFMT
C Input of the file :
WRITE(6,*) 'Input file: '
READ(5,10) NAME
CALL JLP_READIMAG(IMAGE,NPL1,NL1,IDIM,NAME,COMMENTS)
C Main loop :
NPL2=NPL1/2
NL2=NL1/2
DO J2=1,NL2
DO I2=1,NPL2
I1=(2*I2)-1
J1=(2*J2)-1
IMAGE(I2,J2)=0.25*(IMAGE(I1,J1)+IMAGE(I1,J1+1)+
1 IMAGE(I1+1,J1+1)+IMAGE(I1+1,J1))
END DO
END DO
C PRINT *,' PREVIOUS NPL,NL :',NPL2,NL2
C Suppression of the last columns
IF(NL2.GT.512) NL2=512
PRINT *,' NEW NPL,NL :',NPL2,NL2
C Output of the file :
WRITE(6,*) 'Output file: '
READ(5,10) NAME
CALL JLP_WRITEIMAG(IMAGE,NPL2,NL2,IDIM,NAME,COMMENTS)
CALL JLP_END
END
| source/ccd/compress_cfht.for |
module RPT_mod
use kdtree2_module
implicit none
! these can be used to get the component list and selected output headers
! from the commented code blocks near line 203 in RPT_dolo.f90
! type component_list
! character(:), allocatable :: comp
! end type
! type selectout_list
! character(:), allocatable :: head
! end type
integer, parameter :: sp = kind(1.0), dp = kind(1.0d0)
double precision, parameter :: pi = 4.0d0 * atan(1.0d0), kappaD = 0.5d0,&
kappa = (1.0d0 - kappaD), kappaM = 0.5d0,&
kappaI = 1.0d0 - kappaM
integer, parameter :: nspec = 10, numsd = 5, num_alloc = 1000
! NOTE: nspec (the number of chemical species in the model) is hard-coded for
! this specific problem
! numsd is distances over which particle reactions are considered
! num_alloc is the maximum number of nearby particles expected to be found
! mobile particle type
! NOTE: these are only for a 1D problem
type mparticle
double precision :: loc ! real-valued spatial location
double precision :: concs(nspec) ! vector of chemical concentrations
logical :: active
! indicates whether particle is active and within the domain
integer :: bin
! used to indicate which spatial grid point a particle resides within
end type
! immobile particle type
type iparticle
double precision :: loc
double precision :: concs(nspec)
end type
! a couple of derived types for the kD tree search
! holds indices of nearby particles
type index_array
integer, allocatable :: indices(:)
end type
! holds the distances to the corresponding particle held by index_array
type dist_array
double precision, allocatable :: dists(:)
end type
contains
! subroutine to initialize the random number generator seed from clock time
subroutine init_random_seed()
integer :: i, n, clock
integer, allocatable :: seed(:)
call random_seed(size = n)
allocate (seed(n))
call system_clock(count = clock)
seed = clock + 37 * (/ (i - 1, i = 1, n) /)
call random_seed(put = seed)
deallocate(seed)
end subroutine init_random_seed
! this generates the PHREEQC input file for this specific problem
! NOTE: much of this is hard-coded and not general
subroutine phreeqc_input(calcite_in, na_in, mg_in, ca_in, cl_in, co2_in)
double precision, intent(in ) :: calcite_in, na_in, mg_in, ca_in,&
cl_in, co2_in
character*1 :: tab
tab = char(9)
open (unit=11, file='dolomite_chem.in', action='write')
write (11, *) '# Brine-CO2-Calcite-Quartz system'
write (11, *) 'SOLUTION 0 Brine'
write (11, *) tab, 'pH 7.0'
write (11, *) tab, 'units mol/L'
write (11, *) tab, 'temp 60.000000'
write (11, *) tab, 'pressure 98.6923 atm' ! = 100 bar
write (11, '(A, A, f8.6)') tab, 'Na ', Na_in
write (11, '(A, A, f8.6)') tab, 'Mg ', mg_in
write (11, '(A, A, f8.6)') tab, 'Ca ', ca_in
write (11, '(A, A, f8.6, A)') tab, 'Cl ', cl_in, ' charge'
write (11, *) 'EQUILIBRIUM_PHASES 0'
write (11, '(A, A, f9.6)') tab, 'CO2(g) 2.0 ', co2_in
write (11, *) 'SAVE solution 0'
write (11, *) 'END'
write (11, *) 'SOLUTION 1 Domain'
write (11, *) tab, 'pH 7.0 charge'
write (11, *) tab, 'temp 60.000000'
write (11, *) tab, 'pressure 98.6923 atm' ! = 100 bar
write (11, *) tab, 'Cl 10.0'
write (11, *) 'EQUILIBRIUM_PHASES 1'
write (11, '(A, A, f9.6)') tab, 'Calcite 0.000000', calcite_in
write (11, *) tab, 'Dolomite 0.000000 0.000000'
write (11, *) tab, 'Quartz 0.000000 22.000000'
write (11, *) 'SAVE solution 1'
write (11, *) 'SELECTED_OUTPUT'
write (11, *) tab, '-simulation false'
write (11, *) tab, '-state false'
write (11, *) tab, '-solution false'
write (11, *) tab, '-distance false'
write (11, *) tab, '-time false'
write (11, *) tab, '-step false'
write (11, *) tab, '-ph true' ! get pH output
write (11, *) tab, '-pe false'
write (11, *) tab, '-equilibrium_phases Calcite Dolomite'
! get calcite and dolomite concentrations
write (11, *) 'END'
close (unit=11, status='keep')
end subroutine phreeqc_input
! moves active particles via advection
subroutine advect(p, v, dt, alive)
type(mparticle), intent(inout) :: p(:) ! mobile particle array
double precision, intent(in ) :: v(:), dt ! velocity grid and time step
integer, intent(in ) :: alive(:)
! array of indices of active particles
! use the velocity of the relevant cell, based on bin value
p(alive)%loc = p(alive)%loc + v(p(alive)%bin) * dt
end subroutine advect
! moves active particles via diffusion
subroutine diffuse(p, np, D, dt, alive)
type(mparticle), intent(inout) :: p(:) ! mobile particle array
double precision, intent(in ) :: D(:), dt
! diffusion coefficient grid and time step
integer, intent(in ) :: np, alive(:)
! number and array of indices of active particles
double precision :: normvec(np)
! vector which will hold Normal(0, 1) values
! call N(0, 1) generator
call box_mullerp(np, normvec)
! use the diffusion coeff of the relevant cell, based on bin value
p(alive)%loc = p(alive)%loc + sqrt(2.0d0 * kappaD * D(p(alive)%bin) * dt) * normvec
end subroutine diffuse
! reflective lower boundary
subroutine reflectlow(p, low, alive)
type(mparticle), intent(inout) :: p(:) ! mobile particle array
double precision, intent(in ) :: low ! lower spatial boundary
integer, intent(in ) :: alive(:)
! array of indices of active particles
! if particle has exited lower boundary, flip the negative location
! to the same positive value
where (p(alive)%loc < low) p(alive)%loc = -p(alive)%loc
end subroutine reflectlow
! absorbing upper boundary
subroutine absorbhigh(p, high, alive, na, n)
type(mparticle), intent(inout) :: p(:) ! mobile particle array
double precision, intent(in ) :: high ! upper spatial boundary
integer, intent(in ) :: alive(:), na
integer, intent( out) :: n
logical :: gone(na)
! if particle has exited upper boundary, make the particle inactive
! also, make bin and loc -999 to catch any errors
gone = p(alive)%loc > high
n = count(gone)
where (gone) p(alive)%active = .false.
where (gone) p(alive)%bin = -999
where (gone) p(alive)%loc = -999
end subroutine absorbhigh
! since PHREEQCRM can't accept the particle array as input, this subroutine
! assigns the values in the 2D concs array to its corresponding immobile
! particle
subroutine concs_to_iparts(c, p, np)
double precision, intent(in ) :: c(:, :)
! 2D concentration array used by PHREEQCRM
type(iparticle), intent(inout) :: p(:) ! immobile particle array
integer, intent(in ) :: np ! number of immobile particles
integer :: i ! iteration variable
do i = 1, np
p(i)%concs = c(i, :)
enddo
end subroutine concs_to_iparts
! this does the opposite of above
subroutine iparts_to_concs(c, p, np)
double precision, intent(inout) :: c(:, :)
! 2D concentration array used by PHREEQCRM
type(iparticle), intent(in ) :: p(:) ! immobile particle array
integer, intent(in ) :: np ! number of immobile particles
integer :: i ! iteration variable
do i = 1, np
c(i, :) = p(i)%concs
enddo
end subroutine iparts_to_concs
! this subroutine builds the distance matrix for all mobile-immobile pairwise
! distances less than the cutoff radius
subroutine build_Distmat(ip, mp, na, alive, ni, D, dt, Distmat)
type(iparticle), intent(in ) :: ip(:) ! immobile particle array
type(mparticle), intent(in ) :: mp(:) ! mobile particle array
integer, intent(in ) :: na, alive(:), ni
! number and array of indices of active mobile particles and number
! of immobile particles
double precision, intent(in ) :: D(:), dt
double precision, intent( out) :: Distmat(ni, na)
! diffusion coefficient array, time step, and domain length
type(kdtree2), pointer :: tree ! this is the KD tree
integer :: ntot, dim = 1, bindex, i, j
! total number of particles (active mobile + immobile)
!****Note: hard coded one spatial dimension
real(kdkind) :: locs(na + ni), r2
! array holding locations of immobile and active immobile particles
! and value of squared search radius for KD search
type(index_array), allocatable :: closeguys(:)
! this holds the indices of nearby particles
type(dist_array), allocatable :: close_dists(:)
! this holds the distances to the corresponding nearby particle
Distmat = 0.0d0
! calculate total number of particles to be considered for mass balance
ntot = na + ni
! build locs array--immobile particles will be at the beginning of the
! array, and mobile will be at the end
locs(1 : ni) = real(ip%loc, kdkind)
locs(ni + 1 : ntot) = real(mp(alive)%loc, kdkind)
! calculate interaction distance to be numsd standard deviations of the
! Brownian Motion process--r2 is this distance squared
! ****NOTE: numsd is a global variable that is hard-coded above
r2 = (real(numsd, kdkind) * sqrt(4.0_kdkind * maxval(real(D, kdkind)) *&
real(dt, kdkind)))**2
! build the KD tree and search it
! ****NOTE: num_alloc is a global variable that is hard-coded above
call maketree(tree, dim, ntot, locs)
allocate (closeguys(ni), close_dists(ni))
! this finds the closest mobile particles to each immobile particle
call search(1, ni, tree, r2, num_alloc, closeguys, close_dists)
! NOTE: this search returns the SQUARED distance between two points
! also, the point itself is included in the closeguys list
call kdtree2_destroy(tree)
! loop over immobile particles to build distance matrix
do i = 1, ni ! immobile particle loop
do j = 1, size(closeguys(i)%indices) ! mobile particle loop
! this is the mobile particle loop
! note that the closeguys array is indexed to the loc array,
! and thus its true index in the mp array is calculated below
! current mobile particle's index in locs array
if (closeguys(i)%indices(j) <= ni) cycle
! if B is an immobile particle, skip this loop
! also prevents distance with self
bindex = closeguys(i)%indices(j) - ni
! NOTE: Distmat is indexed to the mobile alive array
Distmat(i, bindex) = close_dists(i)%dists(j)
enddo
enddo
deallocate (closeguys, close_dists)
end subroutine build_Distmat
! algorithm set forth in mobile-immobile JCP paper using explicit matrix forward
! solve
subroutine immobile2mobile(ip, mp, na, alive, ni, D, dt, nc, Distmat)
type(iparticle), intent(inout) :: ip(:) ! immobile particle array
type(mparticle), intent(inout) :: mp(:) ! mobile particle array
integer, intent(in ) :: na, alive(:), ni, nc
! number and array of indices of active mobile particles and number
! of immobile particles
double precision, intent(in ) :: D(:), dt, Distmat(ni, na)
! diffusion coefficient array, time step, and domain length
integer :: i
double precision :: WImat(na, ni), denom(na, ni), DTmat(na, ni),&
colsum(ni)
! denom is used in v(s) calculation but is pre-calculated for efficiency
! v_s is encounter density for a mobile/immobile particle pair
DTmat = transpose(Distmat)
do i = 1, ni
denom(:, i) = -kappa * kappaI * 4.0d0 * D(mp(alive)%bin) * dt
enddo
where (DTmat /= 0.0d0) WImat = exp(DTmat / denom)
colsum = sum(WImat, 1)
do i = 1, ni
WImat(:, i) = WImat(:, i) / colsum(i)
enddo
do i = 1, nc
mp(alive)%concs(i) = matmul(WImat, ip%concs(i))
enddo
end subroutine immobile2mobile
! this does the opposite of the above
subroutine mobile2immobile(ip, mp, na, alive, ni, D, dt, nc, Distmat)
type(iparticle), intent(inout) :: ip(:) ! immobile particle array
type(mparticle), intent(inout) :: mp(:) ! mobile particle array
integer, intent(in ) :: na, alive(:), ni, nc
! number and array of indices of active mobile particles and number
! of immobile particles
double precision, intent(in ) :: D(:), dt, Distmat(ni, na)
! diffusion coefficient array, time step, and domain length
integer :: i
double precision :: WMmat(ni, na), denom(ni, na)
! denom is used in v(s) calculation but is pre-calculated for efficiency
! v_s is encounter density for a mobile/immobile particle pair
do i = 1, ni
denom(i, :) = -kappa * kappaM * 4.0d0 * D(mp(alive)%bin) * dt
enddo
where (Distmat /= 0.0d0) WMmat = exp(Distmat / denom)
do i = 1, na
WMmat(:, i) = WMmat (:, i) / sum(WMmat(:, i), 1)
enddo
do i = 1, nc
ip%concs(i) = matmul(WMmat, mp(alive)%concs(i))
enddo
end subroutine mobile2immobile
! this builds a KD tree
subroutine maketree(tree2, d, n, locs)
type(kdtree2), pointer, intent( out) :: tree2 ! this is the KD tree
integer, intent(in ) :: d, n
! number of spatial dimensions, number of particles
real(kdkind), intent(in ) :: locs(d, n)
! location array for particles, with dimension d x n (number of
! spatial dimensions x number of particles)
! build the tree
tree2 => kdtree2_create(locs, dim=d, sort=.false., rearrange=.true.)
! currently don't see a need to sort, as false is quicker, while
! rearrange = true is quicker
end subroutine maketree
! this searches an already built KD tree
subroutine search(start, end, tree, r2, num_alloc, closeguys, close_dists)
integer, intent(in ) :: start, end, num_alloc
! number of particles and how large to to preallocate results array
! within KD tree module
type(kdtree2), pointer, intent(in ) :: tree ! the KD tree
real(kdkind), intent(in ) :: r2 ! squared search radius
type(index_array), intent( out) :: closeguys(:)
! this holds the indices of nearby particles
type(dist_array), intent( out) :: close_dists(:)
! this holds the distances to the corresponding nearby particle
integer :: i, n, nf
! loop iterator and number of particles found by search
type(kdtree2_result), allocatable :: results(:)
! results array from KD tree module
allocate (results(num_alloc))
n = end - start + 1
! loop over all particles
do i = 1, n
! the type of search used here finds all the particles within
! squared distance r2 from the i^th particle in the list
! the hard-coded 0 is the 'correlation time' of the search
call kdtree2_r_nearest_around_point(tree, i + start - 1, 0, r2, nf, num_alloc, results)
! allocate these based on how many nearby particles were found
allocate (closeguys(i)%indices(nf), close_dists(i)%dists(nf))
closeguys(i)%indices = results(1 : nf)%idx
close_dists(i)%dists = results(1 : nf)%dis
end do
deallocate (results)
end subroutine search
! these next two subroutines use the Box-Muller transform to generate N(0,1)
! random numbers from U(0,1)
! https://goo.gl/DQgmMu
! Note: this polar formulation seems to be consistently ~20% faster than the
! version below that uses trig functions
! reference for polar version (and standard version):
! https://www.taygeta.com/random/gaussian.html
subroutine box_mullerp(n, z)
integer, intent(in ) :: n ! size of random vector to be generated
double precision, intent( out) :: z(n)
integer :: j
double precision :: w, x1, x2
call init_random_seed()
do j = 1, n/2
w = 1.0d0
do while (w >= 1.0d0)
x1 = 2.0d0 * rand() - 1.0d0
x2 = 2.0d0 * rand() - 1.0d0
w = x1**2 + x2**2
enddo
w = sqrt((-2.0d0 * log(w)) / w)
z(2 * j - 1 : 2 * j) = (/x1 * w, x2 * w/)
enddo
if (mod(n, 2) /= 0) then
w = 1.0d0
do while (w >= 1.0d0)
x1 = 2.0d0 * rand() - 1.0d0
x2 = 2.0d0 * rand() - 1.0d0
w = x1**2 + x2**2
enddo
w = sqrt((-2.0d0 * log(w)) / w)
z(n) = x1 * w
endif
end subroutine box_mullerp
! subroutine box_muller()
! integer, parameter :: n = 1e8
! integer :: i, j
! double precision :: x1, x2, y1, y2, z(n)
! call init_random_seed()
! i = 1
! do j = 1, n/2
! x1 = rand()
! x2 = rand()
! y1 = sqrt(-2.0d0 * log(x1)) * cos(2.0d0 * pi * x2)
! y2 = sqrt(-2.0d0 * log(x1)) * sin(2.0d0 * pi * x2)
! z(i : i + 1) = (/y1, y2/)
! i = i + 2
! enddo
! end subroutine box_muller
end module RPT_mod
| dolomite_problem/RPT_mod.f90 |
! This file is part of toml-f.
!
! Copyright (C) 2019-2020 Sebastian Ehlert
!
! Licensed under either of Apache License, Version 2.0 or MIT license
! at your option; you may not use this file except in compliance with
! the License.
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!> Implementation of a basic storage structure as pointer list of pointers.
!>
!> This implementation does purposely not use pointer attributes in the
!> datastructure to make it safer to work with.
module tomlf_structure_vector
use tomlf_constants, only : tfc
use tomlf_structure_base, only : toml_ordered
use tomlf_type_value, only : toml_value, toml_key
implicit none
private
public :: toml_vector, new_vector
!> Wrapped TOML value to generate pointer list
type :: toml_node
!> TOML value payload
class(toml_value), allocatable :: val
end type toml_node
!> Stores TOML values in a list of pointers
type, extends(toml_ordered) :: toml_vector
!> Current number of stored TOML values
integer :: n = 0
!> List of TOML values
type(toml_node), allocatable :: lst(:)
contains
!> Get number of TOML values in the structure
procedure :: get_len
!> Find a TOML value based on its key
procedure :: find
!> Get TOML value at a given index
procedure :: get
!> Push back a TOML value to the structure
procedure :: push_back
!> Remove the first element from the structure
procedure :: shift
!> Remove the last element from the structure
procedure :: pop
!> Get list of all keys in the structure
procedure :: get_keys
!> Delete TOML value at a given key
procedure :: delete
!> Destroy the data structure
procedure :: destroy
end type toml_vector
!> Initial storage capacity of the datastructure
integer, parameter :: initial_size = 16
contains
!> Constructor for the storage data structure
subroutine new_vector(self, n)
!> Instance of the structure
type(toml_vector), intent(out) :: self
!> Initial storage capacity
integer, intent(in), optional :: n
self%n = 0
if (present(n)) then
allocate(self%lst(min(1, n)))
else
allocate(self%lst(initial_size))
end if
end subroutine new_vector
!> Get number of TOML values in the structure
pure function get_len(self) result(length)
!> Instance of the structure
class(toml_vector), intent(in), target :: self
!> Current length of the ordered structure
integer :: length
length = self%n
end function get_len
!> Find a TOML value based on its key
subroutine find(self, key, ptr)
!> Instance of the structure
class(toml_vector), intent(inout), target :: self
!> Key to the TOML value
character(kind=tfc, len=*), intent(in) :: key
!> Pointer to the stored value at given key
class(toml_value), pointer, intent(out) :: ptr
integer :: i
nullify(ptr)
do i = 1, self%n
if (allocated(self%lst(i)%val)) then
if (self%lst(i)%val%match_key(key)) then
ptr => self%lst(i)%val
exit
end if
end if
end do
end subroutine find
!> Get TOML value at a given index
subroutine get(self, idx, ptr)
!> Instance of the structure
class(toml_vector), intent(inout), target :: self
!> Position in the ordered structure
integer, intent(in) :: idx
!> Pointer to the stored value at given index
class(toml_value), pointer, intent(out) :: ptr
nullify(ptr)
if (idx > 0 .and. idx <= self%n) then
if (allocated(self%lst(idx)%val)) then
ptr => self%lst(idx)%val
end if
end if
end subroutine get
!> Push back a TOML value to the structure
subroutine push_back(self, val)
!> Instance of the structure
class(toml_vector), intent(inout), target :: self
!> TOML value to be stored
class(toml_value), allocatable, intent(inout) :: val
integer :: m
if (.not.allocated(self%lst)) then
call resize(self%lst, initial_size)
end if
m = size(self%lst)
if (self%n >= m) then
call resize(self%lst, m + m/2 + 1)
end if
self%n = self%n + 1
call move_alloc(val, self%lst(self%n)%val)
end subroutine push_back
!> Remove the first element from the data structure
subroutine shift(self, val)
!> Instance of the structure
class(toml_vector), intent(inout), target :: self
!> TOML value to be retrieved
class(toml_value), allocatable, intent(out) :: val
integer :: i
if (self%n > 0) then
call move_alloc(self%lst(1)%val, val)
do i = 2, self%n
call move_alloc(self%lst(i)%val, self%lst(i-1)%val)
end do
self%n = self%n - 1
end if
end subroutine shift
!> Remove the last element from the data structure
subroutine pop(self, val)
!> Instance of the structure
class(toml_vector), intent(inout), target :: self
!> TOML value to be retrieved
class(toml_value), allocatable, intent(out) :: val
if (self%n > 0) then
call move_alloc(self%lst(self%n)%val, val)
self%n = self%n - 1
end if
end subroutine pop
!> Get list of all keys in the structure
subroutine get_keys(self, list)
!> Instance of the structure
class(toml_vector), intent(inout), target :: self
!> List of all keys
type(toml_key), allocatable, intent(out) :: list(:)
integer :: i
allocate(list(self%n))
do i = 1, self%n
if (allocated(self%lst(i)%val)) then
if (allocated(self%lst(i)%val%key)) then
list(i)%key = self%lst(i)%val%key
end if
end if
end do
end subroutine get_keys
!> Delete TOML value at a given key
subroutine delete(self, key)
!> Instance of the structure
class(toml_vector), intent(inout), target :: self
!> Key to the TOML value
character(kind=tfc, len=*), intent(in) :: key
integer :: idx, i
idx = 0
do i = 1, self%n
if (allocated(self%lst(i)%val)) then
if (self%lst(i)%val%match_key(key)) then
idx = i
exit
end if
end if
end do
if (idx > 0) then
call self%lst(idx)%val%destroy
do i = idx+1, self%n
call move_alloc(self%lst(i)%val, self%lst(i-1)%val)
end do
self%n = self%n - 1
end if
end subroutine delete
!> Change size of the TOML value vector
subroutine resize(list, n)
!> Array of TOML values to be resized
type(toml_node), allocatable, intent(inout), target :: list(:)
!> New size of the list
integer, intent(in) :: n
type(toml_node), allocatable, target :: tmp(:)
integer :: i
if (allocated(list)) then
call move_alloc(list, tmp)
allocate(list(n))
do i = 1, min(size(tmp), n)
if (allocated(tmp(i)%val)) then
call move_alloc(tmp(i)%val, list(i)%val)
end if
end do
do i = n+1, size(tmp)
if (allocated(tmp(i)%val)) then
call tmp(i)%val%destroy
deallocate(tmp(i)%val)
end if
end do
deallocate(tmp)
else
allocate(list(n))
end if
end subroutine resize
!> Deconstructor for data structure
subroutine destroy(self)
!> Instance of the structure
class(toml_vector), intent(inout), target :: self
integer :: i
do i = 1, self%n
if (allocated(self%lst(i)%val)) then
call self%lst(i)%val%destroy
end if
end do
deallocate(self%lst)
self%n = 0
end subroutine destroy
end module tomlf_structure_vector
| src/tomlf/structure/vector.f90 |
!***********************************************************************
! Integrated Water Flow Model (IWFM)
! Copyright (C) 2005-2021
! State of California, Department of Water Resources
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License
! as published by the Free Software Foundation; either version 2
! of the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
! (http://www.gnu.org/copyleft/gpl.html)
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
!
! For tecnical support, e-mail: [email protected]
!***********************************************************************
MODULE SupplyAdjustment
USE MessageLogger , ONLY: SetLastMessage , &
EchoProgress , &
MessageArray , &
iFatal
USE GeneralUtilities , ONLY: NormalizeArray
USE TimeSeriesUtilities , ONLY: TimeStepType
USE Package_ComponentConnectors , ONLY: SupplyToDestinationType , &
DestinationToSupplyType , &
SupplyDestinationConnectorType
USE Package_Misc , ONLY: IntTSDataInFileType , &
ReadTSData , &
f_iSupply_Diversion , &
f_iSupply_ElemPump , &
f_iSupply_Well , &
f_iFlowDest_Element , &
f_iAg , &
f_iUrb
USE Package_AppGW , ONLY: AppGWType , &
f_iPump_Well , &
f_iPump_ElemPump
USE Package_AppStream , ONLY: AppStreamType
USE Package_RootZone , ONLY: RootZoneType
USE Package_Discretization , ONLY: AppGridType , &
StratigraphyType
IMPLICIT NONE
! ******************************************************************
! ******************************************************************
! ******************************************************************
! ***
! *** VARIABLE DEFINITIONS
! ***
! ******************************************************************
! ******************************************************************
! ******************************************************************
! -------------------------------------------------------------
! --- PUBLIC ENTITIES
! -------------------------------------------------------------
PRIVATE
PUBLIC :: SupplyAdjustmentType , &
f_iAdjustNone , &
f_iAdjustPump , &
f_iAdjustDiver , &
f_iAdjustPumpDiver , &
f_iAdjustForNone , &
f_iAdjustForAg , &
f_iAdjustForUrb , &
f_iAdjustForAgUrb
! -------------------------------------------------------------
! --- ADJUSTMENT FLAGS
! -------------------------------------------------------------
INTEGER,PARAMETER :: f_iAdjustNone = 00 , & !No adjustment
f_iAdjustPump = 10 , & !Adjust pumping only
f_iAdjustDiver = 01 , & !Adjust diversions only
f_iAdjustPumpDiver = 11 , & !Adjust both diversion and pumping
f_iAdjustForNone = 00 , & !Do not adjust supply for ag or urban
f_iAdjustForAg = 10 , & !Adjust supply for ag only
f_iAdjustForUrb = 01 , & !Adjust supply for urban only
f_iAdjustForAgUrb = 11 !Adjust supply for ag and urban both
! -------------------------------------------------------------
! --- SUPPLY ADJUSTMENT DATA TYPE
! -------------------------------------------------------------
TYPE SupplyAdjustmentType
PRIVATE
INTEGER :: iAdjust = f_iAdjustNone !Will pumping, diversions or both will be adjusted
INTEGER :: NAdjustLocations = 0 !Number of demand locations (e.g. elements or subregions) for which supply will be adjusted
INTEGER :: NMaxPumpAdjustIter = 0 !Number of maximum supply adjustment iterations (only used for pumping; for diversions diversion rank is used to limit the iterations)
INTEGER :: iWellPumpAdjustIter = 0 !Current well pumping adjustment iteration
INTEGER :: iElemPumpAdjustIter = 0 !Current element pumping adjustment iteration
INTEGER :: iDiverAdjustIter = -1 !Current diversion adjustment iteration; set to -1 since smallest diversion rank is zero
INTEGER :: iGlobalAdjustIter = 1 !Current global iteration counting all pumping and diversion adjustment iterations
REAL(8) :: Tolerance = 0.0 !Tolerance as a fraction of demand that supply will be adjusted to (has to be a number between 0 and 1)
LOGICAL :: lAdjust = .FALSE. !Flag to check further adjustment runs will be performed
TYPE(IntTSDataInFileType) :: SpecFile !Supply adjustment specifications file
CONTAINS
PROCEDURE,PASS :: New
PROCEDURE,PASS :: Kill
PROCEDURE,PASS :: IsAdjust
PROCEDURE,PASS :: IsDiversionAdjusted
PROCEDURE,PASS :: IsPumpingAdjusted
PROCEDURE,PASS :: GetAdjustFlag
PROCEDURE,PASS :: GetAdjustIter
PROCEDURE,PASS :: GetFileName
PROCEDURE,PASS :: SetTolerance
PROCEDURE,PASS :: SetAdjustFlag
PROCEDURE,PASS :: SetMaxPumpAdjustIter
PROCEDURE,PASS :: ReadTSData => SupplyAdjustment_ReadTSData
PROCEDURE,PASS :: Adjust
PROCEDURE,PASS :: ResetState
END TYPE SupplyAdjustmentType
! -------------------------------------------------------------
! --- MISC. ENTITIES
! -------------------------------------------------------------
INTEGER,PARAMETER :: ModNameLen = 18
CHARACTER(LEN=ModNameLen),PARAMETER :: ModName = 'SupplyAdjustment::'
CONTAINS
! ******************************************************************
! ******************************************************************
! ******************************************************************
! ***
! *** CONSTRUCTORS
! ***
! ******************************************************************
! ******************************************************************
! ******************************************************************
! -------------------------------------------------------------
! --- NEW SUPPLY ADJUSTMENT DATA
! --- *** Note: Assumes iAdjust and NMaxPumpAdjustIter flags are already set
! -------------------------------------------------------------
SUBROUTINE New(SupplyAdjustment,cFileName,cWorkingDirectory,NDemandLocations,TimeStep,iStat)
CLASS(SupplyAdjustmentType) :: SupplyAdjustment
CHARACTER(LEN=*),INTENT(IN) :: cFileName,cWorkingDirectory
INTEGER,INTENT(IN) :: NDemandLocations
TYPE(TimeStepType),INTENT(IN) :: TimeStep
INTEGER,INTENT(OUT) :: iStat
!Local variables
CHARACTER(LEN=ModNameLen+3) :: ThisProcedure = ModName // 'New'
!Initialize
iStat = 0
!Always instantiate SupplyAdjustment object since it maybe modified later and info will be needed
!IF (SupplyAdjustment%iAdjust .EQ. f_iAdjustNone) RETURN
!Stop if no filename is given
IF (cFileName .EQ. '') THEN
MessageArray(1) = 'Supply adjustment specifications file must be specified'
MessageArray(2) = ' when pumping or diversions are defined!'
CALL SetLastMessage(MessageArray(1:2),iFatal,ThisProcedure)
iStat = -1
RETURN
END IF
!Instantiate data
CALL SupplyAdjustment%SpecFile%Init(cFileName,cWorkingDirectory,'supply adjustment specifications file',TimeStep%TrackTime,BlocksToSkip=1,iStat=iStat)
IF (iStat .EQ. -1) RETURN
!Set number of locations for which supply adjustment will be performed
SupplyAdjustment%NAdjustLocations = NDemandLocations
END SUBROUTINE New
! ******************************************************************
! ******************************************************************
! ******************************************************************
! ***
! *** DESTRUCTORS
! ***
! ******************************************************************
! ******************************************************************
! ******************************************************************
! -------------------------------------------------------------
! --- KILL SUPPLY ADJUSTMENT DATA
! -------------------------------------------------------------
SUBROUTINE Kill(SupplyAdjust)
CLASS(SupplyAdjustmentType) :: SupplyAdjust
!Local variables
TYPE(SupplyAdjustmentType) :: DummyData
!Set atrributes to their default values
SupplyAdjust%iAdjust = DummyData%iAdjust
SupplyAdjust%NAdjustLocations = DummyData%NAdjustLocations
SupplyAdjust%NMaxPumpAdjustIter = DummyData%NMaxPumpAdjustIter
SupplyAdjust%iWellPumpAdjustIter = DummyData%iWellPumpAdjustIter
SupplyAdjust%iElemPumpAdjustIter = DummyData%iElemPumpAdjustIter
SupplyAdjust%iDiverAdjustIter = DummyData%iDiverAdjustIter
SupplyAdjust%iGlobalAdjustIter = DummyData%iGlobalAdjustIter
SupplyAdjust%Tolerance = DummyData%Tolerance
SupplyAdjust%lAdjust = DummyData%lAdjust
!Close the attached time-series data
CALL SupplyAdjust%SpecFile%Close()
END SUBROUTINE Kill
! ******************************************************************
! ******************************************************************
! ******************************************************************
! ***
! *** GETTERS
! ***
! ******************************************************************
! ******************************************************************
! ******************************************************************
! -------------------------------------------------------------
! --- GET SUPPLY ADJUSTMENT FLAGS FILENAME
! -------------------------------------------------------------
SUBROUTINE GetFileName(SupplyAdjustment,cFileName)
CLASS(SupplyAdjustmentType),INTENT(IN) :: SupplyAdjustment
CHARACTER(:),ALLOCATABLE,INTENT(OUT) :: cFileName
CALL SupplyAdjustment%SpecFile%GetFileName(cFileName)
END SUBROUTINE GetFileName
! -------------------------------------------------------------
! --- GET SUPPLY ADJUSTMENT FLAG
! -------------------------------------------------------------
PURE FUNCTION GetAdjustFlag(SupplyAdjustment) RESULT(iFlag)
CLASS(SupplyAdjustmentType),INTENT(IN) :: SupplyAdjustment
INTEGER :: iFlag
iFlag = SupplyAdjustment%iAdjust
END FUNCTION GetAdjustFlag
! -------------------------------------------------------------
! --- GET GLOBAL SUPPLY ADJUSTMENT ITERATION NUMBER
! -------------------------------------------------------------
PURE FUNCTION GetAdjustIter(SupplyAdjustment) RESULT(iGlobalIter)
CLASS(SupplyAdjustmentType),INTENT(IN) :: SupplyAdjustment
INTEGER :: iGlobalIter
iGlobalIter = SupplyAdjustment%iGlobalAdjustIter
END FUNCTION GetAdjustIter
! -------------------------------------------------------------
! --- GET SUPPLY ADJUSTMENT FLAG TO SEE IF FURTHER ADJUSTMENT RUNS ARE TO BE PERFORMED
! -------------------------------------------------------------
PURE FUNCTION IsAdjust(SupplyAdjustment) RESULT(lAdjust)
CLASS(SupplyAdjustmentType),INTENT(IN) :: SupplyAdjustment
LOGICAL :: lAdjust
lAdjust = SupplyAdjustment%lAdjust
END FUNCTION IsAdjust
! -------------------------------------------------------------
! --- ARE DIVERSIONS ADJUSTED?
! -------------------------------------------------------------
PURE FUNCTION IsDiversionAdjusted(SupplyAdjustment) RESULT(lAdjust)
CLASS(SupplyAdjustmentType),INTENT(IN) :: SupplyAdjustment
LOGICAL :: lAdjust
IF (SupplyAdjustment%iAdjust.EQ.f_iAdjustDiver .OR. SupplyAdjustment%iAdjust.EQ.f_iAdjustPumpDiver) THEN
lAdjust = .TRUE.
ELSE
lAdjust = .FALSE.
END IF
END FUNCTION IsDiversionAdjusted
! -------------------------------------------------------------
! --- IS PUMPING ADJUSTED?
! -------------------------------------------------------------
PURE FUNCTION IsPumpingAdjusted(SupplyAdjustment) RESULT(lAdjust)
CLASS(SupplyAdjustmentType),INTENT(IN) :: SupplyAdjustment
LOGICAL :: lAdjust
IF (SupplyAdjustment%iAdjust.EQ.f_iAdjustPump .OR. SupplyAdjustment%iAdjust.EQ.f_iAdjustPumpDiver) THEN
lAdjust = .TRUE.
ELSE
lAdjust = .FALSE.
END IF
END FUNCTION IsPumpingAdjusted
! ******************************************************************
! ******************************************************************
! ******************************************************************
! ***
! *** SETTERS
! ***
! ******************************************************************
! ******************************************************************
! ******************************************************************
! -------------------------------------------------------------
! --- SET SUPPLY ADJUSTMENT TOLERANCE
! -------------------------------------------------------------
SUBROUTINE SetTolerance(SupplyAdjustment,Toler,iStat)
REAL(8),INTENT(IN) :: Toler
CLASS(SupplyAdjustmentType) :: SupplyAdjustment
INTEGER,INTENT(OUT) :: iStat
!Local variables
CHARACTER(LEN=ModNameLen+12) :: ThisProcedure = ModName // 'SetTolerance'
!Initialize
iStat = 0
!Make sure tolerance is set to a value between 0 and 1
IF (Toler.GT.1.0 .OR. Toler.LT.0.0) THEN
CALL SetLastMessage('Supply adjustment tolerance must be a value between 0 and 1',iFatal,ThisProcedure)
iStat = -1
RETURN
END IF
!Set the variable
SupplyAdjustment%Tolerance = Toler
END SUBROUTINE SetTolerance
! -------------------------------------------------------------
! --- SET MAXIMUM NUMBER OF ADJUSTMENTS FOR PUMPING
! -------------------------------------------------------------
SUBROUTINE SetMaxPumpAdjustIter(SupplyAdjustment,iMaxIter,iStat)
CLASS(SupplyAdjustmentType) :: SupplyAdjustment
INTEGER,INTENT(IN) :: iMaxIter
INTEGER,INTENT(OUT) :: iStat
!Local variables
CHARACTER(LEN=ModNameLen+20) :: ThisProcedure = ModName // 'SetMaxPumpAdjustIter'
!Initialize
iStat = 0
!Make sure that iMaxIter is not less than 1
IF (iMaxIter .LE. 0) THEN
CALL SetLastMessage('Maximum supply adjustment iteration number must be greater than zero!',iFatal,ThisProcedure)
iStat = -1
RETURN
END IF
SupplyAdjustment%NMaxPumpAdjustIter = iMaxIter
END SUBROUTINE SetMaxPumpAdjustIter
! -------------------------------------------------------------
! --- SET SUPPLY ADJUSTMENT FLAG
! -------------------------------------------------------------
SUBROUTINE SetAdjustFlag(SupplyAdjustment,iAdjust,iStat)
CLASS(SupplyAdjustmentType) :: SupplyAdjustment
INTEGER,INTENT(IN) :: iAdjust
INTEGER,INTENT(OUT) :: iStat
!Local variables
CHARACTER(LEN=ModNameLen+13) :: ThisProcedure = ModName // 'SetAdjustFlag'
!Initialize
iStat = 0
!Make sure that adjustment flag is recognised
IF (iAdjust .NE. f_iAdjustNone) THEN
IF (iAdjust .NE. f_iAdjustPump) THEN
IF (iAdjust .NE. f_iAdjustDiver) THEN
IF (iAdjust .NE. f_iAdjustPumpDiver) THEN
CALL SetLastMessage('Supply adjustment flag to adjust pumping, diversions or both is not recognized!',iFatal,ThisProcedure)
iStat = -1
RETURN
END IF
END IF
END IF
END IF
SupplyAdjustment%iAdjust = iAdjust
!Set the flag to check if adjustment runs will be performed
IF (iAdjust .NE. f_iAdjustNone) THEN
SupplyAdjustment%lAdjust = .TRUE.
ELSE
SupplyAdjustment%lAdjust = .FALSE.
END IF
END SUBROUTINE SetAdjustFlag
! ******************************************************************
! ******************************************************************
! ******************************************************************
! ***
! *** DATA READER
! ***
! ******************************************************************
! ******************************************************************
! ******************************************************************
! -------------------------------------------------------------
! --- READ SUPPLY ADJUSTMENT SPECS
! -------------------------------------------------------------
SUBROUTINE SupplyAdjustment_ReadTSData(SupplyAdjustment,TimeStep,iStat)
CLASS(SupplyAdjustmentType) :: SupplyAdjustment
TYPE(TimeStepType),INTENT(IN) :: TimeStep
INTEGER,INTENT(OUT) :: iStat
!Local variables
INTEGER :: FileReadCode
!Return if no adjustment is asked for
IF (SupplyAdjustment%iAdjust .EQ. f_iAdjustNone) THEN
iStat = 0
RETURN
END IF
!Read data
CALL ReadTSData(TimeStep,'supply adjustment specs data',SupplyAdjustment%SpecFile,FileReadCode,iStat)
END SUBROUTINE SupplyAdjustment_ReadTSData
! ******************************************************************
! ******************************************************************
! ******************************************************************
! ***
! *** MISC. METHODS
! ***
! ******************************************************************
! ******************************************************************
! ******************************************************************
! -------------------------------------------------------------
! --- ADJUST SUPPLIES
! -------------------------------------------------------------
SUBROUTINE Adjust(SupplyAdjustment,AppGrid,RootZone,AppGW,AppStream,DiverDestConnector,WellDestConnector,ElemPumpDestConnector)
CLASS(SupplyAdjustmentType) :: SupplyAdjustment
TYPE(AppGridType),INTENT(IN) :: AppGrid
TYPE(RootZoneType),INTENT(IN) :: RootZone
TYPE(AppGWType) :: AppGW
TYPE(AppStreamType) :: AppStream
TYPE(SupplyDestinationConnectorType) :: DiverDestConnector,WellDestConnector,ElemPumpDestConnector
!Local variables
INTEGER :: NDiver,NPump
REAL(8),DIMENSION(SupplyAdjustment%NAdjustLocations) :: AgDiff,UrbDiff,AgDemand,UrbDemand,AgToler,UrbToler,AgSupply,UrbSupply
LOGICAL :: lAdjusted
!Return if there is no need to adjust
IF (SupplyAdjustment%iAdjust .EQ. f_iAdjustNone) RETURN
!Initialize
SupplyAdjustment%lAdjust = .TRUE.
!Inform user
CALL EchoProgress('Adjusting supplies to meet water demand')
!Get water demands
CALL RootZone%GetWaterDemand(f_iAg,AgDemand)
CALL RootZone%GetWaterDemand(f_iUrb,UrbDemand)
!Get water suppies
CALL RootZone%GetWaterSupply(AppGrid,f_iAg,AgSupply)
CALL RootZone%GetWaterSupply(AppGrid,f_iUrb,UrbSupply)
!Supply shortage (demand-supply) at each demand location
AgDiff = AgDemand - AgSupply
UrbDiff = UrbDemand - UrbSupply
!Supply adjustment tolerance at each demand location
AgToler = AgDemand * SupplyAdjustment%Tolerance
UrbToler = UrbDemand * SupplyAdjustment%Tolerance
!First adjust diversions
IF (IsDiversionsAdjustable(SupplyAdjustment,AppStream)) THEN
NDiver = AppStream%GetNDiver()
CALL AdjustDiversions(AppStream , &
DiverDestConnector , &
NDiver , &
AgToler , &
UrbToler , &
AgDiff , &
UrbDiff , &
SupplyAdjustment%SpecFile%iValues , &
SupplyAdjustment%iGlobalAdjustIter , &
SupplyAdjustment%iDiverAdjustIter , &
lAdjusted )
!If nothing is adjusted, is it possible to adjust other supplies?
IF (.NOT. lAdjusted) THEN
SupplyAdjustment%iDiverAdjustIter = AppStream%GetMaxDiversionRank() + 1
IF (.NOT. IsMoreAdjustmentPossible(SupplyAdjustment,AppGW,AppStream)) THEN
SupplyAdjustment%lAdjust = .FALSE.
RETURN
END IF
ELSE
RETURN
END IF
END IF
!Then adjust wells
IF (IsPumpingAdjustable(SupplyAdjustment,AppGW,f_iSupply_Well)) THEN
NPump = AppGW%GetNWells()
CALL AdjustPumping(AppGW , &
WellDestConnector , &
NPump , &
f_iSupply_Well , &
AgToler , &
UrbToler , &
AgDiff , &
UrbDiff , &
SupplyAdjustment%SpecFile%iValues , &
SupplyAdjustment%iGlobalAdjustIter , &
SupplyAdjustment%iWellPumpAdjustIter , &
lAdjusted )
!If nothing is adjusted, is it possible to adjust other supplies?
IF (.NOT. lAdjusted) THEN
SupplyAdjustment%iWellPumpAdjustIter = SupplyAdjustment%NMaxPumpAdjustIter + 1
IF (.NOT. IsMoreAdjustmentPossible(SupplyAdjustment,AppGW,AppStream)) THEN
SupplyAdjustment%lAdjust = .FALSE.
RETURN
END IF
ELSE
RETURN
END IF
END IF
!Finally adjust elemental pumping
IF (IsPumpingAdjustable(SupplyAdjustment,AppGW,f_iSupply_ElemPump)) THEN
NPump = AppGW%GetNElemPumps()
CALL AdjustPumping(AppGW , &
ElemPumpDestConnector , &
NPump , &
f_iSupply_ElemPump , &
AgToler , &
UrbToler , &
AgDiff , &
UrbDiff , &
SupplyAdjustment%SpecFile%iValues , &
SupplyAdjustment%iGlobalAdjustIter , &
SupplyAdjustment%iElemPumpAdjustIter , &
lAdjusted )
!If nothing is adjusted, is it possible to adjust other supplies?
IF (.NOT. lAdjusted) THEN
SupplyAdjustment%iElemPumpAdjustIter = SupplyAdjustment%NMaxPumpAdjustIter + 1
SupplyAdjustment%lAdjust = .FALSE.
END IF
RETURN
END IF
!If made to this point, no more adjustment is possible
SupplyAdjustment%lAdjust = .FALSE.
END SUBROUTINE Adjust
! -------------------------------------------------------------
! --- ADJUST DIVERSIONS TO MEET ELEMENT LEVEL DEMANDS
! -------------------------------------------------------------
SUBROUTINE AdjustDiversions(AppStream,DiverDestConnector,NDiver,AgToler,UrbToler,AgDiff,UrbDiff,iAdjustFlags,iGlobalAdjustIter,iDiverAdjustIter,lAdjusted)
TYPE(AppStreamType) :: AppStream
TYPE(SupplyDestinationConnectorType) :: DiverDestConnector
INTEGER,INTENT(IN) :: NDiver,iAdjustFlags(:)
REAL(8),INTENT(IN) :: AgToler(:),UrbToler(:),AgDiff(:),UrbDiff(:)
INTEGER :: iGlobalAdjustIter,iDiverAdjustIter
LOGICAL,INTENT(OUT) :: lAdjusted
!Local variables
INTEGER :: iAdjustFlagsLocal(0:SIZE(iAdjustFlags)),iColAdjust(NDiver), &
iDiverRank(NDiver),iDiverAdjustFlags(NDiver)
REAL(8) :: DeliRequired(NDiver),DeliMax(NDiver),DeliActual(NDiver),IrigFracs(NDiver)
!Initialize
iAdjustFlagsLocal(0) = 0
iAdjustFlagsLocal(1:) = iAdjustFlags
!Get diversions specs data
CALL AppStream%GetSupplyAdjustData(iDiverRank , &
iColAdjust , &
DeliRequired , &
DeliMax , &
DeliActual , &
IrigFracs )
iDiverAdjustFlags = iAdjustFlagsLocal(iColAdjust)
!Increment diversion adjustment counter by 1 until at least one diversion with that rank or higher exist
DO
iDiverAdjustIter = iDiverAdjustIter + 1
IF (iDiverAdjustIter .GT. AppStream%GetMaxDiversionRank()) RETURN
IF (.NOT. ANY(iDiverRank .EQ. iDiverAdjustIter)) CYCLE
IF (ANY(iDiverRank .GE. iDiverAdjustIter)) EXIT
END DO
!Adjust diversions
CALL AdjustSupplies(f_iSupply_Diversion , &
iDiverRank , &
iDiverAdjustIter , &
iDiverAdjustFlags , &
AgDiff , &
UrbDiff , &
AgToler , &
UrbToler , &
DeliActual , &
DeliMax , &
DiverDestConnector , &
DeliRequired , &
IrigFracs , &
lAdjusted )
!If adjusted, update the supply specs with stream object
IF (lAdjusted) THEN
CALL AppStream%SetSupplySpecs(DiverDestConnector,DeliRequired,IrigFracs,DiverDestConnector%SupplyToDestination)
!Increment global adjustment iteration number
iGlobalAdjustIter = iGlobalAdjustIter + 1
END IF
END SUBROUTINE AdjustDiversions
! -------------------------------------------------------------
! --- ADJUST WELL/ELEMENT PUMPING TO MEET ELEMENT LEVEL DEMANDS
! -------------------------------------------------------------
SUBROUTINE AdjustPumping(AppGW,PumpDestConnector,NPump,iSupplyType,AgToler,UrbToler,AgDiff,UrbDiff,iAdjustFlags,iGlobalAdjustIter,iPumpAdjustIter,lAdjusted)
TYPE(AppGWType) :: AppGW
TYPE(SupplyDestinationConnectorType) :: PumpDestConnector
INTEGER,INTENT(IN) :: NPump,iSupplyType,iAdjustFlags(:)
REAL(8),INTENT(IN) :: AgToler(:),UrbToler(:),AgDiff(:),UrbDiff(:)
INTEGER :: iGlobalAdjustIter,iPumpAdjustIter
LOGICAL,INTENT(OUT) :: lAdjusted
!Local variables
INTEGER :: iAdjustFlagsLocal(0:SIZE(iAdjustFlags)),iColAdjust(NPump),iPumpAdjustFlags(NPump)
INTEGER,PARAMETER :: iDummyArray(1) = [0]
REAL(8) :: PumpRequired(NPump),PumpMax(NPump),PumpActual(NPump),IrigFracs(NPump)
!Initialize
iAdjustFlagsLocal(0) = 0
iAdjustFlagsLocal(1:) = iAdjustFlags
!Get pumping specs data
CALL AppGW%GetSupplyAdjustData(iSupplyType , &
iColAdjust , &
PumpRequired , &
PumpMax , &
PumpActual , &
IrigFracs )
iPumpAdjustFlags = iAdjustFlagsLocal(iColAdjust)
!Adjust pumping
CALL AdjustSupplies(iSupplyType , &
iDummyArray , &
iPumpAdjustIter , &
iPumpAdjustFlags , &
AgDiff , &
UrbDiff , &
AgToler , &
UrbToler , &
PumpActual , &
PumpMax , &
PumpDestConnector , &
PumpRequired , &
IrigFracs , &
lAdjusted )
!If any pumping is adjusted...
IF (lAdjusted) THEN
!Update the supply specs with pumping object
CALL AppGW%SetSupplySpecs(PumpDestConnector,iSupplyType,PumpRequired,IrigFracs,PumpDestConnector%SupplyToDestination)
!Increment global and pumping specific adjustment iteration number
iGlobalAdjustIter = iGlobalAdjustIter + 1
iPumpAdjustIter = iPumpAdjustIter + 1
END IF
END SUBROUTINE AdjustPumping
! -------------------------------------------------------------
! --- ADJUST SUPPLIES
! -------------------------------------------------------------
SUBROUTINE AdjustSupplies(iSupplyType,iDiverRanks,iDiverAdjustIter,iAdjustFlags,AgDiff,UrbDiff,AgToler,UrbToler,SourcesActual,SourcesMax,SupplyDestConnector,SourcesRequired,IrigFracs,lAdjusted)
INTEGER,INTENT(IN) :: iSupplyType,iDiverRanks(:),iDiverAdjustIter,iAdjustFlags(:)
REAL(8),INTENT(IN) :: AgDiff(:),UrbDiff(:),AgToler(:),UrbToler(:)
REAL(8),INTENT(IN) :: SourcesActual(:),SourcesMax(:)
TYPE(SupplyDestinationConnectorType) :: SupplyDestConnector
REAL(8) :: SourcesRequired(:),IrigFracs(:)
LOGICAL,INTENT(OUT) :: lAdjusted
!Local variables
INTEGER :: indxDest,nAdjustable,nSupply,indxSupply
REAL(8) :: Diff,SourcesRequired_Original(SupplyDestConnector%NSupply),Toler,IrigFracs_Original(SupplyDestConnector%NSupply)
LOGICAL :: lAdjustSuppliesForADest(500),lAdjustedSupplies(SupplyDestConnector%NSupply)
!Initialize
lAdjusted = .FALSE.
lAdjustedSupplies = .FALSE.
SourcesRequired_Original = SourcesRequired
SourcesRequired = SourcesActual
IrigFracs_Original = IrigFracs
ASSOCIATE (pSupplyToDest => SupplyDestConnector%SupplyToDestination , &
pDestToSupply => SupplyDestConnector%DestinationToSupply )
!First convert supply to destination fractions into volumes
DO indxSupply=1,SupplyDestConnector%NSupply
pSupplyToDest(indxSupply)%SupplyToDestFracs_Ag = SourcesActual(indxSupply) * IrigFracs(indxSupply) * pSupplyToDest(indxSupply)%SupplyToDestFracs_Ag
pSupplyToDest(indxSupply)%SupplyToDestFracs_Urb = SourcesActual(indxSupply) * (1d0-IrigFracs(indxSupply)) * pSupplyToDest(indxSupply)%SupplyToDestFracs_Urb
END DO
!Iterate over destinations
Destination_Loop: &
DO indxDest=1,SupplyDestConnector%NDestination
nSupply = pDestToSupply(indxDest)%nSupply
!If there are no sources serving this destination, cycle
IF (nSupply .EQ. 0) CYCLE
!Adjust for ag demand
!--------------------
Diff = AgDiff(indxDest)
Toler = AgToler(indxDest)
Ag_Supply_Adjustment_Loop: &
DO
!Adjust if the demand-supply difference is greater than the tolerance
IF (ABS(Diff) .LE. Toler) EXIT
!Count adjustable supplies
CALL TagAdjustableSupplies(iSupplyType , &
Diff , &
f_iAg , &
iAdjustFlags , &
SourcesRequired_Original, &
SourcesRequired , &
SourcesActual , &
SourcesMax , &
iDiverRanks , &
iDiverAdjustIter , &
pDestToSupply(indxDest) , &
pSupplyToDest , &
lAdjustSuppliesForADest )
nAdjustable = COUNT(lAdjustSuppliesForADest(1:nSupply))
!Exit if there are no adjustable supplies
IF (nAdjustable .EQ. 0) EXIT
!Something is adjusted
lAdjusted = .TRUE.
!Tag the supplies as adjusted
DO indxSupply=1,nSupply
IF (.NOT. lAdjustSuppliesForADest(indxSupply)) CYCLE
lAdjustedSupplies(pDestToSupply(indxDest)%iSupplies(indxSupply)) = .TRUE.
END DO
!Adjust supply
CALL Adjust(f_iAg,Toler,lAdjustSuppliesForADest,SourcesMax,pDestToSupply(indxDest),pSupplyToDest,SourcesActual,SourcesRequired)
END DO Ag_Supply_Adjustment_Loop
!Adjust for urb demand
!--------------------
Diff = UrbDiff(indxDest)
Toler = UrbToler(indxDest)
Urb_Supply_Adjustment_Loop: &
DO
!Adjust if the demand-supply difference is greater than the tolerance
IF (ABS(Diff) .LE. Toler) EXIT
!Count adjustable supplies
CALL TagAdjustableSupplies(iSupplyType , &
Diff , &
f_iUrb , &
iAdjustFlags , &
SourcesRequired_Original, &
SourcesRequired , &
SourcesActual , &
SourcesMax , &
iDiverRanks , &
iDiverAdjustIter , &
pDestToSupply(indxDest) , &
pSupplyToDest , &
lAdjustSuppliesForADest )
nAdjustable = COUNT(lAdjustSuppliesForADest(1:nSupply))
!Exit if there are no adjustable supplies
IF (nAdjustable .EQ. 0) EXIT
!Something is adjusted
lAdjusted = .TRUE.
!Tag the supplies as adjusted
DO indxSupply=1,nSupply
IF (.NOT. lAdjustSuppliesForADest(indxSupply)) CYCLE
lAdjustedSupplies(pDestToSupply(indxDest)%iSupplies(indxSupply)) = .TRUE.
END DO
!Adjust supply
CALL Adjust(f_iUrb,Toler,lAdjustSuppliesForADest,SourcesMax,pDestToSupply(indxDest),pSupplyToDest,SourcesActual,SourcesRequired)
END DO Urb_Supply_Adjustment_Loop
END DO Destination_Loop
!Finally convert volumetric supply-to-destination connections to fractions
DO indxSupply=1,SupplyDestConnector%NSupply
IF (.NOT. lAdjustedSupplies(indxSupply)) THEN
SourcesRequired(indxSupply) = SourcesRequired_Original(indxSupply)
IrigFracs(indxSupply) = IrigFracs_Original(indxSupply)
ELSE
IF (SourcesRequired(indxSupply) .GT. 0.0) THEN
IrigFracs(indxSupply) = SUM(pSupplyToDest(indxSupply)%SupplyToDestFracs_Ag) / SourcesRequired(indxSupply)
ELSE
IrigFracs(indxSupply) = IrigFracs_Original(indxSupply)
END IF
END IF
IF (pSupplyToDest(indxSupply)%nDest .EQ. 1) THEN
pSupplyToDest(indxSupply)%SupplyToDestFracs_Ag = 1.0
pSupplyToDest(indxSupply)%SupplyToDestFracs_Urb = 1.0
ELSE
CALL NormalizeArray(pSupplyToDest(indxSupply)%SupplyToDestFracs_Ag)
CALL NormalizeArray(pSupplyToDest(indxSupply)%SupplyToDestFracs_Urb)
END IF
END DO
END ASSOCIATE
CONTAINS
! ############################################
! --- ADJUST SUPPLIES FOR AN ELEMENT
! ############################################
SUBROUTINE Adjust(iAdjustFor,Toler,lAdjustSupplies,SourcesMax,DestToSupply,SupplyToDest,SourcesActual,SourcesRequired)
INTEGER,INTENT(IN) :: iAdjustFor
REAL(8),INTENT(IN) :: Toler,SourcesActual(:),SourcesMax(:)
LOGICAL,INTENT(IN) :: lAdjustSupplies(:)
TYPE(DestinationToSupplyType),INTENT(IN) :: DestToSupply
TYPE(SupplyToDestinationType) :: SupplyToDest(:)
REAL(8) :: SourcesRequired(:)
!Local variables
INTEGER :: indxSupply,iSupply,indxInServedDest
REAL(8) :: rCorrection,rAdjustedSupply,rCheck,AgSupplyTotal, &
DestSupply_Ag_Old,DestSupply_Urb_Old,DestSupply_Ag_New, &
DestSupply_Urb_New
!Find correction
rCorrection = Diff / REAL(nAdjustable,8)
!Adjust each adjustable supply
Diff = 0.0
DO indxSupply=1,DestToSupply%nSupply
IF (.NOT. lAdjustSupplies(indxSupply)) CYCLE
iSupply = DestToSupply%iSupplies(indxSupply)
indxInServedDest = DestToSupply%iIndexInServedDest(indxSupply)
ASSOCIATE (pSupplyToDest => SupplyToDest(iSupply) )
DestSupply_Ag_Old = pSupplyToDest%SupplyToDestFracs_Ag(indxInServedDest)
DestSupply_Urb_Old = pSupplyToDest%SupplyToDestFracs_Urb(indxInServedDest)
IF (iAdjustFor .EQ. f_iAg) THEN
rAdjustedSupply = DestSupply_Ag_Old
ELSE
rAdjustedSupply = DestSupply_Urb_Old
END IF
!If the supply is being reduced
IF (rCorrection .LT. 0.0) THEN
!If Tolerance is zero, the demand is zero. Set the supply to zero
IF (Toler .EQ. 0.0) THEN
rAdjustedSupply = 0.0
ELSE
rCheck = rAdjustedSupply + rCorrection
!Adjusted supply cannot be less than zero
IF (rCheck .LT. 0.0) THEN
Diff = Diff + rCheck
rAdjustedSupply = 0.0
ELSE
rAdjustedSupply = rCheck
END IF
END IF
!If the supply is being increased
ELSE
!Don't do anything special; if the overall SourceRequired is greater than SourceMax,
!this will be taken care of during routing and any unmet demand will be taken care
!of in the next supply adjustment iteration
rAdjustedSupply = rAdjustedSupply + rCorrection
END IF
!Store adjusted supplies
IF (iAdjustFor .EQ. f_iAg) THEN
DestSupply_Ag_New = MIN(rAdjustedSupply , SourcesMax(iSupply))
DestSupply_Urb_New = DestSupply_Urb_Old
ELSE
DestSupply_Ag_New = DestSupply_Ag_Old
DestSupply_Urb_New = MIN(rAdjustedSupply , SourcesMax(iSupply))
END IF
SourcesRequired(iSupply) = SourcesRequired(iSupply) - (DestSupply_Ag_Old + DestSupply_Urb_Old) + (DestSupply_Ag_New + DestSupply_Urb_New)
SourcesRequired(iSupply) = MAX(0d0 , SourcesRequired(iSupply)) !Check for round-off errors; sometimes sources become a tiny negative value
pSupplyToDest%SupplyToDestFracs_Ag(indxInServedDest) = DestSupply_Ag_New
pSupplyToDest%SupplyToDestFracs_Urb(indxInServedDest) = DestSupply_Urb_New
END ASSOCIATE
END DO
END SUBROUTINE Adjust
END SUBROUTINE AdjustSupplies
! -------------------------------------------------------------
! --- TAG ADJUSTABLE SUPPLIES
! -------------------------------------------------------------
SUBROUTINE TagAdjustableSupplies(iSupplyType,Diff,iAdjustFor,iAdjustFlags,SourcesRequired_Old,SourcesRequired_New,SourcesActual,MaxSources,iDiverRanks,iDiverAdjustIter,DestToSupply,SupplyToDest,lAdjustSupplies)
INTEGER,INTENT(IN) :: iSupplyType,iAdjustFor,iDiverAdjustIter,iDiverRanks(:),iAdjustFlags(:)
REAL(8),INTENT(IN) :: Diff,SourcesRequired_Old(:),SourcesRequired_New(:),SourcesActual(:),MaxSources(:)
TYPE(DestinationToSupplyType),INTENT(IN) :: DestToSupply
TYPE(SupplyToDestinationType),INTENT(IN) :: SupplyToDest(:)
LOGICAL,INTENT(OUT) :: lAdjustSupplies(:)
!Local variables
INTEGER :: indxSupply,iAdjustSupplyFor,iSupply,indxInServedDest
REAL(8) :: Supply
!Initialize
lAdjustSupplies(1:DestToSupply%nSupply) = .TRUE.
!Tag the adjustable supplies
DO indxSupply=1,DestToSupply%nSupply
iSupply = DestToSupply%iSupplies(indxSupply)
indxInServedDest = DestToSupply%iIndexInServedDest(indxSupply)
!Supply must be greater than or equal to zero to be adjustable
IF (SourcesRequired_Old(iSupply) .LT. 0.0) THEN
lAdjustSupplies(indxSupply) = .FALSE.
CYCLE
END IF
!Is the supply tagged for adjustment?
iAdjustSupplyFor = iAdjustFlags(iSupply)
IF (iAdjustFor .EQ. f_iAg) THEN
IF (iAdjustSupplyFor.EQ.f_iAdjustForUrb .OR. iAdjustSupplyFor.EQ.f_iAdjustForNone) THEN
lAdjustSupplies(indxSupply) = .FALSE.
CYCLE
END IF
ELSE
IF (iAdjustSupplyFor.EQ.f_iAdjustForAg .OR. iAdjustSupplyFor.EQ.f_iAdjustForNone) THEN
lAdjustSupplies(indxSupply) = .FALSE.
CYCLE
END IF
END IF
!Is the rank of the diversion greater than or equal to the rank being considered?
IF (iSupplyType .EQ. f_iSupply_Diversion) THEN
IF (iDiverRanks(indxSupply) .LT. iDiverAdjustIter) THEN
lAdjustSupplies(indxSupply) = .FALSE.
CYCLE
END IF
END IF
!If the supply needs to be decreased...
IF (Diff .LT. 0.0) THEN
IF (iAdjustFor .EQ. f_iAg) THEN
Supply = SupplyToDest(iSupply)%SupplyToDestFracs_Ag(indxInServedDest)
ELSE
Supply = SupplyToDest(iSupply)%SupplyToDestFracs_Urb(indxInServedDest)
END IF
!Is the original supply greater than zero?
IF (Supply .EQ. 0.0) THEN
lAdjustSupplies(indxSupply) = .FALSE.
CYCLE
END IF
!If the supply needs to be increased...
ELSE
!Is the water at source less than the maximum amount?
IF (SourcesRequired_New(iSupply) .GE. MaxSources(iSupply)) THEN
lAdjustSupplies(indxSupply) = .FALSE.
CYCLE
END IF
!Is the actual source less than required source indicating that there is not enough water at the source?
IF (SourcesRequired_Old(iSupply) .GT. SourcesActual(iSupply)) THEN
lAdjustSupplies(indxSupply) = .FALSE.
CYCLE
END IF
END IF
END DO
END SUBROUTINE TagAdjustableSupplies
! -------------------------------------------------------------
! --- RESET THE STATE OF THE SUPPLY ADJUSTMENT OBJECT
! -------------------------------------------------------------
SUBROUTINE ResetState(SupplyAdjustment)
CLASS(SupplyAdjustmentType) :: SupplyAdjustment
!Local variables
TYPE(SupplyAdjustmentType) :: DefaultData
!No need to do anything if supply adjustment is not on
IF (SupplyAdjustment%iAdjust .EQ. f_iAdjustNone) RETURN
SupplyAdjustment%iWellPumpAdjustIter = DefaultData%iWellPumpAdjustIter
SupplyAdjustment%iElemPumpAdjustIter = DefaultData%iElemPumpAdjustIter
SupplyAdjustment%iDiverAdjustIter = DefaultData%iDiverAdjustIter
SupplyAdjustment%iGlobalAdjustIter = DefaultData%iGlobalAdjustIter
SupplyAdjustment%lAdjust = .TRUE.
END SUBROUTINE ResetState
! -------------------------------------------------------------
! --- CAN DIVERSIONS BE ADJUSTED?
! -------------------------------------------------------------
FUNCTION IsDiversionsAdjustable(SupplyAdjustment,AppStream) RESULT(lAdjustable)
TYPE(SupplyAdjustmentType),INTENT(IN) :: SupplyAdjustment
TYPE(AppStreamType),INTENT(IN) :: AppStream
LOGICAL :: lAdjustable
!Local variables
INTEGER :: NDiver,indxDiver,ErrorCode
INTEGER,ALLOCATABLE :: iColAdjust(:)
LOGICAL :: lAdjusting
!Initialize
lAdjustable = .FALSE.
NDiver = AppStream%GetNDiver()
!Are there any diversions defined?
IF (NDiver .EQ. 0) RETURN
!Has the user asked for diversion adjustment?
IF (SupplyAdjustment%iAdjust.EQ.f_iAdjustNone .OR. SupplyAdjustment%iAdjust.EQ.f_iAdjustPump) RETURN
!Is the iteration number less than the maximum?
IF (SupplyAdjustment%iDiverAdjustIter .GT. AppStream%GetMaxDiversionRank()) RETURN
!Are any of the diversions adjustable for the currrent time step?
ALLOCATE (iColAdjust(NDiver))
CALL AppStream%GetiColAdjust(iColAdjust)
lAdjusting = .FALSE.
DO indxDiver=1,NDiver
IF (iColAdjust(indxDiver) .EQ. 0) CYCLE
IF (SupplyAdjustment%SpecFile%iValues(iColAdjust(indxDiver)) .NE. f_iAdjustForNone) THEN
lAdjusting = .TRUE.
EXIT
END IF
END DO
DEALLOCATE (iColAdjust ,STAT=ErrorCode)
IF (.NOT. lAdjusting) RETURN
!If made to to this point, diversions are adjustable
lAdjustable = .TRUE.
END FUNCTION IsDiversionsAdjustable
! -------------------------------------------------------------
! --- CAN PUMPING BE ADJUSTED?
! -------------------------------------------------------------
FUNCTION IsPumpingAdjustable(SupplyAdjustment,AppGW,iSupplyType) RESULT(lAdjustable)
TYPE(SupplyAdjustmentType),INTENT(IN) :: SupplyAdjustment
TYPE(AppGWType),INTENT(IN) :: AppGW
INTEGER,INTENT(IN) :: iSupplyType
LOGICAL :: lAdjustable
!Local variables
INTEGER :: iIter,NPumps,indxPump,iPumpType,ErrorCode
INTEGER,ALLOCATABLE :: iColAdjust(:)
LOGICAL :: lAdjusting
!Initialize
lAdjustable = .FALSE.
SELECT CASE (iSupplyType)
CASE (f_iSupply_Well)
NPumps = AppGW%GetNWells()
iIter = SupplyAdjustment%iWellPumpAdjustIter
iPumpType = f_iPump_Well
CASE (f_iSupply_ElemPump)
NPumps = AppGW%GetNElemPumps()
iIter = SupplyAdjustment%iElemPumpAdjustIter
iPumpType = f_iPump_ElemPump
END SELECT
!Are there any pumping defined?
IF (NPumps .EQ. 0) RETURN
!Has the user asked for pumping adjustment?
IF (SupplyAdjustment%iAdjust.EQ.f_iAdjustNone .OR. SupplyAdjustment%iAdjust.EQ.f_iAdjustDiver) RETURN
!Is the iteration number less than the maximum?
IF (iIter .GE. SupplyAdjustment%nMaxPumpAdjustIter) RETURN
!Are any of the wells/element pumps adjustable for the currrent time step?
ALLOCATE (iColAdjust(NPumps))
CALL AppGW%GetiColAdjust(iPumpType,iColAdjust)
lAdjusting = .FALSE.
DO indxPump=1,NPumps
IF (iColAdjust(indxPump) .EQ. 0) CYCLE
IF (SupplyAdjustment%SpecFile%iValues(iColAdjust(indxPump)) .NE. f_iAdjustForNone) THEN
lAdjusting = .TRUE.
EXIT
END IF
END DO
DEALLOCATE (iColAdjust ,STAT=ErrorCode)
IF (.NOT. lAdjusting) RETURN
!If made to to this point, pumping is adjustable
lAdjustable = .TRUE.
END FUNCTION IsPumpingAdjustable
! -------------------------------------------------------------
! --- CAN MORE SUPPLIES BE ADJUSTED?
! -------------------------------------------------------------
FUNCTION IsMoreAdjustmentPossible(SupplyAdjustment,AppGW,AppStream) RESULT(lPossible)
TYPE(SupplyAdjustmentType),INTENT(IN) :: SupplyAdjustment
TYPE(AppGWType),INTENT(IN) :: AppGW
TYPE(AppStreamType),INTENT(IN) :: AppStream
LOGICAL :: lPossible
!Initialize
lPossible = .FALSE.
!Any diversions adjustable?
IF (IsDiversionsAdjustable(SupplyAdjustment,AppStream)) THEN
lPossible = .TRUE.
RETURN
END IF
!Any wells adjustable?
IF (IsPumpingAdjustable(SupplyAdjustment,AppGW,f_iSupply_Well)) THEN
lPossible = .TRUE.
RETURN
END IF
!Any element pumping adjustable?
IF (IsPumpingAdjustable(SupplyAdjustment,AppGW,f_iSupply_ElemPump)) lPossible = .TRUE.
END FUNCTION IsMoreAdjustmentPossible
END MODULE | code/SourceCode/Package_Supply/SupplyAdjustment.f90 |
! Double precision
integer, parameter:: dp=kind(0.d0)
! Parameters
integer, intent(in) :: ndim, nfun
real(dp), intent(in) :: z(ndim)
real(dp), intent(out) :: f(nfun)
! Globar variables
common /gvars/ Pi, t, mu, x0, epsf, V, Uc, Uf, Gkinv, Gkqinv
common /freq/ omega, qx, qy
real(dp) :: Pi, t, mu, x0, epsf, V, Uc, Uf, qx, qy
complex(dp) :: omega, Gkinv(16), Gkqinv(16)
! Local variables
integer :: status, log=10
real(dp) :: kx, ky, kqx, kqy, &
epsk, epskpQ, epskq, epskqpQ, &
chik, chikq, chikpQ, chikqpQ
complex(dp) :: Gk(16), Gkq(16)
! Interface for called procedures
interface
subroutine invert4x4(m, invOut, fail)
implicit none
complex(kind=8), dimension(16), intent(in) :: m
complex(kind=8), dimension(16), intent(out) :: invOut
integer, intent(out) :: fail
end subroutine invert4x4
end interface | inc/sG0.f90 |
!======================================================================!
SUBROUTINE CalcMn(n0, n1)
!----------------------------------------------------------------------!
! Calculates time averaged velocity and velocity fluctuations. !
!----------------------------------------------------------------------!
!------------------------------[Modules]-------------------------------!
USE all_mod
USE pro_mod
USE les_mod
USE rans_mod
!----------------------------------------------------------------------!
IMPLICIT NONE
!-----------------------------[Parameters]-----------------------------!
INTEGER :: n0, n1
!-------------------------------[Locals]-------------------------------!
INTEGER :: c, n
!--------------------------------[CVS]---------------------------------!
! $Id: CalcMn.f90,v 1.17 2008/12/05 13:22:06 IUS\mhadziabdic Exp $
! $Source: /home/IUS/mhadziabdic/.CVSROOT/T-Rex/Process/CalcMn.f90,v $
!======================================================================!
n=n1-n0
if(n > -1) then
do c=-NbC,NC
!-----------------------!
! mean values !
!-----------------------!
U % mean(c) = ( U % mean(c) * (1.*n) + U % n(c) ) / (1.*(n+1))
V % mean(c) = ( V % mean(c) * (1.*n) + V % n(c) ) / (1.*(n+1))
W % mean(c) = ( W % mean(c) * (1.*n) + W % n(c) ) / (1.*(n+1))
P % mean(c) = ( P % mean(c) * (1.*n) + P % n(c) ) / (1.*(n+1))
!------------------------------!
! fluctuating values !
!------------------------------!
uu % mean(c) = ( uu % mean(c)*(1.*n) + U % n(c) * U % n(c) ) &
/ (1.*(n+1))
vv % mean(c) = ( vv % mean(c)*(1.*n) + V % n(c) * V % n(c) ) &
/ (1.*(n+1))
ww % mean(c) = ( ww % mean(c)*(1.*n) + W % n(c) * W % n(c) ) &
/ (1.*(n+1))
uv % mean(c) = ( uv % mean(c)*(1.*n) + U % n(c) * V % n(c) ) &
/ (1.*(n+1))
uw % mean(c) = ( uw % mean(c)*(1.*n) + U % n(c) * W % n(c) ) &
/ (1.*(n+1))
vw % mean(c) = ( vw % mean(c)*(1.*n) + V % n(c) * W % n(c) ) &
/ (1.*(n+1))
VISt_mean(c) = ( VISt_mean(c)*(1.*n) + VISt(c) ) &
/ (1.*(n+1))
if(HOT==YES) then
T % mean(c) = ( T % mean(c) * (1.*n) + T % n(c) ) / (1.*(n+1))
TT % mean(c) = ( TT % mean(c)*(1.*n) + T % n(c) * T % n(c) ) &
/ (1.*(n+1))
uT % mean(c) = ( uT % mean(c)*(1.*n) + u % n(c) * T % n(c) ) &
/ (1.*(n+1))
vT % mean(c) = ( vT % mean(c)*(1.*n) + v % n(c) * T % n(c) ) &
/ (1.*(n+1))
wT % mean(c) = ( wT % mean(c)*(1.*n) + w % n(c) * T % n(c) ) &
/ (1.*(n+1))
end if
end do
end if
RETURN
END SUBROUTINE CalcMn
| Process/CalcMn.f90 |