# netCDF error number -51 processing file

**URL:** <https://forum.cmascenter.org/t/netcdf-error-number-51-processing-file/4026>\
**Category:** SMOKE\
**Created:** [March 28, 2023, 3:33pm UTC](https://forum.cmascenter.org/t/netcdf-error-number-51-processing-file/4026 "2023-03-28T15:33:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Hu](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@Jason\_Hu](https://forum.cmascenter.org/u/Jason_Hu)\
**Post date:** [March 28, 2023, 3:33pm UTC](https://forum.cmascenter.org/t/netcdf-error-number-51-processing-file/4026/1 "2023-03-28T15:33:19Z")

</div>

Dear all,

I get an error as shown below when I use SMOKE ‘speciate’ to deal with emission file. I tried another file named b.ncf and succeeded. a.ncf is copied from b.ncf. I don’t know what’s the difference between these two files except the variables values.  
[b.ncf.txt](https://forum.cmascenter.org/uploads/short-url/2fRQAxcus4bryq8oNQc3HCxf49t.txt) (7.0 KB)  
[a.ncf.txt](https://forum.cmascenter.org/uploads/short-url/yxZPVBI3bBdSWW8WD96iumGdCZ4.txt) (6.5 KB)

Value for PROMPTFLAG not defined;returning default: TRUE  
Enter logical name for 2-D AND 3-D GRIDDED INPUTS list [FILELIST] \>\>filelist

```
 File "filelist" opened for input on unit: 99
 filelist

 Value for MRG_DIFF_DAYS not defined;returning default: FALSE
 Mrggrid compiled with I/O API MXVARS3 = 2048
 Error opening file at path-name:
 netCDF error number -51 processing file "a.nc"
 NetCDF: Unknown file format
 NetCDF: Unknown file format
 a.nc
 Could not open file "a.nc".
 
 *** ERROR ABORT in subroutine MRGGRID
 Ending program "MRGGRID".

```

---

<div class="post-metadata">

**Author:** ![hogrefe.christian](https://avatars.discourse-cdn.com/v4/letter/h/74df32/32.png) [@hogrefe.christian](https://forum.cmascenter.org/u/hogrefe.christian)\
**Post date:** [March 28, 2023, 3:50pm UTC](https://forum.cmascenter.org/t/netcdf-error-number-51-processing-file/4026/2 "2023-03-28T15:50:12Z")

</div>

> [@Jason\_Hu](#):
>
> a.ncf is copied from b.ncf

How was this done exactly, and which tool(s) were involved in the generation of a.ncf?

What does `ncdump -k a.ncf` and `ncdump -k b.ncf` show?

The reason for asking these questions is that there is a possibility that the tool(s) used to generate a.ncf created the file using the netcdf-4 / “enhanced” data model while the SMOKE executable was compiled with an underlying netcdf library that only supported the classic data model (i.e. without netcdf-4 support). ncdump -k will show which netcdf data model is used in the file.

---

<div class="post-metadata">

**Author:** ![Jason\_Hu](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@Jason\_Hu](https://forum.cmascenter.org/u/Jason_Hu)\
**Post date:** [March 29, 2023, 4:03pm UTC](https://forum.cmascenter.org/t/netcdf-error-number-51-processing-file/4026/3 "2023-03-29T16:03:02Z")

</div>

Hi Hogrefe,

Yes, b.ncf was created using classic netcdf format, while a.ncf was created using netcdf4. BTW, could you tell how to compile SMOKE with supporting netcdf4?

Thanks,  
Jason

---

<div class="post-metadata">

**Author:** ![cjcoats](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@cjcoats](https://forum.cmascenter.org/u/cjcoats)\
**Post date:** [March 29, 2023, 4:22pm UTC](https://forum.cmascenter.org/t/netcdf-error-number-51-processing-file/4026/4 "2023-03-29T16:22:32Z")

</div>

Run the netCDF commands

> `nf-config --libs`  
> `nc-config --libs`  
> and add the resulting libraries after the `-lnetcdff -lnetcdf` in the _Makefile_ system.

---

<div class="post-metadata">

**Author:** ![hogrefe.christian](https://avatars.discourse-cdn.com/v4/letter/h/74df32/32.png) [@hogrefe.christian](https://forum.cmascenter.org/u/hogrefe.christian)\
**Post date:** [March 29, 2023, 6:12pm UTC](https://forum.cmascenter.org/t/netcdf-error-number-51-processing-file/4026/5 "2023-03-29T18:12:34Z")

</div>

As an alternative to recompiling netCDF, I/O API, and SMOKE with netCDF4 support, given that your system version of ncdump apparently was generated with netCDF4 support (otherwise you would not have been able to post the header of a.ncf generated by ncdump), you could also convert a.ncf back to classic format with this command `nccopy -k classic a.ncf a1.ncf` and then use a1.ncf as input to SMOKE (nccopy should reside in the same bin directory as ncdump)
