Dear Mat,
I am sorry you are having trouble with generating the analytical grid netcdf file. I tested your code with my version of the routine rgrd_AnaGrid and I was able to generate the grid netcdf file. I strongly suspect that there is an issue with your netcdf toolbox installation. Here is a short video of my test:
https://www.dropbox.com/s/rjd4b10mztqw3 ... naGrid.mov
To check your netcdf toolbox installation, please try in MATLAB to execute the command:
If you do not have this code or if this code gives you an empty file, this will confirm that we need to fix the netcdf installation. Otherwise the issue may be more settle. I am posting here the version of the rgrd_AnaGrid I have, just in case.
Let me know how it goes.
Best wishes,
Manu
Code: Select all
function CreateGridFile(Lp,Mp,filename)
% FUNCTION CreateGridFile(Lp,Mp,filename)
% Creates an empty grid file of dimension Lp x Lm
%
% 05/03 E. Di Lorenzo (edl@gatech.edu)
%Mp=44;
%Lp=92;
M=Mp-1;
Mm=Mp-2;
L=Lp-1;
Lm=Lp-2;
nc = netcdf(filename, 'clobber');
%% Global attributes:
nc.type = ncchar('Gridpak file');
nc.gridid = ncchar(' ');
nc.history = ncchar('Created by E. Di Lorenzo ');
%% Dimensions:
nc('xi_psi') = L;
nc('xi_rho') = Lp;
nc('xi_u') = L;
nc('xi_v') = Lp;
nc('eta_psi') = M;
nc('eta_rho') = Mp;
nc('eta_u') = Mp;
nc('eta_v') = M;
nc('two') = 2;
nc('bath') = 1; %% (record dimension)
%% Variables and attributes:
nc{'xl'} = ncdouble; %% 1 element.
nc{'xl'}.long_name = ncchar('domain length in the XI-direction');
nc{'xl'}.units = ncchar('meter');
nc{'el'} = ncdouble; %% 1 element.
nc{'el'}.long_name = ncchar('domain length in the ETA-direction');
nc{'el'}.units = ncchar('meter');
nc{'depthmin'} = ncshort; %% 1 element.
nc{'depthmin'}.long_name = ncchar('Shallow bathymetry clipping depth');
nc{'depthmin'}.units = ncchar('meter');
nc{'depthmax'} = ncshort; %% 1 element.
nc{'depthmax'}.long_name = ncchar('Deep bathymetry clipping depth');
nc{'depthmax'}.units = ncchar('meter');
nc{'spherical'} = ncchar; %% 1 element.
nc{'spherical'}.long_name = ncchar('Grid type logical switch');
nc{'spherical'}.option_T = ncchar('spherical');
nc{'spherical'}.option_F = ncchar('Cartesian');
nc{'hraw'} = ncdouble('bath', 'eta_rho', 'xi_rho'); %% 2068 elements.
nc{'hraw'}.long_name = ncchar('Working bathymetry at RHO-points');
nc{'hraw'}.units = ncchar('meter');
nc{'hraw'}.field = ncchar('bath, scalar');
nc{'h'} = ncdouble('eta_rho', 'xi_rho'); %% 2068 elements.
nc{'h'}.long_name = ncchar('Final bathymetry at RHO-points');
nc{'h'}.units = ncchar('meter');
nc{'h'}.field = ncchar('bath, scalar');
nc{'f'} = ncdouble('eta_rho', 'xi_rho'); %% 2068 elements.
nc{'f'}.long_name = ncchar('Coriolis parameter at RHO-points');
nc{'f'}.units = ncchar('second-1');
nc{'f'}.field = ncchar('Coriolis, scalar');
nc{'pm'} = ncdouble('eta_rho', 'xi_rho'); %% 2068 elements.
nc{'pm'}.long_name = ncchar('curvilinear coordinate metric in XI');
nc{'pm'}.units = ncchar('meter-1');
nc{'pm'}.field = ncchar('pm, scalar');
nc{'pn'} = ncdouble('eta_rho', 'xi_rho'); %% 2068 elements.
nc{'pn'}.long_name = ncchar('curvilinear coordinate metric in ETA');
nc{'pn'}.units = ncchar('meter-1');
nc{'pn'}.field = ncchar('pn, scalar');
nc{'x_rho'} = ncdouble('eta_rho', 'xi_rho'); %% 2068 elements.
nc{'x_rho'}.long_name = ncchar('x location of RHO-points');
nc{'x_rho'}.units = ncchar('meter');
nc{'y_rho'} = ncdouble('eta_rho', 'xi_rho'); %% 2068 elements.
nc{'y_rho'}.long_name = ncchar('y location of RHO-points');
nc{'y_rho'}.units = ncchar('meter');
nc{'x_psi'} = ncdouble('eta_psi', 'xi_psi'); %% 1953 elements.
nc{'x_psi'}.long_name = ncchar('x location of PSI-points');
nc{'x_psi'}.units = ncchar('meter');
nc{'y_psi'} = ncdouble('eta_psi', 'xi_psi'); %% 1953 elements.
nc{'y_psi'}.long_name = ncchar('y location of PSI-points');
nc{'y_psi'}.units = ncchar('meter');
nc{'x_u'} = ncdouble('eta_u', 'xi_u'); %% 2046 elements.
nc{'x_u'}.long_name = ncchar('x location of U-points');
nc{'x_u'}.units = ncchar('meter');
nc{'y_u'} = ncdouble('eta_u', 'xi_u'); %% 2046 elements.
nc{'y_u'}.long_name = ncchar('y location of U-points');
nc{'y_u'}.units = ncchar('meter');
nc{'x_v'} = ncdouble('eta_v', 'xi_v'); %% 1974 elements.
nc{'x_v'}.long_name = ncchar('x location of V-points');
nc{'x_v'}.units = ncchar('meter');
nc{'y_v'} = ncdouble('eta_v', 'xi_v'); %% 1974 elements.
nc{'y_v'}.long_name = ncchar('y location of V-points');
nc{'y_v'}.units = ncchar('meter');
nc{'lat_rho'} = ncdouble('eta_rho', 'xi_rho'); %% 2068 elements.
nc{'lat_rho'}.long_name = ncchar('latitude of RHO-points');
nc{'lat_rho'}.units = ncchar('degree_north');
nc{'lon_rho'} = ncdouble('eta_rho', 'xi_rho'); %% 2068 elements.
nc{'lon_rho'}.long_name = ncchar('longitude of RHO-points');
nc{'lon_rho'}.units = ncchar('degree_east');
nc{'lat_psi'} = ncdouble('eta_psi', 'xi_psi'); %% 1953 elements.
nc{'lat_psi'}.long_name = ncchar('latitude of PSI-points');
nc{'lat_psi'}.units = ncchar('degree_north');
nc{'lon_psi'} = ncdouble('eta_psi', 'xi_psi'); %% 1953 elements.
nc{'lon_psi'}.long_name = ncchar('longitude of PSI-points');
nc{'lon_psi'}.units = ncchar('degree_east');
nc{'lat_u'} = ncdouble('eta_u', 'xi_u'); %% 2046 elements.
nc{'lat_u'}.long_name = ncchar('latitude of U-points');
nc{'lat_u'}.units = ncchar('degree_north');
nc{'lon_u'} = ncdouble('eta_u', 'xi_u'); %% 2046 elements.
nc{'lon_u'}.long_name = ncchar('longitude of U-points');
nc{'lon_u'}.units = ncchar('degree_east');
nc{'lat_v'} = ncdouble('eta_v', 'xi_v'); %% 1974 elements.
nc{'lat_v'}.long_name = ncchar('latitude of V-points');
nc{'lat_v'}.units = ncchar('degree_north');
nc{'lon_v'} = ncdouble('eta_v', 'xi_v'); %% 1974 elements.
nc{'lon_v'}.long_name = ncchar('longitude of V-points');
nc{'lon_v'}.units = ncchar('degree_east');
nc{'mask_rho'} = ncdouble('eta_rho', 'xi_rho');
nc{'mask_rho'}.long_name = ncchar('mask on RHO-points');
nc{'mask_rho'}.long_name = 'mask on RHO-points';
nc{'mask_rho'}.option_0 = ncchar('land');
nc{'mask_rho'}.option_0 = 'land';
nc{'mask_rho'}.option_1 = ncchar('water');
nc{'mask_rho'}.option_1 = 'water';
nc{'mask_u'} = ncdouble('eta_u', 'xi_u');
nc{'mask_u'}.long_name = ncchar('mask on U-points');
nc{'mask_u'}.long_name = 'mask on U-points';
nc{'mask_u'}.option_0 = ncchar('land');
nc{'mask_u'}.option_0 = 'land';
nc{'mask_u'}.option_1 = ncchar('water');
nc{'mask_u'}.option_1 = 'water';
nc{'mask_v'} = ncdouble('eta_v', 'xi_v');
nc{'mask_v'}.long_name = ncchar('mask on V-points');
nc{'mask_v'}.long_name = 'mask on V-points';
nc{'mask_v'}.option_0 = ncchar('land');
nc{'mask_v'}.option_0 = 'land';
nc{'mask_v'}.option_1 = ncchar('water');
nc{'mask_v'}.option_1 = 'water';
nc{'mask_psi'} = ncdouble('eta_psi', 'xi_psi');
nc{'mask_psi'}.long_name = ncchar('mask on PSI-points');
nc{'mask_psi'}.long_name = 'mask on PSI-points';
nc{'mask_psi'}.option_0 = ncchar('land');
nc{'mask_psi'}.option_0 = 'land';
nc{'mask_psi'}.option_1 = ncchar('water');
nc{'mask_psi'}.option_1 = 'water';
%nc{'angle'} = ncdouble('eta_rho', 'xi_rho'); %% 2068 elements.
%nc{'angle'}.long_name = ncchar('angle between xi axis and east');
%nc{'angle'}.units = ncchar('degree');
endef(nc)
close(nc)