SCALE-RM
mod_land_vars.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
10 !-------------------------------------------------------------------------------
12  !-----------------------------------------------------------------------------
13  !
14  !++ used modules
15  !
16  use scale_precision
17  use scale_stdio
18  use scale_prof
19  use scale_debug
22 
23  use scale_const, only: &
24  i_sw => const_i_sw, &
25  i_lw => const_i_lw
26  !-----------------------------------------------------------------------------
27  implicit none
28  private
29  !-----------------------------------------------------------------------------
30  !
31  !++ Public procedure
32  !
33  public :: land_vars_setup
34  public :: land_vars_restart_read
35  public :: land_vars_restart_write
36  public :: land_vars_history
37  public :: land_vars_total
38  public :: land_vars_external_in
39 
40  public :: land_vars_restart_create
41  public :: land_vars_restart_open
43  public :: land_vars_restart_enddef
44  public :: land_vars_restart_close
45 
46  public :: convert_ws2vwc
47 
48  !-----------------------------------------------------------------------------
49  !
50  !++ Public parameters & variables
51  !
52  logical, public :: land_restart_output = .false.
53 
54  character(len=H_LONG), public :: land_restart_in_basename = ''
55  logical, public :: land_restart_in_postfix_timelabel = .false.
56  character(len=H_LONG), public :: land_restart_out_basename = ''
57  logical, public :: land_restart_out_postfix_timelabel = .true.
58  character(len=H_MID), public :: land_restart_out_title = 'LAND restart'
59  character(len=H_SHORT), public :: land_restart_out_dtype = 'DEFAULT'
60 
61  ! prognostic variables
62  real(RP), public, allocatable :: land_temp (:,:,:)
63  real(RP), public, allocatable :: land_water (:,:,:)
64  real(RP), public, allocatable :: land_sfc_temp (:,:)
65  real(RP), public, allocatable :: land_sfc_albedo(:,:,:)
66 
67  ! tendency variables
68  real(RP), public, allocatable :: land_temp_t (:,:,:)
69  real(RP), public, allocatable :: land_water_t (:,:,:)
70  real(RP), public, allocatable :: land_sfc_temp_t (:,:)
71  real(RP), public, allocatable :: land_sfc_albedo_t(:,:,:)
72 
73  ! surface variables for restart
74  real(RP), public, allocatable :: land_sflx_mw (:,:)
75  real(RP), public, allocatable :: land_sflx_mu (:,:)
76  real(RP), public, allocatable :: land_sflx_mv (:,:)
77  real(RP), public, allocatable :: land_sflx_sh (:,:)
78  real(RP), public, allocatable :: land_sflx_lh (:,:)
79  real(RP), public, allocatable :: land_sflx_gh (:,:)
80  real(RP), public, allocatable :: land_sflx_evap(:,:)
81 
82  ! diagnostic variables
83  real(RP), public, allocatable :: land_u10(:,:)
84  real(RP), public, allocatable :: land_v10(:,:)
85  real(RP), public, allocatable :: land_t2 (:,:)
86  real(RP), public, allocatable :: land_q2 (:,:)
87 
88  ! recieved atmospheric variables
89  real(RP), public, allocatable :: atmos_temp (:,:)
90  real(RP), public, allocatable :: atmos_pres (:,:)
91  real(RP), public, allocatable :: atmos_w (:,:)
92  real(RP), public, allocatable :: atmos_u (:,:)
93  real(RP), public, allocatable :: atmos_v (:,:)
94  real(RP), public, allocatable :: atmos_dens (:,:)
95  real(RP), public, allocatable :: atmos_qv (:,:)
96  real(RP), public, allocatable :: atmos_pbl (:,:)
97  real(RP), public, allocatable :: atmos_sfc_pres (:,:)
98  real(RP), public, allocatable :: atmos_sflx_lw (:,:)
99  real(RP), public, allocatable :: atmos_sflx_sw (:,:)
100  real(RP), public, allocatable :: atmos_cossza (:,:)
101  real(RP), public, allocatable :: atmos_sflx_prec(:,:)
102 
103  real(RP), public, allocatable :: land_property (:,:,:)
104 
105  character(len=H_LONG), public :: land_property_in_filename = ''
106 
107  integer, public, parameter :: land_property_nmax = 8
108  integer, public, parameter :: i_waterlimit = 1 ! maximum soil moisture [m3/m3]
109  integer, public, parameter :: i_watercritical = 2 ! critical soil moisture [m3/m3]
110  integer, public, parameter :: i_thermalcond = 3 ! thermal conductivity for soil [W/K/m]
111  integer, public, parameter :: i_heatcapacity = 4 ! heat capacity for soil [J/K/m3]
112  integer, public, parameter :: i_waterdiff = 5 ! moisture diffusivity in the soil [m2/s]
113  integer, public, parameter :: i_z0m = 6 ! roughness length for momemtum [m]
114  integer, public, parameter :: i_z0h = 7 ! roughness length for heat [m]
115  integer, public, parameter :: i_z0e = 8 ! roughness length for vapor [m]
116 
117  !-----------------------------------------------------------------------------
118  !
119  !++ Private procedure
120  !
121  private :: land_param_read
122 
123  !-----------------------------------------------------------------------------
124  !
125  !++ Private parameters & variables
126  !
127  logical, private :: land_vars_checkrange = .false.
128 
129  integer, private, parameter :: vmax = 13
130  integer, private, parameter :: i_temp = 1
131  integer, private, parameter :: i_water = 2
132  integer, private, parameter :: i_waterds = 3
133  integer, private, parameter :: i_sfc_temp = 4
134  integer, private, parameter :: i_alb_lw = 5
135  integer, private, parameter :: i_alb_sw = 6
136  integer, private, parameter :: i_sflx_mw = 7
137  integer, private, parameter :: i_sflx_mu = 8
138  integer, private, parameter :: i_sflx_mv = 9
139  integer, private, parameter :: i_sflx_sh = 10
140  integer, private, parameter :: i_sflx_lh = 11
141  integer, private, parameter :: i_sflx_gh = 12
142  integer, private, parameter :: i_sflx_evap = 13
143 
144  character(len=H_SHORT), private :: var_name(vmax)
145  character(len=H_MID), private :: var_desc(vmax)
146  character(len=H_SHORT), private :: var_unit(vmax)
147  integer, private :: var_id(vmax)
148  integer, private :: restart_fid = -1 ! file ID
149 
150  data var_name / 'LAND_TEMP', &
151  'LAND_WATER', &
152  'LAND_DSAT', &
153  'LAND_SFC_TEMP', &
154  'LAND_ALB_LW', &
155  'LAND_ALB_SW', &
156  'LAND_SFLX_MW', &
157  'LAND_SFLX_MU', &
158  'LAND_SFLX_MV', &
159  'LAND_SFLX_SH', &
160  'LAND_SFLX_LH', &
161  'LAND_SFLX_GH', &
162  'LAND_SFLX_evap' /
163  data var_desc / 'temperature at each soil layer', &
164  'moisture at each soil layer', &
165  'degree of saturation at each soil layer', &
166  'land surface skin temperature', &
167  'land surface albedo (longwave)', &
168  'land surface albedo (shortwave)', &
169  'land surface w-momentum flux', &
170  'land surface u-momentum flux', &
171  'land surface v-momentum flux', &
172  'land surface sensible heat flux', &
173  'land surface latent heat flux', &
174  'land surface ground heat flux', &
175  'land surface water vapor flux' /
176  data var_unit / 'K', &
177  'm3/m3', &
178  '1', &
179  'K', &
180  '1', &
181  '1', &
182  'kg/m2/s', &
183  'kg/m2/s', &
184  'kg/m2/s', &
185  'J/m2/s', &
186  'J/m2/s', &
187  'J/m2/s', &
188  'kg/m2/s' /
189 
190  real(RP), private, allocatable :: land_property_table(:,:)
191 
192  integer, private :: land_qa_comm
193  real(RP), private, allocatable :: work_comm(:,:,:) ! for communication
194 
195  logical, private :: land_restart_in_check_coordinates = .true.
196 
197  !-----------------------------------------------------------------------------
198 contains
199  !-----------------------------------------------------------------------------
201  subroutine land_vars_setup
202  use scale_process, only: &
204  use scale_const, only: &
205  undef => const_undef
206  use scale_comm, only: &
207  comm_vars8, &
208  comm_wait
209  use scale_landuse, only: &
212  implicit none
213 
214  namelist / param_land_vars / &
217  land_restart_in_check_coordinates, &
223  land_vars_checkrange
224 
225  integer :: ierr
226  integer :: i, j, iv, p
227  !---------------------------------------------------------------------------
228 
229  if( io_l ) write(io_fid_log,*)
230  if( io_l ) write(io_fid_log,*) '++++++ Module[VARS] / Categ[LAND] / Origin[SCALE-RM]'
231 
232  allocate( land_temp(lkmax,ia,ja) )
233  allocate( land_water(lkmax,ia,ja) )
234  allocate( land_sfc_temp(ia,ja) )
235  allocate( land_sfc_albedo(ia,ja,2) )
236  land_temp(:,:,:) = undef
237  land_water(:,:,:) = undef
238  land_sfc_temp(:,:) = undef
239  land_sfc_albedo(:,:,:) = undef
240 
241  allocate( land_temp_t(lkmax,ia,ja) )
242  allocate( land_water_t(lkmax,ia,ja) )
243  allocate( land_sfc_temp_t(ia,ja) )
244  allocate( land_sfc_albedo_t(ia,ja,2) )
245  land_temp_t(:,:,:) = undef
246  land_water_t(:,:,:) = undef
247  land_sfc_temp_t(:,:) = undef
248  land_sfc_albedo_t(:,:,:) = undef
249 
250  allocate( land_sflx_mw(ia,ja) )
251  allocate( land_sflx_mu(ia,ja) )
252  allocate( land_sflx_mv(ia,ja) )
253  allocate( land_sflx_sh(ia,ja) )
254  allocate( land_sflx_lh(ia,ja) )
255  allocate( land_sflx_gh(ia,ja) )
256  allocate( land_sflx_evap(ia,ja) )
257  land_sflx_mw(:,:) = undef
258  land_sflx_mu(:,:) = undef
259  land_sflx_mv(:,:) = undef
260  land_sflx_sh(:,:) = undef
261  land_sflx_lh(:,:) = undef
262  land_sflx_gh(:,:) = undef
263  land_sflx_evap(:,:) = undef
264 
265  allocate( land_u10(ia,ja) )
266  allocate( land_v10(ia,ja) )
267  allocate( land_t2(ia,ja) )
268  allocate( land_q2(ia,ja) )
269  land_u10(:,:) = undef
270  land_v10(:,:) = undef
271  land_t2(:,:) = undef
272  land_q2(:,:) = undef
273 
274  allocate( atmos_temp(ia,ja) )
275  allocate( atmos_pres(ia,ja) )
276  allocate( atmos_w(ia,ja) )
277  allocate( atmos_u(ia,ja) )
278  allocate( atmos_v(ia,ja) )
279  allocate( atmos_dens(ia,ja) )
280  allocate( atmos_qv(ia,ja) )
281  allocate( atmos_pbl(ia,ja) )
282  allocate( atmos_sfc_pres(ia,ja) )
283  allocate( atmos_sflx_lw(ia,ja) )
284  allocate( atmos_sflx_sw(ia,ja) )
285  allocate( atmos_cossza(ia,ja) )
286  allocate( atmos_sflx_prec(ia,ja) )
287  atmos_temp(:,:) = undef
288  atmos_pres(:,:) = undef
289  atmos_w(:,:) = undef
290  atmos_u(:,:) = undef
291  atmos_v(:,:) = undef
292  atmos_dens(:,:) = undef
293  atmos_qv(:,:) = undef
294  atmos_pbl(:,:) = undef
295  atmos_sfc_pres(:,:) = undef
296  atmos_sflx_lw(:,:) = undef
297  atmos_sflx_sw(:,:) = undef
298  atmos_cossza(:,:) = undef
299  atmos_sflx_prec(:,:) = undef
300 
301  land_qa_comm = lkmax &
302  + lkmax &
303  + 1 &
304  + 2
305 
306  allocate( work_comm(ia,ja,land_qa_comm) )
307 
308  !--- read namelist
309  rewind(io_fid_conf)
310  read(io_fid_conf,nml=param_land_vars,iostat=ierr)
311  if( ierr < 0 ) then !--- missing
312  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
313  elseif( ierr > 0 ) then !--- fatal error
314  write(*,*) 'xxx Not appropriate names in namelist PARAM_LAND_VARS. Check!'
315  call prc_mpistop
316  endif
317  if( io_nml ) write(io_fid_nml,nml=param_land_vars)
318 
319  if( io_l ) write(io_fid_log,*)
320  if( io_l ) write(io_fid_log,*) '*** List of prognostic variables (LAND) ***'
321  if( io_l ) write(io_fid_log,'(1x,A,A24,A,A48,A,A12,A)') &
322  '*** |', 'VARNAME ','|', &
323  'DESCRIPTION ', '[', 'UNIT ', ']'
324  do iv = 1, vmax
325  if( io_l ) write(io_fid_log,'(1x,A,I3,A,A24,A,A48,A,A12,A)') &
326  '*** NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
327  enddo
328 
329  if( io_l ) write(io_fid_log,*)
330  if ( land_restart_in_basename /= '' ) then
331  if( io_l ) write(io_fid_log,*) '*** Restart input? : YES, file = ', trim(land_restart_in_basename)
332  if( io_l ) write(io_fid_log,*) '*** Add timelabel? : ', land_restart_in_postfix_timelabel
333  else
334  if( io_l ) write(io_fid_log,*) '*** Restart input? : NO'
335  endif
336  if ( land_restart_output &
337  .AND. land_restart_out_basename /= '' ) then
338  if( io_l ) write(io_fid_log,*) '*** Restart output? : YES, file = ', trim(land_restart_out_basename)
339  if( io_l ) write(io_fid_log,*) '*** Add timelabel? : ', land_restart_out_postfix_timelabel
340  else
341  if( io_l ) write(io_fid_log,*) '*** Restart output? : NO'
342  land_restart_output = .false.
343  endif
344 
345  ! Read land property table
346  allocate( land_property_table(landuse_pft_nmax,land_property_nmax) )
347  land_property_table(:,:) = undef
348 
349  call land_param_read
350 
351  ! Apply land property to 2D map
353 
354  ! tentative, mosaic is off
355  do p = 1, land_property_nmax
356  do j = js, je
357  do i = is, ie
358  land_property(i,j,p) = land_property_table( landuse_index_pft(i,j,1), p )
359  enddo
360  enddo
361  enddo
362 
363  do p = 1, land_property_nmax
364  call comm_vars8( land_property(:,:,p), p )
365  enddo
366  do p = 1, land_property_nmax
367  call comm_wait ( land_property(:,:,p), p )
368  enddo
369 
370  return
371  end subroutine land_vars_setup
372 
373  !-----------------------------------------------------------------------------
375  subroutine land_vars_restart_open
376  use scale_time, only: &
378  use scale_fileio, only: &
379  fileio_open, &
380  fileio_check_coordinates
381  use mod_land_admin, only: &
382  land_sw
383  implicit none
384 
385  character(len=19) :: timelabel
386  character(len=H_LONG) :: basename
387  !---------------------------------------------------------------------------
388 
389  if( io_l ) write(io_fid_log,*)
390  if( io_l ) write(io_fid_log,*) '*** Open restart file (LAND) ***'
391 
392  if ( land_sw .and. land_restart_in_basename /= '' ) then
393 
395  call time_gettimelabel( timelabel )
396  basename = trim(land_restart_in_basename)//'_'//trim(timelabel)
397  else
398  basename = trim(land_restart_in_basename)
399  endif
400 
401  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
402 
403  call fileio_open( restart_fid, & ! [OUT]
404  basename ) ! [IN]
405 
406  if ( land_restart_in_check_coordinates ) then
407  call fileio_check_coordinates( restart_fid, land=.true. )
408  end if
409 
410  else
411  if( io_l ) write(io_fid_log,*) '*** restart file for land is not specified.'
412  endif
413 
414  return
415  end subroutine land_vars_restart_open
416 
417  !-----------------------------------------------------------------------------
419  subroutine land_vars_restart_read
420  use scale_fileio, only: &
421  fileio_read, &
423  implicit none
424  !---------------------------------------------------------------------------
425 
426  if ( restart_fid /= -1 ) then
427  if( io_l ) write(io_fid_log,*)
428  if( io_l ) write(io_fid_log,*) '*** Read from restart file (LAND) ***'
429 
430  call fileio_read( land_temp(:,:,:), & ! [OUT]
431  restart_fid, var_name(i_temp), 'Land', step=1 ) ! [IN]
432  call fileio_read( land_water(:,:,:), & ! [OUT]
433  restart_fid, var_name(i_water), 'Land', step=1 ) ! [IN]
434  call fileio_read( land_sfc_temp(:,:), & ! [OUT]
435  restart_fid, var_name(i_sfc_temp), 'XY', step=1 ) ! [IN]
436  call fileio_read( land_sfc_albedo(:,:,i_lw), & ! [OUT]
437  restart_fid, var_name(i_alb_lw), 'XY', step=1 ) ! [IN]
438  call fileio_read( land_sfc_albedo(:,:,i_sw), & ! [OUT]
439  restart_fid, var_name(i_alb_sw), 'XY', step=1 ) ! [IN]
440  call fileio_read( land_sflx_mw(:,:), & ! [OUT]
441  restart_fid, var_name(i_sflx_mw), 'XY', step=1 ) ! [IN]
442  call fileio_read( land_sflx_mu(:,:), & ! [OUT]
443  restart_fid, var_name(i_sflx_mu), 'XY', step=1 ) ! [IN]
444  call fileio_read( land_sflx_mv(:,:), & ! [OUT]
445  restart_fid, var_name(i_sflx_mv), 'XY', step=1 ) ! [IN]
446  call fileio_read( land_sflx_sh(:,:), & ! [OUT]
447  restart_fid, var_name(i_sflx_sh), 'XY', step=1 ) ! [IN]
448  call fileio_read( land_sflx_lh(:,:), & ! [OUT]
449  restart_fid, var_name(i_sflx_lh), 'XY', step=1 ) ! [IN]
450  call fileio_read( land_sflx_gh(:,:), & ! [OUT]
451  restart_fid, var_name(i_sflx_gh), 'XY', step=1 ) ! [IN]
452  call fileio_read( land_sflx_evap(:,:), & ! [OUT]
453  restart_fid, var_name(i_sflx_evap), 'XY', step=1 ) ! [IN]
454 
455  if( io_aggregate ) call fileio_flush( restart_fid ) ! commit all pending read requests
456 
457  call land_vars_total
458  else
459  if( io_l ) write(io_fid_log,*) '*** invalid restart file ID for land.'
460  endif
461 
462  return
463  end subroutine land_vars_restart_read
464 
465  !-----------------------------------------------------------------------------
467  subroutine land_vars_history
468  use scale_history, only: &
469  hist_in
470  implicit none
471 
472  real(RP) :: land_waterds(lkmax,ia,ja)
473  integer :: k, i, j
474  !---------------------------------------------------------------------------
475 
476  if ( land_vars_checkrange ) then
477  call valcheck( land_temp(:,is:ie,js:je), 0.0_rp, 1000.0_rp, var_name(i_temp), &
478  __file__, __line__ )
479  call valcheck( land_water(:,is:ie,js:je), 0.0_rp, 1000.0_rp, var_name(i_water), &
480  __file__, __line__ )
481  call valcheck( land_sfc_temp(is:ie,js:je), 0.0_rp, 1000.0_rp, var_name(i_sfc_temp), &
482  __file__, __line__ )
483  call valcheck( land_sfc_albedo(is:ie,js:je,i_lw), 0.0_rp, 2.0_rp, var_name(i_alb_lw), &
484  __file__, __line__ )
485  call valcheck( land_sfc_albedo(is:ie,js:je,i_sw), 0.0_rp, 2.0_rp, var_name(i_alb_sw), &
486  __file__, __line__ )
487  endif
488 
489  call hist_in( land_temp(:,:,:), var_name(i_temp), var_desc(i_temp), var_unit(i_temp), zdim='land' )
490  call hist_in( land_water(:,:,:), var_name(i_water), var_desc(i_water), var_unit(i_water), zdim='land' )
491  do j = js, je
492  do i = is, ie
493  do k = 1, lkmax
494  land_waterds(k,i,j) = land_water(k,i,j) / land_property(i,j,i_waterlimit)
495  end do
496  end do
497  end do
498  call hist_in( land_waterds(:,:,:), var_name(i_waterds), var_desc(i_waterds), var_unit(i_waterds), zdim='land', nohalo=.true. )
499 
500 
501  call hist_in( land_sfc_temp(:,:), var_name(i_sfc_temp), var_desc(i_sfc_temp), var_unit(i_sfc_temp) )
502  call hist_in( land_sfc_albedo(:,:,i_lw), var_name(i_alb_lw), var_desc(i_alb_lw), var_unit(i_alb_lw) )
503  call hist_in( land_sfc_albedo(:,:,i_sw), var_name(i_alb_sw), var_desc(i_alb_sw), var_unit(i_alb_sw) )
504 
505  call hist_in( land_sflx_mw(:,:), var_name(i_sflx_mw), var_desc(i_sflx_mw), var_unit(i_sflx_mw) )
506  call hist_in( land_sflx_mu(:,:), var_name(i_sflx_mu), var_desc(i_sflx_mu), var_unit(i_sflx_mu) )
507  call hist_in( land_sflx_mv(:,:), var_name(i_sflx_mv), var_desc(i_sflx_mv), var_unit(i_sflx_mv) )
508  call hist_in( land_sflx_sh(:,:), var_name(i_sflx_sh), var_desc(i_sflx_sh), var_unit(i_sflx_sh) )
509  call hist_in( land_sflx_lh(:,:), var_name(i_sflx_lh), var_desc(i_sflx_lh), var_unit(i_sflx_lh) )
510  call hist_in( land_sflx_gh(:,:), var_name(i_sflx_gh), var_desc(i_sflx_gh), var_unit(i_sflx_gh) )
511  call hist_in( land_sflx_evap(:,:), var_name(i_sflx_evap), var_desc(i_sflx_evap), var_unit(i_sflx_evap) )
512 
513  return
514  end subroutine land_vars_history
515 
516  !-----------------------------------------------------------------------------
518  subroutine land_vars_total
519  use scale_rm_statistics, only: &
521  stat_total
522  implicit none
523 
524  real(RP) :: total
525 
526  character(len=2) :: sk
527  integer :: k
528  !---------------------------------------------------------------------------
529 
530  if ( statistics_checktotal ) then
531 
532  do k = lks, lke
533  write(sk,'(I2.2)') k
534 
535  call stat_total( total, land_temp(k,:,:), trim(var_name(i_temp) )//sk )
536  call stat_total( total, land_water(k,:,:), trim(var_name(i_water))//sk )
537  enddo
538 
539  call stat_total( total, land_sfc_temp(:,:), var_name(i_sfc_temp) )
540  call stat_total( total, land_sfc_albedo(:,:,i_lw), var_name(i_alb_lw) )
541  call stat_total( total, land_sfc_albedo(:,:,i_sw), var_name(i_alb_sw) )
542 
543  endif
544 
545  return
546  end subroutine land_vars_total
547 
548  !-----------------------------------------------------------------------------
550  subroutine land_vars_external_in( &
551  LAND_TEMP_in, &
552  LAND_WATER_in, &
553  LAND_SFC_TEMP_in, &
554  LAND_SFC_albedo_in )
555  implicit none
556 
557  real(RP), intent(in) :: land_temp_in (:,:,:)
558  real(RP), intent(in) :: land_water_in(:,:,:)
559  real(RP), intent(in) :: land_sfc_temp_in (ia,ja)
560  real(RP), intent(in) :: land_sfc_albedo_in(ia,ja,2)
561  !---------------------------------------------------------------------------
562 
563  if( io_l ) write(io_fid_log,*)
564  if( io_l ) write(io_fid_log,*) '*** External Input (land) ***'
565 
566  land_temp(:,:,:) = land_temp_in(:,:,:)
567  land_water(:,:,:) = land_water_in(:,:,:)
568  land_sfc_temp(:,:) = land_sfc_temp_in(:,:)
569  land_sfc_albedo(:,:,:) = land_sfc_albedo_in(:,:,:)
570 
571  land_sflx_mw(:,:) = 0.0_rp
572  land_sflx_mu(:,:) = 0.0_rp
573  land_sflx_mv(:,:) = 0.0_rp
574  land_sflx_sh(:,:) = 0.0_rp
575  land_sflx_lh(:,:) = 0.0_rp
576  land_sflx_gh(:,:) = 0.0_rp
577  land_sflx_evap(:,:) = 0.0_rp
578 
579  call land_vars_total
580 
581  return
582  end subroutine land_vars_external_in
583 
584  !-----------------------------------------------------------------------------
586  subroutine land_param_read
587  use scale_process, only: &
589  use scale_landuse, only: &
591  implicit none
592 
593  integer :: index
594  character(len=H_MID) :: description
595  real(RP) :: strgmax
596  real(RP) :: strgcrt
597  real(RP) :: tcs
598  real(RP) :: hcs
599  real(RP) :: dfw
600  real(RP) :: z0m
601  real(RP) :: z0h
602  real(RP) :: z0e
603 
604  namelist / param_land_property / &
606 
607  namelist / param_land_data / &
608  index, &
609  description, &
610  strgmax, &
611  strgcrt, &
612  tcs, &
613  hcs, &
614  dfw, &
615  z0m, &
616  z0h, &
617  z0e
618 
619  integer :: n
620  integer :: ierr
621 
622  integer :: io_fid_land_property
623  !---------------------------------------------------------------------------
624 
625  !--- read namelist
626  rewind(io_fid_conf)
627  read(io_fid_conf,nml=param_land_property,iostat=ierr)
628  if( ierr < 0 ) then !--- missing
629  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
630  elseif( ierr > 0 ) then !--- fatal error
631  write(*,*) 'xxx Not appropriate names in namelist PARAM_LAND_PROPERTY. Check!'
632  call prc_mpistop
633  endif
634  if( io_nml ) write(io_fid_nml,nml=param_land_property)
635 
636  if( land_property_in_filename /= '' ) then
637  !--- Open land parameter file
638  io_fid_land_property = io_get_available_fid()
639  open( io_fid_land_property, &
640  file = trim(land_property_in_filename), &
641  form = 'formatted', &
642  status = 'old', &
643  iostat = ierr )
644 
645  if ( ierr /= 0 ) then
646  write(*,*) 'xxx [LAND_param_read] Failed to open land parameter file! :', &
648  call prc_mpistop
649  else
650  if( io_l ) write(io_fid_log,*)
651  if( io_l ) write(io_fid_log,*) '*** Properties for each plant functional type (PFT)'
652  if( io_l ) write(io_fid_log,'(12(1x,A))') '*** ', &
653  ' description', &
654  'Max Stg.', &
655  'CRT Stg.', &
656  'T condu.', &
657  'H capac.', &
658  'DFC Wat.', &
659  ' Z0(m)', &
660  ' Z0(h)', &
661  ' Z0(e)'
662 
663  !--- read namelist
664  rewind(io_fid_land_property)
665 
666  do n = 1, landuse_pft_nmax
667  ! undefined roughness length
668  z0h = -1.0_rp
669  z0e = -1.0_rp
670 
671  read(io_fid_land_property,nml=param_land_data,iostat=ierr)
672  if ( ierr < 0 ) then !--- no more data
673  exit
674  elseif( ierr > 0 ) then !--- fatal error
675  write(*,*) 'xxx Not appropriate names in namelist PARAM_LAND_DATA. Check!'
676  call prc_mpistop
677  endif
678 
679  if( z0h < 0.0_rp ) then
680  z0h = z0m / 7.4_rp ! defined by Garratt and Francey (1978)
681  endif
682  if( z0e < 0.0_rp ) then
683  z0e = z0m / 7.4_rp ! defined by Garratt and Francey (1978)
684  endif
685 
686  land_property_table(index,i_waterlimit ) = strgmax
687  land_property_table(index,i_watercritical) = strgcrt
688  land_property_table(index,i_thermalcond ) = tcs
689  land_property_table(index,i_heatcapacity ) = hcs
690  land_property_table(index,i_waterdiff ) = dfw
691  land_property_table(index,i_z0m ) = z0m
692  land_property_table(index,i_z0h ) = z0h
693  land_property_table(index,i_z0e ) = z0e
694 
695  if( io_l ) write(io_fid_log,'(1x,A10,I3.3,1x,A32,3(1x,F8.2),(1x,ES8.1),4(1x,F8.2))') &
696  '*** IDX = ', index, &
697  trim(description), &
698  strgmax, &
699  strgcrt, &
700  tcs, &
701  hcs, &
702  dfw, &
703  z0m, &
704  z0h, &
705  z0e
706  enddo
707 
708  end if
709 
710  close( io_fid_land_property )
711 
712  endif
713 
714  return
715  end subroutine land_param_read
716 
717  !-----------------------------------------------------------------------------
719  function convert_ws2vwc( WS, critical ) result( VWC )
720  implicit none
721 
722  real(RP), intent(in) :: ws(ia,ja) ! water saturation [fraction]
723  logical, intent(in) :: critical ! is I_WaterCritical used?
724 
725  real(RP) :: vwc(ia,ja) ! volumetric water content [m3/m3]
726 
727  ! work
728  integer :: i, j, num
729  !---------------------------------------------------------------------------
730 
731  if( critical ) then
732  num = i_watercritical
733  else
734  num = i_waterlimit
735  end if
736 
737  do j = js, je
738  do i = is, ie
739  vwc(i,j) = max( min( ws(i,j)*land_property(i,j,num), land_property(i,j,num) ), 0.0_rp )
740  end do
741  end do
742 
743  return
744  end function convert_ws2vwc
745 
746  !-----------------------------------------------------------------------------
748  subroutine land_vars_restart_create
749  use scale_time, only: &
751  use scale_fileio, only: &
753  use mod_land_admin, only: &
754  land_sw
755  implicit none
756 
757  character(len=19) :: timelabel
758  character(len=H_LONG) :: basename
759  !---------------------------------------------------------------------------
760 
761  if ( land_sw .and. land_restart_out_basename /= '' ) then
762 
763  if( io_l ) write(io_fid_log,*)
764  if( io_l ) write(io_fid_log,*) '*** Create restart file (LAND) ***'
765 
767  call time_gettimelabel( timelabel )
768  basename = trim(land_restart_out_basename)//'_'//trim(timelabel)
769  else
770  basename = trim(land_restart_out_basename)
771  endif
772 
773  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
774 
775  call fileio_create( restart_fid, & ! [OUT]
777 
778  endif
779 
780  return
781  end subroutine land_vars_restart_create
782 
783  !-----------------------------------------------------------------------------
785  subroutine land_vars_restart_enddef
786  use scale_fileio, only: &
788  implicit none
789 
790  if ( restart_fid /= -1 ) then
791  call fileio_enddef( restart_fid ) ! [IN]
792  endif
793 
794  return
795  end subroutine land_vars_restart_enddef
796 
797  !-----------------------------------------------------------------------------
799  subroutine land_vars_restart_close
800  use scale_fileio, only: &
802  implicit none
803  !---------------------------------------------------------------------------
804 
805  if ( restart_fid /= -1 ) then
806  if( io_l ) write(io_fid_log,*)
807  if( io_l ) write(io_fid_log,*) '*** Close restart file (LAND) ***'
808 
809  call fileio_close( restart_fid ) ! [IN]
810 
811  restart_fid = -1
812  endif
813 
814  return
815  end subroutine land_vars_restart_close
816 
817  !-----------------------------------------------------------------------------
819  subroutine land_vars_restart_def_var
820  use scale_fileio, only: &
822  implicit none
823  !---------------------------------------------------------------------------
824 
825  if ( restart_fid /= -1 ) then
826 
827  call fileio_def_var( restart_fid, var_id(i_temp), var_name(i_temp), var_desc(i_temp), &
828  var_unit(i_temp), 'Land', land_restart_out_dtype)
829  call fileio_def_var( restart_fid, var_id(i_water), var_name(i_water), var_desc(i_water), &
830  var_unit(i_water), 'Land', land_restart_out_dtype)
831  call fileio_def_var( restart_fid, var_id(i_sfc_temp), var_name(i_sfc_temp), var_desc(i_sfc_temp), &
832  var_unit(i_sfc_temp), 'XY', land_restart_out_dtype)
833  call fileio_def_var( restart_fid, var_id(i_alb_lw), var_name(i_alb_lw), var_desc(i_alb_lw), &
834  var_unit(i_alb_lw), 'XY', land_restart_out_dtype)
835  call fileio_def_var( restart_fid, var_id(i_alb_sw), var_name(i_alb_sw), var_desc(i_alb_sw), &
836  var_unit(i_alb_sw), 'XY', land_restart_out_dtype)
837  call fileio_def_var( restart_fid, var_id(i_sflx_mw), var_name(i_sflx_mw), var_desc(i_sflx_mw), &
838  var_unit(i_sflx_mw), 'XY', land_restart_out_dtype)
839  call fileio_def_var( restart_fid, var_id(i_sflx_mu), var_name(i_sflx_mu), var_desc(i_sflx_mu), &
840  var_unit(i_sflx_mu), 'XY', land_restart_out_dtype)
841  call fileio_def_var( restart_fid, var_id(i_sflx_mv), var_name(i_sflx_mv), var_desc(i_sflx_mv), &
842  var_unit(i_sflx_mv), 'XY', land_restart_out_dtype)
843  call fileio_def_var( restart_fid, var_id(i_sflx_sh), var_name(i_sflx_sh), var_desc(i_sflx_sh), &
844  var_unit(i_sflx_sh), 'XY', land_restart_out_dtype)
845  call fileio_def_var( restart_fid, var_id(i_sflx_lh), var_name(i_sflx_lh), var_desc(i_sflx_lh), &
846  var_unit(i_sflx_lh), 'XY', land_restart_out_dtype)
847  call fileio_def_var( restart_fid, var_id(i_sflx_gh), var_name(i_sflx_gh), var_desc(i_sflx_gh), &
848  var_unit(i_sflx_gh), 'XY', land_restart_out_dtype)
849  call fileio_def_var( restart_fid, var_id(i_sflx_evap), var_name(i_sflx_evap), var_desc(i_sflx_evap), &
850  var_unit(i_sflx_evap), 'XY', land_restart_out_dtype)
851 
852  endif
853 
854  return
855  end subroutine land_vars_restart_def_var
856 
857  !-----------------------------------------------------------------------------
859  subroutine land_vars_restart_write
860  use scale_fileio, only: &
861  fileio_write_var
862  implicit none
863  !---------------------------------------------------------------------------
864 
865  if ( restart_fid /= -1 ) then
866 
867  call land_vars_total
868 
869  call fileio_write_var( restart_fid, var_id(i_temp), land_temp(:,:,:), & ! [IN]
870  var_name(i_temp), 'Land', nohalo=.true. ) ! [IN]
871  call fileio_write_var( restart_fid, var_id(i_water), land_water(:,:,:), & ! [IN]
872  var_name(i_water), 'Land', nohalo=.true. ) ! [IN]
873  call fileio_write_var( restart_fid, var_id(i_sfc_temp), land_sfc_temp(:,:), & ! [IN]
874  var_name(i_sfc_temp), 'XY', nohalo=.true. ) ! [IN]
875  call fileio_write_var( restart_fid, var_id(i_alb_lw), land_sfc_albedo(:,:,i_lw), & ! [IN]
876  var_name(i_alb_lw), 'XY', nohalo=.true. ) ! [IN]
877  call fileio_write_var( restart_fid, var_id(i_alb_sw), land_sfc_albedo(:,:,i_sw), & ! [IN]
878  var_name(i_alb_sw), 'XY', nohalo=.true. ) ! [IN]
879  call fileio_write_var( restart_fid, var_id(i_sflx_mw), land_sflx_mw(:,:), & ! [IN]
880  var_name(i_sflx_mw), 'XY', nohalo=.true. ) ! [IN]
881  call fileio_write_var( restart_fid, var_id(i_sflx_mu), land_sflx_mu(:,:), & ! [IN]
882  var_name(i_sflx_mu), 'XY', nohalo=.true. ) ! [IN]
883  call fileio_write_var( restart_fid, var_id(i_sflx_mv), land_sflx_mv(:,:), & ! [IN]
884  var_name(i_sflx_mv), 'XY', nohalo=.true. ) ! [IN]
885  call fileio_write_var( restart_fid, var_id(i_sflx_sh), land_sflx_sh(:,:), & ! [IN]
886  var_name(i_sflx_sh), 'XY', nohalo=.true. ) ! [IN]
887  call fileio_write_var( restart_fid, var_id(i_sflx_lh), land_sflx_lh(:,:), & ! [IN]
888  var_name(i_sflx_lh), 'XY', nohalo=.true. ) ! [IN]
889  call fileio_write_var( restart_fid, var_id(i_sflx_gh), land_sflx_gh(:,:), & ! [IN]
890  var_name(i_sflx_gh), 'XY', nohalo=.true. ) ! [IN]
891  call fileio_write_var( restart_fid, var_id(i_sflx_evap), land_sflx_evap(:,:), & ! [IN]
892  var_name(i_sflx_evap), 'XY', nohalo=.true. ) ! [IN]
893 
894  endif
895 
896  return
897  end subroutine land_vars_restart_write
898 
899 end module mod_land_vars
module Land admin
integer, public is
start point of inner domain: x, local
module DEBUG
Definition: scale_debug.F90:13
logical, public statistics_checktotal
calc&report variable totals to logfile?
real(rp), dimension(:,:), allocatable, public land_v10
land surface velocity v at 10m [m/s]
integer, public je
end point of inner domain: y, local
real(rp), dimension(:,:), allocatable, public land_sflx_mw
land surface w-momentum flux [kg/m2/s]
subroutine, public land_vars_restart_close
Close restart file.
integer, public const_i_lw
long-wave radiation index
Definition: scale_const.F90:95
subroutine, public prc_mpistop
Abort MPI.
logical, public land_restart_output
Output restart file?
integer, parameter, public i_heatcapacity
integer, parameter, public i_waterlimit
real(rp), dimension(:,:), allocatable, public atmos_qv
real(rp), dimension(:,:), allocatable, public land_sflx_sh
land surface sensible heat flux [J/m2/s]
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:61
subroutine, public fileio_flush(fid)
Flush all pending requests to a netCDF file (PnetCDF only)
real(rp), dimension(:,:), allocatable, public atmos_pbl
subroutine, public land_vars_setup
Setup.
real(rp), dimension(:,:), allocatable, public atmos_sflx_prec
real(rp), dimension(:,:), allocatable, public atmos_u
module STDIO
Definition: scale_stdio.F90:12
integer, parameter, public i_watercritical
subroutine, public land_vars_restart_enddef
Exit netCDF define mode.
real(rp), dimension(:,:,:), allocatable, public land_sfc_albedo_t
tendency of LAND_SFC_albedo
real(rp), dimension(:,:), allocatable, public land_sflx_lh
land surface latent heat flux [J/m2/s]
character(len=h_long), public land_restart_in_basename
Basename of the input file.
character(len=h_short), public land_restart_out_dtype
REAL4 or REAL8.
real(rp), dimension(:,:), allocatable, public atmos_w
integer, parameter, public i_z0h
module FILE I/O (netcdf)
real(rp), dimension(:,:), allocatable, public land_sflx_evap
land surface water vapor flux [kg/m2/s]
integer, parameter, public i_z0e
real(rp), public const_undef
Definition: scale_const.F90:43
module Statistics
real(rp), dimension(:,:), allocatable, public atmos_sfc_pres
subroutine, public land_vars_restart_create
Create land restart file.
subroutine, public land_vars_restart_read
Read land restart.
real(rp), dimension(:,:), allocatable, public atmos_pres
module grid index
real(rp), dimension(:,:), allocatable, public land_sfc_temp
land surface skin temperature [K]
real(rp), dimension(:,:), allocatable, public atmos_temp
logical, public io_nml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:62
real(rp), dimension(:,:), allocatable, public land_sflx_mu
land surface u-momentum flux [kg/m2/s]
real(rp), dimension(:,:), allocatable, public land_q2
land surface water vapor at 2m [kg/kg]
integer, public ia
of whole cells: x, local, with HALO
real(rp), dimension(:,:), allocatable, public land_t2
land surface temperature at 2m [K]
integer function, public io_get_available_fid()
search & get available file ID
module LANDUSE
subroutine, public time_gettimelabel(timelabel)
generate time label
Definition: scale_time.F90:90
real(rp) function, dimension(ia, ja), public convert_ws2vwc(WS, critical)
conversion from water saturation [fraction] to volumetric water content [m3/m3]
logical, public land_restart_in_postfix_timelabel
Add timelabel to the basename of input file?
character(len=h_long), public land_restart_out_basename
Basename of the output file.
subroutine, public fileio_create(fid, basename, title, datatype, date, subsec, append, nozcoord)
Create/open a netCDF file.
subroutine, public land_vars_restart_def_var
Define land variables in restart file.
real(rp), dimension(:,:,:), allocatable, public land_temp
temperature of each soil layer [K]
module COMMUNICATION
Definition: scale_comm.F90:23
integer, public js
start point of inner domain: y, local
module TIME
Definition: scale_time.F90:15
module PROCESS
real(rp), dimension(:,:), allocatable, public land_u10
land surface velocity u at 10m [m/s]
integer, dimension(:,:,:), allocatable, public landuse_index_pft
index of PFT for each mosaic
real(rp), dimension(:,:,:), allocatable, public land_water_t
tendency of LAND_WATER
real(rp), dimension(:,:,:), allocatable, public land_sfc_albedo
land surface albedo (0-1)
module LAND Variables
real(rp), dimension(:,:), allocatable, public land_sfc_temp_t
tendency of LAND_SFC_TEMP
module CONSTANT
Definition: scale_const.F90:14
real(rp), dimension(:,:), allocatable, public atmos_dens
real(rp), dimension(:,:), allocatable, public land_sflx_gh
land surface heat flux [J/m2/s]
real(rp), dimension(:,:), allocatable, public atmos_v
subroutine, public fileio_enddef(fid)
Exit netCDF file define mode.
real(rp), dimension(:,:,:), allocatable, public land_water
moisture of each soil layer [m3/m3]
subroutine, public land_vars_external_in(LAND_TEMP_in, LAND_WATER_in, LAND_SFC_TEMP_in, LAND_SFC_albedo_in)
Input from External I/O.
logical, public land_restart_out_postfix_timelabel
Add timelabel to the basename of output file?
subroutine, public land_vars_total
Budget monitor for land.
module profiler
Definition: scale_prof.F90:10
real(rp), dimension(:,:), allocatable, public land_sflx_mv
land surface v-momentum flux [kg/m2/s]
character(len=h_mid), public land_restart_out_title
Title of the output file.
integer, public ie
end point of inner domain: x, local
real(rp), dimension(:,:,:), allocatable, public land_temp_t
tendency of LAND_TEMP
integer, parameter, public i_z0m
character(len=h_long), public land_property_in_filename
the file of land parameter table
logical, public io_aggregate
do parallel I/O through PnetCDF
Definition: scale_stdio.F90:66
subroutine, public fileio_open(fid, basename)
open a netCDF file for read
integer, public const_i_sw
short-wave radiation index
Definition: scale_const.F90:96
module PRECISION
subroutine, public fileio_def_var(fid, vid, varname, desc, unit, axistype, datatype, timeintv, nsteps)
Define a variable to file.
module HISTORY
subroutine, public land_vars_history
History output set for land variables.
integer, public landuse_pft_nmax
number of plant functional type(PFT)
subroutine, public land_vars_restart_open
Open land restart file for read.
subroutine, public fileio_close(fid)
Close a netCDF file.
module land grid index
integer, parameter, public land_property_nmax
integer, public io_fid_conf
Config file ID.
Definition: scale_stdio.F90:55
logical, public land_sw
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
subroutine, public land_vars_restart_write
Write land variables to restart file.
real(rp), dimension(:,:), allocatable, public atmos_sflx_sw
integer, parameter, public i_thermalcond
real(rp), dimension(:,:), allocatable, public atmos_cossza
integer, parameter, public i_waterdiff
real(rp), dimension(:,:,:), allocatable, public land_property
land surface property
integer, public io_fid_nml
Log file ID (only for output namelist)
Definition: scale_stdio.F90:57
real(rp), dimension(:,:), allocatable, public atmos_sflx_lw
integer, public ja
of whole cells: y, local, with HALO