1 | !> @file check_open.f90 |
---|
2 | !--------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
7 | ! either version 3 of the License, or (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with |
---|
14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: check_open.f90 1683 2015-10-07 23:57:51Z knoop $ |
---|
26 | ! |
---|
27 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
28 | ! Code annotations made doxygen readable |
---|
29 | ! |
---|
30 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
31 | ! Removed redundant output for combine_plot_fields |
---|
32 | ! |
---|
33 | ! 1468 2014-09-24 14:06:57Z maronga |
---|
34 | ! Adapted for use on up to 6-digit processor cores |
---|
35 | ! Added file unit 117 (PROGRESS) |
---|
36 | ! |
---|
37 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
38 | ! Format of particle exchange statistics extended to reasonable numbers of |
---|
39 | ! particles. |
---|
40 | ! |
---|
41 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
42 | ! REAL constants provided with KIND-attribute, |
---|
43 | ! declaration for unused variables xkoor, ykoor, zkoor removed |
---|
44 | ! |
---|
45 | ! 1327 2014-03-21 11:00:16Z raasch |
---|
46 | ! parts concerning iso2d and avs output removed |
---|
47 | ! |
---|
48 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
49 | ! ONLY-attribute added to USE-statements, |
---|
50 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
51 | ! kinds are defined in new module kinds, |
---|
52 | ! old module precision_kind is removed, |
---|
53 | ! revision history before 2012 removed, |
---|
54 | ! comment fields (!:) to be used for variable explanations added to |
---|
55 | ! all variable declaration statements |
---|
56 | ! |
---|
57 | ! 1106 2013-03-04 05:31:38Z raasch |
---|
58 | ! array_kind renamed precision_kind |
---|
59 | ! |
---|
60 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
61 | ! unused variables removed |
---|
62 | ! |
---|
63 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
64 | ! code put under GPL (PALM 3.9) |
---|
65 | ! |
---|
66 | ! 1031 2012-10-19 14:35:30Z raasch |
---|
67 | ! netCDF4 without parallel file support implemented, |
---|
68 | ! opening of netCDF files are done by new routines create_netcdf_file and |
---|
69 | ! open_write_netcdf_file |
---|
70 | ! |
---|
71 | ! 964 2012-07-26 09:14:24Z raasch |
---|
72 | ! old profil-units (40:49) removed, |
---|
73 | ! append feature removed from unit 14 |
---|
74 | ! |
---|
75 | ! 849 2012-03-15 10:35:09Z raasch |
---|
76 | ! comment changed |
---|
77 | ! |
---|
78 | ! 809 2012-01-30 13:32:58Z maronga |
---|
79 | ! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives |
---|
80 | ! |
---|
81 | ! 807 2012-01-25 11:53:51Z maronga |
---|
82 | ! New cpp directive "__check" implemented which is used by check_namelist_files |
---|
83 | ! |
---|
84 | ! Revision 1.1 1997/08/11 06:10:55 raasch |
---|
85 | ! Initial revision |
---|
86 | ! |
---|
87 | ! |
---|
88 | ! Description: |
---|
89 | ! ------------ |
---|
90 | !> Check if file unit is open. If not, open file and, if necessary, write a |
---|
91 | !> header or start other initializing actions, respectively. |
---|
92 | !------------------------------------------------------------------------------! |
---|
93 | SUBROUTINE check_open( file_id ) |
---|
94 | |
---|
95 | |
---|
96 | USE arrays_3d, & |
---|
97 | ONLY: zu |
---|
98 | |
---|
99 | USE control_parameters, & |
---|
100 | ONLY: avs_data_file, coupling_char, data_output_2d_on_each_pe, host, & |
---|
101 | message_string, mid, netcdf_data_format, nz_do3d, openfile, & |
---|
102 | return_addres, return_username, run_description_header, runnr |
---|
103 | |
---|
104 | USE grid_variables, & |
---|
105 | ONLY: dx, dy |
---|
106 | |
---|
107 | USE indices, & |
---|
108 | ONLY: nbgp, nx, nxl, nxr, ny, nyn, nyng, nys, nysg, nz, nzb, nzt |
---|
109 | |
---|
110 | USE kinds |
---|
111 | |
---|
112 | USE netcdf_control |
---|
113 | |
---|
114 | USE particle_attributes, & |
---|
115 | ONLY: max_number_of_particle_groups, number_of_particle_groups, & |
---|
116 | particle_groups |
---|
117 | |
---|
118 | USE pegrid |
---|
119 | |
---|
120 | USE profil_parameter, & |
---|
121 | ONLY: cross_ts_numbers, cross_ts_number_count |
---|
122 | |
---|
123 | USE statistics, & |
---|
124 | ONLY: region, statistic_regions |
---|
125 | |
---|
126 | |
---|
127 | IMPLICIT NONE |
---|
128 | |
---|
129 | CHARACTER (LEN=2) :: mask_char !< |
---|
130 | CHARACTER (LEN=2) :: suffix !< |
---|
131 | CHARACTER (LEN=20) :: xtext = 'time in s' !< |
---|
132 | CHARACTER (LEN=30) :: filename !< |
---|
133 | CHARACTER (LEN=40) :: avs_coor_file !< |
---|
134 | CHARACTER (LEN=40) :: avs_coor_file_localname !< |
---|
135 | CHARACTER (LEN=40) :: avs_data_file_localname !< |
---|
136 | CHARACTER (LEN=80) :: rtext !< |
---|
137 | CHARACTER (LEN=100) :: avs_coor_file_catalog !< |
---|
138 | CHARACTER (LEN=100) :: avs_data_file_catalog !< |
---|
139 | CHARACTER (LEN=100) :: batch_scp !< |
---|
140 | CHARACTER (LEN=100) :: line !< |
---|
141 | CHARACTER (LEN=400) :: command !< |
---|
142 | |
---|
143 | INTEGER(iwp) :: av !< |
---|
144 | INTEGER(iwp) :: numline = 1 !< |
---|
145 | INTEGER(iwp) :: cranz !< |
---|
146 | INTEGER(iwp) :: file_id !< |
---|
147 | INTEGER(iwp) :: i !< |
---|
148 | INTEGER(iwp) :: iaddres !< |
---|
149 | INTEGER(iwp) :: iusern !< |
---|
150 | INTEGER(iwp) :: j !< |
---|
151 | INTEGER(iwp) :: k !< |
---|
152 | INTEGER(iwp) :: legpos = 1 !< |
---|
153 | INTEGER(iwp) :: timodex = 1 !< |
---|
154 | |
---|
155 | INTEGER(iwp), DIMENSION(10) :: klist !< |
---|
156 | |
---|
157 | LOGICAL :: avs_coor_file_found = .FALSE. !< |
---|
158 | LOGICAL :: avs_data_file_found = .FALSE. !< |
---|
159 | LOGICAL :: datleg = .TRUE. !< |
---|
160 | LOGICAL :: get_filenames !< |
---|
161 | LOGICAL :: grid = .TRUE. !< |
---|
162 | LOGICAL :: netcdf_extend !< |
---|
163 | LOGICAL :: rand = .TRUE. !< |
---|
164 | LOGICAL :: swap = .TRUE. !< |
---|
165 | LOGICAL :: twoxa = .TRUE. !< |
---|
166 | LOGICAL :: twoya = .TRUE. !< |
---|
167 | |
---|
168 | REAL(wp) :: ansx = -999.999_wp !< |
---|
169 | REAL(wp) :: ansy = -999.999_wp !< |
---|
170 | REAL(wp) :: gwid = 0.1_wp !< |
---|
171 | REAL(wp) :: rlegfak = 1.5_wp !< |
---|
172 | REAL(wp) :: sizex = 250.0_wp !< |
---|
173 | REAL(wp) :: sizey = 40.0_wp !< |
---|
174 | REAL(wp) :: texfac = 1.5_wp !< |
---|
175 | |
---|
176 | REAL(wp), DIMENSION(:), ALLOCATABLE :: eta !< |
---|
177 | REAL(wp), DIMENSION(:), ALLOCATABLE :: ho !< |
---|
178 | REAL(wp), DIMENSION(:), ALLOCATABLE :: hu !< |
---|
179 | |
---|
180 | |
---|
181 | |
---|
182 | NAMELIST /RAHMEN/ numline, cranz, datleg, rtext, swap |
---|
183 | NAMELIST /CROSS/ ansx, ansy, grid, gwid, klist, legpos, & |
---|
184 | rand, rlegfak, sizex, sizey, texfac, & |
---|
185 | timodex, twoxa, twoya, xtext |
---|
186 | |
---|
187 | |
---|
188 | ! |
---|
189 | !-- Immediate return if file already open |
---|
190 | IF ( openfile(file_id)%opened ) RETURN |
---|
191 | |
---|
192 | #if ! defined ( __check ) |
---|
193 | ! |
---|
194 | !-- Only certain files are allowed to be re-opened |
---|
195 | !-- NOTE: some of the other files perhaps also could be re-opened, but it |
---|
196 | !-- has not been checked so far, if it works! |
---|
197 | IF ( openfile(file_id)%opened_before ) THEN |
---|
198 | SELECT CASE ( file_id ) |
---|
199 | CASE ( 13, 14, 21, 22, 23, 80:85, 117 ) |
---|
200 | IF ( file_id == 14 .AND. openfile(file_id)%opened_before ) THEN |
---|
201 | message_string = 're-open of unit ' // & |
---|
202 | '14 is not verified. Please check results!' |
---|
203 | CALL message( 'check_open', 'PA0165', 0, 1, 0, 6, 0 ) |
---|
204 | ENDIF |
---|
205 | |
---|
206 | CASE DEFAULT |
---|
207 | WRITE( message_string, * ) 're-opening of file-id ', file_id, & |
---|
208 | ' is not allowed' |
---|
209 | CALL message( 'check_open', 'PA0166', 0, 1, 0, 6, 0 ) |
---|
210 | |
---|
211 | RETURN |
---|
212 | |
---|
213 | END SELECT |
---|
214 | ENDIF |
---|
215 | #endif |
---|
216 | |
---|
217 | ! |
---|
218 | !-- Check if file may be opened on the relevant PE |
---|
219 | SELECT CASE ( file_id ) |
---|
220 | |
---|
221 | CASE ( 15, 16, 17, 18, 19, 50:59, 81:84, 104:105, 107, 109, 117 ) |
---|
222 | |
---|
223 | IF ( myid /= 0 ) THEN |
---|
224 | WRITE( message_string, * ) 'opening file-id ',file_id, & |
---|
225 | ' not allowed for PE ',myid |
---|
226 | CALL message( 'check_open', 'PA0167', 2, 2, -1, 6, 1 ) |
---|
227 | ENDIF |
---|
228 | |
---|
229 | CASE ( 101:103, 106, 111:113, 116, 201:200+2*max_masks ) |
---|
230 | |
---|
231 | IF ( netcdf_data_format < 5 ) THEN |
---|
232 | |
---|
233 | IF ( myid /= 0 ) THEN |
---|
234 | WRITE( message_string, * ) 'opening file-id ',file_id, & |
---|
235 | ' not allowed for PE ',myid |
---|
236 | CALL message( 'check_open', 'PA0167', 2, 2, -1, 6, 1 ) |
---|
237 | ENDIF |
---|
238 | |
---|
239 | ENDIF |
---|
240 | |
---|
241 | CASE ( 21, 22, 23 ) |
---|
242 | |
---|
243 | IF ( .NOT. data_output_2d_on_each_pe ) THEN |
---|
244 | IF ( myid /= 0 ) THEN |
---|
245 | WRITE( message_string, * ) 'opening file-id ',file_id, & |
---|
246 | ' not allowed for PE ',myid |
---|
247 | CALL message( 'check_open', 'PA0167', 2, 2, -1, 6, 1 ) |
---|
248 | END IF |
---|
249 | ENDIF |
---|
250 | |
---|
251 | CASE ( 27, 28, 29, 31, 33, 71:73, 90:99 ) |
---|
252 | |
---|
253 | ! |
---|
254 | !-- File-ids that are used temporarily in other routines |
---|
255 | WRITE( message_string, * ) 'opening file-id ',file_id, & |
---|
256 | ' is not allowed since it is used otherwise' |
---|
257 | CALL message( 'check_open', 'PA0168', 0, 1, 0, 6, 0 ) |
---|
258 | |
---|
259 | END SELECT |
---|
260 | |
---|
261 | ! |
---|
262 | !-- Open relevant files |
---|
263 | SELECT CASE ( file_id ) |
---|
264 | |
---|
265 | CASE ( 11 ) |
---|
266 | |
---|
267 | #if defined ( __check ) |
---|
268 | ! |
---|
269 | !-- In case of a prior parameter file check, the p3d data is stored in |
---|
270 | !-- PARIN, while the p3df is stored in PARINF. This only applies to |
---|
271 | !-- check_namelist_files! |
---|
272 | IF ( check_restart == 2 ) THEN |
---|
273 | OPEN ( 11, FILE='PARINF'//coupling_char, FORM='FORMATTED', & |
---|
274 | STATUS='OLD' ) |
---|
275 | ELSE |
---|
276 | OPEN ( 11, FILE='PARIN'//coupling_char, FORM='FORMATTED', & |
---|
277 | STATUS='OLD' ) |
---|
278 | END IF |
---|
279 | #else |
---|
280 | |
---|
281 | OPEN ( 11, FILE='PARIN'//coupling_char, FORM='FORMATTED', & |
---|
282 | STATUS='OLD' ) |
---|
283 | #endif |
---|
284 | |
---|
285 | CASE ( 13 ) |
---|
286 | |
---|
287 | IF ( myid_char == '' ) THEN |
---|
288 | OPEN ( 13, FILE='BININ'//coupling_char//myid_char, & |
---|
289 | FORM='UNFORMATTED', STATUS='OLD' ) |
---|
290 | ELSE |
---|
291 | ! |
---|
292 | !-- First opening of unit 13 openes file _000000 on all PEs because |
---|
293 | !-- only this file contains the global variables |
---|
294 | IF ( .NOT. openfile(file_id)%opened_before ) THEN |
---|
295 | OPEN ( 13, FILE='BININ'//TRIM( coupling_char )//'/_000000', & |
---|
296 | FORM='UNFORMATTED', STATUS='OLD' ) |
---|
297 | ELSE |
---|
298 | OPEN ( 13, FILE='BININ'//TRIM( coupling_char )//'/'//myid_char,& |
---|
299 | FORM='UNFORMATTED', STATUS='OLD' ) |
---|
300 | ENDIF |
---|
301 | ENDIF |
---|
302 | |
---|
303 | CASE ( 14 ) |
---|
304 | |
---|
305 | IF ( myid_char == '' ) THEN |
---|
306 | OPEN ( 14, FILE='BINOUT'//coupling_char//myid_char, & |
---|
307 | FORM='UNFORMATTED', POSITION='APPEND' ) |
---|
308 | ELSE |
---|
309 | IF ( myid == 0 .AND. .NOT. openfile(file_id)%opened_before ) THEN |
---|
310 | CALL local_system( 'mkdir BINOUT' // coupling_char ) |
---|
311 | ENDIF |
---|
312 | #if defined( __parallel ) && ! defined ( __check ) |
---|
313 | ! |
---|
314 | !-- Set a barrier in order to allow that all other processors in the |
---|
315 | !-- directory created by PE0 can open their file |
---|
316 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
317 | #endif |
---|
318 | OPEN ( 14, FILE='BINOUT'//TRIM(coupling_char)//'/'//myid_char, & |
---|
319 | FORM='UNFORMATTED' ) |
---|
320 | ENDIF |
---|
321 | |
---|
322 | CASE ( 15 ) |
---|
323 | |
---|
324 | OPEN ( 15, FILE='RUN_CONTROL'//coupling_char, FORM='FORMATTED' ) |
---|
325 | |
---|
326 | CASE ( 16 ) |
---|
327 | |
---|
328 | OPEN ( 16, FILE='LIST_PROFIL'//coupling_char, FORM='FORMATTED' ) |
---|
329 | |
---|
330 | CASE ( 17 ) |
---|
331 | |
---|
332 | OPEN ( 17, FILE='LIST_PROFIL_1D'//coupling_char, FORM='FORMATTED' ) |
---|
333 | |
---|
334 | CASE ( 18 ) |
---|
335 | |
---|
336 | OPEN ( 18, FILE='CPU_MEASURES'//coupling_char, FORM='FORMATTED' ) |
---|
337 | |
---|
338 | CASE ( 19 ) |
---|
339 | |
---|
340 | OPEN ( 19, FILE='HEADER'//coupling_char, FORM='FORMATTED' ) |
---|
341 | |
---|
342 | CASE ( 20 ) |
---|
343 | |
---|
344 | IF ( myid == 0 .AND. .NOT. openfile(file_id)%opened_before ) THEN |
---|
345 | CALL local_system( 'mkdir DATA_LOG' // coupling_char ) |
---|
346 | ENDIF |
---|
347 | IF ( myid_char == '' ) THEN |
---|
348 | OPEN ( 20, FILE='DATA_LOG'//TRIM( coupling_char )//'/_000000', & |
---|
349 | FORM='UNFORMATTED', POSITION='APPEND' ) |
---|
350 | ELSE |
---|
351 | #if defined( __parallel ) && ! defined ( __check ) |
---|
352 | ! |
---|
353 | !-- Set a barrier in order to allow that all other processors in the |
---|
354 | !-- directory created by PE0 can open their file |
---|
355 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
356 | #endif |
---|
357 | OPEN ( 20, FILE='DATA_LOG'//TRIM( coupling_char )//'/'//myid_char,& |
---|
358 | FORM='UNFORMATTED', POSITION='APPEND' ) |
---|
359 | ENDIF |
---|
360 | |
---|
361 | CASE ( 21 ) |
---|
362 | |
---|
363 | IF ( data_output_2d_on_each_pe ) THEN |
---|
364 | OPEN ( 21, FILE='PLOT2D_XY'//TRIM( coupling_char )//myid_char, & |
---|
365 | FORM='UNFORMATTED', POSITION='APPEND' ) |
---|
366 | ELSE |
---|
367 | OPEN ( 21, FILE='PLOT2D_XY'//coupling_char, & |
---|
368 | FORM='UNFORMATTED', POSITION='APPEND' ) |
---|
369 | ENDIF |
---|
370 | |
---|
371 | IF ( myid == 0 .AND. .NOT. openfile(file_id)%opened_before ) THEN |
---|
372 | ! |
---|
373 | !-- Output for combine_plot_fields |
---|
374 | IF ( data_output_2d_on_each_pe .AND. myid_char /= '' ) THEN |
---|
375 | WRITE (21) -nbgp, nx+nbgp, -nbgp, ny+nbgp ! total array size |
---|
376 | WRITE (21) 0, nx+1, 0, ny+1 ! output part |
---|
377 | ENDIF |
---|
378 | ! |
---|
379 | !-- Determine and write ISO2D coordiante header |
---|
380 | ALLOCATE( eta(0:ny+1), ho(0:nx+1), hu(0:nx+1) ) |
---|
381 | hu = 0.0_wp |
---|
382 | ho = (ny+1) * dy |
---|
383 | DO i = 1, ny |
---|
384 | eta(i) = REAL( i ) / ( ny + 1.0_wp ) |
---|
385 | ENDDO |
---|
386 | eta(0) = 0.0_wp |
---|
387 | eta(ny+1) = 1.0_wp |
---|
388 | |
---|
389 | WRITE (21) dx,eta,hu,ho |
---|
390 | DEALLOCATE( eta, ho, hu ) |
---|
391 | |
---|
392 | ENDIF |
---|
393 | |
---|
394 | CASE ( 22 ) |
---|
395 | |
---|
396 | IF ( data_output_2d_on_each_pe ) THEN |
---|
397 | OPEN ( 22, FILE='PLOT2D_XZ'//TRIM( coupling_char )//myid_char, & |
---|
398 | FORM='UNFORMATTED', POSITION='APPEND' ) |
---|
399 | ELSE |
---|
400 | OPEN ( 22, FILE='PLOT2D_XZ'//coupling_char, FORM='UNFORMATTED', & |
---|
401 | POSITION='APPEND' ) |
---|
402 | ENDIF |
---|
403 | |
---|
404 | IF ( myid == 0 .AND. .NOT. openfile(file_id)%opened_before ) THEN |
---|
405 | ! |
---|
406 | !-- Output for combine_plot_fields |
---|
407 | IF ( data_output_2d_on_each_pe .AND. myid_char /= '' ) THEN |
---|
408 | WRITE (22) -nbgp, nx+nbgp, 0, nz+1 ! total array size |
---|
409 | WRITE (22) 0, nx+1, 0, nz+1 ! output part |
---|
410 | ENDIF |
---|
411 | ! |
---|
412 | !-- Determine and write ISO2D coordinate header |
---|
413 | ALLOCATE( eta(0:nz+1), ho(0:nx+1), hu(0:nx+1) ) |
---|
414 | hu = 0.0_wp |
---|
415 | ho = zu(nz+1) |
---|
416 | DO i = 1, nz |
---|
417 | eta(i) = REAL( zu(i) ) / zu(nz+1) |
---|
418 | ENDDO |
---|
419 | eta(0) = 0.0_wp |
---|
420 | eta(nz+1) = 1.0_wp |
---|
421 | |
---|
422 | WRITE (22) dx,eta,hu,ho |
---|
423 | DEALLOCATE( eta, ho, hu ) |
---|
424 | |
---|
425 | ENDIF |
---|
426 | |
---|
427 | CASE ( 23 ) |
---|
428 | |
---|
429 | IF ( data_output_2d_on_each_pe ) THEN |
---|
430 | OPEN ( 23, FILE='PLOT2D_YZ'//TRIM( coupling_char )//myid_char, & |
---|
431 | FORM='UNFORMATTED', POSITION='APPEND' ) |
---|
432 | ELSE |
---|
433 | OPEN ( 23, FILE='PLOT2D_YZ'//coupling_char, FORM='UNFORMATTED', & |
---|
434 | POSITION='APPEND' ) |
---|
435 | ENDIF |
---|
436 | |
---|
437 | IF ( myid == 0 .AND. .NOT. openfile(file_id)%opened_before ) THEN |
---|
438 | ! |
---|
439 | !-- Output for combine_plot_fields |
---|
440 | IF ( data_output_2d_on_each_pe .AND. myid_char /= '' ) THEN |
---|
441 | WRITE (23) -nbgp, ny+nbgp, 0, nz+1 ! total array size |
---|
442 | WRITE (23) 0, ny+1, 0, nz+1 ! output part |
---|
443 | ENDIF |
---|
444 | ! |
---|
445 | !-- Determine and write ISO2D coordiante header |
---|
446 | ALLOCATE( eta(0:nz+1), ho(0:ny+1), hu(0:ny+1) ) |
---|
447 | hu = 0.0_wp |
---|
448 | ho = zu(nz+1) |
---|
449 | DO i = 1, nz |
---|
450 | eta(i) = REAL( zu(i) ) / zu(nz+1) |
---|
451 | ENDDO |
---|
452 | eta(0) = 0.0_wp |
---|
453 | eta(nz+1) = 1.0_wp |
---|
454 | |
---|
455 | WRITE (23) dx,eta,hu,ho |
---|
456 | DEALLOCATE( eta, ho, hu ) |
---|
457 | |
---|
458 | ENDIF |
---|
459 | |
---|
460 | CASE ( 30 ) |
---|
461 | |
---|
462 | OPEN ( 30, FILE='PLOT3D_DATA'//TRIM( coupling_char )//myid_char, & |
---|
463 | FORM='UNFORMATTED' ) |
---|
464 | ! |
---|
465 | !-- Write coordinate file for AVS |
---|
466 | IF ( myid == 0 ) THEN |
---|
467 | #if defined( __parallel ) |
---|
468 | ! |
---|
469 | !-- Specifications for combine_plot_fields |
---|
470 | WRITE ( 30 ) -nbgp,nx+nbgp,-nbgp,ny+nbgp |
---|
471 | WRITE ( 30 ) 0,nx+1,0,ny+1,0,nz_do3d |
---|
472 | #endif |
---|
473 | ENDIF |
---|
474 | |
---|
475 | CASE ( 50:59 ) |
---|
476 | |
---|
477 | IF ( statistic_regions == 0 .AND. file_id == 50 ) THEN |
---|
478 | suffix = '' |
---|
479 | ELSE |
---|
480 | WRITE ( suffix, '(''_'',I1)' ) file_id - 50 |
---|
481 | ENDIF |
---|
482 | OPEN ( file_id, FILE='PLOTTS_DATA'//TRIM( coupling_char )// & |
---|
483 | TRIM( suffix ), & |
---|
484 | FORM='FORMATTED', RECL=496 ) |
---|
485 | ! |
---|
486 | !-- Write PROFIL parameter file for output of time series |
---|
487 | !-- NOTE: To be on the safe side, this output is done at the beginning of |
---|
488 | !-- the model run (in case of collapse) and it is repeated in |
---|
489 | !-- close_file, then, however, with value ranges for the coordinate |
---|
490 | !-- systems |
---|
491 | ! |
---|
492 | !-- Firstly determine the number of the coordinate systems to be drawn |
---|
493 | cranz = 0 |
---|
494 | DO j = 1, 10 |
---|
495 | IF ( cross_ts_number_count(j) /= 0 ) cranz = cranz+1 |
---|
496 | ENDDO |
---|
497 | rtext = '\1.0 ' // TRIM( run_description_header ) // ' ' // & |
---|
498 | TRIM( region( file_id - 50 ) ) |
---|
499 | ! |
---|
500 | !-- Write RAHMEN parameter |
---|
501 | OPEN ( 90, FILE='PLOTTS_PAR'//TRIM( coupling_char )// & |
---|
502 | TRIM( suffix ), & |
---|
503 | FORM='FORMATTED', DELIM='APOSTROPHE' ) |
---|
504 | WRITE ( 90, RAHMEN ) |
---|
505 | ! |
---|
506 | !-- Determine and write CROSS parameters for the individual coordinate |
---|
507 | !-- systems |
---|
508 | DO j = 1, 10 |
---|
509 | k = cross_ts_number_count(j) |
---|
510 | IF ( k /= 0 ) THEN |
---|
511 | ! |
---|
512 | !-- Store curve numbers, colours and line style |
---|
513 | klist(1:k) = cross_ts_numbers(1:k,j) |
---|
514 | klist(k+1:10) = 999999 |
---|
515 | ! |
---|
516 | !-- Write CROSS parameter |
---|
517 | WRITE ( 90, CROSS ) |
---|
518 | |
---|
519 | ENDIF |
---|
520 | ENDDO |
---|
521 | |
---|
522 | CLOSE ( 90 ) |
---|
523 | ! |
---|
524 | !-- Write all labels at the top of the data file, but only during the |
---|
525 | !-- first run of a sequence of jobs. The following jobs copy the time |
---|
526 | !-- series data to the bottom of that file. |
---|
527 | IF ( runnr == 0 ) THEN |
---|
528 | WRITE ( file_id, 5000 ) TRIM( run_description_header ) // & |
---|
529 | ' ' // TRIM( region( file_id - 50 ) ) |
---|
530 | ENDIF |
---|
531 | |
---|
532 | |
---|
533 | CASE ( 80 ) |
---|
534 | |
---|
535 | IF ( myid_char == '' ) THEN |
---|
536 | OPEN ( 80, FILE='PARTICLE_INFOS'//TRIM(coupling_char)//myid_char, & |
---|
537 | FORM='FORMATTED', POSITION='APPEND' ) |
---|
538 | ELSE |
---|
539 | IF ( myid == 0 .AND. .NOT. openfile(80)%opened_before ) THEN |
---|
540 | CALL local_system( 'mkdir PARTICLE_INFOS' // coupling_char ) |
---|
541 | ENDIF |
---|
542 | #if defined( __parallel ) && ! defined ( __check ) |
---|
543 | ! |
---|
544 | !-- Set a barrier in order to allow that thereafter all other |
---|
545 | !-- processors in the directory created by PE0 can open their file. |
---|
546 | !-- WARNING: The following barrier will lead to hanging jobs, if |
---|
547 | !-- check_open is first called from routine |
---|
548 | !-- allocate_prt_memory! |
---|
549 | IF ( .NOT. openfile(80)%opened_before ) THEN |
---|
550 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
551 | ENDIF |
---|
552 | #endif |
---|
553 | OPEN ( 80, FILE='PARTICLE_INFOS'//TRIM( coupling_char )//'/'// & |
---|
554 | myid_char, & |
---|
555 | FORM='FORMATTED', POSITION='APPEND' ) |
---|
556 | ENDIF |
---|
557 | |
---|
558 | IF ( .NOT. openfile(80)%opened_before ) THEN |
---|
559 | WRITE ( 80, 8000 ) TRIM( run_description_header ) |
---|
560 | ENDIF |
---|
561 | |
---|
562 | CASE ( 81 ) |
---|
563 | |
---|
564 | OPEN ( 81, FILE='PLOTSP_X_PAR'//coupling_char, FORM='FORMATTED', & |
---|
565 | DELIM='APOSTROPHE', RECL=1500, POSITION='APPEND' ) |
---|
566 | |
---|
567 | CASE ( 82 ) |
---|
568 | |
---|
569 | OPEN ( 82, FILE='PLOTSP_X_DATA'//coupling_char, FORM='FORMATTED', & |
---|
570 | POSITION = 'APPEND' ) |
---|
571 | |
---|
572 | CASE ( 83 ) |
---|
573 | |
---|
574 | OPEN ( 83, FILE='PLOTSP_Y_PAR'//coupling_char, FORM='FORMATTED', & |
---|
575 | DELIM='APOSTROPHE', RECL=1500, POSITION='APPEND' ) |
---|
576 | |
---|
577 | CASE ( 84 ) |
---|
578 | |
---|
579 | OPEN ( 84, FILE='PLOTSP_Y_DATA'//coupling_char, FORM='FORMATTED', & |
---|
580 | POSITION='APPEND' ) |
---|
581 | |
---|
582 | CASE ( 85 ) |
---|
583 | |
---|
584 | IF ( myid_char == '' ) THEN |
---|
585 | OPEN ( 85, FILE='PARTICLE_DATA'//TRIM(coupling_char)//myid_char, & |
---|
586 | FORM='UNFORMATTED', POSITION='APPEND' ) |
---|
587 | ELSE |
---|
588 | IF ( myid == 0 .AND. .NOT. openfile(85)%opened_before ) THEN |
---|
589 | CALL local_system( 'mkdir PARTICLE_DATA' // coupling_char ) |
---|
590 | ENDIF |
---|
591 | #if defined( __parallel ) && ! defined ( __check ) |
---|
592 | ! |
---|
593 | !-- Set a barrier in order to allow that thereafter all other |
---|
594 | !-- processors in the directory created by PE0 can open their file |
---|
595 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
596 | #endif |
---|
597 | OPEN ( 85, FILE='PARTICLE_DATA'//TRIM( coupling_char )//'/'// & |
---|
598 | myid_char, & |
---|
599 | FORM='UNFORMATTED', POSITION='APPEND' ) |
---|
600 | ENDIF |
---|
601 | |
---|
602 | IF ( .NOT. openfile(85)%opened_before ) THEN |
---|
603 | WRITE ( 85 ) run_description_header |
---|
604 | ! |
---|
605 | !-- Attention: change version number whenever the output format on |
---|
606 | !-- unit 85 is changed (see also in routine |
---|
607 | !-- lpm_data_output_particles) |
---|
608 | rtext = 'data format version 3.1' |
---|
609 | WRITE ( 85 ) rtext |
---|
610 | WRITE ( 85 ) number_of_particle_groups, & |
---|
611 | max_number_of_particle_groups |
---|
612 | WRITE ( 85 ) particle_groups |
---|
613 | WRITE ( 85 ) nxl, nxr, nys, nyn, nzb, nzt, nbgp |
---|
614 | ENDIF |
---|
615 | |
---|
616 | #if defined( __netcdf ) |
---|
617 | CASE ( 101, 111 ) |
---|
618 | ! |
---|
619 | !-- Set filename depending on unit number |
---|
620 | IF ( file_id == 101 ) THEN |
---|
621 | filename = 'DATA_2D_XY_NETCDF' // coupling_char |
---|
622 | av = 0 |
---|
623 | ELSE |
---|
624 | filename = 'DATA_2D_XY_AV_NETCDF' // coupling_char |
---|
625 | av = 1 |
---|
626 | ENDIF |
---|
627 | ! |
---|
628 | !-- Inquire, if there is a netCDF file from a previuos run. This should |
---|
629 | !-- be opened for extension, if its dimensions and variables match the |
---|
630 | !-- actual run. |
---|
631 | INQUIRE( FILE=filename, EXIST=netcdf_extend ) |
---|
632 | |
---|
633 | IF ( netcdf_extend ) THEN |
---|
634 | ! |
---|
635 | !-- Open an existing netCDF file for output |
---|
636 | CALL open_write_netcdf_file( filename, id_set_xy(av), .TRUE., 20 ) |
---|
637 | ! |
---|
638 | !-- Read header information and set all ids. If there is a mismatch |
---|
639 | !-- between the previuos and the actual run, netcdf_extend is returned |
---|
640 | !-- as .FALSE. |
---|
641 | CALL define_netcdf_header( 'xy', netcdf_extend, av ) |
---|
642 | |
---|
643 | ! |
---|
644 | !-- Remove the local file, if it can not be extended |
---|
645 | IF ( .NOT. netcdf_extend ) THEN |
---|
646 | nc_stat = NF90_CLOSE( id_set_xy(av) ) |
---|
647 | CALL handle_netcdf_error( 'check_open', 21 ) |
---|
648 | IF ( myid == 0 ) CALL local_system( 'rm ' // TRIM( filename ) ) |
---|
649 | ENDIF |
---|
650 | |
---|
651 | ENDIF |
---|
652 | |
---|
653 | IF ( .NOT. netcdf_extend ) THEN |
---|
654 | ! |
---|
655 | !-- Create a new netCDF output file with requested netCDF format |
---|
656 | CALL create_netcdf_file( filename, id_set_xy(av), .TRUE., 22 ) |
---|
657 | |
---|
658 | ! |
---|
659 | !-- Define the header |
---|
660 | CALL define_netcdf_header( 'xy', netcdf_extend, av ) |
---|
661 | |
---|
662 | ! |
---|
663 | !-- In case of parallel netCDF output, create flag file which tells |
---|
664 | !-- combine_plot_fields that nothing is to do. |
---|
665 | IF ( myid == 0 .AND. netcdf_data_format > 4 ) THEN |
---|
666 | OPEN( 99, FILE='NO_COMBINE_PLOT_FIELDS_XY' ) |
---|
667 | WRITE ( 99, '(A)' ) 'no combine_plot_fields.x neccessary' |
---|
668 | CLOSE( 99 ) |
---|
669 | ENDIF |
---|
670 | |
---|
671 | ENDIF |
---|
672 | |
---|
673 | CASE ( 102, 112 ) |
---|
674 | ! |
---|
675 | !-- Set filename depending on unit number |
---|
676 | IF ( file_id == 102 ) THEN |
---|
677 | filename = 'DATA_2D_XZ_NETCDF' // coupling_char |
---|
678 | av = 0 |
---|
679 | ELSE |
---|
680 | filename = 'DATA_2D_XZ_AV_NETCDF' // coupling_char |
---|
681 | av = 1 |
---|
682 | ENDIF |
---|
683 | ! |
---|
684 | !-- Inquire, if there is a netCDF file from a previuos run. This should |
---|
685 | !-- be opened for extension, if its dimensions and variables match the |
---|
686 | !-- actual run. |
---|
687 | INQUIRE( FILE=filename, EXIST=netcdf_extend ) |
---|
688 | |
---|
689 | IF ( netcdf_extend ) THEN |
---|
690 | ! |
---|
691 | !-- Open an existing netCDF file for output |
---|
692 | CALL open_write_netcdf_file( filename, id_set_xz(av), .TRUE., 23 ) |
---|
693 | ! |
---|
694 | !-- Read header information and set all ids. If there is a mismatch |
---|
695 | !-- between the previuos and the actual run, netcdf_extend is returned |
---|
696 | !-- as .FALSE. |
---|
697 | CALL define_netcdf_header( 'xz', netcdf_extend, av ) |
---|
698 | |
---|
699 | ! |
---|
700 | !-- Remove the local file, if it can not be extended |
---|
701 | IF ( .NOT. netcdf_extend ) THEN |
---|
702 | nc_stat = NF90_CLOSE( id_set_xz(av) ) |
---|
703 | CALL handle_netcdf_error( 'check_open', 24 ) |
---|
704 | IF ( myid == 0 ) CALL local_system( 'rm ' // TRIM( filename ) ) |
---|
705 | ENDIF |
---|
706 | |
---|
707 | ENDIF |
---|
708 | |
---|
709 | IF ( .NOT. netcdf_extend ) THEN |
---|
710 | ! |
---|
711 | !-- Create a new netCDF output file with requested netCDF format |
---|
712 | CALL create_netcdf_file( filename, id_set_xz(av), .TRUE., 25 ) |
---|
713 | |
---|
714 | ! |
---|
715 | !-- Define the header |
---|
716 | CALL define_netcdf_header( 'xz', netcdf_extend, av ) |
---|
717 | |
---|
718 | ! |
---|
719 | !-- In case of parallel netCDF output, create flag file which tells |
---|
720 | !-- combine_plot_fields that nothing is to do. |
---|
721 | IF ( myid == 0 .AND. netcdf_data_format > 4 ) THEN |
---|
722 | OPEN( 99, FILE='NO_COMBINE_PLOT_FIELDS_XZ' ) |
---|
723 | WRITE ( 99, '(A)' ) 'no combine_plot_fields.x neccessary' |
---|
724 | CLOSE( 99 ) |
---|
725 | ENDIF |
---|
726 | |
---|
727 | ENDIF |
---|
728 | |
---|
729 | CASE ( 103, 113 ) |
---|
730 | ! |
---|
731 | !-- Set filename depending on unit number |
---|
732 | IF ( file_id == 103 ) THEN |
---|
733 | filename = 'DATA_2D_YZ_NETCDF' // coupling_char |
---|
734 | av = 0 |
---|
735 | ELSE |
---|
736 | filename = 'DATA_2D_YZ_AV_NETCDF' // coupling_char |
---|
737 | av = 1 |
---|
738 | ENDIF |
---|
739 | ! |
---|
740 | !-- Inquire, if there is a netCDF file from a previuos run. This should |
---|
741 | !-- be opened for extension, if its dimensions and variables match the |
---|
742 | !-- actual run. |
---|
743 | INQUIRE( FILE=filename, EXIST=netcdf_extend ) |
---|
744 | |
---|
745 | IF ( netcdf_extend ) THEN |
---|
746 | ! |
---|
747 | !-- Open an existing netCDF file for output |
---|
748 | CALL open_write_netcdf_file( filename, id_set_yz(av), .TRUE., 26 ) |
---|
749 | ! |
---|
750 | !-- Read header information and set all ids. If there is a mismatch |
---|
751 | !-- between the previuos and the actual run, netcdf_extend is returned |
---|
752 | !-- as .FALSE. |
---|
753 | CALL define_netcdf_header( 'yz', netcdf_extend, av ) |
---|
754 | |
---|
755 | ! |
---|
756 | !-- Remove the local file, if it can not be extended |
---|
757 | IF ( .NOT. netcdf_extend ) THEN |
---|
758 | nc_stat = NF90_CLOSE( id_set_yz(av) ) |
---|
759 | CALL handle_netcdf_error( 'check_open', 27 ) |
---|
760 | IF ( myid == 0 ) CALL local_system( 'rm ' // TRIM( filename ) ) |
---|
761 | ENDIF |
---|
762 | |
---|
763 | ENDIF |
---|
764 | |
---|
765 | IF ( .NOT. netcdf_extend ) THEN |
---|
766 | ! |
---|
767 | !-- Create a new netCDF output file with requested netCDF format |
---|
768 | CALL create_netcdf_file( filename, id_set_yz(av), .TRUE., 28 ) |
---|
769 | |
---|
770 | ! |
---|
771 | !-- Define the header |
---|
772 | CALL define_netcdf_header( 'yz', netcdf_extend, av ) |
---|
773 | |
---|
774 | ! |
---|
775 | !-- In case of parallel netCDF output, create flag file which tells |
---|
776 | !-- combine_plot_fields that nothing is to do. |
---|
777 | IF ( myid == 0 .AND. netcdf_data_format > 4 ) THEN |
---|
778 | OPEN( 99, FILE='NO_COMBINE_PLOT_FIELDS_YZ' ) |
---|
779 | WRITE ( 99, '(A)' ) 'no combine_plot_fields.x neccessary' |
---|
780 | CLOSE( 99 ) |
---|
781 | ENDIF |
---|
782 | |
---|
783 | ENDIF |
---|
784 | |
---|
785 | CASE ( 104 ) |
---|
786 | ! |
---|
787 | !-- Set filename |
---|
788 | filename = 'DATA_1D_PR_NETCDF' // coupling_char |
---|
789 | |
---|
790 | ! |
---|
791 | !-- Inquire, if there is a netCDF file from a previuos run. This should |
---|
792 | !-- be opened for extension, if its variables match the actual run. |
---|
793 | INQUIRE( FILE=filename, EXIST=netcdf_extend ) |
---|
794 | |
---|
795 | IF ( netcdf_extend ) THEN |
---|
796 | ! |
---|
797 | !-- Open an existing netCDF file for output |
---|
798 | CALL open_write_netcdf_file( filename, id_set_pr, .FALSE., 29 ) |
---|
799 | ! |
---|
800 | !-- Read header information and set all ids. If there is a mismatch |
---|
801 | !-- between the previuos and the actual run, netcdf_extend is returned |
---|
802 | !-- as .FALSE. |
---|
803 | CALL define_netcdf_header( 'pr', netcdf_extend, 0 ) |
---|
804 | |
---|
805 | ! |
---|
806 | !-- Remove the local file, if it can not be extended |
---|
807 | IF ( .NOT. netcdf_extend ) THEN |
---|
808 | nc_stat = NF90_CLOSE( id_set_pr ) |
---|
809 | CALL handle_netcdf_error( 'check_open', 30 ) |
---|
810 | CALL local_system( 'rm ' // TRIM( filename ) ) |
---|
811 | ENDIF |
---|
812 | |
---|
813 | ENDIF |
---|
814 | |
---|
815 | IF ( .NOT. netcdf_extend ) THEN |
---|
816 | ! |
---|
817 | !-- Create a new netCDF output file with requested netCDF format |
---|
818 | CALL create_netcdf_file( filename, id_set_pr, .FALSE., 31 ) |
---|
819 | ! |
---|
820 | !-- Define the header |
---|
821 | CALL define_netcdf_header( 'pr', netcdf_extend, 0 ) |
---|
822 | |
---|
823 | ENDIF |
---|
824 | |
---|
825 | CASE ( 105 ) |
---|
826 | ! |
---|
827 | !-- Set filename |
---|
828 | filename = 'DATA_1D_TS_NETCDF' // coupling_char |
---|
829 | |
---|
830 | ! |
---|
831 | !-- Inquire, if there is a netCDF file from a previuos run. This should |
---|
832 | !-- be opened for extension, if its variables match the actual run. |
---|
833 | INQUIRE( FILE=filename, EXIST=netcdf_extend ) |
---|
834 | |
---|
835 | IF ( netcdf_extend ) THEN |
---|
836 | ! |
---|
837 | !-- Open an existing netCDF file for output |
---|
838 | CALL open_write_netcdf_file( filename, id_set_ts, .FALSE., 32 ) |
---|
839 | ! |
---|
840 | !-- Read header information and set all ids. If there is a mismatch |
---|
841 | !-- between the previuos and the actual run, netcdf_extend is returned |
---|
842 | !-- as .FALSE. |
---|
843 | CALL define_netcdf_header( 'ts', netcdf_extend, 0 ) |
---|
844 | |
---|
845 | ! |
---|
846 | !-- Remove the local file, if it can not be extended |
---|
847 | IF ( .NOT. netcdf_extend ) THEN |
---|
848 | nc_stat = NF90_CLOSE( id_set_ts ) |
---|
849 | CALL handle_netcdf_error( 'check_open', 33 ) |
---|
850 | CALL local_system( 'rm ' // TRIM( filename ) ) |
---|
851 | ENDIF |
---|
852 | |
---|
853 | ENDIF |
---|
854 | |
---|
855 | IF ( .NOT. netcdf_extend ) THEN |
---|
856 | ! |
---|
857 | !-- Create a new netCDF output file with requested netCDF format |
---|
858 | CALL create_netcdf_file( filename, id_set_ts, .FALSE., 34 ) |
---|
859 | ! |
---|
860 | !-- Define the header |
---|
861 | CALL define_netcdf_header( 'ts', netcdf_extend, 0 ) |
---|
862 | |
---|
863 | ENDIF |
---|
864 | |
---|
865 | |
---|
866 | CASE ( 106, 116 ) |
---|
867 | ! |
---|
868 | !-- Set filename depending on unit number |
---|
869 | IF ( file_id == 106 ) THEN |
---|
870 | filename = 'DATA_3D_NETCDF' // coupling_char |
---|
871 | av = 0 |
---|
872 | ELSE |
---|
873 | filename = 'DATA_3D_AV_NETCDF' // coupling_char |
---|
874 | av = 1 |
---|
875 | ENDIF |
---|
876 | ! |
---|
877 | !-- Inquire, if there is a netCDF file from a previous run. This should |
---|
878 | !-- be opened for extension, if its dimensions and variables match the |
---|
879 | !-- actual run. |
---|
880 | INQUIRE( FILE=filename, EXIST=netcdf_extend ) |
---|
881 | |
---|
882 | IF ( netcdf_extend ) THEN |
---|
883 | ! |
---|
884 | !-- Open an existing netCDF file for output |
---|
885 | CALL open_write_netcdf_file( filename, id_set_3d(av), .TRUE., 35 ) |
---|
886 | ! |
---|
887 | !-- Read header information and set all ids. If there is a mismatch |
---|
888 | !-- between the previuos and the actual run, netcdf_extend is returned |
---|
889 | !-- as .FALSE. |
---|
890 | CALL define_netcdf_header( '3d', netcdf_extend, av ) |
---|
891 | |
---|
892 | ! |
---|
893 | !-- Remove the local file, if it can not be extended |
---|
894 | IF ( .NOT. netcdf_extend ) THEN |
---|
895 | nc_stat = NF90_CLOSE( id_set_3d(av) ) |
---|
896 | CALL handle_netcdf_error( 'check_open', 36 ) |
---|
897 | CALL local_system('rm ' // TRIM( filename ) ) |
---|
898 | ENDIF |
---|
899 | |
---|
900 | ENDIF |
---|
901 | |
---|
902 | IF ( .NOT. netcdf_extend ) THEN |
---|
903 | ! |
---|
904 | !-- Create a new netCDF output file with requested netCDF format |
---|
905 | CALL create_netcdf_file( filename, id_set_3d(av), .TRUE., 37 ) |
---|
906 | |
---|
907 | ! |
---|
908 | !-- Define the header |
---|
909 | CALL define_netcdf_header( '3d', netcdf_extend, av ) |
---|
910 | |
---|
911 | ! |
---|
912 | !-- In case of parallel netCDF output, create flag file which tells |
---|
913 | !-- combine_plot_fields that nothing is to do. |
---|
914 | IF ( myid == 0 .AND. netcdf_data_format > 4 ) THEN |
---|
915 | OPEN( 99, FILE='NO_COMBINE_PLOT_FIELDS_3D' ) |
---|
916 | WRITE ( 99, '(A)' ) 'no combine_plot_fields.x neccessary' |
---|
917 | CLOSE( 99 ) |
---|
918 | ENDIF |
---|
919 | |
---|
920 | ENDIF |
---|
921 | |
---|
922 | |
---|
923 | CASE ( 107 ) |
---|
924 | ! |
---|
925 | !-- Set filename |
---|
926 | filename = 'DATA_1D_SP_NETCDF' // coupling_char |
---|
927 | |
---|
928 | ! |
---|
929 | !-- Inquire, if there is a netCDF file from a previuos run. This should |
---|
930 | !-- be opened for extension, if its variables match the actual run. |
---|
931 | INQUIRE( FILE=filename, EXIST=netcdf_extend ) |
---|
932 | |
---|
933 | IF ( netcdf_extend ) THEN |
---|
934 | ! |
---|
935 | !-- Open an existing netCDF file for output |
---|
936 | CALL open_write_netcdf_file( filename, id_set_sp, .FALSE., 38 ) |
---|
937 | |
---|
938 | ! |
---|
939 | !-- Read header information and set all ids. If there is a mismatch |
---|
940 | !-- between the previuos and the actual run, netcdf_extend is returned |
---|
941 | !-- as .FALSE. |
---|
942 | CALL define_netcdf_header( 'sp', netcdf_extend, 0 ) |
---|
943 | |
---|
944 | ! |
---|
945 | !-- Remove the local file, if it can not be extended |
---|
946 | IF ( .NOT. netcdf_extend ) THEN |
---|
947 | nc_stat = NF90_CLOSE( id_set_sp ) |
---|
948 | CALL handle_netcdf_error( 'check_open', 39 ) |
---|
949 | CALL local_system( 'rm ' // TRIM( filename ) ) |
---|
950 | ENDIF |
---|
951 | |
---|
952 | ENDIF |
---|
953 | |
---|
954 | IF ( .NOT. netcdf_extend ) THEN |
---|
955 | ! |
---|
956 | !-- Create a new netCDF output file with requested netCDF format |
---|
957 | CALL create_netcdf_file( filename, id_set_sp, .FALSE., 40 ) |
---|
958 | ! |
---|
959 | !-- Define the header |
---|
960 | CALL define_netcdf_header( 'sp', netcdf_extend, 0 ) |
---|
961 | |
---|
962 | ENDIF |
---|
963 | |
---|
964 | |
---|
965 | CASE ( 108 ) |
---|
966 | |
---|
967 | IF ( myid_char == '' ) THEN |
---|
968 | filename = 'DATA_PRT_NETCDF' // coupling_char |
---|
969 | ELSE |
---|
970 | filename = 'DATA_PRT_NETCDF' // TRIM( coupling_char ) // '/' // & |
---|
971 | myid_char |
---|
972 | ENDIF |
---|
973 | ! |
---|
974 | !-- Inquire, if there is a netCDF file from a previuos run. This should |
---|
975 | !-- be opened for extension, if its variables match the actual run. |
---|
976 | INQUIRE( FILE=filename, EXIST=netcdf_extend ) |
---|
977 | |
---|
978 | IF ( netcdf_extend ) THEN |
---|
979 | ! |
---|
980 | !-- Open an existing netCDF file for output |
---|
981 | CALL open_write_netcdf_file( filename, id_set_prt, .FALSE., 41 ) |
---|
982 | ! |
---|
983 | !-- Read header information and set all ids. If there is a mismatch |
---|
984 | !-- between the previuos and the actual run, netcdf_extend is returned |
---|
985 | !-- as .FALSE. |
---|
986 | CALL define_netcdf_header( 'pt', netcdf_extend, 0 ) |
---|
987 | |
---|
988 | ! |
---|
989 | !-- Remove the local file, if it can not be extended |
---|
990 | IF ( .NOT. netcdf_extend ) THEN |
---|
991 | nc_stat = NF90_CLOSE( id_set_prt ) |
---|
992 | CALL handle_netcdf_error( 'check_open', 42 ) |
---|
993 | CALL local_system( 'rm ' // filename ) |
---|
994 | ENDIF |
---|
995 | |
---|
996 | ENDIF |
---|
997 | |
---|
998 | IF ( .NOT. netcdf_extend ) THEN |
---|
999 | |
---|
1000 | ! |
---|
1001 | !-- For runs on multiple processors create the subdirectory |
---|
1002 | IF ( myid_char /= '' ) THEN |
---|
1003 | IF ( myid == 0 .AND. .NOT. openfile(file_id)%opened_before ) & |
---|
1004 | THEN ! needs modification in case of non-extendable sets |
---|
1005 | CALL local_system( 'mkdir DATA_PRT_NETCDF' // & |
---|
1006 | TRIM( coupling_char ) // '/' ) |
---|
1007 | ENDIF |
---|
1008 | #if defined( __parallel ) && ! defined ( __check ) |
---|
1009 | ! |
---|
1010 | !-- Set a barrier in order to allow that all other processors in the |
---|
1011 | !-- directory created by PE0 can open their file |
---|
1012 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
1013 | #endif |
---|
1014 | ENDIF |
---|
1015 | |
---|
1016 | ! |
---|
1017 | !-- Create a new netCDF output file with requested netCDF format |
---|
1018 | CALL create_netcdf_file( filename, id_set_prt, .FALSE., 43 ) |
---|
1019 | |
---|
1020 | ! |
---|
1021 | !-- Define the header |
---|
1022 | CALL define_netcdf_header( 'pt', netcdf_extend, 0 ) |
---|
1023 | |
---|
1024 | ENDIF |
---|
1025 | |
---|
1026 | CASE ( 109 ) |
---|
1027 | ! |
---|
1028 | !-- Set filename |
---|
1029 | filename = 'DATA_1D_PTS_NETCDF' // coupling_char |
---|
1030 | |
---|
1031 | ! |
---|
1032 | !-- Inquire, if there is a netCDF file from a previuos run. This should |
---|
1033 | !-- be opened for extension, if its variables match the actual run. |
---|
1034 | INQUIRE( FILE=filename, EXIST=netcdf_extend ) |
---|
1035 | |
---|
1036 | IF ( netcdf_extend ) THEN |
---|
1037 | ! |
---|
1038 | !-- Open an existing netCDF file for output |
---|
1039 | CALL open_write_netcdf_file( filename, id_set_pts, .FALSE., 393 ) |
---|
1040 | ! |
---|
1041 | !-- Read header information and set all ids. If there is a mismatch |
---|
1042 | !-- between the previuos and the actual run, netcdf_extend is returned |
---|
1043 | !-- as .FALSE. |
---|
1044 | CALL define_netcdf_header( 'ps', netcdf_extend, 0 ) |
---|
1045 | |
---|
1046 | ! |
---|
1047 | !-- Remove the local file, if it can not be extended |
---|
1048 | IF ( .NOT. netcdf_extend ) THEN |
---|
1049 | nc_stat = NF90_CLOSE( id_set_pts ) |
---|
1050 | CALL handle_netcdf_error( 'check_open', 394 ) |
---|
1051 | CALL local_system( 'rm ' // TRIM( filename ) ) |
---|
1052 | ENDIF |
---|
1053 | |
---|
1054 | ENDIF |
---|
1055 | |
---|
1056 | IF ( .NOT. netcdf_extend ) THEN |
---|
1057 | ! |
---|
1058 | !-- Create a new netCDF output file with requested netCDF format |
---|
1059 | CALL create_netcdf_file( filename, id_set_pts, .FALSE., 395 ) |
---|
1060 | ! |
---|
1061 | !-- Define the header |
---|
1062 | CALL define_netcdf_header( 'ps', netcdf_extend, 0 ) |
---|
1063 | |
---|
1064 | ENDIF |
---|
1065 | |
---|
1066 | |
---|
1067 | ! |
---|
1068 | !-- Progress file that is used by the PALM watchdog |
---|
1069 | CASE ( 117 ) |
---|
1070 | |
---|
1071 | OPEN ( 117, FILE='PROGRESS'//coupling_char, STATUS='REPLACE', FORM='FORMATTED' ) |
---|
1072 | |
---|
1073 | |
---|
1074 | CASE ( 201:200+2*max_masks ) |
---|
1075 | ! |
---|
1076 | !-- Set filename depending on unit number |
---|
1077 | IF ( file_id <= 200+max_masks ) THEN |
---|
1078 | mid = file_id - 200 |
---|
1079 | WRITE ( mask_char,'(I2.2)') mid |
---|
1080 | filename = 'DATA_MASK_' // mask_char // '_NETCDF' // coupling_char |
---|
1081 | av = 0 |
---|
1082 | ELSE |
---|
1083 | mid = file_id - (200+max_masks) |
---|
1084 | WRITE ( mask_char,'(I2.2)') mid |
---|
1085 | filename = 'DATA_MASK_' // mask_char // '_AV_NETCDF' // & |
---|
1086 | coupling_char |
---|
1087 | av = 1 |
---|
1088 | ENDIF |
---|
1089 | ! |
---|
1090 | !-- Inquire, if there is a netCDF file from a previuos run. This should |
---|
1091 | !-- be opened for extension, if its dimensions and variables match the |
---|
1092 | !-- actual run. |
---|
1093 | INQUIRE( FILE=filename, EXIST=netcdf_extend ) |
---|
1094 | |
---|
1095 | IF ( netcdf_extend ) THEN |
---|
1096 | ! |
---|
1097 | !-- Open an existing netCDF file for output |
---|
1098 | CALL open_write_netcdf_file( filename, id_set_mask(mid,av), & |
---|
1099 | .TRUE., 456 ) |
---|
1100 | ! |
---|
1101 | !-- Read header information and set all ids. If there is a mismatch |
---|
1102 | !-- between the previuos and the actual run, netcdf_extend is returned |
---|
1103 | !-- as .FALSE. |
---|
1104 | CALL define_netcdf_header( 'ma', netcdf_extend, file_id ) |
---|
1105 | |
---|
1106 | ! |
---|
1107 | !-- Remove the local file, if it can not be extended |
---|
1108 | IF ( .NOT. netcdf_extend ) THEN |
---|
1109 | nc_stat = NF90_CLOSE( id_set_mask(mid,av) ) |
---|
1110 | CALL handle_netcdf_error( 'check_open', 457 ) |
---|
1111 | CALL local_system('rm ' // TRIM( filename ) ) |
---|
1112 | ENDIF |
---|
1113 | |
---|
1114 | ENDIF |
---|
1115 | |
---|
1116 | IF ( .NOT. netcdf_extend ) THEN |
---|
1117 | ! |
---|
1118 | !-- Create a new netCDF output file with requested netCDF format |
---|
1119 | CALL create_netcdf_file( filename, id_set_mask(mid,av), .TRUE., 458 ) |
---|
1120 | ! |
---|
1121 | !-- Define the header |
---|
1122 | CALL define_netcdf_header( 'ma', netcdf_extend, file_id ) |
---|
1123 | |
---|
1124 | ENDIF |
---|
1125 | |
---|
1126 | |
---|
1127 | #else |
---|
1128 | |
---|
1129 | CASE ( 101:109, 111:113, 116, 201:200+2*max_masks ) |
---|
1130 | |
---|
1131 | ! |
---|
1132 | !-- Nothing is done in case of missing netcdf support |
---|
1133 | RETURN |
---|
1134 | |
---|
1135 | #endif |
---|
1136 | |
---|
1137 | CASE DEFAULT |
---|
1138 | |
---|
1139 | WRITE( message_string, * ) 'no OPEN-statement for file-id ',file_id |
---|
1140 | CALL message( 'check_open', 'PA0172', 2, 2, -1, 6, 1 ) |
---|
1141 | |
---|
1142 | END SELECT |
---|
1143 | |
---|
1144 | ! |
---|
1145 | !-- Set open flag |
---|
1146 | openfile(file_id)%opened = .TRUE. |
---|
1147 | |
---|
1148 | ! |
---|
1149 | !-- Formats |
---|
1150 | 3300 FORMAT ('#'/ & |
---|
1151 | 'coord 1 file=',A,' filetype=unformatted'/ & |
---|
1152 | 'coord 2 file=',A,' filetype=unformatted skip=',I6/ & |
---|
1153 | 'coord 3 file=',A,' filetype=unformatted skip=',I6/ & |
---|
1154 | '#') |
---|
1155 | 4000 FORMAT ('# ',A) |
---|
1156 | 5000 FORMAT ('# ',A/ & |
---|
1157 | '#1 E'/'#2 E*'/'#3 dt'/'#4 u*'/'#5 th*'/'#6 umax'/'#7 vmax'/ & |
---|
1158 | '#8 wmax'/'#9 div_new'/'#10 div_old'/'#11 z_i_wpt'/'#12 z_i_pt'/ & |
---|
1159 | '#13 w*'/'#14 w''pt''0'/'#15 w''pt'''/'#16 wpt'/'#17 pt(0)'/ & |
---|
1160 | '#18 pt(zp)'/'#19 splptx'/'#20 splpty'/'#21 splptz') |
---|
1161 | 8000 FORMAT (A/ & |
---|
1162 | ' step time # of parts lPE sent/recv rPE sent/recv ',& |
---|
1163 | 'sPE sent/recv nPE sent/recv max # of parts '/ & |
---|
1164 | 109('-')) |
---|
1165 | |
---|
1166 | END SUBROUTINE check_open |
---|