Hello, I'm encountering some issues with creating an idealized grid for my ROMS model using MATLAB scripts from [https://www.myroms.org/wiki/Grid_Processing_Scripts](https://www.myroms.org/wiki/Grid_Processing_Scripts). When attempting the `c_contact("grid_ideal.nc",1,1)` command, I encountered the error "The NetCDF library encountered an error during execution of 'defDim' function - 'NC_UNLIMITED size already in use (NC_EUNLIMIT)'. Do I need to use this command for an existing file, or can I create a new file with this command?
Additionally, when trying to build the grid based on an existing grid created by my coworker using the "grid_perimeter.m" function, I encountered an error with the message:
```
Error using fclose
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in nc_interface (line 101)
fclose(fid);
Error in nc_getatt (line 61)
[method,~,~] = nc_interface(ncfile);
Error in grid_perimeter (line 154)
Attributes = nc_getatt(G(ng).grid_name);
```
I suspect this is due to the same issue of "grid_ideal.nc" not being an existing file. While the problem is resolved when using the name of an existing file, I would like to create a new file. How can I fix this issue?
Lastly, when using the "write_contact(G.grid_name,S,G);" function, a similar error to the one encountered with `c_contact` appears:
```
Error using matlab.internal.imagesci.netcdflib
The NetCDF library encountered an error during execution of
'defDim' function - 'NC_UNLIMITED size already in use
(NC_EUNLIMIT)'.
Error in netcdf.defDim (line 31)
dimid = matlab.internal.imagesci.netcdflib('defDim', ncid,dimname,dimlen);
Error in c_contact (line 62)
Did.datum = netcdf.defDim(ncid, 'datum' ,Ndatum);
Error in write_contact (line 70)
c_contact(ncname, spherical, Ngrids, Ndatum);
```
I'm uncertain how to address all these problems. Can anyone provide assistance? Thank you!
Issues Encountered in Creating ROMS Model Grid by Matlab: Seeking Assistance
Re: Issues Encountered in Creating ROMS Model Grid by Matlab: Seeking Assistance
c_contact.m is for creating the contact file for two nested grids once the two grid files are already made, so I don't follow why you would be running that routine when you say you are trying to create a grid anew.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu
Re: Issues Encountered in Creating ROMS Model Grid by Matlab: Seeking Assistance
I think I got what you mean. I've been trying to create a new gid. Is there a Matlab function for me to create it?
Additionally, I've seen that "write_contact.m" is also for a nested grid. So I was confused is there a function for helping me to write the grid I've made to save as the nc file I need to run in ROMS?
Thank you so much for your help.
Additionally, I've seen that "write_contact.m" is also for a nested grid. So I was confused is there a function for helping me to write the grid I've made to save as the nc file I need to run in ROMS?
Thank you so much for your help.