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