Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

There are two ways to write error-free programs; only the third one works.


devel / comp.lang.fortran / Re: Is my version of gfortran just too old?

SubjectAuthor
* Is my version of gfortran just too old?James Van Buskirk
`* Re: Is my version of gfortran just too old?Thomas Koenig
 `* Re: Is my version of gfortran just too old?James Van Buskirk
  `* Re: Is my version of gfortran just too old?gah4
   `* Re: Is my version of gfortran just too old?Thomas Koenig
    `* Re: Is my version of gfortran just too old?gah4
     `* Re: Is my version of gfortran just too old?James Van Buskirk
      `* Re: Is my version of gfortran just too old?gah4
       `* Re: Is my version of gfortran just too old?gah4
        `* Re: Is my version of gfortran just too old?gah4
         `* Re: Is my version of gfortran just too old?Ron Shepard
          `* Re: Is my version of gfortran just too old?gah4
           `* Re: Is my version of gfortran just too old?James Van Buskirk
            `* Re: Is my version of gfortran just too old?gah4
             `* Re: Is my version of gfortran just too old?James Van Buskirk
              `- Re: Is my version of gfortran just too old?gah4

1
Is my version of gfortran just too old?

<tjp2cl$hu86$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3026&group=comp.lang.fortran#3026

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: not_valid@comcast.net (James Van Buskirk)
Newsgroups: comp.lang.fortran
Subject: Is my version of gfortran just too old?
Date: Mon, 31 Oct 2022 11:58:24 -0600
Organization: A noiseless patient Spider
Lines: 1
Message-ID: <tjp2cl$hu86$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="iso-8859-1";
reply-type=original
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 31 Oct 2022 17:58:45 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="eebb83f4eece3543955949ea60ac8046";
logging-data="588038"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YAn3rM+fkdaCW7tsq7b2zRCc7PW4gsGs="
Cancel-Lock: sha1:ISO2WYcYblymt9QLKDDUZMFMKjg=
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
Importance: Normal
X-MSMail-Priority: Normal
 by: James Van Buskirk - Mon, 31 Oct 2022 17:58 UTC

I encountered the following bug:

D:\gfortran\james\cheby2>type bug1.f90
function insert(lower,mi)
implicit none
integer, intent(in) :: lower(:)
integer, intent(in) :: mi
integer(size(lower)+1) insert
integer loc

loc = maxloc(lower,mask = mi > lower,dim = 1)
insert = [lower(1:loc),mi,lower(loc+1:)]
end function insert

D:\gfortran\james\cheby2>gfortran -c bug1.f90
bug1.f90:5:22:

integer(size(lower)+1) insert
1
Error: Deferred array 'lower' at (1) is not permitted in an initialization
expre
ssion
bug1.f90:1:6:

function insert(lower,mi)
1
Error: Function 'insert' at (1) has no IMPLICIT type

gfortran -v says
gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)

Is there a newer version that fixes this?

Re: Is my version of gfortran just too old?

<tjp54r$2il75$1@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3027&group=comp.lang.fortran#3027

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2a0a-a540-3cee-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: Is my version of gfortran just too old?
Date: Mon, 31 Oct 2022 18:45:47 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <tjp54r$2il75$1@newsreader4.netcologne.de>
References: <tjp2cl$hu86$1@dont-email.me>
Injection-Date: Mon, 31 Oct 2022 18:45:47 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2a0a-a540-3cee-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2a0a:a540:3cee:0:7285:c2ff:fe6c:992d";
logging-data="2708709"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Mon, 31 Oct 2022 18:45 UTC

James Van Buskirk <not_valid@comcast.net> schrieb:
> I encountered the following bug:
>
> D:\gfortran\james\cheby2>type bug1.f90
> function insert(lower,mi)
> implicit none
> integer, intent(in) :: lower(:)
> integer, intent(in) :: mi
> integer(size(lower)+1) insert
> integer loc
>
> loc = maxloc(lower,mask = mi > lower,dim = 1)
> insert = [lower(1:loc),mi,lower(loc+1:)]
> end function insert
>
> D:\gfortran\james\cheby2>gfortran -c bug1.f90
> bug1.f90:5:22:
>
> integer(size(lower)+1) insert
> 1
> Error: Deferred array 'lower' at (1) is not permitted in an initialization
> expre
> ssion

Do you want to select the kind of the integer dynamically? That
is not possible, the KIND has to be a compile-time constant.

If you meant to write

integer :: insert(size(lower)+1)

that should work (without having tested it).

Re: Is my version of gfortran just too old?

<tjp8ap$idrb$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3028&group=comp.lang.fortran#3028

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: not_valid@comcast.net (James Van Buskirk)
Newsgroups: comp.lang.fortran
Subject: Re: Is my version of gfortran just too old?
Date: Mon, 31 Oct 2022 13:39:47 -0600
Organization: A noiseless patient Spider
Lines: 1
Message-ID: <tjp8ap$idrb$1@dont-email.me>
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de>
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="Windows-1252";
reply-type=original
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 31 Oct 2022 19:40:10 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="eebb83f4eece3543955949ea60ac8046";
logging-data="604011"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18AQdnkkGQpfQGZMgSoZVChATbITUa2NdE="
Cancel-Lock: sha1:prRNfQsTKbqQMQ/uQJWdP67tNxY=
X-MSMail-Priority: Normal
Importance: Normal
In-Reply-To: <tjp54r$2il75$1@newsreader4.netcologne.de>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
 by: James Van Buskirk - Mon, 31 Oct 2022 19:39 UTC

"Thomas Koenig" wrote in message
news:tjp54r$2il75$1@newsreader4.netcologne.de...

> integer :: insert(size(lower)+1)

Thanks. I was translating code from Matlab to Fortran and sort
of forgot the syntax rules. This was indeed my mistake.

Re: Is my version of gfortran just too old?

<7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3029&group=comp.lang.fortran#3029

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a37:4646:0:b0:6e4:ed82:a3ac with SMTP id t67-20020a374646000000b006e4ed82a3acmr10532905qka.57.1667246150772;
Mon, 31 Oct 2022 12:55:50 -0700 (PDT)
X-Received: by 2002:a05:620a:280e:b0:6a6:ee16:8c78 with SMTP id
f14-20020a05620a280e00b006a6ee168c78mr10480320qkp.122.1667246150633; Mon, 31
Oct 2022 12:55:50 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Mon, 31 Oct 2022 12:55:50 -0700 (PDT)
In-Reply-To: <tjp8ap$idrb$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:74f6:f1e0:472d:366f;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:74f6:f1e0:472d:366f
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de>
<tjp8ap$idrb$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com>
Subject: Re: Is my version of gfortran just too old?
From: gah4@u.washington.edu (gah4)
Injection-Date: Mon, 31 Oct 2022 19:55:50 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1811
 by: gah4 - Mon, 31 Oct 2022 19:55 UTC

On Monday, October 31, 2022 at 12:40:13 PM UTC-7, James Van Buskirk wrote:
> "Thomas Koenig" wrote in message
> news:tjp54r$2il75$1...@newsreader4.netcologne.de...
> > integer :: insert(size(lower)+1)
> Thanks. I was translating code from Matlab to Fortran and sort
> of forgot the syntax rules. This was indeed my mistake.

And, reading along, I knew what it was supposed to do, and didn't notice.

Or, maybe, it is time for lunch.

I do hope you don't use this too much. If I understand it, it
allocates a whole new array each time. I am not sure what
happens to the old one.

Re: Is my version of gfortran just too old?

<tjpamf$2iph3$1@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3030&group=comp.lang.fortran#3030

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2a0a-a540-3cee-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: Is my version of gfortran just too old?
Date: Mon, 31 Oct 2022 20:20:31 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <tjpamf$2iph3$1@newsreader4.netcologne.de>
References: <tjp2cl$hu86$1@dont-email.me>
<tjp54r$2il75$1@newsreader4.netcologne.de> <tjp8ap$idrb$1@dont-email.me>
<7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com>
Injection-Date: Mon, 31 Oct 2022 20:20:31 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2a0a-a540-3cee-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2a0a:a540:3cee:0:7285:c2ff:fe6c:992d";
logging-data="2713123"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Mon, 31 Oct 2022 20:20 UTC

gah4 <gah4@u.washington.edu> schrieb:
> On Monday, October 31, 2022 at 12:40:13 PM UTC-7, James Van Buskirk wrote:
>> "Thomas Koenig" wrote in message
>> news:tjp54r$2il75$1...@newsreader4.netcologne.de...
>
>> > integer :: insert(size(lower)+1)
>
>> Thanks. I was translating code from Matlab to Fortran

A step in the right direction :-)

>and sort
>> of forgot the syntax rules. This was indeed my mistake.
>
> And, reading along, I knew what it was supposed to do, and didn't notice.
>
> Or, maybe, it is time for lunch.
>
> I do hope you don't use this too much. If I understand it, it
> allocates a whole new array each time. I am not sure what
> happens to the old one.

When it goes out of scope, it no longer uses memory. (I was
going to say it is deallocated, but that has a precise meaning
in Fortran, so I didn't).

There are ways to create memory leaks in Fortran, but they
all involve pointers.

Re: Is my version of gfortran just too old?

<d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3031&group=comp.lang.fortran#3031

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:430a:b0:6f6:589b:463d with SMTP id u10-20020a05620a430a00b006f6589b463dmr10602159qko.139.1667250256900;
Mon, 31 Oct 2022 14:04:16 -0700 (PDT)
X-Received: by 2002:a0c:9047:0:b0:4bb:f778:b946 with SMTP id
o65-20020a0c9047000000b004bbf778b946mr5893346qvo.77.1667250256712; Mon, 31
Oct 2022 14:04:16 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Mon, 31 Oct 2022 14:04:16 -0700 (PDT)
In-Reply-To: <tjpamf$2iph3$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:74f6:f1e0:472d:366f;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:74f6:f1e0:472d:366f
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de>
<tjp8ap$idrb$1@dont-email.me> <7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com>
<tjpamf$2iph3$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com>
Subject: Re: Is my version of gfortran just too old?
From: gah4@u.washington.edu (gah4)
Injection-Date: Mon, 31 Oct 2022 21:04:16 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2799
 by: gah4 - Mon, 31 Oct 2022 21:04 UTC

On Monday, October 31, 2022 at 1:20:35 PM UTC-7, Thomas Koenig wrote:

(snip, I wrote)
> > I do hope you don't use this too much. If I understand it, it
> > allocates a whole new array each time. I am not sure what
> > happens to the old one.

> When it goes out of scope, it no longer uses memory. (I was
> going to say it is deallocated, but that has a precise meaning
> in Fortran, so I didn't).
> There are ways to create memory leaks in Fortran, but they
> all involve pointers.

It would help to show how the function is called.

And the calling routine might even use pointers.

In any case, there is at least one new array allocated for each call.
If you aren't careful, there might be two or three.

OK, say you do:

integer, allocatable :: y(:)

y = insert(x,3)

As well as I know it, insert allocates an array to return the result, a new
copy of y is allocated (allocate on assignment) and the return array goes away.

Even more interesting:

do i=1,10
y = insert(y, i)
end do

Now the original y gets deallocated, though two allocations each
time through the loop.

integer, pointer :: z(:)

z => insert(x,3)

I don't know if that is allowed., but I think

z => insert(z, 3)

does leak memory for z.

You could also have a function return an allocatable array, and I think:

integer, allocatable :: w(:)

! (allocate and use w)

move_alloc(insert(w,3), w)

So, only one allocation each time.

Re: Is my version of gfortran just too old?

<tjpq6s$jqgn$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3032&group=comp.lang.fortran#3032

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: not_valid@comcast.net (James Van Buskirk)
Newsgroups: comp.lang.fortran
Subject: Re: Is my version of gfortran just too old?
Date: Mon, 31 Oct 2022 18:44:54 -0600
Organization: A noiseless patient Spider
Lines: 1
Message-ID: <tjpq6s$jqgn$1@dont-email.me>
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de> <tjp8ap$idrb$1@dont-email.me> <7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com> <tjpamf$2iph3$1@newsreader4.netcologne.de> <d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="UTF-8";
reply-type=original
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 1 Nov 2022 00:45:16 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="15bca88aa5bba8652f9acafe3558f56b";
logging-data="649751"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CA+FwSqSQCp1PMYwPwfQ9hg6Ftd/kxSE="
Cancel-Lock: sha1:vF+FuSATHEcDj7eUa/TOskyCPxI=
In-Reply-To: <d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com>
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
X-Priority: 3
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
X-MSMail-Priority: Normal
 by: James Van Buskirk - Tue, 1 Nov 2022 00:44 UTC

"gah4" wrote in message
news:d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com...

> y = insert(x,3)

This was close to my usage, which actually was:

lower_new = insert(lower,mi)

It replaced the Matlab code:

lower_new = sort([mi lower])

Both methods are highly efficient in that they reliably insert
the new element mi into the sorted array lower, while still
occupying perhaps a couple of ppm of overall CPU time.
Of course, I admit to having gotten a little cross-eyed in
composing the Fortran replacement :)
Replacing code like

err = jac\f;

or

plot(dplot',xplot,'b-');

is much more problematic.

Re: Is my version of gfortran just too old?

<f006fa9a-056f-4a55-8ec6-402503987b07n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3033&group=comp.lang.fortran#3033

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:bc1:b0:6ef:2e0:d8c1 with SMTP id s1-20020a05620a0bc100b006ef02e0d8c1mr11529512qki.351.1667265542727;
Mon, 31 Oct 2022 18:19:02 -0700 (PDT)
X-Received: by 2002:a05:6214:5185:b0:472:f9b0:cbc6 with SMTP id
kl5-20020a056214518500b00472f9b0cbc6mr13577577qvb.92.1667265542591; Mon, 31
Oct 2022 18:19:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Mon, 31 Oct 2022 18:19:02 -0700 (PDT)
In-Reply-To: <tjpq6s$jqgn$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:74f6:f1e0:472d:366f;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:74f6:f1e0:472d:366f
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de>
<tjp8ap$idrb$1@dont-email.me> <7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com>
<tjpamf$2iph3$1@newsreader4.netcologne.de> <d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com>
<tjpq6s$jqgn$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f006fa9a-056f-4a55-8ec6-402503987b07n@googlegroups.com>
Subject: Re: Is my version of gfortran just too old?
From: gah4@u.washington.edu (gah4)
Injection-Date: Tue, 01 Nov 2022 01:19:02 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2563
 by: gah4 - Tue, 1 Nov 2022 01:19 UTC

On Monday, October 31, 2022 at 5:45:20 PM UTC-7, James Van Buskirk wrote:
> "gah4" wrote in message
> news:d604914b-d8a2-4857...@googlegroups.com...
>
> > y = insert(x,3)
>
> This was close to my usage, which actually was:
>
> lower_new = insert(lower,mi)
>
> It replaced the Matlab code:
>
> lower_new = sort([mi lower])
>
> Both methods are highly efficient in that they reliably insert
> the new element mi into the sorted array lower, while still
> occupying perhaps a couple of ppm of overall CPU time.
> Of course, I admit to having gotten a little cross-eyed in
> composing the Fortran replacement :)
> Replacing code like

So I presume you are not doing this for millions of billions of elements.

Some years ago, I was working on a C program that reads a file into memory.
It had a loop that reads a line, and uses strcat() to add it to the buffer.

And this was done for maybe 1,000,000 elements. (From 60 character lines.)

That is O(n**2), as is I believe yours.

But if n isn't so big, it should be fine.

And as previously, as far as I know it allocates two arrays each
time through the loop.

Re: Is my version of gfortran just too old?

<2cc52c31-2a81-4db7-adc1-61756b2b196bn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3034&group=comp.lang.fortran#3034

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a0c:b351:0:b0:4bc:9ed:6fe6 with SMTP id a17-20020a0cb351000000b004bc09ed6fe6mr9935105qvf.76.1667369410245;
Tue, 01 Nov 2022 23:10:10 -0700 (PDT)
X-Received: by 2002:ac8:4256:0:b0:3a4:fd1c:a5ca with SMTP id
r22-20020ac84256000000b003a4fd1ca5camr18573820qtm.77.1667369410068; Tue, 01
Nov 2022 23:10:10 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 1 Nov 2022 23:10:09 -0700 (PDT)
In-Reply-To: <f006fa9a-056f-4a55-8ec6-402503987b07n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:3c7c:6dba:c43a:e97e;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:3c7c:6dba:c43a:e97e
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de>
<tjp8ap$idrb$1@dont-email.me> <7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com>
<tjpamf$2iph3$1@newsreader4.netcologne.de> <d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com>
<tjpq6s$jqgn$1@dont-email.me> <f006fa9a-056f-4a55-8ec6-402503987b07n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2cc52c31-2a81-4db7-adc1-61756b2b196bn@googlegroups.com>
Subject: Re: Is my version of gfortran just too old?
From: gah4@u.washington.edu (gah4)
Injection-Date: Wed, 02 Nov 2022 06:10:10 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2270
 by: gah4 - Wed, 2 Nov 2022 06:10 UTC

(snip)

> And this was done for maybe 1,000,000 elements. (From 60 character lines.)
> That is O(n**2), as is I believe yours.

OK, I am running this one:

integer, allocatable :: x(:)
interface
function insert(y, mi)
integer, intent(in) :: y(:), mi
integer insert(size(y)+1)
end function
end interface

allocate(x(1))
x(1)=1
do i=1000000,1,-1
x=insert(x,i)
enddo
print *,x(1), x(size(x)), size(x)
end

function insert(lower,mi)
implicit none
integer, intent(in) :: lower(:)
integer, intent(in) :: mi
integer insert(size(lower)+1)
integer loc

loc = maxloc(lower,mask = mi > lower,dim = 1)
insert = [lower(1:loc),mi,lower(loc+1:)]
end function insert

Any suggestions on how long it should take?

I will post when it is done.

Re: Is my version of gfortran just too old?

<dad145dd-c4db-475c-b383-554d6e19f443n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3035&group=comp.lang.fortran#3035

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:903:b0:3a5:4062:4b15 with SMTP id bx3-20020a05622a090300b003a540624b15mr4351013qtb.351.1667373547056;
Wed, 02 Nov 2022 00:19:07 -0700 (PDT)
X-Received: by 2002:a05:620a:10b7:b0:6fa:398c:4218 with SMTP id
h23-20020a05620a10b700b006fa398c4218mr8248031qkk.647.1667373546930; Wed, 02
Nov 2022 00:19:06 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 2 Nov 2022 00:19:06 -0700 (PDT)
In-Reply-To: <2cc52c31-2a81-4db7-adc1-61756b2b196bn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:3c7c:6dba:c43a:e97e;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:3c7c:6dba:c43a:e97e
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de>
<tjp8ap$idrb$1@dont-email.me> <7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com>
<tjpamf$2iph3$1@newsreader4.netcologne.de> <d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com>
<tjpq6s$jqgn$1@dont-email.me> <f006fa9a-056f-4a55-8ec6-402503987b07n@googlegroups.com>
<2cc52c31-2a81-4db7-adc1-61756b2b196bn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dad145dd-c4db-475c-b383-554d6e19f443n@googlegroups.com>
Subject: Re: Is my version of gfortran just too old?
From: gah4@u.washington.edu (gah4)
Injection-Date: Wed, 02 Nov 2022 07:19:07 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1800
 by: gah4 - Wed, 2 Nov 2022 07:19 UTC

On Tuesday, November 1, 2022 at 11:10:12 PM UTC-7, gah4 wrote:
> (snip)

> do i=1000000,1,-1
> x=insert(x,i)
> enddo

(snip)

> Any suggestions on how long it should take?
> I will post when it is done.

And the answer is 82 minutes.

Re: Is my version of gfortran just too old?

<Zmv8L.6710$Jjx8.4068@fx15.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3036&group=comp.lang.fortran#3036

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:102.0)
Gecko/20100101 Thunderbird/102.4.1
Subject: Re: Is my version of gfortran just too old?
Content-Language: en-US
Newsgroups: comp.lang.fortran
References: <tjp2cl$hu86$1@dont-email.me>
<tjp54r$2il75$1@newsreader4.netcologne.de> <tjp8ap$idrb$1@dont-email.me>
<7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com>
<tjpamf$2iph3$1@newsreader4.netcologne.de>
<d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com>
<tjpq6s$jqgn$1@dont-email.me>
<f006fa9a-056f-4a55-8ec6-402503987b07n@googlegroups.com>
<2cc52c31-2a81-4db7-adc1-61756b2b196bn@googlegroups.com>
<dad145dd-c4db-475c-b383-554d6e19f443n@googlegroups.com>
From: nospam@nowhere.org (Ron Shepard)
In-Reply-To: <dad145dd-c4db-475c-b383-554d6e19f443n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 29
Message-ID: <Zmv8L.6710$Jjx8.4068@fx15.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Wed, 2 Nov 2022 09:44:08 -0500
X-Received-Bytes: 2155
 by: Ron Shepard - Wed, 2 Nov 2022 14:44 UTC

On 11/2/22 2:19 AM, gah4 wrote:
> On Tuesday, November 1, 2022 at 11:10:12 PM UTC-7, gah4 wrote:
>> (snip)
>
>> do i=1000000,1,-1
>> x=insert(x,i)
>> enddo
>
> (snip)
>
>> Any suggestions on how long it should take?
>
>> I will post when it is done.
>
> And the answer is 82 minutes.

You should consider a different underlying data structure than a linear
array. I suggest looking at a binary search tree (BST). You can code a
simple one in fortran in about the same number of lines as your posted
example.

Your insertion step requires O(n) effort for each insertion where n is
the current number of data points. A BST insertion requires O(log(n))
effort for each insertion. There are some other data structures that
might be useful too, but this is simple and should get you started in
the right direction.

$.02 -Ron Shepard

Re: Is my version of gfortran just too old?

<b4284a2d-ba24-48fb-93b0-e9851cbb48ecn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3037&group=comp.lang.fortran#3037

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a37:b7c3:0:b0:6f7:65f6:a896 with SMTP id h186-20020a37b7c3000000b006f765f6a896mr18402324qkf.293.1667414132682;
Wed, 02 Nov 2022 11:35:32 -0700 (PDT)
X-Received: by 2002:a05:622a:ca:b0:3a5:24d2:9295 with SMTP id
p10-20020a05622a00ca00b003a524d29295mr15329063qtw.300.1667414132454; Wed, 02
Nov 2022 11:35:32 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 2 Nov 2022 11:35:32 -0700 (PDT)
In-Reply-To: <Zmv8L.6710$Jjx8.4068@fx15.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:60fa:ecb6:7c48:7efb;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:60fa:ecb6:7c48:7efb
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de>
<tjp8ap$idrb$1@dont-email.me> <7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com>
<tjpamf$2iph3$1@newsreader4.netcologne.de> <d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com>
<tjpq6s$jqgn$1@dont-email.me> <f006fa9a-056f-4a55-8ec6-402503987b07n@googlegroups.com>
<2cc52c31-2a81-4db7-adc1-61756b2b196bn@googlegroups.com> <dad145dd-c4db-475c-b383-554d6e19f443n@googlegroups.com>
<Zmv8L.6710$Jjx8.4068@fx15.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b4284a2d-ba24-48fb-93b0-e9851cbb48ecn@googlegroups.com>
Subject: Re: Is my version of gfortran just too old?
From: gah4@u.washington.edu (gah4)
Injection-Date: Wed, 02 Nov 2022 18:35:32 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2972
 by: gah4 - Wed, 2 Nov 2022 18:35 UTC

On Wednesday, November 2, 2022 at 7:44:12 AM UTC-7, Ron Shepard wrote:

(snip, I wrote)

> > And the answer is 82 minutes.

> You should consider a different underlying data structure than a linear
> array. I suggest looking at a binary search tree (BST). You can code a
> simple one in fortran in about the same number of lines as your posted
> example.
> Your insertion step requires O(n) effort for each insertion where n is
> the current number of data points. A BST insertion requires O(log(n))
> effort for each insertion. There are some other data structures that
> might be useful too, but this is simple and should get you started in
> the right direction.
Just to be sure, it is James data structure and not mine.
I was trying to see how to call insert, and this was my first time
with an INTERFACE for a function returning a variable number of
array elements.

There is a popular binary search tree using pointers, but there is
also the heap, and especially binary heap:

https://en.wikipedia.org/wiki/Heap_(data_structure)

The binary heap is a binary tree without the pointers.

But that only helps if you don't reallocate it (once, or twice,
or more) each time.

But if N is 10, or 100, or even 1000, then it isn't so bad.

My calculation says for N=1,000,000,000 it is 156 years.

Re: Is my version of gfortran just too old?

<tkjggi$jnrq$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3107&group=comp.lang.fortran#3107

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: not_valid@comcast.net (James Van Buskirk)
Newsgroups: comp.lang.fortran
Subject: Re: Is my version of gfortran just too old?
Date: Thu, 10 Nov 2022 11:38:23 -0700
Organization: A noiseless patient Spider
Lines: 1
Message-ID: <tkjggi$jnrq$1@dont-email.me>
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de> <tjp8ap$idrb$1@dont-email.me> <7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com> <tjpamf$2iph3$1@newsreader4.netcologne.de> <d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com> <tjpq6s$jqgn$1@dont-email.me> <f006fa9a-056f-4a55-8ec6-402503987b07n@googlegroups.com> <2cc52c31-2a81-4db7-adc1-61756b2b196bn@googlegroups.com> <dad145dd-c4db-475c-b383-554d6e19f443n@googlegroups.com> <Zmv8L.6710$Jjx8.4068@fx15.iad> <b4284a2d-ba24-48fb-93b0-e9851cbb48ecn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="UTF-8";
reply-type=original
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 10 Nov 2022 18:39:14 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="60b7d5a4000874c6684d8cc1f1c332a2";
logging-data="647034"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19uGyzNq84blkBd8v+iIvbknhS7CcHVdTI="
Cancel-Lock: sha1:z/Vve1uIlHMDtKIem8o6Zct+SdE=
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
Importance: Normal
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
In-Reply-To: <b4284a2d-ba24-48fb-93b0-e9851cbb48ecn@googlegroups.com>
 by: James Van Buskirk - Thu, 10 Nov 2022 18:38 UTC

"gah4" wrote in message
news:b4284a2d-ba24-48fb-93b0-e9851cbb48ecn@googlegroups.com...

> On Wednesday, November 2, 2022 at 7:44:12 AM UTC-7, Ron Shepard wrote:

> (snip, I wrote)

> > > And the answer is 82 minutes.

> > You should consider a different underlying data structure than a linear
> > array. I suggest looking at a binary search tree (BST). You can code a
> > simple one in fortran in about the same number of lines as your posted
> > example.

> > Your insertion step requires O(n) effort for each insertion where n is
> > the current number of data points. A BST insertion requires O(log(n))
> > effort for each insertion. There are some other data structures that
> > might be useful too, but this is simple and should get you started in
> > the right direction.

> Just to be sure, it is James data structure and not mine.
> I was trying to see how to call insert, and this was my first time
> with an INTERFACE for a function returning a variable number of
> array elements.

> There is a popular binary search tree using pointers, but there is
> also the heap, and especially binary heap:

For this particular data structure there was no impact on performance,
but there was another one where the results were accumulated in
arrays. That really did slow things down tremendously but I hadn't
noticed before because the rest of my program was too slow for
the arrays to get that large. Since the results were to be plotted,
their order of generation was what mattered so I dropped them into
a linked list and the longest-running cases sped up by an order of
magnitude.

In the original example the sorted arrays had to be swept through
in order several times after each update so only arrays made
sense.

Re: Is my version of gfortran just too old?

<1868633b-01d9-4c22-9220-7a324ddeb9c2n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3111&group=comp.lang.fortran#3111

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a0c:f243:0:b0:4c6:dd9:586c with SMTP id z3-20020a0cf243000000b004c60dd9586cmr614261qvl.40.1668113675104;
Thu, 10 Nov 2022 12:54:35 -0800 (PST)
X-Received: by 2002:a0c:ebc4:0:b0:4b4:8037:1303 with SMTP id
k4-20020a0cebc4000000b004b480371303mr1876200qvq.16.1668113674936; Thu, 10 Nov
2022 12:54:34 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 10 Nov 2022 12:54:34 -0800 (PST)
In-Reply-To: <tkjggi$jnrq$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:e021:8644:700f:cf57;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:e021:8644:700f:cf57
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de>
<tjp8ap$idrb$1@dont-email.me> <7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com>
<tjpamf$2iph3$1@newsreader4.netcologne.de> <d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com>
<tjpq6s$jqgn$1@dont-email.me> <f006fa9a-056f-4a55-8ec6-402503987b07n@googlegroups.com>
<2cc52c31-2a81-4db7-adc1-61756b2b196bn@googlegroups.com> <dad145dd-c4db-475c-b383-554d6e19f443n@googlegroups.com>
<Zmv8L.6710$Jjx8.4068@fx15.iad> <b4284a2d-ba24-48fb-93b0-e9851cbb48ecn@googlegroups.com>
<tkjggi$jnrq$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1868633b-01d9-4c22-9220-7a324ddeb9c2n@googlegroups.com>
Subject: Re: Is my version of gfortran just too old?
From: gah4@u.washington.edu (gah4)
Injection-Date: Thu, 10 Nov 2022 20:54:35 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3333
 by: gah4 - Thu, 10 Nov 2022 20:54 UTC

On Thursday, November 10, 2022 at 10:39:17 AM UTC-8, James Van Buskirk wrote:

(snip, I wrote)
> > There is a popular binary search tree using pointers, but there is
> > also the heap, and especially binary heap:

> For this particular data structure there was no impact on performance,
> but there was another one where the results were accumulated in
> arrays. That really did slow things down tremendously but I hadn't
> noticed before because the rest of my program was too slow for
> the arrays to get that large. Since the results were to be plotted,
> their order of generation was what mattered so I dropped them into
> a linked list and the longest-running cases sped up by an order of
> magnitude.
> In the original example the sorted arrays had to be swept through
> in order several times after each update so only arrays made
> sense.

The binary heap is an interesting data structure, and one well
designed for languages were arrays start at 1. (It is usual to
ignore the 0th element in C.)

If you consider a balanced binary tree, and read off the elements
row by row, and then store them in an array:

the root goes in element 1.
The next two in elements 10 and 11. (Binary addressing.)
The next four in elements 100, 101, 110, 111.

Because of the way the addressing works, you can go up the
tree, just shifting the address right one bit at a time.

There is a convenient algorithm to go through the elements
in sorted order, based on binary arithmetic. Maybe not quite
as fast as a sorted array, but pretty fast.

And it is O(log N) to add elements to the heap.

Re: Is my version of gfortran just too old?

<tkk0u3$l094$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3114&group=comp.lang.fortran#3114

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: not_valid@comcast.net (James Van Buskirk)
Newsgroups: comp.lang.fortran
Subject: Re: Is my version of gfortran just too old?
Date: Thu, 10 Nov 2022 16:18:42 -0700
Organization: A noiseless patient Spider
Lines: 1
Message-ID: <tkk0u3$l094$1@dont-email.me>
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de> <tjp8ap$idrb$1@dont-email.me> <7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com> <tjpamf$2iph3$1@newsreader4.netcologne.de> <d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com> <tjpq6s$jqgn$1@dont-email.me> <f006fa9a-056f-4a55-8ec6-402503987b07n@googlegroups.com> <2cc52c31-2a81-4db7-adc1-61756b2b196bn@googlegroups.com> <dad145dd-c4db-475c-b383-554d6e19f443n@googlegroups.com> <Zmv8L.6710$Jjx8.4068@fx15.iad> <b4284a2d-ba24-48fb-93b0-e9851cbb48ecn@googlegroups.com> <tkjggi$jnrq$1@dont-email.me> <1868633b-01d9-4c22-9220-7a324ddeb9c2n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="UTF-8";
reply-type=original
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 10 Nov 2022 23:19:31 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="307511bbedd46ea7f47a399887990b96";
logging-data="688420"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BegDaZw4MweAogcgJtxCMoXx5hgGSKME="
Cancel-Lock: sha1:xlVMp4knVkBKmGUtx6BhVX3EQVQ=
In-Reply-To: <1868633b-01d9-4c22-9220-7a324ddeb9c2n@googlegroups.com>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
 by: James Van Buskirk - Thu, 10 Nov 2022 23:18 UTC

"gah4" wrote in message
news:1868633b-01d9-4c22-9220-7a324ddeb9c2n@googlegroups.com...

> The binary heap is an interesting data structure, and one well
> designed for languages were arrays start at 1. (It is usual to
> ignore the 0th element in C.)

> If you consider a balanced binary tree, and read off the elements
> row by row, and then store them in an array:

> the root goes in element 1.
> The next two in elements 10 and 11. (Binary addressing.)
> The next four in elements 100, 101, 110, 111.

> Because of the way the addressing works, you can go up the
> tree, just shifting the address right one bit at a time.

> There is a convenient algorithm to go through the elements
> in sorted order, based on binary arithmetic. Maybe not quite
> as fast as a sorted array, but pretty fast.

> And it is O(log N) to add elements to the heap.

I think that I have previously post AVL tree code to this forum.

It is unfortunate that you have not fleshed your ideas out by
posting code like:

integer n
real(REAL64) harvest
..
..
..
call RANDOM_NUMBER(harvest)
n = HUGE(n)*harvest
! Now insert n into your data structure...

So as to compare performance between the example you posted
and your proposed data structure solution...

Re: Is my version of gfortran just too old?

<cd04cf6d-d5ab-413f-b525-f544f62d9ca9n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=3118&group=comp.lang.fortran#3118

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:8005:b0:6fa:17e5:b62b with SMTP id ee5-20020a05620a800500b006fa17e5b62bmr2458447qkb.676.1668127033307;
Thu, 10 Nov 2022 16:37:13 -0800 (PST)
X-Received: by 2002:a0c:e18d:0:b0:4b7:ac8a:c3e5 with SMTP id
p13-20020a0ce18d000000b004b7ac8ac3e5mr131633qvl.92.1668127033153; Thu, 10 Nov
2022 16:37:13 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 10 Nov 2022 16:37:12 -0800 (PST)
In-Reply-To: <tkk0u3$l094$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:e021:8644:700f:cf57;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:e021:8644:700f:cf57
References: <tjp2cl$hu86$1@dont-email.me> <tjp54r$2il75$1@newsreader4.netcologne.de>
<tjp8ap$idrb$1@dont-email.me> <7cef4d63-8bae-446f-b4c1-c3644a33e501n@googlegroups.com>
<tjpamf$2iph3$1@newsreader4.netcologne.de> <d604914b-d8a2-4857-add1-2f92706d2898n@googlegroups.com>
<tjpq6s$jqgn$1@dont-email.me> <f006fa9a-056f-4a55-8ec6-402503987b07n@googlegroups.com>
<2cc52c31-2a81-4db7-adc1-61756b2b196bn@googlegroups.com> <dad145dd-c4db-475c-b383-554d6e19f443n@googlegroups.com>
<Zmv8L.6710$Jjx8.4068@fx15.iad> <b4284a2d-ba24-48fb-93b0-e9851cbb48ecn@googlegroups.com>
<tkjggi$jnrq$1@dont-email.me> <1868633b-01d9-4c22-9220-7a324ddeb9c2n@googlegroups.com>
<tkk0u3$l094$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cd04cf6d-d5ab-413f-b525-f544f62d9ca9n@googlegroups.com>
Subject: Re: Is my version of gfortran just too old?
From: gah4@u.washington.edu (gah4)
Injection-Date: Fri, 11 Nov 2022 00:37:13 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3292
 by: gah4 - Fri, 11 Nov 2022 00:37 UTC

On Thursday, November 10, 2022 at 3:19:35 PM UTC-8, James Van Buskirk wrote:

(snip)

> I think that I have previously post AVL tree code to this forum.
> It is unfortunate that you have not fleshed your ideas out by
> posting code like:
> integer n
> real(REAL64) harvest
> call RANDOM_NUMBER(harvest)
> n = HUGE(n)*harvest
> ! Now insert n into your data structure...
> So as to compare performance between the example you posted
> and your proposed data structure solution...

Many years ago for a CS class assignment I did a heapsort program.
(In PDP-10 ALGOL!) That was based on the explanation in
Knuth's volume 3, which I think I bought to do that assignment.

I have not actually tried to write one since then.

I think, though, it depends somewhat on how, and how often, you
go through the sorted data.

As well as I know, your original program goes through the array
four times for each call. One to create the mask. One to extract
the location from the mask. One to copy into the return array.
One to copy the return array to the called program array.

Though that only means a 4 in front of the N**2.

OK, now another Fortran tree story.

The IBM Fortran H compiler stores the symbol table in six
balanced trees, instead of a hash table. In the manual, they
suggest that for faster compilation, you distribute your names
equally between 1 and 6 characters!

No suggestion that you choose names for readability, though.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor