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