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