!private subroutine flushblock(unit, iostat) integer, intent(in):: unit integer, intent(out):: iostat if (info(unit)%hot) then call writeblock(unit, info(unit)%cached%blk, info(unit)%buf, iostat) info(unit)%hot = .false. else iostat = 0 endif end subroutine !private subroutine fetchblock(unit, i, iostat) integer, intent(in):: unit, i integer, intent(out):: iostat call set_buffer(unit, iostat) if (iostat /= 0) return if (info(unit)%cur%blk == i) return call flushblock(unit, iostat) if (iostat /= 0) return call readblock(unit, i, info(unit)%buf, iostat) end subroutine
This pair of routines are written at the viewpoint of buffer management, instead of top-down approach from read/write. I believe that such a inversion of viewpoint is important in programming.
スポンサーサイト