Index: palm/trunk/SOURCE/module_interface.f90
===================================================================
--- palm/trunk/SOURCE/module_interface.f90	(revision 4028)
+++ palm/trunk/SOURCE/module_interface.f90	(revision 4039)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Introduce diagnostic output
+! 
+! 4028 2019-06-13 12:21:37Z schwenkel
 ! Further modularization of particle code components
 ! 
@@ -210,4 +213,13 @@
               chem_rrd_local,                                                  &
               chem_wrd_local
+     
+    USE diagnostic_output_quantities_mod,                                      & 
+        ONLY:  doq_3d_data_averaging,                                          &
+               doq_check_data_output,                                          &
+               doq_define_netcdf_grid,                                         &
+               doq_output_2d,                                                  &
+               doq_output_3d,                                                  &
+               doq_wrd_local
+!                doq_rrd_local,                                                  &
 
     USE flight_mod,                                                            &
@@ -751,4 +763,8 @@
        CALL chem_check_data_output( variable, unit, i, ilen, k )
     ENDIF
+    
+    IF ( unit == 'illegal' )  THEN
+       CALL doq_check_data_output( variable, unit )
+    ENDIF
 
     IF ( unit == 'illegal'  .AND.  gust_module_enabled  )  THEN
@@ -1179,4 +1195,5 @@
     IF ( bulk_cloud_model    )  CALL bcm_3d_data_averaging( mode, variable )
     IF ( air_chemistry       )  CALL chem_3d_data_averaging( mode, variable )
+    CALL doq_3d_data_averaging( mode, variable )
     IF ( gust_module_enabled )  CALL gust_3d_data_averaging( mode, variable )
     IF ( land_surface        )  CALL lsm_3d_data_averaging( mode, variable )
@@ -1234,4 +1251,10 @@
             )
     ENDIF
+    
+    IF ( .NOT. found )  THEN
+       CALL doq_output_2d(                                                     &
+               av, variable, found, grid, mode, local_pf, two_d,               &
+               nzb_do, nzt_do, fill_value )
+    ENDIF
 
     IF ( .NOT. found  .AND.  gust_module_enabled )  THEN
@@ -1314,5 +1337,10 @@
        resorted = .TRUE.
     ENDIF
-
+    
+    IF ( .NOT. found )  THEN
+       CALL doq_output_3d( av, variable, found, local_pf, fill_value, nzb_do, nzt_do )
+       resorted = .TRUE.
+    ENDIF
+    
     IF ( .NOT. found  .AND.  gust_module_enabled )  THEN
        CALL gust_data_output_3d( av, variable, found, local_pf, fill_value, nzb_do, nzt_do )
@@ -1466,15 +1494,19 @@
     LOGICAL,      INTENT(INOUT) ::  found        !< flag if variable was found
 
-    REAL(wp), DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp), INTENT(OUT) :: tmp_2d   !<
-    REAL(wp), DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp), INTENT(OUT) :: tmp_3d   !<
+    REAL(wp), &
+       DIMENSION(nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp), &
+       INTENT(OUT) :: tmp_2d   !<
+    REAL(wp), &
+       DIMENSION(nzb:nzt+1,nys_on_file-nbgp:nyn_on_file+nbgp,nxl_on_file-nbgp:nxr_on_file+nbgp), &
+       INTENT(OUT) :: tmp_3d   !<
 
 
     IF ( debug_output )  CALL debug_message( 'module-specific read local restart data', 'start' )
 
-    IF ( .NOT. found ) CALL bio_rrd_local(                                     &
+    IF ( .NOT. found )  CALL bio_rrd_local(                                    &
                                found                                           &
                             )
 
-    IF ( .NOT. found ) CALL bcm_rrd_local(                                     &
+    IF ( .NOT. found )  CALL bcm_rrd_local(                                    &
                                map_index,                                      &
                                nxlf, nxlc, nxl_on_file,                        &
@@ -1485,5 +1517,5 @@
                             ) ! ToDo: change interface to pass variable
 
-    IF ( .NOT. found ) CALL chem_rrd_local(                                    &
+    IF ( .NOT. found )  CALL chem_rrd_local(                                   &
                                map_index,                                      &
                                nxlf, nxlc, nxl_on_file,                        &
@@ -1493,6 +1525,15 @@
                                tmp_3d, found                                   &
                             ) ! ToDo: change interface to pass variable
-
-    IF ( .NOT. found ) CALL gust_rrd_local(                                    &
+                            
+!     IF ( .NOT. found )  CALL doq_rrd_local(                                    &
+!                                map_index,                                      &
+!                                nxlf, nxlc, nxl_on_file,                        &
+!                                nxrf, nxrc, nxr_on_file,                        &
+!                                nynf, nync, nyn_on_file,                        &
+!                                nysf, nysc, nys_on_file,                        &
+!                                tmp_3d_non_standard, found                      &
+!                             ) ! ToDo: change interface to pass variable CALL doq_wrd_local
+
+    IF ( .NOT. found )  CALL gust_rrd_local(                                   &
                                map_index,                                      &
                                nxlf, nxlc, nxl_on_file,                        &
@@ -1503,5 +1544,5 @@
                             ) ! ToDo: change interface to pass variable
 
-    IF ( .NOT. found ) CALL lpm_rrd_local(                                     &
+    IF ( .NOT. found )  CALL lpm_rrd_local(                                    &
                                map_index,                                      &
                                nxlf, nxlc, nxl_on_file,                        &
@@ -1512,5 +1553,5 @@
                             ) ! ToDo: change interface to pass variable
 
-    IF ( .NOT. found ) CALL lsm_rrd_local(                                     &
+    IF ( .NOT. found )  CALL lsm_rrd_local(                                    &
                                map_index,                                      &
                                nxlf, nxlc, nxl_on_file,                        &
@@ -1521,5 +1562,5 @@
                             ) ! ToDo: change interface to pass variable
 
-    IF ( .NOT. found ) CALL ocean_rrd_local(                                   &
+    IF ( .NOT. found )  CALL ocean_rrd_local(                                  &
                                map_index,                                      &
                                nxlf, nxlc, nxl_on_file,                        &
@@ -1530,5 +1571,5 @@
                             ) ! ToDo: change interface to pass variable
 
-    IF ( .NOT. found ) CALL radiation_rrd_local(                               &
+    IF ( .NOT. found )  CALL radiation_rrd_local(                              &
                                map_index,                                      &
                                nxlf, nxlc, nxl_on_file,                        &
@@ -1539,5 +1580,5 @@
                             ) ! ToDo: change interface to pass variable
 
-    IF ( .NOT. found ) CALL salsa_rrd_local(                                   &
+    IF ( .NOT. found )  CALL salsa_rrd_local(                                  &
                                map_index,                                      &
                                nxlf, nxlc, nxl_on_file,                        &
@@ -1548,5 +1589,5 @@
                             ) ! ToDo: change interface to pass variable
 
-    IF ( .NOT. found ) CALL usm_rrd_local(                                     &
+    IF ( .NOT. found )  CALL usm_rrd_local(                                    &
                                map_index,                                      &
                                nxlf, nxlc, nxl_on_file,                        &
@@ -1558,7 +1599,7 @@
 !
 !-- Surface data do not need overlap data, so do not pass these information.
-    IF ( .NOT. found ) CALL surface_data_output_rrd_local( found )
+    IF ( .NOT. found )  CALL surface_data_output_rrd_local( found )
                            
-    IF ( .NOT. found ) CALL user_rrd_local(                                    &
+    IF ( .NOT. found )  CALL user_rrd_local(                                   &
                                map_index,                                      &
                                nxlf, nxlc, nxl_on_file,                        &
@@ -1588,4 +1629,5 @@
     IF ( bulk_cloud_model )     CALL bcm_wrd_local
     IF ( air_chemistry )        CALL chem_wrd_local
+    CALL doq_wrd_local
     IF ( gust_module_enabled )  CALL gust_wrd_local
     IF ( particle_advection )   CALL lpm_wrd_local    
