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

module file / external_input More...

Data Types

interface  read2D
 
interface  read3D
 

Functions/Subroutines

subroutine, public file_external_input_setup
 Setup. More...
 
subroutine, public file_external_input_finalize
 finalize More...
 
subroutine file_external_input_regist_external_1d (varname, var, axistype, step_nmax, time_now, time_step, aggregate, allow_missing)
 Regist external data. More...
 
subroutine file_external_input_regist_external_2d (varname, var, axistype, step_nmax, time_now, time_step, aggregate, allow_missing)
 Regist external data. More...
 
subroutine file_external_input_regist_external_3d (varname, var, axistype, step_nmax, time_now, time_step, aggregate, allow_missing)
 Regist external data. More...
 
subroutine file_external_input_regist_file (basename, basename_add_num, number_of_files, varname, axistype, enable_periodic_year, enable_periodic_month, enable_periodic_day, step_fixed, defval, check_coordinates, aggregate, allow_missing, step_limit, update_dt, 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...
 
subroutine file_external_input_put_ref_1d (varname, var, error)
 Put reference data. More...
 
subroutine file_external_input_put_ref_2d (varname, var, error)
 
subroutine file_external_input_put_ref_3d (varname, var, error)
 
subroutine file_external_input_get_ref_1d (varname, var, error, i_step)
 Get reference data. More...
 
subroutine, public file_external_input_query (varname, time_current, do_readdata)
 Check time to read. More...
 
integer function file_external_input_getid (varname)
 

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()
 
procedure(read1d), pointer, public file_external_input_read_1d => NULL()
 
procedure(read2d), pointer, public file_external_input_read_2d => NULL()
 
procedure(read3d), pointer, public file_external_input_read_3d => NULL()
 
integer, parameter, public i_prev = 1
 [index] previous More...
 
integer, parameter, public i_next = 2
 [index] next More...
 

Detailed Description

module file / external_input

Description
External file input module
Author
Team SCALE
NAMELIST
  • EXTERNAL_ITEM
    nametypedefault valuecomment
    BASENAME character(len=*)
    BASENAME_ADD_NUM logical
    NUMBER_OF_FILES integer
    VARNAME character(len=*)
    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?
    DEFVAL real(RP)
    CHECK_COORDINATES logical
    FILE_AGGREGATE logical
    ALLOW_MISSING 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 236 of file scale_file_external_input.F90.

236  use scale_prc, only: &
237  prc_abort
238  use scale_const, only: &
239  undef => const_undef
240  use scale_file, only: &
241  file_aggregate_default => file_aggregate
242  implicit none
243 
244  character(len=H_LONG) :: basename
245  logical :: basename_add_num
246  integer :: number_of_files
247  character(len=H_SHORT) :: varname
248  character(len=H_SHORT) :: axistype
249  integer :: step_limit ! limit number for reading data
250  integer :: step_fixed ! fixed step position to read
251  logical :: enable_periodic_year ! treat as yearly periodic data?
252  logical :: enable_periodic_month ! treat as yearly,monthly periodic data?
253  logical :: enable_periodic_day ! treat as yearly,monthly,daily periodic data?
254  real(RP) :: defval
255  logical :: check_coordinates
256  logical :: file_aggregate
257  logical :: allow_missing
258 
259  namelist / external_item / &
260  basename, &
261  basename_add_num, &
262  number_of_files, &
263  varname, &
264  axistype, &
265  step_limit, &
266  step_fixed, &
267  enable_periodic_year, &
268  enable_periodic_month, &
269  enable_periodic_day, &
270  defval, &
271  check_coordinates, &
272  file_aggregate, &
273  allow_missing
274 
275  integer :: count
276  integer :: ierr
277  !---------------------------------------------------------------------------
278 
279  log_newline
280  log_info("FILE_EXTERNAL_INPUT_setup",*) 'Setup'
281 
282  ! count external data from namelist
283  rewind(io_fid_conf)
284  do count = 1, file_external_input_item_limit
285  ! set default
286  step_limit = file_external_input_step_limit
287  basename = ''
288  basename_add_num = .false.
289  number_of_files = 1
290  varname = ''
291  axistype = ''
292  step_fixed = -1
293  enable_periodic_year = .false.
294  enable_periodic_month = .false.
295  enable_periodic_day = .false.
296  defval = undef
297  check_coordinates = .false.
298  file_aggregate = file_aggregate_default
299  allow_missing = .false.
300 
301  ! read namelist
302  read(io_fid_conf,nml=external_item,iostat=ierr)
303  if ( ierr < 0 ) then !--- no more items
304  exit
305  elseif( ierr > 0 ) then !--- fatal error
306  log_error("FILE_EXTERNAL_INPUT_setup",*) 'Not appropriate names in namelist EXTERNAL_ITEM. Check!', count
307  call prc_abort
308  endif
309  log_nml(external_item)
310 
311  call file_external_input_regist( basename, & ! [IN]
312  basename_add_num, & ! [IN]
313  number_of_files, & ! [IN]
314  varname, & ! [IN]
315  axistype, & ! [IN]
316  enable_periodic_year, & ! [IN]
317  enable_periodic_month, & ! [IN]
318  enable_periodic_day, & ! [IN]
319  step_fixed, & ! [IN]
320  defval, & ! [IN]
321  check_coordinates = check_coordinates, & ! [IN]
322  aggregate = file_aggregate, & ! [IN]
323  allow_missing = allow_missing, & ! [IN]
324  step_limit = step_limit ) ! [IN]
325  enddo
326 
327  !$acc enter data create(FILE_EXTERNAL_INPUT_item)
328 
329  return

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

Referenced by scale_file_external_input_cartesc::file_external_input_cartesc_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_external_input_finalize()

subroutine, public scale_file_external_input::file_external_input_finalize

finalize

Definition at line 335 of file scale_file_external_input.F90.

335  implicit none
336 
337  integer :: id
338 
339  log_newline
340  log_info("FILE_EXTERNAL_INPUT_finalize",*) 'Finalize'
341 
342  do id = 1, file_external_input_item_count
343  !$acc exit data delete(FILE_EXTERNAL_INPUT_item(id)%value)
344  deallocate( file_external_input_item(id)%value )
345  deallocate( file_external_input_item(id)%time )
346  if ( allocated( file_external_input_item(id)%basename ) ) &
347  deallocate( file_external_input_item(id)%basename )
348  end do
349 
350  !$acc exit data delete(FILE_EXTERNAL_INPUT_item)
351  file_external_input_item_count = 0
352 
353  return

References file_external_input_get_dims1d, file_external_input_get_dims2d, file_external_input_get_dims3d, file_external_input_getid(), and scale_prc::prc_abort().

Referenced by scale_file_external_input_cartesc::file_external_input_cartesc_finalize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_external_input_regist_external_1d()

subroutine scale_file_external_input::file_external_input_regist_external_1d ( character(len=*), intent(in)  varname,
real(rp), dimension(:), intent(in)  var,
character(len=*), intent(in)  axistype,
integer, intent(in)  step_nmax,
real(dp), intent(in)  time_now,
real(dp), intent(in)  time_step,
logical, intent(in), optional  aggregate,
logical, intent(in), optional  allow_missing 
)

Regist external data.

Definition at line 628 of file scale_file_external_input.F90.

628  use scale_const, only: &
629  undef => const_undef
630  implicit none
631  character(len=*), intent(in) :: varname
632  real(RP), intent(in) :: var(:)
633  character(len=*), intent(in) :: axistype
634  integer, intent(in) :: step_nmax
635  real(DP), intent(in) :: time_now
636  real(DP), intent(in) :: time_step
637  logical, intent(in), optional :: aggregate
638  logical, intent(in), optional :: allow_missing
639 
640  integer :: dim_size(1)
641  logical :: error
642  !---------------------------------------------------------------------------
643 
644  call file_external_input_init_var( &
645  varname, &
646  axistype, &
647  aggregate, &
648  allow_missing )
649 
650  dim_size(:) = shape( var )
651 
652  call file_external_input_regist_var( &
653  varname, &
654  axistype, &
655  1, &
656  dim_size(:), &
657  step_nmax, &
658  1, &
659  time_now, &
660  time_step, &
661  undef )
662 
663  call file_external_input_put_ref_1d( &
664  varname, &
665  var(:), &
666  error )
667 
668  return

References scale_const::const_undef, and file_external_input_put_ref_1d().

Here is the call graph for this function:

◆ file_external_input_regist_external_2d()

subroutine scale_file_external_input::file_external_input_regist_external_2d ( character(len=*), intent(in)  varname,
real(rp), dimension(:,:), intent(in)  var,
character(len=*), intent(in)  axistype,
integer, intent(in)  step_nmax,
real(dp), intent(in)  time_now,
real(dp), intent(in)  time_step,
logical, intent(in), optional  aggregate,
logical, intent(in), optional  allow_missing 
)

Regist external data.

Definition at line 682 of file scale_file_external_input.F90.

682  use scale_const, only: &
683  undef => const_undef
684  implicit none
685  character(len=*), intent(in) :: varname
686  real(RP), intent(in) :: var(:,:)
687  character(len=*), intent(in) :: axistype
688  integer, intent(in) :: step_nmax
689  real(DP), intent(in) :: time_now
690  real(DP), intent(in) :: time_step
691  logical, intent(in), optional :: aggregate
692  logical, intent(in), optional :: allow_missing
693 
694  integer :: dim_size(2)
695  logical :: error
696  !---------------------------------------------------------------------------
697 
698  call file_external_input_init_var( &
699  varname, &
700  axistype, &
701  aggregate, &
702  allow_missing )
703 
704  dim_size(:) = shape( var )
705 
706  call file_external_input_regist_var( &
707  varname, &
708  axistype, &
709  2, &
710  dim_size(:), &
711  step_nmax, &
712  1, &
713  time_now, &
714  time_step, &
715  undef )
716 
717  call file_external_input_put_ref_2d( &
718  varname, &
719  var(:,:), &
720  error )
721 
722  return

References scale_const::const_undef, and file_external_input_put_ref_2d().

Here is the call graph for this function:

◆ file_external_input_regist_external_3d()

subroutine scale_file_external_input::file_external_input_regist_external_3d ( character(len=*), intent(in)  varname,
real(rp), dimension(:,:,:), intent(in)  var,
character(len=*), intent(in)  axistype,
integer, intent(in)  step_nmax,
real(dp), intent(in)  time_now,
real(dp), intent(in)  time_step,
logical, intent(in), optional  aggregate,
logical, intent(in), optional  allow_missing 
)

Regist external data.

Definition at line 736 of file scale_file_external_input.F90.

736  use scale_const, only: &
737  undef => const_undef
738  implicit none
739  character(len=*), intent(in) :: varname
740  real(RP), intent(in) :: var(:,:,:)
741  character(len=*), intent(in) :: axistype
742  integer, intent(in) :: step_nmax
743  real(DP), intent(in) :: time_now
744  real(DP), intent(in) :: time_step
745  logical, intent(in), optional :: aggregate
746  logical, intent(in), optional :: allow_missing
747 
748  integer :: dim_size(3)
749  logical :: error
750  !---------------------------------------------------------------------------
751 
752  call file_external_input_init_var( &
753  varname, &
754  axistype, &
755  aggregate, &
756  allow_missing )
757 
758  dim_size(:) = shape( var )
759 
760  call file_external_input_regist_var( &
761  varname, &
762  axistype, &
763  3, &
764  dim_size(:), &
765  step_nmax, &
766  1, &
767  time_now, &
768  time_step, &
769  undef )
770 
771  call file_external_input_put_ref_3d( &
772  varname, &
773  var(:,:,:), &
774  error )
775 
776  return

References scale_const::const_undef, and file_external_input_put_ref_3d().

Here is the call graph for this function:

◆ file_external_input_regist_file()

subroutine scale_file_external_input::file_external_input_regist_file ( character(len=*), intent(in)  basename,
logical, intent(in)  basename_add_num,
integer, intent(in)  number_of_files,
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)  defval,
logical, intent(in), optional  check_coordinates,
logical, intent(in), optional  aggregate,
logical, intent(in), optional  allow_missing,
integer, intent(in), optional  step_limit,
real(dp), intent(out), optional  update_dt,
logical, intent(out), optional  exist 
)

Regist data.

Definition at line 798 of file scale_file_external_input.F90.

798  use scale_file_h, only: &
799  file_fread
800  use scale_file, only: &
801  file_aggregate, &
802  file_open, &
803  file_get_all_datainfo, &
804  file_read
805  use scale_prc, only: &
806  prc_myrank, &
807  prc_abort
808  use scale_calendar, only: &
814  i_year, &
815  i_month, &
816  i_day
817  use scale_time, only: &
819  time_nowdaysec, &
821  use scale_file_cartesc, only: &
822  file_cartesc_check_coordinates
823  implicit none
824 
825  character(len=*), intent(in) :: basename
826  logical, intent(in) :: basename_add_num
827  integer, intent(in) :: number_of_files
828  character(len=*), intent(in) :: varname
829  character(len=*), intent(in) :: axistype
830  integer, intent(in) :: step_fixed ! fixed step position to read
831  logical, intent(in) :: enable_periodic_year ! treat as yearly periodic data?
832  logical, intent(in) :: enable_periodic_month ! treat as yearly,monthly periodic data?
833  logical, intent(in) :: enable_periodic_day ! treat as yearly,monthly,daily periodic data?
834  real(RP), intent(in) :: defval
835 
836  logical, intent(in), optional :: check_coordinates
837  logical, intent(in), optional :: aggregate
838  logical, intent(in), optional :: allow_missing
839  integer, intent(in), optional :: step_limit ! limit number for reading data
840  real(DP), intent(out), optional :: update_dt
841  logical, intent(out), optional :: exist
842 
843  integer :: step_nmax
844  character(len=H_MID) :: description
845  character(len=H_SHORT) :: unit
846  character(len=H_MID) :: standard_name
847  integer :: datatype
848  integer :: dim_rank
849  character(len=H_SHORT) :: dim_name (FILE_EXTERNAL_INPUT_dim_limit)
850  integer :: dim_size (FILE_EXTERNAL_INPUT_dim_limit)
851  integer :: natts
852  character(len=H_SHORT) :: att_name (FILE_EXTERNAL_INPUT_att_limit)
853  integer :: att_type (FILE_EXTERNAL_INPUT_att_limit)
854  integer :: att_len (FILE_EXTERNAL_INPUT_att_limit)
855  real(DP) :: time_start(FILE_EXTERNAL_INPUT_step_limit)
856  real(DP) :: time_end (FILE_EXTERNAL_INPUT_step_limit)
857  character(len=H_MID) :: time_units
858  character(len=H_SHORT) :: calendar
859 
860  integer :: datadate(6)
861  real(DP) :: datasubsec
862  integer :: dataday
863  real(DP) :: datasec
864  integer :: offset_year
865 
866  character(len=H_LONG) :: filename
867 
868  logical :: aggregate_
869  integer :: step_limit_
870 
871  real(RP), allocatable :: buf(:,:,:)
872 
873  logical :: error
874 
875  integer :: fid
876  integer :: nid, n
877  !---------------------------------------------------------------------------
878 
879  if ( present(aggregate) ) then
880  aggregate_ = aggregate
881  else
882  aggregate_ = file_aggregate
883  end if
884 
885  if ( present(step_limit) ) then
886  if ( step_limit > 0 ) then
887  step_limit_ = step_limit
888  else
889  step_limit_ = file_external_input_step_limit
890  endif
891  else
892  step_limit_ = file_external_input_step_limit
893  endif
894 
895  call file_external_input_init_var( &
896  varname, &
897  axistype, &
898  aggregate_, &
899  allow_missing )
900 
901 
902  nid = file_external_input_item_count
903 
904  file_external_input_item(nid)%file = .true.
905  file_external_input_item(nid)%nfile = number_of_files
906  file_external_input_item(nid)%file_current = 1
907  file_external_input_item(nid)%data_step_offset = 0
908  file_external_input_item(nid)%step_limit = step_limit_
909 
910  allocate( file_external_input_item(nid)%basename(number_of_files) )
911  if ( number_of_files > 1 .or. basename_add_num ) then
912  do n = 1, number_of_files
913  write(filename,'(A,A,I5.5)') trim(basename), '_', n - 1
914  file_external_input_item(nid)%basename(n) = filename
915  enddo
916  else
917  file_external_input_item(nid)%basename(1) = basename
918  end if
919 
920 
921  filename = file_external_input_item(nid)%basename(1)
922  call file_open( filename, & ! [IN]
923  fid, & ! [OUT]
924  aggregate=aggregate_, & ! [IN]
925  rankid=prc_myrank ) ! [IN]
926 
927  ! read from file
928  call file_get_all_datainfo( fid, varname, & ! [IN]
929  step_nmax, & ! [OUT]
930  description, unit, standard_name, & ! [OUT]
931  datatype, & ! [OUT]
932  dim_rank, dim_name(:), dim_size(:), & ! [OUT]
933  natts, att_name(:), att_type(:), att_len(:), & ! [OUT]
934  time_start(1:step_limit_), time_end(1:step_limit_), & ! [OUT]
935  time_units, calendar ) ! [OUT]
936 
937  if ( step_nmax > 0 ) then
938  if ( present(exist) ) then
939  exist = .true.
940  endif
941  else
942  if ( present(exist) ) then
943  exist = .false.
944  return
945  else
946  log_error("FILE_EXTERNAL_INPUT_regist",*) 'Data not found! filename,varname = ', trim(filename), ', ', trim(varname)
947  call prc_abort
948  endif
949  endif
950 
951  do n = dim_rank+1, 3
952  dim_size(n) = 1
953  enddo
954 
955  file_external_input_item(nid)%fid = fid
956 
957  if ( enable_periodic_day ) then
958  file_external_input_item(nid)%flag_periodic = i_periodic_day
959  elseif( enable_periodic_month ) then
960  file_external_input_item(nid)%flag_periodic = i_periodic_month
961  elseif( enable_periodic_year ) then
962  file_external_input_item(nid)%flag_periodic = i_periodic_year
963  endif
964 
965  call file_external_input_regist_var( &
966  varname, &
967  axistype, &
968  dim_rank, &
969  dim_size(:), &
970  step_nmax, &
971  number_of_files, &
972  0.0_dp, 0.0_dp, &
973  defval )
974 
975  do n = 1, file_external_input_item(nid)%step_num
976  file_external_input_item(nid)%time(n) = calendar_cfunits2sec( time_end(n), time_units, time_offset_year, time_startdaysec )
977  enddo
978 
979  if ( file_external_input_item(nid)%step_num == 1 ) then
980 
981  file_external_input_item(nid)%fixed_step = .true.
982  file_external_input_item(nid)%data_step_prev = 1
983  file_external_input_item(nid)%data_step_next = 1
984 
985  else if ( step_fixed > 0 ) then ! fixed time step mode
986 
987  file_external_input_item(nid)%fixed_step = .true.
988  file_external_input_item(nid)%data_step_prev = step_fixed
989  file_external_input_item(nid)%data_step_next = step_fixed
990 
991  else
992 
993  ! seek start position
994  file_external_input_item(nid)%data_step_next = 1
995  do n = 1, file_external_input_item(nid)%step_num
996  if ( file_external_input_item(nid)%time(n) > time_nowdaysec ) exit
997  file_external_input_item(nid)%data_step_next = n + 1
998  enddo
999 
1000  file_external_input_item(nid)%data_step_prev = file_external_input_item(nid)%data_step_next - 1
1001 
1002  if ( file_external_input_item(nid)%flag_periodic > 0 ) then ! periodic time step mode
1003 
1004  if ( file_external_input_item(nid)%data_step_next == 1 ) then ! between first-1 and first
1005 
1006  ! first-1 = last
1007  file_external_input_item(nid)%data_step_prev = file_external_input_item(nid)%step_num
1008 
1009  elseif( file_external_input_item(nid)%data_step_next == file_external_input_item(nid)%step_num+1 ) then ! between last and last+1
1010 
1011  ! last+1 = first
1012  file_external_input_item(nid)%data_step_next = 1
1013 
1014  ! update data time in periodic condition
1015  do n = 1, file_external_input_item(nid)%step_num
1016  dataday = 0
1017  datasec = file_external_input_item(nid)%time(n)
1018  offset_year = 0
1019  call calendar_adjust_daysec( dataday, datasec ) ! [INOUT]
1020 
1021  call calendar_daysec2date( datadate(:), & ! [OUT]
1022  datasubsec, & ! [OUT]
1023  dataday, & ! [IN]
1024  datasec, & ! [IN]
1025  offset_year ) ! [IN]
1026 
1027  if ( file_external_input_item(nid)%flag_periodic == i_periodic_day ) then
1028  datadate(i_day) = datadate(i_day) + 1
1029  elseif( file_external_input_item(nid)%flag_periodic == i_periodic_month ) then
1030  datadate(i_month) = datadate(i_month) + 1
1031  elseif( file_external_input_item(nid)%flag_periodic == i_periodic_year ) then
1032  datadate(i_year) = datadate(i_year) + 1
1033  endif
1034 
1035  call calendar_date2daysec( dataday, & ! [OUT]
1036  datasec, & ! [OUT]
1037  datadate(:), & ! [IN]
1038  datasubsec, & ! [IN]
1039  offset_year ) ! [IN]
1040 
1041  file_external_input_item(nid)%time(n) = calendar_combine_daysec( dataday, datasec )
1042  enddo
1043 
1044  log_info("FILE_EXTERNAL_INPUT_regist",*) 'data time is updated.'
1045  endif
1046 
1047  else ! normal mode
1048 
1049  if ( file_external_input_item(nid)%data_step_next == 1 &
1050  .OR. file_external_input_item(nid)%data_step_next == file_external_input_item(nid)%step_num+1 ) then
1051  log_error("FILE_EXTERNAL_INPUT_regist",*) 'Current time is out of period of external data! ', trim(varname)
1052  call prc_abort
1053  endif
1054 
1055  endif
1056 
1057  endif
1058 
1059  !--- read first data
1060  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A15)') 'Initial read of external data : ', trim(varname)
1061 
1062  allocate( buf(file_external_input_item(nid)%var_size(1),file_external_input_item(nid)%var_size(2),file_external_input_item(nid)%var_size(3)) )
1063  !$acc data create(buf)
1064 
1065  select case ( dim_rank )
1066  case ( 1 )
1067 
1068  ! read prev
1069  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
1070  'Read 1D var : ', trim(file_external_input_item(nid)%varname), &
1071  ' (step= ', file_external_input_item(nid)%data_step_prev, ')'
1072 
1073  if ( file_external_input_item(nid)%aggregate ) then
1074  call file_external_input_read_1d( file_external_input_item(nid)%fid, & ! [IN]
1075  file_external_input_item(nid)%varname, & ! [IN]
1076  file_external_input_item(nid)%axistype, & ! [IN]
1077  buf(:,1,1), & ! [OUT]
1078  step=file_external_input_item(nid)%data_step_prev ) ! [IN]
1079  else
1080  call file_read( file_external_input_item(nid)%fid, & ! [IN]
1081  file_external_input_item(nid)%varname, & ! [IN]
1082  buf(:,1,1), & ! [OUT]
1083  step=file_external_input_item(nid)%data_step_prev ) ! [IN]
1084  end if
1085 
1086  call file_external_input_put_ref_1d( file_external_input_item(nid)%varname, &
1087  buf(:,1,1), &
1088  error )
1089 
1090  ! read next
1091  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
1092  'Read 1D var : ', trim(file_external_input_item(nid)%varname), &
1093  ' (step= ', file_external_input_item(nid)%data_step_next, ')'
1094 
1095  if ( file_external_input_item(nid)%aggregate ) then
1096  call file_external_input_read_1d( file_external_input_item(nid)%fid, & ! [IN]
1097  file_external_input_item(nid)%varname, & ! [IN]
1098  file_external_input_item(nid)%axistype, & ! [IN]
1099  buf(:,1,1), & ! [OUT]
1100  step=file_external_input_item(nid)%data_step_next ) ! [IN]
1101  else
1102  call file_read( file_external_input_item(nid)%fid, & ! [IN]
1103  file_external_input_item(nid)%varname, & ! [IN]
1104  buf(:,1,1), & ! [OUT]
1105  step=file_external_input_item(nid)%data_step_next ) ! [IN]
1106  end if
1107 
1108  call file_external_input_put_ref_1d( file_external_input_item(nid)%varname, &
1109  buf(:,1,1), &
1110  error )
1111 
1112  case ( 2 )
1113 
1114  ! read prev
1115  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
1116  'Read 2D var : ', trim(file_external_input_item(nid)%varname), &
1117  ' (step= ', file_external_input_item(nid)%data_step_prev, ')'
1118 
1119  if ( file_external_input_item(nid)%aggregate ) then
1120  call file_external_input_read_2d( file_external_input_item(nid)%fid, & ! [IN]
1121  file_external_input_item(nid)%varname, & ! [IN]
1122  file_external_input_item(nid)%axistype, & ! [IN]
1123  buf(:,:,1), & ! [OUT]
1124  step=file_external_input_item(nid)%data_step_prev ) ! [IN]
1125  else
1126  call file_read( file_external_input_item(nid)%fid, & ! [IN]
1127  file_external_input_item(nid)%varname, & ! [IN]
1128  buf(:,:,1), & ! [OUT]
1129  step=file_external_input_item(nid)%data_step_prev ) ! [IN]
1130  end if
1131 
1132  call file_external_input_put_ref_2d( file_external_input_item(nid)%varname, &
1133  buf(:,:,1), &
1134  error )
1135 
1136  ! read next
1137  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
1138  'Read 2D var : ', trim(file_external_input_item(nid)%varname), &
1139  ' (step= ', file_external_input_item(nid)%data_step_next, ')'
1140 
1141  if ( file_external_input_item(nid)%aggregate ) then
1142  call file_external_input_read_2d( file_external_input_item(nid)%fid, & ! [IN]
1143  file_external_input_item(nid)%varname, & ! [IN]
1144  file_external_input_item(nid)%axistype, & ! [IN]
1145  buf(:,:,1), & ! [OUT]
1146  step=file_external_input_item(nid)%data_step_next ) ! [IN]
1147  else
1148  call file_read( file_external_input_item(nid)%fid, & ! [IN]
1149  file_external_input_item(nid)%varname, & ! [IN]
1150  buf(:,:,1), & ! [OUT]
1151  step=file_external_input_item(nid)%data_step_next ) ! [IN]
1152  end if
1153 
1154  call file_external_input_put_ref_2d( file_external_input_item(nid)%varname, &
1155  buf(:,:,1), &
1156  error )
1157 
1158  case ( 3 )
1159 
1160  ! read prev
1161  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
1162  'Read 3D var : ', trim(file_external_input_item(nid)%varname), &
1163  ' (step= ', file_external_input_item(nid)%data_step_prev, ')'
1164 
1165  if ( file_external_input_item(nid)%aggregate ) then
1166  call file_external_input_read_3d( file_external_input_item(nid)%fid, & ! [IN]
1167  file_external_input_item(nid)%varname, & ! [IN]
1168  file_external_input_item(nid)%axistype, & ! [IN]
1169  buf(:,:,:), & ! [OUT]
1170  step=file_external_input_item(nid)%data_step_prev ) ! [IN]
1171  else
1172  call file_read( file_external_input_item(nid)%fid, & ! [IN]
1173  file_external_input_item(nid)%varname, & ! [IN]
1174  buf(:,:,:), & ! [OUT]
1175  step=file_external_input_item(nid)%data_step_prev ) ! [IN]
1176  end if
1177 
1178  call file_external_input_put_ref_3d( file_external_input_item(nid)%varname, &
1179  buf(:,:,:), &
1180  error )
1181 
1182  ! read next
1183  log_info("FILE_EXTERNAL_INPUT_regist",'(1x,A,A,A,I4,A)') &
1184  'Read 3D var : ', trim(file_external_input_item(nid)%varname), &
1185  ' (step= ', file_external_input_item(nid)%data_step_next, ')'
1186 
1187  if ( file_external_input_item(nid)%aggregate ) then
1188  call file_external_input_read_3d( file_external_input_item(nid)%fid, & ! [IN]
1189  file_external_input_item(nid)%varname, & ! [IN]
1190  file_external_input_item(nid)%axistype, & ! [IN]
1191  buf(:,:,:), & ! [OUT]
1192  step=file_external_input_item(nid)%data_step_next ) ! [IN]
1193  else
1194  call file_read( file_external_input_item(nid)%fid, & ! [IN]
1195  file_external_input_item(nid)%varname, & ! [IN]
1196  buf(:,:,:), & ! [OUT]
1197  step=file_external_input_item(nid)%data_step_next ) ! [IN]
1198  end if
1199 
1200  call file_external_input_put_ref_3d( file_external_input_item(nid)%varname, &
1201  buf(:,:,:), &
1202  error )
1203 
1204  case default
1205  log_error("FILE_EXTERNAL_INPUT_regist",*) 'Unexpected dim rank: ', dim_rank
1206  call prc_abort
1207  end select
1208 
1209  !$acc end data
1210 
1211  deallocate( buf )
1212 
1213  if ( present(check_coordinates) ) then
1214  if ( check_coordinates ) then
1215  call file_cartesc_check_coordinates( fid, &
1216  atmos = file_external_input_item(nid)%ndim==3, &
1217  transpose = file_external_input_item(nid)%transpose )
1218  endif
1219  endif
1220 
1221 
1222  if ( present(update_dt) ) then
1223  update_dt = file_external_input_item(nid)%time(file_external_input_item(nid)%data_step_next) &
1224  - file_external_input_item(nid)%time(file_external_input_item(nid)%data_step_prev)
1225  end if
1226 
1227  return

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::file_aggregate, file_external_input_put_ref_1d(), file_external_input_put_ref_2d(), file_external_input_put_ref_3d(), file_external_input_read_1d, file_external_input_read_2d, file_external_input_read_3d, 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.

Here is the call 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 1237 of file scale_file_external_input.F90.

1237  use scale_const, only: &
1238  eps => const_eps, &
1239  undef => const_undef
1240  use scale_file, only: &
1241  file_read
1242  implicit none
1243  character(len=*), intent(in) :: varname ! item name
1244  real(DP), intent(in) :: time_current ! current time
1245  real(RP), intent(out) :: var(:) ! variable
1246  logical, intent(out) :: error ! error code
1247 
1248  integer :: nid
1249  real(RP) :: weight
1250  logical :: do_readfile
1251  integer :: step_next
1252 
1253  real(RP), allocatable :: buf(:)
1254 
1255  integer :: n1s, n1e
1256  integer :: n1
1257  !---------------------------------------------------------------------------
1258 
1259  nid = file_external_input_getid(varname)
1260 
1261  if ( nid == 0 ) then
1262  log_info("FILE_EXTERNAL_INPUT_update_1D",*) 'Variable was not registered: ', trim(varname)
1263  error = .true.
1264  return
1265  endif
1266 
1267  if ( file_external_input_item(nid)%ndim /= 1 ) then
1268  log_info("FILE_EXTERNAL_INPUT_update_1D",*) 'Data is not 1D var: ', trim(file_external_input_item(nid)%varname)
1269  error = .true.
1270  return
1271  endif
1272 
1273  call file_external_input_time_advance( nid, & ! [IN]
1274  time_current, & ! [IN]
1275  weight, & ! [OUT]
1276  do_readfile ) ! [OUT]
1277 
1278  if ( do_readfile ) then
1279 
1280  if ( file_external_input_item(nid)%file ) then
1281 
1282  step_next = file_external_input_item(nid)%data_step_next - file_external_input_item(nid)%data_step_offset
1283 
1284  log_info("FILE_EXTERNAL_INPUT_update_1D",'(1x,A,A,A,I4,A,I4,A)') &
1285  'Read 1D var : ', trim(file_external_input_item(nid)%varname), &
1286  ' (step= ', file_external_input_item(nid)%data_step_next, ', file step=', step_next, ')'
1287 
1288  allocate( buf(file_external_input_item(nid)%var_size(1)) )
1289  !$acc data create(buf)
1290 
1291  ! read next
1292  if ( file_external_input_item(nid)%aggregate ) then
1293  call file_external_input_read_1d( file_external_input_item(nid)%fid, & ! [IN]
1294  file_external_input_item(nid)%varname, & ! [IN]
1295  file_external_input_item(nid)%axistype, & ! [IN]
1296  buf(:), & ! [OUT]
1297  step=file_external_input_item(nid)%data_step_next ) ! [IN]
1298  else
1299  call file_read( file_external_input_item(nid)%fid, & ! [IN]
1300  file_external_input_item(nid)%varname, & ! [IN]
1301  buf(:), & ! [OUT]
1302  step=step_next ) ! [IN]
1303  end if
1304 
1305  call file_external_input_put_ref_1d( file_external_input_item(nid)%varname, &
1306  buf(:), &
1307  error )
1308 
1309  !$acc end data
1310  deallocate( buf )
1311 
1312  if ( error ) return
1313  end if
1314 
1315  endif
1316 
1317 
1318  error = .false.
1319 
1320  n1s = file_external_input_item(nid)%dim_start(1)
1321  n1e = n1s - 1 + file_external_input_item(nid)%dim_max(1)
1322 
1323  !$acc data copyout(var)
1324 
1325  ! store data with weight
1326  if ( file_external_input_item(nid)%allow_missing ) then
1327  !$omp parallel do
1328  !$acc kernels present(FILE_EXTERNAL_INPUT_item(nid))
1329  do n1 = n1s, n1e
1330  if ( abs( file_external_input_item(nid)%value(n1,1,1,i_prev) - undef ) > eps &
1331  .and. abs( file_external_input_item(nid)%value(n1,1,1,i_next) - undef ) > eps ) then
1332  var(n1) = ( 1.0_rp-weight ) * file_external_input_item(nid)%value(n1,1,1,i_prev) &
1333  + ( weight ) * file_external_input_item(nid)%value(n1,1,1,i_next)
1334  else
1335  var(n1) = undef
1336  end if
1337  enddo
1338  !$acc end kernels
1339  else
1340  !$omp parallel do
1341  !$acc kernels present(FILE_EXTERNAL_INPUT_item(nid))
1342  do n1 = n1s, n1e
1343  var(n1) = ( 1.0_rp-weight ) * file_external_input_item(nid)%value(n1,1,1,i_prev) &
1344  + ( weight ) * file_external_input_item(nid)%value(n1,1,1,i_next)
1345  enddo
1346  !$acc end kernels
1347  end if
1348 
1349  !$acc end data
1350 
1351  return

References scale_const::const_eps, scale_const::const_undef, file_external_input_getid(), file_external_input_put_ref_1d(), file_external_input_read_1d, i_next, and i_prev.

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 1361 of file scale_file_external_input.F90.

1361  use scale_const, only: &
1362  eps => const_eps, &
1363  undef => const_undef
1364  use scale_file, only: &
1365  file_read
1366  implicit none
1367  character(len=*), intent(in) :: varname ! item name
1368  real(DP), intent(in) :: time_current ! current time
1369  real(RP), intent(out) :: var(:,:) ! variable
1370  logical, intent(out) :: error ! error code
1371 
1372  integer :: nid
1373  real(RP) :: weight
1374  logical :: do_readfile
1375  integer :: step_next
1376 
1377  real(RP), allocatable :: buf(:,:)
1378 
1379  integer :: n1s, n1e, n2s, n2e
1380  integer :: n1, n2
1381  !---------------------------------------------------------------------------
1382 
1383  nid = file_external_input_getid( varname )
1384 
1385  if ( nid == 0 ) then
1386  log_info("FILE_EXTERNAL_INPUT_update_2D",*) 'Variable was not registered: ', trim(varname)
1387  error = .true.
1388  return
1389  endif
1390 
1391  if ( file_external_input_item(nid)%ndim /= 2 ) then
1392  log_info("FILE_EXTERNAL_INPUT_update_2D",*) 'Data is not 2D var: ', trim(file_external_input_item(nid)%varname)
1393  error = .true.
1394  return
1395  endif
1396 
1397  call file_external_input_time_advance( nid, & ! [IN]
1398  time_current, & ! [IN]
1399  weight, & ! [OUT]
1400  do_readfile ) ! [OUT]
1401 
1402  if ( do_readfile ) then
1403 
1404  if ( file_external_input_item(nid)%file ) then
1405 
1406  step_next = file_external_input_item(nid)%data_step_next - file_external_input_item(nid)%data_step_offset
1407 
1408  log_info("FILE_EXTERNAL_INPUT_update_2D",'(1x,A,A,A,I4,A,I4,A)') &
1409  'Read 2D var : ', trim(file_external_input_item(nid)%varname), &
1410  ' (step= ', file_external_input_item(nid)%data_step_next, ', file step=', step_next, ')'
1411 
1412  allocate( buf(file_external_input_item(nid)%var_size(1),file_external_input_item(nid)%var_size(2)) )
1413  !$acc data create(buf)
1414 
1415  ! read next
1416  if ( file_external_input_item(nid)%aggregate ) then
1417  call file_external_input_read_2d( file_external_input_item(nid)%fid, & ! [IN]
1418  file_external_input_item(nid)%varname, & ! [IN]
1419  file_external_input_item(nid)%axistype, & ! [IN]
1420  buf(:,:), & ! [OUT]
1421  step=file_external_input_item(nid)%data_step_next ) ! [IN]
1422  else
1423  call file_read( file_external_input_item(nid)%fid, & ! [IN]
1424  file_external_input_item(nid)%varname, & ! [IN]
1425  buf(:,:), & ! [OUT]
1426  step=step_next ) ! [IN]
1427  end if
1428 
1429  call file_external_input_put_ref_2d( file_external_input_item(nid)%varname, &
1430  buf(:,:), &
1431  error )
1432 
1433  !$acc end data
1434  deallocate( buf )
1435 
1436  if ( error ) return
1437  end if
1438 
1439  endif
1440 
1441  error = .false.
1442 
1443  n1s = file_external_input_item(nid)%dim_start(1)
1444  n1e = n1s - 1 + file_external_input_item(nid)%dim_max(1)
1445  n2s = file_external_input_item(nid)%dim_start(2)
1446  n2e = n2s - 1 + file_external_input_item(nid)%dim_max(2)
1447 
1448  !$acc data copyout(var)
1449 
1450  ! store data with weight
1451  if ( file_external_input_item(nid)%allow_missing ) then
1452  !$omp parallel do
1453  !$acc kernels present(FILE_EXTERNAL_INPUT_item(nid))
1454  do n2 = n2s, n2e
1455  do n1 = n1s, n1e
1456  if ( abs( file_external_input_item(nid)%value(n1,n2,1,i_prev) - undef ) > eps &
1457  .and. abs( file_external_input_item(nid)%value(n1,n2,1,i_next) - undef ) > eps ) then
1458  var(n1,n2) = ( 1.0_rp-weight ) * file_external_input_item(nid)%value(n1,n2,1,i_prev) &
1459  + ( weight ) * file_external_input_item(nid)%value(n1,n2,1,i_next)
1460  else
1461  var(n1,n2) = undef
1462  end if
1463  enddo
1464  enddo
1465  !$acc end kernels
1466  else
1467  !$omp parallel do
1468  !$acc kernels present(FILE_EXTERNAL_INPUT_item(nid))
1469  do n2 = n2s, n2e
1470  do n1 = n1s, n1e
1471  var(n1,n2) = ( 1.0_rp-weight ) * file_external_input_item(nid)%value(n1,n2,1,i_prev) &
1472  + ( weight ) * file_external_input_item(nid)%value(n1,n2,1,i_next)
1473  enddo
1474  enddo
1475  !$acc end kernels
1476  end if
1477 
1478  !$acc end data
1479 
1480  return

References scale_const::const_eps, scale_const::const_undef, file_external_input_getid(), file_external_input_put_ref_2d(), file_external_input_read_2d, i_next, and i_prev.

Here is the call graph for this function:

◆ 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 1490 of file scale_file_external_input.F90.

1490  use scale_const, only: &
1491  eps => const_eps, &
1492  undef => const_undef
1493  use scale_file, only: &
1494  file_read
1495  implicit none
1496  character(len=*), intent(in) :: varname ! item name
1497  real(DP), intent(in) :: time_current ! current time
1498  real(RP), intent(out) :: var(:,:,:) ! variable
1499  logical, intent(out) :: error ! error code
1500 
1501  integer :: nid
1502  real(RP) :: weight
1503  logical :: do_readfile
1504  integer :: step_next
1505 
1506  real(RP), allocatable :: buf(:,:,:)
1507 
1508  integer :: n1s, n1e, n2s, n2e, n3s, n3e
1509  integer :: n1, n2, n3
1510  !---------------------------------------------------------------------------
1511 
1512  nid = file_external_input_getid( varname )
1513 
1514  if ( nid == 0 ) then
1515  log_info("FILE_EXTERNAL_INPUT_update_3D",*) 'Variable was not registered: ', trim(varname)
1516  error = .true.
1517  return
1518  endif
1519 
1520  if ( file_external_input_item(nid)%ndim /= 3 ) then
1521  log_info("FILE_EXTERNAL_INPUT_update_3D",*) 'Data is not 3D var: ', trim(file_external_input_item(nid)%varname)
1522  error = .true.
1523  return
1524  endif
1525 
1526  call file_external_input_time_advance( nid, & ! [IN]
1527  time_current, & ! [IN]
1528  weight, & ! [OUT]
1529  do_readfile ) ! [OUT]
1530 
1531  if ( do_readfile ) then
1532 
1533  if ( file_external_input_item(nid)%file ) then
1534 
1535  step_next = file_external_input_item(nid)%data_step_next - file_external_input_item(nid)%data_step_offset
1536 
1537  log_info("FILE_EXTERNAL_INPUT_update_3D",'(1x,A,A,A,I4,A,I4,A)') &
1538  'Read 3D var : ', trim(file_external_input_item(nid)%varname), &
1539  ' (step= ', file_external_input_item(nid)%data_step_next, ', file step=', step_next, ')'
1540 
1541  allocate( buf(file_external_input_item(nid)%var_size(1),file_external_input_item(nid)%var_size(2),file_external_input_item(nid)%var_size(3)) )
1542  !$acc data create(buf)
1543 
1544  ! read next
1545  if ( file_external_input_item(nid)%aggregate ) then
1546  call file_external_input_read_3d( file_external_input_item(nid)%fid, & ! [IN]
1547  file_external_input_item(nid)%varname, & ! [IN]
1548  file_external_input_item(nid)%axistype, & ! [IN]
1549  buf(:,:,:), & ! [OUT]
1550  step=file_external_input_item(nid)%data_step_next ) ! [IN]
1551  else
1552  call file_read( file_external_input_item(nid)%fid, & ! [IN]
1553  file_external_input_item(nid)%varname, & ! [IN]
1554  buf(:,:,:), & ! [OUT]
1555  step=step_next ) ! [IN]
1556  end if
1557 
1558  call file_external_input_put_ref_3d( file_external_input_item(nid)%varname, &
1559  buf(:,:,:), &
1560  error )
1561 
1562  !$acc end data
1563  deallocate(buf)
1564 
1565  if ( error ) return
1566  end if
1567 
1568  endif
1569 
1570  error = .false.
1571 
1572  n1s = file_external_input_item(nid)%dim_start(1)
1573  n1e = n1s - 1 + file_external_input_item(nid)%dim_max(1)
1574  n2s = file_external_input_item(nid)%dim_start(2)
1575  n2e = n2s - 1 + file_external_input_item(nid)%dim_max(2)
1576  n3s = file_external_input_item(nid)%dim_start(3)
1577  n3e = n3s - 1 + file_external_input_item(nid)%dim_max(3)
1578 
1579  !$acc data copyout(var)
1580 
1581  ! store data with weight
1582  if ( file_external_input_item(nid)%allow_missing ) then
1583  !$omp parallel do
1584  !$acc kernels present(FILE_EXTERNAL_INPUT_item(nid))
1585  do n3 = n3s, n3e
1586  do n2 = n2s, n2e
1587  do n1 = n1s, n1e
1588  if ( abs( file_external_input_item(nid)%value(n1,n2,n3,i_prev) - undef ) > eps &
1589  .and. abs( file_external_input_item(nid)%value(n1,n2,n3,i_next) - undef ) > eps ) then
1590  var(n1,n2,n3) = ( 1.0_rp-weight ) * file_external_input_item(nid)%value(n1,n2,n3,i_prev) &
1591  + ( weight ) * file_external_input_item(nid)%value(n1,n2,n3,i_next)
1592  else
1593  var(n1,n2,n3) = undef
1594  end if
1595  enddo
1596  enddo
1597  enddo
1598  !$acc end kernels
1599  else
1600  !$omp parallel do
1601  !$acc kernels present(FILE_EXTERNAL_INPUT_item(nid))
1602  do n3 = n3s, n3e
1603  do n2 = n2s, n2e
1604  do n1 = n1s, n1e
1605  var(n1,n2,n3) = ( 1.0_rp-weight ) * file_external_input_item(nid)%value(n1,n2,n3,i_prev) &
1606  + ( weight ) * file_external_input_item(nid)%value(n1,n2,n3,i_next)
1607  enddo
1608  enddo
1609  enddo
1610  !$acc end kernels
1611  end if
1612 
1613  !$acc end data
1614 
1615  return

References scale_const::const_eps, scale_const::const_undef, file_external_input_getid(), file_external_input_put_ref_3d(), file_external_input_read_3d, i_next, and i_prev.

Here is the call graph for this function:

◆ file_external_input_put_ref_1d()

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

Put reference data.

Definition at line 1624 of file scale_file_external_input.F90.

1624  use scale_const, only: &
1625  eps => const_eps, &
1626  undef => const_undef
1627  implicit none
1628  character(len=*), intent(in) :: varname ! item name
1629  real(RP), intent(in) :: var(:) ! variable
1630  logical, intent(out) :: error ! error code
1631 
1632  integer :: nid
1633  integer :: n1, nn1, nnn1
1634 
1635  nid = file_external_input_getid( varname )
1636 
1637  if ( nid == 0 ) then
1638  log_info("FILE_EXTERNAL_INPUT_put_ref_1D",*) 'Variable was not registered: ', trim(varname)
1639  error = .true.
1640  return
1641  endif
1642 
1643  error = .false.
1644 
1645  !$omp workshare
1646  !$acc kernels present(FILE_EXTERNAL_INPUT_item(nid))
1647  file_external_input_item(nid)%value(:,:,:,i_prev) = file_external_input_item(nid)%value(:,:,:,i_next)
1648  !$acc end kernels
1649  !$omp end workshare
1650 
1651  !$omp parallel do private(nn1,nnn1)
1652  !$acc kernels copyin(var) present(FILE_EXTERNAL_INPUT_item(nid))
1653  !$acc loop reduction(.or.:error) independent
1654  do n1 = 1, file_external_input_item(nid)%dim_max(1)
1655  nn1 = n1 + file_external_input_item(nid)%dim_start(1) - 1
1656  nnn1 = n1 + file_external_input_item(nid)%var_start(1) - 1
1657  if ( .not. file_external_input_item(nid)%allow_missing ) then
1658  if ( abs( var(nnn1) - undef ) < eps ) then
1659  log_warn("FILE_EXTERNAL_INPUT_put_ref_1D",*) 'missing value is found in ', &
1660 #ifdef _OPENACC
1661  file_external_input_item(nid)%varname, ' at (',nnn1,')'
1662 #else
1663  trim(file_external_input_item(nid)%varname), ' at (',nnn1,')'
1664 #endif
1665  error = .true.
1666  end if
1667  end if
1668  file_external_input_item(nid)%value(nn1,1,1,i_next) = var(nnn1)
1669  enddo
1670  !$acc end kernels
1671 
1672  return

References scale_const::const_eps, scale_const::const_undef, file_external_input_getid(), i_next, and i_prev.

Referenced by file_external_input_regist_external_1d(), file_external_input_regist_file(), and file_external_input_update_1d().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_external_input_put_ref_2d()

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

Definition at line 1679 of file scale_file_external_input.F90.

1679  use scale_const, only: &
1680  eps => const_eps, &
1681  undef => const_undef
1682  implicit none
1683  character(len=*), intent(in) :: varname ! item name
1684  real(RP), intent(in) :: var(:,:) ! variable
1685  logical, intent(out) :: error ! error code
1686 
1687  integer :: nid
1688  integer :: n1, n2, nn1, nn2, nnn1, nnn2
1689 
1690  nid = file_external_input_getid( varname )
1691 
1692  if ( nid == 0 ) then
1693  log_info("FILE_EXTERNAL_INPUT_put_var_2D",*) 'Variable was not registered: ', trim(varname)
1694  error = .true.
1695  return
1696  endif
1697 
1698  error = .false.
1699 
1700  !$omp workshare
1701  !$acc kernels present(FILE_EXTERNAL_INPUT_item(nid))
1702  file_external_input_item(nid)%value(:,:,:,i_prev) = file_external_input_item(nid)%value(:,:,:,i_next)
1703  !$acc end kernels
1704  !$omp end workshare
1705 
1706  if ( file_external_input_item(nid)%transpose ) then
1707  ! (x,z)->(z,x)
1708  !$omp parallel do private(nn1,nn2,nnn1,nnn2)
1709  !$acc kernels copyin(var) present(FILE_EXTERNAL_INPUT_item(nid))
1710  !$acc loop collapse(2) reduction(.or.:error) independent
1711  do n2 = 1, file_external_input_item(nid)%dim_max(2)
1712 #ifndef _OPENACC
1713  if ( error ) cycle
1714  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
1715  nnn2 = n2 + file_external_input_item(nid)%var_start(1) - 1
1716 #endif
1717  do n1 = 1, file_external_input_item(nid)%dim_max(1)
1718 #ifdef _OPENACC
1719  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
1720  nnn2 = n2 + file_external_input_item(nid)%var_start(1) - 1
1721 #endif
1722  nn1 = n1 + file_external_input_item(nid)%dim_start(1) - 1
1723  nnn1 = n1 + file_external_input_item(nid)%var_start(2) - 1
1724  if ( .not. file_external_input_item(nid)%allow_missing ) then
1725  if ( abs( var(nnn2,nnn1) - undef ) < eps ) then
1726  log_warn("FILE_EXTERNAL_INPUT_put_ref_2D",*) 'missing value is found in ', &
1727 #ifdef _OPENACC
1728  file_external_input_item(nid)%varname, ' at (',nnn2,',',nnn1,')'
1729 #else
1730  trim(file_external_input_item(nid)%varname), ' at (',nnn2,',',nnn1,')'
1731 #endif
1732  error = .true.
1733  end if
1734  end if
1735  file_external_input_item(nid)%value(nn1,nn2,1,i_next) = var(nnn2,nnn1)
1736  enddo
1737  enddo
1738  !$acc end kernels
1739  else
1740  ! (z,x)->(z,x)
1741  !$omp parallel do private(nn1,nn2,nnn1,nnn2)
1742  !$acc kernels copyin(var) present(FILE_EXTERNAL_INPUT_item(nid))
1743  !$acc loop collapse(2) reduction(.or.:error) independent
1744  do n2 = 1, file_external_input_item(nid)%dim_max(2)
1745 #ifndef _OPENACC
1746  if ( error ) cycle
1747  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
1748  nnn2 = n2 + file_external_input_item(nid)%var_start(2) - 1
1749 #endif
1750  do n1 = 1, file_external_input_item(nid)%dim_max(1)
1751 #ifdef _OPENACC
1752  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
1753  nnn2 = n2 + file_external_input_item(nid)%var_start(2) - 1
1754 #endif
1755  nn1 = n1 + file_external_input_item(nid)%dim_start(1) - 1
1756  nnn1 = n1 + file_external_input_item(nid)%var_start(1) - 1
1757  if ( .not. file_external_input_item(nid)%allow_missing ) then
1758  if ( abs( var(nnn2,nnn1) - undef ) < eps ) then
1759  log_warn("FILE_EXTERNAL_INPUT_put_ref_2D",*) 'missing value is found in ', &
1760 #ifdef _OPENACC
1761  file_external_input_item(nid)%varname, ' at (',nnn1,',',nnn2,')'
1762 #else
1763  trim(file_external_input_item(nid)%varname), ' at (',nnn1,',',nnn2,')'
1764 #endif
1765  error = .true.
1766  end if
1767  end if
1768  file_external_input_item(nid)%value(nn1,nn2,1,i_next) = var(nnn1,nnn2)
1769  enddo
1770  enddo
1771  !$acc end kernels
1772  endif
1773 
1774  return

References scale_const::const_eps, scale_const::const_undef, file_external_input_getid(), i_next, and i_prev.

Referenced by file_external_input_regist_external_2d(), file_external_input_regist_file(), and file_external_input_update_2d().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_external_input_put_ref_3d()

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

Definition at line 1781 of file scale_file_external_input.F90.

1781  use scale_const, only: &
1782  eps => const_eps, &
1783  undef => const_undef
1784  implicit none
1785  character(len=*), intent(in) :: varname ! item name
1786  real(RP), intent(in) :: var(:,:,:) ! variable
1787  logical, intent(out) :: error ! error code
1788 
1789  integer :: nid
1790  integer :: n1, n2, n3, nn1, nn2, nn3, nnn1, nnn2, nnn3
1791 
1792  nid = file_external_input_getid( varname )
1793 
1794  if ( nid == 0 ) then
1795  log_info("FILE_EXTERNAL_INPUT_put_ref_3D",*) 'Variable was not registered: ', trim(varname)
1796  error = .true.
1797  return
1798  endif
1799 
1800  error = .false.
1801 
1802  !$omp workshare
1803  !$acc kernels
1804  file_external_input_item(nid)%value(:,:,:,i_prev) = file_external_input_item(nid)%value(:,:,:,i_next)
1805  !$acc end kernels
1806  !$omp end workshare
1807 
1808  if ( file_external_input_item(nid)%transpose ) then
1809  ! (x,y,z)->(z,x,y)
1810  !$omp parallel do private(nn1,nn2,nn3,nnn1,nnn2,nnn3)
1811  !$acc kernels copyin(var) present(FILE_EXTERNAL_INPUT_item(nid))
1812  !$acc loop collapse(3) reduction(.or.:error) independent
1813  do n3 = 1, file_external_input_item(nid)%dim_max(3)
1814 #ifndef _OPENACC
1815  if ( error ) cycle
1816  nn3 = n3 + file_external_input_item(nid)%dim_start(3) - 1
1817  nnn3 = n3 + file_external_input_item(nid)%var_start(2) - 1
1818 #endif
1819  do n2 = 1, file_external_input_item(nid)%dim_max(2)
1820 #ifndef _OPENACC
1821  if ( error ) exit
1822  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
1823  nnn2 = n2 + file_external_input_item(nid)%var_start(1) - 1
1824 #endif
1825  do n1 = 1, file_external_input_item(nid)%dim_max(1)
1826 #ifdef _OPENACC
1827  nn3 = n3 + file_external_input_item(nid)%dim_start(3) - 1
1828  nnn3 = n3 + file_external_input_item(nid)%var_start(2) - 1
1829  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
1830  nnn2 = n2 + file_external_input_item(nid)%var_start(1) - 1
1831 #endif
1832  nn1 = n1 + file_external_input_item(nid)%dim_start(1) - 1
1833  nnn1 = n1 + file_external_input_item(nid)%var_start(3) - 1
1834  if ( .not. file_external_input_item(nid)%allow_missing ) then
1835  if ( abs( var(nnn2,nnn3,nnn1) - undef ) < eps ) then
1836  log_warn("FILE_EXTERNAL_INPUT_put_ref_3D",*) 'missing value is found in ', &
1837 #ifdef _OPENACC
1838  file_external_input_item(nid)%varname, ' at (',nnn2,',',nnn3,',',nnn1,')'
1839 #else
1840  trim(file_external_input_item(nid)%varname), ' at (',nnn2,',',nnn3,',',nnn1,')'
1841 #endif
1842  error = .true.
1843  end if
1844  end if
1845  file_external_input_item(nid)%value(nn1,nn2,nn3,i_next) = var(nnn2,nnn3,nnn1)
1846  enddo
1847  enddo
1848  enddo
1849  !$acc end kernels
1850  else
1851  ! (z,x,y)->(z,x,y)
1852  !$omp parallel do private(nn1,nn2,nn3,nnn1,nnn2,nnn3)
1853  !$acc kernels copyin(var) present(FILE_EXTERNAL_INPUT_item(nid))
1854  !$acc loop collapse(3) reduction(.or.:error) independent
1855  do n3 = 1, file_external_input_item(nid)%dim_max(3)
1856 #ifndef _OPENACC
1857  if ( error ) cycle
1858  nn3 = n3 + file_external_input_item(nid)%dim_start(3) - 1
1859  nnn3 = n3 + file_external_input_item(nid)%var_start(3) - 1
1860 #endif
1861  do n2 = 1, file_external_input_item(nid)%dim_max(2)
1862 #ifndef _OPENACC
1863  if ( error ) exit
1864  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
1865  nnn2 = n2 + file_external_input_item(nid)%var_start(2) - 1
1866 #endif
1867  do n1 = 1, file_external_input_item(nid)%dim_max(1)
1868 #ifdef _OPENACC
1869  nn3 = n3 + file_external_input_item(nid)%dim_start(3) - 1
1870  nnn3 = n3 + file_external_input_item(nid)%var_start(3) - 1
1871  nn2 = n2 + file_external_input_item(nid)%dim_start(2) - 1
1872  nnn2 = n2 + file_external_input_item(nid)%var_start(2) - 1
1873 #endif
1874  nn1 = n1 + file_external_input_item(nid)%dim_start(1) - 1
1875  nnn1 = n1 + file_external_input_item(nid)%var_start(1) - 1
1876  if ( .not. file_external_input_item(nid)%allow_missing ) then
1877  if ( abs( var(nnn1,nnn2,nnn3) - undef ) < eps ) then
1878  log_warn("FILE_EXTERNAL_INPUT_put_ref_3D",*) 'missing value is found in ', &
1879 #ifdef _OPENACC
1880  file_external_input_item(nid)%varname, ' at (',nnn1,',',nnn2,',',nnn3,')'
1881 #else
1882  trim(file_external_input_item(nid)%varname), ' at (',nnn1,',',nnn2,',',nnn3,')'
1883 #endif
1884  error = .true.
1885  end if
1886  end if
1887  file_external_input_item(nid)%value(nn1,nn2,nn3,i_next) = var(nnn1,nnn2,nnn3)
1888  enddo
1889  enddo
1890  enddo
1891  !$acc end kernels
1892  endif
1893 
1894  return

References scale_const::const_eps, scale_const::const_undef, file_external_input_getid(), i_next, and i_prev.

Referenced by file_external_input_regist_external_3d(), file_external_input_regist_file(), and file_external_input_update_3d().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_external_input_get_ref_1d()

subroutine scale_file_external_input::file_external_input_get_ref_1d ( character(len=*), intent(in)  varname,
real(rp), dimension(:), intent(out)  var,
logical, intent(out)  error,
integer, intent(in), optional  i_step 
)

Get reference data.

Definition at line 1904 of file scale_file_external_input.F90.

1904  implicit none
1905  character(len=*), intent(in) :: varname ! item name
1906  real(RP), intent(out) :: var(:) ! variable
1907  logical, intent(out) :: error ! error code
1908 
1909  integer, optional, intent(in) :: i_step
1910 
1911  integer :: i_step_
1912  integer :: nid
1913 
1914  if ( present(i_step) ) then
1915  i_step_ = i_step
1916  else
1917  i_step_ = i_next
1918  end if
1919 
1920  nid = file_external_input_getid( varname )
1921 
1922  if ( nid == 0 ) then
1923  log_info("FILE_EXTERNAL_INPUT_get_ref_1D",*) 'Variable was not registered: ', trim(varname)
1924  error = .true.
1925  return
1926  endif
1927 
1928  error = .false.
1929 
1930  !$omp workshare
1931  !$acc kernels present(FILE_EXTERNAL_INPUT_item(nid))
1932  var(:) = file_external_input_item(nid)%value(:,1,1,i_step_)
1933  !$acc end kernels
1934  !$omp end workshare
1935 
1936  return

References file_external_input_getid(), and i_next.

Here is the call graph for this function:

◆ file_external_input_query()

subroutine, public scale_file_external_input::file_external_input_query ( character(len=*), intent(in)  varname,
real(dp), intent(in)  time_current,
logical, intent(out)  do_readdata 
)

Check time to read.

Definition at line 2027 of file scale_file_external_input.F90.

2027  implicit none
2028  character(len=*), intent(in) :: varname ! variable name
2029  real(DP), intent(in) :: time_current ! current time
2030  logical, intent(out) :: do_readdata ! read new data at this time?
2031 
2032  integer :: nid
2033 
2034  nid = file_external_input_getid( varname )
2035 
2036  call file_external_input_query_id( nid, &
2037  time_current, &
2038  do_readdata )
2039 
2040  return

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_getid(), 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.

Referenced by mod_atmos_bnd_driver::atmos_boundary_driver_send().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_external_input_getid()

integer function scale_file_external_input::file_external_input_getid ( character(len=*), intent(in)  varname)

Definition at line 2309 of file scale_file_external_input.F90.

2309  character(len=*), intent(in) :: varname
2310 
2311  integer nid, n
2312 
2313  ! searching the data ID
2314  nid = 0
2315  do n = 1, file_external_input_item_count
2316  if( varname == file_external_input_item(n)%varname ) then
2317  nid = n
2318  exit
2319  end if
2320  enddo
2321 
2322  return

Referenced by file_external_input_finalize(), file_external_input_get_ref_1d(), file_external_input_put_ref_1d(), file_external_input_put_ref_2d(), file_external_input_put_ref_3d(), file_external_input_query(), file_external_input_update_1d(), file_external_input_update_2d(), and file_external_input_update_3d().

Here is the caller 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 157 of file scale_file_external_input.F90.

157  procedure(get_dims1D), pointer :: FILE_EXTERNAL_INPUT_get_dims1D => null()

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

◆ file_external_input_get_dims2d

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

Definition at line 158 of file scale_file_external_input.F90.

158  procedure(get_dims2D), pointer :: FILE_EXTERNAL_INPUT_get_dims2D => null()

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

◆ file_external_input_get_dims3d

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

Definition at line 159 of file scale_file_external_input.F90.

159  procedure(get_dims3D), pointer :: FILE_EXTERNAL_INPUT_get_dims3D => null()

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

◆ file_external_input_read_1d

procedure(read1d), pointer, public scale_file_external_input::file_external_input_read_1d => NULL()

Definition at line 164 of file scale_file_external_input.F90.

164  procedure(read1D), pointer :: FILE_EXTERNAL_INPUT_read_1D => null()

Referenced by scale_file_external_input_cartesc::file_external_input_cartesc_setup(), file_external_input_regist_file(), and file_external_input_update_1d().

◆ file_external_input_read_2d

procedure(read2d), pointer, public scale_file_external_input::file_external_input_read_2d => NULL()

Definition at line 165 of file scale_file_external_input.F90.

165  procedure(read2D), pointer :: FILE_EXTERNAL_INPUT_read_2D => null()

Referenced by scale_file_external_input_cartesc::file_external_input_cartesc_setup(), file_external_input_regist_file(), and file_external_input_update_2d().

◆ file_external_input_read_3d

procedure(read3d), pointer, public scale_file_external_input::file_external_input_read_3d => NULL()

Definition at line 166 of file scale_file_external_input.F90.

166  procedure(read3D), pointer :: FILE_EXTERNAL_INPUT_read_3D => null()

Referenced by scale_file_external_input_cartesc::file_external_input_cartesc_setup(), file_external_input_regist_file(), and file_external_input_update_3d().

◆ i_prev

integer, parameter, public scale_file_external_input::i_prev = 1

◆ i_next

integer, parameter, public scale_file_external_input::i_next = 2
scale_time::time_nowdaysec
real(dp), public time_nowdaysec
second of current time [sec]
Definition: scale_time.F90:72
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:350
scale_file::file_open
subroutine, public file_open(basename, fid, mode, single, allnodes, aggregate, rankid, postfix)
Definition: scale_file.F90:536
scale_calendar::calendar_daysec2date
subroutine, public calendar_daysec2date(ymdhms, subsec, absday, abssec, offset_year)
Convert from gregorian date to absolute day/second.
Definition: scale_calendar.F90:255
scale_calendar::calendar_combine_daysec
real(dp) function, public calendar_combine_daysec(absday, abssec)
Combine day and second.
Definition: scale_calendar.F90:467
scale_const::const_eps
real(rp), public const_eps
small number
Definition: scale_const.F90:35
scale_prc::prc_myrank
integer, public prc_myrank
process num in local communicator
Definition: scale_prc.F90:91
scale_calendar
module CALENDAR
Definition: scale_calendar.F90:13
scale_file
module file
Definition: scale_file.F90:15
scale_prc
module PROCESS
Definition: scale_prc.F90:11
scale_const
module CONSTANT
Definition: scale_const.F90:11
scale_calendar::calendar_date2daysec
subroutine, public calendar_date2daysec(absday, abssec, ymdhms, subsec, offset_year)
Convert from gregorian date to absolute day/second.
Definition: scale_calendar.F90:192
scale_calendar::calendar_adjust_daysec
subroutine, public calendar_adjust_daysec(absday, abssec)
Adjust day and second.
Definition: scale_calendar.F90:442
scale_file_h
module file_h
Definition: scale_file_h.F90:11
scale_time
module TIME
Definition: scale_time.F90:11
scale_calendar::calendar_cfunits2sec
real(dp) function, public calendar_cfunits2sec(cftime, cfunits, offset_year, startdaysec)
Convert time in units of the CF convention to second.
Definition: scale_calendar.F90:550
scale_calendar::i_month
integer, parameter, public i_month
[index] month
Definition: scale_calendar.F90:46
scale_file::file_aggregate
logical, public file_aggregate
Definition: scale_file.F90:196
scale_file_h::file_fread
integer, parameter, public file_fread
Definition: scale_file_h.F90:34
scale_calendar::i_year
integer, parameter, public i_year
[index] year
Definition: scale_calendar.F90:45
scale_calendar::i_day
integer, parameter, public i_day
[index] day
Definition: scale_calendar.F90:47
scale_const::const_undef
real(rp), public const_undef
Definition: scale_const.F90:43
scale_time::time_startdaysec
real(dp), public time_startdaysec
second of start time [sec]
Definition: scale_time.F90:77
scale_file_cartesc
module file / cartesianC
Definition: scale_file_cartesC.F90:11
scale_time::time_offset_year
integer, public time_offset_year
time offset [year]
Definition: scale_time.F90:76