1 |
C $Header: /u/gcmpack/MITgcm/verification/tutorial_global_oce_optim/code_ad/cost_temp.F,v 1.5 2009/10/09 01:20:45 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "COST_OPTIONS.h" |
5 |
|
6 |
SUBROUTINE COST_TEMP( myThid ) |
7 |
C *==========================================================* |
8 |
C | SUBROUTINE COST_TEMP |
9 |
C | o the subroutine computes the sum of the squared errors |
10 |
C | relatively to the Levitus climatology |
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_AUTODIFF_TAMC |
24 |
# include "tamc.h" |
25 |
# include "tamc_keys.h" |
26 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
27 |
|
28 |
C ======== Routine arguments ====================== |
29 |
C myThid - Thread number for this instance of the routine. |
30 |
INTEGER myThid |
31 |
|
32 |
#ifdef ALLOW_COST_TEMP |
33 |
C ========= Local variables ========================= |
34 |
INTEGER i, j, k |
35 |
INTEGER bi, bj |
36 |
INTEGER Nk |
37 |
_RL locfc,tmp |
38 |
_RL thetalev(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
39 |
|
40 |
Nk = 2 |
41 |
C Read annual mean Levitus temperature |
42 |
|
43 |
CALL READ_FLD_XYZ_RL('lev_t_an.bin',' ',thetalev,0,myThid) |
44 |
|
45 |
C Total number of wet temperature point |
46 |
tmp = 0. _d 0 |
47 |
DO bj=myByLo(myThid),myByHi(myThid) |
48 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
49 |
DO k=1, Nk |
50 |
DO j=1,sNy |
51 |
DO i=1,sNx |
52 |
tmp = tmp + maskC(i,j,k,bi,bj) |
53 |
ENDDO |
54 |
ENDDO |
55 |
ENDDO |
56 |
ENDDO |
57 |
ENDDO |
58 |
_GLOBAL_SUM_RL( tmp , myThid ) |
59 |
IF ( tmp.GT.0. ) tmp = 1. _d 0 / tmp |
60 |
|
61 |
DO bj=myByLo(myThid),myByHi(myThid) |
62 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
63 |
|
64 |
#ifdef ALLOW_AUTODIFF_TAMC |
65 |
act1 = bi - myBxLo(myThid) |
66 |
max1 = myBxHi(myThid) - myBxLo(myThid) + 1 |
67 |
act2 = bj - myByLo(myThid) |
68 |
max2 = myByHi(myThid) - myByLo(myThid) + 1 |
69 |
act3 = myThid - 1 |
70 |
ikey = (act1 + 1) + act2*max1 |
71 |
& + act3*max1*max2 |
72 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
73 |
|
74 |
locfc = 0. _d 0 |
75 |
DO k=1,Nk |
76 |
DO j=1,sNy |
77 |
DO i=1,sNx |
78 |
locfc = locfc + tmp*maskC(i,j,k,bi,bj)* |
79 |
& wtheta(k,bi,bj)* |
80 |
& ( cMeanTheta(i,j,k,bi,bj) - thetalev(i,j,k,bi,bj) )**2 |
81 |
ENDDO |
82 |
ENDDO |
83 |
ENDDO |
84 |
|
85 |
objf_temp_tut(bi,bj) = locfc |
86 |
c print*,'objf_temp_tut =',locfc,startTime,endTime,tmp |
87 |
|
88 |
ENDDO |
89 |
ENDDO |
90 |
#endif |
91 |
RETURN |
92 |
END |