[英]open a file in Fortran
我想在 Fortran 中打開兩個文件,但得到以下錯誤消息:
Fortran 運行時錯誤:行尾
infile_T 包含從 1970 年到 2100 年的年份和這些年份的溫度值。 Infile_CO2 包含相同時間段的年份和 CO2 值。 我只想加載 1970 年到 1998 年的年份和溫度值。
這是我的代碼:
integer j,p, Jahre_CO2
character*20 infile_T, infile_CO2
parameter(infile_T='temp2m.obs',
1 infile_CO2='yco2.sze',
1 anfja=0,
1 endja=29,
1 nt=endja-anfja+1)
real T_beob(anfja:endja),Jahre_T, CO2_beob(anfja:endja)
open(11,file=infile_T)
do ja=anfja,endja
read(11,*) Jahre_T,T_beob(ja)
enddo
close(11)
print *,Jahre_T
open(12, file=infile_CO2)
do p=anfja,endja
read(12,*) Jahre_CO2,CO2_beob(p)
enddo
close(12)
write(6,*) 'Daten eingelesen !',T_beob
確保您的文件包含您希望它們包含的所有數據。 如果您的文件包含 130 行,而您只讀取 30 行,那么您不應該收到文件結束錯誤。
檢查數據的格式。 通常“年”(Jahre)是整數; 所以你有 Jahre_CO2 作為 integer,但 Jahre_T 是真實的——仔細檢查一下。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.