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