repo_name
stringlengths 7
81
| path
stringlengths 4
224
| copies
stringclasses 221
values | size
stringlengths 4
7
| content
stringlengths 975
1.04M
| license
stringclasses 15
values |
---|---|---|---|---|---|
prool/ccx_prool | CalculiX/ccx_2.17/src/designvariabless.f | 1 | 3623 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2020 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 designvariabless(inpc,textpart,tieset,tietol,istep,
& istat,n,iline,ipol,inl,ipoinp,inp,ntie,ntie_,ipoinpc,
& set,nset,ier)
!
! reading the input deck: *DESIGNVARIABLES
!
implicit none
!
character*1 inpc(*)
character*81 tieset(3,*),set(*)
character*132 textpart(16)
!
integer istep,istat,n,i,key,ipos,iline,ipol,inl,ipoinp(2,*),
& inp(3,*),ntie,ntie_,ipoinpc(0:*),nset,itype,ier
!
real*8 tietol(3,*)
!
! Check of correct position in Inputdeck
!
if(istep.gt.0) then
write(*,*) '*ERROR reading *DESIGN VARIABLES: *DESIGNVARIABLES'
write(*,*) ' should be placed before all step definitions'
ier=1
return
endif
!
! Check of correct number of ties
!
ntie=ntie+1
if(ntie.gt.ntie_) then
write(*,*) '*ERROR reading *DESIGN VARIABLES: increase ntie_'
ier=1
return
endif
!
! Read in *DESIGNVARIABLES
!
itype=0
do i=2,n
if(textpart(i)(1:5).eq.'TYPE=') then
read(textpart(i)(6:85),'(a80)',iostat=istat)
& tieset(1,ntie)(1:80)
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*DESIGNVARIABLE%",ier)
return
endif
itype=1
endif
enddo
!
if(itype.eq.0) then
write(*,*)
&'*ERROR reading *DESIGN VARIABLES: type is lacking'
call inputerror(inpc,ipoinpc,iline,
& "*DESIGNVARIABLE%",ier)
return
endif
!
! Add "D" at the end of the name of the designvariable keyword
!
tieset(1,ntie)(81:81)='D'
!
if(tieset(1,ntie)(1:10).eq.'COORDINATE') then
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) then
write(*,*)
&'*ERROR reading *DESIGN VARIABLES: definition'
write(*,*) ' is not complete.'
ier=1
return
endif
!
! Read the name of the design variable node set
!
tieset(2,ntie)(1:81)=textpart(1)(1:81)
ipos=index(tieset(2,ntie),' ')
tieset(2,ntie)(ipos:ipos)='N'
!
! Check existence of the node set
!
do i=1,nset
if(set(i).eq.tieset(2,ntie)) exit
enddo
if(i.gt.nset) then
write(*,*) '*ERROR reading *DESIGN VARIABLES'
write(*,*) 'node set ',tieset(2,ntie)(1:ipos-1),
& 'does not exist. Card image:'
call inputerror(inpc,ipoinpc,iline,
& "*DESIGN VARIABLES%",ier)
return
endif
endif
!
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
!
return
end
| gpl-2.0 |
techno/gcc-mist32 | gcc/testsuite/gfortran.dg/deferred_type_param_5.f90 | 136 | 1180 | ! { dg-do compile }
!
! PR fortran/49110
! PR fortran/52843
!
! Based on a contributed code by jwmwalrus@gmail.com
!
! Before, character(len=:) result variable were rejected in PURE functions.
!
module mod1
use iso_c_binding
implicit none
contains
pure function c_strlen(str)
character(KIND = C_CHAR), intent(IN) :: str(*)
integer :: c_strlen,i
i = 1
do
if (i < 1) then
c_strlen = 0
return
end if
if (str(i) == c_null_char) exit
i = i + 1
end do
c_strlen = i - 1
end function c_strlen
pure function c2fstring(cbuffer) result(string)
character(:), allocatable :: string
character(KIND = C_CHAR), intent(IN) :: cbuffer(*)
integer :: i
continue
string = REPEAT(' ', c_strlen(cbuffer))
do i = 1, c_strlen(cbuffer)
if (cbuffer(i) == C_NULL_CHAR) exit
string(i:i) = cbuffer(i)
enddo
string = TRIM(string)
end function
end module mod1
use mod1
character(len=:), allocatable :: str
str = c2fstring("ABCDEF"//c_null_char//"GHI")
if (len(str) /= 6 .or. str /= "ABCDEF") call abort()
end
| gpl-2.0 |
prool/ccx_prool | ARPACK/EXAMPLES/BAND/dnbdr2.f | 3 | 12107 | program dnbdr2
c
c ... Construct matrices A in LAPACK-style band form.
c The matrix A is derived from the discretization of
c the 2-d convection-diffusion operator
c
c -Laplacian(u) + rho*partial(u)/partial(x).
c
c on the unit square with zero Dirichlet boundary condition
c using standard central difference.
c
c ... Define the shift SIGMA = (SIGMAR, SIGMAI).
c
c ... Call DNBAND to find eigenvalues LAMBDA closest to SIGMA
c such that
c A*x = LAMBDA*x.
c
c ... Use mode 3 of DNAUPD.
c
c\BeginLib
c
c\Routines called:
c dnband ARPACK banded eigenproblem solver.
c dlapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully.
c dlaset LAPACK routine to initialize a matrix to zero.
c daxpy Level 1 BLAS that computes y <- alpha*x+y.
c dnrm2 Level 1 BLAS that computes the norm of a vector.
c dgbmv Level 2 BLAS that computes the band matrix vector product
c
c\Author
c Richard Lehoucq
c Danny Sorensen
c Chao Yang
c Dept. of Computational &
c Applied Mathematics
c Rice University
c Houston, Texas
c
c\SCCS Information: %Z%
c FILE: %M% SID: %I% DATE OF SID: %G% RELEASE: %R%
c
c\Remarks
c 1. None
c
c\EndLib
c
c---------------------------------------------------------------------
c
c %-------------------------------------%
c | Define leading dimensions for all |
c | arrays. |
c | MAXN - Maximum size of the matrix |
c | MAXNEV - Maximum number of |
c | eigenvalues to be computed |
c | MAXNCV - Maximum number of Arnoldi |
c | vectors stored |
c | MAXBDW - Maximum bandwidth |
c %-------------------------------------%
c
integer maxn, maxnev, maxncv, maxbdw, lda,
& lworkl, ldv
parameter ( maxn = 1000, maxnev = 25, maxncv=50,
& maxbdw=50, lda = maxbdw, ldv = maxn )
c
c %--------------%
c | Local Arrays |
c %--------------%
c
integer iparam(11), iwork(maxn)
logical select(maxncv)
Double precision
& a(lda,maxn), m(lda,maxn), rfac(lda,maxn),
& workl(3*maxncv*maxncv+6*maxncv), workd(3*maxn),
& workev(3*maxncv), v(ldv, maxncv),
& resid(maxn), d(maxncv, 3), ax(maxn)
Complex*16
& cfac(lda, maxn), workc(maxn)
c
c %---------------%
c | Local Scalars |
c %---------------%
c
character which*2, bmat
integer nev, ncv, ku, kl, info, i, j, ido,
& n, nx, lo, idiag, isub, isup, mode, maxitr,
& nconv
logical rvec, first
Double precision
& tol, rho, h2, h, sigmar, sigmai
c
c %------------%
c | Parameters |
c %------------%
c
Double precision
& one, zero, two
parameter (one = 1.0D+0, zero = 0.0D+0,
& two = 2.0D+0)
c
c %-----------------------------%
c | BLAS & LAPACK routines used |
c %-----------------------------%
c
Double precision
& dlapy2, dnrm2
external dlapy2, dnrm2, daxpy, dgbmv
c
c %--------------------%
c | Intrinsic function |
c %--------------------%
c
intrinsic abs
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
c
c %-------------------------------------------------%
c | The number NX is the number of interior points |
c | in the discretization of the 2-dimensional |
c | convection-diffusion operator on the unit |
c | square with zero Dirichlet boundary condition. |
c | The number N(=NX*NX) is the dimension of the |
c | matrix. A standard eigenvalue problem is |
c | solved (BMAT = 'I'). NEV is the number of |
c | eigenvalues (closest to (SIGMAR,SIGMAI)) to be |
c | approximated. Since the shift-invert moded is |
c | used, WHICH is set to 'LM'. The user can modify |
c | NX, NEV, NCV, SIGMAR, SIGMAI to solve problems |
c | of different sizes, and to get different parts |
c | the spectrum. However, The following conditions |
c | must be satisfied: |
c | N <= MAXN |
c | NEV <= MAXNEV |
c | NEV + 2 <= NCV <= MAXNCV |
c %-------------------------------------------------%
c
nx = 10
n = nx*nx
nev = 4
ncv = 20
if ( n .gt. maxn ) then
print *, ' ERROR with _NBDR2: N is greater than MAXN '
go to 9000
else if ( nev .gt. maxnev ) then
print *, ' ERROR with _NBDR2: NEV is greater than MAXNEV '
go to 9000
else if ( ncv .gt. maxncv ) then
print *, ' ERROR with _NBDR2: NCV is greater than MAXNCV '
go to 9000
end if
bmat = 'I'
which = 'LM'
sigmar = 1.0D+4
sigmai = 0.0D+0
c
c %-----------------------------------------------------%
c | The work array WORKL is used in DNAUPD as |
c | workspace. Its dimension LWORKL is set as |
c | illustrated below. The parameter TOL determines |
c | the stopping criterion. If TOL<=0, machine |
c | precision is used. The variable IDO is used for |
c | reverse communication, and is initially set to 0. |
c | Setting INFO=0 indicates that a random vector is |
c | generated in DNAUPD to start the Arnoldi iteration. |
c %-----------------------------------------------------%
c
lworkl = 3*ncv**2+6*ncv
tol = zero
ido = 0
info = 0
c
c %---------------------------------------------------%
c | IPARAM(3) specifies the maximum number of Arnoldi |
c | iterations allowed. Mode 3 of DNAUPD is used |
c | (IPARAM(7) = 3). All these options can be changed |
c | by the user. For details, see the documentation |
c | in DNBAND. |
c %---------------------------------------------------%
c
maxitr = 300
mode = 3
c
iparam(3) = maxitr
iparam(7) = mode
c
c %----------------------------------------%
c | Construct the matrix A in LAPACK-style |
c | banded form. |
c %----------------------------------------%
c
c %-------------------------------------%
c | KU, KL are number of superdiagonals |
c | and subdiagonals within the band of |
c | matrices A. |
c %-------------------------------------%
c
kl = nx
ku = nx
call dlaset('A', 2*kl+ku+1, n, zero, zero, a, lda)
call dlaset('A', 2*kl+ku+1, n, zero, zero, m, lda)
call dlaset('A', 2*kl+ku+1, n, zero, zero, rfac, lda)
c
c %---------------%
c | Main diagonal |
c %---------------%
c
h = one / dble(nx+1)
h2 = h*h
c
idiag = kl+ku+1
do 30 j = 1, n
a(idiag,j) = 4.0D+0 / h2
30 continue
c
c %-------------------------------------%
c | First subdiagonal and superdiagonal |
c %-------------------------------------%
c
isup = kl+ku
isub = kl+ku+2
rho = 1.0D+1
do 50 i = 1, nx
lo = (i-1)*nx
do 40 j = lo+1, lo+nx-1
a(isub,j+1) = -one/h2 + rho/two/h
a(isup,j) = -one/h2 - rho/two/h
40 continue
50 continue
c
c %------------------------------------%
c | KL-th subdiagonal and KU-th super- |
c | diagonal. |
c %------------------------------------%
c
isup = kl+1
isub = 2*kl+ku+1
do 80 i = 1, nx-1
lo = (i-1)*nx
do 70 j = lo+1, lo+nx
a(isup,nx+j) = -one / h2
a(isub,j) = -one / h2
70 continue
80 continue
c
c %------------------------------------------------%
c | Call ARPACK banded solver to find eigenvalues |
c | and eigenvectors. The real parts of the |
c | eigenvalues are returned in the first column |
c | of D, the imaginary parts are returned in the |
c | second column of D. Eigenvectors are returned |
c | in the first NCONV (=IPARAM(5)) columns of V. |
c %------------------------------------------------%
c
rvec = .true.
call dnband(rvec, 'A', select, d, d(1,2), v, ldv, sigmar,
& sigmai, workev, n, a, m, lda, rfac, cfac, kl, ku,
& which, bmat, nev, tol, resid, ncv, v, ldv, iparam,
& workd, workl, lworkl, workc, iwork, info)
c
if ( info .eq. 0) then
c
c %-----------------------------------%
c | Print out convergence information |
c %-----------------------------------%
c
nconv = iparam(5)
c
print *, ' '
print *, ' _NBDR2 '
print *, ' ====== '
print *, ' '
print *, ' The size of the matrix is ', n
print *, ' Number of eigenvalue requested is ', nev
print *, ' The number of Arnoldi vectors generated',
& ' (NCV) is ', ncv
print *, ' The number of converged Ritz values is ',
& nconv
print *, ' What portion of the spectrum ', which
print *, ' The number of Implicit Arnoldi ',
& ' update taken is ', iparam(3)
print *, ' The number of OP*x is ', iparam(9)
print *, ' The convergence tolerance is ', tol
print *, ' '
c
c %----------------------------%
c | Compute the residual norm. |
c | || A*x - lambda*x || |
c %----------------------------%
c
first = .true.
do 90 j = 1, nconv
c
if ( d(j,2) .eq. zero ) then
c
c %--------------------%
c | Ritz value is real |
c %--------------------%
c
call dgbmv('Notranspose', n, n, kl, ku, one,
& a(kl+1,1), lda, v(1,j), 1, zero,
& ax, 1)
call daxpy(n, -d(j,1), v(1,j), 1, ax, 1)
d(j,3) = dnrm2(n, ax, 1)
d(j,3) = d(j,3) / abs(d(j,1))
c
else if ( first ) then
c
c %------------------------%
c | Ritz value is complex |
c | Residual of one Ritz |
c | value of the conjugate |
c | pair is computed. |
c %------------------------%
c
call dgbmv('Notranspose', n, n, kl, ku, one,
& a(kl+1,1), lda, v(1,j), 1, zero,
& ax, 1)
call daxpy(n, -d(j,1), v(1,j), 1, ax, 1)
call daxpy(n, d(j,2), v(1,j+1), 1, ax, 1)
d(j,3) = dnrm2(n, ax, 1)
call dgbmv('Notranspose', n, n, kl, ku, one,
& a(kl+1,1), lda, v(1,j+1), 1, zero,
& ax, 1)
call daxpy(n, -d(j,1), v(1,j+1), 1, ax, 1)
call daxpy(n, -d(j,2), v(1,j), 1, ax, 1)
d(j,3) = dlapy2( d(j,3), dnrm2(n, ax, 1) )
d(j,3) = d(j,3) / dlapy2(d(j,1),d(j,2))
d(j+1,3) = d(j,3)
first = .false.
else
first = .true.
end if
c
90 continue
call dmout(6, nconv, 3, d, maxncv, -6,
& 'Ritz values (Real,Imag) and relative residuals')
else
c
c %-------------------------------------%
c | Either convergence failed, or there |
c | is error. Check the documentation |
c | for DNBAND. |
c %-------------------------------------%
c
print *, ' '
print *, ' Error with _nband, info= ', info
print *, ' Check the documentation of _nband '
print *, ' '
c
end if
c
9000 end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.17/src/sigini.f | 1 | 1905 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2020 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 sigini(sigma,coords,ntens,ncrds,noel,npt,layer,
& kspt,lrebar,rebarn)
!
! user subroutine sigini
!
! INPUT:
!
! coords coordinates of the integration point
! ntens number of stresses to be defined
! ncrds number of coordinates
! noel element number
! npt integration point number
! layer currently not used
! kspt currently not used
! lrebar currently not used (value: 0)
! rebarn currently not used
!
! OUTPUT:
!
! sigma(1..ntens) residual stress values in the integration
! point. If ntens=6 the order of the
! components is 11,22,33,12,13,23
!
implicit none
!
character*80 rebarn
integer ntens,ncrds,noel,npt,layer,kspt,lrebar
real*8 sigma(*),coords(*)
!
sigma(1)=-100.d0*coords(2)
sigma(2)=-100.d0*coords(2)
sigma(3)=-100.d0*coords(2)
sigma(4)=0.d0
sigma(5)=0.d0
sigma(6)=0.d0
!
return
end
| gpl-2.0 |
freedesktop-unofficial-mirror/gstreamer-sdk__gcc | gcc/testsuite/gfortran.dg/achar_5.f90 | 181 | 1818 | ! { dg-do compile }
!
program test
print *, char(255)
print *, achar(255)
print *, char(255,kind=1)
print *, achar(255,kind=1)
print *, char(255,kind=4)
print *, achar(255,kind=4)
print *, char(0)
print *, achar(0)
print *, char(0,kind=1)
print *, achar(0,kind=1)
print *, char(0,kind=4)
print *, achar(0,kind=4)
print *, char(297) ! { dg-error "too large for the collating sequence" }
print *, achar(297) ! { dg-error "too large for the collating sequence" }
print *, char(297,kind=1) ! { dg-error "too large for the collating sequence" }
print *, achar(297,kind=1) ! { dg-error "too large for the collating sequence" }
print *, char(297,kind=4)
print *, achar(297,kind=4)
print *, char(-1) ! { dg-error "negative" }
print *, achar(-1) ! { dg-error "negative" }
print *, char(-1,kind=1) ! { dg-error "negative" }
print *, achar(-1,kind=1) ! { dg-error "negative" }
print *, char(-1,kind=4) ! { dg-error "negative" }
print *, achar(-1,kind=4) ! { dg-error "negative" }
print *, char(huge(0_8)) ! { dg-error "too large for the collating sequence" }
print *, achar(huge(0_8)) ! { dg-error "too large for the collating sequence" }
print *, char(huge(0_8),kind=1) ! { dg-error "too large for the collating sequence" }
print *, achar(huge(0_8),kind=1) ! { dg-error "too large for the collating sequence" }
print *, char(huge(0_8),kind=4) ! { dg-error "too large for the collating sequence" }
print *, achar(huge(0_8),kind=4) ! { dg-error "too large for the collating sequence" }
print *, char(z'FFFFFFFF', kind=4)
print *, achar(z'FFFFFFFF', kind=4)
print *, char(z'100000000', kind=4) ! { dg-error "too large for the collating sequence" }
print *, achar(z'100000000', kind=4) ! { dg-error "too large for the collating sequence" }
end program test
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/moehring.f | 1 | 16295 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 moehring (node1,node2,nodem,nelem,lakon,kon,ipkon,
& nactdog,identity,ielprop,prop,iflag,v,xflow,f,
& nodef,idirf,df,cp,R,dvi,numf,set,mi,ttime,time,iaxial)
!
! moehring element
! This subroutines computes the evolution of the core swirl ratio
! for a disc stator system with either centrifugal or centripetal
! flow.
! Theoretical explanations can be found in
! "Untersuchung dfes radialen Druckverlaufes und des übertragenen
! drehmomentes im Radseitenraum von Kreiselpumpen bei glatter,
! ebene Radwand und bei Anvendung von Rückenschaufeln"
! Uwe Klaus Möhring , Dissertation,
! An der Üniversität Carolo-Wilhelmina zu Braunschweig 1976
!
! author: Yannick Muller
!
implicit none
!
logical identity
character*8 lakon(*)
character*81 set(*)
!
integer nelem,nactdog(0:3,*),node1,node2,nodem,numf,
& ielprop(*),nodef(*),idirf(*),index,iflag,iaxial,
& ipkon(*),kon(*),kgas,key,neval,ier,limit,lenw,last,
& iwork2(400),node_up,node_down,mi(*)
!
real*8 prop(*),v(0:mi(2),*),xflow,f,df(*),r,dvi,pi,
& R_min, R_max,cr, R_shroud,rsrmax,gap,swirl_up,
& pup,pdown,tup,tdown,kappa,cp,ttime,time,
& Rup,Rdown,K0,Kup,Cq,Re_phi,phi,lambda1, lambda2,
& a,b,epsabs,
& epsrel,result,abserr,work(1200),zk0,T1,T2,P1,P2,Pr,
& qred_crit,omega,rurd,C_p,Cm,Mr,f_k,f_t,f_p,f_m,f_cm,
& pdiff,pdiff_min,xflow_0,Cq_0,phi_0
!
external dKdX,dKdP,dkdT,dKdm,f_k,f_t,f_p,f_m,f_cm
!
! numf=4
!
if(iflag.eq.0) then
identity=.true.
!
if(nactdog(2,node1).ne.0)then
identity=.false.
elseif(nactdog(2,node2).ne.0)then
identity=.false.
elseif(nactdog(1,nodem).ne.0)then
identity=.false.
endif
!
elseif(iflag.eq.1)then
!
pi=4.d0*datan(1.d0)
kappa=(cp/(cp-R))
index=ielprop(nelem)
qred_crit=dsqrt(kappa/R)*
& (1+0.5d0*(kappa-1))**(-0.5*(kappa+1)/(kappa-1))
!
! Because there is no explicit expression relating massflow
! to pressure loss for möhrings
! initial mass flow is set to arbitrarily
! with consideration to flow direction
!
node1=kon(ipkon(nelem)+1)
node2=kon(ipkon(nelem)+3)
p1=v(2,node1)
p2=v(2,node2)
T1=v(0,node1)
T2=v(0,node2)
!
! fictious cross section
! A=1E-5
if(p1.gt.p2) then
xflow=1/dsqrt(T1)*P1*qred_crit*0.5d0
else
xflow=-1/dsqrt(T1)*P1*qred_crit*0.5d0
endif
!
elseif(iflag.eq.2)then
!
numf=4
index=ielprop(nelem)
pi=4.d0*datan(1.d0)
!
! Cr
Cr=0.315
!
! minimal disc radius
R_min=prop(index+1)
!
! maximal disc radius
R_max=prop(index+2)
!
! R_min/R_max
Rurd=R_min/R_max
!
! disc/stator gap
gap=prop(index+3)
!
! shroud radius
R_shroud=prop(index+4)
!
! R_schroud/R_max
rsrmax=R_shroud/R_max
!
! defining flow parameters
!
! massflow
xflow=v(1,nodem)*iaxial
!
! upstream node
node_up=nint(prop(index+5))
!
! downstream node
node_down=nint(prop(index+6))
!
! centripetal
if(lakon(nelem)(2:5).eq.'MRGP') then
if(xflow.lt.0d0) then
xflow=-xflow
endif
!
Rup=R_max
Rdown=R_min
!
nodef(1)=node_up
nodef(2)=node_up
nodef(3)=nodem
nodef(4)=node_down
!
! centrifugal
elseif(lakon(nelem)(2:5).eq.'MRGF') then
if(xflow.gt.0d0) then
xflow=-xflow
endif
!
Rup=R_min
Rdown=R_max
!
! if(xflow.gt.0) then
nodef(1)=node_up
nodef(2)=node_up
nodef(3)=nodem
nodef(4)=node_down
endif
!
! upstream pressure
pup=v(2,node_up)
!
! downstream pressure
pdown=v(2,node_down)
!
! Upstream temperature
Tup=v(0,node_up)
!
! downstream temperature
Tdown=v(0,node_down)
!
idirf(1)=2
idirf(2)=0
idirf(3)=1
idirf(4)=2
!
! rotation related parameters
!
! rotation
!
omega=prop(index+7)
!
! swirl at R_upstream
swirl_up=prop(index+8)
!
! core swirl ratio when xflow=0
K0=1/(1+(rsrmax**3.6*
& (rsrmax+4.6*gap/R_max))**(4.d0/7.d0))
!
! core swirl ratio at R_inlet
Kup=swirl_up/(omega*Rup)
!
! dynamic_viscosity
! kgas=0
! call dynamic_viscosity(kgas,Tup,dvi)
if(dabs(dvi).lt.1E-30) then
write(*,*) '*ERROR in moehring: '
write(*,*) ' no dynamic viscosity defined'
write(*,*) ' dvi= ',dvi
call exit(201)
c kgas=0
c call dynamic_viscosity(kgas,Tup,dvi)
endif
!
! defining common coefficients
!
Cq=xflow*R*Tup/(Pup*omega*(R_max)**3)
!
Re_phi=(omega*R_max**2*Pup)/(dvi*R*Tup)
!
phi=Cq*(Re_phi)**0.2d0
!
zk0=(1-K0)/K0
!
! lambda1
lambda1=(R_max-R_min)/dabs(R_max-R_min)*Pi*Cr/4*
& (dvi*R/(omega*R_max**2)**0.2d0*(omega*R_max**3)/R)
!
! lambda2
lambda2=2d0*R/(omega**2*R_max**2)
!
!*************************************************************************
! integration of K(X),dKdp(X),dKdT(X),dKdm(X)
limit=201
lenw=5*limit
!
! if(lakon(nelem)(2:5).eq.'MRGF') then
!xflow.lt.0d0) then
!
! lower integration boundary
a=rurd
!
! upper integration boundary
b=1d0
!
! elseif(lakon(nelem)(2:5).eq.'MRGP') then
!
! lower integration boundary
! a=1d0
!
! upper integration boundary
! b=rurd
! endif
!
! absolute error
epsabs=1E-7
!
! relative error
epsrel=1E-7
!
! choice for local integration rule
key=1
!
! determining minimal pressure difference for xflow<<1
!
if(lakon(nelem)(2:5).eq.'MRGF')then
xflow_0=-0.00000003E-3
elseif(lakon(nelem)(2:5).eq.'MRGP') then
xflow_0=0.00000003E-3
endif
!
Cq_0=xflow_0*R*Tup/(Pup*omega*(R_max)**3)
!
phi_0=Cq_0*(Re_phi)**0.2d0
!
call dqag(f_k,a,b,epsabs,epsrel,key,result,abserr,neval,ier,
& limit,lenw,last,iwork2,work,phi_0,lambda1,zk0,Pup,Tup,
& rurd,xflow_0,kup)
!
! pressure coefficient
C_p=2*result
pdiff_min=C_p*Pup/(4*R*Tup)*omega**2*R_max**2
pdiff=dabs(pdown-pup)
!
! K(x)
!
call dqag(f_k,a,b,epsabs,epsrel,key,result,abserr,neval,ier,
& limit,lenw,last,iwork2,work,phi,lambda1,zk0,Pup,Tup,rurd,
& xflow,kup)
!
! residual
!
if(lakon(nelem)(2:5).eq.'MRGF') then
f=lambda2*(Pdown-Pup)/(Pdown+Pup)*Tup-result
elseif(lakon(nelem)(2:5).eq.'MRGP') then
f=lambda2*(Pup-Pdown)/(Pup+Pdown)*Tup-result
endif
!
! pressure coefficient
C_p=2*result
!
! moment coefficient
call dqag(f_cm,a,b,epsabs,epsrel,key,result,abserr,neval,ier,
& limit,lenw,last,iwork2,work,phi,lambda1,zk0,Pup,Tup,rurd,
& xflow,kup)
!
Cm=0.5d0*Pi*Cr*Re_phi**(-0.2d0)*result
Mr=0.5d0*Cm*(Pup/1000d0/(R*Tup))*omega**2*R_max**5
Pr=Mr*omega
!
! pressure
!
call dqag(f_p,a,b,epsabs,epsrel,key,result,abserr,neval,ier,
& limit,lenw,last,iwork2,work,phi,lambda1,zk0,Pup,Tup,rurd,
& xflow,kup)
!
! partial derivative (upstream pressure)
!
if(lakon(nelem)(2:5).eq.'MRGF') then
df(1)=-2*lambda2**Pdown/(Pdown+Pup)**2*Tup-result
elseif(lakon(nelem)(2:5).eq.'MRGP') then
df(1)=2*lambda2**Pdown/(Pdown+Pup)**2*Tup-result
endif
!
! temperature
!
call dqag(f_t,a,b,epsabs,epsrel,key,result,abserr,neval,ier,
& limit,lenw,last,iwork2,work,phi,lambda1,zk0,Pup,Tup,rurd,
& xflow,kup)
!
! partial derivative (upstream temperature)
if(lakon(nelem)(2:5).eq.'MRGF') then
df(2)=lambda2**(Pdown-Pup)/(Pdown+Pup)-result
elseif(lakon(nelem)(2:5).eq.'MRGP') then
df(2)=lambda2**(Pup-Pdown)/(Pdown+Pup)-result
endif
!
! mass flow
!
call dqag(f_m,a,b,epsabs,epsrel,key,result,abserr,neval,ier,
& limit,lenw,last,iwork2,work,phi,lambda1,zk0,Pup,Tup,rurd,
& xflow,kup)
!
! partial derivative (mass flow)
df(3)=-result
!
! pressure
! partial derivative (downstream pressure)
if(lakon(nelem)(2:5).eq.'MRGF') then
df(4)=2*lambda2**Pup/(Pdown+Pup)**2*Tup
elseif(lakon(nelem)(2:5).eq.'MRGP') then
df(4)=-2*lambda2**Pup/(Pdown+Pup)**2*Tup
endif
!
endif
!
xflow=xflow/iaxial
df(3)=df(3)*iaxial
!
return
end
!
******************************************************************************
function f_k(x,phi,lambda1,zk0,Pup,Tup,rurd,xflow,kup)
!
implicit none
integer neq,idid,ipar,iwork(100),lrw,liw,j
real*8 f_k,x,rpar(8),rtol,atol,y(1),info(15),
& Rurd,zk0,lambda1,Kup,xflow,pup,tup,phi,t,rwork(160)
!
external dKdX
!
! storing the parameters
rpar(1)=phi
rpar(3)=zk0
!
! relative error
rtol=1.d-7
! absolute error
atol=1.d-7
!
! initial value
if(xflow.lt.0d0) then
t=rurd
else
t=1.d0
endif
neq=1
!
! initialisation info field
do j=1,15
info(j)=0
enddo
! initial condition f(0)
! core swirl ratio at Rup repectively Rdown depending
! on the type of element centrifugal or centripetal
!
y(1)= Kup
!
lrw=160
liw=60
!
! solving the differential equation Möhring 3.35
! dK/dX=f(K(X))
!
if(dabs(xflow).gt.1E-6) then
call ddeabm(dKdX,neq,t,y,x,info,rtol,atol,idid,
& rwork,lrw,iwork,liw,rpar,ipar)
else
y(1)=1/(Zk0+1)
endif
!
f_k=y(1)**2*x
!
return
end
******************************************************************************
function f_p(x,phi,lambda1,zk0,Pup,Tup,rurd,xflow,kup)
!
implicit none
integer neq,idid,ipar,iwork(100),lrw,liw,j
real*8 f_p,x,rpar(8),rtol,atol,y(1),info(15),Rurd,
& zk0,lambda1,Kup,xflow,pup,tup,phi,t,rwork(160)
!
external dKdp
! storing the parameters
rpar(1)=phi
rpar(2)=lambda1
rpar(3)=zk0
rpar(4)=Pup
rpar(5)=Tup
rpar(6)=rurd
rpar(7)=xflow
rpar(8)=kup
!
! relative error
rtol=1.d-7
! absolute error
atol=1.d-7
!
! initial value
if(xflow.lt.0d0) then
t=rurd
else
t=1.d0
endif
neq=1
!
! initialisation info field
do j=1,15
info(j)=0
enddo
! initial condition f(0)
! core swirl ratio at Rup
!
y(1)= 0d0
!
lrw=160
liw=60
!
call ddeabm(dKdp,neq,t,y,x,info,rtol,atol,idid,
& rwork,lrw,iwork,liw,rpar,ipar)
!
f_p=2*y(1)*x
!
return
end
*****************************************************************************
function f_t(x,phi,lambda1,zk0,Pup,Tup,rurd,xflow,kup)
!
implicit none
integer neq,idid,ipar,iwork(100),lrw,liw,j
real*8 f_t,x,rpar(8),rtol,atol,y(1),info(15),Rurd,
& zk0,lambda1,Kup,xflow, pup,tup,phi,t,rwork(160)
!
external dKdt
!
! storing the parameters
rpar(1)=phi
rpar(2)=lambda1
rpar(3)=zk0
rpar(4)=Pup
rpar(5)=Tup
rpar(6)=rurd
rpar(7)=xflow
rpar(8)=kup
!
! relative error
rtol=1.d-7
! absolute error
atol=1.d-7
!
! initial value
if(xflow.lt.0d0) then
t=rurd
else
t=1.d0
endif
! if(xflow.lt.0d0) then
! t=rurd
! else
! t=1.d0
! endif
neq=1
!
! initialisation info field
do j=1,15
info(j)=0
enddo
! initial condition f(0)
! core swirl ratio at Rup
!
y(1)= 0d0
!
lrw=160
liw=60
!
call ddeabm(dKdt,neq,t,y,x,info,rtol,atol,idid,
& rwork,lrw,iwork,liw,rpar,ipar)
!
f_t=2d0*y(1)*x
!
return
end
******************************************************************************
function f_m(x,phi,lambda1,zk0,Pup,Tup,rurd,xflow,kup)
!
implicit none
integer neq,idid,ipar,j,iwork(100),lrw,liw
real*8 f_m,x,rpar(8),rtol,atol,y(1),info(15),
& Rurd,zk0,lambda1,Kup,xflow,pup,tup,phi,t,rwork(160)
!
external dKdm
!
! storing the parameters
rpar(1)=phi
rpar(2)=lambda1
rpar(3)=zk0
rpar(4)=Pup
rpar(5)=Tup
rpar(6)=rurd
rpar(7)=xflow
rpar(8)=kup
!
! relative error
rtol=1.d-7
! absolute error
atol=1.d-7
!
! initial value
if(xflow.lt.0d0) then
t=rurd
else
t=1.d0
endif
neq=1
!
! initialisation info field
do j=1,15
info(j)=0
enddo
! initial condition f(0)
! core swirl ratio at Rup
!
y(1)=0
!
lrw=160
liw=60
!
! solving the differential equation Möhring 3.35
! dK/dX=f(K(X))
!
call ddeabm(dKdm,neq,t,y,x,info,rtol,atol,idid,
& rwork,lrw,iwork,liw,rpar,ipar)
!
f_m=2*y(1)*x
!
return
end
******************************************************************************
function f_cm(x,phi,lambda1,zk0,Pup,Tup,rurd,xflow,kup)
!
implicit none
integer neq,idid,ipar,j,iwork(100),lrw,liw
real*8 f_cm,x,rpar(8),rtol,atol,y(1),info(15),
& Rurd,zk0,lambda1,Kup,xflow,pup,tup,phi,t,rwork(160)
!
external dKdX
!
! storing the parameters
rpar(1)=phi
rpar(2)=lambda1
rpar(3)=zk0
rpar(4)=Pup
rpar(5)=Tup
rpar(6)=rurd
rpar(7)=xflow
rpar(8)=kup
!
! relative error
rtol=1.d-7
! absolute error
atol=1.d-7
! initial value
!
if(xflow.lt.0d0) then
t=rurd
else
t=1.d0
endif
!
neq=1
!
! initialisation info field
do j=1,15
info(j)=0
enddo
! initial condition f(0)
! core swirl ratio at Rup
!
y(1)=Kup
!
lrw=160
liw=60
!
! solving the differential equation Möhring 3.35
! dK/dX=f(K(X))
!
call ddeabm(dKdX,neq,t,y,x,info,rtol,atol,idid,
& rwork,lrw,iwork,liw,rpar,ipar)
!
f_cm=dabs(1-y(1))/(1-y(1))*dabs(1-y(1))**(1.75d0)
& *x**(3.6d0)
!
return
end
| gpl-2.0 |
prool/ccx_prool | ARPACK/SRC/cnaup2.f | 3 | 29120 | c\BeginDoc
c
c\Name: cnaup2
c
c\Description:
c Intermediate level interface called by cnaupd.
c
c\Usage:
c call cnaup2
c ( IDO, BMAT, N, WHICH, NEV, NP, TOL, RESID, MODE, IUPD,
c ISHIFT, MXITER, V, LDV, H, LDH, RITZ, BOUNDS,
c Q, LDQ, WORKL, IPNTR, WORKD, RWORK, INFO )
c
c\Arguments
c
c IDO, BMAT, N, WHICH, NEV, TOL, RESID: same as defined in cnaupd.
c MODE, ISHIFT, MXITER: see the definition of IPARAM in cnaupd.
c
c NP Integer. (INPUT/OUTPUT)
c Contains the number of implicit shifts to apply during
c each Arnoldi iteration.
c If ISHIFT=1, NP is adjusted dynamically at each iteration
c to accelerate convergence and prevent stagnation.
c This is also roughly equal to the number of matrix-vector
c products (involving the operator OP) per Arnoldi iteration.
c The logic for adjusting is contained within the current
c subroutine.
c If ISHIFT=0, NP is the number of shifts the user needs
c to provide via reverse comunication. 0 < NP < NCV-NEV.
c NP may be less than NCV-NEV since a leading block of the current
c upper Hessenberg matrix has split off and contains "unwanted"
c Ritz values.
c Upon termination of the IRA iteration, NP contains the number
c of "converged" wanted Ritz values.
c
c IUPD Integer. (INPUT)
c IUPD .EQ. 0: use explicit restart instead implicit update.
c IUPD .NE. 0: use implicit update.
c
c V Complex N by (NEV+NP) array. (INPUT/OUTPUT)
c The Arnoldi basis vectors are returned in the first NEV
c columns of V.
c
c LDV Integer. (INPUT)
c Leading dimension of V exactly as declared in the calling
c program.
c
c H Complex (NEV+NP) by (NEV+NP) array. (OUTPUT)
c H is used to store the generated upper Hessenberg matrix
c
c LDH Integer. (INPUT)
c Leading dimension of H exactly as declared in the calling
c program.
c
c RITZ Complex array of length NEV+NP. (OUTPUT)
c RITZ(1:NEV) contains the computed Ritz values of OP.
c
c BOUNDS Complex array of length NEV+NP. (OUTPUT)
c BOUNDS(1:NEV) contain the error bounds corresponding to
c the computed Ritz values.
c
c Q Complex (NEV+NP) by (NEV+NP) array. (WORKSPACE)
c Private (replicated) work array used to accumulate the
c rotation in the shift application step.
c
c LDQ Integer. (INPUT)
c Leading dimension of Q exactly as declared in the calling
c program.
c
c WORKL Complex work array of length at least
c (NEV+NP)**2 + 3*(NEV+NP). (WORKSPACE)
c Private (replicated) array on each PE or array allocated on
c the front end. It is used in shifts calculation, shifts
c application and convergence checking.
c
c
c IPNTR Integer array of length 3. (OUTPUT)
c Pointer to mark the starting locations in the WORKD for
c vectors used by the Arnoldi iteration.
c -------------------------------------------------------------
c IPNTR(1): pointer to the current operand vector X.
c IPNTR(2): pointer to the current result vector Y.
c IPNTR(3): pointer to the vector B * X when used in the
c shift-and-invert mode. X is the current operand.
c -------------------------------------------------------------
c
c WORKD Complex work array of length 3*N. (WORKSPACE)
c Distributed array to be used in the basic Arnoldi iteration
c for reverse communication. The user should not use WORKD
c as temporary workspace during the iteration !!!!!!!!!!
c See Data Distribution Note in CNAUPD.
c
c RWORK Real work array of length NEV+NP ( WORKSPACE)
c Private (replicated) array on each PE or array allocated on
c the front end.
c
c INFO Integer. (INPUT/OUTPUT)
c If INFO .EQ. 0, a randomly initial residual vector is used.
c If INFO .NE. 0, RESID contains the initial residual vector,
c possibly from a previous run.
c Error flag on output.
c = 0: Normal return.
c = 1: Maximum number of iterations taken.
c All possible eigenvalues of OP has been found.
c NP returns the number of converged Ritz values.
c = 2: No shifts could be applied.
c = -8: Error return from LAPACK eigenvalue calculation;
c This should never happen.
c = -9: Starting vector is zero.
c = -9999: Could not build an Arnoldi factorization.
c Size that was built in returned in NP.
c
c\EndDoc
c
c-----------------------------------------------------------------------
c
c\BeginLib
c
c\Local variables:
c xxxxxx Complex
c
c\References:
c 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in
c a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992),
c pp 357-385.
c 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly
c Restarted Arnoldi Iteration", Rice University Technical Report
c TR95-13, Department of Computational and Applied Mathematics.
c
c\Routines called:
c cgetv0 ARPACK initial vector generation routine.
c cnaitr ARPACK Arnoldi factorization routine.
c cnapps ARPACK application of implicit shifts routine.
c cneigh ARPACK compute Ritz values and error bounds routine.
c cngets ARPACK reorder Ritz values and error bounds routine.
c csortc ARPACK sorting routine.
c ivout ARPACK utility routine that prints integers.
c second ARPACK utility routine for timing.
c cmout ARPACK utility routine that prints matrices
c cvout ARPACK utility routine that prints vectors.
c svout ARPACK utility routine that prints vectors.
c slamch LAPACK routine that determines machine constants.
c slapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully.
c ccopy Level 1 BLAS that copies one vector to another .
c cdotc Level 1 BLAS that computes the scalar product of two vectors.
c cswap Level 1 BLAS that swaps two vectors.
c scnrm2 Level 1 BLAS that computes the norm of a vector.
c
c\Author
c Danny Sorensen Phuong Vu
c Richard Lehoucq CRPC / Rice Universitya
c Chao Yang Houston, Texas
c Dept. of Computational &
c Applied Mathematics
c Rice University
c Houston, Texas
c
c\SCCS Information: @(#)
c FILE: naup2.F SID: 2.5 DATE OF SID: 8/16/96 RELEASE: 2
c
c\Remarks
c 1. None
c
c\EndLib
c
c-----------------------------------------------------------------------
c
subroutine cnaup2
& ( ido, bmat, n, which, nev, np, tol, resid, mode, iupd,
& ishift, mxiter, v, ldv, h, ldh, ritz, bounds,
& q, ldq, workl, ipntr, workd, rwork, info )
c
c %----------------------------------------------------%
c | Include files for debugging and timing information |
c %----------------------------------------------------%
c
include 'debug.h'
include 'stat.h'
c
c %------------------%
c | Scalar Arguments |
c %------------------%
c
character bmat*1, which*2
integer ido, info, ishift, iupd, mode, ldh, ldq, ldv, mxiter,
& n, nev, np
Real
& tol
c
c %-----------------%
c | Array Arguments |
c %-----------------%
c
integer ipntr(13)
Complex
& bounds(nev+np), h(ldh,nev+np), q(ldq,nev+np),
& resid(n), ritz(nev+np), v(ldv,nev+np),
& workd(3*n), workl( (nev+np)*(nev+np+3) )
Real
& rwork(nev+np)
c
c %------------%
c | Parameters |
c %------------%
c
Complex
& one, zero
Real
& rzero
parameter (one = (1.0E+0, 0.0E+0), zero = (0.0E+0, 0.0E+0),
& rzero = 0.0E+0)
c
c %---------------%
c | Local Scalars |
c %---------------%
c
logical cnorm, getv0, initv, update, ushift
integer ierr, iter, i, j, kplusp, msglvl, nconv, nevbef, nev0,
& np0, nptemp
Complex
& cmpnorm
Real
& rtemp, eps23, rnorm
character wprime*2
c
save cnorm, getv0, initv, update, ushift,
& iter, kplusp, msglvl, nconv, nev0, np0,
& eps23
c
c
c %-----------------------%
c | Local array arguments |
c %-----------------------%
c
integer kp(3)
c
c %----------------------%
c | External Subroutines |
c %----------------------%
c
external ccopy, cgetv0, cnaitr, cneigh, cngets, cnapps,
& csortc, cswap, cmout, cvout, ivout, second
c
c %--------------------%
c | External functions |
c %--------------------%
c
Complex
& cdotc
Real
& scnrm2, slamch, slapy2
external cdotc, scnrm2, slamch, slapy2
c
c %---------------------%
c | Intrinsic Functions |
c %---------------------%
c
intrinsic aimag, real, min, max
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
c
if (ido .eq. 0) then
c
call second (t0)
c
msglvl = mcaup2
c
nev0 = nev
np0 = np
c
c %-------------------------------------%
c | kplusp is the bound on the largest |
c | Lanczos factorization built. |
c | nconv is the current number of |
c | "converged" eigenvalues. |
c | iter is the counter on the current |
c | iteration step. |
c %-------------------------------------%
c
kplusp = nev + np
nconv = 0
iter = 0
c
c %---------------------------------%
c | Get machine dependent constant. |
c %---------------------------------%
c
eps23 = slamch('Epsilon-Machine')
eps23 = eps23**(2.0E+0 / 3.0E+0)
c
c %---------------------------------------%
c | Set flags for computing the first NEV |
c | steps of the Arnoldi factorization. |
c %---------------------------------------%
c
getv0 = .true.
update = .false.
ushift = .false.
cnorm = .false.
c
if (info .ne. 0) then
c
c %--------------------------------------------%
c | User provides the initial residual vector. |
c %--------------------------------------------%
c
initv = .true.
info = 0
else
initv = .false.
end if
end if
c
c %---------------------------------------------%
c | Get a possibly random starting vector and |
c | force it into the range of the operator OP. |
c %---------------------------------------------%
c
10 continue
c
if (getv0) then
call cgetv0 (ido, bmat, 1, initv, n, 1, v, ldv, resid, rnorm,
& ipntr, workd, info)
c
if (ido .ne. 99) go to 9000
c
if (rnorm .eq. rzero) then
c
c %-----------------------------------------%
c | The initial vector is zero. Error exit. |
c %-----------------------------------------%
c
info = -9
go to 1100
end if
getv0 = .false.
ido = 0
end if
c
c %-----------------------------------%
c | Back from reverse communication : |
c | continue with update step |
c %-----------------------------------%
c
if (update) go to 20
c
c %-------------------------------------------%
c | Back from computing user specified shifts |
c %-------------------------------------------%
c
if (ushift) go to 50
c
c %-------------------------------------%
c | Back from computing residual norm |
c | at the end of the current iteration |
c %-------------------------------------%
c
if (cnorm) go to 100
c
c %----------------------------------------------------------%
c | Compute the first NEV steps of the Arnoldi factorization |
c %----------------------------------------------------------%
c
call cnaitr (ido, bmat, n, 0, nev, mode, resid, rnorm, v, ldv,
& h, ldh, ipntr, workd, info)
c
if (ido .ne. 99) go to 9000
c
if (info .gt. 0) then
np = info
mxiter = iter
info = -9999
go to 1200
end if
c
c %--------------------------------------------------------------%
c | |
c | M A I N ARNOLDI I T E R A T I O N L O O P |
c | Each iteration implicitly restarts the Arnoldi |
c | factorization in place. |
c | |
c %--------------------------------------------------------------%
c
1000 continue
c
iter = iter + 1
c
if (msglvl .gt. 0) then
call ivout (logfil, 1, iter, ndigit,
& '_naup2: **** Start of major iteration number ****')
end if
c
c %-----------------------------------------------------------%
c | Compute NP additional steps of the Arnoldi factorization. |
c | Adjust NP since NEV might have been updated by last call |
c | to the shift application routine cnapps. |
c %-----------------------------------------------------------%
c
np = kplusp - nev
c
if (msglvl .gt. 1) then
call ivout (logfil, 1, nev, ndigit,
& '_naup2: The length of the current Arnoldi factorization')
call ivout (logfil, 1, np, ndigit,
& '_naup2: Extend the Arnoldi factorization by')
end if
c
c %-----------------------------------------------------------%
c | Compute NP additional steps of the Arnoldi factorization. |
c %-----------------------------------------------------------%
c
ido = 0
20 continue
update = .true.
c
call cnaitr (ido, bmat, n, nev, np, mode, resid, rnorm, v, ldv,
& h, ldh, ipntr, workd, info)
c
if (ido .ne. 99) go to 9000
c
if (info .gt. 0) then
np = info
mxiter = iter
info = -9999
go to 1200
end if
update = .false.
c
if (msglvl .gt. 1) then
call svout (logfil, 1, rnorm, ndigit,
& '_naup2: Corresponding B-norm of the residual')
end if
c
c %--------------------------------------------------------%
c | Compute the eigenvalues and corresponding error bounds |
c | of the current upper Hessenberg matrix. |
c %--------------------------------------------------------%
c
call cneigh (rnorm, kplusp, h, ldh, ritz, bounds,
& q, ldq, workl, rwork, ierr)
c
if (ierr .ne. 0) then
info = -8
go to 1200
end if
c
c %---------------------------------------------------%
c | Select the wanted Ritz values and their bounds |
c | to be used in the convergence test. |
c | The wanted part of the spectrum and corresponding |
c | error bounds are in the last NEV loc. of RITZ, |
c | and BOUNDS respectively. |
c %---------------------------------------------------%
c
nev = nev0
np = np0
c
c %--------------------------------------------------%
c | Make a copy of Ritz values and the corresponding |
c | Ritz estimates obtained from cneigh. |
c %--------------------------------------------------%
c
call ccopy(kplusp,ritz,1,workl(kplusp**2+1),1)
call ccopy(kplusp,bounds,1,workl(kplusp**2+kplusp+1),1)
c
c %---------------------------------------------------%
c | Select the wanted Ritz values and their bounds |
c | to be used in the convergence test. |
c | The wanted part of the spectrum and corresponding |
c | bounds are in the last NEV loc. of RITZ |
c | BOUNDS respectively. |
c %---------------------------------------------------%
c
call cngets (ishift, which, nev, np, ritz, bounds)
c
c %------------------------------------------------------------%
c | Convergence test: currently we use the following criteria. |
c | The relative accuracy of a Ritz value is considered |
c | acceptable if: |
c | |
c | error_bounds(i) .le. tol*max(eps23, magnitude_of_ritz(i)). |
c | |
c %------------------------------------------------------------%
c
nconv = 0
c
do 25 i = 1, nev
rtemp = max( eps23, slapy2( real(ritz(np+i)),
& aimag(ritz(np+i)) ) )
if ( slapy2(real(bounds(np+i)),aimag(bounds(np+i)))
& .le. tol*rtemp ) then
nconv = nconv + 1
end if
25 continue
c
if (msglvl .gt. 2) then
kp(1) = nev
kp(2) = np
kp(3) = nconv
call ivout (logfil, 3, kp, ndigit,
& '_naup2: NEV, NP, NCONV are')
call cvout (logfil, kplusp, ritz, ndigit,
& '_naup2: The eigenvalues of H')
call cvout (logfil, kplusp, bounds, ndigit,
& '_naup2: Ritz estimates of the current NCV Ritz values')
end if
c
c %---------------------------------------------------------%
c | Count the number of unwanted Ritz values that have zero |
c | Ritz estimates. If any Ritz estimates are equal to zero |
c | then a leading block of H of order equal to at least |
c | the number of Ritz values with zero Ritz estimates has |
c | split off. None of these Ritz values may be removed by |
c | shifting. Decrease NP the number of shifts to apply. If |
c | no shifts may be applied, then prepare to exit |
c %---------------------------------------------------------%
c
nptemp = np
do 30 j=1, nptemp
if (bounds(j) .eq. zero) then
np = np - 1
nev = nev + 1
end if
30 continue
c
if ( (nconv .ge. nev0) .or.
& (iter .gt. mxiter) .or.
& (np .eq. 0) ) then
c
if (msglvl .gt. 4) then
call cvout(logfil, kplusp, workl(kplusp**2+1), ndigit,
& '_naup2: Eigenvalues computed by _neigh:')
call cvout(logfil, kplusp, workl(kplusp**2+kplusp+1),
& ndigit,
& '_naup2: Ritz estimates computed by _neigh:')
end if
c
c %------------------------------------------------%
c | Prepare to exit. Put the converged Ritz values |
c | and corresponding bounds in RITZ(1:NCONV) and |
c | BOUNDS(1:NCONV) respectively. Then sort. Be |
c | careful when NCONV > NP |
c %------------------------------------------------%
c
c %------------------------------------------%
c | Use h( 3,1 ) as storage to communicate |
c | rnorm to cneupd if needed |
c %------------------------------------------%
h(3,1) = cmplx(rnorm,rzero)
c
c %----------------------------------------------%
c | Sort Ritz values so that converged Ritz |
c | values appear within the first NEV locations |
c | of ritz and bounds, and the most desired one |
c | appears at the front. |
c %----------------------------------------------%
c
if (which .eq. 'LM') wprime = 'SM'
if (which .eq. 'SM') wprime = 'LM'
if (which .eq. 'LR') wprime = 'SR'
if (which .eq. 'SR') wprime = 'LR'
if (which .eq. 'LI') wprime = 'SI'
if (which .eq. 'SI') wprime = 'LI'
c
call csortc(wprime, .true., kplusp, ritz, bounds)
c
c %--------------------------------------------------%
c | Scale the Ritz estimate of each Ritz value |
c | by 1 / max(eps23, magnitude of the Ritz value). |
c %--------------------------------------------------%
c
do 35 j = 1, nev0
rtemp = max( eps23, slapy2( real(ritz(j)),
& aimag(ritz(j)) ) )
bounds(j) = bounds(j)/rtemp
35 continue
c
c %---------------------------------------------------%
c | Sort the Ritz values according to the scaled Ritz |
c | estimates. This will push all the converged ones |
c | towards the front of ritz, bounds (in the case |
c | when NCONV < NEV.) |
c %---------------------------------------------------%
c
wprime = 'LM'
call csortc(wprime, .true., nev0, bounds, ritz)
c
c %----------------------------------------------%
c | Scale the Ritz estimate back to its original |
c | value. |
c %----------------------------------------------%
c
do 40 j = 1, nev0
rtemp = max( eps23, slapy2( real(ritz(j)),
& aimag(ritz(j)) ) )
bounds(j) = bounds(j)*rtemp
40 continue
c
c %-----------------------------------------------%
c | Sort the converged Ritz values again so that |
c | the "threshold" value appears at the front of |
c | ritz and bound. |
c %-----------------------------------------------%
c
call csortc(which, .true., nconv, ritz, bounds)
c
if (msglvl .gt. 1) then
call cvout (logfil, kplusp, ritz, ndigit,
& '_naup2: Sorted eigenvalues')
call cvout (logfil, kplusp, bounds, ndigit,
& '_naup2: Sorted ritz estimates.')
end if
c
c %------------------------------------%
c | Max iterations have been exceeded. |
c %------------------------------------%
c
if (iter .gt. mxiter .and. nconv .lt. nev0) info = 1
c
c %---------------------%
c | No shifts to apply. |
c %---------------------%
c
if (np .eq. 0 .and. nconv .lt. nev0) info = 2
c
np = nconv
go to 1100
c
else if ( (nconv .lt. nev0) .and. (ishift .eq. 1) ) then
c
c %-------------------------------------------------%
c | Do not have all the requested eigenvalues yet. |
c | To prevent possible stagnation, adjust the size |
c | of NEV. |
c %-------------------------------------------------%
c
nevbef = nev
nev = nev + min(nconv, np/2)
if (nev .eq. 1 .and. kplusp .ge. 6) then
nev = kplusp / 2
else if (nev .eq. 1 .and. kplusp .gt. 3) then
nev = 2
end if
np = kplusp - nev
c
c %---------------------------------------%
c | If the size of NEV was just increased |
c | resort the eigenvalues. |
c %---------------------------------------%
c
if (nevbef .lt. nev)
& call cngets (ishift, which, nev, np, ritz, bounds)
c
end if
c
if (msglvl .gt. 0) then
call ivout (logfil, 1, nconv, ndigit,
& '_naup2: no. of "converged" Ritz values at this iter.')
if (msglvl .gt. 1) then
kp(1) = nev
kp(2) = np
call ivout (logfil, 2, kp, ndigit,
& '_naup2: NEV and NP are')
call cvout (logfil, nev, ritz(np+1), ndigit,
& '_naup2: "wanted" Ritz values ')
call cvout (logfil, nev, bounds(np+1), ndigit,
& '_naup2: Ritz estimates of the "wanted" values ')
end if
end if
c
if (ishift .eq. 0) then
c
c %-------------------------------------------------------%
c | User specified shifts: pop back out to get the shifts |
c | and return them in the first 2*NP locations of WORKL. |
c %-------------------------------------------------------%
c
ushift = .true.
ido = 3
go to 9000
end if
50 continue
ushift = .false.
c
if ( ishift .ne. 1 ) then
c
c %----------------------------------%
c | Move the NP shifts from WORKL to |
c | RITZ, to free up WORKL |
c | for non-exact shift case. |
c %----------------------------------%
c
call ccopy (np, workl, 1, ritz, 1)
end if
c
if (msglvl .gt. 2) then
call ivout (logfil, 1, np, ndigit,
& '_naup2: The number of shifts to apply ')
call cvout (logfil, np, ritz, ndigit,
& '_naup2: values of the shifts')
if ( ishift .eq. 1 )
& call cvout (logfil, np, bounds, ndigit,
& '_naup2: Ritz estimates of the shifts')
end if
c
c %---------------------------------------------------------%
c | Apply the NP implicit shifts by QR bulge chasing. |
c | Each shift is applied to the whole upper Hessenberg |
c | matrix H. |
c | The first 2*N locations of WORKD are used as workspace. |
c %---------------------------------------------------------%
c
call cnapps (n, nev, np, ritz, v, ldv,
& h, ldh, resid, q, ldq, workl, workd)
c
c %---------------------------------------------%
c | Compute the B-norm of the updated residual. |
c | Keep B*RESID in WORKD(1:N) to be used in |
c | the first step of the next call to cnaitr. |
c %---------------------------------------------%
c
cnorm = .true.
call second (t2)
if (bmat .eq. 'G') then
nbx = nbx + 1
call ccopy (n, resid, 1, workd(n+1), 1)
ipntr(1) = n + 1
ipntr(2) = 1
ido = 2
c
c %----------------------------------%
c | Exit in order to compute B*RESID |
c %----------------------------------%
c
go to 9000
else if (bmat .eq. 'I') then
call ccopy (n, resid, 1, workd, 1)
end if
c
100 continue
c
c %----------------------------------%
c | Back from reverse communication; |
c | WORKD(1:N) := B*RESID |
c %----------------------------------%
c
if (bmat .eq. 'G') then
call second (t3)
tmvbx = tmvbx + (t3 - t2)
end if
c
if (bmat .eq. 'G') then
cmpnorm = cdotc (n, resid, 1, workd, 1)
rnorm = sqrt(slapy2(real(cmpnorm),aimag(cmpnorm)))
else if (bmat .eq. 'I') then
rnorm = scnrm2(n, resid, 1)
end if
cnorm = .false.
c
if (msglvl .gt. 2) then
call svout (logfil, 1, rnorm, ndigit,
& '_naup2: B-norm of residual for compressed factorization')
call cmout (logfil, nev, nev, h, ldh, ndigit,
& '_naup2: Compressed upper Hessenberg matrix H')
end if
c
go to 1000
c
c %---------------------------------------------------------------%
c | |
c | E N D O F M A I N I T E R A T I O N L O O P |
c | |
c %---------------------------------------------------------------%
c
1100 continue
c
mxiter = iter
nev = nconv
c
1200 continue
ido = 99
c
c %------------%
c | Error Exit |
c %------------%
c
call second (t1)
tcaup2 = t1 - t0
c
9000 continue
c
c %---------------%
c | End of cnaup2 |
c %---------------%
c
return
end
| gpl-2.0 |
alexfrolov/grappa | applications/NPB/MPI/MPI_dummy/mpi_dummy.f | 5 | 8622 | subroutine mpi_isend(buf,count,datatype,source,
& tag,comm,request,ierror)
integer buf(*), count,datatype,source,tag,comm,
& request,ierror
call mpi_error()
return
end
subroutine mpi_irecv(buf,count,datatype,source,
& tag,comm,request,ierror)
integer buf(*), count,datatype,source,tag,comm,
& request,ierror
call mpi_error()
return
end
subroutine mpi_send(buf,count,datatype,dest,tag,comm,ierror)
integer buf(*), count,datatype,dest,tag,comm,ierror
call mpi_error()
return
end
subroutine mpi_recv(buf,count,datatype,source,
& tag,comm,status,ierror)
integer buf(*), count,datatype,source,tag,comm,
& status(*),ierror
call mpi_error()
return
end
subroutine mpi_comm_split(comm,color,key,newcomm,ierror)
integer comm,color,key,newcomm,ierror
return
end
subroutine mpi_comm_rank(comm, rank,ierr)
implicit none
integer comm, rank,ierr
rank = 0
return
end
subroutine mpi_comm_size(comm, size, ierr)
implicit none
integer comm, size, ierr
size = 1
return
end
double precision function mpi_wtime()
implicit none
double precision t
c This function must measure wall clock time, not CPU time.
c Since there is no portable timer in Fortran (77)
c we call a routine compiled in C (though the C source may have
c to be tweaked).
call wtime(t)
c The following is not ok for "official" results because it reports
c CPU time not wall clock time. It may be useful for developing/testing
c on timeshared Crays, though.
c call second(t)
mpi_wtime = t
return
end
c may be valid to call this in single processor case
subroutine mpi_barrier(comm,ierror)
return
end
c may be valid to call this in single processor case
subroutine mpi_bcast(buf, nitems, type, root, comm, ierr)
implicit none
integer buf(*), nitems, type, root, comm, ierr
return
end
subroutine mpi_comm_dup(oldcomm, newcomm,ierror)
integer oldcomm, newcomm,ierror
newcomm= oldcomm
return
end
subroutine mpi_error()
print *, 'mpi_error called'
stop
end
subroutine mpi_abort(comm, errcode, ierr)
implicit none
integer comm, errcode, ierr
print *, 'mpi_abort called'
stop
end
subroutine mpi_finalize(ierr)
return
end
subroutine mpi_init(ierr)
return
end
c assume double precision, which is all SP uses
subroutine mpi_reduce(inbuf, outbuf, nitems,
$ type, op, root, comm, ierr)
implicit none
include 'mpif.h'
integer nitems, type, op, root, comm, ierr
double precision inbuf(*), outbuf(*)
if (type .eq. mpi_double_precision) then
call mpi_reduce_dp(inbuf, outbuf, nitems,
$ type, op, root, comm, ierr)
else if (type .eq. mpi_double_complex) then
call mpi_reduce_dc(inbuf, outbuf, nitems,
$ type, op, root, comm, ierr)
else if (type .eq. mpi_complex) then
call mpi_reduce_complex(inbuf, outbuf, nitems,
$ type, op, root, comm, ierr)
else if (type .eq. mpi_real) then
call mpi_reduce_real(inbuf, outbuf, nitems,
$ type, op, root, comm, ierr)
else if (type .eq. mpi_integer) then
call mpi_reduce_int(inbuf, outbuf, nitems,
$ type, op, root, comm, ierr)
else
print *, 'mpi_reduce: unknown type ', type
end if
return
end
subroutine mpi_reduce_real(inbuf, outbuf, nitems,
$ type, op, root, comm, ierr)
implicit none
integer nitems, type, op, root, comm, ierr, i
real inbuf(*), outbuf(*)
do i = 1, nitems
outbuf(i) = inbuf(i)
end do
return
end
subroutine mpi_reduce_dp(inbuf, outbuf, nitems,
$ type, op, root, comm, ierr)
implicit none
integer nitems, type, op, root, comm, ierr, i
double precision inbuf(*), outbuf(*)
do i = 1, nitems
outbuf(i) = inbuf(i)
end do
return
end
subroutine mpi_reduce_dc(inbuf, outbuf, nitems,
$ type, op, root, comm, ierr)
implicit none
integer nitems, type, op, root, comm, ierr, i
double complex inbuf(*), outbuf(*)
do i = 1, nitems
outbuf(i) = inbuf(i)
end do
return
end
subroutine mpi_reduce_complex(inbuf, outbuf, nitems,
$ type, op, root, comm, ierr)
implicit none
integer nitems, type, op, root, comm, ierr, i
complex inbuf(*), outbuf(*)
do i = 1, nitems
outbuf(i) = inbuf(i)
end do
return
end
subroutine mpi_reduce_int(inbuf, outbuf, nitems,
$ type, op, root, comm, ierr)
implicit none
integer nitems, type, op, root, comm, ierr, i
integer inbuf(*), outbuf(*)
do i = 1, nitems
outbuf(i) = inbuf(i)
end do
return
end
subroutine mpi_allreduce(inbuf, outbuf, nitems,
$ type, op, comm, ierr)
implicit none
integer nitems, type, op, comm, ierr
double precision inbuf(*), outbuf(*)
call mpi_reduce(inbuf, outbuf, nitems,
$ type, op, 0, comm, ierr)
return
end
subroutine mpi_alltoall(inbuf, nitems, type, outbuf, nitems_dum,
$ type_dum, comm, ierr)
implicit none
include 'mpif.h'
integer nitems, type, comm, ierr, nitems_dum, type_dum
double precision inbuf(*), outbuf(*)
if (type .eq. mpi_double_precision) then
call mpi_alltoall_dp(inbuf, outbuf, nitems,
$ type, comm, ierr)
else if (type .eq. mpi_double_complex) then
call mpi_alltoall_dc(inbuf, outbuf, nitems,
$ type, comm, ierr)
else if (type .eq. mpi_complex) then
call mpi_alltoall_complex(inbuf, outbuf, nitems,
$ type, comm, ierr)
else if (type .eq. mpi_real) then
call mpi_alltoall_real(inbuf, outbuf, nitems,
$ type, comm, ierr)
else if (type .eq. mpi_integer) then
call mpi_alltoall_int(inbuf, outbuf, nitems,
$ type, comm, ierr)
else
print *, 'mpi_alltoall: unknown type ', type
end if
return
end
subroutine mpi_alltoall_dc(inbuf, outbuf, nitems,
$ type, comm, ierr)
implicit none
integer nitems, type, comm, ierr, i
double complex inbuf(*), outbuf(*)
do i = 1, nitems
outbuf(i) = inbuf(i)
end do
return
end
subroutine mpi_alltoall_complex(inbuf, outbuf, nitems,
$ type, comm, ierr)
implicit none
integer nitems, type, comm, ierr, i
double complex inbuf(*), outbuf(*)
do i = 1, nitems
outbuf(i) = inbuf(i)
end do
return
end
subroutine mpi_alltoall_dp(inbuf, outbuf, nitems,
$ type, comm, ierr)
implicit none
integer nitems, type, comm, ierr, i
double precision inbuf(*), outbuf(*)
do i = 1, nitems
outbuf(i) = inbuf(i)
end do
return
end
subroutine mpi_alltoall_real(inbuf, outbuf, nitems,
$ type, comm, ierr)
implicit none
integer nitems, type, comm, ierr, i
real inbuf(*), outbuf(*)
do i = 1, nitems
outbuf(i) = inbuf(i)
end do
return
end
subroutine mpi_alltoall_int(inbuf, outbuf, nitems,
$ type, comm, ierr)
implicit none
integer nitems, type, comm, ierr, i
integer inbuf(*), outbuf(*)
do i = 1, nitems
outbuf(i) = inbuf(i)
end do
return
end
subroutine mpi_wait(request,status,ierror)
integer request,status,ierror
call mpi_error()
return
end
subroutine mpi_waitall(count,requests,status,ierror)
integer count,requests(*),status(*),ierror
call mpi_error()
return
end
| bsd-3-clause |
prool/ccx_prool | CalculiX/ccx_2.15/src/resultsmech_se.f | 2 | 40033 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2018 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 resultsmech_se(co,kon,ipkon,lakon,ne,v,
& stx,elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,
& ielmat,ielorien,norien,orab,ntmat_,t0,t1,ithermal,prestr,
& iprestr,eme,iperturb,fn,iout,vold,nmethod,
& veold,dtime,time,ttime,plicon,nplicon,plkcon,nplkcon,
& xstateini,xstiff,xstate,npmat_,matname,mi,ielas,icmd,
& ncmat_,nstate_,stiini,vini,ener,eei,enerini,istep,iinc,
& springarea,reltime,calcul_fn,calcul_cauchy,nener,
& ikin,ne0,thicke,emeini,pslavsurf,
& pmastsurf,mortar,clearini,nea,neb,ielprop,prop,dfn,
& idesvar,nodedesi,fn0,sti,icoordinate,dxstiff,
& ialdesi,xdesi)
!
! calculates stresses and the material tangent at the integration
! points and the internal forces at the nodes
!
implicit none
!
integer cauchy
!
character*8 lakon(*),lakonl
character*80 amat,matname(*)
!
integer kon(*),konl(26),nea,neb,mi(*),mint2d,nopes,
& nelcon(2,*),nrhcon(*),nalcon(2,*),ielmat(mi(3),*),
& ielorien(mi(3),*),ntmat_,ipkon(*),ne0,iflag,null,
& istep,iinc,mt,ne,mattyp,ithermal(2),iprestr,i,j,k,m1,m2,jj,
& i1,m3,m4,kk,nener,indexe,nope,norien,iperturb(*),iout,
& icmd,ihyper,nmethod,kode,imat,mint3d,iorien,ielas,
& istiff,ncmat_,nstate_,ikin,ilayer,nlayer,ki,kl,ielprop(*),
& nplicon(0:ntmat_,*),nplkcon(0:ntmat_,*),npmat_,calcul_fn,
& calcul_cauchy,nopered,mortar,jfaces,igauss,
& idesvar,node,nodedesi(*),kscale,idir,nlgeom_undo,
& iactive,icoordinate,ialdesi(*),ii
!
real*8 co(3,*),v(0:mi(2),*),shp(4,26),stiini(6,mi(1),*),
& stx(6,mi(1),*),xl(3,26),vl(0:mi(2),26),stre(6),prop(*),
& elcon(0:ncmat_,ntmat_,*),rhcon(0:1,ntmat_,*),xs2(3,7),
& alcon(0:6,ntmat_,*),vini(0:mi(2),*),thickness,
& alzero(*),orab(7,*),elas(21),rho,fn(0:mi(2),*),
& fnl(3,10),skl(3,3),beta(6),xl2(3,8),qa(4),
& vkl(0:3,3),t0(*),t1(*),prestr(6,mi(1),*),eme(6,mi(1),*),
& ckl(3,3),vold(0:mi(2),*),eloc(9),veold(0:mi(2),*),
& springarea(2,*),elconloc(21),eth(6),xkl(3,3),voldl(0:mi(2),26),
& xikl(3,3),ener(mi(1),*),emec(6),eei(6,mi(1),*),enerini(mi(1),*),
& emec0(6),veoldl(0:mi(2),26),xsj2(3),shp2(7,8),
& e,un,al,um,am1,xi,et,ze,tt,exx,eyy,ezz,exy,exz,eyz,
& xsj,vj,t0l,t1l,dtime,weight,pgauss(3),vij,time,ttime,
& plicon(0:2*npmat_,ntmat_,*),plkcon(0:2*npmat_,ntmat_,*),
& xstiff(27,mi(1),*),xstate(nstate_,mi(1),*),plconloc(802),
& vokl(3,3),xstateini(nstate_,mi(1),*),vikl(3,3),
& gs(8,4),a,reltime,tlayer(4),dlayer(4),xlayer(mi(3),4),
& thicke(mi(3),*),emeini(6,mi(1),*),clearini(3,9,*),
& pslavsurf(3,*),pmastsurf(6,*),sti(6,mi(1),*),
& fn0(0:mi(2),*),dfn(0:mi(2),*),hglf(3,4),ahr,
& dxstiff(27,mi(1),ne,*),xdesi(3,*)
!
intent(in) co,kon,ipkon,lakon,ne,v,
& stx,elcon,nelcon,rhcon,nrhcon,alcon,nalcon,alzero,
& ielmat,ielorien,norien,orab,ntmat_,t0,t1,ithermal,prestr,
& iprestr,eme,iperturb,fn,iout,vold,nmethod,
& veold,dtime,time,ttime,plicon,nplicon,plkcon,nplkcon,
& xstateini,xstate,npmat_,matname,mi,ielas,icmd,
& ncmat_,nstate_,stiini,vini,ener,eei,enerini,istep,iinc,
& springarea,reltime,calcul_fn,calcul_cauchy,nener,
& ikin,ne0,thicke,emeini,pslavsurf,
& pmastsurf,mortar,clearini,nea,neb,ielprop,prop,
& idesvar,nodedesi,sti,icoordinate,ialdesi,xdesi
!
intent(inout) dfn,fn0,dxstiff,xstiff
!
include "gauss.f"
!
iflag=3
null=0
qa(3)=-1.d0
qa(4)=0.d0
!
mt=mi(2)+1
!
! -------------------------------------------------------------
! Initialisation of the loop for the variation of
! the internal forces
! -------------------------------------------------------------
!
!
! Loop over all elements in thread
do ii=nea,neb
if(idesvar.gt.0) then
i=ialdesi(ii)
else
i=ii
endif
!
lakonl=lakon(i)
!
if(ipkon(i).lt.0) cycle
!
! no 3D-fluid elements
!
if(lakonl(1:1).eq.'F') cycle
if(lakonl(1:7).eq.'DCOUP3D') cycle
!
if(lakonl(7:8).ne.'LC') then
!
imat=ielmat(1,i)
amat=matname(imat)
if(norien.gt.0) then
iorien=ielorien(1,i)
else
iorien=0
endif
!
if(nelcon(1,imat).lt.0) then
ihyper=1
else
ihyper=0
endif
elseif(lakonl(4:5).eq.'20') then
!
! composite materials
!
mint2d=4
nopes=8
! determining the number of layers
!
nlayer=0
do k=1,mi(3)
if(ielmat(k,i).ne.0) then
nlayer=nlayer+1
endif
enddo
!
! determining the layer thickness and global thickness
! at the shell integration points
!
iflag=1
indexe=ipkon(i)
do kk=1,mint2d
xi=gauss3d2(1,kk)
et=gauss3d2(2,kk)
call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag)
tlayer(kk)=0.d0
do k=1,nlayer
thickness=0.d0
do j=1,nopes
thickness=thickness+thicke(k,indexe+j)*shp2(4,j)
enddo
tlayer(kk)=tlayer(kk)+thickness
xlayer(k,kk)=thickness
enddo
enddo
iflag=3
!
ilayer=0
do k=1,4
dlayer(k)=0.d0
enddo
elseif(lakonl(4:5).eq.'15') then
!
! composite materials
!
mint2d=3
nopes=6
! determining the number of layers
!
nlayer=0
do k=1,mi(3)
if(ielmat(k,i).ne.0) then
nlayer=nlayer+1
endif
enddo
!
! determining the layer thickness and global thickness
! at the shell integration points
!
iflag=1
indexe=ipkon(i)
do kk=1,mint2d
xi=gauss3d10(1,kk)
et=gauss3d10(2,kk)
call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag)
tlayer(kk)=0.d0
do k=1,nlayer
thickness=0.d0
do j=1,nopes
thickness=thickness+thicke(k,indexe+j)*shp2(4,j)
enddo
tlayer(kk)=tlayer(kk)+thickness
xlayer(k,kk)=thickness
enddo
enddo
iflag=3
!
ilayer=0
do k=1,3
dlayer(k)=0.d0
enddo
!
endif
!
indexe=ipkon(i)
c Bernhardi start
if(lakonl(1:5).eq.'C3D8I') then
nope=11
elseif(lakonl(4:5).eq.'20') then
c Bernhardi end
nope=20
elseif(lakonl(4:4).eq.'8') then
nope=8
elseif(lakonl(4:5).eq.'10') then
nope=10
elseif(lakonl(4:4).eq.'4') then
nope=4
elseif(lakonl(4:5).eq.'15') then
nope=15
elseif(lakonl(4:4).eq.'6') then
nope=6
elseif((lakonl(1:1).eq.'E').and.(lakonl(7:7).ne.'F')) then
!
! spring elements, contact spring elements and
! dashpot elements
!
if(lakonl(7:7).eq.'C') then
!
! contact spring elements
!
if(mortar.eq.1) then
!
! face-to-face penalty
!
nope=kon(ipkon(i))
elseif(mortar.eq.0) then
!
! node-to-face penalty
!
nope=ichar(lakonl(8:8))-47
konl(nope+1)=kon(indexe+nope+1)
endif
else
!
! genuine spring elements and dashpot elements
!
nope=ichar(lakonl(8:8))-47
endif
else
cycle
endif
!
! computation of the coordinates of the local nodes w/ variation
! if the designnode belongs to the considered element
!
if(idesvar.gt.0) then
!
if(icoordinate.eq.1) then
!
! the coordinates of the nodes are the design variables
!
do j=1,nope
node=kon(indexe+j)
if(node.eq.nodedesi(idesvar)) then
iactive=j
exit
endif
enddo
endif
!
endif
!
if(lakonl(4:5).eq.'8R') then
mint3d=1
elseif(lakonl(4:7).eq.'20RB') then
if((lakonl(8:8).eq.'R').or.(lakonl(8:8).eq.'C')) then
mint3d=50
else
call beamintscheme(lakonl,mint3d,ielprop(i),prop,
& null,xi,et,ze,weight)
endif
elseif((lakonl(4:4).eq.'8').or.
& (lakonl(4:6).eq.'20R')) then
if(lakonl(7:8).eq.'LC') then
mint3d=8*nlayer
else
mint3d=8
endif
elseif(lakonl(4:4).eq.'2') then
mint3d=27
elseif(lakonl(4:5).eq.'10') then
mint3d=4
elseif(lakonl(4:4).eq.'4') then
mint3d=1
elseif(lakonl(4:5).eq.'15') then
if(lakonl(7:8).eq.'LC') then
mint3d=6*nlayer
else
mint3d=9
endif
elseif(lakonl(4:4).eq.'6') then
mint3d=2
elseif(lakonl(1:1).eq.'E') then
mint3d=0
endif
do j=1,nope
konl(j)=kon(indexe+j)
do k=1,3
xl(k,j)=co(k,konl(j))
vl(k,j)=v(k,konl(j))
voldl(k,j)=vold(k,konl(j))
enddo
enddo
!
! computation of the coordinates of the local nodes w/ variation
! if the designnode belongs to the considered element
!
if((idesvar.gt.0).and.(icoordinate.eq.1)) then
do j=1,3
xl(j,iactive)=xl(j,iactive)+xdesi(j,idesvar)
enddo
endif
!
! calculating the forces for the contact elements
!
if(mint3d.eq.0) then
!
! "normal" spring and dashpot elements
!
kode=nelcon(1,imat)
if(lakonl(7:7).eq.'A') then
t0l=0.d0
t1l=0.d0
if(ithermal(1).eq.1) then
t0l=(t0(konl(1))+t0(konl(2)))/2.d0
t1l=(t1(konl(1))+t1(konl(2)))/2.d0
elseif(ithermal(1).ge.2) then
t0l=(t0(konl(1))+t0(konl(2)))/2.d0
t1l=(vold(0,konl(1))+vold(0,konl(2)))/2.d0
endif
endif
!
! spring elements (including contact springs)
!
if(lakonl(2:2).eq.'S') then
if((lakonl(7:7).eq.'A').or.(lakonl(7:7).eq.'1').or.
& (lakonl(7:7).eq.'2').or.((mortar.eq.0).and.
& ((nmethod.ne.1).or.(iperturb(1).ge.2).or.(iout.ne.-1))))
& then
call springforc_n2f(xl,konl,vl,imat,elcon,nelcon,elas,
& fnl,ncmat_,ntmat_,nope,lakonl,t1l,kode,elconloc,
& plicon,nplicon,npmat_,ener(1,i),nener,
& stx(1,1,i),mi,springarea(1,konl(nope+1)),nmethod,
& ne0,nstate_,xstateini,xstate,reltime,
& ielas,ener(1,i+ne),ielorien,orab,norien,i)
elseif((mortar.eq.1).and.
& ((nmethod.ne.1).or.(iperturb(1).ge.2).or.(iout.ne.-1)))
& then
jfaces=kon(indexe+nope+2)
igauss=kon(indexe+nope+1)
call springforc_f2f(xl,vl,imat,elcon,nelcon,elas,
& fnl,ncmat_,ntmat_,nope,lakonl,t1l,kode,elconloc,
& plicon,nplicon,npmat_,ener(1,i),nener,
& stx(1,1,i),mi,springarea(1,igauss),nmethod,
& ne0,nstate_,xstateini,xstate,reltime,
& ielas,jfaces,igauss,pslavsurf,pmastsurf,
& clearini,ener(1,i+ne),kscale,konl,iout,i)
endif
!
! next lines are not executed in linstatic.c before the
! setup of the stiffness matrix (i.e. nmethod=1 and
! iperturb(1)<1 and iout=-1).
!
if((lakonl(7:7).eq.'A').or.
& ((nmethod.ne.1).or.(iperturb(1).ge.2).or.(iout.ne.-1)))
& then
if(idesvar.eq.0) then
do j=1,nope
do k=1,3
fn0(k,indexe+j)=fn0(k,indexe+j)+fnl(k,j)
enddo
enddo
else
do j=1,nope
do k=1,3
dfn(k,konl(j))=dfn(k,konl(j))+fnl(k,j)
enddo
enddo
endif
endif
!
! dashpot elements (including contact dashpots)
!
elseif((nmethod.eq.4).or.(nmethod.eq.5).or.
& ((abs(nmethod).eq.1).and.(iperturb(1).ge.2))) then
endif
elseif(ikin.eq.1) then
do j=1,nope
do k=1,3
veoldl(k,j)=veold(k,konl(j))
enddo
enddo
endif
!
do jj=1,mint3d
if(lakonl(4:5).eq.'8R') then
xi=gauss3d1(1,jj)
et=gauss3d1(2,jj)
ze=gauss3d1(3,jj)
weight=weight3d1(jj)
elseif(lakonl(4:7).eq.'20RB') then
if((lakonl(8:8).eq.'R').or.(lakonl(8:8).eq.'C')) then
xi=gauss3d13(1,jj)
et=gauss3d13(2,jj)
ze=gauss3d13(3,jj)
weight=weight3d13(jj)
else
call beamintscheme(lakonl,mint3d,ielprop(i),prop,
& jj,xi,et,ze,weight)
endif
elseif((lakonl(4:4).eq.'8').or.
& (lakonl(4:6).eq.'20R'))
& then
if(lakonl(7:8).ne.'LC') then
xi=gauss3d2(1,jj)
et=gauss3d2(2,jj)
ze=gauss3d2(3,jj)
weight=weight3d2(jj)
else
kl=mod(jj,8)
if(kl.eq.0) kl=8
!
xi=gauss3d2(1,kl)
et=gauss3d2(2,kl)
ze=gauss3d2(3,kl)
weight=weight3d2(kl)
!
ki=mod(jj,4)
if(ki.eq.0) ki=4
!
if(kl.eq.1) then
ilayer=ilayer+1
if(ilayer.gt.1) then
do k=1,4
dlayer(k)=dlayer(k)+xlayer(ilayer-1,k)
enddo
endif
endif
ze=2.d0*(dlayer(ki)+(ze+1.d0)/2.d0*xlayer(ilayer,ki))/
& tlayer(ki)-1.d0
weight=weight*xlayer(ilayer,ki)/tlayer(ki)
!
! material and orientation
!
imat=ielmat(ilayer,i)
amat=matname(imat)
if(norien.gt.0) then
iorien=ielorien(ilayer,i)
else
iorien=0
endif
!
if(nelcon(1,imat).lt.0) then
ihyper=1
else
ihyper=0
endif
endif
elseif(lakonl(4:4).eq.'2') then
xi=gauss3d3(1,jj)
et=gauss3d3(2,jj)
ze=gauss3d3(3,jj)
weight=weight3d3(jj)
elseif(lakonl(4:5).eq.'10') then
xi=gauss3d5(1,jj)
et=gauss3d5(2,jj)
ze=gauss3d5(3,jj)
weight=weight3d5(jj)
elseif(lakonl(4:4).eq.'4') then
xi=gauss3d4(1,jj)
et=gauss3d4(2,jj)
ze=gauss3d4(3,jj)
weight=weight3d4(jj)
elseif(lakonl(4:5).eq.'15') then
if(lakonl(7:8).ne.'LC') then
xi=gauss3d8(1,jj)
et=gauss3d8(2,jj)
ze=gauss3d8(3,jj)
weight=weight3d8(jj)
else
kl=mod(jj,6)
if(kl.eq.0) kl=6
!
xi=gauss3d10(1,kl)
et=gauss3d10(2,kl)
ze=gauss3d10(3,kl)
weight=weight3d10(kl)
!
ki=mod(jj,3)
if(ki.eq.0) ki=3
!
if(kl.eq.1) then
ilayer=ilayer+1
if(ilayer.gt.1) then
do k=1,3
dlayer(k)=dlayer(k)+xlayer(ilayer-1,k)
enddo
endif
endif
ze=2.d0*(dlayer(ki)+(ze+1.d0)/2.d0*xlayer(ilayer,ki))/
& tlayer(ki)-1.d0
weight=weight*xlayer(ilayer,ki)/tlayer(ki)
!
! material and orientation
!
imat=ielmat(ilayer,i)
amat=matname(imat)
if(norien.gt.0) then
iorien=ielorien(ilayer,i)
else
iorien=0
endif
!
if(nelcon(1,imat).lt.0) then
ihyper=1
else
ihyper=0
endif
endif
elseif(lakonl(4:4).eq.'6') then
xi=gauss3d7(1,jj)
et=gauss3d7(2,jj)
ze=gauss3d7(3,jj)
weight=weight3d7(jj)
endif
!
c Bernhardi start
if(lakonl(1:5).eq.'C3D8R') then
call shape8hr(xl,xsj,shp,gs,a)
elseif(lakonl(1:5).eq.'C3D8I') then
call shape8hu(xi,et,ze,xl,xsj,shp,iflag)
elseif(nope.eq.20) then
c Bernhardi end
if(lakonl(7:7).eq.'A') then
call shape20h_ax(xi,et,ze,xl,xsj,shp,iflag)
elseif((lakonl(7:7).eq.'E').or.
& (lakonl(7:7).eq.'S')) then
call shape20h_pl(xi,et,ze,xl,xsj,shp,iflag)
else
call shape20h(xi,et,ze,xl,xsj,shp,iflag)
endif
elseif(nope.eq.8) then
call shape8h(xi,et,ze,xl,xsj,shp,iflag)
elseif(nope.eq.10) then
call shape10tet(xi,et,ze,xl,xsj,shp,iflag)
elseif(nope.eq.4) then
call shape4tet(xi,et,ze,xl,xsj,shp,iflag)
elseif(nope.eq.15) then
call shape15w(xi,et,ze,xl,xsj,shp,iflag)
else
call shape6w(xi,et,ze,xl,xsj,shp,iflag)
endif
!
! vkl(m2,m3) contains the derivative of the m2-
! component of the displacement with respect to
! direction m3
!
do m2=1,3
do m3=1,3
vkl(m2,m3)=0.d0
enddo
enddo
!
do m1=1,nope
do m2=1,3
do m3=1,3
vkl(m2,m3)=vkl(m2,m3)+shp(m3,m1)*vl(m2,m1)
enddo
c write(*,*) 'vnoeie',i,konl(m1),(vkl(m2,k),k=1,3)
enddo
enddo
!
! for frequency analysis or buckling with preload the
! strains are calculated with respect to the deformed
! configuration
! for a linear iteration within a nonlinear increment:
! the tangent matrix is calculated at strain at the end
! of the previous increment
!
if((iperturb(1).eq.1).or.(iperturb(1).eq.-1))then
do m2=1,3
do m3=1,3
vokl(m2,m3)=0.d0
enddo
enddo
!
do m1=1,nope
do m2=1,3
do m3=1,3
vokl(m2,m3)=vokl(m2,m3)+
& shp(m3,m1)*voldl(m2,m1)
enddo
enddo
enddo
endif
!
kode=nelcon(1,imat)
!
! calculating the strain
!
! attention! exy,exz and eyz are engineering strains!
!
exx=vkl(1,1)
eyy=vkl(2,2)
ezz=vkl(3,3)
exy=vkl(1,2)+vkl(2,1)
exz=vkl(1,3)+vkl(3,1)
eyz=vkl(2,3)+vkl(3,2)
!
if(iperturb(2).eq.1) then
!
! Lagrangian strain
!
exx=exx+(vkl(1,1)**2+vkl(2,1)**2+vkl(3,1)**2)/2.d0
eyy=eyy+(vkl(1,2)**2+vkl(2,2)**2+vkl(3,2)**2)/2.d0
ezz=ezz+(vkl(1,3)**2+vkl(2,3)**2+vkl(3,3)**2)/2.d0
exy=exy+vkl(1,1)*vkl(1,2)+vkl(2,1)*vkl(2,2)+
& vkl(3,1)*vkl(3,2)
exz=exz+vkl(1,1)*vkl(1,3)+vkl(2,1)*vkl(2,3)+
& vkl(3,1)*vkl(3,3)
eyz=eyz+vkl(1,2)*vkl(1,3)+vkl(2,2)*vkl(2,3)+
& vkl(3,2)*vkl(3,3)
!
! for frequency analysis or buckling with preload the
! strains are calculated with respect to the deformed
! configuration
!
elseif(iperturb(1).eq.1) then
exx=exx+vokl(1,1)*vkl(1,1)+vokl(2,1)*vkl(2,1)+
& vokl(3,1)*vkl(3,1)
eyy=eyy+vokl(1,2)*vkl(1,2)+vokl(2,2)*vkl(2,2)+
& vokl(3,2)*vkl(3,2)
ezz=ezz+vokl(1,3)*vkl(1,3)+vokl(2,3)*vkl(2,3)+
& vokl(3,3)*vkl(3,3)
exy=exy+vokl(1,1)*vkl(1,2)+vokl(1,2)*vkl(1,1)+
& vokl(2,1)*vkl(2,2)+vokl(2,2)*vkl(2,1)+
& vokl(3,1)*vkl(3,2)+vokl(3,2)*vkl(3,1)
exz=exz+vokl(1,1)*vkl(1,3)+vokl(1,3)*vkl(1,1)+
& vokl(2,1)*vkl(2,3)+vokl(2,3)*vkl(2,1)+
& vokl(3,1)*vkl(3,3)+vokl(3,3)*vkl(3,1)
eyz=eyz+vokl(1,2)*vkl(1,3)+vokl(1,3)*vkl(1,2)+
& vokl(2,2)*vkl(2,3)+vokl(2,3)*vkl(2,2)+
& vokl(3,2)*vkl(3,3)+vokl(3,3)*vkl(3,2)
endif
!
! storing the local strains
!
if(iperturb(1).ne.-1) then
eloc(1)=exx
eloc(2)=eyy
eloc(3)=ezz
eloc(4)=exy/2.d0
eloc(5)=exz/2.d0
eloc(6)=eyz/2.d0
else
!
! linear iteration within a nonlinear increment:
!
eloc(1)=vokl(1,1)+
& (vokl(1,1)**2+vokl(2,1)**2+vokl(3,1)**2)/2.d0
eloc(2)=vokl(2,2)+
& (vokl(1,2)**2+vokl(2,2)**2+vokl(3,2)**2)/2.d0
eloc(3)=vokl(3,3)+
& (vokl(1,3)**2+vokl(2,3)**2+vokl(3,3)**2)/2.d0
eloc(4)=(vokl(1,2)+vokl(2,1)+vokl(1,1)*vokl(1,2)+
& vokl(2,1)*vokl(2,2)+vokl(3,1)*vokl(3,2))/2.d0
eloc(5)=(vokl(1,3)+vokl(3,1)+vokl(1,1)*vokl(1,3)+
& vokl(2,1)*vokl(2,3)+vokl(3,1)*vokl(3,3))/2.d0
eloc(6)=(vokl(2,3)+vokl(3,2)+vokl(1,2)*vokl(1,3)+
& vokl(2,2)*vokl(2,3)+vokl(3,2)*vokl(3,3))/2.d0
endif
!
! calculating the deformation gradient (needed to
! convert the element stiffness matrix from spatial
! coordinates to material coordinates
! deformation plasticity)
!
if((kode.eq.-50).or.(kode.le.-100)) then
!
! calculating the deformation gradient
!
c Bernhardi start
xkl(1,1)=vkl(1,1)+1.0d0
xkl(2,2)=vkl(2,2)+1.0d0
xkl(3,3)=vkl(3,3)+1.0d0
c Bernhardi end
xkl(1,2)=vkl(1,2)
xkl(1,3)=vkl(1,3)
xkl(2,3)=vkl(2,3)
xkl(2,1)=vkl(2,1)
xkl(3,1)=vkl(3,1)
xkl(3,2)=vkl(3,2)
!
! calculating the Jacobian
!
vj=xkl(1,1)*(xkl(2,2)*xkl(3,3)-xkl(2,3)*xkl(3,2))
& -xkl(1,2)*(xkl(2,1)*xkl(3,3)-xkl(2,3)*xkl(3,1))
& +xkl(1,3)*(xkl(2,1)*xkl(3,2)-xkl(2,2)*xkl(3,1))
!
! inversion of the deformation gradient (only for
! deformation plasticity)
!
if(kode.eq.-50) then
!
ckl(1,1)=(xkl(2,2)*xkl(3,3)-xkl(2,3)*xkl(3,2))/vj
ckl(2,2)=(xkl(1,1)*xkl(3,3)-xkl(1,3)*xkl(3,1))/vj
ckl(3,3)=(xkl(1,1)*xkl(2,2)-xkl(1,2)*xkl(2,1))/vj
ckl(1,2)=(xkl(1,3)*xkl(3,2)-xkl(1,2)*xkl(3,3))/vj
ckl(1,3)=(xkl(1,2)*xkl(2,3)-xkl(2,2)*xkl(1,3))/vj
ckl(2,3)=(xkl(2,1)*xkl(1,3)-xkl(1,1)*xkl(2,3))/vj
ckl(2,1)=(xkl(3,1)*xkl(2,3)-xkl(2,1)*xkl(3,3))/vj
ckl(3,1)=(xkl(2,1)*xkl(3,2)-xkl(2,2)*xkl(3,1))/vj
ckl(3,2)=(xkl(3,1)*xkl(1,2)-xkl(1,1)*xkl(3,2))/vj
!
! converting the Lagrangian strain into Eulerian
! strain (only for deformation plasticity)
!
cauchy=0
call str2mat(eloc,ckl,vj,cauchy)
endif
!
endif
!
! calculating fields for incremental plasticity
!
if(kode.le.-100) then
!
! calculating the deformation gradient at the
! start of the increment
!
! calculating the displacement gradient at the
! start of the increment
!
do m2=1,3
do m3=1,3
vikl(m2,m3)=0.d0
enddo
enddo
!
do m1=1,nope
do m2=1,3
do m3=1,3
vikl(m2,m3)=vikl(m2,m3)
& +shp(m3,m1)*vini(m2,konl(m1))
enddo
enddo
enddo
!
! calculating the deformation gradient of the old
! fields
!
xikl(1,1)=vikl(1,1)+1.d0
xikl(2,2)=vikl(2,2)+1.d0
xikl(3,3)=vikl(3,3)+1.d0
xikl(1,2)=vikl(1,2)
xikl(1,3)=vikl(1,3)
xikl(2,3)=vikl(2,3)
xikl(2,1)=vikl(2,1)
xikl(3,1)=vikl(3,1)
xikl(3,2)=vikl(3,2)
!
! calculating the Jacobian
!
vij=xikl(1,1)*(xikl(2,2)*xikl(3,3)
& -xikl(2,3)*xikl(3,2))
& -xikl(1,2)*(xikl(2,1)*xikl(3,3)
& -xikl(2,3)*xikl(3,1))
& +xikl(1,3)*(xikl(2,1)*xikl(3,2)
& -xikl(2,2)*xikl(3,1))
!
! stresses at the start of the increment
!
do m1=1,6
stre(m1)=sti(m1,jj,i)
enddo
!
endif
!
! prestress values
!
if(iprestr.eq.1) then
do kk=1,6
beta(kk)=-prestr(kk,jj,i)
enddo
else
do kk=1,6
beta(kk)=0.d0
enddo
endif
!
if(ithermal(1).ge.1) then
!
! calculating the temperature difference in
! the integration point
!
t0l=0.d0
t1l=0.d0
if(ithermal(1).eq.1) then
if((lakonl(4:5).eq.'8 ').or.
& (lakonl(4:5).eq.'8I')) then
do i1=1,8
t0l=t0l+t0(konl(i1))/8.d0
t1l=t1l+t1(konl(i1))/8.d0
enddo
elseif(lakonl(4:6).eq.'20 ') then
nopered=20
call lintemp(t0,t1,konl,nopered,jj,t0l,t1l)
elseif(lakonl(4:6).eq.'10T') then
call linscal10(t0,konl,t0l,null,shp)
call linscal10(t1,konl,t1l,null,shp)
else
do i1=1,nope
t0l=t0l+shp(4,i1)*t0(konl(i1))
t1l=t1l+shp(4,i1)*t1(konl(i1))
enddo
endif
elseif(ithermal(1).ge.2) then
if((lakonl(4:5).eq.'8 ').or.
& (lakonl(4:5).eq.'8I')) then
do i1=1,8
t0l=t0l+t0(konl(i1))/8.d0
t1l=t1l+vold(0,konl(i1))/8.d0
enddo
elseif(lakonl(4:6).eq.'20 ') then
nopered=20
call lintemp_th(t0,vold,konl,nopered,jj,t0l,t1l,mi)
elseif(lakonl(4:6).eq.'10T') then
call linscal10(t0,konl,t0l,null,shp)
call linscal10(vold,konl,t1l,mi(2),shp)
else
do i1=1,nope
t0l=t0l+shp(4,i1)*t0(konl(i1))
t1l=t1l+shp(4,i1)*vold(0,konl(i1))
enddo
endif
endif
tt=t1l-t0l
endif
!
! calculating the coordinates of the integration point
! for material orientation purposes (for cylindrical
! coordinate systems)
!
if((iorien.gt.0).or.(kode.le.-100)) then
do j=1,3
pgauss(j)=0.d0
do i1=1,nope
pgauss(j)=pgauss(j)+shp(4,i1)*co(j,konl(i1))
enddo
enddo
endif
!
! material data; for linear elastic materials
! this includes the calculation of the stiffness
! matrix
!
istiff=0
!
call materialdata_me(elcon,nelcon,rhcon,nrhcon,alcon,
& nalcon,imat,amat,iorien,pgauss,orab,ntmat_,
& elas,rho,i,ithermal,alzero,mattyp,t0l,t1l,ihyper,
& istiff,elconloc,eth,kode,plicon,nplicon,
& plkcon,nplkcon,npmat_,plconloc,mi(1),dtime,jj,
& xstiff,ncmat_)
!
! determining the mechanical strain
!
if(ithermal(1).ne.0) then
do m1=1,6
emec(m1)=eloc(m1)-eth(m1)
c emec0(m1)=emeini(m1,jj,i)
enddo
else
do m1=1,6
emec(m1)=eloc(m1)
c emec0(m1)=emeini(m1,jj,i)
enddo
endif
if(kode.le.-100) then
do m1=1,6
emec0(m1)=emeini(m1,jj,i)
enddo
endif
!
! subtracting the plastic initial strains
!
if(iprestr.eq.2) then
do m1=1,6
emec(m1)=emec(m1)-prestr(m1,jj,i)
enddo
endif
!
! calculating the local stiffness and stress
!
nlgeom_undo=0
call mechmodel(elconloc,elas,emec,kode,emec0,ithermal,
& icmd,beta,stre,xkl,ckl,vj,xikl,vij,
& plconloc,xstate,xstateini,ielas,
& amat,t1l,dtime,time,ttime,i,jj,nstate_,mi(1),
& iorien,pgauss,orab,eloc,mattyp,qa(3),istep,iinc,
& ipkon,nmethod,iperturb,qa(4),nlgeom_undo)
!
if(((nmethod.ne.4).or.(iperturb(1).ne.0)).and.
& (nmethod.ne.5)) then
if(idesvar.eq.0) then
do m1=1,21
xstiff(m1,jj,i)=elas(m1)
enddo
elseif(icoordinate.ne.1) then
!
! for orientation design variables: store the modified
! stiffness matrix for use in mafillsmse
!
idir=idesvar-3*((idesvar-1)/3)
do m1=1,21
dxstiff(m1,jj,i,idir)=elas(m1)
enddo
endif
endif
!
if((iperturb(1).eq.-1).and.(nlgeom_undo.eq.0)) then
!
! if the forced displacements were changed at
! the start of a nonlinear step, the nodal
! forces due do this displacements are
! calculated in a purely linear way, and
! the first iteration is purely linear in order
! to allow the displacements to redistribute
! in a quasi-static way (only applies to
! quasi-static analyses (*STATIC))
!
eloc(1)=exx-vokl(1,1)
eloc(2)=eyy-vokl(2,2)
eloc(3)=ezz-vokl(3,3)
eloc(4)=exy-(vokl(1,2)+vokl(2,1))
eloc(5)=exz-(vokl(1,3)+vokl(3,1))
eloc(6)=eyz-(vokl(2,3)+vokl(3,2))
!
if(mattyp.eq.1) then
e=elas(1)
un=elas(2)
um=e/(1.d0+un)
al=un*um/(1.d0-2.d0*un)
um=um/2.d0
am1=al*(eloc(1)+eloc(2)+eloc(3))
stre(1)=am1+2.d0*um*eloc(1)
stre(2)=am1+2.d0*um*eloc(2)
stre(3)=am1+2.d0*um*eloc(3)
stre(4)=um*eloc(4)
stre(5)=um*eloc(5)
stre(6)=um*eloc(6)
elseif(mattyp.eq.2) then
stre(1)=eloc(1)*elas(1)+eloc(2)*elas(2)
& +eloc(3)*elas(4)
stre(2)=eloc(1)*elas(2)+eloc(2)*elas(3)
& +eloc(3)*elas(5)
stre(3)=eloc(1)*elas(4)+eloc(2)*elas(5)
& +eloc(3)*elas(6)
stre(4)=eloc(4)*elas(7)
stre(5)=eloc(5)*elas(8)
stre(6)=eloc(6)*elas(9)
elseif(mattyp.eq.3) then
stre(1)=eloc(1)*elas(1)+eloc(2)*elas(2)+
& eloc(3)*elas(4)+eloc(4)*elas(7)+
& eloc(5)*elas(11)+eloc(6)*elas(16)
stre(2)=eloc(1)*elas(2)+eloc(2)*elas(3)+
& eloc(3)*elas(5)+eloc(4)*elas(8)+
& eloc(5)*elas(12)+eloc(6)*elas(17)
stre(3)=eloc(1)*elas(4)+eloc(2)*elas(5)+
& eloc(3)*elas(6)+eloc(4)*elas(9)+
& eloc(5)*elas(13)+eloc(6)*elas(18)
stre(4)=eloc(1)*elas(7)+eloc(2)*elas(8)+
& eloc(3)*elas(9)+eloc(4)*elas(10)+
& eloc(5)*elas(14)+eloc(6)*elas(19)
stre(5)=eloc(1)*elas(11)+eloc(2)*elas(12)+
& eloc(3)*elas(13)+eloc(4)*elas(14)+
& eloc(5)*elas(15)+eloc(6)*elas(20)
stre(6)=eloc(1)*elas(16)+eloc(2)*elas(17)+
& eloc(3)*elas(18)+eloc(4)*elas(19)+
& eloc(5)*elas(20)+eloc(6)*elas(21)
endif
endif
!
skl(1,1)=stre(1)
skl(2,2)=stre(2)
skl(3,3)=stre(3)
skl(2,1)=stre(4)
skl(3,1)=stre(5)
skl(3,2)=stre(6)
!
skl(1,2)=skl(2,1)
skl(1,3)=skl(3,1)
skl(2,3)=skl(3,2)
!
! calculation of the nodal forces
!
if(calcul_fn.eq.1)then
if(idesvar.eq.0) then
!
! unperturbed state
!
do m1=1,nope
do m2=1,3
!
! linear elastic part
!
do m3=1,3
fn0(m2,indexe+m1)=fn0(m2,indexe+m1)+
& xsj*skl(m2,m3)*shp(m3,m1)*weight
enddo
!
! nonlinear geometric part
!
if((iperturb(2).eq.1).and.(nlgeom_undo.eq.0))
& then
do m3=1,3
do m4=1,3
fn0(m2,indexe+m1)=fn0(m2,indexe+m1)+
& xsj*skl(m4,m3)*weight*
& (vkl(m2,m4)*shp(m3,m1)+
& vkl(m2,m3)*shp(m4,m1))/2.d0
enddo
enddo
endif
!
enddo
enddo
c Bernhardi start
if(lakonl(1:5).eq.'C3D8R') then
ahr=elas(1)*a
!
do i1=1,3
do k=1,4
hglf(i1,k)=0.0d0
do j=1,8
hglf(i1,k)=hglf(i1,k)+gs(j,k)*vl(i1,j)
enddo
hglf(i1,k)=hglf(i1,k)*ahr
enddo
enddo
do i1=1,3
do j=1,8
do k=1,4
fn0(i1,indexe+j)=fn0(i1,indexe+j)+
& hglf(i1,k)*gs(j,k)
enddo
enddo
enddo
endif
c Bernhardi end
else
!
! perturbed state
!
do m1=1,nope
do m2=1,3
!
! linear elastic part
!
do m3=1,3
dfn(m2,konl(m1))=dfn(m2,konl(m1))+
& xsj*skl(m2,m3)*shp(m3,m1)*weight
enddo
!
! nonlinear geometric part
!
if((iperturb(2).eq.1).and.(nlgeom_undo.eq.0))
& then
do m3=1,3
do m4=1,3
dfn(m2,konl(m1))=dfn(m2,konl(m1))+
& xsj*skl(m4,m3)*weight*
& (vkl(m2,m4)*shp(m3,m1)+
& vkl(m2,m3)*shp(m4,m1))/2.d0
enddo
enddo
endif
!
enddo
enddo
c Bernhardi start
if(lakonl(1:5).eq.'C3D8R') then
!
ahr=elas(1)*a
!
do i1=1,3
do k=1,4
hglf(i1,k)=0.0d0
do j=1,8
hglf(i1,k)=hglf(i1,k)+gs(j,k)*vl(i1,j)
enddo
hglf(i1,k)=hglf(i1,k)*ahr
enddo
enddo
do i1=1,3
do j=1,8
do k=1,4
dfn(i1,konl(j))=dfn(i1,konl(j))
& +hglf(i1,k)*gs(j,k)
enddo
enddo
enddo
endif
c Bernhardi end
endif
endif
!
enddo ! enddo loop over the integration points
!
! subtracting the unperturbed state of the element at stake
!
if(idesvar.gt.0) then
do m1=1,nope
do m2=1,3
dfn(m2,konl(m1))=dfn(m2,konl(m1))
& -fn0(m2,indexe+m1)
enddo
enddo
endif
!
! end of loop over all elements in thread
enddo
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.10/src/changesolidsections.f | 4 | 6507 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 changesolidsections(inpc,textpart,set,istartset,
& iendset,ialset,nset,ielmat,matname,nmat,ielorien,orname,norien,
& lakon,thicke,kon,ipkon,irstrt,istep,istat,n,iline,ipol,inl,
& ipoinp,inp,cs,mcs,iaxial,ipoinpc,mi)
!
! reading the input deck: *CHANGE SOLID SECTION
!
implicit none
!
character*1 inpc(*)
character*8 lakon(*)
character*80 matname(*),orname(*),material,orientation
character*81 set(*),elset
character*132 textpart(16)
!
integer mi(*),istartset(*),iendset(*),ialset(*),ielmat(mi(3),*),
& ielorien(mi(3),*),kon(*),ipkon(*),indexe,irstrt,nset,nmat,
& norien,
& istep,istat,n,key,i,j,k,l,imaterial,iorientation,ipos,
& iline,ipol,inl,ipoinp(2,*),inp(3,*),mcs,iaxial,ipoinpc(0:*)
!
real*8 thicke(mi(3),*),thickness,pi,cs(17,*)
!
if(istep.eq.0) then
write(*,*) '*ERROR reading *CHANGE SOLID SECTION:'
write(*,*) ' *CHANGE SOLID SECTION should'
write(*,*) ' be placed within a step definition'
call exit(201)
endif
!
pi=4.d0*datan(1.d0)
!
orientation='
& '
elset='
& '
ipos=0
!
do i=2,n
if(textpart(i)(1:9).eq.'MATERIAL=') then
material=textpart(i)(10:89)
elseif(textpart(i)(1:12).eq.'ORIENTATION=') then
orientation=textpart(i)(13:92)
elseif(textpart(i)(1:6).eq.'ELSET=') then
elset=textpart(i)(7:86)
elset(81:81)=' '
ipos=index(elset,' ')
elset(ipos:ipos)='E'
else
write(*,*) '*WARNING reading *CHANGE SOLID SECTION:'
write(*,*) ' parameter not recognized:'
write(*,*) ' ',
& textpart(i)(1:index(textpart(i),' ')-1)
call inputwarning(inpc,ipoinpc,iline,
&"*CHANGE SOLID SECTIONQ%")
endif
enddo
!
! check for the existence of the set,the material and orientation
!
do i=1,nmat
if(matname(i).eq.material) exit
enddo
if(i.gt.nmat) then
do i=1,nmat
if(matname(i)(1:11).eq.'ANISO_CREEP') then
if(matname(i)(12:20).eq.material(1:9)) exit
elseif(matname(i)(1:10).eq.'ANISO_PLAS') then
if(matname(i)(11:20).eq.material(1:10)) exit
endif
enddo
endif
if(i.gt.nmat) then
write(*,*)
& '*ERROR reading *CHANGE SOLID SECTION: nonexistent material'
write(*,*) ' '
call inputerror(inpc,ipoinpc,iline,
&"*CHANGE SOLID SECTION%")
call exit(201)
endif
imaterial=i
!
if(orientation.eq.' ') then
iorientation=0
else
do i=1,norien
if(orname(i).eq.orientation) exit
enddo
if(i.gt.norien) then
write(*,*) '*ERROR reading *CHANGE SOLID SECTION:'
write(*,*) ' nonexistent orientation'
write(*,*) ' '
call inputerror(inpc,ipoinpc,iline,
&"*CHANGE SOLID SECTION%")
call exit(201)
endif
iorientation=i
endif
!
if(ipos.eq.0) then
write(*,*)
& '*ERROR reading *CHANGE SOLID SECTION: no element set ',elset
write(*,*) ' was been defined. '
call inputerror(inpc,ipoinpc,iline,
&"*CHANGE SOLID SECTION%")
call exit(201)
endif
do i=1,nset
if(set(i).eq.elset) exit
enddo
if(i.gt.nset) then
elset(ipos:ipos)=' '
write(*,*) '*ERROR reading *CHANGE SOLID SECTION:'
write(*,*) ' element set ',elset
write(*,*) ' has not yet been defined. '
call inputerror(inpc,ipoinpc,iline,
&"*CHANGE SOLID SECTION%")
call exit(201)
endif
!
! assigning the elements of the set the appropriate material
! and orientation number
!
do j=istartset(i),iendset(i)
if(ialset(j).gt.0) then
if((lakon(ialset(j))(1:1).eq.'B').or.
& (lakon(ialset(j))(1:1).eq.'S')) then
write(*,*) '*ERROR reading *CHANGE SOLID SECTION:'
write(*,*) ' *CHANGE SOLID SECTION can'
write(*,*) ' not be used for beam or shell elements
&'
write(*,*) ' Faulty element: ',ialset(j)
call exit(201)
endif
ielmat(1,ialset(j))=imaterial
if(norien.gt.0) ielorien(1,ialset(j))=iorientation
else
k=ialset(j-2)
do
k=k-ialset(j)
if(k.ge.ialset(j-1)) exit
if((lakon(k)(1:1).eq.'B').or.
& (lakon(k)(1:1).eq.'S')) then
write(*,*) '*ERROR reading *CHANGE SOLID SECTION:'
write(*,*) ' *CHANGE SOLID SECTION can'
write(*,*) ' not be used for beam or shell eleme
&nts'
write(*,*) ' Faulty element: ',k
call exit(201)
endif
ielmat(1,k)=imaterial
if(norien.gt.0) ielorien(1,k)=iorientation
enddo
endif
enddo
!
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
!
! assigning a thickness to plane stress elements and an angle to
! axisymmetric elements
!
if(key.eq.0) then
write(*,*) '*ERROR reading *CHANGE SOLID SECTION'
write(*,*) ' no second line allowed'
call inputerror(inpc,ipoinpc,iline,
&"*CHANGE SOLID SECTION%")
endif
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.16/src/radmatrix.f | 1 | 10082 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2019 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.
!
!
! center of gravity of the projection of the vertices for
! visibility purposes
! exact integration for one triangle: routine cubtri
! if the surfaces are far enough away, one-point integration
! is used
!
subroutine radmatrix(ntr,adrad,aurad,bcr,sideload,nelemload,
& xloadact,lakon,vold,ipkon,kon,co,nloadtr,tarea,tenv,physcon,
& erad,adview,auview,ithermal,iinc,iit,fenv,istep,dtime,ttime,
& time,iviewfile,xloadold,reltime,nmethod,mi,iemchange,nam,
& iamload,jqrad,irowrad,nzsrad)
!
implicit none
!
character*8 lakonl,lakon(*)
character*20 sideload(*)
!
integer ntr,nelemload(2,*),nope,nopes,mint2d,i,j,k,l,
& node,ifaceq(8,6),ifacet(6,4),iviewfile,mi(*),
& ifacew(8,5),nelem,ig,index,konl(20),iflag,
& ipkon(*),kon(*),nloadtr(*),i1,ithermal,iinc,iit,
& istep,jltyp,nfield,nmethod,iemchange,nam,
& iamload(2,*),irowrad(*),jqrad(*),nzsrad
!
real*8 adrad(*),aurad(*),bcr(ntr,1),xloadact(2,*),h(2),
& xl2(3,8),coords(3),dxsj2,temp,xi,et,weight,xsj2(3),
& vold(0:mi(2),*),co(3,*),shp2(7,8),xs2(3,7),
& areamean,tarea(*),tenv(*),erad(*),fenv(*),physcon(*),
& adview(*),auview(*),tl2(8),tvar(2),field,
& dtime,ttime,time,areaj,xloadold(2,*),reltime,
& fform
!
data ifaceq /4,3,2,1,11,10,9,12,
& 5,6,7,8,13,14,15,16,
& 1,2,6,5,9,18,13,17,
& 2,3,7,6,10,19,14,18,
& 3,4,8,7,11,20,15,19,
& 4,1,5,8,12,17,16,20/
data ifacet /1,3,2,7,6,5,
& 1,2,4,5,9,8,
& 2,3,4,6,10,9,
& 1,4,3,8,10,7/
data ifacew /1,3,2,9,8,7,0,0,
& 4,5,6,10,11,12,0,0,
& 1,2,5,4,7,14,10,13,
& 2,3,6,5,8,15,11,14,
& 4,6,3,1,12,15,9,13/
data iflag /2/
!
external fform
!
include "gauss.f"
!
tvar(1)=time
tvar(2)=ttime+time
!
! filling acr and bcr
!
do i1=1,ntr
i=nloadtr(i1)
nelem=nelemload(1,i)
lakonl=lakon(nelem)
!
! calculate the mean temperature of the face
!
read(sideload(i)(2:2),'(i1)') ig
!
! number of nodes and integration points in the face
!
if(lakonl(4:4).eq.'2') then
nope=20
nopes=8
elseif(lakonl(4:4).eq.'8') then
nope=8
nopes=4
elseif(lakonl(4:5).eq.'10') then
nope=10
nopes=6
elseif(lakonl(4:4).eq.'4') then
nope=4
nopes=3
elseif(lakonl(4:5).eq.'15') then
nope=15
else
nope=6
endif
!
if(lakonl(4:5).eq.'8R') then
mint2d=1
elseif((lakonl(4:4).eq.'8').or.(lakonl(4:6).eq.'20R'))
& then
if(lakonl(7:7).eq.'A') then
mint2d=2
else
mint2d=4
endif
elseif(lakonl(4:4).eq.'2') then
mint2d=9
elseif(lakonl(4:5).eq.'10') then
mint2d=3
elseif(lakonl(4:4).eq.'4') then
mint2d=1
endif
!
if(lakonl(4:4).eq.'6') then
mint2d=1
if(ig.le.2) then
nopes=3
else
nopes=4
endif
endif
if(lakonl(4:5).eq.'15') then
if(ig.le.2) then
mint2d=3
nopes=6
else
mint2d=4
nopes=8
endif
endif
!
! connectivity of the element
!
index=ipkon(nelem)
if(index.lt.0) then
write(*,*) '*ERROR in radmatrix: element ',nelem
write(*,*) ' is not defined'
call exit(201)
endif
do k=1,nope
konl(k)=kon(index+k)
enddo
!
! coordinates of the nodes belonging to the face
!
if((nope.eq.20).or.(nope.eq.8)) then
do k=1,nopes
tl2(k)=vold(0,konl(ifaceq(k,ig)))
!
do j=1,3
xl2(j,k)=co(j,konl(ifaceq(k,ig)))+
& vold(j,konl(ifaceq(k,ig)))
enddo
enddo
elseif((nope.eq.10).or.(nope.eq.4)) then
do k=1,nopes
tl2(k)=vold(0,konl(ifacet(k,ig)))
do j=1,3
xl2(j,k)=co(j,konl(ifacet(k,ig)))+
& vold(j,konl(ifacet(k,ig)))
enddo
enddo
else
do k=1,nopes
tl2(k)=vold(0,konl(ifacew(k,ig)))
do j=1,3
xl2(j,k)=co(j,konl(ifacew(k,ig)))+
& vold(j,konl(ifacew(k,ig)))
enddo
enddo
endif
!
! integration to obtain the center of gravity and the mean
! temperature; radiation coefficient
!
areamean=0.d0
tarea(i1)=0.d0
!
read(sideload(i)(2:2),'(i1)') jltyp
jltyp=jltyp+10
if(sideload(i)(5:6).ne.'NU') then
erad(i1)=xloadact(1,i)
!
! if an amplitude was defined for the emissivity it is
! assumed that the emissivity changes with the step, so
! acr has to be calculated anew in every iteration
!
if(nam.gt.0) then
if(iamload(1,i).ne.0) then
iemchange=1
endif
endif
else
erad(i1)=0.d0
endif
!
do l=1,mint2d
if((lakonl(4:5).eq.'8R').or.
& ((lakonl(4:4).eq.'6').and.(nopes.eq.4))) then
xi=gauss2d1(1,l)
et=gauss2d1(2,l)
weight=weight2d1(l)
elseif((lakonl(4:4).eq.'8').or.
& (lakonl(4:6).eq.'20R').or.
& ((lakonl(4:5).eq.'15').and.(nopes.eq.8))) then
xi=gauss2d2(1,l)
et=gauss2d2(2,l)
weight=weight2d2(l)
elseif(lakonl(4:4).eq.'2') then
xi=gauss2d3(1,l)
et=gauss2d3(2,l)
weight=weight2d3(l)
elseif((lakonl(4:5).eq.'10').or.
& ((lakonl(4:5).eq.'15').and.(nopes.eq.6))) then
xi=gauss2d5(1,l)
et=gauss2d5(2,l)
weight=weight2d5(l)
elseif((lakonl(4:4).eq.'4').or.
& ((lakonl(4:4).eq.'6').and.(nopes.eq.3))) then
xi=gauss2d4(1,l)
et=gauss2d4(2,l)
weight=weight2d4(l)
endif
!
if(nopes.eq.8) then
call shape8q(xi,et,xl2,xsj2,xs2,shp2,iflag)
elseif(nopes.eq.4) then
call shape4q(xi,et,xl2,xsj2,xs2,shp2,iflag)
elseif(nopes.eq.6) then
call shape6tri(xi,et,xl2,xsj2,xs2,shp2,iflag)
else
call shape3tri(xi,et,xl2,xsj2,xs2,shp2,iflag)
endif
!
dxsj2=dsqrt(xsj2(1)*xsj2(1)+xsj2(2)*xsj2(2)+
& xsj2(3)*xsj2(3))
!
temp=0.d0
do j=1,nopes
temp=temp+tl2(j)*shp2(4,j)
enddo
!
tarea(i1)=tarea(i1)+temp*dxsj2*weight
areamean=areamean+dxsj2*weight
!
if(sideload(i)(5:6).eq.'NU') then
areaj=dxsj2*weight
do k=1,3
coords(k)=0.d0
enddo
do j=1,nopes
do k=1,3
coords(k)=coords(k)+xl2(k,j)*shp2(4,j)
enddo
enddo
call radiate(h(1),tenv(i1),temp,istep,
& iinc,tvar,nelem,l,coords,jltyp,field,nfield,
& sideload(i),node,areaj,vold,mi,iemchange)
if(nmethod.eq.1) h(1)=xloadold(1,i)+
& (h(1)-xloadold(1,i))*reltime
erad(i1)=erad(i1)+h(1)
endif
!
enddo
tarea(i1)=tarea(i1)/areamean-physcon(1)
if(sideload(i)(5:6).eq.'NU') then
erad(i1)=erad(i1)/mint2d
endif
!
! updating the right hand side
!
bcr(i1,1)=physcon(2)*(erad(i1)*tarea(i1)**4+
& (1.d0-erad(i1))*fenv(i1)*tenv(i1)**4)
c write(*,*) 'radmatrix ',bcr(i1,1)
!
enddo
!
! adrad and aurad is recalculated only if the viewfactors
! or the emissivity changed
!
if(((ithermal.eq.3).and.(iviewfile.ge.0)).or.
& ((iit.eq.-1).and.(iviewfile.ne.-2)).or.(iemchange.eq.1).or.
& ((iit.eq.0).and.(abs(nmethod).eq.1))) then
!
do i=1,ntr
erad(i)=1.d0-erad(i)
enddo
!
! diagonal entries
!
do i=1,ntr
adrad(i)=1.d0-erad(i)*adview(i)
enddo
!
! lower triangular entries
!
do i=1,nzsrad
aurad(i)=-erad(irowrad(i))*auview(i)
enddo
!
! upper triangular entries
!
do i=1,ntr
do j=nzsrad+jqrad(i),nzsrad+jqrad(i+1)-1
aurad(j)=-erad(i)*auview(j)
enddo
enddo
!
do i=1,ntr
erad(i)=1.d0-erad(i)
enddo
endif
!
return
end
| gpl-2.0 |
spthm/sphray | src/OpenGL/OpenGL_openglut.F90 | 2 | 67729 | MODULE OpenGL_glut
USE OpenGL_kinds
IMPLICIT NONE
PRIVATE
! Portions copyright (C) 2004, the OpenGLUT project contributors.
! OpenGLUT branched from freeglut in February, 2004.
!
! openglut.h
!
! The openglut library include file
!
! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
! PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
! IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
! CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
! openglut_std.h
!
! The GLUT-compatible part of the OpenGLUT library include file
!
! Portions copyright (c) 2004, the OpenGLUT project contributors.
! OpenGLUT branched from freeglut in Feburary, 2004.
!
! Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
! Written by Pawel W. Olszta, <olszta@sourceforge.net>
! Creation date: Thu Dec 2 1999
!
! Permission is hereby granted, free of charge, to any person obtaining a
! copy of this software and associated documentation files (the "Software"),
! to deal in the Software without restriction, including without limitation
! the rights to use, copy, modify, merge, publish, distribute, sublicense,
! and/or sell copies of the Software, and to permit persons to whom the
! Software is furnished to do so, subject to the following conditions:
!
! The above copyright notice and this permission notice shall be included
! in all copies or substantial portions of the Software.
!
! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
! PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
! IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
! CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
! The OpenGLUT, freeglut, and GLUT API versions
!
! FREEGLUT and FREEGLUT_VERSION are commented out. Unless
! OpenGLUT is going to ensure very good freeglut compatibility,
! providing freeglut API level symbols is probably more harmful than helpful.
! Let the application programmer use the OpenGLUT version to determine
! features, not our pseudo-freeglut version compatibility.
!
! If this is an issue, we can re-enable it later.
!
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_API_VERSION = 4
! GLUT API macro definitions -- the special key codes:
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F1 = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F2 = z'0002'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F3 = z'0003'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F4 = z'0004'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F5 = z'0005'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F6 = z'0006'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F7 = z'0007'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F8 = z'0008'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F9 = z'0009'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F10 = z'000A'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F11 = z'000B'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_F12 = z'000C'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_LEFT = z'0064'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_UP = z'0065'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_RIGHT = z'0066'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_DOWN = z'0067'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_PAGE_UP = z'0068'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_PAGE_DOWN = z'0069'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_HOME = z'006A'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_END = z'006B'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_INSERT = z'006C'
! GLUT API macro definitions -- mouse state definitions
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_LEFT_BUTTON = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_MIDDLE_BUTTON = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_RIGHT_BUTTON = z'0002'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_DOWN = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_UP = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_LEFT = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_ENTERED = z'0001'
! GLUT API macro definitions -- the display mode definitions
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_RGB = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_RGBA = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_INDEX = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_SINGLE = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_DOUBLE = z'0002'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_ACCUM = z'0004'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_ALPHA = z'0008'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_DEPTH = z'0010'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_STENCIL = z'0020'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_MULTISAMPLE = z'0080'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_STEREO = z'0100'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_LUMINANCE = z'0200'
! GLUT API macro definitions -- windows and menu related definitions
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_MENU_NOT_IN_USE = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_MENU_IN_USE = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_NOT_VISIBLE = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VISIBLE = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_HIDDEN = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_FULLY_RETAINED = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_PARTIALLY_RETAINED = z'0002'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_FULLY_COVERED = z'0003'
! GLUT API macro definitions -- fonts definitions
! ???, , PUBLIC :: GLUT_STROKE_ROMAN=((void *)0x0000)
! ???, , PUBLIC :: GLUT_STROKE_MONO_ROMAN=((void *)0x0001)
! ???, , PUBLIC :: GLUT_BITMAP_9_BY_15=((void *)0x0002)
! ???, , PUBLIC :: GLUT_BITMAP_8_BY_13=((void *)0x0003)
! ???, , PUBLIC :: GLUT_BITMAP_TIMES_ROMAN_10=((void *)0x0004)
! ???, , PUBLIC :: GLUT_BITMAP_TIMES_ROMAN_24=((void *)0x0005)
! ???, , PUBLIC :: GLUT_BITMAP_HELVETICA_10=((void *)0x0006)
! ???, , PUBLIC :: GLUT_BITMAP_HELVETICA_12=((void *)0x0007)
! ???, , PUBLIC :: GLUT_BITMAP_HELVETICA_18=((void *)0x0008)
! GLUT API macro definitions -- the glutGet parameters
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_X = z'0064'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_Y = z'0065'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_WIDTH = z'0066'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_HEIGHT = z'0067'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_BUFFER_SIZE = z'0068'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_STENCIL_SIZE = z'0069'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_DEPTH_SIZE = z'006A'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_RED_SIZE = z'006B'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_GREEN_SIZE = z'006C'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_BLUE_SIZE = z'006D'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_ALPHA_SIZE = z'006E'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_ACCUM_RED_SIZE = z'006F'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_ACCUM_GREEN_SIZE = z'0070'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_ACCUM_BLUE_SIZE = z'0071'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_ACCUM_ALPHA_SIZE = z'0072'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_DOUBLEBUFFER = z'0073'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_RGBA = z'0074'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_PARENT = z'0075'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_NUM_CHILDREN = z'0076'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_COLORMAP_SIZE = z'0077'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_NUM_SAMPLES = z'0078'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_STEREO = z'0079'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_CURSOR = z'007A'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_SCREEN_WIDTH = z'00C8'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_SCREEN_HEIGHT = z'00C9'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_SCREEN_WIDTH_MM = z'00CA'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_SCREEN_HEIGHT_MM = z'00CB'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_MENU_NUM_ITEMS = z'012C'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_DISPLAY_MODE_POSSIBLE = z'0190'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_INIT_WINDOW_X = z'01F4'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_INIT_WINDOW_Y = z'01F5'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_INIT_WINDOW_WIDTH = z'01F6'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_INIT_WINDOW_HEIGHT = z'01F7'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_INIT_DISPLAY_MODE = z'01F8'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_ELAPSED_TIME = z'02BC'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_FORMAT_ID = z'007B'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_INIT_STATE = z'007C'
! GLUT API macro definitions -- the glutDeviceGet parameters
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_HAS_KEYBOARD = z'0258'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_HAS_MOUSE = z'0259'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_HAS_SPACEBALL = z'025A'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_HAS_DIAL_AND_BUTTON_BOX = z'025B'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_HAS_TABLET = z'025C'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_NUM_MOUSE_BUTTONS = z'025D'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_NUM_SPACEBALL_BUTTONS = z'025E'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_NUM_BUTTON_BOX_BUTTONS = z'025F'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_NUM_DIALS = z'0260'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_NUM_TABLET_BUTTONS = z'0261'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_DEVICE_IGNORE_KEY_REPEAT = z'0262'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_DEVICE_KEY_REPEAT = z'0263'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_HAS_JOYSTICK = z'0264'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_OWNS_JOYSTICK = z'0265'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_JOYSTICK_BUTTONS = z'0266'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_JOYSTICK_AXES = z'0267'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_JOYSTICK_POLL_RATE = z'0268'
! GLUT API macro definitions -- the glutLayerGet parameters
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_OVERLAY_POSSIBLE = z'0320'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_LAYER_IN_USE = z'0321'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_HAS_OVERLAY = z'0322'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_TRANSPARENT_INDEX = z'0323'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_NORMAL_DAMAGED = z'0324'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_OVERLAY_DAMAGED = z'0325'
! GLUT API macro definitions -- the glutVideoResizeGet parameters
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VIDEO_RESIZE_POSSIBLE = z'0384'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VIDEO_RESIZE_IN_USE = z'0385'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VIDEO_RESIZE_X_DELTA = z'0386'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VIDEO_RESIZE_Y_DELTA = z'0387'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VIDEO_RESIZE_WIDTH_DELTA = z'0388'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VIDEO_RESIZE_HEIGHT_DELTA = z'0389'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VIDEO_RESIZE_X = z'038A'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VIDEO_RESIZE_Y = z'038B'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VIDEO_RESIZE_WIDTH = z'038C'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VIDEO_RESIZE_HEIGHT = z'038D'
! GLUT API macro definitions -- the glutUseLayer parameters
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_NORMAL = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_OVERLAY = z'0001'
! GLUT API macro definitions -- the glutGetModifiers parameters
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_ACTIVE_SHIFT = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_ACTIVE_CTRL = z'0002'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_ACTIVE_ALT = z'0004'
! GLUT API macro definitions -- the glutSetCursor parameters
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_RIGHT_ARROW = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_LEFT_ARROW = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_INFO = z'0002'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_DESTROY = z'0003'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_HELP = z'0004'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_CYCLE = z'0005'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_SPRAY = z'0006'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_WAIT = z'0007'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_TEXT = z'0008'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_CROSSHAIR = z'0009'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_UP_DOWN = z'000A'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_LEFT_RIGHT = z'000B'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_TOP_SIDE = z'000C'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_BOTTOM_SIDE = z'000D'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_LEFT_SIDE = z'000E'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_RIGHT_SIDE = z'000F'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_TOP_LEFT_CORNER = z'0010'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_TOP_RIGHT_CORNER = z'0011'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_BOTTOM_RIGHT_CORNER = z'0012'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_BOTTOM_LEFT_CORNER = z'0013'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_INHERIT = z'0064'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_NONE = z'0065'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CURSOR_FULL_CROSSHAIR = z'0066'
! GLUT API macro definitions -- RGB color component specification definitions
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_RED = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_GREEN = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_BLUE = z'0002'
! GLUT API macro definitions -- additional keyboard and joystick definitions
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_REPEAT_OFF = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_REPEAT_ON = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_KEY_REPEAT_DEFAULT = z'0002'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_JOYSTICK_BUTTON_A = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_JOYSTICK_BUTTON_B = z'0002'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_JOYSTICK_BUTTON_C = z'0004'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_JOYSTICK_BUTTON_D = z'0008'
! GLUT API macro definitions -- game mode definitions
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_GAME_MODE_ACTIVE = z'0000'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_GAME_MODE_POSSIBLE = z'0001'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_GAME_MODE_WIDTH = z'0002'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_GAME_MODE_HEIGHT = z'0003'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_GAME_MODE_PIXEL_DEPTH = z'0004'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_GAME_MODE_REFRESH_RATE = z'0005'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_GAME_MODE_DISPLAY_CHANGED = z'0006'
! Initialization functions, see og_init.c
! void glutInit( int* pargc, char** argv )
PUBLIC glutInit
INTERFACE glutInit
MODULE PROCEDURE glutInit_f03
END INTERFACE glutInit
INTERFACE
SUBROUTINE glutInit_gl(pargc, argv) BIND(C,NAME="glutInit")
IMPORT
! INTEGER(GLint), DIMENSION(*) :: pargc
INTEGER(GLint) :: pargc
TYPE(C_PTR), INTENT(IN) :: argv
END SUBROUTINE glutInit_gl
END INTERFACE
! void glutInitWindowPosition( int x, int y )
PUBLIC glutInitWindowPosition
INTERFACE
SUBROUTINE glutInitWindowPosition(x, y) BIND(C,NAME="glutInitWindowPosition")
IMPORT
INTEGER(GLint), VALUE :: x, y
END SUBROUTINE glutInitWindowPosition
END INTERFACE
! void glutInitWindowSize( int width, int height )
PUBLIC glutInitWindowSize
INTERFACE
SUBROUTINE glutInitWindowSize(width, height) BIND(C,NAME="glutInitWindowSize")
IMPORT
INTEGER(GLint), VALUE :: width, height
END SUBROUTINE glutInitWindowSize
END INTERFACE
! void glutInitDisplayMode( unsigned int displayMode )
PUBLIC glutInitDisplayMode
INTERFACE
SUBROUTINE glutInitDisplayMode(displayMode) BIND(C,NAME="glutInitDisplayMode")
IMPORT
INTEGER(GLuint), VALUE :: displayMode
END SUBROUTINE glutInitDisplayMode
END INTERFACE
! void glutInitDisplayString( const char* displayMode )
PUBLIC glutInitDisplayString
INTERFACE
SUBROUTINE glutInitDisplayString(displayMode) BIND(C,NAME="glutInitDisplayString")
IMPORT
! CHARACTER, INTENT(IN) :: displayMode
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: displayMode
END SUBROUTINE glutInitDisplayString
END INTERFACE
! Process loop function, see og_main.c
! void glutMainLoop( void )
PUBLIC glutMainLoop
INTERFACE
SUBROUTINE glutMainLoop() BIND(C,NAME="glutMainLoop")
IMPORT
END SUBROUTINE glutMainLoop
END INTERFACE
! Window management functions, see og_window.c
! int glutCreateWindow( const char* title )
PUBLIC glutCreateWindow
INTERFACE
FUNCTION glutCreateWindow(title) BIND(C,NAME="glutCreateWindow")
IMPORT
INTEGER(GLint) :: glutCreateWindow
! CHARACTER, INTENT(IN) :: title
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: title
END FUNCTION glutCreateWindow
END INTERFACE
! int glutCreateSubWindow( int window, int x, int y, int width, int height)
PUBLIC glutCreateSubWindow
INTERFACE
FUNCTION glutCreateSubWindow(window, x, y, width, height) BIND(C,NAME="glutCreateSubWindow")
IMPORT
INTEGER(GLint) :: glutCreateSubWindow
INTEGER(GLint), VALUE :: window, x, y, width, height
END FUNCTION glutCreateSubWindow
END INTERFACE
! void glutDestroyWindow( int window )
PUBLIC glutDestroyWindow
INTERFACE
SUBROUTINE glutDestroyWindow(window) BIND(C,NAME="glutDestroyWindow")
IMPORT
INTEGER(GLint), VALUE :: window
END SUBROUTINE glutDestroyWindow
END INTERFACE
! void glutSetWindow( int window )
PUBLIC glutSetWindow
INTERFACE
SUBROUTINE glutSetWindow(window) BIND(C,NAME="glutSetWindow")
IMPORT
INTEGER(GLint), VALUE :: window
END SUBROUTINE glutSetWindow
END INTERFACE
! int glutGetWindow( void )
PUBLIC glutGetWindow
INTERFACE
FUNCTION glutGetWindow() BIND(C,NAME="glutGetWindow")
IMPORT
INTEGER(GLint) :: glutGetWindow
END FUNCTION glutGetWindow
END INTERFACE
! void glutSetWindowTitle( const char* title )
PUBLIC glutSetWindowTitle
INTERFACE
SUBROUTINE glutSetWindowTitle(title) BIND(C,NAME="glutSetWindowTitle")
IMPORT
! CHARACTER, INTENT(IN) :: title
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: title
END SUBROUTINE glutSetWindowTitle
END INTERFACE
! void glutSetIconTitle( const char* title )
PUBLIC glutSetIconTitle
INTERFACE
SUBROUTINE glutSetIconTitle(title) BIND(C,NAME="glutSetIconTitle")
IMPORT
! CHARACTER, INTENT(IN) :: title
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: title
END SUBROUTINE glutSetIconTitle
END INTERFACE
! void glutReshapeWindow( int width, int height )
PUBLIC glutReshapeWindow
INTERFACE
SUBROUTINE glutReshapeWindow(width, height) BIND(C,NAME="glutReshapeWindow")
IMPORT
INTEGER(GLint), VALUE :: width, height
END SUBROUTINE glutReshapeWindow
END INTERFACE
! void glutPositionWindow( int x, int y )
PUBLIC glutPositionWindow
INTERFACE
SUBROUTINE glutPositionWindow(x, y) BIND(C,NAME="glutPositionWindow")
IMPORT
INTEGER(GLint), VALUE :: x, y
END SUBROUTINE glutPositionWindow
END INTERFACE
! void glutShowWindow( void )
PUBLIC glutShowWindow
INTERFACE
SUBROUTINE glutShowWindow() BIND(C,NAME="glutShowWindow")
IMPORT
END SUBROUTINE glutShowWindow
END INTERFACE
! void glutHideWindow( void )
PUBLIC glutHideWindow
INTERFACE
SUBROUTINE glutHideWindow() BIND(C,NAME="glutHideWindow")
IMPORT
END SUBROUTINE glutHideWindow
END INTERFACE
! void glutIconifyWindow( void )
PUBLIC glutIconifyWindow
INTERFACE
SUBROUTINE glutIconifyWindow() BIND(C,NAME="glutIconifyWindow")
IMPORT
END SUBROUTINE glutIconifyWindow
END INTERFACE
! void glutPushWindow( void )
PUBLIC glutPushWindow
INTERFACE
SUBROUTINE glutPushWindow() BIND(C,NAME="glutPushWindow")
IMPORT
END SUBROUTINE glutPushWindow
END INTERFACE
! void glutPopWindow( void )
PUBLIC glutPopWindow
INTERFACE
SUBROUTINE glutPopWindow() BIND(C,NAME="glutPopWindow")
IMPORT
END SUBROUTINE glutPopWindow
END INTERFACE
! void glutFullScreen( void )
PUBLIC glutFullScreen
INTERFACE
SUBROUTINE glutFullScreen() BIND(C,NAME="glutFullScreen")
IMPORT
END SUBROUTINE glutFullScreen
END INTERFACE
! Display-connected functions, see og_display.c
! void glutPostWindowRedisplay( int window )
PUBLIC glutPostWindowRedisplay
INTERFACE
SUBROUTINE glutPostWindowRedisplay(window) BIND(C,NAME="glutPostWindowRedisplay")
IMPORT
INTEGER(GLint), VALUE :: window
END SUBROUTINE glutPostWindowRedisplay
END INTERFACE
! void glutPostRedisplay( void )
PUBLIC glutPostRedisplay
INTERFACE
SUBROUTINE glutPostRedisplay() BIND(C,NAME="glutPostRedisplay")
IMPORT
END SUBROUTINE glutPostRedisplay
END INTERFACE
! void glutSwapBuffers( void )
PUBLIC glutSwapBuffers
INTERFACE
SUBROUTINE glutSwapBuffers() BIND(C,NAME="glutSwapBuffers")
IMPORT
END SUBROUTINE glutSwapBuffers
END INTERFACE
! Mouse cursor functions, see og_cursor.c
! void glutWarpPointer( int x, int y )
PUBLIC glutWarpPointer
INTERFACE
SUBROUTINE glutWarpPointer(x, y) BIND(C,NAME="glutWarpPointer")
IMPORT
INTEGER(GLint), VALUE :: x, y
END SUBROUTINE glutWarpPointer
END INTERFACE
! void glutSetCursor( int cursor )
PUBLIC glutSetCursor
INTERFACE
SUBROUTINE glutSetCursor(cursor) BIND(C,NAME="glutSetCursor")
IMPORT
INTEGER(GLint), VALUE :: cursor
END SUBROUTINE glutSetCursor
END INTERFACE
! Overlay stuff, see og_overlay.c
! void glutEstablishOverlay( void )
PUBLIC glutEstablishOverlay
INTERFACE
SUBROUTINE glutEstablishOverlay() BIND(C,NAME="glutEstablishOverlay")
IMPORT
END SUBROUTINE glutEstablishOverlay
END INTERFACE
! void glutRemoveOverlay( void )
PUBLIC glutRemoveOverlay
INTERFACE
SUBROUTINE glutRemoveOverlay() BIND(C,NAME="glutRemoveOverlay")
IMPORT
END SUBROUTINE glutRemoveOverlay
END INTERFACE
! void glutUseLayer( GLenum layer )
PUBLIC glutUseLayer
INTERFACE
SUBROUTINE glutUseLayer(layer) BIND(C,NAME="glutUseLayer")
IMPORT
INTEGER(GLenum), VALUE :: layer
END SUBROUTINE glutUseLayer
END INTERFACE
! void glutPostOverlayRedisplay( void )
PUBLIC glutPostOverlayRedisplay
INTERFACE
SUBROUTINE glutPostOverlayRedisplay() BIND(C,NAME="glutPostOverlayRedisplay")
IMPORT
END SUBROUTINE glutPostOverlayRedisplay
END INTERFACE
! void glutPostWindowOverlayRedisplay( int window )
PUBLIC glutPostWindowOverlayRedisplay
INTERFACE
SUBROUTINE glutPostWindowOverlayRedisplay(window) BIND(C,NAME="glutPostWindowOverlayRedisplay")
IMPORT
INTEGER(GLint), VALUE :: window
END SUBROUTINE glutPostWindowOverlayRedisplay
END INTERFACE
! void glutShowOverlay( void )
PUBLIC glutShowOverlay
INTERFACE
SUBROUTINE glutShowOverlay() BIND(C,NAME="glutShowOverlay")
IMPORT
END SUBROUTINE glutShowOverlay
END INTERFACE
! void glutHideOverlay( void )
PUBLIC glutHideOverlay
INTERFACE
SUBROUTINE glutHideOverlay() BIND(C,NAME="glutHideOverlay")
IMPORT
END SUBROUTINE glutHideOverlay
END INTERFACE
! Menu stuff, see og_menu.c
! int glutCreateMenu( void (* callback)( int menu ) )
PUBLIC glutCreateMenu
INTERFACE
FUNCTION glutCreateMenu(proc) BIND(C,NAME="glutCreateMenu")
IMPORT
INTEGER(GLint) :: glutCreateMenu
! void proc( int menu )
INTERFACE
SUBROUTINE proc(menu) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: menu
END SUBROUTINE proc
END INTERFACE
END FUNCTION glutCreateMenu
END INTERFACE
! void glutDestroyMenu( int menu )
PUBLIC glutDestroyMenu
INTERFACE
SUBROUTINE glutDestroyMenu(menu) BIND(C,NAME="glutDestroyMenu")
IMPORT
INTEGER(GLint), VALUE :: menu
END SUBROUTINE glutDestroyMenu
END INTERFACE
! int glutGetMenu( void )
PUBLIC glutGetMenu
INTERFACE
FUNCTION glutGetMenu() BIND(C,NAME="glutGetMenu")
IMPORT
INTEGER(GLint) :: glutGetMenu
END FUNCTION glutGetMenu
END INTERFACE
! void glutSetMenu( int menu )
PUBLIC glutSetMenu
INTERFACE
SUBROUTINE glutSetMenu(menu) BIND(C,NAME="glutSetMenu")
IMPORT
INTEGER(GLint), VALUE :: menu
END SUBROUTINE glutSetMenu
END INTERFACE
! void glutAddMenuEntry( const char* label, int value )
PUBLIC glutAddMenuEntry
INTERFACE
SUBROUTINE glutAddMenuEntry(label, value) BIND(C,NAME="glutAddMenuEntry")
IMPORT
! CHARACTER, INTENT(IN) :: label
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: label
INTEGER(GLint), VALUE :: value
END SUBROUTINE glutAddMenuEntry
END INTERFACE
! void glutAddSubMenu( const char* label, int subMenu )
PUBLIC glutAddSubMenu
INTERFACE
SUBROUTINE glutAddSubMenu(label, subMenu) BIND(C,NAME="glutAddSubMenu")
IMPORT
! CHARACTER, INTENT(IN) :: label
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: label
INTEGER(GLint), VALUE :: subMenu
END SUBROUTINE glutAddSubMenu
END INTERFACE
! void glutChangeToMenuEntry( int item, const char* label, int value)
PUBLIC glutChangeToMenuEntry
INTERFACE
SUBROUTINE glutChangeToMenuEntry(item, label, value) BIND(C,NAME="glutChangeToMenuEntry")
IMPORT
! CHARACTER, INTENT(IN) :: label
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: label
INTEGER(GLint), VALUE :: item, value
END SUBROUTINE glutChangeToMenuEntry
END INTERFACE
! void glutChangeToSubMenu( int item, const char* label, int value)
PUBLIC glutChangeToSubMenu
INTERFACE
SUBROUTINE glutChangeToSubMenu(item, label, value) BIND(C,NAME="glutChangeToSubMenu")
IMPORT
! CHARACTER, INTENT(IN) :: label
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: label
INTEGER(GLint), VALUE :: item, value
END SUBROUTINE glutChangeToSubMenu
END INTERFACE
! void glutRemoveMenuItem( int item )
PUBLIC glutRemoveMenuItem
INTERFACE
SUBROUTINE glutRemoveMenuItem(item) BIND(C,NAME="glutRemoveMenuItem")
IMPORT
INTEGER(GLint), VALUE :: item
END SUBROUTINE glutRemoveMenuItem
END INTERFACE
! void glutAttachMenu( int button )
PUBLIC glutAttachMenu
INTERFACE
SUBROUTINE glutAttachMenu(button) BIND(C,NAME="glutAttachMenu")
IMPORT
INTEGER(GLint), VALUE :: button
END SUBROUTINE glutAttachMenu
END INTERFACE
! void glutDetachMenu( int button )
PUBLIC glutDetachMenu
INTERFACE
SUBROUTINE glutDetachMenu(button) BIND(C,NAME="glutDetachMenu")
IMPORT
INTEGER(GLint), VALUE :: button
END SUBROUTINE glutDetachMenu
END INTERFACE
! Global callback functions, see og_callbacks.c
! void glutTimerFunc( unsigned int time, void (* callback)( int value), int value)
PUBLIC glutTimerFunc
INTERFACE glutTimerFunc
MODULE PROCEDURE glutTimerFunc_f03
END INTERFACE glutTimerFunc
INTERFACE
SUBROUTINE glutTimerFunc_gl(time, proc, value) BIND(C,NAME="glutTimerFunc")
IMPORT
INTEGER(GLint), VALUE :: value
INTEGER(GLuint), VALUE :: time
! void proc( int value)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutTimerFunc_gl
END INTERFACE
! void glutIdleFunc( void (* callback)( void ) )
PUBLIC glutIdleFunc
INTERFACE glutIdleFunc
MODULE PROCEDURE glutIdleFunc_f03
END INTERFACE glutIdleFunc
INTERFACE
SUBROUTINE glutIdleFunc_gl(proc) BIND(C,NAME="glutIdleFunc")
IMPORT
! void proc( void )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutIdleFunc_gl
END INTERFACE
! Window-specific callback functions, see og_callbacks.c
! void glutKeyboardFunc( void (* callback)( unsigned char key, int x, int y))
PUBLIC glutKeyboardFunc
INTERFACE glutKeyboardFunc
MODULE PROCEDURE glutKeyboardFunc_f03
END INTERFACE glutKeyboardFunc
INTERFACE
SUBROUTINE glutKeyboardFunc_gl(proc) BIND(C,NAME="glutKeyboardFunc")
IMPORT
! void proc( unsigned char key, int x, int y)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutKeyboardFunc_gl
END INTERFACE
! void glutSpecialFunc( void (* callback)( int key, int x, int y ) )
PUBLIC glutSpecialFunc
INTERFACE glutSpecialFunc
MODULE PROCEDURE glutSpecialFunc_f03
END INTERFACE glutSpecialFunc
INTERFACE
SUBROUTINE glutSpecialFunc_gl(proc) BIND(C,NAME="glutSpecialFunc")
IMPORT
! void proc( int key, int x, int y )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutSpecialFunc_gl
END INTERFACE
! void glutReshapeFunc( void (* callback)( int h, int w) )
PUBLIC glutReshapeFunc
INTERFACE glutReshapeFunc
MODULE PROCEDURE glutReshapeFunc_f03
END INTERFACE glutReshapeFunc
INTERFACE
SUBROUTINE glutReshapeFunc_gl(proc) BIND(C,NAME="glutReshapeFunc")
IMPORT
! void proc( int h, int w)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutReshapeFunc_gl
END INTERFACE
! void glutVisibilityFunc( void (* callback)( int visible) )
PUBLIC glutVisibilityFunc
INTERFACE glutVisibilityFunc
MODULE PROCEDURE glutVisibilityFunc_f03
END INTERFACE glutVisibilityFunc
INTERFACE
SUBROUTINE glutVisibilityFunc_gl(proc) BIND(C,NAME="glutVisibilityFunc")
IMPORT
! void proc( int visible)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutVisibilityFunc_gl
END INTERFACE
! void glutDisplayFunc( void (* callback)( void ) )
PUBLIC glutDisplayFunc
INTERFACE glutDisplayFunc
MODULE PROCEDURE glutDisplayFunc_f03
END INTERFACE glutDisplayFunc
INTERFACE
SUBROUTINE glutDisplayFunc_gl(proc) BIND(C,NAME="glutDisplayFunc")
IMPORT
! void proc( void )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutDisplayFunc_gl
END INTERFACE
! void glutMouseFunc( void (* callback)( int button, int state, int x, int y ))
PUBLIC glutMouseFunc
INTERFACE glutMouseFunc
MODULE PROCEDURE glutMouseFunc_f03
END INTERFACE glutMouseFunc
INTERFACE
SUBROUTINE glutMouseFunc_gl(proc) BIND(C,NAME="glutMouseFunc")
IMPORT
! void proc( int button, int state, int x, int y )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutMouseFunc_gl
END INTERFACE
! void glutMotionFunc( void (* callback)( int x, int y) )
PUBLIC glutMotionFunc
INTERFACE glutMotionFunc
MODULE PROCEDURE glutMotionFunc_f03
END INTERFACE glutMotionFunc
INTERFACE
SUBROUTINE glutMotionFunc_gl(proc) BIND(C,NAME="glutMotionFunc")
IMPORT
! void proc( int x, int y)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutMotionFunc_gl
END INTERFACE
! void glutPassiveMotionFunc( void (* callback)( int x, int y))
PUBLIC glutPassiveMotionFunc
INTERFACE glutPassiveMotionFunc
MODULE PROCEDURE glutPassiveMotionFunc_f03
END INTERFACE glutPassiveMotionFunc
INTERFACE
SUBROUTINE glutPassiveMotionFunc_gl(proc) BIND(C,NAME="glutPassiveMotionFunc")
IMPORT
! void proc( int x, int y)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutPassiveMotionFunc_gl
END INTERFACE
! void glutEntryFunc( void (* callback)( int value) )
PUBLIC glutEntryFunc
INTERFACE glutEntryFunc
MODULE PROCEDURE glutEntryFunc_f03
END INTERFACE glutEntryFunc
INTERFACE
SUBROUTINE glutEntryFunc_gl(proc) BIND(C,NAME="glutEntryFunc")
IMPORT
! void proc( int value)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutEntryFunc_gl
END INTERFACE
! void glutKeyboardUpFunc( void (* callback)( unsigned char key, int x, int y))
PUBLIC glutKeyboardUpFunc
INTERFACE glutKeyboardUpFunc
MODULE PROCEDURE glutKeyboardUpFunc_f03
END INTERFACE glutKeyboardUpFunc
INTERFACE
SUBROUTINE glutKeyboardUpFunc_gl(proc) BIND(C,NAME="glutKeyboardUpFunc")
IMPORT
! void proc( unsigned char key, int x, int y)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutKeyboardUpFunc_gl
END INTERFACE
! void glutSpecialUpFunc( void (* callback)( int key, int x, int y))
PUBLIC glutSpecialUpFunc
INTERFACE glutSpecialUpFunc
MODULE PROCEDURE glutSpecialUpFunc_f03
END INTERFACE glutSpecialUpFunc
INTERFACE
SUBROUTINE glutSpecialUpFunc_gl(proc) BIND(C,NAME="glutSpecialUpFunc")
IMPORT
! void proc( int key, int x, int y)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutSpecialUpFunc_gl
END INTERFACE
! void glutJoystickFunc( void (* callback)( unsigned int buttonMask, int x, int y, int z ), int pollInterval)
PUBLIC glutJoystickFunc
INTERFACE glutJoystickFunc
MODULE PROCEDURE glutJoystickFunc_f03
END INTERFACE glutJoystickFunc
INTERFACE
SUBROUTINE glutJoystickFunc_gl(proc, pollInterval) BIND(C,NAME="glutJoystickFunc")
IMPORT
INTEGER(GLint), VALUE :: pollInterval
! void proc( unsigned int buttonMask, int x, int y, int z )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutJoystickFunc_gl
END INTERFACE
! void glutMenuStateFunc( void (* callback)( int menu ) )
PUBLIC glutMenuStateFunc
INTERFACE glutMenuStateFunc
MODULE PROCEDURE glutMenuStateFunc_f03
END INTERFACE glutMenuStateFunc
INTERFACE
SUBROUTINE glutMenuStateFunc_gl(proc) BIND(C,NAME="glutMenuStateFunc")
IMPORT
! void proc( int menu )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutMenuStateFunc_gl
END INTERFACE
! void glutMenuStatusFunc( void (* callback)( int status, int x, int y))
PUBLIC glutMenuStatusFunc
INTERFACE glutMenuStatusFunc
MODULE PROCEDURE glutMenuStatusFunc_f03
END INTERFACE glutMenuStatusFunc
INTERFACE
SUBROUTINE glutMenuStatusFunc_gl(proc) BIND(C,NAME="glutMenuStatusFunc")
IMPORT
! void proc( int status, int x, int y)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutMenuStatusFunc_gl
END INTERFACE
! void glutOverlayDisplayFunc( void (* callback)( void ) )
PUBLIC glutOverlayDisplayFunc
INTERFACE glutOverlayDisplayFunc
MODULE PROCEDURE glutOverlayDisplayFunc_f03
END INTERFACE glutOverlayDisplayFunc
INTERFACE
SUBROUTINE glutOverlayDisplayFunc_gl(proc) BIND(C,NAME="glutOverlayDisplayFunc")
IMPORT
! void proc( void )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutOverlayDisplayFunc_gl
END INTERFACE
! void glutWindowStatusFunc( void (* callback)( int status) )
PUBLIC glutWindowStatusFunc
INTERFACE glutWindowStatusFunc
MODULE PROCEDURE glutWindowStatusFunc_f03
END INTERFACE glutWindowStatusFunc
INTERFACE
SUBROUTINE glutWindowStatusFunc_gl(proc) BIND(C,NAME="glutWindowStatusFunc")
IMPORT
! void proc( int status)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutWindowStatusFunc_gl
END INTERFACE
! void glutSpaceballMotionFunc( void (* callback)( int key, int x, int y ))
PUBLIC glutSpaceballMotionFunc
INTERFACE glutSpaceballMotionFunc
MODULE PROCEDURE glutSpaceballMotionFunc_f03
END INTERFACE glutSpaceballMotionFunc
INTERFACE
SUBROUTINE glutSpaceballMotionFunc_gl(proc) BIND(C,NAME="glutSpaceballMotionFunc")
IMPORT
! void proc( int key, int x, int y )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutSpaceballMotionFunc_gl
END INTERFACE
! void glutSpaceballRotateFunc( void (* callback)( int key, int x, int y ))
PUBLIC glutSpaceballRotateFunc
INTERFACE glutSpaceballRotateFunc
MODULE PROCEDURE glutSpaceballRotateFunc_f03
END INTERFACE glutSpaceballRotateFunc
INTERFACE
SUBROUTINE glutSpaceballRotateFunc_gl(proc) BIND(C,NAME="glutSpaceballRotateFunc")
IMPORT
! void proc( int key, int x, int y )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutSpaceballRotateFunc_gl
END INTERFACE
! void glutSpaceballButtonFunc( void (* callback)( int x, int y))
PUBLIC glutSpaceballButtonFunc
INTERFACE glutSpaceballButtonFunc
MODULE PROCEDURE glutSpaceballButtonFunc_f03
END INTERFACE glutSpaceballButtonFunc
INTERFACE
SUBROUTINE glutSpaceballButtonFunc_gl(proc) BIND(C,NAME="glutSpaceballButtonFunc")
IMPORT
! void proc( int x, int y)
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutSpaceballButtonFunc_gl
END INTERFACE
! void glutButtonBoxFunc( void (* callback)( int x, int y ) )
PUBLIC glutButtonBoxFunc
INTERFACE glutButtonBoxFunc
MODULE PROCEDURE glutButtonBoxFunc_f03
END INTERFACE glutButtonBoxFunc
INTERFACE
SUBROUTINE glutButtonBoxFunc_gl(proc) BIND(C,NAME="glutButtonBoxFunc")
IMPORT
! void proc( int x, int y )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutButtonBoxFunc_gl
END INTERFACE
! void glutDialsFunc( void (* callback)( int x, int y ) )
PUBLIC glutDialsFunc
INTERFACE glutDialsFunc
MODULE PROCEDURE glutDialsFunc_f03
END INTERFACE glutDialsFunc
INTERFACE
SUBROUTINE glutDialsFunc_gl(proc) BIND(C,NAME="glutDialsFunc")
IMPORT
! void proc( int x, int y )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutDialsFunc_gl
END INTERFACE
! void glutTabletMotionFunc( void (* callback)( int x, int y ) )
PUBLIC glutTabletMotionFunc
INTERFACE glutTabletMotionFunc
MODULE PROCEDURE glutTabletMotionFunc_f03
END INTERFACE glutTabletMotionFunc
INTERFACE
SUBROUTINE glutTabletMotionFunc_gl(proc) BIND(C,NAME="glutTabletMotionFunc")
IMPORT
! void proc( int x, int y )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutTabletMotionFunc_gl
END INTERFACE
! void glutTabletButtonFunc( void (* callback)( int button, int state, int x, int y ))
PUBLIC glutTabletButtonFunc
INTERFACE glutTabletButtonFunc
MODULE PROCEDURE glutTabletButtonFunc_f03
END INTERFACE glutTabletButtonFunc
INTERFACE
SUBROUTINE glutTabletButtonFunc_gl(proc) BIND(C,NAME="glutTabletButtonFunc")
IMPORT
! void proc( int button, int state, int x, int y )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutTabletButtonFunc_gl
END INTERFACE
! State setting and retrieval functions, see og_state.c
! int glutGet( GLenum query )
PUBLIC glutGet
INTERFACE
FUNCTION glutGet(query) BIND(C,NAME="glutGet")
IMPORT
INTEGER(GLint) :: glutGet
INTEGER(GLenum), VALUE :: query
END FUNCTION glutGet
END INTERFACE
! int glutDeviceGet( GLenum query )
PUBLIC glutDeviceGet
INTERFACE
FUNCTION glutDeviceGet(query) BIND(C,NAME="glutDeviceGet")
IMPORT
INTEGER(GLint) :: glutDeviceGet
INTEGER(GLenum), VALUE :: query
END FUNCTION glutDeviceGet
END INTERFACE
! int glutGetModifiers( void )
PUBLIC glutGetModifiers
INTERFACE
FUNCTION glutGetModifiers() BIND(C,NAME="glutGetModifiers")
IMPORT
INTEGER(GLint) :: glutGetModifiers
END FUNCTION glutGetModifiers
END INTERFACE
! int glutLayerGet( GLenum query )
PUBLIC glutLayerGet
INTERFACE
FUNCTION glutLayerGet(query) BIND(C,NAME="glutLayerGet")
IMPORT
INTEGER(GLint) :: glutLayerGet
INTEGER(GLenum), VALUE :: query
END FUNCTION glutLayerGet
END INTERFACE
! Font stuff, see og_font.c
! void glutBitmapCharacter( void* font, int character )
PUBLIC glutBitmapCharacter
INTERFACE
SUBROUTINE glutBitmapCharacter(font, character) BIND(C,NAME="glutBitmapCharacter")
IMPORT
INTEGER(GLint), VALUE :: character
TYPE(C_PTR), VALUE :: font
END SUBROUTINE glutBitmapCharacter
END INTERFACE
! int glutBitmapWidth( void* font, int character )
PUBLIC glutBitmapWidth
INTERFACE
FUNCTION glutBitmapWidth(font, character) BIND(C,NAME="glutBitmapWidth")
IMPORT
INTEGER(GLint) :: glutBitmapWidth
INTEGER(GLint), VALUE :: character
TYPE(C_PTR), VALUE :: font
END FUNCTION glutBitmapWidth
END INTERFACE
! void glutStrokeCharacter( void* font, int character )
PUBLIC glutStrokeCharacter
INTERFACE
SUBROUTINE glutStrokeCharacter(font, character) BIND(C,NAME="glutStrokeCharacter")
IMPORT
INTEGER(GLint), VALUE :: character
TYPE(C_PTR), VALUE :: font
END SUBROUTINE glutStrokeCharacter
END INTERFACE
! float glutStrokeWidth( void* font, int character )
PUBLIC glutStrokeWidth
INTERFACE
FUNCTION glutStrokeWidth(font, character) BIND(C,NAME="glutStrokeWidth")
IMPORT
REAL(C_FLOAT) :: glutStrokeWidth
INTEGER(GLint), VALUE :: character
TYPE(C_PTR), VALUE :: font
END FUNCTION glutStrokeWidth
END INTERFACE
! int glutBitmapLength( void* font, const unsigned char* string )
PUBLIC glutBitmapLength
INTERFACE
FUNCTION glutBitmapLength(font, string) BIND(C,NAME="glutBitmapLength")
IMPORT
INTEGER(GLint) :: glutBitmapLength
! CHARACTER, INTENT(IN) :: string
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: string
TYPE(C_PTR), VALUE :: font
END FUNCTION glutBitmapLength
END INTERFACE
! float glutStrokeLength( void* font, const unsigned char* string )
PUBLIC glutStrokeLength
INTERFACE
FUNCTION glutStrokeLength(font, string) BIND(C,NAME="glutStrokeLength")
IMPORT
REAL(C_FLOAT) :: glutStrokeLength
! CHARACTER, INTENT(IN) :: string
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: string
TYPE(C_PTR), VALUE :: font
END FUNCTION glutStrokeLength
END INTERFACE
! Geometry functions, see og_geometry.c
! void glutWireCube( GLdouble size )
PUBLIC glutWireCube
INTERFACE
SUBROUTINE glutWireCube(size) BIND(C,NAME="glutWireCube")
IMPORT
REAL(GLdouble), VALUE :: size
END SUBROUTINE glutWireCube
END INTERFACE
! void glutSolidCube( GLdouble size )
PUBLIC glutSolidCube
INTERFACE
SUBROUTINE glutSolidCube(size) BIND(C,NAME="glutSolidCube")
IMPORT
REAL(GLdouble), VALUE :: size
END SUBROUTINE glutSolidCube
END INTERFACE
! void glutWireSphere( GLdouble radius, GLint slices, GLint stacks)
PUBLIC glutWireSphere
INTERFACE
SUBROUTINE glutWireSphere(radius, slices, stacks) BIND(C,NAME="glutWireSphere")
IMPORT
INTEGER(GLint), VALUE :: slices, stacks
REAL(GLdouble), VALUE :: radius
END SUBROUTINE glutWireSphere
END INTERFACE
! void glutSolidSphere( GLdouble radius, GLint slices, GLint stacks)
PUBLIC glutSolidSphere
INTERFACE
SUBROUTINE glutSolidSphere(radius, slices, stacks) BIND(C,NAME="glutSolidSphere")
IMPORT
INTEGER(GLint), VALUE :: slices, stacks
REAL(GLdouble), VALUE :: radius
END SUBROUTINE glutSolidSphere
END INTERFACE
! void glutWireCone( GLdouble base, GLdouble height, GLint slices, GLint stacks)
PUBLIC glutWireCone
INTERFACE
SUBROUTINE glutWireCone(base, height, slices, stacks) BIND(C,NAME="glutWireCone")
IMPORT
INTEGER(GLint), VALUE :: slices, stacks
REAL(GLdouble), VALUE :: base, height
END SUBROUTINE glutWireCone
END INTERFACE
! void glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLint stacks)
PUBLIC glutSolidCone
INTERFACE
SUBROUTINE glutSolidCone(base, height, slices, stacks) BIND(C,NAME="glutSolidCone")
IMPORT
INTEGER(GLint), VALUE :: slices, stacks
REAL(GLdouble), VALUE :: base, height
END SUBROUTINE glutSolidCone
END INTERFACE
! void glutWireTorus( GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings)
PUBLIC glutWireTorus
INTERFACE
SUBROUTINE glutWireTorus(innerRadius, outerRadius, sides, rings) BIND(C,NAME="glutWireTorus")
IMPORT
INTEGER(GLint), VALUE :: sides, rings
REAL(GLdouble), VALUE :: innerRadius, outerRadius
END SUBROUTINE glutWireTorus
END INTERFACE
! void glutSolidTorus( GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings)
PUBLIC glutSolidTorus
INTERFACE
SUBROUTINE glutSolidTorus(innerRadius, outerRadius, sides, rings) BIND(C,NAME="glutSolidTorus")
IMPORT
INTEGER(GLint), VALUE :: sides, rings
REAL(GLdouble), VALUE :: innerRadius, outerRadius
END SUBROUTINE glutSolidTorus
END INTERFACE
! void glutWireDodecahedron( void )
PUBLIC glutWireDodecahedron
INTERFACE
SUBROUTINE glutWireDodecahedron() BIND(C,NAME="glutWireDodecahedron")
IMPORT
END SUBROUTINE glutWireDodecahedron
END INTERFACE
! void glutSolidDodecahedron( void )
PUBLIC glutSolidDodecahedron
INTERFACE
SUBROUTINE glutSolidDodecahedron() BIND(C,NAME="glutSolidDodecahedron")
IMPORT
END SUBROUTINE glutSolidDodecahedron
END INTERFACE
! void glutWireOctahedron( void )
PUBLIC glutWireOctahedron
INTERFACE
SUBROUTINE glutWireOctahedron() BIND(C,NAME="glutWireOctahedron")
IMPORT
END SUBROUTINE glutWireOctahedron
END INTERFACE
! void glutSolidOctahedron( void )
PUBLIC glutSolidOctahedron
INTERFACE
SUBROUTINE glutSolidOctahedron() BIND(C,NAME="glutSolidOctahedron")
IMPORT
END SUBROUTINE glutSolidOctahedron
END INTERFACE
! void glutWireTetrahedron( void )
PUBLIC glutWireTetrahedron
INTERFACE
SUBROUTINE glutWireTetrahedron() BIND(C,NAME="glutWireTetrahedron")
IMPORT
END SUBROUTINE glutWireTetrahedron
END INTERFACE
! void glutSolidTetrahedron( void )
PUBLIC glutSolidTetrahedron
INTERFACE
SUBROUTINE glutSolidTetrahedron() BIND(C,NAME="glutSolidTetrahedron")
IMPORT
END SUBROUTINE glutSolidTetrahedron
END INTERFACE
! void glutWireIcosahedron( void )
PUBLIC glutWireIcosahedron
INTERFACE
SUBROUTINE glutWireIcosahedron() BIND(C,NAME="glutWireIcosahedron")
IMPORT
END SUBROUTINE glutWireIcosahedron
END INTERFACE
! void glutSolidIcosahedron( void )
PUBLIC glutSolidIcosahedron
INTERFACE
SUBROUTINE glutSolidIcosahedron() BIND(C,NAME="glutSolidIcosahedron")
IMPORT
END SUBROUTINE glutSolidIcosahedron
END INTERFACE
! Teapot rendering functions, found in og_teapot.c
! void glutWireTeapot( GLdouble size )
PUBLIC glutWireTeapot
INTERFACE
SUBROUTINE glutWireTeapot(size) BIND(C,NAME="glutWireTeapot")
IMPORT
REAL(GLdouble), VALUE :: size
END SUBROUTINE glutWireTeapot
END INTERFACE
! void glutSolidTeapot( GLdouble size )
PUBLIC glutSolidTeapot
INTERFACE
SUBROUTINE glutSolidTeapot(size) BIND(C,NAME="glutSolidTeapot")
IMPORT
REAL(GLdouble), VALUE :: size
END SUBROUTINE glutSolidTeapot
END INTERFACE
! Game mode functions, see og_gamemode.c
! void glutGameModeString( const char* string )
PUBLIC glutGameModeString
INTERFACE
SUBROUTINE glutGameModeString(string) BIND(C,NAME="glutGameModeString")
IMPORT
! CHARACTER, INTENT(IN) :: string
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: string
END SUBROUTINE glutGameModeString
END INTERFACE
! int glutEnterGameMode( void )
PUBLIC glutEnterGameMode
INTERFACE
FUNCTION glutEnterGameMode() BIND(C,NAME="glutEnterGameMode")
IMPORT
INTEGER(GLint) :: glutEnterGameMode
END FUNCTION glutEnterGameMode
END INTERFACE
! void glutLeaveGameMode( void )
PUBLIC glutLeaveGameMode
INTERFACE
SUBROUTINE glutLeaveGameMode() BIND(C,NAME="glutLeaveGameMode")
IMPORT
END SUBROUTINE glutLeaveGameMode
END INTERFACE
! int glutGameModeGet( GLenum query )
PUBLIC glutGameModeGet
INTERFACE
FUNCTION glutGameModeGet(query) BIND(C,NAME="glutGameModeGet")
IMPORT
INTEGER(GLint) :: glutGameModeGet
INTEGER(GLenum), VALUE :: query
END FUNCTION glutGameModeGet
END INTERFACE
! Video resize functions, see og_videoresize.c
! int glutVideoResizeGet( GLenum query )
PUBLIC glutVideoResizeGet
INTERFACE
FUNCTION glutVideoResizeGet(query) BIND(C,NAME="glutVideoResizeGet")
IMPORT
INTEGER(GLint) :: glutVideoResizeGet
INTEGER(GLenum), VALUE :: query
END FUNCTION glutVideoResizeGet
END INTERFACE
! void glutSetupVideoResizing( void )
PUBLIC glutSetupVideoResizing
INTERFACE
SUBROUTINE glutSetupVideoResizing() BIND(C,NAME="glutSetupVideoResizing")
IMPORT
END SUBROUTINE glutSetupVideoResizing
END INTERFACE
! void glutStopVideoResizing( void )
PUBLIC glutStopVideoResizing
INTERFACE
SUBROUTINE glutStopVideoResizing() BIND(C,NAME="glutStopVideoResizing")
IMPORT
END SUBROUTINE glutStopVideoResizing
END INTERFACE
! void glutVideoResize( int x, int y, int width, int height)
PUBLIC glutVideoResize
INTERFACE
SUBROUTINE glutVideoResize(x, y, width, height) BIND(C,NAME="glutVideoResize")
IMPORT
INTEGER(GLint), VALUE :: x, y, width, height
END SUBROUTINE glutVideoResize
END INTERFACE
! void glutVideoPan( int x, int y, int width, int height )
PUBLIC glutVideoPan
INTERFACE
SUBROUTINE glutVideoPan(x, y, width, height) BIND(C,NAME="glutVideoPan")
IMPORT
INTEGER(GLint), VALUE :: x, y, width, height
END SUBROUTINE glutVideoPan
END INTERFACE
! Colormap functions, see og_misc.c
! void glutSetColor( int color, GLfloat red, GLfloat green, GLfloat blue)
PUBLIC glutSetColor
INTERFACE
SUBROUTINE glutSetColor(color, red, green, blue) BIND(C,NAME="glutSetColor")
IMPORT
INTEGER(GLint), VALUE :: color
REAL(GLfloat), VALUE :: red, green, blue
END SUBROUTINE glutSetColor
END INTERFACE
! GLfloat glutGetColor( int color, int component )
PUBLIC glutGetColor
INTERFACE
FUNCTION glutGetColor(color, component) BIND(C,NAME="glutGetColor")
IMPORT
REAL(GLfloat) :: glutGetColor
INTEGER(GLint), VALUE :: color, component
END FUNCTION glutGetColor
END INTERFACE
! void glutCopyColormap( int window )
PUBLIC glutCopyColormap
INTERFACE
SUBROUTINE glutCopyColormap(window) BIND(C,NAME="glutCopyColormap")
IMPORT
INTEGER(GLint), VALUE :: window
END SUBROUTINE glutCopyColormap
END INTERFACE
! Misc keyboard and joystick functions, see og_misc.c
! void glutIgnoreKeyRepeat( int ignore )
PUBLIC glutIgnoreKeyRepeat
INTERFACE
SUBROUTINE glutIgnoreKeyRepeat(ignore) BIND(C,NAME="glutIgnoreKeyRepeat")
IMPORT
INTEGER(GLint), VALUE :: ignore
END SUBROUTINE glutIgnoreKeyRepeat
END INTERFACE
! void glutSetKeyRepeat( int repeatMode )
PUBLIC glutSetKeyRepeat
INTERFACE
SUBROUTINE glutSetKeyRepeat(repeatMode) BIND(C,NAME="glutSetKeyRepeat")
IMPORT
INTEGER(GLint), VALUE :: repeatMode
END SUBROUTINE glutSetKeyRepeat
END INTERFACE
! void glutForceJoystickFunc( void )
PUBLIC glutForceJoystickFunc
INTERFACE
SUBROUTINE glutForceJoystickFunc() BIND(C,NAME="glutForceJoystickFunc")
IMPORT
END SUBROUTINE glutForceJoystickFunc
END INTERFACE
! Misc functions, see og_misc.c
! int glutExtensionSupported( const char* extension )
PUBLIC glutExtensionSupported
INTERFACE
FUNCTION glutExtensionSupported(extension) BIND(C,NAME="glutExtensionSupported")
IMPORT
INTEGER(GLint) :: glutExtensionSupported
! CHARACTER, INTENT(IN) :: extension
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: extension
END FUNCTION glutExtensionSupported
END INTERFACE
! void glutReportErrors( void )
PUBLIC glutReportErrors
INTERFACE
SUBROUTINE glutReportErrors() BIND(C,NAME="glutReportErrors")
IMPORT
END SUBROUTINE glutReportErrors
END INTERFACE
! _______________________________________
! OpenGLUT EXTENSIONS
! _______________________________________
! GLUT API Extension macro definitions -- behavior when the user clicks
! on the window-close/program-quit widget box.
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_ACTION_EXIT = 0
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_ACTION_GLUTMAINLOOP_RETURNS = 1
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_ACTION_CONTINUE_EXECUTION = 2
! Create a new rendering context when the user opens a new window?
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_CREATE_NEW_CONTEXT = 0
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_USE_CURRENT_CONTEXT = 1
! GLUT API Extension macro definitions -- display mode
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_OFFSCREEN = z'0400'
! GLUT API Extension macro definitions -- the glutGet parameters
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_ACTION_ON_WINDOW_CLOSE = z'01F9'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_BORDER_WIDTH = z'01FA'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_WINDOW_HEADER_HEIGHT = z'01FB'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_VERSION = z'01FC'
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_RENDERING_CONTEXT = z'01FD'
! Process loop function, see freeglut_main.c
! void glutMainLoopEvent( void )
PUBLIC glutMainLoopEvent
INTERFACE
SUBROUTINE glutMainLoopEvent() BIND(C,NAME="glutMainLoopEvent")
IMPORT
END SUBROUTINE glutMainLoopEvent
END INTERFACE
! void glutLeaveMainLoop( void )
PUBLIC glutLeaveMainLoop
INTERFACE
SUBROUTINE glutLeaveMainLoop() BIND(C,NAME="glutLeaveMainLoop")
IMPORT
END SUBROUTINE glutLeaveMainLoop
END INTERFACE
! Window-specific callback functions, see freeglut_callbacks.c
! void glutMouseWheelFunc( void (* callback)( int button, int state, int x, int y ))
PUBLIC glutMouseWheelFunc
INTERFACE glutMouseWheelFunc
MODULE PROCEDURE glutMouseWheelFunc_f03
END INTERFACE glutMouseWheelFunc
INTERFACE
SUBROUTINE glutMouseWheelFunc_gl(proc) BIND(C,NAME="glutMouseWheelFunc")
IMPORT
! void proc( int button, int state, int x, int y )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutMouseWheelFunc_gl
END INTERFACE
! void glutCloseFunc( void (* callback)( void ) )
PUBLIC glutCloseFunc
INTERFACE glutCloseFunc
MODULE PROCEDURE glutCloseFunc_f03
END INTERFACE glutCloseFunc
INTERFACE
SUBROUTINE glutCloseFunc_gl(proc) BIND(C,NAME="glutCloseFunc")
IMPORT
! void proc( void )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutCloseFunc_gl
END INTERFACE
! void glutWMCloseFunc( void (* callback)( void ) )
PUBLIC glutWMCloseFunc
INTERFACE glutWMCloseFunc
MODULE PROCEDURE glutWMCloseFunc_f03
END INTERFACE glutWMCloseFunc
INTERFACE
SUBROUTINE glutWMCloseFunc_gl(proc) BIND(C,NAME="glutWMCloseFunc")
IMPORT
! void proc( void )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutWMCloseFunc_gl
END INTERFACE
! A. Donev: Also a destruction callback for menus
! void glutMenuDestroyFunc( void (* callback)( void ) )
PUBLIC glutMenuDestroyFunc
INTERFACE glutMenuDestroyFunc
MODULE PROCEDURE glutMenuDestroyFunc_f03
END INTERFACE glutMenuDestroyFunc
INTERFACE
SUBROUTINE glutMenuDestroyFunc_gl(proc) BIND(C,NAME="glutMenuDestroyFunc")
IMPORT
! void proc( void )
TYPE(C_FUNPTR), VALUE :: proc
END SUBROUTINE glutMenuDestroyFunc_gl
END INTERFACE
! State setting and retrieval functions, see freeglut_state.c
! void glutSetOption ( GLenum option_flag, int value )
PUBLIC glutSetOption
INTERFACE
SUBROUTINE glutSetOption(option_flag, value) BIND(C,NAME="glutSetOption")
IMPORT
INTEGER(GLenum), VALUE :: option_flag
INTEGER(GLint), VALUE :: value
END SUBROUTINE glutSetOption
END INTERFACE
! A.Donev: User-data manipulation
! void* glutGetWindowData( void )
PUBLIC glutGetWindowData
INTERFACE
FUNCTION glutGetWindowData() BIND(C,NAME="glutGetWindowData")
IMPORT
TYPE(C_PTR) :: glutGetWindowData
END FUNCTION glutGetWindowData
END INTERFACE
! void glutSetWindowData(void* data)
PUBLIC glutSetWindowData
INTERFACE
SUBROUTINE glutSetWindowData(data) BIND(C,NAME="glutSetWindowData")
IMPORT
TYPE(C_PTR), VALUE :: data
END SUBROUTINE glutSetWindowData
END INTERFACE
! void* glutGetMenuData( void )
PUBLIC glutGetMenuData
INTERFACE
FUNCTION glutGetMenuData() BIND(C,NAME="glutGetMenuData")
IMPORT
TYPE(C_PTR) :: glutGetMenuData
END FUNCTION glutGetMenuData
END INTERFACE
! void glutSetMenuData(void* data)
PUBLIC glutSetMenuData
INTERFACE
SUBROUTINE glutSetMenuData(data) BIND(C,NAME="glutSetMenuData")
IMPORT
TYPE(C_PTR), VALUE :: data
END SUBROUTINE glutSetMenuData
END INTERFACE
! Font stuff, see freeglut_font.c
! int glutBitmapHeight( void* font )
PUBLIC glutBitmapHeight
INTERFACE
FUNCTION glutBitmapHeight(font) BIND(C,NAME="glutBitmapHeight")
IMPORT
INTEGER(GLint) :: glutBitmapHeight
TYPE(C_PTR), VALUE :: font
END FUNCTION glutBitmapHeight
END INTERFACE
! GLfloat glutStrokeHeight( void* font )
PUBLIC glutStrokeHeight
INTERFACE
FUNCTION glutStrokeHeight(font) BIND(C,NAME="glutStrokeHeight")
IMPORT
REAL(GLfloat) :: glutStrokeHeight
TYPE(C_PTR), VALUE :: font
END FUNCTION glutStrokeHeight
END INTERFACE
! void glutBitmapString( void* font, const unsigned char *string)
PUBLIC glutBitmapString
INTERFACE
SUBROUTINE glutBitmapString(font, string) BIND(C,NAME="glutBitmapString")
IMPORT
! CHARACTER, INTENT(IN) :: string
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: string
TYPE(C_PTR), VALUE :: font
END SUBROUTINE glutBitmapString
END INTERFACE
! void glutStrokeString( void* font, const unsigned char *string)
PUBLIC glutStrokeString
INTERFACE
SUBROUTINE glutStrokeString(font, string) BIND(C,NAME="glutStrokeString")
IMPORT
! CHARACTER, INTENT(IN) :: string
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: string
TYPE(C_PTR), VALUE :: font
END SUBROUTINE glutStrokeString
END INTERFACE
! Geometry functions, see freeglut_geometry.c
! void glutWireRhombicDodecahedron( void )
PUBLIC glutWireRhombicDodecahedron
INTERFACE
SUBROUTINE glutWireRhombicDodecahedron() BIND(C,NAME="glutWireRhombicDodecahedron")
IMPORT
END SUBROUTINE glutWireRhombicDodecahedron
END INTERFACE
! void glutSolidRhombicDodecahedron( void )
PUBLIC glutSolidRhombicDodecahedron
INTERFACE
SUBROUTINE glutSolidRhombicDodecahedron() BIND(C,NAME="glutSolidRhombicDodecahedron")
IMPORT
END SUBROUTINE glutSolidRhombicDodecahedron
END INTERFACE
! void glutWireSierpinskiSponge( int num_levels, const GLdouble offset[3], GLdouble scale)
PUBLIC glutWireSierpinskiSponge
INTERFACE
SUBROUTINE glutWireSierpinskiSponge(num_levels, offset, scale) BIND(C,NAME="glutWireSierpinskiSponge")
IMPORT
INTEGER(GLint), VALUE :: num_levels
REAL(GLdouble), DIMENSION(3), INTENT(IN) :: offset
REAL(GLdouble), VALUE :: scale
END SUBROUTINE glutWireSierpinskiSponge
END INTERFACE
! void glutSolidSierpinskiSponge( int num_levels, const GLdouble offset[3], GLdouble scale)
PUBLIC glutSolidSierpinskiSponge
INTERFACE
SUBROUTINE glutSolidSierpinskiSponge(num_levels, offset, scale) BIND(C,NAME="glutSolidSierpinskiSponge")
IMPORT
INTEGER(GLint), VALUE :: num_levels
REAL(GLdouble), DIMENSION(3), INTENT(IN) :: offset
REAL(GLdouble), VALUE :: scale
END SUBROUTINE glutSolidSierpinskiSponge
END INTERFACE
! void glutWireCylinder( GLdouble radius, GLdouble height, GLint slices, GLint stacks)
PUBLIC glutWireCylinder
INTERFACE
SUBROUTINE glutWireCylinder(radius, height, slices, stacks) BIND(C,NAME="glutWireCylinder")
IMPORT
INTEGER(GLint), VALUE :: slices, stacks
REAL(GLdouble), VALUE :: radius, height
END SUBROUTINE glutWireCylinder
END INTERFACE
! void glutSolidCylinder( GLdouble radius, GLdouble height, GLint slices, GLint stacks)
PUBLIC glutSolidCylinder
INTERFACE
SUBROUTINE glutSolidCylinder(radius, height, slices, stacks) BIND(C,NAME="glutSolidCylinder")
IMPORT
INTEGER(GLint), VALUE :: slices, stacks
REAL(GLdouble), VALUE :: radius, height
END SUBROUTINE glutSolidCylinder
END INTERFACE
! Extension functions, see freeglut_ext.c
! void *glutGetProcAddress( const char *procName )
PUBLIC glutGetProcAddress
INTERFACE
FUNCTION glutGetProcAddress(procName) BIND(C,NAME="glutGetProcAddress")
IMPORT
TYPE(C_PTR) :: glutGetProcAddress
! CHARACTER, INTENT(IN) :: procName
CHARACTER(C_CHAR), DIMENSION(*), INTENT(IN) :: procName
END FUNCTION glutGetProcAddress
END INTERFACE
! GLUT API Extension macro definitions -- display mode
INTEGER(GLenum), PARAMETER, PUBLIC :: GLUT_BORDERLESS = z'0800'
! OpenGLUT experimental functions.
! Allow for conditional compilation of experimental features.
! Font variables in GLUT_fonts.c
TYPE(C_PTR), BIND(C), PUBLIC, PROTECTED :: GLUT_STROKE_ROMAN, &
GLUT_STROKE_MONO_ROMAN, GLUT_BITMAP_9_BY_15, GLUT_BITMAP_8_BY_13, &
GLUT_BITMAP_TIMES_ROMAN_10, GLUT_BITMAP_TIMES_ROMAN_24, &
GLUT_BITMAP_HELVETICA_10, GLUT_BITMAP_HELVETICA_12, &
GLUT_BITMAP_HELVETICA_18
! A special callback function for compatibility with f90gl
TYPE(C_FUNPTR), PUBLIC, SAVE, BIND(C) :: GLUT_NULL_FUNC=C_NULL_FUNPTR
CONTAINS
SUBROUTINE glutInit_f03()
INTEGER(C_INT) :: argcp=1
TYPE(C_PTR), DIMENSION(1), TARGET :: argv=C_NULL_PTR
CHARACTER(C_CHAR), DIMENSION(1), TARGET :: empty_string=C_NULL_CHAR
! A hack
INTERFACE
SUBROUTINE SetNullFunc() BIND(C,NAME='SetNullFunc')
END SUBROUTINE
END INTERFACE
argv(1)=C_LOC(empty_string)
CALL glutInit_gl(argcp, C_LOC(argv))
END SUBROUTINE
SUBROUTINE glutTimerFunc_f03(time, proc, value)
INTEGER(GLint), VALUE :: value
INTEGER(GLuint), VALUE :: time
INTERFACE
SUBROUTINE proc(value) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: value
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutTimerFunc_gl(time, C_FUNLOC(proc), value)
ELSE
CALL glutTimerFunc_gl(time, C_NULL_FUNPTR, value)
END IF
END SUBROUTINE glutTimerFunc_f03
SUBROUTINE glutIdleFunc_f03(proc)
INTERFACE
SUBROUTINE proc() BIND(C)
IMPORT
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutIdleFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutIdleFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutIdleFunc_f03
SUBROUTINE glutKeyboardFunc_f03(proc)
INTERFACE
SUBROUTINE proc(key, x, y) BIND(C)
IMPORT
INTEGER(GLbyte), VALUE :: key
INTEGER(GLint), VALUE :: x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutKeyboardFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutKeyboardFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutKeyboardFunc_f03
SUBROUTINE glutSpecialFunc_f03(proc)
INTERFACE
SUBROUTINE proc(key, x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: key, x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutSpecialFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutSpecialFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutSpecialFunc_f03
SUBROUTINE glutReshapeFunc_f03(proc)
INTERFACE
SUBROUTINE proc(h, w) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: h, w
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutReshapeFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutReshapeFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutReshapeFunc_f03
SUBROUTINE glutVisibilityFunc_f03(proc)
INTERFACE
SUBROUTINE proc(visible) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: visible
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutVisibilityFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutVisibilityFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutVisibilityFunc_f03
SUBROUTINE glutDisplayFunc_f03(proc)
INTERFACE
SUBROUTINE proc() BIND(C)
IMPORT
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutDisplayFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutDisplayFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutDisplayFunc_f03
SUBROUTINE glutMouseFunc_f03(proc)
INTERFACE
SUBROUTINE proc(button, state, x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: button, state, x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutMouseFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutMouseFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutMouseFunc_f03
SUBROUTINE glutMotionFunc_f03(proc)
INTERFACE
SUBROUTINE proc(x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutMotionFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutMotionFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutMotionFunc_f03
SUBROUTINE glutPassiveMotionFunc_f03(proc)
INTERFACE
SUBROUTINE proc(x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutPassiveMotionFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutPassiveMotionFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutPassiveMotionFunc_f03
SUBROUTINE glutEntryFunc_f03(proc)
INTERFACE
SUBROUTINE proc(value) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: value
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutEntryFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutEntryFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutEntryFunc_f03
SUBROUTINE glutKeyboardUpFunc_f03(proc)
INTERFACE
SUBROUTINE proc(key, x, y) BIND(C)
IMPORT
INTEGER(GLbyte), VALUE :: key
INTEGER(GLint), VALUE :: x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutKeyboardUpFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutKeyboardUpFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutKeyboardUpFunc_f03
SUBROUTINE glutSpecialUpFunc_f03(proc)
INTERFACE
SUBROUTINE proc(key, x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: key, x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutSpecialUpFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutSpecialUpFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutSpecialUpFunc_f03
SUBROUTINE glutJoystickFunc_f03(proc, pollInterval)
INTEGER(GLint), VALUE :: pollInterval
INTERFACE
SUBROUTINE proc(buttonMask, x, y, z) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: x, y, z
INTEGER(GLuint), VALUE :: buttonMask
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutJoystickFunc_gl(C_FUNLOC(proc), pollInterval)
ELSE
CALL glutJoystickFunc_gl(C_NULL_FUNPTR, pollInterval)
END IF
END SUBROUTINE glutJoystickFunc_f03
SUBROUTINE glutMenuStateFunc_f03(proc)
INTERFACE
SUBROUTINE proc(menu) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: menu
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutMenuStateFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutMenuStateFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutMenuStateFunc_f03
SUBROUTINE glutMenuStatusFunc_f03(proc)
INTERFACE
SUBROUTINE proc(status, x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: status, x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutMenuStatusFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutMenuStatusFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutMenuStatusFunc_f03
SUBROUTINE glutOverlayDisplayFunc_f03(proc)
INTERFACE
SUBROUTINE proc() BIND(C)
IMPORT
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutOverlayDisplayFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutOverlayDisplayFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutOverlayDisplayFunc_f03
SUBROUTINE glutWindowStatusFunc_f03(proc)
INTERFACE
SUBROUTINE proc(status) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: status
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutWindowStatusFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutWindowStatusFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutWindowStatusFunc_f03
SUBROUTINE glutSpaceballMotionFunc_f03(proc)
INTERFACE
SUBROUTINE proc(key, x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: key, x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutSpaceballMotionFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutSpaceballMotionFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutSpaceballMotionFunc_f03
SUBROUTINE glutSpaceballRotateFunc_f03(proc)
INTERFACE
SUBROUTINE proc(key, x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: key, x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutSpaceballRotateFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutSpaceballRotateFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutSpaceballRotateFunc_f03
SUBROUTINE glutSpaceballButtonFunc_f03(proc)
INTERFACE
SUBROUTINE proc(x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutSpaceballButtonFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutSpaceballButtonFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutSpaceballButtonFunc_f03
SUBROUTINE glutButtonBoxFunc_f03(proc)
INTERFACE
SUBROUTINE proc(x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutButtonBoxFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutButtonBoxFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutButtonBoxFunc_f03
SUBROUTINE glutDialsFunc_f03(proc)
INTERFACE
SUBROUTINE proc(x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutDialsFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutDialsFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutDialsFunc_f03
SUBROUTINE glutTabletMotionFunc_f03(proc)
INTERFACE
SUBROUTINE proc(x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutTabletMotionFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutTabletMotionFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutTabletMotionFunc_f03
SUBROUTINE glutTabletButtonFunc_f03(proc)
INTERFACE
SUBROUTINE proc(button, state, x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: button, state, x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutTabletButtonFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutTabletButtonFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutTabletButtonFunc_f03
SUBROUTINE glutMouseWheelFunc_f03(proc)
INTERFACE
SUBROUTINE proc(button, state, x, y) BIND(C)
IMPORT
INTEGER(GLint), VALUE :: button, state, x, y
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutMouseWheelFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutMouseWheelFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutMouseWheelFunc_f03
SUBROUTINE glutCloseFunc_f03(proc)
INTERFACE
SUBROUTINE proc() BIND(C)
IMPORT
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutCloseFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutCloseFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutCloseFunc_f03
SUBROUTINE glutWMCloseFunc_f03(proc)
INTERFACE
SUBROUTINE proc() BIND(C)
IMPORT
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutWMCloseFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutWMCloseFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutWMCloseFunc_f03
SUBROUTINE glutMenuDestroyFunc_f03(proc)
INTERFACE
SUBROUTINE proc() BIND(C)
IMPORT
END SUBROUTINE proc
END INTERFACE
OPTIONAL :: proc
IF(PRESENT(proc)) THEN
CALL glutMenuDestroyFunc_gl(C_FUNLOC(proc))
ELSE
CALL glutMenuDestroyFunc_gl(C_NULL_FUNPTR)
END IF
END SUBROUTINE glutMenuDestroyFunc_f03
END MODULE OpenGL_glut
| gpl-3.0 |
techno/gcc-mist32 | gcc/testsuite/gfortran.dg/allocatable_dummy_1.f90 | 188 | 1177 | ! { dg-do run }
! Test procedures with allocatable dummy arguments
program alloc_dummy
implicit none
integer, allocatable :: a(:)
integer, allocatable :: b(:)
call init(a)
if (.NOT.allocated(a)) call abort()
if (.NOT.all(a == [ 1, 2, 3 ])) call abort()
call useit(a, b)
if (.NOT.all(b == [ 1, 2, 3 ])) call abort()
if (.NOT.all(whatever(a) == [ 1, 2, 3 ])) call abort()
call kill(a)
if (allocated(a)) call abort()
call kill(b)
if (allocated(b)) call abort()
contains
subroutine init(x)
integer, allocatable, intent(out) :: x(:)
allocate(x(3))
x = [ 1, 2, 3 ]
end subroutine init
subroutine useit(x, y)
integer, allocatable, intent(in) :: x(:)
integer, allocatable, intent(out) :: y(:)
if (allocated(y)) call abort()
call init(y)
y = x
end subroutine useit
function whatever(x)
integer, allocatable :: x(:)
integer :: whatever(size(x))
whatever = x
end function whatever
subroutine kill(x)
integer, allocatable, intent(out) :: x(:)
end subroutine kill
end program alloc_dummy
| gpl-2.0 |
rsignell-usgs/seagrid | seagrid/mex_matlab76_win32/mexsepeli.F | 7 | 120051 | #include <fintrf.h>
c
c purpose mexsepeli solves for the 2nd order finite
c difference approximation to the separable
c elliptic equation arising from conformal
c mapping and grid generation.
c
c
c
c
c The calling sequence from MATLAB should be
c
c >> [x, y, perturb, ierror] = mexsepeli ( x, y, ...
c l2, m2, ...
c seta, sxi, ...
c nwrk, nx2 );
c
c
c Output Parameters
c x,y:
c represent "x" and "y" grid coordinates
c perturb:
c Optional. Don't think this is needed for our
c application.
c ierror:
c Optional. An error flag that indicates invalid
c input parameters or failure to find a solution.
c = 0 no error
c = 4 if attempt to find a solution fails.
c (the linear system generated is not
c diagonally dominant.)
c
c Input Parameters
c x,y:
c represent "x" and "y" grid coordinates
c l2:
c x independent variable ranges from 0 to l2
c m2:
c y independent variable ranges from 0 to m2
c seta;
c digitized points on boundaries 1,3
c sxi:
c digitized points on boundaries 2,4
c
c
c So
c 1) nlhs = 2
c 2) plhs(1) = x
c plhs(2) = y
c 3) nrhs = 6
c 4) prhs(1) = x
c prhs(2) = y
c prhs(3) = l2
c prhs(4) = m2
c prhs(5) = seta
c prhs(6) = sxi
c
c
c $Id: mexsepeli.F,v 1.3 2004/09/30 20:57:43 jevans Exp $
c Currently locked by $Locker: $ (not locked if blank)
c (Time in GMT, EST=GMT-5:00
c $Log: mexsepeli.F,v $
c Revision 1.3 2004/09/30 20:57:43 jevans
c Several automatic casts (from real*8 to complex) were being done that g77
c was complaining about. Some new complex variables were added that made
c the cast explicit. g77 no longer spits out any warnings.
c
c Revision 1.2 2004/09/30 20:32:39 jevans
c Removed all declarations of variables that the solaris compiler claimed
c were never used. Seems to run fine.
c
c Revision 1.1.1.1 2004/09/30 15:22:15 jevans
c initial import
c
c Revision 1.1.1.1 2004/03/02 16:53:17 jevans
c MEXSEPELI
c
c Revision 1.4 2003/02/09 17:51:14 jevans
c Converted some more CMPLX statements to DCMPLX. Linux compilation didn't
c catch it, but Alpha did.
c
c Revision 1.2 2003/01/15 23:23:04 jevans
c Lots of matrices redefined as for their sizes. Who knows if it works?
c How the hell did it ever work before? God how I luv fortran.
c
c Revision 1.1.1.1 2003/01/15 22:31:12 jevans
c Imported sources
c
c
c
c
c $Id: mexsepeli.F,v 1.3 2004/09/30 20:57:43 jevans Exp $
c Currently locked by $Locker: $ (not locked if blank)
c (Time in GMT, EST=GMT-5:00
c $Log: mexsepeli.F,v $
c Revision 1.3 2004/09/30 20:57:43 jevans
c Several automatic casts (from real*8 to complex) were being done that g77
c was complaining about. Some new complex variables were added that made
c the cast explicit. g77 no longer spits out any warnings.
c
c Revision 1.2 2004/09/30 20:32:39 jevans
c Removed all declarations of variables that the solaris compiler claimed
c were never used. Seems to run fine.
c
c Revision 1.1.1.1 2004/09/30 15:22:15 jevans
c initial import
c
c Revision 1.1.1.1 2004/03/02 16:53:17 jevans
c MEXSEPELI
c
c Revision 1.4 2003/02/09 17:51:14 jevans
c Converted some more CMPLX statements to DCMPLX. Linux compilation didn't
c catch it, but Alpha did.
c
c Revision 1.2 2003/01/15 23:23:04 jevans
c Lots of matrices redefined as for their sizes. Who knows if it works?
c How the hell did it ever work before? God how I luv fortran.
c
c Revision 1.1.1.1 2003/01/15 22:31:12 jevans
c Imported sources
c
c Revision 1.2 1997/10/03 19:43:04 jevans
c Had to change compile time options to include "-align dcommons"
c and "-r8".
c
c the "mexCopyReal8ToPtr" and related functions suffer from the
c fact that they assume all arrays to be a single column. Since
c my x and y are dimensioned to be larger than their logical
c size (i.e. they are 800x800, but might logically be only 100x80
c or so), those arrays had to be columnified before passing them
c back to MATLAB, and "uncolumnified" upon passing them into
c MATLAB.
c
c Revision 1.1 1997/10/03 17:50:43 jevans
c Initial revision
c
c
c
subroutine mexFunction ( nlhs, plhs, nrhs, prhs )
crps POINTER plhs(*), prhs(*)
integer plhs(*), prhs(*)
integer nlhs, nrhs
include 'mexsepeli.inc'
c
c These are the number of rows and columns (m by n) of the
c matrices we work with.
integer size_m, size_n, size_mn
integer i, j, k
c
c Need some temporary space to store the double-precision
c matlab arguments. The correct number of rows and columns
c is not known at first.
real*8 tempx(0:nx2,0:ny2), tempy(0:nx2,0:ny2)
c
c input ranges for independent variables.
c 0 < x < l2, 0 < y < y2
integer l2, m2
c
c Pointers to input arguments
crps POINTER p
integer p
real*8 pa(1)
real*8 PERTRB
c
c Check for proper number of arguments.
c There must be at least 1 argument on the left hand size and
c no more than 3.
if ( nlhs .lt. 1 ) then
call mexErrMsgTxt ( 'Not enough input args for mexsepeli.' )
elseif ( nlhs .gt. 3 ) then
call mexErrMsgTxt ( 'Too many input args for mexsepeli.' )
endif
if ( nrhs .ne. 6 ) then
call mexErrMsgTxt('mexsepeli requires 6 input arguments')
endif
c
c Check that all input arguments were numeric.
if ( mxIsNumeric(prhs(1)) .ne. 1 ) then
call mexErrMsgTxt
+ ( 'x input array should be numeric' )
endif
if ( mxIsNumeric(prhs(2)) .ne. 1 ) then
call mexErrMsgTxt
+ ( 'y input array should be numeric' )
endif
if ( mxIsNumeric(prhs(3)) .ne. 1 ) then
call mexErrMsgTxt
+ ( 'l2 input should be numeric' )
endif
if ( mxIsNumeric(prhs(4)) .ne. 1 ) then
call mexErrMsgTxt
+ ( 'm2 input should be numeric' )
endif
if ( mxIsNumeric(prhs(5)) .ne. 1 ) then
call mexErrMsgTxt
+ ( 'seta input array should be numeric' )
endif
if ( mxIsNumeric(prhs(6)) .ne. 1 ) then
call mexErrMsgTxt
+ ( 'sxi input array should be numeric' )
endif
c
c Check to see that the l2 and m2 arguments were scalars
size_m = mxGetM ( prhs(3) )
size_n = mxGetN ( prhs(3) )
if ( size_n .ne. 1 .or. size_m .ne. 1 ) then
call mexErrMsgTxt
+ ('l2 argument should be a scalar' )
endif
size_m = mxGetM ( prhs(4) )
size_n = mxGetN ( prhs(4) )
if ( size_n .ne. 1 .or. size_m .ne. 1 ) then
call mexErrMsgTxt
+ ('m2 argument should be a scalar' )
endif
c
c Load the data into Fortran matrices.
c
c x
p = mxGetPr(prhs(1))
size_m = mxGetM ( prhs(1) )
size_n = mxGetN ( prhs(1) )
size_mn = size_m*size_n
call mxCopyPtrToReal8(p,tempx,size_mn)
k = 0
do 10 j = 0, size_n - 1
do 5 i = 0, size_m - 1
x(i,j) = tempx(k,0)
k = k + 1
5 continue
10 continue
c
c y
p = mxGetPr(prhs(2))
size_m = mxGetM ( prhs(2) )
size_n = mxGetN ( prhs(2) )
size_mn = size_m*size_n
call mxCopyPtrToReal8(p,tempy,size_mn)
k = 0
do 20 j = 0, size_n - 1
do 15 i = 0, size_m - 1
y(i,j) = tempy(k,0)
k = k + 1
15 continue
20 continue
c
c l2
p = mxGetPr(prhs(3))
call mxCopyPtrToReal8(p,pa,1)
l2 = pa(1)
c
c m2
p = mxGetPr(prhs(4))
call mxCopyPtrToReal8(p,pa,1)
m2 = pa(1)
c
c seta
p = mxGetPr(prhs(5))
size_m = mxGetM ( prhs(5) )
size_n = mxGetN ( prhs(5) )
neta = size_m*size_n
call mxCopyPtrToReal8(p,seta,neta)
c
c sxi
p = mxGetPr(prhs(6))
size_m = mxGetM ( prhs(6) )
size_n = mxGetN ( prhs(6) )
nxi = size_m*size_n
call mxCopyPtrToReal8(p,sxi,nxi)
c
c Construct right hand side
do 30 j = 0, neta - 1
do 25 i = 0, nxi - 1
rhs(i,j) = 0.
25 continue
30 continue
c
c Call the computational subroutine.
ewrk(1) = nwrk
call sepeli(0,2,0.d0,dble(l2),l2,1,wrk,wrk,wrk,wrk,0.d0,
* dble(m2),m2,
* 1,wrk,wrk,wrk,wrk,rhs,x,nx2+1,ewrk,pertrb,ierr)
if ( ierr .eq. 1 ) then
call mexErrMsgTxt
+ ( 'range of independent variables is out of whack' )
else if ( ierr .eq. 2 ) then
call mexErrMsgTxt
+ ( 'boundary condition mbdcnd wrongly specified' )
else if ( ierr .eq. 3 ) then
call mexErrMsgTxt
+ ( 'boundary condition nbdcnd wrongly specified' )
else if ( ierr .eq. 4 ) then
call mexErrMsgTxt
+ ( 'linear system generated is not diagonally dominant' )
else if ( ierr .eq. 5 ) then
call mexErrMsgTxt
+ ( 'idmn is too small' )
else if ( ierr .eq. 6 ) then
call mexErrMsgTxt
+ ( 'm is too small or too large' )
else if ( ierr .eq. 7 ) then
call mexErrMsgTxt
+ ( 'n is too small or too large' )
else if ( ierr .eq. 8 ) then
call mexErrMsgTxt
+ ( 'iorder is not 2 or 4' )
else if ( ierr .eq. 9 ) then
call mexErrMsgTxt
+ ( 'intl is not 0 or 1' )
else if ( ierr .eq. 10 ) then
call mexErrMsgTxt
+ ( 'afun*dfun less than or equal to 0' )
else if ( ierr .eq. 11 ) then
call mexErrMsgTxt
+ ( 'work space length input in w(1) is not right' )
end if
ewrk(1) = nwrk
call sepeli(0,2,0.d0,dble(l2),l2,1,wrk,wrk,wrk,wrk,0.d0,
* dble(m2),m2,
* 1,wrk,wrk,wrk,wrk,rhs,y,nx2+1,ewrk,pertrb,ierr)
if ( ierr .eq. 1 ) then
call mexErrMsgTxt
+ ( 'range of independent variables is out of whack' )
else if ( ierr .eq. 2 ) then
call mexErrMsgTxt
+ ( 'boundary condition mbdcnd wrongly specified' )
else if ( ierr .eq. 3 ) then
call mexErrMsgTxt
+ ( 'boundary condition nbdcnd wrongly specified' )
else if ( ierr .eq. 4 ) then
call mexErrMsgTxt
+ ( 'linear system generated is not diagonally dominant' )
else if ( ierr .eq. 5 ) then
call mexErrMsgTxt
+ ( 'idmn is too small' )
else if ( ierr .eq. 6 ) then
call mexErrMsgTxt
+ ( 'm is too small or too large' )
else if ( ierr .eq. 7 ) then
call mexErrMsgTxt
+ ( 'n is too small or too large' )
else if ( ierr .eq. 8 ) then
call mexErrMsgTxt
+ ( 'iorder is not 2 or 4' )
else if ( ierr .eq. 9 ) then
call mexErrMsgTxt
+ ( 'intl is not 0 or 1' )
else if ( ierr .eq. 10 ) then
call mexErrMsgTxt
+ ( 'afun*dfun less than or equal to 0' )
else if ( ierr .eq. 11 ) then
call mexErrMsgTxt
+ ( 'work space length input in w(1) is not right' )
end if
c
c Create matrices for output arguments
c Since the mxCopyReal8ToPtr routine just assumes one long
c column matrix, we have to "columnify" both x and y.
c
c x
size_m = mxGetM ( prhs(1) )
size_n = mxGetN ( prhs(1) )
size_mn = size_m*size_n
plhs(1) = mxCreateFull(size_m, size_n, 0)
p = mxGetPr(plhs(1))
k = 0
do 40 j = 0, size_n - 1
do 35 i = 0, size_m - 1
tempx(k,0) = x(i,j)
k = k + 1
35 continue
40 continue
call mxCopyReal8ToPtr ( tempx, p, size_mn )
c
c y
size_m = mxGetM ( prhs(2) )
size_n = mxGetN ( prhs(2) )
size_mn = size_m*size_n
plhs(2) = mxCreateFull(size_m, size_n, 0)
p = mxGetPr(plhs(2))
k = 0
do 50 j = 0, size_n - 1
do 45 i = 0, size_m - 1
tempy(k,0) = y(i,j)
k = k + 1
45 continue
50 continue
call mxCopyReal8ToPtr ( tempy, p, size_mn )
return
end
c Subroutine SEPELI(INTL,IORDER,A,B,M,MBDCND,BDA,ALPHA,BDB,BETA,C,D,
c * N,NBDCND,BDC,GAMA,BDD,XNU,COFX,COFY,GRHS,USOL,IDMN,W,PERTRB,
c * IERROR)
Subroutine SEPELI(INTL,IORDER,A,B,M,MBDCND,BDA,ALPHA,BDB,BETA,C,D,
* N,NBDCND,BDC,GAMA,BDD,XNU,GRHS,USOL,IDMN,W,PERTRB,
* IERROR)
c
c dimension of bda(n+1), bdb(n+1), bdc(m+1), bdd(m+1),
c arguments usol(idmn,n+1),grhs(idmn,n+1),
c w (see argument list)
c
c latest revision march 1985
c
c purpose sepeli solves for either the second-order
c finite difference approximation or a
c fourth-order approximation to a separable
c elliptic equation
c
c 2 2
c af(x)*d u/dx + bf(x)*du/dx + cf(x)*u +
c 2 2
c df(y)*d u/dy + ef(y)*du/dy + ff(y)*u
c
c = g(x,y)
c
c on a rectangle (x greater than or equal to a
c and less than or equal to b; y greater than
c or equal to c and less than or equal to d).
c any combination of periodic or mixed boundary
c conditions is allowed.
c
c the possible boundary conditions are:
c in the x-direction:
c (0) periodic, u(x+b-a,y)=u(x,y) for all
c y,x (1) u(a,y), u(b,y) are specified for
c all y
c (2) u(a,y), du(b,y)/dx+beta*u(b,y) are
c specified for all y
c (3) du(a,y)/dx+alpha*u(a,y),du(b,y)/dx+
c beta*u(b,y) are specified for all y
c (4) du(a,y)/dx+alpha*u(a,y),u(b,y) are
c specified for all y
c
c in the y-direction:
c (0) periodic, u(x,y+d-c)=u(x,y) for all x,y
c (1) u(x,c),u(x,d) are specified for all x
c (2) u(x,c),du(x,d)/dy+xnu*u(x,d) are
c specified for all x
c (3) du(x,c)/dy+gama*u(x,c),du(x,d)/dy+
c xnu*u(x,d) are specified for all x
c (4) du(x,c)/dy+gama*u(x,c),u(x,d) are
c specified for all x
c
c usage call sepeli (intl,iorder,a,b,m,mbdcnd,bda,
c alpha,bdb,beta,c,d,n,nbdcnd,bdc,
c gama,bdd,xnu,cofx,cofy,grhs,usol,
c idmn,w,pertrb,ierror)
c
c arguments
c on input intl
c = 0 on initial entry to sepeli or if any
c of the arguments c,d, n, nbdcnd, cofy
c are changed from a previous call
c = 1 if c, d, n, nbdcnd, cofy are unchanged
c from the previous call.
c
c iorder
c = 2 if a second-order approximation
c is sought
c = 4 if a fourth-order approximation
c is sought
c
c a,b
c the range of the x-independent variable,
c i.e., x is greater than or equal to a
c and less than or equal to b. a must be
c less than b.
c
c m
c the number of panels into which the
c interval [a,b] is subdivided. hence,
c there will be m+1 grid points in the x-
c direction given by xi=a+(i-1)*dlx
c for i=1,2,...,m+1 where dlx=(b-a)/m is
c the panel width. m must be less than
c idmn and greater than 5.
c
c mbdcnd
c indicates the type of boundary condition
c at x=a and x=b
c
c = 0 if the solution is periodic in x, i.e.,
c u(x+b-a,y)=u(x,y) for all y,x
c = 1 if the solution is specified at x=a
c and x=b, i.e., u(a,y) and u(b,y) are
c specified for all y
c = 2 if the solution is specified at x=a and
c the boundary condition is mixed at x=b,
c i.e., u(a,y) and du(b,y)/dx+beta*u(b,y)
c are specified for all y
c = 3 if the boundary conditions at x=a and
c x=b are mixed, i.e.,
c du(a,y)/dx+alpha*u(a,y) and
c du(b,y)/dx+beta*u(b,y) are specified
c for all y
c = 4 if the boundary condition at x=a is
c mixed and the solution is specified
c at x=b, i.e., du(a,y)/dx+alpha*u(a,y)
c and u(b,y) are specified for all y
c
c bda
c a one-dimensional array of length n+1
c that specifies the values of
c du(a,y)/dx+ alpha*u(a,y) at x=a, when
c mbdcnd=3 or 4.
c bda(j) = du(a,yj)/dx+alpha*u(a,yj),
c j=1,2,...,n+1. when mbdcnd has any other
c other value, bda is a dummy parameter.
c
c alpha
c the scalar multiplying the solution in
c case of a mixed boundary condition at x=a
c (see argument bda). if mbdcnd is not
c equal to 3 or 4 then alpha is a dummy
c parameter.
c
c bdb
c a one-dimensional array of length n+1
c that specifies the values of
c du(b,y)/dx+ beta*u(b,y) at x=b.
c when mbdcnd=2 or 3
c bdb(j) = du(b,yj)/dx+beta*u(b,yj),
c j=1,2,...,n+1. when mbdcnd has any other
c other value, bdb is a dummy parameter.
c
c beta
c the scalar multiplying the solution in
c case of a mixed boundary condition at
c x=b (see argument bdb). if mbdcnd is
c not equal to 2 or 3 then beta is a dummy
c parameter.
c
c c,d
c the range of the y-independent variable,
c i.e., y is greater than or equal to c
c and less than or equal to d. c must be
c less than d.
c
c n
c the number of panels into which the
c interval [c,d] is subdivided.
c hence, there will be n+1 grid points
c in the y-direction given by
c yj=c+(j-1)*dly for j=1,2,...,n+1 where
c dly=(d-c)/n is the panel width.
c in addition, n must be greater than 4.
c
c nbdcnd
c indicates the types of boundary conditions
c at y=c and y=d
c
c = 0 if the solution is periodic in y,
c i.e., u(x,y+d-c)=u(x,y) for all x,y
c = 1 if the solution is specified at y=c
c and y = d, i.e., u(x,c) and u(x,d)
c are specified for all x
c = 2 if the solution is specified at y=c
c and the boundary condition is mixed
c at y=d, i.e., u(x,c) and
c du(x,d)/dy+xnu*u(x,d) are specified
c for all x
c = 3 if the boundary conditions are mixed
c at y=c and y=d, i.e.,
c du(x,d)/dy+gama*u(x,c) and
c du(x,d)/dy+xnu*u(x,d) are specified
c for all x
c = 4 if the boundary condition is mixed
c at y=c and the solution is specified
c at y=d, i.e. du(x,c)/dy+gama*u(x,c)
c and u(x,d) are specified for all x
c
c bdc
c a one-dimensional array of length m+1
c that specifies the value of
c du(x,c)/dy+gama*u(x,c) at y=c.
c when nbdcnd=3 or 4 bdc(i) = du(xi,c)/dy +
c gama*u(xi,c), i=1,2,...,m+1.
c when nbdcnd has any other value, bdc
c is a dummy parameter.
c
c gama
c the scalar multiplying the solution in
c case of a mixed boundary condition at
c y=c (see argument bdc). if nbdcnd is
c not equal to 3 or 4 then gama is a dummy
c parameter.
c
c bdd
c a one-dimensional array of length m+1
c that specifies the value of
c du(x,d)/dy + xnu*u(x,d) at y=c.
c when nbdcnd=2 or 3 bdd(i) = du(xi,d)/dy +
c xnu*u(xi,d), i=1,2,...,m+1.
c when nbdcnd has any other value, bdd
c is a dummy parameter.
c
c xnu
c the scalar multiplying the solution in
c case of a mixed boundary condition at
c y=d (see argument bdd). if nbdcnd is
c not equal to 2 or 3 then xnu is a
c dummy parameter.
c
c cofx
c a user-supplied subprogram with
c parameters x, afun, bfun, cfun which
c returns the values of the x-dependent
c coefficients af(x), bf(x), cf(x) in the
c elliptic equation at x.
c
c cofy
c a user-supplied subprogram with parameters
c y, dfun, efun, ffun which returns the
c values of the y-dependent coefficients
c df(y), ef(y), ff(y) in the elliptic
c equation at y.
c
c note: cofx and cofy must be declared
c external in the calling routine.
c the values returned in afun and dfun
c must satisfy afun*dfun greater than 0
c for a less than x less than b, c less
c than y less than d (see ierror=10).
c the coefficients provided may lead to a
c matrix equation which is not diagonally
c dominant in which case solution may fail
c (see ierror=4).
c
c grhs
c a two-dimensional array that specifies the
c values of the right-hand side of the
c elliptic equation, i.e.,
c grhs(i,j)=g(xi,yi), for i=2,...,m,
c j=2,...,n. at the boundaries, grhs is
c defined by
c
c mbdcnd grhs(1,j) grhs(m+1,j)
c ------ --------- -----------
c 0 g(a,yj) g(b,yj)
c 1 * *
c 2 * g(b,yj) j=1,2,...,n+1
c 3 g(a,yj) g(b,yj)
c 4 g(a,yj) *
c
c nbdcnd grhs(i,1) grhs(i,n+1)
c ------ --------- -----------
c 0 g(xi,c) g(xi,d)
c 1 * *
c 2 * g(xi,d) i=1,2,...,m+1
c 3 g(xi,c) g(xi,d)
c 4 g(xi,c) *
c
c where * means these quantities are not used.
c grhs should be dimensioned idmn by at least
c n+1 in the calling routine.
c
c usol
c a two-dimensional array that specifies the
c values of the solution along the boundaries.
c at the boundaries, usol is defined by
c
c mbdcnd usol(1,j) usol(m+1,j)
c ------ --------- -----------
c 0 * *
c 1 u(a,yj) u(b,yj)
c 2 u(a,yj) * j=1,2,...,n+1
c 3 * *
c 4 * u(b,yj)
c
c nbdcnd usol(i,1) usol(i,n+1)
c ------ --------- -----------
c 0 * *
c 1 u(xi,c) u(xi,d)
c 2 u(xi,c) * i=1,2,...,m+1
c 3 * *
c 4 * u(xi,d)
c
c where * means the quantities are not used
c in the solution.
c
c if iorder=2, the user may equivalence grhs
c and usol to save space. note that in this
c case the tables specifying the boundaries
c of the grhs and usol arrays determine the
c boundaries uniquely except at the corners.
c if the tables call for both g(x,y) and
c u(x,y) at a corner then the solution must
c be chosen. for example, if mbdcnd=2 and
c nbdcnd=4, then u(a,c), u(a,d), u(b,d) must
c be chosen at the corners in addition
c to g(b,c).
c
c if iorder=4, then the two arrays, usol and
c grhs, must be distinct.
c
c usol should be dimensioned idmn by at least
c n+1 in the calling routine.
c
c idmn
c the row (or first) dimension of the arrays
c grhs and usol as it appears in the program
c calling sepeli. this parameter is used
c to specify the variable dimension of grhs
c and usol. idmn must be at least 7 and
c greater than or equal to m+1.
c
c w
c a one-dimensional array that must be
c provided by the user for work space.
c let k=int(log2(n+1))+1 and set l=2**(k+1).
c then (k-2)*l+k+10*n+12*m+27 will suffice
c as a length of w. the actual length of w
c in the calling routine must be set in w(1)
c (see ierror=11).
c
c on output usol
c contains the approximate solution to the
c elliptic equation.
c usol(i,j) is the approximation to u(xi,yj)
c for i=1,2...,m+1 and j=1,2,...,n+1.
c the approximation has error
c o(dlx**2+dly**2) if called with iorder=2
c and o(dlx**4+dly**4) if called with
c iorder=4.
c
c w
c contains intermediate values that must not
c be destroyed if sepeli is called again with
c intl=1. in addition w(1) contains the
c exact minimal length (in floating point)
c required for the work space (see ierror=11).
c
c pertrb
c if a combination of periodic or derivative
c boundary conditions
c (i.e., alpha=beta=0 if mbdcnd=3;
c gama=xnu=0 if nbdcnd=3) is specified
c and if the coefficients of u(x,y) in the
c separable elliptic equation are zero
c (i.e., cf(x)=0 for x greater than or equal
c to a and less than or equal to b;
c ff(y)=0 for y greater than or equal to c
c and less than or equal to d) then a
c solution may not exist. pertrb is a
c constant calculated and subtracted from
c the right-hand side of the matrix equations
c generated by sepeli which insures that a
c solution exists. sepeli then computes this
c solution which is a weighted minimal least
c squares solution to the original problem.
c
c ierror
c an error flag that indicates invalid input
c parameters or failure to find a solution
c = 0 no error
c = 1 if a greater than b or c greater than d
c = 2 if mbdcnd less than 0 or mbdcnd greater
c than 4
c = 3 if nbdcnd less than 0 or nbdcnd greater
c than 4
c = 4 if attempt to find a solution fails.
c (the linear system generated is not
c diagonally dominant.)
c = 5 if idmn is too small
c (see discussion of idmn)
c = 6 if m is too small or too large
c (see discussion of m)
c = 7 if n is too small (see discussion of n)
c = 8 if iorder is not 2 or 4
c = 9 if intl is not 0 or 1
c = 10 if afun*dfun less than or equal to 0
c for some interior mesh point (xi,yj)
c = 11 if the work space length input in w(1)
c is less than the exact minimal work
c space length required output in w(1).
c
c note (concerning ierror=4): for the
c coefficients input through cofx, cofy,
c the discretization may lead to a block
c tridiagonal linear system which is not
c diagonally dominant (for example, this
c happens if cfun=0 and bfun/(2.*dlx) greater
c than afun/dlx**2). in this case solution
c may fail. this cannot happen in the limit
c as dlx, dly approach zero. hence, the
c condition may be remedied by taking larger
c values for m or n.
c
c special conditions see cofx, cofy argument descriptions above.
c
c i/o none
c
c precision single
c
c required library blktri, comf, q8qst4, and sepaux, which are
c files loaded by default on ncar's cray machines.
c
c language fortran
c
c history developed at ncar during 1975-76 by
c john c. adams of the scientific computing
c division. released on ncar's public software
c libraries in january 1980.
c
c portability fortran 66
c
c algorithm sepeli automatically discretizes the
c separable elliptic equation which is then
c solved by a generalized cyclic reduction
c algorithm in the subroutine, blktri. the
c fourth-order solution is obtained using
c 'deferred corrections' which is described
c and referenced in sections, references and
c method.
c
c timing the operational count is proportional to
c m*n*log2(n).
c
c accuracy the following accuracy results were obtained
c on a cdc 7600. note that the fourth-order
c accuracy is not realized until the mesh is
c sufficiently refined.
c
c second-order fourth-order
c m n error error
c
c 6 6 6.8e-1 1.2e0
c 14 14 1.4e-1 1.8e-1
c 30 30 3.2e-2 9.7e-3
c 62 62 7.5e-3 3.0e-4
c 126 126 1.8e-3 3.5e-6
c
c portability fortran 66
c
c references keller, h.b., numerical methods for two-point
c boundary-value problems, blaisdel (1968),
c waltham, mass.
c
c swarztrauber, p., and r. sweet (1975):
c efficient fortran subprograms for the
c solution of elliptic partial differential
c equations. ncar technical note
c ncar-tn/ia-109, pp. 135-137.
c***********************************************************************
IMPLICIT NONE
integer IDMN, INTL, IORDER, MBDCND, NBDCND, M, N, IERROR
integer L, LOGB2N, LL, K, LENGTH, LINPUT
integer LOUTPT
integer I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13
Dimension GRHS(IDMN,1), USOL(IDMN,IDMN)
Dimension BDA(1), BDB(1), BDC(1), BDD(1), W(1)
real*8 BDA
real*8 ALPHA
real*8 BDB
real*8 BETA
real*8 BDC
real*8 GAMA
real*8 BDD
real*8 XNU
real*8 GRHS
real*8 USOL
real*8 W
real*8 A, B, C, D, PERTRB
c External COFX, COFY
Logical Q8Q4
Save Q8Q4
Data Q8Q4 /.TRUE./
c
If (Q8Q4) Then
c call q8qst4('loclib','sepeli','sepeli','version 01')
Q8Q4 = .FALSE.
End If
c
c check input parameters
c
c Call CHKPRM(INTL,IORDER,A,B,M,MBDCND,C,D,N,NBDCND,COFX,COFY,IDMN,
c * IERROR)
Call CHKPRM(INTL,IORDER,A,B,M,MBDCND,C,D,N,NBDCND,IDMN,
* IERROR)
If (IERROR.NE.0) Return
c
c compute minimum work space and check work space length input
c
L = N + 1
If (NBDCND.EQ.0) L = N
LOGB2N = INT(DLOG(DBLE(L)+0.d5)/DLOG(2.d0)) + 1
LL = 2 ** (LOGB2N+1)
K = M + 1
L = N + 1
LENGTH = (LOGB2N-2) * LL + LOGB2N + MAX0(2*L,6*K) + 5
If (NBDCND.EQ.0) LENGTH = LENGTH + 2 * L
IERROR = 11
LINPUT = INT(W(1)+0.5)
LOUTPT = LENGTH + 6 * (K+L) + 1
W(1) = DBLE(LOUTPT)
If (LOUTPT.GT.LINPUT) Return
IERROR = 0
c
c set work space indices
c
I1 = LENGTH + 2
I2 = I1 + L
I3 = I2 + L
I4 = I3 + L
I5 = I4 + L
I6 = I5 + L
I7 = I6 + L
I8 = I7 + K
I9 = I8 + K
I10 = I9 + K
I11 = I10 + K
I12 = I11 + K
I13 = 2
c Call SPELIP(INTL,IORDER,A,B,M,MBDCND,BDA,ALPHA,BDB,BETA,C,D,N,
c * NBDCND,BDC,GAMA,BDD,XNU,COFX,COFY,W(I1),W(I2),W(I3),W(I4),
c * W(I5),W(I6),W(I7),W(I8),W(I9),W(I10),W(I11),W(I12),GRHS,USOL,
c * IDMN,W(I13),PERTRB,IERROR)
Call SPELIP(INTL,IORDER,A,B,M,MBDCND,BDA,ALPHA,BDB,BETA,C,D,N,
* NBDCND,BDC,GAMA,BDD,XNU,W(I1),W(I2),W(I3),W(I4),
* W(I5),W(I6),W(I7),W(I8),W(I9),W(I10),W(I11),W(I12),GRHS,USOL,
* IDMN,W(I13),PERTRB,IERROR)
Return
End
c Subroutine SPELIP(INTL,IORDER,A,B,M,MBDCND,BDA,ALPHA,BDB,BETA,C,D,
c * N,NBDCND,BDC,GAMA,BDD,XNU,COFX,COFY,AN,BN,CN,DN,UN,ZN,AM,BM,
c * CM,DM,UM,ZM,GRHS,USOL,IDMN,W,PERTRB,IERROR)
Subroutine SPELIP(INTL,IORDER,A,B,M,MBDCND,BDA,ALPHA,BDB,BETA,C,D,
* N,NBDCND,BDC,GAMA,BDD,XNU,AN,BN,CN,DN,UN,ZN,AM,BM,
* CM,DM,UM,ZM,GRHS,USOL,IDMN,W,PERTRB,IERROR)
c
c spelip sets up vectors and arrays for input to blktri
c and computes a second order solution in usol. a return jump to
c sepeli occurrs if iorder=2. if iorder=4 a fourth order
c solution is generated in usol.
c
IMPLICIT NONE
integer IDMN
Dimension BDA(1), BDB(1), BDC(1), BDD(1), W(1)
Dimension GRHS(IDMN,1), USOL(IDMN,IDMN)
Dimension AN(1), BN(1), CN(1), DN(1), UN(1), ZN(1)
Dimension AM(1), BM(1), CM(1), DM(1), UM(1), ZM(1)
integer KSWX, KSWY, K, MBDCND, NBDCND
integer AIT, BIT, CIT, DIT, IS, MIT, NIT, L
real*8 MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4
Common /SPLP/ KSWX, KSWY, K, L,
* MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4,
* AIT, BIT, CIT, DIT, MIT, NIT, IS
Logical SINGLR
real*8 BDA, BDB, BDC, BDD
real*8 ALPHA, BETA, GAMA
real*8 A, B, C, D, W
real*8 XNU
real*8 GRHS, USOL
real*8 AN, BN, CN, DN, UN, ZN
real*8 AM, BM, CM, DM, UM, ZM
real*8 YJ, DJ, EJ, FJ
real*8 XI, AI, BI, CI
real*8 PRTRB, PERTRB
integer M, N, I, J, I1, MP, NP, IORDER, IORD, INTL, IERROR
real*8 AXI, BXI, CXI, DYJ, EYJ, FYJ, AX1, CXM, DY1, FYN
c External COFX, COFY
c
c set parameters internally
c
KSWX = MBDCND + 1
KSWY = NBDCND + 1
K = M + 1
L = N + 1
AIT = A
BIT = B
CIT = C
DIT = D
c
c set right hand side values from grhs in usol on the interior
c and non-specified boundaries.
c
Do 20 I = 2, M
Do 10 J = 2, N
USOL(I,J) = GRHS(I,J)
10 Continue
20 Continue
If (KSWX.NE.2.AND.KSWX.NE.3) Then
Do 30 J = 2, N
USOL(1,J) = GRHS(1,J)
30 Continue
End If
If (KSWX.NE.2.AND.KSWX.NE.5) Then
Do 40 J = 2, N
USOL(K,J) = GRHS(K,J)
40 Continue
End If
If (KSWY.NE.2.AND.KSWY.NE.3) Then
Do 50 I = 2, M
USOL(I,1) = GRHS(I,1)
50 Continue
End If
If (KSWY.NE.2.AND.KSWY.NE.5) Then
Do 60 I = 2, M
USOL(I,L) = GRHS(I,L)
60 Continue
End If
If (KSWX.NE.2.AND.KSWX.NE.3.AND.KSWY.NE.2.AND.KSWY.NE.3)
* USOL(1,1) = GRHS(1,1)
If (KSWX.NE.2.AND.KSWX.NE.5.AND.KSWY.NE.2.AND.KSWY.NE.3)
* USOL(K,1) = GRHS(K,1)
If (KSWX.NE.2.AND.KSWX.NE.3.AND.KSWY.NE.2.AND.KSWY.NE.5)
* USOL(1,L) = GRHS(1,L)
If (KSWX.NE.2.AND.KSWX.NE.5.AND.KSWY.NE.2.AND.KSWY.NE.5)
* USOL(K,L) = GRHS(K,L)
I1 = 1
c
c set switches for periodic or non-periodic boundaries
c
MP = 1
NP = 1
If (KSWX.EQ.1) MP = 0
If (KSWY.EQ.1) NP = 0
c
c set dlx,dly and size of block tri-diagonal system generated
c in nint,mint
c
DLX = (BIT-AIT) / DBLE(M)
MIT = K - 1
If (KSWX.EQ.2) MIT = K - 2
If (KSWX.EQ.4) MIT = K
DLY = (DIT-CIT) / DBLE(N)
NIT = L - 1
If (KSWY.EQ.2) NIT = L - 2
If (KSWY.EQ.4) NIT = L
TDLX3 = 2.0 * DLX ** 3
DLX4 = DLX ** 4
TDLY3 = 2.0 * DLY ** 3
DLY4 = DLY ** 4
c
c set subscript limits for portion of array to input to blktri
c
IS = 1
JS = 1
If (KSWX.EQ.2.OR.KSWX.EQ.3) IS = 2
If (KSWY.EQ.2.OR.KSWY.EQ.3) JS = 2
NS = NIT + JS - 1
MS = MIT + IS - 1
c
c set x - direction
c
Do 70 I = 1, MIT
XI = AIT + DBLE(IS+I-2) * DLX
Call COFX(XI,AI,BI,CI)
AXI = (AI/DLX-0.5*BI) / DLX
BXI = -2. * AI / DLX ** 2 + CI
CXI = (AI/DLX+0.5*BI) / DLX
AM(I) = AXI
BM(I) = BXI
CM(I) = CXI
70 Continue
c
c set y direction
c
Do 80 J = 1, NIT
YJ = CIT + DBLE(JS+J-2) * DLY
Call COFY(YJ,DJ,EJ,FJ)
DYJ = (DJ/DLY-0.5*EJ) / DLY
EYJ = (-2.*DJ/DLY**2+FJ)
FYJ = (DJ/DLY+0.5*EJ) / DLY
AN(J) = DYJ
BN(J) = EYJ
CN(J) = FYJ
80 Continue
c
c adjust edges in x direction unless periodic
c
AX1 = AM(1)
CXM = CM(MIT)
Go To (130,90,110,120,100), KSWX
c
c dirichlet-dirichlet in x direction
c
90 AM(1) = 0.0
CM(MIT) = 0.0
Go To 130
c
c mixed-dirichlet in x direction
c
100 AM(1) = 0.0
BM(1) = BM(1) + 2. * ALPHA * DLX * AX1
CM(1) = CM(1) + AX1
CM(MIT) = 0.0
Go To 130
c
c dirichlet-mixed in x direction
c
110 AM(1) = 0.0
AM(MIT) = AM(MIT) + CXM
BM(MIT) = BM(MIT) - 2. * BETA * DLX * CXM
CM(MIT) = 0.0
Go To 130
c
c mixed - mixed in x direction
c
120 Continue
AM(1) = 0.0
BM(1) = BM(1) + 2. * DLX * ALPHA * AX1
CM(1) = CM(1) + AX1
AM(MIT) = AM(MIT) + CXM
BM(MIT) = BM(MIT) - 2. * DLX * BETA * CXM
CM(MIT) = 0.0
130 Continue
c
c adjust in y direction unless periodic
c
DY1 = AN(1)
FYN = CN(NIT)
Go To (180,140,160,170,150), KSWY
c
c dirichlet-dirichlet in y direction
c
140 Continue
AN(1) = 0.0
CN(NIT) = 0.0
Go To 180
c
c mixed-dirichlet in y direction
c
150 Continue
AN(1) = 0.0
BN(1) = BN(1) + 2. * DLY * GAMA * DY1
CN(1) = CN(1) + DY1
CN(NIT) = 0.0
Go To 180
c
c dirichlet-mixed in y direction
c
160 AN(1) = 0.0
AN(NIT) = AN(NIT) + FYN
BN(NIT) = BN(NIT) - 2. * DLY * XNU * FYN
CN(NIT) = 0.0
Go To 180
c
c mixed - mixed direction in y direction
c
170 Continue
AN(1) = 0.0
BN(1) = BN(1) + 2. * DLY * GAMA * DY1
CN(1) = CN(1) + DY1
AN(NIT) = AN(NIT) + FYN
BN(NIT) = BN(NIT) - 2.0 * DLY * XNU * FYN
CN(NIT) = 0.0
180 If (KSWX.NE.1) Then
c
c adjust usol along x edge
c
Do 190 J = JS, NS
If (KSWX.EQ.2.OR.KSWX.EQ.3) Then
USOL(IS,J) = USOL(IS,J) - AX1 * USOL(1,J)
Else
USOL(IS,J) = USOL(IS,J) + 2.0 * DLX * AX1 * BDA(J)
End If
If (KSWX.EQ.2.OR.KSWX.EQ.5) Then
USOL(MS,J) = USOL(MS,J) - CXM * USOL(K,J)
Else
USOL(MS,J) = USOL(MS,J) - 2.0 * DLX * CXM * BDB(J)
End If
190 Continue
End If
If (KSWY.NE.1) Then
c
c adjust usol along y edge
c
Do 200 I = IS, MS
If (KSWY.EQ.2.OR.KSWY.EQ.3) Then
USOL(I,JS) = USOL(I,JS) - DY1 * USOL(I,1)
Else
USOL(I,JS) = USOL(I,JS) + 2.0 * DLY * DY1 * BDC(I)
End If
If (KSWY.EQ.2.OR.KSWY.EQ.5) Then
USOL(I,NS) = USOL(I,NS) - FYN * USOL(I,L)
Else
USOL(I,NS) = USOL(I,NS) - 2.0 * DLY * FYN * BDD(I)
End If
200 Continue
End If
c
c save adjusted edges in grhs if iorder=4
c
If (IORDER.EQ.4) Then
Do 210 J = JS, NS
GRHS(IS,J) = USOL(IS,J)
GRHS(MS,J) = USOL(MS,J)
210 Continue
Do 220 I = IS, MS
GRHS(I,JS) = USOL(I,JS)
GRHS(I,NS) = USOL(I,NS)
220 Continue
End If
IORD = IORDER
PERTRB = 0.0
c
c check if operator is singular
c
c Call CHKSNG(MBDCND,NBDCND,ALPHA,BETA,GAMA,XNU,COFX,COFY,SINGLR)
Call CHKSNG(MBDCND,NBDCND,ALPHA,BETA,GAMA,XNU,SINGLR)
c
c compute non-zero eigenvector in null space of transpose
c if singular
c
If (SINGLR) Call SEPTRI(MIT,AM,BM,CM,DM,UM,ZM)
If (SINGLR) Call SEPTRI(NIT,AN,BN,CN,DN,UN,ZN)
c
c make initialization call to blktri
c
If (INTL.EQ.0) Call BLKTRI(INTL,NP,NIT,AN,BN,CN,MP,MIT,AM,BM,CM,
* IDMN,USOL(IS,JS),IERROR,W)
If (IERROR.NE.0) Return
c
c adjust right hand side if necessary
c
230 Continue
If (SINGLR) Call SEPORT(USOL,IDMN,ZN,ZM,PERTRB)
c
c compute solution
c
Call BLKTRI(I1,NP,NIT,AN,BN,CN,MP,MIT,AM,BM,CM,IDMN,USOL(IS,JS),
* IERROR,W)
If (IERROR.NE.0) Return
c
c set periodic boundaries if necessary
c
If (KSWX.EQ.1) Then
Do 240 J = 1, L
USOL(K,J) = USOL(1,J)
240 Continue
End If
If (KSWY.EQ.1) Then
Do 250 I = 1, K
USOL(I,L) = USOL(I,1)
250 Continue
End If
c
c minimize solution with respect to weighted least squares
c norm if operator is singular
c
If (SINGLR) Call SEPMIN(USOL,IDMN,ZN,ZM,PRTRB)
c
c return if deferred corrections and a fourth order solution are
c not flagged
c
If (IORD.EQ.2) Return
IORD = 2
c
c compute new right hand side for fourth order solution
c
c Call DEFER(COFX,COFY,IDMN,USOL,GRHS)
Call DEFER(IDMN,USOL,GRHS)
Go To 230
End
c Subroutine CHKPRM(INTL,IORDER,A,B,M,MBDCND,C,D,N,NBDCND,COFX,COFY,
c * IDMN,IERROR)
Subroutine CHKPRM(INTL,IORDER,A,B,M,MBDCND,C,D,N,NBDCND,
* IDMN,IERROR)
c
c this program checks the input parameters for errors
c
c External COFX, COFY
c
c check definition of solution region
c
IMPLICIT NONE
integer IERROR, MBDCND, NBDCND, IDMN, M, N, IORDER, INTL
real*8 A, B, C, D
real*8 YJ, DJ, EJ, FJ
real*8 XI, AI, BI, CI, DLX, DLY
integer I, J
IERROR = 1
If (A.GE.B.OR.C.GE.D) Return
c
c check boundary switches
c
IERROR = 2
If (MBDCND.LT.0.OR.MBDCND.GT.4) Return
IERROR = 3
If (NBDCND.LT.0.OR.NBDCND.GT.4) Return
c
c check first dimension in calling routine
c
IERROR = 5
If (IDMN.LT.7) Return
c
c check m
c
IERROR = 6
If (M.GT.(IDMN-1).OR.M.LT.6) Return
c
c check n
c
IERROR = 7
If (N.LT.5) Return
c
c check iorder
c
IERROR = 8
If (IORDER.NE.2.AND.IORDER.NE.4) Return
c
c check intl
c
IERROR = 9
If (INTL.NE.0.AND.INTL.NE.1) Return
c
c check that equation is elliptic
c
DLX = (B-A) / DBLE(M)
DLY = (D-C) / DBLE(N)
Do 20 I = 2, M
XI = A + DBLE(I-1) * DLX
Call COFX(XI,AI,BI,CI)
Do 10 J = 2, N
YJ = C + DBLE(J-1) * DLY
Call COFY(YJ,DJ,EJ,FJ)
If (AI*DJ.LE.0.0) Then
IERROR = 10
Return
End If
10 Continue
20 Continue
c
c no error found
c
IERROR = 0
Return
End
c Subroutine CHKSNG(MBDCND,NBDCND,ALPHA,BETA,GAMA,XNU,COFX,COFY,
c * SINGLR)
Subroutine CHKSNG(MBDCND,NBDCND,ALPHA,BETA,GAMA,XNU,
* SINGLR)
c
c this subroutine checks if the pde sepeli
c must solve is a singular operator
c
IMPLICIT NONE
integer MBDCND, NBDCND
integer KSWX, KSWY, K, L
integer AIT, BIT, CIT, DIT, IS, MIT, NIT
real*8 MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4
Common /SPLP/ KSWX, KSWY, K, L,
* MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4,
* AIT, BIT, CIT, DIT, MIT, NIT, IS
integer I, J
Logical SINGLR
real*8 ALPHA
real*8 BETA
real*8 GAMA
real*8 XNU
real*8 YJ, DJ, EJ, FJ
real*8 XI, AI, BI, CI
SINGLR = .FALSE.
c
c check if the boundary conditions are
c entirely periodic and/or mixed
c
If ((MBDCND.NE.0.AND.MBDCND.NE.3).OR.(NBDCND.NE.0.AND.NBDCND.NE.3)
* ) Return
c
c check that mixed conditions are pure neuman
c
If (MBDCND.EQ.3) Then
If (ALPHA.NE.0.0.OR.BETA.NE.0.0) Return
End If
If (NBDCND.EQ.3) Then
If (GAMA.NE.0.0.OR.XNU.NE.0.0) Return
End If
c
c check that non-derivative coefficient functions
c are zero
c
Do 10 I = IS, MS
XI = AIT + DBLE(I-1) * DLX
Call COFX(XI,AI,BI,CI)
If (CI.NE.0.0) Return
10 Continue
Do 20 J = JS, NS
YJ = CIT + DBLE(J-1) * DLY
Call COFY(YJ,DJ,EJ,FJ)
If (FJ.NE.0.0) Return
20 Continue
c
c the operator must be singular if this point is reached
c
SINGLR = .TRUE.
Return
End
c Subroutine DEFER(COFX,COFY,IDMN,USOL,GRHS)
Subroutine DEFER(IDMN,USOL,GRHS)
c
c this subroutine first approximates the truncation error given by
c trun1(x,y)=dlx**2*tx+dly**2*ty where
c tx=afun(x)*uxxxx/12.0+bfun(x)*uxxx/6.0 on the interior and
c at the boundaries if periodic(here uxxx,uxxxx are the third
c and fourth partial derivatives of u with respect to x).
c tx is of the form afun(x)/3.0*(uxxxx/4.0+uxxx/dlx)
c at x=a or x=b if the boundary condition there is mixed.
c tx=0.0 along specified boundaries. ty has symmetric form
c in y with x,afun(x),bfun(x) replaced by y,dfun(y),efun(y).
c the second order solution in usol is used to approximate
c (via second order finite differencing) the truncation error
c and the result is added to the right hand side in grhs
c and then transferred to usol to be used as a new right
c hand side when calling blktri for a fourth order solution.
c
IMPLICIT NONE
integer KSWX, KSWY, K
integer AIT, BIT, CIT, DIT, IS, MIT, NIT
real*8 MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4
integer L
Common /SPLP/ KSWX, KSWY, K, L,
* MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4,
* AIT, BIT, CIT, DIT, MIT, NIT, IS
integer IDMN
Dimension GRHS(IDMN,1), USOL(IDMN,1)
real*8 GRHS, USOL, UXXX, UXXXX, UYYY, UYYYY
c External COFX, COFY
real*8 YJ, DJ, EJ, FJ
real*8 XI, AI, BI, CI, TX, TY
integer I, J
c
c compute truncation error approximation over the entire mesh
c
Do 20 J = JS, NS
YJ = CIT + DBLE(J-1) * DLY
Call COFY(YJ,DJ,EJ,FJ)
Do 10 I = IS, MS
XI = AIT + DBLE(I-1) * DLX
Call COFX(XI,AI,BI,CI)
c
c compute partial derivative approximations at (xi,yj)
c
Call SEPDX(USOL,IDMN,I,J,UXXX,UXXXX)
Call SEPDY(USOL,IDMN,I,J,UYYY,UYYYY)
TX = AI * UXXXX / 12.0 + BI * UXXX / 6.0
TY = DJ * UYYYY / 12.0 + EJ * UYYY / 6.0
c
c reset form of truncation if at boundary which is non-periodic
c
If (.NOT.(KSWX.EQ.1.OR.(I.GT.1.AND.I.LT.K))) Then
TX = AI / 3.0 * (UXXXX/4.0+UXXX/DLX)
End If
If (.NOT.(KSWY.EQ.1.OR.(J.GT.1.AND.J.LT.L))) Then
TY = DJ / 3.0 * (UYYYY/4.0+UYYY/DLY)
End If
GRHS(I,J) = GRHS(I,J) + DLX ** 2 * TX + DLY ** 2 * TY
10 Continue
20 Continue
c
c reset the right hand side in usol
c
Do 40 I = IS, MS
Do 30 J = JS, NS
USOL(I,J) = GRHS(I,J)
30 Continue
40 Continue
Return
c
c revision history---
c
c december 1979 first added to nssl
c-----------------------------------------------------------------------
End
Subroutine BLKTRI(IFLG,NP,N,AN,BN,CN,MP,M,AM,BM,CM,IDIMY,Y,IERROR,
* W)
c
c dimension of an(n),bn(n),cn(n),am(m),bm(m),cm(m),y(idimy,n),
c arguments w(see argument list)
c
c latest revision january 1985
c
c usage call blktri (iflg,np,n,an,bn,cn,mp,m,am,bm,
c cm,idimy,y,ierror,w)
c
c purpose blktri solves a system of linear equations
c of the form
c
c an(j)*x(i,j-1) + am(i)*x(i-1,j) +
c (bn(j)+bm(i))*x(i,j) + cn(j)*x(i,j+1) +
c cm(i)*x(i+1,j) = y(i,j)
c
c for i = 1,2,...,m and j = 1,2,...,n.
c
c i+1 and i-1 are evaluated modulo m and
c j+1 and j-1 modulo n, i.e.,
c
c x(i,0) = x(i,n), x(i,n+1) = x(i,1),
c x(0,j) = x(m,j), x(m+1,j) = x(1,j).
c
c these equations usually result from the
c discretization of separable elliptic
c equations. boundary conditions may be
c dirichlet, neumann, or periodic.
c
c arguments
c
c on input iflg
c
c = 0 initialization only.
c certain quantities that depend on np,
c n, an, bn, and cn are computed and
c stored in the work array w.
c
c = 1 the quantities that were computed
c in the initialization are used
c to obtain the solution x(i,j).
c
c note:
c a call with iflg=0 takes
c approximately one half the time
c as a call with iflg = 1.
c however, the initialization does
c not have to be repeated unless np,
c n, an, bn, or cn change.
c
c np
c = 0 if an(1) and cn(n) are not zero,
c which corresponds to periodic
c bounary conditions.
c
c = 1 if an(1) and cn(n) are zero.
c
c n
c the number of unknowns in the j-direction.
c n must be greater than 4.
c the operation count is proportional to
c mnlog2(n), hence n should be selected
c less than or equal to m.
c
c an,bn,cn
c one-dimensional arrays of length n
c that specify the coefficients in the
c linear equations given above.
c
c mp
c = 0 if am(1) and cm(m) are not zero,
c which corresponds to periodic
c boundary conditions.
c
c = 1 if am(1) = cm(m) = 0 .
c
c m
c the number of unknowns in the i-direction.
c m must be greater than 4.
c
c am,bm,cm
c one-dimensional arrays of length m that
c specify the coefficients in the linear
c equations given above.
c
c idimy
c the row (or first) dimension of the
c two-dimensional array y as it appears
c in the program calling blktri.
c this parameter is used to specify the
c variable dimension of y.
c idimy must be at least m.
c
c y
c a two-dimensional array that specifies
c the values of the right side of the linear
c system of equations given above.
c y must be dimensioned at least m*n.
c
c w
c a one-dimensional array that must be
c provided by the user for work space.
c if np=1 define k=int(log2(n))+1 and
c set l=2**(k+1) then w must have dimension
c (k-2)*l+k+5+max(2n,6m)
c
c if np=0 define k=int(log2(n-1))+1 and
c set l=2**(k+1) then w must have dimension
c (k-2)*l+k+5+2n+max(2n,6m)
c
c **important**
c for purposes of checking, the required
c dimension of w is computed by blktri and
c stored in w(1) in floating point format.
c
c arguments
c
c on output y
c contains the solution x.
c
c ierror
c an error flag that indicates invalid
c input parameters. except for number zer0,
c a solution is not attempted.
c
c = 0 no error.
c = 1 m is less than 5
c = 2 n is less than 5
c = 3 idimy is less than m.
c = 4 blktri failed while computing results
c that depend on the coefficient arrays
c an, bn, cn. check these arrays.
c = 5 an(j)*cn(j-1) is less than 0 for some j.
c
c possible reasons for this condition are
c 1. the arrays an and cn are not correct
c 2. too large a grid spacing was used
c in the discretization of the elliptic
c equation.
c 3. the linear equations resulted from a
c partial differential equation which
c was not elliptic.
c
c w
c contains intermediate values that must
c not be destroyed if blktri will be called
c again with iflg=1. w(1) contains the
c number of locations required by w in
c floating point format.
c
c
c special conditions the algorithm may fail if abs(bm(i)+bn(j))
c is less than abs(am(i))+abs(an(j))+
c abs(cm(i))+abs(cn(j))
c for some i and j. the algorithm will also
c fail if an(j)*cn(j-1) is less than zero for
c some j.
c see the description of the output parameter
c ierror.
c
c i/o none
c
c precision single
c
c required library comf and q8qst4, which are automatically loaded
c files ncar's cray machines.
c
c language fortran
c
c history written by paul swarztrauber at ncar in the
c early 1970's. rewritten and released in
c january, 1980.
c
c algorithm generalized cyclic reduction
c
c portability fortran 66. approximate machine accuracy
c is computed in function epmach.
c
c references swarztrauber,p. and r. sweet, 'efficient
c fortran subprograms for the solution of
c elliptic equations'
c ncar tn/ia-109, july, 1975, 138 pp.
c
c swarztrauber p. n.,a direct method for
c the discrete solution of separable
c elliptic equations, s.i.a.m.
c j. numer. anal.,11(1974) pp. 1136-1150.
c***********************************************************************
IMPLICIT NONE
integer IDIMY
Dimension AN(1), BN(1), CN(1), AM(1), BM(1), CM(1), Y(IDIMY,1)
Dimension W(2)
External PROD, PRODP, CPROD, CPRODP
integer M, N, NP, MP
integer K, NM, NCMPLX, IK, NL
real*8 EPS, NPP, CNV
Common /CBLKT/ K, NM, NCMPLX, IK, NPP, CNV, EPS
real*8 AN, BN, CN, AM, BM, CM, Y, W
integer IERROR, NH, IWAH, IW1, IWBH, IW2, IW3, IWD, IWW, IWU
integer IFLG
c
c the following call is for monitoring library use at ncar
c
Logical Q8Q4
Save Q8Q4
Data Q8Q4 /.TRUE./
If (Q8Q4) Then
c call q8qst4('loclib','blktri','blktri','version 01')
Q8Q4 = .FALSE.
End If
c
c test m and n for the proper form
c
NM = N
IERROR = 0
If (M.LT.5) Then
IERROR = 1
Else
If (NM.LT.3) Then
IERROR = 2
Else
If (IDIMY.LT.M) Then
IERROR = 3
Else
NH = N
NPP = NP
If (NPP.NE.0) Then
NH = NH + 1
End If
IK = 2
K = 1
10 IK = IK + IK
K = K + 1
If (NH.GT.IK) Go To 10
NL = IK
IK = IK + IK
NL = NL - 1
IWAH = (K-2) * IK + K + 6
If (NPP.NE.0) Then
c
c divide w into working sub arrays
c
IW1 = IWAH
IWBH = IW1 + NM
W(1) = DBLE(IW1-1+DMAX1(2.d0*NM,6.d0*M))
Else
IWBH = IWAH + NM + NM
IW1 = IWBH
W(1) = DBLE(IW1-1+DMAX1(2.d0*NM,6.d0*M))
NM = NM - 1
End If
c
c subroutine comp b computes the roots of the b polynomials
c
If (IERROR.EQ.0) Then
IW2 = IW1 + M
IW3 = IW2 + M
IWD = IW3 + M
IWW = IWD + M
IWU = IWW + M
If (IFLG.EQ.0) Then
Call COMPB(NL,IERROR,AN,BN,CN,W(2),W(IWAH),W(IWBH))
Else
If (MP.NE.0) Then
c
c subroutine blktr1 solves the linear system
c
Call BLKTR1(NL,AN,BN,CN,M,AM,BM,CM,IDIMY,Y,W(2),
* W(IW1),W(IW2),W(IW3),W(IWD),W(IWW),W(IWU),1)
c Call BLKTR1(NL,AN,BN,CN,M,AM,BM,CM,IDIMY,Y,W(2),
c * W(IW1),W(IW2),W(IW3),W(IWD),W(IWW),W(IWU),PROD,
c * CPROD)
Else
c Call BLKTR1(NL,AN,BN,CN,M,AM,BM,CM,IDIMY,Y,W(2),
c * W(IW1),W(IW2),W(IW3),W(IWD),W(IWW),W(IWU),PRODP,
c * CPRODP)
Call BLKTR1(NL,AN,BN,CN,M,AM,BM,CM,IDIMY,Y,W(2),
* W(IW1),W(IW2),W(IW3),W(IWD),W(IWW),W(IWU),2)
End If
End If
End If
End If
End If
End If
Return
End
Subroutine BLKTR1(N,AN,BN,CN,M,AM,BM,CM,IDIMY,Y,B,W1,W2,W3,WD,WW,
c WU,PRDCT,CPRDCT)
* WU, PFLAG )
c
c blktr1 solves the linear system
c
c b contains the roots of all the b polynomials
c w1,w2,w3,wd,ww,wu are all working arrays
c prdct is either prodp or prod depending on whether the boundary
c conditions in the m direction are periodic or not
c cprdct is either cprodp or cprod which are the complex versions
c of prodp and prod. these are called in the event that some
c of the roots of the b sub p polynomial are complex
c
c If PFLAG==1, then use PROD and CPROD as callable functions.
c Otherwise use PRODP and CPRODP
c
IMPLICIT NONE
integer IDIMY
Dimension AN(1), BN(1), CN(1), AM(1), BM(1), CM(1), B(1), W1(1),
* W2(1), W3(1), WD(1), WW(1), WU(1), Y(IDIMY,1)
real*8 AN, BN, CN, AM, BM, CM, B, W1
real*8 W2, W3, WD, WW, WU, Y
real*8 DUM
integer M, N
integer PFLAG
integer K, NM, NCMPLX, IK
real*8 EPS, NPP, CNV
Common /CBLKT/ K, NM, NCMPLX, IK, NPP, CNV, EPS
integer I2,IR,IM2,NM2, I1, IRM1, IM3, NM3
integer I3, IM1, NM1, KDO, L, I4, IF,I, IPI1, IPI2, IPI3
integer NC, IDXA, IP2, NA, NP2, IP1, NP1, J, IP3, NP3
integer IZ, NZ, IDXC, IZR, LL, IFD, IP, NP, IMI1, IMI2
c
c Added this to avoid compiler warning on g77
c John Evans
Complex cbip, cw1, cw3, cww
c
c begin reduction phase
c
KDO = K - 1
Do 40 L = 1, KDO
IR = L - 1
I2 = 2 ** IR
I1 = I2 / 2
I3 = I2 + I1
I4 = I2 + I2
IRM1 = IR - 1
Call INDXB(I2,IR,IM2,NM2)
Call INDXB(I1,IRM1,IM3,NM3)
Call INDXB(I3,IRM1,IM1,NM1)
If (PFLAG.eq.1) Then
Call PROD(NM2,B(IM2),NM3,B(IM3),NM1,B(IM1),0,DUM,Y(1,I2),
* W3, M, AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NM2,B(IM2),NM3,B(IM3),NM1,B(IM1),0,DUM,Y(1,I2),
* W3,M,AM,BM,CM,WD,WW,WU)
End If
c
c Call PRDCT(NM2,B(IM2),NM3,B(IM3),NM1,B(IM1),0,DUM,Y(1,I2),W3,M,
c * AM,BM,CM,WD,WW,WU)
c
IF = 2 ** K
Do 30 I = I4, IF, I4
If (I.LE.NM) Then
IPI1 = I + I1
IPI2 = I + I2
IPI3 = I + I3
Call INDXC(I,IR,IDXC,NC)
If (I.LT.IF) Then
Call INDXA(I,IR,IDXA,NA)
Call INDXB(I-I1,IRM1,IM1,NM1)
Call INDXB(IPI2,IR,IP2,NP2)
Call INDXB(IPI1,IRM1,IP1,NP1)
Call INDXB(IPI3,IRM1,IP3,NP3)
c Call PRDCT(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),W3,W1,M,AM,
c * BM,CM,WD,WW,WU)
If (PFLAG .eq.1) Then
Call PROD(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),W3,W1,
* M,AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),W3,W1,
* M,AM,BM,CM,WD,WW,WU)
End If
If (IPI2.GT.NM) Then
Do 10 J = 1, M
W3(J) = 0.
W2(J) = 0.
10 Continue
Else
c Call PRDCT(NP2,B(IP2),NP1,B(IP1),NP3,B(IP3),0,DUM,
c * Y(1,IPI2),W3,M,AM,BM,CM,WD,WW,WU)
c Call PRDCT(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),W3,W2,M,
c * AM,BM,CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NP2,B(IP2),NP1,B(IP1),NP3,B(IP3),0,DUM,
* Y(1,IPI2),W3,M,AM,BM,CM,WD,WW,WU)
Call PROD(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),W3,
* W2,M,AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NP2,B(IP2),NP1,B(IP1),NP3,B(IP3),0,DUM,
* Y(1,IPI2),W3,M,AM,BM,CM,WD,WW,WU)
Call PRODP(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),W3,
* W2,M,AM,BM,CM,WD,WW,WU)
End If
End If
Do 20 J = 1, M
Y(J,I) = W1(J) + W2(J) + Y(J,I)
20 Continue
End If
End If
30 Continue
40 Continue
If (NPP.EQ.0) Then
c
c the periodic case is treated using the capacitance matrix method
c
IF = 2 ** K
I = IF / 2
I1 = I / 2
Call INDXB(I-I1,K-2,IM1,NM1)
Call INDXB(I+I1,K-2,IP1,NP1)
Call INDXB(I,K-1,IZ,NZ)
c Call PRDCT(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,Y(1,I),W1,M,AM,
c * BM,CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,Y(1,I),W1,
* M,AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,Y(1,I),
* W1,M,AM,BM,CM,WD,WW,WU)
End If
IZR = I
Do 50 J = 1, M
W2(J) = W1(J)
50 Continue
Do 70 LL = 2, K
L = K - LL + 1
IR = L - 1
I2 = 2 ** IR
I1 = I2 / 2
I = I2
Call INDXC(I,IR,IDXC,NC)
Call INDXB(I,IR,IZ,NZ)
Call INDXB(I-I1,IR-1,IM1,NM1)
Call INDXB(I+I1,IR-1,IP1,NP1)
c Call PRDCT(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),W1,W1,M,AM,BM,
c * CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),W1,W1,M,
* AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),W1,W1,
* M,AM,BM,CM,WD,WW,WU)
End If
Do 60 J = 1, M
W1(J) = Y(J,I) + W1(J)
60 Continue
c Call PRDCT(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,W1,W1,M,AM,BM,
c * CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,W1,W1,M,
* AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,W1,W1,
* M,AM,BM,CM,WD,WW,WU)
End If
70 Continue
Do 100 LL = 2, K
L = K - LL + 1
IR = L - 1
I2 = 2 ** IR
I1 = I2 / 2
I4 = I2 + I2
IFD = IF - I2
Do 90 I = I2, IFD, I4
If (I-I2-IZR.EQ.0) Then
If (I.GT.NM) Go To 100
Call INDXA(I,IR,IDXA,NA)
Call INDXB(I,IR,IZ,NZ)
Call INDXB(I-I1,IR-1,IM1,NM1)
Call INDXB(I+I1,IR-1,IP1,NP1)
c Call PRDCT(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),W2,W2,M,AM,
c * BM,CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),W2,W2,
* M,AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),W2,
* W2,M,AM,BM,CM,WD,WW,WU)
End If
Do 80 J = 1, M
W2(J) = Y(J,I) + W2(J)
80 Continue
c Call PRDCT(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,W2,W2,M,
c * AM,BM,CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,W2,
* W2,M,AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,
* W2,W2,M,AM,BM,CM,WD,WW,WU)
End If
IZR = I
If (I.EQ.NM) Go To 110
End If
90 Continue
100 Continue
110 Do 120 J = 1, M
Y(J,NM+1) = Y(J,NM+1) - CN(NM+1) * W1(J) - AN(NM+1) * W2(J)
120 Continue
Call INDXB(IF/2,K-1,IM1,NM1)
Call INDXB(IF,K-1,IP,NP)
If (NCMPLX.NE.0) Then
cbip = CMPLX ( B(IP) )
cw1 = CMPLX ( W1(1) )
cw3 = CMPLX ( W3(1) )
cww = CMPLX ( WW(1) )
c Call CPRDCT(NM+1,B(IP),NM1,B(IM1),0,DUM,0,DUM,Y(1,NM+1),
c * Y(1,NM+1),M,AM,BM,CM,W1,W3,WW)
If (PFLAG.eq.1) Then
Call CPROD(NM+1, cbip, NM1,B(IM1),0,DUM,0,DUM,
* Y(1,NM+1),Y(1,NM+1),M,AM,BM,CM, cw1, cw3, cww)
Else
Call CPRODP(NM+1,cbip,NM1,B(IM1),0,DUM,0,DUM,
* Y(1,NM+1),Y(1,NM+1),M,AM,BM,CM, cw1, cw3, cww)
End If
Else
c Call PRDCT(NM+1,B(IP),NM1,B(IM1),0,DUM,0,DUM,Y(1,NM+1),
c * Y(1,NM+1),M,AM,BM,CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NM+1,B(IP),NM1,B(IM1),0,DUM,0,DUM,Y(1,NM+1),
* Y(1,NM+1),M,AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NM+1,B(IP),NM1,B(IM1),0,DUM,0,DUM,Y(1,NM+1),
* Y(1,NM+1),M,AM,BM,CM,WD,WW,WU)
End If
End If
Do 130 J = 1, M
W1(J) = AN(1) * Y(J,NM+1)
W2(J) = CN(NM) * Y(J,NM+1)
Y(J,1) = Y(J,1) - W1(J)
Y(J,NM) = Y(J,NM) - W2(J)
130 Continue
Do 150 L = 1, KDO
IR = L - 1
I2 = 2 ** IR
I4 = I2 + I2
I1 = I2 / 2
I = I4
Call INDXA(I,IR,IDXA,NA)
Call INDXB(I-I2,IR,IM2,NM2)
Call INDXB(I-I2-I1,IR-1,IM3,NM3)
Call INDXB(I-I1,IR-1,IM1,NM1)
c Call PRDCT(NM2,B(IM2),NM3,B(IM3),NM1,B(IM1),0,DUM,W1,W1,M,AM,
c * BM,CM,WD,WW,WU)
c Call PRDCT(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),W1,W1,M,AM,BM,
c * CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NM2,B(IM2),NM3,B(IM3),NM1,B(IM1),0,DUM,W1,W1,
* M,AM,BM,CM,WD,WW,WU)
Call PROD(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),W1,W1,M,
* AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NM2,B(IM2),NM3,B(IM3),NM1,B(IM1),0,DUM,W1,
* W1,M,AM,BM,CM,WD,WW,WU)
Call PRODP(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),W1,W1,
* M,AM,BM,CM,WD,WW,WU)
End If
Do 140 J = 1, M
Y(J,I) = Y(J,I) - W1(J)
140 Continue
150 Continue
c
IZR = NM
Do 180 L = 1, KDO
IR = L - 1
I2 = 2 ** IR
I1 = I2 / 2
I3 = I2 + I1
I4 = I2 + I2
IRM1 = IR - 1
Do 170 I = I4, IF, I4
IPI1 = I + I1
IPI2 = I + I2
IPI3 = I + I3
If (IPI2.NE.IZR) Then
If (I-IZR) 170, 180, 170
End If
Call INDXC(I,IR,IDXC,NC)
Call INDXB(IPI2,IR,IP2,NP2)
Call INDXB(IPI1,IRM1,IP1,NP1)
Call INDXB(IPI3,IRM1,IP3,NP3)
c Call PRDCT(NP2,B(IP2),NP1,B(IP1),NP3,B(IP3),0,DUM,W2,W2,M,
c * AM,BM,CM,WD,WW,WU)
c Call PRDCT(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),W2,W2,M,AM,BM,
c * CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NP2,B(IP2),NP1,B(IP1),NP3,B(IP3),0,DUM,W2,
* W2,M,AM,BM,CM,WD,WW,WU)
Call PROD(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),W2,W2,M,
* AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NP2,B(IP2),NP1,B(IP1),NP3,B(IP3),0,DUM,W2,
* W2,M,AM,BM,CM,WD,WW,WU)
Call PRODP(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),W2,W2,M,
* AM,BM,CM,WD,WW,WU)
End If
Do 160 J = 1, M
Y(J,I) = Y(J,I) - W2(J)
160 Continue
IZR = I
Go To 180
170 Continue
180 Continue
End If
c
c begin back substitution phase
c
Do 230 LL = 1, K
L = K - LL + 1
IR = L - 1
IRM1 = IR - 1
I2 = 2 ** IR
I1 = I2 / 2
I4 = I2 + I2
IFD = IF - I2
Do 220 I = I2, IFD, I4
If (I.LE.NM) Then
IMI1 = I - I1
IMI2 = I - I2
IPI1 = I + I1
IPI2 = I + I2
Call INDXA(I,IR,IDXA,NA)
Call INDXC(I,IR,IDXC,NC)
Call INDXB(I,IR,IZ,NZ)
Call INDXB(IMI1,IRM1,IM1,NM1)
Call INDXB(IPI1,IRM1,IP1,NP1)
If (I.LE.I2) Then
Do 190 J = 1, M
W1(J) = 0.
190 Continue
Else
c Call PRDCT(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),Y(1,IMI2),
c * W1,M,AM,BM,CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),
* Y(1,IMI2),W1,M,AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NM1,B(IM1),0,DUM,0,DUM,NA,AN(IDXA),
* Y(1,IMI2),W1,M,AM,BM,CM,WD,WW,WU)
End If
End If
If (IPI2.GT.NM) Then
Do 200 J = 1, M
W2(J) = 0.
200 Continue
Else
c Call PRDCT(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),Y(1,IPI2),
c * W2,M,AM,BM,CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),
* Y(1,IPI2),W2,M,AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NP1,B(IP1),0,DUM,0,DUM,NC,CN(IDXC),
* Y(1,IPI2),W2,M,AM,BM,CM,WD,WW,WU)
End If
End If
Do 210 J = 1, M
W1(J) = Y(J,I) + W1(J) + W2(J)
210 Continue
c Call PRDCT(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,W1,Y(1,I),M,
c * AM,BM,CM,WD,WW,WU)
If (PFLAG.eq.1) Then
Call PROD(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,W1,
* Y(1,I),M,AM,BM,CM,WD,WW,WU)
Else
Call PRODP(NZ,B(IZ),NM1,B(IM1),NP1,B(IP1),0,DUM,W1,
* Y(1,I),M,AM,BM,CM,WD,WW,WU)
End If
End If
220 Continue
230 Continue
Return
End
Subroutine INDXB(I,IR,IDX,IDP)
c
c b(idx) is the location of the first root of the b(i,ir) polynomial
c
IMPLICIT NONE
integer IDP, IDX, I, IR
integer IZH, ID, IPL
integer K, NM, NCMPLX, IK
real*8 EPS, NPP, CNV
Common /CBLKT/ K, NM, NCMPLX, IK, NPP, CNV, EPS
IDP = 0
If (IR) 30, 10, 20
10 If (I.GT.NM) Go To 30
IDX = I
IDP = 1
Return
20 IZH = 2 ** IR
ID = I - IZH - IZH
IDX = ID + ID + (IR-1) * IK + IR + (IK-I) / IZH + 4
IPL = IZH - 1
IDP = IZH + IZH - 1
If (I-IPL-NM.GT.0) Then
IDP = 0
Return
End If
If (I+IPL-NM.GT.0) Then
IDP = NM + IPL - I + 1
End If
30 Return
End
Subroutine INDXA(I,IR,IDXA,NA)
IMPLICIT NONE
integer K, NM, NCMPLX, IK
real*8 EPS, NPP, CNV
Common /CBLKT/ K, NM, NCMPLX, IK, NPP, CNV, EPS
integer NA, IDXA, I, IR
NA = 2 ** IR
IDXA = I - NA + 1
If (I.GT.NM) Then
NA = 0
End If
Return
End
Subroutine INDXC(I,IR,IDXC,NC)
IMPLICIT NONE
integer K, NM, NCMPLX, IK, NC, IR, I, IDXC
real*8 EPS, NPP, CNV
Common /CBLKT/ K, NM, NCMPLX, IK, NPP, CNV, EPS
NC = 2 ** IR
IDXC = I
If (IDXC+NC-1-NM.GT.0) Then
NC = 0
End If
Return
End
Subroutine PROD(ND,BD,NM1,BM1,NM2,BM2,NA,AA,X,Y,M,A,B,C,D,W,U)
c
c prod applies a sequence of matrix operations to the vector x and
c stores the result in y
c bd,bm1,bm2 are arrays containing roots of certian b polynomials
c nd,nm1,nm2 are the lengths of the arrays bd,bm1,bm2 respectively
c aa array containing scalar multipliers of the vector x
c na is the length of the array aa
c x,y the matrix operations are applied to x and the result is y
c a,b,c are arrays which contain the tridiagonal matrix
c m is the order of the matrix
c d,w,u are working arrays
c is determines whether or not a change in sign is made
c
IMPLICIT NONE
Dimension A(1), B(1), C(1), X(1), Y(1), D(2), W(2), BD(1),
* BM1(1), BM2(1), AA(1), U(1)
real*8 bd,bm1, bm2, aa, a, b, c, d, u, w, x, y, rt
real*8 den
integer nd, nm1, nm2, na, m, j, mm, id, ibr, m1, m2, ia
integer k
Do 10 J = 1, M
W(J) = X(J)
Y(J) = W(J)
10 Continue
MM = M - 1
ID = ND
IBR = 0
M1 = NM1
M2 = NM2
IA = NA
20 If (IA.GT.0) Then
RT = AA(IA)
If (ND.EQ.0) RT = -RT
IA = IA - 1
c
c scalar multiplication
c
Do 30 J = 1, M
Y(J) = RT * W(J)
30 Continue
End If
If (ID.GT.0) Then
RT = BD(ID)
ID = ID - 1
If (ID.EQ.0) IBR = 1
c
c begin solution to system
c
D(M) = A(M) / (B(M)-RT)
W(M) = Y(M) / (B(M)-RT)
Do 40 J = 2, MM
K = M - J
DEN = B(K+1) - RT - C(K+1) * D(K+2)
D(K+1) = A(K+1) / DEN
W(K+1) = (Y(K+1)-C(K+1)*W(K+2)) / DEN
40 Continue
DEN = B(1) - RT - C(1) * D(2)
W(1) = 1.
If (DEN.NE.0) Then
W(1) = (Y(1)-C(1)*W(2)) / DEN
End If
Do 50 J = 2, M
W(J) = W(J) - D(J) * W(J-1)
50 Continue
If (NA) 80, 80, 20
60 Do 70 J = 1, M
Y(J) = W(J)
70 Continue
IBR = 1
Go To 20
80 If (M1.LE.0) Then
If (M2) 60, 60, 90
End If
If (M2.GT.0) Then
If (ABS(BM1(M1)).LE.ABS(BM2(M2))) Go To 90
End If
If (IBR.LE.0) Then
If (ABS(BM1(M1)-BD(ID)).LT.ABS(BM1(M1)-RT)) Go To 60
End If
RT = RT - BM1(M1)
M1 = M1 - 1
Go To 100
90 If (IBR.LE.0) Then
If (ABS(BM2(M2)-BD(ID)).LT.ABS(BM2(M2)-RT)) Go To 60
End If
RT = RT - BM2(M2)
M2 = M2 - 1
100 Do 110 J = 1, M
Y(J) = Y(J) + RT * W(J)
110 Continue
Go To 20
End If
Return
End
Subroutine PRODP(ND,BD,NM1,BM1,NM2,BM2,NA,AA,X,Y,M,A,B,C,D,U,W)
c
c prodp applies a sequence of matrix operations to the vector x and
c stores the result in y periodic boundary conditions
c
c bd,bm1,bm2 are arrays containing roots of certian b polynomials
c nd,nm1,nm2 are the lengths of the arrays bd,bm1,bm2 respectively
c aa array containing scalar multipliers of the vector x
c na is the length of the array aa
c x,y the matrix operations are applied to x and the result is y
c a,b,c are arrays which contain the tridiagonal matrix
c m is the order of the matrix
c d,u,w are working arrays
c is determines whether or not a change in sign is made
c
IMPLICIT NONE
Dimension A(1), B(1), C(1), X(1), Y(1), D(1), U(1), BD(1),
* BM1(1), BM2(1), AA(1), W(1)
real*8 bd,bm1, bm2, aa, a, b, c, d, u, w, x, y, rt, bh, ym, v
real*8 den, am
integer nd, nm1, nm2, na, m, j, mm, mm2, id, ibr, m1, m2, ia
integer k
Do 10 J = 1, M
Y(J) = X(J)
W(J) = Y(J)
10 Continue
MM = M - 1
MM2 = M - 2
ID = ND
IBR = 0
M1 = NM1
M2 = NM2
IA = NA
20 If (IA.GT.0) Then
RT = AA(IA)
If (ND.EQ.0) RT = -RT
IA = IA - 1
Do 30 J = 1, M
Y(J) = RT * W(J)
30 Continue
End If
If (ID.GT.0) Then
RT = BD(ID)
ID = ID - 1
If (ID.EQ.0) IBR = 1
c
c begin solution to system
c
BH = B(M) - RT
YM = Y(M)
DEN = B(1) - RT
D(1) = C(1) / DEN
U(1) = A(1) / DEN
W(1) = Y(1) / DEN
V = C(M)
If (MM2.GE.2) Then
Do 40 J = 2, MM2
DEN = B(J) - RT - A(J) * D(J-1)
D(J) = C(J) / DEN
U(J) = -A(J) * U(J-1) / DEN
W(J) = (Y(J)-A(J)*W(J-1)) / DEN
BH = BH - V * U(J-1)
YM = YM - V * W(J-1)
V = -V * D(J-1)
40 Continue
End If
DEN = B(M-1) - RT - A(M-1) * D(M-2)
D(M-1) = (C(M-1)-A(M-1)*U(M-2)) / DEN
W(M-1) = (Y(M-1)-A(M-1)*W(M-2)) / DEN
AM = A(M) - V * D(M-2)
BH = BH - V * U(M-2)
YM = YM - V * W(M-2)
DEN = BH - AM * D(M-1)
If (DEN.NE.0) Then
W(M) = (YM-AM*W(M-1)) / DEN
Else
W(M) = 1.
End If
W(M-1) = W(M-1) - D(M-1) * W(M)
Do 50 J = 2, MM
K = M - J
W(K) = W(K) - D(K) * W(K+1) - U(K) * W(M)
50 Continue
If (NA) 80, 80, 20
60 Do 70 J = 1, M
Y(J) = W(J)
70 Continue
IBR = 1
Go To 20
80 If (M1.LE.0) Then
If (M2) 60, 60, 90
End If
If (M2.GT.0) Then
If (ABS(BM1(M1)).LE.ABS(BM2(M2))) Go To 90
End If
If (IBR.LE.0) Then
If (ABS(BM1(M1)-BD(ID)).LT.ABS(BM1(M1)-RT)) Go To 60
End If
RT = RT - BM1(M1)
M1 = M1 - 1
Go To 100
90 If (IBR.LE.0) Then
If (ABS(BM2(M2)-BD(ID)).LT.ABS(BM2(M2)-RT)) Go To 60
End If
RT = RT - BM2(M2)
M2 = M2 - 1
100 Do 110 J = 1, M
Y(J) = Y(J) + RT * W(J)
110 Continue
Go To 20
End If
Return
End
Subroutine CPROD(ND,BD,NM1,BM1,NM2,BM2,NA,AA,X,YY,M,A,B,C,D,W,Y)
c
c prod applies a sequence of matrix operations to the vector x and
c stores the result in yy (complex case)
c aa array containing scalar multipliers of the vector x
c nd,nm1,nm2 are the lengths of the arrays bd,bm1,bm2 respectively
c bd,bm1,bm2 are arrays containing roots of certian b polynomials
c na is the length of the array aa
c x,yy the matrix operations are applied to x and the result is yy
c a,b,c are arrays which contain the tridiagonal matrix
c m is the order of the matrix
c d,w,y are working arrays
c isgn determines whether or not a change in sign is made
c
IMPLICIT NONE
Complex Y, D, W, BD, CRT, DEN, Y1, Y2
Dimension A(1), B(1), C(1), X(1), Y(2), D(2), W(2), BD(1),
* BM1(1), BM2(1), AA(1), YY(1)
integer J, M, MM, ND, NM1, NM2, ID, M1, M2, IA
integer NA, IFLG, K
real*8 BM1, BM2, AA, X, YY, A, B, C, RT
Do 10 J = 1, M
Y(J) = DCMPLX(X(J),0.d0)
10 Continue
MM = M - 1
ID = ND
M1 = NM1
M2 = NM2
IA = NA
20 IFLG = 0
If (ID.GT.0) Then
CRT = BD(ID)
ID = ID - 1
c
c begin solution to system
c
D(M) = A(M) / (B(M)-CRT)
W(M) = Y(M) / (B(M)-CRT)
Do 30 J = 2, MM
K = M - J
DEN = B(K+1) - CRT - C(K+1) * D(K+2)
D(K+1) = A(K+1) / DEN
W(K+1) = (Y(K+1)-C(K+1)*W(K+2)) / DEN
30 Continue
DEN = B(1) - CRT - C(1) * D(2)
If (CABS(DEN).NE.0) Then
Y(1) = (Y(1)-C(1)*W(2)) / DEN
Else
Y(1) = (1.,0.)
End If
Do 40 J = 2, M
Y(J) = W(J) - D(J) * Y(J-1)
40 Continue
End If
If (M1.LE.0) Then
If (M2.LE.0) Go To 60
RT = BM2(M2)
M2 = M2 - 1
Else
If (M2.LE.0) Then
RT = BM1(M1)
M1 = M1 - 1
Else
If (ABS(BM1(M1)).GT.ABS(BM2(M2))) Then
RT = BM1(M1)
M1 = M1 - 1
Else
RT = BM2(M2)
M2 = M2 - 1
End If
End If
End If
Y1 = (B(1)-RT) * Y(1) + C(1) * Y(2)
If (MM.GE.2) Then
c
c matrix multiplication
c
Do 50 J = 2, MM
Y2 = A(J) * Y(J-1) + (B(J)-RT) * Y(J) + C(J) * Y(J+1)
Y(J-1) = Y1
Y1 = Y2
50 Continue
End If
Y(M) = A(M) * Y(M-1) + (B(M)-RT) * Y(M)
Y(M-1) = Y1
IFLG = 1
Go To 20
60 If (IA.GT.0) Then
RT = AA(IA)
IA = IA - 1
IFLG = 1
c
c scalar multiplication
c
Do 70 J = 1, M
Y(J) = RT * Y(J)
70 Continue
End If
If (IFLG.GT.0) Go To 20
Do 80 J = 1, M
YY(J) = REAL(Y(J))
80 Continue
Return
End
Subroutine CPRODP(ND,BD,NM1,BM1,NM2,BM2,NA,AA,X,YY,M,A,B,C,D,U,Y)
c
c prodp applies a sequence of matrix operations to the vector x and
c stores the result in yy periodic boundary conditions
c and complex case
c
c bd,bm1,bm2 are arrays containing roots of certian b polynomials
c nd,nm1,nm2 are the lengths of the arrays bd,bm1,bm2 respectively
c aa array containing scalar multipliers of the vector x
c na is the length of the array aa
c x,yy the matrix operations are applied to x and the result is yy
c a,b,c are arrays which contain the tridiagonal matrix
c m is the order of the matrix
c d,u,y are working arrays
c isgn determines whether or not a change in sign is made
c
IMPLICIT NONE
Complex Y, D, U, V, DEN, BH, YM, AM, Y1, Y2, YH, BD, CRT
Dimension A(1), B(1), C(1), X(1), Y(2), D(1), U(1), BD(1),
* BM1(1), BM2(1), AA(1), YY(1)
integer J, M, MM, MM2, ND, NM1, NM2, ID, M1, M2, IA
integer NA, IFLG, K
real*8 BM1, BM2, AA, X, YY, A, B, C, RT
Do 10 J = 1, M
Y(J) = DCMPLX(X(J),0.d0)
10 Continue
MM = M - 1
MM2 = M - 2
ID = ND
M1 = NM1
M2 = NM2
IA = NA
20 IFLG = 0
If (ID.GT.0) Then
CRT = BD(ID)
ID = ID - 1
IFLG = 1
c
c begin solution to system
c
BH = B(M) - CRT
YM = Y(M)
DEN = B(1) - CRT
D(1) = C(1) / DEN
U(1) = A(1) / DEN
Y(1) = Y(1) / DEN
V = DCMPLX(C(M),0.d0)
If (MM2.GE.2) Then
Do 30 J = 2, MM2
DEN = B(J) - CRT - A(J) * D(J-1)
D(J) = C(J) / DEN
U(J) = -A(J) * U(J-1) / DEN
Y(J) = (Y(J)-A(J)*Y(J-1)) / DEN
BH = BH - V * U(J-1)
YM = YM - V * Y(J-1)
V = -V * D(J-1)
30 Continue
End If
DEN = B(M-1) - CRT - A(M-1) * D(M-2)
D(M-1) = (C(M-1)-A(M-1)*U(M-2)) / DEN
Y(M-1) = (Y(M-1)-A(M-1)*Y(M-2)) / DEN
AM = A(M) - V * D(M-2)
BH = BH - V * U(M-2)
YM = YM - V * Y(M-2)
DEN = BH - AM * D(M-1)
If (CABS(DEN).NE.0) Then
Y(M) = (YM-AM*Y(M-1)) / DEN
Else
Y(M) = (1.,0.)
End If
Y(M-1) = Y(M-1) - D(M-1) * Y(M)
Do 40 J = 2, MM
K = M - J
Y(K) = Y(K) - D(K) * Y(K+1) - U(K) * Y(M)
40 Continue
End If
If (M1.LE.0) Then
If (M2.LE.0) Go To 60
RT = BM2(M2)
M2 = M2 - 1
Else
If (M2.LE.0) Then
RT = BM1(M1)
M1 = M1 - 1
Else
If (DABS(BM1(M1)).GT.DABS(BM2(M2))) Then
RT = BM1(M1)
M1 = M1 - 1
Else
RT = BM2(M2)
M2 = M2 - 1
End If
End If
End If
c
c matrix multiplication
c
YH = Y(1)
Y1 = (B(1)-RT) * Y(1) + C(1) * Y(2) + A(1) * Y(M)
If (MM.GE.2) Then
Do 50 J = 2, MM
Y2 = A(J) * Y(J-1) + (B(J)-RT) * Y(J) + C(J) * Y(J+1)
Y(J-1) = Y1
Y1 = Y2
50 Continue
End If
Y(M) = A(M) * Y(M-1) + (B(M)-RT) * Y(M) + C(M) * YH
Y(M-1) = Y1
IFLG = 1
Go To 20
60 If (IA.GT.0) Then
RT = AA(IA)
IA = IA - 1
IFLG = 1
c
c scalar multiplication
c
Do 70 J = 1, M
Y(J) = RT * Y(J)
70 Continue
End If
If (IFLG.GT.0) Go To 20
Do 80 J = 1, M
YY(J) = REAL(Y(J))
80 Continue
Return
End
Subroutine PPADD(N,IERROR,A,C,CBP,BP,BH)
c
c ppadd computes the eigenvalues of the periodic tridiagonal matrix
c with coefficients an,bn,cn
c
c n is the order of the bh and bp polynomials
c on output bp contians the eigenvalues
c cbp is the same as bp except type complex
c bh is used to temporarily store the roots of the b hat polynomial
c which enters through bp
c
IMPLICIT NONE
DOUBLE Complex CX, FSG, HSG, DD
DOUBLE Complex F, FP, FPP, CDIS, R1, R2, R3, CBP
Dimension A(1), C(1), BP(1), BH(3), CBP(1)
real*8 A, C, BP, BH
real*8 XR, XM
real*8 SGN
integer K, NM, NCMPLX, IK
real*8 EPS, NPP, XL, CNV
Common /CBLKT/ K, NM, NCMPLX, IK, NPP, CNV, EPS
real*8 PSGF, PPSPF, PPSGF
External PSGF, PPSPF, PPSGF
real*8 SCNV, DB, BSRH, PSG
integer IZ, N, IZM, IZM2, J, NT, MODIZ, IS, IF, IG, IT, ICV, I2
integer I3, NHALF, IERROR
SCNV = DSQRT(CNV)
IZ = N
IZM = IZ - 1
IZM2 = IZ - 2
If (BP(N)-BP(1)) 10, 240, 30
10 Do 20 J = 1, N
NT = N - J
BH(J) = BP(NT+1)
20 Continue
Go To 50
30 Do 40 J = 1, N
BH(J) = BP(J)
40 Continue
50 NCMPLX = 0
MODIZ = MOD(IZ,2)
IS = 1
If (MODIZ.NE.0) Then
If (A(1)) 80, 240, 60
End If
60 XL = BH(1)
DB = BH(3) - BH(1)
70 XL = XL - DB
If (PSGF(XL,IZ,C,A,BH).LE.0) Go To 70
SGN = -1.
CBP(1) = DCMPLX(BSRH(XL,BH(1),IZ,C,A,BH,PSGF,SGN),0.d0)
IS = 2
80 IF = IZ - 1
If (MODIZ.NE.0) Then
If (A(1)) 90, 240, 110
End If
90 XR = BH(IZ)
DB = BH(IZ) - BH(IZ-2)
100 XR = XR + DB
If (PSGF(XR,IZ,C,A,BH).LT.0) Go To 100
SGN = 1.
CBP(IZ) = DCMPLX(BSRH(BH(IZ),XR,IZ,C,A,BH,PSGF,SGN),0.d0)
IF = IZ - 2
110 Do 180 IG = IS, IF, 2
XL = BH(IG)
XR = BH(IG+1)
SGN = -1.
XM = BSRH(XL,XR,IZ,C,A,BH,PPSPF,SGN)
PSG = PSGF(XM,IZ,C,A,BH)
If (ABS(PSG).GT.EPS) Then
If (PSG*PPSGF(XM,IZ,C,A,BH)) 120, 130, 140
c
c case of a real zero
c
120 SGN = 1.
CBP(IG) = DCMPLX(BSRH(BH(IG),XM,IZ,C,A,BH,PSGF,SGN),0.d0)
SGN = -1.
CBP(IG+1) = DCMPLX(BSRH(XM,BH(IG+1),IZ,C,A,BH,PSGF,SGN),0.d0)
Go To 180
End If
c
c case of a multiple zero
c
130 CBP(IG) = DCMPLX(XM,0.d0)
CBP(IG+1) = DCMPLX(XM,0.d0)
Go To 180
c
c case of a complex zero
c
140 IT = 0
ICV = 0
CX = DCMPLX(XM,0.d0)
150 FSG = (1.,0.)
HSG = (1.,0.)
FP = (0.,0.)
FPP = (0.,0.)
Do 160 J = 1, IZ
DD = 1. / (CX-BH(J))
FSG = FSG * A(J) * DD
HSG = HSG * C(J) * DD
FP = FP + DD
FPP = FPP - DD * DD
160 Continue
If (MODIZ.EQ.0) Then
F = (1.,0.) - FSG - HSG
Else
F = (1.,0.) + FSG + HSG
End If
I3 = 0
If (CDABS(FP).GT.0) Then
I3 = 1
R3 = -F / FP
End If
I2 = 0
If (CDABS(FPP).GT.0) Then
I2 = 1
CDIS = CDSQRT(FP**2-2.*F*FPP)
R1 = CDIS - FP
R2 = -FP - CDIS
If (CDABS(R1).GT.CDABS(R2)) Then
R1 = R1 / FPP
Else
R1 = R2 / FPP
End If
R2 = 2. * F / FPP / R1
If (CDABS(R2).LT.CDABS(R1)) R1 = R2
If (I3.LE.0) Go To 170
If (CDABS(R3).LT.CDABS(R1)) R1 = R3
Else
R1 = R3
End If
170 CX = CX + R1
IT = IT + 1
If (IT.GT.50) Go To 240
If (CDABS(R1).GT.SCNV) Go To 150
If (ICV.LE.0) Then
ICV = 1
Go To 150
End If
CBP(IG) = CX
CBP(IG+1) = CONJG(CX)
180 Continue
If (CDABS(CBP(N))-CDABS(CBP(1))) 190, 240, 210
190 NHALF = N / 2
Do 200 J = 1, NHALF
NT = N - J
CX = CBP(J)
CBP(J) = CBP(NT+1)
CBP(NT+1) = CX
200 Continue
210 NCMPLX = 1
Do 220 J = 2, IZ
If (DIMAG(CBP(J)).NE.0) Go To 250
220 Continue
NCMPLX = 0
Do 230 J = 2, IZ
BP(J) = DREAL(CBP(J))
230 Continue
Go To 250
240 IERROR = 4
250 Continue
Return
End
Function PSGF(X,IZ,C,A,BH)
IMPLICIT NONE
DOUBLE PRECISION PSGF
Dimension A(1), C(1), BH(1)
real*8 A, X, C, BH
integer IZ
real*8 FSG, HSG, DD
integer J
FSG = 1.
HSG = 1.
Do 10 J = 1, IZ
DD = 1. / (X-BH(J))
FSG = FSG * A(J) * DD
HSG = HSG * C(J) * DD
10 Continue
If (MOD(IZ,2).EQ.0) Then
PSGF = 1. - FSG - HSG
Return
End If
PSGF = 1. + FSG + HSG
Return
End
Function BSRH(XLL,XRR,IZ,C,A,BH,F,SGN)
IMPLICIT NONE
DOUBLE PRECISION BSRH
DOUBLE PRECISION F
Dimension A(1), C(1), BH(1)
real*8 XLL, XRR, A, C, BH, SGN
integer IZ
integer K, NM, NCMPLX, IK
real*8 EPS, NPP, XL, CNV
Common /CBLKT/ K, NM, NCMPLX, IK, NPP, CNV, EPS
real*8 DX, X, XR
XL = XLL
XR = XRR
DX = .5 * ABS(XR-XL)
10 X = .5 * (XL+XR)
If (SGN*F(X,IZ,C,A,BH)) 30, 50, 20
20 XR = X
Go To 40
30 XL = X
40 DX = .5 * DX
If (DX.GT.CNV) Go To 10
50 BSRH = .5 * (XL+XR)
Return
End
Function PPSGF(X,IZ,C,A,BH)
IMPLICIT NONE
real*8 PPSGF
Dimension A(1), C(1), BH(1)
real*8 A, C, BH, X
integer J, IZ
real*8 SUM
SUM = 0.
Do 10 J = 1, IZ
SUM = SUM - 1. / (X-BH(J)) ** 2
10 Continue
PPSGF = SUM
Return
End
Function PPSPF(X,IZ,C,A,BH)
IMPLICIT NONE
real*8 PPSPF
Dimension A(1), C(1), BH(1)
real*8 SUM, A, C, BH, X
integer J, IZ
SUM = 0.
Do 10 J = 1, IZ
SUM = SUM + 1. / (X-BH(J))
10 Continue
PPSPF = SUM
Return
End
Subroutine COMPB(N,IERROR,AN,BN,CN,B,AH,BH)
c
c compb computes the roots of the b polynomials using subroutine
c tevls which is a modification the eispack program tqlrat.
c ierror is set to 4 if either tevls fails or if a(j+1)*c(j) is
c less than zero for some j. ah,bh are temporary work arrays.
c
IMPLICIT NONE
Dimension AN(1), BN(1), CN(1), B(1), AH(1), BH(1)
real*8 AN, BN, CN, B, AH, BH
integer N, IERROR
real*8 BNORM, EPMACH
integer J, K, NM, NCMPLX, IK, DUM, IF, KDO, L, IR, I2, I4, IPL
integer IFD, I, IB, NB, JS, JF, LS, LH, NMP, L1, L2, J2, J1, N2M2
real*8 EPS, NPP, CNV, ARG, D1, D2, D3
Common /CBLKT/ K, NM, NCMPLX, IK, NPP, CNV, EPS
EPS = EPMACH(DUM)
BNORM = DABS(BN(1))
Do 10 J = 2, NM
BNORM = DMAX1(BNORM,DABS(BN(J)))
ARG = AN(J) * CN(J-1)
If (ARG.LT.0) Go To 110
B(J) = SIGN(SQRT(ARG),AN(J))
10 Continue
CNV = EPS * BNORM
IF = 2 ** K
KDO = K - 1
Do 50 L = 1, KDO
IR = L - 1
I2 = 2 ** IR
I4 = I2 + I2
IPL = I4 - 1
IFD = IF - I4
Do 40 I = I4, IFD, I4
Call INDXB(I,L,IB,NB)
If (NB.LE.0) Go To 50
JS = I - IPL
JF = JS + NB - 1
LS = 0
Do 20 J = JS, JF
LS = LS + 1
BH(LS) = BN(J)
AH(LS) = B(J)
20 Continue
Call TEVLS(NB,BH,AH,IERROR)
If (IERROR.NE.0) Go To 100
LH = IB - 1
Do 30 J = 1, NB
LH = LH + 1
B(LH) = -BH(J)
30 Continue
40 Continue
50 Continue
Do 60 J = 1, NM
B(J) = -BN(J)
60 Continue
If (NPP.EQ.0) Then
NMP = NM + 1
NB = NM + NMP
Do 70 J = 1, NB
L1 = MOD(J-1,NMP) + 1
L2 = MOD(J+NM-1,NMP) + 1
ARG = AN(L1) * CN(L2)
If (ARG.LT.0) Go To 110
BH(J) = SIGN(SQRT(ARG),-AN(L1))
AH(J) = -BN(L1)
70 Continue
Call TEVLS(NB,AH,BH,IERROR)
If (IERROR.NE.0) Go To 100
Call INDXB(IF,K-1,J2,LH)
Call INDXB(IF/2,K-1,J1,LH)
J2 = J2 + 1
LH = J2
N2M2 = J2 + NM + NM - 2
80 D1 = DABS(B(J1)-B(J2-1))
D2 = DABS(B(J1)-B(J2))
D3 = DABS(B(J1)-B(J2+1))
If (.NOT.((D2.LT.D1).AND.(D2.LT.D3))) Then
B(LH) = B(J2)
J2 = J2 + 1
LH = LH + 1
If (J2-N2M2) 80, 80, 90
End If
J2 = J2 + 1
J1 = J1 + 1
If (J2.LE.N2M2) Go To 80
90 B(LH) = B(N2M2+1)
Call INDXB(IF,K-1,J1,J2)
J2 = J1 + NMP + NMP
Call PPADD(NM+1,IERROR,AN,CN,B(J1),B(J1),B(J2))
End If
Return
100 IERROR = 4
Return
110 IERROR = 5
Return
End
Subroutine TEVLS(N,D,E2,IERR)
c
IMPLICIT NONE
Integer I, J, L, M, N, II, L1, MML, IERR
Real*8 D(N), E2(N)
Real*8 B, C, F, G, H, P, R, S
c
c real sqrt,abs,sign
c
integer K, NM, NCMPLX, IK, NHALF, NTOP
real*8 MACHEP, NPP, CNV, DHOLD
Common /CBLKT/ K, NM, NCMPLX, IK, NPP, CNV, MACHEP
c
c this subroutine is a modification of the eispack subroutine tqlrat
c algorithm 464, comm. acm 16, 689(1973) by reinsch.
c
c this subroutine finds the eigenvalues of a symmetric
c tridiagonal matrix by the rational ql method.
c
c on input-
c
c n is the order of the matrix,
c
c d contains the diagonal elements of the input matrix,
c
c e2 contains the subdiagonal elements of the
c input matrix in its last n-1 positions. e2(1) is arbitrary.
c
c on output-
c
c d contains the eigenvalues in ascending order. if an
c error exit is made, the eigenvalues are correct and
c ordered for indices 1,2,...ierr-1, but may not be
c the smallest eigenvalues,
c
c e2 has been destroyed,
c
c ierr is set to
c zero for normal return,
c j if the j-th eigenvalue has not been
c determined after 30 iterations.
c
c questions and comments should be directed to b. s. garbow,
c applied mathematics division, argonne national laboratory
c
c
c ********** machep is a machine dependent parameter specifying
c the relative precision of floating point arithmetic.
c
c **********
c
IERR = 0
If (N.NE.1) Then
c
Do 10 I = 2, N
E2(I-1) = E2(I) * E2(I)
10 Continue
c
F = 0.0
B = 0.0
E2(N) = 0.0
c
Do 90 L = 1, N
J = 0
H = MACHEP * (DABS(D(L))+DSQRT(E2(L)))
If (B.LE.H) Then
B = H
C = B * B
End If
c
c ********** look for small squared sub-diagonal element **********
c
Do 20 M = L, N
If (E2(M).LE.C) Go To 30
c
c ********** e2(n) is always zero, so there is no exit
c through the bottom of the loop **********
c
20 Continue
c
30 If (M.NE.L) Then
40 If (J.EQ.30) Go To 110
J = J + 1
c
c ********** form shift **********
c
L1 = L + 1
S = SQRT(E2(L))
G = D(L)
P = (D(L1)-G) / (2.0*S)
R = SQRT(P*P+1.0)
D(L) = S / (P+SIGN(R,P))
H = G - D(L)
c
Do 50 I = L1, N
D(I) = D(I) - H
50 Continue
c
F = F + H
c
c ********** rational ql transformation **********
c
G = D(M)
If (G.EQ.0.0) G = B
H = G
S = 0.0
MML = M - L
c
c ********** for i=m-1 step -1 until l do -- **********
c
Do 60 II = 1, MML
I = M - II
P = G * H
R = P + E2(I)
E2(I+1) = S * R
S = E2(I) / R
D(I+1) = H + S * (H+D(I))
G = D(I) - E2(I) / G
If (G.EQ.0.0) G = B
H = G * P / R
60 Continue
c
E2(L) = S * G
D(L) = H
c
c ********** guard against underflowed h **********
c
If (H.NE.0.0) Then
If (ABS(E2(L)).GT.ABS(C/H)) Then
E2(L) = H * E2(L)
If (E2(L).NE.0.0) Go To 40
End If
End If
End If
P = D(L) + F
c
c ********** order eigenvalues **********
c
If (L.NE.1) Then
c
c ********** for i=l step -1 until 2 do -- **********
c
Do 70 II = 2, L
I = L + 2 - II
If (P.GE.D(I-1)) Go To 80
D(I) = D(I-1)
70 Continue
End If
c
I = 1
80 D(I) = P
90 Continue
c
If (ABS(D(N)).GE.ABS(D(1))) Go To 120
NHALF = N / 2
Do 100 I = 1, NHALF
NTOP = N - I
DHOLD = D(I)
D(I) = D(NTOP+1)
D(NTOP+1) = DHOLD
100 Continue
Go To 120
c
c ********** set error -- no convergence to an
c eigenvalue after 30 iterations **********
c
110 IERR = L
End If
120 Return
c
c ********** last card of tqlrat **********
c
c
c revision history---
c
c december 1979 first added to nssl
c-----------------------------------------------------------------------
End
c package comf the entries in this package are lowlevel
c entries, supporting ulib packages blktri
c and cblktri. that is, these routines are
c not called directly by users, but rather
c by entries within blktri and cblktri.
c description of entries epmach and pimach
c follow below.
c
c latest revision january 1985
c
c special conditions none
c
c i/o none
c
c precision single
c
c required library none
c files
c
c language fortran
c ********************************************************************
c
c function epmach (dum)
c
c purpose to compute an approximate machine accuracy
c epsilon according to the following definition:
c epsilon is the smallest number such that
c (1.+epsilon).gt.1.)
c
c usage eps = epmach (dum)
c
c arguments
c on input dum
c dummy value
c
c arguments
c on output none
c
c history the original version, written when the
c blktri package was converted from the
c cdc 7600 to run on the cray-1, calculated
c machine accuracy by successive divisions
c by 10. use of this constant caused blktri
c to compute solutions on the cray-1 with four
c fewer places of accuracy than the version
c on the 7600. it was found that computing
c machine accuracy by successive divisions
c of 2 produced a machine accuracy 29% less
c than the value generated by successive
c divisions by 10, and that use of this
c machine constant in the blktri package
c recovered the accuracy that appeared to
c be lost on conversion.
c
c algorithm computes machine accuracy by successive
c divisions of two.
c
c portability this code will execute on machines other
c than the cray1, but the returned value may
c be unsatisfactory. see history above.
c ********************************************************************
c
c function pimach (dum)
c
c purpose to supply the value of the constant pi
c correct to machine precision where
c pi=3.141592653589793238462643383279502884197
c 1693993751058209749446
c
c usage pi = pimach (dum)
c
c arguments
c on input dum
c dummy value
c
c arguments
c on output none
c
c algorithm the value of pi is set in a constant.
c
c portability this entry is portable, but users should
c check to see whether greater accuracy is
c required.
c
c***********************************************************************
Function EPMACH(DUM)
IMPLICIT NONE
real*8 EPMACH, V, EPS
integer DUM
Common /VALUE/ V
EPS = 1.
10 EPS = EPS / 2.
Call STORE(EPS+1.)
If (V.GT.1.) Go To 10
EPMACH = 100. * EPS
Return
End
Subroutine STORE(X)
IMPLICIT NONE
real*8 X, V
Common /VALUE/ V
V = X
Return
End
C Function PIMACH(DUM)
C IMPLICIT NONE
C real*8 PIMACH
c pi=3.1415926535897932384626433832795028841971693993751058209749446
c
C PIMACH = 3.14159265358979
C Return
C End
c package sepaux contains no user entry points.
c
c latest revision march 1985
c
c purpose this package contains auxiliary routines for
c ncar public software packages such as sepeli
c and sepx4.
c
c usage since this package contains no user entries,
c no usage instructions or argument descriptions
c are given here.
c
c special conditions none
c
c i/o none
c
c precision single
c
c required library none
c files
c
c language fortran
c
c history developed in the late 1970's by john c. adams
c of ncar's scienttific computing division.
c
c portability fortran 66
c **********************************************************************
Subroutine SEPORT(USOL,IDMN,ZN,ZM,PERTRB)
c
c this subroutine orthoganalizes the array usol with respect to
c the constant array in a weighted least squares norm
c
IMPLICIT NONE
integer KSWX, KSWY, K , L
integer AIT, BIT, CIT, DIT, IS, MIT, NIT
real*8 MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4
Common /SPLP/ KSWX, KSWY, K, L,
* MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4,
* AIT, BIT, CIT, DIT, MIT, NIT, IS
integer IDMN
Dimension USOL(IDMN,1), ZN(1), ZM(1)
real*8 USOL, ZN, ZM, UTE, ETE, PERTRB
integer ISTR, JSTR, IFNL, JFNL, I, II, J, JJ
ISTR = IS
IFNL = MS
JSTR = JS
JFNL = NS
c
c compute weighted inner products
c
UTE = 0.0
ETE = 0.0
Do 20 I = IS, MS
II = I - IS + 1
Do 10 J = JS, NS
JJ = J - JS + 1
ETE = ETE + ZM(II) * ZN(JJ)
UTE = UTE + USOL(I,J) * ZM(II) * ZN(JJ)
10 Continue
20 Continue
c
c set perturbation parameter
c
PERTRB = UTE / ETE
c
c subtract off constant pertrb
c
Do 40 I = ISTR, IFNL
Do 30 J = JSTR, JFNL
USOL(I,J) = USOL(I,J) - PERTRB
30 Continue
40 Continue
Return
End
Subroutine SEPMIN(USOL,IDMN,ZN,ZM,PERTB)
c
c this subroutine orhtogonalizes the array usol with respect to
c the constant array in a weighted least squares norm
c
IMPLICIT NONE
integer KSWX, KSWY, K, IDMN, ISTR, JSTR,L, IFNL, JFNL
integer AIT, BIT, CIT, DIT, IS, MIT, NIT
real*8 MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4
real*8 UTE, ETE, PERTB, PERTRB
integer I, II, J, JJ
Common /SPLP/ KSWX, KSWY, K, L,
* MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4,
* AIT, BIT, CIT, DIT, MIT, NIT, IS
Dimension USOL(IDMN,1), ZN(1), ZM(1)
real*8 USOL, ZN, ZM
c
c entry at sepmin occurrs when the final solution is
c to be minimized with respect to the weighted
c least squares norm
c
ISTR = 1
IFNL = K
JSTR = 1
JFNL = L
c
c compute weighted inner products
c
UTE = 0.0
ETE = 0.0
Do 20 I = IS, MS
II = I - IS + 1
Do 10 J = JS, NS
JJ = J - JS + 1
ETE = ETE + ZM(II) * ZN(JJ)
UTE = UTE + USOL(I,J) * ZM(II) * ZN(JJ)
10 Continue
20 Continue
c
c set perturbation parameter
c
PERTRB = UTE / ETE
c
c subtract off constant pertrb
c
Do 40 I = ISTR, IFNL
Do 30 J = JSTR, JFNL
USOL(I,J) = USOL(I,J) - PERTRB
30 Continue
40 Continue
Return
End
Subroutine SEPTRI(N,A,B,C,D,U,Z)
c
c this subroutine solves for a non-zero eigenvector corresponding
c to the zero eigenvalue of the transpose of the rank
c deficient one matrix with subdiagonal a, diagonal b, and
c superdiagonal c , with a(1) in the (1,n) position, with
c c(n) in the (n,1) position, and all other elements zero.
c
IMPLICIT NONE
integer N
Dimension A(N), B(N), C(N), D(N), U(N), Z(N)
real*8 A, B, C, D, U, Z
real*8 BN, V, DEN, AN
integer K, NM1, NM2, J
BN = B(N)
D(1) = A(2) / B(1)
V = A(1)
U(1) = C(N) / B(1)
NM2 = N - 2
Do 10 J = 2, NM2
DEN = B(J) - C(J-1) * D(J-1)
D(J) = A(J+1) / DEN
U(J) = -C(J-1) * U(J-1) / DEN
BN = BN - V * U(J-1)
V = -V * D(J-1)
10 Continue
DEN = B(N-1) - C(N-2) * D(N-2)
D(N-1) = (A(N)-C(N-2)*U(N-2)) / DEN
AN = C(N-1) - V * D(N-2)
BN = BN - V * U(N-2)
DEN = BN - AN * D(N-1)
c
c set last component equal to one
c
Z(N) = 1.0
Z(N-1) = -D(N-1)
NM1 = N - 1
Do 20 J = 2, NM1
K = N - J
Z(K) = -D(K) * Z(K+1) - U(K) * Z(N)
20 Continue
Return
End
Subroutine SEPDX(U,IDMN,I,J,UXXX,UXXXX)
c
c this program computes second order finite difference
c approximations to the third and fourth x
c partial derivatives of u at the (i,j) mesh point
c
IMPLICIT NONE
integer KSWX, KSWY, K, L, I, J
integer AIT, BIT, CIT, DIT, IS, MIT, NIT
real*8 MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4
Common /SPLP/ KSWX, KSWY, K, L,
* MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4,
* AIT, BIT, CIT, DIT, MIT, NIT, IS
integer IDMN
Dimension U(IDMN,1)
real*8 U, UXXX, UXXXX
If (I.LE.2.OR.I.GE.(K-1)) Then
If (I.NE.1) Then
If (I.EQ.2) Go To 10
If (I.EQ.K-1) Go To 20
If (I.EQ.K) Go To 30
End If
c
c compute partial derivative approximations at x=a
c
If (KSWX.NE.1) Then
UXXX = (-5.0*U(1,J)+18.0*U(2,J)-24.0*U(3,J)+14.0*U(4,J)-3.0*
* U(5,J)) / (TDLX3)
UXXXX = (3.0*U(1,J)-14.0*U(2,J)+26.0*U(3,J)-24.0*U(4,J)+11.0*
* U(5,J)-2.0*U(6,J)) / DLX4
Return
End If
c
c periodic at x=a
c
UXXX = (-U(K-2,J)+2.0*U(K-1,J)-2.0*U(2,J)+U(3,J)) / (TDLX3)
UXXXX = (U(K-2,J)-4.0*U(K-1,J)+6.0*U(1,J)-4.0*U(2,J)+U(3,J)) /
* DLX4
Return
c
c compute partial derivative approximations at x=a+dlx
c
10 If (KSWX.NE.1) Then
UXXX = (-3.0*U(1,J)+10.0*U(2,J)-12.0*U(3,J)+6.0*U(4,J)-
* U(5,J)) / TDLX3
UXXXX = (2.0*U(1,J)-9.0*U(2,J)+16.0*U(3,J)-14.0*U(4,J)+6.0*
* U(5,J)-U(6,J)) / DLX4
Return
End If
c
c periodic at x=a+dlx
c
UXXX = (-U(K-1,J)+2.0*U(1,J)-2.0*U(3,J)+U(4,J)) / (TDLX3)
UXXXX = (U(K-1,J)-4.0*U(1,J)+6.0*U(2,J)-4.0*U(3,J)+U(4,J)) /
* DLX4
Return
End If
c
c compute partial derivative approximations on the interior
c
UXXX = (-U(I-2,J)+2.0*U(I-1,J)-2.0*U(I+1,J)+U(I+2,J)) / TDLX3
UXXXX = (U(I-2,J)-4.0*U(I-1,J)+6.0*U(I,J)-4.0*U(I+1,J)+U(I+2,J)) /
* DLX4
Return
c
c compute partial derivative approximations at x=b-dlx
c
20 If (KSWX.NE.1) Then
UXXX = (U(K-4,J)-6.0*U(K-3,J)+12.0*U(K-2,J)-10.0*U(K-1,J)+3.0*
* U(K,J)) / TDLX3
UXXXX = (-U(K-5,J)+6.0*U(K-4,J)-14.0*U(K-3,J)+16.0*U(K-2,J)-9.0*
* U(K-1,J)+2.0*U(K,J)) / DLX4
Return
End If
c
c periodic at x=b-dlx
c
UXXX = (-U(K-3,J)+2.0*U(K-2,J)-2.0*U(1,J)+U(2,J)) / TDLX3
UXXXX = (U(K-3,J)-4.0*U(K-2,J)+6.0*U(K-1,J)-4.0*U(1,J)+U(2,J)) /
* DLX4
Return
c
c compute partial derivative approximations at x=b
c
30 UXXX = -(3.0*U(K-4,J)-14.0*U(K-3,J)+24.0*U(K-2,J)-18.0*U(K-1,J)+
* 5.0*U(K,J)) / TDLX3
UXXXX = (-2.0*U(K-5,J)+11.0*U(K-4,J)-24.0*U(K-3,J)+26.0*U(K-2,J)-
* 14.0*U(K-1,J)+3.0*U(K,J)) / DLX4
Return
End
Subroutine SEPDY(U,IDMN,I,J,UYYY,UYYYY)
IMPLICIT NONE
c
c this program computes second order finite difference
c approximations to the third and fourth y
c partial derivatives of u at the (i,j) mesh point
c
integer KSWX, KSWY, K
integer AIT, BIT, CIT, DIT, IS, MIT, NIT
real*8 MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4
Common /SPLP/ KSWX, KSWY, K, L,
* MS, JS, NS, DLX, DLY, TDLX3, TDLY3, DLX4, DLY4,
* AIT, BIT, CIT, DIT, MIT, NIT, IS
integer IDMN, I, J, L
Dimension U(IDMN,IDMN)
real*8 U, UYYY, UYYYY
If (J.LE.2.OR.J.GE.(L-1)) Then
If (J.NE.1) Then
If (J.EQ.2) Go To 10
If (J.EQ.L-1) Go To 20
If (J.EQ.L) Go To 30
End If
c
c compute partial derivative approximations at y=c
c
If (KSWY.NE.1) Then
UYYY = (-5.0*U(I,1)+18.0*U(I,2)-24.0*U(I,3)+14.0*U(I,4)-3.0*
* U(I,5)) / TDLY3
UYYYY = (3.0*U(I,1)-14.0*U(I,2)+26.0*U(I,3)-24.0*U(I,4)+11.0*
* U(I,5)-2.0*U(I,6)) / DLY4
Return
End If
c
c periodic at x=a
c
UYYY = (-U(I,L-2)+2.0*U(I,L-1)-2.0*U(I,2)+U(I,3)) / TDLY3
UYYYY = (U(I,L-2)-4.0*U(I,L-1)+6.0*U(I,1)-4.0*U(I,2)+U(I,3)) /
* DLY4
Return
c
c compute partial derivative approximations at y=c+dly
c
10 If (KSWY.NE.1) Then
UYYY = (-3.0*U(I,1)+10.0*U(I,2)-12.0*U(I,3)+6.0*U(I,4)-
* U(I,5)) / TDLY3
UYYYY = (2.0*U(I,1)-9.0*U(I,2)+16.0*U(I,3)-14.0*U(I,4)+6.0*
* U(I,5)-U(I,6)) / DLY4
Return
End If
c
c periodic at y=c+dly
c
UYYY = (-U(I,L-1)+2.0*U(I,1)-2.0*U(I,3)+U(I,4)) / TDLY3
UYYYY = (U(I,L-1)-4.0*U(I,1)+6.0*U(I,2)-4.0*U(I,3)+U(I,4)) /
* DLY4
Return
End If
c
c compute partial derivative approximations on the interior
c
UYYY = (-U(I,J-2)+2.0*U(I,J-1)-2.0*U(I,J+1)+U(I,J+2)) / TDLY3
UYYYY = (U(I,J-2)-4.0*U(I,J-1)+6.0*U(I,J)-4.0*U(I,J+1)+U(I,J+2)) /
* DLY4
Return
c
c compute partial derivative approximations at y=d-dly
c
20 If (KSWY.NE.1) Then
UYYY = (U(I,L-4)-6.0*U(I,L-3)+12.0*U(I,L-2)-10.0*U(I,L-1)+3.0*
* U(I,L)) / TDLY3
UYYYY = (-U(I,L-5)+6.0*U(I,L-4)-14.0*U(I,L-3)+16.0*U(I,L-2)-9.0*
* U(I,L-1)+2.0*U(I,L)) / DLY4
Return
End If
c
c periodic at y=d-dly
c
UYYY = (-U(I,L-3)+2.0*U(I,L-2)-2.0*U(I,1)+U(I,2)) / TDLY3
UYYYY = (U(I,L-3)-4.0*U(I,L-2)+6.0*U(I,L-1)-4.0*U(I,1)+U(I,2)) /
* DLY4
Return
c
c compute partial derivative approximations at y=d
c
30 UYYY = -(3.0*U(I,L-4)-14.0*U(I,L-3)+24.0*U(I,L-2)-18.0*U(I,L-1)+
* 5.0*U(I,L)) / TDLY3
UYYYY = (-2.0*U(I,L-5)+11.0*U(I,L-4)-24.0*U(I,L-3)+26.0*U(I,L-2)-
* 14.0*U(I,L-1)+3.0*U(I,L)) / DLY4
Return
c
c revision history---
c
c december 1979 first added to nssl
c-----------------------------------------------------------------------
End
Subroutine COFX(XX,AFUN,BFUN,CFUN)
c
c subroutine to compute the coefficients of the elliptic equation
c solved to fill in the grid. it is passed (along with cofy) to
c the elliptic solver sepeli.
Include 'mexsepeli.inc'
integer I
real*8 DXDI, AFUN, BFUN, CFUN, XX
I = DNINT(XX)
DXDI = 0.5 * (SXI(I+1)-SXI(I-1))
AFUN = 1. / DXDI ** 2
BFUN = (-SXI(I+1)+2.*SXI(I)-SXI(I-1)) / DXDI ** 3
CFUN = 0.
Return
End
Subroutine COFY(YY,DFUN,EFUN,FFUN)
Include 'mexsepeli.inc'
integer J
real*8 DEDJ, DFUN, EFUN, FFUN, YY
J = DNINT(YY)
DEDJ = 0.5 * (SETA(J+1)-SETA(J-1))
DFUN = 1. / DEDJ ** 2
EFUN = (-SETA(J+1)+2.*SETA(J)-SETA(J-1)) / DEDJ ** 3
FFUN = 0.
Return
End
| cc0-1.0 |
alexfrolov/grappa | applications/NPB/MPI/BT/full_mpiio.f | 8 | 8075 |
c---------------------------------------------------------------------
c---------------------------------------------------------------------
subroutine setup_btio
c---------------------------------------------------------------------
c---------------------------------------------------------------------
include 'header.h'
include 'mpinpb.h'
integer ierr
integer mstatus(MPI_STATUS_SIZE)
integer sizes(4), starts(4), subsizes(4)
integer cell_btype(maxcells), cell_ftype(maxcells)
integer cell_blength(maxcells)
integer info
character*20 cb_nodes, cb_size
integer c, m
integer cell_disp(maxcells)
call mpi_bcast(collbuf_nodes, 1, MPI_INTEGER,
> root, comm_setup, ierr)
call mpi_bcast(collbuf_size, 1, MPI_INTEGER,
> root, comm_setup, ierr)
if (collbuf_nodes .eq. 0) then
info = MPI_INFO_NULL
else
write (cb_nodes,*) collbuf_nodes
write (cb_size,*) collbuf_size
call MPI_Info_create(info, ierr)
call MPI_Info_set(info, 'cb_nodes', cb_nodes, ierr)
call MPI_Info_set(info, 'cb_buffer_size', cb_size, ierr)
call MPI_Info_set(info, 'collective_buffering', 'true', ierr)
endif
call MPI_Type_contiguous(5, MPI_DOUBLE_PRECISION,
$ element, ierr)
call MPI_Type_commit(element, ierr)
call MPI_Type_extent(element, eltext, ierr)
do c = 1, ncells
c
c Outer array dimensions ar same for every cell
c
sizes(1) = IMAX+4
sizes(2) = JMAX+4
sizes(3) = KMAX+4
c
c 4th dimension is cell number, total of maxcells cells
c
sizes(4) = maxcells
c
c Internal dimensions of cells can differ slightly between cells
c
subsizes(1) = cell_size(1, c)
subsizes(2) = cell_size(2, c)
subsizes(3) = cell_size(3, c)
c
c Cell is 4th dimension, 1 cell per cell type to handle varying
c cell sub-array sizes
c
subsizes(4) = 1
c
c type constructors use 0-based start addresses
c
starts(1) = 2
starts(2) = 2
starts(3) = 2
starts(4) = c-1
c
c Create buftype for a cell
c
call MPI_Type_create_subarray(4, sizes, subsizes,
$ starts, MPI_ORDER_FORTRAN, element,
$ cell_btype(c), ierr)
c
c block length and displacement for joining cells -
c 1 cell buftype per block, cell buftypes have own displacment
c generated from cell number (4th array dimension)
c
cell_blength(c) = 1
cell_disp(c) = 0
enddo
c
c Create combined buftype for all cells
c
call MPI_Type_struct(ncells, cell_blength, cell_disp,
$ cell_btype, combined_btype, ierr)
call MPI_Type_commit(combined_btype, ierr)
do c = 1, ncells
c
c Entire array size
c
sizes(1) = PROBLEM_SIZE
sizes(2) = PROBLEM_SIZE
sizes(3) = PROBLEM_SIZE
c
c Size of c'th cell
c
subsizes(1) = cell_size(1, c)
subsizes(2) = cell_size(2, c)
subsizes(3) = cell_size(3, c)
c
c Starting point in full array of c'th cell
c
starts(1) = cell_low(1,c)
starts(2) = cell_low(2,c)
starts(3) = cell_low(3,c)
call MPI_Type_create_subarray(3, sizes, subsizes,
$ starts, MPI_ORDER_FORTRAN,
$ element, cell_ftype(c), ierr)
cell_blength(c) = 1
cell_disp(c) = 0
enddo
call MPI_Type_struct(ncells, cell_blength, cell_disp,
$ cell_ftype, combined_ftype, ierr)
call MPI_Type_commit(combined_ftype, ierr)
iseek=0
if (node .eq. root) then
call MPI_File_delete(filenm, MPI_INFO_NULL, ierr)
endif
call MPI_Barrier(comm_solve, ierr)
call MPI_File_open(comm_solve,
$ filenm,
$ MPI_MODE_RDWR+MPI_MODE_CREATE,
$ MPI_INFO_NULL, fp, ierr)
if (ierr .ne. MPI_SUCCESS) then
print *, 'Error opening file'
stop
endif
call MPI_File_set_view(fp, iseek, element,
$ combined_ftype, 'native', info, ierr)
if (ierr .ne. MPI_SUCCESS) then
print *, 'Error setting file view'
stop
endif
do m = 1, 5
xce_sub(m) = 0.d0
end do
idump_sub = 0
return
end
c---------------------------------------------------------------------
c---------------------------------------------------------------------
subroutine output_timestep
c---------------------------------------------------------------------
c---------------------------------------------------------------------
include 'header.h'
include 'mpinpb.h'
integer mstatus(MPI_STATUS_SIZE)
integer ierr
call MPI_File_write_at_all(fp, iseek, u,
$ 1, combined_btype, mstatus, ierr)
if (ierr .ne. MPI_SUCCESS) then
print *, 'Error writing to file'
stop
endif
call MPI_Type_size(combined_btype, iosize, ierr)
iseek = iseek + iosize/eltext
idump_sub = idump_sub + 1
if (rd_interval .gt. 0) then
if (idump_sub .ge. rd_interval) then
iseek = 0
call acc_sub_norms(idump+1)
iseek = 0
idump_sub = 0
endif
endif
return
end
c---------------------------------------------------------------------
c---------------------------------------------------------------------
subroutine acc_sub_norms(idump_cur)
include 'header.h'
include 'mpinpb.h'
integer idump_cur
integer ii, m, ichunk
integer ierr
integer mstatus(MPI_STATUS_SIZE)
double precision xce_single(5)
ichunk = idump_cur - idump_sub + 1
do ii=0, idump_sub-1
call MPI_File_read_at_all(fp, iseek, u,
$ 1, combined_btype, mstatus, ierr)
if (ierr .ne. MPI_SUCCESS) then
print *, 'Error reading back file'
call MPI_File_close(fp, ierr)
stop
endif
call MPI_Type_size(combined_btype, iosize, ierr)
iseek = iseek + iosize/eltext
if (node .eq. root) print *, 'Reading data set ', ii+ichunk
call error_norm(xce_single)
do m = 1, 5
xce_sub(m) = xce_sub(m) + xce_single(m)
end do
enddo
return
end
c---------------------------------------------------------------------
c---------------------------------------------------------------------
subroutine btio_cleanup
c---------------------------------------------------------------------
c---------------------------------------------------------------------
include 'header.h'
include 'mpinpb.h'
integer ierr
call MPI_File_close(fp, ierr)
return
end
c---------------------------------------------------------------------
c---------------------------------------------------------------------
subroutine accumulate_norms(xce_acc)
c---------------------------------------------------------------------
c---------------------------------------------------------------------
include 'header.h'
include 'mpinpb.h'
double precision xce_acc(5)
integer m, ierr
if (rd_interval .gt. 0) goto 20
call MPI_File_open(comm_solve,
$ filenm,
$ MPI_MODE_RDONLY,
$ MPI_INFO_NULL,
$ fp,
$ ierr)
iseek = 0
call MPI_File_set_view(fp, iseek, element, combined_ftype,
$ 'native', MPI_INFO_NULL, ierr)
c clear the last time step
call clear_timestep
c read back the time steps and accumulate norms
call acc_sub_norms(idump)
call MPI_File_close(fp, ierr)
20 continue
do m = 1, 5
xce_acc(m) = xce_sub(m) / dble(idump)
end do
return
end
| bsd-3-clause |
epfl-cosmo/q-e | PHonon/Gamma/find_equiv_sites.f90 | 15 | 1270 | !
! Copyright (C) 2003 PWSCF group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!
SUBROUTINE find_equiv_sites (nat,nsym,irt,has_equivalent, &
n_diff_sites,n_equiv_atoms,equiv_atoms)
!
IMPLICIT NONE
INTEGER :: nat, nsym, na, nb, ns, n_diff_sites, irt(48,nat), &
equiv_atoms(nat,nat), n_equiv_atoms(nat), has_equivalent(nat)
!
n_diff_sites = 0
DO na = 1,nat
has_equivalent(na) = 0
ENDDO
!
DO na = 1,nat
IF (has_equivalent(na)==0) THEN
n_diff_sites = n_diff_sites + 1
n_equiv_atoms (n_diff_sites) = 1
equiv_atoms(n_diff_sites,1) = na
!
DO nb = na+1,nat
DO ns = 1, nsym
IF ( irt(ns,nb) == na) THEN
has_equivalent(nb) = 1
n_equiv_atoms (n_diff_sites) = &
n_equiv_atoms (n_diff_sites) + 1
equiv_atoms(n_diff_sites, &
n_equiv_atoms(n_diff_sites)) = nb
GOTO 10
ENDIF
ENDDO
10 CONTINUE
ENDDO
ENDIF
ENDDO
!
RETURN
END SUBROUTINE find_equiv_sites
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.16/src/calcinitialflux.f | 1 | 1469 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2019 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 calcinitialflux(area,vfa,xxna,
& ipnei,nef,neifa,lakonf,flux)
!
! correction of v due to the balance of mass
! the correction is in normal direction to the face
!
implicit none
!
character*8 lakonf(*)
!
integer i,j,indexf,ipnei(*),ifa,nef,neifa(*),numfaces
!
real*8 area(*),vfa(0:7,*),xxna(3,*),flux(*)
!
do i=1,nef
do indexf=ipnei(i)+1,ipnei(i+1)
ifa=neifa(indexf)
flux(indexf)=vfa(5,ifa)*
& (vfa(1,ifa)*xxna(1,indexf)+
& vfa(2,ifa)*xxna(2,indexf)+
& vfa(3,ifa)*xxna(3,indexf))
enddo
enddo
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/extrapolate_vel.f | 1 | 4729 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 extrapolate_vel(nface,ielfa,xrlfa,vel,vfa,
& ifabou,xboun,ipnei,nef,icyclic,c,ifatie,xxn)
!
! inter/extrapolation of v at the center of the elements
! to the center of the faces
!
implicit none
!
integer nface,ielfa(4,*),ifabou(*),iel1,iel2,iel3,i,j,ipointer,
& indexf,ipnei(*),nef,icyclic,ifatie(*)
!
real*8 xrlfa(3,*),vel(nef,0:7),vfa(0:7,*),xboun(*),xl1,xl2,
& c(3,3),xxn(3,*),dd
!
c$omp parallel default(none)
c$omp& shared(nface,ielfa,xrlfa,vfa,vel,ipnei,ifabou,xboun,
c$omp& icyclic,c,ifatie,xxn)
c$omp& private(i,iel1,xl1,iel2,xl2,j,iel3,ipointer,indexf,dd)
c$omp do
do i=1,nface
iel1=ielfa(1,i)
xl1=xrlfa(1,i)
iel2=ielfa(2,i)
if(iel2.gt.0) then
xl2=xrlfa(2,i)
if((icyclic.eq.0).or.(ifatie(i).eq.0)) then
do j=1,3
vfa(j,i)=xl1*vel(iel1,j)+xl2*vel(iel2,j)
enddo
elseif(ifatie(i).gt.0) then
do j=1,3
vfa(j,i)=xl1*vel(iel1,j)+xl2*
& (c(j,1)*vel(iel2,1)
& +c(j,2)*vel(iel2,2)
& +c(j,3)*vel(iel2,3))
enddo
else
do j=1,3
vfa(j,i)=xl1*vel(iel1,j)+xl2*
& (c(1,j)*vel(iel2,1)
& +c(2,j)*vel(iel2,2)
& +c(3,j)*vel(iel2,3))
enddo
endif
else
indexf=ipnei(iel1)+ielfa(4,i)
iel3=ielfa(3,i)
c write(*,*) 'extrapolate_vel ',iel1,iel2,iel3
if(iel2.lt.0) then
ipointer=-iel2
!
! global x-direction
!
if(ifabou(ipointer+1).gt.0) then
!
! v_1 given
!
vfa(1,i)=xboun(ifabou(ipointer+1))
elseif((ifabou(ipointer+4).ne.0).and.(iel3.ne.0)) then
!
! p given; linear interpolation
!
vfa(1,i)=xl1*vel(iel1,1)+xrlfa(3,i)*vel(iel3,1)
else
!
! constant extrapolation
!
vfa(1,i)=vel(iel1,1)
endif
!
! global y-direction
!
if(ifabou(ipointer+2).gt.0) then
!
! v_2 given
!
vfa(2,i)=xboun(ifabou(ipointer+2))
elseif((ifabou(ipointer+4).ne.0).and.(iel3.ne.0)) then
!
! p given; linear interpolation
!
vfa(2,i)=xl1*vel(iel1,2)+xrlfa(3,i)*vel(iel3,2)
else
!
! constant extrapolation
!
vfa(2,i)=vel(iel1,2)
endif
!
! global z-direction
!
if(ifabou(ipointer+3).gt.0) then
!
! v_3 given
!
vfa(3,i)=xboun(ifabou(ipointer+3))
elseif((ifabou(ipointer+4).ne.0).and.(iel3.ne.0)) then
!
! p given; linear interpolation
!
vfa(3,i)=xl1*vel(iel1,3)+xrlfa(3,i)*vel(iel3,3)
else
!
! constant extrapolation
!
vfa(3,i)=vel(iel1,3)
endif
!
! correction for sliding boundary conditions
!
c if(ifabou(ipointer+5).eq.2) then
if(ifabou(ipointer+5).lt.0) then
dd=vfa(1,i)*xxn(1,indexf)+
& vfa(2,i)*xxn(2,indexf)+
& vfa(3,i)*xxn(3,indexf)
do j=1,3
vfa(j,i)=vfa(j,i)-dd*xxn(j,indexf)
enddo
endif
!
else
!
! constant extrapolation
!
do j=1,3
vfa(j,i)=vel(iel1,j)
enddo
endif
endif
enddo
c$omp end do
c$omp end parallel
!
c write(*,*) 'extrapolate_vel '
c do i=1,nef
c write(*,*) i,(vel(i,j),j=0,5)
c enddo
c do i=1,nface
c write(*,*) i,(vfa(j,i),j=0,5)
c enddo
return
end
| gpl-2.0 |
techno/gcc-mist32 | gcc/testsuite/gfortran.dg/internal_references_1.f90 | 135 | 1045 | ! { dg-do compile }
! This tests the patch for PRs 24327, 25024 & 25625, which
! are all connected with references to internal procedures.
! This is a composite of the PR testcases; and each is
! labelled by PR.
!
! Contributed by Paul Thomas <pault@gcc.gnu.org>
!
! PR25625 - would neglect to point out that there were 2 subroutines p.
module m
implicit none
contains
subroutine p (i) ! { dg-error "is already defined" }
integer :: i
end subroutine
subroutine p (i) ! { dg-error "is already defined" }
integer :: i
end subroutine
end module
!
! PR25124 - would happily ignore the declaration of foo in the main program.
program test
real :: foo, x ! { dg-error "explicit interface and must not have attributes declared" }
x = bar () ! This is OK because it is a regular reference.
x = foo ()
contains
function foo () ! { dg-error "explicit interface and must not have attributes declared" }
foo = 1.0
end function foo
function bar ()
bar = 1.0
end function bar
end program test
| gpl-2.0 |
grlee77/scipy | scipy/integrate/quadpack/dqagp.f | 32 | 10517 | subroutine dqagp(f,a,b,npts2,points,epsabs,epsrel,result,abserr,
* neval,ier,leniw,lenw,last,iwork,work)
c***begin prologue dqagp
c***date written 800101 (yymmdd)
c***revision date 830518 (yymmdd)
c***category no. h2a2a1
c***keywords automatic integrator, general-purpose,
c singularities at user specified points,
c extrapolation, globally adaptive
c***author piessens,robert,appl. math. & progr. div - k.u.leuven
c de doncker,elise,appl. math. & progr. div. - k.u.leuven
c***purpose the routine calculates an approximation result to a given
c definite integral i = integral of f over (a,b),
c hopefully satisfying following claim for accuracy
c break points of the integration interval, where local
c difficulties of the integrand may occur (e.g.
c singularities, discontinuities), are provided by the user.
c***description
c
c computation of a definite integral
c standard fortran subroutine
c double precision version
c
c parameters
c on entry
c f - double precision
c function subprogram defining the integrand
c function f(x). the actual name for f needs to be
c declared e x t e r n a l in the driver program.
c
c a - double precision
c lower limit of integration
c
c b - double precision
c upper limit of integration
c
c npts2 - integer
c number equal to two more than the number of
c user-supplied break points within the integration
c range, npts.ge.2.
c if npts2.lt.2, the routine will end with ier = 6.
c
c points - double precision
c vector of dimension npts2, the first (npts2-2)
c elements of which are the user provided break
c points. if these points do not constitute an
c ascending sequence there will be an automatic
c sorting.
c
c epsabs - double precision
c absolute accuracy requested
c epsrel - double precision
c relative accuracy requested
c if epsabs.le.0
c and epsrel.lt.max(50*rel.mach.acc.,0.5d-28),
c the routine will end with ier = 6.
c
c on return
c result - double precision
c approximation to the integral
c
c abserr - double precision
c estimate of the modulus of the absolute error,
c which should equal or exceed abs(i-result)
c
c neval - integer
c number of integrand evaluations
c
c ier - integer
c ier = 0 normal and reliable termination of the
c routine. it is assumed that the requested
c accuracy has been achieved.
c ier.gt.0 abnormal termination of the routine.
c the estimates for integral and error are
c less reliable. it is assumed that the
c requested accuracy has not been achieved.
c error messages
c ier = 1 maximum number of subdivisions allowed
c has been achieved. one can allow more
c subdivisions by increasing the value of
c limit (and taking the according dimension
c adjustments into account). however, if
c this yields no improvement it is advised
c to analyze the integrand in order to
c determine the integration difficulties. if
c the position of a local difficulty can be
c determined (i.e. singularity,
c discontinuity within the interval), it
c should be supplied to the routine as an
c element of the vector points. if necessary
c an appropriate special-purpose integrator
c must be used, which is designed for
c handling the type of difficulty involved.
c = 2 the occurrence of roundoff error is
c detected, which prevents the requested
c tolerance from being achieved.
c the error may be under-estimated.
c = 3 extremely bad integrand behaviour occurs
c at some points of the integration
c interval.
c = 4 the algorithm does not converge.
c roundoff error is detected in the
c extrapolation table.
c it is presumed that the requested
c tolerance cannot be achieved, and that
c the returned result is the best which
c can be obtained.
c = 5 the integral is probably divergent, or
c slowly convergent. it must be noted that
c divergence can occur with any other value
c of ier.gt.0.
c = 6 the input is invalid because
c npts2.lt.2 or
c break points are specified outside
c the integration range or
c (epsabs.le.0 and
c epsrel.lt.max(50*rel.mach.acc.,0.5d-28))
c result, abserr, neval, last are set to
c zero. except when leniw or lenw or npts2 is
c invalid, iwork(1), iwork(limit+1),
c work(limit*2+1) and work(limit*3+1)
c are set to zero.
c work(1) is set to a and work(limit+1)
c to b (where limit = (leniw-npts2)/2).
c
c dimensioning parameters
c leniw - integer
c dimensioning parameter for iwork
c leniw determines limit = (leniw-npts2)/2,
c which is the maximum number of subintervals in the
c partition of the given integration interval (a,b),
c leniw.ge.(3*npts2-2).
c if leniw.lt.(3*npts2-2), the routine will end with
c ier = 6.
c
c lenw - integer
c dimensioning parameter for work
c lenw must be at least leniw*2-npts2.
c if lenw.lt.leniw*2-npts2, the routine will end
c with ier = 6.
c
c last - integer
c on return, last equals the number of subintervals
c produced in the subdivision process, which
c determines the number of significant elements
c actually in the work arrays.
c
c work arrays
c iwork - integer
c vector of dimension at least leniw. on return,
c the first k elements of which contain
c pointers to the error estimates over the
c subintervals, such that work(limit*3+iwork(1)),...,
c work(limit*3+iwork(k)) form a decreasing
c sequence, with k = last if last.le.(limit/2+2), and
c k = limit+1-last otherwise
c iwork(limit+1), ...,iwork(limit+last) contain the
c subdivision levels of the subintervals, i.e.
c if (aa,bb) is a subinterval of (p1,p2)
c where p1 as well as p2 is a user-provided
c break point or integration limit, then (aa,bb) has
c level l if abs(bb-aa) = abs(p2-p1)*2**(-l),
c iwork(limit*2+1), ..., iwork(limit*2+npts2) have
c no significance for the user,
c note that limit = (leniw-npts2)/2.
c
c work - double precision
c vector of dimension at least lenw
c on return
c work(1), ..., work(last) contain the left
c end points of the subintervals in the
c partition of (a,b),
c work(limit+1), ..., work(limit+last) contain
c the right end points,
c work(limit*2+1), ..., work(limit*2+last) contain
c the integral approximations over the subintervals,
c work(limit*3+1), ..., work(limit*3+last)
c contain the corresponding error estimates,
c work(limit*4+1), ..., work(limit*4+npts2)
c contain the integration limits and the
c break points sorted in an ascending sequence.
c note that limit = (leniw-npts2)/2.
c
c***references (none)
c***routines called dqagpe,xerror
c***end prologue dqagp
c
double precision a,abserr,b,epsabs,epsrel,f,points,result,work
integer ier,iwork,last,leniw,lenw,limit,lvl,l1,l2,l3,l4,neval,
* npts2
c
dimension iwork(leniw),points(npts2),work(lenw)
c
external f
c
c check validity of limit and lenw.
c
c***first executable statement dqagp
ier = 6
neval = 0
last = 0
result = 0.0d+00
abserr = 0.0d+00
if(leniw.lt.(3*npts2-2).or.lenw.lt.(leniw*2-npts2).or.npts2.lt.2)
* go to 10
c
c prepare call for dqagpe.
c
limit = (leniw-npts2)/2
l1 = limit+1
l2 = limit+l1
l3 = limit+l2
l4 = limit+l3
c
call dqagpe(f,a,b,npts2,points,epsabs,epsrel,limit,result,abserr,
* neval,ier,work(1),work(l1),work(l2),work(l3),work(l4),
* iwork(1),iwork(l1),iwork(l2),last)
c
c call error handler if necessary.
c
lvl = 0
10 if(ier.eq.6) lvl = 1
if(ier.ne.0) call xerror('abnormal return from dqagp',26,ier,lvl)
return
end
| bsd-3-clause |
prool/ccx_prool | CalculiX/ccx_2.9/src/radresult.f | 5 | 1853 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 radresult(ntr,xloadact,bcr,nloadtr,tarea,
& tenv,physcon,erad,auview,fenv,irowrad,jqrad,
& nzsrad,q)
!
implicit none
!
integer i,j,k,ntr,nloadtr(*),irowrad(*),jqrad(*),nzsrad
!
real*8 xloadact(2,*), tarea(*),tenv(*),auview(*),
& erad(*),fenv(*),physcon(*),bcr(ntr),q(*)
!
! calculating the flux and transforming the flux into an
! equivalent temperature
!
write(*,*) ''
!
do i=1,ntr
q(i)=bcr(i)
enddo
!
! lower triangle
!
do i=1,ntr
do j=jqrad(i),jqrad(i+1)-1
k=irowrad(j)
q(k)=q(k)-auview(j)*bcr(i)
!
! upper triangle
!
q(i)=q(i)-auview(nzsrad+j)*bcr(k)
enddo
enddo
!
do i=1,ntr
j=nloadtr(i)
q(i)=q(i)-fenv(i)*physcon(2)*tenv(i)**4
xloadact(2,j)=
& max(tarea(i)**4-q(i)/(erad(i)*physcon(2)),0.d0)
xloadact(2,j)=(xloadact(2,j))**0.25+physcon(1)
enddo
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.15/src/mafillk.f | 1 | 7696 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2018 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 mafillk(nef,ipnei,neifa,neiel,vfa,xxn,area,
& au,ad,jq,irow,nzs,b,vel,umfa,xlet,xle,gradkfa,xxi,
& body,volume,ielfa,lakonf,ifabou,nbody,neq,
& dtimef,velo,veloo,cvfa,hcfa,cvel,gradvel,xload,gamma,xrlfa,
& xxj,nactdohinv,a1,a2,a3,flux,nefa,nefb,iau6,xxni,xxnj,
& iturbulent,f1,of2,yy,umel,gradkel,gradoel)
!
! filling the matrix for the conservation of energy
!
implicit none
!
logical knownflux
!
character*8 lakonf(*)
!
integer i,nef,indexf,ipnei(*),j,ifa,iel,neifa(*),
& neiel(*),jq(*),irow(*),nzs,ielfa(4,*),nefa,nefb,
& ipointer,ifabou(*),nbody,neq,indexb,nactdohinv(*),
& iau6(6,*),iturbulent
!
real*8 xflux,vfa(0:7,*),xxn(3,*),area(*),au(*),ad(*),b(neq),
& vel(nef,0:7),umfa(*),xlet(*),xle(*),coef,gradkfa(3,*),
& xxi(3,*),body(0:3,*),volume(*),dtimef,velo(nef,0:7),
& veloo(nef,0:7),rhovol,cvel(*),gradvel(3,3,*),sk,
& cvfa(*),hcfa(*),div,xload(2,*),gamma(*),xrlfa(3,*),
& xxj(3,*),a1,a2,a3,flux(*),xxnj(3,*),xxni(3,*),difcoef,
& f1(*),of2(*),yy(*),umel(*),gradkel(3,*),gradoel(3,*),
& cd,arg1
!
intent(in) nef,ipnei,neifa,neiel,vfa,xxn,area,
& jq,irow,nzs,vel,umfa,xlet,xle,gradkfa,xxi,
& body,volume,ielfa,lakonf,ifabou,nbody,neq,
& dtimef,velo,veloo,cvfa,hcfa,cvel,gradvel,xload,gamma,xrlfa,
& xxj,nactdohinv,a1,a2,a3,flux,nefa,nefb,iturbulent
!
intent(inout) au,ad,b
!
do i=nefa,nefb
!
if(iturbulent.eq.1) then
!
! k-epsilon model
!
sk=1.d0
elseif(iturbulent.eq.2) then
!
! k-omega model
!
sk=0.5d0
else
!
! BSL and SST model
!
cd=max(2.d0*vel(i,5)*0.856d0*
& (gradkel(1,i)*gradoel(1,i)+
& gradkel(2,i)*gradoel(2,i)+
& gradkel(3,i)*gradoel(3,i))/vel(i,7),
& 1.d-20)
arg1=min(max(dsqrt(vel(i,6))/(0.09d0*vel(i,7)*yy(i)),
& 500.d0*umel(i)/(vel(i,5)*yy(i)**2*vel(i,7))),
& 4.d0*vel(i,5)*0.856d0*vel(i,6)/(cd*yy(i)**2))
f1(i)=dtanh(arg1**4)
if(iturbulent.eq.3) then
!
! BSL model
!
sk=0.5d0*f1(i)+(1.d0-f1(i))
else
!
! SST model
!
sk=0.85d0*f1(i)+(1.d0-f1(i))
endif
endif
!
do indexf=ipnei(i)+1,ipnei(i+1)
!
! convection
!
ifa=neifa(indexf)
iel=neiel(indexf)
xflux=flux(indexf)
!
if(xflux.ge.0.d0) then
!
! outflowing flux
!
ad(i)=ad(i)+xflux
!
b(i)=b(i)-gamma(ifa)*(vfa(6,ifa)-vel(i,6))*xflux
!
else
if(iel.gt.0) then
!
! incoming flux from neighboring element
!
au(indexf)=au(indexf)+xflux
!
b(i)=b(i)-gamma(ifa)*(vfa(6,ifa)-vel(iel,6))*xflux
!
else
!
! incoming flux through boundary
!
if(ielfa(2,ifa).lt.0) then
indexb=-ielfa(2,ifa)
if(((ifabou(indexb+1).ne.0).and.
& (ifabou(indexb+2).ne.0).and.
& (ifabou(indexb+3).ne.0)).or.
& (dabs(xflux).lt.1.d-10)) then
b(i)=b(i)-vfa(6,ifa)*xflux
endif
endif
endif
endif
!
! diffusion
!
if(iturbulent.le.3) then
!
! k-epsilon, k-omega or BSL model
!
difcoef=umfa(ifa)+sk*vfa(5,ifa)*vfa(6,ifa)/vfa(7,ifa)
else
!
! SST model
!
difcoef=umfa(ifa)+sk*vfa(5,ifa)*(0.31d0*vfa(6,ifa))/
& max(0.31d0*vfa(7,ifa),of2(i))
endif
!
if(iel.ne.0) then
!
! neighboring element
!
coef=difcoef*area(ifa)/xlet(indexf)
ad(i)=ad(i)+coef
au(indexf)=au(indexf)-coef
!
! correction for non-orthogonal grid
!
b(i)=b(i)+difcoef*area(ifa)*
& (gradkfa(1,ifa)*xxnj(1,indexf)+
& gradkfa(2,ifa)*xxnj(2,indexf)+
& gradkfa(3,ifa)*xxnj(3,indexf))
else
!
! boundary; either temperature given or adiabatic
! or outlet
!
knownflux=.false.
ipointer=abs(ielfa(2,ifa))
if(ipointer.gt.0) then
if((ifabou(ipointer+5).ne.0).or.
& (ifabou(ipointer+1).ne.0).or.
& (ifabou(ipointer+2).ne.0).or.
& (ifabou(ipointer+3).ne.0)) then
!
! no outlet:
! (i.e. no wall || no sliding || at least one velocity given)
! turbulent variable is assumed fixed
!
coef=difcoef*area(ifa)/xle(indexf)
ad(i)=ad(i)+coef
b(i)=b(i)+coef*vfa(6,ifa)
else
!
! outlet: no diffusion
!
endif
endif
!
! correction for non-orthogonal grid
!
if(.not.knownflux) then
b(i)=b(i)+difcoef*area(ifa)*
& (gradkfa(1,ifa)*xxni(1,indexf)+
& gradkfa(2,ifa)*xxni(2,indexf)+
& gradkfa(3,ifa)*xxni(3,indexf))
endif
endif
enddo
!
! viscous dissipation
!
rhovol=vel(i,5)*volume(i)
!
! sink terms are treated implicitly (lhs)
!
ad(i)=ad(i)+rhovol*0.09d0*vel(i,7)
!
! source terms are treated explicitly (rhs)
!
if(iturbulent.le.3) then
!
! k-epsilon, k-omega and BSL-model: the turbulent
! viscosity=k/omega
!
b(i)=b(i)+rhovol*vel(i,6)*((
& (2.d0*(gradvel(1,1,i)**2+gradvel(2,2,i)**2+
& gradvel(3,3,i)**2)+
& (gradvel(1,2,i)+gradvel(2,1,i))**2+
& (gradvel(1,3,i)+gradvel(3,1,i))**2+
& (gradvel(2,3,i)+gradvel(3,2,i))**2))/vel(i,7))
else
!
! SST model: other definition of the turbulent
! viscosity
!
b(i)=b(i)+rhovol*0.31d0*vel(i,6)*((
& (2.d0*(gradvel(1,1,i)**2+gradvel(2,2,i)**2+
& gradvel(3,3,i)**2)+
& (gradvel(1,2,i)+gradvel(2,1,i))**2+
& (gradvel(1,3,i)+gradvel(3,1,i))**2+
& (gradvel(2,3,i)+gradvel(3,2,i))**2))/
& max(0.31d0*vel(i,7),of2(i)))
endif
!
! transient term
!
b(i)=b(i)-(a2*velo(i,6)+a3*veloo(i,6))*rhovol
rhovol=a1*rhovol
ad(i)=ad(i)+rhovol
!
enddo
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.17/src/shape6tritilde_lin.f | 1 | 6422 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2020 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.
!
!
! function to evaluate transformed shape funciton \f$ shape(\xi,\eta) \f$
! for quad-lin mortar method, see phd-thesis Sitzmann Chapter 4.1.
!
! Author: Saskia Sitzmann
!
! [in] xi xi-coordinate
! [in] et eta-coordinate
! [in] xl local node coordinates
! [out] xsj jacobian vector
! [out] xs local derivative of the global coordinates
! [out] shp evaluated shape functions and derivatives
! [in] iflag flag indicating what to compute
!
subroutine shape6tritilde_lin(xi,et,xl,xsj,xs,shp,iflag)
!
! iflag=1: calculate only the value of the shape functions
! iflag=2: calculate the value of the shape functions,
! their derivatives w.r.t. the local coordinates
! and the Jacobian vector (local normal to the
! surface)
! iflag=3: calculate the value of the shape functions, the
! value of their derivatives w.r.t. the global
! coordinates and the Jacobian vector (local normal
! to the surface)
! iflag=4: calculate the value of the shape functions, the
! value of their 1st and 2nd order derivatives
! w.r.t. the local coordinates, the Jacobian vector
! (local normal to the surface)
!
! shape functions and derivatives for a 6-node quadratic
! isoparametric triangular element. 0<=xi,et<=1,xi+et<=1
!
implicit none
!
integer i,j,k,iflag
!
real*8 shp(7,8),xs(3,7),xsi(2,3),xl(3,8),sh(3),xsj(3)
!
real*8 xi,et
!
!
!
! shape functions and their glocal derivatives for an element
! described with two local parameters and three global ones.
!
! shape functions
!
shp(4,1)=1.d0-xi-et
shp(4,2)=xi
shp(4,3)=et
shp(4,4)=4.d0*xi*(1.d0-xi-et)
shp(4,5)=4.d0*xi*et
shp(4,6)=4.d0*et*(1.d0-xi-et)
!
! Caution: derivatives and exspecially jacobian for untransformed
! basis functions are given
! needed for consistent integration
!
if(iflag.eq.1) return
!
! local derivatives of the shape functions: xi-derivative
!
shp(1,1)=4.d0*(xi+et)-3.d0
shp(1,2)=4.d0*xi-1.d0
shp(1,3)=0.d0
shp(1,4)=4.d0*(1.d0-2.d0*xi-et)
shp(1,5)=4.d0*et
shp(1,6)=-4.d0*et
!
! local derivatives of the shape functions: eta-derivative
!
shp(2,1)=4.d0*(xi+et)-3.d0
shp(2,2)=0.d0
shp(2,3)=4.d0*et-1.d0
shp(2,4)=-4.d0*xi
shp(2,5)=4.d0*xi
shp(2,6)=4.d0*(1.d0-xi-2.d0*et)
!
! computation of the local derivative of the global coordinates
! (xs)
!
do i=1,3
do j=1,2
xs(i,j)=0.d0
do k=1,6
xs(i,j)=xs(i,j)+xl(i,k)*shp(j,k)
enddo
enddo
enddo
!
! computation of the jacobian vector
!
xsj(1)=xs(2,1)*xs(3,2)-xs(3,1)*xs(2,2)
xsj(2)=xs(1,2)*xs(3,1)-xs(3,2)*xs(1,1)
xsj(3)=xs(1,1)*xs(2,2)-xs(2,1)*xs(1,2)
!
if(iflag.eq.3) then
!
! computation of the global derivative of the local coordinates
! (xsi) (inversion of xs)
!
if(dabs(xsj(3)).gt.1.d-10) then
xsi(1,1)=xs(2,2)/xsj(3)
xsi(2,2)=xs(1,1)/xsj(3)
xsi(1,2)=-xs(1,2)/xsj(3)
xsi(2,1)=-xs(2,1)/xsj(3)
if(dabs(xsj(2)).gt.1.d-10) then
xsi(2,3)=xs(1,1)/(-xsj(2))
xsi(1,3)=-xs(1,2)/(-xsj(2))
elseif(dabs(xsj(1)).gt.1.d-10) then
xsi(2,3)=xs(2,1)/xsj(1)
xsi(1,3)=-xs(2,2)/xsj(1)
else
xsi(2,3)=0.d0
xsi(1,3)=0.d0
endif
elseif(dabs(xsj(2)).gt.1.d-10) then
xsi(1,1)=xs(3,2)/(-xsj(2))
xsi(2,3)=xs(1,1)/(-xsj(2))
xsi(1,3)=-xs(1,2)/(-xsj(2))
xsi(2,1)=-xs(3,1)/(-xsj(2))
if(dabs(xsj(1)).gt.1.d-10) then
xsi(1,2)=xs(3,2)/xsj(1)
xsi(2,2)=-xs(3,1)/xsj(1)
else
xsi(1,2)=0.d0
xsi(2,2)=0.d0
endif
else
xsi(1,2)=xs(3,2)/xsj(1)
xsi(2,3)=xs(2,1)/xsj(1)
xsi(1,3)=-xs(2,2)/xsj(1)
xsi(2,2)=-xs(3,1)/xsj(1)
xsi(1,1)=0.d0
xsi(2,1)=0.d0
endif
!
! computation of the global derivatives of the shape functions
!
do k=1,6
do j=1,3
sh(j)=shp(1,k)*xsi(1,j)+shp(2,k)*xsi(2,j)
enddo
do j=1,3
shp(j,k)=sh(j)
enddo
enddo
!
elseif(iflag.eq.4) then
!
! local 2nd order derivatives of the shape functions: xi,xi-derivative
!
shp(5,1)=0.d0
shp(5,2)=0.d0
shp(5,3)=0.d0
shp(5,4)=-8.d0
shp(5,5)=0.d0
shp(5,6)=0.d0
!
! local 2nd order derivatives of the shape functions: xi,eta-derivative
!
shp(6,1)=0.d0
shp(6,2)=0.d0
shp(6,3)=0.d0
shp(6,4)=-4.d0
shp(6,5)=4.d0
shp(6,6)=-4.d0
!
! local 2nd order derivatives of the shape functions: eta,eta-derivative
!
shp(7,1)=0.d0
shp(7,2)=0.d0
shp(7,3)=0.d0
shp(7,4)=0.d0
shp(7,5)=0.d0
shp(7,6)=-8.d0
!
! computation of the local 2nd derivatives of the global coordinates
! (xs)
!
do i=1,3
do j=5,7
xs(i,j)=0.d0
do k=1,6
xs(i,j)=xs(i,j)+xl(i,k)*shp(j,k)
enddo
enddo
enddo
endif
!
return
end
| gpl-2.0 |
epfl-cosmo/q-e | PW/src/get_locals.f90 | 19 | 2317 | !
! Copyright (C) 2005 PWSCF group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!---------------------------------------------------------------------------
subroutine get_locals(rholoc,magloc, rho)
!---------------------------------------------------------------------------
!
! Here local integrations are carried out around atoms.
! The points and weights for these integrations are determined in the
! subroutine make_pointlists, the result may be printed in the
! subroutine report_mag. If constraints are present, the results of this
! calculation are used in v_of_rho for determining the penalty functional.
!
USE kinds, ONLY : DP
USE ions_base, ONLY : nat
USE cell_base, ONLY : omega
USE lsda_mod, ONLY : nspin
USE mp_bands, ONLY : intra_bgrp_comm
USE mp, ONLY : mp_sum
USE fft_base, ONLY : dfftp
USE noncollin_module, ONLY : pointlist, factlist, noncolin
implicit none
!
! I/O variables
!
real(DP) :: &
rholoc(nat), & ! integrated charge arount the atoms
magloc(nspin-1,nat) ! integrated magnetic moment around the atom
real(DP) :: rho (dfftp%nnr, nspin)
!
! local variables
!
integer i,ipol
real(DP) :: fact
real(DP), allocatable :: auxrholoc(:,:)
allocate (auxrholoc(0:nat,nspin))
auxrholoc(:,:) = 0.d0
do i=1,dfftp%nnr
auxrholoc(pointlist(i),1:nspin) = auxrholoc(pointlist(i),1:nspin) + &
rho(i,1:nspin) * factlist(i)
end do
!
call mp_sum( auxrholoc( 0:nat, 1:nspin), intra_bgrp_comm )
!
fact = omega/(dfftp%nr1*dfftp%nr2*dfftp%nr3)
if (nspin.eq.2) then
rholoc(1:nat) = (auxrholoc(1:nat,1)+auxrholoc(1:nat,2)) * fact
magloc(1,1:nat) = (auxrholoc(1:nat,1)-auxrholoc(1:nat,2)) * fact
else
rholoc(1:nat) = auxrholoc(1:nat,1) * fact
if (noncolin) then
do ipol=1,3
magloc(ipol,1:nat) = auxrholoc(1:nat,ipol+1) * fact
end do
end if
endif
!
deallocate (auxrholoc)
end subroutine get_locals
| gpl-2.0 |
prool/ccx_prool | ARPACK_i8/LAPACK/classq.f | 5 | 3038 | SUBROUTINE CLASSQ( N, X, INCX, SCALE, SUMSQ )
*
* -- LAPACK auxiliary routine (version 2.0) --
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
* Courant Institute, Argonne National Lab, and Rice University
* October 31, 1992
*
* .. Scalar Arguments ..
INTEGER INCX, N
REAL SCALE, SUMSQ
* ..
* .. Array Arguments ..
COMPLEX X( * )
* ..
*
* Purpose
* =======
*
* CLASSQ returns the values scl and ssq such that
*
* ( scl**2 )*ssq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,
*
* where x( i ) = abs( X( 1 + ( i - 1 )*INCX ) ). The value of sumsq is
* assumed to be at least unity and the value of ssq will then satisfy
*
* 1.0 .le. ssq .le. ( sumsq + 2*n ).
*
* scale is assumed to be non-negative and scl returns the value
*
* scl = max( scale, abs( real( x( i ) ) ), abs( aimag( x( i ) ) ) ),
* i
*
* scale and sumsq must be supplied in SCALE and SUMSQ respectively.
* SCALE and SUMSQ are overwritten by scl and ssq respectively.
*
* The routine makes only one pass through the vector X.
*
* Arguments
* =========
*
* N (input) INTEGER
* The number of elements to be used from the vector X.
*
* X (input) REAL
* The vector x as described above.
* x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n.
*
* INCX (input) INTEGER
* The increment between successive values of the vector X.
* INCX > 0.
*
* SCALE (input/output) REAL
* On entry, the value scale in the equation above.
* On exit, SCALE is overwritten with the value scl .
*
* SUMSQ (input/output) REAL
* On entry, the value sumsq in the equation above.
* On exit, SUMSQ is overwritten with the value ssq .
*
* =====================================================================
*
* .. Parameters ..
REAL ZERO
PARAMETER ( ZERO = 0.0E+0 )
* ..
* .. Local Scalars ..
INTEGER IX
REAL TEMP1
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, AIMAG, REAL
* ..
* .. Executable Statements ..
*
IF( N.GT.0 ) THEN
DO 10 IX = 1, 1 + ( N-1 )*INCX, INCX
IF( REAL( X( IX ) ).NE.ZERO ) THEN
TEMP1 = ABS( REAL( X( IX ) ) )
IF( SCALE.LT.TEMP1 ) THEN
SUMSQ = 1 + SUMSQ*( SCALE / TEMP1 )**2
SCALE = TEMP1
ELSE
SUMSQ = SUMSQ + ( TEMP1 / SCALE )**2
END IF
END IF
IF( AIMAG( X( IX ) ).NE.ZERO ) THEN
TEMP1 = ABS( AIMAG( X( IX ) ) )
IF( SCALE.LT.TEMP1 ) THEN
SUMSQ = 1 + SUMSQ*( SCALE / TEMP1 )**2
SCALE = TEMP1
ELSE
SUMSQ = SUMSQ + ( TEMP1 / SCALE )**2
END IF
END IF
10 CONTINUE
END IF
*
RETURN
*
* End of CLASSQ
*
END
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/identamta.f | 6 | 1618 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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.
!
!
! identifies the position id of reftime in an ordered array
! amta(1,istart...iend) of real numbers; amta is defined as amta(2,*)
!
! id is such that amta(1,id).le.reftime and amta(1,id+1).gt.reftime
!
subroutine identamta(amta,reftime,istart,iend,id)
!
implicit none
!
integer id,istart,iend,n2,m
real*8 amta(2,*),reftime
id=istart-1
if(iend.lt.istart) return
n2=iend+1
do
m=(n2+id)/2
if(reftime.ge.amta(1,m)) then
id=m
else
n2=m
endif
if((n2-id).eq.1) return
enddo
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.8p2/src/identamta.f | 6 | 1618 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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.
!
!
! identifies the position id of reftime in an ordered array
! amta(1,istart...iend) of real numbers; amta is defined as amta(2,*)
!
! id is such that amta(1,id).le.reftime and amta(1,id+1).gt.reftime
!
subroutine identamta(amta,reftime,istart,iend,id)
!
implicit none
!
integer id,istart,iend,n2,m
real*8 amta(2,*),reftime
id=istart-1
if(iend.lt.istart) return
n2=iend+1
do
m=(n2+id)/2
if(reftime.ge.amta(1,m)) then
id=m
else
n2=m
endif
if((n2-id).eq.1) return
enddo
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/writepf.f | 6 | 2068 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 writepf(d,bjr,bji,freq,nev,mode,nherm)
!
! writes the participation factors to unit 5
!
implicit none
!
integer j,nev,mode,nherm
real*8 d(*),bjr(*),bji(*),freq,pi
!
pi=4.d0*datan(1.d0)
!
write(5,*)
if(mode.eq.0) then
write(5,100) freq
else
write(5,101) mode
endif
!
100 format('P A R T I C I P A T I O N F A C T O R S F O R',
&' F R E Q U E N C Y ',e20.13,' (CYCLES/TIME)')
101 format('P A R T I C I P A T I O N F A C T O R S F O R',
&' M O D E ',i5)
!
if(nherm.eq.1) then
write(5,*)
write(5,*) 'MODE NO FREQUENCY FACTOR'
write(5,*) ' (CYCLES/TIME) REAL IMAGINARY'
write(5,*)
do j=1,nev
write(5,'(i7,3(2x,e14.7))') j,d(j)/(2.d0*pi),bjr(j),bji(j)
enddo
else
write(5,*)
write(5,*)
&'MODE NO FREQ. (REAL) FREQ. (IMAG) FACTOR'
write(5,*)
&' (CYCLES/TIME) (RAD/TIME) REAL IMAGINARY'
write(5,*)
do j=1,nev
write(5,'(i7,4(2x,e14.7))') j,d(2*j-1)/(2.d0*pi),d(2*j),
& bjr(j),bji(j)
enddo
endif
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.8p2/src/resultsini_em.f | 2 | 11252 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 resultsini_em(nk,v,ithermal,filab,iperturb,f,fn,
& nactdof,iout,qa,b,nodeboun,ndirboun,
& xboun,nboun,ipompc,nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq,
& veold,dtime,mi,vini,nprint,prlab,
& intpointvarm,calcul_fn,calcul_f,calcul_qa,calcul_cauchy,iener,
& ikin,intpointvart,xforc,nforc)
!
! initialization
!
! 1. storing the calculated primary variables nodewise
! 2. inserting the boundary conditions nodewise (SPC's and MPC's)
! 3. determining which derived variables (strains, stresses,
! internal forces...) have to be calculated
!
implicit none
!
character*6 prlab(*)
character*20 labmpc(*)
character*87 filab(*)
!
integer mi(*),nactdof(0:mi(2),*),nodeboun(*),ndirboun(*),
& ipompc(*),nodempc(3,*),mt,nk,ithermal(2),i,j,
& iener,iperturb(*),iout,nboun,nmpc,nmethod,ist,ndir,node,index,
& neq,nprint,ikin,calcul_fn,nforc,
& calcul_f,calcul_cauchy,calcul_qa,intpointvarm,intpointvart,
& irefnode,irotnode,iexpnode,irefnodeprev
!
real*8 v(0:mi(2),*),vini(0:mi(2),*),f(*),fn(0:mi(2),*),
& cam(5),b(*),xboun(*),coefmpc(*),
& veold(0:mi(2),*),xforc(*),
& qa(3),dtime,bnac,
& fixed_disp
!
mt=mi(2)+1
!
if((iout.ne.2).and.(iout.gt.-1)) then
!
if((nmethod.ne.4).or.(iperturb(1).le.1)) then
if(ithermal(1).ne.2) then
do i=1,nk
do j=1,mi(2)
if(nactdof(j,i).ne.0) then
bnac=b(nactdof(j,i))
else
cycle
endif
v(j,i)=v(j,i)+bnac
if((iperturb(1).ne.0).and.(abs(nmethod).eq.1)) then
if(dabs(bnac).gt.cam(1)) then
cam(1)=dabs(bnac)
cam(4)=nactdof(j,i)-0.5d0
endif
endif
enddo
enddo
endif
if(ithermal(1).gt.1) then
do i=1,nk
if(nactdof(0,i).ne.0) then
bnac=b(nactdof(0,i))
else
cycle
endif
v(0,i)=v(0,i)+bnac
if((iperturb(1).ne.0).and.(abs(nmethod).eq.1)) then
if(dabs(bnac).gt.cam(2)) then
cam(2)=dabs(bnac)
cam(5)=nactdof(0,i)-0.5d0
endif
endif
enddo
endif
!
else
!
! direct integration dynamic step
! b contains the acceleration increment
!
if(ithermal(1).ne.2) then
do i=1,nk
do j=1,mi(2)
veold(j,i)=0.d0
if(nactdof(j,i).ne.0) then
bnac=b(nactdof(j,i))
else
cycle
endif
v(j,i)=v(j,i)+bnac
if(dabs(bnac).gt.cam(1)) then
cam(1)=dabs(bnac)
cam(4)=nactdof(j,i)-0.5d0
endif
enddo
enddo
endif
if(ithermal(1).gt.1) then
do i=1,nk
veold(0,i)=0.d0
if(nactdof(0,i).ne.0) then
bnac=b(nactdof(0,i))
else
cycle
endif
v(0,i)=v(0,i)+bnac
if(dabs(bnac).gt.cam(2)) then
cam(2)=dabs(bnac)
cam(5)=nactdof(0,i)-0.5d0
endif
cam(3)=max(cam(3),dabs(v(0,i)-vini(0,i)))
enddo
endif
endif
!
endif
!
! initialization
!
calcul_fn=0
calcul_f=0
calcul_qa=0
calcul_cauchy=0
!
! determining which quantities have to be calculated
!
if((iperturb(1).ge.2).or.((iperturb(1).le.0).and.(iout.lt.0)))
& then
if((iout.lt.1).and.(iout.gt.-2)) then
calcul_fn=1
calcul_f=1
calcul_qa=1
elseif((iout.ne.-2).and.(iperturb(2).eq.1)) then
calcul_cauchy=1
endif
endif
!
if(iout.gt.0) then
if((filab(5)(1:4).eq.'RF ').or.
& (filab(10)(1:4).eq.'RFL ')) then
calcul_fn=1
else
do i=1,nprint
if((prlab(i)(1:4).eq.'RF ').or.
& (prlab(i)(1:4).eq.'RFL ')) then
calcul_fn=1
exit
endif
enddo
endif
endif
!
! check whether user-defined concentrated forces were defined
!
do i=1,nforc
if((xforc(i).lt.1.2357111318d0).and.
& (xforc(i).gt.1.2357111316d0)) then
calcul_fn=1
exit
endif
enddo
!
! initializing fn
!
if(calcul_fn.eq.1) then
do i=1,nk
do j=0,mi(2)
fn(j,i)=0.d0
enddo
enddo
endif
!
! initializing f
!
if(calcul_f.eq.1) then
do i=1,neq
f(i)=0.d0
enddo
endif
!
! SPC's and MPC's have to be taken into account for
! iout=0,1 and -1
!
if(abs(iout).lt.2) then
!
! inserting the boundary conditions
!
do i=1,nboun
if(ndirboun(i).gt.mi(2)) cycle
fixed_disp=xboun(i)
c if((nmethod.eq.4).and.(iperturb(1).gt.1)) then
c ndir=ndirboun(i)
c node=nodeboun(i)
c veold(ndir,node)=(xboun(i)-v(ndir,node))/dtime
c endif
v(ndirboun(i),nodeboun(i))=fixed_disp
enddo
!
! inserting the mpc information
!
do i=1,nmpc
ist=ipompc(i)
node=nodempc(1,ist)
ndir=nodempc(2,ist)
if(ndir.eq.0) then
if(ithermal(1).lt.2) cycle
elseif(ndir.gt.mi(2)) then
cycle
else
if(ithermal(1).eq.2) cycle
endif
index=nodempc(3,ist)
fixed_disp=0.d0
if(index.ne.0) then
do
fixed_disp=fixed_disp-coefmpc(index)*
& v(nodempc(2,index),nodempc(1,index))
index=nodempc(3,index)
if(index.eq.0) exit
enddo
endif
fixed_disp=fixed_disp/coefmpc(ist)
v(ndir,node)=fixed_disp
enddo
endif
!
! storing the knot information in the .dat-file
!
irefnodeprev=0
do i=1,nmpc
if(iout.gt.0) then
if(labmpc(i)(1:4).eq.'KNOT') then
irefnode=nodempc(1,nodempc(3,ipompc(i)))
if(irefnode.ne.irefnodeprev) then
irefnodeprev=irefnode
iexpnode=nodempc(1,nodempc(3,nodempc(3,ipompc(i))))
if(labmpc(i)(5:5).ne.'2') then
irotnode=nodempc(1,nodempc(3,nodempc(3,
& nodempc(3,ipompc(i)))))
else
irotnode=nodempc(1,nodempc(3,nodempc(3,
& nodempc(3,nodempc(3,nodempc(3,ipompc(i)))))))
endif
write(5,*)
write(5,'(a5)') labmpc(i)(1:5)
write(5,'("tra",i5,3(1x,e11.4))')
& irefnode,(v(j,irefnode),j=1,3)
write(5,'("rot",i5,3(1x,e11.4))')
& irotnode,(v(j,irotnode),j=1,3)
if(labmpc(i)(5:5).eq.'2') then
write(5,'("exp",i5,3(1x,e11.4))')
& iexpnode,(v(j,iexpnode),j=1,3)
else
write(5,'("exp",i5,3(1x,e11.4))')
& iexpnode,v(1,iexpnode)
endif
endif
endif
endif
enddo
!
! check whether there are any strain output requests
!
iener=0
ikin=0
if((filab(7)(1:4).eq.'ENER').or.(filab(27)(1:4).eq.'CELS')) then
iener=1
endif
do i=1,nprint
if((prlab(i)(1:4).eq.'ENER').or.(prlab(i)(1:4).eq.'ELSE').or.
& (prlab(i)(1:4).eq.'CELS')) then
iener=1
elseif(prlab(i)(1:4).eq.'ELKE') then
ikin=1
endif
enddo
!
qa(1)=0.d0
qa(2)=0.d0
!
! check whether integration point variables are needed in
! modal dynamics and steady state dynamics calculations
!
intpointvarm=1
intpointvart=1
!
if((nmethod.ge.4).and.(iperturb(1).lt.2)) then
intpointvarm=0
if((filab(3)(1:4).eq.'S ').or.
& (filab(4)(1:4).eq.'E ').or.
& (filab(5)(1:4).eq.'RF ').or.
& (filab(6)(1:4).eq.'PEEQ').or.
& (filab(7)(1:4).eq.'ENER').or.
& (filab(8)(1:4).eq.'SDV ').or.
& (filab(13)(1:4).eq.'ZZS ').or.
& (filab(13)(1:4).eq.'ERR ').or.
& (filab(18)(1:4).eq.'PHS ').or.
& (filab(20)(1:4).eq.'MAXS').or.
& (filab(26)(1:4).eq.'CONT').or.
& (filab(27)(1:4).eq.'CELS')) intpointvarm=1
do i=1,nprint
if((prlab(i)(1:4).eq.'S ').or.
& (prlab(i)(1:4).eq.'E ').or.
& (prlab(i)(1:4).eq.'PEEQ').or.
& (prlab(i)(1:4).eq.'ENER').or.
& (prlab(i)(1:4).eq.'ELKE').or.
& (prlab(i)(1:4).eq.'CDIS').or.
& (prlab(i)(1:4).eq.'CSTR').or.
& (prlab(i)(1:4).eq.'CELS').or.
& (prlab(i)(1:4).eq.'SDV ').or.
& (prlab(i)(1:4).eq.'RF ')) then
intpointvarm=1
exit
endif
enddo
!
intpointvart=0
if((filab(9)(1:4).eq.'HFL ').or.
& (filab(10)(1:4).eq.'RFL ')) intpointvart=1
do i=1,nprint
if((prlab(i)(1:4).eq.'HFL ').or.
& (prlab(i)(1:4).eq.'RFL ')) intpointvart=1
enddo
!
! if internal forces are requested integration point
! values have to be calculated
!
if(calcul_fn.eq.1) then
intpointvarm=1
intpointvart=1
endif
endif
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/xlocal.f | 10 | 9640 | !
! 3D local of the gauss points within the faces of
! the elements
!
! xlocal8r: C3D8R element
! xlocal8: C3D8 and C3D20R element
! xlocal20: C3D20 element
! xlocal4: C3D4 element
! xlocal10: C3D10 element
! xlocal6: C3D6 element
! xlocal15: C3D15 element
!
xlocal8r=reshape((/
& 0.000000000000000D+0, 0.000000000000000D+0,-0.100000000000000D+1
&, 0.000000000000000D+0, 0.000000000000000D+0, 0.100000000000000D+1
&, 0.000000000000000D+0,-0.100000000000000D+1, 0.000000000000000D+0
&, 0.100000000000000D+1, 0.000000000000000D+0, 0.000000000000000D+0
&, 0.000000000000000D+0, 0.100000000000000D+1, 0.000000000000000D+0
&,-0.100000000000000D+1, 0.000000000000000D+0,0.000000000000000D+0/
&),(/3,1,6/))
!
xlocal8=reshape((/
&-0.577350269189626D+0, 0.577350269189626D+0,-0.100000000000000D+1
&, 0.577350269189626D+0, 0.577350269189626D+0,-0.100000000000000D+1
&,-0.577350269189626D+0,-0.577350269189626D+0,-0.100000000000000D+1
&, 0.577350269189626D+0,-0.577350269189626D+0,-0.100000000000000D+1
&,-0.577350269189626D+0,-0.577350269189626D+0, 0.100000000000000D+1
&, 0.577350269189626D+0,-0.577350269189626D+0, 0.100000000000000D+1
&,-0.577350269189626D+0, 0.577350269189626D+0, 0.100000000000000D+1
&, 0.577350269189626D+0, 0.577350269189626D+0, 0.100000000000000D+1
&,-0.577350269189626D+0,-0.100000000000000D+1,-0.577350269189626D+0
&, 0.577350269189626D+0,-0.100000000000000D+1,-0.577350269189626D+0
&,-0.577350269189626D+0,-0.100000000000000D+1, 0.577350269189626D+0
&, 0.577350269189626D+0,-0.100000000000000D+1, 0.577350269189626D+0
&, 0.100000000000000D+1,-0.577350269189626D+0,-0.577350269189626D+0
&, 0.100000000000000D+1, 0.577350269189626D+0,-0.577350269189626D+0
&, 0.100000000000000D+1,-0.577350269189626D+0, 0.577350269189626D+0
&, 0.100000000000000D+1, 0.577350269189626D+0, 0.577350269189626D+0
&, 0.577350269189626D+0, 0.100000000000000D+1,-0.577350269189626D+0
&,-0.577350269189626D+0, 0.100000000000000D+1,-0.577350269189626D+0
&, 0.577350269189626D+0, 0.100000000000000D+1, 0.577350269189626D+0
&,-0.577350269189626D+0, 0.100000000000000D+1, 0.577350269189626D+0
&,-0.100000000000000D+1, 0.577350269189626D+0,-0.577350269189626D+0
&,-0.100000000000000D+1,-0.577350269189626D+0,-0.577350269189626D+0
&,-0.100000000000000D+1, 0.577350269189626D+0, 0.577350269189626D+0
&,-0.100000000000000D+1,-0.577350269189626D+0,0.577350269189626D+0/
&),(/3,4,6/))
!
xlocal20=reshape((/
&-0.774596669241483D+0, 0.774596669241483D+0,-0.100000000000000D+1
&, 0.000000000000000D+0, 0.774596669241483D+0,-0.100000000000000D+1
&, 0.774596669241483D+0, 0.774596669241483D+0,-0.100000000000000D+1
&,-0.774596669241483D+0, 0.000000000000000D+0,-0.100000000000000D+1
&, 0.000000000000000D+0, 0.000000000000000D+0,-0.100000000000000D+1
&, 0.774596669241483D+0, 0.000000000000000D+0,-0.100000000000000D+1
&,-0.774596669241483D+0,-0.774596669241483D+0,-0.100000000000000D+1
&, 0.000000000000000D+0,-0.774596669241483D+0,-0.100000000000000D+1
&, 0.774596669241483D+0,-0.774596669241483D+0,-0.100000000000000D+1
&,-0.774596669241483D+0,-0.774596669241483D+0, 0.100000000000000D+1
&, 0.000000000000000D+0,-0.774596669241483D+0, 0.100000000000000D+1
&, 0.774596669241483D+0,-0.774596669241483D+0, 0.100000000000000D+1
&,-0.774596669241483D+0, 0.000000000000000D+0, 0.100000000000000D+1
&, 0.000000000000000D+0, 0.000000000000000D+0, 0.100000000000000D+1
&, 0.774596669241483D+0, 0.000000000000000D+0, 0.100000000000000D+1
&,-0.774596669241483D+0, 0.774596669241483D+0, 0.100000000000000D+1
&, 0.000000000000000D+0, 0.774596669241483D+0, 0.100000000000000D+1
&, 0.774596669241483D+0, 0.774596669241483D+0, 0.100000000000000D+1
&,-0.774596669241483D+0,-0.100000000000000D+1,-0.774596669241483D+0
&, 0.000000000000000D+0,-0.100000000000000D+1,-0.774596669241483D+0
&, 0.774596669241483D+0,-0.100000000000000D+1,-0.774596669241483D+0
&,-0.774596669241483D+0,-0.100000000000000D+1, 0.000000000000000D+0
&, 0.000000000000000D+0,-0.100000000000000D+1, 0.000000000000000D+0
&, 0.774596669241483D+0,-0.100000000000000D+1, 0.000000000000000D+0
&,-0.774596669241483D+0,-0.100000000000000D+1, 0.774596669241483D+0
&, 0.000000000000000D+0,-0.100000000000000D+1, 0.774596669241483D+0
&, 0.774596669241483D+0,-0.100000000000000D+1, 0.774596669241483D+0
&, 0.100000000000000D+1,-0.774596669241483D+0,-0.774596669241483D+0
&, 0.100000000000000D+1, 0.000000000000000D+0,-0.774596669241483D+0
&, 0.100000000000000D+1, 0.774596669241483D+0,-0.774596669241483D+0
&, 0.100000000000000D+1,-0.774596669241483D+0, 0.000000000000000D+0
&, 0.100000000000000D+1, 0.000000000000000D+0, 0.000000000000000D+0
&, 0.100000000000000D+1, 0.774596669241483D+0, 0.000000000000000D+0
&, 0.100000000000000D+1,-0.774596669241483D+0, 0.774596669241483D+0
&, 0.100000000000000D+1, 0.000000000000000D+0, 0.774596669241483D+0
&, 0.100000000000000D+1, 0.774596669241483D+0, 0.774596669241483D+0
&, 0.774596669241483D+0, 0.100000000000000D+1,-0.774596669241483D+0
&, 0.000000000000000D+0, 0.100000000000000D+1,-0.774596669241483D+0
&,-0.774596669241483D+0, 0.100000000000000D+1,-0.774596669241483D+0
&, 0.774596669241483D+0, 0.100000000000000D+1, 0.000000000000000D+0
&, 0.000000000000000D+0, 0.100000000000000D+1, 0.000000000000000D+0
&,-0.774596669241483D+0, 0.100000000000000D+1, 0.000000000000000D+0
&, 0.774596669241483D+0, 0.100000000000000D+1, 0.774596669241483D+0
&, 0.000000000000000D+0, 0.100000000000000D+1, 0.774596669241483D+0
&,-0.774596669241483D+0, 0.100000000000000D+1, 0.774596669241483D+0
&,-0.100000000000000D+1, 0.774596669241483D+0,-0.774596669241483D+0
&,-0.100000000000000D+1, 0.000000000000000D+0,-0.774596669241483D+0
&,-0.100000000000000D+1,-0.774596669241483D+0,-0.774596669241483D+0
&,-0.100000000000000D+1, 0.774596669241483D+0, 0.000000000000000D+0
&,-0.100000000000000D+1, 0.000000000000000D+0, 0.000000000000000D+0
&,-0.100000000000000D+1,-0.774596669241483D+0, 0.000000000000000D+0
&,-0.100000000000000D+1, 0.774596669241483D+0, 0.774596669241483D+0
&,-0.100000000000000D+1, 0.000000000000000D+0, 0.774596669241483D+0
&,-0.100000000000000D+1,-0.774596669241483D+0,0.774596669241483D+0/
&),(/3,9,6/))
!
xlocal4=reshape((/
& 0.333333333333333D+0, 0.333333333333333D+0, 0.000000000000000D+0
&, 0.333333333333333D+0, 0.000000000000000D+0, 0.333333333333333D+0
&, 0.333333333333334D+0, 0.333333333333333D+0, 0.333333333333333D+0
&, 0.000000000000000D+0, 0.333333333333333D+0,0.333333333333333D+0/
&),(/3,1,4/))
!
xlocal10=reshape((/
& 0.166666666666667D+0, 0.166666666666667D+0, 0.000000000000000D+0
&, 0.166666666666667D+0, 0.666666666666667D+0, 0.000000000000000D+0
&, 0.666666666666667D+0, 0.166666666666667D+0, 0.000000000000000D+0
&, 0.166666666666667D+0, 0.000000000000000D+0, 0.166666666666667D+0
&, 0.666666666666667D+0, 0.000000000000000D+0, 0.166666666666667D+0
&, 0.166666666666667D+0, 0.000000000000000D+0, 0.666666666666667D+0
&, 0.666666666666666D+0, 0.166666666666667D+0, 0.166666666666667D+0
&, 0.166666666666666D+0, 0.666666666666667D+0, 0.166666666666667D+0
&, 0.166666666666666D+0, 0.166666666666667D+0, 0.666666666666667D+0
&, 0.000000000000000D+0, 0.166666666666667D+0, 0.166666666666667D+0
&, 0.000000000000000D+0, 0.166666666666667D+0, 0.666666666666667D+0
&, 0.000000000000000D+0, 0.666666666666667D+0,0.166666666666667D+0/
&),(/3,3,4/))
!
xlocal6=reshape((/
& 0.333333333333333D+0, 0.333333333333333D+0,-0.100000000000000D+1
&, 0.333333333333333D+0, 0.333333333333333D+0, 0.100000000000000D+1
&, 0.500000000000000D+0, 0.000000000000000D+0, 0.000000000000000D+0
&, 0.500000000000000D+0, 0.500000000000000D+0, 0.000000000000000D+0
&, 0.000000000000000D+0, 0.500000000000000D+0,0.000000000000000D+0/
&),(/3,1,5/))
!
xlocal15=reshape((/
& 0.166666666666667D+0, 0.166666666666667D+0,-0.100000000000000D+1
&, 0.166666666666667D+0, 0.666666666666667D+0,-0.100000000000000D+1
&, 0.666666666666667D+0, 0.166666666666667D+0,-0.100000000000000D+1
&, 0.d0,0.d0,0.d0
&, 0.166666666666667D+0, 0.166666666666667D+0, 0.100000000000000D+1
&, 0.666666666666667D+0, 0.166666666666667D+0, 0.100000000000000D+1
&, 0.166666666666667D+0, 0.666666666666667D+0, 0.100000000000000D+1
&, 0.d0,0.d0,0.d0
&, 0.211324865405187D+0, 0.000000000000000D+0,-0.577350269189626D+0
&, 0.788675134594813D+0, 0.000000000000000D+0,-0.577350269189626D+0
&, 0.211324865405187D+0, 0.000000000000000D+0, 0.577350269189626D+0
&, 0.788675134594813D+0, 0.000000000000000D+0, 0.577350269189626D+0
&, 0.788675134594813D+0, 0.211324865405187D+0,-0.577350269189626D+0
&, 0.211324865405187D+0, 0.788675134594813D+0,-0.577350269189626D+0
&, 0.788675134594813D+0, 0.211324865405187D+0, 0.577350269189626D+0
&, 0.211324865405187D+0, 0.788675134594813D+0, 0.577350269189626D+0
&, 0.000000000000000D+0, 0.211324865405187D+0, 0.577350269189626D+0
&, 0.000000000000000D+0, 0.788675134594813D+0, 0.577350269189626D+0
&, 0.000000000000000D+0, 0.211324865405187D+0,-0.577350269189626D+0
&, 0.000000000000000D+0,0.788675134594813D+0,-0.577350269189626D+0/
&),(/3,4,5/))
!
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.8p2/src/xlocal.f | 10 | 9640 | !
! 3D local of the gauss points within the faces of
! the elements
!
! xlocal8r: C3D8R element
! xlocal8: C3D8 and C3D20R element
! xlocal20: C3D20 element
! xlocal4: C3D4 element
! xlocal10: C3D10 element
! xlocal6: C3D6 element
! xlocal15: C3D15 element
!
xlocal8r=reshape((/
& 0.000000000000000D+0, 0.000000000000000D+0,-0.100000000000000D+1
&, 0.000000000000000D+0, 0.000000000000000D+0, 0.100000000000000D+1
&, 0.000000000000000D+0,-0.100000000000000D+1, 0.000000000000000D+0
&, 0.100000000000000D+1, 0.000000000000000D+0, 0.000000000000000D+0
&, 0.000000000000000D+0, 0.100000000000000D+1, 0.000000000000000D+0
&,-0.100000000000000D+1, 0.000000000000000D+0,0.000000000000000D+0/
&),(/3,1,6/))
!
xlocal8=reshape((/
&-0.577350269189626D+0, 0.577350269189626D+0,-0.100000000000000D+1
&, 0.577350269189626D+0, 0.577350269189626D+0,-0.100000000000000D+1
&,-0.577350269189626D+0,-0.577350269189626D+0,-0.100000000000000D+1
&, 0.577350269189626D+0,-0.577350269189626D+0,-0.100000000000000D+1
&,-0.577350269189626D+0,-0.577350269189626D+0, 0.100000000000000D+1
&, 0.577350269189626D+0,-0.577350269189626D+0, 0.100000000000000D+1
&,-0.577350269189626D+0, 0.577350269189626D+0, 0.100000000000000D+1
&, 0.577350269189626D+0, 0.577350269189626D+0, 0.100000000000000D+1
&,-0.577350269189626D+0,-0.100000000000000D+1,-0.577350269189626D+0
&, 0.577350269189626D+0,-0.100000000000000D+1,-0.577350269189626D+0
&,-0.577350269189626D+0,-0.100000000000000D+1, 0.577350269189626D+0
&, 0.577350269189626D+0,-0.100000000000000D+1, 0.577350269189626D+0
&, 0.100000000000000D+1,-0.577350269189626D+0,-0.577350269189626D+0
&, 0.100000000000000D+1, 0.577350269189626D+0,-0.577350269189626D+0
&, 0.100000000000000D+1,-0.577350269189626D+0, 0.577350269189626D+0
&, 0.100000000000000D+1, 0.577350269189626D+0, 0.577350269189626D+0
&, 0.577350269189626D+0, 0.100000000000000D+1,-0.577350269189626D+0
&,-0.577350269189626D+0, 0.100000000000000D+1,-0.577350269189626D+0
&, 0.577350269189626D+0, 0.100000000000000D+1, 0.577350269189626D+0
&,-0.577350269189626D+0, 0.100000000000000D+1, 0.577350269189626D+0
&,-0.100000000000000D+1, 0.577350269189626D+0,-0.577350269189626D+0
&,-0.100000000000000D+1,-0.577350269189626D+0,-0.577350269189626D+0
&,-0.100000000000000D+1, 0.577350269189626D+0, 0.577350269189626D+0
&,-0.100000000000000D+1,-0.577350269189626D+0,0.577350269189626D+0/
&),(/3,4,6/))
!
xlocal20=reshape((/
&-0.774596669241483D+0, 0.774596669241483D+0,-0.100000000000000D+1
&, 0.000000000000000D+0, 0.774596669241483D+0,-0.100000000000000D+1
&, 0.774596669241483D+0, 0.774596669241483D+0,-0.100000000000000D+1
&,-0.774596669241483D+0, 0.000000000000000D+0,-0.100000000000000D+1
&, 0.000000000000000D+0, 0.000000000000000D+0,-0.100000000000000D+1
&, 0.774596669241483D+0, 0.000000000000000D+0,-0.100000000000000D+1
&,-0.774596669241483D+0,-0.774596669241483D+0,-0.100000000000000D+1
&, 0.000000000000000D+0,-0.774596669241483D+0,-0.100000000000000D+1
&, 0.774596669241483D+0,-0.774596669241483D+0,-0.100000000000000D+1
&,-0.774596669241483D+0,-0.774596669241483D+0, 0.100000000000000D+1
&, 0.000000000000000D+0,-0.774596669241483D+0, 0.100000000000000D+1
&, 0.774596669241483D+0,-0.774596669241483D+0, 0.100000000000000D+1
&,-0.774596669241483D+0, 0.000000000000000D+0, 0.100000000000000D+1
&, 0.000000000000000D+0, 0.000000000000000D+0, 0.100000000000000D+1
&, 0.774596669241483D+0, 0.000000000000000D+0, 0.100000000000000D+1
&,-0.774596669241483D+0, 0.774596669241483D+0, 0.100000000000000D+1
&, 0.000000000000000D+0, 0.774596669241483D+0, 0.100000000000000D+1
&, 0.774596669241483D+0, 0.774596669241483D+0, 0.100000000000000D+1
&,-0.774596669241483D+0,-0.100000000000000D+1,-0.774596669241483D+0
&, 0.000000000000000D+0,-0.100000000000000D+1,-0.774596669241483D+0
&, 0.774596669241483D+0,-0.100000000000000D+1,-0.774596669241483D+0
&,-0.774596669241483D+0,-0.100000000000000D+1, 0.000000000000000D+0
&, 0.000000000000000D+0,-0.100000000000000D+1, 0.000000000000000D+0
&, 0.774596669241483D+0,-0.100000000000000D+1, 0.000000000000000D+0
&,-0.774596669241483D+0,-0.100000000000000D+1, 0.774596669241483D+0
&, 0.000000000000000D+0,-0.100000000000000D+1, 0.774596669241483D+0
&, 0.774596669241483D+0,-0.100000000000000D+1, 0.774596669241483D+0
&, 0.100000000000000D+1,-0.774596669241483D+0,-0.774596669241483D+0
&, 0.100000000000000D+1, 0.000000000000000D+0,-0.774596669241483D+0
&, 0.100000000000000D+1, 0.774596669241483D+0,-0.774596669241483D+0
&, 0.100000000000000D+1,-0.774596669241483D+0, 0.000000000000000D+0
&, 0.100000000000000D+1, 0.000000000000000D+0, 0.000000000000000D+0
&, 0.100000000000000D+1, 0.774596669241483D+0, 0.000000000000000D+0
&, 0.100000000000000D+1,-0.774596669241483D+0, 0.774596669241483D+0
&, 0.100000000000000D+1, 0.000000000000000D+0, 0.774596669241483D+0
&, 0.100000000000000D+1, 0.774596669241483D+0, 0.774596669241483D+0
&, 0.774596669241483D+0, 0.100000000000000D+1,-0.774596669241483D+0
&, 0.000000000000000D+0, 0.100000000000000D+1,-0.774596669241483D+0
&,-0.774596669241483D+0, 0.100000000000000D+1,-0.774596669241483D+0
&, 0.774596669241483D+0, 0.100000000000000D+1, 0.000000000000000D+0
&, 0.000000000000000D+0, 0.100000000000000D+1, 0.000000000000000D+0
&,-0.774596669241483D+0, 0.100000000000000D+1, 0.000000000000000D+0
&, 0.774596669241483D+0, 0.100000000000000D+1, 0.774596669241483D+0
&, 0.000000000000000D+0, 0.100000000000000D+1, 0.774596669241483D+0
&,-0.774596669241483D+0, 0.100000000000000D+1, 0.774596669241483D+0
&,-0.100000000000000D+1, 0.774596669241483D+0,-0.774596669241483D+0
&,-0.100000000000000D+1, 0.000000000000000D+0,-0.774596669241483D+0
&,-0.100000000000000D+1,-0.774596669241483D+0,-0.774596669241483D+0
&,-0.100000000000000D+1, 0.774596669241483D+0, 0.000000000000000D+0
&,-0.100000000000000D+1, 0.000000000000000D+0, 0.000000000000000D+0
&,-0.100000000000000D+1,-0.774596669241483D+0, 0.000000000000000D+0
&,-0.100000000000000D+1, 0.774596669241483D+0, 0.774596669241483D+0
&,-0.100000000000000D+1, 0.000000000000000D+0, 0.774596669241483D+0
&,-0.100000000000000D+1,-0.774596669241483D+0,0.774596669241483D+0/
&),(/3,9,6/))
!
xlocal4=reshape((/
& 0.333333333333333D+0, 0.333333333333333D+0, 0.000000000000000D+0
&, 0.333333333333333D+0, 0.000000000000000D+0, 0.333333333333333D+0
&, 0.333333333333334D+0, 0.333333333333333D+0, 0.333333333333333D+0
&, 0.000000000000000D+0, 0.333333333333333D+0,0.333333333333333D+0/
&),(/3,1,4/))
!
xlocal10=reshape((/
& 0.166666666666667D+0, 0.166666666666667D+0, 0.000000000000000D+0
&, 0.166666666666667D+0, 0.666666666666667D+0, 0.000000000000000D+0
&, 0.666666666666667D+0, 0.166666666666667D+0, 0.000000000000000D+0
&, 0.166666666666667D+0, 0.000000000000000D+0, 0.166666666666667D+0
&, 0.666666666666667D+0, 0.000000000000000D+0, 0.166666666666667D+0
&, 0.166666666666667D+0, 0.000000000000000D+0, 0.666666666666667D+0
&, 0.666666666666666D+0, 0.166666666666667D+0, 0.166666666666667D+0
&, 0.166666666666666D+0, 0.666666666666667D+0, 0.166666666666667D+0
&, 0.166666666666666D+0, 0.166666666666667D+0, 0.666666666666667D+0
&, 0.000000000000000D+0, 0.166666666666667D+0, 0.166666666666667D+0
&, 0.000000000000000D+0, 0.166666666666667D+0, 0.666666666666667D+0
&, 0.000000000000000D+0, 0.666666666666667D+0,0.166666666666667D+0/
&),(/3,3,4/))
!
xlocal6=reshape((/
& 0.333333333333333D+0, 0.333333333333333D+0,-0.100000000000000D+1
&, 0.333333333333333D+0, 0.333333333333333D+0, 0.100000000000000D+1
&, 0.500000000000000D+0, 0.000000000000000D+0, 0.000000000000000D+0
&, 0.500000000000000D+0, 0.500000000000000D+0, 0.000000000000000D+0
&, 0.000000000000000D+0, 0.500000000000000D+0,0.000000000000000D+0/
&),(/3,1,5/))
!
xlocal15=reshape((/
& 0.166666666666667D+0, 0.166666666666667D+0,-0.100000000000000D+1
&, 0.166666666666667D+0, 0.666666666666667D+0,-0.100000000000000D+1
&, 0.666666666666667D+0, 0.166666666666667D+0,-0.100000000000000D+1
&, 0.d0,0.d0,0.d0
&, 0.166666666666667D+0, 0.166666666666667D+0, 0.100000000000000D+1
&, 0.666666666666667D+0, 0.166666666666667D+0, 0.100000000000000D+1
&, 0.166666666666667D+0, 0.666666666666667D+0, 0.100000000000000D+1
&, 0.d0,0.d0,0.d0
&, 0.211324865405187D+0, 0.000000000000000D+0,-0.577350269189626D+0
&, 0.788675134594813D+0, 0.000000000000000D+0,-0.577350269189626D+0
&, 0.211324865405187D+0, 0.000000000000000D+0, 0.577350269189626D+0
&, 0.788675134594813D+0, 0.000000000000000D+0, 0.577350269189626D+0
&, 0.788675134594813D+0, 0.211324865405187D+0,-0.577350269189626D+0
&, 0.211324865405187D+0, 0.788675134594813D+0,-0.577350269189626D+0
&, 0.788675134594813D+0, 0.211324865405187D+0, 0.577350269189626D+0
&, 0.211324865405187D+0, 0.788675134594813D+0, 0.577350269189626D+0
&, 0.000000000000000D+0, 0.211324865405187D+0, 0.577350269189626D+0
&, 0.000000000000000D+0, 0.788675134594813D+0, 0.577350269189626D+0
&, 0.000000000000000D+0, 0.211324865405187D+0,-0.577350269189626D+0
&, 0.000000000000000D+0,0.788675134594813D+0,-0.577350269189626D+0/
&),(/3,4,5/))
!
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.11/src/xlocal.f | 10 | 9640 | !
! 3D local of the gauss points within the faces of
! the elements
!
! xlocal8r: C3D8R element
! xlocal8: C3D8 and C3D20R element
! xlocal20: C3D20 element
! xlocal4: C3D4 element
! xlocal10: C3D10 element
! xlocal6: C3D6 element
! xlocal15: C3D15 element
!
xlocal8r=reshape((/
& 0.000000000000000D+0, 0.000000000000000D+0,-0.100000000000000D+1
&, 0.000000000000000D+0, 0.000000000000000D+0, 0.100000000000000D+1
&, 0.000000000000000D+0,-0.100000000000000D+1, 0.000000000000000D+0
&, 0.100000000000000D+1, 0.000000000000000D+0, 0.000000000000000D+0
&, 0.000000000000000D+0, 0.100000000000000D+1, 0.000000000000000D+0
&,-0.100000000000000D+1, 0.000000000000000D+0,0.000000000000000D+0/
&),(/3,1,6/))
!
xlocal8=reshape((/
&-0.577350269189626D+0, 0.577350269189626D+0,-0.100000000000000D+1
&, 0.577350269189626D+0, 0.577350269189626D+0,-0.100000000000000D+1
&,-0.577350269189626D+0,-0.577350269189626D+0,-0.100000000000000D+1
&, 0.577350269189626D+0,-0.577350269189626D+0,-0.100000000000000D+1
&,-0.577350269189626D+0,-0.577350269189626D+0, 0.100000000000000D+1
&, 0.577350269189626D+0,-0.577350269189626D+0, 0.100000000000000D+1
&,-0.577350269189626D+0, 0.577350269189626D+0, 0.100000000000000D+1
&, 0.577350269189626D+0, 0.577350269189626D+0, 0.100000000000000D+1
&,-0.577350269189626D+0,-0.100000000000000D+1,-0.577350269189626D+0
&, 0.577350269189626D+0,-0.100000000000000D+1,-0.577350269189626D+0
&,-0.577350269189626D+0,-0.100000000000000D+1, 0.577350269189626D+0
&, 0.577350269189626D+0,-0.100000000000000D+1, 0.577350269189626D+0
&, 0.100000000000000D+1,-0.577350269189626D+0,-0.577350269189626D+0
&, 0.100000000000000D+1, 0.577350269189626D+0,-0.577350269189626D+0
&, 0.100000000000000D+1,-0.577350269189626D+0, 0.577350269189626D+0
&, 0.100000000000000D+1, 0.577350269189626D+0, 0.577350269189626D+0
&, 0.577350269189626D+0, 0.100000000000000D+1,-0.577350269189626D+0
&,-0.577350269189626D+0, 0.100000000000000D+1,-0.577350269189626D+0
&, 0.577350269189626D+0, 0.100000000000000D+1, 0.577350269189626D+0
&,-0.577350269189626D+0, 0.100000000000000D+1, 0.577350269189626D+0
&,-0.100000000000000D+1, 0.577350269189626D+0,-0.577350269189626D+0
&,-0.100000000000000D+1,-0.577350269189626D+0,-0.577350269189626D+0
&,-0.100000000000000D+1, 0.577350269189626D+0, 0.577350269189626D+0
&,-0.100000000000000D+1,-0.577350269189626D+0,0.577350269189626D+0/
&),(/3,4,6/))
!
xlocal20=reshape((/
&-0.774596669241483D+0, 0.774596669241483D+0,-0.100000000000000D+1
&, 0.000000000000000D+0, 0.774596669241483D+0,-0.100000000000000D+1
&, 0.774596669241483D+0, 0.774596669241483D+0,-0.100000000000000D+1
&,-0.774596669241483D+0, 0.000000000000000D+0,-0.100000000000000D+1
&, 0.000000000000000D+0, 0.000000000000000D+0,-0.100000000000000D+1
&, 0.774596669241483D+0, 0.000000000000000D+0,-0.100000000000000D+1
&,-0.774596669241483D+0,-0.774596669241483D+0,-0.100000000000000D+1
&, 0.000000000000000D+0,-0.774596669241483D+0,-0.100000000000000D+1
&, 0.774596669241483D+0,-0.774596669241483D+0,-0.100000000000000D+1
&,-0.774596669241483D+0,-0.774596669241483D+0, 0.100000000000000D+1
&, 0.000000000000000D+0,-0.774596669241483D+0, 0.100000000000000D+1
&, 0.774596669241483D+0,-0.774596669241483D+0, 0.100000000000000D+1
&,-0.774596669241483D+0, 0.000000000000000D+0, 0.100000000000000D+1
&, 0.000000000000000D+0, 0.000000000000000D+0, 0.100000000000000D+1
&, 0.774596669241483D+0, 0.000000000000000D+0, 0.100000000000000D+1
&,-0.774596669241483D+0, 0.774596669241483D+0, 0.100000000000000D+1
&, 0.000000000000000D+0, 0.774596669241483D+0, 0.100000000000000D+1
&, 0.774596669241483D+0, 0.774596669241483D+0, 0.100000000000000D+1
&,-0.774596669241483D+0,-0.100000000000000D+1,-0.774596669241483D+0
&, 0.000000000000000D+0,-0.100000000000000D+1,-0.774596669241483D+0
&, 0.774596669241483D+0,-0.100000000000000D+1,-0.774596669241483D+0
&,-0.774596669241483D+0,-0.100000000000000D+1, 0.000000000000000D+0
&, 0.000000000000000D+0,-0.100000000000000D+1, 0.000000000000000D+0
&, 0.774596669241483D+0,-0.100000000000000D+1, 0.000000000000000D+0
&,-0.774596669241483D+0,-0.100000000000000D+1, 0.774596669241483D+0
&, 0.000000000000000D+0,-0.100000000000000D+1, 0.774596669241483D+0
&, 0.774596669241483D+0,-0.100000000000000D+1, 0.774596669241483D+0
&, 0.100000000000000D+1,-0.774596669241483D+0,-0.774596669241483D+0
&, 0.100000000000000D+1, 0.000000000000000D+0,-0.774596669241483D+0
&, 0.100000000000000D+1, 0.774596669241483D+0,-0.774596669241483D+0
&, 0.100000000000000D+1,-0.774596669241483D+0, 0.000000000000000D+0
&, 0.100000000000000D+1, 0.000000000000000D+0, 0.000000000000000D+0
&, 0.100000000000000D+1, 0.774596669241483D+0, 0.000000000000000D+0
&, 0.100000000000000D+1,-0.774596669241483D+0, 0.774596669241483D+0
&, 0.100000000000000D+1, 0.000000000000000D+0, 0.774596669241483D+0
&, 0.100000000000000D+1, 0.774596669241483D+0, 0.774596669241483D+0
&, 0.774596669241483D+0, 0.100000000000000D+1,-0.774596669241483D+0
&, 0.000000000000000D+0, 0.100000000000000D+1,-0.774596669241483D+0
&,-0.774596669241483D+0, 0.100000000000000D+1,-0.774596669241483D+0
&, 0.774596669241483D+0, 0.100000000000000D+1, 0.000000000000000D+0
&, 0.000000000000000D+0, 0.100000000000000D+1, 0.000000000000000D+0
&,-0.774596669241483D+0, 0.100000000000000D+1, 0.000000000000000D+0
&, 0.774596669241483D+0, 0.100000000000000D+1, 0.774596669241483D+0
&, 0.000000000000000D+0, 0.100000000000000D+1, 0.774596669241483D+0
&,-0.774596669241483D+0, 0.100000000000000D+1, 0.774596669241483D+0
&,-0.100000000000000D+1, 0.774596669241483D+0,-0.774596669241483D+0
&,-0.100000000000000D+1, 0.000000000000000D+0,-0.774596669241483D+0
&,-0.100000000000000D+1,-0.774596669241483D+0,-0.774596669241483D+0
&,-0.100000000000000D+1, 0.774596669241483D+0, 0.000000000000000D+0
&,-0.100000000000000D+1, 0.000000000000000D+0, 0.000000000000000D+0
&,-0.100000000000000D+1,-0.774596669241483D+0, 0.000000000000000D+0
&,-0.100000000000000D+1, 0.774596669241483D+0, 0.774596669241483D+0
&,-0.100000000000000D+1, 0.000000000000000D+0, 0.774596669241483D+0
&,-0.100000000000000D+1,-0.774596669241483D+0,0.774596669241483D+0/
&),(/3,9,6/))
!
xlocal4=reshape((/
& 0.333333333333333D+0, 0.333333333333333D+0, 0.000000000000000D+0
&, 0.333333333333333D+0, 0.000000000000000D+0, 0.333333333333333D+0
&, 0.333333333333334D+0, 0.333333333333333D+0, 0.333333333333333D+0
&, 0.000000000000000D+0, 0.333333333333333D+0,0.333333333333333D+0/
&),(/3,1,4/))
!
xlocal10=reshape((/
& 0.166666666666667D+0, 0.166666666666667D+0, 0.000000000000000D+0
&, 0.166666666666667D+0, 0.666666666666667D+0, 0.000000000000000D+0
&, 0.666666666666667D+0, 0.166666666666667D+0, 0.000000000000000D+0
&, 0.166666666666667D+0, 0.000000000000000D+0, 0.166666666666667D+0
&, 0.666666666666667D+0, 0.000000000000000D+0, 0.166666666666667D+0
&, 0.166666666666667D+0, 0.000000000000000D+0, 0.666666666666667D+0
&, 0.666666666666666D+0, 0.166666666666667D+0, 0.166666666666667D+0
&, 0.166666666666666D+0, 0.666666666666667D+0, 0.166666666666667D+0
&, 0.166666666666666D+0, 0.166666666666667D+0, 0.666666666666667D+0
&, 0.000000000000000D+0, 0.166666666666667D+0, 0.166666666666667D+0
&, 0.000000000000000D+0, 0.166666666666667D+0, 0.666666666666667D+0
&, 0.000000000000000D+0, 0.666666666666667D+0,0.166666666666667D+0/
&),(/3,3,4/))
!
xlocal6=reshape((/
& 0.333333333333333D+0, 0.333333333333333D+0,-0.100000000000000D+1
&, 0.333333333333333D+0, 0.333333333333333D+0, 0.100000000000000D+1
&, 0.500000000000000D+0, 0.000000000000000D+0, 0.000000000000000D+0
&, 0.500000000000000D+0, 0.500000000000000D+0, 0.000000000000000D+0
&, 0.000000000000000D+0, 0.500000000000000D+0,0.000000000000000D+0/
&),(/3,1,5/))
!
xlocal15=reshape((/
& 0.166666666666667D+0, 0.166666666666667D+0,-0.100000000000000D+1
&, 0.166666666666667D+0, 0.666666666666667D+0,-0.100000000000000D+1
&, 0.666666666666667D+0, 0.166666666666667D+0,-0.100000000000000D+1
&, 0.d0,0.d0,0.d0
&, 0.166666666666667D+0, 0.166666666666667D+0, 0.100000000000000D+1
&, 0.666666666666667D+0, 0.166666666666667D+0, 0.100000000000000D+1
&, 0.166666666666667D+0, 0.666666666666667D+0, 0.100000000000000D+1
&, 0.d0,0.d0,0.d0
&, 0.211324865405187D+0, 0.000000000000000D+0,-0.577350269189626D+0
&, 0.788675134594813D+0, 0.000000000000000D+0,-0.577350269189626D+0
&, 0.211324865405187D+0, 0.000000000000000D+0, 0.577350269189626D+0
&, 0.788675134594813D+0, 0.000000000000000D+0, 0.577350269189626D+0
&, 0.788675134594813D+0, 0.211324865405187D+0,-0.577350269189626D+0
&, 0.211324865405187D+0, 0.788675134594813D+0,-0.577350269189626D+0
&, 0.788675134594813D+0, 0.211324865405187D+0, 0.577350269189626D+0
&, 0.211324865405187D+0, 0.788675134594813D+0, 0.577350269189626D+0
&, 0.000000000000000D+0, 0.211324865405187D+0, 0.577350269189626D+0
&, 0.000000000000000D+0, 0.788675134594813D+0, 0.577350269189626D+0
&, 0.000000000000000D+0, 0.211324865405187D+0,-0.577350269189626D+0
&, 0.000000000000000D+0,0.788675134594813D+0,-0.577350269189626D+0/
&),(/3,4,5/))
!
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.16/src/fixnode.f | 1 | 2050 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2019 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 fixnode(nobject,nk,set,nset,istartset,iendset,
& ialset,iobject,nodedesiinv,dgdxglob,objectset)
!
! determination of the fixed nodes for the sensitivity analysis
!
implicit none
!
character*81 objectset(4,*),set(*)
!
integer nk,nobject,nset,istartset(*),iendset(*),ialset(*),
& iobject,nodedesiinv(*),i,j,node
!
real*8 dgdxglob(2,nk,nobject)
!
! determining the set of fixed nodes
!
do i=1,nset
if(objectset(3,iobject).eq.set(i)) exit
enddo
!
if(i.le.nset) then
!
do j=istartset(i),iendset(i)
if(ialset(j).gt.0) then
node=ialset(j)
if(nodedesiinv(node).eq.1) then
dgdxglob(1,node,iobject)=1.0d0
dgdxglob(2,node,iobject)=1.0d0
endif
else
node=ialset(j-2)
do
node=node-ialset(j)
if(node.ge.ialset(j-1)) exit
if(nodedesiinv(node).eq.1) then
dgdxglob(1,node,iobject)=1.0d0
dgdxglob(2,node,iobject)=1.0d0
endif
enddo
endif
enddo
endif
!
return
end
| gpl-2.0 |
grlee77/scipy | scipy/integrate/quadpack/dqc25f.f | 6 | 13255 | subroutine dqc25f(f,a,b,omega,integr,nrmom,maxp1,ksave,result,
* abserr,neval,resabs,resasc,momcom,chebmo)
c***begin prologue dqc25f
c***date written 810101 (yymmdd)
c***revision date 830518 (yymmdd)
c***category no. h2a2a2
c***keywords integration rules for functions with cos or sin
c factor, clenshaw-curtis, gauss-kronrod
c***author piessens,robert,appl. math. & progr. div. - k.u.leuven
c de doncker,elise,appl. math. & progr. div. - k.u.leuven
c***purpose to compute the integral i=integral of f(x) over (a,b)
c where w(x) = cos(omega*x) or w(x)=sin(omega*x) and to
c compute j = integral of abs(f) over (a,b). for small value
c of omega or small intervals (a,b) the 15-point gauss-kronro
c rule is used. otherwise a generalized clenshaw-curtis
c method is used.
c***description
c
c integration rules for functions with cos or sin factor
c standard fortran subroutine
c double precision version
c
c parameters
c on entry
c f - double precision
c function subprogram defining the integrand
c function f(x). the actual name for f needs to
c be declared e x t e r n a l in the calling program.
c
c a - double precision
c lower limit of integration
c
c b - double precision
c upper limit of integration
c
c omega - double precision
c parameter in the weight function
c
c integr - integer
c indicates which weight function is to be used
c integr = 1 w(x) = cos(omega*x)
c integr = 2 w(x) = sin(omega*x)
c
c nrmom - integer
c the length of interval (a,b) is equal to the length
c of the original integration interval divided by
c 2**nrmom (we suppose that the routine is used in an
c adaptive integration process, otherwise set
c nrmom = 0). nrmom must be zero at the first call.
c
c maxp1 - integer
c gives an upper bound on the number of chebyshev
c moments which can be stored, i.e. for the
c intervals of lengths abs(bb-aa)*2**(-l),
c l = 0,1,2, ..., maxp1-2.
c
c ksave - integer
c key which is one when the moments for the
c current interval have been computed
c
c on return
c result - double precision
c approximation to the integral i
c
c abserr - double precision
c estimate of the modulus of the absolute
c error, which should equal or exceed abs(i-result)
c
c neval - integer
c number of integrand evaluations
c
c resabs - double precision
c approximation to the integral j
c
c resasc - double precision
c approximation to the integral of abs(f-i/(b-a))
c
c on entry and return
c momcom - integer
c for each interval length we need to compute the
c chebyshev moments. momcom counts the number of
c intervals for which these moments have already been
c computed. if nrmom.lt.momcom or ksave = 1, the
c chebyshev moments for the interval (a,b) have
c already been computed and stored, otherwise we
c compute them and we increase momcom.
c
c chebmo - double precision
c array of dimension at least (maxp1,25) containing
c the modified chebyshev moments for the first momcom
c momcom interval lengths
c
c ......................................................................
c***references (none)
c***routines called d1mach,dgtsl,dqcheb,dqk15w,dqwgtf
c***end prologue dqc25f
c
double precision a,abserr,ac,an,an2,as,asap,ass,b,centr,chebmo,
* cheb12,cheb24,conc,cons,cospar,d,dabs,dcos,dsin,dqwgtf,d1,
* d1mach,d2,estc,ests,f,fval,hlgth,oflow,omega,parint,par2,par22,
* p2,p3,p4,resabs,resasc,resc12,resc24,ress12,ress24,result,
* sinpar,v,x
integer i,iers,integr,isym,j,k,ksave,m,momcom,neval,maxp1,
* noequ,noeq1,nrmom
c
dimension chebmo(maxp1,25),cheb12(13),cheb24(25),d(25),d1(25),
* d2(25),fval(25),v(28),x(11)
c
external f,dqwgtf
c
c the vector x contains the values cos(k*pi/24)
c k = 1, ...,11, to be used for the chebyshev expansion of f
c
data x(1) / 0.9914448613 7381041114 4557526928 563d0 /
data x(2) / 0.9659258262 8906828674 9743199728 897d0 /
data x(3) / 0.9238795325 1128675612 8183189396 788d0 /
data x(4) / 0.8660254037 8443864676 3723170752 936d0 /
data x(5) / 0.7933533402 9123516457 9776961501 299d0 /
data x(6) / 0.7071067811 8654752440 0844362104 849d0 /
data x(7) / 0.6087614290 0872063941 6097542898 164d0 /
data x(8) / 0.5000000000 0000000000 0000000000 000d0 /
data x(9) / 0.3826834323 6508977172 8459984030 399d0 /
data x(10) / 0.2588190451 0252076234 8898837624 048d0 /
data x(11) / 0.1305261922 2005159154 8406227895 489d0 /
c
c list of major variables
c -----------------------
c
c centr - mid point of the integration interval
c hlgth - half-length of the integration interval
c fval - value of the function f at the points
c (b-a)*0.5*cos(k*pi/12) + (b+a)*0.5, k = 0, ..., 24
c cheb12 - coefficients of the chebyshev series expansion
c of degree 12, for the function f, in the
c interval (a,b)
c cheb24 - coefficients of the chebyshev series expansion
c of degree 24, for the function f, in the
c interval (a,b)
c resc12 - approximation to the integral of
c cos(0.5*(b-a)*omega*x)*f(0.5*(b-a)*x+0.5*(b+a))
c over (-1,+1), using the chebyshev series
c expansion of degree 12
c resc24 - approximation to the same integral, using the
c chebyshev series expansion of degree 24
c ress12 - the analogue of resc12 for the sine
c ress24 - the analogue of resc24 for the sine
c
c
c machine dependent constant
c --------------------------
c
c oflow is the largest positive magnitude.
c
c***first executable statement dqc25f
oflow = d1mach(2)
c
centr = 0.5d+00*(b+a)
hlgth = 0.5d+00*(b-a)
parint = omega*hlgth
c
c compute the integral using the 15-point gauss-kronrod
c formula if the value of the parameter in the integrand
c is small.
c
if(dabs(parint).gt.0.2d+01) go to 10
call dqk15w(f,dqwgtf,omega,p2,p3,p4,integr,a,b,result,
* abserr,resabs,resasc)
neval = 15
go to 170
c
c compute the integral using the generalized clenshaw-
c curtis method.
c
10 conc = hlgth*dcos(centr*omega)
cons = hlgth*dsin(centr*omega)
resasc = oflow
neval = 25
c
c check whether the chebyshev moments for this interval
c have already been computed.
c
if(nrmom.lt.momcom.or.ksave.eq.1) go to 120
c
c compute a new set of chebyshev moments.
c
m = momcom+1
par2 = parint*parint
par22 = par2+0.2d+01
sinpar = dsin(parint)
cospar = dcos(parint)
c
c compute the chebyshev moments with respect to cosine.
c
v(1) = 0.2d+01*sinpar/parint
v(2) = (0.8d+01*cospar+(par2+par2-0.8d+01)*sinpar/parint)/par2
v(3) = (0.32d+02*(par2-0.12d+02)*cospar+(0.2d+01*
* ((par2-0.80d+02)*par2+0.192d+03)*sinpar)/parint)/(par2*par2)
ac = 0.8d+01*cospar
as = 0.24d+02*parint*sinpar
if(dabs(parint).gt.0.24d+02) go to 30
c
c compute the chebyshev moments as the solutions of a
c boundary value problem with 1 initial value (v(3)) and 1
c end value (computed using an asymptotic formula).
c
noequ = 25
noeq1 = noequ-1
an = 0.6d+01
do 20 k = 1,noeq1
an2 = an*an
d(k) = -0.2d+01*(an2-0.4d+01)*(par22-an2-an2)
d2(k) = (an-0.1d+01)*(an-0.2d+01)*par2
d1(k+1) = (an+0.3d+01)*(an+0.4d+01)*par2
v(k+3) = as-(an2-0.4d+01)*ac
an = an+0.2d+01
20 continue
an2 = an*an
d(noequ) = -0.2d+01*(an2-0.4d+01)*(par22-an2-an2)
v(noequ+3) = as-(an2-0.4d+01)*ac
v(4) = v(4)-0.56d+02*par2*v(3)
ass = parint*sinpar
asap = (((((0.210d+03*par2-0.1d+01)*cospar-(0.105d+03*par2
* -0.63d+02)*ass)/an2-(0.1d+01-0.15d+02*par2)*cospar
* +0.15d+02*ass)/an2-cospar+0.3d+01*ass)/an2-cospar)/an2
v(noequ+3) = v(noequ+3)-0.2d+01*asap*par2*(an-0.1d+01)*
* (an-0.2d+01)
c
c solve the tridiagonal system by means of gaussian
c elimination with partial pivoting.
c
c*** call to dgtsl has been replaced by call to
c*** lapack routine dgtsv
c
c call dgtsl(noequ,d1,d,d2,v(4),iers)
call dgtsv(noequ,1,d1(2),d,d2,v(4),noequ,iers)
go to 50
c
c compute the chebyshev moments by means of forward
c recursion.
c
30 an = 0.4d+01
do 40 i = 4,13
an2 = an*an
v(i) = ((an2-0.4d+01)*(0.2d+01*(par22-an2-an2)*v(i-1)-ac)
* +as-par2*(an+0.1d+01)*(an+0.2d+01)*v(i-2))/
* (par2*(an-0.1d+01)*(an-0.2d+01))
an = an+0.2d+01
40 continue
50 do 60 j = 1,13
chebmo(m,2*j-1) = v(j)
60 continue
c
c compute the chebyshev moments with respect to sine.
c
v(1) = 0.2d+01*(sinpar-parint*cospar)/par2
v(2) = (0.18d+02-0.48d+02/par2)*sinpar/par2
* +(-0.2d+01+0.48d+02/par2)*cospar/parint
ac = -0.24d+02*parint*cospar
as = -0.8d+01*sinpar
if(dabs(parint).gt.0.24d+02) go to 80
c
c compute the chebyshev moments as the solutions of a boundary
c value problem with 1 initial value (v(2)) and 1 end value
c (computed using an asymptotic formula).
c
an = 0.5d+01
do 70 k = 1,noeq1
an2 = an*an
d(k) = -0.2d+01*(an2-0.4d+01)*(par22-an2-an2)
d2(k) = (an-0.1d+01)*(an-0.2d+01)*par2
d1(k+1) = (an+0.3d+01)*(an+0.4d+01)*par2
v(k+2) = ac+(an2-0.4d+01)*as
an = an+0.2d+01
70 continue
an2 = an*an
d(noequ) = -0.2d+01*(an2-0.4d+01)*(par22-an2-an2)
v(noequ+2) = ac+(an2-0.4d+01)*as
v(3) = v(3)-0.42d+02*par2*v(2)
ass = parint*cospar
asap = (((((0.105d+03*par2-0.63d+02)*ass+(0.210d+03*par2
* -0.1d+01)*sinpar)/an2+(0.15d+02*par2-0.1d+01)*sinpar-
* 0.15d+02*ass)/an2-0.3d+01*ass-sinpar)/an2-sinpar)/an2
v(noequ+2) = v(noequ+2)-0.2d+01*asap*par2*(an-0.1d+01)
* *(an-0.2d+01)
c
c solve the tridiagonal system by means of gaussian
c elimination with partial pivoting.
c
c*** call to dgtsl has been replaced by call to
c*** lapack routine dgtsv
c
c call dgtsl(noequ,d1,d,d2,v(3),iers)
call dgtsv(noequ,1,d1(2),d,d2,v(3),noequ,iers)
go to 100
c
c compute the chebyshev moments by means of forward recursion.
c
80 an = 0.3d+01
do 90 i = 3,12
an2 = an*an
v(i) = ((an2-0.4d+01)*(0.2d+01*(par22-an2-an2)*v(i-1)+as)
* +ac-par2*(an+0.1d+01)*(an+0.2d+01)*v(i-2))
* /(par2*(an-0.1d+01)*(an-0.2d+01))
an = an+0.2d+01
90 continue
100 do 110 j = 1,12
chebmo(m,2*j) = v(j)
110 continue
120 if (nrmom.lt.momcom) m = nrmom+1
if (momcom.lt.(maxp1-1).and.nrmom.ge.momcom) momcom = momcom+1
c
c compute the coefficients of the chebyshev expansions
c of degrees 12 and 24 of the function f.
c
fval(1) = 0.5d+00*f(centr+hlgth)
fval(13) = f(centr)
fval(25) = 0.5d+00*f(centr-hlgth)
do 130 i = 2,12
isym = 26-i
fval(i) = f(hlgth*x(i-1)+centr)
fval(isym) = f(centr-hlgth*x(i-1))
130 continue
call dqcheb(x,fval,cheb12,cheb24)
c
c compute the integral and error estimates.
c
resc12 = cheb12(13)*chebmo(m,13)
ress12 = 0.0d+00
k = 11
do 140 j = 1,6
resc12 = resc12+cheb12(k)*chebmo(m,k)
ress12 = ress12+cheb12(k+1)*chebmo(m,k+1)
k = k-2
140 continue
resc24 = cheb24(25)*chebmo(m,25)
ress24 = 0.0d+00
resabs = dabs(cheb24(25))
k = 23
do 150 j = 1,12
resc24 = resc24+cheb24(k)*chebmo(m,k)
ress24 = ress24+cheb24(k+1)*chebmo(m,k+1)
resabs = resabs+dabs(cheb24(k))+dabs(cheb24(k+1))
k = k-2
150 continue
estc = dabs(resc24-resc12)
ests = dabs(ress24-ress12)
resabs = resabs*dabs(hlgth)
if(integr.eq.2) go to 160
result = conc*resc24-cons*ress24
abserr = dabs(conc*estc)+dabs(cons*ests)
go to 170
160 result = conc*ress24+cons*resc24
abserr = dabs(conc*ests)+dabs(cons*estc)
170 return
end
| bsd-3-clause |
techno/gcc-mist32 | gcc/testsuite/gfortran.dg/edit_real_1.f90 | 137 | 2462 | ! { dg-do run }
! Check real value edit descriptors
! Also checks that rounding is performed correctly
program edit_real_1
character(len=20) s
character(len=20) x
character(len=200) t
parameter (x = "xxxxxxxxxxxxxxxxxxxx")
! W append a "z" onto each test to check the field is the correct width
s = x
! G -> F format
write (s, '(G10.3,A)') 12.36, "z"
if (s .ne. " 12.4 z") call abort
s = x
! G -> E format
write (s, '(G10.3,A)') -0.0012346, "z"
if (s .ne. "-0.123E-02z") call abort
s = x
! Gw.eEe format
write (s, '(G10.3e1,a)') 12.34, "z"
if (s .ne. " 12.3 z") call abort
! E format with excessive precision
write (t, '(E199.192,A)') 1.5, "z"
if ((t(1:7) .ne. " 0.1500") .or. (t(194:200) .ne. "00E+01z")) call abort
! EN format
s = x
write (s, '(EN15.3,A)') 12873.6, "z"
if (s .ne. " 12.874E+03z") call abort
! EN format, negative exponent
s = x
write (s, '(EN15.3,A)') 12.345e-6, "z"
if (s .ne. " 12.345E-06z") call abort
! ES format
s = x
write (s, '(ES10.3,A)') 16.235, "z"
if (s .ne. " 1.624E+01z") call abort
! F format, small number
s = x
write (s, '(F10.8,A)') 1.0e-20, "z"
if (s .ne. "0.00000000z") call abort
! E format, very large number.
! Used to overflow with positive scale factor
s = x
write (s, '(1PE10.3,A)') huge(0d0), "z"
! The actual value is target specific, so just do a basic check
if ((s(1:1) .eq. "*") .or. (s(7:7) .ne. "+") .or. &
(s(11:11) .ne. "z")) call abort
! F format, round up with carry to most significant digit.
s = x
write (s, '(F10.3,A)') 0.9999, "z"
if (s .ne. " 1.000z") call abort
! F format, round up with carry to most significant digit < 0.1.
s = x
write (s, '(F10.3,A)') 0.0099, "z"
if (s .ne. " 0.010z") call abort
! E format, round up with carry to most significant digit.
s = x
write (s, '(E10.3,A)') 0.9999, "z"
if (s .ne. " 0.100E+01z") call abort
! EN format, round up with carry to most significant digit.
s = x
write (s, '(EN15.3,A)') 999.9999, "z"
if (s .ne. " 1.000E+03z") call abort
! E format, positive scale factor
s = x
write (s, '(2PE10.4,A)') 1.2345, "z"
if (s .ne. '12.345E-01z') call abort
! E format, negative scale factor
s = x
write (s, '(-2PE10.4,A)') 1.250001, "z"
if (s .ne. '0.0013E+03z') call abort
! E format, single digit precision
s = x
write (s, '(E10.1,A)') 1.1, "z"
if (s .ne. ' 0.1E+01z') call abort
end
| gpl-2.0 |
epfl-cosmo/q-e | XSpectra/src/lr_sm1_psi.f90 | 6 | 12573 | !
! Copyright (C) 2001-2006 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!----------------------------------------------------------------------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SUBROUTINE sm1_psi( recalc, lda, n, m, psi, spsi)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!----------------------------------------------------------------------------
!
! This routine applies the S^{-1} matrix to m wavefunctions psi
! and puts the results in spsi.
! Requires the products of psi with all beta functions
! in array becp(nkb,m) (calculated in h_psi or by ccalbec)
! input:
! recalc decides if the overlap of beta functions is recalculated or not.
! this is needed e.g. if ions are moved and the overlap changes accordingly
! lda leading dimension of arrays psi, spsi
! n true dimension of psi, spsi
! m number of states psi
! psi
! output:
! spsi S^{-1}*psi
!
! Original routine written by Ralph Gebauer
! Modified by Christos Gougoussis
!
USE kinds, ONLY : DP
USE control_flags, ONLY : gamma_only
USE uspp, ONLY : okvan, vkb, nkb, qq
USE uspp_param, ONLY : upf, nh
USE ldaU, ONLY : lda_plus_u
USE ions_base, ONLY : nat, ntyp => nsp, ityp
use becmod, only : calbec
!
IMPLICIT NONE
!
! ... First the dummy variables
!
LOGICAL :: recalc
INTEGER :: lda, n, m
COMPLEX(KIND=DP) :: psi(lda,m), spsi(lda,m)
!
CALL start_clock( 'sm1' )
!
IF ( gamma_only ) THEN
CALL sm1_psi_gamma()
ELSE
!
CALL sm1_psi_k()
!
END IF
!
CALL stop_clock( 'sm1' )
!
RETURN
!
CONTAINS
!-----------------------------------------------------------------------
SUBROUTINE sm1_psi_gamma()
!-----------------------------------------------------------------------
!
USE becmod, ONLY : becp
!
IMPLICIT NONE
!
! ... local variables
!
INTEGER :: ikb, jkb, ih, jh, na, nt, ijkb0, ibnd, ii
! counters
real(KIND=DP), ALLOCATABLE :: ps(:,:)
real(kind=dp), allocatable, save :: BB_(:,:)
! the product vkb and psi
!
! ... initialize spsi
!
CALL zcopy( lda * m, psi, 1, spsi, 1 )
!
! ... The product with the beta functions
!
IF ( nkb == 0 .OR. .NOT. okvan ) RETURN
!
if(.not.allocated(BB_)) then
allocate(BB_(nkb,nkb))
recalc = .true.
endif
if(recalc) then
call errore('sm1_psi','recalculating BB_ matrix',-1)
call pw_gemm('Y',nkb,nkb,n,vkb,lda,vkb,lda,BB_,nkb)
ALLOCATE( ps( nkb, nkb ) )
ps(:,:) = (0.d0)
ijkb0 = 0
do nt=1,ntyp
if (upf(nt)%tvanp) then
do na=1,nat
if(ityp(na).eq.nt) then
do ii=1,nkb
do jh=1,nh(nt)
jkb=ijkb0 + jh
do ih=1,nh(nt)
ikb = ijkb0 + ih
ps(ikb,ii) = ps(ikb,ii) + qq(ih,jh,nt)*BB_(jkb,ii)
enddo
enddo
enddo
ijkb0 = ijkb0+nh(nt)
endif
enddo
else
DO na = 1, nat
IF ( ityp(na) == nt ) ijkb0 = ijkb0 + nh(nt)
END DO
endif
enddo
do ii=1,nkb
ps(ii,ii) = ps(ii,ii) + 1.d0
enddo
call dinv_matrix(ps,nkb)
BB_(:,:) = 0.d0
ijkb0 = 0
do nt=1,ntyp
if (upf(nt)%tvanp) then
do na=1,nat
if(ityp(na).eq.nt) then
do ii=1,nkb
do jh=1,nh(nt)
jkb=ijkb0 + jh
do ih=1,nh(nt)
ikb = ijkb0 + ih
BB_(ii,jkb) = BB_(ii,jkb) - ps(ii,ikb)*qq(ih,jh,nt)
enddo
enddo
enddo
ijkb0 = ijkb0+nh(nt)
endif
enddo
else
DO na = 1, nat
IF ( ityp(na) == nt ) ijkb0 = ijkb0 + nh(nt)
END DO
endif
enddo
deallocate(ps)
endif
call pw_gemm('Y',nkb,m,n,vkb,lda,psi,lda,becp%r,nkb)
!
ALLOCATE( ps( nkb, m ) )
ps(:,:) = 0.D0
!
do ibnd=1,m
do jkb=1,nkb
do ii=1,nkb
ps(jkb,ibnd) = ps(jkb,ibnd)+BB_(jkb,ii)*becp%r(ii,ibnd)
enddo
enddo
enddo
!
do ibnd=1,m
do ii=1,nkb
call zaxpy(n,CMPLX(ps(ii,ibnd),0.0d0,dp),vkb(1,ii),1,spsi(1,ibnd),1)
enddo
enddo
!
DEALLOCATE( ps )
!
RETURN
!
END SUBROUTINE sm1_psi_gamma
!
!-----------------------------------------------------------------------
SUBROUTINE sm1_psi_k()
!-----------------------------------------------------------------------
!
! ... k-points version
!
USE becmod, ONLY : becp
USE klist, only : xk
USE mp, only : mp_sum ! CG
USE mp_global, ONLY : intra_pool_comm ! CG
!
IMPLICIT NONE
!
! ... local variables
!
INTEGER :: ikb, jkb, ih, jh, na, nt, ijkb0, ibnd, ii, ik1
! counters
complex(KIND=DP), ALLOCATABLE :: ps(:,:)
complex(kind=dp), allocatable, save :: BB_(:,:)
! the product vkb and psi
!
! ... initialize spsi
!
CALL zcopy( lda * m, psi, 1, spsi, 1 )
!
! ... The product with the beta functions
!
IF ( nkb == 0 .OR. .NOT. okvan ) RETURN
!
if(.not.allocated(BB_)) then
allocate(BB_(nkb,nkb))
recalc = .true.
endif
if(recalc) then
call errore('sm1_psi','recalculating BB_ matrix',-1)
ALLOCATE( ps( nkb, nkb ) )
call zgemm('C','N',nkb,nkb,n,(1.d0,0.d0),vkb,lda,vkb,lda,(0.d0,0.d0),BB_(1,1),nkb)
!****** CALL reduce( 2 * nkb * nkb, BB_ )
CALL mp_sum( BB_, intra_pool_comm ) !CG
ps(:,:) = (0.d0,0.d0)
ijkb0 = 0
do nt=1,ntyp
if (upf(nt)%tvanp) then
do na=1,nat
if(ityp(na).eq.nt) then
do ii=1,nkb
do jh=1,nh(nt)
jkb=ijkb0 + jh
do ih=1,nh(nt)
ikb = ijkb0 + ih
ps(ikb,ii) = ps(ikb,ii) + BB_(jkb,ii)*qq(ih,jh,nt)
enddo
enddo
enddo
ijkb0 = ijkb0+nh(nt)
endif
enddo
else
DO na = 1, nat
IF ( ityp(na) == nt ) ijkb0 = ijkb0 + nh(nt)
END DO
endif
enddo
do ii=1,nkb
ps(ii,ii) = ps(ii,ii) + (1.d0,0.d0)
enddo
call zinv_matrix(ps,nkb)
BB_(:,:) = (0.d0,0.d0)
ijkb0 = 0
do nt=1,ntyp
if (upf(nt)%tvanp) then
do na=1,nat
if(ityp(na).eq.nt) then
do ii=1,nkb
do jh=1,nh(nt)
jkb=ijkb0 + jh
do ih=1,nh(nt)
ikb = ijkb0 + ih
! BB_(ii,jkb) = BB_(ii,jkb) - ps(ii,jkb)*qq(ih,jh,nt) ! this seems false
BB_(ii,jkb) = BB_(ii,jkb) - ps(ii,ikb)*qq(ih,jh,nt) ! modified by CG
enddo
enddo
enddo
ijkb0 = ijkb0+nh(nt)
endif
enddo
else
DO na = 1, nat
IF ( ityp(na) == nt ) ijkb0 = ijkb0 + nh(nt)
END DO
endif
enddo
deallocate(ps)
endif
! call calbec ( lda, vkb, psi, becp ) ! erreur ici ?
call calbec ( n, vkb, psi, becp%k )
!
ALLOCATE( ps( nkb, m ) )
ps(:,:) = (0.d0,0.d0)
!
do ibnd=1,m
do jkb=1,nkb
do ii=1,nkb
ps(jkb,ibnd) = ps(jkb,ibnd)+BB_(jkb,ii)*becp%k(ii,ibnd)
enddo
enddo
enddo
!
!
CALL zgemm( 'N', 'N', n, m, nkb, (1.D0, 0.D0), vkb, &
lda, ps, nkb, (1.D0, 0.D0), spsi, lda )
! CALL zcopy( lda * m, psi, 1, spsi, 1 ) ! remove this !!!
DEALLOCATE( ps )
!
RETURN
!
END SUBROUTINE sm1_psi_k
!
END subroutine sm1_psi
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine dinv_matrix(M,N)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
USE kinds, ONLY : DP
implicit none
integer :: N ! matrix dimension
real(kind=dp), dimension(0:N-1,0:N-1) :: M ! MAtrix to be inverted
real(kind=dp), dimension(:), allocatable :: work
integer, dimension(:), allocatable :: ipiv
integer :: i,lwork,info
integer, save :: lworkfact
data lworkfact /64/
lwork = lworkfact*N
allocate(ipiv(0:N-1))
allocate(work(1:lwork))
! Factorize Matrix M
call dgetrf( N, N, M, N, ipiv, info )
if (info.ne.0) then
call errore('dinv_matrix','error in dgetrf',info)
endif
! Invert Matrix
call dgetri( N, M, N, ipiv, work, lwork, info )
if (info.ne.0) then
call errore('dinv_matrix','error in dgetri',info)
else
lworkfact = int(work(1)/N)
endif
deallocate(work)
deallocate(ipiv)
end subroutine dinv_matrix
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine zinv_matrix(M,N)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
USE kinds, ONLY : DP
implicit none
integer :: N ! matrix dimension
complex(kind=dp), dimension(0:N-1,0:N-1) :: M ! MAtrix to be inverted
complex(kind=dp), dimension(:), allocatable :: work
integer, dimension(:), allocatable :: ipiv
integer :: i,lwork,info
integer, save :: lworkfact
data lworkfact /64/
lwork = lworkfact*N
allocate(ipiv(0:N-1))
allocate(work(1:lwork))
! Factorize Matrix M
call zgetrf( N, N, M, N, ipiv, info )
if (info.ne.0) then
call errore('zinv_matrix','error in zgetrf',info)
endif
! Invert Matrix
call zgetri( N, M, N, ipiv, work, lwork, info )
if (info.ne.0) then
call errore('zinv_matrix','error in zgetri',info)
else
lworkfact = int(work(1)/N)
endif
deallocate(work)
deallocate(ipiv)
end subroutine zinv_matrix
!
! Copyright (C) 2002-2005 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!
!----------------------------------------------------------------------------
SUBROUTINE pw_gemm( sum_over_nodes, na, nb, n, a, lda, b, ldb, c, ldc )
!----------------------------------------------------------------------------
!
! ... matrix times matrix with summation index running on G-vectors or PWs
! ... c(ij)=real(a(ik)*b(kj)) using half G vectors or half PWs
!
! ccalbec( nkb, npwx, npw, nbnd, vkb, psi, bec ) =>
! pw_gemm( 'Y', nkb, nbnd, npw, vkb, npwx, psi, npwx, bec, nkb )
!
!
USE kinds, ONLY : DP
USE gvect, ONLY : gstart
USE mp, only : mp_sum ! CG
USE mp_global, ONLY : intra_pool_comm ! CG
!
IMPLICIT NONE
!
! ... input
!
CHARACTER(LEN=1) :: sum_over_nodes
INTEGER :: na, nb, n, lda, ldb, ldc
COMPLEX(DP) :: a(lda,na), b(ldb,nb)
!
! ... output
!
REAL(DP) :: c(ldc,nb)
!
!
IF ( na == 0 .OR. nb == 0 ) RETURN
!
CALL start_clock( 'pw_gemm' )
!
IF ( nb == 1 ) THEN
!
CALL dgemv( 'C', 2*n, na, 2.D0, a, 2*lda, b, 1, 0.D0, c, 1 )
!
IF ( gstart == 2 ) c(:,1) = c(:,1) - a(1,:) * b(1,1)
!
ELSE
!
CALL dgemm( 'C', 'N', na, nb, 2*n, 2.D0, a, 2*lda, b, 2*ldb, 0.D0, c, ldc )
!
IF ( gstart == 2 ) &
CALL DGER( na, nb, -1.D0, a, 2*lda, b, 2*ldb, c, ldc )
!
END IF
!
!******** IF ( sum_over_nodes == 'y' .OR. &
!******** sum_over_nodes == 'Y' ) CALL reduce( ldc*nb, c )
IF ( sum_over_nodes == 'y' .OR. &
sum_over_nodes == 'Y' ) CALL mp_sum( c, intra_pool_comm ) !CG
!
CALL stop_clock( 'pw_gemm' )
!
RETURN
!
END SUBROUTINE pw_gemm
| gpl-2.0 |
techno/gcc-mist32 | gcc/testsuite/gfortran.dg/entry_14.f90 | 136 | 1767 | ! { dg-do run }
!
! PR fortran/34137
!
! Entry was previously not possible in a module.
! Checks also whether the different result combinations
! work properly.
!
module m1
implicit none
contains
function func(a)
implicit none
integer :: a, func
real :: ent
func = a*4
return
entry ent(a)
ent = -a*2.0
return
end function func
end module m1
module m2
implicit none
contains
function func(a)
implicit none
integer :: a, func
real :: func2
func = a*8
return
entry ent(a) result(func2)
func2 = -a*4.0
return
end function func
end module m2
module m3
implicit none
contains
function func(a) result(res)
implicit none
integer :: a, res
real :: func2
res = a*12
return
entry ent(a) result(func2)
func2 = -a*6.0
return
end function func
end module m3
module m4
implicit none
contains
function func(a) result(res)
implicit none
integer :: a, res
real :: ent
res = a*16
return
entry ent(a)
ent = -a*8.0
return
end function func
end module m4
program main
implicit none
call test1()
call test2()
call test3()
call test4()
contains
subroutine test1()
use m1
implicit none
if(func(3) /= 12) call abort()
if(abs(ent(7) + 14.0) > tiny(1.0)) call abort()
end subroutine test1
subroutine test2()
use m2
implicit none
if(func(9) /= 72) call abort()
if(abs(ent(11) + 44.0) > tiny(1.0)) call abort()
end subroutine test2
subroutine test3()
use m3
implicit none
if(func(13) /= 156) call abort()
if(abs(ent(17) + 102.0) > tiny(1.0)) call abort()
end subroutine test3
subroutine test4()
use m4
implicit none
if(func(23) /= 368) call abort()
if(abs(ent(27) + 216.0) > tiny(1.0)) call abort()
end subroutine test4
end program main
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.17/src/plane_eq.f | 1 | 1891 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2020 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 plane_eq.f
!
! Creates the plane equation from three known points.
! Gives the z-coordinate of the fourth point as an output.
!
! x1,y1,z1: The coordinates of the first point
! x2,y2,z2: The coordinates of the second point
! x3,y3,z3: The coordinates of the third point
! x0,y0: The x and y-coordinates for the fourth point
! output: The z-coordinate according to the x0 and y0
!
! by: Jaro Hokkanen
!
subroutine plane_eq(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,output)
!
implicit none
!
real*8 x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,output,
& a,b,c,d
!
d=x1*y2*z3+y1*z2*x3+z1*x2*y3-x1*z2*y3-y1*x2*z3-z1*y2*x3
if(d.ne.0.d0) then
a=1.d0/d*(y2*z3+y1*z2+z1*y3-z2*y3-y1*z3-z1*y2)
endif
if(d.ne.0.d0) then
b=1.d0/d*(x1*z3+z2*x3+z1*x2-x1*z2-x2*z3-z1*x3)
endif
if(d.ne.0.d0) then
c=1.d0/d*(x1*y2+y1*x3+x2*y3-x1*y3-y1*x2-y2*x3)
endif
if(d.ne.0.d0) then
output=1.d0/c*(1.d0-a*x0-b*y0)
else
output=0.d0
endif
return
end
| gpl-2.0 |
freedesktop-unofficial-mirror/gstreamer-sdk__gcc | gcc/testsuite/gfortran.dg/read_eof_all.f90 | 169 | 1987 | ! { dg-do run }
! PR43265 Followup patch for miscellaneous EOF conditions.
! Eaxamples from Tobius Burnus
use iso_fortran_env
character(len=2) :: str, str2(2)
integer :: a, b, c, ios
str = ''
str2 = ''
open(99,file='test.dat',access='stream',form='unformatted', status='replace')
write(99) ' '
close(99)
open(99,file='test.dat')
read(99, '(T7,i2)') i
close(99, status="delete")
if (i /= 0) call abort
read(str(1:0), '(T7,i1)') i
if (i /= 0) call abort
read(str,'(i2,/,i2)',end=111) a, b
call abort !stop 'ERROR: Expected EOF error (1)'
111 continue
read(str2,'(i2,/,i2)',end=112) a, b
read(str2,'(i2,/,i2,/,i2)',end=113) a, b, c
call abort !stop 'ERROR: Expected EOF error (2)'
112 call abort !stop 'ERROR: Unexpected EOF (3)'
113 continue
read(str,'(i2,/,i2)',end=121,pad='no') a, b
call abort !stop 'ERROR: Expected EOF error (1)'
121 continue
read(str2(:),'(i2,/,i2)', end=122, pad='no') a, b
goto 125
122 call abort !stop 'ERROR: Expected no EOF error (2)'
125 continue
read(str2(:),'(i2,/,i2,/,i2)',end=123,pad='no') a, b, c
call abort !stop 'ERROR: Expected EOF error (3)'
123 continue
read(str(2:1),'(i2,/,i2)',end=131, pad='no') a, b
call abort !stop 'ERROR: Expected EOF error (1)'
131 continue
read(str2(:)(2:1),'(i2,/,i2)',end=132, pad='no') a, b
call abort !stop 'ERROR: Expected EOF error (2)'
132 continue
read(str2(:)(2:1),'(i2,/,i2,/,i2)',end=133,pad='no') a, b, c
call abort !stop 'ERROR: Expected EOF error (3)'
133 continue
read(str(2:1),'(i2,/,i2)',iostat=ios, pad='no') a, b
if (ios /= IOSTAT_END) call abort !stop 'ERROR: expected iostat /= 0 (1)'
read(str2(:)(2:1),'(i2,/,i2)',iostat=ios, pad='no') a, b
if (ios /= IOSTAT_END) call abort !stop 'ERROR: expected iostat /= 0 (2)'
read(str2(:)(2:1),'(i2,/,i2,/,i2)',iostat=ios,pad='no') a, b, c
if (ios /= IOSTAT_END) call abort !stop 'ERROR: expected iostat /= 0 (2)'
! print *, "success"
end
| gpl-2.0 |
francescosalvadore/openpde | src/lib/openpde_field/openpde_field_block_FV_1D.f90 | 1 | 6924 | !< Concrete class of field block for Finite Volume 1D methods.
module openpde_field_block_FV_1D
!< Concrete class of field block for Finite Volume 1D methods.
use, intrinsic :: iso_fortran_env, only : stderr=>error_unit
use openpde_kinds
use openpde_mesh_FV_1D
use openpde_mesh_block_FV_1D
implicit none
private
public :: field_block_FV_1D
type :: field_block_FV_1D
!< Concrete class of field block for Finite Volume 1D methods.
real(R_P), allocatable, dimension(:) :: val !< Block value.
contains
! public methods
procedure, pass(this) :: alloc !< Allocate block.
procedure, pass(this) :: free !< Free dynamic memory.
procedure, pass(this) :: init !< Initilize block.
procedure, pass(this) :: output !< Output block data.
! public operators
generic, public :: operator(+) => add !< Operator `+` overloading.
generic, public :: operator(*) => mul, realmul, mulreal !< Operator `*` overloading.
generic, public :: operator(-) => sub !< Operator `-` overloading.
generic, public :: operator(/) => div !< Operator `-` overloading.
generic, public :: assignment(=) => assign_block !< Assignment overloading.
! private methods
procedure, pass(lhs), private :: add !< Add blocks.
procedure, pass(lhs), private :: assign_block !< Assign blocks.
procedure, pass(lhs), private :: mul !< Multiply blocks.
procedure, pass(lhs), private :: mulreal !< Multiply block for real.
procedure, pass(rhs), private :: realmul !< Multiply real for block.
procedure, pass(lhs), private :: sub !< Subtract blocks.
procedure, pass(lhs), private :: div !< Subtract blocks.
endtype field_block_FV_1D
contains
! public methods
subroutine alloc(this, mesh_block, error)
!< Allocate block.
class(field_block_FV_1D), intent(inout) :: this !< The block.
type(mesh_block_FV_1D), intent(in) :: mesh_block !< Mesh of the block.
integer(I_P), intent(out), optional :: error !< Error status.
call this%free
allocate(this%val(1-mesh_block%ng:mesh_block%n+mesh_block%ng))
if (present(error)) error = 0
end subroutine alloc
elemental subroutine free(this)
!< Free dynamic memory.
class(field_block_FV_1D), intent(inout) :: this !< The field.
if (allocated(this%val)) deallocate(this%val)
end subroutine free
subroutine init(this, mesh_field, b, error)
!< Initialize block.
class(field_block_FV_1D), intent(inout) :: this !< The block.
type(mesh_FV_1D), intent(in) :: mesh_field !< Mesh of the whole field.
integer(I_P), intent(in) :: b !< Block index.
integer(I_P), intent(out), optional :: error !< Error status.
integer(I_P) :: offset !< Cells offset.
integer(I_P) :: n !< Total number of Cells.
integer(I_P) :: i !< Counter.
offset = 0 ; if (b>1) offset = sum(mesh_field%blocks(1:b-1)%n, dim=1)
n = sum(mesh_field%blocks%n, dim=1)
call this%alloc(mesh_block=mesh_field%blocks(b), error=error)
do i = 1, mesh_field%blocks(b)%n
this%val(i) = sin((i+offset)*2._R_P*acos(-1._R_P)/n)
enddo
if (present(error)) error = 0
end subroutine init
subroutine output(this, unit, mesh_block, error)
!< Output block data.
class(field_block_FV_1D), intent(in) :: this !< The block.
integer(I_P), intent(in) :: unit !< Unit file.
type(mesh_block_FV_1D), intent(in) :: mesh_block !< Mesh of the block.
integer(I_P), intent(out), optional :: error !< Error status.
integer(I_P) :: i !< Counter.
do i=1, mesh_block%n
write(unit, *) this%val(i)
enddo
if (present(error)) error = 0
end subroutine output
! private methods
elemental function add(lhs, rhs) result(opr)
!< Add blocks.
class(field_block_FV_1D), intent(in) :: lhs !< Left hand side.
type(field_block_FV_1D), intent(in) :: rhs !< Left hand side.
type(field_block_FV_1D) :: opr !< Operator result.
opr%val = lhs%val + rhs%val
end function add
elemental subroutine assign_block(lhs, rhs)
!< Assign blocks.
class(field_block_FV_1D), intent(inout) :: lhs !< Left hand side.
type(field_block_FV_1D), intent(in) :: rhs !< Left hand side.
lhs%val = rhs%val
end subroutine assign_block
elemental function mul(lhs, rhs) result(opr)
!< Multiply blocks.
class(field_block_FV_1D), intent(in) :: lhs !< Left hand side.
type(field_block_FV_1D), intent(in) :: rhs !< Left hand side.
type(field_block_FV_1D) :: opr !< Operator result.
opr%val = lhs%val * rhs%val
end function mul
elemental function mulreal(lhs, rhs) result(opr)
!< Multiply field for real.
class(field_block_FV_1D), intent(in) :: lhs !< Left hand side.
real(R_P), intent(in) :: rhs !< Right hand side.
type(field_block_FV_1D) :: opr !< Operator result.
opr%val = lhs%val * rhs
end function mulreal
elemental function realmul(lhs, rhs) result(opr)
!< Multiply real for field.
real(R_P), intent(in) :: lhs !< Left hand side.
class(field_block_FV_1D), intent(in) :: rhs !< Right hand side.
type(field_block_FV_1D) :: opr !< Operator result.
opr%val = lhs * rhs%val
end function realmul
elemental function sub(lhs, rhs) result(opr)
!< Subtract blocks.
class(field_block_FV_1D), intent(in) :: lhs !< Left hand side.
type(field_block_FV_1D), intent(in) :: rhs !< Left hand side.
type(field_block_FV_1D) :: opr !< Operator result.
opr%val = lhs%val - rhs%val
end function sub
elemental function div(lhs, rhs) result(opr)
!< Subtract blocks.
class(field_block_FV_1D), intent(in) :: lhs !< Left hand side.
type(field_block_FV_1D), intent(in) :: rhs !< Left hand side.
type(field_block_FV_1D) :: opr !< Operator result.
opr%val = lhs%val / rhs%val
end function div
end module openpde_field_block_FV_1D
| bsd-2-clause |
prool/ccx_prool | CalculiX/ccx_2.16/src/calcvol.f | 3 | 1558 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998 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 calcvol(n1,n2,n3,n4,cotet,volume)
!
! calculates the volume of a tetrahedral element with nodes
! n1, n2, n3 and n4
!
implicit none
!
integer n1,n2,n3,n4
!
real*8 cotet(3,*),s(3),volume
!
s(1)=(cotet(2,n2)-cotet(2,n1))*(cotet(3,n3)-cotet(3,n1))-
& (cotet(3,n2)-cotet(3,n1))*(cotet(2,n3)-cotet(2,n1))
s(2)=(cotet(3,n2)-cotet(3,n1))*(cotet(1,n3)-cotet(1,n1))-
& (cotet(1,n2)-cotet(1,n1))*(cotet(3,n3)-cotet(3,n1))
s(3)=(cotet(1,n2)-cotet(1,n1))*(cotet(2,n3)-cotet(2,n1))-
& (cotet(2,n2)-cotet(2,n1))*(cotet(1,n3)-cotet(1,n1))
volume=((cotet(1,n4)-cotet(1,n1))*s(1)+
& (cotet(2,n4)-cotet(2,n1))*s(2)+
& (cotet(3,n4)-cotet(3,n1))*s(3))/6.d0
!
return
end
| gpl-2.0 |
epfl-cosmo/q-e | PW/src/update_pot.f90 | 7 | 29070 | !
! Copyright (C) 2001-2016 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!
#define ONE (1.D0,0.D0)
#define ZERO (0.D0,0.D0)
!
MODULE extrapolation
!
! ... wfc and rho extrapolation
!
USE kinds, ONLY: dp
!
REAL(dp) :: &
alpha0, &! the mixing parameters for the extrapolation
beta0 ! of the starting potential
INTEGER :: &
history, &! number of old steps available for potential updating
pot_order = 0, &! type of potential updating ( see update_pot )
wfc_order = 0 ! type of wavefunctions updating ( see update_pot )
!
PRIVATE
PUBLIC :: pot_order, wfc_order
PUBLIC :: update_file, update_neb, update_pot, extrapolate_charge
!
CONTAINS
!
!----------------------------------------------------------------------------
SUBROUTINE update_file ( )
!----------------------------------------------------------------------------
!
! ... Reads, updates and rewrites the file containing atomic positions at
! ... two previous steps, used by potential and wavefunction extrapolation
! ... Requires: number of atoms nat, current atomic positions tau
! ... Produces: length of history and tau at current and two previous steps
! ... written to file $prefix.update
!
USE io_global, ONLY : ionode
USE io_files, ONLY : iunupdate, seqopn
USE ions_base, ONLY : nat, tau
!
IMPLICIT NONE
!
REAL(DP), ALLOCATABLE :: tauold(:,:,:)
LOGICAL :: exst
!
IF ( ionode ) THEN
!
ALLOCATE( tauold( 3, nat, 3 ) )
CALL seqopn( iunupdate, 'update', 'FORMATTED', exst )
IF ( .NOT. exst ) THEN
!
! ... file not present, start the procedure
!
history = 1
tauold = 0.D0
ELSE
READ( UNIT = iunupdate, FMT = * ) history
READ( UNIT = iunupdate, FMT = * ) tauold
REWIND( UNIT = iunupdate )
!
! ... read and save the previous two steps ( three steps are saved )
!
tauold(:,:,3) = tauold(:,:,2)
tauold(:,:,2) = tauold(:,:,1)
tauold(:,:,1) = tau(:,:)
!
! ... history is updated (a new ionic step has been done)
!
history = MIN( 3, ( history + 1 ) )
!
END IF
!
! ... history and positions are written on file, file is closed
!
WRITE( UNIT = iunupdate, FMT = * ) history
WRITE( UNIT = iunupdate, FMT = * ) tauold
CLOSE( UNIT = iunupdate, STATUS = 'KEEP' )
DEALLOCATE( tauold )
!
END IF
!
END SUBROUTINE update_file
!
!----------------------------------------------------------------------------
SUBROUTINE update_neb ( )
!----------------------------------------------------------------------------
!
! ... Potential and wavefunction extrapolation for NEB
! ... Prepares file with previous steps for usage by update_pot
! ... Must be merged soon with update_file for MD in PWscf
!
USE io_global, ONLY : ionode, ionode_id
USE io_files, ONLY : iunupdate, seqopn
USE mp, ONLY : mp_bcast
USE mp_images, ONLY : intra_image_comm
USE ions_base, ONLY : nat, tau, nsp, ityp
USE gvect, ONLY : ngm, g, eigts1, eigts2, eigts3
USE vlocal, ONLY : strf
USE cell_base, ONLY : bg
USE fft_base, ONLY : dfftp
!
IMPLICIT NONE
!
REAL(DP), ALLOCATABLE :: tauold(:,:,:)
LOGICAL :: exst
!
ALLOCATE( tauold( 3, nat, 3 ) )
!
IF ( ionode ) THEN
!
CALL seqopn( iunupdate, 'update', 'FORMATTED', exst )
IF ( exst ) THEN
!
READ( UNIT = iunupdate, FMT = * ) history
READ( UNIT = iunupdate, FMT = * ) tauold
!
ELSE
!
! ... file not present: create one (update_pot needs it)
!
history = 0
tauold = 0.D0
WRITE( UNIT = iunupdate, FMT = * ) history
WRITE( UNIT = iunupdate, FMT = * ) tauold
!
END IF
!
CLOSE( UNIT = iunupdate, STATUS = 'KEEP' )
!
END IF
!
CALL mp_bcast( history, ionode_id, intra_image_comm )
CALL mp_bcast( tauold, ionode_id, intra_image_comm )
!
IF ( history > 0 ) THEN
!
! ... potential and wavefunctions are extrapolated only if
! ... we are starting a new self-consistency ( scf on the
! ... previous image was achieved )
!
IF ( pot_order > 0 ) THEN
!
! ... structure factors of the old positions are computed
! ... (needed for the old atomic charge; update_pot will then
! ... overwrite them with structure factors at curret positions)
!
CALL struc_fact( nat, tauold(:,:,1), nsp, ityp, ngm, g, bg, &
dfftp%nr1, dfftp%nr2, dfftp%nr3, strf, &
eigts1, eigts2, eigts3 )
!
END IF
!
CALL update_pot()
!
END IF
!
IF ( ionode ) THEN
!
! ... save the previous two steps, for usage in next scf
! ... ( a total of three ionic steps is saved )
!
tauold(:,:,3) = tauold(:,:,2)
tauold(:,:,2) = tauold(:,:,1)
tauold(:,:,1) = tau(:,:)
!
! ... update history count (will be used at next step)
!
history = MIN( 3, ( history + 1 ) )
!
! ... update history file (must be deleted if scf conv. not reached)
!
CALL seqopn( iunupdate, 'update', 'FORMATTED', exst )
!
WRITE( UNIT = iunupdate, FMT = * ) history
WRITE( UNIT = iunupdate, FMT = * ) tauold
!
CLOSE( UNIT = iunupdate, STATUS = 'KEEP' )
!
END IF
!
DEALLOCATE ( tauold )
!
END SUBROUTINE update_neb
!----------------------------------------------------------------------------
SUBROUTINE update_pot()
!----------------------------------------------------------------------------
!
! ... update the potential extrapolating the charge density and extrapolates
! ... the wave-functions
!
! ... charge density extrapolation :
!
! ... pot_order = 0 copy the old potential (nothing is done)
!
! ... pot_order = 1 subtract old atomic charge density and sum the new
! ... if dynamics is done the routine extrapolates also
! ... the difference between the the scf charge and the
! ... atomic one,
!
! ... pot_order = 2 first order extrapolation :
!
! ... rho(t+dt) = 2*rho(t) - rho(t-dt)
!
! ... pot_order = 3 second order extrapolation :
!
! ... rho(t+dt) = rho(t) +
! ... + alpha0*( rho(t) - rho(t-dt) )
! ... + beta0* ( rho(t-dt) - rho(t-2*dt) )
!
!
! ... wave-functions extrapolation :
!
! ... wfc_order = 0 nothing is done
!
! ... wfc_order = 2 first order extrapolation :
!
! ... |psi(t+dt)> = 2*|psi(t)> - |psi(t-dt)>
!
! ... wfc_order = 3 second order extrapolation :
!
! ... |psi(t+dt)> = |psi(t)> +
! ... + alpha0*( |psi(t)> - |psi(t-dt)> )
! ... + beta0* ( |psi(t-dt)> - |psi(t-2*dt)> )
!
!
! ... alpha0 and beta0 are calculated in "find_alpha_and_beta()" so that
! ... |tau'-tau(t+dt)| is minimum;
! ... tau' and tau(t+dt) are respectively the atomic positions at time
! ... t+dt and the extrapolated one:
!
! ... tau(t+dt) = tau(t) + alpha0*( tau(t) - tau(t-dt) )
! ... + beta0*( tau(t-dt) -tau(t-2*dt) )
!
!
USE io_files, ONLY : prefix, iunupdate, tmp_dir, wfc_dir, nd_nmbr, seqopn
USE io_global, ONLY : ionode, ionode_id
USE cell_base, ONLY : bg
USE ions_base, ONLY : nat, tau, nsp, ityp
USE gvect, ONLY : ngm, g
USE vlocal, ONLY : strf
USE mp, ONLY : mp_bcast
USE mp_images, ONLY : intra_image_comm
!
IMPLICIT NONE
!
REAL(DP), ALLOCATABLE :: tauold(:,:,:)
INTEGER :: rho_extr, wfc_extr
LOGICAL :: exists
!
!
CALL start_clock( 'update_pot' )
!
ALLOCATE( tauold( 3, nat, 3 ) )
!
IF ( ionode ) THEN
!
CALL seqopn( iunupdate, 'update', 'FORMATTED', exists )
!
IF ( exists ) THEN
!
READ( UNIT = iunupdate, FMT = * ) history
READ( UNIT = iunupdate, FMT = * ) tauold
!
! ... find the best coefficients for the extrapolation
! ... of the charge density and of the wavefunctions
! ... (see Arias et al. PRB 45, 1538 (1992) )
!
CALL find_alpha_and_beta( nat, tau, tauold, alpha0, beta0 )
!
CLOSE( UNIT = iunupdate, STATUS = 'KEEP' )
!
ELSE
!
! ... default values of extrapolation coefficients
!
alpha0 = 1.D0
beta0 = 0.D0
history = 0
tauold = 0.0_dp
!
CLOSE( UNIT = iunupdate, STATUS = 'DELETE' )
!
END IF
!
END IF
!
CALL mp_bcast( alpha0, ionode_id, intra_image_comm )
CALL mp_bcast( beta0, ionode_id, intra_image_comm )
CALL mp_bcast( history,ionode_id, intra_image_comm )
CALL mp_bcast( tauold, ionode_id, intra_image_comm )
!
IF ( wfc_order > 0 ) THEN
!
! ... determines the maximum effective order of the extrapolation on the
! ... basis of the files that are really available (for wavefunctions)
!
IF ( ionode ) THEN
!
wfc_extr = MIN( 1, history, wfc_order )
!
INQUIRE( FILE = TRIM( wfc_dir ) // &
& TRIM( prefix ) // '.oldwfc' // nd_nmbr, EXIST = exists )
!
IF ( exists ) THEN
!
wfc_extr = MIN( 2, history, wfc_order )
!
INQUIRE( FILE = TRIM( wfc_dir ) // &
& TRIM( prefix ) // '.old2wfc' // nd_nmbr , EXIST = exists )
!
IF ( exists ) wfc_extr = MIN( 3, history, wfc_order )
!
END IF
!
END IF
!
CALL mp_bcast( wfc_extr, ionode_id, intra_image_comm )
!
!
! ... save tau(t+dt), replace with tau(t)
! ... extrapolate_wfcs needs tau(t) to evaluate S(t)
! ... note that structure factors have not yet been updated
!
tauold (:,:,2) = tau (:,:)
tau (:,:) = tauold (:,:,1)
!
CALL extrapolate_wfcs( wfc_extr )
!
! ... restore tau(t+dt)
!
tau (:,:) = tauold (:,:,2)
!
END IF
!
DEALLOCATE( tauold )
!
! ... determines the maximum effective order of the extrapolation on the
! ... basis of the files that are really available (for the charge density)
!
IF ( ionode ) THEN
!
rho_extr = MIN( 1, history, pot_order )
!
INQUIRE( FILE = TRIM( tmp_dir ) // TRIM( prefix ) // &
& '.save/charge-density.old.dat', EXIST = exists )
!
IF ( .NOT. exists ) &
!
INQUIRE( FILE = TRIM( tmp_dir ) // TRIM( prefix ) // &
& '.save/charge-density.old.xml', EXIST = exists )
!
IF ( exists ) THEN
!
rho_extr = MIN( 2, history, pot_order )
!
INQUIRE( FILE = TRIM( tmp_dir ) // TRIM( prefix ) // &
& '.save/charge-density.old2.dat', EXIST = exists )
!
IF ( .NOT. exists ) &
!
INQUIRE( FILE = TRIM( tmp_dir ) // TRIM( prefix ) // &
& '.save/charge-density.old2.xml', EXIST = exists )
!
IF ( exists ) rho_extr = MIN( 3, history, pot_order )
!
END IF
!
END IF
!
CALL mp_bcast( rho_extr, ionode_id, intra_image_comm )
!
CALL extrapolate_charge( rho_extr )
!
CALL stop_clock( 'update_pot' )
!
RETURN
!
END SUBROUTINE update_pot
!
!----------------------------------------------------------------------------
SUBROUTINE extrapolate_charge( rho_extr )
!----------------------------------------------------------------------------
!
USE constants, ONLY : eps32
USE io_global, ONLY : stdout
USE cell_base, ONLY : omega, bg
USE ions_base, ONLY : nat, tau, nsp, ityp
USE fft_base, ONLY : dfftp, dffts
USE fft_interfaces, ONLY : fwfft, invfft
USE gvect, ONLY : ngm, g, gg, gstart, nl, eigts1, eigts2, eigts3
USE lsda_mod, ONLY : lsda, nspin
USE scf, ONLY : rho, rho_core, rhog_core, v
USE ldaU, ONLY : eth
USE wavefunctions_module, ONLY : psic
USE ener, ONLY : ehart, etxc, vtxc, epaw
USE extfield, ONLY : etotefield
USE cellmd, ONLY : lmovecell, omega_old
USE vlocal, ONLY : strf
USE noncollin_module, ONLY : noncolin
USE klist, ONLY : nelec
USE io_rho_xml, ONLY : write_rho, read_rho
USE paw_variables, ONLY : okpaw, ddd_paw
USE paw_onecenter, ONLY : PAW_potential
!
IMPLICIT NONE
!
INTEGER, INTENT(IN) :: rho_extr
!
REAL(DP), ALLOCATABLE :: work(:,:), work1(:,:)
! work is the difference between rho and atomic rho at time t
! work1 is the same thing at time t-dt
REAL(DP) :: charge
!
INTEGER :: is
!
IF ( rho_extr < 1 ) THEN
!
! ... calculate structure factors for the new positions
!
IF ( lmovecell ) CALL scale_h()
!
CALL struc_fact( nat, tau, nsp, ityp, ngm, g, bg, &
dfftp%nr1, dfftp%nr2, dfftp%nr3, strf, eigts1, eigts2, eigts3 )
!
! ... new charge density from extrapolated wfcs
!
IF ( rho_extr < 0 ) THEN
!
CALL sum_band ()
!
WRITE( UNIT = stdout, FMT = '(5X, &
& "charge density from extrapolated wavefunctions")' )
ELSE
!
WRITE( UNIT = stdout, FMT = '(5X, &
& "charge density from previous step")' )
!
END IF
!
CALL set_rhoc()
!
ELSE
!
ALLOCATE( work( dfftp%nnr, 1 ) )
!
work = 0.D0
!
! ... in the lsda case the magnetization will follow rigidly the density
! ... keeping fixed the value of zeta = mag / rho_tot.
! ... zeta is set here and put in rho%of_r(:,2) while rho%of_r(:,1)
! ... will contain the total valence charge
!
IF ( lsda ) CALL rho2zeta( rho%of_r, rho_core, dfftp%nnr, nspin, 1 )
!
IF ( noncolin ) THEN
!
DO is = 2, nspin
!
WHERE( rho%of_r(:,1) > eps32 )
!
rho%of_r(:,is) = rho%of_r(:,is) / rho%of_r(:,1)
!
ELSEWHERE
!
rho%of_r(:,is) = 0.D0
!
END WHERE
!
END DO
!
END IF
!
! ... subtract the old atomic charge density
!
CALL atomic_rho( work, 1 )
!
rho%of_r(:,1) = rho%of_r(:,1) - work(:,1)
!
IF ( lmovecell ) rho%of_r(:,1) = rho%of_r(:,1) * omega_old
!
! ... extrapolate the difference between the atomic charge and
! ... the self-consistent one
!
IF ( rho_extr == 1 ) THEN
!
! ... if rho_extr = 1 update the potential subtracting to the charge
! ... density the "old" atomic charge and summing the
! ... new one
!
WRITE( UNIT = stdout, FMT = '(5X, &
& "NEW-OLD atomic charge density approx. for the potential")' )
!
CALL write_rho( rho%of_r, 1, 'old' )
!
ELSE IF ( rho_extr == 2 ) THEN
!
WRITE( UNIT = stdout, &
FMT = '(5X,"first order charge density extrapolation")' )
!
! ... oldrho -> work
!
CALL read_rho( work, 1, 'old' )
!
! ... rho%of_r -> oldrho
! ... work -> oldrho2
!
CALL write_rho( rho%of_r, 1, 'old' )
CALL write_rho( work, 1, 'old2' )
!
! ... extrapolation
!
rho%of_r(:,1) = 2.D0*rho%of_r(:,1) - work(:,1)
!
ELSE IF ( rho_extr == 3 ) THEN
!
WRITE( UNIT = stdout, &
FMT = '(5X,"second order charge density extrapolation")' )
!
ALLOCATE( work1( dfftp%nnr, 1 ) )
!
work1 = 0.D0
!
! ... oldrho2 -> work1
! ... oldrho -> work
!
CALL read_rho( work1, 1, 'old2' )
CALL read_rho( work, 1, 'old' )
!
! ... rho%of_r -> oldrho
! ... work -> oldrho2
!
CALL write_rho( rho%of_r, 1, 'old' )
CALL write_rho( work, 1, 'old2' )
!
rho%of_r(:,1) = rho%of_r(:,1) + alpha0*( rho%of_r(:,1) - work(:,1) ) + &
beta0*( work(:,1) - work1(:,1) )
!
DEALLOCATE( work1 )
!
END IF
!
IF ( lmovecell ) rho%of_r(:,1) = rho%of_r(:,1) / omega
!
! ... calculate structure factors for the new positions
!
IF ( lmovecell ) CALL scale_h()
!
CALL struc_fact( nat, tau, nsp, ityp, ngm, g, bg, &
dfftp%nr1, dfftp%nr2, dfftp%nr3, strf, eigts1, eigts2, eigts3 )
!
CALL set_rhoc()
!
! ... add atomic charges in the new positions
!
CALL atomic_rho( work, 1 )
!
rho%of_r(:,1) = rho%of_r(:,1) + work(:,1)
!
! ... reset up and down charge densities in the LSDA case
!
IF ( lsda ) CALL rho2zeta( rho%of_r, rho_core, dfftp%nnr, nspin, -1 )
!
IF ( noncolin ) THEN
!
DO is = 2, nspin
!
WHERE( rho%of_r(:,1) > eps32 )
!
rho%of_r(:,is) = rho%of_r(:,is)*rho%of_r(:,1)
!
ELSEWHERE
!
rho%of_r(:,is) = 0.D0
!
END WHERE
!
END DO
!
END IF
!
DEALLOCATE( work )
!
END IF
!
! ... bring extrapolated rho to G-space
!
DO is = 1, nspin
!
psic(:) = rho%of_r(:,is)
!
CALL fwfft ('Dense', psic, dfftp)
!
rho%of_g(:,is) = psic(nl(:))
!
END DO
!
CALL v_of_rho( rho, rho_core, rhog_core, &
ehart, etxc, vtxc, eth, etotefield, charge, v )
IF (okpaw) CALL PAW_potential(rho%bec, ddd_PAW, epaw)
!
IF ( ABS( charge - nelec ) / charge > 1.D-7 ) THEN
!
WRITE( stdout, &
'(5X,"extrapolated charge ",F10.5,", renormalised to ",F10.5)') &
charge, nelec
!
rho%of_r = rho%of_r / charge*nelec
rho%of_g = rho%of_g / charge*nelec
!
END IF
!
RETURN
!
END SUBROUTINE extrapolate_charge
!
!-----------------------------------------------------------------------
SUBROUTINE extrapolate_wfcs( wfc_extr )
!-----------------------------------------------------------------------
!
! ... This routine extrapolate the wfc's after a "parallel alignment"
! ... of the basis of the t-dt and t time steps, according to a recipe
! ... by Mead, Rev. Mod. Phys., vol 64, pag. 51 (1992), eqs. 3.20-3.29
!
USE io_global, ONLY : stdout
USE klist, ONLY : nks, ngk, xk, igk_k
USE lsda_mod, ONLY : lsda, current_spin, isk
USE wvfct, ONLY : nbnd, npwx
USE ions_base, ONLY : nat, tau
USE io_files, ONLY : nwordwfc, iunwfc, iunoldwfc, &
iunoldwfc2, diropn
USE buffers, ONLY : get_buffer, save_buffer
USE uspp, ONLY : nkb, vkb, okvan
USE wavefunctions_module, ONLY : evc
USE noncollin_module, ONLY : noncolin, npol
USE control_flags, ONLY : gamma_only
USE becmod, ONLY : allocate_bec_type, deallocate_bec_type, &
bec_type, becp, calbec
USE mp_images, ONLY : intra_image_comm
USE mp, ONLY : mp_barrier
!
IMPLICIT NONE
!
INTEGER, INTENT(IN) :: wfc_extr
!
INTEGER :: npw, ik, zero_ew, lwork, info
! do-loop variables
! counter on k-points
! number of zero 'eigenvalues' of the s_m matrix
! used by singular value decomposition (ZGESVD)
! flag returned by ZGESVD
COMPLEX(DP), ALLOCATABLE :: sp_m(:,:), u_m(:,:), w_m(:,:), work(:)
! the overlap matrix s^+ (eq. 3.24)
! left unitary matrix in the SVD of sp_m
! right unitary matrix in the SVD of sp_m
! workspace for ZGESVD
COMPLEX(DP), ALLOCATABLE :: evcold(:,:), aux(:,:)
! wavefunctions at previous iteration + workspace
REAL(DP), ALLOCATABLE :: ew(:), rwork(:), rp_m(:,:)
! the eigenvalues of s_m
! workspace for ZGESVD
! real version of sp_m
LOGICAL :: exst
!
CALL mp_barrier( intra_image_comm ) ! debug
!
IF ( wfc_extr == 1 ) THEN
!
CALL diropn( iunoldwfc, 'oldwfc', 2*nwordwfc, exst )
!
DO ik = 1, nks
!
! ... "now" -> "old"
!
IF ( nks > 1 ) CALL get_buffer( evc, nwordwfc, iunwfc, ik )
CALL davcio( evc, 2*nwordwfc, iunoldwfc, ik, +1 )
!
END DO
!
CLOSE( UNIT = iunoldwfc, STATUS = 'KEEP' )
!
ELSE
!
CALL diropn( iunoldwfc, 'oldwfc', 2*nwordwfc, exst )
IF ( wfc_extr > 2 .OR. wfc_order > 2 ) &
CALL diropn( iunoldwfc2, 'old2wfc', 2*nwordwfc, exst )
!
IF ( wfc_extr == 2 ) THEN
!
WRITE( stdout, '(/5X,"first order wave-functions extrapolation")' )
!
ELSE
!
WRITE( stdout, '(/5X,"second order wave-functions extrapolation")' )
!
END IF
!
ALLOCATE( evcold( npwx*npol, nbnd ), aux( npwx*npol, nbnd ) )
ALLOCATE( sp_m( nbnd, nbnd ), u_m( nbnd, nbnd ), w_m( nbnd, nbnd ), ew( nbnd ) )
CALL allocate_bec_type ( nkb, nbnd, becp )
!
IF( SIZE( aux ) /= SIZE( evc ) ) &
CALL errore('extrapolate_wfcs ', ' aux wrong size ', ABS( SIZE( aux ) - SIZE( evc ) ) )
!
! query workspace
!
lwork = 5*nbnd
!
ALLOCATE( rwork( lwork ) )
ALLOCATE( work( lwork ) )
lwork = -1
CALL ZGESVD( 'A', 'A', nbnd, nbnd, sp_m, nbnd, ew, u_m, &
nbnd, w_m, nbnd, work, lwork, rwork, info )
!
lwork = INT(work( 1 )) + 1
!
IF( lwork > SIZE( work ) ) THEN
DEALLOCATE( work )
ALLOCATE( work( lwork ) )
END IF
!
zero_ew = 0
!
DO ik = 1, nks
!
! ... read wavefcts as (t-dt), replace with wavefcts at (t)
!
CALL davcio( evcold, 2*nwordwfc, iunoldwfc, ik, -1 )
IF ( nks > 1 ) CALL get_buffer( evc, nwordwfc, iunwfc, ik )
CALL davcio( evc, 2*nwordwfc, iunoldwfc, ik, +1 )
!
npw = ngk (ik)
IF ( okvan ) THEN
!
! ... Ultrasoft PP: calculate overlap matrix
! ... Required by s_psi:
! ... nonlocal pseudopotential projectors |beta>, <psi|beta>
!
IF ( nkb > 0 ) CALL init_us_2( npw, igk_k(1,ik), xk(1,ik), vkb )
CALL calbec( npw, vkb, evc, becp )
!
CALL s_psi ( npwx, npw, nbnd, evc, aux )
!
ELSE
!
! ... Norm-Conserving PP: no overlap matrix
!
aux = evc
!
END IF
!
! ... construct s^+_m = <psi(t)|S|psi(t-dt)>
!
IF ( gamma_only ) THEN
ALLOCATE( rp_m ( nbnd, nbnd ) )
CALL calbec ( npw, aux, evcold, rp_m )
sp_m(:,:) = CMPLX(rp_m(:,:),0.0_DP,kind=DP)
DEALLOCATE( rp_m )
ELSE IF ( noncolin) THEN
CALL calbec ( npwx*npol, aux, evcold, sp_m )
ELSE
CALL calbec ( npw, aux, evcold, sp_m )
END IF
!
! ... the unitary matrix [sp_m*s_m]^(-1/2)*sp_m (eq. 3.29) by means the
! ... singular value decomposition (SVD) of sp_m = u_m*diag(ew)*w_m
! ... becomes u_m * w_m
!
CALL ZGESVD( 'A', 'A', nbnd, nbnd, sp_m, nbnd, ew, u_m, &
nbnd, w_m, nbnd, work, lwork, rwork, info )
!
! ... check on eigenvalues
!
zero_ew = COUNT( ew(:) < 0.1D0 )
!
! ... use sp_m to store u_m * w_m
!
CALL ZGEMM( 'N', 'N', nbnd, nbnd, nbnd, ONE, &
u_m, nbnd, w_m, nbnd, ZERO, sp_m, nbnd )
!
! ... now use aux as workspace to calculate "aligned" wavefcts:
!
! ... aux_i = sum_j evcold_j*s_m_ji (eq.3.21)
!
CALL ZGEMM( 'N', 'C', npw, nbnd, nbnd, ONE, &
evcold, npwx, sp_m, nbnd, ZERO, aux, npwx )
!
! ... alpha0 and beta0 are calculated in "update_pot"
! ... for first-order interpolation, alpha0=1, beta0=0
!
IF ( wfc_extr == 3 ) THEN
evc = ( 1.0_dp + alpha0 ) * evc + ( beta0 - alpha0 ) * aux
ELSE
evc = 2.0_dp * evc - aux
END IF
!
IF ( wfc_order > 2 ) THEN
!
! ... second-order interpolation:
! ... read wavefcts at (t-2dt), save aligned wavefcts at (t-dt)
!
IF ( wfc_extr == 3 ) &
CALL davcio( evcold, 2*nwordwfc, iunoldwfc2, ik, -1 )
!
CALL davcio( aux, 2*nwordwfc, iunoldwfc2, ik, +1 )
!
IF ( wfc_extr ==3 ) THEN
!
! ... align wfcs at (t-2dt), add to interpolation formula
!
CALL ZGEMM( 'N', 'C', npw, nbnd, nbnd, ONE, &
evcold, npwx, sp_m, nbnd, ZERO, aux, npwx )
!
evc = evc - beta0 * aux
!
END IF
!
END IF
!
! ... save interpolated wavefunctions to file iunwfc
!
IF ( nks > 1 ) CALL save_buffer( evc, nwordwfc, iunwfc, ik )
!
END DO
!
IF ( zero_ew > 0 ) &
WRITE( stdout, '( 5X,"Message from extrapolate_wfcs: ",/, &
& 5X,"the matrix <psi(t-dt)|psi(t)> has ", &
& I2," small (< 0.1) eigenvalues")' ) zero_ew
!
DEALLOCATE( u_m, w_m, ew, aux, evcold, sp_m )
DEALLOCATE( work, rwork )
CALL deallocate_bec_type ( becp )
!
CLOSE( UNIT = iunoldwfc, STATUS = 'KEEP' )
IF ( wfc_extr > 2 .OR. wfc_order > 2 ) &
CLOSE( UNIT = iunoldwfc2, STATUS = 'KEEP' )
!
END IF
!
CALL mp_barrier( intra_image_comm ) ! debug
!
RETURN
!
END SUBROUTINE extrapolate_wfcs
!
! ... this routine is used also by compute_scf (NEB) and compute_fes_grads
!
!----------------------------------------------------------------------------
SUBROUTINE find_alpha_and_beta( nat, tau, tauold, alpha0, beta0 )
!----------------------------------------------------------------------------
!
! ... This routine finds the best coefficients alpha0 and beta0 so that
!
! ... | tau(t+dt) - tau' | is minimum, where
!
! ... tau' = tau(t) + alpha0 * ( tau(t) - tau(t-dt) )
! ... + beta0 * ( tau(t-dt) -tau(t-2*dt) )
!
USE constants, ONLY : eps16
USE io_global, ONLY : stdout
!
IMPLICIT NONE
!
INTEGER :: nat, na, ipol
REAL(DP) :: alpha0, beta0, tau(3,nat), tauold(3,nat,3)
REAL(DP) :: a11, a12, a21, a22, b1, b2, c, det
!
!
IF ( history <= 2 ) RETURN
!
! ... solution of the linear system
!
a11 = 0.D0
a12 = 0.D0
a21 = 0.D0
a22 = 0.D0
b1 = 0.D0
b2 = 0.D0
c = 0.D0
!
DO na = 1, nat
!
DO ipol = 1, 3
!
a11 = a11 + ( tauold(ipol,na,1) - tauold(ipol,na,2) )**2
!
a12 = a12 + ( tauold(ipol,na,1) - tauold(ipol,na,2) ) * &
( tauold(ipol,na,2) - tauold(ipol,na,3) )
!
a22 = a22 + ( tauold(ipol,na,2) - tauold(ipol,na,3) )**2
!
b1 = b1 - ( tauold(ipol,na,1) - tau(ipol,na) ) * &
( tauold(ipol,na,1) - tauold(ipol,na,2) )
!
b2 = b2 - ( tauold(ipol,na,1) - tau(ipol,na) ) * &
( tauold(ipol,na,2) - tauold(ipol,na,3) )
!
c = c + ( tauold(ipol,na,1) - tau(ipol,na) )**2
!
END DO
!
END DO
!
a21 = a12
!
det = a11 * a22 - a12 * a21
!
IF ( det < - eps16 ) THEN
!
alpha0 = 0.D0
beta0 = 0.D0
!
WRITE( UNIT = stdout, &
FMT = '(5X,"WARNING: in find_alpha_and_beta det = ",F10.6)' ) det
!
END IF
!
! ... case det > 0: a well defined minimum exists
!
IF ( det > eps16 ) THEN
!
alpha0 = ( b1 * a22 - b2 * a12 ) / det
beta0 = ( a11 * b2 - a21 * b1 ) / det
!
ELSE
!
! ... case det = 0 : the two increments are linearly dependent,
! ... chose solution with alpha = b1 / a11 and beta = 0
! ... ( discard oldest configuration )
!
alpha0 = 0.D0
beta0 = 0.D0
!
IF ( a11 /= 0.D0 ) alpha0 = b1 / a11
!
END IF
!
RETURN
!
END SUBROUTINE find_alpha_and_beta
!
END MODULE extrapolation
| gpl-2.0 |
prool/ccx_prool | ARPACK_i8/BLAS/zgbmv.f | 25 | 10059 | SUBROUTINE ZGBMV ( TRANS, M, N, KL, KU, ALPHA, A, LDA, X, INCX,
$ BETA, Y, INCY )
* .. Scalar Arguments ..
COMPLEX*16 ALPHA, BETA
INTEGER INCX, INCY, KL, KU, LDA, M, N
CHARACTER*1 TRANS
* .. Array Arguments ..
COMPLEX*16 A( LDA, * ), X( * ), Y( * )
* ..
*
* Purpose
* =======
*
* ZGBMV performs one of the matrix-vector operations
*
* y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, or
*
* y := alpha*conjg( A' )*x + beta*y,
*
* where alpha and beta are scalars, x and y are vectors and A is an
* m by n band matrix, with kl sub-diagonals and ku super-diagonals.
*
* Parameters
* ==========
*
* TRANS - CHARACTER*1.
* On entry, TRANS specifies the operation to be performed as
* follows:
*
* TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
*
* TRANS = 'T' or 't' y := alpha*A'*x + beta*y.
*
* TRANS = 'C' or 'c' y := alpha*conjg( A' )*x + beta*y.
*
* Unchanged on exit.
*
* M - INTEGER.
* On entry, M specifies the number of rows of the matrix A.
* M must be at least zero.
* Unchanged on exit.
*
* N - INTEGER.
* On entry, N specifies the number of columns of the matrix A.
* N must be at least zero.
* Unchanged on exit.
*
* KL - INTEGER.
* On entry, KL specifies the number of sub-diagonals of the
* matrix A. KL must satisfy 0 .le. KL.
* Unchanged on exit.
*
* KU - INTEGER.
* On entry, KU specifies the number of super-diagonals of the
* matrix A. KU must satisfy 0 .le. KU.
* Unchanged on exit.
*
* ALPHA - COMPLEX*16 .
* On entry, ALPHA specifies the scalar alpha.
* Unchanged on exit.
*
* A - COMPLEX*16 array of DIMENSION ( LDA, n ).
* Before entry, the leading ( kl + ku + 1 ) by n part of the
* array A must contain the matrix of coefficients, supplied
* column by column, with the leading diagonal of the matrix in
* row ( ku + 1 ) of the array, the first super-diagonal
* starting at position 2 in row ku, the first sub-diagonal
* starting at position 1 in row ( ku + 2 ), and so on.
* Elements in the array A that do not correspond to elements
* in the band matrix (such as the top left ku by ku triangle)
* are not referenced.
* The following program segment will transfer a band matrix
* from conventional full matrix storage to band storage:
*
* DO 20, J = 1, N
* K = KU + 1 - J
* DO 10, I = MAX( 1, J - KU ), MIN( M, J + KL )
* A( K + I, J ) = matrix( I, J )
* 10 CONTINUE
* 20 CONTINUE
*
* Unchanged on exit.
*
* LDA - INTEGER.
* On entry, LDA specifies the first dimension of A as declared
* in the calling (sub) program. LDA must be at least
* ( kl + ku + 1 ).
* Unchanged on exit.
*
* X - COMPLEX*16 array of DIMENSION at least
* ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
* and at least
* ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
* Before entry, the incremented array X must contain the
* vector x.
* Unchanged on exit.
*
* INCX - INTEGER.
* On entry, INCX specifies the increment for the elements of
* X. INCX must not be zero.
* Unchanged on exit.
*
* BETA - COMPLEX*16 .
* On entry, BETA specifies the scalar beta. When BETA is
* supplied as zero then Y need not be set on input.
* Unchanged on exit.
*
* Y - COMPLEX*16 array of DIMENSION at least
* ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
* and at least
* ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
* Before entry, the incremented array Y must contain the
* vector y. On exit, Y is overwritten by the updated vector y.
*
*
* INCY - INTEGER.
* On entry, INCY specifies the increment for the elements of
* Y. INCY must not be zero.
* Unchanged on exit.
*
*
* Level 2 Blas routine.
*
* -- Written on 22-October-1986.
* Jack Dongarra, Argonne National Lab.
* Jeremy Du Croz, Nag Central Office.
* Sven Hammarling, Nag Central Office.
* Richard Hanson, Sandia National Labs.
*
*
* .. Parameters ..
COMPLEX*16 ONE
PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )
COMPLEX*16 ZERO
PARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )
* .. Local Scalars ..
COMPLEX*16 TEMP
INTEGER I, INFO, IX, IY, J, JX, JY, K, KUP1, KX, KY,
$ LENX, LENY
LOGICAL NOCONJ
* .. External Functions ..
LOGICAL LSAME
EXTERNAL LSAME
* .. External Subroutines ..
EXTERNAL XERBLA
* .. Intrinsic Functions ..
INTRINSIC DCONJG, MAX, MIN
* ..
* .. Executable Statements ..
*
* Test the input parameters.
*
INFO = 0
IF ( .NOT.LSAME( TRANS, 'N' ).AND.
$ .NOT.LSAME( TRANS, 'T' ).AND.
$ .NOT.LSAME( TRANS, 'C' ) )THEN
INFO = 1
ELSE IF( M.LT.0 )THEN
INFO = 2
ELSE IF( N.LT.0 )THEN
INFO = 3
ELSE IF( KL.LT.0 )THEN
INFO = 4
ELSE IF( KU.LT.0 )THEN
INFO = 5
ELSE IF( LDA.LT.( KL + KU + 1 ) )THEN
INFO = 8
ELSE IF( INCX.EQ.0 )THEN
INFO = 10
ELSE IF( INCY.EQ.0 )THEN
INFO = 13
END IF
IF( INFO.NE.0 )THEN
CALL XERBLA( 'ZGBMV ', INFO )
RETURN
END IF
*
* Quick return if possible.
*
IF( ( M.EQ.0 ).OR.( N.EQ.0 ).OR.
$ ( ( ALPHA.EQ.ZERO ).AND.( BETA.EQ.ONE ) ) )
$ RETURN
*
NOCONJ = LSAME( TRANS, 'T' )
*
* Set LENX and LENY, the lengths of the vectors x and y, and set
* up the start points in X and Y.
*
IF( LSAME( TRANS, 'N' ) )THEN
LENX = N
LENY = M
ELSE
LENX = M
LENY = N
END IF
IF( INCX.GT.0 )THEN
KX = 1
ELSE
KX = 1 - ( LENX - 1 )*INCX
END IF
IF( INCY.GT.0 )THEN
KY = 1
ELSE
KY = 1 - ( LENY - 1 )*INCY
END IF
*
* Start the operations. In this version the elements of A are
* accessed sequentially with one pass through the band part of A.
*
* First form y := beta*y.
*
IF( BETA.NE.ONE )THEN
IF( INCY.EQ.1 )THEN
IF( BETA.EQ.ZERO )THEN
DO 10, I = 1, LENY
Y( I ) = ZERO
10 CONTINUE
ELSE
DO 20, I = 1, LENY
Y( I ) = BETA*Y( I )
20 CONTINUE
END IF
ELSE
IY = KY
IF( BETA.EQ.ZERO )THEN
DO 30, I = 1, LENY
Y( IY ) = ZERO
IY = IY + INCY
30 CONTINUE
ELSE
DO 40, I = 1, LENY
Y( IY ) = BETA*Y( IY )
IY = IY + INCY
40 CONTINUE
END IF
END IF
END IF
IF( ALPHA.EQ.ZERO )
$ RETURN
KUP1 = KU + 1
IF( LSAME( TRANS, 'N' ) )THEN
*
* Form y := alpha*A*x + y.
*
JX = KX
IF( INCY.EQ.1 )THEN
DO 60, J = 1, N
IF( X( JX ).NE.ZERO )THEN
TEMP = ALPHA*X( JX )
K = KUP1 - J
DO 50, I = MAX( 1, J - KU ), MIN( M, J + KL )
Y( I ) = Y( I ) + TEMP*A( K + I, J )
50 CONTINUE
END IF
JX = JX + INCX
60 CONTINUE
ELSE
DO 80, J = 1, N
IF( X( JX ).NE.ZERO )THEN
TEMP = ALPHA*X( JX )
IY = KY
K = KUP1 - J
DO 70, I = MAX( 1, J - KU ), MIN( M, J + KL )
Y( IY ) = Y( IY ) + TEMP*A( K + I, J )
IY = IY + INCY
70 CONTINUE
END IF
JX = JX + INCX
IF( J.GT.KU )
$ KY = KY + INCY
80 CONTINUE
END IF
ELSE
*
* Form y := alpha*A'*x + y or y := alpha*conjg( A' )*x + y.
*
JY = KY
IF( INCX.EQ.1 )THEN
DO 110, J = 1, N
TEMP = ZERO
K = KUP1 - J
IF( NOCONJ )THEN
DO 90, I = MAX( 1, J - KU ), MIN( M, J + KL )
TEMP = TEMP + A( K + I, J )*X( I )
90 CONTINUE
ELSE
DO 100, I = MAX( 1, J - KU ), MIN( M, J + KL )
TEMP = TEMP + DCONJG( A( K + I, J ) )*X( I )
100 CONTINUE
END IF
Y( JY ) = Y( JY ) + ALPHA*TEMP
JY = JY + INCY
110 CONTINUE
ELSE
DO 140, J = 1, N
TEMP = ZERO
IX = KX
K = KUP1 - J
IF( NOCONJ )THEN
DO 120, I = MAX( 1, J - KU ), MIN( M, J + KL )
TEMP = TEMP + A( K + I, J )*X( IX )
IX = IX + INCX
120 CONTINUE
ELSE
DO 130, I = MAX( 1, J - KU ), MIN( M, J + KL )
TEMP = TEMP + DCONJG( A( K + I, J ) )*X( IX )
IX = IX + INCX
130 CONTINUE
END IF
Y( JY ) = Y( JY ) + ALPHA*TEMP
JY = JY + INCY
IF( J.GT.KU )
$ KX = KX + INCX
140 CONTINUE
END IF
END IF
*
RETURN
*
* End of ZGBMV .
*
END
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.10/src/calccvfa.f | 3 | 1489 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 calccvfa(nface,vfa,shcon,nshcon,ielmat,ntmat_,
& mi,ielfa,cvfa,physcon)
!
! calculation of the secant heat capacity at constant pressure/volume
! at the face centers (incompressible media)
!
implicit none
!
integer nface,i,nshcon(2,*),imat,ntmat_,mi(*),
& ielmat(mi(3),*),ielfa(4,*)
!
real*8 t1l,vfa(0:5,*),cp,shcon(0:3,ntmat_,*),cvfa(*),physcon(*)
!
do i=1,nface
t1l=vfa(0,i)
!
! take the material of the first adjacent element
!
imat=ielmat(1,ielfa(1,i))
call materialdata_cp_sec(imat,ntmat_,t1l,shcon,nshcon,cp,
& physcon)
cvfa(i)=cp
enddo
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.9/src/radiate.f | 4 | 3292 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 radiate(e,sink,temp,kstep,kinc,time,noel,npt,
& coords,jltyp,field,nfield,loadtype,node,area,vold,mi,
& iemchange)
!
! user subroutine radiate
!
!
! INPUT:
!
! sink present sink temperature
! temp current temperature value
! kstep step number
! kinc increment number
! time(1) current step time
! time(2) current total time
! noel element number
! npt integration point number
! coords(1..3) global coordinates of the integration point
! jltyp loading face kode:
! 11 = face 1
! 12 = face 2
! 13 = face 3
! 14 = face 4
! 15 = face 5
! 16 = face 6
! field currently not used
! nfield currently not used (value = 1)
! loadtype load type label
! node currently not used
! area area covered by the integration point
! vold(0..4,1..nk) solution field in all nodes
! 0: temperature
! 1: displacement in global x-direction
! 2: displacement in global y-direction
! 3: displacement in global z-direction
! 4: static pressure
! mi(1) max # of integration points per element (max
! over all elements)
! mi(2) max degree of freedomm per node (max over all
! nodes) in fields like v(0:mi(2))...
!
! OUTPUT:
!
! e(1) magnitude of the emissivity
! e(2) not used; please do NOT assign any value
! sink sink temperature (need not be defined
! for cavity radiation)
! iemchange = 1 if the emissivity is changed during
! a step, else zero.
!
implicit none
!
character*20 loadtype
!
integer kstep,kinc,noel,npt,jltyp,nfield,node,mi(*),iemchange
!
real*8 e(2),sink,time(2),coords(3),temp,field(nfield),area,
& vold(0:mi(2),*)
!
intent(in) temp,kstep,kinc,time,noel,npt,
& coords,jltyp,field,nfield,loadtype,node,area,vold,mi
!
intent(out) e,iemchange
!
intent(inout) sink
!
e(1)=0.72d0
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.8p2/src/shape3l.f | 2 | 2019 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 shape3l(xi,xl,xsj,xs,shp,iflag)
!
! shape functions and derivatives for a 3-node quadratic
! isoparametric 1-D element. -1<=xi<=1
!
! iflag=2: calculate the value of the shape functions,
! their derivatives w.r.t. the local coordinates
! and the Jacobian (size of tangent vector to the
! curved line)
!
implicit none
!
integer i,k,iflag
!
real*8 shp(7,3),xs(3,7),xsi(2,3),xl(3,3),sh(3),xsj(3)
!
real*8 xi
!
! shape functions and their glocal derivatives for an element
! described with two local parameters and three global ones.
!
! local derivatives of the shape functions: xi-derivative
!
shp(1,1)=xi-0.5d0
shp(1,2)=-2.d0*xi
shp(1,3)=xi+0.5d0
!
! shape functions
!
shp(4,1)=xi*(xi-1.d0)/2.d0
shp(4,2)=(1.d0-xi)*(1.d0+xi)
shp(4,3)=xi*(xi+1.d0)/2.d0
!
! computation of the local derivative of the global coordinates
! (xs)
!
do i=1,3
xs(i,1)=0.d0
do k=1,3
xs(i,1)=xs(i,1)+xl(i,k)*shp(1,k)
enddo
enddo
!
! computation of the jacobian vector
!
xsj(1)=dsqrt(xs(1,1)**2+xs(2,1)**2+xs(3,1)**2)
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.10/src/boundaryfs.f | 4 | 8900 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 boundaryfs(inpc,textpart,set,istartset,iendset,
& ialset,nset,nodeboun,ndirboun,xboun,nboun,nboun_,nk,
& iamboun,amname,nam,ipompc,nodempc,coefmpc,nmpc,nmpc_,
& mpcfree,trab,ntrans,ikboun,ilboun,ikmpc,ilmpc,nk_,
& co,labmpc,typeboun,istat,n,iline,ipol,
& inl,ipoinp,inp,nam_,namtot_,namta,amta,nmethod,iperturb,
& ipoinpc,vold,mi,xload,sideload,nload,nelemload,lakon,kon,
& ipkon,ne)
!
! reading the input deck: *BOUNDARYF
!
! (boundary conditions for CFD-calculations)
!
implicit none
!
logical user,fixed
!
character*1 typeboun(*),type,inpc(*)
character*8 lakon(*)
character*20 labmpc(*),sideload(*)
character*80 amname(*),amplitude
character*81 set(*),elset
character*132 textpart(16)
!
integer istartset(*),iendset(*),ialset(*),nodeboun(*),
& ndirboun(*),iface,nload,nelemload(2,*),kon(*),ipkon(*),
& nset,nboun,nboun_,istat,n,i,j,k,l,ibounstart,ibounend,
& key,nk,iamboun(*),nam,iamplitude,ipompc(*),nodempc(3,*),
& nmpc,nmpc_,mpcfree,ikboun(*),ilboun(*),ikmpc(*),
& ilmpc(*),ntrans,nk_,ipos,m,ne,
& iline,ipol,inl,ipoinp(2,*),inp(3,*),nam_,namtot,namtot_,
& namta(3,*),idelay,nmethod,iperturb,ipoinpc(0:*),
& mi(*)
!
real*8 xboun(*),bounval,coefmpc(*),trab(7,*),co(3,*),amta(2,*),
& vold(0:mi(2),*),xload(2,*)
!
type='F'
iamplitude=0
idelay=0
user=.false.
fixed=.false.
!
do i=2,n
if(textpart(i)(1:10).eq.'AMPLITUDE=') then
read(textpart(i)(11:90),'(a80)') amplitude
do j=nam,1,-1
if(amname(j).eq.amplitude) then
iamplitude=j
exit
endif
enddo
if(j.eq.0) then
write(*,*)
& '*ERROR reading *BOUNDARYF: nonexistent amplitude'
write(*,*) ' '
call inputerror(inpc,ipoinpc,iline,
&"*BOUNDARYF%")
call exit(201)
endif
iamplitude=j
elseif(textpart(i)(1:10).eq.'TIMEDELAY=') THEN
if(idelay.ne.0) then
write(*,*)'*ERROR reading *BOUNDARYF: the parameter TIME'
write(*,*) ' DELAY is used twice in the same'
write(*,*) ' keyword; '
call inputerror(inpc,ipoinpc,iline,
&"*BOUNDARYF%")
call exit(201)
else
idelay=1
endif
nam=nam+1
if(nam.gt.nam_) then
write(*,*) '*ERROR reading *BOUNDARYF: increase nam_'
call exit(201)
endif
amname(nam)='
& '
if(iamplitude.eq.0) then
write(*,*)'*ERROR reading *BOUNDARYF: time delay must be'
write(*,*) ' preceded by the amplitude parameter'
call exit(201)
endif
namta(3,nam)=sign(iamplitude,namta(3,iamplitude))
iamplitude=nam
if(nam.eq.1) then
namtot=0
else
namtot=namta(2,nam-1)
endif
namtot=namtot+1
if(namtot.gt.namtot_) then
write(*,*) '*ERROR boundaries: increase namtot_'
call exit(201)
endif
namta(1,nam)=namtot
namta(2,nam)=namtot
read(textpart(i)(11:30),'(f20.0)',iostat=istat)
& amta(1,namtot)
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*BOUNDARYF%")
elseif(textpart(i)(1:4).eq.'USER') then
user=.true.
else
write(*,*)
& '*WARNING reading *BOUNDARYF: parameter not recognized:'
write(*,*) ' ',
& textpart(i)(1:index(textpart(i),' ')-1)
call inputwarning(inpc,ipoinpc,iline,
&"*BOUNDARYF%")
endif
enddo
!
if(user.and.(iamplitude.ne.0)) then
write(*,*) '*WARNING: no amplitude definition is allowed'
write(*,*) ' for temperatures defined by a'
write(*,*) ' user routine'
iamplitude=0
endif
!
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) return
!
read(textpart(3)(1:10),'(i10)',iostat=istat) ibounstart
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*BOUNDARYF%")
!
if(textpart(4)(1:1).eq.' ') then
ibounend=ibounstart
else
read(textpart(4)(1:10),'(i10)',iostat=istat) ibounend
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*BOUNDARYF%")
endif
!
if(textpart(5)(1:1).eq.' ') then
bounval=0.d0
else
read(textpart(5)(1:20),'(f20.0)',iostat=istat) bounval
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*BOUNDARYF%")
endif
!
! dummy boundary condition consisting of the first primes
!
if(user) bounval=1.2357111317d0
!
read(textpart(1)(1:10),'(i10)',iostat=istat) l
if(istat.eq.0) then
if((l.gt.ne).or.(l.le.0)) then
write(*,*) '*ERROR reading *BOUNDARYF:'
write(*,*) ' element ',l,' is not defined'
call exit(201)
endif
read(textpart(2)(2:2),'(i1)',iostat=istat) iface
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*BOUNDARYF%")
l=10*l+iface
call bounaddf(l,ibounstart,ibounend,bounval,
& nodeboun,ndirboun,xboun,nboun,nboun_,
& iamboun,iamplitude,nam,ipompc,nodempc,
& coefmpc,nmpc,nmpc_,mpcfree,trab,
& ntrans,ikboun,ilboun,ikmpc,ilmpc,co,nk,nk_,labmpc,
& type,typeboun,nmethod,iperturb,vold,mi,
& nelemload,sideload,xload,nload,lakon,ipkon,kon)
else
read(textpart(1)(1:80),'(a80)',iostat=istat) elset
elset(81:81)=' '
ipos=index(elset,' ')
elset(ipos:ipos)='E'
do i=1,nset
if(set(i).eq.elset) exit
enddo
if(i.gt.nset) then
elset(ipos:ipos)=' '
write(*,*) '*ERROR reading *BOUNDARYF: surface ',elset
write(*,*) ' has not yet been defined. '
call inputerror(inpc,ipoinpc,iline,
&"*BOUNDARYF%")
call exit(201)
endif
read(textpart(2)(2:2),'(i1)',iostat=istat) iface
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*BOUNDARYF%")
do j=istartset(i),iendset(i)
if(ialset(j).gt.0) then
k=ialset(j)
k=10*k+iface
call bounaddf(k,ibounstart,ibounend,bounval,
& nodeboun,ndirboun,xboun,nboun,nboun_,
& iamboun,iamplitude,nam,ipompc,nodempc,
& coefmpc,nmpc,nmpc_,mpcfree,trab,
& ntrans,ikboun,ilboun,ikmpc,ilmpc,co,nk,nk_,labmpc,
& type,typeboun,nmethod,iperturb,vold,mi,
& nelemload,sideload,xload,nload,lakon,ipkon,kon)
else
m=ialset(j-2)
do
m=m-ialset(j)
if(m.ge.ialset(j-1)) exit
k=10*m+iface
call bounaddf(k,ibounstart,ibounend,bounval,
& nodeboun,ndirboun,xboun,nboun,nboun_,
& iamboun,iamplitude,nam,ipompc,nodempc,
& coefmpc,nmpc,nmpc_,mpcfree,trab,
& ntrans,ikboun,ilboun,ikmpc,ilmpc,co,nk,nk_,
& labmpc,type,typeboun,nmethod,iperturb,
& vold,mi,
& nelemload,sideload,xload,nload,lakon,ipkon,kon)
enddo
endif
enddo
endif
enddo
!
return
end
| gpl-2.0 |
epfl-cosmo/q-e | PHonon/Gamma/drhodv.f90 | 2 | 1551 | !
! Copyright (C) 2003 PWSCF group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!
!-----------------------------------------------------------------------
SUBROUTINE drhodv(nu_i)
!-----------------------------------------------------------------------
!
! calculate the electronic term <psi|dv|dpsi> of the dynamical matrix
!
USE mp_global, ONLY : intra_pool_comm
USE mp, ONLY : mp_sum
USE klist, ONLY : wk !, nks
USE wvfct, ONLY : nbnd, npw, npwx
USE cgcom
IMPLICIT NONE
INTEGER :: nu_i
!
INTEGER :: nu_j, ibnd, ik
real(DP) :: dynel(nmodes), work(nbnd)
!
CALL start_clock('drhodv')
!
dynel(:) = 0.d0
ik = 1
! do ik=1,nks
!
!** calculate the dynamical matrix (<DeltaV*psi(ion)|\DeltaPsi(ion)>)
!
DO nu_j = 1,nmodes
!
! DeltaV*psi(ion) for mode nu_j is recalculated
!
CALL dvpsi_kb(ik,nu_j)
!
! this is the real part of <DeltaV*Psi(ion)|DeltaPsi(ion)>
!
CALL pw_dot('N',npw,nbnd,dvpsi,npwx,dpsi ,npwx,work)
DO ibnd = 1,nbnd
dynel(nu_j) = dynel(nu_j) + 2.0d0*wk(ik)*work(ibnd)
ENDDO
ENDDO
#ifdef __MPI
CALL mp_sum( dynel, intra_pool_comm )
#endif
!
! NB this must be done only at the end of the calculation!
!
DO nu_j = 1,nmodes
dyn(nu_i,nu_j) = - (dyn(nu_i,nu_j)+dynel(nu_j))
ENDDO
!
CALL stop_clock('drhodv')
!
RETURN
END SUBROUTINE drhodv
| gpl-2.0 |
grlee77/scipy | scipy/special/cdflib/cdfbin.f | 18 | 8616 | SUBROUTINE cdfbin(which,p,q,s,xn,pr,ompr,status,bound)
C**********************************************************************
C
C SUBROUTINE CDFBIN ( WHICH, P, Q, S, XN, PR, OMPR, STATUS, BOUND )
C Cumulative Distribution Function
C BINomial distribution
C
C
C Function
C
C
C Calculates any one parameter of the binomial
C distribution given values for the others.
C
C
C Arguments
C
C
C WHICH --> Integer indicating which of the next four argument
C values is to be calculated from the others.
C Legal range: 1..4
C iwhich = 1 : Calculate P and Q from S,XN,PR and OMPR
C iwhich = 2 : Calculate S from P,Q,XN,PR and OMPR
C iwhich = 3 : Calculate XN from P,Q,S,PR and OMPR
C iwhich = 4 : Calculate PR and OMPR from P,Q,S and XN
C INTEGER WHICH
C
C P <--> The cumulation from 0 to S of the binomial distribution.
C (Probablility of S or fewer successes in XN trials each
C with probability of success PR.)
C Input range: [0,1].
C DOUBLE PRECISION P
C
C Q <--> 1-P.
C Input range: [0, 1].
C P + Q = 1.0.
C DOUBLE PRECISION Q
C
C S <--> The number of successes observed.
C Input range: [0, XN]
C Search range: [0, XN]
C DOUBLE PRECISION S
C
C XN <--> The number of binomial trials.
C Input range: (0, +infinity).
C Search range: [1E-100, 1E100]
C DOUBLE PRECISION XN
C
C PR <--> The probability of success in each binomial trial.
C Input range: [0,1].
C Search range: [0,1]
C DOUBLE PRECISION PR
C
C OMPR <--> 1-PR
C Input range: [0,1].
C Search range: [0,1]
C PR + OMPR = 1.0
C DOUBLE PRECISION OMPR
C
C STATUS <-- 0 if calculation completed correctly
C -I if input parameter number I is out of range
C 1 if answer appears to be lower than lowest
C search bound
C 2 if answer appears to be higher than greatest
C search bound
C 3 if P + Q .ne. 1
C 4 if PR + OMPR .ne. 1
C INTEGER STATUS
C
C BOUND <-- Undefined if STATUS is 0
C
C Bound exceeded by parameter number I if STATUS
C is negative.
C
C Lower search bound if STATUS is 1.
C
C Upper search bound if STATUS is 2.
C
C
C Method
C
C
C Formula 26.5.24 of Abramowitz and Stegun, Handbook of
C Mathematical Functions (1966) is used to reduce the binomial
C distribution to the cumulative incomplete beta distribution.
C
C Computation of other parameters involve a search for a value that
C produces the desired value of P. The search relies on the
C monotinicity of P with the other parameter.
C
C
C**********************************************************************
C .. Parameters ..
DOUBLE PRECISION atol
PARAMETER (atol=1.0D-50)
DOUBLE PRECISION tol
PARAMETER (tol=1.0D-8)
DOUBLE PRECISION zero,inf
PARAMETER (zero=1.0D-100,inf=1.0D100)
DOUBLE PRECISION one
PARAMETER (one=1.0D0)
C ..
C .. Scalar Arguments ..
DOUBLE PRECISION bound,ompr,p,pr,q,s,xn
INTEGER status,which
C ..
C .. Local Scalars ..
DOUBLE PRECISION ccum,cum,fx,pq,prompr,xhi,xlo
LOGICAL qhi,qleft,qporq
C ..
C .. External Functions ..
DOUBLE PRECISION spmpar
EXTERNAL spmpar
C ..
C .. External Subroutines ..
EXTERNAL cumbin,dinvr,dstinv,dstzr,dzror
C ..
C .. Intrinsic Functions ..
INTRINSIC abs
C ..
IF (.NOT. ((which.LT.1).OR. (which.GT.4))) GO TO 30
IF (.NOT. (which.LT.1)) GO TO 10
bound = 1.0D0
GO TO 20
10 bound = 4.0D0
20 status = -1
RETURN
30 IF (which.EQ.1) GO TO 70
IF (.NOT. ((p.LT.0.0D0).OR. (p.GT.1.0D0))) GO TO 60
IF (.NOT. (p.LT.0.0D0)) GO TO 40
bound = 0.0D0
GO TO 50
40 bound = 1.0D0
50 status = -2
RETURN
60 CONTINUE
70 IF (which.EQ.1) GO TO 110
IF (.NOT. ((q.LT.0.0D0).OR. (q.GT.1.0D0))) GO TO 100
IF (.NOT. (q.LT.0.0D0)) GO TO 80
bound = 0.0D0
GO TO 90
80 bound = 1.0D0
90 status = -3
RETURN
100 CONTINUE
110 IF (which.EQ.3) GO TO 130
IF (.NOT. (xn.LE.0.0D0)) GO TO 120
bound = 0.0D0
status = -5
RETURN
120 CONTINUE
130 IF (which.EQ.2) GO TO 170
IF (.NOT. ((s.LT.0.0D0).OR. ((which.NE.3).AND.
+ (s.GT.xn)))) GO TO 160
IF (.NOT. (s.LT.0.0D0)) GO TO 140
bound = 0.0D0
GO TO 150
140 bound = xn
150 status = -4
RETURN
160 CONTINUE
170 IF (which.EQ.4) GO TO 210
IF (.NOT. ((pr.LT.0.0D0).OR. (pr.GT.1.0D0))) GO TO 200
IF (.NOT. (pr.LT.0.0D0)) GO TO 180
bound = 0.0D0
GO TO 190
180 bound = 1.0D0
190 status = -6
RETURN
200 CONTINUE
210 IF (which.EQ.4) GO TO 250
IF (.NOT. ((ompr.LT.0.0D0).OR. (ompr.GT.1.0D0))) GO TO 240
IF (.NOT. (ompr.LT.0.0D0)) GO TO 220
bound = 0.0D0
GO TO 230
220 bound = 1.0D0
230 status = -7
RETURN
240 CONTINUE
250 IF (which.EQ.1) GO TO 290
pq = p + q
IF (.NOT. (abs(((pq)-0.5D0)-0.5D0).GT.
+ (3.0D0*spmpar(1)))) GO TO 280
IF (.NOT. (pq.LT.0.0D0)) GO TO 260
bound = 0.0D0
GO TO 270
260 bound = 1.0D0
270 status = 3
RETURN
280 CONTINUE
290 IF (which.EQ.4) GO TO 330
prompr = pr + ompr
IF (.NOT. (abs(((prompr)-0.5D0)-0.5D0).GT.
+ (3.0D0*spmpar(1)))) GO TO 320
IF (.NOT. (prompr.LT.0.0D0)) GO TO 300
bound = 0.0D0
GO TO 310
300 bound = 1.0D0
310 status = 4
RETURN
320 CONTINUE
330 IF (.NOT. (which.EQ.1)) qporq = p .LE. q
IF ((1).EQ. (which)) THEN
CALL cumbin(s,xn,pr,ompr,p,q)
status = 0
ELSE IF ((2).EQ. (which)) THEN
s = xn/2.0D0
CALL dstinv(0.0D0,xn,0.5D0,0.5D0,5.0D0,atol,tol)
status = 0
CALL dinvr(status,s,fx,qleft,qhi)
340 IF (.NOT. (status.EQ.1)) GO TO 370
CALL cumbin(s,xn,pr,ompr,cum,ccum)
IF (.NOT. (qporq)) GO TO 350
fx = cum - p
GO TO 360
350 fx = ccum - q
360 CALL dinvr(status,s,fx,qleft,qhi)
GO TO 340
370 IF (.NOT. (status.EQ.-1)) GO TO 400
IF (.NOT. (qleft)) GO TO 380
status = 1
bound = 0.0D0
GO TO 390
380 status = 2
bound = xn
390 CONTINUE
400 CONTINUE
ELSE IF ((3).EQ. (which)) THEN
xn = 5.0D0
CALL dstinv(zero,inf,0.5D0,0.5D0,5.0D0,atol,tol)
status = 0
CALL dinvr(status,xn,fx,qleft,qhi)
410 IF (.NOT. (status.EQ.1)) GO TO 440
CALL cumbin(s,xn,pr,ompr,cum,ccum)
IF (.NOT. (qporq)) GO TO 420
fx = cum - p
GO TO 430
420 fx = ccum - q
430 CALL dinvr(status,xn,fx,qleft,qhi)
GO TO 410
440 IF (.NOT. (status.EQ.-1)) GO TO 470
IF (.NOT. (qleft)) GO TO 450
status = 1
bound = zero
GO TO 460
450 status = 2
bound = inf
460 CONTINUE
470 CONTINUE
ELSE IF ((4).EQ. (which)) THEN
CALL dstzr(0.0D0,1.0D0,atol,tol)
IF (.NOT. (qporq)) GO TO 500
status = 0
CALL dzror(status,pr,fx,xlo,xhi,qleft,qhi)
ompr = one - pr
480 IF (.NOT. (status.EQ.1)) GO TO 490
CALL cumbin(s,xn,pr,ompr,cum,ccum)
fx = cum - p
CALL dzror(status,pr,fx,xlo,xhi,qleft,qhi)
ompr = one - pr
GO TO 480
490 GO TO 530
500 status = 0
CALL dzror(status,ompr,fx,xlo,xhi,qleft,qhi)
pr = one - ompr
510 IF (.NOT. (status.EQ.1)) GO TO 520
CALL cumbin(s,xn,pr,ompr,cum,ccum)
fx = ccum - q
CALL dzror(status,ompr,fx,xlo,xhi,qleft,qhi)
pr = one - ompr
GO TO 510
520 CONTINUE
530 IF (.NOT. (status.EQ.-1)) GO TO 560
IF (.NOT. (qleft)) GO TO 540
status = 1
bound = 0.0D0
GO TO 550
540 status = 2
bound = 1.0D0
550 CONTINUE
560 END IF
RETURN
END
| bsd-3-clause |
prool/ccx_prool | ARPACK_i8/EXAMPLES/NONSYM/sndrv1.f | 3 | 16550 | program sndrv1
c
c
c Example program to illustrate the idea of reverse communication
c for a standard nonsymmetric eigenvalue problem.
c
c We implement example one of ex-nonsym.doc in DOCUMENTS directory
c
c\Example-1
c ... Suppose we want to solve A*x = lambda*x in regular mode,
c where A is obtained from the standard central difference
c discretization of the convection-diffusion operator
c (Laplacian u) + rho*(du / dx)
c on the unit square [0,1]x[0,1] with zero Dirichlet boundary
c condition.
c
c ... OP = A and B = I.
c
c ... Assume "call av (nx,x,y)" computes y = A*x.c
c
c ... Use mode 1 of SNAUPD.
c
c\BeginLib
c
c\Routines called:
c snaupd ARPACK reverse communication interface routine.
c sneupd ARPACK routine that returns Ritz values and (optionally)
c Ritz vectors.
c slapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully.
c saxpy Level 1 BLAS that computes y <- alpha*x+y.
c snrm2 Level 1 BLAS that computes the norm of a vector.
c av Matrix vector multiplication routine that computes A*x.
c tv Matrix vector multiplication routine that computes T*x,
c where T is a tridiagonal matrix. It is used in routine
c av.
c
c\Author
c Richard Lehoucq
c Danny Sorensen
c Chao Yang
c Dept. of Computational &
c Applied Mathematics
c Rice University
c Houston, Texas
c
c\SCCS Information: @(#)
c FILE: ndrv1.F SID: 2.4 DATE OF SID: 4/22/96 RELEASE: 2
c
c\Remarks
c 1. None
c
c\EndLib
c---------------------------------------------------------------------------
c
c %-----------------------------%
c | Define maximum dimensions |
c | for all arrays. |
c | MAXN: Maximum dimension |
c | of the A allowed. |
c | MAXNEV: Maximum NEV allowed |
c | MAXNCV: Maximum NCV allowed |
c %-----------------------------%
c
integer maxn, maxnev, maxncv, ldv
parameter (maxn=256, maxnev=12, maxncv=30, ldv=maxn)
c
c %--------------%
c | Local Arrays |
c %--------------%
c
integer iparam(11), ipntr(14)
logical select(maxncv)
Real
& ax(maxn), d(maxncv,3), resid(maxn),
& v(ldv,maxncv), workd(3*maxn),
& workev(3*maxncv),
& workl(3*maxncv*maxncv+6*maxncv)
c
c %---------------%
c | Local Scalars |
c %---------------%
c
character bmat*1, which*2
integer ido, n, nx, nev, ncv, lworkl, info, j,
& ierr, nconv, maxitr, ishfts, mode
Real
& tol, sigmar, sigmai
logical first, rvec
c
c %------------%
c | Parameters |
c %------------%
c
Real
& zero
parameter (zero = 0.0E+0)
c
c %-----------------------------%
c | BLAS & LAPACK routines used |
c %-----------------------------%
c
Real
& slapy2, snrm2
external slapy2, snrm2, saxpy
c
c %--------------------%
c | Intrinsic function |
c %--------------------%
c
intrinsic abs
c
c %-----------------------%
c | Executable Statements |
c %-----------------------%
c
c %--------------------------------------------------%
c | The number NX is the number of interior points |
c | in the discretization of the 2-dimensional |
c | convection-diffusion operator on the unit |
c | square with zero Dirichlet boundary condition. |
c | The number N(=NX*NX) is the dimension of the |
c | matrix. A standard eigenvalue problem is |
c | solved (BMAT = 'I'). NEV is the number of |
c | eigenvalues to be approximated. The user can |
c | modify NX, NEV, NCV, WHICH to solve problems of |
c | different sizes, and to get different parts of |
c | the spectrum. However, The following |
c | conditions must be satisfied: |
c | N <= MAXN |
c | NEV <= MAXNEV |
c | NEV + 2 <= NCV <= MAXNCV |
c %--------------------------------------------------%
c
nx = 10
n = nx*nx
nev = 4
ncv = 20
if ( n .gt. maxn ) then
print *, ' ERROR with _NDRV1: N is greater than MAXN '
go to 9000
else if ( nev .gt. maxnev ) then
print *, ' ERROR with _NDRV1: NEV is greater than MAXNEV '
go to 9000
else if ( ncv .gt. maxncv ) then
print *, ' ERROR with _NDRV1: NCV is greater than MAXNCV '
go to 9000
end if
bmat = 'I'
which = 'SM'
c
c %-----------------------------------------------------%
c | The work array WORKL is used in SNAUPD as |
c | workspace. Its dimension LWORKL is set as |
c | illustrated below. The parameter TOL determines |
c | the stopping criterion. If TOL<=0, machine |
c | precision is used. The variable IDO is used for |
c | reverse communication, and is initially set to 0. |
c | Setting INFO=0 indicates that a random vector is |
c | generated in SNAUPD to start the Arnoldi iteration. |
c %-----------------------------------------------------%
c
lworkl = 3*ncv**2+6*ncv
tol = zero
ido = 0
info = 0
c
c %---------------------------------------------------%
c | This program uses exact shifts with respect to |
c | the current Hessenberg matrix (IPARAM(1) = 1). |
c | IPARAM(3) specifies the maximum number of Arnoldi |
c | iterations allowed. Mode 1 of SNAUPD is used |
c | (IPARAM(7) = 1). All these options can be changed |
c | by the user. For details see the documentation in |
c | SNAUPD. |
c %---------------------------------------------------%
c
ishfts = 1
maxitr = 300
mode = 1
c
iparam(1) = ishfts
iparam(3) = maxitr
iparam(7) = mode
c
c %-------------------------------------------%
c | M A I N L O O P (Reverse communication) |
c %-------------------------------------------%
c
10 continue
c
c %---------------------------------------------%
c | Repeatedly call the routine SNAUPD and take |
c | actions indicated by parameter IDO until |
c | either convergence is indicated or maxitr |
c | has been exceeded. |
c %---------------------------------------------%
c
call snaupd ( ido, bmat, n, which, nev, tol, resid,
& ncv, v, ldv, iparam, ipntr, workd, workl, lworkl,
& info )
c
if (ido .eq. -1 .or. ido .eq. 1) then
c
c %-------------------------------------------%
c | Perform matrix vector multiplication |
c | y <--- OP*x |
c | The user should supply his/her own |
c | matrix vector multiplication routine here |
c | that takes workd(ipntr(1)) as the input |
c | vector, and return the matrix vector |
c | product to workd(ipntr(2)). |
c %-------------------------------------------%
c
call av (nx, workd(ipntr(1)), workd(ipntr(2)))
c
c %-----------------------------------------%
c | L O O P B A C K to call SNAUPD again. |
c %-----------------------------------------%
c
go to 10
c
end if
c
c %----------------------------------------%
c | Either we have convergence or there is |
c | an error. |
c %----------------------------------------%
c
if ( info .lt. 0 ) then
c
c %--------------------------%
c | Error message, check the |
c | documentation in SNAUPD. |
c %--------------------------%
c
print *, ' '
print *, ' Error with _naupd, info = ', info
print *, ' Check the documentation of _naupd'
print *, ' '
c
else
c
c %-------------------------------------------%
c | No fatal errors occurred. |
c | Post-Process using SNEUPD. |
c | |
c | Computed eigenvalues may be extracted. |
c | |
c | Eigenvectors may also be computed now if |
c | desired. (indicated by rvec = .true.) |
c %-------------------------------------------%
c
rvec = .true.
c
call sneupd ( rvec, 'A', select, d, d(1,2), v, ldv,
& sigmar, sigmai, workev, bmat, n, which, nev, tol,
& resid, ncv, v, ldv, iparam, ipntr, workd, workl,
& lworkl, ierr )
c
c %-----------------------------------------------%
c | The real part of the eigenvalue is returned |
c | in the first column of the two dimensional |
c | array D, and the imaginary part is returned |
c | in the second column of D. The corresponding |
c | eigenvectors are returned in the first NEV |
c | columns of the two dimensional array V if |
c | requested. Otherwise, an orthogonal basis |
c | for the invariant subspace corresponding to |
c | the eigenvalues in D is returned in V. |
c %-----------------------------------------------%
c
if ( ierr .ne. 0) then
c
c %------------------------------------%
c | Error condition: |
c | Check the documentation of SNEUPD. |
c %------------------------------------%
c
print *, ' '
print *, ' Error with _neupd, info = ', ierr
print *, ' Check the documentation of _neupd. '
print *, ' '
c
else
c
first = .true.
nconv = iparam(5)
do 20 j=1, nconv
c
c %---------------------------%
c | Compute the residual norm |
c | |
c | || A*x - lambda*x || |
c | |
c | for the NCONV accurately |
c | computed eigenvalues and |
c | eigenvectors. (iparam(5) |
c | indicates how many are |
c | accurate to the requested |
c | tolerance) |
c %---------------------------%
c
if (d(j,2) .eq. zero) then
c
c %--------------------%
c | Ritz value is real |
c %--------------------%
c
call av(nx, v(1,j), ax)
call saxpy(n, -d(j,1), v(1,j), 1, ax, 1)
d(j,3) = snrm2(n, ax, 1)
d(j,3) = d(j,3) / abs(d(j,1))
c
else if (first) then
c
c %------------------------%
c | Ritz value is complex. |
c | Residual of one Ritz |
c | value of the conjugate |
c | pair is computed. |
c %------------------------%
c
call av(nx, v(1,j), ax)
call saxpy(n, -d(j,1), v(1,j), 1, ax, 1)
call saxpy(n, d(j,2), v(1,j+1), 1, ax, 1)
d(j,3) = snrm2(n, ax, 1)
call av(nx, v(1,j+1), ax)
call saxpy(n, -d(j,2), v(1,j), 1, ax, 1)
call saxpy(n, -d(j,1), v(1,j+1), 1, ax, 1)
d(j,3) = slapy2( d(j,3), snrm2(n, ax, 1) )
d(j,3) = d(j,3) / slapy2(d(j,1),d(j,2))
d(j+1,3) = d(j,3)
first = .false.
else
first = .true.
end if
c
20 continue
c
c %-----------------------------%
c | Display computed residuals. |
c %-----------------------------%
c
call smout(6, nconv, 3, d, maxncv, -6,
& 'Ritz values (Real,Imag) and relative residuals')
end if
c
c %-------------------------------------------%
c | Print additional convergence information. |
c %-------------------------------------------%
c
if ( info .eq. 1) then
print *, ' '
print *, ' Maximum number of iterations reached.'
print *, ' '
else if ( info .eq. 3) then
print *, ' '
print *, ' No shifts could be applied during implicit
& Arnoldi update, try increasing NCV.'
print *, ' '
end if
c
print *, ' '
print *, ' _NDRV1 '
print *, ' ====== '
print *, ' '
print *, ' Size of the matrix is ', n
print *, ' The number of Ritz values requested is ', nev
print *, ' The number of Arnoldi vectors generated',
& ' (NCV) is ', ncv
print *, ' What portion of the spectrum: ', which
print *, ' The number of converged Ritz values is ',
& nconv
print *, ' The number of Implicit Arnoldi update',
& ' iterations taken is ', iparam(3)
print *, ' The number of OP*x is ', iparam(9)
print *, ' The convergence criterion is ', tol
print *, ' '
c
end if
c
c %---------------------------%
c | Done with program sndrv1. |
c %---------------------------%
c
9000 continue
c
end
c
c==========================================================================
c
c matrix vector subroutine
c
c The matrix used is the 2 dimensional convection-diffusion
c operator discretized using central difference.
c
subroutine av (nx, v, w)
integer nx, j, lo
Real
& v(nx*nx), w(nx*nx), one, h2
parameter (one = 1.0E+0)
external saxpy
c
c Computes w <--- OP*v, where OP is the nx*nx by nx*nx block
c tridiagonal matrix
c
c | T -I |
c |-I T -I |
c OP = | -I T |
c | ... -I|
c | -I T|
c
c derived from the standard central difference discretization
c of the 2 dimensional convection-diffusion operator
c (Laplacian u) + rho*(du/dx) on a unit square with zero boundary
c condition.
c
c When rho*h/2 <= 1, the discrete convection-diffusion operator
c has real eigenvalues. When rho*h/2 > 1, it has COMPLEX
c eigenvalues.
c
c The subroutine TV is called to compute y<---T*x.
c
c
h2 = one / real((nx+1)*(nx+1))
c
call tv(nx,v(1),w(1))
call saxpy(nx, -one/h2, v(nx+1), 1, w(1), 1)
c
do 10 j = 2, nx-1
lo = (j-1)*nx
call tv(nx, v(lo+1), w(lo+1))
call saxpy(nx, -one/h2, v(lo-nx+1), 1, w(lo+1), 1)
call saxpy(nx, -one/h2, v(lo+nx+1), 1, w(lo+1), 1)
10 continue
c
lo = (nx-1)*nx
call tv(nx, v(lo+1), w(lo+1))
call saxpy(nx, -one/h2, v(lo-nx+1), 1, w(lo+1), 1)
c
return
end
c=========================================================================
subroutine tv (nx, x, y)
c
integer nx, j
Real
& x(nx), y(nx), h, h2, dd, dl, du
c
Real
& one, zero, rho
parameter (one = 1.0E+0, zero = 0.0E+0,
& rho = 0.0E+0)
c
c Compute the matrix vector multiplication y<---T*x
c where T is a nx by nx tridiagonal matrix with DD on the
c diagonal, DL on the subdiagonal, and DU on the superdiagonal.
c
c When rho*h/2 <= 1, the discrete convection-diffusion operator
c has real eigenvalues. When rho*h/2 > 1, it has COMPLEX
c eigenvalues.
c
h = one / real(nx+1)
h2 = h*h
dd = 4.0E+0 / h2
dl = -one / h2 - 5.0E-1*rho / h
du = -one / h2 + 5.0E-1*rho / h
c
y(1) = dd*x(1) + du*x(2)
do 10 j = 2,nx-1
y(j) = dl*x(j-1) + dd*x(j) + du*x(j+1)
10 continue
y(nx) = dl*x(nx-1) + dd*x(nx)
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.11/src/expansions.f | 6 | 5146 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 expansions(inpc,textpart,alcon,nalcon,
& alzero,nmat,ntmat_,irstrt,istep,istat,n,iline,ipol,inl,ipoinp,
& inp,ipoinpc)
!
! reading the input deck: *EXPANSION
!
implicit none
!
character*1 inpc(*)
character*132 textpart(16)
!
integer nalcon(2,*),nmat,ntmat,ntmat_,istep,istat,n,
& ipoinpc(0:*),
& i,ityp,key,irstrt,iline,ipol,inl,ipoinp(2,*),inp(3,*)
!
real*8 alcon(0:6,ntmat_,*),alzero(*)
!
ntmat=0
alzero(nmat)=0.d0
!
if((istep.gt.0).and.(irstrt.ge.0)) then
write(*,*)
& '*ERROR reading *EXPANSION: *EXPANSION should be placed'
write(*,*) ' before all step definitions'
call exit(201)
endif
!
if(nmat.eq.0) then
write(*,*)
& '*ERROR reading *EXPANSION: *EXPANSION should be preceded'
write(*,*) ' by a *MATERIAL card'
call exit(201)
endif
!
ityp=1
!
do i=2,n
if(textpart(i)(1:5).eq.'TYPE=') then
if(textpart(i)(6:8).eq.'ISO') then
ityp=1
elseif(textpart(i)(6:10).eq.'ORTHO') then
ityp=3
elseif(textpart(i)(6:10).eq.'ANISO') then
ityp=6
endif
elseif(textpart(i)(1:5).eq.'ZERO=') then
read(textpart(i)(6:25),'(f20.0)',iostat=istat) alzero(nmat)
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*EXPANSION%")
else
write(*,*)
& '*WARNING reading *EXPANSION: parameter not recognized:'
write(*,*) ' ',
& textpart(i)(1:index(textpart(i),' ')-1)
call inputwarning(inpc,ipoinpc,iline,
&"*EXPANSION%")
endif
enddo
!
nalcon(1,nmat)=ityp
!
if(ityp.eq.1) then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) return
ntmat=ntmat+1
nalcon(2,nmat)=ntmat
if(ntmat.gt.ntmat_) then
write(*,*) '*ERROR reading *EXPANSION: increase ntmat_'
call exit(201)
endif
do i=1,1
read(textpart(i)(1:20),'(f20.0)',iostat=istat)
& alcon(i,ntmat,nmat)
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*EXPANSION%")
enddo
read(textpart(2)(1:20),'(f20.0)',iostat=istat)
& alcon(0,ntmat,nmat)
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*EXPANSION%")
enddo
elseif(ityp.eq.3) then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) return
ntmat=ntmat+1
nalcon(2,nmat)=ntmat
if(ntmat.gt.ntmat_) then
write(*,*) '*ERROR reading *EXPANSION: increase ntmat_'
call exit(201)
endif
do i=1,3
read(textpart(i)(1:20),'(f20.0)',iostat=istat)
& alcon(i,ntmat,nmat)
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*EXPANSION%")
enddo
read(textpart(4)(1:20),'(f20.0)',iostat=istat)
& alcon(0,ntmat,nmat)
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*EXPANSION%")
enddo
elseif(ityp.eq.6) then
do
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) return
ntmat=ntmat+1
nalcon(2,nmat)=ntmat
if(ntmat.gt.ntmat_) then
write(*,*) '*ERROR reading *EXPANSION: increase ntmat_'
call exit(201)
endif
do i=1,6
read(textpart(i)(1:20),'(f20.0)',iostat=istat)
& alcon(i,ntmat,nmat)
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*EXPANSION%")
enddo
read(textpart(7)(1:20),'(f20.0)',iostat=istat)
& alcon(0,ntmat,nmat)
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*EXPANSION%")
enddo
endif
!
return
end
| gpl-2.0 |
alexfrolov/grappa | applications/NPB/MPI/LU/blts.f | 5 | 9217 | c---------------------------------------------------------------------
c---------------------------------------------------------------------
subroutine blts ( ldmx, ldmy, ldmz,
> nx, ny, nz, k,
> omega,
> v,
> ldz, ldy, ldx, d,
> ist, iend, jst, jend,
> nx0, ny0, ipt, jpt)
c---------------------------------------------------------------------
c---------------------------------------------------------------------
c---------------------------------------------------------------------
c
c compute the regular-sparse, block lower triangular solution:
c
c v <-- ( L-inv ) * v
c
c---------------------------------------------------------------------
implicit none
c---------------------------------------------------------------------
c input parameters
c---------------------------------------------------------------------
integer ldmx, ldmy, ldmz
integer nx, ny, nz
integer k
double precision omega
double precision v( 5, -1:ldmx+2, -1:ldmy+2, *),
> ldz( 5, 5, ldmx, ldmy),
> ldy( 5, 5, ldmx, ldmy),
> ldx( 5, 5, ldmx, ldmy),
> d( 5, 5, ldmx, ldmy)
integer ist, iend
integer jst, jend
integer nx0, ny0
integer ipt, jpt
include 'timing.h'
c---------------------------------------------------------------------
c local variables
c---------------------------------------------------------------------
integer i, j, m
integer iex
double precision tmp, tmp1
double precision tmat(5,5)
c---------------------------------------------------------------------
c receive data from north and west
c---------------------------------------------------------------------
if (timeron) call timer_start(t_lcomm)
iex = 0
call exchange_1( v,k,iex )
if (timeron) call timer_stop(t_lcomm)
if (timeron) call timer_start(t_blts)
do j = jst, jend
do i = ist, iend
do m = 1, 5
v( m, i, j, k ) = v( m, i, j, k )
> - omega * ( ldz( m, 1, i, j ) * v( 1, i, j, k-1 )
> + ldz( m, 2, i, j ) * v( 2, i, j, k-1 )
> + ldz( m, 3, i, j ) * v( 3, i, j, k-1 )
> + ldz( m, 4, i, j ) * v( 4, i, j, k-1 )
> + ldz( m, 5, i, j ) * v( 5, i, j, k-1 ) )
end do
end do
end do
do j=jst,jend
do i = ist, iend
do m = 1, 5
v( m, i, j, k ) = v( m, i, j, k )
> - omega * ( ldy( m, 1, i, j ) * v( 1, i, j-1, k )
> + ldx( m, 1, i, j ) * v( 1, i-1, j, k )
> + ldy( m, 2, i, j ) * v( 2, i, j-1, k )
> + ldx( m, 2, i, j ) * v( 2, i-1, j, k )
> + ldy( m, 3, i, j ) * v( 3, i, j-1, k )
> + ldx( m, 3, i, j ) * v( 3, i-1, j, k )
> + ldy( m, 4, i, j ) * v( 4, i, j-1, k )
> + ldx( m, 4, i, j ) * v( 4, i-1, j, k )
> + ldy( m, 5, i, j ) * v( 5, i, j-1, k )
> + ldx( m, 5, i, j ) * v( 5, i-1, j, k ) )
end do
c---------------------------------------------------------------------
c diagonal block inversion
c
c forward elimination
c---------------------------------------------------------------------
do m = 1, 5
tmat( m, 1 ) = d( m, 1, i, j )
tmat( m, 2 ) = d( m, 2, i, j )
tmat( m, 3 ) = d( m, 3, i, j )
tmat( m, 4 ) = d( m, 4, i, j )
tmat( m, 5 ) = d( m, 5, i, j )
end do
tmp1 = 1.0d+00 / tmat( 1, 1 )
tmp = tmp1 * tmat( 2, 1 )
tmat( 2, 2 ) = tmat( 2, 2 )
> - tmp * tmat( 1, 2 )
tmat( 2, 3 ) = tmat( 2, 3 )
> - tmp * tmat( 1, 3 )
tmat( 2, 4 ) = tmat( 2, 4 )
> - tmp * tmat( 1, 4 )
tmat( 2, 5 ) = tmat( 2, 5 )
> - tmp * tmat( 1, 5 )
v( 2, i, j, k ) = v( 2, i, j, k )
> - v( 1, i, j, k ) * tmp
tmp = tmp1 * tmat( 3, 1 )
tmat( 3, 2 ) = tmat( 3, 2 )
> - tmp * tmat( 1, 2 )
tmat( 3, 3 ) = tmat( 3, 3 )
> - tmp * tmat( 1, 3 )
tmat( 3, 4 ) = tmat( 3, 4 )
> - tmp * tmat( 1, 4 )
tmat( 3, 5 ) = tmat( 3, 5 )
> - tmp * tmat( 1, 5 )
v( 3, i, j, k ) = v( 3, i, j, k )
> - v( 1, i, j, k ) * tmp
tmp = tmp1 * tmat( 4, 1 )
tmat( 4, 2 ) = tmat( 4, 2 )
> - tmp * tmat( 1, 2 )
tmat( 4, 3 ) = tmat( 4, 3 )
> - tmp * tmat( 1, 3 )
tmat( 4, 4 ) = tmat( 4, 4 )
> - tmp * tmat( 1, 4 )
tmat( 4, 5 ) = tmat( 4, 5 )
> - tmp * tmat( 1, 5 )
v( 4, i, j, k ) = v( 4, i, j, k )
> - v( 1, i, j, k ) * tmp
tmp = tmp1 * tmat( 5, 1 )
tmat( 5, 2 ) = tmat( 5, 2 )
> - tmp * tmat( 1, 2 )
tmat( 5, 3 ) = tmat( 5, 3 )
> - tmp * tmat( 1, 3 )
tmat( 5, 4 ) = tmat( 5, 4 )
> - tmp * tmat( 1, 4 )
tmat( 5, 5 ) = tmat( 5, 5 )
> - tmp * tmat( 1, 5 )
v( 5, i, j, k ) = v( 5, i, j, k )
> - v( 1, i, j, k ) * tmp
tmp1 = 1.0d+00 / tmat( 2, 2 )
tmp = tmp1 * tmat( 3, 2 )
tmat( 3, 3 ) = tmat( 3, 3 )
> - tmp * tmat( 2, 3 )
tmat( 3, 4 ) = tmat( 3, 4 )
> - tmp * tmat( 2, 4 )
tmat( 3, 5 ) = tmat( 3, 5 )
> - tmp * tmat( 2, 5 )
v( 3, i, j, k ) = v( 3, i, j, k )
> - v( 2, i, j, k ) * tmp
tmp = tmp1 * tmat( 4, 2 )
tmat( 4, 3 ) = tmat( 4, 3 )
> - tmp * tmat( 2, 3 )
tmat( 4, 4 ) = tmat( 4, 4 )
> - tmp * tmat( 2, 4 )
tmat( 4, 5 ) = tmat( 4, 5 )
> - tmp * tmat( 2, 5 )
v( 4, i, j, k ) = v( 4, i, j, k )
> - v( 2, i, j, k ) * tmp
tmp = tmp1 * tmat( 5, 2 )
tmat( 5, 3 ) = tmat( 5, 3 )
> - tmp * tmat( 2, 3 )
tmat( 5, 4 ) = tmat( 5, 4 )
> - tmp * tmat( 2, 4 )
tmat( 5, 5 ) = tmat( 5, 5 )
> - tmp * tmat( 2, 5 )
v( 5, i, j, k ) = v( 5, i, j, k )
> - v( 2, i, j, k ) * tmp
tmp1 = 1.0d+00 / tmat( 3, 3 )
tmp = tmp1 * tmat( 4, 3 )
tmat( 4, 4 ) = tmat( 4, 4 )
> - tmp * tmat( 3, 4 )
tmat( 4, 5 ) = tmat( 4, 5 )
> - tmp * tmat( 3, 5 )
v( 4, i, j, k ) = v( 4, i, j, k )
> - v( 3, i, j, k ) * tmp
tmp = tmp1 * tmat( 5, 3 )
tmat( 5, 4 ) = tmat( 5, 4 )
> - tmp * tmat( 3, 4 )
tmat( 5, 5 ) = tmat( 5, 5 )
> - tmp * tmat( 3, 5 )
v( 5, i, j, k ) = v( 5, i, j, k )
> - v( 3, i, j, k ) * tmp
tmp1 = 1.0d+00 / tmat( 4, 4 )
tmp = tmp1 * tmat( 5, 4 )
tmat( 5, 5 ) = tmat( 5, 5 )
> - tmp * tmat( 4, 5 )
v( 5, i, j, k ) = v( 5, i, j, k )
> - v( 4, i, j, k ) * tmp
c---------------------------------------------------------------------
c back substitution
c---------------------------------------------------------------------
v( 5, i, j, k ) = v( 5, i, j, k )
> / tmat( 5, 5 )
v( 4, i, j, k ) = v( 4, i, j, k )
> - tmat( 4, 5 ) * v( 5, i, j, k )
v( 4, i, j, k ) = v( 4, i, j, k )
> / tmat( 4, 4 )
v( 3, i, j, k ) = v( 3, i, j, k )
> - tmat( 3, 4 ) * v( 4, i, j, k )
> - tmat( 3, 5 ) * v( 5, i, j, k )
v( 3, i, j, k ) = v( 3, i, j, k )
> / tmat( 3, 3 )
v( 2, i, j, k ) = v( 2, i, j, k )
> - tmat( 2, 3 ) * v( 3, i, j, k )
> - tmat( 2, 4 ) * v( 4, i, j, k )
> - tmat( 2, 5 ) * v( 5, i, j, k )
v( 2, i, j, k ) = v( 2, i, j, k )
> / tmat( 2, 2 )
v( 1, i, j, k ) = v( 1, i, j, k )
> - tmat( 1, 2 ) * v( 2, i, j, k )
> - tmat( 1, 3 ) * v( 3, i, j, k )
> - tmat( 1, 4 ) * v( 4, i, j, k )
> - tmat( 1, 5 ) * v( 5, i, j, k )
v( 1, i, j, k ) = v( 1, i, j, k )
> / tmat( 1, 1 )
enddo
enddo
if (timeron) call timer_stop(t_blts)
c---------------------------------------------------------------------
c send data to east and south
c---------------------------------------------------------------------
if (timeron) call timer_start(t_lcomm)
iex = 2
call exchange_1( v,k,iex )
if (timeron) call timer_stop(t_lcomm)
return
end
| bsd-3-clause |
epfl-cosmo/q-e | PHonon/PH/phq_recover.f90 | 8 | 8504 | !
! Copyright (C) 2001-2009 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!-----------------------------------------------------------------------
subroutine phq_recover
!-----------------------------------------------------------------------
!
! This subroutine tests if a xml restart file exists with the
! information of where the code stopped and, if appropriate the
! partial dynamical matrix and the partial effective charges.
! if (rec_code>2) done_irr, comp_irr
! info on calculated irreps - overrides initialization in phq_setup.
! The xml file is in the
! directory _phprefix.phsave. The xml file contains
! where_rec a string with information of the point where the calculation
! stopped
! rec_code_read where_rec status description
!
! -1000 Nothing has been read. There is no recover file.
! -40 phq_setup Only the displacements u have been read from file
! -30 phq_init u and dyn(0) read from file
! -25 not active yet. Restart in solve_e_fpol
! -20 solve_e all previous. Stopped within solve_e. There
! should be a recover file.
! -10 solve_e2 epsilon and zstareu are available if requested.
! Stopped within solve_e2. There should be a
! recover file.
! 2 phescf all previous, raman tenson and elop tensor are
! available if required.
! 10 solve_linter all previous. Stopped within solve linter.
! There should be a recover file.
! 20 phqscf all previous dyn_rec(irr) and zstarue0(irr) are
! available.
! 30 dynmatrix all previous, dyn and zstarue are available.
!
! The logic of the phonon code recover is the following:
! The recover variable is read from input and never changed. If it is
! false it disables completely the recover.
! The control of the code is given by the arrays:
! comp_iq, done_iq : for each q point if it has to be calculated or
! if it is already available. These are calculated
! only once by check_initial_status or read from file
! by the same routine.
! comp_irr, done_irr : for each irreducible representation if it has
! to be calculated or if it is already calculated.
! The latter variables are valid only for the current
! q and are calculated in phq_setup and modified here
! if something is on the file.
! epsil, done_epsil, zeu, done_zeu, zue, done_zue, lraman, done_lraman,
! elop, done_elop ... control the electric field calculations. These are
! set by prepare_q, or read from file by phq_setup.
!
! The position where the code stopped is in the variable rec_code_read
! defined above. This variable allows to exit from a routine if the quantity
! calculated by this routine is already saved on file.
! It is the responsibility of the routine (not of the calling code)
! to known if it has to make the calculation or just exit because the
! value of rec_code_read is too high.
!
! if rec_code_read = (-25), -20, -10, 10
! It is expected that an unformatted recover file exists.
! The following data are in the
! unformatted file and are read by
! routines solve_e (-20), solve_e2 (-10), solve_linter (10):
! iter, dr2, convt
! info on status of linear-response calculation for a given irrep.
! dvscfin
! self-consistent potential for current iteration and irrep
! if (okpaw) dbecsum
! the change of the D coefficients calculated so far.
! if (okvan) int1, int2, int3
! arrays used with US potentials : int1 and int2 calculated in dvanqq,
! int3 calculatec in newdq (depends upon self-consistency)
!
! rec_code_read is valid only for the first q. For the following q
! it is reset to -1000 in clean_pw_ph. So the recover file allows to
! restart only the current q. However information on other q could
! be available in the directory phsave, so this routine reads the
! appropriate files and reset comp_irr and done_irr if appropriate.
!
!
USE kinds, ONLY : DP
USE io_global, ONLY : stdout
USE ph_restart, ONLY : ph_readfile
USE control_ph, ONLY : epsil, rec_code_read, all_done, where_rec,&
zeu, done_epsil, done_zeu, ext_recover, recover, &
zue, trans, current_iq, low_directory_check
USE wvfct, ONLY : nbnd
USE el_phon, ONLY : el_ph_mat, el_ph_mat_rec, done_elph, elph
USE efield_mod, ONLY : zstarue0, zstarue0_rec
USE partial, ONLY : comp_irr, done_irr
USE modes, ONLY : nirr, npert
USE ramanm, ONLY : lraman, elop, done_lraman, done_elop
USE freq_ph, ONLY : fpol, done_fpol, done_iu, nfs
USE grid_irr_iq, ONLY : comp_irr_iq
USE dynmat, ONLY : dyn, dyn_rec
USE qpoint, ONLY : nksq
USE control_lr, ONLY : lgamma
!
implicit none
!
integer :: irr, ierr, ierr1, iu, npe, imode0
! counter on representations
! error code
logical :: exst
character(len=256) :: filename
ierr=0
IF (recover) THEN
IF (lgamma) CALL ph_readfile('tensors', 0, 0, ierr1)
IF (fpol.and.lgamma) THEN
done_fpol=.TRUE.
DO iu=1,nfs
CALL ph_readfile('polarization', 0, iu, ierr1)
done_fpol=done_fpol.AND.done_iu(iu)
END DO
ENDIF
dyn = (0.0_DP, 0.0_DP )
done_irr=.FALSE.
imode0=0
IF (elph) THEN
el_ph_mat=(0.0_DP, 0.0_DP)
done_elph=.FALSE.
ENDIF
DO irr=0, nirr
IF (comp_irr_iq(irr,current_iq).OR..NOT.low_directory_check) THEN
IF (trans.OR.elph) THEN
CALL ph_readfile('data_dyn', current_iq, irr, ierr1)
IF (ierr1 == 0) THEN
dyn = dyn + dyn_rec
IF (zue.and.irr>0) zstarue0 = zstarue0 + zstarue0_rec
ENDIF
END IF
IF ( elph .and. irr > 0 ) THEN
npe = npert(irr)
ALLOCATE(el_ph_mat_rec(nbnd,nbnd,nksq,npe))
CALL ph_readfile('el_phon', current_iq, irr, ierr1)
IF (ierr1 == 0) THEN
el_ph_mat(:,:,:,imode0+1:imode0+npe) = &
el_ph_mat(:,:,:,imode0+1:imode0+npe) + el_ph_mat_rec(:,:,:,:)
ENDIF
DEALLOCATE(el_ph_mat_rec)
imode0=imode0 + npe
END IF
ENDIF
ENDDO
IF (rec_code_read==-40) THEN
WRITE( stdout, '(/,4x," Modes are read from file ")')
ELSEIF (rec_code_read==-25) THEN
WRITE( stdout, '(/,4x," Restart in Polarization calculation")')
ELSEIF (rec_code_read==-20) THEN
WRITE( stdout, '(/,4x," Restart in Electric Field calculation")')
ELSEIF (rec_code_read==-10) then
WRITE( stdout, '(/,4x," Restart in Raman calculation")')
ELSEIF (rec_code_read==2) THEN
WRITE( stdout, '(/,4x," Restart after Electric Field calculation")')
ELSEIF (rec_code_read==10.OR.rec_code_read==20) then
WRITE( stdout, '(/,4x," Restart in Phonon calculation")')
ELSEIF (rec_code_read==30) then
WRITE( stdout, '(/,4x," Restart after Phonon calculation")')
ELSE
call errore ('phq_recover', 'wrong restart data file', -1)
ierr=1
ENDIF
ENDIF
!
ext_recover = ext_recover .AND. ierr==0
!
! The case in which everything has been already calculated and we just
! recollect all the results must be treated in a special way (it does
! not require any initialization).
! We check here if everything has been done
!
all_done=.true.
DO irr = 0, nirr
IF ( comp_irr(irr) .AND. .NOT.done_irr(irr) ) all_done=.false.
ENDDO
IF (rec_code_read < 2) THEN
IF (epsil.AND..NOT.done_epsil) all_done=.FALSE.
IF (zeu.AND..NOT.done_zeu) all_done=.FALSE.
IF (lraman.AND..NOT.done_lraman) all_done=.FALSE.
IF (elop.AND..NOT.done_elop) all_done=.FALSE.
IF (fpol.AND..NOT.done_fpol) all_done=.FALSE.
END IF
RETURN
END SUBROUTINE phq_recover
| gpl-2.0 |
jarn0ld/gnuradio | gr-filter/lib/gen_interpolator_taps/praxis.f | 96 | 38958 | C
C Copyright 2002 Free Software Foundation, Inc.
C
C This file is part of GNU Radio
C
C GNU Radio is free software; you can redistribute it and/or modify
C it under the terms of the GNU General Public License as published by
C the Free Software Foundation; either version 3, or (at your option)
C any later version.
C
C GNU Radio is distributed in the hope that it will be useful,
C but WITHOUT ANY WARRANTY; without even the implied warranty of
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
C GNU General Public License for more details.
C
C You should have received a copy of the GNU General Public License
C along with GNU Radio; see the file COPYING. If not, write to
C the Free Software Foundation, Inc., 51 Franklin Street,
C Boston, MA 02110-1301, USA.
C
DOUBLE PRECISION FUNCTION PRAX2(F,INITV,NDIM,OUT)
DOUBLE PRECISION INITV(128),OUT(128), F
INTEGER NDIM
EXTERNAL F
C
DOUBLE PRECISION V,X,D,Q0,Q1,DMIN,EPSMCH,FX,H,QD0,QD1,QF1,
* SMALL,T,XLDT,XM2,XM4,DSEED,SCBD
C
COMMON /CPRAX/ V(128,128),X(128),D(128),Q0(128),Q1(128),
* DMIN,EPSMCH,FX,H,QD0,QD1,QF1,SMALL,T,XLDT,XM2,XM4,DSEED,SCBD,
* N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
C
N=NDIM
do 10 I=1,N
10 X(I) = INITV(I)
C
call praset
C -1 produces no diagnostic output
jprint = -1
nfmax = 3000
C tighter tolerance
T=1.0D-6
C
call praxis(f)
C
do 30 I=1,N
30 OUT(I) = X(I)
C
prax2 = fx
return
end
SUBROUTINE PRASET
C
C PRASET 1.0 JUNE 1995
C
C SET INITIAL VALUES FOR SOME QUANTITIES USED IN SUBROUTINE PRAXIS.
C THE USER CAN RESET THESE, IF DESIRED,
C AFTER CALLING PRASET AND BEFORE CALLING PRAXIS.
C
C J. P. CHANDLER, COMPUTER SCIENCE DEPARTMENT,
C OKLAHOMA STATE UNIVERSITY
C
C ON MANY MACHINES, SUBROUTINE PRAXIS WILL CAUSE UNDERFLOW AND/OR
C DIVIDE CHECK WHEN COMPUTING EPSMCH**4 AND EPSMCH**(-4).
C IN THAT CASE, SET EPSMCH=1.0D-9 (OR POSSIBLY EPSMCH=1.0D-8)
C AFTER CALLING SUBROUTINE PRASET.
C
INTEGER N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
INTEGER J
C
DOUBLE PRECISION V,X,D,Q0,Q1,DMIN,EPSMCH,FX,H,QD0,QD1,QF1,
* SMALL,T,XLDT,XM2,XM4,DSEED,SCBD
DOUBLE PRECISION A,B,XMID,XPLUS,RZERO,UNITR,RTWO
C
COMMON /CPRAX/ V(128,128),X(128),D(128),Q0(128),Q1(128),
* DMIN,EPSMCH,FX,H,QD0,QD1,QF1,SMALL,T,XLDT,XM2,XM4,DSEED,SCBD,
* N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
C
RZERO=0.0D0
UNITR=1.0D0
RTWO=2.0D0
C
C NMAX IS THE DIMENSION OF THE ARRAYS V(*,*), X(*), D(*),
C Q0(*), AND Q1(*).
C
NMAX=128
C
C NFMAX IS THE MAXIMUM NUMBER OF FUNCTION EVALUATIONS PERMITTED.
C
NFMAX=100000
C
C LP IS THE LOGICAL UNIT NUMBER FOR PRINTED OUTPUT.
C
LP=6
C
C T IS A CONVERGENCE TOLERANCE USED IN SUBROUTINE PRAXIS.
C
T=1.0D-5
C
C JPRINT CONTROLS PRINTED OUTPUT IN PRAXIS.
C
JPRINT=4
C
C H IS AN ESTIMATE OF THE DISTANCE FROM THE INITIAL POINT
C TO THE SOLUTION.
C
H=1.0D0
C
C USE BISECTION TO COMPUTE THE VALUE OF EPSMCH, "MACHINE EPSILON".
C EPSMCH IS THE SMALLEST FLOATING POINT (REAL OR DOUBLE PRECISION)
C NUMBER WHICH, WHEN ADDED TO ONE, GIVES A RESULT GREATER THAN ONE.
C
A=RZERO
B=UNITR
10 XMID=A+(B-A)/RTWO
IF(XMID.LE.A .OR. XMID.GE.B) GO TO 20
XPLUS=UNITR+XMID
IF(XPLUS.GT.UNITR) THEN
B=XMID
ELSE
A=XMID
ENDIF
GO TO 10
C
20 EPSMCH=B
C
DO 30 J=1,NMAX
X(J)=RZERO
30 CONTINUE
C
C JRANCH = 1 TO USE BRENT'S RANDOM,
C JRANCH = 2 TO USE FUNCTION DRANDM.
C
JRANCH=1
C
CALL RANINI(4.0D0)
C
C DSEED IS AN INITIAL SEED FOR DRANDM,
C A SUBROUTINE THAT GENERATES PSEUDORANDOM NUMBERS
C UNIFORMLY DISTRIBUTED ON (0,1).
C
DSEED=1234567.0D0
C
C SCBD IS AN UPPER BOUND ON THE SCALE FACTORS IN PRAXIS.
C IF THE AXES MAY BE BADLY SCALED (WHICH IS TO BE AVOIDED IF
C POSSIBLE) THEN SET SCBD = 10, OTHERWISE 1.
C
SCBD=1.0D0
C
C ILLCIN IS THE INITIAL VALUE OF ILLC,
C THE FLAG THAT SIGNALS AN ILL-CONDITIONED PROBLEM.
C IF THE PROBLEM IS KNOWN TO BE ILL-CONDITIONED SET ILLCIN=1,
C OTHERWISE 0.
C
ILLCIN=0
C
C KTM IS A CONVERGENCE SWITCH USED IN PRAXIS.
C KTM+1 IS THE NUMBER OF ITERATIONS WITHOUT IMPROVEMENT
C BEFORE THE ALGORITHM TERMINATES.
C KTM=4 IS VERY CAUTIOUS.
C USUALLY KTM=1 IS SATISFACTORY.
C
KTM=1
C
RETURN
C
C END PRASET
C
END
SUBROUTINE PRAXIS(F)
C
C PRAXIS 2.0 JUNE 1995
C
C THE PRAXIS PACKAGE MINIMIZES THE FUNCTION F(X,N) OF N
C VARIABLES X(1),...,X(N), USING THE PRINCIPAL AXIS METHOD.
C F MUST BE A SMOOTH (CONTINUOUSLY DIFFERENTIABLE) FUNCTION.
C
C "ALGORITHMS FOR MINIMIZATION WITHOUT DERIVATIVES",
C RICHARD P. BRENT, PRENTICE-HALL 1973 (ISBN 0-13-022335-2),
C PAGES 156-167
C
C TRANSLATED FROM ALGOL W TO A.N.S.I. 1966 STANDARD BASIC FORTRAN
C BY ROSALEE TAYLOR AND SUE PINSKI, COMPUTER SCIENCE DEPARTMENT,
C OKLAHOMA STATE UNIVERSITY (DECEMBER 1973).
C
C UPDATED TO A.N.S.I. STANDARD FORTRAN 77 BY J. P. CHANDLER
C COMPUTER SCIENCE DEPARTMENT, OKLAHOMA STATE UNIVERSITY
C
C
C SUBROUTINE PRAXIS CALLS SUBPROGRAMS
C F, MINX, RANDOM (OR DRANDM), QUAD, MINFIT, SORT.
C
C SUBROUTINE QUAD CALLS MINX.
C
C SUBROUTINE MINX CALLS FLIN.
C
C SUBROUTINE FLIN CALLS F.
C
C
C INPUT QUANTITIES (SET IN THE CALLING PROGRAM)...
C
C F FUNCTION F(X,N) TO BE MINIMIZED
C
C X(*) INITIAL GUESS OF MINIMUM
C
C N DIMENSION OF X (NOTE... N MUST BE .GE. 2)
C
C H MAXIMUM STEP SIZE
C
C T TOLERANCE
C
C EPSMCH MACHINE PRECISION
C
C JPRINT PRINT SWITCH
C
C
C OUTPUT QUANTITIES...
C
C X(*) ESTIMATED POINT OF MINIMUM
C
C FX VALUE OF F AT X
C
C NL NUMBER OF LINEAR SEARCHES
C
C NF NUMBER OF FUNCTION EVALUATIONS
C
C V(*,*) EIGENVECTORS OF A
C NEW DIRECTIONS
C
C D(*) EIGENVALUES OF A
C NEW D
C
C Z(*) SCALE FACTORS
C
C
C ON ENTRY X(*) HOLDS A GUESS. ON RETURN IT HOLDS THE ESTIMATED
C POINT OF MINIMUM, WITH (HOPEFULLY)
C ABS(ERROR) LESS THAN SQRT(EPSMCH)*ABS(X) + T, WHERE
C EPSMCH IS THE MACHINE PRECISION, THE SMALLEST NUMBER SUCH THAT
C (1 + EPSMCH) IS GREATER THAN 1.
C
C T IS A TOLERANCE.
C
C H IS THE MAXIMUM STEP SIZE, SET TO ABOUT THE MAXIMUM EXPECTED
C DISTANCE FROM THE GUESS TO THE MINIMUM. IF H IS SET TOO
C SMALL OR TOO LARGE THEN THE INITIAL RATE OF CONVERGENCE WILL
C BE SLOW.
C
C THE USER SHOULD OBSERVE THE COMMENT ON HEURISTIC NUMBERS
C AT THE BEGINNING OF THE SUBROUTINE.
C
C JPRINT CONTROLS THE PRINTING OF INTERMEDIATE RESULTS.
C IT USES SUBROUTINES FLIN, MINX, QUAD, SORT, AND MINFIT.
C IF JPRINT = 1, F IS PRINTED AFTER EVERY N+1 OR N+2 LINEAR
C MINIMIZATIONS, AND FINAL X IS PRINTED, BUT INTERMEDIATE
C X ONLY IF N IS LESS THAN OR EQUAL TO 4.
C IF JPRINT = 2, EIGENVALUES OF A AND SCALE FACTORS ARE ALSO PRINTED.
C IF JPRINT = 3, F AND X ARE PRINTED AFTER EVERY FEW LINEAR
C MINIMIZATIONS.
C IF JPRINT = 4, EIGENVECTORS ARE ALSO PRINTED.
C IF JPRINT = 5, ADDITIONAL DEBUGGING INFORMATION IS ALSO PRINTED.
C
C RANDOM RETURNS A RANDOM NUMBER UNIFORMLY DISTRIBUTED IN (0, 1).
C
C THIS SUBROUTINE IS MACHINE-INDEPENDENT, APART FROM THE
C SPECIFICATION OF EPSMCH. WE ASSUME THAT EPSMCH**(-4) DOES NOT
C OVERFLOW (IF IT DOES THEN EPSMCH MUST BE INCREASED), AND THAT ON
C FLOATING-POINT UNDERFLOW THE RESULT IS SET TO ZERO.
C
INTEGER N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
INTEGER ILLC,I,IK,IM,IMU,J,K,KL,KM1,KT,K2
C
DOUBLE PRECISION V,X,D,Q0,Q1,DMIN,EPSMCH,FX,H,QD0,QD1,QF1,
* SMALL,T,XLDT,XM2,XM4,DSEED,SCBD
DOUBLE PRECISION F, Y,Z,E, DABS,DSQRT,ZABS,ZSQRT,DRANDM,
* HUNDRD,HUNDTH,ONE,PT9,RHALF,TEN,TENTH,TWO,ZERO,
* DF,DLDFAC,DN,F1,XF,XL,T2,RANVAL,ARG,
* VLARGE,VSMALL,XLARGE,XLDS,FXVALU,F1VALU,S,SF,SL
C
EXTERNAL F
C
DIMENSION Y(128),Z(128),E(128)
C
COMMON /CPRAX/ V(128,128),X(128),D(128),Q0(128),Q1(128),
* DMIN,EPSMCH,FX,H,QD0,QD1,QF1,SMALL,T,XLDT,XM2,XM4,DSEED,SCBD,
* N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
C
ZABS(ARG)=DABS(ARG)
ZSQRT(ARG)=DSQRT(ARG)
C
C INITIALIZATION...
C
RHALF=0.5D0
ONE=1.0D0
TENTH=0.1D0
HUNDTH=0.01D0
HUNDRD=100.0D0
ZERO=0.0D0
PT9=0.9D0
TEN=10.0D0
TWO=2.0D0
C
C MACHINE DEPENDENT NUMBERS...
C
C ON MANY COMPUTERS, VSMALL WILL UNDERFLOW,
C AND COMPUTING XLARGE MAY CAUSE A DIVISION BY ZERO.
C IN THAT CASE, EPSMCH SHOULD BE SET EQUAL TO 1.0D-9
C (OR POSSIBLY 1.0D-8) BEFORE CALLING PRAXIS.
C
SMALL=EPSMCH*EPSMCH
VSMALL=SMALL*SMALL
XLARGE=ONE/SMALL
VLARGE=ONE/VSMALL
XM2=ZSQRT(EPSMCH)
XM4=ZSQRT(XM2)
C
C HEURISTIC NUMBERS...
C
C IF THE AXES MAY BE BADLY SCALED (WHICH IS TO BE AVOIDED IF
C POSSIBLE) THEN SET SCBD = 10, OTHERWISE 1.
C
C IF THE PROBLEM IS KNOWN TO BE ILL-CONDITIONED SET ILLC = 1,
C OTHERWISE 0.
C
C KTM+1 IS THE NUMBER OF ITERATIONS WITHOUT IMPROVEMENT
C BEFORE THE ALGORITHM TERMINATES.
C KTM=4 IS VERY CAUTIOUS.
C USUALLY KTM=1 IS SATISFACTORY.
C
C BRENT RECOMMENDED THE FOLLOWING VALUES FOR MOST PROBLEMS...
C
C SCBD=1.0
C ILLC=0
C KTM=1
C
C SCBD, ILLCIN, AND KTM ARE NOW IN COMMON.
C THEY ARE INITIALIZED IN SUBROUTINE PRASET,
C AND CAN BE RESET BY THE USER AFTER CALLING PRASET.
C
ILLC=ILLCIN
C
IF(ILLC.EQ.1) THEN
DLDFAC=TENTH
ELSE
DLDFAC=HUNDTH
ENDIF
C
KT=0
NL=0
NF=1
FX=F(X,N)
QF1=FX
T=SMALL+ZABS(T)
T2=T
DMIN=SMALL
IF(H.LT.HUNDRD*T) H=HUNDRD*T
XLDT=H
C
DO 20 I=1,N
DO 10 J=1,N
V(I,J)=ZERO
10 CONTINUE
V(I,I)=ONE
20 CONTINUE
C
QD0=ZERO
D(1)=ZERO
C
C Q0(*) AND Q1(*) ARE PREVIOUS X(*) POINTS,
C INITIALIZED IN PRAXIS, USED IN FLIN,
C AND CHANGED IN QUAD.
C
DO 30 I=1,N
Q1(I)=X(I)
C
C Q0(*) WAS NOT INITIALIZED IN BRENT'S ALGOL PROCEDURE.
C
Q0(I)=X(I)
30 CONTINUE
C
IF(JPRINT.GT.0) THEN
WRITE(LP,40)NL,NF,FX
40 FORMAT(/' NL =',I10,5X,'NF =',I10/5X,'FX =',1PG15.7)
C
IF(N.LE.4 .OR. JPRINT.GT.2) THEN
WRITE(LP,50)(X(I),I=1,N)
50 FORMAT(/8X,'X'/(1X,1PG15.7,4G15.7))
ENDIF
ENDIF
C
C MAIN LOOP...
C LABEL L0...
C
60 SF=D(1)
S=ZERO
D(1)=ZERO
C
C MINIMIZE ALONG THE FIRST DIRECTION.
C
IF(JPRINT.GE.5) WRITE(LP,70)D(1),S,FX
70 FORMAT(/' CALL NO. 1 TO MINX.'/
* 5X,'D(1) =',1PG15.7,5X,'S =',G15.7,5X,'FX =',G15.7)
C
FXVALU=FX
CALL MINX(1,2,D(1),S,FXVALU,0,F)
C
IF(S.LE.ZERO) THEN
DO 80 I=1,N
V(I,1)=-V(I,1)
80 CONTINUE
ENDIF
C
IF(SF.LE.PT9*D(1) .OR. PT9*SF.GE.D(1)) THEN
C
IF(N.GE.2) THEN
DO 90 I=2,N
D(I)=ZERO
90 CONTINUE
ENDIF
C
ENDIF
C
IF(N.LT.2) GO TO 320
DO 310 K=2,N
C
DO 100 I=1,N
Y(I)=X(I)
100 CONTINUE
C
SF=FX
IF(KT.GT.0) ILLC=1
C
C LABEL L1...
C
110 KL=K
DF=ZERO
C
IF(ILLC.EQ.1) THEN
C
C TAKE A RANDOM STEP TO GET OUT OF A RESOLUTION VALLEY.
C
C PRAXIS ASSUMES THAT RANDOM (OR DRANDM) RETURNS
C A PSEUDORANDOM NUMBER UNIFORMLY DISTRIBUTED IN (0,1),
C AND THAT ANY INITIALIZATION OF THE RANDOM NUMBER GENERATOR
C HAS ALREADY BEEN DONE.
C
DO 130 I=1,N
C
IF(JRANCH.EQ.1) THEN
CALL RANDOM(RANVAL)
ELSE
RANVAL=DRANDM(DSEED)
ENDIF
C
S=(TENTH*XLDT+T2*TEN**KT)*(RANVAL-RHALF)
Z(I)=S
C
DO 120 J=1,N
X(J)=X(J)+S*V(J,I)
120 CONTINUE
130 CONTINUE
C
FX=F(X,N)
NF=NF+1
C
IF(JPRINT.GE.1) WRITE(LP,140)NF,SF,FX
140 FORMAT(/' ***** RANDOM STEP IN PRAXIS. NF =',I11/
* 5X,'SF =',1PG15.7,5X,'FX =',G15.7)
ENDIF
C
IF(K.GT.N) GO TO 170
DO 160 K2=K,N
SL=FX
S=ZERO
C
C MINIMIZE ALONG NON-CONJUGATE DIRECTIONS.
C
IF(JPRINT.GE.5) WRITE(LP,150)K2,D(K2),S,FX
150 FORMAT(/' CALL NO. 2 TO MINX.'/
* 5X,'K2 =',I4,5X,'D(K2) =',1PG15.7,5X,
* 'S =',G15.7/5X,'FX =',G15.7)
C
FXVALU=FX
CALL MINX(K2,2,D(K2),S,FXVALU,0,F)
C
IF(ILLC.EQ.1) THEN
S=D(K2)*(S+Z(K2))**2
ELSE
S=SL-FX
ENDIF
C
IF(DF.LT.S) THEN
DF=S
KL=K2
ENDIF
160 CONTINUE
C
170 IF(ILLC.EQ.0 .AND. DF.LT.ZABS(HUNDRD*EPSMCH*FX)) THEN
C
C NO SUCCESS WITH ILLC=0, SO TRY ONCE WITH ILLC=1 .
C
ILLC=1
C
C GO TO L1.
C
GO TO 110
ENDIF
C
IF(K.EQ.2 .AND. JPRINT.GT.1) THEN
WRITE(LP,180)(D(I),I=1,N)
180 FORMAT(/' NEW D'/(1X,1PG15.7,4G15.7))
ENDIF
C
KM1=K-1
IF(KM1.LT.1) GO TO 210
DO 200 K2=1,KM1
C
C MINIMIZE ALONG CONJUGATE DIRECTIONS.
C
IF(JPRINT.GE.5) WRITE(LP,190)K2,D(K2),S,FX
190 FORMAT(/' CALL NO. 3 TO MINX.'/
* 5X,'K2 =',I4,5X,'D(K2) =',1PG15.7,5X,
* 'S =',G15.7/5X,'FX =',G15.7)
C
S=ZERO
FXVALU=FX
CALL MINX(K2,2,D(K2),S,FXVALU,0,F)
200 CONTINUE
C
210 F1=FX
FX=SF
C
XLDS=ZERO
DO 220 I=1,N
SL=X(I)
X(I)=Y(I)
SL=SL-Y(I)
Y(I)=SL
XLDS=XLDS+SL*SL
220 CONTINUE
C
XLDS=ZSQRT(XLDS)
IF(XLDS.GT.SMALL) THEN
C
C THROW AWAY THE DIRECTION KL AND MINIMIZE ALONG
C THE NEW CONJUGATE DIRECTION.
C
IK=KL-1
IF(K.GT.IK) GO TO 250
DO 240 IM=K,IK
I=IK-IM+K
C
DO 230 J=1,N
V(J,I+1)=V(J,I)
230 CONTINUE
C
D(I+1)=D(I)
240 CONTINUE
C
250 D(K)=ZERO
C
DO 260 I=1,N
V(I,K)=Y(I)/XLDS
260 CONTINUE
C
IF(JPRINT.GE.5) WRITE(LP,270)K,D(K),XLDS,F1
270 FORMAT(/' CALL NO. 4 TO MINX.'/
* 5X,'K =',I4,5X,'D(K) =',1PG15.7,5X,
* 'XLDS =',G15.7/5X,'F1 =',G15.7)
C
F1VALU=F1
CALL MINX(K,4,D(K),XLDS,F1VALU,1,F)
C
IF(XLDS.LE.ZERO) THEN
XLDS=-XLDS
C
DO 280 I=1,N
V(I,K)=-V(I,K)
280 CONTINUE
ENDIF
ENDIF
C
XLDT=DLDFAC*XLDT
IF(XLDT.LT.XLDS) XLDT=XLDS
C
IF(JPRINT.GT.0) THEN
WRITE(LP,40)NL,NF,FX
IF(N.LE.4 .OR. JPRINT.GT.2) THEN
WRITE(LP,50)(X(I),I=1,N)
ENDIF
ENDIF
C
T2=ZERO
DO 290 I=1,N
T2=T2+X(I)**2
290 CONTINUE
T2=XM2*ZSQRT(T2)+T
C
C SEE IF THE STEP LENGTH EXCEEDS HALF THE TOLERANCE.
C
IF(XLDT.GT.RHALF*T2) THEN
KT=0
ELSE
KT=KT+1
ENDIF
C
C IF(...) GO TO L2
C
IF(KT.GT.KTM) GO TO 550
C
IF(NF.GE.NFMAX) THEN
WRITE(LP,300)NFMAX
300 FORMAT(/' IN PRAXIS, NF REACHED THE LIMIT NFMAX =',I11/
* 5X,'THIS IS AN ABNORMAL TERMINATION.'/
* 5X,'THE FUNCTION HAS NOT BEEN MINIMIZED AND',
* ' THE RESULTING X(*) VECTOR SHOULD NOT BE USED.')
GO TO 550
ENDIF
C
310 CONTINUE
C
C TRY QUADRATIC EXTRAPOLATION IN CASE WE ARE STUCK IN A CURVED VALLEY.
C
320 CALL QUAD(F)
C
DN=ZERO
DO 330 I=1,N
D(I)=ONE/ZSQRT(D(I))
IF(DN.LT.D(I)) DN=D(I)
330 CONTINUE
C
IF(JPRINT.GT.3) THEN
C
WRITE(LP,340)
340 FORMAT(/' NEW DIRECTIONS')
C
DO 360 I=1,N
WRITE(LP,350)I,(V(I,J),J=1,N)
350 FORMAT(1X,I5,4X,1PG15.7,4G15.7/(10X,5G15.7))
360 CONTINUE
ENDIF
C
DO 380 J=1,N
C
S=D(J)/DN
DO 370 I=1,N
V(I,J)=S*V(I,J)
370 CONTINUE
380 CONTINUE
C
IF(SCBD.GT.ONE) THEN
C
C SCALE THE AXES TO TRY TO REDUCE THE CONDITION NUMBER.
C
S=VLARGE
DO 400 I=1,N
C
SL=ZERO
DO 390 J=1,N
SL=SL+V(I,J)**2
390 CONTINUE
C
Z(I)=ZSQRT(SL)
IF(Z(I).LT.XM4) Z(I)=XM4
IF(S.GT.Z(I)) S=Z(I)
400 CONTINUE
C
DO 410 I=1,N
SL=S/Z(I)
Z(I)=ONE/SL
C
IF(Z(I).GT.SCBD) THEN
SL=ONE/SCBD
Z(I)=SCBD
ENDIF
C
C IT APPEARS THAT THERE ARE TWO MISSING END; STATEMENTS
C AT THIS POINT IN BRENT'S LISTING.
C
410 CONTINUE
ENDIF
C
C TRANSPOSE V FOR MINFIT.
C
IF(N.LT.2) GO TO 440
DO 430 I=2,N
C
IMU=I-1
DO 420 J=1,IMU
S=V(I,J)
V(I,J)=V(J,I)
V(J,I)=S
420 CONTINUE
430 CONTINUE
C
C FIND THE SINGULAR VALUE DECOMPOSITION OF V.
C THIS GIVES THE EIGENVALUES AND PRINCIPAL AXES
C OF THE APPROXIMATING QUADRATIC FORM
C WITHOUT SQUARING THE CONDITION NUMBER.
C
440 CALL MINFIT(N,EPSMCH,VSMALL,V,D,E,NMAX,LP)
C
IF(SCBD.GT.ONE) THEN
C
C UNSCALING...
C
DO 460 I=1,N
C
S=Z(I)
DO 450 J=1,N
V(I,J)=S*V(I,J)
450 CONTINUE
460 CONTINUE
C
DO 490 I=1,N
C
S=ZERO
DO 470 J=1,N
S=S+V(J,I)**2
470 CONTINUE
S=ZSQRT(S)
C
D(I)=S*D(I)
C
S=ONE/S
DO 480 J=1,N
V(J,I)=S*V(J,I)
480 CONTINUE
490 CONTINUE
ENDIF
C
DO 500 I=1,N
C
IF(DN*D(I).GT.XLARGE) THEN
D(I)=VSMALL
ELSE IF(DN*D(I).LT.SMALL) THEN
D(I)=VLARGE
ELSE
D(I)=ONE/(DN*D(I))**2
ENDIF
500 CONTINUE
C
C SORT THE NEW EIGENVALUES AND EIGENVECTORS.
C
CALL SORT
C
DMIN=D(N)
IF(DMIN.LT.SMALL) DMIN=SMALL
C
IF(XM2*D(1).GT.DMIN) THEN
ILLC=1
ELSE
ILLC=0
ENDIF
C
IF(JPRINT.GT.1 .AND. SCBD.GT.ONE) THEN
WRITE(LP,510)(Z(I),I=1,N)
510 FORMAT(/' SCALE FACTORS'/(1X,1PG15.7,4G15.7))
ENDIF
C
IF(JPRINT.GT.1) THEN
WRITE(LP,520)(D(I),I=1,N)
520 FORMAT(/' EIGENVALUES OF A'/(1X,1PG15.7,4G15.7))
ENDIF
C
IF(JPRINT.GT.3) THEN
C
WRITE(LP,530)
530 FORMAT(/' EIGENVECTORS OF A')
C
DO 540 I=1,N
WRITE(LP,350)I,(V(I,J),J=1,N)
540 CONTINUE
ENDIF
C
C GO BACK TO THE MAIN LOOP.
C GO TO L0
C
C HANDLE THE CASE N .EQ. 1 IN AN AD HOC WAY.
C (BRENT DID NOT PROVIDE FOR THIS CASE.)
C
IF(N.GE.2) GO TO 60
C
C LABEL L2...
C
550 IF(JPRINT.GT.0) THEN
WRITE(LP,560)(X(I),I=1,N)
560 FORMAT(//7X,'X'/(1X,1PG15.7,4G15.7))
ENDIF
C
FX=F(X,N)
C
IF(JPRINT.GE.0) WRITE(LP,570)FX,NL,NF
570 FORMAT(/' EXIT PRAXIS. FX =',1PG25.17,5X,'NL =',I8,
* 5X,'NF =',I9)
C
RETURN
C
C END PRAXIS
C
END
SUBROUTINE QUAD(F)
C
C THIS SUBROUTINE LOOKS FOR THE MINIMUM ALONG
C A CURVE DEFINED BY Q0, Q1, AND X.
C
C "ALGORITHMS FOR MINIMIZATION WITHOUT DERIVATIVES",
C RICHARD P. BRENT, PRENTICE-HALL 1973, PAGE 161
C
C SUBROUTINE QUAD IS CALLED BY SUBROUTINE PRAXIS.
C
INTEGER N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
INTEGER I
C
DOUBLE PRECISION V,X,D,Q0,Q1,DMIN,EPSMCH,FX,H,QD0,QD1,QF1,
* SMALL,T,XLDT,XM2,XM4,DSEED,SCBD
DOUBLE PRECISION F, DSQRT,ZSQRT,ARG,
* ONE,QA,QB,QC,S,TWO,XL,ZERO,QF1VAL
C
EXTERNAL F
C
COMMON /CPRAX/ V(128,128),X(128),D(128),Q0(128),Q1(128),
* DMIN,EPSMCH,FX,H,QD0,QD1,QF1,SMALL,T,XLDT,XM2,XM4,DSEED,SCBD,
* N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
C
ZSQRT(ARG)=DSQRT(ARG)
C
ZERO=0.0D0
ONE=1.0D0
C
S=FX
FX=QF1
QF1=S
QD1=ZERO
C
DO 10 I=1,N
S=X(I)
XL=Q1(I)
X(I)=XL
Q1(I)=S
QD1=QD1+(S-XL)**2
10 CONTINUE
C
QD1=ZSQRT(QD1)
XL=QD1
S=ZERO
C
IF(QD0.GT.ZERO .AND. QD1.GT.ZERO .AND. NL.GE.3*N*N) THEN
C
IF(JPRINT.GE.1) WRITE(LP,20)NF,QD0,QD1,FX,QF1
20 FORMAT(/' ***** CALL MINX FROM QUAD. NF =',I11/
* 5X,'QD0 =',1PG15.7,5X,'QD1 =',G15.7/
* 5X,'FX =',G15.7,5X,'QF1 =',G15.7)
C
QF1VAL=QF1
CALL MINX(0,2,S,XL,QF1VAL,1,F)
QA=XL*(XL-QD1)/(QD0*(QD0+QD1))
QB=(XL+QD0)*(QD1-XL)/(QD0*QD1)
QC=XL*(XL+QD0)/(QD1*(QD0+QD1))
ELSE
FX=QF1
QA=ZERO
QB=ZERO
QC=ONE
ENDIF
C
QD0=QD1
C
DO 30 I=1,N
S=Q0(I)
Q0(I)=X(I)
X(I)=QA*S+QB*X(I)+QC*Q1(I)
30 CONTINUE
C
RETURN
C
C END QUAD
C
END
SUBROUTINE MINX(J,NITS,D2,X1,F1,IFK,F)
C
C SUBROUTINE MINX MINIMIZES F FROM X IN THE DIRECTION V(*,J)
C UNLESS J IS LESS THAN 1, WHEN A QUADRATIC SEARCH IS DONE IN
C THE PLANE DEFINED BY Q0, Q1, AND X.
C
C "ALGORITHMS FOR MINIMIZATION WITHOUT DERIVATIVES",
C RICHARD P. BRENT, PRENTICE-HALL 1973, PAGES 159-160
C
C SUBROUTINE MINX IS CALLED BY SUBROUTINES PRAXIS AND QUAD.
C
C D2 AND X1 RETURN RESULTS.
C J, NITS, F1 AND IFK ARE VALUE PARAMETERS THAT RETURN NOTHING.
C DO NOT SEND A COMMON VARIABLE TO MINX FOR PARAMETER F1.
C
C
C D2 IS AN APPROXIMATION TO HALF OF
C THE SECOND DERIVATIVE OF F (OR ZERO).
C
C X1 IS AN ESTIMATE OF DISTANCE TO MINIMUM,
C RETURNED AS THE DISTANCE FOUND.
C
C IF IFK = 1 THEN F1 IS FLIN(X1), OTHERWISE X1 AND F1 ARE
C IGNORED ON ENTRY UNLESS FINAL FX IS GREATER THAN F1.
C
C NITS CONTROLS THE NUMBER OF TIMES AN ATTEMPT IS MADE TO
C HALVE THE INTERVAL.
C
EXTERNAL F
C
INTEGER N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
INTEGER IFK,J,NITS, I,IDZ,K
C
DOUBLE PRECISION V,X,D,Q0,Q1,DMIN,EPSMCH,FX,H,QD0,QD1,QF1,
* SMALL,T,XLDT,XM2,XM4,DSEED,SCBD
DOUBLE PRECISION D2,X1,
* DABS,DSQRT,ZABS,ZSQRT,ARG,
* HUNDTH,RHALF,TWO,ZERO,
* DENOM,D1,FM,F0,F1,F2,S,SF1,SX1,T2,XM,X2
C
COMMON /CPRAX/ V(128,128),X(128),D(128),Q0(128),Q1(128),
* DMIN,EPSMCH,FX,H,QD0,QD1,QF1,SMALL,T,XLDT,XM2,XM4,DSEED,SCBD,
* N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
C
ZSQRT(ARG)=DSQRT(ARG)
ZABS(ARG)=DABS(ARG)
C
HUNDTH=0.01D0
ZERO=0.0D0
TWO=2.0D0
RHALF=0.5D0
C
SF1=F1
SX1=X1
K=0
XM=ZERO
FM=FX
F0=FX
C
IF(D2.LT.EPSMCH) THEN
IDZ=1
ELSE
IDZ=0
ENDIF
C
C FIND THE STEP SIZE.
C
S=ZERO
DO 10 I=1,N
S=S+X(I)**2
10 CONTINUE
S=ZSQRT(S)
C
IF(IDZ.EQ.1) THEN
DENOM=DMIN
ELSE
DENOM=D2
ENDIF
C
T2=XM4*ZSQRT(ZABS(FX)/DENOM+S*XLDT)+XM2*XLDT
S=XM4*S+T
IF(IDZ.EQ.1 .AND. T2.GT.S) T2=S
IF(T2.LT.SMALL) T2=SMALL
IF(T2.GT.HUNDTH*H) T2=HUNDTH*H
C
IF(IFK.EQ.1 .AND. F1.LE.FM) THEN
XM=X1
FM=F1
ENDIF
C
IF(IFK.EQ.0 .OR. ZABS(X1).LT.T2) THEN
C
IF(X1.GE.ZERO) THEN
X1=T2
ELSE
X1=-T2
ENDIF
C
CALL FLIN(X1,J,F,F1)
ENDIF
C
IF(F1.LT.FM) THEN
XM=X1
FM=F1
ENDIF
C
C LABEL L0...
C
20 IF(IDZ.EQ.1) THEN
C
C EVALUATE FLIN AT ANOTHER POINT,
C AND ESTIMATE THE SECOND DERIVATIVE.
C
IF(F0.LT.F1) THEN
X2=-X1
ELSE
X2=TWO*X1
ENDIF
C
CALL FLIN(X2,J,F,F2)
C
IF(F2.LE.FM) THEN
XM=X2
FM=F2
ENDIF
C
D2=(X2*(F1-F0)-X1*(F2-F0))/(X1*X2*(X1-X2))
C
IF(JPRINT.GE.5) WRITE(LP,30)X1,X2,F0,F1,F2,D2
30 FORMAT(/' COMPUTE D2 IN SUBROUTINE MINX.'/
* 5X,'X1 =',1PG15.7,5X,'X2 =',G15.7/
* 5X,'F0 =',G15.7,5X,'F1 =',G15.7,5X,'F2 =',G15.7/
* 5X,'D2 =',G15.7)
ENDIF
C
C ESTIMATE THE FIRST DERIVATIVE AT 0.
C
D1=(F1-F0)/X1-X1*D2
IDZ=1
C
C PREDICT THE MINIMUM.
C
IF(D2.LE.SMALL) THEN
C
IF(D1.LT.ZERO) THEN
X2=H
ELSE
X2=-H
ENDIF
C
ELSE
X2=-RHALF*D1/D2
ENDIF
C
IF(ZABS(X2).GT.H) THEN
C
IF(X2.GT.ZERO) THEN
X2=H
ELSE
X2=-H
ENDIF
ENDIF
C
C EVALUATE F AT THE PREDICTED MINIMUM.
C LABEL L1...
C
40 CALL FLIN(X2,J,F,F2)
C
IF(K.LT.NITS .AND. F2.GT.F0) THEN
C
C NO SUCCESS, SO TRY AGAIN.
C
K=K+1
C
C IF(...) GO TO L0
C
IF(F0.LT.F1 .AND. X1*X2.GT.ZERO) GO TO 20
X2=X2/TWO
C
C GO TO L1
C
GO TO 40
C
ENDIF
C
C INCREMENT THE ONE-DIMENSIONAL SEARCH COUNTER.
C
NL=NL+1
C
IF(F2.GT.FM) THEN
X2=XM
ELSE
FM=F2
ENDIF
C
C GET A NEW ESTIMATE OF THE SECOND DERIVATIVE.
C
IF(ZABS(X2*(X2-X1)).GT.SMALL) THEN
D2=(X2*(F1-F0)-X1*(FM-F0))/(X1*X2*(X1-X2))
C
IF(JPRINT.GE.5) WRITE(LP,50)X1,X2,F0,FM,F1,D2
50 FORMAT(/' RECOMPUTE D2 IN SUBROUTINE MINX.'/
* 5X,'X1 =',1PG15.7,5X,'X2 =',G15.7/
* 5X,'F0 =',G15.7,5X,'FM =',G15.7,5X,'F1 =',G15.7/
* 5X,'D2 =',G15.7)
C
ELSE IF(K.GT.0) THEN
D2=ZERO
C
IF(JPRINT.GE.5) WRITE(LP,60)
60 FORMAT(/' SET D2=0 IN SUBROUTINE MINX.')
ELSE
D2=D2
ENDIF
C
IF(D2.LE.SMALL) THEN
D2=SMALL
C
IF(JPRINT.GE.5) WRITE(LP,70)D2
70 FORMAT(/' SET D2=SMALL=',1PG15.7,' IN SUBROUTINE MINX.')
ENDIF
C
IF(JPRINT.GE.5) WRITE(LP,80)X1,X2,FX,FM,SF1
80 FORMAT(/' SUBROUTINE MINX. X1 =',1PG15.7,5X,'X2 =',G15.7/
* 5X,'FX =',G15.7,5X,'FM =',G15.7,5X,'SF1 =',G15.7)
C
X1=X2
FX=FM
IF(SF1.LT.FX) THEN
FX=SF1
X1=SX1
ENDIF
C
C UPDATE X FOR A LINEAR SEARCH BUT NOT FOR A PARABOLIC SEARCH.
C
IF(J.GT.0) THEN
C
DO 90 I=1,N
X(I)=X(I)+X1*V(I,J)
90 CONTINUE
ENDIF
C
IF(JPRINT.GE.5) WRITE(LP,100)D2,X1,F1,FX
100 FORMAT(/' LEAVE SUBROUTINE MINX.'/
* 5X,'D2 =',1PG15.7,5X,'X1 =',G15.7,5X,'F1 =',G15.7/
* 5X,'FX =',G15.7)
C
RETURN
C
C END MINX
C
END
SUBROUTINE FLIN(XL,J,F,FLN)
C
C FLIN IS A FUNCTION OF ONE VARIABLE XL WHICH IS MINIMIZED BY
C SUBROUTINE MINX.
C
C "ALGORITHMS FOR MINIMIZATION WITHOUT DERIVATIVES",
C RICHARD P. BRENT, PRENTICE-HALL 1973, PAGES 159-160
C
C SUBROUTINE FLIN IS CALLED BY SUBROUTINE MINX.
C
INTEGER N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
INTEGER J, I
C
DOUBLE PRECISION V,X,D,Q0,Q1,DMIN,EPSMCH,FX,H,QD0,QD1,QF1,
* SMALL,T,XLDT,XM2,XM4,DSEED,SCBD
DOUBLE PRECISION XL,F,FLN, TT, QA,QB,QC
C
DIMENSION TT(128)
C
COMMON /CPRAX/ V(128,128),X(128),D(128),Q0(128),Q1(128),
* DMIN,EPSMCH,FX,H,QD0,QD1,QF1,SMALL,T,XLDT,XM2,XM4,DSEED,SCBD,
* N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
C
IF(J.GT.0) THEN
C
C LINEAR SEARCH...
C
DO 10 I=1,N
TT(I)=X(I)+XL*V(I,J)
10 CONTINUE
C
ELSE
C
C SEARCH ALONG A PARABOLIC SPACE CURVE.
C
QA=XL*(XL-QD1)/(QD0*(QD0+QD1))
QB=(XL+QD0)*(QD1-XL)/(QD0*QD1)
QC=XL*(XL+QD0)/(QD1*(QD0+QD1))
C
DO 20 I=1,N
TT(I)=QA*Q0(I)+QB*X(I)+QC*Q1(I)
20 CONTINUE
ENDIF
C
C INCREMENT FUNCTION EVALUATION COUNTER.
C
NF=NF+1
FLN=F(TT,N)
C
RETURN
C
C END FLIN
C
END
SUBROUTINE MINFIT(N,EPS,TOL,AB,Q,E,NMAX,LP)
C
C AN IMPROVED VERSION OF MINFIT, RESTRICTED TO M=N, P=0.
C SEE GOLUB AND REINSCH (1970).
C
C "ALGORITHMS FOR MINIMIZATION WITHOUT DERIVATIVES",
C RICHARD P. BRENT, PRENTICE-HALL 1973, PAGES 156-158
C
C G. H. GOLUB AND C. REINSCH,
C "SINGULAR VALUE DECOMPOSITION AND LEAST SQUARES SOLUTIONS',
C NUMERISCHE MATHEMATIK 14 (1970) PAGES 403-420
C
C THE SINGULAR VALUES OF THE ARRAY AB ARE RETURNED IN Q,
C AND AB IS OVERWRITTEN WITH THE ORTHOGONAL MATRIX V SUCH THAT
C U.DIAG(Q)=AB.V, WHERE U IS ANOTHER ORTHOGONAL MATRIX.
C
C SUBROUTINE MINFIT IS CALLED BY SUBROUTINE PRAXIS.
C
INTEGER N,NMAX,LP,
* I,II,J,JTHIRT,K,KK,KT,L,LL2,LPI,L2
C
DOUBLE PRECISION EPS,TOL,AB,Q,E,
* DABS,DSQRT,ZABS,ZSQRT,ARG,
* C,DENOM,F,G,H,ONE,X,Y,Z,ZERO,S,TWO
C
DIMENSION AB(NMAX,N),Q(N),E(N)
C
ZABS(ARG)=DABS(ARG)
ZSQRT(ARG)=DSQRT(ARG)
C
JTHIRT=30
C
ZERO=0.0D0
ONE=1.0D0
TWO=2.0D0
C
C HOUSEHOLDER'S REDUCTION TO BIDIAGONAL FORM...
C
X=ZERO
G=ZERO
C
DO 140 I=1,N
E(I)=G
S=ZERO
L=I+1
C
DO 10 J=I,N
S=S+AB(J,I)**2
10 CONTINUE
C
IF(S.LT.TOL) THEN
G=ZERO
ELSE
F=AB(I,I)
C
IF(F.LT.ZERO) THEN
G=ZSQRT(S)
ELSE
G=-ZSQRT(S)
ENDIF
C
H=F*G-S
AB(I,I)=F-G
C
IF(L.GT.N) GO TO 60
DO 50 J=L,N
C
F=ZERO
IF(I.GT.N) GO TO 30
DO 20 K=I,N
F=F+AB(K,I)*AB(K,J)
20 CONTINUE
30 F=F/H
C
IF(I.GT.N) GO TO 50
DO 40 K=I,N
AB(K,J)=AB(K,J)+F*AB(K,I)
40 CONTINUE
50 CONTINUE
ENDIF
C
60 Q(I)=G
S=ZERO
C
IF(I.LE.N) THEN
C
IF(L.GT.N) GO TO 80
DO 70 J=L,N
S=S+AB(I,J)**2
70 CONTINUE
ENDIF
C
80 IF(S.LT.TOL) THEN
G=ZERO
ELSE
F=AB(I,I+1)
C
IF(F.LT.ZERO) THEN
G=ZSQRT(S)
ELSE
G=-ZSQRT(S)
ENDIF
C
H=F*G-S
AB(I,I+1)=F-G
IF(L.GT.N) GO TO 130
DO 90 J=L,N
E(J)=AB(I,J)/H
90 CONTINUE
C
DO 120 J=L,N
C
S=ZERO
DO 100 K=L,N
S=S+AB(J,K)*AB(I,K)
100 CONTINUE
C
DO 110 K=L,N
AB(J,K)=AB(J,K)+S*E(K)
110 CONTINUE
120 CONTINUE
ENDIF
C
130 Y=ZABS(Q(I))+ZABS(E(I))
C
IF(Y.GT.X) X=Y
140 CONTINUE
C
C ACCUMULATION OF RIGHT-HAND TRANSFORMATIONS...
C
DO 210 II=1,N
I=N-II+1
C
IF(G.NE.ZERO) THEN
H=AB(I,I+1)*G
C
IF(L.GT.N) GO TO 200
DO 150 J=L,N
AB(J,I)=AB(I,J)/H
150 CONTINUE
C
DO 180 J=L,N
C
S=ZERO
DO 160 K=L,N
S=S+AB(I,K)*AB(K,J)
160 CONTINUE
C
DO 170 K=L,N
AB(K,J)=AB(K,J)+S*AB(K,I)
170 CONTINUE
180 CONTINUE
ENDIF
C
IF(L.GT.N) GO TO 200
DO 190 J=L,N
AB(J,I)=ZERO
AB(I,J)=ZERO
190 CONTINUE
C
200 AB(I,I)=ONE
G=E(I)
L=I
210 CONTINUE
C
C DIAGONALIZATION OF THE BIDIAGONAL FORM...
C
EPS=EPS*X
DO 330 KK=1,N
K=N-KK+1
KT=0
C
C LABEL TESTFSPLITTING...
C
220 KT=KT+1
C
IF(KT.GT.JTHIRT) THEN
E(K)=ZERO
WRITE(LP,230)
230 FORMAT(' QR FAILED.')
ENDIF
C
DO 240 LL2=1,K
L2=K-LL2+1
L=L2
C
C IF(...) GO TO TESTFCONVERGENCE
C
IF(ZABS(E(L)).LE.EPS) GO TO 270
C
C IF(...) GO TO CANCELLATION
C
IF(ZABS(Q(L-1)).LE.EPS) GO TO 250
240 CONTINUE
C
C CANCELLATION OF E(L) IF L IS GREATER THAN 1...
C LABEL CANCELLATION...
C
250 C=ZERO
S=ONE
IF(L.GT.K) GO TO 270
DO 260 I=L,K
F=S*E(I)
E(I)=C*E(I)
C
C IF(...) GO TO TESTFCONVERGENCE
C
IF(ZABS(F).LE.EPS) GO TO 270
G=Q(I)
C
IF(ZABS(F).LT.ZABS(G)) THEN
H=ZABS(G)*ZSQRT(ONE+(F/G)**2)
ELSE IF(F.NE.ZERO) THEN
H=ZABS(F)*ZSQRT(ONE+(G/F)**2)
ELSE
H=ZERO
ENDIF
C
Q(I)=H
C
IF(H.EQ.ZERO) THEN
H=ONE
G=ONE
ENDIF
C
C THE ABOVE REPLACES Q(I) AND H BY SQUARE ROOT OF (G*G+F*F)
C WHICH MAY GIVE INCORRECT RESULTS IF THE SQUARES UNDERFLOW OR IF
C F = G = 0 .
C
C=G/H
S=-F/H
260 CONTINUE
C
C LABEL TESTFCONVERGENCE...
C
270 Z=Q(K)
C
C IF(...) GO TO CONVERGENCE
C
IF(L.EQ.K) GO TO 310
C
C SHIFT FROM BOTTOM 2*2 MINOR.
C
X=Q(L)
Y=Q(K-1)
G=E(K-1)
H=E(K)
F=((Y-Z)*(Y+Z)+(G-H)*(G+H))/(TWO*H*Y)
G=ZSQRT(F*F+ONE)
C
IF(F.LT.ZERO) THEN
DENOM=F-G
ELSE
DENOM=F+G
ENDIF
C
F=((X-Z)*(X+Z)+H*(Y/DENOM-H))/X
C
C NEXT QR TRANSFORMATION...
C
S=ONE
C=ONE
LPI=L+1
IF(LPI.GT.K) GO TO 300
DO 290 I=LPI,K
G=E(I)
Y=Q(I)
H=S*G
G=G*C
C
IF(ZABS(F).LT.ZABS(H)) THEN
Z=ZABS(H)*ZSQRT(ONE+(F/H)**2)
ELSE IF(F.NE.ZERO) THEN
Z=ZABS(F)*ZSQRT(ONE+(H/F)**2)
ELSE
Z=ZERO
ENDIF
C
E(I-1)=Z
C
IF(Z.EQ.ZERO) THEN
F=ONE
Z=ONE
ENDIF
C
C=F/Z
S=H/Z
F=X*C+G*S
G=-X*S+G*C
H=Y*S
Y=Y*C
C
DO 280 J=1,N
X=AB(J,I-1)
Z=AB(J,I)
AB(J,I-1)=X*C+Z*S
AB(J,I)=-X*S+Z*C
280 CONTINUE
C
IF(ZABS(F).LT.ZABS(H)) THEN
Z=ZABS(H)*ZSQRT(ONE+(F/H)**2)
ELSE IF(F.NE.ZERO) THEN
Z=ZABS(F)*ZSQRT(ONE+(H/F)**2)
ELSE
Z=ZERO
ENDIF
C
Q(I-1)=Z
C
IF(Z.EQ.ZERO) THEN
F=ONE
Z=ONE
ENDIF
C
C=F/Z
S=H/Z
F=C*G+S*Y
X=-S*G+C*Y
290 CONTINUE
C
300 E(L)=ZERO
E(K)=F
Q(K)=X
C
C GO TO TESTFSPLITTING
C
GO TO 220
C
C LABEL CONVERGENCE...
C
310 IF(Z.LT.ZERO) THEN
C
C Q(K) IS MADE NON-NEGATIVE.
C
Q(K)=-Z
DO 320 J=1,N
AB(J,K)=-AB(J,K)
320 CONTINUE
ENDIF
330 CONTINUE
C
RETURN
C
C END MINFIT
C
END
SUBROUTINE SORT
C
C THIS SUBROUTINE SORTS THE ELEMENTS OF D
C AND THE CORRESPONDING COLUMNS OF V INTO DESCENDING ORDER.
C
C "ALGORITHMS FOR MINIMIZATION WITHOUT DERIVATIVES",
C RICHARD P. BRENT, PRENTICE-HALL 1973, PAGES 158-159
C
INTEGER N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
INTEGER I,IPI,J,K,NMI
C
DOUBLE PRECISION V,X,D,Q0,Q1,DMIN,EPSMCH,FX,H,QD0,QD1,QF1,
* SMALL,T,XLDT,XM2,XM4,DSEED,SCBD
DOUBLE PRECISION S
C
COMMON /CPRAX/ V(128,128),X(128),D(128),Q0(128),Q1(128),
* DMIN,EPSMCH,FX,H,QD0,QD1,QF1,SMALL,T,XLDT,XM2,XM4,DSEED,SCBD,
* N,NL,NF,LP,JPRINT,NMAX,ILLCIN,KTM,NFMAX,JRANCH
C
NMI=N-1
IF(NMI.LT.1) GO TO 50
DO 40 I=1,NMI
K=I
S=D(I)
IPI=I+1
IF(IPI.GT.N) GO TO 20
C
DO 10 J=IPI,N
C
IF(D(J).GT.S) THEN
K=J
S=D(J)
ENDIF
10 CONTINUE
C
20 IF(K.GT.I) THEN
D(K)=D(I)
D(I)=S
C
DO 30 J=1,N
S=V(J,I)
V(J,I)=V(J,K)
V(J,K)=S
30 CONTINUE
ENDIF
40 CONTINUE
C
50 RETURN
C
C END SORT
C
END
SUBROUTINE RANINI(RVALUE)
C
C SUBROUTINE RANINI PERFORMS INITIALIZATION FOR SUBROUTINE RANDOM.
C
C "ALGORITHMS FOR MINIMIZATION WITHOUT DERIVATIVES",
C RICHARD P. BRENT, PRENTICE-HALL 1973, PAGES 163-164
C
INTEGER JRAN2,I
C
DOUBLE PRECISION RVALUE,R,RAN3,DMOD,DABS,RAN1
C
COMMON /COMRAN/ RAN3(127),RAN1,JRAN2
C
R=DMOD(DABS(RVALUE),8190.0D0)+1
JRAN2=127
C
10 IF(JRAN2.GT.0) THEN
JRAN2=JRAN2-1
RAN1=-2.0D0**55
C
DO 20 I=1,7
R=DMOD(1756.0D0*R,8191.0D0)
RAN1=(RAN1+(R-DMOD(R,32.0D0))/32.0D0)/256.0D0
20 CONTINUE
C
RAN3(JRAN2+1)=RAN1
GO TO 10
ENDIF
C
RETURN
C
C END RANINI
C
END
SUBROUTINE RANDOM(RANVAL)
C
C SUBROUTINE RANDOM RETURNS A DOUBLE PRECISION PSEUDORANDOM NUMBER
C UNIFORMLY DISTRIBUTED IN (0,1) (INCLUDING 0 BUT NOT 1).
C
C "ALGORITHMS FOR MINIMIZATION WITHOUT DERIVATIVES",
C RICHARD P. BRENT, PRENTICE-HALL 1973, PAGES 163-164
C
C BEFORE THE FIRST CALL TO RANDOM, THE USER MUST
C CALL RANINI(R) ONCE (ONLY) WITH R A DOUBLE PRECISION NUMBER
C EQUAL TO ANY INTEGER VALUE.
C BRENT (PAGE 166) USED THE EQUIVALENT OF
C CALL RANINI(4.0D0) .
C
C THE ALGORITHM USED IN SUBROUTINE RANDOM RETURNS X(N)/2**56,
C WHERE X(N) = X(N-1) + X(N-127) (MOD 2**56) .
C SINCE (1 + X + X**127) IS PRIMITIVE (MOD 2),
C THE PERIOD IS AT LEAST (2**127 - 1), WHICH EXCEEDS 10**38.
C
C SEE "SEMINUMERICAL ALGORITHMS", VOLUME 2 OF
C "THE ART OF COMPUTER PROGRAMMING" BY DONALD E. KNUTH,
C ADDISON-WESLEY 1969, PAGES 26, 34, AND 464.
C
C X(N) IS STORED IN DOUBLE PRECISION AS RAN3 = X(N)/2**56 - 1/2,
C AND ALL DOUBLE PRECISION ARITHMETIC IS EXACT.
C
INTEGER JRAN2
C
DOUBLE PRECISION RANVAL,RAN3,RAN1
C
COMMON /COMRAN/ RAN3(127),RAN1,JRAN2
C
IF(JRAN2.EQ.0) THEN
JRAN2=126
ELSE
JRAN2=JRAN2-1
ENDIF
C
RAN1=RAN1+RAN3(JRAN2+1)
IF(RAN1.LT.0.0D0) THEN
RAN1=RAN1+0.5D0
ELSE
RAN1=RAN1-0.5D0
ENDIF
C
RAN3(JRAN2+1)=RAN1
RANVAL=RAN1+0.5D0
C
RETURN
C
C END RANDOM
C
END
DOUBLE PRECISION FUNCTION DRANDM(DL)
C
C SIMPLE PORTABLE PSEUDORANDOM NUMBER GENERATOR.
C
C DRANDM RETURNS FUNCTION VALUES THAT ARE PSEUDORANDOM
C NUMBERS UNIFORMLY DISTRIBUTED ON THE INTERVAL (0,1).
C
C 'NUMERICAL MATHEMATICS AND COMPUTING' BY WARD CHENEY AND
C DAVID KINCAID, BROOKS/COLE PUBLISHING COMPANY
C (FIRST EDITION, 1980), PAGE 203
C
C AT THE BEGINNING OF EXECUTION, OR WHENEVER A NEW SEQUENCE IS
C TO BE INITIATED, SET DL EQUAL TO AN INTEGER VALUE BETWEEN
C 1.0D0 AND 2147483646.0D0, INCLUSIVE. DO THIS ONLY ONCE.
C THEREAFTER, DO NOT SET OR ALTER DL IN ANY WAY.
C FUNCTION DRANDM WILL MODIFY DL FOR ITS OWN PURPOSES.
C
C DRANDM USES A MULTIPLICATIVE CONGRUENTIAL METHOD.
C THE NUMBERS GENERATED BY DRANDM SUFFER FROM THE PARALLEL
C PLANES DEFECT DISCOVERED BY G. MARSAGLIA, AND SHOULD NOT BE
C USED WHEN HIGH-QUALITY RANDOMNESS IS REQUIRED. IN THAT
C CASE, USE A "SHUFFLING" METHOD.
C
DOUBLE PRECISION DL,DMOD
C
10 DL=DMOD(16807.0D0*DL,2147483647.0D0)
DRANDM=DL/2147483647.0D0
IF(DRANDM.LE.0.0D0 .OR. DRANDM.GE.1.0D0) GO TO 10
RETURN
END
| gpl-3.0 |
techno/gcc-mist32 | libgfortran/generated/_dim_r10.F90 | 47 | 1458 | ! Copyright (C) 2002-2015 Free Software Foundation, Inc.
! Contributed by Paul Brook <paul@nowt.org>
!
!This file is part of the GNU Fortran 95 runtime library (libgfortran).
!
!GNU libgfortran 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 3 of the License, or (at your option) any later version.
!GNU libgfortran 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.
!
!Under Section 7 of GPL version 3, you are granted additional
!permissions described in the GCC Runtime Library Exception, version
!3.1, as published by the Free Software Foundation.
!
!You should have received a copy of the GNU General Public License and
!a copy of the GCC Runtime Library Exception along with this program;
!see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
!<http://www.gnu.org/licenses/>.
!
!This file is machine generated.
#include "config.h"
#include "kinds.inc"
#include "c99_protos.inc"
#if defined (HAVE_GFC_REAL_10)
elemental function _gfortran_specific__dim_r10 (p1, p2)
real (kind=10), intent (in) :: p1, p2
real (kind=10) :: _gfortran_specific__dim_r10
_gfortran_specific__dim_r10 = dim (p1, p2)
end function
#endif
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.17/src/map3dtolayer.f | 1 | 6412 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2020 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 map3dtolayer(yn,ipkon,kon,lakon,nfield,
& ne,co,ielmat,mi)
!
! interpolates 3d field nodal values to nodal values in the
! layers of composite materials
!
implicit none
!
character*8 lakon(*)
!
integer ipkon(*),kon(*),ne,nfield,i,j,k,l,mi(*),nelem,
& ielmat(mi(3),*),nlayer,iflag,nbot20(8),nmid20(8),ntop20(8),
& nbot15(6),nmid15(6),ntop15(6),ibot,itop,nope,nopes,nopeexp,
& indexe,konl(20),imid,node,nodebot,nodetop
!
real*8 yn(nfield,*),shp(4,20),xsj(3),co(3,*),xl(3,20),
& xi,et,ze,dd,dt,xi20(8),et20(8),xi15(6),et15(6)
!
!
!
data iflag /1/
!
data nbot20 /1,2,3,4,9,10,11,12/
data nmid20 /17,18,19,20,0,0,0,0/
data ntop20 /5,6,7,8,13,14,15,16/
!
data nbot15 /1,2,3,7,8,9/
data nmid15 /13,14,15,0,0,0/
data ntop15 /4,5,6,10,11,12/
!
data xi20 /-1.d0,1.d0,1.d0,-1.d0,0.d0,1.d0,0.d0,-1.d0/
data et20 /-1.d0,-1.d0,1.d0,1.d0,-1.d0,0.d0,1.d0,0.d0/
!
data xi15 /0.d0,1.d0,0.d0,0.5d0,0.5d0,0.d0/
data et15 /0.d0,0.d0,1.d0,0.d0,0.5d0,0.5d0/
!
include "gauss.f"
!
do nelem=1,ne
if(lakon(nelem)(7:8).eq.'LC') then
!
! composite materials
!
! determining the number of layers
!
nlayer=0
do k=1,mi(3)
if(ielmat(k,nelem).ne.0) then
nlayer=nlayer+1
endif
enddo
!
indexe=ipkon(nelem)
!
if(lakon(nelem)(4:5).eq.'20') then
nope=20
nopes=8
nopeexp=28
elseif(lakon(nelem)(4:5).eq.'15') then
nope=15
nopes=6
nopeexp=21
endif
!
do i=1,nope
konl(i)=kon(indexe+i)
do j=1,3
xl(j,i)=co(j,konl(i))
enddo
enddo
!
do i=1,nopes
if(lakon(nelem)(4:5).eq.'20') then
ibot=nbot20(i)
imid=nmid20(i)
itop=ntop20(i)
xi=xi20(i)
et=et20(i)
else
ibot=nbot15(i)
imid=nmid15(i)
itop=ntop15(i)
xi=xi15(i)
et=et15(i)
endif
!
nodebot=konl(ibot)
nodetop=konl(itop)
dd=sqrt((co(1,nodebot)-co(1,nodetop))**2+
& (co(2,nodebot)-co(2,nodetop))**2+
& (co(3,nodebot)-co(3,nodetop))**2)
do j=0,nlayer-1
!
! bottom node
!
node=kon(indexe+nopeexp+j*nope+ibot)
dt=sqrt((co(1,nodebot)-co(1,node))**2+
& (co(2,nodebot)-co(2,node))**2+
& (co(3,nodebot)-co(3,node))**2)
ze=2.d0*dt/dd-1.d0
c write(*,*) 'map3dtolayer',node,xi,et,ze
!
! determining the value of the shape functions
!
if(lakon(nelem)(4:5).eq.'20') then
call shape20h(xi,et,ze,xl,xsj,shp,iflag)
elseif(lakon(nelem)(4:5).eq.'15') then
call shape15w(xi,et,ze,xl,xsj,shp,iflag)
endif
!
do k=1,nfield
yn(k,node)=0.d0
do l=1,nope
yn(k,node)=yn(k,node)+
& shp(4,l)*yn(k,konl(l))
c write(*,*) 'xi',xi,et,ze,node
c write(*,*) l,shp(4,l),yn(k,konl(l))
enddo
enddo
!
! top node
!
node=kon(indexe+nopeexp+j*nope+itop)
dt=sqrt((co(1,nodebot)-co(1,node))**2+
& (co(2,nodebot)-co(2,node))**2+
& (co(3,nodebot)-co(3,node))**2)
ze=2.d0*dt/dd-1.d0
c write(*,*) 'map3dtolayer',node,xi,et,ze
!
! determining the value of the shape functions
!
if(lakon(nelem)(4:5).eq.'20') then
call shape20h(xi,et,ze,xl,xsj,shp,iflag)
elseif(lakon(nelem)(4:5).eq.'15') then
call shape15w(xi,et,ze,xl,xsj,shp,iflag)
endif
!
do k=1,nfield
yn(k,node)=0.d0
do l=1,nope
yn(k,node)=yn(k,node)+
& shp(4,l)*yn(k,konl(l))
enddo
enddo
!
! middle node, if any
!
if(i.gt.nopes/2) cycle
!
node=kon(indexe+nopeexp+j*nope+imid)
dt=sqrt((co(1,nodebot)-co(1,node))**2+
& (co(2,nodebot)-co(2,node))**2+
& (co(3,nodebot)-co(3,node))**2)
ze=2.d0*dt/dd-1.d0
c write(*,*) 'map3dtolayer',node,xi,et,ze
!
! determining the value of the shape functions
!
if(lakon(nelem)(4:5).eq.'20') then
call shape20h(xi,et,ze,xl,xsj,shp,iflag)
elseif(lakon(nelem)(4:5).eq.'15') then
call shape15w(xi,et,ze,xl,xsj,shp,iflag)
endif
!
do k=1,nfield
yn(k,node)=0.d0
do l=1,nope
yn(k,node)=yn(k,node)+
& shp(4,l)*yn(k,konl(l))
enddo
enddo
enddo
enddo
endif
enddo
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/inversewavspd.f | 1 | 4035 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2007 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 inversewavspd(xi,et,c,rho,a)
!
! Calculates the propagation wave speed in a material, up to its 21
! constants. Subroutine for calcmatwavsps.f
! Based on the procedure in:
! C. Lane. The Development of a 2D Ultrasonic Array Inspection
! for Single Crystal Turbine Blades.
! Switzerland: Springer International Publishing, 2014.
!
! CARLO MONJARAZ TEC (CMT)
!
! INPUT:
!
! xi,et: values within a square domain between -1 and 1.
! correlate in a unique way with 0<=phi<=pi and
! -pi<=theta<=pi
!
! elas: c(3,3,3,3) - The elasticity vector
!
! rho: double - Density of the material
!
!
! OUTPUT:
!
! a: inverse of the wave speed
!
implicit none
!
integer i,j,k,l,ier,matz,ndim
!
real*8 c(3,3,3,3),rho,xn(3),cm(3,3,3),a,xi,et,
& cmm(3,3),dd,al(3),alz(3,3),fv1(3),fv2(3),
& theta,phi,pi,p3(3),v(3),
& speed
!
intent(in) xi,et,c,rho
!
intent(inout) a
!
pi=4.d0*datan(1.d0)
!
theta=xi*pi
phi=(et+1.d0)*pi/2.d0
!
do l=1,3
v(l)=0.
do k=1,3
cmm(k,l)=0.
do j=1,3
cm(j,l,k)=0.
enddo
enddo
enddo
!
xn(1)=dcos(theta)*dsin(phi)
xn(2)=dsin(theta)*dsin(phi)
xn(3)=dcos(phi)
!
! c ------------ PER EAcH DIREcTION find wave speed-----------------------
!
do l=1,3
do k=1,3
do i=1,3
do j=1,3
cm(l,k,i)=cm(l,k,i)+c(l,k,j,i)*xn(j)
enddo
enddo
enddo
enddo
!
do k=1,3
do i=1,3
do l=1,3
cmm(k,i)=cmm(k,i)+cm(l,k,i)*xn(l)
enddo
enddo
enddo
!
ndim=3
matz=1
ier=0
!
! ---------reset vars for EIGvALUES
!
do j=1,3
al(j)=0.
fv1(j)=0.
fv2(j)=0.
do i=1,3
alz(j,i)=0.
enddo
enddo
!
call rs(ndim,ndim,cmm,al,matz,alz,fv1,fv2,ier)
!
! ------normalizing eigenvectors to P vectors----------
!
dd=dsqrt(alz(1,3)**2+alz(2,3)**2+alz(3,3)**2)
p3(1)=alz(1,3)/dd
p3(2)=alz(2,3)/dd
p3(3)=alz(3,3)/dd
!
do l=1,3
do k=1,3
cmm(k,l)=0.
do j=1,3
cm(j,l,k)=0.
enddo
enddo
enddo
!
do l=1,3
do j=1,3
do i=1,3
do k=1,3
cm(l,j,i)=cm(l,j,i)+c(l,k,j,i)*xn(k);
enddo
enddo
enddo
enddo
!
do l=1,3
do j=1,3
do i=1,3
cmm(l,j)=cmm(l,j)+cm(l,j,i)*p3(i);
enddo
enddo
enddo
!
do j=1,3
do l=1,3
v(j)=v(j)+cmm(l,j)*p3(l)
enddo
enddo
!
dd=dsqrt(v(1)**2+v(2)**2+v(3)**2)
speed=dd/dsqrt(rho*al(3))
c speed=dsqrt(dd/rho)
!
! inverse wave speed
!
a=1.d0/speed
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.16/src/objectives.f | 1 | 15240 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2019 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 objectives(inpc,textpart,istep,istat,n,iline,ipol,inl,
& ipoinp,inp,ipoinpc,nener,nobject,objectset,objective_flag,
& set,nset,ntie,tieset,ier)
!
! reading the input deck: *OBJECTIVE
!
! criteria: DISPLACEMENT
! X-DISP
! Y-DISP
! Z-DISP
! EIGENFREQUENCY
! GREEN
! MASS
! STRAIN ENERGY
! STRESS
!
implicit none
!
logical objective_flag
!
character*1 inpc(*)
character*132 textpart(16)
character*81 objectset(4,*),set(*),tieset(3,*)
!
integer istep,istat,n,key,i,iline,ipol,inl,ipoinp(2,*),nset,
& inp(3,*),ipoinpc(0:*),nener,nobject,k,ipos,nconst,icoordinate,
& ntie,ier
!
real*8 rho,stress
!
! initialization
!
rho=0.d0
stress=0.d0
icoordinate=0
!
! check whether the design variables are the coordinates
!
do i=1,ntie
if(tieset(1,i)(81:81).eq.'D') then
if(tieset(1,i)(1:10).eq.'COORDINATE') then
icoordinate=1
exit
elseif(tieset(1,i)(1:11).eq.'ORIENTATION') then
exit
endif
endif
enddo
!
if(objective_flag) then
write(*,*) '*ERROR reading *OBJECTIVE'
write(*,*) ' no more than one *OBJECTIVE keyword'
write(*,*) ' is allowed per *SENSITIVITY step'
ier=1
return
endif
!
if(istep.lt.1) then
write(*,*) '*ERROR reading *OBJECTIVE: *OBJECTIVE can
&only be used within a SENSITIVITY STEP'
ier=1
return
endif
!
! check if constraints are already defined
!
nconst=0
if(nobject.gt.0) then
nconst=nobject
nobject=0
endif
!
! check if it is a minimization or maximization problem
!
if(textpart(2)(1:7).eq.'TARGET=') then
if(textpart(1)(8:10).eq.'MIN') then
objectset(2,1)(17:19)='MIN'
elseif(textpart(2)(8:10).eq.'MAX') then
objectset(2,1)(17:19)='MAX'
else
write(*,*)
& '*WARNING optimization TARGET not known.'
write(*,*)
& ' Minimization problem assumed as default.'
objectset(2,1)(17:19)='MIN'
endif
else
write(*,*)
& '*WARNING optimization TARGET not specified.'
write(*,*)
& ' Minimization problem assumed as default.'
objectset(2,1)(17:19)='MIN'
endif
!
! reading the objectives
!
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
!
do
if(textpart(1)(1:12).eq.'DISPLACEMENT') then
nobject=nobject+1
objectset(1,nobject)(1:12)='DISPLACEMENT'
do k=13,20
objectset(1,nobject)(k:k)=' '
enddo
if(n.ge.2) then
read(textpart(2)(1:80),'(a80)',iostat=istat)
& objectset(3,nobject)(1:80)
objectset(3,nobject)(81:81)=' '
ipos=index(objectset(3,nobject),' ')
if(ipos.ne.1) then
objectset(3,nobject)(ipos:ipos)='N'
!
! check the existence of the set
!
do i=1,nset
if(set(i).eq.objectset(3,nobject)) exit
enddo
if(i.gt.nset) then
objectset(3,nobject)(ipos:ipos)=' '
write(*,*) '*ERROR reading *OBJECTIVE: node set ',
& objectset(3,nobject)
write(*,*) ' has not yet been defined. '
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
endif
endif
elseif(textpart(1)(1:6).eq.'X-DISP') then
nobject=nobject+1
objectset(1,nobject)(1:6)='X-DISP'
do k=7,20
objectset(1,nobject)(k:k)=' '
enddo
if(n.ge.2) then
read(textpart(2)(1:80),'(a80)',iostat=istat)
& objectset(3,nobject)(1:80)
objectset(3,nobject)(81:81)=' '
ipos=index(objectset(3,nobject),' ')
if(ipos.ne.1) then
objectset(3,nobject)(ipos:ipos)='N'
!
! check the existence of the set
!
do i=1,nset
if(set(i).eq.objectset(3,nobject)) exit
enddo
if(i.gt.nset) then
objectset(3,nobject)(ipos:ipos)=' '
write(*,*) '*ERROR reading *OBJECTIVE: node set ',
& objectset(3,nobject)
write(*,*) ' has not yet been defined. '
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
endif
endif
elseif(textpart(1)(1:6).eq.'Y-DISP') then
nobject=nobject+1
objectset(1,nobject)(1:6)='Y-DISP'
do k=7,20
objectset(1,nobject)(k:k)=' '
enddo
if(n.ge.2) then
read(textpart(2)(1:80),'(a80)',iostat=istat)
& objectset(3,nobject)(1:80)
objectset(3,nobject)(81:81)=' '
ipos=index(objectset(3,nobject),' ')
if(ipos.ne.1) then
objectset(3,nobject)(ipos:ipos)='N'
!
! check the existence of the set
!
do i=1,nset
if(set(i).eq.objectset(3,nobject)) exit
enddo
if(i.gt.nset) then
objectset(3,nobject)(ipos:ipos)=' '
write(*,*) '*ERROR reading *OBJECTIVE: node set ',
& objectset(3,nobject)
write(*,*) ' has not yet been defined. '
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
endif
endif
elseif(textpart(1)(1:6).eq.'Z-DISP') then
nobject=nobject+1
objectset(1,nobject)(1:6)='Z-DISP'
do k=7,20
objectset(1,nobject)(k:k)=' '
enddo
if(n.ge.2) then
read(textpart(2)(1:80),'(a80)',iostat=istat)
& objectset(3,nobject)(1:80)
objectset(3,nobject)(81:81)=' '
ipos=index(objectset(3,nobject),' ')
if(ipos.ne.1) then
objectset(3,nobject)(ipos:ipos)='N'
!
! check the existence of the set
!
do i=1,nset
if(set(i).eq.objectset(3,nobject)) exit
enddo
if(i.gt.nset) then
objectset(3,nobject)(ipos:ipos)=' '
write(*,*) '*ERROR reading *OBJECTIVE: node set ',
& objectset(3,nobject)
write(*,*) ' has not yet been defined. '
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
endif
endif
elseif(textpart(1)(1:14).eq.'EIGENFREQUENCY') then
nobject=nobject+1
objectset(1,nobject)(1:14)='EIGENFREQUENCY'
do k=15,20
objectset(1,nobject)(k:k)=' '
enddo
elseif(textpart(1)(1:5).eq.'GREEN') then
nobject=nobject+1
objectset(1,nobject)(1:5)='GREEN'
do k=6,20
objectset(1,nobject)(k:k)=' '
enddo
elseif(textpart(1)(1:4).eq.'MASS') then
nobject=nobject+1
objectset(1,nobject)(1:4)='MASS'
do k=5,20
objectset(1,nobject)(k:k)=' '
enddo
if(n.ge.2) then
read(textpart(2)(1:80),'(a80)',iostat=istat)
& objectset(3,nobject)(1:80)
objectset(3,nobject)(81:81)=' '
ipos=index(objectset(3,nobject),' ')
if(ipos.ne.1) then
objectset(3,nobject)(ipos:ipos)='E'
!
! check the existence of the set
!
do i=1,nset
if(set(i).eq.objectset(3,nobject)) exit
enddo
if(i.gt.nset) then
objectset(3,nobject)(ipos:ipos)=' '
write(*,*)
& '*ERROR reading *OBJECTIVE: element set ',
& objectset(3,nobject)
write(*,*) ' has not yet been defined. '
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
endif
endif
elseif(textpart(1)(1:12).eq.'STRAINENERGY') then
nobject=nobject+1
objectset(1,nobject)(1:12)='STRAINENERGY'
do k=13,20
objectset(1,nobject)(k:k)=' '
enddo
if(n.ge.2) then
read(textpart(2)(1:80),'(a80)',iostat=istat)
& objectset(3,nobject)(1:80)
objectset(3,nobject)(81:81)=' '
ipos=index(objectset(3,nobject),' ')
if(ipos.ne.1) then
objectset(3,nobject)(ipos:ipos)='E'
!
! check the existence of the set
!
do i=1,nset
if(set(i).eq.objectset(3,nobject)) exit
enddo
if(i.gt.nset) then
objectset(3,nobject)(ipos:ipos)=' '
write(*,*)
& '*ERROR reading *OBJECTIVE: element set ',
& objectset(3,nobject)
write(*,*) ' has not yet been defined. '
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
endif
endif
nener=1
elseif(textpart(1)(1:6).eq.'STRESS') then
nobject=nobject+1
objectset(1,nobject)(1:6)='STRESS'
do k=7,20
objectset(1,nobject)(k:k)=' '
enddo
if(n.ge.2) then
read(textpart(2)(1:80),'(a80)',iostat=istat)
& objectset(3,nobject)(1:80)
objectset(3,nobject)(81:81)=' '
ipos=index(objectset(3,nobject),' ')
if(ipos.ne.1) then
objectset(3,nobject)(ipos:ipos)='N'
!
! check the existence of the set
!
do i=1,nset
if(set(i).eq.objectset(3,nobject)) exit
enddo
if(i.gt.nset) then
objectset(3,nobject)(ipos:ipos)=' '
write(*,*) '*ERROR reading *OBJECTIVE: node set ',
& objectset(3,nobject)
write(*,*) ' has not yet been defined. '
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
endif
endif
!
! rho for the Kreisselmeier-Steinhauser function
!
if(n.ge.3) then
read(textpart(3)(1:20),'(f20.0)',iostat=istat) rho
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
objectset(2,nobject)(41:60)=textpart(3)(1:20)
endif
!
if(icoordinate.eq.1) then
if(rho.lt.1.d0) then
write(*,*) '*ERROR reading *OBJECTIVE'
write(*,*) ' first Kreisselmeier-Steinhauser'
write(*,*) ' parameter rho cannot be less'
write(*,*) ' than 1'
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
endif
!
! the target stress for the Kreisselmeier-Steinhauser function
!
if(n.ge.4) then
read(textpart(4)(1:20),'(f20.0)',iostat=istat) stress
if(istat.gt.0) then
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
objectset(2,nobject)(61:80)=textpart(4)(1:20)
endif
!
if(stress.le.0.d0) then
if(icoordinate.eq.1) then
write(*,*) '*ERROR reading *OBJECTIVE'
write(*,*) ' the target stress in the'
write(*,*) ' Kreisselmeier-Steinhauser function'
write(*,*) ' must be strictly positive'
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
endif
else
write(*,*) '*ERROR reading *OBJECTIVE'
write(*,*) ' objective function not known'
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
!
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) exit
!
! if constraints are defined only one objective function is allowed
!
if((nconst.gt.0).and.(nobject.gt.1)) then
write(*,*) '*ERROR reading *OBJECTIVE'
write(*,*) ' in the case constraints are defined,'
write(*,*) ' the definition of only 1 objective'
write(*,*) ' is allowed'
call inputerror(inpc,ipoinpc,iline,
& "*OBJECTIVE%",ier)
return
endif
enddo
!
! In the case constraints are already defined, the actual number of
! nobjects is restored
!
if(nconst.gt.0) then
nobject=nconst
endif
!
return
end
| gpl-2.0 |
techno/gcc-mist32 | libgomp/testsuite/libgomp.fortran/simd7.f90 | 102 | 9430 | ! { dg-do run }
! { dg-additional-options "-msse2" { target sse2_runtime } }
! { dg-additional-options "-mavx" { target avx_runtime } }
subroutine foo (d, e, f, g, m, n)
integer :: i, j, b(2:9), c(3:n), d(:), e(2:n), f(2:,3:), n
integer, allocatable :: g(:), h(:), k, m
logical :: l
l = .false.
allocate (h(2:7))
i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
!$omp simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5)linear(g:6) &
!$omp & linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l)
do i = 0, 63
l = l .or. .not.allocated (g) .or. .not.allocated (h)
l = l .or. .not.allocated (k) .or. .not.allocated (m)
l = l .or. any (b /= 7 + i) .or. any (c /= 8 + 2 * i)
l = l .or. any (d /= 9 + 3 * i) .or. any (e /= 10 + 4 * i)
l = l .or. any (f /= 11 + 5 * i) .or. any (g /= 12 + 6 * i)
l = l .or. any (h /= 13 + 7 * i) .or. (k /= 14 + 8 * i)
l = l .or. (m /= 15 + 9 * i)
l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
h = h + 7; k = k + 8; m = m + 9
end do
if (l .or. i /= 64) call abort
if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
if (m /= 15 + 9 * 64) call abort
if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
!$omp simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5)linear(g:6) &
!$omp & linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l) collapse(2)
do i = 0, 7
do j = 0, 7
l = l .or. .not.allocated (g) .or. .not.allocated (h)
l = l .or. .not.allocated (k) .or. .not.allocated (m)
l = l .or. any (b /= 7 + (8 * i + j)) .or. any (c /= 8 + 2 * (8 * i + j))
l = l .or. any (d /= 9 + 3 * (8 * i + j)) .or. any (e /= 10 + 4 * (8 * i + j))
l = l .or. any (f /= 11 + 5 * (8 * i + j)) .or. any (g /= 12 + 6 * (8 * i + j))
l = l .or. any (h /= 13 + 7 * (8 * i + j)) .or. (k /= 14 + 8 * (8 * i + j))
l = l .or. (m /= 15 + 9 * (8 * i + j))
l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
h = h + 7; k = k + 8; m = m + 9
end do
end do
if (l .or. i /= 8 .or. j /= 8) call abort
if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
if (m /= 15 + 9 * 64) call abort
if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
!$omp parallel do simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5) &
!$omp & linear(g:6)linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l)
do i = 0, 63
l = l .or. .not.allocated (g) .or. .not.allocated (h)
l = l .or. .not.allocated (k) .or. .not.allocated (m)
l = l .or. any (b /= 7 + i) .or. any (c /= 8 + 2 * i)
l = l .or. any (d /= 9 + 3 * i) .or. any (e /= 10 + 4 * i)
l = l .or. any (f /= 11 + 5 * i) .or. any (g /= 12 + 6 * i)
l = l .or. any (h /= 13 + 7 * i) .or. (k /= 14 + 8 * i)
l = l .or. (m /= 15 + 9 * i)
l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
h = h + 7; k = k + 8; m = m + 9
end do
if (l .or. i /= 64) call abort
if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
if (m /= 15 + 9 * 64) call abort
if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
!$omp parallel do simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5) &
!$omp & linear(g:6)linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l) collapse(2)
do i = 0, 7
do j = 0, 7
l = l .or. .not.allocated (g) .or. .not.allocated (h)
l = l .or. .not.allocated (k) .or. .not.allocated (m)
l = l .or. any (b /= 7 + (8 * i + j)) .or. any (c /= 8 + 2 * (8 * i + j))
l = l .or. any (d /= 9 + 3 * (8 * i + j)) .or. any (e /= 10 + 4 * (8 * i + j))
l = l .or. any (f /= 11 + 5 * (8 * i + j)) .or. any (g /= 12 + 6 * (8 * i + j))
l = l .or. any (h /= 13 + 7 * (8 * i + j)) .or. (k /= 14 + 8 * (8 * i + j))
l = l .or. (m /= 15 + 9 * (8 * i + j))
l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
h = h + 7; k = k + 8; m = m + 9
end do
end do
if (l .or. i /= 8 .or. j /= 8) call abort
if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
if (m /= 15 + 9 * 64) call abort
if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
end subroutine
interface
subroutine foo (d, e, f, g, m, n)
integer :: d(:), e(2:n), f(2:,3:), n
integer, allocatable :: g(:), m
end subroutine
end interface
integer, parameter :: n = 8
integer :: d(2:18), e(3:n+1), f(5:6,7:9)
integer, allocatable :: g(:), m
allocate (g(7:10))
call foo (d, e, f, g, m, n)
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.8p2/src/biotsavart.f | 6 | 4807 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 biotsavart(ipkon,kon,lakon,ne,co,qfx,h0,mi,nka,nkb)
!
implicit none
!
! calculates the magnetic intensity due to currents in the phi-
! domain of an electromagnetic calculation
!
character*8 lakon(*)
!
integer ipkon(*),kon(*),ne,i,nka,nkb,mint3d,konl(26),
& j,k,indexe,kk,iflag,mi(*),nope,l
!
real*8 co(3,*),qfx(3,mi(1),*),h0(3,*),xl(3,26),r(3),c2,
& con(3),pgauss(3),c1,xi,et,ze,xsj,shp(4,20),weight
!
include "gauss.f"
!
c1=1.d0/(16.d0*datan(1.d0))
iflag=2
!
do j=nka,nkb
!
do k=1,3
con(k)=co(k,j)
enddo
!
do i=1,ne
if(ipkon(i).lt.0) cycle
!
! currents are supposed to be modeled by shell elements
! only
!
if(lakon(i)(7:7).ne.'L') cycle
!
if(lakon(i)(4:5).eq.'8R') then
mint3d=1
nope=8
elseif(lakon(i)(4:4).eq.'8') then
mint3d=8
nope=8
elseif(lakon(i)(4:6).eq.'20R') then
mint3d=8
nope=20
elseif(lakon(i)(4:4).eq.'2') then
mint3d=27
nope=20
elseif(lakon(i)(4:5).eq.'15') then
mint3d=9
nope=15
elseif(lakon(i)(4:4).eq.'6') then
mint3d=2
nope=6
endif
!
indexe=ipkon(i)
!
do l=1,nope
konl(l)=kon(indexe+l)
do k=1,3
xl(k,l)=co(k,konl(l))
enddo
enddo
!
do kk=1,mint3d
!
if(lakon(i)(4:5).eq.'8R') then
xi=gauss3d1(1,kk)
et=gauss3d1(2,kk)
ze=gauss3d1(3,kk)
weight=weight3d1(kk)
elseif((lakon(i)(4:4).eq.'8').or.
& (lakon(i)(4:6).eq.'20R'))
& then
xi=gauss3d2(1,kk)
et=gauss3d2(2,kk)
ze=gauss3d2(3,kk)
weight=weight3d2(kk)
elseif(lakon(i)(4:4).eq.'2') then
xi=gauss3d3(1,kk)
et=gauss3d3(2,kk)
ze=gauss3d3(3,kk)
weight=weight3d3(kk)
elseif(lakon(i)(4:5).eq.'15') then
xi=gauss3d8(1,kk)
et=gauss3d8(2,kk)
ze=gauss3d8(3,kk)
weight=weight3d8(kk)
elseif(lakon(i)(4:4).eq.'6') then
xi=gauss3d7(1,kk)
et=gauss3d7(2,kk)
ze=gauss3d7(3,kk)
weight=weight3d7(kk)
endif
!
! shape functions
!
if(nope.eq.20) then
call shape20h(xi,et,ze,xl,xsj,shp,iflag)
elseif(nope.eq.8) then
call shape8h(xi,et,ze,xl,xsj,shp,iflag)
elseif(nope.eq.15) then
call shape15w(xi,et,ze,xl,xsj,shp,iflag)
elseif(nope.eq.6) then
call shape6w(xi,et,ze,xl,xsj,shp,iflag)
endif
!
! coordinates of the gauss point
!
do k=1,3
pgauss(k)=0.d0
do l=1,nope
pgauss(k)=pgauss(k)+shp(4,l)*xl(k,l)
enddo
enddo
!
! distance from node to gauss point
!
do k=1,3
r(k)=con(k)-pgauss(k)
enddo
c2=weight*xsj/((r(1)*r(1)+r(2)*r(2)+r(3)*r(3))**(1.5d0))
!
h0(1,j)=h0(1,j)+c2*
& (qfx(2,kk,i)*r(3)-qfx(3,kk,i)*r(2))
h0(2,j)=h0(2,j)+c2*
& (qfx(3,kk,i)*r(1)-qfx(1,kk,i)*r(3))
h0(3,j)=h0(3,j)+c2*
& (qfx(1,kk,i)*r(2)-qfx(2,kk,i)*r(1))
enddo
enddo
!
do k=1,3
h0(k,j)=h0(k,j)*c1
enddo
enddo
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/biotsavart.f | 6 | 4807 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 biotsavart(ipkon,kon,lakon,ne,co,qfx,h0,mi,nka,nkb)
!
implicit none
!
! calculates the magnetic intensity due to currents in the phi-
! domain of an electromagnetic calculation
!
character*8 lakon(*)
!
integer ipkon(*),kon(*),ne,i,nka,nkb,mint3d,konl(26),
& j,k,indexe,kk,iflag,mi(*),nope,l
!
real*8 co(3,*),qfx(3,mi(1),*),h0(3,*),xl(3,26),r(3),c2,
& con(3),pgauss(3),c1,xi,et,ze,xsj,shp(4,20),weight
!
include "gauss.f"
!
c1=1.d0/(16.d0*datan(1.d0))
iflag=2
!
do j=nka,nkb
!
do k=1,3
con(k)=co(k,j)
enddo
!
do i=1,ne
if(ipkon(i).lt.0) cycle
!
! currents are supposed to be modeled by shell elements
! only
!
if(lakon(i)(7:7).ne.'L') cycle
!
if(lakon(i)(4:5).eq.'8R') then
mint3d=1
nope=8
elseif(lakon(i)(4:4).eq.'8') then
mint3d=8
nope=8
elseif(lakon(i)(4:6).eq.'20R') then
mint3d=8
nope=20
elseif(lakon(i)(4:4).eq.'2') then
mint3d=27
nope=20
elseif(lakon(i)(4:5).eq.'15') then
mint3d=9
nope=15
elseif(lakon(i)(4:4).eq.'6') then
mint3d=2
nope=6
endif
!
indexe=ipkon(i)
!
do l=1,nope
konl(l)=kon(indexe+l)
do k=1,3
xl(k,l)=co(k,konl(l))
enddo
enddo
!
do kk=1,mint3d
!
if(lakon(i)(4:5).eq.'8R') then
xi=gauss3d1(1,kk)
et=gauss3d1(2,kk)
ze=gauss3d1(3,kk)
weight=weight3d1(kk)
elseif((lakon(i)(4:4).eq.'8').or.
& (lakon(i)(4:6).eq.'20R'))
& then
xi=gauss3d2(1,kk)
et=gauss3d2(2,kk)
ze=gauss3d2(3,kk)
weight=weight3d2(kk)
elseif(lakon(i)(4:4).eq.'2') then
xi=gauss3d3(1,kk)
et=gauss3d3(2,kk)
ze=gauss3d3(3,kk)
weight=weight3d3(kk)
elseif(lakon(i)(4:5).eq.'15') then
xi=gauss3d8(1,kk)
et=gauss3d8(2,kk)
ze=gauss3d8(3,kk)
weight=weight3d8(kk)
elseif(lakon(i)(4:4).eq.'6') then
xi=gauss3d7(1,kk)
et=gauss3d7(2,kk)
ze=gauss3d7(3,kk)
weight=weight3d7(kk)
endif
!
! shape functions
!
if(nope.eq.20) then
call shape20h(xi,et,ze,xl,xsj,shp,iflag)
elseif(nope.eq.8) then
call shape8h(xi,et,ze,xl,xsj,shp,iflag)
elseif(nope.eq.15) then
call shape15w(xi,et,ze,xl,xsj,shp,iflag)
elseif(nope.eq.6) then
call shape6w(xi,et,ze,xl,xsj,shp,iflag)
endif
!
! coordinates of the gauss point
!
do k=1,3
pgauss(k)=0.d0
do l=1,nope
pgauss(k)=pgauss(k)+shp(4,l)*xl(k,l)
enddo
enddo
!
! distance from node to gauss point
!
do k=1,3
r(k)=con(k)-pgauss(k)
enddo
c2=weight*xsj/((r(1)*r(1)+r(2)*r(2)+r(3)*r(3))**(1.5d0))
!
h0(1,j)=h0(1,j)+c2*
& (qfx(2,kk,i)*r(3)-qfx(3,kk,i)*r(2))
h0(2,j)=h0(2,j)+c2*
& (qfx(3,kk,i)*r(1)-qfx(1,kk,i)*r(3))
h0(3,j)=h0(3,j)+c2*
& (qfx(1,kk,i)*r(2)-qfx(2,kk,i)*r(1))
enddo
enddo
!
do k=1,3
h0(k,j)=h0(k,j)*c1
enddo
enddo
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/massflow_percent.f | 1 | 4745 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 massflow_percent(node1,node2,nodem,nelem,lakon,kon,
& ipkon,nactdog,identity,ielprop,prop,iflag,v,xflow,f,
& nodef,idirf,df,cp,r,physcon,dvi,numf,set,shcon,
& nshcon,rhcon,nrhcon,ntmat_,co,vold,mi,ttime,time,iaxial)
!
! partial massflow element
!
! author: Yannick Muller
!
implicit none
!
logical identity
character*8 lakon(*)
character*81 set(*)
!
integer nelem,nactdog(0:3,*),node1,node2,nodem,numf,
& ielprop(*),nodef(*),idirf(*),index,iflag,
& inv,ipkon(*),kon(*),number,kgas,iaxial,
& nodea,nodeb,mi(*),i,itype,nodemup,
& nrhcon(*),ntmat_,nshcon(*)
!
real*8 prop(*),v(0:mi(2),*),xflow,f,df(*),kappa,R,a,d,xl,
& p1,p2,T1,physcon(*),pi,xflow_oil,T2,co(3,*),vold(0:mi(2),*),
& xflow_sum,percent_xflow,cp,dvi,pt1,pt2,Tt1,Tt2,ttime,time,
& shcon(0:3,ntmat_,*),rhcon(0:1,ntmat_,*)
!
pi=4.d0*datan(1.d0)
index=ielprop(nelem)
!
if(iflag.eq.0) then
identity=.true.
!
if(nactdog(2,node1).ne.0)then
identity=.false.
elseif(nactdog(2,node2).ne.0)then
identity=.false.
elseif(nactdog(1,nodem).ne.0)then
identity=.false.
endif
!
elseif(iflag.eq.1)then
!
percent_xflow=prop(index+1)
xflow_sum=0
!
do i=2,10
if(nint(prop(index+i)).ne.0) then
nodemup=kon(ipkon(nint(prop(index+i)))+2)
if(v(1,nodemup).gt.0)then
xflow_sum=xflow_sum+v(1,nodemup)*iaxial
endif
endif
enddo
!
if(xflow_sum.eq.0d0) then
xflow_sum=0.001d0
endif
!
xflow=xflow_sum*percent_xflow
!
elseif((iflag.eq.2).or.(iflag.eq.3))then
!
percent_xflow=prop(index+1)
xflow_sum=0
do i=2,10
if(nint(prop(index+i)).ne.0) then
nodemup=kon(ipkon(nint(prop(index+i)))+2)
if(v(1,nodemup).gt.0)then
xflow_sum=xflow_sum+v(1,nodemup)*iaxial
endif
endif
enddo
if(xflow_sum.eq.0.d0) then
xflow_sum=1E-5
endif
!
inv=1
!
pt1=v(2,node1)
pt2=v(2,node2)
xflow=v(1,nodem)*iaxial
Tt1=v(0,node1)-physcon(1)
Tt2=v(0,node2)-physcon(1)
!
nodef(1)=node1
nodef(2)=node1
nodef(3)=nodem
nodef(4)=node2
!
idirf(1)=2
idirf(2)=0
idirf(3)=1
idirf(4)=2
!
if(iflag.eq.2) then
numf=4
!
f=xflow/xflow_sum-percent_xflow
!
df(1)=0
df(2)=0
df(3)=1/xflow_sum
df(4)=0
!
! output
!
elseif(iflag.eq.3)then
!
xflow_oil=0
!
write(1,*) ''
write(1,55) ' from node ',node1,
& ' to node ', node2,' : air massflow rate = '
& ,inv*xflow,
& ', oil massflow rate = ',xflow_oil
55 format(1X,A,I6,A,I6,A,e11.4,A,A,e11.4,A)
!
write(1,56)' Inlet node ',node1,' : Tt1 = ',Tt1,
& ' , Ts1 = ',Tt1,' , Pt1 = ',Pt1
!
write(1,*)' Element ',nelem,lakon(nelem)
write(1,57)' Massflow upstream = ',xflow_sum,
& ' [kg/s]'
write(1,58)' Massflow fraction = ', percent_xflow
write(1,56)' Outlet node ',node2,': Tt2=',Tt2,
& ', Ts2=',Tt2,', Pt2=',Pt2
!
endif
endif
!
56 format(1X,A,I6,A,e11.4,A,e11.4,A,e11.4,A)
57 format(1X,A,e11.4,A)
58 format(1X,A,e11.4)
!
xflow=xflow/iaxial
df(3)=df(3)*iaxial
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.17/src/near3d_se.f | 1 | 6384 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2020 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 near3d_se(xo,yo,zo,x,y,z,nx,ny,nz,xp,yp,zp,n,
& ir,r,nr,radius)
!
! determines the nodes out of n within a radius r of
! the point with coordinates (xp,yp,zp);
!
!
! INPUT:
!
! xo x-coordinates of cloud of nodes
! yo y-coordinates of cloud of nodes
! zo z-coordinates of cloud of nodes
! x xo ordered in increasing order
! (can be done in the calling program
! with dsort)
! y yo ordered in increasing order
! z zo ordered in increasing order
! nx permutations of x-ordering
! ny permutations of y-ordering
! nz permutations of z-ordering
! xp x-coordinate of point of interest
! yp y-coordinate of point of interest
! zp z-coordinate of point of interest
! n number of nodes in cloud
! radius radius
!
! OUTPUT:
!
! ir numbers of the nodes within the given radius
! r distance square of the nodes within the given
! radius
! nr number of nodes within the given radius
!
implicit none
!
integer n,nx(n),ny(n),nz(n),ir(n+6),nr,nrprev,irnew,
& i,j,k,m,id,idx,idy,idz,node
!
real*8 x(n),y(n),z(n),xo(n),yo(n),zo(n),xp,yp,zp,r(n+6),
& xr,yr,zr,c(8),dd,xw,xe,ys,yn,zb,zt,radius,
& radius2
!
radius2=radius*radius
nrprev=0
!
! identify position of xp, yp and zp
!
call ident(x,xp,n,idx)
call ident(y,yp,n,idy)
call ident(z,zp,n,idz)
!
! initialization of the maximal distance in each direction
!
xw=0.d0
xe=0.d0
ys=0.d0
yn=0.d0
zb=0.d0
zt=0.d0
!
i=1
!
do
!
nr=nrprev
!
! westp
!
id=idx+1-i
if(id.gt.0) then
node=nx(id)
xw=xo(node)-xp
yr=yo(node)-yp
zr=zo(node)-zp
dd=xw*xw+yr*yr+zr*zr
if(dd.lt.radius2) then
nr=nr+1
ir(nr)=node
endif
else
xw=1.d30
endif
!
! east
!
id=idx+i
if(id.le.n) then
node=nx(id)
xe=xo(node)-xp
yr=yo(node)-yp
zr=zo(node)-zp
dd=xe*xe+yr*yr+zr*zr
if(dd.lt.radius2) then
nr=nr+1
ir(nr)=node
endif
else
xe=1.d30
endif
!
! south
!
id=idy+1-i
if(id.gt.0) then
node=ny(id)
xr=xo(node)-xp
ys=yo(node)-yp
zr=zo(node)-zp
dd=xr*xr+ys*ys+zr*zr
if(dd.lt.radius2) then
nr=nr+1
ir(nr)=node
endif
else
ys=1.d30
endif
!
! north
!
id=idy+i
if(id.le.n) then
node=ny(id)
xr=xo(node)-xp
yn=yo(node)-yp
zr=zo(node)-zp
dd=xr*xr+yn*yn+zr*zr
if(dd.lt.radius2) then
nr=nr+1
ir(nr)=node
endif
else
yn=1.d30
endif
!
! bottom
!
id=idz+1-i
if(id.gt.0) then
node=nz(id)
xr=xo(node)-xp
yr=yo(node)-yp
zb=zo(node)-zp
dd=xr*xr+yr*yr+zb*zb
if(dd.lt.radius2) then
nr=nr+1
ir(nr)=node
endif
else
zb=1.d30
endif
!
! top
!
id=idz+i
if(id.le.n) then
node=nz(id)
xr=xo(node)-xp
yr=yo(node)-yp
zt=zo(node)-zp
dd=xr*xr+yr*yr+zt*zt
if(dd.lt.radius2) then
nr=nr+1
ir(nr)=node
endif
else
zt=1.d30
endif
!
! check for new entries
!
if(nr.gt.nrprev) then
m=nrprev
do j=nrprev+1,nr
irnew=ir(j)
call nident(ir,irnew,m,id)
if(id.eq.0) then
m=m+1
do k=m,2,-1
ir(k)=ir(k-1)
enddo
ir(1)=irnew
elseif(ir(id).ne.irnew) then
m=m+1
do k=m,id+2,-1
ir(k)=ir(k-1)
enddo
ir(id+1)=irnew
endif
enddo
nrprev=m
endif
!
i=i+1
!
! check the corners of the box
!
c(1)=xe*xe+yn*yn+zb*zb
if(c(1).lt.radius2) cycle
c(2)=xw*xw+yn*yn+zb*zb
if(c(2).lt.radius2) cycle
c(3)=xw*xw+ys*ys+zb*zb
if(c(3).lt.radius2) cycle
c(4)=xe*xe+ys*ys+zb*zb
if(c(4).lt.radius2) cycle
c(5)=xe*xe+yn*yn+zt*zt
if(c(5).lt.radius2) cycle
c(6)=xw*xw+yn*yn+zt*zt
if(c(6).lt.radius2) cycle
c(7)=xw*xw+ys*ys+zt*zt
if(c(7).lt.radius2) cycle
c(8)=xe*xe+ys*ys+zt*zt
if(c(8).lt.radius2) cycle
!
! no new entries possible: finished
!
nr=nrprev
do j=1,nr
node=ir(j)
xr=xo(node)-xp
yr=yo(node)-yp
zr=zo(node)-zp
r(j)=xr*xr+yr*yr+zr*zr
enddo
exit
!
enddo
!
return
end
| gpl-2.0 |
epfl-cosmo/q-e | PP/src/local_dos1d.f90 | 8 | 7523 |
!
! Copyright (C) 2001 PWSCF group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!
!--------------------------------------------------------------------
SUBROUTINE local_dos1d (ik, kband, plan)
!--------------------------------------------------------------------
!
! calculates |psi|^2 for band kband at point ik
!
USE kinds, ONLY: dp
USE cell_base, ONLY: omega
USE ions_base, ONLY: nat, ntyp=>nsp, ityp
USE fft_base, ONLY: dffts, dfftp
USE fft_interfaces, ONLY : fwfft, invfft
USE gvecs, ONLY : nls, doublegrid
USE lsda_mod, ONLY: current_spin
USE uspp, ONLY: becsum, indv, nhtol, nhtoj
USE uspp_param, ONLY: upf, nh, nhm
USE wvfct, ONLY: npwx, wg
USE klist, ONLY: ngk, igk_k
USE noncollin_module, ONLY: noncolin, npol
USE spin_orb, ONLY: lspinorb, fcoef
USE wavefunctions_module, ONLY: evc, psic, psic_nc
USE becmod, ONLY: bec_type, becp
IMPLICIT NONE
!
! input variables
!
INTEGER :: ik, kband
! input: the k point
! input: the band
real(DP) :: plan (dfftp%nr3)
! output: the planar average of this state
!
! Additional local variables for Ultrasoft PP's
!
INTEGER :: npw, ikb, jkb, ijkb0, ih, jh, na, ijh, ipol, np
! counter on beta functions
! counter on beta functions
! auxiliary variable for ijkb0
! counter on solid beta functions
! counter on solid beta functions
! counter on atoms
! counter on composite beta functions
! the pseudopotential
!
! And here the local variables
!
INTEGER :: ir, ig, ibnd, is1, is2, kkb, kh
! counter on 3D r points
! counter on spin polarizations
! counter on g vectors
! counter on bands
real(DP) :: w1
! the weight of one k point
real(DP), ALLOCATABLE :: aux (:)
! auxiliary for rho
COMPLEX(DP), ALLOCATABLE :: prho (:), be1(:,:), be2(:,:)
! complex charge for fft
ALLOCATE (prho(dfftp%nnr))
ALLOCATE (aux(dfftp%nnr))
IF (lspinorb) THEN
ALLOCATE(be1(nhm,2))
ALLOCATE(be2(nhm,2))
ENDIF
aux(:) = 0.d0
becsum(:,:,:) = 0.d0
npw = ngk(ik)
wg (kband, ik) = 1.d0
!
!
! First compute the square modulus of the state kband,ik on the smooth
! mesh
!
IF (noncolin) THEN
psic_nc = (0.d0,0.d0)
DO ig = 1, npw
psic_nc (nls (igk_k (ig,ik) ), 1 ) = evc (ig , kband)
psic_nc (nls (igk_k (ig,ik) ), 2 ) = evc (ig+npwx, kband)
ENDDO
DO ipol=1,npol
CALL invfft ('Wave', psic_nc(:,ipol), dffts)
ENDDO
w1 = wg (kband, ik) / omega
DO ipol=1,npol
DO ir = 1, dffts%nnr
aux(ir) = aux(ir) + w1 * ( dble(psic_nc(ir,ipol))**2 + &
aimag(psic_nc(ir,ipol))**2 )
ENDDO
ENDDO
ELSE
psic(1:dffts%nnr) = (0.d0,0.d0)
DO ig = 1, npw
psic (nls (igk_k (ig,ik) ) ) = evc (ig, kband)
ENDDO
CALL invfft ('Wave', psic, dffts)
w1 = wg (kband, ik) / omega
DO ir = 1, dffts%nnr
aux(ir) = aux(ir) + w1 * (dble(psic(ir))**2 + aimag(psic(ir))**2)
ENDDO
ENDIF
!
! If we have a US pseudopotential we compute here the becsum term
!
ibnd = kband
w1 = wg (ibnd, ik)
ijkb0 = 0
DO np = 1, ntyp
IF (upf(np)%tvanp) THEN
DO na = 1, nat
IF (ityp (na) == np) THEN
IF (noncolin) THEN
IF (upf(np)%has_so) THEN
be1=(0.d0,0.d0)
be2=(0.d0,0.d0)
DO ih = 1, nh(np)
ikb = ijkb0 + ih
DO kh = 1, nh(np)
IF ((nhtol(kh,np)==nhtol(ih,np)).and. &
(nhtoj(kh,np)==nhtoj(ih,np)).and. &
(indv(kh,np)==indv(ih,np))) THEN
kkb=ijkb0 + kh
DO is1=1,2
DO is2=1,2
be1(ih,is1)=be1(ih,is1)+ &
fcoef(ih,kh,is1,is2,np)* &
becp%nc(kkb,is2,ibnd)
be2(ih,is1)=be2(ih,is1)+ &
fcoef(kh,ih,is2,is1,np)* &
conjg(becp%nc(kkb,is2,ibnd))
ENDDO
ENDDO
ENDIF
ENDDO
ENDDO
ENDIF
ENDIF
ijh = 1
DO ih = 1, nh (np)
ikb = ijkb0 + ih
IF (noncolin) THEN
IF (upf(np)%has_so) THEN
becsum(ijh,na,1)=becsum(ijh,na,1)+ w1* &
(be1(ih,1)*be2(ih,1)+be1(ih,2)*be2(ih,2))
ELSE
DO ipol=1,npol
becsum(ijh,na,current_spin) = &
becsum(ijh,na,current_spin) + w1 * &
dble( conjg(becp%nc(ikb,ipol,ibnd)) * &
becp%nc(ikb,ipol,ibnd) )
ENDDO
ENDIF
ELSE
becsum(ijh,na,current_spin) = &
becsum(ijh,na,current_spin) + w1 * &
dble( conjg(becp%k(ikb,ibnd)) * becp%k(ikb,ibnd) )
ENDIF
ijh = ijh + 1
DO jh = ih + 1, nh (np)
jkb = ijkb0 + jh
IF (noncolin) THEN
IF (upf(np)%has_so) THEN
becsum(ijh,na,1)=becsum(ijh,na,1) &
+ w1*((be1(jh,1)*be2(ih,1)+ &
be1(jh,2)*be2(ih,2))+ &
(be1(ih,1)*be2(jh,1)+ &
be1(ih,2)*be2(jh,2)) )
ELSE
DO ipol=1,npol
becsum(ijh,na,current_spin) = &
becsum(ijh,na,current_spin) + w1 * 2.d0 * &
dble( conjg(becp%nc(ikb,ipol,ibnd)) &
* becp%nc(jkb,ipol,ibnd) )
ENDDO
ENDIF
ELSE
becsum(ijh,na,current_spin) = &
becsum(ijh,na,current_spin) + w1 * 2.d0 * &
dble( conjg(becp%k(ikb,ibnd)) * becp%k(jkb,ibnd) )
ENDIF
ijh = ijh + 1
ENDDO
ENDDO
ijkb0 = ijkb0 + nh (np)
ENDIF
ENDDO
ELSE
DO na = 1, nat
IF (ityp (na) ==np) ijkb0 = ijkb0 + nh (np)
ENDDO
ENDIF
ENDDO
!
! Interpolate on the thick mesh and pass to reciprocal space
!
IF (doublegrid) THEN
CALL interpolate (aux, aux, 1)
ENDIF
DO ir = 1, dfftp%nnr
prho (ir) = cmplx(aux (ir), 0.d0,kind=DP)
ENDDO
CALL fwfft ('Dense', prho, dfftp)
!
! Here we add the US contribution to the charge for the atoms which n
! it. Or compute the planar average in the NC case.
!
CALL addusdens1d (plan, prho)
!
DEALLOCATE (aux)
DEALLOCATE (prho)
IF (lspinorb) THEN
DEALLOCATE(be1)
DEALLOCATE(be2)
ENDIF
!
RETURN
END SUBROUTINE local_dos1d
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/convert2slapcol.f | 1 | 1342 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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.
!
! y=A*x for real sparse symmetric matrices
!
! storage of the matrix:
! au: first lower triangle
! ad: diagonal terms
!
subroutine convert2slapcol(au,ad,jq,nzs,nef,aua)
!
implicit none
!
integer jq(*),nzs,nef,i,j,k
real*8 au(*),ad(*),aua(*)
!
! converting the CalculiX format into the SLAP column format
!
k=nzs+nef
!
do i=nef,1,-1
do j=jq(i+1)-1,jq(i),-1
aua(k)=au(j)
k=k-1
enddo
aua(k)=ad(i)
k=k-1
enddo
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.15/src/isortiid.f | 10 | 8748 | !
! SLATEC: public domain
!
*deck isort
subroutine isortiid (ix,iy,dy,n,kflag)
!
! modified to make the same interchanges in an integer (iy)
! and double (dy) array!
!
C***BEGIN PROLOGUE ISORT
C***PURPOSE Sort an array and optionally make the same interchanges in
C an auxiliary array. The array may be sorted in increasing
C or decreasing order. A slightly modified QUICKSORT
C algorithm is used.
C***LIBRARY SLATEC
C***CATEGORY N6A2A
C***TYPE INTEGER (SSORT-S, DSORT-D, ISORT-I)
C***KEYWORDS SINGLETON QUICKSORT, SORT, SORTING
C***AUTHOR Jones, R. E., (SNLA)
C Kahaner, D. K., (NBS)
C Wisniewski, J. A., (SNLA)
C***DESCRIPTION
C
C ISORT sorts array IX and optionally makes the same interchanges in
C array IY. The array IX may be sorted in increasing order or
C decreasing order. A slightly modified quicksort algorithm is used.
C
C Description of Parameters
C IX - integer array of values to be sorted
C IY - integer array to be (optionally) carried along
C N - number of values in integer array IX to be sorted
C KFLAG - control parameter
C = 2 means sort IX in increasing order and carry IY along.
C = 1 means sort IX in increasing order (ignoring IY)
C = -1 means sort IX in decreasing order (ignoring IY)
C = -2 means sort IX in decreasing order and carry IY along.
C
C***REFERENCES R. C. Singleton, Algorithm 347, An efficient algorithm
C for sorting with minimal storage, Communications of
C the ACM, 12, 3 (1969), pp. 185-187.
C***ROUTINES CALLED XERMSG
C***REVISION HISTORY (YYMMDD)
C 761118 DATE WRITTEN
C 810801 Modified by David K. Kahaner.
C 890531 Changed all specific intrinsics to generic. (WRB)
C 890831 Modified array declarations. (WRB)
C 891009 Removed unreferenced statement labels. (WRB)
C 891009 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
C 901012 Declared all variables; changed X,Y to IX,IY. (M. McClain)
C 920501 Reformatted the REFERENCES section. (DWL, WRB)
C 920519 Clarified error messages. (DWL)
C 920801 Declarations section rebuilt and code restructured to use
C IF-THEN-ELSE-ENDIF. (RWC, WRB)
! 100411 changed the dimension of IL and IU from 21 to 31.
!
! field IL and IU have the dimension 31. This is log2 of the largest
! array size to be sorted. If arrays larger than 2**31 in length have
! to be sorted, this dimension has to be modified accordingly
!
C***END PROLOGUE ISORT
!
implicit none
C .. Scalar Arguments ..
integer kflag, n
C .. Array Arguments ..
integer ix(*)
real*8 dy(*)
integer iy(*)
C .. Local Scalars ..
real r
integer i, ij, j, k, kk, l, m, nn, t, tt
real*8 tty,ty
integer uuy,uy
C .. Local Arrays ..
integer il(31), iu(31)
C .. External Subroutines ..
! EXTERNAL XERMSG
C .. Intrinsic Functions ..
intrinsic abs, int
C***FIRST EXECUTABLE STATEMENT ISORT
nn = n
if (nn .lt. 1) then
! CALL XERMSG ('SLATEC', 'ISORT',
! + 'The number of values to be sorted is not positive.', 1, 1)
return
endif
C
kk = abs(kflag)
if (kk.ne.1 .and. kk.ne.2) then
! CALL XERMSG ('SLATEC', 'ISORT',
! + 'The sort control parameter, K, is not 2, 1, -1, or -2.', 2,
! + 1)
return
endif
C
C Alter array IX to get decreasing order if needed
C
if (kflag .le. -1) then
do 10 i=1,nn
ix(i) = -ix(i)
10 continue
endif
C
if (kk .eq. 2) go to 100
C
C Sort IX only
C
m = 1
i = 1
j = nn
r = 0.375e0
C
20 if (i .eq. j) go to 60
if (r .le. 0.5898437e0) then
r = r+3.90625e-2
else
r = r-0.21875e0
endif
C
30 k = i
C
C Select a central element of the array and save it in location T
C
ij = i + int((j-i)*r)
t = ix(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
endif
l = j
C
C If last element of array is less than than T, interchange with T
C
if (ix(j) .lt. t) then
ix(ij) = ix(j)
ix(j) = t
t = ix(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
endif
endif
C
C Find an element in the second half of the array which is smaller
C than T
C
40 l = l-1
if (ix(l) .gt. t) go to 40
C
C Find an element in the first half of the array which is greater
C than T
C
50 k = k+1
if (ix(k) .lt. t) go to 50
C
C Interchange these elements
C
if (k .le. l) then
tt = ix(l)
ix(l) = ix(k)
ix(k) = tt
go to 40
endif
C
C Save upper and lower subscripts of the array yet to be sorted
C
if (l-i .gt. j-k) then
il(m) = i
iu(m) = l
i = k
m = m+1
else
il(m) = k
iu(m) = j
j = l
m = m+1
endif
go to 70
C
C Begin again on another portion of the unsorted array
C
60 m = m-1
if (m .eq. 0) go to 190
i = il(m)
j = iu(m)
C
70 if (j-i .ge. 1) go to 30
if (i .eq. 1) go to 20
i = i-1
C
80 i = i+1
if (i .eq. j) go to 60
t = ix(i+1)
if (ix(i) .le. t) go to 80
k = i
C
90 ix(k+1) = ix(k)
k = k-1
if (t .lt. ix(k)) go to 90
ix(k+1) = t
go to 80
C
C Sort IX and carry IY along
C
100 m = 1
i = 1
j = nn
r = 0.375e0
C
110 if (i .eq. j) go to 150
if (r .le. 0.5898437e0) then
r = r+3.90625e-2
else
r = r-0.21875e0
endif
C
120 k = i
C
C Select a central element of the array and save it in location T
C
ij = i + int((j-i)*r)
t = ix(ij)
ty = dy(ij)
uy = iy(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
dy(ij) = dy(i)
iy(ij) = iy(i)
dy(i) = ty
iy(i) = uy
ty = dy(ij)
uy = iy(ij)
endif
l = j
C
C If last element of array is less than T, interchange with T
C
if (ix(j) .lt. t) then
ix(ij) = ix(j)
ix(j) = t
t = ix(ij)
dy(ij) = dy(j)
iy(ij) = iy(j)
dy(j) = ty
iy(j) = uy
ty = dy(ij)
uy = iy(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
dy(ij) = dy(i)
iy(ij) = iy(i)
dy(i) = ty
iy(i) = uy
ty = dy(ij)
uy = iy(ij)
endif
endif
C
C Find an element in the second half of the array which is smaller
C than T
C
130 l = l-1
if (ix(l) .gt. t) go to 130
C
C Find an element in the first half of the array which is greater
C than T
C
140 k = k+1
if (ix(k) .lt. t) go to 140
C
C Interchange these elements
C
if (k .le. l) then
tt = ix(l)
ix(l) = ix(k)
ix(k) = tt
tty = dy(l)
uuy = iy(l)
dy(l) = dy(k)
iy(l) = iy(k)
dy(k) = tty
iy(k) = uuy
go to 130
endif
C
C Save upper and lower subscripts of the array yet to be sorted
C
if (l-i .gt. j-k) then
il(m) = i
iu(m) = l
i = k
m = m+1
else
il(m) = k
iu(m) = j
j = l
m = m+1
endif
go to 160
C
C Begin again on another portion of the unsorted array
C
150 m = m-1
if (m .eq. 0) go to 190
i = il(m)
j = iu(m)
C
160 if (j-i .ge. 1) go to 120
if (i .eq. 1) go to 110
i = i-1
C
170 i = i+1
if (i .eq. j) go to 150
t = ix(i+1)
ty = dy(i+1)
uy = iy(i+1)
if (ix(i) .le. t) go to 170
k = i
C
180 ix(k+1) = ix(k)
dy(k+1) = dy(k)
iy(k+1) = iy(k)
k = k-1
if (t .lt. ix(k)) go to 180
ix(k+1) = t
dy(k+1) = ty
iy(k+1) = uy
go to 170
C
C Clean up
C
190 if (kflag .le. -1) then
do 200 i=1,nn
ix(i) = -ix(i)
200 continue
endif
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/isortiid.f | 10 | 8748 | !
! SLATEC: public domain
!
*deck isort
subroutine isortiid (ix,iy,dy,n,kflag)
!
! modified to make the same interchanges in an integer (iy)
! and double (dy) array!
!
C***BEGIN PROLOGUE ISORT
C***PURPOSE Sort an array and optionally make the same interchanges in
C an auxiliary array. The array may be sorted in increasing
C or decreasing order. A slightly modified QUICKSORT
C algorithm is used.
C***LIBRARY SLATEC
C***CATEGORY N6A2A
C***TYPE INTEGER (SSORT-S, DSORT-D, ISORT-I)
C***KEYWORDS SINGLETON QUICKSORT, SORT, SORTING
C***AUTHOR Jones, R. E., (SNLA)
C Kahaner, D. K., (NBS)
C Wisniewski, J. A., (SNLA)
C***DESCRIPTION
C
C ISORT sorts array IX and optionally makes the same interchanges in
C array IY. The array IX may be sorted in increasing order or
C decreasing order. A slightly modified quicksort algorithm is used.
C
C Description of Parameters
C IX - integer array of values to be sorted
C IY - integer array to be (optionally) carried along
C N - number of values in integer array IX to be sorted
C KFLAG - control parameter
C = 2 means sort IX in increasing order and carry IY along.
C = 1 means sort IX in increasing order (ignoring IY)
C = -1 means sort IX in decreasing order (ignoring IY)
C = -2 means sort IX in decreasing order and carry IY along.
C
C***REFERENCES R. C. Singleton, Algorithm 347, An efficient algorithm
C for sorting with minimal storage, Communications of
C the ACM, 12, 3 (1969), pp. 185-187.
C***ROUTINES CALLED XERMSG
C***REVISION HISTORY (YYMMDD)
C 761118 DATE WRITTEN
C 810801 Modified by David K. Kahaner.
C 890531 Changed all specific intrinsics to generic. (WRB)
C 890831 Modified array declarations. (WRB)
C 891009 Removed unreferenced statement labels. (WRB)
C 891009 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
C 901012 Declared all variables; changed X,Y to IX,IY. (M. McClain)
C 920501 Reformatted the REFERENCES section. (DWL, WRB)
C 920519 Clarified error messages. (DWL)
C 920801 Declarations section rebuilt and code restructured to use
C IF-THEN-ELSE-ENDIF. (RWC, WRB)
! 100411 changed the dimension of IL and IU from 21 to 31.
!
! field IL and IU have the dimension 31. This is log2 of the largest
! array size to be sorted. If arrays larger than 2**31 in length have
! to be sorted, this dimension has to be modified accordingly
!
C***END PROLOGUE ISORT
!
implicit none
C .. Scalar Arguments ..
integer kflag, n
C .. Array Arguments ..
integer ix(*)
real*8 dy(*)
integer iy(*)
C .. Local Scalars ..
real r
integer i, ij, j, k, kk, l, m, nn, t, tt
real*8 tty,ty
integer uuy,uy
C .. Local Arrays ..
integer il(31), iu(31)
C .. External Subroutines ..
! EXTERNAL XERMSG
C .. Intrinsic Functions ..
intrinsic abs, int
C***FIRST EXECUTABLE STATEMENT ISORT
nn = n
if (nn .lt. 1) then
! CALL XERMSG ('SLATEC', 'ISORT',
! + 'The number of values to be sorted is not positive.', 1, 1)
return
endif
C
kk = abs(kflag)
if (kk.ne.1 .and. kk.ne.2) then
! CALL XERMSG ('SLATEC', 'ISORT',
! + 'The sort control parameter, K, is not 2, 1, -1, or -2.', 2,
! + 1)
return
endif
C
C Alter array IX to get decreasing order if needed
C
if (kflag .le. -1) then
do 10 i=1,nn
ix(i) = -ix(i)
10 continue
endif
C
if (kk .eq. 2) go to 100
C
C Sort IX only
C
m = 1
i = 1
j = nn
r = 0.375e0
C
20 if (i .eq. j) go to 60
if (r .le. 0.5898437e0) then
r = r+3.90625e-2
else
r = r-0.21875e0
endif
C
30 k = i
C
C Select a central element of the array and save it in location T
C
ij = i + int((j-i)*r)
t = ix(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
endif
l = j
C
C If last element of array is less than than T, interchange with T
C
if (ix(j) .lt. t) then
ix(ij) = ix(j)
ix(j) = t
t = ix(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
endif
endif
C
C Find an element in the second half of the array which is smaller
C than T
C
40 l = l-1
if (ix(l) .gt. t) go to 40
C
C Find an element in the first half of the array which is greater
C than T
C
50 k = k+1
if (ix(k) .lt. t) go to 50
C
C Interchange these elements
C
if (k .le. l) then
tt = ix(l)
ix(l) = ix(k)
ix(k) = tt
go to 40
endif
C
C Save upper and lower subscripts of the array yet to be sorted
C
if (l-i .gt. j-k) then
il(m) = i
iu(m) = l
i = k
m = m+1
else
il(m) = k
iu(m) = j
j = l
m = m+1
endif
go to 70
C
C Begin again on another portion of the unsorted array
C
60 m = m-1
if (m .eq. 0) go to 190
i = il(m)
j = iu(m)
C
70 if (j-i .ge. 1) go to 30
if (i .eq. 1) go to 20
i = i-1
C
80 i = i+1
if (i .eq. j) go to 60
t = ix(i+1)
if (ix(i) .le. t) go to 80
k = i
C
90 ix(k+1) = ix(k)
k = k-1
if (t .lt. ix(k)) go to 90
ix(k+1) = t
go to 80
C
C Sort IX and carry IY along
C
100 m = 1
i = 1
j = nn
r = 0.375e0
C
110 if (i .eq. j) go to 150
if (r .le. 0.5898437e0) then
r = r+3.90625e-2
else
r = r-0.21875e0
endif
C
120 k = i
C
C Select a central element of the array and save it in location T
C
ij = i + int((j-i)*r)
t = ix(ij)
ty = dy(ij)
uy = iy(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
dy(ij) = dy(i)
iy(ij) = iy(i)
dy(i) = ty
iy(i) = uy
ty = dy(ij)
uy = iy(ij)
endif
l = j
C
C If last element of array is less than T, interchange with T
C
if (ix(j) .lt. t) then
ix(ij) = ix(j)
ix(j) = t
t = ix(ij)
dy(ij) = dy(j)
iy(ij) = iy(j)
dy(j) = ty
iy(j) = uy
ty = dy(ij)
uy = iy(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
dy(ij) = dy(i)
iy(ij) = iy(i)
dy(i) = ty
iy(i) = uy
ty = dy(ij)
uy = iy(ij)
endif
endif
C
C Find an element in the second half of the array which is smaller
C than T
C
130 l = l-1
if (ix(l) .gt. t) go to 130
C
C Find an element in the first half of the array which is greater
C than T
C
140 k = k+1
if (ix(k) .lt. t) go to 140
C
C Interchange these elements
C
if (k .le. l) then
tt = ix(l)
ix(l) = ix(k)
ix(k) = tt
tty = dy(l)
uuy = iy(l)
dy(l) = dy(k)
iy(l) = iy(k)
dy(k) = tty
iy(k) = uuy
go to 130
endif
C
C Save upper and lower subscripts of the array yet to be sorted
C
if (l-i .gt. j-k) then
il(m) = i
iu(m) = l
i = k
m = m+1
else
il(m) = k
iu(m) = j
j = l
m = m+1
endif
go to 160
C
C Begin again on another portion of the unsorted array
C
150 m = m-1
if (m .eq. 0) go to 190
i = il(m)
j = iu(m)
C
160 if (j-i .ge. 1) go to 120
if (i .eq. 1) go to 110
i = i-1
C
170 i = i+1
if (i .eq. j) go to 150
t = ix(i+1)
ty = dy(i+1)
uy = iy(i+1)
if (ix(i) .le. t) go to 170
k = i
C
180 ix(k+1) = ix(k)
dy(k+1) = dy(k)
iy(k+1) = iy(k)
k = k-1
if (t .lt. ix(k)) go to 180
ix(k+1) = t
dy(k+1) = ty
iy(k+1) = uy
go to 170
C
C Clean up
C
190 if (kflag .le. -1) then
do 200 i=1,nn
ix(i) = -ix(i)
200 continue
endif
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.16/src/isortiid.f | 10 | 8748 | !
! SLATEC: public domain
!
*deck isort
subroutine isortiid (ix,iy,dy,n,kflag)
!
! modified to make the same interchanges in an integer (iy)
! and double (dy) array!
!
C***BEGIN PROLOGUE ISORT
C***PURPOSE Sort an array and optionally make the same interchanges in
C an auxiliary array. The array may be sorted in increasing
C or decreasing order. A slightly modified QUICKSORT
C algorithm is used.
C***LIBRARY SLATEC
C***CATEGORY N6A2A
C***TYPE INTEGER (SSORT-S, DSORT-D, ISORT-I)
C***KEYWORDS SINGLETON QUICKSORT, SORT, SORTING
C***AUTHOR Jones, R. E., (SNLA)
C Kahaner, D. K., (NBS)
C Wisniewski, J. A., (SNLA)
C***DESCRIPTION
C
C ISORT sorts array IX and optionally makes the same interchanges in
C array IY. The array IX may be sorted in increasing order or
C decreasing order. A slightly modified quicksort algorithm is used.
C
C Description of Parameters
C IX - integer array of values to be sorted
C IY - integer array to be (optionally) carried along
C N - number of values in integer array IX to be sorted
C KFLAG - control parameter
C = 2 means sort IX in increasing order and carry IY along.
C = 1 means sort IX in increasing order (ignoring IY)
C = -1 means sort IX in decreasing order (ignoring IY)
C = -2 means sort IX in decreasing order and carry IY along.
C
C***REFERENCES R. C. Singleton, Algorithm 347, An efficient algorithm
C for sorting with minimal storage, Communications of
C the ACM, 12, 3 (1969), pp. 185-187.
C***ROUTINES CALLED XERMSG
C***REVISION HISTORY (YYMMDD)
C 761118 DATE WRITTEN
C 810801 Modified by David K. Kahaner.
C 890531 Changed all specific intrinsics to generic. (WRB)
C 890831 Modified array declarations. (WRB)
C 891009 Removed unreferenced statement labels. (WRB)
C 891009 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
C 901012 Declared all variables; changed X,Y to IX,IY. (M. McClain)
C 920501 Reformatted the REFERENCES section. (DWL, WRB)
C 920519 Clarified error messages. (DWL)
C 920801 Declarations section rebuilt and code restructured to use
C IF-THEN-ELSE-ENDIF. (RWC, WRB)
! 100411 changed the dimension of IL and IU from 21 to 31.
!
! field IL and IU have the dimension 31. This is log2 of the largest
! array size to be sorted. If arrays larger than 2**31 in length have
! to be sorted, this dimension has to be modified accordingly
!
C***END PROLOGUE ISORT
!
implicit none
C .. Scalar Arguments ..
integer kflag, n
C .. Array Arguments ..
integer ix(*)
real*8 dy(*)
integer iy(*)
C .. Local Scalars ..
real r
integer i, ij, j, k, kk, l, m, nn, t, tt
real*8 tty,ty
integer uuy,uy
C .. Local Arrays ..
integer il(31), iu(31)
C .. External Subroutines ..
! EXTERNAL XERMSG
C .. Intrinsic Functions ..
intrinsic abs, int
C***FIRST EXECUTABLE STATEMENT ISORT
nn = n
if (nn .lt. 1) then
! CALL XERMSG ('SLATEC', 'ISORT',
! + 'The number of values to be sorted is not positive.', 1, 1)
return
endif
C
kk = abs(kflag)
if (kk.ne.1 .and. kk.ne.2) then
! CALL XERMSG ('SLATEC', 'ISORT',
! + 'The sort control parameter, K, is not 2, 1, -1, or -2.', 2,
! + 1)
return
endif
C
C Alter array IX to get decreasing order if needed
C
if (kflag .le. -1) then
do 10 i=1,nn
ix(i) = -ix(i)
10 continue
endif
C
if (kk .eq. 2) go to 100
C
C Sort IX only
C
m = 1
i = 1
j = nn
r = 0.375e0
C
20 if (i .eq. j) go to 60
if (r .le. 0.5898437e0) then
r = r+3.90625e-2
else
r = r-0.21875e0
endif
C
30 k = i
C
C Select a central element of the array and save it in location T
C
ij = i + int((j-i)*r)
t = ix(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
endif
l = j
C
C If last element of array is less than than T, interchange with T
C
if (ix(j) .lt. t) then
ix(ij) = ix(j)
ix(j) = t
t = ix(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
endif
endif
C
C Find an element in the second half of the array which is smaller
C than T
C
40 l = l-1
if (ix(l) .gt. t) go to 40
C
C Find an element in the first half of the array which is greater
C than T
C
50 k = k+1
if (ix(k) .lt. t) go to 50
C
C Interchange these elements
C
if (k .le. l) then
tt = ix(l)
ix(l) = ix(k)
ix(k) = tt
go to 40
endif
C
C Save upper and lower subscripts of the array yet to be sorted
C
if (l-i .gt. j-k) then
il(m) = i
iu(m) = l
i = k
m = m+1
else
il(m) = k
iu(m) = j
j = l
m = m+1
endif
go to 70
C
C Begin again on another portion of the unsorted array
C
60 m = m-1
if (m .eq. 0) go to 190
i = il(m)
j = iu(m)
C
70 if (j-i .ge. 1) go to 30
if (i .eq. 1) go to 20
i = i-1
C
80 i = i+1
if (i .eq. j) go to 60
t = ix(i+1)
if (ix(i) .le. t) go to 80
k = i
C
90 ix(k+1) = ix(k)
k = k-1
if (t .lt. ix(k)) go to 90
ix(k+1) = t
go to 80
C
C Sort IX and carry IY along
C
100 m = 1
i = 1
j = nn
r = 0.375e0
C
110 if (i .eq. j) go to 150
if (r .le. 0.5898437e0) then
r = r+3.90625e-2
else
r = r-0.21875e0
endif
C
120 k = i
C
C Select a central element of the array and save it in location T
C
ij = i + int((j-i)*r)
t = ix(ij)
ty = dy(ij)
uy = iy(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
dy(ij) = dy(i)
iy(ij) = iy(i)
dy(i) = ty
iy(i) = uy
ty = dy(ij)
uy = iy(ij)
endif
l = j
C
C If last element of array is less than T, interchange with T
C
if (ix(j) .lt. t) then
ix(ij) = ix(j)
ix(j) = t
t = ix(ij)
dy(ij) = dy(j)
iy(ij) = iy(j)
dy(j) = ty
iy(j) = uy
ty = dy(ij)
uy = iy(ij)
C
C If first element of array is greater than T, interchange with T
C
if (ix(i) .gt. t) then
ix(ij) = ix(i)
ix(i) = t
t = ix(ij)
dy(ij) = dy(i)
iy(ij) = iy(i)
dy(i) = ty
iy(i) = uy
ty = dy(ij)
uy = iy(ij)
endif
endif
C
C Find an element in the second half of the array which is smaller
C than T
C
130 l = l-1
if (ix(l) .gt. t) go to 130
C
C Find an element in the first half of the array which is greater
C than T
C
140 k = k+1
if (ix(k) .lt. t) go to 140
C
C Interchange these elements
C
if (k .le. l) then
tt = ix(l)
ix(l) = ix(k)
ix(k) = tt
tty = dy(l)
uuy = iy(l)
dy(l) = dy(k)
iy(l) = iy(k)
dy(k) = tty
iy(k) = uuy
go to 130
endif
C
C Save upper and lower subscripts of the array yet to be sorted
C
if (l-i .gt. j-k) then
il(m) = i
iu(m) = l
i = k
m = m+1
else
il(m) = k
iu(m) = j
j = l
m = m+1
endif
go to 160
C
C Begin again on another portion of the unsorted array
C
150 m = m-1
if (m .eq. 0) go to 190
i = il(m)
j = iu(m)
C
160 if (j-i .ge. 1) go to 120
if (i .eq. 1) go to 110
i = i-1
C
170 i = i+1
if (i .eq. j) go to 150
t = ix(i+1)
ty = dy(i+1)
uy = iy(i+1)
if (ix(i) .le. t) go to 170
k = i
C
180 ix(k+1) = ix(k)
dy(k+1) = dy(k)
iy(k+1) = iy(k)
k = k-1
if (t .lt. ix(k)) go to 180
ix(k+1) = t
dy(k+1) = ty
iy(k+1) = uy
go to 170
C
C Clean up
C
190 if (kflag .le. -1) then
do 200 i=1,nn
ix(i) = -ix(i)
200 continue
endif
return
end
| gpl-2.0 |
techno/gcc-mist32 | libgfortran/generated/_log_r8.F90 | 47 | 1467 | ! Copyright (C) 2002-2015 Free Software Foundation, Inc.
! Contributed by Paul Brook <paul@nowt.org>
!
!This file is part of the GNU Fortran 95 runtime library (libgfortran).
!
!GNU libgfortran 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 3 of the License, or (at your option) any later version.
!GNU libgfortran 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.
!
!Under Section 7 of GPL version 3, you are granted additional
!permissions described in the GCC Runtime Library Exception, version
!3.1, as published by the Free Software Foundation.
!
!You should have received a copy of the GNU General Public License and
!a copy of the GCC Runtime Library Exception along with this program;
!see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
!<http://www.gnu.org/licenses/>.
!
!This file is machine generated.
#include "config.h"
#include "kinds.inc"
#include "c99_protos.inc"
#if defined (HAVE_GFC_REAL_8)
#ifdef HAVE_LOG
elemental function _gfortran_specific__log_r8 (parm)
real (kind=8), intent (in) :: parm
real (kind=8) :: _gfortran_specific__log_r8
_gfortran_specific__log_r8 = log (parm)
end function
#endif
#endif
| gpl-2.0 |
techno/gcc-mist32 | gcc/testsuite/gfortran.dg/equiv_7.f90 | 174 | 3659 | ! { dg-do run }
! { dg-options "-std=gnu" }
! Tests the fix for PR29786, in which initialization of overlapping
! equivalence elements caused a compile error.
!
! Contributed by Bernhard Fischer <aldot@gcc.gnu.org>
!
block data
common /global/ ca (4)
integer(4) ca, cb
equivalence (cb, ca(3))
data (ca(i), i = 1, 2) /42,43/, ca(4) /44/
data cb /99/
end block data
integer(4), parameter :: abcd = ichar ("a") + 256_4 * (ichar("b") + 256_4 * &
(ichar ("c") + 256_4 * ichar ("d")))
logical(4), parameter :: bigendian = transfer (abcd, "wxyz") .eq. "abcd"
call int4_int4
call real4_real4
call complex_real
call check_block_data
call derived_types ! Thanks to Tobias Burnus for this:)
!
! This came up in PR29786 comment #9 - Note the need to treat endianess
! Thanks Dominique d'Humieres:)
!
if (bigendian) then
if (d1mach_little (1) .ne. transfer ((/0_4, 1048576_4/), 1d0)) call abort ()
if (d1mach_little (2) .ne. transfer ((/-1_4,2146435071_4/), 1d0)) call abort ()
else
if (d1mach_big (1) .ne. transfer ((/1048576_4, 0_4/), 1d0)) call abort ()
if (d1mach_big (2) .ne. transfer ((/2146435071_4,-1_4/), 1d0)) call abort ()
end if
!
contains
subroutine int4_int4
integer(4) a(4)
integer(4) b
equivalence (b,a(3))
data b/3/
data (a(i), i=1,2) /1,2/, a(4) /4/
if (any (a .ne. (/1, 2, 3, 4/))) call abort ()
end subroutine int4_int4
subroutine real4_real4
real(4) a(4)
real(4) b
equivalence (b,a(3))
data b/3.0_4/
data (a(i), i=1,2) /1.0_4, 2.0_4/, &
a(4) /4.0_4/
if (sum (abs (a - &
(/1.0_4, 2.0_4, 3.0_4, 4.0_4/))) > 1.0e-6) call abort ()
end subroutine real4_real4
subroutine complex_real
complex(4) a(4)
real(4) b(2)
equivalence (b,a(3))
data b(1)/3.0_4/, b(2)/4.0_4/
data (a(i), i=1,2) /(0.0_4, 1.0_4),(2.0_4,0.0_4)/, &
a(4) /(0.0_4,5.0_4)/
if (sum (abs (a - (/(0.0_4, 1.0_4),(2.0_4, 0.0_4), &
(3.0_4, 4.0_4),(0.0_4, 5.0_4)/))) > 1.0e-6) call abort ()
end subroutine complex_real
subroutine check_block_data
common /global/ ca (4)
equivalence (ca(3), cb)
integer(4) ca
if (any (ca .ne. (/42, 43, 99, 44/))) call abort ()
end subroutine check_block_data
function d1mach_little(i) result(d1mach)
implicit none
double precision d1mach,dmach(5)
integer i
integer*4 large(4),small(4)
equivalence ( dmach(1), small(1) )
equivalence ( dmach(2), large(1) )
data small(1),small(2) / 0, 1048576/
data large(1),large(2) /-1,2146435071/
d1mach = dmach(i)
end function d1mach_little
function d1mach_big(i) result(d1mach)
implicit none
double precision d1mach,dmach(5)
integer i
integer*4 large(4),small(4)
equivalence ( dmach(1), small(1) )
equivalence ( dmach(2), large(1) )
data small(1),small(2) /1048576, 0/
data large(1),large(2) /2146435071,-1/
d1mach = dmach(i)
end function d1mach_big
subroutine derived_types
TYPE T1
sequence
character (3) :: chr
integer :: i = 1
integer :: j
END TYPE T1
TYPE T2
sequence
character (3) :: chr = "wxy"
integer :: i = 1
integer :: j = 4
END TYPE T2
TYPE(T1) :: a1
TYPE(T2) :: a2
EQUIVALENCE(a1,a2) ! { dg-warning="mixed|components" }
if (a1%chr .ne. "wxy") call abort ()
if (a1%i .ne. 1) call abort ()
if (a1%j .ne. 4) call abort ()
end subroutine derived_types
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/uncouptempdisps.f | 2 | 7283 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 uncouptempdisps(inpc,textpart,
& nmethod,iperturb,isolver,
& istep,istat,n,tinc,tper,tmin,tmax,idrct,ithermal,iline,ipol,
& inl,ipoinp,inp,ipoinpc,alpha,ctrl,ttime,nener)
!
! reading the input deck: *UNCOUPLED TEMPERATURE-DISPLACEMENT
!
! isolver=0: SPOOLES
! 2: iterative solver with diagonal scaling
! 3: iterative solver with Cholesky preconditioning
! 4: sgi solver
! 5: TAUCS
! 7: pardiso
!
implicit none
!
logical timereset
!
character*1 inpc(*)
character*20 solver
character*132 textpart(16)
!
integer nmethod,iperturb,isolver,istep,istat,n,key,i,idrct,
& ithermal,iline,ipol,inl,ipoinp(2,*),inp(3,*),ipoinpc(0:*),
& nener
!
real*8 tinc,tper,tmin,tmax,alpha,ctrl(*),ttime
!
idrct=0
alpha=-0.05d0
tmin=0.d0
tmax=0.d0
nmethod=4
timereset=.false.
!
if(iperturb.eq.0) then
iperturb=2
elseif((iperturb.eq.1).and.(istep.gt.1)) then
write(*,*) '*ERROR in couptempdisps: perturbation analysis is'
write(*,*) ' not provided in a *HEAT TRANSFER step.'
call exit(201)
endif
!
if(istep.lt.1) then
write(*,*) '*ERROR in couptempdisps: *HEAT TRANSFER can only '
write(*,*) ' be used within a STEP'
call exit(201)
endif
!
! default solver
!
solver=' '
if(isolver.eq.0) then
solver(1:7)='SPOOLES'
elseif(isolver.eq.2) then
solver(1:16)='ITERATIVESCALING'
elseif(isolver.eq.3) then
solver(1:17)='ITERATIVECHOLESKY'
elseif(isolver.eq.4) then
solver(1:3)='SGI'
elseif(isolver.eq.5) then
solver(1:5)='TAUCS'
elseif(isolver.eq.7) then
solver(1:7)='PARDISO'
endif
!
do i=2,n
if(textpart(i)(1:6).eq.'ALPHA=') then
read(textpart(i)(7:26),'(f20.0)',iostat=istat) alpha
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*UNCOUPLED TEMPERATURE-DISPLACEMENT%")
if(alpha.lt.-1.d0/3.d0) then
write(*,*) '*WARNING in dynamics: alpha is smaller'
write(*,*) ' than -1/3 and is reset to -1/3'
alpha=-1.d0/3.d0
elseif(alpha.gt.0.d0) then
write(*,*) '*WARNING in dynamics: alpha is greater'
write(*,*) ' than 0 and is reset to 0'
alpha=0.d0
endif
elseif(textpart(i)(1:7).eq.'SOLVER=') then
read(textpart(i)(8:27),'(a20)') solver
elseif((textpart(i)(1:6).eq.'DIRECT').and.
& (textpart(i)(1:9).ne.'DIRECT=NO')) then
idrct=1
elseif(textpart(i)(1:11).eq.'STEADYSTATE') then
nmethod=1
elseif(textpart(i)(1:7).eq.'DELTMX=') then
read(textpart(i)(8:27),'(f20.0)',iostat=istat) ctrl(27)
elseif(textpart(i)(1:9).eq.'TIMERESET') then
timereset=.true.
elseif(textpart(i)(1:17).eq.'TOTALTIMEATSTART=') then
read(textpart(i)(18:37),'(f20.0)',iostat=istat) ttime
else
write(*,*)
& '*WARNING in uncouptempdisps: parameter not recognized:'
write(*,*) ' ',
& textpart(i)(1:index(textpart(i),' ')-1)
call inputwarning(inpc,ipoinpc,iline,
&"*UNCOUPLED TEMPERATURE-DISPLACEMENT%")
endif
enddo
if(nmethod.eq.1) ctrl(27)=1.d30
!
if((ithermal.eq.0).and.(nmethod.ne.1).and.
& (nmethod.ne.2).and.(iperturb.ne.0)) then
write(*,*) '*ERROR in couptempdisps: please define initial '
write(*,*) ' conditions for the temperature'
call exit(201)
else
ithermal=4
endif
!
if(solver(1:7).eq.'SPOOLES') then
isolver=0
elseif(solver(1:16).eq.'ITERATIVESCALING') then
isolver=2
elseif(solver(1:17).eq.'ITERATIVECHOLESKY') then
isolver=3
elseif(solver(1:3).eq.'SGI') then
isolver=4
elseif(solver(1:5).eq.'TAUCS') then
isolver=5
elseif(solver(1:7).eq.'PARDISO') then
isolver=7
else
write(*,*) '*WARNING in couptempdisps: unknown solver;'
write(*,*) ' the default solver is used'
endif
!
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
if((istat.lt.0).or.(key.eq.1)) then
if(iperturb.ge.2) then
write(*,*) '*WARNING in couptempdisps: a nonlinear analysis
&is requested'
write(*,*) ' but no time increment nor step is speci
&fied'
write(*,*) ' the defaults (1,1) are used'
tinc=1.d0
tper=1.d0
tmin=1.d-5
tmax=1.d+30
endif
if(timereset)ttime=ttime-tper
if(nmethod.eq.4) nener=1
return
endif
!
read(textpart(1)(1:20),'(f20.0)',iostat=istat) tinc
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*UNCOUPLED TEMPERATURE-DISPLACEMENT%")
read(textpart(2)(1:20),'(f20.0)',iostat=istat) tper
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*UNCOUPLED TEMPERATURE-DISPLACEMENT%")
read(textpart(3)(1:20),'(f20.0)',iostat=istat) tmin
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*UNCOUPLED TEMPERATURE-DISPLACEMENT%")
read(textpart(4)(1:20),'(f20.0)',iostat=istat) tmax
if(istat.gt.0) call inputerror(inpc,ipoinpc,iline,
&"*UNCOUPLED TEMPERATURE-DISPLACEMENT%")
!
if(tinc.le.0.d0) then
write(*,*) '*ERROR in couptempdisps: initial increment size is
&negative'
endif
if(tper.le.0.d0) then
write(*,*) '*ERROR in couptempdisps: step size is negative'
endif
if(tinc.gt.tper) then
write(*,*) '*ERROR in couptempdisps: initial increment size exc
&eeds step size'
endif
!
if(idrct.ne.1) then
c if(dabs(tmin).lt.1.d-10) then
c tmin=min(tinc,1.d-5*tper)
if(dabs(tmin).lt.1.d-6*tper) then
tmin=min(tinc,1.d-6*tper)
endif
if(dabs(tmax).lt.1.d-10) then
tmax=1.d+30
endif
endif
!
if(timereset)ttime=ttime-tper
!
if(nmethod.eq.4) nener=1
!
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.9/src/resultsprint.f | 1 | 15189 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 resultsprint(co,nk,kon,ipkon,lakon,ne,v,stn,inum,
& stx,ielorien,norien,orab,t1,ithermal,filab,een,iperturb,fn,
& nactdof,iout,vold,nodeboun,ndirboun,nboun,nmethod,ttime,xstate,
& epn,mi,nstate_,ener,enern,xstaten,eei,set,nset,istartset,
& iendset,ialset,nprint,prlab,prset,qfx,qfn,trab,inotr,ntrans,
& nelemload,nload,ikin,ielmat,thicke,eme,emn,rhcon,nrhcon,shcon,
& nshcon,cocon,ncocon,ntmat_,sideload,icfd,inomat,pslavsurf,
& islavact,cdn,mortar,islavnode,nslavnode,ntie,islavsurf,time,
& ielprop,prop,veold,ne0,nmpc,ipompc,nodempc,labmpc,energyini,
& energy)
!
! - stores the results in the .dat file, if requested
! - nodal quantities at the nodes
! - element quantities at the integration points
! - calculates the extrapolation of element quantities to
! the nodes (if requested for .frd output)
! - calculates 1d/2d results for 1d/2d elements by
! interpolation
!
implicit none
!
logical force,rfprint
!
character*1 cflag
character*6 prlab(*)
character*8 lakon(*)
character*20 sideload(*),labmpc(*)
character*81 set(*),prset(*)
character*87 filab(*)
!
integer kon(*),inum(*),iperm(20),mi(*),ielorien(mi(3),*),
& ipkon(*),icfdout,nactdof(0:mi(2),*),nodeboun(*),icompressible,
& nelemload(2,*),ndirboun(*),ielmat(mi(3),*),nrhcon(*),
& inotr(2,*),iorienloc,iflag,nload,mt,nk,ne,ithermal(2),i,
& norien,iperturb(*),iout,nboun,nmethod,node,nshcon(*),
& nfield,ndim,nstate_,nset,istartset(*),iendset(*),ialset(*),
& nprint,ntrans,ikin,ncocon(2,*),ntmat_,icfd,inomat(*),mortar,
& islavact(*),islavnode(*),nslavnode(*),ntie,islavsurf(2,*),
& ielprop(*),ne0,index,nmpc,ipompc(*),nodempc(3,*)
!
real*8 co(3,*),v(0:mi(2),*),stx(6,mi(1),*),stn(6,*),cdn(6,*),
& qfx(3,mi(1),*),qfn(3,*),orab(7,*),fn(0:mi(2),*),pslavsurf(3,*),
& t1(*),een(6,*),vold(0:mi(2),*),epn(*),thicke(mi(3),*),time,
& ener(mi(1),*),enern(*),eei(6,mi(1),*),rhcon(0:1,ntmat_,*),
& ttime,xstate(nstate_,mi(1),*),trab(7,*),xstaten(nstate_,*),
& eme(6,mi(1),*),emn(6,*),shcon(0:3,ntmat_,*),cocon(0:6,ntmat_,*),
& prop(*),veold(0:mi(2),*),energy(*),energyini(*)
!
data iflag /3/
data iperm /5,6,7,8,1,2,3,4,13,14,15,16,9,10,11,12,17,18,19,20/
!
mt=mi(2)+1
!
! no print requests
!
if(iout.le.0) then
!
! 2d basic dof results (displacements, temperature) are
! calculated in each iteration, so that they are available
! in the user subroutines
!
if(filab(1)(5:5).ne.' ') then
nfield=mt
call map3dto1d2d_v(v,ipkon,inum,kon,lakon,nfield,nk,
& ne,nactdof)
endif
!
! the total energy should not be calculated:
! - for non-dynamical calculations (nmethod!=4)
! - for modal dynamics (iperturb(1)<=1)
! - for thermal and thermomechanical calculations (ithermal(1)>1)
! - for electromagnetic calculations (mi(2)=5)
!
if((nmethod.eq.4).and.(iperturb(1).gt.1).and.
& (ithermal(1).le.1).and.(mi(2).ne.5)) then
call calcenergy(ipkon,lakon,kon,co,ener,mi,ne,thicke,
& ielmat,energyini,energy)
endif
!
return
endif
!
! output in dat file (with *NODE PRINT or *EL PRINT)
!
call printout(set,nset,istartset,iendset,ialset,nprint,
& prlab,prset,v,t1,fn,ipkon,lakon,stx,eei,xstate,ener,
& mi(1),nstate_,ithermal,co,kon,qfx,ttime,trab,inotr,ntrans,
& orab,ielorien,norien,nk,ne,inum,filab,vold,ikin,ielmat,thicke,
& eme,islavsurf,mortar,time,ielprop,prop,veold)
!
icompressible=0
call printoutface(co,rhcon,nrhcon,ntmat_,vold,shcon,nshcon,
& cocon,ncocon,icompressible,istartset,iendset,ipkon,lakon,kon,
& ialset,prset,ttime,nset,set,nprint,prlab,ielmat,mi,time)
!
! interpolation in the original nodes of 1d and 2d elements
! this operation has to be performed in any case since
! the interpolated values may be needed as boundary conditions
! in the next step (e.g. the temperature in a heat transfer
! calculation as boundary condition in a subsequent static
! step)
!
if(filab(1)(5:5).ne.' ') then
nfield=mt
cflag=filab(1)(5:5)
force=.false.
call map3dto1d2d(v,ipkon,inum,kon,lakon,nfield,nk,
& ne,cflag,co,vold,force,mi)
endif
!
if((filab(2)(1:4).eq.'NT ').and.(ithermal(1).le.1)) then
if(filab(2)(5:5).eq.'I') then
nfield=1
cflag=filab(2)(5:5)
force=.false.
call map3dto1d2d(t1,ipkon,inum,kon,lakon,nfield,nk,
& ne,cflag,co,vold,force,mi)
endif
endif
!
! check whether forces are requested in the frd-file. If so, but
! none are requested in the .dat file, and output=2d,
! map3dto1d2d has to be called
!
if(filab(5)(1:2).eq.'RF') then
if(filab(5)(5:5).eq.'I') then
rfprint=.false.
do i=1,nprint
if(prlab(i)(1:2).eq.'RF') then
rfprint=.true.
exit
endif
enddo
if(.not.rfprint) then
nfield=mt
cflag=' '
force=.true.
call map3dto1d2d(fn,ipkon,inum,kon,lakon,nfield,nk,
& ne,cflag,co,vold,force,mi)
endif
endif
endif
!
! in this routine no 3d-fluid results are stored
!
icfdout=0
!
! for composites:
! interpolation of the displacements and temperatures
! from the expanded nodes to the layer nodes
!
if(mi(3).gt.1) then
if((filab(1)(1:3).eq.'U ').or.
& ((filab(2)(1:4).eq.'NT ').and.(ithermal(1).gt.1))) then
nfield=mt
call map3dtolayer(v,ipkon,kon,lakon,nfield,
& ne,co,ielmat,mi)
endif
if((filab(2)(1:4).eq.'NT ').and.(ithermal(1).le.1)) then
nfield=1
call map3dtolayer(t1,ipkon,kon,lakon,nfield,
& ne,co,ielmat,mi)
endif
endif
!
! determining the contact differential displacements and stresses
! in the contact nodes for output in frd format (only for face-
! to-face penalty; for node-to-face penalty these quantities are
! determined in the slave nodes and no extrapolation is necessary)
!
! This block must precede all calls to extrapolate, since the
! field inum from extrapolatecontact.f is not correct; by a
! subsequent call to extrapolate inum is corrected.
!
if((filab(26)(1:4).eq.'CONT').or.(filab(46)(1:4).eq.'PCON')) then
if(mortar.eq.1) then
nfield=6
ndim=6
cflag=filab(3)(5:5)
force=.false.
call extrapolatecontact(stx,cdn,ipkon,inum,kon,lakon,nfield,
& nk,ne,mi(1),ndim,co,cflag,vold,force,pslavsurf,
& islavact,islavnode,nslavnode,ntie,islavsurf,ielprop,prop,
& ielmat,ne0)
endif
endif
!
! determining the stresses in the nodes for output in frd format
!
if((filab(3)(1:4).eq.'S ').or.(filab(18)(1:4).eq.'PHS ').or.
& (filab(20)(1:4).eq.'MAXS').or.
& (((filab(44)(1:4).eq.'EMFE').or.(filab(45)(1:4).eq.'EMFB'))
& .and.(ithermal(1).ne.2))) then
nfield=6
ndim=6
if((norien.gt.0).and.(filab(3)(6:6).eq.'L')) then
iorienloc=1
else
iorienloc=0
endif
cflag=filab(3)(5:5)
force=.false.
!
call extrapolate(stx,stn,ipkon,inum,kon,lakon,nfield,nk,
& ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
& vold,force,ielmat,thicke,ielprop,prop)
!
endif
!
! determining the total strains in the nodes for output in frd format
!
if((filab(4)(1:4).eq.'E ').or.(filab(30)(1:4).eq.'MAXE')) then
nfield=6
ndim=6
if((norien.gt.0).and.(filab(4)(6:6).eq.'L')) then
iorienloc=1
else
iorienloc=0
endif
cflag=filab(4)(5:5)
force=.false.
call extrapolate(eei,een,ipkon,inum,kon,lakon,nfield,nk,
& ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
& vold,force,ielmat,thicke,ielprop,prop)
endif
!
! determining the mechanical strains in the nodes for output in
! frd format
!
if(filab(32)(1:4).eq.'ME ') then
nfield=6
ndim=6
if((norien.gt.0).and.(filab(4)(6:6).eq.'L')) then
iorienloc=1
else
iorienloc=0
endif
cflag=filab(4)(5:5)
force=.false.
call extrapolate(eme,emn,ipkon,inum,kon,lakon,nfield,nk,
& ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
& vold,force,ielmat,thicke,ielprop,prop)
endif
!
! determining the plastic equivalent strain in the nodes
! for output in frd format
!
if(filab(6)(1:4).eq.'PEEQ') then
nfield=1
ndim=nstate_
iorienloc=0
cflag=filab(6)(5:5)
force=.false.
call extrapolate(xstate,epn,ipkon,inum,kon,lakon,nfield,nk,
& ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
& vold,force,ielmat,thicke,ielprop,prop)
endif
!
! determining the total energy in the nodes
! for output in frd format
!
if(filab(7)(1:4).eq.'ENER') then
nfield=1
ndim=1
iorienloc=0
cflag=filab(7)(5:5)
force=.false.
call extrapolate(ener,enern,ipkon,inum,kon,lakon,nfield,nk,
& ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
& vold,force,ielmat,thicke,ielprop,prop)
endif
!
! determining the internal state variables in the nodes
! for output in frd format
!
if(filab(8)(1:4).eq.'SDV ') then
nfield=nstate_
ndim=nstate_
if((norien.gt.0).and.(filab(9)(6:6).eq.'L')) then
write(*,*) '*WARNING in results: SDV variables cannot'
write(*,*) ' be stored in a local frame;'
write(*,*) ' the global frame will be used'
endif
iorienloc=0
cflag=filab(8)(5:5)
force=.false.
call extrapolate(xstate,xstaten,ipkon,inum,kon,lakon,nfield,nk,
& ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
& vold,force,ielmat,thicke,ielprop,prop)
endif
!
! determining the heat flux in the nodes for output in frd format
!
if(((filab(9)(1:4).eq.'HFL ').and.(ithermal(1).gt.1)).or.
& ((filab(42)(1:3).eq.'ECD').and.(ithermal(1).eq.2))) then
nfield=3
ndim=3
if((norien.gt.0).and.(filab(9)(6:6).eq.'L')) then
iorienloc=1
else
iorienloc=0
endif
cflag=filab(9)(5:5)
force=.false.
call extrapolate(qfx,qfn,ipkon,inum,kon,lakon,nfield,nk,
& ne,mi(1),ndim,orab,ielorien,co,iorienloc,cflag,
& vold,force,ielmat,thicke,ielprop,prop)
endif
!
! if no element quantities requested in the nodes: calculate
! inum if nodal quantities are requested: used in subroutine frd
! to determine which nodes are active in the model
!
if((filab(3)(1:4).ne.'S ').and.(filab(4)(1:4).ne.'E ').and.
& (filab(6)(1:4).ne.'PEEQ').and.(filab(7)(1:4).ne.'ENER').and.
& (filab(8)(1:4).ne.'SDV ').and.(filab(9)(1:4).ne.'HFL ').and.
& (filab(42)(1:3).ne.'ECD').and.(filab(32)(1:4).ne.'ME ').and.
& ((nmethod.ne.4).or.(iperturb(1).ge.2))) then
!
nfield=0
ndim=0
iorienloc=0
cflag=filab(1)(5:5)
call createinum(ipkon,inum,kon,lakon,nk,ne,cflag,nelemload,
& nload,nodeboun,nboun,ndirboun,ithermal,co,vold,mi,ielmat)
endif
!
c if(ithermal(1).gt.1) then
if(ithermal(2).gt.1) then
!
! next section is executed if at least one step is thermal
! or thermomechanical
!
! extrapolation for the network
! -interpolation for the total pressure and temperature
! in the middle nodes
! -extrapolation for the mass flow in the end nodes
!
call networkextrapolate(v,ipkon,inum,kon,lakon,ne,mi)
!
! printing values for environmental film and
! pressure nodes (these nodes are considered to be network
! nodes)
!
do i=1,nload
if((sideload(i)(3:4).ne.'FC').and.
& (sideload(i)(3:4).ne.'NP')) cycle
node=nelemload(2,i)
if(icfd.eq.1) then
if(node.gt.0) then
if(inomat(node).ne.0) cycle
endif
endif
if((node.gt.0).and.(sideload(i)(1:1).ne.' ')) then
if(inum(node).lt.0) cycle
inum(node)=-1
endif
enddo
!
! printing values radiation
! (these nodes are considered to be network nodes, unless
! they were already assigned to the structure)
!
do i=1,nload
if((sideload(i)(3:4).ne.'CR')) cycle
node=nelemload(2,i)
if(icfd.eq.1) then
if(node.gt.0) then
if(inomat(node).ne.0) cycle
endif
endif
if((node.gt.0).and.(sideload(i)(1:1).ne.' ')) then
if(inum(node).ne.0) cycle
inum(node)=-1
endif
enddo
!
! printing values for nodes belonging to network MPC's
! (these nodes are considered to be network nodes)
!
do i=1,nmpc
if(labmpc(i)(1:7).eq.'NETWORK') then
index=ipompc(i)
do
node=nodempc(1,index)
if(inum(node).ge.0) inum(node)=-1
index=nodempc(3,index)
if(index.eq.0) exit
enddo
endif
enddo
!
! printing values of prescribed boundary conditions (these
! nodes are considered to be network nodes)
!
do i=1,nboun
node=nodeboun(i)
if(inum(node).ne.0) cycle
if(icfd.eq.1) then
if(inomat(node).ne.0) cycle
endif
if((cflag.ne.' ').and.(ndirboun(i).eq.3)) cycle
inum(node)=-1
enddo
endif
!
return
end
| gpl-2.0 |
techno/gcc-mist32 | gcc/testsuite/gfortran.dg/namelist_22.f90 | 166 | 1390 | !{ dg-do run { target fd_truncate } }
!{ dg-options "-std=legacy" }
!
! Tests filling arrays from a namelist read when object list is not complete.
! This is the same as namelist_21.f90 except using spaces as seperators instead
! of commas. Developed from a test case provided by Christoph Jacob.
! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org>.
program pr24794
implicit none
integer, parameter :: maxop=15, iunit=7
character*8 namea(maxop), nameb(maxop)
integer i, ier
namelist/ccsopr/ namea,nameb
namea=""
nameb=""
open (12, status="scratch", delim="apostrophe")
write (12, '(a)') "&ccsopr"
write (12, '(a)') " namea='spi01h' 'spi02o' 'spi03h' 'spi04o' 'spi05h'"
write (12, '(a)') " 'spi07o' 'spi08h' 'spi09h'"
write (12, '(a)') " nameb='spi01h' 'spi03h' 'spi05h' 'spi06h' 'spi08h'"
write (12, '(a)') "&end"
rewind (12)
read (12, nml=ccsopr, iostat=ier)
if (ier.ne.0) call abort()
rewind (12)
write(12,nml=ccsopr)
rewind (12)
read (12, nml=ccsopr, iostat=ier)
if (ier.ne.0) call abort()
if (namea(2).ne."spi02o ") call abort()
if (namea(9).ne." ") call abort()
if (namea(15).ne." ") call abort()
if (nameb(1).ne."spi01h ") call abort()
if (nameb(6).ne." ") call abort()
if (nameb(15).ne." ") call abort()
close (12)
end program pr24794
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/addimdnodedof.f | 2 | 2588 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 addimdnodedof(node,k,ikmpc,ilmpc,ipompc,
& nodempc,nmpc,imdnode,nmdnode,imddof,nmddof,nactdof,mi,
& imdmpc,nmdmpc,imdboun,nmdboun,ikboun,nboun,ilboun)
!
! node was kept by the user in a modal dynamics calculation;
! the present routine checks DOF k of node; if this DOF belongs
! to a MPC all independent nodes and DOF's of the MPC have to be kept
!
implicit none
!
integer node,k,idof,ikmpc(*),ilmpc(*),ipompc(*),nodempc(3,*),
& nmpc,imdnode(*),nmdnode,imddof(*),nmddof,id,ist,index,jdof,
& mi(*),nactdof(0:mi(2),*),imdmpc(*),nmdmpc,imdboun(*),nmdboun,
& ikboun(*),nboun,ilboun(*)
!
idof=nactdof(k,node)
c write(*,*) 'addimdnodedof ',node,k,idof
if(idof.le.0) then
idof=(node-1)*8+k
!
! checking for mpc's
!
call nident(ikmpc,idof,nmpc,id)
if(id.gt.0) then
if(ikmpc(id).eq.idof) then
call addimd(imdmpc,nmdmpc,ilmpc(id))
id=ilmpc(id)
ist=ipompc(id)
index=nodempc(3,ist)
if(index.ne.0) then
do
call addimd(imdnode,nmdnode,nodempc(1,index))
jdof=nactdof(nodempc(2,index),nodempc(1,index))
if(jdof.gt.0) call addimd(imddof,nmddof,jdof)
index=nodempc(3,index)
if(index.eq.0) exit
enddo
endif
endif
endif
!
! checking for spc's
!
call nident(ikboun,idof,nboun,id)
if(id.gt.0) then
if(ikboun(id).eq.idof) then
call addimd(imdboun,nmdboun,ilboun(id))
endif
endif
else
call addimd(imddof,nmddof,idof)
endif
!
return
end
| gpl-2.0 |
LucHermitte/ITK | Modules/ThirdParty/VNL/src/vxl/v3p/netlib/blas/zgeru.f | 46 | 4266 | SUBROUTINE ZGERU(M,N,ALPHA,X,INCX,Y,INCY,A,LDA)
* .. Scalar Arguments ..
DOUBLE COMPLEX ALPHA
INTEGER INCX,INCY,LDA,M,N
* ..
* .. Array Arguments ..
DOUBLE COMPLEX A(LDA,*),X(*),Y(*)
* ..
*
* Purpose
* =======
*
* ZGERU performs the rank 1 operation
*
* A := alpha*x*y' + A,
*
* where alpha is a scalar, x is an m element vector, y is an n element
* vector and A is an m by n matrix.
*
* Arguments
* ==========
*
* M - INTEGER.
* On entry, M specifies the number of rows of the matrix A.
* M must be at least zero.
* Unchanged on exit.
*
* N - INTEGER.
* On entry, N specifies the number of columns of the matrix A.
* N must be at least zero.
* Unchanged on exit.
*
* ALPHA - COMPLEX*16 .
* On entry, ALPHA specifies the scalar alpha.
* Unchanged on exit.
*
* X - COMPLEX*16 array of dimension at least
* ( 1 + ( m - 1 )*abs( INCX ) ).
* Before entry, the incremented array X must contain the m
* element vector x.
* Unchanged on exit.
*
* INCX - INTEGER.
* On entry, INCX specifies the increment for the elements of
* X. INCX must not be zero.
* Unchanged on exit.
*
* Y - COMPLEX*16 array of dimension at least
* ( 1 + ( n - 1 )*abs( INCY ) ).
* Before entry, the incremented array Y must contain the n
* element vector y.
* Unchanged on exit.
*
* INCY - INTEGER.
* On entry, INCY specifies the increment for the elements of
* Y. INCY must not be zero.
* Unchanged on exit.
*
* A - COMPLEX*16 array of DIMENSION ( LDA, n ).
* Before entry, the leading m by n part of the array A must
* contain the matrix of coefficients. On exit, A is
* overwritten by the updated matrix.
*
* LDA - INTEGER.
* On entry, LDA specifies the first dimension of A as declared
* in the calling (sub) program. LDA must be at least
* max( 1, m ).
* Unchanged on exit.
*
*
* Level 2 Blas routine.
*
* -- Written on 22-October-1986.
* Jack Dongarra, Argonne National Lab.
* Jeremy Du Croz, Nag Central Office.
* Sven Hammarling, Nag Central Office.
* Richard Hanson, Sandia National Labs.
*
*
* .. Parameters ..
DOUBLE COMPLEX ZERO
PARAMETER (ZERO= (0.0D+0,0.0D+0))
* ..
* .. Local Scalars ..
DOUBLE COMPLEX TEMP
INTEGER I,INFO,IX,J,JY,KX
* ..
* .. External Subroutines ..
EXTERNAL XERBLA
* ..
* .. Intrinsic Functions ..
INTRINSIC MAX
* ..
*
* Test the input parameters.
*
INFO = 0
IF (M.LT.0) THEN
INFO = 1
ELSE IF (N.LT.0) THEN
INFO = 2
ELSE IF (INCX.EQ.0) THEN
INFO = 5
ELSE IF (INCY.EQ.0) THEN
INFO = 7
ELSE IF (LDA.LT.MAX(1,M)) THEN
INFO = 9
END IF
IF (INFO.NE.0) THEN
CALL XERBLA('ZGERU ',INFO)
RETURN
END IF
*
* Quick return if possible.
*
IF ((M.EQ.0) .OR. (N.EQ.0) .OR. (ALPHA.EQ.ZERO)) RETURN
*
* Start the operations. In this version the elements of A are
* accessed sequentially with one pass through A.
*
IF (INCY.GT.0) THEN
JY = 1
ELSE
JY = 1 - (N-1)*INCY
END IF
IF (INCX.EQ.1) THEN
DO 20 J = 1,N
IF (Y(JY).NE.ZERO) THEN
TEMP = ALPHA*Y(JY)
DO 10 I = 1,M
A(I,J) = A(I,J) + X(I)*TEMP
10 CONTINUE
END IF
JY = JY + INCY
20 CONTINUE
ELSE
IF (INCX.GT.0) THEN
KX = 1
ELSE
KX = 1 - (M-1)*INCX
END IF
DO 40 J = 1,N
IF (Y(JY).NE.ZERO) THEN
TEMP = ALPHA*Y(JY)
IX = KX
DO 30 I = 1,M
A(I,J) = A(I,J) + X(IX)*TEMP
IX = IX + INCX
30 CONTINUE
END IF
JY = JY + INCY
40 CONTINUE
END IF
*
RETURN
*
* End of ZGERU .
*
END
| apache-2.0 |
prool/ccx_prool | CalculiX/ccx_2.10/src/liquidchannel.f | 4 | 45555 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 liquidchannel(node1,node2,nodem,nelem,lakon,
& nactdog,identity,ielprop,prop,iflag,v,xflow,f,
& nodef,idirf,df,rho,g,co,dvi,numf,mi,ipkon,kon)
!
! open channel for incompressible media
!
! SG: sluice gate
! SO: sluice opening
! WE: weir
! WO: weir opening
! DS: discontinuous slope
! DO: discontinuous slope opening
! : default channel mit linearly varying trapezoid cross
! section
!
implicit none
!
logical identity,bresse,jump
character*8 lakon(*)
!
integer nelem,nactdog(0:3,*),node1,node2,nodem,indexup,i,
& ielprop(*),nodef(4),idirf(4),index,iflag,mi(*),nsol,
& inv,numf,nodesg,nelemdown,nelemup,node0,kon(*),ipkon(*)
!
real*8 prop(*),v(0:mi(2),*),xflow,f,df(4),b,d,c,p,
& h1,h2,rho,dvi,friction,reynolds,dg,b1,b2,
& g(3),dl,xks,z1,z2,co(3,*),xflow2,dyg3dbj,dyg4dbj,
& s0,sqrts0,hk,form_fact,h1ns,h2ns,h0,dyg3deta,dyg4deta,
& dh3dh1,dh4dh2,dh3dm,dh4dm,eta,dA3deta,dA4deta,bj,
& theta,cth,tth,um1,um2,A1,A2,P1,P2,D1,D2,dA1dh1,dA2dh2,
& dP1dh1,dP2dh2,dD1dh1,dD2dh2,h3,h4,dh3deta,xn1,xn2,xt1,xt2,
& dh4deta,yg3,yg4,dyg3dh3,dyg4dh4,A3,A4,dA3dh3,dA4dh4,
& dum1dh1,dum2dh2,c1,c2,dbds,dbjdeta,e0,e1,e2,e3,
& dyg3dm,dyg4dm,dA3dm,dA4dm,dyg3dh1,dyg4dh2,
& dA3dh1,dA4dh2,solreal(3),solimag(3),dist
!
! iflag=0: check whether all parameters in the element equation
! are known => equation is not needed
! iflag=1: calculation of the initial flux
! iflag=2: evaluate the element equation and all derivatives
! iflag=3: correct the channel depth in order to move a jump
!
if (iflag.eq.0) then
identity=.true.
!
if(nactdog(2,node1).ne.0)then
identity=.false.
elseif(nactdog(2,node2).ne.0)then
identity=.false.
elseif(nactdog(1,nodem).ne.0)then
identity=.false.
endif
!
elseif((iflag.eq.1).or.(iflag.eq.2))then
!
index=ielprop(nelem)
!
h1=v(2,node1)
h2=v(2,node2)
!
z1=-g(1)*co(1,node1)-g(2)*co(2,node1)-g(3)*co(3,node1)
z2=-g(1)*co(1,node2)-g(2)*co(2,node2)-g(3)*co(3,node2)
!
dg=dsqrt(g(1)*g(1)+g(2)*g(2)+g(3)*g(3))
!
if(iflag.eq.1) then
!
! in a first call of liquidchannel the flow is determined,
! in a second call the channel depth is calculated
!
if(lakon(nelem)(6:7).eq.'SG') then
!
! sluice gate
!
b=prop(index+1)
s0=prop(index+2)
if(s0.lt.-1.d0) then
s0=dasin((z1-z2)/dl)
endif
sqrts0=dsqrt(1.d0-s0*s0)
theta=0.d0
h2=prop(index+3)
!
if(dabs(xflow).lt.1.d-30) then
!
! determine initial mass flow
!
if(nactdog(2,node1).ne.0) then
!
! upstream level not known
!
xflow=0.d0
else
xflow=2.d0*dg*(rho*b*h2)**2*(h1-h2*sqrts0)
if(xflow.lt.0.d0) then
write(*,*)'*ERROR in liquidchannel: water level'
write(*,*) ' upstream of sluice gate is '
write(*,*) ' smaller than downstream heigh
&t'
call exit(201)
else
xflow=dsqrt(xflow)
endif
endif
else
!
! determine the downstream depth
! and the upstream depth if not defined as BC
!
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
if(h2.gt.hk) then
!
! for initial conditions
!
if(nactdog(2,node1).ne.0) v(2,node1)=3.d0*hk/2.d0
v(2,node2)=hk
else
!
! for initial conditions
!
if(nactdog(2,node1).ne.0) v(2,node1)=
& xflow**2/(2.d0*dg*(rho*b*h2)**2)+h2*sqrts0
v(2,node2)=h2
endif
endif
elseif(lakon(nelem)(6:7).eq.'WE') then
!
! weir
!
b=prop(index+1)
p=prop(index+2)
c=prop(index+3)
sqrts0=1.d0
theta=0.d0
!
if(dabs(xflow).lt.1.d-30) then
!
! determine initial mass flow
!
if(nactdog(2,node1).ne.0) then
!
! upstream level unknown
!
xflow=0.d0
else
if(h1.le.p) then
write(*,*) '*ERROR in liquidchannel'
write(*,*) ' weir height exceeds'
write(*,*) ' upstream level'
call exit(201)
endif
xflow=rho*c*b*(h1-p)**(1.5d0)
endif
else
!
! determine the downstream depth
! and the upstream depth if not defined as BC
!
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
!
! for initial conditions
!
if(nactdog(2,node1).ne.0) v(2,node1)=p+3.d0*hk/2.d0
!
! next value is used for downstream initial values
!
v(2,node2)=hk
endif
!
elseif(lakon(nelem)(6:7).eq.'DS') then
if(dabs(xflow).lt.1.d-30) then
!
! initial mass flow cannot be determined for this
! type of element
!
xflow=0.d0
else
!
! determine the downstream depth
!
b=prop(index+1)
s0=prop(index+2)
if(s0.lt.-1.d0) then
s0=dasin((z1-z2)/dl)
endif
sqrts0=dsqrt(1.d0-s0*s0)
theta=prop(index+4)
!
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
!
! initial condition for fluid depth
! supercritical value
!
v(2,node2)=hk/2.d0
endif
!
endif
else
!
! calculating f and its derivatives
!
bresse=.false.
jump=.false.
!
xflow2=xflow*xflow
!
! element properties
!
if((lakon(nelem)(6:7).eq.'SG').or.
& (lakon(nelem)(6:7).eq.'SO').or.
& (lakon(nelem)(6:7).eq.'WO').or.
& (lakon(nelem)(6:7).eq.'RE').or.
& (lakon(nelem)(6:7).eq.' ').or.
& (lakon(nelem)(6:7).eq.'DS').or.
& (lakon(nelem)(6:7).eq.'DO')) then
b=prop(index+1)
s0=prop(index+2)
if(s0.lt.-1.d0) then
s0=dasin((z1-z2)/dl)
endif
sqrts0=dsqrt(1.d0-s0*s0)
if(lakon(nelem)(6:7).ne.'SG') then
dl=prop(index+3)
theta=prop(index+4)
xks=prop(index+5)
if(dl.le.0.d0) then
dl=dsqrt((co(1,node2)-co(1,node1))**2+
& (co(2,node2)-co(2,node1))**2+
& (co(3,node2)-co(3,node1))**2)
endif
else
theta=0.d0
endif
elseif(lakon(nelem)(6:7).eq.'WE') then
b=prop(index+1)
p=prop(index+2)
c=prop(index+3)
sqrts0=1.d0
theta=0.d0
elseif((lakon(nelem)(6:7).eq.'CO').or.
& (lakon(nelem)(6:7).eq.'EL')) then
b1=prop(index+1)
!
s0=prop(index+2)
if(s0.lt.-1.d0) then
s0=0.d0
endif
sqrts0=dsqrt(1.d0-s0*s0)
!
dl=prop(index+3)
if(dl.le.0.d0) then
dl=dsqrt((co(1,node2)-co(1,node1))**2+
& (co(2,node2)-co(2,node1))**2+
& (co(3,node2)-co(3,node1))**2)
endif
!
b2=prop(index+4)
b=(b1+b2)/2.d0
theta=0.d0
xks=0.d0
elseif((lakon(nelem)(6:7).eq.'ST').or.
& (lakon(nelem)(6:7).eq.'DR')) then
b=prop(index+1)
!
s0=prop(index+2)
if(s0.lt.-1.d0) then
s0=0.d0
endif
sqrts0=dsqrt(1.d0-s0*s0)
!
dl=prop(index+3)
if(dl.le.0.d0) then
dl=dsqrt((co(1,node2)-co(1,node1))**2+
& (co(2,node2)-co(2,node1))**2+
& (co(3,node2)-co(3,node1))**2)
endif
!
d=prop(index+4)
b1=b
b2=b
theta=0.d0
xks=0.d0
endif
!
if(xflow.ge.0.d0) then
inv=1
else
inv=-1
endif
!
! standard element equation: unknowns are the mass flow
! and the depth upstream and downstream
!
numf=3
nodef(1)=node1
nodef(2)=nodem
nodef(3)=node2
idirf(1)=2
idirf(2)=1
idirf(3)=2
!
if(lakon(nelem)(6:7).eq.'SG') then
!
! sluice gate
! 1-SG-2-SO-3
!
! h2 cannot exceed HKmax
!
h2=prop(index+3)
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
if(h2.gt.hk) h2=hk
!
nelemdown=int(prop(index+5))
h3=v(2,kon(ipkon(nelemdown)+3))
call hns(b,theta,rho,dg,sqrts0,xflow,h2,h2ns)
if(h3.lt.h2ns) then
!
! Q=f_SG(h1,h2): sluice gate equation between
! 1 and 2
!
! next line for output only
!
v(2,node2)=h2
c write(30,*) 'SG: sluice gate equation '
c write(30,*)'h1= ',h1,'h2= ',h2,'h3= ',h3,'h2ns= ',h2ns
df(1)=2.d0*dg*(rho*b*h2)**2
df(2)=-2.d0*xflow
f=df(1)*(h1-h2*sqrts0)
df(3)=2.d0*f/h2-df(1)*sqrts0
f=f-xflow2
else
!
! fake equation
!
c write(30,*) 'SG: fake equation '
c write(30,*)'h1= ',h1,'h2= ',h2,'h3= ',h3,'h2ns= ',h2ns
numf=1
nodef(1)=nodem
idirf(1)=3
f=prop(index+4)-0.5d0
df(1)=1.d0
endif
elseif(lakon(nelem)(6:7).eq.'SO') then
!
! sluice opening (element streamdown of sluice gate)
! 0-SG-1-SO-2
!
nelemup=int(prop(index+6))
node0=kon(ipkon(nelemup)+1)
h0=v(2,node0)
h1=prop(ielprop(nelemup)+3)
!
! h1 cannot exceed HKmax
!
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
if(h1.gt.hk) h1=hk
!
call hns(b,theta,rho,dg,sqrts0,xflow,h1,h1ns)
if(h2.lt.h1ns) then
!
! bresse (frontwater)
!
c write(30,*) 'SO: Bresse equation '
c write(30,*)'h0= ',h0,'h1= ',h1,'h2= ',h2,'h1ns= ',h1ns
bresse=.true.
else
!
! Q=f_SG(h0,h2): sluice gate equation between 0 and 2
! (backwater)
!
! reset gate height
!
h1=prop(ielprop(nelemup)+3)
!
c write(30,*) 'SO: Sluice gate eqn. between 0 and 2 '
c write(30,*)'h0= ',h0,'h1= ',h1,'h2= ',h2,'h1ns= ',h1ns
numf=4
nodef(4)=node0
idirf(4)=2
!
if(h2.gt.h1) then
!
! gate flow (water touches gate)
! section = b * h1
!
! next line for output only
!
v(2,node1)=h1
df(4)=2.d0*dg*(rho*b*h1)**2
df(3)=-df(4)*sqrts0
df(2)=-2.d0*xflow
f=df(4)*(h0-h2*sqrts0)
df(1)=2.d0*f/h1
else
!
! incomplete inflexion (water does not touch gate)
! section = b * h2
!
! next line for output only
!
v(2,node1)=h2
df(4)=2.d0*dg*(rho*b*h2)**2
df(3)=-df(4)*sqrts0
df(2)=-2.d0*xflow
f=df(4)*(h0-h2*sqrts0)
df(3)=df(3)+2.d0*f/h2
df(1)=0.d0
endif
f=f-xflow2
endif
elseif(lakon(nelem)(6:7).eq.'WE') then
!
! weir
! 1-WE-2-WO-3
!
nelemdown=int(prop(index+5))
h3=v(2,kon(ipkon(nelemdown)+3))
!
! default depth for weir is hk
!
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
!
if(h3.lt.p+hk) then
!
! output only
!
v(2,node2)=p+hk
!
! Q=f_WE(h1): weir equation
!
c write(30,*) 'WE: weir equation '
c write(30,*)'h1= ',h1,'h2= ',h2,'h3= ',h3,'hk= ',hk
f=rho*c*b*(h1-p)**(1.5d0)
df(1)=3.d0*f/(2.d0*(h1-p))
f=f-xflow
df(2)=-1.d0
df(3)=0.d0
else
!
! fake equation
!
c write(30,*) 'WE: weir equation '
c write(30,*)'h1= ',h1,'h2= ',h2,'h3= ',h3,'hk= ',hk
numf=1
nodef(1)=nodem
idirf(1)=3
f=prop(index+4)-0.5d0
df(1)=1.d0
endif
elseif(lakon(nelem)(6:7).eq.'WO') then
!
! weir opening (element streamdown of weir)
! 0-WE-1-WO-2
!
nelemup=int(prop(index+6))
node0=kon(ipkon(nelemup)+1)
h0=v(2,node0)
!
p=prop(ielprop(nelemup)+2)
!
! default depth for weir is hk
!
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
!
if(h2.lt.p+hk) then
!
! bresse between 1 and 2
!
h1=hk
c write(30,*) 'WO: Bresse equation '
c write(30,*)'h0= ',h0,'h1= ',h1,'h2= ',h2,'hk= ',hk
p=prop(ielprop(nelemup)+2)
s0=dasin(p/dsqrt(dl**2+p**2))
c write(*,*) 's0=',p,dl,s0
sqrts0=dsqrt(1.d0-s0*s0)
bresse=.true.
else
!
! output only
!
v(2,node1)=h2
!
! bresse between 0 and 2
!
c write(30,*) 'WO: Bresse eqn. between 0 and 2 '
c write(30,*)'h0= ',h0,'h1= ',h1,'h2= ',h2,'hk= ',hk
nodef(1)=node0
h1=h0
bresse=.true.
endif
elseif(lakon(nelem)(6:7).eq.'DS') then
!
! discontinuous slope
! 1-DS-2-DO-3
!
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
!
if(h1.gt.hk) then
nelemdown=int(prop(index+8))
h3=v(2,kon(ipkon(nelemdown)+3))
if(h3.le.hk) then
!
! upstream: backwater curve
! downstream: frontwater curve
!
h2=hk
bresse=.true.
c write(30,*) 'DS: back/front bresse'
c write(30,*)'h1= ',h1,'h2= ',h2,'h3= ',h3
!
! for output purposes
!
v(2,node2)=h2
else
!
! both curves are backwater curves
! fake equation
!
c write(30,*) 'DS: back/back fake equation '
c write(30,*)'h1= ',h1,'h2= ',h2,'h3= ',h3
numf=1
nodef(1)=nodem
idirf(1)=3
f=prop(index+7)-0.5d0
df(1)=1.d0
endif
else
!
! both curves are frontwater curves
! fake equation
!
c write(30,*) 'DS: front/front fake equation '
c write(30,*)'h1= ',h1,'h2= ',h2
nelemup=int(prop(index+6))
numf=1
nodef(1)=kon(ipkon(nelemup)+2)
idirf(1)=3
f=prop(index+7)-0.5d0
df(1)=1.d0
endif
elseif(lakon(nelem)(6:7).eq.'DO') then
!
! discontinuous slope opening
! (element streamdown of discontinuous slope)
! 0-DS-1-DO-2
!
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
!
nelemup=int(prop(index+6))
node0=kon(ipkon(nelemup)+1)
h0=v(2,node0)
!
if(h0.gt.hk) then
if(h2.le.hk) then
!
! upstream: backwater curve
! downstream: frontwater curve
! bresse between 1 and 2
!
h1=hk
c write(30,*) 'DO: back/front bresse 1-2'
c write(30,*)'h0= ',h0,'h1= ',h1,'h2= ',h2
bresse=.true.
else
!
! both curves are backwater curves
! bresse between 0 and 2
!
c write(30,*) 'DO: back/back bresse 0-2'
c write(30,*)'h0= ',h0,'h1= ',h1,'h2= ',h2
nodef(1)=node0
h1=h0
bresse=.true.
!
! output purposes
!
v(2,node1)=(h0+h2)/2.d0
endif
else
!
! both curves are frontwater curves
! bresse between 0 and 2
!
c write(30,*) 'DO: front/front bresse 0-2'
c write(30,*)'h0= ',h0,'h1= ',h1,'h2= ',h2
nodef(1)=node0
h1=h0
bresse=.true.
!
! output purposes
!
v(2,node1)=(h0+h2)/2.d0
endif
elseif(lakon(nelem)(6:7).eq.'RE') then
!
! element upstream of a reservoir
! calculating the critical depth
!
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
if(h1.ge.hk) then
!
! backwater curve
!
if(h2.lt.hk) h2=hk
c write(30,*) 'RE: Bresse downstream equation '
c write(30,*) 'h1= ',h1,'h2= ',h2,'hk= ',hk
bresse=.true.
else
!
! frontwater curve
!
call hns(b,theta,rho,dg,sqrts0,xflow,h1,h1ns)
if(h2.le.h1ns) then
c write(30,*) 'RE: fake equation '
c write(30,*) 'h1= ',h1,'h2= ',h2,'h1ns= ',h1ns
!
! fake equation
!
nelemup=int(prop(index+6))
nodesg=kon(ipkon(nelemup)+2)
numf=1
nodef(1)=nodesg
idirf(1)=3
!
! retrieving previous value of eta
!
index=ielprop(nelemup)
if(lakon(nelemup)(6:7).eq.'SG') then
f=prop(index+4)-0.5d0
elseif(lakon(nelemup)(6:7).eq.'WE') then
f=prop(index+4)-0.5d0
elseif(lakon(nelemup)(6:7).eq.'DS') then
f=prop(index+7)-0.5d0
endif
df(1)=1.d0
else
c write(30,*) 'RE: Bresse downstream equation '
c write(30,*) 'h1= ',h1,'h2= ',h2,'h1ns= ',h1ns
bresse=.true.
endif
endif
elseif(lakon(nelem)(6:7).eq.'CO') then
c write(30,*) 'CO: contraction '
c write(30,*)'h1= ',h1,'h2= ',h2
!
call hcrit(xflow,rho,b2,theta,dg,sqrts0,hk)
v(3,node2)=hk
!
if(inv.eq.-1) then
if((h1.gt.hk).and.(h2.lt.hk)) then
jump=.true.
endif
else
if((h1.lt.hk).and.(h2.gt.hk)) then
jump=.true.
endif
endif
!
c write(*,*) 'CO ',jump
!
if(.not.jump) then
c1=rho*rho*dg
c2=b1*b2*h1*h2
df(1)=b1*(2.d0*xflow2+c1*b1*b2*h2**3)
df(3)=b2*(2.d0*xflow2+c1*b1*b1*h1**3)
f=h1*df(1)-h2*df(3)
df(1)=df(1)-3.d0*c1*c2*b1*h1
df(3)=3.d0*c1*c2*b1*h2-df(3)
df(2)=4.d0*(b1*h1-b2*h2)*xflow
endif
elseif(lakon(nelem)(6:7).eq.'EL') then
c write(30,*) 'EL: enlargement '
c write(30,*)'h1= ',h1,'h2= ',h2
!
call hcrit(xflow,rho,b2,theta,dg,sqrts0,hk)
v(3,node2)=hk
!
if(inv.eq.-1) then
if((h1.gt.hk).and.(h2.lt.hk)) then
jump=.true.
endif
else
if((h1.lt.hk).and.(h2.gt.hk)) then
jump=.true.
endif
endif
!
c write(*,*) 'EL ',jump
!
if(.not.jump) then
c1=rho*rho*dg
c2=b1*b2*h1*h2
df(1)=b1*(2.d0*xflow2+c1*b2*b2*h2**3)
df(3)=b2*(2.d0*xflow2+c1*b1*b2*h1**3)
f=h1*df(1)-h2*df(3)
df(1)=df(1)-3.d0*c1*c2*b2*h1
df(3)=3.d0*c1*c2*b2*h2-df(3)
df(2)=4.d0*(b1*h1-b2*h2)*xflow
endif
elseif(lakon(nelem)(6:7).eq.'DR') then
c write(30,*) 'DR: drop '
c write(30,*)'h1= ',h1,'h2= ',h2
!
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
!
if(inv.eq.-1) then
if((h1.gt.hk).and.(h2.lt.hk)) then
jump=.true.
endif
else
if((h1.lt.hk).and.(h2.gt.hk)) then
jump=.true.
endif
endif
!
if(.not.jump) then
c1=rho*rho*dg
df(1)=2.d0*xflow2+c1*b*b*h2**3
df(3)=2.d0*xflow2+c1*b*b*h1*(h1+d)**2
f=h1*df(1)-h2*df(3)
df(1)=df(1)-c1*b*b*h2*(3.d0*h1+d)*(h1+d)
df(3)=3.d0*c1*b*b*h1*h2*h2-df(3)
df(2)=4.d0*(h1-h2)*xflow
endif
elseif(lakon(nelem)(6:7).eq.'ST') then
c write(30,*) 'ST: step '
c write(30,*)'h1= ',h1,'h2= ',h2
!
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
!
if(inv.eq.-1) then
if((h1.gt.hk).and.(h2.lt.hk)) then
jump=.true.
endif
else
if((h1.lt.hk).and.(h2.gt.hk)) then
jump=.true.
endif
endif
!
if(.not.jump) then
c1=rho*rho*dg
df(1)=2.d0*xflow2+c1*b*b*h2*(h2+d)**2
df(3)=2.d0*xflow2+c1*b*b*h1**3
f=h1*df(1)-h2*df(3)
df(1)=df(1)-3.d0*c1*b*b*h1*h1*h2
df(3)=c1*b*b*h1*(3.d0*h2+d)*(h2+d)-df(3)
df(2)=4.d0*(h1-h2)*xflow
endif
elseif(lakon(nelem)(6:7).eq.' ') then
bresse=.true.
c write(30,*) 'straight: Bresse equation '
c write(30,*) 'h1= ',h1,'h2= ',h2
endif
!
! bresse equation
!
if((bresse).or.(jump)) then
!
if(xks.gt.0.d0) then
!
! White-Coolebrook
!
! hydraulic diameter
!
d=2.d0*(h1+h2)
reynolds=4.d0*xflow/(b*dvi)
form_fact=1.d0
call friction_coefficient(dl,d,xks,reynolds,form_fact,
& friction)
endif
!
if(bresse) then
call hcrit(xflow,rho,b,theta,dg,sqrts0,hk)
v(3,node2)=hk
if(inv.eq.-1) then
if((h1.gt.hk).and.(h2.lt.hk)) then
jump=.true.
endif
else
if((h1.lt.hk).and.(h2.gt.hk)) then
jump=.true.
endif
endif
b1=b
b2=b
endif
!
! geometric data
!
cth=dcos(theta)
tth=dtan(theta)
!
! nonprismatic cross section
!
if(lakon(nelem)(6:7).eq.' ') then
dbds=prop(index+7)
else
dbds=0.d0
endif
!
! width at water surface
!
dD1dh1=2.d0*tth
dD2dh2=dD1dh1
D1=b1+h1*dD1dh1
D2=b2+dl*dbds+h2*dD2dh2
!
! cross section
!
A1=h1*(b1+h1*tth)
A2=h2*(b2+dl*dbds+h2*tth)
dA1dh1=D1
dA2dh2=D2
!
! perimeter
!
P1=b1+2.d0*h1/cth
P2=b2+dl*dbds+2.d0*h2/cth
dP1dh1=2.d0/cth
dP2dh2=dP1dh1
!
! factor for friction
!
if(xks.gt.0.d0) then
! White-Coolebrook
um1=friction/8.d0
um2=um1
dum1dh1=0.d0
dum2dh2=0.d0
else
! Manning
um1=xks*xks*dg*(P1/A1)**(1.d0/3.d0)
um2=xks*xks*dg*(P2/A2)**(1.d0/3.d0)
dum1dh1=xks*xks*dg*
& (P1**(-2.d0/3.d0)*dP1dh1*A1**(1.d0/3.d0)-
& A1**(-2.d0/3.d0)*dA1dh1*P1**(1.d0/3.d0))/
& (3.d0*A1**(2.d0/3d0))
dum2dh2=xks*xks*dg*
& (P2**(-2.d0/3.d0)*dP2dh2*A2**(1.d0/3.d0)-
& A2**(-2.d0/3.d0)*dA2dh2*P2**(1.d0/3.d0))/
& (3.d0*A2**(2.d0/3d0))
endif
!
! constants
!
c1=rho*rho*dg
c2=c1*sqrts0
c1=c1*s0
!
! hydraulic jump
!
if(jump) then
c write(30,*)
c & 'liquidchannel: jump in element,hk ',nelem,hk
nelemup=prop(index+6)
indexup=ielprop(nelemup)
if(lakon(nelemup)(6:7).eq.'SG') then
eta=prop(indexup+4)
prop(indexup+7)=nelem+0.5d0
elseif(lakon(nelemup)(6:7).eq.'WE') then
eta=prop(indexup+4)
prop(indexup+7)=nelem+0.5d0
elseif(lakon(nelemup)(6:7).eq.'DS') then
eta=prop(indexup+7)
prop(indexup+9)=nelem+0.5d0
endif
!
! determining h3, h4 and derivatives
!
! numerator
!
xt1=c1*A1**3+(h1*dbds-um1*P1)*xflow2
xt2=c1*A2**3+(h2*dbds-um2*P2)*xflow2
!
! denominator
!
xn1=c2*A1**3-D1*xflow2
xn2=c2*A2**3-D2*xflow2
!
! h3 and h4
!
h3=h1+dl*xt1/xn1*eta
h4=h2-dl*xt2/xn2*(1.d0-eta)
c write(30,*)
c & 'liquidchannel: h3,h4,eta ',h3,h4,eta
!
if(bresse) then
!
! width at jump
!
bj=b+dbds*eta*dl
!
! cross sections and derivatives
!
A3=h3*(bj+h3*tth)
A4=h4*(bj+h4*tth)
dA3dh3=bj+2.d0*h3*tth
dA4dh4=bj+2.d0*h4*tth
!
! center of gravity and derivatives
!
yg3=h3*(3.d0*bj+2.d0*h3*tth)/(6.d0*(bj+h3*tth))
yg4=h4*(3.d0*bj+2.d0*h4*tth)/(6.d0*(bj+h4*tth))
dyg3dh3=((3.d0*bj+4.d0*h3*tth)*(bj+tth)
& -tth*h3*(3.d0*bj+2.d0*h3*tth))/
& (6.d0*(bj+h3*tth)**2)
dyg4dh4=((3.d0*bj+4.d0*h4*tth)*(bj+tth)
& -tth*h4*(3.d0*bj+2.d0*h4*tth))/
& (6.d0*(bj+h4*tth)**2)
dyg3dbj=h3*h3*tth/(6.d0*(bj+h3*tth)**2)
dyg4dbj=h4*h4*tth/(6.d0*(bj+h4*tth)**2)
endif
!
! derivative of h3 w.r.t. h1 and of h4 w.r.t. h2
!
dh3dh1=1.d0+((3.d0*c1*A1*A1*dA1dh1
& +(dbds-dum1dh1*P1-um1*dP1dh1)*xflow2)*xn1
& -(3.d0*c2*A1*A1*dA1dh1-dD1dh1*xflow2)*xt1)/
& (xn1*xn1)*eta*dl
dh4dh2=1.d0-((3.d0*c1*A2*A2*dA2dh2
& +(dbds-dum2dh2*P2-um2*dP2dh2)*xflow2)*xn2
& -(3.d0*c2*A2*A2*dA2dh2-dD2dh2*xflow2)*xt2)/
& (xn2*xn2)*(1.d0-eta)*dl
!
if(bresse) then
dA3dh1=dA3dh3*dh3dh1
dA4dh2=dA4dh4*dh4dh2
dyg3dh1=dyg3dh3*dh3dh1
dyg4dh2=dyg4dh4*dh4dh2
endif
!
! derivative of h3 and h4 w.r.t. the mass flow
!
dh3dm=((dbds*h1-um1*P1)*xn1+D1*xt1)*2.d0*xflow/
& (xn1*xn1)*eta*dl
dh4dm=-((dbds*h2-um2*P2)*xn2+D2*xt2)*2.d0*xflow/
& (xn2*xn2)*(1.d0-eta)*dl
!
if(bresse) then
dA3dm=dA3dh3*dh3dm
dA4dm=dA4dh4*dh4dm
dyg3dm=dyg3dh3*dh3dm
dyg4dm=dyg4dh4*dh4dm
endif
!
! derivative of h3 and h4 w.r.t. eta
!
dh3deta=dl*xt1/xn1
dh4deta=dl*xt2/xn2
!
if(bresse) then
dbjdeta=dbds*dl
!
! derivative of A3, A4, yg3 and yg4 w.r.t. eta
!
dA3deta=dA3dh3*dh3deta+h3*dbjdeta
dA4deta=dA4dh4*dh4deta+h4*dbjdeta
dyg3deta=dyg3dh3*dh3deta+dyg3dbj*dbjdeta
dyg4deta=dyg4dh4*dh4deta+dyg4dbj*dbjdeta
endif
!
numf=4
nodef(4)=kon(ipkon(nelemup)+2)
idirf(4)=3
!
if(bresse) then
f=A4*xflow2+c2*(A3*A3*A4*yg3-A3*A4*A4*yg4)
& -A3*xflow2
df(1)=c2*(2.d0*A3*dA3dh1*A4*yg3+A3*A3*A4*dyg3dh1
& -dA3dh1*A4*A4*yg4)-dA3dh1*xflow2
df(2)=2.d0*xflow*(A4-A3)+
& (c2*(2.d0*A3*A4*yg3-A4*A4*yg4)-xflow2)*dA3dm+
& (c2*(A3*A3*yg3-2.d0*A3*A4*yg4)+xflow2)*dA4dm+
& c2*A3*A3*A4*dyg3dm-c2*A3*A4*A4*dyg4dm
df(3)=c2*(A3*A3*dA4dh2*yg3-2.d0*A3*A4*dA4dh2*yg4
& -A3*A4*A4*dyg4dh2)+dA4dh2*xflow2
df(4)=dA4deta*xflow2+
& c2*(2.d0*A3*dA3deta*A4*yg3+A3*A3*dA4deta*yg3
& +A3*A3*A4*dyg3deta-dA3deta*A4*A4*yg4
& -A3*2.d0*A4*dA4deta*yg4-A3*A4*A4*dyg4deta)
& -dA3deta*xflow2
elseif(lakon(nelem)(6:7).eq.'CO') then
f=b2*h4*(2.d0*xflow2+c2*b1*b1*h3**3)-
& b1*h3*(2.d0*xflow2+c2*b1*b2*h4**3)
! dfdh3
df(1)=3.d0*b2*h4*c2*b1*b1*h3*h3-
& b1*(2.d0*xflow2+c2*b1*b2*h4**3)
! dfdh4
df(3)=b2*(2.d0*xflow2+c2*b1*b1*h3**3)-
& 3.d0*b1*h3*c2*b1*b2*h4*h4
! dfdm
df(2)=4.d0*xflow*(b2*h4-b1*h3)+
& df(1)*dh3dm+df(3)*dh4dm
! dfdeta
df(4)=df(1)*dh3deta+df(3)*dh4deta
! dfdh1
df(1)=df(1)*dh3dh1
! dfdh2
df(3)=df(3)*dh4dh2
elseif(lakon(nelem)(6:7).eq.'EL') then
f=b2*h4*(2.d0*xflow2+c2*b1*b2*h3**3)-
& b1*h3*(2.d0*xflow2+c2*b2*b2*h4**3)
! dfdh3
df(1)=3.d0*b2*h4*c2*b1*b2*h3*h3-
& b1*(2.d0*xflow2+c2*b2*b2*h4**3)
! dfdh4
df(3)=b2*(2.d0*xflow2+c2*b1*b2*h3**3)-
& 3.d0*b1*h3*c2*b2*b2*h4*h4
! dfdm
df(2)=4.d0*xflow*(b2*h4-b1*h3)+
& df(1)*dh3dm+df(3)*dh4dm
! dfdeta
df(4)=df(1)*dh3deta+df(3)*dh4deta
! dfdh1
df(1)=df(1)*dh3dh1
! dfdh2
df(3)=df(3)*dh4dh2
elseif(lakon(nelem)(6:7).eq.'DR') then
f=h4*(2.d0*xflow2+c2*b*b*h3*(h3+d)**2)-
& h3*(2.d0*xflow2+c2*b*b*h4**3)
! dfdh3
df(1)=h4*c2*b*b*(3.d0*h3+d)*(h3+d)-
& (2.d0*xflow2+c2*b*b*h4**3)
! dfdh4
df(3)=(2.d0*xflow2+c2*b*b*h3*(h3+d)**2)-
& 3.d0*h3*c2*b*b*h4*h4
! dfdm
df(2)=4.d0*xflow*(h4-h3)+
& df(1)*dh3dm+df(3)*dh4dm
! dfdeta
df(4)=df(1)*dh3deta+df(3)*dh4deta
! dfdh1
df(1)=df(1)*dh3dh1
! dfdh2
df(3)=df(3)*dh4dh2
elseif(lakon(nelem)(6:7).eq.'ST') then
f=h4*(2.d0*xflow2+c2*b*b*h3**3)-
& h3*(2.d0*xflow2+c2*b*b*h4*(h4+d)**2)
! dfdh3
df(1)=3.d0*h4*c2*b*b*h3*h3-
& (2.d0*xflow2+c2*b*b*h4*(h4+d)**2)
! dfdh4
df(3)=(2.d0*xflow2+c2*b*b*h3**3)-
& h3*c2*b*b*(3.d0*h4+d)*(h4+d)
! dfdm
df(2)=4.d0*xflow*(h4-h3)+
& df(1)*dh3dm+df(3)*dh4dm
! dfdeta
df(4)=df(1)*dh3deta+df(3)*dh4deta
! dfdh1
df(1)=df(1)*dh3dh1
! dfdh2
df(3)=df(3)*dh4dh2
endif
else
!
! regular Bresse equation
!
f=c2*(A1**3+A2**3)-xflow2*(D1+D2)
df(1)=-f+(h2-h1)*(c2*dA1dh1*3.d0*A1*A1-xflow2*dD1dh1)
& -dl*(c1*3.d0*A1*A1*dA1dh1
& -(dum1dh1*P1+um1*dP1dh1-dbds)*xflow2)
df(2)=(-(h2-h1)*(D1+D2)
& +dl*(um1*P1+um2*P2-(h1+h2)*dbds))*2.d0*xflow
df(3)=f+(h2-h1)*(c2*dA2dh2*3.d0*A2*A2-xflow2*dD2dh2)
& -dl*(c1*3.d0*A2*A2*dA2dh2
& -(dum2dh2*P2+um2*dP2dh2-dbds)*xflow2)
f=(h2-h1)*f-dl*(c1*(A1**3+A2**3)
& -(um1*P1+um2*P2-(h1+h2)*dbds)*xflow2)
endif
endif
endif
elseif(iflag.eq.3) then
!
! only if called from resultgas in case the element contains
! a hydraulic jump and eta<0 or eta>1. This means that the
! jump does not take place in the element itself. By adjusting
! h1 or h2 the jump is forced into a neighboring element
!
index=ielprop(nelem)
c write(30,*) 'iflag=3, nelem',nelem,lakon(nelem)
!
h1=v(2,node1)
h2=v(2,node2)
!
z1=-g(1)*co(1,node1)-g(2)*co(2,node1)-g(3)*co(3,node1)
z2=-g(1)*co(1,node2)-g(2)*co(2,node2)-g(3)*co(3,node2)
!
dg=dsqrt(g(1)*g(1)+g(2)*g(2)+g(3)*g(3))
!
xflow2=xflow*xflow
!
! determine eta (present location of jump)
!
nelemup=prop(index+6)
indexup=ielprop(nelemup)
if(lakon(nelemup)(6:7).eq.'SG') then
eta=prop(indexup+4)
prop(indexup+4)=0.5d0
prop(indexup+7)=0.5d0
elseif(lakon(nelemup)(6:7).eq.'WE') then
eta=prop(indexup+4)
prop(indexup+4)=0.5d0
prop(indexup+7)=0.5d0
elseif(lakon(nelemup)(6:7).eq.'DS') then
eta=prop(indexup+7)
prop(indexup+7)=0.5d0
prop(indexup+9)=0.5d0
endif
!
! element properties
!
if((lakon(nelem)(6:7).eq.'SG').or.
& (lakon(nelem)(6:7).eq.'SO').or.
& (lakon(nelem)(6:7).eq.'RE').or.
& (lakon(nelem)(6:7).eq.' ').or.
& (lakon(nelem)(6:7).eq.'DS').or.
& (lakon(nelem)(6:7).eq.'DO')) then
b=prop(index+1)
s0=prop(index+2)
if(s0.lt.-1.d0) then
s0=dasin((z1-z2)/dl)
endif
sqrts0=dsqrt(1.d0-s0*s0)
if(lakon(nelem)(6:7).ne.'SG') then
dl=prop(index+3)
theta=prop(index+4)
xks=prop(index+5)
if(dl.le.0.d0) then
dl=dsqrt((co(1,node2)-co(1,node1))**2+
& (co(2,node2)-co(2,node1))**2+
& (co(3,node2)-co(3,node1))**2)
endif
else
theta=0.d0
endif
elseif(lakon(nelem)(6:7).eq.'WE') then
b=prop(index+1)
p=prop(index+2)
c=prop(index+3)
elseif((lakon(nelem)(6:7).eq.'CO').or.
& (lakon(nelem)(6:7).eq.'EL')) then
b1=prop(index+1)
s0=prop(index+2)
if(s0.lt.-1.d0) then
s0=dasin((z1-z2)/dl)
endif
sqrts0=dsqrt(1.d0-s0*s0)
b2=prop(index+4)
elseif((lakon(nelem)(6:7).eq.'DR').or.
& (lakon(nelem)(6:7).eq.'ST'))then
b=prop(index+1)
s0=prop(index+2)
if(s0.lt.-1.d0) then
s0=dasin((z1-z2)/dl)
endif
sqrts0=dsqrt(1.d0-s0*s0)
d=prop(index+4)
endif
!
! contraction, enlargement, drop and step:
! adjust h1 or h2 by solving the appropriate
! momentum equation
!
if((lakon(nelem)(6:7).eq.'CO').or.
& (lakon(nelem)(6:7).eq.'EL').or.
& (lakon(nelem)(6:7).eq.'DR').or.
& (lakon(nelem)(6:7).eq.'ST'))then
c2=rho*rho*dg*sqrts0
!
if(eta.gt.1.d0) then
!
! h1 is given, h2 is unknown
!
if(lakon(nelem)(6:7).eq.'CO') then
e3=b1*h1*c2*b1*b2
e0=2.d0*b1*h1*xflow2/e3
e1=-(2.d0*xflow2+c2*b1*b1*h1**3)*b2/e3
e2=0.d0
elseif(lakon(nelem)(6:7).eq.'EL') then
e3=b1*h1*c2*b2*b2
e0=2.d0*b1*h1*xflow2/e3
e1=-(2.d0*xflow2+c2*b1*b2*h1**3)*b2/e3
e2=0.d0
elseif(lakon(nelem)(6:7).eq.'DR') then
e3=h1*c2*b*b
e0=h1*2.d0*xflow2/e3
e1=-(2.d0*xflow2+c2*b*b*h1*(h1+d)**2)/e3
e2=0.d0
elseif(lakon(nelem)(6:7).eq.'ST') then
e3=h1*c2*b*b
e0=h1*2.d0*xflow2/e3
e1=(h1*c2*b*b*d*d-(2.d0*xflow2+c2*b*b*h1**3))/e3
e2=h1*c2*b*b*2.d0*d/e3
endif
!
! solve the cubic equation
!
call cubic(e0,e1,e2,solreal,solimag,nsol)
!
! determine the real solution closest to h1
!
dist=1.d30
do i=1,nsol
if(dabs(solreal(i)-h1).lt.dist) then
dist=dabs(solreal(i)-h1)
h2=solreal(i)
endif
enddo
if(nactdog(2,node2).ne.0) v(2,node2)=h2
elseif(eta.lt.0.d0) then
!
! h2 is given, h1 is unknown
!
if(lakon(nelem)(6:7).eq.'CO') then
e3=c2*b1*b1*b2*h2
e0=2.d0*xflow2*b2*h2/e3
e1=-b1*(2.d0*xflow2+c2*b1*b2*h2**3)/e3
e2=0.d0
elseif(lakon(nelem)(6:7).eq.'EL') then
e3=c2*b1*b2*b2*h2
e0=2.d0*xflow2*b2*h2/e3
e1=-b1*(2.d0*xflow2+c2*b2*b2*h2**3)/e3
e2=0.d0
elseif(lakon(nelem)(6:7).eq.'DR') then
e3=c2*b*b*h2
e0=2.d0*xflow2*h2/e3
e1=(c2*b*b*d*d*h2-(2.d0*xflow2+c2*b*b*h2**3))/e3
e2=c2*b*b*2.d0*d*h2/e3
elseif(lakon(nelem)(6:7).eq.'ST') then
e3=c2*b*b*h2
e0=2.d0*xflow2*h2/e3
e1=-(2.d0*xflow2+c2*b*b*h2*(h2+d)**2)/e3
e2=0.d0
endif
!
! solve the cubic equation
!
call cubic(e0,e1,e2,solreal,solimag,nsol)
c write(30,*) 'check ',solreal(1)**3+e1*solreal(1)+e0
!
c write(30,*) 'nsol',nsol
c write(30,*) 'solreal',(solreal(i),i=1,3)
c write(30,*) 'solimag',(solimag(i),i=1,3)
!
! determine the real solution closest to h2
!
dist=1.d30
do i=1,nsol
if(dabs(solreal(i)-h2).lt.dist) then
dist=dabs(solreal(i)-h2)
h1=solreal(i)
endif
enddo
if(nactdog(2,node1).ne.0) v(2,node1)=h1
endif
return
endif
!
if(xks.gt.0.d0) then
!
! White-Coolebrook
!
! hydraulic diameter
!
d=2.d0*(h1+h2)
reynolds=4.d0*xflow/(b*dvi)
form_fact=1.d0
call friction_coefficient(dl,d,xks,reynolds,form_fact,
& friction)
endif
!
! geometric data
!
cth=dcos(theta)
tth=dtan(theta)
!
! nonprismatic cross section
!
if(lakon(nelem)(6:7).eq.' ') then
dbds=prop(index+7)
else
dbds=0.d0
endif
!
! width at water surface
!
dD1dh1=2.d0*tth
dD2dh2=dD1dh1
D1=b+h1*dD1dh1
D2=b+dl*dbds+h2*dD2dh2
!
! cross section
!
A1=h1*(b+h1*tth)
A2=h2*(b+dl*dbds+h2*tth)
!
! perimeter
!
P1=b+2.d0*h1/cth
P2=b+dl*dbds+2.d0*h2/cth
!
! factor for friction
!
if(xks.gt.0.d0) then
! White-Coolebrook
um1=friction/8.d0
um2=um1
else
! Manning
um1=xks*xks*dg*(P1/A1)**(1.d0/3.d0)
um2=xks*xks*dg*(P2/A2)**(1.d0/3.d0)
endif
!
! constants
!
c1=rho*rho*dg
c2=c1*sqrts0
c1=c1*s0
!
if(eta.gt.1.d0) then
xt1=c1*A1**3+(h1*dbds-um1*P1)*xflow2
xn1=c2*A2**3-D2*xflow2
if(nactdog(2,node2).ne.0) v(2,node2)=h1+dl*xt1/xn1
c write(30,*) 'move jump: h1 h2,h2new ',h1,h2,v(2,node2)
elseif(eta.lt.0.d0) then
xt2=c1*A2**3+(h2*dbds-um2*P2)*xflow2
xn2=c2*A2**3-D2*xflow2
if(nactdog(2,node1).ne.0)
& v(2,node1)=h2-dl*xt2/xn2
c write(30,*) 'move jump: h1 h1new h2 ',h1,v(2,node1),h2
endif
endif
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.16/src/preprojectgrad.f | 1 | 1926 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2019 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 preprojectgrad(vector,ndesi,nodedesi,dgdxglob,nactive,
& nobject,nnlconst,ipoacti,nk,rhs,iconst,objectset,xtf)
!
! calculates the projected gradient
!
implicit none
!
character*81 objectset(4,*)
!
integer ndesi,nodedesi(*),irow,icol,nactive,nobject,nnlconst,
& ipoacti(*),nk,ipos,node,iconst,i
!
real*8 dgdxglob(2,nk,nobject),vector(ndesi),rhs(*),scalar,dd,
& len,xtf(*),brauch,nutz
!
! initialization of enlarged field dgdxglob and
! calculate the second part of xlambd
!
do irow=1,nk
dgdxglob(2,irow,nobject)=0.d0
dgdxglob(1,irow,nobject)=0.d0
enddo
!
do icol=1,nactive
if(icol.le.nnlconst) then
do irow=1,ndesi
ipos=ipoacti(icol)
node=nodedesi(irow)
xtf(icol)=xtf(icol)+dgdxglob(2,node,1)
& *dgdxglob(2,node,ipos)
enddo
else
ipos=ipoacti(icol)
node=nodedesi(ipos)
xtf(icol)=dgdxglob(2,node,1)
endif
enddo
!
return
end
| gpl-2.0 |
alexfrolov/grappa | applications/NPB/MPI/LU/erhs.f | 6 | 20815 | c---------------------------------------------------------------------
c---------------------------------------------------------------------
subroutine erhs
c---------------------------------------------------------------------
c---------------------------------------------------------------------
c---------------------------------------------------------------------
c
c compute the right hand side based on exact solution
c
c---------------------------------------------------------------------
implicit none
include 'applu.incl'
c---------------------------------------------------------------------
c local variables
c---------------------------------------------------------------------
integer i, j, k, m
integer iglob, jglob
integer iex
integer L1, L2
integer ist1, iend1
integer jst1, jend1
double precision dsspm
double precision xi, eta, zeta
double precision q
double precision u21, u31, u41
double precision tmp
double precision u21i, u31i, u41i, u51i
double precision u21j, u31j, u41j, u51j
double precision u21k, u31k, u41k, u51k
double precision u21im1, u31im1, u41im1, u51im1
double precision u21jm1, u31jm1, u41jm1, u51jm1
double precision u21km1, u31km1, u41km1, u51km1
dsspm = dssp
do k = 1, nz
do j = 1, ny
do i = 1, nx
do m = 1, 5
frct( m, i, j, k ) = 0.0d+00
end do
end do
end do
end do
do k = 1, nz
zeta = ( dble(k-1) ) / ( nz - 1 )
do j = 1, ny
jglob = jpt + j
eta = ( dble(jglob-1) ) / ( ny0 - 1 )
do i = 1, nx
iglob = ipt + i
xi = ( dble(iglob-1) ) / ( nx0 - 1 )
do m = 1, 5
rsd(m,i,j,k) = ce(m,1)
> + ce(m,2) * xi
> + ce(m,3) * eta
> + ce(m,4) * zeta
> + ce(m,5) * xi * xi
> + ce(m,6) * eta * eta
> + ce(m,7) * zeta * zeta
> + ce(m,8) * xi * xi * xi
> + ce(m,9) * eta * eta * eta
> + ce(m,10) * zeta * zeta * zeta
> + ce(m,11) * xi * xi * xi * xi
> + ce(m,12) * eta * eta * eta * eta
> + ce(m,13) * zeta * zeta * zeta * zeta
end do
end do
end do
end do
c---------------------------------------------------------------------
c xi-direction flux differences
c---------------------------------------------------------------------
c
c iex = flag : iex = 0 north/south communication
c : iex = 1 east/west communication
c
c---------------------------------------------------------------------
iex = 0
c---------------------------------------------------------------------
c communicate and receive/send two rows of data
c---------------------------------------------------------------------
call exchange_3 (rsd,iex)
L1 = 0
if (north.eq.-1) L1 = 1
L2 = nx + 1
if (south.eq.-1) L2 = nx
ist1 = 1
iend1 = nx
if (north.eq.-1) ist1 = 4
if (south.eq.-1) iend1 = nx - 3
do k = 2, nz - 1
do j = jst, jend
do i = L1, L2
flux(1,i,j,k) = rsd(2,i,j,k)
u21 = rsd(2,i,j,k) / rsd(1,i,j,k)
q = 0.50d+00 * ( rsd(2,i,j,k) * rsd(2,i,j,k)
> + rsd(3,i,j,k) * rsd(3,i,j,k)
> + rsd(4,i,j,k) * rsd(4,i,j,k) )
> / rsd(1,i,j,k)
flux(2,i,j,k) = rsd(2,i,j,k) * u21 + c2 *
> ( rsd(5,i,j,k) - q )
flux(3,i,j,k) = rsd(3,i,j,k) * u21
flux(4,i,j,k) = rsd(4,i,j,k) * u21
flux(5,i,j,k) = ( c1 * rsd(5,i,j,k) - c2 * q ) * u21
end do
end do
end do
do k = 2, nz - 1
do j = jst, jend
do i = ist, iend
do m = 1, 5
frct(m,i,j,k) = frct(m,i,j,k)
> - tx2 * ( flux(m,i+1,j,k) - flux(m,i-1,j,k) )
end do
end do
do i = ist, L2
tmp = 1.0d+00 / rsd(1,i,j,k)
u21i = tmp * rsd(2,i,j,k)
u31i = tmp * rsd(3,i,j,k)
u41i = tmp * rsd(4,i,j,k)
u51i = tmp * rsd(5,i,j,k)
tmp = 1.0d+00 / rsd(1,i-1,j,k)
u21im1 = tmp * rsd(2,i-1,j,k)
u31im1 = tmp * rsd(3,i-1,j,k)
u41im1 = tmp * rsd(4,i-1,j,k)
u51im1 = tmp * rsd(5,i-1,j,k)
flux(2,i,j,k) = (4.0d+00/3.0d+00) * tx3 *
> ( u21i - u21im1 )
flux(3,i,j,k) = tx3 * ( u31i - u31im1 )
flux(4,i,j,k) = tx3 * ( u41i - u41im1 )
flux(5,i,j,k) = 0.50d+00 * ( 1.0d+00 - c1*c5 )
> * tx3 * ( ( u21i **2 + u31i **2 + u41i **2 )
> - ( u21im1**2 + u31im1**2 + u41im1**2 ) )
> + (1.0d+00/6.0d+00)
> * tx3 * ( u21i**2 - u21im1**2 )
> + c1 * c5 * tx3 * ( u51i - u51im1 )
end do
do i = ist, iend
frct(1,i,j,k) = frct(1,i,j,k)
> + dx1 * tx1 * ( rsd(1,i-1,j,k)
> - 2.0d+00 * rsd(1,i,j,k)
> + rsd(1,i+1,j,k) )
frct(2,i,j,k) = frct(2,i,j,k)
> + tx3 * c3 * c4 * ( flux(2,i+1,j,k) - flux(2,i,j,k) )
> + dx2 * tx1 * ( rsd(2,i-1,j,k)
> - 2.0d+00 * rsd(2,i,j,k)
> + rsd(2,i+1,j,k) )
frct(3,i,j,k) = frct(3,i,j,k)
> + tx3 * c3 * c4 * ( flux(3,i+1,j,k) - flux(3,i,j,k) )
> + dx3 * tx1 * ( rsd(3,i-1,j,k)
> - 2.0d+00 * rsd(3,i,j,k)
> + rsd(3,i+1,j,k) )
frct(4,i,j,k) = frct(4,i,j,k)
> + tx3 * c3 * c4 * ( flux(4,i+1,j,k) - flux(4,i,j,k) )
> + dx4 * tx1 * ( rsd(4,i-1,j,k)
> - 2.0d+00 * rsd(4,i,j,k)
> + rsd(4,i+1,j,k) )
frct(5,i,j,k) = frct(5,i,j,k)
> + tx3 * c3 * c4 * ( flux(5,i+1,j,k) - flux(5,i,j,k) )
> + dx5 * tx1 * ( rsd(5,i-1,j,k)
> - 2.0d+00 * rsd(5,i,j,k)
> + rsd(5,i+1,j,k) )
end do
c---------------------------------------------------------------------
c Fourth-order dissipation
c---------------------------------------------------------------------
IF (north.eq.-1) then
do m = 1, 5
frct(m,2,j,k) = frct(m,2,j,k)
> - dsspm * ( + 5.0d+00 * rsd(m,2,j,k)
> - 4.0d+00 * rsd(m,3,j,k)
> + rsd(m,4,j,k) )
frct(m,3,j,k) = frct(m,3,j,k)
> - dsspm * ( - 4.0d+00 * rsd(m,2,j,k)
> + 6.0d+00 * rsd(m,3,j,k)
> - 4.0d+00 * rsd(m,4,j,k)
> + rsd(m,5,j,k) )
end do
END IF
do i = ist1,iend1
do m = 1, 5
frct(m,i,j,k) = frct(m,i,j,k)
> - dsspm * ( rsd(m,i-2,j,k)
> - 4.0d+00 * rsd(m,i-1,j,k)
> + 6.0d+00 * rsd(m,i,j,k)
> - 4.0d+00 * rsd(m,i+1,j,k)
> + rsd(m,i+2,j,k) )
end do
end do
IF (south.eq.-1) then
do m = 1, 5
frct(m,nx-2,j,k) = frct(m,nx-2,j,k)
> - dsspm * ( rsd(m,nx-4,j,k)
> - 4.0d+00 * rsd(m,nx-3,j,k)
> + 6.0d+00 * rsd(m,nx-2,j,k)
> - 4.0d+00 * rsd(m,nx-1,j,k) )
frct(m,nx-1,j,k) = frct(m,nx-1,j,k)
> - dsspm * ( rsd(m,nx-3,j,k)
> - 4.0d+00 * rsd(m,nx-2,j,k)
> + 5.0d+00 * rsd(m,nx-1,j,k) )
end do
END IF
end do
end do
c---------------------------------------------------------------------
c eta-direction flux differences
c---------------------------------------------------------------------
c
c iex = flag : iex = 0 north/south communication
c : iex = 1 east/west communication
c
c---------------------------------------------------------------------
iex = 1
c---------------------------------------------------------------------
c communicate and receive/send two rows of data
c---------------------------------------------------------------------
call exchange_3 (rsd,iex)
L1 = 0
if (west.eq.-1) L1 = 1
L2 = ny + 1
if (east.eq.-1) L2 = ny
jst1 = 1
jend1 = ny
if (west.eq.-1) jst1 = 4
if (east.eq.-1) jend1 = ny - 3
do k = 2, nz - 1
do j = L1, L2
do i = ist, iend
flux(1,i,j,k) = rsd(3,i,j,k)
u31 = rsd(3,i,j,k) / rsd(1,i,j,k)
q = 0.50d+00 * ( rsd(2,i,j,k) * rsd(2,i,j,k)
> + rsd(3,i,j,k) * rsd(3,i,j,k)
> + rsd(4,i,j,k) * rsd(4,i,j,k) )
> / rsd(1,i,j,k)
flux(2,i,j,k) = rsd(2,i,j,k) * u31
flux(3,i,j,k) = rsd(3,i,j,k) * u31 + c2 *
> ( rsd(5,i,j,k) - q )
flux(4,i,j,k) = rsd(4,i,j,k) * u31
flux(5,i,j,k) = ( c1 * rsd(5,i,j,k) - c2 * q ) * u31
end do
end do
end do
do k = 2, nz - 1
do i = ist, iend
do j = jst, jend
do m = 1, 5
frct(m,i,j,k) = frct(m,i,j,k)
> - ty2 * ( flux(m,i,j+1,k) - flux(m,i,j-1,k) )
end do
end do
end do
do j = jst, L2
do i = ist, iend
tmp = 1.0d+00 / rsd(1,i,j,k)
u21j = tmp * rsd(2,i,j,k)
u31j = tmp * rsd(3,i,j,k)
u41j = tmp * rsd(4,i,j,k)
u51j = tmp * rsd(5,i,j,k)
tmp = 1.0d+00 / rsd(1,i,j-1,k)
u21jm1 = tmp * rsd(2,i,j-1,k)
u31jm1 = tmp * rsd(3,i,j-1,k)
u41jm1 = tmp * rsd(4,i,j-1,k)
u51jm1 = tmp * rsd(5,i,j-1,k)
flux(2,i,j,k) = ty3 * ( u21j - u21jm1 )
flux(3,i,j,k) = (4.0d+00/3.0d+00) * ty3 *
> ( u31j - u31jm1 )
flux(4,i,j,k) = ty3 * ( u41j - u41jm1 )
flux(5,i,j,k) = 0.50d+00 * ( 1.0d+00 - c1*c5 )
> * ty3 * ( ( u21j **2 + u31j **2 + u41j **2 )
> - ( u21jm1**2 + u31jm1**2 + u41jm1**2 ) )
> + (1.0d+00/6.0d+00)
> * ty3 * ( u31j**2 - u31jm1**2 )
> + c1 * c5 * ty3 * ( u51j - u51jm1 )
end do
end do
do j = jst, jend
do i = ist, iend
frct(1,i,j,k) = frct(1,i,j,k)
> + dy1 * ty1 * ( rsd(1,i,j-1,k)
> - 2.0d+00 * rsd(1,i,j,k)
> + rsd(1,i,j+1,k) )
frct(2,i,j,k) = frct(2,i,j,k)
> + ty3 * c3 * c4 * ( flux(2,i,j+1,k) - flux(2,i,j,k) )
> + dy2 * ty1 * ( rsd(2,i,j-1,k)
> - 2.0d+00 * rsd(2,i,j,k)
> + rsd(2,i,j+1,k) )
frct(3,i,j,k) = frct(3,i,j,k)
> + ty3 * c3 * c4 * ( flux(3,i,j+1,k) - flux(3,i,j,k) )
> + dy3 * ty1 * ( rsd(3,i,j-1,k)
> - 2.0d+00 * rsd(3,i,j,k)
> + rsd(3,i,j+1,k) )
frct(4,i,j,k) = frct(4,i,j,k)
> + ty3 * c3 * c4 * ( flux(4,i,j+1,k) - flux(4,i,j,k) )
> + dy4 * ty1 * ( rsd(4,i,j-1,k)
> - 2.0d+00 * rsd(4,i,j,k)
> + rsd(4,i,j+1,k) )
frct(5,i,j,k) = frct(5,i,j,k)
> + ty3 * c3 * c4 * ( flux(5,i,j+1,k) - flux(5,i,j,k) )
> + dy5 * ty1 * ( rsd(5,i,j-1,k)
> - 2.0d+00 * rsd(5,i,j,k)
> + rsd(5,i,j+1,k) )
end do
end do
c---------------------------------------------------------------------
c fourth-order dissipation
c---------------------------------------------------------------------
IF (west.eq.-1) then
do i = ist, iend
do m = 1, 5
frct(m,i,2,k) = frct(m,i,2,k)
> - dsspm * ( + 5.0d+00 * rsd(m,i,2,k)
> - 4.0d+00 * rsd(m,i,3,k)
> + rsd(m,i,4,k) )
frct(m,i,3,k) = frct(m,i,3,k)
> - dsspm * ( - 4.0d+00 * rsd(m,i,2,k)
> + 6.0d+00 * rsd(m,i,3,k)
> - 4.0d+00 * rsd(m,i,4,k)
> + rsd(m,i,5,k) )
end do
end do
END IF
do j = jst1, jend1
do i = ist, iend
do m = 1, 5
frct(m,i,j,k) = frct(m,i,j,k)
> - dsspm * ( rsd(m,i,j-2,k)
> - 4.0d+00 * rsd(m,i,j-1,k)
> + 6.0d+00 * rsd(m,i,j,k)
> - 4.0d+00 * rsd(m,i,j+1,k)
> + rsd(m,i,j+2,k) )
end do
end do
end do
IF (east.eq.-1) then
do i = ist, iend
do m = 1, 5
frct(m,i,ny-2,k) = frct(m,i,ny-2,k)
> - dsspm * ( rsd(m,i,ny-4,k)
> - 4.0d+00 * rsd(m,i,ny-3,k)
> + 6.0d+00 * rsd(m,i,ny-2,k)
> - 4.0d+00 * rsd(m,i,ny-1,k) )
frct(m,i,ny-1,k) = frct(m,i,ny-1,k)
> - dsspm * ( rsd(m,i,ny-3,k)
> - 4.0d+00 * rsd(m,i,ny-2,k)
> + 5.0d+00 * rsd(m,i,ny-1,k) )
end do
end do
END IF
end do
c---------------------------------------------------------------------
c zeta-direction flux differences
c---------------------------------------------------------------------
do k = 1, nz
do j = jst, jend
do i = ist, iend
flux(1,i,j,k) = rsd(4,i,j,k)
u41 = rsd(4,i,j,k) / rsd(1,i,j,k)
q = 0.50d+00 * ( rsd(2,i,j,k) * rsd(2,i,j,k)
> + rsd(3,i,j,k) * rsd(3,i,j,k)
> + rsd(4,i,j,k) * rsd(4,i,j,k) )
> / rsd(1,i,j,k)
flux(2,i,j,k) = rsd(2,i,j,k) * u41
flux(3,i,j,k) = rsd(3,i,j,k) * u41
flux(4,i,j,k) = rsd(4,i,j,k) * u41 + c2 *
> ( rsd(5,i,j,k) - q )
flux(5,i,j,k) = ( c1 * rsd(5,i,j,k) - c2 * q ) * u41
end do
end do
end do
do k = 2, nz - 1
do j = jst, jend
do i = ist, iend
do m = 1, 5
frct(m,i,j,k) = frct(m,i,j,k)
> - tz2 * ( flux(m,i,j,k+1) - flux(m,i,j,k-1) )
end do
end do
end do
end do
do k = 2, nz
do j = jst, jend
do i = ist, iend
tmp = 1.0d+00 / rsd(1,i,j,k)
u21k = tmp * rsd(2,i,j,k)
u31k = tmp * rsd(3,i,j,k)
u41k = tmp * rsd(4,i,j,k)
u51k = tmp * rsd(5,i,j,k)
tmp = 1.0d+00 / rsd(1,i,j,k-1)
u21km1 = tmp * rsd(2,i,j,k-1)
u31km1 = tmp * rsd(3,i,j,k-1)
u41km1 = tmp * rsd(4,i,j,k-1)
u51km1 = tmp * rsd(5,i,j,k-1)
flux(2,i,j,k) = tz3 * ( u21k - u21km1 )
flux(3,i,j,k) = tz3 * ( u31k - u31km1 )
flux(4,i,j,k) = (4.0d+00/3.0d+00) * tz3 * ( u41k
> - u41km1 )
flux(5,i,j,k) = 0.50d+00 * ( 1.0d+00 - c1*c5 )
> * tz3 * ( ( u21k **2 + u31k **2 + u41k **2 )
> - ( u21km1**2 + u31km1**2 + u41km1**2 ) )
> + (1.0d+00/6.0d+00)
> * tz3 * ( u41k**2 - u41km1**2 )
> + c1 * c5 * tz3 * ( u51k - u51km1 )
end do
end do
end do
do k = 2, nz - 1
do j = jst, jend
do i = ist, iend
frct(1,i,j,k) = frct(1,i,j,k)
> + dz1 * tz1 * ( rsd(1,i,j,k+1)
> - 2.0d+00 * rsd(1,i,j,k)
> + rsd(1,i,j,k-1) )
frct(2,i,j,k) = frct(2,i,j,k)
> + tz3 * c3 * c4 * ( flux(2,i,j,k+1) - flux(2,i,j,k) )
> + dz2 * tz1 * ( rsd(2,i,j,k+1)
> - 2.0d+00 * rsd(2,i,j,k)
> + rsd(2,i,j,k-1) )
frct(3,i,j,k) = frct(3,i,j,k)
> + tz3 * c3 * c4 * ( flux(3,i,j,k+1) - flux(3,i,j,k) )
> + dz3 * tz1 * ( rsd(3,i,j,k+1)
> - 2.0d+00 * rsd(3,i,j,k)
> + rsd(3,i,j,k-1) )
frct(4,i,j,k) = frct(4,i,j,k)
> + tz3 * c3 * c4 * ( flux(4,i,j,k+1) - flux(4,i,j,k) )
> + dz4 * tz1 * ( rsd(4,i,j,k+1)
> - 2.0d+00 * rsd(4,i,j,k)
> + rsd(4,i,j,k-1) )
frct(5,i,j,k) = frct(5,i,j,k)
> + tz3 * c3 * c4 * ( flux(5,i,j,k+1) - flux(5,i,j,k) )
> + dz5 * tz1 * ( rsd(5,i,j,k+1)
> - 2.0d+00 * rsd(5,i,j,k)
> + rsd(5,i,j,k-1) )
end do
end do
end do
c---------------------------------------------------------------------
c fourth-order dissipation
c---------------------------------------------------------------------
do j = jst, jend
do i = ist, iend
do m = 1, 5
frct(m,i,j,2) = frct(m,i,j,2)
> - dsspm * ( + 5.0d+00 * rsd(m,i,j,2)
> - 4.0d+00 * rsd(m,i,j,3)
> + rsd(m,i,j,4) )
frct(m,i,j,3) = frct(m,i,j,3)
> - dsspm * (- 4.0d+00 * rsd(m,i,j,2)
> + 6.0d+00 * rsd(m,i,j,3)
> - 4.0d+00 * rsd(m,i,j,4)
> + rsd(m,i,j,5) )
end do
end do
end do
do k = 4, nz - 3
do j = jst, jend
do i = ist, iend
do m = 1, 5
frct(m,i,j,k) = frct(m,i,j,k)
> - dsspm * ( rsd(m,i,j,k-2)
> - 4.0d+00 * rsd(m,i,j,k-1)
> + 6.0d+00 * rsd(m,i,j,k)
> - 4.0d+00 * rsd(m,i,j,k+1)
> + rsd(m,i,j,k+2) )
end do
end do
end do
end do
do j = jst, jend
do i = ist, iend
do m = 1, 5
frct(m,i,j,nz-2) = frct(m,i,j,nz-2)
> - dsspm * ( rsd(m,i,j,nz-4)
> - 4.0d+00 * rsd(m,i,j,nz-3)
> + 6.0d+00 * rsd(m,i,j,nz-2)
> - 4.0d+00 * rsd(m,i,j,nz-1) )
frct(m,i,j,nz-1) = frct(m,i,j,nz-1)
> - dsspm * ( rsd(m,i,j,nz-3)
> - 4.0d+00 * rsd(m,i,j,nz-2)
> + 5.0d+00 * rsd(m,i,j,nz-1) )
end do
end do
end do
return
end
| bsd-3-clause |
freedesktop-unofficial-mirror/gstreamer-sdk__gcc | gcc/testsuite/gfortran.dg/minlocval_1.f90 | 164 | 6341 | ! { dg-do run }
! { dg-add-options ieee }
! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
real :: a(3), nan, minf, pinf
real, allocatable :: c(:)
logical :: l
logical :: l2(3)
nan = 0.0
minf = 0.0
pinf = 0.0
nan = 0.0/nan
minf = -1.0/minf
pinf = 1.0/pinf
allocate (c(3))
a(:) = nan
if (minloc (a, dim = 1).ne.1) call abort
if (.not.isnan(minval (a, dim = 1))) call abort
a(:) = pinf
if (minloc (a, dim = 1).ne.1) call abort
if (minval (a, dim = 1).ne.pinf) call abort
a(1:2) = nan
if (minloc (a, dim = 1).ne.3) call abort
if (minval (a, dim = 1).ne.pinf) call abort
a(2) = 1.0
if (minloc (a, dim = 1).ne.2) call abort
if (minval (a, dim = 1).ne.1) call abort
a(2) = minf
if (minloc (a, dim = 1).ne.2) call abort
if (minval (a, dim = 1).ne.minf) call abort
c(:) = nan
if (minloc (c, dim = 1).ne.1) call abort
if (.not.isnan(minval (c, dim = 1))) call abort
c(:) = pinf
if (minloc (c, dim = 1).ne.1) call abort
if (minval (c, dim = 1).ne.pinf) call abort
c(1:2) = nan
if (minloc (c, dim = 1).ne.3) call abort
if (minval (c, dim = 1).ne.pinf) call abort
c(2) = 1.0
if (minloc (c, dim = 1).ne.2) call abort
if (minval (c, dim = 1).ne.1) call abort
c(2) = minf
if (minloc (c, dim = 1).ne.2) call abort
if (minval (c, dim = 1).ne.minf) call abort
l = .false.
l2(:) = .false.
a(:) = nan
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(:) = pinf
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(1:2) = nan
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(2) = 1.0
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(2) = minf
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(:) = nan
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(:) = pinf
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(1:2) = nan
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(2) = 1.0
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(2) = minf
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
l = .true.
l2(:) = .true.
a(:) = nan
if (minloc (a, dim = 1, mask = l).ne.1) call abort
if (.not.isnan(minval (a, dim = 1, mask = l))) call abort
if (minloc (a, dim = 1, mask = l2).ne.1) call abort
if (.not.isnan(minval (a, dim = 1, mask = l2))) call abort
a(:) = pinf
if (minloc (a, dim = 1, mask = l).ne.1) call abort
if (minval (a, dim = 1, mask = l).ne.pinf) call abort
if (minloc (a, dim = 1, mask = l2).ne.1) call abort
if (minval (a, dim = 1, mask = l2).ne.pinf) call abort
a(1:2) = nan
if (minloc (a, dim = 1, mask = l).ne.3) call abort
if (minval (a, dim = 1, mask = l).ne.pinf) call abort
if (minloc (a, dim = 1, mask = l2).ne.3) call abort
if (minval (a, dim = 1, mask = l2).ne.pinf) call abort
a(2) = 1.0
if (minloc (a, dim = 1, mask = l).ne.2) call abort
if (minval (a, dim = 1, mask = l).ne.1) call abort
if (minloc (a, dim = 1, mask = l2).ne.2) call abort
if (minval (a, dim = 1, mask = l2).ne.1) call abort
a(2) = minf
if (minloc (a, dim = 1, mask = l).ne.2) call abort
if (minval (a, dim = 1, mask = l).ne.minf) call abort
if (minloc (a, dim = 1, mask = l2).ne.2) call abort
if (minval (a, dim = 1, mask = l2).ne.minf) call abort
c(:) = nan
if (minloc (c, dim = 1, mask = l).ne.1) call abort
if (.not.isnan(minval (c, dim = 1, mask = l))) call abort
if (minloc (c, dim = 1, mask = l2).ne.1) call abort
if (.not.isnan(minval (c, dim = 1, mask = l2))) call abort
c(:) = pinf
if (minloc (c, dim = 1, mask = l).ne.1) call abort
if (minval (c, dim = 1, mask = l).ne.pinf) call abort
if (minloc (c, dim = 1, mask = l2).ne.1) call abort
if (minval (c, dim = 1, mask = l2).ne.pinf) call abort
c(1:2) = nan
if (minloc (c, dim = 1, mask = l).ne.3) call abort
if (minval (c, dim = 1, mask = l).ne.pinf) call abort
if (minloc (c, dim = 1, mask = l2).ne.3) call abort
if (minval (c, dim = 1, mask = l2).ne.pinf) call abort
c(2) = 1.0
if (minloc (c, dim = 1, mask = l).ne.2) call abort
if (minval (c, dim = 1, mask = l).ne.1) call abort
if (minloc (c, dim = 1, mask = l2).ne.2) call abort
if (minval (c, dim = 1, mask = l2).ne.1) call abort
c(2) = minf
if (minloc (c, dim = 1, mask = l).ne.2) call abort
if (minval (c, dim = 1, mask = l).ne.minf) call abort
if (minloc (c, dim = 1, mask = l2).ne.2) call abort
if (minval (c, dim = 1, mask = l2).ne.minf) call abort
deallocate (c)
allocate (c(-2:-3))
if (minloc (c, dim = 1).ne.0) call abort
if (minval (c, dim = 1).ne.huge(pinf)) call abort
end
| gpl-2.0 |
techno/gcc-mist32 | gcc/testsuite/gfortran.dg/minlocval_1.f90 | 164 | 6341 | ! { dg-do run }
! { dg-add-options ieee }
! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
real :: a(3), nan, minf, pinf
real, allocatable :: c(:)
logical :: l
logical :: l2(3)
nan = 0.0
minf = 0.0
pinf = 0.0
nan = 0.0/nan
minf = -1.0/minf
pinf = 1.0/pinf
allocate (c(3))
a(:) = nan
if (minloc (a, dim = 1).ne.1) call abort
if (.not.isnan(minval (a, dim = 1))) call abort
a(:) = pinf
if (minloc (a, dim = 1).ne.1) call abort
if (minval (a, dim = 1).ne.pinf) call abort
a(1:2) = nan
if (minloc (a, dim = 1).ne.3) call abort
if (minval (a, dim = 1).ne.pinf) call abort
a(2) = 1.0
if (minloc (a, dim = 1).ne.2) call abort
if (minval (a, dim = 1).ne.1) call abort
a(2) = minf
if (minloc (a, dim = 1).ne.2) call abort
if (minval (a, dim = 1).ne.minf) call abort
c(:) = nan
if (minloc (c, dim = 1).ne.1) call abort
if (.not.isnan(minval (c, dim = 1))) call abort
c(:) = pinf
if (minloc (c, dim = 1).ne.1) call abort
if (minval (c, dim = 1).ne.pinf) call abort
c(1:2) = nan
if (minloc (c, dim = 1).ne.3) call abort
if (minval (c, dim = 1).ne.pinf) call abort
c(2) = 1.0
if (minloc (c, dim = 1).ne.2) call abort
if (minval (c, dim = 1).ne.1) call abort
c(2) = minf
if (minloc (c, dim = 1).ne.2) call abort
if (minval (c, dim = 1).ne.minf) call abort
l = .false.
l2(:) = .false.
a(:) = nan
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(:) = pinf
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(1:2) = nan
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(2) = 1.0
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
a(2) = minf
if (minloc (a, dim = 1, mask = l).ne.0) call abort
if (minval (a, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (a, dim = 1, mask = l2).ne.0) call abort
if (minval (a, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(:) = nan
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(:) = pinf
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(1:2) = nan
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(2) = 1.0
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
c(2) = minf
if (minloc (c, dim = 1, mask = l).ne.0) call abort
if (minval (c, dim = 1, mask = l).ne.huge(pinf)) call abort
if (minloc (c, dim = 1, mask = l2).ne.0) call abort
if (minval (c, dim = 1, mask = l2).ne.huge(pinf)) call abort
l = .true.
l2(:) = .true.
a(:) = nan
if (minloc (a, dim = 1, mask = l).ne.1) call abort
if (.not.isnan(minval (a, dim = 1, mask = l))) call abort
if (minloc (a, dim = 1, mask = l2).ne.1) call abort
if (.not.isnan(minval (a, dim = 1, mask = l2))) call abort
a(:) = pinf
if (minloc (a, dim = 1, mask = l).ne.1) call abort
if (minval (a, dim = 1, mask = l).ne.pinf) call abort
if (minloc (a, dim = 1, mask = l2).ne.1) call abort
if (minval (a, dim = 1, mask = l2).ne.pinf) call abort
a(1:2) = nan
if (minloc (a, dim = 1, mask = l).ne.3) call abort
if (minval (a, dim = 1, mask = l).ne.pinf) call abort
if (minloc (a, dim = 1, mask = l2).ne.3) call abort
if (minval (a, dim = 1, mask = l2).ne.pinf) call abort
a(2) = 1.0
if (minloc (a, dim = 1, mask = l).ne.2) call abort
if (minval (a, dim = 1, mask = l).ne.1) call abort
if (minloc (a, dim = 1, mask = l2).ne.2) call abort
if (minval (a, dim = 1, mask = l2).ne.1) call abort
a(2) = minf
if (minloc (a, dim = 1, mask = l).ne.2) call abort
if (minval (a, dim = 1, mask = l).ne.minf) call abort
if (minloc (a, dim = 1, mask = l2).ne.2) call abort
if (minval (a, dim = 1, mask = l2).ne.minf) call abort
c(:) = nan
if (minloc (c, dim = 1, mask = l).ne.1) call abort
if (.not.isnan(minval (c, dim = 1, mask = l))) call abort
if (minloc (c, dim = 1, mask = l2).ne.1) call abort
if (.not.isnan(minval (c, dim = 1, mask = l2))) call abort
c(:) = pinf
if (minloc (c, dim = 1, mask = l).ne.1) call abort
if (minval (c, dim = 1, mask = l).ne.pinf) call abort
if (minloc (c, dim = 1, mask = l2).ne.1) call abort
if (minval (c, dim = 1, mask = l2).ne.pinf) call abort
c(1:2) = nan
if (minloc (c, dim = 1, mask = l).ne.3) call abort
if (minval (c, dim = 1, mask = l).ne.pinf) call abort
if (minloc (c, dim = 1, mask = l2).ne.3) call abort
if (minval (c, dim = 1, mask = l2).ne.pinf) call abort
c(2) = 1.0
if (minloc (c, dim = 1, mask = l).ne.2) call abort
if (minval (c, dim = 1, mask = l).ne.1) call abort
if (minloc (c, dim = 1, mask = l2).ne.2) call abort
if (minval (c, dim = 1, mask = l2).ne.1) call abort
c(2) = minf
if (minloc (c, dim = 1, mask = l).ne.2) call abort
if (minval (c, dim = 1, mask = l).ne.minf) call abort
if (minloc (c, dim = 1, mask = l2).ne.2) call abort
if (minval (c, dim = 1, mask = l2).ne.minf) call abort
deallocate (c)
allocate (c(-2:-3))
if (minloc (c, dim = 1).ne.0) call abort
if (minval (c, dim = 1).ne.huge(pinf)) call abort
end
| gpl-2.0 |
LucHermitte/ITK | Modules/ThirdParty/Netlib/src/netlib/slatec/dgamr.f | 48 | 1343 | *DECK DGAMR
DOUBLE PRECISION FUNCTION DGAMR (X)
C***BEGIN PROLOGUE DGAMR
C***PURPOSE Compute the reciprocal of the Gamma function.
C***LIBRARY SLATEC (FNLIB)
C***CATEGORY C7A
C***TYPE DOUBLE PRECISION (GAMR-S, DGAMR-D, CGAMR-C)
C***KEYWORDS FNLIB, RECIPROCAL GAMMA FUNCTION, SPECIAL FUNCTIONS
C***AUTHOR Fullerton, W., (LANL)
C***DESCRIPTION
C
C DGAMR(X) calculates the double precision reciprocal of the
C complete Gamma function for double precision argument X.
C
C***REFERENCES (NONE)
C***ROUTINES CALLED DGAMMA, DLGAMS, XERCLR, XGETF, XSETF
C***REVISION HISTORY (YYMMDD)
C 770701 DATE WRITTEN
C 890531 Changed all specific intrinsics to generic. (WRB)
C 890531 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900727 Added EXTERNAL statement. (WRB)
C***END PROLOGUE DGAMR
DOUBLE PRECISION X, ALNGX, SGNGX, DGAMMA
EXTERNAL DGAMMA
C***FIRST EXECUTABLE STATEMENT DGAMR
DGAMR = 0.0D0
IF (X.LE.0.0D0 .AND. AINT(X).EQ.X) RETURN
C
CALL XGETF (IROLD)
CALL XSETF (1)
IF (ABS(X).GT.10.0D0) GO TO 10
DGAMR = 1.0D0/DGAMMA(X)
CALL XERCLR
CALL XSETF (IROLD)
RETURN
C
10 CALL DLGAMS (X, ALNGX, SGNGX)
CALL XERCLR
CALL XSETF (IROLD)
DGAMR = SGNGX * EXP(-ALNGX)
RETURN
C
END
| apache-2.0 |
freedesktop-unofficial-mirror/gstreamer-sdk__gcc | gcc/testsuite/gfortran.dg/c_ptr_tests_14.f90 | 30 | 1423 | ! { dg-do run }
! { dg-options "-fdump-tree-original" }
!
! PR fortran/41298
!
! Check that c_null_ptr default initializer is really applied
module m
use iso_c_binding
type, public :: fgsl_file
type(c_ptr) :: gsl_file = c_null_ptr
type(c_funptr) :: gsl_func = c_null_funptr
type(c_ptr) :: NIptr
type(c_funptr) :: NIfunptr
end type fgsl_file
contains
subroutine sub(aaa,bbb)
type(fgsl_file), intent(out) :: aaa
type(fgsl_file), intent(inout) :: bbb
end subroutine
subroutine proc() bind(C)
end subroutine proc
end module m
program test
use m
implicit none
type(fgsl_file) :: file, noreinit
integer, target :: tgt
call sub(file, noreinit)
if(c_associated(file%gsl_file)) call abort()
if(c_associated(file%gsl_func)) call abort()
file%gsl_file = c_loc(tgt)
file%gsl_func = c_funloc(proc)
call sub(file, noreinit)
if(c_associated(file%gsl_file)) call abort()
if(c_associated(file%gsl_func)) call abort()
end program test
! { dg-final { scan-tree-dump-times "gsl_file = 0B" 1 "original" } }
! { dg-final { scan-tree-dump-times "gsl_func = 0B" 1 "original" } }
! { dg-final { scan-tree-dump-times "NIptr = 0B" 0 "original" } }
! { dg-final { scan-tree-dump-times "NIfunptr = 0B" 0 "original" } }
! { dg-final { scan-tree-dump-times "bbb =" 0 "original" } }
! { dg-final { cleanup-tree-dump "original" } }
! { dg-final { cleanup-modules "m" } }
| gpl-2.0 |
freedesktop-unofficial-mirror/gstreamer-sdk__gcc | gcc/testsuite/gfortran.dg/where_operator_assign_2.f90 | 52 | 3388 | ! { dg-do compile }
! Tests the fix for PR30407, in which operator assignments did not work
! in WHERE blocks or simple WHERE statements.
!
! Contributed by Paul Thomas <pault@gcc.gnu.org>
!******************************************************************************
module global
type :: a
integer :: b
integer :: c
end type a
interface assignment(=)
module procedure a_to_a
end interface
interface operator(.ne.)
module procedure a_ne_a
end interface
type(a) :: x(4), y(4), z(4), u(4, 4)
logical :: l1(4), t = .true., f= .false.
contains
!******************************************************************************
elemental subroutine a_to_a (m, n)
type(a), intent(in) :: n
type(a), intent(out) :: m
m%b = n%b + 1
m%c = n%c
end subroutine a_to_a
!******************************************************************************
elemental logical function a_ne_a (m, n)
type(a), intent(in) :: n
type(a), intent(in) :: m
a_ne_a = (m%b .ne. n%b) .or. (m%c .ne. n%c)
end function a_ne_a
!******************************************************************************
elemental function foo (m)
type(a) :: foo
type(a), intent(in) :: m
foo%b = 0
foo%c = m%c
end function foo
end module global
!******************************************************************************
program test
use global
x = (/a (0, 1),a (0, 2),a (0, 3),a (0, 4)/)
y = x
z = x
l1 = (/t, f, f, t/)
call test_where_1
if (any (y .ne. (/a (2, 1),a (2, 2),a (2, 3),a (2, 4)/))) call abort ()
call test_where_2
if (any (y .ne. (/a (1, 0),a (2, 2),a (2, 3),a (1, 0)/))) call abort ()
if (any (z .ne. (/a (3, 4),a (1, 0),a (1, 0),a (3, 1)/))) call abort ()
call test_where_3
if (any (y .ne. (/a (1, 0),a (1, 2),a (1, 3),a (1, 0)/))) call abort ()
y = x
call test_where_forall_1
if (any (u(4, :) .ne. (/a (1, 4),a (2, 2),a (2, 3),a (1, 4)/))) call abort ()
l1 = (/t, f, t, f/)
call test_where_4
if (any (x .ne. (/a (1, 1),a (2, 1),a (1, 3),a (2, 3)/))) call abort ()
contains
!******************************************************************************
subroutine test_where_1 ! Test a simple WHERE
where (l1) y = x
end subroutine test_where_1
!******************************************************************************
subroutine test_where_2 ! Test a WHERE blocks
where (l1)
y = a (0, 0)
z = z(4:1:-1)
elsewhere
y = x
z = a (0, 0)
end where
end subroutine test_where_2
!******************************************************************************
subroutine test_where_3 ! Test a simple WHERE with a function assignment
where (.not. l1) y = foo (x)
end subroutine test_where_3
!******************************************************************************
subroutine test_where_forall_1 ! Test a WHERE in a FORALL block
forall (i = 1:4)
where (.not. l1)
u(i, :) = x
elsewhere
u(i, :) = a(0, i)
endwhere
end forall
end subroutine test_where_forall_1
!******************************************************************************
subroutine test_where_4 ! Test a WHERE assignment with dependencies
where (l1(1:3))
x(2:4) = x(1:3)
endwhere
end subroutine test_where_4
end program test
! { dg-final { cleanup-modules "global" } }
| gpl-2.0 |
techno/gcc-mist32 | libgfortran/generated/_sinh_r4.F90 | 47 | 1473 | ! Copyright (C) 2002-2015 Free Software Foundation, Inc.
! Contributed by Paul Brook <paul@nowt.org>
!
!This file is part of the GNU Fortran 95 runtime library (libgfortran).
!
!GNU libgfortran 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 3 of the License, or (at your option) any later version.
!GNU libgfortran 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.
!
!Under Section 7 of GPL version 3, you are granted additional
!permissions described in the GCC Runtime Library Exception, version
!3.1, as published by the Free Software Foundation.
!
!You should have received a copy of the GNU General Public License and
!a copy of the GCC Runtime Library Exception along with this program;
!see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
!<http://www.gnu.org/licenses/>.
!
!This file is machine generated.
#include "config.h"
#include "kinds.inc"
#include "c99_protos.inc"
#if defined (HAVE_GFC_REAL_4)
#ifdef HAVE_SINHF
elemental function _gfortran_specific__sinh_r4 (parm)
real (kind=4), intent (in) :: parm
real (kind=4) :: _gfortran_specific__sinh_r4
_gfortran_specific__sinh_r4 = sinh (parm)
end function
#endif
#endif
| gpl-2.0 |
epfl-cosmo/q-e | GWW/gww/para_gww.f90 | 12 | 3927 | !
! Copyright (C) 2001-2013 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!
MODULE para_gww
!this modules contains arrays indicating if the
!processor should perform the task
SAVE
LOGICAL, ALLOCATABLE :: is_my_time(:) !for 2n+1 times and frequencies
LOGICAL :: is_my_last!for extra 0 time calculation
LOGICAL, ALLOCATABLE :: is_my_pola(:) !for 0 to n calculations
LOGICAL, ALLOCATABLE :: is_my_state(:)!for KS states considered 1 to n_max
LOGICAL, ALLOCATABLE :: is_my_state_range(:)!for KS states considered i_min to i_max
CONTAINS
subroutine free_memory_para_gww
implicit none
if(allocated(is_my_time)) deallocate(is_my_time)
if(allocated(is_my_pola)) deallocate(is_my_pola)
if(allocated(is_my_state)) deallocate(is_my_state)
if(allocated(is_my_state_range)) deallocate(is_my_state_range)
return
end subroutine free_memory_para_gww
SUBROUTINE setup_para_gww(ntimes,nstates, i_min, i_max)
!this subroutine initialize the para variables for the gww
!calculation, parallelization is achieved on imaginary times
!and frequencies
USE mp_world, ONLY : mpime, nproc
USE io_global, ONLY : stdout
implicit none
INTEGER, INTENT(in) :: ntimes!number of time samples
INTEGER, INTENT(in) :: nstates!max number of states
INTEGER, INTENT(in) :: i_min!lowest state for which the self-energy is calculated
INTEGER, INTENT(in) :: i_max!upper state for which the self-energy is calculated
INTEGER :: ndelta, it, ip, iqq
!allocates arrays
allocate(is_my_time(-ntimes:ntimes))
allocate(is_my_pola(0:ntimes))
allocate(is_my_state(nstates))
allocate(is_my_state_range(i_min:i_max))
is_my_time(:)=.false.
is_my_pola(:)=.false.
is_my_state(:)=.false.
is_my_state_range(:)=.false.
ndelta=(2*ntimes+1)/nproc
if(ndelta*nproc < (2*ntimes+1)) ndelta=ndelta+1
iqq=-ntimes
do ip=0,nproc-1
do it=1,ndelta
if(iqq <= ntimes.and.(mpime==ip)) then
is_my_time(iqq)=.true.
endif
if(it==1.and.(mpime==ip)) write(stdout,*) 'min', iqq, ip,it,ndelta
if(it==ndelta.and.(mpime==ip)) write(stdout,*) 'max', iqq, ip,it,ndelta
iqq=iqq+1
enddo
enddo
if((mpime+1)==nproc) then
is_my_last=.true.
else
is_my_last=.false.
endif
ndelta=(ntimes+1)/nproc
if(ndelta*nproc < (ntimes+1)) ndelta=ndelta+1
iqq=0
do ip=0,nproc-1
do it=1,ndelta
if(iqq <= ntimes.and.(mpime==ip)) then
is_my_pola(iqq)=.true.
endif
if(it==1.and.(mpime==ip)) write(stdout,*) 'min pola', iqq
if(it==ndelta.and.(mpime==ip)) write(stdout,*) 'max pola', iqq
iqq=iqq+1
enddo
enddo
ndelta=(nstates)/nproc
if(ndelta*nproc < nstates) ndelta=ndelta+1
iqq=1
do ip=0,nproc-1
do it=1,ndelta
if(iqq <= nstates.and.(mpime==ip)) then
is_my_state(iqq)=.true.
endif
if(it==1.and.(mpime==ip)) write(stdout,*) 'min state', iqq
if(it==ndelta.and.(mpime==ip)) write(stdout,*) 'max state', iqq
iqq=iqq+1
enddo
enddo
ndelta=(i_max-i_min+1)/nproc
if(ndelta*nproc < (i_max-i_min+1)) ndelta=ndelta+1
iqq=1
do ip=0,nproc-1
do it=1,ndelta
if(iqq <= (i_max-i_min+1).and.(mpime==ip)) then
is_my_state_range(iqq+i_min-1)=.true.
endif
if(it==1.and.(mpime==ip)) write(stdout,*) 'min state range', iqq +i_min-1
if(it==ndelta.and.(mpime==ip)) write(stdout,*) 'max state range', iqq+i_min-1
iqq=iqq+1
enddo
enddo
return
END SUBROUTINE setup_para_gww
END MODULE para_gww
| gpl-2.0 |
prool/ccx_prool | ARPACK_i8/LAPACK/dlartg.f | 12 | 3969 | SUBROUTINE DLARTG( F, G, CS, SN, R )
*
* -- LAPACK auxiliary routine (version 2.0) --
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
* Courant Institute, Argonne National Lab, and Rice University
* September 30, 1994
*
* .. Scalar Arguments ..
DOUBLE PRECISION CS, F, G, R, SN
* ..
*
* Purpose
* =======
*
* DLARTG generate a plane rotation so that
*
* [ CS SN ] . [ F ] = [ R ] where CS**2 + SN**2 = 1.
* [ -SN CS ] [ G ] [ 0 ]
*
* This is a slower, more accurate version of the BLAS1 routine DROTG,
* with the following other differences:
* F and G are unchanged on return.
* If G=0, then CS=1 and SN=0.
* If F=0 and (G .ne. 0), then CS=0 and SN=1 without doing any
* floating point operations (saves work in DBDSQR when
* there are zeros on the diagonal).
*
* If F exceeds G in magnitude, CS will be positive.
*
* Arguments
* =========
*
* F (input) DOUBLE PRECISION
* The first component of vector to be rotated.
*
* G (input) DOUBLE PRECISION
* The second component of vector to be rotated.
*
* CS (output) DOUBLE PRECISION
* The cosine of the rotation.
*
* SN (output) DOUBLE PRECISION
* The sine of the rotation.
*
* R (output) DOUBLE PRECISION
* The nonzero component of the rotated vector.
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO
PARAMETER ( ZERO = 0.0D0 )
DOUBLE PRECISION ONE
PARAMETER ( ONE = 1.0D0 )
DOUBLE PRECISION TWO
PARAMETER ( TWO = 2.0D0 )
* ..
* .. Local Scalars ..
LOGICAL FIRST
INTEGER COUNT, I
DOUBLE PRECISION EPS, F1, G1, SAFMIN, SAFMN2, SAFMX2, SCALE
* ..
* .. External Functions ..
DOUBLE PRECISION DLAMCH
EXTERNAL DLAMCH
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, INT, LOG, MAX, SQRT
* ..
* .. Save statement ..
SAVE FIRST, SAFMX2, SAFMIN, SAFMN2
* ..
* .. Data statements ..
DATA FIRST / .TRUE. /
* ..
* .. Executable Statements ..
*
IF( FIRST ) THEN
FIRST = .FALSE.
SAFMIN = DLAMCH( 'S' )
EPS = DLAMCH( 'E' )
SAFMN2 = DLAMCH( 'B' )**INT( LOG( SAFMIN / EPS ) /
$ LOG( DLAMCH( 'B' ) ) / TWO )
SAFMX2 = ONE / SAFMN2
END IF
IF( G.EQ.ZERO ) THEN
CS = ONE
SN = ZERO
R = F
ELSE IF( F.EQ.ZERO ) THEN
CS = ZERO
SN = ONE
R = G
ELSE
F1 = F
G1 = G
SCALE = MAX( ABS( F1 ), ABS( G1 ) )
IF( SCALE.GE.SAFMX2 ) THEN
COUNT = 0
10 CONTINUE
COUNT = COUNT + 1
F1 = F1*SAFMN2
G1 = G1*SAFMN2
SCALE = MAX( ABS( F1 ), ABS( G1 ) )
IF( SCALE.GE.SAFMX2 )
$ GO TO 10
R = SQRT( F1**2+G1**2 )
CS = F1 / R
SN = G1 / R
DO 20 I = 1, COUNT
R = R*SAFMX2
20 CONTINUE
ELSE IF( SCALE.LE.SAFMN2 ) THEN
COUNT = 0
30 CONTINUE
COUNT = COUNT + 1
F1 = F1*SAFMX2
G1 = G1*SAFMX2
SCALE = MAX( ABS( F1 ), ABS( G1 ) )
IF( SCALE.LE.SAFMN2 )
$ GO TO 30
R = SQRT( F1**2+G1**2 )
CS = F1 / R
SN = G1 / R
DO 40 I = 1, COUNT
R = R*SAFMN2
40 CONTINUE
ELSE
R = SQRT( F1**2+G1**2 )
CS = F1 / R
SN = G1 / R
END IF
IF( ABS( F ).GT.ABS( G ) .AND. CS.LT.ZERO ) THEN
CS = -CS
SN = -SN
R = -R
END IF
END IF
RETURN
*
* End of DLARTG
*
END
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.10/src/rcavi.f | 4 | 2496 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 rcavi(node1,node2,nodem,nelem,lakon,kon,ipkon,
& nactdog,identity,ielprop,prop,iflag,v,xflow,f,
& nodef,idirf,df,cp,R,physcon,dvi,numf,set,mi,iaxial)
!
! rotating cavity element
!
! author: Yannick Muller
!
implicit none
!
logical identity
character*8 lakon(*)
character*81 set(*)
!
integer nelem,nactdog(0:3,*),node1,node2,nodem,numf,
& ielprop(*),nodef(4),idirf(4),index,iflag,mi(*),
& inv,ipkon(*),kon(*),kgas,nelem_in,nelem_out,iaxial,
& element0,node10,node20,node11,node21,node12,node22,node_cav,
& node_main,node_main2,node_in1,node_out1,node_in2,node_out2
!
real*8 prop(*),v(0:mi(2),*),xflow,f,df(4),kappa,R,a,d,
& p1,p2,T1,T2,Aeff,C1,C2,C3,cd,cp,physcon(3),p2p1,km1,dvi,
& kp1,kdkm1,tdkp1,km1dk,x,y,ca1,cb1,ca2,cb2,dT1,alambda,
& reynolds,pi,xflow_oil,s,Tcav,pcav,pmin,pmax,
& Tref,Alpha1, Alpha2, Alpha3, GF,kf,MRTAP_ref_ein,
& MRTAP_ref_aus, m_ref_ein, m_ref_aus,maus_zu_mref,
& mein_zu_mref, A_aus, A_ein, A_ges,m_aus, m_ein, m_sperr
!
pi=4.d0*datan(1.d0)
if (iflag.eq.0) then
identity=.true.
!
if(nactdog(2,node1).ne.0)then
identity=.false.
elseif(nactdog(2,node2).ne.0)then
identity=.false.
elseif(nactdog(1,nodem).ne.0)then
identity=.false.
endif
!
elseif (iflag.eq.1) then
!
p1=v(2,node1)
call rcavi_cp_lt(xflow)
call rcavi_cp_nt(xflow)
elseif (iflag.eq.2) then
!
elseif (iflag.eq.3) then
!
endif
return
end
| gpl-2.0 |
epfl-cosmo/q-e | atomic/src/dvex.f90 | 16 | 1906 | !--------------------------------------------------------------------
subroutine dvex(nu,dvy)
!--------------------------------------------------------------------
!
USE kinds, ONLY: DP
USE constants, ONLY: e2
USE ld1inc, ONLY: nwf, psi, ll, oc, sl3, nspin, isw, grid
use radial_grids, only: ndmx, hartree
implicit none
!
! I/O variables
!
integer :: nu
real (DP) :: dvy(ndmx)
!
! local variables
!
integer :: i, mu, l0, l1, l2, l3
real (DP) :: wrk(ndmx), wrk1(ndmx)
real (DP) :: fac, sss, ocs, doc, half
!
do i=1,grid%mesh
dvy(i)=0.0d0
end do
l1 = ll(nu)
half = 2.d0 * l1 + 1.d0
do mu=1,nwf
!
! only wfc with the same spin contribute to exchange term
!
if (isw(mu) /= isw(nu) ) cycle
ocs = oc(mu) * (0.5d0 * nspin)
! write (*,*) mu, oc(mu), ocs
if ( mu == nu ) then
doc = 0.d0
if( (l1 /= 0) .and. (ocs > 0.d0) ) then
i = int(ocs)
doc = (i*(2.d0*ocs-i-1.d0)/(half-1.d0) - ocs*ocs/half) * half/ocs
end if
ocs = ocs + doc
! if (doc /= 0.d0) write (*,*) "DOC ",nu, doc
end if
!
l2 = ll(mu)
l0=abs(l1-l2)
do i=1,grid%mesh
wrk(i) = psi(i,1,mu)*psi(i,1,nu)
end do
do l3=l0,l1+l2
sss = sl3(l1,l2,l3)
! write (*,*) l1,l2,l3,sss
if (abs(sss).gt.1.0d-10) then
call hartree(l3,l1+l2+2,grid%mesh,grid,wrk,wrk1)
fac =-e2*ocs*sss/2.0d0
do i=1,grid%mesh
dvy(i)= dvy(i) + fac*wrk1(i)*psi(i,1,mu)
end do
end if
end do
!- spurious hartree part
if (mu == nu ) then
call hartree(0,2,grid%mesh,grid,wrk,wrk1)
fac = doc*e2
do i=1,grid%mesh
dvy(i)= dvy(i) + fac*wrk1(i)*psi(i,1,mu)
end do
end if
end do
return
end subroutine dvex
| gpl-2.0 |
LucHermitte/ITK | Modules/ThirdParty/VNL/src/vxl/v3p/netlib/eispack/balbak.f | 41 | 2307 | subroutine balbak(nm,n,low,igh,scale,m,z)
c
integer i,j,k,m,n,ii,nm,igh,low
double precision scale(n),z(nm,m)
double precision s
c
c this subroutine is a translation of the algol procedure balbak,
c num. math. 13, 293-304(1969) by parlett and reinsch.
c handbook for auto. comp., vol.ii-linear algebra, 315-326(1971).
c
c this subroutine forms the eigenvectors of a real general
c matrix by back transforming those of the corresponding
c balanced matrix determined by balanc.
c
c on input
c
c nm must be set to the row dimension of two-dimensional
c array parameters as declared in the calling program
c dimension statement.
c
c n is the order of the matrix.
c
c low and igh are integers determined by balanc.
c
c scale contains information determining the permutations
c and scaling factors used by balanc.
c
c m is the number of columns of z to be back transformed.
c
c z contains the real and imaginary parts of the eigen-
c vectors to be back transformed in its first m columns.
c
c on output
c
c z contains the real and imaginary parts of the
c transformed eigenvectors in its first m columns.
c
c questions and comments should be directed to burton s. garbow,
c mathematics and computer science div, argonne national laboratory
c
c this version dated august 1983.
c
c ------------------------------------------------------------------
c
if (m .eq. 0) go to 200
if (igh .eq. low) go to 120
c
do 110 i = low, igh
s = scale(i)
c .......... left hand eigenvectors are back transformed
c if the foregoing statement is replaced by
c s=1.0d0/scale(i). ..........
do 100 j = 1, m
100 z(i,j) = z(i,j) * s
c
110 continue
c ......... for i=low-1 step -1 until 1,
c igh+1 step 1 until n do -- ..........
120 do 140 ii = 1, n
i = ii
if (i .ge. low .and. i .le. igh) go to 140
if (i .lt. low) i = low - ii
k = scale(i)
if (k .eq. i) go to 140
c
do 130 j = 1, m
s = z(i,j)
z(i,j) = z(k,j)
z(k,j) = s
130 continue
c
140 continue
c
200 return
end
| apache-2.0 |
techno/gcc-mist32 | libgomp/testsuite/libgomp.fortran/examples-4/e.50.4.f90 | 74 | 1424 | ! { dg-do run }
module e_50_4_mod
contains
subroutine init (v1, v2, N)
integer :: i, N
real, pointer, dimension(:) :: v1, v2
do i = 1, N
v1(i) = i + 2.0
v2(i) = i - 3.0
end do
end subroutine
subroutine check (p, N)
integer :: i, N
real, parameter :: EPS = 0.00001
real, pointer, dimension(:) :: p
do i = 1, N
diff = p(i) - (i + 2.0) * (i - 3.0)
if (diff > EPS .or. -diff > EPS) call abort
end do
end subroutine
subroutine vec_mult_1 (p, v1, v2, N)
integer :: i, N
real, pointer, dimension(:) :: p, v1, v2
!$omp target map(to: v1(1:N), v2(:N)) map(from: p(1:N))
!$omp parallel do
do i = 1, N
p(i) = v1(i) * v2(i)
end do
!$omp end target
end subroutine
subroutine vec_mult_2 (p, v1, v2, N)
real, dimension(*) :: p, v1, v2
integer :: i, N
!$omp target map(to: v1(1:N), v2(:N)) map(from: p(1:N))
!$omp parallel do
do i = 1, N
p(i) = v1(i) * v2(i)
end do
!$omp end target
end subroutine
end module
program e_50_4
use e_50_4_mod, only : init, check, vec_mult_1, vec_mult_2
real, pointer, dimension(:) :: p1, p2, v1, v2
integer :: n
n = 1000
allocate (p1(n), p2(n), v1(n), v2(n))
call init (v1, v2, n)
call vec_mult_1 (p1, v1, v2, n)
call vec_mult_2 (p2, v1, v2, n)
call check (p1, N)
call check (p2, N)
deallocate (p1, p2, v1, v2)
end program
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.10/src/nidentll.f | 6 | 1352 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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.
!
! this routine is identical to ident except that x and px are
! integer*8
!
! identifies the position id of px in an ordered array
! x of integers;
!
! id is such that x(id).le.px and x(id+1).gt.px
!
subroutine nidentll(x,px,n,id)
implicit none
integer n,id,n2,m
integer*8 x,px
dimension x(n)
id=0
if(n.eq.0) return
n2=n+1
do
m=(n2+id)/2
if(px.ge.x(m)) then
id=m
else
n2=m
endif
if((n2-id).eq.1) return
enddo
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.9/src/nidentll.f | 6 | 1352 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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.
!
! this routine is identical to ident except that x and px are
! integer*8
!
! identifies the position id of px in an ordered array
! x of integers;
!
! id is such that x(id).le.px and x(id+1).gt.px
!
subroutine nidentll(x,px,n,id)
implicit none
integer n,id,n2,m
integer*8 x,px
dimension x(n)
id=0
if(n.eq.0) return
n2=n+1
do
m=(n2+id)/2
if(px.ge.x(m)) then
id=m
else
n2=m
endif
if((n2-id).eq.1) return
enddo
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.16/src/extfacepernode.f | 1 | 2264 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2019 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 extfacepernode(iponoelfa,inoelfa,lakonfa,ipkonfa,
& konfa,nsurfs,inoelsize)
!
implicit none
!
character*8 lakonfa(*)
!
integer iponoelfa(*),inoelfa(3,*),ipkonfa(*),konfa(*),i,j,nsurfs,
& inoelfree,nope,indexe,node,inoelsize
!
intent(in) lakonfa,ipkonfa,konfa,nsurfs
!
intent(inout) iponoelfa,inoelfa,inoelsize
!
! lists which external faces correspond to a given node i
! iponoelfa(i) points to an entry j in field inoelfa where:
! inoelfa(1,j): face number as catalogued in fields konfa, lakonfa
! inoelfa(2,j): local node number in the topology description
! inoelfa(3,j): pointer to the next face to which i belongs, or, if
! none is left: zero
!
inoelfree=1
do i=1,nsurfs
if(ipkonfa(i).lt.0) cycle
if(lakonfa(i)(2:2).eq.'8') then
nope=8
elseif(lakonfa(i)(2:2).eq.'4') then
nope=4
elseif(lakonfa(i)(2:2).eq.'6') then
nope=6
elseif(lakonfa(i)(2:2).eq.'3') then
nope=3
endif
indexe=ipkonfa(i)
do j=1,nope
node=konfa(indexe+j)
inoelfa(1,inoelfree)=i
inoelfa(2,inoelfree)=j
inoelfa(3,inoelfree)=iponoelfa(node)
iponoelfa(node)=inoelfree
inoelfree=inoelfree+1
enddo
enddo
!
! size of field inoelfa
!
inoelsize=inoelfree-1
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.17/src/umat.f | 2 | 2859 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2020 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 umat(stress,statev,ddsdde,sse,spd,scd,
& rpl,ddsddt,drplde,drpldt,
& stran,dstran,time,dtime,temp,dtemp,predef,dpred,cmname,
& ndi,nshr,ntens,nstatv,props,nprops,coords,drot,pnewdt,
& celent,dfgrd0,dfgrd1,noel,npt,layer,kspt,kstep,kinc)
!
! here, an ABAQUS umat routine can be inserted
!
! note that reals should be double precision (REAL*8)
!
implicit none
!
character*80 cmname
!
integer ndi,nshr,ntens,nstatv,nprops,noel,npt,layer,kspt,
& kstep,kinc
!
real*8 stress(ntens),statev(nstatv),
& ddsdde(ntens,ntens),ddsddt(ntens),drplde(ntens),
& stran(ntens),dstran(ntens),time(2),celent,
& props(nprops),coords(3),drot(3,3),dfgrd0(3,3),dfgrd1(3,3),
& sse,spd,scd,rpl,drpldt,dtime,temp,dtemp,predef,dpred,
& pnewdt
!
! START EXAMPLE LINEAR ELASTIC MATERIAL
!
integer i,j
real*8 e,un,al,um,am1,am2
!
c write(*,*) 'noel,npt ',noel,npt
c write(*,*) 'stress ',(stress(i),i=1,6)
c write(*,*) 'stran ',(stran(i),i=1,6)
c write(*,*) 'dstran ',(dstran(i),i=1,6)
c write(*,*) 'drot ',((drot(i,j),i=1,3),j=1,3)
e=props(1)
un=props(2)
al=un*e/(1.d0+un)/(1.d0-2.d0*un)
um=e/2.d0/(1.d0+un)
am1=al+2.d0*um
am2=um
!
! stress
!
stress(1)=stress(1)+am1*dstran(1)+al*(dstran(2)+dstran(3))
stress(2)=stress(2)+am1*dstran(2)+al*(dstran(1)+dstran(3))
stress(3)=stress(3)+am1*dstran(3)+al*(dstran(1)+dstran(2))
stress(4)=stress(4)+am2*dstran(4)
stress(5)=stress(5)+am2*dstran(5)
stress(6)=stress(6)+am2*dstran(6)
!
! stiffness
!
do i=1,6
do j=1,6
ddsdde(i,j)=0.d0
enddo
enddo
ddsdde(1,1)=al+2.d0*um
ddsdde(1,2)=al
ddsdde(2,1)=al
ddsdde(2,2)=al+2.d0*um
ddsdde(1,3)=al
ddsdde(3,1)=al
ddsdde(2,3)=al
ddsdde(3,2)=al
ddsdde(3,3)=al+2.d0*um
ddsdde(4,4)=um
ddsdde(5,5)=um
ddsdde(6,6)=um
!
! END EXAMPLE LINEAR ELASTIC MATERIAL
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.8p2/src/noanalysiss.f | 6 | 1573 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 noanalysiss(inpc,textpart,nmethod,iperturb,istep,
& istat,n,iline,ipol,inl,ipoinp,inp,ipoinpc,tper)
!
! reading the input deck: *NO ANALYSIS
!
implicit none
!
character*1 inpc(*)
character*132 textpart(16)
!
integer nmethod,iperturb,istep,istat,n,key,iline,ipol,inl,
& ipoinp(2,*),inp(3,*),ipoinpc(0:*)
!
real*8 tper
!
if(istep.lt.1) then
write(*,*)'*ERROR in noanalysis: *NO ANALYSIS can only be used'
write(*,*) ' within a STEP'
call exit(201)
endif
!
write(*,*) '*WARNING: no analysis option was chosen'
!
nmethod=0
iperturb=0
tper=1.d0
!
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/noanalysiss.f | 6 | 1573 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 noanalysiss(inpc,textpart,nmethod,iperturb,istep,
& istat,n,iline,ipol,inl,ipoinp,inp,ipoinpc,tper)
!
! reading the input deck: *NO ANALYSIS
!
implicit none
!
character*1 inpc(*)
character*132 textpart(16)
!
integer nmethod,iperturb,istep,istat,n,key,iline,ipol,inl,
& ipoinp(2,*),inp(3,*),ipoinpc(0:*)
!
real*8 tper
!
if(istep.lt.1) then
write(*,*)'*ERROR in noanalysis: *NO ANALYSIS can only be used'
write(*,*) ' within a STEP'
call exit(201)
endif
!
write(*,*) '*WARNING: no analysis option was chosen'
!
nmethod=0
iperturb=0
tper=1.d0
!
call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
& ipoinp,inp,ipoinpc)
!
return
end
| gpl-2.0 |
sally-xiyue/pycles | RRTMG/sw/modules/rrsw_ncpar.f90 | 19 | 3966 | module rrsw_ncpar
use parkind ,only : im => kind_im, rb => kind_rb
implicit none
save
real(kind=rb), parameter :: cpdair = 1003.5 ! Specific heat capacity of dry air
! at constant pressure at 273 K
! (J kg-1 K-1)
integer(kind=im), dimension(50) :: status
integer(kind=im) :: i
integer(kind=im), parameter :: keylower = 9, &
keyupper = 5, &
Tdiff = 5, &
ps = 59, &
plower = 13, &
pupper = 47, &
Tself = 10, &
Tforeignlower = 3, &
Tforeignupper = 2, &
pforeign = 4, &
T = 19, &
band = 14, &
GPoint = 16, &
GPointSet = 2
integer(kind=im), parameter :: maxAbsorberNameLength = 5, &
Absorber = 12, &
maxKeySpeciesNameLength = 3, &
maxKeySpeciesNames = 2
character(len = maxAbsorberNameLength), dimension(Absorber), parameter :: &
AbsorberNames = (/ &
'N2 ', &
'CCL4 ', &
'CFC11', &
'CFC12', &
'CFC22', &
'H2O ', &
'CO2 ', &
'O3 ', &
'N2O ', &
'CO ', &
'CH4 ', &
'O2 ' /)
character(len = maxKeySpeciesNameLength), dimension(band,maxKeySpeciesNames), parameter :: &
KeySpeciesNamesLower = RESHAPE( SOURCE = (/ 'H2O', 'H2O', 'H2O', 'H2O', 'H2O', 'H2O', 'H2O', &
'H2O', 'H2O', 'H2O', ' ', 'O3 ', 'O3 ', 'H2O', &
'CH4', 'CO2', 'CH4', 'CO2', ' ', 'CO2', 'O2 ', &
' ', 'O2 ', ' ', ' ', ' ', 'O2 ', ' ' /), &
SHAPE = (/ band, maxKeySpeciesNames /) )
character(len = maxKeySpeciesNameLength), dimension(band,maxKeySpeciesNames), parameter :: &
KeySpeciesNamesUpper = RESHAPE( SOURCE = (/ 'CH4', 'H2O', 'CH4', 'CO2', 'H2O', 'H2O', 'O2 ', &
' ', 'O2 ', ' ', ' ', 'O3 ', 'O3 ', 'CO2', &
' ', 'CO2', ' ', ' ', ' ', 'CO2', ' ', &
' ', ' ', ' ', ' ', ' ', 'O2 ', ' ' /), &
SHAPE = (/ band, maxKeySpeciesNames /) )
integer(kind=im), dimension(band) :: BandNums = (/ 16, 17, 18, 19, 20, 21, 22, &
23, 24, 25, 26, 27, 28, 29 /)
real(kind=rb), dimension(keylower) :: KeySpeciesLower = (/ 1.0, 0.125, 0.25, 0.375, &
0.50, 0.625, 0.75, 0.875, 1.0 /)
real(kind=rb), dimension(keyupper) :: KeySpeciesUpper = (/ 0.0, 0.25, 0.50, 0.75, 1.0 /)
real(kind=rb), dimension(Tdiff) :: TempDiffs = (/ -30, -15, 0, 15, 30 /)
real(kind=rb), dimension(Tself) :: TempSelf = (/ 245.6,252.8,260.0,267.2,274.4, &
281.6,288.8,296.0,303.2,310.4 /)
real(kind=rb), dimension(Tforeignlower) :: TempForeignlower = (/ 296, 260, 224 /)
real(kind=rb), dimension(Tforeignupper) :: TempForeignupper = (/ 224, 260 /)
real(kind=rb), dimension(pforeign) :: PressForeign = (/ 970, 475, 219, 3 /)
real(kind=rb), dimension(T) :: Temp = (/188.0, 195.2, 202.4, 209.6, 216.8, 224.0, &
231.2, 238.4, 245.6, 252.8, 260.0, 267.2, &
274.4, 281.6, 288.8, 296.0, 303.2, 310.4, 317.6 /)
contains
subroutine getAbsorberIndex(AbsorberName,AbsorberIndex)
character(len = *), intent(in) :: AbsorberName
integer(kind=im), intent(out) :: AbsorberIndex
integer(kind=im) :: m
AbsorberIndex = -1
do m = 1, Absorber
if (trim(AbsorberNames(m)) == trim(AbsorberName)) then
AbsorberIndex = m
end if
end do
if (AbsorberIndex == -1) then
print*, "Absorber name index lookup failed."
end if
end subroutine getAbsorberIndex
end module rrsw_ncpar
| gpl-3.0 |
prool/ccx_prool | CalculiX/ccx_2.11/src/mafillpbc.f | 3 | 1789 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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 mafillpbc(nef,au,ad,jq,irow,
& b,iatleastonepressurebc,nzs)
!
! filling the lhs and rhs to calculate p
!
implicit none
!
integer i,nef,irow(*),jq(*),iatleastonepressurebc,nzs
!
real*8 ad(*),au(*),b(*)
!
! at least one pressure bc is needed. If none is applied,
! the last dof is set to 0
!
! a pressure bc is only recognized if not all velocity degrees of
! freedom are prescribed on the same face
!
c write(*,*) 'mafillpbc', iatleastonepressurebc
if(iatleastonepressurebc.eq.0) then
ad(nef)=1.d0
b(nef)=0.d0
do i=2,nef
if(jq(i)-1>0) then
if(irow(jq(i)-1).eq.nef) then
au(jq(i)-1)=0.d0
endif
endif
enddo
endif
!
c do i=1,nzs
c write(*,*) 'mafillp irow,au',i,au(i)
c enddo
c do i=1,nef
c write(*,*) 'mafillp ad b',i,ad(i),b(i)
c enddo
!
return
end
| gpl-2.0 |
prool/ccx_prool | CalculiX/ccx_2.12/src/pk_cdi_r.f | 6 | 1261 | !
! CalculiX - A 3-dimensional finite element program
! Copyright (C) 1998-2015 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.
!
! cd inncompressible fro thin orifices with corner radiusing (eq 5)
!
! author: Yannick Muller
!
subroutine pk_cdi_r (rqd,reynolds,beta,cdi_r)
!
implicit none
!
real*8 rqd,reynolds,beta,cdi_r,frqd,cdi_se,cdi_noz
!
call pk_cdi_noz(reynolds,cdi_noz)
call pk_cdi_se(reynolds,beta,cdi_se)
frqd=0.008d0+0.992d0*exp(-5.5d0*rqd-3.5d0*rqd**2.d0)
!
cdi_r=cdi_noz-frqd*(cdi_noz-cdi_se)
!
return
end
| gpl-2.0 |
prool/ccx_prool | ARPACK/LAPACK/dlaexc.f | 7 | 10799 | SUBROUTINE DLAEXC( WANTQ, N, T, LDT, Q, LDQ, J1, N1, N2, WORK,
$ INFO )
*
* -- LAPACK auxiliary routine (version 2.0) --
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
* Courant Institute, Argonne National Lab, and Rice University
* February 29, 1992
*
* .. Scalar Arguments ..
LOGICAL WANTQ
INTEGER INFO, J1, LDQ, LDT, N, N1, N2
* ..
* .. Array Arguments ..
DOUBLE PRECISION Q( LDQ, * ), T( LDT, * ), WORK( * )
* ..
*
* Purpose
* =======
*
* DLAEXC swaps adjacent diagonal blocks T11 and T22 of order 1 or 2 in
* an upper quasi-triangular matrix T by an orthogonal similarity
* transformation.
*
* T must be in Schur canonical form, that is, block upper triangular
* with 1-by-1 and 2-by-2 diagonal blocks; each 2-by-2 diagonal block
* has its diagonal elemnts equal and its off-diagonal elements of
* opposite sign.
*
* Arguments
* =========
*
* WANTQ (input) LOGICAL
* = .TRUE. : accumulate the transformation in the matrix Q;
* = .FALSE.: do not accumulate the transformation.
*
* N (input) INTEGER
* The order of the matrix T. N >= 0.
*
* T (input/output) DOUBLE PRECISION array, dimension (LDT,N)
* On entry, the upper quasi-triangular matrix T, in Schur
* canonical form.
* On exit, the updated matrix T, again in Schur canonical form.
*
* LDT (input) INTEGER
* The leading dimension of the array T. LDT >= max(1,N).
*
* Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N)
* On entry, if WANTQ is .TRUE., the orthogonal matrix Q.
* On exit, if WANTQ is .TRUE., the updated matrix Q.
* If WANTQ is .FALSE., Q is not referenced.
*
* LDQ (input) INTEGER
* The leading dimension of the array Q.
* LDQ >= 1; and if WANTQ is .TRUE., LDQ >= N.
*
* J1 (input) INTEGER
* The index of the first row of the first block T11.
*
* N1 (input) INTEGER
* The order of the first block T11. N1 = 0, 1 or 2.
*
* N2 (input) INTEGER
* The order of the second block T22. N2 = 0, 1 or 2.
*
* WORK (workspace) DOUBLE PRECISION array, dimension (N)
*
* INFO (output) INTEGER
* = 0: successful exit
* = 1: the transformed matrix T would be too far from Schur
* form; the blocks are not swapped and T and Q are
* unchanged.
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
DOUBLE PRECISION TEN
PARAMETER ( TEN = 1.0D+1 )
INTEGER LDD, LDX
PARAMETER ( LDD = 4, LDX = 2 )
* ..
* .. Local Scalars ..
INTEGER IERR, J2, J3, J4, K, ND
DOUBLE PRECISION CS, DNORM, EPS, SCALE, SMLNUM, SN, T11, T22,
$ T33, TAU, TAU1, TAU2, TEMP, THRESH, WI1, WI2,
$ WR1, WR2, XNORM
* ..
* .. Local Arrays ..
DOUBLE PRECISION D( LDD, 4 ), U( 3 ), U1( 3 ), U2( 3 ),
$ X( LDX, 2 )
* ..
* .. External Functions ..
DOUBLE PRECISION DLAMCH, DLANGE
EXTERNAL DLAMCH, DLANGE
* ..
* .. External Subroutines ..
EXTERNAL DLACPY, DLANV2, DLARFG, DLARFX, DLARTG, DLASY2,
$ DROT
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, MAX
* ..
* .. Executable Statements ..
*
INFO = 0
*
* Quick return if possible
*
IF( N.EQ.0 .OR. N1.EQ.0 .OR. N2.EQ.0 )
$ RETURN
IF( J1+N1.GT.N )
$ RETURN
*
J2 = J1 + 1
J3 = J1 + 2
J4 = J1 + 3
*
IF( N1.EQ.1 .AND. N2.EQ.1 ) THEN
*
* Swap two 1-by-1 blocks.
*
T11 = T( J1, J1 )
T22 = T( J2, J2 )
*
* Determine the transformation to perform the interchange.
*
CALL DLARTG( T( J1, J2 ), T22-T11, CS, SN, TEMP )
*
* Apply transformation to the matrix T.
*
IF( J3.LE.N )
$ CALL DROT( N-J1-1, T( J1, J3 ), LDT, T( J2, J3 ), LDT, CS,
$ SN )
CALL DROT( J1-1, T( 1, J1 ), 1, T( 1, J2 ), 1, CS, SN )
*
T( J1, J1 ) = T22
T( J2, J2 ) = T11
*
IF( WANTQ ) THEN
*
* Accumulate transformation in the matrix Q.
*
CALL DROT( N, Q( 1, J1 ), 1, Q( 1, J2 ), 1, CS, SN )
END IF
*
ELSE
*
* Swapping involves at least one 2-by-2 block.
*
* Copy the diagonal block of order N1+N2 to the local array D
* and compute its norm.
*
ND = N1 + N2
CALL DLACPY( 'Full', ND, ND, T( J1, J1 ), LDT, D, LDD )
DNORM = DLANGE( 'Max', ND, ND, D, LDD, WORK )
*
* Compute machine-dependent threshold for test for accepting
* swap.
*
EPS = DLAMCH( 'P' )
SMLNUM = DLAMCH( 'S' ) / EPS
THRESH = MAX( TEN*EPS*DNORM, SMLNUM )
*
* Solve T11*X - X*T22 = scale*T12 for X.
*
CALL DLASY2( .FALSE., .FALSE., -1, N1, N2, D, LDD,
$ D( N1+1, N1+1 ), LDD, D( 1, N1+1 ), LDD, SCALE, X,
$ LDX, XNORM, IERR )
*
* Swap the adjacent diagonal blocks.
*
K = N1 + N1 + N2 - 3
GO TO ( 10, 20, 30 )K
*
10 CONTINUE
*
* N1 = 1, N2 = 2: generate elementary reflector H so that:
*
* ( scale, X11, X12 ) H = ( 0, 0, * )
*
U( 1 ) = SCALE
U( 2 ) = X( 1, 1 )
U( 3 ) = X( 1, 2 )
CALL DLARFG( 3, U( 3 ), U, 1, TAU )
U( 3 ) = ONE
T11 = T( J1, J1 )
*
* Perform swap provisionally on diagonal block in D.
*
CALL DLARFX( 'L', 3, 3, U, TAU, D, LDD, WORK )
CALL DLARFX( 'R', 3, 3, U, TAU, D, LDD, WORK )
*
* Test whether to reject swap.
*
IF( MAX( ABS( D( 3, 1 ) ), ABS( D( 3, 2 ) ), ABS( D( 3,
$ 3 )-T11 ) ).GT.THRESH )GO TO 50
*
* Accept swap: apply transformation to the entire matrix T.
*
CALL DLARFX( 'L', 3, N-J1+1, U, TAU, T( J1, J1 ), LDT, WORK )
CALL DLARFX( 'R', J2, 3, U, TAU, T( 1, J1 ), LDT, WORK )
*
T( J3, J1 ) = ZERO
T( J3, J2 ) = ZERO
T( J3, J3 ) = T11
*
IF( WANTQ ) THEN
*
* Accumulate transformation in the matrix Q.
*
CALL DLARFX( 'R', N, 3, U, TAU, Q( 1, J1 ), LDQ, WORK )
END IF
GO TO 40
*
20 CONTINUE
*
* N1 = 2, N2 = 1: generate elementary reflector H so that:
*
* H ( -X11 ) = ( * )
* ( -X21 ) = ( 0 )
* ( scale ) = ( 0 )
*
U( 1 ) = -X( 1, 1 )
U( 2 ) = -X( 2, 1 )
U( 3 ) = SCALE
CALL DLARFG( 3, U( 1 ), U( 2 ), 1, TAU )
U( 1 ) = ONE
T33 = T( J3, J3 )
*
* Perform swap provisionally on diagonal block in D.
*
CALL DLARFX( 'L', 3, 3, U, TAU, D, LDD, WORK )
CALL DLARFX( 'R', 3, 3, U, TAU, D, LDD, WORK )
*
* Test whether to reject swap.
*
IF( MAX( ABS( D( 2, 1 ) ), ABS( D( 3, 1 ) ), ABS( D( 1,
$ 1 )-T33 ) ).GT.THRESH )GO TO 50
*
* Accept swap: apply transformation to the entire matrix T.
*
CALL DLARFX( 'R', J3, 3, U, TAU, T( 1, J1 ), LDT, WORK )
CALL DLARFX( 'L', 3, N-J1, U, TAU, T( J1, J2 ), LDT, WORK )
*
T( J1, J1 ) = T33
T( J2, J1 ) = ZERO
T( J3, J1 ) = ZERO
*
IF( WANTQ ) THEN
*
* Accumulate transformation in the matrix Q.
*
CALL DLARFX( 'R', N, 3, U, TAU, Q( 1, J1 ), LDQ, WORK )
END IF
GO TO 40
*
30 CONTINUE
*
* N1 = 2, N2 = 2: generate elementary reflectors H(1) and H(2) so
* that:
*
* H(2) H(1) ( -X11 -X12 ) = ( * * )
* ( -X21 -X22 ) ( 0 * )
* ( scale 0 ) ( 0 0 )
* ( 0 scale ) ( 0 0 )
*
U1( 1 ) = -X( 1, 1 )
U1( 2 ) = -X( 2, 1 )
U1( 3 ) = SCALE
CALL DLARFG( 3, U1( 1 ), U1( 2 ), 1, TAU1 )
U1( 1 ) = ONE
*
TEMP = -TAU1*( X( 1, 2 )+U1( 2 )*X( 2, 2 ) )
U2( 1 ) = -TEMP*U1( 2 ) - X( 2, 2 )
U2( 2 ) = -TEMP*U1( 3 )
U2( 3 ) = SCALE
CALL DLARFG( 3, U2( 1 ), U2( 2 ), 1, TAU2 )
U2( 1 ) = ONE
*
* Perform swap provisionally on diagonal block in D.
*
CALL DLARFX( 'L', 3, 4, U1, TAU1, D, LDD, WORK )
CALL DLARFX( 'R', 4, 3, U1, TAU1, D, LDD, WORK )
CALL DLARFX( 'L', 3, 4, U2, TAU2, D( 2, 1 ), LDD, WORK )
CALL DLARFX( 'R', 4, 3, U2, TAU2, D( 1, 2 ), LDD, WORK )
*
* Test whether to reject swap.
*
IF( MAX( ABS( D( 3, 1 ) ), ABS( D( 3, 2 ) ), ABS( D( 4, 1 ) ),
$ ABS( D( 4, 2 ) ) ).GT.THRESH )GO TO 50
*
* Accept swap: apply transformation to the entire matrix T.
*
CALL DLARFX( 'L', 3, N-J1+1, U1, TAU1, T( J1, J1 ), LDT, WORK )
CALL DLARFX( 'R', J4, 3, U1, TAU1, T( 1, J1 ), LDT, WORK )
CALL DLARFX( 'L', 3, N-J1+1, U2, TAU2, T( J2, J1 ), LDT, WORK )
CALL DLARFX( 'R', J4, 3, U2, TAU2, T( 1, J2 ), LDT, WORK )
*
T( J3, J1 ) = ZERO
T( J3, J2 ) = ZERO
T( J4, J1 ) = ZERO
T( J4, J2 ) = ZERO
*
IF( WANTQ ) THEN
*
* Accumulate transformation in the matrix Q.
*
CALL DLARFX( 'R', N, 3, U1, TAU1, Q( 1, J1 ), LDQ, WORK )
CALL DLARFX( 'R', N, 3, U2, TAU2, Q( 1, J2 ), LDQ, WORK )
END IF
*
40 CONTINUE
*
IF( N2.EQ.2 ) THEN
*
* Standardize new 2-by-2 block T11
*
CALL DLANV2( T( J1, J1 ), T( J1, J2 ), T( J2, J1 ),
$ T( J2, J2 ), WR1, WI1, WR2, WI2, CS, SN )
CALL DROT( N-J1-1, T( J1, J1+2 ), LDT, T( J2, J1+2 ), LDT,
$ CS, SN )
CALL DROT( J1-1, T( 1, J1 ), 1, T( 1, J2 ), 1, CS, SN )
IF( WANTQ )
$ CALL DROT( N, Q( 1, J1 ), 1, Q( 1, J2 ), 1, CS, SN )
END IF
*
IF( N1.EQ.2 ) THEN
*
* Standardize new 2-by-2 block T22
*
J3 = J1 + N2
J4 = J3 + 1
CALL DLANV2( T( J3, J3 ), T( J3, J4 ), T( J4, J3 ),
$ T( J4, J4 ), WR1, WI1, WR2, WI2, CS, SN )
IF( J3+2.LE.N )
$ CALL DROT( N-J3-1, T( J3, J3+2 ), LDT, T( J4, J3+2 ),
$ LDT, CS, SN )
CALL DROT( J3-1, T( 1, J3 ), 1, T( 1, J4 ), 1, CS, SN )
IF( WANTQ )
$ CALL DROT( N, Q( 1, J3 ), 1, Q( 1, J4 ), 1, CS, SN )
END IF
*
END IF
RETURN
*
* Exit with INFO = 1 if swap was rejected.
*
50 CONTINUE
INFO = 1
RETURN
*
* End of DLAEXC
*
END
| gpl-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.