C.....Subroutine to write the output. subroutine wrtraw(nframe,istart,iend,ihop,jstart,jend,jhop, & base,field,ilead,xmax) implicit real (a-h,o-z) real field(ilead,*) character filnam*1024, base*(*), frmt*30 C..... C Local variables: C frmt = internal file used to construct output file name C ilen = number of non-blank characters in the base name C idum,jdum = dummy loop counters C ipnt = record pointer for output file C ndigit = number of digits in current frame number C Input variables: C field,ilead = two dimensional array with leading dimension ilead C base = base name of output files C nframe = frame number (assumed set by calling program) C istart,jstart = starting column and row for output C iend,jend = ending column and row for output C ihop,jhop = column and row strides C Output variable: C xmax = largest absolute value of output C..... C.....Determine the location of last character in the base name. ilen = index(base,' ') - 1 C.....Calculate the number of digits in the current frame number. ndigit = log10(real(nframe)+.01) + 1 C.....Construct the proper format field for the desired output file name. write(frmt,'(a2,i4,a5,i9,a1)')'(a',ilen,',a1,i',ndigit,')' C.....Put this together to obtain the proper output file name. write(filnam,frmt)base,'.',nframe C..... C Open the output file with the proper format and write header info. C ppm files assume data is written in the order that it would C appear in a page of a book -- the first entry is for the C upper left corner, the next is for the next column over, etc. C..... C.....****** One-shot approach with one "mombo" write statement. C Some compilers may not like the record length (but I haven't C encountered any that have complained yet). ****** C..... length = 4*(((iend-istart)/ihop+1)*((jend-jstart)/jhop+1)+2) open(68,file=filnam,status='new',form='unformatted', & access='direct',recl=length,err=2000) C.....Loop through data looking for min and max. do jdum=jend,jstart,-jhop do idum=istart,iend,ihop if(abs(field(idum,jdum)).gt.xmax)xmax=abs(field(idum,jdum)) enddo enddo write(68,rec=1)real((iend-istart)/ihop + 1), & real((jend-jstart)/jhop + 1), & ((real(field(idum,jdum)), & idum=istart,iend,ihop), & jdum=jend,jstart,-jhop) close(68) return 2000 write(6,*)'Error opening multiple output files.' stop end C------------------------ end of subroutine wrtraw -----------------------