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