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