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