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