Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where statement

Status
Not open for further replies.

Levay87

Programmer
Jun 12, 2016
6
DE
Hello,
thanks a lot for your help. Now I have to apply rules.
All (T) are marked become (X).
All h(H) become (T)

Why it does not run?
Here is my code:

program exercise10
implicit none

character,dimension(3,3)::arr1=reshape((/"#","#","T","#","H","T","#","#","#"/),(/3,3/))

write(*,*) "Exersice10: ", arr1

where (arr1=T) arr1="X"
write(*,*) arr1
elsewhere (arr1=H) arr1="T"
wirte(*,*) arr1
end where

end program exercise10
 
Does it even compile?

In the where statement = is assignment, == is a test for equality.
You can't use a write statement in a where clause.
You don't have variables T and H: are these meant to be "T" and "H"?
 
Compilation failed.

Yes, these meant to be "T" and "H".

It tried this. But it does not run.

where (arr1=="T") arr1=="X"
write(*,*) arr1
elsewhere (arr1=="H") arr1=="T"
wirte(*,*) arr1
end where

Need help
please!
 
You can't use a write statement in a where clause
 
ok. But this also does not run ;(


where (arr1=="T")
arr1=="X"
where (arr1=="H")
arr1=="T"
endwhere
endwhere
 
I found the solution! THX a lot!


where ( arr1=="T" )
arr1="X"
where ( arr1=="H" )
arr1="T"
Endwhere
endwhere
 
You could use
Code:
where (arr1=="T")
   arr1 = "X"
elsewhere (arr1 == "H")
   arr1 = "T"
end where
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top