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

Namelist with pointers

abhimodak
New Contributor I
713 Views
Hi

The snippet below compiles ok but throws an access violation when reading the namlist. I am using IVF 11.1.051 on VS2005 and WinXP64.

If P and T are not pointers, this error does not happen. The same is true for array X.

The access violation happens in debug mode while in release mode the values of P and T are stomped over. It runs fine when using XLFortran. If I have not done something silly here, may be there is a bug in the namelist implementation. (I know there is one with allocatable characters.)

Abhi

----

Module EMG

Implicit None

Private

Integer, Parameter :: rKind = kind(1.0d0)

! Define field
Type, Public :: newField
Real(rKind) :: E
Real(rKind) :: B
Real(rKind), Allocatable :: X(:)
End Type newField

Type(newField) :: Gauss
Target :: Gauss

! Entities that are public
Public :: rKind
Public :: Gauss
Public :: EMG_Initialize

Contains

Subroutine EMG_Initialize(KK, iError)

Implicit None

Integer, Intent(IN) :: KK
Integer, Intent(OUT) :: iError

iError = 0

! Allocate memory for the field
Allocate(Gauss%X(KK), stat=iError)
if (iError /= 0) then
iError = 1
endif

End Subroutine EMG_Initialize

End Module EMG

Program Test_NameList

Use EMG

Implicit None

Integer, Parameter :: LINP = 90, LOUT = 91

Integer :: KK, iError, ial

!Real(rKind) :: P, T
Real(rKind), Allocatable :: X(:)

Real(rKind), Pointer :: P, T
!Real(rKind), Pointer :: X(:)

Logical :: Apply
NameList / INPUT/ Apply, P, T, X

!
!###################
!

KK = 3

! Initialize EMG
Call EMG_Initialize(KK, iError)
if (iError /= 0) then
Write(*,*) "Error initializing EMG."
Stop
endif

NullifY(P)
P => Gauss%E

NullifY(T)
T => Gauss%B

!Nullify(X)
!X => Gauss%X
Allocate(X(KK), stat=ial)
if (ial /= 0) then
Write(*,*) "Allocation failed."
Stop
endif

Open(Linp, File="FieldCondition.inp", Form="Formatted", Status="Old")
Rewind(Linp)
Read(Linp, NML=INPUT)
Close(Linp)
Write(*,NML=INPUT)

End Program Test_NameList

=====

The contents of file 'FieldCondition.inp' are:

&INPUT

Apply = F
P = 10.00000000
T = 1600.00000000
X = 6.603199904580657E-002,3.674703942511635E-004,2.807054850067047E-006

/

0 Kudos
5 Replies
Steven_L_Intel1
Employee
713 Views
Sigh - we fixed a case for pointer arrays (coming in Update 4) but somehow overlooked pointer scalars. The new issue ID is DPD200142385.
0 Kudos
abhimodak
New Contributor I
713 Views
Hi Steve

Thanks.

Just curious: Is update 4 going to include allowing allocatable characters in namelist?

I reported it here: http://software.intel.com/en-us/forums/showthread.php?t=69103

Abhi
0 Kudos
Steven_L_Intel1
Employee
713 Views
Yes, that should work in update 4.
0 Kudos
Steven_L_Intel1
Employee
713 Views
The fix for the issue in this thread should appear in Update 5, scheduled for late January.
0 Kudos
abhimodak
New Contributor I
713 Views

FYI:

It looks like the namelist with pointers is working in update 5!

Abhi

0 Kudos
Reply