Ignore:
Timestamp:
Mar 1, 2010 8:30:24 AM (14 years ago)
Author:
raasch
Message:

New:
---
Output in NetCDF4-format. New d3par-parameter netcdf_data_format.

(check_open, check_parameters, close_file, data_output_2d, data_output_3d, header, modules, netcdf, parin)

Modules to be loaded for compilation (mbuild) or job execution (mrun)
can be given in the configuration file using variable modules. Example:

%modules ifort/11.0.069:netcdf lcsgih parallel

This method replaces the (undocumented) mpilib-variable.

WARNING: All fixed settings of modules in the scripts mbuild, mrun, and subjob
have been removed! Please set the modules variable appropriately in your
configuration file. (mbuild, mrun, subjob)

Changed:


Parameters netcdf_64bit and netcdf_64bit_3d have been removed. Use
netcdf_data_format = 2 for choosing the classic 64bit-offset format (this is
the default). The offset-format can not be set independently for the
3d-output-data any more.

Parameters netcdf_format_mask, netcdf_format_mask_av, and variables
nc_format_mask, format_parallel_io removed. They are replaced by the new
parameter netcdf_data_format. (check_open, close_file,
data_output_mask, header, init_masks, modules, parin)

Errors:


bugfix in trunk/UTIL/Makefile: forgot to compile for interpret_config

Bugfix: timeseries data have to be collected by PE0 (user_statistics)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/data_output_2d.f90

    r392 r493  
    7373    CHARACTER (LEN=25) ::  section_chr
    7474    CHARACTER (LEN=50) ::  rtext
    75     INTEGER ::  av, ngp, file_id, i, if, is, j, k, l, layer_xy, n, psi, s, &
    76                 sender, &
     75    INTEGER ::  av, ngp, file_id, i, if, is, iis, j, k, l, layer_xy, n, psi, &
     76                s, sender, &
    7777                ind(4)
    7878    LOGICAL ::  found, resorted, two_d
     
    110110          ALLOCATE( level_z(0:nzt+1), local_2d(nxl-1:nxr+1,nys-1:nyn+1) )
    111111
    112 #if defined( __netcdf )
    113           IF ( myid == 0  .AND.  netcdf_output )  CALL check_open( 101+av*10 )
    114 #endif
     112!
     113!--       Classic and 64bit offset NetCDF output is done only on PE0.
     114!--       netCDF4/HDF5 output is done in parallel on all PEs.
     115          IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 2 ) ) &
     116          THEN
     117             CALL check_open( 101+av*10 )
     118          ENDIF
    115119
    116120          IF ( data_output_2d_on_each_pe )  THEN
     
    130134          ALLOCATE( local_2d(nxl-1:nxr+1,nzb:nzt+1) )
    131135
    132 #if defined( __netcdf )
    133           IF ( myid == 0  .AND.  netcdf_output )  CALL check_open( 102+av*10 )
    134 #endif
     136!
     137!--       Classic and 64bit offset NetCDF output is done only on PE0.
     138!--       netCDF4/HDF5 output may be done in parallel on all PEs.
     139          IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 2 ) ) &
     140          THEN
     141             CALL check_open( 102+av*10 )
     142          ENDIF
    135143
    136144          IF ( data_output_2d_on_each_pe )  THEN
     
    150158          ALLOCATE( local_2d(nys-1:nyn+1,nzb:nzt+1) )
    151159
    152 #if defined( __netcdf )
    153           IF ( myid == 0  .AND.  netcdf_output )  CALL check_open( 103+av*10 )
    154 #endif
     160!
     161!--       Classic and 64bit offset NetCDF output is done only on PE0.
     162!--       netCDF4/HDF5 output may be done in parallel on all PEs.
     163          IF ( netcdf_output .AND. ( myid == 0 .OR. netcdf_data_format > 2 ) ) &
     164          THEN
     165             CALL check_open( 103+av*10 )
     166          ENDIF
    155167
    156168          IF ( data_output_2d_on_each_pe )  THEN
     
    603615!
    604616!--                Update the NetCDF xy cross section time axis
    605                    IF ( myid == 0 )  THEN
     617                   IF ( myid == 0  .OR.  netcdf_data_format > 2 )  THEN
    606618                      IF ( simulated_time /= do2d_xy_last_time(av) )  THEN
    607619                         do2d_xy_time_count(av) = do2d_xy_time_count(av) + 1
    608620                         do2d_xy_last_time(av)  = simulated_time
    609                          IF ( .NOT. data_output_2d_on_each_pe  .AND. &
    610                               netcdf_output )  THEN
     621                         IF ( ( .NOT. data_output_2d_on_each_pe  .AND. &
     622                              netcdf_output )  .OR.  netcdf_data_format > 2 ) &
     623                         THEN
    611624#if defined( __netcdf )
    612625                            nc_stat = NF90_PUT_VAR( id_set_xy(av),             &
     
    615628                                         start = (/ do2d_xy_time_count(av) /), &
    616629                                                    count = (/ 1 /) )
    617                          CALL handle_netcdf_error( 'data_output_2d', 53 )
     630                            CALL handle_netcdf_error( 'data_output_2d', 53 )
    618631#endif
    619632                         ENDIF
     
    645658
    646659#if defined( __parallel )
    647                    IF ( data_output_2d_on_each_pe )  THEN
    648 !
    649 !--                   Output of partial arrays on each PE
     660                   IF ( netcdf_output  .AND.  netcdf_data_format > 2 )  THEN
     661!
     662!--                   Output in NetCDF4/HDF5 format.
     663!--                   Do not output redundant ghost point data except for the
     664!--                   boundaries of the total domain.
     665                      IF ( two_d ) THEN
     666                         iis = 1
     667                      ELSE
     668                         iis = is
     669                      ENDIF
     670
    650671#if defined( __netcdf )
    651                       IF ( netcdf_output  .AND.  myid == 0 )  THEN
    652                          WRITE ( 21 )  simulated_time, do2d_xy_time_count(av), &
    653                                        av
    654                       ENDIF
    655 #endif
    656                       WRITE ( 21 )  nxl-1, nxr+1, nys-1, nyn+1
    657                       WRITE ( 21 )  local_2d
    658 
     672                      IF ( nxr == nx  .AND.  nyn /= ny )  THEN
     673                         nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
     674                                                 id_var_do2d(av,if),           &
     675                                                 local_2d(nxl:nxr+1,nys:nyn),  &
     676                                                 start = (/ nxl+1, nys+1, iis, &
     677                                                    do2d_xy_time_count(av) /), &
     678                                                 count = (/ nxr-nxl+2,         &
     679                                                            nyn-nys+1, 1, 1 /) )
     680                      ELSEIF ( nxr /= nx  .AND.  nyn == ny )  THEN
     681                         nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
     682                                                 id_var_do2d(av,if),           &
     683                                                 local_2d(nxl:nxr,nys:nyn+1),  &
     684                                                 start = (/ nxl+1, nys+1, iis, &
     685                                                    do2d_xy_time_count(av) /), &
     686                                                 count = (/ nxr-nxl+1,         &
     687                                                            nyn-nys+2, 1, 1 /) )
     688                      ELSEIF ( nxr == nx  .AND.  nyn == ny )  THEN
     689                         nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
     690                                                 id_var_do2d(av,if),           &
     691                                                 local_2d(nxl:nxr+1,nys:nyn+1),&
     692                                                 start = (/ nxl+1, nys+1, iis, &
     693                                                    do2d_xy_time_count(av) /), &
     694                                                 count = (/ nxr-nxl+2,          &
     695                                                            nyn-nys+2, 1, 1 /) )
     696                      ELSE
     697                         nc_stat = NF90_PUT_VAR( id_set_xy(av),                &
     698                                                 id_var_do2d(av,if),           &
     699                                                 local_2d(nxl:nxr,nys:nyn),    &
     700                                                 start = (/ nxl+1, nys+1, iis, &
     701                                                    do2d_xy_time_count(av) /), &
     702                                                 count = (/ nxr-nxl+1,         &
     703                                                            nyn-nys+1, 1, 1 /) )
     704                      ENDIF
     705
     706                      CALL handle_netcdf_error( 'data_output_2d', 55 )
     707#endif
    659708                   ELSE
    660 !
    661 !--                   PE0 receives partial arrays from all processors and then
    662 !--                   outputs them. Here a barrier has to be set, because
    663 !--                   otherwise "-MPI- FATAL: Remote protocol queue full" may
    664 !--                   occur.
    665                       CALL MPI_BARRIER( comm2d, ierr )
    666 
    667                       ngp = ( nxr-nxl+3 ) * ( nyn-nys+3 )
    668                       IF ( myid == 0 )  THEN
    669 !
    670 !--                      Local array can be relocated directly.
    671                          total_2d(nxl-1:nxr+1,nys-1:nyn+1) = local_2d
    672 !
    673 !--                      Receive data from all other PEs.
    674                          DO  n = 1, numprocs-1
    675 !
    676 !--                         Receive index limits first, then array.
    677 !--                         Index limits are received in arbitrary order from
    678 !--                         the PEs.
    679                             CALL MPI_RECV( ind(1), 4, MPI_INTEGER,            &
    680                                            MPI_ANY_SOURCE, 0, comm2d, status, &
    681                                            ierr )
    682                             sender = status(MPI_SOURCE)
     709
     710                      IF ( data_output_2d_on_each_pe )  THEN
     711!
     712!--                      Output of partial arrays on each PE
     713#if defined( __netcdf )
     714                         IF ( netcdf_output  .AND.  myid == 0 )  THEN
     715                            WRITE ( 21 )  simulated_time, &
     716                                          do2d_xy_time_count(av), av
     717                         ENDIF
     718#endif
     719                         WRITE ( 21 )  nxl-1, nxr+1, nys-1, nyn+1
     720                         WRITE ( 21 )  local_2d
     721
     722                      ELSE
     723!
     724!--                      PE0 receives partial arrays from all processors and
     725!--                      then outputs them. Here a barrier has to be set,
     726!--                      because otherwise "-MPI- FATAL: Remote protocol queue
     727!--                      full" may occur.
     728                         CALL MPI_BARRIER( comm2d, ierr )
     729
     730                         ngp = ( nxr-nxl+3 ) * ( nyn-nys+3 )
     731                         IF ( myid == 0 )  THEN
     732!
     733!--                         Local array can be relocated directly.
     734                            total_2d(nxl-1:nxr+1,nys-1:nyn+1) = local_2d
     735!
     736!--                         Receive data from all other PEs.
     737                            DO  n = 1, numprocs-1
     738!
     739!--                            Receive index limits first, then array.
     740!--                            Index limits are received in arbitrary order from
     741!--                            the PEs.
     742                               CALL MPI_RECV( ind(1), 4, MPI_INTEGER,    &
     743                                              MPI_ANY_SOURCE, 0, comm2d, &
     744                                              status, ierr )
     745                               sender = status(MPI_SOURCE)
     746                               DEALLOCATE( local_2d )
     747                               ALLOCATE( local_2d(ind(1):ind(2),ind(3):ind(4)) )
     748                               CALL MPI_RECV( local_2d(ind(1),ind(3)), ngp,  &
     749                                              MPI_REAL, sender, 1, comm2d,   &
     750                                              status, ierr )
     751                               total_2d(ind(1):ind(2),ind(3):ind(4)) = local_2d
     752                            ENDDO
     753!
     754!--                         Output of the total cross-section.
     755                            IF ( iso2d_output )  THEN
     756                               WRITE (21)  total_2d(0:nx+1,0:ny+1)
     757                            ENDIF
     758!
     759!--                         Relocate the local array for the next loop increment
    683760                            DEALLOCATE( local_2d )
    684                             ALLOCATE( local_2d(ind(1):ind(2),ind(3):ind(4)) )
    685                             CALL MPI_RECV( local_2d(ind(1),ind(3)), ngp,      &
    686                                            MPI_REAL, sender, 1, comm2d,       &
    687                                            status, ierr )
    688                             total_2d(ind(1):ind(2),ind(3):ind(4)) = local_2d
    689                          ENDDO
    690 !
    691 !--                      Output of the total cross-section.
    692                          IF ( iso2d_output ) WRITE (21)  total_2d(0:nx+1,0:ny+1)
    693 !
    694 !--                      Relocate the local array for the next loop increment
    695                          DEALLOCATE( local_2d )
    696                          ALLOCATE( local_2d(nxl-1:nxr+1,nys-1:nyn+1) )
     761                            ALLOCATE( local_2d(nxl-1:nxr+1,nys-1:nyn+1) )
    697762
    698763#if defined( __netcdf )
    699                          IF ( netcdf_output )  THEN
    700                             IF ( two_d ) THEN
    701                                nc_stat = NF90_PUT_VAR( id_set_xy(av),          &
    702                                                        id_var_do2d(av,if),     &
     764                            IF ( netcdf_output )  THEN
     765                               IF ( two_d ) THEN
     766                                  nc_stat = NF90_PUT_VAR( id_set_xy(av),       &
     767                                                          id_var_do2d(av,if),  &
    703768                                                      total_2d(0:nx+1,0:ny+1), &
    704769                                start = (/ 1, 1, 1, do2d_xy_time_count(av) /), &
    705770                                                count = (/ nx+2, ny+2, 1, 1 /) )
    706                             ELSE
    707                                nc_stat = NF90_PUT_VAR( id_set_xy(av),          &
    708                                                        id_var_do2d(av,if),     &
     771                               ELSE
     772                                  nc_stat = NF90_PUT_VAR( id_set_xy(av),       &
     773                                                          id_var_do2d(av,if),  &
    709774                                                      total_2d(0:nx+1,0:ny+1), &
    710775                               start = (/ 1, 1, is, do2d_xy_time_count(av) /), &
    711776                                                count = (/ nx+2, ny+2, 1, 1 /) )
     777                               ENDIF
     778                               CALL handle_netcdf_error( 'data_output_2d', 54 )
    712779                            ENDIF
    713                             CALL handle_netcdf_error( 'data_output_2d', 54 )
    714                          ENDIF
    715 #endif
    716 
    717                       ELSE
    718 !
    719 !--                      First send the local index limits to PE0
    720                          ind(1) = nxl-1; ind(2) = nxr+1
    721                          ind(3) = nys-1; ind(4) = nyn+1
    722                          CALL MPI_SEND( ind(1), 4, MPI_INTEGER, 0, 0, comm2d, &
    723                                         ierr )
    724 !
    725 !--                      Send data to PE0
    726                          CALL MPI_SEND( local_2d(nxl-1,nys-1), ngp, MPI_REAL, &
    727                                         0, 1, comm2d, ierr )
    728                       ENDIF
    729 !
    730 !--                   A barrier has to be set, because otherwise some PEs may
    731 !--                   proceed too fast so that PE0 may receive wrong data on
    732 !--                   tag 0
    733                       CALL MPI_BARRIER( comm2d, ierr )
     780#endif
     781
     782                         ELSE
     783!
     784!--                         First send the local index limits to PE0
     785                            ind(1) = nxl-1; ind(2) = nxr+1
     786                            ind(3) = nys-1; ind(4) = nyn+1
     787                            CALL MPI_SEND( ind(1), 4, MPI_INTEGER, 0, 0, &
     788                                           comm2d, ierr )
     789!
     790!--                         Send data to PE0
     791                            CALL MPI_SEND( local_2d(nxl-1,nys-1), ngp, &
     792                                           MPI_REAL, 0, 1, comm2d, ierr )
     793                         ENDIF
     794!
     795!--                      A barrier has to be set, because otherwise some PEs may
     796!--                      proceed too fast so that PE0 may receive wrong data on
     797!--                      tag 0
     798                         CALL MPI_BARRIER( comm2d, ierr )
     799                      ENDIF
     800
    734801                   ENDIF
    735802#else
     
    752819                                              count = (/ nx+2, ny+2, 1, 1 /) )
    753820                      ENDIF
    754                       CALL handle_netcdf_error( 'data_output_2d', 55 )
     821                      CALL handle_netcdf_error( 'data_output_2d', 447 )
    755822                   ENDIF
    756823#endif
     
    789856!
    790857!--                Update the NetCDF xz cross section time axis
    791                    IF ( myid == 0 )  THEN
     858                   IF ( myid == 0  .OR.  netcdf_data_format > 2 )  THEN
     859
    792860                      IF ( simulated_time /= do2d_xz_last_time(av) )  THEN
    793861                         do2d_xz_time_count(av) = do2d_xz_time_count(av) + 1
    794862                         do2d_xz_last_time(av)  = simulated_time
    795                          IF ( .NOT. data_output_2d_on_each_pe  .AND. &
    796                               netcdf_output )  THEN
     863                         IF ( ( .NOT. data_output_2d_on_each_pe  .AND.        &
     864                              netcdf_output )  .OR.  netcdf_data_format > 2 ) &
     865                         THEN
    797866#if defined( __netcdf )
    798867                            nc_stat = NF90_PUT_VAR( id_set_xz(av),             &
     
    801870                                         start = (/ do2d_xz_time_count(av) /), &
    802871                                                    count = (/ 1 /) )
    803                              CALL handle_netcdf_error( 'data_output_2d', 56 )
    804 #endif
    805                          ENDIF
    806                       ENDIF
     872                            CALL handle_netcdf_error( 'data_output_2d', 56 )
     873#endif
     874                         ENDIF
     875                      ENDIF
     876
    807877                   ENDIF
    808878!
     
    848918
    849919#if defined( __parallel )
    850                    IF ( data_output_2d_on_each_pe )  THEN
    851 !
    852 !--                   Output of partial arrays on each PE. If the cross section
    853 !--                   does not reside on the PE, output special index values.
     920                   IF ( netcdf_output  .AND.  netcdf_data_format > 2 )  THEN
     921!
     922!--                   ATTENTION: The following lines are a workaround, because
     923!--                              independet output does not work with the
     924!--                              current NetCDF4 installation. Therefore, data
     925!--                              are transferred from PEs having the cross
     926!--                              sections to other PEs along y having no cross
     927!--                              section data. Some of these data are the
     928!--                              output.
     929!--                   BEGIN WORKAROUND---------------------------------------
     930                      IF ( npey /= 1  .AND.  section(is,s) /= -1)  THEN
     931                         ALLOCATE( local_2d_l(nxl-1:nxr+1,nzb:nzt+1) )
     932                         local_2d_l = 0.0
     933                         IF ( section(is,s) >= nys .AND. section(is,s) <= nyn )&
     934                         THEN
     935                            local_2d_l = local_2d
     936                         ENDIF
     937#if defined( __parallel )
     938!
     939!--                      Distribute data over all PEs along y
     940                         ngp = ( nxr-nxl+3 ) * ( nzt-nzb+2 )
     941                         CALL MPI_ALLREDUCE( local_2d_l(nxl-1,nzb),            &
     942                                             local_2d(nxl-1,nzb), ngp,         &
     943                                             MPI_REAL, MPI_SUM, comm1dy, ierr )
     944#else
     945                         local_2d = local_2d_l
     946#endif
     947                         DEALLOCATE( local_2d_l )
     948                      ENDIF
     949!--                   END WORKAROUND-----------------------------------------
     950
     951!
     952!--                   Output in NetCDF4/HDF5 format.
     953!--                   Output only on those PEs where the respective cross
     954!--                   sections reside. Cross sections averaged along y are
     955!--                   output on the respective first PE along y (myidy=0).
     956                      IF ( ( section(is,s) >= nys  .AND.  &
     957                             section(is,s) <= nyn )  .OR.  &
     958                           ( section(is,s) == -1  .AND.  myidy == 0 ) )  THEN
     959!
     960!--                      Do not output redundant ghost point data except for the
     961!--                      boundaries of the total domain.
    854962#if defined( __netcdf )
    855                       IF ( netcdf_output  .AND.  myid == 0 )  THEN
    856                          WRITE ( 22 )  simulated_time, do2d_xz_time_count(av), &
    857                                        av
    858                       ENDIF
    859 #endif
    860                       IF ( ( section(is,s)>=nys .AND. section(is,s)<=nyn ) .OR.&
    861                            ( section(is,s) == -1  .AND.  nys-1 == -1 ) )       &
    862                       THEN
    863                          WRITE (22)  nxl-1, nxr+1, nzb, nzt+1
    864                          WRITE (22)  local_2d
     963                         IF ( nxr == nx )  THEN
     964                            nc_stat = NF90_PUT_VAR( id_set_xz(av),             &
     965                                                id_var_do2d(av,if),            &
     966                                                local_2d(nxl:nxr+1,nzb:nzt+1), &
     967                                                start = (/ nxl+1, is, 1,       &
     968                                                    do2d_xz_time_count(av) /), &
     969                                                count = (/ nxr-nxl+2, 1,       &
     970                                                           nzt+2, 1 /) )
     971                         ELSE
     972                            nc_stat = NF90_PUT_VAR( id_set_xz(av),             &
     973                                                id_var_do2d(av,if),            &
     974                                                local_2d(nxl:nxr,nzb:nzt+1),   &
     975                                                start = (/ nxl+1, is, 1,       &
     976                                                    do2d_xz_time_count(av) /), &
     977                                                count = (/ nxr-nxl+1, 1,       &
     978                                                           nzt+2, 1 /) )
     979                         ENDIF
     980
     981                         CALL handle_netcdf_error( 'data_output_2d', 57 )
     982
    865983                      ELSE
    866                          WRITE (22)  -1, -1, -1, -1
     984!
     985!--                      Output on other PEs. Only one point is output!!
     986!--                      ATTENTION: This is a workaround (see above)!!
     987                         IF ( npey /= 1 )  THEN
     988                            nc_stat = NF90_PUT_VAR( id_set_xz(av),             &
     989                                                    id_var_do2d(av,if),        &
     990                                                    local_2d(nxl:nxl,nzb:nzb), &
     991                                                    start = (/ nxl+1, is, 1,   &
     992                                                    do2d_xz_time_count(av) /), &
     993                                                    count = (/ 1, 1, 1, 1 /) )
     994                            CALL handle_netcdf_error( 'data_output_2d', 451 )
     995                         ENDIF
     996#endif
    867997                      ENDIF
    868998
    869999                   ELSE
    870 !
    871 !--                   PE0 receives partial arrays from all processors of the
    872 !--                   respective cross section and outputs them. Here a
    873 !--                   barrier has to be set, because otherwise
    874 !--                   "-MPI- FATAL: Remote protocol queue full" may occur.
    875                       CALL MPI_BARRIER( comm2d, ierr )
    876 
    877                       ngp = ( nxr-nxl+3 ) * ( nzt-nzb+2 )
    878                       IF ( myid == 0 )  THEN
    879 !
    880 !--                      Local array can be relocated directly.
    881                          IF ( ( section(is,s)>=nys .AND. section(is,s)<=nyn )  &
    882                             .OR. ( section(is,s) == -1  .AND.  nys-1 == -1 ) ) &
     1000
     1001                      IF ( data_output_2d_on_each_pe )  THEN
     1002!
     1003!--                      Output of partial arrays on each PE. If the cross
     1004!--                      section does not reside on the PE, output special
     1005!--                      index values.
     1006#if defined( __netcdf )
     1007                         IF ( netcdf_output  .AND.  myid == 0 )  THEN
     1008                            WRITE ( 22 )  simulated_time, &
     1009                                          do2d_xz_time_count(av), av
     1010                         ENDIF
     1011#endif
     1012                         IF ( ( section(is,s) >= nys  .AND.                  &
     1013                                section(is,s) <= nyn )  .OR.                 &
     1014                              ( section(is,s) == -1  .AND.  nys-1 == -1 ) )  &
    8831015                         THEN
    884                             total_2d(nxl-1:nxr+1,nzb:nzt+1) = local_2d
    885                          ENDIF
    886 !
    887 !--                      Receive data from all other PEs.
    888                          DO  n = 1, numprocs-1
    889 !
    890 !--                         Receive index limits first, then array.
    891 !--                         Index limits are received in arbitrary order from
    892 !--                         the PEs.
    893                             CALL MPI_RECV( ind(1), 4, MPI_INTEGER,            &
    894                                            MPI_ANY_SOURCE, 0, comm2d, status, &
    895                                            ierr )
    896 !
    897 !--                         Not all PEs have data for XZ-cross-section.
    898                             IF ( ind(1) /= -9999 )  THEN
    899                                sender = status(MPI_SOURCE)
    900                                DEALLOCATE( local_2d )
    901                                ALLOCATE( local_2d(ind(1):ind(2),ind(3):ind(4)) )
    902                                CALL MPI_RECV( local_2d(ind(1),ind(3)), ngp, &
    903                                               MPI_REAL, sender, 1, comm2d,  &
     1016                            WRITE (22)  nxl-1, nxr+1, nzb, nzt+1
     1017                            WRITE (22)  local_2d
     1018                         ELSE
     1019                            WRITE (22)  -1, -1, -1, -1
     1020                         ENDIF
     1021
     1022                      ELSE
     1023!
     1024!--                      PE0 receives partial arrays from all processors of the
     1025!--                      respective cross section and outputs them. Here a
     1026!--                      barrier has to be set, because otherwise
     1027!--                      "-MPI- FATAL: Remote protocol queue full" may occur.
     1028                         CALL MPI_BARRIER( comm2d, ierr )
     1029
     1030                         ngp = ( nxr-nxl+3 ) * ( nzt-nzb+2 )
     1031                         IF ( myid == 0 )  THEN
     1032!
     1033!--                         Local array can be relocated directly.
     1034                            IF ( ( section(is,s) >= nys  .AND.                 &
     1035                                   section(is,s) <= nyn )  .OR.                &
     1036                                 ( section(is,s) == -1  .AND.  nys-1 == -1 ) ) &
     1037                            THEN
     1038                               total_2d(nxl-1:nxr+1,nzb:nzt+1) = local_2d
     1039                            ENDIF
     1040!
     1041!--                         Receive data from all other PEs.
     1042                            DO  n = 1, numprocs-1
     1043!
     1044!--                            Receive index limits first, then array.
     1045!--                            Index limits are received in arbitrary order from
     1046!--                            the PEs.
     1047                               CALL MPI_RECV( ind(1), 4, MPI_INTEGER,     &
     1048                                              MPI_ANY_SOURCE, 0, comm2d,  &
    9041049                                              status, ierr )
    905                                total_2d(ind(1):ind(2),ind(3):ind(4)) = local_2d
     1050!
     1051!--                            Not all PEs have data for XZ-cross-section.
     1052                               IF ( ind(1) /= -9999 )  THEN
     1053                                  sender = status(MPI_SOURCE)
     1054                                  DEALLOCATE( local_2d )
     1055                                  ALLOCATE( local_2d(ind(1):ind(2), &
     1056                                                     ind(3):ind(4)) )
     1057                                  CALL MPI_RECV( local_2d(ind(1),ind(3)), ngp, &
     1058                                                 MPI_REAL, sender, 1, comm2d,  &
     1059                                                 status, ierr )
     1060                                  total_2d(ind(1):ind(2),ind(3):ind(4)) = &
     1061                                                                        local_2d
     1062                               ENDIF
     1063                            ENDDO
     1064!
     1065!--                         Output of the total cross-section.
     1066                            IF ( iso2d_output )  THEN
     1067                               WRITE (22)  total_2d(0:nx+1,nzb:nzt+1)
    9061068                            ENDIF
    907                          ENDDO
    908 !
    909 !--                      Output of the total cross-section.
    910                          IF ( iso2d_output )  THEN
    911                             WRITE (22)  total_2d(0:nx+1,nzb:nzt+1)
    912                          ENDIF
    913 !
    914 !--                      Relocate the local array for the next loop increment
    915                          DEALLOCATE( local_2d )
    916                          ALLOCATE( local_2d(nxl-1:nxr+1,nzb:nzt+1) )
     1069!
     1070!--                         Relocate the local array for the next loop increment
     1071                            DEALLOCATE( local_2d )
     1072                            ALLOCATE( local_2d(nxl-1:nxr+1,nzb:nzt+1) )
    9171073
    9181074#if defined( __netcdf )
    919                          IF ( netcdf_output )  THEN
    920                             nc_stat = NF90_PUT_VAR( id_set_xz(av),             &
     1075                            IF ( netcdf_output )  THEN
     1076                               nc_stat = NF90_PUT_VAR( id_set_xz(av),          &
    9211077                                                    id_var_do2d(av,if),        &
    9221078                                                    total_2d(0:nx+1,nzb:nzt+1),&
    9231079                               start = (/ 1, is, 1, do2d_xz_time_count(av) /), &
    9241080                                                count = (/ nx+2, 1, nz+2, 1 /) )
    925                             CALL handle_netcdf_error( 'data_output_2d', 57 )
    926                          ENDIF
    927 #endif
    928 
    929                       ELSE
    930 !
    931 !--                      If the cross section resides on the PE, send the
    932 !--                      local index limits, otherwise send -9999 to PE0.
    933                          IF ( ( section(is,s)>=nys .AND. section(is,s)<=nyn )  &
    934                             .OR. ( section(is,s) == -1  .AND.  nys-1 == -1 ) ) &
    935                          THEN
    936                             ind(1) = nxl-1; ind(2) = nxr+1
    937                             ind(3) = nzb;   ind(4) = nzt+1
     1081                               CALL handle_netcdf_error( 'data_output_2d', 58 )
     1082                            ENDIF
     1083#endif
     1084
    9381085                         ELSE
    939                             ind(1) = -9999; ind(2) = -9999
    940                             ind(3) = -9999; ind(4) = -9999
    941                          ENDIF
    942                          CALL MPI_SEND( ind(1), 4, MPI_INTEGER, 0, 0, comm2d, &
    943                                         ierr )
    944 !
    945 !--                      If applicable, send data to PE0.
    946                          IF ( ind(1) /= -9999 )  THEN
    947                             CALL MPI_SEND( local_2d(nxl-1,nzb), ngp, MPI_REAL, &
    948                                            0, 1, comm2d, ierr )
    949                          ENDIF
    950                       ENDIF
    951 !
    952 !--                   A barrier has to be set, because otherwise some PEs may
    953 !--                   proceed too fast so that PE0 may receive wrong data on
    954 !--                   tag 0
    955                       CALL MPI_BARRIER( comm2d, ierr )
     1086!
     1087!--                         If the cross section resides on the PE, send the
     1088!--                         local index limits, otherwise send -9999 to PE0.
     1089                            IF ( ( section(is,s) >= nys  .AND.                 &
     1090                                   section(is,s) <= nyn )  .OR.                &
     1091                                 ( section(is,s) == -1  .AND.  nys-1 == -1 ) ) &
     1092                            THEN
     1093                               ind(1) = nxl-1; ind(2) = nxr+1
     1094                               ind(3) = nzb;   ind(4) = nzt+1
     1095                            ELSE
     1096                               ind(1) = -9999; ind(2) = -9999
     1097                               ind(3) = -9999; ind(4) = -9999
     1098                            ENDIF
     1099                            CALL MPI_SEND( ind(1), 4, MPI_INTEGER, 0, 0, &
     1100                                           comm2d, ierr )
     1101!
     1102!--                         If applicable, send data to PE0.
     1103                            IF ( ind(1) /= -9999 )  THEN
     1104                               CALL MPI_SEND( local_2d(nxl-1,nzb), ngp, &
     1105                                              MPI_REAL, 0, 1, comm2d, ierr )
     1106                            ENDIF
     1107                         ENDIF
     1108!
     1109!--                      A barrier has to be set, because otherwise some PEs may
     1110!--                      proceed too fast so that PE0 may receive wrong data on
     1111!--                      tag 0
     1112                         CALL MPI_BARRIER( comm2d, ierr )
     1113                      ENDIF
     1114
    9561115                   ENDIF
    9571116#else
     
    9661125                               start = (/ 1, is, 1, do2d_xz_time_count(av) /), &
    9671126                                              count = (/ nx+2, 1, nz+2, 1 /) )
    968                       CALL handle_netcdf_error( 'data_output_2d', 58 )
     1127                      CALL handle_netcdf_error( 'data_output_2d', 451 )
    9691128                   ENDIF
    9701129#endif
     
    9951154                CASE ( 'yz' )
    9961155!
    997 !--                Update the NetCDF xy cross section time axis
    998                    IF ( myid == 0 )  THEN
     1156!--                Update the NetCDF yz cross section time axis
     1157                   IF ( myid == 0  .OR.  netcdf_data_format > 2 )  THEN
     1158
    9991159                      IF ( simulated_time /= do2d_yz_last_time(av) )  THEN
    10001160                         do2d_yz_time_count(av) = do2d_yz_time_count(av) + 1
    10011161                         do2d_yz_last_time(av)  = simulated_time
    1002                          IF ( .NOT. data_output_2d_on_each_pe  .AND. &
    1003                               netcdf_output )  THEN
     1162                         IF ( ( .NOT. data_output_2d_on_each_pe  .AND.        &
     1163                              netcdf_output )  .OR.  netcdf_data_format > 2 ) &
     1164                         THEN
    10041165#if defined( __netcdf )
    10051166                            nc_stat = NF90_PUT_VAR( id_set_yz(av),             &
     
    10121173                         ENDIF
    10131174                      ENDIF
     1175
    10141176                   ENDIF
    10151177!
     
    10551217
    10561218#if defined( __parallel )
    1057                    IF ( data_output_2d_on_each_pe )  THEN
    1058 !
    1059 !--                   Output of partial arrays on each PE. If the cross section
    1060 !--                   does not reside on the PE, output special index values.
     1219                   IF ( netcdf_output  .AND.  netcdf_data_format > 2 )  THEN
     1220!
     1221!--                   ATTENTION: The following lines are a workaround, because
     1222!--                              independet output does not work with the
     1223!--                              current NetCDF4 installation. Therefore, data
     1224!--                              are transferred from PEs having the cross
     1225!--                              sections to other PEs along y having no cross
     1226!--                              section data. Some of these data are the
     1227!--                              output.
     1228!--                   BEGIN WORKAROUND---------------------------------------
     1229                      IF ( npex /= 1  .AND.  section(is,s) /= -1)  THEN
     1230                         ALLOCATE( local_2d_l(nys-1:nyn+1,nzb:nzt+1) )
     1231                         local_2d_l = 0.0
     1232                         IF ( section(is,s) >= nxl .AND. section(is,s) <= nxr )&
     1233                         THEN
     1234                            local_2d_l = local_2d
     1235                         ENDIF
     1236#if defined( __parallel )
     1237!
     1238!--                      Distribute data over all PEs along x
     1239                         ngp = ( nyn-nys+3 ) * ( nzt-nzb+2 )
     1240                         CALL MPI_ALLREDUCE( local_2d_l(nys-1,nzb),            &
     1241                                             local_2d(nys-1,nzb), ngp,         &
     1242                                             MPI_REAL, MPI_SUM, comm1dx, ierr )
     1243#else
     1244                         local_2d = local_2d_l
     1245#endif
     1246                         DEALLOCATE( local_2d_l )
     1247                      ENDIF
     1248!--                   END WORKAROUND-----------------------------------------
     1249
     1250!
     1251!--                   Output in NetCDF4/HDF5 format.
     1252!--                   Output only on those PEs where the respective cross
     1253!--                   sections reside. Cross sections averaged along x are
     1254!--                   output on the respective first PE along x (myidx=0).
     1255                      IF ( ( section(is,s) >= nxl  .AND.  &
     1256                             section(is,s) <= nxr )  .OR.  &
     1257                           ( section(is,s) == -1  .AND.  myidx == 0 ) )  THEN
     1258!
     1259!--                      Do not output redundant ghost point data except for the
     1260!--                      boundaries of the total domain.
    10611261#if defined( __netcdf )
    1062                       IF ( netcdf_output  .AND.  myid == 0 )  THEN
    1063                          WRITE ( 23 )  simulated_time, do2d_yz_time_count(av), &
    1064                                        av
    1065                       ENDIF
    1066 #endif
    1067                       IF ( ( section(is,s)>=nxl .AND. section(is,s)<=nxr ) .OR.&
    1068                            ( section(is,s) ==  -1  .AND.  nxl-1 == -1 ) )      &
    1069                       THEN
    1070                          WRITE (23)  nys-1, nyn+1, nzb, nzt+1
    1071                          WRITE (23)  local_2d
     1262                         IF ( nyn == ny )  THEN
     1263                            nc_stat = NF90_PUT_VAR( id_set_yz(av),             &
     1264                                                id_var_do2d(av,if),            &
     1265                                                local_2d(nys:nyn+1,nzb:nzt+1), &
     1266                                                start = (/ is, nys+1, 1,       &
     1267                                                    do2d_yz_time_count(av) /), &
     1268                                                count = (/ 1, nyn-nys+2,       &
     1269                                                           nzt+2, 1 /) )
     1270                         ELSE
     1271                            nc_stat = NF90_PUT_VAR( id_set_yz(av),             &
     1272                                                id_var_do2d(av,if),            &
     1273                                                local_2d(nys:nyn,nzb:nzt+1),   &
     1274                                                start = (/ is, nys+1, 1,       &
     1275                                                    do2d_yz_time_count(av) /), &
     1276                                                count = (/ 1, nyn-nys+1,       &
     1277                                                           nzt+2, 1 /) )
     1278                         ENDIF
     1279
     1280                         CALL handle_netcdf_error( 'data_output_2d', 60 )
     1281
    10721282                      ELSE
    1073                          WRITE (23)  -1, -1, -1, -1
     1283!
     1284!--                      Output on other PEs. Only one point is output!!
     1285!--                      ATTENTION: This is a workaround (see above)!!
     1286                         IF ( npex /= 1 )  THEN
     1287                            nc_stat = NF90_PUT_VAR( id_set_yz(av),             &
     1288                                                    id_var_do2d(av,if),        &
     1289                                                    local_2d(nys:nys,nzb:nzb), &
     1290                                                    start = (/ is, nys+1, 1,   &
     1291                                                    do2d_yz_time_count(av) /), &
     1292                                                    count = (/ 1, 1, 1, 1 /) )
     1293                            CALL handle_netcdf_error( 'data_output_2d', 452 )
     1294                         ENDIF
     1295#endif
    10741296                      ENDIF
    10751297
    10761298                   ELSE
    1077 !
    1078 !--                   PE0 receives partial arrays from all processors of the
    1079 !--                   respective cross section and outputs them. Here a
    1080 !--                   barrier has to be set, because otherwise
    1081 !--                   "-MPI- FATAL: Remote protocol queue full" may occur.
    1082                       CALL MPI_BARRIER( comm2d, ierr )
    1083 
    1084                       ngp = ( nyn-nys+3 ) * ( nzt-nzb+2 )
    1085                       IF ( myid == 0 )  THEN
    1086 !
    1087 !--                      Local array can be relocated directly.
    1088                          IF ( ( section(is,s)>=nxl .AND. section(is,s)<=nxr )  &
    1089                            .OR. ( section(is,s) ==  -1  .AND.  nxl-1 == -1 ) ) &
     1299
     1300                      IF ( data_output_2d_on_each_pe )  THEN
     1301!
     1302!--                      Output of partial arrays on each PE. If the cross
     1303!--                      section does not reside on the PE, output special
     1304!--                      index values.
     1305#if defined( __netcdf )
     1306                         IF ( netcdf_output  .AND.  myid == 0 )  THEN
     1307                            WRITE ( 23 )  simulated_time, &
     1308                                          do2d_yz_time_count(av), av
     1309                         ENDIF
     1310#endif
     1311                         IF ( ( section(is,s) >= nxl  .AND.                  &
     1312                                section(is,s) <= nxr )  .OR.                 &
     1313                              ( section(is,s) == -1  .AND.  nxl-1 == -1 ) )  &
    10901314                         THEN
    1091                             total_2d(nys-1:nyn+1,nzb:nzt+1) = local_2d
    1092                          ENDIF
    1093 !
    1094 !--                      Receive data from all other PEs.
    1095                          DO  n = 1, numprocs-1
    1096 !
    1097 !--                         Receive index limits first, then array.
    1098 !--                         Index limits are received in arbitrary order from
    1099 !--                         the PEs.
    1100                             CALL MPI_RECV( ind(1), 4, MPI_INTEGER,            &
    1101                                            MPI_ANY_SOURCE, 0, comm2d, status, &
    1102                                            ierr )
    1103 !
    1104 !--                         Not all PEs have data for YZ-cross-section.
    1105                             IF ( ind(1) /= -9999 )  THEN
    1106                                sender = status(MPI_SOURCE)
    1107                                DEALLOCATE( local_2d )
    1108                                ALLOCATE( local_2d(ind(1):ind(2),ind(3):ind(4)) )
    1109                                CALL MPI_RECV( local_2d(ind(1),ind(3)), ngp, &
    1110                                               MPI_REAL, sender, 1, comm2d,  &
     1315                            WRITE (23)  nys-1, nyn+1, nzb, nzt+1
     1316                            WRITE (23)  local_2d
     1317                         ELSE
     1318                            WRITE (23)  -1, -1, -1, -1
     1319                         ENDIF
     1320
     1321                      ELSE
     1322!
     1323!--                      PE0 receives partial arrays from all processors of the
     1324!--                      respective cross section and outputs them. Here a
     1325!--                      barrier has to be set, because otherwise
     1326!--                      "-MPI- FATAL: Remote protocol queue full" may occur.
     1327                         CALL MPI_BARRIER( comm2d, ierr )
     1328
     1329                         ngp = ( nyn-nys+3 ) * ( nzt-nzb+2 )
     1330                         IF ( myid == 0 )  THEN
     1331!
     1332!--                         Local array can be relocated directly.
     1333                            IF ( ( section(is,s) >= nxl  .AND.                 &
     1334                                   section(is,s) <= nxr )   .OR.               &
     1335                                 ( section(is,s) == -1  .AND.  nxl-1 == -1 ) ) &
     1336                            THEN
     1337                               total_2d(nys-1:nyn+1,nzb:nzt+1) = local_2d
     1338                            ENDIF
     1339!
     1340!--                         Receive data from all other PEs.
     1341                            DO  n = 1, numprocs-1
     1342!
     1343!--                            Receive index limits first, then array.
     1344!--                            Index limits are received in arbitrary order from
     1345!--                            the PEs.
     1346                               CALL MPI_RECV( ind(1), 4, MPI_INTEGER,     &
     1347                                              MPI_ANY_SOURCE, 0, comm2d,  &
    11111348                                              status, ierr )
    1112                                total_2d(ind(1):ind(2),ind(3):ind(4)) = local_2d
     1349!
     1350!--                            Not all PEs have data for YZ-cross-section.
     1351                               IF ( ind(1) /= -9999 )  THEN
     1352                                  sender = status(MPI_SOURCE)
     1353                                  DEALLOCATE( local_2d )
     1354                                  ALLOCATE( local_2d(ind(1):ind(2), &
     1355                                                     ind(3):ind(4)) )
     1356                                  CALL MPI_RECV( local_2d(ind(1),ind(3)), ngp, &
     1357                                                 MPI_REAL, sender, 1, comm2d,  &
     1358                                                 status, ierr )
     1359                                  total_2d(ind(1):ind(2),ind(3):ind(4)) = &
     1360                                                                        local_2d
     1361                               ENDIF
     1362                            ENDDO
     1363!
     1364!--                         Output of the total cross-section.
     1365                            IF ( iso2d_output )  THEN
     1366                               WRITE (23)  total_2d(0:ny+1,nzb:nzt+1)
    11131367                            ENDIF
    1114                          ENDDO
    1115 !
    1116 !--                      Output of the total cross-section.
    1117                          IF ( iso2d_output )  THEN
    1118                             WRITE (23)  total_2d(0:ny+1,nzb:nzt+1)
    1119                          ENDIF
    1120 !
    1121 !--                      Relocate the local array for the next loop increment
    1122                          DEALLOCATE( local_2d )
    1123                          ALLOCATE( local_2d(nys-1:nyn+1,nzb:nzt+1) )
     1368!
     1369!--                         Relocate the local array for the next loop increment
     1370                            DEALLOCATE( local_2d )
     1371                            ALLOCATE( local_2d(nys-1:nyn+1,nzb:nzt+1) )
    11241372
    11251373#if defined( __netcdf )
    1126                          IF ( netcdf_output )  THEN
    1127                             nc_stat = NF90_PUT_VAR( id_set_yz(av),             &
     1374                            IF ( netcdf_output )  THEN
     1375                               nc_stat = NF90_PUT_VAR( id_set_yz(av),          &
    11281376                                                    id_var_do2d(av,if),        &
    11291377                                                    total_2d(0:ny+1,nzb:nzt+1),&
    11301378                               start = (/ is, 1, 1, do2d_yz_time_count(av) /), &
    11311379                                                count = (/ 1, ny+2, nz+2, 1 /) )
    1132                             CALL handle_netcdf_error( 'data_output_2d', 60 )
    1133                          ENDIF
    1134 #endif
    1135 
    1136                       ELSE
    1137 !
    1138 !--                      If the cross section resides on the PE, send the
    1139 !--                      local index limits, otherwise send -9999 to PE0.
    1140                          IF ( ( section(is,s)>=nxl .AND. section(is,s)<=nxr )  &
    1141                            .OR. ( section(is,s) ==  -1  .AND.  nxl-1 == -1 ) ) &
    1142                          THEN
    1143                             ind(1) = nys-1; ind(2) = nyn+1
    1144                             ind(3) = nzb;   ind(4) = nzt+1
     1380                               CALL handle_netcdf_error( 'data_output_2d', 61 )
     1381                            ENDIF
     1382#endif
     1383
    11451384                         ELSE
    1146                             ind(1) = -9999; ind(2) = -9999
    1147                             ind(3) = -9999; ind(4) = -9999
    1148                          ENDIF
    1149                          CALL MPI_SEND( ind(1), 4, MPI_INTEGER, 0, 0, comm2d, &
    1150                                         ierr )
    1151 !
    1152 !--                      If applicable, send data to PE0.
    1153                          IF ( ind(1) /= -9999 )  THEN
    1154                             CALL MPI_SEND( local_2d(nys-1,nzb), ngp, MPI_REAL, &
    1155                                            0, 1, comm2d, ierr )
    1156                          ENDIF
    1157                       ENDIF
    1158 !
    1159 !--                   A barrier has to be set, because otherwise some PEs may
    1160 !--                   proceed too fast so that PE0 may receive wrong data on
    1161 !--                   tag 0
    1162                       CALL MPI_BARRIER( comm2d, ierr )
     1385!
     1386!--                         If the cross section resides on the PE, send the
     1387!--                         local index limits, otherwise send -9999 to PE0.
     1388                            IF ( ( section(is,s) >= nxl  .AND.                 &
     1389                                   section(is,s) <= nxr )  .OR.                &
     1390                                 ( section(is,s) == -1  .AND.  nxl-1 == -1 ) ) &
     1391                            THEN
     1392                               ind(1) = nys-1; ind(2) = nyn+1
     1393                               ind(3) = nzb;   ind(4) = nzt+1
     1394                            ELSE
     1395                               ind(1) = -9999; ind(2) = -9999
     1396                               ind(3) = -9999; ind(4) = -9999
     1397                            ENDIF
     1398                            CALL MPI_SEND( ind(1), 4, MPI_INTEGER, 0, 0, &
     1399                                           comm2d, ierr )
     1400!
     1401!--                         If applicable, send data to PE0.
     1402                            IF ( ind(1) /= -9999 )  THEN
     1403                               CALL MPI_SEND( local_2d(nys-1,nzb), ngp, &
     1404                                              MPI_REAL, 0, 1, comm2d, ierr )
     1405                            ENDIF
     1406                         ENDIF
     1407!
     1408!--                      A barrier has to be set, because otherwise some PEs may
     1409!--                      proceed too fast so that PE0 may receive wrong data on
     1410!--                      tag 0
     1411                         CALL MPI_BARRIER( comm2d, ierr )
     1412                      ENDIF
     1413
    11631414                   ENDIF
    11641415#else
     
    11731424                               start = (/ is, 1, 1, do2d_xz_time_count(av) /), &
    11741425                                              count = (/ 1, ny+2, nz+2, 1 /) )
    1175                       CALL handle_netcdf_error( 'data_output_2d', 61 )
     1426                      CALL handle_netcdf_error( 'data_output_2d', 452 )
    11761427                   ENDIF
    11771428#endif
Note: See TracChangeset for help on using the changeset viewer.