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