问题描述
在子程序或函数中“读取”(在此代码中通过“i”)后,是否可以在主程序中定义数组维度?
我从这段代码开始(我想将'n'更改为':',可能需要move write语句 到主程序):
module carga
contains
subroutine io
implicit none
integer,parameter :: n = 10
integer,dimension(n) :: dia,mes,ano,hora,minuto
real,dimension(n) :: abs1
character*50 :: formato = '(i2,1x,i2,i4,f7.4)'
integer :: IoUnit,IoUnit2,ierr
integer :: i
!------------------------------------------------------
open(newunit = IoUnit,file = 'datos.txt')
open(newunit = IoUnit2,file = 'salida.txt')
!------------------------------------------------------
read(IoUnit,*)
do
read(unit = IoUnit,fmt = formato,iostat = ierr) dia(i),mes(i),ano(i),hora(i),minuto(i),abs1(i)
if (ierr /= 0) exit
write(unit = IoUnit2,fmt = formato) dia(i),abs1(i)
i = i + 1
end do
end subroutine io
end module carga
!///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
program fecha
use carga
implicit none
call io
end program fecha
我正在使用这个 txt 的内容:
dia mes ano hora min abs1
3 6 2016 0 5 30.4570
3 6 2016 0 10 27.5388
3 6 2016 0 15 23.1983
3 6 2016 0 20 22.3339
3 6 2016 0 25 22.0864
3 6 2016 0 30 20.9339
3 6 2016 0 35 21.8094
3 6 2016 0 40 21.3255
3 6 2016 0 45 22.1972
3 6 2016 0 50 21.2331
3 6 2016 0 55 21.6099
3 6 2016 1 0 20.4057
我不知道该怎么做。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)