1 |
C $Header: /u/gcmpack/MITgcm/verification/isomip/code_ad/cost_test.F,v 1.1 2012/01/06 13:01:09 heimbach Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "COST_OPTIONS.h" |
5 |
|
6 |
subroutine cost_test( myThid ) |
7 |
C *==========================================================* |
8 |
C | subroutine cost_test |
9 |
C | o this routine computes the cost function for the tiles |
10 |
C | of this processor |
11 |
C *==========================================================* |
12 |
C | Notes |
13 |
C *==========================================================* |
14 |
IMPLICIT NONE |
15 |
|
16 |
C == Global variables === |
17 |
#include "SIZE.h" |
18 |
#include "EEPARAMS.h" |
19 |
#include "PARAMS.h" |
20 |
#include "DYNVARS.h" |
21 |
#include "GRID.h" |
22 |
|
23 |
#include "cost.h" |
24 |
|
25 |
C == Routine arguments == |
26 |
C myThid - Thread number for this instance of the routine. |
27 |
integer myThid |
28 |
|
29 |
#ifdef ALLOW_COST_TEST |
30 |
C == Local variables |
31 |
integer bi, bj |
32 |
_RL thetaRef |
33 |
integer i, j, k |
34 |
integer ig, jg |
35 |
integer itlo,ithi |
36 |
integer jtlo,jthi |
37 |
c _RL thetaLev(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
38 |
|
39 |
jtlo = mybylo(mythid) |
40 |
jthi = mybyhi(mythid) |
41 |
itlo = mybxlo(mythid) |
42 |
ithi = mybxhi(mythid) |
43 |
|
44 |
if ( useCubedSphereExchange) then |
45 |
iLocOut = 7 |
46 |
jLocOut = 28 |
47 |
kLocOut = 1 |
48 |
else |
49 |
iLocOut = 80 |
50 |
jLocOut = 30 |
51 |
kLocOut = 1 |
52 |
endif |
53 |
|
54 |
c CALL READ_FLD_XYZ_RL( hydrogThetaFile, ' ', thetaLev, 0, myThid ) |
55 |
|
56 |
ce some reference temperature |
57 |
thetaRef = 24.0 _d 0 |
58 |
|
59 |
C-- Calculate mask for tracer cells (0 => land, 1 => water) |
60 |
k=1 |
61 |
|
62 |
C-- Calculate cost function on tile of this instance |
63 |
do bj = jtlo,jthi |
64 |
do bi = itlo,ithi |
65 |
do j=1,sNy |
66 |
jg = myYGlobalLo-1+(bj-1)*sNy+j |
67 |
do i=1,sNx |
68 |
ig = myXGlobalLo-1+(bi-1)*sNx+i |
69 |
|
70 |
#ifndef ALLOW_COST_TSQUARED |
71 |
if ((ig .eq. iLocOut) .and. (jg .eq. jLocOut)) then |
72 |
write(*,'(a,3(x,i4),a,4(x,i4))') |
73 |
& 'COST ',ig,jg,kLocOut,' TILE ',i,j,bi,bj |
74 |
objf_test(bi,bj) = theta(i,j,kLocOut,bi,bj) |
75 |
cph( |
76 |
print *, 'ph-cost ', ig, jg, kLocOut, |
77 |
& theta(i,j,kLocOut,bi,bj) |
78 |
cph) |
79 |
endif |
80 |
#else |
81 |
do k=1,nr |
82 |
if (maskC(i,j,k,bi,bj).NE.0.) then |
83 |
objf_test(bi,bj) = objf_test(bi,bj) + |
84 |
& ( theta(i,j,k,bi,bj) )**2 |
85 |
endif |
86 |
enddo |
87 |
#endif |
88 |
|
89 |
enddo |
90 |
enddo |
91 |
enddo |
92 |
enddo |
93 |
|
94 |
#endif /* ALLOW_COST_TEST */ |
95 |
|
96 |
RETURN |
97 |
END |