Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageIn 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
Post Follow-up to this message"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
Post Follow-up to this messageOn 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/
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.