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