1 |
C $Header: /u/gcmpack/MITgcm/verification/halfpipe_streamice/code_oad/ctrl_map_ini_genarr.F,v 1.3 2015/01/30 19:19:19 heimbach Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CTRL_OPTIONS.h" |
5 |
#include "STREAMICE_OPTIONS.h" |
6 |
|
7 |
CBOP |
8 |
C !ROUTINE: CTRL_MAP_INI_GENARR |
9 |
C !INTERFACE: |
10 |
SUBROUTINE CTRL_MAP_INI_GENARR( myThid ) |
11 |
|
12 |
C !DESCRIPTION: \bv |
13 |
C *================================================================= |
14 |
C | SUBROUTINE CTRL_MAP_INI_GENARR |
15 |
C | Add the generic arrays of the |
16 |
C | control vector to the model state and update the tile halos. |
17 |
C | The control vector is defined in the header file "ctrl.h". |
18 |
C *================================================================= |
19 |
C \ev |
20 |
|
21 |
C !USES: |
22 |
IMPLICIT NONE |
23 |
|
24 |
C == global variables == |
25 |
#include "SIZE.h" |
26 |
#include "EEPARAMS.h" |
27 |
#include "PARAMS.h" |
28 |
#include "GRID.h" |
29 |
#include "DYNVARS.h" |
30 |
#include "FFIELDS.h" |
31 |
#include "CTRL_SIZE.h" |
32 |
#include "ctrl.h" |
33 |
#include "CTRL_GENARR.h" |
34 |
#include "ctrl_dummy.h" |
35 |
#include "optim.h" |
36 |
#ifdef ALLOW_PTRACERS |
37 |
# include "PTRACERS_SIZE.h" |
38 |
c#include "PTRACERS_PARAMS.h" |
39 |
# include "PTRACERS_FIELDS.h" |
40 |
#endif |
41 |
#ifdef ALLOW_STREAMICE |
42 |
# include "STREAMICE.h" |
43 |
#endif |
44 |
|
45 |
C !INPUT/OUTPUT PARAMETERS: |
46 |
C == routine arguments == |
47 |
INTEGER myThid |
48 |
|
49 |
C !FUNCTIONS: |
50 |
INTEGER ILNBLNk |
51 |
EXTERNAL ILNBLNK |
52 |
|
53 |
C !LOCAL VARIABLES: |
54 |
C == local variables == |
55 |
integer bi,bj |
56 |
integer i,j,k |
57 |
integer jmin,jmax |
58 |
integer imin,imax |
59 |
integer il |
60 |
integer iarr |
61 |
|
62 |
logical doglobalread |
63 |
logical ladinit |
64 |
character*(MAX_LEN_FNAM) fnamebase |
65 |
character*( 80) fnamegeneric |
66 |
character*(MAX_LEN_MBUF) msgBuf |
67 |
_RL fac |
68 |
CEOP |
69 |
|
70 |
jmin = 1 |
71 |
jmax = sNy |
72 |
imin = 1 |
73 |
imax = sNx |
74 |
|
75 |
doglobalread = .false. |
76 |
ladinit = .false. |
77 |
fac = 1. _d 0 |
78 |
|
79 |
#ifdef ALLOW_GENARR2D_CONTROL |
80 |
C-- An example of connecting specific fields |
81 |
C-- to 3 generic 2D control arrays |
82 |
|
83 |
C-- generic - user-defined control vars |
84 |
DO iarr = 1, maxCtrlArr2D |
85 |
|
86 |
fnamebase = xx_genarr2d_file(iarr) |
87 |
il=ILNBLNK( fnamebase ) |
88 |
write(fnamegeneric(1:80),'(2a,i10.10)') |
89 |
& fnamebase(1:il),'.',optimcycle |
90 |
CALL ACTIVE_READ_XY ( fnamegeneric, tmpfld2d, 1, |
91 |
& doglobalread, ladinit, optimcycle, |
92 |
& myThid, xx_genarr2d_dummy(iarr) ) |
93 |
DO bj=myByLo(myThid), myByHi(myThid) |
94 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
95 |
do j = jmin,jmax |
96 |
do i = imin,imax |
97 |
|
98 |
if ( iarr .eq. 2 ) then |
99 |
H_streamice(i,j,bi,bj) = |
100 |
& H_streamice(i,j,bi,bj) |
101 |
& + tmpfld2d(i,j,bi,bj) |
102 |
#ifdef ALLOW_OPENAD |
103 |
cph & + xx_genarr2d(i,j,bi,bj,iarr) |
104 |
#endif |
105 |
|
106 |
elseif (iarr.eq.1) then |
107 |
B_glen(i,j,bi,bj) = |
108 |
& B_glen(i,j,bi,bj) |
109 |
& + tmpfld2d(i,j,bi,bj) |
110 |
#ifdef ALLOW_OPENAD |
111 |
cph & + xx_genarr2d(i,j,bi,bj,iarr) |
112 |
#endif |
113 |
|
114 |
! elseif (iarr.eq.5) then |
115 |
! BDOT_streamice(i,j,bi,bj) = |
116 |
! & BDOT_streamice(i,j,bi,bj) |
117 |
! & + tmpfld2d(i,j,bi,bj) |
118 |
|
119 |
endif |
120 |
|
121 |
enddo |
122 |
enddo |
123 |
ENDDO |
124 |
ENDDO |
125 |
C-- end iarr loop |
126 |
ENDDO |
127 |
|
128 |
_EXCH_XY_RL( H_streamice, myThid ) |
129 |
_EXCH_XY_RL( R_low_si, myThid ) |
130 |
_EXCH_XY_RL( C_basal_friction, myThid ) |
131 |
|
132 |
#endif /* ALLOW_GENARR2D_CONTROL */ |
133 |
|
134 |
#ifdef ALLOW_GENARR3D_CONTROL |
135 |
C-- An example of connecting specific fields |
136 |
C-- to 3 generic 3D control arrays |
137 |
--->>> |
138 |
--->>> COMPILE FAILURE IS DELIBERATE |
139 |
--->>> BE SURE WHAT YOU ARE DOING AND CUSTOMIZE <<<--- |
140 |
--->>> |
141 |
C-- generic - user-defined control vars |
142 |
DO iarr = 1, maxCtrlArr3D |
143 |
|
144 |
fnamebase = xx_genarr3d_file(iarr) |
145 |
il=ILNBLNK( fnamebase ) |
146 |
write(fnamegeneric(1:80),'(2a,i10.10)') |
147 |
& fnamebase(1:il),'.',optimcycle |
148 |
CALL ACTIVE_READ_XYZ( fnamegeneric, tmpfld3d, 1, |
149 |
& doglobalread, ladinit, optimcycle, |
150 |
& myThid, xx_genarr3d_dummy(iarr) ) |
151 |
DO bj=myByLo(myThid), myByHi(myThid) |
152 |
DO bi=myBxLo(myThid), myBxHi(myThid) |
153 |
do k = 1,Nr |
154 |
do j = jmin,jmax |
155 |
do i = imin,imax |
156 |
if ( iarr .eq. 1 ) then |
157 |
theta(i,j,k,bi,bj) = theta(i,j,k,bi,bj) |
158 |
& + fac*tmpfld3d(i,j,k,bi,bj) |
159 |
elseif ( iarr .eq. 2 ) then |
160 |
salt(i,j,k,bi,bj) = salt(i,j,k,bi,bj) |
161 |
& + fac*tmpfld3d(i,j,k,bi,bj) |
162 |
elseif ( iarr .eq. 3 ) then |
163 |
#ifdef ALLOW_DIFFKR_CONTROL |
164 |
diffkr(i,j,k,bi,bj) = diffkr(i,j,k,bi,bj) |
165 |
& + tmpfld3d(i,j,k,bi,bj) |
166 |
#endif |
167 |
endif |
168 |
enddo |
169 |
enddo |
170 |
enddo |
171 |
ENDDO |
172 |
ENDDO |
173 |
C-- end iarr loop |
174 |
ENDDO |
175 |
_EXCH_XYZ_RL( theta, myThid ) |
176 |
_EXCH_XYZ_RL( salt, myThid ) |
177 |
#ifdef ALLOW_DIFFKR_CONTROL |
178 |
_EXCH_XYZ_RL( diffkr, myThid ) |
179 |
#endif |
180 |
|
181 |
#endif /* ALLOW_GENARR3D_CONTROL */ |
182 |
|
183 |
RETURN |
184 |
END |