Mayk Pire
Mayk Pire

Reputation: 11

Fortran 95 Missing expression error

300      do i=1,counter


open(1,file='Pcow_pd.txt')
write(1,*),Sw_pd(i), Pcow_pd(i)
open(2,file='Krw_pd.txt')
write(2,*),Sw_pd(i), Krw_pd(i)
open(3,file='Kro_pd.txt')
write(3,*),Sw_pd(i), Kro_pd(i)

print*, counter

end do   
print *,"filled =",filled

When I compile the code I get an error message at write lines which I cannot fix

Compile error: error 573 - Missing expression

Upvotes: 1

Views: 733

Answers (1)

francescalus
francescalus

Reputation: 32366

As has been commented, there should be no comma before the list of items for output. You should simply have

write(1,*) Sw_pd(i), Pcow_pd(i)

and so on.

The later line

print*, counter

where the comma before counter is absolutely necessary, may add a little confusion on writing. This is perhaps increased by how read is used: there are two forms:

read *, x
read (*,*) y

The first example without an explicit statement of unit implies the same unit as the * in the second and it requires a comma. The second must not have a comma.

A simple way to remember whether the output list has a comma first: if the format comes in isolation use the comma; if the unit is specified, don't.

Upvotes: 2

Related Questions