output_processing.F90 8.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
! !MODULE: output_processing
!
! !INTERFACE:
   module output_processing
!
! !DESCRIPTION:
!  This modules serves as a container for processing output variables. 

! !USES:
   use domain, only: imin,imax,jmin,jmax,kmax
15
   use field_manager
16
   IMPLICIT NONE
17 18
!
   private
19 20
!
! !PUBLIC DATA FUNCTIONS:
Knut's avatar
Knut committed
21 22
   public init_output_processing, do_output_processing
   public register_processed_variables, finalize_register_processed_variables
23
!
24
! !PUBLIC DATA MEMBERS:
Knut's avatar
Knut committed
25 26
!
! !PRIVATE DATA MEMBERS:
27 28
   REALTYPE, dimension(:,:),   allocatable, target :: u2d, v2d
   REALTYPE, dimension(:,:,:), allocatable, target :: u3d, v3d
Knut's avatar
Knut committed
29
   REALTYPE, dimension(:,:),   allocatable, target :: u2d_destag, v2d_destag
30
   REALTYPE, dimension(:,:,:), allocatable, target :: u3d_destag, v3d_destag
Knut's avatar
Knut committed
31 32 33 34 35

   logical         :: u2d_used, v2d_used
   logical         :: u3d_used, v3d_used
   logical, target :: u2d_now, v2d_now
   logical, target :: u3d_now, v3d_now
36 37 38 39
   logical, target:: u2d_destag_use, v2d_destag_use
   logical, target:: u3d_destag_use, v3d_destag_use
   integer, parameter :: rk = kind(_ONE_)
!
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Hans Burchard
!
!EOP
!-----------------------------------------------------------------------

   contains

!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: init_output_processing - read required variables
!
! !INTERFACE:
   subroutine init_output_processing
!
! !USES:
   IMPLICIT NONE
!
! !DESCRIPTION:
!
! !INPUT PARAMETERS:
!    character(len=*), intent(in)        :: filename
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding
!
! !LOCAL VARIABLES:
   integer                             :: rc
!EOP
!-------------------------------------------------------------------------
!BOC
Knut's avatar
Knut committed
72

73 74 75 76 77 78
   allocate(u2d_destag(E2DFIELD),stat=rc)
   if (rc /= 0) stop 'init_output_processing: Error allocating memory (u2d_destag)'
   u2d_destag = 0._rk
   allocate(v2d_destag(E2DFIELD),stat=rc)
   if (rc /= 0) stop 'init_output_processing: Error allocating memory (v2d_destag)'
   v2d_destag = 0._rk
79 80

#if 0
81 82 83 84
   allocate(u3d_destag(I3DFIELD),stat=rc)
   if (rc /= 0) stop 'init_output_processing: Error allocating memory (u3d_destag)'
   allocate(v3d_destag(I3DFIELD),stat=rc)
   if (rc /= 0) stop 'init_output_processing: Error allocating memory (v3d_destag)'
85 86 87 88 89 90 91
#endif
   return
   end subroutine init_output_processing
!EOC

!-----------------------------------------------------------------------
!BOP
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
!
! !ROUTINE: register_processed_variables()
!
! !INTERFACE:
   subroutine register_processed_variables(fm)
!
! !DESCRIPTION:
!
! !USES:
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
   type (type_field_manager) :: fm
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding & Jorn Bruggeman
!
! !LOCAL VARIABLES:
!EOP
!-----------------------------------------------------------------------
!BOC
   LEVEL2 'register_processed_variables()'

Knut's avatar
Knut committed
115 116 117 118 119 120 121 122 123
   call fm%register('u2d', 'm/s', 'velocity in local x-direction', standard_name='', fill_value=-9999._rk, category='velocities', output_level=output_level_debug, used=u2d_used, used_now=u2d_now)
   call fm%register('v2d', 'm/s', 'velocity in local y-direction', standard_name='', fill_value=-9999._rk, category='velocities', output_level=output_level_debug, used=v2d_used, used_now=v2d_now)

#ifndef NO_3D
   call fm%register('u3d', 'm/s', 'velocity in local x-direction (3D)', standard_name='', dimensions=(/id_dim_z/), fill_value=-9999._rk, category='velocities', output_level=output_level_debug, used=u3d_used, used_now=u3d_now)
   call fm%register('v3d', 'm/s', 'velocity in local y-direction (3D)', standard_name='', dimensions=(/id_dim_z/), fill_value=-9999._rk, category='velocities', output_level=output_level_debug, used=v3d_used, used_now=v3d_now)
#endif


124 125
   call fm%register('u2d-destag', 'm/s', 'velocity in local x-direction(destag)', standard_name='', data2d=u2d_destag(_2D_W_), fill_value=-9999._rk, category='velocities',output_level=output_level_debug, used_now=u2d_destag_use)
   call fm%register('v2d-destag', 'm/s', 'velocity in local y-direction(destag)', standard_name='', data2d=v2d_destag(_2D_W_), fill_value=-9999._rk, category='velocities',output_level=output_level_debug, used_now=v2d_destag_use)
126 127 128 129 130

   return
   end subroutine register_processed_variables
!EOC

Knut's avatar
Knut committed
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
!-----------------------------------------------------------------------
!BOP
!
! !ROUTINE: finalize_register_processed_variables() - send optional variables.
!
! !INTERFACE:
   subroutine finalize_register_processed_variables(fm)
!
! !DESCRIPTION:
!
! !USES:
   use field_manager
   IMPLICIT NONE
!
! !INPUT PARAMETERS:
   type (type_field_manager) :: fm
!
! !REVISION HISTORY:
!  Original author(s): Knut Klingbeil
!
! !LOCAL VARIABLES:
   integer                             :: rc
!EOP
!-----------------------------------------------------------------------
!BOC
   LEVEL1 'finalize_register_processed_variables()'

   if (u2d_used) then
      allocate(u2d(E2DFIELD),stat=rc)
      if (rc /= 0) stop 'finalize_register_processed_variables: Error allocating memory (u2d)'
      u2d = 0._rk
      call fm%send_data('u2d', u2d(_2D_W_))
   end if

   if (v2d_used) then
      allocate(v2d(E2DFIELD),stat=rc)
      if (rc /= 0) stop 'finalize_register_processed_variables: Error allocating memory (v2d)'
      v2d = 0._rk
      call fm%send_data('v2d', v2d(_2D_W_))
   end if

#ifndef NO_3D
   if (u3d_used) then
      allocate(u3d(I3DFIELD),stat=rc)
      if (rc /= 0) stop 'finalize_register_processed_variables: Error allocating memory (u3d)'
      u3d = 0._rk
      call fm%send_data('u3d', u3d(_3D_W_))
   end if

   if (v3d_used) then
      allocate(v3d(I3DFIELD),stat=rc)
      if (rc /= 0) stop 'finalize_register_processed_variables: Error allocating memory (v3d)'
      v3d = 0._rk
      call fm%send_data('v3d', v3d(_3D_W_))
   end if
#endif

   return
   end subroutine finalize_register_processed_variables
!EOC

192 193 194
!-----------------------------------------------------------------------
!BOP
! !IROUTINE: do_output_processing - read required variables
195 196 197 198 199
!
! !INTERFACE:
  subroutine do_output_processing
!
! !USES:
200
   use domain, only: az, au, av
201 202
   use variables_2d, only: z,D
   use variables_2d, only: U,V,DU,DV
Knut's avatar
Knut committed
203
#ifndef NO_3D
204
   use variables_3d, only: kmin,hn,uu,hun,vv,hvn
Knut's avatar
Knut committed
205
#endif
206 207 208 209 210 211 212 213 214 215 216 217 218 219
   IMPLICIT NONE
!
! !DESCRIPTION:
!
! !INPUT PARAMETERS:
!
! !REVISION HISTORY:
!  Original author(s): Karsten Bolding
!
! !LOCAL VARIABLES:
   REALTYPE, parameter                 :: vel_missing        =-9999.
!EOP
!-------------------------------------------------------------------------
!BOC
220 221

!  2D - velocities
Knut's avatar
Knut committed
222 223

   if (u2d_now) then
224
      call to_2d_vel(imin,jmin,imax,jmax,au,U,DU,vel_missing,       &
225
                     imin,jmin,imax,jmax,u2d)
Knut's avatar
Knut committed
226 227 228
   end if

   if (v2d_now) then
229
      call to_2d_vel(imin,jmin,imax,jmax,av,V,DV,vel_missing,       &
230
                     imin,jmin,imax,jmax,v2d)
231 232
   end if

233
!  3D - velocities
234
#ifndef NO_3D
Knut's avatar
Knut committed
235
   if (u3d_now) then
236
      call to_3d_uu(imin,jmin,imax,jmax,kmin,kmax,az, &
237
                    hun,uu,vel_missing,u3d)
Knut's avatar
Knut committed
238 239 240
   end if

   if (v3d_now) then
241
      call to_3d_vv (imin,jmin,imax,jmax,kmin,kmax,az, &
242
                     hvn,vv,vel_missing,v3d)
243
   end if
Knut's avatar
Knut committed
244 245 246 247 248 249 250 251 252
#endif


   if (u2d_destag_use .and. v2d_destag_use) then
      call to_2d_u(imin,jmin,imax,jmax,az,U,DU,vel_missing,      &
                   imin,jmin,imax,jmax,u2d_destag)
      call to_2d_v(imin,jmin,imax,jmax,az,V,DV,vel_missing,      &
                   imin,jmin,imax,jmax,v2d_destag)
   end if
253

Knut's avatar
Knut committed
254 255
#if 0
#ifndef NO_3D
256
   if (allocated(u3d_destag) .and. allocated(v3d_destag)) then
257
      call to_3d_vel(imin,jmin,imax,jmax,kmin,kmax,au, &
258
                     hun,uu,vel_missing,u3d_destag)
259
      call to_3d_vel(imin,jmin,imax,jmax,kmin,kmax,av, &
260
                     hvn,vv,vel_missing,v3d_destag)
261
   end if
262
#endif
263 264 265 266 267 268 269 270 271 272 273
#endif

   return
   end subroutine do_output_processing
!EOC

   end module output_processing

!-----------------------------------------------------------------------
! Copyright (C) 2019 - Karsten Bolding & Jorn Bruggeman (BB)           !
!-----------------------------------------------------------------------