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

Error in fortran code?

mohammad_f_
Beginner
472 Views

hello everybody

i have received a fortran code, i don't know that which version of fortran is it??

prat of this code is here:

<< PROGRAM CSTGRD
PARAMETER(IP=51,JP=100,NX=35,NY=61,LX=500,LY=500,IPW=25,IPE=25,
1 JPS=25,JPN=25,JPT=(JPS+JP+JPN),IPT=(IPW+IP+IPE)
2 ,NPR=(10*(NX+NY-2)+1),NSEC=10)
COMMON XV(IP),YV(JP),XS(NPR),YS(NPR),IS(NPR),JS(NPR),
1 ISC(NPR),JSC(NPR),XV1(LX),YV1(LY),SMX(LX),SMY(LY),
2 SX1(10),SY1(10),NL(20),XINT(20),XSD(NPR),YSD(NPR),
3 SMD(LX),XVE(IPE),XVW(IPW),YVS(JPS),YVN(JPN),XVT(IPT),
4 YVT(JPT),SX2(10),SY2(10)
COMMON DSMX(LX),DSMY(LY),XSN(NPR),YSN(NPR),XSS(NPR),
1 YSS(NPR),ISCN(NPR),JSCN(NPR),ISCS(NPR),JSCS(NPR)
2 ,KT(LX),DSMD(LX),T(IP,JP),DSM0(LX),LSTPS(NSEC),LSTPN(NSEC)
COMMON XCN(NX),YCN(NX),XCS(NX),YCS(NX),XCE(NY),YCE(NY),
1 XCW(NY),YCW(NY),XC(NX,NY),YC(NX,NY),XCL(NX,3*JP),
2 YCL(NX,3*JP),XCLD(3*JP),YCLD(3*JP),LSTPE(NSEC),LSTPW(NSEC),
3 LSTP(NSEC),ISHP(NSEC),X1(NSEC),Y1(NSEC),X2(NSEC),Y2(NSEC),
4 THT(NSEC),IARC(NSEC),IFLG(IP,JP),NPIS(NX)
COMMON ELN(NX,NY),ELS(NX,NY),COSNX(NX,NY),COSNY(NX,NY),
1 COSNZ(NX,NY),COSSX(NX,NY),COSSY(NX,NY),COSSZ(NX,NY)
COMMON NS,NI,NIM1,NJ,NJM1,NP,MI,MJ,NMD,NST,NRT,ISE,ISW,JSN,JSS
1 ,NIW,NIE,NIT,NJS,NJN,NJT,ISMX,NSCS,NSCN,LSCS,LSCN >>

when i debug it with "intel visual fortran composer XE 2011" i receive many errors like:

Error 1 error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: <IDENTIFIER> C:\Users\mohammad\Desktop\fortran\mesh\mesh\mesh.f90 2

Error 2 error #5082: Syntax error, found ',' when expecting one of: <END-OF-STATEMENT> ; C:\Users\mohammad\Desktop\fortran\mesh\mesh\mesh.f90 3

Error 3 error #5276: Unbalanced parentheses C:\Users\mohammad\Desktop\fortran\mesh\mesh\mesh.f90 4

Error 4 error #5082: Syntax error, found ',' when expecting one of: BLOCK BLOCKDATA PROGRAM MODULE TYPE BYTE CHARACTER CLASS DOUBLE DOUBLECOMPLEX ... C:\Users\mohammad\Desktop\fortran\mesh\mesh\mesh.f90 4

Error 5 error #5082: Syntax error, found ')' when expecting one of: , <END-OF-STATEMENT> ; C:\Users\mohammad\Desktop\fortran\mesh\mesh\mesh.f90 4

and many other. now i have one questions:

Is this code in another version if fortran like 77...? i mean that i should change my compiler??? if yes how i can download and access it??

0 Kudos
4 Replies
DavidWhite
Valued Contributor II
473 Views

This looks like Fortran 77 fixed format code, except that it appears to have lost the spacing on the lines - not sure whether this happened when you posted the code, or it is wrong in your source.

All of the code should start in column 7, except where you have the continuation lines, (1, 2, 3, etc), where this continuation number must be in column 6.

Also, you need to have the file named as *.for, so that the compiler recognizes that it is fixed format (.f90, etc implied free format).

David

0 Kudos
jimdempseyatthecove
Honored Contributor III
474 Views

What you posted is not only not formatted correctly, it is an incomplete program. Reformatted to fixed form (name it with .for file type)

      PROGRAM CSTGRD
      PARAMETER(IP=51,JP=100,NX=35,NY=61,LX=500,LY=500,IPW=25,IPE=25,
     1 JPS=25,JPN=25,JPT=(JPS+JP+JPN),IPT=(IPW+IP+IPE)
     2 ,NPR=(10*(NX+NY-2)+1),NSEC=10)
      COMMON XV(IP),YV(JP),XS(NPR),YS(NPR),IS(NPR),JS(NPR),
     1 ISC(NPR),JSC(NPR),XV1(LX),YV1(LY),SMX(LX),SMY(LY),
     2 SX1(10),SY1(10),NL(20),XINT(20),XSD(NPR),YSD(NPR),
     3 SMD(LX),XVE(IPE),XVW(IPW),YVS(JPS),YVN(JPN),XVT(IPT),
     4 YVT(JPT),SX2(10),SY2(10)
      COMMON DSMX(LX),DSMY(LY),XSN(NPR),YSN(NPR),XSS(NPR),
     1 YSS(NPR),ISCN(NPR),JSCN(NPR),ISCS(NPR),JSCS(NPR)
     2 ,KT(LX),DSMD(LX),T(IP,JP),DSM0(LX),LSTPS(NSEC),LSTPN(NSEC)
      COMMON XCN(NX),YCN(NX),XCS(NX),YCS(NX),XCE(NY),YCE(NY),
     1 XCW(NY),YCW(NY),XC(NX,NY),YC(NX,NY),XCL(NX,3*JP),
     2 YCL(NX,3*JP),XCLD(3*JP),YCLD(3*JP),LSTPE(NSEC),LSTPW(NSEC),
     3 LSTP(NSEC),ISHP(NSEC),X1(NSEC),Y1(NSEC),X2(NSEC),Y2(NSEC),
     4 THT(NSEC),IARC(NSEC),IFLG(IP,JP),NPIS(NX)
      COMMON ELN(NX,NY),ELS(NX,NY),COSNX(NX,NY),COSNY(NX,NY),
     1 COSNZ(NX,NY),COSSX(NX,NY),COSSY(NX,NY),COSSZ(NX,NY)
      COMMON NS,NI,NIM1,NJ,NJM1,NP,MI,MJ,NMD,NST,NRT,ISE,ISW,JSN,JSS
     1 ,NIW,NIE,NIT,NJS,NJN,NJT,ISMX,NSCS,NSCN,LSCS,LSCN 

Note, program statements (PROGRAM, PARAMETER, COMMON) begin on column 7 (no tabs), and continuation lines begin on column 6 (no tabs).

However there is no code (computation statements), and not END to end the PROGRAM.

Jim Dempsey

0 Kudos
mohammad_f_
Beginner
474 Views

thank you Mr White and Mr Dempsey

this code is only a part of my main code. original code has .f extension. if you see that the line number doesn't start in 7th column, it's because of writing the code in text format and pasting above. I debug my code with g77. I give from it some files as an output. by i don't know how to show the output files. because the files shows my geometry.

0 Kudos
mecej4
Honored Contributor III
474 Views

You seem to be under the impression that the suffix in the filename (.f, .for, .f90) signifies that the code in the file is matched to a particular Fortran standard (.for for Fortran 77, .f90 for Fortran 90, etc.).

That impression is incorrect. There are only two types of Fortran source files -- fixed format and free format, and the type is indicated by the filename suffix.

Simply rename the file "mesh.f90" as "mesh.f", and compile, as David White already suggested.

When you post code, use the {...} button on the tool bar or attach the file, so that the file is represented exactly.

0 Kudos
Reply