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