Add a couple of diagnostic figures at the end of the function for sanity checking the function. Also change the way the open boundary nodes are index by using the same approach as is in the code to generate the Casename_obc.dat file. This should avoid problems where the interpolated arrays store the data in a different order from how FVCOM is expecting it (I am assuming here that FVCOM assumes the order of boundary nodes specified in Casename_obc.dat will be common across all input data which use the open boundary nodes. This seems sensible to me)
Change the way the open boundary nodes are obtained to match that which is in the code which generates Casename_obc.dat. This should stop problems with ordering values in the input arrays where the manner in which the list of open boundary nodes are generated in different ways resulting in different output orders