Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 ディスカッション

Unformatted reading

rafadix08
ビギナー
373件の閲覧回数
Hi,
I am reading a .csv filein fortran but I am not being able to read my last variable. I guess I have to increase some parameter, but I don't know which one.
Here is my code:


open(unit = 1 , file = 'initial_conditions.csv')
read(1,*)
do
read(1,*,IOSTAT=status) n, first_year_data(n), born_data(n), age_data(n), educ_data(n), gender_data(n), &
choice_data(n,first_year_data(n)) , choice_data(n,first_year_data(n)-1), &
choice_data(n,first_year_data(n)-2), choice_data(n,first_year_data(n)-3), &
choice_data(n,first_year_data(n)-4), choice_data(n,first_year_data(n)-5), &
choice_data(n,first_year_data(n)-6), choice_data(n,first_year_data(n)-7), &
choice_data(n,first_year_data(n)-8), choice_data(n,first_year_data(n)-9), &
wage_data(n,first_year_data(n))
if (status /= 0 ) exit
end do
close(1)

All the variables read are declared as integer but the last one, which is declared as real. All the variables are read correctly but the last one, where I get zeros everywhere.

Here are a few lines of the file I am reading from

6,1995,1935,60,2,2,4,4,4,4,4,4,4,4,4,4,0,0,0,9,17.200000017
7,1995,1935,60,2,1,4,4,4,4,4,4,4,4,4,4,0,0,0,9,15.700000016
8,1995,1935,60,4,1,4,4,4,4,4,4,4,4,4,4,0,0,0,9,71.250000071
9,1995,1935,60,4,2,4,4,4,4,4,4,4,4,4,0,0,0,0,8,249.90000025
10,1995,1935,60,2,1,4,4,4,4,4,4,4,4,4,4,0,0,0,9,34.725000035

Thanks a lot,
Rafael
0 件の賞賛
1 返信
Steven_L_Intel1
従業員
373件の閲覧回数
I count 21 values in each line but only 19 items in the READ.
返信