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

Last change on this file since 105 was 105, checked in by raasch, 17 years ago

bugs in check_open and user_interface removed

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