This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
bugreport
- From: Jean-Pierre dot Flament at univ-lille1 dot fr
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 31 Oct 2003 15:58:42 +0100 (MET)
- Subject: bugreport
Dear gentelmen,
I have got a problem with a program reading mixed NAMELIST
and "GROUP DATA" data.
The namelist are the standard fortran namelist, and the
"group data" is indeed a group of free format data
enclosed within a couple of $NAME/$END banners
The input is in a disk file which is rewound before
each read. The program either locates the $NAME
when reading a "group data"² or issues a read(ir,NAME)
when reading a namelist.
it happens that, executing this program on a PC pentium,
compiled with g77, that the data of a namelist are not read
correctly. Fortunately the little program below reproduces
the result of the actual run. The data file is after the
fortran code.
* the compilation command is
g77 -g -C -o pgmtest pgmtest.f
or
g77 -O2 -o pgmtest pgmtest.f
* and then pgmtest <datafile
* and here is the result of g77 -v
Lecture des spe©cification à partir de /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configure© avec: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux
--with-system-zlib --enable-__cxa_atexit
Mode¨le de thread: posix
version gcc 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
* Here is what happens
1/ the data consist of a "group data" named $FILE specifying
free format data , followed by the namelist CNTRL
setting the variable ISPHER to 1, while the initialization
in the program sets it to 0.
2/ When there is at least one SLASH in the strings of $FILE
we get ISPHER=0 instead of 1. When there is no SLASH,
ISPHER is correct, =1
3/ when $CNTRL is put before $FILE the result is correct, even
when there is SLASH in $FILE
4/ when a line (even empty) is inserted between the $END of
$FILE and $CNTRL, the result is correct: this the workarround
that I found.
I guessed that the SLASH(es) in $FILE was the source of
error because a / may end a namelist
This problem never occured with other compilers (on
IBM -AIX or FORTRAN VS-,HP ,DEC or SGI)
SAMPLE FORTRAN CODE pgmtest.f
--------------------------------------------------------
program bug
c
implicit real*8 (a-h,o-z)
parameter (MXIODA=255,MXATOM=128,MXSYM=48,IBMMX=255)
parameter (ZERO=0.0D+00)
character*80 texte
character*8 errmsg,BLANK
integer direct
integer thime
integer semisp
integer dirstp
integer runflg
integer fldint
c
c ----- variables in common -----
c
c
data BLANK /' '/
data time /9999999.0D+00/
data igraf /0/
data direct /0/
data iprint /0/
data irest /0/
data runflg /0/
data noprop /0/
data nosym /0/
data qmttol /1.0d-04/
data ispher /0/
data list /0/
data ifield /0/
data intfld /0/
data moddia /1/
data lenmem /200000/
data lenxio / 1/
data lenvec /200000/
c
9997 format(' ----- namelist $CNTRL -----', /,
# ' runflg = ',i2 , ' noprop = ',i2 , ' nosym = ',i2 ,
# ' ispher = ',i2 , ' direct = ',i2 , /,
# ' irest = ',i2 , /,
# ' igraf = ',i2 , ' iprint = ',i2 , ' list = ',i2 ,/,
# ' moddia = ',i2 , /,
# ' maxlcm = ',i10,/,' maxvec = ',i10,/,' maxxio = ',i10,/,
# ' qmttol = ',e10.3, /,
# ' time = ',f10.1,' (sec)')
c
namelist /cntrl/ time,iprint,irest,runflg,noprop,nosym,qmttol,
# list,moddia,maxxio,maxvec,maxlcm,
# direct,igraf,ispher
c
maxxio = lenxio
maxvec = lenvec
maxlcm = lcmmax
c
ier = 0
do while(ier.eq.0)
read(5,'(a80)',iostat=ier) texte
write(4,'(a80)') texte
enddo
ir = 4
iw = 6
rewind ir
read(ir,cntrl,end=10,err=10)
10 continue
c
c
write(iw,9997) runflg,noprop,nosym,ispher,direct,
# irest,
# igraf,iprint,list,
# moddia,
# maxlcm,maxvec,maxxio,
# qmttol,time
c
end
THE DATA after the ---------------------
---------------------------------
$file
oms omsmc.i2
pseu pseudo/PSN
$end
$CNTRL ispher=1,NOSYM=0,RUNFLG=0,noprop=0, $END
$GUESS NGUESS=9,norb=44,gssfil='gss.i2', $END
$BASIS
*** Iode ********
0 0 15 0 ... ECP
C1 2
I 53.0 LC 1.3335 0.0 0.0 - O K I
1 S 3 give 1.0
1 2.188316 0.799111
1 1.749319 -1.200211
1 .321036 0.610723
1 S 1 give 1.0
1 .160762 .180945
1 S 1 give 1.0
1 .078052 .105244
1 P 3 give 1.0
1 2.159164 0.320438
1 1.855827 -0.467669
1 .383991 0.427095
1 P 1 give 1.0
1 .163129 1.0
1 P 1 give 1.0
1 .065984 1.0
1 D 1 give 1.0
1 .730000 1.0
1 D 1 give 1.0
1 .270000 1.0
I 53.0 LC 1.3335 0.0 0.0 + O K I
1 S 3 give 1.0
1 2.188316 0.799111
1 1.749319 -1.200211
1 .321036 0.610723
1 S 1 give 1.0
1 .160762 .180945
1 S 1 give 1.0
1 .078052 .105244
1 P 3 give 1.0
1 2.159164 0.320438
1 1.855827 -0.467669
1 .383991 0.427095
1 P 1 give 1.0
1 .163129 1.0
1 P 1 give 1.0
1 .065984 1.0
1 D 1 give 1.0
1 .730000 1.0
1 D 1 give 1.0
1 .270000 1.0
$END
$ECP
I-ECP 46 3
1
0.0 0 1.0
1
50.44054 2 2.648255
1
42.905904 2 2.226666
1
5.445394 2 0.644831
I-ECP 46 3
$END
$WFN WFNFLG=1, $END
$SCF NCO=7, $end
$MC MAXIT=30,nocas=1,nocan=0, $END
$TRF $END
$DRT
*** CALCUL MCSCF DE I2 1S+ + 1Pi ***
0 10 1 3 0 0 0 0 0 0 0 0
7*DOC 8*VAL
$END
$GUGSRT $END
$GUGEM $END
$GUGDIA NSTATE=8,maxit=160, $END
$GUGDM $END
$GUGDM2 nstate=8,istate=1,2,3,4,5,6,7,8,wstate=8*1.0, $END
$CASMP2 $END
$NEWTON $END
$PUN nopltx=1,noplto=1,gamess=1,biosym=1,hyperc=1, $END