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