Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

Allocatable character array gets corrupted in the namelist

abhimodak
New Contributor I
1,366 Views
Hi

It seems that while integer and real allocatable arrays are fine with namelist in version 11.1.046, the allocatable character arrays still have a problem.

The snippet below has correct values for arrays I and R but the character array changes to undefined pointer/array if the length of character is greater than or equal to 5. If it is less than 5 then the debugger shows undefined address.

Abhi

---
Program Test_Namelist

Implicit None

Integer, Allocatable :: I(:)
Real, Allocatable :: R(:)
Character(1), Allocatable :: C(:)

NameList /Test/ I, R, C

Integer, Parameter :: Linp = 71, nMax = 5
Integer :: n

Allocate(I(nMax), R(nMax), C(nMax))

I = 0; R = 1.0; C = ' '

Open(Linp, File='Test.inp', Form='Formatted', Status='Old')
Rewind(Linp)
Read(Linp,NML=Test)
Close(Linp)

Print *, I
Print *, R
Print *, C

End Program Test_Namelist

The contents of Test.inp:

&Test

I = 1, 2, 3
R = 2.0, 3.0
C = 'A', 'B', 'C', 'D'

/
0 Kudos
10 Replies
Steven_L_Intel1
Employee
1,366 Views
Thanks - I can reproduce this and will report it to development. Issue ID is DPD200140845
0 Kudos
abhimodak
New Contributor I
1,366 Views
FYI: This seems to be working in 11.1.054!
Thanks.

Abhi
0 Kudos
Steven_L_Intel1
Employee
1,366 Views
Indeed - haven't gotten to updating the threads yet. Glad to hear it.
0 Kudos
xlevaill
Beginner
1,365 Views

Hi,

I still have a problem with intel 11.1.056 for characters array.

When reading namelist (with the exemple below), I have a error message of "SIGSEGV, segmentation fault occurred".

When writing namelist, I have ugly symbol into characters array.

Everything is fine with REAL and INT. I attached my test files.

Any ideas ?
Xavier

Just for information :

Intel Fortran IA-64 Compiler Professional for applications running on IA-64, Version 11.1 Build 20090827 Package ID: l_cprof_p_11.1.056
Copyright (C) 1985-2009 Intel Corporation. All rights reserved

UPDATE :


The segmentation faultduring the reading was due to a delimiter problem. so the reading almost works. the segmentation fault occurs when I print the characters array. Now the character arrays contains ugly symbol or piece of code... wired ?!

0 Kudos
IDZ_A_Intel
Employee
1,365 Views

Hi Xavier

With the program snippet attached, I neither get a segmentation fault nor the character arrays contain ugly symbol. I am using WinXP64 with VS2005 and the compiler version is 11.1.054.

Abhi

0 Kudos
Steven_L_Intel1
Employee
1,365 Views
xlevaill is using the Linux compiler, where the version numbers are different. 11.1.056 is the "Update 3" compiler. This issue was resolved in Update 4.
0 Kudos
xlevaill
Beginner
1,365 Views

Steve,

thank you for your quick answer. I 'll ask my sysadmin to install...

@+

Xavier

0 Kudos
xlevaill
Beginner
1,365 Views

Hi Steve,

A little question : compilation (see lines below) doesn't work with "-stand f03" option, The use of allocatable array into namelist is a F2003 feature, isn't it ?

@+

Xavier

=== test file ===

PROGRAM MAIN
REAL, DIMENSION(:), ALLOCATABLE :: TAB
NAMELIST/TOTO/TAB
END PROGRAM MAIN
==========

0 Kudos
Steven_L_Intel1
Employee
1,365 Views
Thanks. This should compile without warnings if F2003 standards checking is in effect. For F95/F90, a warning is appropriate but the wording of the warning given is incorrect. I have escalated this as issue DPD200150685.
0 Kudos
Steven_L_Intel1
Employee
1,365 Views
The warning will be fixed in a future release of the compiler.
0 Kudos
Reply