Fortran Coder

标题: 紧急求助,固定格式与自由格式的问题 [打印本页]

作者: lmbh2014    时间: 2014-10-9 15:14
标题: 紧急求助,固定格式与自由格式的问题
分别采用NVT和NPT模拟出当T*=1.65时,LJ流体的状态方程并进行比较
用FORTRAN编写的时候总是有错误,恳请高手指教,非常感谢。

NPT.zip

10.74 KB, 下载次数: 4


作者: 楚香饭    时间: 2014-10-9 15:30
请给出源码,错误提示
作者: lmbh2014    时间: 2014-10-9 16:21
楚香饭 发表于 2014-10-9 15:30
请给出源码,错误提示

谢谢您,代码说是超过1000字,回复不了。错误是:
--------------------Configuration: rty - Win32 Debug--------------------
Compiling Fortran...
F:\fortran programs\rty\agsdf.for
f90: Error: Illegal character in statement label field  [P]
f90: Error: Illegal character in statement label field  [R]
f90: Error: Illegal character in statement label field  [O]
f90: Error: Illegal character in statement label field  [G]
f90: Error: Illegal character in statement label field  [R]
f90: Error: First statement in file must not be continued
F:\fortran programs\rty\agsdf.for(1) : Error: Syntax error, found END-OF-STATEMENT when expecting one of: ( : % . = =>
PROGRAM MCNVT
-------------^
F:\fortran programs\rty\agsdf.for(357) : Error: Illegal character in statement label field  [=]
   = '',F10.6)') FLP
---^
F:\fortran programs\rty\agsdf.for(357) : Error: Syntax error, found REAL_CONSTANT '.6' when expecting one of: ( * , ) + . - % . ** / // =
   = '',F10.6)') FLP
-----------^
F:\fortran programs\rty\agsdf.for(84) : Error: Executable statements are invalid within the BLOCK DATA unit.
        WRITE(*,'(1H1,'' **** PROGRAM MCLJ ****                  ''/)')
--------^
F:\fortran programs\rty\agsdf.for(76) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [TITLE]
        CHARACTER   TITLE*80, CNFILE*30
--------------------^
F:\fortran programs\rty\agsdf.for(67) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [DRMAX]
        REAL        DRMAX, DENS, TEMP, DENSLJ, SIGMA, RMIN, RCUT, BETA
--------------------^
F:\fortran programs\rty\agsdf.for(67) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [DENS]
        REAL        DRMAX, DENS, TEMP, DENSLJ, SIGMA, RMIN, RCUT, BETA
---------------------------^
F:\fortran programs\rty\agsdf.for(67) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [TEMP]
        REAL        DRMAX, DENS, TEMP, DENSLJ, SIGMA, RMIN, RCUT, BETA
---------------------------------^
F:\fortran programs\rty\agsdf.for(67) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [DENSLJ]
        REAL        DRMAX, DENS, TEMP, DENSLJ, SIGMA, RMIN, RCUT, BETA
---------------------------------------^
F:\fortran programs\rty\agsdf.for(67) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [SIGMA]
        REAL        DRMAX, DENS, TEMP, DENSLJ, SIGMA, RMIN, RCUT, BETA
-----------------------------------------------^
F:\fortran programs\rty\agsdf.for(67) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [RMIN]
        REAL        DRMAX, DENS, TEMP, DENSLJ, SIGMA, RMIN, RCUT, BETA
------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(67) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [RCUT]
        REAL        DRMAX, DENS, TEMP, DENSLJ, SIGMA, RMIN, RCUT, BETA
------------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(67) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [BETA]
        REAL        DRMAX, DENS, TEMP, DENSLJ, SIGMA, RMIN, RCUT, BETA
------------------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(68) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [DUMMY]
        REAL        RANF, DUMMY, ACM, ACATMA, PI, RATIO, SR9, SR3
--------------------------^
F:\fortran programs\rty\agsdf.for(68) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [ACM]
        REAL        RANF, DUMMY, ACM, ACATMA, PI, RATIO, SR9, SR3
---------------------------------^
F:\fortran programs\rty\agsdf.for(68) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [ACATMA]
        REAL        RANF, DUMMY, ACM, ACATMA, PI, RATIO, SR9, SR3
--------------------------------------^
F:\fortran programs\rty\agsdf.for(68) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [RATIO]
        REAL        RANF, DUMMY, ACM, ACATMA, PI, RATIO, SR9, SR3
--------------------------------------------------^
F:\fortran programs\rty\agsdf.for(68) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [SR9]
        REAL        RANF, DUMMY, ACM, ACATMA, PI, RATIO, SR9, SR3
---------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(68) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [SR3]
        REAL        RANF, DUMMY, ACM, ACATMA, PI, RATIO, SR9, SR3
--------------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(69) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [V]
        REAL        V, VNEW, VOLD, VEND, VN, DELTV, DELTVB, VS
--------------------^
F:\fortran programs\rty\agsdf.for(69) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [VNEW]
        REAL        V, VNEW, VOLD, VEND, VN, DELTV, DELTVB, VS
-----------------------^
F:\fortran programs\rty\agsdf.for(69) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [VOLD]
        REAL        V, VNEW, VOLD, VEND, VN, DELTV, DELTVB, VS
-----------------------------^
F:\fortran programs\rty\agsdf.for(69) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [VEND]
        REAL        V, VNEW, VOLD, VEND, VN, DELTV, DELTVB, VS
-----------------------------------^
F:\fortran programs\rty\agsdf.for(69) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [VN]
        REAL        V, VNEW, VOLD, VEND, VN, DELTV, DELTVB, VS
-----------------------------------------^
F:\fortran programs\rty\agsdf.for(69) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [DELTV]
        REAL        V, VNEW, VOLD, VEND, VN, DELTV, DELTVB, VS
---------------------------------------------^
F:\fortran programs\rty\agsdf.for(69) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [DELTVB]
        REAL        V, VNEW, VOLD, VEND, VN, DELTV, DELTVB, VS
----------------------------------------------------^
F:\fortran programs\rty\agsdf.for(69) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [VS]
        REAL        V, VNEW, VOLD, VEND, VN, DELTV, DELTVB, VS
------------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(70) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [W]
        REAL        W, WEND, WNEW, WOLD, PRES, DELTW, WS, PS
--------------------^
F:\fortran programs\rty\agsdf.for(70) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [WEND]
        REAL        W, WEND, WNEW, WOLD, PRES, DELTW, WS, PS
-----------------------^
F:\fortran programs\rty\agsdf.for(70) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [WNEW]
        REAL        W, WEND, WNEW, WOLD, PRES, DELTW, WS, PS
-----------------------------^
F:\fortran programs\rty\agsdf.for(70) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [WOLD]
        REAL        W, WEND, WNEW, WOLD, PRES, DELTW, WS, PS
-----------------------------------^


作者: lmbh2014    时间: 2014-10-9 16:21
楚香饭 发表于 2014-10-9 15:30
请给出源码,错误提示

F:\fortran programs\rty\agsdf.for(70) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [PRES]
        REAL        W, WEND, WNEW, WOLD, PRES, DELTW, WS, PS
-----------------------------------------^
F:\fortran programs\rty\agsdf.for(70) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [DELTW]
        REAL        W, WEND, WNEW, WOLD, PRES, DELTW, WS, PS
-----------------------------------------------^
F:\fortran programs\rty\agsdf.for(70) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [WS]
        REAL        W, WEND, WNEW, WOLD, PRES, DELTW, WS, PS
------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(70) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [PS]
        REAL        W, WEND, WNEW, WOLD, PRES, DELTW, WS, PS
----------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(71) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [VLRC]
        REAL        VLRC, VLRC6, VLRC12, WLRC, WLRC6, WLRC12
--------------------^
F:\fortran programs\rty\agsdf.for(71) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [VLRC6]
        REAL        VLRC, VLRC6, VLRC12, WLRC, WLRC6, WLRC12
--------------------------^
F:\fortran programs\rty\agsdf.for(71) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [VLRC12]
        REAL        VLRC, VLRC6, VLRC12, WLRC, WLRC6, WLRC12
---------------------------------^
F:\fortran programs\rty\agsdf.for(71) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [WLRC]
        REAL        VLRC, VLRC6, VLRC12, WLRC, WLRC6, WLRC12
-----------------------------------------^
F:\fortran programs\rty\agsdf.for(71) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [WLRC6]
        REAL        VLRC, VLRC6, VLRC12, WLRC, WLRC6, WLRC12
-----------------------------------------------^
F:\fortran programs\rty\agsdf.for(71) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [WLRC12]
        REAL        VLRC, VLRC6, VLRC12, WLRC, WLRC6, WLRC12
------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(72) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [RXIOLD]
        REAL        RXIOLD, RYIOLD, RZIOLD, RXINEW, RYINEW, RZINEW
--------------------^
F:\fortran programs\rty\agsdf.for(72) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [RYIOLD]
        REAL        RXIOLD, RYIOLD, RZIOLD, RXINEW, RYINEW, RZINEW
----------------------------^
F:\fortran programs\rty\agsdf.for(72) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [RZIOLD]
        REAL        RXIOLD, RYIOLD, RZIOLD, RXINEW, RYINEW, RZINEW
------------------------------------^
F:\fortran programs\rty\agsdf.for(72) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [RXINEW]
        REAL        RXIOLD, RYIOLD, RZIOLD, RXINEW, RYINEW, RZINEW
--------------------------------------------^
F:\fortran programs\rty\agsdf.for(72) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [RYINEW]
        REAL        RXIOLD, RYIOLD, RZIOLD, RXINEW, RYINEW, RZINEW
----------------------------------------------------^
F:\fortran programs\rty\agsdf.for(72) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [RZINEW]
        REAL        RXIOLD, RYIOLD, RZIOLD, RXINEW, RYINEW, RZINEW
------------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(73) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [AVV]
        REAL        AVV, AVP, AVW, ACV, ACP, ACVSQ, ACPSQ, FLV, FLP
--------------------^
F:\fortran programs\rty\agsdf.for(73) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [AVP]
        REAL        AVV, AVP, AVW, ACV, ACP, ACVSQ, ACPSQ, FLV, FLP
-------------------------^
F:\fortran programs\rty\agsdf.for(73) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [AVW]
        REAL        AVV, AVP, AVW, ACV, ACP, ACVSQ, ACPSQ, FLV, FLP
------------------------------^
F:\fortran programs\rty\agsdf.for(73) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [ACV]
        REAL        AVV, AVP, AVW, ACV, ACP, ACVSQ, ACPSQ, FLV, FLP
-----------------------------------^
F:\fortran programs\rty\agsdf.for(73) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [ACP]
        REAL        AVV, AVP, AVW, ACV, ACP, ACVSQ, ACPSQ, FLV, FLP
----------------------------------------^
F:\fortran programs\rty\agsdf.for(73) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [ACVSQ]
        REAL        AVV, AVP, AVW, ACV, ACP, ACVSQ, ACPSQ, FLV, FLP
---------------------------------------------^
F:\fortran programs\rty\agsdf.for(73) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [ACPSQ]
        REAL        AVV, AVP, AVW, ACV, ACP, ACVSQ, ACPSQ, FLV, FLP
----------------------------------------------------^
F:\fortran programs\rty\agsdf.for(73) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [FLV]
        REAL        AVV, AVP, AVW, ACV, ACP, ACVSQ, ACPSQ, FLV, FLP
-----------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(73) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [FLP]
        REAL        AVV, AVP, AVW, ACV, ACP, ACVSQ, ACPSQ, FLV, FLP
----------------------------------------------------------------^
F:\fortran programs\rty\agsdf.for(74) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [STEP]
        INTEGER     STEP, I, NSTEP, IPRINT, ISAVE, IRATIO
--------------------^
F:\fortran programs\rty\agsdf.for(74) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [I]
        INTEGER     STEP, I, NSTEP, IPRINT, ISAVE, IRATIO
--------------------------^
F:\fortran programs\rty\agsdf.for(74) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [NSTEP]
        INTEGER     STEP, I, NSTEP, IPRINT, ISAVE, IRATIO
-----------------------------^
F:\fortran programs\rty\agsdf.for(74) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [IPRINT]
        INTEGER     STEP, I, NSTEP, IPRINT, ISAVE, IRATIO
------------------------------------^
F:\fortran programs\rty\agsdf.for(74) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [ISAVE]
        INTEGER     STEP, I, NSTEP, IPRINT, ISAVE, IRATIO
--------------------------------------------^
F:\fortran programs\rty\agsdf.for(74) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [IRATIO]
        INTEGER     STEP, I, NSTEP, IPRINT, ISAVE, IRATIO
---------------------------------------------------^
F:\fortran programs\rty\agsdf.for(75) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [OVRLAP]
        LOGICAL     OVRLAP
--------------------^
F:\fortran programs\rty\agsdf.for(76) : Info: Symbol in BLOCK DATA program unit is not in a COMMON block.   [CNFILE]
        CHARACTER   TITLE*80, CNFILE*30
------------------------------^
Error executing df.exe.

rty.exe - 10 error(s), 0 warning(s)
作者: fcode    时间: 2014-10-9 16:27
看起来你的源代码是自由格式的。而你使用了固定格式的扩展名 (for)试试改成 f90 扩展名。

如果还有问题,你可以上传源代码作为附件。
作者: lmbh2014    时间: 2014-10-9 16:36
fcode 发表于 2014-10-9 16:27
看起来你的源代码是自由格式的。而你使用了固定格式的扩展名 (for)试试改成 f90 扩展名。

如果还有问题 ...

请问f90的拓展名是什么?我们研一新开分子模拟课,不太明白。
作者: fcode    时间: 2014-10-9 16:39
你现在的文件名是 agsdf.for,改成 agsdf.f90 然后重新编译
作者: lmbh2014    时间: 2014-10-9 17:48
fcode 发表于 2014-10-9 16:39
你现在的文件名是 agsdf.for,改成 agsdf.f90 然后重新编译

非常感谢。我输入了一个特别简单的程序,都有错误。代码:
      PROGRAM mc


      do icyc1=1,ncycl
        call mcmove
          if (mod(icyc1,nsamp).eq.0)
        +  call sample
        enddo
        end

错误信息:--------------------Configuration: hai - Win32 Debug--------------------
Compiling Fortran...
F:\fortran programs\hai\ad.f90
F:\fortran programs\hai\ad.f90(6) : Error: Syntax error, found END-OF-STATEMENT when expecting one of: BLOCK BLOCKDATA PROGRAM TYPE COMPLEX BYTE CHARACTER DOUBLE DOUBLECOMPLEX ...
   if (mod(icyc1,nsamp).eq.0)
------------------------------------^
F:\fortran programs\hai\ad.f90(7) : Error: Syntax error, found '+' when expecting one of: <LABEL> <END-OF-STATEMENT> ; BLOCK BLOCKDATA PROGRAM TYPE COMPLEX BYTE CHARACTER ...
+  call sample
--------^
Error executing df.exe.

hai.exe - 2 error(s), 0 warning(s)

作者: 楚香饭    时间: 2014-10-9 17:58
[Fortran] 纯文本查看 复制代码
PROGRAM mc
       do icyc1=1,ncycl
         call mcmove
           if (mod(icyc1,nsamp).eq.0) call sample  !// 写成一行既可
         enddo
         end

作者: lmbh2014    时间: 2014-10-9 18:13
楚香饭 发表于 2014-10-9 17:58
[mw_shl_code=fortran,true]PROGRAM mc
       do icyc1=1,ncycl
         call mcmove

请问这个是什么意思呢:--------------------Configuration: hahaha - Win32 Debug--------------------
Compiling Fortran...
F:\fortran programs\hahaha\haah.f90
F:\fortran programs\hahaha\haah.f90(2) : Warning: Variable NCYCL is used before its value has been defined
       do icyc1=1,ncycl
------------------^
F:\fortran programs\hahaha\haah.f90(4) : Warning: Variable NSAMP is used before its value has been defined
           if (mod(icyc1,nsamp).eq.0) call sample  
-------------------------^
Linking...
haah.obj : error LNK2001: unresolved external symbol _MCMOVE@0
haah.obj : error LNK2001: unresolved external symbol _SAMPLE@0
Debug/hahaha.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

hahaha.exe - 3 error(s), 2 warning(s)
作者: 楚香饭    时间: 2014-10-9 18:16
Warning: Variable NCYCL is used before its value has been defined
变量 NCYCL 没有定义和符值,就开始使用。

unresolved external symbol _MCMOVE@0
找不到函数 MCMOVE

unresolved external symbol _SAMPLE@0
与上一个类同

遇到错误,请先阅读本站文章,常见错误:http://error.w.fcode.cn

作者: lmbh2014    时间: 2014-10-9 18:18
楚香饭 发表于 2014-10-9 18:16
Warning: Variable NCYCL is used before its value has been defined
变量 NCYCL 没有定义和符值,就开始 ...

太感谢您了。学哥。
作者: lmbh2014    时间: 2014-10-9 18:21
lmbh2014 发表于 2014-10-9 18:18
太感谢您了。学哥。

请问我上传的那个附件可以解答这道题吗?
作者: 楚香饭    时间: 2014-10-9 18:26
论坛允许直接上传源代码文件,例如 *.for *.f90 等,不需要复制粘贴到 word 里

你的附件在我这里可以正常编译链接并执行。

1 **** PROGRAM MCLJ ****

CONSTANT-NVT MONTE CARLO PROGRAM
FOR LENNARD JONES ATOMS
ENTER THE RUN TITLE

然后就要求输入了。我不知道如何输入,没法进行下一步。




欢迎光临 Fortran Coder (http://bbs.fcode.cn/) Powered by Discuz! X3.2