Changeset 493 for palm/trunk/SOURCE


Ignore:
Timestamp:
Mar 1, 2010 8:30:24 AM (15 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)

Location:
palm/trunk/SOURCE
Files:
1 deleted
12 edited

Legend:

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

    r449 r493  
    44! Current revisions:
    55! -----------------
    6 !
     6! NetCDF4 support (parallel output)
    77!
    88! Former revisions:
     
    125125    SELECT CASE ( file_id )
    126126
    127        CASE ( 15, 16, 17, 18, 19, 40:49, 50:59, 81:84, 101:107, 109, 111:113, &
    128               116, 121:160 )
     127       CASE ( 15, 16, 17, 18, 19, 40:49, 50:59, 81:84, 104:105, 107, 109 )
    129128             
    130           IF ( .NOT. format_parallel_io) THEN
     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
    131138         
    132139             IF ( myid /= 0 )  THEN
     
    136143             ENDIF
    137144             
    138           ENDIF
     145          ENDIF
    139146
    140147       CASE ( 21, 22, 23 )
     
    705712          IF ( netcdf_extend )  THEN
    706713!
    707 !--          Open an existing NetCDF file for output
     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
    708719             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_xy(av) )
     720#endif
    709721
    710722             CALL handle_netcdf_error( 'check_open', 20 )
     
    720732                nc_stat = NF90_CLOSE( id_set_xy(av) )
    721733                CALL handle_netcdf_error( 'check_open', 21 )
    722                 CALL local_system( 'rm ' // TRIM( filename ) )
     734                IF ( myid == 0 )  CALL local_system( 'rm ' // TRIM( filename ) )
    723735             ENDIF
    724736
     
    727739          IF ( .NOT. netcdf_extend )  THEN
    728740!
    729 !--          Create a new NetCDF output file
    730              IF ( netcdf_64bit )  THEN
    731 #if defined( __netcdf_64bit )
     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
    732750                nc_stat = NF90_CREATE( filename,                               &
    733751                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
    734752                                       id_set_xy(av) )
    735 #else
    736                 message_string = 'NetCDF: no 64-bit offset allowed ' // &
    737                                  'on this machine'
    738                 CALL message( 'check_open', 'PA0171', 0, 1, 0, 6, 0 )
    739 
    740                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_xy(av) )
    741 #endif
    742              ELSE
    743                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_xy(av) )
    744              ENDIF
     753
     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 )
     771#endif
     772             ENDIF
     773
    745774             CALL handle_netcdf_error( 'check_open', 22 )
     775
    746776!
    747777!--          Define the header
    748778             CALL define_netcdf_header( 'xy', netcdf_extend, av )
     779
     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
    749788
    750789          ENDIF
     
    769808!
    770809!--          Open an existing NetCDF file for output
     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
    771814             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_xz(av) )
     815#endif
    772816             CALL handle_netcdf_error( 'check_open', 23 )
    773817!
     
    782826                nc_stat = NF90_CLOSE( id_set_xz(av) )
    783827                CALL handle_netcdf_error( 'check_open', 24 )
    784                 CALL local_system( 'rm ' // TRIM( filename ) )
     828                IF ( myid == 0 )  CALL local_system( 'rm ' // TRIM( filename ) )
    785829             ENDIF
    786830
     
    789833          IF ( .NOT. netcdf_extend )  THEN
    790834!
    791 !--          Create a new NetCDF output file
    792              IF ( netcdf_64bit )  THEN
    793 #if defined( __netcdf_64bit )
     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
    794844                nc_stat = NF90_CREATE( filename,                               &
    795845                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
    796846                                       id_set_xz(av) )
    797 #else
    798                 message_string = 'NetCDF: no 64-bit offset allowed ' // &
    799                                  'on this machine'
    800                 CALL message( 'check_open', 'PA0171', 0, 1, 0, 6, 0 )
    801          
    802                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_xz(av) )
    803 #endif
    804              ELSE
    805                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_xz(av) )
    806              ENDIF
     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 )
     865#endif
     866             ENDIF
     867
    807868             CALL handle_netcdf_error( 'check_open', 25 )
     869
    808870!
    809871!--          Define the header
    810872             CALL define_netcdf_header( 'xz', netcdf_extend, av )
     873
     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
    811882
    812883          ENDIF
     
    831902!
    832903!--          Open an existing NetCDF file for output
     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
    833908             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_yz(av) )
     909#endif
    834910             CALL handle_netcdf_error( 'check_open', 26 )
    835911!
     
    844920                nc_stat = NF90_CLOSE( id_set_yz(av) )
    845921                CALL handle_netcdf_error( 'check_open', 27 )
    846                 CALL local_system( 'rm ' // TRIM( filename ) )
     922                IF ( myid == 0 )  CALL local_system( 'rm ' // TRIM( filename ) )
    847923             ENDIF
    848924
     
    851927          IF ( .NOT. netcdf_extend )  THEN
    852928!
    853 !--          Create a new NetCDF output file
    854              IF ( netcdf_64bit )  THEN
    855 #if defined( __netcdf_64bit )
    856                 nc_stat = NF90_CREATE( filename,                               &
    857                                        OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET), &
     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
     938                nc_stat = NF90_CREATE( filename,                               &
     939                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
    858940                                       id_set_yz(av) )
    859 #else
    860                 message_string = 'NetCDF: no 64-bit offset allowed ' // &
    861                                  'on this machine'
    862                 CALL message( 'check_open', 'PA0171', 0, 1, 0, 6, 0 )
    863                
    864                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_yz(av) )
    865 #endif
    866              ELSE
    867                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_yz(av) )
    868              ENDIF
     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 )
     959#endif
     960             ENDIF
     961
    869962             CALL handle_netcdf_error( 'check_open', 28 )
     963
    870964!
    871965!--          Define the header
    872966             CALL define_netcdf_header( 'yz', netcdf_extend, av )
     967
     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
    873976
    874977          ENDIF
     
    9081011!
    9091012!--          Create a new NetCDF output file
    910              IF ( netcdf_64bit )  THEN
    911 #if defined( __netcdf_64bit )
     1013             IF ( netcdf_data_format > 1 )  THEN
    9121014                nc_stat = NF90_CREATE( filename,                               &
    9131015                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
    9141016                                       id_set_pr )
    915 #else
    916                 message_string = 'NetCDF: no 64-bit offset allowed ' // &
    917                                  'on this machine'
    918                 CALL message( 'check_open', 'PA0171', 0, 1, 0, 6, 0 )
    919                
    920                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_pr )
    921 #endif
    9221017             ELSE
    9231018                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_pr )
     
    9641059!
    9651060!--          Create a new NetCDF output file
    966              IF ( netcdf_64bit )  THEN
    967 #if defined( __netcdf_64bit )
     1061             IF ( netcdf_data_format > 1 )  THEN
    9681062                nc_stat = NF90_CREATE( filename,                               &
    9691063                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
    9701064                                       id_set_ts )
    971 #else
    972                 message_string = 'NetCDF: no 64-bit offset allowed ' // &
    973                                  'on this machine'
    974                 CALL message( 'check_open', 'PA0171', 0, 1, 0, 6, 0 )
    975                
    976                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_ts )
    977 #endif
    9781065             ELSE
    9791066                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_ts )
     
    9981085          ENDIF
    9991086!
    1000 !--       Inquire, if there is a NetCDF file from a previuos run. This should
     1087!--       Inquire, if there is a NetCDF file from a previous run. This should
    10011088!--       be opened for extension, if its dimensions and variables match the
    10021089!--       actual run.
     
    10051092          IF ( netcdf_extend )  THEN
    10061093!
    1007 !--          Open an existing NetCDF file for output
     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
    10081099             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_3d(av) )
     1100#endif
    10091101             CALL handle_netcdf_error( 'check_open', 35 )
    10101102!
     
    10261118          IF ( .NOT. netcdf_extend )  THEN
    10271119!
    1028 !--          Create a new NetCDF output file
    1029              IF ( netcdf_64bit_3d )  THEN
    1030 #if defined( __netcdf_64bit )
     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
    10311129                nc_stat = NF90_CREATE( filename,                               &
    10321130                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
    10331131                                       id_set_3d(av) )
    1034 #else
    1035                 message_string = 'NetCDF: no 64-bit offset allowed ' // &
    1036                                  'on this machine'
    1037                 CALL message( 'check_open', 'PA0171', 0, 1, 0, 6, 0 )
    1038                
    1039                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_3d(av) )
    1040 #endif
    1041              ELSE
    1042                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_3d(av) )
    1043              ENDIF
     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 )
     1150#endif
     1151             ENDIF
     1152
    10441153             CALL handle_netcdf_error( 'check_open', 37 )
     1154
    10451155!
    10461156!--          Define the header
    10471157             CALL define_netcdf_header( '3d', netcdf_extend, av )
     1158
     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
    10481167
    10491168          ENDIF
     
    10851204!
    10861205!--          Create a new NetCDF output file
    1087              IF ( netcdf_64bit )  THEN
    1088 #if defined( __netcdf_64bit )
     1206             IF ( netcdf_data_format > 1 )  THEN
    10891207                nc_stat = NF90_CREATE( filename,                               &
    10901208                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
    10911209                                       id_set_sp )
    1092 #else
    1093                 message_string = 'NetCDF: no 64-bit offset allowed ' // &
    1094                                  'on this machine'
    1095                 CALL message( 'check_open', 'PA0171', 0, 1, 0, 6, 0 )
    1096                
    1097                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_sp )
    1098 #endif
    10991210             ELSE
    11001211                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_sp )
     
    11621273!
    11631274!--          Create a new NetCDF output file
    1164              IF ( netcdf_64bit )  THEN
    1165 #if defined( __netcdf_64bit )
     1275             IF ( netcdf_data_format > 1 )  THEN
    11661276                nc_stat = NF90_CREATE( filename,                               &
    11671277                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
    11681278                                       id_set_prt )
    1169 #else
    1170                 message_string = 'NetCDF: no 64-bit offset allowed ' // &
    1171                                  'on this machine'
    1172                 CALL message( 'check_open', 'PA0171', 0, 1, 0, 6, 0 )
    1173                
    1174                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_prt )
    1175 #endif
    11761279             ELSE
    11771280                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_prt )
     
    12191322!
    12201323!--          Create a new NetCDF output file
    1221              IF ( netcdf_64bit )  THEN
    1222 #if defined( __netcdf_64bit )
     1324             IF ( netcdf_data_format > 1 )  THEN
    12231325                nc_stat = NF90_CREATE( filename,                               &
    12241326                                       OR( NF90_NOCLOBBER, NF90_64BIT_OFFSET ),&
    12251327                                       id_set_pts )
    1226 #else
    1227                 message_string = 'NetCDF: no 64-bit offset allowed ' // &
    1228                                  'on this machine'
    1229                 CALL message( 'check_open', 'PA0171', 0, 1, 0, 6, 0 )
    1230                
    1231                 nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_pts )
    1232 #endif
    12331328             ELSE
    12341329                nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, id_set_pts )
     
    12661361!--          Open an existing NetCDF file for output
    12671362#if defined( __netcdf4 )
    1268              nc_stat = NF90_OPEN_PAR( filename, NF90_WRITE, comm2d, &
    1269                                       MPI_INFO_NULL, id_set_mask(mid,av) )
     1363             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_mask(mid,av), &
     1364                                  COMM = comm2d, INFO = MPI_INFO_NULL )
    12701365#else
    12711366             nc_stat = NF90_OPEN( filename, NF90_WRITE, id_set_mask(mid,av) )
     
    12901385          IF ( .NOT. netcdf_extend )  THEN
    12911386!
    1292 !--          Create a new NetCDF output file
    1293              SELECT CASE ( nc_format_mask(mid,av) )
    1294 
    1295                 CASE ( 1 )
    1296                    nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, &
    1297                         id_set_mask(mid,av) )
    1298 
    1299                 CASE ( 2 )
    1300 #if defined( __netcdf_64bit )
    1301                    nc_stat = NF90_CREATE( filename, OR( NF90_NOCLOBBER, &
    1302                         NF90_64BIT_OFFSET ), id_set_mask(mid,av) )
    1303 #else
    1304                    WRITE( message_string, * ) 'NetCDF: no 64-bit ', &
    1305                         'offset format allowed on this machine'
    1306                    CALL message( 'check_open', 'PA9998', 0, 1, 0, 6, 0 )
    1307                    nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, &
    1308                         id_set_mask(mid,av) )
    1309 #endif
    1310 
    1311                 CASE ( 3 )
     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) )
     1393
     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) )
     1400
     1401
    13121402#if defined( __netcdf4 )
    1313                    nc_stat = NF90_CREATE_PAR( filename, OR( NF90_NOCLOBBER, &
    1314                         NF90_NETCDF4 ), comm2d, MPI_INFO_NULL, &
    1315                         id_set_mask(mid,av) )
    1316 #else
    1317                    WRITE( message_string, * ) 'NetCDF: no NetCDF 4 ', &
    1318                         'format allowed on this machine'
    1319                    CALL message( 'check_open', 'PA9998', 0, 1, 0, 6, 0 )
    1320                    nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, &
    1321                         id_set_mask(mid,av) )
    1322 #endif
    1323 
    1324                 CASE ( 4 )
    1325 #if defined( __netcdf4 )
    1326                    nc_stat = NF90_CREATE_PAR( filename, OR( NF90_NOCLOBBER, &
    1327                       NF90_CLASSIC_MODEL ), comm2d, &
    1328                       MPI_INFO_NULL, id_set_mask(mid,av) )
    1329 #else
    1330                    WRITE( message_string, * ) 'NetCDF: no NetCDF 4 (Classic ', &
    1331                         'model) format allowed on this machine'
    1332                    CALL message( 'check_open', 'PA9998', 0, 1, 0, 6, 0 )
    1333                    nc_stat = NF90_CREATE( filename, NF90_NOCLOBBER, &
    1334                         id_set_mask(mid,av) )
    1335 #endif
    1336 
    1337                 CASE DEFAULT
    1338                    WRITE( message_string, * ) 'illegal NetCDF file format: ', &
    1339                         'nc_format_mask(mid=',mid,',av=',av,')=', &
    1340                         nc_format_mask(mid,av)
    1341                    CALL message( 'check_open', 'PA9998', 2, 2, 0, 6, 0 )
    1342 
    1343              END SELECT
     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 )
     1410
     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 )
     1419#endif
     1420             ENDIF
     1421
    13441422             CALL handle_netcdf_error( 'check_open', 9998 )
    13451423!
  • palm/trunk/SOURCE/check_parameters.f90

    r484 r493  
    44! Current revisions:
    55! -----------------
    6 !
     6! netcdf_data_format is checked
    77!
    88! Former revisions:
     
    26922692
    26932693!
     2694!-- Check the NetCDF data format
     2695    IF ( netcdf_data_format > 2 )  THEN
     2696#if defined( __netcdf4 )
     2697       CONTINUE
     2698#else
     2699       message_string = 'NetCDF: NetCDF4 format requested but no ' // &
     2700                        'cpp-directive __netcdf4 given & switch '  // &
     2701                        'back to 64-bit offset format'
     2702       CALL message( 'check_parameters', 'PA0171', 0, 1, 0, 6, 0 )
     2703       netcdf_data_format = 2
     2704#endif
     2705    ENDIF
     2706
     2707!
    26942708!-- Check netcdf precison
    26952709    ldum = .FALSE.
  • palm/trunk/SOURCE/close_file.f90

    r449 r493  
    44! Current revisions:
    55! -----------------
    6 !
     6! Adjustments for NetCDF parallel data output
    77!
    88! Former revisions:
     
    409409             CASE ( 101 )
    410410
    411                 IF ( myid == 0  .AND.  netcdf_output )  THEN
     411                IF ( netcdf_output  .AND.  &
     412                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
    412413                   nc_stat = NF90_CLOSE( id_set_xy(0) )
    413414                   CALL handle_netcdf_error( 'close_file', 44 )
     
    416417             CASE ( 102 )
    417418
    418                 IF ( myid == 0  .AND.  netcdf_output )  THEN
     419                IF ( netcdf_output  .AND.  &
     420                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
    419421                   nc_stat = NF90_CLOSE( id_set_xz(0) )
    420422                   CALL handle_netcdf_error( 'close_file', 45 )
     
    423425             CASE ( 103 )
    424426
    425                 IF ( myid == 0  .AND.  netcdf_output )  THEN
     427                IF ( netcdf_output  .AND.  &
     428                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
    426429                   nc_stat = NF90_CLOSE( id_set_yz(0) )
    427430                   CALL handle_netcdf_error( 'close_file', 46 )
     
    444447             CASE ( 106 )
    445448
    446                 IF ( myid == 0  .AND.  netcdf_output )  THEN
     449                IF ( netcdf_output  .AND.  &
     450                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
    447451                   nc_stat = NF90_CLOSE( id_set_3d(0) )
    448452                   CALL handle_netcdf_error( 'close_file', 49 )
     
    472476             CASE ( 111 )
    473477
    474                 IF ( myid == 0  .AND.  netcdf_output )  THEN
     478                IF ( netcdf_output  .AND.  &
     479                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
    475480                   nc_stat = NF90_CLOSE( id_set_xy(1) )
    476481                   CALL handle_netcdf_error( 'close_file', 52 )
     
    479484             CASE ( 112 )
    480485
    481                 IF ( myid == 0  .AND.  netcdf_output )  THEN
     486                IF ( netcdf_output  .AND.  &
     487                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
    482488                   nc_stat = NF90_CLOSE( id_set_xz(1) )
    483489                   CALL handle_netcdf_error( 'close_file', 352 )
     
    486492             CASE ( 113 )
    487493
    488                 IF ( myid == 0  .AND.  netcdf_output )  THEN
     494                IF ( netcdf_output  .AND.  &
     495                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
    489496                   nc_stat = NF90_CLOSE( id_set_yz(1) )
    490497                   CALL handle_netcdf_error( 'close_file', 353 )
     
    493500             CASE ( 116 )
    494501
    495                 IF ( myid == 0  .AND.  netcdf_output )  THEN
     502                IF ( netcdf_output  .AND.  &
     503                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
    496504                   nc_stat = NF90_CLOSE( id_set_3d(1) )
    497505                   CALL handle_netcdf_error( 'close_file', 353 )
     
    500508             CASE ( 121:160 )
    501509             
    502                 IF ( format_parallel_io ) THEN
     510                IF ( netcdf_output  .AND.  &
     511                     ( myid == 0  .OR.  netcdf_data_format > 2 ) )  THEN
    503512!
    504513!--                decompose fid into mid and av
     
    513522                   CALL handle_netcdf_error( 'close_file', 9998 )
    514523               
    515                 ELSEIF ( myid == 0  .AND.  netcdf_output )  THEN
    516 !
    517 !--                decompose fid into mid and av
    518                    IF ( fid <= 140 )  THEN
    519                       mid = fid - 120
    520                       av = 0
    521                    ELSE
    522                       mid = fid - 140
    523                       av = 1
    524                    ENDIF
    525                    nc_stat = NF90_CLOSE( id_set_mask(mid,av) )
    526                    CALL handle_netcdf_error( 'close_file', 9998 )
    527                    
    528524                ENDIF
    529525
  • 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
  • palm/trunk/SOURCE/data_output_3d.f90

    r392 r493  
    7676!-- Open output file.
    7777!-- Also creates coordinate and fld-file for AVS.
    78 !-- In case of a run on more than one PE, each PE opens its own file and
     78!-- For classic or 64bit NetCDF output or output of other (old) data formats,
     79!-- for a run on more than one PE, each PE opens its own file and
    7980!-- writes the data of its subdomain in binary format (regardless of the format
    8081!-- the user has requested). After the run, these files are combined to one
    8182!-- file by combine_plot_fields in the format requested by the user (netcdf
    82 !-- and/or avs).
    83     IF ( avs_output  .OR.  ( numprocs > 1 ) )  CALL check_open( 30 )
    84 
    85 #if defined( __netcdf )
    86     IF ( myid == 0  .AND.  netcdf_output )  CALL check_open( 106+av*10 )
    87 #endif
     83!-- and/or avs).
     84!-- For NetCDF4/HDF5 output, data is written in parallel into one file.
     85    IF ( netcdf_output )  THEN
     86       IF ( netcdf_data_format < 3 )  THEN
     87          CALL check_open( 30 )
     88          IF ( myid == 0 )  CALL check_open( 106+av*10 )
     89       ELSE
     90          CALL check_open( 106+av*10 )
     91       ENDIF
     92    ELSE
     93       IF ( avs_output  .OR.  ( numprocs > 1 ) )  CALL check_open( 30 )
     94    ENDIF
    8895
    8996!
     
    94101!-- Update the NetCDF time axis
    95102#if defined( __netcdf )
    96     do3d_time_count(av) = do3d_time_count(av) + 1
    97     IF ( myid == 0  .AND.  netcdf_output )  THEN
    98        nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av), &
    99                                (/ time_since_reference_point /),  &
    100                                start = (/ do3d_time_count(av) /), &
    101                                count = (/ 1 /) )
    102        CALL handle_netcdf_error( 'data_output_3d', 376 )
     103    IF ( myid == 0  .OR.  netcdf_data_format > 2 )  THEN
     104       do3d_time_count(av) = do3d_time_count(av) + 1
     105       IF ( netcdf_output )  THEN
     106          nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_time_3d(av), &
     107                                  (/ time_since_reference_point /),  &
     108                                  start = (/ do3d_time_count(av) /), &
     109                                  count = (/ 1 /) )
     110          CALL handle_netcdf_error( 'data_output_3d', 376 )
     111       ENDIF
    103112    ENDIF
    104113#endif
     
    376385!--       Uncompressed output.
    377386#if defined( __parallel )
    378           IF ( netcdf_output  .AND.  myid == 0 )  THEN
    379              WRITE ( 30 )  simulated_time, do3d_time_count(av), av
     387          IF ( netcdf_output )  THEN
     388             IF ( netcdf_data_format < 3 )  THEN
     389!
     390!--             Classic or 64bit format. Data is output in parallel in FORTRAN
     391!--             binary format here, and later collected into one file by
     392!--             combine_plot_fields
     393                IF ( myid == 0 )  THEN
     394                   WRITE ( 30 )  simulated_time, do3d_time_count(av), av
     395                ENDIF
     396                WRITE ( 30 )  nxl-1, nxr+1, nys-1, nyn+1, nzb, nz_do3d
     397                WRITE ( 30 )  local_pf
     398
     399             ELSE
     400!
     401!--             Output in NetCDF4/HDF5 format.
     402!--             Do not output redundant ghost point data except for the
     403!--             boundaries of the total domain.
     404                IF ( nxr == nx  .AND.  nyn /= ny )  THEN
     405                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
     406                                  local_pf(nxl:nxr+1,nys:nyn,nzb:nz_do3d),    &
     407                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
     408                      count = (/ nxr-nxl+2, nyn-nys+1, nz_do3d-nzb+1, 1 /) )
     409                ELSEIF ( nxr /= nx  .AND.  nyn == ny )  THEN
     410                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
     411                                  local_pf(nxl:nxr,nys:nyn+1,nzb:nz_do3d),    &
     412                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
     413                      count = (/ nxr-nxl+1, nyn-nys+2, nz_do3d-nzb+1, 1 /) )
     414                ELSEIF ( nxr == nx  .AND.  nyn == ny )  THEN
     415                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
     416                                  local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d),  &
     417                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
     418                      count = (/ nxr-nxl+2, nyn-nys+2, nz_do3d-nzb+1, 1 /) )
     419                ELSE
     420                   nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if), &
     421                                  local_pf(nxl:nxr,nys:nyn,nzb:nz_do3d),      &
     422                      start = (/ nxl+1, nys+1, nzb+1, do3d_time_count(av) /), &
     423                      count = (/ nxr-nxl+1, nyn-nys+1, nz_do3d-nzb+1, 1 /) )
     424                ENDIF
     425                CALL handle_netcdf_error( 'data_output_3d', 386 )
     426             ENDIF
    380427          ENDIF
    381           WRITE ( 30 )  nxl-1, nxr+1, nys-1, nyn+1, nzb, nz_do3d
    382           WRITE ( 30 )  local_pf
    383428#else
    384429          IF ( avs_output )  THEN
     
    387432#if defined( __netcdf )
    388433          IF ( netcdf_output )  THEN
    389              nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),       &
    390                                   local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d),  &
    391                                   start = (/ 1, 1, 1, do3d_time_count(av) /), &
    392                                   count = (/ nx+2, ny+2, nz_do3d-nzb+1, 1 /) )
    393              CALL handle_netcdf_error( 'data_output_3d', 386 )
     434
     435             nc_stat = NF90_PUT_VAR( id_set_3d(av), id_var_do3d(av,if),    &
     436                               local_pf(nxl:nxr+1,nys:nyn+1,nzb:nz_do3d),  &
     437                               start = (/ 1, 1, 1, do3d_time_count(av) /), &
     438                               count = (/ nx+2, ny+2, nz_do3d-nzb+1, 1 /) )
     439             CALL handle_netcdf_error( 'data_output_3d', 446 )
     440
    394441          ENDIF
    395442#endif
  • palm/trunk/SOURCE/data_output_mask.f90

    r484 r493  
    5353    CALL cpu_log (log_point(49),'data_output_mask','start')
    5454
    55 !!
     55!
    5656!-- Open output file.
    57     IF ( format_parallel_io .AND. netcdf_output )  THEN
    58        CALL check_open( 120+mid+av*max_masks )
    59     ELSEIF (myid == 0  .AND.  netcdf_output ) THEN
     57    IF ( netcdf_output  .AND.  ( myid == 0  .OR.  netcdf_data_format > 2 ) ) &
     58    THEN
    6059       CALL check_open( 120+mid+av*max_masks )
    6160    ENDIF
     
    7473!-- Update the NetCDF time axis.
    7574    domask_time_count(mid,av) = domask_time_count(mid,av) + 1
    76     IF ( format_parallel_io .AND. netcdf_output )  THEN
    77        nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_time_mask(mid,av), &
    78                                (/ simulated_time /),                          &
    79                                start = (/ domask_time_count(mid,av) /),       &
    80                                count = (/ 1 /) )
    81        CALL handle_netcdf_error( 'data_output_mask', 9998 )
    82     ELSEIF ( myid == 0  .AND.  netcdf_output )  THEN
     75    IF ( netcdf_output  .AND.  ( myid == 0  .OR.  netcdf_data_format > 2 ) ) &
     76    THEN
    8377       nc_stat = NF90_PUT_VAR( id_set_mask(mid,av), id_var_time_mask(mid,av), &
    8478                               (/ simulated_time /),                          &
     
    9589!
    9690!--    Reallocate local_pf on PE 0 since its shape changes during MPI exchange
    97        IF ( .NOT. format_parallel_io .AND. myid == 0 .AND. if > 1 )  THEN
     91       IF ( netcdf_data_format < 3   .AND.  myid == 0  .AND. if > 1 )  THEN
    9892          DEALLOCATE( local_pf )
    9993          ALLOCATE( local_pf(mask_size_l(mid,1),mask_size_l(mid,2), &
     
    329323!--    The choice of method depends on the correct setting of preprocessor
    330324!--    directives __parallel and __netcdf4 as well as on the parameter
    331 !--    nc_format_mask(mid,av).
     325!--    netcdf_data_format.
    332326#if defined( __parallel )
    333327#if defined( __netcdf4 )
    334        IF ( nc_format_mask(mid,av) == 3 .OR. nc_format_mask(mid,av) == 4 )  THEN
     328       IF ( netcdf_data_format > 2 )  THEN
    335329!
    336330!--       (1) a. Parallel I/O using NetCDF 4 (not yet tested)
  • palm/trunk/SOURCE/header.f90

    r482 r493  
    44! Current revisions:
    55! -----------------
    6 !
     6! NetCDF data output format extendend for NetCDF4/HDF5
    77!
    88! Former revisions:
     
    1616! 410 2009-12-04 17:05:40Z letzel
    1717! Masked data output: + dt_domask, mask_01~20_x|y|z, mask_01~20_x|y|z_loop,
    18 ! mask_scale|_x|y|z, masks, netcdf_format_mask[_av], skip_time_domask
     18! mask_scale|_x|y|z, masks, skip_time_domask
    1919!
    2020! 346 2009-07-06 10:13:41Z raasch
     
    700700       output_format = ''
    701701       IF ( netcdf_output )  THEN
    702           IF ( netcdf_64bit )  THEN
    703              output_format = 'netcdf (64 bit offset)'
     702          IF ( netcdf_data_format == 1 )  THEN
     703             output_format = 'NetCDF classic'
    704704          ELSE
    705              output_format = 'netcdf'
     705             output_format = 'NetCDF 64bit offset'
    706706          ENDIF
    707707       ENDIF
     
    778778          output_format = ''
    779779          IF ( netcdf_output )  THEN
    780              IF ( netcdf_64bit )  THEN
    781                 output_format = 'netcdf (64 bit offset)'
    782              ELSE
    783                 output_format = 'netcdf'
     780             IF ( netcdf_data_format == 1 )  THEN
     781                output_format = 'NetCDF classic'
     782             ELSEIF ( netcdf_data_format == 2 )  THEN
     783                output_format = 'NetCDF 64bit offset'
     784             ELSEIF ( netcdf_data_format == 3 )  THEN
     785                output_format = 'NetCDF4/HDF5'
     786             ELSEIF ( netcdf_data_format == 4 )  THEN
     787                output_format = 'NetCDF4/HDF5 clasic'
    784788             ENDIF
    785789          ENDIF
     
    935939          output_format = ''
    936940          IF ( netcdf_output )  THEN
    937              IF ( netcdf_64bit_3d )  THEN
    938                 output_format = 'netcdf (64 bit offset)'
    939              ELSE
    940                 output_format = 'netcdf'
     941             IF ( netcdf_data_format == 1 )  THEN
     942                output_format = 'NetCDF classic'
     943             ELSEIF ( netcdf_data_format == 2 )  THEN
     944                output_format = 'NetCDF 64bit offset'
     945             ELSEIF ( netcdf_data_format == 3 )  THEN
     946                output_format = 'NetCDF4/HDF5'
     947             ELSEIF ( netcdf_data_format == 4 )  THEN
     948                output_format = 'NetCDF4/HDF5 clasic'
    941949             ENDIF
    942950          ENDIF
     
    10291037             output_format = ''
    10301038             IF ( netcdf_output )  THEN
    1031                 SELECT CASE ( nc_format_mask(mid,av) )
    1032                    CASE ( 1 )
    1033                       output_format = 'netcdf (classic format)'
    1034                    CASE ( 2 )
    1035                       output_format = 'netcdf (64bit offset format)'
    1036                    CASE ( 3 )
    1037                       output_format = 'netcdf (NetCDF 4 format)'
    1038                    CASE ( 4 )
    1039                       output_format = 'netcdf (NetCDF 4 classic model format)'
    1040                 END SELECT
     1039                IF ( netcdf_data_format == 1 )  THEN
     1040                   output_format = 'NetCDF classic'
     1041                ELSEIF ( netcdf_data_format == 2 )  THEN
     1042                   output_format = 'NetCDF 64bit offset'
     1043                ELSEIF ( netcdf_data_format == 3 )  THEN
     1044                   output_format = 'NetCDF4/HDF5'
     1045                ELSEIF ( netcdf_data_format == 4 )  THEN
     1046                   output_format = 'NetCDF4/HDF5 clasic'
     1047                ENDIF
    10411048             ENDIF
    10421049             WRITE ( io, 344 )  output_format
     
    10921099       output_format = ''
    10931100       IF ( netcdf_output )  THEN
    1094           IF ( netcdf_64bit )  THEN
    1095              output_format = 'netcdf (64 bit offset)'
     1101          IF ( netcdf_data_format == 1 )  THEN
     1102             output_format = 'NetCDF classic'
    10961103          ELSE
    1097              output_format = 'netcdf'
     1104             output_format = 'NetCDF 64bit offset'
    10981105          ENDIF
    10991106       ENDIF
     
    11691176       output_format = ''
    11701177       IF ( netcdf_output )  THEN
    1171           IF ( netcdf_64bit )  THEN
    1172              output_format = 'netcdf (64 bit offset)'
     1178          IF ( netcdf_data_format == 1 )  THEN
     1179             output_format = 'NetCDF classic'
    11731180          ELSE
    1174              output_format = 'netcdf'
     1181             output_format = 'NetCDF 64bit offset'
    11751182          ENDIF
    11761183       ENDIF
     
    14931500          output_format = ''
    14941501          IF ( netcdf_output )  THEN
    1495              IF ( netcdf_64bit )  THEN
     1502             IF ( netcdf_data_format > 1 )  THEN
    14961503                output_format = 'netcdf (64 bit offset) and binary'
    14971504             ELSE
  • palm/trunk/SOURCE/init_masks.f90

    r484 r493  
    4848    ALLOCATE( mask(max_masks,3,mask_xyz_dimension), &
    4949              mask_loop(max_masks,3,3) )
    50 !
    51 !-- Store netcdf file formats for masked data output in one shared array
    52     nc_format_mask(:,0) = netcdf_format_mask
    53     nc_format_mask(:,1) = netcdf_format_mask_av
    5450   
    55     IF ( ANY( nc_format_mask == 3 ) .OR. ANY( nc_format_mask == 4 )) THEN
    56        format_parallel_io = .TRUE.
    57     ENDIF
    58 
    59     IF ( ANY( nc_format_mask < 1 ) .OR. ANY( nc_format_mask > 4 ) )  THEN
    60        WRITE( message_string, * )  'illegal value: netcdf_format_mask and ', &
    61             'netcdf_format_mask_av must be either 1, 2, 3 or 4'
    62        IF ( ANY( nc_format_mask == 3 ) .OR. ANY( nc_format_mask == 4 ) )  THEN
    63           message_string = TRIM( message_string ) // '&NetCDF file formats '// &
    64                '3 (NetCDF 4) and 4 (NetCDF 4 Classic model)'// &
    65                '&are currently not supported (not yet tested).'
    66        ENDIF
     51!
     52!-- Parallel mask output not yet tested
     53    IF ( netcdf_data_format > 2 )  THEN
     54       message_string = 'NetCDF file formats '//                         &
     55                        '3 (NetCDF 4) and 4 (NetCDF 4 Classic model)'//  &
     56                        '&are currently not supported (not yet tested).'
    6757       CALL message( 'init_masks', 'PA9998', 1, 2, 0, 6, 0 )
    6858    ENDIF
     
    162152!
    163153!-- Global arrays are required by define_netcdf_header.
    164     IF ( format_parallel_io )  THEN
    165        ALLOCATE( mask_i_global(max_masks,nx+1), &
    166                  mask_j_global(max_masks,ny+1), &
    167                  mask_k_global(max_masks,nz+1) )
    168        mask_i_global = -1; mask_j_global = -1; mask_k_global = -1
    169     ELSEIF ( myid == 0 )  THEN
     154    IF ( myid == 0  .OR.  netcdf_data_format > 2 )  THEN
    170155       ALLOCATE( mask_i_global(max_masks,nx+1), &
    171156                 mask_j_global(max_masks,ny+1), &
     
    472457       CALL MPI_BARRIER( comm2d, ierr )
    473458       
    474        IF ( format_parallel_io )  THEN 
     459       IF ( netcdf_data_format > 2 )  THEN 
    475460         
    476           CALL MPI_BCAST( mask_i_global(mid,:), nx+1, MPI_INTEGER, 0, comm2d, ierr )
    477           CALL MPI_BCAST( mask_j_global(mid,:), ny+1, MPI_INTEGER, 0, comm2d, ierr )
    478           CALL MPI_BCAST( mask_k_global(mid,:), nz+1, MPI_INTEGER, 0, comm2d, ierr )
     461          CALL MPI_BCAST( mask_i_global(mid,:), nx+1, MPI_INTEGER, 0, comm2d, &
     462                          ierr )
     463          CALL MPI_BCAST( mask_j_global(mid,:), ny+1, MPI_INTEGER, 0, comm2d, &
     464                          ierr )
     465          CALL MPI_BCAST( mask_k_global(mid,:), nz+1, MPI_INTEGER, 0, comm2d, &
     466                          ierr )
    479467         
    480468       ENDIF
     
    496484
    497485 CONTAINS
     486
    498487    SUBROUTINE set_mask_locations( dim, dxyz, dxyz_string, nxyz, nxyz_string, &
    499488                                   lb, ub )
  • palm/trunk/SOURCE/modules.f90

    r486 r493  
    55! Current revisions:
    66! -----------------
    7 !
     7! +netcdf_data_format, -netcdf_64bit, -netcdf_64bit_3d
    88!
    99! Former revisions:
     
    2323! 410 2009-12-04 17:05:40Z letzel
    2424! masked data output: + dt_domask, mask_01~20_x|y|z, mask_01~20_x|y|z_loop,
    25 ! mask_scale|_x|y|z, masks, netcdf_format_mask[_av], skip_time_domask
     25! mask_scale|_x|y|z, masks, skip_time_domask
    2626!
    2727! 388 2009-09-23 09:40:33Z raasch
     
    379379                intermediate_timestep_count, intermediate_timestep_count_max, &
    380380                iran = -1234567, last_dt_change = 0, masks = 0, &
    381                 maximum_grid_level, &
    382                 max_pr_user = 0, mgcycles = 0, mg_cycles = -1, &
    383                 mg_switch_to_pe0_level = 0, mid, ngsrb = 2, nsor = 20, &
     381                maximum_grid_level, max_pr_user = 0, mgcycles = 0, &
     382                mg_cycles = -1, mg_switch_to_pe0_level = 0, mid, &
     383                netcdf_data_format = 2, ngsrb = 2, nsor = 20, &
    384384                nsor_ini = 100, n_sor, normalizing_region = 0, &
    385385                nz_do1d, nz_do3d = -9999, outflow_damping_width = -1, &
     
    396396                mask_size(max_masks,3) = -1, mask_size_l(max_masks,3) = -1, &
    397397                mask_start_l(max_masks,3) = -1, &
    398                 nc_format_mask(1:max_masks,0:1), &
    399                 netcdf_format_mask(1:max_masks) = 1, &
    400                 netcdf_format_mask_av(1:max_masks) = 1, &
    401398                pt_vertical_gradient_level_ind(10) = -9999, &
    402399                q_vertical_gradient_level_ind(10) = -9999, &
     
    430427                disturbance_created = .FALSE., &
    431428                first_call_advec_particles = .TRUE., &
    432                 force_print_header = .FALSE., format_parallel_io = .FALSE., &
    433                 galilei_transformation = .FALSE.,&
     429                force_print_header = .FALSE., galilei_transformation = .FALSE.,&
    434430                humidity = .FALSE., humidity_remote = .FALSE., &
    435431                inflow_l = .FALSE., inflow_n = .FALSE., &
     
    437433                iso2d_output = .FALSE., large_scale_subsidence = .FALSE., &
    438434                mg_switch_to_pe0 = .FALSE., &
    439                 netcdf_output = .FALSE., netcdf_64bit = .FALSE., &
    440                 netcdf_64bit_3d = .TRUE., ocean = .FALSE., &
     435                netcdf_output = .FALSE., ocean = .FALSE., &
    441436                outflow_l = .FALSE., outflow_n = .FALSE., outflow_r = .FALSE., &
    442437                outflow_s = .FALSE., passive_scalar = .FALSE., &
  • palm/trunk/SOURCE/netcdf.f90

    r449 r493  
    77! Current revisions:
    88! ------------------
    9 !
     9! Extensions for NetCDF4 output
    1010!
    1111! Former revisions:
     
    10931093                                     'units', TRIM( do3d_unit(av,i) ) )
    10941094             CALL handle_netcdf_error( 'netcdf', 357 )
    1095 
     1095#if defined( __netcdf4 )
     1096!
     1097!--          Set collective io operations for parallel io
     1098             IF ( netcdf_data_format > 2 )  THEN
     1099                nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av),     &
     1100                                               id_var_do3d(av,i), &
     1101                                               NF90_COLLECTIVE )
     1102                CALL handle_netcdf_error( 'netcdf', 445 )
     1103             ENDIF
     1104#endif
    10961105             i = i + 1
    10971106
     
    12991308                                       id_var_do3d(av,i) )
    13001309             CALL handle_netcdf_error( 'netcdf', 95 )
     1310#if defined( __netcdf4 )
     1311!
     1312!--          Set collective io operations for parallel io
     1313             IF ( netcdf_data_format > 2 )  THEN
     1314                nc_stat = NF90_VAR_PAR_ACCESS( id_set_3d(av),     &
     1315                                               id_var_do3d(av,i), &
     1316                                               NF90_COLLECTIVE )
     1317                CALL handle_netcdf_error( 'netcdf', 453 )
     1318             ENDIF
     1319#endif
    13011320             i = i + 1
    13021321          ENDDO
     
    16441663                                        'units', TRIM( do2d_unit(av,i) ) )
    16451664                CALL handle_netcdf_error( 'netcdf', 354 )
     1665#if defined( __netcdf4 )
     1666!
     1667!--             Set collective io operations for parallel io
     1668                IF ( netcdf_data_format > 2 )  THEN
     1669                   nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av),     &
     1670                                                  id_var_do2d(av,i), &
     1671                                                  NF90_COLLECTIVE )
     1672                   CALL handle_netcdf_error( 'netcdf', 448 )
     1673                ENDIF
     1674#endif
    16461675             ENDIF
    16471676
     
    19401969                                          id_var_do2d(av,i) )
    19411970                CALL handle_netcdf_error( 'netcdf', 138 )
     1971#if defined( __netcdf4 )
     1972!
     1973!--             Set collective io operations for parallel io
     1974                IF ( netcdf_data_format > 2 )  THEN
     1975                   nc_stat = NF90_VAR_PAR_ACCESS( id_set_xy(av),     &
     1976                                                  id_var_do2d(av,i), &
     1977                                                  NF90_COLLECTIVE )
     1978                   CALL handle_netcdf_error( 'netcdf', 454 )
     1979                ENDIF
     1980#endif
    19421981             ENDIF
    19431982             i = i + 1
     
    22122251                                        'units', TRIM( do2d_unit(av,i) ) )
    22132252                CALL handle_netcdf_error( 'netcdf', 355 )
     2253#if defined( __netcdf4 )
     2254!
     2255!--             Set independent io operations for parallel io. Collective io
     2256!--             is only allowed in case of a 1d-decomposition along x, because
     2257!--             otherwise, not all PEs have output data.
     2258                IF ( netcdf_data_format > 2 )  THEN
     2259                   IF ( npey == 1 )  THEN
     2260                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av),     &
     2261                                                     id_var_do2d(av,i), &
     2262                                                     NF90_COLLECTIVE )
     2263                   ELSE
     2264!
     2265!--                   ATTENTION: Due to a probable bug in the NetCDF4
     2266!--                              installation, independet output does not work
     2267!--                              A workaround is used in data_output_2d on those
     2268!--                              PEs having no data
     2269                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av),     &
     2270                                                     id_var_do2d(av,i), &
     2271                                                     NF90_COLLECTIVE )
     2272!                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av),     &
     2273!                                                     id_var_do2d(av,i), &
     2274!                                                     NF90_INDEPENDENT )
     2275                   ENDIF
     2276                   CALL handle_netcdf_error( 'netcdf', 449 )
     2277                ENDIF
     2278#endif
    22142279             ENDIF
    22152280
     
    24782543                                          id_var_do2d(av,i) )
    24792544                CALL handle_netcdf_error( 'netcdf', 177 )
     2545#if defined( __netcdf4 )
     2546!
     2547!--             Set independent io operations for parallel io. Collective io
     2548!--             is only allowed in case of a 1d-decomposition along x, because
     2549!--             otherwise, not all PEs have output data.
     2550                IF ( netcdf_data_format > 2 )  THEN
     2551                   IF ( npey == 1 )  THEN
     2552                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av),     &
     2553                                                     id_var_do2d(av,i), &
     2554                                                     NF90_COLLECTIVE )
     2555                   ELSE
     2556!
     2557!--                   ATTENTION: Due to a probable bug in the NetCDF4
     2558!--                              installation, independet output does not work
     2559!--                              A workaround is used in data_output_2d on those
     2560!--                              PEs having no data
     2561                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av),     &
     2562                                                     id_var_do2d(av,i), &
     2563                                                     NF90_COLLECTIVE )
     2564!                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_xz(av),     &
     2565!                                                     id_var_do2d(av,i), &
     2566!                                                     NF90_INDEPENDENT )
     2567                   ENDIF
     2568                   CALL handle_netcdf_error( 'netcdf', 455 )
     2569                ENDIF
     2570#endif
    24802571             ENDIF
    24812572             i = i + 1
     
    27502841                                        'units', TRIM( do2d_unit(av,i) ) )
    27512842                CALL handle_netcdf_error( 'netcdf', 356 )
     2843#if defined( __netcdf4 )
     2844!
     2845!--             Set independent io operations for parallel io. Collective io
     2846!--             is only allowed in case of a 1d-decomposition along y, because
     2847!--             otherwise, not all PEs have output data.
     2848                IF ( netcdf_data_format > 2 )  THEN
     2849                   IF ( npex == 1 )  THEN
     2850                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av),     &
     2851                                                     id_var_do2d(av,i), &
     2852                                                     NF90_COLLECTIVE )
     2853                   ELSE
     2854!
     2855!--                   ATTENTION: Due to a probable bug in the NetCDF4
     2856!--                              installation, independet output does not work
     2857!--                              A workaround is used in data_output_2d on those
     2858!--                              PEs having no data
     2859                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av),     &
     2860                                                     id_var_do2d(av,i), &
     2861                                                     NF90_COLLECTIVE )
     2862!                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av),     &
     2863!                                                     id_var_do2d(av,i), &
     2864!                                                     NF90_INDEPENDENT )
     2865                   ENDIF
     2866                   CALL handle_netcdf_error( 'netcdf', 450 )
     2867                ENDIF
     2868#endif
    27522869             ENDIF
    27532870
     
    30143131                                          id_var_do2d(av,i) )
    30153132                CALL handle_netcdf_error( 'netcdf', 216 )
     3133#if defined( __netcdf4 )
     3134!
     3135!--             Set independent io operations for parallel io. Collective io
     3136!--             is only allowed in case of a 1d-decomposition along y, because
     3137!--             otherwise, not all PEs have output data.
     3138                IF ( netcdf_data_format > 2 )  THEN
     3139                   IF ( npex == 1 )  THEN
     3140                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av),     &
     3141                                                     id_var_do2d(av,i), &
     3142                                                     NF90_COLLECTIVE )
     3143                   ELSE
     3144!
     3145!--                   ATTENTION: Due to a probable bug in the NetCDF4
     3146!--                              installation, independet output does not work
     3147!--                              A workaround is used in data_output_2d on those
     3148!--                              PEs having no data
     3149                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av),     &
     3150                                                     id_var_do2d(av,i), &
     3151                                                     NF90_COLLECTIVE )
     3152!                      nc_stat = NF90_VAR_PAR_ACCESS( id_set_yz(av),     &
     3153!                                                     id_var_do2d(av,i), &
     3154!                                                     NF90_INDEPENDENT )
     3155                   ENDIF
     3156                   CALL handle_netcdf_error( 'netcdf', 450 )
     3157                ENDIF
     3158#endif
    30163159             ENDIF
    30173160             i = i + 1
  • palm/trunk/SOURCE/parin.f90

    r482 r493  
    44! Current revisions:
    55! -----------------
    6 !
     6! +netcdf_data_format in d3par, -netcdf_64bit, -netcdf_64bit_3d
    77!
    88! Former revisions:
     
    1616! 410 2009-12-04 17:05:40Z letzel
    1717! masked data output: + dt_domask, mask_01~20_x|y|z, mask_01~20_x|y|z_loop,
    18 ! mask_scale_x|y|z, masks, netcdf_format_mask[_av], skip_time_domask
     18! mask_scale_x|y|z, masks, skip_time_domask
    1919!
    2020! 291 2009-04-16 12:07:26Z raasch
     
    6161! 20 2007-02-26 00:12:32Z raasch
    6262! +top_heatflux, use_top_fluxes in inipar
    63 !
    64 ! -netcdf_64bit_3d
    6563!
    6664! 3 2007-02-13 11:30:58Z raasch
     
    208206                       mask_19_z_loop, mask_20_z_loop, &
    209207                       mg_cycles, mg_switch_to_pe0_level, &
    210                        netcdf_64bit, netcdf_64bit_3d, &
    211                        netcdf_format_mask, netcdf_format_mask_av, &
     208                       netcdf_data_format, &
    212209                       ngsrb, normalizing_region, npex, npey, nsor, nz_do3d, &
    213210                       omega_sor, &
  • palm/trunk/SOURCE/user_statistics.f90

    r484 r493  
    44! Current revisions:
    55! -----------------
    6 !
     6! Bugfix: timeseries data have to be collected by PE0
    77!
    88! Former revisions:
     
    2525    USE arrays_3d
    2626    USE indices
     27    USE netcdf_control
    2728    USE statistics
    2829    USE user
     
    3334
    3435    INTEGER ::  i, j, k, sr, tn
     36
     37    REAL, DIMENSION(dots_num_palm+1:dots_max) ::  ts_value_l
    3538
    3639
     
    7073!--    creates two time series for the absolut values of the horizontal
    7174!--    velocities u and v.
    72 !       ts_value(dots_num_palm+1,sr) = ABS( u_max )
    73 !       ts_value(dots_num_palm+2,sr) = ABS( v_max )
     75!       ts_value_l = 0.0
     76!       ts_value_l(dots_num_palm+1,sr) = ABS( u_max )
     77!       ts_value_l(dots_num_palm+2,sr) = ABS( v_max )
     78!
     79!--     Collect / send values to PE0, because only PE0 outputs the time series.
     80!--     CAUTION: Collection is done by taking the sum over all processors.
     81!--              You may have to normalize this sum, depending on the quantity
     82!--              that you like to calculate. For serial runs, nothing has to be
     83!--              done.
     84!--     HINT: If the time series value that you are calculating has the same
     85!--           value on all PEs, you can omit the MPI_ALLREDUCE call and
     86!--           assign ts_value(dots_num_palm+1:,sr) = ts_value_l directly.
     87!#if defined( __parallel )
     88!       CALL MPI_ALLREDUCE( ts_value_l(dots_num_palm+1),                       &
     89!                           ts_value(dots_num_palm+1,sr),                      &
     90!                           dots_max-dots_num_palm, MPI_REAL, MPI_SUM, comm2d, &
     91!                           ierr )
     92!#else
     93!       ts_value(dots_num_palm+1:,sr) = ts_value_l
     94!#endif
    7495
    7596    ENDIF
Note: See TracChangeset for help on using the changeset viewer.