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
Alexpux/GCC
gcc/testsuite/gfortran.dg/gomp/crayptr1.f90
166
1189
! { dg-do compile } ! { dg-options "-fopenmp -fcray-pointer" } integer :: a, b, c, d, i pointer (ip1, a) pointer (ip2, b) pointer (ip3, c) pointer (ip4, d) !$omp parallel shared (a) ! { dg-error "Cray pointee 'a' in SHARED clause" } !$omp end parallel !$omp parallel private (b) ! { dg-error "Cray pointee 'b' in PRIVATE clause" } !$omp end parallel !$omp parallel firstprivate (c) ! { dg-error "Cray pointee 'c' in FIRSTPRIVATE clause" } !$omp end parallel !$omp parallel do lastprivate (d) ! { dg-error "Cray pointee 'd' in LASTPRIVATE clause" } do i = 1, 10 if (i .eq. 10) d = 1 end do !$omp end parallel do !$omp parallel reduction (+: a) ! { dg-error "Cray pointee 'a' in REDUCTION clause" } !$omp end parallel ip1 = loc (i) !$omp parallel shared (ip1) a = 2 !$omp end parallel !$omp parallel private (ip2, i) ip2 = loc (i) b = 1 !$omp end parallel ip3 = loc (i) !$omp parallel firstprivate (ip3) !$omp end parallel !$omp parallel do lastprivate (ip4) do i = 1, 10 if (i .eq. 10) ip4 = loc (i) end do !$omp end parallel do !$omp parallel reduction (+: ip1) ! { dg-error "Cray pointer 'ip1' in REDUCTION clause" } !$omp end parallel end
gpl-2.0
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/coarray/image_index_1.f90
147
2745
! { dg-do run } ! ! Run-time test for IMAGE_INDEX with cobounds only known at ! the compile time, suitable for any number of NUM_IMAGES() ! For compile-time cobounds, the -fcoarray=lib version still ! needs to run-time evalulation if image_index returns > 1 ! as image_index is 0 if the index would exceed num_images(). ! ! Please set num_images() to >= 13, if possible. ! ! PR fortran/18918 ! program test_image_index implicit none integer :: index1, index2, index3 logical :: one integer, allocatable :: a(:)[:,:,:], b(:)[:,:], c(:,:)[:] integer, save :: d(2)[-1:3, *] integer, save :: e(2)[-1:-1, 3:*] one = num_images() == 1 allocate(a(1)[3:3, -4:-3, 88:*]) allocate(b(2)[-1:0,0:*]) allocate(c(3,3)[*]) index1 = image_index(a, [3, -4, 88] ) index2 = image_index(b, [-1, 0] ) index3 = image_index(c, [1] ) if (index1 /= 1 .or. index2 /= 1 .or. index3 /= 1) call abort() index1 = image_index(a, [3, -3, 88] ) index2 = image_index(b, [0, 0] ) index3 = image_index(c, [2] ) if (one .and. (index1 /= 0 .or. index2 /= 0 .or. index3 /= 0)) & call abort() if (.not. one .and. (index1 /= 2 .or. index2 /= 2 .or. index3 /= 2)) & call abort() index1 = image_index(d, [-1, 1] ) index2 = image_index(d, [0, 1] ) if (one .and. (index1 /= 1 .or. index2 /= 0)) & call abort() if (.not. one .and. (index1 /= 1 .or. index2 /= 2)) & call abort() index1 = image_index(e, [-1, 3] ) index2 = image_index(e, [-1, 4] ) if (one .and. (index1 /= 1 .or. index2 /= 0)) & call abort() if (.not. one .and. (index1 /= 1 .or. index2 /= 2)) & call abort() call test(1, a,b,c) ! The following test is in honour of the F2008 standard: deallocate(a) allocate(a (10) [10, 0:9, 0:*]) index1 = image_index(a, [1, 0, 0] ) index2 = image_index(a, [3, 1, 2] ) ! = 213, yeah! index3 = image_index(a, [3, 1, 0] ) ! = 13 if (num_images() < 13 .and. (index1 /= 1 .or. index2 /= 0 .or. index3 /= 0)) & call abort() if (num_images() >= 213 .and. (index1 /= 1 .or. index2 /= 213 .or. index3 /= 13)) & call abort() if (num_images() >= 13 .and. (index1 /= 1 .or. index2 /= 0 .or. index3 /= 13)) & call abort() contains subroutine test(n, a, b, c) integer :: n integer :: a(1)[3*n:3*n, -4*n:-3*n, 88*n:*], b(2)[-1*n:0*n,0*n:*], c(3*n,3*n)[*] index1 = image_index(a, [3, -4, 88] ) index2 = image_index(b, [-1, 0] ) index3 = image_index(c, [1] ) if (index1 /= 1 .or. index2 /= 1 .or. index3 /= 1) call abort() index1 = image_index(a, [3, -3, 88] ) index2 = image_index(b, [0, 0] ) index3 = image_index(c, [2] ) if (one .and. (index1 /= 0 .or. index2 /= 0 .or. index3 /= 0)) & call abort() if (.not. one .and. (index1 /= 2 .or. index2 /= 2 .or. index3 /= 2)) & call abort() end subroutine test end program test_image_index
gpl-2.0
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/fmt_f0_1.f90
162
1761
! { dg-do run } ! PR39304 write of 0.0 with F0.3 gives ** ! PR47567 Small absolute values. ! Test case developed from case provided by reporter. REAL :: x CHARACTER(80) :: str x = 0.0 write (str,'(f0.0)') x if (str.ne."0.") call abort write (str,'(f0.1)') x if (str.ne.".0") call abort write (str,'(f0.2)') x if (str.ne.".00") call abort write (str,'(f0.3)') x if (str.ne.".000") call abort write (str,'(f0.4)') x if (str.ne.".0000") call abort write (str,'(F0.0)') 0.0 if (str.ne."0.") call abort write (str,'(F0.0)') 0.001 if (str.ne."0.") call abort write (str,'(F0.0)') 0.01 if (str.ne."0.") call abort write (str,'(F0.0)') 0.1 if (str.ne."0.") call abort write (str,'(F1.0)') -0.0 if (str.ne."*") call abort write (str,'(F1.0)') 0.001 if (str.ne."*") call abort write (str,'(F1.0)') 0.01 if (str.ne."*") call abort write (str,'(F1.0)') 0.1 if (str.ne."*") call abort write (str,'(F2.0)') -0.001 if (str.ne."**") call abort write (str,'(F2.0)') -0.01 if (str.ne."**") call abort write (str,'(F2.0)') -0.1 if (str.ne."**") call abort write (str,'(F0.2)') 0.0 if (str.ne.".00") call abort write (str,'(F0.0)') -0.0 if (str.ne."-0.") call abort write (str,'(F0.1)') -0.0 if (str.ne."-.0") call abort write (str,'(F0.2)') -0.0 if (str.ne."-.00") call abort write (str,'(F0.3)') -0.0 if (str.ne."-.000") call abort write (str,'(F3.0)') -0.0 if (str.ne."-0.") call abort write (str,'(F2.0)') -0.0 if (str.ne."**") call abort write (str,'(F1.0)') -0.0 if (str.ne."*") call abort write (str,'(F0.1)') -0.0 if (str.ne."-.0") call abort write (str,'(F3.1)') -0.0 if (str.ne."-.0") call abort write (str,'(F2.1)') -0.0 if (str.ne."**") call abort write (str,'(F1.1)') -0.0 if (str.ne."*") call abort END
gpl-2.0
Alexpux/GCC
gcc/testsuite/gfortran.dg/ieee/ieee_7.f90
34
1311
! { dg-do run } use :: ieee_arithmetic implicit none ! Test IEEE_SELECTED_REAL_KIND in specification expressions integer(kind=ieee_selected_real_kind()) :: i1 integer(kind=ieee_selected_real_kind(10)) :: i2 integer(kind=ieee_selected_real_kind(10,10)) :: i3 integer(kind=ieee_selected_real_kind(10,10,2)) :: i4 ! Test IEEE_SELECTED_REAL_KIND if (ieee_support_datatype(0.)) then if (ieee_selected_real_kind() /= kind(0.)) call abort if (ieee_selected_real_kind(0) /= kind(0.)) call abort if (ieee_selected_real_kind(0,0) /= kind(0.)) call abort if (ieee_selected_real_kind(0,0,2) /= kind(0.)) call abort end if if (ieee_support_datatype(0.d0)) then if (ieee_selected_real_kind(precision(0.)+1) /= kind(0.d0)) call abort if (ieee_selected_real_kind(precision(0.),range(0.)+1) /= kind(0.d0)) call abort if (ieee_selected_real_kind(precision(0.)+1,range(0.)+1) /= kind(0.d0)) call abort if (ieee_selected_real_kind(precision(0.)+1,range(0.)+1,2) /= kind(0.d0)) call abort end if if (ieee_selected_real_kind(0,0,3) /= -5) call abort if (ieee_selected_real_kind(precision(0.d0)+1) /= -1) call abort if (ieee_selected_real_kind(0,range(0.d0)+1) /= -2) call abort if (ieee_selected_real_kind(precision(0.d0)+1,range(0.d0)+1) /= -3) call abort end
gpl-2.0
Anatoscope/sofa
SofaKernel/extlibs/eigen-3.3.3/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
lgpl-2.1
Alexpux/GCC
gcc/testsuite/gfortran.dg/c_f_pointer_tests_3.f90
88
1524
! { dg-do compile } ! { dg-options "-O2 -fdump-tree-original" } ! ! PR fortran/32600 c_f_pointer w/o shape ! PR fortran/32580 c_f_procpointer ! ! Verify that c_f_prointer [w/o shape] and c_f_procpointer generate ! the right code - and no library call program test use iso_c_binding implicit none type(c_ptr) :: cptr type(c_funptr) :: cfunptr integer(4), pointer :: fptr integer(4), pointer :: fptr_array(:) procedure(integer(4)), pointer :: fprocptr call c_f_pointer(cptr, fptr) call c_f_pointer(cptr, fptr_array, [ 1 ]) call c_f_procpointer(cfunptr, fprocptr) end program test ! Make sure there is no function call: ! { dg-final { scan-tree-dump-times "c_f" 0 "original" } } ! { dg-final { scan-tree-dump-times "c_f_pointer" 0 "original" } } ! { dg-final { scan-tree-dump-times "c_f_pointer_i4" 0 "original" } } ! ! Check scalar c_f_pointer ! { dg-final { scan-tree-dump-times " fptr = .integer.kind=4. .. cptr" 1 "original" } } ! ! Array c_f_pointer: ! ! { dg-final { scan-tree-dump-times " fptr_array.data = cptr;" 1 "original" } } ! { dg-final { scan-tree-dump-times " fptr_array.dim\\\[S..\\\].lbound = 1;" 1 "original" } } ! { dg-final { scan-tree-dump-times " fptr_array.dim\\\[S..\\\].ubound = " 1 "original" } } ! { dg-final { scan-tree-dump-times " fptr_array.dim\\\[S..\\\].stride = " 1 "original" } } ! ! Check c_f_procpointer ! { dg-final { scan-tree-dump-times " fprocptr = .integer.kind=4. .\\*<.*>. ... cfunptr;" 1 "original" } } ! ! { dg-final { cleanup-tree-dump "original" } }
gpl-2.0
crtc-demos/gcc-ia16
libgfortran/generated/_abs_r8.F90
16
1468
! Copyright (C) 2002-2016 Free Software Foundation, Inc. ! Contributed by Paul Brook <paul@nowt.org> ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !GNU libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. !GNU libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. ! !This file is machine generated. #include "config.h" #include "kinds.inc" #include "c99_protos.inc" #if defined (HAVE_GFC_REAL_8) #ifdef HAVE_FABS elemental function _gfortran_specific__abs_r8 (parm) real (kind=8), intent (in) :: parm real (kind=8) :: _gfortran_specific__abs_r8 _gfortran_specific__abs_r8 = abs (parm) end function #endif #endif
gpl-2.0
Alexpux/GCC
libgomp/testsuite/libgomp.fortran/vla3.f90
202
7527
! { dg-do run } call test contains subroutine check (x, y, l) integer :: x, y logical :: l l = l .or. x .ne. y end subroutine check subroutine foo (c, d, e, f, g, h, i, j, k, n) use omp_lib integer :: n character (len = *) :: c character (len = n) :: d integer, dimension (2, 3:5, n) :: e integer, dimension (2, 3:n, n) :: f character (len = *), dimension (5, 3:n) :: g character (len = n), dimension (5, 3:n) :: h real, dimension (:, :, :) :: i double precision, dimension (3:, 5:, 7:) :: j integer, dimension (:, :, :) :: k logical :: l integer :: p, q, r character (len = n) :: s integer, dimension (2, 3:5, n) :: t integer, dimension (2, 3:n, n) :: u character (len = n), dimension (5, 3:n) :: v character (len = 2 * n + 24) :: w integer :: x, z character (len = 1) :: y s = 'PQRSTUV' forall (p = 1:2, q = 3:5, r = 1:7) t(p, q, r) = -10 + p - q + 2 * r forall (p = 1:2, q = 3:7, r = 1:7) u(p, q, r) = 30 - p + q - 2 * r forall (p = 1:5, q = 3:7, p + q .le. 8) v(p, q) = '_+|/Oo_' forall (p = 1:5, q = 3:7, p + q .gt. 8) v(p, q) = '///|||!' l = .false. !$omp parallel default (none) shared (c, d, e, f, g, h, i, j, k) & !$omp & shared (s, t, u, v) reduction (.or.:l) num_threads (6) & !$omp private (p, q, r, w, x, y) l = l .or. c .ne. 'abcdefghijkl' l = l .or. d .ne. 'ABCDEFG' l = l .or. s .ne. 'PQRSTUV' do 100, p = 1, 2 do 100, q = 3, 7 do 100, r = 1, 7 if (q .lt. 6) l = l .or. e(p, q, r) .ne. 5 + p + q + 2 * r l = l .or. f(p, q, r) .ne. 25 + p + q + 2 * r if (r .lt. 6 .and. q + r .le. 8) l = l .or. g(r, q) .ne. '0123456789AB' if (r .lt. 6 .and. q + r .gt. 8) l = l .or. g(r, q) .ne. '9876543210ZY' if (r .lt. 6 .and. q + r .le. 8) l = l .or. h(r, q) .ne. '0123456' if (r .lt. 6 .and. q + r .gt. 8) l = l .or. h(r, q) .ne. '9876543' if (q .lt. 6) l = l .or. t(p, q, r) .ne. -10 + p - q + 2 * r l = l .or. u(p, q, r) .ne. 30 - p + q - 2 * r if (r .lt. 6 .and. q + r .le. 8) l = l .or. v(r, q) .ne. '_+|/Oo_' if (r .lt. 6 .and. q + r .gt. 8) l = l .or. v(r, q) .ne. '///|||!' 100 continue do 101, p = 3, 5 do 101, q = 2, 6 do 101, r = 1, 7 l = l .or. i(p - 2, q - 1, r) .ne. 7.5 * p * q * r l = l .or. j(p, q + 3, r + 6) .ne. 9.5 * p * q * r 101 continue do 102, p = 1, 5 do 102, q = 4, 6 l = l .or. k(p, 1, q - 3) .ne. 19 + p + 7 + 3 * q 102 continue do 110 z = 0, omp_get_num_threads () - 1 !$omp barrier x = omp_get_thread_num () w = '' if (z .eq. 0) w = 'thread0thr_number_0THREAD0THR_NUMBER_0' if (z .eq. 1) w = 'thread1thr_number_1THREAD1THR_NUMBER_1' if (z .eq. 2) w = 'thread2thr_number_2THREAD2THR_NUMBER_2' if (z .eq. 3) w = 'thread3thr_number_3THREAD3THR_NUMBER_3' if (z .eq. 4) w = 'thread4thr_number_4THREAD4THR_NUMBER_4' if (z .eq. 5) w = 'thread5thr_number_5THREAD5THR_NUMBER_5' if (x .eq. z) then c = w(8:19) d = w(1:7) forall (p = 1:2, q = 3:5, r = 1:7) e(p, q, r) = 5 * x + p + q + 2 * r forall (p = 1:2, q = 3:7, r = 1:7) f(p, q, r) = 25 * x + p + q + 2 * r forall (p = 1:5, q = 3:7, p + q .le. 8) g(p, q) = w(8:19) forall (p = 1:5, q = 3:7, p + q .gt. 8) g(p, q) = w(27:38) forall (p = 1:5, q = 3:7, p + q .le. 8) h(p, q) = w(1:7) forall (p = 1:5, q = 3:7, p + q .gt. 8) h(p, q) = w(20:26) forall (p = 3:5, q = 2:6, r = 1:7) i(p - 2, q - 1, r) = (7.5 + x) * p * q * r forall (p = 3:5, q = 2:6, r = 1:7) j(p, q + 3, r + 6) = (9.5 + x) * p * q * r forall (p = 1:5, q = 7:7, r = 4:6) k(p, q - 6, r - 3) = 19 + x + p + q + 3 * r s = w(20:26) forall (p = 1:2, q = 3:5, r = 1:7) t(p, q, r) = -10 + x + p - q + 2 * r forall (p = 1:2, q = 3:7, r = 1:7) u(p, q, r) = 30 - x - p + q - 2 * r forall (p = 1:5, q = 3:7, p + q .le. 8) v(p, q) = w(1:7) forall (p = 1:5, q = 3:7, p + q .gt. 8) v(p, q) = w(20:26) end if !$omp barrier x = z y = '' if (x .eq. 0) y = '0' if (x .eq. 1) y = '1' if (x .eq. 2) y = '2' if (x .eq. 3) y = '3' if (x .eq. 4) y = '4' if (x .eq. 5) y = '5' l = l .or. w(7:7) .ne. y l = l .or. w(19:19) .ne. y l = l .or. w(26:26) .ne. y l = l .or. w(38:38) .ne. y l = l .or. c .ne. w(8:19) l = l .or. d .ne. w(1:7) l = l .or. s .ne. w(20:26) do 103, p = 1, 2 do 103, q = 3, 7 do 103, r = 1, 7 if (q .lt. 6) l = l .or. e(p, q, r) .ne. 5 * x + p + q + 2 * r l = l .or. f(p, q, r) .ne. 25 * x + p + q + 2 * r if (r .lt. 6 .and. q + r .le. 8) l = l .or. g(r, q) .ne. w(8:19) if (r .lt. 6 .and. q + r .gt. 8) l = l .or. g(r, q) .ne. w(27:38) if (r .lt. 6 .and. q + r .le. 8) l = l .or. h(r, q) .ne. w(1:7) if (r .lt. 6 .and. q + r .gt. 8) l = l .or. h(r, q) .ne. w(20:26) if (q .lt. 6) l = l .or. t(p, q, r) .ne. -10 + x + p - q + 2 * r l = l .or. u(p, q, r) .ne. 30 - x - p + q - 2 * r if (r .lt. 6 .and. q + r .le. 8) l = l .or. v(r, q) .ne. w(1:7) if (r .lt. 6 .and. q + r .gt. 8) l = l .or. v(r, q) .ne. w(20:26) 103 continue do 104, p = 3, 5 do 104, q = 2, 6 do 104, r = 1, 7 l = l .or. i(p - 2, q - 1, r) .ne. (7.5 + x) * p * q * r l = l .or. j(p, q + 3, r + 6) .ne. (9.5 + x) * p * q * r 104 continue do 105, p = 1, 5 do 105, q = 4, 6 l = l .or. k(p, 1, q - 3) .ne. 19 + x + p + 7 + 3 * q 105 continue 110 continue call check (size (e, 1), 2, l) call check (size (e, 2), 3, l) call check (size (e, 3), 7, l) call check (size (e), 42, l) call check (size (f, 1), 2, l) call check (size (f, 2), 5, l) call check (size (f, 3), 7, l) call check (size (f), 70, l) call check (size (g, 1), 5, l) call check (size (g, 2), 5, l) call check (size (g), 25, l) call check (size (h, 1), 5, l) call check (size (h, 2), 5, l) call check (size (h), 25, l) call check (size (i, 1), 3, l) call check (size (i, 2), 5, l) call check (size (i, 3), 7, l) call check (size (i), 105, l) call check (size (j, 1), 4, l) call check (size (j, 2), 5, l) call check (size (j, 3), 7, l) call check (size (j), 140, l) call check (size (k, 1), 5, l) call check (size (k, 2), 1, l) call check (size (k, 3), 3, l) call check (size (k), 15, l) !$omp end parallel if (l) call abort end subroutine foo subroutine test character (len = 12) :: c character (len = 7) :: d integer, dimension (2, 3:5, 7) :: e integer, dimension (2, 3:7, 7) :: f character (len = 12), dimension (5, 3:7) :: g character (len = 7), dimension (5, 3:7) :: h real, dimension (3:5, 2:6, 1:7) :: i double precision, dimension (3:6, 2:6, 1:7) :: j integer, dimension (1:5, 7:7, 4:6) :: k integer :: p, q, r c = 'abcdefghijkl' d = 'ABCDEFG' forall (p = 1:2, q = 3:5, r = 1:7) e(p, q, r) = 5 + p + q + 2 * r forall (p = 1:2, q = 3:7, r = 1:7) f(p, q, r) = 25 + p + q + 2 * r forall (p = 1:5, q = 3:7, p + q .le. 8) g(p, q) = '0123456789AB' forall (p = 1:5, q = 3:7, p + q .gt. 8) g(p, q) = '9876543210ZY' forall (p = 1:5, q = 3:7, p + q .le. 8) h(p, q) = '0123456' forall (p = 1:5, q = 3:7, p + q .gt. 8) h(p, q) = '9876543' forall (p = 3:5, q = 2:6, r = 1:7) i(p, q, r) = 7.5 * p * q * r forall (p = 3:6, q = 2:6, r = 1:7) j(p, q, r) = 9.5 * p * q * r forall (p = 1:5, q = 7:7, r = 4:6) k(p, q, r) = 19 + p + q + 3 * r call foo (c, d, e, f, g, h, i, j, k, 7) end subroutine test end
gpl-2.0
crtc-demos/gcc-ia16
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
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/entry_13.f90
136
1751
! { dg-do run } ! Tests the fix for pr31214, in which the typespec for the entry would be lost, ! thereby causing the function to be disallowed, since the function and entry ! types did not match. ! ! Contributed by Joost VandeVondele <jv244@cam.ac.uk> ! module type_mod implicit none type x real x end type x type y real x end type y type z real x end type z interface assignment(=) module procedure equals end interface assignment(=) interface operator(//) module procedure a_op_b, b_op_a end interface operator(//) interface operator(==) module procedure a_po_b, b_po_a end interface operator(==) contains subroutine equals(x,y) type(z), intent(in) :: y type(z), intent(out) :: x x%x = y%x end subroutine equals function a_op_b(a,b) type(x), intent(in) :: a type(y), intent(in) :: b type(z) a_op_b type(z) b_op_a a_op_b%x = a%x + b%x return entry b_op_a(b,a) b_op_a%x = a%x - b%x end function a_op_b function a_po_b(a,b) type(x), intent(in) :: a type(y), intent(in) :: b type(z) a_po_b type(z) b_po_a entry b_po_a(b,a) a_po_b%x = a%x/b%x end function a_po_b end module type_mod program test use type_mod implicit none type(x) :: x1 = x(19.0_4) type(y) :: y1 = y(7.0_4) type(z) z1 z1 = x1//y1 if (abs(z1%x - (19.0_4 + 7.0_4)) > epsilon(x1%x)) call abort () z1 = y1//x1 if (abs(z1%x - (19.0_4 - 7.0_4)) > epsilon(x1%x)) call abort () z1 = x1==y1 if (abs(z1%x - 19.0_4/7.0_4) > epsilon(x1%x)) call abort () z1 = y1==x1 if (abs(z1%x - 19.0_4/7.0_4) > epsilon(x1%x)) call abort () end program test
gpl-2.0
crtc-demos/gcc-ia16
libgfortran/generated/_sinh_r4.F90
16
1473
! Copyright (C) 2002-2016 Free Software Foundation, Inc. ! Contributed by Paul Brook <paul@nowt.org> ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !GNU libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. !GNU libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. ! !This file is machine generated. #include "config.h" #include "kinds.inc" #include "c99_protos.inc" #if defined (HAVE_GFC_REAL_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
Alexpux/GCC
gcc/testsuite/gfortran.dg/sizeof.f90
162
2083
! { dg-do run } ! Verify that the sizeof intrinsic does as advertised subroutine check_int (j) INTEGER(4) :: i, ia(5), ib(5,4), ip, ipa(:) target :: ib POINTER :: ip, ipa logical :: l(6) integer(8) :: jb(5,4) if (sizeof (jb) /= 2*sizeof (ib)) call abort if (sizeof(j) == 4) then if (sizeof (j) /= sizeof (i)) call abort else if (sizeof (j) /= 2 * sizeof (i)) call abort end if ipa=>ib(2:3,1) l = (/ sizeof(i) == 4, sizeof(ia) == 20, sizeof(ib) == 80, & sizeof(ip) == 4, sizeof(ipa) == 8, sizeof(ib(1:5:2,3)) == 12 /) if (any(.not.l)) call abort if (sizeof(l) /= 6*sizeof(l(1))) call abort end subroutine check_int subroutine check_real (x, y) dimension y(5) real(4) :: r(20,20,20), rp(:,:) target :: r pointer :: rp double precision :: d(5,5) complex(kind=4) :: c(5) if (sizeof (y) /= 5*sizeof (x)) call abort if (sizeof (r) /= 8000*4) call abort rp => r(5,2:10,1:5) if (sizeof (rp) /= 45*4) call abort rp => r(1:5,1:5,1) if (sizeof (d) /= 2*sizeof (rp)) call abort if (sizeof (c(1)) /= 2*sizeof(r(1,1,1))) call abort end subroutine check_real subroutine check_derived () type dt integer i end type dt type (dt) :: a integer :: i type foo integer :: i(5000) real :: j(5) type(dt) :: d end type foo type bar integer :: j(5000) real :: k(5) type(dt) :: d end type bar type (foo) :: oof type (bar) :: rab integer(8) :: size_500, size_200, sizev500, sizev200 type all real, allocatable :: r(:) end type all real :: r(200), s(500) type(all) :: v if (sizeof(a) /= sizeof(i)) call abort if (sizeof(oof) /= sizeof(rab)) call abort allocate (v%r(500)) sizev500 = sizeof (v) size_500 = sizeof (v%r) deallocate (v%r) allocate (v%r(200)) sizev200 = sizeof (v) size_200 = sizeof (v%r) deallocate (v%r) if (size_500 - size_200 /= sizeof(s) - sizeof(r) .or. sizev500 /= sizev200) & call abort end subroutine check_derived call check_int (1) call check_real (1.0, (/1.0, 2.0, 3.0, 4.0, 5.0/)) call check_derived () end
gpl-2.0
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/module_procedure_1.f90
136
1087
! { dg-do run } ! Modified program from http://groups.google.com/group/\ ! comp.lang.fortran/browse_frm/thread/423e4392dc965ab7# ! module myoperator contains function dadd(arg1,arg2) integer ::dadd(2) integer, intent(in) :: arg1(2), arg2(2) dadd(1)=arg1(1)+arg2(1) dadd(2)=arg1(2)+arg2(2) end function dadd end module myoperator program test_interface use myoperator implicit none interface operator (.myadd.) module procedure dadd end interface integer input1(2), input2(2), mysum(2) input1 = (/0,1/) input2 = (/3,3/) mysum = input1 .myadd. input2 if (mysum(1) /= 3 .and. mysum(2) /= 4) call abort call test_sub(input1, input2) end program test_interface subroutine test_sub(input1, input2) use myoperator implicit none interface operator (.myadd.) module procedure dadd end interface integer, intent(in) :: input1(2), input2(2) integer mysum(2) mysum = input1 .myadd. input2 if (mysum(1) /= 3 .and. mysum(2) /= 4) call abort end subroutine test_sub
gpl-2.0
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/pointer_check_2.f90
185
1629
! { dg-do run } ! { dg-options "-fcheck=pointer" } ! { dg-shouldfail "Unassociated/unallocated actual argument" } ! ! { dg-output ".*At line 60.*Pointer actual argument 'ptr1' is not associated" } ! ! PR fortran/40580 ! ! Run-time check of passing deallocated/nonassociated actuals ! to nonallocatable/nonpointer dummies. ! ! Check for variable actuals ! subroutine test1(a) integer :: a a = 4444 end subroutine test1 subroutine test2(a) integer :: a(2) a = 4444 end subroutine test2 subroutine ppTest(f) implicit none external f call f() end subroutine ppTest Program RunTimeCheck implicit none external :: test1, test2, ppTest integer, pointer :: ptr1, ptr2(:) integer, allocatable :: alloc2(:) procedure(), pointer :: pptr allocate(ptr1,ptr2(2),alloc2(2)) pptr => sub ! OK call test1(ptr1) call test3(ptr1) call test2(ptr2) call test2(alloc2) call test4(ptr2) call test4(alloc2) call ppTest(pptr) call ppTest2(pptr) ! Invalid 1: deallocate(alloc2) ! call test2(alloc2) ! call test4(alloc2) ! Invalid 2: deallocate(ptr1,ptr2) nullify(ptr1,ptr2) ! call test1(ptr1) call test3(ptr1) ! call test2(ptr2) ! call test4(ptr2) ! Invalid 3: nullify(pptr) ! call ppTest(pptr) call ppTest2(pptr) contains subroutine test3(b) integer :: b b = 333 end subroutine test3 subroutine test4(b) integer :: b(2) b = 333 end subroutine test4 subroutine sub() print *, 'Hello World' end subroutine sub subroutine ppTest2(f) implicit none procedure(sub) :: f call f() end subroutine ppTest2 end Program RunTimeCheck
gpl-2.0
Alexpux/GCC
gcc/testsuite/gfortran.dg/pointer_check_2.f90
185
1629
! { dg-do run } ! { dg-options "-fcheck=pointer" } ! { dg-shouldfail "Unassociated/unallocated actual argument" } ! ! { dg-output ".*At line 60.*Pointer actual argument 'ptr1' is not associated" } ! ! PR fortran/40580 ! ! Run-time check of passing deallocated/nonassociated actuals ! to nonallocatable/nonpointer dummies. ! ! Check for variable actuals ! subroutine test1(a) integer :: a a = 4444 end subroutine test1 subroutine test2(a) integer :: a(2) a = 4444 end subroutine test2 subroutine ppTest(f) implicit none external f call f() end subroutine ppTest Program RunTimeCheck implicit none external :: test1, test2, ppTest integer, pointer :: ptr1, ptr2(:) integer, allocatable :: alloc2(:) procedure(), pointer :: pptr allocate(ptr1,ptr2(2),alloc2(2)) pptr => sub ! OK call test1(ptr1) call test3(ptr1) call test2(ptr2) call test2(alloc2) call test4(ptr2) call test4(alloc2) call ppTest(pptr) call ppTest2(pptr) ! Invalid 1: deallocate(alloc2) ! call test2(alloc2) ! call test4(alloc2) ! Invalid 2: deallocate(ptr1,ptr2) nullify(ptr1,ptr2) ! call test1(ptr1) call test3(ptr1) ! call test2(ptr2) ! call test4(ptr2) ! Invalid 3: nullify(pptr) ! call ppTest(pptr) call ppTest2(pptr) contains subroutine test3(b) integer :: b b = 333 end subroutine test3 subroutine test4(b) integer :: b(2) b = 333 end subroutine test4 subroutine sub() print *, 'Hello World' end subroutine sub subroutine ppTest2(f) implicit none procedure(sub) :: f call f() end subroutine ppTest2 end Program RunTimeCheck
gpl-2.0
CFDEMproject/LIGGGHTS-PUBLIC
lib/linalg/dtrsv.f
72
10138
*> \brief \b DTRSV * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE DTRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX) * * .. Scalar Arguments .. * INTEGER INCX,LDA,N * CHARACTER DIAG,TRANS,UPLO * .. * .. Array Arguments .. * DOUBLE PRECISION A(LDA,*),X(*) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DTRSV solves one of the systems of equations *> *> A*x = b, or A**T*x = b, *> *> where b and x are n element vectors and A is an n by n unit, or *> non-unit, upper or lower triangular matrix. *> *> No test for singularity or near-singularity is included in this *> routine. Such tests must be performed before calling this routine. *> \endverbatim * * Arguments: * ========== * *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> On entry, UPLO specifies whether the matrix 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. *> \endverbatim *> *> \param[in] TRANS *> \verbatim *> TRANS is CHARACTER*1 *> On entry, TRANS specifies the equations to be solved as *> follows: *> *> TRANS = 'N' or 'n' A*x = b. *> *> TRANS = 'T' or 't' A**T*x = b. *> *> TRANS = 'C' or 'c' A**T*x = b. *> \endverbatim *> *> \param[in] DIAG *> \verbatim *> DIAG is 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. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> On entry, N specifies the order of the matrix A. *> N must be at least zero. *> \endverbatim *> *> \param[in] A *> \verbatim *> A is DOUBLE PRECISION array of DIMENSION ( LDA, n ). *> Before entry with UPLO = 'U' or 'u', the leading n by n *> 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 n by n *> 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. *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> On entry, LDA specifies the first dimension of A as declared *> in the calling (sub) program. LDA must be at least *> max( 1, n ). *> \endverbatim *> *> \param[in,out] X *> \verbatim *> X is DOUBLE PRECISION array of dimension at least *> ( 1 + ( n - 1 )*abs( INCX ) ). *> Before entry, the incremented array X must contain the n *> element right-hand side vector b. On exit, X is overwritten *> with the solution vector x. *> \endverbatim *> *> \param[in] INCX *> \verbatim *> INCX is INTEGER *> On entry, INCX specifies the increment for the elements of *> X. INCX must not be zero. *> *> Level 2 Blas routine. *> *> -- Written on 22-October-1986. *> Jack Dongarra, Argonne National Lab. *> Jeremy Du Croz, Nag Central Office. *> Sven Hammarling, Nag Central Office. *> Richard Hanson, Sandia National Labs. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup double_blas_level1 * * ===================================================================== SUBROUTINE DTRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX) * * -- Reference BLAS level1 routine (version 3.4.0) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. INTEGER INCX,LDA,N CHARACTER DIAG,TRANS,UPLO * .. * .. Array Arguments .. DOUBLE PRECISION A(LDA,*),X(*) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO PARAMETER (ZERO=0.0D+0) * .. * .. Local Scalars .. DOUBLE PRECISION TEMP INTEGER I,INFO,IX,J,JX,KX LOGICAL NOUNIT * .. * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX * .. * * Test the input parameters. * INFO = 0 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN INFO = 1 ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND. + .NOT.LSAME(TRANS,'C')) THEN INFO = 2 ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN INFO = 3 ELSE IF (N.LT.0) THEN INFO = 4 ELSE IF (LDA.LT.MAX(1,N)) THEN INFO = 6 ELSE IF (INCX.EQ.0) THEN INFO = 8 END IF IF (INFO.NE.0) THEN CALL XERBLA('DTRSV ',INFO) RETURN END IF * * Quick return if possible. * IF (N.EQ.0) RETURN * NOUNIT = LSAME(DIAG,'N') * * Set up the start point in X if the increment is not unity. This * will be ( N - 1 )*INCX too small for descending loops. * IF (INCX.LE.0) THEN KX = 1 - (N-1)*INCX ELSE IF (INCX.NE.1) THEN KX = 1 END IF * * Start the operations. In this version the elements of A are * accessed sequentially with one pass through A. * IF (LSAME(TRANS,'N')) THEN * * Form x := inv( A )*x. * IF (LSAME(UPLO,'U')) THEN IF (INCX.EQ.1) THEN DO 20 J = N,1,-1 IF (X(J).NE.ZERO) THEN IF (NOUNIT) X(J) = X(J)/A(J,J) TEMP = X(J) DO 10 I = J - 1,1,-1 X(I) = X(I) - TEMP*A(I,J) 10 CONTINUE END IF 20 CONTINUE ELSE JX = KX + (N-1)*INCX DO 40 J = N,1,-1 IF (X(JX).NE.ZERO) THEN IF (NOUNIT) X(JX) = X(JX)/A(J,J) TEMP = X(JX) IX = JX DO 30 I = J - 1,1,-1 IX = IX - INCX X(IX) = X(IX) - TEMP*A(I,J) 30 CONTINUE END IF JX = JX - INCX 40 CONTINUE END IF ELSE IF (INCX.EQ.1) THEN DO 60 J = 1,N IF (X(J).NE.ZERO) THEN IF (NOUNIT) X(J) = X(J)/A(J,J) TEMP = X(J) DO 50 I = J + 1,N X(I) = X(I) - TEMP*A(I,J) 50 CONTINUE END IF 60 CONTINUE ELSE JX = KX DO 80 J = 1,N IF (X(JX).NE.ZERO) THEN IF (NOUNIT) X(JX) = X(JX)/A(J,J) TEMP = X(JX) IX = JX DO 70 I = J + 1,N IX = IX + INCX X(IX) = X(IX) - TEMP*A(I,J) 70 CONTINUE END IF JX = JX + INCX 80 CONTINUE END IF END IF ELSE * * Form x := inv( A**T )*x. * IF (LSAME(UPLO,'U')) THEN IF (INCX.EQ.1) THEN DO 100 J = 1,N TEMP = X(J) DO 90 I = 1,J - 1 TEMP = TEMP - A(I,J)*X(I) 90 CONTINUE IF (NOUNIT) TEMP = TEMP/A(J,J) X(J) = TEMP 100 CONTINUE ELSE JX = KX DO 120 J = 1,N TEMP = X(JX) IX = KX DO 110 I = 1,J - 1 TEMP = TEMP - A(I,J)*X(IX) IX = IX + INCX 110 CONTINUE IF (NOUNIT) TEMP = TEMP/A(J,J) X(JX) = TEMP JX = JX + INCX 120 CONTINUE END IF ELSE IF (INCX.EQ.1) THEN DO 140 J = N,1,-1 TEMP = X(J) DO 130 I = N,J + 1,-1 TEMP = TEMP - A(I,J)*X(I) 130 CONTINUE IF (NOUNIT) TEMP = TEMP/A(J,J) X(J) = TEMP 140 CONTINUE ELSE KX = KX + (N-1)*INCX JX = KX DO 160 J = N,1,-1 TEMP = X(JX) IX = KX DO 150 I = N,J + 1,-1 TEMP = TEMP - A(I,J)*X(IX) IX = IX - INCX 150 CONTINUE IF (NOUNIT) TEMP = TEMP/A(J,J) X(JX) = TEMP JX = JX - INCX 160 CONTINUE END IF END IF END IF * RETURN * * End of DTRSV . * END
gpl-2.0
Anatoscope/sofa
SofaKernel/extlibs/eigen-3.3.3/blas/testing/dblat1.f
288
44819
*> \brief \b DBLAT1 * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * PROGRAM DBLAT1 * * *> \par Purpose: * ============= *> *> \verbatim *> *> Test program for the DOUBLE PRECISION Level 1 BLAS. *> *> Based upon the original BLAS test routine together with: *> F06EAF Example Program Text *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date April 2012 * *> \ingroup double_blas_testing * * ===================================================================== PROGRAM DBLAT1 * * -- Reference BLAS test routine (version 3.4.1) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * April 2012 * * ===================================================================== * * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. DOUBLE PRECISION SFAC INTEGER IC * .. External Subroutines .. EXTERNAL CHECK0, CHECK1, CHECK2, CHECK3, HEADER * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA SFAC/9.765625D-4/ * .. Executable Statements .. WRITE (NOUT,99999) DO 20 IC = 1, 13 ICASE = IC CALL HEADER * * .. Initialize PASS, INCX, and INCY for a new case. .. * .. the value 9999 for INCX or INCY will appear in the .. * .. detailed output, if any, for cases that do not involve .. * .. these parameters .. * PASS = .TRUE. INCX = 9999 INCY = 9999 IF (ICASE.EQ.3 .OR. ICASE.EQ.11) THEN CALL CHECK0(SFAC) ELSE IF (ICASE.EQ.7 .OR. ICASE.EQ.8 .OR. ICASE.EQ.9 .OR. + ICASE.EQ.10) THEN CALL CHECK1(SFAC) ELSE IF (ICASE.EQ.1 .OR. ICASE.EQ.2 .OR. ICASE.EQ.5 .OR. + ICASE.EQ.6 .OR. ICASE.EQ.12 .OR. ICASE.EQ.13) THEN CALL CHECK2(SFAC) ELSE IF (ICASE.EQ.4) THEN CALL CHECK3(SFAC) END IF * -- Print IF (PASS) WRITE (NOUT,99998) 20 CONTINUE STOP * 99999 FORMAT (' Real BLAS Test Program Results',/1X) 99998 FORMAT (' ----- PASS -----') END SUBROUTINE HEADER * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Arrays .. CHARACTER*6 L(13) * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA L(1)/' DDOT '/ DATA L(2)/'DAXPY '/ DATA L(3)/'DROTG '/ DATA L(4)/' DROT '/ DATA L(5)/'DCOPY '/ DATA L(6)/'DSWAP '/ DATA L(7)/'DNRM2 '/ DATA L(8)/'DASUM '/ DATA L(9)/'DSCAL '/ DATA L(10)/'IDAMAX'/ DATA L(11)/'DROTMG'/ DATA L(12)/'DROTM '/ DATA L(13)/'DSDOT '/ * .. Executable Statements .. WRITE (NOUT,99999) ICASE, L(ICASE) RETURN * 99999 FORMAT (/' Test of subprogram number',I3,12X,A6) END SUBROUTINE CHECK0(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. DOUBLE PRECISION SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. DOUBLE PRECISION SA, SB, SC, SS, D12 INTEGER I, K * .. Local Arrays .. DOUBLE PRECISION DA1(8), DATRUE(8), DB1(8), DBTRUE(8), DC1(8), $ DS1(8), DAB(4,9), DTEMP(9), DTRUE(9,9) * .. External Subroutines .. EXTERNAL DROTG, DROTMG, STEST1 * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA DA1/0.3D0, 0.4D0, -0.3D0, -0.4D0, -0.3D0, 0.0D0, + 0.0D0, 1.0D0/ DATA DB1/0.4D0, 0.3D0, 0.4D0, 0.3D0, -0.4D0, 0.0D0, + 1.0D0, 0.0D0/ DATA DC1/0.6D0, 0.8D0, -0.6D0, 0.8D0, 0.6D0, 1.0D0, + 0.0D0, 1.0D0/ DATA DS1/0.8D0, 0.6D0, 0.8D0, -0.6D0, 0.8D0, 0.0D0, + 1.0D0, 0.0D0/ DATA DATRUE/0.5D0, 0.5D0, 0.5D0, -0.5D0, -0.5D0, + 0.0D0, 1.0D0, 1.0D0/ DATA DBTRUE/0.0D0, 0.6D0, 0.0D0, -0.6D0, 0.0D0, + 0.0D0, 1.0D0, 0.0D0/ * INPUT FOR MODIFIED GIVENS DATA DAB/ .1D0,.3D0,1.2D0,.2D0, A .7D0, .2D0, .6D0, 4.2D0, B 0.D0,0.D0,0.D0,0.D0, C 4.D0, -1.D0, 2.D0, 4.D0, D 6.D-10, 2.D-2, 1.D5, 10.D0, E 4.D10, 2.D-2, 1.D-5, 10.D0, F 2.D-10, 4.D-2, 1.D5, 10.D0, G 2.D10, 4.D-2, 1.D-5, 10.D0, H 4.D0, -2.D0, 8.D0, 4.D0 / * TRUE RESULTS FOR MODIFIED GIVENS DATA DTRUE/0.D0,0.D0, 1.3D0, .2D0, 0.D0,0.D0,0.D0, .5D0, 0.D0, A 0.D0,0.D0, 4.5D0, 4.2D0, 1.D0, .5D0, 0.D0,0.D0,0.D0, B 0.D0,0.D0,0.D0,0.D0, -2.D0, 0.D0,0.D0,0.D0,0.D0, C 0.D0,0.D0,0.D0, 4.D0, -1.D0, 0.D0,0.D0,0.D0,0.D0, D 0.D0, 15.D-3, 0.D0, 10.D0, -1.D0, 0.D0, -1.D-4, E 0.D0, 1.D0, F 0.D0,0.D0, 6144.D-5, 10.D0, -1.D0, 4096.D0, -1.D6, G 0.D0, 1.D0, H 0.D0,0.D0,15.D0,10.D0,-1.D0, 5.D-5, 0.D0,1.D0,0.D0, I 0.D0,0.D0, 15.D0, 10.D0, -1. D0, 5.D5, -4096.D0, J 1.D0, 4096.D-6, K 0.D0,0.D0, 7.D0, 4.D0, 0.D0,0.D0, -.5D0, -.25D0, 0.D0/ * 4096 = 2 ** 12 DATA D12 /4096.D0/ DTRUE(1,1) = 12.D0 / 130.D0 DTRUE(2,1) = 36.D0 / 130.D0 DTRUE(7,1) = -1.D0 / 6.D0 DTRUE(1,2) = 14.D0 / 75.D0 DTRUE(2,2) = 49.D0 / 75.D0 DTRUE(9,2) = 1.D0 / 7.D0 DTRUE(1,5) = 45.D-11 * (D12 * D12) DTRUE(3,5) = 4.D5 / (3.D0 * D12) DTRUE(6,5) = 1.D0 / D12 DTRUE(8,5) = 1.D4 / (3.D0 * D12) DTRUE(1,6) = 4.D10 / (1.5D0 * D12 * D12) DTRUE(2,6) = 2.D-2 / 1.5D0 DTRUE(8,6) = 5.D-7 * D12 DTRUE(1,7) = 4.D0 / 150.D0 DTRUE(2,7) = (2.D-10 / 1.5D0) * (D12 * D12) DTRUE(7,7) = -DTRUE(6,5) DTRUE(9,7) = 1.D4 / D12 DTRUE(1,8) = DTRUE(1,7) DTRUE(2,8) = 2.D10 / (1.5D0 * D12 * D12) DTRUE(1,9) = 32.D0 / 7.D0 DTRUE(2,9) = -16.D0 / 7.D0 * .. Executable Statements .. * * Compute true values which cannot be prestored * in decimal notation * DBTRUE(1) = 1.0D0/0.6D0 DBTRUE(3) = -1.0D0/0.6D0 DBTRUE(5) = 1.0D0/0.6D0 * DO 20 K = 1, 8 * .. Set N=K for identification in output if any .. N = K IF (ICASE.EQ.3) THEN * .. DROTG .. IF (K.GT.8) GO TO 40 SA = DA1(K) SB = DB1(K) CALL DROTG(SA,SB,SC,SS) CALL STEST1(SA,DATRUE(K),DATRUE(K),SFAC) CALL STEST1(SB,DBTRUE(K),DBTRUE(K),SFAC) CALL STEST1(SC,DC1(K),DC1(K),SFAC) CALL STEST1(SS,DS1(K),DS1(K),SFAC) ELSEIF (ICASE.EQ.11) THEN * .. DROTMG .. DO I=1,4 DTEMP(I)= DAB(I,K) DTEMP(I+4) = 0.0 END DO DTEMP(9) = 0.0 CALL DROTMG(DTEMP(1),DTEMP(2),DTEMP(3),DTEMP(4),DTEMP(5)) CALL STEST(9,DTEMP,DTRUE(1,K),DTRUE(1,K),SFAC) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK0' STOP END IF 20 CONTINUE 40 RETURN END SUBROUTINE CHECK1(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. DOUBLE PRECISION SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. INTEGER I, LEN, NP1 * .. Local Arrays .. DOUBLE PRECISION DTRUE1(5), DTRUE3(5), DTRUE5(8,5,2), DV(8,5,2), + SA(10), STEMP(1), STRUE(8), SX(8) INTEGER ITRUE2(5) * .. External Functions .. DOUBLE PRECISION DASUM, DNRM2 INTEGER IDAMAX EXTERNAL DASUM, DNRM2, IDAMAX * .. External Subroutines .. EXTERNAL ITEST1, DSCAL, STEST, STEST1 * .. Intrinsic Functions .. INTRINSIC MAX * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA SA/0.3D0, -1.0D0, 0.0D0, 1.0D0, 0.3D0, 0.3D0, + 0.3D0, 0.3D0, 0.3D0, 0.3D0/ DATA DV/0.1D0, 2.0D0, 2.0D0, 2.0D0, 2.0D0, 2.0D0, + 2.0D0, 2.0D0, 0.3D0, 3.0D0, 3.0D0, 3.0D0, 3.0D0, + 3.0D0, 3.0D0, 3.0D0, 0.3D0, -0.4D0, 4.0D0, + 4.0D0, 4.0D0, 4.0D0, 4.0D0, 4.0D0, 0.2D0, + -0.6D0, 0.3D0, 5.0D0, 5.0D0, 5.0D0, 5.0D0, + 5.0D0, 0.1D0, -0.3D0, 0.5D0, -0.1D0, 6.0D0, + 6.0D0, 6.0D0, 6.0D0, 0.1D0, 8.0D0, 8.0D0, 8.0D0, + 8.0D0, 8.0D0, 8.0D0, 8.0D0, 0.3D0, 9.0D0, 9.0D0, + 9.0D0, 9.0D0, 9.0D0, 9.0D0, 9.0D0, 0.3D0, 2.0D0, + -0.4D0, 2.0D0, 2.0D0, 2.0D0, 2.0D0, 2.0D0, + 0.2D0, 3.0D0, -0.6D0, 5.0D0, 0.3D0, 2.0D0, + 2.0D0, 2.0D0, 0.1D0, 4.0D0, -0.3D0, 6.0D0, + -0.5D0, 7.0D0, -0.1D0, 3.0D0/ DATA DTRUE1/0.0D0, 0.3D0, 0.5D0, 0.7D0, 0.6D0/ DATA DTRUE3/0.0D0, 0.3D0, 0.7D0, 1.1D0, 1.0D0/ DATA DTRUE5/0.10D0, 2.0D0, 2.0D0, 2.0D0, 2.0D0, + 2.0D0, 2.0D0, 2.0D0, -0.3D0, 3.0D0, 3.0D0, + 3.0D0, 3.0D0, 3.0D0, 3.0D0, 3.0D0, 0.0D0, 0.0D0, + 4.0D0, 4.0D0, 4.0D0, 4.0D0, 4.0D0, 4.0D0, + 0.20D0, -0.60D0, 0.30D0, 5.0D0, 5.0D0, 5.0D0, + 5.0D0, 5.0D0, 0.03D0, -0.09D0, 0.15D0, -0.03D0, + 6.0D0, 6.0D0, 6.0D0, 6.0D0, 0.10D0, 8.0D0, + 8.0D0, 8.0D0, 8.0D0, 8.0D0, 8.0D0, 8.0D0, + 0.09D0, 9.0D0, 9.0D0, 9.0D0, 9.0D0, 9.0D0, + 9.0D0, 9.0D0, 0.09D0, 2.0D0, -0.12D0, 2.0D0, + 2.0D0, 2.0D0, 2.0D0, 2.0D0, 0.06D0, 3.0D0, + -0.18D0, 5.0D0, 0.09D0, 2.0D0, 2.0D0, 2.0D0, + 0.03D0, 4.0D0, -0.09D0, 6.0D0, -0.15D0, 7.0D0, + -0.03D0, 3.0D0/ DATA ITRUE2/0, 1, 2, 2, 3/ * .. Executable Statements .. DO 80 INCX = 1, 2 DO 60 NP1 = 1, 5 N = NP1 - 1 LEN = 2*MAX(N,1) * .. Set vector arguments .. DO 20 I = 1, LEN SX(I) = DV(I,NP1,INCX) 20 CONTINUE * IF (ICASE.EQ.7) THEN * .. DNRM2 .. STEMP(1) = DTRUE1(NP1) CALL STEST1(DNRM2(N,SX,INCX),STEMP(1),STEMP,SFAC) ELSE IF (ICASE.EQ.8) THEN * .. DASUM .. STEMP(1) = DTRUE3(NP1) CALL STEST1(DASUM(N,SX,INCX),STEMP(1),STEMP,SFAC) ELSE IF (ICASE.EQ.9) THEN * .. DSCAL .. CALL DSCAL(N,SA((INCX-1)*5+NP1),SX,INCX) DO 40 I = 1, LEN STRUE(I) = DTRUE5(I,NP1,INCX) 40 CONTINUE CALL STEST(LEN,SX,STRUE,STRUE,SFAC) ELSE IF (ICASE.EQ.10) THEN * .. IDAMAX .. CALL ITEST1(IDAMAX(N,SX,INCX),ITRUE2(NP1)) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK1' STOP END IF 60 CONTINUE 80 CONTINUE RETURN END SUBROUTINE CHECK2(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. DOUBLE PRECISION SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. DOUBLE PRECISION SA INTEGER I, J, KI, KN, KNI, KPAR, KSIZE, LENX, LENY, $ MX, MY * .. Local Arrays .. DOUBLE PRECISION DT10X(7,4,4), DT10Y(7,4,4), DT7(4,4), $ DT8(7,4,4), DX1(7), $ DY1(7), SSIZE1(4), SSIZE2(14,2), SSIZE(7), $ STX(7), STY(7), SX(7), SY(7), $ DPAR(5,4), DT19X(7,4,16),DT19XA(7,4,4), $ DT19XB(7,4,4), DT19XC(7,4,4),DT19XD(7,4,4), $ DT19Y(7,4,16), DT19YA(7,4,4),DT19YB(7,4,4), $ DT19YC(7,4,4), DT19YD(7,4,4), DTEMP(5) INTEGER INCXS(4), INCYS(4), LENS(4,2), NS(4) * .. External Functions .. DOUBLE PRECISION DDOT, DSDOT EXTERNAL DDOT, DSDOT * .. External Subroutines .. EXTERNAL DAXPY, DCOPY, DROTM, DSWAP, STEST, STEST1 * .. Intrinsic Functions .. INTRINSIC ABS, MIN * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. EQUIVALENCE (DT19X(1,1,1),DT19XA(1,1,1)),(DT19X(1,1,5), A DT19XB(1,1,1)),(DT19X(1,1,9),DT19XC(1,1,1)), B (DT19X(1,1,13),DT19XD(1,1,1)) EQUIVALENCE (DT19Y(1,1,1),DT19YA(1,1,1)),(DT19Y(1,1,5), A DT19YB(1,1,1)),(DT19Y(1,1,9),DT19YC(1,1,1)), B (DT19Y(1,1,13),DT19YD(1,1,1)) DATA SA/0.3D0/ DATA INCXS/1, 2, -2, -1/ DATA INCYS/1, -2, 1, -2/ DATA LENS/1, 1, 2, 4, 1, 1, 3, 7/ DATA NS/0, 1, 2, 4/ DATA DX1/0.6D0, 0.1D0, -0.5D0, 0.8D0, 0.9D0, -0.3D0, + -0.4D0/ DATA DY1/0.5D0, -0.9D0, 0.3D0, 0.7D0, -0.6D0, 0.2D0, + 0.8D0/ DATA DT7/0.0D0, 0.30D0, 0.21D0, 0.62D0, 0.0D0, + 0.30D0, -0.07D0, 0.85D0, 0.0D0, 0.30D0, -0.79D0, + -0.74D0, 0.0D0, 0.30D0, 0.33D0, 1.27D0/ DATA DT8/0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.68D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.68D0, -0.87D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.68D0, -0.87D0, 0.15D0, + 0.94D0, 0.0D0, 0.0D0, 0.0D0, 0.5D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.68D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.35D0, -0.9D0, 0.48D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.38D0, -0.9D0, 0.57D0, 0.7D0, -0.75D0, + 0.2D0, 0.98D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.68D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.35D0, -0.72D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.38D0, + -0.63D0, 0.15D0, 0.88D0, 0.0D0, 0.0D0, 0.0D0, + 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.68D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.68D0, -0.9D0, 0.33D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.68D0, -0.9D0, 0.33D0, 0.7D0, + -0.75D0, 0.2D0, 1.04D0/ DATA DT10X/0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.5D0, -0.9D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.5D0, -0.9D0, 0.3D0, 0.7D0, + 0.0D0, 0.0D0, 0.0D0, 0.6D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.3D0, 0.1D0, 0.5D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.8D0, 0.1D0, -0.6D0, + 0.8D0, 0.3D0, -0.3D0, 0.5D0, 0.6D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.5D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, -0.9D0, + 0.1D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.7D0, + 0.1D0, 0.3D0, 0.8D0, -0.9D0, -0.3D0, 0.5D0, + 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.5D0, 0.3D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.5D0, 0.3D0, -0.6D0, 0.8D0, 0.0D0, 0.0D0, + 0.0D0/ DATA DT10Y/0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.6D0, 0.1D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.6D0, 0.1D0, -0.5D0, 0.8D0, 0.0D0, + 0.0D0, 0.0D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, -0.5D0, -0.9D0, 0.6D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, -0.4D0, -0.9D0, 0.9D0, + 0.7D0, -0.5D0, 0.2D0, 0.6D0, 0.5D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.6D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, -0.5D0, + 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + -0.4D0, 0.9D0, -0.5D0, 0.6D0, 0.0D0, 0.0D0, + 0.0D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.6D0, -0.9D0, 0.1D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.6D0, -0.9D0, 0.1D0, 0.7D0, + -0.5D0, 0.2D0, 0.8D0/ DATA SSIZE1/0.0D0, 0.3D0, 1.6D0, 3.2D0/ DATA SSIZE2/0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, + 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, + 1.17D0, 1.17D0, 1.17D0/ * * FOR DROTM * DATA DPAR/-2.D0, 0.D0,0.D0,0.D0,0.D0, A -1.D0, 2.D0, -3.D0, -4.D0, 5.D0, B 0.D0, 0.D0, 2.D0, -3.D0, 0.D0, C 1.D0, 5.D0, 2.D0, 0.D0, -4.D0/ * TRUE X RESULTS F0R ROTATIONS DROTM DATA DT19XA/.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E -.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G 3.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .6D0, .1D0, 0.D0,0.D0,0.D0,0.D0,0.D0, I -.8D0, 3.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0, J -.9D0, 2.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0, K 3.5D0, -.4D0, 0.D0,0.D0,0.D0,0.D0,0.D0, L .6D0, .1D0, -.5D0, .8D0, 0.D0,0.D0,0.D0, M -.8D0, 3.8D0, -2.2D0, -1.2D0, 0.D0,0.D0,0.D0, N -.9D0, 2.8D0, -1.4D0, -1.3D0, 0.D0,0.D0,0.D0, O 3.5D0, -.4D0, -2.2D0, 4.7D0, 0.D0,0.D0,0.D0/ * DATA DT19XB/.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E -.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G 3.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .6D0, .1D0, -.5D0, 0.D0,0.D0,0.D0,0.D0, I 0.D0, .1D0, -3.0D0, 0.D0,0.D0,0.D0,0.D0, J -.3D0, .1D0, -2.0D0, 0.D0,0.D0,0.D0,0.D0, K 3.3D0, .1D0, -2.0D0, 0.D0,0.D0,0.D0,0.D0, L .6D0, .1D0, -.5D0, .8D0, .9D0, -.3D0, -.4D0, M -2.0D0, .1D0, 1.4D0, .8D0, .6D0, -.3D0, -2.8D0, N -1.8D0, .1D0, 1.3D0, .8D0, 0.D0, -.3D0, -1.9D0, O 3.8D0, .1D0, -3.1D0, .8D0, 4.8D0, -.3D0, -1.5D0 / * DATA DT19XC/.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E -.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G 3.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .6D0, .1D0, -.5D0, 0.D0,0.D0,0.D0,0.D0, I 4.8D0, .1D0, -3.0D0, 0.D0,0.D0,0.D0,0.D0, J 3.3D0, .1D0, -2.0D0, 0.D0,0.D0,0.D0,0.D0, K 2.1D0, .1D0, -2.0D0, 0.D0,0.D0,0.D0,0.D0, L .6D0, .1D0, -.5D0, .8D0, .9D0, -.3D0, -.4D0, M -1.6D0, .1D0, -2.2D0, .8D0, 5.4D0, -.3D0, -2.8D0, N -1.5D0, .1D0, -1.4D0, .8D0, 3.6D0, -.3D0, -1.9D0, O 3.7D0, .1D0, -2.2D0, .8D0, 3.6D0, -.3D0, -1.5D0 / * DATA DT19XD/.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E -.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G 3.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .6D0, .1D0, 0.D0,0.D0,0.D0,0.D0,0.D0, I -.8D0, -1.0D0, 0.D0,0.D0,0.D0,0.D0,0.D0, J -.9D0, -.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0, K 3.5D0, .8D0, 0.D0,0.D0,0.D0,0.D0,0.D0, L .6D0, .1D0, -.5D0, .8D0, 0.D0,0.D0,0.D0, M -.8D0, -1.0D0, 1.4D0, -1.6D0, 0.D0,0.D0,0.D0, N -.9D0, -.8D0, 1.3D0, -1.6D0, 0.D0,0.D0,0.D0, O 3.5D0, .8D0, -3.1D0, 4.8D0, 0.D0,0.D0,0.D0/ * TRUE Y RESULTS FOR ROTATIONS DROTM DATA DT19YA/.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E .7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F 1.7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G -2.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .5D0, -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0, I .7D0, -4.8D0, 0.D0,0.D0,0.D0,0.D0,0.D0, J 1.7D0, -.7D0, 0.D0,0.D0,0.D0,0.D0,0.D0, K -2.6D0, 3.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0, L .5D0, -.9D0, .3D0, .7D0, 0.D0,0.D0,0.D0, M .7D0, -4.8D0, 3.0D0, 1.1D0, 0.D0,0.D0,0.D0, N 1.7D0, -.7D0, -.7D0, 2.3D0, 0.D0,0.D0,0.D0, O -2.6D0, 3.5D0, -.7D0, -3.6D0, 0.D0,0.D0,0.D0/ * DATA DT19YB/.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E .7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F 1.7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G -2.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .5D0, -.9D0, .3D0, 0.D0,0.D0,0.D0,0.D0, I 4.0D0, -.9D0, -.3D0, 0.D0,0.D0,0.D0,0.D0, J -.5D0, -.9D0, 1.5D0, 0.D0,0.D0,0.D0,0.D0, K -1.5D0, -.9D0, -1.8D0, 0.D0,0.D0,0.D0,0.D0, L .5D0, -.9D0, .3D0, .7D0, -.6D0, .2D0, .8D0, M 3.7D0, -.9D0, -1.2D0, .7D0, -1.5D0, .2D0, 2.2D0, N -.3D0, -.9D0, 2.1D0, .7D0, -1.6D0, .2D0, 2.0D0, O -1.6D0, -.9D0, -2.1D0, .7D0, 2.9D0, .2D0, -3.8D0 / * DATA DT19YC/.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E .7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F 1.7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G -2.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .5D0, -.9D0, 0.D0,0.D0,0.D0,0.D0,0.D0, I 4.0D0, -6.3D0, 0.D0,0.D0,0.D0,0.D0,0.D0, J -.5D0, .3D0, 0.D0,0.D0,0.D0,0.D0,0.D0, K -1.5D0, 3.0D0, 0.D0,0.D0,0.D0,0.D0,0.D0, L .5D0, -.9D0, .3D0, .7D0, 0.D0,0.D0,0.D0, M 3.7D0, -7.2D0, 3.0D0, 1.7D0, 0.D0,0.D0,0.D0, N -.3D0, .9D0, -.7D0, 1.9D0, 0.D0,0.D0,0.D0, O -1.6D0, 2.7D0, -.7D0, -3.4D0, 0.D0,0.D0,0.D0/ * DATA DT19YD/.5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, A .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, B .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, C .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, D .5D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, E .7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, F 1.7D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, G -2.6D0, 0.D0,0.D0,0.D0,0.D0,0.D0,0.D0, H .5D0, -.9D0, .3D0, 0.D0,0.D0,0.D0,0.D0, I .7D0, -.9D0, 1.2D0, 0.D0,0.D0,0.D0,0.D0, J 1.7D0, -.9D0, .5D0, 0.D0,0.D0,0.D0,0.D0, K -2.6D0, -.9D0, -1.3D0, 0.D0,0.D0,0.D0,0.D0, L .5D0, -.9D0, .3D0, .7D0, -.6D0, .2D0, .8D0, M .7D0, -.9D0, 1.2D0, .7D0, -1.5D0, .2D0, 1.6D0, N 1.7D0, -.9D0, .5D0, .7D0, -1.6D0, .2D0, 2.4D0, O -2.6D0, -.9D0, -1.3D0, .7D0, 2.9D0, .2D0, -4.0D0 / * * .. Executable Statements .. * DO 120 KI = 1, 4 INCX = INCXS(KI) INCY = INCYS(KI) MX = ABS(INCX) MY = ABS(INCY) * DO 100 KN = 1, 4 N = NS(KN) KSIZE = MIN(2,KN) LENX = LENS(KN,MX) LENY = LENS(KN,MY) * .. Initialize all argument arrays .. DO 20 I = 1, 7 SX(I) = DX1(I) SY(I) = DY1(I) 20 CONTINUE * IF (ICASE.EQ.1) THEN * .. DDOT .. CALL STEST1(DDOT(N,SX,INCX,SY,INCY),DT7(KN,KI),SSIZE1(KN) + ,SFAC) ELSE IF (ICASE.EQ.2) THEN * .. DAXPY .. CALL DAXPY(N,SA,SX,INCX,SY,INCY) DO 40 J = 1, LENY STY(J) = DT8(J,KN,KI) 40 CONTINUE CALL STEST(LENY,SY,STY,SSIZE2(1,KSIZE),SFAC) ELSE IF (ICASE.EQ.5) THEN * .. DCOPY .. DO 60 I = 1, 7 STY(I) = DT10Y(I,KN,KI) 60 CONTINUE CALL DCOPY(N,SX,INCX,SY,INCY) CALL STEST(LENY,SY,STY,SSIZE2(1,1),1.0D0) ELSE IF (ICASE.EQ.6) THEN * .. DSWAP .. CALL DSWAP(N,SX,INCX,SY,INCY) DO 80 I = 1, 7 STX(I) = DT10X(I,KN,KI) STY(I) = DT10Y(I,KN,KI) 80 CONTINUE CALL STEST(LENX,SX,STX,SSIZE2(1,1),1.0D0) CALL STEST(LENY,SY,STY,SSIZE2(1,1),1.0D0) ELSE IF (ICASE.EQ.12) THEN * .. DROTM .. KNI=KN+4*(KI-1) DO KPAR=1,4 DO I=1,7 SX(I) = DX1(I) SY(I) = DY1(I) STX(I)= DT19X(I,KPAR,KNI) STY(I)= DT19Y(I,KPAR,KNI) END DO * DO I=1,5 DTEMP(I) = DPAR(I,KPAR) END DO * DO I=1,LENX SSIZE(I)=STX(I) END DO * SEE REMARK ABOVE ABOUT DT11X(1,2,7) * AND DT11X(5,3,8). IF ((KPAR .EQ. 2) .AND. (KNI .EQ. 7)) $ SSIZE(1) = 2.4D0 IF ((KPAR .EQ. 3) .AND. (KNI .EQ. 8)) $ SSIZE(5) = 1.8D0 * CALL DROTM(N,SX,INCX,SY,INCY,DTEMP) CALL STEST(LENX,SX,STX,SSIZE,SFAC) CALL STEST(LENY,SY,STY,STY,SFAC) END DO ELSE IF (ICASE.EQ.13) THEN * .. DSDOT .. CALL TESTDSDOT(REAL(DSDOT(N,REAL(SX),INCX,REAL(SY),INCY)), $ REAL(DT7(KN,KI)),REAL(SSIZE1(KN)), .3125E-1) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK2' STOP END IF 100 CONTINUE 120 CONTINUE RETURN END SUBROUTINE CHECK3(SFAC) * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. DOUBLE PRECISION SFAC * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. DOUBLE PRECISION SC, SS INTEGER I, K, KI, KN, KSIZE, LENX, LENY, MX, MY * .. Local Arrays .. DOUBLE PRECISION COPYX(5), COPYY(5), DT9X(7,4,4), DT9Y(7,4,4), + DX1(7), DY1(7), MWPC(11), MWPS(11), MWPSTX(5), + MWPSTY(5), MWPTX(11,5), MWPTY(11,5), MWPX(5), + MWPY(5), SSIZE2(14,2), STX(7), STY(7), SX(7), + SY(7) INTEGER INCXS(4), INCYS(4), LENS(4,2), MWPINX(11), + MWPINY(11), MWPN(11), NS(4) * .. External Subroutines .. EXTERNAL DROT, STEST * .. Intrinsic Functions .. INTRINSIC ABS, MIN * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Data statements .. DATA INCXS/1, 2, -2, -1/ DATA INCYS/1, -2, 1, -2/ DATA LENS/1, 1, 2, 4, 1, 1, 3, 7/ DATA NS/0, 1, 2, 4/ DATA DX1/0.6D0, 0.1D0, -0.5D0, 0.8D0, 0.9D0, -0.3D0, + -0.4D0/ DATA DY1/0.5D0, -0.9D0, 0.3D0, 0.7D0, -0.6D0, 0.2D0, + 0.8D0/ DATA SC, SS/0.8D0, 0.6D0/ DATA DT9X/0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.78D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.78D0, -0.46D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.78D0, -0.46D0, -0.22D0, + 1.06D0, 0.0D0, 0.0D0, 0.0D0, 0.6D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.78D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.66D0, 0.1D0, -0.1D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.96D0, 0.1D0, -0.76D0, 0.8D0, 0.90D0, + -0.3D0, -0.02D0, 0.6D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.78D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, -0.06D0, 0.1D0, + -0.1D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.90D0, + 0.1D0, -0.22D0, 0.8D0, 0.18D0, -0.3D0, -0.02D0, + 0.6D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.78D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.78D0, 0.26D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.78D0, 0.26D0, -0.76D0, 1.12D0, + 0.0D0, 0.0D0, 0.0D0/ DATA DT9Y/0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.04D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.04D0, -0.78D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.04D0, -0.78D0, 0.54D0, + 0.08D0, 0.0D0, 0.0D0, 0.0D0, 0.5D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.04D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.7D0, + -0.9D0, -0.12D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.64D0, -0.9D0, -0.30D0, 0.7D0, -0.18D0, 0.2D0, + 0.28D0, 0.5D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.04D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.7D0, -1.08D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.64D0, -1.26D0, + 0.54D0, 0.20D0, 0.0D0, 0.0D0, 0.0D0, 0.5D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.04D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.04D0, -0.9D0, 0.18D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.04D0, -0.9D0, 0.18D0, 0.7D0, + -0.18D0, 0.2D0, 0.16D0/ DATA SSIZE2/0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0, + 0.0D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, + 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, 1.17D0, + 1.17D0, 1.17D0, 1.17D0/ * .. Executable Statements .. * DO 60 KI = 1, 4 INCX = INCXS(KI) INCY = INCYS(KI) MX = ABS(INCX) MY = ABS(INCY) * DO 40 KN = 1, 4 N = NS(KN) KSIZE = MIN(2,KN) LENX = LENS(KN,MX) LENY = LENS(KN,MY) * IF (ICASE.EQ.4) THEN * .. DROT .. DO 20 I = 1, 7 SX(I) = DX1(I) SY(I) = DY1(I) STX(I) = DT9X(I,KN,KI) STY(I) = DT9Y(I,KN,KI) 20 CONTINUE CALL DROT(N,SX,INCX,SY,INCY,SC,SS) CALL STEST(LENX,SX,STX,SSIZE2(1,KSIZE),SFAC) CALL STEST(LENY,SY,STY,SSIZE2(1,KSIZE),SFAC) ELSE WRITE (NOUT,*) ' Shouldn''t be here in CHECK3' STOP END IF 40 CONTINUE 60 CONTINUE * MWPC(1) = 1 DO 80 I = 2, 11 MWPC(I) = 0 80 CONTINUE MWPS(1) = 0 DO 100 I = 2, 6 MWPS(I) = 1 100 CONTINUE DO 120 I = 7, 11 MWPS(I) = -1 120 CONTINUE MWPINX(1) = 1 MWPINX(2) = 1 MWPINX(3) = 1 MWPINX(4) = -1 MWPINX(5) = 1 MWPINX(6) = -1 MWPINX(7) = 1 MWPINX(8) = 1 MWPINX(9) = -1 MWPINX(10) = 1 MWPINX(11) = -1 MWPINY(1) = 1 MWPINY(2) = 1 MWPINY(3) = -1 MWPINY(4) = -1 MWPINY(5) = 2 MWPINY(6) = 1 MWPINY(7) = 1 MWPINY(8) = -1 MWPINY(9) = -1 MWPINY(10) = 2 MWPINY(11) = 1 DO 140 I = 1, 11 MWPN(I) = 5 140 CONTINUE MWPN(5) = 3 MWPN(10) = 3 DO 160 I = 1, 5 MWPX(I) = I MWPY(I) = I MWPTX(1,I) = I MWPTY(1,I) = I MWPTX(2,I) = I MWPTY(2,I) = -I MWPTX(3,I) = 6 - I MWPTY(3,I) = I - 6 MWPTX(4,I) = I MWPTY(4,I) = -I MWPTX(6,I) = 6 - I MWPTY(6,I) = I - 6 MWPTX(7,I) = -I MWPTY(7,I) = I MWPTX(8,I) = I - 6 MWPTY(8,I) = 6 - I MWPTX(9,I) = -I MWPTY(9,I) = I MWPTX(11,I) = I - 6 MWPTY(11,I) = 6 - I 160 CONTINUE MWPTX(5,1) = 1 MWPTX(5,2) = 3 MWPTX(5,3) = 5 MWPTX(5,4) = 4 MWPTX(5,5) = 5 MWPTY(5,1) = -1 MWPTY(5,2) = 2 MWPTY(5,3) = -2 MWPTY(5,4) = 4 MWPTY(5,5) = -3 MWPTX(10,1) = -1 MWPTX(10,2) = -3 MWPTX(10,3) = -5 MWPTX(10,4) = 4 MWPTX(10,5) = 5 MWPTY(10,1) = 1 MWPTY(10,2) = 2 MWPTY(10,3) = 2 MWPTY(10,4) = 4 MWPTY(10,5) = 3 DO 200 I = 1, 11 INCX = MWPINX(I) INCY = MWPINY(I) DO 180 K = 1, 5 COPYX(K) = MWPX(K) COPYY(K) = MWPY(K) MWPSTX(K) = MWPTX(I,K) MWPSTY(K) = MWPTY(I,K) 180 CONTINUE CALL DROT(MWPN(I),COPYX,INCX,COPYY,INCY,MWPC(I),MWPS(I)) CALL STEST(5,COPYX,MWPSTX,MWPSTX,SFAC) CALL STEST(5,COPYY,MWPSTY,MWPSTY,SFAC) 200 CONTINUE RETURN END SUBROUTINE STEST(LEN,SCOMP,STRUE,SSIZE,SFAC) * ********************************* STEST ************************** * * THIS SUBR COMPARES ARRAYS SCOMP() AND STRUE() OF LENGTH LEN TO * SEE IF THE TERM BY TERM DIFFERENCES, MULTIPLIED BY SFAC, ARE * NEGLIGIBLE. * * C. L. LAWSON, JPL, 1974 DEC 10 * * .. Parameters .. INTEGER NOUT DOUBLE PRECISION ZERO PARAMETER (NOUT=6, ZERO=0.0D0) * .. Scalar Arguments .. DOUBLE PRECISION SFAC INTEGER LEN * .. Array Arguments .. DOUBLE PRECISION SCOMP(LEN), SSIZE(LEN), STRUE(LEN) * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. DOUBLE PRECISION SD INTEGER I * .. External Functions .. DOUBLE PRECISION SDIFF EXTERNAL SDIFF * .. Intrinsic Functions .. INTRINSIC ABS * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Executable Statements .. * DO 40 I = 1, LEN SD = SCOMP(I) - STRUE(I) IF (ABS(SFAC*SD) .LE. ABS(SSIZE(I))*EPSILON(ZERO)) + GO TO 40 * * HERE SCOMP(I) IS NOT CLOSE TO STRUE(I). * IF ( .NOT. PASS) GO TO 20 * PRINT FAIL MESSAGE AND HEADER. PASS = .FALSE. WRITE (NOUT,99999) WRITE (NOUT,99998) 20 WRITE (NOUT,99997) ICASE, N, INCX, INCY, I, SCOMP(I), + STRUE(I), SD, SSIZE(I) 40 CONTINUE RETURN * 99999 FORMAT (' FAIL') 99998 FORMAT (/' CASE N INCX INCY I ', + ' COMP(I) TRUE(I) DIFFERENCE', + ' SIZE(I)',/1X) 99997 FORMAT (1X,I4,I3,2I5,I3,2D36.8,2D12.4) END SUBROUTINE TESTDSDOT(SCOMP,STRUE,SSIZE,SFAC) * ********************************* STEST ************************** * * THIS SUBR COMPARES ARRAYS SCOMP() AND STRUE() OF LENGTH LEN TO * SEE IF THE TERM BY TERM DIFFERENCES, MULTIPLIED BY SFAC, ARE * NEGLIGIBLE. * * C. L. LAWSON, JPL, 1974 DEC 10 * * .. Parameters .. INTEGER NOUT REAL ZERO PARAMETER (NOUT=6, ZERO=0.0E0) * .. Scalar Arguments .. REAL SFAC, SCOMP, SSIZE, STRUE * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. REAL SD * .. Intrinsic Functions .. INTRINSIC ABS * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Executable Statements .. * SD = SCOMP - STRUE IF (ABS(SFAC*SD) .LE. ABS(SSIZE) * EPSILON(ZERO)) + GO TO 40 * * HERE SCOMP(I) IS NOT CLOSE TO STRUE(I). * IF ( .NOT. PASS) GO TO 20 * PRINT FAIL MESSAGE AND HEADER. PASS = .FALSE. WRITE (NOUT,99999) WRITE (NOUT,99998) 20 WRITE (NOUT,99997) ICASE, N, INCX, INCY, SCOMP, + STRUE, SD, SSIZE 40 CONTINUE RETURN * 99999 FORMAT (' FAIL') 99998 FORMAT (/' CASE N INCX INCY ', + ' COMP(I) TRUE(I) DIFFERENCE', + ' SIZE(I)',/1X) 99997 FORMAT (1X,I4,I3,1I5,I3,2E36.8,2E12.4) END SUBROUTINE STEST1(SCOMP1,STRUE1,SSIZE,SFAC) * ************************* STEST1 ***************************** * * THIS IS AN INTERFACE SUBROUTINE TO ACCOMODATE THE FORTRAN * REQUIREMENT THAT WHEN A DUMMY ARGUMENT IS AN ARRAY, THE * ACTUAL ARGUMENT MUST ALSO BE AN ARRAY OR AN ARRAY ELEMENT. * * C.L. LAWSON, JPL, 1978 DEC 6 * * .. Scalar Arguments .. DOUBLE PRECISION SCOMP1, SFAC, STRUE1 * .. Array Arguments .. DOUBLE PRECISION SSIZE(*) * .. Local Arrays .. DOUBLE PRECISION SCOMP(1), STRUE(1) * .. External Subroutines .. EXTERNAL STEST * .. Executable Statements .. * SCOMP(1) = SCOMP1 STRUE(1) = STRUE1 CALL STEST(1,SCOMP,STRUE,SSIZE,SFAC) * RETURN END DOUBLE PRECISION FUNCTION SDIFF(SA,SB) * ********************************* SDIFF ************************** * COMPUTES DIFFERENCE OF TWO NUMBERS. C. L. LAWSON, JPL 1974 FEB 15 * * .. Scalar Arguments .. DOUBLE PRECISION SA, SB * .. Executable Statements .. SDIFF = SA - SB RETURN END SUBROUTINE ITEST1(ICOMP,ITRUE) * ********************************* ITEST1 ************************* * * THIS SUBROUTINE COMPARES THE VARIABLES ICOMP AND ITRUE FOR * EQUALITY. * C. L. LAWSON, JPL, 1974 DEC 10 * * .. Parameters .. INTEGER NOUT PARAMETER (NOUT=6) * .. Scalar Arguments .. INTEGER ICOMP, ITRUE * .. Scalars in Common .. INTEGER ICASE, INCX, INCY, N LOGICAL PASS * .. Local Scalars .. INTEGER ID * .. Common blocks .. COMMON /COMBLA/ICASE, N, INCX, INCY, PASS * .. Executable Statements .. * IF (ICOMP.EQ.ITRUE) GO TO 40 * * HERE ICOMP IS NOT EQUAL TO ITRUE. * IF ( .NOT. PASS) GO TO 20 * PRINT FAIL MESSAGE AND HEADER. PASS = .FALSE. WRITE (NOUT,99999) WRITE (NOUT,99998) 20 ID = ICOMP - ITRUE WRITE (NOUT,99997) ICASE, N, INCX, INCY, ICOMP, ITRUE, ID 40 CONTINUE RETURN * 99999 FORMAT (' FAIL') 99998 FORMAT (/' CASE N INCX INCY ', + ' COMP TRUE DIFFERENCE', + /1X) 99997 FORMAT (1X,I4,I3,2I5,2I36,I12) END
lgpl-2.1
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.fortran-torture/compile/pr32663.f
193
4377
SUBROUTINE DIMOID(DEN,RLMO,SSQU,STRI,ATMU,IATM,IWHI,MAPT,INAT, * IATB,L1,L2,M1,M2,NATS,NOSI,NCAT,NSWE) C IMPLICIT DOUBLE PRECISION(A-H,O-Z) C DIMENSION RLMO(L1,L1),SSQU(L1,L1),STRI(L2),ATMU(NATS),DEN(M2) DIMENSION IATM(NATS,M1),IWHI(M1+NATS),MAPT(M1),INAT(M1+NATS) DIMENSION IATB(NATS,M1) C PARAMETER (MXATM=500, MXSH=1000, MXGTOT=5000, MXAO=2047) C LOGICAL GOPARR,DSKWRK,MASWRK C COMMON /INFOA / NAT,ICH,MUL,NUM,NQMT,NE,NA,NB, * ZAN(MXATM),C(3,MXATM) COMMON /IOFILE/ IR,IW,IP,IJKO,IJKT,IDAF,NAV,IODA(400) COMMON /NSHEL / EX(MXGTOT),CS(MXGTOT),CP(MXGTOT),CD(MXGTOT), * CF(MXGTOT),CG(MXGTOT), * KSTART(MXSH),KATOM(MXSH),KTYPE(MXSH), * KNG(MXSH),KLOC(MXSH),KMIN(MXSH), * KMAX(MXSH),NSHELL COMMON /OPTLOC/ CVGLOC,MAXLOC,IPRTLO,ISYMLO,IFCORE,NOUTA,NOUTB, * MOOUTA(MXAO),MOOUTB(MXAO) COMMON /PAR / ME,MASTER,NPROC,IBTYP,IPTIM,GOPARR,DSKWRK,MASWRK COMMON /RUNLAB/ TITLE(10),A(MXATM),B(MXATM),BFLAB(MXAO) C C DO 920 II=1,M1 INAT(II) = 0 920 CONTINUE C DO 900 IO = NOUTA+1,NUMLOC IZ = IO - NOUTA DO 895 II=NST,NEND ATMU(II) = 0.0D+00 IATM(II,IZ) = 0 895 CONTINUE IFUNC = 0 DO 890 ISHELL = 1,NSHELL IAT = KATOM(ISHELL) IST = KMIN(ISHELL) IEN = KMAX(ISHELL) DO 880 INO = IST,IEN IFUNC = IFUNC + 1 IF (IAT.LT.NST.OR.IAT.GT.NEND) GOTO 880 ZINT = 0.0D+00 DO 870 II = 1,L1 ZINT = ZINT + RLMO(II,IO)*SSQU(II,IFUNC) 870 CONTINUE ATMU(IAT) = ATMU(IAT) + RLMO(IFUNC,IO)*ZINT 880 CONTINUE 890 CONTINUE IF (MASWRK) WRITE(IW,9010) IZ,(ATMU(II),II=NST,NEND) 900 CONTINUE C NOSI = 0 DO 700 II=1,M1 NO=0 DO 720 JJ=1,NAT NO = NO + 1 720 CONTINUE 740 CONTINUE IF (NO.GT.1.OR.NO.EQ.0) THEN NOSI = NOSI + 1 IWHI(NOSI) = II ENDIF IF (MASWRK) * WRITE(IW,9030) II,(IATM(J,II),A(IATM(J,II)),J=1,NO) 700 CONTINUE C IF (MASWRK) THEN WRITE(IW,9035) NOSI IF (NOSI.GT.0) THEN WRITE(IW,9040) (IWHI(I),I=1,NOSI) WRITE(IW,9040) ELSE WRITE(IW,9040) ENDIF ENDIF C CALL DCOPY(L1*L1,RLMO,1,SSQU,1) CALL DCOPY(M2,DEN,1,STRI,1) C IP2 = NOUTA IS2 = M1+NOUTA-NOSI DO 695 II=1,NAT INAT(II) = 0 695 CONTINUE C DO 690 IAT=1,NAT DO 680 IORB=1,M1 IP1 = IORB + NOUTA IF (IATM(1,IORB).NE.IAT) GOTO 680 IF (IATM(2,IORB).NE.0) GOTO 680 INAT(IAT) = INAT(IAT) + 1 IP2 = IP2 + 1 CALL DCOPY(L1,SSQU(1,IP1),1,RLMO(1,IP2),1) CALL ICOPY(NAT,IATM(1,IORB),1,IATB(1,IP2-NOUTA),1) MAPT(IORB) = IP2-NOUTA 680 CONTINUE DO 670 IORB=1,NOSI IS1 = IWHI(IORB) + NOUTA IF (IAT.EQ.NAT.AND.IATM(1,IWHI(IORB)).EQ.0) GOTO 675 IF (IATM(1,IWHI(IORB)).NE.IAT) GOTO 670 675 CONTINUE IS2 = IS2 + 1 MAPT(IWHI(IORB)) = IS2-NOUTA 670 CONTINUE 690 CONTINUE C NSWE = 0 NCAT = 0 LASP = 1 NLAST = 0 DO 620 II=1,NAT NSWE = NSWE + (IWHI(II)*(IWHI(II)-1))/2 NCAT = NCAT + 1 INAT(NCAT) = LASP + NLAST LASP = INAT(NCAT) NLAST = IWHI(II) IWHI(NCAT) = II 620 CONTINUE C DO 610 II=1,NOSI NCAT = NCAT + 1 INAT(NCAT) = LASP + NLAST LASP = INAT(NCAT) NLAST = 1 IWHI(NCAT) = 0 610 CONTINUE C RETURN C 8000 FORMAT(/1X,'** MULLIKEN ATOMIC POPULATIONS FOR EACH NON-FROZEN ', * 'LOCALIZED ORBITAL **') 9000 FORMAT(/3X,'ATOM',2X,100(I2,1X,A4)) 9005 FORMAT(1X,'LMO') 9010 FORMAT(1X,I3,3X,100F7.3) 9015 FORMAT(/1X,'** ATOMIC POPULATIONS GREATER THAN ',F4.2, * ' ARE CONSIDERED MAJOR **') 9020 FORMAT(/2X,'LMO',3X,'MAJOR CONTRIBUTIONS FROM ATOM(S)') 9030 FORMAT(2X,I3,2X,100(I2,1X,A2,2X)) 9035 FORMAT(/1X,'NO OF LMOS INVOLVING MORE THAN ONE ATOM =',I3) 9040 FORMAT(1X,'THESE ARE LMOS :',100I3) C END
gpl-2.0
cmeon/Simplex
lib/CMakeFiles/2.8.12.2/CompilerIdFortran/CMakeFortranCompilerId.F
19
4484
PROGRAM CMakeFortranCompilerId #if 0 ! Identify the compiler #endif #if defined(__INTEL_COMPILER) || defined(__ICC) PRINT *, 'INFO:compiler[Intel]' #elif defined(__SUNPRO_F90) || defined(__SUNPRO_F95) PRINT *, 'INFO:compiler[SunPro]' #elif defined(_CRAYFTN) PRINT *, 'INFO:compiler[Cray]' #elif defined(__G95__) PRINT *, 'INFO:compiler[G95]' #elif defined(__PATHSCALE__) PRINT *, 'INFO:compiler[PathScale]' #elif defined(__ABSOFT__) PRINT *, 'INFO:compiler[Absoft]' #elif defined(__GNUC__) PRINT *, 'INFO:compiler[GNU]' #elif defined(__IBMC__) # if defined(__COMPILER_VER__) PRINT *, 'INFO:compiler[zOS]' # elif __IBMC__ >= 800 PRINT *, 'INFO:compiler[XL]' # else PRINT *, 'INFO:compiler[VisualAge]' # endif #elif defined(__PGI) PRINT *, 'INFO:compiler[PGI]' #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) PRINT *, 'INFO:compiler[MIPSpro]' # if 0 ! This compiler is either not known or is too old to define an ! identification macro. Try to identify the platform and guess that ! it is the native compiler. # endif #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) PRINT *, 'INFO:compiler[VisualAge]' #elif defined(__sgi) || defined(__sgi__) || defined(_SGI) PRINT *, 'INFO:compiler[MIPSpro]' #elif defined(__hpux) || defined(__hpux__) PRINT *, 'INFO:compiler[HP]' #elif 1 # if 0 ! The above 'elif 1' instead of 'else' is to work around a bug in the ! SGI preprocessor which produces both the __sgi and else blocks. # endif PRINT *, 'INFO:compiler[]' #endif #if 0 ! Identify the platform #endif #if defined(__linux) || defined(__linux__) || defined(linux) PRINT *, 'INFO:platform[Linux]' #elif defined(__CYGWIN__) PRINT *, 'INFO:platform[Cygwin]' #elif defined(__MINGW32__) PRINT *, 'INFO:platform[MinGW]' #elif defined(__APPLE__) PRINT *, 'INFO:platform[Darwin]' #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) PRINT *, 'INFO:platform[Windows]' #elif defined(__FreeBSD__) || defined(__FreeBSD) PRINT *, 'INFO:platform[FreeBSD]' #elif defined(__NetBSD__) || defined(__NetBSD) PRINT *, 'INFO:platform[NetBSD]' #elif defined(__OpenBSD__) || defined(__OPENBSD) PRINT *, 'INFO:platform[OpenBSD]' #elif defined(__sun) || defined(sun) PRINT *, 'INFO:platform[SunOS]' #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) PRINT *, 'INFO:platform[AIX]' #elif defined(__sgi) || defined(__sgi__) || defined(_SGI) PRINT *, 'INFO:platform[IRIX]' #elif defined(__hpux) || defined(__hpux__) PRINT *, 'INFO:platform[HP-UX]' #elif defined(__HAIKU__) PRINT *, 'INFO:platform[Haiku]' #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) PRINT *, 'INFO:platform[BeOS]' #elif defined(__QNX__) || defined(__QNXNTO__) PRINT *, 'INFO:platform[QNX]' #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) PRINT *, 'INFO:platform[Tru64]' #elif defined(__riscos) || defined(__riscos__) PRINT *, 'INFO:platform[RISCos]' #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) PRINT *, 'INFO:platform[SINIX]' #elif defined(__UNIX_SV__) PRINT *, 'INFO:platform[UNIX_SV]' #elif defined(__bsdos__) PRINT *, 'INFO:platform[BSDOS]' #elif defined(_MPRAS) || defined(MPRAS) PRINT *, 'INFO:platform[MP-RAS]' #elif defined(__osf) || defined(__osf__) PRINT *, 'INFO:platform[OSF1]' #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) PRINT *, 'INFO:platform[SCO_SV]' #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) PRINT *, 'INFO:platform[ULTRIX]' #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) PRINT *, 'INFO:platform[Xenix]' #elif 1 # if 0 ! The above 'elif 1' instead of 'else' is to work around a bug in the ! SGI preprocessor which produces both the __sgi and else blocks. # endif PRINT *, 'INFO:platform[]' #endif #if defined(_WIN32) && (defined(__INTEL_COMPILER) || defined(__ICC)) # if defined(_M_IA64) PRINT *, 'INFO:arch[IA64]' # elif defined(_M_X64) || defined(_M_AMD64) PRINT *, 'INFO:arch[x64]' # elif defined(_M_IX86) PRINT *, 'INFO:arch[X86]' # endif #endif END
mit
ajjl/ITK
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/lapack/complex16/zlarf.f
44
3255
SUBROUTINE ZLARF( SIDE, M, N, V, INCV, TAU, C, LDC, WORK ) * * -- LAPACK auxiliary routine (version 3.0) -- * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., * Courant Institute, Argonne National Lab, and Rice University * September 30, 1994 * * .. Scalar Arguments .. CHARACTER SIDE INTEGER INCV, LDC, M, N COMPLEX*16 TAU * .. * .. Array Arguments .. COMPLEX*16 C( LDC, * ), V( * ), WORK( * ) * .. * * Purpose * ======= * * ZLARF applies a complex elementary reflector H to a complex M-by-N * matrix C, from either the left or the right. H is represented in the * form * * H = I - tau * v * v' * * where tau is a complex scalar and v is a complex vector. * * If tau = 0, then H is taken to be the unit matrix. * * To apply H' (the conjugate transpose of H), supply conjg(tau) instead * tau. * * Arguments * ========= * * SIDE (input) CHARACTER*1 * = 'L': form H * C * = 'R': form C * H * * M (input) INTEGER * The number of rows of the matrix C. * * N (input) INTEGER * The number of columns of the matrix C. * * V (input) COMPLEX*16 array, dimension * (1 + (M-1)*abs(INCV)) if SIDE = 'L' * or (1 + (N-1)*abs(INCV)) if SIDE = 'R' * The vector v in the representation of H. V is not used if * TAU = 0. * * INCV (input) INTEGER * The increment between elements of v. INCV <> 0. * * TAU (input) COMPLEX*16 * The value tau in the representation of H. * * C (input/output) COMPLEX*16 array, dimension (LDC,N) * On entry, the M-by-N matrix C. * On exit, C is overwritten by the matrix H * C if SIDE = 'L', * or C * H if SIDE = 'R'. * * LDC (input) INTEGER * The leading dimension of the array C. LDC >= max(1,M). * * WORK (workspace) COMPLEX*16 array, dimension * (N) if SIDE = 'L' * or (M) if SIDE = 'R' * * ===================================================================== * * .. Parameters .. COMPLEX*16 ONE, ZERO PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ), $ ZERO = ( 0.0D+0, 0.0D+0 ) ) * .. * .. External Subroutines .. EXTERNAL ZGEMV, ZGERC * .. * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. Executable Statements .. * IF( LSAME( SIDE, 'L' ) ) THEN * * Form H * C * IF( TAU.NE.ZERO ) THEN * * w := C' * v * CALL ZGEMV( 'Conjugate transpose', M, N, ONE, C, LDC, V, $ INCV, ZERO, WORK, 1 ) * * C := C - v * w' * CALL ZGERC( M, N, -TAU, V, INCV, WORK, 1, C, LDC ) END IF ELSE * * Form C * H * IF( TAU.NE.ZERO ) THEN * * w := C * v * CALL ZGEMV( 'No transpose', M, N, ONE, C, LDC, V, INCV, $ ZERO, WORK, 1 ) * * C := C - w * v' * CALL ZGERC( M, N, -TAU, WORK, 1, V, INCV, C, LDC ) END IF END IF RETURN * * End of ZLARF * END
apache-2.0
Alexpux/GCC
libgfortran/generated/_abs_i4.F90
35
1455
! 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_INTEGER_4) elemental function _gfortran_specific__abs_i4 (parm) integer (kind=4), intent (in) :: parm integer (kind=4) :: _gfortran_specific__abs_i4 _gfortran_specific__abs_i4 = abs (parm) end function #endif
gpl-2.0
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/char_pack_1.f90
188
1478
! Test (non-scalar) pack for character arrays. ! { dg-do run } program main implicit none integer, parameter :: n1 = 3, n2 = 4, nv = 10, slen = 9 character (len = slen), dimension (n1, n2) :: a character (len = slen), dimension (nv) :: vector logical, dimension (n1, n2) :: mask integer :: i1, i2, i do i2 = 1, n2 do i1 = 1, n1 a (i1, i2) = 'abc'(i1:i1) // 'defg'(i2:i2) // 'cantrip' end do end do mask (1, :) = (/ .true., .false., .true., .true. /) mask (2, :) = (/ .true., .false., .false., .false. /) mask (3, :) = (/ .false., .true., .true., .true. /) do i = 1, nv vector (i) = 'crespo' // '0123456789'(i:i) end do call test1 (pack (a, mask)) call test2 (pack (a, mask, vector)) contains subroutine test1 (b) character (len = slen), dimension (:) :: b i = 0 do i2 = 1, n2 do i1 = 1, n1 if (mask (i1, i2)) then i = i + 1 if (b (i) .ne. a (i1, i2)) call abort end if end do end do if (size (b, 1) .ne. i) call abort end subroutine test1 subroutine test2 (b) character (len = slen), dimension (:) :: b if (size (b, 1) .ne. nv) call abort i = 0 do i2 = 1, n2 do i1 = 1, n1 if (mask (i1, i2)) then i = i + 1 if (b (i) .ne. a (i1, i2)) call abort end if end do end do do i = i + 1, nv if (b (i) .ne. vector (i)) call abort end do end subroutine test2 end program main
gpl-2.0
Alexpux/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
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/namelist_24.f90
166
1745
!{ dg-do run } !{ dg-options -std=gnu } ! Tests namelist read when more data is provided then specified by ! array qualifier in list. ! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org>. program pr24459 implicit none integer nd, ier, i, j parameter ( nd = 5 ) character*(8) names(nd,nd) character*(8) names2(nd,nd) character*(8) names3(nd,nd) namelist / mynml / names, names2, names3 open(unit=20,status='scratch', delim='apostrophe') write (20, '(a)') "&MYNML" write (20, '(a)') "NAMES = 25*'0'" write (20, '(a)') "NAMES2 = 25*'0'" write (20, '(a)') "NAMES3 = 25*'0'" write (20, '(a)') "NAMES(2,2) = 'frogger'" write (20, '(a)') "NAMES(1,1) = 'E123' 'E456' 'D789' 'P135' 'P246'" write (20, '(a)') "NAMES2(1:5:2,2) = 'abcde' 'fghij' 'klmno'" write (20, '(a)') "NAMES3 = 'E123' 'E456' 'D789' 'P135' 'P246' '0' 'frogger'" write (20, '(a)') "/" rewind(20) read(20,nml=mynml, iostat=ier) if (ier.ne.0) call abort() if (any(names(:,3:5).ne."0")) call abort() if (names(2,2).ne."frogger") call abort() if (names(1,1).ne."E123") call abort() if (names(2,1).ne."E456") call abort() if (names(3,1).ne."D789") call abort() if (names(4,1).ne."P135") call abort() if (names(5,1).ne."P246") call abort() if (any(names2(:,1).ne."0")) call abort() if (any(names2(:,3:5).ne."0")) call abort() if (names2(1,2).ne."abcde") call abort() if (names2(2,2).ne."0") call abort() if (names2(3,2).ne."fghij") call abort() if (names2(4,2).ne."0") call abort() if (names2(5,2).ne."klmno") call abort() if (any(names3.ne.names)) call abort() end
gpl-2.0
renato-monaro/OEMTP
src/support/dlapy3.f
35
2763
*> \brief \b DLAPY3 returns sqrt(x2+y2+z2). * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download DLAPY3 + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlapy3.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlapy3.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlapy3.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * DOUBLE PRECISION FUNCTION DLAPY3( X, Y, Z ) * * .. Scalar Arguments .. * DOUBLE PRECISION X, Y, Z * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DLAPY3 returns sqrt(x**2+y**2+z**2), taking care not to cause *> unnecessary overflow. *> \endverbatim * * Arguments: * ========== * *> \param[in] X *> \verbatim *> X is DOUBLE PRECISION *> \endverbatim *> *> \param[in] Y *> \verbatim *> Y is DOUBLE PRECISION *> \endverbatim *> *> \param[in] Z *> \verbatim *> Z is DOUBLE PRECISION *> X, Y and Z specify the values x, y and z. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup auxOTHERauxiliary * * ===================================================================== DOUBLE PRECISION FUNCTION DLAPY3( X, Y, Z ) * * -- LAPACK auxiliary routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. DOUBLE PRECISION X, Y, Z * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO PARAMETER ( ZERO = 0.0D0 ) * .. * .. Local Scalars .. DOUBLE PRECISION W, XABS, YABS, ZABS * .. * .. Intrinsic Functions .. INTRINSIC ABS, MAX, SQRT * .. * .. Executable Statements .. * XABS = ABS( X ) YABS = ABS( Y ) ZABS = ABS( Z ) W = MAX( XABS, YABS, ZABS ) IF( W.EQ.ZERO ) THEN * W can be zero for max(0,nan,0) * adding all three entries together will make sure * NaN will not disappear. DLAPY3 = XABS + YABS + ZABS ELSE DLAPY3 = W*SQRT( ( XABS / W )**2+( YABS / W )**2+ $ ( ZABS / W )**2 ) END IF RETURN * * End of DLAPY3 * END
gpl-3.0
Alexpux/GCC
libgfortran/generated/_tanh_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_TANHF elemental function _gfortran_specific__tanh_r4 (parm) real (kind=4), intent (in) :: parm real (kind=4) :: _gfortran_specific__tanh_r4 _gfortran_specific__tanh_r4 = tanh (parm) end function #endif #endif
gpl-2.0
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.dg/coarray_lib_token_1.f90
48
2747
! { dg-do compile } ! { dg-options "-fcoarray=lib -fdump-tree-original" } ! ! Check whether TOKEN and OFFSET are correctly propagated ! program main implicit none type t integer(4) :: a, b end type t integer :: caf[*] type(t) :: caf_dt[*] caf = 42 caf_dt = t (1,2) call sub (caf, caf_dt%b) print *,caf, caf_dt%b if (caf /= -99 .or. caf_dt%b /= -101) call abort () call sub_opt () call sub_opt (caf) if (caf /= 124) call abort () contains subroutine sub (x1, x2) integer :: x1[*], x2[*] call sub2 (x1, x2) end subroutine sub subroutine sub2 (y1, y2) integer :: y1[*], y2[*] print *, y1, y2 if (y1 /= 42 .or. y2 /= 2) call abort () y1 = -99 y2 = -101 end subroutine sub2 subroutine sub_opt (z) integer, optional :: z[*] if (present (z)) then if (z /= -99) call abort () z = 124 end if end subroutine sub_opt end program main ! SCAN TREE DUMP AND CLEANUP ! ! PROTOTYPE 1: ! ! sub (integer(kind=4) * restrict x1, integer(kind=4) * restrict x2, ! void * restrict caf_token.4, integer(kind=8) caf_offset.5, ! void * restrict caf_token.6, integer(kind=8) caf_offset.7) ! ! { dg-final { scan-tree-dump-times "sub \\(integer.kind=4. . restrict x1, integer.kind=4. . restrict x2, void . restrict caf_token.\[0-9\]+, integer.kind=.. caf_offset.\[0-9\]+, void . restrict caf_token.\[0-9\]+, integer.kind=.. caf_offset.\[0-9\]+\\)" 1 "original" } } ! ! PROTOTYPE 2: ! ! sub2 (integer(kind=4) * restrict y1, integer(kind=4) * restrict y2, ! void * restrict caf_token.0, integer(kind=8) caf_offset.1, ! void * restrict caf_token.2, integer(kind=8) caf_offset.3) ! ! { dg-final { scan-tree-dump-times "sub2 \\(integer.kind=4. . restrict y1, integer.kind=4. . restrict y2, void . restrict caf_token.\[0-9\]+, integer.kind=.. caf_offset.\[0-9\]+, void . restrict caf_token.\[0-9\]+, integer.kind=.. caf_offset.\[0-9\]+\\)" 1 "original" } } ! ! CALL 1 ! ! sub ((integer(kind=4) *) caf, &caf_dt->b, caf_token.9, 0, caf_token.10, 4); ! ! { dg-final { scan-tree-dump-times "sub \\(\[^,\]*caf, &caf_dt->b, caf_token.\[0-9\]+, 0, caf_token.\[0-9\]+, 4\\)" 1 "original" } } ! ! sub2 ((integer(kind=4) *) x1, (integer(kind=4) *) x2, ! caf_token.4, NON_LVALUE_EXPR <caf_offset.5>, ! caf_token.6, NON_LVALUE_EXPR <caf_offset.7>); ! ! { dg-final { scan-tree-dump-times "sub2 \\(\[^,\]*x1, \[^,\]*x2, caf_token.\[0-9]+, \[^,\]*caf_offset\[^,\]*, caf_token.\[0-9\]+, \[^,\]*caf_offset\[^,\]*\\)" 1 "original" } } ! ! CALL 3 ! ! { dg-final { scan-tree-dump-times "sub_opt \\(0B, 0B, 0\\)" 1 "original" } } ! ! CALL 4 ! ! { dg-final { scan-tree-dump-times "sub_opt \\(.integer.kind=4. .. caf, caf_token.\[0-9\]+, 0\\)" 1 "original" } } !
gpl-2.0
crtc-demos/gcc-ia16
libgfortran/generated/_conjg_c16.F90
16
1466
! Copyright (C) 2002-2016 Free Software Foundation, Inc. ! Contributed by Paul Brook <paul@nowt.org> ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !GNU libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. !GNU libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. ! !This file is machine generated. #include "config.h" #include "kinds.inc" #include "c99_protos.inc" #if defined (HAVE_GFC_COMPLEX_16) elemental function _gfortran_specific__conjg_16 (parm) complex (kind=16), intent (in) :: parm complex (kind=16) :: _gfortran_specific__conjg_16 _gfortran_specific__conjg_16 = conjg (parm) end function #endif
gpl-2.0
Alexpux/GCC
gcc/testsuite/gfortran.dg/pr18122.f90
182
1212
! { dg-do run } ! test namelist with scalars and arrays. ! Based on example provided by thomas.koenig@online.de program sechs_w implicit none integer, parameter :: dr=selected_real_kind(15) integer, parameter :: nkmax=6 real (kind=dr) :: rb(nkmax) integer :: z real (kind=dr) :: dg real (kind=dr) :: a real (kind=dr) :: da real (kind=dr) :: delta real (kind=dr) :: s,t integer :: nk real (kind=dr) alpha0 real (kind=dr) :: phi, phi0, rad, rex, zk, z0, drdphi, dzdphi namelist /schnecke/ z, dg, a, t, delta, s, nk, rb, alpha0 open (10,status="scratch") write (10, *) "&SCHNECKE" write (10, *) " z=1," write (10, *) " dg=58.4," write (10, *) " a=48.," write (10, *) " delta=0.4," write (10, *) " s=0.4," write (10, *) " nk=6," write (10, *) " rb=60, 0, 40," write (10, *) " alpha0=20.," write (10, *) "/" rewind (10) read (10,schnecke) close (10) if ((z /= 1) .or. (dg /= 58.4_dr) .or. (a /= 48.0_dr) .or. & (delta /= 0.4_dr).or. (s /= 0.4_dr) .or. (nk /= 6) .or. & (rb(1) /= 60._dr).or. (rb(2) /= 0.0_dr).or. (rb(3) /=40.0_dr).or. & (alpha0 /= 20.0_dr)) call abort () end program sechs_w
gpl-2.0
Alexpux/GCC
gcc/testsuite/gfortran.dg/argument_checking_13.f90
163
3013
! { dg-do compile } ! ! PR fortran/34796 ! ! Argument checks: ! - elements of deferred-shape arrays (= non-dummies) are allowed ! as the memory is contiguous ! - while assumed-shape arrays (= dummy arguments) and pointers are ! not (strides can make them non-contiguous) ! and ! - if the memory is non-contigous, character arguments have as ! storage size only the size of the element itself, check for ! too short actual arguments. ! subroutine test1(assumed_sh_dummy, pointer_dummy) implicit none interface subroutine rlv1(y) real :: y(3) end subroutine rlv1 end interface real :: assumed_sh_dummy(:,:,:) real, pointer :: pointer_dummy(:,:,:) real, allocatable :: deferred(:,:,:) real, pointer :: ptr(:,:,:) call rlv1(deferred(1,1,1)) ! valid since contiguous call rlv1(ptr(1,1,1)) ! { dg-error "Element of assumed-shaped or pointer array" } call rlv1(assumed_sh_dummy(1,1,1)) ! { dg-error "Element of assumed-shaped or pointer array" } call rlv1(pointer_dummy(1,1,1)) ! { dg-error "Element of assumed-shaped or pointer array" } end subroutine test2(assumed_sh_dummy, pointer_dummy) implicit none interface subroutine rlv2(y) character :: y(3) end subroutine rlv2 end interface character(3) :: assumed_sh_dummy(:,:,:) character(3), pointer :: pointer_dummy(:,:,:) character(3), allocatable :: deferred(:,:,:) character(3), pointer :: ptr(:,:,:) call rlv2(deferred(1,1,1)) ! Valid since contiguous call rlv2(ptr(1,1,1)) ! Valid F2003 call rlv2(assumed_sh_dummy(1,1,1)) ! Valid F2003 call rlv2(pointer_dummy(1,1,1)) ! Valid F2003 ! The following is kind of ok: The memory access it valid ! We warn nonetheless as the result is not what is intented ! and also formally wrong. ! Using (1:string_length) would be ok. call rlv2(ptr(1,1,1)(1:1)) ! { dg-warning "contains too few elements" } call rlv2(assumed_sh_dummy(1,1,1)(1:2)) ! { dg-warning "contains too few elements" } call rlv2(pointer_dummy(1,1,1)(1:3)) ! Valid F2003 end subroutine test3(assumed_sh_dummy, pointer_dummy) implicit none interface subroutine rlv3(y) character :: y(3) end subroutine rlv3 end interface character(2) :: assumed_sh_dummy(:,:,:) character(2), pointer :: pointer_dummy(:,:,:) character(2), allocatable :: deferred(:,:,:) character(2), pointer :: ptr(:,:,:) call rlv3(deferred(1,1,1)) ! Valid since contiguous call rlv3(ptr(1,1,1)) ! { dg-warning "contains too few elements" } call rlv3(assumed_sh_dummy(1,1,1)) ! { dg-warning "contains too few elements" } call rlv3(pointer_dummy(1,1,1)) ! { dg-warning "contains too few elements" } call rlv3(deferred(1,1,1)(1:2)) ! Valid since contiguous call rlv3(ptr(1,1,1)(1:2)) ! { dg-warning "contains too few elements" } call rlv3(assumed_sh_dummy(1,1,1)(1:2)) ! { dg-warning "contains too few elements" } call rlv3(pointer_dummy(1,1,1)(1:2)) ! { dg-warning "contains too few elements" } end
gpl-2.0
Alexpux/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
tenstream/tenstream
tests/test_boxmc_8_16/test_boxmc_8_16.F90
1
9467
module test_boxmc_8_16 use m_boxmc, only: t_boxmc, t_boxmc_8_16 use m_data_parameters, only: & mpiint, iintegers, ireals, ireal_dp, & one, zero, i1, default_str_len, & init_mpi_data_parameters use m_optprop_parameters, only: stddev_atol use m_boxmc_geometry, only: setup_default_unit_cube_geometry use m_helper_functions, only: deg2rad, itoa, ftoa use pfunit_mod implicit none real(ireal_dp) :: bg(3), phi, theta, dx, dy, dz real(ireals) :: S(16), T(8), S_target(16), T_target(8) real(ireals) :: S_tol(16), T_tol(8) real(ireal_dp), allocatable :: vertices(:) type(t_boxmc_8_16) :: bmc_8_16 integer(mpiint) :: myid, mpierr, numnodes, comm character(len=120) :: msg real(ireal_dp), parameter :: sigma = 3 ! normal test range for coefficients real(ireal_dp), parameter :: atol = 1e-3, rtol = 1e-2 !real(ireal_dp),parameter :: atol=1e-5, rtol=1e-3 contains @before subroutine setup(this) class(MpiTestMethod), intent(inout) :: this comm = this%getMpiCommunicator() numnodes = this%getNumProcesses() myid = this%getProcessRank() call init_mpi_data_parameters(comm) call bmc_8_16%init(comm) if (myid .eq. 0) print *, 'Testing Box-MonteCarlo model with tolerances atol/rtol :: ', atol, rtol phi = 0 theta = 0 dx = 100 dy = dx dz = 5 call setup_default_unit_cube_geometry(dx, dy, dz, vertices) S_target = zero T_target = zero end subroutine setup @after subroutine teardown(this) class(MpiTestMethod), intent(inout) :: this if (myid .eq. 0) print *, 'Finishing boxmc tests module' end subroutine teardown @test(npes=[1]) subroutine test_boxmc_select_cases_direct_srctopface(this) class(MpiTestMethod), intent(inout) :: this integer(iintegers) :: src ! direct to diffuse tests bg = [1e-3_ireal_dp, 1e-1_ireal_dp, 1._ireal_dp] theta = 60 phi = 0; src = 1 T_target = [0.30206, 0.00000, 0.06325, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000] S_target = [0.00000, 0.62473, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, & & 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000] call bmc_8_16%get_coeff(comm, bg, src, .true., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) write (msg, *) ' test_boxmc_select_cases_direct_srctopface'//itoa(src)//' phi='//ftoa(phi) call check(S_target, T_target, S, T, msg=msg) phi = 270; src = 2 T_target = [0.06317, 0.30127, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000] S_target = [0.00000, 0.00000, 0.00000, 0.62561, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, & & 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000] call bmc_8_16%get_coeff(comm, bg, src, .true., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) write (msg, *) ' test_boxmc_select_cases_direct_srctopface'//itoa(src)//' phi='//ftoa(phi) call check(S_target, T_target, S, T, msg=msg) phi = 180; src = 3 T_target = [0.06300, 0.00000, 0.30112, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000] S_target = [0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.62593, 0.00000, 0.00000, 0.00000, 0.00000, & & 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000] call bmc_8_16%get_coeff(comm, bg, src, .true., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) write (msg, *) ' test_boxmc_select_cases_direct_srctopface'//itoa(src)//' phi='//ftoa(phi) call check(S_target, T_target, S, T, msg=msg) phi = 90; src = 3 T_target = [0.00000, 0.00000, 0.30130, 0.06258, 0.00000, 0.00000, 0.00000, 0.00000] S_target = [0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.62618, 0.00000, 0.00000, & & 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000] call bmc_8_16%get_coeff(comm, bg, src, .true., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) write (msg, *) ' test_boxmc_select_cases_direct_srctopface'//itoa(src)//' phi='//ftoa(phi) call check(S_target, T_target, S, T, msg=msg) end subroutine @test(npes=[1]) subroutine test_boxmc_select_cases_diff_srctopface(this) class(MpiTestMethod), intent(inout) :: this integer(iintegers) :: src ! direct to diffuse tests bg = [1e-6_ireal_dp, 1e-3_ireal_dp, .99_ireal_dp] T_target = zero src = 2 S_target = [0.00004, 0.90780, 0.00001, 0.00013, 0.00001, 0.00001, 0.00001, 0.00012, 0.01306, 0.01308, & & 0.00001, 0.00000, 0.00000, 0.06572, 0.00000, 0.00001] call bmc_8_16%get_coeff(comm, bg, src, .false., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) call check(S_target, T_target, S, T, msg=' test_boxmc_select_cases_diff_srctopface_quadrant_north') src = 4 S_target = [0.00001, 0.00013, 0.00003, 0.90747, 0.00001, 0.00012, 0.00000, 0.00001, 0.06606, 0.00000, & & 0.00002, 0.00000, 0.01299, 0.01313, 0.00000, 0.00000] call bmc_8_16%get_coeff(comm, bg, src, .false., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) call check(S_target, T_target, S, T, msg=' test_boxmc_select_cases_diff_srctopface_quadrant_west') src = 6 S_target = [0.00000, 0.00002, 0.00000, 0.00013, 0.00003, 0.90742, 0.00001, 0.00012, 0.01294, 0.01324, & & 0.00001, 0.00000, 0.06604, 0.00000, 0.00002, 0.00000] call bmc_8_16%get_coeff(comm, bg, src, .false., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) call check(S_target, T_target, S, T, msg=' test_boxmc_select_cases_diff_srctopface_quadrant_south') src = 8 S_target = [0.00001, 0.00012, 0.00000, 0.00001, 0.00001, 0.00011, 0.00005, 0.90754, 0.00000, 0.06622, & & 0.00000, 0.00002, 0.01317, 0.01272, 0.00000, 0.00001] call bmc_8_16%get_coeff(comm, bg, src, .false., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) call check(S_target, T_target, S, T, msg=' test_boxmc_select_cases_diff_srctopface_quadrant_east') end subroutine @test(npes=[1]) subroutine test_boxmc_select_cases_diff_srcbotface(this) class(MpiTestMethod), intent(inout) :: this integer(iintegers) :: src ! direct to diffuse tests bg = [1e-6_ireal_dp, 1e-3_ireal_dp, .99_ireal_dp] T_target = zero src = 1 S_target = [0.90792, 0.00003, 0.00013, 0.00001, 0.00002, 0.00000, 0.00009, 0.00001, 0.00000, 0.00000, & & 0.01283, 0.01301, 0.00000, 0.00002, 0.00000, 0.06591] call bmc_8_16%get_coeff(comm, bg, src, .false., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) call check(S_target, T_target, S, T, msg=' test_boxmc_select_cases_diff_srcbotface_quadrant_north') src = 3 S_target = [0.00013, 0.00001, 0.90763, 0.00003, 0.00013, 0.00001, 0.00000, 0.00000, 0.00002, 0.00000, & & 0.06609, 0.00000, 0.00000, 0.00000, 0.01290, 0.01304] call bmc_8_16%get_coeff(comm, bg, src, .false., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) call check(S_target, T_target, S, T, msg=' test_boxmc_select_cases_diff_srcbotface_quadrant_west') src = 5 S_target = [0.00001, 0.00001, 0.00013, 0.00000, 0.90761, 0.00004, 0.00012, 0.00001, 0.00001, 0.00001, & & 0.01296, 0.01327, 0.00001, 0.00000, 0.06581, 0.00000] call bmc_8_16%get_coeff(comm, bg, src, .false., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) call check(S_target, T_target, S, T, msg=' test_boxmc_select_cases_diff_srcbotface_quadrant_south') src = 7 S_target = [0.00013, 0.00001, 0.00001, 0.00000, 0.00011, 0.00001, 0.90678, 0.00003, 0.00000, 0.00002, & & 0.00000, 0.06684, 0.00000, 0.00000, 0.01284, 0.01321] call bmc_8_16%get_coeff(comm, bg, src, .false., phi, theta, vertices, S, T, S_tol, T_tol, inp_atol=atol, inp_rtol=rtol) call check(S_target, T_target, S, T, msg=' test_boxmc_select_cases_diff_srcbotface_quadrant_east') end subroutine subroutine check(S_target, T_target, S, T, msg) real(ireals), intent(in), dimension(:) :: S_target, T_target, S, T character(len=*), optional :: msg character(default_str_len) :: local_msgS, local_msgT real(ireals), parameter :: test_atol = real(atol, ireals) * real(sigma, ireals) if (myid .eq. 0) then print *, '' if (present(msg)) then write (local_msgS, *) trim(msg), ':: Diffuse boxmc coefficient not as ' write (local_msgT, *) trim(msg), ':: Direct boxmc coefficient not as ' print *, msg else write (local_msgS, *) 'Diffuse boxmc coefficient not as ' write (local_msgT, *) 'Direct boxmc coefficient not as ' end if print *, '---------------------' write (*, FMT='( " diffuse :: :: ",16(f9.5) )') S write (*, FMT='( " target :: :: ",16(f9.5) )') S_target write (*, FMT='( " diff :: :: ",16(f9.5) )') S_target - S print *, '' write (*, FMT='( " direct :: :: ", 8(f9.5) )') T write (*, FMT='( " target :: :: ", 8(f9.5) )') T_target write (*, FMT='( " diff :: :: ", 8(f9.5) )') T_target - T print *, '---------------------' print *, '' @assertEqual(S_target, S, test_atol, local_msgS) @assertLessThanOrEqual(zero, S) @assertGreaterThanOrEqual(one, S) @assertEqual(T_target, T, test_atol, local_msgT) @assertLessThanOrEqual(zero, T) @assertGreaterThanOrEqual(one, T) end if end subroutine end module
gpl-3.0
Alexpux/GCC
gcc/testsuite/gfortran.dg/pr43984.f90
103
1502
! { dg-do compile } ! { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-pre" } module test type shell1quartet_type integer(kind=kind(1)) :: ab_l_sum integer(kind=kind(1)), dimension(:), pointer :: ab_form_3dints_x_indices => NULL() integer(kind=kind(1)), dimension(:), pointer :: ab_form_3dints_yz_rms_indices => NULL() end type contains subroutine make_esss(self,esss) type(shell1quartet_type) :: self intent(in) :: self real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss real(kind=kind(1.0d0)), dimension(:), pointer :: Izz real(kind=kind(1.0d0)), dimension(:,:), pointer :: Ix,Iy,Iz,Iyz integer(kind=kind(1)), dimension(:), pointer :: e_x,ii_ivec integer(kind=kind(1)) :: dim, dim1, nroots, ii,z,y dim = self%ab_l_sum+1 dim1 = self%ab_l_sum+2 nroots = (dim1) / 2 call create_(Ix,nroots,dim) call create_(Iy,nroots,dim) call create_(Iz,nroots,dim) call create_(Iyz,nroots,dim*dim1/2) e_x => self%ab_form_3dints_x_indices ii_ivec => self%ab_form_3dints_yz_rms_indices call foo(Ix) call foo(Iy) call foo(Iz) esss = ZERO ii = 0 do z=1,dim Izz => Iz(:,z) do y=1,dim1-z ii = ii + 1 Iyz(:,ii) = Izz * Iy(:,y) end do end do esss = esss + sum(Ix(:,e_x) * Iyz(:,ii_ivec),1) end subroutine end ! There should be three loads from iyz.data, not four. ! { dg-final { scan-tree-dump-times "= iyz.data" 3 "pre" } } ! { dg-final { cleanup-tree-dump "pre" } }
gpl-2.0
Alexpux/GCC
gcc/testsuite/gfortran.dg/proc_ptr_comp_23.f90
155
1437
! { dg-do run } ! Tests the fix for PR42104 in which the call to the procedure pointer ! component caused an ICE because the "always_implicit flag was not used ! to force the passing of a descriptor for the array argument. ! ! Contributed by Martien Hulsen <m.a.hulsen@tue.nl> ! module poisson_functions_m implicit none contains function func ( nr, x ) integer, intent(in) :: nr real, intent(in), dimension(:) :: x real :: func real :: pi pi = 4 * atan(1.) select case(nr) case(1) func = 0 case(2) func = 1 case(3) func = 1 + cos(pi*x(1))*cos(pi*x(2)) case default write(*,'(/a,i0/)') 'Error func: wrong function number: ', nr stop end select end function func end module poisson_functions_m module element_defs_m implicit none abstract interface function dummyfunc ( nr, x ) integer, intent(in) :: nr real, intent(in), dimension(:) :: x real :: dummyfunc end function dummyfunc end interface type function_p procedure(dummyfunc), nopass, pointer :: p => null() end type function_p end module element_defs_m program t use poisson_functions_m use element_defs_m procedure(dummyfunc), pointer :: p => null() type(function_p) :: funcp p => func funcp%p => func print *, func(nr=3,x=(/0.1,0.1/)) print *, p(nr=3,x=(/0.1,0.1/)) print *, funcp%p(nr=3,x=(/0.1,0.1/)) end program t
gpl-2.0
CFDEMproject/LIGGGHTS-PUBLIC
lib/linalg/zpptrf.f
72
6478
*> \brief \b ZPPTRF * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download ZPPTRF + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zpptrf.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zpptrf.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zpptrf.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE ZPPTRF( UPLO, N, AP, INFO ) * * .. Scalar Arguments .. * CHARACTER UPLO * INTEGER INFO, N * .. * .. Array Arguments .. * COMPLEX*16 AP( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> ZPPTRF computes the Cholesky factorization of a complex Hermitian *> positive definite matrix A stored in packed format. *> *> The factorization has the form *> A = U**H * U, if UPLO = 'U', or *> A = L * L**H, if UPLO = 'L', *> where U is an upper triangular matrix and L is lower triangular. *> \endverbatim * * Arguments: * ========== * *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> = 'U': Upper triangle of A is stored; *> = 'L': Lower triangle of A is stored. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the matrix A. N >= 0. *> \endverbatim *> *> \param[in,out] AP *> \verbatim *> AP is COMPLEX*16 array, dimension (N*(N+1)/2) *> On entry, the upper or lower triangle of the Hermitian matrix *> A, packed columnwise in a linear array. The j-th column of A *> is stored in the array AP as follows: *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; *> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. *> See below for further details. *> *> On exit, if INFO = 0, the triangular factor U or L from the *> Cholesky factorization A = U**H*U or A = L*L**H, in the same *> storage format as A. *> \endverbatim *> *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -i, the i-th argument had an illegal value *> > 0: if INFO = i, the leading minor of order i is not *> positive definite, and the factorization could not be *> completed. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup complex16OTHERcomputational * *> \par Further Details: * ===================== *> *> \verbatim *> *> The packed storage scheme is illustrated by the following example *> when N = 4, UPLO = 'U': *> *> Two-dimensional storage of the Hermitian matrix A: *> *> a11 a12 a13 a14 *> a22 a23 a24 *> a33 a34 (aij = conjg(aji)) *> a44 *> *> Packed storage of the upper triangle of A: *> *> AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] *> \endverbatim *> * ===================================================================== SUBROUTINE ZPPTRF( UPLO, N, AP, INFO ) * * -- LAPACK computational routine (version 3.4.0) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. CHARACTER UPLO INTEGER INFO, N * .. * .. Array Arguments .. COMPLEX*16 AP( * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ZERO, ONE PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) * .. * .. Local Scalars .. LOGICAL UPPER INTEGER J, JC, JJ DOUBLE PRECISION AJJ * .. * .. External Functions .. LOGICAL LSAME COMPLEX*16 ZDOTC EXTERNAL LSAME, ZDOTC * .. * .. External Subroutines .. EXTERNAL XERBLA, ZDSCAL, ZHPR, ZTPSV * .. * .. Intrinsic Functions .. INTRINSIC DBLE, SQRT * .. * .. Executable Statements .. * * Test the input parameters. * INFO = 0 UPPER = LSAME( UPLO, 'U' ) IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN INFO = -1 ELSE IF( N.LT.0 ) THEN INFO = -2 END IF IF( INFO.NE.0 ) THEN CALL XERBLA( 'ZPPTRF', -INFO ) RETURN END IF * * Quick return if possible * IF( N.EQ.0 ) $ RETURN * IF( UPPER ) THEN * * Compute the Cholesky factorization A = U**H * U. * JJ = 0 DO 10 J = 1, N JC = JJ + 1 JJ = JJ + J * * Compute elements 1:J-1 of column J. * IF( J.GT.1 ) $ CALL ZTPSV( 'Upper', 'Conjugate transpose', 'Non-unit', $ J-1, AP, AP( JC ), 1 ) * * Compute U(J,J) and test for non-positive-definiteness. * AJJ = DBLE( AP( JJ ) ) - ZDOTC( J-1, AP( JC ), 1, AP( JC ), $ 1 ) IF( AJJ.LE.ZERO ) THEN AP( JJ ) = AJJ GO TO 30 END IF AP( JJ ) = SQRT( AJJ ) 10 CONTINUE ELSE * * Compute the Cholesky factorization A = L * L**H. * JJ = 1 DO 20 J = 1, N * * Compute L(J,J) and test for non-positive-definiteness. * AJJ = DBLE( AP( JJ ) ) IF( AJJ.LE.ZERO ) THEN AP( JJ ) = AJJ GO TO 30 END IF AJJ = SQRT( AJJ ) AP( JJ ) = AJJ * * Compute elements J+1:N of column J and update the trailing * submatrix. * IF( J.LT.N ) THEN CALL ZDSCAL( N-J, ONE / AJJ, AP( JJ+1 ), 1 ) CALL ZHPR( 'Lower', N-J, -ONE, AP( JJ+1 ), 1, $ AP( JJ+N-J+1 ) ) JJ = JJ + N - J + 1 END IF 20 CONTINUE END IF GO TO 40 * 30 CONTINUE INFO = J * 40 CONTINUE RETURN * * End of ZPPTRF * END
gpl-2.0
ajjl/ITK
Modules/ThirdParty/VNL/src/vxl/v3p/netlib/mathews/trapezod.f
41
1043
C NUMERICAL METHODS: FORTRAN Programs, (c) John H. Mathews 1994 C To accompany the text: C NUMERICAL METHODS for Mathematics, Science and Engineering, 2nd Ed, 1992 C Prentice Hall, Englewood Cliffs, New Jersey, 07632, U.S.A. C This free software is complements of the author. C C Algorithm 7.1 (Composite Trapezoidal Rule). C Section 7.2, Composite Trapezoidal and Simpson's Rule, Page 365 C SUBROUTINE TRAPRU(F,A,B,M,Trule) INTEGER K,M DOUBLE PRECISION A,B,H,Sum,Trule,X EXTERNAL F H=(B-A)/M Sum=0 DO K=1,M-1 X=A+H*K Sum=Sum+F(X) ENDDO Sum=H*(F(A)+F(B)+2*Sum)/2 Trule=Sum RETURN END SUBROUTINE XTRAPRU(F,A,B,M,Trule) C This subroutine uses labeled DO loop(s). INTEGER K,M DOUBLE PRECISION A,B,H,Sum,Trule,X EXTERNAL F H=(B-A)/M Sum=0 DO 10 K=1,M-1 X=A+H*K Sum=Sum+F(X) 10 CONTINUE Sum=H*(F(A)+F(B)+2*Sum)/2 Trule=Sum RETURN END
apache-2.0
tenstream/tenstream
rrtmg/rrtm_lw/rrlw_tbl.f90
1
1706
module m_tenstr_rrlw_tbl use m_tenstr_parkind_lw, only : im => kind_im, rb => kind_rb implicit none save !------------------------------------------------------------------ ! rrtmg_lw exponential lookup table arrays ! Initial version: JJMorcrette, ECMWF, jul1998 ! Revised: MJIacono, AER, Jun 2006 ! Revised: MJIacono, AER, Aug 2007 ! Revised: MJIacono, AER, Aug 2008 !------------------------------------------------------------------ ! name type purpose ! ----- : ---- : ---------------------------------------------- ! ntbl : integer: Lookup table dimension ! tblint : real : Lookup table conversion factor ! tau_tbl: real : Clear-sky optical depth (used in cloudy radiative ! transfer) ! exp_tbl: real : Transmittance lookup table ! tfn_tbl: real : Tau transition function; i.e. the transition of ! the Planck function from that for the mean layer ! temperature to that for the layer boundary ! temperature as a function of optical depth. ! The "linear in tau" method is used to make ! the table. ! pade : real : Pade constant ! bpade : real : Inverse of Pade constant !------------------------------------------------------------------ integer(kind=im), parameter :: ntbl = 10000 real(kind=rb), parameter :: tblint = 10000.0_rb real(kind=rb) , dimension(0:ntbl) :: tau_tbl real(kind=rb) , dimension(0:ntbl) :: exp_tbl real(kind=rb) , dimension(0:ntbl) :: tfn_tbl real(kind=rb), parameter :: pade = 0.278_rb real(kind=rb) :: bpade end module m_tenstr_rrlw_tbl
gpl-3.0
crtc-demos/gcc-ia16
libgfortran/generated/misc_specifics.F90
16
6990
! Copyright (C) 2002-2016 Free Software Foundation, Inc. ! Contributed by Paul Brook <paul@nowt.org> ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !GNU libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. !GNU libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. ! !This file is machine generated. #include "config.h" #include "kinds.inc" #if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__nint_4_4 (parm) real (kind=4) , intent (in) :: parm integer (kind=4) :: _gfortran_specific__nint_4_4 _gfortran_specific__nint_4_4 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__nint_4_8 (parm) real (kind=8) , intent (in) :: parm integer (kind=4) :: _gfortran_specific__nint_4_8 _gfortran_specific__nint_4_8 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__nint_4_10 (parm) real (kind=10) , intent (in) :: parm integer (kind=4) :: _gfortran_specific__nint_4_10 _gfortran_specific__nint_4_10 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__nint_4_16 (parm) real (kind=16) , intent (in) :: parm integer (kind=4) :: _gfortran_specific__nint_4_16 _gfortran_specific__nint_4_16 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__nint_8_4 (parm) real (kind=4) , intent (in) :: parm integer (kind=8) :: _gfortran_specific__nint_8_4 _gfortran_specific__nint_8_4 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__nint_8_8 (parm) real (kind=8) , intent (in) :: parm integer (kind=8) :: _gfortran_specific__nint_8_8 _gfortran_specific__nint_8_8 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__nint_8_10 (parm) real (kind=10) , intent (in) :: parm integer (kind=8) :: _gfortran_specific__nint_8_10 _gfortran_specific__nint_8_10 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__nint_8_16 (parm) real (kind=16) , intent (in) :: parm integer (kind=8) :: _gfortran_specific__nint_8_16 _gfortran_specific__nint_8_16 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__nint_16_4 (parm) real (kind=4) , intent (in) :: parm integer (kind=16) :: _gfortran_specific__nint_16_4 _gfortran_specific__nint_16_4 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__nint_16_8 (parm) real (kind=8) , intent (in) :: parm integer (kind=16) :: _gfortran_specific__nint_16_8 _gfortran_specific__nint_16_8 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__nint_16_10 (parm) real (kind=10) , intent (in) :: parm integer (kind=16) :: _gfortran_specific__nint_16_10 _gfortran_specific__nint_16_10 = nint (parm) end function #endif #if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__nint_16_16 (parm) real (kind=16) , intent (in) :: parm integer (kind=16) :: _gfortran_specific__nint_16_16 _gfortran_specific__nint_16_16 = nint (parm) end function #endif #if defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__char_1_i4 (parm) integer (kind=4) , intent (in) :: parm character (kind=1,len=1) :: _gfortran_specific__char_1_i4 _gfortran_specific__char_1_i4 = char (parm, kind=1) end function #endif #if defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__char_1_i8 (parm) integer (kind=8) , intent (in) :: parm character (kind=1,len=1) :: _gfortran_specific__char_1_i8 _gfortran_specific__char_1_i8 = char (parm, kind=1) end function #endif #if defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__char_1_i16 (parm) integer (kind=16) , intent (in) :: parm character (kind=1,len=1) :: _gfortran_specific__char_1_i16 _gfortran_specific__char_1_i16 = char (parm, kind=1) end function #endif #if defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__len_1_i4 (parm) character (kind=1,len=*) , intent (in) :: parm integer (kind=4) :: _gfortran_specific__len_1_i4 _gfortran_specific__len_1_i4 = len (parm) end function #endif #if defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__len_1_i8 (parm) character (kind=1,len=*) , intent (in) :: parm integer (kind=8) :: _gfortran_specific__len_1_i8 _gfortran_specific__len_1_i8 = len (parm) end function #endif #if defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__len_1_i16 (parm) character (kind=1,len=*) , intent (in) :: parm integer (kind=16) :: _gfortran_specific__len_1_i16 _gfortran_specific__len_1_i16 = len (parm) end function #endif #if defined (HAVE_GFC_INTEGER_4) elemental function _gfortran_specific__index_1_i4 (parm1, parm2) character (kind=1,len=*) , intent (in) :: parm1, parm2 integer (kind=4) :: _gfortran_specific__index_1_i4 _gfortran_specific__index_1_i4 = index (parm1, parm2) end function #endif #if defined (HAVE_GFC_INTEGER_8) elemental function _gfortran_specific__index_1_i8 (parm1, parm2) character (kind=1,len=*) , intent (in) :: parm1, parm2 integer (kind=8) :: _gfortran_specific__index_1_i8 _gfortran_specific__index_1_i8 = index (parm1, parm2) end function #endif #if defined (HAVE_GFC_INTEGER_16) elemental function _gfortran_specific__index_1_i16 (parm1, parm2) character (kind=1,len=*) , intent (in) :: parm1, parm2 integer (kind=16) :: _gfortran_specific__index_1_i16 _gfortran_specific__index_1_i16 = index (parm1, parm2) end function #endif
gpl-2.0
renato-monaro/OEMTP
src/support/zlarfg.f
33
5417
*> \brief \b ZLARFG generates an elementary reflector (Householder matrix). * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * *> \htmlonly *> Download ZLARFG + dependencies *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarfg.f"> *> [TGZ]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarfg.f"> *> [ZIP]</a> *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarfg.f"> *> [TXT]</a> *> \endhtmlonly * * Definition: * =========== * * SUBROUTINE ZLARFG( N, ALPHA, X, INCX, TAU ) * * .. Scalar Arguments .. * INTEGER INCX, N * COMPLEX*16 ALPHA, TAU * .. * .. Array Arguments .. * COMPLEX*16 X( * ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> ZLARFG generates a complex elementary reflector H of order n, such *> that *> *> H**H * ( alpha ) = ( beta ), H**H * H = I. *> ( x ) ( 0 ) *> *> where alpha and beta are scalars, with beta real, and x is an *> (n-1)-element complex vector. H is represented in the form *> *> H = I - tau * ( 1 ) * ( 1 v**H ) , *> ( v ) *> *> where tau is a complex scalar and v is a complex (n-1)-element *> vector. Note that H is not hermitian. *> *> If the elements of x are all zero and alpha is real, then tau = 0 *> and H is taken to be the unit matrix. *> *> Otherwise 1 <= real(tau) <= 2 and abs(tau-1) <= 1 . *> \endverbatim * * Arguments: * ========== * *> \param[in] N *> \verbatim *> N is INTEGER *> The order of the elementary reflector. *> \endverbatim *> *> \param[in,out] ALPHA *> \verbatim *> ALPHA is COMPLEX*16 *> On entry, the value alpha. *> On exit, it is overwritten with the value beta. *> \endverbatim *> *> \param[in,out] X *> \verbatim *> X is COMPLEX*16 array, dimension *> (1+(N-2)*abs(INCX)) *> On entry, the vector x. *> On exit, it is overwritten with the vector v. *> \endverbatim *> *> \param[in] INCX *> \verbatim *> INCX is INTEGER *> The increment between elements of X. INCX > 0. *> \endverbatim *> *> \param[out] TAU *> \verbatim *> TAU is COMPLEX*16 *> The value tau. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date September 2012 * *> \ingroup complex16OTHERauxiliary * * ===================================================================== SUBROUTINE ZLARFG( N, ALPHA, X, INCX, TAU ) * * -- LAPACK auxiliary routine (version 3.4.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * September 2012 * * .. Scalar Arguments .. INTEGER INCX, N COMPLEX*16 ALPHA, TAU * .. * .. Array Arguments .. COMPLEX*16 X( * ) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ONE, ZERO PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 ) * .. * .. Local Scalars .. INTEGER J, KNT DOUBLE PRECISION ALPHI, ALPHR, BETA, RSAFMN, SAFMIN, XNORM * .. * .. External Functions .. DOUBLE PRECISION DLAMCH, DLAPY3, DZNRM2 COMPLEX*16 ZLADIV EXTERNAL DLAMCH, DLAPY3, DZNRM2, ZLADIV * .. * .. Intrinsic Functions .. INTRINSIC ABS, DBLE, DCMPLX, DIMAG, SIGN * .. * .. External Subroutines .. EXTERNAL ZDSCAL, ZSCAL * .. * .. Executable Statements .. * IF( N.LE.0 ) THEN TAU = ZERO RETURN END IF * XNORM = DZNRM2( N-1, X, INCX ) ALPHR = DBLE( ALPHA ) ALPHI = DIMAG( ALPHA ) * IF( XNORM.EQ.ZERO .AND. ALPHI.EQ.ZERO ) THEN * * H = I * TAU = ZERO ELSE * * general case * BETA = -SIGN( DLAPY3( ALPHR, ALPHI, XNORM ), ALPHR ) SAFMIN = DLAMCH( 'S' ) / DLAMCH( 'E' ) RSAFMN = ONE / SAFMIN * KNT = 0 IF( ABS( BETA ).LT.SAFMIN ) THEN * * XNORM, BETA may be inaccurate; scale X and recompute them * 10 CONTINUE KNT = KNT + 1 CALL ZDSCAL( N-1, RSAFMN, X, INCX ) BETA = BETA*RSAFMN ALPHI = ALPHI*RSAFMN ALPHR = ALPHR*RSAFMN IF( ABS( BETA ).LT.SAFMIN ) $ GO TO 10 * * New BETA is at most 1, at least SAFMIN * XNORM = DZNRM2( N-1, X, INCX ) ALPHA = DCMPLX( ALPHR, ALPHI ) BETA = -SIGN( DLAPY3( ALPHR, ALPHI, XNORM ), ALPHR ) END IF TAU = DCMPLX( ( BETA-ALPHR ) / BETA, -ALPHI / BETA ) ALPHA = ZLADIV( DCMPLX( ONE ), ALPHA-BETA ) CALL ZSCAL( N-1, ALPHA, X, INCX ) * * If ALPHA is subnormal, it may lose relative accuracy * DO 20 J = 1, KNT BETA = BETA*SAFMIN 20 CONTINUE ALPHA = BETA END IF * RETURN * * End of ZLARFG * END
gpl-3.0
tm1249wk/WASHLIGGGHTS-2.3.7
lib/meam/meam_force.F
30
23692
c Extern "C" declaration has the form: c c void meam_force_(int *, int *, int *, double *, int *, int *, int *, double *, c int *, int *, int *, int *, double *, double *, c double *, double *, double *, double *, double *, double *, c double *, double *, double *, double *, double *, double *, c double *, double *, double *, double *, double *, double *, int *); c c Call from pair_meam.cpp has the form: c c meam_force_(&i,&nmax,&eflag_either,&eflag_global,&eflag_atom,&vflag_atom, c &eng_vdwl,eatom,&ntype,type,fmap,&x[0][0], c &numneigh[i],firstneigh[i],&numneigh_full[i],firstneigh_full[i], c &scrfcn[offset],&dscrfcn[offset],&fcpair[offset], c dgamma1,dgamma2,dgamma3,rho0,rho1,rho2,rho3,frhop, c &arho1[0][0],&arho2[0][0],arho2b,&arho3[0][0],&arho3b[0][0], c &t_ave[0][0],&tsq_ave[0][0],&f[0][0],&vatom[0][0],&errorflag); c subroutine meam_force(i, nmax, $ eflag_either, eflag_global, eflag_atom, vflag_atom, $ eng_vdwl, eatom, ntype, type, fmap, x, $ numneigh, firstneigh, numneigh_full, firstneigh_full, $ scrfcn, dscrfcn, fcpair, $ dGamma1, dGamma2, dGamma3, rho0, rho1, rho2, rho3, fp, $ Arho1, Arho2, Arho2b, Arho3, Arho3b, t_ave, tsq_ave, f, $ vatom, errorflag) use meam_data implicit none integer eflag_either, eflag_global, eflag_atom, vflag_atom integer nmax, ntype, type, fmap real*8 eng_vdwl, eatom, x integer numneigh, firstneigh, numneigh_full, firstneigh_full real*8 scrfcn, dscrfcn, fcpair real*8 dGamma1, dGamma2, dGamma3 real*8 rho0, rho1, rho2, rho3, fp real*8 Arho1, Arho2, Arho2b real*8 Arho3, Arho3b real*8 t_ave, tsq_ave, f, vatom integer errorflag dimension eatom(nmax) dimension type(nmax), fmap(ntype) dimension x(3,nmax) dimension firstneigh(numneigh), firstneigh_full(numneigh_full) dimension scrfcn(numneigh), dscrfcn(numneigh), fcpair(numneigh) dimension dGamma1(nmax), dGamma2(nmax), dGamma3(nmax) dimension rho0(nmax), rho1(nmax), rho2(nmax), rho3(nmax), fp(nmax) dimension Arho1(3,nmax), Arho2(6,nmax), Arho2b(nmax) dimension Arho3(10,nmax), Arho3b(3,nmax) dimension t_ave(3,nmax), tsq_ave(3,nmax), f(3,nmax), vatom(6,nmax) integer i,j,jn,k,kn,kk,m,n,p,q integer nv2,nv3,elti,eltj,eltk,ind real*8 xitmp,yitmp,zitmp,delij(3),delref(3),rij2,rij,rij3 real*8 delik(3),deljk(3),v(6),fi(3),fj(3) real*8 Eu,astar,astarp,third,sixth real*8 pp,phiforce,dUdrij,dUdsij,dUdrijm(3),force,forcem real*8 B,r,recip,phi,phip,rhop,a real*8 sij,fcij,dfcij,ds(3) real*8 a0,a1,a1i,a1j,a2,a2i,a2j real*8 a3i,a3j,a3i1,a3i2,a3j1,a3j2 real*8 G,dG,Gbar,dGbar,gam,shpi(3),shpj(3),Z,denom real*8 ai,aj,ro0i,ro0j,invrei,invrej real*8 b0,rhoa0j,drhoa0j,rhoa0i,drhoa0i real*8 b1,rhoa1j,drhoa1j,rhoa1i,drhoa1i real*8 b2,rhoa2j,drhoa2j,rhoa2i,drhoa2i real*8 a3,a3a,b3,rhoa3j,drhoa3j,rhoa3i,drhoa3i real*8 drho0dr1,drho0dr2,drho0ds1,drho0ds2 real*8 drho1dr1,drho1dr2,drho1ds1,drho1ds2 real*8 drho1drm1(3),drho1drm2(3) real*8 drho2dr1,drho2dr2,drho2ds1,drho2ds2 real*8 drho2drm1(3),drho2drm2(3) real*8 drho3dr1,drho3dr2,drho3ds1,drho3ds2 real*8 drho3drm1(3),drho3drm2(3) real*8 dt1dr1,dt1dr2,dt1ds1,dt1ds2 real*8 dt2dr1,dt2dr2,dt2ds1,dt2ds2 real*8 dt3dr1,dt3dr2,dt3ds1,dt3ds2 real*8 drhodr1,drhodr2,drhods1,drhods2,drhodrm1(3),drhodrm2(3) real*8 arg,arg1,arg2 real*8 arg1i1,arg1j1,arg1i2,arg1j2,arg2i2,arg2j2 real*8 arg1i3,arg1j3,arg2i3,arg2j3,arg3i3,arg3j3 real*8 dsij1,dsij2,force1,force2 real*8 t1i,t2i,t3i,t1j,t2j,t3j errorflag = 0 third = 1.0/3.0 sixth = 1.0/6.0 c Compute forces atom i elti = fmap(type(i)) if (elti.gt.0) then xitmp = x(1,i) yitmp = x(2,i) zitmp = x(3,i) c Treat each pair do jn = 1,numneigh j = firstneigh(jn) eltj = fmap(type(j)) if (scrfcn(jn).ne.0.d0.and.eltj.gt.0) then sij = scrfcn(jn)*fcpair(jn) delij(1) = x(1,j) - xitmp delij(2) = x(2,j) - yitmp delij(3) = x(3,j) - zitmp rij2 = delij(1)*delij(1) + delij(2)*delij(2) $ + delij(3)*delij(3) if (rij2.lt.cutforcesq) then rij = sqrt(rij2) r = rij c Compute phi and phip ind = eltind(elti,eltj) pp = rij*rdrar + 1.0D0 kk = pp kk = min(kk,nrar-1) pp = pp - kk pp = min(pp,1.0D0) phi = ((phirar3(kk,ind)*pp + phirar2(kk,ind))*pp $ + phirar1(kk,ind))*pp + phirar(kk,ind) phip = (phirar6(kk,ind)*pp + phirar5(kk,ind))*pp $ + phirar4(kk,ind) recip = 1.0d0/r if (eflag_either.ne.0) then if (eflag_global.ne.0) eng_vdwl = eng_vdwl + phi*sij if (eflag_atom.ne.0) then eatom(i) = eatom(i) + 0.5*phi*sij eatom(j) = eatom(j) + 0.5*phi*sij endif endif c write(1,*) "force_meamf: phi: ",phi c write(1,*) "force_meamf: phip: ",phip c Compute pair densities and derivatives invrei = 1.d0/re_meam(elti,elti) ai = rij*invrei - 1.d0 ro0i = rho0_meam(elti) rhoa0i = ro0i*exp(-beta0_meam(elti)*ai) drhoa0i = -beta0_meam(elti)*invrei*rhoa0i rhoa1i = ro0i*exp(-beta1_meam(elti)*ai) drhoa1i = -beta1_meam(elti)*invrei*rhoa1i rhoa2i = ro0i*exp(-beta2_meam(elti)*ai) drhoa2i = -beta2_meam(elti)*invrei*rhoa2i rhoa3i = ro0i*exp(-beta3_meam(elti)*ai) drhoa3i = -beta3_meam(elti)*invrei*rhoa3i if (elti.ne.eltj) then invrej = 1.d0/re_meam(eltj,eltj) aj = rij*invrej - 1.d0 ro0j = rho0_meam(eltj) rhoa0j = ro0j*exp(-beta0_meam(eltj)*aj) drhoa0j = -beta0_meam(eltj)*invrej*rhoa0j rhoa1j = ro0j*exp(-beta1_meam(eltj)*aj) drhoa1j = -beta1_meam(eltj)*invrej*rhoa1j rhoa2j = ro0j*exp(-beta2_meam(eltj)*aj) drhoa2j = -beta2_meam(eltj)*invrej*rhoa2j rhoa3j = ro0j*exp(-beta3_meam(eltj)*aj) drhoa3j = -beta3_meam(eltj)*invrej*rhoa3j else rhoa0j = rhoa0i drhoa0j = drhoa0i rhoa1j = rhoa1i drhoa1j = drhoa1i rhoa2j = rhoa2i drhoa2j = drhoa2i rhoa3j = rhoa3i drhoa3j = drhoa3i endif if (ialloy.eq.1) then rhoa1j = rhoa1j * t1_meam(eltj) rhoa2j = rhoa2j * t2_meam(eltj) rhoa3j = rhoa3j * t3_meam(eltj) rhoa1i = rhoa1i * t1_meam(elti) rhoa2i = rhoa2i * t2_meam(elti) rhoa3i = rhoa3i * t3_meam(elti) drhoa1j = drhoa1j * t1_meam(eltj) drhoa2j = drhoa2j * t2_meam(eltj) drhoa3j = drhoa3j * t3_meam(eltj) drhoa1i = drhoa1i * t1_meam(elti) drhoa2i = drhoa2i * t2_meam(elti) drhoa3i = drhoa3i * t3_meam(elti) endif nv2 = 1 nv3 = 1 arg1i1 = 0.d0 arg1j1 = 0.d0 arg1i2 = 0.d0 arg1j2 = 0.d0 arg1i3 = 0.d0 arg1j3 = 0.d0 arg3i3 = 0.d0 arg3j3 = 0.d0 do n = 1,3 do p = n,3 do q = p,3 arg = delij(n)*delij(p)*delij(q)*v3D(nv3) arg1i3 = arg1i3 + Arho3(nv3,i)*arg arg1j3 = arg1j3 - Arho3(nv3,j)*arg nv3 = nv3+1 enddo arg = delij(n)*delij(p)*v2D(nv2) arg1i2 = arg1i2 + Arho2(nv2,i)*arg arg1j2 = arg1j2 + Arho2(nv2,j)*arg nv2 = nv2+1 enddo arg1i1 = arg1i1 + Arho1(n,i)*delij(n) arg1j1 = arg1j1 - Arho1(n,j)*delij(n) arg3i3 = arg3i3 + Arho3b(n,i)*delij(n) arg3j3 = arg3j3 - Arho3b(n,j)*delij(n) enddo c rho0 terms drho0dr1 = drhoa0j * sij drho0dr2 = drhoa0i * sij c rho1 terms a1 = 2*sij/rij drho1dr1 = a1*(drhoa1j-rhoa1j/rij)*arg1i1 drho1dr2 = a1*(drhoa1i-rhoa1i/rij)*arg1j1 a1 = 2.d0*sij/rij do m = 1,3 drho1drm1(m) = a1*rhoa1j*Arho1(m,i) drho1drm2(m) = -a1*rhoa1i*Arho1(m,j) enddo c rho2 terms a2 = 2*sij/rij2 drho2dr1 = a2*(drhoa2j - 2*rhoa2j/rij)*arg1i2 $ - 2.d0/3.d0*Arho2b(i)*drhoa2j*sij drho2dr2 = a2*(drhoa2i - 2*rhoa2i/rij)*arg1j2 $ - 2.d0/3.d0*Arho2b(j)*drhoa2i*sij a2 = 4*sij/rij2 do m = 1,3 drho2drm1(m) = 0.d0 drho2drm2(m) = 0.d0 do n = 1,3 drho2drm1(m) = drho2drm1(m) $ + Arho2(vind2D(m,n),i)*delij(n) drho2drm2(m) = drho2drm2(m) $ - Arho2(vind2D(m,n),j)*delij(n) enddo drho2drm1(m) = a2*rhoa2j*drho2drm1(m) drho2drm2(m) = -a2*rhoa2i*drho2drm2(m) enddo c rho3 terms rij3 = rij*rij2 a3 = 2*sij/rij3 a3a = 6.d0/5.d0*sij/rij drho3dr1 = a3*(drhoa3j - 3*rhoa3j/rij)*arg1i3 $ - a3a*(drhoa3j - rhoa3j/rij)*arg3i3 drho3dr2 = a3*(drhoa3i - 3*rhoa3i/rij)*arg1j3 $ - a3a*(drhoa3i - rhoa3i/rij)*arg3j3 a3 = 6*sij/rij3 a3a = 6*sij/(5*rij) do m = 1,3 drho3drm1(m) = 0.d0 drho3drm2(m) = 0.d0 nv2 = 1 do n = 1,3 do p = n,3 arg = delij(n)*delij(p)*v2D(nv2) drho3drm1(m) = drho3drm1(m) $ + Arho3(vind3D(m,n,p),i)*arg drho3drm2(m) = drho3drm2(m) $ + Arho3(vind3D(m,n,p),j)*arg nv2 = nv2 + 1 enddo enddo drho3drm1(m) = (a3*drho3drm1(m) - a3a*Arho3b(m,i)) $ *rhoa3j drho3drm2(m) = (-a3*drho3drm2(m) + a3a*Arho3b(m,j)) $ *rhoa3i enddo c Compute derivatives of weighting functions t wrt rij t1i = t_ave(1,i) t2i = t_ave(2,i) t3i = t_ave(3,i) t1j = t_ave(1,j) t2j = t_ave(2,j) t3j = t_ave(3,j) if (ialloy.eq.1) then a1i = 0.d0 a1j = 0.d0 a2i = 0.d0 a2j = 0.d0 a3i = 0.d0 a3j = 0.d0 if ( tsq_ave(1,i) .ne. 0.d0 ) then a1i = drhoa0j*sij/tsq_ave(1,i) endif if ( tsq_ave(1,j) .ne. 0.d0 ) then a1j = drhoa0i*sij/tsq_ave(1,j) endif if ( tsq_ave(2,i) .ne. 0.d0 ) then a2i = drhoa0j*sij/tsq_ave(2,i) endif if ( tsq_ave(2,j) .ne. 0.d0 ) then a2j = drhoa0i*sij/tsq_ave(2,j) endif if ( tsq_ave(3,i) .ne. 0.d0 ) then a3i = drhoa0j*sij/tsq_ave(3,i) endif if ( tsq_ave(3,j) .ne. 0.d0 ) then a3j = drhoa0i*sij/tsq_ave(3,j) endif dt1dr1 = a1i*(t1_meam(eltj)-t1i*t1_meam(eltj)**2) dt1dr2 = a1j*(t1_meam(elti)-t1j*t1_meam(elti)**2) dt2dr1 = a2i*(t2_meam(eltj)-t2i*t2_meam(eltj)**2) dt2dr2 = a2j*(t2_meam(elti)-t2j*t2_meam(elti)**2) dt3dr1 = a3i*(t3_meam(eltj)-t3i*t3_meam(eltj)**2) dt3dr2 = a3j*(t3_meam(elti)-t3j*t3_meam(elti)**2) else if (ialloy.eq.2) then dt1dr1 = 0.d0 dt1dr2 = 0.d0 dt2dr1 = 0.d0 dt2dr2 = 0.d0 dt3dr1 = 0.d0 dt3dr2 = 0.d0 else ai = 0.d0 if( rho0(i) .ne. 0.d0 ) then ai = drhoa0j*sij/rho0(i) end if aj = 0.d0 if( rho0(j) .ne. 0.d0 ) then aj = drhoa0i*sij/rho0(j) end if dt1dr1 = ai*(t1_meam(eltj)-t1i) dt1dr2 = aj*(t1_meam(elti)-t1j) dt2dr1 = ai*(t2_meam(eltj)-t2i) dt2dr2 = aj*(t2_meam(elti)-t2j) dt3dr1 = ai*(t3_meam(eltj)-t3i) dt3dr2 = aj*(t3_meam(elti)-t3j) endif c Compute derivatives of total density wrt rij, sij and rij(3) call get_shpfcn(shpi,lattce_meam(elti,elti)) call get_shpfcn(shpj,lattce_meam(eltj,eltj)) drhodr1 = dGamma1(i)*drho0dr1 $ + dGamma2(i)* $ (dt1dr1*rho1(i)+t1i*drho1dr1 $ + dt2dr1*rho2(i)+t2i*drho2dr1 $ + dt3dr1*rho3(i)+t3i*drho3dr1) $ - dGamma3(i)* $ (shpi(1)*dt1dr1+shpi(2)*dt2dr1+shpi(3)*dt3dr1) drhodr2 = dGamma1(j)*drho0dr2 $ + dGamma2(j)* $ (dt1dr2*rho1(j)+t1j*drho1dr2 $ + dt2dr2*rho2(j)+t2j*drho2dr2 $ + dt3dr2*rho3(j)+t3j*drho3dr2) $ - dGamma3(j)* $ (shpj(1)*dt1dr2+shpj(2)*dt2dr2+shpj(3)*dt3dr2) do m = 1,3 drhodrm1(m) = 0.d0 drhodrm2(m) = 0.d0 drhodrm1(m) = dGamma2(i)* $ (t1i*drho1drm1(m) $ + t2i*drho2drm1(m) $ + t3i*drho3drm1(m)) drhodrm2(m) = dGamma2(j)* $ (t1j*drho1drm2(m) $ + t2j*drho2drm2(m) $ + t3j*drho3drm2(m)) enddo c Compute derivatives wrt sij, but only if necessary if (dscrfcn(jn).ne.0.d0) then drho0ds1 = rhoa0j drho0ds2 = rhoa0i a1 = 2.d0/rij drho1ds1 = a1*rhoa1j*arg1i1 drho1ds2 = a1*rhoa1i*arg1j1 a2 = 2.d0/rij2 drho2ds1 = a2*rhoa2j*arg1i2 $ - 2.d0/3.d0*Arho2b(i)*rhoa2j drho2ds2 = a2*rhoa2i*arg1j2 $ - 2.d0/3.d0*Arho2b(j)*rhoa2i a3 = 2.d0/rij3 a3a = 6.d0/(5.d0*rij) drho3ds1 = a3*rhoa3j*arg1i3 - a3a*rhoa3j*arg3i3 drho3ds2 = a3*rhoa3i*arg1j3 - a3a*rhoa3i*arg3j3 if (ialloy.eq.1) then a1i = 0.d0 a1j = 0.d0 a2i = 0.d0 a2j = 0.d0 a3i = 0.d0 a3j = 0.d0 if ( tsq_ave(1,i) .ne. 0.d0 ) then a1i = rhoa0j/tsq_ave(1,i) endif if ( tsq_ave(1,j) .ne. 0.d0 ) then a1j = rhoa0i/tsq_ave(1,j) endif if ( tsq_ave(2,i) .ne. 0.d0 ) then a2i = rhoa0j/tsq_ave(2,i) endif if ( tsq_ave(2,j) .ne. 0.d0 ) then a2j = rhoa0i/tsq_ave(2,j) endif if ( tsq_ave(3,i) .ne. 0.d0 ) then a3i = rhoa0j/tsq_ave(3,i) endif if ( tsq_ave(3,j) .ne. 0.d0 ) then a3j = rhoa0i/tsq_ave(3,j) endif dt1ds1 = a1i*(t1_meam(eltj)-t1i*t1_meam(eltj)**2) dt1ds2 = a1j*(t1_meam(elti)-t1j*t1_meam(elti)**2) dt2ds1 = a2i*(t2_meam(eltj)-t2i*t2_meam(eltj)**2) dt2ds2 = a2j*(t2_meam(elti)-t2j*t2_meam(elti)**2) dt3ds1 = a3i*(t3_meam(eltj)-t3i*t3_meam(eltj)**2) dt3ds2 = a3j*(t3_meam(elti)-t3j*t3_meam(elti)**2) else if (ialloy.eq.2) then dt1ds1 = 0.d0 dt1ds2 = 0.d0 dt2ds1 = 0.d0 dt2ds2 = 0.d0 dt3ds1 = 0.d0 dt3ds2 = 0.d0 else ai = 0.d0 if( rho0(i) .ne. 0.d0 ) then ai = rhoa0j/rho0(i) end if aj = 0.d0 if( rho0(j) .ne. 0.d0 ) then aj = rhoa0i/rho0(j) end if dt1ds1 = ai*(t1_meam(eltj)-t1i) dt1ds2 = aj*(t1_meam(elti)-t1j) dt2ds1 = ai*(t2_meam(eltj)-t2i) dt2ds2 = aj*(t2_meam(elti)-t2j) dt3ds1 = ai*(t3_meam(eltj)-t3i) dt3ds2 = aj*(t3_meam(elti)-t3j) endif drhods1 = dGamma1(i)*drho0ds1 $ + dGamma2(i)* $ (dt1ds1*rho1(i)+t1i*drho1ds1 $ + dt2ds1*rho2(i)+t2i*drho2ds1 $ + dt3ds1*rho3(i)+t3i*drho3ds1) $ - dGamma3(i)* $ (shpi(1)*dt1ds1+shpi(2)*dt2ds1+shpi(3)*dt3ds1) drhods2 = dGamma1(j)*drho0ds2 $ + dGamma2(j)* $ (dt1ds2*rho1(j)+t1j*drho1ds2 $ + dt2ds2*rho2(j)+t2j*drho2ds2 $ + dt3ds2*rho3(j)+t3j*drho3ds2) $ - dGamma3(j)* $ (shpj(1)*dt1ds2+shpj(2)*dt2ds2+shpj(3)*dt3ds2) endif c Compute derivatives of energy wrt rij, sij and rij(3) dUdrij = phip*sij $ + fp(i)*drhodr1 + fp(j)*drhodr2 dUdsij = 0.d0 if (dscrfcn(jn).ne.0.d0) then dUdsij = phi $ + fp(i)*drhods1 + fp(j)*drhods2 endif do m = 1,3 dUdrijm(m) = fp(i)*drhodrm1(m) + fp(j)*drhodrm2(m) enddo c Add the part of the force due to dUdrij and dUdsij force = dUdrij*recip + dUdsij*dscrfcn(jn) do m = 1,3 forcem = delij(m)*force + dUdrijm(m) f(m,i) = f(m,i) + forcem f(m,j) = f(m,j) - forcem enddo c Tabulate per-atom virial as symmetrized stress tensor if (vflag_atom.ne.0) then fi(1) = delij(1)*force + dUdrijm(1) fi(2) = delij(2)*force + dUdrijm(2) fi(3) = delij(3)*force + dUdrijm(3) v(1) = -0.5 * (delij(1) * fi(1)) v(2) = -0.5 * (delij(2) * fi(2)) v(3) = -0.5 * (delij(3) * fi(3)) v(4) = -0.25 * (delij(1)*fi(2) + delij(2)*fi(1)) v(5) = -0.25 * (delij(1)*fi(3) + delij(3)*fi(1)) v(6) = -0.25 * (delij(2)*fi(3) + delij(3)*fi(2)) vatom(1,i) = vatom(1,i) + v(1) vatom(2,i) = vatom(2,i) + v(2) vatom(3,i) = vatom(3,i) + v(3) vatom(4,i) = vatom(4,i) + v(4) vatom(5,i) = vatom(5,i) + v(5) vatom(6,i) = vatom(6,i) + v(6) vatom(1,j) = vatom(1,j) + v(1) vatom(2,j) = vatom(2,j) + v(2) vatom(3,j) = vatom(3,j) + v(3) vatom(4,j) = vatom(4,j) + v(4) vatom(5,j) = vatom(5,j) + v(5) vatom(6,j) = vatom(6,j) + v(6) endif c Now compute forces on other atoms k due to change in sij if (sij.eq.0.d0.or.sij.eq.1.d0) goto 100 do kn = 1,numneigh_full k = firstneigh_full(kn) eltk = fmap(type(k)) if (k.ne.j.and.eltk.gt.0) then call dsij(i,j,k,jn,nmax,numneigh,rij2,dsij1,dsij2, $ ntype,type,fmap,x,scrfcn,fcpair) if (dsij1.ne.0.d0.or.dsij2.ne.0.d0) then force1 = dUdsij*dsij1 force2 = dUdsij*dsij2 do m = 1,3 delik(m) = x(m,k) - x(m,i) deljk(m) = x(m,k) - x(m,j) enddo do m = 1,3 f(m,i) = f(m,i) + force1*delik(m) f(m,j) = f(m,j) + force2*deljk(m) f(m,k) = f(m,k) - force1*delik(m) $ - force2*deljk(m) enddo c Tabulate per-atom virial as symmetrized stress tensor if (vflag_atom.ne.0) then fi(1) = force1*delik(1) fi(2) = force1*delik(2) fi(3) = force1*delik(3) fj(1) = force2*deljk(1) fj(2) = force2*deljk(2) fj(3) = force2*deljk(3) v(1) = -third * (delik(1)*fi(1) + deljk(1)*fj(1)) v(2) = -third * (delik(2)*fi(2) + deljk(2)*fj(2)) v(3) = -third * (delik(3)*fi(3) + deljk(3)*fj(3)) v(4) = -sixth * (delik(1)*fi(2) + deljk(1)*fj(2) + $ delik(2)*fi(1) + deljk(2)*fj(1)) v(5) = -sixth * (delik(1)*fi(3) + deljk(1)*fj(3) + $ delik(3)*fi(1) + deljk(3)*fj(1)) v(6) = -sixth * (delik(2)*fi(3) + deljk(2)*fj(3) + $ delik(3)*fi(2) + deljk(3)*fj(2)) vatom(1,i) = vatom(1,i) + v(1) vatom(2,i) = vatom(2,i) + v(2) vatom(3,i) = vatom(3,i) + v(3) vatom(4,i) = vatom(4,i) + v(4) vatom(5,i) = vatom(5,i) + v(5) vatom(6,i) = vatom(6,i) + v(6) vatom(1,j) = vatom(1,j) + v(1) vatom(2,j) = vatom(2,j) + v(2) vatom(3,j) = vatom(3,j) + v(3) vatom(4,j) = vatom(4,j) + v(4) vatom(5,j) = vatom(5,j) + v(5) vatom(6,j) = vatom(6,j) + v(6) vatom(1,k) = vatom(1,k) + v(1) vatom(2,k) = vatom(2,k) + v(2) vatom(3,k) = vatom(3,k) + v(3) vatom(4,k) = vatom(4,k) + v(4) vatom(5,k) = vatom(5,k) + v(5) vatom(6,k) = vatom(6,k) + v(6) endif endif endif c end of k loop enddo endif 100 continue endif c end of j loop enddo c else if elti=0, this is not a meam atom endif return end
gpl-2.0
crtc-demos/gcc-ia16
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
crtc-demos/gcc-ia16
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
NCAR/icar
src/objects/boundary_h.f90
2
5168
module boundary_interface use icar_constants use options_interface, only : options_t use variable_dict_interface, only : var_dict_t use variable_interface, only : variable_t use meta_data_interface, only : meta_data_t use time_object, only : Time_type use time_delta_object, only : time_delta_t use data_structures, only : interpolable_type use icar_constants implicit none private public :: boundary_t ! ------------------------------------------------ ! boundary conditions type, must be linearizable so we can remove low res linear wind field ! ------------------------------------------------ type :: boundary_t type(meta_data_t) :: info ! list of input files character (len=kMAX_FILE_LENGTH), allocatable :: file_list(:) ! manage file pointer and position in file for boundary conditions integer :: curfile integer :: curstep type(Time_type) :: current_time ! the date/time of the forcing data in memory type(time_delta_t) :: forcing_dt ! the time step in between two forcing steps character(len=kMAX_STRING_LENGTH) :: time_var ! the name of the input time variable [optional] type(var_dict_t) :: variables ! a dictionary with all forcing data ! boundary data coordinate system real, dimension(:,:), allocatable :: lat, lon real, dimension(:,:,:), allocatable :: z type(interpolable_type) :: geo type(interpolable_type) :: geo_u type(interpolable_type) :: geo_v type(interpolable_type) :: original_geo contains procedure :: init procedure :: init_external procedure :: update_forcing procedure :: distribute_update procedure :: distribute_initial_conditions ! procedure :: find_start_time procedure :: init_local procedure :: init_local2 end type interface ! Set default component values module subroutine init(this, options) implicit none class(boundary_t), intent(inout) :: this type(options_t), intent(inout) :: options end subroutine module subroutine init_external(this, options) implicit none class(boundary_t), intent(inout) :: this type(options_t), intent(inout) :: options end subroutine module subroutine init_local2(this, options, file_list, var_list, dim_list, start_time, & lat_ext, lon_ext, zvar_ext, time_ext) !, p_var, ps_var) implicit none class(boundary_t), intent(inout) :: this type(options_t), intent(inout) :: options character(len=kMAX_NAME_LENGTH), intent(in) :: file_list(:) character(len=kMAX_NAME_LENGTH), intent(in) :: var_list (:) integer, intent(in) :: dim_list (:) type(Time_type), intent(in), optional :: start_time character(len=kMAX_NAME_LENGTH), intent(in) :: lat_ext character(len=kMAX_NAME_LENGTH), intent(in) :: lon_ext character(len=kMAX_NAME_LENGTH), intent(in), optional :: zvar_ext character(len=kMAX_NAME_LENGTH), intent(in), optional :: time_ext ! character(len=kMAX_NAME_LENGTH), intent(in) :: p_var ! character(len=kMAX_NAME_LENGTH), intent(in) :: ps_var end subroutine module subroutine init_local(this, options, file_list, var_list, dim_list, start_time, & lat_var, lon_var, z_var, time_var, p_var, ps_var) implicit none class(boundary_t), intent(inout) :: this type(options_t), intent(inout) :: options character(len=kMAX_NAME_LENGTH), intent(in) :: file_list(:) character(len=kMAX_NAME_LENGTH), intent(in) :: var_list (:) integer, intent(in) :: dim_list (:) type(Time_type), intent(in) :: start_time character(len=kMAX_NAME_LENGTH), intent(in) :: lat_var character(len=kMAX_NAME_LENGTH), intent(in) :: lon_var character(len=kMAX_NAME_LENGTH), intent(in) :: z_var character(len=kMAX_NAME_LENGTH), intent(in) :: time_var character(len=kMAX_NAME_LENGTH), intent(in) :: p_var character(len=kMAX_NAME_LENGTH), intent(in) :: ps_var end subroutine module subroutine update_forcing(this, options) implicit none class(boundary_t), intent(inout) :: this type(options_t), intent(inout) :: options end subroutine module subroutine distribute_update(this) implicit none class(boundary_t), intent(inout) :: this end subroutine module subroutine distribute_initial_conditions(this) implicit none class(boundary_t), intent(inout) :: this end subroutine end interface end module
mit
Alexpux/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
crtc-demos/gcc-ia16
gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_mmval.f90
190
1175
! Program to test the MINVAL and MAXVAL intrinsics program testmmval implicit none integer, dimension (3, 3) :: a integer, dimension (3) :: b logical, dimension (3, 3) :: m, tr integer i character (len=9) line a = reshape ((/1, 2, 3, 5, 4, 6, 9, 8, 7/), (/3, 3/)); tr = .true. b = minval (a, 1) if (any(b .ne. (/1, 4, 7/))) call abort write (line, 9000) minval (a, 1) if (line .ne. ' 1 4 7') call abort m = .true. m(1, 1) = .false. m(1, 2) = .false. b = minval (a, 1, m) if (any(b .ne. (/2, 4, 7/))) call abort b = minval (a, 1, m .and. tr) if (any(b .ne. (/2, 4, 7/))) call abort write (line, 9000) minval(a, 1, m) if (line .ne. ' 2 4 7') call abort b = maxval (a, 1) if (any(b .ne. (/3, 6, 9/))) call abort write (line, 9000) maxval (a, 1) if (line .ne. ' 3 6 9') call abort m = .true. m(1, 2) = .false. m(1, 3) = .false. b = maxval (a, 1, m) if (any(b .ne. (/3, 6, 8/))) call abort b = maxval (a, 1, m .and. tr) if (any(b .ne. (/3, 6, 8/))) call abort write (line, 9000) maxval(a, 1, m) if (line .ne. ' 3 6 8') call abort 9000 format(3I3) end program
gpl-2.0
timj/starlink-pyndf
hds/cmp_len.f
1
2127
subroutine cmp_len(struct, comp, len, status) *+ * Name: * CMP_LEN * Purpose: * Component String Precision enquiry. * Language: * VAX Fortran * Invocation: * CALL CMP_LEN(LOC, NAME, LEN, STATUS) * Description: * A string precision enquiry is made for a structure component * of type '_CHAR*LEN'. * Arguments: * LOC=CHARACTER*(DAT__SZLOC) * Variable containing a locator associated with a structured * data object. * NAME=CHARACTER*(*) * Expression specifying the component name of a primitive * object contained in the structure. * LEN=INTEGER * Variable to receive number of characters per value. * STATUS=INTEGER * Variable holding the status value. If this variable is not * SAI__OK on input, the routine will return without action. * If the routine fails to complete, this variable will be * set to an appropriate error number. * Algorithm: * Get object locator using DAT_FIND and then get size from * DAT_LEN. * Authors: * Jack Giddings (UCL::JRG) * {enter_new_authors_here} * History: * 3-JAN-1983: Original. (UCL::JRG) * 15-APR-1987: Improved prologue layout (RAL::AJC) * {enter_further_changes_here} * Bugs: * {note_any_bugs_here} *- * Global Constants: INCLUDE 'SAE_PAR' INCLUDE 'DAT_PAR' * Arguments Given: character*(*) struct ! Structure Locator character*(*) comp ! Component Name * Arguments Returned: integer len ! String precision of component * Status return : integer status ! Status Return * Local Variables: character*(DAT__SZLOC) loc ! Component locator *. if (status .eq. SAI__OK) then call dat_find(struct, comp, loc, status) if (status .ne. SAI__OK) then call cmp_erdsn(struct, comp, status) else call dat_len(loc, len, status) if (status .ne. SAI__OK) then call cmp_erdsn(struct, comp, status) endif call dat_annul(loc, status) endif endif end
gpl-3.0
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/complex_intrinsic_5.f90
136
14154
! { dg-do run } ! ! PR fortran/33197 ! ! Complex inverse trigonometric functions ! and complex inverse hyperbolic functions ! ! Run-time evaluation check ! module test implicit none real(4), parameter :: eps4 = epsilon(0.0_4)*4.0_4 real(8), parameter :: eps8 = epsilon(0.0_8)*2.0_8 interface check procedure check4, check8 end interface check contains SUBROUTINE check4(z, zref) complex(4), intent(in) :: z, zref if ( abs (real(z)-real(zref)) > eps4 & .or.abs (aimag(z)-aimag(zref)) > eps4) then print '(a,/,2((2g0," + I ",g0),/))', "check4:"," z=",z,'zref=',zref print '(a,g0," + I*",g0," eps=",g0)', 'Diff: ', & real(z)-real(zref), & aimag(z)-aimag(zref), eps4 call abort() end if END SUBROUTINE check4 SUBROUTINE check8(z, zref) complex(8), intent(in) :: z, zref if ( abs (real(z)-real(zref)) > eps8 & .or.abs (aimag(z)-aimag(zref)) > eps8) then print '(a,/,2((2g0," + I ",g0),/))', "check8:"," z=",z,'zref=',zref print '(a,g0," + I*",g0," eps=",g0)', 'Diff: ', & real(z)-real(zref), & aimag(z)-aimag(zref), eps8 call abort() end if END SUBROUTINE check8 end module test PROGRAM ArcTrigHyp use test IMPLICIT NONE complex(4), volatile :: z4 complex(8), volatile :: z8 !!!!! ZERO !!!!!! ! z = 0 z4 = cmplx(0.0_4, 0.0_4, kind=4) z8 = cmplx(0.0_8, 0.0_8, kind=8) ! Exact: 0 call check(asin(z4), cmplx(0.0_4, 0.0_4, kind=4)) call check(asin(z8), cmplx(0.0_8, 0.0_8, kind=8)) ! Exact: Pi/2 = 1.5707963267948966192313216916397514 call check(acos(z4), cmplx(1.57079632679489661920_4, 0.0_4, kind=4)) call check(acos(z8), cmplx(1.57079632679489661920_8, 0.0_8, kind=8)) ! Exact: 0 call check(atan(z4), cmplx(0.0_4, 0.0_4, kind=4)) call check(atan(z8), cmplx(0.0_8, 0.0_8, kind=8)) ! Exact: 0 call check(asinh(z4), cmplx(0.0_4, 0.0_4, kind=4)) call check(asinh(z8), cmplx(0.0_8, 0.0_8, kind=8)) ! Exact: I*Pi/2 = I*1.5707963267948966192313216916397514 call check(acosh(z4), cmplx(0.0_4, 1.57079632679489661920_4, kind=4)) call check(acosh(z8), cmplx(0.0_8, 1.57079632679489661920_8, kind=8)) ! Exact: 0 call check(atanh(z4), cmplx(0.0_4, 0.0_4, kind=4)) call check(atanh(z8), cmplx(0.0_8, 0.0_8, kind=8)) !!!!! POSITIVE NUMBERS !!!!!! ! z = tanh(1.0) z4 = cmplx(0.76159415595576488811945828260479359_4, 0.0_4, kind=4) z8 = cmplx(0.76159415595576488811945828260479359_8, 0.0_8, kind=8) ! Numerically: 0.86576948323965862428960184619184444 call check(asin(z4), cmplx(0.86576948323965862428960184619184444_4, 0.0_4, kind=4)) call check(asin(z8), cmplx(0.86576948323965862428960184619184444_8, 0.0_8, kind=8)) ! Numerically: 0.70502684355523799494171984544790700 call check(acos(z4), cmplx(0.70502684355523799494171984544790700_4, 0.0_4, kind=4)) call check(acos(z8), cmplx(0.70502684355523799494171984544790700_8, 0.0_8, kind=8)) ! Numerically: 0.65088016802300754993807813168285564 call check(atan(z4), cmplx(0.65088016802300754993807813168285564_4, 0.0_4, kind=4)) call check(atan(z8), cmplx(0.65088016802300754993807813168285564_8, 0.0_8, kind=8)) ! Numerically: 0.70239670712987482778422106260749699 call check(asinh(z4), cmplx(0.70239670712987482778422106260749699_4, 0.0_4, kind=4)) call check(asinh(z8), cmplx(0.70239670712987482778422106260749699_8, 0.0_8, kind=8)) ! Numerically: 0.70502684355523799494171984544790700*I call check(acosh(z4), cmplx(0.0_4, 0.70502684355523799494171984544790700_4, kind=4)) call check(acosh(z8), cmplx(0.0_8, 0.70502684355523799494171984544790700_8, kind=8)) ! Exact: 1 call check(atanh(z4), cmplx(1.0_4, 0.0_4, kind=4)) call check(atanh(z8), cmplx(1.0_8, 0.0_8, kind=8)) ! z = I*tanh(1.0) z4 = cmplx(0.0_4, 0.76159415595576488811945828260479359_4, kind=4) z8 = cmplx(0.0_8, 0.76159415595576488811945828260479359_8, kind=8) ! Numerically: I*0.70239670712987482778422106260749699 call check(asin(z4), cmplx(0.0_4, 0.70239670712987482778422106260749699_4, kind=4)) call check(asin(z8), cmplx(0.0_8, 0.70239670712987482778422106260749699_8, kind=8)) ! Numerically: 1.5707963267948966192313216916397514 - I*0.7023967071298748277842210626074970 call check(acos(z4), cmplx(1.5707963267948966192313216916397514_4, -0.7023967071298748277842210626074970_4, kind=4)) call check(acos(z8), cmplx(1.5707963267948966192313216916397514_8, -0.7023967071298748277842210626074970_8, kind=8)) ! Exact: I*1 call check(atan(z4), cmplx(0.0_4, 1.0_4, kind=4)) call check(atan(z8), cmplx(0.0_8, 1.0_8, kind=8)) ! Numerically: I*0.86576948323965862428960184619184444 call check(asinh(z4), cmplx(0.0_4, 0.86576948323965862428960184619184444_4, kind=4)) call check(asinh(z8), cmplx(0.0_8, 0.86576948323965862428960184619184444_8, kind=8)) ! Numerically: 0.7023967071298748277842210626074970 + I*1.5707963267948966192313216916397514 call check(acosh(z4), cmplx(0.7023967071298748277842210626074970_4, 1.5707963267948966192313216916397514_4, kind=4)) call check(acosh(z8), cmplx(0.7023967071298748277842210626074970_8, 1.5707963267948966192313216916397514_8, kind=8)) ! Numerically: I*0.65088016802300754993807813168285564 call check(atanh(z4), cmplx(0.0_4, 0.65088016802300754993807813168285564_4, kind=4)) call check(atanh(z8), cmplx(0.0_8, 0.65088016802300754993807813168285564_8, kind=8)) ! z = (1+I)*tanh(1.0) z4 = cmplx(0.76159415595576488811945828260479359_4, 0.76159415595576488811945828260479359_4, kind=4) z8 = cmplx(0.76159415595576488811945828260479359_8, 0.76159415595576488811945828260479359_8, kind=8) ! Numerically: 0.59507386031622633330574869409179139 + I*0.82342412550090412964986631390412834 call check(asin(z4), cmplx(0.59507386031622633330574869409179139_4, 0.82342412550090412964986631390412834_4, kind=4)) call check(asin(z8), cmplx(0.59507386031622633330574869409179139_8, 0.82342412550090412964986631390412834_8, kind=8)) ! Numerically: 0.97572246647867028592557299754796005 - I*0.82342412550090412964986631390412834 call check(acos(z4), cmplx(0.97572246647867028592557299754796005_4, -0.82342412550090412964986631390412834_4, kind=4)) call check(acos(z8), cmplx(0.97572246647867028592557299754796005_8, -0.82342412550090412964986631390412834_8, kind=8)) ! Numerically: 0.83774433133636226305479129936568267 + I*0.43874835208710654149508159123595167 call check(atan(z4), cmplx(0.83774433133636226305479129936568267_4, 0.43874835208710654149508159123595167_4, kind=4)) call check(atan(z8), cmplx(0.83774433133636226305479129936568267_8, 0.43874835208710654149508159123595167_8, kind=8)) ! Numerically: 0.82342412550090412964986631390412834 + I*0.59507386031622633330574869409179139 call check(asinh(z4), cmplx(0.82342412550090412964986631390412834_4, 0.59507386031622633330574869409179139_4, kind=4)) call check(asinh(z8), cmplx(0.82342412550090412964986631390412834_8, 0.59507386031622633330574869409179139_8, kind=8)) ! Numerically: 0.82342412550090412964986631390412834 + I*0.97572246647867028592557299754796005 call check(acosh(z4), cmplx(0.82342412550090412964986631390412834_4, 0.97572246647867028592557299754796005_4, kind=4)) call check(acosh(z8), cmplx(0.82342412550090412964986631390412834_8, 0.97572246647867028592557299754796005_8, kind=8)) ! Numerically: 0.43874835208710654149508159123595167 + I*0.83774433133636226305479129936568267 call check(atanh(z4), cmplx(0.43874835208710654149508159123595167_4, 0.83774433133636226305479129936568267_4, kind=4)) call check(atanh(z8), cmplx(0.43874835208710654149508159123595167_8, 0.83774433133636226305479129936568267_8, kind=8)) ! z = 1+I z4 = cmplx(1.0_4, 1.0_4, kind=4) z8 = cmplx(1.0_8, 1.0_8, kind=8) ! Numerically: 0.66623943249251525510400489597779272 + I*1.06127506190503565203301891621357349 call check(asin(z4), cmplx(0.66623943249251525510400489597779272_4, 1.06127506190503565203301891621357349_4, kind=4)) call check(asin(z8), cmplx(0.66623943249251525510400489597779272_8, 1.06127506190503565203301891621357349_8, kind=8)) ! Numerically: 0.90455689430238136412731679566195872 - I*1.06127506190503565203301891621357349 call check(acos(z4), cmplx(0.90455689430238136412731679566195872_4, -1.06127506190503565203301891621357349_4, kind=4)) call check(acos(z8), cmplx(0.90455689430238136412731679566195872_8, -1.06127506190503565203301891621357349_8, kind=8)) ! Numerically: 1.01722196789785136772278896155048292 + I*0.40235947810852509365018983330654691 call check(atan(z4), cmplx(1.01722196789785136772278896155048292_4, 0.40235947810852509365018983330654691_4, kind=4)) call check(atan(z8), cmplx(1.01722196789785136772278896155048292_8, 0.40235947810852509365018983330654691_8, kind=8)) ! Numerically: 1.06127506190503565203301891621357349 + I*0.66623943249251525510400489597779272 call check(asinh(z4), cmplx(1.06127506190503565203301891621357349_4, 0.66623943249251525510400489597779272_4, kind=4)) call check(asinh(z8), cmplx(1.06127506190503565203301891621357349_8, 0.66623943249251525510400489597779272_8, kind=8)) ! Numerically: 1.06127506190503565203301891621357349 + I*0.90455689430238136412731679566195872 call check(acosh(z4), cmplx(1.06127506190503565203301891621357349_4, 0.90455689430238136412731679566195872_4, kind=4)) call check(acosh(z8), cmplx(1.06127506190503565203301891621357349_8, 0.90455689430238136412731679566195872_8, kind=8)) ! Numerically: 0.40235947810852509365018983330654691 + I*1.01722196789785136772278896155048292 call check(atanh(z4), cmplx(0.40235947810852509365018983330654691_4, 1.01722196789785136772278896155048292_4, kind=4)) call check(atanh(z8), cmplx(0.40235947810852509365018983330654691_8, 1.01722196789785136772278896155048292_8, kind=8)) ! z = (1+I)*1.1 z4 = cmplx(1.1_4, 1.1_4, kind=4) z8 = cmplx(1.1_8, 1.1_8, kind=8) ! Numerically: 0.68549840630267734494444454677951503 + I*1.15012680127435581678415521738176733 call check(asin(z4), cmplx(0.68549840630267734494444454677951503_4, 1.15012680127435581678415521738176733_4, kind=4)) call check(asin(z8), cmplx(0.68549840630267734494444454677951503_8, 1.15012680127435581678415521738176733_8, kind=8)) ! Numerically: 0.8852979204922192742868771448602364 - I*1.1501268012743558167841552173817673 call check(acos(z4), cmplx(0.8852979204922192742868771448602364_4, -1.1501268012743558167841552173817673_4, kind=4)) call check(acos(z8), cmplx(0.8852979204922192742868771448602364_8, -1.1501268012743558167841552173817673_8, kind=8)) ! Numerically: 1.07198475450905931839240655913126728 + I*0.38187020129010862908881230531688930 call check(atan(z4), cmplx(1.07198475450905931839240655913126728_4, 0.38187020129010862908881230531688930_4, kind=4)) call check(atan(z8), cmplx(1.07198475450905931839240655913126728_8, 0.38187020129010862908881230531688930_8, kind=8)) ! Numerically: 1.15012680127435581678415521738176733 + I*0.68549840630267734494444454677951503 call check(asinh(z4), cmplx(1.15012680127435581678415521738176733_4, 0.68549840630267734494444454677951503_4, kind=4)) call check(asinh(z8), cmplx(1.15012680127435581678415521738176733_8, 0.68549840630267734494444454677951503_8, kind=8)) ! Numerically: 1.1501268012743558167841552173817673 + I*0.8852979204922192742868771448602364 call check(acosh(z4), cmplx(1.1501268012743558167841552173817673_4, 0.8852979204922192742868771448602364_4, kind=4)) call check(acosh(z8), cmplx(1.1501268012743558167841552173817673_8, 0.8852979204922192742868771448602364_8, kind=8)) ! Numerically: 0.38187020129010862908881230531688930 + I*1.07198475450905931839240655913126728 call check(atanh(z4), cmplx(0.38187020129010862908881230531688930_4, 1.07198475450905931839240655913126728_4, kind=4)) call check(atanh(z8), cmplx(0.38187020129010862908881230531688930_8, 1.07198475450905931839240655913126728_8, kind=8)) !!!!! Negative NUMBERS !!!!!! ! z = -(1+I)*1.1 z4 = cmplx(-1.1_4, -1.1_4, kind=4) z8 = cmplx(-1.1_8, -1.1_8, kind=8) ! Numerically: -0.68549840630267734494444454677951503 - I*1.15012680127435581678415521738176733 call check(asin(z4), cmplx(-0.68549840630267734494444454677951503_4, -1.15012680127435581678415521738176733_4, kind=4)) call check(asin(z8), cmplx(-0.68549840630267734494444454677951503_8, -1.15012680127435581678415521738176733_8, kind=8)) ! Numerically: 2.2562947330975739641757662384192665 + I*1.1501268012743558167841552173817673 call check(acos(z4), cmplx(2.2562947330975739641757662384192665_4, 1.1501268012743558167841552173817673_4, kind=4)) call check(acos(z8), cmplx(2.2562947330975739641757662384192665_8, 1.1501268012743558167841552173817673_8, kind=8)) ! Numerically: -1.07198475450905931839240655913126728 - I*0.38187020129010862908881230531688930 call check(atan(z4), cmplx(-1.07198475450905931839240655913126728_4, -0.38187020129010862908881230531688930_4, kind=4)) call check(atan(z8), cmplx(-1.07198475450905931839240655913126728_8, -0.38187020129010862908881230531688930_8, kind=8)) ! Numerically: -1.15012680127435581678415521738176733 - I*0.68549840630267734494444454677951503 call check(asinh(z4), cmplx(-1.15012680127435581678415521738176733_4, -0.68549840630267734494444454677951503_4, kind=4)) call check(asinh(z8), cmplx(-1.15012680127435581678415521738176733_8, -0.68549840630267734494444454677951503_8, kind=8)) ! Numerically: 1.1501268012743558167841552173817673 - I*2.2562947330975739641757662384192665 call check(acosh(z4), cmplx(1.1501268012743558167841552173817673_4, -2.2562947330975739641757662384192665_4, kind=4)) call check(acosh(z8), cmplx(1.1501268012743558167841552173817673_8, -2.2562947330975739641757662384192665_8, kind=8)) ! Numerically: 0.38187020129010862908881230531688930 + I*1.07198475450905931839240655913126728 call check(atanh(z4), cmplx(-0.38187020129010862908881230531688930_4, -1.07198475450905931839240655913126728_4, kind=4)) call check(atanh(z8), cmplx(-0.38187020129010862908881230531688930_8, -1.07198475450905931839240655913126728_8, kind=8)) END PROGRAM ArcTrigHyp
gpl-2.0
ovilab/atomify-lammps
libs/lammps/lib/linalg/dsymv.f
57
9413
*> \brief \b DSYMV * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * SUBROUTINE DSYMV(UPLO,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY) * * .. Scalar Arguments .. * DOUBLE PRECISION ALPHA,BETA * INTEGER INCX,INCY,LDA,N * CHARACTER UPLO * .. * .. Array Arguments .. * DOUBLE PRECISION A(LDA,*),X(*),Y(*) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> DSYMV performs the matrix-vector operation *> *> y := alpha*A*x + beta*y, *> *> where alpha and beta are scalars, x and y are n element vectors and *> A is an n by n symmetric matrix. *> \endverbatim * * Arguments: * ========== * *> \param[in] UPLO *> \verbatim *> UPLO is CHARACTER*1 *> On entry, UPLO specifies whether the upper or lower *> triangular part of the array A is to be referenced as *> follows: *> *> UPLO = 'U' or 'u' Only the upper triangular part of A *> is to be referenced. *> *> UPLO = 'L' or 'l' Only the lower triangular part of A *> is to be referenced. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> On entry, N specifies the order of the matrix A. *> N must be at least zero. *> \endverbatim *> *> \param[in] ALPHA *> \verbatim *> ALPHA is DOUBLE PRECISION. *> On entry, ALPHA specifies the scalar alpha. *> \endverbatim *> *> \param[in] A *> \verbatim *> A is DOUBLE PRECISION array of DIMENSION ( LDA, n ). *> Before entry with UPLO = 'U' or 'u', the leading n by n *> upper triangular part of the array A must contain the upper *> triangular part of the symmetric matrix and the strictly *> lower triangular part of A is not referenced. *> Before entry with UPLO = 'L' or 'l', the leading n by n *> lower triangular part of the array A must contain the lower *> triangular part of the symmetric matrix and the strictly *> upper triangular part of A is not referenced. *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> On entry, LDA specifies the first dimension of A as declared *> in the calling (sub) program. LDA must be at least *> max( 1, n ). *> \endverbatim *> *> \param[in] X *> \verbatim *> X is DOUBLE PRECISION array of dimension at least *> ( 1 + ( n - 1 )*abs( INCX ) ). *> Before entry, the incremented array X must contain the n *> element vector x. *> \endverbatim *> *> \param[in] INCX *> \verbatim *> INCX is INTEGER *> On entry, INCX specifies the increment for the elements of *> X. INCX must not be zero. *> \endverbatim *> *> \param[in] BETA *> \verbatim *> BETA is DOUBLE PRECISION. *> On entry, BETA specifies the scalar beta. When BETA is *> supplied as zero then Y need not be set on input. *> \endverbatim *> *> \param[in,out] Y *> \verbatim *> Y is DOUBLE PRECISION array of dimension at least *> ( 1 + ( n - 1 )*abs( INCY ) ). *> Before entry, the incremented array Y must contain the n *> element vector y. On exit, Y is overwritten by the updated *> vector y. *> \endverbatim *> *> \param[in] INCY *> \verbatim *> INCY is INTEGER *> On entry, INCY specifies the increment for the elements of *> Y. INCY must not be zero. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \date November 2011 * *> \ingroup double_blas_level2 * *> \par Further Details: * ===================== *> *> \verbatim *> *> Level 2 Blas routine. *> The vector and matrix arguments are not referenced when N = 0, or M = 0 *> *> -- Written on 22-October-1986. *> Jack Dongarra, Argonne National Lab. *> Jeremy Du Croz, Nag Central Office. *> Sven Hammarling, Nag Central Office. *> Richard Hanson, Sandia National Labs. *> \endverbatim *> * ===================================================================== SUBROUTINE DSYMV(UPLO,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY) * * -- Reference BLAS level2 routine (version 3.4.0) -- * -- Reference BLAS is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2011 * * .. Scalar Arguments .. DOUBLE PRECISION ALPHA,BETA INTEGER INCX,INCY,LDA,N CHARACTER UPLO * .. * .. Array Arguments .. DOUBLE PRECISION A(LDA,*),X(*),Y(*) * .. * * ===================================================================== * * .. Parameters .. DOUBLE PRECISION ONE,ZERO PARAMETER (ONE=1.0D+0,ZERO=0.0D+0) * .. * .. Local Scalars .. DOUBLE PRECISION TEMP1,TEMP2 INTEGER I,INFO,IX,IY,J,JX,JY,KX,KY * .. * .. External Functions .. LOGICAL LSAME EXTERNAL LSAME * .. * .. External Subroutines .. EXTERNAL XERBLA * .. * .. Intrinsic Functions .. INTRINSIC MAX * .. * * Test the input parameters. * INFO = 0 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN INFO = 1 ELSE IF (N.LT.0) THEN INFO = 2 ELSE IF (LDA.LT.MAX(1,N)) THEN INFO = 5 ELSE IF (INCX.EQ.0) THEN INFO = 7 ELSE IF (INCY.EQ.0) THEN INFO = 10 END IF IF (INFO.NE.0) THEN CALL XERBLA('DSYMV ',INFO) RETURN END IF * * Quick return if possible. * IF ((N.EQ.0) .OR. ((ALPHA.EQ.ZERO).AND. (BETA.EQ.ONE))) RETURN * * Set up the start points in X and Y. * IF (INCX.GT.0) THEN KX = 1 ELSE KX = 1 - (N-1)*INCX END IF IF (INCY.GT.0) THEN KY = 1 ELSE KY = 1 - (N-1)*INCY END IF * * Start the operations. In this version the elements of A are * accessed sequentially with one pass through the triangular part * of A. * * First form y := beta*y. * IF (BETA.NE.ONE) THEN IF (INCY.EQ.1) THEN IF (BETA.EQ.ZERO) THEN DO 10 I = 1,N Y(I) = ZERO 10 CONTINUE ELSE DO 20 I = 1,N Y(I) = BETA*Y(I) 20 CONTINUE END IF ELSE IY = KY IF (BETA.EQ.ZERO) THEN DO 30 I = 1,N Y(IY) = ZERO IY = IY + INCY 30 CONTINUE ELSE DO 40 I = 1,N Y(IY) = BETA*Y(IY) IY = IY + INCY 40 CONTINUE END IF END IF END IF IF (ALPHA.EQ.ZERO) RETURN IF (LSAME(UPLO,'U')) THEN * * Form y when A is stored in upper triangle. * IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN DO 60 J = 1,N TEMP1 = ALPHA*X(J) TEMP2 = ZERO DO 50 I = 1,J - 1 Y(I) = Y(I) + TEMP1*A(I,J) TEMP2 = TEMP2 + A(I,J)*X(I) 50 CONTINUE Y(J) = Y(J) + TEMP1*A(J,J) + ALPHA*TEMP2 60 CONTINUE ELSE JX = KX JY = KY DO 80 J = 1,N TEMP1 = ALPHA*X(JX) TEMP2 = ZERO IX = KX IY = KY DO 70 I = 1,J - 1 Y(IY) = Y(IY) + TEMP1*A(I,J) TEMP2 = TEMP2 + A(I,J)*X(IX) IX = IX + INCX IY = IY + INCY 70 CONTINUE Y(JY) = Y(JY) + TEMP1*A(J,J) + ALPHA*TEMP2 JX = JX + INCX JY = JY + INCY 80 CONTINUE END IF ELSE * * Form y when A is stored in lower triangle. * IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN DO 100 J = 1,N TEMP1 = ALPHA*X(J) TEMP2 = ZERO Y(J) = Y(J) + TEMP1*A(J,J) DO 90 I = J + 1,N Y(I) = Y(I) + TEMP1*A(I,J) TEMP2 = TEMP2 + A(I,J)*X(I) 90 CONTINUE Y(J) = Y(J) + ALPHA*TEMP2 100 CONTINUE ELSE JX = KX JY = KY DO 120 J = 1,N TEMP1 = ALPHA*X(JX) TEMP2 = ZERO Y(JY) = Y(JY) + TEMP1*A(J,J) IX = JX IY = JY DO 110 I = J + 1,N IX = IX + INCX IY = IY + INCY Y(IY) = Y(IY) + TEMP1*A(I,J) TEMP2 = TEMP2 + A(I,J)*X(IX) 110 CONTINUE Y(JY) = Y(JY) + ALPHA*TEMP2 JX = JX + INCX JY = JY + INCY 120 CONTINUE END IF END IF * RETURN * * End of DSYMV . * END
gpl-3.0
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/bind_c_dts.f90
155
1235
! { dg-do run } ! { dg-additional-sources bind_c_dts_driver.c } module bind_c_dts use, intrinsic :: iso_c_binding implicit none type, bind(c) :: MYFTYPE_1 integer(c_int) :: i, j real(c_float) :: s end type MYFTYPE_1 TYPE, BIND(C) :: particle REAL(C_DOUBLE) :: x,vx REAL(C_DOUBLE) :: y,vy REAL(C_DOUBLE) :: z,vz REAL(C_DOUBLE) :: m END TYPE particle type(myftype_1), bind(c, name="myDerived") :: myDerived contains subroutine types_test(my_particles, num_particles) bind(c) integer(c_int), value :: num_particles type(particle), dimension(num_particles) :: my_particles integer :: i ! going to set the particle in the middle of the list i = num_particles / 2; my_particles(i)%x = my_particles(i)%x + .2d0 my_particles(i)%vx = my_particles(i)%vx + .2d0 my_particles(i)%y = my_particles(i)%y + .2d0 my_particles(i)%vy = my_particles(i)%vy + .2d0 my_particles(i)%z = my_particles(i)%z + .2d0 my_particles(i)%vz = my_particles(i)%vz + .2d0 my_particles(i)%m = my_particles(i)%m + .2d0 myDerived%i = myDerived%i + 1 myDerived%j = myDerived%j + 1 myDerived%s = myDerived%s + 1.0; end subroutine types_test end module bind_c_dts
gpl-2.0
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/function_types_2.f90
155
1574
! { dg-do compile } ! Tests the fix for PR34431 in which function TYPEs that were ! USE associated would cause an error. ! ! Contributed by Tobias Burnus <burnus@gcc.gnu.org> ! module m1 integer :: hh type t real :: r end type t end module m1 module m2 type t integer :: k end type t end module m2 module m3 contains type(t) function func() use m2 func%k = 77 end function func end module m3 type(t) function a() use m1, only: hh type t2 integer :: j end type t2 type t logical :: b end type t a%b = .true. end function a type(t) function b() use m1, only: hh use m2 use m3 b = func () b%k = 5 end function b type(t) function c() use m1, only: hh type t2 integer :: j end type t2 type t logical :: b end type t c%b = .true. end function c program main type t integer :: m end type t contains type(t) function a1() use m1, only: hh type t2 integer :: j end type t2 type t logical :: b end type t a1%b = .true. end function a1 type(t) function b1() use m1, only: hh use m2, only: t ! NAG f95 believes that the host-associated type(t) ! should be used: ! b1%m = 5 ! However, I (Tobias Burnus) believe that the use-associated one should ! be used: b1%k = 5 end function b1 type(t) function c1() use m1, only: hh type t2 integer :: j end type t2 type t logical :: b end type t c1%b = .true. end function c1 type(t) function d1() d1%m = 55 end function d1 end program main
gpl-2.0
Hellybean/SaberMod_ROM_Toolchain
gcc/testsuite/gfortran.dg/mvbits_4.f90
174
1031
! { dg-do run } ! PR fortran/35681 ! Check that dependencies of MVBITS arguments are resolved correctly by using ! temporaries if both arguments refer to the same variable. integer, dimension(10) :: ila1 = (/1,2,3,4,5,6,7,8,9,10/) integer, dimension(20) :: ila2 integer, dimension(10), target :: ila3 integer, pointer :: ila3_ptr(:) integer, parameter :: SHOULD_BE(10) = (/17,18,11,4,13,22,7,16,9,18/) integer, parameter :: INDEX_VECTOR(10) = (/9,9,6,2,4,9,2,9,6,10/) ila2(2:20:2) = ila1 ila3 = ila1 ! Argument is already packed. call mvbits (ila1(INDEX_VECTOR), 2, 4, ila1, 3) write (*,'(10(I3))') ila1 if (any (ila1 /= SHOULD_BE)) call abort () ! Argument is not packed. call mvbits (ila2(2*INDEX_VECTOR), 2, 4, ila2(2:20:2), 3) write (*,'(10(I3))') ila2(2:20:2) if (any (ila2(2:20:2) /= SHOULD_BE)) call abort () ! Pointer and target ila3_ptr => ila3 call mvbits (ila3(INDEX_VECTOR), 2, 4, ila3_ptr, 3) write (*,'(10(I3))') ila3 if (any (ila3 /= SHOULD_BE)) call abort () end
gpl-2.0
intervigilium/cs259-or32-gcc
gcc/testsuite/gfortran.dg/stfunc_6.f90
94
1028
! { dg-do compile } ! { dg-options "-std=legacy" } ! ! Tests the fix for the second bit of PR29389, in which the ! statement function would not be recognised as not PURE ! when it referenced a procedure that is not PURE. ! ! This is based on stfunc_4.f90 with the statement function made ! impure by a reference to 'v'. ! ! Contributed by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> INTEGER :: st1, i = 99, a(4), q = 6 st1 (i) = i * i * i st3 (i) = i * v(i) FORALL(i=1:4) a(i) = st1 (i) FORALL(i=1:4) a(i) = u (a(i)) - a(i)** 2 if (any (a .ne. 0)) call abort () if (i .ne. 99) call abort () FORALL (i=1:4) a(i) = st3 (i) ! { dg-error "non-PURE function" "non-PURE reference in FORALL" { xfail *-*-*} } FORALL (i=1:4) a(i) = v(i) ! { dg-error "non-PURE function" } contains pure integer function u (x) integer,intent(in) :: x st2 (i) = i * v(i) ! { dg-error "non-PURE procedure" } u = st2(x) end function integer function v (x) integer,intent(in) :: x v = i end function end
gpl-2.0
ovilab/atomify-lammps
libs/lammps/tools/eam_database/create.f
46
8594
C author: X. W. Zhou, xzhou@sandia.gov c open(unit=5,file='a.i') call inter c close(5) call writeset stop end ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c main subroutine. c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc subroutine inter character*80 atomtype,atommatch,outfile,outelem namelist /funccard/ atomtype common /pass1/ re(16),fe(16),rhoe(16),alpha(16), * beta(16),beta1(16),A(16),B(16),cai(16),ramda(16), * ramda1(16),Fi0(16),Fi1(16),Fi2(16),Fi3(16), * Fm0(16),Fm1(16),Fm2(16),Fm3(16),Fm4(16), * fnn(16),Fn(16),rhoin(16),rhoout(16),rhol(16), * rhoh(16),rhos(16) common /pass2/ ielement(16),amass(16),Fr(5000,16), * rhor(5000,16),z2r(5000,16,16),ntypes,blat(16), * nrho,drho,nr,dr,rc,outfile,outelem ntypes=0 10 continue atomtype='none' read(5,funccard) if (atomtype .eq. 'none') goto 1200 open(unit=10,file='EAM_code',form='FORMATTED',status='OLD') 11 read(10,9501,end=1210)atommatch 9501 format(a80) if (atomtype .eq. atommatch) then ntypes=ntypes+1 length=len_trim(outfile) if (length .eq. len(outfile)) then outfile = atomtype else outfile = outfile(1:length)//atomtype endif length=len_trim(outelem) if (length .eq. len(outelem)) then outelem = atomtype else outelem = outelem(1:length)//' '//atomtype endif read(10,*) re(ntypes) read(10,*) fe(ntypes) read(10,*) rhoe(ntypes) read(10,*) rhos(ntypes) read(10,*) alpha(ntypes) read(10,*) beta(ntypes) read(10,*) A(ntypes) read(10,*) B(ntypes) read(10,*) cai(ntypes) read(10,*) ramda(ntypes) read(10,*) Fi0(ntypes) read(10,*) Fi1(ntypes) read(10,*) Fi2(ntypes) read(10,*) Fi3(ntypes) read(10,*) Fm0(ntypes) read(10,*) Fm1(ntypes) read(10,*) Fm2(ntypes) read(10,*) Fm3(ntypes) read(10,*) fnn(ntypes) read(10,*) Fn(ntypes) read(10,*) ielement(ntypes) read(10,*) amass(ntypes) read(10,*) Fm4(ntypes) read(10,*) beta1(ntypes) read(10,*) ramda1(ntypes) read(10,*) rhol(ntypes) read(10,*) rhoh(ntypes) blat(ntypes)=sqrt(2.0)*re(ntypes) rhoin(ntypes)=rhol(ntypes)*rhoe(ntypes) rhoout(ntypes)=rhoh(ntypes)*rhoe(ntypes) else do 1 i=1,27 1 read(10,*)vtmp goto 11 endif close(10) goto 10 1210 write(6,*)'error: atom type ',atomtype,' not found' stop 1200 continue nr=2000 nrho=2000 alatmax=blat(1) rhoemax=rhoe(1) do 2 i=2,ntypes if (alatmax .lt. blat(i)) alatmax=blat(i) if (rhoemax .lt. rhoe(i)) rhoemax=rhoe(i) 2 continue rc=sqrt(10.0)/2.0*alatmax rst=0.5 dr=rc/(nr-1.0) fmax=-1.0 do 3 i1=1,ntypes do 3 i2=1,i1 if ( i1 .eq. i2) then do 4 i=1,nr r=(i-1.0)*dr if (r .lt. rst) r=rst call prof(i1,r,fvalue) if (fmax .lt. fvalue) fmax=fvalue rhor(i,i1)=fvalue call pair(i1,i2,r,psi) z2r(i,i1,i2)=r*psi 4 continue else do 5 i=1,nr r=(i-1.0)*dr if (r .lt. rst) r=rst call pair(i1,i2,r,psi) z2r(i,i1,i2)=r*psi z2r(i,i2,i1)=z2r(i,i1,i2) 5 continue endif 3 continue rhom=fmax if (rhom .lt. 2.0*rhoemax) rhom=2.0*rhoemax if (rhom .lt. 100.0) rhom=100.0 drho=rhom/(nrho-1.0) do 6 it=1,ntypes do 7 i=1,nrho rhoF=(i-1.0)*drho call embed(it,rhoF,emb) Fr(i,it)=emb 7 continue 6 continue return end ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c This subroutine calculates the electron density. c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc subroutine prof(it,r,f) common /pass1/ re(16),fe(16),rhoe(16),alpha(16), * beta(16),beta1(16),A(16),B(16),cai(16),ramda(16), * ramda1(16),Fi0(16),Fi1(16),Fi2(16),Fi3(16), * Fm0(16),Fm1(16),Fm2(16),Fm3(16),Fm4(16), * fnn(16),Fn(16),rhoin(16),rhoout(16),rhol(16), * rhoh(16),rhos(16) f=fe(it)*exp(-beta1(it)*(r/re(it)-1.0)) f=f/(1.0+(r/re(it)-ramda1(it))**20) return end ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c This subroutine calculates the pair potential. c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc subroutine pair(it1,it2,r,psi) common /pass1/ re(16),fe(16),rhoe(16),alpha(16), * beta(16),beta1(16),A(16),B(16),cai(16),ramda(16), * ramda1(16),Fi0(16),Fi1(16),Fi2(16),Fi3(16), * Fm0(16),Fm1(16),Fm2(16),Fm3(16),Fm4(16), * fnn(16),Fn(16),rhoin(16),rhoout(16),rhol(16), * rhoh(16),rhos(16) if (it1 .eq. it2) then psi1=A(it1)*exp(-alpha(it1)*(r/re(it1)-1.0)) psi1=psi1/(1.0+(r/re(it1)-cai(it1))**20) psi2=B(it1)*exp(-beta(it1)*(r/re(it1)-1.0)) psi2=psi2/(1.0+(r/re(it1)-ramda(it1))**20) psi=psi1-psi2 else psi1=A(it1)*exp(-alpha(it1)*(r/re(it1)-1.0)) psi1=psi1/(1.0+(r/re(it1)-cai(it1))**20) psi2=B(it1)*exp(-beta(it1)*(r/re(it1)-1.0)) psi2=psi2/(1.0+(r/re(it1)-ramda(it1))**20) psia=psi1-psi2 psi1=A(it2)*exp(-alpha(it2)*(r/re(it2)-1.0)) psi1=psi1/(1.0+(r/re(it2)-cai(it2))**20) psi2=B(it2)*exp(-beta(it2)*(r/re(it2)-1.0)) psi2=psi2/(1.0+(r/re(it2)-ramda(it2))**20) psib=psi1-psi2 call prof(it1,r,f1) call prof(it2,r,f2) psi=0.5*(f2/f1*psia+f1/f2*psib) endif return end ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c This subroutine calculates the embedding energy. c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc subroutine embed(it,rho,emb) common /pass1/ re(16),fe(16),rhoe(16),alpha(16), * beta(16),beta1(16),A(16),B(16),cai(16),ramda(16), * ramda1(16),Fi0(16),Fi1(16),Fi2(16),Fi3(16), * Fm0(16),Fm1(16),Fm2(16),Fm3(16),Fm4(16), * fnn(16),Fn(16),rhoin(16),rhoout(16),rhol(16), * rhoh(16),rhos(16) if (rho .lt. rhoe(it)) then Fm33=Fm3(it) else Fm33=Fm4(it) endif if (rho .lt. rhoin(it)) then emb=Fi0(it)+ * Fi1(it)*(rho/rhoin(it)-1.0)+ * Fi2(it)*(rho/rhoin(it)-1.0)**2+ * Fi3(it)*(rho/rhoin(it)-1.0)**3 else if (rho .lt. rhoout(it)) then emb=Fm0(it)+ * Fm1(it)*(rho/rhoe(it)-1.0)+ * Fm2(it)*(rho/rhoe(it)-1.0)**2+ * Fm33*(rho/rhoe(it)-1.0)**3 else emb=Fn(it)*(1.0-fnn(it)*log(rho/rhos(it)))* * (rho/rhos(it))**fnn(it) endif return end ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c write out set file. c ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc subroutine writeset character*80 outfile,outelem common /pass1/ re(16),fe(16),rhoe(16),alpha(16), * beta(16),beta1(16),A(16),B(16),cai(16),ramda(16), * ramda1(16),Fi0(16),Fi1(16),Fi2(16),Fi3(16), * Fm0(16),Fm1(16),Fm2(16),Fm3(16),Fm4(16), * fnn(16),Fn(16),rhoin(16),rhoout(16),rhol(16), * rhoh(16),rhos(16) common /pass2/ ielement(16),amass(16),Fr(5000,16), * rhor(5000,16),z2r(5000,16,16),ntypes,blat(16), * nrho,drho,nr,dr,rc,outfile,outelem character*80 struc struc='fcc' outfile = outfile(1:index(outfile,' ')-1)//'.set' open(unit=1,file=outfile) write(1,*) write(1,*) write(1,*) write(1,8)ntypes,outelem 8 format(i5,' ',a24) write(1,9)nrho,drho,nr,dr,rc 9 format(i5,e24.16,i5,2e24.16) do 10 i=1,ntypes write(1,11)ielement(i),amass(i),blat(i),struc write(1,12)(Fr(j,i),j=1,nrho) write(1,12)(rhor(j,i),j=1,nr) 10 continue 11 format(i5,2g15.5,a8) 12 format(5e24.16) do 13 i1=1,ntypes do 13 i2=1,i1 write(1,12)(z2r(i,i1,i2),i=1,nr) 13 continue close(1) return end
gpl-3.0
Hellybean/SaberMod_ROM_Toolchain
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
kmkolasinski/Quantulaba
main_deriv.f90
2
8082
! ------------------------------------------------------ ! ! Quantulaba - simple_sqlat.f90 - Krzysztof Kolasinski 2015 ! ! We want to find few first eigenvalues of rectangular ! system defined within effective mass Shroedinger ! equation. Magnetic field will be included into account. ! We assume that after the finite discretization nodes ! of the mesh are separated by dx=5nm distance in ! each direction. ! ------------------------------------------------------ ! program transporter use modunits ! unit conversion tools use modscatter ! eigen values and transport use modlead ! bandgap structure use modshape use modutils implicit none character(*),parameter :: output_folder = "plots/" type(qscatter) :: qt type(qshape) :: lead_shape doubleprecision :: zeros_vector(200) doubleprecision :: a_dx,a_Emin,a_Emax,a_Bz integer :: no_expected_states integer ,parameter :: nx = 50 integer ,parameter :: ny = 50 doubleprecision,parameter :: dx = 5.0 ! [nm] integer , dimension(nx,ny) :: gindex ! converts local index (i,j) to global index integer :: i,j,k,p doubleprecision :: lead_translation_vec(3),Ef ! Use atomic units in effective band model -> see modunit.f90 for more details call modunits_set_GaAs_params() a_dx = dx * L2LA ! convert it to atomic units a_Bz = BtoAtomicB(0.0D0) ! 1 Tesla to atomic units ! Initalize system call qt%init_system() ! ---------------------------------------------------------- ! 1. Create mesh - loop over width and height of the lattice ! ---------------------------------------------------------- k = 0 gindex = 0 do i = 1 , nx do j = 1 , ny ! Initalize atom structure with position of the atom. ! For more details see modsys.f90 and qatom structure parameters. ! We assume that the 2D lattice lies at z=0. ! qt%qatom - is a auxiliary variable of type(qatom), you can use your own ! if you want. call qt%qatom%init((/ (i-1) * dx , (j-1) * dx , 0.0 * dx /),no_in_states=2) !here e.g. you can diable some part of atoms ! if( sqrt(abs(i - nx/2.0-1)**2 + abs(j - ny/2.0-1)**2)*dx < 20 ) then ! qt%qatom%bActive = .false. ! do not include those atoms in calculations ! endif ! Add atom to the system. call qt%qsystem%add_atom(qt%qatom) k = k + 1 gindex(i,j) = k enddo enddo ! ---------------------------------------------------------- ! 2. Construct logical connections between sites on the mesh. ! ---------------------------------------------------------- ! Set criterium for the nearest neightbours "radius" search algorithm. ! Same as above qt%qnnbparam is a auxiliary variable of type(nnb_params) - more details in modsys.f90 ! This structure is responsible for different criteria of nearest neighbour searching !qt%qnnbparam%box = (/1.2*dx,1.2*dx,0.0D0/) ! do not search for the sites far than (-dx:+dx) direction ! Setup connections between sites with provided by you function "connect", see below for example. qt%qnnbparam%NNB_FILTER = QSYS_NNB_FILTER_DISTANCE qt%qnnbparam%distance = 4*dx QSYS_DEBUG_LEVEL = 2 p = 1 call qtools_fd_template(v_dnFdxn,0,1) call qtools_fd_template(v_dnFdxn,1,p) call qtools_fd_template(v_dnFdyn,1,p) call qtools_fd_template(v_dnFdxn,2,p) call qtools_fd_template(v_dnFdyn,2,p) call qt%qsystem%make_lattice(qt%qnnbparam,c_matrix=coupling) ! ---------------------------------------------------------- ! 4. Use generated mesh to calculate the band structure ! in the region of homogenous lead. ! ---------------------------------------------------------- ! Setup shape and initialize lead ! Lead needs to know where it is (lead_shape) and using this information it will ! create propper matrices and connections using list of atoms lead_translation_vec = (/ p*dx , 0.0D0 , 0.0D0 /) call lead_shape%init_range_3d((/-0.5*dx,0.0D0,0.0D0/),lead_translation_vec) call qt%add_lead(lead_shape,lead_translation_vec) ! Add second lead at the end of the system lead_translation_vec = (/ -p*dx , 0.0D0 , 0.0D0 /) call lead_shape%init_range_3d((/(nx-0.5)*dx,0.0D0,0.0D0/),lead_translation_vec) call qt%add_lead(lead_shape,lead_translation_vec) a_Emin = -50.0 / E0 / 1000.0 ! converting from [meV] to atomic units a_Emax = 300.0 / E0 / 1000.0 ! converting from [meV] to atomic units call qt%leads(1)%bands(output_folder//"bands.dat",-M_PI/2,+M_PI/2,M_PI/100.0,a_Emin,a_Emax) call qt%save_system(output_folder//"system.xml") ! Solve scattering problem for Ef=0.001 Ef = 5/E0/1000.0 QSYS_DEBUG_LEVEL = 2 ! show more info call qt%calculate_modes(Ef) call qt%solve(1,Ef) ! Save calculated electron density to file do i = 1 , size(qt%qauxvec) qt%qauxvec(i) = sum(qt%densities(:,i)) enddo call qt%qsystem%save_data(output_folder//"densities.xml",array2d=qt%densities,array1d=qt%qauxvec) ! Perform scan in function of Energy ! open(unit=111,file=output_folder//"T.dat") print*,"Performing energy scan..." do Ef = 0.0 , 0.006 , 0.00005 call qt%qsystem%update_lattice(c_matrix=coupling) call qt%calculate_modes(Ef) call qt%solve(1,Ef) write(111,"(100f20.6)"),Ef,sum(qt%Tn(:)) enddo close(111) ! ---------------------------------------------------------- ! X. Clean memory... ! ---------------------------------------------------------- call lead_shape%destroy_shape() call qt%destroy_system() !print*,"Generating plots..." !print*,"Plotting band structure..." call system("cd "//output_folder//"; python plot_bands.py") !print*,"Plotting eigenvectors..." !call system("cd "//output_folder//"; ./plot_eigenvecs.py") !print*,"Plotting Transmission..." call system("cd "//output_folder//"; ./plot_T.py") !print*,"Use Viewer program to see the structure and created leads." contains ! --------------------------------------------------------------------------- ! This function decides if site A (called here atomA) with spin s1 has hoping ! to atom B with spin s2, and what is the value of the coupling. ! If there is no interaction between them returns false, otherwise true. ! --------------------------------------------------------------------------- !logical function connect(atomA,atomB,coupling_val) ! use modcommons ! implicit none ! type(qatom) :: atomA,atomB ! ! complex*16 :: coupling_val ! you must overwrite this variable ! ! local variables ! integer :: idx,idy ! doubleprecision :: dydiff,dxdiff,t0,y ! ! ! Calculate distance between atoms in units of dx. ! dxdiff = (atomA%atom_pos(1)-atomB%atom_pos(1))/dx ! dydiff = (atomA%atom_pos(2)-atomB%atom_pos(2))/dx ! ! Convert it to integers ! idx = NINT(dxdiff) ! idy = NINT(dydiff) ! ! default return value ! connect = .true. ! coupling_val = 0 ! ! hoping parameter ! t0 = 1/(2*m_eff*a_dx**2) ! ! ! coupling_val = -t0*(dnFdxn(2,idx,idy,0) + dnFdyn(2,idx,idy,0)) ! ! if(abs(coupling_val) < qsys_double_error) connect = .false. ! !end function connect logical function coupling(atomA,atomB,coupling_mat) use modcommons implicit none type(qatom) :: atomA,atomB complex*16 :: coupling_mat(:,:) ! you must overwrite this variable ! local variables integer :: xdiff,ydiff,idx,idy doubleprecision :: dydiff,dxdiff,t0,y,rs,bz ! Calculate distance between atoms in units of dx. dxdiff = (atomA%atom_pos(1)-atomB%atom_pos(1))/dx dydiff = (atomA%atom_pos(2)-atomB%atom_pos(2))/dx ! Convert it to integers idx = NINT(dxdiff) idy = NINT(dydiff) ! default return value coupling = .true. coupling_mat = 0.00 t0 = 1/(2*m_eff*a_dx**2) rs = 0.06/(2*a_dx) ! rashba coupling bz = 0.0001 coupling_mat = -t0*(dnFdxn(2,idx,idy,0) + dnFdyn(2,idx,idy,0))*MAT_DIAG + & bz * MAT_SZ * dnFdxn(0,idx,idy,0) + & rs * MAT_SX * (-II*dnFdyn(1,idx,idy,0)) - & rs * MAT_SY * (-II*dnFdxn(1,idx,idy,0)) if(sum(abs(coupling_mat)) < qsys_double_error) coupling = .false. end function coupling end program transporter
mit
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/pr55330.f90
134
1668
! PR rtl-optimization/55330 ! { dg-do compile } ! { dg-options "-O -fPIC -fno-dse -fno-guess-branch-probability" } module global public p, line interface p module procedure p end interface character(128) :: line = 'abcdefghijklmnopqrstuvwxyz' contains subroutine p() character(128) :: word word = line call redirect_((/word/)) end subroutine subroutine redirect_ (ch) character(*) :: ch(:) if (ch(1) /= line) call abort () end subroutine redirect_ end module global module my_module implicit none type point real :: x end type point type(point), pointer, public :: stdin => NULL() contains subroutine my_p(w) character(128) :: w call r(stdin,(/w/)) end subroutine my_p subroutine r(ptr, io) use global type(point), pointer :: ptr character(128) :: io(:) if (associated (ptr)) call abort () if (io(1) .ne. line) call abort () end subroutine r end module my_module program main use global use my_module integer :: i(6) = (/1,6,3,4,5,2/) character (6) :: a = 'hello ', t character(len=1) :: s(6) = (/'g','g','d','d','a','o'/) equivalence (s, t) call option_stopwatch_s (a) call p () call my_p (line) s = s(i) call option_stopwatch_a ((/a,'hola! ', t/)) contains subroutine option_stopwatch_s(a) character (*), intent(in) :: a character (len=len(a)) :: b b = 'hola! ' call option_stopwatch_a((/a, b, 'goddag'/)) end subroutine option_stopwatch_s subroutine option_stopwatch_a (a) character (*) :: a(:) if (any (a .ne. (/'hello ','hola! ','goddag'/))) call abort () end subroutine option_stopwatch_a end program main
gpl-2.0
intervigilium/cs259-or32-gcc
gcc/testsuite/gfortran.dg/whole_file_1.f90
4
1043
! { dg-do compile } ! { dg-options "-fwhole-file" } ! Tests the fix for PR22571 in which the derived types in a, b ! c and d were not detected to be different. In e and f, they ! are the same because they are sequence types. ! ! Contributed by Joost VandeVondele <jv244@cam.ac.uk> ! subroutine a(p) type t integer :: t1 end type type(t) :: p p%t1 = 42 end subroutine subroutine b type u integer :: u1 end type type (u) :: q call a(q) ! { dg-error "Type mismatch" } print *, q%u1 end subroutine subroutine c(p) type u integer :: u1 end type type(u) :: p p%u1 = 42 end subroutine subroutine d type u integer :: u1 end type type (u) :: q call c(q) ! { dg-error "Type mismatch" } print *, q%u1 end subroutine subroutine e(p) type u sequence integer :: u1 end type type(u) :: p p%u1 = 42 end subroutine subroutine f type u sequence integer :: u1 end type type (u) :: q call e(q) ! This is OK because the types are sequence. print *, q%u1 end subroutine
gpl-2.0
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/finalize_13.f90
111
3780
! { dg-do run } ! ! PR fortran/37336 ! module m implicit none type t integer :: i contains final :: fini3, fini2, fini_elm end type t type, extends(t) :: t2 integer :: j contains final :: f2ini2, f2ini_elm end type t2 logical :: elem_call logical :: rank2_call logical :: rank3_call integer :: cnt, cnt2 integer :: fini_call contains subroutine fini2 (x) type(t), intent(in), contiguous :: x(:,:) if (.not. rank2_call) call abort () if (size(x,1) /= 2 .or. size(x,2) /= 3) call abort() !print *, 'fini2:', x%i if (any (x%i /= reshape([11, 12, 21, 22, 31, 32], [2,3]))) call abort() fini_call = fini_call + 1 end subroutine subroutine fini3 (x) type(t), intent(in) :: x(2,2,*) integer :: i,j,k if (.not. elem_call) call abort () if (.not. rank3_call) call abort () if (cnt2 /= 9) call abort() if (cnt /= 1) call abort() do i = 1, 2 do j = 1, 2 do k = 1, 2 !print *, k,j,i,x(k,j,i)%i if (x(k,j,i)%i /= k+10*j+100*i) call abort() end do end do end do fini_call = fini_call + 1 end subroutine impure elemental subroutine fini_elm (x) type(t), intent(in) :: x if (.not. elem_call) call abort () if (rank3_call) call abort () if (cnt2 /= 6) call abort() if (cnt /= x%i) call abort() !print *, 'fini_elm:', cnt, x%i fini_call = fini_call + 1 cnt = cnt + 1 end subroutine subroutine f2ini2 (x) type(t2), intent(in), target :: x(:,:) if (.not. rank2_call) call abort () if (size(x,1) /= 2 .or. size(x,2) /= 3) call abort() !print *, 'f2ini2:', x%i !print *, 'f2ini2:', x%j if (any (x%i /= reshape([11, 12, 21, 22, 31, 32], [2,3]))) call abort() if (any (x%j /= 100*reshape([11, 12, 21, 22, 31, 32], [2,3]))) call abort() fini_call = fini_call + 1 end subroutine impure elemental subroutine f2ini_elm (x) type(t2), intent(in) :: x integer, parameter :: exprected(*) & = [111, 112, 121, 122, 211, 212, 221, 222] if (.not. elem_call) call abort () !print *, 'f2ini_elm:', cnt2, x%i, x%j if (rank3_call) then if (x%i /= exprected(cnt2)) call abort () if (x%j /= 1000*exprected(cnt2)) call abort () else if (cnt2 /= x%i .or. cnt2*10 /= x%j) call abort() end if cnt2 = cnt2 + 1 fini_call = fini_call + 1 end subroutine end module m program test use m implicit none class(t), save, allocatable :: y(:), z(:,:), zz(:,:,:) target :: z, zz integer :: i,j,k elem_call = .false. rank2_call = .false. rank3_call = .false. allocate (t2 :: y(5)) select type (y) type is (t2) do i = 1, 5 y(i)%i = i y(i)%j = i*10 end do end select cnt = 1 cnt2 = 1 fini_call = 0 elem_call = .true. deallocate (y) if (fini_call /= 10) call abort () elem_call = .false. rank2_call = .false. rank3_call = .false. allocate (t2 :: z(2,3)) select type (z) type is (t2) do i = 1, 3 do j = 1, 2 z(j,i)%i = j+10*i z(j,i)%j = (j+10*i)*100 end do end do end select cnt = 1 cnt2 = 1 fini_call = 0 rank2_call = .true. deallocate (z) if (fini_call /= 2) call abort () elem_call = .false. rank2_call = .false. rank3_call = .false. allocate (t2 :: zz(2,2,2)) select type (zz) type is (t2) do i = 1, 2 do j = 1, 2 do k = 1, 2 zz(k,j,i)%i = k+10*j+100*i zz(k,j,i)%j = (k+10*j+100*i)*1000 end do end do end do end select cnt = 1 cnt2 = 1 fini_call = 0 rank3_call = .true. elem_call = .true. deallocate (zz) if (fini_call /= 2*2*2+1) call abort () end program test
gpl-2.0
tuxillo/aarch64-dragonfly-gcc
libgfortran/generated/_tanh_r8.F90
47
1472
! Copyright (C) 2002-2015 Free Software Foundation, Inc. ! Contributed by Paul Brook <paul@nowt.org> ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !GNU libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. !GNU libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. ! !This file is machine generated. #include "config.h" #include "kinds.inc" #include "c99_protos.inc" #if defined (HAVE_GFC_REAL_8) #ifdef HAVE_TANH elemental function _gfortran_specific__tanh_r8 (parm) real (kind=8), intent (in) :: parm real (kind=8) :: _gfortran_specific__tanh_r8 _gfortran_specific__tanh_r8 = tanh (parm) end function #endif #endif
gpl-2.0
CompOpt4Apps/IEGenLib
lib/gmp/mpn/cray/mulww.f
24
2267
c Helper for mpn_mul_1, mpn_addmul_1, and mpn_submul_1 for Cray PVP. c Copyright 1996, 2000 Free Software Foundation, Inc. c This file is part of the GNU MP Library. c c The GNU MP Library is free software; you can redistribute it and/or modify c it under the terms of either: c c * the GNU Lesser General Public License as published by the Free c Software Foundation; either version 3 of the License, or (at your c option) any later version. c c or c c * the GNU General Public License as published by the Free Software c Foundation; either version 2 of the License, or (at your option) any c later version. c c or both in parallel, as here. c c The GNU MP Library is distributed in the hope that it will be useful, but c WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY c or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License c for more details. c c You should have received copies of the GNU General Public License and the c GNU Lesser General Public License along with the GNU MP Library. If not, c see https://www.gnu.org/licenses/. c p1[] = hi(a[]*s); the upper limbs of each product c p0[] = low(a[]*s); the corresponding lower limbs c n is number of limbs in the vectors subroutine gmpn_mulww(p1,p0,a,n,s) integer*8 p1(0:*),p0(0:*),a(0:*),s integer n integer*8 a0,a1,a2,s0,s1,s2,c integer*8 ai,t0,t1,t2,t3,t4 s0 = shiftl(and(s,4194303),24) s1 = shiftl(and(shiftr(s,22),4194303),24) s2 = shiftl(and(shiftr(s,44),4194303),24) do i = 0,n-1 ai = a(i) a0 = shiftl(and(ai,4194303),24) a1 = shiftl(and(shiftr(ai,22),4194303),24) a2 = shiftl(and(shiftr(ai,44),4194303),24) t0 = i24mult(a0,s0) t1 = i24mult(a0,s1)+i24mult(a1,s0) t2 = i24mult(a0,s2)+i24mult(a1,s1)+i24mult(a2,s0) t3 = i24mult(a1,s2)+i24mult(a2,s1) t4 = i24mult(a2,s2) p0(i)=shiftl(t2,44)+shiftl(t1,22)+t0 c=shiftr(shiftr(t0,22)+and(t1,4398046511103)+ $ shiftl(and(t2,1048575),22),42) p1(i)=shiftl(t4,24)+shiftl(t3,2)+shiftr(t2,20)+shiftr(t1,42)+c end do end
bsd-2-clause
FrontISTR/FrontISTR
hecmw1/src/solver/mpc/hecmw_mpc_prepost.f90
1
20078
!------------------------------------------------------------------------------- ! Copyright (c) 2019 FrontISTR Commons ! This software is released under the MIT License, see LICENSE.txt !------------------------------------------------------------------------------- module hecmw_mpc_prepost use hecmw_util use m_hecmw_comm_f use hecmw_matrix_misc use hecmw_matrix_ass use hecmw_local_matrix use hecmw_solver_las implicit none private public :: hecmw_mpc_mat_init public :: hecmw_mpc_mat_init_explicit public :: hecmw_mpc_mat_finalize public :: hecmw_mpc_mat_finalize_explicit public :: hecmw_mpc_mat_ass public :: hecmw_mpc_trans_rhs public :: hecmw_mpc_tback_sol public :: hecmw_mpc_trans_mass public :: hecmw_mpc_tback_eigvec public :: hecmw_mpc_mark_slave contains !C !C*** !C*** hecmw_mpc_mat_init !C*** !C subroutine hecmw_mpc_mat_init(hecMESH, hecMAT, hecMESHmpc, hecMATmpc, conMAT, conMATmpc) implicit none type (hecmwST_local_mesh), intent(inout), target :: hecMESH type (hecmwST_matrix), intent(in), target :: hecMAT type (hecmwST_local_mesh), pointer :: hecMESHmpc type (hecmwST_matrix), pointer :: hecMATmpc type (hecmwST_matrix), intent(in), target, optional :: conMAT type (hecmwST_matrix), pointer, optional :: conMATmpc integer(kind=kint) :: totalmpc, MPC_METHOD, SOLVER_TYPE totalmpc = hecMESH%mpc%n_mpc call hecmw_allreduce_I1 (hecMESH, totalmpc, hecmw_sum) if (totalmpc == 0) then hecMESHmpc => hecMESH hecMATmpc => hecMAT if (present(conMAT).and.present(conMATmpc)) conMATmpc => conMAT return endif call hecmw_mpc_scale(hecMESH) MPC_METHOD = hecmw_mat_get_mpc_method(hecMAT) if (MPC_METHOD < 1 .or. 3 < MPC_METHOD) then SOLVER_TYPE = hecmw_mat_get_solver_type(hecMAT) if (SOLVER_TYPE > 1) then ! DIRECT SOLVER MPC_METHOD = 1 ! default: penalty else ! ITERATIVE SOLVER MPC_METHOD = 3 ! default: elimination endif call hecmw_mat_set_mpc_method(hecMAT, MPC_METHOD) endif if (MPC_METHOD == 2) then write(*,*) 'WARNING: MPCMETHOD=2 (MPCCG) is deprecated; may not work correctly' ! MPC_METHOD = 3 ! call hecmw_mat_set_mpc_method(hecMAT, MPC_METHOD) endif select case (MPC_METHOD) case (1) ! penalty hecMESHmpc => hecMESH hecMATmpc => hecMAT if (present(conMAT).and.present(conMATmpc)) conMATmpc => conMAT case (2) ! MPCCG hecMESHmpc => hecMESH hecMATmpc => hecMAT if (present(conMAT).and.present(conMATmpc)) conMATmpc => conMAT case (3) ! elimination allocate(hecMESHmpc) call hecmw_mpc_mesh_copy(hecMESH, hecMESHmpc) allocate(hecMATmpc) call hecmw_mat_init(hecMATmpc) if (present(conMAT).and.present(conMATmpc)) then allocate(conMATmpc) call hecMW_mat_init(conMATmpc) endif end select end subroutine hecmw_mpc_mat_init !C !C*** !C*** hecmw_mpc_mat_init_explicit !C*** !C subroutine hecmw_mpc_mat_init_explicit(hecMESH, hecMAT, hecMATmpc) implicit none type (hecmwST_local_mesh), intent(inout), target :: hecMESH type (hecmwST_matrix), intent(in), target :: hecMAT type (hecmwST_matrix), pointer :: hecMATmpc integer(kind=kint) :: totalmpc, MPC_METHOD totalmpc = hecMESH%mpc%n_mpc call hecmw_allreduce_I1 (hecMESH, totalmpc, hecmw_sum) if (totalmpc == 0) then hecMATmpc => hecMAT return endif call hecmw_mpc_scale(hecMESH) ! Force MPC_METHOD=3 MPC_METHOD = 3 call hecmw_mat_set_mpc_method(hecMAT, MPC_METHOD) allocate(hecMATmpc) call hecmw_mat_init(hecMATmpc) hecMATmpc%N = hecMAT%N hecMATmpc%NP = hecMAT%NP hecMATmpc%NDOF = hecMAT%NDOF allocate(hecMATmpc%B(size(hecMAT%B))) allocate(hecMATmpc%X(size(hecMAT%X))) end subroutine hecmw_mpc_mat_init_explicit !C !C*** !C*** hecmw_mpc_mat_finalize !C*** !C subroutine hecmw_mpc_mat_finalize(hecMESH, hecMAT, hecMESHmpc, hecMATmpc, conMATmpc) implicit none type (hecmwST_local_mesh), intent(in) :: hecMESH type (hecmwST_matrix), intent(in) :: hecMAT type (hecmwST_local_mesh), pointer :: hecMESHmpc type (hecmwST_matrix), pointer :: hecMATmpc type (hecmwST_matrix), pointer, optional :: conMATmpc integer(kind=kint) :: totalmpc, MPC_METHOD totalmpc = hecMESH%mpc%n_mpc call hecmw_allreduce_I1 (hecMESH, totalmpc, hecmw_sum) if (totalmpc == 0) then nullify(hecMESHmpc) nullify(hecMATmpc) if (present(conMATmpc)) nullify(conMATmpc) return endif MPC_METHOD = hecmw_mat_get_mpc_method(hecMAT) select case (MPC_METHOD) case (1) ! penalty nullify(hecMESHmpc) nullify(hecMATmpc) if (present(conMATmpc)) nullify(conMATmpc) case (2) ! MPCCG nullify(hecMESHmpc) nullify(hecMATmpc) if (present(conMATmpc)) nullify(conMATmpc) case (3) ! elimination call hecmw_mpc_mesh_free(hecMESHmpc) deallocate(hecMESHmpc) nullify(hecMESHmpc) call hecmw_mat_finalize(hecMATmpc) deallocate(hecMATmpc) nullify(hecMATmpc) if (present(conMATmpc)) then call hecmw_mat_finalize(conMATmpc) deallocate(conMATmpc) nullify(conMATmpc) endif end select end subroutine hecmw_mpc_mat_finalize !C !C*** !C*** hecmw_mpc_mat_finalize_explicit !C*** !C subroutine hecmw_mpc_mat_finalize_explicit(hecMESH, hecMAT, hecMATmpc) implicit none type (hecmwST_local_mesh), intent(in) :: hecMESH type (hecmwST_matrix), intent(in) :: hecMAT type (hecmwST_matrix), pointer :: hecMATmpc integer(kind=kint) :: totalmpc, MPC_METHOD totalmpc = hecMESH%mpc%n_mpc call hecmw_allreduce_I1 (hecMESH, totalmpc, hecmw_sum) if (totalmpc == 0) then nullify(hecMATmpc) return endif MPC_METHOD = hecmw_mat_get_mpc_method(hecMAT) select case (MPC_METHOD) case (1) ! penalty nullify(hecMATmpc) case (2) ! MPCCG nullify(hecMATmpc) case (3) ! elimination call hecmw_mat_finalize(hecMATmpc) deallocate(hecMATmpc) nullify(hecMATmpc) end select end subroutine hecmw_mpc_mat_finalize_explicit !C !C*** !C*** hecmw_mpc_mat_ass !C*** !C subroutine hecmw_mpc_mat_ass(hecMESH, hecMAT, hecMESHmpc, hecMATmpc, conMAT, conMATmpc, hecLagMAT) implicit none type (hecmwST_local_mesh), intent(in) :: hecMESH type (hecmwST_matrix), intent(inout) :: hecMAT type (hecmwST_local_mesh), pointer :: hecMESHmpc type (hecmwST_matrix), pointer :: hecMATmpc type (hecmwST_matrix), intent(inout), optional :: conMAT type (hecmwST_matrix), pointer, optional :: conMATmpc type (hecmwST_matrix_lagrange), intent(inout), optional :: hecLagMAT integer(kind=kint) :: totalmpc, MPC_METHOD totalmpc = hecMESH%mpc%n_mpc call hecmw_allreduce_I1 (hecMESH, totalmpc, hecmw_sum) if (totalmpc == 0) return MPC_METHOD = hecmw_mat_get_mpc_method(hecMAT) select case (MPC_METHOD) case (1) ! penalty !if (hecMESH%my_rank.eq.0) write(0,*) "MPC Method: Penalty" call hecmw_mat_ass_equation ( hecMESH, hecMAT ) case (2) ! MPCCG !if (hecMESH%my_rank.eq.0) write(0,*) "MPC Method: MPC-CG" case (3) ! elimination !if (hecMESH%my_rank.eq.0) write(0,*) "MPC Method: Elimination" call hecmw_trimatmul_TtKT_mpc(hecMESHmpc, hecMAT, hecMATmpc) if (present(conMAT).and.present(conMATmpc).and.present(hecLagMAT)) then call hecmw_trimatmul_TtKT_mpc(hecMESHmpc, conMAT, conMATmpc) call resize_hecLagMAT(conMAT%NP, conMATmpc%NP, conMAT%NDOF, hecLagMAT) endif end select end subroutine hecmw_mpc_mat_ass subroutine resize_hecLagMAT(NP_orig, NP_new, ndof, hecLagMAT) integer(kind=kint), intent(in) :: NP_orig, NP_new, ndof type (hecmwST_matrix_lagrange), intent(inout) :: hecLagMAT integer(kind=kint), pointer :: itemp(:) if (hecLagMAT%num_lagrange == 0) return allocate(itemp(0:NP_new)) itemp(0:NP_orig) = hecLagMAT%indexU_lagrange(0:NP_orig) itemp(NP_orig+1:NP_new) = hecLagMAT%indexU_lagrange(NP_orig) deallocate(hecLagMAT%indexU_lagrange) hecLagMAT%indexU_lagrange => itemp end subroutine resize_hecLagMAT !C !C*** !C*** hecmw_mpc_trans_rhs !C*** !C subroutine hecmw_mpc_trans_rhs(hecMESH, hecMAT, hecMATmpc) implicit none type (hecmwST_local_mesh), intent(inout) :: hecMESH type (hecmwST_matrix), intent(inout) :: hecMAT type (hecmwST_matrix), pointer :: hecMATmpc real(kind=kreal), allocatable :: Btmp(:) real(kind=kreal) :: time_dumm integer(kind=kint) :: totalmpc, MPC_METHOD, i totalmpc = hecMESH%mpc%n_mpc call hecmw_allreduce_I1 (hecMESH, totalmpc, hecmw_sum) if (totalmpc == 0) return MPC_METHOD = hecmw_mat_get_mpc_method(hecMAT) select case (MPC_METHOD) case (1) ! penalty call hecmw_mat_ass_equation_rhs ( hecMESH, hecMATmpc ) case (2) ! MPCCG allocate(Btmp(hecMAT%NP*hecMAT%NDOF)) do i = 1, hecMAT%NP*hecMAT%NDOF Btmp(i) = hecMAT%B(i) enddo call hecmw_trans_b(hecMESH, hecMAT, Btmp, hecMATmpc%B, time_dumm) deallocate(Btmp) case (3) ! elimination call hecmw_trans_b(hecMESH, hecMAT, hecMAT%B, hecMATmpc%B, time_dumm) hecMATmpc%Iarray=hecMAT%Iarray hecMATmpc%Rarray=hecMAT%Rarray end select end subroutine hecmw_mpc_trans_rhs !C !C*** !C*** hecmw_mpc_tback_sol !C*** !C subroutine hecmw_mpc_tback_sol(hecMESH, hecMAT, hecMATmpc) implicit none type (hecmwST_local_mesh), intent(in) :: hecMESH type (hecmwST_matrix), intent(inout) :: hecMAT type (hecmwST_matrix), pointer :: hecMATmpc real(kind=kreal) :: time_dumm integer(kind=kint) :: totalmpc, MPC_METHOD, i integer(kind=kint) :: npndof, npndof_mpc, num_lagrange totalmpc = hecMESH%mpc%n_mpc call hecmw_allreduce_I1 (hecMESH, totalmpc, hecmw_sum) if (totalmpc == 0) return MPC_METHOD = hecmw_mat_get_mpc_method(hecMAT) select case (MPC_METHOD) case (1) ! penalty ! do nothing case (2) ! MPCCG call hecmw_tback_x(hecMESH, hecMAT%NDOF, hecMAT%X, time_dumm) case (3) ! elimination npndof = hecMAT%NP * hecMAT%NDOF do i = 1, npndof hecMAT%X(i) = hecMATmpc%X(i) enddo call hecmw_tback_x(hecMESH, hecMAT%NDOF, hecMAT%X, time_dumm) num_lagrange = size(hecMAT%X) - npndof npndof_mpc = hecMATmpc%NP * hecMATmpc%NDOF do i = 1, num_lagrange hecMAT%X(npndof+i) = hecMATmpc%X(npndof_mpc+i) enddo hecMAT%Iarray=hecMATmpc%Iarray hecMAT%Rarray=hecMATmpc%Rarray end select end subroutine hecmw_mpc_tback_sol !C !C*** !C*** hecmw_mpc_trans_mass !C*** !C subroutine hecmw_mpc_trans_mass(hecMESH, hecMAT, mass) implicit none type (hecmwST_local_mesh), intent(inout) :: hecMESH type (hecmwST_matrix), intent(inout) :: hecMAT real(kind=kreal), intent(inout) :: mass(:) real(kind=kreal), allocatable :: Mtmp(:) real(kind=kreal) :: time_dumm integer(kind=kint) :: totalmpc, MPC_METHOD, i totalmpc = hecMESH%mpc%n_mpc call hecmw_allreduce_I1 (hecMESH, totalmpc, hecmw_sum) if (totalmpc == 0) return MPC_METHOD = hecmw_mat_get_mpc_method(hecMAT) select case (MPC_METHOD) case (1) ! penalty ! do nothing case (2,3) ! MPCCG or elimination allocate(Mtmp(hecMAT%NP*hecMAT%NDOF)) !C-- {Mt} = [T'] {w} call hecmw_Ttvec(hecMESH, hecMAT%NDOF, mass, Mtmp, time_dumm) do i = 1, hecMAT%NP*hecMAT%NDOF mass(i) = Mtmp(i) enddo deallocate(Mtmp) end select end subroutine hecmw_mpc_trans_mass !C !C*** !C*** hecmw_mpc_tback_eigvec !C*** !C subroutine hecmw_mpc_tback_eigvec(hecMESH, hecMAT, neig, eigvec) implicit none type (hecmwST_local_mesh), intent(in) :: hecMESH type (hecmwST_matrix), intent(inout) :: hecMAT integer(kind=kint), intent(in) :: neig real(kind=kreal), intent(inout) :: eigvec(:,:) real(kind=kreal) :: time_dumm integer(kind=kint) :: totalmpc, MPC_METHOD, i totalmpc = hecMESH%mpc%n_mpc call hecmw_allreduce_I1 (hecMESH, totalmpc, hecmw_sum) if (totalmpc == 0) return MPC_METHOD = hecmw_mat_get_mpc_method(hecMAT) select case (MPC_METHOD) case (1) ! penalty ! do nothing case (2,3) ! MPCCG or elimination do i = 1, neig call hecmw_tback_x(hecMESH, hecMAT%NDOF, eigvec(:,i), time_dumm) !!! need normalization??? enddo end select end subroutine hecmw_mpc_tback_eigvec !C !C*** !C*** hecmw_mpc_mark_slave !C*** !C subroutine hecmw_mpc_mark_slave(hecMESH, hecMAT, mark) implicit none type (hecmwST_local_mesh), intent(in) :: hecMESH type (hecmwST_matrix), intent(inout) :: hecMAT integer(kind=kint), intent(out) :: mark(:) integer(kind=kint) :: ndof, i, j, k, kk ndof = hecMAT%NDOF mark(:) = 0 OUTER: do i = 1, hecMESH%mpc%n_mpc do j = hecMESH%mpc%mpc_index(i-1)+1, hecMESH%mpc%mpc_index(i) if (hecMESH%mpc%mpc_dof(j) > ndof) cycle OUTER enddo k = hecMESH%mpc%mpc_index(i-1)+1 kk = ndof * (hecMESH%mpc%mpc_item(k) - 1) + hecMESH%mpc%mpc_dof(k) mark(kk) = 1 enddo OUTER end subroutine hecmw_mpc_mark_slave !C !C*** !C*** hecmw_mpc_scale !C*** !C subroutine hecmw_mpc_scale(hecMESH) implicit none type (hecmwST_local_mesh), intent(inout) :: hecMESH integer(kind=kint) :: i, j, k real(kind=kreal) :: WVAL !$omp parallel default(none),private(i,j,k,WVAL),shared(hecMESH) !$omp do do i = 1, hecMESH%mpc%n_mpc k = hecMESH%mpc%mpc_index(i-1)+1 WVAL = 1.d0 / hecMESH%mpc%mpc_val(k) hecMESH%mpc%mpc_val(k) = 1.d0 do j = hecMESH%mpc%mpc_index(i-1)+2, hecMESH%mpc%mpc_index(i) hecMESH%mpc%mpc_val(j) = hecMESH%mpc%mpc_val(j) * WVAL enddo hecMESH%mpc%mpc_const(i) = hecMESH%mpc%mpc_const(i) * WVAL enddo !$omp end do !$omp end parallel end subroutine hecmw_mpc_scale !C !C*** !C*** hecmw_trans_b !C*** !C subroutine hecmw_trans_b(hecMESH, hecMAT, B, BT, COMMtime) implicit none type (hecmwST_local_mesh), intent(in) :: hecMESH type (hecmwST_matrix), intent(in) :: hecMAT real(kind=kreal), intent(in) :: B(:) real(kind=kreal), intent(out), target :: BT(:) real(kind=kreal), intent(inout) :: COMMtime real(kind=kreal), allocatable :: W(:) real(kind=kreal), pointer :: XG(:) integer(kind=kint) :: ndof, i, j, k, kk, flg_bak ndof = hecMAT%NDOF allocate(W(hecMESH%n_node * ndof)) !C=== !C +---------------------------+ !C | {bt}= [T']({b} - [A]{xg}) | !C +---------------------------+ !C=== XG => BT do i = 1, hecMAT%N * ndof XG(i) = 0.d0 enddo !C-- Generate {xg} from mpc_const !$omp parallel default(none),private(i,k,kk),shared(hecMESH,XG),firstprivate(ndof) !$omp do OUTER: do i = 1, hecMESH%mpc%n_mpc do j = hecMESH%mpc%mpc_index(i-1)+1, hecMESH%mpc%mpc_index(i) if (hecMESH%mpc%mpc_dof(j) > ndof) cycle OUTER enddo k = hecMESH%mpc%mpc_index(i-1) + 1 kk = ndof * (hecMESH%mpc%mpc_item(k) - 1) + hecMESH%mpc%mpc_dof(k) XG(kk) = hecMESH%mpc%mpc_const(i) enddo OUTER !$omp end do !$omp end parallel !C-- {w} = {b} - [A]{xg} flg_bak = hecmw_mat_get_flag_mpcmatvec(hecMAT) call hecmw_mat_set_flag_mpcmatvec(hecMAT, 0) call hecmw_matresid(hecMESH, hecMAT, XG, B, W, COMMtime) call hecmw_mat_set_flag_mpcmatvec(hecMAT, flg_bak) !C-- {bt} = [T'] {w} call hecmw_Ttvec(hecMESH, ndof, W, BT, COMMtime) deallocate(W) end subroutine hecmw_trans_b !C !C*** !C*** hecmw_tback_x !C*** !C subroutine hecmw_tback_x(hecMESH, ndof, X, COMMtime) implicit none type (hecmwST_local_mesh), intent(in) :: hecMESH integer(kind=kint), intent(in) :: ndof real(kind=kreal), intent(inout) :: X(:) real(kind=kreal), intent(inout) :: COMMtime real(kind=kreal), allocatable :: W(:) integer(kind=kint) :: i, j, k, kk allocate(W(hecMESH%n_node * ndof)) !C-- {tx} = [T]{x} call hecmw_Tvec(hecMESH, ndof, X, W, COMMtime) !C-- {x} = {tx} + {xg} !$omp parallel default(none),private(i,k,kk),shared(hecMESH,X,W),firstprivate(ndof) !$omp do do i= 1, hecMESH%nn_internal * ndof X(i)= W(i) enddo !$omp end do !$omp do OUTER: do i = 1, hecMESH%mpc%n_mpc do j = hecMESH%mpc%mpc_index(i-1)+1, hecMESH%mpc%mpc_index(i) if (hecMESH%mpc%mpc_dof(j) > ndof) cycle OUTER enddo k = hecMESH%mpc%mpc_index(i-1) + 1 kk = ndof * (hecMESH%mpc%mpc_item(k) - 1) + hecMESH%mpc%mpc_dof(k) X(kk) = X(kk) + hecMESH%mpc%mpc_const(i) enddo OUTER !$omp end do !$omp end parallel deallocate(W) call hecmw_update_R(hecMESH, X, hecMESH%n_node, ndof) end subroutine hecmw_tback_x subroutine hecmw_mpc_mesh_copy(src, dst) implicit none type (hecmwST_local_mesh), intent(in) :: src type (hecmwST_local_mesh), intent(out) :: dst dst%zero = src%zero dst%MPI_COMM = src%MPI_COMM dst%PETOT = src%PETOT dst%PEsmpTOT = src%PEsmpTOT dst%my_rank = src%my_rank dst%n_subdomain = src%n_subdomain dst%n_node = src%n_node dst%nn_internal = src%nn_internal dst%n_elem = src%n_elem dst%ne_internal = src%ne_internal dst%n_elem_type = src%n_elem_type dst%n_dof = src%n_dof dst%n_neighbor_pe = src%n_neighbor_pe if (src%n_neighbor_pe > 0) then allocate(dst%neighbor_pe(dst%n_neighbor_pe)) dst%neighbor_pe(:) = src%neighbor_pe(:) allocate(dst%import_index(0:dst%n_neighbor_pe)) dst%import_index(:)= src%import_index(:) allocate(dst%export_index(0:dst%n_neighbor_pe)) dst%export_index(:)= src%export_index(:) allocate(dst%import_item(dst%import_index(dst%n_neighbor_pe))) dst%import_item(:) = src%import_item(:) allocate(dst%export_item(dst%export_index(dst%n_neighbor_pe))) dst%export_item(:) = src%export_item(:) endif allocate(dst%global_node_ID(dst%n_node)) dst%global_node_ID(1:dst%n_node) = src%global_node_ID(1:dst%n_node) allocate(dst%node_ID(2*dst%n_node)) dst%node_ID(1:2*dst%n_node) = src%node_ID(1:2*dst%n_node) allocate(dst%elem_type_item(dst%n_elem_type)) dst%elem_type_item(:) = src%elem_type_item(:) ! dst%mpc%n_mpc = src%mpc%n_mpc dst%mpc%mpc_index => src%mpc%mpc_index dst%mpc%mpc_item => src%mpc%mpc_item dst%mpc%mpc_dof => src%mpc%mpc_dof dst%mpc%mpc_val => src%mpc%mpc_val dst%mpc%mpc_const => src%mpc%mpc_const ! dst%node_group%n_grp = src%node_group%n_grp dst%node_group%n_bc = src%node_group%n_bc dst%node_group%grp_name => src%node_group%grp_name dst%node_group%grp_index => src%node_group%grp_index dst%node_group%grp_item => src%node_group%grp_item dst%node_group%bc_grp_ID => src%node_group%bc_grp_ID dst%node_group%bc_grp_type => src%node_group%bc_grp_type dst%node_group%bc_grp_index => src%node_group%bc_grp_index dst%node_group%bc_grp_dof => src%node_group%bc_grp_dof dst%node_group%bc_grp_val => src%node_group%bc_grp_val ! dst%node => src%node end subroutine hecmw_mpc_mesh_copy subroutine hecmw_mpc_mesh_free(hecMESH) implicit none type (hecmwST_local_mesh), intent(inout) :: hecMESH if (hecMESH%n_neighbor_pe > 1) then deallocate(hecMESH%neighbor_pe) deallocate(hecMESH%import_index) deallocate(hecMESH%export_index) deallocate(hecMESH%import_item) deallocate(hecMESH%export_item) endif deallocate(hecMESH%global_node_ID) deallocate(hecMESH%node_ID) deallocate(hecMESH%elem_type_item) end subroutine hecmw_mpc_mesh_free end module hecmw_mpc_prepost
mit
Hellybean/SaberMod_ROM_Toolchain
libgfortran/generated/_acosh_r16.F90
26
1484
! Copyright (C) 2002-2013 Free Software Foundation, Inc. ! Contributed by Paul Brook <paul@nowt.org> ! !This file is part of the GNU Fortran 95 runtime library (libgfortran). ! !GNU libgfortran is free software; you can redistribute it and/or !modify it under the terms of the GNU General Public !License as published by the Free Software Foundation; either !version 3 of the License, or (at your option) any later version. !GNU libgfortran is distributed in the hope that it will be useful, !but WITHOUT ANY WARRANTY; without even the implied warranty of !MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !GNU General Public License for more details. ! !Under Section 7 of GPL version 3, you are granted additional !permissions described in the GCC Runtime Library Exception, version !3.1, as published by the Free Software Foundation. ! !You should have received a copy of the GNU General Public License and !a copy of the GCC Runtime Library Exception along with this program; !see the files COPYING3 and COPYING.RUNTIME respectively. If not, see !<http://www.gnu.org/licenses/>. ! !This file is machine generated. #include "config.h" #include "kinds.inc" #include "c99_protos.inc" #if defined (HAVE_GFC_REAL_16) #ifdef HAVE_ACOSHL elemental function _gfortran_specific__acosh_r16 (parm) real (kind=16), intent (in) :: parm real (kind=16) :: _gfortran_specific__acosh_r16 _gfortran_specific__acosh_r16 = acosh (parm) end function #endif #endif
gpl-2.0
intervigilium/cs259-or32-gcc
gcc/testsuite/gfortran.dg/alloc_comp_assign_6.f90
38
1930
! { dg-do run } ! Tests the fix for pr32880, in which 'res' was deallocated ! before it could be used in the concatenation. ! Adapted from vst28.f95, in Lawrie Schonfeld's iso_varying_string ! testsuite, by Tobias Burnus. ! module iso_varying_string type varying_string character(LEN=1), dimension(:), allocatable :: chars end type varying_string interface assignment(=) module procedure op_assign_VS_CH end interface assignment(=) interface operator(//) module procedure op_concat_VS_CH end interface operator(//) contains elemental subroutine op_assign_VS_CH (var, exp) type(varying_string), intent(out) :: var character(LEN=*), intent(in) :: exp integer :: length integer :: i_char length = len(exp) allocate(var%chars(length)) forall(i_char = 1:length) var%chars(i_char) = exp(i_char:i_char) end forall end subroutine op_assign_VS_CH elemental function op_concat_VS_CH (string_a, string_b) result (concat_string) type(varying_string), intent(in) :: string_a character(LEN=*), intent(in) :: string_b type(varying_string) :: concat_string len_string_a = size(string_a%chars) allocate(concat_string%chars(len_string_a+len(string_b))) if (len_string_a >0) & concat_string%chars(:len_string_a) = string_a%chars if (len (string_b) > 0) & concat_string%chars(len_string_a+1:) = string_b end function op_concat_VS_CH end module iso_varying_string program VST28 use iso_varying_string character(len=10) :: char_a type(VARYING_STRING) :: res char_a = "abcdefghij" res = char_a(5:5) res = res//char_a(6:6) if(size(res%chars) /= 2 .or. any(res%chars /= ['e','f'])) then write(*,*) 'ERROR: should be ef, got: ', res%chars, size(res%chars) call abort () end if end program VST28 ! { dg-final { cleanup-modules "iso_varying_string" } }
gpl-2.0
parkin/hdf5.js
hdf5-1.8.12/hl/fortran/test/tstimage.f90
15
8986
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! 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 the FORTRAN90 tests for H5LT ! program image_test call make_image1() end program image_test !------------------------------------------------------------------------- ! make_image1 !------------------------------------------------------------------------- subroutine make_image1() use h5im ! module of H5IM use hdf5 ! module of HDF5 library implicit none character(len=8), parameter :: filename = "f1img.h5" ! file name character(len=4), parameter :: dsetname1 = "img1" ! dataset name character(len=4), parameter :: dsetname2 = "img2" ! dataset name character(len=15), parameter :: il ="INTERLACE_PIXEL"! dataset name integer(hid_t) :: file_id ! file identifier integer(hsize_t), parameter :: width = 500 ! width of image integer(hsize_t), parameter :: height = 200 ! height of image integer, parameter :: pal_entries = 9 ! palette number of entries integer, dimension(width*height) :: buf1 ! data buffer integer, dimension(width*height) :: bufr1 ! data buffer integer, dimension(width*height*3) :: buf2 ! data buffer integer, dimension(width*height*3) :: bufr2 ! data buffer integer(hsize_t) :: widthr ! width of image integer(hsize_t) :: heightr ! height of image integer(hsize_t) :: planesr ! color planes integer(hsize_t) :: npalsr ! palettes character(len=15) :: interlacer ! interlace integer :: errcode ! error flag integer :: is_image ! error flag integer :: i, j, n ! general purpose integers ! ! palette ! create a 9 entry palette ! character(len=4), parameter :: pal_name = "pal1" ! dataset name integer(hsize_t), dimension(2) :: pal_dims = (/pal_entries,3/) ! palette dimensions integer(hsize_t), dimension(2) :: pal_dims_out ! palette dimensions integer, dimension(pal_entries*3) :: pal_data_out ! data buffer integer(hsize_t) :: npals ! number of palettes integer :: pal_number ! palette number integer :: is_palette ! is palette integer :: space integer, dimension(pal_entries*3) :: pal_data_in = (/& 0,0,168,& ! dark blue 0,0,252,& ! blue 0,168,252,& ! ocean blue 84,252,252,& ! light blue 168,252,168,& ! light green 0,252,168,& ! green 252,252,84,& ! yellow 252,168,0,& ! orange 252,0,0/) ! red ! create an 8bit image of 9 values divided evenly by the array ! space = width*height / pal_entries; n = 0; j = 0; do i = 1, width*height buf1(i) = n if ( j > space ) then n = n + 1; j = 0; endif if (n>pal_entries-1) n=0; j = j +1; end do ! ! create a 3 byte rgb image ! n = 0; j = 0; do i = 1, width*height*3 buf2(i) = n; if (j == 3) then n = n + 1; j = 0; endif if (n>255) n=0; j = j +1; end do ! Initialize FORTRAN predefined datatypes. ! call h5open_f(errcode) ! ! Create a new file using default properties. ! call h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, errcode) !------------------------------------------------------------------------- ! indexed image !------------------------------------------------------------------------- call test_begin(' Make/Read image 8bit ') ! ! write image. ! call h5immake_image_8bit_f(file_id,dsetname1,width,height,buf1,errcode) ! ! read image. ! call h5imread_image_f(file_id,dsetname1,bufr1,errcode) ! ! compare read and write buffers. ! do i = 1, width*height if ( buf1(i) /= bufr1(i) ) then print *, 'read buffer differs from write buffer' print *, bufr1(i), ' and ', buf1(i) stop endif end do ! ! get image info. ! call h5imget_image_info_f(file_id,dsetname1,widthr,heightr,planesr,interlacer,npalsr,errcode) if ( (widthr /= widthr) .or. (heightr /= height) .or. (planesr /= 1)) then print *, 'h5imget_image_info_f bad value' stop endif is_image = h5imis_image_f(file_id,dsetname1) if ( is_image /= 1) then print *, 'h5imis_image_f bad value' stop endif call passed() !------------------------------------------------------------------------- ! true color image !------------------------------------------------------------------------- call test_begin(' Make/Read image 24bit ') ! ! write image. ! call h5immake_image_24bit_f(file_id,dsetname2,width,height,il,buf2,errcode) ! ! read image. ! call h5imread_image_f(file_id,dsetname2,bufr2,errcode) ! ! compare read and write buffers. ! do i = 1, width*height*3 if ( buf2(i) /= bufr2(i) ) then print *, 'read buffer differs from write buffer' print *, bufr2(i), ' and ', buf2(i) stop endif end do ! ! get image info. ! call h5imget_image_info_f(file_id,dsetname2,widthr,heightr,planesr,interlacer,npalsr,errcode) if ( (widthr /= widthr) .or. (heightr /= height) .or. (planesr /= 3)) then print *, 'h5imget_image_info_f bad value' stop endif is_image = h5imis_image_f(file_id,dsetname2) if ( is_image /= 1) then print *, 'h5imis_image_f bad value' stop endif call passed() !------------------------------------------------------------------------- ! palette !------------------------------------------------------------------------- call test_begin(' Make palette ') ! ! make palette. ! call h5immake_palette_f(file_id,pal_name,pal_dims,pal_data_in,errcode) call passed() call test_begin(' Link/Unlink palette ') ! ! link palette. ! call h5imlink_palette_f(file_id,dsetname1,pal_name,errcode) ! ! read palette. ! pal_number = 0 call h5imget_palette_f(file_id,dsetname1,pal_number,pal_data_out,errcode) ! ! compare read and write buffers. ! do i = 1, pal_entries*3 if ( pal_data_in(i) /= pal_data_out(i) ) then print *, 'read buffer differs from write buffer' print *, pal_data_in(i), ' and ', pal_data_out(i) stop endif end do ! ! get number of palettes ! call h5imget_npalettes_f(file_id,dsetname1,npals,errcode) if ( npals /= 1) then print *, 'h5imget_npalettes_f bad value' stop endif ! ! get palette info ! pal_number = 0 call h5imget_palette_info_f(file_id,dsetname1,pal_number,pal_dims_out,errcode) if ( (pal_dims_out(1) /= pal_dims(1)) .or. (pal_dims_out(2) /= pal_dims(2))) then print *, 'h5imget_palette_info_f bad value' stop endif ! ! is palette ! is_palette = h5imis_palette_f(file_id,pal_name) if ( is_palette /= 1 ) then print *, 'h5imis_palette_f bad value' stop endif ! ! unlink palette. ! call h5imunlink_palette_f(file_id,dsetname1,pal_name,errcode) ! ! get number of palettes ! call h5imget_npalettes_f(file_id,dsetname1,npals,errcode ) if ( npals /= 0) then print *, 'h5imget_npalettes_f bad value' stop endif ! ! link palette again ! call h5imlink_palette_f(file_id,dsetname1,pal_name,errcode) call passed() !------------------------------------------------------------------------- ! end !------------------------------------------------------------------------- ! ! Close the file. ! call h5fclose_f(file_id, errcode) ! ! Close FORTRAN predefined datatypes. ! call h5close_f(errcode) ! ! end function. ! end subroutine make_image1 !------------------------------------------------------------------------- ! test_begin !------------------------------------------------------------------------- subroutine test_begin(string) character(len=*), intent(in) :: string write(*, fmt = '(14a)', advance = 'no') string write(*, fmt = '(40x,a)', advance = 'no') ' ' end subroutine test_begin !------------------------------------------------------------------------- ! passed !------------------------------------------------------------------------- subroutine passed() write(*, fmt = '(6a)') 'PASSED' end subroutine passed
apache-2.0
intervigilium/cs259-or32-gcc
gcc/testsuite/gfortran.dg/graphite/pr40982.f90
140
3579
! { dg-options "-O3 -fgraphite-identity -floop-interchange " } module mqc_m implicit none private public :: mutual_ind_quad_cir_coil integer, parameter, private :: longreal = selected_real_kind(15,90) real (kind = longreal), parameter, private :: pi = 3.141592653589793_longreal real (kind = longreal), parameter, private :: small = 1.0e-10_longreal contains subroutine mutual_ind_quad_cir_coil (r_coil, x_coil, y_coil, z_coil, h_coil, n_coil, & rotate_coil, m, mu, l12) real (kind = longreal), intent(in) :: r_coil, x_coil, y_coil, z_coil, h_coil, n_coil, & mu real (kind = longreal), dimension(:,:), intent(in) :: rotate_coil integer, intent(in) :: m real (kind = longreal), intent(out) :: l12 real (kind = longreal), dimension(3,3) :: rotate_quad real (kind = longreal), dimension(9), save :: x2gauss, y2gauss, w2gauss, z1gauss, & w1gauss real (kind = longreal) :: xxvec, xyvec, xzvec, yxvec, yyvec, yzvec, zxvec, zyvec, & zzvec, magnitude, l12_lower, l12_upper, dx, dy, dz, theta, & a, b1, b2, numerator, denominator, coefficient, angle real (kind = longreal), dimension(3) :: c_vector, q_vector, rot_c_vector, & rot_q_vector, current_vector, & coil_current_vec, coil_tmp_vector integer :: i, j, k logical, save :: first = .true. do i = 1, 2*m theta = pi*real(i,longreal)/real(m,longreal) c_vector(1) = r_coil * cos(theta) c_vector(2) = r_coil * sin(theta) coil_tmp_vector(1) = -sin(theta) coil_tmp_vector(2) = cos(theta) coil_tmp_vector(3) = 0.0_longreal coil_current_vec(1) = dot_product(rotate_coil(1,:),coil_tmp_vector(:)) coil_current_vec(2) = dot_product(rotate_coil(2,:),coil_tmp_vector(:)) coil_current_vec(3) = dot_product(rotate_coil(3,:),coil_tmp_vector(:)) do j = 1, 9 c_vector(3) = 0.5 * h_coil * z1gauss(j) rot_c_vector(1) = dot_product(rotate_coil(1,:),c_vector(:)) + dx rot_c_vector(2) = dot_product(rotate_coil(2,:),c_vector(:)) + dy rot_c_vector(3) = dot_product(rotate_coil(3,:),c_vector(:)) + dz do k = 1, 9 q_vector(1) = 0.5_longreal * a * (x2gauss(k) + 1.0_longreal) q_vector(2) = 0.5_longreal * b1 * (y2gauss(k) - 1.0_longreal) q_vector(3) = 0.0_longreal rot_q_vector(1) = dot_product(rotate_quad(1,:),q_vector(:)) rot_q_vector(2) = dot_product(rotate_quad(2,:),q_vector(:)) rot_q_vector(3) = dot_product(rotate_quad(3,:),q_vector(:)) numerator = w1gauss(j) * w2gauss(k) * & dot_product(coil_current_vec,current_vector) denominator = sqrt(dot_product(rot_c_vector-rot_q_vector, & rot_c_vector-rot_q_vector)) l12_lower = l12_lower + numerator/denominator end do end do end do l12 = coefficient * (b1 * l12_lower + b2 * l12_upper) end subroutine mutual_ind_quad_cir_coil end module mqc_m
gpl-2.0
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.fortran-torture/execute/nan_inf_fmt.f90
162
2361
!pr 12839- F2003 formatting of Inf /Nan ! Modified for PR47434 implicit none character*40 l character*12 fmt real zero, pos_inf, neg_inf, nan zero = 0.0 ! need a better way of generating these floating point ! exceptional constants. pos_inf = 1.0/zero neg_inf = -1.0/zero nan = zero/zero ! check a field width = 0 fmt = '(F0.0)' write(l,fmt=fmt)pos_inf if (l.ne.'Inf') call abort write(l,fmt=fmt)neg_inf if (l.ne.'-Inf') call abort write(l,fmt=fmt)nan if (l.ne.'NaN') call abort ! check a field width < 3 fmt = '(F2.0)' write(l,fmt=fmt)pos_inf if (l.ne.'**') call abort write(l,fmt=fmt)neg_inf if (l.ne.'**') call abort write(l,fmt=fmt)nan if (l.ne.'**') call abort ! check a field width = 3 fmt = '(F3.0)' write(l,fmt=fmt)pos_inf if (l.ne.'Inf') call abort write(l,fmt=fmt)neg_inf if (l.ne.'***') call abort write(l,fmt=fmt)nan if (l.ne.'NaN') call abort ! check a field width > 3 fmt = '(F4.0)' write(l,fmt=fmt)pos_inf if (l.ne.' Inf') call abort write(l,fmt=fmt)neg_inf if (l.ne.'-Inf') call abort write(l,fmt=fmt)nan if (l.ne.' NaN') call abort ! check a field width = 7 fmt = '(F7.0)' write(l,fmt=fmt)pos_inf if (l.ne.' Inf') call abort write(l,fmt=fmt)neg_inf if (l.ne.' -Inf') call abort write(l,fmt=fmt)nan if (l.ne.' NaN') call abort ! check a field width = 8 fmt = '(F8.0)' write(l,fmt=fmt)pos_inf if (l.ne.'Infinity') call abort write(l,fmt=fmt)neg_inf if (l.ne.' -Inf') call abort write(l,fmt=fmt)nan if (l.ne.' NaN') call abort ! check a field width = 9 fmt = '(F9.0)' write(l,fmt=fmt)pos_inf if (l.ne.' Infinity') call abort write(l,fmt=fmt)neg_inf if (l.ne.'-Infinity') call abort write(l,fmt=fmt)nan if (l.ne.' NaN') call abort ! check a field width = 14 fmt = '(F14.0)' write(l,fmt=fmt)pos_inf if (l.ne.' Infinity') call abort write(l,fmt=fmt)neg_inf if (l.ne.' -Infinity') call abort write(l,fmt=fmt)nan if (l.ne.' NaN') call abort end
gpl-2.0
intervigilium/cs259-or32-gcc
gcc/testsuite/gfortran.dg/der_io_2.f90
52
1032
! { dg-do compile } ! PR 23843 ! IO of derived types with private components is allowed in the module itself, ! but not elsewhere module gfortran2 type :: tp1 private integer :: i end type tp1 type :: tp1b integer :: i end type tp1b type :: tp2 real :: a type(tp1) :: t end type tp2 contains subroutine test() type(tp1) :: x type(tp2) :: y write (*, *) x write (*, *) y end subroutine test end module gfortran2 program prog use gfortran2 implicit none type :: tp3 type(tp2) :: t end type tp3 type :: tp3b type(tp1b) :: t end type tp3b type(tp1) :: x type(tp2) :: y type(tp3) :: z type(tp3b) :: zb write (*, *) x ! { dg-error "PRIVATE components" } write (*, *) y ! { dg-error "PRIVATE components" } write (*, *) z ! { dg-error "PRIVATE components" } write (*, *) zb end program prog ! { dg-final { cleanup-modules "gfortran2" } }
gpl-2.0
alongwithyou/rnnlib
hdf5_snap/fortran/test/tH5S.f90
8
11286
!****h* root/fortran/test/tH5S.f90 ! ! NAME ! tH5S.f90 ! ! FUNCTION ! Basic testing of Fortran H5S, Dataspace Interface, APIs. ! ! COPYRIGHT ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! 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. * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! ! NOTES ! Tests the following functionalities: ! h5screate_f, h5scopy_f, h5screate_simple_f, h5sis_simple_f, ! h5sget_simple_extent_dims_f,h5sget_simple_extent_ndims_f ! h5sget_simple_extent_npoints_f, h5sget_simple_extent_type_f, ! h5sextent_copy_f, h5sset_extent_simple_f, h5sset_extent_none_f ! ! CONTAINS SUBROUTINES ! dataspace_basic_test ! !***** MODULE TH5S CONTAINS SUBROUTINE dataspace_basic_test(cleanup, total_error) USE HDF5 ! This module contains all necessary modules USE TH5_MISC IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(INOUT) :: total_error CHARACTER(LEN=10), PARAMETER :: filename1 = "basicspace" ! File1 name CHARACTER(LEN=9), PARAMETER :: filename2 = "copyspace" ! File2 name CHARACTER(LEN=80) :: fix_filename1 CHARACTER(LEN=80) :: fix_filename2 CHARACTER(LEN=9), PARAMETER :: dsetname = "basicdset" ! Dataset name INTEGER(HID_T) :: file1_id, file2_id ! File identifiers INTEGER(HID_T) :: dset1_id, dset2_id ! Dataset identifiers INTEGER(HID_T) :: space1_id, space2_id ! Dataspace identifiers INTEGER(HSIZE_T), DIMENSION(2) :: dims1 = (/4,6/) ! Dataset dimensions INTEGER(HSIZE_T), DIMENSION(2) :: maxdims1 = (/4,6/) ! maximum dimensions INTEGER(HSIZE_T), DIMENSION(2) :: dims2 = (/6,6/) ! Dataset dimensions INTEGER(HSIZE_T), DIMENSION(2) :: maxdims2 = (/6,6/) ! maximum dimensions INTEGER(HSIZE_T), DIMENSION(2) :: dimsout, maxdimsout ! dimensions INTEGER(HSIZE_T) :: npoints !number of elements in the dataspace INTEGER :: rank1 = 2 ! Dataspace1 rank INTEGER :: rank2 = 2 ! Dataspace2 rank INTEGER :: classtype ! Dataspace class type INTEGER, DIMENSION(4,6) :: data1_in, data1_out ! Data input buffers INTEGER, DIMENSION(6,6) :: data2_in, data2_out ! Data output buffers INTEGER :: error ! Error flag LOGICAL :: flag !flag to test datyspace is simple or not INTEGER :: i, j !general purpose integers INTEGER(HSIZE_T), DIMENSION(2) :: data_dims ! ! Initialize the dset_data array. ! do i = 1, 4 do j = 1, 6 data1_in(i,j) = (i-1)*6 + j; end do end do do i = 1, 6 do j = 1, 6 data2_in(i,j) = i*6 + j; end do end do ! ! Initialize FORTRAN predefined datatypes. ! ! CALL h5init_types_f(error) ! CALL check("h5init_types_f", error, total_error) ! ! Create new files using default properties. ! CALL h5_fixname_f(filename1, fix_filename1, H5P_DEFAULT_F, error) if (error .ne. 0) then write(*,*) "Cannot modify filename" stop endif CALL h5fcreate_f(fix_filename1, H5F_ACC_TRUNC_F, file1_id, error) CALL check("h5fcreate_f", error, total_error) CALL h5_fixname_f(filename2, fix_filename2, H5P_DEFAULT_F, error) if (error .ne. 0) then write(*,*) "Cannot modify filename" stop endif CALL h5fcreate_f(fix_filename2, H5F_ACC_TRUNC_F, file2_id, error) CALL check("h5fcreate_f", error, total_error) ! ! Create dataspace for file1. ! CALL h5screate_simple_f(rank1, dims1, space1_id, error, maxdims1) CALL check("h5screate_simple_f", error, total_error) ! ! Copy space1_id to space2_id. ! CALL h5scopy_f(space1_id, space2_id, error) CALL check("h5scopy_f", error, total_error) ! !Check whether copied space is simple. ! CALL h5sis_simple_f(space2_id, flag, error) CALL check("h5sissimple_f", error, total_error) IF (.NOT. flag) write(*,*) "dataspace is not simple type" ! !set the copied space to none. ! CALL h5sset_extent_none_f(space2_id, error) CALL check("h5sset_extent_none_f", error, total_error) ! !copy the extent of space1_id to space2_id. ! CALL h5sextent_copy_f(space2_id, space1_id, error) CALL check("h5sextent_copy_f", error, total_error) ! !get the copied space's dimensions. ! CALL h5sget_simple_extent_dims_f(space2_id, dimsout, maxdimsout, error) CALL check("h5sget_simple_extent_dims_f", error, total_error) IF ((dimsout(1) .NE. dims1(1)) .OR. (dimsout(2) .NE. dims1(2)) ) THEN write(*,*)"error occured, copied dims not same" END IF ! !get the copied space's rank. ! CALL h5sget_simple_extent_ndims_f(space2_id, rank2, error) CALL check("h5sget_simple_extent_ndims_f", error, total_error) IF (rank2 .NE. rank1) write(*,*)"error occured, copied ranks not same" ! !get the copied space's number of elements. ! CALL h5sget_simple_extent_npoints_f(space2_id, npoints, error) CALL check("h5sget_simple_extent_npoints_f", error, total_error) IF (npoints .NE. 24) write(*,*)"error occured, number of elements not correct" ! !get the copied space's class type. ! CALL h5sget_simple_extent_type_f(space2_id, classtype, error) CALL check("h5sget_simple_extent_type_f", error, total_error) IF (classtype .NE. 1) write(*,*)"class type not H5S_SIMPLE_f" ! !set the copied space to none before extend the dimensions. ! CALL h5sset_extent_none_f(space2_id, error) CALL check("h5sset_extent_none_f", error, total_error) ! !set the copied space to dim2 size. ! CALL h5sset_extent_simple_f(space2_id, rank2, dims2, maxdims2, error) CALL check("h5sset_extent_simple_f", error, total_error) ! !get the copied space's dimensions. ! CALL h5sget_simple_extent_dims_f(space2_id, dimsout, maxdimsout, error) CALL check("h5sget_simple_extent_dims_f", error, total_error) IF ((dimsout(1) .NE. dims2(1)) .OR. (dimsout(2) .NE. dims2(2)) ) THEN write(*,*)"error occured, copied dims not same" END IF ! ! Create the datasets with default properties in two files. ! CALL h5dcreate_f(file1_id, dsetname, H5T_NATIVE_INTEGER, space1_id, & dset1_id, error) CALL check("h5dcreate_f", error, total_error) CALL h5dcreate_f(file2_id, dsetname, H5T_NATIVE_INTEGER, space2_id, & dset2_id, error) CALL check("h5dcreate_f", error, total_error) ! ! Write the datasets. ! data_dims(1) = 4 data_dims(2) = 6 CALL h5dwrite_f(dset1_id, H5T_NATIVE_INTEGER, data1_in, data_dims, error) CALL check("h5dwrite_f", error, total_error) data_dims(1) = 6 data_dims(2) = 6 CALL h5dwrite_f(dset2_id, H5T_NATIVE_INTEGER, data2_in, data_dims, error) CALL check("h5dwrite_f", error, total_error) ! ! Read the first dataset. ! data_dims(1) = 4 data_dims(2) = 6 CALL h5dread_f(dset1_id, H5T_NATIVE_INTEGER, data1_out, data_dims, error) CALL check("h5dread_f", error, total_error) ! !Compare the data. ! do i = 1, 4 do j = 1, 6 IF (data1_out(i,j) .NE. data1_in(i, j)) THEN write(*, *) "dataset test error occured" write(*,*) "data read is not the same as the data writen" END IF end do end do ! ! Read the second dataset. ! data_dims(1) = 6 data_dims(2) = 6 CALL h5dread_f(dset2_id, H5T_NATIVE_INTEGER, data2_out, data_dims, error) CALL check("h5dread_f", error, total_error) ! !Compare the data. ! do i = 1, 6 do j = 1, 6 IF (data2_out(i,j) .NE. data2_in(i, j)) THEN write(*, *) "dataset test error occured" write(*,*) "data read is not the same as the data writen" END IF end do end do ! !Close the datasets. ! CALL h5dclose_f(dset1_id, error) CALL check("h5dclose_f", error, total_error) CALL h5dclose_f(dset2_id, error) CALL check("h5dclose_f", error, total_error) ! ! Terminate access to the data spaces. ! CALL h5sclose_f(space1_id, error) CALL check("h5sclose_f", error, total_error) CALL h5sclose_f(space2_id, error) CALL check("h5sclose_f", error, total_error) ! ! Close the files. ! CALL h5fclose_f(file1_id, error) CALL check("h5fclose_f", error, total_error) CALL h5fclose_f(file2_id, error) CALL check("h5fclose_f", error, total_error) if(cleanup) CALL h5_cleanup_f(filename1, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) if(cleanup) CALL h5_cleanup_f(filename2, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) RETURN END SUBROUTINE dataspace_basic_test END MODULE TH5S
gpl-3.0
tuxillo/aarch64-dragonfly-gcc
libgomp/testsuite/libgomp.fortran/vla3.f90
202
7527
! { dg-do run } call test contains subroutine check (x, y, l) integer :: x, y logical :: l l = l .or. x .ne. y end subroutine check subroutine foo (c, d, e, f, g, h, i, j, k, n) use omp_lib integer :: n character (len = *) :: c character (len = n) :: d integer, dimension (2, 3:5, n) :: e integer, dimension (2, 3:n, n) :: f character (len = *), dimension (5, 3:n) :: g character (len = n), dimension (5, 3:n) :: h real, dimension (:, :, :) :: i double precision, dimension (3:, 5:, 7:) :: j integer, dimension (:, :, :) :: k logical :: l integer :: p, q, r character (len = n) :: s integer, dimension (2, 3:5, n) :: t integer, dimension (2, 3:n, n) :: u character (len = n), dimension (5, 3:n) :: v character (len = 2 * n + 24) :: w integer :: x, z character (len = 1) :: y s = 'PQRSTUV' forall (p = 1:2, q = 3:5, r = 1:7) t(p, q, r) = -10 + p - q + 2 * r forall (p = 1:2, q = 3:7, r = 1:7) u(p, q, r) = 30 - p + q - 2 * r forall (p = 1:5, q = 3:7, p + q .le. 8) v(p, q) = '_+|/Oo_' forall (p = 1:5, q = 3:7, p + q .gt. 8) v(p, q) = '///|||!' l = .false. !$omp parallel default (none) shared (c, d, e, f, g, h, i, j, k) & !$omp & shared (s, t, u, v) reduction (.or.:l) num_threads (6) & !$omp private (p, q, r, w, x, y) l = l .or. c .ne. 'abcdefghijkl' l = l .or. d .ne. 'ABCDEFG' l = l .or. s .ne. 'PQRSTUV' do 100, p = 1, 2 do 100, q = 3, 7 do 100, r = 1, 7 if (q .lt. 6) l = l .or. e(p, q, r) .ne. 5 + p + q + 2 * r l = l .or. f(p, q, r) .ne. 25 + p + q + 2 * r if (r .lt. 6 .and. q + r .le. 8) l = l .or. g(r, q) .ne. '0123456789AB' if (r .lt. 6 .and. q + r .gt. 8) l = l .or. g(r, q) .ne. '9876543210ZY' if (r .lt. 6 .and. q + r .le. 8) l = l .or. h(r, q) .ne. '0123456' if (r .lt. 6 .and. q + r .gt. 8) l = l .or. h(r, q) .ne. '9876543' if (q .lt. 6) l = l .or. t(p, q, r) .ne. -10 + p - q + 2 * r l = l .or. u(p, q, r) .ne. 30 - p + q - 2 * r if (r .lt. 6 .and. q + r .le. 8) l = l .or. v(r, q) .ne. '_+|/Oo_' if (r .lt. 6 .and. q + r .gt. 8) l = l .or. v(r, q) .ne. '///|||!' 100 continue do 101, p = 3, 5 do 101, q = 2, 6 do 101, r = 1, 7 l = l .or. i(p - 2, q - 1, r) .ne. 7.5 * p * q * r l = l .or. j(p, q + 3, r + 6) .ne. 9.5 * p * q * r 101 continue do 102, p = 1, 5 do 102, q = 4, 6 l = l .or. k(p, 1, q - 3) .ne. 19 + p + 7 + 3 * q 102 continue do 110 z = 0, omp_get_num_threads () - 1 !$omp barrier x = omp_get_thread_num () w = '' if (z .eq. 0) w = 'thread0thr_number_0THREAD0THR_NUMBER_0' if (z .eq. 1) w = 'thread1thr_number_1THREAD1THR_NUMBER_1' if (z .eq. 2) w = 'thread2thr_number_2THREAD2THR_NUMBER_2' if (z .eq. 3) w = 'thread3thr_number_3THREAD3THR_NUMBER_3' if (z .eq. 4) w = 'thread4thr_number_4THREAD4THR_NUMBER_4' if (z .eq. 5) w = 'thread5thr_number_5THREAD5THR_NUMBER_5' if (x .eq. z) then c = w(8:19) d = w(1:7) forall (p = 1:2, q = 3:5, r = 1:7) e(p, q, r) = 5 * x + p + q + 2 * r forall (p = 1:2, q = 3:7, r = 1:7) f(p, q, r) = 25 * x + p + q + 2 * r forall (p = 1:5, q = 3:7, p + q .le. 8) g(p, q) = w(8:19) forall (p = 1:5, q = 3:7, p + q .gt. 8) g(p, q) = w(27:38) forall (p = 1:5, q = 3:7, p + q .le. 8) h(p, q) = w(1:7) forall (p = 1:5, q = 3:7, p + q .gt. 8) h(p, q) = w(20:26) forall (p = 3:5, q = 2:6, r = 1:7) i(p - 2, q - 1, r) = (7.5 + x) * p * q * r forall (p = 3:5, q = 2:6, r = 1:7) j(p, q + 3, r + 6) = (9.5 + x) * p * q * r forall (p = 1:5, q = 7:7, r = 4:6) k(p, q - 6, r - 3) = 19 + x + p + q + 3 * r s = w(20:26) forall (p = 1:2, q = 3:5, r = 1:7) t(p, q, r) = -10 + x + p - q + 2 * r forall (p = 1:2, q = 3:7, r = 1:7) u(p, q, r) = 30 - x - p + q - 2 * r forall (p = 1:5, q = 3:7, p + q .le. 8) v(p, q) = w(1:7) forall (p = 1:5, q = 3:7, p + q .gt. 8) v(p, q) = w(20:26) end if !$omp barrier x = z y = '' if (x .eq. 0) y = '0' if (x .eq. 1) y = '1' if (x .eq. 2) y = '2' if (x .eq. 3) y = '3' if (x .eq. 4) y = '4' if (x .eq. 5) y = '5' l = l .or. w(7:7) .ne. y l = l .or. w(19:19) .ne. y l = l .or. w(26:26) .ne. y l = l .or. w(38:38) .ne. y l = l .or. c .ne. w(8:19) l = l .or. d .ne. w(1:7) l = l .or. s .ne. w(20:26) do 103, p = 1, 2 do 103, q = 3, 7 do 103, r = 1, 7 if (q .lt. 6) l = l .or. e(p, q, r) .ne. 5 * x + p + q + 2 * r l = l .or. f(p, q, r) .ne. 25 * x + p + q + 2 * r if (r .lt. 6 .and. q + r .le. 8) l = l .or. g(r, q) .ne. w(8:19) if (r .lt. 6 .and. q + r .gt. 8) l = l .or. g(r, q) .ne. w(27:38) if (r .lt. 6 .and. q + r .le. 8) l = l .or. h(r, q) .ne. w(1:7) if (r .lt. 6 .and. q + r .gt. 8) l = l .or. h(r, q) .ne. w(20:26) if (q .lt. 6) l = l .or. t(p, q, r) .ne. -10 + x + p - q + 2 * r l = l .or. u(p, q, r) .ne. 30 - x - p + q - 2 * r if (r .lt. 6 .and. q + r .le. 8) l = l .or. v(r, q) .ne. w(1:7) if (r .lt. 6 .and. q + r .gt. 8) l = l .or. v(r, q) .ne. w(20:26) 103 continue do 104, p = 3, 5 do 104, q = 2, 6 do 104, r = 1, 7 l = l .or. i(p - 2, q - 1, r) .ne. (7.5 + x) * p * q * r l = l .or. j(p, q + 3, r + 6) .ne. (9.5 + x) * p * q * r 104 continue do 105, p = 1, 5 do 105, q = 4, 6 l = l .or. k(p, 1, q - 3) .ne. 19 + x + p + 7 + 3 * q 105 continue 110 continue call check (size (e, 1), 2, l) call check (size (e, 2), 3, l) call check (size (e, 3), 7, l) call check (size (e), 42, l) call check (size (f, 1), 2, l) call check (size (f, 2), 5, l) call check (size (f, 3), 7, l) call check (size (f), 70, l) call check (size (g, 1), 5, l) call check (size (g, 2), 5, l) call check (size (g), 25, l) call check (size (h, 1), 5, l) call check (size (h, 2), 5, l) call check (size (h), 25, l) call check (size (i, 1), 3, l) call check (size (i, 2), 5, l) call check (size (i, 3), 7, l) call check (size (i), 105, l) call check (size (j, 1), 4, l) call check (size (j, 2), 5, l) call check (size (j, 3), 7, l) call check (size (j), 140, l) call check (size (k, 1), 5, l) call check (size (k, 2), 1, l) call check (size (k, 3), 3, l) call check (size (k), 15, l) !$omp end parallel if (l) call abort end subroutine foo subroutine test character (len = 12) :: c character (len = 7) :: d integer, dimension (2, 3:5, 7) :: e integer, dimension (2, 3:7, 7) :: f character (len = 12), dimension (5, 3:7) :: g character (len = 7), dimension (5, 3:7) :: h real, dimension (3:5, 2:6, 1:7) :: i double precision, dimension (3:6, 2:6, 1:7) :: j integer, dimension (1:5, 7:7, 4:6) :: k integer :: p, q, r c = 'abcdefghijkl' d = 'ABCDEFG' forall (p = 1:2, q = 3:5, r = 1:7) e(p, q, r) = 5 + p + q + 2 * r forall (p = 1:2, q = 3:7, r = 1:7) f(p, q, r) = 25 + p + q + 2 * r forall (p = 1:5, q = 3:7, p + q .le. 8) g(p, q) = '0123456789AB' forall (p = 1:5, q = 3:7, p + q .gt. 8) g(p, q) = '9876543210ZY' forall (p = 1:5, q = 3:7, p + q .le. 8) h(p, q) = '0123456' forall (p = 1:5, q = 3:7, p + q .gt. 8) h(p, q) = '9876543' forall (p = 3:5, q = 2:6, r = 1:7) i(p, q, r) = 7.5 * p * q * r forall (p = 3:6, q = 2:6, r = 1:7) j(p, q, r) = 9.5 * p * q * r forall (p = 1:5, q = 7:7, r = 4:6) k(p, q, r) = 19 + p + q + 3 * r call foo (c, d, e, f, g, h, i, j, k, 7) end subroutine test end
gpl-2.0
ovilab/atomify-lammps
libs/lammps/tools/chain.f
34
8319
c Create LAMMPS data file for collection of c polymer bead-spring chains of various lengths and bead sizes c Syntax: chain < def.chain > data.file c def.chain is input file that specifies the chains c data.file is output file that will be input for LAMMPS c includes image flags in data file so chains can be unraveled later program chain integer swaptype integer, allocatable :: nchain(:),nmonomer(:) integer, allocatable :: ntype(:),nbondtype(:) integer, allocatable :: type(:),molecule(:) integer, allocatable :: imagex(:),imagey(:),imagez(:) real*8, allocatable :: x(:),y(:),z(:) real*8, allocatable :: bondlength(:),restrict(:) common xprd,yprd,zprd,xboundlo,xboundhi, $ yboundlo,yboundhi,zboundlo,zboundhi real*8 random 900 format(a) 901 format(2f15.6,a) 902 format(i3,f5.1) 903 format(i10,i8,i8,3f10.4,3i4) 904 format(i9,i3,2i9) c read chain definitions read (5,*) read (5,*) read (5,*) rhostar read (5,*) iseed read (5,*) nsets read (5,*) swaptype allocate(nchain(nsets)) allocate(nmonomer(nsets)) allocate(ntype(nsets)) allocate(nbondtype(nsets)) allocate(bondlength(nsets)) allocate(restrict(nsets)) do iset = 1,nsets read (5,*) read (5,*) nchain(iset) read (5,*) nmonomer(iset) read (5,*) ntype(iset) read (5,*) nbondtype(iset) read (5,*) bondlength(iset) read (5,*) restrict(iset) enddo c natoms = total # of monomers natoms = 0 do iset = 1,nsets natoms = natoms + nchain(iset)*nmonomer(iset) enddo allocate(x(natoms)) allocate(y(natoms)) allocate(z(natoms)) allocate(type(natoms)) allocate(molecule(natoms)) allocate(imagex(natoms)) allocate(imagey(natoms)) allocate(imagez(natoms)) c setup box size (sigma = 1.0) volume = natoms/rhostar xprd = volume**(1.0/3.0) yprd = xprd zprd = xprd xboundlo = -xprd/2.0 xboundhi = -xboundlo yboundlo = xboundlo yboundhi = xboundhi zboundlo = xboundlo zboundhi = xboundhi c generate random chains c loop over sets and chains in each set n = 0 nmolecule = 0 do iset = 1,nsets do ichain = 1,nchain(iset) nmolecule = nmolecule + 1 c random starting point for the chain in the box x1 = 0.0 y1 = 0.0 z1 = 0.0 x2 = xboundlo + random(iseed)*xprd y2 = yboundlo + random(iseed)*yprd z2 = zboundlo + random(iseed)*zprd c store 1st monomer of chain c 1st monomer is always in original box (image = 0) call pbc(x2,y2,z2) n = n + 1 x(n) = x2 y(n) = y2 z(n) = z2 type(n) = ntype(iset) imagex(n) = 0 imagey(n) = 0 imagez(n) = 0 if (swaptype == 0) then molecule(n) = nmolecule else molecule(n) = 1 endif c generate rest of monomers in this chain do imonomer = 2,nmonomer(iset) x0 = x1 y0 = y1 z0 = z1 x1 = x2 y1 = y2 z1 = z2 c random point inside sphere of unit radius 10 xinner = 2.0*random(iseed) - 1.0 yinner = 2.0*random(iseed) - 1.0 zinner = 2.0*random(iseed) - 1.0 rsq = xinner*xinner + yinner*yinner + zinner*zinner if (rsq > 1.0) goto 10 c project point to surface of sphere of unit radius r = sqrt(rsq) xsurf = xinner/r ysurf = yinner/r zsurf = zinner/r c create new point by scaling unit offsets by bondlength (sigma = 1.0) x2 = x1 + xsurf*bondlength(iset) y2 = y1 + ysurf*bondlength(iset) z2 = z1 + zsurf*bondlength(iset) c check that new point meets restriction requirement c only for 3rd monomer and beyond dx = x2 - x0 dy = y2 - y0 dz = z2 - z0 r = sqrt(dx*dx + dy*dy + dz*dz) if (imonomer > 2 .and. r <= restrict(iset)) goto 10 c store new point c if delta to previous bead is large, then increment/decrement image flag call pbc(x2,y2,z2) n = n + 1 x(n) = x2 y(n) = y2 z(n) = z2 type(n) = ntype(iset) if (abs(x(n)-x(n-1)) < 2.0*bondlength(iset)) then imagex(n) = imagex(n-1) else if (x(n) - x(n-1) < 0.0) then imagex(n) = imagex(n-1) + 1 else if (x(n) - x(n-1) > 0.0) then imagex(n) = imagex(n-1) - 1 endif if (abs(y(n)-y(n-1)) < 2.0*bondlength(iset)) then imagey(n) = imagey(n-1) else if (y(n) - y(n-1) < 0.0) then imagey(n) = imagey(n-1) + 1 else if (y(n) - y(n-1) > 0.0) then imagey(n) = imagey(n-1) - 1 endif if (abs(z(n)-z(n-1)) < 2.0*bondlength(iset)) then imagez(n) = imagez(n-1) else if (z(n) - z(n-1) < 0.0) then imagez(n) = imagez(n-1) + 1 else if (z(n) - z(n-1) > 0.0) then imagez(n) = imagez(n-1) - 1 endif if (swaptype == 0) then molecule(n) = nmolecule else if (swaptype == 1) then molecule(n) = imonomer else if (swaptype == 2) then if (imonomer <= nmonomer(iset)/2) then molecule(n) = imonomer else molecule(n) = nmonomer(iset)+1-imonomer endif endif enddo enddo enddo c compute quantities needed for LAMMPS file nbonds = 0 ntypes = 0 nbondtypes = 0 do iset = 1,nsets nbonds = nbonds + nchain(iset)*(nmonomer(iset)-1) if (ntype(iset) > ntypes) ntypes = ntype(iset) if (nbondtype(iset) > nbondtypes) $ nbondtypes = nbondtype(iset) enddo c write out LAMMPS file write (6,900) 'LAMMPS FENE chain data file' write (6,*) write (6,*) natoms,' atoms' write (6,*) nbonds,' bonds' write (6,*) 0,' angles' write (6,*) 0,' dihedrals' write (6,*) 0,' impropers' write (6,*) write (6,*) ntypes,' atom types' write (6,*) nbondtypes,' bond types' write (6,*) 0,' angle types' write (6,*) 0,' dihedral types' write (6,*) 0,' improper types' write (6,*) write (6,901) xboundlo,xboundhi,' xlo xhi' write (6,901) yboundlo,yboundhi,' ylo yhi' write (6,901) zboundlo,zboundhi,' zlo zhi' write (6,*) write (6,900) 'Masses' write (6,*) do i = 1,ntypes write (6,902) i,1.0 enddo write (6,*) write (6,900) 'Atoms' write (6,*) do i = 1,natoms write (6,903) i,molecule(i),type(i),x(i),y(i),z(i), $ imagex(i),imagey(i),imagez(i) enddo if (nbonds > 0) then write (6,*) write (6,900) 'Bonds' write (6,*) n = 0 m = 0 do iset = 1,nsets do ichain = 1,nchain(iset) do imonomer = 1,nmonomer(iset) n = n + 1 if (imonomer /= nmonomer(iset)) then m = m + 1 write (6,904) m,nbondtype(iset),n,n+1 endif enddo enddo enddo endif end c ************ c Subroutines c ************ c periodic boundary conditions - map atom back into periodic box subroutine pbc(x,y,z) common xprd,yprd,zprd,xboundlo,xboundhi, $ yboundlo,yboundhi,zboundlo,zboundhi if (x < xboundlo) x = x + xprd if (x >= xboundhi) x = x - xprd if (y < yboundlo) y = y + yprd if (y >= yboundhi) y = y - yprd if (z < zboundlo) z = z + zprd if (z >= zboundhi) z = z - zprd return end c RNG from Numerical Recipes real*8 function random(iseed) real*8 aa,mm,sseed parameter (aa=16807.0D0,mm=2147483647.0D0) sseed = iseed sseed = mod(aa*sseed,mm) random = sseed/mm iseed = sseed return end
gpl-3.0
Hellybean/SaberMod_ROM_Toolchain
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
Hellybean/SaberMod_ROM_Toolchain
gcc/testsuite/gfortran.dg/entry_13.f90
136
1751
! { dg-do run } ! Tests the fix for pr31214, in which the typespec for the entry would be lost, ! thereby causing the function to be disallowed, since the function and entry ! types did not match. ! ! Contributed by Joost VandeVondele <jv244@cam.ac.uk> ! module type_mod implicit none type x real x end type x type y real x end type y type z real x end type z interface assignment(=) module procedure equals end interface assignment(=) interface operator(//) module procedure a_op_b, b_op_a end interface operator(//) interface operator(==) module procedure a_po_b, b_po_a end interface operator(==) contains subroutine equals(x,y) type(z), intent(in) :: y type(z), intent(out) :: x x%x = y%x end subroutine equals function a_op_b(a,b) type(x), intent(in) :: a type(y), intent(in) :: b type(z) a_op_b type(z) b_op_a a_op_b%x = a%x + b%x return entry b_op_a(b,a) b_op_a%x = a%x - b%x end function a_op_b function a_po_b(a,b) type(x), intent(in) :: a type(y), intent(in) :: b type(z) a_po_b type(z) b_po_a entry b_po_a(b,a) a_po_b%x = a%x/b%x end function a_po_b end module type_mod program test use type_mod implicit none type(x) :: x1 = x(19.0_4) type(y) :: y1 = y(7.0_4) type(z) z1 z1 = x1//y1 if (abs(z1%x - (19.0_4 + 7.0_4)) > epsilon(x1%x)) call abort () z1 = y1//x1 if (abs(z1%x - (19.0_4 - 7.0_4)) > epsilon(x1%x)) call abort () z1 = x1==y1 if (abs(z1%x - 19.0_4/7.0_4) > epsilon(x1%x)) call abort () z1 = y1==x1 if (abs(z1%x - 19.0_4/7.0_4) > epsilon(x1%x)) call abort () end program test
gpl-2.0
Hellybean/SaberMod_ROM_Toolchain
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
intervigilium/cs259-or32-gcc
gcc/testsuite/gfortran.dg/nested_forall_1.f
38
1050
! { dg-do compile } ! ! PR fortran/35820 ! ! Memory leak(s) while resolving forall constructs. ! ! Contributed by Dick Hendrickson <dick.hendrickson@gmail.com> MODULE TESTS INTEGER,PARAMETER,PUBLIC :: I1_KV = KIND(1) INTEGER,PARAMETER,PUBLIC :: R1_KV = KIND(1.0) INTEGER, PRIVATE :: J1,J2 INTEGER,PARAMETER,PUBLIC :: S1 = 10, S2 = 9 CONTAINS SUBROUTINE SA0136(RDA,IDA,BDA) REAL(R1_KV) RDA(S1) INTEGER(I1_KV) IDA(S1,S2) INTEGER(I1_KV) ICA(S1,S2) REAL(R1_KV) RCA(S1) ! T E S T S T A T E M E N T S FORALL (J1 = 1:S1) RDA(J1) = RCA(J1) + 1.0_R1_KV FORALL (J2 = 1:S2) IDA(J1,J2) = ICA(J1,J2) + 1 END FORALL FORALL (J2 = 1:S2) IDA(J1,J2) = ICA(J1,J2) END FORALL ENDFORALL FORALL (J1 = 1:S1) RDA(J1) = RCA(J1) FORALL (J2 = 1:S2) IDA(J1,J2) = ICA(J1,J2) END FORALL END FORALL END SUBROUTINE END MODULE TESTS ! { dg-final { cleanup-modules "tests" } }
gpl-2.0
Hellybean/SaberMod_ROM_Toolchain
gcc/testsuite/gfortran.dg/vect/vect-5.f90
96
1284
! { dg-require-effective-target vect_int } Subroutine foo (N, M) Integer N Integer M integer A(8,16) integer B(8) B = (/ 2, 3, 5, 7, 11, 13, 17, 23 /) ! Unknown loop bound. J depends on I. do I = 1, N do J = I, M A(J,2) = B(J) end do end do do I = 1, N do J = I, M if (A(J,2) /= B(J)) then call abort () endif end do end do Return end program main Call foo (16, 8) stop end ! { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } ! { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail { vect_no_align || {! vector_alignment_reachable} } } } } ! { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { vect_no_align } } } } ! { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 2 "vect" { target { vect_no_align } } } } ! { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target { {! vector_alignment_reachable} && {! vect_hw_misalign} } } } } ! { dg-final { cleanup-tree-dump "vect" } }
gpl-2.0
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/entry_16.f90
144
1042
! { dg-do run } ! Tests the fix for PR33499 in which the ENTRY cx_radc was not ! getting its TYPE. ! ! Contributed by Michael Richmond <michael.a.richmond@nasa.gov> ! MODULE complex IMPLICIT NONE PRIVATE PUBLIC :: cx, OPERATOR(+), OPERATOR(.eq.) TYPE cx integer :: re integer :: im END TYPE cx INTERFACE OPERATOR (+) MODULE PROCEDURE cx_cadr, cx_radc END INTERFACE INTERFACE OPERATOR (.eq.) MODULE PROCEDURE cx_eq END INTERFACE CONTAINS FUNCTION cx_cadr(z, r) ENTRY cx_radc(r, z) TYPE (cx) :: cx_cadr, cx_radc TYPE (cx), INTENT(IN) :: z integer, INTENT(IN) :: r cx_cadr%re = z%re + r cx_cadr%im = z%im END FUNCTION cx_cadr FUNCTION cx_eq(u, v) TYPE (cx), INTENT(IN) :: u, v logical :: cx_eq cx_eq = (u%re .eq. v%re) .and. (u%im .eq. v%im) END FUNCTION cx_eq END MODULE complex use complex type(cx) :: a = cx (1, 2), c, d logical :: f integer :: b = 3 if (.not.((a + b) .eq. (b + a))) call abort () if (.not.((a + b) .eq. cx (4, 2))) call abort () end
gpl-2.0
parkin/hdf5.js
hdf5-1.8.12/fortran/test/tH5G_1_8.f90
4
87632
!****h* root/fortran/test/tH5G_1_8.f90 ! ! NAME ! tH5G_1_8.f90 ! ! FUNCTION ! Basic testing of Fortran H5G APIs introduced in 1.8. ! ! COPYRIGHT ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! 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. * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! ! CONTAINS SUBROUTINES ! group_test, group_info, timestamps, mklinks, test_move_preserves, lifecycle ! cklinks, delete_by_idx, link_info_by_idx_check, test_lcpl, objcopy, ! lapl_nlinks ! !***** SUBROUTINE group_test(cleanup, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(OUT) :: total_error INTEGER(HID_T) :: fapl, fapl2, my_fapl ! /* File access property lists */ INTEGER :: error, ret_total_error ! WRITE(*,*) "TESTING GROUPS" CALL H5Pcreate_f(H5P_FILE_ACCESS_F, fapl, error) CALL check("H5Pcreate_f",error, total_error) ! /* Copy the file access property list */ CALL H5Pcopy_f(fapl, fapl2, error) CALL check("H5Pcopy_f",error, total_error) ! /* Set the "use the latest version of the format" bounds for creating objects in the file */ CALL H5Pset_libver_bounds_f(fapl2, H5F_LIBVER_LATEST_F, H5F_LIBVER_LATEST_F, error) CALL check("H5Pset_libver_bounds_f",error, total_error) ! /* Check for FAPL to USE */ my_fapl = fapl2 ret_total_error = 0 CALL mklinks(fapl2, ret_total_error) CALL write_test_status(ret_total_error, & ' Testing building a file with assorted links', & total_error) ret_total_error = 0 CALL cklinks(fapl2, ret_total_error) CALL write_test_status(ret_total_error, & ' Testing links are correct and building assorted links', & total_error) ret_total_error = 0 CALL group_info(cleanup, fapl2, ret_total_error) CALL write_test_status(ret_total_error, & ' Testing create group with creation order indices, test querying group info', & total_error) ! CALL ud_hard_links(fapl2,total_error) ret_total_error = 0 CALL timestamps(cleanup, fapl2, ret_total_error) CALL write_test_status(ret_total_error, & ' Testing disabling tracking timestamps for an object', & total_error) ret_total_error = 0 CALL test_move_preserves(fapl2, ret_total_error) CALL write_test_status(ret_total_error, & ' Testing moving and renaming links preserves their properties', & total_error) ret_total_error = 0 CALL delete_by_idx(cleanup,fapl2,ret_total_error) CALL write_test_status(ret_total_error, & ' Testing deleting links by index', & total_error) ret_total_error = 0 CALL test_lcpl(cleanup, fapl, ret_total_error) CALL write_test_status(ret_total_error, & ' Testing link creation property lists', & total_error) ret_total_error = 0 CALL objcopy(fapl, ret_total_error) CALL write_test_status(ret_total_error, & ' Testing object copy', & total_error) ret_total_error = 0 CALL lifecycle(cleanup, fapl2, ret_total_error) CALL write_test_status(ret_total_error, & ' Testing adding links to a group follow proper "lifecycle"', & total_error) IF(cleanup) CALL h5_cleanup_f("TestLinks", H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) END SUBROUTINE group_test !/*------------------------------------------------------------------------- ! * Function: group_info ! * ! * Purpose: Create a group with creation order indices and test querying ! * group info. ! * ! * Return: Success: 0 ! * Failure: -1 ! * ! * Programmer: Adapted from C test routines by ! * M.S. Breitenfeld ! * February 18, 2008 ! * ! *------------------------------------------------------------------------- ! */ SUBROUTINE group_info(cleanup, fapl, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE INTEGER, INTENT(OUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl INTEGER(HID_T) :: gcpl_id ! /* Group creation property list ID */ INTEGER :: max_compact ! /* Maximum # of links to store in group compactly */ INTEGER :: min_dense ! /* Minimum # of links to store in group "densely" */ INTEGER :: idx_type ! /* Type of index to operate on */ INTEGER :: order, iorder ! /* Order within in the index */ LOGICAL, DIMENSION(1:2) :: use_index = (/.FALSE.,.TRUE./) ! /* Use index on creation order values */ CHARACTER(LEN=6), PARAMETER :: prefix = 'links0' CHARACTER(LEN=9), PARAMETER :: filename = prefix//'.h5' ! /* File name */ INTEGER :: Input1 INTEGER(HID_T) :: group_id ! /* Group ID */ INTEGER(HID_T) :: soft_group_id ! /* Group ID for soft links */ INTEGER :: i ! /* Local index variables */ INTEGER :: storage_type ! Type of storage for links in group: ! H5G_STORAGE_TYPE_COMPACT: Compact storage ! H5G_STORAGE_TYPE_DENSE: Indexed storage ! H5G_STORAGE_TYPE_SYMBOL_TABLE: Symbol tables, the original HDF5 structure INTEGER :: nlinks ! Number of links in group INTEGER :: max_corder ! Current maximum creation order value for group INTEGER :: u,v ! /* Local index variables */ CHARACTER(LEN=2) :: chr2 INTEGER(HID_T) :: group_id2, group_id3 ! /* Group IDs */ CHARACTER(LEN=7) :: objname ! /* Object name */ CHARACTER(LEN=7) :: objname2 ! /* Object name */ CHARACTER(LEN=19) :: valname ! /* Link value */ CHARACTER(LEN=12), PARAMETER :: CORDER_GROUP_NAME = "corder_group" CHARACTER(LEN=17), PARAMETER :: CORDER_SOFT_GROUP_NAME = "corder_soft_group" INTEGER(HID_T) :: file_id ! /* File ID */ INTEGER :: error ! /* Generic return value */ LOGICAL :: mounted LOGICAL :: cleanup ! /* Create group creation property list */ CALL H5Pcreate_f(H5P_GROUP_CREATE_F, gcpl_id, error ) CALL check("H5Pcreate_f", error, total_error) ! /* Query the group creation properties */ CALL H5Pget_link_phase_change_f(gcpl_id, max_compact, min_dense, error) CALL check("H5Pget_link_phase_change_f", error, total_error) ! /* Loop over operating on different indices on link fields */ DO idx_type = H5_INDEX_NAME_F, H5_INDEX_CRT_ORDER_F ! /* Loop over operating in different orders */ DO iorder = H5_ITER_INC_F, H5_ITER_NATIVE_F ! /* Loop over using index for creation order value */ DO i = 1, 2 ! /* Print appropriate test message */ IF(idx_type == H5_INDEX_CRT_ORDER_F)THEN IF(iorder == H5_ITER_INC_F)THEN order = H5_ITER_INC_F !!$ IF(use_index(i))THEN !!$ WRITE(*,'(5x,A)')"query group info by creation order index in increasing order w/creation order index" !!$ ELSE !!$ WRITE(*,'(5x,A)')"query group info by creation order index in increasing order w/o creation order index" !!$ ENDIF ELSE IF (iorder == H5_ITER_DEC_F) THEN order = H5_ITER_DEC_F !!$ IF(use_index(i))THEN !!$ WRITE(*,'(5x,A)')"query group info by creation order index in decreasing order w/creation order index" !!$ ELSE !!$ WRITE(*,'(5x,A)')"query group info by creation order index in decreasing order w/o creation order index" !!$ ENDIF ELSE order = H5_ITER_NATIVE_F !!$ IF(use_index(i))THEN !!$ WRITE(*,'(5x,A)')"query group info by creation order index in native order w/creation order index" !!$ ELSE !!$ WRITE(*,'(5x,A)')"query group info by creation order index in native order w/o creation order index" !!$ ENDIF ENDIF ELSE IF(iorder == H5_ITER_INC_F)THEN order = H5_ITER_INC_F !!$ IF(use_index(i))THEN !!$ WRITE(*,'(5x,A)')"query group info by creation order index in increasing order w/creation order index" !!$ ELSE !!$ WRITE(*,'(5x,A)')"query group info by creation order index in increasing order w/o creation order index" !!$ ENDIF ELSE IF (iorder == H5_ITER_DEC_F) THEN order = H5_ITER_DEC_F !!$ IF(use_index(i))THEN !!$ WRITE(*,'(5x,A)')"query group info by creation order index in decreasing order w/creation order index" !!$ ELSE !!$ WRITE(*,'(5x,A)')"query group info by creation order index in decreasing order w/o creation order index" !!$ ENDIF ELSE order = H5_ITER_NATIVE_F !!$ IF(use_index(i))THEN !!$ WRITE(*,'(5x,A)')"query group info by creation order index in native order w/creation order index" !!$ ELSE !!$ WRITE(*,'(5x,A)')"query group info by creation order index in native order w/o creation order index" !!$ ENDIF ENDIF END IF ! /* Create file */ CALL H5Fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl) CALL check("H5Fcreate_f", error, total_error) ! /* Set creation order tracking & indexing on group */ IF(use_index(i))THEN Input1 = H5P_CRT_ORDER_INDEXED_F ELSE Input1 = 0 ENDIF CALL H5Pset_link_creation_order_f(gcpl_id, IOR(H5P_CRT_ORDER_TRACKED_F, Input1), error) CALL check("H5Pset_link_creation_order_f", error, total_error) ! /* Create group with creation order tracking on */ CALL H5Gcreate_f(file_id, CORDER_GROUP_NAME, group_id, error, gcpl_id=gcpl_id) CALL check("H5Gcreate_f", error, total_error) ! /* Create group with creation order tracking on for soft links */ CALL H5Gcreate_f(file_id, CORDER_SOFT_GROUP_NAME, soft_group_id, error, & OBJECT_NAMELEN_DEFAULT_F, H5P_DEFAULT_F, gcpl_id) CALL check("H5Gcreate_f", error, total_error) ! /* Check for out of bound query by index on empty group, should fail */ CALL H5Gget_info_by_idx_f(group_id, ".", H5_INDEX_NAME_F, order, INT(0,HSIZE_T), & storage_type, nlinks, max_corder, error) CALL VERIFY("H5Gget_info_by_idx_f", error, -1, total_error) ! /* Create several links, up to limit of compact form */ DO u = 0, max_compact-1 ! /* Make name for link */ WRITE(chr2,'(I2.2)') u objname = 'fill '//chr2 ! /* Create hard link, with group object */ CALL H5Gcreate_f(group_id, objname, group_id2, error, OBJECT_NAMELEN_DEFAULT_F, H5P_DEFAULT_F, gcpl_id) CALL check("H5Gcreate_f", error, total_error) ! /* Retrieve group's information */ CALL H5Gget_info_f(group_id2, storage_type, nlinks, max_corder, error, mounted) CALL check("H5Gget_info_f", error, total_error) ! /* Check (new/empty) group's information */ CALL VERIFY("H5Gget_info_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL VERIFY("H5Gget_info_f", max_corder, 0, total_error) CALL VERIFY("H5Gget_info_f", nlinks, 0, total_error) CALL verifyLogical("H5Gget_info_f.mounted", mounted,.FALSE.,total_error) ! /* Retrieve group's information */ CALL H5Gget_info_by_name_f(group_id, objname, storage_type, nlinks, max_corder, error, mounted=mounted) CALL check("H5Gget_info_by_name_f", error, total_error) ! /* Check (new/empty) group's information */ CALL VERIFY("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL VERIFY("H5Gget_info_by_name_f", max_corder, 0, total_error) CALL VERIFY("H5Gget_info_by_name_f", nlinks, 0, total_error) CALL verifyLogical("H5Gget_info_by_name_f.mounted", mounted,.FALSE.,total_error) ! /* Retrieve group's information */ CALL H5Gget_info_by_name_f(group_id2, ".", storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_by_name", error, total_error) ! /* Check (new/empty) group's information */ CALL VERIFY("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL VERIFY("H5Gget_info_by_name_f", max_corder, 0, total_error) CALL VERIFY("H5Gget_info_by_name_f", nlinks, 0, total_error) ! /* Create objects in new group created */ DO v = 0, u ! /* Make name for link */ WRITE(chr2,'(I2.2)') v objname2 = 'fill '//chr2 ! /* Create hard link, with group object */ CALL H5Gcreate_f(group_id2, objname2, group_id3, error ) CALL check("H5Gcreate_f", error, total_error) ! /* Close group created */ CALL H5Gclose_f(group_id3, error) CALL check("H5Gclose_f", error, total_error) ENDDO ! /* Retrieve group's information */ CALL H5Gget_info_f(group_id2, storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_f", error, total_error) ! /* Check (new) group's information */ CALL VERIFY("H5Gget_info_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL VERIFY("H5Gget_info_f", max_corder, u+1, total_error) CALL VERIFY("H5Gget_info_f", nlinks, u+1, total_error) ! /* Retrieve group's information */ CALL H5Gget_info_by_name_f(group_id, objname, storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_by_name_f", error, total_error) ! /* Check (new) group's information */ CALL VERIFY("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL VERIFY("H5Gget_info_by_name_f",max_corder, u+1, total_error) CALL VERIFY("H5Gget_info_by_name_f", nlinks, u+1, total_error) ! /* Retrieve group's information */ CALL H5Gget_info_by_name_f(group_id2, ".", storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_by_name_f", error, total_error) ! /* Check (new) group's information */ CALL VERIFY("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL VERIFY("H5Gget_info_by_name_f", max_corder, u+1, total_error) CALL VERIFY("H5Gget_info_by_name_f", nlinks, u+1, total_error) ! /* Retrieve group's information */ IF(order.NE.H5_ITER_NATIVE_F)THEN IF(order.EQ.H5_ITER_INC_F) THEN CALL H5Gget_info_by_idx_f(group_id, ".", idx_type, order, INT(u,HSIZE_T), & storage_type, nlinks, max_corder, error,lapl_id=H5P_DEFAULT_F, mounted=mounted) CALL check("H5Gget_info_by_idx_f", error, total_error) CALL verifyLogical("H5Gget_info_by_idx_f", mounted,.FALSE.,total_error) ELSE CALL H5Gget_info_by_idx_f(group_id, ".", idx_type, order, INT(0,HSIZE_T), & storage_type, nlinks, max_corder, error, mounted=mounted) CALL verifyLogical("H5Gget_info_by_idx_f", mounted,.FALSE.,total_error) CALL check("H5Gget_info_by_idx_f", error, total_error) ENDIF ! /* Check (new) group's information */ CALL VERIFY("H5Gget_info_by_idx_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL VERIFY("H5Gget_info_by_idx_f", max_corder, u+1, total_error) CALL VERIFY("H5Gget_info_by_idx_f", nlinks, u+1, total_error) ENDIF ! /* Close group created */ CALL H5Gclose_f(group_id2, error) CALL check("H5Gclose_f", error, total_error) ! /* Retrieve main group's information */ CALL H5Gget_info_f(group_id, storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_f", error, total_error) ! /* Check main group's information */ CALL VERIFY("H5Gget_info_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL VERIFY("H5Gget_info_f", max_corder, u+1, total_error) CALL VERIFY("H5Gget_info_f", nlinks, u+1, total_error) ! /* Retrieve main group's information, by name */ CALL H5Gget_info_by_name_f(file_id, CORDER_GROUP_NAME, storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_by_name_f", error, total_error) ! /* Check main group's information */ CALL VERIFY("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL VERIFY("H5Gget_info_by_name_f", max_corder, u+1, total_error) CALL VERIFY("H5Gget_info_by_name_f", nlinks, u+1, total_error) ! /* Retrieve main group's information, by name */ CALL H5Gget_info_by_name_f(group_id, ".", storage_type, nlinks, max_corder, error, H5P_DEFAULT_F) CALL check("H5Gget_info_by_name_f", error, total_error) ! /* Check main group's information */ CALL VERIFY("H5Gget_info_by_name_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL VERIFY("H5Gget_info_by_name_f", max_corder, u+1, total_error) CALL VERIFY("H5Gget_info_by_name_f", nlinks, u+1, total_error) ! /* Create soft link in another group, to objects in main group */ valname = CORDER_GROUP_NAME//objname CALL H5Lcreate_soft_f(valname, soft_group_id, objname, error, H5P_DEFAULT_F, H5P_DEFAULT_F) ! /* Retrieve soft link group's information, by name */ CALL H5Gget_info_f(soft_group_id, storage_type, nlinks, max_corder, error) CALL check("H5Gget_info_f", error, total_error) ! /* Check soft link group's information */ CALL VERIFY("H5Gget_info_f", storage_type, H5G_STORAGE_TYPE_COMPACT_F, total_error) CALL VERIFY("H5Gget_info_f", max_corder, u+1, total_error) CALL VERIFY("H5Gget_info_f", nlinks, u+1, total_error) ENDDO ! /* Close the groups */ CALL H5Gclose_f(group_id, error) CALL check("H5Gclose_f", error, total_error) CALL H5Gclose_f(soft_group_id, error) CALL check("H5Gclose_f", error, total_error) ! /* Close the file */ CALL H5Fclose_f(file_id, error) CALL check("H5Fclose_f", error, total_error) ENDDO ENDDO ENDDO ! /* Free resources */ CALL H5Pclose_f(gcpl_id, error) CALL check("H5Pclose_f", error, total_error) IF(cleanup) CALL h5_cleanup_f(prefix, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) END SUBROUTINE group_info !/*------------------------------------------------------------------------- ! * Function: timestamps ! * ! * Purpose: Verify that disabling tracking timestamps for an object ! * works correctly ! * ! * ! * Programmer: M.S. Breitenfeld ! * February 20, 2008 ! * ! *------------------------------------------------------------------------- ! */ SUBROUTINE timestamps(cleanup, fapl, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE INTEGER, INTENT(OUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl INTEGER(HID_T) :: file_id !/* File ID */ INTEGER(HID_T) :: group_id !/* Group ID */ INTEGER(HID_T) :: group_id2 !/* Group ID */ INTEGER(HID_T) :: gcpl_id !/* Group creation property list ID */ INTEGER(HID_T) :: gcpl_id2 !/* Group creation property list ID */ CHARACTER(LEN=6), PARAMETER :: prefix = 'links9' CHARACTER(LEN=9), PARAMETER :: filename = prefix//'.h5' ! /* File name */ ! /* Timestamp macros */ CHARACTER(LEN=10), PARAMETER :: TIMESTAMP_GROUP_1="timestamp1" CHARACTER(LEN=10), PARAMETER :: TIMESTAMP_GROUP_2="timestamp2" LOGICAL :: track_times LOGICAL :: cleanup INTEGER :: error ! /* Print test message */ ! WRITE(*,*) "timestamps on objects" ! /* Create group creation property list */ CALL H5Pcreate_f(H5P_GROUP_CREATE_F, gcpl_id, error ) CALL check("H5Pcreate_f", error, total_error) ! /* Query the object timestamp setting */ CALL H5Pget_obj_track_times_f(gcpl_id, track_times, error) CALL check("H5Pget_obj_track_times_f", error, total_error) !/* Check default timestamp information */ CALL VerifyLogical("H5Pget_obj_track_times",track_times,.TRUE.,total_error) ! /* Set a non-default object timestamp setting */ CALL H5Pset_obj_track_times_f(gcpl_id, .FALSE., error) CALL check("H5Pset_obj_track_times_f", error, total_error) ! /* Query the object timestamp setting */ CALL H5Pget_obj_track_times_f(gcpl_id, track_times, error) CALL check("H5Pget_obj_track_times_f", error, total_error) ! /* Check default timestamp information */ CALL VerifyLogical("H5Pget_obj_track_times",track_times,.FALSE.,total_error) ! /* Create file */ !h5_fixname(FILENAME[0], fapl, filename, sizeof filename); CALL H5Fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl) CALL check("h5fcreate_f",error,total_error) ! /* Create group with non-default object timestamp setting */ CALL h5gcreate_f(file_id, TIMESTAMP_GROUP_1, group_id, error, & OBJECT_NAMELEN_DEFAULT_F, H5P_DEFAULT_F, gcpl_id, H5P_DEFAULT_F) CALL check("h5fcreate_f",error,total_error) ! /* Close the group creation property list */ CALL H5Pclose_f(gcpl_id, error) CALL check("H5Pclose_f", error, total_error) ! /* Create group with default object timestamp setting */ CALL h5gcreate_f(file_id, TIMESTAMP_GROUP_2, group_id2, error, & OBJECT_NAMELEN_DEFAULT_F, H5P_DEFAULT_F, H5P_DEFAULT_F, H5P_DEFAULT_F) CALL check("h5fcreate_f",error,total_error) ! /* Retrieve the new groups' creation properties */ CALL H5Gget_create_plist_f(group_id, gcpl_id, error) CALL check("H5Gget_create_plist", error, total_error) CALL H5Gget_create_plist_f(group_id2, gcpl_id2, error) CALL check("H5Gget_create_plist", error, total_error) ! /* Query & verify the object timestamp settings */ CALL H5Pget_obj_track_times_f(gcpl_id, track_times, error) CALL check("H5Pget_obj_track_times_f", error, total_error) CALL VerifyLogical("H5Pget_obj_track_times1",track_times,.FALSE.,total_error) CALL H5Pget_obj_track_times_f(gcpl_id2, track_times, error) CALL check("H5Pget_obj_track_times_f", error, total_error) CALL VerifyLogical("H5Pget_obj_track_times2",track_times,.TRUE.,total_error) ! /* Query the object information for each group */ ! if(H5Oget_info(group_id, &oinfo) < 0) TEST_ERROR ! if(H5Oget_info(group_id2, &oinfo2) < 0) TEST_ERROR !!$ /* Sanity check object information for each group */ !!$ if(oinfo.atime != 0) TEST_ERROR !!$ if(oinfo.mtime != 0) TEST_ERROR !!$ if(oinfo.ctime != 0) TEST_ERROR !!$ if(oinfo.btime != 0) TEST_ERROR !!$ if(oinfo.atime == oinfo2.atime) TEST_ERROR !!$ if(oinfo.mtime == oinfo2.mtime) TEST_ERROR !!$ if(oinfo.ctime == oinfo2.ctime) TEST_ERROR !!$ if(oinfo.btime == oinfo2.btime) TEST_ERROR !!$ if((oinfo.hdr.flags & H5O_HDR_STORE_TIMES) != 0) TEST_ERROR !!$ if((oinfo2.hdr.flags & H5O_HDR_STORE_TIMES) == 0) TEST_ERROR !!$ if(oinfo.hdr.space.total >= oinfo2.hdr.space.total) TEST_ERROR !!$ if(oinfo.hdr.space.meta >= oinfo2.hdr.space.meta) TEST_ERROR ! /* Close the property lists */ CALL H5Pclose_f(gcpl_id, error) CALL check("H5Pclose_f", error, total_error) CALL H5Pclose_f(gcpl_id2, error) CALL check("H5Pclose_f", error, total_error) ! /* Close the groups */ CALL H5Gclose_f(group_id, error) CALL check("H5Gclose_f", error, total_error) CALL H5Gclose_f(group_id2, error) CALL check("H5Gclose_f", error, total_error) !/* Close the file */ CALL H5Fclose_f(file_id, error) CALL check("H5Fclose_f", error, total_error) !/* Re-open the file */ CALL h5fopen_f(FileName, H5F_ACC_RDONLY_F, file_id, error, H5P_DEFAULT_F) CALL check("h5fopen_f",error,total_error) !/* Open groups */ CALL H5Gopen_f(file_id, TIMESTAMP_GROUP_1, group_id, error) ! with no optional param. CALL check("H5Gopen_f", error, total_error) CALL H5Gopen_f(file_id, TIMESTAMP_GROUP_2, group_id2, error, H5P_DEFAULT_F) ! with optional param. CALL check("H5Gopen_f", error, total_error) ! /* Retrieve the new groups' creation properties */ CALL H5Gget_create_plist_f(group_id, gcpl_id, error) CALL check("H5Gget_create_plist", error, total_error) CALL H5Gget_create_plist_f(group_id2, gcpl_id2, error) CALL check("H5Gget_create_plist", error, total_error) ! /* Query & verify the object timestamp settings */ CALL H5Pget_obj_track_times_f(gcpl_id, track_times, error) CALL check("H5Pget_obj_track_times_f", error, total_error) CALL VerifyLogical("H5Pget_obj_track_times1",track_times,.FALSE.,total_error) CALL H5Pget_obj_track_times_f(gcpl_id2, track_times, error) CALL check("H5Pget_obj_track_times_f", error, total_error) CALL VerifyLogical("H5Pget_obj_track_times2",track_times,.TRUE.,total_error) !!$ !!$ /* Query the object information for each group */ !!$ if(H5Oget_info(group_id, &oinfo) < 0) TEST_ERROR !!$ if(H5Oget_info(group_id2, &oinfo2) < 0) TEST_ERROR !!$ !!$ /* Sanity check object information for each group */ !!$ if(oinfo.atime != 0) TEST_ERROR !!$ if(oinfo.mtime != 0) TEST_ERROR !!$ if(oinfo.ctime != 0) TEST_ERROR !!$ if(oinfo.btime != 0) TEST_ERROR !!$ if(oinfo.atime == oinfo2.atime) TEST_ERROR !!$ if(oinfo.mtime == oinfo2.mtime) TEST_ERROR !!$ if(oinfo.ctime == oinfo2.ctime) TEST_ERROR !!$ if(oinfo.btime == oinfo2.btime) TEST_ERROR !!$ if((oinfo.hdr.flags & H5O_HDR_STORE_TIMES) != 0) TEST_ERROR !!$ if((oinfo2.hdr.flags & H5O_HDR_STORE_TIMES) == 0) TEST_ERROR !!$ if(oinfo.hdr.space.total >= oinfo2.hdr.space.total) TEST_ERROR !!$ if(oinfo.hdr.space.meta >= oinfo2.hdr.space.meta) TEST_ERROR ! /* Close the property lists */ CALL H5Pclose_f(gcpl_id, error) CALL check("H5Pclose_f", error, total_error) CALL H5Pclose_f(gcpl_id2, error) CALL check("H5Pclose_f", error, total_error) ! /* Close the groups */ CALL H5Gclose_f(group_id, error) CALL check("H5Gclose_f", error, total_error) CALL H5Gclose_f(group_id2, error) CALL check("H5Gclose_f", error, total_error) !/* Close the file */ CALL H5Fclose_f(file_id, error) CALL check("H5Fclose_f", error, total_error) IF(cleanup) CALL h5_cleanup_f(prefix, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) END SUBROUTINE timestamps !/*------------------------------------------------------------------------- ! * Function: mklinks ! * ! * Purpose: Build a file with assorted links. ! * ! * ! * Programmer: Adapted from C test by: ! * M.S. Breitenfeld ! * ! * Modifications: ! * ! *------------------------------------------------------------------------- ! */ SUBROUTINE mklinks(fapl, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE INTEGER, INTENT(OUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl INTEGER(HID_T) :: file, scalar, grp, d1 CHARACTER(LEN=12), PARAMETER :: filename ='TestLinks.h5' INTEGER(HSIZE_T), DIMENSION(1) :: adims2 = (/1/) ! Attribute dimension INTEGER :: arank = 1 ! Attribure rank INTEGER :: error INTEGER :: cset ! Indicates the character set used for the link’s name. INTEGER :: corder ! Specifies the link’s creation order position. LOGICAL :: f_corder_valid ! Indicates whether the value in corder is valid. INTEGER :: link_type ! Specifies the link class: ! H5L_TYPE_HARD_F - Hard link ! H5L_TYPE_SOFT_F - Soft link ! H5L_TYPE_EXTERNAL_F - External link ! H5L_TYPE_ERROR _F - Error INTEGER(HADDR_T) :: address ! If the link is a hard link, address specifies the file address that the link points to INTEGER(SIZE_T) :: val_size ! If the link is a symbolic link, val_size will be the length of the link value ! WRITE(*,*) "link creation (w/new group format)" ! /* Create a file */ CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, file, error, H5P_DEFAULT_F, fapl) CALL check("mklinks.h5fcreate_f",error,total_error) CALL h5screate_simple_f(arank, adims2, scalar, error) CALL check("mklinks.h5screate_simple_f",error,total_error) !/* Create a group */ CALL H5Gcreate_f(file, "grp1", grp, error) CALL check("H5Gcreate_f", error, total_error) CALL H5Gclose_f(grp, error) CALL check("h5gclose_f",error,total_error) !/* Create a dataset */ CALL h5dcreate_f(file, "d1", H5T_NATIVE_INTEGER, scalar, d1, error) CALL check("h5dcreate_f",error,total_error) CALL h5dclose_f(d1, error) CALL check("h5dclose_f",error,total_error) !/* Create a hard link */ CALL H5Lcreate_hard_f(file, "d1", INT(H5L_SAME_LOC_F,HID_T), "grp1/hard", error) CALL check("H5Lcreate_hard_f", error, total_error) !/* Create a symbolic link */ CALL H5Lcreate_soft_f("/d1", file, "grp1/soft",error) CALL check("H5Lcreate_soft_f", error, total_error) CALL H5Lget_info_f(file, "grp1/soft", & cset, corder, f_corder_valid, link_type, address, val_size, & error, H5P_DEFAULT_F) CALL check("H5Lget_info_f",error,total_error) ! CALL VerifyLogical("H5Lget_info_by_idx_f11", f_corder_valid, .TRUE., total_error) CALL VERIFY("H5Lget_info_by_idx_f", H5L_TYPE_SOFT_F, link_type, total_error) CALL VERIFY("H5Lget_info_by_idx_f", cset, H5T_CSET_ASCII_F, total_error) ! should be '/d1' + NULL character = 4 CALL VERIFY("H5Lget_info_by_idx_f", INT(val_size), 4, total_error) !/* Create a symbolic link to something that doesn't exist */ CALL H5Lcreate_soft_f("foobar", file, "grp1/dangle",error) !/* Create a recursive symbolic link */ CALL H5Lcreate_soft_f("/grp1/recursive", file, "/grp1/recursive",error) !/* Close */ CALL h5sclose_f(scalar, error) CALL check("h5sclose_f",error,total_error) CALL h5fclose_f(file, error) CALL check("h5fclose_f",error,total_error) END SUBROUTINE mklinks !/*------------------------------------------------------------------------- ! * Function: test_move_preserves ! * ! * Purpose: Tests that moving and renaming links preserves their ! * properties. ! * ! * Programmer: M.S. Breitenfeld ! * March 3, 2008 ! * ! * Modifications: ! * ! *------------------------------------------------------------------------- ! */ SUBROUTINE test_move_preserves(fapl_id, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE INTEGER, INTENT(OUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl_id INTEGER(HID_T):: file_id INTEGER(HID_T):: group_id INTEGER(HID_T):: fcpl_id ! /* Group creation property list ID */ INTEGER(HID_T):: lcpl_id !H5O_info_t oinfo; !H5L_info_t linfo; INTEGER :: old_cset INTEGER :: old_corder !H5T_cset_t old_cset; !int64_t old_corder; /* Creation order value of link */ !time_t old_modification_time; !time_t curr_time; !unsigned crt_order_flags; /* Status of creation order info for GCPL */ !char filename[1024]; INTEGER :: crt_order_flags ! /* Status of creation order info for GCPL */ CHARACTER(LEN=12), PARAMETER :: filename = 'TestLinks.h5' INTEGER :: cset ! Indicates the character set used for the link’s name. INTEGER :: corder ! Specifies the link’s creation order position. LOGICAL :: f_corder_valid ! Indicates whether the value in corder is valid. INTEGER :: link_type ! Specifies the link class: ! H5L_TYPE_HARD_F - Hard link ! H5L_TYPE_SOFT_F - Soft link ! H5L_TYPE_EXTERNAL_F - External link ! H5L_TYPE_ERROR _F - Error INTEGER(HADDR_T) :: address ! If the link is a hard link, address specifies the file address that the link points to INTEGER(SIZE_T) :: val_size ! If the link is a symbolic link, val_size will be the length of the link value INTEGER :: error ! WRITE(*,*) "moving and copying links preserves their properties (w/new group format)" !/* Create a file creation property list with creation order stored for links ! * in the root group ! */ CALL H5Pcreate_f(H5P_FILE_CREATE_F, fcpl_id, error) CALL check("H5Pcreate_f",error, total_error) CALL H5Pget_link_creation_order_f(fcpl_id, crt_order_flags, error) CALL check("H5Pget_link_creation_order_f",error, total_error) CALL VERIFY("H5Pget_link_creation_order_f",crt_order_flags,0, total_error) CALL H5Pset_link_creation_order_f(fcpl_id, H5P_CRT_ORDER_TRACKED_F, error) CALL check("H5Pset_link_creation_order_f", error, total_error) CALL H5Pget_link_creation_order_f(fcpl_id, crt_order_flags, error) CALL check("H5Pget_link_creation_order_f",error, total_error) CALL VERIFY("H5Pget_link_creation_order_f",crt_order_flags, H5P_CRT_ORDER_TRACKED_F, total_error) !/* Create file */ !/* (with creation order tracking for the root group) */ CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, file_id, error, fcpl_id, fapl_id) CALL check("h5fcreate_f",error,total_error) !/* Create a link creation property list with the UTF-8 character encoding */ CALL H5Pcreate_f(H5P_LINK_CREATE_F, lcpl_id, error) CALL check("H5Pcreate_f",error, total_error) CALL H5Pset_char_encoding_f(lcpl_id, H5T_CSET_UTF8_F, error) CALL check("H5Pset_char_encoding_f",error, total_error) !/* Create a group with that lcpl */ CALL H5Gcreate_f(file_id, "group", group_id, error,lcpl_id=lcpl_id, gcpl_id=H5P_DEFAULT_F, gapl_id=H5P_DEFAULT_F) CALL check("H5Gcreate_f", error, total_error) CALL H5Gclose_f(group_id, error) CALL check("H5Gclose_f", error, total_error) ! /* Get the group's link's information */ CALL H5Lget_info_f(file_id, "group", & cset, corder, f_corder_valid, link_type, address, val_size, & error, H5P_DEFAULT_F) CALL check("H5Lget_info_f",error,total_error) ! if(H5Oget_info_by_name(file_id, "group", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR old_cset = cset CALL VERIFY("H5Lget_info_f",old_cset,H5T_CSET_UTF8_F,total_error) CALL VerifyLogical("H5Lget_info_f",f_corder_valid,.TRUE.,total_error) old_corder = corder; CALL VERIFY("H5Lget_info_f",old_corder,0,total_error) ! old_modification_time = oinfo.mtime; ! /* If this test happens too quickly, the times will all be the same. Make sure the time changes. */ ! curr_time = HDtime(NULL); ! while(HDtime(NULL) <= curr_time) ! ; ! /* Close the file and reopen it */ CALL H5Fclose_f(file_id, error) CALL check("H5Fclose_f", error, total_error) !!$ if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) TEST_ERROR !!$ !!$ /* Get the link's character set & modification time . They should be unchanged */ !!$ if(H5Lget_info(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR !!$ if(old_cset != linfo.cset) TEST_ERROR !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(old_corder != linfo.corder) TEST_ERROR !!$ !!$ /* Create a new link to the group. It should have a different creation order value but the same modification time */ !!$ if(H5Lcreate_hard(file_id, "group", file_id, "group2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group2", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR !!$ if(H5Lget_info(file_id, "group2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_corder == linfo.corder) TEST_ERROR !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(linfo.corder != 1) TEST_ERROR !!$ if(linfo.cset != H5T_CSET_ASCII) TEST_ERROR !!$ !!$ /* Copy the first link to a UTF-8 name. !!$ * Its creation order value should be different, but modification time !!$ * should not change. !!$ */ !!$ if(H5Lcopy(file_id, "group", file_id, "group_copied", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group_copied", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR !!$ if(H5Lget_info(file_id, "group_copied", &linfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(linfo.corder != 2) TEST_ERROR !!$ !!$ /* Check that its character encoding is UTF-8 */ !!$ if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR !!$ !!$ /* Move the link with the default property list. */ !!$ if(H5Lmove(file_id, "group_copied", file_id, "group_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group_copied2", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR !!$ if(H5Lget_info(file_id, "group_copied2", &linfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(linfo.corder != 3) TEST_ERROR !!$ !!$ /* Check that its character encoding is not UTF-8 */ !!$ if(linfo.cset == H5T_CSET_UTF8) TEST_ERROR !!$ !!$ /* Check that the original link is unchanged */ !!$ if(H5Oget_info_by_name(file_id, "group", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR !!$ if(H5Lget_info(file_id, "group", &linfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(old_corder != linfo.corder) TEST_ERROR !!$ if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR !!$ !!$ /* Move the first link to a UTF-8 name. !!$ * Its creation order value will change, but modification time should not !!$ * change. */ !!$ if(H5Lmove(file_id, "group", file_id, "group_moved", lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group_moved", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR !!$ if(H5Lget_info(file_id, "group_moved", &linfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(linfo.corder != 4) TEST_ERROR !!$ !!$ /* Check that its character encoding is UTF-8 */ !!$ if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR !!$ !!$ /* Move the link again using the default property list. */ !!$ if(H5Lmove(file_id, "group_moved", file_id, "group_moved_again", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(H5Oget_info_by_name(file_id, "group_moved_again", &oinfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(old_modification_time != oinfo.mtime) TEST_ERROR !!$ if(H5Lget_info(file_id, "group_moved_again", &linfo, H5P_DEFAULT) < 0) TEST_ERROR !!$ if(linfo.corder_valid != TRUE) TEST_ERROR !!$ if(linfo.corder != 5) TEST_ERROR !!$ !!$ /* Check that its character encoding is not UTF-8 */ !!$ if(linfo.cset == H5T_CSET_UTF8) TEST_ERROR ! /* Close open IDs */ CALL H5Pclose_f(fcpl_id, error) CALL check("H5Pclose_f", error, total_error) CALL H5Pclose_f(lcpl_id, error) CALL check("H5Pclose_f", error, total_error) ! if(H5Fclose(file_id) < 0) TEST_ERROR END SUBROUTINE test_move_preserves !/*------------------------------------------------------------------------- ! * Function: lifecycle ! * ! * Purpose: Test that adding links to a group follow proper "lifecycle" ! * of empty->compact->symbol table->compact->empty. (As group ! * is created, links are added, then links removed) ! * ! * Return: Success: 0 ! * ! * Failure: -1 ! * ! * Programmer: Quincey Koziol ! * Monday, October 17, 2005 ! * ! *------------------------------------------------------------------------- ! */ SUBROUTINE lifecycle(cleanup, fapl2, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE INTEGER, INTENT(OUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl2 INTEGER :: error INTEGER, PARAMETER :: NAME_BUF_SIZE =7 INTEGER(HID_T) :: fid !/* File ID */ INTEGER(HID_T) :: gid !/* Group ID */ INTEGER(HID_T) :: gcpl !/* Group creation property list ID */ INTEGER(size_t) :: lheap_size_hint !/* Local heap size hint */ INTEGER :: max_compact !/* Maximum # of links to store in group compactly */ INTEGER :: min_dense !/* Minimum # of links to store in group "densely" */ INTEGER :: est_num_entries !/* Estimated # of entries in group */ INTEGER :: est_name_len !/* Estimated length of entry name */ CHARACTER(LEN=NAME_BUF_SIZE) :: filename = 'fixx.h5' INTEGER(SIZE_T) :: LIFECYCLE_LOCAL_HEAP_SIZE_HINT = 256 INTEGER :: LIFECYCLE_MAX_COMPACT = 4 INTEGER :: LIFECYCLE_MIN_DENSE = 3 INTEGER :: LIFECYCLE_EST_NUM_ENTRIES = 4 INTEGER :: LIFECYCLE_EST_NAME_LEN=8 CHARACTER(LEN=3) :: LIFECYCLE_TOP_GROUP="top" ! These value are taken from H5Gprivate.h INTEGER :: H5G_CRT_GINFO_MAX_COMPACT = 8 INTEGER :: H5G_CRT_GINFO_MIN_DENSE = 6 INTEGER :: H5G_CRT_GINFO_EST_NUM_ENTRIES = 4 INTEGER :: H5G_CRT_GINFO_EST_NAME_LEN = 8 logical :: cleanup ! WRITE(*,*) 'group lifecycle' ! /* Create file */ CALL H5Fcreate_f(filename, H5F_ACC_TRUNC_F, fid, error, access_prp=fapl2) CALL check("H5Fcreate_f",error,total_error) !/* Close file */ CALL H5Fclose_f(fid,error) CALL check("H5Fclose_f",error,total_error) ! /* Get size of file as empty */ ! if((empty_size = h5_get_file_size(filename)) < 0) TEST_ERROR ! /* Re-open file */ CALL H5Fopen_f(filename, H5F_ACC_RDWR_F, fid, error,access_prp=fapl2) CALL check("H5Fopen_f",error,total_error) ! /* Set up group creation property list */ CALL H5Pcreate_f(H5P_GROUP_CREATE_F,gcpl,error) CALL check("H5Pcreate_f",error,total_error) ! /* Query default group creation property settings */ CALL H5Pget_local_heap_size_hint_f(gcpl, lheap_size_hint, error) CALL check("H5Pget_local_heap_size_hint_f",error,total_error) CALL verify("H5Pget_local_heap_size_hint_f", INT(lheap_size_hint),0,total_error) CALL H5Pget_link_phase_change_f(gcpl, max_compact, min_dense, error) CALL check("H5Pget_link_phase_change_f", error, total_error) CALL verify("H5Pget_link_phase_change_f", max_compact, H5G_CRT_GINFO_MAX_COMPACT,total_error) CALL verify("H5Pget_link_phase_change_f", min_dense, H5G_CRT_GINFO_MIN_DENSE,total_error) CALL H5Pget_est_link_info_f(gcpl, est_num_entries, est_name_len, error) CALL check("H5Pget_est_link_info_f", error, total_error) CALL verify("H5Pget_est_link_info_f", est_num_entries, H5G_CRT_GINFO_EST_NUM_ENTRIES,total_error) CALL verify("H5Pget_est_link_info_f", est_name_len, H5G_CRT_GINFO_EST_NAME_LEN,total_error) !/* Set GCPL parameters */ CALL H5Pset_local_heap_size_hint_f(gcpl, LIFECYCLE_LOCAL_HEAP_SIZE_HINT, error) CALL check("H5Pset_local_heap_size_hint_f", error, total_error) CALL H5Pset_link_phase_change_f(gcpl, LIFECYCLE_MAX_COMPACT, LIFECYCLE_MIN_DENSE, error) CALL check("H5Pset_link_phase_change_f", error, total_error) CALL H5Pset_est_link_info_f(gcpl, LIFECYCLE_EST_NUM_ENTRIES, LIFECYCLE_EST_NAME_LEN, error) CALL check("H5Pset_est_link_info_f", error, total_error) ! /* Create group for testing lifecycle */ CALL H5Gcreate_f(fid, LIFECYCLE_TOP_GROUP, gid, error, gcpl_id=gcpl) CALL check("H5Gcreate_f", error, total_error) ! /* Query group creation property settings */ CALL H5Pget_local_heap_size_hint_f(gcpl, lheap_size_hint, error) CALL check("H5Pget_local_heap_size_hint_f",error,total_error) CALL verify("H5Pget_local_heap_size_hint_f", INT(lheap_size_hint),INT(LIFECYCLE_LOCAL_HEAP_SIZE_HINT),total_error) CALL H5Pget_link_phase_change_f(gcpl, max_compact, min_dense, error) CALL check("H5Pget_link_phase_change_f", error, total_error) CALL verify("H5Pget_link_phase_change_f", max_compact, LIFECYCLE_MAX_COMPACT,total_error) CALL verify("H5Pget_link_phase_change_f", min_dense, LIFECYCLE_MIN_DENSE,total_error) CALL H5Pget_est_link_info_f(gcpl, est_num_entries, est_name_len, error) CALL check("H5Pget_est_link_info_f", error, total_error) CALL verify("H5Pget_est_link_info_f", est_num_entries, LIFECYCLE_EST_NUM_ENTRIES,total_error) CALL verify("H5Pget_est_link_info_f", est_name_len, LIFECYCLE_EST_NAME_LEN,total_error) !/* Close top group */ CALL H5Gclose_f(gid, error) CALL check("H5Gclose_f", error, total_error) !/* Unlink top group */ CALL H5Ldelete_f(fid, LIFECYCLE_TOP_GROUP, error) CALL check("H5Ldelete_f", error, total_error) ! /* Close GCPL */ CALL H5Pclose_f(gcpl, error) CALL check("H5Pclose_f", error, total_error) ! /* Close file */ CALL H5Fclose_f(fid,error) CALL check("H5Fclose_f",error,total_error) IF(cleanup) CALL h5_cleanup_f("fixx", H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) END SUBROUTINE lifecycle !/*------------------------------------------------------------------------- ! * Function: cklinks ! * ! * Purpose: Open the file created in the first step and check that the ! * links look correct. ! * ! * Return: Success: 0 ! * ! * Failure: -1 ! * ! * Programmer: M.S. Breitenfeld ! * April 14, 2008 ! * ! * Modifications: Modified original C code ! * ! *------------------------------------------------------------------------- ! */ SUBROUTINE cklinks(fapl, total_error) ! USE ISO_C_BINDING USE HDF5 ! This module contains all necessary modules IMPLICIT NONE INTEGER, INTENT(OUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl INTEGER :: error INTEGER(HID_T) :: file ! H5O_info_t oinfo1, oinfo2; ! H5L_info_t linfo2; CHARACTER(LEN=12), PARAMETER :: filename ='TestLinks.h5' ! TYPE(C_PTR) :: linkval LOGICAL :: Lexists ! /* Open the file */ CALL H5Fopen_f(filename, H5F_ACC_RDONLY_F, file, error,access_prp=fapl) CALL check("H5Fopen_f",error,total_error) ! /* Hard link */ !!$ IF(H5Oget_info_by_name(file, "d1", &oinfo1, H5P_DEFAULT) < 0) FAIL_STACK_ERROR !!$ IF(H5Oget_info_by_name(file, "grp1/hard", &oinfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR !!$ IF(H5O_TYPE_DATASET != oinfo2.type) { !!$ H5_FAILED(); !!$ printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); !!$ TEST_ERROR !!$ } /* end if */ !!$ if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { !!$ H5_FAILED(); !!$ puts(" Hard link test failed. Link seems not to point to the "); !!$ puts(" expected file location."); !!$ TEST_ERROR !!$ } /* end if */ CALL H5Lexists_f(file,"d1",Lexists, error) CALL verifylogical("H5Lexists", Lexists,.TRUE.,total_error) CALL H5Lexists_f(file,"grp1/hard",Lexists, error) CALL verifylogical("H5Lexists", Lexists,.TRUE.,total_error) ! /* Cleanup */ CALL H5Fclose_f(file,error) CALL check("H5Fclose_f",error,total_error) END SUBROUTINE cklinks !/*------------------------------------------------------------------------- ! * Function: delete_by_idx ! * ! * Purpose: Create a group with creation order indices and test deleting ! * links by index. ! * ! * Return: Total error ! * ! * C Programmer: Quincey Koziol ! * Tuesday, November 14, 2006 ! * ! * Adapted to FORTRAN: M.S. Breitenfeld ! * March 3, 2008 ! * ! *------------------------------------------------------------------------- ! */ SUBROUTINE delete_by_idx(cleanup, fapl, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE INTEGER, INTENT(OUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl INTEGER(HID_T) :: file_id ! /* File ID */ INTEGER(HID_T) :: group_id ! /* Group ID */ INTEGER(HID_T) :: gcpl_id ! /* Group creation property list ID */ INTEGER :: idx_type ! /* Type of index to operate on */ LOGICAL, DIMENSION(1:2) :: use_index = (/.FALSE.,.TRUE./) ! /* Use index on creation order values */ INTEGER :: max_compact ! /* Maximum # of links to store in group compactly */ INTEGER :: min_dense ! /* Minimum # of links to store in group "densely" */ CHARACTER(LEN=7) :: objname ! /* Object name */ CHARACTER(LEN=8) :: filename = 'file0.h5' ! /* File name */ CHARACTER(LEN=12), PARAMETER :: CORDER_GROUP_NAME = "corder_group" LOGICAL :: f_corder_valid ! Indicates whether the creation order data is valid for this attribute INTEGER :: corder ! Is a positive integer containing the creation order of the attribute INTEGER :: cset ! Indicates the character set used for the attribute’s name INTEGER(SIZE_T) :: val_size INTEGER :: link_type INTEGER(HADDR_T) :: address INTEGER :: u ! /* Local index variable */ INTEGER :: Input1, i INTEGER(HID_T) :: group_id2 INTEGER(HID_T) :: grp INTEGER :: iorder ! /* Order within in the index */ CHARACTER(LEN=2) :: chr2 INTEGER :: error INTEGER :: id_type ! ! ! CHARACTER(LEN=80) :: fix_filename1 CHARACTER(LEN=80) :: fix_filename2 INTEGER(HSIZE_T) :: htmp LOGICAL :: cleanup DO i = 1, 80 fix_filename1(i:i) = " " fix_filename2(i:i) = " " ENDDO ! /* Loop over operating on different indices on link fields */ DO idx_type = H5_INDEX_NAME_F, H5_INDEX_CRT_ORDER_F ! /* Loop over operating in different orders */ DO iorder = H5_ITER_INC_F, H5_ITER_DEC_F ! /* Loop over using index for creation order value */ DO i = 1, 2 ! /* Print appropriate test message */ !!$ IF(idx_type == H5_INDEX_CRT_ORDER_F)THEN !!$ IF(iorder == H5_ITER_INC_F)THEN !!$ IF(use_index(i))THEN !!$ WRITE(*,'(5x,A)')"deleting links by creation order index in increasing order w/creation order index" !!$ ELSE !!$ WRITE(*,'(5x,A)')"deleting links by creation order index in increasing order w/o creation order index" !!$ ENDIF !!$ ELSE !!$ IF(use_index(i))THEN !!$ WRITE(*,'(5x,A)')"deleting links by creation order index in decreasing order w/creation order index" !!$ ELSE !!$ WRITE(*,'(5x,A)')"deleting links by creation order index in decreasing order w/o creation order index" !!$ ENDIF !!$ ENDIF !!$ ELSE !!$ IF(iorder == H5_ITER_INC_F)THEN !!$ IF(use_index(i))THEN !!$ WRITE(*,'(5x,A)')"deleting links by name index in increasing order w/creation order index" !!$ ELSE !!$ WRITE(*,'(5x,A)')"deleting links by name index in increasing order w/o creation order index" !!$ ENDIF !!$ ELSE !!$ IF(use_index(i))THEN !!$ WRITE(*,'(5x,A)')"deleting links by name index in decreasing order w/creation order index" !!$ ELSE !!$ WRITE(*,'(5x,A)')"deleting links by name index in decreasing order w/o creation order index" !!$ ENDIF !!$ ENDIF !!$ ENDIF ! /* Create file */ CALL H5Fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error, access_prp=fapl) CALL check("delete_by_idx.H5Fcreate_f", error, total_error) ! /* Create group creation property list */ CALL H5Pcreate_f(H5P_GROUP_CREATE_F, gcpl_id, error ) CALL check("delete_by_idx.H5Pcreate_f", error, total_error) ! /* Set creation order tracking & indexing on group */ IF(use_index(i))THEN Input1 = H5P_CRT_ORDER_INDEXED_F ELSE Input1 = 0 ENDIF CALL H5Pset_link_creation_order_f(gcpl_id, IOR(H5P_CRT_ORDER_TRACKED_F, Input1), error) CALL check("delete_by_idx.H5Pset_link_creation_order_f", error, total_error) ! /* Create group with creation order tracking on */ CALL H5Gcreate_f(file_id, CORDER_GROUP_NAME, group_id, error, gcpl_id=gcpl_id) CALL check("delete_by_idx.H5Gcreate_f", error, total_error) ! /* Query the group creation properties */ CALL H5Pget_link_phase_change_f(gcpl_id, max_compact, min_dense, error) CALL check("delete_by_idx.H5Pget_link_phase_change_f", error, total_error) ! /* Delete links from one end */ ! /* Check for deletion on empty group */ CALL H5Ldelete_by_idx_f(group_id, ".", idx_type, iorder, INT(0,HSIZE_T), error) CALL VERIFY("delete_by_idx.H5Ldelete_by_idx_f", error, -1, total_error) ! test should fail (error = -1) ! /* Create several links, up to limit of compact form */ DO u = 0, max_compact-1 ! /* Make name for link */ WRITE(chr2,'(I2.2)') u objname = 'fill '//chr2 ! /* Create hard link, with group object */ CALL H5Gcreate_f(group_id, objname, group_id2, error) CALL check("delete_by_idx.H5Gcreate_f", error, total_error) CALL H5Gclose_f(group_id2, error) CALL check("delete_by_idx.H5Gclose_f", error, total_error) ! /* Verify link information for new link */ CALL link_info_by_idx_check(group_id, objname, u, & .TRUE., use_index(i), total_error) ENDDO ! /* Verify state of group (compact) */ ! IF(H5G_has_links_test(group_id, NULL) != TRUE) TEST_ERROR ! /* Check for out of bound deletion */ htmp =9 !EP CALL H5Ldelete_by_idx_f(group_id, ".", idx_type, iorder, INT(u,HSIZE_T), error) CALL H5Ldelete_by_idx_f(group_id, ".", idx_type, iorder, htmp, error) CALL VERIFY("H5Ldelete_by_idx_f", error, -1, total_error) ! test should fail (error = -1) ! /* Delete links from compact group */ DO u = 0, (max_compact - 1) -1 ! /* Delete first link in appropriate order */ CALL H5Ldelete_by_idx_f(group_id, ".", idx_type, iorder, INT(0,HSIZE_T), error) CALL check("H5Ldelete_by_idx_f", error, total_error) ! /* Verify the link information for first link in appropriate order */ ! HDmemset(&linfo, 0, sizeof(linfo)); CALL H5Lget_info_by_idx_f(group_id, ".", idx_type, iorder, INT(0,HSIZE_T), & link_type, f_corder_valid, corder, cset, address, val_size, error) CALL H5Oopen_by_addr_f(group_id, address, grp, error) CALL check("H5Oopen_by_addr_f", error, total_error) CALL H5Iget_type_f(grp, id_type, error) CALL check("H5Iget_type_f", error, total_error) CALL VERIFY("H5Iget_type_f", id_type, H5I_GROUP_F, total_error) CALL H5Gclose_f(grp, error) CALL check("H5Gclose_f", error, total_error) CALL VerifyLogical("H5Lget_info_by_idx_f", f_corder_valid, .TRUE., total_error) CALL VERIFY("H5Lget_info_by_idx_f", H5L_TYPE_HARD_F, link_type, total_error) IF(iorder.EQ.H5_ITER_INC_F)THEN CALL VERIFY("H5Lget_info_by_idx_f", corder, u+1, total_error) ELSE CALL VERIFY("H5Lget_info_by_idx_f", corder, (max_compact - (u + 2)), total_error) ENDIF CALL VERIFY("H5Lget_info_by_idx_f",cset, H5T_CSET_ASCII_F, total_error) ! /* Verify the name for first link in appropriate order */ ! HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); !!$ size_tmp = 20 !!$ CALL H5Lget_name_by_idx_f(group_id, ".", idx_type, order, INT(0,HSIZE_T), size_tmp, tmpname, error) !!$ CALL check("delete_by_idx.H5Lget_name_by_idx_f", error, total_error) !!$ !!$ IF(order .EQ. H5_ITER_INC_F)THEN !!$ WRITE(chr2,'(I2.2)') u + 1 !!$ ELSE !!$ WRITE(chr2,'(I2.2)') (max_compact - (u + 2)) !!$ ENDIF !!$ objname = 'fill '//chr2 !!$ PRINT*,objname, tmpname !!$ CALL verifyString("delete_by_idx.H5Lget_name_by_idx_f", objname, tmpname, total_error) ENDDO ! /* Close the group */ CALL H5Gclose_f(group_id, error) CALL check("delete_by_idx.H5Gclose_f", error, total_error) !/* Close the group creation property list */ CALL H5Pclose_f(gcpl_id, error) CALL check("delete_by_idx.H5Gclose_f", error, total_error) !/* Close the file */ CALL H5Fclose_f(file_id, error) CALL check("delete_by_idx.H5Gclose_f", error, total_error) IF(cleanup) CALL h5_cleanup_f("file0", H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) ENDDO ENDDO ENDDO END SUBROUTINE delete_by_idx !/*------------------------------------------------------------------------- ! * Function: link_info_by_idx_check ! * ! * Purpose: Support routine for link_info_by_idx, to verify the link ! * info is correct for a link ! * ! * Note: This routine assumes that the links have been inserted in the ! * group in alphabetical order. ! * ! * Return: Success: 0 ! * Failure: -1 ! * ! * Programmer: Quincey Koziol ! * Tuesday, November 7, 2006 ! * ! *------------------------------------------------------------------------- ! */ SUBROUTINE link_info_by_idx_check(group_id, linkname, n, & hard_link, use_index, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE INTEGER, INTENT(INOUT) :: total_error INTEGER(HID_T), INTENT(IN) :: group_id CHARACTER(LEN=*), INTENT(IN) :: linkname INTEGER, INTENT(IN) :: n LOGICAL, INTENT(IN) :: hard_link LOGICAL, INTENT(IN) :: use_index LOGICAL :: f_corder_valid ! Indicates whether the creation order data is valid for this attribute INTEGER :: corder ! Is a positive integer containing the creation order of the attribute INTEGER :: cset ! Indicates the character set used for the attribute’s name INTEGER :: link_type INTEGER(HADDR_T) :: address INTEGER(SIZE_T) :: val_size ! Indicates the size, in the number of characters, of the attribute CHARACTER(LEN=7) :: tmpname !/* Temporary link name */ CHARACTER(LEN=3) :: tmpname_small !/* to small temporary link name */ CHARACTER(LEN=10) :: tmpname_big !/* to big temporary link name */ CHARACTER(LEN=7) :: valname !/* Link value name */ CHARACTER(LEN=2) :: chr2 INTEGER(SIZE_T) :: size_tmp INTEGER :: error ! /* Make link value for increasing/native order queries */ WRITE(chr2,'(I2.2)') n valname = 'valn.'//chr2 ! /* Verify the link information for first link, in increasing creation order */ ! HDmemset(&linfo, 0, sizeof(linfo)); CALL H5Lget_info_by_idx_f(group_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_INC_F, INT(0,HSIZE_T), & link_type, f_corder_valid, corder, cset, address, val_size, error) CALL check("H5Lget_info_by_idx_f", error, total_error) CALL VERIFY("H5Lget_info_by_idx_f", corder, 0, total_error) ! /* Verify the link information for new link, in increasing creation order */ ! HDmemset(&linfo, 0, sizeof(linfo)); CALL H5Lget_info_by_idx_f(group_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_INC_F, INT(n,HSIZE_T), & link_type, f_corder_valid, corder, cset, address, val_size, error) CALL check("H5Lget_info_by_idx_f", error, total_error) CALL VERIFY("H5Lget_info_by_idx_f", corder, n, total_error) ! /* Verify value for new soft link, in increasing creation order */ !!$ IF(hard_link)THEN !!$ ! HDmemset(tmpval, 0, (size_t)NAME_BUF_SIZE); !!$ !!$ CALL H5Lget_val_by_idx_f(group_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_INC_F, n, tmpval, INT(7,SIZE_T),error) !!$ CALL check("H5Lget_val_by_idx",error,total_error) !!$ !!$! IF(HDstrcmp(valname, tmpval)) TEST_ERROR !!$ ENDIF ! /* Verify the name for new link, in increasing creation order */ ! HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE); ! The actual size of tmpname should be 7 CALL H5Lget_name_by_idx_f(group_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_INC_F, INT(n,HSIZE_T), tmpname_small, error, size_tmp) CALL check("link_info_by_idx_check.H5Lget_name_by_idx_f", error, total_error) CALL verifyString("link_info_by_idx_check.H5Lget_name_by_idx_f", & linkname(1:LEN(tmpname_small)), tmpname_small(1:LEN(tmpname_small)), total_error) CALL VERIFY("link_info_by_idx_check.H5Lget_name_by_idx_f", INT(size_tmp), 7, total_error) ! try it with the correct size CALL H5Lget_name_by_idx_f(group_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_INC_F, INT(n,HSIZE_T), tmpname, error, size=size_tmp) CALL check("link_info_by_idx_check.H5Lget_name_by_idx_f", error, total_error) CALL verifyString("link_info_by_idx_check.H5Lget_name_by_idx_f", & linkname(1:LEN(tmpname)), tmpname(1:LEN(tmpname)), total_error) CALL VERIFY("link_info_by_idx_check.H5Lget_name_by_idx_f", INT(size_tmp), 7, total_error) CALL H5Lget_name_by_idx_f(group_id, ".", H5_INDEX_CRT_ORDER_F, H5_ITER_INC_F, INT(n,HSIZE_T), tmpname_big, error, size_tmp) CALL check("link_info_by_idx_check.H5Lget_name_by_idx_f", error, total_error) CALL verifyString("link_info_by_idx_check.H5Lget_name_by_idx_f", & linkname(1:7), tmpname_big(1:7), total_error) CALL VERIFY("link_info_by_idx_check.H5Lget_name_by_idx_f", INT(size_tmp), 7, total_error) ! Try with a buffer set to small END SUBROUTINE link_info_by_idx_check !/*------------------------------------------------------------------------- ! * Function: test_lcpl ! * ! * Purpose: Tests Link Creation Property Lists ! * ! * Return: Success: 0 ! * Failure: number of errors ! * ! * Programmer: M.S. Breitenfeld ! * Modified C routine ! * March 12, 2008 ! * ! * Modifications: ! * ! *------------------------------------------------------------------------- ! */ SUBROUTINE test_lcpl(cleanup, fapl, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE INTEGER, INTENT(INOUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl LOGICAL :: cleanup INTEGER(HID_T) :: file_id INTEGER(HID_T) :: group_id INTEGER(HID_T) :: space_id, data_space INTEGER(HID_T) :: dset_id INTEGER(HID_T) :: type_id INTEGER(HID_T) :: lcpl_id INTEGER :: cset ! Indicates the character set used for the link’s name. INTEGER :: corder ! Specifies the link’s creation order position. LOGICAL :: f_corder_valid ! Indicates whether the value in corder is valid. INTEGER :: link_type ! Specifies the link class: ! H5L_TYPE_HARD_F - Hard link ! H5L_TYPE_SOFT_F - Soft link ! H5L_TYPE_EXTERNAL_F - External link ! H5L_TYPE_ERROR _F - Error INTEGER(HADDR_T) :: address ! If the link is a hard link, address specifies the file address that the link points to INTEGER(SIZE_T) :: val_size ! If the link is a symbolic link, val_size will be the length of the link value CHARACTER(LEN=1024) :: filename = 'tempfile.h5' INTEGER, PARAMETER :: TEST6_DIM1 = 8, TEST6_DIM2 = 7 INTEGER(HSIZE_T), DIMENSION(1:2), PARAMETER :: dims = (/TEST6_DIM1,TEST6_DIM2/) INTEGER :: encoding INTEGER :: error LOGICAL :: Lexists INTEGER(HSIZE_T), DIMENSION(1:2), PARAMETER :: extend_dim = (/TEST6_DIM1-2,TEST6_DIM2-3/) INTEGER(HSIZE_T), DIMENSION(1:2) :: dimsout, maxdimsout ! dimensions INTEGER :: i INTEGER :: tmp1, tmp2 INTEGER(HID_T) :: crp_list ! WRITE(*,*) "link creation property lists (w/new group format)" !/* Actually, intermediate group creation is tested elsewhere (tmisc). ! * Here we only need to test the character encoding property */ !/* Create file */ ! h5_fixname(FILENAME[0], fapl, filename, sizeof filename); CALL H5Fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error, H5P_DEFAULT_F, fapl) CALL check("H5Fcreate_f", error, total_error) ! /* Create and link a group with the default LCPL */ CALL H5Gcreate_f(file_id, "/group", group_id, error) CALL check("H5Gcreate_f", error, total_error) ! /* Check that its character encoding is the default */ CALL H5Lget_info_f(file_id, "group", & cset, corder, f_corder_valid, link_type, address, val_size, & error, H5P_DEFAULT_F) !/* File-wide default character encoding can not yet be set via the file ! * creation property list and is always ASCII. */ !#define H5F_DEFAULT_CSET H5T_CSET_ASCII -- FROM H5Fprivate.h -- CALL VERIFY("H5Lget_info_f",cset, H5T_CSET_ASCII_F,total_error) ! /* Create and commit a datatype with the default LCPL */ CALL h5tcopy_f(H5T_NATIVE_INTEGER, type_id, error) CALL check("h5tcopy_f",error,total_error) CALL h5tcommit_f(file_id, "/type", type_id, error) CALL check("h5tcommit_f", error, total_error) CALL h5tclose_f(type_id, error) CALL check("h5tclose_f", error, total_error) ! /* Check that its character encoding is the default */ CALL H5Lget_info_f(file_id, "type", & cset, corder, f_corder_valid, link_type, address, val_size, & error) CALL check("h5tclose_f", error, total_error) !/* File-wide default character encoding can not yet be set via the file ! * creation property list and is always ASCII. */ !#define H5F_DEFAULT_CSET H5T_CSET_ASCII -- FROM H5Fprivate.h -- CALL verify("H5Lget_info_f",cset, H5T_CSET_ASCII_F,total_error) !/* Create a dataspace */ CALL h5screate_simple_f(2, dims, space_id, error) CALL check("h5screate_simple_f",error,total_error) CALL h5pcreate_f(H5P_DATASET_CREATE_F, crp_list, error) CALL h5pset_chunk_f(crp_list, 2, dims, error) CALL h5pcreate_f(H5P_DATASET_CREATE_F, crp_list, error) CALL h5pset_chunk_f(crp_list, 2, dims, error) CALL h5pcreate_f(H5P_DATASET_CREATE_F, crp_list, error) CALL h5pset_chunk_f(crp_list, 2, dims, error) ! /* Create a dataset using the default LCPL */ CALL h5dcreate_f(file_id, "/dataset", H5T_NATIVE_INTEGER, space_id, dset_id, error, crp_list) CALL check("h5dcreate_f", error, total_error) CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) ! Reopen CALL H5Dopen_f(file_id, "/dataset", dset_id, error) CALL check("h5dopen_f", error, total_error) ! /* Extend the dataset */ CALL H5Dset_extent_f(dset_id, extend_dim, error) CALL check("H5Dset_extent_f", error, total_error) ! /* Verify the dataspaces */ ! !Get dataset's dataspace handle. ! CALL h5dget_space_f(dset_id, data_space, error) CALL check("h5dget_space_f",error,total_error) CALL h5sget_simple_extent_dims_f(data_space, dimsout, maxdimsout, error) CALL check("h5sget_simple_extent_dims_f",error, total_error) DO i = 1, 2 tmp1 = dimsout(i) tmp2 = extend_dim(i) !EP CALL VERIFY("H5Sget_simple_extent_dims", dimsout(i), extend_dim(i), total_error) CALL VERIFY("H5Sget_simple_extent_dims", tmp1, tmp2, total_error) !EP CALL VERIFY("H5Sget_simple_extent_dims", maxdimsout(i), dims(i), total_error) tmp1 = maxdimsout(i) tmp2 = dims(i) CALL VERIFY("H5Sget_simple_extent_dims", tmp1, tmp2, total_error) ENDDO ! /* close data set */ CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) ! /* Check that its character encoding is the default */ CALL H5Lget_info_f(file_id, "dataset", & cset, corder, f_corder_valid, link_type, address, val_size, & error) CALL check("H5Lget_info_f", error, total_error) !/* File-wide default character encoding can not yet be set via the file ! * creation property list and is always ASCII. */ !#define H5F_DEFAULT_CSET H5T_CSET_ASCII -- FROM H5Fprivate.h -- CALL verify("h5tclose_f",cset, H5T_CSET_ASCII_F,total_error) !/* Create a link creation property list with the UTF-8 character encoding */ CALL H5Pcreate_f(H5P_LINK_CREATE_F,lcpl_id,error) CALL check("h5Pcreate_f",error,total_error) CALL H5Pset_char_encoding_f(lcpl_id, H5T_CSET_UTF8_F, error) CALL check("H5Pset_char_encoding_f",error, total_error) ! /* Create and link a group with the new LCPL */ CALL H5Gcreate_f(file_id, "/group2", group_id, error,lcpl_id=lcpl_id) CALL check("H5Gcreate_f", error, total_error) CALL H5Gclose_f(group_id, error) CALL check("H5Gclose_f", error, total_error) !/* Check that its character encoding is UTF-8 */ CALL H5Lget_info_f(file_id, "group2", & cset, corder, f_corder_valid, link_type, address, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f",cset, H5T_CSET_UTF8_F,total_error) ! /* Create and commit a datatype with the new LCPL */ CALL h5tcopy_f(H5T_NATIVE_INTEGER, type_id, error) CALL check("h5tcopy_f",error,total_error) CALL h5tcommit_f(file_id, "/type2", type_id, error, lcpl_id=lcpl_id) CALL check("h5tcommit_f", error, total_error) CALL h5tclose_f(type_id, error) CALL check("h5tclose_f", error, total_error) !/* Check that its character encoding is UTF-8 */ CALL H5Lget_info_f(file_id, "type2", & cset, corder, f_corder_valid, link_type, address, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f",cset, H5T_CSET_UTF8_F,total_error) ! /* Create a dataset using the new LCPL */ CALL h5dcreate_f(file_id, "/dataset2", H5T_NATIVE_INTEGER, space_id, dset_id, error,lcpl_id=lcpl_id) CALL check("h5dcreate_f", error, total_error) CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) CALL H5Pget_char_encoding_f(lcpl_id, encoding, error) CALL check("H5Pget_char_encoding_f", error, total_error) CALL VERIFY("H5Pget_char_encoding_f", encoding, H5T_CSET_UTF8_F, total_error) ! /* Check that its character encoding is UTF-8 */ CALL H5Lget_info_f(file_id, "dataset2", & cset, corder, f_corder_valid, link_type, address, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f2",cset, H5T_CSET_UTF8_F,total_error) ! /* Create a new link to the dataset with a different character encoding. */ CALL H5Pclose_f(lcpl_id, error) CALL check("H5Pclose_f", error, total_error) CALL H5Pcreate_f(H5P_LINK_CREATE_F,lcpl_id,error) CALL check("h5Pcreate_f",error,total_error) CALL H5Pset_char_encoding_f(lcpl_id, H5T_CSET_ASCII_F, error) CALL check("H5Pset_char_encoding_f",error, total_error) CALL H5Lcreate_hard_f(file_id, "/dataset2", file_id, "/dataset2_link", error, lcpl_id) CALL check("H5Lcreate_hard_f",error, total_error) CALL H5Lexists_f(file_id,"/dataset2_link",Lexists, error) CALL check("H5Lexists",error, total_error) CALL verifylogical("H5Lexists", Lexists,.TRUE.,total_error) ! /* Check that its character encoding is ASCII */ CALL H5Lget_info_f(file_id, "/dataset2_link", & cset, corder, f_corder_valid, link_type, address, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f",cset, H5T_CSET_ASCII_F,total_error) ! /* Check that the first link's encoding hasn't changed */ CALL H5Lget_info_f(file_id, "/dataset2", & cset, corder, f_corder_valid, link_type, address, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f3",cset, H5T_CSET_UTF8_F,total_error) !/* Make sure that LCPLs work properly for other API calls: */ !/* H5Lcreate_soft */ CALL H5Pset_char_encoding_f(lcpl_id, H5T_CSET_UTF8_F, error) CALL check("H5Pset_char_encoding_f",error, total_error) CALL H5Lcreate_soft_f("dataset2", file_id, "slink_to_dset2",error,lcpl_id) CALL check("H5Lcreate_soft_f", error, total_error) CALL H5Lget_info_f(file_id, "slink_to_dset2", & cset, corder, f_corder_valid, link_type, address, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f",cset, H5T_CSET_UTF8_F,total_error) ! /* H5Lmove */ CALL H5Pset_char_encoding_f(lcpl_id, H5T_CSET_ASCII_F, error) CALL check("H5Pset_char_encoding_f",error, total_error) CALL H5Lmove_f(file_id, "slink_to_dset2", file_id, "moved_slink", error, lcpl_id, H5P_DEFAULT_F) CALL check("H5Lmove_f",error, total_error) CALL H5Lget_info_f(file_id, "moved_slink", & cset, corder, f_corder_valid, link_type, address, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f",cset, H5T_CSET_ASCII_F,total_error) ! /* H5Lcopy */ CALL H5Pset_char_encoding_f(lcpl_id, H5T_CSET_UTF8_F, error) CALL check("H5Pset_char_encoding_f",error, total_error) CALL H5Lcopy_f(file_id, "moved_slink", file_id, "copied_slink", error, lcpl_id) CALL H5Lget_info_f(file_id, "copied_slink", & cset, corder, f_corder_valid, link_type, address, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f",cset, H5T_CSET_UTF8_F,total_error) ! /* H5Lcreate_external */ CALL H5Lcreate_external_f("filename", "path", file_id, "extlink", error, lcpl_id) CALL check("H5Lcreate_external_f", error, total_error) CALL H5Lget_info_f(file_id, "extlink", & cset, corder, f_corder_valid, link_type, address, val_size, & error) CALL check("H5Lget_info_f", error, total_error) CALL verify("H5Lget_info_f",cset, H5T_CSET_UTF8_F,total_error) ! /* Close open IDs */ CALL H5Pclose_f(lcpl_id, error) CALL check("H5Pclose_f", error, total_error) CALL H5Sclose_f(space_id, error) CALL check("h5Sclose_f",error,total_error) CALL H5Fclose_f(file_id, error) CALL check("H5Fclose_f", error, total_error) IF(cleanup) CALL h5_cleanup_f("tempfile", H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) END SUBROUTINE test_lcpl SUBROUTINE objcopy(fapl, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE INTEGER, INTENT(INOUT) :: total_error INTEGER(HID_T), INTENT(IN) :: fapl INTEGER(HID_T) :: fapl2, pid INTEGER :: flag, cpy_flags INTEGER :: error flag = H5O_COPY_SHALLOW_HIERARCHY_F !/* Copy the file access property list */ CALL H5Pcopy_f(fapl, fapl2, error) CALL check("H5Pcopy_f", error, total_error) !/* Set the "use the latest version of the format" bounds for creating objects in the file */ CALL H5Pset_libver_bounds_f(fapl2, H5F_LIBVER_LATEST_F, H5F_LIBVER_LATEST_F, error) ! /* create property to pass copy options */ CALL h5pcreate_f(H5P_OBJECT_COPY_F, pid, error) CALL check("h5pcreate_f",error, total_error) ! /* set options for object copy */ CALL H5Pset_copy_object_f(pid, flag, error) CALL check("H5Pset_copy_object_f",error, total_error) ! /* Verify object copy flags */ CALL H5Pget_copy_object_f(pid, cpy_flags, error) CALL check("H5Pget_copy_object_f",error, total_error) CALL VERIFY("H5Pget_copy_object_f", cpy_flags, flag, total_error) !!$ !!$ CALL test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_WITHOUT_ATTR_FLAG, !!$ FALSE, "H5Ocopy(): without attributes"); CALL lapl_nlinks(fapl2, total_error) END SUBROUTINE objcopy !/*------------------------------------------------------------------------- ! * Function: lapl_nlinks ! * ! * Purpose: Check that the maximum number of soft links can be adjusted ! * by the user using the Link Access Property List. ! * ! * Return: Success: 0 ! * ! * Failure: -1 ! * ! * Programmer: James Laird ! * Tuesday, June 6, 2006 ! * ! * Modifications: ! * ! *------------------------------------------------------------------------- ! */ SUBROUTINE lapl_nlinks( fapl, total_error) USE HDF5 IMPLICIT NONE INTEGER(HID_T), INTENT(IN) :: fapl INTEGER, INTENT(INOUT) :: total_error INTEGER :: error INTEGER(HID_T) :: fid = (-1) !/* File ID */ INTEGER(HID_T) :: gid = (-1), gid2 = (-1) !/* Group IDs */ INTEGER(HID_T) :: plist = (-1) ! /* lapl ID */ INTEGER(HID_T) :: tid = (-1) ! /* Other IDs */ INTEGER(HID_T) :: gapl = (-1), dapl = (-1), tapl = (-1) ! /* Other property lists */ CHARACTER(LEN=7) :: objname ! /* Object name */ INTEGER(size_t) :: name_len ! /* Length of object name */ CHARACTER(LEN=12) :: filename = 'TestLinks.h5' INTEGER(size_t) :: nlinks ! /* nlinks for H5Pset_nlinks */ INTEGER(size_t) :: buf_size = 7 ! WRITE(*,*) "adjusting nlinks with LAPL (w/new group format)" ! /* Create file */ CALL h5fcreate_f(FileName, H5F_ACC_TRUNC_F, fid, error, access_prp=fapl) CALL check(" lapl_nlinks.h5fcreate_f",error,total_error) ! /* Create group with short name in file (used as target for links) */ CALL H5Gcreate_f(fid, "final", gid, error) CALL check(" lapl_nlinks.H5Gcreate_f", error, total_error) !/* Create chain of soft links to existing object (limited) */ CALL H5Lcreate_soft_f("final", fid, "soft1", error) CALL H5Lcreate_soft_f("soft1", fid, "soft2", error) CALL H5Lcreate_soft_f("soft2", fid, "soft3", error) CALL H5Lcreate_soft_f("soft3", fid, "soft4", error) CALL H5Lcreate_soft_f("soft4", fid, "soft5", error) CALL H5Lcreate_soft_f("soft5", fid, "soft6", error) CALL H5Lcreate_soft_f("soft6", fid, "soft7", error) CALL H5Lcreate_soft_f("soft7", fid, "soft8", error) CALL H5Lcreate_soft_f("soft8", fid, "soft9", error) CALL H5Lcreate_soft_f("soft9", fid, "soft10", error) CALL H5Lcreate_soft_f("soft10", fid, "soft11", error) CALL H5Lcreate_soft_f("soft11", fid, "soft12", error) CALL H5Lcreate_soft_f("soft12", fid, "soft13", error) CALL H5Lcreate_soft_f("soft13", fid, "soft14", error) CALL H5Lcreate_soft_f("soft14", fid, "soft15", error) CALL H5Lcreate_soft_f("soft15", fid, "soft16", error) CALL H5Lcreate_soft_f("soft16", fid, "soft17", error) !/* Close objects */ CALL H5Gclose_f(gid, error) CALL check("h5gclose_f",error,total_error) CALL h5fclose_f(fid, error) CALL check("h5fclose_f",error,total_error) !/* Open file */ CALL h5fopen_f(FileName, H5F_ACC_RDWR_F, fid, error, fapl) CALL check("h5open_f",error,total_error) !/* Create LAPL with higher-than-usual nlinks value */ !/* Create a non-default lapl with udata set to point to the first group */ CALL H5Pcreate_f(H5P_LINK_ACCESS_F,plist,error) CALL check("h5Pcreate_f",error,total_error) nlinks = 20 CALL H5Pset_nlinks_f(plist, nlinks, error) CALL check("H5Pset_nlinks_f",error,total_error) !/* Ensure that nlinks was set successfully */ nlinks = 0 CALL H5Pget_nlinks_f(plist, nlinks, error) CALL check("H5Pset_nlinks_f",error,total_error) CALL VERIFY("H5Pset_nlinks_f",INT(nlinks), 20, total_error) !/* Open object through what is normally too many soft links using ! * new property list */ CALL H5Oopen_f(fid,"soft17",gid,error,plist) CALL check("H5Oopen_f",error,total_error) !/* Check name */ CALL h5iget_name_f(gid, objname, buf_size, name_len, error) CALL check("h5iget_name_f",error,total_error) CALL VerifyString("h5iget_name_f", TRIM(objname),"/soft17", total_error) !/* Create group using soft link */ CALL H5Gcreate_f(gid, "new_soft", gid2, error) CALL check("H5Gcreate_f", error, total_error) ! /* Close groups */ CALL H5Gclose_f(gid2, error) CALL check("H5Gclose_f", error, total_error) CALL H5Gclose_f(gid, error) CALL check("H5Gclose_f", error, total_error) !/* Set nlinks to a smaller number */ nlinks = 4 CALL H5Pset_nlinks_f(plist, nlinks, error) CALL check("H5Pset_nlinks_f", error, total_error) !/* Ensure that nlinks was set successfully */ nlinks = 0 CALL H5Pget_nlinks_f(plist, nlinks, error) CALL check("H5Pget_nlinks_f",error,total_error) CALL VERIFY("H5Pget_nlinks_f", INT(nlinks), 4, total_error) ! /* Try opening through what is now too many soft links */ CALL H5Oopen_f(fid,"soft5",gid,error,plist) CALL VERIFY("H5Oopen_f", error, -1, total_error) ! should fail ! /* Open object through lesser soft link */ CALL H5Oopen_f(fid,"soft4",gid,error,plist) CALL check("H5Oopen_",error,total_error) ! /* Check name */ CALL h5iget_name_f(gid, objname, buf_size, name_len, error) CALL check("h5iget_name_f",error,total_error) CALL VerifyString("h5iget_name_f", TRIM(objname),"/soft4", total_error) ! /* Test other functions that should use a LAPL */ nlinks = 20 CALL H5Pset_nlinks_f(plist, nlinks, error) CALL check("H5Pset_nlinks_f", error, total_error) !/* Try copying and moving when both src and dst contain many soft links ! * using a non-default LAPL ! */ CALL H5Lcopy_f(fid, "soft17", fid, "soft17/newer_soft", error, H5P_DEFAULT_F, plist) CALL check("H5Lcopy_f",error,total_error) CALL H5Lmove_f(fid, "soft17/newer_soft", fid, "soft17/newest_soft", error, lapl_id=plist) CALL check("H5Lmove_f",error, total_error) ! /* H5Olink */ CALL H5Olink_f(gid, fid, "soft17/link_to_group", error, H5P_DEFAULT_F, plist) CALL check("H5Olink_f", error, total_error) ! /* H5Lcreate_hard and H5Lcreate_soft */ CALL H5Lcreate_hard_f(fid, "soft17", fid, "soft17/link2_to_group", error, H5P_DEFAULT_F, plist) CALL check("H5Lcreate_hard_f", error, total_error) CALL H5Lcreate_soft_f("/soft4", fid, "soft17/soft_link",error, H5P_DEFAULT_F, plist) CALL check("H5Lcreate_soft_f", error, total_error) ! /* H5Ldelete */ CALL h5ldelete_f(fid, "soft17/soft_link", error, plist) CALL check("H5Ldelete_f", error, total_error) !!$ /* H5Lget_val and H5Lget_info */ !!$ if(H5Lget_val(fid, "soft17", NULL, (size_t)0, plist) < 0) TEST_ERROR !!$ if(H5Lget_info(fid, "soft17", NULL, plist) < 0) TEST_ERROR !!$ ! /* H5Lcreate_external and H5Lcreate_ud */ CALL H5Lcreate_external_f("filename", "path", fid, "soft17/extlink", error, H5P_DEFAULT_F, plist) CALL check("H5Lcreate_external_f", error, total_error) !!$ if(H5Lregister(UD_rereg_class) < 0) TEST_ERROR !!$ if(H5Lcreate_ud(fid, "soft17/udlink", UD_HARD_TYPE, NULL, (size_t)0, H5P_DEFAULT, plist) < 0) TEST_ERROR !!$ ! /* Close plist */ CALL h5pclose_f(plist, error) CALL check("h5pclose_f", error, total_error) ! /* Create a datatype and dataset as targets inside the group */ CALL h5tcopy_f(H5T_NATIVE_INTEGER, tid, error) CALL check("h5tcopy_f",error,total_error) CALL h5tcommit_f(gid, "datatype", tid, error) CALL check("h5tcommit_f", error, total_error) CALL h5tclose_f(tid, error) CALL check("h5tclose_f", error, total_error) !!$ !!$ dims[0] = 2; !!$ dims[1] = 2; !!$ if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR !!$ if((did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR !!$ if(H5Dclose(did) < 0) TEST_ERROR !!$ !/* Close group */ CALL h5gclose_f(gid, error) CALL check("h5gclose_f",error,total_error) !!$ !!$ /* Try to open the objects using too many symlinks with default *APLs */ !!$ H5E_BEGIN_TRY { !!$ if((gid = H5Gopen2(fid, "soft17", H5P_DEFAULT)) >= 0) !!$ FAIL_PUTS_ERROR(" Should have failed for too many nested links.") !!$ if((tid = H5Topen2(fid, "soft17/datatype", H5P_DEFAULT)) >= 0) !!$ FAIL_PUTS_ERROR(" Should have failed for too many nested links.") !!$ if((did = H5Dopen2(fid, "soft17/dataset", H5P_DEFAULT)) >= 0) !!$ FAIL_PUTS_ERROR(" Should have failed for too many nested links.") !!$ } H5E_END_TRY !!$ ! /* Create property lists with nlinks set */ CALL H5Pcreate_f(H5P_GROUP_ACCESS_F,gapl,error) CALL check("h5Pcreate_f",error,total_error) CALL H5Pcreate_f(H5P_DATATYPE_ACCESS_F,tapl,error) CALL check("h5Pcreate_f",error,total_error) CALL H5Pcreate_f(H5P_DATASET_ACCESS_F,dapl,error) CALL check("h5Pcreate_f",error,total_error) nlinks = 20 CALL H5Pset_nlinks_f(gapl, nlinks, error) CALL check("H5Pset_nlinks_f", error, total_error) CALL H5Pset_nlinks_f(tapl, nlinks, error) CALL check("H5Pset_nlinks_f", error, total_error) CALL H5Pset_nlinks_f(dapl, nlinks, error) CALL check("H5Pset_nlinks_f", error, total_error) !/* We should now be able to use these property lists to open each kind ! * of object. ! */ CALL H5Gopen_f(fid, "soft17", gid, error, gapl) CALL check("H5Gopen_f",error,total_error) CALL H5Topen_f(fid, "soft17/datatype", tid, error, tapl) CALL check("H5Gopen_f",error,total_error) !!$ if((did = H5Dopen2(fid, "soft17/dataset", dapl)) < 0) TEST_ERROR ! /* Close objects */ CALL h5gclose_f(gid, error) CALL check("h5gclose_f",error,total_error) CALL h5tclose_f(tid, error) CALL check("h5tclose_f", error, total_error) !!$ if(H5Dclose(did) < 0) TEST_ERROR !!$ ! /* Close plists */ CALL h5pclose_f(gapl, error) CALL check("h5pclose_f", error, total_error) CALL h5pclose_f(tapl, error) CALL check("h5pclose_f", error, total_error) !!$ if(H5Pclose(dapl) < 0) TEST_ERROR !!$ !!$ /* Unregister UD hard link class */ !!$ if(H5Lunregister(UD_HARD_TYPE) < 0) TEST_ERROR !!$ ! /* Close file */ CALL H5Fclose_f(fid, error) CALL check("H5Fclose_f", error, total_error) END SUBROUTINE lapl_nlinks
apache-2.0
parkin/hdf5.js
hdf5-1.8.12/fortran/test/tH5Sselect.f90
4
67722
!****h* root/fortran/test/tH5Sselect.f90 ! ! NAME ! tH5Sselect.f90 ! ! FUNCTION ! Basic testing of Fortran H5S, Selection-related Dataspace Interface, APIs. ! ! COPYRIGHT ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! 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. * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ! ! NOTES ! Tests the following functionalities: ! h5sget_select_npoints_f, h5sselect_elements_f, h5sselect_all_f, ! h5sselect_none_f, h5sselect_valid_f, h5sselect_hyperslab_f, ! h5sget_select_bounds_f, h5sget_select_elem_pointlist_f, ! h5sget_select_elem_npoints_f, h5sget_select_hyper_blocklist_f, ! h5sget_select_hyper_nblocks_f, h5sget_select_npoints_f ! ! CONTAINS SUBROUTINES ! test_select_hyperslab, test_select_element, test_basic_select, ! test_select_point, test_select_combine, test_select_bounds ! ! !***** SUBROUTINE test_select_hyperslab(cleanup, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(OUT) :: total_error CHARACTER(LEN=7), PARAMETER :: filename = "tselect" CHARACTER(LEN=80) :: fix_filename ! !dataset name is "IntArray" ! CHARACTER(LEN=8), PARAMETER :: dsetname = "IntArray" INTEGER(HID_T) :: file_id ! File identifier INTEGER(HID_T) :: dset_id ! Dataset identifier INTEGER(HID_T) :: dataspace ! Dataspace identifier INTEGER(HID_T) :: memspace ! memspace identifier ! !Memory space dimensions ! INTEGER(HSIZE_T), DIMENSION(3) :: dimsm = (/7,7,3/) ! !Dataset dimensions ! INTEGER(HSIZE_T), DIMENSION(2) :: dimsf = (/5,6/) ! !Size of the hyperslab in the file ! INTEGER(HSIZE_T), DIMENSION(2) :: count = (/3,4/) ! !hyperslab offset in the file ! INTEGER(HSIZE_T), DIMENSION(2) :: offset = (/1,2/) ! !Size of the hyperslab in memory ! INTEGER(HSIZE_T), DIMENSION(3) :: count_out = (/3,4,1/) ! !hyperslab offset in memory ! INTEGER(HSIZE_T), DIMENSION(3) :: offset_out = (/3,0,0/) ! !data to write ! INTEGER, DIMENSION(5,6) :: data ! !output buffer ! INTEGER, DIMENSION(7,7,3) :: data_out ! !dataset space rank ! INTEGER :: dsetrank = 2 ! !memspace rank ! INTEGER :: memrank = 3 ! !general purpose integer ! INTEGER :: i, j ! !flag to check operation success ! INTEGER :: error INTEGER(HSIZE_T), DIMENSION(3) :: data_dims ! !This writes data to the HDF5 file. ! ! !data initialization ! do i = 1, 5 do j = 1, 6 data(i,j) = (i-1) + (j-1); end do end do ! ! 0, 1, 2, 3, 4, 5 ! 1, 2, 3, 4, 5, 6 ! 2, 3, 4, 5, 6, 7 ! 3, 4, 5, 6, 7, 8 ! 4, 5, 6, 7, 8, 9 ! ! !Initialize FORTRAN predifined datatypes ! ! CALL h5init_types_f(error) ! CALL check("h5init_types_f", error, total_error) ! !Create a new file using default properties. ! CALL h5_fixname_f(filename, fix_filename, H5P_DEFAULT_F, error) if (error .ne. 0) then write(*,*) "Cannot modify filename" stop endif CALL h5fcreate_f(fix_filename, H5F_ACC_TRUNC_F, file_id, error) CALL check("h5fcreate_f", error, total_error) ! !Create the data space for the dataset. ! CALL h5screate_simple_f(dsetrank, dimsf, dataspace, error) CALL check("h5screate_simple_f", error, total_error) ! ! Create the dataset with default properties ! CALL h5dcreate_f(file_id, dsetname, H5T_STD_I32BE, dataspace, & dset_id, error) CALL check("h5dcreate_f", error, total_error) ! ! Write the dataset ! data_dims(1) = 5 data_dims(2) = 6 CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data, data_dims, error) CALL check("h5dwrite_f", error, total_error) ! !Close the dataspace for the dataset. ! CALL h5sclose_f(dataspace, error) CALL check("h5sclose_f", error, total_error) ! !Close the dataset. ! CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) ! !Close the file. ! CALL h5fclose_f(file_id, error) CALL check("h5fclose_f", error, total_error) ! !This reads the hyperslab from the sds.h5 file just !created, into a 2-dimensional plane of the 3-dimensional array. ! ! !initialize data_out array ! ! do i = 1, 7 ! do j = 1, 7 ! do k = 1,3 ! data_out(i,j,k) = 0; ! end do ! end do ! end do ! !Open the file. ! CALL h5fopen_f (fix_filename, H5F_ACC_RDONLY_F, file_id, error) CALL check("h5fopen_f", error, total_error) ! !Open the dataset. ! CALL h5dopen_f(file_id, dsetname, dset_id, error) CALL check("h5dopen_f", error, total_error) ! !Get dataset's dataspace handle. ! CALL h5dget_space_f(dset_id, dataspace, error) CALL check("h5dget_space_f", error, total_error) ! !Select hyperslab in the dataset. ! CALL h5sselect_hyperslab_f(dataspace, H5S_SELECT_SET_F, & offset, count, error) CALL check("h5sselect_hyperslab_f", error, total_error) ! !create memory dataspace. ! CALL h5screate_simple_f(memrank, dimsm, memspace, error) CALL check("h5screate_simple_f", error, total_error) ! !Select hyperslab in memory. ! CALL h5sselect_hyperslab_f(memspace, H5S_SELECT_SET_F, & offset_out, count_out, error) CALL check("h5sselect_hyperslab_f", error, total_error) ! !Read data from hyperslab in the file into the hyperslab in !memory and display. ! data_dims(1) = 7 data_dims(2) = 7 data_dims(3) = 3 CALL h5dread_f(dset_id, H5T_NATIVE_INTEGER, data_out, data_dims, error, & memspace, dataspace) CALL check("h5dread_f", error, total_error) ! !Display data_out array ! !do i = 1, 7 ! print *, (data_out(i,j,1), j = 1,7) !end do ! 0 0 0 0 0 0 0 ! 0 0 0 0 0 0 0 ! 0 0 0 0 0 0 0 ! 3 4 5 6 0 0 0 ! 4 5 6 7 0 0 0 ! 5 6 7 8 0 0 0 ! 0 0 0 0 0 0 0 ! ! !Close the dataspace for the dataset. ! CALL h5sclose_f(dataspace, error) CALL check("h5sclose_f", error, total_error) ! !Close the memoryspace. ! CALL h5sclose_f(memspace, error) CALL check("h5sclose_f", error, total_error) ! !Close the dataset. ! CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) ! !Close the file. ! CALL h5fclose_f(file_id, error) CALL check("h5fclose_f", error, total_error) if(cleanup) CALL h5_cleanup_f(filename, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) RETURN END SUBROUTINE test_select_hyperslab ! !Subroutine to test element selection ! SUBROUTINE test_select_element(cleanup, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(OUT) :: total_error ! !the dataset1 is stored in file "copy1.h5" ! CHARACTER(LEN=13), PARAMETER :: filename1 = "tselect_copy1" CHARACTER(LEN=80) :: fix_filename1 ! !the dataset2 is stored in file "copy2.h5" ! CHARACTER(LEN=13), PARAMETER :: filename2 = "tselect_copy2" CHARACTER(LEN=80) :: fix_filename2 ! !dataset1 name is "Copy1" ! CHARACTER(LEN=8), PARAMETER :: dsetname1 = "Copy1" ! !dataset2 name is "Copy2" ! CHARACTER(LEN=8), PARAMETER :: dsetname2 = "Copy2" ! !dataset rank ! INTEGER, PARAMETER :: RANK = 2 ! !number of points selected ! INTEGER(SIZE_T), PARAMETER :: NUMP = 2 INTEGER(HID_T) :: file1_id ! File1 identifier INTEGER(HID_T) :: file2_id ! File2 identifier INTEGER(HID_T) :: dset1_id ! Dataset1 identifier INTEGER(HID_T) :: dset2_id ! Dataset2 identifier INTEGER(HID_T) :: dataspace1 ! Dataspace identifier INTEGER(HID_T) :: dataspace2 ! Dataspace identifier INTEGER(HID_T) :: memspace ! memspace identifier ! !Memory space dimensions ! INTEGER(HSIZE_T), DIMENSION(1) :: dimsm = (/2/) ! !Dataset dimensions ! INTEGER(HSIZE_T), DIMENSION(2) :: dimsf = (/3,4/) ! !Points positions in the file ! INTEGER(HSIZE_T), DIMENSION(RANK,NUMP) :: coord ! !data buffers ! INTEGER, DIMENSION(3,4) :: buf1, buf2, bufnew ! !value to write ! INTEGER, DIMENSION(2) :: val = (/53, 59/) ! !memory rank ! INTEGER :: memrank = 1 ! !general purpose integer ! INTEGER :: i, j ! !flag to check operation success ! INTEGER :: error INTEGER(HSIZE_T), DIMENSION(3) :: data_dims ! !Create two files containing identical datasets. Write 0's to one !and 1's to the other. ! ! !data initialization ! do i = 1, 3 do j = 1, 4 buf1(i,j) = 0; end do end do do i = 1, 3 do j = 1, 4 buf2(i,j) = 1; end do end do ! !Initialize FORTRAN predifined datatypes ! ! CALL h5init_types_f(error) ! CALL check("h5init_types_f", error, total_error) ! !Create file1, file2 using default properties. ! CALL h5_fixname_f(filename1, fix_filename1, H5P_DEFAULT_F, error) if (error .ne. 0) then write(*,*) "Cannot modify filename" stop endif CALL h5fcreate_f(fix_filename1, H5F_ACC_TRUNC_F, file1_id, error) CALL check("h5fcreate_f", error, total_error) CALL h5_fixname_f(filename2, fix_filename2, H5P_DEFAULT_F, error) if (error .ne. 0) then write(*,*) "Cannot modify filename" stop endif CALL h5fcreate_f(fix_filename2, H5F_ACC_TRUNC_F, file2_id, error) CALL check("h5fcreate_f", error, total_error) ! !Create the data space for the datasets. ! CALL h5screate_simple_f(RANK, dimsf, dataspace1, error) CALL check("h5screate_simple_f", error, total_error) CALL h5screate_simple_f(RANK, dimsf, dataspace2, error) CALL check("h5screate_simple_f", error, total_error) ! ! Create the datasets with default properties ! CALL h5dcreate_f(file1_id, dsetname1, H5T_NATIVE_INTEGER, dataspace1, & dset1_id, error) CALL check("h5dcreate_f", error, total_error) CALL h5dcreate_f(file2_id, dsetname2, H5T_NATIVE_INTEGER, dataspace2, & dset2_id, error) CALL check("h5dcreate_f", error, total_error) ! ! Write the datasets ! data_dims(1) = 3 data_dims(2) = 4 CALL h5dwrite_f(dset1_id, H5T_NATIVE_INTEGER, buf1, data_dims, error) CALL check("h5dwrite_f", error, total_error) CALL h5dwrite_f(dset2_id, H5T_NATIVE_INTEGER, buf2, data_dims, error) CALL check("h5dwrite_f", error, total_error) ! !Close the dataspace for the datasets. ! CALL h5sclose_f(dataspace1, error) CALL check("h5sclose_f", error, total_error) CALL h5sclose_f(dataspace2, error) CALL check("h5sclose_f", error, total_error) ! !Close the datasets. ! CALL h5dclose_f(dset1_id, error) CALL check("h5dclose_f", error, total_error) CALL h5dclose_f(dset2_id, error) CALL check("h5dclose_f", error, total_error) ! !Close the files. ! CALL h5fclose_f(file1_id, error) CALL check("h5fclose_f", error, total_error) CALL h5fclose_f(file2_id, error) CALL check("h5fclose_f", error, total_error) ! !Open the two files. Select two points in one file, write values to !those point locations, then do H5Scopy and write the values to the !other file. Close files. ! ! !Open the files. ! CALL h5fopen_f (fix_filename1, H5F_ACC_RDWR_F, file1_id, error) CALL check("h5fopen_f", error, total_error) CALL h5fopen_f (fix_filename2, H5F_ACC_RDWR_F, file2_id, error) CALL check("h5fopen_f", error, total_error) ! !Open the datasets. ! CALL h5dopen_f(file1_id, dsetname1, dset1_id, error) CALL check("h5dopen_f", error, total_error) CALL h5dopen_f(file2_id, dsetname2, dset2_id, error) CALL check("h5dopen_f", error, total_error) ! !Get dataset1's dataspace handle. ! CALL h5dget_space_f(dset1_id, dataspace1, error) CALL check("h5dget_space_f", error, total_error) ! !create memory dataspace. ! CALL h5screate_simple_f(memrank, dimsm, memspace, error) CALL check("h5screate_simple_f", error, total_error) ! !Set the selected point positions.Because Fortran array index starts ! from 1, so add one to the actual select points in C ! coord(1,1) = 1 coord(2,1) = 2 coord(1,2) = 1 coord(2,2) = 4 ! !Select the elements in file space ! CALL h5sselect_elements_f(dataspace1, H5S_SELECT_SET_F, RANK, NUMP,& coord, error) CALL check("h5sselect_elements_f", error, total_error) ! !Write value into the selected points in dataset1 ! data_dims(1) = 2 CALL H5dwrite_f(dset1_id, H5T_NATIVE_INTEGER, val, data_dims, error, & mem_space_id=memspace, file_space_id=dataspace1) CALL check("h5dwrite_f", error, total_error) ! !Copy the daspace1 into dataspace2 ! CALL h5scopy_f(dataspace1, dataspace2, error) CALL check("h5scopy_f", error, total_error) ! !Write value into the selected points in dataset2 ! CALL H5dwrite_f(dset2_id, H5T_NATIVE_INTEGER, val, data_dims, error, & mem_space_id=memspace, file_space_id=dataspace2) CALL check("h5dwrite_f", error, total_error) ! !Close the dataspace for the datasets. ! CALL h5sclose_f(dataspace1, error) CALL check("h5sclose_f", error, total_error) CALL h5sclose_f(dataspace2, error) CALL check("h5sclose_f", error, total_error) ! !Close the memoryspace. ! CALL h5sclose_f(memspace, error) CALL check("h5sclose_f", error, total_error) ! !Close the datasets. ! CALL h5dclose_f(dset1_id, error) CALL check("h5dclose_f", error, total_error) CALL h5dclose_f(dset2_id, error) CALL check("h5dclose_f", error, total_error) ! !Close the files. ! CALL h5fclose_f(file1_id, error) CALL check("h5fclose_f", error, total_error) CALL h5fclose_f(file2_id, error) CALL check("h5fclose_f", error, total_error) ! !Open both files and print the contents of the datasets. ! ! !Open the files. ! CALL h5fopen_f (fix_filename1, H5F_ACC_RDWR_F, file1_id, error) CALL check("h5fopen_f", error, total_error) CALL h5fopen_f (fix_filename2, H5F_ACC_RDWR_F, file2_id, error) CALL check("h5fopen_f", error, total_error) ! !Open the datasets. ! CALL h5dopen_f(file1_id, dsetname1, dset1_id, error) CALL check("h5dopen_f", error, total_error) CALL h5dopen_f(file2_id, dsetname2, dset2_id, error) CALL check("h5dopen_f", error, total_error) ! !Read dataset1. ! data_dims(1) = 3 data_dims(2) = 4 CALL h5dread_f(dset1_id, H5T_NATIVE_INTEGER, bufnew, data_dims, error) CALL check("h5dread_f", error, total_error) ! !Display the data read from dataset "Copy1" ! !write(*,*) "The data in dataset Copy1 is: " !do i = 1, 3 ! print *, (bufnew(i,j), j = 1,4) !end do ! !Read dataset2. ! CALL h5dread_f(dset2_id, H5T_NATIVE_INTEGER, bufnew, data_dims, error) CALL check("h5dread_f", error, total_error) ! !Display the data read from dataset "Copy2" ! !write(*,*) "The data in dataset Copy2 is: " !do i = 1, 3 ! print *, (bufnew(i,j), j = 1,4) !end do ! !Close the datasets. ! CALL h5dclose_f(dset1_id, error) CALL check("h5dclose_f", error, total_error) CALL h5dclose_f(dset2_id, error) CALL check("h5dclose_f", error, total_error) ! !Close the files. ! CALL h5fclose_f(file1_id, error) CALL check("h5fclose_f", error, total_error) CALL h5fclose_f(file2_id, error) CALL check("h5fclose_f", error, total_error) if(cleanup) CALL h5_cleanup_f(filename1, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) if(cleanup) CALL h5_cleanup_f(filename2, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) RETURN END SUBROUTINE test_select_element SUBROUTINE test_basic_select(cleanup, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(OUT) :: total_error ! !the dataset is stored in file "testselect.h5" ! CHARACTER(LEN=10), PARAMETER :: filename = "testselect" CHARACTER(LEN=80) :: fix_filename ! !dataspace rank ! INTEGER, PARAMETER :: RANK = 2 ! !select NUMP_POINTS points from the file ! INTEGER(SIZE_T), PARAMETER :: NUMPS = 10 ! !dataset name is "testselect" ! CHARACTER(LEN=10), PARAMETER :: dsetname = "testselect" INTEGER(HID_T) :: file_id ! File identifier INTEGER(HID_T) :: dset_id ! Dataset identifier INTEGER(HID_T) :: dataspace ! Dataspace identifier ! !Dataset dimensions ! INTEGER(HSIZE_T), DIMENSION(2) :: dimsf = (/5,6/) ! !Size of the hyperslab in the file ! INTEGER(HSIZE_T), DIMENSION(2) :: count = (/2,2/) ! !hyperslab offset in the file ! INTEGER(HSIZE_T), DIMENSION(2) :: offset = (/0,0/) ! !start block for getting the selected hyperslab ! INTEGER(HSIZE_T) :: startblock = 0 ! !start point for getting the selected elements ! INTEGER(HSIZE_T) :: startpoint = 0 ! !Stride of the hyperslab in the file ! INTEGER(HSIZE_T), DIMENSION(2) :: stride = (/3,3/) ! !BLock size of the hyperslab in the file ! INTEGER(HSIZE_T), DIMENSION(2) :: block = (/2,2/) ! !array to give selected points' coordinations ! INTEGER(HSIZE_T), DIMENSION(RANK, NUMPS) :: coord ! !Number of hyperslabs selected in the current dataspace ! INTEGER(HSSIZE_T) :: num_blocks ! !allocatable array for putting a list of hyperslabs !selected in the current file dataspace ! INTEGER(HSIZE_T), ALLOCATABLE, DIMENSION(:) :: blocklist ! !Number of points selected in the current dataspace ! INTEGER(HSSIZE_T) :: num_points INTEGER(HSIZE_T) :: num1_points ! !allocatable array for putting a list of points !selected in the current file dataspace ! INTEGER(HSIZE_T), ALLOCATABLE, DIMENSION(:) :: pointlist ! !start and end bounds in the current dataspace selection ! INTEGER(HSIZE_T), DIMENSION(RANK) :: startout, endout ! !data to write ! INTEGER, DIMENSION(5,6) :: data ! !flag to check operation success ! INTEGER :: error INTEGER(HSIZE_T), DIMENSION(3) :: data_dims INTEGER :: i ! !initialize the coord array to give the selected points' position ! coord(1,1) = 1 coord(2,1) = 1 coord(1,2) = 1 coord(2,2) = 3 coord(1,3) = 1 coord(2,3) = 5 coord(1,4) = 3 coord(2,4) = 1 coord(1,5) = 3 coord(2,5) = 3 coord(1,6) = 3 coord(2,6) = 5 coord(1,7) = 4 coord(2,7) = 3 coord(1,8) = 4 coord(2,8) = 1 coord(1,9) = 5 coord(2,9) = 3 coord(1,10) = 5 coord(2,10) = 5 ! !Create a new file using default properties. ! CALL h5_fixname_f(filename, fix_filename, H5P_DEFAULT_F, error) if (error .ne. 0) then write(*,*) "Cannot modify filename" stop endif CALL h5fcreate_f(fix_filename, H5F_ACC_TRUNC_F, file_id, error) CALL check("h5fcreate_f", error, total_error) ! !Create the data space for the dataset. ! CALL h5screate_simple_f(RANK, dimsf, dataspace, error) CALL check("h5screate_simple_f", error, total_error) ! ! Create the dataset with default properties ! CALL h5dcreate_f(file_id, dsetname, H5T_STD_I32BE, dataspace, & dset_id, error) CALL check("h5dcreate_f", error, total_error) ! ! Write the dataset ! data_dims(1) = 5 data_dims(2) = 6 CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data, data_dims, error) CALL check("h5dwrite_f", error, total_error) ! !Close the dataspace for the dataset. ! CALL h5sclose_f(dataspace, error) CALL check("h5sclose_f", error, total_error) ! !Close the dataset. ! CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) ! !Close the file. ! CALL h5fclose_f(file_id, error) CALL check("h5fclose_f", error, total_error) ! !Open the file. ! CALL h5fopen_f (fix_filename, H5F_ACC_RDONLY_F, file_id, error) CALL check("h5fopen_f", error, total_error) ! !Open the dataset. ! CALL h5dopen_f(file_id, dsetname, dset_id, error) CALL check("h5dopen_f", error, total_error) ! !Get dataset's dataspace handle. ! CALL h5dget_space_f(dset_id, dataspace, error) CALL check("h5dget_space_f", error, total_error) ! !Select hyperslab in the dataset. ! CALL h5sselect_hyperslab_f(dataspace, H5S_SELECT_SET_F, & offset, count, error, stride, block) CALL check("h5sselect_hyperslab_f", error, total_error) ! !get the number of hyperslab blocks in the current dataspac selection ! CALL h5sget_select_hyper_nblocks_f(dataspace, num_blocks, error) CALL check("h5sget_select_hyper_nblocks_f", error, total_error) IF (num_blocks .NE. 4) write (*,*) "error occured with num_blocks" !write(*,*) num_blocks !result of num_blocks is 4 ! !allocate the blocklist array ! ALLOCATE(blocklist(num_blocks*RANK*2), STAT= error) if(error .NE. 0) then STOP endif ! !get the list of hyperslabs selected in the current dataspac selection ! CALL h5sget_select_hyper_blocklist_f(dataspace, startblock, & num_blocks, blocklist, error) CALL check("h5sget_select_hyper_blocklist_f", error, total_error) ! write(*,*) (blocklist(i), i =1, num_blocks*RANK*2) !result of blocklist selected is: !1, 1, 2, 2, 4, 1, 5, 2, 1, 4, 2, 5, 4, 4, 5, 5 ! !deallocate the blocklist array ! DEALLOCATE(blocklist) ! !get the selection bounds in the current dataspac selection ! CALL h5sget_select_bounds_f(dataspace, startout, endout, error) CALL check("h5sget_select_bounds_f", error, total_error) IF ( (startout(1) .ne. 1) .or. (startout(2) .ne. 1) ) THEN write(*,*) "error occured to select_bounds's start position" END IF IF ( (endout(1) .ne. 5) .or. (endout(2) .ne. 5) ) THEN write(*,*) "error occured to select_bounds's end position" END IF !write(*,*) (startout(i), i = 1, RANK) !result of startout is 0, 0 !write(*,*) (endout(i), i = 1, RANK) !result of endout is 5, 5 ! !allocate the pointlist array ! ! ALLOCATE(pointlist(num_blocks*RANK), STAT= error) ALLOCATE(pointlist(20), STAT= error) if(error .NE. 0) then STOP endif ! !Select the elements in file space ! CALL h5sselect_elements_f(dataspace, H5S_SELECT_SET_F, RANK, NUMPS,& coord, error) CALL check("h5sselect_elements_f", error, total_error) ! !Get the number of selected elements ! CALL h5sget_select_elem_npoints_f(dataspace, num_points, error) CALL check("h5sget_select_elem_npoints_f", error, total_error) IF (num_points .NE. 10) write(*,*) "error occured with num_points" !write(*,*) num_points ! result of num_points is 10 ! !Get the list of selected elements ! num1_points = num_points CALL h5sget_select_elem_pointlist_f(dataspace, startpoint, & num1_points, pointlist, error) CALL check("h5sget_select_elem_pointlist_f", error, total_error) !write(*,*) (pointlist(i), i =1, num1_points*RANK) !result of pintlist is: !1, 1, 3, 1, 5, 1, 1, 3, 3, 3, 5, 3, 3, !4, 1, 4, 3, 5, 5, 5 ! !deallocate the pointlist array ! DEALLOCATE(pointlist) ! !Close the dataspace for the dataset. ! CALL h5sclose_f(dataspace, error) CALL check("h5sclose_f", error, total_error) ! !Close the dataset. ! CALL h5dclose_f(dset_id, error) CALL check("h5dclose_f", error, total_error) ! !Close the file. ! CALL h5fclose_f(file_id, error) CALL check("h5fclose_f", error, total_error) if(cleanup) CALL h5_cleanup_f(filename, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) RETURN END SUBROUTINE test_basic_select !/**************************************************************** !** !** test_select_point(): Test basic H5S (dataspace) selection code. !** Tests element selections between dataspaces of various sizes !** and dimensionalities. !** !****************************************************************/ SUBROUTINE test_select_point(cleanup, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(OUT) :: total_error INTEGER(HID_T) :: xfer_plist INTEGER, PARAMETER :: SPACE1_DIM1=3 INTEGER, PARAMETER :: SPACE1_DIM2=15 INTEGER, PARAMETER :: SPACE1_DIM3=13 INTEGER, PARAMETER :: SPACE2_DIM1=30 INTEGER, PARAMETER :: SPACE2_DIM2=26 INTEGER, PARAMETER :: SPACE3_DIM1=15 INTEGER, PARAMETER :: SPACE3_DIM2=26 INTEGER, PARAMETER :: SPACE1_RANK=3 INTEGER, PARAMETER :: SPACE2_RANK=2 INTEGER, PARAMETER :: SPACE3_RANK=2 ! /* Element selection information */ INTEGER, PARAMETER :: POINT1_NPOINTS=10 INTEGER(hid_t) ::fid1 ! /* HDF5 File IDs */ INTEGER(hid_t) ::dataset ! /* Dataset ID */ INTEGER(hid_t) ::sid1,sid2 ! /* Dataspace ID */ INTEGER(hsize_t), DIMENSION(1:3) :: dims1 = (/SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3/) INTEGER(hsize_t), DIMENSION(1:2) :: dims2 = (/SPACE2_DIM1, SPACE2_DIM2/) INTEGER(hsize_t), DIMENSION(1:2) :: dims3 = (/SPACE3_DIM1, SPACE3_DIM2/) INTEGER(hsize_t), DIMENSION(1:SPACE1_RANK,1:POINT1_NPOINTS) :: coord1 !/* Coordinates for point selection */ INTEGER(hsize_t), DIMENSION(1:SPACE1_RANK,1:POINT1_NPOINTS) :: temp_coord1 !/* Coordinates for point selection */ INTEGER(hsize_t), DIMENSION(1:SPACE2_RANK,1:POINT1_NPOINTS) :: coord2 !/* Coordinates for point selection */ INTEGER(hsize_t), DIMENSION(1:SPACE2_RANK,1:POINT1_NPOINTS) :: temp_coord2 !/* Coordinates for point selection */ INTEGER(hsize_t), DIMENSION(1:SPACE3_RANK,1:POINT1_NPOINTS) :: coord3 !/* Coordinates for point selection */ INTEGER(hsize_t), DIMENSION(1:SPACE3_RANK,1:POINT1_NPOINTS) :: temp_coord3 !/* Coordinates for point selection */ INTEGER(hssize_t) :: npoints !!$ uint8_t *wbuf, /* buffer to write to disk */ !!$ *rbuf, /* buffer read from disk */ !!$ *tbuf; /* temporary buffer pointer */ INTEGER :: i,j; !/* Counters */ ! struct pnt_iter pi; /* Custom Pointer iterator struct */ INTEGER :: error !/* Generic return value */ CHARACTER(LEN=9) :: filename = 'h5s_hyper' CHARACTER(LEN=80) :: fix_filename CHARACTER(LEN=1), DIMENSION(1:SPACE2_DIM1,1:SPACE2_DIM2) :: wbuf, rbuf CALL h5_fixname_f(filename, fix_filename, H5P_DEFAULT_F, error) IF (error .NE. 0) THEN WRITE(*,*) "Cannot modify filename" STOP ENDIF xfer_plist = H5P_DEFAULT_F ! MESSAGE(5, ("Testing Element Selection Functions\n")); !/* Allocate write & read buffers */ !!$ wbuf = HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2); !!$ rbuf = HDcalloc(sizeof(uint8_t), (size_t)(SPACE3_DIM1 * SPACE3_DIM2)); !!$ !/* Initialize WRITE buffer */ DO i = 1, SPACE2_DIM1 DO j = 1, SPACE2_DIM2 wbuf(i,j) = 'a' ENDDO ENDDO !!$ for(i=0, tbuf=wbuf; i<SPACE2_DIM1; i++) !!$ for(j=0; j<SPACE2_DIM2; j++) !!$ *tbuf++=(uint8_t)((i*SPACE2_DIM2)+j); !/* Create file */ CALL h5fcreate_f(fix_filename, H5F_ACC_TRUNC_F, fid1, error) CALL check("h5fcreate_f", error, total_error) !/* Create dataspace for dataset */ CALL h5screate_simple_f(SPACE1_RANK, dims1, sid1, error) CALL check("h5screate_simple_f", error, total_error) !/* Create dataspace for write buffer */ CALL h5screate_simple_f(SPACE2_RANK, dims2, sid2, error) CALL check("h5screate_simple_f", error, total_error) !/* Select sequence of ten points for disk dataset */ coord1(1,1)=1; coord1(2,1)=11; coord1(3,1)= 6; coord1(1,2)=2; coord1(2,2)= 3; coord1(3,2)= 8; coord1(1,3)=3; coord1(2,3)= 5; coord1(3,3)=10; coord1(1,4)=1; coord1(2,4)= 7; coord1(3,4)=12; coord1(1,5)=2; coord1(2,5)= 9; coord1(3,5)=14; coord1(1,6)=3; coord1(2,6)=13; coord1(3,6)= 1; coord1(1,7)=1; coord1(2,7)=15; coord1(3,7)= 3; coord1(1,8)=2; coord1(2,8)= 1; coord1(3,8)= 5; coord1(1,9)=3; coord1(2,9)= 2; coord1(3,9)= 7; coord1(1,10)=1; coord1(2,10)= 4; coord1(3,10)= 9 CALL h5sselect_elements_f(sid1, H5S_SELECT_SET_F, SPACE1_RANK, INT(POINT1_NPOINTS,size_t), coord1, error) CALL check("h5sselect_elements_f", error, total_error) !/* Verify correct elements selected */ CALL h5sget_select_elem_pointlist_f(sid1, INT(0,hsize_t), INT(POINT1_NPOINTS,hsize_t),temp_coord1,error) CALL check("h5sget_select_elem_pointlist_f", error, total_error) DO i= 1, POINT1_NPOINTS CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord1(1,i)), INT(coord1(1,i)), total_error) CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord1(2,i)), INT(coord1(2,i)), total_error) CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord1(3,i)), INT(coord1(3,i)), total_error) ENDDO CALL H5Sget_select_npoints_f(sid1, npoints, error) CALL check("h5sget_select_npoints_f", error, total_error) CALL verify("h5sget_select_npoints_f", INT(npoints), 10, total_error) !/* Append another sequence of ten points to disk dataset */ coord1(1,1)=1; coord1(2,1)=3; coord1(3,1)= 1; coord1(1,2)=2; coord1(2,2)=11; coord1(3,2)= 9; coord1(1,3)=3; coord1(2,3)= 9; coord1(3,3)=11; coord1(1,4)=1; coord1(2,4)= 8; coord1(3,4)=13; coord1(1,5)=2; coord1(2,5)= 4; coord1(3,5)=12; coord1(1,6)=3; coord1(2,6)= 2; coord1(3,6)= 2; coord1(1,7)=1; coord1(2,7)=14; coord1(3,7)= 8; coord1(1,8)=2; coord1(2,8)=15; coord1(3,8)= 7; coord1(1,9)=3; coord1(2,9)= 3; coord1(3,9)= 6; coord1(1,10)=1; coord1(2,10)= 7; coord1(3,10)= 14 CALL h5sselect_elements_f(sid1, H5S_SELECT_APPEND_F, SPACE1_RANK, INT(POINT1_NPOINTS,size_t), coord1, error) CALL check("h5sselect_elements_f", error, total_error) ! /* Verify correct elements selected */ CALL h5sget_select_elem_pointlist_f(sid1, INT(POINT1_NPOINTS,hsize_t), INT(POINT1_NPOINTS,hsize_t),temp_coord1,error) CALL check("h5sget_select_elem_pointlist_f", error, total_error) DO i= 1, POINT1_NPOINTS CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord1(1,i)), INT(coord1(1,i)), total_error) CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord1(2,i)), INT(coord1(2,i)), total_error) CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord1(3,i)), INT(coord1(3,i)), total_error) ENDDO CALL H5Sget_select_npoints_f(sid1, npoints, error) CALL check("h5sget_select_npoints_f", error, total_error) CALL verify("h5sget_select_npoints_f", INT(npoints), 20, total_error) ! /* Select sequence of ten points for memory dataset */ coord2(1,1)=13; coord2(2,1)= 4; coord2(1,2)=16; coord2(2,2)=14; coord2(1,3)= 8; coord2(2,3)=26; coord2(1,4)= 1; coord2(2,4)= 7; coord2(1,5)=14; coord2(2,5)= 1; coord2(1,6)=25; coord2(2,6)=12; coord2(1,7)=13; coord2(2,7)=22; coord2(1,8)=30; coord2(2,8)= 5; coord2(1,9)= 9; coord2(2,9)= 9; coord2(1,10)=20; coord2(2,10)=18 CALL h5sselect_elements_f(sid2, H5S_SELECT_SET_F, SPACE2_RANK, INT(POINT1_NPOINTS,size_t), coord2, error) CALL check("h5sselect_elements_f", error, total_error) !/* Verify correct elements selected */ CALL h5sget_select_elem_pointlist_f(sid2, INT(0,hsize_t), INT(POINT1_NPOINTS,hsize_t),temp_coord2,error) CALL check("h5sget_select_elem_pointlist_f", error, total_error) DO i= 1, POINT1_NPOINTS CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord2(1,i)), INT(coord2(1,i)), total_error) CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord2(2,i)), INT(coord2(2,i)), total_error) ENDDO !!$ !!$ /* Save points for later iteration */ !!$ /* (these are in the second half of the buffer, because we are prepending */ !!$ /* the next list of points to the beginning of the point selection list) */ !!$ HDmemcpy(((char *)pi.coord)+sizeof(coord2),coord2,sizeof(coord2)); !!$ CALL H5Sget_select_npoints_f(sid2, npoints, error) CALL check("h5sget_select_npoints_f", error, total_error) CALL verify("h5sget_select_npoints_f", INT(npoints), 10, total_error) !/* Append another sequence of ten points to memory dataset */ coord2(1,1)=25; coord2(2,1)= 1; coord2(1,2)= 3; coord2(2,2)=26; coord2(1,3)=14; coord2(2,3)=18; coord2(1,4)= 9; coord2(2,4)= 4; coord2(1,5)=30; coord2(2,5)= 5; coord2(1,6)=12; coord2(2,6)=15; coord2(1,7)= 6; coord2(2,7)=23; coord2(1,8)=13; coord2(2,8)= 3; coord2(1,9)=22; coord2(2,9)=13; coord2(1,10)= 10; coord2(2,10)=19 CALL h5sselect_elements_f(sid2, H5S_SELECT_PREPEND_F, SPACE2_RANK, INT(POINT1_NPOINTS,size_t), coord2, error) CALL check("h5sselect_elements_f", error, total_error) !/* Verify correct elements selected */ CALL h5sget_select_elem_pointlist_f(sid2, INT(0,hsize_t), INT(POINT1_NPOINTS,hsize_t),temp_coord2,error) CALL check("h5sget_select_elem_pointlist_f", error, total_error) DO i= 1, POINT1_NPOINTS CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord2(1,i)), INT(coord2(1,i)), total_error) CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord2(2,i)), INT(coord2(2,i)), total_error) ENDDO CALL H5Sget_select_npoints_f(sid2, npoints, error) CALL check("h5sget_select_npoints_f", error, total_error) CALL verify("h5sget_select_npoints_f", INT(npoints), 20, total_error) !!$ /* Save points for later iteration */ !!$ HDmemcpy(pi.coord,coord2,sizeof(coord2)); ! /* Create a dataset */ CALL h5dcreate_f(fid1, "Dataset1", H5T_NATIVE_CHARACTER, sid1, dataset, error) CALL check("h5dcreate_f", error, total_error) ! /* Write selection to disk */ CALL h5dwrite_f(dataset, H5T_NATIVE_CHARACTER, wbuf, dims2, error, sid2, sid1, xfer_plist) CALL check("h5dwrite_f", error, total_error) ! /* Close memory dataspace */ CALL h5sclose_f(sid2, error) CALL check("h5sclose_f", error, total_error) ! /* Create dataspace for reading buffer */ CALL h5screate_simple_f(SPACE3_RANK, dims3, sid2, error) CALL check("h5screate_simple_f", error, total_error) ! /* Select sequence of points for read dataset */ coord3(1,1)= 1; coord3(2,1)= 3; coord3(1,2)= 5; coord3(2,2)= 9; coord3(1,3)=14; coord3(2,3)=14; coord3(1,4)=15; coord3(2,4)=21; coord3(1,5)= 8; coord3(2,5)=10; coord3(1,6)= 3; coord3(2,6)= 1; coord3(1,7)= 10; coord3(2,7)=20; coord3(1,8)= 2; coord3(2,8)=23; coord3(1,9)=13; coord3(2,9)=22; coord3(1,10)=12; coord3(2,10)=7; CALL h5sselect_elements_f(sid2, H5S_SELECT_SET_F, SPACE3_RANK, INT(POINT1_NPOINTS,size_t), coord3, error) CALL check("h5sselect_elements_f", error, total_error) ! /* Verify correct elements selected */ CALL h5sget_select_elem_pointlist_f(sid2, INT(0,hsize_t), INT(POINT1_NPOINTS,hsize_t),temp_coord3,error) CALL check("h5sget_select_elem_pointlist_f", error, total_error) DO i= 1, POINT1_NPOINTS CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord3(1,i)), INT(coord3(1,i)), total_error) CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord3(2,i)), INT(coord3(2,i)), total_error) ENDDO CALL H5Sget_select_npoints_f(sid2, npoints, error) CALL check("h5sget_select_npoints_f", error, total_error) CALL verify("h5sget_select_npoints_f", INT(npoints), 10, total_error) !/* Append another sequence of ten points to disk dataset */ coord3(1,1)=15; coord3(2,1)=26; coord3(1,2)= 1; coord3(2,2)= 1; coord3(1,3)=12; coord3(2,3)=12; coord3(1,4)= 6; coord3(2,4)=15; coord3(1,5)= 4; coord3(2,5)= 6; coord3(1,6)= 3; coord3(2,6)= 3; coord3(1,7)= 8; coord3(2,7)=14; coord3(1,8)=10; coord3(2,8)=17; coord3(1,9)=13; coord3(2,9)=23; coord3(1,10)=14; coord3(2,10)=10 CALL h5sselect_elements_f(sid2, H5S_SELECT_APPEND_F, SPACE3_RANK, INT(POINT1_NPOINTS,size_t), coord3, error) CALL check("h5sselect_elements_f", error, total_error) ! /* Verify correct elements selected */ CALL h5sget_select_elem_pointlist_f(sid2, INT(POINT1_NPOINTS,hsize_t), INT(POINT1_NPOINTS,hsize_t),temp_coord3,error) CALL check("h5sget_select_elem_pointlist_f", error, total_error) DO i= 1, POINT1_NPOINTS CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord3(1,i)), INT(coord3(1,i)), total_error) CALL VERIFY("h5sget_select_elem_pointlist_f", INT(temp_coord3(2,i)), INT(coord3(2,i)), total_error) ENDDO CALL H5Sget_select_npoints_f(sid2, npoints, error) CALL check("h5sget_select_npoints_f", error, total_error) CALL verify("h5sget_select_npoints_f", INT(npoints), 20, total_error) ! F2003 feature !!$ /* Read selection from disk */ !!$ ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,rbuf); !!$ CHECK(ret, FAIL, "H5Dread"); !!$ !!$ /* Check that the values match with a dataset iterator */ !!$ pi.buf=wbuf; !!$ pi.offset=0; !!$ ret = H5Diterate(rbuf,H5T_NATIVE_UCHAR,sid2,test_select_point_iter1,&pi); !!$ CHECK(ret, FAIL, "H5Diterate"); !!$ ! F2003 feature !/* Close memory dataspace */ CALL h5sclose_f(sid2, error) CALL check("h5sclose_f", error, total_error) !/* Close disk dataspace */ CALL h5sclose_f(sid1, error) CALL check("h5sclose_f", error, total_error) !/* Close Dataset */ CALL h5dclose_f(dataset, error) CALL check("h5dclose_f", error, total_error) !/* Close file */ CALL h5fclose_f(fid1, error) CALL check("h5fclose_f", error, total_error) IF(cleanup) CALL h5_cleanup_f(filename, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) END SUBROUTINE test_select_point !/**************************************************************** !** !** test_select_combine(): Test basic H5S (dataspace) selection code. !** Tests combining "all" and "none" selections with hyperslab !** operations. !** !****************************************************************/ SUBROUTINE test_select_combine(cleanup, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(OUT) :: total_error INTEGER, PARAMETER :: SPACE7_RANK = 2 INTEGER, PARAMETER :: SPACE7_DIM1 = 10 INTEGER, PARAMETER :: SPACE7_DIM2 = 10 INTEGER(hid_t) :: base_id ! /* Base dataspace for test */ INTEGER(hid_t) :: all_id ! /* Dataspace for "all" selection */ INTEGER(hid_t) :: none_id ! /* Dataspace for "none" selection */ INTEGER(hid_t) :: space1 ! /* Temporary dataspace #1 */ INTEGER(hsize_t), DIMENSION(1:SPACE7_RANK) :: start ! /* Hyperslab start */ INTEGER(hsize_t), DIMENSION(1:SPACE7_RANK) :: stride ! /* Hyperslab stride */ INTEGER(hsize_t), DIMENSION(1:SPACE7_RANK) :: icount ! /* Hyperslab count */ INTEGER(hsize_t), DIMENSION(1:SPACE7_RANK) :: iblock ! /* Hyperslab BLOCK */ INTEGER(hsize_t), DIMENSION(1:SPACE7_RANK) :: dims = (/SPACE7_DIM1,SPACE7_DIM2/) !/* Dimensions of dataspace */ INTEGER :: sel_type ! /* Selection type */ INTEGER(hssize_t) :: nblocks !/* Number of hyperslab blocks */ INTEGER(hsize_t), DIMENSION(1:128,1:2,1:SPACE7_RANK) :: blocks ! /* List of blocks */ INTEGER :: error, area !/* Create dataspace for dataset on disk */ CALL h5screate_simple_f(SPACE7_RANK, dims, base_id, error) CALL check("h5screate_simple_f", error, total_error) ! /* Copy base dataspace and set selection to "all" */ CALL h5scopy_f(base_id, all_id, error) CALL check("h5scopy_f", error, total_error) CALL H5Sselect_all_f(all_id, error) CALL check("H5Sselect_all_f", error, total_error) CALL H5Sget_select_type_f(all_id, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT(H5S_SEL_ALL_F), total_error) !/* Copy base dataspace and set selection to "none" */ CALL h5scopy_f(base_id, none_id, error) CALL check("h5scopy_f", error, total_error) CALL H5Sselect_none_f(none_id, error) CALL check("H5Sselect_none_f", error, total_error) CALL H5Sget_select_type_f(none_id, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT(H5S_SEL_NONE_F), total_error) !/* Copy "all" selection & space */ CALL H5Scopy_f(all_id, space1, error) CALL check("h5scopy_f", error, total_error) !/* 'OR' "all" selection with another hyperslab */ start(1:2) = 0 stride(1:2) = 1 icount(1:2) = 1 iblock(1:2) = (/5,4/) CALL h5sselect_hyperslab_f(space1, H5S_SELECT_OR_F, start, & icount, error, stride, iblock) CALL check("h5sselect_hyperslab_f", error, total_error) !/* Verify that it's still "all" selection */ CALL H5Sget_select_type_f(space1, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT(H5S_SEL_ALL_F), total_error) !/* Close temporary dataspace */ CALL h5sclose_f(space1, error) CALL check("h5sclose_f", error, total_error) !/* Copy "all" selection & space */ CALL H5Scopy_f(all_id, space1, error) CALL check("h5scopy_f", error, total_error) ! /* 'AND' "all" selection with another hyperslab */ start(1:2) = 0 stride(1:2) = 1 icount(1:2) = 1 iblock(1:2) = (/5,4/) CALL h5sselect_hyperslab_f(space1, H5S_SELECT_AND_F, start, & icount, error, stride, iblock) CALL check("h5sselect_hyperslab_f", error, total_error) !/* Verify that the new selection is the same at the original block */ CALL H5Sget_select_type_f(space1, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT( H5S_SEL_HYPERSLABS_F), total_error) !/* Verify that there is only one block */ CALL h5sget_select_hyper_nblocks_f(space1, nblocks, error) CALL check("h5sget_select_hyper_nblocks_f", error, total_error) CALL VERIFY("h5sget_select_hyper_nblocks_f", INT(nblocks), 1, total_error) !/* Retrieve the block defined */ CALL h5sget_select_hyper_blocklist_f(space1, INT(0, hsize_t), INT(nblocks,hsize_t), blocks, error) CALL check("h5sget_select_hyper_blocklist_f", error, total_error) !/* Verify that the correct block is defined */ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(1,1,1)), 1, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(2,1,1)), 1, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(3,1,1)), 5, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(4,1,1)), 4, total_error) !/* Close temporary dataspace */ CALL h5sclose_f(space1, error) CALL check("h5sclose_f", error, total_error) !/* Copy "all" selection & space */ CALL H5Scopy_f(all_id, space1, error) CALL check("h5scopy_f", error, total_error) ! /* 'XOR' "all" selection with another hyperslab */ start(1:2) = 0 stride(1:2) = 1 icount(1:2) = 1 iblock(1:2) = (/5,4/) CALL h5sselect_hyperslab_f(space1, H5S_SELECT_XOR_F, start, & icount, error, stride, iblock) CALL check("h5sselect_hyperslab_f", error, total_error) ! /* Verify that the new selection is an inversion of the original block */ CALL H5Sget_select_type_f(space1, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT( H5S_SEL_HYPERSLABS_F), total_error) ! /* Verify that there are two blocks */ CALL h5sget_select_hyper_nblocks_f(space1, nblocks, error) CALL check("h5sget_select_hyper_nblocks_f", error, total_error) CALL VERIFY("h5sget_select_hyper_nblocks_f", INT(nblocks), 2, total_error) ! /* Retrieve the block defined */ blocks = -1 ! /* Reset block list */ CALL h5sget_select_hyper_blocklist_f(space1, INT(0, hsize_t), INT(nblocks,hsize_t), blocks, error) CALL check("h5sget_select_hyper_blocklist_f", error, total_error) ! /* Verify that the correct block is defined */ ! No guarantee is implied as the order in which blocks are listed. ! So this will ONLY work for square domains iblock(1:2) = (/5,5/) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(1,1,1)), 1, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(2,1,1)), 5, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(3,1,1)), 5, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(4,1,1)), 10, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(5,1,1)), 6, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(6,1,1)), 1, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(7,1,1)), 10, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(8,1,1)), 10, total_error) ! Otherwise make sure the "area" of the block is correct area = (ABS(INT(blocks(1,1,1)-blocks(3,1,1)))+1)*(ABS(INT(blocks(2,1,1)-blocks(4,1,1)))+1) area = area + (ABS(INT(blocks(5,1,1)-blocks(7,1,1)))+1)*(ABS(INT(blocks(6,1,1)-blocks(8,1,1)))+1) CALL VERIFY("h5sget_select_hyper_blocklist_f", area, 80, total_error) !/* Close temporary dataspace */ CALL h5sclose_f(space1, error) CALL check("h5sclose_f", error, total_error) ! /* Copy "all" selection & space */ CALL H5Scopy_f(all_id, space1, error) CALL check("h5scopy_f", error, total_error) ! /* 'NOTB' "all" selection with another hyperslab */ start(1:2) = 0 stride(1:2) = 1 icount(1:2) = 1 iblock(1:2) = (/5,4/) !5 CALL h5sselect_hyperslab_f(space1, H5S_SELECT_NOTB_F, start, & icount, error, stride, iblock) CALL check("h5sselect_hyperslab_f", error, total_error) ! /* Verify that the new selection is an inversion of the original block */ CALL H5Sget_select_type_f(space1, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT( H5S_SEL_HYPERSLABS_F), total_error) ! /* Verify that there are two blocks */ CALL h5sget_select_hyper_nblocks_f(space1, nblocks, error) CALL check("h5sget_select_hyper_nblocks_f", error, total_error) CALL VERIFY("h5sget_select_hyper_nblocks_f", INT(nblocks), 2, total_error) ! /* Retrieve the block defined */ blocks = -1 ! /* Reset block list */ CALL h5sget_select_hyper_blocklist_f(space1, INT(0, hsize_t), INT(nblocks,hsize_t), blocks, error) CALL check("h5sget_select_hyper_blocklist_f", error, total_error) ! /* Verify that the correct block is defined */ ! No guarantee is implied as the order in which blocks are listed. ! So this will ONLY work for square domains iblock(1:2) = (/5,5/) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(1,1,1)), 1, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(2,1,1)), 5, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(3,1,1)), 5, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(4,1,1)),10, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(5,1,1)), 6, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(6,1,1)), 1, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(7,1,1)),10, total_error) !!$ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(8,1,1)),10, total_error) ! Otherwise make sure the "area" of the block is correct area = (ABS(INT(blocks(1,1,1)-blocks(3,1,1)))+1)*(ABS(INT(blocks(2,1,1)-blocks(4,1,1)))+1) area = area + (ABS(INT(blocks(5,1,1)-blocks(7,1,1)))+1)*(ABS(INT(blocks(6,1,1)-blocks(8,1,1)))+1) CALL VERIFY("h5sget_select_hyper_blocklist_f", area, 80, total_error) ! /* Close temporary dataspace */ CALL h5sclose_f(space1, error) CALL check("h5sclose_f", error, total_error) ! /* Copy "all" selection & space */ CALL H5Scopy_f(all_id, space1, error) CALL check("h5scopy_f", error, total_error) ! /* 'NOTA' "all" selection with another hyperslab */ start(1:2) = 0 stride(1:2) = 1 icount(1:2) = 1 iblock(1:2) = (/5,4/) !5 CALL h5sselect_hyperslab_f(space1, H5S_SELECT_NOTA_F, start, & icount, error, stride, iblock) CALL check("h5sselect_hyperslab_f", error, total_error) !/* Verify that the new selection is the "none" selection */ CALL H5Sget_select_type_f(space1, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT( H5S_SEL_NONE_F), total_error) ! /* Close temporary dataspace */ CALL h5sclose_f(space1, error) CALL check("h5sclose_f", error, total_error) ! /* Copy "none" selection & space */ CALL H5Scopy_f(none_id, space1, error) CALL check("h5scopy_f", error, total_error) ! /* 'OR' "none" selection with another hyperslab */ start(1:2) = 0 stride(1:2) = 1 icount(1:2) = 1 iblock(1:2) = (/5,4/) !5 CALL h5sselect_hyperslab_f(space1, H5S_SELECT_OR_F, start, & icount, error, stride, iblock) CALL check("h5sselect_hyperslab_f", error, total_error) ! /* Verify that the new selection is the same as the original hyperslab */ CALL H5Sget_select_type_f(space1, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT( H5S_SEL_HYPERSLABS_F), total_error) ! /* Verify that there is only one block */ CALL h5sget_select_hyper_nblocks_f(space1, nblocks, error) CALL check("h5sget_select_hyper_nblocks_f", error, total_error) CALL VERIFY("h5sget_select_hyper_nblocks_f", INT(nblocks), 1, total_error) ! /* Retrieve the block defined */ blocks = -1 ! /* Reset block list */ CALL h5sget_select_hyper_blocklist_f(space1, INT(0, hsize_t), INT(nblocks,hsize_t), blocks, error) CALL check("h5sget_select_hyper_blocklist_f", error, total_error) ! /* Verify that the correct block is defined */ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(1,1,1)), 1, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(2,1,1)), 1, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(3,1,1)), 5, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(4,1,1)), 4, total_error) ! /* Close temporary dataspace */ CALL h5sclose_f(space1, error) CALL check("h5sclose_f", error, total_error) ! /* Copy "none" selection & space */ CALL H5Scopy_f(none_id, space1, error) CALL check("h5scopy_f", error, total_error) ! /* 'AND' "none" selection with another hyperslab */ start(1:2) = 0 stride(1:2) = 1 icount(1:2) = 1 iblock(1:2) = (/5,4/) !5 CALL h5sselect_hyperslab_f(space1, H5S_SELECT_AND_F, start, & icount, error, stride, iblock) CALL check("h5sselect_hyperslab_f", error, total_error) ! /* Verify that the new selection is the "none" selection */ CALL H5Sget_select_type_f(space1, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT( H5S_SEL_NONE_F), total_error) ! /* Close temporary dataspace */ CALL h5sclose_f(space1, error) CALL check("h5sclose_f", error, total_error) ! /* Copy "none" selection & space */ CALL H5Scopy_f(none_id, space1, error) CALL check("h5scopy_f", error, total_error) ! /* 'XOR' "none" selection with another hyperslab */ start(1:2) = 0 stride(1:2) = 1 icount(1:2) = 1 iblock(1:2) = (/5,4/) !5 CALL h5sselect_hyperslab_f(space1, H5S_SELECT_XOR_F, start, & icount, error, stride, iblock) CALL check("h5sselect_hyperslab_f", error, total_error) ! /* Verify that the new selection is the same as the original hyperslab */ CALL H5Sget_select_type_f(space1, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT( H5S_SEL_HYPERSLABS_F), total_error) ! /* Verify that there is only one block */ CALL h5sget_select_hyper_nblocks_f(space1, nblocks, error) CALL check("h5sget_select_hyper_nblocks_f", error, total_error) CALL VERIFY("h5sget_select_hyper_nblocks_f", INT(nblocks), 1, total_error) ! /* Retrieve the block defined */ blocks = -1 ! /* Reset block list */ CALL h5sget_select_hyper_blocklist_f(space1, INT(0, hsize_t), INT(nblocks,hsize_t), blocks, error) CALL check("h5sget_select_hyper_blocklist_f", error, total_error) ! /* Verify that the correct block is defined */ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(1,1,1)), 1, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(2,1,1)), 1, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(3,1,1)), 5, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(4,1,1)), 4, total_error) ! /* Close temporary dataspace */ CALL h5sclose_f(space1, error) CALL check("h5sclose_f", error, total_error) ! /* Copy "none" selection & space */ CALL H5Scopy_f(none_id, space1, error) CALL check("h5scopy_f", error, total_error) ! /* 'NOTB' "none" selection with another hyperslab */ start(1:2) = 0 stride(1:2) = 1 icount(1:2) = 1 iblock(1:2) = (/5,4/) !5 CALL h5sselect_hyperslab_f(space1, H5S_SELECT_NOTB_F, start, & icount, error, stride, iblock) CALL check("h5sselect_hyperslab_f", error, total_error) ! /* Verify that the new selection is the "none" selection */ CALL H5Sget_select_type_f(space1, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT( H5S_SEL_NONE_F), total_error) ! /* Close temporary dataspace */ CALL h5sclose_f(space1, error) CALL check("h5sclose_f", error, total_error) ! /* Copy "none" selection & space */ CALL H5Scopy_f(none_id, space1, error) CALL check("h5scopy_f", error, total_error) ! /* 'NOTA' "none" selection with another hyperslab */ start(1:2) = 0 stride(1:2) = 1 icount(1:2) = 1 iblock(1:2) = (/5,4/) !5 CALL h5sselect_hyperslab_f(space1, H5S_SELECT_NOTA_F, start, & icount, error, stride, iblock) CALL check("h5sselect_hyperslab_f", error, total_error) ! /* Verify that the new selection is the same as the original hyperslab */ CALL H5Sget_select_type_f(space1, sel_type, error) CALL check("H5Sget_select_type_f", error, total_error) CALL VERIFY("H5Sget_select_type_f", INT(sel_type), INT( H5S_SEL_HYPERSLABS_F), total_error) ! /* Verify that there is ONLY one BLOCK */ CALL h5sget_select_hyper_nblocks_f(space1, nblocks, error) CALL check("h5sget_select_hyper_nblocks_f", error, total_error) CALL VERIFY("h5sget_select_hyper_nblocks_f", INT(nblocks), 1, total_error) ! /* Retrieve the block defined */ blocks = -1 ! /* Reset block list */ CALL h5sget_select_hyper_blocklist_f(space1, INT(0, hsize_t), INT(nblocks,hsize_t), blocks, error) CALL check("h5sget_select_hyper_blocklist_f", error, total_error) ! /* Verify that the correct block is defined */ CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(1,1,1)), 1, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(2,1,1)), 1, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(3,1,1)), 5, total_error) CALL VERIFY("h5sget_select_hyper_blocklist_f", INT(blocks(4,1,1)), 4, total_error) ! /* Close temporary dataspace */ CALL h5sclose_f(space1, error) CALL check("h5sclose_f", error, total_error) ! /* Close dataspaces */ CALL h5sclose_f(base_id, error) CALL check("h5sclose_f", error, total_error) CALL h5sclose_f(all_id, error) CALL check("h5sclose_f", error, total_error) CALL h5sclose_f(none_id, error) CALL check("h5sclose_f", error, total_error) END SUBROUTINE test_select_combine !/**************************************************************** !** !** test_select_bounds(): Tests selection bounds on dataspaces, !** both with and without offsets. !** !****************************************************************/ SUBROUTINE test_select_bounds(cleanup, total_error) USE HDF5 ! This module contains all necessary modules IMPLICIT NONE LOGICAL, INTENT(IN) :: cleanup INTEGER, INTENT(OUT) :: total_error INTEGER, PARAMETER :: SPACE11_RANK=2 INTEGER, PARAMETER :: SPACE11_DIM1=100 INTEGER, PARAMETER :: SPACE11_DIM2=50 INTEGER, PARAMETER :: SPACE11_NPOINTS=4 INTEGER(hid_t) :: sid ! /* Dataspace ID */ INTEGER(hsize_t), DIMENSION(1:SPACE11_RANK) :: dims = (/SPACE11_DIM1, SPACE11_DIM2/) !Dataspace dimensions INTEGER(hsize_t), DIMENSION(SPACE11_RANK, SPACE11_NPOINTS) :: coord !/* Coordinates for point selection INTEGER(hsize_t), DIMENSION(SPACE11_RANK) :: start ! /* The start of the hyperslab */ INTEGER(hsize_t), DIMENSION(SPACE11_RANK) :: stride !/* The stride between block starts for the hyperslab */ INTEGER(hsize_t), DIMENSION(SPACE11_RANK) :: count !/* The number of blocks for the hyperslab */ INTEGER(hsize_t), DIMENSION(SPACE11_RANK) :: BLOCK !/* The size of each block for the hyperslab */ INTEGER(hssize_t), DIMENSION(SPACE11_RANK) :: offset !/* Offset amount for selection */ INTEGER(hsize_t), DIMENSION(SPACE11_RANK) :: low_bounds !/* The low bounds for the selection */ INTEGER(hsize_t), DIMENSION(SPACE11_RANK) :: high_bounds !/* The high bounds for the selection */ INTEGER :: error !/* Create dataspace */ CALL h5screate_simple_f(SPACE11_RANK, dims, sid, error) CALL check("h5screate_simple_f", error, total_error) ! /* Get bounds for 'all' selection */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL check("h5sget_select_bounds_f", error, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(1)), 1, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(2)), 1, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(1)), SPACE11_DIM1, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(2)), SPACE11_DIM2, total_error) !/* Set offset for selection */ offset(1:2) = 1 CALL H5Soffset_simple_f(sid, offset, error) CALL check("H5Soffset_simple_f", error, total_error) !/* Get bounds for 'all' selection with offset (which should be ignored) */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL check("h5sget_select_bounds_f", error, total_error) CALL verify("h5sget_select_bounds_f", INT(low_bounds(1)), 1, total_error) CALL verify("h5sget_select_bounds_f", INT(low_bounds(2)), 1, total_error) CALL verify("h5sget_select_bounds_f", INT(high_bounds(1)), SPACE11_DIM1, total_error) CALL verify("h5sget_select_bounds_f", INT(high_bounds(2)), SPACE11_DIM2, total_error) !/* Reset offset for selection */ offset(1:2) = 0 CALL H5Soffset_simple_f(sid, offset, error) CALL check("H5Soffset_simple_f", error, total_error) !/* Set 'none' selection */ CALL H5Sselect_none_f(sid, error) CALL check("H5Sselect_none_f", error, total_error) !/* Get bounds for 'none' selection, should fail */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL VERIFY("h5sget_select_bounds_f", error, -1, total_error) !/* Set point selection */ coord(1,1)= 3; coord(2,1)= 3; coord(1,2)= 3; coord(2,2)= 46; coord(1,3)= 96; coord(2,3)= 3; coord(1,4)= 96; coord(2,4)= 46; CALL h5sselect_elements_f(sid, H5S_SELECT_SET_F, SPACE11_RANK, INT(SPACE11_NPOINTS,size_t), coord, error) CALL check("h5sselect_elements_f", error, total_error) !/* Get bounds for point selection */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL check("h5sget_select_bounds_f", error, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(1)), 3, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(2)), 3, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(1)), SPACE11_DIM1-4, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(2)), SPACE11_DIM2-4, total_error) ! /* Set bad offset for selection */ offset(1:2) = (/5,-5/) CALL H5Soffset_simple_f(sid, offset, error) CALL check("H5Soffset_simple_f", error, total_error) ! /* Get bounds for hyperslab selection with negative offset */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL VERIFY("h5sget_select_bounds_f", error, -1, total_error) ! /* Set valid offset for selection */ offset(1:2) = (/2,-2/) CALL H5Soffset_simple_f(sid, offset, error) CALL check("H5Soffset_simple_f", error, total_error) ! /* Get bounds for point selection with offset */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL check("h5sget_select_bounds_f", error, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(1)), 5, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(2)), 1, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(1)), SPACE11_DIM1-2, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(2)), SPACE11_DIM2-6, total_error) ! /* Reset offset for selection */ offset(1:2) = 0 CALL H5Soffset_simple_f(sid, offset, error) CALL check("H5Soffset_simple_f", error, total_error) ! /* Set "regular" hyperslab selection */ start(1:2) = 2 stride(1:2) = 10 count(1:2) = 4 block(1:2) = 5 CALL h5sselect_hyperslab_f(sid, H5S_SELECT_SET_F, start, & count, error, stride, block) CALL check("h5sselect_hyperslab_f", error, total_error) !/* Get bounds for hyperslab selection */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL check("h5sget_select_bounds_f", error, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(1)), 3, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(2)), 3, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(1)), 37, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(2)), 37, total_error) !/* Set bad offset for selection */ offset(1:2) = (/5,-5/) CALL H5Soffset_simple_f(sid, offset, error) CALL check("H5Soffset_simple_f", error, total_error) ! /* Get bounds for hyperslab selection with negative offset */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL VERIFY("h5sget_select_bounds_f", error, -1, total_error) ! /* Set valid offset for selection */ offset(1:2) = (/5,-2/) CALL H5Soffset_simple_f(sid, offset, error) CALL check("H5Soffset_simple_f", error, total_error) !/* Get bounds for hyperslab selection with offset */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL check("h5sget_select_bounds_f", error, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(1)), 8, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(2)), 1, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(1)), 42, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(2)), 35, total_error) !/* Reset offset for selection */ offset(1:2) = 0 CALL H5Soffset_simple_f(sid, offset, error) CALL check("H5Soffset_simple_f", error, total_error) ! /* Make "irregular" hyperslab selection */ start(1:2) = 20 stride(1:2) = 20 count(1:2) = 2 block(1:2) = 10 CALL h5sselect_hyperslab_f(sid, H5S_SELECT_OR_F, start, & count, error, stride, block) CALL check("h5sselect_hyperslab_f", error, total_error) !/* Get bounds for hyperslab selection */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL check("h5sget_select_bounds_f", error, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(1)), 3, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(2)), 3, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(1)), 50, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(2)), 50, total_error) ! /* Set bad offset for selection */ offset(1:2) = (/5,-5/) CALL H5Soffset_simple_f(sid, offset, error) CALL check("H5Soffset_simple_f", error, total_error) ! /* Get bounds for hyperslab selection with negative offset */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL VERIFY("h5sget_select_bounds_f", error, -1, total_error) !/* Set valid offset for selection */ offset(1:2) = (/5,-2/) CALL H5Soffset_simple_f(sid, offset, error) CALL check("H5Soffset_simple_f", error, total_error) !/* Get bounds for hyperslab selection with offset */ CALL h5sget_select_bounds_f(sid, low_bounds, high_bounds, error) CALL check("h5sget_select_bounds_f", error, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(1)), 8, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(low_bounds(2)), 1, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(1)), 55, total_error) CALL VERIFY("h5sget_select_bounds_f", INT(high_bounds(2)), 48, total_error) !/* Reset offset for selection */ offset(1:2) = 0 CALL H5Soffset_simple_f(sid, offset, error) CALL check("H5Soffset_simple_f", error, total_error) !/* Close the dataspace */ CALL h5sclose_f(sid, error) CALL check("h5sclose_f", error, total_error) END SUBROUTINE test_select_bounds
apache-2.0
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/g77/980628-7.f
191
1449
c { dg-do run } * 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 real r1(5), r2(5), r3(5) double precision d1, d2, d3 integer i1, i2, i3 equivalence (d1, r1(2)) equivalence (d2, r2(2)) equivalence (d3, r3(2)) r1(1) = 1. d1 = 10. r1(4) = 1. r1(5) = 1. i1 = 1 r2(1) = 2. d2 = 20. r2(4) = 2. r2(5) = 2. i2 = 2 r3(1) = 3. d3 = 30. r3(4) = 3. r3(5) = 3. i3 = 3 call x (r1, d1, i1, r2, d2, i2, r3, d3, i3) end subroutine x (r1, d1, i1, r2, d2, i2, r3, d3, i3) implicit none real r1(5), r2(5), r3(5) double precision d1, d2, d3 integer i1, i2, i3 if (r1(1) .ne. 1.) call abort if (d1 .ne. 10.) call abort if (r1(4) .ne. 1.) call abort if (r1(5) .ne. 1.) call abort if (i1 .ne. 1) call abort if (r2(1) .ne. 2.) call abort if (d2 .ne. 20.) call abort if (r2(4) .ne. 2.) call abort if (r2(5) .ne. 2.) call abort if (i2 .ne. 2) call abort if (r3(1) .ne. 3.) call abort if (d3 .ne. 30.) call abort if (r3(4) .ne. 3.) call abort if (r3(5) .ne. 3.) call abort if (i3 .ne. 3) call abort end
gpl-2.0
intervigilium/cs259-or32-gcc
gcc/testsuite/gfortran.dg/g77/980628-7.f
191
1449
c { dg-do run } * 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 real r1(5), r2(5), r3(5) double precision d1, d2, d3 integer i1, i2, i3 equivalence (d1, r1(2)) equivalence (d2, r2(2)) equivalence (d3, r3(2)) r1(1) = 1. d1 = 10. r1(4) = 1. r1(5) = 1. i1 = 1 r2(1) = 2. d2 = 20. r2(4) = 2. r2(5) = 2. i2 = 2 r3(1) = 3. d3 = 30. r3(4) = 3. r3(5) = 3. i3 = 3 call x (r1, d1, i1, r2, d2, i2, r3, d3, i3) end subroutine x (r1, d1, i1, r2, d2, i2, r3, d3, i3) implicit none real r1(5), r2(5), r3(5) double precision d1, d2, d3 integer i1, i2, i3 if (r1(1) .ne. 1.) call abort if (d1 .ne. 10.) call abort if (r1(4) .ne. 1.) call abort if (r1(5) .ne. 1.) call abort if (i1 .ne. 1) call abort if (r2(1) .ne. 2.) call abort if (d2 .ne. 20.) call abort if (r2(4) .ne. 2.) call abort if (r2(5) .ne. 2.) call abort if (i2 .ne. 2) call abort if (r3(1) .ne. 3.) call abort if (d3 .ne. 30.) call abort if (r3(4) .ne. 3.) call abort if (r3(5) .ne. 3.) call abort if (i3 .ne. 3) call abort end
gpl-2.0
Zoxc/avery-binutils
gdb/testsuite/gdb.fortran/vla.f90
9
1764
! Copyright 2015 Free Software Foundation, Inc. ! ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 3 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. If not, see <http://www.gnu.org/licenses/>. program vla real, target, allocatable :: vla1 (:, :, :) real, target, allocatable :: vla2 (:, :, :) real, target, allocatable :: vla3 (:, :) real, pointer :: pvla (:, :, :) logical :: l allocate (vla1 (10,10,10)) ! vla1-init l = allocated(vla1) allocate (vla2 (1:7,42:50,13:35)) ! vla1-allocated l = allocated(vla2) vla1(:, :, :) = 1311 ! vla2-allocated vla1(3, 6, 9) = 42 vla1(1, 3, 8) = 1001 vla1(6, 2, 7) = 13 vla2(:, :, :) = 1311 ! vla1-filled vla2(5, 45, 20) = 42 pvla => vla1 ! vla2-filled l = associated(pvla) pvla => vla2 ! pvla-associated l = associated(pvla) pvla(5, 45, 20) = 1 pvla(7, 45, 14) = 2 pvla => null() ! pvla-re-associated l = associated(pvla) deallocate (vla1) ! pvla-deassociated l = allocated(vla1) deallocate (vla2) ! vla1-deallocated l = allocated(vla2) allocate (vla3 (2,2)) ! vla2-deallocated vla3(:,:) = 13 end program vla
gpl-2.0
avtobiff/virtualagc
GeminiCatchUpandRendezvousProgram/ERRANG.f
11
1387
C COPYRIGHT NONE. THIS CODE IS IN THE PUBLIC DOMAIN. C FILENAME GEMINICATCHUPANDRENDEZVOUSPROGRAM/ERRANG.F C PURPOSE THIS IS PART OF THE ORIGINAL 1965 SIMULATION C PROGRAM FOR THE GEMINI 7/6 MISSION C CATCH-UP AND RENDEZVOUS FLIGHT PHASES. C THIS PARTICULAR FILE CONTAINS ONLY THE C ERRANG SUBROUTINE (ERROR ANGLE SUBROUTINE). C WEBSITE WWW.IBIBLIO.ORG/APOLLO C HISTORY 2010-08-14 RSB BEGAN TRANSCRIBING FROM C THE SCANNED PDF REPORT. C C REFER TO MAIN.F FOR MORE-DETAILED INTRODUCTORY COMMENTS. C C FROM PAGE 164 OF THE REPORT SUBROUTINE ERRANG (CUDPHS,CUDPSS,CUDTHS,CDPHSC,CDPSSC,CDTHSC) 1 IF(ABSF(CUDPHS)-20./57.2957795) 3, 3, 4 3 CDPHSC=CUDPHS GO TO 7 4 IF (CUDPHS) 5, 6, 6 5 CDPHSC=-20./57.2957795 GO TO 7 6 CDPHSC=20./57.2957795 7 IF (ABSF(CUDPSS)-20./57.2957795) 8, 8, 9 8 CDPSSC=CUDPSS GO TO 12 9 IF (CUDPSS) 10, 11, 11 10 CDPSSC=-20./57.2957795 GO TO 12 11 CDPSSC=20./57.2957795 12 IF (ABSF(CUDTHS)-20./57.2957795) 13, 14, 14 13 CDTHSC=CUDTHS GO TO 2 14 IF (CUDTHS) 15, 16, 16 15 CDTHSC=-20./57.2957795 GO TO 2 16 CDTHSC=20./57.2957795 2 RETURN END(1,1,0,0,0,0,1,1,0,0,0,0,0,0,0)
gpl-2.0
intervigilium/cs259-or32-gcc
gcc/testsuite/gfortran.dg/namelist_24.f90
166
1745
!{ dg-do run } !{ dg-options -std=gnu } ! Tests namelist read when more data is provided then specified by ! array qualifier in list. ! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org>. program pr24459 implicit none integer nd, ier, i, j parameter ( nd = 5 ) character*(8) names(nd,nd) character*(8) names2(nd,nd) character*(8) names3(nd,nd) namelist / mynml / names, names2, names3 open(unit=20,status='scratch', delim='apostrophe') write (20, '(a)') "&MYNML" write (20, '(a)') "NAMES = 25*'0'" write (20, '(a)') "NAMES2 = 25*'0'" write (20, '(a)') "NAMES3 = 25*'0'" write (20, '(a)') "NAMES(2,2) = 'frogger'" write (20, '(a)') "NAMES(1,1) = 'E123' 'E456' 'D789' 'P135' 'P246'" write (20, '(a)') "NAMES2(1:5:2,2) = 'abcde' 'fghij' 'klmno'" write (20, '(a)') "NAMES3 = 'E123' 'E456' 'D789' 'P135' 'P246' '0' 'frogger'" write (20, '(a)') "/" rewind(20) read(20,nml=mynml, iostat=ier) if (ier.ne.0) call abort() if (any(names(:,3:5).ne."0")) call abort() if (names(2,2).ne."frogger") call abort() if (names(1,1).ne."E123") call abort() if (names(2,1).ne."E456") call abort() if (names(3,1).ne."D789") call abort() if (names(4,1).ne."P135") call abort() if (names(5,1).ne."P246") call abort() if (any(names2(:,1).ne."0")) call abort() if (any(names2(:,3:5).ne."0")) call abort() if (names2(1,2).ne."abcde") call abort() if (names2(2,2).ne."0") call abort() if (names2(3,2).ne."fghij") call abort() if (names2(4,2).ne."0") call abort() if (names2(5,2).ne."klmno") call abort() if (any(names3.ne.names)) call abort() end
gpl-2.0
mfvalin/rmnlib
bmf/bmf_areastop.f90
3
1100
!/* RMNLIB - Library of useful routines for C and FORTRAN programming ! * Copyright (C) 1975-2005 Environnement Canada ! * ! * This library is free software; you can redistribute it and/or ! * modify it under the terms of the GNU Lesser General Public ! * License as published by the Free Software Foundation, ! * version 2.1 of the License. ! * ! * This library is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! * Lesser General Public License for more details. ! * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the ! * Free Software Foundation, Inc., 59 Temple Place - Suite 330, ! * Boston, MA 02111-1307, USA. ! */ subroutine bmf_areastop use bmf_area implicit none ! ! ! istart = -1 jstart = -1 iend = -1 jend = -1 ! in_the_game=.false. bloc_in_the_game=.false. if(allocated(recvcountv)) then deallocate(recvcountv) endif ! end subroutine bmf_areastop
lgpl-2.1
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/optional_dim_3.f90
144
1760
! { dg-do run } ! PR34540 cshift, eoshift, kind=1 and kind=2 arguments. ! Test case thanks to Thomas Koenig. module tst_foo implicit none contains subroutine tst_optional(a,n1,n2) integer(kind=1), intent(in), optional:: n1 integer(kind=2), intent(in), optional:: n2 integer(kind=1), dimension(2) :: s1 character(64) :: testbuf real, dimension(:,:) :: a s1 = (/1, 1/) write(testbuf,'(4F10.2)') cshift(a, shift=s1) if (testbuf /= " 2.00 1.00 4.00 3.00") CALL abort write(testbuf,'(4F10.2)') cshift(a,shift=s1,dim=n2) if (testbuf /= " 2.00 1.00 4.00 3.00") CALL abort write(testbuf,'(4F10.2)') eoshift(a,shift=s1,dim=n1) if (testbuf /= " 2.00 0.00 4.00 0.00") CALL abort write(testbuf,'(4F10.2)') eoshift(a,shift=s1,dim=n2) if (testbuf /= " 2.00 0.00 4.00 0.00") CALL abort end subroutine tst_optional subroutine sub(bound, dimmy) integer(kind=8), optional :: dimmy logical, optional :: bound logical :: lotto(4) character(20) :: testbuf lotto = .false. lotto = cshift((/.true.,.false.,.true.,.false./),1,dim=dimmy) write(testbuf,*) lotto if (trim(testbuf).ne." F T F T") call abort lotto = .false. lotto = eoshift((/.true.,.true.,.true.,.true./),1,boundary=bound,dim=dimmy) lotto = eoshift(lotto,1,dim=dimmy) write(testbuf,*) lotto if (trim(testbuf).ne." T T F F") call abort end subroutine end module tst_foo program main use tst_foo implicit none real, dimension(2,2) :: r integer(kind=1) :: d1 integer(kind=2) :: d2 data r /1.0, 2.0, 3.0, 4.0/ d1 = 1_1 d2 = 1_2 call tst_optional(r,d1, d2) call sub(bound=.false., dimmy=1_8) call sub() end program main
gpl-2.0
Hellybean/SaberMod_ROM_Toolchain
gcc/testsuite/gfortran.dg/vector_subscript_6.f90
114
1154
! { dg-do compile } ! { dg-options "-fdump-tree-original" } subroutine test0(esss,Ix, e_x) real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss real(kind=kind(1.0d0)), dimension(:), intent(in) :: Ix integer(kind=kind(1)), dimension(:), intent(in) :: e_x esss = Ix(e_x) end subroutine subroutine test1(esss,Ix, e_x) real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss real(kind=kind(1.0d0)), dimension(:), intent(in) :: Ix integer(kind=4), dimension(:), intent(in) :: e_x esss = Ix(e_x) end subroutine subroutine test2(esss,Ix, e_x) real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss real(kind=kind(1.0d0)), dimension(:), intent(in) :: Ix integer(kind=8), dimension(:), intent(in) :: e_x esss = Ix(e_x) end subroutine subroutine test3(esss,Ix,Iyz, e_x, ii_ivec) real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss real(kind=kind(1.0d0)), dimension(:), intent(in) :: Ix,Iyz integer(kind=kind(1)), dimension(:), intent(in) :: e_x,ii_ivec esss = esss + Ix(e_x) * Iyz(ii_ivec) end subroutine ! { dg-final { scan-tree-dump-not "malloc" "original" } } ! { dg-final { cleanup-tree-dump "original" } }
gpl-2.0
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/pr18122.f90
182
1212
! { dg-do run } ! test namelist with scalars and arrays. ! Based on example provided by thomas.koenig@online.de program sechs_w implicit none integer, parameter :: dr=selected_real_kind(15) integer, parameter :: nkmax=6 real (kind=dr) :: rb(nkmax) integer :: z real (kind=dr) :: dg real (kind=dr) :: a real (kind=dr) :: da real (kind=dr) :: delta real (kind=dr) :: s,t integer :: nk real (kind=dr) alpha0 real (kind=dr) :: phi, phi0, rad, rex, zk, z0, drdphi, dzdphi namelist /schnecke/ z, dg, a, t, delta, s, nk, rb, alpha0 open (10,status="scratch") write (10, *) "&SCHNECKE" write (10, *) " z=1," write (10, *) " dg=58.4," write (10, *) " a=48.," write (10, *) " delta=0.4," write (10, *) " s=0.4," write (10, *) " nk=6," write (10, *) " rb=60, 0, 40," write (10, *) " alpha0=20.," write (10, *) "/" rewind (10) read (10,schnecke) close (10) if ((z /= 1) .or. (dg /= 58.4_dr) .or. (a /= 48.0_dr) .or. & (delta /= 0.4_dr).or. (s /= 0.4_dr) .or. (nk /= 6) .or. & (rb(1) /= 60._dr).or. (rb(2) /= 0.0_dr).or. (rb(3) /=40.0_dr).or. & (alpha0 /= 20.0_dr)) call abort () end program sechs_w
gpl-2.0
timj/starlink-pyndf
chr/test_isnam.f
1
2456
SUBROUTINE TEST_ISNAM(STATUS) *+ * Name: * TEST_ISNAM * Purpose: * Test CHR_ISNAM. * Language: * Starlink Fortran 77 * Invocation: * CALL TEST_ISNAM(STATUS) * Description: * Test CHR_ISNAM. * If any failure occurs, return STATUS = SAI__ERROR. * Otherwise, STATUS is unchanged. * Arguments: * STATUS = INTEGER (Returned) * The status of the tests. * Copyright: * Copyright (C) 1989, 1993, 1994 Science & Engineering Research Council. * All Rights Reserved. * Licence: * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be * useful,but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street,Fifth Floor, Boston, MA * 02110-1301, USA * Authors: * RLVAD::AJC: A J Chipperfield (STARLINK) * RLVAD::ACC: A C Charles (STARLINK) * {enter_new_authors_here} * History: * 17-AUG-1989 (RLVAD::AJC): * Original version. * 14-SEP-1993 (ACC) * Modularised version: broken into one routine for each of 5 main * categories of tests. * 02-MAR-1994 (ACC) * Second modularised version: broken further into one routine for * each of subroutine tested. This subroutine created. * {enter_further_changes_here} * Bugs: * {note_any_bugs_here} * Subprograms called: * CHR_ISNAM *- * Type Definitions: IMPLICIT NONE ! No implicit typing * Arguments Given: * None * Arguments Returned: INTEGER STATUS * Global Constants: INCLUDE 'SAE_PAR' ! Standard SAE constants INCLUDE 'CHR_ERR' * External References: LOGICAL CHR_ISNAM *. * Test CHR_ISNAM IF (CHR_ISNAM('NAME01') .AND. .NOT. : (CHR_ISNAM('01NAME') .OR. CHR_ISNAM('NAME@'))) THEN PRINT *, 'CHR_ISNAM OK' ELSE PRINT *, 'CHR_ISNAM FAILS' STATUS = SAI__ERROR ENDIF END
gpl-3.0
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/ieee/ieee_3.f90
80
6129
! { dg-do run } use :: ieee_arithmetic implicit none real :: sx1, sx2, sx3 double precision :: dx1, dx2, dx3 integer, parameter :: s = kind(sx1), d = kind(dx1) type(ieee_round_type) :: mode ! Test IEEE_IS_FINITE if (ieee_support_datatype(0._s)) then if (.not. ieee_is_finite(0.2_s)) call abort if (.not. ieee_is_finite(-0.2_s)) call abort if (.not. ieee_is_finite(0._s)) call abort if (.not. ieee_is_finite(-0._s)) call abort if (.not. ieee_is_finite(tiny(0._s))) call abort if (.not. ieee_is_finite(tiny(0._s)/100)) call abort if (.not. ieee_is_finite(huge(0._s))) call abort if (.not. ieee_is_finite(-huge(0._s))) call abort sx1 = huge(sx1) if (ieee_is_finite(2*sx1)) call abort if (ieee_is_finite(2*(-sx1))) call abort sx1 = ieee_value(sx1, ieee_quiet_nan) if (ieee_is_finite(sx1)) call abort end if if (ieee_support_datatype(0._d)) then if (.not. ieee_is_finite(0.2_d)) call abort if (.not. ieee_is_finite(-0.2_d)) call abort if (.not. ieee_is_finite(0._d)) call abort if (.not. ieee_is_finite(-0._d)) call abort if (.not. ieee_is_finite(tiny(0._d))) call abort if (.not. ieee_is_finite(tiny(0._d)/100)) call abort if (.not. ieee_is_finite(huge(0._d))) call abort if (.not. ieee_is_finite(-huge(0._d))) call abort dx1 = huge(dx1) if (ieee_is_finite(2*dx1)) call abort if (ieee_is_finite(2*(-dx1))) call abort dx1 = ieee_value(dx1, ieee_quiet_nan) if (ieee_is_finite(dx1)) call abort end if ! Test IEEE_IS_NAN if (ieee_support_datatype(0._s)) then if (ieee_is_nan(0.2_s)) call abort if (ieee_is_nan(-0.2_s)) call abort if (ieee_is_nan(0._s)) call abort if (ieee_is_nan(-0._s)) call abort if (ieee_is_nan(tiny(0._s))) call abort if (ieee_is_nan(tiny(0._s)/100)) call abort if (ieee_is_nan(huge(0._s))) call abort if (ieee_is_nan(-huge(0._s))) call abort sx1 = huge(sx1) if (ieee_is_nan(2*sx1)) call abort if (ieee_is_nan(2*(-sx1))) call abort sx1 = ieee_value(sx1, ieee_quiet_nan) if (.not. ieee_is_nan(sx1)) call abort sx1 = -1 if (.not. ieee_is_nan(sqrt(sx1))) call abort end if if (ieee_support_datatype(0._d)) then if (ieee_is_nan(0.2_d)) call abort if (ieee_is_nan(-0.2_d)) call abort if (ieee_is_nan(0._d)) call abort if (ieee_is_nan(-0._d)) call abort if (ieee_is_nan(tiny(0._d))) call abort if (ieee_is_nan(tiny(0._d)/100)) call abort if (ieee_is_nan(huge(0._d))) call abort if (ieee_is_nan(-huge(0._d))) call abort dx1 = huge(dx1) if (ieee_is_nan(2*dx1)) call abort if (ieee_is_nan(2*(-dx1))) call abort dx1 = ieee_value(dx1, ieee_quiet_nan) if (.not. ieee_is_nan(dx1)) call abort dx1 = -1 if (.not. ieee_is_nan(sqrt(dx1))) call abort end if ! IEEE_IS_NEGATIVE if (ieee_support_datatype(0._s)) then if (ieee_is_negative(0.2_s)) call abort if (.not. ieee_is_negative(-0.2_s)) call abort if (ieee_is_negative(0._s)) call abort if (.not. ieee_is_negative(-0._s)) call abort if (ieee_is_negative(tiny(0._s))) call abort if (ieee_is_negative(tiny(0._s)/100)) call abort if (.not. ieee_is_negative(-tiny(0._s))) call abort if (.not. ieee_is_negative(-tiny(0._s)/100)) call abort if (ieee_is_negative(huge(0._s))) call abort if (.not. ieee_is_negative(-huge(0._s))) call abort sx1 = huge(sx1) if (ieee_is_negative(2*sx1)) call abort if (.not. ieee_is_negative(2*(-sx1))) call abort sx1 = ieee_value(sx1, ieee_quiet_nan) if (ieee_is_negative(sx1)) call abort sx1 = -1 if (ieee_is_negative(sqrt(sx1))) call abort end if if (ieee_support_datatype(0._d)) then if (ieee_is_negative(0.2_d)) call abort if (.not. ieee_is_negative(-0.2_d)) call abort if (ieee_is_negative(0._d)) call abort if (.not. ieee_is_negative(-0._d)) call abort if (ieee_is_negative(tiny(0._d))) call abort if (ieee_is_negative(tiny(0._d)/100)) call abort if (.not. ieee_is_negative(-tiny(0._d))) call abort if (.not. ieee_is_negative(-tiny(0._d)/100)) call abort if (ieee_is_negative(huge(0._d))) call abort if (.not. ieee_is_negative(-huge(0._d))) call abort dx1 = huge(dx1) if (ieee_is_negative(2*dx1)) call abort if (.not. ieee_is_negative(2*(-dx1))) call abort dx1 = ieee_value(dx1, ieee_quiet_nan) if (ieee_is_negative(dx1)) call abort dx1 = -1 if (ieee_is_negative(sqrt(dx1))) call abort end if ! Test IEEE_IS_NORMAL if (ieee_support_datatype(0._s)) then if (.not. ieee_is_normal(0.2_s)) call abort if (.not. ieee_is_normal(-0.2_s)) call abort if (.not. ieee_is_normal(0._s)) call abort if (.not. ieee_is_normal(-0._s)) call abort if (.not. ieee_is_normal(tiny(0._s))) call abort if (ieee_is_normal(tiny(0._s)/100)) call abort if (.not. ieee_is_normal(-tiny(0._s))) call abort if (ieee_is_normal(-tiny(0._s)/100)) call abort if (.not. ieee_is_normal(huge(0._s))) call abort if (.not. ieee_is_normal(-huge(0._s))) call abort sx1 = huge(sx1) if (ieee_is_normal(2*sx1)) call abort if (ieee_is_normal(2*(-sx1))) call abort sx1 = ieee_value(sx1, ieee_quiet_nan) if (ieee_is_normal(sx1)) call abort sx1 = -1 if (ieee_is_normal(sqrt(sx1))) call abort end if if (ieee_support_datatype(0._d)) then if (.not. ieee_is_normal(0.2_d)) call abort if (.not. ieee_is_normal(-0.2_d)) call abort if (.not. ieee_is_normal(0._d)) call abort if (.not. ieee_is_normal(-0._d)) call abort if (.not. ieee_is_normal(tiny(0._d))) call abort if (ieee_is_normal(tiny(0._d)/100)) call abort if (.not. ieee_is_normal(-tiny(0._d))) call abort if (ieee_is_normal(-tiny(0._d)/100)) call abort if (.not. ieee_is_normal(huge(0._d))) call abort if (.not. ieee_is_normal(-huge(0._d))) call abort dx1 = huge(dx1) if (ieee_is_normal(2*dx1)) call abort if (ieee_is_normal(2*(-dx1))) call abort dx1 = ieee_value(dx1, ieee_quiet_nan) if (ieee_is_normal(dx1)) call abort dx1 = -1 if (ieee_is_normal(sqrt(dx1))) call abort end if end
gpl-2.0
kmkolasinski/Quantulaba
modcommons.f90
2
12772
module modcommons implicit none doubleprecision,public :: CONDA complex*16 ,parameter,public :: II = CMPLX(0.0D0,1.0D0) integer ,parameter,public :: M_IN = 1 , M_OUT = 2 ! numbering the incoming mode and outgoing one integer,parameter,public :: QSYS_NO_BONDS_INC_VALUE = 10 ! For sparse structures integer,parameter,public :: QSYS_NO_ATOMS_INC_VALUE = 10000 ! doubleprecision,public :: QSYS_COUPLING_CUTOFF_VALUE = 0.0D0 ! logical,public :: QSYS_DISABLE_HERMICITY_CHECK = .false. logical,public :: QSYS_FORCE_HERMITIAN_MATRIX = .true. ! by default creates hermitian matrix, so connect ! function may take care only for the nnb with greater ID number double precision,public :: QSYS_DELTA_SVD = 1.0D-16 ! Minimal value of SVD decomposion, modes < delta are rejjected from Bloch matrices double precision,public :: QSYS_ERROR_EPS = 1.0D-10 ! Used to choose which method will be used, during modes stabilization logical,public :: QSYS_FORCE_SCHUR_DECOMPOSITION = .false. ! Maybe more stable but slower only for WFM logical,public :: QSYS_FORCE_ZGGEV_TO_FIND_MODES = .false. ! When finding modes use generalied eigenvalue problem, can be more stable integer,public :: QSYS_DEBUG_LEVEL = 0 ! 0 - less messages, 1-more, 2-even more doubleprecision,parameter :: qsys_double_error = 1.0D-16 ! approximated error of double presicion numerical error ENUM, BIND(C) ENUMERATOR :: QSYS_SCATTERING_QTBM = 1 ! solve scattering problem with QTBM ENUMERATOR :: QSYS_SCATTERING_WFM = 2 ! solve with WFM ENUMERATOR :: QSYS_SCATTERING_QTBM_TAKE_ALL_EVAN = -1 ! force QTBM to take all evanescent modes (may be not stable) END ENUM ENUM, BIND(C) ENUMERATOR :: QSYS_LINSYS_STEP_FACTORIZE = 1 ! factorize matrix ENUMERATOR :: QSYS_LINSYS_STEP_SOLVE = 2 ! solve system ENUMERATOR :: QSYS_LINSYS_STEP_FREE_MEMORY = 3 ! free memory ENUMERATOR :: QSYS_LINSYS_ALL_STEPS = 4 ! all steps in one call END ENUM ! PARDISO matrix types definition ENUM, BIND(C) ENUMERATOR :: QSYS_LINSYS_PARDISO_REAL_STRUCT_SYM = 1 ! real and structurally symmetric ENUMERATOR :: QSYS_LINSYS_PARDISO_REAL_SYM_POSITIVE_DEFINE = 2 ! real and symmetric positive definite ENUMERATOR :: QSYS_LINSYS_PARDISO_REAL_SYM_IDENFINITE = -2 ! real and symmetric indefinite ENUMERATOR :: QSYS_LINSYS_PARDISO_CMPLX_STRUCT_SYM = 3 ! complex and structurally symmetric ENUMERATOR :: QSYS_LINSYS_PARDISO_CMPLX_HERMITIAN_POSITIVE_DEFINE = 4 ! complex and Hermitian positive definite ENUMERATOR :: QSYS_LINSYS_PARDISO_CMPLX_HERMITIAN_IDENFINITE = -4 ! complex and Hermitian indefinite ENUMERATOR :: QSYS_LINSYS_PARDISO_CMPLX_SYM = 6 ! complex and symmetric ENUMERATOR :: QSYS_LINSYS_PARDISO_REAL_NON_SYM = 11 ! real and nonsymmetric ENUMERATOR :: QSYS_LINSYS_PARDISO_CMPLX_NON_SYM = 13 ! complex and nonsymmetric END ENUM public :: QSYS_LINSYS_STEP_FACTORIZE,QSYS_LINSYS_STEP_SOLVE,QSYS_LINSYS_STEP_FREE_MEMORY,QSYS_LINSYS_ALL_STEPS public :: QSYS_LINSYS_PARDISO_REAL_STRUCT_SYM,QSYS_LINSYS_PARDISO_REAL_SYM_POSITIVE_DEFINE,QSYS_LINSYS_PARDISO_REAL_SYM_IDENFINITE public :: QSYS_LINSYS_PARDISO_CMPLX_STRUCT_SYM,QSYS_LINSYS_PARDISO_CMPLX_HERMITIAN_POSITIVE_DEFINE,QSYS_LINSYS_PARDISO_CMPLX_HERMITIAN_IDENFINITE public :: QSYS_LINSYS_PARDISO_CMPLX_SYM,QSYS_LINSYS_PARDISO_REAL_NON_SYM,QSYS_LINSYS_PARDISO_CMPLX_NON_SYM public :: QSYS_SCATTERING_QTBM, QSYS_SCATTERING_WFM , QSYS_SCATTERING_QTBM_TAKE_ALL_EVAN public :: qsys_double_error ENUM, BIND(C) ENUMERATOR :: QSYS_LEAD_TYPE_NORMAL = 0 ENUMERATOR :: QSYS_LEAD_TYPE_PSEUDO_TRANSPARENT = 1 END ENUM public :: QSYS_LEAD_TYPE_NORMAL,QSYS_LEAD_TYPE_PSEUDO_TRANSPARENT integer,public :: QSYS_SCATTERING_METHOD = QSYS_SCATTERING_WFM ! choose approach integer,public :: QSYS_SCATTERING_QTBM_NO_EVAN = QSYS_SCATTERING_QTBM_TAKE_ALL_EVAN ! force number of evanescent modes in calculation logical,public :: B_SINGULAR_MATRIX = .false. ! ------------------------------------------------------- integer,parameter :: QTOOLS_FD_EXPANSION_MAX_ORDER = 10 ! calculate up to 4th order of finite difference ! expansion of derivative. See modutils for more details. public :: QTOOLS_FD_EXPANSION_MAX_ORDER ! ------------------------------------------------------- private ! ----------------------------------------------- ! Stucture which holds connection between ! Atom A and B. ! ----------------------------------------------- type qbond integer :: toAtomID ! ID of atom B integer :: fromBondID ! id of bond in atom B to A complex*16,allocatable,dimension(:,:) :: bondMatrix complex*16,allocatable,dimension(:,:) :: overlapMatrix ! overlap matrix in case of LCAO orbitals contains procedure, public, pass(this) :: destroy_bond procedure, public, pass(this) :: copy_bond endtype qbond ! ----------------------------------------------- ! Stucture which holds the information about ! atom ! ----------------------------------------------- type qatom doubleprecision :: atom_pos(3) ! position (x,y,z) in some units integer :: no_in_states ! number of internal states (e.g. spin degree of freedom) logical :: bActive ! if the site is taken into calculations integer :: flag , flag_aux0 ! arbitrary number, can be used by user e.g. to distinguish two different atoms integer,allocatable,dimension(:) :: globalIDs ! in case of no_bonds > 1 this array contains global ID of atom in spin state type(qbond),allocatable,dimension(:) :: bonds ! contains information about hoping between different atoms ! Atom A may have connection with itself integer :: no_bonds ! nuber of conetions with different atoms contains procedure, public, pass(site) :: init procedure, public, pass(site) :: destroy procedure, public, pass(site) :: add_bond end type qatom ! ---------------------------------------------------------------- ! Structure responsible for Nearest neigthbour search parameter ! ---------------------------------------------------------------- ENUM , BIND(C) ENUMERATOR :: QSYS_NNB_FILTER_BOX = 1 ENUMERATOR :: QSYS_NNB_FILTER_CHECK_ALL = 2 ENUMERATOR :: QSYS_NNB_FILTER_DISTANCE = 3 END ENUM type nnb_params doubleprecision :: box(3) ! estimated search distance in XYZ directions doubleprecision :: distance ! if NNB_FILTER = QSYS_NNB_FILTER_DISTANCE compare distance ! between atoms, not coordinates integer :: NNB_FILTER = QSYS_NNB_FILTER_BOX endtype nnb_params public :: QSYS_NNB_FILTER_CHECK_ALL public :: QSYS_NNB_FILTER_DISTANCE public :: QSYS_NNB_FILTER_BOX public :: qatom , nnb_params public :: reset_clock , get_clock INTEGER,private :: clock1 contains ! ------------------------------------------------------------------------ ! Time functions ! ------------------------------------------------------------------------ subroutine reset_clock() CALL SYSTEM_CLOCK(COUNT=clock1) end subroutine reset_clock real function get_clock() result(c) INTEGER :: clock_rate,c_time CALL SYSTEM_CLOCK(COUNT_RATE=clock_rate) CALL SYSTEM_CLOCK(COUNT=c_time) c = (real(c_time) - clock1)/clock_rate end function get_clock subroutine printDate character(8) :: date character(10) :: time character(5) :: zone integer,dimension(8) :: values ! using keyword arguments call date_and_time(date,time,zone,values) call date_and_time(DATE=date,ZONE=zone) call date_and_time(TIME=time) call date_and_time(VALUES=values) print '(a,2x,a,A,2x,a)'," DATA:", date," TIME:", time end subroutine printDate ! ------------------------------------------------------------------------ ! Initialize qatom structure. This function does not ! have to be called. Each parameter of atom structure ! can be accessed separetely. ! atom_pos - position of atom in space. Units are uniportant. ! no_in_states - [optional] number of spin states. Default value is 1. ! In case of {-1/2,+1/2} electron spin set it to 2. ! bActive - [optional] each atom can be disactivated before final construction ! of the lattice. If bActive == false then dis atom will ! not be taken during the hamiltonian construction. ! flag - [optional] can be used by user to perform some specific action ! ------------------------------------------------------------------------ subroutine init(site,atom_pos,no_in_states,bActive,flag,flag_aux0) class(qatom) :: site doubleprecision :: atom_pos(3) integer, optional :: no_in_states , flag ,flag_aux0 logical, optional :: bActive site%no_in_states = 1 site%bActive = .true. site%atom_pos = atom_pos site%no_bonds = 0 site%flag = 0 site%flag_aux0 = 0 if(present(no_in_states)) site%no_in_states = no_in_states if(present(bActive)) site%bActive = bActive if(present(flag)) site%flag = flag if(present(flag_aux0)) site%flag_aux0 = flag_aux0 end subroutine init ! ------------------------------------------------------------------------ ! Free allocated memory ! ------------------------------------------------------------------------ subroutine destroy(site) class(qatom) :: site integer :: b if(allocated(site%globalIDs)) deallocate(site%globalIDs) do b = 1,site%no_bonds call site%bonds(b)%destroy_bond() enddo if(allocated(site%bonds)) deallocate(site%bonds) site%bActive = .false. site%no_bonds = 0 site%flag = 0 site%flag_aux0 = 0 end subroutine destroy ! ------------------------------------------------------------------------ ! Add new qbonding between two atoms (hoping between A and B). ! fromInnerID - id of spin state of current atom ! toAtomID - id of atom B ! toInnerID - id of spin state of atom B ! bondValue - hoping paremeter ! ------------------------------------------------------------------------ subroutine add_bond(site,toAtomID,bondMatrix,overlapMatrix) class(qatom) :: site integer :: toAtomID complex*16,dimension(:,:) :: bondMatrix complex*16,dimension(:,:) , optional :: overlapMatrix integer :: b,nb,ns1,ns2 ! temporal array type(qbond),allocatable,dimension(:) :: tmp_bonds ! increase number of bond in atoms site%no_bonds = site%no_bonds+1 nb = size(site%bonds) ! adding new bond requires resizing of the bonds array if necessary if(.not. allocated(site%bonds)) then allocate(site%bonds(QSYS_NO_BONDS_INC_VALUE)) else if( site%no_bonds > nb ) then allocate(tmp_bonds(nb)) do b = 1 , nb call tmp_bonds(b)%copy_bond(site%bonds(b)) call site%bonds(b)%destroy_bond() enddo if(allocated(site%bonds)) deallocate(site%bonds) allocate(site%bonds(size(tmp_bonds)+QSYS_NO_BONDS_INC_VALUE)) do b = 1 , nb call site%bonds(b)%copy_bond(tmp_bonds(b)) call tmp_bonds(b)%destroy_bond() enddo deallocate(tmp_bonds) endif ! set new bond ns1 = size(bondMatrix,1) ns2 = size(bondMatrix,2) allocate(site%bonds(site%no_bonds)%bondMatrix(ns1,ns2)) allocate(site%bonds(site%no_bonds)%overlapMatrix(ns1,ns2)) site%bonds(site%no_bonds)%bondMatrix = bondMatrix site%bonds(site%no_bonds)%toAtomID = toAtomID site%bonds(site%no_bonds)%fromBondID = 0 site%bonds(site%no_bonds)%overlapMatrix = 0.0 if(present(overlapMatrix)) site%bonds(site%no_bonds)%overlapMatrix = overlapMatrix; endsubroutine add_bond subroutine destroy_bond(this) class(qbond) :: this this%toAtomID = -1 this%fromBondID = -1 if(allocated(this%overlapMatrix)) deallocate(this%overlapMatrix) if(allocated(this%bondMatrix)) deallocate(this%bondMatrix) end subroutine destroy_bond subroutine copy_bond(this,source) class(qbond) :: this type(qbond) :: source integer :: ns1,ns2 ns1 = size(source%bondMatrix,1) ns2 = size(source%bondMatrix,2) call this%destroy_bond() allocate(this%bondMatrix (ns1,ns2)) allocate(this%overlapMatrix(ns1,ns2)) this%toAtomID = source%toAtomID this%fromBondID = source%fromBondID this%bondMatrix = source%bondMatrix this%overlapMatrix = source%overlapMatrix end subroutine copy_bond end module modcommons
mit
QSTEM/QSTEM
fftw-3.2.2-dll64/fftw3.f
35
2447
INTEGER FFTW_R2HC PARAMETER (FFTW_R2HC=0) INTEGER FFTW_HC2R PARAMETER (FFTW_HC2R=1) INTEGER FFTW_DHT PARAMETER (FFTW_DHT=2) INTEGER FFTW_REDFT00 PARAMETER (FFTW_REDFT00=3) INTEGER FFTW_REDFT01 PARAMETER (FFTW_REDFT01=4) INTEGER FFTW_REDFT10 PARAMETER (FFTW_REDFT10=5) INTEGER FFTW_REDFT11 PARAMETER (FFTW_REDFT11=6) INTEGER FFTW_RODFT00 PARAMETER (FFTW_RODFT00=7) INTEGER FFTW_RODFT01 PARAMETER (FFTW_RODFT01=8) INTEGER FFTW_RODFT10 PARAMETER (FFTW_RODFT10=9) INTEGER FFTW_RODFT11 PARAMETER (FFTW_RODFT11=10) INTEGER FFTW_FORWARD PARAMETER (FFTW_FORWARD=-1) INTEGER FFTW_BACKWARD PARAMETER (FFTW_BACKWARD=+1) INTEGER FFTW_MEASURE PARAMETER (FFTW_MEASURE=0) INTEGER FFTW_DESTROY_INPUT PARAMETER (FFTW_DESTROY_INPUT=1) INTEGER FFTW_UNALIGNED PARAMETER (FFTW_UNALIGNED=2) INTEGER FFTW_CONSERVE_MEMORY PARAMETER (FFTW_CONSERVE_MEMORY=4) INTEGER FFTW_EXHAUSTIVE PARAMETER (FFTW_EXHAUSTIVE=8) INTEGER FFTW_PRESERVE_INPUT PARAMETER (FFTW_PRESERVE_INPUT=16) INTEGER FFTW_PATIENT PARAMETER (FFTW_PATIENT=32) INTEGER FFTW_ESTIMATE PARAMETER (FFTW_ESTIMATE=64) INTEGER FFTW_ESTIMATE_PATIENT PARAMETER (FFTW_ESTIMATE_PATIENT=128) INTEGER FFTW_BELIEVE_PCOST PARAMETER (FFTW_BELIEVE_PCOST=256) INTEGER FFTW_NO_DFT_R2HC PARAMETER (FFTW_NO_DFT_R2HC=512) INTEGER FFTW_NO_NONTHREADED PARAMETER (FFTW_NO_NONTHREADED=1024) INTEGER FFTW_NO_BUFFERING PARAMETER (FFTW_NO_BUFFERING=2048) INTEGER FFTW_NO_INDIRECT_OP PARAMETER (FFTW_NO_INDIRECT_OP=4096) INTEGER FFTW_ALLOW_LARGE_GENERIC PARAMETER (FFTW_ALLOW_LARGE_GENERIC=8192) INTEGER FFTW_NO_RANK_SPLITS PARAMETER (FFTW_NO_RANK_SPLITS=16384) INTEGER FFTW_NO_VRANK_SPLITS PARAMETER (FFTW_NO_VRANK_SPLITS=32768) INTEGER FFTW_NO_VRECURSE PARAMETER (FFTW_NO_VRECURSE=65536) INTEGER FFTW_NO_SIMD PARAMETER (FFTW_NO_SIMD=131072) INTEGER FFTW_NO_SLOW PARAMETER (FFTW_NO_SLOW=262144) INTEGER FFTW_NO_FIXED_RADIX_LARGE_N PARAMETER (FFTW_NO_FIXED_RADIX_LARGE_N=524288) INTEGER FFTW_ALLOW_PRUNING PARAMETER (FFTW_ALLOW_PRUNING=1048576) INTEGER FFTW_WISDOM_ONLY PARAMETER (FFTW_WISDOM_ONLY=2097152)
gpl-3.0
tuxillo/aarch64-dragonfly-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
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/proc_ptr_comp_23.f90
155
1437
! { dg-do run } ! Tests the fix for PR42104 in which the call to the procedure pointer ! component caused an ICE because the "always_implicit flag was not used ! to force the passing of a descriptor for the array argument. ! ! Contributed by Martien Hulsen <m.a.hulsen@tue.nl> ! module poisson_functions_m implicit none contains function func ( nr, x ) integer, intent(in) :: nr real, intent(in), dimension(:) :: x real :: func real :: pi pi = 4 * atan(1.) select case(nr) case(1) func = 0 case(2) func = 1 case(3) func = 1 + cos(pi*x(1))*cos(pi*x(2)) case default write(*,'(/a,i0/)') 'Error func: wrong function number: ', nr stop end select end function func end module poisson_functions_m module element_defs_m implicit none abstract interface function dummyfunc ( nr, x ) integer, intent(in) :: nr real, intent(in), dimension(:) :: x real :: dummyfunc end function dummyfunc end interface type function_p procedure(dummyfunc), nopass, pointer :: p => null() end type function_p end module element_defs_m program t use poisson_functions_m use element_defs_m procedure(dummyfunc), pointer :: p => null() type(function_p) :: funcp p => func funcp%p => func print *, func(nr=3,x=(/0.1,0.1/)) print *, p(nr=3,x=(/0.1,0.1/)) print *, funcp%p(nr=3,x=(/0.1,0.1/)) end program t
gpl-2.0
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/direct_io_5.f90
188
1099
! { dg-do run } ! PR27757 Problems with direct access I/O ! This test checks a series of random writes followed by random reads. ! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org> program testdirect implicit none integer, dimension(100) :: a integer :: i,j,k,ier real :: x data a / 13, 9, 34, 41, 25, 98, 6, 12, 11, 44, 79, 3,& & 64, 61, 77, 57, 59, 2, 92, 38, 71, 64, 31, 60, 28, 90, 26,& & 97, 47, 26, 48, 96, 95, 82, 100, 90, 45, 71, 71, 67, 72,& & 76, 94, 49, 85, 45, 100, 22, 96, 48, 13, 23, 40, 14, 76, 99,& & 96, 90, 65, 2, 8, 60, 96, 19, 45, 1, 100, 48, 91, 20, 92,& & 72, 81, 59, 24, 37, 43, 21, 54, 68, 31, 19, 79, 63, 41,& & 42, 12, 10, 62, 43, 9, 30, 9, 54, 35, 4, 5, 55, 3, 94 / open(unit=15,file="testdirectio",access="direct",form="unformatted",recl=89) do i=1,100 k = a(i) write(unit=15, rec=k) k enddo do j=1,100 read(unit=15, rec=a(j), iostat=ier) k if (ier.ne.0) then call abort() else if (a(j) /= k) call abort() endif enddo close(unit=15, status="delete") end program testdirect
gpl-2.0
tuxillo/aarch64-dragonfly-gcc
gcc/testsuite/gfortran.dg/deferred_type_param_5.f90
136
1180
! { dg-do compile } ! ! PR fortran/49110 ! PR fortran/52843 ! ! Based on a contributed code by jwmwalrus@gmail.com ! ! Before, character(len=:) result variable were rejected in PURE functions. ! module mod1 use iso_c_binding implicit none contains pure function c_strlen(str) character(KIND = C_CHAR), intent(IN) :: str(*) integer :: c_strlen,i i = 1 do if (i < 1) then c_strlen = 0 return end if if (str(i) == c_null_char) exit i = i + 1 end do c_strlen = i - 1 end function c_strlen pure function c2fstring(cbuffer) result(string) character(:), allocatable :: string character(KIND = C_CHAR), intent(IN) :: cbuffer(*) integer :: i continue string = REPEAT(' ', c_strlen(cbuffer)) do i = 1, c_strlen(cbuffer) if (cbuffer(i) == C_NULL_CHAR) exit string(i:i) = cbuffer(i) enddo string = TRIM(string) end function end module mod1 use mod1 character(len=:), allocatable :: str str = c2fstring("ABCDEF"//c_null_char//"GHI") if (len(str) /= 6 .or. str /= "ABCDEF") call abort() end
gpl-2.0
Hellybean/SaberMod_ROM_Toolchain
gcc/testsuite/gfortran.dg/achar_5.f90
181
1818
! { dg-do compile } ! program test print *, char(255) print *, achar(255) print *, char(255,kind=1) print *, achar(255,kind=1) print *, char(255,kind=4) print *, achar(255,kind=4) print *, char(0) print *, achar(0) print *, char(0,kind=1) print *, achar(0,kind=1) print *, char(0,kind=4) print *, achar(0,kind=4) print *, char(297) ! { dg-error "too large for the collating sequence" } print *, achar(297) ! { dg-error "too large for the collating sequence" } print *, char(297,kind=1) ! { dg-error "too large for the collating sequence" } print *, achar(297,kind=1) ! { dg-error "too large for the collating sequence" } print *, char(297,kind=4) print *, achar(297,kind=4) print *, char(-1) ! { dg-error "negative" } print *, achar(-1) ! { dg-error "negative" } print *, char(-1,kind=1) ! { dg-error "negative" } print *, achar(-1,kind=1) ! { dg-error "negative" } print *, char(-1,kind=4) ! { dg-error "negative" } print *, achar(-1,kind=4) ! { dg-error "negative" } print *, char(huge(0_8)) ! { dg-error "too large for the collating sequence" } print *, achar(huge(0_8)) ! { dg-error "too large for the collating sequence" } print *, char(huge(0_8),kind=1) ! { dg-error "too large for the collating sequence" } print *, achar(huge(0_8),kind=1) ! { dg-error "too large for the collating sequence" } print *, char(huge(0_8),kind=4) ! { dg-error "too large for the collating sequence" } print *, achar(huge(0_8),kind=4) ! { dg-error "too large for the collating sequence" } print *, char(z'FFFFFFFF', kind=4) print *, achar(z'FFFFFFFF', kind=4) print *, char(z'100000000', kind=4) ! { dg-error "too large for the collating sequence" } print *, achar(z'100000000', kind=4) ! { dg-error "too large for the collating sequence" } end program test
gpl-2.0
Hellybean/SaberMod_ROM_Toolchain
gcc/testsuite/gfortran.dg/transpose_optimization_2.f90
88
1817
! { dg-do run } ! { dg-options "-fdump-tree-original " } ! Checks the fix for PR46896, in which the optimization that passes ! the argument of TRANSPOSE directly missed the possible aliasing ! through host association. ! ! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org> ! module mod integer :: b(2,3) = reshape([1,2,3,4,5,6], [2,3]) contains subroutine msub(x) integer :: x(:,:) b(1,:) = 99 b(2,:) = x(:,1) if (any (b(:,1) /= [99, 1]).or.any (b(:,2) /= [99, 3])) call abort() end subroutine msub subroutine pure_msub(x, y) integer, intent(in) :: x(:,:) integer, intent(OUT) :: y(size (x, 2), size (x, 1)) y = transpose (x) end subroutine pure_msub end use mod integer :: a(2,3) = reshape([1,2,3,4,5,6], [2,3]) call impure call purity contains ! ! pure_sub and pure_msub could be PURE, if so declared. They do not ! need a temporary. ! subroutine purity integer :: c(2,3) call pure_sub(transpose(a), c) if (any (c .ne. a)) call abort call pure_msub(transpose(b), c) if (any (c .ne. b)) call abort end subroutine purity ! ! sub and msub both need temporaries to avoid aliasing. ! subroutine impure call sub(transpose(a)) end subroutine impure subroutine sub(x) integer :: x(:,:) a(1,:) = 88 a(2,:) = x(:,1) if (any (a(:,1) /= [88, 1]).or.any (a(:,2) /= [88, 3])) call abort() end subroutine sub subroutine pure_sub(x, y) integer, intent(in) :: x(:,:) integer, intent(OUT) :: y(size (x, 2), size (x, 1)) y = transpose (x) end subroutine pure_sub end ! ! The check below for temporaries gave 14 and 33 for "parm" and "atmp". ! ! { dg-final { scan-tree-dump-times "parm" 66 "original" } } ! { dg-final { scan-tree-dump-times "atmp" 12 "original" } } ! { dg-final { cleanup-tree-dump "original" } }
gpl-2.0
Hellybean/SaberMod_ROM_Toolchain
gcc/testsuite/gfortran.dg/proc_decl_23.f90
92
1091
! { dg-do compile } ! Test the fix for PR43227, in which the lines below would segfault. ! ! Dominique d'Humieres <dominiq@lps.ens.fr> ! function char1 (s) result(res) character, dimension(:), intent(in) :: s character(len=size(s)) :: res do i = 1, size(s) res(i:i) = s(i) end do end function char1 module m_string procedure(string_to_char) :: char1 ! segfault procedure(string_to_char), pointer :: char2 ! segfault type t_string procedure(string_to_char), pointer, nopass :: char3 ! segfault end type t_string contains function string_to_char (s) result(res) character, dimension(:), intent(in) :: s character(len=size(s)) :: res do i = 1, size(s) res(i:i) = s(i) end do end function string_to_char end module m_string use m_string type(t_string) :: t print *, string_to_char (["a","b","c"]) char2 => string_to_char print *, char2 (["d","e","f"]) t%char3 => string_to_char print *, t%char3 (["g","h","i"]) print *, char1 (["j","k","l"]) end ! { dg-final { cleanup-tree-dump "m_string" } }
gpl-2.0
intervigilium/cs259-or32-gcc
gcc/testsuite/gfortran.dg/proc_decl_23.f90
92
1091
! { dg-do compile } ! Test the fix for PR43227, in which the lines below would segfault. ! ! Dominique d'Humieres <dominiq@lps.ens.fr> ! function char1 (s) result(res) character, dimension(:), intent(in) :: s character(len=size(s)) :: res do i = 1, size(s) res(i:i) = s(i) end do end function char1 module m_string procedure(string_to_char) :: char1 ! segfault procedure(string_to_char), pointer :: char2 ! segfault type t_string procedure(string_to_char), pointer, nopass :: char3 ! segfault end type t_string contains function string_to_char (s) result(res) character, dimension(:), intent(in) :: s character(len=size(s)) :: res do i = 1, size(s) res(i:i) = s(i) end do end function string_to_char end module m_string use m_string type(t_string) :: t print *, string_to_char (["a","b","c"]) char2 => string_to_char print *, char2 (["d","e","f"]) t%char3 => string_to_char print *, t%char3 (["g","h","i"]) print *, char1 (["j","k","l"]) end ! { dg-final { cleanup-tree-dump "m_string" } }
gpl-2.0
FrontISTR/FrontISTR
fistr1/src/lib/dynamic_mass.f90
1
8599
!------------------------------------------------------------------------------- ! Copyright (c) 2019 FrontISTR Commons ! This software is released under the MIT License, see LICENSE.txt !------------------------------------------------------------------------------- !> This module contains subroutines used in 3d eigen analysis for module m_dynamic_mass contains subroutine mass_C2(etype, nn, ecoord, gausses, sec_opt, thick, mass, lumped, temperature) use mMechGauss use m_MatMatrix use elementInfo implicit none type(tGaussStatus), intent(in) :: gausses(:) !< status of qudrature points integer(kind=kint), intent(in) :: etype !< element type integer(kind=kint), intent(in) :: nn !< number of elemental nodes real(kind=kreal), intent(in) :: ecoord(2,nn) !< coordinates of elemental nodes real(kind=kreal), intent(out) :: mass(:,:) !< mass matrix real(kind=kreal), intent(out) :: lumped(:) !< mass matrix real(kind=kreal), intent(in), optional :: temperature(nn) !< temperature type(tMaterial), pointer :: matl !< material information integer(kind=kint), parameter :: ndof = 2 integer(kind=kint) :: i, j, LX, sec_opt real(kind=kreal) :: naturalCoord(2) real(kind=kreal) :: func(nn), thick real(kind=kreal) :: det, wg, rho real(kind=kreal) :: D(2,2), N(2, nn*ndof), DN(2, nn*ndof) real(kind=kreal) :: gderiv(nn,2) logical :: is_lumped mass(:,:) = 0.0d0 lumped = 0.0d0 matl => gausses(1)%pMaterial if(sec_opt == 2) thick = 1.0d0 do LX = 1, NumOfQuadPoints(etype) call getQuadPoint(etype, LX, naturalCoord) call getShapeFunc(etype, naturalCoord, func) call getGlobalDeriv(etype, nn, naturalcoord, ecoord, det, gderiv) if(present(temperature))then !ina(1) = temperature !call fetch_TableData(MC_ISOELASTIC, matl%dict, outa, ierr, ina) !if(ierr)then rho = matl%variables(M_DENSITY) !else ! rho = outa(1) !endif else !call fetch_TableData(MC_ISOELASTIC, matl%dict, outa, ierr) !if(ierr)then rho = matl%variables(M_DENSITY) !else ! rho = outa(1) !endif endif D = 0.0d0 D(1,1) = rho*thick D(2,2) = rho*thick wg = getWeight(etype, LX)*det N = 0.0d0 do i = 1, nn N(1,2*i-1) = func(i) N(2,2*i ) = func(i) enddo DN(1:2, 1:nn*ndof) = matmul(D, N(1:2, 1:nn*ndof)) forall(i = 1:nn*ndof, j = 1:nn*ndof) mass(i,j) = mass(i,j) + dot_product(N(:,i), DN(:,j))*wg end forall enddo is_lumped = .true. if(is_lumped) call get_lumped_mass(nn, ndof, mass, lumped) end subroutine mass_C2 subroutine mass_C3(etype, nn, ecoord, gausses, mass, lumped, temperature) use mMechGauss use m_MatMatrix use elementInfo implicit none type(tGaussStatus), intent(in) :: gausses(:) !< status of qudrature points integer(kind=kint), intent(in) :: etype !< element type integer(kind=kint), intent(in) :: nn !< number of elemental nodes real(kind=kreal), intent(in) :: ecoord(3,nn) !< coordinates of elemental nodes real(kind=kreal), intent(out) :: mass(:,:) !< mass matrix real(kind=kreal), intent(out) :: lumped(:) !< mass matrix real(kind=kreal), intent(in), optional :: temperature(nn) !< temperature type(tMaterial), pointer :: matl !< material information integer(kind=kint), parameter :: ndof = 3 integer(kind=kint) :: i, j, LX real(kind=kreal) :: naturalCoord(3) real(kind=kreal) :: func(nn) real(kind=kreal) :: det, wg, rho real(kind=kreal) :: D(3, 3), N(3, nn*ndof), DN(3, nn*ndof) real(kind=kreal) :: gderiv(nn, 3) logical :: is_lumped mass(:,:) = 0.0d0 lumped = 0.0d0 matl => gausses(1)%pMaterial do LX = 1, NumOfQuadPoints(etype) call getQuadPoint(etype, LX, naturalCoord) call getShapeFunc(etype, naturalCoord, func) call getGlobalDeriv(etype, nn, naturalcoord, ecoord, det, gderiv) if(present(temperature))then !ina(1) = temperature !call fetch_TableData(MC_ISOELASTIC, matl%dict, outa, ierr, ina) !if(ierr)then rho = matl%variables(M_DENSITY) !else ! rho = outa(1) !endif else !call fetch_TableData(MC_ISOELASTIC, matl%dict, outa, ierr) !if(ierr)then rho = matl%variables(M_DENSITY) !else ! rho = outa(1) !endif endif D = 0.0d0 D(1,1) = rho D(2,2) = rho D(3,3) = rho wg = getWeight(etype,LX)*det N = 0.0d0 do i = 1, nn N(1,3*i-2) = func(i) N(2,3*i-1) = func(i) N(3,3*i ) = func(i) enddo DN(1:3, 1:nn*ndof) = matmul(D, N(1:3, 1:nn*ndof)) forall(i = 1:nn*ndof, j = 1:nn*ndof) mass(i,j) = mass(i,j) + dot_product(N(:,i), DN(:,j))*wg end forall enddo is_lumped = .true. if(is_lumped) call get_lumped_mass(nn, ndof, mass, lumped) end subroutine mass_C3 subroutine get_lumped_mass(nn, ndof, mass, lumped) use hecmw implicit none integer(kind=kint) :: i, j, nn, ndof real(kind=kreal) :: lumped(:), mass(:,:) real(kind=kreal) :: diag_mass, total_mass total_mass = 0.0d0 do i = 1, nn*ndof, ndof do j = 1, nn*ndof, ndof total_mass = total_mass + mass(j,i) enddo enddo diag_mass = 0.0d0 do i = 1, nn*ndof, ndof diag_mass = diag_mass + mass(i,i) enddo diag_mass = 1.0d0/diag_mass do i = 1, nn*ndof lumped(i) = lumped(i) + mass(i,i)*total_mass*diag_mass enddo mass = 0.0d0 do i = 1, nn*ndof mass(i,i) = lumped(i) enddo end subroutine get_lumped_mass function get_length(ecoord) use hecmw implicit none real(kind=kreal) :: get_length, ecoord(3,20) get_length = dsqrt( & (ecoord(1,2) - ecoord(1,1))**2 + & (ecoord(2,2) - ecoord(2,1))**2 + & (ecoord(3,2) - ecoord(3,1))**2 ) end function get_length function get_face3(ecoord) use hecmw implicit none real(kind=kreal) :: get_face3, ecoord(3,20) real(kind=kreal) :: a1, a2, a3 real(kind=kreal) :: X(3), Y(3), Z(3) X(1) = ecoord(1,1); Y(1) = ecoord(2,1); Z(1) = ecoord(3,1) X(2) = ecoord(1,2); Y(2) = ecoord(2,2); Z(2) = ecoord(3,2) X(3) = ecoord(1,3); Y(3) = ecoord(2,3); Z(3) = ecoord(3,3) a1 = (X(2) - X(1))**2 + (Y(2) - Y(1))**2 + (Z(2) - Z(1))**2 a2 = (X(1) - X(3))*(X(2) - X(1)) & & + (Y(1) - Y(3))*(Y(2) - Y(1)) & & + (Z(1) - Z(3))*(Z(2) - Z(1)) a3 = (X(3) - X(1))**2 + (Y(3) - Y(1))**2 + (Z(3) - Z(1))**2 get_face3 = 0.5d0*dsqrt(a1*a3 - a2*a2) end function get_face3 function get_face4(ecoord) use hecmw implicit none integer(kind=kint) :: LX, LY real(kind=kreal) :: get_face4, ecoord(3,20) real(kind=kreal) :: XG(2), RI, SI, RP, SP, RM, SM, HR(4), HS(4) real(kind=kreal) :: XR, XS, YR, YS, ZR, ZS real(kind=kreal) :: X(4), Y(4), Z(4), det X(1) = ecoord(1,1); Y(1) = ecoord(2,1); Z(1) = ecoord(3,1) X(2) = ecoord(1,2); Y(2) = ecoord(2,2); Z(2) = ecoord(3,2) X(3) = ecoord(1,3); Y(3) = ecoord(2,3); Z(3) = ecoord(3,3) X(4) = ecoord(1,4); Y(4) = ecoord(2,4); Z(4) = ecoord(3,4) XG(1) = -0.5773502691896258D0 XG(2) = -XG(1) get_face4 = 0.0d0 do LX = 1, 2 RI = XG(LX) do LY = 1, 2 SI = XG(LY) RP = 1.0d0 + RI SP = 1.0d0 + SI RM = 1.0d0 - RI SM = 1.0d0 - SI !C* FOR R-COORDINATE HR(1) = 0.25d0*SP HR(2) = -0.25d0*SP HR(3) = -0.25d0*SM HR(4) = 0.25d0*SM !C* FOR S-COORDINATE HS(1) = 0.25d0*RP HS(2) = 0.25d0*RM HS(3) = -0.25d0*RM HS(4) = -0.25d0*RP !C*JACOBI MATRIX XR = HR(1)*X(1) + HR(2)*X(2) + HR(3)*X(3) + HR(4)*X(4) XS = HS(1)*X(1) + HS(2)*X(2) + HS(3)*X(3) + HS(4)*X(4) YR = HR(1)*Y(1) + HR(2)*Y(2) + HR(3)*Y(3) + HR(4)*Y(4) YS = HS(1)*Y(1) + HS(2)*Y(2) + HS(3)*Y(3) + HS(4)*Y(4) ZR = HR(1)*Z(1) + HR(2)*Z(2) + HR(3)*Z(3) + HR(4)*Z(4) ZS = HS(1)*Z(1) + HS(2)*Z(2) + HS(3)*Z(3) + HS(4)*Z(4) det = (YR*ZS - ZR*YS)**2 + (ZR*XS - XR*ZS)**2 + (XR*YS - YR*XS)**2 det = dsqrt(det) get_face4 = get_face4 + det enddo enddo end function get_face4 end module m_dynamic_mass
mit