program sum_r3dv_step ! ********************************************************************** ! * . . . ! * PROGRAM: sum_r3dv_step ! * PRGMMR: M. ZUPANSKI ORG: CIRA/CSU DATE: 2003-09-10 ! * ! * ABSTRACT: STEP-LENGTH RELATED COMPONENTS OF OBSERVATIONAL COST FUNCTION ! * Calculate the inner products for step-length update ! * ! * INPUT: res_trial = R**(-1/2)*(y-Hx) (trial obs residual) ! * res = R**(-1/2)*(y-Hx) (old-previous iteration obs residual) ! * ! * PROGRAM LOG: ! * ! * 09/10/2003 ..... M. ZUPANSKI: ! * ! ********************************************************************** integer,parameter :: ires_trial=21 !! trial residual integer,parameter :: ires=22 !! old residual integer,parameter :: icost=51 !! obs cost function contributions real cost_top,cost_bot integer NUM_total integer NUM real,dimension(:),allocatable :: res,res_trial !=========================================================== !--- initialize step-length sums (obs contributions) cost_top=0.0 cost_bot=0.0 !---- ! ! READ THE OBS RESIDUALS ! CLOSE(ires_trial) OPEN(UNIT=ires_trial,FILE='res_trial',FORM='UNFORMATTED',IOSTAT=IER) READ(ires_trial) mdata allocate(res_trial(1:mdata)) READ(ires_trial) res_trial CLOSE(ires_trial,status='KEEP') CLOSE(ires) OPEN(UNIT=ires,FILE='res_cntrl',FORM='UNFORMATTED',IOSTAT=IER) READ(ires) NUM allocate(res(1:NUM)) READ(ires) res CLOSE(ires,status='KEEP') if(NUM.eq.mdata) then write(*,*) "ALL is fine, number of obs match" else write(*,*) "PROBLEM: Number of obs DOES NOT match: mdata=",mdata," NUM=",NUM stop end if ! ! PROCESS COST-FUNCTION ! do i=1,NUM cost_top=cost_top+(res(i)-res_trial(i))*res(i) cost_bot=cost_bot+(res(i)-res_trial(i))*(res(i)-res_trial(i)) end do write(3,*)"==============================================" write(3,*)"TOTAL NUMBER OF OBSERVATIONS " write(3,*)"==============================================" write(3,*)"NUM_total= ",NUM write(3,*)"==============================================" WRITE(3,*)"=========OBSERVATIONAL STEP COST FUNCTION============" WRITE(3,8801) cost_top WRITE(3,8802) cost_bot 8801 FORMAT('TRIAL COST-FUNCTION: SSTOP=',E15.7) 8802 FORMAT('TRIAL COST-FUNCTION: SSBOT=',E15.7/) ! WRITE OUT THE TOTAL COST-FUNCTION ! CLOSE(icost) OPEN(UNIT=icost,FILE='obssum',FORM='UNFORMATTED',IOSTAT=IER) WRITE(icost) cost_top,cost_bot CLOSE(icost,STATUS='KEEP') stop end