File: f77_get_fortran_handle_max.m4

package info (click to toggle)
openmpi 1.6.5-9.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 91,628 kB
  • ctags: 44,305
  • sloc: ansic: 408,966; cpp: 44,454; sh: 27,828; makefile: 10,486; asm: 3,882; python: 1,239; lex: 805; perl: 549; csh: 253; fortran: 232; f90: 126; tcl: 12
file content (70 lines) | stat: -rw-r--r-- 3,160 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl                         University Research and Technology
dnl                         Corporation.  All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl                         of Tennessee Research Foundation.  All rights
dnl                         reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
dnl                         University of Stuttgart.  All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl                         All rights reserved.
dnl Copyright (c) 2013      Cisco Systems, Inc.  All rights reserved.
dnl $COPYRIGHT$
dnl 
dnl Additional copyrights may follow
dnl 
dnl $HEADER$
dnl

# OMPI_F77_GET_FORTRAN_HANDLE_MAX()
# ---------------------------------------------------------------
# Find the maximum value of fortran integers, then calculate
# min(INT_MAX, max fortran INTEGER).  This represents the maximum
# number of fortran MPI handle index.
AC_DEFUN([OMPI_F77_GET_FORTRAN_HANDLE_MAX],[
    AC_CACHE_CHECK([for max Fortran MPI handle index],
        [ompi_cv_f77_fortran_handle_max],
        [ # Find max fortran INTEGER value.  Set to sentinel value if we don't
         # have a Fortran compiler (e.g., if --disable-f77 was given). 
         if test "$OMPI_WANT_F77_BINDINGS" = "0" ; then
             ompi_fint_max=0
         else
             OPAL_COMPUTE_MAX_VALUE([$OMPI_SIZEOF_FORTRAN_INTEGER], [ompi_fint_max])
         fi

         # Get INT_MAX.  Compute a SWAG if we are cross compiling or something
         # goes wrong.
         rm -f conftest.out >/dev/null 2>&1
         AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <limits.h>
]],[[FILE *fp = fopen("conftest.out", "w");
long cint = INT_MAX;
fprintf(fp, "%ld", cint);
fclose(fp);]])], 
             [ompi_cint_max=`cat conftest.out`], 
             [ompi_cint_max=0],
             [ #cross compiling is fun.  compute INT_MAX same as INTEGER max
              OPAL_COMPUTE_MAX_VALUE([$ac_cv_sizeof_int], [ompi_cint_max])])

         if test "$ompi_cint_max" = "0" ; then
             # wow - something went really wrong.  Be conservative
             ompi_cv_f77_fortran_handle_max=32767
         elif test "$ompi_fint_max" = "0" ; then
             # we aren't compiling Fortran - just set it to C INT_MAX
             ompi_cv_f77_fortran_handle_max=$ompi_cint_max
         else
             # take the lesser of C INT_MAX and Fortran INTEGER
             # max.  The resulting value will then be storable in
             # either type.  There's no easy way to do this in
             # the shell, so make the preprocessor do it.
             ompi_cv_f77_fortran_handle_max="( $ompi_fint_max < $ompi_cint_max ? $ompi_fint_max : $ompi_cint_max )"
          fi
          rm -f conftest.out > /dev/null 2>&1 ])

    AC_DEFINE_UNQUOTED([OMPI_FORTRAN_HANDLE_MAX],
        [$ompi_cv_f77_fortran_handle_max],
        [Max handle value for fortran MPI handles, effectively min(INT_MAX, max fortran INTEGER value)])
])dnl