program res2nc ! read ascii *.res or binary *.resb file and convert to a netcdf *.nc 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, ilen integer :: nsteps, nfile, n 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_res,ilen,ierr) call cl_getarg(2,filename_nc,ilen,ierr) else goto 99 ! goto usage statement 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 nsteps=1 nfile = 1 ! Read the existing *.res or *.resb file cpu_time0=second() if(binary_res) then call bwread(filename_res,net,ncnt,tim,dt1,nsteps, nfile) else call wread(filename_res,net,ncnt,tim,dt1,nsteps, nfile) endif cpu_time1=second() write(*,*) cpu_time1-cpu_time0,' CPU seconds to read ', filename_res net=0 ncnt=0 ! Write the netcdf file cpu_time0=second() call wpunchnc(filename_nc, net, ncnt, tim, dt1) cpu_time1=second() write(*,*) cpu_time1-cpu_time0,' CPU seconds to write ', filename_nc call finish_mp ! finish MPI stop 99 write(*,*) 'ERROR.' write(*,*) 'Usage: res2nc file1.res file2.nc' write(*,*) ' will convert ascii file1.res into netCDF file2.nc' write(*,*) 'Usage: res2nc file1.resb file2.nc' write(*,*) ' will convert binary file1.resb into netCDF file2.nc' stop end program res2nc