Richard Rublev
Richard Rublev

Reputation: 8164

Error on line 50: attempt to give DATA in type-declaration

I am try to compile FORTRAN 77 code and I have problems like this.

  integer row(nnzmax+nszero),column(nnzmax+nszero),
 +        ireg(nximax),florsm(nzimax)/nzimax*2/
  real lambda,imodel(nximax,nzimax),dm(nmmax),
 +     dum1(nmmax),dum2(nmmax),data(ndmax+nsconst),
 +     anz(nnzmax+nszero),ibmodel(nximax,nzimax),
 +     smwz(nzimax)/nzimax*-1./,spwz(nzimax)/nzimax*-1./

Error on line 50: attempt to give DATA in type-declaration
Error on line 52: attempt to give DATA in type-declaration

I used to work with this code,but it has been compiled with Intel Fotran Compiler. I have moved to other country so I do not have ifort installed here. I am using fort77 now. Should I try with some compilation options or?I have used this script to compile app .f from this folder.

#! /bin/csh -f

set list=`ls *.f`
set FLAG="-o"
echo $list
foreach file (${list})
  echo $file
  f77 ${file} ${FLAG} ${file:r}
  mv ${file:r} ../bin/.

end

I have changed declarations like this:

integer row(nnzmax+nszero),column(nnzmax+nszero), + ireg(nximax),florsm(nzimax), + data florsm /nzimax*2/ real lambda,imodel(nximax,nzimax),dm(nmmax), + dum1(nmmax),dum2(nmmax),data(ndmax+nsconst), + anz(nnzmax+nszero),ibmodel(nximax,nzimax), + data smwz /nzimax*-1./, + data spwz /nzimax*-1./

But still I got

Error on line 50: attempt to give DATA in type-declaration
Error on line 53: attempt to give DATA in type-declaration
Error on line 385: Declaration error for smwz: used as variable
Error on line 385: Declaration error for smwz: may not appear in namelist
Error on line 385: Declaration error for spwz: used as variable
Error on line 385: Declaration error for spwz: may not appear in namelist

Upvotes: 0

Views: 200

Answers (1)

High Performance Mark
High Performance Mark

Reputation: 78316

This fragment, and the later similar ones

florsm(nzimax)/nzimax*2/

looks like a non-standard way of initialising a variable with a sort-of data statement merged into the declaration. A more standard approach would separate the two, something like

florsm(nzimax)
...
data florsm /nzimax*2/

One of the beauties of working with the Intel Fortran compiler is its long history; along the way it has picked up, and continues to accept, all sorts of non-standard features. I'm guessing that this is one of those and is not acceptable to the other compiler you mention.

Of course, this seems to be what the error statement seems to be telling us.

A standard replacement might be

florsm(nzimax) = 2

but that takes advantage of a Fortran 90 feature which something called fort77 might not understand either.

Upvotes: 4

Related Questions