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

LEN of subroutine variables
Hello,
I would like to ask you if the following code is legal (notice the
LEN type parameter of MOD_B_STRING):


module mod_a
implicit none
character(len=100) :: mod_a_string
end module mod_a


module mod_b
use mod_a
implicit none

contains

subroutine mod_b_sub()
 character(len=len(trim(mod_a_string))+2)
 :: &
mod_b_string

mod_b_string = trim(mod_a_string) // '!!'
write(*,*) mod_b_string

end subroutine mod_b_sub
end module mod_b


program test_string

use mod_a
use mod_b

implicit none

mod_a_string = 'Hello'
call mod_b_sub()

end program test_string


When this code is compiled with gfortran or ifort, it behaves "as
expected", in that it prints Hello!! (no warning even when using all
the debugging options). Also, valgrind shows no errors.  With pgf,
however, the code compiles with no errors but at runtime produces a
huge blank output. Here, valgrind complains about "Conditional jump or
move depends on uninitialised value(s)" at CALL MOD_B_SUB().

(more details:
gfortran --version
GNU Fortran 95 (GCC) 4.1.2 (Gentoo 4.1.2)
ifort --version
ifort (IFORT) 9.1 20061101
pgf95 -V
pgf95 6.1-1 32-bit target on x86 Linux)

Thank you!
Marco Restelli


Report this thread to moderator Post Follow-up to this message
Old Post
mrestelli@gmail.com
08-21-07 12:10 AM


Re: LEN of subroutine variables
On Mon, 20 Aug 2007 06:29:51 -0700, mrestelli@gmail.com wrote
(in article <1187616591.093651.68110@k79g2000hse.googlegroups.com> ):

>    I would like to ask you if the following code is legal (notice the
> LEN type parameter of MOD_B_STRING):
[code elided]

Yes, that looks fine. It is even ok in f90. (This is an area where things go
t
progressively more liberal with each version of the standard, but this one
looks ok for f90 and later).

> When this code is compiled with gfortran or ifort, it behaves "as
> expected", in that it prints Hello!! (no warning even when using all
> the debugging options). Also, valgrind shows no errors.

Good.

>  With pgf, however,...

I'd suggest a bug report. Pgf isn't the most robust compiler out there. It i
s
better than it used to be, but still has plenty of room to go.

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


 ________________________________________
________

Hogwasher, Premier News and Mail for OS X
http://www.asar.com/cgi-bin/product.../hogwasher.html
 ________________________________________
________


Report this thread to moderator Post Follow-up to this message
Old Post
Richard Maine
08-21-07 12:10 AM


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 02:16 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.