看懂就好,呵呵。不辛苦,这论坛的帖子不多。 |
fcode 发表于 2014-6-26 13:16 我明白了,上面的程序我看懂了。多谢管理员。 |
fcode 发表于 2014-6-26 13:16 那你岂不是很辛苦,哈哈。还有一个问题。 [Fortran] 纯文本查看 复制代码 subroutine intoch ( cvar, ivar, ilend) c*********************************************************************** c* * c* PURPOSE: Write integer left-justified into character variable * c* * c* ARGUMENTS: CVAR - character variable receiving integer * c* IVAR - integer to write into character * c* ILEND - obsolete * c* * c*********************************************************************** c---- Dummy arguments character*(*) cvar integer ivar, ilend c-- Local working storage character cform*5 integer ilen, ivara c---- Find required length to write IVAR, including sign ivara = abs(ivar) ilen = 1 mag = 10 do 100 i=1,10 if (ivara.lt.mag) go to 200 ilen = ilen + 1 100 mag = mag * 10 200 if (ivar.lt.0) ilen = ilen + 1 c---- Write IVAR into CVAR, left justified. If CVAR length is not c enough, FORTRAN error handling is used ('*****') ilen = min(ilen,len(cvar)) write (cform,'(a,i2,a)') '(I',ilen,')' cvar = ' ' write (cvar,cform) ivar return end 倒数第三行,为什么cform也写到了格式的位置,难道是按照cform的格式表示ivar,然后将值赋给cvar? |
是的,我加的。不用你编辑。 |
fcode 发表于 2014-6-26 13:06 多谢管理员!话说这个已解决是你加上去的吗,我还以为需要发帖本人修改帖子状态呢。 |
是的。你的错误就是字符串不够长。 |
fcode 发表于 2014-6-26 12:13 就等同于把其他类型变量的值转成字符型然后赋值,这样理解可以吗?所以你上面例子中的c的长度一定要大于或等于6. |
这是内部文件的用法。表示把其他类型的变量,输出到字符串里。 (你可以认为这个字符串是一个存在于内部的“文件”) unit -5 , file Internal Formatted Write 表示你的错误正是“内部文件”出现的问题。 |
fcode 发表于 2014-6-25 18:04 write的格式不应该是WRITE(设备号,输出格式)吗,用字符占据设备号的位置是什么意思?并且我运行了一下,没有输出任何东西。 |
捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )
GMT+8, 2025-4-20 03:31