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