I have now solved the problem I faced. thought I would just document my progress here for anyone who faces a similar problem in the future. Summarizing:
- .m files that ship with the download in croco_tools have netcdf call that Octave (also matlab) doesn’t consider correct syntax (as in my post here). They need to be switched to the syntax in the documentation: netcdf.create, netcdf.open, netcdf.putVar etc.
- Octave (here I haven’t tried Matlab) reads and writes the variables in the reverse order of appearance. For example:
nc=netcdf.open(grdname,“NC_NOWRITE”);
id_lonr=netcdf.inqVarID(nc, “lon_rho”);
nclonr = netcdf.getVar(nc, id_lonr);
returns an array of size(xi_rho, eta_rho) even though it is stored as (eta_rho, xi_rho) in the netdcf file. SO , a reversal.
- The writing is also reversed. For example:
var_u_s = netcdf.defVar(nc, “u_south”, ‘NC_DOUBLE’, [dim_xi_u dim_s_rho dim_v3dt]);
is the declaration to create a variable with dimensions [dim_v3dt, s_rho, xi_u].
And entering values into it also has to be performed in the same order (Reverse of what the downloaded files have)
- Specifically to Benguela: The external data files do not have Attributes add offset and scale factor and the code defaults it to NaN if the value is not found. This returns an NaN array.
Additionally, a missing_value attribute is declared (say -1e9) but the data contains other garbage values for example -5e04. This needs to be cleaned up.
Once these steps are carried out, the case works. I am still a little confused/surprised as to this not being a topics discussed/ pointed out previously on the forum and makes me wonder if I am doing something very seriously wrong.
PS. I drew these conclusions after comparing the preproc files I generated with the preproc files available for download for the benguela case. Thanks to the developers for having those available
I hope this will help someone, or I get feedback on something I am doing seriously wrong