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