Ncrename is used to rename variables in a netCDF file.
In many CCR files, precipitation-evaporation is named P-E. However, GrADS and many other software packages will not recognize variables with a minus sign in them. So in order to look at P-E, it must be renamed.
The following command will change the name P-E to PME. The file GEN2AGCM-CONB-MONE0509.rename.nc will be identical to GEN2AGCM-CONB-MONE0509.nc except that P-E will be named PME.
Download the file: GEN2AGCM-CONB-SEAE0509.nc
Download the file metadata/header information (retrieved via ncdump -h): GEN2AGCM-CONB-SEAE0509.ncdump.txt
ncrename -v P-E,PME GEN2AGCM-CONB-MONE0509.nc GEN2AGCM-CONB-MONE0509.rename.nc
If you wanted to, you could write over the original file and not create a new file:
ncrename -v P-E,PME GEN2AGCM-CONB-MONE0509.nc
Ncrename can also be used to rename coordinate variables such as latitude and longitude. This is a little trickier because these latitude and longitude are both dimensions and variables within a file. Therefore, you have to rename both the dimension and and the variable.
Rename latitude and longitude to lat and lon, respectively, using the same file as above, GEN2AGCM-CONB-SEAE0509.nc:
ncrename -d longitude,lon -d latitude,lat -v longitude,lon -v latitude,lat GEN2AGCM-CONB-MONE0509.nc GEN2AGCM-CONB-SEAE0509.rename2.nc