Two ways to implement a netCDF copy program for classic files:
create empty target file add dimensions and global attributes to target for each variable in the source file add the variable definition to the target file copy the variable's attributes to target copy the variable's data to the target
create empty target file add dimensions and global attributes to target add all the variable definitions to the target file copy all the variable attributes to target for each variable in the source file copy the variable's data to the target
Timings for using method 1 on a 44 MByte WRF model output (with about 100 variables):
real 3m3.40s user 0m8.03s sys 0m28.29s
Timings for using method 2 on same WRF model output:
real 0m3.76s 49 x faster user 0m0.42s sys 0m0.95s
NetCDF-4 note:
Since netCDF-4 files do not have a
contiguous header, schema additions are efficient.
Timings for method 1 but creating the empty target file as a netCDF-4 classic model file:
real 0m5.75s 32 x faster user 0m1.00s sys 0m1.29s