OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libgfortran/] [intrinsics/] [selected_real_kind.f90] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
!   Copyright 2003, 2004 Free Software Foundation, Inc.
2
!   Contributed by Kejia Zhao 
3
!
4
!This file is part of the GNU Fortran 95 runtime library (libgfor).
5
!
6
!GNU libgfor is free software; you can redistribute it and/or
7
!modify it under the terms of the GNU Lesser General Public
8
!License as published by the Free Software Foundation; either
9
!version 2.1 of the License, or (at your option) any later version.
10
!
11
!GNU libgfor is distributed in the hope that it will be useful,
12
!but WITHOUT ANY WARRANTY; without even the implied warranty of
13
!MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
!GNU Lesser General Public License for more details.
15
!
16
!You should have received a copy of the GNU Lesser General Public
17
!License along with libgfor; see the file COPYING.  If not,
18
!write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
!Boston, MA 02110-1301, USA.
20
!
21
 
22
function selected_real_kind (p, r)
23
  implicit none
24
  integer, optional, intent (in) :: p, r
25
  integer :: selected_real_kind
26
  integer :: i, p2, r2
27
  logical :: found_p, found_r
28
  ! Real kind_precision_range table
29
  type :: real_info
30
    integer :: kind
31
    integer :: precision
32
    integer :: range
33
  end type real_info
34
 
35
  include "selected_real_kind.inc"
36
 
37
  selected_real_kind = 0
38
  p2 = 0
39
  r2 = 0
40
  found_p = .false.
41
  found_r = .false.
42
 
43
  if (present (p)) p2 = p
44
  if (present (r)) r2 = r
45
 
46
  ! Assumes each type has a greater precision and range than previous one.
47
 
48
  do i = 1, c
49
    if (p2 <= real_infos (i) % precision) found_p = .true.
50
    if (r2 <= real_infos (i) % range) found_r = .true.
51
    if (found_p .and. found_r) then
52
      selected_real_kind = real_infos (i) % kind
53
      return
54
    end if
55
  end do
56
 
57
  if (.not. (found_p)) selected_real_kind = selected_real_kind - 1
58
  if (.not. (found_r)) selected_real_kind = selected_real_kind - 2
59
 
60
  return
61
end function

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.