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