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