C This program reads a real number and prints it back out. The C program also remembers the "state" it is in and changes state if C there was an error reading the input. The total number of states C is specified by the variable "numsts". C..... program shell implicit none real a integer state, numsts, num C..... C a = variable that is set by read operation C state = current "state" or mode of the program C numsts = the total number of possible states (the state numbers go C from zero to numsts-1) C num = status of the read operation stored here C..... state = 0 numsts = 5 10 read(5,*,iostat=num) a if (num .eq. 0) then print *, 'my state is ',state,' and you entered ', a elseif (num .lt. 0) then stop else state = mod(state+1,numsts) print *, 'I''ve changed state to state ',state endif goto 10 stop end