SCALE-RM
mod_ocean_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
21 
22  use scale_const, only: &
23  i_sw => const_i_sw, &
24  i_lw => const_i_lw
25  !-----------------------------------------------------------------------------
26  implicit none
27  private
28  !-----------------------------------------------------------------------------
29  !
30  !++ Public procedure
31  !
32  public :: ocean_vars_setup
33  public :: ocean_vars_restart_read
34  public :: ocean_vars_restart_write
35  public :: ocean_vars_history
36  public :: ocean_vars_total
37  public :: ocean_vars_external_in
38 
40  public :: ocean_vars_restart_open
43  public :: ocean_vars_restart_close
44 
45  !-----------------------------------------------------------------------------
46  !
47  !++ Public parameters & variables
48  !
49  logical, public :: ocean_restart_output = .false.
50 
51  character(len=H_LONG), public :: ocean_restart_in_basename = ''
52  logical, public :: ocean_restart_in_postfix_timelabel = .false.
53  character(len=H_LONG), public :: ocean_restart_out_basename = ''
54  logical, public :: ocean_restart_out_postfix_timelabel = .true.
55  character(len=H_MID), public :: ocean_restart_out_title = 'OCEAN restart'
56  character(len=H_SHORT), public :: ocean_restart_out_dtype = 'DEFAULT'
57 
58  ! prognostic variables
59  real(RP), public, allocatable :: ocean_temp (:,:)
60  real(RP), public, allocatable :: ocean_sfc_temp (:,:)
61  real(RP), public, allocatable :: ocean_sfc_albedo(:,:,:)
62  real(RP), public, allocatable :: ocean_sfc_z0m (:,:)
63  real(RP), public, allocatable :: ocean_sfc_z0h (:,:)
64  real(RP), public, allocatable :: ocean_sfc_z0e (:,:)
65 
66  ! tendency variables
67  real(RP), public, allocatable :: ocean_temp_t (:,:)
68  real(RP), public, allocatable :: ocean_sfc_temp_t (:,:)
69  real(RP), public, allocatable :: ocean_sfc_albedo_t(:,:,:)
70  real(RP), public, allocatable :: ocean_sfc_z0m_t (:,:)
71  real(RP), public, allocatable :: ocean_sfc_z0h_t (:,:)
72  real(RP), public, allocatable :: ocean_sfc_z0e_t (:,:)
73 
74  ! surface variables for restart
75  real(RP), public, allocatable :: ocean_sflx_mw (:,:)
76  real(RP), public, allocatable :: ocean_sflx_mu (:,:)
77  real(RP), public, allocatable :: ocean_sflx_mv (:,:)
78  real(RP), public, allocatable :: ocean_sflx_sh (:,:)
79  real(RP), public, allocatable :: ocean_sflx_lh (:,:)
80  real(RP), public, allocatable :: ocean_sflx_wh (:,:)
81  real(RP), public, allocatable :: ocean_sflx_evap(:,:)
82 
83  ! diagnostic variables
84  real(RP), public, allocatable :: ocean_u10(:,:)
85  real(RP), public, allocatable :: ocean_v10(:,:)
86  real(RP), public, allocatable :: ocean_t2 (:,:)
87  real(RP), public, allocatable :: ocean_q2 (:,:)
88 
89  ! recieved atmospheric variables
90  real(RP), public, allocatable :: atmos_temp (:,:)
91  real(RP), public, allocatable :: atmos_pres (:,:)
92  real(RP), public, allocatable :: atmos_w (:,:)
93  real(RP), public, allocatable :: atmos_u (:,:)
94  real(RP), public, allocatable :: atmos_v (:,:)
95  real(RP), public, allocatable :: atmos_dens (:,:)
96  real(RP), public, allocatable :: atmos_qv (:,:)
97  real(RP), public, allocatable :: atmos_pbl (:,:)
98  real(RP), public, allocatable :: atmos_sfc_pres (:,:)
99  real(RP), public, allocatable :: atmos_sflx_lw (:,:)
100  real(RP), public, allocatable :: atmos_sflx_sw (:,:)
101  real(RP), public, allocatable :: atmos_cossza (:,:)
102  real(RP), public, allocatable :: atmos_sflx_prec(:,:)
103 
104  !-----------------------------------------------------------------------------
105  !
106  !++ Private procedure
107  !
108  !-----------------------------------------------------------------------------
109  !
110  !++ Private parameters & variables
111  !
112  logical, private :: ocean_vars_checkrange = .false.
113 
114  integer, private, parameter :: vmax = 14
115  integer, private, parameter :: i_temp = 1
116  integer, private, parameter :: i_sfc_temp = 2
117  integer, private, parameter :: i_alb_lw = 3
118  integer, private, parameter :: i_alb_sw = 4
119  integer, private, parameter :: i_sfc_z0m = 5
120  integer, private, parameter :: i_sfc_z0h = 6
121  integer, private, parameter :: i_sfc_z0e = 7
122  integer, private, parameter :: i_sflx_mw = 8
123  integer, private, parameter :: i_sflx_mu = 9
124  integer, private, parameter :: i_sflx_mv = 10
125  integer, private, parameter :: i_sflx_sh = 11
126  integer, private, parameter :: i_sflx_lh = 12
127  integer, private, parameter :: i_sflx_wh = 13
128  integer, private, parameter :: i_sflx_evap = 14
129 
130  character(len=H_SHORT), private :: var_name(vmax)
131  character(len=H_MID), private :: var_desc(vmax)
132  character(len=H_SHORT), private :: var_unit(vmax)
133  integer, private :: var_id(vmax)
134  integer, private :: restart_fid = -1 ! file ID
135 
136  logical, private :: ocean_restart_in_check_coordinates = .true.
137 
138  data var_name / 'OCEAN_TEMP', &
139  'OCEAN_SFC_TEMP', &
140  'OCEAN_ALB_LW', &
141  'OCEAN_ALB_SW', &
142  'OCEAN_SFC_Z0M', &
143  'OCEAN_SFC_Z0H', &
144  'OCEAN_SFC_Z0E', &
145  'OCEAN_SFLX_MW', &
146  'OCEAN_SFLX_MU', &
147  'OCEAN_SFLX_MV', &
148  'OCEAN_SFLX_SH', &
149  'OCEAN_SFLX_LH', &
150  'OCEAN_SFLX_WH', &
151  'OCEAN_SFLX_evap' /
152  data var_desc / 'temperature at uppermost ocean layer', &
153  'ocean surface skin temperature', &
154  'ocean surface albedo (longwave)', &
155  'ocean surface albedo (shortwave)', &
156  'ocean surface roughness length (momentum)', &
157  'ocean surface roughness length (heat)', &
158  'ocean surface roughness length (vapor)', &
159  'ocean surface w-momentum flux', &
160  'ocean surface u-momentum flux', &
161  'ocean surface v-momentum flux', &
162  'ocean surface sensible heat flux', &
163  'ocean surface latent heat flux', &
164  'ocean surface water heat flux', &
165  'ocean surface water vapor flux' /
166  data var_unit / 'K', &
167  'K', &
168  '1', &
169  '1', &
170  'm', &
171  'm', &
172  'm', &
173  'kg/m2/s', &
174  'kg/m2/s', &
175  'kg/m2/s', &
176  'J/m2/s', &
177  'J/m2/s', &
178  'J/m2/s', &
179  'kg/m2/s' /
180 
181  !-----------------------------------------------------------------------------
182 contains
183  !-----------------------------------------------------------------------------
185  subroutine ocean_vars_setup
186  use scale_process, only: &
188  use scale_const, only: &
189  undef => const_undef
190  implicit none
191 
192  namelist / param_ocean_vars / &
195  ocean_restart_in_check_coordinates, &
201  ocean_vars_checkrange
202 
203  integer :: ierr
204  integer :: iv
205  !---------------------------------------------------------------------------
206 
207  if( io_l ) write(io_fid_log,*)
208  if( io_l ) write(io_fid_log,*) '++++++ Module[VARS] / Categ[OCEAN] / Origin[SCALE-RM]'
209 
210  allocate( ocean_temp(ia,ja) )
211  allocate( ocean_sfc_temp(ia,ja) )
212  allocate( ocean_sfc_albedo(ia,ja,2) )
213  allocate( ocean_sfc_z0m(ia,ja) )
214  allocate( ocean_sfc_z0h(ia,ja) )
215  allocate( ocean_sfc_z0e(ia,ja) )
216  ocean_temp(:,:) = undef
217  ocean_sfc_temp(:,:) = undef
218  ocean_sfc_albedo(:,:,:) = undef
219  ocean_sfc_z0m(:,:) = undef
220  ocean_sfc_z0h(:,:) = undef
221  ocean_sfc_z0e(:,:) = undef
222 
223  allocate( ocean_temp_t(ia,ja) )
224  allocate( ocean_sfc_temp_t(ia,ja) )
225  allocate( ocean_sfc_albedo_t(ia,ja,2) )
226  allocate( ocean_sfc_z0m_t(ia,ja) )
227  allocate( ocean_sfc_z0h_t(ia,ja) )
228  allocate( ocean_sfc_z0e_t(ia,ja) )
229  ocean_temp_t(:,:) = undef
230  ocean_sfc_temp_t(:,:) = undef
231  ocean_sfc_albedo_t(:,:,:) = undef
232  ocean_sfc_z0m_t(:,:) = undef
233  ocean_sfc_z0h_t(:,:) = undef
234  ocean_sfc_z0e_t(:,:) = undef
235 
236  allocate( ocean_sflx_mw(ia,ja) )
237  allocate( ocean_sflx_mu(ia,ja) )
238  allocate( ocean_sflx_mv(ia,ja) )
239  allocate( ocean_sflx_sh(ia,ja) )
240  allocate( ocean_sflx_lh(ia,ja) )
241  allocate( ocean_sflx_wh(ia,ja) )
242  allocate( ocean_sflx_evap(ia,ja) )
243  ocean_sflx_mw(:,:) = undef
244  ocean_sflx_mu(:,:) = undef
245  ocean_sflx_mv(:,:) = undef
246  ocean_sflx_sh(:,:) = undef
247  ocean_sflx_lh(:,:) = undef
248  ocean_sflx_wh(:,:) = undef
249  ocean_sflx_evap(:,:) = undef
250 
251  allocate( ocean_u10(ia,ja) )
252  allocate( ocean_v10(ia,ja) )
253  allocate( ocean_t2(ia,ja) )
254  allocate( ocean_q2(ia,ja) )
255  ocean_u10(:,:) = undef
256  ocean_v10(:,:) = undef
257  ocean_t2(:,:) = undef
258  ocean_q2(:,:) = undef
259 
260  allocate( atmos_temp(ia,ja) )
261  allocate( atmos_pres(ia,ja) )
262  allocate( atmos_w(ia,ja) )
263  allocate( atmos_u(ia,ja) )
264  allocate( atmos_v(ia,ja) )
265  allocate( atmos_dens(ia,ja) )
266  allocate( atmos_qv(ia,ja) )
267  allocate( atmos_pbl(ia,ja) )
268  allocate( atmos_sfc_pres(ia,ja) )
269  allocate( atmos_sflx_lw(ia,ja) )
270  allocate( atmos_sflx_sw(ia,ja) )
271  allocate( atmos_cossza(ia,ja) )
272  allocate( atmos_sflx_prec(ia,ja) )
273  atmos_temp(:,:) = undef
274  atmos_pres(:,:) = undef
275  atmos_w(:,:) = undef
276  atmos_u(:,:) = undef
277  atmos_v(:,:) = undef
278  atmos_dens(:,:) = undef
279  atmos_qv(:,:) = undef
280  atmos_pbl(:,:) = undef
281  atmos_sfc_pres(:,:) = undef
282  atmos_sflx_lw(:,:) = undef
283  atmos_sflx_sw(:,:) = undef
284  atmos_cossza(:,:) = undef
285  atmos_sflx_prec(:,:) = undef
286 
287  !--- read namelist
288  rewind(io_fid_conf)
289  read(io_fid_conf,nml=param_ocean_vars,iostat=ierr)
290  if( ierr < 0 ) then !--- missing
291  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
292  elseif( ierr > 0 ) then !--- fatal error
293  write(*,*) 'xxx Not appropriate names in namelist PARAM_OCEAN_VARS. Check!'
294  call prc_mpistop
295  endif
296  if( io_nml ) write(io_fid_nml,nml=param_ocean_vars)
297 
298  if( io_l ) write(io_fid_log,*)
299  if( io_l ) write(io_fid_log,*) '*** List of prognostic variables (OCEAN) ***'
300  if( io_l ) write(io_fid_log,'(1x,A,A24,A,A48,A,A12,A)') &
301  '*** |', 'VARNAME ','|', &
302  'DESCRIPTION ', '[', 'UNIT ', ']'
303  do iv = 1, vmax
304  if( io_l ) write(io_fid_log,'(1x,A,I3,A,A24,A,A48,A,A12,A)') &
305  '*** NO.',iv,'|',var_name(iv),'|',var_desc(iv),'[',var_unit(iv),']'
306 
307  enddo
308 
309  if( io_l ) write(io_fid_log,*)
310  if ( ocean_restart_in_basename /= '' ) then
311  if( io_l ) write(io_fid_log,*) '*** Restart input? : YES, file = ', trim(ocean_restart_in_basename)
312  if( io_l ) write(io_fid_log,*) '*** Add timelabel? : ', ocean_restart_in_postfix_timelabel
313  else
314  if( io_l ) write(io_fid_log,*) '*** Restart input? : NO'
315  endif
316  if ( ocean_restart_output &
317  .AND. ocean_restart_out_basename /= '' ) then
318  if( io_l ) write(io_fid_log,*) '*** Restart output? : YES, file = ', trim(ocean_restart_out_basename)
319  if( io_l ) write(io_fid_log,*) '*** Add timelabel? : ', ocean_restart_out_postfix_timelabel
320  else
321  if( io_l ) write(io_fid_log,*) '*** Restart output? : NO'
322  ocean_restart_output = .false.
323  endif
324 
325  return
326  end subroutine ocean_vars_setup
327 
328  !-----------------------------------------------------------------------------
330  subroutine ocean_vars_restart_open
331  use scale_time, only: &
333  use scale_fileio, only: &
334  fileio_open, &
335  fileio_check_coordinates
336  use mod_ocean_admin, only: &
337  ocean_sw
338  implicit none
339 
340  character(len=19) :: timelabel
341  character(len=H_LONG) :: basename
342  !---------------------------------------------------------------------------
343 
344  if( io_l ) write(io_fid_log,*)
345  if( io_l ) write(io_fid_log,*) '*** Open restart file (OCEAN) ***'
346 
347  if ( ocean_sw .and. ocean_restart_in_basename /= '' ) then
348 
350  call time_gettimelabel( timelabel )
351  basename = trim(ocean_restart_in_basename)//'_'//trim(timelabel)
352  else
353  basename = trim(ocean_restart_in_basename)
354  endif
355 
356  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
357 
358  call fileio_open( restart_fid, & ! [OUT]
359  basename ) ! [IN]
360 
361  if ( ocean_restart_in_check_coordinates ) then
362  call fileio_check_coordinates( restart_fid )
363  end if
364 
365  else
366  if( io_l ) write(io_fid_log,*) '*** restart file for ocean is not specified.'
367  endif
368 
369  return
370  end subroutine ocean_vars_restart_open
371 
372  !-----------------------------------------------------------------------------
374  subroutine ocean_vars_restart_read
375  use scale_fileio, only: &
376  fileio_read, &
378  implicit none
379  !---------------------------------------------------------------------------
380 
381  if ( restart_fid /= -1 ) then
382  if( io_l ) write(io_fid_log,*)
383  if( io_l ) write(io_fid_log,*) '*** Read from restart file (OCEAN) ***'
384 
385  call fileio_read( ocean_temp(:,:), & ! [OUT]
386  restart_fid, var_name(i_temp), 'XY', step=1 ) ! [IN]
387  call fileio_read( ocean_sfc_temp(:,:), & ! [OUT]
388  restart_fid, var_name(i_sfc_temp), 'XY', step=1 ) ! [IN]
389  call fileio_read( ocean_sfc_albedo(:,:,i_lw), & ! [OUT]
390  restart_fid, var_name(i_alb_lw), 'XY', step=1 ) ! [IN]
391  call fileio_read( ocean_sfc_albedo(:,:,i_sw), & ! [OUT]
392  restart_fid, var_name(i_alb_sw), 'XY', step=1 ) ! [IN]
393  call fileio_read( ocean_sfc_z0m(:,:), & ! [OUT]
394  restart_fid, var_name(i_sfc_z0m), 'XY', step=1 ) ! [IN]
395  call fileio_read( ocean_sfc_z0h(:,:), & ! [OUT]
396  restart_fid, var_name(i_sfc_z0h), 'XY', step=1 ) ! [IN]
397  call fileio_read( ocean_sfc_z0e(:,:), & ! [OUT]
398  restart_fid, var_name(i_sfc_z0e), 'XY', step=1 ) ! [IN]
399 
400  call fileio_read( ocean_sflx_mw(:,:), & ! [OUT]
401  restart_fid, var_name(i_sflx_mw), 'XY', step=1 ) ! [IN]
402  call fileio_read( ocean_sflx_mu(:,:), & ! [OUT]
403  restart_fid, var_name(i_sflx_mu), 'XY', step=1 ) ! [IN]
404  call fileio_read( ocean_sflx_mv(:,:), & ! [OUT]
405  restart_fid, var_name(i_sflx_mv), 'XY', step=1 ) ! [IN]
406  call fileio_read( ocean_sflx_sh(:,:), & ! [OUT]
407  restart_fid, var_name(i_sflx_sh), 'XY', step=1 ) ! [IN]
408  call fileio_read( ocean_sflx_lh(:,:), & ! [OUT]
409  restart_fid, var_name(i_sflx_lh), 'XY', step=1 ) ! [IN]
410  call fileio_read( ocean_sflx_wh(:,:), & ! [OUT]
411  restart_fid, var_name(i_sflx_wh), 'XY', step=1 ) ! [IN]
412  call fileio_read( ocean_sflx_evap(:,:), & ! [OUT]
413  restart_fid, var_name(i_sflx_evap), 'XY', step=1 ) ! [IN]
414 
415  if( io_aggregate ) call fileio_flush( restart_fid ) ! commit all pending read requests
416 
417  call ocean_vars_total
418  else
419  if( io_l ) write(io_fid_log,*) '*** invalid restart file ID for ocean.'
420  endif
421 
422  return
423  end subroutine ocean_vars_restart_read
424 
425  !-----------------------------------------------------------------------------
427  subroutine ocean_vars_history
428  use scale_history, only: &
429  hist_in
430  implicit none
431  !---------------------------------------------------------------------------
432 
433  if ( ocean_vars_checkrange ) then
434  call valcheck( ocean_temp(is:ie,js:je), 0.0_rp, 1000.0_rp, var_name(i_temp), &
435  __file__, __line__ )
436  call valcheck( ocean_sfc_temp(is:ie,js:je), 0.0_rp, 1000.0_rp, var_name(i_sfc_temp), &
437  __file__, __line__ )
438  call valcheck( ocean_sfc_albedo(is:ie,js:je,i_lw), 0.0_rp, 2.0_rp, var_name(i_alb_lw), &
439  __file__, __line__ )
440  call valcheck( ocean_sfc_albedo(is:ie,js:je,i_sw), 0.0_rp, 2.0_rp, var_name(i_alb_sw), &
441  __file__, __line__ )
442  call valcheck( ocean_sfc_z0m(is:ie,js:je), 0.0_rp, 1000.0_rp, var_name(i_sfc_z0m), &
443  __file__, __line__ )
444  call valcheck( ocean_sfc_z0h(is:ie,js:je), 0.0_rp, 1000.0_rp, var_name(i_sfc_z0h), &
445  __file__, __line__ )
446  call valcheck( ocean_sfc_z0e(is:ie,js:je), 0.0_rp, 1000.0_rp, var_name(i_sfc_z0e), &
447  __file__, __line__ )
448  endif
449 
450  call hist_in( ocean_temp(:,:), var_name(i_temp), var_desc(i_temp), var_unit(i_temp) )
451  call hist_in( ocean_sfc_temp(:,:), var_name(i_sfc_temp), var_desc(i_sfc_temp), var_unit(i_sfc_temp) )
452  call hist_in( ocean_sfc_albedo(:,:,i_lw), var_name(i_alb_lw), var_desc(i_alb_lw), var_unit(i_alb_lw) )
453  call hist_in( ocean_sfc_albedo(:,:,i_sw), var_name(i_alb_sw), var_desc(i_alb_sw), var_unit(i_alb_sw) )
454  call hist_in( ocean_sfc_z0m(:,:), var_name(i_sfc_z0m), var_desc(i_sfc_z0m), var_unit(i_sfc_z0m) )
455  call hist_in( ocean_sfc_z0h(:,:), var_name(i_sfc_z0h), var_desc(i_sfc_z0h), var_unit(i_sfc_z0h) )
456  call hist_in( ocean_sfc_z0e(:,:), var_name(i_sfc_z0e), var_desc(i_sfc_z0e), var_unit(i_sfc_z0e) )
457 
458  call hist_in( ocean_sflx_mw(:,:), var_name(i_sflx_mw), var_desc(i_sflx_mw), var_unit(i_sflx_mw) )
459  call hist_in( ocean_sflx_mu(:,:), var_name(i_sflx_mu), var_desc(i_sflx_mu), var_unit(i_sflx_mu) )
460  call hist_in( ocean_sflx_mv(:,:), var_name(i_sflx_mv), var_desc(i_sflx_mv), var_unit(i_sflx_mv) )
461  call hist_in( ocean_sflx_sh(:,:), var_name(i_sflx_sh), var_desc(i_sflx_sh), var_unit(i_sflx_sh) )
462  call hist_in( ocean_sflx_lh(:,:), var_name(i_sflx_lh), var_desc(i_sflx_lh), var_unit(i_sflx_lh) )
463  call hist_in( ocean_sflx_wh(:,:), var_name(i_sflx_wh), var_desc(i_sflx_wh), var_unit(i_sflx_wh) )
464  call hist_in( ocean_sflx_evap(:,:), var_name(i_sflx_evap), var_desc(i_sflx_evap), var_unit(i_sflx_evap) )
465 
466  return
467  end subroutine ocean_vars_history
468 
469  !-----------------------------------------------------------------------------
471  subroutine ocean_vars_total
472  use scale_rm_statistics, only: &
474  stat_total
475  implicit none
476 
477  real(RP) :: total
478  !---------------------------------------------------------------------------
479 
480  if ( statistics_checktotal ) then
481 
482  call stat_total( total, ocean_temp(:,:), var_name(i_temp) )
483  call stat_total( total, ocean_sfc_temp(:,:), var_name(i_sfc_temp) )
484  call stat_total( total, ocean_sfc_albedo(:,:,i_lw), var_name(i_alb_lw) )
485  call stat_total( total, ocean_sfc_albedo(:,:,i_sw), var_name(i_alb_sw) )
486  call stat_total( total, ocean_sfc_z0m(:,:), var_name(i_sfc_z0m) )
487  call stat_total( total, ocean_sfc_z0h(:,:), var_name(i_sfc_z0h) )
488  call stat_total( total, ocean_sfc_z0e(:,:), var_name(i_sfc_z0e) )
489 
490  call stat_total( total, ocean_sflx_mw(:,:), var_name(i_sflx_mw) )
491  call stat_total( total, ocean_sflx_mu(:,:), var_name(i_sflx_mu) )
492  call stat_total( total, ocean_sflx_mv(:,:), var_name(i_sflx_mv) )
493  call stat_total( total, ocean_sflx_sh(:,:), var_name(i_sflx_sh) )
494  call stat_total( total, ocean_sflx_lh(:,:), var_name(i_sflx_lh) )
495  call stat_total( total, ocean_sflx_wh(:,:), var_name(i_sflx_wh) )
496  call stat_total( total, ocean_sflx_evap(:,:), var_name(i_sflx_evap) )
497 
498  endif
499 
500  return
501  end subroutine ocean_vars_total
502 
503  !-----------------------------------------------------------------------------
505  subroutine ocean_vars_external_in( &
506  OCEAN_TEMP_in, &
507  OCEAN_SFC_TEMP_in, &
508  OCEAN_SFC_albedo_in, &
509  OCEAN_SFC_Z0M_in, &
510  OCEAN_SFC_Z0H_in, &
511  OCEAN_SFC_Z0E_in )
512  implicit none
513 
514  real(RP), intent(in) :: ocean_temp_in (ia,ja)
515  real(RP), intent(in) :: ocean_sfc_temp_in (ia,ja)
516  real(RP), intent(in) :: ocean_sfc_albedo_in(ia,ja,2)
517  real(RP), intent(in) :: ocean_sfc_z0m_in (ia,ja)
518  real(RP), intent(in) :: ocean_sfc_z0h_in (ia,ja)
519  real(RP), intent(in) :: ocean_sfc_z0e_in (ia,ja)
520  !---------------------------------------------------------------------------
521 
522  if( io_l ) write(io_fid_log,*)
523  if( io_l ) write(io_fid_log,*) '*** External Input file (ocean) ***'
524 
525  ocean_temp(:,:) = ocean_temp_in(:,:)
526  ocean_sfc_temp(:,:) = ocean_sfc_temp_in(:,:)
527  ocean_sfc_albedo(:,:,:) = ocean_sfc_albedo_in(:,:,:)
528  ocean_sfc_z0m(:,:) = ocean_sfc_z0m_in(:,:)
529  ocean_sfc_z0h(:,:) = ocean_sfc_z0h_in(:,:)
530  ocean_sfc_z0e(:,:) = ocean_sfc_z0e_in(:,:)
531 
532  ocean_sflx_mw(:,:) = 0.0_rp
533  ocean_sflx_mu(:,:) = 0.0_rp
534  ocean_sflx_mv(:,:) = 0.0_rp
535  ocean_sflx_sh(:,:) = 0.0_rp
536  ocean_sflx_lh(:,:) = 0.0_rp
537  ocean_sflx_wh(:,:) = 0.0_rp
538  ocean_sflx_evap(:,:) = 0.0_rp
539 
540  call ocean_vars_total
541 
542  return
543  end subroutine ocean_vars_external_in
544 
545  !-----------------------------------------------------------------------------
547  subroutine ocean_vars_restart_create
548  use scale_time, only: &
550  use scale_fileio, only: &
552  use mod_ocean_admin, only: &
553  ocean_sw
554  implicit none
555 
556  character(len=19) :: timelabel
557  character(len=H_LONG) :: basename
558  !---------------------------------------------------------------------------
559 
560  if ( ocean_sw .and. ocean_restart_out_basename /= '' ) then
561 
562  if( io_l ) write(io_fid_log,*)
563  if( io_l ) write(io_fid_log,*) '*** Create restart file (OCEAN) ***'
564 
566  call time_gettimelabel( timelabel )
567  basename = trim(ocean_restart_out_basename)//'_'//trim(timelabel)
568  else
569  basename = trim(ocean_restart_out_basename)
570  endif
571 
572  if( io_l ) write(io_fid_log,*) '*** basename: ', trim(basename)
573 
574  call fileio_create( restart_fid, & ! [OUT]
576 
577  endif
578 
579  return
580  end subroutine ocean_vars_restart_create
581 
582  !-----------------------------------------------------------------------------
584  subroutine ocean_vars_restart_enddef
585  use scale_fileio, only: &
587  implicit none
588 
589  if ( restart_fid /= -1 ) then
590  call fileio_enddef( restart_fid ) ! [IN]
591  endif
592 
593  return
594  end subroutine ocean_vars_restart_enddef
595 
596  !-----------------------------------------------------------------------------
598  subroutine ocean_vars_restart_close
599  use scale_fileio, only: &
601  implicit none
602  !---------------------------------------------------------------------------
603 
604  if ( restart_fid /= -1 ) then
605  if( io_l ) write(io_fid_log,*)
606  if( io_l ) write(io_fid_log,*) '*** Close restart file (OCEAN) ***'
607 
608  call fileio_close( restart_fid ) ! [IN]
609 
610  restart_fid = -1
611  endif
612 
613  return
614  end subroutine ocean_vars_restart_close
615 
616  !-----------------------------------------------------------------------------
618  subroutine ocean_vars_restart_def_var
619  use scale_fileio, only: &
621  implicit none
622  !---------------------------------------------------------------------------
623 
624  if ( restart_fid /= -1 ) then
625 
626  call fileio_def_var( restart_fid, var_id(i_temp), var_name(i_temp), var_desc(i_temp), &
627  var_unit(i_temp), 'XY', ocean_restart_out_dtype)
628  call fileio_def_var( restart_fid, var_id(i_sfc_temp), var_name(i_sfc_temp), var_desc(i_sfc_temp), &
629  var_unit(i_sfc_temp), 'XY', ocean_restart_out_dtype)
630  call fileio_def_var( restart_fid, var_id(i_alb_lw), var_name(i_alb_lw), var_desc(i_alb_lw), &
631  var_unit(i_alb_lw), 'XY', ocean_restart_out_dtype)
632  call fileio_def_var( restart_fid, var_id(i_alb_sw), var_name(i_alb_sw), var_desc(i_alb_sw), &
633  var_unit(i_alb_sw), 'XY', ocean_restart_out_dtype)
634  call fileio_def_var( restart_fid, var_id(i_sfc_z0m), var_name(i_sfc_z0m), var_desc(i_sfc_z0m), &
635  var_unit(i_sfc_z0m), 'XY', ocean_restart_out_dtype)
636  call fileio_def_var( restart_fid, var_id(i_sfc_z0h), var_name(i_sfc_z0h), var_desc(i_sfc_z0h), &
637  var_unit(i_sfc_z0h), 'XY', ocean_restart_out_dtype)
638  call fileio_def_var( restart_fid, var_id(i_sfc_z0e), var_name(i_sfc_z0e), var_desc(i_sfc_z0e), &
639  var_unit(i_sfc_z0e), 'XY', ocean_restart_out_dtype)
640  call fileio_def_var( restart_fid, var_id(i_sflx_mw), var_name(i_sflx_mw), var_desc(i_sflx_mw), &
641  var_unit(i_sflx_mw), 'XY', ocean_restart_out_dtype)
642  call fileio_def_var( restart_fid, var_id(i_sflx_mu), var_name(i_sflx_mu), var_desc(i_sflx_mu), &
643  var_unit(i_sflx_mu), 'XY', ocean_restart_out_dtype)
644  call fileio_def_var( restart_fid, var_id(i_sflx_mv), var_name(i_sflx_mv), var_desc(i_sflx_mv), &
645  var_unit(i_sflx_mv), 'XY', ocean_restart_out_dtype)
646  call fileio_def_var( restart_fid, var_id(i_sflx_sh), var_name(i_sflx_sh), var_desc(i_sflx_sh), &
647  var_unit(i_sflx_sh), 'XY', ocean_restart_out_dtype)
648  call fileio_def_var( restart_fid, var_id(i_sflx_lh), var_name(i_sflx_lh), var_desc(i_sflx_lh), &
649  var_unit(i_sflx_lh), 'XY', ocean_restart_out_dtype)
650  call fileio_def_var( restart_fid, var_id(i_sflx_wh), var_name(i_sflx_wh), var_desc(i_sflx_wh), &
651  var_unit(i_sflx_wh), 'XY', ocean_restart_out_dtype)
652  call fileio_def_var( restart_fid, var_id(i_sflx_evap), var_name(i_sflx_evap), var_desc(i_sflx_evap), &
653  var_unit(i_sflx_evap), 'XY', ocean_restart_out_dtype)
654 
655  endif
656 
657  return
658  end subroutine ocean_vars_restart_def_var
659 
660  !-----------------------------------------------------------------------------
662  subroutine ocean_vars_restart_write
663  use scale_fileio, only: &
664  fileio_write_var
665  implicit none
666  !---------------------------------------------------------------------------
667 
668  if ( restart_fid /= -1 ) then
669 
670  call ocean_vars_total
671 
672  call fileio_write_var( restart_fid, var_id(i_temp), ocean_temp(:,:), & ! [IN]
673  var_name(i_temp), 'XY', nohalo=.true. ) ! [IN]
674  call fileio_write_var( restart_fid, var_id(i_sfc_temp), ocean_sfc_temp(:,:), & ! [IN]
675  var_name(i_sfc_temp), 'XY', nohalo=.true. ) ! [IN]
676  call fileio_write_var( restart_fid, var_id(i_alb_lw), ocean_sfc_albedo(:,:,i_lw), & ! [IN]
677  var_name(i_alb_lw), 'XY', nohalo=.true. ) ! [IN]
678  call fileio_write_var( restart_fid, var_id(i_alb_sw), ocean_sfc_albedo(:,:,i_sw), & ! [IN]
679  var_name(i_alb_sw), 'XY', nohalo=.true. ) ! [IN]
680  call fileio_write_var( restart_fid, var_id(i_sfc_z0m), ocean_sfc_z0m(:,:), & ! [IN]
681  var_name(i_sfc_z0m), 'XY', nohalo=.true. ) ! [IN]
682  call fileio_write_var( restart_fid, var_id(i_sfc_z0h), ocean_sfc_z0h(:,:), & ! [IN]
683  var_name(i_sfc_z0h), 'XY', nohalo=.true. ) ! [IN]
684  call fileio_write_var( restart_fid, var_id(i_sfc_z0e), ocean_sfc_z0e(:,:), & ! [IN]
685  var_name(i_sfc_z0e), 'XY', nohalo=.true. ) ! [IN]
686  call fileio_write_var( restart_fid, var_id(i_sflx_mw), ocean_sflx_mw(:,:), & ! [IN]
687  var_name(i_sflx_mw), 'XY', nohalo=.true. ) ! [IN]
688  call fileio_write_var( restart_fid, var_id(i_sflx_mu), ocean_sflx_mu(:,:), & ! [IN]
689  var_name(i_sflx_mu), 'XY', nohalo=.true. ) ! [IN]
690  call fileio_write_var( restart_fid, var_id(i_sflx_mv), ocean_sflx_mv(:,:), & ! [IN]
691  var_name(i_sflx_mv), 'XY', nohalo=.true. ) ! [IN]
692  call fileio_write_var( restart_fid, var_id(i_sflx_sh), ocean_sflx_sh(:,:), & ! [IN]
693  var_name(i_sflx_sh), 'XY', nohalo=.true. ) ! [IN]
694  call fileio_write_var( restart_fid, var_id(i_sflx_lh), ocean_sflx_lh(:,:), & ! [IN]
695  var_name(i_sflx_lh), 'XY', nohalo=.true. ) ! [IN]
696  call fileio_write_var( restart_fid, var_id(i_sflx_wh), ocean_sflx_wh(:,:), & ! [IN]
697  var_name(i_sflx_wh), 'XY', nohalo=.true. ) ! [IN]
698  call fileio_write_var( restart_fid, var_id(i_sflx_evap), ocean_sflx_evap(:,:), & ! [IN]
699  var_name(i_sflx_evap), 'XY', nohalo=.true. ) ! [IN]
700 
701  endif
702 
703  return
704  end subroutine ocean_vars_restart_write
705 
706 end module mod_ocean_vars
real(rp), dimension(:,:), allocatable, public ocean_v10
ocean surface velocity v at 10m [m/s]
integer, public is
start point of inner domain: x, local
module DEBUG
Definition: scale_debug.F90:13
logical, public ocean_sw
real(rp), dimension(:,:), allocatable, public atmos_w
logical, public statistics_checktotal
calc&report variable totals to logfile?
real(rp), dimension(:,:), allocatable, public ocean_sfc_temp_t
tendency of OCEAN_SFC_TEMP
integer, public je
end point of inner domain: y, local
real(rp), dimension(:,:), allocatable, public ocean_sfc_z0e_t
tendency of OCEAN_SFC_Z0E
real(rp), dimension(:,:,:), allocatable, public ocean_sfc_albedo
ocean surface albedo (0-1)
real(rp), dimension(:,:), allocatable, public atmos_dens
integer, public const_i_lw
long-wave radiation index
Definition: scale_const.F90:95
subroutine, public prc_mpistop
Abort MPI.
subroutine, public ocean_vars_restart_open
Open ocean restart file for read.
real(rp), dimension(:,:,:), allocatable, public ocean_sfc_albedo_t
tendency of OCEAN_SFC_alebdo
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:61
real(rp), dimension(:,:), allocatable, public ocean_sfc_z0e
ocean surface roughness length for vapor [m]
real(rp), dimension(:,:), allocatable, public ocean_temp
temperature at uppermost ocean layer [K]
subroutine, public ocean_vars_restart_write
Write ocean variables to restart file.
subroutine, public fileio_flush(fid)
Flush all pending requests to a netCDF file (PnetCDF only)
real(rp), dimension(:,:), allocatable, public atmos_v
subroutine, public ocean_vars_history
History output set for ocean variables.
module STDIO
Definition: scale_stdio.F90:12
character(len=h_short), public ocean_restart_out_dtype
REAL4 or REAL8.
real(rp), dimension(:,:), allocatable, public ocean_sflx_wh
ocean surface water heat flux [J/m2/s]
subroutine, public ocean_vars_restart_def_var
Define ocean variables in restart file.
real(rp), dimension(:,:), allocatable, public atmos_sflx_lw
subroutine, public ocean_vars_restart_enddef
Exit netCDF define mode.
module FILE I/O (netcdf)
real(rp), dimension(:,:), allocatable, public ocean_temp_t
tendency of OCEAN_TEMP
real(rp), public const_undef
Definition: scale_const.F90:43
module Statistics
subroutine, public ocean_vars_restart_create
Create ocean restart file.
module grid index
logical, public io_nml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:62
real(rp), dimension(:,:), allocatable, public atmos_cossza
integer, public ia
of whole cells: x, local, with HALO
real(rp), dimension(:,:), allocatable, public ocean_sflx_mv
ocean surface v-momentum flux [kg/m2/s]
subroutine, public time_gettimelabel(timelabel)
generate time label
Definition: scale_time.F90:90
real(rp), dimension(:,:), allocatable, public atmos_sfc_pres
real(rp), dimension(:,:), allocatable, public atmos_qv
logical, public ocean_restart_out_postfix_timelabel
Add timelabel to the basename of output file?
subroutine, public ocean_vars_total
Budget monitor for ocean.
subroutine, public fileio_create(fid, basename, title, datatype, date, subsec, append, nozcoord)
Create/open a netCDF file.
real(rp), dimension(:,:), allocatable, public ocean_sfc_z0h_t
tendency of OCEAN_SFC_Z0H
logical, public ocean_restart_in_postfix_timelabel
Add timelabel to the basename of input file?
integer, public js
start point of inner domain: y, local
module TIME
Definition: scale_time.F90:15
module PROCESS
real(rp), dimension(:,:), allocatable, public atmos_sflx_prec
module Ocean admin
subroutine, public ocean_vars_external_in(OCEAN_TEMP_in, OCEAN_SFC_TEMP_in, OCEAN_SFC_albedo_in, OCEAN_SFC_Z0M_in, OCEAN_SFC_Z0H_in, OCEAN_SFC_Z0E_in)
Input from External I/O.
real(rp), dimension(:,:), allocatable, public atmos_temp
subroutine, public ocean_vars_restart_read
Read ocean restart.
real(rp), dimension(:,:), allocatable, public ocean_sflx_mw
ocean surface w-momentum flux [kg/m2/s]
module CONSTANT
Definition: scale_const.F90:14
real(rp), dimension(:,:), allocatable, public ocean_sflx_mu
ocean surface u-momentum flux [kg/m2/s]
real(rp), dimension(:,:), allocatable, public ocean_q2
ocean surface water vapor at 2m [kg/kg]
subroutine, public fileio_enddef(fid)
Exit netCDF file define mode.
real(rp), dimension(:,:), allocatable, public atmos_u
module profiler
Definition: scale_prof.F90:10
integer, public ie
end point of inner domain: x, local
real(rp), dimension(:,:), allocatable, public atmos_sflx_sw
real(rp), dimension(:,:), allocatable, public ocean_sfc_z0m
ocean surface roughness length for momentum [m]
real(rp), dimension(:,:), allocatable, public atmos_pbl
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.
subroutine, public ocean_vars_setup
Setup.
real(rp), dimension(:,:), allocatable, public ocean_sflx_sh
ocean surface sensible heat flux [J/m2/s]
character(len=h_long), public ocean_restart_in_basename
Basename of the input file.
module HISTORY
real(rp), dimension(:,:), allocatable, public ocean_sfc_temp
ocean surface skin temperature [K]
subroutine, public fileio_close(fid)
Close a netCDF file.
character(len=h_long), public ocean_restart_out_basename
Basename of the output file.
integer, public io_fid_conf
Config file ID.
Definition: scale_stdio.F90:55
real(rp), dimension(:,:), allocatable, public ocean_sfc_z0m_t
tendency of OCEAN_SFC_Z0M
logical, public ocean_restart_output
Output restart file?
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
subroutine, public ocean_vars_restart_close
Close restart file.
real(rp), dimension(:,:), allocatable, public atmos_pres
real(rp), dimension(:,:), allocatable, public ocean_sflx_lh
ocean surface latent heat flux [J/m2/s]
real(rp), dimension(:,:), allocatable, public ocean_u10
ocean surface velocity u at 10m [m/s]
real(rp), dimension(:,:), allocatable, public ocean_sflx_evap
ocean surface water vapor flux [kg/m2/s]
real(rp), dimension(:,:), allocatable, public ocean_sfc_z0h
ocean surface roughness length for heat [m]
real(rp), dimension(:,:), allocatable, public ocean_t2
ocean surface temperature at 2m [K]
module OCEAN Variables
integer, public io_fid_nml
Log file ID (only for output namelist)
Definition: scale_stdio.F90:57
character(len=h_mid), public ocean_restart_out_title
Title of the output file.
integer, public ja
of whole cells: y, local, with HALO