C..... C Subroutine to write raw output files. Input array may be a two- C or three-dimensional array. C..... subroutine wrtraw(nframe,istart,iend,ihop,jstart,jend,jhop, & koffst,base,field,ilead,jlead,ijob,xmax) implicit real (a-h,o-z) real field(*) 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 i,j = dummy loop counters C ipnt = record pointer for output file C ndigit = number of digits in current frame number C Input variables: C field = two- or three-dimensional array C ilead,jlead = number of rows (x) and columns (y) in array C base = base name of output files C nframe = frame number C istart,jstart = starting points in first and second "directions" C iend,jend = ending points in first and second "directions" C ihop,jhop = strides in first and second "directions" C koffst = offset in third "direction" C ijob = job number C ijob = 0 -> field is a 2D array C output = f(istart <= i <= iend, jstart <= j <= jend) C "x" coordinate corresponds to i C "y" coordinate corresponds to j C koffst and jlead have no affect C ijob = 1 -> field is a 3D array, output over constant x plane C output = f(koffst, istart <= i <= iend, jstart <= j <= jend) C "x" = koffst C "y" coordinate corresponds to i C "z" coordinate corresponds to j C ijob = 2 -> field is a 3D array, output over constant y plane C output = f(istart <= i <= iend, koffst, jstart <= j <= jend) C "x" coordinate corresponds to i C "y" = koffst C "z" coordinate corresponds to j C ijob = 3 -> field is a 3D array, output over constant z plane C output = f(istart <= i <= iend, jstart <= j <= jend, koffst) C "x" coordinate corresponds to i C "y" coordinate corresponds to j C "z" = koffst 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)+0.01) + 1 C.....Construct the proper format 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.....Open the output file and write header info. open(68,file=filnam,status='new',form='unformatted', & access='direct',recl=4,err=2000) write(68,rec=1)real((iend-istart)/ihop + 1) write(68,rec=2)real((jend-jstart)/jhop + 1) C..... C Loop through writing of data. The first entry is for the upper C left corner, the next is for the next column over, etc. C..... ipnt=2 ijlead = ilead*jlead if (ijob .eq. 0) then C........Two-dimensional array. do 20 j=jend,jstart,-jhop do 10 i=istart,iend,ihop ipnt=ipnt + 1 indx = (j-1)*ilead + i if(abs(field(indx)).gt.xmax) & xmax=abs(field(indx)) write(68,rec=ipnt)field(indx) 10 continue 20 continue elseif (ijob .eq. 1) then C........Three-dimensional array. Constant x plane. i = koffst do 120 k=jend,jstart,-jhop koff = (k-1)*ijlead do 110 j=istart,iend,ihop joff = (j-1)*ilead ipnt=ipnt + 1 indx = koff + joff + i if(abs(field(indx)).gt.xmax) & xmax=abs(field(indx)) write(68,rec=ipnt)field(indx) 110 continue 120 continue elseif (ijob .eq. 2) then C........Three-dimensional array. Constant y plane. joff = (koffst-1)*ilead do 220 k=jend,jstart,-jhop koff = (k-1)*ijlead do 210 i=istart,iend,ihop ipnt=ipnt + 1 indx = koff + joff + i if(abs(field(indx)).gt.xmax) & xmax=abs(field(indx)) write(68,rec=ipnt)field(indx) 210 continue 220 continue else C........Three-dimensional array. Constant z plane. koff = ijlead*(koffst-1) do 320 j=jend,jstart,-jhop joff = (j-1)*ilead do 310 i=istart,iend,ihop ipnt=ipnt + 1 indx = koff + joff + i if(abs(field(indx)).gt.xmax) & xmax=abs(field(indx)) write(68,rec=ipnt)field(indx) 310 continue 320 continue endif close(68) return 2000 write(6,*)'Error opening output file in wrtraw.' stop end