Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
new_line
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Paul Anton Letnes  
View profile  
 More options Aug 16 2012, 3:53 pm
Newsgroups: comp.lang.fortran
From: Paul Anton Letnes <paul.anton.let...@nospam.gmail.kthxbai.com>
Date: Thu, 16 Aug 2012 21:53:00 +0200
Subject: new_line
Hi,

what does the standard have to say to the following? This line:
character(len=*), parameter :: newline = new_line("a")
makes ifort (Version 11.1 on Linux) say:
code.f90(4): error #6263: This intrinsic function is invalid in constant
expressions.   [NEW_LINE]
character(len=*), parameter :: newline = new_line("a")
-----------------------------------------^
compilation aborted for code.f90 (code 1)

The code compiles just fine in gfortran.

Paul


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dick Hendrickson  
View profile  
 More options Aug 16 2012, 6:32 pm
Newsgroups: comp.lang.fortran
From: Dick Hendrickson <dick.hendrick...@att.net>
Date: Thu, 16 Aug 2012 17:32:41 -0500
Local: Thurs, Aug 16 2012 6:32 pm
Subject: Re: new_line
On 8/16/12 2:53 PM, Paul Anton Letnes wrote:

> Hi,

> what does the standard have to say to the following? This line:
> character(len=*), parameter :: newline = new_line("a")
> makes ifort (Version 11.1 on Linux) say:
> code.f90(4): error #6263: This intrinsic function is invalid in constant
> expressions. [NEW_LINE]
> character(len=*), parameter :: newline = new_line("a")
> -----------------------------------------^
> compilation aborted for code.f90 (code 1)

> The code compiles just fine in gfortran.

> Paul

I think it should work in F2003 (I didn't try to track down F2008).  The
rules for initialization expressions (7.1.6) allow a specification
inquiry with a constant argument and page 125 says NEW_LINE is a
specification inquiry function.

Dick Hendrickson


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Anton Letnes  
View profile  
 More options Aug 17 2012, 3:22 am
Newsgroups: comp.lang.fortran
From: Paul Anton Letnes <paul.anton.let...@nospam.gmail.kthxbai.com>
Date: Fri, 17 Aug 2012 09:22:19 +0200
Local: Fri, Aug 17 2012 3:22 am
Subject: Re: new_line
On 17.08.12 00:32, Dick Hendrickson wrote:

If F2003 says it's OK, I'd expect F2008 to say the same? Anyway, this
will make life somewhat complicated if it can't be resolved... Is there
a standard way of determining a character, parameter :: ... which
contains the "newline" character(s)?

Paul


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tobias Burnus  
View profile  
 More options Aug 17 2012, 3:43 am
Newsgroups: comp.lang.fortran
From: Tobias Burnus <bur...@net-b.de>
Date: Fri, 17 Aug 2012 09:43:48 +0200
Local: Fri, Aug 17 2012 3:43 am
Subject: Re: new_line
On 08/17/2012 09:22 AM, Paul Anton Letnes wrote:

> If F2003 says it's OK, I'd expect F2008 to say the same? Anyway, this
> will make life somewhat complicated if it can't be resolved... Is there
> a standard way of determining a character, parameter :: ... which
> contains the "newline" character(s)?

A 100% equivalent doesn't exist, but achar(10) should work.

Unless you have an UCS-4 character; then you should use char(10,kind=...).

(I admit I find new_line one of the less useful new intrinsics - and I
had wished a method to obtain Windows' crlf via an intrinsic.)

 From the standard:

Result Value.
Case (i): If A is default character and the character in position 10 of
the ASCII collating sequence is representable in the default character
set, then the result is ACHAR (10).
Case (ii): If A is ASCII character or ISO 10646 character, then the
result is CHAR (10, KIND (A)).
Case (iii): Otherwise, the result is a processor-dependent character
that represents a newline in output to files connected for formatted
stream output if there is such a character.
Case (iv): Otherwise, the result is the blank character.

Tobias


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Anton Letnes  
View profile  
 More options Aug 17 2012, 4:13 am
Newsgroups: comp.lang.fortran
From: Paul Anton Letnes <paul.anton.let...@nospam.gmail.kthxbai.com>
Date: Fri, 17 Aug 2012 10:13:10 +0200
Local: Fri, Aug 17 2012 4:13 am
Subject: Re: new_line
On 17.08.12 09:43, Tobias Burnus wrote:

Ah, I see. I thought that achar(10) was a nonstandard way of doing this,
but it looks like it should be fine?

Paul


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Maine  
View profile  
 More options Aug 17 2012, 9:05 am
Newsgroups: comp.lang.fortran
From: nos...@see.signature (Richard Maine)
Date: Fri, 17 Aug 2012 06:05:50 -0700
Local: Fri, Aug 17 2012 9:05 am
Subject: Re: new_line
Paul Anton Letnes <paul.anton.let...@nospam.gmail.kthxbai.com> wrote:

> On 17.08.12 09:43, Tobias Burnus wrote:
> > On 08/17/2012 09:22 AM, Paul Anton Letnes wrote:
> >> If F2003 says it's OK, I'd expect F2008 to say the same? Anyway, this
> >> will make life somewhat complicated if it can't be resolved... Is there
> >> a standard way of determining a character, parameter :: ... which
> >> contains the "newline" character(s)?

> > A 100% equivalent doesn't exist, but achar(10) should work.
> Ah, I see. I thought that achar(10) was a nonstandard way of doing this,
> but it looks like it should be fine?

Achar(10) is perfectly standard. I agree with Tobias about new_line
being of limitted utility. As you can see from the quote above, new_line
is specifically defined to be achar(10) in most cases. I'd say that the
only cases where it has much application are those where you are looking
for the new_line character used by a non-default character kind. That
would be pretty rare. In particular, that comes up a *LOT* less often
than people getting confused by what new_line means and thinking it will
return the character (or character sequence) used by the OS to represent
a newline in a file. As in, I've never actually seen a useful
application for new_line in practice (largely because I've never worked
with a compiler that supports a character set where it does anything
useful), but the confusion happens regularly.

I suspect you might be thinking of the "F" language, which was an
f90/f95 subset. If I recall correctly, F omitted the achar intrinsic as
part of its subsetting. Or maybe I have it backwards and they omitted
char, but I think it was achar.

--
Richard Maine                    | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle           |  -- Mark Twain


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Lionel  
View profile  
 More options Aug 17 2012, 9:58 am
Newsgroups: comp.lang.fortran
From: Steve Lionel <steve.lio...@intel.invalid>
Date: Fri, 17 Aug 2012 09:58:09 -0400
Local: Fri, Aug 17 2012 9:58 am
Subject: Re: new_line
On 8/16/2012 3:53 PM, Paul Anton Letnes wrote:

> what does the standard have to say to the following? This line:
> character(len=*), parameter :: newline = new_line("a")
> makes ifort (Version 11.1 on Linux) say:
> code.f90(4): error #6263: This intrinsic function is invalid in constant
> expressions.   [NEW_LINE]
> character(len=*), parameter :: newline = new_line("a")
> -----------------------------------------^
> compilation aborted for code.f90 (code 1)

It seems we overlooked that when adding the function many years ago - I
have filed bug report DPD200235439 about it. F2003 explicitly calls out
NEW_LINE as a "specification inquiry function" and F2008 generalizes the
rule to include all inquiry functions.

--
Steve Lionel
Developer Products Division
Intel Corporation
Merrimack, NH

For email address, replace "invalid" with "com"

User communities for Intel Software Development Products
   http://software.intel.com/en-us/forums/
Intel Software Development Products Support
   http://software.intel.com/sites/support/
My Fortran blog
   http://www.intel.com/software/drfortran

Refer to http://software.intel.com/en-us/articles/optimization-notice
for more information regarding performance and optimization choices in
Intel software products.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Daniel Feenberg  
View profile  
 More options Aug 17 2012, 7:59 pm
Newsgroups: comp.lang.fortran
From: Daniel Feenberg <feenb...@gmail.com>
Date: Fri, 17 Aug 2012 16:59:04 -0700 (PDT)
Local: Fri, Aug 17 2012 7:59 pm
Subject: Re: new_line

Now I am confused. Achar(10) is newline in POSIX, but after years of reading in this newsgroup how something couldn't be made part of the fortran standard because a CPU with 60 bit words from the 1950s couldn't deal with it, how can achar(10) be called the standard for newline? What about Windows? I think I am misunderstanding something. What is it intended to return if not the character sequence used by the OS? The standard quoted above says "processor" but doesn't a fortran processor include the OS?

daniel feenberg


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan Nagle  
View profile  
 More options Aug 17 2012, 8:47 pm
Newsgroups: comp.lang.fortran
From: Dan Nagle <danlna...@me.com>
Date: Fri, 17 Aug 2012 18:47:34 -0600
Local: Fri, Aug 17 2012 8:47 pm
Subject: Re: new_line
Hi,

On 2012-08-17 23:59:04 +0000, Daniel Feenberg said:

> Now I am confused. Achar(10) is newline in POSIX, but after years of
> reading in this newsgroup how something couldn't be made part of the
> fortran standard because a CPU with 60 bit words from the 1950s
> couldn't deal with it, how can achar(10) be called the standard for
> newline? What about Windows? I think I am misunderstanding something.
> What is it intended to return if not the character sequence used by the
> OS? The standard quoted above says "processor" but doesn't a fortran
> processor include the OS?

The new line character, or achar( 10), or whatever, is only a signal
to the rtl to end the record.

Strange short character sets didn't have end-of-record characters,
the file had a record structure.

IMNSHO, the worst thing new_line() does is make any future attempt
at classifying characters a little bit harder, because it might return
a control character or it might return a graphic character, and that
will likely require a special case for clarity.  Yuk.

--
Cheers!

Dan Nagle


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Maine  
View profile  
 More options Aug 17 2012, 10:47 pm
Newsgroups: comp.lang.fortran
From: nos...@see.signature (Richard Maine)
Date: Fri, 17 Aug 2012 19:47:57 -0700
Local: Fri, Aug 17 2012 10:47 pm
Subject: Re: new_line

Daniel Feenberg <feenb...@gmail.com> wrote:
> Now I am confused. Achar(10) is newline in POSIX, but after years of
> reading in this newsgroup how something couldn't be made part of the
> fortran standard because a CPU with 60 bit words from the 1950s couldn't
> deal with it, how can achar(10) be called the standard for newline? What
> about Windows? I think I am misunderstanding something. What is it
> intended to return if not the character sequence used by the OS? The
> standard quoted above says "processor" but doesn't a fortran processor
> include the OS?

See the part of my post where I commented about how often people were
confused about what the new_line intrinsic does. Yes, your confusion is
shared by many people. The intrinsic does *NOT* do what you think it
does. In particular, it has nothing to do with what character or
characters are used to represent the end of a line in a text file. It
doesn't even imply that the end of a line in a text file is represented
by a sequence of characters. Text file lines could be represented by
header with the line length, much like typical unformated file records.
I have worked on multiple systems with representations like that.

The achar(10) (or other character returned by new_line) is used as a
flag to be interpreted by the Fortran runtime library. That runtime
library is then responsible for doing whatever is needed to terminate
the line (record). This does not have to be just copying the achar(10)
to the file. On a Windows system, the Fortran runtimes should put a
cr/lf sequence in the file when an achar(10) is encountered.

This is, by the way, pretty much identical to what the C standard
specifies. That is no coincidence. The achar(10) handling stuff was
added to Fortran as part of C interop. If I recall correctly, it applies
only to formatted stream files.

--
Richard Maine                    | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle           |  -- Mark Twain


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »