1 | !! This subroutines initialize a variable or an array |
---|
2 | !! with a variable or an array of smaller rank |
---|
3 | !! - i is for integer interface - r for real interface |
---|
4 | !! - 0 is for a scalar - 1 for a 1D array - 2 for a 2D array |
---|
5 | !! Thee right routines is automatically called depending type of input variable |
---|
6 | !! This initialisation is done only if the value of input field is egal to val_exp |
---|
7 | !! |
---|
8 | !! If a key word is provided which is not equal to "NO_KEYWORD" or "NOKEYWORD" then |
---|
9 | !! we try to find the value to fill in in the configuration file. |
---|
10 | !! |
---|
11 | !! @author Marie-Alice Foujols and Jan Polcher |
---|
12 | !! @Version : $Revision: 12 $, $Date: 2010-11-05 16:42:13 +0100 (Fri, 05 Nov 2010) $ |
---|
13 | !! |
---|
14 | !< $HeadURL: http://forge.ipsl.jussieu.fr/orchidee/svn/trunk/ORCHIDEE/src_sechiba/sechiba_io_p.f90 $ |
---|
15 | !< $Date: 2010-11-05 16:42:13 +0100 (Fri, 05 Nov 2010) $ |
---|
16 | !< $Author: mmaipsl $ |
---|
17 | !< $Revision: 12 $ |
---|
18 | !! IPSL (2006) |
---|
19 | !! This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC |
---|
20 | !! |
---|
21 | MODULE sechiba_io_p |
---|
22 | |
---|
23 | USE defprec |
---|
24 | |
---|
25 | USE constantes |
---|
26 | USE ioipsl |
---|
27 | USE parallel |
---|
28 | |
---|
29 | IMPLICIT NONE |
---|
30 | |
---|
31 | INTERFACE setvar_p |
---|
32 | MODULE PROCEDURE i0setvar_p, i10setvar_p, i20setvar_p, i11setvar_p, i21setvar_p, i22setvar_p |
---|
33 | MODULE PROCEDURE r0setvar_p, r10setvar_p, r20setvar_p, r11setvar_p, r21setvar_p, r22setvar_p, r30setvar_p |
---|
34 | END INTERFACE |
---|
35 | |
---|
36 | ! |
---|
37 | ! mettre la l'interface des routines utilisees: |
---|
38 | ! |
---|
39 | ! restget/put/ini histbeg/def flinopen/close |
---|
40 | ! |
---|
41 | |
---|
42 | LOGICAL, SAVE :: long_print_setvar_p=.FALSE. !! change to true to have more information |
---|
43 | |
---|
44 | CONTAINS |
---|
45 | |
---|
46 | !! pour déclancher les restarts rajoutés avec un paramètre externe |
---|
47 | FUNCTION ok_var ( varname ) |
---|
48 | CHARACTER(LEN=*), INTENT(IN) :: varname |
---|
49 | LOGICAL ok_var |
---|
50 | ok_var=.FALSE. |
---|
51 | CALL getin_p(varname, ok_var) |
---|
52 | END FUNCTION ok_var |
---|
53 | |
---|
54 | !! Interface for integer scalar to scalar. |
---|
55 | SUBROUTINE i0setvar_p (var, val_exp, key_wd, val_put) |
---|
56 | |
---|
57 | INTEGER(i_std), INTENT(inout) :: var !! Integer scalar to modify |
---|
58 | INTEGER(i_std), INTENT(in) :: val_exp !! Exceptional value |
---|
59 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
60 | INTEGER(i_std), INTENT(in) :: val_put !! Initial value to stored |
---|
61 | |
---|
62 | INTEGER(i_std) :: val_tmp |
---|
63 | INTEGER(i_std) :: is_key |
---|
64 | |
---|
65 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
66 | |
---|
67 | IF (long_print_setvar_p) WRITE (numout,*) "i0setvar :", key_wd, val_exp, val_put |
---|
68 | |
---|
69 | val_tmp = val_put |
---|
70 | |
---|
71 | IF ( var == val_exp ) THEN |
---|
72 | IF ( is_key <= 0 ) THEN |
---|
73 | CALL getin_p(key_wd, val_tmp) |
---|
74 | ENDIF |
---|
75 | var = val_tmp |
---|
76 | END IF |
---|
77 | |
---|
78 | END SUBROUTINE i0setvar_p |
---|
79 | |
---|
80 | |
---|
81 | !! Interface for initialising an 1D integer array with a scalar integer. |
---|
82 | SUBROUTINE i10setvar_p (var, val_exp, key_wd, val_put) |
---|
83 | |
---|
84 | INTEGER(i_std), DIMENSION(:), INTENT(inout) :: var !! 1D integer array to modify |
---|
85 | INTEGER(i_std), INTENT(in) :: val_exp !! Exceptional value |
---|
86 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
87 | INTEGER(i_std), INTENT(in) :: val_put !! Scalar value to stored |
---|
88 | |
---|
89 | INTEGER(i_std) :: val_tmp |
---|
90 | INTEGER(i_std) :: is_key |
---|
91 | |
---|
92 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
93 | |
---|
94 | IF (long_print_setvar_p) WRITE (numout,*) "i10setvar :", key_wd, val_exp, val_put |
---|
95 | |
---|
96 | val_tmp = val_put |
---|
97 | |
---|
98 | IF ( ALL( var(:) == val_exp ) ) THEN |
---|
99 | IF ( is_key <= 0 ) THEN |
---|
100 | CALL getin_p(key_wd, val_tmp) |
---|
101 | ENDIF |
---|
102 | var(:) = val_tmp |
---|
103 | END IF |
---|
104 | |
---|
105 | END SUBROUTINE i10setvar_p |
---|
106 | |
---|
107 | |
---|
108 | !! Interface for initialising an 1D array integer with an other 1D array integer. |
---|
109 | SUBROUTINE i11setvar_p (var, val_exp, key_wd, val_put, is_grid) |
---|
110 | |
---|
111 | INTEGER(i_std), DIMENSION(:), INTENT(inout) :: var !! 1D integer array to modify |
---|
112 | INTEGER(i_std), INTENT(in) :: val_exp !! Exceptional value |
---|
113 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
114 | INTEGER(i_std), DIMENSION(:), INTENT(in) :: val_put !! 1D integer array to stored |
---|
115 | LOGICAL, OPTIONAL :: is_grid !! Parameter present indicates a setvar for a grid variable |
---|
116 | |
---|
117 | INTEGER(i_std), ALLOCATABLE,DIMENSION(:) :: val_tmp |
---|
118 | INTEGER(i_std), ALLOCATABLE,DIMENSION(:) :: val_tmp_g |
---|
119 | INTEGER(i_std) :: is_key |
---|
120 | |
---|
121 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
122 | |
---|
123 | IF (long_print_setvar_p) WRITE (numout,*) "i11setvar :", key_wd, val_exp, SIZE(val_put), val_put(1) |
---|
124 | |
---|
125 | ALLOCATE(val_tmp(SIZE(val_put))) |
---|
126 | val_tmp(:) = val_put(:) |
---|
127 | |
---|
128 | IF ( ALL( var(:) == val_exp ) ) THEN |
---|
129 | IF ( is_key <= 0 ) THEN |
---|
130 | IF (PRESENT(is_grid) ) THEN |
---|
131 | IF (is_root_prc) & |
---|
132 | ALLOCATE( val_tmp_g(nbp_glo) ) |
---|
133 | CALL gather( val_tmp,val_tmp_g ) |
---|
134 | IF (is_root_prc) & |
---|
135 | CALL getin(key_wd, val_tmp_g) |
---|
136 | CALL scatter( val_tmp,val_tmp_g ) |
---|
137 | IF (is_root_prc) & |
---|
138 | DEALLOCATE( val_tmp_g ) |
---|
139 | ELSE |
---|
140 | CALL getin_p(key_wd, val_tmp) |
---|
141 | ENDIF |
---|
142 | ENDIF |
---|
143 | var(:) = val_tmp (:) |
---|
144 | END IF |
---|
145 | |
---|
146 | DEALLOCATE(val_tmp) |
---|
147 | |
---|
148 | END SUBROUTINE i11setvar_p |
---|
149 | |
---|
150 | |
---|
151 | !! Interface for initialising an 2D array integer with a scalar integer. |
---|
152 | SUBROUTINE i20setvar_p (var, val_exp, key_wd, val_put) |
---|
153 | |
---|
154 | INTEGER(i_std), DIMENSION(:,:), INTENT(inout) :: var !! 2D integer array to modify |
---|
155 | INTEGER(i_std), INTENT(in) :: val_exp !! Exceptional value |
---|
156 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
157 | INTEGER(i_std), INTENT(in) :: val_put !! Scalar value to stored |
---|
158 | |
---|
159 | INTEGER(i_std) :: val_tmp |
---|
160 | INTEGER(i_std) :: is_key |
---|
161 | |
---|
162 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
163 | |
---|
164 | ! |
---|
165 | ! this subroutine set val_put value to var if var is constant |
---|
166 | ! |
---|
167 | ! |
---|
168 | IF (long_print_setvar_p) WRITE (numout,*) "i20setvar :", key_wd, val_exp, val_put |
---|
169 | |
---|
170 | val_tmp = val_put |
---|
171 | |
---|
172 | IF ( ALL( var(:,:) == val_exp ) ) THEN |
---|
173 | IF ( is_key <= 0 ) THEN |
---|
174 | CALL getin_p(key_wd, val_tmp) |
---|
175 | ENDIF |
---|
176 | var(:,:) = val_tmp |
---|
177 | END IF |
---|
178 | |
---|
179 | END SUBROUTINE i20setvar_p |
---|
180 | |
---|
181 | |
---|
182 | !! Interface for initialising an 2D array integer with an 1D array integer. |
---|
183 | !! Row or column depending size of 1D array to stored. |
---|
184 | !! |
---|
185 | !! example: 1D 1,2,3 2D is 1, 2, 3, |
---|
186 | !! 1, 2, 3 |
---|
187 | !! |
---|
188 | !! |
---|
189 | !! example: 1D 1,2,3 2D is 1, 1, |
---|
190 | !! 2, 2, |
---|
191 | !! 3, 3 |
---|
192 | !! |
---|
193 | SUBROUTINE i21setvar_p (var, val_exp, key_wd, val_put, is_grid) |
---|
194 | |
---|
195 | INTEGER(i_std), DIMENSION(:,:), INTENT(inout) :: var !! 2D integer array to modify |
---|
196 | INTEGER(i_std), INTENT(in) :: val_exp !! Exceptional value |
---|
197 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
198 | INTEGER(i_std), DIMENSION(:), INTENT(in) :: val_put !! 1D integer array to stored |
---|
199 | LOGICAL, OPTIONAL :: is_grid !! Parameter present indicates a setvar for a grid variable |
---|
200 | |
---|
201 | INTEGER(i_std), ALLOCATABLE,DIMENSION(:) :: val_tmp |
---|
202 | INTEGER(i_std) :: is_key |
---|
203 | |
---|
204 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
205 | |
---|
206 | ! test if the 1D array dimension is compatible with first or second |
---|
207 | ! dimension of the 2D array |
---|
208 | |
---|
209 | IF (long_print_setvar_p) WRITE (numout,*) "i21setvar :", key_wd, val_exp, val_put |
---|
210 | |
---|
211 | ALLOCATE(val_tmp(SIZE(val_put))) |
---|
212 | val_tmp(:) = val_put(:) |
---|
213 | |
---|
214 | IF (SIZE(val_put)==SIZE(var,1)) THEN |
---|
215 | ! |
---|
216 | ! example: 1D 1.,2.,3. 2D is 1., 2., 3., |
---|
217 | ! 1., 2., 3. |
---|
218 | ! |
---|
219 | IF ( ALL( var(:,:) == val_exp ) ) THEN |
---|
220 | IF ( is_key <= 0 ) THEN |
---|
221 | CALL getin_p(key_wd, val_tmp) |
---|
222 | ENDIF |
---|
223 | var(:,:) = SPREAD(val_tmp(:),2,SIZE(var,1)) |
---|
224 | END IF |
---|
225 | ELSEIF (SIZE(val_put)==SIZE(var,2)) THEN |
---|
226 | ! |
---|
227 | ! example: 1D 1.,2.,3. 2D is 1., 1., |
---|
228 | ! 2., 2., |
---|
229 | ! 3., 3. |
---|
230 | ! |
---|
231 | IF ( ALL( var(:,:) == val_exp ) ) THEN |
---|
232 | IF ( is_key <= 0 ) THEN |
---|
233 | CALL getin_p(key_wd, val_tmp) |
---|
234 | ENDIF |
---|
235 | var(:,:) = SPREAD(val_tmp(:),1,SIZE(var,1)) |
---|
236 | END IF |
---|
237 | ELSE |
---|
238 | WRITE (numout,*) ' incompatible dimension var and val_put' |
---|
239 | WRITE (numout,*) ' var ', SIZE(var,1), SIZE(var,2) |
---|
240 | WRITE (numout,*) ' val_put ', SIZE(val_put) |
---|
241 | STOP 'setvar' |
---|
242 | END IF |
---|
243 | |
---|
244 | DEALLOCATE(val_tmp) |
---|
245 | |
---|
246 | END SUBROUTINE i21setvar_p |
---|
247 | |
---|
248 | !! Interface for initialising an 2D array integer with an other 2D array integer. |
---|
249 | SUBROUTINE i22setvar_p (var, val_exp, key_wd, val_put, is_grid) |
---|
250 | |
---|
251 | INTEGER(i_std), DIMENSION(:,:), INTENT(inout) :: var !! 2D integer array to modify |
---|
252 | INTEGER(i_std), INTENT(in) :: val_exp !! Exceptional value |
---|
253 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
254 | INTEGER(i_std), DIMENSION(:,:), INTENT(in) :: val_put !! 2D integer array to stored |
---|
255 | LOGICAL, OPTIONAL :: is_grid !! Parameter present indicates a setvar for a grid variable |
---|
256 | |
---|
257 | INTEGER(i_std), ALLOCATABLE, DIMENSION(:,:) :: val_tmp |
---|
258 | INTEGER(i_std) :: is_key |
---|
259 | |
---|
260 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
261 | |
---|
262 | IF (long_print_setvar_p) WRITE (numout,*) "i21setvar :", key_wd, val_exp, SIZE(val_put), val_put(1,1) |
---|
263 | |
---|
264 | ALLOCATE(val_tmp(SIZE(val_put,DIM=1),SIZE(val_put,DIM=2))) |
---|
265 | val_tmp(:,:) = val_put(:,:) |
---|
266 | |
---|
267 | IF ( ALL(var(:,:) == val_exp ) ) THEN |
---|
268 | IF ( is_key <= 0 ) THEN |
---|
269 | CALL getin_p(key_wd, val_tmp) |
---|
270 | ENDIF |
---|
271 | var(:,:) = val_tmp(:,:) |
---|
272 | END IF |
---|
273 | |
---|
274 | DEALLOCATE(val_tmp) |
---|
275 | |
---|
276 | END SUBROUTINE i22setvar_p |
---|
277 | |
---|
278 | |
---|
279 | !! Interface for scalar to scalar real |
---|
280 | SUBROUTINE r0setvar_p (var, val_exp, key_wd, val_put) |
---|
281 | |
---|
282 | REAL(r_std), INTENT(inout) :: var !! Real scalar to modify |
---|
283 | REAL(r_std), INTENT(in) :: val_exp !! Exceptional value |
---|
284 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
285 | REAL(r_std), INTENT(in) :: val_put !! Initial value to stored |
---|
286 | |
---|
287 | REAL(r_std) :: val_tmp |
---|
288 | INTEGER(i_std) :: is_key |
---|
289 | |
---|
290 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
291 | |
---|
292 | IF (long_print_setvar_p) WRITE (numout,*) "r0setvar :", key_wd, val_exp, val_put |
---|
293 | |
---|
294 | val_tmp = val_put |
---|
295 | |
---|
296 | IF ( var==val_exp ) THEN |
---|
297 | IF ( is_key <= 0 ) THEN |
---|
298 | CALL getin_p(key_wd, val_tmp) |
---|
299 | ENDIF |
---|
300 | var = val_tmp |
---|
301 | END IF |
---|
302 | |
---|
303 | END SUBROUTINE r0setvar_p |
---|
304 | |
---|
305 | |
---|
306 | !! Interface for initialising an 1D real array with a scalar real. |
---|
307 | SUBROUTINE r10setvar_p (var, val_exp, key_wd, val_put) |
---|
308 | |
---|
309 | REAL(r_std), DIMENSION(:), INTENT(inout) :: var !! 1D real array to modify |
---|
310 | REAL(r_std), INTENT(in) :: val_exp !! Exceptional value |
---|
311 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
312 | REAL(r_std), INTENT(in) :: val_put !! Scalar value to stored |
---|
313 | |
---|
314 | REAL(r_std) :: val_tmp |
---|
315 | INTEGER(i_std) :: is_key |
---|
316 | |
---|
317 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
318 | |
---|
319 | IF (long_print_setvar_p) WRITE (numout,*) "r10setvar :", key_wd, val_exp, val_put |
---|
320 | |
---|
321 | val_tmp = val_put |
---|
322 | |
---|
323 | IF ( ALL( var(:) == val_exp ) ) THEN |
---|
324 | IF ( is_key <= 0 ) THEN |
---|
325 | CALL getin_p(key_wd, val_tmp) |
---|
326 | ENDIF |
---|
327 | var(:) = val_tmp |
---|
328 | END IF |
---|
329 | |
---|
330 | END SUBROUTINE r10setvar_p |
---|
331 | |
---|
332 | |
---|
333 | !! Interface for initialising an 1D array real with an other 1D array real. |
---|
334 | SUBROUTINE r11setvar_p (var, val_exp, key_wd, val_put, is_grid) |
---|
335 | |
---|
336 | REAL(r_std), DIMENSION(:), INTENT(inout) :: var !! 1D real array to modify |
---|
337 | REAL(r_std), INTENT(in) :: val_exp !! Exceptional value |
---|
338 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
339 | REAL(r_std), DIMENSION(:), INTENT(in) :: val_put !! 1D integer array to stored |
---|
340 | LOGICAL, OPTIONAL :: is_grid !! Parameter present indicates a setvar for a grid variable |
---|
341 | |
---|
342 | REAL(r_std), ALLOCATABLE,DIMENSION(:) :: val_tmp |
---|
343 | INTEGER(i_std) :: is_key |
---|
344 | |
---|
345 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
346 | |
---|
347 | IF (long_print_setvar_p) WRITE (numout,*) "r11setvar :", key_wd, val_exp, SIZE(val_put), val_put(1) |
---|
348 | |
---|
349 | ALLOCATE(val_tmp(SIZE(val_put))) |
---|
350 | val_tmp(:) = val_put(:) |
---|
351 | |
---|
352 | IF ( ALL( var(:) == val_exp ) ) THEN |
---|
353 | IF ( is_key <= 0 ) THEN |
---|
354 | CALL getin_p(key_wd, val_tmp) |
---|
355 | ENDIF |
---|
356 | var(:) = val_tmp (:) |
---|
357 | END IF |
---|
358 | |
---|
359 | DEALLOCATE(val_tmp) |
---|
360 | |
---|
361 | END SUBROUTINE r11setvar_p |
---|
362 | |
---|
363 | |
---|
364 | !! Interface for initialising an 2D array real with a scalar real. |
---|
365 | SUBROUTINE r20setvar_p (var, val_exp, key_wd, val_put) |
---|
366 | |
---|
367 | ! interface for scalar to 2D array real |
---|
368 | |
---|
369 | REAL(r_std), DIMENSION(:,:), INTENT(inout) :: var !! 2D integer array to modify |
---|
370 | REAL(r_std), INTENT(in) :: val_exp !! Exceptional value |
---|
371 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
372 | REAL(r_std), INTENT(in) :: val_put !! Scalar value to stored |
---|
373 | |
---|
374 | REAL(r_std) :: val_tmp |
---|
375 | INTEGER(i_std) :: is_key |
---|
376 | |
---|
377 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
378 | |
---|
379 | IF (long_print_setvar_p) WRITE (numout,*) "r20setvar :", key_wd, val_exp, val_put |
---|
380 | |
---|
381 | val_tmp = val_put |
---|
382 | |
---|
383 | IF ( ALL( var(:,:) == val_exp ) ) THEN |
---|
384 | IF ( is_key <= 0 ) THEN |
---|
385 | CALL getin_p(key_wd, val_tmp) |
---|
386 | ENDIF |
---|
387 | var(:,:) = val_tmp |
---|
388 | END IF |
---|
389 | |
---|
390 | END SUBROUTINE r20setvar_p |
---|
391 | |
---|
392 | |
---|
393 | !! Interface for initialising an 2D array real with an 1D array real. |
---|
394 | !! Row or column depending size of 1D array to stored. |
---|
395 | !! |
---|
396 | !! example: 1D 1.,2.,3. 2D is 1., 2., 3., |
---|
397 | !! 1., 2., 3. |
---|
398 | !! |
---|
399 | !! |
---|
400 | !! example: 1D 1.,2.,3. 2D is 1., 1., |
---|
401 | !! 2., 2., |
---|
402 | !! 3., 3. |
---|
403 | !! |
---|
404 | SUBROUTINE r21setvar_p (var, val_exp, key_wd, val_put, is_grid) |
---|
405 | |
---|
406 | ! interface for 1D array to 2D array real |
---|
407 | |
---|
408 | REAL(r_std), DIMENSION(:,:), INTENT(inout) :: var !! 2D real array to modify |
---|
409 | REAL(r_std), INTENT(in) :: val_exp !! Exceptional value |
---|
410 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
411 | REAL(r_std), DIMENSION(:), INTENT(in) :: val_put !! 1D real array to stored |
---|
412 | LOGICAL, OPTIONAL :: is_grid !! Parameter present indicates a setvar for a grid variable |
---|
413 | |
---|
414 | REAL(r_std), ALLOCATABLE,DIMENSION(:) :: val_tmp |
---|
415 | INTEGER(i_std) :: is_key |
---|
416 | |
---|
417 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
418 | |
---|
419 | ! test if the 1D array dimension is compatible with first or second |
---|
420 | ! dimension of the 2D array |
---|
421 | |
---|
422 | IF (long_print_setvar_p) WRITE (numout,*) "r21setvar :", key_wd, val_exp, SIZE(val_put), val_put(1) |
---|
423 | |
---|
424 | ALLOCATE(val_tmp(SIZE(val_put))) |
---|
425 | val_tmp(:) = val_put(:) |
---|
426 | |
---|
427 | IF (SIZE(val_put)==SIZE(var,1)) THEN |
---|
428 | ! |
---|
429 | ! example: 1D 1.,2.,3. 2D is 1., 2., 3., |
---|
430 | ! 1., 2., 3. |
---|
431 | ! |
---|
432 | IF ( ALL( var(:,:) == val_exp ) ) THEN |
---|
433 | IF ( is_key <= 0 ) THEN |
---|
434 | CALL getin_p(key_wd, val_tmp) |
---|
435 | ENDIF |
---|
436 | var(:,:) = SPREAD(val_tmp(:),2,SIZE(var,1)) |
---|
437 | END IF |
---|
438 | ELSEIF (SIZE(val_put)==SIZE(var,2)) THEN |
---|
439 | ! |
---|
440 | ! example: 1D 1.,2.,3. 2D is 1., 1., |
---|
441 | ! 2., 2., |
---|
442 | ! 3., 3. |
---|
443 | ! |
---|
444 | IF ( ALL( var(:,:) == val_exp ) ) THEN |
---|
445 | IF ( is_key <= 0 ) THEN |
---|
446 | CALL getin_p(key_wd, val_tmp) |
---|
447 | ENDIF |
---|
448 | var(:,:) = SPREAD(val_tmp(:),1,SIZE(var,1)) |
---|
449 | END IF |
---|
450 | ELSE |
---|
451 | WRITE (numout,*) ' incompatible dimension var and val_put' |
---|
452 | WRITE (numout,*) ' var ', SIZE(var,1), SIZE(var,2) |
---|
453 | WRITE (numout,*) ' val_put ', SIZE(val_put) |
---|
454 | STOP 'setvar' |
---|
455 | END IF |
---|
456 | |
---|
457 | DEALLOCATE(val_tmp) |
---|
458 | |
---|
459 | END SUBROUTINE r21setvar_p |
---|
460 | |
---|
461 | |
---|
462 | !! Interface for initialising an 2D array real with an other 2D array real. |
---|
463 | SUBROUTINE r22setvar_p (var, val_exp, key_wd, val_put, is_grid) |
---|
464 | |
---|
465 | ! interface for 2D array to 2D array real |
---|
466 | |
---|
467 | REAL(r_std), DIMENSION(:,:), INTENT(inout) :: var !! 2D real array to modify |
---|
468 | REAL(r_std), INTENT(in) :: val_exp !! Exceptional value |
---|
469 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
470 | REAL(r_std), DIMENSION(:,:), INTENT(in) :: val_put !! 2D integer array to stored |
---|
471 | LOGICAL, OPTIONAL :: is_grid !! Parameter present indicates a setvar for a grid variable |
---|
472 | |
---|
473 | REAL(r_std), ALLOCATABLE, DIMENSION(:,:) :: val_tmp |
---|
474 | INTEGER(i_std) :: is_key |
---|
475 | |
---|
476 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
477 | |
---|
478 | IF (long_print_setvar_p) WRITE (numout,*) "r22setvar :", key_wd, val_exp, SIZE(val_put), val_put(1,1) |
---|
479 | |
---|
480 | ALLOCATE(val_tmp(SIZE(val_put,DIM=1),SIZE(val_put,DIM=2))) |
---|
481 | val_tmp(:,:) = val_put(:,:) |
---|
482 | |
---|
483 | IF ( ALL( var(:,:) == val_exp ) ) THEN |
---|
484 | IF ( is_key <= 0 ) THEN |
---|
485 | CALL getin_p(key_wd, val_tmp) |
---|
486 | ENDIF |
---|
487 | var(:,:) = val_tmp(:,:) |
---|
488 | END IF |
---|
489 | |
---|
490 | DEALLOCATE(val_tmp) |
---|
491 | |
---|
492 | END SUBROUTINE r22setvar_p |
---|
493 | |
---|
494 | !! Interface for initialising an 3D array real with a scalar real. |
---|
495 | SUBROUTINE r30setvar_p (var, val_exp, key_wd, val_put) |
---|
496 | |
---|
497 | ! interface for scalar to 3D array real |
---|
498 | |
---|
499 | REAL(r_std), DIMENSION(:,:,:), INTENT(inout) :: var !! 3D integer array to modify |
---|
500 | REAL(r_std), INTENT(in) :: val_exp !! Exceptional value |
---|
501 | CHARACTER(LEN=*), INTENT(in) :: key_wd !! The Key word we will look for |
---|
502 | REAL(r_std), INTENT(in) :: val_put !! Scalar value to stored |
---|
503 | |
---|
504 | REAL(r_std) :: val_tmp |
---|
505 | INTEGER(i_std) :: is_key |
---|
506 | |
---|
507 | is_key = MAX(INDEX(key_wd, 'NO_KEYWORD'), INDEX(key_wd, 'NOKEYWORD')) |
---|
508 | |
---|
509 | IF (long_print_setvar_p) WRITE(numout,*) 'r30setvar',val_exp, val_put |
---|
510 | |
---|
511 | val_tmp = val_put |
---|
512 | |
---|
513 | IF ( ALL( var(:,:,:) == val_exp ) ) THEN |
---|
514 | IF ( is_key <= 0 ) THEN |
---|
515 | CALL getin_p(key_wd, val_tmp) |
---|
516 | ENDIF |
---|
517 | var(:,:,:) = val_tmp |
---|
518 | END IF |
---|
519 | |
---|
520 | END SUBROUTINE r30setvar_p |
---|
521 | |
---|
522 | END MODULE sechiba_io_p |
---|