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