Only write dimension coordinates if the dimension is actually defined