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
optimsoc/gzll-gcc
gcc/testsuite/gfortran.dg/duplicate_labels.f90
207
1742
! { dg-do compile } ! PR 21257 program dups integer i,j,k abc: do i = 1, 3 abc: do j = 1, 3 ! { dg-error "Duplicate construct label" } k = i + j end do abc end do abc ! { dg-error "Expecting END PROGRAM" } xyz: do i = 1, 2 k = i + 2 end do xyz xyz: do j = 1, 5 ! { dg-error "Duplicate construct label" } k = j + 2 end do loop ! { dg-error "Expecting END PROGRAM" } her: if (i == 1) then her: if (j == 1) then ! { dg-error "Duplicate construct label" } k = i + j end if her end if her ! { dg-error "Expecting END PROGRAM" } his: if (i == 1) then i = j end if his his: if (j === 1) then ! { dg-error "Duplicate construct label" } print *, j end if his ! { dg-error "Expecting END PROGRAM" } sgk: select case (i) case (1) sgk: select case (j) ! { dg-error "Duplicate construct label" } case (10) i = i + j case (20) j = j + i end select sgk case (2) ! { dg-error "Unexpected CASE statement" } i = i + 1 j = j + 1 end select sgk ! { dg-error "Expecting END PROGRAM" } apl: select case (i) case (1) k = 2 case (2) j = 1 end select apl apl: select case (i) ! { dg-error "Duplicate construct label" } case (1) ! { dg-error "Unexpected CASE statement" } j = 2 case (2) ! { dg-error "Unexpected CASE statement" } k = 1 end select apl ! { dg-error "Expecting END PROGRAM" } end program dups
gpl-2.0
optimsoc/gzll-gcc
gcc/testsuite/gfortran.dg/read_eof_all.f90
169
1987
! { dg-do run } ! PR43265 Followup patch for miscellaneous EOF conditions. ! Eaxamples from Tobius Burnus use iso_fortran_env character(len=2) :: str, str2(2) integer :: a, b, c, ios str = '' str2 = '' open(99,file='test.dat',access='stream',form='unformatted', status='replace') write(99) ' ' close(99) open(99,file='test.dat') read(99, '(T7,i2)') i close(99, status="delete") if (i /= 0) call abort read(str(1:0), '(T7,i1)') i if (i /= 0) call abort read(str,'(i2,/,i2)',end=111) a, b call abort !stop 'ERROR: Expected EOF error (1)' 111 continue read(str2,'(i2,/,i2)',end=112) a, b read(str2,'(i2,/,i2,/,i2)',end=113) a, b, c call abort !stop 'ERROR: Expected EOF error (2)' 112 call abort !stop 'ERROR: Unexpected EOF (3)' 113 continue read(str,'(i2,/,i2)',end=121,pad='no') a, b call abort !stop 'ERROR: Expected EOF error (1)' 121 continue read(str2(:),'(i2,/,i2)', end=122, pad='no') a, b goto 125 122 call abort !stop 'ERROR: Expected no EOF error (2)' 125 continue read(str2(:),'(i2,/,i2,/,i2)',end=123,pad='no') a, b, c call abort !stop 'ERROR: Expected EOF error (3)' 123 continue read(str(2:1),'(i2,/,i2)',end=131, pad='no') a, b call abort !stop 'ERROR: Expected EOF error (1)' 131 continue read(str2(:)(2:1),'(i2,/,i2)',end=132, pad='no') a, b call abort !stop 'ERROR: Expected EOF error (2)' 132 continue read(str2(:)(2:1),'(i2,/,i2,/,i2)',end=133,pad='no') a, b, c call abort !stop 'ERROR: Expected EOF error (3)' 133 continue read(str(2:1),'(i2,/,i2)',iostat=ios, pad='no') a, b if (ios /= IOSTAT_END) call abort !stop 'ERROR: expected iostat /= 0 (1)' read(str2(:)(2:1),'(i2,/,i2)',iostat=ios, pad='no') a, b if (ios /= IOSTAT_END) call abort !stop 'ERROR: expected iostat /= 0 (2)' read(str2(:)(2:1),'(i2,/,i2,/,i2)',iostat=ios,pad='no') a, b, c if (ios /= IOSTAT_END) call abort !stop 'ERROR: expected iostat /= 0 (2)' ! print *, "success" end
gpl-2.0
optimsoc/gzll-gcc
libgfortran/generated/_cos_c10.F90
35
1484
! Copyright (C) 2002-2014 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_CCOSL elemental function _gfortran_specific__cos_c10 (parm) complex (kind=10), intent (in) :: parm complex (kind=10) :: _gfortran_specific__cos_c10 _gfortran_specific__cos_c10 = cos (parm) end function #endif #endif
gpl-2.0
optimsoc/gzll-gcc
gcc/testsuite/gfortran.dg/transfer_intrinsic_5.f90
135
1150
! { dg-do run } ! ! PR fortran/56615 ! ! Contributed by Harald Anlauf ! ! program gfcbug implicit none integer, parameter :: n = 8 integer :: i character(len=1), dimension(n) :: a, b character(len=n) :: s, t character(len=n/2) :: u do i = 1, n a(i) = achar (i-1 + iachar("a")) end do ! print *, "# Forward:" ! print *, "a=", a s = transfer (a, s) ! print *, "s=", s call cmp (a, s) ! print *, " stride = +2:" do i = 1, n/2 u(i:i) = a(2*i-1) end do ! print *, "u=", u call cmp (a(1:n:2), u) ! print * ! print *, "# Backward:" b = a(n:1:-1) ! print *, "b=", b t = transfer (b, t) ! print *, "t=", t call cmp (b, t) ! print *, " stride = -1:" call cmp (a(n:1:-1), t) contains subroutine cmp (b, s) character(len=1), dimension(:), intent(in) :: b character(len=*), intent(in) :: s character(len=size(b)) :: c c = transfer (b, c) if (c /= s) then print *, "c=", c, " ", merge (" ok","BUG!", c == s) call abort () end if end subroutine cmp end program gfcbug
gpl-2.0
simomarsili/elss
src/dump.f90
1
6052
! Copyright (C) 2015-2017, Simone Marsili ! All rights reserved. ! License: BSD 3 clause module dump use kinds use constants use units, only: units_open,units_open_unf implicit none private public :: read_chk public :: dump_chk public :: dump_seq public :: dump_energies interface read_chk module procedure read_chk_file module procedure read_chk_unit end interface read_chk interface dump_chk module procedure dump_chk_file module procedure dump_chk_unit end interface dump_chk contains subroutine dump_energies(unt,etot,efields,ecouplings) integer, intent(in) :: unt real(kflt), intent(in) :: etot,efields,ecouplings write(unt,'(3(f12.3,1x))') etot,efields,ecouplings flush(unt) end subroutine dump_energies subroutine dump_seq(data_type, unt, seq, time, etot, eh, ej) character(len=*), intent(in) :: data_type integer, intent(in) :: unt integer, intent(in) :: seq(:) integer, intent(in) :: time real(kflt), intent(in) :: etot, eh, ej select case(trim(data_type)) case ('int') call dump_int(unt, seq, time, etot, eh, ej) case ('bio', 'protein', 'nuc_acid') call dump_fasta(unt, seq, time, etot, eh, ej) end select end subroutine dump_seq subroutine dump_int(unt,seq,time,etot,eh,ej) integer, intent(in) :: unt integer, intent(in) :: seq(:) integer, intent(in) :: time real(kflt), intent(in) :: etot,eh,ej write(unt,'(a,1x,i8,3(1x,f12.3))') '>', time, etot, eh, ej write(unt,'(10000i3)') seq - 1 ! class index start from zero flush(unt) end subroutine dump_int subroutine dump_fasta(unt,seq,time,etot,eh,ej) use fasta, only: fasta_alphabet use constants integer, intent(in) :: unt integer, intent(in) :: seq(:) integer, intent(in) :: time real(kflt), intent(in) :: etot,eh,ej integer :: i,n,si character(len=long_string_size) :: string n = size(seq) string='' do i = 1,n si = seq(i) string = trim(string)//fasta_alphabet(si:si) end do write(unt,'(a,1x,i8,3(1x,f12.3))') '>', time, etot, eh, ej write(unt,'(a)') trim(string) flush(unt) end subroutine dump_fasta subroutine read_chk_unit(unt, nvars, nclasses, data_type, data, prm, & error_code) ! read a checkpoint file use random, only: random_data use fasta, only: set_fasta_alphabet integer, intent(in) :: unt integer, intent(out) :: nvars integer, intent(out) :: nclasses character(len=*), intent(out) :: data_type integer, intent(out), allocatable :: data(:, :) real(kflt), intent(out), allocatable :: prm(:) integer, intent(out) :: error_code integer, allocatable :: dummy(:) integer :: id,ndata,nv,nc,err integer :: data_shape(2) error_code = 0 read(unt) nvars read(unt) nclasses read(unt) data_type read(unt) ndata allocate(data(nvars, ndata), stat=err) allocate(prm(nvars * nclasses + nvars * (nvars - 1) * nclasses**2 / 2), & stat=err) data = 0 prm = 0.0_kflt allocate(dummy(nvars),stat=err) do id = 1, ndata read(unt) data(:, id) end do read(unt) prm select case (trim(data_type)) case('bio', 'protein', 'nuc_acid') call set_fasta_alphabet(data_type) case default ! do nothing end select end subroutine read_chk_unit subroutine read_chk_file(filename,nvars,nclasses,data_type,data,& prm,error_code) ! should read both a filename or a unit character(len=*), intent(in) :: filename integer, intent(inout) :: nvars,nclasses character(len=*), intent(inout) :: data_type integer, intent(inout), allocatable :: data(:, :) real(kflt), intent(inout), allocatable :: prm(:) integer, intent(out) :: error_code integer :: unt,err error_code = 0 call units_open_unf(filename,'old',unt,err) if( err /= 0 ) then write(0,*) 'ERROR ! error opening file '//trim(filename) error_code = 1 return end if call read_chk_unit(unt,nvars,nclasses,data_type,data,prm,error_code) close(unt) end subroutine read_chk_file subroutine dump_chk_unit(unt,data_type,nclasses,seqs,prm,& error_code) ! dump a checkpoint file integer, intent(in) :: unt character(len=*), intent(in) :: data_type integer, intent(in) :: nclasses integer, intent(in) :: seqs(:,:) real(kflt), intent(in) :: prm(:) integer, intent(out) :: error_code integer :: table_shape(2) integer :: id, nvars, ndata error_code = 0 table_shape = shape(seqs) nvars = table_shape(1) ndata = table_shape(2) write(unt) nvars write(unt) nclasses write(unt) data_type write(unt) ndata do id = 1, ndata write(unt) seqs(:, id) end do write(unt) prm end subroutine dump_chk_unit subroutine dump_chk_file(filename,status,data_type,nclasses,& seqs,prm,error_code) ! dump a checkpoint file character(len=*), intent(in) :: filename character(len=*), intent(in) :: status character(len=*), intent(in) :: data_type integer, intent(in) :: nclasses integer, intent(in) :: seqs(:,:) real(kflt), intent(in) :: prm(:) integer, intent(out) :: error_code integer :: unt,err error_code = 0 call units_open_unf(filename,status,unt,err) if( err /= 0 ) then write(0,*) 'ERROR ! error opening file '//trim(filename) error_code = 1 return end if call dump_chk_unit(unt,data_type,nclasses,seqs,prm,error_code) close(unt) end subroutine dump_chk_file end module dump
bsd-3-clause
optimsoc/gzll-gcc
libgfortran/generated/_tan_r4.F90
35
1468
! Copyright (C) 2002-2014 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_TANF elemental function _gfortran_specific__tan_r4 (parm) real (kind=4), intent (in) :: parm real (kind=4) :: _gfortran_specific__tan_r4 _gfortran_specific__tan_r4 = tan (parm) end function #endif #endif
gpl-2.0
jinbow/Octopus
test/src.mitgcm/load_reflect.f90
1
1148
subroutine load_reflect() use global, only: reflect_x,reflect_y,Nx,Ny,Nz,path2uvw implicit none open(43,file=trim(path2uvw)//'reflect_x.bin',& form='unformatted',access='direct',convert='BIG_ENDIAN',& status='old',recl=4*Nz*(Nx+4)*Ny) read(43,rec=1) reflect_x(-2:Nx+1,0:Ny-1,0:Nz-1) close(43) ! reflect_x(-2:-1,:,:)=reflect_x(Nx-2:Nx-1,:,:) ! reflect_x(Nx:Nx+1,:,:)=reflect_x(0:1,:,:) reflect_x(:,:,Nz)=reflect_x(:,:,Nz-1) reflect_x(:,:,-1)=reflect_x(:,:,0) print*, "==================================================" print*, "loading reflect_x" open(43,file=trim(path2uvw)//'reflect_y.bin',& form='unformatted',access='direct',convert='BIG_ENDIAN',& status='old',recl=4*Nz*(Nx+4)*Ny) read(43,rec=1) reflect_y(-2:Nx+1,0:Ny-1,0:Nz-1) close(43) ! reflect_y(-2:-1,:,:)=reflect_y(Nx-2:Nx-1,:,:) ! reflect_y(Nx:Nx+1,:,:)=reflect_y(0:1,:,:) reflect_y(:,:,Nz)=reflect_y(:,:,Nz-1) reflect_y(:,:,-1)=reflect_y(:,:,0) print*, "==================================================" print*, "loading reflect_y" end subroutine load_reflect
mit
mogrodnik/piernik
src/multigrid/multigrid_helpers.F90
3
5537
! ! PIERNIK Code Copyright (C) 2006 Michal Hanasz ! ! This file is part of PIERNIK code. ! ! PIERNIK 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. ! ! PIERNIK 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 PIERNIK. If not, see <http://www.gnu.org/licenses/>. ! ! Initial implementation of PIERNIK code was based on TVD split MHD code by ! Ue-Li Pen ! see: Pen, Arras & Wong (2003) for algorithm and ! http://www.cita.utoronto.ca/~pen/MHD ! for original source code "mhd.f90" ! ! For full list of developers see $PIERNIK_HOME/license/pdt.txt ! #include "piernik.h" !> \brief Helper multigrid routines that depend at most on multigridvars and can be used everywhere else in multigrid. module multigrid_helpers ! pulled by MULTIGRID implicit none public :: all_dirty, set_relax_boundaries, copy_and_max private contains !> !! \brief Put insane FP values into all multigrid working arrays !! !! \details If there are any uninitialized values used in the solver under certain circumstances, the dirtyH will most likely propagate and be easily detectable. !! \deprecated remove this clause as soon as Intel Compiler gets required features and/or bug fixes !< subroutine all_dirty #if defined(__INTEL_COMPILER) use cg_list_bnd, only: cg_list_bnd_t ! QA_WARN intel #endif /* __INTEL_COMPILER */ use cg_list_global, only: all_cg use constants, only: dirtyH1 use global, only: dirty_debug use multigridvars, only: source, solution, defect, correction implicit none call all_cg%set_dirty(source, 0.999*dirtyH1) call all_cg%set_dirty(solution, 0.998*dirtyH1) call all_cg%set_dirty(defect, 0.997*dirtyH1) call all_cg%set_dirty(correction, 0.996*dirtyH1) if (dirty_debug) call all_cg%reset_boundaries(0.995*dirtyH1) end subroutine all_dirty !> \brief Take care of boundaries of relaxated grid subroutine set_relax_boundaries(cg, ind, is, ie, js, je, ks, ke, b, need_bnd_upd) use constants, only: xdim, ydim, zdim, LO, HI use domain, only: dom use grid_cont, only: grid_container implicit none type(grid_container), pointer, intent(inout) :: cg !< current grid container integer(kind=4), intent(in) :: ind !< index in cg%q(:) integer, intent(out) :: is, ie, js, je, ks, ke !< indices in cg integer(kind=4), intent(in) :: b !< how far we look into boundary layer logical, intent(in) :: need_bnd_upd !< if .true. then update 1 layer of external boundaries ! calling curl%external_boundaries(ind, bnd_type = BND_NEGREF) is a bit overkill if (cg%ext_bnd(xdim, LO)) then is = cg%is if (need_bnd_upd) cg%q(ind)%arr(is-1, :, :) = - cg%q(ind)%arr(is, :, :) else is = cg%is-b*dom%D_(xdim) endif if (cg%ext_bnd(xdim, HI)) then ie = cg%ie if (need_bnd_upd) cg%q(ind)%arr(ie+1, :, :) = - cg%q(ind)%arr(ie, :, :) else ie = cg%ie+b*dom%D_(xdim) endif if (cg%ext_bnd(ydim, LO)) then js = cg%js if (need_bnd_upd) cg%q(ind)%arr(:, js-1, :) = - cg%q(ind)%arr(:, js, :) else js = cg%js-b*dom%D_(ydim) endif if (cg%ext_bnd(ydim, HI)) then je = cg%je if (need_bnd_upd) cg%q(ind)%arr(:, je+1, :) = - cg%q(ind)%arr(:, je, :) else je = cg%je+b*dom%D_(ydim) endif if (cg%ext_bnd(zdim, LO)) then ks = cg%ks if (need_bnd_upd) cg%q(ind)%arr(:, :, ks-1) = - cg%q(ind)%arr(:, :, ks) else ks = cg%ks-b*dom%D_(zdim) endif if (cg%ext_bnd(zdim, HI)) then ke = cg%ke if (need_bnd_upd) cg%q(ind)%arr(:, :, ke+1) = - cg%q(ind)%arr(:, :, ke) else ke = cg%ke+b*dom%D_(zdim) endif end subroutine set_relax_boundaries !> \brief Copy solution to a temporary place and compute maximum value function copy_and_max(curl, soln) result(max_in) use cg_level_connected, only: cg_level_connected_t use cg_list, only: cg_list_element use constants, only: pMAX use mpisetup, only: piernik_MPI_Allreduce implicit none type(cg_level_connected_t), pointer, intent(in) :: curl !< pointer to a level for which we approximate the solution integer(kind=4), intent(in) :: soln !< index of solution in cg%q(:) type(cg_list_element), pointer :: cgl real :: max_in max_in = 0. cgl => curl%first do while (associated(cgl)) associate (cg => cgl%cg) cgl%cg%prolong_xyz(RNG) = cgl%cg%q(soln)%arr(RNG) max_in = max(max_in, maxval(abs(cg%prolong_xyz(RNG)))) end associate cgl => cgl%nxt enddo call piernik_MPI_Allreduce(max_in, pMAX) end function copy_and_max end module multigrid_helpers
gpl-3.0
optimsoc/gzll-gcc
libgomp/testsuite/libgomp.fortran/udr8.f90
102
1074
! { dg-do run } module udr8m1 integer, parameter :: a = 6 integer :: b !$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) !$omp declare reduction (.add. : integer : & !$omp & omp_out = omp_out .add. iand (omp_in, -4)) & !$omp & initializer (omp_priv = 3) interface operator (.add.) module procedure f1 end interface contains integer function f1 (x, y) integer, intent (in) :: x, y f1 = x + y end function f1 end module udr8m1 module udr8m2 use udr8m1 type dt integer :: x end type !$omp declare reduction (+ : dt : omp_out = omp_out + omp_in) & !$omp & initializer (omp_priv = dt (0)) interface operator (+) module procedure f2 end interface contains type(dt) function f2 (x, y) type(dt), intent (in) :: x, y f2%x = x%x + y%x end function f2 end module udr8m2 use udr8m2 integer :: i, j type(dt) :: d j = 3 d%x = 0 !$omp parallel do reduction (.add.: j) reduction (+ : d) do i = 1, 100 j = j.add.iand (i, -4) d = d + dt(i) end do if (d%x /= 5050 .or. j /= 4903) call abort end
gpl-2.0
jchristopherson/linalg
src/external/qrupdate/dqrinc.f
1
4242
c Copyright (C) 2008, 2009 VZLU Prague, a.s., Czech Republic c c Author: Jaroslav Hajek <highegg@gmail.com> c c This file is part of qrupdate. c c qrupdate is free software; you can redistribute it and/or modify c it under the terms of the GNU General Public License as published by c the Free Software Foundation; either version 3 of the License, or c (at your option) any later version. c c This program is distributed in the hope that it will be useful, c but WITHOUT ANY WARRANTY; without even the implied warranty of c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the c GNU General Public License for more details. c c You should have received a copy of the GNU General Public License c along with this software; see the file COPYING. If not, see c <http://www.gnu.org/licenses/>. c subroutine dqrinc(m,n,k,Q,ldq,R,ldr,j,x,w) c purpose: updates a QR factorization after inserting a new c column. c i.e., given an m-by-k orthogonal matrix Q, an m-by-n c upper trapezoidal matrix R and index j in the range c 1:n+1, this subroutine updates the matrix Q -> Q1 and c R -> R1 so that Q1 is again orthogonal, R1 upper c trapezoidal, and Q1*R1 = [A(:,1:j-1); x; A(:,j:n)], c where A = Q*R. c (real version) c arguments: c m (in) number of rows of the matrix Q. c n (in) number of columns of the matrix R. c k (in) number of columns of Q, and rows of R. Must be c either k = m (full Q) or k = n <= m (economical form, c basis dimension will increase). c Q (io) on entry, the orthogonal m-by-k matrix Q. c on exit, the updated matrix Q1. c ldq (in) leading dimension of Q. ldq >= m. c R (io) on entry, the original matrix R. c on exit, the updated matrix R1. c ldr (in) leading dimension of R. ldr >= min(m,n+1). c j (in) the position of the new column in R1 c x (in) the column being inserted c w (out) a workspace vector of size k. c integer m,n,k,ldq,ldr,j double precision Q(ldq,*),R(ldr,*),x(*),w(*) external dqrtv1,dqrqh,dqrot external xerbla,dcopy,ddot,daxpy,dscal,dnrm2 double precision ddot,dnrm2,rx integer info,i,k1 logical full c quick return if possible. if (m == 0) return c check arguments. info = 0 if (m < 0) then info = 1 else if (n < 0) then info = 2 else if (k /= m .and. (k /= n .or. n >= m)) then info = 3 else if (ldq < m) then info = 5 else if (ldr < min(m,k+1)) then info = 7 else if (j < 1 .or. j > n+1) then info = 8 end if if (info /= 0) then call xerbla('DQRINC',info) return end if full = k == m c insert empty column at j-th position. do i = n,j,-1 call dcopy(k,R(1,i),1,R(1,i+1),1) end do c insert Q'*u into R. In the nonfull case, form also u-Q*Q'*u. if (full) then k1 = k do i = 1,k R(i,j) = ddot(m,Q(1,i),1,x,1) end do else k1 = k + 1 c zero last row of R do i = 1,n+1 R(k1,i) = 0d0 end do call dcopy(m,x,1,Q(1,k1),1) do i = 1,k R(i,j) = ddot(m,Q(1,i),1,Q(1,k1),1) call daxpy(m,-R(i,j),Q(1,i),1,Q(1,k1),1) end do c get norm of the inserted column rx = dnrm2(m,Q(1,k1),1) R(k1,j) = rx if (rx == 0d0) then c in the rare case when rx is exact zero, we still need to provide c a valid orthogonal unit vector. The details are boring, so handle c that elsewhere. call dgqvec(m,k,Q,ldq,Q(1,k1)) else c otherwise, just normalize the added column. call dscal(m,1d0/rx,Q(1,k1),1) end if end if c maybe we're finished. if (j > k) return c eliminate the spike. call dqrtv1(k1+1-j,R(j,j),w) c apply rotations to R(j:k,j:n). if (j <= n) call dqrqh(k1+1-j,n+1-j,R(j,j+1),ldr,w,R(j+1,j)) c apply rotations to Q(:,j:k). call dqrot('B',m,k1+1-j,Q(1,j),ldq,w,R(j+1,j)) c zero spike. do i = j+1,k1 R(i,j) = 0d0 end do end subroutine
gpl-3.0
optimsoc/gzll-gcc
gcc/testsuite/gfortran.dg/assumed_charlen_function_1.f90
154
1971
! { dg-do compile } ! { dg-options "-std=legacy" } ! Tests the patch for PRs 25084, 20852, 25085 and 25086, all of ! which involve assumed character length functions. ! Compiled from original PR testcases, which were all contributed ! by Joost VandeVondele <jv244@cam.ac.uk> ! ! PR25084 - the error is not here but in any use of .IN. ! It is OK to define an assumed character length function ! in an interface but it cannot be invoked (5.1.1.5). MODULE M1 TYPE SET INTEGER CARD END TYPE SET END MODULE M1 MODULE INTEGER_SETS INTERFACE OPERATOR (.IN.) FUNCTION ELEMENT(X,A) ! { dg-error "cannot be assumed character length" } USE M1 CHARACTER(LEN=*) :: ELEMENT INTEGER, INTENT(IN) :: X TYPE(SET), INTENT(IN) :: A END FUNCTION ELEMENT END INTERFACE END MODULE ! 5.1.1.5 of the Standard: A function name declared with an asterisk ! char-len-param shall not be array-valued, pointer-valued, recursive ! or pure ! ! PR20852 RECURSIVE FUNCTION TEST() ! { dg-error "cannot be recursive" } CHARACTER(LEN=*) :: TEST TEST = "" END FUNCTION !PR25085 FUNCTION F1() ! { dg-error "cannot be array-valued" } CHARACTER(LEN=*), DIMENSION(10) :: F1 F1 = "" END FUNCTION F1 !PR25086 FUNCTION F2() result(f4) ! { dg-error "cannot be pointer-valued" } CHARACTER(LEN=*), POINTER :: f4 f4 = "" END FUNCTION F2 !PR????? pure FUNCTION F3() ! { dg-error "cannot be pure" } CHARACTER(LEN=*) :: F3 F3 = "" END FUNCTION F3 function not_OK (ch) character(*) not_OK, ch ! OK in an external function not_OK = ch end function not_OK use m1 character(4) :: answer character(*), external :: not_OK integer :: i type (set) :: z interface function ext (i) character(*) :: ext integer :: i end function ext end interface answer = not_OK ("unOK") ! { dg-error "since it is not a dummy" } END
gpl-2.0
optimsoc/gzll-gcc
libgomp/testsuite/libgomp.fortran/udr13.f90
102
3246
! { dg-do run } interface subroutine sub1 (x, y) integer, intent(in) :: y(:) integer, intent(out) :: x(:) end subroutine function fn2 (x, m1, m2, n1, n2) integer, intent(in) :: x(:,:), m1, m2, n1, n2 integer :: fn2(m1:m2,n1:n2) end function subroutine sub3 (x, y) integer, allocatable, intent(in) :: y(:,:) integer, allocatable, intent(inout) :: x(:,:) end subroutine end interface !$omp declare reduction (foo : integer : sub3 (omp_out, omp_in)) & !$omp initializer (omp_priv = fn3 (omp_orig)) !$omp declare reduction (bar : integer : omp_out = fn1 (omp_out, omp_in, & !$omp & lbound (omp_out, 1), ubound (omp_out, 1))) & !$omp & initializer (sub1 (omp_priv, omp_orig)) !$omp declare reduction (baz : integer : sub2 (omp_out, omp_in)) & !$omp initializer (omp_priv = fn2 (omp_orig, lbound (omp_priv, 1), & !$omp ubound (omp_priv, 1), lbound (omp_priv, 2), ubound (omp_priv, 2))) interface function fn1 (x, y, m1, m2) integer, intent(in) :: x(:), y(:), m1, m2 integer :: fn1(m1:m2) end function subroutine sub2 (x, y) integer, intent(in) :: y(:,:) integer, intent(inout) :: x(:,:) end subroutine function fn3 (x) integer, allocatable, intent(in) :: x(:,:) integer, allocatable :: fn3(:,:) end function end interface integer :: a(10), b(3:5,7:9), r integer, allocatable :: c(:,:) a(:) = 0 r = 0 !$omp parallel reduction (bar : a) reduction (+: r) if (lbound (a, 1) /= 1 .or. ubound (a, 1) /= 10) call abort a = a + 2 r = r + 1 !$omp end parallel if (any (a /= 4 * r) ) call abort b(:,:) = 0 allocate (c (4:6,8:10)) c(:,:) = 0 r = 0 !$omp parallel reduction (baz : b, c) reduction (+: r) if (lbound (b, 1) /= 3 .or. ubound (b, 1) /= 5) call abort if (lbound (b, 2) /= 7 .or. ubound (b, 2) /= 9) call abort if (.not. allocated (c)) call abort if (lbound (c, 1) /= 4 .or. ubound (c, 1) /= 6) call abort if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 10) call abort b = b + 3 c = c + 4 r = r + 1 !$omp end parallel if (any (b /= 3 * r) .or. any (c /= 4 * r)) call abort deallocate (c) allocate (c (0:1,7:11)) c(:,:) = 0 r = 0 !$omp parallel reduction (foo : c) reduction (+: r) if (.not. allocated (c)) call abort if (lbound (c, 1) /= 0 .or. ubound (c, 1) /= 1) call abort if (lbound (c, 2) /= 7 .or. ubound (c, 2) /= 11) call abort c = c + 5 r = r + 1 !$omp end parallel if (any (c /= 10 * r)) call abort end function fn1 (x, y, m1, m2) integer, intent(in) :: x(:), y(:), m1, m2 integer :: fn1(m1:m2) fn1 = x + 2 * y end function subroutine sub1 (x, y) integer, intent(in) :: y(:) integer, intent(out) :: x(:) x = 0 end subroutine function fn2 (x, m1, m2, n1, n2) integer, intent(in) :: x(:,:), m1, m2, n1, n2 integer :: fn2(m1:m2,n1:n2) fn2 = x end function subroutine sub2 (x, y) integer, intent(inout) :: x(:,:) integer, intent(in) :: y(:,:) x = x + y end subroutine function fn3 (x) integer, allocatable, intent(in) :: x(:,:) integer, allocatable :: fn3(:,:) fn3 = x end function subroutine sub3 (x, y) integer, allocatable, intent(inout) :: x(:,:) integer, allocatable, intent(in) :: y(:,:) x = x + 2 * y end subroutine
gpl-2.0
optimsoc/gzll-gcc
libgfortran/generated/_log_c8.F90
35
1477
! Copyright (C) 2002-2014 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_8) #ifdef HAVE_CLOG elemental function _gfortran_specific__log_c8 (parm) complex (kind=8), intent (in) :: parm complex (kind=8) :: _gfortran_specific__log_c8 _gfortran_specific__log_c8 = log (parm) end function #endif #endif
gpl-2.0
alexurba/cftb
src/libsrc/blas/SRC/ztrmm.f
1
13069
SUBROUTINE ZTRMM(SIDE,UPLO,TRANSA,DIAG,M,N,ALPHA,A,LDA,B,LDB) * .. Scalar Arguments .. DOUBLE COMPLEX ALPHA INTEGER LDA,LDB,M,N CHARACTER DIAG,SIDE,TRANSA,UPLO * .. * .. Array Arguments .. DOUBLE COMPLEX A(LDA,*),B(LDB,*) * .. * * Purpose * ======= * * ZTRMM performs one of the matrix-matrix operations * * B := alpha*op( A )*B, or B := alpha*B*op( A ) * * where alpha is a scalar, B is an m by n matrix, A is a unit, or * non-unit, upper or lower triangular matrix and op( A ) is one of * * op( A ) = A or op( A ) = A' or op( A ) = conjg( A' ). * * Arguments * ========== * * SIDE - CHARACTER*1. * On entry, SIDE specifies whether op( A ) multiplies B from * the left or right as follows: * * SIDE = 'L' or 'l' B := alpha*op( A )*B. * * SIDE = 'R' or 'r' B := alpha*B*op( A ). * * Unchanged on exit. * * UPLO - CHARACTER*1. * On entry, UPLO specifies whether the matrix A is an upper or * lower triangular matrix as follows: * * UPLO = 'U' or 'u' A is an upper triangular matrix. * * UPLO = 'L' or 'l' A is a lower triangular matrix. * * Unchanged on exit. * * TRANSA - CHARACTER*1. * On entry, TRANSA specifies the form of op( A ) to be used in * the matrix multiplication as follows: * * TRANSA = 'N' or 'n' op( A ) = A. * * TRANSA = 'T' or 't' op( A ) = A'. * * TRANSA = 'C' or 'c' op( A ) = conjg( A' ). * * Unchanged on exit. * * DIAG - CHARACTER*1. * On entry, DIAG specifies whether or not A is unit triangular * as follows: * * DIAG = 'U' or 'u' A is assumed to be unit triangular. * * DIAG = 'N' or 'n' A is not assumed to be unit * triangular. * * Unchanged on exit. * * M - INTEGER. * On entry, M specifies the number of rows of B. M must be at * least zero. * Unchanged on exit. * * N - INTEGER. * On entry, N specifies the number of columns of B. N must be * at least zero. * Unchanged on exit. * * ALPHA - COMPLEX*16 . * On entry, ALPHA specifies the scalar alpha. When alpha is * zero then A is not referenced and B need not be set before * entry. * Unchanged on exit. * * A - COMPLEX*16 array of DIMENSION ( LDA, k ), where k is m * when SIDE = 'L' or 'l' and is n when SIDE = 'R' or 'r'. * Before entry with UPLO = 'U' or 'u', the leading k by k * upper triangular part of the array A must contain the upper * triangular matrix and the strictly lower triangular part of * A is not referenced. * Before entry with UPLO = 'L' or 'l', the leading k by k * lower triangular part of the array A must contain the lower * triangular matrix and the strictly upper triangular part of * A is not referenced. * Note that when DIAG = 'U' or 'u', the diagonal elements of * A are not referenced either, but are assumed to be unity. * Unchanged on exit. * * LDA - INTEGER. * On entry, LDA specifies the first dimension of A as declared * in the calling (sub) program. When SIDE = 'L' or 'l' then * LDA must be at least max( 1, m ), when SIDE = 'R' or 'r' * then LDA must be at least max( 1, n ). * Unchanged on exit. * * B - COMPLEX*16 array of DIMENSION ( LDB, n ). * Before entry, the leading m by n part of the array B must * contain the matrix B, and on exit is overwritten by the * transformed matrix. * * LDB - INTEGER. * On entry, LDB specifies the first dimension of B as declared * in the calling (sub) program. LDB must be at least * max( 1, m ). * Unchanged on exit. * * Further Details * =============== * * Level 3 Blas routine. * * -- Written on 8-February-1989. * Jack Dongarra, Argonne National Laboratory. * Iain Duff, AERE Harwell. * Jeremy Du Croz, Numerical Algorithms Group Ltd. * Sven Hammarling, Numerical Algorithms Group Ltd. * * ===================================================================== * * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL XERBLA * .. * .. Intrinsic Functions .. INTRINSIC DCONJG,MAX * .. * .. Local Scalars .. DOUBLE COMPLEX TEMP INTEGER I,INFO,J,K,NROWA LOGICAL LSIDE,NOCONJ,NOUNIT,UPPER * .. * .. Parameters .. DOUBLE COMPLEX ONE PARAMETER (ONE= (1.0D+0,0.0D+0)) DOUBLE COMPLEX ZERO PARAMETER (ZERO= (0.0D+0,0.0D+0)) * .. * * Test the input parameters. * LSIDE = LSAME(SIDE,'L') IF (LSIDE) THEN NROWA = M ELSE NROWA = N END IF NOCONJ = LSAME(TRANSA,'T') NOUNIT = LSAME(DIAG,'N') UPPER = LSAME(UPLO,'U') * INFO = 0 IF ((.NOT.LSIDE) .AND. (.NOT.LSAME(SIDE,'R'))) THEN INFO = 1 ELSE IF ((.NOT.UPPER) .AND. (.NOT.LSAME(UPLO,'L'))) THEN INFO = 2 ELSE IF ((.NOT.LSAME(TRANSA,'N')) .AND. + (.NOT.LSAME(TRANSA,'T')) .AND. + (.NOT.LSAME(TRANSA,'C'))) THEN INFO = 3 ELSE IF ((.NOT.LSAME(DIAG,'U')) .AND. (.NOT.LSAME(DIAG,'N'))) THEN INFO = 4 ELSE IF (M.LT.0) THEN INFO = 5 ELSE IF (N.LT.0) THEN INFO = 6 ELSE IF (LDA.LT.MAX(1,NROWA)) THEN INFO = 9 ELSE IF (LDB.LT.MAX(1,M)) THEN INFO = 11 END IF IF (INFO.NE.0) THEN CALL XERBLA('ZTRMM ',INFO) RETURN END IF * * Quick return if possible. * IF (M.EQ.0 .OR. N.EQ.0) RETURN * * And when alpha.eq.zero. * IF (ALPHA.EQ.ZERO) THEN DO 20 J = 1,N DO 10 I = 1,M B(I,J) = ZERO 10 CONTINUE 20 CONTINUE RETURN END IF * * Start the operations. * IF (LSIDE) THEN IF (LSAME(TRANSA,'N')) THEN * * Form B := alpha*A*B. * IF (UPPER) THEN DO 50 J = 1,N DO 40 K = 1,M IF (B(K,J).NE.ZERO) THEN TEMP = ALPHA*B(K,J) DO 30 I = 1,K - 1 B(I,J) = B(I,J) + TEMP*A(I,K) 30 CONTINUE IF (NOUNIT) TEMP = TEMP*A(K,K) B(K,J) = TEMP END IF 40 CONTINUE 50 CONTINUE ELSE DO 80 J = 1,N DO 70 K = M,1,-1 IF (B(K,J).NE.ZERO) THEN TEMP = ALPHA*B(K,J) B(K,J) = TEMP IF (NOUNIT) B(K,J) = B(K,J)*A(K,K) DO 60 I = K + 1,M B(I,J) = B(I,J) + TEMP*A(I,K) 60 CONTINUE END IF 70 CONTINUE 80 CONTINUE END IF ELSE * * Form B := alpha*A'*B or B := alpha*conjg( A' )*B. * IF (UPPER) THEN DO 120 J = 1,N DO 110 I = M,1,-1 TEMP = B(I,J) IF (NOCONJ) THEN IF (NOUNIT) TEMP = TEMP*A(I,I) DO 90 K = 1,I - 1 TEMP = TEMP + A(K,I)*B(K,J) 90 CONTINUE ELSE IF (NOUNIT) TEMP = TEMP*DCONJG(A(I,I)) DO 100 K = 1,I - 1 TEMP = TEMP + DCONJG(A(K,I))*B(K,J) 100 CONTINUE END IF B(I,J) = ALPHA*TEMP 110 CONTINUE 120 CONTINUE ELSE DO 160 J = 1,N DO 150 I = 1,M TEMP = B(I,J) IF (NOCONJ) THEN IF (NOUNIT) TEMP = TEMP*A(I,I) DO 130 K = I + 1,M TEMP = TEMP + A(K,I)*B(K,J) 130 CONTINUE ELSE IF (NOUNIT) TEMP = TEMP*DCONJG(A(I,I)) DO 140 K = I + 1,M TEMP = TEMP + DCONJG(A(K,I))*B(K,J) 140 CONTINUE END IF B(I,J) = ALPHA*TEMP 150 CONTINUE 160 CONTINUE END IF END IF ELSE IF (LSAME(TRANSA,'N')) THEN * * Form B := alpha*B*A. * IF (UPPER) THEN DO 200 J = N,1,-1 TEMP = ALPHA IF (NOUNIT) TEMP = TEMP*A(J,J) DO 170 I = 1,M B(I,J) = TEMP*B(I,J) 170 CONTINUE DO 190 K = 1,J - 1 IF (A(K,J).NE.ZERO) THEN TEMP = ALPHA*A(K,J) DO 180 I = 1,M B(I,J) = B(I,J) + TEMP*B(I,K) 180 CONTINUE END IF 190 CONTINUE 200 CONTINUE ELSE DO 240 J = 1,N TEMP = ALPHA IF (NOUNIT) TEMP = TEMP*A(J,J) DO 210 I = 1,M B(I,J) = TEMP*B(I,J) 210 CONTINUE DO 230 K = J + 1,N IF (A(K,J).NE.ZERO) THEN TEMP = ALPHA*A(K,J) DO 220 I = 1,M B(I,J) = B(I,J) + TEMP*B(I,K) 220 CONTINUE END IF 230 CONTINUE 240 CONTINUE END IF ELSE * * Form B := alpha*B*A' or B := alpha*B*conjg( A' ). * IF (UPPER) THEN DO 280 K = 1,N DO 260 J = 1,K - 1 IF (A(J,K).NE.ZERO) THEN IF (NOCONJ) THEN TEMP = ALPHA*A(J,K) ELSE TEMP = ALPHA*DCONJG(A(J,K)) END IF DO 250 I = 1,M B(I,J) = B(I,J) + TEMP*B(I,K) 250 CONTINUE END IF 260 CONTINUE TEMP = ALPHA IF (NOUNIT) THEN IF (NOCONJ) THEN TEMP = TEMP*A(K,K) ELSE TEMP = TEMP*DCONJG(A(K,K)) END IF END IF IF (TEMP.NE.ONE) THEN DO 270 I = 1,M B(I,K) = TEMP*B(I,K) 270 CONTINUE END IF 280 CONTINUE ELSE DO 320 K = N,1,-1 DO 300 J = K + 1,N IF (A(J,K).NE.ZERO) THEN IF (NOCONJ) THEN TEMP = ALPHA*A(J,K) ELSE TEMP = ALPHA*DCONJG(A(J,K)) END IF DO 290 I = 1,M B(I,J) = B(I,J) + TEMP*B(I,K) 290 CONTINUE END IF 300 CONTINUE TEMP = ALPHA IF (NOUNIT) THEN IF (NOCONJ) THEN TEMP = TEMP*A(K,K) ELSE TEMP = TEMP*DCONJG(A(K,K)) END IF END IF IF (TEMP.NE.ONE) THEN DO 310 I = 1,M B(I,K) = TEMP*B(I,K) 310 CONTINUE END IF 320 CONTINUE END IF END IF END IF * RETURN * * End of ZTRMM . * END
mit
Vitancourt/gcc
gcc/testsuite/gfortran.dg/pr61209.f90
99
1519
! { dg-do compile } ! { dg-options "-O -fbounds-check" } MODULE array_types INTERFACE array_data MODULE PROCEDURE array_data_i1d END INTERFACE TYPE array_i1d_type END TYPE array_i1d_type TYPE array_i1d_obj TYPE(array_i1d_type), POINTER :: low END TYPE array_i1d_obj TYPE dbcsr_type TYPE(array_i1d_obj) :: local_rows LOGICAL :: local_indexing END TYPE dbcsr_type TYPE dbcsr_obj TYPE(dbcsr_type) :: m END TYPE dbcsr_obj CONTAINS FUNCTION array_data_i1d(array) RESULT (DATA) TYPE(array_i1d_obj), INTENT(IN) :: array INTEGER, DIMENSION(:), POINTER :: DATA IF (ASSOCIATED (array%low)) THEN ENDIF END FUNCTION array_data_i1d SUBROUTINE dbcsr_make_index_list (matrix, thread_redist) TYPE(dbcsr_obj), INTENT(INOUT) :: matrix LOGICAL, INTENT(IN) :: thread_redist INTEGER, ALLOCATABLE, DIMENSION(:, :) :: blki INTEGER, DIMENSION(:), POINTER :: local_rows, td INTEGER :: blk nthreads = 0 IF (nthreads .GT. 0 .AND. thread_redist) THEN IF (matrix%m%local_indexing) THEN local_rows => array_data (matrix%m%local_rows) ENDIF CALL dbcsr_build_row_index_inplace (thr_c, nthreads) IF (matrix%m%local_indexing) THEN DO blk = 1, nblks IF (td(local_rows(blki(1, blk))) .EQ. ithread) THEN ENDIF ENDDO ENDIF ENDIF END SUBROUTINE dbcsr_make_index_list END MODULE
gpl-2.0
Vitancourt/gcc
gcc/testsuite/gfortran.dg/select_type_25.f90
165
1265
! { dg-do compile } ! { dg-options "-fcoarray=single" } ! ! PR fortran/51605 ! subroutine one() type t end type t ! (a) Invalid (was ICEing before) class(t), target :: p1 ! { dg-error "must be dummy, allocatable or pointer" } class(t), pointer :: p2 select type(p1) type is(t) p2 => p1 class is(t) p2 => p1 end select end subroutine one subroutine two() type t end type t class(t), allocatable, target :: p1 ! (b) Valid class(t), pointer :: p2 select type(p1) type is(t) p2 => p1 class is(t) p2 => p1 end select end subroutine two subroutine three() type t end type t class(t), allocatable :: p1 ! (c) Invalid as not TARGET class(t), pointer :: p2 select type(p1) type is(t) p2 => p1 ! { dg-error "Pointer assignment target is neither TARGET nor POINTER" } class is(t) p2 => p1 ! { dg-error "Pointer assignment target is neither TARGET nor POINTER" } end select end subroutine three subroutine four() type t end type t class(t), pointer :: p1 ! (d) Valid class(t), pointer :: p2 select type(p1) type is(t) p2 => p1 class is(t) p2 => p1 end select end subroutine four subroutine caf(x) type t end type t class(t) :: x[*] select type(x) type is(t) end select end subroutine caf
gpl-2.0
rotorliu/eigen
lapack/iladlr.f
271
3000
*> \brief \b ILADLR * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download ILADLR + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/iladlr.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/iladlr.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/iladlr.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * INTEGER FUNCTION ILADLR( M, N, A, LDA ) * * .. Scalar Arguments .. * INTEGER M, N, LDA * .. * .. Array Arguments .. * DOUBLE PRECISION A( LDA, * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> ILADLR scans A for its last non-zero row. *> \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 April 2012 * *> \ingroup auxOTHERauxiliary * * ===================================================================== INTEGER FUNCTION ILADLR( M, N, A, LDA ) * * -- LAPACK auxiliary routine (version 3.4.1) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * April 2012 * * .. 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, J * .. * .. Executable Statements .. * * Quick test for the common case where one corner is non-zero. IF( M.EQ.0 ) THEN ILADLR = M ELSE IF( A(M, 1).NE.ZERO .OR. A(M, N).NE.ZERO ) THEN ILADLR = M ELSE * Scan up each column tracking the last zero row seen. ILADLR = 0 DO J = 1, N I=M DO WHILE((A(MAX(I,1),J).EQ.ZERO).AND.(I.GE.1)) I=I-1 ENDDO ILADLR = MAX( ILADLR, I ) END DO END IF RETURN END
bsd-3-clause
sudosurootdev/gcc
libgomp/testsuite/libgomp.fortran/retval1.f90
109
3188
! { dg-do run } function f1 () use omp_lib real :: f1 logical :: l f1 = 6.5 l = .false. !$omp parallel firstprivate (f1) num_threads (2) reduction (.or.:l) l = f1 .ne. 6.5 if (omp_get_thread_num () .eq. 0) f1 = 8.5 if (omp_get_thread_num () .eq. 1) f1 = 14.5 !$omp barrier l = l .or. (omp_get_thread_num () .eq. 0 .and. f1 .ne. 8.5) l = l .or. (omp_get_thread_num () .eq. 1 .and. f1 .ne. 14.5) !$omp end parallel if (l) call abort f1 = -2.5 end function f1 function f2 () use omp_lib real :: f2, e2 logical :: l entry e2 () f2 = 6.5 l = .false. !$omp parallel firstprivate (e2) num_threads (2) reduction (.or.:l) l = e2 .ne. 6.5 if (omp_get_thread_num () .eq. 0) e2 = 8.5 if (omp_get_thread_num () .eq. 1) e2 = 14.5 !$omp barrier l = l .or. (omp_get_thread_num () .eq. 0 .and. e2 .ne. 8.5) l = l .or. (omp_get_thread_num () .eq. 1 .and. e2 .ne. 14.5) !$omp end parallel if (l) call abort e2 = 7.5 end function f2 function f3 () use omp_lib real :: f3, e3 logical :: l entry e3 () f3 = 6.5 l = .false. !$omp parallel firstprivate (f3, e3) num_threads (2) reduction (.or.:l) l = e3 .ne. 6.5 l = l .or. f3 .ne. 6.5 if (omp_get_thread_num () .eq. 0) e3 = 8.5 if (omp_get_thread_num () .eq. 1) e3 = 14.5 f3 = e3 - 4.5 !$omp barrier l = l .or. (omp_get_thread_num () .eq. 0 .and. e3 .ne. 8.5) l = l .or. (omp_get_thread_num () .eq. 1 .and. e3 .ne. 14.5) l = l .or. f3 .ne. e3 - 4.5 !$omp end parallel if (l) call abort e3 = 0.5 end function f3 function f4 () result (r4) use omp_lib real :: r4, s4 logical :: l entry e4 () result (s4) r4 = 6.5 l = .false. !$omp parallel firstprivate (r4, s4) num_threads (2) reduction (.or.:l) l = s4 .ne. 6.5 l = l .or. r4 .ne. 6.5 if (omp_get_thread_num () .eq. 0) s4 = 8.5 if (omp_get_thread_num () .eq. 1) s4 = 14.5 r4 = s4 - 4.5 !$omp barrier l = l .or. (omp_get_thread_num () .eq. 0 .and. s4 .ne. 8.5) l = l .or. (omp_get_thread_num () .eq. 1 .and. s4 .ne. 14.5) l = l .or. r4 .ne. s4 - 4.5 !$omp end parallel if (l) call abort s4 = -0.5 end function f4 function f5 (is_f5) use omp_lib real :: f5 integer :: e5 logical :: l, is_f5 entry e5 (is_f5) if (is_f5) then f5 = 6.5 else e5 = 8 end if l = .false. !$omp parallel firstprivate (f5, e5) shared (is_f5) num_threads (2) & !$omp reduction (.or.:l) if (.not. is_f5) l = l .or. e5 .ne. 8 if (is_f5) l = l .or. f5 .ne. 6.5 if (omp_get_thread_num () .eq. 0) e5 = 8 if (omp_get_thread_num () .eq. 1) e5 = 14 f5 = e5 - 4.5 !$omp barrier l = l .or. (omp_get_thread_num () .eq. 0 .and. e5 .ne. 8) l = l .or. (omp_get_thread_num () .eq. 1 .and. e5 .ne. 14) l = l .or. f5 .ne. e5 - 4.5 !$omp end parallel if (l) call abort if (is_f5) f5 = -2.5 if (.not. is_f5) e5 = 8 end function f5 real :: f1, f2, e2, f3, e3, f4, e4, f5 integer :: e5 if (f1 () .ne. -2.5) call abort if (f2 () .ne. 7.5) call abort if (e2 () .ne. 7.5) call abort if (f3 () .ne. 0.5) call abort if (e3 () .ne. 0.5) call abort if (f4 () .ne. -0.5) call abort if (e4 () .ne. -0.5) call abort if (f5 (.true.) .ne. -2.5) call abort if (e5 (.false.) .ne. 8) call abort end
gpl-2.0
Vitancourt/gcc
libgfortran/generated/_abs_r10.F90
47
1475
! Copyright (C) 2002-2015 Free Software Foundation, Inc. ! Contributed by Paul Brook <paul@nowt.org> ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !GNU libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. !GNU libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. ! !This file is machine generated. #include "config.h" #include "kinds.inc" #include "c99_protos.inc" #if defined (HAVE_GFC_REAL_10) #ifdef HAVE_FABSL elemental function _gfortran_specific__abs_r10 (parm) real (kind=10), intent (in) :: parm real (kind=10) :: _gfortran_specific__abs_r10 _gfortran_specific__abs_r10 = abs (parm) end function #endif #endif
gpl-2.0
OSGConnect/modulefiles
recipes/pythia-pgs-mg-2.1.2/clean_lhco_output.f
1
17733
c------------- c Clean Olympics Output c Blame Jesse Thaler/Aaron Pierce c------------- PROGRAM CLEAN implicit none c&&&&&&&&&&&&&&&&&&& integer NMXHEP1 parameter (NMXHEP1=4000) common/HEPEVT1/NEVHEP1,NHEP1,ISTHEP1(NMXHEP1),IDHEP1(NMXHEP1), &JMOHEP1(2,NMXHEP1),JDAHEP1(2,NMXHEP1),PHEP1(5,NMXHEP1), &VHEP1(4,NMXHEP1), BeginStdhep1, EndStdhep1, i1 character*80 BeginStdhep1, EndStdhep1 integer NEVHEP1,NHEP1,ISTHEP1,IDHEP1,JMOHEP1,JDAHEP1,i1 double precision PHEP1,VHEP1 save /HEPEVT1/ C... NEVHEP - event number C... NHEP - number of entries in this event C... ISTHEP(..) - status code C... IDHEP(..) - particle ID, P.D.G. standard C... JMOHEP(1,..) - position of mother particle in list C... JMOHEP(2,..) - position of second mother particle in list C... JDAHEP(1,..) - position of first daughter in list C... JDAHEP(2,..) - position of last daughter in list C... PHEP(1,..) - x momentum in GeV/c C... PHEP(2,..) - y momentum in GeV/c C... PHEP(3,..) - z momentum in GeV/c C... PHEP(4,..) - energy in GeV C... PHEP(5,..) - mass in GeV/c**2 C... VHEP(1,..) - x vertex position in mm C... VHEP(2,..) - y vertex position in mm C... VHEP(3,..) - z vertex position in mm C... VHEP(4,..) - production time in mm/c c&&&&&&&&&&&&&&&&&&& integer numargs,iarg,dummy character*80 filetoclean,filetooutput,tmpinfo character*80 firstline integer nob,i parameter (nob=100) integer KCOUNTp,KTYPEp double precision XETAp,XPHIp,XPTp,XMASSp,XNTRACKp, & XBTAGp,XHADEMp,XDUM1p,XDUM2p common /PARTICLE/KCOUNTp,KTYPEp,XETAp, & XPHIp,XPTp,XMASSp, & XNTRACKp,XBTAGp,XHADEMp, & XDUM1p,XDUM2p integer KCOUNT,KTYPE,NPART double precision XETA,XPHI,XPT,XMASS,XNTRACK, & XBTAG,XHADEM,XDUM1,XDUM2 common /EVENT/KCOUNT(0:nob),KTYPE(0:nob),XETA(0:nob), & XPHI(0:nob),XPT(0:nob),XMASS(0:nob), & XNTRACK(0:nob),XBTAG(0:nob),XHADEM(0:nob), & XDUM1(0:nob),XDUM2(0:nob),NPART integer lfn logical ismuonclean,istriggerremove,isfirstremove logical isoldformat common /FLAGS/lfn,ismuonclean,istriggerremove,isfirstremove, & isoldformat lfn = 53 c... Get command line arguments numargs = IArgC() call getArg(numargs-1,filetoclean) call getArg(numargs,filetooutput) open(47,file=filetoclean,form='formatted',status='old') open(53,file=filetooutput, ACCESS='APPEND') ismuonclean=.false. isfirstremove=.false. istriggerremove=.false. isoldformat=.false. do iarg = 1, numargs-2 call getArg(iarg,tmpinfo) if (tmpinfo(1:index(tmpinfo,' ')).eq.'-muon') then ismuonclean = .true. else if (tmpinfo(1:index(tmpinfo,' ')).eq.'-first') then isfirstremove = .true. else if (tmpinfo(1:index(tmpinfo,' ')).eq.'-trigger') then istriggerremove = .true. else if (tmpinfo(1:index(tmpinfo,' ')).eq.'-old') then isoldformat = .true. else write(6,*) "Command line argument ", & tmpinfo(1:index(tmpinfo,' ')), & " not-recognized." end if end do C if(isoldformat.and.istriggerremove) then write(6,*) "When Old format called, Trigger option not needed" write(6,*) "Will remove the zero objects automatically" endif if(isoldformat.and.ismuonclean) then write(6,*) "When Old format called. Muon option not needed" write(6,*) "will combine muons automatically" endif if(isoldformat) then write (6,*) "I will convert the file to the old format and" write (6,*) "merge the non-isolated muons with jets" else if (ismuonclean) then write(6,*) "I will merge non-isolated muons with jets..." else if (istriggerremove) then write(6,*) "I will remove trigger object and put trigger" write(6,*) "word in the missing ET HAD/EM fraction..." end if if (isfirstremove) then write(6,*) "I will remove the first line..." endif c... Read in data to common blocks 600 format(i3,i5,f9.3,f7.3,f8.2,f8.2,2f6.1,f9.2,2f6.1) 601 format(i3,i14,i7) 602 format(i3) read(47,end=100,fmt='(a80)') firstline ! first line is junk, store for later output if (isfirstremove) then else if (isoldformat) then 630 format(1x,2a3,2x,2a7,1X,2a9,2a7) !write out the old header line instead write(lfn,630) ' #','typ',' eta',' phi',' pt', $ ' jmas',' ntrack',' btag' else write(lfn,'(a80)') firstline !spit back out the first line end if c write (lfn,*) 'debug147: ' do while (.true.) read(47,end=100,fmt='(a80)') tmpinfo read(tmpinfo,fmt=602) KCOUNTp if (KCOUNTp.eq.(-1) ) then c write (lfn,*) 'debug153: ' read(tmpinfo,fmt=601) dummy, NEVHEP1, nhep1 do i = 1, nhep1 read(47, *) i1, isthep1(i), idhep1(i), . jmohep1(1,i), jmohep1(2,i), . jdahep1(1,i), jdahep1(2,i), . phep1(1,i), phep1(2,i), phep1(3,i), phep1(4,i), . phep1(5,i), . vhep1(1,i), vhep1(2,i), vhep1(3,i), vhep1(4,i) enddo else if (KCOUNTp.eq.0) then c write (lfn,*) 'debug164: ' read(tmpinfo,fmt=601) dummy,KCOUNTp, KTYPEp call startEvent else c write (lfn,*) 'debug169: ' read(tmpinfo,end=100,fmt=600) KCOUNTp,KTYPEp, & XETAp,XPHIp,XPTp,XMASSp, & XNTRACKp,XBTAGp,XHADEMp, & XDUM1p,XDUM2p end if if(KCOUNTp.eq.(-1) ) cycle; c write (lfn,*) 'debug174: ' call addParticle c write (lfn,*) 'debug176: ' if (KTYPEp.eq.6) call endEvent c write (lfn,*) 'debug178: ' end do c write (lfn,*) 'debug182: ' 100 continue write(6,*) "Thank you for using the olympics output cleaner." c write (lfn,*) 'debug186: ' end C------ Start Event subroutine startEvent c&&&&&&&&&&&&&&&&&&& integer NMXHEP1 parameter (NMXHEP1=4000) common/HEPEVT1/NEVHEP1,NHEP1,ISTHEP1(NMXHEP1),IDHEP1(NMXHEP1), &JMOHEP1(2,NMXHEP1),JDAHEP1(2,NMXHEP1),PHEP1(5,NMXHEP1), &VHEP1(4,NMXHEP1), BeginStdhep1, EndStdhep1, i1 character*80 BeginStdhep1, EndStdhep1 integer NEVHEP1,NHEP1,ISTHEP1,IDHEP1,JMOHEP1,JDAHEP1, i1 double precision PHEP1,VHEP1 save /HEPEVT1/ C... NEVHEP - event number C... NHEP - number of entries in this event C... ISTHEP(..) - status code C... IDHEP(..) - particle ID, P.D.G. standard C... JMOHEP(1,..) - position of mother particle in list C... JMOHEP(2,..) - position of second mother particle in list C... JDAHEP(1,..) - position of first daughter in list C... JDAHEP(2,..) - position of last daughter in list C... PHEP(1,..) - x momentum in GeV/c C... PHEP(2,..) - y momentum in GeV/c C... PHEP(3,..) - z momentum in GeV/c C... PHEP(4,..) - energy in GeV C... PHEP(5,..) - mass in GeV/c**2 C... VHEP(1,..) - x vertex position in mm C... VHEP(2,..) - y vertex position in mm C... VHEP(3,..) - z vertex position in mm C... VHEP(4,..) - production time in mm/c c&&&&&&&&&&&&&&&&&&& integer nob,i parameter (nob=100) integer KCOUNTp,KTYPEp double precision XETAp,XPHIp,XPTp,XMASSp,XNTRACKp, & XBTAGp,XHADEMp,XDUM1p,XDUM2p common /PARTICLE/KCOUNTp,KTYPEp,XETAp, & XPHIp,XPTp,XMASSp, & XNTRACKp,XBTAGp,XHADEMp, & XDUM1p,XDUM2p integer KCOUNT,KTYPE,NPART double precision XETA,XPHI,XPT,XMASS,XNTRACK, & XBTAG,XHADEM,XDUM1,XDUM2 common /EVENT/KCOUNT(0:nob),KTYPE(0:nob),XETA(0:nob), & XPHI(0:nob),XPT(0:nob),XMASS(0:nob), & XNTRACK(0:nob),XBTAG(0:nob),XHADEM(0:nob), & XDUM1(0:nob),XDUM2(0:nob),NPART integer lfn logical ismuonclean,istriggerremove,isfirstremove logical isoldformat common /FLAGS/lfn,ismuonclean,istriggerremove,isfirstremove, & isoldformat NPART = -1 ! The trigger object is the 0th object do i = 0, nob KCOUNT(i) = 0 KTYPE(i) = 0 XETA(i) = 0 XPHI(i) = 0 XPT(i) = 0 XMASS(i) = 0 XNTRACK(i)= 0 XBTAG(i) = 0 XHADEM(i) = 0 XDUM1(i) = 0 XDUM2(i) = 0 end do write (lfn,*) 'BeginEvent ', NEVHEP1 write (lfn,*) 'BeginStdhep' write (lfn,*) nhep1 do i = 1, nhep1 write (lfn,fmt=282) i, isthep1(i), idhep1(i), . jmohep1(1,i), jmohep1(2,i), . jdahep1(1,i), jdahep1(2,i), . phep1(1,i), phep1(2,i), phep1(3,i), phep1(4,i), . phep1(5,i), . vhep1(1,i), vhep1(2,i), vhep1(3,i), vhep1(4,i) enddo 282 format(i6,i4,i11,4i6,9f12.2) c 282 format(i5,i3,i10,4i5,9f9.2) write (lfn,*) 'EndStdhep' write (lfn,*) 'BeginReco' if (istriggerremove.or.isoldformat) then else c write (lfn,*) 'debug286: ' write(lfn,'(i3,i14,i7)') 0,KCOUNTp,KTYPEp end if end C------ Add Particle subroutine addParticle integer nob,i parameter (nob=100) integer KCOUNTp,KTYPEp double precision XETAp,XPHIp,XPTp,XMASSp,XNTRACKp, & XBTAGp,XHADEMp,XDUM1p,XDUM2p common /PARTICLE/KCOUNTp,KTYPEp,XETAp, & XPHIp,XPTp,XMASSp, & XNTRACKp,XBTAGp,XHADEMp, & XDUM1p,XDUM2p integer KCOUNT,KTYPE,NPART double precision XETA,XPHI,XPT,XMASS,XNTRACK, & XBTAG,XHADEM,XDUM1,XDUM2 common /EVENT/KCOUNT(0:nob),KTYPE(0:nob),XETA(0:nob), & XPHI(0:nob),XPT(0:nob),XMASS(0:nob), & XNTRACK(0:nob),XBTAG(0:nob),XHADEM(0:nob), & XDUM1(0:nob),XDUM2(0:nob),NPART integer lfn logical ismuonclean,istriggerremove,isfirstremove, & isoldformat common /FLAGS/lfn,ismuonclean,istriggerremove,isfirstremove, & isoldformat NPART = NPART + 1 KCOUNT(NPART) = KCOUNTp KTYPE(NPART) = KTYPEp XETA(NPART) = XETAp XPHI(NPART) = XPHIp XPT(NPART) = XPTp XMASS(NPART) = XMASSp XNTRACK(NPART)= XNTRACKp XBTAG(NPART) = XBTAGp XHADEM(NPART) = XHADEMp XDUM1(NPART) = XDUM1p XDUM2(NPART) = XDUM2p if (isoldformat) then C need to fix up btags column, massage number of tracks and charge if(KTYPEp.eq.4.and.XBTAGp.eq.1.0.or.XBTAGp.eq.2.0) then !btag for jets XBTAG(NPART)=1.0 else if(KTYPEp.eq.4.and.XBTAGp.eq.1.0) then XBTAG(NPART)=0.0 endif if (KTYPEp.le.2) then !for electrons and muons XMASS(NPART)=XNTRACKp !puts charge back in the mass column endif if (KTYPEp.eq.3) then !for taus if (XNTRACKp.gt.0) then XMASS(NPART)=1.0 else XMASS(NPART)=-1.0 XNTRACK(NPART)=ABS(XNTRACKp) end if endif endif end C------ End Event subroutine endEvent integer nob,i,k parameter (nob=100) integer KCOUNT,KTYPE,NPART double precision XETA,XPHI,XPT,XMASS,XNTRACK, & XBTAG,XHADEM,XDUM1,XDUM2 common /EVENT/KCOUNT(0:nob),KTYPE(0:nob),XETA(0:nob), & XPHI(0:nob),XPT(0:nob),XMASS(0:nob), & XNTRACK(0:nob),XBTAG(0:nob),XHADEM(0:nob), & XDUM1(0:nob),XDUM2(0:nob),NPART integer lfn logical ismuonclean,istriggerremove,isfirstremove logical isoldformat common /FLAGS/lfn,ismuonclean,istriggerremove,isfirstremove, & isoldformat C double precision ptiso, etrat double precision ptisomax, etratmax parameter(ptisomax=5d0) parameter(etratmax=.1125d0) logical jetcloseflag C if (.Not.isoldformat) then if (istriggerremove) then c write (lfn,*) 'L375: NPART = ', NPART do i = 1, NPART if (KTYPE(i).eq.6) then ! if missing ET object XHADEM(i) = KTYPE(0) !move the trigger word there end if end do end if endif if (ismuonclean.or.isoldformat) then c write (lfn,*) 'L385: NPART = ', NPART do i = 1, NPART if (KTYPE(i).eq.2) then C we'll check to see if muon passes cuts ptiso=DBLE(INT(XHADEM(i))) etrat=XHADEM(i)-ptiso !decimal part if (ptiso .ge. ptisomax .or. etrat.ge. etratmax) then KTYPE(i) = 999 ! remove muon C add it to the closest jet in delta R if there is a jet in event C otherwise the muon just gets deleted. if (int(XBTAG(i)).gt.0) then call mergeMuon(i,int(XBTAG(i))) endif end if endif end do end if k = 0 ! renumber events c write (lfn,*) 'L406: NPART = ', NPART do i = 1, NPART ! trigger word has already been printed in startEvent if (KTYPE(i).ne.999) then ! if not a deleted object k = k + 1 if(isoldformat) then if (ktype(i).ne.6) then c write (lfn,*) 'debug412: ' write(lfn,fmt=601) k,KTYPE(i),XETA(i), & XPHI(i),XPT(i),XMASS(i),XNTRACK(i),XBTAG(i) else c write (lfn,*) 'debug416: ' write(lfn,601) k,6,0.0,xphi(i),xpt(i),0.0,0.0,0.0 end if else c write (lfn,*) 'debug420: ' write(lfn,fmt=600) k,KTYPE(i),XETA(i), & XPHI(i),XPT(i),XMASS(i), & XNTRACK(i),XBTAG(i),XHADEM(i), & XDUM1(i),XDUM2(i) end if end if end do 600 format(i3,i5,f9.3,f7.3,f8.2,f8.2,2f6.1,f9.2,2f6.1) 601 format(1x,2i3,2x,2f7.3,1X,2f9.2,2f7.1) write (lfn,*) 'EndReco' write (lfn,*) 'EndEvent' end C------ Merge Muon subroutine mergeMuon(imuon,ijet) integer nob,i,k parameter (nob=100) double precision PX1,PY1,PZ1,PE1,PX2,PY2,PZ2,PE2,ETA,PHI,PT,MASS integer KCOUNT,KTYPE,NPART double precision XETA,XPHI,XPT,XMASS,XNTRACK, & XBTAG,XHADEM,XDUM1,XDUM2 common /EVENT/KCOUNT(0:nob),KTYPE(0:nob),XETA(0:nob), & XPHI(0:nob),XPT(0:nob),XMASS(0:nob), & XNTRACK(0:nob),XBTAG(0:nob),XHADEM(0:nob), & XDUM1(0:nob),XDUM2(0:nob),NPART logical ismuonclean,istriggerremove,isfirstremove logical isoldformat common /FLAGS/lfn,ismuonclean,istriggerremove,isfirstremove, & isoldformat C call fourVector(XETA(imuon),XPHI(imuon),XPT(imuon),XMASS(imuon), & PX1,PY1,PZ1,PE1) call fourVector(XETA(ijet),XPHI(ijet),XPT(ijet),XMASS(ijet), & PX2,PY2,PZ2,PE2) C PX2 = PX1 + PX2 PY2 = PY1 + PY2 PZ2 = PZ1 + PZ2 PE2 = PE1 + PE2 call etaPhiPtMass(PX2,PY2,PZ2,PE2,ETA,PHI,PT,MASS) XETA(ijet) = ETA XPHI(ijet) = PHI XPT(ijet) = PT XMASS(ijet) = MASS if (.not.isoldformat) then XNTRACK(ijet)= XNTRACK(ijet)+1.1 else XNTRACK(ijet)= XNTRACK(ijet)+1.0 endif end C---------------------------------------------------------------------- C...Begin subroutine fourVector C---------------------------------------------------------------------- subroutine fourVector(ETA,PHI,PT,MASS,PX,PY,PZ,PE) double precision ETA,PHI,PT,MASS,PX,PY,PZ,PE PX = PT * cos(PHI) PY = PT * sin(PHI) PZ = PT * sinh(ETA) PE=SQRT (PX**2+PY**2+PZ**2+MASS**2) end C---------------------------------------------------------------------- C...Begin subroutine etaPhiPtMass C---------------------------------------------------------------------- subroutine etaPhiPtMass(PX,PY,PZ,PE,ETA,PHI,PT,MASS) implicit none double precision ETA,PHI,PT,MASS,PX,PY,PZ,PE double precision MASSSQ,PTSQ,PTEMP double precision pi parameter (pi=3.1415926d0) MASSSQ=PE**2 - PX**2 - PY**2 - PZ**2 if (MASSSQ.gt.0d0) then MASS=sqrt(MASSSQ) else MASS=0d0 endif C PTSQ=PX**2+PY**2 IF (PTSQ.gt.0d0) then PT = SQRT(PTSQ) else PT=0d0 endif C PHI = atan2(PY,PX) if (PHI.le.0d0) THEN PHI = PHI + 2.0d0*pi endif C ETA = 0 PTEMP=SQRT(PTSQ+PZ**2) if ( (PTEMP-PZ).ne.0.0) then ETA = dlog(PT/(PTEMP-PZ)) endif return end
apache-2.0
sudosurootdev/gcc
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
sudosurootdev/gcc
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
sudosurootdev/gcc
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
Vitancourt/gcc
libgfortran/generated/_mod_i8.F90
47
1461
! 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_INTEGER_8) elemental function _gfortran_specific__mod_i8 (p1, p2) integer (kind=8), intent (in) :: p1, p2 integer (kind=8) :: _gfortran_specific__mod_i8 _gfortran_specific__mod_i8 = mod (p1, p2) end function #endif
gpl-2.0
Vitancourt/gcc
gcc/testsuite/gfortran.dg/alloc_comp_initializer_1.f90
136
1751
! { dg-do run } ! This checks the correct functioning of derived types with default initializers ! and allocatable components. ! ! Contributed by Salvatore Filippone <salvatore.filippone@uniroma2.it> ! module p_type_mod type m_type integer, allocatable :: p(:) end type m_type type basep_type type(m_type), allocatable :: av(:) type(m_type), pointer :: ap => null () integer :: i = 101 end type basep_type type p_type type(basep_type), allocatable :: basepv(:) integer :: p1 , p2 = 1 end type p_type end module p_type_mod program foo use p_type_mod implicit none type(m_type), target :: a type(p_type) :: pre type(basep_type) :: wee call test_ab8 () a = m_type ((/101,102/)) call p_bld (a, pre) if (associated (wee%ap) .or. wee%i /= 101) call abort () wee%ap => a if (.not.associated (wee%ap) .or. allocated (wee%av)) call abort () wee = basep_type ((/m_type ((/201, 202, 203/))/), null (), 99) if (.not.allocated (wee%av) .or. associated (wee%ap) .or. (wee%i .ne. 99)) call abort () contains ! Check that allocatable components are nullified after allocation. subroutine test_ab8 () type(p_type) :: p integer :: ierr if (.not.allocated(p%basepv)) then allocate(p%basepv(1),stat=ierr) endif if (allocated (p%basepv) .neqv. .true.) call abort () if (allocated (p%basepv(1)%av) .neqv. .false.) call abort if (p%basepv(1)%i .ne. 101) call abort () end subroutine test_ab8 subroutine p_bld (a, p) use p_type_mod type (m_type) :: a type(p_type) :: p if (any (a%p .ne. (/101,102/))) call abort () if (allocated (p%basepv) .or. (p%p2 .ne. 1)) call abort () end subroutine p_bld end program foo
gpl-2.0
nikola-m/caffa3d-uns
tests/test_tensor_field_operations.f90
1
2370
program testFieldOperation use types use utils use geometry use tensor_fields use output implicit none ! Locals integer :: ierr type(volVectorField) :: vec1, vec2 type(volScalarField) :: phi type(volVectorField) :: resVec type(volTensorField) :: T ! 1) Print code logo and timestamp in monitor file !+-----------------------------------------------------------------------------+ call show_logo ! 2) Open & Read mesh file, calculate mesh geometrical quantities, allocate arrays !+-----------------------------------------------------------------------------+ call mesh_geometry ! 3) Define sparsity pattern according to given mesh connectivity data !+-----------------------------------------------------------------------------+ !call create_CSR_matrix_from_mesh_data ! 4) Finite Volume Discretization !+-----------------------------------------------------------------------------+ !allocate( phi(numCells) ) ! vec1 = new_volVectorField( numCells ) ! vec2 = new_volVectorField( numCells ) phi = new_volScalarField( numCells ) ! ! > Initialize vector fields ! vec1 = volVectorField( & "Vector1", & xc**2+yc+zc, & xc+yc**2+zc, & xc+yc+zc**2 & ) vec2 = volVectorField( & "Vector2", & xc+yc+zc, & xc+yc+zc, & xc+yc+zc & ) ! ! 1) Test dot product of two vector field ! phi%mag = vec1.dot.vec2 ! ! 2) Test cross product of two vector fields ! resVec = vec1.cross.vec2 ! ! 3) Tensor product of two vector fields ! T = vec1.tensor.vec2 !...curl of a derived tensor field resVec = .curl.(3.14_dp*T+T) ! ...set field name for vtk output file name: resVec % field_name = 'Curl_volVectorField' ! ! 4) Magnitude squared of a tensor field ! phi = .magSq.T ! 6) Write output files in Paraview .vtu format !+-----------------------------------------------------------------------------+ ierr = write_volScalarField_field( phi ) ierr = write_volVectorField_field( resVec ) ! 7) Final touches. !+-----------------------------------------------------------------------------+ call say_goodbye end program
gpl-3.0
sudosurootdev/gcc
libgfortran/generated/_sinh_r4.F90
35
1473
! Copyright (C) 2002-2014 Free Software Foundation, Inc. ! Contributed by Paul Brook <paul@nowt.org> ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !GNU libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. !GNU libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. ! !This file is machine generated. #include "config.h" #include "kinds.inc" #include "c99_protos.inc" #if defined (HAVE_GFC_REAL_4) #ifdef HAVE_SINHF elemental function _gfortran_specific__sinh_r4 (parm) real (kind=4), intent (in) :: parm real (kind=4) :: _gfortran_specific__sinh_r4 _gfortran_specific__sinh_r4 = sinh (parm) end function #endif #endif
gpl-2.0
luogyong/feasolver
FEMGRID/InsertPoints.f90
1
1549
subroutine InsertPoint() use meshDS use dflib implicit none integer::i,j,M character*7::msg integer::n1,n2 real(8)::d1,d2,d3,t1,t2 !三角形的形心 real(8)::x1,y1,x2,y2,s1,s2,factor call MAXKCD() !返回可插度最大的单元 if(iept==-1) return do while(.true.) if(iept>0.and.elt(iept).kcd==0) then call MAXKCD() end if if(iept==-1) exit if(nnode+1>maxnnode) call EnlargeNodeRelative() nnode=nnode+1 node(nnode).number=nnode n1=elt(iept).maxedge n2=mod(n1,3)+1 x1=node(elt(iept).node(n1)).x x2=node(elt(iept).node(n2)).x y1=node(elt(iept).node(n1)).y y2=node(elt(iept).node(n2)).y s1=node(elt(iept).node(n1)).s s2=node(elt(iept).node(n2)).s factor=s1/(s1+s2) node(nnode).x=x1+(x2-x1)*factor node(nnode).y=y1+(y2-y1)*factor !t1=((node(nnode).x-x1)**2+(node(nnode).y-y1)**2)**0.5 !t2=((node(nnode).x-x2)**2+(node(nnode).y-y2)**2)**0.5 !node(nnode).s=(s1/t1+s2/t2)/(1/t1+1/t2) node(nnode).s=s1+(s2-s1)*factor pehead=iept call GNM_Sloan(nnode) !write(msg,'(i7)') nnode !call SETMESSAGEQQ(msg,QWIN$MSG_RUNNING) end do ! allocate(iept) !防止后面RCL调用EKCD中iept指向null end subroutine subroutine MAXKCD() use meshDS implicit none integer::i integer::t1 if(pept>0) then i=pept else i=1 pept=1 end if iept=-1 do while(.true.) if(elt(i).kcd>0)then IEpt=i pept=i exit end if i=i+1 if(i>nelt) i=1 if(i==pept) exit end do end subroutine
lgpl-2.1
sudosurootdev/gcc
gcc/testsuite/gfortran.dg/entry_17.f90
181
1157
function test1(n) integer :: n character(n) :: test1 character(n) :: bar1 test1 = "" return entry bar1() bar1 = "" end function test1 function test2() character(1) :: test2 character(1) :: bar2 test2 = "" return entry bar2() bar2 = "" end function test2 function test3() ! { dg-warning "Obsolescent feature" } character(*) :: test3 character(*) :: bar3 ! { dg-warning "Obsolescent feature" } test3 = "" return entry bar3() bar3 = "" end function test3 function test4(n) ! { dg-warning "returning variables of different string lengths" } integer :: n character(n) :: test4 character(*) :: bar4 ! { dg-warning "Obsolescent feature" } test4 = "" return entry bar4() bar4 = "" end function test4 function test5() ! { dg-warning "returning variables of different string lengths" } character(1) :: test5 character(2) :: bar5 test5 = "" return entry bar5() bar5 = "" end function test5 function test6() ! { dg-warning "Obsolescent feature|returning variables of different string lengths" } character(*) :: test6 character(2) :: bar6 test6 = "" return entry bar6() bar6 = "" end function test6
gpl-2.0
RobinsonLab/pgplot
examples/pgdemo14.f
1
8895
PROGRAM PGDE14 C----------------------------------------------------------------------- C Demonstration program for PGPLOT: text input with PGRSTR. C C This program illustrates how an interactive program can be written C using PGPLOT. The program displays a number of active fields. Select C one of these fields using the cursor (e.g., click the mouse) to C activate it; then use the keyboard keys to edit the string displayed C in the field. Two of the fields have immediate action: 'DRAW' draws C a simple picture using the parameters specified in the input fields; C 'EXIT' terminates the program. C C A version of the subroutine used here, PGRSTR, may be included in a C future release of the PGPLOT library. C----------------------------------------------------------------------- INTEGER NBOX PARAMETER (NBOX=5) REAL BOX(4,NBOX), X, Y, XX, YY, A, D, XV(100), YV(100) INTEGER IVAL(NBOX) INTEGER PGOPEN, LSTR, I, JUNK, PGCURS, J, NV, BC, FC, CTOI INTEGER II, JJ CHARACTER CH CHARACTER*30 LABEL(NBOX), VALUE(NBOX), RESULT(NBOX) C DATA BOX /0.44, 0.8, 0.79, 0.83, : 0.44, 0.8, 0.69, 0.73, : 0.44, 0.8, 0.59, 0.63, : 0.44, 0.7, 0.29, 0.33, : 0.44, 0.7, 0.19, 0.23/ DATA LABEL /'Number of vertices:', : 'Background Color:', : 'Foreground Color:', : ' ', : ' '/ DATA VALUE /'13', : '0', : '1', : 'DRAW', : 'EXIT'/ C----------------------------------------------------------------------- WRITE (*,*) 'This program requires an interactive device.' WRITE (*,*) 'It presents a menu with editable fields which can be' WRITE (*,*) 'used to set parameters controlling a graph displayed' WRITE (*,*) 'beside the menu. To edit a field, first select it' WRITE (*,*) 'with the cursor (e.g., click mouse button) then use' WRITE (*,*) 'keyboard keys and DEL or ^U. TAB or CR terminates' WRITE (*,*) 'editing Click on DRAW to display the graph or EXIT' WRITE (*,*) 'to terminate the program.' WRITE (*,*) C C Open device for graphics. C IF (PGOPEN('?') .LE. 0) STOP CALL PGPAP(10.0,0.5) IVAL(1) = 13 IVAL(2) = 0 IVAL(3) = 1 C C Clear the screen. Draw a frame at the physical extremities of the C plot, using full-screen viewport and standard window. C CALL PGPAGE CALL PGSVP(0.0,1.0,0.0,1.0) CALL PGSWIN(0.0,2.0,0.0,1.0) CALL PGSCR(0, 0.4, 0.4, 0.4) C C Display fields C 5 WRITE(VALUE(1), '(I6)') IVAL(1) WRITE(VALUE(2), '(I6)') IVAL(2) WRITE(VALUE(3), '(I6)') IVAL(3) CALL PGSAVE CALL PGBBUF CALL PGERAS CALL PGSCI(1) CALL PGSLW(1) CALL PGSFS(1) CALL PGSCH(1.2) DO 10 I=1,NBOX RESULT(I) = VALUE(I) X = BOX(1,I) - 0.04 Y = BOX(3,I) + 0.01 CALL PGSCI(1) CALL PGPTXT(X, Y, 0.0, 1.0, LABEL(I)) CALL PGRECT(BOX(1,I), BOX(2,I), BOX(3,I), BOX(4,I)) X = BOX(1,I) + 0.01 CALL PGSCI(2) CALL PGPTXT(X, Y, 0.0, 0.0, VALUE(I)) 10 CONTINUE C C Draw picture C NV = MIN(100,IVAL(1)) BC = IVAL(2) FC = IVAL(3) CALL PGSCI(BC) CALL PGSFS(1) CALL PGRECT(1.05,1.95,0.05,0.95) CALL PGSCI(FC) CALL PGSFS(2) CALL PGRECT(1.05,1.95,0.05,0.95) IF (NV.GT.3) THEN D = 360.0/NV A = -D DO 120 II=1,NV A = A+D XV(II) = 1.5 + 0.4*COS(A/57.29577951) YV(II) = 0.5 + 0.4*SIN(A/57.29577951) 120 CONTINUE C DO 140 II=1,NV-1 DO 130 JJ=II+1,NV CALL PGMOVE(XV(II),YV(II)) CALL PGDRAW(XV(JJ),YV(JJ)) 130 CONTINUE 140 CONTINUE END IF CALL PGEBUF CALL PGUNSA C C Cursor loop: user selects a box C CALL PGSLW(2) CALL PGSFS(2) XX = 0.5 YY = 0.5 DO 60 J=1,1000 JUNK = PGCURS(XX, YY, CH) IF (ICHAR(CH).EQ.0) GOTO 50 C C Find which box and highlight it C DO 30 I=1,NBOX IF (BOX(1,I).LE.XX .AND. BOX(2,I).GE.XX .AND. : BOX(3,I).LE.YY .AND. BOX(4,I).GE.YY) THEN CALL PGSCI(2) CALL PGSLW(2) CALL PGSCH(1.2) CALL PGRECT(BOX(1,I), BOX(2,I), BOX(3,I), BOX(4,I)) CALL PGSLW(1) IF (I.EQ.5) THEN C -- EXIT box GOTO 50 ELSE IF (I.EQ.4) THEN C -- DRAW box GOTO 5 ELSE C C Read value C IF (RESULT(I).EQ.' ') THEN LSTR = 0 ELSE DO 11 II=LEN(RESULT(I)),1,-1 LSTR = II IF (RESULT(I)(II:II).NE.' ') GOTO 12 11 CONTINUE LSTR = 0 12 CONTINUE END IF X = BOX(1,I) + 0.01 Y = BOX(3,I) + 0.01 CALL PGRSTR(X, Y, 0.0, 0.0, RESULT(I), LSTR, 1) II = 1 IVAL(I) = CTOI(RESULT(I)(1:LSTR), II) END IF CALL PGSLW(2) CALL PGSCI(1) CALL PGRECT(BOX(1,I), BOX(2,I), BOX(3,I), BOX(4,I)) CALL PGSLW(1) END IF 30 CONTINUE 60 CONTINUE C C Close the device and exit. C 50 CONTINUE CALL PGCLOS END SUBROUTINE PGRSTR(X, Y, ANGLE, FJUST, TEXT, LSTR, BCI) REAL X, Y, ANGLE, FJUST CHARACTER*(*) TEXT INTEGER LSTR, BCI C----------------------------------------------------------------------- CHARACTER CH INTEGER JUNK, PGBAND, CI REAL XCUR, YCUR, XBOX(4), YBOX(4) C CALL PGQCI(CI) C 10 CONTINUE C -- Draw current string IF (LSTR.GT.0) THEN CALL PGPTXT(X, Y, ANGLE, FJUST, TEXT(1:LSTR)) CALL PGQTXT(X, Y, ANGLE, FJUST, TEXT(1:LSTR), XBOX, YBOX) XCUR = XBOX(4) YCUR = YBOX(4) ELSE XCUR = X YCUR = Y END IF C -- Read a character JUNK = PGBAND(0, 1, XCUR, YCUR, XCUR, YCUR, CH) C -- Erase old string CALL PGSCI(BCI) IF (LSTR.GT.0) : CALL PGPTXT(X, Y, ANGLE, FJUST, TEXT(1:LSTR)) CALL PGSCI(CI) C -- Avoid problem with PGPLOT escape character IF (CH.EQ.CHAR(92)) CH = '*' C -- Backspace (ctrl H) or delete removes last character IF (ICHAR(CH).EQ.8 .OR. ICHAR(CH).EQ.127) THEN IF (LSTR.GT.0) TEXT(LSTR:LSTR) = ' ' IF (LSTR.GT.0) LSTR = LSTR-1 C -- Ctrl U removes entire string ELSE IF (ICHAR(CH).EQ.21) THEN TEXT(1:LSTR) = ' ' LSTR = 0 C -- Any other non-printing character terminates input ELSE IF (ICHAR(CH).LT.32) THEN IF (LSTR.GT.0) : CALL PGPTXT(X, Y, ANGLE, FJUST, TEXT(1:LSTR)) GOTO 20 C -- Otherwise, add character to string if there is room ELSE IF (LSTR.LT.LEN(TEXT)) THEN LSTR = LSTR+1 TEXT(LSTR:LSTR) = CH END IF GOTO 10 C 20 RETURN END INTEGER FUNCTION CTOI (S, I) CHARACTER*(*) S INTEGER I C C Attempt to read an integer from a character string, and return C the result. No attempt is made to avoid integer overflow. A valid C integer is any sequence of decimal digits. C C Returns: C CTOI : the value of the integer; if the first character C read is not a decimal digit, the value returned C is zero. C Arguments: C S (input) : character string to be parsed. C I (in/out) : on input, I is the index of the first character C in S to be examined; on output, either it points C to the next character after a valid integer, or C it is equal to LEN(S)+1. C----------------------------------------------------------------------- INTEGER K CHARACTER*1 DIGITS(0:9) DATA DIGITS/'0','1','2','3','4','5','6','7','8','9'/ C CTOI = 0 10 IF (I.GT.LEN(S)) RETURN IF (S(I:I).EQ.' ') THEN I = I+1 GOTO 10 END IF DO 20 K=0,9 IF (S(I:I).EQ.DIGITS(K)) GOTO 30 20 CONTINUE RETURN 30 CTOI = CTOI*10 + K I = I+1 GOTO 10 END
apache-2.0
sudosurootdev/gcc
libgfortran/generated/_log_r16.F90
35
1474
! Copyright (C) 2002-2014 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_LOGL elemental function _gfortran_specific__log_r16 (parm) real (kind=16), intent (in) :: parm real (kind=16) :: _gfortran_specific__log_r16 _gfortran_specific__log_r16 = log (parm) end function #endif #endif
gpl-2.0
rotorliu/eigen
lapack/ilazlr.f
271
3010
*> \brief \b ILAZLR * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download ILAZLR + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ilazlr.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ilazlr.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ilazlr.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * INTEGER FUNCTION ILAZLR( M, N, A, LDA ) * * .. Scalar Arguments .. * INTEGER M, N, LDA * .. * .. Array Arguments .. * COMPLEX*16 A( LDA, * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> ILAZLR scans A for its last non-zero row. *> \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 COMPLEX*16 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 April 2012 * *> \ingroup complex16OTHERauxiliary * * ===================================================================== INTEGER FUNCTION ILAZLR( M, N, A, LDA ) * * -- LAPACK auxiliary routine (version 3.4.1) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * April 2012 * * .. Scalar Arguments .. INTEGER M, N, LDA * .. * .. Array Arguments .. COMPLEX*16 A( LDA, * ) * .. * * ===================================================================== * * .. Parameters .. COMPLEX*16 ZERO PARAMETER ( ZERO = (0.0D+0, 0.0D+0) ) * .. * .. Local Scalars .. INTEGER I, J * .. * .. Executable Statements .. * * Quick test for the common case where one corner is non-zero. IF( M.EQ.0 ) THEN ILAZLR = M ELSE IF( A(M, 1).NE.ZERO .OR. A(M, N).NE.ZERO ) THEN ILAZLR = M ELSE * Scan up each column tracking the last zero row seen. ILAZLR = 0 DO J = 1, N I=M DO WHILE((A(MAX(I,1),J).EQ.ZERO).AND.(I.GE.1)) I=I-1 ENDDO ILAZLR = MAX( ILAZLR, I ) END DO END IF RETURN END
bsd-3-clause
FrankZisko/likwid
src/likwid.f90
10
1634
! ======================================================================================= ! ! Filename: likwid.f90 ! ! Description: Marker API f90 module ! ! Version: 3.0 ! Released: 29.11.2012 ! ! Author: Jan Treibig (jt), jan.treibig@gmail.com ! Project: likwid ! ! Copyright (C) 2012 Jan Treibig ! ! 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/>. ! ! ======================================================================================= module likwid interface subroutine likwid_markerInit() end subroutine likwid_markerInit subroutine likwid_markerThreadInit() end subroutine likwid_markerThreadInit subroutine likwid_markerClose() end subroutine likwid_markerClose subroutine likwid_markerStartRegion( regionTag ) character(*) :: regionTag end subroutine likwid_markerStartRegion subroutine likwid_markerStopRegion( regionTag ) character(*) :: regionTag end subroutine likwid_markerStopRegion end interface end module likwid
gpl-3.0
Vitancourt/gcc
libgomp/testsuite/libgomp.fortran/examples-4/async_target-2.f90
23
1414
! { dg-do run } ! { dg-require-effective-target offload_device } subroutine init (v1, v2, N) !$omp declare target integer :: i, N real :: v1(N), v2(N) do i = 1, N v1(i) = i + 2.0 v2(i) = i - 3.0 end do end subroutine subroutine check (p, N) integer :: i, N real, parameter :: EPS = 0.00001 real :: diff, p(N) do i = 1, N diff = p(i) - (i + 2.0) * (i - 3.0) if (diff > EPS .or. -diff > EPS) call abort end do end subroutine subroutine vec_mult (p, N) use omp_lib, only: omp_is_initial_device real :: p(N) real, allocatable :: v1(:), v2(:) integer :: i !$omp declare target (init) !$omp target data map(to: v1, v2, N) map(from: p) !$omp task shared(v1, v2, p) depend(out: v1, v2) !$omp target map(to: v1, v2, N) if (omp_is_initial_device ()) call abort allocate (v1(N), v2(N)) call init (v1, v2, N) !$omp end target !$omp end task !$omp task shared(v1, v2, p) depend(in: v1, v2) !$omp target map(to: v1, v2, N) map(from: p) if (omp_is_initial_device ()) call abort !$omp parallel do do i = 1, N p(i) = v1(i) * v2(i) end do deallocate (v1, v2) !$omp end target !$omp end task !$omp end target data !$omp taskwait call check (p, N) end subroutine program e_55_2 integer, parameter :: N = 1000 real :: p(N) call vec_mult (p, N) end program
gpl-2.0
Vitancourt/gcc
gcc/testsuite/gfortran.dg/string_length_2.f90
48
1796
! { dg-do run } ! { dg-options "-fdump-tree-original" } ! Test that all string length calculations are ! optimized away. program main character (len=999) :: c character (len=5) :: unit unit = ' ' read (unit=unit,fmt='(I5)') i ! Hide from optimizers j = 7 c = '123456789' if (len(c( 3 : 5 )) /= 3) call abort ! Case 1 if (len(c( i*(i+1) : (i+1)*i + 2 )) /= 3) call abort ! Case 2 if (len(c( i*(i+1) : 2 + (i+1)*i )) /= 3) call abort ! Case 3 if (len(c( i*(i+1) + 2 : (i+1)*i + 3 )) /= 2) call abort ! Case 4 if (len(c( 2 + i*(i+1) : (i+1)*i + 3 )) /= 2) call abort ! Case 5 if (len(c( i*(i+1) + 2 : 3 + (i+1)*i )) /= 2) call abort ! Case 6 if (len(c( 2 + i*(i+1) : 3 + (i+1)*i )) /= 2) call abort ! Case 7 if (len(c( i*(i+1) - 1 : (i+1)*i + 1 )) /= 3) call abort ! Case 8 if (len(c( i*(i+1) - 1 : 1 + (i+1)*i )) /= 3) call abort ! Case 9 if (len(c( i*(i+1) : (i+1)*i -(-1))) /= 2) call abort ! Case 10 if (len(c( i*(i+1) +(-2): (i+1)*i - 1 )) /= 2) call abort ! Case 11 if (len(c( i*(i+1) + 2 : (i+1)*i -(-4))) /= 3) call abort ! Case 12 if (len(c( i*(i+1) - 3 : (i+1)*i - 1 )) /= 3) call abort ! Case 13 if (len(c(13 - i*(i+1) :15 - (i+1)*i )) /= 3) call abort ! Case 14 if (len(c( i*(i+1) +(-1): (i+1)*i )) /= 2) call abort ! Case 15 if (len(c(-1 + i*(i+1) : (i+1)*i )) /= 2) call abort ! Case 16 if (len(c( i*(i+1) - 2 : (i+1)*i )) /= 3) call abort ! Case 17 if (len(c( (i-2)*(i-3) : (i-3)*(i-2) )) /= 1) call abort ! Case 18 end program main ! { dg-final { scan-tree-dump-times "_abort" 0 "original" } }
gpl-2.0
Vitancourt/gcc
gcc/testsuite/gfortran.dg/allocate_with_typespec_2.f
183
3416
C { dg-do compile } C C Allocation of arrays with a type-spec specification with implicit none. C 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 C C Allocation of a scalar with a type-spec specification with implicit none C 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 C C Allocation of arrays with a type-spec specification with implicit none. C 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 C C Allocation of a scalar with a type-spec specification without implicit none C 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
gpl-2.0
sudosurootdev/gcc
gcc/testsuite/gfortran.dg/ftell_3.f90
147
1189
! { dg-do run { target fd_truncate } } ! PR43605 FTELL intrinsic returns incorrect position ! Contributed by Janne Blomqvist, Manfred Schwarb ! and Dominique d'Humieres. program ftell_3 integer :: i, j character(1) :: ch character(len=99) :: buffer open(10, form='formatted', position='rewind') write(10, '(a)') '123456' write(10, '(a)') '789' write(10, '(a)') 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC' write(10, '(a)') 'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD' rewind(10) read(10, '(a)') buffer call ftell(10, i) ! Expected: On '\n' systems: 7, on \r\n systems: 8 if(i /= 7 .and. i /= 8) then call abort end if read(10,'(a)') buffer if (trim(buffer) /= "789") then call abort() end if call ftell(10,j) close(10) open(10, access="stream") ! Expected: On '\n' systems: 11, on \r\n systems: 13 if (i == 7) then read(10, pos=7) ch if (ch /= char(10)) call abort if (j /= 11) call abort end if if (i == 8) then read(10, pos=7) ch if (ch /= char(13)) call abort read(10) ch if (ch /= char(10)) call abort if (j /= 13) call abort end if close(10, status="delete") end program ftell_3
gpl-2.0
Vitancourt/gcc
gcc/testsuite/gfortran.dg/used_dummy_types_7.f90
155
1119
! { dg-do compile } ! This tests a patch for a regression caused by the second part of ! the fix for PR30554. The linked derived types dummy_atom and ! dummy_atom_list caused a segment fault because they do not have ! a namespace. ! ! Contributed by Daniel Franke <franke.daniel@gmail.com> ! MODULE types TYPE :: dummy_atom_list TYPE(dummy_atom), DIMENSION(:), POINTER :: table => null() END TYPE TYPE :: dummy_atom TYPE(dummy_atom_private), POINTER :: p => null() END TYPE TYPE :: dummy_atom_private INTEGER :: id END TYPE END MODULE MODULE atom USE types, ONLY: dummy_atom INTERFACE SUBROUTINE dummy_atom_insert_symmetry_mate(this, other) USE types, ONLY: dummy_atom TYPE(dummy_atom), INTENT(inout) :: this TYPE(dummy_atom), INTENT(in) :: other END SUBROUTINE END INTERFACE END MODULE MODULE list INTERFACE SUBROUTINE dummy_atom_list_insert(this, atom2) USE types, ONLY: dummy_atom_list USE atom, ONLY: dummy_atom TYPE(dummy_atom_list), INTENT(inout) :: this TYPE(dummy_atom), INTENT(in) :: atom2 END SUBROUTINE END INTERFACE END MODULE
gpl-2.0
gdooper/scipy
scipy/linalg/src/id_dist/src/idd_id.f
128
15275
c this file contains the following user-callable routines: c c c routine iddp_id computes the ID of a matrix, c to a specified precision. c c routine iddr_id computes the ID of a matrix, c to a specified rank. c c routine idd_reconid reconstructs a matrix from its ID. c c routine idd_copycols collects together selected columns c of a matrix. c c routine idd_getcols collects together selected columns c of a matrix specified by a routine for applying the matrix c to arbitrary vectors. c c routine idd_reconint constructs p in the ID a = b p, c where the columns of b are a subset of the columns of a, c and p is the projection coefficient matrix, c given list, krank, and proj output by routines iddr_id c or iddp_id. c c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c c c subroutine iddp_id(eps,m,n,a,krank,list,rnorms) c c computes the ID of a, i.e., 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 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 such that the greatest singular value of epsilon c <= the greatest singular value of a * eps. c The present routine stores the krank x (n-krank) matrix proj c in the memory initially occupied by a. c c input: c eps -- relative precision of the resulting ID c m -- first dimension of a c n -- second dimension of a, as well as the dimension required c of list c a -- matrix to be ID'd c c output: c a -- the first krank*(n-krank) elements of a constitute c the krank x (n-krank) interpolation matrix proj c krank -- numerical rank c list -- list of the indices of the krank columns of a c through which the other columns of a are expressed; c also, list describes the permutation of proj c required to reconstruct a as indicated in (*) above c rnorms -- absolute values of the entries on the diagonal c of the triangular matrix used to compute the ID c (these may be used to check the stability of the ID) c c _N.B._: This routine changes a. c c reference: c Cheng, Gimbutas, Martinsson, Rokhlin, "On the compression of c low-rank matrices," SIAM Journal on Scientific Computing, c 26 (4): 1389-1404, 2005. c implicit none integer m,n,krank,k,list(n),iswap real*8 a(m,n),eps,rnorms(n) c c c QR decompose a. c call iddp_qrpiv(eps,m,n,a,krank,list,rnorms) c c c Build the list of columns chosen in a c by multiplying together the permutations in list, c with the permutation swapping 1 and list(1) taken rightmost c in the product, that swapping 2 and list(2) taken next c rightmost, ..., that swapping krank and list(krank) taken c leftmost. c do k = 1,n rnorms(k) = k enddo ! k c if(krank .gt. 0) then do k = 1,krank c c Swap rnorms(k) and rnorms(list(k)). c iswap = rnorms(k) rnorms(k) = rnorms(list(k)) rnorms(list(k)) = iswap c enddo ! k endif c do k = 1,n list(k) = rnorms(k) enddo ! k c c c Fill rnorms for the output. c if(krank .gt. 0) then c do k = 1,krank rnorms(k) = a(k,k) enddo ! k c endif c c c Backsolve for proj, storing it at the beginning of a. c if(krank .gt. 0) then call idd_lssolve(m,n,a,krank) endif c c return end c c c c subroutine iddr_id(m,n,a,krank,list,rnorms) c c computes the ID of a, i.e., 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 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 The present routine stores the krank x (n-krank) matrix proj c in the memory initially occupied by a. c c input: c m -- first dimension of a c n -- second dimension of a, as well as the dimension required c of list c a -- matrix to be ID'd c krank -- desired rank of the output matrix c (please note that if krank > m or krank > n, c then the rank of the output matrix will be c less than krank) c c output: c a -- the first krank*(n-krank) elements of a constitute c the krank x (n-krank) interpolation matrix proj c list -- list of the indices of the krank columns of a c through which the other columns of a are expressed; c also, list describes the permutation of proj c required to reconstruct a as indicated in (*) above c rnorms -- absolute values of the entries on the diagonal c of the triangular matrix used to compute the ID c (these may be used to check the stability of the ID) c c _N.B._: This routine changes a. c c reference: c Cheng, Gimbutas, Martinsson, Rokhlin, "On the compression of c low-rank matrices," SIAM Journal on Scientific Computing, c 26 (4): 1389-1404, 2005. c implicit none integer m,n,krank,j,k,list(n),iswap real*8 a(m,n),rnorms(n),ss c c c QR decompose a. c call iddr_qrpiv(m,n,a,krank,list,rnorms) c c c Build the list of columns chosen in a c by multiplying together the permutations in list, c with the permutation swapping 1 and list(1) taken rightmost c in the product, that swapping 2 and list(2) taken next c rightmost, ..., that swapping krank and list(krank) taken c leftmost. c do k = 1,n rnorms(k) = k enddo ! k c if(krank .gt. 0) then do k = 1,krank c c Swap rnorms(k) and rnorms(list(k)). c iswap = rnorms(k) rnorms(k) = rnorms(list(k)) rnorms(list(k)) = iswap c enddo ! k endif c do k = 1,n list(k) = rnorms(k) enddo ! k c c c Fill rnorms for the output. c ss = 0 c do k = 1,krank rnorms(k) = a(k,k) ss = ss+rnorms(k)**2 enddo ! k c c c Backsolve for proj, storing it at the beginning of a. c if(krank .gt. 0 .and. ss .gt. 0) then call idd_lssolve(m,n,a,krank) endif c if(ss .eq. 0) then c do k = 1,n do j = 1,m c a(j,k) = 0 c enddo ! j enddo ! k c endif c c return end c c c c subroutine idd_reconid(m,krank,col,n,list,proj,approx) c c reconstructs the matrix that the routine iddp_id c or iddr_id has decomposed, using the columns col c of the reconstructed matrix whose indices are listed in list, c in addition to the interpolation matrix proj. c c input: c m -- first dimension of cols and approx c krank -- first dimension of cols and proj; also, c n-krank is the second dimension of proj c col -- columns of the matrix to be reconstructed c n -- second dimension of approx; also, c n-krank is the second dimension of proj c list(k) -- index of col(1:m,k) in the reconstructed matrix c when k <= krank; in general, list describes c the permutation required for reconstruction c via cols and proj c proj -- interpolation matrix c c output: c approx -- reconstructed matrix c implicit none integer m,n,krank,j,k,l,list(n) real*8 col(m,krank),proj(krank,n-krank),approx(m,n) c c do j = 1,m do k = 1,n c approx(j,list(k)) = 0 c c Add in the contributions due to the identity matrix. c if(k .le. krank) then approx(j,list(k)) = approx(j,list(k)) + col(j,k) endif c c Add in the contributions due to proj. c if(k .gt. krank) then if(krank .gt. 0) then c do l = 1,krank approx(j,list(k)) = approx(j,list(k)) 1 + col(j,l)*proj(l,k-krank) enddo ! l c endif endif c enddo ! k enddo ! j c c return end c c c c subroutine idd_lssolve(m,n,a,krank) c c backsolves for proj satisfying R_11 proj ~ R_12, c where R_11 = a(1:krank,1:krank) c and R_12 = a(1:krank,krank+1:n). c This routine overwrites the beginning of a with proj. c c input: c m -- first dimension of a c n -- second dimension of a; also, c n-krank is the second dimension of proj c a -- trapezoidal input matrix c krank -- first dimension of proj; also, c n-krank is the second dimension of proj c c output: c a -- the first krank*(n-krank) elements of a constitute c the krank x (n-krank) matrix proj c implicit none integer m,n,krank,j,k,l real*8 a(m,n),sum c c c Overwrite a(1:krank,krank+1:n) with proj. c do k = 1,n-krank do j = krank,1,-1 c sum = 0 c do l = j+1,krank sum = sum+a(j,l)*a(l,krank+k) enddo ! l c a(j,krank+k) = a(j,krank+k)-sum c c Make sure that the entry in proj won't be too big; c set the entry to 0 when roundoff would make it too big c (in which case a(j,j) is so small that the contribution c from this entry in proj to the overall matrix approximation c is supposed to be negligible). c if(abs(a(j,krank+k)) .lt. 2**20*abs(a(j,j))) then a(j,krank+k) = a(j,krank+k)/a(j,j) else a(j,krank+k) = 0 endif c enddo ! j enddo ! k c c c Move proj from a(1:krank,krank+1:n) to the beginning of a. c call idd_moverup(m,n,krank,a) c c return end c c c c subroutine idd_moverup(m,n,krank,a) c c moves the krank x (n-krank) matrix in a(1:krank,krank+1:n), c where a is initially dimensioned m x n, to the beginning of a. c (This is not the most natural way to code the move, c but one of my usually well-behaved compilers chokes c on more natural ways.) c c input: c m -- initial first dimension of a c n -- initial second dimension of a c krank -- number of rows to move c a -- m x n matrix whose krank x (n-krank) block c a(1:krank,krank+1:n) is to be moved c c output: c a -- array starting with the moved krank x (n-krank) block c implicit none integer m,n,krank,j,k real*8 a(m*n) c c do k = 1,n-krank do j = 1,krank a(j+krank*(k-1)) = a(j+m*(krank+k-1)) enddo ! j enddo ! k c c return end c c c c subroutine idd_getcols(m,n,matvec,p1,p2,p3,p4,krank,list, 1 col,x) c c collects together the columns of the matrix a indexed by list c into the matrix col, where routine matvec applies a c to an arbitrary vector. c c input: c m -- first dimension of a c n -- second dimension of a c matvec -- routine which applies a to an arbitrary vector; c this routine must have a calling sequence of the form c c matvec(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 matrix is to be applied, c n is the length of y, c y is the product of the matrix 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 krank -- number of columns to be extracted c list -- indices of the columns to be extracted c c output: c col -- columns of a indexed by list c c work: c x -- must be at least n real*8 elements long c implicit none integer m,n,krank,list(krank),j,k real*8 col(m,krank),x(n),p1,p2,p3,p4 external matvec c c do j = 1,krank c do k = 1,n x(k) = 0 enddo ! k c x(list(j)) = 1 c call matvec(n,x,m,col(1,j),p1,p2,p3,p4) c enddo ! j c c return end c c c c subroutine idd_reconint(n,list,krank,proj,p) c c constructs p in the ID a = b p, c where the columns of b are a subset of the columns of a, c and p is the projection coefficient matrix, c given list, krank, and proj output c by routines iddp_id or iddr_id. c c input: c n -- part of the second dimension of proj and p c list -- list of columns retained from the original matrix c in the ID c krank -- rank of the ID c proj -- matrix of projection coefficients in the ID c c output: c p -- projection matrix in the ID c implicit none integer n,krank,list(n),j,k real*8 proj(krank,n-krank),p(krank,n) c c do k = 1,krank do j = 1,n c if(j .le. krank) then if(j .eq. k) p(k,list(j)) = 1 if(j .ne. k) p(k,list(j)) = 0 endif c if(j .gt. krank) then p(k,list(j)) = proj(k,j-krank) endif c enddo ! j enddo ! k c c return end c c c c subroutine idd_copycols(m,n,a,krank,list,col) c c collects together the columns of the matrix a indexed by list c into the matrix col. c c input: c m -- first dimension of a c n -- second dimension of a c a -- matrix whose columns are to be extracted c krank -- number of columns to be extracted c list -- indices of the columns to be extracted c c output: c col -- columns of a indexed by list c implicit none integer m,n,krank,list(krank),j,k real*8 a(m,n),col(m,krank) c c do k = 1,krank do j = 1,m c col(j,k) = a(j,list(k)) c enddo ! j enddo ! k c c return end
bsd-3-clause
Vitancourt/gcc
libgfortran/generated/_sin_c8.F90
47
1477
! 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_COMPLEX_8) #ifdef HAVE_CSIN elemental function _gfortran_specific__sin_c8 (parm) complex (kind=8), intent (in) :: parm complex (kind=8) :: _gfortran_specific__sin_c8 _gfortran_specific__sin_c8 = sin (parm) end function #endif #endif
gpl-2.0
janvc/utility-scripts
progs/source/mctdh_specpara.f90
1
8565
program mctdh_specpara use routines implicit none integer,parameter :: gsfcio = 1 ! IO unit of the file containing the GS frequencies integer,parameter :: esfcio = 2 ! IO unit of the file containing the ES frequencies integer,parameter :: shiftio = 3 ! IO unit of the file containing the shift vector (k) integer,parameter :: duschio = 4 ! IO unit of the file containing the Duschinsky matrix (J) real(dp),parameter :: pi = 3.141592653589793238_dp ! pi real(dp),parameter :: c0 = 299792458.0_dp ! the speed of light real(dp),parameter :: Eh = 4.3597438e-18_dp ! the Hartree energy real(dp),parameter :: a0 = 5.291772083e-11_dp ! the bohr radius !real(dp),parameter :: u = 1.66053873e-27_dp ! the atomic mass unit !real(dp),parameter :: hbar = 1.054571596e-34_dp ! Planck's constant by 2 Pi real(dp),parameter :: me = 9.10938188e-31_dp ! the electron mass !real(dp),parameter :: amu2au = 1822.88848325_dp ! to convert from amu to atomic units integer :: n, m, o ! loop indices integer :: Nmodes ! number of normal modes integer :: stat ! IO status of the read operation integer :: Nspfs ! number of SPFs integer :: spfs_written ! number of modes written so far integer,dimension(2) :: max_indices ! location of the maximum value of the coupling array logical :: line_started character(len=50) :: argument ! the command argument real(dp),dimension(:),allocatable :: v1 ! ground state frequencies real(dp),dimension(:),allocatable :: v2 ! excited state frequencies real(dp),dimension(:),allocatable :: f1 ! ground state force constants real(dp),dimension(:),allocatable :: f2 ! excited state force constants real(dp),dimension(:),allocatable :: k ! shift vector real(dp),dimension(:),allocatable :: fp ! new force constants real(dp),dimension(:),allocatable :: kappa ! first-order coefficients real(dp),dimension(:,:),allocatable :: J ! Duschinsky matrix real(dp),dimension(:,:),allocatable :: phi ! coupling matrix real(dp),dimension(:,:),allocatable :: phi_sort ! sorted coupling matrix (for mode combination) logical,dimension(:),allocatable :: written ! has the mode been written to sbasis? ! the number of modes must be given as the argument: call get_command_argument(1, argument) if (len_trim(argument) == 0) then write(*,*) "ERROR: no argument given" stop endif read(argument,*,iostat=stat) Nmodes if (stat /= 0) then write(*,*) "ERROR reading Nmodes, status:", stat stop endif ! allocate the arrays: allocate(v1(Nmodes)) allocate(v2(Nmodes)) allocate(f1(Nmodes)) allocate(f2(Nmodes)) allocate(k(Nmodes)) allocate(fp(Nmodes)) allocate(kappa(Nmodes)) allocate(written(Nmodes)) allocate(J(Nmodes,Nmodes)) allocate(phi(Nmodes,Nmodes)) ! open the data files: open(unit=gsfcio,file='gs_freqs',status='old',action='read') open(unit=esfcio,file='es_freqs',status='old',action='read') open(unit=shiftio,file='Displacement_Vector.dat',status='old',action='read') open(unit=duschio,file='Duschinsky_Matrix.dat',status='old',action='read') ! read the data: do n = 1, Nmodes read(gsfcio,*) v1(n) enddo do n = 1, Nmodes read(esfcio,*) v2(n) enddo do n = 1, Nmodes read(shiftio,*) k(n) enddo do n = 1, Nmodes do m = 1, Nmodes read(duschio,*) J(m,n) enddo enddo ! calculate the force constants: f1 = v1**2 * 4.0_dp * pi**2 * c0**2 * 10000.0_dp * a0**2 * me / Eh f2 = v2**2 * 4.0_dp * pi**2 * c0**2 * 10000.0_dp * a0**2 * me / Eh ! write the data: write(*,*) "ground state frequencies" call write_vector(v1) write(*,*) "excited state frequencies" call write_vector(v2) write(*,*) "ground state force constants" call write_vector(f1) write(*,*) "excited state force constants" call write_vector(f2) write(*,*) "shift vector" call write_vector(k) write(*,*) "Duschinsky matrix" call write_matrix(J) ! calculate the new force constants: do m = 1, Nmodes fp(m) = 0.0_dp do n = 1, Nmodes fp(m) = fp(m) + f2(n) * J(n,m)**2 enddo enddo ! calculate the first-order coefficients: do m = 1, Nmodes kappa(m) = 0.0_dp do n = 1, Nmodes kappa(m) = kappa(m) + f2(n) * k(n) * J(n,m) enddo enddo ! calculate the couplings: phi = 0.0_dp do m = 1, Nmodes do o = m + 1, Nmodes phi(m,o) = 0.0_dp do n = 1, Nmodes phi(m,o) = phi(m,o) + f2(n) * J(n,m) * J(n,o) enddo enddo enddo ! write the results: write(*,*) "new force constants" call write_vector(fp) write(*,*) "first-order coefficients" call write_vector(kappa) write(*,*) "couplings" call write_matrix(phi) ! ! write MCTDH input/operator ! ! sbasis-section: phi_sort = abs(phi) written = .false. write(*,'("sbasis-section")') Nspfs = Nmodes / 2 do n = 1, Nspfs write(*,'(" ")',advance='no') spfs_written = 0 write_loop: do max_indices = maxloc(phi_sort) phi_sort(max_indices(1), max_indices(2)) = 0.0_dp do m = 1, 2 if (.not. written(max_indices(m))) then write(*,'("q_",i3.3)',advance='no') max_indices(m) spfs_written = spfs_written + 1 written(max_indices(m)) = .true. if (spfs_written < 2) then write(*,'(", ")',advance='no') endif if (spfs_written == 2) then write(*,'(" = 2")') exit write_loop endif endif enddo enddo write_loop enddo line_started = .false. do n = 1, Nmodes if (.not. written(n)) then if (line_started) then write(*,'(", ")',advance='no') else write(*,'(" ")',advance='no') endif write(*,'("q_",i3.3)',advance='no') n line_started = .true. endif enddo if (line_started) then write(*,'(" = 2")') endif write(*,'("end-sbasis-section")') write(*,*) ! pbasis-section: write(*,'("pbasis-section")') do n = 1, Nmodes write(*,'(" q_",i3.3," ho 10 xi-xf", 2f8.1)') & n, -(kappa(n) / fp(n)) - (3.3_dp / fp(n)**0.25_dp), -(kappa(n) / fp(n)) + (3.3_dp / fp(n)**0.25_dp) enddo write(*,'("end-pbasis-section")') write(*,*) ! init_wf-section: write(*,'("init_wf-section")') write(*,'(" build")') do n = 1, Nmodes write(*,'(" q_",i3.3," eigenf Eq_",i3.3," pop = 1")') n, n enddo write(*,'(" end-build")') write(*,'("end-init_wf-section")') ! parameter-section: write(*,'("parameter-section")') do n = 1, Nmodes write(*,'(" mass_q_",i3.3," = 1.0")') n enddo do n = 1, Nmodes write(*,'(" f_",i3.3," = ",d15.8)') n, f1(n) enddo do n = 1, Nmodes write(*,'(" fp_",i3.3," = ",d15.8)') n, fp(n) enddo do n = 1, Nmodes do m = n + 1, Nmodes write(*,'(" phi_",i3.3,"_",i3.3," = ",d15.8)') n, m, phi(n,m) enddo enddo do n = 1, Nmodes write(*,'(" kappa_",i3.3," = ",d15.8)') n, kappa(n) enddo write(*,'("end-parameter-section")') write(*,*) ! hamiltonian-section: write(*,'("hamiltonian-section")') write(*,'("modes")',advance='no') do n = 1, Nmodes write(*,'(" | q_",i3.3)',advance='no') n enddo write(*,*) do n = 1, Nmodes write(*,'("1.0 |",i0," KE")') n enddo do n = 1, Nmodes write(*,'("0.5*fp_",i3.3," |",i0," q^2")') n, n enddo do n = 1, Nmodes do m = n + 1, Nmodes write(*,'("phi_",i3.3,"_",i3.3," |",i0," q |",i0," q")') n, m, n, m enddo enddo do n = 1, Nmodes write(*,'("kappa_",i3.3," |",i0," q")') n, n enddo write(*,'("end-hamiltonian-section")') write(*,*) ! additional hamiltonians for the GS modes: do n = 1, Nmodes write(*,'("hamiltonian-section_Eq_",i3.3)') n write(*,'("usediag")') write(*,'("modes | q_",i3.3)') n write(*,'("1.0 |1 KE")') write(*,'("0.5*f_",i3.3," |1 q^2")') n write(*,'("end-hamiltonian-section")') write(*,*) enddo write(*,*) "###################################################################" ! mode couplings in descending order: phi_sort = abs(phi) do n = 1, (Nmodes * (Nmodes - 1)) / 2 max_indices = maxloc(phi_sort) write(*,*) max_indices(1), max_indices(2), phi(max_indices(1), max_indices(2)) phi_sort(max_indices(1), max_indices(2)) = 0.0_dp enddo end program mctdh_specpara
gpl-3.0
geodynamics/mineos
green.f
1
21549
c c MINEOS version 1.0 by Guy Masters, John Woodhouse, and Freeman Gilbert c c This program is free software; you can redistribute it and/or modify c it under the terms of the GNU General Public License as published by c the Free Software Foundation; either version 2 of the License, or c (at your option) any later version. c c This program is distributed in the hope that it will be useful, c but WITHOUT ANY WARRANTY; without even the implied warranty of c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the c GNU General Public License for more details. c c You should have received a copy of the GNU General Public License c along with this program; if not, write to the Free Software c Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA c c************************************************************************** c c green program computes for a single event and a given set of stations, c the Green functions. c c************************************************************************** program green implicit none include "green.h" include "fdb/fdb_io.h" include "fdb/fdb_site.h" include "fdb/fdb_sitechan.h" include "fdb/fdb_wfdisc.h" c--- real*4 scalrs(8) real*8 co,si,c1,c2,s1,s2,z,zp,cz,sz,caz,saz,prp common/dheadX/d0,th,ph,jy,jd,jh,jm,sec,tstart common/zfXX/z(3,ml),zp(3,ml) common/grnX/grn(12*mseis) common/modeX/om(meig),a0(meig),omt(meig),a0t(meig) common/vecnlX/vecnl(8,meig),vecnlt(4,meig) common/wts/wt(6,meig) common/sclrX/n,l,e1,e2,e3,e4,au,av common/propX/prp(6*mseis) c--- local variables --- integer*4 lnblnk,numchan(msitechan),numsta(msite) real*8 time,endtime,htoepoch real*4 d0,th,ph,sec,tstart,ss,dt,slat,slon,sdep, * sss, grn, om, a0, omt, a0t, vecnl, vecnlt, * wt,e1,e2,e3,e4,au,av,pi,rad,fmin,fmax, * t0,p0,c0,s0,t1,p1,dp,del,azim integer*4 i,lmax,nmodes,nmodet,j,lp1,indx, * jy,jd,jh,jm,nscan,iy,id,ih,im,jys,jds,jhs,jms, * n,l,len,mchn,icomp,itype1,iscan,ifl,isq,ii integer*4 nchan,inchn,iseq,jdate,ierr,nc(100),ns(100) real*4 ang(3) character*8 ename character*256 efname c--- equivalence and data --- equivalence (n,scalrs) data pi,rad,tstart/3.14159265359,57.29578,0./ data icomp,itype1/0,1/ c c read input parameters c c....read in dbname with static relations: sta, stachan write(*,*) '============= Program green ====================' write(*,*) 'enter path to db with sta & stachan:' read(*,'(a256)') dbin write(*,*) dbin(1:lnblnk(dbin)) c....read in name of file containing list of dbnames. c....each dbname in list refferes ito db with .eigen relation. write(*,*) 'enter name of file within list of nmodes db:' read(*,'(a256)') fname3 write(*,*) fname3(1:lnblnk(fname3)) c....read in file within event and moment tensor info write(*,*) 'enter input CMT file name:' read(*,'(a256)') fname4 write(*,*) fname4(1:lnblnk(fname4)) c....read in frequency range in mHz write(*,*) 'min and max frequencies to be considered (mHz) : ' read(*,*) fmin,fmax write(*,*) fmin,fmax c....read in number of samples in Green function write(*,*) 'enter # pts in greens fns .le. ',mseis,' :' read(*,*) iscan write(*,*) iscan c.... read in output path to gsf name to store Green functions write(*,*) 'enter Green functions output db file name:' read(*,'(a256)') dbout write(*,*) dbout(1:lnblnk(dbout)) write(*,*) '====================================================' c c.....open event file for which you want to compute green's functions c.....read first line to get source and moment tensor info c open(12,file=fname4,status='old') read(12,*) ename,jys,jds,jhs,jms,sss,slat,slon,sdep,dt close (12) write(*,1001) ename,jys,jds,jhs,jms,sss,slat,slon write(*,1002) sdep 1001 format(' green: Event: ',a8,2x,i4,1x,i3,1x,i2,':',i2,':',f6.3,1x, * 'lat = ',f8.3,', lon = ',f9.3) 1002 format(' green: source depth =',f5.1,' km') write(*,1003) dt,iscan 1003 format(' green: step = ',f8.3,' sec, nsamples =',i7) c convert human time to epoch time time = htoepoch (jys,jds,jhs,jms,dble(sss)) endtime = time+dt*(iscan-1) jdate = jys*1000+jds c-- d0=sdep cxx th=90.-slat c.....convert event geographic latitude to geocentric th = 90.0-atan(0.99329534*tan(slat/rad))*rad ph=slon jy=jys jd=jds jh=jhs jm=jms sec=sss c c.....open output file for green's functions c fmin = fmin*pi/500. fmax = fmax*pi/500. call source(fmin,fmax,lmax,nmodes,nmodet) if(lmax.le.ml) goto 5 write(*,*) 'ERR010: green: max l =',lmax,' must be .le.',ml stop ' ' cxx goto 99 5 iscan = iscan/2 call factor(iscan) iscan = 2*iscan if(iscan.gt.mseis) then write(*,*) 'WARNING: green: # of points in Green ', * 'functions is stripped to ',mseis endif iscan=min0(iscan,mseis) t0=th/rad p0=ph/rad c0=cos(t0) s0=sin(t0) c c====loop over records c........read event header c c.....open file with station & channel info --- write(*,*) 'green: Input dbname : ',dbin(1:lnblnk(dbin)) call read_site call read_sitechan c.....select channel sequence --- call select_sitechan(jdate,nchan,numchan,numsta) open(12,file=fname4,status='old') inchn = 1 ifl = 0 c.....choose new single or triple of station(s) 6 iseq = 1 cxx do ii = 1,12*iscan grn(ii) = 0.0 enddo cxx if(ifl.ge.30) goto 88 66 if(inchn.gt.nchan) goto 88 nc(iseq) = iabs(numchan(inchn)) ns(iseq) = numsta(inchn) inchn = inchn+1 iseq = iseq+1 if(numchan(inchn-1).le.0) goto 7 goto 66 7 iseq = iseq-1 c.....print station and channel info --- write(*,1004) sta_site(ns(1)),lat_site(ns(1)), * lon_site(ns(1)),iseq 1004 format(' green: Station: ',a6,1x,f9.4,f10.4,' , Channels: ',i1) do i = 1,iseq write(*,*) 'green: Channel: # ',i,' ',sta_sitechan(nc(i)), * chan_sitechan(nc(i)),hang_sitechan(nc(i)), * vang_sitechan(nc(i)) enddo c....check channels sequence: Z,N,E --- if(iseq.gt.3) then write(*,*) 'WARNING: green: # of channels is stripped to 3' iseq = 3 endif if(iseq.eq.2) then write(*,*) 'WARNING: green: # of channels is stripped to 1' iseq = 1 endif ang(1) = (vang_sitechan(nc(1))-90.0)/rad if(abs(vang_sitechan(nc(1))).gt.0.5) then write(*,*) * 'WARNING: green: Channel: # ',1,' is not vertical. ', * 'Sequence ignored' goto 6 endif do i = 2,iseq ang(i) = hang_sitechan(nc(i))/rad if(abs(vang_sitechan(nc(i))-90.0).gt.0.5) then write(*,*) * 'WARNING: green: Channel: # ',i,' is not horizontal. ', * 'Sequence ignored' goto 6 endif enddo c c compute green functions for selected channels c icomp = 0 do 90 isq=1,iseq c.....extract channel parameters from relation tables ifl = ifl+1 mchn = isq iy = jy id = jd ih = jh im = jm ss = sec cxx t1 = (90.0-lat_site(ns(1)))/rad c.....convert station geographic latitude to geocentric t1 = (90.0-atan(0.99329534*tan(lat_site(ns(1))/rad))*rad)/rad p1 = lon_site(ns(1)) if(p1.lt.0.0) p1 = 360.0+p1 p1 = p1/rad if(icomp.eq.2) goto 500 len=0 if(icomp.eq.1) goto 35 c c....do some trigonometry c epicentral distance: co, si c azimuth of source: caz,saz c c1=cos(t1) s1=sin(t1) dp=p1-p0 co=c0*c1+s0*s1*cos(dp) si=dsqrt(1.d0-co*co) del = datan2(si,co) del = del/pi*180. write(*,'(a,f10.3)')' green: Epicentral Distance : ',del sz=s1*sin(dp)/si cz=(c0*co-c1)/(s0*si) saz=-s0*sin(dp)/si caz=(c0-co*c1)/(si*s1) azim = datan2(saz,caz) azim = azim/pi*180. write(*,'(a,f10.3)')' green: Azimuth of Source : ',azim c2=2.d0*(cz**2-sz**2) s2=8.d0*cz*sz c1=2.d0*cz s1=2.d0*sz c c....generate the spherical harmonics c call zfcns(lmax,co,si) if(mchn.ne.1) goto 35 c*** vertical component *** icomp=1 do 25 i=1,nmodes do 30 j=1,8 30 scalrs(j) = vecnl(j,i) lp1=l+1 c c....initial amplitudes at time t=0 c wt(1,i)=e1*z(1,lp1)*au wt(2,i)=e2*z(1,lp1)*au wt(3,i)=e3*z(2,lp1)*au wt(4,i)=e4*z(3,lp1)*au 25 continue call prop(om,a0,dt,tstart,nmodes,len,iscan,4,prp) call s4t6(grn,iscan,c1,s1,c2,s2) goto 500 c*** theta and phi components *** c*** spheroidal modes *** 35 icomp=2 do 40 i=1,nmodes do 45 j=1,8 45 scalrs(j)=vecnl(j,i) lp1=l+1 c c....initial amplitudes at time t=0 c wt(1,i)=e1*zp(1,lp1)*av wt(2,i)=e2*zp(1,lp1)*av wt(3,i)=e3*zp(2,lp1)*av wt(4,i)=e4*zp(3,lp1)*av wt(5,i)=e3*z(2,lp1)*av/si 40 wt(6,i)=e4*z(3,lp1)*av/si call prop(om,a0,dt,tstart,nmodes,len,iscan,6,prp) len=6*iscan c c*** toroidal modes *** c if(nmodet.eq.0) goto 61 do 60 i=1,nmodet do 65 j=1,4 65 scalrs(j)=vecnlt(j,i) lp1=l+1 c c....initial amplitudes at time t=0 c wt(1,i)=e1*z(2,lp1)/si wt(2,i)=e2*z(3,lp1)/si wt(3,i)=e1*zp(2,lp1) 60 wt(4,i)=e2*zp(3,lp1) call prop(omt,a0t,dt,tstart,nmodet,len,iscan,4,prp) 61 continue call s10t12(grn,iscan,c1,s1,c2,s2) call rotate(grn,iscan,caz,saz,ang(2),ang(3)) c c....greens function longer than data ? : add flags to data ! c cxx 500 nscan=iscan 500 indx=0 if(mchn.eq.3) indx=6*iscan len=6*iscan c c....write out green's functions c nscan = 6 * iscan write(*,1000) ifl,sta_sitechan(nc(1)),chan_sitechan(nc(isq)), * jys,jds,jhs,jms,sss,dt,nscan 1000 format(' green: ',i4,1x,a6,1x,a8,i4,1x,i3,1x,i2,':',i2,':', * f6.3,1x,f8.3,1x,i6) c write wfdisc relation with green functions call default_wfdisc(1) nrowwfdisc = 1 sta_wfdisc(1) = sta_sitechan(nc(1)) chan_wfdisc(1) = chan_sitechan(nc(isq)) chanid_wfdisc(1) = nc(isq) time_wfdisc(1) = time wfid_wfdisc(1) = ifl jdate_wfdisc(1) = jdate endtime_wfdisc(1) = time+(nscan-1)/dt nsamp_wfdisc(1) = nscan calib_wfdisc(1) = 1.0 calper_wfdisc(1) = 20.0 samprate_wfdisc(1) = 1.0/dt segtype_wfdisc(1) = 'g' foff_wfdisc(1) = 0 dir_wfdisc(1) = '.' write(efname,'("g.",i5)') ifl do i = 1,7 if(efname(i:i).eq.' ') efname(i:i) = '0' enddo dfile_wfdisc(1) = efname do i = 1,nscan grn(indx+i) = -grn(indx+i) enddo call put_wfdisc(1,nscan,grn(indx+1),ierr) call write_wfdisc 90 continue goto 6 88 continue close(12) 99 continue end subroutine prop(om,a0,dt,tst,nmodes,len,npts,nfun,prp) include "green.h" real*8 ddt,dts,dt0,dt1,prp(nfun,npts),phi,ain real*8 b0,b1,c0,c1,c2 common/propc/ddt,dts,dt0,dt1,phi,ain,b0,b1,c0,c1,c2 common/grnX/grn(12*mseis) common/wts/wt(6,meig) dimension om(*),a0(*) c c....stores green's function in multiplexed form c ddt = dt dts = tst dt0 = dts - 2*ddt dt1 = dts - ddt do 10 j=1,npts do 10 i=1,nfun 10 prp(i,j) = 0.d0 c c====loop over modes c do 50 j=1,nmodes c c....initialize propagator c b0 = -exp(-2*a0(j)*ddt) b1 = 2*cos(om(j)*ddt) * exp( -a0(j)*ddt) c0 = cos(om(j)*dt0) * exp( -a0(j)*dt0) c1 = cos(om(j)*dt1) * exp( -a0(j)*dt1) c c====loop over time points c do 40 i=1,npts c2 = b1*c1 + b0*c0 do 30 n=1,nfun 30 prp(n,i) = prp(n,i) + wt(n,j)*c2 c0 = c1 c1 = c2 40 continue 50 continue c c....demultiplex green's function c k=len do 60 i=1,npts k = k+1 do 60 n=1,nfun grn((n-1)*npts+k) = prp(n,i) 60 continue return end c*************************************************************** c source sub reads eigen functions from flat databases. c List of dbnames are defined in dbnames.dat file. source read c .eigen relations and select eigen functions for S & T modes c**************************************************************** subroutine source(fmin,fmax,lmax,nmodes,nmodet) implicit none include "green.h" include "fdb/fdb_eigen.h" integer*4 lmax,nmodes,nmodet real*4 fmin,fmax c --- common blocks ------------------------------- real*4 d0,t0,p0,sec,tstart integer*4 jy,jd,jh,jm common/dheadX/d0,t0,p0,jy,jd,jh,jm,sec,tstart real*4 x1,r0,x2,f common/sclXXX/x1,r0,x2,f(4,3) real*4 vecnl,vecnlt common/vecnlX/vecnl(8,meig),vecnlt(4,meig) real*4 om,a0,omt,a0t common/modeX/om(meig),a0(meig),omt(meig),a0t(meig) c --- other variables real* 4 w,q,p,rn,wn,accn real*4 pi2,fot,vn,rs,fl,fl1,fl3,u,v real*4 wsq,e14,au,av,wr,aw integer*4 npts,nrecl,ieig,idat,ierr,ifl,i,is,j,js integer*4 ll,lll,m,l,n,ik character*2 tendia,endian c --- character*64 dir character*256 dbname real*4 fnl(2),r(mk),buf(6,mk) c --- equivalence (fnl(1),n),(fnl(2),l) data fot/1.33333333333/ pi2 = datan(1.0d0)*8.0d0 nmodes = 0 nmodet = 0 lmax=0 ieig = 9 idat = 10 c=================================================================== c Main loop by dbase names c=================================================================== open(7,file=fname3,status='old') c*** read dbnames list 8 read(7,'(a256)',end=9) dbname nrecl = 2000 call open_eigen(dbname,ieig,idat,nrecl,dir,'r',ierr) call read_eigen(ieig,ierr) nrecl = (ncol_eigen*nraw_eigen+npar_eigen)*4 npts = nraw_eigen call close_eigen(ieig,idat) c c....read in spheroidal and toroidal modes c....in frequency band fmin < f < fmax c ifl = 0 call open_eigen(dbname,ieig,idat,nrecl,dir,'r',ierr) 10 ifl = ifl+1 call read_eigen(ieig,ierr) if(ierr.ne.0) goto 30 if(ifl.ne.eigid_eigen) stop * 'ERR011:eigen: flat and bin indices are different.' w = pi2/per_eigen if (w.lt.fmin) goto 10 if (w.le.fmax) goto 11 goto 10 11 read(idat,rec=eigid_eigen) n,l,w,q,rn,vn,accn, + (r(lll),(buf(ll,lll),ll=1,ncol_eigen-1),lll=1,nraw_eigen) if(ncol_eigen.eq.3) then do ik = 1,nraw_eigen buf(3,ik) = 0.0 buf(4,ik) =0.0 enddo endif c swap bytes if necessary tendia = endian() if(datatype_eigen.ne.tendia) then call swap1(fnl,4,2) call swap1(w,4,1) call swap1(q,4,1) call swap1(rn,4,1) call swap1(vn,4,1) call swap1(accn,4,1) call swap1(r,4,mk) call swap1(buf,4,6*mk) endif npts = nraw_eigen wn = vn/rn c c find radius interpolation points c rs=rn/1000. r0=1.-(d0/rs) do 5 i=1,npts if(r(i).lt.r0)is=i 5 continue x1=r(is) js=is+1 x2=r(js) if (typeo_eigen.eq.'S') then C c get source scalars for S mode c nmodes=nmodes+1 if(nmodes.ge.meig) then write(*,*) 'ERR012: green: # sph. modes in band exceed ', * 'max allowed number ',meig stop ' ' endif om(nmodes)=w a0(nmodes)=q lmax = max0(l,lmax) fl=float(l) fl1=fl+1. fl3=fl*fl1 m=-1 do i=is,js m=m+2 do j=1,4 f(j,m)=buf(j,i) enddo enddo call cubic(2) u=f(1,2)/r0 v=f(3,2)/r0 wsq=(w/wn)**2 e14=f(4,2)+u-v if(l.eq.0) e14=0. p = buf(5,npts) au=-((wsq+2.*fot)*buf(1,npts)+fl1*p)*accn av=-(wsq*buf(3,npts)-buf(1,npts)*fot-p)*accn if(l.eq.0) av=0. vecnl(1,nmodes)=fnl(1) vecnl(2,nmodes)=fnl(2) vecnl(3,nmodes)=f(2,2) vecnl(4,nmodes)=u-.5*fl3*v vecnl(5,nmodes)=e14 vecnl(6,nmodes)=2*v vecnl(7,nmodes)=au vecnl(8,nmodes)=av c print 800,n,l,(vecnl(i,nmodes),i=3,8) 800 format(2i4,6e15.7) else if (typeo_eigen.eq.'T') then c c get source scalars for T mode c nmodet=nmodet+1 if(nmodet.ge.meig) then write(*,*) 'ERR012: green: # tor. modes in band exceed ', * 'max allowed number ',meig stop ' ' endif omt(nmodet)=w a0t(nmodet)=q lmax = max0(l,lmax) m=-1 do i=is,js m=m+2 do j=1,2 f(j,m)=buf(j,i) enddo enddo call cubic(1) wr=f(1,2)/r0 wsq=(w/wn)**2 aw=-buf(1,npts)*wsq*accn vecnlt(1,nmodet)=fnl(1) vecnlt(2,nmodet)=fnl(2) vecnlt(3,nmodet)=aw*(wr-f(2,2)) vecnlt(4,nmodet)=-4.*aw*wr c print 801,n,l,(vecnlt(i,nmodet),i=3,4) 801 format(2i4,6e15.7) c 665 continue endif goto 10 30 goto 8 9 close(7) write(*,*) 'green: # sph. modes in band =',nmodes, * ' must be .le. ',meig write(*,*) 'green: # tor. modes in band =',nmodet, * ' must be .le. ',meig return end subroutine s4t6(grn,nscan,c1,s1,c2,s2) implicit real*8(a-h,o-z) real*4 grn(nscan,*) do 1 i=1,nscan f2=grn(i,2) f5=grn(i,3) f6=grn(i,4) grn(i,2)=f2+f6*c2 grn(i,3)=f2-f6*c2 grn(i,4)=f5*c1 grn(i,5)=f5*s1 1 grn(i,6)=f6*s2 return end subroutine s10t12(grn,nscan,c1,s1,c2,s2) implicit real*8(a-h,o-z) real*4 grn(nscan,*) s3=s2/4.d0 do 1 i=1,nscan f11=grn(i,5)-grn(i,9) f12=4.d0*grn(i,6)-grn(i,10) grn(i,9)=f12*s3 grn(i,10)=-f11*s1 grn(i,11)=f11*c1 grn(i,12)=f12*c2 f2=grn(i,2) f5=grn(i,3)-grn(i,7) f6=grn(i,4)-grn(i,8) grn(i,2)=f2+f6*c2 grn(i,3)=f2-f6*c2 grn(i,4)=f5*c1 grn(i,5)=f5*s1 grn(i,6)=f6*s2 grn(i,7)=0.d0 1 grn(i,8)=-f12*s3 return end subroutine rotate(grn,nscan,cz,sz,az1,az2) implicit real*8(a-h,o-z) real*4 grn(*),az1,az2 data pi/3.14159265358979d0/ pi2=0.5d0*pi len=6*nscan if(az1.eq.0.0.and.abs(az2-pi2).lt.1.d-4) then cxx write(*,*)'Standard position.' do i=1,len j=len+i d1=-grn(i)*cz-grn(j)*sz d2=-grn(i)*sz+grn(j)*cz grn(i)=d1 grn(j)=d2 enddo else fdel=cos(az2-az1-pi2) sb=sin(az2-pi2)/fdel cb=cos(az2-pi2)/fdel sa=sin(az1)/fdel ca=cos(az1)/fdel do i=1,len j=len+i d1=-grn(i)*cz-grn(j)*sz d2=-grn(i)*sz+grn(j)*cz grn(i)=d1*cb+d2*sb grn(j)=-d1*sa+d2*ca enddo end if return end subroutine cubic(itype) real*8 a1,a2,c0,c1,c2,c3,x,y,y2,y3 common/sclXXX/x1,r0,x2,f(4,3) common/cubXXX/y,y2,y3,x,a1,a2 data isw/1/ if(isw.ne.1) goto 10 isw=0 y=x2-x1 y2=y**2 y3=y*y2 x=r0-x1 a1=3./y2 a2=2./y3 10 continue do 20 i=1,itype k=2*i j=k-1 c0=f(j,1) c1=f(k,1) c3=f(j,3)-c0 c2=a1*c3-(2.*c1+f(k,3))/y c3=(c1+f(k,3))/y2-a2*c3 f(j,2)=c0+x*(c1+x*(c2+x*c3)) 20 f(k,2)=c1+x*(2.*c2+3.*x*c3) return end subroutine zfcns(lmax,c,s) c zfcns computes z(m,l,theta) and dz(m,l,theta)/dtheta, c denoted z and p resp. all functions for 0 le m le c max(2,l) and 0 le l le lmax are computed. c is cos(theta) c and s is sin(theta). c Z(m,l,theta) = b(m,l) * X(m,l,theta) where c b(m,l) is given in G&D (1975) equation (21) c and X(m,l,theta) is given in G&D (1975) equation (2) c G&D = Gilbert & Dziewonski implicit real*8(a-h,o-z) include "green.h" common/zfXX/z(3,ml),p(3,ml) data pi/3.14159265358979d0/ z(1,1)=1d0/(4.d0*pi) z(2,1)=0.d0 z(3,1)=0.d0 z(1,2)=3d0*c*z(1,1) z(2,2)=1.5d0*s*z(1,1) z(3,2)=0.d0 z(1,3)=2.5d0*(c*z(1,2)-z(1,1)) z(2,3)=5.d0*c*z(2,2) z(3,3)=1.25d0*s*z(2,2) p(1,1)=0.d0 p(2,1)=0.d0 p(3,1)=0.d0 p(1,2)=-2.d0*z(2,2) p(2,2)=0.5d0*z(1,2) p(3,2)=0.d0 p(1,3)=-2.d0*z(2,3) p(2,3)=1.5d0*z(1,3)-2.d0*z(3,3) p(3,3)=0.5d0*z(2,3) if(lmax.le.2) return lmaxp1=lmax+1 tlp1=5d0 do 10 lp1=4,lmaxp1 l=lp1-1 lm1=l-1 elmm=l elpmm1=lm1 tlp1=tlp1+2d0 tlm3=tlp1-4d0 do 10 mp1=1,3 r=tlp1/elmm q=elpmm1/tlm3 z(mp1,lp1)=r*(c*z(mp1,l)-q*z(mp1,lm1)) p(mp1,lp1)=r*(c*p(mp1,l)-s*z(mp1,l)-q*p(mp1,lm1)) elmm=elmm-1d0 10 elpmm1=elpmm1+1d0 return end
gpl-2.0
ma55acre/ExocortexCrate
Shared/hdf5-1.8.9/hl/fortran/src/H5IMff.f90
15
25639
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! Copyright by The HDF Group. * ! Copyright by the Board of Trustees of the University of Illinois. * ! All rights reserved. * ! * ! This file is part of HDF5. The full HDF5 copyright notice, including * ! terms governing use, modification, and redistribution, is contained in * ! the files COPYING and Copyright.html. COPYING can be found at the root * ! of the source code distribution tree; Copyright.html can be found at the * ! root level of an installed copy of the electronic HDF5 document set and * ! is linked from the top-level documents page. It can also be found at * ! http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * ! access to either file, you may request a copy from help@hdfgroup.org. * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! ! ! This file contains FORTRAN90 interfaces for H5IM functions ! module h5im use h5fortran_types use hdf5 contains !------------------------------------------------------------------------- ! Function: h5immake_image_8bit_f ! ! Purpose: Creates and writes an image an 8 bit image ! ! Return: Success: 0, Failure: -1 ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 05, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- subroutine h5immake_image_8bit_f(loc_id,& dset_name,& width,& height,& buf,& errcode ) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5immake_image_8bit_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer(hsize_t), intent(in) :: width ! width of image integer(hsize_t), intent(in) :: height ! height of image integer, intent(in), dimension(*) :: buf ! buffer integer :: errcode ! error code integer :: namelen ! name length interface integer function h5immake_image_8bit_c(loc_id,namelen,dset_name,width,height,buf) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMMAKE_IMAGE_8BIT_C'::h5immake_image_8bit_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name integer(hid_t), intent(in) :: loc_id ! file or group identifier integer :: namelen ! lenght of name buffer character(len=*), intent(in) :: dset_name ! name of the dataset integer(hsize_t), intent(in) :: width ! width of image integer(hsize_t), intent(in) :: height ! height of image integer , intent(in), dimension(*) :: buf ! buffer end function h5immake_image_8bit_c end interface namelen = len(dset_name) errcode = h5immake_image_8bit_c(loc_id,namelen,dset_name,width,height,buf) end subroutine h5immake_image_8bit_f !------------------------------------------------------------------------- ! Function: h5imread_image_f ! ! Purpose: Reads image data from disk. ! ! Return: Success: 0, Failure: -1 ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 05, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- subroutine h5imread_image_f(loc_id,& dset_name,& buf,& errcode ) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5imread_image_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer, intent(inout), dimension(*) :: buf ! buffer integer :: errcode ! error code integer :: namelen ! name length interface integer function h5imread_image_c(loc_id,namelen,dset_name,buf) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMREAD_IMAGE_C'::h5imread_image_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name integer(hid_t), intent(in) :: loc_id ! file or group identifier integer :: namelen ! lenght of name buffer character(len=*), intent(in) :: dset_name ! name of the dataset integer, intent(inout), dimension(*) :: buf ! buffer end function h5imread_image_c end interface namelen = len(dset_name) errcode = h5imread_image_c(loc_id,namelen,dset_name,buf) end subroutine h5imread_image_f !------------------------------------------------------------------------- ! Function: h5immake_image_24bit_f ! ! Purpose: Creates and writes an image a 24 bit image ! ! Return: Success: 0, Failure: -1 ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 05, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- subroutine h5immake_image_24bit_f(loc_id,& dset_name,& width,& height,& il,& buf,& errcode ) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5immake_image_24bit_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer(hsize_t), intent(in) :: width ! width of image integer(hsize_t), intent(in) :: height ! height of image character(len=*), intent(in) :: il ! interlace integer, intent(in), dimension(*) :: buf ! buffer integer :: errcode ! error code integer :: namelen ! name length integer :: ilen ! name length interface integer function h5immake_image_24bit_c(loc_id,namelen,dset_name,ilen,il,width,height,buf) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMMAKE_IMAGE_24BIT_C'::h5immake_image_24bit_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name !DEC$ATTRIBUTES reference :: il integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer(hsize_t), intent(in) :: width ! width of image integer(hsize_t), intent(in) :: height ! height of image character(len=*), intent(in) :: il ! interlace integer, intent(in), dimension(*) :: buf ! buffer integer :: namelen ! lenght of name buffer integer :: ilen ! name length end function h5immake_image_24bit_c end interface namelen = len(dset_name) ilen = len(il) errcode = h5immake_image_24bit_c(loc_id,namelen,dset_name,ilen,il,width,height,buf) end subroutine h5immake_image_24bit_f !------------------------------------------------------------------------- ! Function: h5imget_image_info_f ! ! Purpose: Gets information about an image dataset (dimensions, interlace mode ! and number of associated palettes). ! ! Return: Success: 0, Failure: -1 ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 05, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- subroutine h5imget_image_info_f(loc_id,& dset_name,& width,& height,& planes,& interlace,& npals,& errcode ) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5imget_image_info_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer(hsize_t), intent(inout) :: width ! width of image integer(hsize_t), intent(inout) :: height ! height of image integer(hsize_t), intent(inout) :: planes ! color planes integer(hsize_t), intent(inout) :: npals ! palettes character(len=*), intent(inout) :: interlace ! interlace integer :: errcode ! error code integer :: namelen ! name length integer :: ilen ! name length interface integer function h5imget_image_info_c(loc_id,namelen,dset_name,width,height,planes,npals,ilen,interlace) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMGET_IMAGE_INFO_C'::h5imget_image_info_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name !DEC$ATTRIBUTES reference :: interlace integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer(hsize_t), intent(inout) :: width ! width of image integer(hsize_t), intent(inout) :: height ! height of image integer(hsize_t), intent(inout) :: planes ! color planes integer(hsize_t), intent(inout) :: npals ! palettes character(len=*), intent(inout) :: interlace ! interlace integer :: namelen ! name length integer :: ilen ! name length end function h5imget_image_info_c end interface namelen = len(dset_name) ilen = len(interlace) errcode = h5imget_image_info_c(loc_id,namelen,dset_name,width,height,planes,npals,ilen,interlace) end subroutine h5imget_image_info_f !------------------------------------------------------------------------- ! Function: h5imis_image_f ! ! Purpose: Inquires if a dataset is an image ! ! Return: Success: 0, Failure: -1 ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 05, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- integer function h5imis_image_f(loc_id,& dset_name) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5imis_image_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer :: errcode ! error code integer :: namelen ! name length interface integer function h5imis_image_c(loc_id,namelen,dset_name) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMIS_IMAGE_C'::h5imis_image_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name integer(hid_t), intent(in) :: loc_id ! file or group identifier integer :: namelen ! lenght of name buffer character(len=*), intent(in) :: dset_name ! name of the dataset end function h5imis_image_c end interface namelen = len(dset_name) errcode = h5imis_image_c(loc_id,namelen,dset_name) h5imis_image_f = errcode end function h5imis_image_f !------------------------------------------------------------------------- ! Function: h5immake_palette_f ! ! Purpose: Creates and writes a palette ! ! Return: Success: 0, Failure: -1 ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 06, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- subroutine h5immake_palette_f(loc_id,& dset_name,& pal_dims,& buf,& errcode ) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5immake_palette_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer(hsize_t), intent(in), dimension(*) :: pal_dims ! dimensions integer, intent(in), dimension(*) :: buf ! buffer integer :: errcode ! error code integer :: namelen ! name length interface integer function h5immake_palette_c(loc_id,namelen,dset_name,pal_dims,buf) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMMAKE_PALETTE_C'::h5immake_palette_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name integer(hid_t), intent(in) :: loc_id ! file or group identifier integer :: namelen ! lenght of name buffer character(len=*), intent(in) :: dset_name ! name of the dataset integer(hsize_t), intent(in), dimension(*) :: pal_dims ! dimensions integer, intent(in), dimension(*) :: buf ! buffer end function h5immake_palette_c end interface namelen = len(dset_name) errcode = h5immake_palette_c(loc_id,namelen,dset_name,pal_dims,buf) end subroutine h5immake_palette_f !------------------------------------------------------------------------- ! Function: h5imlink_palette_f ! ! Purpose: This function attaches a palette to an existing image dataset ! ! Return: Success: 0, Failure: -1 ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 06, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- subroutine h5imlink_palette_f(loc_id,& dset_name,& pal_name,& errcode ) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5imlink_palette_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset character(len=*), intent(in) :: pal_name ! palette name integer :: errcode ! error code integer :: namelen ! name length integer :: ilen ! name length interface integer function h5imlink_palette_c(loc_id,namelen,dset_name,ilen,pal_name) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMLINK_PALETTE_C'::h5imlink_palette_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name !DEC$ATTRIBUTES reference :: pal_name integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset character(len=*), intent(in) :: pal_name ! palette name integer :: namelen ! name length integer :: ilen ! name length end function h5imlink_palette_c end interface namelen = len(dset_name) ilen = len(pal_name) errcode = h5imlink_palette_c(loc_id,namelen,dset_name,ilen,pal_name) end subroutine h5imlink_palette_f !------------------------------------------------------------------------- ! Function: h5imunlink_palette_f ! ! Purpose: This function dettaches a palette to an existing image dataset ! ! Return: Success: 0, Failure: -1 ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 06, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- subroutine h5imunlink_palette_f(loc_id,& dset_name,& pal_name,& errcode ) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5imunlink_palette_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset character(len=*), intent(in) :: pal_name ! palette name integer :: errcode ! error code integer :: namelen ! name length integer :: ilen ! name length interface integer function h5imunlink_palette_c(loc_id,namelen,dset_name,ilen,pal_name) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMUNLINK_PALETTE_C'::h5imunlink_palette_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name !DEC$ATTRIBUTES reference :: pal_name integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset character(len=*), intent(in) :: pal_name ! palette name integer :: namelen ! name length integer :: ilen ! name length end function h5imunlink_palette_c end interface namelen = len(dset_name) ilen = len(pal_name) errcode = h5imunlink_palette_c(loc_id,namelen,dset_name,ilen,pal_name) end subroutine h5imunlink_palette_f !------------------------------------------------------------------------- ! Function: h5imget_npalettes_f ! ! Purpose: Gets the number of palettes associated to an image ! ! Return: Success: 0, Failure: -1 ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 05, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- subroutine h5imget_npalettes_f(loc_id,& dset_name,& npals,& errcode ) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5imget_npalettes_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer(hsize_t), intent(inout) :: npals ! palettes integer :: errcode ! error code integer :: namelen ! name length interface integer function h5imget_npalettes_c(loc_id,namelen,dset_name,npals) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMGET_NPALETTES_C'::h5imget_npalettes_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer(hsize_t), intent(inout) :: npals ! palettes integer :: namelen ! name length end function h5imget_npalettes_c end interface namelen = len(dset_name) errcode = h5imget_npalettes_c(loc_id,namelen,dset_name,npals) end subroutine h5imget_npalettes_f !------------------------------------------------------------------------- ! Function: h5imget_palette_info_f ! ! Purpose: Get palette information ! ! Return: Success: 0, Failure: -1 ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 06, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- subroutine h5imget_palette_info_f(loc_id,& dset_name,& pal_number,& dims,& errcode ) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5imget_palette_info_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer, intent(in) :: pal_number ! palette number integer(hsize_t), dimension(*), intent(inout) :: dims ! dimensions integer :: errcode ! error code integer :: namelen ! name length interface integer function h5imget_palette_info_c(loc_id,namelen,dset_name,pal_number,dims) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMGET_PALETTE_INFO_C'::h5imget_palette_info_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer, intent(in) :: pal_number ! palette number integer(hsize_t), dimension(*), intent(inout) :: dims ! dimensions integer :: namelen ! name length end function h5imget_palette_info_c end interface namelen = len(dset_name) errcode = h5imget_palette_info_c(loc_id,namelen,dset_name,pal_number,dims) end subroutine h5imget_palette_info_f !------------------------------------------------------------------------- ! Function: h5imget_palette_f ! ! Purpose: Reads palette ! ! Return: Success: 0, Failure: -1 ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 06, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- subroutine h5imget_palette_f(loc_id,& dset_name,& pal_number,& buf,& errcode ) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5imget_palette_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer, intent(in) :: pal_number ! palette number integer, intent(inout), dimension(*) :: buf ! buffer integer :: errcode ! error code integer :: namelen ! name length interface integer function h5imget_palette_c(loc_id,namelen,dset_name,pal_number,buf) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMGET_PALETTE_C'::h5imget_palette_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name integer(hid_t), intent(in) :: loc_id ! file or group identifier integer :: namelen ! lenght of name buffer character(len=*), intent(in) :: dset_name ! name of the dataset integer, intent(in) :: pal_number ! palette number integer, intent(inout), dimension(*) :: buf ! buffer end function h5imget_palette_c end interface namelen = len(dset_name) errcode = h5imget_palette_c(loc_id,namelen,dset_name,pal_number,buf) end subroutine h5imget_palette_f !------------------------------------------------------------------------- ! Function: h5imis_palette_f ! ! Purpose: Inquires if a dataset is a palette ! ! Return: true, false, fail ! ! Programmer: pvn@ncsa.uiuc.edu ! ! Date: October 06, 2004 ! ! Comments: ! ! Modifications: ! !------------------------------------------------------------------------- integer function h5imis_palette_f(loc_id,& dset_name) implicit none ! !This definition is needed for Windows DLLs !DEC$if defined(BUILD_HDF5_DLL) !DEC$attributes dllexport :: h5imis_palette_f !DEC$endif ! integer(hid_t), intent(in) :: loc_id ! file or group identifier character(len=*), intent(in) :: dset_name ! name of the dataset integer :: errcode ! error code integer :: namelen ! name length interface integer function h5imis_palette_c(loc_id,namelen,dset_name) use h5global !DEC$IF DEFINED(HDF5F90_WINDOWS) !DEC$ATTRIBUTES C,reference,decorate,alias:'H5IMIS_PALETTE_C'::h5imis_palette_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: dset_name integer(hid_t), intent(in) :: loc_id ! file or group identifier integer :: namelen ! lenght of name buffer character(len=*), intent(in) :: dset_name ! name of the dataset end function h5imis_palette_c end interface namelen = len(dset_name) errcode = h5imis_palette_c(loc_id,namelen,dset_name) h5imis_palette_f = errcode end function h5imis_palette_f ! end ! end module H5IM
bsd-3-clause
Vitancourt/gcc
gcc/testsuite/gfortran.dg/g77_intrinsics_sub.f
185
2201
! { dg-do compile } ! { dg-options "-std=legacy" } ! ! Testing g77 intrinsics as subroutines integer(kind=8) i8, j8 integer i4, j4 integer i, j character*80 c call gerror (c) call getlog (c) call hostnm (c, status = i8) call hostnm (c, i8) call hostnm (c, status = i4) call hostnm (c, i4) call hostnm (c, status = i) call hostnm (c, i) call hostnm (c) call kill (i8, i8, status = i8) call kill (i8, i8, i8) call kill (i4, i8, i8) call kill (i8, i4, i8) call kill (i8, i8, i4) call kill (i4, i4, i8) call kill (i4, i8, i4) call kill (i8, i4, i4) call kill (i4, i4, i4) call kill (i, i, i) call kill (i8, i8) call kill (i4, i8) call kill (i8, i4) call kill (i4, i4) call kill (i, i) call link ('foo', 'bar', status = i8) call link ('foo', 'bar', status = i4) call link ('foo', 'bar', status = i) call link ('foo', 'bar', i8) call link ('foo', 'bar', i4) call link ('foo', 'bar', i) call link ('foo', 'bar') call perror (c) call rename ('foo', 'bar', status = i8) call rename ('foo', 'bar', status = i4) call rename ('foo', 'bar', status = i) call rename ('foo', 'bar', i8) call rename ('foo', 'bar', i4) call rename ('foo', 'bar', i) call rename ('foo', 'bar') i = 1 i4 = 1 i8 = 1 call sleep (i) call sleep (i4) call sleep (i8) call sleep (-1) call symlnk ('foo', 'bar', status = i8) call symlnk ('foo', 'bar', status = i4) call symlnk ('foo', 'bar', status = i) call symlnk ('foo', 'bar', i8) call symlnk ('foo', 'bar', i4) call symlnk ('foo', 'bar', i) call symlnk ('foo', 'bar') ! Cleaning our mess call unlink ('bar') ! This should be the last test, unless you want garbage everywhere in ! your filesystem. call chdir ('..', status = i8) call chdir ('..', i8) call chdir ('..', status = i4) call chdir ('..', i4) call chdir ('..', status = i) call chdir ('..', i) call chdir ('..') end
gpl-2.0
RobinsonLab/pgplot
sys_win/W9driv.f
1
22681
C* W9DRIV -- PGPLOT device driver for Windows95 (or WindowsNT) C+ SUBROUTINE W9DRIV (IFUNC, RBUF, NBUF, CHR, LCHR, MODE) USE DFLIB IMPLICIT NONE INTEGER IFUNC, NBUF, LCHR, MODE REAL RBUF(*) CHARACTER CHR*(*) C C PGPLOT driver for IBM PC's and clones running DIGITAL Visual Fortran C (5.0 or higher). This driver will create a graphics window. C PGEND will return control to the default (text) window, but the graphics C window is not erased until <RETURN> is pressed. C C This routine must be compiled and linked with the Digital DFLIB graphics C library. Application must be compiled as a "QuickWin Graphics" project type, C compiler command line option /MW. C C 1989-Nov-03 - (MSDRIV) Started work [AFT] C 1989-Apr-06 - Improved version [AFT] C 1991-Mar-13 - Added cursor routine [JHT] C 12/1993 C. T. Dum: Version for MS Fortran Power Station C 1996-Apr-26 - W9DRIV (Windows95/PowerStation 4.0 version): C resolution modes; interrupt driven mouse (cursor band modes); C rectangle fill; pixel lines [Phil Seeger, PASeeger@aol.com] C 1996-Apr-30 - multiple devices; return color representation [PAS] C 1996-May-03 - each window has its own resolution and palette [PAS] C 1997-Dec-15 - change USE statement from Microsoft to Digital [PAS] C 1998-May-04 - had only 7 windows instead of 8 [PAS] C 1998-Jun-22 - moved window initialization to be after open [ACLarson] C----------------------------------------------------------------------- C C Supported device: IBM PC's and compatibles with Windows95/NT; C requires VGA or higher graphics adapter C C Device type code: /W95 (also /WV, /WS, /WX, or /WZ) C C Modes: 1, VGA, 640 x 480 C 2, SVGA, 800 x 600 C 3, XGA, 1024 x 768 C 4, ZGA, 1280 x 1024 C 0, from PGPLOT_VIDEO environment parameter, or SVGA C The Default mode is 800 x 640 pixels (SVGA). Other resolution C modes are accessed by entering SET PGPLOT_VIDEO=VGA (640x480), C XGA (1024x768), or ZGA (1280x1024) in the AUTOEXEC.BAT file, or C by using alternate device type designations. The maximum allowed C mode is determined by the graphics card and the Windows95 driver. C C Color capability: Color indices 0-15 are set to the default values C of PGPLOT, and indices 16-235 default to a gray scale. Palettes C of up to 235 colors are saved for each of 8 possible device C windows. (20 colors are reserved for the system.) C NOTE: There are some peculiar graphics adapters out there, and C even more peculiar drivers. The default colors have been C tweeked to appear unique in either the upper 6 or the lower C 6 bits of each byte. If you don't like what you see, you C may modify the DATA statement for RGB16. It may also be C necessary to change PARAMETER CNORM from 255 to 63. C C Default device name: None (the device name, if specified, is ignored). C C View surface dimensions: Depends on monitor, typical 7.5x10 inches C C Resolution: Depends on graphics card and Windows95 driver. C C Input capability: Mouse position, must be followed by a keyboard key. C C File format: None. C C Obtaining hardcopy: via Windows95, "File/Print" menu choice. C----------------------------------------------------------------------- C Notes: C Up to MAXDEV "devices" may be open at once. ACTIVE is the number C of the currently selected device (1 if no devices are open). C STATE(i) is 0 if device i is not open, 1 if it is open but with C no current picture, or 2 if it is open with a current picture. C----------------------------------------------------------------------- EXTERNAL GRW900, GRW901 INTEGER MAXDEV REAL*4 CNORM PARAMETER (MAXDEV=8, CNORM=255.) TYPE (xycoord) XY C CHARACTER CMSG*10, WINTITLE*80 INTEGER MX(0:4), MY(0:4), MXX(MAXDEV), MXY(MAXDEV), MXC(MAXDEV),& & I, ACTIVE,IUNIT(MAXDEV), STATE(0:MAXDEV), NPIC(MAXDEV) INTEGER*4 IRGB, RGB(0:235,MAXDEV), RGB16(0:15), RGB236(0:235) INTEGER*2 I2STAT, I2X0, I2Y0, I2X1, I2Y1, DASHLINE(5), ICOLOR, & & CBITS(MAXDEV), IX(1), IY(1), IC(1) INTEGER*4 I4STAT, I4X, I4Y, IXREF, IYREF, BAND, EVENT, IBUF LOGICAL FIRST, QFIRST(MAXDEV), LPOS SAVE FIRST, QFIRST, ACTIVE, STATE, XY, MXX, MXY, MXC, IUNIT, RGB, & & ICOLOR, NPIC, MX, MY, DASHLINE, CBITS, RGB16 DATA FIRST, QFIRST, ACTIVE, STATE(0:MAXDEV)/ & & .TRUE., MAXDEV*.TRUE., 1, -1, MAXDEV*0/ DATA MX, MY/ 0, 640, 800, 1024, 1280, & & 0, 480, 640, 768, 1024/ DATA DASHLINE/#FFFF, #FF80, #FC30, #CCCC, #FCCC/ C C Following data statement provides unique colors on all tested adapters DATA RGB16(0:15)/0, #FFFFFF, #0000FF, #00FF00, #FF0000, #FFFF00, & & #FF00FF, #00FFFF, #005FFF, #00FFAA, #AAFF00, #FF9300, #FF0093, & & #5F00FF, #555555, #AAAAAA/ C C--- C Initialize first 16 RGB values and gray scale for all windows IF (FIRST) THEN FIRST = .FALSE. DO ICOLOR=0,15 DO I=1,MAXDEV RGB(ICOLOR,I) = RGB16(ICOLOR) END DO END DO IRGB = #020202 DO ICOLOR=16,235 IRGB = IRGB + #010101 DO I=1,MAXDEV RGB(ICOLOR,I) = IRGB END DO END DO ICOLOR = 1 DO I=1,MAXDEV CBITS(I) = #0F END DO END IF C SELECT CASE (IFUNC) C CASE (1) C--- IFUNC = 1, Return device name.------------------------------------- SELECT CASE (MODE) CASE (1) CHR = 'WV (Windows95/NT, 640x480)' CASE (2) CHR = 'WS (Windows95/NT, 800x600)' CASE (3) CHR = 'WX (Windows95/NT, 1024x768)' CASE (4) CHR = 'WZ (Windows95/NT, 1280x1024)' CASE DEFAULT CHR = 'W9 (Windows95/NT, mode from environment)' END SELECT LCHR = LEN_TRIM(CHR) C CASE (2) C--- IFUNC = 2, Return physical min and max for plot device, and range C of color indices.--------------------------------------- IF (QFIRST(ACTIVE)) THEN MXX(ACTIVE) = MX(MODE) MXY(ACTIVE) = MY(MODE) MXC(ACTIVE) = 236 CALL GRW900(ACTIVE, MXX, MXY, MXC, QFIRST) END IF RBUF(1) = 0. RBUF(2) = MXX(ACTIVE) RBUF(3) = 0. RBUF(4) = MXY(ACTIVE) RBUF(5) = 0. RBUF(6) = MXC(ACTIVE) NBUF = 6 C CASE (3) C--- IFUNC = 3, Return device resolution. ------------------------------ C Divide the number of pixels on screen by a typical screen size in C inches. IF (QFIRST(ACTIVE)) THEN MXX(ACTIVE) = MX(MODE) MXY(ACTIVE) = MY(MODE) MXC(ACTIVE) = 236 CALL GRW900(ACTIVE, MXX, MXY, MXC, QFIRST) END IF RBUF(1) = FLOAT(MXX(ACTIVE)+1)/10. RBUF(2) = FLOAT(MXY(ACTIVE)+1)/7.5 RBUF(3) = 1.0 NBUF = 3 C CASE (4) C--- IFUNC = 4, Return misc device info. ------------------------------- C (This device is Interactive, Cursor, No dashed lines, No area fill, C No thick lines, Rectangle fill, Pixel primative, No ?, querY color C representation, No markers) CHR = 'ICNNNRPNYN' LCHR = 10 C CASE (5) C--- IFUNC = 5, Return default file name. ------------------------------ CHR = 'PGPlot Graphics' LCHR = LEN_TRIM(CHR) C CASE (6) C--- IFUNC = 6, Return default physical size of plot. ------------------ IF (QFIRST(ACTIVE)) THEN MXX(ACTIVE) = MX(MODE) MXY(ACTIVE) = MY(MODE) MXC(ACTIVE) = 236 CALL GRW900(ACTIVE, MXX, MXY, MXC, QFIRST) END IF RBUF(1) = 0. RBUF(2) = MXX(ACTIVE) RBUF(3) = 0. RBUF(4) = MXY(ACTIVE) NBUF = 4 C CASE (7) C--- IFUNC = 7, Return misc defaults. ---------------------------------- RBUF(1) = 1. NBUF = 1 C CASE (8) C--- IFUNC = 8, Select plot. ------------------------------------------- I = NINT(RBUF(2)) IF (I.GE.1 .AND. I.LE.MAXDEV .AND. STATE(I).GT.0) THEN IF (I .NE. ACTIVE) THEN ACTIVE = I I4STAT = SETACTIVEQQ(IUNIT(ACTIVE)) I4STAT = FOCUSQQ(IUNIT(ACTIVE)) DO I=0,235 RGB236(I) = RGB(I,ACTIVE) END DO I4STAT = REMAPALLPALETTE(RGB236) I2STAT = SETCOLOR(ICOLOR) END IF ELSE CALL GRWARN('invalid or unopened graphics window in W9DRIV') END IF C CASE (9) C--- IFUNC = 9, Open workstation. -------------------------------------- I = 0 DO WHILE (I.LE.MAXDEV .AND. STATE(I).NE.0) I = I + 1 END DO IF (I .GT. MAXDEV) THEN CALL GRWARN('maximum number of graphics windows exceeded') RBUF(1) = 0. RBUF(2) = 0. ELSE ACTIVE = I RBUF(1) = ACTIVE RBUF(2) = 1. C Initialize this window in requested mode, and open it MXX(ACTIVE) = MX(MODE) MXY(ACTIVE) = MY(MODE) MXC(ACTIVE) = 236 CALL GRGLUN(IUNIT(ACTIVE)) WRITE (WINTITLE, '(A,I2)') CHR(:LCHR)//', #', ACTIVE OPEN (IUNIT(ACTIVE), FILE='USER', TITLE=WINTITLE(:LCHR+5)) CALL GRW900(ACTIVE, MXX, MXY, MXC, QFIRST) DO I=0,235 RGB236(I) = RGB(I,ACTIVE) END DO I4STAT = REMAPALLPALETTE(RGB236) I2STAT = SETCOLOR(ICOLOR) STATE(ACTIVE) = 1 NPIC(ACTIVE) = 0 END IF NBUF = 2 C CASE (10) C--- IFUNC=10, Close workstation. -------------------------------------- IF (STATE(ACTIVE) .GT. 0) THEN print ('(A,I2)'), ' Type <RETURN> to close graphics '// & & 'window #',active read * CLOSE (IUNIT(ACTIVE)) STATE(ACTIVE) = 0 QFIRST(ACTIVE) = .TRUE. END IF C CASE (11) C--- IFUNC=11, Begin picture. ------------------------------------------ IF(NPIC(ACTIVE) .EQ. 0) THEN CALL CLEARSCREEN($GCLEARSCREEN) END IF STATE(ACTIVE) = 2 NPIC(ACTIVE) = NPIC(ACTIVE) + 1 I4STAT = SETACTIVEQQ(IUNIT(ACTIVE)) I4STAT = FOCUSQQ(IUNIT(ACTIVE)) C CASE (12) C--- IFUNC=12, Draw line. ---------------------------------------------- I2X0 = NINT(RBUF(1)) I2Y0 = MXY(ACTIVE) - NINT(RBUF(2)) CALL MOVETO(I2X0, I2Y0, XY) I2X1 = NINT(RBUF(3)) I2Y1 = MXY(ACTIVE) - NINT(RBUF(4)) I2STAT = LINETO(I2X1, I2Y1) C CASE (13) C--- IFUNC=13, Draw dot. ----------------------------------------------- I2X0 = NINT(RBUF(1)) I2Y0 = MXY(ACTIVE) - NINT(RBUF(2)) I4STAT = SETPIXEL(I2X0, I2Y0) C CASE (14) C--- IFUNC=14, End picture. -------------------------------------------- IF (STATE(ACTIVE) .GT. 0) STATE(ACTIVE) = 1 NPIC(ACTIVE) = 0 C CASE (15) C--- IFUNC=15, Select color index. ------------------------------------- ICOLOR = MIN(MXC(ACTIVE), MAX(0, NINT(RBUF(1)))) I2STAT = SETCOLOR(ICOLOR) C CASE (16) C--- IFUNC=16, Flush buffer. ------------------------------------------- C CASE (17) C--- IFUNC=17, Read cursor (mouse) AND keystroke ----------------------- I4X = NINT(RBUF(1)) I4Y = MXY(ACTIVE) - NINT(RBUF(2)) IF (NBUF .GE. 6) THEN C Support for multiple forms of cursor IXREF = NINT(RBUF(3)) IYREF = MXY(ACTIVE) - NINT(RBUF(4)) BAND = NINT(RBUF(5)) LPOS = RBUF(6) .GT. 0. ELSE C Simple crosshair cursor IXREF = I4X IYREF = I4Y BAND = 0 LPOS = .TRUE. END IF C C Set color index, for exclusive-ORing ICOLOR = SETCOLOR(CBITS(ACTIVE)) I4STAT = SETWRITEMODE($GXOR) C Initialize mouse routine by calling with fake arguments CALL GRW901(-BAND, MXX(ACTIVE), MXY(ACTIVE), IXREF, IYREF) C Initialize position of cursor by simulating mouse button click IF (LPOS) CALL GRW901(IUNIT(ACTIVE), MOUSE$MOVE, 0, I4X, I4Y) C Activate mouse callback routine EVENT = MOUSE$MOVE I4STAT = REGISTERMOUSEEVENT(IUNIT(ACTIVE), EVENT, GRW901) C Wait for a keystroke CHR(1:1) = GETCHARQQ() C C A key has been struck; turn off mouse, get position, restore color I4STAT = UNREGISTERMOUSEEVENT(IUNIT(ACTIVE), EVENT) CALL GRW901(0, 0, 0, I4X, I4Y) I4STAT = SETWRITEMODE($GPSET) I2STAT = SETCOLOR(ICOLOR) C Return results LCHR = 1 RBUF(1) = I4X RBUF(2) = MXY(ACTIVE) - I4Y NBUF = 2 C CASE (18) C--- IFUNC=18, Erase alpha screen. ------------------------------------- C CASE (19) C--- IFUNC=19, Set line style. ----------------------------------------- C Note: not likely to be called because IFUNC=4 returns "No dashed lines" I = MIN(5, MAX(0, NINT(RBUF(1)))) CALL SETLINESTYLE(DASHLINE(I)) C C--- IFUNC=20, Polygon fill. ------------------------------------------- C CASE (21) C--- IFUNC=21, Set color representation. ------------------------------- I = NINT(RBUF(1)) IF (I.GE.0 .AND. I.LE.MXC(ACTIVE)) THEN ICOLOR = I IRGB = NINT(RBUF(2)*CNORM) .OR. & & ISHFT(NINT(RBUF(3)*CNORM), 8) .OR. & & ISHFT(NINT(RBUF(4)*CNORM),16) RGB(I,ACTIVE) = IRGB CBITS(ACTIVE) = CBITS(ACTIVE) .OR. ICOLOR I4STAT = REMAPPALETTERGB(I, IRGB) END IF C C--- IFUNC=22, Set line width. ----------------------------------------- C C--- IFUNC=23, Escape. ------------------------------------------------- C CASE (24) C--- IFUNC=24, Rectangle fill. ----------------------------------------- I2X0 = NINT(RBUF(1)) I2Y0 = MXY(ACTIVE) - NINT(RBUF(2)) I2X1 = NINT(RBUF(3)) I2Y1 = MXY(ACTIVE) - NINT(RBUF(4)) I2STAT = RECTANGLE($GFILLINTERIOR, I2X0, I2Y0, I2X1, I2Y1) C C--- IFUNC=25, Set fill pattern. --------------------------------------- C CASE (26) C--- IFUNC=26, Line of pixels. ----------------------------------------- IY(1) = MXY(ACTIVE) - NINT(RBUF(2)) IF (IY(1).GE.0 .AND. IY(1).LE.MXY(ACTIVE)) THEN IX(1) = NINT(RBUF(1)) IBUF = 3 IF (IX(1) .LT. 0) THEN IBUF = 3 - IX(1) IX(1) = 0 END IF DO WHILE (IBUF.LE.NBUF .AND. I2X0.LE.MXX(ACTIVE)) IC(1) = MIN(MXC(ACTIVE), MAX(0, NINT(RBUF(IBUF)))) CALL SETPIXELS(1, IX, IY, IC) IBUF = IBUF + 1 IX(1) = IX(1) + 1 END DO END IF C C--- IFUNC=27, Scaling info -------------------------------------------- C C--- IFUNC=28, Draw marker --------------------------------------------- C CASE (29) C--- IFUNC=29, Query color representation.------------------------------ I = NINT(RBUF(1)) IRGB = RGB(I,ACTIVE) RBUF(2) = FLOAT(IAND(IRGB, #FF))/CNORM RBUF(3) = FLOAT(IAND(ISHFT(IRGB,-8), #FF))/CNORM RBUF(4) = FLOAT(IAND(ISHFT(IRGB,-16), #FF))/CNORM NBUF = 4 C CASE DEFAULT C--- Unimplemented Function WRITE (CMSG, '(I10)') IFUNC CALL GRWARN('Unimplemented function in Win95 device driver:'// & & CMSG) NBUF = -1 END SELECT RETURN END C********* SUBROUTINE GRW900(I, MXX, MXY, MXC, QFIRST) USE DFLIB C 1998-May-04 - change from MSFLIB to DFLIB C 1998-Jun-22 - don't set WC.title to 'PGPLOT' IMPLICIT NONE INTEGER I, MXX(*), MXY(*), MXC(*) LOGICAL QFIRST(*) C--- TYPE (WINDOWCONFIG) WC INTEGER TR$L LOGICAL STATUS CHARACTER TR$VID*128 C--- C Set default window configuration C Try to set to input values of MXX, MXY, default 800x600 IF (MXX(I).LE.1 .OR. MXY(I).LE.1) THEN MXX(I) = 800 MXY(I) = 600 MXC(I) = 256 CALL GRGENV('VIDEO', TR$VID, TR$L) IF (TR$L .GT. 0) THEN C There is a "PGPLOT_VIDEO" parameter in the Environment IF( TR$VID(1:1) .EQ. 'V') THEN C Set to VGA resolution MXX(I) = 640 MXY(I) = 480 ELSE IF (TR$VID(1:1) .EQ. 'X') THEN MXX(I) = 1024 MXY(I) = 768 ELSE IF (TR$VID(1:1) .EQ. 'Z') THEN MXX(I) = 1280 MXY(I) = 1024 END IF END IF END IF C WC.numxpixels = MXX(I) WC.numypixels = MXY(I) WC.numcolors = MXC(I) WC.numtextcols = -1 WC.numtextrows = -1 WC.fontsize = -1 STATUS = SETWINDOWCONFIG(WC) IF(.NOT.STATUS) STATUS = SETWINDOWCONFIG(WC) C MXX(I) = WC.numxpixels - 1 MXY(I) = WC.numypixels - 1 MXC(I) = WC.numcolors - 1 QFIRST(I) = .FALSE. RETURN END C********* RECURSIVE SUBROUTINE GRW901(IUNIT,EVENT,KEYSTATE,XMOUSE,YMOUSE) USE DFLIB IMPLICIT NONE INTEGER IUNIT, EVENT, KEYSTATE, XMOUSE, YMOUSE C C Callback routine for mouse events, specific to Windows95 C Note: cursor band modes implemented in software C C 1996-Apr-26 - P.A.Seeger C 1998-May-04 - change from MSFLIB to DFLIB C-- RECORD /xycoord/ XY INTEGER*2 BAND, LENGTH, IX0, IY0, IX1, IY1, IX2, IY2, IXR, IYR INTEGER*4 DUMMY LOGICAL INITIUS, FINIS DATA INITIUS /.TRUE./ SAVE INITIUS,BAND,LENGTH,IX0,IY0,IX1,IY1,IX2,IY2,IXR,IYR C C Disable mouse movement interrupts while in callback routine IF (IUNIT .GT. 0) DUMMY = UNREGISTERMOUSEEVENT(IUNIT, MOUSE$MOVE) C FINIS = IUNIT.EQ.0 .AND. EVENT.EQ.0 .AND. KEYSTATE.EQ.0 IF (IUNIT.LE.0 .AND. .NOT.FINIS) THEN INITIUS = .TRUE. C Get initialization parameters from callback calling sequence BAND = -IUNIT IXR = XMOUSE IYR = YMOUSE IX0 = IXR IY0 = IYR C Extract parameters for length of cursor lines IF (BAND .EQ. 0) THEN C Simple crosshair cursor LENGTH = MAX(EVENT, KEYSTATE)/80 + 3 ELSE LENGTH = 0 IX1 = 0 IX2 = 0 IY1 = 0 IY2 = 0 C Modes with full width horizontal line(s) IF (BAND.EQ.3 .OR. BAND.EQ.5 .OR. BAND.EQ.7) IX2 = EVENT C Modes with full height vertical line(s) IF (BAND.EQ.4 .OR. BAND.EQ.6 .OR. BAND.EQ.7) IY2 = KEYSTATE IF (BAND .EQ. 3) THEN C Draw fixed horizontal line at anchor CALL MOVETO(IX1, IYR, XY) DUMMY = LINETO(IX2, IYR ) ELSE IF (BAND .EQ. 4) THEN C Draw fixed vertical line at anchor CALL MOVETO(IXR, IY1, XY) DUMMY = LINETO(IXR, IY2 ) END IF END IF GO TO 700 END IF C IF (.NOT. INITIUS) THEN C This is NOT an initial call, so need to erase previous cursor C by rewriting it in complementary color mode IF (BAND .EQ. 1) THEN CALL MOVETO(IXR, IYR, XY) DUMMY = LINETO(IX0, IY0 ) ELSE IF (BAND .EQ. 2) THEN DUMMY = RECTANGLE($GBORDER, IXR, IYR, IX0, IY0) ELSE IF (IY2 .NE. IY1) THEN CALL MOVETO(IX0, IY1, XY) DUMMY = LINETO(IX0, IY2 ) END IF IF (IX2 .NE. IX1) THEN CALL MOVETO(IX1, IY0, XY) DUMMY = LINETO(IX2, IY0 ) END IF END IF END IF C IF (FINIS) THEN C Termination call, return latest mouse location XMOUSE = IX0 YMOUSE = IY0 IF (BAND .EQ. 3) THEN C Erase fixed horizontal line at anchor CALL MOVETO(IX1, IYR, XY) DUMMY = LINETO(IX2, IYR ) ELSE IF (BAND .EQ. 4) THEN C Erase fixed vertical line at anchor CALL MOVETO(IXR, IY1, XY) DUMMY = LINETO(IXR, IY2 ) END IF INITIUS = .TRUE. GO TO 700 END IF C C Save new cursor location IX0 = XMOUSE IY0 = YMOUSE IF (BAND .EQ. 0) THEN C Find ends of cursor line segments IX1 = IX0 - LENGTH IX2 = IX0 + LENGTH IY1 = IY0 - LENGTH IY2 = IY0 + LENGTH END IF C C Now draw line, box, or cursor in complementary color INITIUS = .FALSE. IF (BAND .EQ. 1) THEN C Line from anchor to cursor location CALL MOVETO(IXR, IYR, XY) DUMMY = LINETO(IX0, IY0 ) ELSE IF (BAND .EQ. 2) THEN C Box with vertices at anchor and cursor location DUMMY = RECTANGLE($GBORDER, IXR, IYR, IX0, IY0) ELSE IF (IY2 .NE. IY1) THEN C Draw a horizontal line (or segment) CALL MOVETO(IX0, IY1, XY) DUMMY = LINETO(IX0, IY2) END IF IF (IX2 .NE. IX1) THEN C Draw a vertical line (or segment) CALL MOVETO(IX1, IY0, XY) DUMMY = LINETO(IX2, IY0) END IF END IF C 700 CONTINUE IF (IUNIT.GT.0 .AND. .NOT.INITIUS) & & DUMMY = REGISTERMOUSEEVENT(IUNIT, MOUSE$MOVE, GRW901) RETURN END
apache-2.0
sudosurootdev/gcc
gcc/testsuite/gfortran.dg/c_loc_test_22.f90
59
1113
! { dg-do compile } ! { dg-options "-fdump-tree-original" } ! ! PR fortran/56907 ! subroutine sub(xxx, yyy) use iso_c_binding implicit none integer, target, contiguous :: xxx(:) integer, target :: yyy(:) type(c_ptr) :: ptr1, ptr2, ptr3, ptr4 ptr1 = c_loc (xxx) ptr2 = c_loc (xxx(5:)) ptr3 = c_loc (yyy) ptr4 = c_loc (yyy(5:)) end ! { dg-final { scan-tree-dump-not " _gfortran_internal_pack" "original" } } ! { dg-final { scan-tree-dump-times "parm.\[0-9\]+.data = \\(void .\\) &\\(.xxx.\[0-9\]+\\)\\\[0\\\];" 1 "original" } } ! { dg-final { scan-tree-dump-times "parm.\[0-9\]+.data = \\(void .\\) &\\(.xxx.\[0-9\]+\\)\\\[D.\[0-9\]+ \\* 4\\\];" 1 "original" } } ! { dg-final { scan-tree-dump-times "parm.\[0-9\]+.data = \\(void .\\) &\\(.yyy.\[0-9\]+\\)\\\[0\\\];" 1 "original" } } ! { dg-final { scan-tree-dump-times "parm.\[0-9\]+.data = \\(void .\\) &\\(.yyy.\[0-9\]+\\)\\\[D.\[0-9\]+ \\* 4\\\];" 1 "original" } } ! { dg-final { scan-tree-dump-times "D.\[0-9\]+ = parm.\[0-9\]+.data;\[^;]+ptr\[1-4\] = D.\[0-9\]+;" 4 "original" } } ! { dg-final { cleanup-tree-dump "original" } }
gpl-2.0
sudosurootdev/gcc
gcc/testsuite/gfortran.dg/used_types_5.f90
136
1328
! { dg-do compile } ! Tests the fix for a further regression caused by the ! fix for PR28788, as noted in reply #9 in the Bugzilla ! entry by Martin Reinecke <martin@mpa-garching.mpg.de>. ! The problem was caused by certain types of references ! that point to a deleted derived type symbol, after the ! type has been associated to another namespace. An ! example of this is the specification expression for x ! in subroutine foo below. At the same time, this tests ! the correct association of typeaa between a module ! procedure and a new definition of the type in MAIN. ! module types type :: typea sequence integer :: i end type typea type :: typeaa sequence integer :: i end type typeaa type(typea) :: it = typea(2) end module types !------------------------------ module global use types, only: typea, it contains subroutine foo (x) use types type(typeaa) :: ca real :: x(it%i) common /c/ ca x = 42.0 ca%i = 99 end subroutine foo end module global !------------------------------ use global, only: typea, foo type :: typeaa sequence integer :: i end type typeaa type(typeaa) :: cam real :: x(4) common /c/ cam x = -42.0 call foo(x) if (any (x .ne. (/42.0, 42.0, -42.0, -42.0/))) call abort () if (cam%i .ne. 99) call abort () end
gpl-2.0
gdooper/scipy
scipy/linalg/src/id_dist/src/idz_id2svd.f
139
8580
c this file contains the following user-callable routines: c c c routine idz_id2svd converts an approximation to a matrix c in the form of an ID to an approximation in the form of an SVD. c c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c c c subroutine idz_id2svd(m,krank,b,n,list,proj,u,v,s,ier,w) c c converts an approximation to a matrix in the form of an ID c to an approximation in the form of an SVD. c c input: c m -- first dimension of b c krank -- rank of the ID c b -- columns of the original matrix in the ID c list -- list of columns chosen from the original matrix c in the ID c n -- length of list and part of the second dimension of proj c proj -- projection coefficients in the ID c c output: c u -- left singular vectors c v -- right singular vectors c s -- singular values c ier -- 0 when the routine terminates successfully; c nonzero otherwise c c work: c w -- must be at least (krank+1)*(m+3*n+10)+9*krank**2 c complex*16 elements long c c _N.B._: This routine destroys b. c implicit none integer m,krank,n,list(n),iwork,lwork,ip,lp,it,lt,ir,lr, 1 ir2,lr2,ir3,lr3,iind,lind,iindt,lindt,lw,ier real*8 s(krank) complex*16 b(m,krank),proj(krank,n-krank),u(m,krank), 1 v(n,krank),w((krank+1)*(m+3*n+10)+9*krank**2) c c c Allocate memory for idz_id2svd0. c lw = 0 c iwork = lw+1 lwork = 8*krank**2+10*krank lw = lw+lwork c ip = lw+1 lp = krank*n lw = lw+lp c it = lw+1 lt = n*krank lw = lw+lt c ir = lw+1 lr = krank*n lw = lw+lr c ir2 = lw+1 lr2 = krank*m lw = lw+lr2 c ir3 = lw+1 lr3 = krank*krank lw = lw+lr3 c iind = lw+1 lind = n/4+1 lw = lw+1 c iindt = lw+1 lindt = m/4+1 lw = lw+1 c c call idz_id2svd0(m,krank,b,n,list,proj,u,v,s,ier, 1 w(iwork),w(ip),w(it),w(ir),w(ir2),w(ir3), 2 w(iind),w(iindt)) c c return end c c c c subroutine idz_id2svd0(m,krank,b,n,list,proj,u,v,s,ier, 1 work,p,t,r,r2,r3,ind,indt) c c routine idz_id2svd serves as a memory wrapper c for the present routine (please see routine idz_id2svd c for further documentation). c implicit none c character*1 jobz integer m,n,krank,list(n),ind(n),indt(m),ifadjoint, 1 lwork,ldu,ldvt,ldr,info,j,k,ier real*8 s(krank) complex*16 b(m,krank),proj(krank,n-krank),p(krank,n), 1 r(krank,n),r2(krank,m),t(n,krank),r3(krank,krank), 2 u(m,krank),v(n,krank),work(8*krank**2+10*krank) c c c ier = 0 c c c c Construct the projection matrix p from the ID. c call idz_reconint(n,list,krank,proj,p) c c c c Compute a pivoted QR decomposition of b. c call idzr_qrpiv(m,krank,b,krank,ind,r) c c c Extract r from the QR decomposition. c call idz_rinqr(m,krank,b,krank,r) c c c Rearrange r according to ind. c call idz_rearr(krank,ind,krank,krank,r) c c c c Take the adjoint of p to obtain t. c call idz_matadj(krank,n,p,t) c c c Compute a pivoted QR decomposition of t. c call idzr_qrpiv(n,krank,t,krank,indt,r2) c c c Extract r2 from the QR decomposition. c call idz_rinqr(n,krank,t,krank,r2) c c c Rearrange r2 according to indt. c call idz_rearr(krank,indt,krank,krank,r2) c c c c Multiply r and r2^* to obtain r3. c call idz_matmulta(krank,krank,r,krank,r2,r3) c c c c Use LAPACK to SVD r3. c jobz = 'S' ldr = krank lwork = 8*krank**2+10*krank 1 - (krank**2+2*krank+3*krank**2+4*krank) ldu = krank ldvt = krank c call zgesdd(jobz,krank,krank,r3,ldr,s,work,ldu,r,ldvt, 1 work(krank**2+2*krank+3*krank**2+4*krank+1),lwork, 2 work(krank**2+2*krank+1),work(krank**2+1),info) c if(info .ne. 0) then ier = info return endif c c c c Multiply the u from r3 from the left by the q from b c to obtain the u for a. c do k = 1,krank c do j = 1,krank u(j,k) = work(j+krank*(k-1)) enddo ! j c do j = krank+1,m u(j,k) = 0 enddo ! j c enddo ! k c ifadjoint = 0 call idz_qmatmat(ifadjoint,m,krank,b,krank,krank,u,r2) c c c c Take the adjoint of r to obtain r2. c call idz_matadj(krank,krank,r,r2) c c c Multiply the v from r3 from the left by the q from p^* c to obtain the v for a. c do k = 1,krank c do j = 1,krank v(j,k) = r2(j,k) enddo ! j c do j = krank+1,n v(j,k) = 0 enddo ! j c enddo ! k c ifadjoint = 0 call idz_qmatmat(ifadjoint,n,krank,t,krank,krank,v,r2) c c return end c c c c subroutine idz_matadj(m,n,a,aa) c c Takes the adjoint of a to obtain aa. c c input: c m -- first dimension of a, and second dimension of aa c n -- second dimension of a, and first dimension of aa c a -- matrix whose adjoint is to be taken c c output: c aa -- adjoint of a c implicit none integer m,n,j,k complex*16 a(m,n),aa(n,m) c c do k = 1,n do j = 1,m aa(k,j) = conjg(a(j,k)) enddo ! j enddo ! k c c return end c c c c subroutine idz_matmulta(l,m,a,n,b,c) c c multiplies a and b^* to obtain c. c c input: c l -- first dimension of a and c c m -- second dimension of a and b c a -- leftmost matrix in the product c = a b^* c n -- first dimension of b and second dimension of c c b -- rightmost matrix in the product c = a b^* c c output: c c -- product of a and b^* c implicit none integer l,m,n,i,j,k complex*16 a(l,m),b(n,m),c(l,n),sum c c do i = 1,l do k = 1,n c sum = 0 c do j = 1,m sum = sum+a(i,j)*conjg(b(k,j)) enddo ! j c c(i,k) = sum c enddo ! k enddo ! i c c return end c c c c subroutine idz_rearr(krank,ind,m,n,a) c c rearranges a according to ind obtained c from routines idzr_qrpiv or idzp_qrpiv, c assuming that a = q r, where q and r are from idzr_qrpiv c or idzp_qrpiv. c c input: c krank -- rank obtained from routine idzp_qrpiv, c or provided to routine idzr_qrpiv c ind -- indexing array obtained from routine idzr_qrpiv c or idzp_qrpiv c m -- first dimension of a c n -- second dimension of a c a -- matrix to be rearranged c c output: c a -- rearranged matrix c implicit none integer k,krank,m,n,j,ind(krank) complex*16 cswap,a(m,n) c c do k = krank,1,-1 do j = 1,m c cswap = a(j,k) a(j,k) = a(j,ind(k)) a(j,ind(k)) = cswap c enddo ! j enddo ! k c c return end c c c c subroutine idz_rinqr(m,n,a,krank,r) c c extracts R in the QR decomposition specified by the output a c of the routine idzr_qrpiv or idzp_qrpiv. c c input: c m -- first dimension of a c n -- second dimension of a and r c a -- output of routine idzr_qrpiv or idzp_qrpiv c krank -- rank output by routine idzp_qrpiv (or specified c to routine idzr_qrpiv) c c output: c r -- triangular factor in the QR decomposition specified c by the output a of the routine idzr_qrpiv or idzp_qrpiv c implicit none integer m,n,j,k,krank complex*16 a(m,n),r(krank,n) c c c Copy a into r and zero out the appropriate c Householder vectors that are stored in one triangle of a. c do k = 1,n do j = 1,krank r(j,k) = a(j,k) enddo ! j enddo ! k c do k = 1,n if(k .lt. krank) then do j = k+1,krank r(j,k) = 0 enddo ! j endif enddo ! k c c return end
bsd-3-clause
sudosurootdev/gcc
gcc/testsuite/gfortran.dg/debug/pr46756.f
125
1028
C PR debug/46756, reduced from ../20010519-1.f C { dg-do compile } C { dg-options "-O -fcompare-debug" } LOGICAL QDISK,QDW,QCMPCT LOGICAL LNOMA,LRAISE,LSCI,LBIG ASSIGN 801 TO I800 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" } GOTO 800 801 CONTINUE ASSIGN 761 TO I760 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" } 761 CONTINUE IF(LSCI) THEN DO I=1,LENCM ENDDO ENDIF DO WHILE((CVGMX.GT.TOLDIM).AND.(ITER.LT.ITMX)) IF(.NOT.QDW) THEN ASSIGN 641 to I640 ! { dg-warning "Deleted feature: ASSIGN" "Deleted feature: ASSIGN" } GOTO 640 641 CONTINUE ENDIF ENDDO GOTO 700 640 CONTINUE GOTO I640 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" } 700 CONTINUE GOTO I760 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" } 800 CONTINUE GOTO I800 ! { dg-warning "Deleted feature: Assigned" "Assigned GO TO" } END
gpl-2.0
sudosurootdev/gcc
gcc/testsuite/gfortran.dg/large_real_kind_1.f90
136
2147
! { dg-do run } ! { dg-require-effective-target fortran_large_real } module testmod integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1) contains subroutine testoutput (a,b,length,f) real(kind=k),intent(in) :: a real(kind=8),intent(in) :: b integer,intent(in) :: length character(len=*),intent(in) :: f character(len=length) :: ca character(len=length) :: cb write (ca,f) a write (cb,f) b if (ca /= cb) call abort end subroutine testoutput subroutine outputstring (a,f,s) real(kind=k),intent(in) :: a character(len=*),intent(in) :: f character(len=*),intent(in) :: s character(len=len(s)) :: c write (c,f) a if (c /= s) call abort end subroutine outputstring end module testmod ! Testing I/O of large real kinds (larger than kind=8) program test use testmod implicit none real(kind=k) :: x character(len=20) :: c1, c2 call testoutput (0.0_k,0.0_8,40,'(F40.35)') call testoutput (1.0_k,1.0_8,40,'(F40.35)') call testoutput (0.1_k,0.1_8,15,'(F15.10)') call testoutput (1e10_k,1e10_8,15,'(F15.10)') call testoutput (7.51e100_k,7.51e100_8,15,'(F15.10)') call testoutput (1e-10_k,1e-10_8,15,'(F15.10)') call testoutput (7.51e-100_k,7.51e-100_8,15,'(F15.10)') call testoutput (-1.0_k,-1.0_8,40,'(F40.35)') call testoutput (-0.1_k,-0.1_8,15,'(F15.10)') call testoutput (-1e10_k,-1e10_8,15,'(F15.10)') call testoutput (-7.51e100_k,-7.51e100_8,15,'(F15.10)') call testoutput (-1e-10_k,-1e-10_8,15,'(F15.10)') call testoutput (-7.51e-100_k,-7.51e-100_8,15,'(F15.10)') x = huge(x) call outputstring (2*x,'(F20.15)',' Infinity') call outputstring (-2*x,'(F20.15)',' -Infinity') write (c1,'(G20.10E5)') x write (c2,'(G20.10E5)') -x if (c2(1:1) /= '-') call abort c2(1:1) = ' ' if (c1 /= c2) call abort x = tiny(x) call outputstring (x,'(F20.15)',' 0.000000000000000') call outputstring (-x,'(F20.15)',' -0.000000000000000') write (c1,'(G20.10E5)') x write (c2,'(G20.10E5)') -x if (c2(1:1) /= '-') call abort c2(1:1) = ' ' if (c1 /= c2) call abort end program test
gpl-2.0
sudosurootdev/gcc
gcc/testsuite/gfortran.dg/realloc_on_assign_17.f90
133
1150
! { dg-do run } ! Test the fix for PR47517 ! ! Reported by Tobias Burnus <burnus@gcc.gnu.org> ! from a testcase by James Van Buskirk module mytypes implicit none type label integer, allocatable :: parts(:) end type label type table type(label), allocatable :: headers(:) end type table end module mytypes program allocate_assign use mytypes implicit none integer, parameter :: ik8 = selected_int_kind(18) type(table) x1(2) type(table) x2(3) type(table), allocatable :: x(:) integer i, j, k integer(ik8) s call foo s = 0 do k = 1, 10000 x = x1 s = s+x(2)%headers(2)%parts(2) x = x2 s = s+x(2)%headers(2)%parts(2) end do if (s .ne. 40000) call abort contains ! ! TODO - these assignments lose 1872 bytes on x86_64/FC17 ! This is PR38319 ! subroutine foo x1 = [table([(label([(j,j=1,3)]),i=1,3)]), & table([(label([(j,j=1,4)]),i=1,4)])] x2 = [table([(label([(j,j=1,4)]),i=1,4)]), & table([(label([(j,j=1,5)]),i=1,5)]), & table([(label([(j,j=1,6)]),i=1,6)])] end subroutine end program allocate_assign
gpl-2.0
Mouseomics/R
src/library/stats/src/hclust.f
38
10635
C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++C C C C HIERARCHICAL CLUSTERING using (user-specified) criterion. C C C C Parameters: C C C C N the number of points being clustered C C DISS(LEN) dissimilarities in lower half diagonal C C storage; LEN = N.N-1/2, C C IOPT clustering criterion to be used, C C IA, IB, CRIT history of agglomerations; dimensions C C N, first N-1 locations only used, C C MEMBR, NN, DISNN vectors of length N, used to store C C cluster cardinalities, current nearest C C neighbour, and the dissimilarity assoc. C C with the latter. C C MEMBR must be initialized by R to the C C default of rep(1, N) C C FLAG boolean indicator of agglomerable obj./ C C clusters. C C C C F. Murtagh, ESA/ESO/STECF, Garching, February 1986. C C Modifications for R: Ross Ihaka, Dec 1996 C C Fritz Leisch, Jun 2000 C C all vars declared: Martin Maechler, Apr 2001 C C C c- R Bug PR#4195 fixed "along" qclust.c, given in the report C C- Testing: --> "hclust" in ../../../../tests/reg-tests-1b.R C C "ward.D2" (iOpt = 8): Martin Maechler, Mar 2014 C C------------------------------------------------------------C SUBROUTINE HCLUST(N,LEN,IOPT,IA,IB,CRIT,MEMBR,NN,DISNN, X FLAG,DISS) c Args INTEGER N, LEN, IOPT INTEGER IA(N),IB(N), NN(N) LOGICAL FLAG(N), isWard DOUBLE PRECISION CRIT(N), MEMBR(N),DISS(LEN), DISNN(N) c Var INTEGER IM, JJ, JM, I, NCL, J, IND, I2, J2, K, IND1, IND2 DOUBLE PRECISION INF, DMIN, D12 c External function INTEGER IOFFST c c was 1D+20 DATA INF/1.D+300/ c c unnecessary initialization of im jj jm to keep g77 -Wall happy c IM = 0 JJ = 0 JM = 0 C C Initializations C DO I=1,N C We do not initialize MEMBR in order to be able to restart the C algorithm from a cut. C MEMBR(I)=1. FLAG(I)=.TRUE. end do NCL=N IF (iOpt .eq. 8) THEN ! Ward "D2" ---> using *squared* distances do I=1,LEN DISS(I)=DISS(I)*DISS(I) end do ENDIF C C Carry out an agglomeration - first create list of NNs C Note NN and DISNN are the nearest neighbour and its distance C TO THE RIGHT of I. C DO I=1,N-1 DMIN=INF DO J=I+1,N IND=IOFFST(N,I,J) IF (DMIN .GT. DISS(IND)) THEN DMIN=DISS(IND) JM=J end if end do NN(I)=JM DISNN(I)=DMIN end do C-- Repeat ------------------------------------------------------- 400 CONTINUE C Next, determine least diss. using list of NNs DMIN=INF DO I=1,N-1 IF (FLAG(I) .AND. DISNN(I) .LT. DMIN) THEN DMIN=DISNN(I) IM=I JM=NN(I) end if end do NCL=NCL-1 C C This allows an agglomeration to be carried out. C I2=MIN0(IM,JM) J2=MAX0(IM,JM) IA(N-NCL)=I2 IB(N-NCL)=J2 C WARD'S "D1", or "D2" MINIMUM VARIANCE METHOD -- iOpt = 1 or 8. isWard = (iOpt .eq. 1 .or. iOpt .eq. 8) IF (iOpt .eq. 8) DMIN = dsqrt(DMIN) CRIT(N-NCL)=DMIN FLAG(J2)=.FALSE. C C Update dissimilarities from new cluster. C DMIN=INF DO K=1,N IF (FLAG(K) .AND. K .NE. I2) THEN IF (I2.LT.K) THEN IND1=IOFFST(N,I2,K) ELSE IND1=IOFFST(N,K,I2) ENDIF IF (J2.LT.K) THEN IND2=IOFFST(N,J2,K) ELSE IND2=IOFFST(N,K,J2) ENDIF D12=DISS(IOFFST(N,I2,J2)) C C WARD'S "D1", or "D2" MINIMUM VARIANCE METHOD - IOPT=8. IF (isWard) THEN DISS(IND1)=(MEMBR(I2)+MEMBR(K))*DISS(IND1)+ X (MEMBR(J2)+MEMBR(K))*DISS(IND2) - MEMBR(K)*D12 DISS(IND1)=DISS(IND1) / (MEMBR(I2)+MEMBR(J2)+MEMBR(K)) C C SINGLE LINK METHOD - IOPT=2. ELSEIF (IOPT.EQ.2) THEN DISS(IND1)=MIN(DISS(IND1),DISS(IND2)) C C COMPLETE LINK METHOD - IOPT=3. ELSEIF (IOPT.EQ.3) THEN DISS(IND1)=MAX(DISS(IND1),DISS(IND2)) C C AVERAGE LINK (OR GROUP AVERAGE) METHOD - IOPT=4. ELSEIF (IOPT.EQ.4) THEN DISS(IND1)= (MEMBR(I2)*DISS(IND1)+MEMBR(J2)*DISS(IND2)) X / (MEMBR(I2)+MEMBR(J2)) C C MCQUITTY'S METHOD - IOPT=5. ELSEIF (IOPT.EQ.5) THEN DISS(IND1)=(DISS(IND1)+DISS(IND2)) / 2 C C MEDIAN (GOWER'S) METHOD aka "Weighted Centroid" - IOPT=6. ELSEIF (IOPT.EQ.6) THEN DISS(IND1)= ((DISS(IND1)+DISS(IND2)) - D12/2) / 2 C C Unweighted CENTROID METHOD - IOPT=7. ELSEIF (IOPT.EQ.7) THEN DISS(IND1)=(MEMBR(I2)*DISS(IND1)+MEMBR(J2)*DISS(IND2)- X MEMBR(I2)*MEMBR(J2)*D12/(MEMBR(I2)+MEMBR(J2)))/ X (MEMBR(I2)+MEMBR(J2)) ENDIF C IF (I2 .lt. K) THEN IF (DISS(IND1) .LT. DMIN) THEN DMIN=DISS(IND1) JJ=K ENDIF else ! i2 > k c FIX: the rest of the else clause is a fix by JB to ensure c correct nearest neighbours are found when a non-monotone c clustering method (e.g. the centroid methods) are used if(DISS(IND1) .lt. DISNN(K)) then ! find nearest neighbour of i2 DISNN(K) = DISS(IND1) NN(K) = I2 end if ENDIF ENDIF END DO MEMBR(I2)=MEMBR(I2)+MEMBR(J2) DISNN(I2)=DMIN NN(I2)=JJ C C Update list of NNs insofar as this is required. C DO I=1,N-1 IF (FLAG(I) .AND. X ((NN(I).EQ.I2) .OR. (NN(I).EQ.J2))) THEN C (Redetermine NN of I:) DMIN=INF DO J=I+1,N if (FLAG(J)) then IND=IOFFST(N,I,J) if (DISS(IND) .lt. DMIN) then DMIN=DISS(IND) JJ=J end if end if end do NN(I)=JJ DISNN(I)=DMIN end if end do C C Repeat previous steps until N-1 agglomerations carried out. C IF (NCL.GT.1) GOTO 400 C C RETURN END C of HCLUST() C C INTEGER FUNCTION IOFFST(N,I,J) C Map row I and column J of upper half diagonal symmetric matrix C onto vector. INTEGER N,I,J IOFFST=J+(I-1)*N-(I*(I+1))/2 RETURN END C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++C C C C Given a HIERARCHIC CLUSTERING, described as a sequence of C C agglomerations, prepare the seq. of aggloms. and "horiz." C C order of objects for plotting the dendrogram using S routine C C 'plclust'. C C C C Parameters: C C C C IA, IB: vectors of dimension N defining the agglomer- C C ations. C C IIA, IIB: used to store IA and IB values differently C C (in form needed for S command 'plclust' C C IORDER: "horiz." order of objects for dendrogram C C C C F. Murtagh, ESA/ESO/STECF, Garching, June 1991 C C C C HISTORY C C C C Adapted from routine HCASS, which additionally determines C C cluster assignments at all levels, at extra comput. expense C C C C---------------------------------------------------------------C SUBROUTINE HCASS2(N,IA,IB,IORDER,IIA,IIB) c Args INTEGER N,IA(N),IB(N),IORDER(N),IIA(N),IIB(N) c Var INTEGER I, J, K, K1, K2, LOC C C Following bit is to get seq. of merges into format acceptable to plclust C I coded clusters as lowest seq. no. of constituents; S's 'hclust' codes C singletons as -ve numbers, and non-singletons with their seq. nos. C do I=1,N IIA(I)=IA(I) IIB(I)=IB(I) end do do I=1,N-2 C In the following, smallest (+ve or -ve) seq. no. wanted K=MIN(IA(I),IB(I)) do J=I+1, N-1 IF(IA(J).EQ.K) IIA(J)=-I IF(IB(J).EQ.K) IIB(J)=-I end do end do do I=1,N-1 IIA(I)=-IIA(I) IIB(I)=-IIB(I) end do do I=1,N-1 IF (IIA(I).GT.0 .AND. IIB(I).LT.0) THEN K = IIA(I) IIA(I) = IIB(I) IIB(I) = K ENDIF IF (IIA(I).GT.0 .AND. IIB(I).GT.0) THEN K1 = MIN(IIA(I),IIB(I)) K2 = MAX(IIA(I),IIB(I)) IIA(I) = K1 IIB(I) = K2 ENDIF end do C C C NEW PART FOR 'ORDER' C IORDER(1) = IIA(N-1) IORDER(2) = IIB(N-1) LOC=2 DO I=N-2,1,-1 DO J=1,LOC IF(IORDER(J).EQ.I) THEN C REPLACE IORDER(J) WITH IIA(I) AND IIB(I) IORDER(J)=IIA(I) IF (J.EQ.LOC) THEN LOC=LOC+1 IORDER(LOC)=IIB(I) else LOC=LOC+1 do K=LOC,J+2,-1 IORDER(K)=IORDER(K-1) end do IORDER(J+1)=IIB(I) end if GOTO 171 ENDIF end do C SHOULD NEVER REACH HERE 171 CONTINUE end do C C do I=1,N IORDER(I) = -IORDER(I) end do C C RETURN END
gpl-2.0
gdooper/scipy
scipy/sparse/linalg/eigen/arpack/ARPACK/SRC/dnaitr.f
141
30651
c----------------------------------------------------------------------- c\BeginDoc c c\Name: dnaitr c c\Description: c Reverse communication interface for applying NP additional steps to c a K step nonsymmetric Arnoldi factorization. c c Input: OP*V_{k} - V_{k}*H = r_{k}*e_{k}^T c c with (V_{k}^T)*B*V_{k} = I, (V_{k}^T)*B*r_{k} = 0. c c Output: OP*V_{k+p} - V_{k+p}*H = r_{k+p}*e_{k+p}^T c c with (V_{k+p}^T)*B*V_{k+p} = I, (V_{k+p}^T)*B*r_{k+p} = 0. c c where OP and B are as in dnaupd. The B-norm of r_{k+p} is also c computed and returned. c c\Usage: c call dnaitr c ( IDO, BMAT, N, K, NP, NB, RESID, RNORM, V, LDV, H, LDH, c IPNTR, WORKD, INFO ) c c\Arguments c IDO Integer. (INPUT/OUTPUT) c Reverse communication flag. c ------------------------------------------------------------- c IDO = 0: first call to the reverse communication interface c IDO = -1: compute Y = OP * X where c IPNTR(1) is the pointer into WORK for X, c IPNTR(2) is the pointer into WORK for Y. c This is for the restart phase to force the new c starting vector into the range of OP. c IDO = 1: compute Y = OP * X where c IPNTR(1) is the pointer into WORK for X, c IPNTR(2) is the pointer into WORK for Y, c IPNTR(3) is the pointer into WORK for B * X. c IDO = 2: compute Y = B * X where c IPNTR(1) is the pointer into WORK for X, c IPNTR(2) is the pointer into WORK for Y. c IDO = 99: done c ------------------------------------------------------------- c When the routine is used in the "shift-and-invert" mode, the c vector B * Q is already available and do not need to be c recompute in forming OP * Q. c c BMAT Character*1. (INPUT) c BMAT specifies the type of the matrix B that defines the c semi-inner product for the operator OP. See dnaupd. c B = 'I' -> standard eigenvalue problem A*x = lambda*x c B = 'G' -> generalized eigenvalue problem A*x = lambda*M**x c c N Integer. (INPUT) c Dimension of the eigenproblem. c c K Integer. (INPUT) c Current size of V and H. c c NP Integer. (INPUT) c Number of additional Arnoldi steps to take. c c NB Integer. (INPUT) c Blocksize to be used in the recurrence. c Only work for NB = 1 right now. The goal is to have a c program that implement both the block and non-block method. c c RESID Double precision array of length N. (INPUT/OUTPUT) c On INPUT: RESID contains the residual vector r_{k}. c On OUTPUT: RESID contains the residual vector r_{k+p}. c c RNORM Double precision scalar. (INPUT/OUTPUT) c B-norm of the starting residual on input. c B-norm of the updated residual r_{k+p} on output. c c V Double precision N by K+NP array. (INPUT/OUTPUT) c On INPUT: V contains the Arnoldi vectors in the first K c columns. c On OUTPUT: V contains the new NP Arnoldi vectors in the next c NP columns. The first K columns are unchanged. c c LDV Integer. (INPUT) c Leading dimension of V exactly as declared in the calling c program. c c H Double precision (K+NP) by (K+NP) array. (INPUT/OUTPUT) c H is used to store the generated upper Hessenberg matrix. c c LDH Integer. (INPUT) c Leading dimension of H exactly as declared in the calling c program. c c IPNTR Integer array of length 3. (OUTPUT) c Pointer to mark the starting locations in the WORK for c vectors used by the Arnoldi iteration. c ------------------------------------------------------------- c IPNTR(1): pointer to the current operand vector X. c IPNTR(2): pointer to the current result vector Y. c IPNTR(3): pointer to the vector B * X when used in the c shift-and-invert mode. X is the current operand. c ------------------------------------------------------------- c c WORKD Double precision work array of length 3*N. (REVERSE COMMUNICATION) c Distributed array to be used in the basic Arnoldi iteration c for reverse communication. The calling program should not c use WORKD as temporary workspace during the iteration !!!!!! c On input, WORKD(1:N) = B*RESID and is used to save some c computation at the first step. c c INFO Integer. (OUTPUT) c = 0: Normal exit. c > 0: Size of the spanning invariant subspace of OP found. c c\EndDoc c c----------------------------------------------------------------------- c c\BeginLib c c\Local variables: c xxxxxx real c c\References: c 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in c a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992), c pp 357-385. c 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly c Restarted Arnoldi Iteration", Rice University Technical Report c TR95-13, Department of Computational and Applied Mathematics. c c\Routines called: c dgetv0 ARPACK routine to generate the initial vector. c ivout ARPACK utility routine that prints integers. c arscnd ARPACK utility routine for timing. c dmout ARPACK utility routine that prints matrices c dvout ARPACK utility routine that prints vectors. c dlabad LAPACK routine that computes machine constants. c dlamch LAPACK routine that determines machine constants. c dlascl LAPACK routine for careful scaling of a matrix. c dlanhs LAPACK routine that computes various norms of a matrix. c dgemv Level 2 BLAS routine for matrix vector multiplication. c daxpy Level 1 BLAS that computes a vector triad. c dscal Level 1 BLAS that scales a vector. c dcopy Level 1 BLAS that copies one vector to another . c ddot Level 1 BLAS that computes the scalar product of two vectors. c dnrm2 Level 1 BLAS that computes the norm of a vector. 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.4' c c\SCCS Information: @(#) c FILE: naitr.F SID: 2.4 DATE OF SID: 8/27/96 RELEASE: 2 c c\Remarks c The algorithm implemented is: c c restart = .false. c Given V_{k} = [v_{1}, ..., v_{k}], r_{k}; c r_{k} contains the initial residual vector even for k = 0; c Also assume that rnorm = || B*r_{k} || and B*r_{k} are already c computed by the calling program. c c betaj = rnorm ; p_{k+1} = B*r_{k} ; c For j = k+1, ..., k+np Do c 1) if ( betaj < tol ) stop or restart depending on j. c ( At present tol is zero ) c if ( restart ) generate a new starting vector. c 2) v_{j} = r(j-1)/betaj; V_{j} = [V_{j-1}, v_{j}]; c p_{j} = p_{j}/betaj c 3) r_{j} = OP*v_{j} where OP is defined as in dnaupd c For shift-invert mode p_{j} = B*v_{j} is already available. c wnorm = || OP*v_{j} || c 4) Compute the j-th step residual vector. c w_{j} = V_{j}^T * B * OP * v_{j} c r_{j} = OP*v_{j} - V_{j} * w_{j} c H(:,j) = w_{j}; c H(j,j-1) = rnorm c rnorm = || r_(j) || c If (rnorm > 0.717*wnorm) accept step and go back to 1) c 5) Re-orthogonalization step: c s = V_{j}'*B*r_{j} c r_{j} = r_{j} - V_{j}*s; rnorm1 = || r_{j} || c alphaj = alphaj + s_{j}; c 6) Iterative refinement step: c If (rnorm1 > 0.717*rnorm) then c rnorm = rnorm1 c accept step and go back to 1) c Else c rnorm = rnorm1 c If this is the first time in step 6), go to 5) c Else r_{j} lies in the span of V_{j} numerically. c Set r_{j} = 0 and rnorm = 0; go to 1) c EndIf c End Do c c\EndLib c c----------------------------------------------------------------------- c subroutine dnaitr & (ido, bmat, n, k, np, nb, resid, rnorm, v, ldv, h, ldh, & ipntr, workd, info) c c %----------------------------------------------------% c | Include files for debugging and timing information | c %----------------------------------------------------% c include 'debug.h' include 'stat.h' c c %------------------% c | Scalar Arguments | c %------------------% c character bmat*1 integer ido, info, k, ldh, ldv, n, nb, np Double precision & rnorm c c %-----------------% c | Array Arguments | c %-----------------% c integer ipntr(3) Double precision & h(ldh,k+np), resid(n), v(ldv,k+np), workd(3*n) c c %------------% c | Parameters | c %------------% c Double precision & one, zero parameter (one = 1.0D+0, zero = 0.0D+0) c c %---------------% c | Local Scalars | c %---------------% c logical first, orth1, orth2, rstart, step3, step4 integer ierr, i, infol, ipj, irj, ivj, iter, itry, j, msglvl, & jj Double precision & betaj, ovfl, temp1, rnorm1, smlnum, tst1, ulp, unfl, & wnorm save first, orth1, orth2, rstart, step3, step4, & ierr, ipj, irj, ivj, iter, itry, j, msglvl, ovfl, & betaj, rnorm1, smlnum, ulp, unfl, wnorm c c %-----------------------% c | Local Array Arguments | c %-----------------------% c Double precision & xtemp(2) c c %----------------------% c | External Subroutines | c %----------------------% c external daxpy, dcopy, dscal, dgemv, dgetv0, dlabad, & dvout, dmout, ivout, arscnd c c %--------------------% c | External Functions | c %--------------------% c Double precision & ddot, dnrm2, dlanhs, dlamch external ddot, dnrm2, dlanhs, dlamch c c %---------------------% c | Intrinsic Functions | c %---------------------% c intrinsic abs, sqrt c c %-----------------% c | Data statements | c %-----------------% c data first / .true. / c c %-----------------------% c | Executable Statements | c %-----------------------% c if (first) then c c %-----------------------------------------% c | Set machine-dependent constants for the | c | the splitting and deflation criterion. | c | If norm(H) <= sqrt(OVFL), | c | overflow should not occur. | c | REFERENCE: LAPACK subroutine dlahqr | c %-----------------------------------------% c unfl = dlamch( 'safe minimum' ) ovfl = one / unfl call dlabad( unfl, ovfl ) ulp = dlamch( 'precision' ) smlnum = unfl*( n / ulp ) first = .false. end if c if (ido .eq. 0) then c c %-------------------------------% c | Initialize timing statistics | c | & message level for debugging | c %-------------------------------% c call arscnd (t0) msglvl = mnaitr c c %------------------------------% c | Initial call to this routine | c %------------------------------% c info = 0 step3 = .false. step4 = .false. rstart = .false. orth1 = .false. orth2 = .false. j = k + 1 ipj = 1 irj = ipj + n ivj = irj + n end if c c %-------------------------------------------------% c | When in reverse communication mode one of: | c | STEP3, STEP4, ORTH1, ORTH2, RSTART | c | will be .true. when .... | c | STEP3: return from computing OP*v_{j}. | c | STEP4: return from computing B-norm of OP*v_{j} | c | ORTH1: return from computing B-norm of r_{j+1} | c | ORTH2: return from computing B-norm of | c | correction to the residual vector. | c | RSTART: return from OP computations needed by | c | dgetv0. | c %-------------------------------------------------% c if (step3) go to 50 if (step4) go to 60 if (orth1) go to 70 if (orth2) go to 90 if (rstart) go to 30 c c %-----------------------------% c | Else this is the first step | c %-----------------------------% c c %--------------------------------------------------------------% c | | c | A R N O L D I I T E R A T I O N L O O P | c | | c | Note: B*r_{j-1} is already in WORKD(1:N)=WORKD(IPJ:IPJ+N-1) | c %--------------------------------------------------------------% 1000 continue c if (msglvl .gt. 1) then call ivout (logfil, 1, j, ndigit, & '_naitr: generating Arnoldi vector number') call dvout (logfil, 1, rnorm, ndigit, & '_naitr: B-norm of the current residual is') end if c c %---------------------------------------------------% c | STEP 1: Check if the B norm of j-th residual | c | vector is zero. Equivalent to determing whether | c | an exact j-step Arnoldi factorization is present. | c %---------------------------------------------------% c betaj = rnorm if (rnorm .gt. zero) go to 40 c c %---------------------------------------------------% c | Invariant subspace found, generate a new starting | c | vector which is orthogonal to the current Arnoldi | c | basis and continue the iteration. | c %---------------------------------------------------% c if (msglvl .gt. 0) then call ivout (logfil, 1, j, ndigit, & '_naitr: ****** RESTART AT STEP ******') end if c c %---------------------------------------------% c | ITRY is the loop variable that controls the | c | maximum amount of times that a restart is | c | attempted. NRSTRT is used by stat.h | c %---------------------------------------------% c betaj = zero nrstrt = nrstrt + 1 itry = 1 20 continue rstart = .true. ido = 0 30 continue c c %--------------------------------------% c | If in reverse communication mode and | c | RSTART = .true. flow returns here. | c %--------------------------------------% c call dgetv0 (ido, bmat, itry, .false., n, j, v, ldv, & resid, rnorm, ipntr, workd, ierr) if (ido .ne. 99) go to 9000 if (ierr .lt. 0) then itry = itry + 1 if (itry .le. 3) go to 20 c c %------------------------------------------------% c | Give up after several restart attempts. | c | Set INFO to the size of the invariant subspace | c | which spans OP and exit. | c %------------------------------------------------% c info = j - 1 call arscnd (t1) tnaitr = tnaitr + (t1 - t0) ido = 99 go to 9000 end if c 40 continue c c %---------------------------------------------------------% c | STEP 2: v_{j} = r_{j-1}/rnorm and p_{j} = p_{j}/rnorm | c | Note that p_{j} = B*r_{j-1}. In order to avoid overflow | c | when reciprocating a small RNORM, test against lower | c | machine bound. | c %---------------------------------------------------------% c call dcopy (n, resid, 1, v(1,j), 1) if (rnorm .ge. unfl) then temp1 = one / rnorm call dscal (n, temp1, v(1,j), 1) call dscal (n, temp1, workd(ipj), 1) else c c %-----------------------------------------% c | To scale both v_{j} and p_{j} carefully | c | use LAPACK routine SLASCL | c %-----------------------------------------% c call dlascl ('General', i, i, rnorm, one, n, 1, & v(1,j), n, infol) call dlascl ('General', i, i, rnorm, one, n, 1, & workd(ipj), n, infol) end if c c %------------------------------------------------------% c | STEP 3: r_{j} = OP*v_{j}; Note that p_{j} = B*v_{j} | c | Note that this is not quite yet r_{j}. See STEP 4 | c %------------------------------------------------------% c step3 = .true. nopx = nopx + 1 call arscnd (t2) call dcopy (n, v(1,j), 1, workd(ivj), 1) ipntr(1) = ivj ipntr(2) = irj ipntr(3) = ipj ido = 1 c c %-----------------------------------% c | Exit in order to compute OP*v_{j} | c %-----------------------------------% c go to 9000 50 continue c c %----------------------------------% c | Back from reverse communication; | c | WORKD(IRJ:IRJ+N-1) := OP*v_{j} | c | if step3 = .true. | c %----------------------------------% c call arscnd (t3) tmvopx = tmvopx + (t3 - t2) step3 = .false. c c %------------------------------------------% c | Put another copy of OP*v_{j} into RESID. | c %------------------------------------------% c call dcopy (n, workd(irj), 1, resid, 1) c c %---------------------------------------% c | STEP 4: Finish extending the Arnoldi | c | factorization to length j. | c %---------------------------------------% c call arscnd (t2) if (bmat .eq. 'G') then nbx = nbx + 1 step4 = .true. ipntr(1) = irj ipntr(2) = ipj ido = 2 c c %-------------------------------------% c | Exit in order to compute B*OP*v_{j} | c %-------------------------------------% c go to 9000 else if (bmat .eq. 'I') then call dcopy (n, resid, 1, workd(ipj), 1) end if 60 continue c c %----------------------------------% c | Back from reverse communication; | c | WORKD(IPJ:IPJ+N-1) := B*OP*v_{j} | c | if step4 = .true. | c %----------------------------------% c if (bmat .eq. 'G') then call arscnd (t3) tmvbx = tmvbx + (t3 - t2) end if c step4 = .false. c c %-------------------------------------% c | The following is needed for STEP 5. | c | Compute the B-norm of OP*v_{j}. | c %-------------------------------------% c if (bmat .eq. 'G') then wnorm = ddot (n, resid, 1, workd(ipj), 1) wnorm = sqrt(abs(wnorm)) else if (bmat .eq. 'I') then wnorm = dnrm2(n, resid, 1) end if c c %-----------------------------------------% c | Compute the j-th residual corresponding | c | to the j step factorization. | c | Use Classical Gram Schmidt and compute: | c | w_{j} <- V_{j}^T * B * OP * v_{j} | c | r_{j} <- OP*v_{j} - V_{j} * w_{j} | c %-----------------------------------------% c c c %------------------------------------------% c | Compute the j Fourier coefficients w_{j} | c | WORKD(IPJ:IPJ+N-1) contains B*OP*v_{j}. | c %------------------------------------------% c call dgemv ('T', n, j, one, v, ldv, workd(ipj), 1, & zero, h(1,j), 1) c c %--------------------------------------% c | Orthogonalize r_{j} against V_{j}. | c | RESID contains OP*v_{j}. See STEP 3. | c %--------------------------------------% c call dgemv ('N', n, j, -one, v, ldv, h(1,j), 1, & one, resid, 1) c if (j .gt. 1) h(j,j-1) = betaj c call arscnd (t4) c orth1 = .true. c call arscnd (t2) if (bmat .eq. 'G') then nbx = nbx + 1 call dcopy (n, resid, 1, workd(irj), 1) ipntr(1) = irj ipntr(2) = ipj ido = 2 c c %----------------------------------% c | Exit in order to compute B*r_{j} | c %----------------------------------% c go to 9000 else if (bmat .eq. 'I') then call dcopy (n, resid, 1, workd(ipj), 1) end if 70 continue c c %---------------------------------------------------% c | Back from reverse communication if ORTH1 = .true. | c | WORKD(IPJ:IPJ+N-1) := B*r_{j}. | c %---------------------------------------------------% c if (bmat .eq. 'G') then call arscnd (t3) tmvbx = tmvbx + (t3 - t2) end if c orth1 = .false. c c %------------------------------% c | Compute the B-norm of r_{j}. | c %------------------------------% c if (bmat .eq. 'G') then rnorm = ddot (n, resid, 1, workd(ipj), 1) rnorm = sqrt(abs(rnorm)) else if (bmat .eq. 'I') then rnorm = dnrm2(n, resid, 1) end if c c %-----------------------------------------------------------% c | STEP 5: Re-orthogonalization / Iterative refinement phase | c | Maximum NITER_ITREF tries. | c | | c | s = V_{j}^T * B * r_{j} | c | r_{j} = r_{j} - V_{j}*s | c | alphaj = alphaj + s_{j} | c | | c | The stopping criteria used for iterative refinement is | c | discussed in Parlett's book SEP, page 107 and in Gragg & | c | Reichel ACM TOMS paper; Algorithm 686, Dec. 1990. | c | Determine if we need to correct the residual. The goal is | c | to enforce ||v(:,1:j)^T * r_{j}|| .le. eps * || r_{j} || | c | The following test determines whether the sine of the | c | angle between OP*x and the computed residual is less | c | than or equal to 0.717. | c %-----------------------------------------------------------% c if (rnorm .gt. 0.717*wnorm) go to 100 iter = 0 nrorth = nrorth + 1 c c %---------------------------------------------------% c | Enter the Iterative refinement phase. If further | c | refinement is necessary, loop back here. The loop | c | variable is ITER. Perform a step of Classical | c | Gram-Schmidt using all the Arnoldi vectors V_{j} | c %---------------------------------------------------% c 80 continue c if (msglvl .gt. 2) then xtemp(1) = wnorm xtemp(2) = rnorm call dvout (logfil, 2, xtemp, ndigit, & '_naitr: re-orthonalization; wnorm and rnorm are') call dvout (logfil, j, h(1,j), ndigit, & '_naitr: j-th column of H') end if c c %----------------------------------------------------% c | Compute V_{j}^T * B * r_{j}. | c | WORKD(IRJ:IRJ+J-1) = v(:,1:J)'*WORKD(IPJ:IPJ+N-1). | c %----------------------------------------------------% c call dgemv ('T', n, j, one, v, ldv, workd(ipj), 1, & zero, workd(irj), 1) c c %---------------------------------------------% c | Compute the correction to the residual: | c | r_{j} = r_{j} - V_{j} * WORKD(IRJ:IRJ+J-1). | c | The correction to H is v(:,1:J)*H(1:J,1:J) | c | + v(:,1:J)*WORKD(IRJ:IRJ+J-1)*e'_j. | c %---------------------------------------------% c call dgemv ('N', n, j, -one, v, ldv, workd(irj), 1, & one, resid, 1) call daxpy (j, one, workd(irj), 1, h(1,j), 1) c orth2 = .true. call arscnd (t2) if (bmat .eq. 'G') then nbx = nbx + 1 call dcopy (n, resid, 1, workd(irj), 1) ipntr(1) = irj ipntr(2) = ipj ido = 2 c c %-----------------------------------% c | Exit in order to compute B*r_{j}. | c | r_{j} is the corrected residual. | c %-----------------------------------% c go to 9000 else if (bmat .eq. 'I') then call dcopy (n, resid, 1, workd(ipj), 1) end if 90 continue c c %---------------------------------------------------% c | Back from reverse communication if ORTH2 = .true. | c %---------------------------------------------------% c if (bmat .eq. 'G') then call arscnd (t3) tmvbx = tmvbx + (t3 - t2) end if c c %-----------------------------------------------------% c | Compute the B-norm of the corrected residual r_{j}. | c %-----------------------------------------------------% c if (bmat .eq. 'G') then rnorm1 = ddot (n, resid, 1, workd(ipj), 1) rnorm1 = sqrt(abs(rnorm1)) else if (bmat .eq. 'I') then rnorm1 = dnrm2(n, resid, 1) end if c if (msglvl .gt. 0 .and. iter .gt. 0) then call ivout (logfil, 1, j, ndigit, & '_naitr: Iterative refinement for Arnoldi residual') if (msglvl .gt. 2) then xtemp(1) = rnorm xtemp(2) = rnorm1 call dvout (logfil, 2, xtemp, ndigit, & '_naitr: iterative refinement ; rnorm and rnorm1 are') end if end if c c %-----------------------------------------% c | Determine if we need to perform another | c | step of re-orthogonalization. | c %-----------------------------------------% c if (rnorm1 .gt. 0.717*rnorm) then c c %---------------------------------------% c | No need for further refinement. | c | The cosine of the angle between the | c | corrected residual vector and the old | c | residual vector is greater than 0.717 | c | In other words the corrected residual | c | and the old residual vector share an | c | angle of less than arcCOS(0.717) | c %---------------------------------------% c rnorm = rnorm1 c else c c %-------------------------------------------% c | Another step of iterative refinement step | c | is required. NITREF is used by stat.h | c %-------------------------------------------% c nitref = nitref + 1 rnorm = rnorm1 iter = iter + 1 if (iter .le. 1) go to 80 c c %-------------------------------------------------% c | Otherwise RESID is numerically in the span of V | c %-------------------------------------------------% c do 95 jj = 1, n resid(jj) = zero 95 continue rnorm = zero end if c c %----------------------------------------------% c | Branch here directly if iterative refinement | c | wasn't necessary or after at most NITER_REF | c | steps of iterative refinement. | c %----------------------------------------------% c 100 continue c rstart = .false. orth2 = .false. c call arscnd (t5) titref = titref + (t5 - t4) c c %------------------------------------% c | STEP 6: Update j = j+1; Continue | c %------------------------------------% c j = j + 1 if (j .gt. k+np) then call arscnd (t1) tnaitr = tnaitr + (t1 - t0) ido = 99 do 110 i = max(1,k), k+np-1 c c %--------------------------------------------% c | Check for splitting and deflation. | c | Use a standard test as in the QR algorithm | c | REFERENCE: LAPACK subroutine dlahqr | c %--------------------------------------------% c tst1 = abs( h( i, i ) ) + abs( h( i+1, i+1 ) ) if( tst1.eq.zero ) & tst1 = dlanhs( '1', k+np, h, ldh, workd(n+1) ) if( abs( h( i+1,i ) ).le.max( ulp*tst1, smlnum ) ) & h(i+1,i) = zero 110 continue c if (msglvl .gt. 2) then call dmout (logfil, k+np, k+np, h, ldh, ndigit, & '_naitr: Final upper Hessenberg matrix H of order K+NP') end if c go to 9000 end if c c %--------------------------------------------------------% c | Loop back to extend the factorization by another step. | c %--------------------------------------------------------% c go to 1000 c c %---------------------------------------------------------------% c | | c | E N D O F M A I N I T E R A T I O N L O O P | c | | c %---------------------------------------------------------------% c 9000 continue return c c %---------------% c | End of dnaitr | c %---------------% c end
bsd-3-clause
Vitancourt/gcc
gcc/testsuite/gfortran.dg/namelist_11.f
174
1620
c { dg-do run { target fd_truncate } } c This program tests: namelist comment, a blank line before the nameilist name, the namelist name, c a scalar qualifier, various combinations of space, comma and lf delimiters, f-formats, e-formats c a blank line within the data read, nulls, a range qualifier, a new object name before end of data c and an integer read. It also tests that namelist output can be re-read by namelist input. c provided by Paul Thomas - pault@gcc.gnu.org program namelist_1 REAL x(10) REAL(kind=8) xx integer ier namelist /mynml/ x, xx do i = 1 , 10 x(i) = -1 end do x(6) = 6.0 x(10) = 10.0 xx = 0d0 open (10,status="scratch") write (10, *) "!mynml" write (10, *) "" write (10, *) "&gf /" write (10, *) "&mynml x(7) =+99.0e0 x=1.0, 2.0 ," write (10, *) " 2*3.0, ,, 7.0e0,+0.08e+02 !comment" write (10, *) "" write (10, *) " 9000e-3 x(4:5)=4 ,5 " write (10, *) " x=,,3.0, xx=10d0 /" rewind (10) read (10, nml=mynml, IOSTAT=ier) if (ier.ne.0) call abort rewind (10) do i = 1 , 10 if ( abs( x(i) - real(i) ) .gt. 1e-8 ) call abort end do if ( abs( xx - 10d0 ) .gt. 1e-8 ) call abort write (10, nml=mynml, iostat=ier) if (ier.ne.0) call abort rewind (10) read (10, NML=mynml, IOSTAT=ier) if (ier.ne.0) call abort close (10) do i = 1 , 10 if ( abs( x(i) - real(i) ) .gt. 1e-8 ) call abort end do if ( abs( xx - 10d0 ) .gt. 1e-8 ) call abort end program
gpl-2.0
Vitancourt/gcc
gcc/testsuite/gfortran.dg/nint_2.f90
94
1339
! Test that NINT gives right results even in corner cases ! ! PR 31202 ! http://gcc.gnu.org/ml/fortran/2005-04/msg00139.html ! ! { dg-do run } ! { dg-xfail-run-if "PR 33271, math library bug" { powerpc-ibm-aix* powerpc-*-linux* powerpc64-*-linux* *-*-mingw* } { "-O0" } { "" } } ! Note that this doesn't fail on powerpc64le-*-linux*. real(kind=8) :: a integer(kind=8) :: i1, i2 real :: b integer :: j1, j2 a = nearest(0.5_8,-1.0_8) i2 = nint(nearest(0.5_8,-1.0_8)) i1 = nint(a) if (i1 /= 0 .or. i2 /= 0) call abort a = 0.5_8 i2 = nint(0.5_8) i1 = nint(a) if (i1 /= 1 .or. i2 /= 1) call abort a = nearest(0.5_8,1.0_8) i2 = nint(nearest(0.5_8,1.0_8)) i1 = nint(a) if (i1 /= 1 .or. i2 /= 1) call abort b = nearest(0.5,-1.0) j2 = nint(nearest(0.5,-1.0)) j1 = nint(b) if (j1 /= 0 .or. j2 /= 0) call abort b = 0.5 j2 = nint(0.5) j1 = nint(b) if (j1 /= 1 .or. j2 /= 1) call abort b = nearest(0.5,1.0) j2 = nint(nearest(0.5,1.0)) j1 = nint(b) if (j1 /= 1 .or. j2 /= 1) call abort a = 4503599627370497.0_8 i1 = nint(a,kind=8) i2 = nint(4503599627370497.0_8,kind=8) if (i1 /= i2 .or. i1 /= 4503599627370497_8) call abort a = -4503599627370497.0_8 i1 = nint(a,kind=8) i2 = nint(-4503599627370497.0_8,kind=8) if (i1 /= i2 .or. i1 /= -4503599627370497_8) call abort end
gpl-2.0
gdooper/scipy
scipy/special/cdflib/dzror.f
106
7759
SUBROUTINE dzror(status,x,fx,xlo,xhi,qleft,qhi) C********************************************************************** C C SUBROUTINE DZROR(STATUS, X, FX, XLO, XHI, QLEFT, QHI) C Double precision ZeRo of a function -- Reverse Communication C C C Function C C C Performs the zero finding. STZROR must have been called before C this routine in order to set its parameters. C C C Arguments C C C STATUS <--> At the beginning of a zero finding problem, STATUS C should be set to 0 and ZROR invoked. (The value C of other parameters will be ignored on this call.) C C When ZROR needs the function evaluated, it will set C STATUS to 1 and return. The value of the function C should be set in FX and ZROR again called without C changing any of its other parameters. C C When ZROR has finished without error, it will return C with STATUS 0. In that case (XLO,XHI) bound the answe C C If ZROR finds an error (which implies that F(XLO)-Y an C F(XHI)-Y have the same sign, it returns STATUS -1. In C this case, XLO and XHI are undefined. C INTEGER STATUS C C X <-- The value of X at which F(X) is to be evaluated. C DOUBLE PRECISION X C C FX --> The value of F(X) calculated when ZROR returns with C STATUS = 1. C DOUBLE PRECISION FX C C XLO <-- When ZROR returns with STATUS = 0, XLO bounds the C inverval in X containing the solution below. C DOUBLE PRECISION XLO C C XHI <-- When ZROR returns with STATUS = 0, XHI bounds the C inverval in X containing the solution above. C DOUBLE PRECISION XHI C C QLEFT <-- .TRUE. if the stepping search terminated unsucessfully C at XLO. If it is .FALSE. the search terminated C unsucessfully at XHI. C QLEFT is LOGICAL C C QHI <-- .TRUE. if F(X) .GT. Y at the termination of the C search and .FALSE. if F(X) .LT. Y at the C termination of the search. C QHI is LOGICAL C C********************************************************************** C .. Scalar Arguments .. DOUBLE PRECISION fx,x,xhi,xlo,zabstl,zreltl,zxhi,zxlo INTEGER status LOGICAL qhi,qleft C .. C .. Save statement .. SAVE C .. C .. Local Scalars .. DOUBLE PRECISION a,abstol,b,c,d,fa,fb,fc,fd,fda,fdb,m,mb,p,q, + reltol,tol,w,xxhi,xxlo,zx INTEGER ext,i99999 LOGICAL first,qrzero C .. C .. Intrinsic Functions .. INTRINSIC abs,max,sign C .. C .. Statement Functions .. DOUBLE PRECISION ftol C .. C .. Statement Function definitions .. ftol(zx) = 0.5D0*max(abstol,reltol*abs(zx)) C .. C .. Executable Statements .. IF (status.GT.0) GO TO 280 xlo = xxlo xhi = xxhi b = xlo x = xlo C GET-FUNCTION-VALUE ASSIGN 10 TO i99999 GO TO 270 10 fb = fx xlo = xhi a = xlo x = xlo C GET-FUNCTION-VALUE ASSIGN 20 TO i99999 GO TO 270 C C Check that F(ZXLO) < 0 < F(ZXHI) or C F(ZXLO) > 0 > F(ZXHI) C 20 IF (.NOT. (fb.LT.0.0D0)) GO TO 40 IF (.NOT. (fx.LT.0.0D0)) GO TO 30 status = -1 qleft = fx .LT. fb qhi = .FALSE. RETURN 30 CONTINUE 40 IF (.NOT. (fb.GT.0.0D0)) GO TO 60 IF (.NOT. (fx.GT.0.0D0)) GO TO 50 status = -1 qleft = fx .GT. fb qhi = .TRUE. RETURN 50 CONTINUE 60 fa = fx C first = .TRUE. 70 c = a fc = fa ext = 0 80 IF (.NOT. (abs(fc).LT.abs(fb))) GO TO 100 IF (.NOT. (c.NE.a)) GO TO 90 d = a fd = fa 90 a = b fa = fb xlo = c b = xlo fb = fc c = a fc = fa 100 tol = ftol(xlo) m = (c+b)*.5D0 mb = m - b IF (.NOT. (abs(mb).GT.tol)) GO TO 240 IF (.NOT. (ext.GT.3)) GO TO 110 w = mb GO TO 190 110 tol = sign(tol,mb) p = (b-a)*fb IF (.NOT. (first)) GO TO 120 q = fa - fb first = .FALSE. GO TO 130 120 fdb = (fd-fb)/ (d-b) fda = (fd-fa)/ (d-a) p = fda*p q = fdb*fa - fda*fb 130 IF (.NOT. (p.LT.0.0D0)) GO TO 140 p = -p q = -q 140 IF (ext.EQ.3) p = p*2.0D0 IF (.NOT. ((p*1.0D0).EQ.0.0D0.OR.p.LE. (q*tol))) GO TO 150 w = tol GO TO 180 150 IF (.NOT. (p.LT. (mb*q))) GO TO 160 w = p/q GO TO 170 160 w = mb 170 CONTINUE 180 CONTINUE 190 d = a fd = fa a = b fa = fb b = b + w xlo = b x = xlo C GET-FUNCTION-VALUE ASSIGN 200 TO i99999 GO TO 270 200 fb = fx IF (.NOT. ((fc*fb).GE.0.0D0)) GO TO 210 GO TO 70 210 IF (.NOT. (w.EQ.mb)) GO TO 220 ext = 0 GO TO 230 220 ext = ext + 1 230 GO TO 80 240 xhi = c qrzero = (fc.GE.0.0D0 .AND. fb.LE.0.0D0) .OR. + (fc.LT.0.0D0 .AND. fb.GE.0.0D0) IF (.NOT. (qrzero)) GO TO 250 status = 0 GO TO 260 250 status = -1 260 RETURN ENTRY dstzr(zxlo,zxhi,zabstl,zreltl) C********************************************************************** C C SUBROUTINE DSTZR( XLO, XHI, ABSTOL, RELTOL ) C Double precision SeT ZeRo finder - Reverse communication version C C C Function C C C C Sets quantities needed by ZROR. The function of ZROR C and the quantities set is given here. C C Concise Description - Given a function F C find XLO such that F(XLO) = 0. C C More Precise Description - C C Input condition. F is a double precision function of a single C double precision argument and XLO and XHI are such that C F(XLO)*F(XHI) .LE. 0.0 C C If the input condition is met, QRZERO returns .TRUE. C and output values of XLO and XHI satisfy the following C F(XLO)*F(XHI) .LE. 0. C ABS(F(XLO) .LE. ABS(F(XHI) C ABS(XLO-XHI) .LE. TOL(X) C where C TOL(X) = MAX(ABSTOL,RELTOL*ABS(X)) C C If this algorithm does not find XLO and XHI satisfying C these conditions then QRZERO returns .FALSE. This C implies that the input condition was not met. C C C Arguments C C C XLO --> The left endpoint of the interval to be C searched for a solution. C XLO is DOUBLE PRECISION C C XHI --> The right endpoint of the interval to be C for a solution. C XHI is DOUBLE PRECISION C C ABSTOL, RELTOL --> Two numbers that determine the accuracy C of the solution. See function for a C precise definition. C ABSTOL is DOUBLE PRECISION C RELTOL is DOUBLE PRECISION C C C Method C C C Algorithm R of the paper 'Two Efficient Algorithms with C Guaranteed Convergence for Finding a Zero of a Function' C by J. C. P. Bus and T. J. Dekker in ACM Transactions on C Mathematical Software, Volume 1, no. 4 page 330 C (Dec. '75) is employed to find the zero of F(X)-Y. C C********************************************************************** xxlo = zxlo xxhi = zxhi abstol = zabstl reltol = zreltl RETURN STOP '*** EXECUTION FLOWING INTO FLECS PROCEDURES ***' C TO GET-FUNCTION-VALUE 270 status = 1 RETURN 280 CONTINUE GO TO i99999 END
bsd-3-clause
Vitancourt/gcc
gcc/testsuite/gfortran.dg/pr45578.f90
181
1574
! { dg-do run } !*==CENTCM.spg processed by SPAG 6.55Dc at 09:26 on 23 Sep 2005 SUBROUTINE CENTCM IMPLICIT DOUBLE PRECISION(A-H,O-Z) PARAMETER (NM=16384) PARAMETER (NG=100) PARAMETER (NH=100) PARAMETER (MU=20) PARAMETER (NL=1) PARAMETER (LL=10*NM) PARAMETER (KP=2001,KR=2001,KG=2001) COMMON /LCS / X0(3,-2:NM) , X(3,-2:NM,5) , XIN(3,-2:NM) COMMON /MOLEC / LPBc(3) , MOLsp , MOLsa , NBX , NBY , NBZ , NPLa ,& & LPBcsm cm1 = 0.D0 cm2 = 0.D0 cm3 = 0.D0 DO i = 1 , MOLsa cm1 = cm1 + X0(1,i) cm2 = cm2 + X0(2,i) cm3 = cm3 + X0(3,i) ENDDO cm1 = cm1/MOLsa cm2 = cm2/MOLsa cm3 = cm3/MOLsa IF ( (cm1.EQ.0.D0) .AND. (cm2.EQ.0.D0) .AND. (cm3.EQ.0.D0) ) & & RETURN DO i = 1 , MOLsa X0(1,i) = X0(1,i) - cm1 X0(2,i) = X0(2,i) - cm2 X0(3,i) = X0(3,i) - cm3 XIN(1,i) = XIN(1,i) - cm1 XIN(2,i) = XIN(2,i) - cm2 XIN(3,i) = XIN(3,i) - cm3 ENDDO CONTINUE END PROGRAM test IMPLICIT DOUBLE PRECISION(A-H,O-Z) PARAMETER (NM=16384) PARAMETER (NG=100) PARAMETER (NH=100) PARAMETER (MU=20) PARAMETER (NL=1) PARAMETER (LL=10*NM) PARAMETER (KP=2001,KR=2001,KG=2001) COMMON /LCS / X0(3,-2:NM) , X(3,-2:NM,5) , XIN(3,-2:NM) COMMON /MOLEC / LPBc(3) , MOLsp , MOLsa , NBX , NBY , NBZ , NPLa ,& & LPBcsm MOLsa = 10 X0 = 1. CALL CENTCM END
gpl-2.0
Vitancourt/gcc
gcc/testsuite/gfortran.dg/coarray_39.f90
88
1944
! { dg-do compile } ! { dg-options "-fcoarray=single" } ! ! Valid code - but currently not implemented for -fcoarray=lib; single okay ! subroutine one implicit none type t integer, allocatable :: a integer :: b end type t type t2 type(t), allocatable :: caf2[:] end type t2 type(t), save :: caf[*],x type(t2) :: y x = caf[4] x%a = caf[4]%a x%b = caf[4]%a x = y%caf2[5] x%a = y%caf2[4]%a x%b = y%caf2[4]%b end subroutine one subroutine two implicit none type t integer, pointer :: a integer :: b end type t type t2 type(t), allocatable :: caf2[:] end type t2 type(t), save :: caf[*],x type(t2) :: y x = caf[4] x%a = caf[4]%a x%b = caf[4]%b x = y%caf2[5] x%a = y%caf2[4]%a x%b = y%caf2[4]%b end subroutine two subroutine three implicit none type t integer :: b end type t type t2 type(t), allocatable :: caf2(:)[:] end type t2 type(t), save :: caf(10)[*] integer :: x(10) type(t2) :: y x(1) = caf(2)[4]%b x(:) = caf(:)[4]%b x(1) = y%caf2(2)[4]%b x(:) = y%caf2(:)[4]%b end subroutine three subroutine four implicit none type t integer, allocatable :: a integer :: b end type t type t2 class(t), allocatable :: caf2[:] end type t2 class(t), allocatable :: caf[:] type(t) :: x type(t2) :: y x = caf[4] x%a = caf[4]%a x%b = caf[4]%b x = y%caf2[5] x%a = y%caf2[4]%a x%b = y%caf2[4]%b end subroutine four subroutine five implicit none type t integer, pointer :: a integer :: b end type t type t2 class(t), allocatable :: caf2[:] end type t2 class(t), save, allocatable :: caf[:] type(t) :: x type(t2) :: y x = caf[4] x%a = caf[4]%a x%b = caf[4]%b x = y%caf2[5] x%a = y%caf2[4]%a x%b = y%caf2[4]%b end subroutine five subroutine six implicit none type t integer :: b end type t type t2 class(t), allocatable :: caf2(:)[:] end type t2 class(t), save, allocatable :: caf(:)[:] integer :: x(10) type(t2) :: y x(1) = caf(2)[4]%b x(:) = caf(:)[4]%b x(1) = y%caf2(2)[4]%b x(:) = y%caf2(:)[4]%b end subroutine six
gpl-2.0
Vitancourt/gcc
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
Vitancourt/gcc
gcc/testsuite/gfortran.dg/io_constraints_1.f90
155
2257
! { dg-do compile } ! { dg-options "-std=f95" } ! Part I of the test of the IO constraints patch, which fixes PRs: ! PRs 25053, 25063, 25064, 25066, 25067, 25068, 25069, 25307 and 20862. ! ! Contributed by Paul Thomas <pault@gcc.gnu.org> ! module fails 2000 format (1h , 2i6) ! { dg-error "Format statement in module" } end module fails module global integer :: modvar namelist /NL/ modvar contains subroutine foo (i) integer :: i write (*, 100) i 100 format (1h , "i=", i6) ! { dg-warning "The H format specifier at ... is a Fortran 95 deleted feature" } end subroutine foo end module global use global integer :: a,b, c(20) integer(8) :: ierr character(80) :: buffer(3) ! Appending to a USE associated namelist is an extension. NAMELIST /NL/ a,b ! { dg-error "already is USE associated" } a=1 ; b=2 !9.2.2.1: write(c, *) a, b ! { dg-error "array" } !Was correctly picked up before patch. write(buffer((/3,1,2/)), *) a, b ! { dg-error "vector subscript" } !9.2.2.2 and one of 9.4.1 !________________________ write(6, NML=NL, FMT = '(i6)') ! { dg-error "group name and format" } write(6, NML=NL, FMT = 200) ! { dg-error "group name and format" } !9.4.1 !_____ ! ! R912 !Was correctly picked up before patch. write(6, NML=NL, iostat = ierr) ! { dg-error "requires default INTEGER" } ! Constraints !Was correctly picked up before patch. write(1, fmt='(i6)', end = 100) a ! { dg-error "END tag" } !Was correctly picked up before patch. write(1, fmt='(i6)', eor = 100) a ! { dg-error "EOR tag" } !Was correctly picked up before patch. write(1, fmt='(i6)', size = b) a ! { dg-error "SIZE= specifier not allowed" } READ(1, fmt='(i6)', end = 900) a ! { dg-error "not defined" } READ(1, fmt='(i6)', eor = 900, advance='NO') a ! { dg-error "not defined" } READ(1, fmt='(i6)', ERR = 900) a ! { dg-error "not defined" } !Was correctly picked up before patch. READ(1, fmt=800) a ! { dg-error "not defined" } 100 continue 200 format (2i6) END
gpl-2.0
svn2github/pyopt
pyOpt/pyFILTERSD/source/densel.f
2
30645
christen this file denseL.f c Copyright (C) 1996 Roger Fletcher c Current version dated 4 October 2011 c THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC c LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM c CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT c***************** dense matrix routines for manipulating L ******************** c *************************************************************** c Basis matrix routines for bqpd with dense matrices (block form) c *************************************************************** c These routines form and update L-Implicit-U factors LPB=U of a matrix B c whose columns are the normal vectors of the active constraints. In this c method only the unit lower triangular matrix L and the diagonal of U (in c addition to the row permutation P) is stored. B is represented in block form c | A_1 0 | where the first m1 columns (A_1 and A_2) come from the c | A_2 I | general constraint normals (columns of the matrix A in bqpd) c and the remaining unit columns come from simple bounds. The matrix A may be c specified in either dense or sparse format and the user is referred to the c files denseA.f or sparseA.f. About m1*m1/2 locations are required to store c L-Implicit-U factors of B. The user MUST supply an upper bound on m1 by c setting mxm1 in the labelled common block c common/mxm1c/mxm1 c Setting mxm1=min(m+1,n) is always sufficient. c Workspace c ********* c denseL.f requires c mxm1*(mxm1+1)/2+3*n+mxm1 locations of real workspace, and c n+mxm1+n+m locations of integer workspace c These are stored at the end of the workspace arrays ws and lws in bqpd. c The user MUST set the lengths of these arrays in mxws and mxlws in c common/wsc/kk,ll,kkk,lll,mxws,mxlws c along with the values kk and ll of space to be used by gdotx. c Other information c ***************** c L-Implicit-U factors are updated by a variant of the Fletcher-Matthews c method, which has proved very reliable in practice. The method is described c in the reference c Fletcher R., Dense Factors of Sparse Matrices, in "Approximation Theory c and Optimization. Tributes to M.J.D. Powell", (M.D. Buhmann and A. Iserles, c eds), Cambridge University Press (1997), pp. 145-166. c Steepest edge coefficients e(i) are also updated in these routines c The file contains routines for solving systems with B or its transpose c which might be of use in association with bqpd. These routines are c documented below. subroutine start_up(n,nm,nmi,a,la,nk,e,ls,aa,ll,mode,ifail) implicit double precision (a-h,r-z), integer (i-q) dimension a(*),la(*),e(*),ls(*),aa(*),ll(*) common/noutc/nout common/wsc/kk,ll_,kkk,lll,mxws,mxlws common/epsc/eps,tol,emin common/densec/ns,ns1,nt,nt1,nu,nu1,mx1,lc,lc1,li,li1 common/factorc/m0,m1,mm0,mm,mp,mq common/refactorc/nup,nfreq common/mxm1c/mxm1 if(mxm1.le.0)then write(nout,*)'mxm1 =',mxm1,' is not set correctly' ifail=7 return endif ns=kk+kkk+mxm1*(mxm1+1)/2+3*n+mxm1 nt=ll_+lll+n+mxm1+nmi if(ns.gt.mxws.or.nt.gt.mxlws)then write(nout,*)'not enough real (ws) or integer (lws) workspace' write(nout,*)'you give values for mxws and mxlws as',mxws,mxlws write(nout,*)'minimum values for mxws and mxlws are',ns,nt ifail=7 return endif nup=0 small=max(1.D1*tol,sqrt(eps)) smallish=max(eps/tol,1.D1*small) c set storage map for dense factors ns=mxm1*(mxm1+1)/2 ns1=ns+1 nt=ns+n nt1=nt+1 nu=nt+n nu1=nu+1 mx1=nu1+n lc=n lc1=lc+1 li=lc+mxm1 li1=li+1 c write(nout,*)'ls',(ls(ij),ij=1,nk) c write(nout,*)'ls',(ls(ij),ij=nm+1,nmi) if(mode.ge.3)then call re_factor(n,nm,a,la,aa,aa(ns1),aa(nt1),ll,ll(lc1),ll(li1)) call check_L(n,aa,ifail) if(ifail.eq.1)then mode=2 goto1 endif if(nk.eq.n)return c reset ls from e do j=1,nk i=-ls(j) if(i.gt.0)e(i)=-e(i) enddo j=0 nk=nmi do i=1,nmi if(e(i).ne.0.D0)then j=j+1 if(e(i).gt.0.D0)then ls(j)=i else ls(j)=-i e(i)=-e(i) endif else ls(nk)=i nk=nk-1 endif enddo if(j.ne.n)then write(nout,*)'malfunction in reset sequence in start_up' stop endif ifail=0 return endif 1 continue if(emin.eq.0.D0)then c set a lower bound on e(i) emin=1.D0 do i=1,nmi-n emin=max(emin,ailen(n,a,la,i)) enddo emin=1.D0/emin endif do i=1,n e(i)=1.D0 ll(i)=i enddo do i=n+1,nmi e(i)=0.D0 ll(li+i)=0 enddo c shift designated bounds to end nn=n do j=nk,1,-1 i=abs(ls(j)) if(i.eq.0.or.i.gt.nmi)then write(nout,*) * 'ls(j) is zero, or greater in modulus than n+m, for j =',j ifail=4 return endif if(i.le.n)then ls(j)=ls(nk) nk=nk-1 call iexch(ll(nn),ll(i)) nn=nn-1 endif enddo do i=1,n ll(li+ll(i))=i enddo m0=(max(mxm1-nk,0))/2 mm0=m0*(m0+1)/2 m1=0 mm=mm0 j=1 2 continue if(j.gt.nk)goto3 q=abs(ls(j)) c extend factors call aqsol(n,a,la,q,aa,aa(nt1),aa(mx1),aa,ll,ll(lc1),ll(li1)) m1p=m1+1 call linf(nn-m1,aa(nt+m1p),z,iz) iz=iz+m1 if(z.le.tol)then c write(nout,*)'reject c/s',q nk=nk-1 do ij=j,nk ls(ij)=ls(ij+1) enddo goto2 endif if(m1p.gt.mxm1)then write(nout,*)'mxm1 =',mxm1,' is insufficient' ifail=7 return endif if(iz.gt.m1p)then c pivot interchange ll(li+ll(m1p))=iz call iexch(ll(m1p),ll(iz)) call rexch(aa(nt+m1p),aa(nt+iz)) ll(li+ll(m1p))=m1p endif p=ll(m1p) tp=aa(nt+m1p) call eptsol(n,a,la,p,a,aa,aa(ns1),aa(nt1),ll,ll(lc1),ll(li1)) aa(ns+m1p)=1.D0 c update steepest edge coefficients ep=e(p) c eq=ep/tp eq=abs(ep/tp) tp_=tp/ep tpsq=tp_**2 call aqsol(n,a,la,-1,a,aa(nu1),aa(mx1),aa,ll,ll(lc1),ll(li1)) do i=1,m1p aa(nu+i)=aa(ns+i)/ep enddo do i=m1p+1,n aa(nu+i)=0.D0 enddo e(p)=0.D0 do i=1,nmi if(e(i).gt.0.D0)then ij=ll(li+i) ei=e(i) c ti=aa(nt+ij)*eq/ei c e(i)=max(emin,ei*sqrt(max(1.D0-ti*(2.D0*aa(nu+ij)/ei-ti),0.D0))) ti=aa(nt+j)/ei e(i)=max(emin, * ei*sqrt(max(tpsq-ti*(2.D0*tp*aa(nu+j)/ei-ti),0.D0))*eq) endif enddo c e(q)=max(emin,abs(eq)) e(q)=max(emin,eq) m1=m1p mm=mm+m0 do ij=1,m1 aa(mm+ij)=aa(ns+ij) enddo ll(lc+m1)=q ll(li+q)=m1 mm=mm+m1 aa(mm)=tp j=j+1 goto2 3 continue c complete the vector ls do i=nn+1,n nk=nk+1 ls(nk)=ll(i) enddo j=nk do i=m1+1,nn j=j+1 ls(j)=ll(i) enddo do j=nm+1,nmi e(abs(ls(j)))=1.D0 enddo j=n do i=1,nmi if(e(i).eq.0.D0)then j=j+1 ls(j)=i endif enddo do j=nm+1,nmi e(abs(ls(j)))=0.D0 enddo if(mode.gt.2)then z=sqrt(eps) do j=1,n i=abs(ls(j)) e(i)=max(z,e(i)) enddo do j=n+1,nmi i=abs(ls(j)) e(i)=0.D0 enddo endif c write(nout,*)'e =',(e(ij),ij=1,nmi) c write(nout,*)'PAQ factors' c ij=mm0+m0 c do ii=1,m1 c write(nout,*)(aa(ij+j),j=1,ii) c ij=ij+m0+ii c enddo c write(nout,*)'m0,mm0,m1,mm',m0,mm0,m1,mm c write(nout,*)'ls',(ls(ij),ij=1,nmi) c write(nout,*)'row perm',(ll(ij),ij=1,n) c write(nout,*)'column perm',(ll(lc+ij),ij=1,m1) c write(nout,*)'inverse perm',(ll(li+ij),ij=1,nmi) c call checkout(n,a,la,aa,ll,ll(lc1),ll(li1)) mp=-1 mq=-1 ifail=0 return end subroutine refactor(n,nm,a,la,aa,ll,ifail) implicit double precision (a-h,o-z) dimension a(*),la(*),aa(*),ll(*) common/densec/ns,ns1,nt,nt1,nu,nu1,mx1,lc,lc1,li,li1 common/factorc/m0,m1,mm0,mm,mp,mq c write(nout,*)'refactor' call re_factor(n,nm,a,la,aa,aa(ns1),aa(nt1),ll,ll(lc1),ll(li1)) call check_L(n,aa,ifail) return end subroutine pivot(p,q,n,nm,a,la,e,aa,ll,ifail,info) implicit double precision (a-h,r-z), integer (i-q) dimension a(*),la(*),e(*),aa(*),ll(*),info(*) common/noutc/nout common/iprintc/iprint common/densec/ns,ns1,nt,nt1,nu,nu1,mx1,lc,lc1,li,li1 common/factorc/m0,m1,mm0,mm,mp,mq common/mxm1c/mxm1 common/refactorc/nup,nfreq common/epsc/eps,tol,emin c write(nout,*)'pivot: p,q =',p,q ifail=0 if(p.ne.mp)then call eptsol(n,a,la,p,a,aa,aa(ns1),aa(nt1),ll,ll(lc1),ll(li1)) e(p)=sqrt(scpr(0.D0,aa(ns1),aa(ns1),m1+1)) mp=p endif if(q.ne.mq)then call aqsol(n,a,la,q,a,aa(nt1),aa(mx1),aa,ll,ll(lc1),ll(li1)) mq=q endif c update steepest edge coefficients tp=aa(nt+ll(li+p)) if(tp.eq.0.D0)tp=eps ep=e(p) c eq=ep/tp eq=abs(ep/tp) tp=tp/ep tpsq=tp**2 do i=1,m1+1 aa(nu+i)=aa(ns+i)/ep enddo do i=m1+2,n aa(nu+i)=0.D0 enddo call aqsol(n,a,la,-1,a,aa(nu1),aa(mx1),aa,ll,ll(lc1),ll(li1)) c write(nout,*)'row perm',(ll(ij),ij=1,n) c write(nout,*)'column perm',(ll(lc+ij),ij=1,m1) c write(nout,*)'s =',(aa(ns+ij),ij=1,n) c write(nout,*)'t =',(aa(nt+ij),ij=1,n) c write(nout,*)'u =',(aa(nu+ij),ij=1,n) e(p)=0.D0 do i=1,nm if(e(i).gt.0.D0)then j=ll(li+i) ei=e(i) c ti=aa(nt+j)*eq/ei c e(i)=max(emin,ei*sqrt(max(1.D0-ti*(2.D0*aa(nu+j)/ei-ti),0.D0))) ti=aa(nt+j)/ei e(i)=max(emin, * ei*sqrt(max(tpsq-ti*(2.D0*tp*aa(nu+j)/ei-ti),0.D0))*eq) endif enddo c e(q)=max(emin,abs(eq)) e(q)=max(emin,eq) info(1)=info(1)+1 if(nup.ge.nfreq)then c refactorize L ip=ll(li+p) if(p.gt.n)then qq=ll(lc+m1) ll(lc+ip)=qq ll(li+qq)=ip m1=m1-1 ll(li+p)=0 else m1p=m1+1 ll(ip)=ll(m1p) ll(li+ll(ip))=ip ll(m1p)=p ll(li+p)=m1p endif if(q.gt.n)then if(m1.eq.mxm1)then ifail=7 return endif m1=m1+1 ll(lc+m1)=q ll(li+q)=m1 else iq=ll(li+q) m1p=m1+1 ll(iq)=ll(m1p) ll(li+ll(iq))=iq ll(m1p)=q ll(li+q)=m1p endif call re_factor(n,nm,a,la,aa,aa(ns1),aa(nt1),ll,ll(lc1),ll(li1)) else c update L nup=nup+1 if(p.le.n)then if(m1.eq.mxm1)then ifail=7 return endif call linf(m1,aa(ns1),z,iz) if(z.le.4.D0)then if(m0+m1.eq.mxm1)then c write(nout,*)'m0 + m1 = mxm1: re-centre triangle' ii=mm0 mo=m0 m0=m0/2 mm0=m0*(m0+1)/2 mm=mm0 do i=1,m1 ii=ii+mo+i mm=mm+m0+i do j=1-i,0 aa(mm+j)=aa(ii+j) enddo enddo endif do i=1,m1 aa(mm+m0+i)=aa(ns+i) enddo goto1 endif endif call c_flma(n,a,la,p,aa,ll,ll(lc1),ll(li1)) 1 continue if(q.le.n)then call r_flma(n,a,la,q,aa,ll,ll(lc1),ll(li1)) else m1=m1+1 mm=mm+m0+m1 aa(mm)=1.D0 aa(mm)=aiscpri1(n,a,la,q-n,aa(mm-m1+1),0.D0,ll,ll(li1),m1) if(abs(aa(mm)).le.eps)aa(mm)=eps ll(lc+m1)=q ll(li+q)=m1 endif mp=-1 mq=-1 endif call check_L(n,aa,ifail) c write(nout,*)'PAQ factors' c ij=m0+mm0 c do ii=1,m1 c write(nout,*)(aa(ij+j),j=1,ii) c ij=ij+m0+ii c enddo c write(nout,*)'m0,mm0,m1,mm',m0,mm0,m1,mm c write(nout,*)'row perm',(ll(ij),ij=1,n) c write(nout,*)'column perm',(ll(lc+ij),ij=1,m1) c write(nout,*)'inverse perm',(ll(li+ij),ij=1,nm) c call checkout(n,a,la,aa,ll,ll(lc1),ll(li1)) c write(nout,*)'steepest edge coefficients',(e(ij),ij=1,nm) c emax=0.D0 c do i=1,nm c if(e(i).gt.0.D0)then c call eptsol(n,a,la,i,a,aa,aa(ns1),aa(nt1),ll,ll(lc1),ll(li1)) c ei=sqrt(scpr(0.D0,aa(ns1),aa(ns1),n)) c emax=max(emax,abs(ei-e(i))) c endif c enddo c if(emax.ge.tol) c * write(nout,*)'error in steepest edge coefficients =',emax return end subroutine fbsub(n,jmin,jmax,a,la,q,b,x,ls,aa,ll,save) implicit double precision (a-h,r-z), integer (i-q) logical save dimension a(*),la(*),b(*),x(*),ls(*),aa(*),ll(*) c solves a system B.x=b c Parameter list c ************** c n number of variables (as for bqpd) c a,la specification of QP problem data (as for bqpd) c jmin,jmax (see description of ls below) c q an integer which, if in the range 1:n+m, specifies that the rhs vector c b is to be column q of the matrix A of general constraint normals. c In this case the parameter b is not referenced by fbsub. c If q=0 then b is taken as the vector given in the parameter b. c b(n) must be set to the r.h.s. vector b (but only if q=0) c x(n+m) contains the required part of the solution x, set according to the c index number of that component (in the range 1:n for a simple bound and c n+1:n+m for a general constraint) c ls(*) an index vector, listing the components of x that are required. c Only the absolute value of the elements of ls are used (this allows c the possibility of using of the contents of the ls parameter of bqpd). c Elements of x in the range abs(ls(j)), j=jmin:jmax are set by fbsub. c These contortions allow bqpd to be independent of the basis matrix code. c aa(*) real storage used by the basis matrix code (supply the vector c ws(lu1) with ws as in the call of bqpd and lu1 as in common/bqpdc/...) c ll(*) integer storage used by the basis matrix code (supply the vector c lws(ll1) with lws as in the call of bqpd and ll1 as in common/bqpdc/...) c save indicates if fbsub is to save its copy of the solution for possible c future use. We suggest that the user only sets save = .false. common/noutc/nout common/densec/ns,ns1,nt,nt1,nu,nu1,mx1,lc,lc1,li,li1 common/factorc/m0,m1,mm0,mm,mp,mq c write(nout,*)'fbsub q =',q if(save)then if(q.ne.mq)then call aqsol(n,a,la,q,b,aa(nt1),aa(mx1),aa,ll,ll(lc1),ll(li1)) mq=q endif do j=jmin,jmax i=abs(ls(j)) x(i)=aa(nt+ll(li+i)) enddo else call aqsol(n,a,la,q,b,aa(nu1),aa(mx1),aa,ll,ll(lc1),ll(li1)) do j=jmin,jmax i=abs(ls(j)) x(i)=aa(nu+ll(li+i)) enddo endif return end subroutine tfbsub(n,a,la,p,b,x,aa,ll,ep,save) implicit double precision (a-h,r-z), integer (i-q) logical save dimension a(*),la(*),b(*),x(*),aa(*),ll(*) c solves a system Bt.x=b c Parameter list c ************** c n number of variables (as for bqpd) c a,la specification of QP problem data (as for bqpd) c p an integer which, if in the range 1:n+m, specifies that the rhs vector c b is a unit vector appropriate to the position of p in the current c ordering. In this case b is not referenced by tfbsub. c b(n+m) If p=0, this must be set to the r.h.s. vector b. Only the components c of b need be set, according to the index number of each component (in c the range 1:n for a simple bound and n+1:n+m for a general constraint) c x(n) contains the solution x (in natural ordering) c aa(*) real storage used by the basis matrix code (supply the vector c ws(lu1) with ws as in the call of bqpd and lu1 as in common/bqpdc/...) c ll(*) integer storage used by the basis matrix code (supply the vector c lws(ll1) with lws as in the call of bqpd and ll1 as in common/bqpdc/...) c ep if p.ne.0 and save is true, ep contains the l_2 length of x on exit c save indicates if tfbsub is to save its copy of the solution for possible c future use. We suggest that the user only sets save = .false. common/noutc/nout common/densec/ns,ns1,nt,nt1,nu,nu1,mx1,lc,lc1,li,li1 common/factorc/m0,m1,mm0,mm,mp,mq c write(nout,*)'tfbsub p =',p if(save)then if(p.ne.mp)then call eptsol(n,a,la,p,b,aa,aa(ns1),aa(nt1),ll,ll(lc1),ll(li1)) mp=p endif do i=1,n x(ll(i))=aa(ns+i) enddo if(p.gt.0)ep=sqrt(scpr(0.D0,aa(ns1),aa(ns1),m1+1)) else call eptsol(n,a,la,p,b,aa,aa(nu1),aa(nt1),ll,ll(lc1),ll(li1)) do i=1,n x(ll(i))=aa(nu+i) enddo endif c write(nout,*)'x =',(x(i),i=1,n) return end subroutine newg common/factorc/m0,m1,mm0,mm,mp,mq mq=-1 return end c******** The following routines are internal to denseL.f ************** subroutine re_factor(n,nm,a,la,T,sn,tn,lr,lc,li) implicit double precision (a-h,r-z), integer (i-q) dimension a(*),la(*),T(*),sn(*),tn(*),lr(*),lc(*),li(*) common/noutc/nout common/iprintc/iprint common/refactorc/nup,nfreq common/factorc/m0,m1,mm0,mm,mp,mq common/mxm1c/mxm1 common/epsc/eps,tol,emin c write(nout,*)'re_factor' nup=0 if(m1.eq.0)return m0=(mxm1-m1)/2 mm0=m0*(m0+1)/2 c write(nout,*)'row perm',(lr(ij),ij=1,n) c write(nout,*)'column perm',(lc(ij),ij=1,m1) do i=1,m1 sn(i)=0.D0 enddo mm=mm0 do i=1,m1-1 mm=mm+m0+i im=i-1 i1=mm-im q=lc(i)-n if(q.le.0)goto1 c form L.a_q call iscatter(a,la,q,li,sn,n) c write(nout,*)'aq =',(sn(ij),ij=1,m1) jj=mm j1=i1 do j=i,m1 tn(j)=scpr(sn(j),T(j1),sn,im) j1=jj+m0+1 jj=j1+j enddo call iunscatter(a,la,q,li,sn,n) c write(nout,*)'L.aq =',(tn(ij),ij=i,m1) call linf(m1-im,tn(i),z,iz) if(iz.gt.1)then c pivot interchange iz=iz-1 call vexch(T(i1),T(i1+iz*(m0+i)+iz*(iz-1)/2),im) iz=iz+i call rexch(tn(i),tn(iz)) li(lr(i))=iz call iexch(lr(i),lr(iz)) li(lr(i))=i endif if(tn(i).eq.0.D0)tn(i)=eps c update L j1=i1+m0+i zz=-tn(i) do j=i+1,m1 z=tn(j)/zz call mysaxpy(z,T(i1),T(j1),i-1) T(j1+im)=z c write(nout,*)'L(j) =',(T(ij),ij=j1,j1+im) j1=j1+m0+j enddo T(mm)=-zz enddo mm=mm+m0+m1 q=lc(i)-n if(q.le.0)goto1 call iscatter(a,la,q,li,sn,n) T(mm)=scpr(sn(m1),T(mm-m1+1),sn,m1-1) if(T(mm).eq.0.D0)T(mm)=eps c write(nout,*)'PAQ factors' c ij=mm0+m0 c do ii=1,m1 c write(nout,*)(T(ij+j),j=1,ii) c ij=ij+m0+ii c enddo c write(nout,*)'m0,mm0,m1,mm',m0,mm0,m1,mm c write(nout,*)'row perm',(lr(ij),ij=1,n) c write(nout,*)'column perm',(lc(ij),ij=1,m1) c write(nout,*)'inverse perm',(li(ij),ij=1,nm) c call checkout(n,a,la,T,lr,lc1,li) mp=-1 mq=-1 return 1 continue write(nout,*)'malfunction in re_factor: i,lc(i) =',i,q+n stop end subroutine check_L(n,T,ifail) implicit double precision (a-h,r-z), integer (i-q) dimension T(*) common/noutc/nout common/factorc/m0,m1,mm0,mm,mp,mq common/epsc/eps,tol,emin c write(nout,*)'check_L' ifail=1 kk=mm0 c dmin=1.D37 do k=1,m1 kk=kk+m0+k c dmin=min(dmin,abs(T(kk))) if(abs(T(kk)).le.tol)return enddo c write(nout,*)'dmin =',dmin ifail=0 return end subroutine aqsol(n,a,la,q,b,tn,xm,T,lr,lc,li) implicit double precision (a-h,r-z), integer (i-q) dimension a(*),la(*),b(*),tn(*),xm(*),T(*),lr(*),lc(*),li(*) common/noutc/nout common/factorc/m0,m1,mm0,mm,mp,mq c write(nout,*)'aqsol q =',q if(q.gt.0)then do i=1,n tn(i)=0.D0 enddo if(q.le.n)then tn(li(q))=1.D0 else c call isaipy(1.D0,a,la,q-n,tn,n,lr,li) call iscatter(a,la,q-n,li,tn,n) endif elseif(q.eq.0)then do i=1,n tn(li(i))=b(i) enddo endif c write(nout,*)'tn =',(tn(i),i=1,n) ii=mm do i=m1,1,-1 xm(i)=(scpr(tn(i),T(ii-i+1),tn,i-1))/T(ii) call isaipy(-xm(i),a,la,lc(i)-n,tn,n,lr,li) ii=ii-m0-i enddo do i=1,m1 tn(i)=xm(i) enddo c write(nout,*)'tn =',(tn(i),i=1,n) return end subroutine eptsol(n,a,la,p,b,T,sn,tn,lr,lc,li) implicit double precision (a-h,r-z), integer (i-q) dimension a(*),la(*),b(*),T(*),sn(*),tn(*),lr(*),lc(*),li(*) common/noutc/nout common/iprintc/iprint common/epsc/eps,tol,emin common/factorc/m0,m1,mm0,mm,mp,mq c write(nout,*)'eptsol p =',p c if(p.eq.9)then c write(nout,9)'row perm',(lr(ij),ij=1,n) c write(nout,9)'column perm',(lc(ij),ij=1,m1) c write(nout,9)'inverse perm',(li(ij),ij=1,p) c 9 format(A/(15I5)) c endif if(p.gt.n)then pr=li(p) if(pr.le.0)print *,'here1' if(pr.le.0)goto1 if(pr.ne.m1)then z=tn(pr) call r_shift(tn(pr),m1-pr,1) tn(m1)=z call c_flma(n,a,la,p,T,lr,lc,li) m1=m1+1 mm=mm+m0+m1 li(p)=m1 lc(m1)=p T(mm)=1.D0 T(mm)=aiscpri1(n,a,la,p-n,T(mm-m1+1),0.D0,lr,li,m1) if(T(mm).eq.0.D0)T(mm)=eps c write(nout,*)'PAQ factors' c ij=m0+mm0 c do ii=1,m1 c write(nout,*)(T(ij+j),j=1,ii) c ij=ij+m0+ii c enddo c write(nout,*)'m0,mm0,m1,mm',m0,mm0,m1,mm c write(nout,*)'row perm',(lr(ij),ij=1,n) c write(nout,*)'column perm',(lc(ij),ij=1,m1) c write(nout,*)'inverse perm',(li(ij),ij=1,p) c call checkout(n,a,la,T,lr,lc,li) endif ii=mm-m1 z=1.D0/T(mm) do i=1,m1-1 sn(i)=T(ii+i)*z enddo sn(m1)=z do i=m1+1,n sn(i)=0.D0 enddo else ii=m0+mm0 if(p.eq.0)then do i=1,m1 sn(i)=0.D0 enddo do i=m1+1,n sn(i)=b(lr(i)) enddo do i=1,m1 ii=ii+i j=lc(i) sn(i)=-aiscpri(n,a,la,j-n,sn,-b(j),lr,li)/T(ii) call mysaxpy(sn(i),T(ij),sn,i-1) ii=ii+m0 ij=ii+1 enddo else pr=li(p) if(pr.le.m1)print *,'here2' if(pr.le.m1)goto1 m1p=m1+1 call iexch(lr(pr),lr(m1p)) call iexch(li(lr(pr)),li(lr(m1p))) call rexch(tn(pr),tn(m1p)) do i=1,n sn(i)=0.D0 enddo sn(m1p)=1.D0 do i=1,m1 ii=ii+i sn(i)=-aiscpri(n,a,la,lc(i)-n,sn,0.D0,lr,li)/T(ii) call mysaxpy(sn(i),T(ij),sn,i-1) ii=ii+m0 ij=ii+1 enddo endif endif c write(nout,*)'sn =',(sn(i),i=1,n) return 1 continue write(nout,*)'malfunction detected in eptsol: p =',p stop end subroutine c_flma(n,a,la,q,T,lr,lc,li) implicit double precision (a-h,r-z), integer (i-q) dimension a(*),la(*),T(*),lr(*),lc(*),li(*) common/noutc/nout common/mxm1c/mxm1 common/epsc/eps,tol,emin common/factorc/m0,m1,mm0,mm,mp,mq double precision l21 c write(nout,*)'c_flma: q =',q qc=li(q) if(q.gt.n)then if(qc.le.0)goto1 call ishift(lc(qc),m1-qc,1) do j=qc,m1-1 li(lc(j))=j enddo li(q)=0 mm=mm-m1-m0 m1=m1-1 else if(qc.le.m1)goto1 call iexch(lr(qc),lr(m1+1)) call iexch(li(lr(qc)),li(lr(m1+1))) call ishift(lr(2),m1,-1) lr(1)=q do i=1,m1+1 li(lr(i))=i enddo if(m0.eq.0)then c write(nout,*)'m0 = 0: re-centre triangle' m0=(mxm1+1-m1)/2 mm0=m0*(m0+1)/2 ii=mm mm=(m0+m1)*(m0+m1+1)/2 ii=ii-mm ij=mm+m0+1 do i=m1,1,-1 ij=ij-m0-i call r_shift(T(ij),i,ii) ii=ii+m0 enddo endif mm=mm-m0-m1 m0=m0-1 do i=1,m1 mm0=mm0+m0+i T(mm0)=0.D0 enddo mm0=m0*(m0+1)/2 qc=1 endif iswap=0 ii=(qc+m0)*(qc+m0+1)/2 do i=qc,m1 im=i+m0 ii1=ii+m0+1 iip=ii1+i T(ii)=1.D0 u21=T(iip) u11=aiscpri1(n,a,la,lc(i)-n,T(ii1-im),0.D0,lr,li,i) ij=ii+im-iswap c write(nout,*)'i,im,ii,iip,iswap,ij',i,im,ii,iip,iswap,ij l21=T(ij) if(abs(l21).le.eps)l21=0.D0 if(iswap.gt.0)call r_shift(T(ij),iswap,1) del=u21-l21*u11 c write(nout,*)'l21,u11,u21,del =',l21,u11,u21,del c write(nout,*)'old row =',(T(j),j=ii1-im,ii) c write(nout,*)'new row =',(T(j),j=ii1,ii+im) if(abs(del).le.abs(u11)*max(1.D0,abs(l21)))then c if(u11.eq.0.D0)then c r=0.D0 c else if(u11.eq.0.D0)u11=eps r=-u21/u11 if(abs(r).le.eps)r=0.D0 call mysaxpy(r,T(ii1-im),T(ii1),i-1) c endif T(ii)=u11 T(ii+im)=l21+r if(iswap.gt.0)then do j=im+1,m0+m1 ij=ij+j r=T(ij) call r_shift(T(ij),iswap,1) T(ij+iswap)=r enddo endif iswap=0 else r=-u11/del if(abs(r).le.eps)r=0.D0 call permop(T(ii1-im),T(ii1),r,-l21,i-1) T(ii)=del T(ii+im)=r call iexch(lr(i),lr(i+1)) call iexch(li(lr(i)),li(lr(i+1))) iswap=iswap+1 endif ii=iip enddo return 1 continue write(nout,*)'malfunction detected in c_flma: q =',q stop end subroutine r_flma(n,a,la,p,T,lr,lc,li) implicit double precision (a-h,r-z), integer (i-q) dimension a(*),la(*),T(*),lr(*),lc(*),li(*) common/noutc/nout common/epsc/eps,tol,emin common/factorc/m0,m1,mm0,mm,mp,mq double precision l11 c write(nout,*)'r_flma: p =',p pr=li(p) if(pr.gt.m1)then if(pr.eq.m1+1)return write(nout,*)'malfunction detected in r_flma: p =',p stop endif ii=(pr+m0)*(pr+m0+1)/2 u11=T(ii) T(ii)=1.D0 ip=ii do i=pr,m1-1 im=i+m0 ii1=ii+m0+1 iip=ii1+i u22=T(iip) l11=-T(ip+im)/T(ip) if(abs(l11).le.eps)l11=0.D0 u12=aiscpri1(n,a,la,lc(i+1)-n,T(ii1-im),0.D0,lr,li,i) del=l11*u12+u22 c write(nout,*)'l11,u11,u12,u22,del',l11,u11,u12,u22,del c write(nout,*)'old row =',(T(j),j=ii1-im,ii) c write(nout,*)'new row =',(T(j),j=ii1,ii+im) if(abs(del).le.abs(l11)*max(abs(u11),abs(u12)))then call saxpyx(l11,T(ii1-im),T(ii1),i) u11=l11*u11 if(u11.eq.0.D0)u11=eps T(iip)=1.D0 else r=-u12/del if(abs(r).le.eps)r=0.D0 call permop(T(ii1-im),T(ii1),r,l11,i) call iexch(lc(i),lc(i+1)) call iexch(li(lc(i)),li(lc(i+1))) T(iip)=r u22=u11*u22/del u11=del endif call r_shift(T(ip),i-pr,1) T(ii)=u11 u11=u22 ip=ip+im ii=iip enddo call ishift(lr(pr),m1-pr+1,1) lr(m1+1)=p do j=pr,m1+1 li(lr(j))=j enddo c if(T(ip).eq.0.D0)T(ip)=eps l11=-T(ip+m0+m1)/T(ip) call saxpyx(l11,T(mm-m1+1),T(mm+m0+1),m1) call r_shift(T(ip),m1-pr,1) T(mm)=l11*u11 if(T(mm).eq.0.D0)T(mm)=eps return end subroutine permop(v1,v2,r,s,n) implicit double precision (a-h,o-z) dimension v1(*),v2(*) common/noutc/nout if(s.eq.0)then if(r.eq.0)then call vexch(v1,v2,n) else do i=1,n z=v2(i) v2(i)=v1(i)+r*z v1(i)=z enddo endif else if(r.eq.0)then do i=1,n z=v1(i) v1(i)=v2(i)+s*z v2(i)=z enddo else do i=1,n z=v1(i) v1(i)=v2(i)+s*z v2(i)=z+r*v1(i) enddo endif endif return end subroutine checkout(n,a,la,T,lr,lc,li) implicit double precision (a-h,o-z) dimension a(*),la(*),T(*),lr(*),lc(*),li(*) common/noutc/nout common/mxm1c/mxm1 common/epsc/eps,tol,emin common/factorc/m0,m1,mm0,mm,mp,mq emax=0.D0 gmax=0.D0 ii=mm0 do i=1,m1 ii1=ii+m0+1 ii=ii+m0+i d=T(ii) T(ii)=1.D0 do j=1,i-1 e=aiscpri1(n,a,la,lc(j)-n,T(ii1),0.D0,lr,li,i) emax=max(emax,abs(e)) gmax=max(gmax,abs(T(ii+m0+j))) enddo e=aiscpri1(n,a,la,lc(i)-n,T(ii1),-d,lr,li,i) emax=max(emax,abs(e)) T(ii)=d enddo c if(emax.gt.tol.or.gmax.gt.1.D1) c * write(nout,*)'error in LA=U is ',emax,' growth in L =',gmax write(nout,*)'error in LA=U is ',emax,' growth in L =',gmax return end
gpl-3.0
Vitancourt/gcc
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
sudosurootdev/gcc
gcc/testsuite/gfortran.dg/continuation_3.f90
193
1932
! { dg-do compile } ! { dg-options -std=f95 } ! PR 19262 Test limit on line continuations. Test case derived form case in PR ! by Steve Kargl. Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org> print *, & "1" // & ! 1 "2" // & ! 2 "3" // & ! 3 "4" // & ! 4 "5" // & ! 5 "6" // & ! 6 "7" // & ! 7 "8" // & ! 8 "9" // & ! 9 "0" // & ! 10 "1" // & ! 11 "2" // & ! 12 "3" // & ! 13 "4" // & ! 14 "5" // & ! 15 "6" // & ! 16 "7" // & ! 17 "8" // & ! 18 "9" // & ! 19 "0" // & ! 20 "1" // & ! 21 "2" // & ! 22 "3" // & ! 23 "4" // & ! 24 "5" // & ! 25 "6" // & ! 26 "7" // & ! 27 "8" // & ! 28 "9" // & ! 29 "0" // & ! 30 "1" // & ! 31 "2" // & ! 32 "3" // & ! 33 "4" // & ! 34 "5" // & ! 35 "6" // & ! 36 "7" // & ! 37 "8" // & ! 38 "9" print *, & "1" // & ! 1 "2" // & ! 2 "3" // & ! 3 "4" // & ! 4 "5" // & ! 5 "6" // & ! 6 "7" // & ! 7 "8" // & ! 8 "9" // & ! 9 "0" // & ! 10 "1" // & ! 11 "2" // & ! 12 "3" // & ! 13 "4" // & ! 14 "5" // & ! 15 "6" // & ! 16 "7" // & ! 17 "8" // & ! 18 "9" // & ! 19 "0" // & ! 20 "1" // & ! 21 "2" // & ! 22 "3" // & ! 23 "4" // & ! 24 "5" // & ! 25 "6" // & ! 26 "7" // & ! 27 "8" // & ! 28 "9" // & ! 29 ! ! "0" // & ! 30 "1" // & ! 31 ! ! "2" // & ! 32 "3" // & ! 33 "4" // & ! 34 "5" // & ! 35 "6" // & ! 36 "7" // & ! 37 "8" // & ! 38 "9" // & ! 39 "0" ! { dg-warning "Limit of 39 continuations exceeded" } end
gpl-2.0
Vitancourt/gcc
gcc/testsuite/gfortran.dg/internal_references_1.f90
135
1045
! { dg-do compile } ! This tests the patch for PRs 24327, 25024 & 25625, which ! are all connected with references to internal procedures. ! This is a composite of the PR testcases; and each is ! labelled by PR. ! ! Contributed by Paul Thomas <pault@gcc.gnu.org> ! ! PR25625 - would neglect to point out that there were 2 subroutines p. module m implicit none contains subroutine p (i) ! { dg-error "is already defined" } integer :: i end subroutine subroutine p (i) ! { dg-error "is already defined" } integer :: i end subroutine end module ! ! PR25124 - would happily ignore the declaration of foo in the main program. program test real :: foo, x ! { dg-error "explicit interface and must not have attributes declared" } x = bar () ! This is OK because it is a regular reference. x = foo () contains function foo () ! { dg-error "explicit interface and must not have attributes declared" } foo = 1.0 end function foo function bar () bar = 1.0 end function bar end program test
gpl-2.0
Vitancourt/gcc
gcc/testsuite/gfortran.dg/unlimited_polymorphic_13.f90
104
1684
! { dg-do run } ! ! PR fortran/58793 ! ! Contributed by Vladimir Fuka ! ! Had the wrong value for the storage_size for complex ! module m use iso_fortran_env implicit none integer, parameter :: c1 = real_kinds(1) integer, parameter :: c2 = real_kinds(2) integer, parameter :: c3 = real_kinds(size(real_kinds)-1) integer, parameter :: c4 = real_kinds(size(real_kinds)) real(c1) :: r1 real(c2) :: r2 real(c3) :: r3 real(c4) :: r4 contains subroutine s(o, k) class(*) :: o integer :: k integer :: sz sz = 0 select case (k) case (4) sz = storage_size(r1)*2 end select select case (k) case (8) sz = storage_size(r2)*2 end select select case (k) case (real_kinds(size(real_kinds)-1)) sz = storage_size(r3)*2 end select select case (k) case (real_kinds(size(real_kinds))) sz = storage_size(r4)*2 end select if (sz .eq. 0) call abort() if (storage_size(o) /= sz) call abort() ! Break up the SELECT TYPE to pre-empt collisions in the value of 'cn' select type (o) type is (complex(c1)) if (storage_size(o) /= sz) call abort() end select select type (o) type is (complex(c2)) if (storage_size(o) /= sz) call abort() end select select type (o) type is (complex(c3)) if (storage_size(o) /= sz) call abort() end select select type (o) type is (complex(c4)) if (storage_size(o) /= sz) call abort() end select end subroutine s end module m program p use m call s((1._c1, 2._c1), c1) call s((1._c2, 2._c2), c2) call s((1._c3, 2._c3), c3) call s((1._c4, 2._c4), c4) end program p
gpl-2.0
sudosurootdev/gcc
gcc/testsuite/gfortran.dg/unlimited_polymorphic_13.f90
104
1684
! { dg-do run } ! ! PR fortran/58793 ! ! Contributed by Vladimir Fuka ! ! Had the wrong value for the storage_size for complex ! module m use iso_fortran_env implicit none integer, parameter :: c1 = real_kinds(1) integer, parameter :: c2 = real_kinds(2) integer, parameter :: c3 = real_kinds(size(real_kinds)-1) integer, parameter :: c4 = real_kinds(size(real_kinds)) real(c1) :: r1 real(c2) :: r2 real(c3) :: r3 real(c4) :: r4 contains subroutine s(o, k) class(*) :: o integer :: k integer :: sz sz = 0 select case (k) case (4) sz = storage_size(r1)*2 end select select case (k) case (8) sz = storage_size(r2)*2 end select select case (k) case (real_kinds(size(real_kinds)-1)) sz = storage_size(r3)*2 end select select case (k) case (real_kinds(size(real_kinds))) sz = storage_size(r4)*2 end select if (sz .eq. 0) call abort() if (storage_size(o) /= sz) call abort() ! Break up the SELECT TYPE to pre-empt collisions in the value of 'cn' select type (o) type is (complex(c1)) if (storage_size(o) /= sz) call abort() end select select type (o) type is (complex(c2)) if (storage_size(o) /= sz) call abort() end select select type (o) type is (complex(c3)) if (storage_size(o) /= sz) call abort() end select select type (o) type is (complex(c4)) if (storage_size(o) /= sz) call abort() end select end subroutine s end module m program p use m call s((1._c1, 2._c1), c1) call s((1._c2, 2._c2), c2) call s((1._c3, 2._c3), c3) call s((1._c4, 2._c4), c4) end program p
gpl-2.0
Vitancourt/gcc
gcc/testsuite/gfortran.dg/do_check_6.f90
139
2350
! { dg-do compile } ! ! PR fortran/54958 ! module m integer, protected :: i integer :: j end module m subroutine test1() use m implicit none integer :: A(5) ! Valid: data-implied-do (has a scope of the statement or construct) DATA (A(i), i=1,5)/5*42/ ! OK ! Valid: ac-implied-do (has a scope of the statement or construct) print *, [(i, i=1,5 )] ! OK ! Valid: index-name (has a scope of the statement or construct) forall (i = 1:5) ! OK end forall ! Valid: index-name (has a scope of the statement or construct) do concurrent (i = 1:5) ! OK end do ! Invalid: io-implied-do print *, (i, i=1,5 ) ! { dg-error "PROTECTED and can not appear in a variable definition context .iterator variable." } ! Invalid: do-variable in a do-stmt do i = 1, 5 ! { dg-error "PROTECTED and can not appear in a variable definition context .iterator variable." } end do end subroutine test1 subroutine test2(i) implicit none integer, intent(in) :: i integer :: A(5) ! Valid: data-implied-do (has a scope of the statement or construct) DATA (A(i), i=1,5)/5*42/ ! OK ! Valid: ac-implied-do (has a scope of the statement or construct) print *, [(i, i=1,5 )] ! OK ! Valid: index-name (has a scope of the statement or construct) forall (i = 1:5) ! OK end forall ! Valid: index-name (has a scope of the statement or construct) do concurrent (i = 1:5) ! OK end do ! Invalid: io-implied-do print *, (i, i=1,5 ) ! { dg-error "INTENT.IN. in variable definition context .iterator variable." } ! Invalid: do-variable in a do-stmt do i = 1, 5 ! { dg-error "INTENT.IN. in variable definition context .iterator variable." } end do end subroutine test2 pure subroutine test3() use m implicit none integer :: A(5) !DATA (A(j), j=1,5)/5*42/ ! Not allowed in pure ! Valid: ac-implied-do (has a scope of the statement or construct) A = [(j, j=1,5 )] ! OK ! Valid: index-name (has a scope of the statement or construct) forall (j = 1:5) ! OK end forall ! Valid: index-name (has a scope of the statement or construct) do concurrent (j = 1:5) ! OK end do ! print *, (j, j=1,5 ) ! I/O not allowed in PURE ! Invalid: do-variable in a do-stmt do j = 1, 5 ! { dg-error "variable definition context .iterator variable. at .1. in PURE procedure" } end do end subroutine test3
gpl-2.0
gdooper/scipy
scipy/special/cdflib/cdffnc.f
106
8047
SUBROUTINE cdffnc(which,p,q,f,dfn,dfd,phonc,status,bound) C********************************************************************** C C SUBROUTINE CDFFNC( WHICH, P, Q, F, DFN, DFD, PNONC, STATUS, BOUND ) C Cumulative Distribution Function C Non-central F distribution C C C Function C C C Calculates any one parameter of the Non-central F C distribution given values for the others. C C C Arguments C C C WHICH --> Integer indicating which of the next five argument C values is to be calculated from the others. C Legal range: 1..5 C iwhich = 1 : Calculate P and Q from F,DFN,DFD and PNONC C iwhich = 2 : Calculate F from P,Q,DFN,DFD and PNONC C iwhich = 3 : Calculate DFN from P,Q,F,DFD and PNONC C iwhich = 4 : Calculate DFD from P,Q,F,DFN and PNONC C iwhich = 5 : Calculate PNONC from P,Q,F,DFN and DFD C INTEGER WHICH C C P <--> The integral from 0 to F of the non-central f-density. C Input range: [0,1-1E-16). C DOUBLE PRECISION P C C Q <--> 1-P. C Q is not used by this subroutine and is only included C for similarity with other cdf* routines. C DOUBLE PRECISION Q C C F <--> Upper limit of integration of the non-central f-density. C Input range: [0, +infinity). C Search range: [0,1E100] C DOUBLE PRECISION F C C DFN < --> Degrees of freedom of the numerator sum of squares. C Input range: (0, +infinity). C Search range: [ 1E-100, 1E100] C DOUBLE PRECISION DFN C C DFD < --> Degrees of freedom of the denominator sum of squares. C Must be in range: (0, +infinity). C Input range: (0, +infinity). C Search range: [ 1E-100, 1E100] C DOUBLE PRECISION DFD C C PNONC <-> The non-centrality parameter C Input range: [0,infinity) C Search range: [0,1E4] C DOUBLE PRECISION PHONC C C STATUS <-- 0 if calculation completed correctly C -I if input parameter number I is out of range C 1 if answer appears to be lower than lowest C search bound C 2 if answer appears to be higher than greatest C search bound C 3 if P + Q .ne. 1 C INTEGER STATUS C C BOUND <-- Undefined if STATUS is 0 C C Bound exceeded by parameter number I if STATUS C is negative. C C Lower search bound if STATUS is 1. C C Upper search bound if STATUS is 2. C C C Method C C C Formula 26.6.20 of Abramowitz and Stegun, Handbook of C Mathematical Functions (1966) is used to compute the cumulative C distribution function. C C Computation of other parameters involve a seach for a value that C produces the desired value of P. The search relies on the C monotinicity of P with the other parameter. C C WARNING C C The computation time required for this routine is proportional C to the noncentrality parameter (PNONC). Very large values of C this parameter can consume immense computer resources. This is C why the search range is bounded by 10,000. C C WARNING C C The value of the cumulative noncentral F distribution is not C necessarily monotone in either degrees of freedom. There thus C may be two values that provide a given CDF value. This routine C assumes monotonicity and will find an arbitrary one of the two C values. C C********************************************************************** C .. Parameters .. DOUBLE PRECISION tent4 PARAMETER (tent4=1.0D4) DOUBLE PRECISION tol PARAMETER (tol=1.0D-8) DOUBLE PRECISION atol PARAMETER (atol=1.0D-50) DOUBLE PRECISION zero,one,inf PARAMETER (zero=1.0D-100,one=1.0D0-1.0D-16,inf=1.0D100) C .. C .. Scalar Arguments .. DOUBLE PRECISION bound,dfd,dfn,f,p,phonc,q INTEGER status,which C .. C .. Local Scalars .. DOUBLE PRECISION ccum,cum,fx LOGICAL qhi,qleft C .. C .. External Subroutines .. EXTERNAL cumfnc,dinvr,dstinv C .. IF (.NOT. ((which.LT.1).OR. (which.GT.5))) GO TO 30 IF (.NOT. (which.LT.1)) GO TO 10 bound = 1.0D0 GO TO 20 10 bound = 5.0D0 20 status = -1 RETURN 30 IF (which.EQ.1) GO TO 70 IF (.NOT. ((p.LT.0.0D0).OR. (p.GT.one))) GO TO 60 IF (.NOT. (p.LT.0.0D0)) GO TO 40 bound = 0.0D0 GO TO 50 40 bound = one 50 status = -2 RETURN 60 CONTINUE 70 IF (which.EQ.2) GO TO 90 IF (.NOT. (f.LT.0.0D0)) GO TO 80 bound = 0.0D0 status = -4 RETURN 80 CONTINUE 90 IF (which.EQ.3) GO TO 110 IF (.NOT. (dfn.LE.0.0D0)) GO TO 100 bound = 0.0D0 status = -5 RETURN 100 CONTINUE 110 IF (which.EQ.4) GO TO 130 IF (.NOT. (dfd.LE.0.0D0)) GO TO 120 bound = 0.0D0 status = -6 RETURN 120 CONTINUE 130 IF (which.EQ.5) GO TO 150 IF (.NOT. (phonc.LT.0.0D0)) GO TO 140 bound = 0.0D0 status = -7 RETURN 140 CONTINUE 150 IF ((1).EQ. (which)) THEN CALL cumfnc(f,dfn,dfd,phonc,p,q) status = 0 ELSE IF ((2).EQ. (which)) THEN f = 5.0D0 CALL dstinv(0.0D0,inf,0.5D0,0.5D0,5.0D0,atol,tol) status = 0 CALL dinvr(status,f,fx,qleft,qhi) 160 IF (.NOT. (status.EQ.1)) GO TO 170 CALL cumfnc(f,dfn,dfd,phonc,cum,ccum) fx = cum - p CALL dinvr(status,f,fx,qleft,qhi) GO TO 160 170 IF (.NOT. (status.EQ.-1)) GO TO 200 IF (.NOT. (qleft)) GO TO 180 status = 1 bound = 0.0D0 GO TO 190 180 status = 2 bound = inf 190 CONTINUE 200 CONTINUE ELSE IF ((3).EQ. (which)) THEN dfn = 5.0D0 CALL dstinv(zero,inf,0.5D0,0.5D0,5.0D0,atol,tol) status = 0 CALL dinvr(status,dfn,fx,qleft,qhi) 210 IF (.NOT. (status.EQ.1)) GO TO 220 CALL cumfnc(f,dfn,dfd,phonc,cum,ccum) fx = cum - p CALL dinvr(status,dfn,fx,qleft,qhi) GO TO 210 220 IF (.NOT. (status.EQ.-1)) GO TO 250 IF (.NOT. (qleft)) GO TO 230 status = 1 bound = zero GO TO 240 230 status = 2 bound = inf 240 CONTINUE 250 CONTINUE ELSE IF ((4).EQ. (which)) THEN dfd = 5.0D0 CALL dstinv(zero,inf,0.5D0,0.5D0,5.0D0,atol,tol) status = 0 CALL dinvr(status,dfd,fx,qleft,qhi) 260 IF (.NOT. (status.EQ.1)) GO TO 270 CALL cumfnc(f,dfn,dfd,phonc,cum,ccum) fx = cum - p CALL dinvr(status,dfd,fx,qleft,qhi) GO TO 260 270 IF (.NOT. (status.EQ.-1)) GO TO 300 IF (.NOT. (qleft)) GO TO 280 status = 1 bound = zero GO TO 290 280 status = 2 bound = inf 290 CONTINUE 300 CONTINUE ELSE IF ((5).EQ. (which)) THEN phonc = 5.0D0 CALL dstinv(0.0D0,tent4,0.5D0,0.5D0,5.0D0,atol,tol) status = 0 CALL dinvr(status,phonc,fx,qleft,qhi) 310 IF (.NOT. (status.EQ.1)) GO TO 320 CALL cumfnc(f,dfn,dfd,phonc,cum,ccum) fx = cum - p CALL dinvr(status,phonc,fx,qleft,qhi) GO TO 310 320 IF (.NOT. (status.EQ.-1)) GO TO 350 IF (.NOT. (qleft)) GO TO 330 status = 1 bound = 0.0D0 GO TO 340 330 status = 2 bound = tent4 340 CONTINUE 350 END IF RETURN END
bsd-3-clause
sudosurootdev/gcc
gcc/testsuite/gfortran.dg/vect/vect-2.f90
96
1235
! { dg-do compile } ! { dg-require-effective-target vect_float } SUBROUTINE FOO(A, B, C) DIMENSION A(1000000), B(1000000), C(1000000) READ*, X, Y A = LOG(X); B = LOG(Y); C = A + B PRINT*, C(500000) END ! First loop (A=LOG(X)) is vectorized using peeling to align the store. ! Same for the second loop (B=LOG(Y)). ! Third loop (C = A + B) is vectorized using versioning (for targets that don't ! support unaligned loads) or using peeling to align the store (on targets that ! support unaligned loads). ! { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } ! { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 3 "vect" { xfail { vect_no_align || { ! vector_alignment_reachable } } } } } ! { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { target { vect_no_align && { ! vector_alignment_reachable } } } } } ! { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail { vect_no_align } } } } ! { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 3 "vect" {target { vect_no_align || { { ! vector_alignment_reachable } && { ! vect_hw_misalign } } } } } } ! { dg-final { cleanup-tree-dump "vect" } }
gpl-2.0
gdooper/scipy
scipy/integrate/quadpack/dqagpe.f
146
21286
subroutine dqagpe(f,a,b,npts2,points,epsabs,epsrel,limit,result, * abserr,neval,ier,alist,blist,rlist,elist,pts,iord,level,ndin, * last) c***begin prologue dqagpe c***date written 800101 (yymmdd) c***revision date 830518 (yymmdd) c***category no. h2a2a1 c***keywords automatic integrator, general-purpose, c singularities at user specified points, c extrapolation, globally adaptive. c***author piessens,robert ,appl. math. & progr. div. - k.u.leuven c de doncker,elise,appl. math. & progr. div. - k.u.leuven c***purpose the routine calculates an approximation result to a given c definite integral i = integral of f over (a,b), hopefully c satisfying following claim for accuracy abs(i-result).le. c max(epsabs,epsrel*abs(i)). break points of the integration c interval, where local difficulties of the integrand may c occur(e.g. singularities,discontinuities),provided by user. c***description c c computation of a definite integral c standard fortran subroutine c double precision version c c parameters c on entry c f - double precision c function subprogram defining the integrand c function f(x). the actual name for f needs to be c declared e x t e r n a l in the driver program. c c a - double precision c lower limit of integration c c b - double precision c upper limit of integration c c npts2 - integer c number equal to two more than the number of c user-supplied break points within the integration c range, npts2.ge.2. c if npts2.lt.2, the routine will end with ier = 6. c c points - double precision c vector of dimension npts2, the first (npts2-2) c elements of which are the user provided break c points. if these points do not constitute an c ascending sequence there will be an automatic c sorting. c c epsabs - double precision c absolute accuracy requested c epsrel - double precision c relative accuracy requested c if epsabs.le.0 c and epsrel.lt.max(50*rel.mach.acc.,0.5d-28), c the routine will end with ier = 6. c c limit - integer c gives an upper bound on the number of subintervals c in the partition of (a,b), limit.ge.npts2 c if limit.lt.npts2, the routine will end with c ier = 6. c c on return c result - double precision c approximation to the integral c c abserr - double precision c estimate of the modulus of the absolute error, c which should equal or exceed abs(i-result) c c neval - integer c number of integrand evaluations c c ier - integer c ier = 0 normal and reliable termination of the c routine. it is assumed that the requested c accuracy has been achieved. c ier.gt.0 abnormal termination of the routine. c the estimates for integral and error are c less reliable. it is assumed that the c requested accuracy has not been achieved. c error messages c ier = 1 maximum number of subdivisions allowed c has been achieved. one can allow more c subdivisions by increasing the value of c limit (and taking the according dimension c adjustments into account). however, if c this yields no improvement it is advised c to analyze the integrand in order to c determine the integration difficulties. if c the position of a local difficulty can be c determined (i.e. singularity, c discontinuity within the interval), it c should be supplied to the routine as an c element of the vector points. if necessary c an appropriate special-purpose integrator c must be used, which is designed for c handling the type of difficulty involved. c = 2 the occurrence of roundoff error is c detected, which prevents the requested c tolerance from being achieved. c the error may be under-estimated. c = 3 extremely bad integrand behaviour occurs c at some points of the integration c interval. c = 4 the algorithm does not converge. c roundoff error is detected in the c extrapolation table. it is presumed that c the requested tolerance cannot be c achieved, 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.gt.0. c = 6 the input is invalid because c npts2.lt.2 or c break points are specified outside c the integration range or c (epsabs.le.0 and c epsrel.lt.max(50*rel.mach.acc.,0.5d-28)) c or limit.lt.npts2. c result, abserr, neval, last, rlist(1), c and elist(1) are set to zero. alist(1) and c blist(1) are set to a and b respectively. c c alist - double precision c vector of dimension at least limit, the first c last elements of which are the left end points c of the subintervals in the partition of the given c integration range (a,b) c c blist - double precision c vector of dimension at least limit, the first c last elements of which are the right end points c of the subintervals in the partition of the given c integration range (a,b) c c rlist - double precision c vector of dimension at least limit, the first c last elements of which are the integral c approximations on the subintervals c c elist - double precision c vector of dimension at least limit, the first c last elements of which are the moduli of the c absolute error estimates on the subintervals c c pts - double precision c vector of dimension at least npts2, containing the c integration limits and the break points of the c interval in ascending sequence. c c level - integer c vector of dimension at least limit, containing the c subdivision levels of the subinterval, i.e. if c (aa,bb) is a subinterval of (p1,p2) where p1 as c well as p2 is a user-provided break point or c integration limit, then (aa,bb) has level l if c abs(bb-aa) = abs(p2-p1)*2**(-l). c c ndin - integer c vector of dimension at least npts2, after first c integration over the intervals (pts(i)),pts(i+1), c i = 0,1, ..., npts2-2, the error estimates over c some of the intervals may have been increased c artificially, in order to put their subdivision c forward. if this happens for the subinterval c numbered k, ndin(k) is put to 1, otherwise c ndin(k) = 0. c c iord - integer c vector of dimension at least limit, the first k c elements of which are pointers to the c error estimates over the subintervals, c such that elist(iord(1)), ..., elist(iord(k)) c form a decreasing sequence, with k = last c if last.le.(limit/2+2), and k = limit+1-last c otherwise c c last - integer c number of subintervals actually produced in the c subdivisions process c c***references (none) c***routines called d1mach,dqelg,dqk21,dqpsrt c***end prologue dqagpe double precision a,abseps,abserr,alist,area,area1,area12,area2,a1, * a2,b,blist,b1,b2,correc,dabs,defabs,defab1,defab2,dmax1,dmin1, * dres,d1mach,elist,epmach,epsabs,epsrel,erlarg,erlast,errbnd, * errmax,error1,erro12,error2,errsum,ertest,f,oflow,points,pts, * resa,resabs,reseps,result,res3la,rlist,rlist2,sign,temp,uflow integer i,id,ier,ierro,ind1,ind2,iord,ip1,iroff1,iroff2,iroff3,j, * jlow,jupbnd,k,ksgn,ktmin,last,levcur,level,levmax,limit,maxerr, * ndin,neval,nint,nintp1,npts,npts2,nres,nrmax,numrl2 logical extrap,noext c c dimension alist(limit),blist(limit),elist(limit),iord(limit), * level(limit),ndin(npts2),points(npts2),pts(npts2),res3la(3), * rlist(limit),rlist2(52) c external f c c the dimension of rlist2 is determined by the value of c limexp in subroutine epsalg (rlist2 should be of dimension c (limexp+2) at least). c c c list of major variables c ----------------------- c c alist - list of left end points of all subintervals c considered up to now c blist - list of right end points of all subintervals c considered up to now c rlist(i) - approximation to the integral over c (alist(i),blist(i)) c rlist2 - array of dimension at least limexp+2 c containing the part of the epsilon table which c is still needed for further computations c elist(i) - error estimate applying to rlist(i) c maxerr - pointer to the interval with largest error c estimate c errmax - elist(maxerr) c erlast - error on the interval currently subdivided c (before that subdivision has taken place) c area - sum of the integrals over the subintervals c errsum - sum of the errors over the subintervals c errbnd - requested accuracy max(epsabs,epsrel* c abs(result)) c *****1 - variable for the left subinterval c *****2 - variable for the right subinterval c last - index for subdivision c nres - number of calls to the extrapolation routine c numrl2 - number of elements in rlist2. if an appropriate c approximation to the compounded integral has c been obtained, it is put in rlist2(numrl2) after c numrl2 has been increased by one. c erlarg - sum of the errors over the intervals larger c than the smallest interval considered up to now c extrap - logical variable denoting that the routine c is attempting to perform extrapolation. i.e. c before subdividing the smallest interval we c try to decrease the value of erlarg. c noext - logical variable denoting that extrapolation is c no longer allowed (true-value) c c machine dependent constants c --------------------------- c c epmach is the largest relative spacing. c uflow is the smallest positive magnitude. c oflow is the largest positive magnitude. c c***first executable statement dqagpe epmach = d1mach(4) c c test on validity of parameters c ----------------------------- c ier = 0 neval = 0 last = 0 result = 0.0d+00 abserr = 0.0d+00 alist(1) = a blist(1) = b rlist(1) = 0.0d+00 elist(1) = 0.0d+00 iord(1) = 0 level(1) = 0 npts = npts2-2 if(npts2.lt.2.or.limit.le.npts.or.(epsabs.le.0.0d+00.and. * epsrel.lt.dmax1(0.5d+02*epmach,0.5d-28))) ier = 6 if(ier.eq.6) go to 999 c c if any break points are provided, sort them into an c ascending sequence. c sign = 1.0d+00 if(a.gt.b) sign = -1.0d+00 pts(1) = dmin1(a,b) if(npts.eq.0) go to 15 do 10 i = 1,npts pts(i+1) = points(i) 10 continue 15 pts(npts+2) = dmax1(a,b) nint = npts+1 a1 = pts(1) if(npts.eq.0) go to 40 nintp1 = nint+1 do 20 i = 1,nint ip1 = i+1 do 20 j = ip1,nintp1 if(pts(i).le.pts(j)) go to 20 temp = pts(i) pts(i) = pts(j) pts(j) = temp 20 continue if(pts(1).ne.dmin1(a,b).or.pts(nintp1).ne.dmax1(a,b)) ier = 6 if(ier.eq.6) go to 999 c c compute first integral and error approximations. c ------------------------------------------------ c 40 resabs = 0.0d+00 do 50 i = 1,nint b1 = pts(i+1) call dqk21(f,a1,b1,area1,error1,defabs,resa) abserr = abserr+error1 result = result+area1 ndin(i) = 0 if(error1.eq.resa.and.error1.ne.0.0d+00) ndin(i) = 1 resabs = resabs+defabs level(i) = 0 elist(i) = error1 alist(i) = a1 blist(i) = b1 rlist(i) = area1 iord(i) = i a1 = b1 50 continue errsum = 0.0d+00 do 55 i = 1,nint if(ndin(i).eq.1) elist(i) = abserr errsum = errsum+elist(i) 55 continue c c test on accuracy. c last = nint neval = 21*nint dres = dabs(result) errbnd = dmax1(epsabs,epsrel*dres) if(abserr.le.0.1d+03*epmach*resabs.and.abserr.gt.errbnd) ier = 2 if(nint.eq.1) go to 80 do 70 i = 1,npts jlow = i+1 ind1 = iord(i) do 60 j = jlow,nint ind2 = iord(j) if(elist(ind1).gt.elist(ind2)) go to 60 ind1 = ind2 k = j 60 continue if(ind1.eq.iord(i)) go to 70 iord(k) = iord(i) iord(i) = ind1 70 continue if(limit.lt.npts2) ier = 1 80 if(ier.ne.0.or.abserr.le.errbnd) go to 210 c c initialization c -------------- c rlist2(1) = result maxerr = iord(1) errmax = elist(maxerr) area = result nrmax = 1 nres = 0 numrl2 = 1 ktmin = 0 extrap = .false. noext = .false. erlarg = errsum ertest = errbnd levmax = 1 iroff1 = 0 iroff2 = 0 iroff3 = 0 ierro = 0 uflow = d1mach(1) oflow = d1mach(2) abserr = oflow ksgn = -1 if(dres.ge.(0.1d+01-0.5d+02*epmach)*resabs) ksgn = 1 c c main do-loop c ------------ c do 160 last = npts2,limit c c bisect the subinterval with the nrmax-th largest error c estimate. c levcur = level(maxerr)+1 a1 = alist(maxerr) b1 = 0.5d+00*(alist(maxerr)+blist(maxerr)) a2 = b1 b2 = blist(maxerr) erlast = errmax call dqk21(f,a1,b1,area1,error1,resa,defab1) call dqk21(f,a2,b2,area2,error2,resa,defab2) c c improve previous approximations to integral c and error and test for accuracy. c neval = neval+42 area12 = area1+area2 erro12 = error1+error2 errsum = errsum+erro12-errmax area = area+area12-rlist(maxerr) if(defab1.eq.error1.or.defab2.eq.error2) go to 95 if(dabs(rlist(maxerr)-area12).gt.0.1d-04*dabs(area12) * .or.erro12.lt.0.99d+00*errmax) go to 90 if(extrap) iroff2 = iroff2+1 if(.not.extrap) iroff1 = iroff1+1 90 if(last.gt.10.and.erro12.gt.errmax) iroff3 = iroff3+1 95 level(maxerr) = levcur level(last) = levcur rlist(maxerr) = area1 rlist(last) = area2 errbnd = dmax1(epsabs,epsrel*dabs(area)) c c test for roundoff error and eventually set error flag. c if(iroff1+iroff2.ge.10.or.iroff3.ge.20) ier = 2 if(iroff2.ge.5) ierro = 3 c c set error flag in the case that the number of c subintervals equals limit. c if(last.eq.limit) ier = 1 c c set error flag in the case of bad integrand behaviour c at a point of the integration range c if(dmax1(dabs(a1),dabs(b2)).le.(0.1d+01+0.1d+03*epmach)* * (dabs(a2)+0.1d+04*uflow)) ier = 4 c c append the newly-created intervals to the list. c if(error2.gt.error1) go to 100 alist(last) = a2 blist(maxerr) = b1 blist(last) = b2 elist(maxerr) = error1 elist(last) = error2 go to 110 100 alist(maxerr) = a2 alist(last) = a1 blist(last) = b1 rlist(maxerr) = area2 rlist(last) = area1 elist(maxerr) = error2 elist(last) = error1 c c call subroutine dqpsrt to maintain the descending ordering c in the list of error estimates and select the subinterval c with nrmax-th largest error estimate (to be bisected next). c 110 call dqpsrt(limit,last,maxerr,errmax,elist,iord,nrmax) c ***jump out of do-loop if(errsum.le.errbnd) go to 190 c ***jump out of do-loop if(ier.ne.0) go to 170 if(noext) go to 160 erlarg = erlarg-erlast if(levcur+1.le.levmax) erlarg = erlarg+erro12 if(extrap) go to 120 c c test whether the interval to be bisected next is the c smallest interval. c if(level(maxerr)+1.le.levmax) go to 160 extrap = .true. nrmax = 2 120 if(ierro.eq.3.or.erlarg.le.ertest) go to 140 c c the smallest interval has the largest error. c before bisecting decrease the sum of the errors over c the larger intervals (erlarg) and perform extrapolation. c id = nrmax jupbnd = last if(last.gt.(2+limit/2)) jupbnd = limit+3-last do 130 k = id,jupbnd maxerr = iord(nrmax) errmax = elist(maxerr) c ***jump out of do-loop if(level(maxerr)+1.le.levmax) go to 160 nrmax = nrmax+1 130 continue c c perform extrapolation. c 140 numrl2 = numrl2+1 rlist2(numrl2) = area if(numrl2.le.2) go to 155 call dqelg(numrl2,rlist2,reseps,abseps,res3la,nres) ktmin = ktmin+1 if(ktmin.gt.5.and.abserr.lt.0.1d-02*errsum) ier = 5 if(abseps.ge.abserr) go to 150 ktmin = 0 abserr = abseps result = reseps correc = erlarg ertest = dmax1(epsabs,epsrel*dabs(reseps)) c ***jump out of do-loop if(abserr.lt.ertest) go to 170 c c prepare bisection of the smallest interval. c 150 if(numrl2.eq.1) noext = .true. if(ier.ge.5) go to 170 155 maxerr = iord(1) errmax = elist(maxerr) nrmax = 1 extrap = .false. levmax = levmax+1 erlarg = errsum 160 continue c c set the final result. c --------------------- c c 170 if(abserr.eq.oflow) go to 190 if((ier+ierro).eq.0) go to 180 if(ierro.eq.3) abserr = abserr+correc if(ier.eq.0) ier = 3 if(result.ne.0.0d+00.and.area.ne.0.0d+00)go to 175 if(abserr.gt.errsum)go to 190 if(area.eq.0.0d+00) go to 210 go to 180 175 if(abserr/dabs(result).gt.errsum/dabs(area))go to 190 c c test on divergence. c 180 if(ksgn.eq.(-1).and.dmax1(dabs(result),dabs(area)).le. * resabs*0.1d-01) go to 210 if(0.1d-01.gt.(result/area).or.(result/area).gt.0.1d+03.or. * errsum.gt.dabs(area)) ier = 6 go to 210 c c compute global integral sum. c 190 result = 0.0d+00 do 200 k = 1,last result = result+rlist(k) 200 continue abserr = errsum 210 if(ier.gt.2) ier = ier-1 result = result*sign 999 return end
bsd-3-clause
Vitancourt/gcc
gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_product.f90
190
1085
! Program to test the PRODUCT intrinsic program testproduct implicit none integer, dimension (3, 3) :: a integer, dimension (3) :: b logical, dimension (3, 3) :: m, tr character(len=12) line a = reshape ((/1, 2, 3, 4, 5, 6, 7, 8, 9/), (/3, 3/)); b = product (a, 1) tr = .true. if (any(b .ne. (/6, 120, 504/))) call abort write (line, 9000) product(a,1) if (line .ne. ' 6 120 504') call abort if (product (a) .ne. 362880) call abort write (line, 9010) product(a) if (line .ne. '362880') call abort m = .true. m(1, 1) = .false. m(2, 1) = .false. b = product (a, 2, m) if (any(b .ne. (/28, 40, 162/))) call abort b = product (a, 2, m .and. tr) if (any(b .ne. (/28, 40, 162/))) call abort write (line, 9000) product(a, 2, m) if (line .ne. ' 28 40 162') call abort if (product (a, mask=m) .ne. 181440) call abort if (product (a, mask=m .and. tr) .ne. 181440) call abort write (line, 9010) product(a, mask=m) if (line .ne. '181440') call abort 9000 format (3I4) 9010 format (I6) end program
gpl-2.0