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