| 查看: 723 | 回复: 2 | ||
csu_cheng木虫 (正式写手)
|
[求助]
很简单的一段代码,求助fortran大神
|
|
程序很简单,首先得到当前日期,然后与老文件pmain1-save.f90中的‘linkdate=’后面的日期位置,并在pmain.f90新文件中更改‘linkdate=’为当前日期。 无论pmain1-save.f90和pmain.f90中写的是什么,都会出现段错误信息。编译环境win10 64位, gcc 5.1。 源代码如下: program linkocdate ! extract current date and inserts it in the source code of the main program character date*8,mdate*12,line*60 call date_and_time(date) mdate="'"//date(1:4)//'-'//date(5:6)//'-'//date(7:8)//"'" !write(*,*) mdate open(21,file='pmain1-save.F90',access='sequential',status='old') open(22,file='pmain1.F90',access='sequential',status='unknown') 100 continue read(21,110,end=200)line k=index(line,'linkdate=') !find the location of 'linkdate=' in 21 if(k.gt.0) then line(k+9: )=mdate !write(*,*)line(1:40) endif write(22,110)line(1:len_trim(line)) 110 format(a) goto 100 200 continue close(21) close(22) stop end program linkocdate |
» 猜你喜欢
情人节自我反思:在爱情中有过遗憾吗?
已经有10人回复
今年春晚有几个节目很不错,点赞!
已经有7人回复
基金正文30页指的是报告正文还是整个申请书
已经有5人回复
过年走亲戚时感受到了所开私家车的鄙视链
已经有5人回复
wxws.2008
木虫 (正式写手)
- 应助: 5 (幼儿园)
- 金币: 5015.5
- 散金: 256
- 红花: 9
- 帖子: 354
- 在线: 147.9小时
- 虫号: 639701
- 注册: 2008-10-29
- 性别: GG
- 专业: 荒漠化与水土保持
2楼2015-12-01 18:40:32
csu_cheng
木虫 (正式写手)
- 应助: 1 (幼儿园)
- 金币: 3039.7
- 散金: 23
- 红花: 1
- 帖子: 528
- 在线: 193.9小时
- 虫号: 923006
- 注册: 2009-12-08
- 专业: 金属材料的合金相、相变及
3楼2015-12-02 20:24:44













回复此楼