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