! !$Author: joelevin $ !$Date: 2011-03-24 11:33:26 -0500 (Thu, 24 Mar 2011) $ !$Revision: 11724 $ !$HeadURL: https://svn.weru.ksu.edu/weru/weps1/trunk/weps.src/src/lib_reports/running_ave.f95 $ ! SUBROUTINE run_ave(pd_ave, new_val, cnt) USE pd_var_type_def IMPLICIT NONE TYPE (pd_var_type), INTENT (IN OUT) :: pd_ave REAL, INTENT (IN) :: new_val INTEGER, INTENT (IN) :: cnt if (cnt == 0) then write(0,*) "cnt is: ", cnt write(0,*) 'cnt error in running_ave' call exit (1) endif pd_ave%val = pd_ave%val * pd_ave%cnt / (pd_ave%cnt+cnt) + & new_val / (pd_ave%cnt+cnt) pd_ave%cnt = pd_ave%cnt + cnt END SUBROUTINE run_ave