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
puppeh/gcc-6502
gcc/testsuite/gfortran.dg/g77/980628-2.f
188
1337
c { dg-do run } c { dg-options "-std=gnu" } * g77 0.5.23 and previous had bugs involving too little space * allocated for EQUIVALENCE and COMMON areas needing initial * padding to meet alignment requirements of the system. call subr end subroutine subr implicit none character c1(11), c2(11), c3(11) real r1, r2, r3 character c4, c5, c6 equivalence (c1(2), r1) equivalence (c2(2), r2) equivalence (c3(2), r3) c1(1) = '1' r1 = 1. c1(11) = '1' c4 = '4' c2(1) = '2' r2 = 2. c2(11) = '2' c5 = '5' c3(1) = '3' r3 = 3. c3(11) = '3' c6 = '6' call x (c1, r1, c2, r2, c3, r3, c4, c5, c6) end subroutine x (c1, r1, c2, r2, c3, r3, c4, c5, c6) implicit none character c1(11), c2(11), c3(11) real r1, r2, r3 character c4, c5, c6 if (c1(1) .ne. '1') call abort if (r1 .ne. 1.) call abort if (c1(11) .ne. '1') call abort if (c4 .ne. '4') call abort if (c2(1) .ne. '2') call abort if (r2 .ne. 2.) call abort if (c2(11) .ne. '2') call abort if (c5 .ne. '5') call abort if (c3(1) .ne. '3') call abort if (r3 .ne. 3.) call abort if (c3(11) .ne. '3') call abort if (c6 .ne. '6') call abort end
gpl-2.0
dch312/scipy
scipy/optimize/minpack/qrsolv.f
142
6178
subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa) integer n,ldr integer ipvt(n) double precision r(ldr,n),diag(n),qtb(n),x(n),sdiag(n),wa(n) c ********** c c subroutine qrsolv c c given an m by n matrix a, an n by n diagonal matrix d, c and an m-vector b, the problem is to determine an x which c solves the system c c a*x = b , d*x = 0 , c c in the least squares sense. c c this subroutine completes the solution of the problem c if it is provided with the necessary information from the c qr factorization, with column pivoting, of a. that is, if c a*p = q*r, where p is a permutation matrix, q has orthogonal c columns, and r is an upper triangular matrix with diagonal c elements of nonincreasing magnitude, then qrsolv expects c the full upper triangle of r, the permutation matrix p, c and the first n components of (q transpose)*b. the system c a*x = b, d*x = 0, is then equivalent to c c t t c r*z = q *b , p *d*p*z = 0 , c c where x = p*z. if this system does not have full rank, c then a least squares solution is obtained. on output qrsolv c also provides an upper triangular matrix s such that c c t t t c p *(a *a + d*d)*p = s *s . c c s is computed within qrsolv and may be of separate interest. c c the subroutine statement is c c subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa) c c where c c n is a positive integer input variable set to the order of r. c c r is an n by n array. on input the full upper triangle c must contain the full upper triangle of the matrix r. c on output the full upper triangle is unaltered, and the c strict lower triangle contains the strict upper triangle c (transposed) of the upper triangular matrix s. c c ldr is a positive integer input variable not less than n c which specifies the leading dimension of the array r. c c ipvt is an integer input array of length n which defines the c permutation matrix p such that a*p = q*r. column j of p c is column ipvt(j) of the identity matrix. c c diag is an input array of length n which must contain the c diagonal elements of the matrix d. c c qtb is an input array of length n which must contain the first c n elements of the vector (q transpose)*b. c c x is an output array of length n which contains the least c squares solution of the system a*x = b, d*x = 0. c c sdiag is an output array of length n which contains the c diagonal elements of the upper triangular matrix s. c c wa is a work array of length n. c c subprograms called c c fortran-supplied ... dabs,dsqrt c c argonne national laboratory. minpack project. march 1980. c burton s. garbow, kenneth e. hillstrom, jorge j. more c c ********** integer i,j,jp1,k,kp1,l,nsing double precision cos,cotan,p5,p25,qtbpj,sin,sum,tan,temp,zero data p5,p25,zero /5.0d-1,2.5d-1,0.0d0/ c c copy r and (q transpose)*b to preserve input and initialize s. c in particular, save the diagonal elements of r in x. c do 20 j = 1, n do 10 i = j, n r(i,j) = r(j,i) 10 continue x(j) = r(j,j) wa(j) = qtb(j) 20 continue c c eliminate the diagonal matrix d using a givens rotation. c do 100 j = 1, n c c prepare the row of d to be eliminated, locating the c diagonal element using p from the qr factorization. c l = ipvt(j) if (diag(l) .eq. zero) go to 90 do 30 k = j, n sdiag(k) = zero 30 continue sdiag(j) = diag(l) c c the transformations to eliminate the row of d c modify only a single element of (q transpose)*b c beyond the first n, which is initially zero. c qtbpj = zero do 80 k = j, n c c determine a givens rotation which eliminates the c appropriate element in the current row of d. c if (sdiag(k) .eq. zero) go to 70 if (dabs(r(k,k)) .ge. dabs(sdiag(k))) go to 40 cotan = r(k,k)/sdiag(k) sin = p5/dsqrt(p25+p25*cotan**2) cos = sin*cotan go to 50 40 continue tan = sdiag(k)/r(k,k) cos = p5/dsqrt(p25+p25*tan**2) sin = cos*tan 50 continue c c compute the modified diagonal element of r and c the modified element of ((q transpose)*b,0). c r(k,k) = cos*r(k,k) + sin*sdiag(k) temp = cos*wa(k) + sin*qtbpj qtbpj = -sin*wa(k) + cos*qtbpj wa(k) = temp c c accumulate the tranformation in the row of s. c kp1 = k + 1 if (n .lt. kp1) go to 70 do 60 i = kp1, n temp = cos*r(i,k) + sin*sdiag(i) sdiag(i) = -sin*r(i,k) + cos*sdiag(i) r(i,k) = temp 60 continue 70 continue 80 continue 90 continue c c store the diagonal element of s and restore c the corresponding diagonal element of r. c sdiag(j) = r(j,j) r(j,j) = x(j) 100 continue c c solve the triangular system for z. if the system is c singular, then obtain a least squares solution. c nsing = n do 110 j = 1, n if (sdiag(j) .eq. zero .and. nsing .eq. n) nsing = j - 1 if (nsing .lt. n) wa(j) = zero 110 continue if (nsing .lt. 1) go to 150 do 140 k = 1, nsing j = nsing - k + 1 sum = zero jp1 = j + 1 if (nsing .lt. jp1) go to 130 do 120 i = jp1, nsing sum = sum + r(i,j)*wa(i) 120 continue 130 continue wa(j) = (wa(j) - sum)/sdiag(j) 140 continue 150 continue c c permute the components of z back to components of x. c do 160 j = 1, n l = ipvt(j) x(l) = wa(j) 160 continue return c c last card of subroutine qrsolv. c end
bsd-3-clause
nschloe/seacas
packages/seacas/libraries/exodus_for/test/testcpnl.f
1
3520
C Copyright (c) 2005-2017 National Technology & Engineering Solutions C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C program testcpnl c c This is a test program for the Fortran binding of the EXODUS II c database copy function (excopy). c implicit none include 'exodusII.inc' integer iin, iout, exoid, exoid1, ierr, cpu_ws, io_ws, mod_sz real vers data iin /5/, iout /6/ c c open EXODUS II input file c c the setting of cpu_ws isn't used for copying but will test the c conversion routines cpu_ws = 8 io_ws = 4 exoid = exopen ("test.exo", EXREAD, cpu_ws, io_ws, vers, ierr) write (iout, '(/"after exopen, error = ",i3)') 1 ierr write (iout, '("test.exo is an EXODUSII file; version ", 1 f4.2)') vers write (iout, '(" I/O word size: ",i4)') io_ws mod_sz = exlgmd(exoid) write (iout, '(" Model Size",i2)') mod_sz c c create EXODUS II output file with default size reals c c the setting of cpu_ws isn't used for copying but will test the c conversion routines cpu_ws = 8 io_ws = 0 exoid1 = excre ("testcpnl.exo", 1 EXCLOB+EXLARG, cpu_ws, io_ws, ierr) write (iout,'("after excre, id = ", i3, ", error = ",i3)') 1 exoid1, ierr write (iout,'(" I/O word size: ",i4)') io_ws mod_sz = exlgmd(exoid1) write (iout, '(" Model Size",i2)') mod_sz write (iout,'("after excre, error = ", i4)') ierr call excopy (exoid, exoid1, ierr) write (iout, '(/"after excopy, error = ", i3)' ) ierr call exclos (exoid, ierr) write (iout, '(/"after exclos, error = ", i3)' ) ierr call exclos (exoid1, ierr) write (iout, '(/"after exclos, error = ", i3)' ) ierr stop end
bsd-3-clause
tm1249wk/WASHLIGGGHTS-3.3.x
lib/linalg/dasum.f
72
2558
*> \brief \b DASUM * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * DOUBLE PRECISION FUNCTION DASUM(N,DX,INCX) * * .. Scalar Arguments .. * INTEGER INCX,N * .. * .. Array Arguments .. * DOUBLE PRECISION DX(*) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DASUM takes the sum of the absolute values. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup double_blas_level1 * *> \par Further Details: * ===================== *> *> \verbatim *> *> jack dongarra, linpack, 3/11/78. *> modified 3/93 to return if incx .le. 0. *> modified 12/3/93, array(1) declarations changed to array(*) *> \endverbatim *> * ===================================================================== DOUBLE PRECISION FUNCTION DASUM(N,DX,INCX) * * -- Reference BLAS level1 routine (version 3.4.0) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. INTEGER INCX,N * .. * .. Array Arguments .. DOUBLE PRECISION DX(*) * .. * * ===================================================================== * * .. Local Scalars .. DOUBLE PRECISION DTEMP INTEGER I,M,MP1,NINCX * .. * .. Intrinsic Functions .. INTRINSIC DABS,MOD * .. DASUM = 0.0d0 DTEMP = 0.0d0 IF (N.LE.0 .OR. INCX.LE.0) RETURN IF (INCX.EQ.1) THEN * code for increment equal to 1 * * * clean-up loop * M = MOD(N,6) IF (M.NE.0) THEN DO I = 1,M DTEMP = DTEMP + DABS(DX(I)) END DO IF (N.LT.6) THEN DASUM = DTEMP RETURN END IF END IF MP1 = M + 1 DO I = MP1,N,6 DTEMP = DTEMP + DABS(DX(I)) + DABS(DX(I+1)) + $ DABS(DX(I+2)) + DABS(DX(I+3)) + $ DABS(DX(I+4)) + DABS(DX(I+5)) END DO ELSE * * code for increment not equal to 1 * NINCX = N*INCX DO I = 1,NINCX,INCX DTEMP = DTEMP + DABS(DX(I)) END DO END IF DASUM = DTEMP RETURN END
gpl-2.0
dch312/scipy
scipy/integrate/tests/banded5x5.f
6
6691
c banded5x5.f c c This Fortran library contains implementations of the c differential equation c dy/dt = A*y c where A is a 5x5 banded matrix (see below for the actual c values). These functions will be used to test c scipy.integrate.odeint. c c The idea is to solve the system two ways: pure Fortran, and c using odeint. The "pure Fortran" solver is implemented in c the subroutine banded5x5_solve below. It calls LSODA to c solve the system. c c To solve the same system using odeint, the functions in this c file are given a python wrapper using f2py. Then the code c in test_odeint_jac.py uses the wrapper to implement the c equation and Jacobian functions required by odeint. Because c those functions ultimately call the Fortran routines defined c in this file, the two method (pure Fortran and odeint) should c produce exactly the same results. (That's assuming floating c point calculations are deterministic, which can be an c incorrect assumption.) If we simply re-implemented the c equation and Jacobian functions using just python and numpy, c the floating point calculations would not be performed in c the same sequence as in the Fortran code, and we would obtain c different answers. The answer for either method would be c numerically "correct", but the errors would be different, c and the counts of function and Jacobian evaluations would c likely be different. c block data jacobian implicit none double precision bands dimension bands(4,5) common /jac/ bands c The data for a banded Jacobian stored in packed banded c format. The full Jacobian is c c -1, 0.25, 0, 0, 0 c 0.25, -5, 0.25, 0, 0 c 0.10, 0.25, -25, 0.25, 0 c 0, 0.10, 0.25, -125, 0.25 c 0, 0, 0.10, 0.25, -625 c c The columns in the following layout of numbers are c the upper diagonal, main diagonal and two lower diagonals c (i.e. each row in the layout is a column of the packed c banded Jacobian). The values 0.00D0 are in the "don't c care" positions. data bands/ + 0.00D0, -1.0D0, 0.25D0, 0.10D0, + 0.25D0, -5.0D0, 0.25D0, 0.10D0, + 0.25D0, -25.0D0, 0.25D0, 0.10D0, + 0.25D0, -125.0D0, 0.25D0, 0.00D0, + 0.25D0, -625.0D0, 0.00D0, 0.00D0 + / end subroutine getbands(jac) double precision jac dimension jac(4, 5) cf2py intent(out) jac double precision bands dimension bands(4,5) common /jac/ bands integer i, j do 5 i = 1, 4 do 5 j = 1, 5 jac(i, j) = bands(i, j) 5 continue return end c c Differential equations, right-hand-side c subroutine banded5x5(n, t, y, f) implicit none integer n double precision t, y, f dimension y(n), f(n) integer i, j, k double precision bands dimension bands(4,5) common /jac/ bands f(1) = bands(2,1)*y(1) + bands(1,2)*y(2) f(2) = bands(3,1)*y(1) + bands(2,2)*y(2) + bands(1,3)*y(3) f(3) = bands(4,1)*y(1) + bands(3,2)*y(2) + bands(2,3)*y(3) + + bands(1,4)*y(4) f(4) = bands(4,2)*y(2) + bands(3,3)*y(3) + bands(2,4)*y(4) + + bands(1,5)*y(5) f(5) = bands(4,3)*y(3) + bands(3,4)*y(4) + bands(2,5)*y(5) return end c c Jacobian c c The subroutine assumes that the full Jacobian is to be computed. c ml and mu are ignored, and nrowpd is assumed to be n. c subroutine banded5x5_jac(n, t, y, ml, mu, jac, nrowpd) implicit none integer n, ml, mu, nrowpd double precision t, y, jac dimension y(n), jac(nrowpd, n) integer i, j double precision bands dimension bands(4,5) common /jac/ bands do 15 i = 1, 4 do 15 j = 1, 5 if ((i - j) .gt. 0) then jac(i - j, j) = bands(i, j) end if 15 continue return end c c Banded Jacobian c c ml = 2, mu = 1 c subroutine banded5x5_bjac(n, t, y, ml, mu, bjac, nrowpd) implicit none integer n, ml, mu, nrowpd double precision t, y, bjac dimension y(5), bjac(nrowpd, n) integer i, j double precision bands dimension bands(4,5) common /jac/ bands do 20 i = 1, 4 do 20 j = 1, 5 bjac(i, j) = bands(i, j) 20 continue return end subroutine banded5x5_solve(y, nsteps, dt, jt, nst, nfe, nje) c jt is the Jacobian type: c jt = 1 Use the full Jacobian. c jt = 4 Use the banded Jacobian. c nst, nfe and nje are outputs: c nst: Total number of internal steps c nfe: Total number of function (i.e. right-hand-side) c evaluations c nje: Total number of Jacobian evaluations implicit none external banded5x5 external banded5x5_jac external banded5x5_bjac external LSODA c Arguments... double precision y, dt integer nsteps, jt, nst, nfe, nje cf2py intent(inout) y cf2py intent(in) nsteps, dt, jt cf2py intent(out) nst, nfe, nje c Local variables... double precision atol, rtol, t, tout, rwork integer iwork dimension y(5), rwork(500), iwork(500) integer neq, i integer itol, iopt, itask, istate, lrw, liw c Common block... double precision jacband dimension jacband(4,5) common /jac/ jacband c --- t range --- t = 0.0D0 c --- Solver tolerances --- rtol = 1.0D-11 atol = 1.0D-13 itol = 1 c --- Other LSODA parameters --- neq = 5 itask = 1 istate = 1 iopt = 0 iwork(1) = 2 iwork(2) = 1 lrw = 500 liw = 500 c --- Call LSODA in a loop to compute the solution --- do 40 i = 1, nsteps tout = i*dt if (jt .eq. 1) then call LSODA(banded5x5, neq, y, t, tout, & itol, rtol, atol, itask, istate, iopt, & rwork, lrw, iwork, liw, & banded5x5_jac, jt) else call LSODA(banded5x5, neq, y, t, tout, & itol, rtol, atol, itask, istate, iopt, & rwork, lrw, iwork, liw, & banded5x5_bjac, jt) end if 40 if (istate .lt. 0) goto 80 nst = iwork(11) nfe = iwork(12) nje = iwork(13) return 80 write (6,89) istate 89 format(1X,"Error: istate=",I3) return end
bsd-3-clause
nschloe/seacas
packages/seacas/applications/algebra/ag_opnlog.f
1
3245
C Copyright(C) 2008-2017 National Technology & Engineering Solutions of C Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C C======================================================================= SUBROUTINE OPNLOG (LOGU) C======================================================================= C $Id: opnlog.f,v 1.8 2008/03/14 13:45:28 gdsjaar Exp $ C --*** OPNLOG *** (BLOT) Open log file and write header C -- Written by Amy Gilkey - revised 12/21/87 C -- C --OPNLOG opens the log file and writes the command line as the header C --for the log file. C -- C --Parameters: C -- NLOG - IN - the log file number C -- C --Common Variables: C -- Uses QAINFO of /PROGQA/ C -- Uses NDBIN, NDBOUT of /DBASE/ include 'exodusII.inc' include 'ag_progqa.blk' include 'ag_dbase.blk' CHARACTER*256 INLINE CHARACTER*256 STR NLOG = LOGU CALL OPNFIL (NLOG, 'U', 'L', 0, IERR) IF (IERR .NE. 0) THEN CALL PRTERR ('WARNING', 'Log file cannot be opened') NLOG = -1 GOTO 100 END IF INLINE = '$$$ ' // QAINFO(1) L = LENSTR (INLINE) + 1 CALL EXNAME(NDBIN, STR, LFIL) IF (L .LT. LEN (INLINE)) INLINE(L+1:) = STR(:LFIL) L = LENSTR (INLINE) + 1 CALL EXNAME(NDBOUT, STR, LFIL) IF (L .LT. LEN (INLINE)) INLINE(L+1:) = STR(:LFIL) L = LENSTR (INLINE) + 1 WRITE (NLOG, '(A)') INLINE(:L-1) 100 CONTINUE LOGU = NLOG RETURN END
bsd-3-clause
fedya/aircam-openwrt
build_dir/toolchain-arm_v5te_gcc-linaro_uClibc-0.9.32_eabi/gcc-linaro-4.5-2011.02-0/gcc/testsuite/gfortran.dg/whole_file_1.f90
4
1043
! { dg-do compile } ! { dg-options "-fwhole-file" } ! Tests the fix for PR22571 in which the derived types in a, b ! c and d were not detected to be different. In e and f, they ! are the same because they are sequence types. ! ! Contributed by Joost VandeVondele <jv244@cam.ac.uk> ! subroutine a(p) type t integer :: t1 end type type(t) :: p p%t1 = 42 end subroutine subroutine b type u integer :: u1 end type type (u) :: q call a(q) ! { dg-error "Type mismatch" } print *, q%u1 end subroutine subroutine c(p) type u integer :: u1 end type type(u) :: p p%u1 = 42 end subroutine subroutine d type u integer :: u1 end type type (u) :: q call c(q) ! { dg-error "Type mismatch" } print *, q%u1 end subroutine subroutine e(p) type u sequence integer :: u1 end type type(u) :: p p%u1 = 42 end subroutine subroutine f type u sequence integer :: u1 end type type (u) :: q call e(q) ! This is OK because the types are sequence. print *, q%u1 end subroutine
gpl-2.0
puppeh/gcc-6502
gcc/testsuite/gfortran.dg/constructor_2.f90
98
1279
! { dg-do run } ! ! PR fortran/39427 ! module foo_module interface foo procedure constructor end interface type foo integer :: bar end type contains type(foo) function constructor() constructor%bar = 1 end function subroutine test_foo() type(foo) :: f f = foo() if (f%bar /= 1) call abort () f = foo(2) if (f%bar /= 2) call abort () end subroutine test_foo end module foo_module ! Same as foo_module but order ! of INTERFACE and TYPE reversed module bar_module type bar integer :: bar end type interface bar procedure constructor end interface contains type(bar) function constructor() constructor%bar = 3 end function subroutine test_bar() type(bar) :: f f = bar() if (f%bar /= 3) call abort () f = bar(4) if (f%bar /= 4) call abort () end subroutine test_bar end module bar_module program main use foo_module use bar_module implicit none type(foo) :: f type(bar) :: b call test_foo() f = foo() if (f%bar /= 1) call abort () f = foo(2) if (f%bar /= 2) call abort () call test_bar() b = bar() if (b%bar /= 3) call abort () b = bar(4) if (b%bar /= 4) call abort () end program main ! { dg-final { cleanup-tree-dump "foo_module bar_module" } }
gpl-2.0
nschloe/seacas
packages/seacas/applications/fastq/addjut.f
1
3287
C Copyright(C) 2014-2017 National Technology & Engineering Solutions of C Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C C $Id: addjut.f,v 1.1 1990/11/30 11:02:52 gdsjaar Exp $ C $Log: addjut.f,v $ C Revision 1.1 1990/11/30 11:02:52 gdsjaar C Initial revision C C CC* FILE: [.PAVING]ADDJUT.FOR CC* MODIFIED BY: TED BLACKER CC* MODIFICATION DATE: 7/6/90 CC* MODIFICATION: COMPLETED HEADER INFORMATION C SUBROUTINE ADDJUT (MXND, XN, YN, LXK, KXL, NXL, LXN, + ANGLE, LNODES, XNEW, YNEW, NNN, LLL, NOLD, NLOOP, JUTTED) C*********************************************************************** C C SUBROUTINE ADDJUT = ADDS A NEW NODE JUTTING OUT FROM AN EXISTING C NODE C C*********************************************************************** C DIMENSION XN (MXND), YN (MXND) DIMENSION LXK (4, MXND), KXL (2, 3*MXND) DIMENSION NXL (2, 3*MXND), LXN (4, MXND) DIMENSION ANGLE (MXND), LNODES (7, MXND) C LOGICAL JUTTED C NNN = NNN+1 XN (NNN) = XNEW YN (NNN) = YNEW C C MAKE LXN AND NXL ARRAYS C C ADD THE NEW NODE'S LINES C LLL = LLL+1 NXL (1, LLL) = NNN NXL (2, LLL) = NOLD C DO 100 I = 1, 4 LXN (I, NNN) = 0 100 CONTINUE C KXL (1, LLL) = 0 KXL (2, LLL) = 0 C C REDO THE LNODES ARRAY C LNODES (1, NNN) = 0 LNODES (2, NNN) = NOLD LNODES (3, NNN) = NOLD LNODES (4, NNN) = - 1 LNODES (5, NNN) = LLL C LNODES (1, NOLD) = 0 LNODES (3, NOLD) = NNN LNODES (5, NOLD) = LLL C NLOOP = NLOOP + 2 JUTTED = .TRUE. C RETURN C END
bsd-3-clause
puppeh/gcc-6502
gcc/testsuite/gfortran.dg/finalize_13.f90
111
3780
! { dg-do run } ! ! PR fortran/37336 ! module m implicit none type t integer :: i contains final :: fini3, fini2, fini_elm end type t type, extends(t) :: t2 integer :: j contains final :: f2ini2, f2ini_elm end type t2 logical :: elem_call logical :: rank2_call logical :: rank3_call integer :: cnt, cnt2 integer :: fini_call contains subroutine fini2 (x) type(t), intent(in), contiguous :: x(:,:) if (.not. rank2_call) call abort () if (size(x,1) /= 2 .or. size(x,2) /= 3) call abort() !print *, 'fini2:', x%i if (any (x%i /= reshape([11, 12, 21, 22, 31, 32], [2,3]))) call abort() fini_call = fini_call + 1 end subroutine subroutine fini3 (x) type(t), intent(in) :: x(2,2,*) integer :: i,j,k if (.not. elem_call) call abort () if (.not. rank3_call) call abort () if (cnt2 /= 9) call abort() if (cnt /= 1) call abort() do i = 1, 2 do j = 1, 2 do k = 1, 2 !print *, k,j,i,x(k,j,i)%i if (x(k,j,i)%i /= k+10*j+100*i) call abort() end do end do end do fini_call = fini_call + 1 end subroutine impure elemental subroutine fini_elm (x) type(t), intent(in) :: x if (.not. elem_call) call abort () if (rank3_call) call abort () if (cnt2 /= 6) call abort() if (cnt /= x%i) call abort() !print *, 'fini_elm:', cnt, x%i fini_call = fini_call + 1 cnt = cnt + 1 end subroutine subroutine f2ini2 (x) type(t2), intent(in), target :: x(:,:) if (.not. rank2_call) call abort () if (size(x,1) /= 2 .or. size(x,2) /= 3) call abort() !print *, 'f2ini2:', x%i !print *, 'f2ini2:', x%j if (any (x%i /= reshape([11, 12, 21, 22, 31, 32], [2,3]))) call abort() if (any (x%j /= 100*reshape([11, 12, 21, 22, 31, 32], [2,3]))) call abort() fini_call = fini_call + 1 end subroutine impure elemental subroutine f2ini_elm (x) type(t2), intent(in) :: x integer, parameter :: exprected(*) & = [111, 112, 121, 122, 211, 212, 221, 222] if (.not. elem_call) call abort () !print *, 'f2ini_elm:', cnt2, x%i, x%j if (rank3_call) then if (x%i /= exprected(cnt2)) call abort () if (x%j /= 1000*exprected(cnt2)) call abort () else if (cnt2 /= x%i .or. cnt2*10 /= x%j) call abort() end if cnt2 = cnt2 + 1 fini_call = fini_call + 1 end subroutine end module m program test use m implicit none class(t), save, allocatable :: y(:), z(:,:), zz(:,:,:) target :: z, zz integer :: i,j,k elem_call = .false. rank2_call = .false. rank3_call = .false. allocate (t2 :: y(5)) select type (y) type is (t2) do i = 1, 5 y(i)%i = i y(i)%j = i*10 end do end select cnt = 1 cnt2 = 1 fini_call = 0 elem_call = .true. deallocate (y) if (fini_call /= 10) call abort () elem_call = .false. rank2_call = .false. rank3_call = .false. allocate (t2 :: z(2,3)) select type (z) type is (t2) do i = 1, 3 do j = 1, 2 z(j,i)%i = j+10*i z(j,i)%j = (j+10*i)*100 end do end do end select cnt = 1 cnt2 = 1 fini_call = 0 rank2_call = .true. deallocate (z) if (fini_call /= 2) call abort () elem_call = .false. rank2_call = .false. rank3_call = .false. allocate (t2 :: zz(2,2,2)) select type (zz) type is (t2) do i = 1, 2 do j = 1, 2 do k = 1, 2 zz(k,j,i)%i = k+10*j+100*i zz(k,j,i)%j = (k+10*j+100*i)*1000 end do end do end do end select cnt = 1 cnt2 = 1 fini_call = 0 rank3_call = .true. elem_call = .true. deallocate (zz) if (fini_call /= 2*2*2+1) call abort () end program test
gpl-2.0
dch312/scipy
scipy/fftpack/src/dfftpack/zfftb1.f
116
12027
SUBROUTINE ZFFTB1 (N,C,CH,WA,IFAC) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CH(*) ,C(*) ,WA(*) ,IFAC(*) NF = IFAC(2) NA = 0 L1 = 1 IW = 1 DO 116 K1=1,NF IP = IFAC(K1+2) L2 = IP*L1 IDO = N/L2 IDOT = IDO+IDO IDL1 = IDOT*L1 IF (IP .NE. 4) GO TO 103 IX2 = IW+IDOT IX3 = IX2+IDOT IF (NA .NE. 0) GO TO 101 CALL DPASSB4 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3)) GO TO 102 101 CALL DPASSB4 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3)) 102 NA = 1-NA GO TO 115 103 IF (IP .NE. 2) GO TO 106 IF (NA .NE. 0) GO TO 104 CALL DPASSB2 (IDOT,L1,C,CH,WA(IW)) GO TO 105 104 CALL DPASSB2 (IDOT,L1,CH,C,WA(IW)) 105 NA = 1-NA GO TO 115 106 IF (IP .NE. 3) GO TO 109 IX2 = IW+IDOT IF (NA .NE. 0) GO TO 107 CALL DPASSB3 (IDOT,L1,C,CH,WA(IW),WA(IX2)) GO TO 108 107 CALL DPASSB3 (IDOT,L1,CH,C,WA(IW),WA(IX2)) 108 NA = 1-NA GO TO 115 109 IF (IP .NE. 5) GO TO 112 IX2 = IW+IDOT IX3 = IX2+IDOT IX4 = IX3+IDOT IF (NA .NE. 0) GO TO 110 CALL DPASSB5 (IDOT,L1,C,CH,WA(IW),WA(IX2),WA(IX3),WA(IX4)) GO TO 111 110 CALL DPASSB5 (IDOT,L1,CH,C,WA(IW),WA(IX2),WA(IX3),WA(IX4)) 111 NA = 1-NA GO TO 115 112 IF (NA .NE. 0) GO TO 113 CALL DPASSB (NAC,IDOT,IP,L1,IDL1,C,C,C,CH,CH,WA(IW)) GO TO 114 113 CALL DPASSB (NAC,IDOT,IP,L1,IDL1,CH,CH,CH,C,C,WA(IW)) 114 IF (NAC .NE. 0) NA = 1-NA 115 L1 = L2 IW = IW+(IP-1)*IDOT 116 CONTINUE IF (NA .EQ. 0) RETURN N2 = N+N DO 117 I=1,N2 C(I) = CH(I) 117 CONTINUE RETURN END SUBROUTINE DPASSB (NAC,IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CH(IDO,L1,IP) ,CC(IDO,IP,L1) , 1 C1(IDO,L1,IP) ,WA(1) ,C2(IDL1,IP), 2 CH2(IDL1,IP) IDOT = IDO/2 NT = IP*IDL1 IPP2 = IP+2 IPPH = (IP+1)/2 IDP = IP*IDO C IF (IDO .LT. L1) GO TO 106 DO 103 J=2,IPPH JC = IPP2-J DO 102 K=1,L1 DO 101 I=1,IDO CH(I,K,J) = CC(I,J,K)+CC(I,JC,K) CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K) 101 CONTINUE 102 CONTINUE 103 CONTINUE DO 105 K=1,L1 DO 104 I=1,IDO CH(I,K,1) = CC(I,1,K) 104 CONTINUE 105 CONTINUE GO TO 112 106 DO 109 J=2,IPPH JC = IPP2-J DO 108 I=1,IDO DO 107 K=1,L1 CH(I,K,J) = CC(I,J,K)+CC(I,JC,K) CH(I,K,JC) = CC(I,J,K)-CC(I,JC,K) 107 CONTINUE 108 CONTINUE 109 CONTINUE DO 111 I=1,IDO DO 110 K=1,L1 CH(I,K,1) = CC(I,1,K) 110 CONTINUE 111 CONTINUE 112 IDL = 2-IDO INC = 0 DO 116 L=2,IPPH LC = IPP2-L IDL = IDL+IDO DO 113 IK=1,IDL1 C2(IK,L) = CH2(IK,1)+WA(IDL-1)*CH2(IK,2) C2(IK,LC) = WA(IDL)*CH2(IK,IP) 113 CONTINUE IDLJ = IDL INC = INC+IDO DO 115 J=3,IPPH JC = IPP2-J IDLJ = IDLJ+INC IF (IDLJ .GT. IDP) IDLJ = IDLJ-IDP WAR = WA(IDLJ-1) WAI = WA(IDLJ) DO 114 IK=1,IDL1 C2(IK,L) = C2(IK,L)+WAR*CH2(IK,J) C2(IK,LC) = C2(IK,LC)+WAI*CH2(IK,JC) 114 CONTINUE 115 CONTINUE 116 CONTINUE DO 118 J=2,IPPH DO 117 IK=1,IDL1 CH2(IK,1) = CH2(IK,1)+CH2(IK,J) 117 CONTINUE 118 CONTINUE DO 120 J=2,IPPH JC = IPP2-J DO 119 IK=2,IDL1,2 CH2(IK-1,J) = C2(IK-1,J)-C2(IK,JC) CH2(IK-1,JC) = C2(IK-1,J)+C2(IK,JC) CH2(IK,J) = C2(IK,J)+C2(IK-1,JC) CH2(IK,JC) = C2(IK,J)-C2(IK-1,JC) 119 CONTINUE 120 CONTINUE NAC = 1 IF (IDO .EQ. 2) RETURN NAC = 0 DO 121 IK=1,IDL1 C2(IK,1) = CH2(IK,1) 121 CONTINUE DO 123 J=2,IP DO 122 K=1,L1 C1(1,K,J) = CH(1,K,J) C1(2,K,J) = CH(2,K,J) 122 CONTINUE 123 CONTINUE IF (IDOT .GT. L1) GO TO 127 IDIJ = 0 DO 126 J=2,IP IDIJ = IDIJ+2 DO 125 I=4,IDO,2 IDIJ = IDIJ+2 DO 124 K=1,L1 C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J) C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J) 124 CONTINUE 125 CONTINUE 126 CONTINUE RETURN 127 IDJ = 2-IDO DO 130 J=2,IP IDJ = IDJ+IDO DO 129 K=1,L1 IDIJ = IDJ DO 128 I=4,IDO,2 IDIJ = IDIJ+2 C1(I-1,K,J) = WA(IDIJ-1)*CH(I-1,K,J)-WA(IDIJ)*CH(I,K,J) C1(I,K,J) = WA(IDIJ-1)*CH(I,K,J)+WA(IDIJ)*CH(I-1,K,J) 128 CONTINUE 129 CONTINUE 130 CONTINUE RETURN END SUBROUTINE DPASSB2 (IDO,L1,CC,CH,WA1) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CC(IDO,2,L1) ,CH(IDO,L1,2) , 1 WA1(1) IF (IDO .GT. 2) GO TO 102 DO 101 K=1,L1 CH(1,K,1) = CC(1,1,K)+CC(1,2,K) CH(1,K,2) = CC(1,1,K)-CC(1,2,K) CH(2,K,1) = CC(2,1,K)+CC(2,2,K) CH(2,K,2) = CC(2,1,K)-CC(2,2,K) 101 CONTINUE RETURN 102 DO 104 K=1,L1 DO 103 I=2,IDO,2 CH(I-1,K,1) = CC(I-1,1,K)+CC(I-1,2,K) TR2 = CC(I-1,1,K)-CC(I-1,2,K) CH(I,K,1) = CC(I,1,K)+CC(I,2,K) TI2 = CC(I,1,K)-CC(I,2,K) CH(I,K,2) = WA1(I-1)*TI2+WA1(I)*TR2 CH(I-1,K,2) = WA1(I-1)*TR2-WA1(I)*TI2 103 CONTINUE 104 CONTINUE RETURN END SUBROUTINE DPASSB3 (IDO,L1,CC,CH,WA1,WA2) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CC(IDO,3,L1) ,CH(IDO,L1,3) , 1 WA1(1) ,WA2(1) C *** TAUI IS SQRT(3)/2 *** DATA TAUR,TAUI /-0.5D0,0.86602540378443864676D0/ IF (IDO .NE. 2) GO TO 102 DO 101 K=1,L1 TR2 = CC(1,2,K)+CC(1,3,K) CR2 = CC(1,1,K)+TAUR*TR2 CH(1,K,1) = CC(1,1,K)+TR2 TI2 = CC(2,2,K)+CC(2,3,K) CI2 = CC(2,1,K)+TAUR*TI2 CH(2,K,1) = CC(2,1,K)+TI2 CR3 = TAUI*(CC(1,2,K)-CC(1,3,K)) CI3 = TAUI*(CC(2,2,K)-CC(2,3,K)) CH(1,K,2) = CR2-CI3 CH(1,K,3) = CR2+CI3 CH(2,K,2) = CI2+CR3 CH(2,K,3) = CI2-CR3 101 CONTINUE RETURN 102 DO 104 K=1,L1 DO 103 I=2,IDO,2 TR2 = CC(I-1,2,K)+CC(I-1,3,K) CR2 = CC(I-1,1,K)+TAUR*TR2 CH(I-1,K,1) = CC(I-1,1,K)+TR2 TI2 = CC(I,2,K)+CC(I,3,K) CI2 = CC(I,1,K)+TAUR*TI2 CH(I,K,1) = CC(I,1,K)+TI2 CR3 = TAUI*(CC(I-1,2,K)-CC(I-1,3,K)) CI3 = TAUI*(CC(I,2,K)-CC(I,3,K)) DR2 = CR2-CI3 DR3 = CR2+CI3 DI2 = CI2+CR3 DI3 = CI2-CR3 CH(I,K,2) = WA1(I-1)*DI2+WA1(I)*DR2 CH(I-1,K,2) = WA1(I-1)*DR2-WA1(I)*DI2 CH(I,K,3) = WA2(I-1)*DI3+WA2(I)*DR3 CH(I-1,K,3) = WA2(I-1)*DR3-WA2(I)*DI3 103 CONTINUE 104 CONTINUE RETURN END SUBROUTINE DPASSB4 (IDO,L1,CC,CH,WA1,WA2,WA3) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CC(IDO,4,L1) ,CH(IDO,L1,4) , 1 WA1(1) ,WA2(1) ,WA3(1) IF (IDO .NE. 2) GO TO 102 DO 101 K=1,L1 TI1 = CC(2,1,K)-CC(2,3,K) TI2 = CC(2,1,K)+CC(2,3,K) TR4 = CC(2,4,K)-CC(2,2,K) TI3 = CC(2,2,K)+CC(2,4,K) TR1 = CC(1,1,K)-CC(1,3,K) TR2 = CC(1,1,K)+CC(1,3,K) TI4 = CC(1,2,K)-CC(1,4,K) TR3 = CC(1,2,K)+CC(1,4,K) CH(1,K,1) = TR2+TR3 CH(1,K,3) = TR2-TR3 CH(2,K,1) = TI2+TI3 CH(2,K,3) = TI2-TI3 CH(1,K,2) = TR1+TR4 CH(1,K,4) = TR1-TR4 CH(2,K,2) = TI1+TI4 CH(2,K,4) = TI1-TI4 101 CONTINUE RETURN 102 DO 104 K=1,L1 DO 103 I=2,IDO,2 TI1 = CC(I,1,K)-CC(I,3,K) TI2 = CC(I,1,K)+CC(I,3,K) TI3 = CC(I,2,K)+CC(I,4,K) TR4 = CC(I,4,K)-CC(I,2,K) TR1 = CC(I-1,1,K)-CC(I-1,3,K) TR2 = CC(I-1,1,K)+CC(I-1,3,K) TI4 = CC(I-1,2,K)-CC(I-1,4,K) TR3 = CC(I-1,2,K)+CC(I-1,4,K) CH(I-1,K,1) = TR2+TR3 CR3 = TR2-TR3 CH(I,K,1) = TI2+TI3 CI3 = TI2-TI3 CR2 = TR1+TR4 CR4 = TR1-TR4 CI2 = TI1+TI4 CI4 = TI1-TI4 CH(I-1,K,2) = WA1(I-1)*CR2-WA1(I)*CI2 CH(I,K,2) = WA1(I-1)*CI2+WA1(I)*CR2 CH(I-1,K,3) = WA2(I-1)*CR3-WA2(I)*CI3 CH(I,K,3) = WA2(I-1)*CI3+WA2(I)*CR3 CH(I-1,K,4) = WA3(I-1)*CR4-WA3(I)*CI4 CH(I,K,4) = WA3(I-1)*CI4+WA3(I)*CR4 103 CONTINUE 104 CONTINUE RETURN END SUBROUTINE DPASSB5 (IDO,L1,CC,CH,WA1,WA2,WA3,WA4) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DIMENSION CC(IDO,5,L1) ,CH(IDO,L1,5) , 1 WA1(1) ,WA2(1) ,WA3(1) ,WA4(1) C *** TR11=COS(2*PI/5), TI11=SIN(2*PI/5) C *** TR12=COS(4*PI/5), TI12=SIN(4*PI/5) DATA TR11,TI11,TR12,TI12 /0.3090169943749474241D0, + 0.95105651629515357212D0, + -0.8090169943749474241D0,0.58778525229247312917D0/ IF (IDO .NE. 2) GO TO 102 DO 101 K=1,L1 TI5 = CC(2,2,K)-CC(2,5,K) TI2 = CC(2,2,K)+CC(2,5,K) TI4 = CC(2,3,K)-CC(2,4,K) TI3 = CC(2,3,K)+CC(2,4,K) TR5 = CC(1,2,K)-CC(1,5,K) TR2 = CC(1,2,K)+CC(1,5,K) TR4 = CC(1,3,K)-CC(1,4,K) TR3 = CC(1,3,K)+CC(1,4,K) CH(1,K,1) = CC(1,1,K)+TR2+TR3 CH(2,K,1) = CC(2,1,K)+TI2+TI3 CR2 = CC(1,1,K)+TR11*TR2+TR12*TR3 CI2 = CC(2,1,K)+TR11*TI2+TR12*TI3 CR3 = CC(1,1,K)+TR12*TR2+TR11*TR3 CI3 = CC(2,1,K)+TR12*TI2+TR11*TI3 CR5 = TI11*TR5+TI12*TR4 CI5 = TI11*TI5+TI12*TI4 CR4 = TI12*TR5-TI11*TR4 CI4 = TI12*TI5-TI11*TI4 CH(1,K,2) = CR2-CI5 CH(1,K,5) = CR2+CI5 CH(2,K,2) = CI2+CR5 CH(2,K,3) = CI3+CR4 CH(1,K,3) = CR3-CI4 CH(1,K,4) = CR3+CI4 CH(2,K,4) = CI3-CR4 CH(2,K,5) = CI2-CR5 101 CONTINUE RETURN 102 DO 104 K=1,L1 DO 103 I=2,IDO,2 TI5 = CC(I,2,K)-CC(I,5,K) TI2 = CC(I,2,K)+CC(I,5,K) TI4 = CC(I,3,K)-CC(I,4,K) TI3 = CC(I,3,K)+CC(I,4,K) TR5 = CC(I-1,2,K)-CC(I-1,5,K) TR2 = CC(I-1,2,K)+CC(I-1,5,K) TR4 = CC(I-1,3,K)-CC(I-1,4,K) TR3 = CC(I-1,3,K)+CC(I-1,4,K) CH(I-1,K,1) = CC(I-1,1,K)+TR2+TR3 CH(I,K,1) = CC(I,1,K)+TI2+TI3 CR2 = CC(I-1,1,K)+TR11*TR2+TR12*TR3 CI2 = CC(I,1,K)+TR11*TI2+TR12*TI3 CR3 = CC(I-1,1,K)+TR12*TR2+TR11*TR3 CI3 = CC(I,1,K)+TR12*TI2+TR11*TI3 CR5 = TI11*TR5+TI12*TR4 CI5 = TI11*TI5+TI12*TI4 CR4 = TI12*TR5-TI11*TR4 CI4 = TI12*TI5-TI11*TI4 DR3 = CR3-CI4 DR4 = CR3+CI4 DI3 = CI3+CR4 DI4 = CI3-CR4 DR5 = CR2+CI5 DR2 = CR2-CI5 DI5 = CI2-CR5 DI2 = CI2+CR5 CH(I-1,K,2) = WA1(I-1)*DR2-WA1(I)*DI2 CH(I,K,2) = WA1(I-1)*DI2+WA1(I)*DR2 CH(I-1,K,3) = WA2(I-1)*DR3-WA2(I)*DI3 CH(I,K,3) = WA2(I-1)*DI3+WA2(I)*DR3 CH(I-1,K,4) = WA3(I-1)*DR4-WA3(I)*DI4 CH(I,K,4) = WA3(I-1)*DI4+WA3(I)*DR4 CH(I-1,K,5) = WA4(I-1)*DR5-WA4(I)*DI5 CH(I,K,5) = WA4(I-1)*DI5+WA4(I)*DR5 103 CONTINUE 104 CONTINUE RETURN END
bsd-3-clause
fedya/aircam-openwrt
build_dir/toolchain-arm_v5te_gcc-linaro_uClibc-0.9.32_eabi/gcc-linaro-4.5-2011.02-0/libgfortran/generated/_abs_c10.F90
22
1485
! Copyright 2002, 2007, 2009 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_COMPLEX_10) #ifdef HAVE_CABSL elemental function _gfortran_specific__abs_c10 (parm) complex (kind=10), intent (in) :: parm real (kind=10) :: _gfortran_specific__abs_c10 _gfortran_specific__abs_c10 = abs (parm) end function #endif #endif
gpl-2.0
scattering-central/CCP13
otoko/src/vc03a.f
1
6051
SUBROUTINE VC03A (M,N,XD,YD,WD,RD,XN,FN,GN,DN,THETA,IPRINT,W) C C ------------------------------------------------------------ C C calculate a smooth weighted least squares fit to given data C C CALLS: C VB06A C C ------------------------------------------------------------ C REAL*8 W(1) DIMENSION XD(1),YD(1),WD(1),RD(1),XN(N),FN(N),GN(1),DN(1), 1THETA(1) NDIMAX=N C OMIT DATA WITH ZERO WEIGHTS MM=1 J=1 DO 1 I=2,M IF (WD(I)) 3,2,3 2 IF (I-M) 4,3,3 4 W(J)=XD(I) W(J+1)=YD(I) W(J+2)=FLOAT(I) J=J+3 GO TO 1 3 MM=MM+1 XD(MM)=XD(I) YD(MM)=YD(I) WD(MM)=WD(I) 1 CONTINUE J=1 K=MM 7 IF (K-M) 5,6,6 5 K=K+1 XD(K)=W(J) YD(K)=W(J+1) WD(K)=W(J+2) J=J+3 GO TO 7 C INITIALIZATION OF ITERATIONS 6 JA=1 IF (WD(1)) 9,8,9 8 JA=2 9 N=5 IF(N-NDIMAX)100,100,110 100 XN(1)=XD(1) XN(5)=XD(MM) XN(3)=0.5*(XN(1)+XN(5)) XN(2)=0.5*(XN(1)+XN(3)) XN(4)=0.5*(XN(3)+XN(5)) IW=7*MM+46 DO 10 I=1,5 J=IW+I W(J)=XN(I) 10 CONTINUE IP=-IPRINT C CALCULATE THE HISTOGRAMS FOR NEW SCALE FACTORS 11 J=0 K=1 SA=0. 12 SA=SA+WD(K)**2 K=K+1 IF (XD(K)-XD(1)) 12,12,13 13 SA=(SA+0.5*WD(K)**2)/(XD(K)-XD(1)) 14 J=J+1 IF (XD(K)-XN(J+1)) 15,15,16 16 GN(J)=SA*(XN(J+1)-XN(J)) GO TO 14 15 GN(J)=SA*(XD(K)-XN(J))+0.5*WD(K)**2 17 K=K+1 IF (K-MM) 18,18,19 18 IF (XD(K)-XN(J+1)) 20,20,21 20 GN(J)=GN(J)+WD(K)**2 GO TO 17 21 SA=0.5*(WD(K-1)**2+WD(K)**2)/(XD(K)-XD(K-1)) GN(J)=GN(J)-0.5*WD(K-1)**2+SA*(XN(J+1)-XD(K-1)) GO TO 14 C CALCULATE THE NEW SCALE FACTORS 19 K=IW+2 GN(1)=0.00025216*GN(1)*(W(K)-W(K-1))**8/(XN(2)-XN(1)) DO 22 J=3,N IF (XN(J)-W(K)) 23,23,24 24 K=K+1 23 GN(J-1)=0.00025216*GN(J-1)*(W(K)-W(K-1))**8/(XN(J)-XN(J-1)) GN(J-2)=ALOG(GN(J-2)+GN(J-1)) 22 CONTINUE NN=N-2 HS=1.386294 DO 97 J=2,NN GN(J)=AMIN1(GN(J),GN(J-1)+HS) 97 CONTINUE J=NN-1 98 GN(J)=AMIN1(GN(J),GN(J+1)+HS) J=J-1 IF (J) 99,99,98 99 DO 25 J=3,N THETA(J-1)=SQRT(EXP(GN(J-2))/(XN(J)-XN(J-2))) 25 CONTINUE C CALCULATE THE SPLINE APPROXIMATION WITH CURRENT KNOTS CALL VB06A (MM,N,XD,YD,WD,RD,XN,FN,GN,DN,THETA,IP,W) C APPLY STATISTICAL TEST FOR EXTRA KNOTS J=IW+1 JJ=0 K=JA TMAX=0. IIS=1 26 KC=-1 SW=0. SR=0. RP=0. J=J+1 JJ=JJ+1 W(JJ)=0. 27 IF (W(J)-XD(K)) 28,29,30 30 KC=KC+1 SW=SW+RD(K)**2 SR=SR+RP*RD(K) RP=RD(K) K=K+1 GO TO 27 29 IF (WD(K)) 31,28,31 31 KC=KC+1 SW=SW+RD(K)**2 SR=SR+RP*RD(K) 28 IF (SR) 32,32,33 33 SW=(SW/SR)**2 RP=SQRT(SR/FLOAT(KC)) IF (FLOAT(KC)-SW) 32,32,34 34 GO TO (35,36,37),IIS 35 PRP=RP IIS=3 IF (FLOAT(KC)-2.*SW) 38,38,39 37 W(JJ-1)=PRP TMAX=AMAX1(TMAX,PRP) 39 IIS=2 36 W(JJ)=RP TMAX=AMAX1(TMAX,RP) GO TO 38 32 IIS=1 38 IF (W(J)-XN(N)) 26,40,40 C TEST WHETHER ANOTHER ITERATION IS REQUIRED 40 IF (TMAX) 41,41,42 C CALCULATE NEW TREND ARRAY, INCLUDING LARGER TRENDS ONLY 42 TMAX=0.5*TMAX I=0 J=1 JW=1 K=IW+1 THETA(JW)=W(K) 43 I=I+1 K=K+1 IF (W(I)-TMAX) 44,44,45 44 JW=JW+1 THETA(JW)=W(K) 46 FN(J)=0. J=J+1 IF (W(K)-XN(J)) 47,47,46 45 JW=JW+2 THETA(JW-1)=0.5*(W(K-1)+W(K)) THETA(JW)=W(K) IF (XN(J+1)-THETA(JW-1)) 46,46,48 48 FN(J)=1. J=J+1 47 IF (J-N) 43,49,49 C MAKE KNOT SPACINGS BE USED FOUR TIMES 49 IK=1 KL=1 FN(2)=AMAX1(FN(1),FN(2)) GO TO 102 50 K=KL+3 51 IF (FN(K)) 52,52,53 52 K=K-1 IF (K-KL) 74,74,51 53 K=K-1 FN(K)=1. IF (K-KL) 74,74,53 102 K=KL+3 54 K=K+1 IF (K-N) 55,56,56 55 IF (XN(K+1)-XN(K)-1.5*(XN(K)-XN(K-1))) 54,54,56 56 KU=K FN(K-2)=AMAX1(FN(K-2),FN(K-1)) 57 KKU=K 58 K=K-1 IF (K-KL) 59,59,60 60 IF (XN(K)-XN(K-1)-1.5*(XN(K+1)-XN(K))) 58,58,61 61 FN(K+1)=AMAX1(FN(K),FN(K+1)) 59 KKL=K KZ=4 IF (FN(K)) 62,62,63 63 K=K+1 IF (K-KKU) 64,65,65 64 IF (FN(K)) 66,66,63 66 KZ=0 62 KZ=KZ+1 K=K+1 IF (K-KKU) 67,65,65 67 IF (FN(K)) 62,62,68 68 IF (KZ-3) 69,69,70 69 J=K-KZ 71 FN(J)=1. J=J+1 IF (J-K) 71,63,63 70 IF (K+1-KKU) 72,65,65 72 K=K+1 FN(K)=1. GO TO 63 65 IF (KL-KKL) 73,50,50 73 FN(KKL-2)=AMAX1(FN(KKL-2),FN(KKL+1)) FN(KKL-1)=AMAX1(FN(KKL-1),FN(KKL+3)) 75 K=KKL-4 78 IF (FN(K)) 76,76,77 76 K=K+1 IF (K-KKL) 78,79,79 77 FN(K)=1. K=K+1 IF (K-KKL) 77,79,79 79 GO TO (57,80),IK 74 IF (KU-N) 81,82,82 81 KL=KU FN(KL+1)=AMAX1(FN(KL+1),FN(KL-2)) FN(KL)=AMAX1(FN(KL),FN(KL-4)) GO TO 102 82 IK=2 KKL=N GO TO 75 C INSERT EXTRA KNOTS FOR NEW APPROXIMATION 80 DO 83 J=1,N GN(J)=XN(J) 83 CONTINUE NN=1 DO 84 J=2,N IF (FN(J-1)) 85,85,86 86 NN=NN+1 XN(NN)=0.5*(GN(J-1)+GN(J)) 85 NN=NN+1 XN(NN)=GN(J) 84 CONTINUE IF(N-NDIMAX)101,110,110 110 WRITE(5,111)N 111 FORMAT(///' ARRAY SIZES TOO SMALL. N =',I6,///) N=-N GO TO 90 101 N=NN IW=7*MM+8*N+6 DO 87 J=1,JW I=IW+J W(I)=THETA(J) 87 CONTINUE GO TO 11 C RESTORE DATA WITH ZERO WEIGHTS 41 IF (MM-M) 88,89,89 89 IF (IPRINT) 90,90,91 88 J=-2 K=MM 92 J=J+3 K=K+1 W(J)=XD(K) W(J+1)=YD(K) W(J+2)=WD(K) IF (K-M) 92,93,93 93 I=INT(W(J+2)+0.5) 94 IF (K-I) 95,95,96 96 XD(K)=XD(MM) YD(K)=YD(MM) WD(K)=WD(MM) K=K-1 MM=MM-1 GO TO 94 95 XD(K)=W(J) YD(K)=W(J+1) WD(K)=0. K=K-1 J=J-3 IF (J) 91,91,93 91 CALL VB06A (M,N,XD,YD,WD,RD,XN,FN,GN,DN,THETA,IABS(IPRINT),W) 90 RETURN END
bsd-3-clause
yxiong/xyMatlabUtils-release
xyCppUtils/ThirdParty/eigen/lapack/iladlc.f
272
2952
*> \brief \b ILADLC * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download ILADLC + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/iladlc.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/iladlc.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/iladlc.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * INTEGER FUNCTION ILADLC( M, N, A, LDA ) * * .. Scalar Arguments .. * INTEGER M, N, LDA * .. * .. Array Arguments .. * DOUBLE PRECISION A( LDA, * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> ILADLC scans A for its last non-zero column. *> \endverbatim * * Arguments: * ========== * *> \param[in] M *> \verbatim *> M is INTEGER *> The number of rows of the matrix A. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of columns of the matrix A. *> \endverbatim *> *> \param[in] A *> \verbatim *> A is DOUBLE PRECISION array, dimension (LDA,N) *> The m by n matrix A. *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the array A. LDA >= max(1,M). *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup auxOTHERauxiliary * * ===================================================================== INTEGER FUNCTION ILADLC( M, N, A, LDA ) * * -- LAPACK auxiliary routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. INTEGER M, N, LDA * .. * .. Array Arguments .. DOUBLE PRECISION A( LDA, * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO PARAMETER ( ZERO = 0.0D+0 ) * .. * .. Local Scalars .. INTEGER I * .. * .. Executable Statements .. * * Quick test for the common case where one corner is non-zero. IF( N.EQ.0 ) THEN ILADLC = N ELSE IF( A(1, N).NE.ZERO .OR. A(M, N).NE.ZERO ) THEN ILADLC = N ELSE * Now scan each column from the end, returning with the first non-zero. DO ILADLC = N, 1, -1 DO I = 1, M IF( A(I, ILADLC).NE.ZERO ) RETURN END DO END DO END IF RETURN END
mit
nschloe/seacas
packages/seacas/applications/numbers/nu_point2.f
1
4950
C Copyright(C) 1988-2017 National Technology & Engineering Solutions C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C $Id: point2.f,v 1.1 1991/02/21 15:44:54 gdsjaar Exp $ C $Log: point2.f,v $ C Revision 1.1 1991/02/21 15:44:54 gdsjaar C Initial revision C C======================================================================= SUBROUTINE POINT2 (COORD, NUMNP, DIST, NDIM, P1, TOLER, * NODEL, SORTYP, MAP, ANGLE, SORUP, INUM, OPT, SELECT) C======================================================================= DIMENSION COORD (NUMNP, *), DIST(*), P1(*), TOLER(*), * MAP(*), ANGLE(*) CHARACTER*(*) NODEL, SORTYP, OPT LOGICAL SORUP, SELECT(*), ISABRT include 'nu_io.blk' PI = ATAN2(0.0, -1.0) C CALL LOCOUT ('POINT', NDIM, NODEL, TOLER, SORTYP, P1, P1, ' ') C TEMP = TOLER(1) TOLER(1) = MAX(0.0, TEMP - TOLER(2)) TOLER(2) = MAX(0.0, TEMP + TOLER(2)) C X1 = P1(1) Y1 = P1(2) C DO 10 I=1, NUMNP IF (SELECT(I)) THEN X0 = COORD(I,1) Y0 = COORD(I,2) C DIST(I) = (X1 - X0)**2 + (Y1 - Y0)**2 C END IF 10 CONTINUE INUM = 0 DISMIN = 1.0E30 DO 20 I=1, NUMNP IF (SELECT(I)) THEN DISMIN = MIN(DIST(I), ABS(DISMIN-TEMP)) IF (DIST(I) .GE. TOLER(1)**2 .AND. DIST(I) .LE. TOLER(2)**2) * THEN INUM = INUM + 1 MAP(INUM) = I DX = COORD(I,1) - P1(1) DY = COORD(I,2) - P1(2) FIX = SIGN(0.5,ABS(DX+DY)) + SIGN(0.5,-ABS(DX+DY)) ANGLE(I) = ATAN2(DY,DX+FIX) * 180.0 / PI END IF END IF 20 CONTINUE IF (INUM .GT. 0) THEN IF (SORTYP .EQ. 'X') THEN CALL INDEXX (COORD(1,1), MAP, INUM, .FALSE.) ELSE IF (SORTYP .EQ. 'Y') THEN CALL INDEXX (COORD(1,2), MAP, INUM, .FALSE.) ELSE IF (SORTYP .EQ. 'ANGLE') THEN CALL INDEXX (ANGLE, MAP, INUM, .FALSE.) ELSE IF (SORTYP .EQ. 'THETA') THEN CALL INDEXX (ANGLE, MAP, INUM, .FALSE.) ELSE IF (SORTYP .EQ. 'DISTANCE') THEN CALL INDEXX (DIST, MAP, INUM, .FALSE.) END IF END IF IF (SORUP) THEN IBEG = 1 IEND = INUM IINC = 1 ELSE IBEG = INUM IEND = 1 IINC = -1 END IF IF (OPT .EQ. '*' .OR. INDEX(OPT, 'P') .GT. 0) THEN DO 30 IO=IOMIN, IOMAX WRITE (IO, 40) NODEL 30 CONTINUE 40 FORMAT (/,2X,A8,' X Y DISTANCE THETA') DO 60 IN = IBEG, IEND, IINC IF (ISABRT()) RETURN I = MAP(IN) DO 50 IO=IOMIN, IOMAX WRITE (IO, 90) I, (COORD(I,J),J=1,2), SQRT(DIST(I)), * ANGLE(I) 50 CONTINUE 60 CONTINUE C IF (INUM .EQ. 0) THEN DO 70 IO=IOMIN, IOMAX WRITE (IO, 80) SQRT(DISMIN) 70 CONTINUE END IF END IF 80 FORMAT (/' None found within range, minimum distance = ', * 1PE12.3,/) 90 FORMAT (I10, 2(F10.4), 2(1PE12.3)) RETURN END
bsd-3-clause
puppeh/gcc-6502
libgomp/testsuite/libgomp.oacc-fortran/lib-10.f90
72
1898
! { dg-do run } program main implicit none include "openacc_lib.h" integer, target :: a_3d_i(10, 10, 10) complex a_3d_c(10, 10, 10) real a_3d_r(10, 10, 10) integer i, j, k complex c real r integer, parameter :: i_size = sizeof (i) integer, parameter :: c_size = sizeof (c) integer, parameter :: r_size = sizeof (r) if (acc_get_num_devices (acc_device_nvidia) .eq. 0) call exit call acc_init (acc_device_nvidia) call set3d (.FALSE., a_3d_i, a_3d_c, a_3d_r) call acc_copyin (a_3d_i) call acc_copyin (a_3d_c) call acc_copyin (a_3d_r) if (acc_is_present (a_3d_i) .neqv. .TRUE.) call abort if (acc_is_present (a_3d_c) .neqv. .TRUE.) call abort if (acc_is_present (a_3d_r) .neqv. .TRUE.) call abort do i = 1, 10 do j = 1, 10 do k = 1, 10 if (acc_is_present (a_3d_i(i, j, k), i_size) .neqv. .TRUE.) call abort if (acc_is_present (a_3d_c(i, j, k), i_size) .neqv. .TRUE.) call abort if (acc_is_present (a_3d_r(i, j, k), i_size) .neqv. .TRUE.) call abort end do end do end do call acc_shutdown (acc_device_nvidia) contains subroutine set3d (clear, a_i, a_c, a_r) logical clear integer, dimension (:,:,:), intent (inout) :: a_i complex, dimension (:,:,:), intent (inout) :: a_c real, dimension (:,:,:), intent (inout) :: a_r integer i, j, k integer lb1, ub1, lb2, ub2, lb3, ub3 lb1 = lbound (a_i, 1) ub1 = ubound (a_i, 1) lb2 = lbound (a_i, 2) ub2 = ubound (a_i, 2) lb3 = lbound (a_i, 3) ub3 = ubound (a_i, 3) do i = lb1, ub1 do j = lb2, ub2 do k = lb3, ub3 if (clear) then a_i(i, j, k) = 0 a_c(i, j, k) = cmplx (0.0, 0.0) a_r(i, j, k) = 0.0 else a_i(i, j, k) = i a_c(i, j, k) = cmplx (i, j) a_r(i, j, k) = i end if end do end do end do end subroutine end program
gpl-2.0
fedya/aircam-openwrt
build_dir/toolchain-arm_v5te_gcc-linaro_uClibc-0.9.32_eabi/gcc-linaro-4.5-2011.02-0/libgfortran/generated/_abs_r16.F90
22
1479
! Copyright 2002, 2007, 2009 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_16) #ifdef HAVE_FABSL elemental function _gfortran_specific__abs_r16 (parm) real (kind=16), intent (in) :: parm real (kind=16) :: _gfortran_specific__abs_r16 _gfortran_specific__abs_r16 = abs (parm) end function #endif #endif
gpl-2.0
nschloe/seacas
packages/seacas/applications/grepos/gp_elementize.f
1
2672
C Copyright(C) 2011-2017 National Technology & Engineering Solutions of C Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. subroutine elementize(var_nod, var_el, * nelblk, numelb, numlnk, link) real var_nod(*), var_el(*) integer numelb(*), numlnk(*), link(*) IELNK = 0 IE = 0 DO 100 IELB = 1, nelblk IS = IE + 1 IE = IE + NUMELB(IELB) ISLNK = IELNK + 1 IELNK = IELNK + NUMLNK(IELB) * NUMELB(IELB) CALL elemtz1(var_nod, var_el(is), * NUMELB(IELB), NUMLNK(IELB), LINK(ISLNK)) 100 CONTINUE RETURN END subroutine elemtz1(var_nod, var_el, numelb, numlnk, link) real var_nod(*) real var_el(*) integer numelb, numlnk integer link(numlnk,*) do 20 ne=1, numelb var = 0.0 do 10 j=1, numlnk var = var + var_nod(link(j,ne)) 10 continue rnodes = numlnk var_el(ne) = var / rnodes 20 continue return end
bsd-3-clause
nschloe/seacas
packages/seacas/libraries/suplib/ffonof.f
1
3472
C Copyright(C) 2009-2017 National Technology & Engineering Solutions C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C======================================================================= SUBROUTINE FFONOF (IFLD, INTYP, CFIELD, ISON, *) C======================================================================= C$Id: ffonof.f,v 1.2 2009/03/25 12:46:02 gdsjaar Exp $ C$Log: ffonof.f,v $ CRevision 1.2 2009/03/25 12:46:02 gdsjaar CAdd copyright and license notice to all files. C CRevision 1.1.1.1 1990/08/14 16:14:36 gdsjaar CTesting C c Revision 1.1 90/08/14 16:14:35 gdsjaar c Initial revision c c Revision 1.1 90/08/09 13:39:26 gdsjaar c Initial revision c C --*** FFONOF *** (FFLIB) Parse free-field ON/OFF C -- Written by Amy Gilkey - revised 02/24/86 C -- C --FFONOF parses an on/off option from an input field. No field is C --assumed 'ON'. C -- C --Parameters: C -- IFLD - IN/OUT - the index of the current field number, incremented C -- INTYP - IN - the input type from the free-field reader C -- CFIELD - IN - the input option string C -- ISON - OUT - true iff the option is ON, set only if no error C -- * - return statement if the field is invalid; message is printed INTEGER IFLD INTEGER INTYP(*) CHARACTER*(*) CFIELD(*) LOGICAL ISON CHARACTER*4 OPT IF (INTYP(IFLD) .EQ. 0) THEN OPT = CFIELD(IFLD) ELSE IF (INTYP(IFLD) .LE. -1) THEN OPT = 'ON' ELSE OPT = ' ' END IF IF ((OPT(:2) .NE. 'ON') .AND. (OPT(:3) .NE. 'OFF')) THEN CALL PRTERR ('CMDERR', 'Expected "ON" or "OFF"') GOTO 100 END IF ISON = (OPT(:2) .EQ. 'ON') IF (INTYP(IFLD) .GE. -1) IFLD = IFLD + 1 RETURN 100 CONTINUE IF (INTYP(IFLD) .GE. -1) IFLD = IFLD + 1 RETURN 1 END
bsd-3-clause
nschloe/seacas
packages/seacas/applications/blot/tplabn.f
1
4094
C Copyright(C) 2009-2017 National Technology & Engineering Solutions of C Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C======================================================================= SUBROUTINE TPLABN (IPVAR, TIMLIM, NAMES, PLTITL, TXLAB, TYLAB, * MAPEL, MAPND) C======================================================================= C --*** TPLABN *** (TPLOT) Get neutral file plot labels C -- Written by Amy Gilkey - revised 03/23/87 C -- C --TPLABN makes up the plot titles and labels for the neutral file. C -- C --Parameters: C -- IPVAR - IN - the /TPVARS/ index of the starting plot variable C -- TIMLIM - IN - the starting and ending times for a C -- variable-versus-variable curve C -- NAMES - IN - the variable names C -- PLTITL - OUT - the plot title describing the curves to be C -- plotted (e.g. "TIME vs SIGXX at ELEMENT 30" or C -- "LOAD vs SIGXX at ELEMENT 30 for times 0.000 to 15.000") C -- TXLAB, TYLAB - OUT - the X and Y axis labels, either the C -- user-input labels or the plot variable descriptions C -- C --Common Variables: C -- Uses TIMPLT, ITVID, ITVNE of /TPVARS/ C -- Uses XLAB, YLAB of /XYLAB/ include 'params.blk' include 'tpvars.blk' include 'xylab.blk' REAL TIMLIM(2) CHARACTER*(*) NAMES(*) CHARACTER*(*) PLTITL CHARACTER*(*) TXLAB, TYLAB INTEGER MAPEL(*), MAPND(*) CHARACTER*(1024) PV1, PV2 CHARACTER*20 RSTR(2) C --Get the plot legend N = IPVAR IF (TIMPLT) THEN PV1 = 'TIME' CALL TPLABV (-1, ITVID(N), NAMES(ITVID(N)), ITVNE(N), PV2, * MAPEL, MAPND) PLTITL = PV1(:LENSTR(PV1)) // ' vs ' // PV2(:LENSTR(PV2)) write (*,*) pltitl(:lenstr(pltitl)) ELSE CALL TPLABV (-1, ITVID(N), NAMES(ITVID(N)), ITVNE(N), PV1, * MAPEL, MAPND) N = N + 1 CALL TPLABV (-1, ITVID(N), NAMES(ITVID(N)), ITVNE(N), PV2, * MAPEL, MAPND) CALL NUMSTR (2, 4, TIMLIM, RSTR, LSTR) PLTITL = PV1(:LENSTR(PV1)) // ' vs ' // PV2(:LENSTR(PV2)) & // ' for times ' // RSTR(1)(:LENSTR(RSTR(1))) & // ' to ' // RSTR(2)(:LSTR) END IF C --Get the axis labels IF (XLAB .NE. ' ') THEN TXLAB = XLAB ELSE TXLAB = PV1 END IF IF (YLAB .NE. ' ') THEN TYLAB = YLAB ELSE TYLAB = PV2 END IF RETURN END
bsd-3-clause
pscholz/presto
src/slalib/dafin.f
4
6035
SUBROUTINE sla_DAFIN (STRING, IPTR, A, J) *+ * - - - - - - * D A F I N * - - - - - - * * Sexagesimal character string to angle (double precision) * * Given: * STRING c*(*) string containing deg, arcmin, arcsec fields * IPTR i pointer to start of decode (1st = 1) * * Returned: * IPTR i advanced past the decoded angle * A d angle in radians * J i status: 0 = OK * +1 = default, A unchanged * -1 = bad degrees ) * -2 = bad arcminutes ) (note 3) * -3 = bad arcseconds ) * * Example: * * argument before after * * STRING '-57 17 44.806 12 34 56.7' unchanged * IPTR 1 16 (points to 12...) * A ? -1.00000D0 * J ? 0 * * A further call to sla_DAFIN, without adjustment of IPTR, will * decode the second angle, 12deg 34min 56.7sec. * * Notes: * * 1) The first three "fields" in STRING are degrees, arcminutes, * arcseconds, separated by spaces or commas. The degrees field * may be signed, but not the others. The decoding is carried * out by the DFLTIN routine and is free-format. * * 2) Successive fields may be absent, defaulting to zero. For * zero status, the only combinations allowed are degrees alone, * degrees and arcminutes, and all three fields present. If all * three fields are omitted, a status of +1 is returned and A is * unchanged. In all other cases A is changed. * * 3) Range checking: * * The degrees field is not range checked. However, it is * expected to be integral unless the other two fields are absent. * * The arcminutes field is expected to be 0-59, and integral if * the arcseconds field is present. If the arcseconds field * is absent, the arcminutes is expected to be 0-59.9999... * * The arcseconds field is expected to be 0-59.9999... * * 4) Decoding continues even when a check has failed. Under these * circumstances the field takes the supplied value, defaulting * to zero, and the result A is computed and returned. * * 5) Further fields after the three expected ones are not treated * as an error. The pointer IPTR is left in the correct state * for further decoding with the present routine or with DFLTIN * etc. See the example, above. * * 6) If STRING contains hours, minutes, seconds instead of degrees * etc, or if the required units are turns (or days) instead of * radians, the result A should be multiplied as follows: * * for to obtain multiply * STRING A in A by * * d ' " radians 1 = 1D0 * d ' " turns 1/2pi = 0.1591549430918953358D0 * h m s radians 15 = 15D0 * h m s days 15/2pi = 2.3873241463784300365D0 * * Called: sla_DFLTIN * * P.T.Wallace Starlink 1 August 1996 * * Copyright (C) 1996 Rutherford Appleton Laboratory * * License: * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see SLA_CONDITIONS); if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * *- IMPLICIT NONE CHARACTER*(*) STRING INTEGER IPTR DOUBLE PRECISION A INTEGER J DOUBLE PRECISION AS2R PARAMETER (AS2R=4.84813681109535993589914102358D-6) INTEGER JF,JD,JM,JS DOUBLE PRECISION DEG,ARCMIN,ARCSEC * Preset the status to OK JF=0 * Defaults DEG=0D0 ARCMIN=0D0 ARCSEC=0D0 * Decode degrees, arcminutes, arcseconds CALL sla_DFLTIN(STRING,IPTR,DEG,JD) IF (JD.GT.1) THEN JF=-1 ELSE CALL sla_DFLTIN(STRING,IPTR,ARCMIN,JM) IF (JM.LT.0.OR.JM.GT.1) THEN JF=-2 ELSE CALL sla_DFLTIN(STRING,IPTR,ARCSEC,JS) IF (JS.LT.0.OR.JS.GT.1) THEN JF=-3 * See if the combination of fields is credible ELSE IF (JD.GT.0) THEN * No degrees: arcmin, arcsec ought also to be absent IF (JM.EQ.0) THEN * Suspect arcmin JF=-2 ELSE IF (JS.EQ.0) THEN * Suspect arcsec JF=-3 ELSE * All three fields absent JF=1 END IF * Degrees present: if arcsec present so ought arcmin to be ELSE IF (JM.NE.0.AND.JS.EQ.0) THEN JF=-3 * Tests for range and integrality * Degrees ELSE IF (JM.EQ.0.AND.DINT(DEG).NE.DEG) THEN JF=-1 * Arcminutes ELSE IF ((JS.EQ.0.AND.DINT(ARCMIN).NE.ARCMIN).OR. : ARCMIN.GE.60D0) THEN JF=-2 * Arcseconds ELSE IF (ARCSEC.GE.60D0) THEN JF=-3 END IF END IF END IF * Unless all three fields absent, compute angle value IF (JF.LE.0) THEN A=AS2R*(60D0*(60D0*ABS(DEG)+ARCMIN)+ARCSEC) IF (JD.LT.0) A=-A END IF * Return the status J=JF END
gpl-2.0
tm1249wk/WASHLIGGGHTS-3.3.x
lib/linalg/dlaswp.f
75
5055
*> \brief \b DLASWP performs a series of row interchanges on a general rectangular matrix. * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DLASWP + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaswp.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaswp.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaswp.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE DLASWP( N, A, LDA, K1, K2, IPIV, INCX ) * * .. Scalar Arguments .. * INTEGER INCX, K1, K2, LDA, N * .. * .. Array Arguments .. * INTEGER IPIV( * ) * DOUBLE PRECISION A( LDA, * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DLASWP performs a series of row interchanges on the matrix A. *> One row interchange is initiated for each of rows K1 through K2 of A. *> \endverbatim * * Arguments: * ========== * *> \param[in] N *> \verbatim *> N is INTEGER *> The number of columns of the matrix A. *> \endverbatim *> *> \param[in,out] A *> \verbatim *> A is DOUBLE PRECISION array, dimension (LDA,N) *> On entry, the matrix of column dimension N to which the row *> interchanges will be applied. *> On exit, the permuted matrix. *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the array A. *> \endverbatim *> *> \param[in] K1 *> \verbatim *> K1 is INTEGER *> The first element of IPIV for which a row interchange will *> be done. *> \endverbatim *> *> \param[in] K2 *> \verbatim *> K2 is INTEGER *> The last element of IPIV for which a row interchange will *> be done. *> \endverbatim *> *> \param[in] IPIV *> \verbatim *> IPIV is INTEGER array, dimension (K2*abs(INCX)) *> The vector of pivot indices. Only the elements in positions *> K1 through K2 of IPIV are accessed. *> IPIV(K) = L implies rows K and L are to be interchanged. *> \endverbatim *> *> \param[in] INCX *> \verbatim *> INCX is INTEGER *> The increment between successive values of IPIV. If IPIV *> is negative, the pivots are applied in reverse order. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup doubleOTHERauxiliary * *> \par Further Details: * ===================== *> *> \verbatim *> *> Modified by *> R. C. Whaley, Computer Science Dept., Univ. of Tenn., Knoxville, USA *> \endverbatim *> * ===================================================================== SUBROUTINE DLASWP( N, A, LDA, K1, K2, IPIV, INCX ) * * -- LAPACK auxiliary routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. INTEGER INCX, K1, K2, LDA, N * .. * .. Array Arguments .. INTEGER IPIV( * ) DOUBLE PRECISION A( LDA, * ) * .. * * ===================================================================== * * .. Local Scalars .. INTEGER I, I1, I2, INC, IP, IX, IX0, J, K, N32 DOUBLE PRECISION TEMP * .. * .. Executable Statements .. * * Interchange row I with row IPIV(I) for each of rows K1 through K2. * IF( INCX.GT.0 ) THEN IX0 = K1 I1 = K1 I2 = K2 INC = 1 ELSE IF( INCX.LT.0 ) THEN IX0 = 1 + ( 1-K2 )*INCX I1 = K2 I2 = K1 INC = -1 ELSE RETURN END IF * N32 = ( N / 32 )*32 IF( N32.NE.0 ) THEN DO 30 J = 1, N32, 32 IX = IX0 DO 20 I = I1, I2, INC IP = IPIV( IX ) IF( IP.NE.I ) THEN DO 10 K = J, J + 31 TEMP = A( I, K ) A( I, K ) = A( IP, K ) A( IP, K ) = TEMP 10 CONTINUE END IF IX = IX + INCX 20 CONTINUE 30 CONTINUE END IF IF( N32.NE.N ) THEN N32 = N32 + 1 IX = IX0 DO 50 I = I1, I2, INC IP = IPIV( IX ) IF( IP.NE.I ) THEN DO 40 K = N32, N TEMP = A( I, K ) A( I, K ) = A( IP, K ) A( IP, K ) = TEMP 40 CONTINUE END IF IX = IX + INCX 50 CONTINUE END IF * RETURN * * End of DLASWP * END
gpl-2.0
scattering-central/CCP13
software/libs/bsl/imsize.f
1
2037
C LAST UPDATE 15/09/88 C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C SUBROUTINE IMSIZE (ITERM,IPRINT,NPIX,NRAST,IFPIX,ILPIX, & IFRAST,ILRAST,IRC) IMPLICIT NONE C C PURPOSE: ALLOW USER TO SELECT A SECTION OF THE IMAGE. C INTEGER ITERM,IPRINT,NPIX,NRAST,IFPIX,ILPIX,IFRAST,ILRAST,IRC C C ITERM : TERMINAL INPUT C IPRINT : TERMINAL OUTPUT C NPIX : NOS. OF PIXELS IN IMAGE C NRAST : NOS. OF RASTERS IN IMAGE C IFPIX : FIRST PIXEL OF SECTION C ILPIX : LAST PIXEL OF SECTION C IFRAST : FIRST RASTER OF SECTION C ILRAST : LAST RASTER OF SECTION C IRC : RETURN CODE C C CALLS 2: ERRMSG , GETVAL C C-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- C LOCAL VARIABLES: C REAL VALUE(10) INTEGER ITEMP,NVAL C C----------------------------------------------------------------------- C C========GET INTEGRATION LIMITS C 20 WRITE (IPRINT,1000) NPIX,NRAST CALL FLUSH(IPRINT) IFPIX=1 ILPIX=NPIX IFRAST=1 ILRAST=NRAST CALL GETVAL (ITERM,VALUE,NVAL,IRC) IF (IRC.EQ.1) GOTO 999 IF (IRC.EQ.2) GOTO 20 IF (NVAL.GT.0) IFPIX=INT(VALUE(1)) IF (NVAL.GT.1) ILPIX=INT(VALUE(2)) IF (NVAL.GT.2) IFRAST=INT(VALUE(3)) IF (NVAL.GT.3) ILRAST=INT(VALUE(4)) C C======CHECK VALUES LIE WITHIN CORRECT LIMITS C IF (IFPIX.LT.1) IFPIX=1 IF (ILPIX.LT.1) ILPIX=1 IF (IFPIX.GT.NPIX) IFPIX=NPIX IF (ILPIX.GT.NPIX) ILPIX=NPIX IF (IFRAST.LT.1) IFRAST=1 IF (ILRAST.LT.1) ILRAST=1 IF (IFRAST.GT.NRAST) IFRAST=NRAST IF (ILRAST.GT.NRAST) ILRAST=NRAST IF (ILPIX.LT.IFPIX) THEN ITEMP=IFPIX IFPIX=ILPIX ILPIX=ITEMP ENDIF IF (ILRAST.LT.IFRAST) THEN ITEMP=IFRAST IFRAST=ILRAST ILRAST=ITEMP ENDIF 999 RETURN C 1000 FORMAT (' Enter first & last pixels and',/,' first & last' & ' rasters or <CTRL-Z> [1,',I4,',1,',I4,']: ',$) END
bsd-3-clause
scipy/scipy
scipy/integrate/quadpack/dqawo.f
10
10489
recursive subroutine dqawo(f,a,b,omega,integr,epsabs,epsrel, * result,abserr,neval,ier,leniw,maxp1,lenw,last,iwork,work) c***begin prologue dqawo c***date written 800101 (yymmdd) c***revision date 830518 (yymmdd) c***category no. h2a2a1 c***keywords automatic integrator, special-purpose, c integrand with oscillatory cos or sin factor, c clenshaw-curtis method, (end point) singularities, 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(x)*w(x) over (a,b) c where w(x) = cos(omega*x) c or w(x) = sin(omega*x), c hopefully satisfying following claim for accuracy c abs(i-result).le.max(epsabs,epsrel*abs(i)). c***description c c computation of oscillatory integrals c standard fortran subroutine c double precision version c c parameters c on entry c f - double precision c function subprogram defining the function c 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 omega - double precision c parameter in the integrand weight function c c integr - integer c indicates which of the weight functions is used c integr = 1 w(x) = cos(omega*x) c integr = 2 w(x) = sin(omega*x) c if integr.ne.1.and.integr.ne.2, the routine will c end with ier = 6. c c epsabs - double precision c absolute accuracy requested c epsrel - double precision c relative accuracy requested c if epsabs.le.0 and c 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 (= leniw/2) has been achieved. one can c allow more subdivisions by increasing the c value of leniw (and taking the according c dimension adjustments into account). c however, if this yields no improvement it c is advised to analyze the integrand in c order to determine the integration c difficulties. if the position of a local c difficulty can be determined (e.g. c singularity, discontinuity within the c interval) one will probably gain from c splitting up the interval at this point c and calling the integrator on the c subranges. if possible, an appropriate c special-purpose integrator should be used c which is designed for handling the type of c 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 interior points of the c integration interval. c = 4 the algorithm does not converge. c roundoff error is detected in the c extrapolation table. it is presumed that c the requested tolerance cannot be achieved c due to roundoff in the extrapolation c table, and that the returned result is c the best which 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. c = 6 the input is invalid, because c (epsabs.le.0 and c epsrel.lt.max(50*rel.mach.acc.,0.5d-28)) c or (integr.ne.1 and integr.ne.2), c or leniw.lt.2 or maxp1.lt.1 or c lenw.lt.leniw*2+maxp1*25. c result, abserr, neval, last are set to c zero. except when leniw, maxp1 or lenw are c invalid, work(limit*2+1), work(limit*3+1), c iwork(1), iwork(limit+1) are set to zero, c work(1) is set to a and work(limit+1) to c b. c c dimensioning parameters c leniw - integer c dimensioning parameter for iwork. c leniw/2 equals the maximum number of subintervals c allowed in the partition of the given integration c interval (a,b), leniw.ge.2. c if leniw.lt.2, the routine will end with ier = 6. 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(b-a)*2**(-l), c l=0,1, ..., maxp1-2, maxp1.ge.1 c if maxp1.lt.1, the routine will end with ier = 6. c c lenw - integer c dimensioning parameter for work c lenw must be at least leniw*2+maxp1*25. c if lenw.lt.(leniw*2+maxp1*25), the routine will c end 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 c on return, 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 limit = lenw/2 , and k = last c if last.le.(limit/2+2), and k = limit+1-last c otherwise. c furthermore, iwork(limit+1), ..., iwork(limit+ c last) indicate the subdivision levels of the c subintervals, such that iwork(limit+i) = l means c that the subinterval numbered i is of length c abs(b-a)*2**(1-l). 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 c subintervals, c work(limit*3+1), ..., work(limit*3+last) c contain the error estimates. c work(limit*4+1), ..., work(limit*4+maxp1*25) c provide space for storing the chebyshev moments. c note that limit = lenw/2. c c***references (none) c***routines called dqawoe,xerror c***end prologue dqawo c double precision a,abserr,b,epsabs,epsrel,f,omega,result,work integer ier,integr,iwork,last,limit,lenw,leniw,lvl,l1,l2,l3,l4, * maxp1,momcom,neval c dimension iwork(leniw),work(lenw) c external f c c check validity of leniw, maxp1 and lenw. c c***first executable statement dqawo ier = 6 neval = 0 last = 0 result = 0.0d+00 abserr = 0.0d+00 if(leniw.lt.2.or.maxp1.lt.1.or.lenw.lt.(leniw*2+maxp1*25)) * go to 10 c c prepare call for dqawoe c limit = leniw/2 l1 = limit+1 l2 = limit+l1 l3 = limit+l2 l4 = limit+l3 call dqawoe(f,a,b,omega,integr,epsabs,epsrel,limit,1,maxp1,result, * abserr,neval,ier,last,work(1),work(l1),work(l2),work(l3), * iwork(1),iwork(l1),momcom,work(l4)) c c call error handler if necessary c lvl = 0 10 if(ier.eq.6) lvl = 0 if(ier.ne.0) call xerror('abnormal return from dqawo',26,ier,lvl) return end
bsd-3-clause
pscholz/presto
python/fftfit_src/brent.f
3
1873
C @(#)brent.f 1.1 9/7/90 function zbrent(x1,x2,f1,f2,tol,tmp,pha,nsum) C Brent's method root finding, calls dchisqr(x,tmp,r,nsum) function for fftfit C Fit refined till output accuracy is tol parameter (itmax=100,eps=6.e-8,MAXSAM=8192) real*4 tmp(MAXSAM/2),pha(MAXSAM/2) a=x1 b=x2 fa=f1 fb=f2 fc=fb do 11 iter=1,itmax if(fb*fc.gt.0.) then c=a fc=fa d=b-a e=d end if if(abs(fc).lt.abs(fb)) then a=b b=c c=a fa=fb fb=fc fc=fa end if tol1=2.*eps*abs(b)+0.5*tol xm=.5*(c-b) if(abs(xm).le.tol1 .or. fb.eq.0.) then zbrent=b return end if if(abs(e).ge.tol1 .and. abs(fa).gt.abs(fb)) then s=fb/fa if(a.eq.c) then p=2.*xm*s q=1.-s else q=fa/fc r=fb/fc p=s*(2.*xm*q*(q-r)-(b-a)*(r-1.)) q=(q-1.)*(r-1.)*(s-1.) end if if(p.gt.0.) q=-q p=abs(p) if(2.*p .lt. min(3.*xm*q-abs(tol1*q),abs(e*q))) then e=d d=p/q else d=xm e=d end if else d=xm e=d end if a=b fa=fb if(abs(d) .gt. tol1) then b=b+d else b=b+sign(tol1,xm) end if fb=dchisqr(b,tmp,pha,nsum) 11 continue zbrent=b return end function dchisqr(tau,tmp,r,nsum) parameter (MAXSAM=8192) real*4 tmp(MAXSAM/2),r(MAXSAM/2) s=0. do 40 k=1,nsum 40 s=s+k*tmp(k)*sin(-r(k)+k*tau) dchisqr=s return end
gpl-2.0
vigna/scipy
scipy/special/cdflib/erfc1.f
151
3633
DOUBLE PRECISION FUNCTION erfc1(ind,x) C----------------------------------------------------------------------- C EVALUATION OF THE COMPLEMENTARY ERROR FUNCTION C C ERFC1(IND,X) = ERFC(X) IF IND = 0 C ERFC1(IND,X) = EXP(X*X)*ERFC(X) OTHERWISE C----------------------------------------------------------------------- C .. Scalar Arguments .. DOUBLE PRECISION x INTEGER ind C .. C .. Local Scalars .. DOUBLE PRECISION ax,bot,c,e,t,top,w C .. C .. Local Arrays .. DOUBLE PRECISION a(5),b(3),p(8),q(8),r(5),s(4) C .. C .. External Functions .. DOUBLE PRECISION exparg EXTERNAL exparg C .. C .. Intrinsic Functions .. INTRINSIC abs,dble,exp C .. C .. Data statements .. C------------------------- C------------------------- C------------------------- C------------------------- DATA c/.564189583547756D0/ DATA a(1)/.771058495001320D-04/,a(2)/-.133733772997339D-02/, + a(3)/.323076579225834D-01/,a(4)/.479137145607681D-01/, + a(5)/.128379167095513D+00/ DATA b(1)/.301048631703895D-02/,b(2)/.538971687740286D-01/, + b(3)/.375795757275549D+00/ DATA p(1)/-1.36864857382717D-07/,p(2)/5.64195517478974D-01/, + p(3)/7.21175825088309D+00/,p(4)/4.31622272220567D+01/, + p(5)/1.52989285046940D+02/,p(6)/3.39320816734344D+02/, + p(7)/4.51918953711873D+02/,p(8)/3.00459261020162D+02/ DATA q(1)/1.00000000000000D+00/,q(2)/1.27827273196294D+01/, + q(3)/7.70001529352295D+01/,q(4)/2.77585444743988D+02/, + q(5)/6.38980264465631D+02/,q(6)/9.31354094850610D+02/, + q(7)/7.90950925327898D+02/,q(8)/3.00459260956983D+02/ DATA r(1)/2.10144126479064D+00/,r(2)/2.62370141675169D+01/, + r(3)/2.13688200555087D+01/,r(4)/4.65807828718470D+00/, + r(5)/2.82094791773523D-01/ DATA s(1)/9.41537750555460D+01/,s(2)/1.87114811799590D+02/, + s(3)/9.90191814623914D+01/,s(4)/1.80124575948747D+01/ C .. C .. Executable Statements .. C------------------------- C C ABS(X) .LE. 0.5 C ax = abs(x) IF (ax.GT.0.5D0) GO TO 10 t = x*x top = ((((a(1)*t+a(2))*t+a(3))*t+a(4))*t+a(5)) + 1.0D0 bot = ((b(1)*t+b(2))*t+b(3))*t + 1.0D0 erfc1 = 0.5D0 + (0.5D0-x* (top/bot)) IF (ind.NE.0) erfc1 = exp(t)*erfc1 RETURN C C 0.5 .LT. ABS(X) .LE. 4 C 10 IF (ax.GT.4.0D0) GO TO 20 top = ((((((p(1)*ax+p(2))*ax+p(3))*ax+p(4))*ax+p(5))*ax+p(6))*ax+ + p(7))*ax + p(8) bot = ((((((q(1)*ax+q(2))*ax+q(3))*ax+q(4))*ax+q(5))*ax+q(6))*ax+ + q(7))*ax + q(8) erfc1 = top/bot GO TO 40 C C ABS(X) .GT. 4 C 20 IF (x.LE.-5.6D0) GO TO 60 IF (ind.NE.0) GO TO 30 IF (x.GT.100.0D0) GO TO 70 IF (x*x.GT.-exparg(1)) GO TO 70 C 30 t = (1.0D0/x)**2 top = (((r(1)*t+r(2))*t+r(3))*t+r(4))*t + r(5) bot = (((s(1)*t+s(2))*t+s(3))*t+s(4))*t + 1.0D0 erfc1 = (c-t*top/bot)/ax C C FINAL ASSEMBLY C 40 IF (ind.EQ.0) GO TO 50 IF (x.LT.0.0D0) erfc1 = 2.0D0*exp(x*x) - erfc1 RETURN 50 w = dble(x)*dble(x) t = w e = w - dble(t) erfc1 = ((0.5D0+ (0.5D0-e))*exp(-t))*erfc1 IF (x.LT.0.0D0) erfc1 = 2.0D0 - erfc1 RETURN C C LIMIT VALUE FOR LARGE NEGATIVE X C 60 erfc1 = 2.0D0 IF (ind.NE.0) erfc1 = 2.0D0*exp(x*x) RETURN C C LIMIT VALUE FOR LARGE POSITIVE X C WHEN IND = 0 C 70 erfc1 = 0.0D0 RETURN END
bsd-3-clause
fuesika/mmtl
bem/src/ext/sgedi.F
2
3501
SUBROUTINE SGEDI(A,LDA,N,IPVT,DET,WORK,JOB) INTEGER LDA,N,IPVT(*),JOB REAL A(LDA,*),DET(2),WORK(*) C C SGEDI COMPUTES THE DETERMINANT AND INVERSE OF A MATRIX C USING THE FACTORS COMPUTED BY SGECO OR SGEFA. C C ON ENTRY C C A REAL(LDA, N) C THE OUTPUT FROM SGECO OR SGEFA. C C LDA INTEGER C THE LEADING DIMENSION OF THE ARRAY A . C C N INTEGER C THE ORDER OF THE MATRIX A . C C IPVT INTEGER(N) C THE PIVOT VECTOR FROM SGECO OR SGEFA. C C WORK REAL(N) C WORK VECTOR. CONTENTS DESTROYED. C C JOB INTEGER C = 11 BOTH DETERMINANT AND INVERSE. C = 01 INVERSE ONLY. C = 10 DETERMINANT ONLY. C C ON RETURN C C A INVERSE OF ORIGINAL MATRIX IF REQUESTED. C OTHERWISE UNCHANGED. C C DET REAL(2) C DETERMINANT OF ORIGINAL MATRIX IF REQUESTED. C OTHERWISE NOT REFERENCED. C DETERMINANT = DET(1) * 10.0**DET(2) C WITH 1.0 .LE. ABS(DET(1)) .LT. 10.0 C OR DET(1) .EQ. 0.0 . C C ERROR CONDITION C C A DIVISION BY ZERO WILL OCCUR IF THE INPUT FACTOR CONTAINS C A ZERO ON THE DIAGONAL AND THE INVERSE IS REQUESTED. C IT WILL NOT OCCUR IF THE SUBROUTINES ARE CALLED CORRECTLY C AND IF SGECO HAS SET RCOND .GT. 0.0 OR SGEFA HAS SET C INFO .EQ. 0 . C C LINPACK. THIS VERSION DATED 08/14/78 . C CLEVE MOLER, UNIVERSITY OF NEW MEXICO, ARGONNE NATIONAL LAB. C C SUBROUTINES AND FUNCTIONS C C BLAS SAXPY,SSCAL,SSWAP C FORTRAN ABS,MOD C C INTERNAL VARIABLES C REAL T REAL TEN INTEGER I,J,K,KB,KP1,L,NM1 C C C COMPUTE DETERMINANT C IF (JOB/10 .EQ. 0) GO TO 70 DET(1) = 1.0E0 DET(2) = 0.0E0 TEN = 10.0E0 DO 50 I = 1, N IF (IPVT(I) .NE. I) DET(1) = -DET(1) DET(1) = A(I,I)*DET(1) C ...EXIT IF (DET(1) .EQ. 0.0E0) GO TO 60 10 IF (ABS(DET(1)) .GE. 1.0E0) GO TO 20 DET(1) = TEN*DET(1) DET(2) = DET(2) - 1.0E0 GO TO 10 20 CONTINUE 30 IF (ABS(DET(1)) .LT. TEN) GO TO 40 DET(1) = DET(1)/TEN DET(2) = DET(2) + 1.0E0 GO TO 30 40 CONTINUE 50 CONTINUE 60 CONTINUE 70 CONTINUE C C COMPUTE INVERSE(U) C IF (MOD(JOB,10) .EQ. 0) GO TO 150 DO 100 K = 1, N A(K,K) = 1.0E0/A(K,K) T = -A(K,K) CALL SSCAL(K-1,T,A(1,K),1) KP1 = K + 1 IF (N .LT. KP1) GO TO 90 DO 80 J = KP1, N T = A(K,J) A(K,J) = 0.0E0 CALL SAXPY(K,T,A(1,K),1,A(1,J),1) 80 CONTINUE 90 CONTINUE 100 CONTINUE C C FORM INVERSE(U)*INVERSE(L) C NM1 = N - 1 IF (NM1 .LT. 1) GO TO 140 DO 130 KB = 1, NM1 K = N - KB KP1 = K + 1 DO 110 I = KP1, N WORK(I) = A(I,K) A(I,K) = 0.0E0 110 CONTINUE DO 120 J = KP1, N T = WORK(J) CALL SAXPY(N,T,A(1,J),1,A(1,K),1) 120 CONTINUE L = IPVT(K) IF (L .NE. K) CALL SSWAP(N,A(1,K),1,A(1,L),1) 130 CONTINUE 140 CONTINUE 150 CONTINUE RETURN END
gpl-2.0
dch312/scipy
scipy/integrate/quadpack/dqpsrt.f
147
4243
subroutine dqpsrt(limit,last,maxerr,ermax,elist,iord,nrmax) c***begin prologue dqpsrt c***refer to dqage,dqagie,dqagpe,dqawse c***routines called (none) c***revision date 810101 (yymmdd) c***keywords sequential sorting c***author piessens,robert,appl. math. & progr. div. - k.u.leuven c de doncker,elise,appl. math. & progr. div. - k.u.leuven c***purpose this routine maintains the descending ordering in the c list of the local error estimated resulting from the c interval subdivision process. at each call two error c estimates are inserted using the sequential search c method, top-down for the largest error estimate and c bottom-up for the smallest error estimate. c***description c c ordering routine c standard fortran subroutine c double precision version c c parameters (meaning at output) c limit - integer c maximum number of error estimates the list c can contain c c last - integer c number of error estimates currently in the list c c maxerr - integer c maxerr points to the nrmax-th largest error c estimate currently in the list c c ermax - double precision c nrmax-th largest error estimate c ermax = elist(maxerr) c c elist - double precision c vector of dimension last containing c the error estimates c c iord - integer c vector of dimension last, the first k elements c of which contain pointers to the error c estimates, such that c elist(iord(1)),..., elist(iord(k)) c form a decreasing sequence, with c k = last if last.le.(limit/2+2), and c k = limit+1-last otherwise c c nrmax - integer c maxerr = iord(nrmax) c c***end prologue dqpsrt c double precision elist,ermax,errmax,errmin integer i,ibeg,ido,iord,isucc,j,jbnd,jupbn,k,last,limit,maxerr, * nrmax dimension elist(last),iord(last) c c check whether the list contains more than c two error estimates. c c***first executable statement dqpsrt if(last.gt.2) go to 10 iord(1) = 1 iord(2) = 2 go to 90 c c this part of the routine is only executed if, due to a c difficult integrand, subdivision increased the error c estimate. in the normal case the insert procedure should c start after the nrmax-th largest error estimate. c 10 errmax = elist(maxerr) if(nrmax.eq.1) go to 30 ido = nrmax-1 do 20 i = 1,ido isucc = iord(nrmax-1) c ***jump out of do-loop if(errmax.le.elist(isucc)) go to 30 iord(nrmax) = isucc nrmax = nrmax-1 20 continue c c compute the number of elements in the list to be maintained c in descending order. this number depends on the number of c subdivisions still allowed. c 30 jupbn = last if(last.gt.(limit/2+2)) jupbn = limit+3-last errmin = elist(last) c c insert errmax by traversing the list top-down, c starting comparison from the element elist(iord(nrmax+1)). c jbnd = jupbn-1 ibeg = nrmax+1 if(ibeg.gt.jbnd) go to 50 do 40 i=ibeg,jbnd isucc = iord(i) c ***jump out of do-loop if(errmax.ge.elist(isucc)) go to 60 iord(i-1) = isucc 40 continue 50 iord(jbnd) = maxerr iord(jupbn) = last go to 90 c c insert errmin by traversing the list bottom-up. c 60 iord(i-1) = maxerr k = jbnd do 70 j=i,jbnd isucc = iord(k) c ***jump out of do-loop if(errmin.lt.elist(isucc)) go to 80 iord(k+1) = isucc k = k-1 70 continue iord(i) = last go to 90 80 iord(k+1) = last c c set maxerr and ermax. c 90 maxerr = iord(nrmax) ermax = elist(maxerr) return end
bsd-3-clause
nschloe/seacas
packages/seacas/applications/blot/bl_rotate.f
1
3039
C Copyright(C) 2009-2017 National Technology & Engineering Solutions of C Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C======================================================================= SUBROUTINE BL_ROTATE (NUM, NPROT, ROTMAT, ROTCEN, & XN, YN, ZN, HZ, VT, PD) C======================================================================= C --*** ROTATE *** (MESH) Rotate 3D coordinates C -- Written by Amy Gilkey - revised 09/09/87 C -- C --ROTATE rotates the 3D coordinates by subtracting the rotation center C --and multipling by the rotation matrix. C -- C --Parameters: C -- NUM - IN - the number of nodes to rotate C -- NPROT - IN - the node numbers of the nodes to rotate C -- ROTMAT - IN - the rotation matrix C -- ROTCEN - IN - the center of the rotation C -- XN, YN, ZN - IN - the original nodal coordinates C -- HZ, VT, PD - OUT - the rotated nodal coordinates INTEGER NPROT(NUM) REAL ROTMAT(3,3), ROTCEN(3) REAL XN(*), YN(*), ZN(*) REAL HZ(*), VT(*), PD(*) DO 100 IX = 1, NUM INP = NPROT(IX) X = XN(INP) - ROTCEN(1) Y = YN(INP) - ROTCEN(2) Z = ZN(INP) - ROTCEN(3) HZ(INP) = X*ROTMAT(1,1) + Y*ROTMAT(2,1) + Z*ROTMAT(3,1) VT(INP) = X*ROTMAT(1,2) + Y*ROTMAT(2,2) + Z*ROTMAT(3,2) PD(INP) = X*ROTMAT(1,3) + Y*ROTMAT(2,3) + Z*ROTMAT(3,3) 100 CONTINUE RETURN END
bsd-3-clause
puppeh/gcc-6502
gcc/testsuite/gfortran.dg/intent_out_2.f90
136
1028
! { dg-do run } ! Tests the fix for PR33554, in which the default initialization ! of temp, in construct_temp, caused a segfault because it was ! being done before the array offset and lower bound were ! available. ! ! Contributed by Harald Anlauf <anlauf@gmx.de> ! module gfcbug72 implicit none type t_datum character(len=8) :: mn = 'abcdefgh' end type t_datum type t_temp type(t_datum) :: p end type t_temp contains subroutine setup () integer :: i type (t_temp), pointer :: temp(:) => NULL () do i=1,2 allocate (temp (2)) call construct_temp (temp) if (any (temp % p% mn .ne. 'ijklmnop')) call abort () deallocate (temp) end do end subroutine setup !-- subroutine construct_temp (temp) type (t_temp), intent(out) :: temp (:) if (any (temp % p% mn .ne. 'abcdefgh')) call abort () temp(:)% p% mn = 'ijklmnop' end subroutine construct_temp end module gfcbug72 program test use gfcbug72 implicit none call setup () end program test
gpl-2.0
nschloe/seacas
packages/seacas/applications/gen3d/g3_wrnps.f
1
6982
C Copyright(C) 2011-2017 National Technology & Engineering Solutions C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C======================================================================= SUBROUTINE WRNPS (A, IA, IDFRO, IDBCK, & IDNPS, NNNP3, IXNNP3, LTNNP3, FACNP3, & IXNP, NRNP, *) C======================================================================= C --*** WRNPS *** (GEN3D) Write 3D node sets C -- Written by Amy Gilkey - revised 05/05/86 C -- C --WRNPS writes the node set information for the 3D database. C --Calculations have been done elsewhere. C -- C --Parameters: C -- IDFRO - IN - ids for front surface node sets; (0) = length C -- IDBCK - IN - ids for back surface node sets; (0) = length C -- IDNPS - IN - the 2D node sets ids C -- NNNP3 - IN - the number of nodes for each 3D set C -- IXNNP3 - IN - the index of the first node for each 3D set C -- LTNNP3 - IN - the nodes for all 3D sets C -- FACNP3 - IN - the distribution factors for all 3D sets C -- IXNP - IN - the new index for each node C -- NRNP - IN - the number of new nodes generated for each node C -- C --Common Variables: C -- Uses NDBOUT of /DBASE/ C -- Uses NUMNPS, LNPSNL of /DBNUMS/ C -- Uses LNPSNO of /DBNUM3/ INCLUDE 'exodusII.inc' INCLUDE 'g3_dbase.blk' INCLUDE 'g3_dbnums.blk' INCLUDE 'g3_dbnum3.blk' REAL A(*) INTEGER IA(*) INTEGER IDFRO(0:*) INTEGER IDBCK(0:*) INTEGER IDNPS(*) INTEGER NNNP3(*) INTEGER IXNNP3(*) INTEGER LTNNP3(*) REAL FACNP3(*) INTEGER IXNP(*), NRNP(*) LOGICAL ANYNPS NFRO = IDFRO(0) NBCK = IDBCK(0) ANYNPS = (NFRO .GT. 0) .OR. (NBCK .GT. 0) .OR. (NUMNPS .GT. 0) C --Write 3D call expnp (exoid, 20, 5, 5, ierr) call expns (exoid, 20, node_list, ierr) call expnsd (exoid, 20, dist_fact, ierr) IF (ANYNPS) THEN C ... Output nodeset id, number nodes, number dist factors C Assumes that there are the same number of distribution factors C as there are nodes in the nodeset. DO 10 ins = 1, numnps call expnp (ndbout, idnps(ins), nnnp3(ins), nnnp3(ins), ierr) if (ierr .lt. 0) then call exerr('gen3d2', 'Error from expnp', exlmsg) go to 50 endif call expns (ndbout, idnps(ins), LTNNP3(IXNNP3(ins)), ierr) if (ierr .lt. 0) then call exerr('gen3d2', 'Error from expns', exlmsg) go to 50 endif call expnsd(ndbout, idnps(ins), FACNP3(IXNNP3(ins)), ierr) if (ierr .lt. 0) then call exerr('gen3d2', 'Error from expnsd', exlmsg) go to 50 endif 10 continue C ... Output front and back nodesets (if any) C Front and back nodesets contain NUMNP (2D database) nodes C If there are any front or back, then create a temporary C Array to hold the distribution factors. Defaulted to 1.0 if (nfro .gt. 0 .or. nbck .gt. 0) then call mdrsrv('factorns', knfac, numnp) call mdstat(mnerrs, mnused) if (mnerrs .gt. 0) goto 50 call inirea(numnp, 1.0, a(knfac)) do 20 ins = 1, nfro call expnp (ndbout, idfro(ins), numnp, numnp, ierr) if (ierr .lt. 0) then call exerr('gen3d2', 'Error from expnp', exlmsg) go to 50 endif call expns (ndbout, idfro(ins), IXNP, ierr) if (ierr .lt. 0) then call exerr('gen3d2', 'Error from expns', exlmsg) go to 50 endif call expnsd(ndbout, idfro(ins), a(knfac), ierr) if (ierr .lt. 0) then call exerr('gen3d2', 'Error from expnsd', exlmsg) go to 50 endif 20 continue if (nbck .gt. 0) then call mdrsrv('nodelist', knlst, numnp) call mdstat(mnerrs, mnused) if (mnerrs .gt. 0) goto 50 do 30 i=1, numnp ia(knlst+i-1) = ixnp(i) + nrnp(i) - 1 30 continue do 40 ins = 1, nbck call expnp (ndbout, idbck(ins), numnp, numnp, ierr) if (ierr .lt. 0) then call exerr('gen3d2', 'Error from expnp', exlmsg) go to 50 endif call expns (ndbout, idbck(ins), ia(knlst), ierr) if (ierr .lt. 0) then call exerr('gen3d2', 'Error from expns', exlmsg) go to 50 endif call expnsd(ndbout, idbck(ins), a(knfac), ierr) if (ierr .lt. 0) then call exerr('gen3d2', 'Error from expnsd', exlmsg) go to 50 endif 40 continue end if end if end if if (nfro .gt. 0 .or. nbck .gt. 0) then call mddel('factorns') if (nbck .gt. 0) then call mddel('nodelist') end if end if call mdstat(mnerrs, mnused) if (mnerrs .gt. 0) goto 50 RETURN 50 continue RETURN 1 END
bsd-3-clause
nschloe/seacas
packages/seacas/applications/numbers/nu_jacob.f
1
5443
C Copyright(C) 1988-2017 National Technology & Engineering Solutions C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. subroutine jacob(x1,x2,x3,x4,x5,x6,x7,x8, * y1,y2,y3,y4,y5,y6,y7,y8, * z1,z2,z3,z4,z5,z6,z7,z8, JACMN) REAL JACOBI, JACMN REAL XXI(3), XET(3), XZE(3) JACMN = 1.0e38 C... Jacobian at mid-point: xxi(1) = x2 + x3 + x6 + x7 - x1 - x4 - x5 - x8 xet(1) = x3 + x4 + x7 + x8 - x1 - x2 - x5 - x6 xze(1) = x5 + x6 + x7 + x8 - x1 - x2 - x3 - x4 xxi(2) = y2 + y3 + y6 + y7 - y1 - y4 - y5 - y8 xet(2) = y3 + y4 + y7 + y8 - y1 - y2 - y5 - y6 xze(2) = y5 + y6 + y7 + y8 - y1 - y2 - y3 - y4 xxi(3) = z2 + z3 + z6 + z7 - z1 - z4 - z5 - z8 xet(3) = z3 + z4 + z7 + z8 - z1 - z2 - z5 - z6 xze(3) = z5 + z6 + z7 + z8 - z1 - z2 - z3 - z4 jacobi = CRSDOT(xxi,xet,xze)/64.0 jacmn = min(jacobi, jacmn) C... J(0,0,0): xxi(1) = x2 - x1 xet(1) = x4 - x1 xze(1) = x5 - x1 xxi(2) = y2 - y1 xet(2) = y4 - y1 xze(2) = y5 - y1 xxi(3) = z2 - z1 xet(3) = z4 - z1 xze(3) = z5 - z1 jacobi = CRSDOT(xxi,xet,xze) jacmn = min(jacobi, jacmn) C... J(1,0,0): xxi(1) = x2 - x1 xet(1) = x3 - x2 xze(1) = x6 - x2 xxi(2) = y2 - y1 xet(2) = y3 - y2 xze(2) = y6 - y2 xxi(3) = z2 - z1 xet(3) = z3 - z2 xze(3) = z6 - z2 jacobi = CRSDOT(xxi,xet,xze) jacmn = min(jacobi, jacmn) C... J(0,1,0): xxi(1) = x3 - x4 xet(1) = x4 - x1 xze(1) = x8 - x4 xxi(2) = y3 - y4 xet(2) = y4 - y1 xze(2) = y8 - y4 xxi(3) = z3 - z4 xet(3) = z4 - z1 xze(3) = z8 - z4 jacobi = CRSDOT(xxi,xet,xze) jacmn = min(jacobi, jacmn) C... J(0,0,1): xxi(1) = x6 - x5 xet(1) = x8 - x5 xze(1) = x5 - x1 xxi(2) = y6 - y5 xet(2) = y8 - y5 xze(2) = y5 - y1 xxi(3) = z6 - z5 xet(3) = z8 - z5 xze(3) = z5 - z1 jacobi = CRSDOT(xxi,xet,xze) jacmn = min(jacobi, jacmn) C... J(1,1,0): xxi(1) = x3 - x4 xet(1) = x3 - x2 xze(1) = x7 - x3 xxi(2) = y3 - y4 xet(2) = y3 - y2 xze(2) = y7 - y3 xxi(3) = z3 - z4 xet(3) = z3 - z2 xze(3) = z7 - z3 jacobi = CRSDOT(xxi,xet,xze) jacmn = min(jacobi, jacmn) C... J(1,0,1): xxi(1) = x6 - x5 xet(1) = x7 - x6 xze(1) = x6 - x2 xxi(2) = y6 - y5 xet(2) = y7 - y6 xze(2) = y6 - y2 xxi(3) = z6 - z5 xet(3) = z7 - z6 xze(3) = z6 - z2 jacobi = CRSDOT(xxi,xet,xze) jacmn = min(jacobi, jacmn) C... J(0,1,1): xxi(1) = x7 - x8 xet(1) = x8 - x5 xze(1) = x8 - x4 xxi(2) = y7 - y8 xet(2) = y8 - y5 xze(2) = y8 - y4 xxi(3) = z7 - z8 xet(3) = z8 - z5 xze(3) = z8 - z4 jacobi = CRSDOT(xxi,xet,xze) jacmn = min(jacobi, jacmn) C... J(1,1,1): xxi(1) = x7 - x8 xet(1) = x7 - x6 xze(1) = x7 - x3 xxi(2) = y7 - y8 xet(2) = y7 - y6 xze(2) = y7 - y3 xxi(3) = z7 - z8 xet(3) = z7 - z6 xze(3) = z7 - z3 jacobi = CRSDOT(xxi,xet,xze) jacmn = min(jacobi, jacmn) return end REAL FUNCTION CRSDOT(a, b, c) REAL a(3), b(3), c(3) C ... Compute d = a dot (b cross c) REAL xcross, ycross, zcross xcross = b(2) * c(3) - b(3) * c(2) ycross = b(3) * c(1) - b(1) * c(3) zcross = b(1) * c(2) - b(2) * c(1) crsdot = (a(1) * xcross + a(2) * ycross + a(3) * zcross) return end
bsd-3-clause
scipy/scipy
scipy/linalg/src/det.f
29
4787
c Calculate determinant of square matrix c Author: Pearu Peterson, March 2002 c c prefixes: d,z,s,c (double,complex double,float,complex float) c suffixes: _c,_r (column major order,row major order) subroutine ddet_c(det,a,n,piv,info) integer n,piv(n),i,info double precision det,a(n,n) cf2py intent(in,copy) :: a cf2py intent(out) :: det,info cf2py integer intent(hide,cache),depend(n),dimension(n) :: piv cf2py integer intent(hide),depend(a) :: n = shape(a,0) cf2py check(shape(a,0)==shape(a,1)) :: a cf2py callprotoargument double*,double*,int*,int*,int* external dgetrf call dgetrf(n,n,a,n,piv,info) det = 0d0 if (info.ne.0) then return endif det = 1d0 do 10,i=1,n if (piv(i).ne.i) then det = -det * a(i,i) else det = det * a(i,i) endif 10 continue end subroutine ddet_r(det,a,n,piv,info) integer n,piv(n),info double precision det,a(n,n) cf2py intent(c,in,copy) :: a cf2py intent(out) :: det,info cf2py integer intent(hide,cache),depend(n),dimension(n) :: piv cf2py integer intent(hide),depend(a) :: n = shape(a,0) cf2py check(shape(a,0)==shape(a,1)) :: a cf2py callprotoargument double*,double*,int*,int*,int* external ddet_c call ddet_c(det,a,n,piv,info) end subroutine sdet_c(det,a,n,piv,info) integer n,piv(n),i,info real det,a(n,n) cf2py intent(in,copy) :: a cf2py intent(out) :: det,info cf2py integer intent(hide,cache),depend(n),dimension(n) :: piv cf2py integer intent(hide),depend(a) :: n = shape(a,0) cf2py check(shape(a,0)==shape(a,1)) :: a cf2py callprotoargument float*,float*,int*,int*,int* external sgetrf call sgetrf(n,n,a,n,piv,info) det = 0e0 if (info.ne.0) then return endif det = 1e0 do 10,i=1,n if (piv(i).ne.i) then det = -det * a(i,i) else det = det * a(i,i) endif 10 continue end subroutine sdet_r(det,a,n,piv,info) integer n,piv(n),info real det,a(n,n) cf2py intent(c,in,copy) :: a cf2py intent(out) :: det,info cf2py integer intent(hide,cache),depend(n),dimension(n) :: piv cf2py integer intent(hide),depend(a) :: n = shape(a,0) cf2py check(shape(a,0)==shape(a,1)) :: a cf2py callprotoargument float*,float*,int*,int*,int* external sdet_c call sdet_c(det,a,n,piv,info) end subroutine zdet_c(det,a,n,piv,info) integer n,piv(n),i,info complex*16 det,a(n,n) cf2py intent(in,copy) :: a cf2py intent(out) :: det,info cf2py integer intent(hide,cache),depend(n),dimension(n) :: piv cf2py integer intent(hide),depend(a) :: n = shape(a,0) cf2py check(shape(a,0)==shape(a,1)) :: a cf2py callprotoargument complex_double*,complex_double*,int*,int*,int* external zgetrf call zgetrf(n,n,a,n,piv,info) det = (0d0,0d0) if (info.ne.0) then return endif det = (1d0,0d0) do 10,i=1,n if (piv(i).ne.i) then det = -det * a(i,i) else det = det * a(i,i) endif 10 continue end subroutine zdet_r(det,a,n,piv,info) integer n,piv(n),info complex*16 det,a(n,n) cf2py intent(c,in,copy) :: a cf2py intent(out) :: det,info cf2py integer intent(hide,cache),depend(n),dimension(n) :: piv cf2py integer intent(hide),depend(a) :: n = shape(a,0) cf2py check(shape(a,0)==shape(a,1)) :: a cf2py callprotoargument complex_double*,complex_double*,int*,int*,int* external zdet_c call zdet_c(det,a,n,piv,info) end subroutine cdet_c(det,a,n,piv,info) integer n,piv(n),i,info complex det,a(n,n) cf2py intent(in,copy) :: a cf2py intent(out) :: det,info cf2py integer intent(hide,cache),depend(n),dimension(n) :: piv cf2py integer intent(hide),depend(a) :: n = shape(a,0) cf2py check(shape(a,0)==shape(a,1)) :: a cf2py callprotoargument complex_float*,complex_float*,int*,int*,int* external cgetrf call cgetrf(n,n,a,n,piv,info) det = (0e0,0e0) if (info.ne.0) then return endif det = (1e0,0e0) do 10,i=1,n if (piv(i).ne.i) then det = -det * a(i,i) else det = det * a(i,i) endif 10 continue end subroutine cdet_r(det,a,n,piv,info) integer n,piv(n),info complex det,a(n,n) cf2py intent(c,in,copy) :: a cf2py intent(out) :: det,info cf2py integer intent(hide,cache),depend(n),dimension(n) :: piv cf2py integer intent(hide),depend(a) :: n = shape(a,0) cf2py check(shape(a,0)==shape(a,1)) :: a cf2py callprotoargument complex_float*,complex_float*,int*,int*,int* external cdet_c call cdet_c(det,a,n,piv,info) end
bsd-3-clause
nschloe/seacas
packages/seacas/applications/grepos/gp_chkss.f
1
2028
C Copyright(C) 2011-2017 National Technology & Engineering Solutions of C Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. subroutine chkss(nelblk, numelb, iblock) INTEGER NUMELB(*) INTEGER iblock(*) itot = 0 do 10 i=1, nelblk iblock(i) = itot + numelb(i) itot = itot + numelb(i) 10 continue return end
bsd-3-clause
puppeh/gcc-6502
gcc/testsuite/gfortran.dg/entry_13.f90
136
1751
! { dg-do run } ! Tests the fix for pr31214, in which the typespec for the entry would be lost, ! thereby causing the function to be disallowed, since the function and entry ! types did not match. ! ! Contributed by Joost VandeVondele <jv244@cam.ac.uk> ! module type_mod implicit none type x real x end type x type y real x end type y type z real x end type z interface assignment(=) module procedure equals end interface assignment(=) interface operator(//) module procedure a_op_b, b_op_a end interface operator(//) interface operator(==) module procedure a_po_b, b_po_a end interface operator(==) contains subroutine equals(x,y) type(z), intent(in) :: y type(z), intent(out) :: x x%x = y%x end subroutine equals function a_op_b(a,b) type(x), intent(in) :: a type(y), intent(in) :: b type(z) a_op_b type(z) b_op_a a_op_b%x = a%x + b%x return entry b_op_a(b,a) b_op_a%x = a%x - b%x end function a_op_b function a_po_b(a,b) type(x), intent(in) :: a type(y), intent(in) :: b type(z) a_po_b type(z) b_po_a entry b_po_a(b,a) a_po_b%x = a%x/b%x end function a_po_b end module type_mod program test use type_mod implicit none type(x) :: x1 = x(19.0_4) type(y) :: y1 = y(7.0_4) type(z) z1 z1 = x1//y1 if (abs(z1%x - (19.0_4 + 7.0_4)) > epsilon(x1%x)) call abort () z1 = y1//x1 if (abs(z1%x - (19.0_4 - 7.0_4)) > epsilon(x1%x)) call abort () z1 = x1==y1 if (abs(z1%x - 19.0_4/7.0_4) > epsilon(x1%x)) call abort () z1 = y1==x1 if (abs(z1%x - 19.0_4/7.0_4) > epsilon(x1%x)) call abort () end program test
gpl-2.0
nschloe/seacas
packages/zoltan/src/fdriver/fdr_param_file.f90
2
19252
!! !! @HEADER !! !!!!********************************************************************** !! !! Zoltan Toolkit for Load-balancing, Partitioning, Ordering and Coloring !! Copyright 2012 Sandia Corporation !! !! Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, !! the U.S. Government retains certain rights in this software. !! !! Redistribution and use in source and binary forms, with or without !! modification, are permitted provided that the following conditions are !! met: !! !! 1. Redistributions of source code must retain the above copyright !! notice, this list of conditions and the following disclaimer. !! !! 2. Redistributions in binary form must reproduce the above copyright !! notice, this list of conditions and the following disclaimer in the !! documentation and/or other materials provided with the distribution. !! !! 3. Neither the name of the Corporation nor the names of the !! contributors may be used to endorse or promote products derived from !! this software without specific prior written permission. !! !! THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY !! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE !! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR !! PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE !! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, !! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, !! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR !! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF !! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING !! NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS !! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. !! !! Questions? Contact Karen Devine kddevin@sandia.gov !! Erik Boman egboman@sandia.gov !! !!!!********************************************************************** !! !! @HEADER !! ! *************************************************************************** ! ! Code imported to Zoltan zdrive from ! ! zoltanParams_read_file.c ! ! Read Zoltan parameters from a file, call Zoltan to set the parameters ! ! zoltanParams library ! ! Jim Teresco ! ! Department of Computer Science ! Williams College ! ! and ! ! Computer Science Research Institute ! Sandia National Laboratories ! ! ! Translated to Fortran by Bill Mitchell, NIST, March 2007 module dr_param_file !#include <stdio.h> !#include <mpi.h> !#include <stdlib.h> !#include "zoltan.h" use zoltan use mpi_h implicit none private ! Are other routines public? If so, add them separated by commas. Use ! an amperstand at the end of the line to continue on another line. public ztnPrm_read_file ! standard error and standard out are not standardized in Fortran 90, but most ! compilers use units 0 (most) and 6 (universal). Change here if necessary. integer, parameter :: stderr = 0, stdout = 6 !#define DEBUG 1 logical, parameter :: DEBUG = .false. !struct zoltanParams_list_entry { ! char *param; ! char *value; ! struct zoltanParams_list_entry *next; !}; ! unknown length character strings are tricky in Fortran, just pick a ! length that is hopefully big enough. Change it here if necessary. integer, parameter :: MAX_CHAR_LEN = 128 type ztnPrm_list_entry character(len=MAX_CHAR_LEN) :: param character(len=MAX_CHAR_LEN) :: value type (ztnPrm_list_entry), pointer :: next end type ztnPrm_list_entry !struct zoltanParams_hier_struct { ! int partition; ! struct zoltanParams_list_entry *first; !}; type ztnPrm_hier_struct integer :: partition type (ztnPrm_list_entry), pointer :: first end type ztnPrm_hier_struct !static struct zoltanParams_hier_struct **zph = NULL; !static int num_levels = 0; !static MPI_Comm comm; ! I think the use of **zph is as an allocatable array type(ztnPrm_hier_struct), save, allocatable :: zph(:) integer :: num_levels = 0 integer :: comm contains !static void check_level(int level) { ! ! if (!zph) { ! fprintf(stderr,"check_level: must set number of levels first\n"); ! return; ! } ! ! if (level >= num_levels) { ! fprintf(stderr,"check_level: invalid level\n"); ! } !} subroutine check_level(level) integer :: level if (.not. allocated(zph)) then write(stderr,*) "check_level: must set number of levels first" return endif if (level >= num_levels) then write(stderr,*) "check_level: invalid level" endif end subroutine check_level !void zoltanParams_hier_free() { ! int i; ! ! if (!zph) { ! fprintf(stderr, "zoltanParams_hier_free warning: not allocated\n"); ! return; ! } ! ! for (i=0; i<num_levels; i++) { ! free(zph[i]); ! } ! ! free(zph); !} subroutine ztnPrm_hier_free() integer :: i if (.not. allocated(zph)) then write(stderr,*) "ztnPrm_hier_free warning: not allocated" return endif deallocate(zph) end subroutine ztnPrm_hier_free !void zoltanParams_hier_set_num_levels(int levels) { ! int i; subroutine ztnPrm_hier_set_num_levels(levels) integer :: levels integer :: i, astat !#ifdef DEBUG ! printf("(zoltanParams_hier_set_num_levels) setting to %d\n", levels); !#endif if (DEBUG) then write(stdout,*) "(ztnPrm_hier_set_num_levels) setting to ",levels endif ! if (zph) { ! fprintf(stderr,"zoltanParams_hier_set_num_levels warning: already initialized, reinitializing\n"); ! zoltanParams_hier_free(); ! } if (allocated(zph)) then write(stderr,*) "ztnPrm_hier_set_num_levels warning: already initialized, reinitializing" call ztnPrm_hier_free() endif ! if (levels <= 0) { ! fprintf(stderr, "(zoltanParams_hier_set_num_levels) num levels must be positive\n"); ! return; ! } if (levels <= 0) then write(stderr,*) "(ztnPrm_hier_set_num_levels) num levels must be positive" return endif ! num_levels = levels; ! ! SAFE_MALLOC(zph, struct zoltanParams_hier_struct **, ! sizeof(struct zoltanParams_hier_struct *) * levels); ! ! for (i=0; i<levels; i++) { ! SAFE_MALLOC(zph[i], struct zoltanParams_hier_struct *, ! sizeof (struct zoltanParams_hier_struct)); ! zph[i]->partition = 0; ! zph[i]->first = NULL; ! } num_levels = levels allocate(zph(0:levels-1),stat=astat) if (astat /= 0) then write(stderr,*) "allocation failed in ztnPrm_hier_set_num_level" stop endif do i=0,levels-1 zph(i)%partition = 0 nullify(zph(i)%first) end do !} end subroutine ztnPrm_hier_set_num_levels !void zoltanParams_hier_set_partition(int level, int partition) { ! !#ifdef DEBUG ! int mypid; ! MPI_Comm_rank(comm, &mypid); ! ! printf("[%d] will compute partition %d at level %d\n", ! mypid, partition, level); !#endif ! ! check_level(level); ! ! zph[level]->partition = partition; !} subroutine ztnPrm_hier_set_partition(level,partition) integer :: level, partition integer :: mypid, ierr if (DEBUG) then call MPI_Comm_rank(comm,mypid,ierr) write(stdout,*) "[",mypid,"] will compute partition ",partition," at level ",level endif call check_level(level) zph(level)%partition = partition end subroutine ztnPrm_hier_set_partition !void zoltanParams_hier_set_param(int level, char *param, char *value) { ! struct zoltanParams_list_entry *newparam, *nextparam; subroutine ztnPrm_hier_set_param(level,param,value) integer :: level character(len=*) :: param, value type(ztnPrm_list_entry), pointer :: newparam, nextparam integer :: mypid, ierr, astat !#ifdef DEBUG ! int mypid; ! MPI_Comm_rank(comm, &mypid); ! printf("[%d] will set param <%s> to <%s> at level %d\n", ! mypid, param, value, level); !#endif if (DEBUG) then call MPI_Comm_rank(comm,mypid,ierr) write(stdout,*) "[",mypid,"] will set param ",trim(param)," to ",trim(value)," at level ",level endif ! check_level(level); ! ! SAFE_MALLOC(newparam, struct zoltanParams_list_entry *, ! sizeof(struct zoltanParams_list_entry)); call check_level(level) allocate(newparam,stat=astat) if (astat /= 0) then write(stderr,*) "allocation failed in ztnPrm_hier_set_param" stop endif ! newparam->param = strdup(param); ! newparam->value = strdup(value); ! newparam->next = NULL; newparam%param = param newparam%value = value nullify(newparam%next) ! if (!zph[level]->first) { ! zph[level]->first = newparam; ! return; ! } if (.not. associated(zph(level)%first)) then zph(level)%first => newparam return endif ! nextparam = zph[level]->first; ! while (nextparam->next) nextparam=nextparam->next; ! nextparam->next = newparam; nextparam => zph(level)%first do while (associated(nextparam%next)) nextparam => nextparam%next end do nextparam%next => newparam !} end subroutine ztnPrm_hier_set_param !int zoltanParams_hier_get_num_levels() { ! ! return num_levels; !} function ztnPrm_hier_get_num_levels() integer :: ztnPrm_hier_get_num_levels ztnPrm_hier_get_num_levels = num_levels end function ztnPrm_hier_get_num_levels !int zoltanParams_hier_get_part(int level) { ! ! check_level(level); ! ! return zph[level]->partition; !} function ztnPrm_hier_get_part(level) integer :: level integer :: ztnPrm_hier_get_part call check_level(level) ztnPrm_hier_get_part = zph(level)%partition end function ztnPrm_hier_get_part !void zoltanParams_hier_use_params(int level, struct Zoltan_Struct *zz, int *ierr) { ! struct zoltanParams_list_entry *nextparam; ! ! *ierr = ZOLTAN_OK; ! check_level(level); ! ! nextparam = zph[level]->first; ! ! while (nextparam) { ! *ierr = Zoltan_Set_Param(zz, nextparam->param, nextparam->value); ! if (*ierr != ZOLTAN_OK) return; ! nextparam = nextparam->next; ! } ! !} subroutine ztnPrm_hier_use_params(level,zz,ierr) integer :: level type(Zoltan_Struct), pointer :: zz integer :: ierr type(ztnPrm_list_entry), pointer :: nextparam ierr = ZOLTAN_OK call check_level(level) nextparam => zph(level)%first do while (associated(nextparam)) ierr = Zoltan_Set_Param(zz, nextparam%param, nextparam%value) if (ierr /= ZOLTAN_OK) return nextparam => nextparam%next end do end subroutine ztnPrm_hier_use_params !static int get_num_levels(void *data, int *ierr) { ! ! *ierr = ZOLTAN_OK; ! return zoltanParams_hier_get_num_levels(); !} function get_num_levels(data, ierr) integer(Zoltan_INT), intent(in) :: data(*) integer(Zoltan_INT), intent(out) :: ierr integer(Zoltan_INT) :: get_num_levels ierr = ZOLTAN_OK get_num_levels = ztnPrm_hier_get_num_levels() end function get_num_levels !static int get_part(void *data, int level, int *ierr) { ! ! *ierr = ZOLTAN_OK; ! ! return ztnPrm_hier_get_part(level); !} function get_part(data, level, ierr) integer(Zoltan_INT), intent(in) :: data(*) integer(Zoltan_INT), intent(in) :: level integer(Zoltan_INT), intent(out) :: ierr integer(Zoltan_INT) :: get_part ierr = ZOLTAN_OK get_part = ztnPrm_hier_get_part(level) end function get_part !static void get_method(void *data, int level, struct Zoltan_Struct *zz, ! int *ierr) { ! ! zoltanParams_hier_use_params(level, zz, ierr); !} subroutine get_method(data,level,azz,ierr) integer(Zoltan_INT), intent(in) :: data(*) integer(Zoltan_INT), intent(in) :: level type(Zoltan_Struct), intent(in), target :: azz integer(Zoltan_INT), intent(out) :: ierr type(Zoltan_Struct), pointer :: zz zz => azz call ztnPrm_hier_use_params(level, zz, ierr) end subroutine get_method !void zoltanParams_set_comm(MPI_Comm thecomm) { ! ! remember the comm passed in ! MPI_Comm_dup(thecomm, &comm); !} subroutine ztnPrm_set_comm(thecomm) integer :: thecomm integer :: ierr ! remember the comm passed in call MPI_Comm_dup(thecomm, comm, ierr) end subroutine ztnPrm_set_comm !void zoltanParams_hier_setup(struct Zoltan_Struct *zz) { ! ! make sure the hierarchical balancing callbacks are in place ! if (Zoltan_Set_Fn(zz, ZOLTAN_HIER_NUM_LEVELS_FN_TYPE, ! (void (*)()) get_num_levels, NULL) == ZOLTAN_FATAL) { ! fprintf(stderr,"zoltanParams_hier_setup: set NUM_LEVELS callback failed\n"); ! } ! ! if (Zoltan_Set_Fn(zz, ZOLTAN_HIER_PARTITION_FN_TYPE, ! (void (*)()) get_part, NULL) == ZOLTAN_FATAL) { ! fprintf(stderr,"zoltanParams_hier_setup: set PARTITION callback failed\n"); ! } ! ! if (Zoltan_Set_Fn(zz, ZOLTAN_HIER_METHOD_FN_TYPE, ! (void (*)()) get_method, NULL) == ZOLTAN_FATAL) { ! fprintf(stderr,"zoltanParams_hier_setup: set METHOD callback failed\n"); ! } !} subroutine ztnPrm_hier_setup(zz) type(Zoltan_Struct), pointer :: zz integer(Zoltan_INT) :: dummy(1) = (/0/) ! make sure the hierarchical balancing callbacks are in place if (Zoltan_Set_Hier_Num_Levels_Fn(zz, get_num_levels, dummy) == & ZOLTAN_FATAL) then write(stderr,*) "ztnPrm_hier_setup: set NUM_LEVELS callback failed" endif if (Zoltan_Set_Hier_Part_Fn(zz, get_part, dummy) == & ZOLTAN_FATAL) then write(stderr,*) "ztnPrm_hier_setup: set PARTITION callback failed" endif if (Zoltan_Set_Hier_Method_Fn(zz, get_method, dummy) == & ZOLTAN_FATAL) then write(stderr,*) "ztnPrm_hier_setup: set METHOD callback failed" endif end subroutine ztnPrm_hier_setup ! ! ! zoltanParams_read_file ! ! Set up the given Zoltan_Struct with parameters as specified ! in the given file. ! ! File format: ! ! Lines of the format: ! ZOLTAN_PARAM PARAM_VALUE ! ! If the parameter is LB_METHOD set to HIER, the next part of the file ! is interpreted as hierarchical balancing parameters: ! ! num_levels ! level 0 partitions for each proc ! level 0 parameters ! end with LEVEL END ! level 1 partitions for each proc ! level 1 parameters ! end with LEVEL END ! ... ! ! End file with EOF ! ! !void zoltanParams_read_file(struct Zoltan_Struct *lb, char *file, ! MPI_Comm thecomm) { ! FILE *fp; ! char str1[500], str2[500]; ! int numlevels, level, partition, proc; ! int ierr; ! int mypid, numprocs; subroutine ztnPrm_read_file(lb, file, thecomm) type(Zoltan_Struct), pointer :: lb character(len=*) :: file integer :: thecomm integer :: fp character(len=500) :: str1, str2 integer :: numlevels, level, proc integer :: ierr integer :: mypid, numprocs logical :: not2 integer, allocatable :: partition(:) ! remember the comm passed in ! MPI_Comm_dup(thecomm, &comm); ! ! MPI_Comm_rank(comm, &mypid); ! MPI_Comm_size(comm, &numprocs); ! remember the comm passed in call MPI_Comm_dup(thecomm, comm, ierr) call MPI_Comm_rank(comm, mypid, ierr) call MPI_Comm_size(comm, numprocs, ierr) ! fp = fopen(file, "r"); ! if (!fp) { ! fprintf(stderr,"Cannot open file %s for reading", file); ! return; ! } ! Assume unit 9 is available. If it isn't, an error will be reported and ! you can change it to some other positive integer, not too big. fp = 9 open(unit=fp,file=trim(file),action="read",iostat=ierr) if (ierr /= 0) then write(stderr,*) "cannot open file ",trim(file)," for reading" return endif !#ifdef DEBUG ! if (mypid == 0) { ! printf("Reading Zoltan parameters from file %s\n", file); ! } !#endif if (DEBUG) then if (mypid == 0) then write(stdout,*) "Reading Zoltan parameters from file ",trim(file) endif endif ! while (fscanf(fp, "%s %s\n", str1, str2) == 2) { do call myread(fp, str1, str2, not2) if (not2) exit ! ierr = Zoltan_Set_Param(lb, str1, str2); ! if (ierr != ZOLTAN_OK) { ! fprintf(stderr,"Zoltan_Set_Param failed to set param <%s> to <%s>",str1,str2); ! } !#ifdef DEBUG ! else { ! if (mypid == 0) { ! printf("Set Zoltan parameter <%s> to <%s>\n", str1, str2); ! } ! } !#endif ! get rid of the leading space left on str2 str2 = adjustl(str2) ierr = Zoltan_Set_Param(lb, trim(str1), trim(str2)) if (ierr /= ZOLTAN_OK) then write(stderr,*) "Zoltan_Set_Param failed to set param ",trim(str1)," to ",trim(str2) endif if (DEBUG) then if (ierr == ZOLTAN_OK) then if (mypid == 0) then write(stdout,*) "Set Zoltan parameter ",trim(str1)," to ",trim(str2) endif endif endif ! if (strcmp(str1,"LB_METHOD") == 0 && strcmp(str2,"HIER") == 0) { if (trim(str1) == "LB_METHOD" .and. trim(str2) == "HIER") then ! zoltanParams_hier_setup(lb); call ztnPrm_hier_setup(lb) ! the rest of the file contains hierarchical balancing parameters ! fscanf(fp, "%d", &numlevels); ! the rest of the file contains hierarchical balancing parameters ! The line containing numlevels is already in str1 (NO - it's next in the file) read(fp,*) numlevels !#ifdef DEBUG ! printf("[%d] read in numlevels=%d\n", mypid, numlevels); !#endif if (DEBUG) then write(stdout,*) "[",mypid,"] read in numlevels=",numlevels endif ! zoltanParams_hier_set_num_levels(numlevels); call ztnPrm_hier_set_num_levels(numlevels) ! for (level=0; level<numlevels; level++) { ! first, a list of partitions for each proc should be in the file ! for (proc=0; proc<numprocs; proc++) { ! fscanf(fp, "%d", &partition); ! if (proc == mypid) zoltanParams_hier_set_partition(level, partition); ! } allocate(partition(0:numprocs-1)) ! probably should check that allocate succeeded do level=0,numlevels-1 read(fp,*) partition ! assumes the line has exactly numprocs numbers call ztnPrm_hier_set_partition(level,partition(mypid)) ! then parameters until we get LEVEL END ! while ((fscanf(fp, "%s %s\n", str1, str2) == 2) && ! (strcmp(str1, "LEVEL") != 0) && ! (strcmp(str2, "END") != 0)) { ! ! zoltanParams_hier_set_param(level, str1, str2); ! } ! } ! then parameters until we get LEVEL END do read(fp,*) str1, str2 str2 = adjustl(str2) if (trim(str1) == "LEVEL" .and. trim(str2) == "END") exit call ztnPrm_hier_set_param(level, str1, str2) end do end do deallocate(partition) ! } endif ! } end do ! fclose(fp); close(fp) !} end subroutine ztnPrm_read_file ! Fortran will generate an error if we try to read 2 strings and there is ! only 1 there. So we have to read the whole line into a string and ! see if there are 1 or 2 strings in there. Then read the individual ! strings and return them with a flag indicating if there are 1 or 2. subroutine myread(runit,str1,str2,not2) integer :: runit character(len=*) :: str1, str2 logical :: not2 integer :: iostat ! assume 1000 is plenty long for an input line. character(len=1000) :: line ! read the whole input line read(runit,"(A)",iostat=iostat) line ! end of file? if (iostat /= 0) then not2 = .true. else ! remove leading blanks line = adjustl(line) ! read the first string read(line,*) str1 ! if the length of the whole line with leading and trailing blanks removed ! is the same as the length of the first string, then there is only 1 string if (len_trim(line) == len_trim(str1)) then not2 = .true. ! otherwise, read the second line else not2 = .false. read(line(len_trim(str1)+1:),"(A)") str2 endif endif end subroutine myread end module dr_param_file
bsd-3-clause
dch312/scipy
scipy/integrate/quadpack/dqagi.f
109
8806
subroutine dqagi(f,bound,inf,epsabs,epsrel,result,abserr,neval, * ier,limit,lenw,last,iwork,work) c***begin prologue dqagi c***date written 800101 (yymmdd) c***revision date 830518 (yymmdd) c***category no. h2a3a1,h2a4a1 c***keywords automatic integrator, infinite intervals, c general-purpose, transformation, extrapolation, c 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 integral i = integral of f over (bound,+infinity) c or i = integral of f over (-infinity,bound) c or i = integral of f over (-infinity,+infinity) c hopefully satisfying following claim for accuracy c abs(i-result).le.max(epsabs,epsrel*abs(i)). c***description c c integration over infinite intervals c standard fortran subroutine 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 bound - double precision c finite bound of integration range c (has no meaning if interval is doubly-infinite) c c inf - integer c indicating the kind of integration range involved c inf = 1 corresponds to (bound,+infinity), c inf = -1 to (-infinity,bound), c inf = 2 to (-infinity,+infinity). 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 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. the c estimates for result and error are less c reliable. it is assumed that the requested c 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 (e.g. singularity, c discontinuity within the interval) one c will probably gain from splitting up the c interval at this point and calling the c integrator on the subranges. if possible, c an appropriate special-purpose integrator c should 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 assumed that the requested tolerance c cannot be achieved, and that the returned c result is the best which 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. c = 6 the input is invalid, because c (epsabs.le.0 and c epsrel.lt.max(50*rel.mach.acc.,0.5d-28)) c or limit.lt.1 or leniw.lt.limit*4. c result, abserr, neval, last are set to c zero. exept when limit or leniw is c invalid, iwork(1), work(limit*2+1) and c work(limit*3+1) are set to zero, work(1) c is set to a and work(limit+1) to b. c c dimensioning parameters c limit - integer c dimensioning parameter for iwork c limit determines the maximum number of subintervals c in the partition of the given integration interval c (a,b), limit.ge.1. c if limit.lt.1, the routine will end with ier = 6. c c lenw - integer c dimensioning parameter for work c lenw must be at least limit*4. c if lenw.lt.limit*4, 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 limit, the first c k elements of which contain pointers c to the error estimates over the subintervals, c 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 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 the c integral approximations over the subintervals, c work(limit*3+1), ..., work(limit*3+last) c contain the error estimates. c***references (none) c***routines called dqagie,xerror c***end prologue dqagi c double precision abserr,bound,epsabs,epsrel,f,result,work integer ier,inf,iwork,last,lenw,limit,lvl,l1,l2,l3,neval c dimension iwork(limit),work(lenw) c external f c c check validity of limit and lenw. c c***first executable statement dqagi ier = 6 neval = 0 last = 0 result = 0.0d+00 abserr = 0.0d+00 if(limit.lt.1.or.lenw.lt.limit*4) go to 10 c c prepare call for dqagie. c l1 = limit+1 l2 = limit+l1 l3 = limit+l2 c call dqagie(f,bound,inf,epsabs,epsrel,limit,result,abserr, * neval,ier,work(1),work(l1),work(l2),work(l3),iwork,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 dqagi',26,ier,lvl) return end
bsd-3-clause
vigna/scipy
scipy/special/cdflib/gaminv.f
151
10511
SUBROUTINE gaminv(a,x,x0,p,q,ierr) C ---------------------------------------------------------------------- C INVERSE INCOMPLETE GAMMA RATIO FUNCTION C C GIVEN POSITIVE A, AND NONEGATIVE P AND Q WHERE P + Q = 1. C THEN X IS COMPUTED WHERE P(A,X) = P AND Q(A,X) = Q. SCHRODER C ITERATION IS EMPLOYED. THE ROUTINE ATTEMPTS TO COMPUTE X C TO 10 SIGNIFICANT DIGITS IF THIS IS POSSIBLE FOR THE C PARTICULAR COMPUTER ARITHMETIC BEING USED. C C ------------ C C X IS A VARIABLE. IF P = 0 THEN X IS ASSIGNED THE VALUE 0, C AND IF Q = 0 THEN X IS SET TO THE LARGEST FLOATING POINT C NUMBER AVAILABLE. OTHERWISE, GAMINV ATTEMPTS TO OBTAIN C A SOLUTION FOR P(A,X) = P AND Q(A,X) = Q. IF THE ROUTINE C IS SUCCESSFUL THEN THE SOLUTION IS STORED IN X. C C X0 IS AN OPTIONAL INITIAL APPROXIMATION FOR X. IF THE USER C DOES NOT WISH TO SUPPLY AN INITIAL APPROXIMATION, THEN SET C X0 .LE. 0. C C IERR IS A VARIABLE THAT REPORTS THE STATUS OF THE RESULTS. C WHEN THE ROUTINE TERMINATES, IERR HAS ONE OF THE FOLLOWING C VALUES ... C C IERR = 0 THE SOLUTION WAS OBTAINED. ITERATION WAS C NOT USED. C IERR.GT.0 THE SOLUTION WAS OBTAINED. IERR ITERATIONS C WERE PERFORMED. C IERR = -2 (INPUT ERROR) A .LE. 0 C IERR = -3 NO SOLUTION WAS OBTAINED. THE RATIO Q/A C IS TOO LARGE. C IERR = -4 (INPUT ERROR) P + Q .NE. 1 C IERR = -6 20 ITERATIONS WERE PERFORMED. THE MOST C RECENT VALUE OBTAINED FOR X IS GIVEN. C THIS CANNOT OCCUR IF X0 .LE. 0. C IERR = -7 ITERATION FAILED. NO VALUE IS GIVEN FOR X. C THIS MAY OCCUR WHEN X IS APPROXIMATELY 0. C IERR = -8 A VALUE FOR X HAS BEEN OBTAINED, BUT THE C ROUTINE IS NOT CERTAIN OF ITS ACCURACY. C ITERATION CANNOT BE PERFORMED IN THIS C CASE. IF X0 .LE. 0, THIS CAN OCCUR ONLY C WHEN P OR Q IS APPROXIMATELY 0. IF X0 IS C POSITIVE THEN THIS CAN OCCUR WHEN A IS C EXCEEDINGLY CLOSE TO X AND A IS EXTREMELY C LARGE (SAY A .GE. 1.E20). C ---------------------------------------------------------------------- C WRITTEN BY ALFRED H. MORRIS, JR. C NAVAL SURFACE WEAPONS CENTER C DAHLGREN, VIRGINIA C ------------------- C .. Scalar Arguments .. DOUBLE PRECISION a,p,q,x,x0 INTEGER ierr C .. C .. Local Scalars .. DOUBLE PRECISION a0,a1,a2,a3,am1,amax,ap1,ap2,ap3,apn,b,b1,b2,b3, + b4,c,c1,c2,c3,c4,c5,d,e,e2,eps,g,h,ln10,pn,qg,qn, + r,rta,s,s2,sum,t,tol,u,w,xmax,xmin,xn,y,z INTEGER iop C .. C .. Local Arrays .. DOUBLE PRECISION amin(2),bmin(2),dmin(2),emin(2),eps0(2) C .. C .. External Functions .. DOUBLE PRECISION alnrel,gamln,gamln1,gamma,rcomp,spmpar EXTERNAL alnrel,gamln,gamln1,gamma,rcomp,spmpar C .. C .. External Subroutines .. EXTERNAL gratio C .. C .. Intrinsic Functions .. INTRINSIC abs,dble,dlog,dmax1,exp,sqrt C .. C .. Data statements .. C ------------------- C LN10 = LN(10) C C = EULER CONSTANT C ------------------- C ------------------- C ------------------- C ------------------- DATA ln10/2.302585D0/ DATA c/.577215664901533D0/ DATA a0/3.31125922108741D0/,a1/11.6616720288968D0/, + a2/4.28342155967104D0/,a3/.213623493715853D0/ DATA b1/6.61053765625462D0/,b2/6.40691597760039D0/, + b3/1.27364489782223D0/,b4/.036117081018842D0/ DATA eps0(1)/1.D-10/,eps0(2)/1.D-08/ DATA amin(1)/500.0D0/,amin(2)/100.0D0/ DATA bmin(1)/1.D-28/,bmin(2)/1.D-13/ DATA dmin(1)/1.D-06/,dmin(2)/1.D-04/ DATA emin(1)/2.D-03/,emin(2)/6.D-03/ DATA tol/1.D-5/ C .. C .. Executable Statements .. C ------------------- C ****** E, XMIN, AND XMAX ARE MACHINE DEPENDENT CONSTANTS. C E IS THE SMALLEST NUMBER FOR WHICH 1.0 + E .GT. 1.0. C XMIN IS THE SMALLEST POSITIVE NUMBER AND XMAX IS THE C LARGEST POSITIVE NUMBER. C e = spmpar(1) xmin = spmpar(2) xmax = spmpar(3) C ------------------- x = 0.0D0 IF (a.LE.0.0D0) GO TO 300 t = dble(p) + dble(q) - 1.D0 IF (abs(t).GT.e) GO TO 320 C ierr = 0 IF (p.EQ.0.0D0) RETURN IF (q.EQ.0.0D0) GO TO 270 IF (a.EQ.1.0D0) GO TO 280 C e2 = 2.0D0*e amax = 0.4D-10/ (e*e) iop = 1 IF (e.GT.1.D-10) iop = 2 eps = eps0(iop) xn = x0 IF (x0.GT.0.0D0) GO TO 160 C C SELECTION OF THE INITIAL APPROXIMATION XN OF X C WHEN A .LT. 1 C IF (a.GT.1.0D0) GO TO 80 g = gamma(a+1.0D0) qg = q*g IF (qg.EQ.0.0D0) GO TO 360 b = qg/a IF (qg.GT.0.6D0*a) GO TO 40 IF (a.GE.0.30D0 .OR. b.LT.0.35D0) GO TO 10 t = exp(- (b+c)) u = t*exp(t) xn = t*exp(u) GO TO 160 C 10 IF (b.GE.0.45D0) GO TO 40 IF (b.EQ.0.0D0) GO TO 360 y = -dlog(b) s = 0.5D0 + (0.5D0-a) z = dlog(y) t = y - s*z IF (b.LT.0.15D0) GO TO 20 xn = y - s*dlog(t) - dlog(1.0D0+s/ (t+1.0D0)) GO TO 220 20 IF (b.LE.0.01D0) GO TO 30 u = ((t+2.0D0* (3.0D0-a))*t+ (2.0D0-a)* (3.0D0-a))/ + ((t+ (5.0D0-a))*t+2.0D0) xn = y - s*dlog(t) - dlog(u) GO TO 220 30 c1 = -s*z c2 = -s* (1.0D0+c1) c3 = s* ((0.5D0*c1+ (2.0D0-a))*c1+ (2.5D0-1.5D0*a)) c4 = -s* (((c1/3.0D0+ (2.5D0-1.5D0*a))*c1+ ((a-6.0D0)*a+7.0D0))* + c1+ ((11.0D0*a-46)*a+47.0D0)/6.0D0) c5 = -s* ((((-c1/4.0D0+ (11.0D0*a-17.0D0)/6.0D0)*c1+ ((-3.0D0*a+ + 13.0D0)*a-13.0D0))*c1+0.5D0* (((2.0D0*a-25.0D0)*a+72.0D0)*a- + 61.0D0))*c1+ (((25.0D0*a-195.0D0)*a+477.0D0)*a-379.0D0)/ + 12.0D0) xn = ((((c5/y+c4)/y+c3)/y+c2)/y+c1) + y IF (a.GT.1.0D0) GO TO 220 IF (b.GT.bmin(iop)) GO TO 220 x = xn RETURN C 40 IF (b*q.GT.1.D-8) GO TO 50 xn = exp(- (q/a+c)) GO TO 70 50 IF (p.LE.0.9D0) GO TO 60 xn = exp((alnrel(-q)+gamln1(a))/a) GO TO 70 60 xn = exp(dlog(p*g)/a) 70 IF (xn.EQ.0.0D0) GO TO 310 t = 0.5D0 + (0.5D0-xn/ (a+1.0D0)) xn = xn/t GO TO 160 C C SELECTION OF THE INITIAL APPROXIMATION XN OF X C WHEN A .GT. 1 C 80 IF (q.LE.0.5D0) GO TO 90 w = dlog(p) GO TO 100 90 w = dlog(q) 100 t = sqrt(-2.0D0*w) s = t - (((a3*t+a2)*t+a1)*t+a0)/ ((((b4*t+b3)*t+b2)*t+b1)*t+1.0D0) IF (q.GT.0.5D0) s = -s C rta = sqrt(a) s2 = s*s xn = a + s*rta + (s2-1.0D0)/3.0D0 + s* (s2-7.0D0)/ (36.0D0*rta) - + ((3.0D0*s2+7.0D0)*s2-16.0D0)/ (810.0D0*a) + + s* ((9.0D0*s2+256.0D0)*s2-433.0D0)/ (38880.0D0*a*rta) xn = dmax1(xn,0.0D0) IF (a.LT.amin(iop)) GO TO 110 x = xn d = 0.5D0 + (0.5D0-x/a) IF (abs(d).LE.dmin(iop)) RETURN C 110 IF (p.LE.0.5D0) GO TO 130 IF (xn.LT.3.0D0*a) GO TO 220 y = - (w+gamln(a)) d = dmax1(2.0D0,a* (a-1.0D0)) IF (y.LT.ln10*d) GO TO 120 s = 1.0D0 - a z = dlog(y) GO TO 30 120 t = a - 1.0D0 xn = y + t*dlog(xn) - alnrel(-t/ (xn+1.0D0)) xn = y + t*dlog(xn) - alnrel(-t/ (xn+1.0D0)) GO TO 220 C 130 ap1 = a + 1.0D0 IF (xn.GT.0.70D0*ap1) GO TO 170 w = w + gamln(ap1) IF (xn.GT.0.15D0*ap1) GO TO 140 ap2 = a + 2.0D0 ap3 = a + 3.0D0 x = exp((w+x)/a) x = exp((w+x-dlog(1.0D0+ (x/ap1)* (1.0D0+x/ap2)))/a) x = exp((w+x-dlog(1.0D0+ (x/ap1)* (1.0D0+x/ap2)))/a) x = exp((w+x-dlog(1.0D0+ (x/ap1)* (1.0D0+ (x/ap2)* (1.0D0+ + x/ap3))))/a) xn = x IF (xn.GT.1.D-2*ap1) GO TO 140 IF (xn.LE.emin(iop)*ap1) RETURN GO TO 170 C 140 apn = ap1 t = xn/apn sum = 1.0D0 + t 150 apn = apn + 1.0D0 t = t* (xn/apn) sum = sum + t IF (t.GT.1.D-4) GO TO 150 t = w - dlog(sum) xn = exp((xn+t)/a) xn = xn* (1.0D0- (a*dlog(xn)-xn-t)/ (a-xn)) GO TO 170 C C SCHRODER ITERATION USING P C 160 IF (p.GT.0.5D0) GO TO 220 170 IF (p.LE.1.D10*xmin) GO TO 350 am1 = (a-0.5D0) - 0.5D0 180 IF (a.LE.amax) GO TO 190 d = 0.5D0 + (0.5D0-xn/a) IF (abs(d).LE.e2) GO TO 350 C 190 IF (ierr.GE.20) GO TO 330 ierr = ierr + 1 CALL gratio(a,xn,pn,qn,0) IF (pn.EQ.0.0D0 .OR. qn.EQ.0.0D0) GO TO 350 r = rcomp(a,xn) IF (r.EQ.0.0D0) GO TO 350 t = (pn-p)/r w = 0.5D0* (am1-xn) IF (abs(t).LE.0.1D0 .AND. abs(w*t).LE.0.1D0) GO TO 200 x = xn* (1.0D0-t) IF (x.LE.0.0D0) GO TO 340 d = abs(t) GO TO 210 C 200 h = t* (1.0D0+w*t) x = xn* (1.0D0-h) IF (x.LE.0.0D0) GO TO 340 IF (abs(w).GE.1.0D0 .AND. abs(w)*t*t.LE.eps) RETURN d = abs(h) 210 xn = x IF (d.GT.tol) GO TO 180 IF (d.LE.eps) RETURN IF (abs(p-pn).LE.tol*p) RETURN GO TO 180 C C SCHRODER ITERATION USING Q C 220 IF (q.LE.1.D10*xmin) GO TO 350 am1 = (a-0.5D0) - 0.5D0 230 IF (a.LE.amax) GO TO 240 d = 0.5D0 + (0.5D0-xn/a) IF (abs(d).LE.e2) GO TO 350 C 240 IF (ierr.GE.20) GO TO 330 ierr = ierr + 1 CALL gratio(a,xn,pn,qn,0) IF (pn.EQ.0.0D0 .OR. qn.EQ.0.0D0) GO TO 350 r = rcomp(a,xn) IF (r.EQ.0.0D0) GO TO 350 t = (q-qn)/r w = 0.5D0* (am1-xn) IF (abs(t).LE.0.1D0 .AND. abs(w*t).LE.0.1D0) GO TO 250 x = xn* (1.0D0-t) IF (x.LE.0.0D0) GO TO 340 d = abs(t) GO TO 260 C 250 h = t* (1.0D0+w*t) x = xn* (1.0D0-h) IF (x.LE.0.0D0) GO TO 340 IF (abs(w).GE.1.0D0 .AND. abs(w)*t*t.LE.eps) RETURN d = abs(h) 260 xn = x IF (d.GT.tol) GO TO 230 IF (d.LE.eps) RETURN IF (abs(q-qn).LE.tol*q) RETURN GO TO 230 C C SPECIAL CASES C 270 x = xmax RETURN C 280 IF (q.LT.0.9D0) GO TO 290 x = -alnrel(-p) RETURN 290 x = -dlog(q) RETURN C C ERROR RETURN C 300 ierr = -2 RETURN C 310 ierr = -3 RETURN C 320 ierr = -4 RETURN C 330 ierr = -6 RETURN C 340 ierr = -7 RETURN C 350 x = xn ierr = -8 RETURN C 360 x = xmax ierr = -8 RETURN END
bsd-3-clause
andim/scipy
scipy/special/cdflib/gaminv.f
151
10511
SUBROUTINE gaminv(a,x,x0,p,q,ierr) C ---------------------------------------------------------------------- C INVERSE INCOMPLETE GAMMA RATIO FUNCTION C C GIVEN POSITIVE A, AND NONEGATIVE P AND Q WHERE P + Q = 1. C THEN X IS COMPUTED WHERE P(A,X) = P AND Q(A,X) = Q. SCHRODER C ITERATION IS EMPLOYED. THE ROUTINE ATTEMPTS TO COMPUTE X C TO 10 SIGNIFICANT DIGITS IF THIS IS POSSIBLE FOR THE C PARTICULAR COMPUTER ARITHMETIC BEING USED. C C ------------ C C X IS A VARIABLE. IF P = 0 THEN X IS ASSIGNED THE VALUE 0, C AND IF Q = 0 THEN X IS SET TO THE LARGEST FLOATING POINT C NUMBER AVAILABLE. OTHERWISE, GAMINV ATTEMPTS TO OBTAIN C A SOLUTION FOR P(A,X) = P AND Q(A,X) = Q. IF THE ROUTINE C IS SUCCESSFUL THEN THE SOLUTION IS STORED IN X. C C X0 IS AN OPTIONAL INITIAL APPROXIMATION FOR X. IF THE USER C DOES NOT WISH TO SUPPLY AN INITIAL APPROXIMATION, THEN SET C X0 .LE. 0. C C IERR IS A VARIABLE THAT REPORTS THE STATUS OF THE RESULTS. C WHEN THE ROUTINE TERMINATES, IERR HAS ONE OF THE FOLLOWING C VALUES ... C C IERR = 0 THE SOLUTION WAS OBTAINED. ITERATION WAS C NOT USED. C IERR.GT.0 THE SOLUTION WAS OBTAINED. IERR ITERATIONS C WERE PERFORMED. C IERR = -2 (INPUT ERROR) A .LE. 0 C IERR = -3 NO SOLUTION WAS OBTAINED. THE RATIO Q/A C IS TOO LARGE. C IERR = -4 (INPUT ERROR) P + Q .NE. 1 C IERR = -6 20 ITERATIONS WERE PERFORMED. THE MOST C RECENT VALUE OBTAINED FOR X IS GIVEN. C THIS CANNOT OCCUR IF X0 .LE. 0. C IERR = -7 ITERATION FAILED. NO VALUE IS GIVEN FOR X. C THIS MAY OCCUR WHEN X IS APPROXIMATELY 0. C IERR = -8 A VALUE FOR X HAS BEEN OBTAINED, BUT THE C ROUTINE IS NOT CERTAIN OF ITS ACCURACY. C ITERATION CANNOT BE PERFORMED IN THIS C CASE. IF X0 .LE. 0, THIS CAN OCCUR ONLY C WHEN P OR Q IS APPROXIMATELY 0. IF X0 IS C POSITIVE THEN THIS CAN OCCUR WHEN A IS C EXCEEDINGLY CLOSE TO X AND A IS EXTREMELY C LARGE (SAY A .GE. 1.E20). C ---------------------------------------------------------------------- C WRITTEN BY ALFRED H. MORRIS, JR. C NAVAL SURFACE WEAPONS CENTER C DAHLGREN, VIRGINIA C ------------------- C .. Scalar Arguments .. DOUBLE PRECISION a,p,q,x,x0 INTEGER ierr C .. C .. Local Scalars .. DOUBLE PRECISION a0,a1,a2,a3,am1,amax,ap1,ap2,ap3,apn,b,b1,b2,b3, + b4,c,c1,c2,c3,c4,c5,d,e,e2,eps,g,h,ln10,pn,qg,qn, + r,rta,s,s2,sum,t,tol,u,w,xmax,xmin,xn,y,z INTEGER iop C .. C .. Local Arrays .. DOUBLE PRECISION amin(2),bmin(2),dmin(2),emin(2),eps0(2) C .. C .. External Functions .. DOUBLE PRECISION alnrel,gamln,gamln1,gamma,rcomp,spmpar EXTERNAL alnrel,gamln,gamln1,gamma,rcomp,spmpar C .. C .. External Subroutines .. EXTERNAL gratio C .. C .. Intrinsic Functions .. INTRINSIC abs,dble,dlog,dmax1,exp,sqrt C .. C .. Data statements .. C ------------------- C LN10 = LN(10) C C = EULER CONSTANT C ------------------- C ------------------- C ------------------- C ------------------- DATA ln10/2.302585D0/ DATA c/.577215664901533D0/ DATA a0/3.31125922108741D0/,a1/11.6616720288968D0/, + a2/4.28342155967104D0/,a3/.213623493715853D0/ DATA b1/6.61053765625462D0/,b2/6.40691597760039D0/, + b3/1.27364489782223D0/,b4/.036117081018842D0/ DATA eps0(1)/1.D-10/,eps0(2)/1.D-08/ DATA amin(1)/500.0D0/,amin(2)/100.0D0/ DATA bmin(1)/1.D-28/,bmin(2)/1.D-13/ DATA dmin(1)/1.D-06/,dmin(2)/1.D-04/ DATA emin(1)/2.D-03/,emin(2)/6.D-03/ DATA tol/1.D-5/ C .. C .. Executable Statements .. C ------------------- C ****** E, XMIN, AND XMAX ARE MACHINE DEPENDENT CONSTANTS. C E IS THE SMALLEST NUMBER FOR WHICH 1.0 + E .GT. 1.0. C XMIN IS THE SMALLEST POSITIVE NUMBER AND XMAX IS THE C LARGEST POSITIVE NUMBER. C e = spmpar(1) xmin = spmpar(2) xmax = spmpar(3) C ------------------- x = 0.0D0 IF (a.LE.0.0D0) GO TO 300 t = dble(p) + dble(q) - 1.D0 IF (abs(t).GT.e) GO TO 320 C ierr = 0 IF (p.EQ.0.0D0) RETURN IF (q.EQ.0.0D0) GO TO 270 IF (a.EQ.1.0D0) GO TO 280 C e2 = 2.0D0*e amax = 0.4D-10/ (e*e) iop = 1 IF (e.GT.1.D-10) iop = 2 eps = eps0(iop) xn = x0 IF (x0.GT.0.0D0) GO TO 160 C C SELECTION OF THE INITIAL APPROXIMATION XN OF X C WHEN A .LT. 1 C IF (a.GT.1.0D0) GO TO 80 g = gamma(a+1.0D0) qg = q*g IF (qg.EQ.0.0D0) GO TO 360 b = qg/a IF (qg.GT.0.6D0*a) GO TO 40 IF (a.GE.0.30D0 .OR. b.LT.0.35D0) GO TO 10 t = exp(- (b+c)) u = t*exp(t) xn = t*exp(u) GO TO 160 C 10 IF (b.GE.0.45D0) GO TO 40 IF (b.EQ.0.0D0) GO TO 360 y = -dlog(b) s = 0.5D0 + (0.5D0-a) z = dlog(y) t = y - s*z IF (b.LT.0.15D0) GO TO 20 xn = y - s*dlog(t) - dlog(1.0D0+s/ (t+1.0D0)) GO TO 220 20 IF (b.LE.0.01D0) GO TO 30 u = ((t+2.0D0* (3.0D0-a))*t+ (2.0D0-a)* (3.0D0-a))/ + ((t+ (5.0D0-a))*t+2.0D0) xn = y - s*dlog(t) - dlog(u) GO TO 220 30 c1 = -s*z c2 = -s* (1.0D0+c1) c3 = s* ((0.5D0*c1+ (2.0D0-a))*c1+ (2.5D0-1.5D0*a)) c4 = -s* (((c1/3.0D0+ (2.5D0-1.5D0*a))*c1+ ((a-6.0D0)*a+7.0D0))* + c1+ ((11.0D0*a-46)*a+47.0D0)/6.0D0) c5 = -s* ((((-c1/4.0D0+ (11.0D0*a-17.0D0)/6.0D0)*c1+ ((-3.0D0*a+ + 13.0D0)*a-13.0D0))*c1+0.5D0* (((2.0D0*a-25.0D0)*a+72.0D0)*a- + 61.0D0))*c1+ (((25.0D0*a-195.0D0)*a+477.0D0)*a-379.0D0)/ + 12.0D0) xn = ((((c5/y+c4)/y+c3)/y+c2)/y+c1) + y IF (a.GT.1.0D0) GO TO 220 IF (b.GT.bmin(iop)) GO TO 220 x = xn RETURN C 40 IF (b*q.GT.1.D-8) GO TO 50 xn = exp(- (q/a+c)) GO TO 70 50 IF (p.LE.0.9D0) GO TO 60 xn = exp((alnrel(-q)+gamln1(a))/a) GO TO 70 60 xn = exp(dlog(p*g)/a) 70 IF (xn.EQ.0.0D0) GO TO 310 t = 0.5D0 + (0.5D0-xn/ (a+1.0D0)) xn = xn/t GO TO 160 C C SELECTION OF THE INITIAL APPROXIMATION XN OF X C WHEN A .GT. 1 C 80 IF (q.LE.0.5D0) GO TO 90 w = dlog(p) GO TO 100 90 w = dlog(q) 100 t = sqrt(-2.0D0*w) s = t - (((a3*t+a2)*t+a1)*t+a0)/ ((((b4*t+b3)*t+b2)*t+b1)*t+1.0D0) IF (q.GT.0.5D0) s = -s C rta = sqrt(a) s2 = s*s xn = a + s*rta + (s2-1.0D0)/3.0D0 + s* (s2-7.0D0)/ (36.0D0*rta) - + ((3.0D0*s2+7.0D0)*s2-16.0D0)/ (810.0D0*a) + + s* ((9.0D0*s2+256.0D0)*s2-433.0D0)/ (38880.0D0*a*rta) xn = dmax1(xn,0.0D0) IF (a.LT.amin(iop)) GO TO 110 x = xn d = 0.5D0 + (0.5D0-x/a) IF (abs(d).LE.dmin(iop)) RETURN C 110 IF (p.LE.0.5D0) GO TO 130 IF (xn.LT.3.0D0*a) GO TO 220 y = - (w+gamln(a)) d = dmax1(2.0D0,a* (a-1.0D0)) IF (y.LT.ln10*d) GO TO 120 s = 1.0D0 - a z = dlog(y) GO TO 30 120 t = a - 1.0D0 xn = y + t*dlog(xn) - alnrel(-t/ (xn+1.0D0)) xn = y + t*dlog(xn) - alnrel(-t/ (xn+1.0D0)) GO TO 220 C 130 ap1 = a + 1.0D0 IF (xn.GT.0.70D0*ap1) GO TO 170 w = w + gamln(ap1) IF (xn.GT.0.15D0*ap1) GO TO 140 ap2 = a + 2.0D0 ap3 = a + 3.0D0 x = exp((w+x)/a) x = exp((w+x-dlog(1.0D0+ (x/ap1)* (1.0D0+x/ap2)))/a) x = exp((w+x-dlog(1.0D0+ (x/ap1)* (1.0D0+x/ap2)))/a) x = exp((w+x-dlog(1.0D0+ (x/ap1)* (1.0D0+ (x/ap2)* (1.0D0+ + x/ap3))))/a) xn = x IF (xn.GT.1.D-2*ap1) GO TO 140 IF (xn.LE.emin(iop)*ap1) RETURN GO TO 170 C 140 apn = ap1 t = xn/apn sum = 1.0D0 + t 150 apn = apn + 1.0D0 t = t* (xn/apn) sum = sum + t IF (t.GT.1.D-4) GO TO 150 t = w - dlog(sum) xn = exp((xn+t)/a) xn = xn* (1.0D0- (a*dlog(xn)-xn-t)/ (a-xn)) GO TO 170 C C SCHRODER ITERATION USING P C 160 IF (p.GT.0.5D0) GO TO 220 170 IF (p.LE.1.D10*xmin) GO TO 350 am1 = (a-0.5D0) - 0.5D0 180 IF (a.LE.amax) GO TO 190 d = 0.5D0 + (0.5D0-xn/a) IF (abs(d).LE.e2) GO TO 350 C 190 IF (ierr.GE.20) GO TO 330 ierr = ierr + 1 CALL gratio(a,xn,pn,qn,0) IF (pn.EQ.0.0D0 .OR. qn.EQ.0.0D0) GO TO 350 r = rcomp(a,xn) IF (r.EQ.0.0D0) GO TO 350 t = (pn-p)/r w = 0.5D0* (am1-xn) IF (abs(t).LE.0.1D0 .AND. abs(w*t).LE.0.1D0) GO TO 200 x = xn* (1.0D0-t) IF (x.LE.0.0D0) GO TO 340 d = abs(t) GO TO 210 C 200 h = t* (1.0D0+w*t) x = xn* (1.0D0-h) IF (x.LE.0.0D0) GO TO 340 IF (abs(w).GE.1.0D0 .AND. abs(w)*t*t.LE.eps) RETURN d = abs(h) 210 xn = x IF (d.GT.tol) GO TO 180 IF (d.LE.eps) RETURN IF (abs(p-pn).LE.tol*p) RETURN GO TO 180 C C SCHRODER ITERATION USING Q C 220 IF (q.LE.1.D10*xmin) GO TO 350 am1 = (a-0.5D0) - 0.5D0 230 IF (a.LE.amax) GO TO 240 d = 0.5D0 + (0.5D0-xn/a) IF (abs(d).LE.e2) GO TO 350 C 240 IF (ierr.GE.20) GO TO 330 ierr = ierr + 1 CALL gratio(a,xn,pn,qn,0) IF (pn.EQ.0.0D0 .OR. qn.EQ.0.0D0) GO TO 350 r = rcomp(a,xn) IF (r.EQ.0.0D0) GO TO 350 t = (q-qn)/r w = 0.5D0* (am1-xn) IF (abs(t).LE.0.1D0 .AND. abs(w*t).LE.0.1D0) GO TO 250 x = xn* (1.0D0-t) IF (x.LE.0.0D0) GO TO 340 d = abs(t) GO TO 260 C 250 h = t* (1.0D0+w*t) x = xn* (1.0D0-h) IF (x.LE.0.0D0) GO TO 340 IF (abs(w).GE.1.0D0 .AND. abs(w)*t*t.LE.eps) RETURN d = abs(h) 260 xn = x IF (d.GT.tol) GO TO 230 IF (d.LE.eps) RETURN IF (abs(q-qn).LE.tol*q) RETURN GO TO 230 C C SPECIAL CASES C 270 x = xmax RETURN C 280 IF (q.LT.0.9D0) GO TO 290 x = -alnrel(-p) RETURN 290 x = -dlog(q) RETURN C C ERROR RETURN C 300 ierr = -2 RETURN C 310 ierr = -3 RETURN C 320 ierr = -4 RETURN C 330 ierr = -6 RETURN C 340 ierr = -7 RETURN C 350 x = xn ierr = -8 RETURN C 360 x = xmax ierr = -8 RETURN END
bsd-3-clause
puppeh/gcc-6502
gcc/testsuite/gfortran.dg/g77/970125-0.f
202
1528
c { dg-do compile } c c Following line added on transfer to gfortran testsuite c { dg-excess-errors "" } c C JCB comments: C g77 doesn't accept the added line "integer(kind=7) ..." -- C it crashes! C C It's questionable that g77 DTRT with regarding to passing C %LOC() as an argument (thus by reference) and the new global C analysis. I need to look into that further; my feeling is that C passing %LOC() as an argument should be treated like passing an C INTEGER(KIND=7) by reference, and no more specially than that C (and that INTEGER(KIND=7) should be permitted as equivalent to C INTEGER(KIND=1), INTEGER(KIND=2), or whatever, depending on the C system's pointer size). C C The back end *still* has a bug here, which should be fixed, C because, currently, what g77 is passing to it is, IMO, correct. C No options: C ../../egcs/gcc/f/info.c:259: failed assertion `ffeinfo_types_[basictype][kindtype] != NULL' C -fno-globals -O: C ../../egcs/gcc/expr.c:7291: Internal compiler error in function expand_expr c Frontend bug fixed by JCB 1998-06-01 com.c &c changes. integer i4 integer(kind=8) i8 integer(kind=8) max4 data max4/2147483647/ i4 = %loc(i4) i8 = %loc(i8) print *, max4 print *, i4, %loc(i4) print *, i8, %loc(i8) call foo(i4, %loc(i4), i8, %loc(i8)) end subroutine foo(i4, i4a, i8, i8a) integer(kind=7) i4a, i8a integer(kind=8) i8 print *, i4, i4a print *, i8, i8a end
gpl-2.0
puppeh/gcc-6502
libgfortran/generated/_asin_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_ASINF elemental function _gfortran_specific__asin_r4 (parm) real (kind=4), intent (in) :: parm real (kind=4) :: _gfortran_specific__asin_r4 _gfortran_specific__asin_r4 = asin (parm) end function #endif #endif
gpl-2.0
vigna/scipy
scipy/sparse/linalg/_eigen/arpack/ARPACK/SRC/zneupd.f
141
34995
c\BeginDoc c c\Name: zneupd c c\Description: c This subroutine returns the converged approximations to eigenvalues c of A*z = lambda*B*z and (optionally): c c (1) The corresponding approximate eigenvectors; c c (2) An orthonormal basis for the associated approximate c invariant subspace; c c (3) Both. c c There is negligible additional cost to obtain eigenvectors. An orthonormal c basis is always computed. There is an additional storage cost of n*nev c if both are requested (in this case a separate array Z must be supplied). c c The approximate eigenvalues and eigenvectors of A*z = lambda*B*z c are derived from approximate eigenvalues and eigenvectors of c of the linear operator OP prescribed by the MODE selection in the c call to ZNAUPD. ZNAUPD must be called before this routine is called. c These approximate eigenvalues and vectors are commonly called Ritz c values and Ritz vectors respectively. They are referred to as such c in the comments that follow. The computed orthonormal basis for the c invariant subspace corresponding to these Ritz values is referred to as a c Schur basis. c c The definition of OP as well as other terms and the relation of computed c Ritz values and vectors of OP with respect to the given problem c A*z = lambda*B*z may be found in the header of ZNAUPD. For a brief c description, see definitions of IPARAM(7), MODE and WHICH in the c documentation of ZNAUPD. c c\Usage: c call zneupd c ( RVEC, HOWMNY, SELECT, D, Z, LDZ, SIGMA, WORKEV, BMAT, c N, WHICH, NEV, TOL, RESID, NCV, V, LDV, IPARAM, IPNTR, WORKD, c WORKL, LWORKL, RWORK, INFO ) c c\Arguments: c RVEC LOGICAL (INPUT) c Specifies whether a basis for the invariant subspace corresponding c to the converged Ritz value approximations for the eigenproblem c A*z = lambda*B*z is computed. c c RVEC = .FALSE. Compute Ritz values only. c c RVEC = .TRUE. Compute Ritz vectors or Schur vectors. c See Remarks below. c c HOWMNY Character*1 (INPUT) c Specifies the form of the basis for the invariant subspace c corresponding to the converged Ritz values that is to be computed. c c = 'A': Compute NEV Ritz vectors; c = 'P': Compute NEV Schur vectors; c = 'S': compute some of the Ritz vectors, specified c by the logical array SELECT. c c SELECT Logical array of dimension NCV. (INPUT) c If HOWMNY = 'S', SELECT specifies the Ritz vectors to be c computed. To select the Ritz vector corresponding to a c Ritz value D(j), SELECT(j) must be set to .TRUE.. c If HOWMNY = 'A' or 'P', SELECT need not be initialized c but it is used as internal workspace. c c D Complex*16 array of dimension NEV+1. (OUTPUT) c On exit, D contains the Ritz approximations c to the eigenvalues lambda for A*z = lambda*B*z. c c Z Complex*16 N by NEV array (OUTPUT) c On exit, if RVEC = .TRUE. and HOWMNY = 'A', then the columns of c Z represents approximate eigenvectors (Ritz vectors) corresponding c to the NCONV=IPARAM(5) Ritz values for eigensystem c A*z = lambda*B*z. c c If RVEC = .FALSE. or HOWMNY = 'P', then Z is NOT REFERENCED. c c NOTE: If if RVEC = .TRUE. and a Schur basis is not required, c the array Z may be set equal to first NEV+1 columns of the Arnoldi c basis array V computed by ZNAUPD. In this case the Arnoldi basis c will be destroyed and overwritten with the eigenvector basis. c c LDZ Integer. (INPUT) c The leading dimension of the array Z. If Ritz vectors are c desired, then LDZ .ge. max( 1, N ) is required. c In any case, LDZ .ge. 1 is required. c c SIGMA Complex*16 (INPUT) c If IPARAM(7) = 3 then SIGMA represents the shift. c Not referenced if IPARAM(7) = 1 or 2. c c WORKEV Complex*16 work array of dimension 2*NCV. (WORKSPACE) c c **** The remaining arguments MUST be the same as for the **** c **** call to ZNAUPD that was just completed. **** c c NOTE: The remaining arguments c c BMAT, N, WHICH, NEV, TOL, RESID, NCV, V, LDV, IPARAM, IPNTR, c WORKD, WORKL, LWORKL, RWORK, INFO c c must be passed directly to ZNEUPD following the last call c to ZNAUPD. These arguments MUST NOT BE MODIFIED between c the the last call to ZNAUPD and the call to ZNEUPD. c c Three of these parameters (V, WORKL and INFO) are also output parameters: c c V Complex*16 N by NCV array. (INPUT/OUTPUT) c c Upon INPUT: the NCV columns of V contain the Arnoldi basis c vectors for OP as constructed by ZNAUPD . c c Upon OUTPUT: If RVEC = .TRUE. the first NCONV=IPARAM(5) columns c contain approximate Schur vectors that span the c desired invariant subspace. c c NOTE: If the array Z has been set equal to first NEV+1 columns c of the array V and RVEC=.TRUE. and HOWMNY= 'A', then the c Arnoldi basis held by V has been overwritten by the desired c Ritz vectors. If a separate array Z has been passed then c the first NCONV=IPARAM(5) columns of V will contain approximate c Schur vectors that span the desired invariant subspace. c c WORKL Double precision work array of length LWORKL. (OUTPUT/WORKSPACE) c WORKL(1:ncv*ncv+2*ncv) contains information obtained in c znaupd. They are not changed by zneupd. c WORKL(ncv*ncv+2*ncv+1:3*ncv*ncv+4*ncv) holds the c untransformed Ritz values, the untransformed error estimates of c the Ritz values, the upper triangular matrix for H, and the c associated matrix representation of the invariant subspace for H. c c Note: IPNTR(9:13) contains the pointer into WORKL for addresses c of the above information computed by zneupd. c ------------------------------------------------------------- c IPNTR(9): pointer to the NCV RITZ values of the c original system. c IPNTR(10): Not used c IPNTR(11): pointer to the NCV corresponding error estimates. c IPNTR(12): pointer to the NCV by NCV upper triangular c Schur matrix for H. c IPNTR(13): pointer to the NCV by NCV matrix of eigenvectors c of the upper Hessenberg matrix H. Only referenced by c zneupd if RVEC = .TRUE. See Remark 2 below. c ------------------------------------------------------------- c c INFO Integer. (OUTPUT) c Error flag on output. c = 0: Normal exit. c c = 1: The Schur form computed by LAPACK routine csheqr c could not be reordered by LAPACK routine ztrsen. c Re-enter subroutine zneupd with IPARAM(5)=NCV and c increase the size of the array D to have c dimension at least dimension NCV and allocate at least NCV c columns for Z. NOTE: Not necessary if Z and V share c the same space. Please notify the authors if this error c occurs. c c = -1: N must be positive. c = -2: NEV must be positive. c = -3: NCV-NEV >= 1 and less than or equal to N. c = -5: WHICH must be one of 'LM', 'SM', 'LR', 'SR', 'LI', 'SI' c = -6: BMAT must be one of 'I' or 'G'. c = -7: Length of private work WORKL array is not sufficient. c = -8: Error return from LAPACK eigenvalue calculation. c This should never happened. c = -9: Error return from calculation of eigenvectors. c Informational error from LAPACK routine ztrevc. c = -10: IPARAM(7) must be 1,2,3 c = -11: IPARAM(7) = 1 and BMAT = 'G' are incompatible. c = -12: HOWMNY = 'S' not yet implemented c = -13: HOWMNY must be one of 'A' or 'P' if RVEC = .true. c = -14: ZNAUPD did not find any eigenvalues to sufficient c accuracy. c = -15: ZNEUPD got a different count of the number of converged c Ritz values than ZNAUPD got. This indicates the user c probably made an error in passing data from ZNAUPD to c ZNEUPD or that the data was modified before entering c ZNEUPD c c\BeginLib 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 3. B. Nour-Omid, B. N. Parlett, T. Ericsson and P. S. Jensen, c "How to Implement the Spectral Transformation", Math Comp., c Vol. 48, No. 178, April, 1987 pp. 664-673. c c\Routines called: c ivout ARPACK utility routine that prints integers. c zmout ARPACK utility routine that prints matrices c zvout ARPACK utility routine that prints vectors. c zgeqr2 LAPACK routine that computes the QR factorization of c a matrix. c zlacpy LAPACK matrix copy routine. c zlahqr LAPACK routine that computes the Schur form of a c upper Hessenberg matrix. c zlaset LAPACK matrix initialization routine. c ztrevc LAPACK routine to compute the eigenvectors of a matrix c in upper triangular form. c ztrsen LAPACK routine that re-orders the Schur form. c zunm2r LAPACK routine that applies an orthogonal matrix in c factored form. c dlamch LAPACK routine that determines machine constants. c ztrmm Level 3 BLAS matrix times an upper triangular matrix. c zgeru Level 2 BLAS rank one update to a matrix. c zcopy Level 1 BLAS that copies one vector to another . c zscal Level 1 BLAS that scales a vector. c zdscal Level 1 BLAS that scales a complex vector by a real number. c dznrm2 Level 1 BLAS that computes the norm of a complex vector. c c\Remarks c c 1. Currently only HOWMNY = 'A' and 'P' are implemented. c c 2. Schur vectors are an orthogonal representation for the basis of c Ritz vectors. Thus, their numerical properties are often superior. c If RVEC = .true. then the relationship c A * V(:,1:IPARAM(5)) = V(:,1:IPARAM(5)) * T, and c transpose( V(:,1:IPARAM(5)) ) * V(:,1:IPARAM(5)) = I c are approximately satisfied. c Here T is the leading submatrix of order IPARAM(5) of the c upper triangular matrix stored workl(ipntr(12)). c c\Authors c Danny Sorensen Phuong Vu c Richard Lehoucq CRPC / Rice University c Chao Yang Houston, Texas c Dept. of Computational & c Applied Mathematics c Rice University c Houston, Texas c c\SCCS Information: @(#) c FILE: neupd.F SID: 2.8 DATE OF SID: 07/21/02 RELEASE: 2 c c\EndLib c c----------------------------------------------------------------------- subroutine zneupd(rvec , howmny, select, d , & z , ldz , sigma , workev, & bmat , n , which , nev , & tol , resid , ncv , v , & ldv , iparam, ipntr , workd , & workl, lworkl, 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, howmny, which*2 logical rvec integer info, ldz, ldv, lworkl, n, ncv, nev Complex*16 & sigma Double precision & tol c c %-----------------% c | Array Arguments | c %-----------------% c integer iparam(11), ipntr(14) logical select(ncv) Double precision & rwork(ncv) Complex*16 & d(nev) , resid(n) , v(ldv,ncv), & z(ldz, nev), & workd(3*n) , workl(lworkl), workev(2*ncv) c c %------------% c | Parameters | c %------------% c Complex*16 & one, zero parameter (one = (1.0D+0, 0.0D+0), zero = (0.0D+0, 0.0D+0)) c c %---------------% c | Local Scalars | c %---------------% c character type*6 integer bounds, ierr , ih , ihbds, iheig , nconv , & invsub, iuptri, iwev , j , ldh , ldq , & mode , msglvl, ritz , wr , k , irz , & ibd , outncv, iq , np , numcnv, jj , & ishift, nconv2 Complex*16 & rnorm, temp, vl(1) Double precision & conds, sep, rtemp, eps23 logical reord c c %----------------------% c | External Subroutines | c %----------------------% c external zcopy , zgeru, zgeqr2, zlacpy, zmout, & zunm2r, ztrmm, zvout, ivout, & zlahqr c c %--------------------% c | External Functions | c %--------------------% c Double precision & dznrm2, dlamch, dlapy2 external dznrm2, dlamch, dlapy2 c Complex*16 & wzdotc external wzdotc c c %-----------------------% c | Executable Statements | c %-----------------------% c c %------------------------% c | Set default parameters | c %------------------------% c msglvl = mceupd mode = iparam(7) nconv = iparam(5) info = 0 c c c %---------------------------------% c | Get machine dependent constant. | c %---------------------------------% c eps23 = dlamch('Epsilon-Machine') eps23 = eps23**(2.0D+0 / 3.0D+0) c c %-------------------------------% c | Quick return | c | Check for incompatible input | c %-------------------------------% c ierr = 0 c if (nconv .le. 0) then ierr = -14 else if (n .le. 0) then ierr = -1 else if (nev .le. 0) then ierr = -2 else if (ncv .le. nev+1 .or. ncv .gt. n) then ierr = -3 else if (which .ne. 'LM' .and. & which .ne. 'SM' .and. & which .ne. 'LR' .and. & which .ne. 'SR' .and. & which .ne. 'LI' .and. & which .ne. 'SI') then ierr = -5 else if (bmat .ne. 'I' .and. bmat .ne. 'G') then ierr = -6 else if (lworkl .lt. 3*ncv**2 + 4*ncv) then ierr = -7 else if ( (howmny .ne. 'A' .and. & howmny .ne. 'P' .and. & howmny .ne. 'S') .and. rvec ) then ierr = -13 else if (howmny .eq. 'S' ) then ierr = -12 end if c if (mode .eq. 1 .or. mode .eq. 2) then type = 'REGULR' else if (mode .eq. 3 ) then type = 'SHIFTI' else ierr = -10 end if if (mode .eq. 1 .and. bmat .eq. 'G') ierr = -11 c c %------------% c | Error Exit | c %------------% c if (ierr .ne. 0) then info = ierr go to 9000 end if c c %--------------------------------------------------------% c | Pointer into WORKL for address of H, RITZ, WORKEV, Q | c | etc... and the remaining workspace. | c | Also update pointer to be used on output. | c | Memory is laid out as follows: | c | workl(1:ncv*ncv) := generated Hessenberg matrix | c | workl(ncv*ncv+1:ncv*ncv+ncv) := ritz values | c | workl(ncv*ncv+ncv+1:ncv*ncv+2*ncv) := error bounds | c %--------------------------------------------------------% c c %-----------------------------------------------------------% c | The following is used and set by ZNEUPD. | c | workl(ncv*ncv+2*ncv+1:ncv*ncv+3*ncv) := The untransformed | c | Ritz values. | c | workl(ncv*ncv+3*ncv+1:ncv*ncv+4*ncv) := The untransformed | c | error bounds of | c | the Ritz values | c | workl(ncv*ncv+4*ncv+1:2*ncv*ncv+4*ncv) := Holds the upper | c | triangular matrix | c | for H. | c | workl(2*ncv*ncv+4*ncv+1: 3*ncv*ncv+4*ncv) := Holds the | c | associated matrix | c | representation of | c | the invariant | c | subspace for H. | c | GRAND total of NCV * ( 3 * NCV + 4 ) locations. | c %-----------------------------------------------------------% c ih = ipntr(5) ritz = ipntr(6) iq = ipntr(7) bounds = ipntr(8) ldh = ncv ldq = ncv iheig = bounds + ldh ihbds = iheig + ldh iuptri = ihbds + ldh invsub = iuptri + ldh*ncv ipntr(9) = iheig ipntr(11) = ihbds ipntr(12) = iuptri ipntr(13) = invsub wr = 1 iwev = wr + ncv c c %-----------------------------------------% c | irz points to the Ritz values computed | c | by _neigh before exiting _naup2. | c | ibd points to the Ritz estimates | c | computed by _neigh before exiting | c | _naup2. | c %-----------------------------------------% c irz = ipntr(14) + ncv*ncv ibd = irz + ncv c c %------------------------------------% c | RNORM is B-norm of the RESID(1:N). | c %------------------------------------% c rnorm = workl(ih+2) workl(ih+2) = zero c if (msglvl .gt. 2) then call zvout(logfil, ncv, workl(irz), ndigit, & '_neupd: Ritz values passed in from _NAUPD.') call zvout(logfil, ncv, workl(ibd), ndigit, & '_neupd: Ritz estimates passed in from _NAUPD.') end if c if (rvec) then c reord = .false. c c %---------------------------------------------------% c | Use the temporary bounds array to store indices | c | These will be used to mark the select array later | c %---------------------------------------------------% c do 10 j = 1,ncv workl(bounds+j-1) = j select(j) = .false. 10 continue c c %-------------------------------------% c | Select the wanted Ritz values. | c | Sort the Ritz values so that the | c | wanted ones appear at the tailing | c | NEV positions of workl(irr) and | c | workl(iri). Move the corresponding | c | error estimates in workl(ibd) | c | accordingly. | c %-------------------------------------% c np = ncv - nev ishift = 0 call zngets(ishift, which , nev , & np , workl(irz), workl(bounds)) c if (msglvl .gt. 2) then call zvout (logfil, ncv, workl(irz), ndigit, & '_neupd: Ritz values after calling _NGETS.') call zvout (logfil, ncv, workl(bounds), ndigit, & '_neupd: Ritz value indices after calling _NGETS.') end if c c %-----------------------------------------------------% c | Record indices of the converged wanted Ritz values | c | Mark the select array for possible reordering | c %-----------------------------------------------------% c numcnv = 0 do 11 j = 1,ncv rtemp = max(eps23, & dlapy2 ( dble(workl(irz+ncv-j)), & dimag(workl(irz+ncv-j)) )) jj = workl(bounds + ncv - j) if (numcnv .lt. nconv .and. & dlapy2( dble(workl(ibd+jj-1)), & dimag(workl(ibd+jj-1)) ) & .le. tol*rtemp) then select(jj) = .true. numcnv = numcnv + 1 if (jj .gt. nconv) reord = .true. endif 11 continue c c %-----------------------------------------------------------% c | Check the count (numcnv) of converged Ritz values with | c | the number (nconv) reported by dnaupd. If these two | c | are different then there has probably been an error | c | caused by incorrect passing of the dnaupd data. | c %-----------------------------------------------------------% c if (msglvl .gt. 2) then call ivout(logfil, 1, numcnv, ndigit, & '_neupd: Number of specified eigenvalues') call ivout(logfil, 1, nconv, ndigit, & '_neupd: Number of "converged" eigenvalues') end if c if (numcnv .ne. nconv) then info = -15 go to 9000 end if c c %-------------------------------------------------------% c | Call LAPACK routine zlahqr to compute the Schur form | c | of the upper Hessenberg matrix returned by ZNAUPD. | c | Make a copy of the upper Hessenberg matrix. | c | Initialize the Schur vector matrix Q to the identity. | c %-------------------------------------------------------% c call zcopy(ldh*ncv, workl(ih), 1, workl(iuptri), 1) call zlaset('All', ncv, ncv , & zero , one, workl(invsub), & ldq) call zlahqr(.true., .true. , ncv , & 1 , ncv , workl(iuptri), & ldh , workl(iheig) , 1 , & ncv , workl(invsub), ldq , & ierr) call zcopy(ncv , workl(invsub+ncv-1), ldq, & workl(ihbds), 1) c if (ierr .ne. 0) then info = -8 go to 9000 end if c if (msglvl .gt. 1) then call zvout (logfil, ncv, workl(iheig), ndigit, & '_neupd: Eigenvalues of H') call zvout (logfil, ncv, workl(ihbds), ndigit, & '_neupd: Last row of the Schur vector matrix') if (msglvl .gt. 3) then call zmout (logfil , ncv, ncv , & workl(iuptri), ldh, ndigit, & '_neupd: The upper triangular matrix ') end if end if c if (reord) then c c %-----------------------------------------------% c | Reorder the computed upper triangular matrix. | c %-----------------------------------------------% c call ztrsen('None' , 'V' , select , & ncv , workl(iuptri), ldh , & workl(invsub), ldq , workl(iheig), & nconv2 , conds , sep , & workev , ncv , ierr) c if (nconv2 .lt. nconv) then nconv = nconv2 end if if (ierr .eq. 1) then info = 1 go to 9000 end if c if (msglvl .gt. 2) then call zvout (logfil, ncv, workl(iheig), ndigit, & '_neupd: Eigenvalues of H--reordered') if (msglvl .gt. 3) then call zmout(logfil , ncv, ncv , & workl(iuptri), ldq, ndigit, & '_neupd: Triangular matrix after re-ordering') end if end if c end if c c %---------------------------------------------% c | Copy the last row of the Schur basis matrix | c | to workl(ihbds). This vector will be used | c | to compute the Ritz estimates of converged | c | Ritz values. | c %---------------------------------------------% c call zcopy(ncv , workl(invsub+ncv-1), ldq, & workl(ihbds), 1) c c %--------------------------------------------% c | Place the computed eigenvalues of H into D | c | if a spectral transformation was not used. | c %--------------------------------------------% c if (type .eq. 'REGULR') then call zcopy(nconv, workl(iheig), 1, d, 1) end if c c %----------------------------------------------------------% c | Compute the QR factorization of the matrix representing | c | the wanted invariant subspace located in the first NCONV | c | columns of workl(invsub,ldq). | c %----------------------------------------------------------% c call zgeqr2(ncv , nconv , workl(invsub), & ldq , workev, workev(ncv+1), & ierr) c c %--------------------------------------------------------% c | * Postmultiply V by Q using zunm2r. | c | * Copy the first NCONV columns of VQ into Z. | c | * Postmultiply Z by R. | c | The N by NCONV matrix Z is now a matrix representation | c | of the approximate invariant subspace associated with | c | the Ritz values in workl(iheig). The first NCONV | c | columns of V are now approximate Schur vectors | c | associated with the upper triangular matrix of order | c | NCONV in workl(iuptri). | c %--------------------------------------------------------% c call zunm2r('Right', 'Notranspose', n , & ncv , nconv , workl(invsub), & ldq , workev , v , & ldv , workd(n+1) , ierr) call zlacpy('All', n, nconv, v, ldv, z, ldz) c do 20 j=1, nconv c c %---------------------------------------------------% c | Perform both a column and row scaling if the | c | diagonal element of workl(invsub,ldq) is negative | c | I'm lazy and don't take advantage of the upper | c | triangular form of workl(iuptri,ldq). | c | Note that since Q is orthogonal, R is a diagonal | c | matrix consisting of plus or minus ones. | c %---------------------------------------------------% c if ( dble( workl(invsub+(j-1)*ldq+j-1) ) .lt. & dble(zero) ) then call zscal(nconv, -one, workl(iuptri+j-1), ldq) call zscal(nconv, -one, workl(iuptri+(j-1)*ldq), 1) end if c 20 continue c if (howmny .eq. 'A') then c c %--------------------------------------------% c | Compute the NCONV wanted eigenvectors of T | c | located in workl(iuptri,ldq). | c %--------------------------------------------% c do 30 j=1, ncv if (j .le. nconv) then select(j) = .true. else select(j) = .false. end if 30 continue c call ztrevc('Right', 'Select' , select , & ncv , workl(iuptri), ldq , & vl , 1 , workl(invsub), & ldq , ncv , outncv , & workev , rwork , ierr) c if (ierr .ne. 0) then info = -9 go to 9000 end if c c %------------------------------------------------% c | Scale the returning eigenvectors so that their | c | Euclidean norms are all one. LAPACK subroutine | c | ztrevc returns each eigenvector normalized so | c | that the element of largest magnitude has | c | magnitude 1. | c %------------------------------------------------% c do 40 j=1, nconv rtemp = dznrm2(ncv, workl(invsub+(j-1)*ldq), 1) rtemp = dble(one) / rtemp call zdscal ( ncv, rtemp, & workl(invsub+(j-1)*ldq), 1 ) c c %------------------------------------------% c | Ritz estimates can be obtained by taking | c | the inner product of the last row of the | c | Schur basis of H with eigenvectors of T. | c | Note that the eigenvector matrix of T is | c | upper triangular, thus the length of the | c | inner product can be set to j. | c %------------------------------------------% c workev(j) = wzdotc(j, workl(ihbds), 1, & workl(invsub+(j-1)*ldq), 1) 40 continue c if (msglvl .gt. 2) then call zcopy(nconv, workl(invsub+ncv-1), ldq, & workl(ihbds), 1) call zvout (logfil, nconv, workl(ihbds), ndigit, & '_neupd: Last row of the eigenvector matrix for T') if (msglvl .gt. 3) then call zmout(logfil , ncv, ncv , & workl(invsub), ldq, ndigit, & '_neupd: The eigenvector matrix for T') end if end if c c %---------------------------------------% c | Copy Ritz estimates into workl(ihbds) | c %---------------------------------------% c call zcopy(nconv, workev, 1, workl(ihbds), 1) c c %----------------------------------------------% c | The eigenvector matrix Q of T is triangular. | c | Form Z*Q. | c %----------------------------------------------% c call ztrmm('Right' , 'Upper' , 'No transpose', & 'Non-unit', n , nconv , & one , workl(invsub), ldq , & z , ldz) end if c else c c %--------------------------------------------------% c | An approximate invariant subspace is not needed. | c | Place the Ritz values computed ZNAUPD into D. | c %--------------------------------------------------% c call zcopy(nconv, workl(ritz), 1, d, 1) call zcopy(nconv, workl(ritz), 1, workl(iheig), 1) call zcopy(nconv, workl(bounds), 1, workl(ihbds), 1) c end if c c %------------------------------------------------% c | Transform the Ritz values and possibly vectors | c | and corresponding error bounds of OP to those | c | of A*x = lambda*B*x. | c %------------------------------------------------% c if (type .eq. 'REGULR') then c if (rvec) & call zscal(ncv, rnorm, workl(ihbds), 1) c else c c %---------------------------------------% c | A spectral transformation was used. | c | * Determine the Ritz estimates of the | c | Ritz values in the original system. | c %---------------------------------------% c if (rvec) & call zscal(ncv, rnorm, workl(ihbds), 1) c do 50 k=1, ncv temp = workl(iheig+k-1) workl(ihbds+k-1) = workl(ihbds+k-1) / temp / temp 50 continue c end if c c %-----------------------------------------------------------% c | * Transform the Ritz values back to the original system. | c | For TYPE = 'SHIFTI' the transformation is | c | lambda = 1/theta + sigma | c | NOTES: | c | *The Ritz vectors are not affected by the transformation. | c %-----------------------------------------------------------% c if (type .eq. 'SHIFTI') then do 60 k=1, nconv d(k) = one / workl(iheig+k-1) + sigma 60 continue end if c if (type .ne. 'REGULR' .and. msglvl .gt. 1) then call zvout (logfil, nconv, d, ndigit, & '_neupd: Untransformed Ritz values.') call zvout (logfil, nconv, workl(ihbds), ndigit, & '_neupd: Ritz estimates of the untransformed Ritz values.') else if ( msglvl .gt. 1) then call zvout (logfil, nconv, d, ndigit, & '_neupd: Converged Ritz values.') call zvout (logfil, nconv, workl(ihbds), ndigit, & '_neupd: Associated Ritz estimates.') end if c c %-------------------------------------------------% c | Eigenvector Purification step. Formally perform | c | one of inverse subspace iteration. Only used | c | for MODE = 3. See reference 3. | c %-------------------------------------------------% c if (rvec .and. howmny .eq. 'A' .and. type .eq. 'SHIFTI') then c c %------------------------------------------------% c | Purify the computed Ritz vectors by adding a | c | little bit of the residual vector: | c | T | c | resid(:)*( e s ) / theta | c | NCV | c | where H s = s theta. | c %------------------------------------------------% c do 100 j=1, nconv if (workl(iheig+j-1) .ne. zero) then workev(j) = workl(invsub+(j-1)*ldq+ncv-1) / & workl(iheig+j-1) endif 100 continue c %---------------------------------------% c | Perform a rank one update to Z and | c | purify all the Ritz vectors together. | c %---------------------------------------% c call zgeru (n, nconv, one, resid, 1, workev, 1, z, ldz) c end if c 9000 continue c return c c %---------------% c | End of zneupd| c %---------------% c end
bsd-3-clause
dch312/scipy
scipy/linalg/src/id_dist/src/idzr_rid.f
128
4548
c this file contains the following user-callable routines: c c c routine idzr_rid computes the ID, to a specified rank, c of a matrix specified by a routine for applying its adjoint c to arbitrary vectors. This routine is randomized. c c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c c c subroutine idzr_rid(m,n,matveca,p1,p2,p3,p4,krank,list,proj) c c computes the ID of a matrix "a" specified by c the routine matveca -- matveca must apply the adjoint c of the matrix being ID'd to an arbitrary vector -- c i.e., the present routine lists in list the indices c of krank columns of a such that c c a(j,list(k)) = a(j,list(k)) c c for all j = 1, ..., m; k = 1, ..., krank, and c c min(m,n,krank) c a(j,list(k)) = Sigma a(j,list(l)) * proj(l,k-krank)(*) c l=1 c c + epsilon(j,k-krank) c c for all j = 1, ..., m; k = krank+1, ..., n, c c for some matrix epsilon, dimensioned epsilon(m,n-krank), c whose norm is (hopefully) minimized by the pivoting procedure. c c input: c m -- number of rows in the matrix to be ID'd c n -- number of columns in the matrix to be ID'd c matveca -- routine which applies the adjoint c of the matrix to be ID'd to an arbitrary vector; c this routine must have a calling sequence c of the form c c matveca(m,x,n,y,p1,p2,p3,p4), c c where m is the length of x, c x is the vector to which the adjoint c of the matrix is to be applied, c n is the length of y, c y is the product of the adjoint of the matrix and x, c and p1, p2, p3, and p4 are user-specified parameters c p1 -- parameter to be passed to routine matveca c p2 -- parameter to be passed to routine matveca c p3 -- parameter to be passed to routine matveca c p4 -- parameter to be passed to routine matveca c krank -- rank of the ID to be constructed c c output: c list -- indices of the columns in the ID c proj -- matrix of coefficients needed to interpolate c from the selected columns to the other columns c in the original matrix being ID'd; c proj doubles as a work array in the present routine, so c proj must be at least m+(krank+3)*n complex*16 elements c long c c _N.B._: The algorithm used by this routine is randomized. c proj must be at least m+(krank+3)*n complex*16 elements c long. c c reference: c Halko, Martinsson, Tropp, "Finding structure with randomness: c probabilistic algorithms for constructing approximate c matrix decompositions," SIAM Review, 53 (2): 217-288, c 2011. c implicit none integer m,n,krank,list(n),lw,ix,lx,iy,ly,ir,lr complex*16 p1,p2,p3,p4,proj(m+(krank+3)*n) external matveca c c c Allocate memory in w. c lw = 0 c ir = lw+1 lr = (krank+2)*n lw = lw+lr c ix = lw+1 lx = m lw = lw+lx c iy = lw+1 ly = n lw = lw+ly c c call idzr_ridall0(m,n,matveca,p1,p2,p3,p4,krank, 1 list,proj(ir),proj(ix),proj(iy)) c c return end c c c c subroutine idzr_ridall0(m,n,matveca,p1,p2,p3,p4,krank, 1 list,r,x,y) c c routine idzr_ridall serves as a memory wrapper c for the present routine c (see idzr_ridall for further documentation). c implicit none integer j,k,l,m,n,krank,list(n),m2 complex*16 x(m),y(n),p1,p2,p3,p4,r(krank+2,n) external matveca c c c Set the number of random test vectors to 2 more than the rank. c l = krank+2 c c Apply the adjoint of the original matrix to l random vectors. c do j = 1,l c c Generate a random vector. c m2 = m*2 call id_srand(m2,x) c c Apply the adjoint of the matrix to x, obtaining y. c call matveca(m,x,n,y,p1,p2,p3,p4) c c Copy the conjugate of y into row j of r. c do k = 1,n r(j,k) = conjg(y(k)) enddo ! k c enddo ! j c c c ID r. c call idzr_id(l,n,r,krank,list,y) c c return end
bsd-3-clause
hendersa/sel4px4os
impl/libs/libpx4eigen/blas/testing/dblat1.f
288
44819
*> \brief \b DBLAT1 * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * PROGRAM DBLAT1 * * *> \par Purpose: * ============= *> *> \verbatim *> *> Test program for the DOUBLE PRECISION Level 1 BLAS. *> *> Based upon the original BLAS test routine together with: *> F06EAF Example Program Text *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date April 2012 * *> \ingroup double_blas_testing * * ===================================================================== PROGRAM DBLAT1 * * -- Reference BLAS test routine (version 3.4.1) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * April 2012 * * ===================================================================== * * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. DOUBLE PRECISION SFAC INTEGER IC * .. External Subroutines .. EXTERNAL CHECK0, CHECK1, CHECK2, CHECK3, HEADER * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA SFAC/9.765625D-4/ * .. Executable Statements .. WRITE (NOUT,99999) DO 20 IC = 1, 13 ICASE = IC CALL HEADER * * .. Initialize PASS, INCX, and INCY for a new case. .. * .. the value 9999 for INCX or INCY will appear in the .. * .. detailed output, if any, for cases that do not involve .. * .. these parameters .. * PASS = .TRUE. INCX = 9999 INCY = 9999 IF (ICASE.EQ.3 .OR. ICASE.EQ.11) THEN CALL CHECK0(SFAC) ELSE IF (ICASE.EQ.7 .OR. ICASE.EQ.8 .OR. ICASE.EQ.9 .OR. + ICASE.EQ.10) THEN CALL CHECK1(SFAC) ELSE IF (ICASE.EQ.1 .OR. ICASE.EQ.2 .OR. ICASE.EQ.5 .OR. + ICASE.EQ.6 .OR. ICASE.EQ.12 .OR. ICASE.EQ.13) THEN CALL CHECK2(SFAC) ELSE IF (ICASE.EQ.4) THEN CALL CHECK3(SFAC) END IF * -- Print IF (PASS) WRITE (NOUT,99998) 20 CONTINUE STOP * 99999 FORMAT (' Real BLAS Test Program Results',/1X) 99998 FORMAT (' ----- PASS -----') END SUBROUTINE HEADER * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Arrays .. CHARACTER*6 L(13) * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA L(1)/' DDOT '/ DATA L(2)/'DAXPY '/ DATA L(3)/'DROTG '/ DATA L(4)/' DROT '/ DATA L(5)/'DCOPY '/ DATA L(6)/'DSWAP '/ DATA L(7)/'DNRM2 '/ DATA L(8)/'DASUM '/ DATA L(9)/'DSCAL '/ DATA L(10)/'IDAMAX'/ DATA L(11)/'DROTMG'/ DATA L(12)/'DROTM '/ DATA L(13)/'DSDOT '/ * .. Executable Statements .. WRITE (NOUT,99999) ICASE, L(ICASE) RETURN * 99999 FORMAT (/' Test of subprogram number',I3,12X,A6) END SUBROUTINE CHECK0(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. DOUBLE PRECISION SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. DOUBLE PRECISION SA, SB, SC, SS, D12 INTEGER I, K * .. Local Arrays .. DOUBLE PRECISION DA1(8), DATRUE(8), DB1(8), DBTRUE(8), DC1(8), $ DS1(8), DAB(4,9), DTEMP(9), DTRUE(9,9) * .. External Subroutines .. EXTERNAL DROTG, DROTMG, STEST1 * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA DA1/0.3D0, 0.4D0, -0.3D0, -0.4D0, -0.3D0, 0.0D0, + 0.0D0, 1.0D0/ DATA DB1/0.4D0, 0.3D0, 0.4D0, 0.3D0, -0.4D0, 0.0D0, + 1.0D0, 0.0D0/ DATA DC1/0.6D0, 0.8D0, -0.6D0, 0.8D0, 0.6D0, 1.0D0, + 0.0D0, 1.0D0/ DATA DS1/0.8D0, 0.6D0, 0.8D0, -0.6D0, 0.8D0, 0.0D0, + 1.0D0, 0.0D0/ DATA DATRUE/0.5D0, 0.5D0, 0.5D0, -0.5D0, -0.5D0, + 0.0D0, 1.0D0, 1.0D0/ DATA DBTRUE/0.0D0, 0.6D0, 0.0D0, -0.6D0, 0.0D0, + 0.0D0, 1.0D0, 0.0D0/ * INPUT FOR MODIFIED GIVENS DATA DAB/ .1D0,.3D0,1.2D0,.2D0, A .7D0, .2D0, .6D0, 4.2D0, B 0.D0,0.D0,0.D0,0.D0, C 4.D0, -1.D0, 2.D0, 4.D0, D 6.D-10, 2.D-2, 1.D5, 10.D0, E 4.D10, 2.D-2, 1.D-5, 10.D0, F 2.D-10, 4.D-2, 1.D5, 10.D0, G 2.D10, 4.D-2, 1.D-5, 10.D0, H 4.D0, -2.D0, 8.D0, 4.D0 / * TRUE RESULTS FOR MODIFIED GIVENS DATA DTRUE/0.D0,0.D0, 1.3D0, .2D0, 0.D0,0.D0,0.D0, .5D0, 0.D0, A 0.D0,0.D0, 4.5D0, 4.2D0, 1.D0, .5D0, 0.D0,0.D0,0.D0, B 0.D0,0.D0,0.D0,0.D0, -2.D0, 0.D0,0.D0,0.D0,0.D0, C 0.D0,0.D0,0.D0, 4.D0, -1.D0, 0.D0,0.D0,0.D0,0.D0, D 0.D0, 15.D-3, 0.D0, 10.D0, -1.D0, 0.D0, -1.D-4, E 0.D0, 1.D0, F 0.D0,0.D0, 6144.D-5, 10.D0, -1.D0, 4096.D0, -1.D6, G 0.D0, 1.D0, H 0.D0,0.D0,15.D0,10.D0,-1.D0, 5.D-5, 0.D0,1.D0,0.D0, I 0.D0,0.D0, 15.D0, 10.D0, -1. D0, 5.D5, -4096.D0, J 1.D0, 4096.D-6, K 0.D0,0.D0, 7.D0, 4.D0, 0.D0,0.D0, -.5D0, -.25D0, 0.D0/ * 4096 = 2 ** 12 DATA D12 /4096.D0/ DTRUE(1,1) = 12.D0 / 130.D0 DTRUE(2,1) = 36.D0 / 130.D0 DTRUE(7,1) = -1.D0 / 6.D0 DTRUE(1,2) = 14.D0 / 75.D0 DTRUE(2,2) = 49.D0 / 75.D0 DTRUE(9,2) = 1.D0 / 7.D0 DTRUE(1,5) = 45.D-11 * (D12 * D12) DTRUE(3,5) = 4.D5 / (3.D0 * D12) DTRUE(6,5) = 1.D0 / D12 DTRUE(8,5) = 1.D4 / (3.D0 * D12) DTRUE(1,6) = 4.D10 / (1.5D0 * D12 * D12) DTRUE(2,6) = 2.D-2 / 1.5D0 DTRUE(8,6) = 5.D-7 * D12 DTRUE(1,7) = 4.D0 / 150.D0 DTRUE(2,7) = (2.D-10 / 1.5D0) * (D12 * D12) DTRUE(7,7) = -DTRUE(6,5) DTRUE(9,7) = 1.D4 / D12 DTRUE(1,8) = DTRUE(1,7) DTRUE(2,8) = 2.D10 / (1.5D0 * D12 * D12) DTRUE(1,9) = 32.D0 / 7.D0 DTRUE(2,9) = -16.D0 / 7.D0 * .. Executable Statements .. * * Compute true values which cannot be prestored * in decimal notation * DBTRUE(1) = 1.0D0/0.6D0 DBTRUE(3) = -1.0D0/0.6D0 DBTRUE(5) = 1.0D0/0.6D0 * DO 20 K = 1, 8 * .. Set N=K for identification in output if any .. N = K IF (ICASE.EQ.3) THEN * .. DROTG .. IF (K.GT.8) GO TO 40 SA = DA1(K) SB = DB1(K) CALL DROTG(SA,SB,SC,SS) CALL STEST1(SA,DATRUE(K),DATRUE(K),SFAC) CALL STEST1(SB,DBTRUE(K),DBTRUE(K),SFAC) CALL STEST1(SC,DC1(K),DC1(K),SFAC) CALL STEST1(SS,DS1(K),DS1(K),SFAC) ELSEIF (ICASE.EQ.11) THEN * .. DROTMG .. DO I=1,4 DTEMP(I)= DAB(I,K) DTEMP(I+4) = 0.0 END DO DTEMP(9) = 0.0 CALL DROTMG(DTEMP(1),DTEMP(2),DTEMP(3),DTEMP(4),DTEMP(5)) CALL STEST(9,DTEMP,DTRUE(1,K),DTRUE(1,K),SFAC) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK0' STOP END IF 20 CONTINUE 40 RETURN END SUBROUTINE CHECK1(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. DOUBLE PRECISION SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. INTEGER I, LEN, NP1 * .. Local Arrays .. DOUBLE PRECISION DTRUE1(5), DTRUE3(5), DTRUE5(8,5,2), DV(8,5,2), + SA(10), STEMP(1), STRUE(8), SX(8) INTEGER ITRUE2(5) * .. External Functions .. DOUBLE PRECISION DASUM, DNRM2 INTEGER IDAMAX EXTERNAL DASUM, DNRM2, IDAMAX * .. External Subroutines .. EXTERNAL ITEST1, DSCAL, STEST, STEST1 * .. Intrinsic Functions .. INTRINSIC MAX * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA SA/0.3D0, -1.0D0, 0.0D0, 1.0D0, 0.3D0, 0.3D0, + 0.3D0, 0.3D0, 0.3D0, 0.3D0/ DATA DV/0.1D0, 2.0D0, 2.0D0, 2.0D0, 2.0D0, 2.0D0, + 2.0D0, 2.0D0, 0.3D0, 3.0D0, 3.0D0, 3.0D0, 3.0D0, + 3.0D0, 3.0D0, 3.0D0, 0.3D0, -0.4D0, 4.0D0, + 4.0D0, 4.0D0, 4.0D0, 4.0D0, 4.0D0, 0.2D0, + -0.6D0, 0.3D0, 5.0D0, 5.0D0, 5.0D0, 5.0D0, + 5.0D0, 0.1D0, -0.3D0, 0.5D0, -0.1D0, 6.0D0, + 6.0D0, 6.0D0, 6.0D0, 0.1D0, 8.0D0, 8.0D0, 8.0D0, + 8.0D0, 8.0D0, 8.0D0, 8.0D0, 0.3D0, 9.0D0, 9.0D0, + 9.0D0, 9.0D0, 9.0D0, 9.0D0, 9.0D0, 0.3D0, 2.0D0, + -0.4D0, 2.0D0, 2.0D0, 2.0D0, 2.0D0, 2.0D0, + 0.2D0, 3.0D0, -0.6D0, 5.0D0, 0.3D0, 2.0D0, + 2.0D0, 2.0D0, 0.1D0, 4.0D0, -0.3D0, 6.0D0, + -0.5D0, 7.0D0, -0.1D0, 3.0D0/ DATA DTRUE1/0.0D0, 0.3D0, 0.5D0, 0.7D0, 0.6D0/ DATA DTRUE3/0.0D0, 0.3D0, 0.7D0, 1.1D0, 1.0D0/ DATA DTRUE5/0.10D0, 2.0D0, 2.0D0, 2.0D0, 2.0D0, + 2.0D0, 2.0D0, 2.0D0, -0.3D0, 3.0D0, 3.0D0, + 3.0D0, 3.0D0, 3.0D0, 3.0D0, 3.0D0, 0.0D0, 0.0D0, + 4.0D0, 4.0D0, 4.0D0, 4.0D0, 4.0D0, 4.0D0, + 0.20D0, -0.60D0, 0.30D0, 5.0D0, 5.0D0, 5.0D0, + 5.0D0, 5.0D0, 0.03D0, -0.09D0, 0.15D0, -0.03D0, + 6.0D0, 6.0D0, 6.0D0, 6.0D0, 0.10D0, 8.0D0, + 8.0D0, 8.0D0, 8.0D0, 8.0D0, 8.0D0, 8.0D0, + 0.09D0, 9.0D0, 9.0D0, 9.0D0, 9.0D0, 9.0D0, + 9.0D0, 9.0D0, 0.09D0, 2.0D0, -0.12D0, 2.0D0, + 2.0D0, 2.0D0, 2.0D0, 2.0D0, 0.06D0, 3.0D0, + -0.18D0, 5.0D0, 0.09D0, 2.0D0, 2.0D0, 2.0D0, + 0.03D0, 4.0D0, -0.09D0, 6.0D0, -0.15D0, 7.0D0, + -0.03D0, 3.0D0/ DATA ITRUE2/0, 1, 2, 2, 3/ * .. Executable Statements .. DO 80 INCX = 1, 2 DO 60 NP1 = 1, 5 N = NP1 - 1 LEN = 2*MAX(N,1) * .. Set vector arguments .. DO 20 I = 1, LEN SX(I) = DV(I,NP1,INCX) 20 CONTINUE * IF (ICASE.EQ.7) THEN * .. DNRM2 .. STEMP(1) = DTRUE1(NP1) CALL STEST1(DNRM2(N,SX,INCX),STEMP(1),STEMP,SFAC) ELSE IF (ICASE.EQ.8) THEN * .. DASUM .. STEMP(1) = DTRUE3(NP1) CALL STEST1(DASUM(N,SX,INCX),STEMP(1),STEMP,SFAC) ELSE IF (ICASE.EQ.9) THEN * .. DSCAL .. CALL DSCAL(N,SA((INCX-1)*5+NP1),SX,INCX) DO 40 I = 1, LEN STRUE(I) = DTRUE5(I,NP1,INCX) 40 CONTINUE CALL STEST(LEN,SX,STRUE,STRUE,SFAC) ELSE IF (ICASE.EQ.10) THEN * .. IDAMAX .. CALL ITEST1(IDAMAX(N,SX,INCX),ITRUE2(NP1)) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK1' STOP END IF 60 CONTINUE 80 CONTINUE RETURN END SUBROUTINE CHECK2(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. DOUBLE PRECISION SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. DOUBLE PRECISION SA INTEGER I, J, KI, KN, KNI, KPAR, KSIZE, LENX, LENY, $ MX, MY * .. Local Arrays .. DOUBLE PRECISION DT10X(7,4,4), DT10Y(7,4,4), DT7(4,4), $ DT8(7,4,4), DX1(7), $ DY1(7), SSIZE1(4), SSIZE2(14,2), SSIZE(7), $ STX(7), STY(7), SX(7), SY(7), $ DPAR(5,4), DT19X(7,4,16),DT19XA(7,4,4), $ DT19XB(7,4,4), DT19XC(7,4,4),DT19XD(7,4,4), $ DT19Y(7,4,16), DT19YA(7,4,4),DT19YB(7,4,4), $ DT19YC(7,4,4), DT19YD(7,4,4), DTEMP(5) INTEGER INCXS(4), INCYS(4), LENS(4,2), NS(4) * .. External Functions .. DOUBLE PRECISION DDOT, DSDOT EXTERNAL DDOT, DSDOT * .. External Subroutines .. EXTERNAL DAXPY, DCOPY, DROTM, DSWAP, STEST, STEST1 * .. Intrinsic Functions .. INTRINSIC ABS, MIN * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. EQUIVALENCE (DT19X(1,1,1),DT19XA(1,1,1)),(DT19X(1,1,5), A DT19XB(1,1,1)),(DT19X(1,1,9),DT19XC(1,1,1)), B (DT19X(1,1,13),DT19XD(1,1,1)) EQUIVALENCE (DT19Y(1,1,1),DT19YA(1,1,1)),(DT19Y(1,1,5), A DT19YB(1,1,1)),(DT19Y(1,1,9),DT19YC(1,1,1)), B (DT19Y(1,1,13),DT19YD(1,1,1)) DATA SA/0.3D0/ DATA INCXS/1, 2, -2, -1/ DATA INCYS/1, -2, 1, -2/ DATA LENS/1, 1, 2, 4, 1, 1, 3, 7/ DATA NS/0, 1, 2, 4/ DATA DX1/0.6D0, 0.1D0, -0.5D0, 0.8D0, 0.9D0, -0.3D0, + -0.4D0/ DATA DY1/0.5D0, -0.9D0, 0.3D0, 0.7D0, -0.6D0, 0.2D0, + 0.8D0/ DATA DT7/0.0D0, 0.30D0, 0.21D0, 0.62D0, 0.0D0, + 0.30D0, -0.07D0, 0.85D0, 0.0D0, 0.30D0, -0.79D0, + -0.74D0, 0.0D0, 0.30D0, 0.33D0, 1.27D0/ DATA DT8/0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.68D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.68D0, -0.87D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.68D0, -0.87D0, 0.15D0, + 0.94D0, 0.0D0, 0.0D0, 0.0D0, 0.5D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.68D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.35D0, -0.9D0, 0.48D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.38D0, -0.9D0, 0.57D0, 0.7D0, -0.75D0, + 0.2D0, 0.98D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.68D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.35D0, -0.72D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.38D0, + -0.63D0, 0.15D0, 0.88D0, 0.0D0, 0.0D0, 0.0D0, + 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.68D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.68D0, -0.9D0, 0.33D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.68D0, -0.9D0, 0.33D0, 0.7D0, + -0.75D0, 0.2D0, 1.04D0/ DATA DT10X/0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.5D0, -0.9D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.5D0, -0.9D0, 0.3D0, 0.7D0, + 0.0D0, 0.0D0, 0.0D0, 0.6D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.3D0, 0.1D0, 0.5D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.8D0, 0.1D0, -0.6D0, + 0.8D0, 0.3D0, -0.3D0, 0.5D0, 0.6D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.5D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, -0.9D0, + 0.1D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.7D0, + 0.1D0, 0.3D0, 0.8D0, -0.9D0, -0.3D0, 0.5D0, + 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.5D0, 0.3D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.5D0, 0.3D0, -0.6D0, 0.8D0, 0.0D0, 0.0D0, + 0.0D0/ DATA DT10Y/0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.6D0, 0.1D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.6D0, 0.1D0, -0.5D0, 0.8D0, 0.0D0, + 0.0D0, 0.0D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, -0.5D0, -0.9D0, 0.6D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, -0.4D0, -0.9D0, 0.9D0, + 0.7D0, -0.5D0, 0.2D0, 0.6D0, 0.5D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.6D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, -0.5D0, + 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + -0.4D0, 0.9D0, -0.5D0, 0.6D0, 0.0D0, 0.0D0, + 0.0D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.6D0, -0.9D0, 0.1D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.6D0, -0.9D0, 0.1D0, 0.7D0, + -0.5D0, 0.2D0, 0.8D0/ DATA SSIZE1/0.0D0, 0.3D0, 1.6D0, 3.2D0/ DATA SSIZE2/0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, + 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, + 1.17D0, 1.17D0, 1.17D0/ * * FOR DROTM * DATA DPAR/-2.D0, 0.D0,0.D0,0.D0,0.D0, A -1.D0, 2.D0, -3.D0, -4.D0, 5.D0, B 0.D0, 0.D0, 2.D0, -3.D0, 0.D0, C 1.D0, 5.D0, 2.D0, 0.D0, -4.D0/ * TRUE X RESULTS F0R ROTATIONS DROTM DATA DT19XA/.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E -.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G 3.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .6D0, .1D0, 0.D0,0.D0,0.D0,0.D0,0.D0, I -.8D0, 3.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0, J -.9D0, 2.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0, K 3.5D0, -.4D0, 0.D0,0.D0,0.D0,0.D0,0.D0, L .6D0, .1D0, -.5D0, .8D0, 0.D0,0.D0,0.D0, M -.8D0, 3.8D0, -2.2D0, -1.2D0, 0.D0,0.D0,0.D0, N -.9D0, 2.8D0, -1.4D0, -1.3D0, 0.D0,0.D0,0.D0, O 3.5D0, -.4D0, -2.2D0, 4.7D0, 0.D0,0.D0,0.D0/ * DATA DT19XB/.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E -.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G 3.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .6D0, .1D0, -.5D0, 0.D0,0.D0,0.D0,0.D0, I 0.D0, .1D0, -3.0D0, 0.D0,0.D0,0.D0,0.D0, J -.3D0, .1D0, -2.0D0, 0.D0,0.D0,0.D0,0.D0, K 3.3D0, .1D0, -2.0D0, 0.D0,0.D0,0.D0,0.D0, L .6D0, .1D0, -.5D0, .8D0, .9D0, -.3D0, -.4D0, M -2.0D0, .1D0, 1.4D0, .8D0, .6D0, -.3D0, -2.8D0, N -1.8D0, .1D0, 1.3D0, .8D0, 0.D0, -.3D0, -1.9D0, O 3.8D0, .1D0, -3.1D0, .8D0, 4.8D0, -.3D0, -1.5D0 / * DATA DT19XC/.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E -.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G 3.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .6D0, .1D0, -.5D0, 0.D0,0.D0,0.D0,0.D0, I 4.8D0, .1D0, -3.0D0, 0.D0,0.D0,0.D0,0.D0, J 3.3D0, .1D0, -2.0D0, 0.D0,0.D0,0.D0,0.D0, K 2.1D0, .1D0, -2.0D0, 0.D0,0.D0,0.D0,0.D0, L .6D0, .1D0, -.5D0, .8D0, .9D0, -.3D0, -.4D0, M -1.6D0, .1D0, -2.2D0, .8D0, 5.4D0, -.3D0, -2.8D0, N -1.5D0, .1D0, -1.4D0, .8D0, 3.6D0, -.3D0, -1.9D0, O 3.7D0, .1D0, -2.2D0, .8D0, 3.6D0, -.3D0, -1.5D0 / * DATA DT19XD/.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E -.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G 3.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .6D0, .1D0, 0.D0,0.D0,0.D0,0.D0,0.D0, I -.8D0, -1.0D0, 0.D0,0.D0,0.D0,0.D0,0.D0, J -.9D0, -.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0, K 3.5D0, .8D0, 0.D0,0.D0,0.D0,0.D0,0.D0, L .6D0, .1D0, -.5D0, .8D0, 0.D0,0.D0,0.D0, M -.8D0, -1.0D0, 1.4D0, -1.6D0, 0.D0,0.D0,0.D0, N -.9D0, -.8D0, 1.3D0, -1.6D0, 0.D0,0.D0,0.D0, O 3.5D0, .8D0, -3.1D0, 4.8D0, 0.D0,0.D0,0.D0/ * TRUE Y RESULTS FOR ROTATIONS DROTM DATA DT19YA/.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E .7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F 1.7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G -2.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .5D0, -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0, I .7D0, -4.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0, J 1.7D0, -.7D0, 0.D0,0.D0,0.D0,0.D0,0.D0, K -2.6D0, 3.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0, L .5D0, -.9D0, .3D0, .7D0, 0.D0,0.D0,0.D0, M .7D0, -4.8D0, 3.0D0, 1.1D0, 0.D0,0.D0,0.D0, N 1.7D0, -.7D0, -.7D0, 2.3D0, 0.D0,0.D0,0.D0, O -2.6D0, 3.5D0, -.7D0, -3.6D0, 0.D0,0.D0,0.D0/ * DATA DT19YB/.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E .7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F 1.7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G -2.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .5D0, -.9D0, .3D0, 0.D0,0.D0,0.D0,0.D0, I 4.0D0, -.9D0, -.3D0, 0.D0,0.D0,0.D0,0.D0, J -.5D0, -.9D0, 1.5D0, 0.D0,0.D0,0.D0,0.D0, K -1.5D0, -.9D0, -1.8D0, 0.D0,0.D0,0.D0,0.D0, L .5D0, -.9D0, .3D0, .7D0, -.6D0, .2D0, .8D0, M 3.7D0, -.9D0, -1.2D0, .7D0, -1.5D0, .2D0, 2.2D0, N -.3D0, -.9D0, 2.1D0, .7D0, -1.6D0, .2D0, 2.0D0, O -1.6D0, -.9D0, -2.1D0, .7D0, 2.9D0, .2D0, -3.8D0 / * DATA DT19YC/.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E .7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F 1.7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G -2.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .5D0, -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0, I 4.0D0, -6.3D0, 0.D0,0.D0,0.D0,0.D0,0.D0, J -.5D0, .3D0, 0.D0,0.D0,0.D0,0.D0,0.D0, K -1.5D0, 3.0D0, 0.D0,0.D0,0.D0,0.D0,0.D0, L .5D0, -.9D0, .3D0, .7D0, 0.D0,0.D0,0.D0, M 3.7D0, -7.2D0, 3.0D0, 1.7D0, 0.D0,0.D0,0.D0, N -.3D0, .9D0, -.7D0, 1.9D0, 0.D0,0.D0,0.D0, O -1.6D0, 2.7D0, -.7D0, -3.4D0, 0.D0,0.D0,0.D0/ * DATA DT19YD/.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E .7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F 1.7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G -2.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .5D0, -.9D0, .3D0, 0.D0,0.D0,0.D0,0.D0, I .7D0, -.9D0, 1.2D0, 0.D0,0.D0,0.D0,0.D0, J 1.7D0, -.9D0, .5D0, 0.D0,0.D0,0.D0,0.D0, K -2.6D0, -.9D0, -1.3D0, 0.D0,0.D0,0.D0,0.D0, L .5D0, -.9D0, .3D0, .7D0, -.6D0, .2D0, .8D0, M .7D0, -.9D0, 1.2D0, .7D0, -1.5D0, .2D0, 1.6D0, N 1.7D0, -.9D0, .5D0, .7D0, -1.6D0, .2D0, 2.4D0, O -2.6D0, -.9D0, -1.3D0, .7D0, 2.9D0, .2D0, -4.0D0 / * * .. Executable Statements .. * DO 120 KI = 1, 4 INCX = INCXS(KI) INCY = INCYS(KI) MX = ABS(INCX) MY = ABS(INCY) * DO 100 KN = 1, 4 N = NS(KN) KSIZE = MIN(2,KN) LENX = LENS(KN,MX) LENY = LENS(KN,MY) * .. Initialize all argument arrays .. DO 20 I = 1, 7 SX(I) = DX1(I) SY(I) = DY1(I) 20 CONTINUE * IF (ICASE.EQ.1) THEN * .. DDOT .. CALL STEST1(DDOT(N,SX,INCX,SY,INCY),DT7(KN,KI),SSIZE1(KN) + ,SFAC) ELSE IF (ICASE.EQ.2) THEN * .. DAXPY .. CALL DAXPY(N,SA,SX,INCX,SY,INCY) DO 40 J = 1, LENY STY(J) = DT8(J,KN,KI) 40 CONTINUE CALL STEST(LENY,SY,STY,SSIZE2(1,KSIZE),SFAC) ELSE IF (ICASE.EQ.5) THEN * .. DCOPY .. DO 60 I = 1, 7 STY(I) = DT10Y(I,KN,KI) 60 CONTINUE CALL DCOPY(N,SX,INCX,SY,INCY) CALL STEST(LENY,SY,STY,SSIZE2(1,1),1.0D0) ELSE IF (ICASE.EQ.6) THEN * .. DSWAP .. CALL DSWAP(N,SX,INCX,SY,INCY) DO 80 I = 1, 7 STX(I) = DT10X(I,KN,KI) STY(I) = DT10Y(I,KN,KI) 80 CONTINUE CALL STEST(LENX,SX,STX,SSIZE2(1,1),1.0D0) CALL STEST(LENY,SY,STY,SSIZE2(1,1),1.0D0) ELSE IF (ICASE.EQ.12) THEN * .. DROTM .. KNI=KN+4*(KI-1) DO KPAR=1,4 DO I=1,7 SX(I) = DX1(I) SY(I) = DY1(I) STX(I)= DT19X(I,KPAR,KNI) STY(I)= DT19Y(I,KPAR,KNI) END DO * DO I=1,5 DTEMP(I) = DPAR(I,KPAR) END DO * DO I=1,LENX SSIZE(I)=STX(I) END DO * SEE REMARK ABOVE ABOUT DT11X(1,2,7) * AND DT11X(5,3,8). IF ((KPAR .EQ. 2) .AND. (KNI .EQ. 7)) $ SSIZE(1) = 2.4D0 IF ((KPAR .EQ. 3) .AND. (KNI .EQ. 8)) $ SSIZE(5) = 1.8D0 * CALL DROTM(N,SX,INCX,SY,INCY,DTEMP) CALL STEST(LENX,SX,STX,SSIZE,SFAC) CALL STEST(LENY,SY,STY,STY,SFAC) END DO ELSE IF (ICASE.EQ.13) THEN * .. DSDOT .. CALL TESTDSDOT(REAL(DSDOT(N,REAL(SX),INCX,REAL(SY),INCY)), $ REAL(DT7(KN,KI)),REAL(SSIZE1(KN)), .3125E-1) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK2' STOP END IF 100 CONTINUE 120 CONTINUE RETURN END SUBROUTINE CHECK3(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. DOUBLE PRECISION SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. DOUBLE PRECISION SC, SS INTEGER I, K, KI, KN, KSIZE, LENX, LENY, MX, MY * .. Local Arrays .. DOUBLE PRECISION COPYX(5), COPYY(5), DT9X(7,4,4), DT9Y(7,4,4), + DX1(7), DY1(7), MWPC(11), MWPS(11), MWPSTX(5), + MWPSTY(5), MWPTX(11,5), MWPTY(11,5), MWPX(5), + MWPY(5), SSIZE2(14,2), STX(7), STY(7), SX(7), + SY(7) INTEGER INCXS(4), INCYS(4), LENS(4,2), MWPINX(11), + MWPINY(11), MWPN(11), NS(4) * .. External Subroutines .. EXTERNAL DROT, STEST * .. Intrinsic Functions .. INTRINSIC ABS, MIN * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA INCXS/1, 2, -2, -1/ DATA INCYS/1, -2, 1, -2/ DATA LENS/1, 1, 2, 4, 1, 1, 3, 7/ DATA NS/0, 1, 2, 4/ DATA DX1/0.6D0, 0.1D0, -0.5D0, 0.8D0, 0.9D0, -0.3D0, + -0.4D0/ DATA DY1/0.5D0, -0.9D0, 0.3D0, 0.7D0, -0.6D0, 0.2D0, + 0.8D0/ DATA SC, SS/0.8D0, 0.6D0/ DATA DT9X/0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.78D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.78D0, -0.46D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.78D0, -0.46D0, -0.22D0, + 1.06D0, 0.0D0, 0.0D0, 0.0D0, 0.6D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.78D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.66D0, 0.1D0, -0.1D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.96D0, 0.1D0, -0.76D0, 0.8D0, 0.90D0, + -0.3D0, -0.02D0, 0.6D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.78D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, -0.06D0, 0.1D0, + -0.1D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.90D0, + 0.1D0, -0.22D0, 0.8D0, 0.18D0, -0.3D0, -0.02D0, + 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.78D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.78D0, 0.26D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.78D0, 0.26D0, -0.76D0, 1.12D0, + 0.0D0, 0.0D0, 0.0D0/ DATA DT9Y/0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.04D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.04D0, -0.78D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.04D0, -0.78D0, 0.54D0, + 0.08D0, 0.0D0, 0.0D0, 0.0D0, 0.5D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.04D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.7D0, + -0.9D0, -0.12D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.64D0, -0.9D0, -0.30D0, 0.7D0, -0.18D0, 0.2D0, + 0.28D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.04D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.7D0, -1.08D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.64D0, -1.26D0, + 0.54D0, 0.20D0, 0.0D0, 0.0D0, 0.0D0, 0.5D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.04D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.04D0, -0.9D0, 0.18D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.04D0, -0.9D0, 0.18D0, 0.7D0, + -0.18D0, 0.2D0, 0.16D0/ DATA SSIZE2/0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, + 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, + 1.17D0, 1.17D0, 1.17D0/ * .. Executable Statements .. * DO 60 KI = 1, 4 INCX = INCXS(KI) INCY = INCYS(KI) MX = ABS(INCX) MY = ABS(INCY) * DO 40 KN = 1, 4 N = NS(KN) KSIZE = MIN(2,KN) LENX = LENS(KN,MX) LENY = LENS(KN,MY) * IF (ICASE.EQ.4) THEN * .. DROT .. DO 20 I = 1, 7 SX(I) = DX1(I) SY(I) = DY1(I) STX(I) = DT9X(I,KN,KI) STY(I) = DT9Y(I,KN,KI) 20 CONTINUE CALL DROT(N,SX,INCX,SY,INCY,SC,SS) CALL STEST(LENX,SX,STX,SSIZE2(1,KSIZE),SFAC) CALL STEST(LENY,SY,STY,SSIZE2(1,KSIZE),SFAC) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK3' STOP END IF 40 CONTINUE 60 CONTINUE * MWPC(1) = 1 DO 80 I = 2, 11 MWPC(I) = 0 80 CONTINUE MWPS(1) = 0 DO 100 I = 2, 6 MWPS(I) = 1 100 CONTINUE DO 120 I = 7, 11 MWPS(I) = -1 120 CONTINUE MWPINX(1) = 1 MWPINX(2) = 1 MWPINX(3) = 1 MWPINX(4) = -1 MWPINX(5) = 1 MWPINX(6) = -1 MWPINX(7) = 1 MWPINX(8) = 1 MWPINX(9) = -1 MWPINX(10) = 1 MWPINX(11) = -1 MWPINY(1) = 1 MWPINY(2) = 1 MWPINY(3) = -1 MWPINY(4) = -1 MWPINY(5) = 2 MWPINY(6) = 1 MWPINY(7) = 1 MWPINY(8) = -1 MWPINY(9) = -1 MWPINY(10) = 2 MWPINY(11) = 1 DO 140 I = 1, 11 MWPN(I) = 5 140 CONTINUE MWPN(5) = 3 MWPN(10) = 3 DO 160 I = 1, 5 MWPX(I) = I MWPY(I) = I MWPTX(1,I) = I MWPTY(1,I) = I MWPTX(2,I) = I MWPTY(2,I) = -I MWPTX(3,I) = 6 - I MWPTY(3,I) = I - 6 MWPTX(4,I) = I MWPTY(4,I) = -I MWPTX(6,I) = 6 - I MWPTY(6,I) = I - 6 MWPTX(7,I) = -I MWPTY(7,I) = I MWPTX(8,I) = I - 6 MWPTY(8,I) = 6 - I MWPTX(9,I) = -I MWPTY(9,I) = I MWPTX(11,I) = I - 6 MWPTY(11,I) = 6 - I 160 CONTINUE MWPTX(5,1) = 1 MWPTX(5,2) = 3 MWPTX(5,3) = 5 MWPTX(5,4) = 4 MWPTX(5,5) = 5 MWPTY(5,1) = -1 MWPTY(5,2) = 2 MWPTY(5,3) = -2 MWPTY(5,4) = 4 MWPTY(5,5) = -3 MWPTX(10,1) = -1 MWPTX(10,2) = -3 MWPTX(10,3) = -5 MWPTX(10,4) = 4 MWPTX(10,5) = 5 MWPTY(10,1) = 1 MWPTY(10,2) = 2 MWPTY(10,3) = 2 MWPTY(10,4) = 4 MWPTY(10,5) = 3 DO 200 I = 1, 11 INCX = MWPINX(I) INCY = MWPINY(I) DO 180 K = 1, 5 COPYX(K) = MWPX(K) COPYY(K) = MWPY(K) MWPSTX(K) = MWPTX(I,K) MWPSTY(K) = MWPTY(I,K) 180 CONTINUE CALL DROT(MWPN(I),COPYX,INCX,COPYY,INCY,MWPC(I),MWPS(I)) CALL STEST(5,COPYX,MWPSTX,MWPSTX,SFAC) CALL STEST(5,COPYY,MWPSTY,MWPSTY,SFAC) 200 CONTINUE RETURN END SUBROUTINE STEST(LEN,SCOMP,STRUE,SSIZE,SFAC) * ********************************* STEST ************************** * * THIS SUBR COMPARES ARRAYS SCOMP() AND STRUE() OF LENGTH LEN TO * SEE IF THE TERM BY TERM DIFFERENCES, MULTIPLIED BY SFAC, ARE * NEGLIGIBLE. * * C. L. LAWSON, JPL, 1974 DEC 10 * * .. Parameters .. INTEGER NOUT DOUBLE PRECISION ZERO PARAMETER (NOUT=6, ZERO=0.0D0) * .. Scalar Arguments .. DOUBLE PRECISION SFAC INTEGER LEN * .. Array Arguments .. DOUBLE PRECISION SCOMP(LEN), SSIZE(LEN), STRUE(LEN) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. DOUBLE PRECISION SD INTEGER I * .. External Functions .. DOUBLE PRECISION SDIFF EXTERNAL SDIFF * .. Intrinsic Functions .. INTRINSIC ABS * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Executable Statements .. * DO 40 I = 1, LEN SD = SCOMP(I) - STRUE(I) IF (ABS(SFAC*SD) .LE. ABS(SSIZE(I))*EPSILON(ZERO)) + GO TO 40 * * HERE SCOMP(I) IS NOT CLOSE TO STRUE(I). * IF ( .NOT. PASS) GO TO 20 * PRINT FAIL MESSAGE AND HEADER. PASS = .FALSE. WRITE (NOUT,99999) WRITE (NOUT,99998) 20 WRITE (NOUT,99997) ICASE, N, INCX, INCY, I, SCOMP(I), + STRUE(I), SD, SSIZE(I) 40 CONTINUE RETURN * 99999 FORMAT (' FAIL') 99998 FORMAT (/' CASE N INCX INCY I ', + ' COMP(I) TRUE(I) DIFFERENCE', + ' SIZE(I)',/1X) 99997 FORMAT (1X,I4,I3,2I5,I3,2D36.8,2D12.4) END SUBROUTINE TESTDSDOT(SCOMP,STRUE,SSIZE,SFAC) * ********************************* STEST ************************** * * THIS SUBR COMPARES ARRAYS SCOMP() AND STRUE() OF LENGTH LEN TO * SEE IF THE TERM BY TERM DIFFERENCES, MULTIPLIED BY SFAC, ARE * NEGLIGIBLE. * * C. L. LAWSON, JPL, 1974 DEC 10 * * .. Parameters .. INTEGER NOUT REAL ZERO PARAMETER (NOUT=6, ZERO=0.0E0) * .. Scalar Arguments .. REAL SFAC, SCOMP, SSIZE, STRUE * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. REAL SD * .. Intrinsic Functions .. INTRINSIC ABS * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Executable Statements .. * SD = SCOMP - STRUE IF (ABS(SFAC*SD) .LE. ABS(SSIZE) * EPSILON(ZERO)) + GO TO 40 * * HERE SCOMP(I) IS NOT CLOSE TO STRUE(I). * IF ( .NOT. PASS) GO TO 20 * PRINT FAIL MESSAGE AND HEADER. PASS = .FALSE. WRITE (NOUT,99999) WRITE (NOUT,99998) 20 WRITE (NOUT,99997) ICASE, N, INCX, INCY, SCOMP, + STRUE, SD, SSIZE 40 CONTINUE RETURN * 99999 FORMAT (' FAIL') 99998 FORMAT (/' CASE N INCX INCY ', + ' COMP(I) TRUE(I) DIFFERENCE', + ' SIZE(I)',/1X) 99997 FORMAT (1X,I4,I3,1I5,I3,2E36.8,2E12.4) END SUBROUTINE STEST1(SCOMP1,STRUE1,SSIZE,SFAC) * ************************* STEST1 ***************************** * * THIS IS AN INTERFACE SUBROUTINE TO ACCOMODATE THE FORTRAN * REQUIREMENT THAT WHEN A DUMMY ARGUMENT IS AN ARRAY, THE * ACTUAL ARGUMENT MUST ALSO BE AN ARRAY OR AN ARRAY ELEMENT. * * C.L. LAWSON, JPL, 1978 DEC 6 * * .. Scalar Arguments .. DOUBLE PRECISION SCOMP1, SFAC, STRUE1 * .. Array Arguments .. DOUBLE PRECISION SSIZE(*) * .. Local Arrays .. DOUBLE PRECISION SCOMP(1), STRUE(1) * .. External Subroutines .. EXTERNAL STEST * .. Executable Statements .. * SCOMP(1) = SCOMP1 STRUE(1) = STRUE1 CALL STEST(1,SCOMP,STRUE,SSIZE,SFAC) * RETURN END DOUBLE PRECISION FUNCTION SDIFF(SA,SB) * ********************************* SDIFF ************************** * COMPUTES DIFFERENCE OF TWO NUMBERS. C. L. LAWSON, JPL 1974 FEB 15 * * .. Scalar Arguments .. DOUBLE PRECISION SA, SB * .. Executable Statements .. SDIFF = SA - SB RETURN END SUBROUTINE ITEST1(ICOMP,ITRUE) * ********************************* ITEST1 ************************* * * THIS SUBROUTINE COMPARES THE VARIABLES ICOMP AND ITRUE FOR * EQUALITY. * C. L. LAWSON, JPL, 1974 DEC 10 * * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. INTEGER ICOMP, ITRUE * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. INTEGER ID * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Executable Statements .. * IF (ICOMP.EQ.ITRUE) GO TO 40 * * HERE ICOMP IS NOT EQUAL TO ITRUE. * IF ( .NOT. PASS) GO TO 20 * PRINT FAIL MESSAGE AND HEADER. PASS = .FALSE. WRITE (NOUT,99999) WRITE (NOUT,99998) 20 ID = ICOMP - ITRUE WRITE (NOUT,99997) ICASE, N, INCX, INCY, ICOMP, ITRUE, ID 40 CONTINUE RETURN * 99999 FORMAT (' FAIL') 99998 FORMAT (/' CASE N INCX INCY ', + ' COMP TRUE DIFFERENCE', + /1X) 99997 FORMAT (1X,I4,I3,2I5,2I36,I12) END
bsd-2-clause
vigna/scipy
scipy/linalg/src/id_dist/src/idz_snorm.f
139
12408
c this file contains the following user-callable routines: c c c routine idz_snorm estimates the spectral norm c of a matrix specified by routines for applying the matrix c and its adjoint to arbitrary vectors. This routine uses c the power method with a random starting vector. c c routine idz_diffsnorm estimates the spectral norm c of the difference between two matrices specified by routines c for applying the matrices and their adjoints c to arbitrary vectors. This routine uses c the power method with a random starting vector. c c routine idz_enorm calculates the Euclidean norm of a vector. c c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c c c subroutine idz_snorm(m,n,matveca,p1a,p2a,p3a,p4a, 1 matvec,p1,p2,p3,p4,its,snorm,v,u) c c estimates the spectral norm of a matrix a specified c by a routine matvec for applying a to an arbitrary vector, c and by a routine matveca for applying a^* c to an arbitrary vector. This routine uses the power method c with a random starting vector. c c input: c m -- number of rows in a c n -- number of columns in a c matveca -- routine which applies the adjoint of a c to an arbitrary vector; this routine must have c a calling sequence of the form c c matveca(m,x,n,y,p1a,p2a,p3a,p4a), c c where m is the length of x, c x is the vector to which the adjoint of a c is to be applied, c n is the length of y, c y is the product of the adjoint of a and x, c and p1a, p2a, p3a, and p4a are user-specified c parameters c p1a -- parameter to be passed to routine matveca c p2a -- parameter to be passed to routine matveca c p3a -- parameter to be passed to routine matveca c p4a -- parameter to be passed to routine matveca c matvec -- routine which applies the matrix a c to an arbitrary vector; this routine must have c a calling sequence of the form c c matvec(n,x,m,y,p1,p2,p3,p4), c c where n is the length of x, c x is the vector to which a is to be applied, c m is the length of y, c y is the product of a and x, c and p1, p2, p3, and p4 are user-specified parameters c p1 -- parameter to be passed to routine matvec c p2 -- parameter to be passed to routine matvec c p3 -- parameter to be passed to routine matvec c p4 -- parameter to be passed to routine matvec c its -- number of iterations of the power method to conduct c c output: c snorm -- estimate of the spectral norm of a c v -- estimate of a normalized right singular vector c corresponding to the greatest singular value of a c c work: c u -- must be at least m complex*16 elements long c c reference: c Kuczynski and Wozniakowski, "Estimating the largest eigenvalue c by the power and Lanczos algorithms with a random start," c SIAM Journal on Matrix Analysis and Applications, c 13 (4): 1992, 1094-1122. c implicit none integer m,n,its,it,n2,k real*8 snorm,enorm complex*16 p1a,p2a,p3a,p4a,p1,p2,p3,p4,u(m),v(n) external matveca,matvec c c c Fill the real and imaginary parts of each entry c of the initial vector v with i.i.d. random variables c drawn uniformly from [-1,1]. c n2 = 2*n call id_srand(n2,v) c do k = 1,n v(k) = 2*v(k)-1 enddo ! k c c c Normalize v. c call idz_enorm(n,v,enorm) c do k = 1,n v(k) = v(k)/enorm enddo ! k c c do it = 1,its c c Apply a to v, obtaining u. c call matvec(n,v,m,u,p1,p2,p3,p4) c c Apply a^* to u, obtaining v. c call matveca(m,u,n,v,p1a,p2a,p3a,p4a) c c Normalize v. c call idz_enorm(n,v,snorm) c if(snorm .ne. 0) then c do k = 1,n v(k) = v(k)/snorm enddo ! k c endif c snorm = sqrt(snorm) c enddo ! it c c return end c c c c subroutine idz_enorm(n,v,enorm) c c computes the Euclidean norm of v, the square root c of the sum of the squares of the absolute values c of the entries of v. c c input: c n -- length of v c v -- vector whose Euclidean norm is to be calculated c c output: c enorm -- Euclidean norm of v c implicit none integer n,k real*8 enorm complex*16 v(n) c c enorm = 0 c do k = 1,n enorm = enorm+v(k)*conjg(v(k)) enddo ! k c enorm = sqrt(enorm) c c return end c c c c subroutine idz_diffsnorm(m,n,matveca,p1a,p2a,p3a,p4a, 1 matveca2,p1a2,p2a2,p3a2,p4a2, 2 matvec,p1,p2,p3,p4, 3 matvec2,p12,p22,p32,p42,its,snorm,w) c c estimates the spectral norm of the difference between matrices c a and a2, where a is specified by routines matvec and matveca c for applying a and a^* to arbitrary vectors, c and a2 is specified by routines matvec2 and matveca2 c for applying a2 and (a2)^* to arbitrary vectors. c This routine uses the power method c with a random starting vector. c c input: c m -- number of rows in a, as well as the number of rows in a2 c n -- number of columns in a, as well as the number of columns c in a2 c matveca -- routine which applies the adjoint of a c to an arbitrary vector; this routine must have c a calling sequence of the form c c matveca(m,x,n,y,p1a,p2a,p3a,p4a), c c where m is the length of x, c x is the vector to which the adjoint of a c is to be applied, c n is the length of y, c y is the product of the adjoint of a and x, c and p1a, p2a, p3a, and p4a are user-specified c parameters c p1a -- parameter to be passed to routine matveca c p2a -- parameter to be passed to routine matveca c p3a -- parameter to be passed to routine matveca c p4a -- parameter to be passed to routine matveca c matveca2 -- routine which applies the adjoint of a2 c to an arbitrary vector; this routine must have c a calling sequence of the form c c matveca2(m,x,n,y,p1a2,p2a2,p3a2,p4a2), c c where m is the length of x, c x is the vector to which the adjoint of a2 c is to be applied, c n is the length of y, c y is the product of the adjoint of a2 and x, c and p1a2, p2a2, p3a2, and p4a2 are user-specified c parameters c p1a2 -- parameter to be passed to routine matveca2 c p2a2 -- parameter to be passed to routine matveca2 c p3a2 -- parameter to be passed to routine matveca2 c p4a2 -- parameter to be passed to routine matveca2 c matvec -- routine which applies the matrix a c to an arbitrary vector; this routine must have c a calling sequence of the form c c matvec(n,x,m,y,p1,p2,p3,p4), c c where n is the length of x, c x is the vector to which a is to be applied, c m is the length of y, c y is the product of a and x, c and p1, p2, p3, and p4 are user-specified parameters c p1 -- parameter to be passed to routine matvec c p2 -- parameter to be passed to routine matvec c p3 -- parameter to be passed to routine matvec c p4 -- parameter to be passed to routine matvec c matvec2 -- routine which applies the matrix a2 c to an arbitrary vector; this routine must have c a calling sequence of the form c c matvec2(n,x,m,y,p12,p22,p32,p42), c c where n is the length of x, c x is the vector to which a2 is to be applied, c m is the length of y, c y is the product of a2 and x, and c p12, p22, p32, and p42 are user-specified parameters c p12 -- parameter to be passed to routine matvec2 c p22 -- parameter to be passed to routine matvec2 c p32 -- parameter to be passed to routine matvec2 c p42 -- parameter to be passed to routine matvec2 c its -- number of iterations of the power method to conduct c c output: c snorm -- estimate of the spectral norm of a-a2 c c work: c w -- must be at least 3*m+3*n complex*16 elements long c c reference: c Kuczynski and Wozniakowski, "Estimating the largest eigenvalue c by the power and Lanczos algorithms with a random start," c SIAM Journal on Matrix Analysis and Applications, c 13 (4): 1992, 1094-1122. c implicit none integer m,n,its,lw,iu,lu,iu1,lu1,iu2,lu2, 1 iv,lv,iv1,lv1,iv2,lv2 real*8 snorm complex*16 p1a,p2a,p3a,p4a,p1a2,p2a2,p3a2,p4a2, 1 p1,p2,p3,p4,p12,p22,p32,p42,w(3*m+3*n) external matveca,matvec,matveca2,matvec2 c c c Allocate memory in w. c lw = 0 c iu = lw+1 lu = m lw = lw+lu c iu1 = lw+1 lu1 = m lw = lw+lu1 c iu2 = lw+1 lu2 = m lw = lw+lu2 c iv = lw+1 lv = n lw = lw+1 c iv1 = lw+1 lv1 = n lw = lw+lv1 c iv2 = lw+1 lv2 = n lw = lw+lv2 c c call idz_diffsnorm0(m,n,matveca,p1a,p2a,p3a,p4a, 1 matveca2,p1a2,p2a2,p3a2,p4a2, 2 matvec,p1,p2,p3,p4, 3 matvec2,p12,p22,p32,p42, 4 its,snorm,w(iu),w(iu1),w(iu2), 5 w(iv),w(iv1),w(iv2)) c c return end c c c c subroutine idz_diffsnorm0(m,n,matveca,p1a,p2a,p3a,p4a, 1 matveca2,p1a2,p2a2,p3a2,p4a2, 2 matvec,p1,p2,p3,p4, 3 matvec2,p12,p22,p32,p42, 4 its,snorm,u,u1,u2,v,v1,v2) c c routine idz_diffsnorm serves as a memory wrapper c for the present routine. (Please see routine idz_diffsnorm c for further documentation.) c implicit none integer m,n,its,it,n2,k real*8 snorm,enorm complex*16 p1a,p2a,p3a,p4a,p1a2,p2a2,p3a2,p4a2, 1 p1,p2,p3,p4,p12,p22,p32,p42,u(m),u1(m),u2(m), 2 v(n),v1(n),v2(n) external matveca,matvec,matveca2,matvec2 c c c Fill the real and imaginary parts of each entry c of the initial vector v with i.i.d. random variables c drawn uniformly from [-1,1]. c n2 = 2*n call id_srand(n2,v) c do k = 1,n v(k) = 2*v(k)-1 enddo ! k c c c Normalize v. c call idz_enorm(n,v,enorm) c do k = 1,n v(k) = v(k)/enorm enddo ! k c c do it = 1,its c c Apply a and a2 to v, obtaining u1 and u2. c call matvec(n,v,m,u1,p1,p2,p3,p4) call matvec2(n,v,m,u2,p12,p22,p32,p42) c c Form u = u1-u2. c do k = 1,m u(k) = u1(k)-u2(k) enddo ! k c c Apply a^* and (a2)^* to u, obtaining v1 and v2. c call matveca(m,u,n,v1,p1a,p2a,p3a,p4a) call matveca2(m,u,n,v2,p1a2,p2a2,p3a2,p4a2) c c Form v = v1-v2. c do k = 1,n v(k) = v1(k)-v2(k) enddo ! k c c Normalize v. c call idz_enorm(n,v,snorm) c if(snorm .gt. 0) then c do k = 1,n v(k) = v(k)/snorm enddo ! k c endif c snorm = sqrt(snorm) c enddo ! it c c return end
bsd-3-clause
pscholz/presto
src/slalib/rcc.f
4
58810
DOUBLE PRECISION FUNCTION sla_RCC (TDB, UT1, WL, U, V) *+ * - - - - * R C C * - - - - * * Relativistic clock correction: the difference between proper time at * a point on the surface of the Earth and coordinate time in the Solar * System barycentric space-time frame of reference. * * The proper time is terrestrial time, TT; the coordinate time is an * implementation of barycentric dynamical time, TDB. * * Given: * TDB d TDB (MJD: JD-2400000.5) * UT1 d universal time (fraction of one day) * WL d clock longitude (radians west) * U d clock distance from Earth spin axis (km) * V d clock distance north of Earth equatorial plane (km) * * Returned: * The clock correction, TDB-TT, in seconds: * * . TDB is coordinate time in the solar system barycentre frame * of reference, in units chosen to eliminate the scale difference * with respect to terrestrial time. * * . TT is the proper time for clocks at mean sea level on the * Earth. * * Notes: * * 1 The argument TDB is, strictly, the barycentric coordinate time; * however, the terrestrial time TT can in practice be used without * any significant loss of accuracy. * * 2 The result returned by sla_RCC comprises a main (annual) * sinusoidal term of amplitude approximately 0.00166 seconds, plus * planetary and lunar terms up to about 20 microseconds, and diurnal * terms up to 2 microseconds. The variation arises from the * transverse Doppler effect and the gravitational red-shift as the * observer varies in speed and moves through different gravitational * potentials. * * 3 The geocentric model is that of Fairhead & Bretagnon (1990), in * its full form. It was supplied by Fairhead (private * communication) as a FORTRAN subroutine. The original Fairhead * routine used explicit formulae, in such large numbers that * problems were experienced with certain compilers (Microsoft * Fortran on PC aborted with stack overflow, Convex compiled * successfully but extremely slowly). The present implementation is * a complete recoding, with the original Fairhead coefficients held * in a table. To optimise arithmetic precision, the terms are * accumulated in reverse order, smallest first. A number of other * coding changes were made, in order to match the calling sequence * of previous versions of the present routine, and to comply with * Starlink programming standards. The numerical results compared * with those from the Fairhead form are essentially unaffected by * the changes, the differences being at the 10^-20 sec level. * * 4 The topocentric part of the model is from Moyer (1981) and * Murray (1983). It is an approximation to the expression * ( v / c ) . ( r / c ), where v is the barycentric velocity of * the Earth, r is the geocentric position of the observer and * c is the speed of light. * * 5 During the interval 1950-2050, the absolute accuracy of is better * than +/- 3 nanoseconds relative to direct numerical integrations * using the JPL DE200/LE200 solar system ephemeris. * * 6 The IAU definition of TDB was that it must differ from TT only by * periodic terms. Though practical, this is an imprecise definition * which ignores the existence of very long-period and secular * effects in the dynamics of the solar system. As a consequence, * different implementations of TDB will, in general, differ in zero- * point and will drift linearly relative to one other. * * 7 TDB was, in principle, superseded by new coordinate timescales * which the IAU introduced in 1991: geocentric coordinate time, * TCG, and barycentric coordinate time, TCB. However, sla_RCC * can be used to implement the periodic part of TCB-TCG. * * References: * * 1 Fairhead, L., & Bretagnon, P., Astron.Astrophys., 229, 240-247 * (1990). * * 2 Moyer, T.D., Cel.Mech., 23, 33 (1981). * * 3 Murray, C.A., Vectorial Astrometry, Adam Hilger (1983). * * 4 Seidelmann, P.K. et al, Explanatory Supplement to the * Astronomical Almanac, Chapter 2, University Science Books * (1992). * * 5 Simon J.L., Bretagnon P., Chapront J., Chapront-Touze M., * Francou G. & Laskar J., Astron.Astrophys., 282, 663-683 (1994). * * P.T.Wallace Starlink 7 May 2000 * * Copyright (C) 2000 Rutherford Appleton Laboratory * * License: * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see SLA_CONDITIONS); if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * *- IMPLICIT NONE DOUBLE PRECISION TDB,UT1,WL,U,V DOUBLE PRECISION D2PI,D2R PARAMETER (D2PI=6.283185307179586476925287D0, : D2R=0.0174532925199432957692369D0) DOUBLE PRECISION T,TSOL,W,ELSUN,EMSUN,D,ELJ,ELS, : WT,W0,W1,W2,W3,W4,WF,WJ * ----------------------------------------------------------------------- * * Fairhead and Bretagnon canonical coefficients * * 787 sets of three coefficients. * * Each set is amplitude (microseconds) * frequency (radians per Julian millennium since J2000), * phase (radians). * * Sets 1-474 are the T**0 terms, * " 475-679 " " T**1 " * " 680-764 " " T**2 " * " 765-784 " " T**3 " * " 785-787 " " T**4 " . * DOUBLE PRECISION FAIRHD(3,787) INTEGER I,J DATA ((FAIRHD(I,J),I=1,3),J= 1, 10) / : 1656.674564D-6, 6283.075849991D0, 6.240054195D0, : 22.417471D-6, 5753.384884897D0, 4.296977442D0, : 13.839792D-6, 12566.151699983D0, 6.196904410D0, : 4.770086D-6, 529.690965095D0, 0.444401603D0, : 4.676740D-6, 6069.776754553D0, 4.021195093D0, : 2.256707D-6, 213.299095438D0, 5.543113262D0, : 1.694205D-6, -3.523118349D0, 5.025132748D0, : 1.554905D-6, 77713.771467920D0, 5.198467090D0, : 1.276839D-6, 7860.419392439D0, 5.988822341D0, : 1.193379D-6, 5223.693919802D0, 3.649823730D0 / DATA ((FAIRHD(I,J),I=1,3),J= 11, 20) / : 1.115322D-6, 3930.209696220D0, 1.422745069D0, : 0.794185D-6, 11506.769769794D0, 2.322313077D0, : 0.447061D-6, 26.298319800D0, 3.615796498D0, : 0.435206D-6, -398.149003408D0, 4.349338347D0, : 0.600309D-6, 1577.343542448D0, 2.678271909D0, : 0.496817D-6, 6208.294251424D0, 5.696701824D0, : 0.486306D-6, 5884.926846583D0, 0.520007179D0, : 0.432392D-6, 74.781598567D0, 2.435898309D0, : 0.468597D-6, 6244.942814354D0, 5.866398759D0, : 0.375510D-6, 5507.553238667D0, 4.103476804D0 / DATA ((FAIRHD(I,J),I=1,3),J= 21, 30) / : 0.243085D-6, -775.522611324D0, 3.651837925D0, : 0.173435D-6, 18849.227549974D0, 6.153743485D0, : 0.230685D-6, 5856.477659115D0, 4.773852582D0, : 0.203747D-6, 12036.460734888D0, 4.333987818D0, : 0.143935D-6, -796.298006816D0, 5.957517795D0, : 0.159080D-6, 10977.078804699D0, 1.890075226D0, : 0.119979D-6, 38.133035638D0, 4.551585768D0, : 0.118971D-6, 5486.777843175D0, 1.914547226D0, : 0.116120D-6, 1059.381930189D0, 0.873504123D0, : 0.137927D-6, 11790.629088659D0, 1.135934669D0 / DATA ((FAIRHD(I,J),I=1,3),J= 31, 40) / : 0.098358D-6, 2544.314419883D0, 0.092793886D0, : 0.101868D-6, -5573.142801634D0, 5.984503847D0, : 0.080164D-6, 206.185548437D0, 2.095377709D0, : 0.079645D-6, 4694.002954708D0, 2.949233637D0, : 0.062617D-6, 20.775395492D0, 2.654394814D0, : 0.075019D-6, 2942.463423292D0, 4.980931759D0, : 0.064397D-6, 5746.271337896D0, 1.280308748D0, : 0.063814D-6, 5760.498431898D0, 4.167901731D0, : 0.048042D-6, 2146.165416475D0, 1.495846011D0, : 0.048373D-6, 155.420399434D0, 2.251573730D0 / DATA ((FAIRHD(I,J),I=1,3),J= 41, 50) / : 0.058844D-6, 426.598190876D0, 4.839650148D0, : 0.046551D-6, -0.980321068D0, 0.921573539D0, : 0.054139D-6, 17260.154654690D0, 3.411091093D0, : 0.042411D-6, 6275.962302991D0, 2.869567043D0, : 0.040184D-6, -7.113547001D0, 3.565975565D0, : 0.036564D-6, 5088.628839767D0, 3.324679049D0, : 0.040759D-6, 12352.852604545D0, 3.981496998D0, : 0.036507D-6, 801.820931124D0, 6.248866009D0, : 0.036955D-6, 3154.687084896D0, 5.071801441D0, : 0.042732D-6, 632.783739313D0, 5.720622217D0 / DATA ((FAIRHD(I,J),I=1,3),J= 51, 60) / : 0.042560D-6, 161000.685737473D0, 1.270837679D0, : 0.040480D-6, 15720.838784878D0, 2.546610123D0, : 0.028244D-6, -6286.598968340D0, 5.069663519D0, : 0.033477D-6, 6062.663207553D0, 4.144987272D0, : 0.034867D-6, 522.577418094D0, 5.210064075D0, : 0.032438D-6, 6076.890301554D0, 0.749317412D0, : 0.030215D-6, 7084.896781115D0, 3.389610345D0, : 0.029247D-6, -71430.695617928D0, 4.183178762D0, : 0.033529D-6, 9437.762934887D0, 2.404714239D0, : 0.032423D-6, 8827.390269875D0, 5.541473556D0 / DATA ((FAIRHD(I,J),I=1,3),J= 61, 70) / : 0.027567D-6, 6279.552731642D0, 5.040846034D0, : 0.029862D-6, 12139.553509107D0, 1.770181024D0, : 0.022509D-6, 10447.387839604D0, 1.460726241D0, : 0.020937D-6, 8429.241266467D0, 0.652303414D0, : 0.020322D-6, 419.484643875D0, 3.735430632D0, : 0.024816D-6, -1194.447010225D0, 1.087136918D0, : 0.025196D-6, 1748.016413067D0, 2.901883301D0, : 0.021691D-6, 14143.495242431D0, 5.952658009D0, : 0.017673D-6, 6812.766815086D0, 3.186129845D0, : 0.022567D-6, 6133.512652857D0, 3.307984806D0 / DATA ((FAIRHD(I,J),I=1,3),J= 71, 80) / : 0.016155D-6, 10213.285546211D0, 1.331103168D0, : 0.014751D-6, 1349.867409659D0, 4.308933301D0, : 0.015949D-6, -220.412642439D0, 4.005298270D0, : 0.015974D-6, -2352.866153772D0, 6.145309371D0, : 0.014223D-6, 17789.845619785D0, 2.104551349D0, : 0.017806D-6, 73.297125859D0, 3.475975097D0, : 0.013671D-6, -536.804512095D0, 5.971672571D0, : 0.011942D-6, 8031.092263058D0, 2.053414715D0, : 0.014318D-6, 16730.463689596D0, 3.016058075D0, : 0.012462D-6, 103.092774219D0, 1.737438797D0 / DATA ((FAIRHD(I,J),I=1,3),J= 81, 90) / : 0.010962D-6, 3.590428652D0, 2.196567739D0, : 0.015078D-6, 19651.048481098D0, 3.969480770D0, : 0.010396D-6, 951.718406251D0, 5.717799605D0, : 0.011707D-6, -4705.732307544D0, 2.654125618D0, : 0.010453D-6, 5863.591206116D0, 1.913704550D0, : 0.012420D-6, 4690.479836359D0, 4.734090399D0, : 0.011847D-6, 5643.178563677D0, 5.489005403D0, : 0.008610D-6, 3340.612426700D0, 3.661698944D0, : 0.011622D-6, 5120.601145584D0, 4.863931876D0, : 0.010825D-6, 553.569402842D0, 0.842715011D0 / DATA ((FAIRHD(I,J),I=1,3),J= 91,100) / : 0.008666D-6, -135.065080035D0, 3.293406547D0, : 0.009963D-6, 149.563197135D0, 4.870690598D0, : 0.009858D-6, 6309.374169791D0, 1.061816410D0, : 0.007959D-6, 316.391869657D0, 2.465042647D0, : 0.010099D-6, 283.859318865D0, 1.942176992D0, : 0.007147D-6, -242.728603974D0, 3.661486981D0, : 0.007505D-6, 5230.807466803D0, 4.920937029D0, : 0.008323D-6, 11769.853693166D0, 1.229392026D0, : 0.007490D-6, -6256.777530192D0, 3.658444681D0, : 0.009370D-6, 149854.400134205D0, 0.673880395D0 / DATA ((FAIRHD(I,J),I=1,3),J=101,110) / : 0.007117D-6, 38.027672636D0, 5.294249518D0, : 0.007857D-6, 12168.002696575D0, 0.525733528D0, : 0.007019D-6, 6206.809778716D0, 0.837688810D0, : 0.006056D-6, 955.599741609D0, 4.194535082D0, : 0.008107D-6, 13367.972631107D0, 3.793235253D0, : 0.006731D-6, 5650.292110678D0, 5.639906583D0, : 0.007332D-6, 36.648562930D0, 0.114858677D0, : 0.006366D-6, 4164.311989613D0, 2.262081818D0, : 0.006858D-6, 5216.580372801D0, 0.642063318D0, : 0.006919D-6, 6681.224853400D0, 6.018501522D0 / DATA ((FAIRHD(I,J),I=1,3),J=111,120) / : 0.006826D-6, 7632.943259650D0, 3.458654112D0, : 0.005308D-6, -1592.596013633D0, 2.500382359D0, : 0.005096D-6, 11371.704689758D0, 2.547107806D0, : 0.004841D-6, 5333.900241022D0, 0.437078094D0, : 0.005582D-6, 5966.683980335D0, 2.246174308D0, : 0.006304D-6, 11926.254413669D0, 2.512929171D0, : 0.006603D-6, 23581.258177318D0, 5.393136889D0, : 0.005123D-6, -1.484472708D0, 2.999641028D0, : 0.004648D-6, 1589.072895284D0, 1.275847090D0, : 0.005119D-6, 6438.496249426D0, 1.486539246D0 / DATA ((FAIRHD(I,J),I=1,3),J=121,130) / : 0.004521D-6, 4292.330832950D0, 6.140635794D0, : 0.005680D-6, 23013.539539587D0, 4.557814849D0, : 0.005488D-6, -3.455808046D0, 0.090675389D0, : 0.004193D-6, 7234.794256242D0, 4.869091389D0, : 0.003742D-6, 7238.675591600D0, 4.691976180D0, : 0.004148D-6, -110.206321219D0, 3.016173439D0, : 0.004553D-6, 11499.656222793D0, 5.554998314D0, : 0.004892D-6, 5436.993015240D0, 1.475415597D0, : 0.004044D-6, 4732.030627343D0, 1.398784824D0, : 0.004164D-6, 12491.370101415D0, 5.650931916D0 / DATA ((FAIRHD(I,J),I=1,3),J=131,140) / : 0.004349D-6, 11513.883316794D0, 2.181745369D0, : 0.003919D-6, 12528.018664345D0, 5.823319737D0, : 0.003129D-6, 6836.645252834D0, 0.003844094D0, : 0.004080D-6, -7058.598461315D0, 3.690360123D0, : 0.003270D-6, 76.266071276D0, 1.517189902D0, : 0.002954D-6, 6283.143160294D0, 4.447203799D0, : 0.002872D-6, 28.449187468D0, 1.158692983D0, : 0.002881D-6, 735.876513532D0, 0.349250250D0, : 0.003279D-6, 5849.364112115D0, 4.893384368D0, : 0.003625D-6, 6209.778724132D0, 1.473760578D0 / DATA ((FAIRHD(I,J),I=1,3),J=141,150) / : 0.003074D-6, 949.175608970D0, 5.185878737D0, : 0.002775D-6, 9917.696874510D0, 1.030026325D0, : 0.002646D-6, 10973.555686350D0, 3.918259169D0, : 0.002575D-6, 25132.303399966D0, 6.109659023D0, : 0.003500D-6, 263.083923373D0, 1.892100742D0, : 0.002740D-6, 18319.536584880D0, 4.320519510D0, : 0.002464D-6, 202.253395174D0, 4.698203059D0, : 0.002409D-6, 2.542797281D0, 5.325009315D0, : 0.003354D-6, -90955.551694697D0, 1.942656623D0, : 0.002296D-6, 6496.374945429D0, 5.061810696D0 / DATA ((FAIRHD(I,J),I=1,3),J=151,160) / : 0.003002D-6, 6172.869528772D0, 2.797822767D0, : 0.003202D-6, 27511.467873537D0, 0.531673101D0, : 0.002954D-6, -6283.008539689D0, 4.533471191D0, : 0.002353D-6, 639.897286314D0, 3.734548088D0, : 0.002401D-6, 16200.772724501D0, 2.605547070D0, : 0.003053D-6, 233141.314403759D0, 3.029030662D0, : 0.003024D-6, 83286.914269554D0, 2.355556099D0, : 0.002863D-6, 17298.182327326D0, 5.240963796D0, : 0.002103D-6, -7079.373856808D0, 5.756641637D0, : 0.002303D-6, 83996.847317911D0, 2.013686814D0 / DATA ((FAIRHD(I,J),I=1,3),J=161,170) / : 0.002303D-6, 18073.704938650D0, 1.089100410D0, : 0.002381D-6, 63.735898303D0, 0.759188178D0, : 0.002493D-6, 6386.168624210D0, 0.645026535D0, : 0.002366D-6, 3.932153263D0, 6.215885448D0, : 0.002169D-6, 11015.106477335D0, 4.845297676D0, : 0.002397D-6, 6243.458341645D0, 3.809290043D0, : 0.002183D-6, 1162.474704408D0, 6.179611691D0, : 0.002353D-6, 6246.427287062D0, 4.781719760D0, : 0.002199D-6, -245.831646229D0, 5.956152284D0, : 0.001729D-6, 3894.181829542D0, 1.264976635D0 / DATA ((FAIRHD(I,J),I=1,3),J=171,180) / : 0.001896D-6, -3128.388765096D0, 4.914231596D0, : 0.002085D-6, 35.164090221D0, 1.405158503D0, : 0.002024D-6, 14712.317116458D0, 2.752035928D0, : 0.001737D-6, 6290.189396992D0, 5.280820144D0, : 0.002229D-6, 491.557929457D0, 1.571007057D0, : 0.001602D-6, 14314.168113050D0, 4.203664806D0, : 0.002186D-6, 454.909366527D0, 1.402101526D0, : 0.001897D-6, 22483.848574493D0, 4.167932508D0, : 0.001825D-6, -3738.761430108D0, 0.545828785D0, : 0.001894D-6, 1052.268383188D0, 5.817167450D0 / DATA ((FAIRHD(I,J),I=1,3),J=181,190) / : 0.001421D-6, 20.355319399D0, 2.419886601D0, : 0.001408D-6, 10984.192351700D0, 2.732084787D0, : 0.001847D-6, 10873.986030480D0, 2.903477885D0, : 0.001391D-6, -8635.942003763D0, 0.593891500D0, : 0.001388D-6, -7.046236698D0, 1.166145902D0, : 0.001810D-6, -88860.057071188D0, 0.487355242D0, : 0.001288D-6, -1990.745017041D0, 3.913022880D0, : 0.001297D-6, 23543.230504682D0, 3.063805171D0, : 0.001335D-6, -266.607041722D0, 3.995764039D0, : 0.001376D-6, 10969.965257698D0, 5.152914309D0 / DATA ((FAIRHD(I,J),I=1,3),J=191,200) / : 0.001745D-6, 244287.600007027D0, 3.626395673D0, : 0.001649D-6, 31441.677569757D0, 1.952049260D0, : 0.001416D-6, 9225.539273283D0, 4.996408389D0, : 0.001238D-6, 4804.209275927D0, 5.503379738D0, : 0.001472D-6, 4590.910180489D0, 4.164913291D0, : 0.001169D-6, 6040.347246017D0, 5.841719038D0, : 0.001039D-6, 5540.085789459D0, 2.769753519D0, : 0.001004D-6, -170.672870619D0, 0.755008103D0, : 0.001284D-6, 10575.406682942D0, 5.306538209D0, : 0.001278D-6, 71.812653151D0, 4.713486491D0 / DATA ((FAIRHD(I,J),I=1,3),J=201,210) / : 0.001321D-6, 18209.330263660D0, 2.624866359D0, : 0.001297D-6, 21228.392023546D0, 0.382603541D0, : 0.000954D-6, 6282.095528923D0, 0.882213514D0, : 0.001145D-6, 6058.731054289D0, 1.169483931D0, : 0.000979D-6, 5547.199336460D0, 5.448375984D0, : 0.000987D-6, -6262.300454499D0, 2.656486959D0, : 0.001070D-6, -154717.609887482D0, 1.827624012D0, : 0.000991D-6, 4701.116501708D0, 4.387001801D0, : 0.001155D-6, -14.227094002D0, 3.042700750D0, : 0.001176D-6, 277.034993741D0, 3.335519004D0 / DATA ((FAIRHD(I,J),I=1,3),J=211,220) / : 0.000890D-6, 13916.019109642D0, 5.601498297D0, : 0.000884D-6, -1551.045222648D0, 1.088831705D0, : 0.000876D-6, 5017.508371365D0, 3.969902609D0, : 0.000806D-6, 15110.466119866D0, 5.142876744D0, : 0.000773D-6, -4136.910433516D0, 0.022067765D0, : 0.001077D-6, 175.166059800D0, 1.844913056D0, : 0.000954D-6, -6284.056171060D0, 0.968480906D0, : 0.000737D-6, 5326.786694021D0, 4.923831588D0, : 0.000845D-6, -433.711737877D0, 4.749245231D0, : 0.000819D-6, 8662.240323563D0, 5.991247817D0 / DATA ((FAIRHD(I,J),I=1,3),J=221,230) / : 0.000852D-6, 199.072001436D0, 2.189604979D0, : 0.000723D-6, 17256.631536341D0, 6.068719637D0, : 0.000940D-6, 6037.244203762D0, 6.197428148D0, : 0.000885D-6, 11712.955318231D0, 3.280414875D0, : 0.000706D-6, 12559.038152982D0, 2.824848947D0, : 0.000732D-6, 2379.164473572D0, 2.501813417D0, : 0.000764D-6, -6127.655450557D0, 2.236346329D0, : 0.000908D-6, 131.541961686D0, 2.521257490D0, : 0.000907D-6, 35371.887265976D0, 3.370195967D0, : 0.000673D-6, 1066.495477190D0, 3.876512374D0 / DATA ((FAIRHD(I,J),I=1,3),J=231,240) / : 0.000814D-6, 17654.780539750D0, 4.627122566D0, : 0.000630D-6, 36.027866677D0, 0.156368499D0, : 0.000798D-6, 515.463871093D0, 5.151962502D0, : 0.000798D-6, 148.078724426D0, 5.909225055D0, : 0.000806D-6, 309.278322656D0, 6.054064447D0, : 0.000607D-6, -39.617508346D0, 2.839021623D0, : 0.000601D-6, 412.371096874D0, 3.984225404D0, : 0.000646D-6, 11403.676995575D0, 3.852959484D0, : 0.000704D-6, 13521.751441591D0, 2.300991267D0, : 0.000603D-6, -65147.619767937D0, 4.140083146D0 / DATA ((FAIRHD(I,J),I=1,3),J=241,250) / : 0.000609D-6, 10177.257679534D0, 0.437122327D0, : 0.000631D-6, 5767.611978898D0, 4.026532329D0, : 0.000576D-6, 11087.285125918D0, 4.760293101D0, : 0.000674D-6, 14945.316173554D0, 6.270510511D0, : 0.000726D-6, 5429.879468239D0, 6.039606892D0, : 0.000710D-6, 28766.924424484D0, 5.672617711D0, : 0.000647D-6, 11856.218651625D0, 3.397132627D0, : 0.000678D-6, -5481.254918868D0, 6.249666675D0, : 0.000618D-6, 22003.914634870D0, 2.466427018D0, : 0.000738D-6, 6134.997125565D0, 2.242668890D0 / DATA ((FAIRHD(I,J),I=1,3),J=251,260) / : 0.000660D-6, 625.670192312D0, 5.864091907D0, : 0.000694D-6, 3496.032826134D0, 2.668309141D0, : 0.000531D-6, 6489.261398429D0, 1.681888780D0, : 0.000611D-6, -143571.324284214D0, 2.424978312D0, : 0.000575D-6, 12043.574281889D0, 4.216492400D0, : 0.000553D-6, 12416.588502848D0, 4.772158039D0, : 0.000689D-6, 4686.889407707D0, 6.224271088D0, : 0.000495D-6, 7342.457780181D0, 3.817285811D0, : 0.000567D-6, 3634.621024518D0, 1.649264690D0, : 0.000515D-6, 18635.928454536D0, 3.945345892D0 / DATA ((FAIRHD(I,J),I=1,3),J=261,270) / : 0.000486D-6, -323.505416657D0, 4.061673868D0, : 0.000662D-6, 25158.601719765D0, 1.794058369D0, : 0.000509D-6, 846.082834751D0, 3.053874588D0, : 0.000472D-6, -12569.674818332D0, 5.112133338D0, : 0.000461D-6, 6179.983075773D0, 0.513669325D0, : 0.000641D-6, 83467.156352816D0, 3.210727723D0, : 0.000520D-6, 10344.295065386D0, 2.445597761D0, : 0.000493D-6, 18422.629359098D0, 1.676939306D0, : 0.000478D-6, 1265.567478626D0, 5.487314569D0, : 0.000472D-6, -18.159247265D0, 1.999707589D0 / DATA ((FAIRHD(I,J),I=1,3),J=271,280) / : 0.000559D-6, 11190.377900137D0, 5.783236356D0, : 0.000494D-6, 9623.688276691D0, 3.022645053D0, : 0.000463D-6, 5739.157790895D0, 1.411223013D0, : 0.000432D-6, 16858.482532933D0, 1.179256434D0, : 0.000574D-6, 72140.628666286D0, 1.758191830D0, : 0.000484D-6, 17267.268201691D0, 3.290589143D0, : 0.000550D-6, 4907.302050146D0, 0.864024298D0, : 0.000399D-6, 14.977853527D0, 2.094441910D0, : 0.000491D-6, 224.344795702D0, 0.878372791D0, : 0.000432D-6, 20426.571092422D0, 6.003829241D0 / DATA ((FAIRHD(I,J),I=1,3),J=281,290) / : 0.000481D-6, 5749.452731634D0, 4.309591964D0, : 0.000480D-6, 5757.317038160D0, 1.142348571D0, : 0.000485D-6, 6702.560493867D0, 0.210580917D0, : 0.000426D-6, 6055.549660552D0, 4.274476529D0, : 0.000480D-6, 5959.570433334D0, 5.031351030D0, : 0.000466D-6, 12562.628581634D0, 4.959581597D0, : 0.000520D-6, 39302.096962196D0, 4.788002889D0, : 0.000458D-6, 12132.439962106D0, 1.880103788D0, : 0.000470D-6, 12029.347187887D0, 1.405611197D0, : 0.000416D-6, -7477.522860216D0, 1.082356330D0 / DATA ((FAIRHD(I,J),I=1,3),J=291,300) / : 0.000449D-6, 11609.862544012D0, 4.179989585D0, : 0.000465D-6, 17253.041107690D0, 0.353496295D0, : 0.000362D-6, -4535.059436924D0, 1.583849576D0, : 0.000383D-6, 21954.157609398D0, 3.747376371D0, : 0.000389D-6, 17.252277143D0, 1.395753179D0, : 0.000331D-6, 18052.929543158D0, 0.566790582D0, : 0.000430D-6, 13517.870106233D0, 0.685827538D0, : 0.000368D-6, -5756.908003246D0, 0.731374317D0, : 0.000330D-6, 10557.594160824D0, 3.710043680D0, : 0.000332D-6, 20199.094959633D0, 1.652901407D0 / DATA ((FAIRHD(I,J),I=1,3),J=301,310) / : 0.000384D-6, 11933.367960670D0, 5.827781531D0, : 0.000387D-6, 10454.501386605D0, 2.541182564D0, : 0.000325D-6, 15671.081759407D0, 2.178850542D0, : 0.000318D-6, 138.517496871D0, 2.253253037D0, : 0.000305D-6, 9388.005909415D0, 0.578340206D0, : 0.000352D-6, 5749.861766548D0, 3.000297967D0, : 0.000311D-6, 6915.859589305D0, 1.693574249D0, : 0.000297D-6, 24072.921469776D0, 1.997249392D0, : 0.000363D-6, -640.877607382D0, 5.071820966D0, : 0.000323D-6, 12592.450019783D0, 1.072262823D0 / DATA ((FAIRHD(I,J),I=1,3),J=311,320) / : 0.000341D-6, 12146.667056108D0, 4.700657997D0, : 0.000290D-6, 9779.108676125D0, 1.812320441D0, : 0.000342D-6, 6132.028180148D0, 4.322238614D0, : 0.000329D-6, 6268.848755990D0, 3.033827743D0, : 0.000374D-6, 17996.031168222D0, 3.388716544D0, : 0.000285D-6, -533.214083444D0, 4.687313233D0, : 0.000338D-6, 6065.844601290D0, 0.877776108D0, : 0.000276D-6, 24.298513841D0, 0.770299429D0, : 0.000336D-6, -2388.894020449D0, 5.353796034D0, : 0.000290D-6, 3097.883822726D0, 4.075291557D0 / DATA ((FAIRHD(I,J),I=1,3),J=321,330) / : 0.000318D-6, 709.933048357D0, 5.941207518D0, : 0.000271D-6, 13095.842665077D0, 3.208912203D0, : 0.000331D-6, 6073.708907816D0, 4.007881169D0, : 0.000292D-6, 742.990060533D0, 2.714333592D0, : 0.000362D-6, 29088.811415985D0, 3.215977013D0, : 0.000280D-6, 12359.966151546D0, 0.710872502D0, : 0.000267D-6, 10440.274292604D0, 4.730108488D0, : 0.000262D-6, 838.969287750D0, 1.327720272D0, : 0.000250D-6, 16496.361396202D0, 0.898769761D0, : 0.000325D-6, 20597.243963041D0, 0.180044365D0 / DATA ((FAIRHD(I,J),I=1,3),J=331,340) / : 0.000268D-6, 6148.010769956D0, 5.152666276D0, : 0.000284D-6, 5636.065016677D0, 5.655385808D0, : 0.000301D-6, 6080.822454817D0, 2.135396205D0, : 0.000294D-6, -377.373607916D0, 3.708784168D0, : 0.000236D-6, 2118.763860378D0, 1.733578756D0, : 0.000234D-6, 5867.523359379D0, 5.575209112D0, : 0.000268D-6, -226858.238553767D0, 0.069432392D0, : 0.000265D-6, 167283.761587465D0, 4.369302826D0, : 0.000280D-6, 28237.233459389D0, 5.304829118D0, : 0.000292D-6, 12345.739057544D0, 4.096094132D0 / DATA ((FAIRHD(I,J),I=1,3),J=341,350) / : 0.000223D-6, 19800.945956225D0, 3.069327406D0, : 0.000301D-6, 43232.306658416D0, 6.205311188D0, : 0.000264D-6, 18875.525869774D0, 1.417263408D0, : 0.000304D-6, -1823.175188677D0, 3.409035232D0, : 0.000301D-6, 109.945688789D0, 0.510922054D0, : 0.000260D-6, 813.550283960D0, 2.389438934D0, : 0.000299D-6, 316428.228673312D0, 5.384595078D0, : 0.000211D-6, 5756.566278634D0, 3.789392838D0, : 0.000209D-6, 5750.203491159D0, 1.661943545D0, : 0.000240D-6, 12489.885628707D0, 5.684549045D0 / DATA ((FAIRHD(I,J),I=1,3),J=351,360) / : 0.000216D-6, 6303.851245484D0, 3.862942261D0, : 0.000203D-6, 1581.959348283D0, 5.549853589D0, : 0.000200D-6, 5642.198242609D0, 1.016115785D0, : 0.000197D-6, -70.849445304D0, 4.690702525D0, : 0.000227D-6, 6287.008003254D0, 2.911891613D0, : 0.000197D-6, 533.623118358D0, 1.048982898D0, : 0.000205D-6, -6279.485421340D0, 1.829362730D0, : 0.000209D-6, -10988.808157535D0, 2.636140084D0, : 0.000208D-6, -227.526189440D0, 4.127883842D0, : 0.000191D-6, 415.552490612D0, 4.401165650D0 / DATA ((FAIRHD(I,J),I=1,3),J=361,370) / : 0.000190D-6, 29296.615389579D0, 4.175658539D0, : 0.000264D-6, 66567.485864652D0, 4.601102551D0, : 0.000256D-6, -3646.350377354D0, 0.506364778D0, : 0.000188D-6, 13119.721102825D0, 2.032195842D0, : 0.000185D-6, -209.366942175D0, 4.694756586D0, : 0.000198D-6, 25934.124331089D0, 3.832703118D0, : 0.000195D-6, 4061.219215394D0, 3.308463427D0, : 0.000234D-6, 5113.487598583D0, 1.716090661D0, : 0.000188D-6, 1478.866574064D0, 5.686865780D0, : 0.000222D-6, 11823.161639450D0, 1.942386641D0 / DATA ((FAIRHD(I,J),I=1,3),J=371,380) / : 0.000181D-6, 10770.893256262D0, 1.999482059D0, : 0.000171D-6, 6546.159773364D0, 1.182807992D0, : 0.000206D-6, 70.328180442D0, 5.934076062D0, : 0.000169D-6, 20995.392966449D0, 2.169080622D0, : 0.000191D-6, 10660.686935042D0, 5.405515999D0, : 0.000228D-6, 33019.021112205D0, 4.656985514D0, : 0.000184D-6, -4933.208440333D0, 3.327476868D0, : 0.000220D-6, -135.625325010D0, 1.765430262D0, : 0.000166D-6, 23141.558382925D0, 3.454132746D0, : 0.000191D-6, 6144.558353121D0, 5.020393445D0 / DATA ((FAIRHD(I,J),I=1,3),J=381,390) / : 0.000180D-6, 6084.003848555D0, 0.602182191D0, : 0.000163D-6, 17782.732072784D0, 4.960593133D0, : 0.000225D-6, 16460.333529525D0, 2.596451817D0, : 0.000222D-6, 5905.702242076D0, 3.731990323D0, : 0.000204D-6, 227.476132789D0, 5.636192701D0, : 0.000159D-6, 16737.577236597D0, 3.600691544D0, : 0.000200D-6, 6805.653268085D0, 0.868220961D0, : 0.000187D-6, 11919.140866668D0, 2.629456641D0, : 0.000161D-6, 127.471796607D0, 2.862574720D0, : 0.000205D-6, 6286.666278643D0, 1.742882331D0 / DATA ((FAIRHD(I,J),I=1,3),J=391,400) / : 0.000189D-6, 153.778810485D0, 4.812372643D0, : 0.000168D-6, 16723.350142595D0, 0.027860588D0, : 0.000149D-6, 11720.068865232D0, 0.659721876D0, : 0.000189D-6, 5237.921013804D0, 5.245313000D0, : 0.000143D-6, 6709.674040867D0, 4.317625647D0, : 0.000146D-6, 4487.817406270D0, 4.815297007D0, : 0.000144D-6, -664.756045130D0, 5.381366880D0, : 0.000175D-6, 5127.714692584D0, 4.728443327D0, : 0.000162D-6, 6254.626662524D0, 1.435132069D0, : 0.000187D-6, 47162.516354635D0, 1.354371923D0 / DATA ((FAIRHD(I,J),I=1,3),J=401,410) / : 0.000146D-6, 11080.171578918D0, 3.369695406D0, : 0.000180D-6, -348.924420448D0, 2.490902145D0, : 0.000148D-6, 151.047669843D0, 3.799109588D0, : 0.000157D-6, 6197.248551160D0, 1.284375887D0, : 0.000167D-6, 146.594251718D0, 0.759969109D0, : 0.000133D-6, -5331.357443741D0, 5.409701889D0, : 0.000154D-6, 95.979227218D0, 3.366890614D0, : 0.000148D-6, -6418.140930027D0, 3.384104996D0, : 0.000128D-6, -6525.804453965D0, 3.803419985D0, : 0.000130D-6, 11293.470674356D0, 0.939039445D0 / DATA ((FAIRHD(I,J),I=1,3),J=411,420) / : 0.000152D-6, -5729.506447149D0, 0.734117523D0, : 0.000138D-6, 210.117701700D0, 2.564216078D0, : 0.000123D-6, 6066.595360816D0, 4.517099537D0, : 0.000140D-6, 18451.078546566D0, 0.642049130D0, : 0.000126D-6, 11300.584221356D0, 3.485280663D0, : 0.000119D-6, 10027.903195729D0, 3.217431161D0, : 0.000151D-6, 4274.518310832D0, 4.404359108D0, : 0.000117D-6, 6072.958148291D0, 0.366324650D0, : 0.000165D-6, -7668.637425143D0, 4.298212528D0, : 0.000117D-6, -6245.048177356D0, 5.379518958D0 / DATA ((FAIRHD(I,J),I=1,3),J=421,430) / : 0.000130D-6, -5888.449964932D0, 4.527681115D0, : 0.000121D-6, -543.918059096D0, 6.109429504D0, : 0.000162D-6, 9683.594581116D0, 5.720092446D0, : 0.000141D-6, 6219.339951688D0, 0.679068671D0, : 0.000118D-6, 22743.409379516D0, 4.881123092D0, : 0.000129D-6, 1692.165669502D0, 0.351407289D0, : 0.000126D-6, 5657.405657679D0, 5.146592349D0, : 0.000114D-6, 728.762966531D0, 0.520791814D0, : 0.000120D-6, 52.596639600D0, 0.948516300D0, : 0.000115D-6, 65.220371012D0, 3.504914846D0 / DATA ((FAIRHD(I,J),I=1,3),J=431,440) / : 0.000126D-6, 5881.403728234D0, 5.577502482D0, : 0.000158D-6, 163096.180360983D0, 2.957128968D0, : 0.000134D-6, 12341.806904281D0, 2.598576764D0, : 0.000151D-6, 16627.370915377D0, 3.985702050D0, : 0.000109D-6, 1368.660252845D0, 0.014730471D0, : 0.000131D-6, 6211.263196841D0, 0.085077024D0, : 0.000146D-6, 5792.741760812D0, 0.708426604D0, : 0.000146D-6, -77.750543984D0, 3.121576600D0, : 0.000107D-6, 5341.013788022D0, 0.288231904D0, : 0.000138D-6, 6281.591377283D0, 2.797450317D0 / DATA ((FAIRHD(I,J),I=1,3),J=441,450) / : 0.000113D-6, -6277.552925684D0, 2.788904128D0, : 0.000115D-6, -525.758811831D0, 5.895222200D0, : 0.000138D-6, 6016.468808270D0, 6.096188999D0, : 0.000139D-6, 23539.707386333D0, 2.028195445D0, : 0.000146D-6, -4176.041342449D0, 4.660008502D0, : 0.000107D-6, 16062.184526117D0, 4.066520001D0, : 0.000142D-6, 83783.548222473D0, 2.936315115D0, : 0.000128D-6, 9380.959672717D0, 3.223844306D0, : 0.000135D-6, 6205.325306007D0, 1.638054048D0, : 0.000101D-6, 2699.734819318D0, 5.481603249D0 / DATA ((FAIRHD(I,J),I=1,3),J=451,460) / : 0.000104D-6, -568.821874027D0, 2.205734493D0, : 0.000103D-6, 6321.103522627D0, 2.440421099D0, : 0.000119D-6, 6321.208885629D0, 2.547496264D0, : 0.000138D-6, 1975.492545856D0, 2.314608466D0, : 0.000121D-6, 137.033024162D0, 4.539108237D0, : 0.000123D-6, 19402.796952817D0, 4.538074405D0, : 0.000119D-6, 22805.735565994D0, 2.869040566D0, : 0.000133D-6, 64471.991241142D0, 6.056405489D0, : 0.000129D-6, -85.827298831D0, 2.540635083D0, : 0.000131D-6, 13613.804277336D0, 4.005732868D0 / DATA ((FAIRHD(I,J),I=1,3),J=461,470) / : 0.000104D-6, 9814.604100291D0, 1.959967212D0, : 0.000112D-6, 16097.679950283D0, 3.589026260D0, : 0.000123D-6, 2107.034507542D0, 1.728627253D0, : 0.000121D-6, 36949.230808424D0, 6.072332087D0, : 0.000108D-6, -12539.853380183D0, 3.716133846D0, : 0.000113D-6, -7875.671863624D0, 2.725771122D0, : 0.000109D-6, 4171.425536614D0, 4.033338079D0, : 0.000101D-6, 6247.911759770D0, 3.441347021D0, : 0.000113D-6, 7330.728427345D0, 0.656372122D0, : 0.000113D-6, 51092.726050855D0, 2.791483066D0 / DATA ((FAIRHD(I,J),I=1,3),J=471,480) / : 0.000106D-6, 5621.842923210D0, 1.815323326D0, : 0.000101D-6, 111.430161497D0, 5.711033677D0, : 0.000103D-6, 909.818733055D0, 2.812745443D0, : 0.000101D-6, 1790.642637886D0, 1.965746028D0, * T : 102.156724D-6, 6283.075849991D0, 4.249032005D0, : 1.706807D-6, 12566.151699983D0, 4.205904248D0, : 0.269668D-6, 213.299095438D0, 3.400290479D0, : 0.265919D-6, 529.690965095D0, 5.836047367D0, : 0.210568D-6, -3.523118349D0, 6.262738348D0, : 0.077996D-6, 5223.693919802D0, 4.670344204D0 / DATA ((FAIRHD(I,J),I=1,3),J=481,490) / : 0.054764D-6, 1577.343542448D0, 4.534800170D0, : 0.059146D-6, 26.298319800D0, 1.083044735D0, : 0.034420D-6, -398.149003408D0, 5.980077351D0, : 0.032088D-6, 18849.227549974D0, 4.162913471D0, : 0.033595D-6, 5507.553238667D0, 5.980162321D0, : 0.029198D-6, 5856.477659115D0, 0.623811863D0, : 0.027764D-6, 155.420399434D0, 3.745318113D0, : 0.025190D-6, 5746.271337896D0, 2.980330535D0, : 0.022997D-6, -796.298006816D0, 1.174411803D0, : 0.024976D-6, 5760.498431898D0, 2.467913690D0 / DATA ((FAIRHD(I,J),I=1,3),J=491,500) / : 0.021774D-6, 206.185548437D0, 3.854787540D0, : 0.017925D-6, -775.522611324D0, 1.092065955D0, : 0.013794D-6, 426.598190876D0, 2.699831988D0, : 0.013276D-6, 6062.663207553D0, 5.845801920D0, : 0.011774D-6, 12036.460734888D0, 2.292832062D0, : 0.012869D-6, 6076.890301554D0, 5.333425680D0, : 0.012152D-6, 1059.381930189D0, 6.222874454D0, : 0.011081D-6, -7.113547001D0, 5.154724984D0, : 0.010143D-6, 4694.002954708D0, 4.044013795D0, : 0.009357D-6, 5486.777843175D0, 3.416081409D0 / DATA ((FAIRHD(I,J),I=1,3),J=501,510) / : 0.010084D-6, 522.577418094D0, 0.749320262D0, : 0.008587D-6, 10977.078804699D0, 2.777152598D0, : 0.008628D-6, 6275.962302991D0, 4.562060226D0, : 0.008158D-6, -220.412642439D0, 5.806891533D0, : 0.007746D-6, 2544.314419883D0, 1.603197066D0, : 0.007670D-6, 2146.165416475D0, 3.000200440D0, : 0.007098D-6, 74.781598567D0, 0.443725817D0, : 0.006180D-6, -536.804512095D0, 1.302642751D0, : 0.005818D-6, 5088.628839767D0, 4.827723531D0, : 0.004945D-6, -6286.598968340D0, 0.268305170D0 / DATA ((FAIRHD(I,J),I=1,3),J=511,520) / : 0.004774D-6, 1349.867409659D0, 5.808636673D0, : 0.004687D-6, -242.728603974D0, 5.154890570D0, : 0.006089D-6, 1748.016413067D0, 4.403765209D0, : 0.005975D-6, -1194.447010225D0, 2.583472591D0, : 0.004229D-6, 951.718406251D0, 0.931172179D0, : 0.005264D-6, 553.569402842D0, 2.336107252D0, : 0.003049D-6, 5643.178563677D0, 1.362634430D0, : 0.002974D-6, 6812.766815086D0, 1.583012668D0, : 0.003403D-6, -2352.866153772D0, 2.552189886D0, : 0.003030D-6, 419.484643875D0, 5.286473844D0 / DATA ((FAIRHD(I,J),I=1,3),J=521,530) / : 0.003210D-6, -7.046236698D0, 1.863796539D0, : 0.003058D-6, 9437.762934887D0, 4.226420633D0, : 0.002589D-6, 12352.852604545D0, 1.991935820D0, : 0.002927D-6, 5216.580372801D0, 2.319951253D0, : 0.002425D-6, 5230.807466803D0, 3.084752833D0, : 0.002656D-6, 3154.687084896D0, 2.487447866D0, : 0.002445D-6, 10447.387839604D0, 2.347139160D0, : 0.002990D-6, 4690.479836359D0, 6.235872050D0, : 0.002890D-6, 5863.591206116D0, 0.095197563D0, : 0.002498D-6, 6438.496249426D0, 2.994779800D0 / DATA ((FAIRHD(I,J),I=1,3),J=531,540) / : 0.001889D-6, 8031.092263058D0, 3.569003717D0, : 0.002567D-6, 801.820931124D0, 3.425611498D0, : 0.001803D-6, -71430.695617928D0, 2.192295512D0, : 0.001782D-6, 3.932153263D0, 5.180433689D0, : 0.001694D-6, -4705.732307544D0, 4.641779174D0, : 0.001704D-6, -1592.596013633D0, 3.997097652D0, : 0.001735D-6, 5849.364112115D0, 0.417558428D0, : 0.001643D-6, 8429.241266467D0, 2.180619584D0, : 0.001680D-6, 38.133035638D0, 4.164529426D0, : 0.002045D-6, 7084.896781115D0, 0.526323854D0 / DATA ((FAIRHD(I,J),I=1,3),J=541,550) / : 0.001458D-6, 4292.330832950D0, 1.356098141D0, : 0.001437D-6, 20.355319399D0, 3.895439360D0, : 0.001738D-6, 6279.552731642D0, 0.087484036D0, : 0.001367D-6, 14143.495242431D0, 3.987576591D0, : 0.001344D-6, 7234.794256242D0, 0.090454338D0, : 0.001438D-6, 11499.656222793D0, 0.974387904D0, : 0.001257D-6, 6836.645252834D0, 1.509069366D0, : 0.001358D-6, 11513.883316794D0, 0.495572260D0, : 0.001628D-6, 7632.943259650D0, 4.968445721D0, : 0.001169D-6, 103.092774219D0, 2.838496795D0 / DATA ((FAIRHD(I,J),I=1,3),J=551,560) / : 0.001162D-6, 4164.311989613D0, 3.408387778D0, : 0.001092D-6, 6069.776754553D0, 3.617942651D0, : 0.001008D-6, 17789.845619785D0, 0.286350174D0, : 0.001008D-6, 639.897286314D0, 1.610762073D0, : 0.000918D-6, 10213.285546211D0, 5.532798067D0, : 0.001011D-6, -6256.777530192D0, 0.661826484D0, : 0.000753D-6, 16730.463689596D0, 3.905030235D0, : 0.000737D-6, 11926.254413669D0, 4.641956361D0, : 0.000694D-6, 3340.612426700D0, 2.111120332D0, : 0.000701D-6, 3894.181829542D0, 2.760823491D0 / DATA ((FAIRHD(I,J),I=1,3),J=561,570) / : 0.000689D-6, -135.065080035D0, 4.768800780D0, : 0.000700D-6, 13367.972631107D0, 5.760439898D0, : 0.000664D-6, 6040.347246017D0, 1.051215840D0, : 0.000654D-6, 5650.292110678D0, 4.911332503D0, : 0.000788D-6, 6681.224853400D0, 4.699648011D0, : 0.000628D-6, 5333.900241022D0, 5.024608847D0, : 0.000755D-6, -110.206321219D0, 4.370971253D0, : 0.000628D-6, 6290.189396992D0, 3.660478857D0, : 0.000635D-6, 25132.303399966D0, 4.121051532D0, : 0.000534D-6, 5966.683980335D0, 1.173284524D0 / DATA ((FAIRHD(I,J),I=1,3),J=571,580) / : 0.000543D-6, -433.711737877D0, 0.345585464D0, : 0.000517D-6, -1990.745017041D0, 5.414571768D0, : 0.000504D-6, 5767.611978898D0, 2.328281115D0, : 0.000485D-6, 5753.384884897D0, 1.685874771D0, : 0.000463D-6, 7860.419392439D0, 5.297703006D0, : 0.000604D-6, 515.463871093D0, 0.591998446D0, : 0.000443D-6, 12168.002696575D0, 4.830881244D0, : 0.000570D-6, 199.072001436D0, 3.899190272D0, : 0.000465D-6, 10969.965257698D0, 0.476681802D0, : 0.000424D-6, -7079.373856808D0, 1.112242763D0 / DATA ((FAIRHD(I,J),I=1,3),J=581,590) / : 0.000427D-6, 735.876513532D0, 1.994214480D0, : 0.000478D-6, -6127.655450557D0, 3.778025483D0, : 0.000414D-6, 10973.555686350D0, 5.441088327D0, : 0.000512D-6, 1589.072895284D0, 0.107123853D0, : 0.000378D-6, 10984.192351700D0, 0.915087231D0, : 0.000402D-6, 11371.704689758D0, 4.107281715D0, : 0.000453D-6, 9917.696874510D0, 1.917490952D0, : 0.000395D-6, 149.563197135D0, 2.763124165D0, : 0.000371D-6, 5739.157790895D0, 3.112111866D0, : 0.000350D-6, 11790.629088659D0, 0.440639857D0 / DATA ((FAIRHD(I,J),I=1,3),J=591,600) / : 0.000356D-6, 6133.512652857D0, 5.444568842D0, : 0.000344D-6, 412.371096874D0, 5.676832684D0, : 0.000383D-6, 955.599741609D0, 5.559734846D0, : 0.000333D-6, 6496.374945429D0, 0.261537984D0, : 0.000340D-6, 6055.549660552D0, 5.975534987D0, : 0.000334D-6, 1066.495477190D0, 2.335063907D0, : 0.000399D-6, 11506.769769794D0, 5.321230910D0, : 0.000314D-6, 18319.536584880D0, 2.313312404D0, : 0.000424D-6, 1052.268383188D0, 1.211961766D0, : 0.000307D-6, 63.735898303D0, 3.169551388D0 / DATA ((FAIRHD(I,J),I=1,3),J=601,610) / : 0.000329D-6, 29.821438149D0, 6.106912080D0, : 0.000357D-6, 6309.374169791D0, 4.223760346D0, : 0.000312D-6, -3738.761430108D0, 2.180556645D0, : 0.000301D-6, 309.278322656D0, 1.499984572D0, : 0.000268D-6, 12043.574281889D0, 2.447520648D0, : 0.000257D-6, 12491.370101415D0, 3.662331761D0, : 0.000290D-6, 625.670192312D0, 1.272834584D0, : 0.000256D-6, 5429.879468239D0, 1.913426912D0, : 0.000339D-6, 3496.032826134D0, 4.165930011D0, : 0.000283D-6, 3930.209696220D0, 4.325565754D0 / DATA ((FAIRHD(I,J),I=1,3),J=611,620) / : 0.000241D-6, 12528.018664345D0, 3.832324536D0, : 0.000304D-6, 4686.889407707D0, 1.612348468D0, : 0.000259D-6, 16200.772724501D0, 3.470173146D0, : 0.000238D-6, 12139.553509107D0, 1.147977842D0, : 0.000236D-6, 6172.869528772D0, 3.776271728D0, : 0.000296D-6, -7058.598461315D0, 0.460368852D0, : 0.000306D-6, 10575.406682942D0, 0.554749016D0, : 0.000251D-6, 17298.182327326D0, 0.834332510D0, : 0.000290D-6, 4732.030627343D0, 4.759564091D0, : 0.000261D-6, 5884.926846583D0, 0.298259862D0 / DATA ((FAIRHD(I,J),I=1,3),J=621,630) / : 0.000249D-6, 5547.199336460D0, 3.749366406D0, : 0.000213D-6, 11712.955318231D0, 5.415666119D0, : 0.000223D-6, 4701.116501708D0, 2.703203558D0, : 0.000268D-6, -640.877607382D0, 0.283670793D0, : 0.000209D-6, 5636.065016677D0, 1.238477199D0, : 0.000193D-6, 10177.257679534D0, 1.943251340D0, : 0.000182D-6, 6283.143160294D0, 2.456157599D0, : 0.000184D-6, -227.526189440D0, 5.888038582D0, : 0.000182D-6, -6283.008539689D0, 0.241332086D0, : 0.000228D-6, -6284.056171060D0, 2.657323816D0 / DATA ((FAIRHD(I,J),I=1,3),J=631,640) / : 0.000166D-6, 7238.675591600D0, 5.930629110D0, : 0.000167D-6, 3097.883822726D0, 5.570955333D0, : 0.000159D-6, -323.505416657D0, 5.786670700D0, : 0.000154D-6, -4136.910433516D0, 1.517805532D0, : 0.000176D-6, 12029.347187887D0, 3.139266834D0, : 0.000167D-6, 12132.439962106D0, 3.556352289D0, : 0.000153D-6, 202.253395174D0, 1.463313961D0, : 0.000157D-6, 17267.268201691D0, 1.586837396D0, : 0.000142D-6, 83996.847317911D0, 0.022670115D0, : 0.000152D-6, 17260.154654690D0, 0.708528947D0 / DATA ((FAIRHD(I,J),I=1,3),J=641,650) / : 0.000144D-6, 6084.003848555D0, 5.187075177D0, : 0.000135D-6, 5756.566278634D0, 1.993229262D0, : 0.000134D-6, 5750.203491159D0, 3.457197134D0, : 0.000144D-6, 5326.786694021D0, 6.066193291D0, : 0.000160D-6, 11015.106477335D0, 1.710431974D0, : 0.000133D-6, 3634.621024518D0, 2.836451652D0, : 0.000134D-6, 18073.704938650D0, 5.453106665D0, : 0.000134D-6, 1162.474704408D0, 5.326898811D0, : 0.000128D-6, 5642.198242609D0, 2.511652591D0, : 0.000160D-6, 632.783739313D0, 5.628785365D0 / DATA ((FAIRHD(I,J),I=1,3),J=651,660) / : 0.000132D-6, 13916.019109642D0, 0.819294053D0, : 0.000122D-6, 14314.168113050D0, 5.677408071D0, : 0.000125D-6, 12359.966151546D0, 5.251984735D0, : 0.000121D-6, 5749.452731634D0, 2.210924603D0, : 0.000136D-6, -245.831646229D0, 1.646502367D0, : 0.000120D-6, 5757.317038160D0, 3.240883049D0, : 0.000134D-6, 12146.667056108D0, 3.059480037D0, : 0.000137D-6, 6206.809778716D0, 1.867105418D0, : 0.000141D-6, 17253.041107690D0, 2.069217456D0, : 0.000129D-6, -7477.522860216D0, 2.781469314D0 / DATA ((FAIRHD(I,J),I=1,3),J=661,670) / : 0.000116D-6, 5540.085789459D0, 4.281176991D0, : 0.000116D-6, 9779.108676125D0, 3.320925381D0, : 0.000129D-6, 5237.921013804D0, 3.497704076D0, : 0.000113D-6, 5959.570433334D0, 0.983210840D0, : 0.000122D-6, 6282.095528923D0, 2.674938860D0, : 0.000140D-6, -11.045700264D0, 4.957936982D0, : 0.000108D-6, 23543.230504682D0, 1.390113589D0, : 0.000106D-6, -12569.674818332D0, 0.429631317D0, : 0.000110D-6, -266.607041722D0, 5.501340197D0, : 0.000115D-6, 12559.038152982D0, 4.691456618D0 / DATA ((FAIRHD(I,J),I=1,3),J=671,680) / : 0.000134D-6, -2388.894020449D0, 0.577313584D0, : 0.000109D-6, 10440.274292604D0, 6.218148717D0, : 0.000102D-6, -543.918059096D0, 1.477842615D0, : 0.000108D-6, 21228.392023546D0, 2.237753948D0, : 0.000101D-6, -4535.059436924D0, 3.100492232D0, : 0.000103D-6, 76.266071276D0, 5.594294322D0, : 0.000104D-6, 949.175608970D0, 5.674287810D0, : 0.000101D-6, 13517.870106233D0, 2.196632348D0, : 0.000100D-6, 11933.367960670D0, 4.056084160D0, : 4.322990D-6, 6283.075849991D0, 2.642893748D0 / DATA ((FAIRHD(I,J),I=1,3),J=681,690) / : 0.406495D-6, 0.000000000D0, 4.712388980D0, : 0.122605D-6, 12566.151699983D0, 2.438140634D0, : 0.019476D-6, 213.299095438D0, 1.642186981D0, : 0.016916D-6, 529.690965095D0, 4.510959344D0, : 0.013374D-6, -3.523118349D0, 1.502210314D0, : 0.008042D-6, 26.298319800D0, 0.478549024D0, : 0.007824D-6, 155.420399434D0, 5.254710405D0, : 0.004894D-6, 5746.271337896D0, 4.683210850D0, : 0.004875D-6, 5760.498431898D0, 0.759507698D0, : 0.004416D-6, 5223.693919802D0, 6.028853166D0 / DATA ((FAIRHD(I,J),I=1,3),J=691,700) / : 0.004088D-6, -7.113547001D0, 0.060926389D0, : 0.004433D-6, 77713.771467920D0, 3.627734103D0, : 0.003277D-6, 18849.227549974D0, 2.327912542D0, : 0.002703D-6, 6062.663207553D0, 1.271941729D0, : 0.003435D-6, -775.522611324D0, 0.747446224D0, : 0.002618D-6, 6076.890301554D0, 3.633715689D0, : 0.003146D-6, 206.185548437D0, 5.647874613D0, : 0.002544D-6, 1577.343542448D0, 6.232904270D0, : 0.002218D-6, -220.412642439D0, 1.309509946D0, : 0.002197D-6, 5856.477659115D0, 2.407212349D0 / DATA ((FAIRHD(I,J),I=1,3),J=701,710) / : 0.002897D-6, 5753.384884897D0, 5.863842246D0, : 0.001766D-6, 426.598190876D0, 0.754113147D0, : 0.001738D-6, -796.298006816D0, 2.714942671D0, : 0.001695D-6, 522.577418094D0, 2.629369842D0, : 0.001584D-6, 5507.553238667D0, 1.341138229D0, : 0.001503D-6, -242.728603974D0, 0.377699736D0, : 0.001552D-6, -536.804512095D0, 2.904684667D0, : 0.001370D-6, -398.149003408D0, 1.265599125D0, : 0.001889D-6, -5573.142801634D0, 4.413514859D0, : 0.001722D-6, 6069.776754553D0, 2.445966339D0 / DATA ((FAIRHD(I,J),I=1,3),J=711,720) / : 0.001124D-6, 1059.381930189D0, 5.041799657D0, : 0.001258D-6, 553.569402842D0, 3.849557278D0, : 0.000831D-6, 951.718406251D0, 2.471094709D0, : 0.000767D-6, 4694.002954708D0, 5.363125422D0, : 0.000756D-6, 1349.867409659D0, 1.046195744D0, : 0.000775D-6, -11.045700264D0, 0.245548001D0, : 0.000597D-6, 2146.165416475D0, 4.543268798D0, : 0.000568D-6, 5216.580372801D0, 4.178853144D0, : 0.000711D-6, 1748.016413067D0, 5.934271972D0, : 0.000499D-6, 12036.460734888D0, 0.624434410D0 / DATA ((FAIRHD(I,J),I=1,3),J=721,730) / : 0.000671D-6, -1194.447010225D0, 4.136047594D0, : 0.000488D-6, 5849.364112115D0, 2.209679987D0, : 0.000621D-6, 6438.496249426D0, 4.518860804D0, : 0.000495D-6, -6286.598968340D0, 1.868201275D0, : 0.000456D-6, 5230.807466803D0, 1.271231591D0, : 0.000451D-6, 5088.628839767D0, 0.084060889D0, : 0.000435D-6, 5643.178563677D0, 3.324456609D0, : 0.000387D-6, 10977.078804699D0, 4.052488477D0, : 0.000547D-6, 161000.685737473D0, 2.841633844D0, : 0.000522D-6, 3154.687084896D0, 2.171979966D0 / DATA ((FAIRHD(I,J),I=1,3),J=731,740) / : 0.000375D-6, 5486.777843175D0, 4.983027306D0, : 0.000421D-6, 5863.591206116D0, 4.546432249D0, : 0.000439D-6, 7084.896781115D0, 0.522967921D0, : 0.000309D-6, 2544.314419883D0, 3.172606705D0, : 0.000347D-6, 4690.479836359D0, 1.479586566D0, : 0.000317D-6, 801.820931124D0, 3.553088096D0, : 0.000262D-6, 419.484643875D0, 0.606635550D0, : 0.000248D-6, 6836.645252834D0, 3.014082064D0, : 0.000245D-6, -1592.596013633D0, 5.519526220D0, : 0.000225D-6, 4292.330832950D0, 2.877956536D0 / DATA ((FAIRHD(I,J),I=1,3),J=741,750) / : 0.000214D-6, 7234.794256242D0, 1.605227587D0, : 0.000205D-6, 5767.611978898D0, 0.625804796D0, : 0.000180D-6, 10447.387839604D0, 3.499954526D0, : 0.000229D-6, 199.072001436D0, 5.632304604D0, : 0.000214D-6, 639.897286314D0, 5.960227667D0, : 0.000175D-6, -433.711737877D0, 2.162417992D0, : 0.000209D-6, 515.463871093D0, 2.322150893D0, : 0.000173D-6, 6040.347246017D0, 2.556183691D0, : 0.000184D-6, 6309.374169791D0, 4.732296790D0, : 0.000227D-6, 149854.400134205D0, 5.385812217D0 / DATA ((FAIRHD(I,J),I=1,3),J=751,760) / : 0.000154D-6, 8031.092263058D0, 5.120720920D0, : 0.000151D-6, 5739.157790895D0, 4.815000443D0, : 0.000197D-6, 7632.943259650D0, 0.222827271D0, : 0.000197D-6, 74.781598567D0, 3.910456770D0, : 0.000138D-6, 6055.549660552D0, 1.397484253D0, : 0.000149D-6, -6127.655450557D0, 5.333727496D0, : 0.000137D-6, 3894.181829542D0, 4.281749907D0, : 0.000135D-6, 9437.762934887D0, 5.979971885D0, : 0.000139D-6, -2352.866153772D0, 4.715630782D0, : 0.000142D-6, 6812.766815086D0, 0.513330157D0 / DATA ((FAIRHD(I,J),I=1,3),J=761,770) / : 0.000120D-6, -4705.732307544D0, 0.194160689D0, : 0.000131D-6, -71430.695617928D0, 0.000379226D0, : 0.000124D-6, 6279.552731642D0, 2.122264908D0, : 0.000108D-6, -6256.777530192D0, 0.883445696D0, : 0.143388D-6, 6283.075849991D0, 1.131453581D0, : 0.006671D-6, 12566.151699983D0, 0.775148887D0, : 0.001480D-6, 155.420399434D0, 0.480016880D0, : 0.000934D-6, 213.299095438D0, 6.144453084D0, : 0.000795D-6, 529.690965095D0, 2.941595619D0, : 0.000673D-6, 5746.271337896D0, 0.120415406D0 / DATA ((FAIRHD(I,J),I=1,3),J=771,780) / : 0.000672D-6, 5760.498431898D0, 5.317009738D0, : 0.000389D-6, -220.412642439D0, 3.090323467D0, : 0.000373D-6, 6062.663207553D0, 3.003551964D0, : 0.000360D-6, 6076.890301554D0, 1.918913041D0, : 0.000316D-6, -21.340641002D0, 5.545798121D0, : 0.000315D-6, -242.728603974D0, 1.884932563D0, : 0.000278D-6, 206.185548437D0, 1.266254859D0, : 0.000238D-6, -536.804512095D0, 4.532664830D0, : 0.000185D-6, 522.577418094D0, 4.578313856D0, : 0.000245D-6, 18849.227549974D0, 0.587467082D0 / DATA ((FAIRHD(I,J),I=1,3),J=781,787) / : 0.000180D-6, 426.598190876D0, 5.151178553D0, : 0.000200D-6, 553.569402842D0, 5.355983739D0, : 0.000141D-6, 5223.693919802D0, 1.336556009D0, : 0.000104D-6, 5856.477659115D0, 4.239842759D0, : 0.003826D-6, 6283.075849991D0, 5.705257275D0, : 0.000303D-6, 12566.151699983D0, 5.407132842D0, : 0.000209D-6, 155.420399434D0, 1.989815753D0 / * ----------------------------------------------------------------------- * Time since J2000.0 in Julian millennia. T=(TDB-51544.5D0)/365250D0 * -------------------- Topocentric terms ------------------------------- * Convert UT1 to local solar time in radians. TSOL = MOD(UT1,1D0)*D2PI - WL * FUNDAMENTAL ARGUMENTS: Simon et al 1994 * Combine time argument (millennia) with deg/arcsec factor. W = T / 3600D0 * Sun Mean Longitude. ELSUN = MOD(280.46645683D0+1296027711.03429D0*W,360D0)*D2R * Sun Mean Anomaly. EMSUN = MOD(357.52910918D0+1295965810.481D0*W,360D0)*D2R * Mean Elongation of Moon from Sun. D = MOD(297.85019547D0+16029616012.090D0*W,360D0)*D2R * Mean Longitude of Jupiter. ELJ = MOD(34.35151874D0+109306899.89453D0*W,360D0)*D2R * Mean Longitude of Saturn. ELS = MOD(50.07744430D0+44046398.47038D0*W,360D0)*D2R * TOPOCENTRIC TERMS: Moyer 1981 and Murray 1983. WT = +0.00029D-10*U*SIN(TSOL+ELSUN-ELS) : +0.00100D-10*U*SIN(TSOL-2D0*EMSUN) : +0.00133D-10*U*SIN(TSOL-D) : +0.00133D-10*U*SIN(TSOL+ELSUN-ELJ) : -0.00229D-10*U*SIN(TSOL+2D0*ELSUN+EMSUN) : -0.0220 D-10*V*COS(ELSUN+EMSUN) : +0.05312D-10*U*SIN(TSOL-EMSUN) : -0.13677D-10*U*SIN(TSOL+2D0*ELSUN) : -1.3184 D-10*V*COS(ELSUN) : +3.17679D-10*U*SIN(TSOL) * --------------- Fairhead model --------------------------------------- * T**0 W0=0D0 DO I=474,1,-1 W0=W0+FAIRHD(1,I)*SIN(FAIRHD(2,I)*T+FAIRHD(3,I)) END DO * T**1 W1=0D0 DO I=679,475,-1 W1=W1+FAIRHD(1,I)*SIN(FAIRHD(2,I)*T+FAIRHD(3,I)) END DO * T**2 W2=0D0 DO I=764,680,-1 W2=W2+FAIRHD(1,I)*SIN(FAIRHD(2,I)*T+FAIRHD(3,I)) END DO * T**3 W3=0D0 DO I=784,765,-1 W3=W3+FAIRHD(1,I)*SIN(FAIRHD(2,I)*T+FAIRHD(3,I)) END DO * T**4 W4=0D0 DO I=787,785,-1 W4=W4+FAIRHD(1,I)*SIN(FAIRHD(2,I)*T+FAIRHD(3,I)) END DO * Multiply by powers of T and combine. WF=T*(T*(T*(T*W4+W3)+W2)+W1)+W0 * Adjustments to use JPL planetary masses instead of IAU. WJ= 0.00065D-6 * SIN( 6069.776754D0 *T + 4.021194D0 ) + : 0.00033D-6 * SIN( 213.299095D0 *T + 5.543132D0 ) + : (-0.00196D-6 * SIN( 6208.294251D0 *T + 5.696701D0 ))+ : (-0.00173D-6 * SIN( 74.781599D0 *T + 2.435900D0 ))+ : 0.03638D-6*T*T * ----------------------------------------------------------------------- * Final result: TDB-TT in seconds. sla_RCC=WT+WF+WJ END
gpl-2.0
nschloe/seacas
packages/seacas/applications/fastq/cornp.f
1
2743
C Copyright(C) 2014-2017 National Technology & Engineering Solutions of C Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with C NTESS, the U.S. Government retains certain rights in this software. C C Redistribution and use in source and binary forms, with or without C modification, are permitted provided that the following conditions are C met: C C * Redistributions of source code must retain the above copyright C notice, this list of conditions and the following disclaimer. C C * Redistributions in binary form must reproduce the above C copyright notice, this list of conditions and the following C disclaimer in the documentation and/or other materials provided C with the distribution. C C * Neither the name of NTESS nor the names of its C contributors may be used to endorse or promote products derived C from this software without specific prior written permission. C C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS C "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT C LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR C A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT C OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, C SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT C LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, C DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY C THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT C (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. C C $Id: cornp.f,v 1.2 1991/03/21 15:44:30 gdsjaar Exp $ C $Log: cornp.f,v $ C Revision 1.2 1991/03/21 15:44:30 gdsjaar C Changed all 3.14159... to atan2(0.0, -1.0) C c Revision 1.1.1.1 1990/11/30 11:05:24 gdsjaar c FASTQ Version 2.0X c c Revision 1.1 90/11/30 11:05:22 gdsjaar c Initial revision c C CC* FILE: [.PAVING]CORNP.FOR CC* MODIFIED BY: TED BLACKER CC* MODIFICATION DATE: 7/6/90 CC* MODIFICATION: COMPLETED HEADER INFORMATION C LOGICAL FUNCTION CORNP (ANGLE) C*********************************************************************** C C FUNCTION CORNP = LOGICAL FUNCTION THAT RETURNS TRUE IF THE ANGLE IS C WITHIN THE CURRENT DEFINITION OF A CORNER C C*********************************************************************** C DATA EPS /.62/ C PI = ATAN2(0.0, -1.0) IF (ANGLE .LT. ( PI - EPS)) THEN CORNP=.TRUE. ELSE CORNP=.FALSE. ENDIF C RETURN C END
bsd-3-clause
pecameron/origin
vendor/github.com/gonum/lapack/internal/testdata/dlasqtest/dcopy.f
191
2631
*> \brief \b DCOPY * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE DCOPY(N,DX,INCX,DY,INCY) * * .. Scalar Arguments .. * INTEGER INCX,INCY,N * .. * .. Array Arguments .. * DOUBLE PRECISION DX(*),DY(*) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DCOPY copies a vector, x, to a vector, y. *> uses unrolled loops for increments equal to one. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup double_blas_level1 * *> \par Further Details: * ===================== *> *> \verbatim *> *> jack dongarra, linpack, 3/11/78. *> modified 12/3/93, array(1) declarations changed to array(*) *> \endverbatim *> * ===================================================================== SUBROUTINE DCOPY(N,DX,INCX,DY,INCY) * * -- Reference BLAS level1 routine (version 3.4.0) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. INTEGER INCX,INCY,N * .. * .. Array Arguments .. DOUBLE PRECISION DX(*),DY(*) * .. * * ===================================================================== * * .. Local Scalars .. INTEGER I,IX,IY,M,MP1 * .. * .. Intrinsic Functions .. INTRINSIC MOD * .. IF (N.LE.0) RETURN IF (INCX.EQ.1 .AND. INCY.EQ.1) THEN * * code for both increments equal to 1 * * * clean-up loop * M = MOD(N,7) IF (M.NE.0) THEN DO I = 1,M DY(I) = DX(I) END DO IF (N.LT.7) RETURN END IF MP1 = M + 1 DO I = MP1,N,7 DY(I) = DX(I) DY(I+1) = DX(I+1) DY(I+2) = DX(I+2) DY(I+3) = DX(I+3) DY(I+4) = DX(I+4) DY(I+5) = DX(I+5) DY(I+6) = DX(I+6) END DO ELSE * * code for unequal increments or equal increments * not equal to 1 * IX = 1 IY = 1 IF (INCX.LT.0) IX = (-N+1)*INCX + 1 IF (INCY.LT.0) IY = (-N+1)*INCY + 1 DO I = 1,N DY(IY) = DX(IX) IX = IX + INCX IY = IY + INCY END DO END IF RETURN END
apache-2.0
CFDEMproject/LAMMPS
tools/ch2lmp/other/mkpdb.f
60
11604
c ------------------------------------------------------------------------- c Code converts LAMMPS output to .pdb files c Overlays coordinates from LAMMPS output onto template pdb c Assumes atom order is the same between the two c Converts from atom-based pbc to residue-based pbc c Also assumes starting config fed to LAMMPS had residue-based pbc c Paul Crozier, SNL, 2002 c ------------------------------------------------------------------------- module global real*8 xprd,yprd,zprd,box(2,3) real*8, allocatable :: x(:,:),q(:),mass(:) real*8, allocatable :: comx(:),comy(:),comz(:),totmass(:) integer ntimestep,natoms,nframes,iframe,nper integer nbonds,nangles,ndihedrals,nimpropers,ntypes integer nbondtypes,nangletypes,ndihedtypes,nimprotypes integer nconfig,nconfig_skip,nskip,nframes_between_pdbs integer nmolecules,nprotein_residues integer, allocatable :: mytrue(:,:),type(:),molecule(:) integer, allocatable :: nboxx(:),nboxy(:),nboxz(:) character*200 data_file_path,config_file_path,pdb_file_path character*200 compare_file_path character*76, allocatable :: outbeg(:),outend(:) end module c ------------------------------------------------------------------------- c ------------------------------------------------------------------------- program mkpdb use global implicit none call read_in_mkpdb call read_data call mkpdb_start do iframe = nskip+1, nframes call find_config call read_config write(6,*) 'Frame # ', iframe if (mod(iframe,nframes_between_pdbs) == 0) call mk_pdb enddo write(6,*) 'Done.' stop end c ------------------------------------------------------------------------- subroutine find_config use global implicit none integer l,m,n,i,j,ntotal real*8 buf(8) if (mod((iframe-1),nper) == 0) then n = (iframe-1)/nper + 1 write(6,*) 'On config file # ', n close(21) c l = n/100 c m = n/10 - l*10 c n = mod(n,10) open(21,file=trim(config_file_path) $ //char(48+n),status='old') rewind 21 c skip the first frame of each config file read(21,*) read(21,*) ntimestep read(21,*) read(21,*) ntotal read(21,*) read(21,*) box(1,1),box(2,1) read(21,*) box(1,2),box(2,2) read(21,*) box(1,3),box(2,3) read(21,*) if (ntotal /= natoms) write(6,*) 'Mismatch # of atoms' do i = 1, natoms read (21,*) (buf(j),j=1,5) enddo endif return end c ------------------------------------------------------------------------- logical function match(str1,str2,m) implicit none character*(*) str1,str2 integer m match = .FALSE. m = len(str1) + 1 if (len(str1).gt.len(str2)) return if (str1.eq.str2(1:len(str1))) match = .TRUE. return end c ------------------------------------------------------------------------- subroutine mk_pdb use global implicit none integer i,j,k,l,m,n,o,imolecule,ith_pdb real*8 xx,yy,zz,shiftx,shifty,shiftz,proteinmass ith_pdb = iframe/nframes_between_pdbs j = ith_pdb/1E4 k = (ith_pdb - j*1E4)/1E3 l = (ith_pdb - j*1E4 - k*1E3)/1E2 m = (ith_pdb - j*1E4 - k*1E3 - l*1E2)/1E1 n = (ith_pdb - j*1E4 - k*1E3 - l*1E2 - m*1E1) open(26,file=trim(pdb_file_path)//char(48+j)//char(48+k)// 1 char(48+l)//char(48+m)//char(48+n)//'.pdb') c Have to convert from pbc applied on an atomic basis to pbc applied c on a residue basis. c Step 1: Recenter system based on protein c.o.m. shiftx = 0.0 shifty = 0.0 shiftz = 0.0 proteinmass = 0.0 do i = 1, natoms imolecule = molecule(i) if (imolecule <= nprotein_residues) then shiftx = shiftx + (x(1,i) + mytrue(1,i)*xprd)*mass(type(i)) shifty = shifty + (x(2,i) + mytrue(2,i)*yprd)*mass(type(i)) shiftz = shiftz + (x(3,i) + mytrue(3,i)*zprd)*mass(type(i)) proteinmass = proteinmass + mass(type(i)) endif enddo shiftx = shiftx/proteinmass shifty = shifty/proteinmass shiftz = shiftz/proteinmass do i = 1, natoms x(1,i) = x(1,i) - shiftx x(2,i) = x(2,i) - shifty x(3,i) = x(3,i) - shiftz enddo c Step 2: Find the c.o.m. of each residue --- "molecule" do i = 1, nmolecules comx(i) = 0.0 comy(i) = 0.0 comz(i) = 0.0 totmass(i) = 0.0 enddo do i = 1, natoms imolecule = molecule(i) comx(imolecule) = comx(imolecule) + 1 (x(1,i) + mytrue(1,i)*xprd)*mass(type(i)) comy(imolecule) = comy(imolecule) + 1 (x(2,i) + mytrue(2,i)*yprd)*mass(type(i)) comz(imolecule) = comz(imolecule) + 1 (x(3,i) + mytrue(3,i)*zprd)*mass(type(i)) totmass(imolecule) = totmass(imolecule) + mass(type(i)) enddo do i = 1, nmolecules comx(i) = comx(i)/totmass(i) comy(i) = comy(i)/totmass(i) comz(i) = comz(i)/totmass(i) enddo c Step 3: Decide how many boxes must be moved in each direction do i = 1, nmolecules nboxx(i) = nint(comx(i)/xprd) nboxy(i) = nint(comy(i)/yprd) nboxz(i) = nint(comz(i)/zprd) enddo c Step 4: Apply moves to atoms. Write pdb file. do i = 1, natoms imolecule = molecule(i) xx = x(1,i) + (mytrue(1,i) - nboxx(imolecule))*xprd yy = x(2,i) + (mytrue(2,i) - nboxy(imolecule))*yprd zz = x(3,i) + (mytrue(3,i) - nboxz(imolecule))*zprd write(26,100) outbeg(i),xx,yy,zz,outend(i) enddo 100 format(a30,3f8.3,a22) write(26,200) 'END' 200 format(a3) close(26) return end c ------------------------------------------------------------------------- subroutine mkpdb_start use global implicit none integer i character*76 pdbline(natoms),str open(25,file=trim(compare_file_path),status='old') rewind 25 do i = 1, natoms read(25,100) pdbline(i) enddo 100 format (a) do i = 1, natoms str = pdbline(i) read (str(1:30),100) outbeg(i) read (str(55:76),100) outend(i) enddo return end c ------------------------------------------------------------------------- c input data from config file subroutine read_config use global implicit none c local variables integer i,j,itag,itrue,ntotal real*8 buf(8) read(21,*) read(21,*) ntimestep read(21,*) read(21,*) ntotal read(21,*) read(21,*) box(1,1),box(2,1) read(21,*) box(1,2),box(2,2) read(21,*) box(1,3),box(2,3) read(21,*) if (ntotal /= natoms) write(6,*) 'Mismatch # of atoms' xprd = box(2,1) - box(1,1) yprd = box(2,2) - box(1,2) zprd = box(2,3) - box(1,3) do i = 1, natoms read (21,*) (buf(j),j=1,5) itag = nint(buf(1)) type(itag)= nint(buf(2)) x(1,itag) = buf(3)*xprd + box(1,1) x(2,itag) = buf(4)*yprd + box(1,2) x(3,itag) = buf(5)*zprd + box(1,3) mytrue(1,itag) = 0 mytrue(2,itag) = 0 mytrue(3,itag) = 0 enddo return end c ------------------------------------------------------------------------- c read data from input file subroutine read_data use global implicit none c local variables logical match integer i,j,jtmp,m,itag real*8 buf(7) character*80 str 900 format (a) open(27,file=trim(data_file_path),status='old') rewind 27 read (27,*) read (27,*) read (27,*) natoms read (27,*) nbonds read (27,*) nangles read (27,*) ndihedrals read (27,*) nimpropers read (27,*) read (27,*) ntypes if (nbonds.gt.0) read (27,*) nbondtypes if (nangles.gt.0) read (27,*) nangletypes if (ndihedrals.gt.0) read (27,*) ndihedtypes if (nimpropers.gt.0) read (27,*) nimprotypes read (27,*) read (27,*) read (27,*) read (27,*) allocate(q(natoms)) allocate(type(natoms)) allocate(molecule(natoms)) allocate(mass(natoms)) allocate(x(3,natoms)) allocate(mytrue(3,natoms)) allocate(outbeg(natoms)) allocate(outend(natoms)) do read (27,*,end=999,err=999) read (27,900,end=999,err=999) str read (27,*,end=999,err=999) if (match('All Done',str,m)) then goto 999 else if (match('Masses',str,m)) then write (6,*) 'Masses ...' do i = 1,ntypes read (27,*) jtmp,mass(i) enddo else if (match('Atoms',str,m)) then write (6,*) 'Atoms ...' do i = 1,natoms read (27,*) (buf(j),j=1,7) itag = nint(buf(1)) molecule(itag) = nint(buf(2)) type(itag) = nint(buf(3)) q(itag) = buf(4) enddo else if (match('Bonds',str,m)) then do i = 1,nbonds read (27,*) enddo else if (match('Angles',str,m)) then do i = 1,nangles read (27,*) enddo else if (match('Impropers',str,m)) then do i = 1,nimpropers read (27,*) enddo else if (match('Pair Coeffs',str,m)) then write (6,*) 'Pair Coeffs ...' do i = 1,ntypes read (27,*) enddo else if (match('Bond Coeffs',str,m)) then do i = 1,nbondtypes read (27,*) enddo else if (match('Angle Coeffs',str,m)) then do i = 1,nangletypes read (27,*) enddo else if (match('Dihedral Coeffs',str,m)) then do i = 1,ndihedtypes read (27,*) enddo else if (match('Dihedrals',str,m)) then do i = 1,ndihedrals read (27,*) enddo goto 999 else write (6,*) 'UNKNOWN: ',trim(str) write (6,*) 'Unknown identifier in data file' endif enddo 999 continue close (27) nmolecules = molecule(natoms) allocate(nboxx(nmolecules)) allocate(nboxy(nmolecules)) allocate(nboxz(nmolecules)) allocate(comx(nmolecules)) allocate(comy(nmolecules)) allocate(comz(nmolecules)) allocate(totmass(nmolecules)) return end c ------------------------------------------------------------------------- c read data from in_mkpdb file subroutine read_in_mkpdb use global implicit none 100 format (a) open(22,file='in_mkpdb') rewind 22 read (22,*) nconfig read (22,*) nper read (22,*) nconfig_skip read (22,*) nframes_between_pdbs read (22,*) nprotein_residues read (22,100) data_file_path read (22,100) config_file_path read (22,100) pdb_file_path read (22,100) compare_file_path nframes = nconfig*nper nskip = nconfig_skip*nper iframe = nskip close (22) return end c -------------------------------------------------------------------------
gpl-2.0
PeyloW/gcc-4.6.4
libgfortran/generated/_exp_c4.F90
22
1482
! Copyright 2002, 2007, 2009 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_COMPLEX_4) #ifdef HAVE_CEXPF elemental function _gfortran_specific__exp_c4 (parm) complex (kind=4), intent (in) :: parm complex (kind=4) :: _gfortran_specific__exp_c4 _gfortran_specific__exp_c4 = exp (parm) end function #endif #endif
gpl-2.0
anlongfei/gcc-4.8.4
gcc/testsuite/gfortran.dg/complex_intrinsic_5.f90
136
14154
! { dg-do run } ! ! PR fortran/33197 ! ! Complex inverse trigonometric functions ! and complex inverse hyperbolic functions ! ! Run-time evaluation check ! module test implicit none real(4), parameter :: eps4 = epsilon(0.0_4)*4.0_4 real(8), parameter :: eps8 = epsilon(0.0_8)*2.0_8 interface check procedure check4, check8 end interface check contains SUBROUTINE check4(z, zref) complex(4), intent(in) :: z, zref if ( abs (real(z)-real(zref)) > eps4 & .or.abs (aimag(z)-aimag(zref)) > eps4) then print '(a,/,2((2g0," + I ",g0),/))', "check4:"," z=",z,'zref=',zref print '(a,g0," + I*",g0," eps=",g0)', 'Diff: ', & real(z)-real(zref), & aimag(z)-aimag(zref), eps4 call abort() end if END SUBROUTINE check4 SUBROUTINE check8(z, zref) complex(8), intent(in) :: z, zref if ( abs (real(z)-real(zref)) > eps8 & .or.abs (aimag(z)-aimag(zref)) > eps8) then print '(a,/,2((2g0," + I ",g0),/))', "check8:"," z=",z,'zref=',zref print '(a,g0," + I*",g0," eps=",g0)', 'Diff: ', & real(z)-real(zref), & aimag(z)-aimag(zref), eps8 call abort() end if END SUBROUTINE check8 end module test PROGRAM ArcTrigHyp use test IMPLICIT NONE complex(4), volatile :: z4 complex(8), volatile :: z8 !!!!! ZERO !!!!!! ! z = 0 z4 = cmplx(0.0_4, 0.0_4, kind=4) z8 = cmplx(0.0_8, 0.0_8, kind=8) ! Exact: 0 call check(asin(z4), cmplx(0.0_4, 0.0_4, kind=4)) call check(asin(z8), cmplx(0.0_8, 0.0_8, kind=8)) ! Exact: Pi/2 = 1.5707963267948966192313216916397514 call check(acos(z4), cmplx(1.57079632679489661920_4, 0.0_4, kind=4)) call check(acos(z8), cmplx(1.57079632679489661920_8, 0.0_8, kind=8)) ! Exact: 0 call check(atan(z4), cmplx(0.0_4, 0.0_4, kind=4)) call check(atan(z8), cmplx(0.0_8, 0.0_8, kind=8)) ! Exact: 0 call check(asinh(z4), cmplx(0.0_4, 0.0_4, kind=4)) call check(asinh(z8), cmplx(0.0_8, 0.0_8, kind=8)) ! Exact: I*Pi/2 = I*1.5707963267948966192313216916397514 call check(acosh(z4), cmplx(0.0_4, 1.57079632679489661920_4, kind=4)) call check(acosh(z8), cmplx(0.0_8, 1.57079632679489661920_8, kind=8)) ! Exact: 0 call check(atanh(z4), cmplx(0.0_4, 0.0_4, kind=4)) call check(atanh(z8), cmplx(0.0_8, 0.0_8, kind=8)) !!!!! POSITIVE NUMBERS !!!!!! ! z = tanh(1.0) z4 = cmplx(0.76159415595576488811945828260479359_4, 0.0_4, kind=4) z8 = cmplx(0.76159415595576488811945828260479359_8, 0.0_8, kind=8) ! Numerically: 0.86576948323965862428960184619184444 call check(asin(z4), cmplx(0.86576948323965862428960184619184444_4, 0.0_4, kind=4)) call check(asin(z8), cmplx(0.86576948323965862428960184619184444_8, 0.0_8, kind=8)) ! Numerically: 0.70502684355523799494171984544790700 call check(acos(z4), cmplx(0.70502684355523799494171984544790700_4, 0.0_4, kind=4)) call check(acos(z8), cmplx(0.70502684355523799494171984544790700_8, 0.0_8, kind=8)) ! Numerically: 0.65088016802300754993807813168285564 call check(atan(z4), cmplx(0.65088016802300754993807813168285564_4, 0.0_4, kind=4)) call check(atan(z8), cmplx(0.65088016802300754993807813168285564_8, 0.0_8, kind=8)) ! Numerically: 0.70239670712987482778422106260749699 call check(asinh(z4), cmplx(0.70239670712987482778422106260749699_4, 0.0_4, kind=4)) call check(asinh(z8), cmplx(0.70239670712987482778422106260749699_8, 0.0_8, kind=8)) ! Numerically: 0.70502684355523799494171984544790700*I call check(acosh(z4), cmplx(0.0_4, 0.70502684355523799494171984544790700_4, kind=4)) call check(acosh(z8), cmplx(0.0_8, 0.70502684355523799494171984544790700_8, kind=8)) ! Exact: 1 call check(atanh(z4), cmplx(1.0_4, 0.0_4, kind=4)) call check(atanh(z8), cmplx(1.0_8, 0.0_8, kind=8)) ! z = I*tanh(1.0) z4 = cmplx(0.0_4, 0.76159415595576488811945828260479359_4, kind=4) z8 = cmplx(0.0_8, 0.76159415595576488811945828260479359_8, kind=8) ! Numerically: I*0.70239670712987482778422106260749699 call check(asin(z4), cmplx(0.0_4, 0.70239670712987482778422106260749699_4, kind=4)) call check(asin(z8), cmplx(0.0_8, 0.70239670712987482778422106260749699_8, kind=8)) ! Numerically: 1.5707963267948966192313216916397514 - I*0.7023967071298748277842210626074970 call check(acos(z4), cmplx(1.5707963267948966192313216916397514_4, -0.7023967071298748277842210626074970_4, kind=4)) call check(acos(z8), cmplx(1.5707963267948966192313216916397514_8, -0.7023967071298748277842210626074970_8, kind=8)) ! Exact: I*1 call check(atan(z4), cmplx(0.0_4, 1.0_4, kind=4)) call check(atan(z8), cmplx(0.0_8, 1.0_8, kind=8)) ! Numerically: I*0.86576948323965862428960184619184444 call check(asinh(z4), cmplx(0.0_4, 0.86576948323965862428960184619184444_4, kind=4)) call check(asinh(z8), cmplx(0.0_8, 0.86576948323965862428960184619184444_8, kind=8)) ! Numerically: 0.7023967071298748277842210626074970 + I*1.5707963267948966192313216916397514 call check(acosh(z4), cmplx(0.7023967071298748277842210626074970_4, 1.5707963267948966192313216916397514_4, kind=4)) call check(acosh(z8), cmplx(0.7023967071298748277842210626074970_8, 1.5707963267948966192313216916397514_8, kind=8)) ! Numerically: I*0.65088016802300754993807813168285564 call check(atanh(z4), cmplx(0.0_4, 0.65088016802300754993807813168285564_4, kind=4)) call check(atanh(z8), cmplx(0.0_8, 0.65088016802300754993807813168285564_8, kind=8)) ! z = (1+I)*tanh(1.0) z4 = cmplx(0.76159415595576488811945828260479359_4, 0.76159415595576488811945828260479359_4, kind=4) z8 = cmplx(0.76159415595576488811945828260479359_8, 0.76159415595576488811945828260479359_8, kind=8) ! Numerically: 0.59507386031622633330574869409179139 + I*0.82342412550090412964986631390412834 call check(asin(z4), cmplx(0.59507386031622633330574869409179139_4, 0.82342412550090412964986631390412834_4, kind=4)) call check(asin(z8), cmplx(0.59507386031622633330574869409179139_8, 0.82342412550090412964986631390412834_8, kind=8)) ! Numerically: 0.97572246647867028592557299754796005 - I*0.82342412550090412964986631390412834 call check(acos(z4), cmplx(0.97572246647867028592557299754796005_4, -0.82342412550090412964986631390412834_4, kind=4)) call check(acos(z8), cmplx(0.97572246647867028592557299754796005_8, -0.82342412550090412964986631390412834_8, kind=8)) ! Numerically: 0.83774433133636226305479129936568267 + I*0.43874835208710654149508159123595167 call check(atan(z4), cmplx(0.83774433133636226305479129936568267_4, 0.43874835208710654149508159123595167_4, kind=4)) call check(atan(z8), cmplx(0.83774433133636226305479129936568267_8, 0.43874835208710654149508159123595167_8, kind=8)) ! Numerically: 0.82342412550090412964986631390412834 + I*0.59507386031622633330574869409179139 call check(asinh(z4), cmplx(0.82342412550090412964986631390412834_4, 0.59507386031622633330574869409179139_4, kind=4)) call check(asinh(z8), cmplx(0.82342412550090412964986631390412834_8, 0.59507386031622633330574869409179139_8, kind=8)) ! Numerically: 0.82342412550090412964986631390412834 + I*0.97572246647867028592557299754796005 call check(acosh(z4), cmplx(0.82342412550090412964986631390412834_4, 0.97572246647867028592557299754796005_4, kind=4)) call check(acosh(z8), cmplx(0.82342412550090412964986631390412834_8, 0.97572246647867028592557299754796005_8, kind=8)) ! Numerically: 0.43874835208710654149508159123595167 + I*0.83774433133636226305479129936568267 call check(atanh(z4), cmplx(0.43874835208710654149508159123595167_4, 0.83774433133636226305479129936568267_4, kind=4)) call check(atanh(z8), cmplx(0.43874835208710654149508159123595167_8, 0.83774433133636226305479129936568267_8, kind=8)) ! z = 1+I z4 = cmplx(1.0_4, 1.0_4, kind=4) z8 = cmplx(1.0_8, 1.0_8, kind=8) ! Numerically: 0.66623943249251525510400489597779272 + I*1.06127506190503565203301891621357349 call check(asin(z4), cmplx(0.66623943249251525510400489597779272_4, 1.06127506190503565203301891621357349_4, kind=4)) call check(asin(z8), cmplx(0.66623943249251525510400489597779272_8, 1.06127506190503565203301891621357349_8, kind=8)) ! Numerically: 0.90455689430238136412731679566195872 - I*1.06127506190503565203301891621357349 call check(acos(z4), cmplx(0.90455689430238136412731679566195872_4, -1.06127506190503565203301891621357349_4, kind=4)) call check(acos(z8), cmplx(0.90455689430238136412731679566195872_8, -1.06127506190503565203301891621357349_8, kind=8)) ! Numerically: 1.01722196789785136772278896155048292 + I*0.40235947810852509365018983330654691 call check(atan(z4), cmplx(1.01722196789785136772278896155048292_4, 0.40235947810852509365018983330654691_4, kind=4)) call check(atan(z8), cmplx(1.01722196789785136772278896155048292_8, 0.40235947810852509365018983330654691_8, kind=8)) ! Numerically: 1.06127506190503565203301891621357349 + I*0.66623943249251525510400489597779272 call check(asinh(z4), cmplx(1.06127506190503565203301891621357349_4, 0.66623943249251525510400489597779272_4, kind=4)) call check(asinh(z8), cmplx(1.06127506190503565203301891621357349_8, 0.66623943249251525510400489597779272_8, kind=8)) ! Numerically: 1.06127506190503565203301891621357349 + I*0.90455689430238136412731679566195872 call check(acosh(z4), cmplx(1.06127506190503565203301891621357349_4, 0.90455689430238136412731679566195872_4, kind=4)) call check(acosh(z8), cmplx(1.06127506190503565203301891621357349_8, 0.90455689430238136412731679566195872_8, kind=8)) ! Numerically: 0.40235947810852509365018983330654691 + I*1.01722196789785136772278896155048292 call check(atanh(z4), cmplx(0.40235947810852509365018983330654691_4, 1.01722196789785136772278896155048292_4, kind=4)) call check(atanh(z8), cmplx(0.40235947810852509365018983330654691_8, 1.01722196789785136772278896155048292_8, kind=8)) ! z = (1+I)*1.1 z4 = cmplx(1.1_4, 1.1_4, kind=4) z8 = cmplx(1.1_8, 1.1_8, kind=8) ! Numerically: 0.68549840630267734494444454677951503 + I*1.15012680127435581678415521738176733 call check(asin(z4), cmplx(0.68549840630267734494444454677951503_4, 1.15012680127435581678415521738176733_4, kind=4)) call check(asin(z8), cmplx(0.68549840630267734494444454677951503_8, 1.15012680127435581678415521738176733_8, kind=8)) ! Numerically: 0.8852979204922192742868771448602364 - I*1.1501268012743558167841552173817673 call check(acos(z4), cmplx(0.8852979204922192742868771448602364_4, -1.1501268012743558167841552173817673_4, kind=4)) call check(acos(z8), cmplx(0.8852979204922192742868771448602364_8, -1.1501268012743558167841552173817673_8, kind=8)) ! Numerically: 1.07198475450905931839240655913126728 + I*0.38187020129010862908881230531688930 call check(atan(z4), cmplx(1.07198475450905931839240655913126728_4, 0.38187020129010862908881230531688930_4, kind=4)) call check(atan(z8), cmplx(1.07198475450905931839240655913126728_8, 0.38187020129010862908881230531688930_8, kind=8)) ! Numerically: 1.15012680127435581678415521738176733 + I*0.68549840630267734494444454677951503 call check(asinh(z4), cmplx(1.15012680127435581678415521738176733_4, 0.68549840630267734494444454677951503_4, kind=4)) call check(asinh(z8), cmplx(1.15012680127435581678415521738176733_8, 0.68549840630267734494444454677951503_8, kind=8)) ! Numerically: 1.1501268012743558167841552173817673 + I*0.8852979204922192742868771448602364 call check(acosh(z4), cmplx(1.1501268012743558167841552173817673_4, 0.8852979204922192742868771448602364_4, kind=4)) call check(acosh(z8), cmplx(1.1501268012743558167841552173817673_8, 0.8852979204922192742868771448602364_8, kind=8)) ! Numerically: 0.38187020129010862908881230531688930 + I*1.07198475450905931839240655913126728 call check(atanh(z4), cmplx(0.38187020129010862908881230531688930_4, 1.07198475450905931839240655913126728_4, kind=4)) call check(atanh(z8), cmplx(0.38187020129010862908881230531688930_8, 1.07198475450905931839240655913126728_8, kind=8)) !!!!! Negative NUMBERS !!!!!! ! z = -(1+I)*1.1 z4 = cmplx(-1.1_4, -1.1_4, kind=4) z8 = cmplx(-1.1_8, -1.1_8, kind=8) ! Numerically: -0.68549840630267734494444454677951503 - I*1.15012680127435581678415521738176733 call check(asin(z4), cmplx(-0.68549840630267734494444454677951503_4, -1.15012680127435581678415521738176733_4, kind=4)) call check(asin(z8), cmplx(-0.68549840630267734494444454677951503_8, -1.15012680127435581678415521738176733_8, kind=8)) ! Numerically: 2.2562947330975739641757662384192665 + I*1.1501268012743558167841552173817673 call check(acos(z4), cmplx(2.2562947330975739641757662384192665_4, 1.1501268012743558167841552173817673_4, kind=4)) call check(acos(z8), cmplx(2.2562947330975739641757662384192665_8, 1.1501268012743558167841552173817673_8, kind=8)) ! Numerically: -1.07198475450905931839240655913126728 - I*0.38187020129010862908881230531688930 call check(atan(z4), cmplx(-1.07198475450905931839240655913126728_4, -0.38187020129010862908881230531688930_4, kind=4)) call check(atan(z8), cmplx(-1.07198475450905931839240655913126728_8, -0.38187020129010862908881230531688930_8, kind=8)) ! Numerically: -1.15012680127435581678415521738176733 - I*0.68549840630267734494444454677951503 call check(asinh(z4), cmplx(-1.15012680127435581678415521738176733_4, -0.68549840630267734494444454677951503_4, kind=4)) call check(asinh(z8), cmplx(-1.15012680127435581678415521738176733_8, -0.68549840630267734494444454677951503_8, kind=8)) ! Numerically: 1.1501268012743558167841552173817673 - I*2.2562947330975739641757662384192665 call check(acosh(z4), cmplx(1.1501268012743558167841552173817673_4, -2.2562947330975739641757662384192665_4, kind=4)) call check(acosh(z8), cmplx(1.1501268012743558167841552173817673_8, -2.2562947330975739641757662384192665_8, kind=8)) ! Numerically: 0.38187020129010862908881230531688930 + I*1.07198475450905931839240655913126728 call check(atanh(z4), cmplx(-0.38187020129010862908881230531688930_4, -1.07198475450905931839240655913126728_4, kind=4)) call check(atanh(z8), cmplx(-0.38187020129010862908881230531688930_8, -1.07198475450905931839240655913126728_8, kind=8)) END PROGRAM ArcTrigHyp
gpl-2.0
PeyloW/gcc-4.6.4
libgfortran/generated/_asinh_r8.F90
22
1481
! Copyright 2002, 2007, 2009 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_ASINH elemental function _gfortran_specific__asinh_r8 (parm) real (kind=8), intent (in) :: parm real (kind=8) :: _gfortran_specific__asinh_r8 _gfortran_specific__asinh_r8 = asinh (parm) end function #endif #endif
gpl-2.0
anlongfei/gcc-4.8.4
libgfortran/generated/misc_specifics.F90
27
6990
! Copyright (C) 2002-2013 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" #if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__nint_4_4 (parm) real (kind=4) , intent (in) :: parm integer (kind=4) :: _gfortran_specific__nint_4_4 _gfortran_specific__nint_4_4 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__nint_4_8 (parm) real (kind=8) , intent (in) :: parm integer (kind=4) :: _gfortran_specific__nint_4_8 _gfortran_specific__nint_4_8 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__nint_4_10 (parm) real (kind=10) , intent (in) :: parm integer (kind=4) :: _gfortran_specific__nint_4_10 _gfortran_specific__nint_4_10 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__nint_4_16 (parm) real (kind=16) , intent (in) :: parm integer (kind=4) :: _gfortran_specific__nint_4_16 _gfortran_specific__nint_4_16 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__nint_8_4 (parm) real (kind=4) , intent (in) :: parm integer (kind=8) :: _gfortran_specific__nint_8_4 _gfortran_specific__nint_8_4 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__nint_8_8 (parm) real (kind=8) , intent (in) :: parm integer (kind=8) :: _gfortran_specific__nint_8_8 _gfortran_specific__nint_8_8 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__nint_8_10 (parm) real (kind=10) , intent (in) :: parm integer (kind=8) :: _gfortran_specific__nint_8_10 _gfortran_specific__nint_8_10 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__nint_8_16 (parm) real (kind=16) , intent (in) :: parm integer (kind=8) :: _gfortran_specific__nint_8_16 _gfortran_specific__nint_8_16 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__nint_16_4 (parm) real (kind=4) , intent (in) :: parm integer (kind=16) :: _gfortran_specific__nint_16_4 _gfortran_specific__nint_16_4 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__nint_16_8 (parm) real (kind=8) , intent (in) :: parm integer (kind=16) :: _gfortran_specific__nint_16_8 _gfortran_specific__nint_16_8 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__nint_16_10 (parm) real (kind=10) , intent (in) :: parm integer (kind=16) :: _gfortran_specific__nint_16_10 _gfortran_specific__nint_16_10 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__nint_16_16 (parm) real (kind=16) , intent (in) :: parm integer (kind=16) :: _gfortran_specific__nint_16_16 _gfortran_specific__nint_16_16 = nint (parm) end function #endif #if defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__char_1_i4 (parm) integer (kind=4) , intent (in) :: parm character (kind=1,len=1) :: _gfortran_specific__char_1_i4 _gfortran_specific__char_1_i4 = char (parm, kind=1) end function #endif #if defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__char_1_i8 (parm) integer (kind=8) , intent (in) :: parm character (kind=1,len=1) :: _gfortran_specific__char_1_i8 _gfortran_specific__char_1_i8 = char (parm, kind=1) end function #endif #if defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__char_1_i16 (parm) integer (kind=16) , intent (in) :: parm character (kind=1,len=1) :: _gfortran_specific__char_1_i16 _gfortran_specific__char_1_i16 = char (parm, kind=1) end function #endif #if defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__len_1_i4 (parm) character (kind=1,len=*) , intent (in) :: parm integer (kind=4) :: _gfortran_specific__len_1_i4 _gfortran_specific__len_1_i4 = len (parm) end function #endif #if defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__len_1_i8 (parm) character (kind=1,len=*) , intent (in) :: parm integer (kind=8) :: _gfortran_specific__len_1_i8 _gfortran_specific__len_1_i8 = len (parm) end function #endif #if defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__len_1_i16 (parm) character (kind=1,len=*) , intent (in) :: parm integer (kind=16) :: _gfortran_specific__len_1_i16 _gfortran_specific__len_1_i16 = len (parm) end function #endif #if defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__index_1_i4 (parm1, parm2) character (kind=1,len=*) , intent (in) :: parm1, parm2 integer (kind=4) :: _gfortran_specific__index_1_i4 _gfortran_specific__index_1_i4 = index (parm1, parm2) end function #endif #if defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__index_1_i8 (parm1, parm2) character (kind=1,len=*) , intent (in) :: parm1, parm2 integer (kind=8) :: _gfortran_specific__index_1_i8 _gfortran_specific__index_1_i8 = index (parm1, parm2) end function #endif #if defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__index_1_i16 (parm1, parm2) character (kind=1,len=*) , intent (in) :: parm1, parm2 integer (kind=16) :: _gfortran_specific__index_1_i16 _gfortran_specific__index_1_i16 = index (parm1, parm2) end function #endif
gpl-2.0
PeyloW/gcc-4.6.4
gcc/testsuite/gfortran.dg/mvbits_4.f90
174
1031
! { dg-do run } ! PR fortran/35681 ! Check that dependencies of MVBITS arguments are resolved correctly by using ! temporaries if both arguments refer to the same variable. integer, dimension(10) :: ila1 = (/1,2,3,4,5,6,7,8,9,10/) integer, dimension(20) :: ila2 integer, dimension(10), target :: ila3 integer, pointer :: ila3_ptr(:) integer, parameter :: SHOULD_BE(10) = (/17,18,11,4,13,22,7,16,9,18/) integer, parameter :: INDEX_VECTOR(10) = (/9,9,6,2,4,9,2,9,6,10/) ila2(2:20:2) = ila1 ila3 = ila1 ! Argument is already packed. call mvbits (ila1(INDEX_VECTOR), 2, 4, ila1, 3) write (*,'(10(I3))') ila1 if (any (ila1 /= SHOULD_BE)) call abort () ! Argument is not packed. call mvbits (ila2(2*INDEX_VECTOR), 2, 4, ila2(2:20:2), 3) write (*,'(10(I3))') ila2(2:20:2) if (any (ila2(2:20:2) /= SHOULD_BE)) call abort () ! Pointer and target ila3_ptr => ila3 call mvbits (ila3(INDEX_VECTOR), 2, 4, ila3_ptr, 3) write (*,'(10(I3))') ila3 if (any (ila3 /= SHOULD_BE)) call abort () end
gpl-2.0
PeyloW/gcc-4.6.4
gcc/testsuite/gfortran.fortran-torture/execute/entry_7.f90
190
2079
! Test alternate entry points for functions when the result types ! of all entry points match function f1 (a) integer a, b integer, pointer :: f1, e1 allocate (f1) f1 = 15 + a return entry e1 (b) allocate (e1) e1 = 42 + b end function function f2 () real, pointer :: f2, e2 entry e2 () allocate (e2) e2 = 45 end function function f3 () double precision, pointer :: f3, e3 entry e3 () allocate (f3) f3 = 47 end function function f4 (a) result (r) double precision a, b double precision, pointer :: r, s allocate (r) r = 15 + a return entry e4 (b) result (s) allocate (s) s = 42 + b end function function f5 () result (r) integer, pointer :: r, s entry e5 () result (s) allocate (r) r = 45 end function function f6 () result (r) real, pointer :: r, s entry e6 () result (s) allocate (s) s = 47 end function program entrytest interface function f1 (a) integer a integer, pointer :: f1 end function function e1 (b) integer b integer, pointer :: e1 end function function f2 () real, pointer :: f2 end function function e2 () real, pointer :: e2 end function function f3 () double precision, pointer :: f3 end function function e3 () double precision, pointer :: e3 end function function f4 (a) double precision a double precision, pointer :: f4 end function function e4 (b) double precision b double precision, pointer :: e4 end function function f5 () integer, pointer :: f5 end function function e5 () integer, pointer :: e5 end function function f6 () real, pointer :: f6 end function function e6 () real, pointer :: e6 end function end interface double precision d if (f1 (6) .ne. 21) call abort () if (e1 (7) .ne. 49) call abort () if (f2 () .ne. 45) call abort () if (e2 () .ne. 45) call abort () if (f3 () .ne. 47) call abort () if (e3 () .ne. 47) call abort () d = 17 if (f4 (d) .ne. 32) call abort () if (e4 (d) .ne. 59) call abort () if (f5 () .ne. 45) call abort () if (e5 () .ne. 45) call abort () if (f6 () .ne. 47) call abort () if (e6 () .ne. 47) call abort () end
gpl-2.0
CFDEMproject/LAMMPS
tools/eam_database/create.f
46
8594
C author: X. W. Zhou, xzhou@sandia.gov c open(unit=5,file='a.i') call inter c close(5) call writeset stop end ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c main subroutine. c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc subroutine inter character*80 atomtype,atommatch,outfile,outelem namelist /funccard/ atomtype common /pass1/ re(16),fe(16),rhoe(16),alpha(16), * beta(16),beta1(16),A(16),B(16),cai(16),ramda(16), * ramda1(16),Fi0(16),Fi1(16),Fi2(16),Fi3(16), * Fm0(16),Fm1(16),Fm2(16),Fm3(16),Fm4(16), * fnn(16),Fn(16),rhoin(16),rhoout(16),rhol(16), * rhoh(16),rhos(16) common /pass2/ ielement(16),amass(16),Fr(5000,16), * rhor(5000,16),z2r(5000,16,16),ntypes,blat(16), * nrho,drho,nr,dr,rc,outfile,outelem ntypes=0 10 continue atomtype='none' read(5,funccard) if (atomtype .eq. 'none') goto 1200 open(unit=10,file='EAM_code',form='FORMATTED',status='OLD') 11 read(10,9501,end=1210)atommatch 9501 format(a80) if (atomtype .eq. atommatch) then ntypes=ntypes+1 length=len_trim(outfile) if (length .eq. len(outfile)) then outfile = atomtype else outfile = outfile(1:length)//atomtype endif length=len_trim(outelem) if (length .eq. len(outelem)) then outelem = atomtype else outelem = outelem(1:length)//' '//atomtype endif read(10,*) re(ntypes) read(10,*) fe(ntypes) read(10,*) rhoe(ntypes) read(10,*) rhos(ntypes) read(10,*) alpha(ntypes) read(10,*) beta(ntypes) read(10,*) A(ntypes) read(10,*) B(ntypes) read(10,*) cai(ntypes) read(10,*) ramda(ntypes) read(10,*) Fi0(ntypes) read(10,*) Fi1(ntypes) read(10,*) Fi2(ntypes) read(10,*) Fi3(ntypes) read(10,*) Fm0(ntypes) read(10,*) Fm1(ntypes) read(10,*) Fm2(ntypes) read(10,*) Fm3(ntypes) read(10,*) fnn(ntypes) read(10,*) Fn(ntypes) read(10,*) ielement(ntypes) read(10,*) amass(ntypes) read(10,*) Fm4(ntypes) read(10,*) beta1(ntypes) read(10,*) ramda1(ntypes) read(10,*) rhol(ntypes) read(10,*) rhoh(ntypes) blat(ntypes)=sqrt(2.0)*re(ntypes) rhoin(ntypes)=rhol(ntypes)*rhoe(ntypes) rhoout(ntypes)=rhoh(ntypes)*rhoe(ntypes) else do 1 i=1,27 1 read(10,*)vtmp goto 11 endif close(10) goto 10 1210 write(6,*)'error: atom type ',atomtype,' not found' stop 1200 continue nr=2000 nrho=2000 alatmax=blat(1) rhoemax=rhoe(1) do 2 i=2,ntypes if (alatmax .lt. blat(i)) alatmax=blat(i) if (rhoemax .lt. rhoe(i)) rhoemax=rhoe(i) 2 continue rc=sqrt(10.0)/2.0*alatmax rst=0.5 dr=rc/(nr-1.0) fmax=-1.0 do 3 i1=1,ntypes do 3 i2=1,i1 if ( i1 .eq. i2) then do 4 i=1,nr r=(i-1.0)*dr if (r .lt. rst) r=rst call prof(i1,r,fvalue) if (fmax .lt. fvalue) fmax=fvalue rhor(i,i1)=fvalue call pair(i1,i2,r,psi) z2r(i,i1,i2)=r*psi 4 continue else do 5 i=1,nr r=(i-1.0)*dr if (r .lt. rst) r=rst call pair(i1,i2,r,psi) z2r(i,i1,i2)=r*psi z2r(i,i2,i1)=z2r(i,i1,i2) 5 continue endif 3 continue rhom=fmax if (rhom .lt. 2.0*rhoemax) rhom=2.0*rhoemax if (rhom .lt. 100.0) rhom=100.0 drho=rhom/(nrho-1.0) do 6 it=1,ntypes do 7 i=1,nrho rhoF=(i-1.0)*drho call embed(it,rhoF,emb) Fr(i,it)=emb 7 continue 6 continue return end ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c This subroutine calculates the electron density. c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc subroutine prof(it,r,f) common /pass1/ re(16),fe(16),rhoe(16),alpha(16), * beta(16),beta1(16),A(16),B(16),cai(16),ramda(16), * ramda1(16),Fi0(16),Fi1(16),Fi2(16),Fi3(16), * Fm0(16),Fm1(16),Fm2(16),Fm3(16),Fm4(16), * fnn(16),Fn(16),rhoin(16),rhoout(16),rhol(16), * rhoh(16),rhos(16) f=fe(it)*exp(-beta1(it)*(r/re(it)-1.0)) f=f/(1.0+(r/re(it)-ramda1(it))**20) return end ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c This subroutine calculates the pair potential. c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc subroutine pair(it1,it2,r,psi) common /pass1/ re(16),fe(16),rhoe(16),alpha(16), * beta(16),beta1(16),A(16),B(16),cai(16),ramda(16), * ramda1(16),Fi0(16),Fi1(16),Fi2(16),Fi3(16), * Fm0(16),Fm1(16),Fm2(16),Fm3(16),Fm4(16), * fnn(16),Fn(16),rhoin(16),rhoout(16),rhol(16), * rhoh(16),rhos(16) if (it1 .eq. it2) then psi1=A(it1)*exp(-alpha(it1)*(r/re(it1)-1.0)) psi1=psi1/(1.0+(r/re(it1)-cai(it1))**20) psi2=B(it1)*exp(-beta(it1)*(r/re(it1)-1.0)) psi2=psi2/(1.0+(r/re(it1)-ramda(it1))**20) psi=psi1-psi2 else psi1=A(it1)*exp(-alpha(it1)*(r/re(it1)-1.0)) psi1=psi1/(1.0+(r/re(it1)-cai(it1))**20) psi2=B(it1)*exp(-beta(it1)*(r/re(it1)-1.0)) psi2=psi2/(1.0+(r/re(it1)-ramda(it1))**20) psia=psi1-psi2 psi1=A(it2)*exp(-alpha(it2)*(r/re(it2)-1.0)) psi1=psi1/(1.0+(r/re(it2)-cai(it2))**20) psi2=B(it2)*exp(-beta(it2)*(r/re(it2)-1.0)) psi2=psi2/(1.0+(r/re(it2)-ramda(it2))**20) psib=psi1-psi2 call prof(it1,r,f1) call prof(it2,r,f2) psi=0.5*(f2/f1*psia+f1/f2*psib) endif return end ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c This subroutine calculates the embedding energy. c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc subroutine embed(it,rho,emb) common /pass1/ re(16),fe(16),rhoe(16),alpha(16), * beta(16),beta1(16),A(16),B(16),cai(16),ramda(16), * ramda1(16),Fi0(16),Fi1(16),Fi2(16),Fi3(16), * Fm0(16),Fm1(16),Fm2(16),Fm3(16),Fm4(16), * fnn(16),Fn(16),rhoin(16),rhoout(16),rhol(16), * rhoh(16),rhos(16) if (rho .lt. rhoe(it)) then Fm33=Fm3(it) else Fm33=Fm4(it) endif if (rho .lt. rhoin(it)) then emb=Fi0(it)+ * Fi1(it)*(rho/rhoin(it)-1.0)+ * Fi2(it)*(rho/rhoin(it)-1.0)**2+ * Fi3(it)*(rho/rhoin(it)-1.0)**3 else if (rho .lt. rhoout(it)) then emb=Fm0(it)+ * Fm1(it)*(rho/rhoe(it)-1.0)+ * Fm2(it)*(rho/rhoe(it)-1.0)**2+ * Fm33*(rho/rhoe(it)-1.0)**3 else emb=Fn(it)*(1.0-fnn(it)*log(rho/rhos(it)))* * (rho/rhos(it))**fnn(it) endif return end ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c write out set file. c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc subroutine writeset character*80 outfile,outelem common /pass1/ re(16),fe(16),rhoe(16),alpha(16), * beta(16),beta1(16),A(16),B(16),cai(16),ramda(16), * ramda1(16),Fi0(16),Fi1(16),Fi2(16),Fi3(16), * Fm0(16),Fm1(16),Fm2(16),Fm3(16),Fm4(16), * fnn(16),Fn(16),rhoin(16),rhoout(16),rhol(16), * rhoh(16),rhos(16) common /pass2/ ielement(16),amass(16),Fr(5000,16), * rhor(5000,16),z2r(5000,16,16),ntypes,blat(16), * nrho,drho,nr,dr,rc,outfile,outelem character*80 struc struc='fcc' outfile = outfile(1:index(outfile,' ')-1)//'.set' open(unit=1,file=outfile) write(1,*) write(1,*) write(1,*) write(1,8)ntypes,outelem 8 format(i5,' ',a24) write(1,9)nrho,drho,nr,dr,rc 9 format(i5,e24.16,i5,2e24.16) do 10 i=1,ntypes write(1,11)ielement(i),amass(i),blat(i),struc write(1,12)(Fr(j,i),j=1,nrho) write(1,12)(rhor(j,i),j=1,nr) 10 continue 11 format(i5,2g15.5,a8) 12 format(5e24.16) do 13 i1=1,ntypes do 13 i2=1,i1 write(1,12)(z2r(i,i1,i2),i=1,nr) 13 continue close(1) return end
gpl-2.0
PeyloW/gcc-4.6.4
libgfortran/generated/_abs_c10.F90
22
1485
! Copyright 2002, 2007, 2009 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_COMPLEX_10) #ifdef HAVE_CABSL elemental function _gfortran_specific__abs_c10 (parm) complex (kind=10), intent (in) :: parm real (kind=10) :: _gfortran_specific__abs_c10 _gfortran_specific__abs_c10 = abs (parm) end function #endif #endif
gpl-2.0
PeyloW/gcc-4.6.4
gcc/testsuite/gfortran.dg/merge_bits_1.F90
162
1304
! Test the MERGE_BITS intrinsic ! ! { dg-do run } ! { dg-options "-ffree-line-length-none" } interface run_merge procedure run_merge_1 procedure run_merge_2 procedure run_merge_4 procedure run_merge_8 end interface #define CHECK(I,J,K) \ if (merge_bits(I,J,K) /= ior(iand(I,K),iand(J,not(K)))) call abort ; \ if (run_merge(I,J,K) /= merge_bits(I,J,K)) call abort CHECK(13_1,18_1,22_1) CHECK(-13_1,18_1,22_1) CHECK(13_1,-18_1,22_1) CHECK(13_1,18_1,-22_1) CHECK(13_2,18_2,22_2) CHECK(-13_2,18_2,22_2) CHECK(13_2,-18_2,22_2) CHECK(13_2,18_2,-22_2) CHECK(13_4,18_4,22_4) CHECK(-13_4,18_4,22_4) CHECK(13_4,-18_4,22_4) CHECK(13_4,18_4,-22_4) CHECK(13_8,18_8,22_8) CHECK(-13_8,18_8,22_8) CHECK(13_8,-18_8,22_8) CHECK(13_8,18_8,-22_8) contains function run_merge_1 (i, j, k) result(res) integer(kind=1) :: i, j, k, res res = merge_bits(i,j,k) end function function run_merge_2 (i, j, k) result(res) integer(kind=2) :: i, j, k, res res = merge_bits(i,j,k) end function function run_merge_4 (i, j, k) result(res) integer(kind=4) :: i, j, k, res res = merge_bits(i,j,k) end function function run_merge_8 (i, j, k) result(res) integer(kind=8) :: i, j, k, res res = merge_bits(i,j,k) end function end
gpl-2.0
anlongfei/gcc-4.8.4
gcc/testsuite/gfortran.dg/backspace_10.f90
166
1220
! { dg-do run } ! PR33307 I/O read/positioning problem - in BACKSPACE ! Test case devloped from test in PR by Jerry DeLisle <jvdelisle@gcc.gnu.org> program gfcbug69b ! Modified example program implicit none integer, parameter :: iunit = 63 integer :: istat, k, ios character(len=20) :: line, message open (iunit) write (iunit, '(a)') "! ***Remove this line***" write (iunit, '(a)') "&FOO file='foo' /" write (iunit, '(a)', advance="no") "&BAR file='bar' /" close (iunit) ! Note: Failure occurred only when ACTION="read" was specified open (iunit, action="read", status="old") read (iunit,'(a)',iostat=ios) line if (ios /= 0) call abort read (iunit,'(a)',iostat=ios) line if (ios /= 0) call abort read (iunit,'(a)',iostat=ios) line if (ios /= 0) call abort read (iunit,'(a)',iostat=ios) line if (ios /= 0) backspace (iunit) rewind (iunit) read (iunit,'(a)',iostat=ios) line if (ios /= 0) call abort read (iunit,'(a)',iostat=ios) line if (ios /= 0) call abort read (iunit,'(a)',iostat=ios) line if (ios /= 0) call abort read (iunit,'(a)',iostat=ios) line if (ios /= -1) call abort close (iunit, status="delete") end program gfcbug69b
gpl-2.0
PeyloW/gcc-4.6.4
gcc/testsuite/gfortran.dg/open_errors.f90
105
1264
! { dg-do run { target { ! { *-*-mingw* *-*-cygwin* spu-*-* } } } } ! PR30005 Enhanced error messages for OPEN ! Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org> ! See PR38956. Test fails on cygwin when user has Administrator rights character(60) :: msg character(25) :: n = "temptestfile" logical :: there inquire(file=n, exist=there) if (.not.there) then open(77,file=n,status="new") close(77, status="keep") endif msg="" open(77,file=n,status="new", iomsg=msg, iostat=i) if (i == 0) call abort() if (msg /= "File 'temptestfile' already exists") call abort() open(77,file=n,status="old") close(77, status="delete") open(77,file=n,status="old", iomsg=msg, iostat=i) if (i == 0) call abort() if (msg /= "File 'temptestfile' does not exist") call abort() open(77,file="./", iomsg=msg, iostat=i) if (msg /= "'./' is a directory" .and. msg /= "Invalid argument") call abort() open(77,file=n,status="new") i = chmod(n, "-w") if (i == 0 .and. getuid() /= 0) then close(77, status="keep") open(77,file=n, iomsg=msg, iostat=i, action="write") if (i == 0) call abort() if (msg /= "Permission denied trying to open file 'temptestfile'") call abort() endif i = chmod(n,"+w") open(77,file=n, iomsg=msg, iostat=i, action="read") close(77, status="delete") end
gpl-2.0
PeyloW/gcc-4.6.4
gcc/testsuite/gfortran.dg/namelist_18.f90
166
1101
!{ dg-do run } !{ dg-options "-std=legacy" } ! ! Tests character delimiters for namelist write ! provided by Paul Thomas - pault@gcc.gnu.org program namelist_18 character*3 :: ch = "foo" character*80 :: buffer namelist /mynml/ ch open (10, status = "scratch") write (10, mynml) rewind (10) read (10, '(a)', iostat = ier) buffer read (10, '(a)', iostat = ier) buffer if (ier .ne. 0) call abort () close (10) If ((buffer(6:6) /= "f") .or. (buffer(9:9) /= """")) call abort () open (10, status = "scratch", delim ="quote") write (10, mynml) rewind (10) read (10, '(a)', iostat = ier) buffer read (10, '(a)', iostat = ier) buffer if (ier .ne. 0) call abort () close (10) If ((buffer(5:5) /= """") .or. (buffer(9:9) /= """")) call abort () open (10, status = "scratch", delim ="apostrophe") write (10, mynml) rewind (10) read (10, '(a)', iostat = ier) buffer read (10, '(a)', iostat = ier) buffer if (ier .ne. 0) call abort () close (10) If ((buffer(5:5) /= "'") .or. (buffer(9:9) /= "'")) call abort () end program namelist_18
gpl-2.0
anlongfei/gcc-4.8.4
libgfortran/generated/_exp_r4.F90
26
1468
! Copyright (C) 2002-2013 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_EXPF elemental function _gfortran_specific__exp_r4 (parm) real (kind=4), intent (in) :: parm real (kind=4) :: _gfortran_specific__exp_r4 _gfortran_specific__exp_r4 = exp (parm) end function #endif #endif
gpl-2.0
foss-for-synopsys-dwc-arc-processors/binutils-gdb
gdb/testsuite/gdb.fortran/array-slices.f90
5
11448
! Copyright 2019-2021 Free Software Foundation, Inc. ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 3 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. If not, see <http://www.gnu.org/licenses/>. subroutine show_elem (array) integer :: array print *, "" print *, "Expected GDB Output:" print *, "" write(*, fmt="(A)", advance="no") "GDB = " write(*, fmt="(I0)", advance="no") array write(*, fmt="(A)", advance="yes") "" print *, "" ! Display Element end subroutine show_elem subroutine show_str (array) character (len=*) :: array print *, "" print *, "Expected GDB Output:" print *, "" write (*, fmt="(A)", advance="no") "GDB = '" write (*, fmt="(A)", advance="no") array write (*, fmt="(A)", advance="yes") "'" print *, "" ! Display String end subroutine show_str subroutine show_1d (array) integer, dimension (:) :: array print *, "Array Contents:" print *, "" do i=LBOUND (array, 1), UBOUND (array, 1), 1 write(*, fmt="(i4)", advance="no") array (i) end do print *, "" print *, "Expected GDB Output:" print *, "" write(*, fmt="(A)", advance="no") "GDB = (" do i=LBOUND (array, 1), UBOUND (array, 1), 1 if (i > LBOUND (array, 1)) then write(*, fmt="(A)", advance="no") ", " end if write(*, fmt="(I0)", advance="no") array (i) end do write(*, fmt="(A)", advance="no") ")" print *, "" ! Display Array Slice 1D end subroutine show_1d subroutine show_2d (array) integer, dimension (:,:) :: array print *, "Array Contents:" print *, "" do i=LBOUND (array, 2), UBOUND (array, 2), 1 do j=LBOUND (array, 1), UBOUND (array, 1), 1 write(*, fmt="(i4)", advance="no") array (j, i) end do print *, "" end do print *, "" print *, "Expected GDB Output:" print *, "" write(*, fmt="(A)", advance="no") "GDB = (" do i=LBOUND (array, 2), UBOUND (array, 2), 1 if (i > LBOUND (array, 2)) then write(*, fmt="(A)", advance="no") " " end if write(*, fmt="(A)", advance="no") "(" do j=LBOUND (array, 1), UBOUND (array, 1), 1 if (j > LBOUND (array, 1)) then write(*, fmt="(A)", advance="no") ", " end if write(*, fmt="(I0)", advance="no") array (j, i) end do write(*, fmt="(A)", advance="no") ")" end do write(*, fmt="(A)", advance="yes") ")" print *, "" ! Display Array Slice 2D end subroutine show_2d subroutine show_3d (array) integer, dimension (:,:,:) :: array print *, "" print *, "Expected GDB Output:" print *, "" write(*, fmt="(A)", advance="no") "GDB = (" do i=LBOUND (array, 3), UBOUND (array, 3), 1 if (i > LBOUND (array, 3)) then write(*, fmt="(A)", advance="no") " " end if write(*, fmt="(A)", advance="no") "(" do j=LBOUND (array, 2), UBOUND (array, 2), 1 if (j > LBOUND (array, 2)) then write(*, fmt="(A)", advance="no") " " end if write(*, fmt="(A)", advance="no") "(" do k=LBOUND (array, 1), UBOUND (array, 1), 1 if (k > LBOUND (array, 1)) then write(*, fmt="(A)", advance="no") ", " end if write(*, fmt="(I0)", advance="no") array (k, j, i) end do write(*, fmt="(A)", advance="no") ")" end do write(*, fmt="(A)", advance="no") ")" end do write(*, fmt="(A)", advance="yes") ")" print *, "" ! Display Array Slice 3D end subroutine show_3d subroutine show_4d (array) integer, dimension (:,:,:,:) :: array print *, "" print *, "Expected GDB Output:" print *, "" write(*, fmt="(A)", advance="no") "GDB = (" do i=LBOUND (array, 4), UBOUND (array, 4), 1 if (i > LBOUND (array, 4)) then write(*, fmt="(A)", advance="no") " " end if write(*, fmt="(A)", advance="no") "(" do j=LBOUND (array, 3), UBOUND (array, 3), 1 if (j > LBOUND (array, 3)) then write(*, fmt="(A)", advance="no") " " end if write(*, fmt="(A)", advance="no") "(" do k=LBOUND (array, 2), UBOUND (array, 2), 1 if (k > LBOUND (array, 2)) then write(*, fmt="(A)", advance="no") " " end if write(*, fmt="(A)", advance="no") "(" do l=LBOUND (array, 1), UBOUND (array, 1), 1 if (l > LBOUND (array, 1)) then write(*, fmt="(A)", advance="no") ", " end if write(*, fmt="(I0)", advance="no") array (l, k, j, i) end do write(*, fmt="(A)", advance="no") ")" end do write(*, fmt="(A)", advance="no") ")" end do write(*, fmt="(A)", advance="no") ")" end do write(*, fmt="(A)", advance="yes") ")" print *, "" ! Display Array Slice 4D end subroutine show_4d ! ! Start of test program. ! program test interface subroutine show_str (array) character (len=*) :: array end subroutine show_str subroutine show_1d (array) integer, dimension (:) :: array end subroutine show_1d subroutine show_2d (array) integer, dimension(:,:) :: array end subroutine show_2d subroutine show_3d (array) integer, dimension(:,:,:) :: array end subroutine show_3d subroutine show_4d (array) integer, dimension(:,:,:,:) :: array end subroutine show_4d end interface ! Declare variables used in this test. integer, dimension (-10:-1,-10:-2) :: neg_array integer, dimension (1:10,1:10) :: array integer, allocatable :: other (:, :) character (len=26) :: str_1 = "abcdefghijklmnopqrstuvwxyz" integer, dimension (-2:2,-2:2,-2:2) :: array3d integer, dimension (-3:3,7:10,-3:3,-10:-7) :: array4d integer, dimension (10:20) :: array1d integer, dimension(:,:), pointer :: pointer2d => null() integer, dimension(-1:9,-1:9), target :: tarray ! Allocate or associate any variables as needed. allocate (other (-5:4, -2:7)) pointer2d => tarray ! Fill arrays with contents ready for testing. call fill_array_1d (array1d) call fill_array_2d (neg_array) call fill_array_2d (array) call fill_array_2d (other) call fill_array_2d (tarray) call fill_array_3d (array3d) call fill_array_4d (array4d) ! The tests. Each call to a show_* function must have a unique set ! of arguments as GDB uses the arguments are part of the test name ! string, so duplicate arguments will result in duplicate test ! names. ! ! If a show_* line ends with VARS=... where '...' is a comma ! separated list of variable names, these variables are assumed to ! be part of the call line, and will be expanded by the test script, ! for example: ! ! do x=1,9,1 ! do y=x,10,1 ! call show_1d (some_array (x,y)) ! VARS=x,y ! end do ! end do ! ! In this example the test script will automatically expand 'x' and ! 'y' in order to better test different aspects of GDB. Do take ! care, the expansion is not very "smart", so try to avoid clashing ! with other text on the line, in the example above, avoid variables ! named 'some' or 'array', as these will likely clash with ! 'some_array'. call show_str (str_1) call show_str (str_1 (1:20)) call show_str (str_1 (10:20)) call show_elem (array1d (11)) call show_elem (pointer2d (2,3)) call show_1d (array1d) call show_1d (array1d (13:17)) call show_1d (array1d (17:13:-1)) call show_1d (array (1:5,1)) call show_1d (array4d (1,7,3,:)) call show_1d (pointer2d (-1:3, 2)) call show_1d (pointer2d (-1, 2:4)) ! Enclosing the array slice argument in (...) causess gfortran to ! repack the array. call show_1d ((array (1:5,1))) call show_2d (pointer2d) call show_2d (array) call show_2d (array (1:5,1:5)) do i=1,10,2 do j=1,10,3 call show_2d (array (1:10:i,1:10:j)) ! VARS=i,j call show_2d (array (10:1:-i,1:10:j)) ! VARS=i,j call show_2d (array (10:1:-i,10:1:-j)) ! VARS=i,j call show_2d (array (1:10:i,10:1:-j)) ! VARS=i,j end do end do call show_2d (array (6:2:-1,3:9)) call show_2d (array (1:10:2, 1:10:2)) call show_2d (other) call show_2d (other (-5:0, -2:0)) call show_2d (other (-5:4:2, -2:7:3)) call show_2d (neg_array) call show_2d (neg_array (-10:-3,-8:-4:2)) ! Enclosing the array slice argument in (...) causess gfortran to ! repack the array. call show_2d ((array (1:10:3, 1:10:2))) call show_2d ((neg_array (-10:-3,-8:-4:2))) call show_3d (array3d) call show_3d (array3d(-1:1,-1:1,-1:1)) call show_3d (array3d(1:-1:-1,1:-1:-1,1:-1:-1)) ! Enclosing the array slice argument in (...) causess gfortran to ! repack the array. call show_3d ((array3d(1:-1:-1,1:-1:-1,1:-1:-1))) call show_4d (array4d) call show_4d (array4d (-3:0,10:7:-1,0:3,-7:-10:-1)) call show_4d (array4d (3:0:-1, 10:7:-1, :, -7:-10:-1)) ! Enclosing the array slice argument in (...) causess gfortran to ! repack the array. call show_4d ((array4d (3:-2:-2, 10:7:-2, :, -7:-10:-1))) ! All done. Deallocate. deallocate (other) ! GDB catches this final breakpoint to indicate the end of the test. print *, "" ! Final Breakpoint. contains ! Fill a 1D array with a unique positive integer in each element. subroutine fill_array_1d (array) integer, dimension (:) :: array integer :: counter counter = 1 do j=LBOUND (array, 1), UBOUND (array, 1), 1 array (j) = counter counter = counter + 1 end do end subroutine fill_array_1d ! Fill a 2D array with a unique positive integer in each element. subroutine fill_array_2d (array) integer, dimension (:,:) :: array integer :: counter counter = 1 do i=LBOUND (array, 2), UBOUND (array, 2), 1 do j=LBOUND (array, 1), UBOUND (array, 1), 1 array (j,i) = counter counter = counter + 1 end do end do end subroutine fill_array_2d ! Fill a 3D array with a unique positive integer in each element. subroutine fill_array_3d (array) integer, dimension (:,:,:) :: array integer :: counter counter = 1 do i=LBOUND (array, 3), UBOUND (array, 3), 1 do j=LBOUND (array, 2), UBOUND (array, 2), 1 do k=LBOUND (array, 1), UBOUND (array, 1), 1 array (k, j,i) = counter counter = counter + 1 end do end do end do end subroutine fill_array_3d ! Fill a 4D array with a unique positive integer in each element. subroutine fill_array_4d (array) integer, dimension (:,:,:,:) :: array integer :: counter counter = 1 do i=LBOUND (array, 4), UBOUND (array, 4), 1 do j=LBOUND (array, 3), UBOUND (array, 3), 1 do k=LBOUND (array, 2), UBOUND (array, 2), 1 do l=LBOUND (array, 1), UBOUND (array, 1), 1 array (l, k, j,i) = counter counter = counter + 1 end do end do end do end do print *, "" end subroutine fill_array_4d end program test
gpl-2.0
kleskjr/scipy
scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/sneigh.f
39
10381
c----------------------------------------------------------------------- c\BeginDoc c c\Name: sneigh c c\Description: c Compute the eigenvalues of the current upper Hessenberg matrix c and the corresponding Ritz estimates given the current residual norm. c c\Usage: c call sneigh c ( RNORM, N, H, LDH, RITZR, RITZI, BOUNDS, Q, LDQ, WORKL, IERR ) c c\Arguments c RNORM Real scalar. (INPUT) c Residual norm corresponding to the current upper Hessenberg c matrix H. c c N Integer. (INPUT) c Size of the matrix H. c c H Real N by N array. (INPUT) c H contains the current upper Hessenberg matrix. c c LDH Integer. (INPUT) c Leading dimension of H exactly as declared in the calling c program. c c RITZR, Real arrays of length N. (OUTPUT) c RITZI On output, RITZR(1:N) (resp. RITZI(1:N)) contains the real c (respectively imaginary) parts of the eigenvalues of H. c c BOUNDS Real array of length N. (OUTPUT) c On output, BOUNDS contains the Ritz estimates associated with c the eigenvalues RITZR and RITZI. This is equal to RNORM c times the last components of the eigenvectors corresponding c to the eigenvalues in RITZR and RITZI. c c Q Real N by N array. (WORKSPACE) c Workspace needed to store the eigenvectors of H. c c LDQ Integer. (INPUT) c Leading dimension of Q exactly as declared in the calling c program. c c WORKL Real work array of length N**2 + 3*N. (WORKSPACE) c Private (replicated) array on each PE or array allocated on c the front end. This is needed to keep the full Schur form c of H and also in the calculation of the eigenvectors of H. c c IERR Integer. (OUTPUT) c Error exit flag from slahqr or strevc. c c\EndDoc c c----------------------------------------------------------------------- c c\BeginLib c c\Local variables: c xxxxxx real c c\Routines called: c slahqr ARPACK routine to compute the real Schur form of an c upper Hessenberg matrix and last row of the Schur vectors. c arscnd ARPACK utility routine for timing. c smout ARPACK utility routine that prints matrices c svout ARPACK utility routine that prints vectors. c slacpy LAPACK matrix copy routine. c wslapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully. c strevc LAPACK routine to compute the eigenvectors of a matrix c in upper quasi-triangular form c sgemv Level 2 BLAS routine for matrix vector multiplication. c scopy Level 1 BLAS that copies one vector to another . c wsnrm2 Level 1 BLAS that computes the norm of a vector. c sscal Level 1 BLAS that scales a vector. c c c\Author c Danny Sorensen Phuong Vu c Richard Lehoucq CRPC / Rice University c Dept. of Computational & Houston, Texas c Applied Mathematics c Rice University c Houston, Texas c c\Revision history: c xx/xx/92: Version ' 2.1' c c\SCCS Information: @(#) c FILE: neigh.F SID: 2.3 DATE OF SID: 4/20/96 RELEASE: 2 c c\Remarks c None c c\EndLib c c----------------------------------------------------------------------- c subroutine sneigh (rnorm, n, h, ldh, ritzr, ritzi, bounds, & q, ldq, workl, ierr) 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 integer ierr, n, ldh, ldq Real & rnorm c c %-----------------% c | Array Arguments | c %-----------------% c Real & bounds(n), h(ldh,n), q(ldq,n), ritzi(n), ritzr(n), & workl(n*(n+3)) c c %------------% c | Parameters | c %------------% c Real & one, zero parameter (one = 1.0E+0, zero = 0.0E+0) c c %------------------------% c | Local Scalars & Arrays | c %------------------------% c logical select(1) integer i, iconj, msglvl Real & temp, vl(1) c c %----------------------% c | External Subroutines | c %----------------------% c external scopy, slacpy, slahqr, strevc, svout, arscnd c c %--------------------% c | External Functions | c %--------------------% c Real & wslapy2, wsnrm2 external wslapy2, wsnrm2 c c %---------------------% c | Intrinsic Functions | c %---------------------% c intrinsic abs c c %-----------------------% c | Executable Statements | c %-----------------------% c c c %-------------------------------% c | Initialize timing statistics | c | & message level for debugging | c %-------------------------------% c call arscnd (t0) msglvl = mneigh c if (msglvl .gt. 2) then call smout (logfil, n, n, h, ldh, ndigit, & '_neigh: Entering upper Hessenberg matrix H ') end if c c %-----------------------------------------------------------% c | 1. Compute the eigenvalues, the last components of the | c | corresponding Schur vectors and the full Schur form T | c | of the current upper Hessenberg matrix H. | c | slahqr returns the full Schur form of H in WORKL(1:N**2) | c | and the last components of the Schur vectors in BOUNDS. | c %-----------------------------------------------------------% c call slacpy ('All', n, n, h, ldh, workl, n) do 5 j = 1, n-1 bounds(j) = zero 5 continue bounds(n) = one call slahqr(.true., .true., n, 1, n, workl, n, ritzr, ritzi, 1, 1, & bounds, 1, ierr) if (ierr .ne. 0) go to 9000 c if (msglvl .gt. 1) then call svout (logfil, n, bounds, ndigit, & '_neigh: last row of the Schur matrix for H') end if c c %-----------------------------------------------------------% c | 2. Compute the eigenvectors of the full Schur form T and | c | apply the last components of the Schur vectors to get | c | the last components of the corresponding eigenvectors. | c | Remember that if the i-th and (i+1)-st eigenvalues are | c | complex conjugate pairs, then the real & imaginary part | c | of the eigenvector components are split across adjacent | c | columns of Q. | c %-----------------------------------------------------------% c call strevc ('R', 'A', select, n, workl, n, vl, n, q, ldq, & n, n, workl(n*n+1), ierr) c if (ierr .ne. 0) go to 9000 c c %------------------------------------------------% c | Scale the returning eigenvectors so that their | c | euclidean norms are all one. LAPACK subroutine | c | strevc returns each eigenvector normalized so | c | that the element of largest magnitude has | c | magnitude 1; here the magnitude of a complex | c | number (x,y) is taken to be |x| + |y|. | c %------------------------------------------------% c iconj = 0 do 10 i=1, n if ( abs( ritzi(i) ) .le. zero ) then c c %----------------------% c | Real eigenvalue case | c %----------------------% c temp = wsnrm2( n, q(1,i), 1 ) call sscal ( n, one / temp, q(1,i), 1 ) else c c %-------------------------------------------% c | Complex conjugate pair case. Note that | c | since the real and imaginary part of | c | the eigenvector are stored in consecutive | c | columns, we further normalize by the | c | square root of two. | c %-------------------------------------------% c if (iconj .eq. 0) then temp = wslapy2( wsnrm2( n, q(1,i), 1 ), & wsnrm2( n, q(1,i+1), 1 ) ) call sscal ( n, one / temp, q(1,i), 1 ) call sscal ( n, one / temp, q(1,i+1), 1 ) iconj = 1 else iconj = 0 end if end if 10 continue c call sgemv ('T', n, n, one, q, ldq, bounds, 1, zero, workl, 1) c if (msglvl .gt. 1) then call svout (logfil, n, workl, ndigit, & '_neigh: Last row of the eigenvector matrix for H') end if c c %----------------------------% c | Compute the Ritz estimates | c %----------------------------% c iconj = 0 do 20 i = 1, n if ( abs( ritzi(i) ) .le. zero ) then c c %----------------------% c | Real eigenvalue case | c %----------------------% c bounds(i) = rnorm * abs( workl(i) ) else c c %-------------------------------------------% c | Complex conjugate pair case. Note that | c | since the real and imaginary part of | c | the eigenvector are stored in consecutive | c | columns, we need to take the magnitude | c | of the last components of the two vectors | c %-------------------------------------------% c if (iconj .eq. 0) then bounds(i) = rnorm * wslapy2( workl(i), workl(i+1) ) bounds(i+1) = bounds(i) iconj = 1 else iconj = 0 end if end if 20 continue c if (msglvl .gt. 2) then call svout (logfil, n, ritzr, ndigit, & '_neigh: Real part of the eigenvalues of H') call svout (logfil, n, ritzi, ndigit, & '_neigh: Imaginary part of the eigenvalues of H') call svout (logfil, n, bounds, ndigit, & '_neigh: Ritz estimates for the eigenvalues of H') end if c call arscnd (t1) tneigh = tneigh + (t1 - t0) c 9000 continue return c c %---------------% c | End of sneigh | c %---------------% c end
bsd-3-clause
kleskjr/scipy
scipy/optimize/lbfgsb/linpack.f
147
5978
subroutine dpofa(a,lda,n,info) integer lda,n,info double precision a(lda,*) c c dpofa factors a double precision symmetric positive definite c matrix. c c dpofa is usually called by dpoco, but it can be called c directly with a saving in time if rcond is not needed. c (time for dpoco) = (1 + 18/n)*(time for dpofa) . c c on entry c c a double precision(lda, n) c the symmetric matrix to be factored. only the c diagonal and upper triangle are used. c c lda integer c the leading dimension of the array a . c c n integer c the order of the matrix a . c c on return c c a an upper triangular matrix r so that a = trans(r)*r c where trans(r) is the transpose. c the strict lower triangle is unaltered. c if info .ne. 0 , the factorization is not complete. c c info integer c = 0 for normal return. c = k signals an error condition. the leading minor c of order k is not positive definite. c c linpack. this version dated 08/14/78 . c cleve moler, university of new mexico, argonne national lab. c c subroutines and functions c c blas ddot c fortran sqrt c c internal variables c double precision ddot,t double precision s integer j,jm1,k c begin block with ...exits to 40 c c do 30 j = 1, n info = j s = 0.0d0 jm1 = j - 1 if (jm1 .lt. 1) go to 20 do 10 k = 1, jm1 t = a(k,j) - ddot(k-1,a(1,k),1,a(1,j),1) t = t/a(k,k) a(k,j) = t s = s + t*t 10 continue 20 continue s = a(j,j) - s c ......exit if (s .le. 0.0d0) go to 40 a(j,j) = sqrt(s) 30 continue info = 0 40 continue return end c====================== The end of dpofa =============================== subroutine dtrsl(t,ldt,n,b,job,info) integer ldt,n,job,info double precision t(ldt,*),b(*) c c c dtrsl solves systems of the form c c t * x = b c or c trans(t) * x = b c c where t is a triangular matrix of order n. here trans(t) c denotes the transpose of the matrix t. c c on entry c c t double precision(ldt,n) c t contains the matrix of the system. the zero c elements of the matrix are not referenced, and c the corresponding elements of the array can be c used to store other information. c c ldt integer c ldt is the leading dimension of the array t. c c n integer c n is the order of the system. c c b double precision(n). c b contains the right hand side of the system. c c job integer c job specifies what kind of system is to be solved. c if job is c c 00 solve t*x=b, t lower triangular, c 01 solve t*x=b, t upper triangular, c 10 solve trans(t)*x=b, t lower triangular, c 11 solve trans(t)*x=b, t upper triangular. c c on return c c b b contains the solution, if info .eq. 0. c otherwise b is unaltered. c c info integer c info contains zero if the system is nonsingular. c otherwise info contains the index of c the first zero diagonal element of t. c c linpack. this version dated 08/14/78 . c g. w. stewart, university of maryland, argonne national lab. c c subroutines and functions c c blas daxpy,ddot c fortran mod c c internal variables c double precision ddot,temp integer case,j,jj c c begin block permitting ...exits to 150 c c check for zero diagonal elements. c do 10 info = 1, n c ......exit if (t(info,info) .eq. 0.0d0) go to 150 10 continue info = 0 c c determine the task and go to it. c case = 1 if (mod(job,10) .ne. 0) case = 2 if (mod(job,100)/10 .ne. 0) case = case + 2 go to (20,50,80,110), case c c solve t*x=b for t lower triangular c 20 continue b(1) = b(1)/t(1,1) if (n .lt. 2) go to 40 do 30 j = 2, n temp = -b(j-1) call daxpy(n-j+1,temp,t(j,j-1),1,b(j),1) b(j) = b(j)/t(j,j) 30 continue 40 continue go to 140 c c solve t*x=b for t upper triangular. c 50 continue b(n) = b(n)/t(n,n) if (n .lt. 2) go to 70 do 60 jj = 2, n j = n - jj + 1 temp = -b(j+1) call daxpy(j,temp,t(1,j+1),1,b(1),1) b(j) = b(j)/t(j,j) 60 continue 70 continue go to 140 c c solve trans(t)*x=b for t lower triangular. c 80 continue b(n) = b(n)/t(n,n) if (n .lt. 2) go to 100 do 90 jj = 2, n j = n - jj + 1 b(j) = b(j) - ddot(jj-1,t(j+1,j),1,b(j+1),1) b(j) = b(j)/t(j,j) 90 continue 100 continue go to 140 c c solve trans(t)*x=b for t upper triangular. c 110 continue b(1) = b(1)/t(1,1) if (n .lt. 2) go to 130 do 120 j = 2, n b(j) = b(j) - ddot(j-1,t(1,j),1,b(1),1) b(j) = b(j)/t(j,j) 120 continue 130 continue 140 continue 150 continue return end c====================== The end of dtrsl ===============================
bsd-3-clause
kleskjr/scipy
scipy/interpolate/fitpack/bispev.f
115
3933
subroutine bispev(tx,nx,ty,ny,c,kx,ky,x,mx,y,my,z,wrk,lwrk, * iwrk,kwrk,ier) c subroutine bispev evaluates on a grid (x(i),y(j)),i=1,...,mx; j=1,... c ,my a bivariate spline s(x,y) of degrees kx and ky, given in the c b-spline representation. c c calling sequence: c call bispev(tx,nx,ty,ny,c,kx,ky,x,mx,y,my,z,wrk,lwrk, c * iwrk,kwrk,ier) c c input parameters: c tx : real array, length nx, which contains the position of the c knots in the x-direction. c nx : integer, giving the total number of knots in the x-direction c ty : real array, length ny, which contains the position of the c knots in the y-direction. c ny : integer, giving the total number of knots in the y-direction c c : real array, length (nx-kx-1)*(ny-ky-1), which contains the c b-spline coefficients. c kx,ky : integer values, giving the degrees of the spline. c x : real array of dimension (mx). c before entry x(i) must be set to the x co-ordinate of the c i-th grid point along the x-axis. c tx(kx+1)<=x(i-1)<=x(i)<=tx(nx-kx), i=2,...,mx. c mx : on entry mx must specify the number of grid points along c the x-axis. mx >=1. c y : real array of dimension (my). c before entry y(j) must be set to the y co-ordinate of the c j-th grid point along the y-axis. c ty(ky+1)<=y(j-1)<=y(j)<=ty(ny-ky), j=2,...,my. c my : on entry my must specify the number of grid points along c the y-axis. my >=1. c wrk : real array of dimension lwrk. used as workspace. c lwrk : integer, specifying the dimension of wrk. c lwrk >= mx*(kx+1)+my*(ky+1) c iwrk : integer array of dimension kwrk. used as workspace. c kwrk : integer, specifying the dimension of iwrk. kwrk >= mx+my. c c output parameters: c z : real array of dimension (mx*my). c on succesful exit z(my*(i-1)+j) contains the value of s(x,y) c at the point (x(i),y(j)),i=1,...,mx;j=1,...,my. c ier : integer error flag c ier=0 : normal return c ier=10: invalid input data (see restrictions) c c restrictions: c mx >=1, my >=1, lwrk>=mx*(kx+1)+my*(ky+1), kwrk>=mx+my c tx(kx+1) <= x(i-1) <= x(i) <= tx(nx-kx), i=2,...,mx c ty(ky+1) <= y(j-1) <= y(j) <= ty(ny-ky), j=2,...,my c c other subroutines required: c fpbisp,fpbspl c c references : c de boor c : on calculating with b-splines, j. approximation theory c 6 (1972) 50-62. c cox m.g. : the numerical evaluation of b-splines, j. inst. maths c applics 10 (1972) 134-149. c dierckx p. : curve and surface fitting with splines, monographs on c numerical analysis, oxford university press, 1993. c c author : c p.dierckx c dept. computer science, k.u.leuven c celestijnenlaan 200a, b-3001 heverlee, belgium. c e-mail : Paul.Dierckx@cs.kuleuven.ac.be c c latest update : march 1987 c c ..scalar arguments.. integer nx,ny,kx,ky,mx,my,lwrk,kwrk,ier c ..array arguments.. integer iwrk(kwrk) real*8 tx(nx),ty(ny),c((nx-kx-1)*(ny-ky-1)),x(mx),y(my),z(mx*my), * wrk(lwrk) c ..local scalars.. integer i,iw,lwest c .. c before starting computations a data check is made. if the input data c are invalid control is immediately repassed to the calling program. ier = 10 lwest = (kx+1)*mx+(ky+1)*my if(lwrk.lt.lwest) go to 100 if(kwrk.lt.(mx+my)) go to 100 if (mx.lt.1) go to 100 if (mx.eq.1) go to 30 go to 10 10 do 20 i=2,mx if(x(i).lt.x(i-1)) go to 100 20 continue 30 if (my.lt.1) go to 100 if (my.eq.1) go to 60 go to 40 40 do 50 i=2,my if(y(i).lt.y(i-1)) go to 100 50 continue 60 ier = 0 iw = mx*(kx+1)+1 call fpbisp(tx,nx,ty,ny,c,kx,ky,x,mx,y,my,z,wrk(1),wrk(iw), * iwrk(1),iwrk(mx+1)) 100 return end
bsd-3-clause
anlongfei/gcc-4.8.4
gcc/testsuite/gfortran.dg/achar_6.F90
174
1711
! { dg-do run } ! { dg-options "-fbackslash" } #define TEST(x,y,z) \ call test (x, y, z, iachar(x), iachar(y), ichar(x), ichar(y)) TEST("a", 4_"a", 97) TEST("\0", 4_"\0", 0) TEST("\b", 4_"\b", 8) TEST("\x80", 4_"\x80", int(z'80')) TEST("\xFF", 4_"\xFF", int(z'FF')) #define TEST2(y,z) \ call test_bis (y, z, iachar(y), ichar(y)) TEST2(4_"\u0100", int(z'0100')) TEST2(4_"\ufe00", int(z'fe00')) TEST2(4_"\u106a", int(z'106a')) TEST2(4_"\uff00", int(z'ff00')) TEST2(4_"\uffff", int(z'ffff')) contains subroutine test (s1, s4, i, i1, i2, i3, i4) character(kind=1,len=1) :: s1 character(kind=4,len=1) :: s4 integer :: i, i1, i2, i3, i4 if (i /= i1) call abort if (i /= i2) call abort if (i /= i3) call abort if (i /= i4) call abort if (iachar (s1) /= i) call abort if (iachar (s4) /= i) call abort if (ichar (s1) /= i) call abort if (ichar (s4) /= i) call abort if (achar(i, kind=1) /= s1) call abort if (achar(i, kind=4) /= s4) call abort if (char(i, kind=1) /= s1) call abort if (char(i, kind=4) /= s4) call abort if (iachar(achar(i, kind=1)) /= i) call abort if (iachar(achar(i, kind=4)) /= i) call abort if (ichar(char(i, kind=1)) /= i) call abort if (ichar(char(i, kind=4)) /= i) call abort end subroutine test subroutine test_bis (s4, i, i2, i4) character(kind=4,len=1) :: s4 integer :: i, i2, i4 if (i /= i2) call abort if (i /= i4) call abort if (iachar (s4) /= i) call abort if (ichar (s4) /= i) call abort if (achar(i, kind=4) /= s4) call abort if (char(i, kind=4) /= s4) call abort if (iachar(achar(i, kind=4)) /= i) call abort if (ichar(char(i, kind=4)) /= i) call abort end subroutine test_bis end
gpl-2.0
anlongfei/gcc-4.8.4
gcc/testsuite/gfortran.dg/module_procedure_1.f90
136
1087
! { dg-do run } ! Modified program from http://groups.google.com/group/\ ! comp.lang.fortran/browse_frm/thread/423e4392dc965ab7# ! module myoperator contains function dadd(arg1,arg2) integer ::dadd(2) integer, intent(in) :: arg1(2), arg2(2) dadd(1)=arg1(1)+arg2(1) dadd(2)=arg1(2)+arg2(2) end function dadd end module myoperator program test_interface use myoperator implicit none interface operator (.myadd.) module procedure dadd end interface integer input1(2), input2(2), mysum(2) input1 = (/0,1/) input2 = (/3,3/) mysum = input1 .myadd. input2 if (mysum(1) /= 3 .and. mysum(2) /= 4) call abort call test_sub(input1, input2) end program test_interface subroutine test_sub(input1, input2) use myoperator implicit none interface operator (.myadd.) module procedure dadd end interface integer, intent(in) :: input1(2), input2(2) integer mysum(2) mysum = input1 .myadd. input2 if (mysum(1) /= 3 .and. mysum(2) /= 4) call abort end subroutine test_sub
gpl-2.0
kleskjr/scipy
scipy/special/cdflib/gaminv.f
151
10511
SUBROUTINE gaminv(a,x,x0,p,q,ierr) C ---------------------------------------------------------------------- C INVERSE INCOMPLETE GAMMA RATIO FUNCTION C C GIVEN POSITIVE A, AND NONEGATIVE P AND Q WHERE P + Q = 1. C THEN X IS COMPUTED WHERE P(A,X) = P AND Q(A,X) = Q. SCHRODER C ITERATION IS EMPLOYED. THE ROUTINE ATTEMPTS TO COMPUTE X C TO 10 SIGNIFICANT DIGITS IF THIS IS POSSIBLE FOR THE C PARTICULAR COMPUTER ARITHMETIC BEING USED. C C ------------ C C X IS A VARIABLE. IF P = 0 THEN X IS ASSIGNED THE VALUE 0, C AND IF Q = 0 THEN X IS SET TO THE LARGEST FLOATING POINT C NUMBER AVAILABLE. OTHERWISE, GAMINV ATTEMPTS TO OBTAIN C A SOLUTION FOR P(A,X) = P AND Q(A,X) = Q. IF THE ROUTINE C IS SUCCESSFUL THEN THE SOLUTION IS STORED IN X. C C X0 IS AN OPTIONAL INITIAL APPROXIMATION FOR X. IF THE USER C DOES NOT WISH TO SUPPLY AN INITIAL APPROXIMATION, THEN SET C X0 .LE. 0. C C IERR IS A VARIABLE THAT REPORTS THE STATUS OF THE RESULTS. C WHEN THE ROUTINE TERMINATES, IERR HAS ONE OF THE FOLLOWING C VALUES ... C C IERR = 0 THE SOLUTION WAS OBTAINED. ITERATION WAS C NOT USED. C IERR.GT.0 THE SOLUTION WAS OBTAINED. IERR ITERATIONS C WERE PERFORMED. C IERR = -2 (INPUT ERROR) A .LE. 0 C IERR = -3 NO SOLUTION WAS OBTAINED. THE RATIO Q/A C IS TOO LARGE. C IERR = -4 (INPUT ERROR) P + Q .NE. 1 C IERR = -6 20 ITERATIONS WERE PERFORMED. THE MOST C RECENT VALUE OBTAINED FOR X IS GIVEN. C THIS CANNOT OCCUR IF X0 .LE. 0. C IERR = -7 ITERATION FAILED. NO VALUE IS GIVEN FOR X. C THIS MAY OCCUR WHEN X IS APPROXIMATELY 0. C IERR = -8 A VALUE FOR X HAS BEEN OBTAINED, BUT THE C ROUTINE IS NOT CERTAIN OF ITS ACCURACY. C ITERATION CANNOT BE PERFORMED IN THIS C CASE. IF X0 .LE. 0, THIS CAN OCCUR ONLY C WHEN P OR Q IS APPROXIMATELY 0. IF X0 IS C POSITIVE THEN THIS CAN OCCUR WHEN A IS C EXCEEDINGLY CLOSE TO X AND A IS EXTREMELY C LARGE (SAY A .GE. 1.E20). C ---------------------------------------------------------------------- C WRITTEN BY ALFRED H. MORRIS, JR. C NAVAL SURFACE WEAPONS CENTER C DAHLGREN, VIRGINIA C ------------------- C .. Scalar Arguments .. DOUBLE PRECISION a,p,q,x,x0 INTEGER ierr C .. C .. Local Scalars .. DOUBLE PRECISION a0,a1,a2,a3,am1,amax,ap1,ap2,ap3,apn,b,b1,b2,b3, + b4,c,c1,c2,c3,c4,c5,d,e,e2,eps,g,h,ln10,pn,qg,qn, + r,rta,s,s2,sum,t,tol,u,w,xmax,xmin,xn,y,z INTEGER iop C .. C .. Local Arrays .. DOUBLE PRECISION amin(2),bmin(2),dmin(2),emin(2),eps0(2) C .. C .. External Functions .. DOUBLE PRECISION alnrel,gamln,gamln1,gamma,rcomp,spmpar EXTERNAL alnrel,gamln,gamln1,gamma,rcomp,spmpar C .. C .. External Subroutines .. EXTERNAL gratio C .. C .. Intrinsic Functions .. INTRINSIC abs,dble,dlog,dmax1,exp,sqrt C .. C .. Data statements .. C ------------------- C LN10 = LN(10) C C = EULER CONSTANT C ------------------- C ------------------- C ------------------- C ------------------- DATA ln10/2.302585D0/ DATA c/.577215664901533D0/ DATA a0/3.31125922108741D0/,a1/11.6616720288968D0/, + a2/4.28342155967104D0/,a3/.213623493715853D0/ DATA b1/6.61053765625462D0/,b2/6.40691597760039D0/, + b3/1.27364489782223D0/,b4/.036117081018842D0/ DATA eps0(1)/1.D-10/,eps0(2)/1.D-08/ DATA amin(1)/500.0D0/,amin(2)/100.0D0/ DATA bmin(1)/1.D-28/,bmin(2)/1.D-13/ DATA dmin(1)/1.D-06/,dmin(2)/1.D-04/ DATA emin(1)/2.D-03/,emin(2)/6.D-03/ DATA tol/1.D-5/ C .. C .. Executable Statements .. C ------------------- C ****** E, XMIN, AND XMAX ARE MACHINE DEPENDENT CONSTANTS. C E IS THE SMALLEST NUMBER FOR WHICH 1.0 + E .GT. 1.0. C XMIN IS THE SMALLEST POSITIVE NUMBER AND XMAX IS THE C LARGEST POSITIVE NUMBER. C e = spmpar(1) xmin = spmpar(2) xmax = spmpar(3) C ------------------- x = 0.0D0 IF (a.LE.0.0D0) GO TO 300 t = dble(p) + dble(q) - 1.D0 IF (abs(t).GT.e) GO TO 320 C ierr = 0 IF (p.EQ.0.0D0) RETURN IF (q.EQ.0.0D0) GO TO 270 IF (a.EQ.1.0D0) GO TO 280 C e2 = 2.0D0*e amax = 0.4D-10/ (e*e) iop = 1 IF (e.GT.1.D-10) iop = 2 eps = eps0(iop) xn = x0 IF (x0.GT.0.0D0) GO TO 160 C C SELECTION OF THE INITIAL APPROXIMATION XN OF X C WHEN A .LT. 1 C IF (a.GT.1.0D0) GO TO 80 g = gamma(a+1.0D0) qg = q*g IF (qg.EQ.0.0D0) GO TO 360 b = qg/a IF (qg.GT.0.6D0*a) GO TO 40 IF (a.GE.0.30D0 .OR. b.LT.0.35D0) GO TO 10 t = exp(- (b+c)) u = t*exp(t) xn = t*exp(u) GO TO 160 C 10 IF (b.GE.0.45D0) GO TO 40 IF (b.EQ.0.0D0) GO TO 360 y = -dlog(b) s = 0.5D0 + (0.5D0-a) z = dlog(y) t = y - s*z IF (b.LT.0.15D0) GO TO 20 xn = y - s*dlog(t) - dlog(1.0D0+s/ (t+1.0D0)) GO TO 220 20 IF (b.LE.0.01D0) GO TO 30 u = ((t+2.0D0* (3.0D0-a))*t+ (2.0D0-a)* (3.0D0-a))/ + ((t+ (5.0D0-a))*t+2.0D0) xn = y - s*dlog(t) - dlog(u) GO TO 220 30 c1 = -s*z c2 = -s* (1.0D0+c1) c3 = s* ((0.5D0*c1+ (2.0D0-a))*c1+ (2.5D0-1.5D0*a)) c4 = -s* (((c1/3.0D0+ (2.5D0-1.5D0*a))*c1+ ((a-6.0D0)*a+7.0D0))* + c1+ ((11.0D0*a-46)*a+47.0D0)/6.0D0) c5 = -s* ((((-c1/4.0D0+ (11.0D0*a-17.0D0)/6.0D0)*c1+ ((-3.0D0*a+ + 13.0D0)*a-13.0D0))*c1+0.5D0* (((2.0D0*a-25.0D0)*a+72.0D0)*a- + 61.0D0))*c1+ (((25.0D0*a-195.0D0)*a+477.0D0)*a-379.0D0)/ + 12.0D0) xn = ((((c5/y+c4)/y+c3)/y+c2)/y+c1) + y IF (a.GT.1.0D0) GO TO 220 IF (b.GT.bmin(iop)) GO TO 220 x = xn RETURN C 40 IF (b*q.GT.1.D-8) GO TO 50 xn = exp(- (q/a+c)) GO TO 70 50 IF (p.LE.0.9D0) GO TO 60 xn = exp((alnrel(-q)+gamln1(a))/a) GO TO 70 60 xn = exp(dlog(p*g)/a) 70 IF (xn.EQ.0.0D0) GO TO 310 t = 0.5D0 + (0.5D0-xn/ (a+1.0D0)) xn = xn/t GO TO 160 C C SELECTION OF THE INITIAL APPROXIMATION XN OF X C WHEN A .GT. 1 C 80 IF (q.LE.0.5D0) GO TO 90 w = dlog(p) GO TO 100 90 w = dlog(q) 100 t = sqrt(-2.0D0*w) s = t - (((a3*t+a2)*t+a1)*t+a0)/ ((((b4*t+b3)*t+b2)*t+b1)*t+1.0D0) IF (q.GT.0.5D0) s = -s C rta = sqrt(a) s2 = s*s xn = a + s*rta + (s2-1.0D0)/3.0D0 + s* (s2-7.0D0)/ (36.0D0*rta) - + ((3.0D0*s2+7.0D0)*s2-16.0D0)/ (810.0D0*a) + + s* ((9.0D0*s2+256.0D0)*s2-433.0D0)/ (38880.0D0*a*rta) xn = dmax1(xn,0.0D0) IF (a.LT.amin(iop)) GO TO 110 x = xn d = 0.5D0 + (0.5D0-x/a) IF (abs(d).LE.dmin(iop)) RETURN C 110 IF (p.LE.0.5D0) GO TO 130 IF (xn.LT.3.0D0*a) GO TO 220 y = - (w+gamln(a)) d = dmax1(2.0D0,a* (a-1.0D0)) IF (y.LT.ln10*d) GO TO 120 s = 1.0D0 - a z = dlog(y) GO TO 30 120 t = a - 1.0D0 xn = y + t*dlog(xn) - alnrel(-t/ (xn+1.0D0)) xn = y + t*dlog(xn) - alnrel(-t/ (xn+1.0D0)) GO TO 220 C 130 ap1 = a + 1.0D0 IF (xn.GT.0.70D0*ap1) GO TO 170 w = w + gamln(ap1) IF (xn.GT.0.15D0*ap1) GO TO 140 ap2 = a + 2.0D0 ap3 = a + 3.0D0 x = exp((w+x)/a) x = exp((w+x-dlog(1.0D0+ (x/ap1)* (1.0D0+x/ap2)))/a) x = exp((w+x-dlog(1.0D0+ (x/ap1)* (1.0D0+x/ap2)))/a) x = exp((w+x-dlog(1.0D0+ (x/ap1)* (1.0D0+ (x/ap2)* (1.0D0+ + x/ap3))))/a) xn = x IF (xn.GT.1.D-2*ap1) GO TO 140 IF (xn.LE.emin(iop)*ap1) RETURN GO TO 170 C 140 apn = ap1 t = xn/apn sum = 1.0D0 + t 150 apn = apn + 1.0D0 t = t* (xn/apn) sum = sum + t IF (t.GT.1.D-4) GO TO 150 t = w - dlog(sum) xn = exp((xn+t)/a) xn = xn* (1.0D0- (a*dlog(xn)-xn-t)/ (a-xn)) GO TO 170 C C SCHRODER ITERATION USING P C 160 IF (p.GT.0.5D0) GO TO 220 170 IF (p.LE.1.D10*xmin) GO TO 350 am1 = (a-0.5D0) - 0.5D0 180 IF (a.LE.amax) GO TO 190 d = 0.5D0 + (0.5D0-xn/a) IF (abs(d).LE.e2) GO TO 350 C 190 IF (ierr.GE.20) GO TO 330 ierr = ierr + 1 CALL gratio(a,xn,pn,qn,0) IF (pn.EQ.0.0D0 .OR. qn.EQ.0.0D0) GO TO 350 r = rcomp(a,xn) IF (r.EQ.0.0D0) GO TO 350 t = (pn-p)/r w = 0.5D0* (am1-xn) IF (abs(t).LE.0.1D0 .AND. abs(w*t).LE.0.1D0) GO TO 200 x = xn* (1.0D0-t) IF (x.LE.0.0D0) GO TO 340 d = abs(t) GO TO 210 C 200 h = t* (1.0D0+w*t) x = xn* (1.0D0-h) IF (x.LE.0.0D0) GO TO 340 IF (abs(w).GE.1.0D0 .AND. abs(w)*t*t.LE.eps) RETURN d = abs(h) 210 xn = x IF (d.GT.tol) GO TO 180 IF (d.LE.eps) RETURN IF (abs(p-pn).LE.tol*p) RETURN GO TO 180 C C SCHRODER ITERATION USING Q C 220 IF (q.LE.1.D10*xmin) GO TO 350 am1 = (a-0.5D0) - 0.5D0 230 IF (a.LE.amax) GO TO 240 d = 0.5D0 + (0.5D0-xn/a) IF (abs(d).LE.e2) GO TO 350 C 240 IF (ierr.GE.20) GO TO 330 ierr = ierr + 1 CALL gratio(a,xn,pn,qn,0) IF (pn.EQ.0.0D0 .OR. qn.EQ.0.0D0) GO TO 350 r = rcomp(a,xn) IF (r.EQ.0.0D0) GO TO 350 t = (q-qn)/r w = 0.5D0* (am1-xn) IF (abs(t).LE.0.1D0 .AND. abs(w*t).LE.0.1D0) GO TO 250 x = xn* (1.0D0-t) IF (x.LE.0.0D0) GO TO 340 d = abs(t) GO TO 260 C 250 h = t* (1.0D0+w*t) x = xn* (1.0D0-h) IF (x.LE.0.0D0) GO TO 340 IF (abs(w).GE.1.0D0 .AND. abs(w)*t*t.LE.eps) RETURN d = abs(h) 260 xn = x IF (d.GT.tol) GO TO 230 IF (d.LE.eps) RETURN IF (abs(q-qn).LE.tol*q) RETURN GO TO 230 C C SPECIAL CASES C 270 x = xmax RETURN C 280 IF (q.LT.0.9D0) GO TO 290 x = -alnrel(-p) RETURN 290 x = -dlog(q) RETURN C C ERROR RETURN C 300 ierr = -2 RETURN C 310 ierr = -3 RETURN C 320 ierr = -4 RETURN C 330 ierr = -6 RETURN C 340 ierr = -7 RETURN C 350 x = xn ierr = -8 RETURN C 360 x = xmax ierr = -8 RETURN END
bsd-3-clause
anlongfei/gcc-4.8.4
gcc/testsuite/gfortran.dg/pointer_check_2.f90
185
1629
! { dg-do run } ! { dg-options "-fcheck=pointer" } ! { dg-shouldfail "Unassociated/unallocated actual argument" } ! ! { dg-output ".*At line 60.*Pointer actual argument 'ptr1' is not associated" } ! ! PR fortran/40580 ! ! Run-time check of passing deallocated/nonassociated actuals ! to nonallocatable/nonpointer dummies. ! ! Check for variable actuals ! subroutine test1(a) integer :: a a = 4444 end subroutine test1 subroutine test2(a) integer :: a(2) a = 4444 end subroutine test2 subroutine ppTest(f) implicit none external f call f() end subroutine ppTest Program RunTimeCheck implicit none external :: test1, test2, ppTest integer, pointer :: ptr1, ptr2(:) integer, allocatable :: alloc2(:) procedure(), pointer :: pptr allocate(ptr1,ptr2(2),alloc2(2)) pptr => sub ! OK call test1(ptr1) call test3(ptr1) call test2(ptr2) call test2(alloc2) call test4(ptr2) call test4(alloc2) call ppTest(pptr) call ppTest2(pptr) ! Invalid 1: deallocate(alloc2) ! call test2(alloc2) ! call test4(alloc2) ! Invalid 2: deallocate(ptr1,ptr2) nullify(ptr1,ptr2) ! call test1(ptr1) call test3(ptr1) ! call test2(ptr2) ! call test4(ptr2) ! Invalid 3: nullify(pptr) ! call ppTest(pptr) call ppTest2(pptr) contains subroutine test3(b) integer :: b b = 333 end subroutine test3 subroutine test4(b) integer :: b(2) b = 333 end subroutine test4 subroutine sub() print *, 'Hello World' end subroutine sub subroutine ppTest2(f) implicit none procedure(sub) :: f call f() end subroutine ppTest2 end Program RunTimeCheck
gpl-2.0
PeyloW/gcc-4.6.4
gcc/testsuite/gfortran.fortran-torture/compile/pr32663.f
193
4377
SUBROUTINE DIMOID(DEN,RLMO,SSQU,STRI,ATMU,IATM,IWHI,MAPT,INAT, * IATB,L1,L2,M1,M2,NATS,NOSI,NCAT,NSWE) C IMPLICIT DOUBLE PRECISION(A-H,O-Z) C DIMENSION RLMO(L1,L1),SSQU(L1,L1),STRI(L2),ATMU(NATS),DEN(M2) DIMENSION IATM(NATS,M1),IWHI(M1+NATS),MAPT(M1),INAT(M1+NATS) DIMENSION IATB(NATS,M1) C PARAMETER (MXATM=500, MXSH=1000, MXGTOT=5000, MXAO=2047) C LOGICAL GOPARR,DSKWRK,MASWRK C COMMON /INFOA / NAT,ICH,MUL,NUM,NQMT,NE,NA,NB, * ZAN(MXATM),C(3,MXATM) COMMON /IOFILE/ IR,IW,IP,IJKO,IJKT,IDAF,NAV,IODA(400) COMMON /NSHEL / EX(MXGTOT),CS(MXGTOT),CP(MXGTOT),CD(MXGTOT), * CF(MXGTOT),CG(MXGTOT), * KSTART(MXSH),KATOM(MXSH),KTYPE(MXSH), * KNG(MXSH),KLOC(MXSH),KMIN(MXSH), * KMAX(MXSH),NSHELL COMMON /OPTLOC/ CVGLOC,MAXLOC,IPRTLO,ISYMLO,IFCORE,NOUTA,NOUTB, * MOOUTA(MXAO),MOOUTB(MXAO) COMMON /PAR / ME,MASTER,NPROC,IBTYP,IPTIM,GOPARR,DSKWRK,MASWRK COMMON /RUNLAB/ TITLE(10),A(MXATM),B(MXATM),BFLAB(MXAO) C C DO 920 II=1,M1 INAT(II) = 0 920 CONTINUE C DO 900 IO = NOUTA+1,NUMLOC IZ = IO - NOUTA DO 895 II=NST,NEND ATMU(II) = 0.0D+00 IATM(II,IZ) = 0 895 CONTINUE IFUNC = 0 DO 890 ISHELL = 1,NSHELL IAT = KATOM(ISHELL) IST = KMIN(ISHELL) IEN = KMAX(ISHELL) DO 880 INO = IST,IEN IFUNC = IFUNC + 1 IF (IAT.LT.NST.OR.IAT.GT.NEND) GOTO 880 ZINT = 0.0D+00 DO 870 II = 1,L1 ZINT = ZINT + RLMO(II,IO)*SSQU(II,IFUNC) 870 CONTINUE ATMU(IAT) = ATMU(IAT) + RLMO(IFUNC,IO)*ZINT 880 CONTINUE 890 CONTINUE IF (MASWRK) WRITE(IW,9010) IZ,(ATMU(II),II=NST,NEND) 900 CONTINUE C NOSI = 0 DO 700 II=1,M1 NO=0 DO 720 JJ=1,NAT NO = NO + 1 720 CONTINUE 740 CONTINUE IF (NO.GT.1.OR.NO.EQ.0) THEN NOSI = NOSI + 1 IWHI(NOSI) = II ENDIF IF (MASWRK) * WRITE(IW,9030) II,(IATM(J,II),A(IATM(J,II)),J=1,NO) 700 CONTINUE C IF (MASWRK) THEN WRITE(IW,9035) NOSI IF (NOSI.GT.0) THEN WRITE(IW,9040) (IWHI(I),I=1,NOSI) WRITE(IW,9040) ELSE WRITE(IW,9040) ENDIF ENDIF C CALL DCOPY(L1*L1,RLMO,1,SSQU,1) CALL DCOPY(M2,DEN,1,STRI,1) C IP2 = NOUTA IS2 = M1+NOUTA-NOSI DO 695 II=1,NAT INAT(II) = 0 695 CONTINUE C DO 690 IAT=1,NAT DO 680 IORB=1,M1 IP1 = IORB + NOUTA IF (IATM(1,IORB).NE.IAT) GOTO 680 IF (IATM(2,IORB).NE.0) GOTO 680 INAT(IAT) = INAT(IAT) + 1 IP2 = IP2 + 1 CALL DCOPY(L1,SSQU(1,IP1),1,RLMO(1,IP2),1) CALL ICOPY(NAT,IATM(1,IORB),1,IATB(1,IP2-NOUTA),1) MAPT(IORB) = IP2-NOUTA 680 CONTINUE DO 670 IORB=1,NOSI IS1 = IWHI(IORB) + NOUTA IF (IAT.EQ.NAT.AND.IATM(1,IWHI(IORB)).EQ.0) GOTO 675 IF (IATM(1,IWHI(IORB)).NE.IAT) GOTO 670 675 CONTINUE IS2 = IS2 + 1 MAPT(IWHI(IORB)) = IS2-NOUTA 670 CONTINUE 690 CONTINUE C NSWE = 0 NCAT = 0 LASP = 1 NLAST = 0 DO 620 II=1,NAT NSWE = NSWE + (IWHI(II)*(IWHI(II)-1))/2 NCAT = NCAT + 1 INAT(NCAT) = LASP + NLAST LASP = INAT(NCAT) NLAST = IWHI(II) IWHI(NCAT) = II 620 CONTINUE C DO 610 II=1,NOSI NCAT = NCAT + 1 INAT(NCAT) = LASP + NLAST LASP = INAT(NCAT) NLAST = 1 IWHI(NCAT) = 0 610 CONTINUE C RETURN C 8000 FORMAT(/1X,'** MULLIKEN ATOMIC POPULATIONS FOR EACH NON-FROZEN ', * 'LOCALIZED ORBITAL **') 9000 FORMAT(/3X,'ATOM',2X,100(I2,1X,A4)) 9005 FORMAT(1X,'LMO') 9010 FORMAT(1X,I3,3X,100F7.3) 9015 FORMAT(/1X,'** ATOMIC POPULATIONS GREATER THAN ',F4.2, * ' ARE CONSIDERED MAJOR **') 9020 FORMAT(/2X,'LMO',3X,'MAJOR CONTRIBUTIONS FROM ATOM(S)') 9030 FORMAT(2X,I3,2X,100(I2,1X,A2,2X)) 9035 FORMAT(/1X,'NO OF LMOS INVOLVING MORE THAN ONE ATOM =',I3) 9040 FORMAT(1X,'THESE ARE LMOS :',100I3) C END
gpl-2.0
slitvinov/lammps-swimmer
lib/linalg/dcopy.f
191
2631
*> \brief \b DCOPY * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE DCOPY(N,DX,INCX,DY,INCY) * * .. Scalar Arguments .. * INTEGER INCX,INCY,N * .. * .. Array Arguments .. * DOUBLE PRECISION DX(*),DY(*) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DCOPY copies a vector, x, to a vector, y. *> uses unrolled loops for increments equal to one. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup double_blas_level1 * *> \par Further Details: * ===================== *> *> \verbatim *> *> jack dongarra, linpack, 3/11/78. *> modified 12/3/93, array(1) declarations changed to array(*) *> \endverbatim *> * ===================================================================== SUBROUTINE DCOPY(N,DX,INCX,DY,INCY) * * -- Reference BLAS level1 routine (version 3.4.0) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. INTEGER INCX,INCY,N * .. * .. Array Arguments .. DOUBLE PRECISION DX(*),DY(*) * .. * * ===================================================================== * * .. Local Scalars .. INTEGER I,IX,IY,M,MP1 * .. * .. Intrinsic Functions .. INTRINSIC MOD * .. IF (N.LE.0) RETURN IF (INCX.EQ.1 .AND. INCY.EQ.1) THEN * * code for both increments equal to 1 * * * clean-up loop * M = MOD(N,7) IF (M.NE.0) THEN DO I = 1,M DY(I) = DX(I) END DO IF (N.LT.7) RETURN END IF MP1 = M + 1 DO I = MP1,N,7 DY(I) = DX(I) DY(I+1) = DX(I+1) DY(I+2) = DX(I+2) DY(I+3) = DX(I+3) DY(I+4) = DX(I+4) DY(I+5) = DX(I+5) DY(I+6) = DX(I+6) END DO ELSE * * code for unequal increments or equal increments * not equal to 1 * IX = 1 IY = 1 IF (INCX.LT.0) IX = (-N+1)*INCX + 1 IF (INCY.LT.0) IY = (-N+1)*INCY + 1 DO I = 1,N DY(IY) = DX(IX) IX = IX + INCX IY = IY + INCY END DO END IF RETURN END
gpl-2.0
JasonRuonanWang/ADIOS2
testing/adios2/bindings/fortran/operation/TestBPWriteReadZfp2D.F90
1
9076
program TestBPWriteReadHeatMapZfp2D use mpi use adios2 implicit none integer(kind=8) :: sum_i1, sum_i2 type(adios2_adios) :: adios type(adios2_io) :: ioPut, ioGet type(adios2_engine) :: bpWriter, bpReader type(adios2_variable), dimension(6) :: var_temperatures, var_temperaturesIn type(adios2_operator) :: zfp_operator integer:: operation_id integer(kind=1), dimension(:, :), allocatable :: temperatures_i1, & sel_temperatures_i1 integer(kind=2), dimension(:, :), allocatable :: temperatures_i2, & sel_temperatures_i2 integer(kind=4), dimension(:, :), allocatable :: temperatures_i4, & sel_temperatures_i4 integer(kind=8), dimension(:, :), allocatable :: temperatures_i8, & sel_temperatures_i8 real(kind=4), dimension(:, :), allocatable :: temperatures_r4, & sel_temperatures_r4 real(kind=8), dimension(:, :), allocatable :: temperatures_r8, & sel_temperatures_r8 integer(kind=8), dimension(2) :: ishape, istart, icount integer(kind=8), dimension(2) :: sel_start, sel_count integer :: ierr, irank, isize integer :: in1, in2 integer :: i1, i2 call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD, irank, ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD, isize, ierr) in1 = 10 in2 = 10 icount = (/in1, in2/) istart = (/0, in2*irank/) ishape = (/in1, in2*isize/) allocate (temperatures_i1(in1, in2)) allocate (temperatures_i2(in1, in2)) allocate (temperatures_i4(in1, in2)) allocate (temperatures_i8(in1, in2)) allocate (temperatures_r4(in1, in2)) allocate (temperatures_r8(in1, in2)) temperatures_i1 = 1 temperatures_i2 = 1 temperatures_i4 = 1 temperatures_i8 = 1_8 temperatures_r4 = 1.0 temperatures_r8 = 1.0_8 ! Start adios2 Writer call adios2_init(adios, MPI_COMM_WORLD, adios2_debug_mode_on, ierr) call adios2_declare_io(ioPut, adios, 'HeatMapWrite', ierr) call adios2_define_variable(var_temperatures(1), ioPut, & 'temperatures_i1', adios2_type_integer1, & 2, ishape, istart, icount, & adios2_constant_dims, ierr) call adios2_define_variable(var_temperatures(2), ioPut, & 'temperatures_i2', adios2_type_integer2, & 2, ishape, istart, icount, & adios2_constant_dims, ierr) call adios2_define_variable(var_temperatures(3), ioPut, & 'temperatures_i4', adios2_type_integer4, & 2, ishape, istart, icount, & adios2_constant_dims, ierr) call adios2_define_variable(var_temperatures(4), ioPut, & 'temperatures_i8', adios2_type_integer8, & 2, ishape, istart, icount, & adios2_constant_dims, ierr) call adios2_define_operator(zfp_operator, adios, 'CompressorZfp', 'zfp', ierr) call adios2_define_variable(var_temperatures(5), ioPut, & 'temperatures_r4', adios2_type_real, & 2, ishape, istart, icount, & adios2_constant_dims, ierr) call adios2_add_operation(operation_id, var_temperatures(5), & zfp_operator, 'rate', '8', ierr) if( operation_id /= 0 ) stop 'operation_id not added for real type' call adios2_define_variable(var_temperatures(6), ioPut, & 'temperatures_r8', adios2_type_dp, & 2, ishape, istart, icount, & adios2_constant_dims, ierr) call adios2_add_operation(operation_id, var_temperatures(6), & zfp_operator, 'rate', '8', ierr) if( operation_id /= 0 ) stop 'operation_id not added for dp type' call adios2_open(bpWriter, ioPut, 'HeatMapZfp2D_f.bp', adios2_mode_write, & ierr) call adios2_put(bpWriter, var_temperatures(1), temperatures_i1, ierr) call adios2_put(bpWriter, var_temperatures(2), temperatures_i2, ierr) call adios2_put(bpWriter, var_temperatures(3), temperatures_i4, ierr) call adios2_put(bpWriter, var_temperatures(4), temperatures_i8, ierr) call adios2_put(bpWriter, var_temperatures(5), temperatures_r4, ierr) call adios2_put(bpWriter, var_temperatures(6), temperatures_r8, ierr) call adios2_close(bpWriter, ierr) if (allocated(temperatures_i1)) deallocate (temperatures_i1) if (allocated(temperatures_i2)) deallocate (temperatures_i2) if (allocated(temperatures_i4)) deallocate (temperatures_i4) if (allocated(temperatures_i8)) deallocate (temperatures_i8) if (allocated(temperatures_r4)) deallocate (temperatures_r4) if (allocated(temperatures_r8)) deallocate (temperatures_r8) ! Start adios2 Reader in rank 0 if (irank == 0) then call adios2_declare_io(ioGet, adios, 'HeatMapRead', ierr) call adios2_open(bpReader, ioGet, 'HeatMapZfp2D_f.bp', & adios2_mode_read, MPI_COMM_SELF, ierr) call adios2_inquire_variable(var_temperaturesIn(1), ioGet, & 'temperatures_i1', ierr) call adios2_inquire_variable(var_temperaturesIn(2), ioGet, & 'temperatures_i2', ierr) call adios2_inquire_variable(var_temperaturesIn(3), ioGet, & 'temperatures_i4', ierr) call adios2_inquire_variable(var_temperaturesIn(4), ioGet, & 'temperatures_i8', ierr) call adios2_inquire_variable(var_temperaturesIn(5), ioGet, & 'temperatures_r4', ierr) call adios2_inquire_variable(var_temperaturesIn(6), ioGet, & 'temperatures_r8', ierr) sel_start = (/0, 0/) sel_count = (/ishape(1), ishape(2)/) allocate (sel_temperatures_i1(ishape(1), ishape(2))) allocate (sel_temperatures_i2(ishape(1), ishape(2))) allocate (sel_temperatures_i4(ishape(1), ishape(2))) allocate (sel_temperatures_i8(ishape(1), ishape(2))) allocate (sel_temperatures_r4(ishape(1), ishape(2))) allocate (sel_temperatures_r8(ishape(1), ishape(2))) sel_temperatures_i1 = 0 sel_temperatures_i2 = 0 sel_temperatures_i4 = 0 sel_temperatures_i8 = 0_8 sel_temperatures_r4 = 0.0_4 sel_temperatures_r8 = 0.0_8 call adios2_set_selection(var_temperaturesIn(1), 2, sel_start, sel_count, & ierr) call adios2_set_selection(var_temperaturesIn(2), 2, sel_start, sel_count, & ierr) call adios2_set_selection(var_temperaturesIn(3), 2, sel_start, sel_count, & ierr) call adios2_set_selection(var_temperaturesIn(4), 2, sel_start, sel_count, & ierr) call adios2_set_selection(var_temperaturesIn(5), 2, sel_start, sel_count, & ierr) call adios2_set_selection(var_temperaturesIn(6), 2, sel_start, sel_count, & ierr) call adios2_get(bpReader, var_temperaturesIn(1), sel_temperatures_i1, ierr) call adios2_get(bpReader, var_temperaturesIn(2), sel_temperatures_i2, ierr) call adios2_get(bpReader, var_temperaturesIn(3), sel_temperatures_i4, ierr) call adios2_get(bpReader, var_temperaturesIn(4), sel_temperatures_i8, ierr) call adios2_get(bpReader, var_temperaturesIn(5), sel_temperatures_r4, ierr) call adios2_get(bpReader, var_temperaturesIn(6), sel_temperatures_r8, ierr) call adios2_close(bpReader, ierr) sum_i1 = 0 sum_i2 = 0 do i2 = 1, INT(sel_count(2), 4) do i1 = 1, INT(sel_count(1), 4) sum_i1 = sum_i1 + sel_temperatures_i1(i1, i2) sum_i2 = sum_i2 + sel_temperatures_i2(i1, i2) end do end do if (sum_i1 /= 100*isize) stop 'Test failed integer*1' if (sum_i2 /= 100*isize) stop 'Test failed integer*2' if (sum(sel_temperatures_i4) /= 100*isize) stop 'Test failed integer*4' if (sum(sel_temperatures_i8) /= 100*isize) stop 'Test failed integer*8' if (sum(sel_temperatures_r4) /= 100*isize) stop 'Test failed real*4' if (sum(sel_temperatures_r8) /= 100*isize) stop 'Test failed real*8' if (allocated(sel_temperatures_i1)) deallocate (sel_temperatures_i1) if (allocated(sel_temperatures_i2)) deallocate (sel_temperatures_i2) if (allocated(sel_temperatures_i4)) deallocate (sel_temperatures_i4) if (allocated(sel_temperatures_i8)) deallocate (sel_temperatures_i8) if (allocated(sel_temperatures_r4)) deallocate (sel_temperatures_r4) if (allocated(sel_temperatures_r8)) deallocate (sel_temperatures_r8) end if call adios2_finalize(adios, ierr) call MPI_Finalize(ierr) end program TestBPWriteReadHeatMapZfp2D
apache-2.0
PeyloW/gcc-4.6.4
libgomp/testsuite/libgomp.fortran/lib3.f
90
2463
C { dg-do run } INCLUDE "omp_lib.h" DOUBLE PRECISION :: D, E LOGICAL :: L INTEGER (KIND = OMP_LOCK_KIND) :: LCK INTEGER (KIND = OMP_NEST_LOCK_KIND) :: NLCK D = OMP_GET_WTIME () CALL OMP_INIT_LOCK (LCK) CALL OMP_SET_LOCK (LCK) IF (OMP_TEST_LOCK (LCK)) CALL ABORT CALL OMP_UNSET_LOCK (LCK) IF (.NOT. OMP_TEST_LOCK (LCK)) CALL ABORT IF (OMP_TEST_LOCK (LCK)) CALL ABORT CALL OMP_UNSET_LOCK (LCK) CALL OMP_DESTROY_LOCK (LCK) CALL OMP_INIT_NEST_LOCK (NLCK) IF (OMP_TEST_NEST_LOCK (NLCK) .NE. 1) CALL ABORT CALL OMP_SET_NEST_LOCK (NLCK) IF (OMP_TEST_NEST_LOCK (NLCK) .NE. 3) CALL ABORT CALL OMP_UNSET_NEST_LOCK (NLCK) CALL OMP_UNSET_NEST_LOCK (NLCK) IF (OMP_TEST_NEST_LOCK (NLCK) .NE. 2) CALL ABORT CALL OMP_UNSET_NEST_LOCK (NLCK) CALL OMP_UNSET_NEST_LOCK (NLCK) CALL OMP_DESTROY_NEST_LOCK (NLCK) CALL OMP_SET_DYNAMIC (.TRUE.) IF (.NOT. OMP_GET_DYNAMIC ()) CALL ABORT CALL OMP_SET_DYNAMIC (.FALSE.) IF (OMP_GET_DYNAMIC ()) CALL ABORT CALL OMP_SET_NESTED (.TRUE.) IF (.NOT. OMP_GET_NESTED ()) CALL ABORT CALL OMP_SET_NESTED (.FALSE.) IF (OMP_GET_NESTED ()) CALL ABORT CALL OMP_SET_NUM_THREADS (5) IF (OMP_GET_NUM_THREADS () .NE. 1) CALL ABORT IF (OMP_GET_MAX_THREADS () .NE. 5) CALL ABORT IF (OMP_GET_THREAD_NUM () .NE. 0) CALL ABORT CALL OMP_SET_NUM_THREADS (3) IF (OMP_GET_NUM_THREADS () .NE. 1) CALL ABORT IF (OMP_GET_MAX_THREADS () .NE. 3) CALL ABORT IF (OMP_GET_THREAD_NUM () .NE. 0) CALL ABORT L = .FALSE. C$OMP PARALLEL REDUCTION (.OR.:L) L = OMP_GET_NUM_THREADS () .NE. 3 L = L .OR. (OMP_GET_THREAD_NUM () .LT. 0) L = L .OR. (OMP_GET_THREAD_NUM () .GE. 3) C$OMP MASTER L = L .OR. (OMP_GET_THREAD_NUM () .NE. 0) C$OMP END MASTER C$OMP END PARALLEL IF (L) CALL ABORT IF (OMP_GET_NUM_PROCS () .LE. 0) CALL ABORT IF (OMP_IN_PARALLEL ()) CALL ABORT C$OMP PARALLEL REDUCTION (.OR.:L) L = .NOT. OMP_IN_PARALLEL () C$OMP END PARALLEL C$OMP PARALLEL REDUCTION (.OR.:L) IF (.TRUE.) L = .NOT. OMP_IN_PARALLEL () C$OMP END PARALLEL E = OMP_GET_WTIME () IF (D .GT. E) CALL ABORT D = OMP_GET_WTICK () C Negative precision is definitely wrong, C bigger than 1s clock resolution is also strange IF (D .LE. 0 .OR. D .GT. 1.) CALL ABORT END
gpl-2.0
foss-for-synopsys-dwc-arc-processors/binutils-gdb
gdb/testsuite/gdb.fortran/vla-type.f90
5
3150
! Copyright 2016-2021 Free Software Foundation, Inc. ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 3 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. If not, see <http://www.gnu.org/licenses/>. program vla_struct type :: one integer, allocatable :: ivla (:, :, :) end type one type :: two integer, allocatable :: ivla1 (:, :, :) integer, allocatable :: ivla2 (:, :) end type two type :: three integer :: ivar integer, allocatable :: ivla (:) end type three type :: four integer, allocatable :: ivla (:) integer :: ivar end type four type :: five type(one) :: tone end type five type(one), target :: onev type(two) :: twov type(three) :: threev type(four) :: fourv type(five) :: fivev type(five) :: fivearr (2) type(five), allocatable :: fivedynarr (:) logical :: l integer :: i, j allocate (onev%ivla (11,22,33)) ! before-allocated l = allocated(onev%ivla) onev%ivla(:, :, :) = 1 onev%ivla(1, 2, 3) = 123 onev%ivla(3, 2, 1) = 321 allocate (twov%ivla1 (5,12,99)) ! onev-filled l = allocated(twov%ivla1) allocate (twov%ivla2 (9,12)) l = allocated(twov%ivla2) twov%ivla1(:, :, :) = 1 twov%ivla1(1, 2, 3) = 123 twov%ivla1(3, 2, 1) = 321 twov%ivla2(:, :) = 1 twov%ivla2(1, 2) = 12 twov%ivla2(2, 1) = 21 threev%ivar = 3 ! twov-filled allocate (threev%ivla (20)) l = allocated(threev%ivla) threev%ivla(:) = 1 threev%ivla(5) = 42 threev%ivla(14) = 24 allocate (fourv%ivla (10)) ! threev-filled l = allocated(fourv%ivla) fourv%ivar = 3 fourv%ivla(:) = 1 fourv%ivla(2) = 2 fourv%ivla(7) = 7 allocate (fivev%tone%ivla (10, 10, 10)) ! fourv-filled l = allocated(fivev%tone%ivla) fivev%tone%ivla(:, :, :) = 1 fivev%tone%ivla(1, 2, 3) = 123 fivev%tone%ivla(3, 2, 1) = 321 allocate (fivearr(1)%tone%ivla (2, 4, 6)) ! fivev-filled allocate (fivearr(2)%tone%ivla (12, 14, 16)) fivearr(1)%tone%ivla(:, :, :) = 1 fivearr(1)%tone%ivla(2, 2, 3) = 223 fivearr(2)%tone%ivla(:, :, :) = 2 fivearr(2)%tone%ivla(6, 7, 8) = 678 allocate (fivedynarr(2)) ! fivearr-filled allocate (fivedynarr(1)%tone%ivla (2, 4, 6)) allocate (fivedynarr(2)%tone%ivla (12, 14, 16)) fivedynarr(1)%tone%ivla(:, :, :) = 1 fivedynarr(1)%tone%ivla(2, 2, 3) = 223 fivedynarr(2)%tone%ivla(:, :, :) = 2 fivedynarr(2)%tone%ivla(6, 7, 8) = 678 l = allocated(fivedynarr) ! fivedynarr-filled end program vla_struct
gpl-2.0
anlongfei/gcc-4.8.4
gcc/testsuite/gfortran.dg/vect/no-fre-no-copy-prop-O3-pr51704.f90
98
1884
! { dg-do compile } integer, parameter :: q = 2 integer, parameter :: nx=3, ny=2*q, nz=5 integer, parameter, dimension(nx,ny,nz) :: p = & & reshape ((/ (i**2, i=1,size(p)) /), shape(p)) integer, parameter, dimension( ny,nz) :: px = & & reshape ((/ (( & & + nx*(nx-1)*(2*nx-1)/6, & & j=0,ny-1), k=0,nz-1) /), shape(px)) integer, parameter, dimension(nx, nz) :: py = & & reshape ((/ (( & & +(nx )**2*ny*(ny-1)*(2*ny-1)/6, & & i=0,nx-1), k=0,nz-1) /), shape(py)) integer, parameter, dimension(nx,ny ) :: pz = & & reshape ((/ (( & & +(nx*ny)**2*nz*(nz-1)*(2*nz-1)/6, & & i=0,nx-1), j=0,ny-1) /), shape(pz)) integer, dimension(nx,ny,nz) :: a integer, dimension(nx,ny ) :: az if (sum(sum(sum(a,1),2),1) /= sum(a)) call abort if (sum(sum(sum(a,3),1),1) /= sum(a)) call abort if (any(1+sum(eid(a),1)+ax+sum( & neid3(a), & 1)+1 /= 3*ax+2)) call abort if (any(1+eid(sum(a,2))+ay+ & neid2( & sum(a,2) & )+1 /= 3*ay+2)) call abort if (any(sum(eid(sum(a,3))+az+2* & neid2(az) & ,1)+1 /= 4*sum(az,1)+1)) call abort contains elemental function eid (x) integer, intent(in) :: x end function eid function neid2 (x) integer, intent(in) :: x(:,:) integer :: neid2(size(x,1),size(x,2)) neid2 = x end function neid2 function neid3 (x) integer, intent(in) :: x(:,:,:) integer :: neid3(size(x,1),size(x,2),size(x,3)) end function neid3 elemental subroutine set (o, i) integer, intent(in) :: i integer, intent(out) :: o end subroutine set elemental subroutine tes (i, o) integer, intent(in) :: i integer, intent(out) :: o end subroutine tes end ! { dg-final { cleanup-tree-dump "vect" } }
gpl-2.0
PeyloW/gcc-4.6.4
gcc/testsuite/gfortran.dg/allocate_alloc_opt_1.f90
29
1204
! { dg-do compile } program a implicit none real x integer j, k, n(4) character(len=70) err character(len=70), allocatable :: error(:) integer, allocatable :: i(:) type b integer, allocatable :: c(:), d(:) end type b type(b) e, f(3) allocate(i(2), stat=x) ! { dg-error "must be a scalar INTEGER" } allocate(i(2), stat=j, stat=k) ! { dg-error "Redundant STAT" } allocate(i(2)) allocate(i(2))) ! { dg-error "Syntax error in ALLOCATE" } allocate(i(2), errmsg=err, errmsg=err) ! { dg-error "Redundant ERRMSG" } allocate(i(2), errmsg=err) ! { dg-warning "useless without a STAT" } allocate(i(2), stat=j, errmsg=x) ! { dg-error "must be a scalar CHARACTER" } allocate(err) ! { dg-error "nonprocedure pointer or an allocatable" } allocate(error(2),stat=j,errmsg=error(1)) ! { dg-error "shall not be ALLOCATEd within" } allocate(i(2), stat = i(1)) ! { dg-error "shall not be ALLOCATEd within" } allocate(n) ! { dg-error "must be ALLOCATABLE or a POINTER" } allocate(i(2), i(2)) ! { dg-error "Allocate-object at" } ! These should not fail the check for duplicate alloc-objects. allocate(f(1)%c(2), f(2)%d(2)) allocate(e%c(2), e%d(2)) end program a
gpl-2.0
anlongfei/gcc-4.8.4
gcc/testsuite/gfortran.dg/argument_checking_13.f90
163
3013
! { dg-do compile } ! ! PR fortran/34796 ! ! Argument checks: ! - elements of deferred-shape arrays (= non-dummies) are allowed ! as the memory is contiguous ! - while assumed-shape arrays (= dummy arguments) and pointers are ! not (strides can make them non-contiguous) ! and ! - if the memory is non-contigous, character arguments have as ! storage size only the size of the element itself, check for ! too short actual arguments. ! subroutine test1(assumed_sh_dummy, pointer_dummy) implicit none interface subroutine rlv1(y) real :: y(3) end subroutine rlv1 end interface real :: assumed_sh_dummy(:,:,:) real, pointer :: pointer_dummy(:,:,:) real, allocatable :: deferred(:,:,:) real, pointer :: ptr(:,:,:) call rlv1(deferred(1,1,1)) ! valid since contiguous call rlv1(ptr(1,1,1)) ! { dg-error "Element of assumed-shaped or pointer array" } call rlv1(assumed_sh_dummy(1,1,1)) ! { dg-error "Element of assumed-shaped or pointer array" } call rlv1(pointer_dummy(1,1,1)) ! { dg-error "Element of assumed-shaped or pointer array" } end subroutine test2(assumed_sh_dummy, pointer_dummy) implicit none interface subroutine rlv2(y) character :: y(3) end subroutine rlv2 end interface character(3) :: assumed_sh_dummy(:,:,:) character(3), pointer :: pointer_dummy(:,:,:) character(3), allocatable :: deferred(:,:,:) character(3), pointer :: ptr(:,:,:) call rlv2(deferred(1,1,1)) ! Valid since contiguous call rlv2(ptr(1,1,1)) ! Valid F2003 call rlv2(assumed_sh_dummy(1,1,1)) ! Valid F2003 call rlv2(pointer_dummy(1,1,1)) ! Valid F2003 ! The following is kind of ok: The memory access it valid ! We warn nonetheless as the result is not what is intented ! and also formally wrong. ! Using (1:string_length) would be ok. call rlv2(ptr(1,1,1)(1:1)) ! { dg-warning "contains too few elements" } call rlv2(assumed_sh_dummy(1,1,1)(1:2)) ! { dg-warning "contains too few elements" } call rlv2(pointer_dummy(1,1,1)(1:3)) ! Valid F2003 end subroutine test3(assumed_sh_dummy, pointer_dummy) implicit none interface subroutine rlv3(y) character :: y(3) end subroutine rlv3 end interface character(2) :: assumed_sh_dummy(:,:,:) character(2), pointer :: pointer_dummy(:,:,:) character(2), allocatable :: deferred(:,:,:) character(2), pointer :: ptr(:,:,:) call rlv3(deferred(1,1,1)) ! Valid since contiguous call rlv3(ptr(1,1,1)) ! { dg-warning "contains too few elements" } call rlv3(assumed_sh_dummy(1,1,1)) ! { dg-warning "contains too few elements" } call rlv3(pointer_dummy(1,1,1)) ! { dg-warning "contains too few elements" } call rlv3(deferred(1,1,1)(1:2)) ! Valid since contiguous call rlv3(ptr(1,1,1)(1:2)) ! { dg-warning "contains too few elements" } call rlv3(assumed_sh_dummy(1,1,1)(1:2)) ! { dg-warning "contains too few elements" } call rlv3(pointer_dummy(1,1,1)(1:2)) ! { dg-warning "contains too few elements" } end
gpl-2.0
PeyloW/gcc-4.6.4
gcc/testsuite/gfortran.dg/pr44691.f
91
1409
C PR rtl-optimization/44691 C { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } C { dg-options "-O2 -fselective-scheduling2" } SUBROUTINE ORIEN(IW,NATOT,NTOTORB,NATORB,P,T) IMPLICIT DOUBLE PRECISION(A-H,O-Z) DIMENSION NATORB(NATOT),P(NTOTORB*(NTOTORB+1)/2) DIMENSION T(NTOTORB,NTOTORB) DO 9000 IATOM=1,NATOT ILAST = NTOTORB IF (IATOM.NE.NATOT) ILAST=NATORB(IATOM+1)-1 DO 8000 IAOI=NATORB(IATOM),ILAST DO 7000 IAOJ = IAOI+1,ILAST R2 = 0.0D+00 R3 = 0.0D+00 DO 6000 INOTA=1,NATOT DO 5000 IK=NATORB(INOTA),NTOTORB IMAI=MAX(IK,IAOI) IMII=MIN(IK,IAOI) IMAJ=MAX(IK,IAOJ) IMIJ=MIN(IK,IAOJ) IKI=(IMAI*(IMAI-1))/2 + IMII IKJ=(IMAJ*(IMAJ-1))/2 + IMIJ PIKI=P(IKI) PIKJ=P(IKJ) R2 = R2 + (PIKI**4)-6*(PIKI*PIKI*PIKJ*PIKJ)+(PIKJ) 5000 CONTINUE 6000 CONTINUE R2 = (R2/4.0D+00) Q = SQRT(R2*R2 + R3*R3) IF (Q.LT.1.0D-08) GO TO 7000 A = COS(THETA) B = -SIN(THETA) CALL ROT1INT(NTOTORB,IAOI,IAOJ,A,B,P) 7000 CONTINUE 8000 CONTINUE 9000 CONTINUE RETURN END
gpl-2.0
anlongfei/gcc-4.8.4
libgfortran/generated/_abs_c10.F90
26
1481
! Copyright (C) 2002-2013 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_COMPLEX_10) #ifdef HAVE_CABSL elemental function _gfortran_specific__abs_c10 (parm) complex (kind=10), intent (in) :: parm real (kind=10) :: _gfortran_specific__abs_c10 _gfortran_specific__abs_c10 = abs (parm) end function #endif #endif
gpl-2.0
PeyloW/gcc-4.6.4
gcc/testsuite/gfortran.dg/g77/19981216-0.f
185
3346
c { dg-do compile } c { dg-options "-std=legacy" } c * Resent-From: Craig Burley <burley@gnu.org> * Resent-To: craig@jcb-sc.com * X-Delivered: at request of burley on mescaline.gnu.org * Date: Wed, 16 Dec 1998 18:31:24 +0100 * From: Dieter Stueken <stueken@conterra.de> * Organization: con terra GmbH * To: fortran@gnu.org * Subject: possible bug * Content-Type: text/plain; charset=iso-8859-1 * X-Mime-Autoconverted: from 8bit to quoted-printable by mescaline.gnu.org id KAA09085 * X-UIDL: 72293bf7f9fac8378ec7feca2bccbce2 * * Hi, * * I'm about to compile a very old, very ugly Fortran program. * For one part I got: * * f77: Internal compiler error: program f771 got fatal signal 6 * * instead of any detailed error message. I was able to break down the * problem to the following source fragment: * * ------------------------------------------- PROGRAM WAP integer(kind=8) ios character*80 name name = 'blah' open(unit=8,status='unknown',file=name,form='formatted', F iostat=ios) END * ------------------------------------------- * * The problem seems to be caused by the "integer(kind=2) ios" declaration. * So far I solved it by simply using a plain integer instead. * * I'm running gcc on a Linux system compiled/installed * with no special options: * * -> g77 -v * g77 version 0.5.23 * Driving: g77 -v -c -xf77-version /dev/null -xnone * Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnulibc1/2.8.1/specs * gcc version 2.8.1 * /usr/lib/gcc-lib/i686-pc-linux-gnulibc1/2.8.1/cpp -lang-c -v -undef * -D__GNUC__=2 -D__GNUC_MINOR__=8 -D__ELF__ -D__unix__ -D__linux__ * -D__unix -D__linux -Asystem(posix) -D_LANGUAGE_FORTRAN -traditional * -Di386 -Di686 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ * -D__i686__ -Asystem(unix) -Acpu(i386) -Amachine(i386) /dev/null * /dev/null * GNU CPP version 2.8.1 (i386 GNU/Linux with ELF) * #include "..." search starts here: * #include <...> search starts here: * /usr/local/include * /usr/i686-pc-linux-gnulibc1/include * /usr/lib/gcc-lib/i686-pc-linux-gnulibc1/2.8.1/include * /usr/include * End of search list. * /usr/lib/gcc-lib/i686-pc-linux-gnulibc1/2.8.1/f771 -fnull-version * -quiet -dumpbase g77-version.f -version -fversion -o /tmp/cca24911.s * /dev/null * GNU F77 version 2.8.1 (i686-pc-linux-gnulibc1) compiled by GNU C version * 2.8.1. * GNU Fortran Front End version 0.5.23 * as -V -Qy -o /tmp/cca24911.o /tmp/cca24911.s * GNU assembler version 2.8.1 (i486-linux), using BFD version 2.8.1 * ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.1 -o /tmp/cca24911 * /tmp/cca24911.o /usr/lib/crt1.o /usr/lib/crti.o * /usr/lib/gcc-lib/i686-pc-linux-gnulibc1/2.8.1/crtbegin.o * -L/usr/lib/gcc-lib/i686-pc-linux-gnulibc1/2.8.1 -L/usr -lg2c -lm -lgcc * -lc -lgcc /usr/lib/gcc-lib/i686-pc-linux-gnulibc1/2.8.1/crtend.o * /usr/lib/crtn.o * /tmp/cca24911 * __G77_LIBF77_VERSION__: 0.5.23 * @(#)LIBF77 VERSION 19970919 * __G77_LIBI77_VERSION__: 0.5.23 * @(#) LIBI77 VERSION pjw,dmg-mods 19980405 * __G77_LIBU77_VERSION__: 0.5.23 * @(#) LIBU77 VERSION 19970919 * * * Regards, Dieter. * -- * Dieter Stüken, con terra GmbH, Münster * stueken@conterra.de stueken@qgp.uni-muenster.de * http://www.conterra.de/ http://qgp.uni-muenster.de/~stueken * (0)251-980-2027 (0)251-83-334974
gpl-2.0
CFDEMproject/LAMMPS
tools/reax/bondConnectCheck.f90
44
7808
!# DEC.9, 2010 !# HLL !# NCSU !# !# This is a program to read the output from 'fix reax/bond', TPRD, Lammps !# The output is saved into file "bonds.reax", where each image is divided !# into three parts: !# !# (1) Head, 7 Lines; !# (2) Body, No._of_atom Lines; !# (3) Tail, 1 Line !# !# The total number of images is related with the output frequence and number of iterations. !# In this case, it is "number of iteration+1". !# !# Each line in Body part is made up of the following parameters: !# id, type, nb, id_1, id_2, ... id_nb, mol, bo_1, bo_2, ... bo_nb, abo, nlp, q !# abo = atomic bond order !# nlp = number of lone pairs !# q = atomic charge !# !# PLEASE DOUBLE CHECK YOUR OWN LAMMPS INPUT SCRIPT & OUTPUT AND MAKE CORRESPONDING CHSNGES program main implicit none integer I, J, K, L integer image, natom integer headline, tailline integer id, atype, nb, bd1, bd2, bd3, bd4, mol double precision bo1, bo2, bo3, bo4, abo, nlp, q open (unit=10, file='bonds.reax') open (unit=20, file='N129.txt', status='unknown') open (unit=21, file='N133.txt', status='unknown') open (unit=22, file='N137.txt', status='unknown') open (unit=23, file='N141.txt', status='unknown') open (unit=24, file='N145.txt', status='unknown') open (unit=25, file='N149.txt', status='unknown') open (unit=26, file='N153.txt', status='unknown') open (unit=27, file='N157.txt', status='unknown') open (unit=30, file='reactionRecord.txt', status='unknown') !# Make changes accordingly. image = 1 headline = 7 tailline = 1 natom = 384 do I = 1, image+1 ! Skip the head part do J = 1, headline read(10,*) end do ! Each image has 'natom' lines do K = 1, natom ! read in the first three number each line to determine: ! (1) what type of atom it is, atype ! the correspondence in Lammps: 1-C, 2-H, 3-O, 4-N, 5-S ! (2) how many bonds it has, nb ! this 'nb' determines the following bond_link information & bond_order paramaters of the same line read(10,*) id, atype, nb ! TEST ! write(*,*) id, atype, nb if (atype .eq. 4) then backspace 10 ! Should have some easier way to replace this "IF", I am just toooo lazy. ! Thanks to the fact that the maximum number of bonds is 4. ^-^ !??? is it possible that nb = 0 ??? KEEP THAT IN MIND. if (nb.eq.0) then read(10,*) id, atype, nb, mol, abo, nlp, q if (id .eq. 129) then write(20, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 133) then write(21, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 137) then write(22, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 141) then write(23, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 145) then write(24, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 149) then write(25, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 153) then write(26, 200) id, atype, nb, mol, abo, nlp, q elseif (id .eq. 157) then write(27, 200) id, atype, nb, mol, abo, nlp, q 200 format(4I4, 3f14.3) endif ! If bd .ne. 3, it measn reaction is happening to Nitrogen atom. write (30, 300) I, id, atype, nb, mol, abo, nlp, q 300 format(5I4, 3f14.3) elseif (nb.eq.1) then read(10,*) id, atype, nb, bd1, mol, bo1, abo, nlp, q if (id .eq. 129) then write(20, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 133) then write(21, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 137) then write(22, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 141) then write(23, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 145) then write(24, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 149) then write(25, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 153) then write(26, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q elseif (id .eq. 157) then write(27, 201) id, atype, nb, bd1, mol, bo1, abo, nlp, q 201 format(5I4, 4f14.3) endif ! If bd .ne. 3, it measn reaction is happening to Nitrogen atom. write (30, 301) I, id, atype, nb, bd1, mol, bo1, abo, nlp, q 301 format(6I4, 4f14.3) elseif (nb.eq.2) then read(10,*) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q if (id .eq. 129) then write(20, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 133) then write(21, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 137) then write(22, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 141) then write(23, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 145) then write(24, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 149) then write(25, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 153) then write(26, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q elseif (id .eq. 157) then write(27, 202) id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q 202 format(6I4, 5f14.3) endif ! If bd .ne. 3, it measn reaction is happening to Nitrogen atom. write (30, 302) I, id, atype, nb, bd1, bd2, mol, bo1, bo2, abo, nlp, q 302 format(7I4, 5f14.3) elseif (nb.eq.3) then read(10,*) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q if (id .eq. 129) then write(20, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 133) then write(21, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 137) then write(22, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 141) then write(23, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 145) then write(24, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 149) then write(25, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q elseif (id .eq. 153) then write(26, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bd3, abo, nlp, q elseif (id .eq. 157) then write(27, 203) id, atype, nb, bd1, bd2, bd3, mol, bo1, bo2, bo3, abo, nlp, q 203 format(7I4, 6f14.3) endif elseif (nb.eq.4) then read(10,*) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q if (id .eq. 129) then write(20, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 133) then write(21, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 137) then write(22, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 141) then write(23, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 145) then write(24, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 149) then write(25, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q elseif (id .eq. 153) then write(26, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bd3, bo4, abo, nlp, q elseif (id .eq. 157) then write(27, 204) id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q 204 format(8I4, 7f14.3) endif ! If bd .ne. 3, it measn reaction is happening to Nitrogen atom. write (30, 304) I, id, atype, nb, bd1, bd2, bd3, bd4, mol, bo1, bo2, bo3, bo4, abo, nlp, q 304 format(9I4, 7f14.3) ! Corresponding to "if (nb.eq.0) then " endif ! Corresponding to "if (atype .eq. 4) then" endif enddo do L =1,tailline read(10,*) enddo enddo end program main
gpl-2.0
PeyloW/gcc-4.6.4
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
kleskjr/scipy
scipy/fftpack/src/fftpack/rffti1.f
98
1357
SUBROUTINE RFFTI1 (N,WA,IFAC) DIMENSION WA(*) ,IFAC(*) ,NTRYH(4) DATA NTRYH(1),NTRYH(2),NTRYH(3),NTRYH(4)/4,2,3,5/ NL = N NF = 0 J = 0 101 J = J+1 IF (J.le.4) GO TO 102 GO TO 103 102 NTRY = NTRYH(J) GO TO 104 103 NTRY = NTRYH(4)+2*(J-4) 104 NQ = NL/NTRY NR = NL-NTRY*NQ IF (NR.eq.0) GO TO 105 GO TO 101 105 NF = NF+1 IFAC(NF+2) = NTRY NL = NQ IF (NTRY .NE. 2) GO TO 107 IF (NF .EQ. 1) GO TO 107 DO 106 I=2,NF IB = NF-I+2 IFAC(IB+2) = IFAC(IB+1) 106 CONTINUE IFAC(3) = 2 107 IF (NL .NE. 1) GO TO 104 IFAC(1) = N IFAC(2) = NF TPI = 6.28318530717959 ARGH = TPI/FLOAT(N) IS = 0 NFM1 = NF-1 L1 = 1 IF (NFM1 .EQ. 0) RETURN DO 110 K1=1,NFM1 IP = IFAC(K1+2) LD = 0 L2 = L1*IP IDO = N/L2 IPM = IP-1 DO 109 J=1,IPM LD = LD+L1 I = IS ARGLD = FLOAT(LD)*ARGH FI = 0. DO 108 II=3,IDO,2 I = I+2 FI = FI+1. ARG = FI*ARGLD WA(I-1) = COS(ARG) WA(I) = SIN(ARG) 108 CONTINUE IS = IS+IDO 109 CONTINUE L1 = L2 110 CONTINUE RETURN END
bsd-3-clause
anlongfei/gcc-4.8.4
gcc/testsuite/gfortran.dg/defined_assignment_1.f90
133
1762
! { dg-do run } ! Test the fix for PR46897. ! ! Contributed by Rouson Damian <rouson@sandia.gov> ! module m0 implicit none type component integer :: i = 0 contains procedure :: assign0 generic :: assignment(=)=>assign0 end type type parent type(component) :: foo end type type, extends(parent) :: child integer :: j end type contains subroutine assign0(lhs,rhs) class(component), intent(out) :: lhs class(component), intent(in) :: rhs lhs%i = 20 end subroutine type(child) function new_child() end function end module module m1 implicit none type component1 integer :: i = 1 contains procedure :: assign1 generic :: assignment(=)=>assign1 end type type t type(component1) :: foo end type contains subroutine assign1(lhs,rhs) class(component1), intent(out) :: lhs class(component1), intent(in) :: rhs lhs%i = 21 end subroutine end module module m2 implicit none type component2 integer :: i = 2 end type interface assignment(=) module procedure assign2 end interface type t2 type(component2) :: foo end type contains subroutine assign2(lhs,rhs) type(component2), intent(out) :: lhs type(component2), intent(in) :: rhs lhs%i = 22 end subroutine end module program main use m0 use m1 use m2 implicit none type(child) :: infant0 type(t) :: infant1, newchild1 type(t2) :: infant2, newchild2 ! Test the reported problem. infant0 = new_child() if (infant0%parent%foo%i .ne. 20) call abort ! Test the case of comment #1 of the PR. infant1 = newchild1 if (infant1%foo%i .ne. 21) call abort ! Test the case of comment #2 of the PR. infant2 = newchild2 if (infant2%foo%i .ne. 2) call abort end
gpl-2.0
Alexpux/GCC
gcc/testsuite/gfortran.dg/interface_16.f90
155
3123
! { dg-do compile } ! This tests the fix for PR32634, in which the generic interface ! in foo_pr_mod was given the original rather than the local name. ! This meant that the original name had to be used in the calll ! in foo_sub. ! ! Contributed by Salvatore Filippone <salvatore.filippone@uniroma2.it> module foo_base_mod type foo_dmt real(kind(1.d0)), allocatable :: rv(:) integer, allocatable :: iv1(:), iv2(:) end type foo_dmt type foo_zmt complex(kind(1.d0)), allocatable :: rv(:) integer, allocatable :: iv1(:), iv2(:) end type foo_zmt type foo_cdt integer, allocatable :: md(:) integer, allocatable :: hi(:), ei(:) end type foo_cdt end module foo_base_mod module bar_prt use foo_base_mod, only : foo_dmt, foo_zmt, foo_cdt type bar_dbprt type(foo_dmt), allocatable :: av(:) real(kind(1.d0)), allocatable :: d(:) type(foo_cdt) :: cd end type bar_dbprt type bar_dprt type(bar_dbprt), allocatable :: bpv(:) end type bar_dprt type bar_zbprt type(foo_zmt), allocatable :: av(:) complex(kind(1.d0)), allocatable :: d(:) type(foo_cdt) :: cd end type bar_zbprt type bar_zprt type(bar_zbprt), allocatable :: bpv(:) end type bar_zprt end module bar_prt module bar_pr_mod use bar_prt interface bar_pwrk subroutine bar_dppwrk(pr,x,y,cd,info,trans,work) use foo_base_mod use bar_prt type(foo_cdt),intent(in) :: cd type(bar_dprt), intent(in) :: pr real(kind(0.d0)),intent(inout) :: x(:), y(:) integer, intent(out) :: info character(len=1), optional :: trans real(kind(0.d0)),intent(inout), optional, target :: work(:) end subroutine bar_dppwrk subroutine bar_zppwrk(pr,x,y,cd,info,trans,work) use foo_base_mod use bar_prt type(foo_cdt),intent(in) :: cd type(bar_zprt), intent(in) :: pr complex(kind(0.d0)),intent(inout) :: x(:), y(:) integer, intent(out) :: info character(len=1), optional :: trans complex(kind(0.d0)),intent(inout), optional, target :: work(:) end subroutine bar_zppwrk end interface end module bar_pr_mod module foo_pr_mod use bar_prt, & & foo_dbprt => bar_dbprt,& & foo_zbprt => bar_zbprt,& & foo_dprt => bar_dprt,& & foo_zprt => bar_zprt use bar_pr_mod, & & foo_pwrk => bar_pwrk end module foo_pr_mod Subroutine foo_sub(a,pr,b,x,eps,cd,info) use foo_base_mod use foo_pr_mod Implicit None !!$ parameters Type(foo_dmt), Intent(in) :: a Type(foo_dprt), Intent(in) :: pr Type(foo_cdt), Intent(in) :: cd Real(Kind(1.d0)), Intent(in) :: b(:) Real(Kind(1.d0)), Intent(inout) :: x(:) Real(Kind(1.d0)), Intent(in) :: eps integer, intent(out) :: info !!$ Local data Real(Kind(1.d0)), allocatable, target :: aux(:),wwrk(:,:) Real(Kind(1.d0)), allocatable :: p(:), f(:) info = 0 Call foo_pwrk(pr,p,f,cd,info,work=aux) ! This worked if bar_pwrk was called! return End Subroutine foo_sub
gpl-2.0
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/gomp/omp_do1.f90
176
1682
! { dg-do compile } ! { dg-options "-fopenmp -std=gnu" } subroutine foo integer :: i, j integer, dimension (30) :: a double precision :: d i = 0 !$omp do private (i) do 100 ! { dg-error "cannot be a DO WHILE or DO without loop control" } if (i .gt. 0) exit ! { dg-error "EXIT statement" } 100 i = i + 1 i = 0 !$omp do private (i) do ! { dg-error "cannot be a DO WHILE or DO without loop control" } if (i .gt. 0) exit ! { dg-error "EXIT statement" } i = i + 1 end do i = 0 !$omp do private (i) do 200 while (i .lt. 4) ! { dg-error "cannot be a DO WHILE or DO without loop control" } 200 i = i + 1 !$omp do private (i) do while (i .lt. 8) ! { dg-error "cannot be a DO WHILE or DO without loop control" } i = i + 1 end do !$omp do do 300 d = 1, 30, 6 ! { dg-warning "Deleted feature: Loop variable" } i = d 300 a(i) = 1 !$omp do do d = 1, 30, 5 ! { dg-warning "Deleted feature: Loop variable" } i = d a(i) = 2 end do !$omp do do i = 1, 30 if (i .eq. 16) exit ! { dg-error "EXIT statement" } end do !$omp do outer: do i = 1, 30 do j = 5, 10 if (i .eq. 6 .and. j .eq. 7) exit outer ! { dg-error "EXIT statement" } end do end do outer last: do i = 1, 30 !$omp parallel if (i .eq. 21) exit last ! { dg-error "leaving OpenMP structured block" } !$omp end parallel end do last !$omp parallel do shared (i) do i = 1, 30, 2 ! { dg-error "iteration variable present on clause" } a(i) = 5 end do !$omp end parallel do end subroutine ! { dg-error "iteration variable must be of type integer" "" { target *-*-* } 27 } ! { dg-error "iteration variable must be of type integer" "" { target *-*-* } 31 }
gpl-2.0
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/pointer_intent_3.f90
162
1226
! { dg-do compile } ! { dg-options "-std=f2003 -fall-intrinsics" } ! { dg-shouldfail "Invalid code" } ! ! Pointer intent test ! PR fortran/29624 ! ! Valid program program test implicit none type myT integer :: j = 5 integer, pointer :: jp => null() end type myT integer, pointer :: p type(myT) :: t call a(p) call b(t) contains subroutine a(p) integer, pointer,intent(in) :: p p => null(p)! { dg-error "pointer association context" } nullify(p) ! { dg-error "pointer association context" } allocate(p) ! { dg-error "pointer association context" } call c(p) ! { dg-error "pointer association context" } deallocate(p) ! { dg-error "pointer association context" } end subroutine subroutine c(p) integer, pointer, intent(inout) :: p nullify(p) end subroutine c subroutine b(t) type(myT),intent(in) :: t t%jp = 5 t%jp => null(t%jp) ! { dg-error "pointer association context" } nullify(t%jp) ! { dg-error "pointer association context" } t%j = 7 ! { dg-error "variable definition context" } allocate(t%jp) ! { dg-error "pointer association context" } deallocate(t%jp) ! { dg-error "pointer association context" } end subroutine b end program
gpl-2.0
crtc-demos/gcc-ia16
libgfortran/generated/_dim_i16.F90
16
1467
! Copyright (C) 2002-2016 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_INTEGER_16) elemental function _gfortran_specific__dim_i16 (p1, p2) integer (kind=16), intent (in) :: p1, p2 integer (kind=16) :: _gfortran_specific__dim_i16 _gfortran_specific__dim_i16 = dim (p1, p2) end function #endif
gpl-2.0
Alexpux/GCC
gcc/testsuite/gfortran.dg/function_types_2.f90
155
1574
! { dg-do compile } ! Tests the fix for PR34431 in which function TYPEs that were ! USE associated would cause an error. ! ! Contributed by Tobias Burnus <burnus@gcc.gnu.org> ! module m1 integer :: hh type t real :: r end type t end module m1 module m2 type t integer :: k end type t end module m2 module m3 contains type(t) function func() use m2 func%k = 77 end function func end module m3 type(t) function a() use m1, only: hh type t2 integer :: j end type t2 type t logical :: b end type t a%b = .true. end function a type(t) function b() use m1, only: hh use m2 use m3 b = func () b%k = 5 end function b type(t) function c() use m1, only: hh type t2 integer :: j end type t2 type t logical :: b end type t c%b = .true. end function c program main type t integer :: m end type t contains type(t) function a1() use m1, only: hh type t2 integer :: j end type t2 type t logical :: b end type t a1%b = .true. end function a1 type(t) function b1() use m1, only: hh use m2, only: t ! NAG f95 believes that the host-associated type(t) ! should be used: ! b1%m = 5 ! However, I (Tobias Burnus) believe that the use-associated one should ! be used: b1%k = 5 end function b1 type(t) function c1() use m1, only: hh type t2 integer :: j end type t2 type t logical :: b end type t c1%b = .true. end function c1 type(t) function d1() d1%m = 55 end function d1 end program main
gpl-2.0
crtc-demos/gcc-ia16
libgfortran/generated/_acosh_r8.F90
16
1477
! Copyright (C) 2002-2016 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_ACOSH elemental function _gfortran_specific__acosh_r8 (parm) real (kind=8), intent (in) :: parm real (kind=8) :: _gfortran_specific__acosh_r8 _gfortran_specific__acosh_r8 = acosh (parm) end function #endif #endif
gpl-2.0
ajjl/ITK
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/eispack/rs.f
41
1957
subroutine rs(nm,n,a,w,matz,z,fv1,fv2,ierr) c integer n,nm,ierr,matz double precision a(nm,n),w(n),z(nm,n),fv1(n),fv2(n) c c this subroutine calls the recommended sequence of c subroutines from the eigensystem subroutine package (eispack) c to find the eigenvalues and eigenvectors (if desired) c of a real symmetric matrix. c c on input c c nm must be set to the row dimension of the two-dimensional c array parameters as declared in the calling program c dimension statement. c c n is the order of the matrix a. c c a contains the real symmetric matrix. c c matz is an integer variable set equal to zero if c only eigenvalues are desired. otherwise it is set to c any non-zero integer for both eigenvalues and eigenvectors. c c on output c c w contains the eigenvalues in ascending order. c c z contains the eigenvectors if matz is not zero. c c ierr is an integer output variable set equal to an error c completion code described in the documentation for tqlrat c and tql2. the normal completion code is zero. c c fv1 and fv2 are temporary storage arrays. 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 (n .le. nm) go to 10 ierr = 10 * n go to 50 c 10 if (matz .ne. 0) go to 20 c .......... find eigenvalues only .......... call tred1(nm,n,a,w,fv1,fv2) * tqlrat encounters catastrophic underflow on the Vax * call tqlrat(n,w,fv2,ierr) call tql1(n,w,fv1,ierr) go to 50 c .......... find both eigenvalues and eigenvectors .......... 20 call tred2(nm,n,a,w,fv1,z) call tql2(nm,n,w,fv1,z,ierr) 50 return end
apache-2.0
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/proc_decl_3.f90
193
1304
! { dg-do compile } ! Some tests for PROCEDURE declarations inside of interfaces. ! Contributed by Janus Weil <jaydub66@gmail.com> module m interface subroutine a() end subroutine a end interface procedure(c) :: f interface bar procedure a,d end interface bar interface foo procedure c end interface foo abstract interface procedure f ! { dg-error "must be in a generic interface" } end interface interface function opfoo(a) integer,intent(in) :: a integer :: opfoo end function opfoo end interface interface operator(.op.) procedure opfoo end interface external ex ! { dg-error "has no explicit interface" } procedure():: ip ! { dg-error "has no explicit interface" } procedure(real):: pip ! { dg-error "has no explicit interface" } interface nn1 procedure ex procedure a, a ! { dg-error "already present in the interface" } end interface interface nn2 procedure ip end interface interface nn3 procedure pip end interface contains subroutine d(x) interface subroutine x() end subroutine x end interface interface gen procedure x end interface end subroutine d function c(x) integer :: x real :: c c = 3.4*x end function c end module m
gpl-2.0
crtc-demos/gcc-ia16
libgfortran/generated/_sinh_r8.F90
16
1472
! Copyright (C) 2002-2016 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_SINH elemental function _gfortran_specific__sinh_r8 (parm) real (kind=8), intent (in) :: parm real (kind=8) :: _gfortran_specific__sinh_r8 _gfortran_specific__sinh_r8 = sinh (parm) end function #endif #endif
gpl-2.0
NCAR/icar
src/utilities/assertions.f90
2
2085
module assertions_mod !! Summary: Utility for runtime checking of logical assertions. !! !! Compile with -DNO_ASSERTIONS to turn assertions off !! !! Use case 1 !! ---------- !! Pass the optional success argument & check for false return value as an indication of assertion failure: !! !! use assertions_mod, only : assert,assertions !! if (assertions) call assert( 2 > 1, "always true inequality", success) !! if (error_code/=0) call my_error_handler() !! !! Use case 2 !! ---------- !! Error-terminate if the assertion fails: !! !! use assertions_mod, only : assert,assertions !! if (assertions) call assert( 2 > 1, "always true inequality") !! !! code contributed by Damian Rouson Sourcery Institute !! implicit none private public :: assert public :: assertions ! Set the USE_ASSERTIONS constant below using the C preprocessor: ! ! gfortran -cpp -DUSE_ASSERTIONS=.false. -c assertions.f90 ! ! or set the corresponding ASSERTIONS variable defined in the makefile ! ! make ASSERTIONS=on ! ! Conditioning assertion calls on this compile-time constant enables optimizing compilers ! to eliminate assertion calls during a dead-code removal phase of optimization. logical, parameter :: assertions=USE_ASSERTIONS contains elemental impure subroutine assert(assertion,description,success) use iso_fortran_env, only : error_unit !! Report on the truth of an assertion or error-terminate on assertion failure implicit none logical, intent(in) :: assertion !! Most assertions will be expressions, e.g., call assert( i>0, "positive i") character(len=*), intent(in) :: description !! Brief statement of what is being asserted logical, intent(out), optional :: success !! Optional assertion result if (present(success)) success=assertion if (.not.assertion) then write(error_unit,*) 'Assertion "',description,'" failed on image ',this_image() if (.not. present(success)) error stop end if end subroutine end module
mit
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/pr61335.f90
56
3700
! { dg-do run } ! { dg-require-visibility "" } ! { dg-additional-options "-fbounds-check" } MODULE cp_units INTEGER, PARAMETER :: default_string_length=80, dp=KIND(0.0D0) LOGICAL, PRIVATE, PARAMETER :: debug_this_module=.TRUE. CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'cp_units' INTEGER, SAVE, PRIVATE :: last_unit_id=0, last_unit_set_id=0 INTEGER, PARAMETER, PUBLIC :: cp_unit_max_kinds=8, cp_unit_basic_desc_length=15,& cp_unit_desc_length=cp_unit_max_kinds*cp_unit_basic_desc_length, cp_ukind_max=9 CONTAINS FUNCTION cp_to_string(i) RESULT(res) INTEGER, INTENT(in) :: i CHARACTER(len=6) :: res INTEGER :: iostat REAL(KIND=dp) :: tmp_r IF (i>999999 .OR. i<-99999) THEN tmp_r=i WRITE (res,fmt='(es6.1)',iostat=iostat) tmp_r ELSE WRITE (res,fmt='(i6)',iostat=iostat) i END IF IF (iostat/=0) THEN STOP 7 END IF END FUNCTION cp_to_string SUBROUTINE cp_unit_create(string) CHARACTER(len=*), INTENT(in) :: string CHARACTER(len=*), PARAMETER :: routineN = 'cp_unit_create', & routineP = moduleN//':'//routineN CHARACTER(default_string_length) :: desc CHARACTER(LEN=40) :: formatstr INTEGER :: i_high, i_low, i_unit, & len_string, next_power INTEGER, DIMENSION(cp_unit_max_kinds) :: kind_id, power, unit_id LOGICAL :: failure failure=.FALSE. unit_id=0 kind_id=0 power=0 i_low=1 i_high=1 len_string=LEN(string) i_unit=0 next_power=1 DO WHILE(i_low<len_string) IF (string(i_low:i_low)/=' ') EXIT i_low=i_low+1 END DO i_high=i_low DO WHILE(i_high<=len_string) IF ( string(i_high:i_high)==' '.OR.string(i_high:i_high)=='^'.OR.& string(i_high:i_high)=='*'.OR.string(i_high:i_high)=='/') EXIT i_high=i_high+1 END DO DO WHILE(.NOT.failure) IF (i_high<=i_low.OR.i_low>len_string) EXIT i_unit=i_unit+1 IF (i_unit>cp_unit_max_kinds) THEN EXIT END IF power(i_unit)=next_power ! parse op i_low=i_high DO WHILE(i_low<=len_string) IF (string(i_low:i_low)/=' ') EXIT i_low=i_low+1 END DO i_high=i_low DO WHILE(i_high<=len_string) IF ( string(i_high:i_high)==' '.OR.string(i_high:i_high)=='^'.OR.& string(i_high:i_high)=='*'.OR.string(i_high:i_high)=='/') EXIT i_high=i_high+1 END DO IF (i_high<i_low.OR.i_low>len_string) EXIT IF (i_high<=len_string) THEN IF (string(i_low:i_high)=='^') THEN i_low=i_high+1 DO WHILE(i_low<=len_string) IF (string(i_low:i_low)/=' ') EXIT i_low=i_low+1 END DO i_high=i_low DO WHILE(i_high<=len_string) SELECT CASE(string(i_high:i_high)) CASE('+','-','0','1','2','3','4','5','6','7','8','9') i_high=i_high+1 CASE default EXIT END SELECT END DO IF (i_high<=i_low.OR.i_low>len_string) THEN write(6,*) "BUG : XXX"//string//"XXX integer expected" STOP 1 EXIT END IF END IF ENDIF END DO END SUBROUTINE cp_unit_create END MODULE cp_units USE cp_units CALL cp_unit_create("fs^-1") END
gpl-2.0
tm1249wk/WASHLIGGGHTS-2.3.7
lib/linalg/dlatrs.f
7
21914
SUBROUTINE DLATRS( UPLO, TRANS, DIAG, NORMIN, N, A, LDA, X, SCALE, $ CNORM, INFO ) * * -- LAPACK auxiliary routine (version 3.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2006 * * .. Scalar Arguments .. CHARACTER DIAG, NORMIN, TRANS, UPLO INTEGER INFO, LDA, N DOUBLE PRECISION SCALE * .. * .. Array Arguments .. DOUBLE PRECISION A( LDA, * ), CNORM( * ), X( * ) * .. * * Purpose * ======= * * DLATRS solves one of the triangular systems * * A *x = s*b or A'*x = s*b * * with scaling to prevent overflow. Here A is an upper or lower * triangular matrix, A' denotes the transpose of A, x and b are * n-element vectors, and s is a scaling factor, usually less than * or equal to 1, chosen so that the components of x will be less than * the overflow threshold. If the unscaled problem will not cause * overflow, the Level 2 BLAS routine DTRSV is called. If the matrix A * is singular (A(j,j) = 0 for some j), then s is set to 0 and a * non-trivial solution to A*x = 0 is returned. * * Arguments * ========= * * UPLO (input) CHARACTER*1 * Specifies whether the matrix A is upper or lower triangular. * = 'U': Upper triangular * = 'L': Lower triangular * * TRANS (input) CHARACTER*1 * Specifies the operation applied to A. * = 'N': Solve A * x = s*b (No transpose) * = 'T': Solve A'* x = s*b (Transpose) * = 'C': Solve A'* x = s*b (Conjugate transpose = Transpose) * * DIAG (input) CHARACTER*1 * Specifies whether or not the matrix A is unit triangular. * = 'N': Non-unit triangular * = 'U': Unit triangular * * NORMIN (input) CHARACTER*1 * Specifies whether CNORM has been set or not. * = 'Y': CNORM contains the column norms on entry * = 'N': CNORM is not set on entry. On exit, the norms will * be computed and stored in CNORM. * * N (input) INTEGER * The order of the matrix A. N >= 0. * * A (input) DOUBLE PRECISION array, dimension (LDA,N) * The triangular matrix A. If UPLO = 'U', the leading n by n * upper triangular part of the array A contains the upper * triangular matrix, and the strictly lower triangular part of * A is not referenced. If UPLO = 'L', the leading n by n lower * triangular part of the array A contains the lower triangular * matrix, and the strictly upper triangular part of A is not * referenced. If DIAG = 'U', the diagonal elements of A are * also not referenced and are assumed to be 1. * * LDA (input) INTEGER * The leading dimension of the array A. LDA >= max (1,N). * * X (input/output) DOUBLE PRECISION array, dimension (N) * On entry, the right hand side b of the triangular system. * On exit, X is overwritten by the solution vector x. * * SCALE (output) DOUBLE PRECISION * The scaling factor s for the triangular system * A * x = s*b or A'* x = s*b. * If SCALE = 0, the matrix A is singular or badly scaled, and * the vector x is an exact or approximate solution to A*x = 0. * * CNORM (input or output) DOUBLE PRECISION array, dimension (N) * * If NORMIN = 'Y', CNORM is an input argument and CNORM(j) * contains the norm of the off-diagonal part of the j-th column * of A. If TRANS = 'N', CNORM(j) must be greater than or equal * to the infinity-norm, and if TRANS = 'T' or 'C', CNORM(j) * must be greater than or equal to the 1-norm. * * If NORMIN = 'N', CNORM is an output argument and CNORM(j) * returns the 1-norm of the offdiagonal part of the j-th column * of A. * * INFO (output) INTEGER * = 0: successful exit * < 0: if INFO = -k, the k-th argument had an illegal value * * Further Details * ======= ======= * * A rough bound on x is computed; if that is less than overflow, DTRSV * is called, otherwise, specific code is used which checks for possible * overflow or divide-by-zero at every operation. * * A columnwise scheme is used for solving A*x = b. The basic algorithm * if A is lower triangular is * * x[1:n] := b[1:n] * for j = 1, ..., n * x(j) := x(j) / A(j,j) * x[j+1:n] := x[j+1:n] - x(j) * A[j+1:n,j] * end * * Define bounds on the components of x after j iterations of the loop: * M(j) = bound on x[1:j] * G(j) = bound on x[j+1:n] * Initially, let M(0) = 0 and G(0) = max{x(i), i=1,...,n}. * * Then for iteration j+1 we have * M(j+1) <= G(j) / | A(j+1,j+1) | * G(j+1) <= G(j) + M(j+1) * | A[j+2:n,j+1] | * <= G(j) ( 1 + CNORM(j+1) / | A(j+1,j+1) | ) * * where CNORM(j+1) is greater than or equal to the infinity-norm of * column j+1 of A, not counting the diagonal. Hence * * G(j) <= G(0) product ( 1 + CNORM(i) / | A(i,i) | ) * 1<=i<=j * and * * |x(j)| <= ( G(0) / |A(j,j)| ) product ( 1 + CNORM(i) / |A(i,i)| ) * 1<=i< j * * Since |x(j)| <= M(j), we use the Level 2 BLAS routine DTRSV if the * reciprocal of the largest M(j), j=1,..,n, is larger than * max(underflow, 1/overflow). * * The bound on x(j) is also used to determine when a step in the * columnwise method can be performed without fear of overflow. If * the computed bound is greater than a large constant, x is scaled to * prevent overflow, but if the bound overflows, x is set to 0, x(j) to * 1, and scale to 0, and a non-trivial solution to A*x = 0 is found. * * Similarly, a row-wise scheme is used to solve A'*x = b. The basic * algorithm for A upper triangular is * * for j = 1, ..., n * x(j) := ( b(j) - A[1:j-1,j]' * x[1:j-1] ) / A(j,j) * end * * We simultaneously compute two bounds * G(j) = bound on ( b(i) - A[1:i-1,i]' * x[1:i-1] ), 1<=i<=j * M(j) = bound on x(i), 1<=i<=j * * The initial values are G(0) = 0, M(0) = max{b(i), i=1,..,n}, and we * add the constraint G(j) >= G(j-1) and M(j) >= M(j-1) for j >= 1. * Then the bound on x(j) is * * M(j) <= M(j-1) * ( 1 + CNORM(j) ) / | A(j,j) | * * <= M(0) * product ( ( 1 + CNORM(i) ) / |A(i,i)| ) * 1<=i<=j * * and we can safely call DTRSV if 1/M(n) and 1/G(n) are both greater * than max(underflow, 1/overflow). * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO, HALF, ONE PARAMETER ( ZERO = 0.0D+0, HALF = 0.5D+0, ONE = 1.0D+0 ) * .. * .. Local Scalars .. LOGICAL NOTRAN, NOUNIT, UPPER INTEGER I, IMAX, J, JFIRST, JINC, JLAST DOUBLE PRECISION BIGNUM, GROW, REC, SMLNUM, SUMJ, TJJ, TJJS, $ TMAX, TSCAL, USCAL, XBND, XJ, XMAX * .. * .. External Functions .. LOGICAL LSAME INTEGER IDAMAX DOUBLE PRECISION DASUM, DDOT, DLAMCH EXTERNAL LSAME, IDAMAX, DASUM, DDOT, DLAMCH * .. * .. External Subroutines .. EXTERNAL DAXPY, DSCAL, DTRSV, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC ABS, MAX, MIN * .. * .. Executable Statements .. * INFO = 0 UPPER = LSAME( UPLO, 'U' ) NOTRAN = LSAME( TRANS, 'N' ) NOUNIT = LSAME( DIAG, 'N' ) * * Test the input parameters. * IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN INFO = -1 ELSE IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT. $ LSAME( TRANS, 'C' ) ) THEN INFO = -2 ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN INFO = -3 ELSE IF( .NOT.LSAME( NORMIN, 'Y' ) .AND. .NOT. $ LSAME( NORMIN, 'N' ) ) THEN INFO = -4 ELSE IF( N.LT.0 ) THEN INFO = -5 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN INFO = -7 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'DLATRS', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 ) $ RETURN * * Determine machine dependent parameters to control overflow. * SMLNUM = DLAMCH( 'Safe minimum' ) / DLAMCH( 'Precision' ) BIGNUM = ONE / SMLNUM SCALE = ONE * IF( LSAME( NORMIN, 'N' ) ) THEN * * Compute the 1-norm of each column, not including the diagonal. * IF( UPPER ) THEN * * A is upper triangular. * DO 10 J = 1, N CNORM( J ) = DASUM( J-1, A( 1, J ), 1 ) 10 CONTINUE ELSE * * A is lower triangular. * DO 20 J = 1, N - 1 CNORM( J ) = DASUM( N-J, A( J+1, J ), 1 ) 20 CONTINUE CNORM( N ) = ZERO END IF END IF * * Scale the column norms by TSCAL if the maximum element in CNORM is * greater than BIGNUM. * IMAX = IDAMAX( N, CNORM, 1 ) TMAX = CNORM( IMAX ) IF( TMAX.LE.BIGNUM ) THEN TSCAL = ONE ELSE TSCAL = ONE / ( SMLNUM*TMAX ) CALL DSCAL( N, TSCAL, CNORM, 1 ) END IF * * Compute a bound on the computed solution vector to see if the * Level 2 BLAS routine DTRSV can be used. * J = IDAMAX( N, X, 1 ) XMAX = ABS( X( J ) ) XBND = XMAX IF( NOTRAN ) THEN * * Compute the growth in A * x = b. * IF( UPPER ) THEN JFIRST = N JLAST = 1 JINC = -1 ELSE JFIRST = 1 JLAST = N JINC = 1 END IF * IF( TSCAL.NE.ONE ) THEN GROW = ZERO GO TO 50 END IF * IF( NOUNIT ) THEN * * A is non-unit triangular. * * Compute GROW = 1/G(j) and XBND = 1/M(j). * Initially, G(0) = max{x(i), i=1,...,n}. * GROW = ONE / MAX( XBND, SMLNUM ) XBND = GROW DO 30 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 50 * * M(j) = G(j-1) / abs(A(j,j)) * TJJ = ABS( A( J, J ) ) XBND = MIN( XBND, MIN( ONE, TJJ )*GROW ) IF( TJJ+CNORM( J ).GE.SMLNUM ) THEN * * G(j) = G(j-1)*( 1 + CNORM(j) / abs(A(j,j)) ) * GROW = GROW*( TJJ / ( TJJ+CNORM( J ) ) ) ELSE * * G(j) could overflow, set GROW to 0. * GROW = ZERO END IF 30 CONTINUE GROW = XBND ELSE * * A is unit triangular. * * Compute GROW = 1/G(j), where G(0) = max{x(i), i=1,...,n}. * GROW = MIN( ONE, ONE / MAX( XBND, SMLNUM ) ) DO 40 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 50 * * G(j) = G(j-1)*( 1 + CNORM(j) ) * GROW = GROW*( ONE / ( ONE+CNORM( J ) ) ) 40 CONTINUE END IF 50 CONTINUE * ELSE * * Compute the growth in A' * x = b. * IF( UPPER ) THEN JFIRST = 1 JLAST = N JINC = 1 ELSE JFIRST = N JLAST = 1 JINC = -1 END IF * IF( TSCAL.NE.ONE ) THEN GROW = ZERO GO TO 80 END IF * IF( NOUNIT ) THEN * * A is non-unit triangular. * * Compute GROW = 1/G(j) and XBND = 1/M(j). * Initially, M(0) = max{x(i), i=1,...,n}. * GROW = ONE / MAX( XBND, SMLNUM ) XBND = GROW DO 60 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 80 * * G(j) = max( G(j-1), M(j-1)*( 1 + CNORM(j) ) ) * XJ = ONE + CNORM( J ) GROW = MIN( GROW, XBND / XJ ) * * M(j) = M(j-1)*( 1 + CNORM(j) ) / abs(A(j,j)) * TJJ = ABS( A( J, J ) ) IF( XJ.GT.TJJ ) $ XBND = XBND*( TJJ / XJ ) 60 CONTINUE GROW = MIN( GROW, XBND ) ELSE * * A is unit triangular. * * Compute GROW = 1/G(j), where G(0) = max{x(i), i=1,...,n}. * GROW = MIN( ONE, ONE / MAX( XBND, SMLNUM ) ) DO 70 J = JFIRST, JLAST, JINC * * Exit the loop if the growth factor is too small. * IF( GROW.LE.SMLNUM ) $ GO TO 80 * * G(j) = ( 1 + CNORM(j) )*G(j-1) * XJ = ONE + CNORM( J ) GROW = GROW / XJ 70 CONTINUE END IF 80 CONTINUE END IF * IF( ( GROW*TSCAL ).GT.SMLNUM ) THEN * * Use the Level 2 BLAS solve if the reciprocal of the bound on * elements of X is not too small. * CALL DTRSV( UPLO, TRANS, DIAG, N, A, LDA, X, 1 ) ELSE * * Use a Level 1 BLAS solve, scaling intermediate results. * IF( XMAX.GT.BIGNUM ) THEN * * Scale X so that its components are less than or equal to * BIGNUM in absolute value. * SCALE = BIGNUM / XMAX CALL DSCAL( N, SCALE, X, 1 ) XMAX = BIGNUM END IF * IF( NOTRAN ) THEN * * Solve A * x = b * DO 110 J = JFIRST, JLAST, JINC * * Compute x(j) = b(j) / A(j,j), scaling x if necessary. * XJ = ABS( X( J ) ) IF( NOUNIT ) THEN TJJS = A( J, J )*TSCAL ELSE TJJS = TSCAL IF( TSCAL.EQ.ONE ) $ GO TO 100 END IF TJJ = ABS( TJJS ) IF( TJJ.GT.SMLNUM ) THEN * * abs(A(j,j)) > SMLNUM: * IF( TJJ.LT.ONE ) THEN IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale x by 1/b(j). * REC = ONE / XJ CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF END IF X( J ) = X( J ) / TJJS XJ = ABS( X( J ) ) ELSE IF( TJJ.GT.ZERO ) THEN * * 0 < abs(A(j,j)) <= SMLNUM: * IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM * to avoid overflow when dividing by A(j,j). * REC = ( TJJ*BIGNUM ) / XJ IF( CNORM( J ).GT.ONE ) THEN * * Scale by 1/CNORM(j) to avoid overflow when * multiplying x(j) times column j. * REC = REC / CNORM( J ) END IF CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF X( J ) = X( J ) / TJJS XJ = ABS( X( J ) ) ELSE * * A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and * scale = 0, and compute a solution to A*x = 0. * DO 90 I = 1, N X( I ) = ZERO 90 CONTINUE X( J ) = ONE XJ = ONE SCALE = ZERO XMAX = ZERO END IF 100 CONTINUE * * Scale x if necessary to avoid overflow when adding a * multiple of column j of A. * IF( XJ.GT.ONE ) THEN REC = ONE / XJ IF( CNORM( J ).GT.( BIGNUM-XMAX )*REC ) THEN * * Scale x by 1/(2*abs(x(j))). * REC = REC*HALF CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC END IF ELSE IF( XJ*CNORM( J ).GT.( BIGNUM-XMAX ) ) THEN * * Scale x by 1/2. * CALL DSCAL( N, HALF, X, 1 ) SCALE = SCALE*HALF END IF * IF( UPPER ) THEN IF( J.GT.1 ) THEN * * Compute the update * x(1:j-1) := x(1:j-1) - x(j) * A(1:j-1,j) * CALL DAXPY( J-1, -X( J )*TSCAL, A( 1, J ), 1, X, $ 1 ) I = IDAMAX( J-1, X, 1 ) XMAX = ABS( X( I ) ) END IF ELSE IF( J.LT.N ) THEN * * Compute the update * x(j+1:n) := x(j+1:n) - x(j) * A(j+1:n,j) * CALL DAXPY( N-J, -X( J )*TSCAL, A( J+1, J ), 1, $ X( J+1 ), 1 ) I = J + IDAMAX( N-J, X( J+1 ), 1 ) XMAX = ABS( X( I ) ) END IF END IF 110 CONTINUE * ELSE * * Solve A' * x = b * DO 160 J = JFIRST, JLAST, JINC * * Compute x(j) = b(j) - sum A(k,j)*x(k). * k<>j * XJ = ABS( X( J ) ) USCAL = TSCAL REC = ONE / MAX( XMAX, ONE ) IF( CNORM( J ).GT.( BIGNUM-XJ )*REC ) THEN * * If x(j) could overflow, scale x by 1/(2*XMAX). * REC = REC*HALF IF( NOUNIT ) THEN TJJS = A( J, J )*TSCAL ELSE TJJS = TSCAL END IF TJJ = ABS( TJJS ) IF( TJJ.GT.ONE ) THEN * * Divide by A(j,j) when scaling x if A(j,j) > 1. * REC = MIN( ONE, REC*TJJ ) USCAL = USCAL / TJJS END IF IF( REC.LT.ONE ) THEN CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF END IF * SUMJ = ZERO IF( USCAL.EQ.ONE ) THEN * * If the scaling needed for A in the dot product is 1, * call DDOT to perform the dot product. * IF( UPPER ) THEN SUMJ = DDOT( J-1, A( 1, J ), 1, X, 1 ) ELSE IF( J.LT.N ) THEN SUMJ = DDOT( N-J, A( J+1, J ), 1, X( J+1 ), 1 ) END IF ELSE * * Otherwise, use in-line code for the dot product. * IF( UPPER ) THEN DO 120 I = 1, J - 1 SUMJ = SUMJ + ( A( I, J )*USCAL )*X( I ) 120 CONTINUE ELSE IF( J.LT.N ) THEN DO 130 I = J + 1, N SUMJ = SUMJ + ( A( I, J )*USCAL )*X( I ) 130 CONTINUE END IF END IF * IF( USCAL.EQ.TSCAL ) THEN * * Compute x(j) := ( x(j) - sumj ) / A(j,j) if 1/A(j,j) * was not used to scale the dotproduct. * X( J ) = X( J ) - SUMJ XJ = ABS( X( J ) ) IF( NOUNIT ) THEN TJJS = A( J, J )*TSCAL ELSE TJJS = TSCAL IF( TSCAL.EQ.ONE ) $ GO TO 150 END IF * * Compute x(j) = x(j) / A(j,j), scaling if necessary. * TJJ = ABS( TJJS ) IF( TJJ.GT.SMLNUM ) THEN * * abs(A(j,j)) > SMLNUM: * IF( TJJ.LT.ONE ) THEN IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale X by 1/abs(x(j)). * REC = ONE / XJ CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF END IF X( J ) = X( J ) / TJJS ELSE IF( TJJ.GT.ZERO ) THEN * * 0 < abs(A(j,j)) <= SMLNUM: * IF( XJ.GT.TJJ*BIGNUM ) THEN * * Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM. * REC = ( TJJ*BIGNUM ) / XJ CALL DSCAL( N, REC, X, 1 ) SCALE = SCALE*REC XMAX = XMAX*REC END IF X( J ) = X( J ) / TJJS ELSE * * A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and * scale = 0, and compute a solution to A'*x = 0. * DO 140 I = 1, N X( I ) = ZERO 140 CONTINUE X( J ) = ONE SCALE = ZERO XMAX = ZERO END IF 150 CONTINUE ELSE * * Compute x(j) := x(j) / A(j,j) - sumj if the dot * product has already been divided by 1/A(j,j). * X( J ) = X( J ) / TJJS - SUMJ END IF XMAX = MAX( XMAX, ABS( X( J ) ) ) 160 CONTINUE END IF SCALE = SCALE / TSCAL END IF * * Scale the column norms by 1/TSCAL for return. * IF( TSCAL.NE.ONE ) THEN CALL DSCAL( N, ONE / TSCAL, CNORM, 1 ) END IF * RETURN * * End of DLATRS * END
gpl-2.0
Alexpux/GCC
gcc/testsuite/gfortran.dg/allocate_with_typespec_1.f90
183
2897
! { dg-do compile } ! ! Allocation of arrays with a type-spec specification with implicit none. ! subroutine implicit_none_test1 implicit none real, allocatable :: x(:) real(4), allocatable :: x4(:) real(8), allocatable :: x8(:) double precision, allocatable :: d1(:) doubleprecision, allocatable :: d2(:) character, allocatable :: c1(:) character(len=4), allocatable :: c2(:) type a integer mytype end type a type(a), allocatable :: b(:) allocate(real :: x(1)) allocate(real(4) :: x4(1)) allocate(real(8) :: x8(1)) allocate(double precision :: d1(1)) allocate(doubleprecision :: d2(1)) allocate(character :: c1(1)) allocate(character(len=4) :: c2(1)) allocate(a :: b(1)) end subroutine implicit_none_test1 ! ! Allocation of a scalar with a type-spec specification with implicit none ! subroutine implicit_none_test2 implicit none real, allocatable :: x real(4), allocatable :: x4 real(8), allocatable :: x8 double precision, allocatable :: d1 doubleprecision, allocatable :: d2 character, allocatable :: c1 character(len=4), allocatable :: c2 type a integer mytype end type a type(a), allocatable :: b allocate(real :: x) allocate(real(4) :: x4) allocate(real(8) :: x8) allocate(double precision :: d1) allocate(doubleprecision :: d2) allocate(character :: c1) allocate(character(len=4) :: c2) allocate(a :: b) end subroutine implicit_none_test2 ! ! Allocation of arrays with a type-spec specification with implicit none. ! subroutine implicit_test3 real, allocatable :: x(:) real(4), allocatable :: x4(:) real(8), allocatable :: x8(:) double precision, allocatable :: d1(:) doubleprecision, allocatable :: d2(:) character, allocatable :: c1(:) character(len=4), allocatable :: c2(:) type a integer mytype end type a type(a), allocatable :: b(:) allocate(real :: x(1)) allocate(real(4) :: x4(1)) allocate(real(8) :: x8(1)) allocate(double precision :: d1(1)) allocate(doubleprecision :: d2(1)) allocate(character :: c1(1)) allocate(character(len=4) :: c2(1)) allocate(a :: b(1)) end subroutine implicit_test3 ! ! Allocation of a scalar with a type-spec specification without implicit none ! subroutine implicit_test4 real, allocatable :: x real(4), allocatable :: x4 real(8), allocatable :: x8 double precision, allocatable :: d1 doubleprecision, allocatable :: d2 character, allocatable :: c1 character(len=4), allocatable :: c2 type a integer mytype end type a type(a), allocatable :: b allocate(real :: x) allocate(real(4) :: x4) allocate(real(8) :: x8) allocate(double precision :: d1) allocate(doubleprecision :: d2) allocate(character :: c1) allocate(character(len=4) :: c2) allocate(a :: b) end subroutine implicit_test4
gpl-2.0
ajjl/ITK
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/lapack/double/dsteqr.f
47
13876
SUBROUTINE DSTEQR( COMPZ, N, D, E, Z, LDZ, WORK, INFO ) * * -- LAPACK routine (version 3.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2006 * * .. Scalar Arguments .. CHARACTER COMPZ INTEGER INFO, LDZ, N * .. * .. Array Arguments .. DOUBLE PRECISION D( * ), E( * ), WORK( * ), Z( LDZ, * ) * .. * * Purpose * ======= * * DSTEQR computes all eigenvalues and, optionally, eigenvectors of a * symmetric tridiagonal matrix using the implicit QL or QR method. * The eigenvectors of a full or band symmetric matrix can also be found * if DSYTRD or DSPTRD or DSBTRD has been used to reduce this matrix to * tridiagonal form. * * Arguments * ========= * * COMPZ (input) CHARACTER*1 * = 'N': Compute eigenvalues only. * = 'V': Compute eigenvalues and eigenvectors of the original * symmetric matrix. On entry, Z must contain the * orthogonal matrix used to reduce the original matrix * to tridiagonal form. * = 'I': Compute eigenvalues and eigenvectors of the * tridiagonal matrix. Z is initialized to the identity * matrix. * * N (input) INTEGER * The order of the matrix. N >= 0. * * D (input/output) DOUBLE PRECISION array, dimension (N) * On entry, the diagonal elements of the tridiagonal matrix. * On exit, if INFO = 0, the eigenvalues in ascending order. * * E (input/output) DOUBLE PRECISION array, dimension (N-1) * On entry, the (n-1) subdiagonal elements of the tridiagonal * matrix. * On exit, E has been destroyed. * * Z (input/output) DOUBLE PRECISION array, dimension (LDZ, N) * On entry, if COMPZ = 'V', then Z contains the orthogonal * matrix used in the reduction to tridiagonal form. * On exit, if INFO = 0, then if COMPZ = 'V', Z contains the * orthonormal eigenvectors of the original symmetric matrix, * and if COMPZ = 'I', Z contains the orthonormal eigenvectors * of the symmetric tridiagonal matrix. * If COMPZ = 'N', then Z is not referenced. * * LDZ (input) INTEGER * The leading dimension of the array Z. LDZ >= 1, and if * eigenvectors are desired, then LDZ >= max(1,N). * * WORK (workspace) DOUBLE PRECISION array, dimension (max(1,2*N-2)) * If COMPZ = 'N', then WORK is not referenced. * * INFO (output) INTEGER * = 0: successful exit * < 0: if INFO = -i, the i-th argument had an illegal value * > 0: the algorithm has failed to find all the eigenvalues in * a total of 30*N iterations; if INFO = i, then i * elements of E have not converged to zero; on exit, D * and E contain the elements of a symmetric tridiagonal * matrix which is orthogonally similar to the original * matrix. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO, ONE, TWO, THREE PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0, $ THREE = 3.0D0 ) INTEGER MAXIT PARAMETER ( MAXIT = 30 ) * .. * .. Local Scalars .. INTEGER I, ICOMPZ, II, ISCALE, J, JTOT, K, L, L1, LEND, $ LENDM1, LENDP1, LENDSV, LM1, LSV, M, MM, MM1, $ NM1, NMAXIT DOUBLE PRECISION ANORM, B, C, EPS, EPS2, F, G, P, R, RT1, RT2, $ S, SAFMAX, SAFMIN, SSFMAX, SSFMIN, TST * .. * .. External Functions .. LOGICAL LSAME DOUBLE PRECISION DLAMCH, DLANST, DLAPY2 EXTERNAL LSAME, DLAMCH, DLANST, DLAPY2 * .. * .. External Subroutines .. EXTERNAL DLAE2, DLAEV2, DLARTG, DLASCL, DLASET, DLASR, $ DLASRT, DSWAP, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC ABS, MAX, SIGN, SQRT * .. * .. Executable Statements .. * * Test the input parameters. * INFO = 0 * IF( LSAME( COMPZ, 'N' ) ) THEN ICOMPZ = 0 ELSE IF( LSAME( COMPZ, 'V' ) ) THEN ICOMPZ = 1 ELSE IF( LSAME( COMPZ, 'I' ) ) THEN ICOMPZ = 2 ELSE ICOMPZ = -1 END IF IF( ICOMPZ.LT.0 ) THEN INFO = -1 ELSE IF( N.LT.0 ) THEN INFO = -2 ELSE IF( ( LDZ.LT.1 ) .OR. ( ICOMPZ.GT.0 .AND. LDZ.LT.MAX( 1, $ N ) ) ) THEN INFO = -6 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'DSTEQR', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 ) $ RETURN * IF( N.EQ.1 ) THEN IF( ICOMPZ.EQ.2 ) $ Z( 1, 1 ) = ONE RETURN END IF * * Determine the unit roundoff and over/underflow thresholds. * EPS = DLAMCH( 'E' ) EPS2 = EPS**2 SAFMIN = DLAMCH( 'S' ) SAFMAX = ONE / SAFMIN SSFMAX = SQRT( SAFMAX ) / THREE SSFMIN = SQRT( SAFMIN ) / EPS2 * * Compute the eigenvalues and eigenvectors of the tridiagonal * matrix. * IF( ICOMPZ.EQ.2 ) $ CALL DLASET( 'Full', N, N, ZERO, ONE, Z, LDZ ) * NMAXIT = N*MAXIT JTOT = 0 * * Determine where the matrix splits and choose QL or QR iteration * for each block, according to whether top or bottom diagonal * element is smaller. * L1 = 1 NM1 = N - 1 * 10 CONTINUE IF( L1.GT.N ) $ GO TO 160 IF( L1.GT.1 ) $ E( L1-1 ) = ZERO IF( L1.LE.NM1 ) THEN DO 20 M = L1, NM1 TST = ABS( E( M ) ) IF( TST.EQ.ZERO ) $ GO TO 30 IF( TST.LE.( SQRT( ABS( D( M ) ) )*SQRT( ABS( D( M+ $ 1 ) ) ) )*EPS ) THEN E( M ) = ZERO GO TO 30 END IF 20 CONTINUE END IF M = N * 30 CONTINUE L = L1 LSV = L LEND = M LENDSV = LEND L1 = M + 1 IF( LEND.EQ.L ) $ GO TO 10 * * Scale submatrix in rows and columns L to LEND * ANORM = DLANST( 'I', LEND-L+1, D( L ), E( L ) ) ISCALE = 0 IF( ANORM.EQ.ZERO ) $ GO TO 10 IF( ANORM.GT.SSFMAX ) THEN ISCALE = 1 CALL DLASCL( 'G', 0, 0, ANORM, SSFMAX, LEND-L+1, 1, D( L ), N, $ INFO ) CALL DLASCL( 'G', 0, 0, ANORM, SSFMAX, LEND-L, 1, E( L ), N, $ INFO ) ELSE IF( ANORM.LT.SSFMIN ) THEN ISCALE = 2 CALL DLASCL( 'G', 0, 0, ANORM, SSFMIN, LEND-L+1, 1, D( L ), N, $ INFO ) CALL DLASCL( 'G', 0, 0, ANORM, SSFMIN, LEND-L, 1, E( L ), N, $ INFO ) END IF * * Choose between QL and QR iteration * IF( ABS( D( LEND ) ).LT.ABS( D( L ) ) ) THEN LEND = LSV L = LENDSV END IF * IF( LEND.GT.L ) THEN * * QL Iteration * * Look for small subdiagonal element. * 40 CONTINUE IF( L.NE.LEND ) THEN LENDM1 = LEND - 1 DO 50 M = L, LENDM1 TST = ABS( E( M ) )**2 IF( TST.LE.( EPS2*ABS( D( M ) ) )*ABS( D( M+1 ) )+ $ SAFMIN )GO TO 60 50 CONTINUE END IF * M = LEND * 60 CONTINUE IF( M.LT.LEND ) $ E( M ) = ZERO P = D( L ) IF( M.EQ.L ) $ GO TO 80 * * If remaining matrix is 2-by-2, use DLAE2 or SLAEV2 * to compute its eigensystem. * IF( M.EQ.L+1 ) THEN IF( ICOMPZ.GT.0 ) THEN CALL DLAEV2( D( L ), E( L ), D( L+1 ), RT1, RT2, C, S ) WORK( L ) = C WORK( N-1+L ) = S CALL DLASR( 'R', 'V', 'B', N, 2, WORK( L ), $ WORK( N-1+L ), Z( 1, L ), LDZ ) ELSE CALL DLAE2( D( L ), E( L ), D( L+1 ), RT1, RT2 ) END IF D( L ) = RT1 D( L+1 ) = RT2 E( L ) = ZERO L = L + 2 IF( L.LE.LEND ) $ GO TO 40 GO TO 140 END IF * IF( JTOT.EQ.NMAXIT ) $ GO TO 140 JTOT = JTOT + 1 * * Form shift. * G = ( D( L+1 )-P ) / ( TWO*E( L ) ) R = DLAPY2( G, ONE ) G = D( M ) - P + ( E( L ) / ( G+SIGN( R, G ) ) ) * S = ONE C = ONE P = ZERO * * Inner loop * MM1 = M - 1 DO 70 I = MM1, L, -1 F = S*E( I ) B = C*E( I ) CALL DLARTG( G, F, C, S, R ) IF( I.NE.M-1 ) $ E( I+1 ) = R G = D( I+1 ) - P R = ( D( I )-G )*S + TWO*C*B P = S*R D( I+1 ) = G + P G = C*R - B * * If eigenvectors are desired, then save rotations. * IF( ICOMPZ.GT.0 ) THEN WORK( I ) = C WORK( N-1+I ) = -S END IF * 70 CONTINUE * * If eigenvectors are desired, then apply saved rotations. * IF( ICOMPZ.GT.0 ) THEN MM = M - L + 1 CALL DLASR( 'R', 'V', 'B', N, MM, WORK( L ), WORK( N-1+L ), $ Z( 1, L ), LDZ ) END IF * D( L ) = D( L ) - P E( L ) = G GO TO 40 * * Eigenvalue found. * 80 CONTINUE D( L ) = P * L = L + 1 IF( L.LE.LEND ) $ GO TO 40 GO TO 140 * ELSE * * QR Iteration * * Look for small superdiagonal element. * 90 CONTINUE IF( L.NE.LEND ) THEN LENDP1 = LEND + 1 DO 100 M = L, LENDP1, -1 TST = ABS( E( M-1 ) )**2 IF( TST.LE.( EPS2*ABS( D( M ) ) )*ABS( D( M-1 ) )+ $ SAFMIN )GO TO 110 100 CONTINUE END IF * M = LEND * 110 CONTINUE IF( M.GT.LEND ) $ E( M-1 ) = ZERO P = D( L ) IF( M.EQ.L ) $ GO TO 130 * * If remaining matrix is 2-by-2, use DLAE2 or SLAEV2 * to compute its eigensystem. * IF( M.EQ.L-1 ) THEN IF( ICOMPZ.GT.0 ) THEN CALL DLAEV2( D( L-1 ), E( L-1 ), D( L ), RT1, RT2, C, S ) WORK( M ) = C WORK( N-1+M ) = S CALL DLASR( 'R', 'V', 'F', N, 2, WORK( M ), $ WORK( N-1+M ), Z( 1, L-1 ), LDZ ) ELSE CALL DLAE2( D( L-1 ), E( L-1 ), D( L ), RT1, RT2 ) END IF D( L-1 ) = RT1 D( L ) = RT2 E( L-1 ) = ZERO L = L - 2 IF( L.GE.LEND ) $ GO TO 90 GO TO 140 END IF * IF( JTOT.EQ.NMAXIT ) $ GO TO 140 JTOT = JTOT + 1 * * Form shift. * G = ( D( L-1 )-P ) / ( TWO*E( L-1 ) ) R = DLAPY2( G, ONE ) G = D( M ) - P + ( E( L-1 ) / ( G+SIGN( R, G ) ) ) * S = ONE C = ONE P = ZERO * * Inner loop * LM1 = L - 1 DO 120 I = M, LM1 F = S*E( I ) B = C*E( I ) CALL DLARTG( G, F, C, S, R ) IF( I.NE.M ) $ E( I-1 ) = R G = D( I ) - P R = ( D( I+1 )-G )*S + TWO*C*B P = S*R D( I ) = G + P G = C*R - B * * If eigenvectors are desired, then save rotations. * IF( ICOMPZ.GT.0 ) THEN WORK( I ) = C WORK( N-1+I ) = S END IF * 120 CONTINUE * * If eigenvectors are desired, then apply saved rotations. * IF( ICOMPZ.GT.0 ) THEN MM = L - M + 1 CALL DLASR( 'R', 'V', 'F', N, MM, WORK( M ), WORK( N-1+M ), $ Z( 1, M ), LDZ ) END IF * D( L ) = D( L ) - P E( LM1 ) = G GO TO 90 * * Eigenvalue found. * 130 CONTINUE D( L ) = P * L = L - 1 IF( L.GE.LEND ) $ GO TO 90 GO TO 140 * END IF * * Undo scaling if necessary * 140 CONTINUE IF( ISCALE.EQ.1 ) THEN CALL DLASCL( 'G', 0, 0, SSFMAX, ANORM, LENDSV-LSV+1, 1, $ D( LSV ), N, INFO ) CALL DLASCL( 'G', 0, 0, SSFMAX, ANORM, LENDSV-LSV, 1, E( LSV ), $ N, INFO ) ELSE IF( ISCALE.EQ.2 ) THEN CALL DLASCL( 'G', 0, 0, SSFMIN, ANORM, LENDSV-LSV+1, 1, $ D( LSV ), N, INFO ) CALL DLASCL( 'G', 0, 0, SSFMIN, ANORM, LENDSV-LSV, 1, E( LSV ), $ N, INFO ) END IF * * Check for no convergence to an eigenvalue after a total * of N*MAXIT iterations. * IF( JTOT.LT.NMAXIT ) $ GO TO 10 DO 150 I = 1, N - 1 IF( E( I ).NE.ZERO ) $ INFO = INFO + 1 150 CONTINUE GO TO 190 * * Order eigenvalues and eigenvectors. * 160 CONTINUE IF( ICOMPZ.EQ.0 ) THEN * * Use Quick Sort * CALL DLASRT( 'I', N, D, INFO ) * ELSE * * Use Selection Sort to minimize swaps of eigenvectors * DO 180 II = 2, N I = II - 1 K = I P = D( I ) DO 170 J = II, N IF( D( J ).LT.P ) THEN K = J P = D( J ) END IF 170 CONTINUE IF( K.NE.I ) THEN D( K ) = D( I ) D( I ) = P CALL DSWAP( N, Z( 1, I ), 1, Z( 1, K ), 1 ) END IF 180 CONTINUE END IF * 190 CONTINUE RETURN * * End of DSTEQR * END
apache-2.0
tenstream/tenstream
src/mcdmda.F90
1
56649
!------------------------------------------------------------------------- ! This file is part of the tenstream solver. ! ! This program is free software: you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation, either version 3 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. If not, see <http://www.gnu.org/licenses/>. ! ! Copyright (C) 2010-2015 Fabian Jakub, <fabian@jakub.com> !------------------------------------------------------------------------- module m_mcdmda use iso_fortran_env, only: int64, output_unit use iso_c_binding, only: c_backspace #include "petsc/finclude/petsc.h" use petsc use m_data_parameters, only: ireals, iintegers, ireal_dp, & mpiint, imp_iinteger, imp_int8, & zero, i0, i1, i2, i3, i4, i5, i6, pi use m_helper_functions, only: & & CHKERR, & & CHKWARN, & & cstr, & & deg2rad, & & expm1, & & get_arg, & & get_petsc_opt, & & imp_allreduce_sum, & & ind_1d_to_nd, & & ind_nd_to_1d, & & ndarray_offsets, & & rotate_angle_x, & & rotate_angle_y, & & spherical_2_cartesian, & & toStr use m_boxmc, only: t_photon, print_photon, scatter_photon, roulette, R, & tau, distance, update_photon_loc, absorb_photon, & t_boxmc, t_boxmc_1_2, t_boxmc_3_6, & imp_t_photon use m_boxmc_geometry, only: setup_default_unit_cube_geometry use m_pprts_base, only: & & atmk, & & t_coord, & & t_solver, & & t_solver_1_2, & & t_solver_3_6, & & t_solver_mcdmda, & & t_state_container use m_petsc_helpers, only: getVecPointer, restoreVecPointer use m_buildings, only: & & t_pprts_buildings, & & PPRTS_TOP_FACE, & & PPRTS_BOT_FACE, & & PPRTS_LEFT_FACE, & & PPRTS_RIGHT_FACE, & & PPRTS_FRONT_FACE, & & PPRTS_REAR_FACE use m_linked_list_iintegers, only: t_list_iintegers, t_node implicit none ! queue status indices integer(iintegers), parameter :: & PQ_SELF = 1, & PQ_NORTH = 2, & PQ_EAST = 3, & PQ_SOUTH = 4, & PQ_WEST = 5 character(len=16), parameter :: id2name(5) = [ & & character(len=16) :: & & 'PQ_SELF', & & 'PQ_NORTH', & & 'PQ_EAST', & & 'PQ_SOUTH', & & 'PQ_WEST' & & ] type :: t_distributed_photon type(t_photon) :: p integer(mpiint) :: request end type type :: t_photon_queue type(t_distributed_photon), allocatable :: photons(:) type(t_list_iintegers) :: ready ! linked list for read_to_go photon indices type(t_list_iintegers) :: empty ! linked_list of empty slots in this queue type(t_list_iintegers) :: sending ! linked_list of sending slots in this queue integer(mpiint) :: owner ! owner is the owning rank, i.e. myid or the neighbor id integer(iintegers) :: queue_index ! is the STATUS integer, i.e. one of PQ_SELF, PQ_NORTH etc. end type logical, parameter :: ldebug = .false. logical, parameter :: ldebug_tracing = .false. real(ireal_dp), parameter :: loceps = 0 !sqrt(epsilon(loceps)) real(ireals), parameter :: blocking_waittime = 5 ! sec contains subroutine solve_mcdmda(solver, edirTOA, solution, ierr, opt_buildings) class(t_solver), intent(in) :: solver real(ireals), intent(in) :: edirTOA type(t_state_container) :: solution integer(mpiint), intent(out) :: ierr type(t_pprts_buildings), intent(in), optional :: opt_buildings integer(mpiint) :: myid type(t_photon_queue) :: pqueues(5) ! [own, north, east, south, west] integer(iintegers) :: Nqueuesize, Nbatchsize integer(iintegers) :: Nphotons_global integer(iintegers) :: locally_started_photons, globally_started_photons, globally_killed_photons integer(iintegers) :: Nphotons_local integer(iintegers) :: started_photons integer(iintegers) :: killed_photons integer(iintegers) :: ip, kp integer(iintegers) :: iter, percent_printed, last_percent_printed integer(mpiint) :: started_request, killed_request, stat(mpi_status_size) logical :: lcomm_finished, lflg, lfirst_print, lfinish_border_photons_first real(ireals) :: photon_weight class(t_boxmc), allocatable :: bmc real(ireal_dp), dimension(:, :, :, :), allocatable :: edir, ediff, abso integer(iintegers), dimension(:, :, :, :), allocatable :: Nediff, buildings_idx ierr = 0 call determine_Nphotons(solver, Nphotons_local, ierr); call CHKERR(ierr) call mpi_allreduce(Nphotons_local, Nphotons_global, 1_mpiint, imp_iinteger, & MPI_SUM, solver%comm, ierr); call CHKERR(ierr) call mpi_comm_rank(solver%comm, myid, ierr); call CHKERR(ierr) Nbatchsize = 10000 call get_petsc_opt(solver%prefix, "-mcdmda_batch_size", Nbatchsize, lflg, ierr); call CHKERR(ierr) Nqueuesize = Nphotons_local call get_petsc_opt(solver%prefix, "-mcdmda_queue_size", Nqueuesize, lflg, ierr); call CHKERR(ierr) lfinish_border_photons_first = .false. call get_petsc_opt(solver%prefix, "-mcdmda_finish_border_photons_first", lfinish_border_photons_first, lflg, ierr) call CHKERR(ierr) associate (C => solver%C_one_atm, C1 => solver%C_one_atm1, Cdir => solver%C_dir, Cdiff => solver%C_diff) if (ldebug) then print *, myid, 'Edir TOA', edirTOA, ': Nphotons_local', Nphotons_local, 'Nphotons_global', Nphotons_global print *, myid, 'Domain start:', C%zs, C%xs, C%ys print *, myid, 'Domain end :', C%ze, C%xe, C%ye print *, myid, 'Domain Size :', C%zm, C%xm, C%ym print *, myid, 'Global Size :', C%glob_zm, C%glob_xm, C%glob_ym print *, myid, 'my neighs NESW', & C%neighbors(22), C%neighbors(16), C%neighbors(4), C%neighbors(10) end if if (solution%lsolar_rad) then allocate (edir(0:Cdir%dof - 1, C1%zs:C1%ze, C%gxs:C%gxe, C%gys:C%gye), source=0._ireal_dp) photon_weight = edirTOA * real(solver%sun%costheta, ireals) & & * solver%C_one_atm%xm * solver%C_one_atm%ym / real(Nphotons_local, ireals) else photon_weight = 0 end if allocate ( & & ediff(0:Cdiff%dof - 1, C1%zs:C1%ze, C%gxs:C%gxe, C%gys:C%gye), & & abso(0:C%dof - 1, C%zs:C%ze, C%xs:C%xe, C%ys:C%ye), & & source=0._ireal_dp) allocate ( & & Nediff(0:Cdiff%dof - 1, C1%zs:C1%ze, C%gxs:C%gxe, C%gys:C%gye), & & source=0_iintegers) call fill_buildings_idx(solver, opt_buildings, buildings_idx) call setup_photon_queue(pqueues(PQ_SELF), Nphotons_local, myid, PQ_SELF) call setup_photon_queue(pqueues(PQ_NORTH), Nqueuesize, C%neighbors(22), PQ_NORTH) call setup_photon_queue(pqueues(PQ_EAST), Nqueuesize, C%neighbors(16), PQ_EAST) call setup_photon_queue(pqueues(PQ_SOUTH), Nqueuesize, C%neighbors(4), PQ_SOUTH) call setup_photon_queue(pqueues(PQ_WEST), Nqueuesize, C%neighbors(10), PQ_WEST) if (C%neighbors(22) .lt. zero) call CHKERR(C%neighbors(22), 'Bad neighbor id for PQ_NORTH') if (C%neighbors(16) .lt. zero) call CHKERR(C%neighbors(16), 'Bad neighbor id for PQ_EAST') if (C%neighbors(4) .lt. zero) call CHKERR(C%neighbors(4), 'Bad neighbor id for PQ_SOUTH') if (C%neighbors(10) .lt. zero) call CHKERR(C%neighbors(10), 'Bad neighbor id for PQ_WEST') end associate select type (solver) class is (t_solver_1_2) allocate (t_boxmc_1_2 :: bmc) class is (t_solver_3_6) allocate (t_boxmc_3_6 :: bmc) class is (t_solver_mcdmda) allocate (t_boxmc_3_6 :: bmc) class default call CHKERR(1_mpiint, 'initialize bmc for mcdmda: unexpected type for solver object for DMDA computations!'// & '-- call with -solver 1_2 or -solver 3_6') end select if (ldebug_tracing) then call bmc%init(MPI_COMM_SELF, rngseed=9, luse_random_seed=.false.) else call bmc%init(MPI_COMM_SELF, luse_random_seed=.true.) end if ! Initialize the locally owned photons call prepare_locally_owned_photons(solver, bmc, solution%lsolar_rad, pqueues(PQ_SELF), Nphotons_local, weight=photon_weight) killed_photons = 0 call mpi_iallreduce(killed_photons, globally_killed_photons, 1_mpiint, imp_iinteger, & MPI_SUM, solver%comm, killed_request, ierr); call CHKERR(ierr) if (ldebug) then lfirst_print = .true. locally_started_photons = 0 call mpi_iallreduce(locally_started_photons, globally_started_photons, 1_mpiint, imp_iinteger, & MPI_SUM, solver%comm, started_request, ierr); call CHKERR(ierr) end if last_percent_printed = -1 iter = 0 do iter = iter + 1 call run_photon_queue( & & solver, bmc, & & pqueues, PQ_SELF, & & edir, ediff, Nediff, abso, & & started_photons=ip, & & killed_photons=kp, & & limit_number_photons=Nbatchsize, & & opt_buildings=opt_buildings, & & buildings_idx=buildings_idx) locally_started_photons = locally_started_photons + ip started_photons = ip; killed_photons = killed_photons + kp if (ldebug) print *, 'SELF', 'started_photons', started_photons, 'killed_photons', killed_photons remote_photons: do ! Run remote photons until they are done, only then go on, this hopefully keeps the queue small started_photons = 0 call exchange_photons(solver, pqueues) call run_photon_queue(& & solver, bmc, & & pqueues, PQ_NORTH, & & edir, ediff, Nediff, abso, & & started_photons=ip, & & killed_photons=kp, & & opt_buildings=opt_buildings, & & buildings_idx=buildings_idx) started_photons = started_photons + ip; killed_photons = killed_photons + kp if (ldebug) print *, 'NORTH', 'started_photons', ip, 'killed_photons', kp call exchange_photons(solver, pqueues) call run_photon_queue( & & solver, bmc, & & pqueues, PQ_EAST, & & edir, ediff, Nediff, abso, & & started_photons=ip, & & killed_photons=kp, & & opt_buildings=opt_buildings, & & buildings_idx=buildings_idx) started_photons = started_photons + ip; killed_photons = killed_photons + kp if (ldebug) print *, 'EAST', 'started_photons', ip, 'killed_photons', kp call exchange_photons(solver, pqueues) call run_photon_queue( & & solver, bmc, & & pqueues, PQ_SOUTH, & & edir, ediff, Nediff, abso, & & started_photons=ip, & & killed_photons=kp, & & opt_buildings=opt_buildings, & & buildings_idx=buildings_idx) started_photons = started_photons + ip; killed_photons = killed_photons + kp if (ldebug) print *, 'SOUTH', 'started_photons', ip, 'killed_photons', kp call exchange_photons(solver, pqueues) call run_photon_queue( & & solver, bmc, & & pqueues, PQ_WEST, & & edir, ediff, Nediff, abso, & & started_photons=ip, & & killed_photons=kp, & & opt_buildings=opt_buildings, & & buildings_idx=buildings_idx) started_photons = started_photons + ip; killed_photons = killed_photons + kp if (ldebug) print *, 'WEST', 'started_photons', ip, 'killed_photons', kp call exchange_photons(solver, pqueues) if (.not. lfinish_border_photons_first) then exit remote_photons elseif (started_photons .eq. 0) then exit remote_photons end if end do remote_photons if (ldebug) then if (lfirst_print .or. globally_started_photons .ne. Nphotons_global) then call mpi_test(started_request, lcomm_finished, stat, ierr); call CHKERR(ierr) if (lcomm_finished) then if (globally_started_photons .eq. Nphotons_global) lfirst_print = .false. if (myid .eq. 0) print *, iter, & 'Globally started photons', globally_started_photons, '/', Nphotons_global, & '('//toStr(100 * real(globally_started_photons) / real(Nphotons_global))//' % )' call mpi_iallreduce(locally_started_photons, globally_started_photons, 1_mpiint, imp_iinteger, & MPI_SUM, solver%comm, started_request, ierr); call CHKERR(ierr) end if end if end if call mpi_test(killed_request, lcomm_finished, stat, ierr); call CHKERR(ierr) if (lcomm_finished) then if (myid .eq. 0) then percent_printed = int(100 * real(globally_killed_photons) / real(Nphotons_global), kind(percent_printed)) if (ldebug .or. percent_printed .ne. last_percent_printed) then !print *, iter, 'Globally killed photons', globally_killed_photons, '/', Nphotons_global, & ! '('//toStr(percent_printed)//' % )' write (*, fmt="(A)", advance='no') repeat(c_backspace, 100)//toStr(iter)// & & ' Globally killed photons '//toStr(globally_killed_photons)//' / '//toStr(Nphotons_global)// & & '( '//toStr(percent_printed)//' % )' call flush (output_unit) last_percent_printed = percent_printed end if end if if (ldebug) call debug_output_queues() if (globally_killed_photons .eq. Nphotons_global) then exit end if ! if we reach here this means there is still work todo, setup a new allreduce call mpi_iallreduce(killed_photons, globally_killed_photons, 1_mpiint, imp_iinteger, & MPI_SUM, solver%comm, killed_request, ierr); call CHKERR(ierr) end if end do call get_result() ! cleanup call bmc%destroy(ierr); call CHKERR(ierr) do ip = 1, size(pqueues) call photon_queue_destroy(pqueues(ip), ierr); call CHKERR(ierr) end do contains subroutine fill_buildings_idx(solver, opt_buildings, buildings_idx) class(t_solver), intent(in) :: solver type(t_pprts_buildings), intent(in), optional :: opt_buildings integer(iintegers), dimension(:, :, :, :), allocatable :: buildings_idx integer(iintegers) :: m, idx(4) if (present(opt_buildings)) then associate (C => solver%C_one_atm, C_diff => solver%C_diff, atm => solver%atm) allocate (buildings_idx(6, C%zs:C%ze, C%xs:C%xe, C%ys:C%ye)) buildings_idx = -1 associate (B => opt_buildings) do m = 1, size(B%iface) call ind_1d_to_nd(B%da_offsets, B%iface(m), idx) idx(2:4) = idx(2:4) - 1 + [C_diff%zs, C_diff%xs, C_diff%ys] associate (k => idx(2), i => idx(3), j => idx(4)) select case (idx(1)) case (PPRTS_TOP_FACE) buildings_idx(PPRTS_TOP_FACE, atmk(atm, k), i, j) = m case (PPRTS_BOT_FACE) buildings_idx(PPRTS_BOT_FACE, atmk(atm, k), i, j) = m case (PPRTS_LEFT_FACE) buildings_idx(PPRTS_LEFT_FACE, atmk(atm, k), i, j) = m case (PPRTS_RIGHT_FACE) buildings_idx(PPRTS_RIGHT_FACE, atmk(atm, k), i, j) = m case (PPRTS_REAR_FACE) buildings_idx(PPRTS_REAR_FACE, atmk(atm, k), i, j) = m case (PPRTS_FRONT_FACE) buildings_idx(PPRTS_FRONT_FACE, atmk(atm, k), i, j) = m end select end associate end do end associate end associate end if end subroutine subroutine get_result() type(tVec) :: ediff_local, edir_local real(ireals), pointer, dimension(:, :, :, :) :: xv_dir => null(), xv_diff => null(), xv_abso => null() real(ireals), pointer, dimension(:) :: xv_dir1d => null(), xv_diff1d => null(), xv_abso1d => null() integer(iintegers) :: Nundersampled associate (& & atm => solver%atm,& & C_one => solver%C_one, & & C_dir => solver%C_dir, & & C_diff => solver%C_diff, & & C_one_atm => solver%C_one_atm,& & C_one_atm1 => solver%C_one_atm1) if (solution%lsolar_rad) then ! handle edir call DMGetLocalVector(C_dir%da, edir_local, ierr); call CHKERR(ierr) call getVecPointer(C_dir%da, edir_local, xv_dir1d, xv_dir) xv_dir(:, C_dir%zs + 1:, :, :) = real(& & edir(:, atmk(atm, C_one_atm1%zs + 1):C_one_atm1%ze, :, :), & & kind(xv_dir)) xv_dir(:, C_dir%zs, :, :) = real(edir(:, C_one_atm1%zs, :, :), kind(xv_dir)) call restoreVecPointer(C_dir%da, edir_local, xv_dir1d, xv_dir) call DMLocalToGlobalBegin(C_dir%da, edir_local, ADD_VALUES, solution%edir, ierr); call CHKERR(ierr) call DMLocalToGlobalEnd(C_dir%da, edir_local, ADD_VALUES, solution%edir, ierr); call CHKERR(ierr) call DMRestoreLocalVector(C_dir%da, edir_local, ierr); call CHKERR(ierr) call PetscObjectSetName(solution%edir, 'edir', ierr); call CHKERR(ierr) call PetscObjectViewFromOptions(solution%edir, PETSC_NULL_VEC, '-mcdmda_show_edir', ierr); call CHKERR(ierr) end if ! handle normalization of ediff call DMGetLocalVector(C_diff%da, ediff_local, ierr); call CHKERR(ierr) call VecSet(ediff_local, zero, ierr); call CHKERR(ierr) call getVecPointer(C_diff%da, ediff_local, xv_diff1d, xv_diff) if (.not. solution%lsolar_rad) then Nundersampled = count(Nediff .gt. 0_iintegers .and. Nediff .le. 10) call CHKWARN(int(Nundersampled, mpiint), 'Found '//toStr(Nundersampled)//' fluxes that were certainly reacheable,'// & & 'but were sampled crudely. This may lead to large biases in the results. Please consider using more photons!') ediff = ediff * real(pi, kind(ediff)) / real(max(1_iintegers, Nediff), kind(ediff)) end if xv_diff(:, C_diff%zs + 1:, :, :) = real(& & ediff(:, atmk(atm, C_one_atm1%zs + 1):C_one_atm1%ze, :, :), & & kind(xv_diff)) xv_diff(:, C_diff%zs, :, :) = real(ediff(:, C_one_atm1%zs, :, :), kind(xv_diff)) call restoreVecPointer(C_diff%da, ediff_local, xv_diff1d, xv_diff) call DMLocalToGlobalBegin(C_diff%da, ediff_local, ADD_VALUES, solution%ediff, ierr); call CHKERR(ierr) call DMLocalToGlobalEnd(C_diff%da, ediff_local, ADD_VALUES, solution%ediff, ierr); call CHKERR(ierr) call DMRestoreLocalVector(C_diff%da, ediff_local, ierr); call CHKERR(ierr) call PetscObjectSetName(solution%ediff, 'ediff', ierr); call CHKERR(ierr) call PetscObjectViewFromOptions(solution%ediff, PETSC_NULL_VEC, '-mcdmda_show_ediff', ierr); call CHKERR(ierr) ! absorption call getVecPointer(C_one%da, solution%abso, xv_abso1d, xv_abso) if (.not. solution%lsolar_rad) then abso = abso * pi * C_one%glob_xm * C_one%glob_ym / Nphotons_global end if xv_abso(i0, :, :, :) = real(& & abso(i0, atmk(atm, C_one_atm%zs):C_one_atm%ze, :, :) & & / atm%dz(atmk(atm, C_one_atm%zs):C_one_atm%ze, :, :), & & kind(xv_abso)) ! eventually collapsed entry at the top xv_abso(i0, C_one%zs, :, :) = real( & & sum(abso(i0, :atmk(atm, C_one_atm%zs), :, :), dim=1) & & / sum(atm%dz(:atmk(atm, C_one_atm%zs), :, :), dim=1), kind(xv_abso)) call restoreVecPointer(C_one%da, solution%abso, xv_abso1d, xv_abso) end associate call PetscObjectViewFromOptions(solution%abso, PETSC_NULL_VEC, '-mcdmda_show_abso', ierr); call CHKERR(ierr) !Rayli solver returns fluxes as [W] solution%lWm2_dir = .true. solution%lWm2_diff = .true. ! and mark solution that it is up to date (to prevent absoprtion computations) solution%lchanged = .false. end subroutine subroutine debug_output_queues() integer(mpiint) :: myid, numnodes, ierr, i call mpi_comm_rank(solver%comm, myid, ierr); call CHKERR(ierr) call mpi_comm_size(solver%comm, numnodes, ierr); call CHKERR(ierr) do i = 0, numnodes - 1 if (i .eq. myid) then print *, '---------- rank ', myid call print_pqueue(pqueues(PQ_SELF)) call print_pqueue(pqueues(PQ_NORTH)) call print_pqueue(pqueues(PQ_EAST)) call print_pqueue(pqueues(PQ_SOUTH)) call print_pqueue(pqueues(PQ_WEST)) end if call mpi_barrier(solver%comm, ierr); call CHKERR(ierr) end do end subroutine end subroutine subroutine determine_Nphotons(solver, Nphotons_local, ierr) class(t_solver), intent(in) :: solver integer(iintegers), intent(out) :: Nphotons_local integer(mpiint), intent(out) :: ierr integer(iintegers) :: mcdmda_photons_per_pixel ! has to be constant over all TOA faces real(ireals) :: rN logical :: lflg integer(mpiint) :: numnodes ierr = 0 call mpi_comm_size(solver%comm, numnodes, ierr); call CHKERR(ierr) mcdmda_photons_per_pixel = 1000 call get_petsc_opt(solver%prefix, "-mcdmda_photons_per_px", & mcdmda_photons_per_pixel, lflg, ierr); call CHKERR(ierr) call get_petsc_opt(solver%prefix, "-mcdmda_photons", rN, lflg, ierr); call CHKERR(ierr) if (lflg) then mcdmda_photons_per_pixel = int(rN, kind(Nphotons_local)) / (numnodes * solver%C_one_atm%xm * solver%C_one_atm%ym) mcdmda_photons_per_pixel = max(1_iintegers, mcdmda_photons_per_pixel) end if Nphotons_local = solver%C_one_atm%xm * solver%C_one_atm%ym * mcdmda_photons_per_pixel end subroutine subroutine photon_queue_destroy(pq, ierr) type(t_photon_queue), intent(inout) :: pq integer(mpiint), intent(out) :: ierr ierr = 0 if (allocated(pq%photons)) deallocate (pq%photons) call pq%ready%finalize() call pq%empty%finalize() call pq%sending%finalize() end subroutine subroutine run_photon_queue(solver, bmc, & & pqueues, ipq, & & edir, ediff, Nediff, abso, & & started_photons, killed_photons, & & limit_number_photons, & & opt_buildings, buildings_idx) class(t_solver), intent(in) :: solver class(t_boxmc), intent(in) :: bmc type(t_photon_queue), intent(inout) :: pqueues(:) ! [own, north, east, south, west] integer(iintegers), intent(in) :: ipq real(ireal_dp), allocatable, dimension(:, :, :, :), intent(inout) :: edir, ediff, abso integer(iintegers), allocatable, dimension(:, :, :, :), intent(inout) :: Nediff integer(iintegers), intent(out) :: started_photons integer(iintegers), intent(out) :: killed_photons integer(iintegers), optional, intent(in) :: limit_number_photons type(t_pprts_buildings), intent(in), optional :: opt_buildings integer(iintegers), allocatable, dimension(:, :, :, :), intent(in) :: buildings_idx integer(iintegers) :: Nphotmax logical :: lkilled_photon if (ldebug) then print *, 'run photon queue ', id2name(pqueues(ipq)%queue_index) call print_pqueue(pqueues(ipq)) end if Nphotmax = get_arg(huge(Nphotmax), limit_number_photons) Nphotmax = min(size(pqueues(ipq)%photons, kind=iintegers), Nphotmax) killed_photons = 0 started_photons = 0 call pqueues(ipq)%ready%for_each(run_ready) contains subroutine run_ready(idx, node, iphoton) integer(iintegers), intent(in) :: idx type(t_node), pointer, intent(inout) :: node integer(iintegers), intent(inout) :: iphoton integer(mpiint) :: ierr if (started_photons .ge. Nphotmax) return call run_photon(& & solver, & & bmc, & & pqueues, & & ipq, & & iphoton, & & edir, & & ediff, & & Nediff, & & abso, & & lkilled_photon, & & opt_buildings=opt_buildings, & & buildings_idx=buildings_idx) started_photons = started_photons + 1 if (lkilled_photon) killed_photons = killed_photons + 1 call pqueues(ipq)%ready%del_node(node, ierr); call CHKERR(ierr) return print *, 'remove unused var warning', idx end subroutine end subroutine subroutine run_photon(solver, bmc, pqueues, ipq, iphoton, & & edir, ediff, Nediff, abso, & & lkilled_photon, & & opt_buildings, buildings_idx) class(t_solver), intent(in) :: solver class(t_boxmc), intent(in) :: bmc type(t_photon_queue), intent(inout) :: pqueues(:) ! [own, north, east, south, west] integer(iintegers), intent(in) :: ipq integer(iintegers), intent(in) :: iphoton real(ireal_dp), allocatable, dimension(:, :, :, :), intent(inout) :: edir, ediff, abso integer(iintegers), allocatable, dimension(:, :, :, :), intent(inout) :: Nediff logical, intent(out) :: lkilled_photon type(t_pprts_buildings), intent(in), optional :: opt_buildings integer(iintegers), allocatable, dimension(:, :, :, :), intent(in) :: buildings_idx logical :: lexit_cell, lthermal, lexit_domain integer(mpiint) :: myid, ierr lkilled_photon = .false. call mpi_comm_rank(solver%comm, myid, ierr); call CHKERR(ierr) associate (p => pqueues(ipq)%photons(iphoton)%p) if (ldebug_tracing) print *, myid, cstr('Start of run_photon :: QUEUE:', 'pink'), id2name(ipq), 'iphoton', iphoton if (ldebug_tracing) call print_photon(p) call check_if_photon_is_in_domain(solver%C_one_atm, p) lthermal = allocated(solver%atm%planck) if (p%src_side .eq. PPRTS_TOP_FACE) then ! started at the top of the box, lets increment TOA downward flux if (p%direct) then p%side = PPRTS_TOP_FACE call update_flx(solver, p, p%k, p%i, p%j, edir, ediff, Nediff) end if end if lexit_domain = .false. lexit_cell = .true. ! mark es exited because it obviously came from some neighbouring box move: do while (.not. lexit_domain) ! this loop will move the photon to the edge of the subdomain if (.not. lthermal) then call roulette(p) if (.not. p%alive) then lkilled_photon = .true. exit move end if end if if (ldebug_tracing) then print *, 'start of move', p%k, p%i, p%j call print_photon(p) end if call check_if_photon_is_in_domain(solver%C_one_atm, p) if (lexit_cell) then ! if photon exited cell before, this is the reentrant state abso(i0, p%k, p%i, p%j) = abso(i0, p%k, p%i, p%j) + real(p%weight, ireals) end if if (present(opt_buildings)) then call building_interaction(lexit_cell) else lexit_cell = .false. end if if (.not. lexit_cell) call move_inside_cell(lexit_cell) ! Define new cellindex and update local position if (.not. lexit_cell) then call scatter_photon_in_cell() else abso(i0, p%k, p%i, p%j) = abso(i0, p%k, p%i, p%j) - real(p%weight, ireals) call exit_cell(lexit_domain) end if end do move call pqueues(ipq)%empty%add(iphoton) end associate contains subroutine scatter_photon_in_cell() associate (p => pqueues(ipq)%photons(iphoton)%p) call scatter_photon(p, real(solver%atm%g(p%k, p%i, p%j), ireal_dp)) p%tau_travel = tau(R()) if (ldebug_tracing) print *, myid, cstr('********************* SCATTERING', 'peach'), p%k, p%i, p%j end associate end subroutine subroutine move_inside_cell(lexit_cell) logical, intent(out) :: lexit_cell real(ireal_dp) :: kabs, ksca, pathlen real(ireal_dp) :: Btop, Bbot, B1, B2, dz, tauabs, tm1 real(ireals), allocatable :: vertices(:) associate (p => pqueues(ipq)%photons(iphoton)%p) kabs = solver%atm%kabs(p%k, p%i, p%j) ksca = solver%atm%ksca(p%k, p%i, p%j) dz = solver%atm%dz(p%k, p%i, p%j) if (lthermal) then Btop = solver%atm%planck(p%k, p%i, p%j) Bbot = solver%atm%planck(p%k + 1, p%i, p%j) B1 = (Btop * p%loc(3) + Bbot * (dz - p%loc(3))) / dz ! planck at start of the ray end if call setup_default_unit_cube_geometry(solver%atm%dx, solver%atm%dy, real(dz, ireals), vertices) call move_photon(bmc, real(vertices, ireal_dp), ksca, p, pathlen, lexit_cell) if (lthermal) then B2 = (Btop * p%loc(3) + Bbot * (dz - p%loc(3))) / dz ! planck at end of the ray tauabs = kabs * pathlen if (tauabs > 1e-10_ireal_dp) then tm1 = expm1(-tauabs) p%weight = p%weight * (tm1 + 1._ireal_dp) + (B2 - B1) - (B1 - (B2 - B1) / tauabs) * tm1 else p%weight = p%weight * (1._ireal_dp - tauabs) + (B1 + B2)*.5_ireal_dp * tauabs end if !print *,p%k, p%i, p%j,'Btop/bot', Btop, Bbot, 'B1,2', B1, B2, 'weight', p%weight, 'kabs', kabs, 'ksca', ksca else ! lsolar call absorb_photon(p, pathlen, kabs) end if end associate end subroutine subroutine building_interaction(lexit_cell) logical, intent(out) :: lexit_cell integer(iintegers) :: bidx real(ireal_dp) :: mu, phi lexit_cell = .false. associate (p => pqueues(ipq)%photons(iphoton)%p) ! p%src_side - side where it is coming from, i.e. where it starts, ! .e.g if flying down, i.e. entering from top, it will be PPRTS_TOP_FACE bidx = buildings_idx(p%src_side, p%k, p%i, p%j) if (bidx .gt. 0) then if (ldebug_tracing) print *, 'hit building @ '//toStr([p%src_side, p%k, p%i, p%j]) p%direct = .false. p%scattercnt = p%scattercnt + 1 p%weight = p%weight * opt_buildings%albedo(bidx) if (lthermal) then p%weight = p%weight + (1._ireals - opt_buildings%albedo(bidx)) * opt_buildings%planck(bidx) end if ! send right back to where it came from: p%side = p%src_side mu = sqrt(R()) phi = deg2rad(R() * 360) p%dir = [sin(phi) * sin(acos(mu)), cos(phi) * sin(acos(mu)), mu] select case (p%src_side) case (PPRTS_TOP_FACE) continue case (PPRTS_BOT_FACE) p%dir = rotate_angle_y(p%dir, 180._ireal_dp) case (PPRTS_LEFT_FACE) p%dir = rotate_angle_y(p%dir, 90._ireal_dp) case (PPRTS_RIGHT_FACE) p%dir = rotate_angle_y(p%dir, 270._ireal_dp) case (PPRTS_REAR_FACE) p%dir = rotate_angle_x(p%dir, 270._ireal_dp) case (PPRTS_FRONT_FACE) p%dir = rotate_angle_x(p%dir, 90._ireal_dp) case default call CHKERR(1_mpiint, 'Dont know what to do with source spec: '//toStr(p%src_side)) end select lexit_cell = .true. end if end associate end subroutine subroutine exit_cell(lexit_domain) logical, intent(out) :: lexit_domain real(ireal_dp) :: mu, phi lexit_domain = .false. associate (p => pqueues(ipq)%photons(iphoton)%p) call update_flx(solver, p, p%k, p%i, p%j, edir, ediff, Nediff) ! Move photon to new cell if (ldebug_tracing) print *, myid, cstr('* MOVE Photon to new cell', 'green') select case (p%side) case (PPRTS_TOP_FACE) ! exit on top if (p%k .eq. solver%C_one_atm%zs) then ! outgoing at TOA if (ldebug_tracing) print *, myid, '********************* Exit TOA', p%k, p%i, p%j lkilled_photon = .true. lexit_domain = .true. end if p%loc(3) = zero + loceps p%k = p%k - 1 p%src_side = PPRTS_BOT_FACE case (PPRTS_BOT_FACE) ! exit cell at bottom if (p%k .eq. solver%C_one_atm%ze) then ! hit the surface, need reflection if (ldebug_tracing) print *, myid, '********************* Before Reflection', p%k, p%i, p%j p%weight = p%weight * solver%atm%albedo(p%i, p%j) if (lthermal) then if (allocated(solver%atm%Bsrfc)) then p%weight = p%weight + (1._ireals - solver%atm%albedo(p%i, p%j)) * solver%atm%Bsrfc(p%i, p%j) else p%weight = p%weight + (1._ireals - solver%atm%albedo(p%i, p%j)) * solver%atm%planck(p%k + 1, p%i, p%j) end if end if p%direct = .false. p%scattercnt = p%scattercnt + 1 mu = sqrt(R()) phi = deg2rad(R() * 360) p%dir = [sin(phi) * sin(acos(mu)), cos(phi) * sin(acos(mu)), mu] p%loc(3) = zero + loceps p%side = PPRTS_TOP_FACE p%src_side = PPRTS_BOT_FACE call update_flx(solver, p, p%k + 1, p%i, p%j, edir, ediff, Nediff) if (ldebug_tracing) print *, myid, cstr('********************* After Reflection', 'aqua'), p%k, p%i, p%j lexit_domain = .false. else p%loc(3) = solver%atm%dz(p%k + 1, p%i, p%j) - loceps p%k = p%k + 1 p%src_side = PPRTS_TOP_FACE end if case (PPRTS_LEFT_FACE) p%loc(1) = solver%atm%dx - loceps p%i = p%i - 1 p%src_side = PPRTS_RIGHT_FACE if (p%i .eq. solver%C_one_atm%xs - 1) then if (ldebug_tracing) print *, myid, cstr('* Sending to WEST', 'blue'), pqueues(PQ_WEST)%owner, p%k, p%i, p%j call send_photon_to_neighbor(solver, solver%C_one_atm, p, pqueues(PQ_WEST)) lexit_domain = .true. end if case (PPRTS_RIGHT_FACE) p%loc(1) = zero + loceps p%i = p%i + 1 p%src_side = PPRTS_LEFT_FACE if (p%i .eq. solver%C_one_atm%xe + 1) then if (ldebug_tracing) print *, myid, cstr('* Sending to EAST', 'blue'), pqueues(PQ_EAST)%owner, p%k, p%i, p%j call send_photon_to_neighbor(solver, solver%C_one_atm, p, pqueues(PQ_EAST)) lexit_domain = .true. end if case (PPRTS_REAR_FACE) p%loc(2) = solver%atm%dy - loceps p%j = p%j - 1 p%src_side = PPRTS_FRONT_FACE if (p%j .eq. solver%C_one_atm%ys - 1) then if (ldebug_tracing) print *, myid, cstr('* Sending to SOUTH', 'blue'), pqueues(PQ_SOUTH)%owner, p%k, p%i, p%j call send_photon_to_neighbor(solver, solver%C_one_atm, p, pqueues(PQ_SOUTH)) lexit_domain = .true. end if case (PPRTS_FRONT_FACE) p%loc(2) = zero + loceps p%j = p%j + 1 p%src_side = PPRTS_REAR_FACE if (p%j .eq. solver%C_one_atm%ye + 1) then if (ldebug_tracing) print *, myid, cstr('* Sending to NORTH', 'blue'), pqueues(PQ_NORTH)%owner, p%k, p%i, p%j call send_photon_to_neighbor(solver, solver%C_one_atm, p, pqueues(PQ_NORTH)) lexit_domain = .true. end if end select end associate end subroutine end subroutine subroutine update_flx(solver, p, k, i, j, edir, ediff, Nediff) class(t_solver), intent(in) :: solver type(t_photon), intent(in) :: p integer(iintegers), intent(in) :: k, i, j ! layer/box indices real(ireal_dp), allocatable, dimension(:, :, :, :), intent(inout) :: edir, ediff integer(iintegers), allocatable, dimension(:, :, :, :), intent(inout) :: Nediff integer(iintegers) :: off, dof if (ldebug_tracing) print *, 'Update Flux', k, i, j, p%direct, p%side select case (p%side) case (PPRTS_TOP_FACE) if (k .lt. lbound(ediff, 2) .or. k .gt. ubound(ediff, 2)) & & call CHKERR(1_mpiint, 'invalid k '//toStr(k)//' '// & & toStr(lbound(ediff, 2))//'/'//toStr(ubound(ediff, 2))) case (PPRTS_BOT_FACE) if (k .lt. lbound(ediff, 2) .or. k .gt. ubound(ediff, 2) - 1) & & call CHKERR(1_mpiint, 'invalid k '//toStr(k)//' '// & & toStr(lbound(ediff, 2))//'/'//toStr(ubound(ediff, 2) - 1)) case (3:6) continue case default call print_photon(p) call CHKERR(1_mpiint, 'hmpf .. didnt expect a p%side gt 6, have '//toStr(p%side)) end select if (i .lt. lbound(ediff, 3) .or. i .gt. ubound(ediff, 3)) & & call CHKERR(1_mpiint, 'invalid i '//toStr(i)//' '// & & '['//toStr(lbound(ediff, 3))//','//toStr(ubound(ediff, 3))//']') if (j .lt. lbound(ediff, 4) .or. j .gt. ubound(ediff, 4)) & & call CHKERR(1_mpiint, 'invalid j '//toStr(j)//' '// & & '['//toStr(lbound(ediff, 4))//','//toStr(ubound(ediff, 4))//']') if (p%direct) then select case (p%side) case (PPRTS_TOP_FACE) edir(i0, k, i, j) = edir(i0, k, i, j) + real(p%weight, kind(edir)) case (PPRTS_BOT_FACE) edir(i0, k + 1, i, j) = edir(i0, k + 1, i, j) + real(p%weight, kind(edir)) case (PPRTS_LEFT_FACE) off = solver%dirtop%dof do dof = 0, solver%dirside%dof - 1 edir(off + dof, k, i, j) = edir(off + dof, k, i, j) + real(p%weight, kind(edir)) end do case (PPRTS_RIGHT_FACE) off = solver%dirtop%dof do dof = 0, solver%dirside%dof - 1 edir(off + dof, k, i + 1, j) = edir(off + dof, k, i + 1, j) + real(p%weight, kind(edir)) end do case (PPRTS_REAR_FACE) ! rear off = solver%dirtop%dof + solver%dirside%dof do dof = 0, solver%dirside%dof - 1 edir(off + dof, k, i, j) = edir(off + dof, k, i, j) + real(p%weight, kind(edir)) end do case (PPRTS_FRONT_FACE) ! front off = solver%dirtop%dof + solver%dirside%dof do dof = 0, solver%dirside%dof - 1 edir(off + dof, k, i, j + 1) = edir(off + dof, k, i, j + 1) + real(p%weight, kind(edir)) end do case default call print_photon(p) call CHKERR(1_mpiint, 'hmpf .. didnt expect p%side '//toStr(p%side)) end select else select case (p%side) case (PPRTS_TOP_FACE) do dof = 0, solver%difftop%dof - 1 if (.not. solver%difftop%is_inward(i1 + dof)) then !Eup ediff(dof, k, i, j) = ediff(dof, k, i, j) + real(p%weight, kind(ediff)) Nediff(dof, k, i, j) = Nediff(dof, k, i, j) + 1_iintegers end if end do case (PPRTS_BOT_FACE) do dof = 0, solver%difftop%dof - 1 if (solver%difftop%is_inward(i1 + dof)) then !Edn ediff(dof, k + 1, i, j) = ediff(dof, k + 1, i, j) + real(p%weight, kind(ediff)) Nediff(dof, k + 1, i, j) = Nediff(dof, k + 1, i, j) + 1_iintegers end if end do case (PPRTS_LEFT_FACE) off = solver%difftop%dof do dof = 0, solver%diffside%dof - 1 if (.not. solver%diffside%is_inward(i1 + dof)) then !Eleft ediff(off + dof, k, i, j) = ediff(off + dof, k, i, j) + real(p%weight, kind(ediff)) Nediff(off + dof, k, i, j) = Nediff(off + dof, k, i, j) + 1_iintegers end if end do case (PPRTS_RIGHT_FACE) off = solver%difftop%dof do dof = 0, solver%diffside%dof - 1 if (solver%diffside%is_inward(i1 + dof)) then !Eright ediff(off + dof, k, i + 1, j) = ediff(off + dof, k, i + 1, j) + real(p%weight, kind(ediff)) Nediff(off + dof, k, i + 1, j) = Nediff(off + dof, k, i + 1, j) + 1_iintegers end if end do case (PPRTS_REAR_FACE) ! rear off = solver%difftop%dof + solver%diffside%dof do dof = 0, solver%diffside%dof - 1 if (.not. solver%diffside%is_inward(i1 + dof)) then !Erear ediff(off + dof, k, i, j) = ediff(off + dof, k, i, j) + real(p%weight, kind(ediff)) Nediff(off + dof, k, i, j) = Nediff(off + dof, k, i, j) + 1_iintegers end if end do case (PPRTS_FRONT_FACE) ! front off = solver%difftop%dof + solver%diffside%dof do dof = 0, solver%diffside%dof - 1 if (solver%diffside%is_inward(i1 + dof)) then !Eforward ediff(off + dof, k, i, j + 1) = ediff(off + dof, k, i, j + 1) + real(p%weight, kind(ediff)) Nediff(off + dof, k, i, j + 1) = Nediff(off + dof, k, i, j + 1) + 1_iintegers end if end do case default call print_photon(p) call CHKERR(1_mpiint, 'hmpf .. didnt expect this p%side, have'//toStr(p%side)) end select end if end subroutine subroutine prepare_locally_owned_photons(solver, bmc, lsolar, pqueue, Nphotons, weight) class(t_solver), intent(in) :: solver class(t_boxmc), intent(in) :: bmc logical, intent(in) :: lsolar type(t_photon_queue), intent(inout) :: pqueue integer(iintegers), intent(in) :: Nphotons real(ireals), intent(in) :: weight type(t_photon) :: p real(ireals) :: phi0, theta0 integer(mpiint) :: myid, ierr integer(iintegers) :: ip, i, j integer(iintegers) :: Nphotons_per_pixel, l real(ireals), allocatable :: vertices(:) real(ireals) :: initial_dir(3) call mpi_comm_rank(solver%comm, myid, ierr); call CHKERR(ierr) phi0 = solver%sun%phi theta0 = solver%sun%theta initial_dir = spherical_2_cartesian(phi0, theta0) Nphotons_per_pixel = max(1_iintegers, Nphotons / int(solver%C_one_atm%xm * solver%C_one_atm%ym, kind(Nphotons))) if (modulo(Nphotons, Nphotons_per_pixel) .ne. 0) & & call CHKERR(1_mpiint, 'Nphotons '//toStr(Nphotons)//' not divisible by Nphotons_per_pixel '//toStr(Nphotons_per_pixel)) do l = 1, Nphotons_per_pixel do i = solver%C_one_atm%xs, solver%C_one_atm%xe do j = solver%C_one_atm%ys, solver%C_one_atm%ye call setup_default_unit_cube_geometry(solver%atm%dx, solver%atm%dy, & solver%atm%dz(i0, i, j), vertices) if (lsolar) then call bmc%init_dir_photon(p, i1, .true., real(initial_dir, ireal_dp), real(vertices, ireal_dp), ierr) else call bmc%init_diff_photon(p, i2, real(vertices, ireal_dp), ierr) end if p%i = i p%j = j p%k = i0 p%src_side = PPRTS_TOP_FACE p%weight = weight p%tau_travel = tau(R()) if (ldebug_tracing) then call antialiased_photon_start(Nphotons_per_pixel, l, p%loc(1), p%loc(2)) else p%loc(1) = R() p%loc(2) = R() end if p%loc(1) = p%loc(1) * solver%atm%dx p%loc(2) = p%loc(2) * solver%atm%dy call pqueue_add_photon(pqueue, p, 0_mpiint, ip, ierr); call CHKERR(ierr) call pqueue%ready%add(ip) if (ldebug) then print *, 'Prepared Photon', i, j, ': iphoton', ip, Nphotons call print_photon(pqueue%photons(ip)%p) end if end do end do end do end subroutine subroutine antialiased_photon_start(Nmax, ip, x, y, tilt_angle) integer(iintegers), intent(in) :: Nmax, ip ! total number of photons per pixel, and the ip'th point for that real(ireal_dp), intent(in), optional :: tilt_angle ! angle by which the grid is rotated in [rad], default: 30deg real(ireal_dp), intent(out) :: x, y ! gives x and y position for a regularly sampled tilted grid real(ireal_dp) :: tilt_grid, rot_x, rot_y integer(iintegers) :: Nx, Ny ! number of pixels in x and y direction integer(iintegers) :: i, j tilt_grid = get_arg(deg2rad(26.6_ireal_dp), tilt_angle) if (Nmax .eq. i1) then x = .5_ireals y = .5_ireals return end if Nx = int(sqrt(real(Nmax, ireal_dp)), iintegers) Ny = Nx if (ip .gt. Nx * Ny) then x = R() y = R() return end if j = (ip - 1) / int(Nx, kind(ip)) ! zero based offsets i = (ip - 1) - j * int(Nx, kind(ip)) x = real(i + 1, ireals) / real(Nx + 1, ireals) * sqrt(5._ireals) / 2._ireals y = real(j + 1, ireals) / real(Ny + 1, ireals) * sqrt(5._ireals) / 2._ireals ! Translate to center (0,0) x = x - .5_ireals y = y - .5_ireals rot_x = x * cos(tilt_grid) - y * sin(tilt_grid) + .5_ireals rot_y = x * sin(tilt_grid) + y * cos(tilt_grid) + .5_ireals x = modulo(rot_x, 1._ireal_dp) y = modulo(rot_y, 1._ireal_dp) !print *,'plot(', x,',',y,',"o") #',ip end subroutine subroutine find_empty_entry_in_pqueue(pqueue, emptyid, ierr) type(t_photon_queue), intent(inout) :: pqueue integer(iintegers), intent(out) :: emptyid integer(mpiint), intent(out) :: ierr call pqueue%empty%pop(emptyid, ierr) if (ierr .ne. 0) then call print_pqueue(pqueue) end if end subroutine subroutine print_pqueue(pq, list_queue) type(t_photon_queue), intent(in) :: pq logical, intent(in), optional :: list_queue if (get_arg(.false., list_queue)) then print *, 'PQUEUE:', pq%owner, '::', pq%queue_index, 'name ', cstr(trim(id2name(pq%queue_index)), 'blue') print *, 'empty:' call pq%empty%view() print *, 'ready:' call pq%ready%view() print *, 'sending:' call pq%sending%view() else print *, pq%owner, cstr(id2name(pq%queue_index), 'blue'), & & ' '//'empty', pq%empty%len(), & & ' '//cstr('ready '//toStr(pq%ready%len()), 'green'), & & ' '//cstr('send '//toStr(pq%sending%len()), 'peach') end if end subroutine subroutine pqueue_add_photon(pqueue, p, request, ind, ierr) type(t_photon_queue), intent(inout) :: pqueue type(t_photon), intent(in) :: p integer(mpiint), intent(in) :: request integer(iintegers), intent(out) :: ind integer(mpiint), intent(out) :: ierr call find_empty_entry_in_pqueue(pqueue, ind, ierr) if (ierr .ne. 0) then call finalize_msgs_blocking(pqueue) call find_empty_entry_in_pqueue(pqueue, ind, ierr) call CHKERR(ierr, 'Could not find an empty slot in neighbor queue '//toStr(pqueue%queue_index)) end if ! Put photon to send queue to neighbor pqueue%photons(ind)%p = p pqueue%photons(ind)%request = request end subroutine subroutine setup_photon_queue(pq, N, owner, queue_index) type(t_photon_queue), intent(inout) :: pq integer(iintegers), intent(in) :: N integer(mpiint), intent(in) :: owner integer(iintegers), intent(in) :: queue_index integer(iintegers) :: i if (allocated(pq%photons)) then call CHKERR(1_mpiint, 'photon queue already allocated') else allocate (pq%photons(N)) end if pq%owner = owner pq%queue_index = queue_index do i = 1, N call pq%empty%add(i) end do end subroutine subroutine send_photon_to_neighbor(solver, C, p_in, pqueue) class(t_solver), intent(in) :: solver type(t_coord), intent(in) :: C type(t_photon), intent(in) :: p_in type(t_photon_queue), intent(inout) :: pqueue integer(mpiint) :: myid, tag, ierr integer(iintegers) :: iphoton logical, parameter :: lcyclic_boundary = .true. call mpi_comm_rank(solver%comm, myid, ierr); call CHKERR(ierr) ! Put photon to send queue to neighbor call pqueue_add_photon(pqueue, p_in, 0_mpiint, iphoton, ierr); call CHKERR(ierr) call pqueue%sending%add(iphoton) associate (p => pqueue%photons(iphoton)%p) if (ldebug) then select case (pqueue%queue_index) case (PQ_SELF) call CHKERR(1_mpiint, 'should not happen that a photon is sent to ourselves?') case (PQ_WEST) !print *,'Sending Photon WEST' if (p%side .ne. PPRTS_LEFT_FACE) call CHKERR(1_mpiint, 'I would assume that side should be 3 when sending WEST') if (p%src_side .ne. PPRTS_RIGHT_FACE) call CHKERR(1_mpiint, 'I would assume that src_side should be 4 when sending WEST') case (PQ_EAST) !print *,'Sending Photon EAST' if (p%side .ne. PPRTS_RIGHT_FACE) call CHKERR(1_mpiint, 'I would assume that side should be 4 when sending EAST') if (p%src_side .ne. PPRTS_LEFT_FACE) call CHKERR(1_mpiint, 'I would assume that src_side should be 3 when sending EAST') case (PQ_NORTH) !print *,'Sending Photon NORTH' if (p%side .ne. PPRTS_FRONT_FACE) call CHKERR(1_mpiint, 'I would assume that side should be 6 when sending NORTH') if (p%src_side .ne. PPRTS_REAR_FACE) call CHKERR(1_mpiint, 'I would assume that src_side should be 5 when sending NORTH') case (PQ_SOUTH) !print *,'Sending Photon SOUTH' if (p%side .ne. PPRTS_REAR_FACE) call CHKERR(1_mpiint, 'I would assume that side should be 5 when sending SOUTH') if (p%src_side .ne. PPRTS_FRONT_FACE) call CHKERR(1_mpiint, 'I would assume that src_side should be 6 when sending SOUTH') end select end if if (lcyclic_boundary) then if (p%i .eq. -1) p%i = C%glob_xm - 1 if (p%j .eq. -1) p%j = C%glob_ym - 1 if (p%i .eq. C%glob_xm) p%i = 0 if (p%j .eq. C%glob_ym) p%j = 0 else call CHKERR(1_mpiint, 'NON-cyclic boundary conditions are not implemented yet!') end if ! asynchronous SEND starts here tag = int(pqueue%queue_index, kind(tag)) call mpi_isend(p, 1_mpiint, imp_t_photon, & pqueue%owner, tag, solver%comm, pqueue%photons(iphoton)%request, ierr); call CHKERR(ierr, 'mpi isend failed') !call mpi_send(p, 1_mpiint, imp_t_photon, & ! pqueue%owner, tag, solver%comm, ierr); call CHKERR(ierr, 'mpi isend failed') if (ldebug) then print *, 'Sending the following photon to rank', pqueue%owner, ':tag', tag call print_photon(p) end if end associate end subroutine subroutine finalize_msgs_non_blocking(pqueue) type(t_photon_queue), intent(inout) :: pqueue call pqueue%sending%for_each(check_sending) contains subroutine check_sending(idx, node, iphoton) integer(iintegers), intent(in) :: idx type(t_node), pointer, intent(inout) :: node integer(iintegers), intent(inout) :: iphoton integer(mpiint) :: stat(mpi_status_size), ierr logical :: lcomm_finished call mpi_test(pqueue%photons(iphoton)%request, lcomm_finished, stat, ierr); call CHKERR(ierr) if (lcomm_finished) then call pqueue%empty%add(iphoton) call pqueue%sending%del_node(node, ierr); call CHKERR(ierr) if (ldebug) then print *, 'Finalized Sending a photon:', iphoton end if end if return print *, 'unused var warning', idx end subroutine end subroutine subroutine finalize_msgs_blocking(pqueue) type(t_photon_queue), intent(inout) :: pqueue integer(iintegers) :: cnt_finished_msgs real(ireal_dp) :: tstart, t integer(iintegers), save :: count_warnings = 0 integer(iintegers), parameter :: max_warnings = 10 call cpu_time(tstart) cnt_finished_msgs = 0 do call pqueue%sending%for_each(check_sending) call cpu_time(t) count_warnings = count_warnings + 1 if (count_warnings .lt. max_warnings) then call CHKWARN(1_mpiint, id2name(pqueue%queue_index)// & & ': waited for '//toStr(t - tstart)//' s.'//new_line('')// & & ' But this is bad for performance!'//new_line('')// & & ' Maybe increasing the queue size helps at the cost of more memory.'//new_line('')// & & ' -mcdmda_queue_size <int>'//new_line('')// & & ' or try to reduce the batch_size with '//new_line('')// & & ' -mcdmda_batch_size <int>'//new_line('')// & & ' or try to wait for all boundary photons to be finished emitting new photons locally'//new_line('')// & & ' -mcdmda_finish_border_photons_first') elseif (count_warnings .eq. max_warnings) then call CHKWARN(1_mpiint, 'waiting warning has been issued '//toStr(max_warnings)//' times... now suppressing it.') end if if (cnt_finished_msgs .ne. 0) return if (t - tstart .gt. blocking_waittime) then call CHKERR(1_mpiint, 'waited for '//toStr(t - tstart)//' s but the queues havent freed up... ') end if end do contains subroutine check_sending(idx, node, iphoton) integer(iintegers), intent(in) :: idx type(t_node), pointer, intent(inout) :: node integer(iintegers), intent(inout) :: iphoton integer(mpiint) :: stat(mpi_status_size), ierr logical :: lcomm_finished call mpi_test(pqueue%photons(iphoton)%request, lcomm_finished, stat, ierr); call CHKERR(ierr) if (lcomm_finished) then call pqueue%empty%add(iphoton) call pqueue%sending%del_node(node, ierr); call CHKERR(ierr) cnt_finished_msgs = cnt_finished_msgs + 1 if (ldebug) then print *, 'Finalized Sending a photon:', iphoton call print_photon(pqueue%photons(iphoton)%p) end if end if return print *, 'unused var warning', idx end subroutine end subroutine subroutine exchange_photons(solver, pqueues) class(t_solver), intent(in) :: solver type(t_photon_queue), intent(inout) :: pqueues(:) ! [own, north, east, south, west] integer(mpiint) :: myid, mpi_status(mpi_status_size), ierr, tag integer(iintegers) :: ipq, iphoton logical :: lgot_msg call mpi_comm_rank(solver%comm, myid, ierr) do ipq = 1, size(pqueues) call finalize_msgs_non_blocking(pqueues(ipq)) end do ! receive all messages that we can get do call mpi_iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, solver%comm, lgot_msg, mpi_status, ierr); call CHKERR(ierr) if (lgot_msg) then tag = mpi_status(MPI_TAG) select case (tag) case (PQ_WEST) ! was sent towards WEST, i.e. it arrives EAST ipq = PQ_EAST case (PQ_EAST) ipq = PQ_WEST case (PQ_SOUTH) ipq = PQ_NORTH case (PQ_NORTH) ipq = PQ_SOUTH case default call CHKERR(1_mpiint, 'received unexpected message with tag '//toStr(tag)) end select if (mpi_status(MPI_SOURCE) .ne. pqueues(ipq)%owner) call CHKERR(1_mpiint, 'Something unexpected happened') call find_empty_entry_in_pqueue(pqueues(ipq), iphoton, ierr) if (ierr .ne. 0) then call finalize_msgs_blocking(pqueues(ipq)) call find_empty_entry_in_pqueue(pqueues(ipq), iphoton, ierr) call CHKERR(ierr, 'no space in queue to receive a msg') end if call mpi_recv(pqueues(ipq)%photons(iphoton)%p, 1_mpiint, imp_t_photon, & mpi_status(MPI_SOURCE), mpi_status(MPI_TAG), solver%comm, mpi_status, ierr); call CHKERR(ierr) call pqueues(ipq)%ready%add(iphoton) if (ldebug) then print *, myid, 'Got Message from rank:', mpi_status(MPI_SOURCE), 'Receiving ipq ', id2name(ipq) call print_photon(pqueues(ipq)%photons(iphoton)%p) end if else exit end if end do end subroutine subroutine move_photon(bmc, vertices, ksca, p, pathlen, lexit_cell) class(t_boxmc) :: bmc real(ireal_dp), intent(in) :: vertices(:), ksca type(t_photon), intent(inout) :: p real(ireal_dp) :: pathlen logical, intent(out) :: lexit_cell real(ireal_dp) :: dist, intersec_dist call bmc%intersect_distance(vertices, p, intersec_dist) dist = distance(p%tau_travel, ksca) pathlen = min(intersec_dist, dist) call update_photon_loc(p, pathlen, ksca) if (intersec_dist .le. dist) then lexit_cell = .true. else lexit_cell = .false. end if end subroutine move_photon subroutine check_if_photon_is_in_domain(C, p) type(t_coord), intent(in) :: C type(t_photon), intent(in) :: p if (p%k .lt. C%zs .or. p%k .gt. C%ze) & call CHKERR(1_mpiint, 'Wrong index(dim1) '//toStr(p%k)//' not in ('//toStr(C%zs)//'/'//toStr(C%ze)//')') if (p%i .lt. C%xs .or. p%i .gt. C%xe) & call CHKERR(1_mpiint, 'Wrong index(dim2) '//toStr(p%i)//' not in ('//toStr(C%xs)//'/'//toStr(C%xe)//')') if (p%j .lt. C%ys .or. p%j .gt. C%ye) & call CHKERR(1_mpiint, 'Wrong index(dim3) '//toStr(p%j)//' not in ('//toStr(C%ys)//'/'//toStr(C%ye)//')') end subroutine end module
gpl-3.0