Note if you want to set the input port value you have to use field:set_value() not port:write().