Writes out N_ports as well as n_ports