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