first pass moving logic from coarray to runtime