- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I count 21 values in each line but only 19 items in the READ.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page