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