Error in matlab codes

Discussion about analysis, visualization, and collaboration tools and techniques

Moderators: arango, robertson

Post Reply
Message
Author
javadi
Posts: 115
Joined: Mon Jan 27, 2020 5:55 pm
Location: UoT

Error in matlab codes

#1 Unread post by javadi »

I am a user of ROMS. I have faced an error to make forcing when using d_ecmwf2roms.m. I tested many methods to fix the following error; however, I am not able to fix this error. Please help me to solve this error.

Code: Select all

Error using fclose
Invalid file identifier.  Use fopen to generate a valid file identifier.

Error in nc_interface (line 98)
  fclose(fid);

Error in nc_getatt (line 61)
[method,~,~] = nc_interface(ncfile);

Error in nc_inq (line 69)
A = nc_getatt(ncfile);            % NetCDF file global attributes

Error in nc_read (line 77)
Info = nc_inq(ncfile);

Error in d_ecmwf2roms (line 296)
  lon = nc_read(InpFile, 'longitude',

                                   ...

Aminrahdarian
Posts: 7
Joined: Wed Jan 25, 2017 5:26 pm
Location: University Of Waikato

Re: Error in matlab codes

#2 Unread post by Aminrahdarian »

Hi Javad,
Remove directories including netcdf functions added in matlab paths and call nc functions from the toolbox that is available in ROMS repository. It seems that the nc_read function you are using does not match.
Amin

User avatar
wilkin
Posts: 875
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: Error in matlab codes

#3 Unread post by wilkin »

d_ecmwf2rom.m is adapted from code I wrote a long time ago and may not work nicely with new versions of ECMWF outputs.

That said, the particular error you get indicates trouble opening a file, so you should check that it exists and that you've given the correct path. Easiest way is to set a debug stop point in nc_read before line 77 and check interactively the next steps in the code.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

javadi
Posts: 115
Joined: Mon Jan 27, 2020 5:55 pm
Location: UoT

Re: Error in matlab codes

#4 Unread post by javadi »

Hi,
Thank you so much for your cooperation.
Based on the previous comments, I do not understand how to do this Remove directories including netcdf functions added in matlab paths and call nc functions from the toolbox that is available in ROMS repository, please explain more. By the way,After changing some codes, I have faced the following error:
Error: File: nc_read.m Line: 91 Column: 1
This statement is not inside any function.
(It follows the END that terminates the definition of the function "nc_read".)

Error in d_ecmwf2roms (line 296)
lon = nc_read(InpFile, 'longitude',

please help me.

User avatar
wilkin
Posts: 875
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: Error in matlab codes

#5 Unread post by wilkin »

That error it at the call to nc_interface. Read the help on nc_interface. Your system is having trouble figuring out the best method to read netcdf files. Are you running an old version of Matlab? Have you successfully read and written netcdf files before?
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

javadi
Posts: 115
Joined: Mon Jan 27, 2020 5:55 pm
Location: UoT

Re: Error in matlab codes

#6 Unread post by javadi »

Hello
I am new user of ROMS and Matlab. The version of my matlab is 2014a. What is solution? you mean i install new version of matlab?

Post Reply