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