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