~ubuntu-branches/ubuntu/trusty/nwchem/trusty-proposed

« back to all changes in this revision

Viewing changes to src/tools/ga-5-1/m4/ga_mpi_unwrap.m4

  • Committer: Package Import Robot
  • Author(s): Michael Banck, Daniel Leidert, Andreas Tille, Michael Banck
  • Date: 2013-07-04 12:14:55 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130704121455-5tvsx2qabor3nrui
Tags: 6.3-1
* New upstream release.
* Fixes anisotropic properties (Closes: #696361).
* New features include:
  + Multi-reference coupled cluster (MRCC) approaches
  + Hybrid DFT calculations with short-range HF 
  + New density-functionals including Minnesota (M08, M11) and HSE hybrid
    functionals
  + X-ray absorption spectroscopy (XAS) with TDDFT
  + Analytical gradients for the COSMO solvation model
  + Transition densities from TDDFT 
  + DFT+U and Electron-Transfer (ET) methods for plane wave calculations
  + Exploitation of space group symmetry in plane wave geometry optimizations
  + Local density of states (LDOS) collective variable added to Metadynamics
  + Various new XC functionals added for plane wave calculations, including
    hybrid and range-corrected ones
  + Electric field gradients with relativistic corrections 
  + Nudged Elastic Band optimization method
  + Updated basis sets and ECPs 

[ Daniel Leidert ]
* debian/watch: Fixed.

[ Andreas Tille ]
* debian/upstream: References

[ Michael Banck ]
* debian/upstream (Name): New field.
* debian/patches/02_makefile_flags.patch: Refreshed.
* debian/patches/06_statfs_kfreebsd.patch: Likewise.
* debian/patches/07_ga_target_force_linux.patch: Likewise.
* debian/patches/05_avoid_inline_assembler.patch: Removed, no longer needed.
* debian/patches/09_backported_6.1.1_fixes.patch: Likewise.
* debian/control (Build-Depends): Added gfortran-4.7 and gcc-4.7.
* debian/patches/10_force_gcc-4.7.patch: New patch, explicitly sets
  gfortran-4.7 and gcc-4.7, fixes test suite hang with gcc-4.8 (Closes:
  #701328, #713262).
* debian/testsuite: Added tests for COSMO analytical gradients and MRCC.
* debian/rules (MRCC_METHODS): New variable, required to enable MRCC methods.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# GA_MPI_UNWRAP()
2
 
# ---------------
3
 
# Attempt to unwrap the MPI compiler for the current language and determine
4
 
# the underlying compiler.
5
 
#
6
 
# The strategy is to first compare the stdout of the version flags using
7
 
# a custom perl script.  Next we combine stdout and sterr for the comparison.
8
 
# Occasionally, the MPI compiler will always report a non-zero exit status.
9
 
# That is the last case checked for.
10
 
AC_DEFUN([GA_MPI_UNWRAP], [
11
 
# Find perl.
12
 
AC_PATH_PROG([PERL], [perl])
13
 
# Create inside.pl.
14
 
rm -f inside.pl
15
 
[cat >inside.pl <<"EOF"
16
 
#!/usr/bin/perl
17
 
$numargs = @S|@#ARGV + 1;
18
 
if ($numargs != 2) {
19
 
    print "Usage: wrapped.txt naked.txt\n";
20
 
    exit 1;
21
 
}
22
 
# Read each input file as a string (rather than a list).
23
 
local $/=undef;
24
 
open WRAPPED, "$ARGV[0]" or die "Could not open wrapped text file: $!";
25
 
$wrapped_lines = <WRAPPED>;
26
 
close WRAPPED;
27
 
open NAKED, "$ARGV[1]" or die "Could not open naked text file: $!";
28
 
$naked_lines = <NAKED>;
29
 
close NAKED;
30
 
# Replace newlines, + from wrapped and naked lines.
31
 
$wrapped_lines =~ tr/\n+/ /;
32
 
$naked_lines =~ tr/\n+/ /;
33
 
# Remove whitespace from beginning of wrapped and naked lines.
34
 
$wrapped_lines =~ s/^\s+//;
35
 
$naked_lines =~ s/^\s+//;
36
 
# Remove whitespace from end of wrapped and naked lines.
37
 
$wrapped_lines =~ s/\s+$//;
38
 
$naked_lines =~ s/\s+$//;
39
 
# If either wrapped_lines or naked_lines are empty, this is an error.
40
 
# It is assumed that the particular version string which created the input
41
 
# files should generate SOMETHING.
42
 
unless ($wrapped_lines) {
43
 
    exit 1;
44
 
}
45
 
unless ($naked_lines) {
46
 
    exit 1;
47
 
}
48
 
# Can the naked lines be found within the wrapped lines?
49
 
if ($wrapped_lines =~ /\Q$naked_lines\E/) {
50
 
    #print "Found as substring\n";
51
 
    exit 0;
52
 
}
53
 
# Are the naked lines exactly the same as the wrapped lines?
54
 
elsif ($wrapped_lines eq $naked_lines) {
55
 
    #print "Found equal\n";
56
 
    exit 0;
57
 
}
58
 
else {
59
 
    #print "Not found\n";
60
 
    exit 1;
61
 
}
62
 
EOF]
63
 
inside="$PERL inside.pl"
64
 
wrapped="$_AC_CC"
65
 
AC_LANG_CASE(
66
 
[C], [AS_CASE([$wrapped],
67
 
    [*_r],  [compilers="bgxlc_r xlc_r"],
68
 
    [*],    [compilers="bgxlc xlc pgcc pathcc icc sxcc fcc opencc suncc craycc gcc ecc cl ccc cc"])
69
 
],
70
 
[C++], [AS_CASE([$wrapped],
71
 
    [*_r],  [compilers="bgxlC_r xlC_r"],
72
 
    [*],    [compilers="icpc pgCC pathCC sxc++ xlC bgxlC openCC sunCC crayCC g++ c++ gpp aCC cxx cc++ cl.exe FCC KCC RCC CC"])
73
 
],
74
 
[Fortran 77], [AS_CASE([$wrapped],
75
 
    [*_r],  [compilers="bgxlf95_r xlf95_r bgxlf90_r xlf90_r bgxlf_r xlf_r"],
76
 
    [*],    [compilers="gfortran g95 bgxlf95 xlf95 f95 fort ifort ifc efc pgf95 pathf95 lf95 openf95 sunf95 crayftn bgxlf90 xlf90 f90 pgf90 pathf90 pghpf epcf90 sxf90 openf90 sunf90 g77 bgxlf xlf f77 frt pgf77 pathf77 cf77 fort77 fl32 af77"])
77
 
    ],
78
 
[Fortran], [
79
 
])
80
 
AS_VAR_PUSHDEF([ga_save_comp], [ga_save_[]_AC_CC[]])
81
 
AS_VAR_PUSHDEF([ga_orig_comp], [ga_orig_[]_AC_CC[]])
82
 
AS_VAR_PUSHDEF([ga_cv_mpi_naked], [ga_cv_mpi[]_AC_LANG_ABBREV[]_naked])
83
 
AC_CACHE_CHECK([for base $wrapped compiler], [ga_cv_mpi_naked], [
84
 
base="`$wrapped -show 2>/dev/null | sed 's/@<:@         @:>@.*@S|@//' | head -1`"
85
 
ga_save_comp="$_AC_CC"
86
 
_AC_CC="$base"
87
 
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [ga_cv_mpi_naked="$base"])
88
 
_AC_CC="$ga_save_comp"
89
 
versions="--version -v -V -qversion"
90
 
found_wrapped_version=0
91
 
# Try separating stdout and stderr. Only compare stdout.
92
 
AS_IF([test "x$ga_cv_mpi_naked" = x], [
93
 
# prepend any CC/CXX/F77 the user may have specified
94
 
compilers="$ga_orig_comp $compilers"
95
 
echo "only comparing stdout" >&AS_MESSAGE_LOG_FD
96
 
for version in $versions
97
 
do
98
 
    echo "trying version=$version" >&AS_MESSAGE_LOG_FD
99
 
    rm -f mpi.txt mpi.err naked.txt naked.err
100
 
    AS_IF([$wrapped $version 1>mpi.txt 2>mpi.err],
101
 
        [found_wrapped_version=1
102
 
         for naked_compiler in $compilers
103
 
         do
104
 
            AS_IF([test "x$naked_compiler" != "x$wrapped"],
105
 
                [AS_IF([$naked_compiler $version 1>naked.txt 2>naked.err],
106
 
                    [AS_IF([$inside mpi.txt naked.txt >/dev/null],
107
 
                        [ga_cv_mpi_naked=$naked_compiler; break],
108
 
                        [echo "inside.pl $wrapped $naked_compiler failed, skipping" >&AS_MESSAGE_LOG_FD])],
109
 
                    [echo "$naked_compiler $version failed, skipping" >&AS_MESSAGE_LOG_FD])])
110
 
         done],
111
 
        [echo "$wrapped $version failed, skipping" >&AS_MESSAGE_LOG_FD])
112
 
    AS_IF([test "x$ga_cv_mpi_naked" != x], [break])
113
 
done
114
 
])
115
 
# Perhaps none of the MPI compilers had a zero exit status (this is bad).
116
 
# In this case we have to do a brute force match regardless of exit status.
117
 
AS_IF([test "x$found_wrapped_version" = x0], [
118
 
AS_IF([test "x$ga_cv_mpi_naked" = x], [
119
 
echo "no zero exit status found for MPI compilers" >&AS_MESSAGE_LOG_FD
120
 
for version in $versions
121
 
do
122
 
    echo "trying version=$version" >&AS_MESSAGE_LOG_FD
123
 
    rm -f mpi.txt mpi.err
124
 
    $wrapped $version 1>mpi.txt 2>mpi.err
125
 
    for naked_compiler in $compilers
126
 
    do
127
 
        AS_IF([test "x$naked_compiler" != "x$wrapped"],
128
 
            [rm -f naked.txt naked.err
129
 
             AS_IF([$naked_compiler $version 1>naked.txt 2>naked.err],
130
 
                [AS_IF([$inside mpi.txt naked.txt >/dev/null],
131
 
                    [ga_cv_mpi_naked=$naked_compiler; break],
132
 
                    [echo "inside.pl $wrapped $naked_compiler failed, skipping" >&AS_MESSAGE_LOG_FD])],
133
 
                [echo "$naked_compiler $version failed, skipping" >&AS_MESSAGE_LOG_FD])])
134
 
    done
135
 
    AS_IF([test "x$ga_cv_mpi_naked" != x], [break])
136
 
done
137
 
])
138
 
])
139
 
# Try by combining stdout/err into one file.
140
 
AS_IF([test "x$ga_cv_mpi_naked" = x], [
141
 
echo "try combining stdout and stderr into one file" >&AS_MESSAGE_LOG_FD
142
 
for version in $versions
143
 
do
144
 
    echo "trying version=$version" >&AS_MESSAGE_LOG_FD
145
 
    rm -f mpi.txt naked.txt
146
 
    AS_IF([$wrapped $version 1>mpi.txt 2>&1],
147
 
        [for naked_compiler in $compilers
148
 
         do
149
 
            AS_IF([test "x$naked_compiler" != "x$wrapped"],
150
 
                [AS_IF([$naked_compiler $version 1>naked.txt 2>&1],
151
 
                    [AS_IF([$inside mpi.txt naked.txt >/dev/null],
152
 
                        [ga_cv_mpi_naked=$naked_compiler; break],
153
 
                        [echo "inside.pl $wrapped $naked_compiler failed, skipping" >&AS_MESSAGE_LOG_FD])],
154
 
                    [echo "$naked_compiler $version failed, skipping" >&AS_MESSAGE_LOG_FD])])
155
 
         done],
156
 
        [echo "$wrapped $version failed, skipping" >&AS_MESSAGE_LOG_FD])
157
 
    AS_IF([test "x$ga_cv_mpi_naked" != x], [break])
158
 
done
159
 
])
160
 
# If we got this far, then it's likely that the MPI compiler had a zero exit
161
 
# status when it shouldn't have for one version flag, but later had a non-zero
162
 
# exit status for a flag it shouldn't have.  One false positive hid a false
163
 
# negative.  In this case, brute force compare all MPI compiler output against
164
 
# all compiler output.
165
 
AS_IF([test "x$ga_cv_mpi_naked" = x], [
166
 
echo "we have a very badly behaving MPI compiler" >&AS_MESSAGE_LOG_FD
167
 
for version in $versions
168
 
do
169
 
    echo "trying version=$version" >&AS_MESSAGE_LOG_FD
170
 
    rm -f mpi.txt mpi.err
171
 
    $wrapped $version 1>mpi.txt 2>mpi.err
172
 
    for naked_compiler in $compilers
173
 
    do
174
 
        AS_IF([test "x$naked_compiler" != "x$wrapped"],
175
 
            [rm -f naked.txt naked.err
176
 
             AS_IF([$naked_compiler $version 1>naked.txt 2>naked.err],
177
 
                [AS_IF([$inside mpi.txt naked.txt >/dev/null],
178
 
                    [ga_cv_mpi_naked=$naked_compiler; break],
179
 
                    [echo "inside.pl $wrapped $naked_compiler failed, skipping" >&AS_MESSAGE_LOG_FD])],
180
 
                [echo "$naked_compiler $version failed, skipping" >&AS_MESSAGE_LOG_FD])])
181
 
    done
182
 
    AS_IF([test "x$ga_cv_mpi_naked" != x], [break])
183
 
done
184
 
])
185
 
rm -f mpi.txt mpi.err naked.txt naked.err
186
 
])
187
 
AS_IF([test "x$ga_cv_mpi_naked" = x],
188
 
    [AC_MSG_ERROR([Could not determine the ]_AC_LANG[ compiler wrapped by MPI])],
189
 
    [AS_IF([test "x$ga_orig_comp" != x && test "x$ga_orig_comp" != "x$ga_cv_mpi_naked"],
190
 
        [AC_MSG_WARN([unwrapped $wrapped ($ga_cv_mpi_naked) does not match user-specified $ga_orig_comp])])])
191
 
AS_VAR_POPDEF([ga_save_comp])
192
 
AS_VAR_POPDEF([ga_cv_mpi_naked])
193
 
rm -f inside.pl
194
 
])dnl
195
 
 
196
 
 
197
 
# GA_MPI_UNWRAP_PUSH()
198
 
# --------------------
199
 
# Set CC/CXX/F77/FC to their unwrapped MPI counterparts.
200
 
# Save their old values for restoring later.
201
 
AC_DEFUN([GA_MPI_UNWRAP_PUSH], [
202
 
ga_mpi_unwrap_push_save_CC="$CC"
203
 
ga_mpi_unwrap_push_save_CXX="$CXX"
204
 
ga_mpi_unwrap_push_save_F77="$F77"
205
 
ga_mpi_unwrap_push_save_FC="$FC"
206
 
AS_IF([test "x$ga_cv_mpic_naked"   != x], [ CC="$ga_cv_mpic_naked"])
207
 
AS_IF([test "x$ga_cv_mpicxx_naked" != x], [CXX="$ga_cv_mpicxx_naked"])
208
 
AS_IF([test "x$ga_cv_mpif77_naked" != x], [F77="$ga_cv_mpif77_naked"])
209
 
AS_IF([test "x$ga_cv_mpifc_naked"  != x], [ FC="$ga_cv_mpifc_naked"])
210
 
])dnl
211
 
 
212
 
 
213
 
# GA_MPI_UNWRAP_POP()
214
 
# -------------------
215
 
# Restore CC/CXX/F77/FC to their MPI counterparts.
216
 
AC_DEFUN([GA_MPI_UNWRAP_POP], [
217
 
 CC="$ga_mpi_unwrap_push_save_CC"
218
 
CXX="$ga_mpi_unwrap_push_save_CXX"
219
 
F77="$ga_mpi_unwrap_push_save_F77"
220
 
 FC="$ga_mpi_unwrap_push_save_FC"
221
 
])dnl