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