Regist data.
265 file_get_all_datainfo, &
284 file_cartesc_check_coordinates
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
291 logical,
intent(in) :: enable_periodic_year
292 logical,
intent(in) :: enable_periodic_month
293 logical,
intent(in) :: enable_periodic_day
294 real(RP),
intent(in) :: offset
295 real(RP),
intent(in) :: defval
297 logical,
intent(in),
optional :: check_coordinates
298 integer,
intent(in),
optional :: step_limit
299 logical,
intent(out),
optional :: exist
302 character(len=H_MID) :: description
303 character(len=H_SHORT) :: unit
304 character(len=H_MID) :: standard_name
307 character(len=H_SHORT) :: dim_name (file_external_input_dim_limit)
308 integer :: dim_size (file_external_input_dim_limit)
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
318 integer :: datadate(6)
319 real(DP) :: datasubsec
322 integer :: offset_year
324 integer :: dim1_max, dim1_s, dim1_e
325 integer :: dim2_max, dim2_s, dim2_e
326 integer :: dim3_max, dim3_s, dim3_e
328 integer :: step_limit_
334 if (
present(step_limit) )
then 335 if ( step_limit > 0 )
then 336 step_limit_ = step_limit
338 step_limit_ = file_external_input_step_limit
341 step_limit_ = file_external_input_step_limit
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)
351 file_external_input_item_count = file_external_input_item_count + 1
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
363 call file_get_all_datainfo( fid, varname, &
365 description, unit, standard_name, &
367 dim_rank, dim_name(:), dim_size(:), &
368 natts, att_name(:), att_type(:), att_len(:), &
369 time_start(1:step_limit_), time_end(1:step_limit_), &
370 time_units, calendar )
372 if ( step_nmax > 0 )
then 373 if (
present(exist) )
then 377 if (
present(exist) )
then 381 log_error(
"FILE_EXTERNAL_INPUT_regist",*)
'Data not found! basename,varname = ', trim(basename(1)),
', ', trim(varname)
390 nid = file_external_input_item_count
392 do n = 1, file_external_input_file_limit
393 if( basename(n) ==
'' )
exit 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
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)
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_
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
416 file_external_input_item(nid)%flag_periodic = 0
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
423 allocate( file_external_input_item(nid)%time(step_limit_) )
424 file_external_input_item(nid)%time(:) = 0.0_dp
426 do n = 1, file_external_input_item(nid)%step_num
430 if ( file_external_input_item(nid)%step_num == 1 )
then 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
436 else if ( step_fixed > 0 )
then 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
444 file_external_input_item(nid)%fixed_step = .false.
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
453 file_external_input_item(nid)%data_step_prev = file_external_input_item(nid)%data_step_next - 1
455 if ( file_external_input_item(nid)%flag_periodic > 0 )
then 457 if ( file_external_input_item(nid)%data_step_next == 1 )
then 460 file_external_input_item(nid)%data_step_prev = file_external_input_item(nid)%step_num
462 elseif( file_external_input_item(nid)%data_step_next == file_external_input_item(nid)%step_num+1 )
then 465 file_external_input_item(nid)%data_step_next = 1
468 do n = 1, file_external_input_item(nid)%step_num
470 datasec = file_external_input_item(nid)%time(n)
480 if ( file_external_input_item(nid)%flag_periodic == i_periodic_day )
then 482 elseif( file_external_input_item(nid)%flag_periodic == i_periodic_month )
then 484 elseif( file_external_input_item(nid)%flag_periodic == i_periodic_year )
then 497 log_info(
"FILE_EXTERNAL_INPUT_regist",*)
'data time is updated.' 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)
513 log_info(
"FILE_EXTERNAL_INPUT_regist",
'(1x,A,A15)')
'Initial read of external data : ', trim(varname)
515 if ( dim_size(1) >= 1 &
516 .AND. dim_size(2) == 1 &
517 .AND. dim_size(3) == 1 )
then 519 call file_external_input_get_dims1d( dim1_max, dim1_s, dim1_e, &
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
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
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,
')' 538 call file_read( file_external_input_item(nid)%fid, &
539 file_external_input_item(nid)%varname, &
540 file_external_input_item(nid)%value(:,1,1,i_prev), &
541 step=file_external_input_item(nid)%data_step_prev )
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,
')' 547 call file_read( file_external_input_item(nid)%fid, &
548 file_external_input_item(nid)%varname, &
549 file_external_input_item(nid)%value(:,1,1,i_next), &
550 step=file_external_input_item(nid)%data_step_next )
552 elseif( dim_size(1) >= 1 &
553 .AND. dim_size(2) > 1 &
554 .AND. dim_size(3) == 1 )
then 556 call file_external_input_get_dims2d( dim1_max, dim1_s, dim1_e, &
557 dim2_max, dim2_s, dim2_e, &
558 file_external_input_item(nid)%transpose, &
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
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
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,
')' 579 call file_read( file_external_input_item(nid)%fid, &
580 file_external_input_item(nid)%varname, &
581 file_external_input_item(nid)%value(:,:,1,i_prev), &
582 step=file_external_input_item(nid)%data_step_prev )
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,
')' 588 call file_read( file_external_input_item(nid)%fid, &
589 file_external_input_item(nid)%varname, &
590 file_external_input_item(nid)%value(:,:,1,i_next), &
591 step=file_external_input_item(nid)%data_step_next )
593 elseif( dim_size(1) >= 1 &
594 .AND. dim_size(2) > 1 &
595 .AND. dim_size(3) > 1 )
then 597 call file_external_input_get_dims3d( dim1_max, dim1_s, dim1_e, &
598 dim2_max, dim2_s, dim2_e, &
599 dim3_max, dim3_s, dim3_e, &
600 file_external_input_item(nid)%transpose, &
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
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
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,
')' 624 call file_read( file_external_input_item(nid)%fid, &
625 file_external_input_item(nid)%varname, &
626 file_external_input_item(nid)%value(:,:,:,i_prev), &
627 step=file_external_input_item(nid)%data_step_prev )
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,
')' 634 call file_read( file_external_input_item(nid)%fid, &
635 file_external_input_item(nid)%varname, &
636 file_external_input_item(nid)%value(:,:,:,i_next), &
637 step=file_external_input_item(nid)%data_step_next )
640 log_error(
"FILE_EXTERNAL_INPUT_regist",*)
'Unexpected dimsize: ', dim_size(:)
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 )
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]
real(dp), public time_startdaysec
second of start time [sec]
subroutine, public file_open(basename, fid, mode, single, aggregate, rankid, postfix)
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]
integer, public prc_myrank
process num in local communicator
subroutine, public prc_abort
Abort Process.
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.
subroutine, public calendar_date2daysec(absday, abssec, ymdhms, subsec, offset_year)
Convert from gregorian date to absolute day/second.