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

Last change on this file since 1745 was 1745, checked in by gronemeier, 8 years ago

Bugfix:calculation of time levels for parallel NetCDF output

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