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