Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Life sucks, but death doesn't put out at all...." -- Thomas J. Kopp


devel / comp.lang.fortran / Re: is there a better way to code this ?

SubjectAuthor
* is there a better way to code this ?Lynn McGuire
+- Re: is there a better way to code this ?gah4
+* Re: is there a better way to code this ?pmk
|`- Re: is there a better way to code this ?gah4
+* Re: is there a better way to code this ?gah4
|+* Re: is there a better way to code this ?Lynn McGuire
||+* Re: is there a better way to code this ?jfh
|||`* Re: is there a better way to code this ?Lynn McGuire
||| `* Re: is there a better way to code this ?gah4
|||  `* Re: is there a better way to code this ?Lynn McGuire
|||   +* Re: is there a better way to code this ?gah4
|||   |+- Re: is there a better way to code this ?Lynn McGuire
|||   |+* Re: is there a better way to code this ?Lynn McGuire
|||   ||`* Re: is there a better way to code this ?gah4
|||   || `- Re: is there a better way to code this ?Lynn McGuire
|||   |`- Re: is there a better way to code this ?Gary Scott
|||   `- Re: is there a better way to code this ?Robin Vowels
||`- Re: is there a better way to code this ?gah4
|`* Re: is there a better way to code this ?Lynn McGuire
| `* Re: is there a better way to code this ?p.kinsler
|  +- Re: is there a better way to code this ?Lynn McGuire
|  +* Re: is there a better way to code this ?gah4
|  |`- Re: is there a better way to code this ?Thomas Koenig
|  `* Re: is there a better way to code this ?jfh
|   +* Re: is there a better way to code this ?gah4
|   |`- Re: is there a better way to code this ?Robin Vowels
|   `* Re: is there a better way to code this ?Ron Shepard
|    +- Re: is there a better way to code this ?pehache
|    +* Re: is there a better way to code this ?Thomas Koenig
|    |`* Re: is there a better way to code this ?Lynn McGuire
|    | `- Re: is there a better way to code this ?Thomas Koenig
|    `- Re: is there a better way to code this ?James Van Buskirk
+* Re: is there a better way to code this ?Ev. Drikos
|`* Why I can't read from a parameter string? [was: is there a better wayEv. Drikos
| `* Re: Why I can't read from a parameter string? [was: is there aThomas Koenig
|  `* Re: Why I can't read from a parameter string? [was: is there a betterEv. Drikos
|   +* Re: Why I can't read from a parameter string? [was: is there a betterEv. Drikos
|   |`* Re: Why I can't read from a parameter string? [was: is there a betterRon Shepard
|   | `* Re: Why I can't read from a parameter string? [was: is there a bettergah4
|   |  `- Re: Why I can't read from a parameter string? [was: is there a better way to codPhillip Helbig (undress to reply
|   `- Re: Why I can't read from a parameter string? [was: is there aThomas Koenig
`* Re: is there a better way to code this ?Robin Vowels
 `* Re: is there a better way to code this ?John
  +* Re: is there a better way to code this ?Robin Vowels
  |`* Re: is there a better way to code this ?Lynn McGuire
  | `* Re: is there a better way to code this ?Robin Vowels
  |  `* Re: is there a better way to code this ?Lynn McGuire
  |   `- Re: is there a better way to code this ?gah4
  `* Re: is there a better way to code this ?David Jones
   `- Re: is there a better way to code this ?Lynn McGuire

Pages:12
Re: Why I can't read from a parameter string? [was: is there a better way to code this ?]

<t8mtc6$16ku$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!lfsn+8Y8XPk4JuCDnArrSA.user.46.165.242.91.POSTED!not-for-mail
From: drikosev@gmail.com (Ev. Drikos)
Newsgroups: comp.lang.fortran
Subject: Re: Why I can't read from a parameter string? [was: is there a better
way to code this ?]
Date: Sun, 19 Jun 2022 13:21:58 +0300
Organization: Aioe.org NNTP Server
Message-ID: <t8mtc6$16ku$1@gioia.aioe.org>
References: <t85qc4$kr5$1@dont-email.me> <t8caqt$5so$1@gioia.aioe.org>
<t8msda$q4d$1@gioia.aioe.org> <t8msqs$4tn$1@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="39582"; posting-host="lfsn+8Y8XPk4JuCDnArrSA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.5.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Ev. Drikos - Sun, 19 Jun 2022 10:21 UTC

On 19/06/2022 13:12, Thomas Koenig wrote:
> Ev. Drikos <drikosev@gmail.com> schrieb:
>
>> Does anybody know why there is such a restriction?
>>
>>
>> ----------------------------------------------
>> $ gfc --version 2>&1 | head -n1
>> GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222
>> (Red Hat Linux 3.2.2-5)
>
> Without looking at the code: g77 has not been maintained for a really
> long time, and it only implements f77 + some extensions. I would not
> be surprised by any restrictions of anything f90-like or later.
>

Thanks for the feedback, the OP discussed F77. In this case version 8
issues a similar error as well:

$ gfortran8 -ffixed-form icep.f
icep.f:20:11:

read(goes(icep:icep),*) nn
1
Error: UNIT specification at (1) must be an INTEGER expression or a
CHARACTER variable

Re: Why I can't read from a parameter string? [was: is there a better way to code this ?]

<t8n9hh$19n$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!lfsn+8Y8XPk4JuCDnArrSA.user.46.165.242.91.POSTED!not-for-mail
From: drikosev@gmail.com (Ev. Drikos)
Newsgroups: comp.lang.fortran
Subject: Re: Why I can't read from a parameter string? [was: is there a better
way to code this ?]
Date: Sun, 19 Jun 2022 16:49:37 +0300
Organization: Aioe.org NNTP Server
Message-ID: <t8n9hh$19n$1@gioia.aioe.org>
References: <t85qc4$kr5$1@dont-email.me> <t8caqt$5so$1@gioia.aioe.org>
<t8msda$q4d$1@gioia.aioe.org> <t8msqs$4tn$1@newsreader4.netcologne.de>
<t8mtc6$16ku$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="1335"; posting-host="lfsn+8Y8XPk4JuCDnArrSA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.5.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
X-Mozilla-News-Host: news://news.aioe.org
 by: Ev. Drikos - Sun, 19 Jun 2022 13:49 UTC

On 19/06/2022 13:21, Ev. Drikos wrote:
> ...
>
> $ gfortran8 -ffixed-form icep.f
> icep.f:20:11:
>
>        read(goes(icep:icep),*) nn
>            1
> Error: UNIT specification at (1) must be an INTEGER expression or a
> CHARACTER variable
>

Ok, an extra assignment to a variable could solve this issue, ie:

ch = go(icep:icep) !an extra assignment to a variable
read(ch, *) nn
goto(10,11) nn

Due to the fixed form format, the example is readable in my gists:
https://gist.github.com/drikosev/7f24acb6435f441d5d6f7be220efdbe9

Yet, the question remains open. Is it perhaps a compiler specific bug
or a standard restriction?

Re: Why I can't read from a parameter string? [was: is there a better way to code this ?]

<t8nb60$c5f$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!news.freedyn.de!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-3fa9-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: Why I can't read from a parameter string? [was: is there a
better way to code this ?]
Date: Sun, 19 Jun 2022 14:17:36 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <t8nb60$c5f$1@newsreader4.netcologne.de>
References: <t85qc4$kr5$1@dont-email.me> <t8caqt$5so$1@gioia.aioe.org>
<t8msda$q4d$1@gioia.aioe.org> <t8msqs$4tn$1@newsreader4.netcologne.de>
<t8mtc6$16ku$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 19 Jun 2022 14:17:36 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-3fa9-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:3fa9:0:7285:c2ff:fe6c:992d";
logging-data="12463"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 19 Jun 2022 14:17 UTC

Ev. Drikos <drikosev@gmail.com> schrieb:
> On 19/06/2022 13:12, Thomas Koenig wrote:
>> Ev. Drikos <drikosev@gmail.com> schrieb:
>>
>>> Does anybody know why there is such a restriction?
>>>
>>>
>>> ----------------------------------------------
>>> $ gfc --version 2>&1 | head -n1
>>> GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222
>>> (Red Hat Linux 3.2.2-5)
>>
>> Without looking at the code: g77 has not been maintained for a really
>> long time, and it only implements f77 + some extensions. I would not
>> be surprised by any restrictions of anything f90-like or later.
>>
>
> Thanks for the feedback, the OP discussed F77. In this case version 8
> issues a similar error as well:
>
> $ gfortran8 -ffixed-form icep.f
> icep.f:20:11:
>
> read(goes(icep:icep),*) nn
> 1
> Error: UNIT specification at (1) must be an INTEGER expression or a
> CHARACTER variable

OK.

A look at the F2018 standard tells us, in 12.4, "Internal Files":

An internal file is a record file with the following properties.

• The file is a variable of default, ASCII, or ISO 10646 character
kind that is not an array section with a vector subscript.

and a bit further down

R1201 io-unit is file-unit-number
or *
or internal-file-variable

R1203 internal-file-variable is char-variable

and further up

R905 char-variable is variable
C905 (R905) char-variable shall be of type character.

and finally

R903 variable-name is name
C903 (R903) variable-name shall be the name of a variable.

And if anybody wonders what a variable is, it's defined in

3.154 variable
data entity that can be defined and redefined during execution of a program

So, since a parameter cannot be redefined during execution, using
an internal I/O statement on it is an error, and the processor
needs to be able to diagnose it.

Re: Why I can't read from a parameter string? [was: is there a better way to code this ?]

<qHGrK.2008$iR.1684@fx44.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx44.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0)
Gecko/20100101 Thunderbird/91.10.0
Subject: Re: Why I can't read from a parameter string? [was: is there a better
way to code this ?]
Content-Language: en-US
Newsgroups: comp.lang.fortran
References: <t85qc4$kr5$1@dont-email.me> <t8caqt$5so$1@gioia.aioe.org>
<t8msda$q4d$1@gioia.aioe.org> <t8msqs$4tn$1@newsreader4.netcologne.de>
<t8mtc6$16ku$1@gioia.aioe.org> <t8n9hh$19n$1@gioia.aioe.org>
From: nospam@nowhere.org (Ron Shepard)
In-Reply-To: <t8n9hh$19n$1@gioia.aioe.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 48
Message-ID: <qHGrK.2008$iR.1684@fx44.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: Sun, 19 Jun 2022 09:48:53 -0500
X-Received-Bytes: 2881
 by: Ron Shepard - Sun, 19 Jun 2022 14:48 UTC

On 6/19/22 8:49 AM, Ev. Drikos wrote:
> On 19/06/2022 13:21, Ev. Drikos wrote:
>> ...
>>
>> $ gfortran8 -ffixed-form icep.f
>> icep.f:20:11:
>>
>>         read(goes(icep:icep),*) nn
>>             1
>> Error: UNIT specification at (1) must be an INTEGER expression or a
>> CHARACTER variable
>>
>
> Ok, an extra assignment to a variable could solve this issue, ie:
>
>  ch = go(icep:icep) !an extra assignment to a variable
>  read(ch, *) nn
>  goto(10,11) nn
>
> Due to the fixed form format, the example is readable in my gists:
> https://gist.github.com/drikosev/7f24acb6435f441d5d6f7be220efdbe9
>
> Yet, the question remains open. Is it perhaps a compiler specific bug
> or a standard restriction?

It is a standard restriction in f77. I remember similar situations many
times in the 1980s.

12.2.5.1 Internal File Properties. An internal file has the following
properties:
(1) The file is a character variable, character array element, character
array, or character substring.

Most compiler writers interpreted that to mean that it could not be
either a literal or a parameter constant. I seem to recall there were
some exceptions, but I always took those exceptions as extensions to the
standard, so if portability was important, I avoided using parameters or
literal constants as internal files.

To be portable, you need to do the assignment, or you need to declare
goes(*) as a variable rather than a parameter. I never understood why
the limitation was in the standard. In my codes, I usually left a
comment explaining why the code was written that way so that I would not
change it a month later by mistake. That comment was, of course, a
separate line beginning with C or *, it was not on the same line. F77
was so limited in so many ways.

$.02 -Ron Shepard

Re: Why I can't read from a parameter string? [was: is there a better way to code this ?]

<66596868-5be6-48c3-8120-73977567ac22n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a5d:6484:0:b0:219:eb95:3502 with SMTP id o4-20020a5d6484000000b00219eb953502mr24944666wri.692.1655767469241;
Mon, 20 Jun 2022 16:24:29 -0700 (PDT)
X-Received: by 2002:a25:c241:0:b0:668:a6b1:5606 with SMTP id
s62-20020a25c241000000b00668a6b15606mr24793612ybf.273.1655767468813; Mon, 20
Jun 2022 16:24:28 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.128.88.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Mon, 20 Jun 2022 16:24:28 -0700 (PDT)
In-Reply-To: <qHGrK.2008$iR.1684@fx44.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:3892:d083:e2ae:3f7a;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:3892:d083:e2ae:3f7a
References: <t85qc4$kr5$1@dont-email.me> <t8caqt$5so$1@gioia.aioe.org>
<t8msda$q4d$1@gioia.aioe.org> <t8msqs$4tn$1@newsreader4.netcologne.de>
<t8mtc6$16ku$1@gioia.aioe.org> <t8n9hh$19n$1@gioia.aioe.org> <qHGrK.2008$iR.1684@fx44.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <66596868-5be6-48c3-8120-73977567ac22n@googlegroups.com>
Subject: Re: Why I can't read from a parameter string? [was: is there a better
way to code this ?]
From: gah4@u.washington.edu (gah4)
Injection-Date: Mon, 20 Jun 2022 23:24:29 +0000
Content-Type: text/plain; charset="UTF-8"
 by: gah4 - Mon, 20 Jun 2022 23:24 UTC

On Sunday, June 19, 2022 at 7:48:57 AM UTC-7, Ron Shepard wrote:

(snip)

> It is a standard restriction in f77. I remember similar situations many
> times in the 1980s.

There were some strange restrictions in Fortran 66, some of which
were removed in Fortran 77.

The I/O list of READ and WRITE statements contains variables (and arrays)
but not constants or expressions. That is obvious for READ, but not
for WRITE.

I believe at the time, actually using WATFIV before 1977, that expressions
in the I/O list of WRITE statements was my favorite new feature.

In Fortran 66, the format part of a READ/WRITE statement is either a
statement number (of a FORMAT statement) or an array with a run-time
format, character data read in A format, or initialized in DATA statements.

Even if it fit i a scalar, it was required to be an array.

Fortran 77 added internal I/O, putting a character variable in place
of the unit number. There are some not so obvious restrictions on it,
but similar to above, can't be a constant.

And now, so many years later, we wonder why.

Re: Why I can't read from a parameter string? [was: is there a better way to code this ?]

<t8s73m$q4a$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!SsQ9R6/+Je+mewmUvumc7g.user.46.165.242.75.POSTED!not-for-mail
From: helbig@asclothestro.multivax.de (Phillip Helbig (undress to reply)
Newsgroups: comp.lang.fortran
Subject: Re: Why I can't read from a parameter string? [was: is there a better way to code this ?]
Date: Tue, 21 Jun 2022 10:38:46 -0000 (UTC)
Organization: Multivax C&R
Message-ID: <t8s73m$q4a$1@gioia.aioe.org>
References: <t85qc4$kr5$1@dont-email.me> <t8caqt$5so$1@gioia.aioe.org> <t8msda$q4d$1@gioia.aioe.org> <t8msqs$4tn$1@newsreader4.netcologne.de> <t8mtc6$16ku$1@gioia.aioe.org> <t8n9hh$19n$1@gioia.aioe.org> <qHGrK.2008$iR.1684@fx44.iad> <66596868-5be6-48c3-8120-73977567ac22n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="26762"; posting-host="SsQ9R6/+Je+mewmUvumc7g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
 by: Phillip Helbig (undr - Tue, 21 Jun 2022 10:38 UTC

In article <66596868-5be6-48c3-8120-73977567ac22n@googlegroups.com>,
gah4 <gah4@u.washington.edu> writes:

> The I/O list of READ and WRITE statements contains variables (and arrays)
> but not constants or expressions. That is obvious for READ, but not
> for WRITE.

Vice versa?

Re: is there a better way to code this ?

<6c0cd7a7-c4d1-4ee8-b155-c760ea07ef49n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6000:1686:b0:21b:9870:47b with SMTP id y6-20020a056000168600b0021b9870047bmr2739069wrd.687.1655814516568;
Tue, 21 Jun 2022 05:28:36 -0700 (PDT)
X-Received: by 2002:a25:41c5:0:b0:668:acc0:5bfd with SMTP id
o188-20020a2541c5000000b00668acc05bfdmr26577207yba.540.1655814516120; Tue, 21
Jun 2022 05:28:36 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!feeder1.cambriumusenet.nl!feed.tweak.nl!209.85.128.88.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 21 Jun 2022 05:28:35 -0700 (PDT)
In-Reply-To: <t8ans4$dnt$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=202.67.103.232; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le
NNTP-Posting-Host: 202.67.103.232
References: <t85qc4$kr5$1@dont-email.me> <375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t886bm$8cq$1@dont-email.me> <cc837c3c-554e-4bf2-91fc-e7879992070dn@googlegroups.com>
<t88h8a$r78$1@dont-email.me> <44bb0892-1c9e-49a1-997a-1adb1068eb77n@googlegroups.com>
<t8ans4$dnt$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6c0cd7a7-c4d1-4ee8-b155-c760ea07ef49n@googlegroups.com>
Subject: Re: is there a better way to code this ?
From: robin.vowels@gmail.com (Robin Vowels)
Injection-Date: Tue, 21 Jun 2022 12:28:36 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2219
 by: Robin Vowels - Tue, 21 Jun 2022 12:28 UTC

On Wednesday, June 15, 2022 at 5:34:32 AM UTC+10, Lynn McGuire wrote:
> On 6/13/2022 7:19 PM, gah4 wrote:
> > On Monday, June 13, 2022 at 4:29:18 PM UTC-7, Lynn McGuire wrote:
> >
> > (snip)
> >
> >>> Depends on what you mean by regular Fortran. In f2003 and later the limit is 255, but in f95 it's 39 in free form, 19 in fixed form.
> >> I meant Standard Fortran.
> >
> > 66, 77, 90, 95, 2008, 2013, or 2018?
> >
> > There is a famous quote:
> >
> > "The nice thing about standards is that we have so many to choose from."
> Heh.
>
> F77 apparently allowed 19 continuation lines.
..
The standard required a minimum of 19 continuation lines.
..
> Open Watcom Fortran 77 is
> extended to allow up to 61 continuation lines.
..
Any compiler can exceed the minimum of 19.

Re: is there a better way to code this ?

<58d35712-fdaa-4461-b684-d3ead6115291n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6000:993:b0:21b:8f16:5b3f with SMTP id by19-20020a056000099300b0021b8f165b3fmr10278286wrb.628.1655815580416;
Tue, 21 Jun 2022 05:46:20 -0700 (PDT)
X-Received: by 2002:a25:3457:0:b0:669:4ae3:31b0 with SMTP id
b84-20020a253457000000b006694ae331b0mr4944496yba.499.1655815579805; Tue, 21
Jun 2022 05:46:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.128.87.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 21 Jun 2022 05:46:19 -0700 (PDT)
In-Reply-To: <t8lb5n$igi$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=202.67.103.232; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le
NNTP-Posting-Host: 202.67.103.232
References: <t85qc4$kr5$1@dont-email.me> <46693e8b-7193-4338-847e-da37f2228f21n@googlegroups.com>
<85a1b6f7-2d9d-4cdd-a904-752c641ad8f4n@googlegroups.com> <756de836-a72b-45f4-8c66-9964fa732c8cn@googlegroups.com>
<t8lb5n$igi$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <58d35712-fdaa-4461-b684-d3ead6115291n@googlegroups.com>
Subject: Re: is there a better way to code this ?
From: robin.vowels@gmail.com (Robin Vowels)
Injection-Date: Tue, 21 Jun 2022 12:46:20 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Robin Vowels - Tue, 21 Jun 2022 12:46 UTC

On Sunday, June 19, 2022 at 6:05:16 AM UTC+10, Lynn McGuire wrote:
> On 6/17/2022 2:43 AM, Robin Vowels wrote:
> > On Thursday, June 16, 2022 at 2:33:44 PM UTC+10, John wrote:
> >> Well, for the first one for maintainability (and not wanting to even mention ASSIGN statements) and primarily for human intelligibility I might go with a way that worked even pre-f90;. It would probably be more efficient if populated with logicals but this format has a few advantages when a human has to manually
> >> maintain the information
> > .
> > GO TO LAB(NN);
> > is still simpler in PL/I.
> > .
> >> program testit
> >> implicit none
> >> integer :: nn
> >> integer,parameter :: EQUALS(*)=[&
> >> +1, -2, -3, +4, +5, -6, -7, -8, +9, -10, &
> >> +11, -12, -13, +14, +15, +16, +17, -18, -19, -20, &
> >> +21, +22, +23, +24, -25, +26, -27, -28, -29, -30, &
> >> -31, +32, -33, -34, -35, -36, -37, -38, -39, -40, &
> >> +41, +42, +43, +44, -45, +46, -47, -48, -49, -50, &
> >> +51, +52, -53, -54, +55, -56, -57, +58, -59, -60, &
> >> +61, -62, +63, -64, -65, -66, +67, +68, -69, +70, &
> >> -71, -72, +73, -74, -75, -76, -77, -78, -79, -80, &
> >> -81, -82, +83, +84, -85, -86, -87, -88, -89, +90, &
> >> +91, +92, +93, -94, -95, -96, +97, +98, -99, -100, &
> >> -101, +102, +103, +104, -105, -106, -107, +108, +109, +110, &
> >> +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, &
> >> +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, &
> >> -131, -132, -133, +134, +135, +136, +137, +138, +139, +140, &
> >> +141, -142, -143, -144, -145, -146, +147, -148, -149, -150, &
> >> +151, -152, -153, -154, -155, -156, -157, -158, -159, +160, &
> >> -161, -162, -163, +164, -165, -166, +167, +168, +169, +170, &
> >> +171, +172, +173, -174, +175, -176, -177, -178, +179, -180, &
> >> -181, -182, -183, -184, +185, +186, +187, +188, +189, +190, &
> >> -191, -192, -193, +194, -195, -196, -197, -198, -199, +200, &
> >> -201, +202, -203, -204, -205, -206, +207, -208, -209, -210, &
> >> +211, +212, -213, -214, +215, -216, -217, -218, -219, +220, &
> >> +221, +222, +223, -224, +225, +226, +227, +228, -229, -230, &
> >> -231, -232, -233, -234, -235, +236, -237, +238, +239, +240, &
> >> -241, -242, -243, -244, +245, -246, -247, -248, +249, -250, &
> >> -251, +252, +253, +254, -255, -256, -257, -258, -259, -260, &
> >> -261, -262, -263, -264, -265, -266, -267, -268, -269, -270, &
> >> -271, -272, -273, +274, -275, +276, -277, +278, +279, +280, &
> >> +281, +282, -283, -284, +285, -286, -287, -288, +289, -290, &
> >> -291, -292, -293, +294, +295, +296, +297, +298, +299, +300, &
> >> -301, -302, -303, -304, -305, -306, -307, -308, -309, -310, &
> >> -311, -312, -313, -314, -315, +316, +317, +318, +319, +320, &
> >> +321, +322, +323, +324, +325, +326, +327, +328, -329, -330, &
> >> +331, +332, -333, -334, -335, -336, +337, +338, +339, +340, &
> >> -341, -342, -343, -344, +345, -346, -347, -348, +349, +350]
> >> ! CHECK THE COMMANDS WHICH SHOULD HAVE EQUAL SIGN
> >> ! + no equal sign required
> >> ! - equal sign required
> >> write(*,*)size(equals)==350
> >> do nn=1,size(equals)
> >> if(equals(nn)>0)then
> >> write(*,*)nn,'equal sign required'
> >> else
> >> write(*,*)nn,'equal sign not required'
> >> endif
> >> enddo
> >> end program testit
..
> So ? We are not talking about PL/I.
..
Several languages have already been discussed in this thread, including PL/I.
..
PL/I can considerably shorten F77 code.
This instance, where a trivial PL/I statement can replace some 30-40 lines of F77,
might be worthy of further examination.

Re: is there a better way to code this ?

<t8sgr0$16ie$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!/Adh2v7LvPPHwMhGJ8JsiA.user.46.165.242.91.POSTED!not-for-mail
From: dajhawkxx@nowherel.com (David Jones)
Newsgroups: comp.lang.fortran
Subject: Re: is there a better way to code this ?
Date: Tue, 21 Jun 2022 13:24:49 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <t8sgr0$16ie$1@gioia.aioe.org>
References: <t85qc4$kr5$1@dont-email.me> <46693e8b-7193-4338-847e-da37f2228f21n@googlegroups.com> <85a1b6f7-2d9d-4cdd-a904-752c641ad8f4n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="39502"; posting-host="/Adh2v7LvPPHwMhGJ8JsiA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: XanaNews/1.21-f3fb89f (x86; Portable ISpell)
X-Notice: Filtered by postfilter v. 0.9.2
 by: David Jones - Tue, 21 Jun 2022 13:24 UTC

John wrote:

> Well, for the first one for maintainability (and not wanting to even
> mention ASSIGN statements) and primarily for human intelligibility I
> might go with a way that worked even pre-f90;.

I don't think we were told enough about the context of all this. If
this bit of code is gone through often in a single execution, it may
well be worth doing some initialisation computations that can sort out
both maintainability and readability as well as overall speed of
execution. One could start with several lists of items of different
types, such as could be extended easily as necessary, and then go
through these lists automatically (once-only) to construct sufficient
cross-referencing etc. so that you can readily know what needs to be
done whenever a decision is needed.

Re: is there a better way to code this ?

<t8tl5e$d1q$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.fortran
Subject: Re: is there a better way to code this ?
Date: Tue, 21 Jun 2022 18:44:46 -0500
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <t8tl5e$d1q$1@dont-email.me>
References: <t85qc4$kr5$1@dont-email.me>
<46693e8b-7193-4338-847e-da37f2228f21n@googlegroups.com>
<85a1b6f7-2d9d-4cdd-a904-752c641ad8f4n@googlegroups.com>
<756de836-a72b-45f4-8c66-9964fa732c8cn@googlegroups.com>
<t8lb5n$igi$1@dont-email.me>
<58d35712-fdaa-4461-b684-d3ead6115291n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 21 Jun 2022 23:44:47 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="643fe03d9fbb9091101d148b09f8d6d6";
logging-data="13370"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kB07AfaJBy2+CHEDKLdyM"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.10.0
Cancel-Lock: sha1:mvjg2ZECQnpCnlvlWZ5wzCa6yM8=
In-Reply-To: <58d35712-fdaa-4461-b684-d3ead6115291n@googlegroups.com>
Content-Language: en-US
 by: Lynn McGuire - Tue, 21 Jun 2022 23:44 UTC

On 6/21/2022 7:46 AM, Robin Vowels wrote:
> On Sunday, June 19, 2022 at 6:05:16 AM UTC+10, Lynn McGuire wrote:
>> On 6/17/2022 2:43 AM, Robin Vowels wrote:
>>> On Thursday, June 16, 2022 at 2:33:44 PM UTC+10, John wrote:
>>>> Well, for the first one for maintainability (and not wanting to even mention ASSIGN statements) and primarily for human intelligibility I might go with a way that worked even pre-f90;. It would probably be more efficient if populated with logicals but this format has a few advantages when a human has to manually
>>>> maintain the information
>>> .
>>> GO TO LAB(NN);
>>> is still simpler in PL/I.
>>> .
>>>> program testit
>>>> implicit none
>>>> integer :: nn
>>>> integer,parameter :: EQUALS(*)=[&
>>>> +1, -2, -3, +4, +5, -6, -7, -8, +9, -10, &
>>>> +11, -12, -13, +14, +15, +16, +17, -18, -19, -20, &
>>>> +21, +22, +23, +24, -25, +26, -27, -28, -29, -30, &
>>>> -31, +32, -33, -34, -35, -36, -37, -38, -39, -40, &
>>>> +41, +42, +43, +44, -45, +46, -47, -48, -49, -50, &
>>>> +51, +52, -53, -54, +55, -56, -57, +58, -59, -60, &
>>>> +61, -62, +63, -64, -65, -66, +67, +68, -69, +70, &
>>>> -71, -72, +73, -74, -75, -76, -77, -78, -79, -80, &
>>>> -81, -82, +83, +84, -85, -86, -87, -88, -89, +90, &
>>>> +91, +92, +93, -94, -95, -96, +97, +98, -99, -100, &
>>>> -101, +102, +103, +104, -105, -106, -107, +108, +109, +110, &
>>>> +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, &
>>>> +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, &
>>>> -131, -132, -133, +134, +135, +136, +137, +138, +139, +140, &
>>>> +141, -142, -143, -144, -145, -146, +147, -148, -149, -150, &
>>>> +151, -152, -153, -154, -155, -156, -157, -158, -159, +160, &
>>>> -161, -162, -163, +164, -165, -166, +167, +168, +169, +170, &
>>>> +171, +172, +173, -174, +175, -176, -177, -178, +179, -180, &
>>>> -181, -182, -183, -184, +185, +186, +187, +188, +189, +190, &
>>>> -191, -192, -193, +194, -195, -196, -197, -198, -199, +200, &
>>>> -201, +202, -203, -204, -205, -206, +207, -208, -209, -210, &
>>>> +211, +212, -213, -214, +215, -216, -217, -218, -219, +220, &
>>>> +221, +222, +223, -224, +225, +226, +227, +228, -229, -230, &
>>>> -231, -232, -233, -234, -235, +236, -237, +238, +239, +240, &
>>>> -241, -242, -243, -244, +245, -246, -247, -248, +249, -250, &
>>>> -251, +252, +253, +254, -255, -256, -257, -258, -259, -260, &
>>>> -261, -262, -263, -264, -265, -266, -267, -268, -269, -270, &
>>>> -271, -272, -273, +274, -275, +276, -277, +278, +279, +280, &
>>>> +281, +282, -283, -284, +285, -286, -287, -288, +289, -290, &
>>>> -291, -292, -293, +294, +295, +296, +297, +298, +299, +300, &
>>>> -301, -302, -303, -304, -305, -306, -307, -308, -309, -310, &
>>>> -311, -312, -313, -314, -315, +316, +317, +318, +319, +320, &
>>>> +321, +322, +323, +324, +325, +326, +327, +328, -329, -330, &
>>>> +331, +332, -333, -334, -335, -336, +337, +338, +339, +340, &
>>>> -341, -342, -343, -344, +345, -346, -347, -348, +349, +350]
>>>> ! CHECK THE COMMANDS WHICH SHOULD HAVE EQUAL SIGN
>>>> ! + no equal sign required
>>>> ! - equal sign required
>>>> write(*,*)size(equals)==350
>>>> do nn=1,size(equals)
>>>> if(equals(nn)>0)then
>>>> write(*,*)nn,'equal sign required'
>>>> else
>>>> write(*,*)nn,'equal sign not required'
>>>> endif
>>>> enddo
>>>> end program testit
> .
>> So ? We are not talking about PL/I.
> .
> Several languages have already been discussed in this thread, including PL/I.
> .
> PL/I can considerably shorten F77 code.
> This instance, where a trivial PL/I statement can replace some 30-40 lines of F77,
> might be worthy of further examination.

In this case, the software program is 850,000 lines of F77, C and C++.
90% currently F77. Adding anything PL/1 is simply not an option.

Lynn

Re: is there a better way to code this ?

<t8tl99$d1q$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.fortran
Subject: Re: is there a better way to code this ?
Date: Tue, 21 Jun 2022 18:46:48 -0500
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <t8tl99$d1q$2@dont-email.me>
References: <t85qc4$kr5$1@dont-email.me>
<46693e8b-7193-4338-847e-da37f2228f21n@googlegroups.com>
<85a1b6f7-2d9d-4cdd-a904-752c641ad8f4n@googlegroups.com>
<t8sgr0$16ie$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 21 Jun 2022 23:46:49 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="643fe03d9fbb9091101d148b09f8d6d6";
logging-data="13370"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lN5V+QbyCaSKFYLXdvDZ/"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.10.0
Cancel-Lock: sha1:KP8/3RiJk2l83tbvG01asfWjNZ0=
In-Reply-To: <t8sgr0$16ie$1@gioia.aioe.org>
Content-Language: en-US
 by: Lynn McGuire - Tue, 21 Jun 2022 23:46 UTC

On 6/21/2022 8:24 AM, David Jones wrote:
> John wrote:
>
>> Well, for the first one for maintainability (and not wanting to even
>> mention ASSIGN statements) and primarily for human intelligibility I
>> might go with a way that worked even pre-f90;.
>
> I don't think we were told enough about the context of all this. If
> this bit of code is gone through often in a single execution, it may
> well be worth doing some initialisation computations that can sort out
> both maintainability and readability as well as overall speed of
> execution. One could start with several lists of items of different
> types, such as could be extended easily as necessary, and then go
> through these lists automatically (once-only) to construct sufficient
> cross-referencing etc. so that you can readily know what needs to be
> done whenever a decision is needed.

This code is used in initialization during the processing of the input
commands for the model. There can be thousands of input commands.

I am planning on converting this code from F77 to C++ some day and
wondering how this code will move across.

Lynn

Re: is there a better way to code this ?

<2915abe0-1b33-4423-a447-7d3e63f62027n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a5d:5c03:0:b0:21b:90e6:42bc with SMTP id cc3-20020a5d5c03000000b0021b90e642bcmr722251wrb.36.1655860903163;
Tue, 21 Jun 2022 18:21:43 -0700 (PDT)
X-Received: by 2002:a25:cad5:0:b0:668:b012:88c0 with SMTP id
a204-20020a25cad5000000b00668b01288c0mr1028185ybg.633.1655860902519; Tue, 21
Jun 2022 18:21:42 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.128.88.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 21 Jun 2022 18:21:42 -0700 (PDT)
In-Reply-To: <t8tl5e$d1q$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:65c1:d5a5:3cba:64c6;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:65c1:d5a5:3cba:64c6
References: <t85qc4$kr5$1@dont-email.me> <46693e8b-7193-4338-847e-da37f2228f21n@googlegroups.com>
<85a1b6f7-2d9d-4cdd-a904-752c641ad8f4n@googlegroups.com> <756de836-a72b-45f4-8c66-9964fa732c8cn@googlegroups.com>
<t8lb5n$igi$1@dont-email.me> <58d35712-fdaa-4461-b684-d3ead6115291n@googlegroups.com>
<t8tl5e$d1q$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2915abe0-1b33-4423-a447-7d3e63f62027n@googlegroups.com>
Subject: Re: is there a better way to code this ?
From: gah4@u.washington.edu (gah4)
Injection-Date: Wed, 22 Jun 2022 01:21:43 +0000
Content-Type: text/plain; charset="UTF-8"
 by: gah4 - Wed, 22 Jun 2022 01:21 UTC

On Tuesday, June 21, 2022 at 4:44:51 PM UTC-7, Lynn McGuire wrote:

(snip)
> In this case, the software program is 850,000 lines of F77, C and C++.
> 90% currently F77. Adding anything PL/1 is simply not an option.

PL/I has statement label variables, which in some cases make for
nicer or smaller code. For this problem, that doesn't help much.

One thing is that PL/I statement labels are alphanumeric,
(with initial letter) like variable names. Sometimes that makes
them more readable, if you give mnemonic names. If ...

It seems that Pascal uses numeric labels to discourage their use.
The WEB system used to write TeX has macros to give them names.

If it helped, you could use a macro system to rename your numeric
labels for readability. You might find that other parts could be made
more readable, too.

Re: is there a better way to code this ?

<fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!1hUlkmAkXAZvySabFRo6yw.user.46.165.242.75.POSTED!not-for-mail
From: p.kinsler@ic.ac.uk
Newsgroups: comp.lang.fortran
Subject: Re: is there a better way to code this ?
Date: Tue, 12 Jul 2022 18:49:35 +0100
Organization: Aioe.org NNTP Server
Message-ID: <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
References: <t85qc4$kr5$1@dont-email.me> <375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com> <t8lbg1$ldi$1@dont-email.me>
Injection-Info: gioia.aioe.org; logging-data="53116"; posting-host="1hUlkmAkXAZvySabFRo6yw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.2.1-20140504 ("Tober an Righ") (UNIX) (Linux/4.4.118 (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: p.kinsler@ic.ac.uk - Tue, 12 Jul 2022 17:49 UTC

Lynn McGuire <lynnmcguire5@gmail.com> wrote:
> One of my favorite things about C++ is that I can declare variables all
> over the place. With an average of 2,000 lines of code per subroutine,
> it would be nice to locate the variable declarations at their usage.

I did that once with some C ... and it then ran about
ten times slower :-/

#Paul

Re: is there a better way to code this ?

<takg4t$240fl$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.fortran
Subject: Re: is there a better way to code this ?
Date: Tue, 12 Jul 2022 13:56:27 -0500
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <takg4t$240fl$2@dont-email.me>
References: <t85qc4$kr5$1@dont-email.me>
<375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 12 Jul 2022 18:56:29 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="f61311964b42172b7910bb5579d249eb";
logging-data="2228725"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oShT3646MRxPMlCVakAWo"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.0.1
Cancel-Lock: sha1:vVzWwTPpTuc4rugJ8aRwWo55mL8=
In-Reply-To: <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
Content-Language: en-US
 by: Lynn McGuire - Tue, 12 Jul 2022 18:56 UTC

On 7/12/2022 12:49 PM, p.kinsler@ic.ac.uk wrote:
> Lynn McGuire <lynnmcguire5@gmail.com> wrote:
>> One of my favorite things about C++ is that I can declare variables all
>> over the place. With an average of 2,000 lines of code per subroutine,
>> it would be nice to locate the variable declarations at their usage.
>
> I did that once with some C ... and it then ran about
> ten times slower :-/
>
> #Paul

That makes no sense whatsoever. I do not see that behavior in my
450,000 line C++ Windows user interface program.

Lynn

Re: is there a better way to code this ?

<3ab1b04f-f0c4-4cae-95d9-e65a691f9c91n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:5cc5:0:b0:31e:c45f:59c4 with SMTP id s5-20020ac85cc5000000b0031ec45f59c4mr2410781qta.187.1657652709034;
Tue, 12 Jul 2022 12:05:09 -0700 (PDT)
X-Received: by 2002:a81:8841:0:b0:31d:a90f:73e2 with SMTP id
y62-20020a818841000000b0031da90f73e2mr3780055ywf.54.1657652708656; Tue, 12
Jul 2022 12:05:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 12 Jul 2022 12:05:08 -0700 (PDT)
In-Reply-To: <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:5529:7313:e91b:865c;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:5529:7313:e91b:865c
References: <t85qc4$kr5$1@dont-email.me> <375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3ab1b04f-f0c4-4cae-95d9-e65a691f9c91n@googlegroups.com>
Subject: Re: is there a better way to code this ?
From: gah4@u.washington.edu (gah4)
Injection-Date: Tue, 12 Jul 2022 19:05:09 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 16
 by: gah4 - Tue, 12 Jul 2022 19:05 UTC

On Tuesday, July 12, 2022 at 10:54:05 AM UTC-7, p.ki...@ic.ac.uk wrote:
> Lynn McGuire <lynnmc...@gmail.com> wrote:
> > One of my favorite things about C++ is that I can declare variables all
> > over the place. With an average of 2,000 lines of code per subroutine,
> > it would be nice to locate the variable declarations at their usage.

> I did that once with some C ... and it then ran about
> ten times slower :-/
As well as I know it for C, I am less sure for C++, the allocation is the
same, independent of where the declarations are. It should not change
run time behavior.

I suppose that some optimizers might work different, depending on
such declarations, though that shouldn't actually happen.

Automatic variables are allocated on function entry.

Re: is there a better way to code this ?

<takjgd$esp$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!rocksolid2!i2pn.org!usenet.goja.nl.eu.org!news.freedyn.de!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd6-3a42-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: is there a better way to code this ?
Date: Tue, 12 Jul 2022 19:53:49 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <takjgd$esp$1@newsreader4.netcologne.de>
References: <t85qc4$kr5$1@dont-email.me>
<375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
<3ab1b04f-f0c4-4cae-95d9-e65a691f9c91n@googlegroups.com>
Injection-Date: Tue, 12 Jul 2022 19:53:49 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd6-3a42-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd6:3a42:0:7285:c2ff:fe6c:992d";
logging-data="15257"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Tue, 12 Jul 2022 19:53 UTC

gah4 <gah4@u.washington.edu> schrieb:
> On Tuesday, July 12, 2022 at 10:54:05 AM UTC-7, p.ki...@ic.ac.uk wrote:
>> Lynn McGuire <lynnmc...@gmail.com> wrote:
>> > One of my favorite things about C++ is that I can declare variables all
>> > over the place. With an average of 2,000 lines of code per subroutine,
>> > it would be nice to locate the variable declarations at their usage.
>
>> I did that once with some C ... and it then ran about
>> ten times slower :-/
>
> As well as I know it for C, I am less sure for C++, the allocation is the
> same, independent of where the declarations are. It should not change
> run time behavior.
>
> I suppose that some optimizers might work different, depending on
> such declarations, though that shouldn't actually happen.
>
> Automatic variables are allocated on function entry.

Not necessarily - there is no need to reserve a stack slot
when the value is no longer needed.

Plus, sometimes it is cheaper to recompute than to spill
and reload, but that's one of the hardest decisions to
make in compilers :-)

Re: is there a better way to code this ?

<1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:5842:0:b0:31e:b670:d1f5 with SMTP id h2-20020ac85842000000b0031eb670d1f5mr9300173qth.307.1657660511420;
Tue, 12 Jul 2022 14:15:11 -0700 (PDT)
X-Received: by 2002:a25:aaae:0:b0:66e:48de:9272 with SMTP id
t43-20020a25aaae000000b0066e48de9272mr217148ybi.523.1657660511044; Tue, 12
Jul 2022 14:15:11 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 12 Jul 2022 14:15:10 -0700 (PDT)
In-Reply-To: <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=115.189.132.234; posting-account=KnYfEgoAAAD1tUJTvdAUZ3XojNa5tezZ
NNTP-Posting-Host: 115.189.132.234
References: <t85qc4$kr5$1@dont-email.me> <375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com>
Subject: Re: is there a better way to code this ?
From: harperjf2@gmail.com (jfh)
Injection-Date: Tue, 12 Jul 2022 21:15:11 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 9
 by: jfh - Tue, 12 Jul 2022 21:15 UTC

On Wednesday, July 13, 2022 at 5:54:05 AM UTC+12, p.ki...@ic.ac.uk wrote:
> Lynn McGuire <lynnmc...@gmail.com> wrote:
> > One of my favorite things about C++ is that I can declare variables all
> > over the place. With an average of 2,000 lines of code per subroutine,
> > it would be nice to locate the variable declarations at their usage.
> I did that once with some C ... and it then ran about
> ten times slower :-/
>
> #Paul
Declaring variables where used was one of my favourite things about Algol 68, long before C++ was invented. The block construct lets you do it in Fortran too.

Re: is there a better way to code this ?

<497a35d3-13fd-4df3-b701-41044d7f801an@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:189d:b0:31e:a89b:99fd with SMTP id v29-20020a05622a189d00b0031ea89b99fdmr124438qtc.638.1657663309353;
Tue, 12 Jul 2022 15:01:49 -0700 (PDT)
X-Received: by 2002:a0d:dbc3:0:b0:31d:f1e:7e8e with SMTP id
d186-20020a0ddbc3000000b0031d0f1e7e8emr530715ywe.180.1657663309022; Tue, 12
Jul 2022 15:01:49 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Tue, 12 Jul 2022 15:01:48 -0700 (PDT)
In-Reply-To: <1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:5529:7313:e91b:865c;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:5529:7313:e91b:865c
References: <t85qc4$kr5$1@dont-email.me> <375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk> <1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <497a35d3-13fd-4df3-b701-41044d7f801an@googlegroups.com>
Subject: Re: is there a better way to code this ?
From: gah4@u.washington.edu (gah4)
Injection-Date: Tue, 12 Jul 2022 22:01:49 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 14
 by: gah4 - Tue, 12 Jul 2022 22:01 UTC

On Tuesday, July 12, 2022 at 2:15:13 PM UTC-7, jfh wrote:

(snip)

> Declaring variables where used was one of my favourite things about Algol 68, long before C++ was invented. The block construct lets you do it in Fortran too.

Different question.

Blocks in ALGOL, BEGIN blocks in PL/I, and some others in other languages, allow for allocation of automatic variables.
(PL/I has DO blocks which are only for grouping, and not allocation or scoping.)

Actually, it might have changed over different versions of C, but at least for some there is no allocation.

Re: is there a better way to code this ?

<JstzK.25578$kY1.19305@fx06.iad>

  copy mid

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

  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!fx06.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.0.1
Subject: Re: is there a better way to code this ?
Content-Language: en-US
Newsgroups: comp.lang.fortran
References: <t85qc4$kr5$1@dont-email.me>
<375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
<1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com>
From: nospam@nowhere.org (Ron Shepard)
In-Reply-To: <1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 10
Message-ID: <JstzK.25578$kY1.19305@fx06.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, 13 Jul 2022 01:18:17 -0500
X-Received-Bytes: 1488
 by: Ron Shepard - Wed, 13 Jul 2022 06:18 UTC

On 7/12/22 4:15 PM, jfh wrote:
> Declaring variables where used was one of my favourite things about Algol 68, long before C++ was invented. The block construct lets you do it in Fortran too.

How exactly does this work in fortran. If you have a block with local
variables, are they allocated afresh when the block is entered and
deallocated upon block exit, or are they just allocated once? What if
the block is within a loop?

$.02 -Ron Shepard

Re: is there a better way to code this ?

<jj7hruFltjoU1@mid.individual.net>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: pehache.7@gmail.com (pehache)
Newsgroups: comp.lang.fortran
Subject: Re: is there a better way to code this ?
Date: Wed, 13 Jul 2022 11:33:50 +0200
Lines: 30
Message-ID: <jj7hruFltjoU1@mid.individual.net>
References: <t85qc4$kr5$1@dont-email.me>
<375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
<1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com>
<JstzK.25578$kY1.19305@fx06.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net /jk+Hdoc9gDxGs8PmwHqUgSJUtB4Qat+XlD6c6GCc1GfY89aWR
Cancel-Lock: sha1:60VRakUe4ewvSCjvrCTBhZsmDZY=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0)
Gecko/20100101 Thunderbird/91.10.0
Content-Language: fr
In-Reply-To: <JstzK.25578$kY1.19305@fx06.iad>
 by: pehache - Wed, 13 Jul 2022 09:33 UTC

Le 13/07/2022 à 08:18, Ron Shepard a écrit :
> On 7/12/22 4:15 PM, jfh wrote:
>> Declaring variables where used was one of my favourite things about
>> Algol 68, long before C++ was invented. The block construct lets you
>> do it in Fortran too.
>
> How exactly does this work in fortran. If you have a block with local
> variables, are they allocated afresh when the block is entered and
> deallocated upon block exit, or are they just allocated once? What if
> the block is within a loop?
>

I haven't checked, but to me a BLOCK is similar to a contained
subroutine, with the same rules concerning the variable that are
declared locally.

If the variable is "allocatable" it is automatically deallocated upon
exit of the the block.

If the variable is "save" then the compiler statically allocates it at
compile time.

For other cases it's up to the compiler to decide between a static
allocation at compile time or an automatic allocation on the stack at
runtime.

--
"...sois ouvert aux idées des autres pour peu qu'elles aillent dans le
même sens que les tiennes.", ST sur fr.bio.medecine
ST passe le mur du çon : <j3nn2hFmqj7U1@mid.individual.net>

Re: is there a better way to code this ?

<af9fb092-8529-4a37-b563-223fcb7eaff3n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:f13:b0:6b5:b956:c1f1 with SMTP id v19-20020a05620a0f1300b006b5b956c1f1mr1611143qkl.691.1657718062906;
Wed, 13 Jul 2022 06:14:22 -0700 (PDT)
X-Received: by 2002:a05:6902:124e:b0:668:222c:e8da with SMTP id
t14-20020a056902124e00b00668222ce8damr3505262ybu.383.1657718062174; Wed, 13
Jul 2022 06:14:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.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, 13 Jul 2022 06:14:21 -0700 (PDT)
In-Reply-To: <497a35d3-13fd-4df3-b701-41044d7f801an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=202.67.103.232; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le
NNTP-Posting-Host: 202.67.103.232
References: <t85qc4$kr5$1@dont-email.me> <375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
<1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com> <497a35d3-13fd-4df3-b701-41044d7f801an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <af9fb092-8529-4a37-b563-223fcb7eaff3n@googlegroups.com>
Subject: Re: is there a better way to code this ?
From: robin.vowels@gmail.com (Robin Vowels)
Injection-Date: Wed, 13 Jul 2022 13:14:22 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1998
 by: Robin Vowels - Wed, 13 Jul 2022 13:14 UTC

On Wednesday, July 13, 2022 at 8:01:51 AM UTC+10, gah4 wrote:
> On Tuesday, July 12, 2022 at 2:15:13 PM UTC-7, jfh wrote:
>
> (snip)
> > Declaring variables where used was one of my favourite things about Algol 68, long before C++ was invented. The block construct lets you do it in Fortran too.
> Different question.
>
> Blocks in ALGOL, BEGIN blocks in PL/I,
..
and PROCEDURE blocks in PL/I

> and some others in other languages, allow for allocation of automatic variables.
> (PL/I has DO blocks which are only for grouping, and not allocation or scoping.)
..
PL/I does not have DO blocks. PL/I has DO groups.

Re: is there a better way to code this ?

<tamt6v$oav$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.freedyn.de!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd6-3a42-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: is there a better way to code this ?
Date: Wed, 13 Jul 2022 16:51:43 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <tamt6v$oav$1@newsreader4.netcologne.de>
References: <t85qc4$kr5$1@dont-email.me>
<375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
<1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com>
<JstzK.25578$kY1.19305@fx06.iad>
Injection-Date: Wed, 13 Jul 2022 16:51:43 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd6-3a42-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd6:3a42:0:7285:c2ff:fe6c:992d";
logging-data="24927"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Wed, 13 Jul 2022 16:51 UTC

Ron Shepard <nospam@nowhere.org> schrieb:
> On 7/12/22 4:15 PM, jfh wrote:
>> Declaring variables where used was one of my favourite things about Algol 68, long before C++ was invented. The block construct lets you do it in Fortran too.
>
> How exactly does this work in fortran. If you have a block with local
> variables, are they allocated afresh when the block is entered and
> deallocated upon block exit, or are they just allocated once? What if
> the block is within a loop?

The compiler will look at the lifetime of the variable and allocate
it on the stack or in a register accordingly. A modern compiler
will, when optimizing, reuse stack slots if possible, with or
without help from the programmer through BLOCK statements.

Compilers have gotten quite good :-)

Also, the intermediate form that compilers use these days,
single static assignment, makes this optimization necessary.
Basically, any assignment to any variable creates a new
variable, so something like

i = 42
j = 2
i = i + j
j = j + i

will be translated to

i_1 = 42
j_1 = 2
i_2 = i_1 + j_1
j_2 = j_1 + i_2

and the compiler will determine that i_1 is no longer
in use, and will drop it.

Anything I learned in my C-64 Basic days about re-using
variables to save space, I had to unlearn :-)

Re: is there a better way to code this ?

<tan2sb$2e2il$5@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: lynnmcguire5@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.fortran
Subject: Re: is there a better way to code this ?
Date: Wed, 13 Jul 2022 13:28:27 -0500
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <tan2sb$2e2il$5@dont-email.me>
References: <t85qc4$kr5$1@dont-email.me>
<375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
<1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com>
<JstzK.25578$kY1.19305@fx06.iad> <tamt6v$oav$1@newsreader4.netcologne.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 13 Jul 2022 18:28:27 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="9d36bd8e489fe4ef7280523af4f27930";
logging-data="2558549"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fIAKPagbk96TCjQnIwMW8"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.0.2
Cancel-Lock: sha1:QQgWIioLW4sQ8V9jXeDvNZmuHiM=
In-Reply-To: <tamt6v$oav$1@newsreader4.netcologne.de>
Content-Language: en-US
 by: Lynn McGuire - Wed, 13 Jul 2022 18:28 UTC

On 7/13/2022 11:51 AM, Thomas Koenig wrote:
> Ron Shepard <nospam@nowhere.org> schrieb:
>> On 7/12/22 4:15 PM, jfh wrote:
>>> Declaring variables where used was one of my favourite things about Algol 68, long before C++ was invented. The block construct lets you do it in Fortran too.
>>
>> How exactly does this work in fortran. If you have a block with local
>> variables, are they allocated afresh when the block is entered and
>> deallocated upon block exit, or are they just allocated once? What if
>> the block is within a loop?
>
> The compiler will look at the lifetime of the variable and allocate
> it on the stack or in a register accordingly. A modern compiler
> will, when optimizing, reuse stack slots if possible, with or
> without help from the programmer through BLOCK statements.
>
> Compilers have gotten quite good :-)
>
> Also, the intermediate form that compilers use these days,
> single static assignment, makes this optimization necessary.
> Basically, any assignment to any variable creates a new
> variable, so something like
>
> i = 42
> j = 2
> i = i + j
> j = j + i
>
> will be translated to
>
> i_1 = 42
> j_1 = 2
> i_2 = i_1 + j_1
> j_2 = j_1 + i_2
>
> and the compiler will determine that i_1 is no longer
> in use, and will drop it.
>
> Anything I learned in my C-64 Basic days about re-using
> variables to save space, I had to unlearn :-)

Yup, we are memory pigs nowadays. I only start to worry about variables
being too large when I declare double precision arrays of more than a
million members. It is just not worth my time to optimize the usage.
And the old memory optimizations in our code are a total pain now.

Lynn

Re: is there a better way to code this ?

<tan430$thl$1@newsreader4.netcologne.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.freedyn.de!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd6-3a42-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: is there a better way to code this ?
Date: Wed, 13 Jul 2022 18:49:04 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <tan430$thl$1@newsreader4.netcologne.de>
References: <t85qc4$kr5$1@dont-email.me>
<375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com>
<t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk>
<1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com>
<JstzK.25578$kY1.19305@fx06.iad> <tamt6v$oav$1@newsreader4.netcologne.de>
<tan2sb$2e2il$5@dont-email.me>
Injection-Date: Wed, 13 Jul 2022 18:49:04 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd6-3a42-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd6:3a42:0:7285:c2ff:fe6c:992d";
logging-data="30261"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Wed, 13 Jul 2022 18:49 UTC

Lynn McGuire <lynnmcguire5@gmail.com> schrieb:
> On 7/13/2022 11:51 AM, Thomas Koenig wrote:
>> Ron Shepard <nospam@nowhere.org> schrieb:
>>> On 7/12/22 4:15 PM, jfh wrote:
>>>> Declaring variables where used was one of my favourite things about Algol 68, long before C++ was invented. The block construct lets you do it in Fortran too.
>>>
>>> How exactly does this work in fortran. If you have a block with local
>>> variables, are they allocated afresh when the block is entered and
>>> deallocated upon block exit, or are they just allocated once? What if
>>> the block is within a loop?
>>
>> The compiler will look at the lifetime of the variable and allocate
>> it on the stack or in a register accordingly. A modern compiler
>> will, when optimizing, reuse stack slots if possible, with or
>> without help from the programmer through BLOCK statements.
>>
>> Compilers have gotten quite good :-)
>>
>> Also, the intermediate form that compilers use these days,
>> single static assignment, makes this optimization necessary.
>> Basically, any assignment to any variable creates a new
>> variable, so something like
>>
>> i = 42
>> j = 2
>> i = i + j
>> j = j + i
>>
>> will be translated to
>>
>> i_1 = 42
>> j_1 = 2
>> i_2 = i_1 + j_1
>> j_2 = j_1 + i_2
>>
>> and the compiler will determine that i_1 is no longer
>> in use, and will drop it.
>>
>> Anything I learned in my C-64 Basic days about re-using
>> variables to save space, I had to unlearn :-)
>
> Yup, we are memory pigs nowadays. I only start to worry about variables
> being too large when I declare double precision arrays of more than a
> million members. It is just not worth my time to optimize the usage.
> And the old memory optimizations in our code are a total pain now.

The nice thing about modern compilers is that, while they use
a lot of memory and a lot of CPU time, they are quite good at
efficient optimization, and also at saving memory if you specify
the right options. Using a modern compiler, the code two codes
above will eventually be optimized into two assignments.

Re: is there a better way to code this ?

<tas5ml$33mjj$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.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 there a better way to code this ?
Date: Fri, 15 Jul 2022 10:47:08 -0600
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <tas5ml$33mjj$1@dont-email.me>
References: <t85qc4$kr5$1@dont-email.me> <375bab02-f98a-464e-aac0-b14c2e39a842n@googlegroups.com> <t8lbg1$ldi$1@dont-email.me> <fqo0qixs31.ln2@ph-kinsle2.qols.ph.ic.ac.uk> <1ae36f48-f336-4495-ac05-fcbe574b6744n@googlegroups.com> <JstzK.25578$kY1.19305@fx06.iad>
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="UTF-8";
reply-type=response
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 15 Jul 2022 16:47:17 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="2a95a73ad8989af2fa4b95275b0ed3db";
logging-data="3267187"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/s+1GgSBb0KiL17e/oVl1R+YqAPRO6RJ8="
Cancel-Lock: sha1:SJb/DEymyP+m+5PzAyzBgu3ntQI=
X-Priority: 3
Importance: Normal
In-Reply-To: <JstzK.25578$kY1.19305@fx06.iad>
X-MSMail-Priority: 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 - Fri, 15 Jul 2022 16:47 UTC

"Ron Shepard" wrote in message news:JstzK.25578$kY1.19305@fx06.iad...

> On 7/12/22 4:15 PM, jfh wrote:
> > Declaring variables where used was one of my favourite things
> about Algol 68, long before C++ was invented. The block construct
> lets you do it in Fortran too.

> How exactly does this work in fortran. If you have a block with local
> variables, are they allocated afresh when the block is entered and
> deallocated upon block exit, or are they just allocated once? What if
> the block is within a loop?

In some instances allocation on entry and deallocation on exit will
definitely be required. Thus the simplest implementation would be
to always do so.

D:\gfortran\clf\blockloop>type blockloop.f90
program blockloop
implicit none
integer i
do i = 1, 15
BLOCK
character(i) fun
write(*,'(*(g0))') fun()
END BLOCK
end do
end program blockloop

function fun()
implicit none
character(*) fun
integer i
do i = 1, len(fun)
fun(i:i) = achar(iachar('0')+modulo(i,10))
end do
end function fun
D:\gfortran\clf\blockloop>gfortran blockloop.f90 -oblockloop

D:\gfortran\clf\blockloop>blockloop
1 12
123
1234
12345
123456
1234567
12345678
123456789
1234567890
12345678901
123456789012
1234567890123
12345678901234
123456789012345

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor