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