0

nc_open(input_file.c_str(), NC_NOWRITE , &ncid)

Here the input_file is the file path. The file is opening only when the netcdf file is placed in the bin folder where the executable is present. When the netcdf file(.nc) is not placed in the bin folder then the netcdf file does not open. why is this happening?

1 Answers1

0

The /bin folder stand for binary and your complied program is usually located in this folder. If you passes in "file.txt" as the file name, the program will find the file "file.txt" in the folder where the program itself locates.

C:\
  |- proj\
         |- bin\
               |- program.exe [open("test.txt")]--\
               |- file.txt     <------------------/

If you want to access the file at a location, you should pass in the absolute path (eg. C:\test.txt) in the input_file

C:\
  |- proj\
  |      |- bin\
  |            |- program.exe [open("C:\\test.txt")]
  |- file.txt     <--------------------|
iLittleWizard
  • 385
  • 2
  • 12
  • yes i did that as well, i put the absolute file path in the nc open function but still i am facing the same problem. – Keith Barretto Mar 10 '22 at 07:20
  • There are many files that needs checking to be done but the thing is that i can't place all the files into the bin folder. I need to access the files from an external drive by giving its absolute path. – Keith Barretto Mar 10 '22 at 07:24