I'm new with Intel TBB library. I'm using the concurrent_hash_map.
When I call to find/erase method my program stuck. why?
Is it a wrong using of find?
TBBProcessingThreadHash_t::accessor tbbAccessor;
std::cout << "size before erase is: " << m_oProcessingThreadHash.size() << std::endl; // return 1
std::cout << "going to find" << std::endl;
if(m_oProcessingThreadHash.find(tbbAccessor, pi_nThreadID)) // <<<<<<<<<<< stuck at this point
{
std::cout << "going to erase" << std::endl;
m_oProcessingThreadHash.erase(tbbAccessor);
std::cout << "Thread deleted successfully from CServerThreadManager" << std::endl;
}
else
{
std::cout << "Failed to delete thread from CServerThreadManager" << std::endl;
}
I used perf top and this is the result for my program:
23.40% libServer.so [.] __TBB_machine_pause
22.81% libc-2.27.so [.] __sched_yield
15.07% [kernel] [k] do_syscall_64
13.95% [kernel] [k] __sched_text_start
2.23% libServer.so [.] tbb::spin_rw_mutex_v3::scoped_lock::try_acquire
1.86% libServer.so [.] tbb::internal::atomic_backoff::bounded_pause
1.43% libServer.so [.] tbb::interface5::concurrent_hash_map<int, IServerProcessingThread*, tbb::tbb_hash_compare<int>, tbb::tbb_allocator<std::pair<int const, IServerProcessingThread*> > >::lookup
1.28% libServer.so [.] __TBB_machine_fetchadd8
1.17% [kernel] [k] exit_to_usermode_loop
0.99% libtbb.so.2 [.] tbb::spin_rw_mutex_v3::internal_acquire_reader
0.97% libServer.so [.] tbb::spin_rw_mutex_v3::scoped_lock::release
0.75% libServer.so [.] tbb::internal::__TBB_machine_atomic_load<long, 2>
0.74% prog [.] tbb::internal::no_copy::no_copy
0.72% [kernel] [k] sys_sched_yield
0.66% libServer.so [.] tbb::interface5::concurrent_hash_map<int, IServerProcessingThread*, tbb::tbb_hash_compare<int>, tbb::tbb_allocator<std::pair<int const, IServerProcessingThread*> > >::search_bu
0.64% libServer.so [.] tbb::interface5::internal::hash_map_base::get_bucket
0.57% libServer.so [.] tbb::interface5::concurrent_hash_map<int, IServerProcessingThread*, tbb::tbb_hash_compare<int>, tbb::tbb_allocator<std::pair<int const, IServerProcessingThread*> > >::bucket_ac
0.56% libServer.so [.] tbb::spin_rw_mutex_v3::scoped_lock::acquire
0.52% libServer.so [.] tbb::tbb_hash_compare<int>::equal
0.51% libServer.so [.] tbb::internal::__TBB_machine_atomic_load<tbb::interface5::internal::hash_map_node_base*, 2>
0.48% libServer.so [.] tbb::internal::atomic_impl<unsigned long>::to_bits_ref<unsigned long const volatile>
0.46% libServer.so [.] tbb::internal::atomic_impl<unsigned long>::to_value<unsigned long>
0.44% libServer.so [.] tbb::spin_rw_mutex_v3::scoped_lock::scoped_lock
0.42% libtbb.so.2 [.] tbb::spin_rw_mutex_v3::internal_try_acquire_writer
0.41% libServer.so [.] tbb::internal::itt_load_word_with_acquire<unsigned long>
0.39% libServer.so [.] tbb::internal::atomic_backoff::atomic_backoff
0.38% prog [.] tbb::interface5::internal::hash_map_base::segment_base
0.37% libServer.so [.] tbb::internal::atomic_impl<unsigned long>::operator unsigned long
0.35% libServer.so [.] tbb::internal::__TBB_load_with_acquire<tbb::interface5::internal::hash_map_node_base*>
0.32% libServer.so [.] tbb::interface5::concurrent_hash_map<int, IServerProcessingThread*, tbb::tbb_hash_compare<int>, tbb::tbb_allocator<std::pair<int const, IServerProcessingThread*> > >::bucket_ac
0.31% libServer.so [.] tbb::interface5::internal::hash_map_base::is_valid
0.28% libServer.so [.] tbb::internal::atomic_backoff::pause
0.28% libServer.so [.] tbb::internal::itt_load_word_with_acquire<tbb::interface5::internal::hash_map_node_base*>
0.24% libServer.so [.] tbb::interface5::internal::hash_map_base::segment_index_of
0.24% libServer.so [.] __TBB_machine_lg
0.23% libServer.so [.] tbb::internal::gcc_builtins::clz
0.23% libServer.so [.] tbb::internal::machine_load_store<long, 8ul>::load_with_acquire
0.23% libServer.so [.] tbb::internal::__TBB_load_with_acquire<long>
0.23% libServer.so [.] tbb::internal::machine_load_store<tbb::interface5::internal::hash_map_node_base*, 8ul>::load_with_acquire
0.23% libServer.so [.] tbb::aligned_space<std::pair<int const, IServerProcessingThread*>, 1ul>::begin
0.22% libServer.so [.] tbb::internal::punned_cast<std::pair<int const, IServerProcessingThread*>*, tbb::aligned_space<std::pair<int const, IServerProcessingThread*>, 1ul> const>
0.21% libServer.so [.] tbb::internal::atomic_impl<unsigned long>::ptr_converter<unsigned long const volatile*>::ptr_converter
0.20% libServer.so [.] tbb::spin_rw_mutex_v3::scoped_lock::~scoped_lock
0.18% libServer.so [.] tbb::interface5::concurrent_hash_map<int, IServerProcessingThread*, tbb::tbb_hash_compare<int>, tbb::tbb_allocator<std::pair<int const, IServerProcessingThread*> > >::node::sto
0.17% libServer.so [.] tbb::interface5::concurrent_hash_map<int, IServerProcessingThread*, tbb::tbb_hash_compare<int>, tbb::tbb_allocator<std::pair<int const, IServerProcessingThread*> > >::bucket_ac
0.15% libServer.so [.] tbb::interface5::concurrent_hash_map<int, IServerProcessingThread*, tbb::tbb_hash_compare<int>, tbb::tbb_allocator<std::pair<int const, IServerProcessingThread*> > >::node::val
0.13% prog [.] tbb::internal::no_assign::no_assign
0.12% libServer.so [.] tbb::interface5::concurrent_hash_map<int, IServerProcessingThread*, tbb::tbb_hash_compare<int>, tbb::tbb_allocator<std::pair<int const, IServerProcessingThread*> > >::bucket_ac
0.09% [kernel] [k] __softirqentry_text_start
0.08% libServer.so [.] tbb::spin_rw_mutex_v3::scoped_lock::acquire#plt
Its look like this entry is locked somehow, but no one locked it.
Related
Consider the following application.
#include <cmath>
void foo()
{
double x = 42.0;
for ( unsigned long i = 0; i < 10000000; ++i )
x = std::sin( x );
}
int main()
{
foo();
return 0;
}
I use the following commands.
g++ main.cpp
perf record ./a.out
perf report
And I see.
Samples: 518 of event 'cycles', Event count (approx.): 410229343
Overhead Command Shared Object Symbol
84,28% a.out libm.so.6 [.] __subtf3
12,59% a.out a.out [.] foo
2,47% a.out a.out [.] _init
0,47% a.out [kernel.kallsyms] [k] may_open
0,17% a.out [kernel.kallsyms] [k] memcg_slab_post_alloc_hook
0,01% perf-ex [kernel.kallsyms] [k] mutex_unlock
0,01% a.out [kernel.kallsyms] [k] __intel_pmu_enable_all.constprop.0
0,00% perf-ex [kernel.kallsyms] [k] native_write_msr
0,00% a.out [kernel.kallsyms] [k] native_write_msr
How to understand 12,59% for foo?
How to tell perf report to show full percent of time spent in a function? I want to see something like - foo 99%, __subtf3 90%.
This is a half of an answer. I will answer myself on the second question.
Use the following command to see percents as you wish.
perf record -e cpu-cycles --call-graph dwarf,4096 -F 250 ./a.out
perf report
And the result will look like.
+ 100,00% 0,00% a.out a.out [.] _start
+ 100,00% 0,00% a.out libc.so.6 [.] __libc_start_main_impl (inlined)
+ 100,00% 0,00% a.out libc.so.6 [.] __libc_start_call_main (inlined)
+ 100,00% 0,00% a.out a.out [.] main
+ 100,00% 16,27% a.out a.out [.] foo
+ 83,73% 0,00% a.out libm.so.6 [.] __sin_fma (inlined)
+ 83,73% 83,73% a.out libm.so.6 [.] __subtf3
+ 62,87% 0,00% a.out libm.so.6 [.] do_sin (inlined)
+ 5,85% 0,00% a.out libm.so.6 [.] libc_feholdsetround_sse_ctx (inlined)
...
This is a PCRE regex. https://regex101.com/r/gJ7pU0/1 that can validate email addresses.
Is there a RFC5322 compliant regex for ruby? Ruby has URI::MailTo::EMAIL_REGEXP, but I do not think it's RFC5322 compliant.
Another post mentioned this 'mail' gem, but I do not see a way to validate email addresses with it.
https://github.com/mikel/mail/tree/6b0ebb142c476bf7c00524effe513a4f151f59ab
PERC RFC5322 Compliant
(?(DEFINE)
(?<addr_spec> (?&local_part) # (?&domain) )
(?<local_part> (?&dot_atom) | (?"ed_string) | (?&obs_local_part) )
(?<domain> (?&dot_atom) | (?&domain_literal) | (?&obs_domain) )
(?<domain_literal> (?&CFWS)? \[ (?: (?&FWS)? (?&dtext) )* (?&FWS)? \] (?&CFWS)? )
(?<dtext> [\x21-\x5a] | [\x5e-\x7e] | (?&obs_dtext) )
(?<quoted_pair> \\ (?: (?&VCHAR) | (?&WSP) ) | (?&obs_qp) )
(?<dot_atom> (?&CFWS)? (?&dot_atom_text) (?&CFWS)? )
(?<dot_atom_text> (?&atext) (?: \. (?&atext) )* )
(?<atext> [a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+ )
(?<atom> (?&CFWS)? (?&atext) (?&CFWS)? )
(?<word> (?&atom) | (?"ed_string) )
(?<quoted_string> (?&CFWS)? " (?: (?&FWS)? (?&qcontent) )* (?&FWS)? " (?&CFWS)? )
(?<qcontent> (?&qtext) | (?"ed_pair) )
(?<qtext> \x21 | [\x23-\x5b] | [\x5d-\x7e] | (?&obs_qtext) )
# comments and whitespace
(?<FWS> (?: (?&WSP)* \r\n )? (?&WSP)+ | (?&obs_FWS) )
(?<CFWS> (?: (?&FWS)? (?&comment) )+ (?&FWS)? | (?&FWS) )
(?<comment> \( (?: (?&FWS)? (?&ccontent) )* (?&FWS)? \) )
(?<ccontent> (?&ctext) | (?"ed_pair) | (?&comment) )
(?<ctext> [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | (?&obs_ctext) )
# obsolete tokens
(?<obs_domain> (?&atom) (?: \. (?&atom) )* )
(?<obs_local_part> (?&word) (?: \. (?&word) )* )
(?<obs_dtext> (?&obs_NO_WS_CTL) | (?"ed_pair) )
(?<obs_qp> \\ (?: \x00 | (?&obs_NO_WS_CTL) | \n | \r ) )
(?<obs_FWS> (?&WSP)+ (?: \r\n (?&WSP)+ )* )
(?<obs_ctext> (?&obs_NO_WS_CTL) )
(?<obs_qtext> (?&obs_NO_WS_CTL) )
(?<obs_NO_WS_CTL> [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f )
# character class definitions
(?<VCHAR> [\x21-\x7E] )
(?<WSP> [ \t] )
)
^(?&addr_spec)$
PCRE to Onigmo recursion/subroutine regex conversion is straight-forward:
Remove the unsupported (?(DEFINE)...) construct
Put all the named groups used to define the consuming pattern at the start of the regex and apply a {0} quantifier to all of them so that they just matched nothing
Replace (?&...) to \g<...> syntax (I have just done it in Notepad++ with \(\?&(\w+)\) to replace with \\g<$1>).
The final expression that will work in Ruby looks like
re =/(?<addr_spec> \g<local_part> # \g<domain> ){0}
(?<local_part> \g<dot_atom> | \g<quoted_string> | \g<obs_local_part> ){0}
(?<domain> \g<dot_atom> | \g<domain_literal> | \g<obs_domain> ){0}
(?<domain_literal> \g<CFWS>? \[ (?: \g<FWS>? \g<dtext> )* \g<FWS>? \] \g<CFWS>? ){0}
(?<dtext> [\x21-\x5a] | [\x5e-\x7e] | \g<obs_dtext> ){0}
(?<quoted_pair> \\ (?: \g<VCHAR> | \g<WSP> ) | \g<obs_qp> ){0}
(?<dot_atom> \g<CFWS>? \g<dot_atom_text> \g<CFWS>? ){0}
(?<dot_atom_text> \g<atext> (?: \. \g<atext> )* ){0}
(?<atext> [a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+ ){0}
(?<atom> \g<CFWS>? \g<atext> \g<CFWS>? ){0}
(?<word> \g<atom> | \g<quoted_string> ){0}
(?<quoted_string> \g<CFWS>? " (?: \g<FWS>? \g<qcontent> )* \g<FWS>? " \g<CFWS>? ){0}
(?<qcontent> \g<qtext> | \g<quoted_pair> ){0}
(?<qtext> \x21 | [\x23-\x5b] | [\x5d-\x7e] | \g<obs_qtext> ){0}
# comments and whitespace
(?<FWS> (?: \g<WSP>* \r\n )? \g<WSP>+ | \g<obs_FWS> ){0}
(?<CFWS> (?: \g<FWS>? \g<comment> )+ \g<FWS>? | \g<FWS> ){0}
(?<comment> \( (?: \g<FWS>? \g<ccontent> )* \g<FWS>? \) ){0}
(?<ccontent> \g<ctext> | \g<quoted_pair> | \g<comment> ){0}
(?<ctext> [\x21-\x27] | [\x2a-\x5b] | [\x5d-\x7e] | \g<obs_ctext> ){0}
# obsolete tokens
(?<obs_domain> \g<atom> (?: \. \g<atom> )* ){0}
(?<obs_local_part> \g<word> (?: \. \g<word> )* ){0}
(?<obs_dtext> \g<obs_NO_WS_CTL> | \g<quoted_pair> ){0}
(?<obs_qp> \\ (?: \x00 | \g<obs_NO_WS_CTL> | \n | \r ) ){0}
(?<obs_FWS> \g<WSP>+ (?: \r\n \g<WSP>+ )* ){0}
(?<obs_ctext> \g<obs_NO_WS_CTL> ){0}
(?<obs_qtext> \g<obs_NO_WS_CTL> ){0}
(?<obs_NO_WS_CTL> [\x01-\x08] | \x0b | \x0c | [\x0e-\x1f] | \x7f ){0}
# character class definitions
(?<VCHAR> [\x21-\x7E] ){0}
(?<WSP> [ \t] ){0}
^\g<addr_spec>$/x
See a Ruby test:
p re.match?('+1~1+#iana.org') # => true
p re.match?('test#[123.123.123.123') # => false
I would like to parse the following lines
8.8.19.12.53 > 125.15.15.9.40583: [udp sum ok] 62639 q: A? mp.microsoft.com. 6/5/9 mp.microsoft.com. CNAME .mp.microsoft.com.c.footprint.net., mp.microsoft.com.c.footprint.net. A 8.250.143.254, mp.microsoft.com.c.footprint.net. A 8.250.157.254 ns: c.footprint.net. NS d.ns.c.footprint.net. ar: d.ns.c.footprint.net. A 4.26.235.155 (439)
8.8.19.12.53 > 125.15.15.9.42091: [udp sum ok] 46555 q: A? www.toto.net. 1/0/0 www.toto.net. A 120.33.1.11 (47)
and get the following output
125.15.15.9 mp.microsoft.com A 8.250.143.254 A 8.250.157.254
125.15.15.9 www.toto.net A 120.33.1.11
I succeeded in parsing the first two fields with command
sed -Eun 's/[^>]+> ([0-9.]+)\.[0-9]+:.+q: A\? ([a-z0-9.-]+)\.([^:]+).*/\1:\2:\3/pg
`
But I cannot get the resolved IPs (A xx.xx.xx.xx). In fact there may be several.
Would it be possible to get such output using sed or Perl ?
EDIT:
As I added in comments, parsing of a larger input sample, I also require several lines to be discarded in the output. This lines can be characterized by :
the number of A records ("A xx.xx.xx.xx") is non null
or the line must not contains NXDomain\*?-
I succeed in meeting the new first need, but not for the second.
Following the #ikegami reply, here is my attempt:
perl -nle '
my $field_value_re = qr/(?![^\s:]++:(?!\S)) \S++ (?: (?! \s++ [^\s:]++:(?!\S) ) \s++ \S++ )*+/x;
my ($id, $rest) = /^ \s+ ( [^:]++ ) : \s++ $field_value_re ( .* ) /sx
or next;
my ($ip) = $id =~ /^ \S++ \s++ \S++ \s++ ( [^\s\.]++\.[^\s\.]++\.[^\s\.]++\.[^\s\.]++ )\.[^\s\.]++ \z /x
or next;
my %fields = $rest =~ /\G \s++ ( [^\s:]++ ) :(?!\S) \s++ ( $field_value_re ) /gsx;
my ($query, $answers) = $fields{q} =~ /^ A\? \s++ ( \S++ ) \s++ \S++ \s++ ( .* ) /sx
or next;
$query =~ s/\.\z//;
my #answers = split(/\s*+,\s*+/, $answers);
my ($afield) = join " ", map { /^\S++\s++A\s++(\S++)/ } #answers;
if ( length($afield) != 0)
{
print join " ", $ip, $query, $afield;
}
' dns.sample
This does as you ask with the sample data
I first build a regex pattern $url_re that matches numeric URLs to make the following code more concise. Then I search for the first URL immediately after >, the named URL right after A?, and all of the following URLs which are preceded by A
They are all stored in array #urls and printed
use strict;
use warnings 'all';
use 5.010;
my $url_re = qr/(?:\d+\.){3}\d+/;
while ( <DATA> ) {
my #urls = ( />\s+($url_re)/, /A\?\s+([-\w.]+\w)/, /(A\s+$url_re)/g );
say "#urls";
}
__DATA__
8.8.19.12.53 > 125.15.15.9.40583: [udp sum ok] 62639 q: A? mp.microsoft.com. 6/5/9 mp.microsoft.com. CNAME .mp.microsoft.com.c.footprint.net., mp.microsoft.com.c.footprint.net. A 8.250.143.254, mp.microsoft.com.c.footprint.net. A 8.250.157.254 ns: c.footprint.net. NS d.ns.c.footprint.net. ar: d.ns.c.footprint.net. A 4.26.235.155 (439)
8.8.19.12.53 > 125.15.15.9.42091: [udp sum ok] 46555 q: A? www.toto.net. 1/0/0 www.toto.net. A 120.33.1.11 (47)
output
125.15.15.9 mp.microsoft.com A 8.250.143.254 A 8.250.157.254 A 4.26.235.155
125.15.15.9 www.toto.net A 120.33.1.11
Each line appears to be of the form
{"id" with spaces}: {stuff} [ {key}: {stuff} ]*
You appear to be interested in information inside the "id", and inside the field named q. The value of the q field appears to be of the form
A? {word} {word} {ns_return} [, {ns_return} ]*
Here's a robust solution that handles the format described above.
perl -nle'
my $field_value_re = qr/(?![^\s:]++:(?!\S)) \S++ (?: (?! \s++ [^\s:]++:(?!\S) ) \s++ \S++ )*+/x;
my ($id, $id_val, $rest) = /^ ( [^:]++ ) : \s++ ( $field_value_re ) ( .* ) /sx
or next;
next if $id_val =~ /\bNXDomain\b/;
my ($ip) = $id =~ /^ \S++ \s++ \S++ \s++ ( [^\s\.]++\.[^\s\.]++\.[^\s\.]++\.[^\s\.]++ )\.[^\s\.]++ \z /x
or next;
my %fields = $rest =~ /\G \s++ ( [^\s:]++ ) :(?!\S) \s++ ( $field_value_re ) /gsx;
my ($query, $answers) = $fields{q} =~ /^ A\? \s++ ( \S++ ) \s++ \S++ \s++ ( .* ) /sx
or next;
$query =~ s/\.\z//;
my #answers =
map { /^\S++\s++A\s++(\S++)/ }
split(/\s*+,\s*+/, $answers);
next if !#answers;
print join " ", $ip, $query, map { "A $_" } #answers;
' log
125.15.15.9 mp.microsoft.com A 8.250.143.254 A 8.250.157.254
125.15.15.9 www.toto.net A 120.33.1.11
This prints the desired output by using the map function in a somewhat unorthodox way to ignore any fields after q:
perl -lne 'print join qq/\t/, m/> ([\d\.]+)\./, map {/A\? ([^\s]+)\./, /(A [\d\.]+)/g} / q:([^:]+)/' log.txt
I really need your help, I have been trying to solve this problem for a few days now with no luck. I am compiling with gfortran (as the main program is in fortran) a program which calls for a library installed (lhapdf) in the standard directory, it is actually found but when linking with c++ libraries it appears to have a problem. As I have no familiarity with configure and makefiles I cant figure out what is wrong, this is my configure file:
#! /bin/sh
# configure script for FormCalc
# note: has nothing to do with GNU autoconf
# this file is part of FormCalc
# last modified 30 Aug 14 th
exec 2> ${LOGFILE:-/dev/null} 3>&1
eval ${LOGFILE:+set -x}
LC_ALL=C
export LC_ALL
test=test$$
trap "rm -fr $test*" 0 1 2 3 15
if (echo "test\c"; echo 1,2,3) | grep c > /dev/null ; then
if (echo -n test; echo 1,2,3) | grep n > /dev/null ; then
echo_n=
echo_c='
'
else
echo_n=-n
echo_c=
fi
else
echo_n=
echo_c='\c'
fi
findprog() {
echo $echo_n "looking for $1... $echo_c" 1>&3
shift
test -n "$CONF_TARGET" && for prog in "$#" ; do
full="`which \"$CONF_TARGET-$prog\" 2> /dev/null`"
test -x "$full" && {
echo $full 1>&3
echo $CONF_TARGET-$prog
return 0
}
done
for prog in "$#" ; do
full="`which \"$prog\" 2> /dev/null`"
test -x "$full" && {
echo $full 1>&3
echo $prog
return 0
}
done
echo "no $# in your path" 1>&3
return 1
}
findlib() {
echo $echo_n "looking for $1... $echo_c" 1>&3
file=$2
tag=$3
shift 3
for base in "$#" \
../$tag* \
../../$tag* \
../../../$tag* \
../../../../$tag* \
$HOME/$tag* \
/usr/local/$tag* \
/usr/$tag* \
/usr/local \
/usr
do
for path in \
"${CONF_LIBDIRSUFFIX:+$base/lib$CONF_LIBDIRSUFFIX}" \
"${CONF_LIBDIRSUFFIX:+$base/$CONF_DEFPREFIX/lib$CONF_LIBDIRSUFFIX}" \
"$base/lib" \
"$base/$CONF_DEFPREFIX/lib" \
${CONF_QUAD:+"$base/build-quad"} \
"$base/build" \
"$base/includects" \
"$base/libs" \
"$base/.libs" \
"$base/src" \
"$base/src/.libs" \
"$base"
do
test -f "$path/$file" && {
echo "$path" 1>&3
echo "$path"
return 0
}
done
done
echo "not found" 1>&3
return 1
}
getldflags() {
ldflags="$LDFLAGS"
while read line ; do
set -- `echo $line | tr ':,()' ' '`
case $1 in
*/collect2$CONF_EXE | */ld$CONF_EXE | ld$CONF_EXE) ;;
*) continue ;;
esac
while test $# -gt 1 ; do
shift
case $1 in
# *.o | -lc | -lgcc*)
*.o | -lc)
;;
-l* | -L* | *.a)
ldflags="$ldflags $1" ;;
-Bstatic | -Bdynamic | *.ld)
ldflags="$ldflags -Wl,$1" ;;
/*)
ldflags="$ldflags -L,$1" ;;
-rpath*)
ldflags="$ldflags -Wl,$1,$2"
shift ;;
-dynamic-linker)
shift ;;
esac
done
done
echo $ldflags
}
CONF_SRC=`dirname $0`
CONF_OS=`uname -s`
CONF_OSVER=`uname -r`
CONF_MACH=`uname -m`
CONF_DEFPREFIX="$CONF_MACH-$CONF_OS"
CONF_PREFIX="$CONF_DEFPREFIX"
CONF_TARGET=
CONF_STATIC=
CONF_STATIC_EXT=
CONF_QUAD=
CONF_DEBUG=
CONF_BITS=
# Mma 5.1's mcc needs -lpthread for static linking
CONF_MCLIBS="-lpthread"
CONF_ARCH="-march=native"
CONF_AS=
CONF_EXE=
case "$CONF_OS" in
CYG*) CONF_EXE=.exe ;;
Darwin) CONF_AS="-Wa,-q" ;;
esac
CONF_MAKEARGS=0
for arg in "$#" ; do
case "$arg" in
--prefix=*)
CONF_PREFIX=`expr "$arg" : ".*--prefix=\(.*\)"` ;;
--host=*)
CONF_TARGET=`expr "$arg" : ".*--host=\(.*\)"` ;;
--static)
CONF_STATIC="-static"
case "$CONF_OS" in
# Apple discourages static linking, see
# http://developer.apple.com/qa/qa2001/qa1118.html,
# so we make only libgcc static. For a static libg2c do:
# sudo chmod 000 /usr/local/lib/libg2c.dylib
Darwin | CYG*)
CONF_STATIC_EXT=$CONF_STATIC
CONF_STATIC= ;;
esac ;;
--quad)
CONF_QUAD=1 ;;
--debug)
CONF_DEBUG="-O0 -g" ;;
--32)
CONF_BITS=32 ;;
--64)
CONF_BITS=64 ;;
--generic)
CONF_ARCH=
CONF_AS= ;;
--make*)
CONF_MAKEARGS="`expr "$arg" : "--make=\(.*\)"`" ;;
--help)
cat << _EOF_ 1>&3
$0 configures FormCalc-generated Fortran code, i.e. determines
or guesses the compiler and flags and writes out a makefile.
$0 understands the following options:
--prefix=DIR use DIR as installation directory,
--host=HOST target host triplet, e.g. i386-pc-linux,
--static link the executables statically,
--quad compile with quadruple precision (gfortran 4.6+, ifort and xlf only),
--debug compile without optimization,
--32 force 32-bit compilation,
--64 force 64-bit compilation,
--generic do not specifically target the CPU configure runs on,
--make[=ARGS] immediately continue with "make ARGS" after configure.
_EOF_
exit 1 ;;
-*)
echo "Warning: $arg is not a valid option." 1>&3 ;;
*=*)
eval `echo $arg\" | sed 's/=/="/'` ;;
*)
echo "Warning: $arg is not a valid argument." 1>&3 ;;
esac
done
test "$CONF_OS" = Linux -a "$CONF_BITS" \!= 32 && CONF_LIBDIRSUFFIX=64
CONF_M=${CONF_BITS:+-m$CONF_BITS}
## look for some programs
CONF_MAKE=`findprog make $MAKE gmake Make make` || exit 1
CONF_CC=`findprog gcc $CC clang gcc` || exit 1
CONF_CXX=`findprog g++ $CXX clang++ g++` || exit 1
CONF_FC=`findprog fortran $FC ${CONF_QUAD:+ifort gfortran xlf} ifort pgf90 xlf gfortran g95 f90` || exit 1
CONF_AR=`findprog ar $AR ar`
CONF_RANLIB=`findprog ranlib $RANLIB ranlib`
CONF_NM=`findprog nm $NM nm`
CONF_DLLTOOL=`findprog dlltool $DLLTOOL dlltool`
CONF_DEF="-D"
case "`$CONF_FC --version -c 2>&1`" in
*G95*)
CONF_FFLAGS="$FFLAGS -O0 -g -ffixed-line-length-132 -freal-loops $CONF_M $CONF_STATIC ${CONF_DEBUG:+-Wall}" ;;
*GNU*)
CONF_FFLAGS="$FFLAGS ${CONF_DEBUG:--O3 -g} -lLHAPDF -ffixed-line-length-none $CONF_M $CONF_STATIC ${CONF_DEBUG:+-Wall}"
case "$CONF_FC" in
*gfortran*)
CONF_FFLAGS="$CONF_FFLAGS $CONF_ARCH $CONF_AS ${CONF_DEBUG:+-Wtabs -ffpe-trap=invalid,overflow,zero} -ff2c ${CONF_STATIC_EXT:+-static-libgfortran -static-libgcc} ${CONF_QUAD:+-fdefault-real-8}" ;;
esac ;;
*)
CONF_FFLAGS="${FFLAGS-default}"
test "$CONF_FFLAGS" = default && case "$CONF_FC$CONF_MACH" in
*pgf*)
CONF_FFLAGS="${CONF_DEBUG:--O3 -g} ${CONF_ARCH:+-Mvect=simd} ${CONF_DEBUG:+-Ktrap=fp} -Mextend -Minform=inform -g77libs ${CONF_STATIC:+-Bstatic} $CONF_M" ;;
*ifort*)
CONF_FFLAGS="${CONF_DEBUG:--O3 -g} $CONF_ARCH -extend_source -warn nouncalled -warn truncated_source -assume bscc $CONF_STATIC ${CONF_STATIC_EXT:+-static-intel} ${CONF_QUAD:+-r16 -DDBLE=QEXT -DDIMAG=QIMAG -DDCONJG=QCONJG -DDCMPLX=QCMPLX} $CONF_M" ;;
*alpha)
CONF_FFLAGS="${CONF_DEBUG:--O3 -g3} ${CONF_DEBUG:+-fpe0} -extend_source -warn truncated_source ${CONF_STATIC:+-non_shared}" ;;
*sun* | *sparc*)
CONF_FFLAGS="${CONF_DEBUG:--O3 -g} ${CONF_DEBUG:+-ftrap=common} -e ${CONF_STATIC:+-Bstatic}" ;;
*hp*)
CONF_FFLAGS="${CONF_DEBUG:--O2 -g} ${CONF_DEBUG:++FPVZO} +es +U77 ${CONF_STATIC:+-Wl,-noshared}" ;;
*xlf*)
CONF_FFLAGS="${CONF_DEBUG:--O2 -g} ${CONF_DEBUG:+-qflttrap=enable:invalid:overflow:zerodivide} -qfixed=132 -qmaxmem=-1 -qextname ${CONF_QUAD:+-qautodbl=dbl}"
CONF_DEF="-WF,-D" ;;
*)
CONF_FFLAGS="${CONF_DEBUG:--O -g}" ;;
esac ;;
esac
## find the Fortran libraries
echo $echo_n "extracting the Fortran libraries... $echo_c" 1>&3
rm -fr $test*
cat > $test.f << _EOF_
program dontpanic
print *, "Hi"
end
_EOF_
eval ${LOGFILE:+cat $test.f 1>&2}
CONF_LDFLAGS=`$CONF_FC $CONF_FFLAGS -v -o -lstdc++ $test $test.f 2>&1 | getldflags`
CONF_INCPATH="$INCPATH"
CONF_STDLIBS="$STDLIBS"
case "$CONF_OS$CONF_OSVER" in
Darwin10*) CONF_STDLIBS="${CONF_STDLIBS:+$CONF_STDLIBS }-lSystemStubs" ;;
esac
echo $CONF_LDFLAGS 1>&3
test -z "$CONF_BITS" && case "$CONF_MACH" in
*86*) CONF_BITS=32
case "`file $test`" in
*x86?64*) CONF_BITS=64 ;;
esac
CONF_M="-m$CONF_BITS" ;;
esac
CONF_CFLAGS="${CFLAGS-${CONF_DEBUG:--O3 -g } $CONF_ARCH -std=gnu99 -fomit-frame-pointer -ffast-math} $CONF_M $CONF_STATIC ${CONF_STATIC_EXT:+-static-libgcc}"
CONF_CXXFLAGS="$CXXFLAGS $CONF_M $CONF_STATIC ${CONF_STATIC_EXT:+-static-libstdc++ -static-libgcc}"
## does Fortran need externals for U77 routines?
echo $echo_n "does $CONF_FC need externals for U77 routines... $echo_c" 1>&3
rm -fr $test*
cat > $test.f << _EOF_
program test
implicit none
print *, iargc(), len_trim("Hi")
end
_EOF_
eval ${LOGFILE:+cat $test.f 1>&2}
if $CONF_FC $CONF_FFLAGS -c $test.f 1>&2 ; then
echo "no" 1>&3
CONF_U77EXT=0
else
echo "yes" 1>&3
CONF_U77EXT=1
fi
## does Fortran append underscores to symbols?
echo $echo_n "does $CONF_FC append underscores... $echo_c" 1>&3
rm -fr $test*
echo "void uscore$$_() {}" > $test-c.c
eval ${LOGFILE:+cat $test-c.c 1>&2}
cat > $test.f << _EOF_
program test_uscore
call uscore$$
end
_EOF_
eval ${LOGFILE:+cat $test.f 1>&2}
$CONF_CC $CONF_CFLAGS -c $test-c.c 1>&2
if $CONF_FC $CONF_FFLAGS -o $test $test.f $test-c.o 1>&2 ; then
echo "yes" 1>&3
else
echo "no" 1>&3
CONF_CFLAGS="$CONF_CFLAGS -DNOUNDERSCORE"
fi
## find max SIMD vector length supported by hardware
echo $echo_n "extracting SIMD capabilities of $CONF_FC... $echo_c" 1>&3
cat simd.h - > $test.F << _EOF_ 2> /dev/null
#ifdef GENERIC
#define SIMD2 0
#define PROP "none"
#elif defined __AVX__
#define SIMD2 2
#define PROP "AVX"
#elif defined __SSE3__
#define SIMD2 1
#define PROP "SSE3"
#else
#define SIMD2 0
#define PROP "none"
#endif
program test
print *, PROP
#if defined SIMD && SIMD == SIMD2
#else
print *, SIMD2
#endif
end
_EOF_
eval ${LOGFILE:+cat $test.F 1>&2}
$CONF_FC $CONF_FFLAGS ${CONF_ARCH:-${CONF_DEF}GENERIC} -o $test $test.F 1>&2
set -- `./$test 2>&1`
echo $1 1>&3
case $2 in
0|1|2) cat > simd.h << _EOF_
#if 0
vectorization ability of $CONF_FC on $HOSTNAME
determined by $0 on `date`
#endif
#define SIMD $2
_EOF_
;;
esac
# check for the necessary libraries
CONF_LIBS=
LTLIB=libooptools${CONF_QUAD:+-quad}.a
CONF_LT="`findlib LoopTools $LTLIB LoopTools $LT`" && {
CONF_INCPATH="${CONF_INCPATH:+$CONF_INCPATH:}\$(LT)/../include:\$(LT)"
CONF_LIBS="\$(LT)/$LTLIB"
}
CONF_NINJA="`findlib Ninja libninja.a ninja $NINJA`" && {
echo $echo_n "determining C++ library needed by Ninja... $echo_c" 1>&3
cat > $test.f << _EOF_
program test
call ninjaformcalc
end
_EOF_
eval ${LOGFILE:+cat $test.f 1>&2}
LIBCPP=-lstdc++
$CONF_FC $CONF_FFLAGS -o $test $test.f $CONF_NINJA/libninja.a $CONF_LT/$LTLIB \
$LIBCPP $CONF_STDLIBS 1>&2 || LIBCPP=-lc++
echo "$LIBCPP" 1>&3
CONF_LIBS="\$(NINJA)/libninja.a $LIBCPP${CONF_LIBS:+ $CONF_LIBS}"
}
CONF_SAMURAI="`findlib Samurai libsamurai.a samurai $SAMURAI`" && {
CONF_INCPATH="${CONF_INCPATH:+$CONF_INCPATH:}\$(SAMURAI)/../samurai:\$(SAMURAI)"
CONF_LIBS="\$(SAMURAI)/libsamurai.a \$(SAMURAI)/libqcdloop.a `\$(SAMURAI)/libavh_olo.a${CONF_LIBS:+ $CONF_LIBS}"
}
CONF_CT="`findlib CutTools libcts.a Cuttools $CT`" && {
CONF_INCPATH="${CONF_INCPATH:+$CONF_INCPATH:}\$(CT)"
CONF_LIBS="\$(CT)/libcts.a${CONF_LIBS:+ $CONF_LIBS}"
}
CONF_FH="`findlib FeynHiggs libFH.a FeynHiggs $FH`" && {
CONF_INCPATH="${CONF_INCPATH:+$CONF_INCPATH:}\$(FH)/../include:\$(FH)"
CONF_LIBS="\$(FH)/libFH.a${CONF_LIBS:+ $CONF_LIBS}"
}
CONF_LHAPDF="`findlib LHAPDF libLHAPDF.a lhapdf $LHAPDF`" &&
CONF_LIBS="\$(LHAPDF)/libLHAPDF.a${CONF_LIBS:+ $CONF_LIBS}"
echo "creating makefile" 1>&3
cat - `dirname $0`/makefile.in > makefile << _EOF_
# --- variables defined by configure ---
SRC = $CONF_SRC
PREFIX = $CONF_PREFIX
LIBDIRSUFFIX = $CONF_LIBDIRSUFFIX
EXE = $CONF_EXE
DEF = $CONF_DEF
LT = $CONF_LT
NINJA = $CONF_NINJA
SAMURAI = $CONF_SAMURAI
CT = $CONF_CT
FH = $CONF_FH
LHAPDF = $CONF_LHAPDF
INCPATH = $CONF_INCPATH
STDLIBS = $CONF_LIBS $CONF_STDLIBS
LDFLAGS = $CONF_LDFLAGS
FC = $CONF_FC
FFLAGS = $CONF_FFLAGS \$(DEF)U77EXT=$CONF_U77EXT ${CONF_DEBUG:+\$(DEF)DEBUG}
CC = $CONF_CC
CFLAGS = $CONF_CFLAGS
CXX = $CONF_CXX
CXXFLAGS = $CONF_CXXFLAGS
MCFLAGS = ${CONF_STATIC:+-st} ${CONF_STATIC_EXT:+-st} ${CONF_BITS:+-b$CONF_BITS}
MCLIBS = $CONF_MCLIBS
# --- end defs by configure ---
_EOF_
if test "$CONF_MAKEARGS" = 0 ; then
cat << _EOF_ 1>&3
now you must run $CONF_MAKE
_EOF_
else
$CONF_MAKE $CONF_MAKEARGS 1>&3 2>&3
fi
exit 0
After running make these are the errors:
gfortran -O3 -g -lLHAPDF -ffixed-line-length-none -march=native -ff2c -DU77EXT=0 -I. -I./F -I. -I. -I../../LoopTools/x86_64-Linux/lib64/../include -I../../LoopTools/x86_64-Linux/lib64 -I/usr/local/lib64/../include -I/usr/local/lib64 -Irenconst/ -DPREFIX= -o run run.F renconst.a squaredme.a util.a /usr/local/lib/libLHAPDF.a /usr/local/lib64/libFH.a ../../LoopTools/x86_64-Linux/lib64/libooptools.a
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `getprefixpath_':
/home/vannia/Documents/lhapdf-5.9.1/src/getdatapath.cc:28: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `operator+<char, std::char_traits<char>, std::allocator<char> >':
/usr/include/c++/4.8/bits/basic_string.h:2405: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::append(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::assign(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1131: undefined reference to `std::string::assign(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `getindexpath_':
/home/vannia/Documents/lhapdf-5.9.1/src/getdatapath.cc:55: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/vannia/Documents/lhapdf-5.9.1/src/getdatapath.cc:55: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::append(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `getdatapath_':
/home/vannia/Documents/lhapdf-5.9.1/src/getdatapath.cc:77: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `operator+<char, std::char_traits<char>, std::allocator<char> >':
/usr/include/c++/4.8/bits/basic_string.h:2405: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::append(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `operator+<char, std::char_traits<char>, std::allocator<char> >':
/usr/include/c++/4.8/bits/basic_string.h:2405: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::append(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `getdatapath_':
/home/vannia/Documents/lhapdf-5.9.1/src/getdatapath.cc:82: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `operator+<char, std::char_traits<char>, std::allocator<char> >':
/usr/include/c++/4.8/bits/basic_string.h:2405: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::append(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::operator=(std::string const&)':
/usr/include/c++/4.8/bits/basic_string.h:547: undefined reference to `std::string::assign(std::string const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `operator+<char, std::char_traits<char>, std::allocator<char> >':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
/usr/local/lib/libLHAPDF.a(getdatapath.o):(.data.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
/usr/local/lib/libLHAPDF.a(version.o): In function `getlhapdfversion_':
/home/vannia/Documents/lhapdf-5.9.1/src/version.cc:18: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(version.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(commoninit.o): In function `commoninit_':
commoninit.f:(.text+0x33): relocation truncated to fit: R_X86_64_PC32 against symbol `lhapdf_' defined in COMMON section in /usr/local/lib/libLHAPDF.a(commoninit.o)
commoninit.f:(.text+0x1d1): relocation truncated to fit: R_X86_64_PC32 against symbol `lhaglsta_' defined in COMMON section in /usr/local/lib/libLHAPDF.a(commoninit.o)
../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o): In function `ljacoeff_':
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:110:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:112:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:112:(.text+0x30): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:114:(.text+0x3c): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:114:(.text+0x45): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:114:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:120:(.text+0x84): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:125:(.text+0xd3): relocation truncated to fit: R_X86_64_PC32 against symbol `ltregul_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:125:(.text+0xf0): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
make: *** [run] Error 1
put it in the makefile in the FFLAGS
FC = gfortran
FFLAGS = -O3 -g -ffixed-line-length-none -march=native -ff2c $(DEF)U77EXT=0 -lstdc++
Perhaps regex is not the best way to parse this, tell me if I it is not. Anyway, here are some examples of what the syntax tree looks like:
(S (CC and))
(SBARTMP (IN once) (NP otherstuff))
(S (S (NP blah (VP blah)) (CC then) (NP blah (VP blah (PP blah))) ))
Anyway, what I am trying to do is pull the connective out (and, then, once, etc) and its corresponding head (CC,IN,CC), which I already know for each syntax tree so it can act as an anchor, and I also need to retrieve its parent (in the first it is S, second SBARTMP, and third it is S), and its siblings, if there are any (in the first none, in the second left hand side sibling, and third left-hand-side and right-hand-side sibling). Anything higher than the parent is not included
my $pos = "(\\\w|-)*";
my $sibling = qr{\s*(\\((?:(?>[^()]+)|(?1))*\\))\s*};
my $connective = "once";
my $re = qr{(\(\w*\s*$sibling*\s*\\(IN\s$connective\\)\s*$sibling*\s*\))};
This code works for things like:
my $test1 = "(X (SBAR-TMP (IN once) (S sdf) (S sdf)))";
my $test2 = "(X (SBAR-TMP (IN once))";
my $test3 = "(X (SBAR-TMP (IN once) (X as))";
my $test4 = "(X (SBAR-TMP (X adsf) (IN once))";
It will throw away the X on top and keep everything else, however, once the siblings have stuff embedded in them then it does not match because the regex does not go deeper.
my $test = "(X (SBAR-TMP (IN once) (MORE stuff (MORE stuff))))";
I am not sure how to account for this. I am kind of new to the extended patterns for Perl, just started learning it. To clarify a bit about what the regex is doing: it looks for the connective within two parentheses and the capital-letter/- combo, looks for a complete parent of the same format closing with two parentheses and then should look for any number of siblings that have all their parentheses paired off.
To only get the nearest 'parent' to your anchor connective you can
do it as a recursive parent with a FAIL or do it directly.
(for some reason I can't edit my other posts, must be cookies being deleted).
use strict;
use warnings;
my $connective = qr/ \((?:IN|CC)\s(?:once|and|then)\)/x;
my $sibling = qr/
\s*
(
(?! $connective )
\(
(?:
(?> (?: [^()]+ ) )
| (?-1)
)*
\)
)
\s*
/x;
my $regex1 = qr/
\( ( [\w-]+ \s* $sibling* \s* $connective \s* $sibling* ) \) #1
/x;
my $regex2 = qr/
( #1
\( \s*
( #2
[\w-]+ \s*
(?> $sibling* \s* $connective (?(R)(*FAIL)) \s* $sibling*
| (?1)
)
)
\s*
\)
)
/x;
my $sample = qq/
(X (SBAR-TMP (IN once) (S sdf) (S sdf)))
(X (SBAR-TMP (IN once))
(X (SBAR-TMP (IN once) (X as))
(X (SBAR-TMP (X adsf) (IN once))
(X (SBAR-TMP (IN once) (MORE stuff (MORE stuff))))
(S (CC and))
(SBARTMP (IN once) (NP otherstuff))
(S (S (NP blah (VP blah)) (CC then) (NP blah (VP blah (PP blah))) ))
/;
while ($sample =~ /$regex1/xg) {
print "Found: $1\n";
}
print '-' x 20, "\n";
while ($sample =~ /$regex2/xg) {
print "Found: $2\n";
}
__END__
Why did you give up on this, you almost had it. Try this:
use strict;
use warnings;
my $connective = qr/(?: \((?:IN|CC)\s(?:once|and|then)\) )/x;
my $sibling = qr/
\s*
(
(?!$connect)
\(
(?:
(?> (?: [^()]+ ) )
| (?-1)
)*
\)
)
\s*
/x;
my $regex = qr/
( #1
\(
\s* [\w-]+ \s*
(?> $sibling* \s* $connective \s* $sibling*
| (?1)
)
\s*
\)
)
/x;
my #tests = (
'(X (SBAR-TMP (IN once) (S sdf) (S sdf)))',
'(X (SBAR-TMP (IN once))',
'(X (SBAR-TMP (IN once) (X as))',
'(X (SBAR-TMP (X adsf) (IN once))',
);
for my $sample (#tests)
{
while ($sample =~ /$regex/xg) {
print "Found: $1\n";
}
}
my $another =<<EOS;
(S (CC and))
(SBARTMP (IN once) (NP otherstuff))
(S
(S
(NP blah
(VP blah)
)
(CC then)
(NP blah
(VP blah
(PP blah)
)
)
)
)
EOS
print "\n---------\n";
while ($another =~ /$regex/xg) {
print "\nFound:\n$1\n";
}
END
This should work as well
use strict;
use warnings;
my $connective = qr/(?: \((?:IN|CC)\s(?:once|and|then)\) )/x;
my $sibling = qr/
(?: \s*
(
(?!$connective)
\(
(?:
(?> (?: [^()]+ ) )
| (?-1)
)*
\)
)
\s* )
/x;
my $regex = qr/
( #1
\( \s*
( #2
[\w-]+ \s*
(?> $sibling* \s* $connective (?(R)(*FAIL)) \s* $sibling*
| (?1)
)
)
\s*
\)
)
/x;
my #tests = (
'(X (SBAR-TMP (IN once) (S sdf) (S sdf)))',
'(X (SBAR-TMP (IN once))',
'(X (SBAR-TMP (IN once) (X as))',
'(X (SBAR-TMP (X adsf) (IN once))',
'(X (SBAR-TMP (IN once) (MORE stuff (MORE stuff))))',
);
for my $sample (#tests)
{
while ($sample =~ /$regex/xg) {
print "Found: $2\n";
}
}
my $another = "
(S (CC and))
(SBARTMP (IN once) (NP otherstuff))
(S (S (NP blah (VP blah)) (CC then) (NP blah (VP blah (PP blah))) ))
";
print "\n---------\n";
while ($another =~ /$regex/xg) {
print "\nFound:\n$2\n";
}
__END__