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