added optional ncid parameter throughout the interface
TODO/CHECK: propagate parameter to subfunctions for speed gain