Question: How can one give this peculiar netCDF file a proper time axis? 

"time" exists as both a dimension and a variable, 
but the time *variable* uses "serial\ date\ number" as its *dimension*. 

There are two challenges: 
1. the variables vs. dimensions issue; and 
2. "serial\ date\ number" appears to indicate spaces (with backslash delimiters) on some systems, but has underscores ("serial\_date\_number") on other systems. 

```
netcdf 
dimensions:
 lon = 80 ;
 lat = 41 ;
 pres = 27 ;
 time = 12053 ;
 serial\ date\ number = 12053 ;
variables:
 double u_mjo(time, pres, lat, lon) ;
 double lon(lon) ;
 lon:units = "degrees_east" ;
 double lat(lat) ;
 lat:units = "degrees_north" ;
 double p_level(pres) ;
 p_level:units = "hPa" ;
 double time(serial\ date\ number) ;
 time:units = "days since 0000-01-01 00:00 UTC" ;
  ...

```

Answer: 
Here's the procedure that worked for me **using only NCO commands** (no ncdump/manual edit/ncgen step):

Extract 4 time steps from OPeNDAP dataset to local netCDF file `allfields.nc`:

```
   ncks -d time,0,3 -d serial_date_number,0,3
    http://weather.rsmas.miami.edu/repository/opendap/synth:100ae90b-71ac-4d38-add9-f8982a976322:L2FsbGZpZWxkcy5uYw==/entry
    -O allfields.nc

```

Extract the `time` variable into a separate file `time.nc`:

```
ncks -v time allfields.nc time.nc

```

Extract everything *except* the `time` variable to a separate file `fixed.nc` (which also removes the problematic `serial_date_number` dimension`):

```
ncks -C -x -v time allfields.nc fixed.nc

```

Rename the dimension `serial_data_number` to `time`:

```
ncrename -O -d serial_date_number,time time.nc

```

Append the file with fixed time to the file without time:

```
ncks -A time.nc fixed.nc

```

The files I used and created in this workflow may be seen here:
<http://geoport.whoi.edu/thredds/catalog/usgs/data2/rsignell/models/mapes/catalog.html>
On Ubuntu 14.04 I was able to do: 

```
ncrename -v variable\ with\ whitespace,variable_with_whitespace filein.nc fileout.nc

```