1 |
C $Header: /u/gcmpack/MITgcm/verification/tutorial_global_oce_optim/code_ad/cost_hflux.F,v 1.7 2014/09/11 19:52:09 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "COST_OPTIONS.h" |
5 |
#ifdef ALLOW_CTRL |
6 |
# include "CTRL_OPTIONS.h" |
7 |
#endif |
8 |
|
9 |
SUBROUTINE COST_HFLUX( myThid ) |
10 |
C *==========================================================* |
11 |
C | SUBROUTINE COST_HFLUX |
12 |
C | o the subroutine computes the cost function relative to |
13 |
C | surface hflux optimization |
14 |
C *==========================================================* |
15 |
|
16 |
IMPLICIT NONE |
17 |
|
18 |
C == Global variables === |
19 |
#include "SIZE.h" |
20 |
#include "EEPARAMS.h" |
21 |
#include "PARAMS.h" |
22 |
#include "GRID.h" |
23 |
#include "DYNVARS.h" |
24 |
#include "cost.h" |
25 |
#include "ctrl_weights.h" |
26 |
#ifdef ALLOW_HFLUXM_CONTROL |
27 |
#include "FFIELDS.h" |
28 |
#endif |
29 |
|
30 |
C ======== Routine arguments ====================== |
31 |
C myThid - Thread number for this instance of the routine. |
32 |
integer myThid |
33 |
|
34 |
#if (defined (ALLOW_COST_HFLUXM) && defined (ALLOW_HFLUXM_CONTROL)) |
35 |
C ========= Local variables ========================= |
36 |
integer i, j |
37 |
integer bi, bj |
38 |
_RL locfc,tmpC |
39 |
|
40 |
tmpC = 0. _d 0 |
41 |
DO bj=myByLo(myThid),myByHi(myThid) |
42 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
43 |
do j=1,sNy |
44 |
do i=1,sNx |
45 |
tmpC = tmpC + maskC(i,j,1,bi,bj) |
46 |
ENDDO |
47 |
ENDDO |
48 |
ENDDO |
49 |
ENDDO |
50 |
_GLOBAL_SUM_RL( tmpC , myThid ) |
51 |
IF ( tmpC.GT.0. ) tmpC = 1. _d 0 / tmpC |
52 |
|
53 |
DO bj=myByLo(myThid),myByHi(myThid) |
54 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
55 |
|
56 |
locfc = 0. _d 0 |
57 |
DO j=1,sNy |
58 |
DO i=1,sNx |
59 |
locfc = locfc + tmpC*maskC(i,j,1,bi,bj)* |
60 |
& whfluxm(i,j,bi,bj)* |
61 |
& ( |
62 |
& Qnetm(i,j,bi,bj) |
63 |
& )**2 |
64 |
ENDDO |
65 |
ENDDO |
66 |
|
67 |
objf_hflux_tut(bi,bj) = locfc |
68 |
c print*,'objf_hflux_tut =',locfc |
69 |
|
70 |
ENDDO |
71 |
ENDDO |
72 |
|
73 |
#endif /* ALLOW_COST_HFLUXM & ALLOW_HFLUXM_CONTROL */ |
74 |
RETURN |
75 |
END |