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