program nc2nc ! ! read netCDF *.nc file and write it back out as another *.nc file. ! This is useful for debuging the netcdf read and write routines. ! ! to invoke on the cray c-90, must first load netcdf module: ! module load netcdf ! ! (c) Copyright 1991 to 1998 by Michael A. Beer, William D. Dorland, ! P. B. Snyder, Q. P. Liu, and Gregory W. Hammett. ALL RIGHTS RESERVED. ! use itg_data use io use mp, only: init_mp, finish_mp, broadcast, proc0 use command_line implicit none include 'netcdf.inc' character filename_nc*80 character filename_nc2*80 integer net,ncnt,iou,status,ndum1,ndum2, ilen real tim,dt1 logical binary_res integer icount, ierr real cpu_time0, cpu_time1, cpu_time call init_mp ! initialize MPI ! determine the name of the input and output files: if(proc0) then icount=iargc() if(icount >= 2) then call cl_getarg(1,filename_nc,ilen,ierr) call cl_getarg(2,filename_nc2,ilen,ierr) else goto 99 endif endif call broadcast(filename_nc) call broadcast(filename_nc2) net=0 ncnt=0 ndum1 = 1 ndum2 = 1 ! Read the netcdf file cpu_time0=second() call wreadnc(filename_nc, net, ncnt, tim, dt1, ndum1, ndum2) cpu_time1=second() cpu_time=cpu_time1-cpu_time0 write(*,*) cpu_time,' CPU seconds to read ', filename_nc net=0 ncnt=0 ! Write the output *.nc file cpu_time0=second() call wpunchnc(filename_nc2, net, ncnt, tim, dt1) cpu_time1=second() cpu_time=cpu_time1-cpu_time0 write(*,*) cpu_time,' CPU seconds to write ', filename_nc2 call finish_mp ! finish MPI stop 99 write(*,*) 'ERROR.' write(*,*) 'ERROR.' write(*,*) 'Usage: nc2nc file1.nc file2.nc' write(*,*) ' will convert netCDF file1.nc into netCDF file2.nc' stop end program nc2nc