21 #include <fms_platform.h> 201 &
OPERATOR(<),
OPERATOR(==),
OPERATOR(/=),
OPERATOR(/),
OPERATOR(+),
ASSIGNMENT(=),
get_date, &
203 USE mpp_io_mod,
ONLY: mpp_open, mpp_close, mpp_get_maxunits
204 USE mpp_mod,
ONLY: mpp_get_current_pelist, mpp_pe, mpp_npes, mpp_root_pe,
mpp_sum 206 #ifdef INTERNAL_FILE_NML 209 USE fms_mod,
ONLY: open_namelist_file, close_file
212 USE fms_mod,
ONLY:
error_mesg, fatal, warning, note, stdout, stdlog, write_version_number,&
241 USE netcdf,
ONLY: nf90_int, nf90_float, nf90_char
268 #include<file_version.h> 488 & long_name, units, missing_value, range, standard_name, do_not_log, err_msg,&
489 & area, volume, realm)
490 CHARACTER(len=*),
INTENT(in) :: module_name, field_name
491 TYPE(
time_type),
OPTIONAL,
INTENT(in) :: init_time
492 CHARACTER(len=*),
OPTIONAL,
INTENT(in) :: long_name, units, standard_name
493 REAL,
OPTIONAL,
INTENT(in) :: missing_value
494 REAL,
DIMENSION(2),
OPTIONAL,
INTENT(in) :: range
495 LOGICAL,
OPTIONAL,
INTENT(in) :: do_not_log
496 CHARACTER(len=*),
OPTIONAL,
INTENT(out):: err_msg
497 INTEGER,
OPTIONAL,
INTENT(in) :: area, volume
498 CHARACTER(len=*),
OPTIONAL,
INTENT(in):: realm
500 IF (
PRESENT(err_msg) ) err_msg =
'' 502 IF (
PRESENT(init_time) )
THEN 504 & (/
null_axis_id/), init_time,long_name, units, missing_value, range, &
505 & standard_name=standard_name, do_not_log=do_not_log, err_msg=err_msg,&
506 & area=area, volume=volume, realm=realm)
509 & (/
null_axis_id/),long_name, units, missing_value, range,&
510 & standard_name=standard_name, do_not_log=do_not_log, realm=realm)
537 & long_name, units, missing_value, range, mask_variant, standard_name, verbose,&
538 & do_not_log, err_msg, interp_method, tile_count, area, volume, realm)
539 CHARACTER(len=*),
INTENT(in) :: module_name, field_name
540 INTEGER,
INTENT(in) :: axes(:)
542 CHARACTER(len=*),
OPTIONAL,
INTENT(in) :: long_name, units, standard_name
543 REAL,
OPTIONAL,
INTENT(in) :: missing_value, range(2)
544 LOGICAL,
OPTIONAL,
INTENT(in) :: mask_variant,verbose
545 LOGICAL,
OPTIONAL,
INTENT(in) :: do_not_log
546 CHARACTER(len=*),
OPTIONAL,
INTENT(out):: err_msg
547 CHARACTER(len=*),
OPTIONAL,
INTENT(in) :: interp_method
548 INTEGER,
OPTIONAL,
INTENT(in) :: tile_count
549 INTEGER,
OPTIONAL,
INTENT(in) :: area, volume
550 CHARACTER(len=*),
OPTIONAL,
INTENT(in):: realm
552 INTEGER :: field, j, ind, file_num, freq
553 INTEGER :: i, cm_ind, cm_file_num
554 INTEGER :: output_units
555 INTEGER :: stdout_unit
556 LOGICAL :: mask_variant1, verbose1
558 CHARACTER(len=128) :: msg
561 stdout_unit = stdout()
563 IF (
PRESENT(mask_variant) )
THEN 564 mask_variant1 = mask_variant
566 mask_variant1 = .false.
569 IF (
PRESENT(verbose) )
THEN 575 IF (
PRESENT(err_msg) ) err_msg =
'' 579 & long_name, units, missing_value, range, mask_variant1, standard_name=standard_name,&
580 & dynamic=.true., do_not_log=do_not_log, interp_method=interp_method, tile_count=tile_count, realm=realm)
587 IF ( mpp_pe() == mpp_root_pe() ) &
588 &
CALL error_mesg (
'diag_manager_mod::register_diag_field',
'module/output_field '&
589 &//trim(module_name)//
'/'// trim(field_name)//&
590 &
' registered AFTER first send_data call, TOO LATE', warning)
598 IF ( mpp_pe() == mpp_root_pe() ) &
599 &
CALL error_mesg (
'diag_manager_mod::register_diag_field',
'module/output_field '&
600 &//trim(module_name)//
'/'// trim(field_name)//
' NOT found in diag_table',&
609 IF (
PRESENT(volume).AND.
PRESENT(area) )
THEN 610 IF ( area.EQ.volume )
THEN 611 CALL error_mesg (
'diag_manager_mod::register_diag_field',
'module/output_field '&
612 &//trim(module_name)//
'/'// trim(field_name)//
' AREA and VOLUME CANNOT be the same variable.& 613 & Contact the developers.',&
619 IF (
PRESENT(area) )
THEN 621 CALL error_mesg (
'diag_manager_mod::register_diag_field',
'module/output_field '&
622 &//trim(module_name)//
'/'// trim(field_name)//
' AREA measures field NOT found in diag_table.& 623 & Contact the model liaison.',&
627 IF (
PRESENT(volume) )
THEN 628 IF ( volume < 0 )
THEN 629 CALL error_mesg (
'diag_manager_mod::register_diag_field',
'module/output_field '&
630 &//trim(module_name)//
'/'// trim(field_name)//
' VOLUME measures field NOT found in diag_table.& 631 & Contact the model liaison.',&
636 IF (
PRESENT(standard_name) )
input_fields(field)%standard_name = standard_name
648 files(file_num)%local = .true.
656 IF ( msg /=
'' )
THEN 657 IF (
fms_error_handler(
'diag_manager_mod::register_diag_field', trim(msg), err_msg) )
RETURN 660 freq =
files(file_num)%output_freq
661 output_units =
files(file_num)%output_units
663 IF ( msg /=
'' )
THEN 665 &
' file='//trim(
files(file_num)%name)//
': '//trim(msg),err_msg))
RETURN 669 IF ( msg /=
'' )
THEN 671 &
' file='//trim(
files(file_num)%name)//
': '//trim(msg),err_msg) )
RETURN 674 WRITE (msg,
'(" lon(",F5.1,", ",F5.1,"), lat(",F5.1,", ",F5.1,"), dep(",F5.1,", ",F5.1,")")') &
678 WRITE(stdout_unit,* )
'module/output_field '//trim(module_name)//
'/'//trim(field_name)// &
679 &
' will be output in region:'//trim(msg)
684 IF ( len_trim(err_msg).GT.0 )
THEN 685 CALL error_mesg (
'diag_manager_mod::register_diag_field',&
686 & trim(err_msg)//
' for module/field '//trim(module_name)//
'/'//trim(field_name),&
727 & missing_value, range, mask_variant, standard_name, DYNAMIC, do_not_log, interp_method,&
728 & tile_count, area, volume, realm)
729 CHARACTER(len=*),
INTENT(in) :: module_name, field_name
730 INTEGER,
DIMENSION(:),
INTENT(in) :: axes
731 CHARACTER(len=*),
OPTIONAL,
INTENT(in) :: long_name, units, standard_name
732 REAL,
OPTIONAL,
INTENT(in) :: missing_value
733 REAL,
DIMENSION(2),
OPTIONAL,
INTENT(in) :: range
734 LOGICAL,
OPTIONAL,
INTENT(in) :: mask_variant
735 LOGICAL,
OPTIONAL,
INTENT(in) :: dynamic
736 LOGICAL,
OPTIONAL,
INTENT(in) :: do_not_log
737 CHARACTER(len=*),
OPTIONAL,
INTENT(in) :: interp_method
738 INTEGER,
OPTIONAL,
INTENT(in) :: tile_count, area, volume
739 CHARACTER(len=*),
OPTIONAL,
INTENT(in) :: realm
741 REAL :: missing_value_use
742 INTEGER :: field, num_axes, j, out_num, k
743 INTEGER,
DIMENSION(3) :: siz, local_siz, local_start, local_end
744 INTEGER :: tile, file_num
745 LOGICAL :: mask_variant1, dynamic1, allow_log
746 CHARACTER(len=128) :: msg
747 INTEGER :: domain_type
752 CALL error_mesg (
'diag_manager_mod::register_static_field',
'diag_manager has NOT been initialized', fatal)
756 IF (
PRESENT(missing_value) )
THEN 760 missing_value_use = missing_value
764 IF (
PRESENT(mask_variant) )
THEN 765 mask_variant1 = mask_variant
767 mask_variant1 = .false.
770 IF (
PRESENT(dynamic) )
THEN 776 IF (
PRESENT(tile_count) )
THEN 782 IF (
PRESENT(do_not_log) )
THEN 783 allow_log = .NOT.do_not_log
794 & long_name, units, missing_value=missing_value, range=range, &
804 domain_type = axis_compatible_check(axes,field_name)
812 CALL error_mesg (
'diag_manager_mod::register_diag_field',
'module/output_field '//trim(module_name)//
'/'//&
813 & trim(field_name)//
' is not registered for tile_count = 1, should not register for tile_count > 1',&
840 IF (
input_fields(field)%register .AND. mpp_pe() == mpp_root_pe() )
THEN 845 CALL error_mesg (
'diag_manager_mod::register_diag_field',
'module/output_field '//trim(module_name)//
'/'//&
846 & trim(field_name)//
' ALREADY registered, should not register twice', fatal)
850 IF (
PRESENT(volume).AND.
PRESENT(area) )
THEN 851 IF ( area.EQ.volume )
THEN 852 CALL error_mesg (
'diag_manager_mod::register_static_field',
'module/output_field '&
853 &//trim(module_name)//
'/'// trim(field_name)//
' AREA and VOLUME CANNOT be the same variable.& 854 & Contact the developers.',&
860 IF (
PRESENT(area) )
THEN 862 CALL error_mesg (
'diag_manager_mod::register_static_field',
'module/output_field '&
863 &//trim(module_name)//
'/'// trim(field_name)//
' AREA measures field NOT found in diag_table.& 864 & Contact the model liaison.n',&
868 IF (
PRESENT(volume) )
THEN 869 IF ( volume < 0 )
THEN 870 CALL error_mesg (
'diag_manager_mod::register_static_field',
'module/output_field '&
871 &//trim(module_name)//
'/'// trim(field_name)//
' VOLUME measures field NOT found in diag_table& 872 & Contact the model liaison.',&
882 input_fields(field)%issued_mask_ignore_warning = .false.
885 IF (
PRESENT(long_name) )
THEN 891 IF (
PRESENT(standard_name) )
input_fields(field)%standard_name = standard_name
893 IF (
PRESENT(units) )
THEN 899 IF (
PRESENT(missing_value) )
THEN 906 IF (
PRESENT(range) )
THEN 909 input_fields(field)%range_present = range(2) .gt. range(1)
915 IF (
PRESENT(interp_method) )
THEN 916 IF ( trim(interp_method) .NE.
'conserve_order1' .AND.&
917 & trim(interp_method) .NE.
'conserve_order2' .AND.&
918 & trim(interp_method) .NE.
'none' )
THEN 924 CALL error_mesg (
'diag_manager_mod::register_diag_field',&
925 &
'when registering module/output_field '//trim(module_name)//
'/'//&
926 & trim(field_name)//
', the optional argument interp_method = '//trim(interp_method)//&
927 &
', but it should be "conserve_order1", "conserve_order2", or "none"', fatal)
935 num_axes =
SIZE(axes(:))
941 IF ( axes(j) .LE. 0 )
THEN 945 CALL error_mesg (
'diag_manager_mod::register_diag_field',
'module/output_field '//trim(module_name)//
'/'//&
946 & trim(field_name)//
' has non-positive axis_id', fatal)
948 siz(j) = get_axis_length(axes(j))
964 IF(mpp_pe() .EQ. mpp_root_pe())
THEN 968 CALL error_mesg (
'diag_manager_mod::register_diag_field ',
'output_field '//trim(field_name)// &
969 ' has pack >=4, range is REQUIRED in register_diag_field', fatal)
974 IF ( .NOT.dynamic1 )
output_fields(out_num)%n_diurnal_samples = 1
979 if (domain_type .eq. diag_axis_2ddomain)
then 980 if (
files(file_num)%use_domainUG)
then 981 call error_mesg(
"diag_manager_mod::register_static_field", &
982 "Diagnostics living on a structured grid" &
983 //
" and an unstructured grid cannot exist" &
984 //
" in the same file (" &
985 //trim(
files(file_num)%name)//
")", &
987 elseif (.not.
files(file_num)%use_domain2D)
then 988 files(file_num)%use_domain2D = .true.
991 if (
files(file_num)%use_domain2D)
then 992 call error_mesg(
"diag_manager_mod::register_static_field", &
993 "Diagnostics living on a structured grid" &
994 //
" and an unstructured grid cannot exist" &
995 //
" in the same file (" &
996 //trim(
files(file_num)%name)//
")", &
998 elseif (.not.
files(file_num)%use_domainUG)
then 999 files(file_num)%use_domainUG = .true.
1014 local_start(2) =
output_fields(out_num)%output_grid%l_start_indx(2)
1015 local_end(2) =
output_fields(out_num)%output_grid%l_end_indx(2)
1016 local_siz(2) = local_end(2) - local_start(2) + 1
1017 allocate(
output_fields(out_num)%buffer(siz(1),local_siz(2),siz(3), &
1019 output_fields(out_num)%region_elements = siz(1)*local_siz(2)*siz(3)
1022 local_start(3) =
output_fields(out_num)%output_grid%l_start_indx(3)
1023 local_end(3) =
output_fields(out_num)%output_grid%l_end_indx(3)
1024 local_siz(3) = local_end(3) - local_start(3) + 1
1025 allocate(
output_fields(out_num)%buffer(siz(1),siz(2),local_siz(3), &
1027 output_fields(out_num)%region_elements = siz(1)*siz(2)*local_siz(3)
1030 output_fields(out_num)%total_elements = siz(1)*siz(2)*siz(3)
1041 IF (
SIZE(axes(:)) .LE. 1 )
THEN 1043 CALL error_mesg (
'diag_manager_mod::register_diag_field',
'axes of '//trim(field_name)//&
1044 &
' must >= 2 for local output', fatal)
1049 local_start(k) =
output_fields(out_num)%output_grid%l_start_indx(k)
1050 local_end(k) =
output_fields(out_num)%output_grid%l_end_indx(k)
1051 local_siz(k) = local_end(k) - local_start(k) +1
1053 ALLOCATE(
output_fields(out_num)%buffer(local_siz(1), local_siz(2), local_siz(3),&
1062 output_fields(out_num)%region_elements = local_siz(1)*local_siz(2)*local_siz(3)
1063 output_fields(out_num)%total_elements = siz(1)*siz(2)*siz(3)
1068 ALLOCATE(
output_fields(out_num)%buffer(siz(1), siz(2), siz(3),&
1077 output_fields(out_num)%total_elements = siz(1)*siz(2)*siz(3)
1083 IF ( .NOT.dynamic1 .AND.
output_fields(out_num)%time_ops )
THEN 1084 WRITE (msg,
'(a,"/",a)') trim(module_name), trim(field_name)
1085 IF ( mpp_pe() .EQ. mpp_root_pe() )
THEN 1092 CALL error_mesg (
'diag_manager_mod::register_static_field',&
1093 &
'module/field '//trim(msg)//
' is STATIC. Cannot perform time operations& 1094 & average, maximum, or minimum on static fields. Setting the time operation& 1095 & to "NONE" for this field.', warning)
1138 IF ( len_trim(msg).GT.0 )
THEN 1139 CALL error_mesg (
'diag_manager_mod::register_static_field',&
1140 & trim(msg)//
' for module/field '//trim(module_name)//
'/'//trim(field_name),&
1145 IF (
PRESENT(realm) )
THEN 1161 allocate(
output_fields(out_num)%counter(siz(1),local_siz(2),siz(3), &
1164 allocate(
output_fields(out_num)%counter(siz(1),siz(2),siz(3), &
1190 CHARACTER(len=*),
INTENT(in) :: module_name, field_name
1213 INTEGER,
INTENT(in) :: field
1215 INTEGER,
INTENT(out) :: out_field_id, out_file_id
1217 INTEGER :: i, cm_ind, cm_file_num
1221 rel_file = rel_field%output_file
1233 IF ( cm_file_num.EQ.rel_file.AND.&
1234 & (( (
output_fields(cm_ind)%time_ops.EQV.rel_field%time_ops) .AND.&
1235 & (
output_fields(cm_ind)%next_output.EQ.rel_field%next_output) .AND.&
1236 & (
output_fields(cm_ind)%last_output.EQ.rel_field%last_output) ).OR.&
1237 & (
output_fields(cm_ind)%static.OR.rel_field%static) ) )
THEN 1239 out_field_id = cm_ind
1240 out_file_id = cm_file_num
1260 IF (
output_fields(cm_ind)%static.OR.rel_field%static )
THEN 1262 out_field_id = cm_ind
1263 out_file_id = cm_file_num
1286 TYPE(output_field_type),
INTENT(inout) :: output_field
1287 INTEGER,
INTENT(in),
OPTIONAL :: area, volume
1288 CHARACTER(len=*),
INTENT(out),
OPTIONAL :: err_msg
1290 INTEGER :: cm_ind, cm_file_num, file_num
1292 IF (
PRESENT(err_msg) )
THEN 1297 IF (
PRESENT(area) )
THEN 1298 IF ( area.LE.0 )
THEN 1300 &
'AREA field not in diag_table for field '//trim(
input_fields(output_field%input_field)%module_name)//&
1301 &
'/'//trim(
input_fields(output_field%input_field)%field_name), err_msg) )
RETURN 1305 IF (
PRESENT(volume) )
THEN 1306 IF ( volume.LE.0 )
THEN 1308 &
'VOLUME field not in diag_table for field '//trim(
input_fields(output_field%input_field)%module_name)//&
1309 &
'/'//trim(
input_fields(output_field%input_field)%field_name), err_msg) )
RETURN 1314 file_num = output_field%output_file
1317 IF (
PRESENT(area) )
THEN 1321 IF ( cm_file_num.NE.file_num )
THEN 1327 &
'AREA measures field "'//trim(
input_fields(area)%module_name)//
'/'//&
1329 &
'" NOT in diag_table with correct output frequency for field '//&
1330 & trim(
input_fields(output_field%input_field)%module_name)//&
1331 &
'/'//trim(
input_fields(output_field%input_field)%field_name), err_msg) )
RETURN 1336 IF (
PRESENT(volume) )
THEN 1340 IF ( cm_file_num.NE.file_num )
THEN 1346 &
'VOLUME measures field "'//trim(
input_fields(volume)%module_name)//
'/'//&
1348 &
'" NOT in diag_table with correct output frequency for field '//&
1349 & trim(
input_fields(output_field%input_field)%module_name)//&
1350 &
'/'//trim(
input_fields(output_field%input_field)%field_name), err_msg) )
RETURN 1362 INTEGER,
intent(in) :: file_num
1363 INTEGER,
intent(in) :: cm_file_num
1364 INTEGER,
intent(in) :: cm_ind
1366 INTEGER :: year, month, day, hour, minute, second
1368 CHARACTER(len=25) :: date_prefix
1369 CHARACTER(len=256) :: asso_file_name
1374 WRITE (date_prefix,
'(1I20.4, 2I2.2,".")') year, month, day
1375 date_prefix=adjustl(date_prefix)
1383 IF ( len_trim(
files(cm_file_num)%name)+17 > len(asso_file_name) )
THEN 1384 CALL error_mesg (
'diag_manager_mod::add_associated_files',&
1385 &
'Length of asso_file_name is not long enough to hold the associated file name. '&
1386 & //
'Contact the developer', fatal)
1388 asso_file_name = trim(
files(cm_file_num)%name)
1399 n =
max(len_trim(asso_file_name),3)
1400 if (asso_file_name(n-2:n).NE.
'.nc') asso_file_name = trim(asso_file_name)//
'.nc' 1405 & trim(date_prefix)//trim(asso_file_name))
1422 LOGICAL FUNCTION send_data_0d(diag_field_id, field, time, err_msg)
1423 INTEGER,
INTENT(in) :: diag_field_id
1424 REAL,
INTENT(in) :: field
1425 TYPE(
time_type),
INTENT(in),
OPTIONAL :: time
1426 CHARACTER(len=*),
INTENT(out),
OPTIONAL :: err_msg
1428 REAL :: field_out(1, 1, 1)
1431 IF ( diag_field_id <= 0 )
THEN 1436 field_out(1, 1, 1) = field
1455 LOGICAL FUNCTION send_data_1d(diag_field_id, field, time, is_in, mask, rmask, ie_in, weight, err_msg)
1456 INTEGER,
INTENT(in) :: diag_field_id
1457 REAL,
DIMENSION(:),
INTENT(in) :: field
1458 REAL,
INTENT(in),
OPTIONAL :: weight
1459 REAL,
INTENT(in),
DIMENSION(:),
OPTIONAL :: rmask
1460 type(
time_type),
INTENT(in),
OPTIONAL :: time
1461 INTEGER,
INTENT(in),
OPTIONAL :: is_in, ie_in
1462 LOGICAL,
INTENT(in),
DIMENSION(:),
OPTIONAL :: mask
1463 CHARACTER(len=*),
INTENT(out),
OPTIONAL :: err_msg
1465 REAL,
DIMENSION(SIZE(field(:)), 1, 1) :: field_out
1466 LOGICAL,
DIMENSION(SIZE(field(:)), 1, 1) :: mask_out
1469 IF ( diag_field_id <= 0 )
THEN 1475 field_out(:, 1, 1) = field
1478 IF (
PRESENT(mask) )
THEN 1479 mask_out(:, 1, 1) = mask
1484 IF (
PRESENT(rmask) )
WHERE (rmask < 0.5) mask_out(:, 1, 1) = .false.
1485 IF (
PRESENT(mask) .OR.
PRESENT(rmask) )
THEN 1486 IF (
PRESENT(is_in) .OR.
PRESENT(ie_in) )
THEN 1488 & mask=mask_out, ie_in=ie_in, je_in=1, ke_in=1, weight=weight, err_msg=err_msg)
1491 & weight=weight, err_msg=err_msg)
1494 IF (
PRESENT(is_in) .OR.
PRESENT(ie_in) )
THEN 1496 & ie_in=ie_in, je_in=1, ke_in=1, weight=weight, err_msg=err_msg)
1518 LOGICAL FUNCTION send_data_2d(diag_field_id, field, time, is_in, js_in, &
1519 & mask, rmask, ie_in, je_in, weight, err_msg)
1520 INTEGER,
INTENT(in) :: diag_field_id
1521 REAL,
INTENT(in),
DIMENSION(:,:) :: field
1522 REAL,
INTENT(in),
OPTIONAL :: weight
1523 type(
time_type),
INTENT(in),
OPTIONAL :: time
1524 INTEGER,
INTENT(in),
OPTIONAL :: is_in, js_in, ie_in, je_in
1525 LOGICAL,
INTENT(in),
DIMENSION(:,:),
OPTIONAL :: mask
1526 REAL,
INTENT(in),
DIMENSION(:,:),
OPTIONAL :: rmask
1527 CHARACTER(len=*),
INTENT(out),
OPTIONAL :: err_msg
1529 REAL,
DIMENSION(SIZE(field,1),SIZE(field,2),1) :: field_out
1530 LOGICAL,
DIMENSION(SIZE(field,1),SIZE(field,2),1) :: mask_out
1533 IF ( diag_field_id <= 0 )
THEN 1539 field_out(:, :, 1) = field
1542 IF (
PRESENT(mask) )
THEN 1543 mask_out(:, :, 1) = mask
1548 IF (
PRESENT(rmask) )
WHERE ( rmask < 0.5 ) mask_out(:, :, 1) = .false.
1549 IF (
PRESENT(mask) .OR.
PRESENT(rmask) )
THEN 1551 & ie_in=ie_in, je_in=je_in, ke_in=1, weight=weight, err_msg=err_msg)
1554 & ie_in=ie_in, je_in=je_in, ke_in=1, weight=weight, err_msg=err_msg)
1561 LOGICAL FUNCTION send_data_2d_r8(diag_field_id, field, time, is_in, js_in, &
1562 & mask, rmask, ie_in, je_in, weight, err_msg)
1563 INTEGER,
INTENT(in) :: diag_field_id
1564 REAL(kind=8),
INTENT(in),
DIMENSION(:,:) :: field
1565 REAL,
INTENT(in),
OPTIONAL :: weight
1566 type(
time_type),
INTENT(in),
OPTIONAL :: time
1567 INTEGER,
INTENT(in),
OPTIONAL :: is_in, js_in, ie_in, je_in
1568 LOGICAL,
INTENT(in),
DIMENSION(:,:),
OPTIONAL :: mask
1569 REAL,
INTENT(in),
DIMENSION(:,:),
OPTIONAL :: rmask
1570 CHARACTER(len=*),
INTENT(out),
OPTIONAL :: err_msg
1572 REAL,
DIMENSION(SIZE(field,1),SIZE(field,2),1) :: field_out
1573 LOGICAL,
DIMENSION(SIZE(field,1),SIZE(field,2),1) :: mask_out
1576 IF ( diag_field_id <= 0 )
THEN 1582 field_out(:, :, 1) = field
1585 IF (
PRESENT(mask) )
THEN 1586 mask_out(:, :, 1) = mask
1591 IF (
PRESENT(rmask) )
WHERE ( rmask < 0.5 ) mask_out(:, :, 1) = .false.
1592 IF (
PRESENT(mask) .OR.
PRESENT(rmask) )
THEN 1594 & ie_in=ie_in, je_in=je_in, ke_in=1, weight=weight, err_msg=err_msg)
1597 & ie_in=ie_in, je_in=je_in, ke_in=1, weight=weight, err_msg=err_msg)
1603 LOGICAL FUNCTION send_data_3d_r8(diag_field_id, field, time, is_in, js_in, ks_in, &
1604 & mask, rmask, ie_in, je_in, ke_in, weight, err_msg)
1605 INTEGER,
INTENT(in) :: diag_field_id
1606 REAL(kind=8),
INTENT(in),
DIMENSION(:,:,:) :: field
1607 REAL,
INTENT(in),
OPTIONAL :: weight
1608 type(
time_type),
INTENT(in),
OPTIONAL :: time
1609 INTEGER,
INTENT(in),
OPTIONAL :: is_in, js_in, ks_in,ie_in,je_in, ke_in
1610 LOGICAL,
INTENT(in),
DIMENSION(:,:,:),
OPTIONAL :: mask
1611 REAL,
INTENT(in),
DIMENSION(:,:,:),
OPTIONAL :: rmask
1612 CHARACTER(len=*),
INTENT(out),
OPTIONAL :: err_msg
1614 REAL,
DIMENSION(SIZE(field,1),SIZE(field,2),size(field,3)) :: field_out
1615 LOGICAL,
DIMENSION(SIZE(field,1),SIZE(field,2),size(field,3)) :: mask_out
1618 IF ( diag_field_id <= 0 )
THEN 1627 IF (
PRESENT(mask) )
THEN 1633 IF (
PRESENT(rmask) )
WHERE ( rmask < 0.5 ) mask_out = .false.
1634 IF (
PRESENT(mask) .OR.
PRESENT(rmask) )
THEN 1636 & ie_in=ie_in, je_in=je_in, ke_in=ke_in, weight=weight, err_msg=err_msg)
1639 & ie_in=ie_in, je_in=je_in, ke_in=ke_in, weight=weight, err_msg=err_msg)
1659 LOGICAL FUNCTION send_data_3d(diag_field_id, field, time, is_in, js_in, ks_in, &
1660 & mask, rmask, ie_in, je_in, ke_in, weight, err_msg)
1661 INTEGER,
INTENT(in) :: diag_field_id
1662 REAL,
DIMENSION(:,:,:),
INTENT(in) :: field
1663 REAL,
INTENT(in),
OPTIONAL :: weight
1664 type(
time_type),
INTENT(in),
OPTIONAL :: time
1665 INTEGER,
INTENT(in),
OPTIONAL :: is_in, js_in, ks_in,ie_in,je_in, ke_in
1666 LOGICAL,
DIMENSION(:,:,:),
INTENT(in),
OPTIONAL :: mask
1667 REAL,
DIMENSION(:,:,:),
INTENT(in),
OPTIONAL :: rmask
1668 CHARACTER(len=*),
INTENT(out),
OPTIONAL :: err_msg
1672 INTEGER :: pow_value
1674 INTEGER :: i, out_num, file_num, n1, n2, n3, number_of_outputs, ii,f1,f2,f3,f4
1675 INTEGER :: freq, units, is, js, ks, ie, je, ke, i1, j1,k1, j, k
1676 INTEGER,
DIMENSION(3) :: l_start, l_end
1677 INTEGER :: hi, hj, twohi, twohj
1679 INTEGER :: day,second,tick
1681 INTEGER :: numthreads
1682 INTEGER :: active_omp_level
1683 #if defined(_OPENMP) 1684 INTEGER :: omp_get_num_threads
1685 INTEGER :: omp_get_level
1687 LOGICAL :: average, phys_window, need_compute
1688 LOGICAL :: reduced_k_range, local_output
1689 LOGICAL :: time_max, time_min, time_rms, time_sum
1690 LOGICAL :: missvalue_present
1691 LOGICAL,
ALLOCATABLE,
DIMENSION(:,:,:) :: oor_mask
1692 CHARACTER(len=256) :: err_msg_local
1693 CHARACTER(len=128) :: error_string, error_string1
1696 IF ( diag_field_id <= 0 )
THEN 1703 IF (
PRESENT(err_msg) ) err_msg =
'' 1705 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d',
'diag_manager NOT initialized', err_msg) )
RETURN 1718 ALLOCATE(oor_mask(
SIZE(field,1),
SIZE(field,2),
SIZE(field,3)), stat=status)
1719 IF ( status .NE. 0 )
THEN 1720 WRITE (err_msg_local, fmt=
'("Unable to allocate oor_mask(",I5,",",I5,",",I5,"). (STAT: ",I5,")")')&
1721 &
SIZE(field,1),
SIZE(field,2),
SIZE(field,3), status
1722 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
RETURN 1725 IF (
PRESENT(mask) )
THEN 1730 IF (
PRESENT(rmask) )
WHERE ( rmask < 0.5 ) oor_mask = .false.
1743 IF (
PRESENT(ie_in) )
THEN 1744 IF ( .NOT.
PRESENT(is_in) )
THEN 1745 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d',
'ie_in present without is_in', err_msg) )
THEN 1746 DEALLOCATE(oor_mask)
1750 IF (
PRESENT(js_in) .AND. .NOT.
PRESENT(je_in) )
THEN 1752 &
'is_in and ie_in present, but js_in present without je_in', err_msg) )
THEN 1753 DEALLOCATE(oor_mask)
1758 IF (
PRESENT(je_in) )
THEN 1759 IF ( .NOT.
PRESENT(js_in) )
THEN 1760 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d',
'je_in present without js_in', err_msg) )
THEN 1761 DEALLOCATE(oor_mask)
1765 IF (
PRESENT(is_in) .AND. .NOT.
PRESENT(ie_in) )
THEN 1767 &
'js_in and je_in present, but is_in present without ie_in', err_msg))
THEN 1768 DEALLOCATE(oor_mask)
1778 IF (
PRESENT(is_in) ) is = is_in
1779 IF (
PRESENT(js_in) ) js = js_in
1780 IF (
PRESENT(ks_in) ) ks = ks_in
1787 IF (
PRESENT(ie_in) ) ie = ie_in
1788 IF (
PRESENT(je_in) ) je = je_in
1789 IF (
PRESENT(ke_in) ) ke = ke_in
1790 twohi = n1-(ie-is+1)
1791 IF ( mod(twohi,2) /= 0 )
THEN 1792 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d',
'non-symmetric halos in first dimension', err_msg) )
THEN 1793 DEALLOCATE(oor_mask)
1797 twohj = n2-(je-js+1)
1798 IF ( mod(twohj,2) /= 0 )
THEN 1799 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d',
'non-symmetric halos in second dimension', err_msg) )
THEN 1800 DEALLOCATE(oor_mask)
1809 IF (
PRESENT(ie_in) .AND.
PRESENT(je_in) )
THEN 1823 IF (
PRESENT(weight) )
THEN 1830 missvalue_present =
input_fields(diag_field_id)%missing_value_present
1831 IF ( missvalue_present ) missvalue =
input_fields(diag_field_id)%missing_value
1833 number_of_outputs =
input_fields(diag_field_id)%num_output_fields
1837 #if defined(_OPENMP) 1838 input_fields(diag_field_id)%numthreads = omp_get_num_threads()
1839 input_fields(diag_field_id)%active_omp_level = omp_get_level()
1842 active_omp_level =
input_fields(diag_field_id)%active_omp_level
1845 if(
present(time))
input_fields(diag_field_id)%time = time
1850 WRITE (error_string,
'("[",ES14.5E3,",",ES14.5E3,"]")')&
1852 WRITE (error_string1,
'("(Min: ",ES14.5E3,", Max: ",ES14.5E3, ")")')&
1853 & minval(field(f1:f2,f3:f4,ks:ke),mask=oor_mask(f1:f2,f3:f4,ks:ke)),&
1854 & maxval(field(f1:f2,f3:f4,ks:ke),mask=oor_mask(f1:f2,f3:f4,ks:ke))
1855 IF ( missvalue_present )
THEN 1856 IF ( any(oor_mask(f1:f2,f3:f4,ks:ke) .AND.&
1857 & ((field(f1:f2,f3:f4,ks:ke) <
input_fields(diag_field_id)%range(1) .OR.&
1858 & field(f1:f2,f3:f4,ks:ke) >
input_fields(diag_field_id)%range(2)).AND.&
1859 & field(f1:f2,f3:f4,ks:ke) .NE. missvalue)) )
THEN 1865 CALL error_mesg(
'diag_manager_mod::send_data_3d',&
1867 &trim(
input_fields(diag_field_id)%module_name)//
' in field '//&
1869 &//trim(error_string1)//&
1870 &
' is outside the range '//trim(error_string)//
',& 1871 & and not equal to the missing value.',&
1875 IF ( any(oor_mask(f1:f2,f3:f4,ks:ke) .AND.&
1876 & (field(f1:f2,f3:f4,ks:ke) <
input_fields(diag_field_id)%range(1) .OR.&
1877 & field(f1:f2,f3:f4,ks:ke) >
input_fields(diag_field_id)%range(2))) )
THEN 1882 CALL error_mesg(
'diag_manager_mod::send_data_3d',&
1884 &trim(
input_fields(diag_field_id)%module_name)//
' in field '//&
1886 &//trim(error_string1)//&
1887 &
' is outside the range '//trim(error_string)//
'.',&
1895 num_out_fields:
DO ii = 1, number_of_outputs
1897 out_num =
input_fields(diag_field_id)%output_fields(ii)
1907 IF ( local_output .AND. (.NOT.need_compute) ) cycle
1913 freq =
files(file_num)%output_freq
1914 units =
files(file_num)%output_units
1927 IF (
output_fields(out_num)%total_elements >
SIZE(field(f1:f2,f3:f4,ks:ke)) )
THEN 1933 IF ( need_compute )
THEN 1940 IF (
PRESENT(time) )
THEN 1941 CALL get_time(time,second,day,tick)
1946 IF ( reduced_k_range )
THEN 1953 l_start(3) =
output_fields(out_num)%output_grid%l_start_indx(3)
1963 IF(
PRESENT(time))
THEN 1966 WRITE (error_string,
'(a,"/",a)')&
1969 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d',
'module/output_field '//trim(error_string)//&
1970 &
', time must be present when output frequency = EVERY_TIME', err_msg))
THEN 1971 DEALLOCATE(oor_mask)
1977 IF ( .NOT.
output_fields(out_num)%static .AND. .NOT.
PRESENT(time) )
THEN 1978 WRITE (error_string,
'(a,"/",a)')&
1981 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d',
'module/output_field '//trim(error_string)//&
1982 &
', time must be present for nonstatic field', err_msg))
THEN 1983 DEALLOCATE(oor_mask)
1991 IF ( (numthreads == 1) .AND. (active_omp_level.LE.1) )
then 1995 IF ( time >
output_fields(out_num)%next_next_output .AND. freq > 0 )
THEN 1996 IF ( mpp_pe() .EQ. mpp_root_pe() )
THEN 1997 WRITE (error_string,
'(a,"/",a)')&
2000 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d',
'module/output_field '//trim(error_string)//&
2001 &
' is skipped one time level in output data', err_msg))
THEN 2002 DEALLOCATE(oor_mask)
2008 status =
writing_field(out_num, .false., error_string, time)
2009 IF(status == -1)
THEN 2010 IF ( mpp_pe() .EQ. mpp_root_pe() )
THEN 2011 IF(
fms_error_handler(
'diag_manager_mod::send_data_3d',
'module/output_field '//trim(error_string)//&
2012 &
', write EMPTY buffer', err_msg))
THEN 2013 DEALLOCATE(oor_mask)
2025 IF ( err_msg_local /=
'' )
THEN 2026 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 2027 DEALLOCATE(oor_mask)
2036 IF ( need_compute )
THEN 2037 WRITE (error_string,
'(a,"/",a)') &
2040 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d',
'module/output_field '//trim(error_string)//&
2041 &
', regional output NOT supported with mask_variant', err_msg))
THEN 2042 DEALLOCATE(oor_mask)
2049 IF (
PRESENT(mask) )
THEN 2050 IF ( missvalue_present )
THEN 2052 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
2054 IF ( err_msg_local /=
'' )
THEN 2055 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 2056 DEALLOCATE(oor_mask)
2061 IF( numthreads>1 .AND. phys_window )
then 2062 IF ( reduced_k_range )
THEN 2067 IF ( mask(i-is+1+hi, j-js+1+hj, k) )
THEN 2068 IF ( pow_value /= 1 )
THEN 2071 & (field(i-is+1+hi, j-js+1+hj, k) * weight1)**(pow_value)
2075 & field(i-is+1+hi, j-js+1+hj, k) * weight1
2078 &
output_fields(out_num)%counter(i-hi,j-hj,k1,sample) + weight1
2087 IF ( mask(i-is+1+hi, j-js+1+hj, k) )
THEN 2088 IF ( pow_value /= 1 )
THEN 2091 & (field(i-is+1+hi,j-js+1+hj,k)*weight1)**(pow_value)
2095 & field(i-is+1+hi,j-js+1+hj,k)*weight1
2098 &
output_fields(out_num)%counter(i-hi,j-hj,k,sample) + weight1
2106 IF ( reduced_k_range )
THEN 2111 IF ( mask(i-is+1+hi, j-js+1+hj, k) )
THEN 2112 IF ( pow_value /= 1 )
THEN 2115 & (field(i-is+1+hi, j-js+1+hj, k) * weight1)**(pow_value)
2119 & field(i-is+1+hi, j-js+1+hj, k) * weight1
2122 &
output_fields(out_num)%counter(i-hi,j-hj,k1,sample) + weight1
2131 IF ( mask(i-is+1+hi, j-js+1+hj, k) )
THEN 2132 IF ( pow_value /= 1 )
THEN 2135 & (field(i-is+1+hi,j-js+1+hj,k)*weight1)**(pow_value)
2139 & field(i-is+1+hi,j-js+1+hj,k)*weight1
2142 &
output_fields(out_num)%counter(i-hi,j-hj,k,sample) + weight1
2151 WRITE (error_string,
'(a,"/",a)')&
2154 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d',
'module/output_field '//trim(error_string)//&
2155 &
', variable mask but no missing value defined', err_msg))
THEN 2156 DEALLOCATE(oor_mask)
2161 WRITE (error_string,
'(a,"/",a)')&
2164 IF(
fms_error_handler(
'diag_manager_mod::send_data_3d',
'module/output_field '//trim(error_string)//&
2165 &
', variable mask but no mask given', err_msg))
THEN 2166 DEALLOCATE(oor_mask)
2171 IF (
PRESENT(mask) )
THEN 2172 IF ( missvalue_present )
THEN 2173 IF ( need_compute )
THEN 2174 IF (numthreads>1 .AND. phys_window)
then 2175 DO k = l_start(3), l_end(3)
2179 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2180 i1 = i-l_start(1)-hi+1
2181 j1= j-l_start(2)-hj+1
2182 IF ( mask(i-is+1+hi, j-js+1+hj, k) )
THEN 2183 IF ( pow_value /= 1 )
THEN 2186 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2190 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2201 DO k = l_start(3), l_end(3)
2205 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2206 i1 = i-l_start(1)-hi+1
2207 j1= j-l_start(2)-hj+1
2208 IF ( mask(i-is+1+hi, j-js+1+hj, k) )
THEN 2209 IF ( pow_value /= 1 )
THEN 2212 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2216 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2230 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2232 output_fields(out_num)%num_elements(sample) + l_end(3) - l_start(3) + 1
2237 ELSE IF ( reduced_k_range )
THEN 2238 IF (numthreads>1 .AND. phys_window)
then 2243 IF ( mask(i-is+1+hi,j-js+1+hj,k) )
THEN 2244 IF ( pow_value /= 1 )
THEN 2247 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2251 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2254 output_fields(out_num)%buffer(i-hi,j-hj,k1,sample)= missvalue
2265 IF ( mask(i-is+1+hi,j-js+1+hj,k) )
THEN 2266 IF ( pow_value /= 1 )
THEN 2269 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2273 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2276 output_fields(out_num)%buffer(i-hi,j-hj,k1,sample)= missvalue
2285 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
2287 IF ( err_msg_local /=
'' )
THEN 2288 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 2289 DEALLOCATE(oor_mask)
2294 IF (numthreads>1 .AND. phys_window)
then 2298 IF ( mask(i-is+1+hi,j-js+1+hj,k) )
THEN 2299 IF ( pow_value /= 1 )
THEN 2302 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2306 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2309 output_fields(out_num)%buffer(i-hi,j-hj,k,sample)= missvalue
2319 IF ( mask(i-is+1+hi,j-js+1+hj,k) )
THEN 2320 IF ( pow_value /= 1 )
THEN 2323 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2327 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2330 output_fields(out_num)%buffer(i-hi,j-hj,k,sample)= missvalue
2339 IF ( need_compute .AND. .NOT.phys_window )
THEN 2340 IF ( any(mask(l_start(1)+hi:l_end(1)+hi,l_start(2)+hj:l_end(2)+hj,l_start(3):l_end(3))) ) &
2344 IF ( any(mask(f1:f2,f3:f4,ks:ke)) )
output_fields(out_num)%count_0d(sample) =&
2350 IF ( (.NOT.all(mask(f1:f2,f3:f4,ks:ke)) .AND. mpp_pe() .EQ. mpp_root_pe()).AND.&
2351 & .NOT.
input_fields(diag_field_id)%issued_mask_ignore_warning )
THEN 2356 CALL error_mesg(
'diag_manager_mod::send_data_3d',&
2357 &
'Mask will be ignored since missing values were not specified for field '//&
2358 & trim(
input_fields(diag_field_id)%field_name)//
' in module '//&
2359 & trim(
input_fields(diag_field_id)%module_name), warning)
2360 input_fields(diag_field_id)%issued_mask_ignore_warning = .true.
2362 IF ( need_compute )
THEN 2363 IF (numthreads>1 .AND. phys_window)
then 2366 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2367 i1 = i-l_start(1)-hi+1
2368 j1 = j-l_start(2)-hj+1
2369 IF ( pow_value /= 1 )
THEN 2371 & (field(i-is+1+hi,j-js+1+hj,l_start(3):l_end(3))*weight1)**(pow_value)
2374 & field(i-is+1+hi,j-js+1+hj,l_start(3):l_end(3))*weight1
2383 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2384 i1 = i-l_start(1)-hi+1
2385 j1 = j-l_start(2)-hj+1
2386 IF ( pow_value /= 1 )
THEN 2388 & (field(i-is+1+hi,j-js+1+hj,l_start(3):l_end(3))*weight1)**(pow_value)
2391 & field(i-is+1+hi,j-js+1+hj,l_start(3):l_end(3))*weight1
2401 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2403 &
output_fields(out_num)%num_elements(sample)+l_end(3)-l_start(3)+1
2409 ELSE IF ( reduced_k_range )
THEN 2410 IF (numthreads>1 .AND. phys_window)
then 2413 IF ( pow_value /= 1 )
THEN 2414 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) =&
2415 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) +&
2416 & (field(f1:f2,f3:f4,ksr:ker)*weight1)**(pow_value)
2418 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) =&
2419 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) +&
2420 & field(f1:f2,f3:f4,ksr:ker)*weight1
2426 IF ( pow_value /= 1 )
THEN 2427 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) =&
2428 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) +&
2429 & (field(f1:f2,f3:f4,ksr:ker)*weight1)**(pow_value)
2431 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) =&
2432 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) +&
2433 & field(f1:f2,f3:f4,ksr:ker)*weight1
2439 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
2441 IF ( err_msg_local /=
'')
THEN 2442 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 2443 DEALLOCATE(oor_mask)
2448 IF (numthreads>1 .AND. phys_window)
then 2449 IF ( pow_value /= 1 )
THEN 2450 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) =&
2451 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) +&
2452 & (field(f1:f2,f3:f4,ks:ke)*weight1)**(pow_value)
2454 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) =&
2455 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) +&
2456 & field(f1:f2,f3:f4,ks:ke)*weight1
2460 IF ( pow_value /= 1 )
THEN 2461 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) =&
2462 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) +&
2463 & (field(f1:f2,f3:f4,ks:ke)*weight1)**(pow_value)
2465 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) =&
2466 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) +&
2467 & field(f1:f2,f3:f4,ks:ke)*weight1
2473 IF ( .NOT.phys_window )
output_fields(out_num)%count_0d(sample) =&
2478 IF ( missvalue_present )
THEN 2479 IF ( need_compute )
THEN 2480 if( numthreads>1 .AND. phys_window )
then 2481 DO k = l_start(3), l_end(3)
2482 k1 = k - l_start(3) + 1
2485 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj)
THEN 2486 i1 = i-l_start(1)-hi+1
2487 j1= j-l_start(2)-hj+1
2488 IF ( field(i-is+1+hi,j-js+1+hj,k) /= missvalue )
THEN 2489 IF ( pow_value /= 1 )
THEN 2492 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2496 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2507 DO k = l_start(3), l_end(3)
2508 k1 = k - l_start(3) + 1
2511 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj)
THEN 2512 i1 = i-l_start(1)-hi+1
2513 j1= j-l_start(2)-hj+1
2514 IF ( field(i-is+1+hi,j-js+1+hj,k) /= missvalue )
THEN 2515 IF ( pow_value /= 1 )
THEN 2518 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2522 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2536 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj)
THEN 2538 &
output_fields(out_num)%num_elements(sample) + l_end(3) - l_start(3) + 1
2542 IF ( .NOT.phys_window )
THEN 2543 outer0:
DO k = l_start(3), l_end(3)
2544 DO j=l_start(2)+hj, l_end(2)+hj
2545 DO i=l_start(1)+hi, l_end(1)+hi
2546 IF ( field(i,j,k) /= missvalue )
THEN 2555 ELSE IF ( reduced_k_range )
THEN 2556 if( numthreads>1 .AND. phys_window )
then 2563 IF ( field(i-is+1+hi,j-js+1+hj,k) /= missvalue )
THEN 2564 IF ( pow_value /= 1 )
THEN 2567 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2571 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2574 output_fields(out_num)%buffer(i-hi,j-hj,k1,sample) = missvalue
2587 IF ( field(i-is+1+hi,j-js+1+hj,k) /= missvalue )
THEN 2588 IF ( pow_value /= 1 )
THEN 2591 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2595 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2598 output_fields(out_num)%buffer(i-hi,j-hj,k1,sample) = missvalue
2606 outer3:
DO k = ksr, ker
2610 IF ( field(i,j,k) /= missvalue )
THEN 2620 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
2622 IF ( err_msg_local /=
'' )
THEN 2623 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 2624 DEALLOCATE(oor_mask)
2629 IF( numthreads > 1 .AND. phys_window )
then 2633 IF ( field(i-is+1+hi,j-js+1+hj,k) /= missvalue )
THEN 2634 IF ( pow_value /= 1 )
THEN 2637 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2641 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2644 output_fields(out_num)%buffer(i-hi,j-hj,k,sample) = missvalue
2654 IF ( field(i-is+1+hi,j-js+1+hj,k) /= missvalue )
THEN 2655 IF ( pow_value /= 1 )
THEN 2658 & (field(i-is+1+hi,j-js+1+hj,k) * weight1)**(pow_value)
2662 & field(i-is+1+hi,j-js+1+hj,k) * weight1
2665 output_fields(out_num)%buffer(i-hi,j-hj,k,sample) = missvalue
2676 IF ( field(i,j,k) /= missvalue )
THEN 2686 IF ( need_compute )
THEN 2687 IF( numthreads > 1 .AND. phys_window )
then 2690 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2691 i1 = i-l_start(1)-hi+1
2692 j1= j-l_start(2)-hj+1
2693 IF ( pow_value /= 1 )
THEN 2695 & (field(i-is+1+hi,j-js+1+hj,l_start(3):l_end(3))*weight1)**(pow_value)
2698 & field(i-is+1+hi,j-js+1+hj,l_start(3):l_end(3))*weight1
2707 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2708 i1 = i-l_start(1)-hi+1
2709 j1= j-l_start(2)-hj+1
2710 IF ( pow_value /= 1 )
THEN 2712 & (field(i-is+1+hi,j-js+1+hj,l_start(3):l_end(3))*weight1)**(pow_value)
2715 & field(i-is+1+hi,j-js+1+hj,l_start(3):l_end(3))*weight1
2726 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2728 &
output_fields(out_num)%num_elements(sample)+l_end(3)-l_start(3)+1
2734 ELSE IF ( reduced_k_range )
THEN 2737 IF( numthreads > 1 .AND. phys_window )
then 2738 IF ( pow_value /= 1 )
THEN 2739 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) =&
2740 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) + &
2741 & (field(f1:f2,f3:f4,ksr:ker)*weight1)**(pow_value)
2743 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) =&
2744 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) + &
2745 & field(f1:f2,f3:f4,ksr:ker)*weight1
2749 IF ( pow_value /= 1 )
THEN 2750 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) =&
2751 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) + &
2752 & (field(f1:f2,f3:f4,ksr:ker)*weight1)**(pow_value)
2754 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) =&
2755 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) + &
2756 & field(f1:f2,f3:f4,ksr:ker)*weight1
2762 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
2764 IF ( err_msg_local /=
'' )
THEN 2765 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 2766 DEALLOCATE(oor_mask)
2771 IF( numthreads > 1 .AND. phys_window )
then 2772 IF ( pow_value /= 1 )
THEN 2773 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) =&
2774 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) +&
2775 & (field(f1:f2,f3:f4,ks:ke)*weight1)**(pow_value)
2777 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) =&
2778 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) +&
2779 & field(f1:f2,f3:f4,ks:ke)*weight1
2783 IF ( pow_value /= 1 )
THEN 2784 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) =&
2785 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) +&
2786 & (field(f1:f2,f3:f4,ks:ke)*weight1)**(pow_value)
2788 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) =&
2789 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) +&
2790 & field(f1:f2,f3:f4,ks:ke)*weight1
2796 IF ( .NOT.phys_window )
output_fields(out_num)%count_0d(sample) =&
2803 IF ( .NOT.need_compute .AND. .NOT.reduced_k_range )&
2805 &
output_fields(out_num)%num_elements(sample) + (ie-is+1)*(je-js+1)*(ke-ks+1)
2806 IF ( reduced_k_range ) &
2808 & (ie-is+1)*(je-js+1)*(ker-ksr+1)
2811 ELSE IF ( time_max )
THEN 2812 IF (
PRESENT(mask) )
THEN 2813 IF ( need_compute )
THEN 2814 DO k = l_start(3), l_end(3)
2815 k1 = k - l_start(3) + 1
2818 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2819 i1 = i-l_start(1)-hi+1
2820 j1= j-l_start(2)-hj+1
2821 IF ( mask(i-is+1+hi,j-js+1+hj,k) .AND.&
2822 & field(i-is+1+hi,j-js+1+hj,k)>
output_fields(out_num)%buffer(i1,j1,k1,sample))
THEN 2823 output_fields(out_num)%buffer(i1,j1,k1,sample) = field(i-is+1+hi,j-js+1+hj,k)
2830 ELSE IF ( reduced_k_range )
THEN 2833 WHERE ( mask(f1:f2,f3:f4,ksr:ker) .AND. &
2834 & field(f1:f2,f3:f4,ksr:ker) >
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample))&
2835 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) = field(f1:f2,f3:f4,ksr:ker)
2838 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
2840 IF ( err_msg_local /=
'' )
THEN 2841 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 2842 DEALLOCATE(oor_mask)
2847 WHERE ( mask(f1:f2,f3:f4,ks:ke) .AND.&
2848 & field(f1:f2,f3:f4,ks:ke)>
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample))&
2849 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) = field(f1:f2,f3:f4,ks:ke)
2852 IF ( need_compute )
THEN 2853 DO k = l_start(3), l_end(3)
2854 k1 = k - l_start(3) + 1
2857 IF(l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2858 i1 = i-l_start(1)-hi+1
2859 j1 = j-l_start(2)-hj+1
2860 IF ( field(i-is+1+hi,j-js+1+hj,k) >
output_fields(out_num)%buffer(i1,j1,k1,sample) )
THEN 2861 output_fields(out_num)%buffer(i1,j1,k1,sample) = field(i-is+1+hi,j-js+1+hj,k)
2868 ELSE IF ( reduced_k_range )
THEN 2871 WHERE ( field(f1:f2,f3:f4,ksr:ker) >
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) ) &
2872 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) = field(f1:f2,f3:f4,ksr:ker)
2875 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
2877 IF ( err_msg_local /=
'' )
THEN 2878 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 2879 DEALLOCATE(oor_mask)
2884 WHERE ( field(f1:f2,f3:f4,ks:ke) >
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) ) &
2885 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) = field(f1:f2,f3:f4,ks:ke)
2889 ELSE IF ( time_min )
THEN 2890 IF (
PRESENT(mask) )
THEN 2891 IF ( need_compute )
THEN 2892 DO k = l_start(3), l_end(3)
2893 k1 = k - l_start(3) + 1
2896 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2897 i1 = i-l_start(1)-hi+1
2898 j1 = j-l_start(2)-hj+1
2899 IF ( mask(i-is+1+hi,j-js+1+hj,k) .AND.&
2900 & field(i-is+1+hi,j-js+1+hj,k) <
output_fields(out_num)%buffer(i1,j1,k1,sample) )
THEN 2901 output_fields(out_num)%buffer(i1,j1,k1,sample) = field(i-is+1+hi,j-js+1+hj,k)
2908 ELSE IF ( reduced_k_range )
THEN 2911 WHERE ( mask(f1:f2,f3:f4,ksr:ker) .AND.&
2912 & field(f1:f2,f3:f4,ksr:ker) <
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample)) &
2913 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) = field(f1:f2,f3:f4,ksr:ker)
2916 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
2918 IF ( err_msg_local /=
'' )
THEN 2919 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 2920 DEALLOCATE(oor_mask)
2925 WHERE ( mask(f1:f2,f3:f4,ks:ke) .AND.&
2926 & field(f1:f2,f3:f4,ks:ke) <
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) ) &
2927 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) = field(f1:f2,f3:f4,ks:ke)
2930 IF ( need_compute )
THEN 2931 DO k = l_start(3), l_end(3)
2932 k1 = k - l_start(3) + 1
2935 IF ( l_start(1)+hi <=i.AND.i<=l_end(1)+hi.AND.l_start(2)+hj<=j.AND.j<=l_end(2)+hj)
THEN 2936 i1 = i-l_start(1)-hi+1
2937 j1= j-l_start(2)-hj+1
2938 IF ( field(i-is+1+hi,j-js+1+hj,k) <
output_fields(out_num)%buffer(i1,j1,k1,sample) )
THEN 2939 output_fields(out_num)%buffer(i1,j1,k1,sample) = field(i-is+1+hi,j-js+1+hj,k)
2946 ELSE IF ( reduced_k_range )
THEN 2949 WHERE ( field(f1:f2,f3:f4,ksr:ker) <
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) ) &
2950 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) = field(f1:f2,f3:f4,ksr:ker)
2953 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
2955 IF ( err_msg_local /=
'' )
THEN 2956 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 2957 DEALLOCATE(oor_mask)
2962 WHERE ( field(f1:f2,f3:f4,ks:ke) <
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) )&
2963 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) = field(f1:f2,f3:f4,ks:ke)
2967 ELSE IF ( time_sum )
THEN 2968 IF (
PRESENT(mask) )
THEN 2969 IF ( need_compute )
THEN 2970 DO k = l_start(3), l_end(3)
2971 k1 = k - l_start(3) + 1
2974 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 2975 i1 = i-l_start(1)-hi+1
2976 j1 = j-l_start(2)-hj+1
2977 IF ( mask(i-is+1+hi,j-js+1+hj,k) )
THEN 2980 field(i-is+1+hi,j-js+1+hj,k)
2987 ELSE IF ( reduced_k_range )
THEN 2990 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) = &
2991 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) + &
2992 & field(f1:f2,f3:f4,ksr:ker)
2995 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
2997 IF ( err_msg_local /=
'' )
THEN 2998 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 2999 DEALLOCATE(oor_mask)
3004 WHERE ( mask(f1:f2,f3:f4,ks:ke) ) &
3005 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) = &
3006 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) + &
3007 & field(f1:f2,f3:f4,ks:ke)
3010 IF ( need_compute )
THEN 3011 DO k = l_start(3), l_end(3)
3012 k1 = k - l_start(3) + 1
3015 IF ( l_start(1)+hi <=i.AND.i<=l_end(1)+hi.AND.l_start(2)+hj<=j.AND.j<=l_end(2)+hj)
THEN 3016 i1 = i-l_start(1)-hi+1
3017 j1= j-l_start(2)-hj+1
3020 & field(i-is+1+hi,j-js+1+hj,k)
3025 ELSE IF ( reduced_k_range )
THEN 3028 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) = &
3029 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) + &
3030 & field(f1:f2,f3:f4,ksr:ker)
3033 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
3035 IF ( err_msg_local /=
'' )
THEN 3036 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 3037 DEALLOCATE(oor_mask)
3042 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) = &
3043 &
output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) + &
3044 & field(f1:f2,f3:f4,ks:ke)
3050 IF ( need_compute )
THEN 3053 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 3054 i1 = i-l_start(1)-hi+1
3055 j1 = j-l_start(2)-hj+1
3056 output_fields(out_num)%buffer(i1,j1,:,sample) = field(i-is+1+hi,j-js+1+hj,l_start(3):l_end(3))
3061 ELSE IF ( reduced_k_range )
THEN 3064 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,:,sample) = field(f1:f2,f3:f4,ksr:ker)
3067 CALL update_bounds(out_num, is-hi, ie-hi, js-hj, je-hj, ks, ke)
3069 IF ( err_msg_local /=
'' )
THEN 3070 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg) )
THEN 3071 DEALLOCATE(oor_mask)
3076 output_fields(out_num)%buffer(is-hi:ie-hi,js-hj:je-hj,ks:ke,sample) = field(f1:f2,f3:f4,ks:ke)
3079 IF (
PRESENT(mask) .AND. missvalue_present )
THEN 3080 IF ( need_compute )
THEN 3081 DO k = l_start(3), l_end(3)
3082 k1 = k - l_start(3) + 1
3085 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 3086 i1 = i-l_start(1)-hi+1
3087 j1 = j-l_start(2)-hj+1
3088 IF ( .NOT.mask(i-is+1+hi,j-js+1+hj,k) )&
3089 &
output_fields(out_num)%buffer(i1,j1,k1,sample) = missvalue
3094 ELSE IF ( reduced_k_range )
THEN 3101 IF ( .NOT.mask(i-is+1+hi,j-js+1+hj,k) ) &
3102 &
output_fields(out_num)%buffer(i-hi,j-hj,k1,sample)= missvalue
3110 IF ( .NOT.mask(i-is+1+hi,j-js+1+hj,k) )&
3111 &
output_fields(out_num)%buffer(i-hi,j-hj,k,sample)= missvalue
3121 IF ( err_msg_local /=
'' )
THEN 3122 IF (
fms_error_handler(
'diag_manager_mod::send_data_3d', err_msg_local, err_msg))
THEN 3123 DEALLOCATE(oor_mask)
3130 IF (
PRESENT(rmask) .AND. missvalue_present )
THEN 3131 IF ( need_compute )
THEN 3132 DO k = l_start(3), l_end(3)
3133 k1 = k - l_start(3) + 1
3136 IF ( l_start(1)+hi <= i .AND. i <= l_end(1)+hi .AND. l_start(2)+hj <= j .AND. j <= l_end(2)+hj )
THEN 3137 i1 = i-l_start(1)-hi+1
3138 j1 = j-l_start(2)-hj+1
3139 IF ( rmask(i-is+1+hi,j-js+1+hj,k) < 0.5 ) &
3140 &
output_fields(out_num)%buffer(i1,j1,k1,sample) = missvalue
3145 ELSE IF ( reduced_k_range )
THEN 3152 IF ( rmask(i-is+1+hi,j-js+1+hj,k) < 0.5 ) &
3153 &
output_fields(out_num)%buffer(i-hi,j-hj,k1,sample)= missvalue
3161 IF ( rmask(i-is+1+hi,j-js+1+hj,k) < 0.5 ) &
3162 &
output_fields(out_num)%buffer(i-hi,j-hj,k,sample)= missvalue
3169 END DO num_out_fields
3171 DEALLOCATE(oor_mask)
3182 INTEGER,
INTENT(in) :: id
3183 REAL,
INTENT(in) :: field(:,:)
3184 REAL,
INTENT(in) :: area (:,:)
3186 LOGICAL,
INTENT(in),
OPTIONAL :: mask (:,:)
3188 REAL,
DIMENSION(SIZE(field,1)) :: out(
size(field,1))
3214 INTEGER,
INTENT(in) :: diag_field_id
3215 REAL,
DIMENSION(:,:),
INTENT(in) :: x
3216 REAL,
DIMENSION(:,:),
INTENT(in) :: area
3217 LOGICAL,
DIMENSION(:,:),
INTENT(in) :: mask
3218 REAL,
DIMENSION(:),
INTENT(out) :: out
3221 REAL,
DIMENSION(SIZE(x,1)) :: s
3222 REAL :: local_missing_value
3226 IF ( diag_field_id <= 0 )
THEN 3230 CALL error_mesg(
'diag_manager_mod::average_tiles1d',&
3231 &
"diag_field_id less than 0. Contact developers.", fatal)
3235 IF (
input_fields(diag_field_id)%missing_value_present )
THEN 3236 local_missing_value =
input_fields(diag_field_id)%missing_value
3238 local_missing_value = 0.0
3245 DO it = 1,
SIZE(area,dim=2)
3246 WHERE ( mask(:,it) )
3247 out(:) = out(:) + x(:,it)*area(:,it)
3248 s(:) = s(:) + area(:,it)
3253 out(:) = out(:)/s(:)
3255 out(:) = local_missing_value
3267 INTEGER,
INTENT(in) :: id
3268 REAL,
INTENT(in) :: field(:,:,:)
3269 REAL,
INTENT(in) :: area (:,:,:)
3271 LOGICAL,
INTENT(in),
OPTIONAL :: mask (:,:,:)
3273 REAL,
DIMENSION(SIZE(field,1),SIZE(field,2)) :: out(
size(field,1),
size(field,2))
3293 INTEGER,
INTENT(in) :: id
3294 REAL,
DIMENSION(:,:,:,:),
INTENT(in) :: field
3295 REAL,
DIMENSION(:,:,:),
INTENT(in) :: area (:,:,:)
3297 LOGICAL,
DIMENSION(:,:,:),
INTENT(in),
OPTIONAL :: mask
3299 REAL,
DIMENSION(SIZE(field,1),SIZE(field,2),SIZE(field,4)) :: out
3300 LOGICAL,
DIMENSION(SIZE(field,1),SIZE(field,2),SIZE(field,4)) :: mask3
3309 DO it=1,
SIZE(field,4)
3310 CALL average_tiles(id, field(:,:,:,it), area, mask, out(:,:,it) )
3313 mask3(:,:,1) = any(mask,dim=3)
3314 DO it = 2,
SIZE(field,4)
3315 mask3(:,:,it) = mask3(:,:,1)
3336 INTEGER,
INTENT(in) :: diag_field_id
3337 REAL,
DIMENSION(:,:,:),
INTENT(in) :: x
3338 REAL,
DIMENSION(:,:,:),
INTENT(in) :: area
3339 LOGICAL,
DIMENSION(:,:,:),
INTENT(in) :: mask
3340 REAL,
DIMENSION(:,:),
INTENT(out) :: out
3343 REAL,
DIMENSION(SIZE(x,1),SIZE(x,2)) :: s
3344 REAL :: local_missing_value
3348 IF ( diag_field_id <= 0 )
THEN 3352 CALL error_mesg(
'diag_manager_mod::average_tiles',&
3353 &
"diag_field_id less than 0. Contact developers.", fatal)
3357 IF (
input_fields(diag_field_id)%missing_value_present )
THEN 3358 local_missing_value =
input_fields(diag_field_id)%missing_value
3360 local_missing_value = 0.0
3367 DO it = 1,
SIZE(area,3)
3368 WHERE ( mask(:,:,it) )
3369 out(:,:) = out(:,:) + x(:,:,it)*area(:,:,it)
3370 s(:,:) = s(:,:) + area(:,:,it)
3374 WHERE ( s(:,:) > 0 )
3375 out(:,:) = out(:,:)/s(:,:)
3377 out(:,:) = local_missing_value
3382 INTEGER FUNCTION writing_field(out_num, at_diag_end, error_string, time)
3383 INTEGER,
INTENT(in) :: out_num
3384 LOGICAL,
INTENT(in) :: at_diag_end
3385 CHARACTER(len=*),
INTENT(out) :: error_string
3389 LOGICAL :: time_max, time_min, reduced_k_range, missvalue_present
3390 LOGICAL :: average, time_rms, need_compute, phys_window
3391 INTEGER :: in_num, file_num, freq, units
3392 INTEGER :: b1,b2,b3,b4
3393 INTEGER :: i, j, k, m
3394 REAL :: missvalue, num
3404 missvalue_present =
input_fields(in_num)%missing_value_present
3416 freq =
files(file_num)%output_freq
3417 units =
files(file_num)%output_units
3444 IF ( phys_window )
THEN 3445 IF ( need_compute .OR. reduced_k_range )
THEN 3453 IF ( num > 0. )
THEN 3454 IF ( missvalue_present )
THEN 3458 IF (
output_fields(out_num)%buffer(i,j,k,m) /= missvalue )
THEN 3471 ELSE IF ( .NOT. at_diag_end )
THEN 3472 IF ( missvalue_present )
THEN 3474 WRITE (error_string,
'(a,"/",a)')&
3484 ELSE IF ( time_min .OR. time_max )
THEN 3485 IF ( missvalue_present )
THEN 3502 IF ( at_diag_end )
RETURN 3518 IF ( time_max )
THEN 3520 ELSE IF ( time_min )
THEN 3549 integer :: file, j, freq, in_num, file_num, out_num
3552 freq =
files(file)%output_freq
3554 DO j = 1,
files(file)%num_fields
3555 out_num =
files(file)%fields(j)
3570 character(len=*),
INTENT(out),
optional :: err_msg
3573 integer :: file, j, out_num, in_num, freq, status
3574 logical :: local_output, need_compute
3575 CHARACTER(len=128) :: error_string
3581 CALL error_mesg(
'diag_manager_mod::diag_send_complete',&
3582 &
"diag_manager_set_time_end must be called before diag_send_complete", fatal)
3586 freq =
files(file)%output_freq
3587 DO j = 1,
files(file)%num_fields
3588 out_num =
files(file)%fields(j)
3601 IF ( local_output .AND. (.NOT.need_compute) ) cycle
3602 next_time = time + time_step
3606 IF ( next_time >
output_fields(out_num)%next_next_output .AND. freq > 0 )
THEN 3607 IF ( mpp_pe() .EQ. mpp_root_pe() )
THEN 3608 WRITE (error_string,
'(a,"/",a)')&
3612 &
'module/output_field '//trim(error_string)//&
3613 &
' is skipped one time level in output data', err_msg))
RETURN 3617 status =
writing_field(out_num, .false., error_string, next_time)
3618 IF ( status == -1 )
THEN 3619 IF ( mpp_pe() .EQ. mpp_root_pe() )
THEN 3620 IF(
fms_error_handler(
'diag_manager_mod::diag_send_complete',
'module/output_field '//trim(error_string)//&
3621 &
', write EMPTY buffer', err_msg))
RETURN 3669 INTEGER,
INTENT(in) :: file
3670 TYPE(time_type),
INTENT(in) :: time
3672 INTEGER :: j, i, input_num, freq, status
3673 INTEGER :: stdout_unit
3674 LOGICAL :: reduced_k_range, need_compute, local_output
3675 CHARACTER(len=128) :: message
3677 stdout_unit = stdout()
3680 DO j = 1,
files(file)%num_fields
3681 i =
files(file)%fields(j)
3691 IF ( local_output .AND. (.NOT. need_compute) ) cycle
3696 freq =
files(file)%output_freq
3703 IF ( time >=
output_fields(i)%next_next_output .AND. freq > 0 )
THEN 3704 WRITE (message,
'(a,"/",a)') trim(
input_fields(input_num)%module_name), &
3710 IF ( mpp_pe() .EQ. mpp_root_pe() ) &
3711 &
CALL error_mesg(
'diag_manager_mod::closing_file',
'module/output_field ' //&
3712 & trim(message)//
', skip one time level, maybe send_data never called', warning)
3721 CALL error_mesg(
'Potential error in diag_manager_end ',&
3723 &
' check if output interval > runlength. Netcdf fill_values are written', note)
3739 IF ( mpp_pe() == mpp_root_pe() )&
3740 &
WRITE (stdout_unit,
'(a,i12,a,a)')
'Diag_Manager: ',
files(file)%bytes_written, &
3741 &
' bytes of data written to file ',trim(
files(file)%name)
3760 INTEGER,
OPTIONAL,
INTENT(IN) :: diag_model_subset
3761 INTEGER,
DIMENSION(6),
OPTIONAL,
INTENT(IN) :: time_init
3762 CHARACTER(len=*),
INTENT(out),
OPTIONAL :: err_msg
3764 CHARACTER(len=*),
PARAMETER :: sep =
'|' 3766 INTEGER,
PARAMETER :: fltkind = float_kind
3767 INTEGER,
PARAMETER :: dblkind = double_kind
3768 INTEGER :: diag_subset_output
3770 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: pelist
3771 INTEGER :: stdlog_unit, stdout_unit
3773 #ifndef INTERNAL_FILE_NML 3776 CHARACTER(len=256) :: err_msg_local
3788 IF (
PRESENT(err_msg) ) err_msg =
'' 3796 pack_size =
SIZE(transfer(0.0_dblkind, (/0.0, 0.0, 0.0, 0.0/)))
3798 IF (
fms_error_handler(
'diag_manager_mod::diag_manager_init',
'unknown pack_size. Must be 1, or 2.', err_msg) )
RETURN 3806 stdlog_unit = stdlog()
3807 stdout_unit = stdout()
3810 CALL write_version_number(
"DIAG_MANAGER_MOD", version)
3816 IF (
PRESENT(diag_model_subset) )
THEN 3818 diag_subset_output = diag_model_subset
3820 IF (
fms_error_handler(
'diag_manager_mod::diag_manager_init',
'invalid value of diag_model_subset',err_msg) )
RETURN 3824 #ifdef INTERNAL_FILE_NML 3827 IF ( file_exist(
'input.nml') )
THEN 3828 nml_unit = open_namelist_file()
3829 READ (nml_unit, diag_manager_nml, iostat=mystat)
3830 CALL close_file(nml_unit)
3838 IF (
check_nml_error(iostat=mystat, nml_name=
'DIAG_MANAGER_NML') < 0 )
THEN 3839 IF ( mpp_pe() == mpp_root_pe() )
THEN 3840 CALL error_mesg(
'diag_manager_mod::diag_manager_init',
'DIAG_MANAGER_NML not found in input.nml. Using defaults.',&
3845 IF ( mpp_pe() == mpp_root_pe() )
THEN 3846 WRITE (stdlog_unit, diag_manager_nml)
3853 CALL error_mesg(
'diag_manager_mod::diag_manager_init',
'Using CMOR missing value ('//trim(err_msg_local)//
').', note)
3858 IF (
max_files .GT. mpp_get_maxunits() )
THEN 3860 WRITE (err_msg_local,
'(A,I6,A,I6,A,I6,A)')
"DIAG_MANAGER_NML variable 'max_files' (",
max_files,
") is larger than '",&
3861 & mpp_get_maxunits(),
"'. Forcing 'max_files' to be ",mpp_get_maxunits(),
"." 3862 CALL error_mesg(
'diag_manager_mod::diag_managet_init', trim(err_msg_local), note)
3869 CALL error_mesg(
'diag_manager_mod::diag_manager_init',
'Out & 3870 &of Range warnings are fatal.', note)
3872 CALL error_mesg(
'diag_manager_mod::diag_manager_init',
'Out & 3873 &of Range warnings will be ignored.', note)
3877 IF ( mpp_pe() == mpp_root_pe() )
THEN 3878 CALL error_mesg(
'diag_manager_mod::diag_manager_init',
'Setting diag_manager_nml variable '//&
3879 &
'mix_snapshot_average_fields = .TRUE. will cause ERRORS in the time coordinates '//&
3880 &
'of all time averaged fields. Strongly recommend setting mix_snapshot_average_fields '//&
3881 &
'= .FALSE.', warning)
3890 ALLOCATE(pelist(mpp_npes()))
3894 IF (
PRESENT(time_init) )
THEN 3896 & time_init(5), time_init(6))
3900 CALL error_mesg(
'diag_manager_mod::diag_manager_init',&
3901 &
'prepend_date only supported when diag_manager_init is called with time_init present.', note)
3906 CALL parse_diag_table(diag_subset=diag_subset_output, istat=mystat, err_msg=err_msg_local)
3907 IF ( mystat /= 0 )
THEN 3909 &
'Error parsing diag_table. '//trim(err_msg_local), err_msg) )
RETURN 3913 files(:)%bytes_written = 0
3917 CALL mpp_open(
diag_log_unit,
'diag_field_log.out', nohdrs=.true.)
3919 &
'Module', sep,
'Field', sep,
'Long Name', sep,&
3920 &
'Units', sep,
'Number of Axis', sep,
'Time Axis', sep,&
3921 &
'Missing Value', sep,
'Min Value', sep,
'Max Value', sep,&
3927 null_axis_id = diag_axis_init(
'scalar_axis', (/0./),
'none',
'N',
'none')
3948 &
'module has not been initialized', fatal)
3969 SUBROUTINE get_base_date(year, month, day, hour, minute, second)
3970 INTEGER,
INTENT(out) :: year, month, day, hour, minute, second
3973 IF (.NOT.module_is_initialized)
CALL error_mesg (
'diag_manager_mod::get_base_date', &
3974 &
'module has not been initialized', fatal)
3979 minute = base_minute
3980 second = base_second
4001 LOGICAL FUNCTION need_data(diag_field_id, next_model_time)
4002 TYPE(time_type),
INTENT(in) :: next_model_time
4003 INTEGER,
INTENT(in) :: diag_field_id
4005 INTEGER :: i, out_num
4008 IF ( diag_field_id < 0 )
RETURN 4009 DO i = 1, input_fields(diag_field_id)%num_output_fields
4011 out_num = input_fields(diag_field_id)%output_fields(i)
4012 IF ( .NOT.output_fields(out_num)%static )
THEN 4013 IF ( next_model_time > output_fields(out_num)%next_output )
need_data=.true.
4017 IF ( output_fields(out_num)%time_average)
need_data = .true.
4038 INTEGER,
INTENT(in) :: n_samples
4040 REAL :: data (n_samples)
4041 REAL :: edges (n_samples+1)
4044 INTEGER :: year, month, day, hour, minute, second
4045 CHARACTER(32) :: name
4046 CHARACTER(128) :: units
4049 WRITE (units,11)
'hours', year, month, day, hour, minute, second
4050 11
FORMAT(a,
' since ',i4.4,
'-',i2.2,
'-',i2.2,
' ',i2.2,
':',i2.2,
':',i2.2)
4054 DATA (i) = 24.0*(
REAL(i)-0.5)/n_samples
4055 edges(i+1) = 24.0*
REAL(i)/n_samples
4060 WRITE (name,
'(a,i2.2)')
'time_of_day_edges_', n_samples
4061 edges_id = get_axis_num(name,
'diurnal')
4062 IF ( edges_id <= 0 )
THEN 4063 edges_id = diag_axis_init(name,edges,units,
'N',
'time of day edges', set_name=
'diurnal')
4068 WRITE (name,
'(a,i2.2)')
'time_of_day_', n_samples
4071 init_diurnal_axis = diag_axis_init(name,
DATA, units,
'N',
'time of day', set_name=
'diurnal', edges=edges_id)
4077 INTEGER,
INTENT(in) :: diag_field_id
4078 CHARACTER(len=*),
INTENT(in) :: name
4079 INTEGER,
INTENT(in) ::
type 4080 CHARACTER(len=*),
INTENT(in),
OPTIONAL :: cval
4081 INTEGER,
DIMENSION(:),
INTENT(in),
OPTIONAL :: ival
4082 REAL,
DIMENSION(:),
INTENT(in),
OPTIONAL :: rval
4084 INTEGER :: istat, length, i, j, this_attribute, out_field
4085 CHARACTER(len=1024) :: err_msg
4087 IF ( .NOT.first_send_data_call )
THEN 4093 CALL error_mesg(
'diag_manager_mod::diag_field_add_attribute',
'Attempting to add attribute "'&
4094 &//trim(name)//
'" to module/input_field "'//trim(input_fields(diag_field_id)%module_name)//
'/'&
4095 &//trim(input_fields(diag_field_id)%field_name)//
'" after first send_data call. Too late.', fatal)
4099 IF ( diag_field_id .LE. 0 )
THEN 4102 DO j=1,input_fields(diag_field_id)%num_output_fields
4103 out_field = input_fields(diag_field_id)%output_fields(j)
4106 CALL attribute_init(output_fields(out_field))
4110 DO i=1, output_fields(out_field)%num_attributes
4111 IF ( trim(output_fields(out_field)%attributes(i)%name) .EQ. trim(name) )
THEN 4117 IF ( this_attribute.NE.0 .AND. (type.EQ.nf90_int .OR. type.EQ.nf90_float) )
THEN 4122 CALL error_mesg(
'diag_manager_mod::diag_field_add_attribute',&
4123 &
'Attribute "'//trim(name)//
'" already defined for module/input_field "'&
4124 &//trim(input_fields(diag_field_id)%module_name)//
'/'&
4125 &//trim(input_fields(diag_field_id)%field_name)//
'". Contact the developers.', fatal)
4126 ELSE IF ( this_attribute.NE.0 .AND. type.EQ.nf90_char .AND. debug_diag_manager )
THEN 4131 CALL error_mesg(
'diag_manager_mod::diag_field_add_attribute',&
4132 &
'Attribute "'//trim(name)//
'" already defined for module/input_field "'&
4133 &//trim(input_fields(diag_field_id)%module_name)//
'/'&
4134 &//trim(input_fields(diag_field_id)%field_name)//
'". Prepending.', note)
4135 ELSE IF ( this_attribute.EQ.0 )
THEN 4138 this_attribute = output_fields(out_field)%num_attributes + 1
4140 IF ( this_attribute .GT. max_field_attributes )
THEN 4145 CALL error_mesg(
'diag_manager_mod::diag_field_add_attribute',&
4146 &
'Number of attributes exceeds max_field_attributes for attribute "'&
4147 &//trim(name)//
'" to module/input_field "'//trim(input_fields(diag_field_id)%module_name)//
'/'&
4148 &//trim(input_fields(diag_field_id)%field_name)//
'". Increase diag_manager_nml:max_field_attributes.',&
4151 output_fields(out_field)%num_attributes = this_attribute
4153 output_fields(out_field)%attributes(this_attribute)%name = name
4154 output_fields(out_field)%attributes(this_attribute)%type =
type 4156 output_fields(out_field)%attributes(this_attribute)%catt =
'' 4162 IF ( .NOT.
PRESENT(ival) )
THEN 4167 CALL error_mesg(
'diag_manager_mod::diag_field_add_attribute',&
4168 &
'Attribute type claims INTEGER, but ival not present for attribute "'&
4169 &//trim(name)//
'" to module/input_field "'//trim(input_fields(diag_field_id)%module_name)//
'/'&
4170 &//trim(input_fields(diag_field_id)%field_name)//
'". Contact then developers.', fatal)
4174 ALLOCATE(output_fields(out_field)%attributes(this_attribute)%iatt(length), stat=istat)
4175 IF ( istat.NE.0 )
THEN 4179 CALL error_mesg(
'diag_manager_mod::diag_field_add_attribute',
'Unable to allocate iatt for attribute "'&
4180 &//trim(name)//
'" to module/input_field "'//trim(input_fields(diag_field_id)%module_name)//
'/'&
4181 &//trim(input_fields(diag_field_id)%field_name)//
'"', fatal)
4184 output_fields(out_field)%attributes(this_attribute)%len = length
4185 output_fields(out_field)%attributes(this_attribute)%iatt = ival
4187 IF ( .NOT.
PRESENT(rval) )
THEN 4192 CALL error_mesg(
'diag_manager_mod::diag_field_add_attribute',&
4193 &
'Attribute type claims REAL, but rval not present for attribute "'&
4194 &//trim(name)//
'" to module/input_field "'//trim(input_fields(diag_field_id)%module_name)//
'/'&
4195 &//trim(input_fields(diag_field_id)%field_name)//
'". Contact the developers.', fatal)
4199 ALLOCATE(output_fields(out_field)%attributes(this_attribute)%fatt(length), stat=istat)
4200 IF ( istat.NE.0 )
THEN 4204 CALL error_mesg(
'diag_manager_mod::diag_field_add_attribute',
'Unable to allocate fatt for attribute "'&
4205 &//trim(name)//
'" to module/input_field "'//trim(input_fields(diag_field_id)%module_name)//
'/'&
4206 &//trim(input_fields(diag_field_id)%field_name)//
'"', fatal)
4209 output_fields(out_field)%attributes(this_attribute)%len = length
4210 output_fields(out_field)%attributes(this_attribute)%fatt = rval
4212 IF ( .NOT.
PRESENT(cval) )
THEN 4217 CALL error_mesg(
'diag_manager_mod::diag_field_add_attribute',&
4218 &
'Attribute type claims CHARACTER, but cval not present for attribute "'&
4219 &//trim(name)//
'" to module/input_field "'//trim(input_fields(diag_field_id)%module_name)//
'/'&
4220 &//trim(input_fields(diag_field_id)%field_name)//
'". Contact the developers.', fatal)
4222 CALL prepend_attribute(output_fields(out_field), trim(name), trim(cval))
4228 CALL error_mesg(
'diag_manager_mod::diag_field_add_attribute',
'Unknown attribute type for attribute "'&
4229 &//trim(name)//
'" to module/input_field "'//trim(input_fields(diag_field_id)%module_name)//
'/'&
4230 &//trim(input_fields(diag_field_id)%field_name)//
'". Contact the developers.', fatal)
4241 INTEGER,
INTENT(in) :: diag_field_id
4242 CHARACTER(len=*),
INTENT(in) :: att_name
4243 REAL,
INTENT(in) :: att_value
4254 INTEGER,
INTENT(in) :: diag_field_id
4255 CHARACTER(len=*),
INTENT(in) :: att_name
4256 INTEGER,
INTENT(in) :: att_value
4267 INTEGER,
INTENT(in) :: diag_field_id
4268 CHARACTER(len=*),
INTENT(in) :: att_name
4269 CHARACTER(len=*),
INTENT(in) :: att_value
4280 INTEGER,
INTENT(in) :: diag_field_id
4281 CHARACTER(len=*),
INTENT(in) :: att_name
4282 REAL,
DIMENSION(:),
INTENT(in) :: att_value
4284 INTEGER :: num_attributes, len
4285 CHARACTER(len=512) :: err_msg
4296 INTEGER,
INTENT(in) :: diag_field_id
4297 CHARACTER(len=*),
INTENT(in) :: att_name
4298 INTEGER,
DIMENSION(:),
INTENT(in) :: att_value
4320 INTEGER,
INTENT(in) :: diag_field_id
4321 INTEGER,
INTENT(in),
OPTIONAL :: area, volume
4325 IF ( diag_field_id.GT.0 )
THEN 4326 IF ( .NOT.
PRESENT(area) .AND. .NOT.
present(volume) )
THEN 4327 CALL error_mesg(
'diag_manager_mod::diag_field_add_cell_measures', &
4328 &
'either area or volume arguments must be present', fatal )
4331 DO j=1, input_fields(diag_field_id)%num_output_fields
4332 ind = input_fields(diag_field_id)%output_fields(j)
4379 #ifdef test_diag_manager 4580 USE mpp_mod,
ONLY: mpp_pe, mpp_root_pe, mpp_debug, mpp_set_stack_size
4584 USE mpp_domains_mod,
ONLY: mpp_domains_init, mpp_domains_set_stack_size
4587 #ifdef INTERNAL_FILE_NML 4590 USE fms_mod,
ONLY: open_namelist_file, close_file
4612 REAL,
ALLOCATABLE,
DIMENSION(:) :: lon_global1, lonb_global1
4613 REAL,
ALLOCATABLE,
DIMENSION(:) :: lat_global1, latb_global1
4614 REAL,
ALLOCATABLE,
DIMENSION(:) :: lon_global2, lonb_global2
4615 REAL,
ALLOCATABLE,
DIMENSION(:) :: lat_global2, latb_global2
4616 REAL,
ALLOCATABLE,
DIMENSION(:) :: pfull, bk, phalf
4617 REAL,
ALLOCATABLE,
DIMENSION(:) :: lon1, lat1, lonb1, latb1
4618 REAL,
ALLOCATABLE,
DIMENSION(:) :: lon2, lat2, lonb2, latb2
4619 REAL,
ALLOCATABLE,
DIMENSION(:,:,:) :: dat1, dat1h
4620 REAL,
ALLOCATABLE,
DIMENSION(:,:,:) :: dat2, dat2h
4621 REAL,
ALLOCATABLE,
DIMENSION(:,:) :: dat2_2d
4622 REAL :: solar_constant = 1600
4623 REAL :: surf_press = 1.e5
4625 INTEGER :: id_phalf, id_pfull, id_bk
4626 INTEGER :: id_lon1, id_lonb1, id_latb1, id_lat1, id_dat1
4627 INTEGER :: id_lon2, id_lat2, id_dat2, id_dat2_2d, id_sol_con, id_dat2h, id_dat2h_2
4628 INTEGER :: id_dat2_got, id_none_got
4629 INTEGER :: i, j, k, is1, ie1, js1, je1, nml_unit, ierr, log_unit, out_unit, m
4630 INTEGER :: is_in, ie_in, js_in, je_in
4631 INTEGER :: is2, ie2, js2, je2, hi=1, hj=1
4632 INTEGER :: nlon1, nlat1, nlon2, nlat2
4633 INTEGER,
DIMENSION(2) :: layout = (/0,0/)
4634 INTEGER :: test_number=1
4635 INTEGER :: nlon=18, nlat=18, nlev=2
4636 INTEGER :: io_layout(2) = (/0,0/)
4637 INTEGER :: nstep = 2
4638 TYPE(
time_type) :: time, time_step, time_end, time_start, run_length
4639 LOGICAL :: used, test_successful
4640 CHARACTER(len=256) :: err_msg
4641 INTEGER :: omp_get_num_threads
4643 INTEGER :: nyc1, n, jsw, jew, isw, iew
4644 INTEGER :: numthreads=1, ny_per_thread, idthread
4645 INTEGER :: months=0, days=0, dt_step=0
4648 INTEGER :: id_nv, id_nv_init
4651 integer(INT_KIND) :: nx = 8
4652 integer(INT_KIND) :: ny = 8
4653 integer(INT_KIND) :: nz = 2
4654 integer(INT_KIND) :: nt = 2
4655 integer(INT_KIND) :: io_tile_factor = 1
4656 integer(INT_KIND) :: halo = 2
4657 integer(INT_KIND) :: ntiles_x = 1
4658 integer(INT_KIND) :: ntiles_y = 2
4659 integer(INT_KIND) :: total_num_tiles
4660 integer(INT_KIND) :: stackmax = 1500000
4661 integer(INT_KIND) :: stackmaxd = 500000
4662 logical(INT_KIND) :: debug = .false.
4663 character(len=64) :: test_file =
"test_unstructured_grid" 4664 character(len=64) :: iospec =
'-F cachea' 4665 integer(INT_KIND) :: pack_size = 1
4666 integer(INT_KIND) :: npes
4667 integer(INT_KIND) :: io_status
4668 real(DOUBLE_KIND) :: doubledata = 0.0
4669 real :: realdata = 0.0
4670 integer(INT_KIND) :: funit = 7
4671 logical(INT_KIND) :: fopened
4674 integer(INT_KIND) :: output_unit=6
4679 namelist /test_diag_manager_nml/ layout, test_number, nlon, nlat, nlev, io_layout, numthreads, &
4680 dt_step, months, days
4681 namelist /utest_nml/nx,ny,nz,nt,ntiles_x,ntiles_y,io_tile_factor
4707 CALL set_calendar_type(julian)
4709 #ifdef INTERNAL_FILE_NML 4713 IF ( file_exist(
'input.nml') )
THEN 4714 nml_unit = open_namelist_file()
4715 READ(nml_unit, nml=test_diag_manager_nml, iostat=ierr)
4716 READ(nml_unit, nml=utest_nml, iostat=i)
4717 CALL close_file(nml_unit)
4724 IF ( check_nml_error(iostat=ierr, nml_name=
'DIAG_MANAGER_NML') < 0 )
THEN 4725 IF ( mpp_pe() == mpp_root_pe() )
THEN 4726 CALL error_mesg(
'diag_manager_mod::diag_manager_init',
'TEST_DIAG_MANAGER_NML not found in input.nml. Using defaults.',&
4730 WRITE (log_unit,test_diag_manager_nml)
4733 if (test_number == 100)
then 4736 call mpp_domains_init(mpp_debug)
4738 call mpp_domains_init()
4743 call mpp_io_init(mpp_debug)
4752 call mpp_set_stack_size(stackmax)
4753 call mpp_domains_set_stack_size(stackmaxd)
4756 if (mpp_pe() .eq. mpp_root_pe())
then 4757 write(output_unit,*)
4758 write(output_unit,*)
"Performing unstructured_io unit test with:" 4759 write(output_unit,*)
"Total number of ranks: ", &
4761 write(output_unit,*)
"Total number of grid points in the x-dimension: ", &
4763 write(output_unit,*)
"Total number of grid points in the y-dimension: ", &
4765 write(output_unit,*)
"Total number of grid points in the z-dimension: ", &
4767 write(output_unit,*)
"Total number of grid points in the t-dimension: ", &
4769 write(output_unit,*)
"Halo width (# of grid points): ", &
4771 write(output_unit,*)
"Using Unstructured domaintypes and calls..." 4775 write(test_file,
'(a,i3.3)') trim(test_file),npes
4778 call diag_manager_init()
4781 call set_calendar_type(julian)
4783 CALL unstruct_test (nx, ny, nz, npes, ntiles_x, 2, time,io_tile_factor)
4786 IF ( test_number == 12 )
THEN 4787 CALL diag_manager_init(err_msg=err_msg)
4788 IF ( err_msg /=
'' )
THEN 4789 WRITE (out_unit,
'(a)')
'test12 successful: err_msg='//trim(err_msg)
4790 CALL error_mesg(
'test_diag_manager',
'test12 successful.',fatal)
4792 WRITE (out_unit,
'(a)')
'test12 fails' 4793 CALL error_mesg(
'test_diag_manager',
'test12 fails',fatal)
4796 CALL diag_manager_init
4799 IF ( layout(1)*layout(2) .NE. mpp_npes() )
THEN 4808 CALL mpp_define_domains((/1,nlon1,1,nlat1/), layout, domain1, name=
'test_diag_manager')
4810 ALLOCATE(lon_global1(nlon1), lonb_global1(nlon1+1))
4811 ALLOCATE(lat_global1(nlat1), latb_global1(nlat1+1))
4812 ALLOCATE(lon_global2(nlon2), lonb_global2(nlon2+1))
4813 ALLOCATE(lat_global2(nlat2), latb_global2(nlat2+1))
4814 ALLOCATE(pfull(nlev), bk(nlev), phalf(nlev+1))
4816 ALLOCATE(lon1(is1:ie1), lat1(js1:je1), lonb1(is1:ie1+1), latb1(js1:je1+1))
4817 CALL compute_grid(nlon1, nlat1, is1, ie1, js1, je1, lon_global1, lat_global1, lonb_global1, latb_global1, lon1, lat1, lonb1, latb1)
4818 CALL mpp_define_domains((/1,nlon2,1,nlat2/), layout, domain2, name=
'test_diag_manager')
4820 CALL mpp_define_io_domain(domain1, io_layout)
4821 CALL mpp_define_io_domain(domain2, io_layout)
4823 ALLOCATE(lon2(is2:ie2), lat2(js2:je2), lonb2(is2:ie2+1), latb2(js2:je2+1))
4824 CALL compute_grid(nlon2, nlat2, is2, ie2, js2, je2, lon_global2, lat_global2, lonb_global2, latb_global2, lon2, lat2, lonb2, latb2)
4825 dp = surf_press/nlev
4830 pfull(k) = .5*(phalf(k) + phalf(k+1))
4831 bk(k) = pfull(k)/surf_press
4834 ALLOCATE(dat1(is1:ie1,js1:je1,nlev))
4835 ALLOCATE(dat1h(is1-hi:ie1+hi,js1-hj:je1+hj,nlev))
4839 dat1(i,j,1) = sin(lon1(i))*cos(lat1(j))
4842 dat1h(is1:ie1,js1:je1,1) = dat1(:,:,1)
4843 dat1(:,:,2) = -dat1(:,:,1)
4844 dat1h(:,:,2) = -dat1h(:,:,1)
4846 ALLOCATE(dat2(is2:ie2,js2:je2,nlev))
4847 ALLOCATE(dat2_2d(is2:ie2,js2:je2))
4848 ALLOCATE(dat2h(is2-hi:ie2+hi,js2-hj:je2+hj,nlev))
4853 dat2(i,j,1) = sin(lon2(i))*cos(lat2(j))
4856 dat2h(is2:ie2,js2:je2,1) = dat2(:,:,1)
4857 dat2(:,:,2) = -dat2(:,:,1)
4858 dat2h(:,:,2) = -dat2h(:,:,1)
4859 dat2_2d = dat2(:,:,1)
4861 id_lonb1 = diag_axis_init(
'lonb1',
rad_to_deg*lonb_global1,
'degrees_E',
'x', long_name=
'longitude edges', domain2=domain1)
4862 id_latb1 = diag_axis_init(
'latb1',
rad_to_deg*latb_global1,
'degrees_N',
'y', long_name=
'latitude edges', domain2=domain1)
4864 id_lon1 = diag_axis_init(
'lon1',
rad_to_deg*lon_global1,
'degrees_E',
'x',long_name=
'longitude',domain2=domain1,edges=id_lonb1)
4865 id_lat1 = diag_axis_init(
'lat1',
rad_to_deg*lat_global1,
'degrees_N',
'y',long_name=
'latitude', domain2=domain1,edges=id_latb1)
4867 id_phalf= diag_axis_init(
'phalf', phalf,
'Pa',
'z', long_name=
'half pressure level', direction=-1)
4868 id_pfull= diag_axis_init(
'pfull', pfull,
'Pa',
'z', long_name=
'full pressure level', direction=-1, edges=id_phalf)
4870 id_lon2 = diag_axis_init(
'lon2',
rad_to_deg*lon_global2,
'degrees_E',
'x', long_name=
'longitude', domain2=domain2)
4871 id_lat2 = diag_axis_init(
'lat2',
rad_to_deg*lat_global2,
'degrees_N',
'y', long_name=
'latitude', domain2=domain2)
4873 IF ( test_number == 22 )
THEN 4876 IF ( id_nv .GT. 0 )
THEN 4877 write (out_unit,
'(a)')
'test22.1 Passes: id_nv has a positive value' 4879 write (out_unit,
'(a)')
'test22.1 Failed: id_nv does not have a positive value' 4883 id_nv_init = diag_axis_init(
'nv',(/1.,2./),
'none',
'N',
'vertex number', set_name=
'nv')
4884 IF ( id_nv_init .EQ. id_nv )
THEN 4885 write (out_unit,
'(a)')
'test22.2 Passes: Can call diag_axis_init on "nv" and get same ID' 4887 write (out_unit,
'(a)')
'test22.2 Failed: Cannot call diag_axis_init on "nv" and get same ID' 4891 IF ( test_number == 21 )
THEN 4898 IF ( test_number == 14 )
THEN 4904 IF ( test_number == 16 )
THEN 4908 id_dat1 =
register_diag_field(
'test_diag_manager_mod',
'dat1', (/id_lon1,id_lat1,id_pfull/), time,
'sample data',
'K')
4909 IF ( test_number == 18 )
THEN 4914 IF ( test_number == 18 .OR. test_number == 19 )
THEN 4915 id_dat2 =
register_diag_field(
'test_diag_manager_mod',
'dat2', (/id_lon1,id_lat1,id_pfull/), time,
'sample data',
'K')
4919 id_dat2 =
register_diag_field(
'test_diag_manager_mod',
'dat2', (/id_lon2,id_lat2,id_pfull/), time,
'sample data',
'K')
4922 'solar constant',
'watts/m2')
4924 IF ( test_number == 20 )
THEN 4926 IF ( id_dat2_got == id_dat2 )
THEN 4927 WRITE (out_unit,
'(a)') .EQ.
'test20.1 Passes, id_dat2id_dat2_got' 4929 WRITE (out_unit,
'(a)') .NE.
'test20.1 Failed, id_dat2id_dat2_got' 4933 IF ( id_none_got == diag_field_not_found )
THEN 4934 write (out_unit,
'(a)') .EQ.
'test20.2 Passes, id_none_gotDIAG_FIELD_NOT_FOUND' 4936 write (out_unit,
'(a)') .NE.
'test20.2 Failed, id_none_gotDIAG_FIELD_NOT_FOUND' 4940 IF ( dt_step == 0 )
CALL error_mesg (
'test_diag_manager',&
4941 &
'dt_step is not set', fatal)
4949 time_end = time_end +
set_time(0, days)
4950 run_length = time_end - time_start
4951 nstep = run_length / time_step
4953 IF ( test_number == 18 )
THEN 4954 id_dat2h =
register_diag_field(
'test_mod',
'dat2h', (/id_lon1,id_lat1,id_pfull/), time,
'sample data',
'K',&
4955 & volume=id_dat1, area=id_dat2, realm=
'myRealm', err_msg=err_msg)
4956 IF ( err_msg /=
'' .OR. id_dat2h <= 0 )
THEN 4957 CALL error_mesg (
'test_diag_manager',&
4958 &
'Unexpected error registering dat2h '//err_msg, fatal)
4960 id_dat2h_2 =
register_diag_field(
'test_mod',
'dat2h_2', (/id_lon1,id_lat1,id_pfull/), time,
'sample data',
'K',&
4962 CALL diag_field_add_cell_measures(id_dat2h_2, area=id_dat2, volume=id_dat1)
4963 ELSE IF ( test_number == 19 )
THEN 4964 id_dat2h =
register_diag_field(
'test_mod',
'dat2h', (/id_lon1,id_lat1,id_pfull/), time,
'sample data',
'K',&
4965 & volume=id_dat1, area=id_dat1, err_msg=err_msg)
4966 IF ( err_msg /=
'' .OR. id_dat2h <= 0 )
THEN 4967 CALL error_mesg (
'test_diag_manager',&
4968 &
'Expected error registering dat2h '//err_msg, fatal)
4972 IF ( test_number == 16 .OR. test_number == 17 .OR. test_number == 18 .OR. test_number == 21 .OR. test_number == 22 )
THEN 4978 IF ( id_dat1 > 0 ) used =
send_data(id_dat1, dat1, time, err_msg=err_msg)
4979 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat1, time, err_msg=err_msg)
4980 IF ( id_dat2h > 0 ) used =
send_data(id_dat2h, dat2h, time, is_in=is_in, js_in=js_in, ie_in=ie_in, je_in=je_in, err_msg=err_msg)
4981 IF ( id_dat2h_2 > 0 ) used =
send_data(id_dat2h_2, dat2h, time, is_in=is_in, js_in=js_in, ie_in=ie_in, je_in=je_in, err_msg=err_msg)
4983 IF ( id_dat1 > 0 ) used =
send_data(id_dat1, dat1, time, err_msg=err_msg)
4984 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat1, time, err_msg=err_msg)
4985 IF ( id_dat2h > 0 ) used =
send_data(id_dat2h, dat2h, time, is_in=is_in, js_in=js_in, ie_in=ie_in, je_in=je_in, err_msg=err_msg)
4986 IF ( id_dat2h_2 > 0 ) used =
send_data(id_dat2h_2, dat2h, time, is_in=is_in, js_in=js_in, ie_in=ie_in, je_in=je_in, err_msg=err_msg)
4990 IF ( test_number == 15 )
THEN 4992 nyc1 = je1 - js1 + 1
4993 IF (mod(nyc1, numthreads ) /= 0)
THEN 4994 CALL error_mesg (
'test_diag_manager',&
4995 &
'The number of OpenMP threads must be an integral multiple & 4996 &of the number of rows in the compute domain', fatal)
4998 ny_per_thread = nyc1/numthreads
5001 CALL diag_manager_set_time_end(time_end)
5004 time = time + time_step
5007 DO jsw = js1, je1, ny_per_thread
5008 jew = jsw + ny_per_thread -1
5011 if(id_dat1>0) used =
send_data(id_dat1, dat1(isw:iew, jsw:jew,:), time, &
5012 is_in=isw-is1+1, js_in=jsw-js1+1,err_msg=err_msg)
5013 if(id_sol_con>0) used =
send_data(id_sol_con, solar_constant, time )
5016 CALL diag_send_complete(time_step)
5021 IF ( test_number == 14 )
THEN 5022 id_dat2_2d =
register_diag_field(
'test_mod',
'dat2', (/id_lon2,id_lat2/), time,
'sample data',
'K', err_msg=err_msg)
5023 IF ( err_msg /=
'' )
THEN 5024 WRITE (out_unit,
'(a)')
'test14 successful. err_msg='//trim(err_msg)
5026 WRITE (out_unit,
'(a)')
'test14 fails.' 5029 id_dat2_2d =
register_diag_field(
'test_mod',
'dat2', (/id_lon2,id_lat2/), time,
'sample data',
'K')
5032 id_bk = register_static_field(
'test_diag_manager_mod',
'bk', (/id_pfull/),
'half level sigma',
'none')
5034 IF ( test_number == 13 )
THEN 5035 IF ( id_dat2_2d > 0 ) used=
send_data(id_dat2_2d, dat2(:,:,1), time, err_msg=err_msg)
5036 IF ( err_msg ==
'' )
THEN 5037 WRITE (out_unit,
'(a)')
'test13: successful if a WARNING message appears that refers to output interval greater than runlength' 5039 WRITE (out_unit,
'(a)')
'test13 fails: err_msg='//trim(err_msg)
5046 IF ( test_number == 11 )
THEN 5049 ie_in = ie2-is2+1+hi
5050 je_in = je2-js2+1+hj
5052 IF ( id_dat2 > 0 ) used=
send_data(id_dat2, dat2h, time, is_in=is_in, js_in=js_in, ie_in=ie_in, je_in=je_in, err_msg=err_msg)
5053 IF ( err_msg ==
'' )
THEN 5054 WRITE (out_unit,
'(a)')
'test11.1 successful.' 5056 WRITE (out_unit,
'(a)')
'test11.1 fails. err_msg='//trim(err_msg)
5060 IF ( id_dat2 > 0 ) used=
send_data(id_dat2, dat2h, time, is_in=is_in, js_in=js_in, ie_in=ie_in, err_msg=err_msg)
5061 IF ( err_msg ==
'' )
THEN 5062 WRITE (out_unit,
'(a)')
'test11.2 fails.' 5064 WRITE (out_unit,
'(a)')
'test11.2 successful. err_msg='//trim(err_msg)
5068 IF ( test_number == 10 )
THEN 5071 IF ( id_bk > 0 ) used =
send_data(id_bk, bk, err_msg=err_msg)
5072 IF ( err_msg ==
'' )
THEN 5073 WRITE (out_unit,
'(a)')
'test10.1 successful.' 5075 WRITE (out_unit,
'(a)')
'test10.1 fails: err_msg='//trim(err_msg)
5079 IF ( id_bk > 0 ) used =
send_data(id_bk, phalf, err_msg=err_msg)
5080 IF ( err_msg ==
'' )
THEN 5081 WRITE(out_unit,
'(a)')
'test10.2 fails.' 5083 WRITE (out_unit,
'(a)')
'test10.2 successful: err_msg='//trim(err_msg)
5087 IF ( test_number == 9 )
THEN 5089 IF ( id_bk > 0 ) used =
send_data(id_bk, bk, err_msg=err_msg)
5090 IF ( err_msg ==
'' )
THEN 5091 WRITE (out_unit,
'(a)')
'test9.1 successful.' 5093 WRITE (out_unit,
'(a)')
'test9.1 fails: err_msg='//trim(err_msg)
5097 IF ( id_bk > 0 ) used =
send_data(id_bk, bk(1:nlev-1), err_msg=err_msg)
5098 IF ( err_msg ==
'' )
THEN 5099 WRITE (out_unit,
'(a)')
'test9.2 fails.' 5101 WRITE (out_unit,
'(a)')
'test9.2 successful: err_msg='//trim(err_msg)
5105 IF ( test_number == 8 )
THEN 5110 ie_in = ie2-is2+1+hi
5111 je_in = je2-js2+1+hj
5112 IF ( id_dat2 > 0 ) used=
send_data(id_dat2, dat2h, time, is_in=is_in, js_in=js_in,&
5113 & ks_in=1, ie_in=ie_in, je_in=je_in, ke_in=nlev, err_msg=err_msg)
5114 IF ( err_msg ==
'' )
THEN 5115 WRITE (out_unit,
'(a)')
'test8.1 successful.' 5117 WRITE (out_unit,
'(a)')
'test8.1 fails: err_msg='//trim(err_msg)
5123 ie_in = ie1-is1+1+hi
5124 je_in = je1-js1+1+hj
5125 IF ( id_dat2 > 0 ) used=
send_data(id_dat2, dat1h, time, is_in=is_in, js_in=js_in,&
5126 & ks_in=1, ie_in=ie_in, je_in=je_in, ke_in=nlev, err_msg=err_msg)
5128 IF ( id_dat2 > 0 ) used=
send_data(id_dat2, dat1h, time, is_in=is_in, js_in=js_in, &
5129 & ks_in=1, ie_in=ie_in, je_in=je_in, ke_in=nlev, err_msg=err_msg)
5130 IF ( err_msg ==
'' )
THEN 5131 WRITE (out_unit,
'(a)')
'test8.2 fails.' 5133 WRITE (out_unit,
'(a)')
'test8.2 successful: err_msg='//trim(err_msg)
5137 IF ( test_number == 7 )
THEN 5142 ie_in = ie1-is1+1+hi
5143 je_in = je1-js1+1+hj
5144 IF ( id_dat1 > 0 ) used=
send_data(id_dat1, dat1h, time, is_in=is_in, js_in=js_in,&
5145 & ks_in=1, ie_in=ie_in, je_in=je_in, ke_in=nlev, err_msg=err_msg)
5146 IF ( err_msg ==
'' )
THEN 5147 WRITE (out_unit,
'(a)')
'test7.1 successful.' 5149 WRITE (out_unit,
'(a)')
'test7.1 fails: err_msg='//trim(err_msg)
5153 ie_in = ie2-is2+1+hi
5154 je_in = je2-js2+1+hj
5155 IF ( id_dat1 > 0 ) used=
send_data(id_dat1, dat2h, time, is_in=is_in, js_in=js_in,&
5156 & ks_in=1, ie_in=ie_in, je_in=je_in, ke_in=nlev, err_msg=err_msg)
5157 IF ( err_msg ==
'' )
THEN 5158 WRITE (out_unit,
'(a)')
'test7.2 fails.' 5160 WRITE (out_unit,
'(a)')
'test7.2 successful: err_msg='//trim(err_msg)
5164 IF ( test_number == 6 )
THEN 5167 test_successful = .true.
5169 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat2(i:i,:,:), time, i-is2+1, 1, err_msg=err_msg)
5170 IF ( err_msg /=
'' )
THEN 5171 WRITE (out_unit,
'(a)')
'test6.1 fails: err_msg='//trim(err_msg)
5172 test_successful = .false.
5177 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat2(i:i,:,:), time, i-is2+1, 1, err_msg=err_msg)
5178 IF ( err_msg /=
'' )
THEN 5179 WRITE (out_unit,
'(a)')
'test6.1 fails: err_msg='//trim(err_msg)
5180 test_successful = .false.
5183 IF ( test_successful )
THEN 5184 WRITE (out_unit,
'(a)')
'test6.1 successful.' 5186 WRITE (out_unit,
'(a)')
'test6.1 fails.' 5193 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat2(i:i,js2:je2-1,:), time, i-is2+1, 1)
5197 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat2(i:i,js2:je2-1,:), time, i-is2+1, 1, err_msg=err_msg)
5198 IF ( err_msg /=
'' )
EXIT 5200 IF ( err_msg ==
'' )
THEN 5201 WRITE (out_unit,
'(a)')
'test6.2 fails.' 5203 WRITE (out_unit,
'(a)')
'test6.2 successful: err_msg='//trim(err_msg)
5207 IF ( test_number == 5 )
THEN 5210 test_successful = .true.
5212 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat2(:,j:j,:), time, 1, j-js2+1, err_msg=err_msg)
5213 IF ( err_msg /=
'' )
THEN 5214 WRITE (out_unit,
'(a)')
'test5.1 fails: err_msg='//trim(err_msg)
5215 test_successful = .false.
5220 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat2(:,j:j,:), time, 1, j-js2+1, err_msg=err_msg)
5221 IF ( err_msg /=
'' )
THEN 5222 WRITE (out_unit,
'(a)')
'test5.1 fails: err_msg='//trim(err_msg)
5223 test_successful = .false.
5226 IF ( test_successful )
THEN 5227 WRITE (out_unit,
'(a)')
'test5.1 successful.' 5229 WRITE (out_unit,
'(a)')
'test5.1 fails.' 5236 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat2(is2:ie2-1,j:j,:), time, 1, j-js2+1)
5240 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat2(is2:ie2-1,j:j,:), time, 1, j-js2+1, err_msg=err_msg)
5241 IF ( err_msg /=
'' )
EXIT 5243 IF ( err_msg ==
'' )
THEN 5244 WRITE (out_unit,
'(a)')
'test5.2 fails.' 5246 WRITE (out_unit,
'(a)')
'test5.2 successful: err_msg='//trim(err_msg)
5250 IF ( test_number == 4 )
THEN 5252 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat2, time, err_msg=err_msg)
5254 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat2, time, err_msg=err_msg)
5255 IF ( err_msg ==
'' )
THEN 5256 WRITE (out_unit,
'(a)')
'test4.1 successful.' 5258 WRITE (out_unit,
'(a)')
'test4.1 fails: err_msg='//trim(err_msg)
5264 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat1, time, err_msg=err_msg)
5266 IF ( id_dat2 > 0 ) used =
send_data(id_dat2, dat1, time, err_msg=err_msg)
5267 IF ( err_msg ==
'' )
THEN 5268 WRITE (out_unit,
'(a)')
'test4.2 fails.' 5270 WRITE (out_unit,
'(a)')
'test4.2 successful: err_msg='//trim(err_msg)
5274 IF ( test_number == 3 )
THEN 5277 test_successful = .true.
5279 IF ( id_dat1 > 0 ) used =
send_data(id_dat1, dat1(i:i,:,:), time, i-is1+1, 1, err_msg=err_msg)
5280 IF ( err_msg /=
'' )
THEN 5281 WRITE (out_unit,
'(a)')
'test3.1 fails: err_msg='//trim(err_msg)
5282 test_successful = .false.
5285 IF ( test_successful )
THEN 5286 WRITE (out_unit,
'(a)')
'test3.1 successful.' 5288 WRITE (out_unit,
'(a)')
'test3.1 fails.' 5293 IF ( id_dat1 > 0 ) used =
send_data(id_dat1, dat2(i:i,:,:), time, i-is1+1, 1, err_msg=err_msg)
5294 IF ( err_msg /=
'' )
EXIT 5296 IF ( err_msg ==
'' )
THEN 5297 WRITE (out_unit,
'(a)')
'test3.2 fails.' 5299 WRITE (out_unit,
'(a)')
'test3.2 successful: err_msg='//trim(err_msg)
5303 IF ( test_number == 2 )
THEN 5306 test_successful = .true.
5308 IF ( id_dat1 > 0 ) used =
send_data(id_dat1, dat1(:,j:j,:), time, 1, j-js1+1, err_msg=err_msg)
5309 IF ( err_msg /=
'' )
THEN 5310 WRITE (out_unit,
'(a)')
'test2.1 fails: err_msg='//trim(err_msg)
5311 test_successful = .false.
5314 IF ( test_successful )
THEN 5315 WRITE (out_unit,
'(a)')
'test2.1 successful.' 5317 WRITE (out_unit,
'(a)')
'test2.1 fails.' 5322 IF ( id_dat1 > 0 ) used =
send_data(id_dat1, dat2(:,j:j,:), time, 1, j-js1+1, err_msg=err_msg)
5323 IF ( err_msg /=
'' )
EXIT 5325 IF ( err_msg ==
'' )
THEN 5326 WRITE (out_unit,
'(a)')
'test2.2 fails.' 5328 WRITE (out_unit,
'(a)')
'test2.2 successful: err_msg='//trim(err_msg)
5332 IF ( test_number == 1 )
THEN 5334 IF ( id_dat1 > 0 ) used =
send_data(id_dat1, dat2, time, err_msg=err_msg)
5335 IF ( err_msg ==
'' )
THEN 5336 WRITE (out_unit,
'(a)')
'test1.1 fails: Intentional error not detected' 5338 WRITE (out_unit,
'(a)')
'test1.1 successful: '//trim(err_msg)
5342 IF ( id_dat1 > 0 ) used =
send_data(id_dat1, dat1, time, err_msg=err_msg)
5343 IF ( err_msg ==
'' )
THEN 5344 WRITE (out_unit,
'(a)')
'test1.2 successful' 5346 WRITE (out_unit,
'(a)')
'test1.2 fails: '//trim(err_msg)
5350 CALL diag_manager_end(time)
5356 SUBROUTINE compute_grid(nlon, nlat, is, ie, js, je, lon_global, lat_global, lonb_global, latb_global, lon, lat, lonb, latb)
5357 INTEGER,
INTENT(in) :: nlon, nlat, is, ie, js, je
5358 REAL,
INTENT(out),
DIMENSION(:) :: lon_global, lat_global, lonb_global, latb_global, lon, lat, lonb, latb
5367 lonb_global(i) = dlon*(i-1)
5370 latb_global(j) = dlat*(j-1) - .5*
pi 5373 lon_global(i) = .5*(lonb_global(i) + lonb_global(i+1))
5376 lat_global(j) = .5*(latb_global(j) + latb_global(j+1))
5378 lon = lon_global(is:ie)
5379 lat = lat_global(js:je)
5380 lonb = lonb_global(is:ie+1)
5381 latb = latb_global(js:je+1)
5384 SUBROUTINE unstruct_test(nx, ny, nz, npes, num_domain_tiles_x, num_domain_tiles_y, diag_time,io_tile_factor)
5385 use,
intrinsic :: iso_fortran_env, only: output_unit
5393 mpp_define_mosaic, &
5396 mpp_define_unstruct_domain, &
5398 mpp_get_ug_compute_domain, &
5399 mpp_get_ug_domain_grid_index, &
5400 mpp_get_ug_domain_ntiles
5411 integer(INT_KIND),
intent(in) :: nx
5412 integer(INT_KIND),
intent(in) :: ny
5413 integer(INT_KIND),
intent(in) :: nz
5414 integer(INT_KIND),
intent(in) :: npes
5415 integer(INT_KIND),
intent(in) :: num_domain_tiles_x
5416 integer(INT_KIND),
intent(in) :: num_domain_tiles_y
5417 type(time_type),
intent(inout) :: diag_time
5418 integer(INT_KIND),
intent(in) :: io_tile_factor
5421 integer(INT_KIND) :: num_domain_tiles
5422 integer(INT_KIND) :: npes_per_domain_tile
5423 integer(INT_KIND) :: my_domain_tile_id
5424 logical(INT_KIND) :: is_domain_tile_root
5425 integer(INT_KIND),
dimension(2) :: layout_for_full_domain
5426 integer(INT_KIND),
dimension(:),
allocatable :: pe_start
5427 integer(INT_KIND),
dimension(:),
allocatable :: pe_end
5428 integer(INT_KIND) :: x_grid_points_per_domain_tile
5429 integer(INT_KIND) :: y_grid_points_per_domain_tile
5430 integer(INT_KIND),
dimension(:,:),
allocatable :: global_indices
5431 integer(INT_KIND),
dimension(:,:),
allocatable :: layout2D
5432 type(domain2D) :: domain_2D
5433 logical(INT_KIND),
dimension(:,:,:),
allocatable :: land_mask
5434 integer(INT_KIND),
dimension(:),
allocatable :: num_non_masked_grid_points_per_domain_tile
5435 integer(INT_KIND) :: mask_counter
5436 integer(INT_KIND) :: num_non_masked_grid_points
5437 integer(INT_KIND),
dimension(:),
allocatable :: num_land_tiles_per_non_masked_grid_point
5438 integer(INT_KIND) :: num_ranks_using_unstructured_grid
5439 integer(INT_KIND),
dimension(:),
allocatable :: unstructured_grid_point_index_map
5440 type(domainUG) :: domain_ug
5441 integer(INT_KIND),
dimension(:),
allocatable :: unstructured_axis_data
5442 integer(INT_KIND) :: unstructured_axis_data_size
5443 character(len=256) :: unstructured_axis_name
5444 real,
dimension(:),
allocatable :: x_axis_data
5445 real,
dimension(:),
allocatable :: y_axis_data
5446 real,
dimension(:),
allocatable :: z_axis_data
5447 real :: unstructured_real_scalar_field_data_ref
5448 real,
dimension(:),
allocatable :: unstructured_real_1D_field_data_ref
5449 real,
dimension(:,:),
allocatable :: unstructured_real_2D_field_data_ref
5450 real,
dimension(:,:,:),
allocatable :: unstructured_real_3D_field_data_ref
5451 integer :: unstructured_int_scalar_field_data_ref
5452 integer,
dimension(:),
allocatable :: unstructured_int_1D_field_data_ref
5453 integer,
dimension(:,:),
allocatable :: unstructured_int_2D_field_data_ref
5454 character(len=256) :: unstructured_real_scalar_field_name
5455 real :: unstructured_real_scalar_field_data
5456 character(len=256) :: unstructured_real_1D_field_name
5457 real,
dimension(:),
allocatable :: unstructured_real_1D_field_data
5458 character(len=256) :: unstructured_real_2D_field_name
5459 real,
dimension(:,:),
allocatable :: unstructured_real_2D_field_data
5460 character(len=256) :: unstructured_real_3D_field_name
5461 real,
dimension(:,:,:),
allocatable :: unstructured_real_3D_field_data
5462 character(len=256) :: unstructured_int_scalar_field_name
5463 integer :: unstructured_int_scalar_field_data
5464 character(len=256) :: unstructured_int_1D_field_name
5465 integer,
dimension(:),
allocatable :: unstructured_int_1D_field_data
5466 character(len=256) :: unstructured_int_2D_field_name
5467 character(len=100) :: unstructured_1d_alt
5468 integer,
dimension(:,:),
allocatable :: unstructured_int_2D_field_data
5469 integer(INT_KIND),
allocatable,
dimension(:) :: unstructured_axis_diag_id
5470 integer(INT_KIND) :: x_axis_diag_id
5471 integer(INT_KIND) :: y_axis_diag_id
5472 integer(INT_KIND) :: z_axis_diag_id
5473 real,
allocatable,
dimension(:) :: lat, lon
5474 integer(INT_KIND) :: idlat
5475 integer(INT_KIND) :: idlon
5476 integer(INT_KIND) :: rsf_diag_id
5478 integer(INT_KIND),
allocatable,
dimension(:) :: rsf_diag_1d_id
5479 integer(INT_KIND) :: rsf_diag_2d_id
5480 integer(INT_KIND) :: num_diag_time_steps
5481 type(time_type) :: diag_time_start
5482 type(time_type) :: diag_time_step
5483 logical(INT_KIND) :: used
5485 integer(INT_KIND) :: i
5486 integer(INT_KIND) :: j
5487 integer(INT_KIND) :: k,l=1
5488 integer(INT_KIND) :: p
5491 integer(INT_KIND) :: ncontacts
5492 integer(INT_KIND),
dimension(20) :: tile1
5493 integer(INT_KIND),
dimension(20) :: tile2
5494 integer(INT_KIND),
dimension(20) :: istart1
5495 integer(INT_KIND),
dimension(20) :: iend1
5496 integer(INT_KIND),
dimension(20) :: jstart1
5497 integer(INT_KIND),
dimension(20) :: jend1
5498 integer(INT_KIND),
dimension(20) :: istart2
5499 integer(INT_KIND),
dimension(20) :: iend2
5500 integer(INT_KIND),
dimension(20) :: jstart2
5501 integer(INT_KIND),
dimension(20) :: jend2
5503 integer(INT_KIND),
dimension(3) :: npes_io_group
5506 if (mpp_pe() .eq. mpp_root_pe())
then 5507 write(output_unit,*)
5508 write(output_unit,*)
"</----------------------------------------" 5509 write(output_unit,*)
"Test create_unstructured_test_restart_file" &
5511 write(output_unit,*)
5518 if (nx .lt. 1 .or. ny .lt. 1)
then 5520 "create_unstructured_test_restart_file:" &
5521 //
" there must be at least on grid point in the" &
5522 //
" x- and y- dimensions.")
5524 if (npes .gt. nx*ny)
then 5526 "create_unstructured_test_restart_file:" &
5527 //
" the total number of ranks cannot be greater" &
5528 //
" than the total number of grid points in the" &
5531 if (num_domain_tiles_x .lt. 1 .or. num_domain_tiles_y .lt. 1)
then 5533 "create_unstructured_test_restart_file:" &
5534 //
" there must be at least on domain tile in the" &
5535 //
" x- and y- dimensions.")
5537 if (mod(nx,num_domain_tiles_x) .ne. 0)
then 5539 "create_unstructured_test_restart_file:" &
5540 //
" the total number of grid points in the" &
5541 //
" x-dimension must be evenly divisible by the" &
5542 //
" total number of domain tiles in the" &
5545 if (mod(ny,num_domain_tiles_y) .ne. 0)
then 5547 "create_unstructured_test_restart_file:" &
5548 //
" the total number of grid points in the" &
5549 //
" y-dimension must be evenly divisible by the" &
5550 //
" total number of domain tiles in the" &
5553 if (num_domain_tiles_x*num_domain_tiles_y .gt. npes)
then 5555 "create_unstructured_test_restart_file:" &
5556 //
" the total number of domain tiles cannot be" &
5557 //
" greater than the total number of ranks.")
5559 if (mod(npes,num_domain_tiles_x) .ne. 0)
then 5561 "create_unstructured_test_restart_file:" &
5562 //
" the total number of ranks must be evenly" &
5563 //
" divisible by the total number of domain" &
5564 //
" tiles in the x-dimension.")
5566 if (mod(npes,num_domain_tiles_y) .ne. 0)
then 5568 "create_unstructured_test_restart_file:" &
5569 //
" the total number of ranks must be evenly" &
5570 //
" divisible by the total number of domain" &
5571 //
" tiles in the y-dimension.")
5575 num_domain_tiles = num_domain_tiles_x*num_domain_tiles_y
5576 npes_per_domain_tile = npes/num_domain_tiles
5577 my_domain_tile_id = (mpp_pe())/npes_per_domain_tile + 1
5578 if (mpp_pe() .eq. (my_domain_tile_id-1)*npes_per_domain_tile)
then 5579 is_domain_tile_root = .true.
5581 is_domain_tile_root = .false.
5583 layout_for_full_domain(1) = num_domain_tiles_x
5584 layout_for_full_domain(2) = npes/layout_for_full_domain(1)
5590 allocate(pe_start(num_domain_tiles))
5591 allocate(pe_end(num_domain_tiles))
5592 do i = 1,num_domain_tiles
5593 pe_start(i) = (i-1)*npes_per_domain_tile
5594 pe_end(i) = i*npes_per_domain_tile - 1
5599 x_grid_points_per_domain_tile = nx/num_domain_tiles_x
5600 y_grid_points_per_domain_tile = ny/num_domain_tiles_y
5601 allocate(global_indices(4,num_domain_tiles))
5602 do i = 1,num_domain_tiles
5603 global_indices(:,i) = (/1,x_grid_points_per_domain_tile, &
5604 1,y_grid_points_per_domain_tile/)
5606 allocate(layout2d(2,num_domain_tiles))
5607 do i = 1,num_domain_tiles
5608 layout2d(1,i) = layout_for_full_domain(1)/num_domain_tiles_x
5609 layout2d(2,i) = layout_for_full_domain(2)/num_domain_tiles_y
5628 call mpp_define_mosaic(global_indices, &
5647 allocate(land_mask(x_grid_points_per_domain_tile, &
5648 y_grid_points_per_domain_tile, &
5650 allocate(num_non_masked_grid_points_per_domain_tile(num_domain_tiles))
5652 do k = 1,num_domain_tiles
5654 do j = 1,y_grid_points_per_domain_tile
5655 do i = 1,x_grid_points_per_domain_tile
5656 if (mod((k-1)*y_grid_points_per_domain_tile*x_grid_points_per_domain_tile + &
5657 (j-1)*x_grid_points_per_domain_tile + &
5658 (i-1),2) .eq. 0)
then 5659 land_mask(i,j,k) = .true.
5660 mask_counter = mask_counter + 1
5664 num_non_masked_grid_points_per_domain_tile(k) = mask_counter
5668 num_non_masked_grid_points = sum(num_non_masked_grid_points_per_domain_tile)
5669 allocate(num_land_tiles_per_non_masked_grid_point(num_non_masked_grid_points))
5670 num_land_tiles_per_non_masked_grid_point = 1
5674 num_ranks_using_unstructured_grid = npes
5675 if (num_ranks_using_unstructured_grid .gt. num_non_masked_grid_points)
then 5677 "create_unstructured_test_restart_file:" &
5678 //
" the number of ranks exceeds the number of" &
5679 //
" non-masked grid points for the unstructured" &
5690 allocate(unstructured_grid_point_index_map(num_non_masked_grid_points))
5692 do k = 1,num_domain_tiles
5693 do j = 1,y_grid_points_per_domain_tile
5694 do i = 1,x_grid_points_per_domain_tile
5695 if (land_mask(i,j,k))
then 5697 unstructured_grid_point_index_map(p) = (j-1)*x_grid_points_per_domain_tile + i
5716 if (mpp_pe() == mpp_root_pe())
write(6,*)
"IO_TILE_FACTOR is ",io_tile_factor
5717 allocate(unstructured_axis_diag_id(1))
5718 allocate(rsf_diag_1d_id(1))
5721 call mpp_define_unstruct_domain(domain_ug, &
5723 num_non_masked_grid_points_per_domain_tile, &
5724 num_land_tiles_per_non_masked_grid_point, &
5725 num_ranks_using_unstructured_grid, &
5727 unstructured_grid_point_index_map)
5737 call mpp_get_ug_compute_domain(domain_ug,
size=unstructured_axis_data_size)
5738 if(.not.
allocated(unstructured_axis_data))
allocate(unstructured_axis_data(unstructured_axis_data_size))
5740 call mpp_get_ug_domain_grid_index(domain_ug,unstructured_axis_data)
5743 unstructured_axis_name =
"ug_axis" 5745 unstructured_axis_diag_id(l) =
diag_axis_init(trim(unstructured_axis_name), &
5746 real(unstructured_axis_data), &
5749 long_name=
"mapping indices", &
5757 if (.not.
allocated(x_axis_data))
allocate(x_axis_data(nx))
5762 x_axis_data(i) =
real(i)
5779 long_name=
"longitude")
5781 if (.not.
allocated(y_axis_data))
allocate(y_axis_data(ny/num_domain_tiles_y))
5782 do i = 1,ny/num_domain_tiles_y
5783 y_axis_data(i) =
real(i)
5789 long_name=
"latitude")
5791 if (.not.
allocated(z_axis_data))
allocate(z_axis_data(nz))
5793 z_axis_data(i) =
real(i*5.0)
5799 long_name=
"dont look down")
5805 unstructured_real_scalar_field_data_ref = 1234.5678*
real(l)
5808 if (.not.
allocated(unstructured_real_1d_field_data_ref))
allocate(unstructured_real_1d_field_data_ref(unstructured_axis_data_size))
5809 do i = 1,unstructured_axis_data_size
5810 unstructured_real_1d_field_data_ref(i) =
real(i) *
real(i)+0.1*(mpp_pe()+1)
5814 if (.not.
allocated(unstructured_real_2d_field_data_ref))
allocate(unstructured_real_2d_field_data_ref(unstructured_axis_data_size,nz))
5816 do i = 1,unstructured_axis_data_size
5817 unstructured_real_2d_field_data_ref(i,j) =
real(j)+0.1*(mpp_pe()+1.0)
5838 unstructured_int_scalar_field_data_ref = 7654321*l
5841 if (.not.
allocated(unstructured_int_1d_field_data_ref))
allocate(unstructured_int_1d_field_data_ref(unstructured_axis_data_size))
5842 do i = 1,unstructured_axis_data_size
5843 unstructured_int_1d_field_data_ref(i) = i - 8*l
5847 if (.not.
allocated(unstructured_int_2d_field_data_ref))
allocate(unstructured_int_2d_field_data_ref(unstructured_axis_data_size,nz))
5849 do i = 1,unstructured_axis_data_size
5850 unstructured_int_2d_field_data_ref(i,j) = -1*((j-1)*unstructured_axis_data_size+i) + 2*l
5855 allocate(lat(ny/num_domain_tiles_y),lon(nx))
5857 lon(i) =
real(i)*360.0/
real(nx)
5859 do j=1,ny/num_domain_tiles_y
5860 lat(j) =
real(j)*180.8/
real(ny)
5865 unstructured_real_scalar_field_name =
"unstructured_real_scalar_field_1" 5866 unstructured_real_scalar_field_data = unstructured_real_scalar_field_data_ref
5870 (/x_axis_diag_id/),&
5871 init_time=diag_time, &
5872 long_name=
"E-W longitude", &
5874 l=
SIZE(unstructured_axis_diag_id)
5877 "unstructured_real_scalar_field_data", &
5878 init_time=diag_time, &
5879 long_name=
"rsf_diag_1", &
5882 "unstructured_real_1D_field_data", &
5883 (/unstructured_axis_diag_id(1)/),&
5884 init_time=diag_time, &
5885 long_name=
"ONE_D_ARRAY", &
5889 "unstructured_real_2D_field_data", &
5890 (/unstructured_axis_diag_id(1), z_axis_diag_id/),&
5891 init_time=diag_time, &
5892 long_name=
"TWO_D_ARRAY", &
5897 (/y_axis_diag_id/),&
5898 init_time=diag_time, &
5899 long_name=
"S-N latitude", &
5905 write(unstructured_1d_alt,
'(a,I0)')
"unstructured_real_1D",l
5907 (/unstructured_axis_diag_id(l)/),&
5908 init_time=diag_time, &
5909 long_name=
"OTHER"//trim(unstructured_1d_alt), &
5915 unstructured_real_1d_field_name =
"unstructured_real_1D_field_1" 5916 if (.not.
allocated(unstructured_real_1d_field_data))
allocate(unstructured_real_1d_field_data(unstructured_axis_data_size))
5917 unstructured_real_1d_field_data = unstructured_real_1d_field_data_ref
5921 unstructured_real_2d_field_name =
"unstructured_real_2D_field_1" 5922 if (.not.
allocated(unstructured_real_2d_field_data))
allocate(unstructured_real_2d_field_data(unstructured_axis_data_size,nz))
5923 unstructured_real_2d_field_data = unstructured_real_2d_field_data_ref
5934 unstructured_int_scalar_field_name =
"unstructured_int_scalar_field_1" 5935 unstructured_int_scalar_field_data = unstructured_int_scalar_field_data_ref
5939 unstructured_int_1d_field_name =
"unstructured_int_1D_field_1" 5940 if (.not.
allocated(unstructured_int_1d_field_data))
allocate(unstructured_int_1d_field_data(unstructured_axis_data_size))
5941 unstructured_int_1d_field_data = unstructured_int_1d_field_data_ref
5945 unstructured_int_2d_field_name =
"unstructured_int_2D_field_1" 5946 if (.not.
allocated(unstructured_int_2d_field_data))
allocate(unstructured_int_2d_field_data(unstructured_axis_data_size,nz))
5947 unstructured_int_2d_field_data = unstructured_int_2d_field_data_ref
5951 num_diag_time_steps = 4
5953 diag_time_start = diag_time
5956 do i = 1,num_diag_time_steps
5959 diag_time = diag_time + diag_time_step
5962 unstructured_real_scalar_field_data_ref = unstructured_real_scalar_field_data_ref + &
5964 unstructured_real_scalar_field_data = unstructured_real_scalar_field_data_ref
5967 if (rsf_diag_id .gt. 0)
then 5969 unstructured_real_scalar_field_data, &
5972 IF (
SIZE(rsf_diag_1d_id) == 1)
THEN 5974 unstructured_real_1d_field_data, &
5979 unstructured_real_1d_field_data, &
5984 unstructured_real_2d_field_data, &
5998 deallocate(pe_start)
6000 deallocate(global_indices)
6001 deallocate(layout2d)
6002 deallocate(land_mask)
6003 deallocate(num_non_masked_grid_points_per_domain_tile)
6004 deallocate(num_land_tiles_per_non_masked_grid_point)
6005 deallocate(unstructured_grid_point_index_map)
6006 deallocate(x_axis_data)
6007 deallocate(y_axis_data)
6008 deallocate(z_axis_data)
6009 deallocate(unstructured_axis_data)
6010 deallocate(unstructured_real_1d_field_data_ref)
6011 deallocate(unstructured_real_2d_field_data_ref)
6013 deallocate(unstructured_int_1d_field_data_ref)
6014 deallocate(unstructured_int_2d_field_data_ref)
6015 deallocate(unstructured_real_1d_field_data)
6016 deallocate(unstructured_real_2d_field_data)
6018 deallocate(unstructured_int_1d_field_data)
6019 deallocate(unstructured_int_2d_field_data)
6025 if (mpp_pe() .eq. mpp_root_pe())
then 6026 write(output_unit,*)
6027 write(output_unit,*)
"Test create_unstructured_test_restart_file" &
6029 write(output_unit,*)
"----------------------------------------/>" 6030 write(output_unit,*)
subroutine diag_field_add_attribute_scalar_c(diag_field_id, att_name, att_value)
integer(int_kind), parameter, public diag_axis_2ddomain
subroutine, public get_subfield_vert_size(axes, outnum)
subroutine, public get_date(time, year, month, day, hour, minute, second, tick, err_msg)
real, parameter cmor_missing_value
CMOR standard missing value.
integer function, public get_ticks_per_second()
integer function, public get_tile_count(ids)
logical write_manifest_file
Indicates if the manifest file should be written. If writing many regional files, then the terminatio...
integer, parameter every_time
character(len=256) global_descriptor
integer, parameter, public gregorian
integer num_output_fields
real, parameter, public rad_to_deg
Degrees per radian [deg/rad].
integer function, public find_input_field(module_name, field_name, tile_count)
subroutine diag_field_add_attribute_scalar_r(diag_field_id, att_name, att_value)
integer, parameter, public noleap
integer, parameter diag_seconds
subroutine unstruct_test(nx, ny, nz, npes, num_domain_tiles_x, num_domain_tiles_y, diag_time, io_tile_factor)
subroutine diag_data_init()
integer max_field_attributes
Maximum number of user definable attributes per field. Liptak: Changed from 2 to 4 20170718...
integer(int_kind), parameter, public diag_axis_ugdomain
subroutine diag_field_attribute_init(diag_field_id, name, type, cval, ival, rval)
integer max_axis_attributes
Maximum number of user definable attributes per axis.
logical function send_tile_averaged_data1d(id, field, area, time, mask)
subroutine, public diag_grid_init(domain, glo_lat, glo_lon, aglo_lat, aglo_lon)
integer max_out_per_in_field
Maximum number of output_fields per input_field. Increase via diag_manager_nml.
subroutine, public diag_util_init()
real function, public get_date_dif(t2, t1, units)
character(len=10), dimension(6) time_unit_list
type(time_type) base_time
character(len=32) pelist_name
subroutine, public update_bounds(out_num, lower_i, upper_i, lower_j, upper_j, lower_k, upper_k)
integer function, public register_static_field(module_name, field_name, axes, long_name, units, missing_value, range, mask_variant, standard_name, DYNAMIC, do_not_log, interp_method, tile_count, area, volume, realm)
integer function init_diurnal_axis(n_samples)
integer function, public get_diag_field_id(module_name, field_name)
integer, parameter end_of_run
subroutine diag_field_add_attribute_i1d(diag_field_id, att_name, att_value)
subroutine, public check_bounds_are_exact_dynamic(out_num, diag_field_id, Time, err_msg)
type(time_type) function, public get_base_time()
integer max_file_attributes
Maximum number of user definable global attributes per file.
logical function, public fms_error_handler(routine, message, err_msg)
logical function get_related_field(field, rel_field, out_field_id, out_file_id)
subroutine, public diag_manager_end(time)
integer, parameter diag_field_not_found
logical function send_data_1d(diag_field_id, field, time, is_in, mask, rmask, ie_in, weight, err_msg)
logical flush_nc_files
Control if diag_manager will force a flush of the netCDF file on each write. Note: changing this to ...
logical function send_data_0d(diag_field_id, field, time, err_msg)
subroutine closing_file(file, time)
subroutine, public write_static(file)
subroutine, public diag_manager_set_time_end(Time_end_in)
integer function writing_field(out_num, at_diag_end, error_string, time)
type(output_field_type), dimension(:), allocatable output_fields
logical write_bytes_in_file
subroutine, public diag_grid_end()
integer function, public check_nml_error(IOSTAT, NML_NAME)
integer, parameter diag_ocean
subroutine add_associated_files(file_num, cm_file_num, cm_ind)
Add to the associated files attribute.
subroutine, public init_output_field(module_name, field_name, output_name, output_file, time_method, pack, tile_count, local_coord)
subroutine average_tiles1d(diag_field_id, x, area, mask, out)
character(len=input_str_length), dimension(:), allocatable, target, public input_nml_file
subroutine, public check_out_of_bounds(out_num, diag_field_id, err_msg)
logical function send_data_2d(diag_field_id, field, time, is_in, js_in, mask, rmask, ie_in, je_in, weight, err_msg)
subroutine, public set_diag_global_att(component, gridType, tileName)
type(time_type) diag_init_time
subroutine, public set_calendar_type(type, err_msg)
integer function register_diag_field_array(module_name, field_name, axes, init_time, long_name, units, missing_value, range, mask_variant, standard_name, verbose, do_not_log, err_msg, interp_method, tile_count, area, volume, realm)
subroutine, public set_filename_appendix(string_in)
subroutine, public get_diag_global_att(gAtt)
real, parameter, public pi
Ratio of circle circumference to diameter [N/A].
type(file_type), dimension(:), allocatable, save files
logical append_pelist_name
integer, parameter diag_hours
subroutine, public fms_init(localcomm)
integer max_num_axis_sets
logical oor_warnings_fatal
subroutine, public sync_file_times(file_id, init_time, err_msg)
subroutine, public diag_manager_init(diag_model_subset, time_init, err_msg)
subroutine, public fms_io_init()
integer max_axes
Maximum number of independent axes.
integer function, public days_in_month(Time, err_msg)
subroutine, public diag_send_complete_instant(time)
The subroutine 'diag_send_complete_instant' allows the user to save diagnostic data on variable inter...
subroutine, public write_diag_manifest(file)
Public routine that will start the writing of the manifest file.
integer, parameter, public julian
type(input_field_type), dimension(:), allocatable input_fields
integer, parameter diag_minutes
integer, parameter, public thirty_day_months
integer function, public diag_axis_init(name, DATA, units, cart_name, long_name, direction, set_name, edges, Domain, Domain2, DomainU, aux, req, tile_count)
logical function, public need_data(diag_field_id, next_model_time)
integer function, public get_axis_length(id)
logical function send_data_3d(diag_field_id, field, time, is_in, js_in, ks_in, mask, rmask, ie_in, je_in, ke_in, weight, err_msg)
subroutine diag_field_add_attribute_scalar_i(diag_field_id, att_name, att_value)
logical module_is_initialized
logical function send_data_2d_r8(diag_field_id, field, time, is_in, js_in, mask, rmask, ie_in, je_in, weight, err_msg)
subroutine, public log_diag_field_info(module_name, field_name, axes, long_name, units, missing_value, range, dynamic)
integer max_files
Maximum number of output files allowed. Increase via diag_manager_nml.
subroutine diag_field_add_attribute_r1d(diag_field_id, att_name, att_value)
subroutine, public get_base_date(year, month, day, hour, minute, second)
integer max_output_fields
Maximum number of output fields. Increase via diag_manager_nml.
integer, parameter diag_years
type(time_type) function, public diag_time_inc(time, output_freq, output_units, err_msg)
type(domain2d) function, public get_domain2d(ids)
subroutine, public check_bounds_are_exact_static(out_num, diag_field_id, err_msg)
logical function send_tile_averaged_data2d(id, field, area, time, mask)
subroutine, public fms_end()
subroutine, public fms_io_exit()
subroutine, public get_subfield_size(axes, outnum)
integer, parameter diag_other
type(time_type) function, public decrement_date(Time, years, months, days, hours, minutes, seconds, ticks, err_msg, allow_neg_inc)
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE size(field%axes(:)) axsiz(i)
logical first_send_data_call
integer, parameter, public fatal
subroutine, public init_input_field(module_name, field_name, tile_count)
logical do_diag_field_log
logical mix_snapshot_average_fields
logical prepend_date
Should the history file have the start date prepended to the file name.
integer(int_kind) function, public axis_compatible_check(id, varname)
subroutine compute_grid(nlon, nlat, is, ie, js, je, lon_global, lat_global, lonb_global, latb_global, lon, lat, lonb, latb)
If the test_number == 100, then call the unstrcutured grid unit test and skip everything else...
integer max_input_fields
Maximum number of input fields. Increase via diag_manager_nml.
type(time_type) time_zero
subroutine, public diag_send_complete(time_step, err_msg)
subroutine, public get_instance_filename(name_in, name_out)
subroutine init_field_cell_measures(output_field, area, volume, err_msg)
subroutine, public diag_field_add_cell_measures(diag_field_id, area, volume)
logical region_out_use_alt_value
integer, parameter diag_days
integer function, public get_axis_num(axis_name, set_name)
integer, parameter diag_all
subroutine, public parse_diag_table(diag_subset, istat, err_msg)
real, parameter, public seconds_per_day
Seconds in a day [s].
logical issue_oor_warnings
subroutine, public get_time(Time, seconds, days, ticks, err_msg)
subroutine, public error_mesg(routine, message, level)
logical debug_diag_manager
integer function register_diag_field_scalar(module_name, field_name, init_time, long_name, units, missing_value, range, standard_name, do_not_log, err_msg, area, volume, realm)
logical function send_data_3d_r8(diag_field_id, field, time, is_in, js_in, ks_in, mask, rmask, ie_in, je_in, ke_in, weight, err_msg)
diag_manifest_mod writes out a manifest file for each diagnostic output file defined in the diag_tabl...
subroutine, public constants_init
dummy routine.
integer, parameter diag_months
subroutine, public diag_data_out(file, field, dat, time, final_call_in, static_write_in)
logical function send_tile_averaged_data3d(id, field, area, time, mask)
subroutine average_tiles(diag_field_id, x, area, mask, out)