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