Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

printing two strings generated by internal write
The program below, which prints a string created by an internal write,
is compiled without warnings by Compaq Visual Fortran, Lahey/Fujitsu,
and g95. At run time, however, LF95 and g95 crash, whereas CVF gives
the output of "3" that I expect. Is the code ok? When I store
int_to_string(3) in a character variable and then print that variable,
all three compilers work fine.

module yy
implicit none
contains
pure function int_to_string(i) result(text)
integer, intent(in) :: i
character (len=10)  :: text
write (text,"(i6)") i
end function int_to_string
end module yy

program xx
use yy, only: int_to_string
implicit none
print*,int_to_string(3)
end program xx

Report this thread to moderator Post Follow-up to this message
Old Post
beliavsky@aol.com
11-18-04 08:56 AM


Re: printing two strings generated by internal write
In article <3064b51d.0411171728.79ecfdf5@posting.google.com>,
<beliavsky@aol.com> wrote:

>The program below, which prints a string created by an internal write,

Doesn't it break the "no recursive I/O" rule?

Works OK in PathScale's compiler...

-- greg

Report this thread to moderator Post Follow-up to this message
Old Post
Greg Lindahl
11-18-04 08:56 AM


Re: printing two strings generated by internal write
"Greg Lindahl" <lindahl@pbm.com> wrote in message
news:419bff8a$1@news.meer.net...

> In article <3064b51d.0411171728.79ecfdf5@posting.google.com>,
>  <beliavsky@aol.com> wrote:
 

> Doesn't it break the "no recursive I/O" rule?

> Works OK in PathScale's compiler...

Breaks the rule in f95, but not f03.  Some of my code did this
and worked in LF95 & CVF but many other compilers didn't like it.
I had to change it so that it would be more widely useable.

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end



Report this thread to moderator Post Follow-up to this message
Old Post
James Van Buskirk
11-18-04 08:56 AM


Re: printing two strings generated by internal write
On 17 Nov 2004 17:28:16 -0800, beliavsky@aol.com wrote:

>The program below, which prints a string created by an internal write,
>is compiled without warnings by Compaq Visual Fortran, Lahey/Fujitsu,
>and g95. At run time, however, LF95 and g95 crash, whereas CVF gives
>the output of "3" that I expect. Is the code ok? When I store
>int_to_string(3) in a character variable and then print that variable,
>all three compilers work fine.

As others have noted, Fortran 95 prohibits starting an I/O operation as a
side-effect of a function call in another I/O operation.  F2003 relaxes this
.

Compaq and now Intel compilers currently allow nested I/O as long as differe
nt
units are used, and internal I/O is always allowed.


Steve Lionel
Software Products Division
Intel Corporation
Nashua, NH

User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://developer.intel.com/software/products/support/

Report this thread to moderator Post Follow-up to this message
Old Post
Steve Lionel
11-18-04 08:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:01 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.