SCALE-RM
Data Types | Functions/Subroutines | Variables
scale_file_external_input Module Reference

module file / external_input More...

Functions/Subroutines

subroutine, public file_external_input_setup
 Setup. More...
 
subroutine, public file_external_input_regist (basename, varname, axistype, enable_periodic_year, enable_periodic_month, enable_periodic_day, step_fixed, offset, defval, check_coordinates, step_limit, exist)
 Regist data. More...
 
subroutine file_external_input_update_1d (varname, time_current, var, error)
 Read data. More...
 
subroutine file_external_input_update_2d (varname, time_current, var, error)
 Read data. More...
 
subroutine file_external_input_update_3d (varname, time_current, var, error)
 Read data. More...
 

Variables

procedure(get_dims1d), pointer, public file_external_input_get_dims1d => NULL()
 
procedure(get_dims2d), pointer, public file_external_input_get_dims2d => NULL()
 
procedure(get_dims3d), pointer, public file_external_input_get_dims3d => NULL()
 
integer, parameter, public file_external_input_file_limit = 100
 limit of file (for one item) More...
 

Detailed Description

module file / external_input

Description
External file input module
Author
Team SCALE
NAMELIST
  • EXTERNAL_ITEM
    nametypedefault valuecomment
    BASENAME character(len=*), dimension(FILE_EXTERNAL_INPUT_FILE_LIMIT)
    VARNAME character(len=*) item name
    AXISTYPE character(len=*)
    STEP_LIMIT integer limit number for reading data
    STEP_FIXED integer fixed step position to read
    ENABLE_PERIODIC_YEAR logical treat as yearly periodic data?
    ENABLE_PERIODIC_MONTH logical treat as yearly,monthly periodic data?
    ENABLE_PERIODIC_DAY logical treat as yearly,monthly,daily periodic data?
    OFFSET real(RP)
    DEFVAL real(RP)
    CHECK_COORDINATES logical

History Output
No history output

Function/Subroutine Documentation

◆ file_external_input_setup()

subroutine, public scale_file_external_input::file_external_input_setup ( )

Setup.

Definition at line 166 of file scale_file_external_input.F90.

References scale_const::const_undef, file_external_input_regist(), scale_io::io_fid_conf, and scale_prc::prc_abort().

Referenced by scale_file_external_input_cartesc::file_external_input_cartesc_setup().

166  use scale_prc, only: &
167  prc_abort
168  use scale_const, only: &
169  undef => const_undef
170  implicit none
171 
172  character(len=H_LONG) :: basename(file_external_input_file_limit)
173  character(len=H_SHORT) :: varname
174  character(len=H_SHORT) :: axistype
175  integer :: step_limit ! limit number for reading data
176  integer :: step_fixed ! fixed step position to read
177  logical :: enable_periodic_year ! treat as yearly periodic data?
178  logical :: enable_periodic_month ! treat as yearly,monthly periodic data?
179  logical :: enable_periodic_day ! treat as yearly,monthly,daily periodic data?
180  real(RP) :: offset
181  real(RP) :: defval
182  logical :: check_coordinates
183 
184  namelist / external_item / &
185  basename, &
186  varname, &
187  axistype, &
188  step_limit, &
189  step_fixed, &
190  enable_periodic_year, &
191  enable_periodic_month, &
192  enable_periodic_day, &
193  offset, &
194  defval, &
195  check_coordinates
196 
197  integer :: count
198  integer :: ierr
199  !---------------------------------------------------------------------------
200 
201  log_newline
202  log_info("FILE_EXTERNAL_INPUT_setup",*) 'Setup'
203 
204  ! count external data from namelist
205  rewind(io_fid_conf)
206  do count = 1, file_external_input_item_limit
207  ! set default
208  step_limit = file_external_input_step_limit
209  basename(:) = ''
210  varname = ''
211  axistype = ''
212  step_fixed = -1
213  enable_periodic_year = .false.
214  enable_periodic_month = .false.
215  enable_periodic_day = .false.
216  offset = 0.0_rp
217  defval = undef
218  check_coordinates = .false.
219 
220  ! read namelist
221  read(io_fid_conf,nml=external_item,iostat=ierr)
222  if ( ierr < 0 ) then !--- no more items
223  exit
224  elseif( ierr > 0 ) then !--- fatal error
225  log_error("FILE_EXTERNAL_INPUT_setup",*) 'Not appropriate names in namelist EXTERNAL_ITEM. Check!', count
226  call prc_abort
227  endif
228  log_nml(external_item)
229 
230  call file_external_input_regist( basename(:), & ! [IN]
231  varname, & ! [IN]
232  axistype, & ! [IN]
233  enable_periodic_year, & ! [IN]
234  enable_periodic_month, & ! [IN]
235  enable_periodic_day, & ! [IN]
236  step_fixed, & ! [IN]
237  offset, & ! [IN]
238  defval, & ! [IN]
239  check_coordinates, & ! [IN]
240  step_limit ) ! [IN]
241  enddo
242 
243  return
integer, public io_fid_conf
Config file ID.
Definition: scale_io.F90:55
real(rp), public const_undef
Definition: scale_const.F90:41
module PROCESS
Definition: scale_prc.F90:11
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:338
module CONSTANT
Definition: scale_const.F90:11
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_external_input_regist()

subroutine, public scale_file_external_input::file_external_input_regist ( character(len=*), dimension(file_external_input_file_limit), intent(in)  basename,
character(len=*), intent(in)  varname,
character(len=*), intent(in)  axistype,
logical, intent(in)  enable_periodic_year,
logical, intent(in)  enable_periodic_month,
logical, intent(in)  enable_periodic_day,
integer, intent(in)  step_fixed,
real(rp), intent(in)  offset,
real(rp), intent(in)  defval,
logical, intent(in), optional  check_coordinates,
integer, intent(in), optional  step_limit,
logical, intent(out), optional  exist 
)

Regist data.

Definition at line 261 of file scale_file_external_input.F90.

References scale_calendar::calendar_adjust_daysec(), scale_calendar::calendar_cfunits2sec(), scale_calendar::calendar_combine_daysec(), scale_calendar::calendar_date2daysec(), scale_calendar::calendar_daysec2date(), file_external_input_file_limit, file_external_input_get_dims1d, file_external_input_get_dims2d, file_external_input_get_dims3d, scale_file_h::file_fread, scale_file::file_open(), scale_calendar::i_day, scale_calendar::i_month, scale_calendar::i_year, scale_prc::prc_abort(), scale_prc::prc_myrank, scale_time::time_nowdaysec, scale_time::time_offset_year, and scale_time::time_startdaysec.

Referenced by scale_atmos_phy_rd_offline::atmos_phy_rd_offline_setup(), file_external_input_setup(), scale_land_dyn_bucket::land_dyn_bucket_setup(), scale_ocean_dyn_offline::ocean_dyn_offline_setup(), scale_ocean_dyn_slab::ocean_dyn_slab_setup(), and scale_ocean_phy_ice_simple::ocean_phy_ice_setup().

261  use scale_file_h, only: &
262  file_fread
263  use scale_file, only: &
264  file_open, &
265  file_get_all_datainfo, &
266  file_read
267  use scale_prc, only: &
268  prc_myrank, &
269  prc_abort
270  use scale_calendar, only: &
276  i_year, &
277  i_month, &
278  i_day
279  use scale_time, only: &
281  time_nowdaysec, &
283  use scale_file_cartesc, only: &
284  file_cartesc_check_coordinates
285  implicit none
286 
287  character(len=*), intent(in) :: basename(file_external_input_file_limit)
288  character(len=*), intent(in) :: varname
289  character(len=*), intent(in) :: axistype
290  integer, intent(in) :: step_fixed ! fixed step position to read
291  logical, intent(in) :: enable_periodic_year ! treat as yearly periodic data?
292  logical, intent(in) :: enable_periodic_month ! treat as yearly,monthly periodic data?
293  logical, intent(in) :: enable_periodic_day ! treat as yearly,monthly,daily periodic data?
294  real(RP), intent(in) :: offset
295  real(RP), intent(in) :: defval
296 
297  logical, intent(in), optional :: check_coordinates
298  integer, intent(in), optional :: step_limit ! limit number for reading data
299  logical, intent(out), optional :: exist
300 
301  integer :: step_nmax
302  character(len=H_MID) :: description
303  character(len=H_SHORT) :: unit
304  character(len=H_MID) :: standard_name
305  integer :: datatype
306  integer :: dim_rank
307  character(len=H_SHORT) :: dim_name (file_external_input_dim_limit)
308  integer :: dim_size (file_external_input_dim_limit)
309  integer :: natts
310  character(len=H_SHORT) :: att_name (file_external_input_att_limit)
311  integer :: att_type (file_external_input_att_limit)
312  integer :: att_len (file_external_input_att_limit)
313  real(DP) :: time_start(file_external_input_step_limit)
314  real(DP) :: time_end (file_external_input_step_limit)
315  character(len=H_MID) :: time_units
316  character(len=H_SHORT) :: calendar
317 
318  integer :: datadate(6)
319  real(DP) :: datasubsec
320  integer :: dataday
321  real(DP) :: datasec
322  integer :: offset_year
323 
324  integer :: dim1_max, dim1_s, dim1_e
325  integer :: dim2_max, dim2_s, dim2_e
326  integer :: dim3_max, dim3_s, dim3_e
327 
328  integer :: step_limit_
329 
330  integer :: fid
331  integer :: nid, n
332  !---------------------------------------------------------------------------
333 
334  if ( present(step_limit) ) then
335  if ( step_limit > 0 ) then
336  step_limit_ = step_limit
337  else
338  step_limit_ = file_external_input_step_limit
339  endif
340  else
341  step_limit_ = file_external_input_step_limit
342  endif
343 
344  do nid = 1, file_external_input_item_count
345  if ( file_external_input_item(nid)%varname == varname ) then
346  log_error("FILE_EXTERNAL_INPUT_regist",*) 'Data is already registered! basename,varname = ', trim(basename(1)), ', ', trim(varname)
347  call prc_abort
348  endif
349  enddo
350 
351  file_external_input_item_count = file_external_input_item_count + 1
352 
353  if ( file_external_input_item_count > file_external_input_item_limit ) then
354  log_error("FILE_EXTERNAL_INPUT_regist",*) 'Number of EXT data exceedes the limit', file_external_input_item_count, file_external_input_item_limit
355  call prc_abort
356  endif
357 
358  call file_open( basename(1), & ! [IN]
359  fid, & ! [OUT]
360  rankid=prc_myrank ) ! [IN]
361 
362  ! read from file
363  call file_get_all_datainfo( fid, varname, & ! [IN]
364  step_nmax, & ! [OUT]
365  description, unit, standard_name, & ! [OUT]
366  datatype, & ! [OUT]
367  dim_rank, dim_name(:), dim_size(:), & ! [OUT]
368  natts, att_name(:), att_type(:), att_len(:), & ! [OUT]
369  time_start(1:step_limit_), time_end(1:step_limit_), & ! [OUT]
370  time_units, calendar ) ! [OUT]
371 
372  if ( step_nmax > 0 ) then
373  if ( present(exist) ) then
374  exist = .true.
375  endif
376  else
377  if ( present(exist) ) then
378  exist = .false.
379  return
380  else
381  log_error("FILE_EXTERNAL_INPUT_regist",*) 'Data not found! basename,varname = ', trim(basename(1)), ', ', trim(varname)
382  call prc_abort
383  endif
384  endif
385 
386  do n = dim_rank+1, 3
387  dim_size(n) = 1
388  enddo
389 
390  nid = file_external_input_item_count
391 
392  do n = 1, file_external_input_file_limit
393  if( basename(n) == '' ) exit
394  enddo
395  file_external_input_item(nid)%nfile = n - 1
396  file_external_input_item(nid)%file_current = 1
397  file_external_input_item(nid)%data_step_offset = 0
398 
399  allocate( file_external_input_item(nid)%basename(file_external_input_item(nid)%nfile) )
400  file_external_input_item(nid)%basename(1:file_external_input_item(nid)%nfile) = basename(1:file_external_input_item(nid)%nfile)
401 
402  ! setup item
403  file_external_input_item(nid)%fid = fid
404  file_external_input_item(nid)%varname = varname
405  file_external_input_item(nid)%dim_size(:) = dim_size(:)
406  file_external_input_item(nid)%step_num = step_nmax
407  file_external_input_item(nid)%step_limit = step_limit_
408 
409  if ( enable_periodic_day ) then
410  file_external_input_item(nid)%flag_periodic = i_periodic_day
411  elseif( enable_periodic_month ) then
412  file_external_input_item(nid)%flag_periodic = i_periodic_month
413  elseif( enable_periodic_year ) then
414  file_external_input_item(nid)%flag_periodic = i_periodic_year
415  else
416  file_external_input_item(nid)%flag_periodic = 0
417  endif
418 
419  allocate( file_external_input_item(nid)%value(dim_size(1),dim_size(2),dim_size(3),2) )
420  file_external_input_item(nid)%value(:,:,:,:) = defval
421  file_external_input_item(nid)%offset = offset
422 
423  allocate( file_external_input_item(nid)%time(step_limit_) )
424  file_external_input_item(nid)%time(:) = 0.0_dp
425 
426  do n = 1, file_external_input_item(nid)%step_num
427  file_external_input_item(nid)%time(n) = calendar_cfunits2sec( time_end(n), time_units, time_offset_year, time_startdaysec )
428  enddo
429 
430  if ( file_external_input_item(nid)%step_num == 1 ) then
431 
432  file_external_input_item(nid)%fixed_step = .true.
433  file_external_input_item(nid)%data_step_prev = 1
434  file_external_input_item(nid)%data_step_next = 1
435 
436  else if ( step_fixed > 0 ) then ! fixed time step mode
437 
438  file_external_input_item(nid)%fixed_step = .true.
439  file_external_input_item(nid)%data_step_prev = step_fixed
440  file_external_input_item(nid)%data_step_next = step_fixed
441 
442  else
443 
444  file_external_input_item(nid)%fixed_step = .false.
445 
446  ! seek start position
447  file_external_input_item(nid)%data_step_next = 1
448  do n = 1, file_external_input_item(nid)%step_num
449  if ( file_external_input_item(nid)%time(n) > time_nowdaysec ) exit
450  file_external_input_item(nid)%data_step_next = n + 1
451  enddo
452 
453  file_external_input_item(nid)%data_step_prev = file_external_input_item(nid)%data_step_next - 1
454 
455  if ( file_external_input_item(nid)%flag_periodic > 0 ) then ! periodic time step mode
456 
457  if ( file_external_input_item(nid)%data_step_next == 1 ) then ! between first-1 and first
458 
459  ! first-1 = last
460  file_external_input_item(nid)%data_step_prev = file_external_input_item(nid)%step_num
461 
462  elseif( file_external_input_item(nid)%data_step_next == file_external_input_item(nid)%step_num+1 ) then ! between last and last+1
463 
464  ! last+1 = first
465  file_external_input_item(nid)%data_step_next = 1
466 
467  ! update data time in periodic condition
468  do n = 1, file_external_input_item(nid)%step_num
469  dataday = 0
470  datasec = file_external_input_item(nid)%time(n)
471  offset_year = 0
472  call calendar_adjust_daysec( dataday, datasec ) ! [INOUT]
473 
474  call calendar_daysec2date( datadate(:), & ! [OUT]
475  datasubsec, & ! [OUT]
476  dataday, & ! [IN]
477  datasec, & ! [IN]
478  offset_year ) ! [IN]
479 
480  if ( file_external_input_item(nid)%flag_periodic == i_periodic_day ) then
481  datadate(i_day) = datadate(i_day) + 1
482  elseif( file_external_input_item(nid)%flag_periodic == i_periodic_month ) then
483  datadate(i_month) = datadate(i_month) + 1
484  elseif( file_external_input_item(nid)%flag_periodic == i_periodic_year ) then
485  datadate(i_year) = datadate(i_year) + 1
486  endif
487 
488  call calendar_date2daysec( dataday, & ! [OUT]
489  datasec, & ! [OUT]
490  datadate(:), & ! [IN]
491  datasubsec, & ! [IN]
492  offset_year ) ! [IN]
493 
494  file_external_input_item(nid)%time(n) = calendar_combine_daysec( dataday, datasec )
495  enddo
496 
497  log_info("FILE_EXTERNAL_INPUT_regist",*) 'data time is updated.'
498  endif
499 
500  else ! normal mode
501 
502  if ( file_external_input_item(nid)%data_step_next == 1 &
503  .OR. file_external_input_item(nid)%data_step_next == file_external_input_item(nid)%step_num+1 ) then
504  log_error("FILE_EXTERNAL_INPUT_regist",*) 'Current time is out of period of external data! ', trim(varname)
505  call prc_abort
506  endif
507 
508  endif
509 
510  endif
511 
512  !--- read first data
513  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A15)') 'Initial read of external data : ', trim(varname)
514 
515  if ( dim_size(1) >= 1 &
516  .AND. dim_size(2) == 1 &
517  .AND. dim_size(3) == 1 ) then ! 1D
518 
519  call file_external_input_get_dims1d( dim1_max, dim1_s, dim1_e, & ! [OUT]
520  varname, axistype ) ! [IN]
521 
522  file_external_input_item(nid)%ndim = 1
523  file_external_input_item(nid)%transpose = .false.
524  allocate( file_external_input_item(nid)%dim_start(1) )
525  file_external_input_item(nid)%dim_start(1) = dim1_s
526 
527  if ( dim1_max /= dim_size(1) ) then
528  log_error("FILE_EXTERNAL_INPUT_regist",*) 'data length does not match! ', trim(axistype), ' item:', trim(varname)
529  log_error_cont(*) 'dim 1 (data,requested) : ', dim_size(1), dim1_max
530  call prc_abort
531  endif
532 
533  ! read prev
534  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
535  'Read 1D var : ', trim(file_external_input_item(nid)%varname), &
536  ' (step= ', file_external_input_item(nid)%data_step_prev, ')'
537 
538  call file_read( file_external_input_item(nid)%fid, & ! [IN]
539  file_external_input_item(nid)%varname, & ! [IN]
540  file_external_input_item(nid)%value(:,1,1,i_prev), & ! [OUT]
541  step=file_external_input_item(nid)%data_step_prev ) ! [IN]
542  ! read next
543  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
544  'Read 1D var : ', trim(file_external_input_item(nid)%varname), &
545  ' (step= ', file_external_input_item(nid)%data_step_next, ')'
546 
547  call file_read( file_external_input_item(nid)%fid, & ! [IN]
548  file_external_input_item(nid)%varname, & ! [IN]
549  file_external_input_item(nid)%value(:,1,1,i_next), & ! [OUT]
550  step=file_external_input_item(nid)%data_step_next ) ! [IN]
551 
552  elseif( dim_size(1) >= 1 &
553  .AND. dim_size(2) > 1 &
554  .AND. dim_size(3) == 1 ) then ! 2D
555 
556  call file_external_input_get_dims2d( dim1_max, dim1_s, dim1_e, & ! [OUT]
557  dim2_max, dim2_s, dim2_e, & ! [OUT]
558  file_external_input_item(nid)%transpose, & ! [OUT]
559  varname, axistype ) ! [IN]
560 
561  file_external_input_item(nid)%ndim = 2
562  allocate( file_external_input_item(nid)%dim_start(2) )
563  file_external_input_item(nid)%dim_start(1) = dim1_s
564  file_external_input_item(nid)%dim_start(2) = dim2_s
565 
566  if ( dim1_max /= dim_size(1) &
567  .OR. dim2_max /= dim_size(2) ) then
568  log_error("FILE_EXTERNAL_INPUT_regist",*) 'data length does not match! ', trim(axistype), ' item:', trim(varname)
569  log_error_cont(*) 'dim 1 (data,requested) : ', dim_size(1), dim1_max
570  log_error_cont(*) 'dim 2 (data,requested) : ', dim_size(2), dim2_max
571  call prc_abort
572  endif
573 
574  ! read prev
575  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
576  'Read 2D var : ', trim(file_external_input_item(nid)%varname), &
577  ' (step= ', file_external_input_item(nid)%data_step_prev, ')'
578 
579  call file_read( file_external_input_item(nid)%fid, & ! [IN]
580  file_external_input_item(nid)%varname, & ! [IN]
581  file_external_input_item(nid)%value(:,:,1,i_prev), & ! [OUT]
582  step=file_external_input_item(nid)%data_step_prev ) ! [IN]
583  ! read next
584  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
585  'Read 2D var : ', trim(file_external_input_item(nid)%varname), &
586  ' (step= ', file_external_input_item(nid)%data_step_next, ')'
587 
588  call file_read( file_external_input_item(nid)%fid, & ! [IN]
589  file_external_input_item(nid)%varname, & ! [IN]
590  file_external_input_item(nid)%value(:,:,1,i_next), & ! [OUT]
591  step=file_external_input_item(nid)%data_step_next ) ! [IN]
592 
593  elseif( dim_size(1) >= 1 &
594  .AND. dim_size(2) > 1 &
595  .AND. dim_size(3) > 1 ) then ! 3D
596 
597  call file_external_input_get_dims3d( dim1_max, dim1_s, dim1_e, & ! [OUT]
598  dim2_max, dim2_s, dim2_e, & ! [OUT]
599  dim3_max, dim3_s, dim3_e, & ! [OUT]
600  file_external_input_item(nid)%transpose, & ! [OUT]
601  varname, axistype ) ! [IN]
602 
603  file_external_input_item(nid)%ndim = 3
604  allocate( file_external_input_item(nid)%dim_start(3) )
605  file_external_input_item(nid)%dim_start(1) = dim1_s
606  file_external_input_item(nid)%dim_start(2) = dim2_s
607  file_external_input_item(nid)%dim_start(3) = dim3_s
608 
609  if ( dim1_max /= dim_size(1) &
610  .OR. dim2_max /= dim_size(2) &
611  .OR. dim3_max /= dim_size(3) ) then
612  log_error("FILE_EXTERNAL_INPUT_regist",*) 'data length does not match! ', trim(axistype), ' item:', trim(varname)
613  log_error_cont(*) 'dim 1 (data,requested) : ', dim_size(1), dim1_max
614  log_error_cont(*) 'dim 2 (data,requested) : ', dim_size(2), dim2_max
615  log_error_cont(*) 'dim 3 (data,requested) : ', dim_size(3), dim3_max
616  call prc_abort
617  endif
618 
619  ! read prev
620  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
621  'Read 3D var : ', trim(file_external_input_item(nid)%varname), &
622  ' (step= ', file_external_input_item(nid)%data_step_prev, ')'
623 
624  call file_read( file_external_input_item(nid)%fid, & ! [IN]
625  file_external_input_item(nid)%varname, & ! [IN]
626  file_external_input_item(nid)%value(:,:,:,i_prev), & ! [OUT]
627  step=file_external_input_item(nid)%data_step_prev ) ! [IN]
628 
629  ! read next
630  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
631  'Read 3D var : ', trim(file_external_input_item(nid)%varname), &
632  ' (step= ', file_external_input_item(nid)%data_step_next, ')'
633 
634  call file_read( file_external_input_item(nid)%fid, & ! [IN]
635  file_external_input_item(nid)%varname, & ! [IN]
636  file_external_input_item(nid)%value(:,:,:,i_next), & ! [OUT]
637  step=file_external_input_item(nid)%data_step_next ) ! [IN]
638 
639  else
640  log_error("FILE_EXTERNAL_INPUT_regist",*) 'Unexpected dimsize: ', dim_size(:)
641  call prc_abort
642  endif
643 
644  if ( present(check_coordinates) ) then
645  if ( check_coordinates ) then
646  call file_cartesc_check_coordinates( fid, &
647  atmos = file_external_input_item(nid)%ndim==3, &
648  transpose = file_external_input_item(nid)%transpose )
649  endif
650  endif
651 
652  return
integer, parameter, public i_month
[index] month
integer, parameter, public i_year
[index] year
real(dp) function, public calendar_combine_daysec(absday, abssec)
Combine day and second.
real(dp), public time_nowdaysec
second of current time [sec]
Definition: scale_time.F90:73
real(dp), public time_startdaysec
second of start time [sec]
Definition: scale_time.F90:78
subroutine, public file_open(basename, fid, mode, single, aggregate, rankid, postfix)
Definition: scale_file.F90:464
module file
Definition: scale_file.F90:15
subroutine, public calendar_adjust_daysec(absday, abssec)
Adjust day and second.
integer, parameter, public file_fread
real(dp) function, public calendar_cfunits2sec(cftime, cfunits, offset_year, startdaysec)
Convert time in units of the CF convention to second.
integer, public time_offset_year
time offset [year]
Definition: scale_time.F90:77
module PROCESS
Definition: scale_prc.F90:11
module TIME
Definition: scale_time.F90:16
integer, public prc_myrank
process num in local communicator
Definition: scale_prc.F90:89
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:338
integer, parameter, public i_day
[index] day
subroutine, public calendar_daysec2date(ymdhms, subsec, absday, abssec, offset_year)
Convert from gregorian date to absolute day/second.
module file / cartesianC
module CALENDAR
subroutine, public calendar_date2daysec(absday, abssec, ymdhms, subsec, offset_year)
Convert from gregorian date to absolute day/second.
module file_h
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_external_input_update_1d()

subroutine scale_file_external_input::file_external_input_update_1d ( character(len=*), intent(in)  varname,
real(dp), intent(in)  time_current,
real(rp), dimension(:), intent(out)  var,
logical, intent(out)  error 
)

Read data.

Definition at line 662 of file scale_file_external_input.F90.

References scale_prc::prc_abort().

662  use scale_file, only: &
663  file_read
664  use scale_prc, only: &
665  prc_abort
666  implicit none
667  character(len=*), intent(in) :: varname ! item name
668  real(DP), intent(in) :: time_current ! current time
669  real(RP), intent(out) :: var(:) ! variable
670  logical, intent(out) :: error ! error code
671 
672  integer :: nid
673  real(RP) :: weight
674  logical :: do_readfile
675  integer :: step_next
676 
677  integer :: n
678  integer :: n1
679  integer :: nn1
680  !---------------------------------------------------------------------------
681 
682  error = .true.
683 
684  ! searching the data ID
685  nid = -1
686  do n = 1, file_external_input_item_count
687  if( varname == file_external_input_item(n)%varname ) nid = n
688  enddo
689 
690  if ( nid == 0 ) then
691  log_info("FILE_EXTERNAL_INPUT_update_1D",*) 'Variable was not registered: ', trim(varname)
692  return
693  endif
694 
695  if ( file_external_input_item(nid)%ndim /= 1 ) then
696  log_error("FILE_EXTERNAL_INPUT_update_1D",*) 'Data is not 1D var: ', trim(file_external_input_item(nid)%varname)
697  call prc_abort
698  endif
699 
700  call file_external_input_time_advance( nid, & ! [IN]
701  time_current, & ! [IN]
702  weight, & ! [OUT]
703  do_readfile ) ! [OUT]
704 
705  if ( do_readfile ) then
706  step_next = file_external_input_item(nid)%data_step_next - file_external_input_item(nid)%data_step_offset
707 
708  log_info("FILE_EXTERNAL_INPUT_update_1D",'(1x,A,A,A,I4,A,I4,A)') &
709  'Read 1D var : ', trim(file_external_input_item(nid)%varname), &
710  ' (step= ', file_external_input_item(nid)%data_step_next, ', file step=', step_next, ')'
711 
712  ! next -> prev
713  file_external_input_item(nid)%value(:,:,:,i_prev) = file_external_input_item(nid)%value(:,:,:,i_next)
714 
715  ! read next
716  call file_read( file_external_input_item(nid)%fid, & ! [IN]
717  file_external_input_item(nid)%varname, & ! [IN]
718  file_external_input_item(nid)%value(:,1,1,i_next), & ! [OUT]
719  step=step_next ) ! [IN]
720  endif
721 
722  ! store data with weight
723  do n1 = 1, file_external_input_item(nid)%dim_size(1)
724  nn1 = n1 + file_external_input_item(nid)%dim_start(1) - 1
725 
726  var(nn1) = ( 1.0_rp-weight ) * file_external_input_item(nid)%value(n1,1,1,i_prev) &
727  + ( weight ) * file_external_input_item(nid)%value(n1,1,1,i_next)
728  enddo
729 
730  error = .false.
731 
732  return
module file
Definition: scale_file.F90:15
module PROCESS
Definition: scale_prc.F90:11
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:338
Here is the call graph for this function:

◆ file_external_input_update_2d()

subroutine scale_file_external_input::file_external_input_update_2d ( character(len=*), intent(in)  varname,
real(dp), intent(in)  time_current,
real(rp), dimension(:,:), intent(out)  var,
logical, intent(out)  error 
)

Read data.

Definition at line 742 of file scale_file_external_input.F90.

742  use scale_file, only: &
743  file_read
744  implicit none
745  character(len=*), intent(in) :: varname ! item name
746  real(DP), intent(in) :: time_current ! current time
747  real(RP), intent(out) :: var(:,:) ! variable
748  logical, intent(out) :: error ! error code
749 
750  integer :: nid
751  real(RP) :: weight
752  logical :: do_readfile
753  integer :: step_next
754 
755  integer :: n
756  integer :: n1, n2
757  integer :: nn1, nn2
758  !---------------------------------------------------------------------------
759 
760  error = .true.
761 
762  ! searching the data ID
763  nid = -1
764  do n = 1, file_external_input_item_count
765  if( varname == file_external_input_item(n)%varname ) nid = n
766  enddo
767 
768  if ( nid == 0 ) then
769  log_info("FILE_EXTERNAL_INPUT_update_2D",*) 'Variable was not registered: ', trim(varname)
770  return
771  endif
772 
773  call file_external_input_time_advance( nid, & ! [IN]
774  time_current, & ! [IN]
775  weight, & ! [OUT]
776  do_readfile ) ! [OUT]
777 
778  if ( do_readfile ) then
779 
780  step_next = file_external_input_item(nid)%data_step_next - file_external_input_item(nid)%data_step_offset
781 
782  log_info("FILE_EXTERNAL_INPUT_update_2D",'(1x,A,A,A,I4,A,I4,A)') &
783  'Read 2D var : ', trim(file_external_input_item(nid)%varname), &
784  ' (step= ', file_external_input_item(nid)%data_step_next, ', file step=', step_next, ')'
785 
786  ! next -> prev
787  file_external_input_item(nid)%value(:,:,:,i_prev) = file_external_input_item(nid)%value(:,:,:,i_next)
788 
789  ! read next
790  call file_read( file_external_input_item(nid)%fid, & ! [IN]
791  file_external_input_item(nid)%varname, & ! [IN]
792  file_external_input_item(nid)%value(:,:,1,i_next), & ! [OUT]
793  step=step_next ) ! [IN]
794  endif
795 
796  if ( file_external_input_item(nid)%transpose ) then
797  ! store data with weight (x,z)->(z,x)
798  do n1 = 1, file_external_input_item(nid)%dim_size(1)
799  nn1 = n1 + file_external_input_item(nid)%dim_start(1) - 1
800 
801  do n2 = 1, file_external_input_item(nid)%dim_size(2)
802  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
803 
804  var(nn2,nn1) = ( 1.0_rp-weight ) * file_external_input_item(nid)%value(n1,n2,1,i_prev) &
805  + ( weight ) * file_external_input_item(nid)%value(n1,n2,1,i_next)
806  enddo
807  enddo
808  else
809  ! store data with weight
810  do n2 = 1, file_external_input_item(nid)%dim_size(2)
811  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
812 
813  do n1 = 1, file_external_input_item(nid)%dim_size(1)
814  nn1 = n1 + file_external_input_item(nid)%dim_start(1) - 1
815 
816  var(nn1,nn2) = ( 1.0_rp-weight ) * file_external_input_item(nid)%value(n1,n2,1,i_prev) &
817  + ( weight ) * file_external_input_item(nid)%value(n1,n2,1,i_next)
818  enddo
819  enddo
820  endif
821 
822  error = .false.
823 
824  return
module file
Definition: scale_file.F90:15

◆ file_external_input_update_3d()

subroutine scale_file_external_input::file_external_input_update_3d ( character(len=*), intent(in)  varname,
real(dp), intent(in)  time_current,
real(rp), dimension(:,:,:), intent(out)  var,
logical, intent(out)  error 
)

Read data.

Definition at line 834 of file scale_file_external_input.F90.

References scale_calendar::calendar_adjust_daysec(), scale_calendar::calendar_cfunits2sec(), scale_calendar::calendar_combine_daysec(), scale_calendar::calendar_date2daysec(), scale_calendar::calendar_daysec2date(), scale_file_h::file_fread, scale_file::file_open(), scale_calendar::i_day, scale_calendar::i_month, scale_calendar::i_year, scale_prc::prc_abort(), scale_prc::prc_myrank, scale_time::time_offset_year, and scale_time::time_startdaysec.

834  use scale_file, only: &
835  file_read
836  implicit none
837  character(len=*), intent(in) :: varname ! item name
838  real(DP), intent(in) :: time_current ! current time
839  real(RP), intent(out) :: var(:,:,:) ! variable
840  logical, intent(out) :: error ! error code
841 
842  integer :: nid
843  real(RP) :: weight
844  logical :: do_readfile
845  integer :: step_next
846 
847  integer :: n
848  integer :: n1, n2, n3
849  integer :: nn1, nn2, nn3
850  !---------------------------------------------------------------------------
851 
852  error = .true.
853 
854  ! searching the data ID
855  nid = -1
856  do n = 1, file_external_input_item_count
857  if( varname == file_external_input_item(n)%varname ) nid = n
858  enddo
859 
860  if ( nid == 0 ) then
861  log_info("FILE_EXTERNAL_INPUT_update_3D",*) 'Variable was not registered: ', trim(varname)
862  return
863  endif
864 
865  call file_external_input_time_advance( nid, & ! [IN]
866  time_current, & ! [IN]
867  weight, & ! [OUT]
868  do_readfile ) ! [OUT]
869 
870  if ( do_readfile ) then
871 
872  step_next = file_external_input_item(nid)%data_step_next - file_external_input_item(nid)%data_step_offset
873 
874  log_info("FILE_EXTERNAL_INPUT_update_3D",'(1x,A,A,A,I4,A,I4,A)') &
875  'Read 3D var : ', trim(file_external_input_item(nid)%varname), &
876  ' (step= ', file_external_input_item(nid)%data_step_next, ', file step=', step_next, ')'
877 
878  ! next -> prev
879  file_external_input_item(nid)%value(:,:,:,i_prev) = file_external_input_item(nid)%value(:,:,:,i_next)
880 
881  ! read next
882  call file_read( file_external_input_item(nid)%fid, & ! [IN]
883  file_external_input_item(nid)%varname, & ! [IN]
884  file_external_input_item(nid)%value(:,:,:,i_next), & ! [OUT]
885  step=step_next ) ! [IN]
886  endif
887 
888  if ( file_external_input_item(nid)%transpose ) then
889  ! store data with weight (x,y,z)->(z,x,y)
890  do n2 = 1, file_external_input_item(nid)%dim_size(2)
891  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
892 
893  do n1 = 1, file_external_input_item(nid)%dim_size(1)
894  nn1 = n1 + file_external_input_item(nid)%dim_start(1) - 1
895 
896  do n3 = 1, file_external_input_item(nid)%dim_size(3)
897  nn3 = n3 + file_external_input_item(nid)%dim_start(3) - 1
898 
899  var(nn3,nn1,nn2) = ( 1.0_rp-weight ) * file_external_input_item(nid)%value(n1,n2,n3,i_prev) &
900  + ( weight ) * file_external_input_item(nid)%value(n1,n2,n3,i_next)
901  enddo
902  enddo
903  enddo
904  else
905  ! store data with weight (z,x,y)->(z,x,y)
906  do n3 = 1, file_external_input_item(nid)%dim_size(3)
907  nn3 = n3 + file_external_input_item(nid)%dim_start(3) - 1
908 
909  do n2 = 1, file_external_input_item(nid)%dim_size(2)
910  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
911 
912  do n1 = 1, file_external_input_item(nid)%dim_size(1)
913  nn1 = n1 + file_external_input_item(nid)%dim_start(1) - 1
914 
915  var(nn1,nn2,nn3) = ( 1.0_rp-weight ) * file_external_input_item(nid)%value(n1,n2,n3,i_prev) &
916  + ( weight ) * file_external_input_item(nid)%value(n1,n2,n3,i_next)
917  enddo
918  enddo
919  enddo
920  endif
921 
922  error = .false.
923 
924  return
module file
Definition: scale_file.F90:15
Here is the call graph for this function:

Variable Documentation

◆ file_external_input_get_dims1d

procedure(get_dims1d), pointer, public scale_file_external_input::file_external_input_get_dims1d => NULL()

Definition at line 100 of file scale_file_external_input.F90.

Referenced by scale_file_external_input_cartesc::file_external_input_cartesc_setup(), and file_external_input_regist().

100  procedure(get_dims1d), pointer :: file_external_input_get_dims1d => null()

◆ file_external_input_get_dims2d

procedure(get_dims2d), pointer, public scale_file_external_input::file_external_input_get_dims2d => NULL()

Definition at line 101 of file scale_file_external_input.F90.

Referenced by scale_file_external_input_cartesc::file_external_input_cartesc_setup(), and file_external_input_regist().

101  procedure(get_dims2d), pointer :: file_external_input_get_dims2d => null()

◆ file_external_input_get_dims3d

procedure(get_dims3d), pointer, public scale_file_external_input::file_external_input_get_dims3d => NULL()

Definition at line 102 of file scale_file_external_input.F90.

Referenced by scale_file_external_input_cartesc::file_external_input_cartesc_setup(), and file_external_input_regist().

102  procedure(get_dims3d), pointer :: file_external_input_get_dims3d => null()

◆ file_external_input_file_limit

integer, parameter, public scale_file_external_input::file_external_input_file_limit = 100