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