source: palm/trunk/SOURCE/check_open.f90 @ 1035

Last change on this file since 1035 was 1035, checked in by raasch, 11 years ago

revisions r1031 and r1034 documented

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