program nc2res ! ! read netCDF *.nc file and convert to an ascii *.res or binary *.resb file ! ! 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_res*80 integer net,ncnt,status,ndum1,ndum2, ilen real tim,dt1 logical binary_res integer icount, ierr real cpu_time0, cpu_time1 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_res,ilen,ierr) else goto 99 endif endif call broadcast(filename_nc) call broadcast(filename_res) ! Determine if the output *.res file should be ascii or binary lrunname=index(filename_res,'.resb',back=.true.)-1 binary_res=.true. if(lrunname .lt. 0) then lrunname=index(filename_res,'.res',back=.true.)-1 binary_res=.false. endif if(lrunname .lt. 0) goto 99 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() write(*,*) cpu_time1-cpu_time0,' seconds to read ', filename_nc net=0 ncnt=0 ! Write the output *.res file cpu_time0=second() if(binary_res) then call bwpunch(filename_res,net,ncnt,tim,dt1) else call wpunch(filename_res,net,ncnt,tim,dt1) endif cpu_time1=second() write(*,*) cpu_time1-cpu_time0,' seconds to write ', filename_res call finish_mp ! finish MPI stop 99 write(*,*) 'ERROR.' write(*,*) 'Usage: nc2res file1.nc file2.res' write(*,*) ' will convert netCDF file1.nc into ascii file2.res' write(*,*) 'Usage: nc2res file1.nc file2.resb' write(*,*) ' will convert netCDF file1.nc into binary file2.resb' stop end program nc2res