[Nek5000-users] Averaging *.f files

nek5000-users at lists.mcs.anl.gov nek5000-users at lists.mcs.anl.gov
Fri Jul 9 20:07:14 CDT 2010


> Hi Paul, Aleks
>
> Thanks for the reply. But I would still have to average the blah.fnnnn files
> after the avg_all call ?
> Say , I have 100 of those avg, rms and rm2 files, I would then have to use
> this avg.c file to complete the averaging process.
> To do so, I compiled the avg.c and created a file with the list of
> blah.fnnnn files and executed it, but I couldn't succeed. Any thoughts
> on where I am going wrong ?
>
> Regards
> Shriram


Hi Shriram,

Correct - you would still have to average them.   I don't know
about avg.c or even if we have anything in place at the moment
to handle the .f files (We'll get this straightened out in the
next few months.)

I would handle it by using nek to do the averaging.  Call the
following routine from userchk.   It will automatically exit
after reading a list of files from "file.list" and dumping
the average of the results.  Modify the code if you want 
weighted averages.

Note that it doesn't average the pressure.   If you want to
do that, it's probably best to compile _this_ code with lx2=lx1
(even if your run was done with lx2=lx1-2).


Paul

c-----------------------------------------------------------------------
       subroutine load_and_avg_data
       include 'SIZE'
       include 'TOTAL'
       include 'ZPER'  ! for nelx,nely,nelz

       parameter (ltt=lx1*ly1*lz1*lelt)
       common /scrnz/ avx(ltt),avy(ltt),avz(ltt),avt(ltt,ldimt)


       character*80 fname,s80
       character*1  fnam1(80)
       equivalence (fname,fnam1)

       n      = nx1*ny1*nz1*nelt
       call opzero(avx,avy,avz)
       call rzero (avt,ltt*ldimt)

       ierr = 0
       if (nid.eq.0) open(unit=55,file='file.list',status='old',err=9991)
       ierr = iglmax(ierr,1)
       if (ierr.gt.0)
      $   call exitti('Problem w/ file.list in .usr file.$',ierr)


c>>   Get the Input Data:

       icount = 0
       n_old_files = 10000
       do ifile=1,n_old_files

          call blank(s80,80)

          iend=0
          if (nid.eq.0) then
             read(55,80,end=100) s80
    80       format(a80)
             write(6,81) ifile,s80
    81       format(i4,' Opening: ',a80)
             goto 110
   100       iend=1
   110       continue
          endif

          iend=iglmax(iend,1)
          if (iend.gt.0) goto 1000

          call bcast(s80,80)
          call chcopy(initc,s80,80)

          nfiles = 1
          call restart(nfiles)

c>>>>    Average the Input Data:

          icount = icount+1
          call opadd2(avx,avy,avz,vx,vy,vz)
          do k=1,ldimt
             call add2(avt(1,k),t(1,1,1,1,k),n)
          enddo

       enddo
  1000 continue


c>>>> Rescale (for average)

       scale = 1./icount
       call cmult2(vx,avx,scale,n)
       call cmult2(vy,avy,scale,n)
       call cmult2(vz,avz,scale,n)
       do k=1,ldimt
          call cmult2(t(1,1,1,1,k),avt(1,k),scale,n)
       enddo

       ifxyo =.true.
       call outpost(vx,vy,vz,pr,t,'   ')
       call exitti('exiting AVG routine$',icount)

       return

  9991 continue

       if (nid.eq.0) then
          ierr = 1
          ierr = iglmax(ierr,1)
          call exitti('Problem w/ file.list in .usr file.$',ierr)
       endif

       return
       end
c-----------------------------------------------------------------------



More information about the Nek5000-users mailing list