1 |
C $Header: /u/gcmpack/MITgcm/pkg/ctrl/ctrl_hfacc_ini.F,v 1.7 2012/07/31 16:05:57 heimbach Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CTRL_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: ctrl_hfacc_ini |
8 |
C !INTERFACE: |
9 |
subroutine ctrl_hfacc_ini( mythid ) |
10 |
|
11 |
C !DESCRIPTION: \bv |
12 |
c *================================================================= |
13 |
c | SUBROUTINE ctrl_hfacc_ini |
14 |
c | Add the hFacC part of the control vector to the model state |
15 |
c | and update the tile halos. |
16 |
c | The control vector is defined in the header file "ctrl.h". |
17 |
c *================================================================= |
18 |
C \ev |
19 |
|
20 |
C !USES: |
21 |
implicit none |
22 |
|
23 |
c == global variables == |
24 |
#include "EEPARAMS.h" |
25 |
#include "SIZE.h" |
26 |
#include "GRID.h" |
27 |
#include "CTRL_SIZE.h" |
28 |
#include "ctrl.h" |
29 |
#include "ctrl_dummy.h" |
30 |
#include "optim.h" |
31 |
|
32 |
C !INPUT/OUTPUT PARAMETERS: |
33 |
c == routine arguments == |
34 |
integer mythid |
35 |
|
36 |
#ifdef ALLOW_HFACC_CONTROL |
37 |
C !LOCAL VARIABLES: |
38 |
c == local variables == |
39 |
|
40 |
integer bi,bj |
41 |
integer i,j,k |
42 |
integer itlo,ithi |
43 |
integer jtlo,jthi |
44 |
integer jmin,jmax |
45 |
integer imin,imax |
46 |
integer il |
47 |
|
48 |
logical equal |
49 |
logical doglobalread |
50 |
logical ladinit |
51 |
|
52 |
character*( 80) fnamehfacc |
53 |
character*(max_len_mbuf) msgbuf |
54 |
|
55 |
_RL fac |
56 |
|
57 |
c == external == |
58 |
integer ilnblnk |
59 |
external ilnblnk |
60 |
|
61 |
c == end of interface == |
62 |
CEOP |
63 |
|
64 |
jtlo = mybylo(mythid) |
65 |
jthi = mybyhi(mythid) |
66 |
itlo = mybxlo(mythid) |
67 |
ithi = mybxhi(mythid) |
68 |
jmin = 1-oly |
69 |
jmax = sny+oly |
70 |
imin = 1-olx |
71 |
imax = snx+olx |
72 |
|
73 |
doglobalread = .false. |
74 |
ladinit = .false. |
75 |
|
76 |
equal = .true. |
77 |
|
78 |
if ( equal ) then |
79 |
fac = 1. _d 0 |
80 |
else |
81 |
fac = 0. _d 0 |
82 |
endif |
83 |
|
84 |
Cml write(msgbuf,'(a)') |
85 |
Cml & 'ctrl_hfacc_ini: Re-initialising hFacC,' |
86 |
Cml call print_message( msgbuf, standardmessageunit, |
87 |
Cml & SQUEEZE_RIGHT , mythid) |
88 |
Cml write(msgbuf,'(a)') |
89 |
Cml & ' adding the control vector.' |
90 |
Cml call print_message( msgbuf, standardmessageunit, |
91 |
Cml & SQUEEZE_RIGHT , mythid) |
92 |
write(standardmessageunit,'(21x,a)') |
93 |
& 'ctrl_hfacc_ini: Re-initialising hFacC,' |
94 |
write(standardmessageunit,'(21x,a)') |
95 |
& ' adding the control vector.' |
96 |
|
97 |
C Re-initialize hFacC, so that TAMC/TAF can see it |
98 |
C Once hFacC is the control variable, and not its anomaly |
99 |
C this will be no longer necessary |
100 |
do bj = jtlo,jthi |
101 |
do bi = itlo,ithi |
102 |
do k = 1,nr |
103 |
do j = jmin,jmax |
104 |
do i = imin,imax |
105 |
hFacC(i,j,k,bi,bj) = 0. |
106 |
tmpfld3d(i,j,k,bi,bj) = 0. _d 0 |
107 |
enddo |
108 |
enddo |
109 |
enddo |
110 |
enddo |
111 |
enddo |
112 |
_BEGIN_MASTER( myThid ) |
113 |
CALL READ_FLD_XYZ_RL( 'hFacC', ' ', hFacC, 0, myThid ) |
114 |
_END_MASTER( myThid ) |
115 |
_EXCH_XYZ_RS( hFacC ,myThid ) |
116 |
|
117 |
C-- |
118 |
il=ilnblnk( xx_hfacc_file ) |
119 |
write(fnamehfacc(1:80),'(2a,i10.10)') |
120 |
& xx_hfacc_file(1:il),'.',optimcycle |
121 |
#ifdef ALLOW_HFACC3D_CONTROL |
122 |
call active_read_xyz( fnamehfacc, tmpfld3d, 1, |
123 |
& doglobalread, ladinit, optimcycle, |
124 |
& mythid, xx_hfacc_dummy ) |
125 |
do bj = jtlo,jthi |
126 |
do bi = itlo,ithi |
127 |
do k = 1,nr |
128 |
do j = jmin,jmax |
129 |
do i = imin,imax |
130 |
hFacC(i,j,k,bi,bj) = hFacC(i,j,k,bi,bj) + |
131 |
& fac*tmpfld3d(i,j,k,bi,bj) |
132 |
enddo |
133 |
enddo |
134 |
enddo |
135 |
enddo |
136 |
enddo |
137 |
#else /* ALLOW_HFACC3D_CONTROL undefined */ |
138 |
call active_read_xy( fnamehfacc, tmpfld2d, 1, |
139 |
& doglobalread, ladinit, optimcycle, |
140 |
& mythid, xx_hfacc_dummy ) |
141 |
do bj = jtlo,jthi |
142 |
do bi = itlo,ithi |
143 |
do j = jmin,jmax |
144 |
do i = imin,imax |
145 |
k = k_lowC(i,j,bi,bj) |
146 |
c if ( k .gt. 0 ) then |
147 |
hFacC(i,j,k,bi,bj) = hFacC(i,j,k,bi,bj) |
148 |
& + fac*tmpfld2d(i,j,bi,bj) |
149 |
c end if |
150 |
enddo |
151 |
enddo |
152 |
enddo |
153 |
enddo |
154 |
#endif /* ALLOW_HFACC3D_CONTROL */ |
155 |
|
156 |
c-- Update the tile edges. |
157 |
|
158 |
CALL dummy_in_hfac( 'C', 0, myThid ) |
159 |
_EXCH_XYZ_RS( hFacC, myThid ) |
160 |
CALL dummy_in_hfac( 'C', 1, myThid ) |
161 |
|
162 |
#endif /* ALLOW_HFACC_CONTROL */ |
163 |
|
164 |
return |
165 |
end |
166 |
|