program nc2res ! read a netCDF *.nc file and converts to an ascii *.res file. ! to invoke on the cray c-90, must first load netcdf module: ! module load netcdf use itg_data use io implicit none include 'netcdf.inc' ! someday will replace the above with an f90 module to enable dynamic ! array allocation. character filename*80 integer net,ncnt,iou,status,ndum1,ndum2 real tim,dt1 integer iargc,icount external iargc, getarg real second,cpu_time0, cpu_time1 c determine the name of the input file: icount=iargc() if(icount .ge. 1) then call getarg(1,runname) else write(6,*) 'Usage: nc2res RUN' write(6,*) ' will convert ascii RUN.res into netCDF RUN.nc' endif lrunname=index(runname,' ')-1 net=0 ncnt=0 ndum1 = 1 ndum2 = 1 filename=runname(1:lrunname)//'.nc' 10 STATUS = nf_open(filename, 0, iou) ! read only IF (STATUS .NE. NF_NOERR) then PRINT *, NF_STRERROR(STATUS) print *, ' ' print *, 'Enter filename (with extension):' read *, filename goto 10 endif cpu_time0=second() call wreadnc(iou, net, ncnt, tim, dt1, ndum1, ndum2) cpu_time1=second() status = nf_close(iou) IF (STATUS .NE. NF_NOERR) PRINT *, NF_STRERROR(STATUS) write(*,*) cpu_time1-cpu_time0,' seconds to read ', filename net=0 ncnt=0 filename=runname(1:lrunname)//'.res' open(unit=iou,file=filename,status='unknown') cpu_time0=second() call wpunch(iou,net,ncnt,tim,dt1) cpu_time1=second() close(unit=iou) write(*,*) cpu_time1-cpu_time0,' seconds to write ', filename stop end