作者bestman8556 (廷廷)
看板Fortran
标题[问题] 读档特定区域一问
时间Mon Nov 19 17:24:13 2012
这是我的data长样:
2012/xx/xx abcdefgxxxxxxxxxxx(表示有问字叙述)
abcdefgxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
12 1234 4567
55 4321 7654
.. .... ....
.. .... ....
.. .... ....
^^^ ^^ ^^
档案中"^"表示有空白的存在
目前已经试过下列方法:
open(unit=10, file='filename.txt')
100 format(
2/,5X,I6)
200 format(I6)
read(10,100) a
write(*,200) a
程式码中黄色的2字可以成功跳过2012/xx/xx以及文字叙述那两列
但因为某些需求黄色文字的部分想要用一个变数取代
就像是
E=12
100 format(
E/,5X,I6)
但执行结果他都要求我必须以一个constant or general expreesion
来表示我大写
E的部分
请求解...............QQ
PS:我有试过另一个方法用open(access='direct',recl=
?)
问号的部分我不知道到底要用甚麽长度分才正确..........
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.115.120.35
1F:推 hiyiyi:1.write(fmtstr,*) E,'/,5X,I6' & read(10,fmtstr) a 11/19 17:52
2F:→ hiyiyi:或2.回圈跳行 do i=1,E & read(10,"(A)") linestr & end do 11/19 17:55
3F:→ bestman8556:h大的第一种方法是说 11/19 18:44
4F:→ bestman8556:用write(字串格式,*) E,'/,5X,I6' 来拼凑出一个字串 11/19 18:46
5F:→ bestman8556:然後写入100 format() 里面吗? 我一值尝试不成功 11/19 18:46
6F:→ bestman8556:在写出write(字串格式,*) E,'/,5X,I6' 这部分出问题. 11/19 18:50
7F:→ bestman8556:解决了~~~ 谢谢~~~~ 11/19 23:17