Error: Invalid character in name at (1)

醉酒当歌 提交于 2019-12-02 01:41:14

问题


I am trying to compile a fortran file along with some .h files in FORTRAN. The .h files contain definition for common blocks of variable. When I compile them in Fortran, I get the following error:

integer knue,ke,knumu,kmu,knutau,ktau,ku,kd,kc,ks,kt,kb,kgamma,
                                      1
Error: Invalid character in name at (1)

The code where this error occurs is,

Now my question is, does this "1" point where the error is?

The lines of code which this errors points is,

integer knue,ke,knumu,kmu,knutau,ktau,ku,kd,kc,ks,kt,kb,kgamma, 
     &     kw,kz,kgluon,kh1,kh2,kh3,khc,ksnue,kse1,kse2,ksnumu,ksmu1,
     &     ksmu2,ksnutau,kstau1,kstau2,ksu1,ksu2,ksd1,ksd2,ksc1,ksc2,
     &     kss1,kss2,kst1,kst2,ksb1,ksb2,kn1,kn2,kn3,kn4,kcha1,kcha2,
     &     kgluin,kgold0,kgoldc

Also, is there something wrong with the way continuation are used. I am using gfortran to compile this file.


回答1:


It looks like you are using Fortran 77 style line continuations and trying to compile with Fortran 90 style free format code. You either need to compile using the gfortran -ffixed-form option, or format the code using Fortran 90 style line continuations:

integer knue,ke,knumu,kmu,knutau,ktau,ku,kd,kc,ks,kt,kb,kgamma, &
          kw,kz,kgluon,kh1,kh2,kh3,khc,ksnue,kse1,kse2,ksnumu,ksmu1, &
          ksmu2,ksnutau,kstau1,kstau2,ksu1,ksu2,ksd1,ksd2,ksc1,ksc2, &
          kss1,kss2,kst1,kst2,ksb1,ksb2,kn1,kn2,kn3,kn4,kcha1,kcha2, &
          kgluin,kgold0,kgoldc 



回答2:


I had this problem when modifying scipy and trying to compile it. The following identation was necessary to make it work, with the star * at column 5. It works for both Fortran 77 and 90 styles.

      double precision a,abseps,abserr,alist,area,area1,area12,area2,
     * a1,a2,b,blist,b1,b2,correc,dabs,defabs,defab1,defab2,d1mach,
     * dmax1,dres,elist,epmach,epsabs,epsrel,erlarg,erlast,errbnd,
     * errmax,error1,error2,erro12,errsum,ertest,f,oflow,resabs,
     * reseps,result,res3la,rlist,rlist2,small,uflow,areav



回答3:


To your first question, yes the "1" normally denotes the point in the code where the error occurs. The code as such looks ok otherwise.




回答4:


Actually the Fortran 77 continuation column is number six.

http://web.stanford.edu/class/me200c/tutorial_77/03_basics.html



来源:https://stackoverflow.com/questions/7822739/error-invalid-character-in-name-at-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!