!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer,
! version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer
!version 3 or (at your option) any later version that should be found at:
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software;
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec),
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
***s/r v4d_ctrlcst - Control cost function
*
#include "model_macros_f.h"
*
subroutine v4d_ctrlcst () 4,6
*
use v4d_prof
, only: Pr_doobs, Pr_nevent
*
implicit none
*
*author
* M.Tanguay
*
*revision
* v2_10 - Tanguay M. - initial MPI version
* v3_00 - Ek N./Tanguay M. - add v4d_cstjok and V4dg_4dvar_L
* v3_01 - Morneau J. - read obs from file and add TLM in cost function
* for V4dg_sensib_L = .T.
* v3_01 - Tanguay M. - add V4dg_sgvc_L
* v3_11 - Tanguay M. - No profiles when Pr_nevent=EVN_TLME
* - Write/Read TRAJ for conv. moved to v4d_rwconv0
* - ADJ of digital filter
*
*object
* see id section
*
*arguments
* none
*
*implicits
#include "v4dg.cdk"
#include "lctl.cdk"
#include "tr3d.cdk"
#include <prof_f.h>
#include "init.cdk"
#include "rstr.cdk"
*
logical time0_L, time_L
*
if(V4dg_conf/100.ne.1.or.V4dg_sgvc_L.or.Pr_nevent.eq.EVN_TLME) return
*
* ----------------------------------------
* Sensitivity analysis or Twin experiments
* ----------------------------------------
if(.not.V4dg_4dvar_L) then
*
* Verify if INITIAL TIME requested
* --------------------------------
time0_L = Lctl_step.eq.0.and.V4dg_inv.ne.1
*
* Verify if .NOT.INITIAL time requested
* -------------------------------------
time_L = Lctl_step.ne.0.and.mod(Lctl_step,V4dg_stepob).eq.0
if(Init_balgm_L.and..not.Rstri_idon_L.and.Lctl_step.ge.(Init_dfnp-1)/2) time_L = .false.
*
if(.not.(time0_L.or.time_L)) return
*
* Store simulated OBSERVATIONS
* ----------------------------
if(V4dg_twin_L.and.V4dg_status.eq.5) then
*
V4dg_rwob = 1
call v4d_rwobfr
(1)
*
endif
* --------------------------------------
* Read and Store OBSERVATIONS if request
* -------------------------------------
if(V4dg_sensib_L.and.V4dg_status.eq.5) then
*
* Read on random file
*
call v4d_rdobs
*
* Store on WA file
* ----------------
V4dg_rwob = 2
call v4d_rwobfr
(1)
*
endif
*
* Store contribution to FORCINGS and Evaluate cost function
* ---------------------------------------------------------
if(V4dg_status.ne.5) then
*
call v4d_cststep
()
*
endif
*
* -----------------------------
* 4D-Var + exchange with 3D-Var
* -----------------------------
elseif(V4dg_4dvar_L) then
*
* Verify if INITIAL TIME requested
* --------------------------------
time0_L = Lctl_step.eq.0.and.Pr_doobs(0).gt.0
*
* Verify if .NOT.INITIAL time requested
* -------------------------------------
time_L = Lctl_step.ne.0.and.Pr_doobs(Lctl_step).gt.0
if(Init_balgm_L.and..not.Rstri_idon_L.and.Lctl_step.ge.(Init_dfnp-1)/2) time_L = .false.
*
if(.not.(time0_L.or.time_L)) return
*
* Interpolate model states at obs. locations and
* output the result to be read by 3D-Var
* ----------------------------------------------
call tmg_start ( 53, 'CSTJOK' )
if((V4dg_status.eq.7.and.V4dg_di_L).or.V4dg_tl_L) call v4d_cstjok
()
call tmg_stop ( 53 )
*
endif
*
return
end