SCALE-RM
mod_cnvuser.F90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
9 !-------------------------------------------------------------------------------
10 #include "scalelib.h"
12  !-----------------------------------------------------------------------------
13  !
14  !++ used modules
15  !
16  use scale_precision
17  use scale_io
18  use scale_prof
20  use scale_tracer
21  use scale_prc, only: &
22  prc_abort
23  !-----------------------------------------------------------------------------
24  implicit none
25  private
26 
27  !-----------------------------------------------------------------------------
28  !
29  !++ Public procedure
30  !
31  public :: cnvuser_setup
32  public :: cnvuser
33 
34  !-----------------------------------------------------------------------------
35  !
36  !++ Public parameters & variables
37  !
38  !-----------------------------------------------------------------------------
39  !
40  !++ Private procedure
41  !
42  private :: cnvuser_prepare_tile
43  private :: cnvuser_prepare_grads
44  private :: cnvuser_prepare_grads_3d
45  private :: cnvuser_execute_grads_3d
46  private :: cnvuser_execute_tile_grads
47  private :: cnvuser_write
48 
49  !-----------------------------------------------------------------------------
50  !
51  !++ Private parameters & variables
52  !
53  logical :: CNVUSER_OUT_AGGREGATE
54 
55  type, abstract :: t_param
56  character(len=H_SHORT) :: INTERP_TYPE
57  integer :: INTERP_LEVEL
58 
59  character(len=H_LONG) :: OUT_BASENAME ! basename of the output file
60  character(len=H_MID) :: OUT_TITLE ! title of the output file
61  character(len=H_SHORT) :: OUT_VARNAME ! name of the variable
62  character(len=H_MID) :: OUT_VARDESC ! title of the variable
63  character(len=H_SHORT) :: OUT_VARUNIT ! units of the variable
64  character(len=H_SHORT) :: OUT_DTYPE ! REAL4 or REAL8
65  real(DP) :: OUT_DT ! sec
66 
67  integer :: NSTEPS ! # of time steps
68  end type t_param
69 
70  ! TILE data
71  type, extends(t_param) :: t_tile
72  character(len=H_SHORT) :: TILE_DTYPE ! data type in the tiled data
73  real(RP) :: TILE_DLAT
74  real(RP) :: TILE_DLON
75  character(len=H_LONG) :: TILE_DIR
76  character(len=H_LONG) :: TILE_CATALOGUE
77  end type t_tile
78 
79  ! GrADS data
80  type, extends(t_param) :: t_grads
81  character(len=H_LONG) :: GrADS_FILENAME
82  character(len=H_SHORT) :: GrADS_VARNAME
83  character(len=H_SHORT) :: GrADS_LATNAME
84  character(len=H_SHORT) :: GrADS_LONNAME
85  end type t_grads
86 
87  ! GrADS-3D data
88  type, extends(t_param) :: t_grads_3d
89  character(len=H_LONG) :: GrADS_FILENAME
90  character(len=H_SHORT) :: GrADS_VARNAME
91  character(len=H_SHORT) :: GrADS_LATNAME
92  character(len=H_SHORT) :: GrADS_LONNAME
93  character(len=H_SHORT) :: GrADS_LEVNAME
94  character(len=H_SHORT) :: GrADS_HEIGHT_PLEV
95  end type t_grads_3d
96 
97  type t_param_wrapper
98  class(t_param), allocatable :: param
99  end type t_param_wrapper
100 
101  type(t_param_wrapper), allocatable :: params(:)
102 
103  !-----------------------------------------------------------------------------
104 contains
105  !-----------------------------------------------------------------------------
107 
108  subroutine cnvuser_setup
109  use scale_file, only: &
111 
112  character(len=H_SHORT) :: cnvuser_file_type
113  character(len=H_SHORT) :: cnvuser_interp_type
114  integer :: cnvuser_interp_level
115 
116  character(len=H_LONG) :: cnvuser_out_basename
117  character(len=H_MID) :: cnvuser_out_title
118  character(len=H_SHORT) :: cnvuser_out_varname
119  character(len=H_MID) :: cnvuser_out_vardesc
120  character(len=H_SHORT) :: cnvuser_out_varunit
121  character(len=H_SHORT) :: cnvuser_out_dtype
122  real(dp) :: cnvuser_out_dt
123 
124  integer :: cnvuser_nsteps
125 
126  ! TILE data
127  character(len=H_SHORT) :: cnvuser_tile_dtype
128  real(rp) :: cnvuser_tile_dlat
129  real(rp) :: cnvuser_tile_dlon
130  character(len=H_LONG) :: cnvuser_tile_dir
131  character(len=H_LONG) :: cnvuser_tile_catalogue
132 
133  ! GrADS data
134  character(len=H_LONG) :: cnvuser_grads_filename
135  character(len=H_SHORT) :: cnvuser_grads_varname
136  character(len=H_SHORT) :: cnvuser_grads_latname
137  character(len=H_SHORT) :: cnvuser_grads_lonname
138  character(len=H_SHORT) :: cnvuser_grads_levname
139  character(len=H_SHORT) :: cnvuser_grads_height_plev
140 
141  namelist / param_cnvuser / &
142  cnvuser_file_type, &
143  cnvuser_nsteps, &
144  cnvuser_interp_type, &
145  cnvuser_interp_level, &
146  cnvuser_tile_dtype, &
147  cnvuser_tile_dlat, &
148  cnvuser_tile_dlon, &
149  cnvuser_tile_dir, &
150  cnvuser_tile_catalogue, &
151  cnvuser_grads_filename, &
152  cnvuser_grads_varname, &
153  cnvuser_grads_latname, &
154  cnvuser_grads_lonname, &
155  cnvuser_grads_levname, &
156  cnvuser_grads_height_plev, &
157  cnvuser_out_basename, &
158  cnvuser_out_title, &
159  cnvuser_out_varname, &
160  cnvuser_out_vardesc, &
161  cnvuser_out_varunit, &
162  cnvuser_out_dtype, &
163  cnvuser_out_dt
164 
165  integer :: ierr, n_vars
166  !---------------------------------------------------------------------------
167 
168  log_newline
169  log_info("CNVUSER_setup",*) 'Setup'
170 
171  cnvuser_out_aggregate = file_aggregate
172 
173  !--- read namelist
174  rewind(io_fid_conf)
175  n_vars = 0
176  do
177  cnvuser_file_type = ''
178  read(io_fid_conf,nml=param_cnvuser,iostat=ierr)
179  if( ierr < 0 ) then !--- missing
180  exit
181  elseif( ierr > 0 ) then !--- fatal error
182  log_error("CNVUSER_setup",*) 'Not appropriate names in namelist PARAM_CNVUSER. Check!'
183  call prc_abort
184  endif
185  if (cnvuser_file_type == "") cycle
186  n_vars = n_vars + 1
187  end do
188 
189  allocate(params(n_vars))
190  rewind(io_fid_conf)
191  n_vars = 0
192  do
193  ! Default value
194  cnvuser_file_type = ''
195  cnvuser_interp_type = 'LINEAR'
196  cnvuser_interp_level = 5
197 
198  cnvuser_out_basename = ''
199  cnvuser_out_title = 'SCALE-RM User Boundary'
200  cnvuser_out_varname = ''
201  cnvuser_out_vardesc = ''
202  cnvuser_out_varunit = ''
203  cnvuser_out_dtype = 'DEFAULT'
204  cnvuser_out_dt = -1_dp
205 
206  cnvuser_nsteps = 1
207 
208 
209  cnvuser_tile_dtype = 'real4'
210  cnvuser_tile_dlat = -1
211  cnvuser_tile_dlon = -1
212  cnvuser_tile_dir = ''
213  cnvuser_tile_catalogue = ''
214 
215 
216  cnvuser_grads_filename = ''
217  cnvuser_grads_varname = ''
218  cnvuser_grads_latname = 'lat'
219  cnvuser_grads_lonname = 'lon'
220  cnvuser_grads_levname = ''
221  cnvuser_grads_height_plev = 'HGT'
222 
223  read(io_fid_conf,nml=param_cnvuser,iostat=ierr)
224  if( ierr /= 0 ) exit
225  log_nml(param_cnvuser)
226  if (cnvuser_file_type == "") cycle
227 
228  n_vars = n_vars + 1
229 
230  select case (cnvuser_file_type)
231  case ("TILE")
232  allocate(t_tile::params(n_vars)%param)
233  case ("GrADS")
234  allocate(t_grads::params(n_vars)%param)
235  case ("GrADS-3D")
236  allocate(t_grads_3d::params(n_vars)%param)
237  case default
238  log_error('CNVUSER_setup',*) 'CNVUSER_FILE_TYPE is invalid: ', cnvuser_file_type
239  log_error_cont(*) 'It must be "TILE" or "GrADS".'
240  call prc_abort
241  end select
242 
243  associate(param => params(n_vars)%param)
244  param%INTERP_TYPE = cnvuser_interp_type
245  param%INTERP_LEVEL = cnvuser_interp_level
246  param%OUT_BASENAME = cnvuser_out_basename
247  param%OUT_TITLE = cnvuser_out_title
248  param%OUT_VARNAME = cnvuser_out_varname
249  param%OUT_VARDESC = cnvuser_out_vardesc
250  param%OUT_VARUNIT = cnvuser_out_varunit
251  param%OUT_DTYPE = cnvuser_out_dtype
252  param%OUT_DT = cnvuser_out_dt
253  param%NSTEPS = cnvuser_nsteps
254  end associate
255 
256  select type (param => params(n_vars)%param)
257  type is (t_tile)
258  param%TILE_DTYPE = cnvuser_tile_dtype
259  param%TILE_DLAT = cnvuser_tile_dlat
260  param%TILE_DLON = cnvuser_tile_dlon
261  param%TILE_DIR = cnvuser_tile_dir
262  param%TILE_CATALOGUE = cnvuser_tile_catalogue
263  type is (t_grads)
264  param%GrADS_FILENAME = cnvuser_grads_filename
265  param%GrADS_VARNAME = cnvuser_grads_varname
266  param%GrADS_LATNAME = cnvuser_grads_latname
267  param%GrADS_LONNAME = cnvuser_grads_lonname
268  if ( param%OUT_VARNAME == '' ) param%OUT_VARNAME = param%GrADS_VARNAME
269  type is (t_grads_3d)
270  param%GrADS_FILENAME = cnvuser_grads_filename
271  param%GrADS_VARNAME = cnvuser_grads_varname
272  param%GrADS_LATNAME = cnvuser_grads_latname
273  param%GrADS_LONNAME = cnvuser_grads_lonname
274  param%GrADS_LEVNAME = cnvuser_grads_levname
275  param%GrADS_HEIGHT_PLEV = cnvuser_grads_height_plev
276  if ( param%OUT_VARNAME == '' ) param%OUT_VARNAME = param%GrADS_VARNAME
277  end select
278  end do
279 
280  end subroutine cnvuser_setup
281 
282  !-----------------------------------------------------------------------------
284  subroutine cnvuser
285  integer :: i
286  !---------------------------------------------------------------------------
287 
288  do i = 1, size(params)
289  associate(param => params(i)%param)
290  if ( param%OUT_BASENAME == '' .or. param%OUT_VARNAME == '' ) then
291  log_error('CNVUSER',*) 'CNVUSER_OUT_BASENAME and CNVUSER_OUT_VARNAME are required'
292  call prc_abort
293  end if
294 
295  select type (param)
296  type is (t_tile)
297  call cnvuser_prepare_tile(param)
298  call cnvuser_execute_tile_grads(param)
299  type is (t_grads)
300  call cnvuser_prepare_grads(param)
301  call cnvuser_execute_tile_grads(param)
302  type is (t_grads_3d)
303  call cnvuser_prepare_grads_3d(param)
304  call cnvuser_execute_grads_3d(param)
305  end select
306 
307  end associate
308  end do
309 
310  end subroutine cnvuser
311 
312  ! private
313 
314  subroutine cnvuser_prepare_tile(tile)
315  use mod_cnv2d, only: &
317  type(t_tile), intent(in) :: tile
318 
319  call cnv2d_tile_init( tile%TILE_DTYPE, &
320  tile%TILE_DLAT, tile%TILE_DLON, &
321  tile%TILE_DIR, &
322  tile%TILE_CATALOGUE, &
323  tile%INTERP_TYPE, &
324  interp_level = tile%INTERP_LEVEL )
325  end subroutine cnvuser_prepare_tile
326 
327  subroutine cnvuser_prepare_grads(grads)
328  use mod_cnv2d, only: &
330  type(t_grads), intent(inout) :: grads
331 
332  call cnv2d_grads_init( grads%GrADS_FILENAME, &
333  grads%GrADS_VARNAME, &
334  grads%GrADS_LATNAME, &
335  grads%GrADS_LONNAME, &
336  grads%INTERP_TYPE, &
337  grads%INTERP_LEVEL )
338  end subroutine cnvuser_prepare_grads
339 
340  subroutine cnvuser_prepare_grads_3d(grads_3d)
341  type(t_grads_3d), intent(inout) :: grads_3d
342 
343  end subroutine cnvuser_prepare_grads_3d
344 
345  subroutine cnvuser_execute_grads_3d(grads_3d)
346  use scale_const, only: &
347  pi => const_pi, &
348  d2r => const_d2r
349  use scale_file_cartesc, only: &
352  file_cartesc_write_var, &
355  use scale_file_grads, only: &
356  file_grads_open, &
357  file_grads_get_shape, &
360  file_grads_read
361  use scale_time, only: &
363  use scale_atmos_grid_cartesc, only: &
364  cx => atmos_grid_cartesc_cx, &
366  use scale_atmos_grid_cartesc_real, only: &
370  use scale_interp, only: &
374  use scale_mapprojection, only: &
375  mapprojection_lonlat2xy
376 
377  type(t_grads_3d), intent(inout) :: grads_3d
378 
379  integer :: i, j, k, step
380  integer :: file_id, var_id
381  integer :: data_shape(3)
382  integer :: fid, vid
383  real(dp) :: timeofs
384  real(rp) :: var_3d(ka,ia,ja,1)
385 
386  ! interpolation
387  integer :: nlev, nlon, nlat
388  logical :: zonal, pole
389 
390  integer, allocatable :: idx_i (:,:,:)
391  integer, allocatable :: idx_j (:,:,:)
392  real(rp), allocatable :: hfact (:,:,:)
393  integer, allocatable :: idx_k (:,:,:,:,:)
394  real(rp), allocatable :: vfact (:,:,:,:)
395  real(rp), allocatable :: data_org (:,:,:)
396  real(rp), allocatable :: x_org (:,:)
397  real(rp), allocatable :: y_org (:,:)
398  real(rp), allocatable :: lat_org (:,:)
399  real(rp), allocatable :: lon_org (:,:)
400  real(rp), allocatable :: lev_org (:,:,:)
401  real(rp), allocatable :: lat_1d (:)
402  real(rp), allocatable :: lon_1d (:)
403  real(rp), allocatable :: lev_1d (:)
404 
405  call file_grads_open( grads_3d%GrADS_FILENAME, & ! [IN]
406  file_id ) ! [OUT]
407 
408  call file_grads_get_shape( file_id, & ! [IN]
409  grads_3d%GrADS_VARNAME, & ! [IN]
410  data_shape(:) ) ! [OUT]
411  nlev = data_shape(1)
412  nlon = data_shape(2)
413  nlat = data_shape(3)
414 
415  ! interporation
416  select case ( trim(grads_3d%INTERP_TYPE) )
417  case ( 'LINEAR' )
418  grads_3d%INTERP_LEVEL = 4
419  case ( 'DIST-WEIGHT' )
420  ! do nothing
421  end select
422 
423  allocate( idx_i( ia,ja,grads_3d%INTERP_LEVEL) )
424  allocate( idx_j( ia,ja,grads_3d%INTERP_LEVEL) )
425  allocate( hfact( ia,ja,grads_3d%INTERP_LEVEL) )
426  allocate( idx_k(ka,2,ia,ja,grads_3d%INTERP_LEVEL) )
427  allocate( vfact(ka, ia,ja,grads_3d%INTERP_LEVEL) )
428 
429  allocate( data_org( nlev, nlon, nlat ) )
430  allocate( x_org( nlon, nlat ) )
431  allocate( y_org( nlon, nlat ) )
432  allocate( lat_org( nlon, nlat ) )
433  allocate( lon_org( nlon, nlat ) )
434  allocate( lev_org( nlev, nlon, nlat ) )
435  allocate( lat_1d( nlat ) )
436  allocate( lon_1d( nlon ) )
437  allocate( lev_1d( nlev ) )
438 
439  ! lat
440  call file_grads_varid( file_id, & ! [IN]
441  grads_3d%GrADS_LATNAME, & ! [IN]
442  var_id ) ! [OUT]
443 
444  if ( file_grads_isoned( file_id, var_id ) ) then
445  call file_grads_read( file_id, & ! [IN]
446  var_id, & ! [IN]
447  lat_1d(:) ) ! [OUT]
448 
449  !$omp parallel do
450  do j = 1, nlat
451  do i = 1, nlon
452  lat_org(i,j) = lat_1d(j) * d2r
453  end do
454  end do
455  else
456  call file_grads_read( file_id, & ! [IN]
457  var_id, & ! [IN]
458  lat_org(:,:) ) ! [OUT]
459 
460  !$omp parallel do
461  do j = 1, nlat
462  do i = 1, nlon
463  lat_org(i,j) = lat_org(i,j) * d2r
464  end do
465  end do
466  end if
467 
468  ! lon
469  call file_grads_varid( file_id, & ! [IN]
470  grads_3d%GrADS_LONNAME, & ! [IN]
471  var_id ) ! [OUT]
472 
473  if ( file_grads_isoned( file_id, var_id ) ) then
474  call file_grads_read( file_id, & ! [IN]
475  var_id, & ! [IN]
476  lon_1d(:) ) ! [OUT]
477 
478  !$omp parallel do
479  do j = 1, nlat
480  do i = 1, nlon
481  lon_org(i,j) = lon_1d(i) * d2r
482  end do
483  end do
484  else
485  call file_grads_read( file_id, & ! [IN]
486  var_id, & ! [IN]
487  lon_org(:,:) ) ! [OUT]
488 
489  !$omp parallel do
490  do j = 1, nlat
491  do i = 1, nlon
492  lon_org(i,j) = lon_org(i,j) * d2r
493  end do
494  end do
495  end if
496 
497  ! lev
498  select case ( trim(grads_3d%GrADS_LEVNAME) )
499  case ( 'zlev' )
500  call file_grads_varid( file_id, & ! [IN]
501  grads_3d%GrADS_LEVNAME, & ! [IN]
502  var_id ) ! [OUT]
503 
504  call file_grads_read( file_id, & ! [IN]
505  var_id, & ! [IN]
506  lev_1d(:) ) ! [OUT]
507 
508  !$omp parallel do collapse(2)
509  do j = 1, nlat
510  do i = 1, nlon
511  do k = 1, nlev
512  lev_org(k,i,j) = lev_1d(k)
513  end do
514  end do
515  end do
516  case ( 'plev' )
517  call file_grads_varid( file_id, & ! [IN]
518  grads_3d%GrADS_HEIGHT_PLEV, & ! [IN]
519  var_id ) ! [OUT]
520 
521  call file_grads_read( file_id, & ! [IN]
522  var_id, & ! [IN]
523  lev_org(:,:,:) ) ! [OUT]
524  case default
525  log_error("CNVUSER_execute_GrADS_3D",*) 'Invalid property in grads_3d%GrADS_LEVNAME: ', trim(grads_3d%GrADS_LEVNAME), ' for ', trim(grads_3d%GrADS_VARNAME)
526  call prc_abort
527  end select
528 
529  ! prepare to read target data
530  call file_grads_varid( file_id, & ! [IN]
531  grads_3d%GrADS_VARNAME, & ! [IN]
532  var_id ) ! [OUT]
533 
534  select case ( grads_3d%INTERP_TYPE )
535  case ( 'LINEAR' )
536  call mapprojection_lonlat2xy( nlon, 1, nlon, & ! [IN]
537  nlat, 1, nlat, & ! [IN]
538  lon_org(:,:), & ! [IN]
539  lat_org(:,:), & ! [IN]
540  x_org(:,:), & ! [OUT]
541  y_org(:,:) ) ! [OUT]
542 
543  zonal = ( maxval(lon_org(:,:)) - minval(lat_org(:,:)) ) > 2.0_rp * pi * 0.9_rp
544  pole = ( maxval(lat_org(:,:)) > pi * 0.5_rp * 0.9_rp ) .or. ( minval(lat_org(:,:)) < - pi * 0.5_rp * 0.9_rp )
545 
546  call interp_factor3d_linear_xy( nlev, 1, nlev, & ! [IN]
547  nlon, nlat, & ! [IN]
548  ka, 1, ka, & ! [IN]
549  ia, ja, & ! [IN]
550  x_org(:,:), & ! [IN]
551  y_org(:,:), & ! [IN]
552  lev_org(:,:,:), & ! [IN]
553  cx(:), & ! [IN]
554  cy(:), & ! [IN]
555  cz(:,:,:), & ! [IN]
556  idx_i(:,:,:), & ! [OUT]
557  idx_j(:,:,:), & ! [OUT]
558  hfact(:,:,:), & ! [OUT]
559  idx_k(:,:,:,:,:), & ! [OUT]
560  vfact(:,:,:,:), & ! [OUT]
561  zonal = zonal, & ! [IN]
562  pole = pole, & ! [IN]
563  missing = .true. ) ! [IN]
564  case ( 'DIST-WEIGHT' )
565  call interp_factor3d_weight( grads_3d%INTERP_LEVEL, & ! [IN]
566  nlev, 1, nlev, & ! [IN]
567  nlon, nlat, & ! [IN]
568  ka, 1, ka, & ! [IN]
569  ia, ja, & ! [IN]
570  lon_org(:,:), & ! [IN]
571  lat_org(:,:), & ! [IN]
572  lev_org(:,:,:), & ! [IN]
573  lon(:,:), & ! [IN]
574  lat(:,:), & ! [IN]
575  cz(:,:,:), & ! [IN]
576  idx_i(:,:,:), & ! [OUT]
577  idx_j(:,:,:), & ! [OUT]
578  hfact(:,:,:), & ! [OUT]
579  idx_k(:,:,:,:,:), & ! [OUT]
580  vfact(:,:,:,:) ) ! [OUT]
581  end select
582 
583  call file_cartesc_create( grads_3d%OUT_BASENAME, & ! [IN]
584  grads_3d%OUT_TITLE, & ! [IN]
585  grads_3d%OUT_DTYPE, & ! [IN]
586  fid, & ! [OUT]
587  date = time_nowdate, & ! [IN]
588  haszcoord = .true., & ! [IN]
589  aggregate = cnvuser_out_aggregate ) ! [IN]
590 
591  call file_cartesc_def_var( fid, & ! [IN]
592  grads_3d%OUT_VARNAME, & ! [IN]
593  grads_3d%OUT_VARDESC, & ! [IN]
594  grads_3d%OUT_VARUNIT, & ! [IN]
595  'ZXYT', & ! [IN]
596  grads_3d%OUT_DTYPE, & ! [IN]
597  vid, & ! [OUT]
598  timeintv = grads_3d%OUT_DT, & ! [IN]
599  nsteps = grads_3d%NSTEPS ) ! [IN]
600 
601  call file_cartesc_enddef(fid)
602 
603  call file_grads_open( grads_3d%GrADS_FILENAME, & ! [IN]
604  file_id ) ! [OUT]
605 
606  call file_grads_varid( file_id, & ! [IN]
607  grads_3d%GrADS_VARNAME, & ! [IN]
608  var_id ) ! [OUT]
609 
610  do step = 1, grads_3d%NSTEPS
611  log_progress(*) 'step = ', step
612  timeofs = ( step - 1 ) * grads_3d%OUT_DT
613 
614  call file_grads_read( file_id, var_id, & ! [IN]
615  data_org(:,:,:), & ! [OUT]
616  step = step ) ! [IN]
617 
618  call interp_interp3d( grads_3d%INTERP_LEVEL, & ! [IN]
619  nlev, 1, nlev, & ! [IN]
620  nlon, nlat, & ! [IN]
621  ka, 1, ka, & ! [IN]
622  ia, ja, & ! [IN]
623  idx_i(:,:,:), & ! [IN]
624  idx_j(:,:,:), & ! [IN]
625  hfact(:,:,:), & ! [IN]
626  idx_k(:,:,:,:,:), & ! [IN]
627  vfact(:,:,:,:), & ! [IN]
628  lev_org(:,:,:), & ! [IN]
629  cz(:,:,:), & ! [IN]
630  data_org(:,:,:), & ! [IN]
631  var_3d(:,:,:,1) ) ! [OUT]
632 
633  call file_cartesc_write_var( fid, vid, & ! [IN]
634  var_3d(:,:,:,: ), & ! [IN]
635  grads_3d%OUT_VARNAME, & ! [IN]
636  'ZXYT', & ! [IN]
637  grads_3d%OUT_DT, & ! [IN]
638  timetarg = 1, & ! [IN]
639  timeofs = timeofs ) ! [IN]
640  end do
641 
642  call file_cartesc_close( fid )
643 
644  deallocate( idx_i )
645  deallocate( idx_j )
646  deallocate( hfact )
647  deallocate( idx_k )
648  deallocate( vfact )
649 
650  deallocate( data_org )
651  deallocate( x_org )
652  deallocate( y_org )
653  deallocate( lat_org )
654  deallocate( lon_org )
655  deallocate( lev_org )
656  deallocate( lat_1d )
657  deallocate( lon_1d )
658  deallocate( lev_1d )
659  end subroutine cnvuser_execute_grads_3d
660 
661  subroutine cnvuser_execute_tile_grads(param)
662 
663  use scale_file_cartesc, only: &
668  use scale_time, only: &
670  use mod_cnv2d, only: &
671  cnv2d_exec
672 
673  class(t_param), intent(in) :: param
674 
675  real(rp) :: var(ia, ja)
676 
677  integer :: fid, vid
678  integer :: step
679 
680  call file_cartesc_create( param%OUT_BASENAME, & ! [IN]
681  param%OUT_TITLE, & ! [IN]
682  param%OUT_DTYPE, & ! [IN]
683  fid, & ! [OUT]
684  date = time_nowdate, & ! [IN]
685  haszcoord = .false., & ! [IN]
686  aggregate = cnvuser_out_aggregate ) ! [IN]
687 
688  call file_cartesc_def_var( fid, & ! [IN]
689  param%OUT_VARNAME, & ! [IN]
690  param%OUT_VARDESC, & ! [IN]
691  param%OUT_VARUNIT, & ! [IN]
692  'XYT', & ! [IN]
693  param%OUT_DTYPE, & ! [IN]
694  vid, & ! [OUT]
695  timeintv = param%OUT_DT, & ! [IN]
696  nsteps = param%NSTEPS ) ! [IN]
697 
698  call file_cartesc_enddef(fid)
699 
700  do step = 1, param%NSTEPS
701  log_progress(*) 'step = ', step
702 
703  call cnv2d_exec( var(:,:), step = step )
704 
705  call cnvuser_write( param%OUT_VARNAME, fid, vid, var(:,:), param%OUT_DT, step )
706 
707  end do
708 
709  call file_cartesc_close( fid )
710  end subroutine cnvuser_execute_tile_grads
711 
712  subroutine cnvuser_write( &
713  CNVUSER_OUT_VARNAME, &
714  fid, vid, &
715  VAR, &
716  timeintv, &
717  istep )
718  use scale_file_cartesc, only: &
719  file_cartesc_write_var
720 
721  character(len=H_SHORT), intent(in) :: cnvuser_out_varname
722  integer, intent(in) :: fid, vid
723  real(rp), intent(in) :: var(ia,ja,1)
724  real(dp), intent(in) :: timeintv
725  integer, intent(in) :: istep
726 
727  real(dp) :: timeofs
728  !---------------------------------------------------------------------------
729 
730  timeofs = ( istep - 1 ) * timeintv
731  call file_cartesc_write_var( fid, vid, & ! [IN]
732  var(:,:,:), & ! [IN]
733  cnvuser_out_varname, & ! [IN]
734  'XYT', & ! [IN]
735  timeintv, & ! [IN]
736  timetarg = 1, & ! [IN]
737  timeofs = timeofs ) ! [IN]
738 
739  return
740  end subroutine cnvuser_write
741 
742 end module mod_cnvuser
mod_cnv2d::cnv2d_grads_init
subroutine, public cnv2d_grads_init(FILE_NAME, VAR_NAME, LAT_NAME, LON_NAME, interp_type, interp_level, search_limit, POSTFIX)
Definition: mod_cnv2d.F90:228
mod_cnv2d
module Convert 2D data
Definition: mod_cnv2d.F90:11
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_file_grads::file_grads_isoned
logical function, public file_grads_isoned(file_id, var_id)
Definition: scale_file_grads.F90:373
scale_file_grads::file_grads_open
subroutine, public file_grads_open(file_name, file_id)
Open.
Definition: scale_file_grads.F90:104
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_cz
real(rp), dimension(:,:,:), allocatable, public atmos_grid_cartesc_real_cz
geopotential height [m] (zxy)
Definition: scale_atmos_grid_cartesC_real.F90:39
scale_file_cartesc::file_cartesc_enddef
subroutine, public file_cartesc_enddef(fid)
Exit netCDF file define mode.
Definition: scale_file_cartesC.F90:964
scale_file_cartesc::file_cartesc_def_var
subroutine, public file_cartesc_def_var(fid, varname, desc, unit, dim_type, datatype, vid, standard_name, timeintv, nsteps, cell_measures)
Define a variable to file.
Definition: scale_file_cartesC.F90:3360
scale_precision
module PRECISION
Definition: scale_precision.F90:14
scale_interp::interp_factor3d_linear_xy
subroutine, public interp_factor3d_linear_xy(KA_ref, KS_ref, KE_ref, IA_ref, JA_ref, KA, KS, KE, IA, JA, x_ref, y_ref, hgt_ref, x, y, hgt, idx_i, idx_j, hfact, idx_k, vfact, flag_extrap, zonal, pole, missing)
Definition: scale_interp.F90:1047
scale_interp
module INTERPOLATION
Definition: scale_interp.F90:12
scale_file_grads::file_grads_varid
subroutine, public file_grads_varid(file_id, var_name, var_id)
Definition: scale_file_grads.F90:312
scale_atmos_grid_cartesc_real
module Atmosphere GRID CartesC Real(real space)
Definition: scale_atmos_grid_cartesC_real.F90:11
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_lon
real(rp), dimension(:,:), allocatable, public atmos_grid_cartesc_real_lon
longitude [rad,0-2pi]
Definition: scale_atmos_grid_cartesC_real.F90:49
scale_file
module file
Definition: scale_file.F90:15
mod_cnvuser::cnvuser_setup
subroutine, public cnvuser_setup
Setup.
Definition: mod_cnvuser.F90:109
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_precision::rp
integer, parameter, public rp
Definition: scale_precision.F90:41
scale_mapprojection
module Map projection
Definition: scale_mapprojection.F90:12
scale_io
module STDIO
Definition: scale_io.F90:10
mod_cnvuser
module Convert 2D user data
Definition: mod_cnvuser.F90:11
mod_cnvuser::cnvuser
subroutine, public cnvuser
Driver.
Definition: mod_cnvuser.F90:285
scale_atmos_grid_cartesc_index
module atmosphere / grid / cartesC index
Definition: scale_atmos_grid_cartesC_index.F90:12
scale_const
module CONSTANT
Definition: scale_const.F90:11
scale_file_cartesc::file_cartesc_close
subroutine, public file_cartesc_close(fid)
Close a netCDF file.
Definition: scale_file_cartesC.F90:1044
scale_prof
module profiler
Definition: scale_prof.F90:11
scale_file_grads
module file_grads
Definition: scale_file_grads.F90:11
scale_precision::dp
integer, parameter, public dp
Definition: scale_precision.F90:32
scale_time
module TIME
Definition: scale_time.F90:11
mod_cnv2d::cnv2d_exec
subroutine, public cnv2d_exec(var, step, min_value, yrevers)
Definition: mod_cnv2d.F90:334
scale_interp::interp_interp3d
subroutine, public interp_interp3d(npoints, KA_ref, KS_ref, KE_ref, IA_ref, JA_ref, KA, KS, KE, IA, JA, idx_i, idx_j, hfact, idx_k, vfact, hgt_ref, hgt, val_ref, val, spline, logwgt, threshold_undef, wsum, val2)
Definition: scale_interp.F90:1469
scale_const::const_pi
real(rp), parameter, public const_pi
pi
Definition: scale_const.F90:32
scale_tracer
module TRACER
Definition: scale_tracer.F90:12
scale_file::file_aggregate
logical, public file_aggregate
Definition: scale_file.F90:196
scale_file_cartesc::file_cartesc_create
subroutine, public file_cartesc_create(basename, title, datatype, fid, date, subsec, haszcoord, append, aggregate, single)
Create/open a netCDF file.
Definition: scale_file_cartesC.F90:796
mod_cnv2d::cnv2d_tile_init
subroutine, public cnv2d_tile_init(dtype, dlat, dlon, dir, catalogue, interp_type, interp_level, nmax)
Definition: mod_cnv2d.F90:124
scale_time::time_nowdate
integer, dimension(6), public time_nowdate
current time [YYYY MM DD HH MM SS]
Definition: scale_time.F90:68
scale_atmos_grid_cartesc::atmos_grid_cartesc_cy
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cy
center coordinate [m]: y, local
Definition: scale_atmos_grid_cartesC.F90:57
scale_interp::interp_factor3d_weight
subroutine, public interp_factor3d_weight(npoints, KA_ref, KS_ref, KE_ref, IA_ref, JA_ref, KA, KS, KE, IA, JA, lon_ref, lat_ref, hgt_ref, lon, lat, hgt, idx_i, idx_j, hfact, idx_k, vfact, flag_extrap)
Definition: scale_interp.F90:1135
scale_const::const_d2r
real(rp), public const_d2r
degree to radian
Definition: scale_const.F90:33
scale_atmos_grid_cartesc_real::atmos_grid_cartesc_real_lat
real(rp), dimension(:,:), allocatable, public atmos_grid_cartesc_real_lat
latitude [rad,-pi,pi]
Definition: scale_atmos_grid_cartesC_real.F90:53
scale_atmos_grid_cartesc
module atmosphere / grid / cartesC
Definition: scale_atmos_grid_cartesC.F90:12
scale_io::io_fid_conf
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:57
scale_file_cartesc
module file / cartesianC
Definition: scale_file_cartesC.F90:11
scale_atmos_grid_cartesc::atmos_grid_cartesc_cx
real(rp), dimension(:), allocatable, public atmos_grid_cartesc_cx
center coordinate [m]: x, local
Definition: scale_atmos_grid_cartesC.F90:56