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