c naok method -----------------------------------------------------------------> c /////////////////////////////////////////////////////////////////////> subroutine next_naok(id_flag, naok, id, val, nx, ny) integer naok, id integer nx,ny real val(nx,ny) logical id_flag(nx) if (id_flag(id)) then write(*,*) "this id(", id ,") is already used" else id_flag(id) = .true. naok = naok + 1 val(1, naok) = id endif c use this after checked that your src is correct c naok = naok + 1 c val(1, naok) = id return end c /////////////////////////////////////////////////////////////////////> c initialize id_flag c /////////////////////////////////////////////////////////////////////> subroutine init_id_flag(id_flag, nx) integer nx logical id_flag(nx) integer id do id = 1, nx id_flag(id) = .false. enddo return end c /////////////////////////////////////////////////////////////////////>