c----------------------------------------------------------- c Less-commented (i.e. more reasonable level of c comments) version of mysum. c----------------------------------------------------------- c mysum_s: reads numbers one per line from stdin c and writes sum on stdout. Ignores invalid inputs c but counts number encountered and reports on stderr. c----------------------------------------------------------- program mysum implicit none real*8 vi, sum integer rc, nbad nbad = 0 sum = 0.0d0 100 continue read(*,*,iostat=rc,end=200) vi if( rc .eq. 0 ) then sum = sum + vi else nbad = nbad + 1 end if go to 100 200 continue write(*,*) sum if( nbad .gt. 0 ) then write(0,*) nbad, ' invalid inputs' end if stop end