From: zhngbn on
Hi, all
I have heard that the build-in function anint of fortran is kind
of slow, but I have to used it quite frequent in my code. Anyone know
a more efficient version of it?

Thanks a lot.
From: Richard Maine on
zhngbn <bin.zhngbn(a)gmail.com> wrote:

> I have heard that the build-in function anint of fortran is kind
> of slow, but I have to used it quite frequent in my code. Anyone know
> a more efficient version of it?

That's pretty much a meaningless question without a whole lot more
context. That kind of thing depends 100% on the particular compiler
implementation. It would not be a property of the Fortran language,
which doesn't say anything about how the function is implemented. If
there were a faster implementation of exactly the same thing, then
presumably the compiler vendor would adopt it and that would then *BE*
the intrinsic one for that compiler.

There are basically only two ways that can make any sense.

1. If it is a problem with a particular compiler. In that case, well, it
would depend on that particular compiler.

2. The suggestion is that the functionality of anint is inherently slow.
In that case, the interesting question would be what alternate
finctionality would suit your needs.

Mostly, I suspect that you just "heard" from someone who was misinformed
or you misinterpreted what you heard. I suggest that unless you have
concrete data to suggest that thsi is noticeably affecting your code
(which I seriously doubt), then it is not a fruitful direction to
pursue.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
From: zhngbn on
> 2. The suggestion is that the functionality of anint is inherently slow.
> In that case, the interesting question would be what alternate
> functionality would suit your needs.

This is what I wanted. :) Any suggestions?
Sorry for any misunderstanding.
Thanks.
From: dpb on
zhngbn wrote:
>> 2. The suggestion is that the functionality of anint is inherently slow.
>> In that case, the interesting question would be what alternate
>> functionality would suit your needs.
>
> This is what I wanted. :) Any suggestions?
....

Profile the code to first prove what you have is actually a
bottleneck...like Richard, I am also skeptical this is a real problem.

--
From: zhngbn on
On Jul 6, 2:56 pm, dpb <n...(a)non.net> wrote:
> zhngbn wrote:
> >> 2. The suggestion is that the functionality of anint is inherently slow.
> >> In that case, the interesting question would be what alternate
> >> functionality would suit your needs.
>
> > This is what I wanted. :) Any suggestions?
>
> ...
>
> Profile the code to first prove what you have is actually a
> bottleneck...like Richard, I am also skeptical this is a real problem.
>
> --

This is the flat profile I got from gprof:

1 Flat profile:
2
3 Each sample counts as 0.01 seconds.
4 % cumulative self self total
5 time seconds seconds calls s/call s/call name
6 38.95 47.07 47.07 20001 0.00 0.00 derv_
7 20.59 71.96 24.89 20001 0.00 0.00 second_
8 17.76 93.42 21.46 20001 0.00 0.00 third_
9 10.08 105.60 12.18
f_ldnint_val
10 2.95 109.17 3.57 40002 0.00 0.00 ljpote_
11 2.55 112.25 3.08 20000 0.00 0.00 u2cart_
12 2.49 115.26 3.01 20000 0.00 0.00 cart2u_
13 2.17 117.88 2.62
__powr8i4
14 0.72 118.75 0.87
for_random_number_quad
15 0.63 119.51 0.76 20001 0.00 0.00 f_long_

Is the function on line 9 "f_ldnint_val" the build-in "anint"? I have
clearly not defined this function.