49 private :: intrpnest_search_nearest_block
50 private :: intrpnest_search_horiz_1points
51 private :: intrpnest_search_horiz_3points
52 private :: intrpnest_search_horiz_4points
53 private :: intrpnest_search_horiz_8points
54 private :: intrpnest_search_horiz_12points
55 private :: intrpnest_search_vert_offline
56 private :: intrpnest_search_vert_online
57 private :: intrpnest_interp_2d_1points
58 private :: intrpnest_interp_3d_1points
59 private :: intrpnest_interp_2d_3points
60 private :: intrpnest_interp_3d_3points
61 private :: intrpnest_interp_2d_4points
62 private :: intrpnest_interp_3d_4points
63 private :: intrpnest_interp_2d_8points
64 private :: intrpnest_interp_3d_8points
65 private :: intrpnest_interp_2d_12points
66 private :: intrpnest_interp_3d_12points
67 private :: intrpnest_haversine
71 subroutine intrpnest_intfc_search_h( &
86 real(RP),
intent(out) :: hfact(:)
87 integer,
intent(out) :: igrd (:)
88 integer,
intent(out) :: jgrd (:)
89 real(RP),
intent(in) :: mylat
90 real(RP),
intent(in) :: mylon
91 real(RP),
intent(in) :: inlat(:,:)
92 real(RP),
intent(in) :: inlon(:,:)
93 integer,
intent(in) ::
is 94 integer,
intent(in) ::
ie 95 integer,
intent(in) ::
js 96 integer,
intent(in) ::
je 97 end subroutine intrpnest_intfc_search_h
99 procedure(intrpnest_intfc_search_h),
pointer :: intrpnest_search_horiz => null()
100 private :: intrpnest_search_horiz
104 subroutine intrpnest_intfc_search_v( &
121 real(RP),
intent(inout) :: vfact(:,:,:,:,:)
122 integer,
intent(inout) :: kgrd (:,:,:,:,:)
123 integer,
intent(out) :: ncopy(:)
124 integer,
intent(in) :: igrd(:)
125 integer,
intent(in) :: jgrd(:)
126 real(RP),
intent(in) :: myhgt(:)
127 real(RP),
intent(in) :: inhgt(:,:,:)
128 integer,
intent(in) :: iloc
129 integer,
intent(in) :: jloc
130 integer,
intent(in) ::
ks 131 integer,
intent(in) ::
ke 132 integer,
intent(in) :: inka
133 logical,
intent(in) :: lndgrd
134 end subroutine intrpnest_intfc_search_v
136 procedure(intrpnest_intfc_search_v),
pointer :: intrpnest_search_vert => null()
137 private :: intrpnest_search_vert
141 subroutine intrpnest_intfc_interp_2d( &
152 real(RP),
intent(out) :: intp(:,:)
153 real(RP),
intent(in) :: ref (:,:)
154 real(RP),
intent(in) :: hfact(:,:,:)
155 integer,
intent(in) :: igrd (:,:,:)
156 integer,
intent(in) :: jgrd (:,:,:)
157 integer,
intent(in) ::
ia 158 integer,
intent(in) ::
ja 159 end subroutine intrpnest_intfc_interp_2d
166 subroutine intrpnest_intfc_interp_3d( &
182 real(RP),
intent(out) :: intp(:,:,:)
183 real(RP),
intent(in) :: ref (:,:,:)
184 real(RP),
intent(in) :: hfact(:,:,:)
185 real(RP),
intent(in) :: vfact(:,:,:,:,:)
186 integer,
intent(in) :: kgrd (:,:,:,:,:)
187 integer,
intent(in) :: igrd (:,:,:)
188 integer,
intent(in) :: jgrd (:,:,:)
189 integer,
intent(in) ::
ia 190 integer,
intent(in) ::
ja 191 integer,
intent(in) ::
ks 192 integer,
intent(in) ::
ke 193 logical,
intent(in),
optional :: logwegt
194 end subroutine intrpnest_intfc_interp_3d
203 real(RP),
private,
parameter :: large_number_1 = 9.999e+15_rp
204 real(RP),
private,
parameter :: large_number_2 = 9.888e+15_rp
205 real(RP),
private,
parameter :: large_number_3 = 9.777e+15_rp
206 real(RP),
private,
parameter :: large_number_4 = 9.666e+15_rp
207 real(RP),
private,
parameter :: large_number_5 = 9.555e+15_rp
208 real(RP),
private,
parameter :: large_number_6 = 9.444e+15_rp
209 real(RP),
private,
parameter :: large_number_7 = 9.333e+15_rp
210 real(RP),
private,
parameter :: large_number_8 = 9.222e+15_rp
211 real(RP),
private,
parameter :: large_number_9 = 9.111e+15_rp
212 real(RP),
private,
parameter :: large_number_10 = 9.000e+15_rp
213 real(RP),
private,
parameter :: large_number_11 = 8.999e+15_rp
214 real(RP),
private,
parameter :: large_number_12 = 8.888e+15_rp
216 integer,
private :: divnum
217 integer,
private :: itp_nh
224 interp_search_divnum, &
231 integer,
intent(in) :: interp_search_divnum
232 integer,
intent(in) :: NEST_INTERP_LEVEL
233 logical,
intent(in) :: OFFLINE
235 character(7) :: select_type
239 if(
io_l )
write(
io_fid_log,*)
'+++ Module[NEST]/Categ[GRID INTERP]' 241 divnum = interp_search_divnum
243 select case ( nest_interp_level )
245 intrpnest_search_horiz => intrpnest_search_horiz_1points
251 intrpnest_search_horiz => intrpnest_search_horiz_3points
257 intrpnest_search_horiz => intrpnest_search_horiz_4points
263 intrpnest_search_horiz => intrpnest_search_horiz_8points
269 intrpnest_search_horiz => intrpnest_search_horiz_12points
275 write(*,*)
'xxx invarid NEST_INTERP_LEVEL (', nest_interp_level, &
276 ') [setup: nest/interp]' 281 select_type =
"offline" 282 intrpnest_search_vert => intrpnest_search_vert_offline
284 select_type =
"online" 285 intrpnest_search_vert => intrpnest_search_vert_online
288 if(
io_l )
write(
io_fid_log,*)
'+++ horizontal interpolation with ', &
289 nest_interp_level,
" points." 290 if(
io_l )
write(
io_fid_log,*)
'+++ vertical interpolation for ', &
315 real(RP),
intent(out) :: hfact(:,:,:)
316 integer,
intent(out) :: igrd (:,:,:)
317 integer,
intent(out) :: jgrd (:,:,:)
319 real(RP),
intent(in) :: mylat(:,:)
320 real(RP),
intent(in) :: mylon(:,:)
321 integer,
intent(in) :: myIA
322 integer,
intent(in) :: myJA
324 real(RP),
intent(in) :: inlat(:,:)
325 real(RP),
intent(in) :: inlon(:,:)
326 integer,
intent(in) :: inIA
327 integer,
intent(in) :: inJA
334 hfact(:,:,:) = 0.0_rp
339 call intrpnest_search_nearest_block( is, ie, js, je, &
340 mylat(i,j), mylon(i,j), &
341 inlat(:,:), inlon(:,:), &
345 call intrpnest_search_horiz( hfact(i,j,:), &
388 real(RP),
intent(out) :: hfact(:,:,:)
389 real(RP),
intent(out) :: vfact(:,:,:,:,:)
390 integer,
intent(out) :: kgrd (:,:,:,:,:)
391 integer,
intent(out) :: igrd (:,:,:)
392 integer,
intent(out) :: jgrd (:,:,:)
393 integer,
intent(out) :: ncopy(:,:,:)
395 real(RP),
intent(in) :: myhgt(:,:,:)
396 real(RP),
intent(in) :: mylat(:,:)
397 real(RP),
intent(in) :: mylon(:,:)
398 integer,
intent(in) :: myKS
399 integer,
intent(in) :: myKE
400 integer,
intent(in) :: myIA
401 integer,
intent(in) :: myJA
403 real(RP),
intent(in) :: inhgt(:,:,:)
404 real(RP),
intent(in) :: inlat(:,:)
405 real(RP),
intent(in) :: inlon(:,:)
406 integer,
intent(in) :: inKA
407 integer,
intent(in) :: inIA
408 integer,
intent(in) :: inJA
410 logical,
intent(in),
optional :: landgrid
419 if (
present(landgrid) )
then 425 hfact(:,:,:) = 0.0_rp
426 vfact(:,:,:,:,:) = 0.0_rp
433 call intrpnest_search_nearest_block( is, ie, js, je, &
434 mylat(i,j), mylon(i,j), &
435 inlat(:,:), inlon(:,:), &
439 call intrpnest_search_horiz( hfact(i,j,:), &
450 call intrpnest_search_vert( vfact, &
471 subroutine intrpnest_search_nearest_block( &
484 integer,
intent(out) :: is
485 integer,
intent(out) :: ie
486 integer,
intent(out) :: js
487 integer,
intent(out) :: je
489 real(RP),
intent(in) :: mylat
490 real(RP),
intent(in) :: mylon
491 real(RP),
intent(in) :: inlat(:,:)
492 real(RP),
intent(in) :: inlon(:,:)
493 integer,
intent(in) :: inIA
494 integer,
intent(in) :: inJA
496 real(RP) :: distance, dist
498 integer :: iinc, jinc
499 integer :: blk_i, blk_j
502 iinc = max( (inia + 1) / divnum, 1 )
503 jinc = max( (inja + 1) / divnum, 1 )
504 dist = large_number_1
507 do while (jj <= inja)
509 do while (ii <= inia)
510 distance = intrpnest_haversine( mylat, mylon, &
511 inlat(ii,jj), inlon(ii,jj) )
512 if( distance < dist )
then 523 is = blk_i - (iinc/2) - 3
525 ie = blk_i + (iinc/2) + 3
526 if( ie > inia ) ie = inia
527 js = blk_j - (jinc/2) - 3
529 je = blk_j + (jinc/2) + 3
530 if( je > inja ) je = inja
533 end subroutine intrpnest_search_nearest_block
538 subroutine intrpnest_search_horiz_1points( &
552 real(RP),
intent(out) :: hfact(:)
553 integer,
intent(out) :: igrd (:)
554 integer,
intent(out) :: jgrd (:)
556 real(RP),
intent(in) :: mylat
557 real(RP),
intent(in) :: mylon
558 real(RP),
intent(in) :: inlat(:,:)
559 real(RP),
intent(in) :: inlon(:,:)
561 integer,
intent(in) :: is
562 integer,
intent(in) :: ie
563 integer,
intent(in) :: js
564 integer,
intent(in) :: je
571 dist = large_number_1
577 distance = intrpnest_haversine( mylat,mylon,inlat(ii,jj),inlon(ii,jj) )
578 if ( distance <= dist )
then 579 dist = distance; igrd(1) = ii; jgrd(1) = jj
587 end subroutine intrpnest_search_horiz_1points
592 subroutine intrpnest_search_horiz_3points( &
608 real(RP),
intent(out) :: hfact(:)
609 integer,
intent(out) :: igrd (:)
610 integer,
intent(out) :: jgrd (:)
612 real(RP),
intent(in) :: mylat
613 real(RP),
intent(in) :: mylon
614 real(RP),
intent(in) :: inlat(:,:)
615 real(RP),
intent(in) :: inlon(:,:)
617 integer,
intent(in) :: is
618 integer,
intent(in) :: ie
619 integer,
intent(in) :: js
620 integer,
intent(in) :: je
628 dist(1) = large_number_3
629 dist(2) = large_number_2
630 dist(3) = large_number_1
636 distance = intrpnest_haversine( mylat,mylon,inlat(ii,jj),inlon(ii,jj) )
637 if ( distance <= dist(1) )
then 638 dist(3) = dist(2); igrd(3) = igrd(2); jgrd(3) = jgrd(2)
639 dist(2) = dist(1); igrd(2) = igrd(1); jgrd(2) = jgrd(1)
640 dist(1) = distance; igrd(1) = ii; jgrd(1) = jj
641 elseif ( dist(1) < distance .AND. distance <= dist(2) )
then 642 dist(3) = dist(2); igrd(3) = igrd(2); jgrd(3) = jgrd(2)
643 dist(2) = distance; igrd(2) = ii; jgrd(2) = jj
644 elseif ( dist(2) < distance .AND. distance <= dist(3) )
then 645 dist(3) = distance; igrd(3) = ii; jgrd(3) = jj
650 if ( abs(dist(1)) < eps )
then 655 denom = 1.0_rp / ( (1.0_rp/dist(1)) + (1.0_rp/dist(2)) + (1.0_rp/dist(3)) )
656 hfact(1) = ( 1.0_rp/dist(1) ) * denom
657 hfact(2) = ( 1.0_rp/dist(2) ) * denom
658 hfact(3) = ( 1.0_rp/dist(3) ) * denom
662 end subroutine intrpnest_search_horiz_3points
667 subroutine intrpnest_search_horiz_4points( &
683 real(RP),
intent(out) :: hfact(:)
684 integer,
intent(out) :: igrd (:)
685 integer,
intent(out) :: jgrd (:)
687 real(RP),
intent(in) :: mylat
688 real(RP),
intent(in) :: mylon
689 real(RP),
intent(in) :: inlat(:,:)
690 real(RP),
intent(in) :: inlon(:,:)
692 integer,
intent(in) :: is
693 integer,
intent(in) :: ie
694 integer,
intent(in) :: js
695 integer,
intent(in) :: je
703 dist(1) = large_number_4
704 dist(2) = large_number_3
705 dist(3) = large_number_2
706 dist(4) = large_number_1
712 distance = intrpnest_haversine( mylat,mylon,inlat(ii,jj),inlon(ii,jj) )
713 if ( distance <= dist(1) )
then 714 dist(4) = dist(3); igrd(4) = igrd(3); jgrd(4) = jgrd(3)
715 dist(3) = dist(2); igrd(3) = igrd(2); jgrd(3) = jgrd(2)
716 dist(2) = dist(1); igrd(2) = igrd(1); jgrd(2) = jgrd(1)
717 dist(1) = distance; igrd(1) = ii; jgrd(1) = jj
718 elseif ( dist(1) < distance .AND. distance <= dist(2) )
then 719 dist(4) = dist(3); igrd(4) = igrd(3); jgrd(4) = jgrd(3)
720 dist(3) = dist(2); igrd(3) = igrd(2); jgrd(3) = jgrd(2)
721 dist(2) = distance; igrd(2) = ii; jgrd(2) = jj
722 elseif ( dist(2) < distance .AND. distance <= dist(3) )
then 723 dist(4) = dist(3); igrd(4) = igrd(3); jgrd(4) = jgrd(3)
724 dist(3) = distance; igrd(3) = ii; jgrd(3) = jj
725 elseif ( dist(3) < distance .AND. distance <= dist(4) )
then 726 dist(4) = distance; igrd(4) = ii; jgrd(4) = jj
731 if ( abs(dist(1)) < eps )
then 737 denom = 1.0_rp / ( (1.0_rp/dist(1)) + (1.0_rp/dist(2)) &
738 + (1.0_rp/dist(3)) + (1.0_rp/dist(4)) )
739 hfact(1) = ( 1.0_rp/dist(1) ) * denom
740 hfact(2) = ( 1.0_rp/dist(2) ) * denom
741 hfact(3) = ( 1.0_rp/dist(3) ) * denom
742 hfact(4) = ( 1.0_rp/dist(4) ) * denom
746 end subroutine intrpnest_search_horiz_4points
751 subroutine intrpnest_search_horiz_8points( &
767 real(RP),
intent(out) :: hfact(:)
768 integer,
intent(out) :: igrd (:)
769 integer,
intent(out) :: jgrd (:)
771 real(RP),
intent(in) :: mylat
772 real(RP),
intent(in) :: mylon
773 real(RP),
intent(in) :: inlat(:,:)
774 real(RP),
intent(in) :: inlon(:,:)
776 integer,
intent(in) :: is
777 integer,
intent(in) :: ie
778 integer,
intent(in) :: js
779 integer,
intent(in) :: je
787 dist(1) = large_number_8
788 dist(2) = large_number_7
789 dist(3) = large_number_6
790 dist(4) = large_number_5
791 dist(5) = large_number_4
792 dist(6) = large_number_3
793 dist(7) = large_number_2
794 dist(8) = large_number_1
800 distance = intrpnest_haversine( mylat,mylon,inlat(ii,jj),inlon(ii,jj) )
801 if ( distance <= dist(1) )
then 802 dist(8) = dist(7); igrd(8) = igrd(7); jgrd(8) = jgrd(7)
803 dist(7) = dist(6); igrd(7) = igrd(6); jgrd(7) = jgrd(6)
804 dist(6) = dist(5); igrd(6) = igrd(5); jgrd(6) = jgrd(5)
805 dist(5) = dist(4); igrd(5) = igrd(4); jgrd(5) = jgrd(4)
806 dist(4) = dist(3); igrd(4) = igrd(3); jgrd(4) = jgrd(3)
807 dist(3) = dist(2); igrd(3) = igrd(2); jgrd(3) = jgrd(2)
808 dist(2) = dist(1); igrd(2) = igrd(1); jgrd(2) = jgrd(1)
809 dist(1) = distance; igrd(1) = ii; jgrd(1) = jj
810 elseif ( dist(1) < distance .AND. distance <= dist(2) )
then 811 dist(8) = dist(7); igrd(8) = igrd(7); jgrd(8) = jgrd(7)
812 dist(7) = dist(6); igrd(7) = igrd(6); jgrd(7) = jgrd(6)
813 dist(6) = dist(5); igrd(6) = igrd(5); jgrd(6) = jgrd(5)
814 dist(5) = dist(4); igrd(5) = igrd(4); jgrd(5) = jgrd(4)
815 dist(4) = dist(3); igrd(4) = igrd(3); jgrd(4) = jgrd(3)
816 dist(3) = dist(2); igrd(3) = igrd(2); jgrd(3) = jgrd(2)
817 dist(2) = distance; igrd(2) = ii; jgrd(2) = jj
818 elseif ( dist(2) < distance .AND. distance <= dist(3) )
then 819 dist(8) = dist(7); igrd(8) = igrd(7); jgrd(8) = jgrd(7)
820 dist(7) = dist(6); igrd(7) = igrd(6); jgrd(7) = jgrd(6)
821 dist(6) = dist(5); igrd(6) = igrd(5); jgrd(6) = jgrd(5)
822 dist(5) = dist(4); igrd(5) = igrd(4); jgrd(5) = jgrd(4)
823 dist(4) = dist(3); igrd(4) = igrd(3); jgrd(4) = jgrd(3)
824 dist(3) = distance; igrd(3) = ii; jgrd(3) = jj
825 elseif ( dist(3) < distance .AND. distance <= dist(4) )
then 826 dist(8) = dist(7); igrd(8) = igrd(7); jgrd(8) = jgrd(7)
827 dist(7) = dist(6); igrd(7) = igrd(6); jgrd(7) = jgrd(6)
828 dist(6) = dist(5); igrd(6) = igrd(5); jgrd(6) = jgrd(5)
829 dist(5) = dist(4); igrd(5) = igrd(4); jgrd(5) = jgrd(4)
830 dist(4) = distance; igrd(4) = ii; jgrd(4) = jj
831 elseif ( dist(4) < distance .AND. distance <= dist(5) )
then 832 dist(8) = dist(7); igrd(8) = igrd(7); jgrd(8) = jgrd(7)
833 dist(7) = dist(6); igrd(7) = igrd(6); jgrd(7) = jgrd(6)
834 dist(6) = dist(5); igrd(6) = igrd(5); jgrd(6) = jgrd(5)
835 dist(5) = distance; igrd(5) = ii; jgrd(5) = jj
836 elseif ( dist(5) < distance .AND. distance <= dist(6) )
then 837 dist(8) = dist(7); igrd(8) = igrd(7); jgrd(8) = jgrd(7)
838 dist(7) = dist(6); igrd(7) = igrd(6); jgrd(7) = jgrd(6)
839 dist(6) = distance; igrd(6) = ii; jgrd(6) = jj
840 elseif ( dist(6) < distance .AND. distance <= dist(7) )
then 841 dist(8) = dist(7); igrd(8) = igrd(7); jgrd(8) = jgrd(7)
842 dist(7) = distance; igrd(7) = ii; jgrd(7) = jj
843 elseif ( dist(7) < distance .AND. distance <= dist(8) )
then 844 dist(8) = distance; igrd(8) = ii; jgrd(8) = jj
849 if ( abs(dist(1)) < eps )
then 853 denom = 1.0_rp / ( (1.0_rp/dist(1)) + (1.0_rp/dist(2)) &
854 + (1.0_rp/dist(3)) + (1.0_rp/dist(4)) &
855 + (1.0_rp/dist(5)) + (1.0_rp/dist(6)) &
856 + (1.0_rp/dist(7)) + (1.0_rp/dist(8)) )
857 hfact(1) = ( 1.0_rp/dist(1) ) * denom
858 hfact(2) = ( 1.0_rp/dist(2) ) * denom
859 hfact(3) = ( 1.0_rp/dist(3) ) * denom
860 hfact(4) = ( 1.0_rp/dist(4) ) * denom
861 hfact(5) = ( 1.0_rp/dist(5) ) * denom
862 hfact(6) = ( 1.0_rp/dist(6) ) * denom
863 hfact(7) = ( 1.0_rp/dist(7) ) * denom
864 hfact(8) = ( 1.0_rp/dist(8) ) * denom
868 end subroutine intrpnest_search_horiz_8points
873 subroutine intrpnest_search_horiz_12points( &
889 real(RP),
intent(out) :: hfact(:)
890 integer,
intent(out) :: igrd (:)
891 integer,
intent(out) :: jgrd (:)
893 real(RP),
intent(in) :: mylat
894 real(RP),
intent(in) :: mylon
895 real(RP),
intent(in) :: inlat(:,:)
896 real(RP),
intent(in) :: inlon(:,:)
898 integer,
intent(in) :: is
899 integer,
intent(in) :: ie
900 integer,
intent(in) :: js
901 integer,
intent(in) :: je
909 dist(1 ) = large_number_12
910 dist(2 ) = large_number_11
911 dist(3 ) = large_number_10
912 dist(4 ) = large_number_9
913 dist(5 ) = large_number_8
914 dist(6 ) = large_number_7
915 dist(7 ) = large_number_6
916 dist(8 ) = large_number_5
917 dist(9 ) = large_number_4
918 dist(10) = large_number_3
919 dist(11) = large_number_2
920 dist(12) = large_number_1
926 distance = intrpnest_haversine( mylat,mylon,inlat(ii,jj),inlon(ii,jj) )
927 if ( distance <= dist(1) )
then 928 dist(12) = dist(11); igrd(12) = igrd(11); jgrd(12) = jgrd(11)
929 dist(11) = dist(10); igrd(11) = igrd(10); jgrd(11) = jgrd(10)
930 dist(10) = dist(9 ); igrd(10) = igrd(9 ); jgrd(10) = jgrd(9 )
931 dist(9 ) = dist(8 ); igrd(9 ) = igrd(8 ); jgrd(9 ) = jgrd(8 )
932 dist(8 ) = dist(7 ); igrd(8 ) = igrd(7 ); jgrd(8 ) = jgrd(7 )
933 dist(7 ) = dist(6 ); igrd(7 ) = igrd(6 ); jgrd(7 ) = jgrd(6 )
934 dist(6 ) = dist(5 ); igrd(6 ) = igrd(5 ); jgrd(6 ) = jgrd(5 )
935 dist(5 ) = dist(4 ); igrd(5 ) = igrd(4 ); jgrd(5 ) = jgrd(4 )
936 dist(4 ) = dist(3 ); igrd(4 ) = igrd(3 ); jgrd(4 ) = jgrd(3 )
937 dist(3 ) = dist(2 ); igrd(3 ) = igrd(2 ); jgrd(3 ) = jgrd(2 )
938 dist(2 ) = dist(1 ); igrd(2 ) = igrd(1 ); jgrd(2 ) = jgrd(1 )
939 dist(1 ) = distance; igrd(1 ) = ii; jgrd(1 ) = jj
940 elseif ( dist(1) < distance .AND. distance <= dist(2) )
then 941 dist(12) = dist(11); igrd(12) = igrd(11); jgrd(12) = jgrd(11)
942 dist(11) = dist(10); igrd(11) = igrd(10); jgrd(11) = jgrd(10)
943 dist(10) = dist(9 ); igrd(10) = igrd(9 ); jgrd(10) = jgrd(9 )
944 dist(9 ) = dist(8 ); igrd(9 ) = igrd(8 ); jgrd(9 ) = jgrd(8 )
945 dist(8 ) = dist(7 ); igrd(8 ) = igrd(7 ); jgrd(8 ) = jgrd(7 )
946 dist(7 ) = dist(6 ); igrd(7 ) = igrd(6 ); jgrd(7 ) = jgrd(6 )
947 dist(6 ) = dist(5 ); igrd(6 ) = igrd(5 ); jgrd(6 ) = jgrd(5 )
948 dist(5 ) = dist(4 ); igrd(5 ) = igrd(4 ); jgrd(5 ) = jgrd(4 )
949 dist(4 ) = dist(3 ); igrd(4 ) = igrd(3 ); jgrd(4 ) = jgrd(3 )
950 dist(3 ) = dist(2 ); igrd(3 ) = igrd(2 ); jgrd(3 ) = jgrd(2 )
951 dist(2 ) = distance; igrd(2 ) = ii; jgrd(2 ) = jj
952 elseif ( dist(2) < distance .AND. distance <= dist(3) )
then 953 dist(12) = dist(11); igrd(12) = igrd(11); jgrd(12) = jgrd(11)
954 dist(11) = dist(10); igrd(11) = igrd(10); jgrd(11) = jgrd(10)
955 dist(10) = dist(9 ); igrd(10) = igrd(9 ); jgrd(10) = jgrd(9 )
956 dist(9 ) = dist(8 ); igrd(9 ) = igrd(8 ); jgrd(9 ) = jgrd(8 )
957 dist(8 ) = dist(7 ); igrd(8 ) = igrd(7 ); jgrd(8 ) = jgrd(7 )
958 dist(7 ) = dist(6 ); igrd(7 ) = igrd(6 ); jgrd(7 ) = jgrd(6 )
959 dist(6 ) = dist(5 ); igrd(6 ) = igrd(5 ); jgrd(6 ) = jgrd(5 )
960 dist(5 ) = dist(4 ); igrd(5 ) = igrd(4 ); jgrd(5 ) = jgrd(4 )
961 dist(4 ) = dist(3 ); igrd(4 ) = igrd(3 ); jgrd(4 ) = jgrd(3 )
962 dist(3 ) = distance; igrd(3 ) = ii; jgrd(3 ) = jj
963 elseif ( dist(3) < distance .AND. distance <= dist(4) )
then 964 dist(12) = dist(11); igrd(12) = igrd(11); jgrd(12) = jgrd(11)
965 dist(11) = dist(10); igrd(11) = igrd(10); jgrd(11) = jgrd(10)
966 dist(10) = dist(9 ); igrd(10) = igrd(9 ); jgrd(10) = jgrd(9 )
967 dist(9 ) = dist(8 ); igrd(9 ) = igrd(8 ); jgrd(9 ) = jgrd(8 )
968 dist(8 ) = dist(7 ); igrd(8 ) = igrd(7 ); jgrd(8 ) = jgrd(7 )
969 dist(7 ) = dist(6 ); igrd(7 ) = igrd(6 ); jgrd(7 ) = jgrd(6 )
970 dist(6 ) = dist(5 ); igrd(6 ) = igrd(5 ); jgrd(6 ) = jgrd(5 )
971 dist(5 ) = dist(4 ); igrd(5 ) = igrd(4 ); jgrd(5 ) = jgrd(4 )
972 dist(4 ) = distance; igrd(4 ) = ii; jgrd(4 ) = jj
973 elseif ( dist(4) < distance .AND. distance <= dist(5) )
then 974 dist(12) = dist(11); igrd(12) = igrd(11); jgrd(12) = jgrd(11)
975 dist(11) = dist(10); igrd(11) = igrd(10); jgrd(11) = jgrd(10)
976 dist(10) = dist(9 ); igrd(10) = igrd(9 ); jgrd(10) = jgrd(9 )
977 dist(9 ) = dist(8 ); igrd(9 ) = igrd(8 ); jgrd(9 ) = jgrd(8 )
978 dist(8 ) = dist(7 ); igrd(8 ) = igrd(7 ); jgrd(8 ) = jgrd(7 )
979 dist(7 ) = dist(6 ); igrd(7 ) = igrd(6 ); jgrd(7 ) = jgrd(6 )
980 dist(6 ) = dist(5 ); igrd(6 ) = igrd(5 ); jgrd(6 ) = jgrd(5 )
981 dist(5 ) = distance; igrd(5 ) = ii; jgrd(5 ) = jj
982 elseif ( dist(5) < distance .AND. distance <= dist(6) )
then 983 dist(12) = dist(11); igrd(12) = igrd(11); jgrd(12) = jgrd(11)
984 dist(11) = dist(10); igrd(11) = igrd(10); jgrd(11) = jgrd(10)
985 dist(10) = dist(9 ); igrd(10) = igrd(9 ); jgrd(10) = jgrd(9 )
986 dist(9 ) = dist(8 ); igrd(9 ) = igrd(8 ); jgrd(9 ) = jgrd(8 )
987 dist(8 ) = dist(7 ); igrd(8 ) = igrd(7 ); jgrd(8 ) = jgrd(7 )
988 dist(7 ) = dist(6 ); igrd(7 ) = igrd(6 ); jgrd(7 ) = jgrd(6 )
989 dist(6 ) = distance; igrd(6 ) = ii; jgrd(6 ) = jj
990 elseif ( dist(6) < distance .AND. distance <= dist(7) )
then 991 dist(12) = dist(11); igrd(12) = igrd(11); jgrd(12) = jgrd(11)
992 dist(11) = dist(10); igrd(11) = igrd(10); jgrd(11) = jgrd(10)
993 dist(10) = dist(9 ); igrd(10) = igrd(9 ); jgrd(10) = jgrd(9 )
994 dist(9 ) = dist(8 ); igrd(9 ) = igrd(8 ); jgrd(9 ) = jgrd(8 )
995 dist(8 ) = dist(7 ); igrd(8 ) = igrd(7 ); jgrd(8 ) = jgrd(7 )
996 dist(7 ) = distance; igrd(7 ) = ii; jgrd(7 ) = jj
997 elseif ( dist(7) < distance .AND. distance <= dist(8) )
then 998 dist(12) = dist(11); igrd(12) = igrd(11); jgrd(12) = jgrd(11)
999 dist(11) = dist(10); igrd(11) = igrd(10); jgrd(11) = jgrd(10)
1000 dist(10) = dist(9 ); igrd(10) = igrd(9 ); jgrd(10) = jgrd(9 )
1001 dist(9 ) = dist(8 ); igrd(9 ) = igrd(8 ); jgrd(9 ) = jgrd(8 )
1002 dist(8 ) = distance; igrd(8 ) = ii; jgrd(8 ) = jj
1003 elseif ( dist(8) < distance .AND. distance <= dist(9) )
then 1004 dist(12) = dist(11); igrd(12) = igrd(11); jgrd(12) = jgrd(11)
1005 dist(11) = dist(10); igrd(11) = igrd(10); jgrd(11) = jgrd(10)
1006 dist(10) = dist(9 ); igrd(10) = igrd(9 ); jgrd(10) = jgrd(9 )
1007 dist(9 ) = distance; igrd(9 ) = ii; jgrd(9 ) = jj
1008 elseif ( dist(9) < distance .AND. distance <= dist(10) )
then 1009 dist(12) = dist(11); igrd(12) = igrd(11); jgrd(12) = jgrd(11)
1010 dist(11) = dist(10); igrd(11) = igrd(10); jgrd(11) = jgrd(10)
1011 dist(10) = distance; igrd(10) = ii; jgrd(10) = jj
1012 elseif ( dist(10) < distance .AND. distance <= dist(11) )
then 1013 dist(12) = dist(11); igrd(12) = igrd(11); jgrd(12) = jgrd(11)
1014 dist(11) = distance; igrd(11) = ii; jgrd(11) = jj
1015 elseif ( dist(11) < distance .AND. distance <= dist(12) )
then 1016 dist(12) = distance; igrd(12) = ii; jgrd(12) = jj
1021 if ( abs(dist(1)) < eps )
then 1025 denom = 1.0_rp / ( (1.0_rp/dist(1 )) + (1.0_rp/dist(2 )) &
1026 + (1.0_rp/dist(3 )) + (1.0_rp/dist(4 )) &
1027 + (1.0_rp/dist(5 )) + (1.0_rp/dist(6 )) &
1028 + (1.0_rp/dist(7 )) + (1.0_rp/dist(8 )) &
1029 + (1.0_rp/dist(9 )) + (1.0_rp/dist(10)) &
1030 + (1.0_rp/dist(11)) + (1.0_rp/dist(12)) )
1031 hfact(1 ) = ( 1.0_rp/dist(1 ) ) * denom
1032 hfact(2 ) = ( 1.0_rp/dist(2 ) ) * denom
1033 hfact(3 ) = ( 1.0_rp/dist(3 ) ) * denom
1034 hfact(4 ) = ( 1.0_rp/dist(4 ) ) * denom
1035 hfact(5 ) = ( 1.0_rp/dist(5 ) ) * denom
1036 hfact(6 ) = ( 1.0_rp/dist(6 ) ) * denom
1037 hfact(7 ) = ( 1.0_rp/dist(7 ) ) * denom
1038 hfact(8 ) = ( 1.0_rp/dist(8 ) ) * denom
1039 hfact(9 ) = ( 1.0_rp/dist(9 ) ) * denom
1040 hfact(10) = ( 1.0_rp/dist(10) ) * denom
1041 hfact(11) = ( 1.0_rp/dist(11) ) * denom
1042 hfact(12) = ( 1.0_rp/dist(12) ) * denom
1046 end subroutine intrpnest_search_horiz_12points
1051 subroutine intrpnest_search_vert_online( &
1069 real(RP),
intent(inout) :: vfact(:,:,:,:,:)
1070 integer,
intent(inout) :: kgrd (:,:,:,:,:)
1071 integer,
intent(out) :: ncopy(:)
1073 integer,
intent(in) :: igrd(:)
1074 integer,
intent(in) :: jgrd(:)
1075 real(RP),
intent(in) :: myhgt(:)
1076 real(RP),
intent(in) :: inhgt(:,:,:)
1077 integer,
intent(in) :: iloc
1078 integer,
intent(in) :: jloc
1079 integer,
intent(in) :: ks
1080 integer,
intent(in) :: ke
1081 integer,
intent(in) :: inKA
1082 logical,
intent(in) :: lndgrd
1086 integer :: ii, jj, idx
1088 integer :: inKS, inKE
1093 write(*,*)
'xxx internal error [interporation: nest/interp]' 1094 write(*,*)
' land grid is not araviable in online' 1106 dist(1) = large_number_2
1107 dist(2) = large_number_1
1110 kgrd(k,iloc,jloc,idx,:) = -1
1114 if( myhgt(k) < inhgt(inks,ii,jj) )
then 1116 ncopy(idx) = ncopy(idx) + 1
1118 kgrd(k,iloc,jloc,idx,:) = inks
1120 vfact(k,iloc,jloc,idx,1) = 1.0_rp
1121 vfact(k,iloc,jloc,idx,2) = 0.0_rp
1126 dist(1) = myhgt(k) - inhgt(kk ,ii,jj)
1127 dist(2) = myhgt(k) - inhgt(kk+1,ii,jj)
1129 if( dist(1) >= 0.0_rp .AND. dist(2) < 0.0_rp )
then 1130 kgrd(k,iloc,jloc,idx,1) = kk
1131 kgrd(k,iloc,jloc,idx,2) = kk+1
1133 vfact(k,iloc,jloc,idx,1) = abs(dist(2)) / ( abs(dist(1)) + abs(dist(2)) )
1134 vfact(k,iloc,jloc,idx,2) = abs(dist(1)) / ( abs(dist(1)) + abs(dist(2)) )
1143 if( .NOT. dflag )
then 1144 write(*,*)
'xxx internal error [INTRPNEST_search_vert_online]' 1145 write(*,*)
'xxx data for interpolation was not found.' 1146 write(*,*)
'xxx iloc=',iloc,
' jloc=',jloc,
' k=',k,
' idx=',idx
1154 end subroutine intrpnest_search_vert_online
1158 subroutine intrpnest_search_vert_offline( &
1178 real(RP),
intent(inout) :: vfact(:,:,:,:,:)
1179 integer,
intent(inout) :: kgrd (:,:,:,:,:)
1180 integer,
intent(out) :: ncopy(:)
1182 integer,
intent(in) :: igrd(:)
1183 integer,
intent(in) :: jgrd(:)
1184 real(RP),
intent(in) :: myhgt(:)
1185 real(RP),
intent(in) :: inhgt(:,:,:)
1186 integer,
intent(in) :: iloc
1187 integer,
intent(in) :: jloc
1188 integer,
intent(in) :: ks
1189 integer,
intent(in) :: ke
1190 integer,
intent(in) :: inKA
1191 logical,
intent(in) :: lndgrd
1197 integer :: k, kk, kks, kke
1202 kks = 1; kke =
lkmax 1213 dist(1) = large_number_2
1214 dist(2) = large_number_1
1215 kgrd(k,iloc,jloc,idx,:) = -1
1218 if( myhgt(k) < inhgt(1,ii,jj) )
then 1219 kgrd(k,iloc,jloc,idx,:) = 1
1220 vfact(k,iloc,jloc,idx,1) = 1.0_rp
1221 vfact(k,iloc,jloc,idx,2) = 0.0_rp
1223 else if( abs(inhgt(inka,ii,jj)-myhgt(k))<eps )
then 1224 kgrd(k,iloc,jloc,idx,:) = inka
1225 vfact(k,iloc,jloc,idx,1) = 1.0_rp
1226 vfact(k,iloc,jloc,idx,2) = 0.0_rp
1228 else if( inhgt(inka,ii,jj) < myhgt(k) )
then 1230 kgrd(k,iloc,jloc,idx,:) = inka
1231 vfact(k,iloc,jloc,idx,1) = 1.0_rp
1232 vfact(k,iloc,jloc,idx,2) = 0.0_rp
1235 write(*,*)
'xxx internal error [INTRPNEST_search_vert_offline]' 1236 write(*,*)
'xxx data level is beyond parent data' 1237 write(*,*)
'in',ii,jj,inka,inhgt(inka,ii,jj),
'my',iloc,jloc,k,myhgt(k)
1243 if( (inhgt(kk,ii,jj)<=myhgt(k)).AND.(myhgt(k)<inhgt(kk+1,ii,jj)) )
then 1244 kgrd(k,iloc,jloc,idx,1) = kk
1245 kgrd(k,iloc,jloc,idx,2) = kk+1
1246 dist(1) = abs( myhgt(k) - inhgt(kk,ii,jj) )
1247 dist(2) = abs( myhgt(k) - inhgt(kk+1,ii,jj) )
1249 if ( abs(dist(1))<eps )
then 1250 vfact(k,iloc,jloc,idx,1) = 1.0_rp
1251 vfact(k,iloc,jloc,idx,2) = 0.0_rp
1253 denom = 1.0_rp / ( (1.0_rp/dist(1)) + (1.0_rp/dist(2)) )
1254 vfact(k,iloc,jloc,idx,1) = ( 1.0_rp/dist(1) ) * denom
1255 vfact(k,iloc,jloc,idx,2) = ( 1.0_rp/dist(2) ) * denom
1262 if( .NOT. dflag )
then 1263 write(*,*)
'xxx internal error [INTRPNEST_search_vert_offline]' 1264 write(*,*)
'xxx data for interpolation was not found.' 1265 write(*,*)
'xxx iloc=',iloc,
' jloc=',jloc,
' k=',k,
' idx=',idx
1273 end subroutine intrpnest_search_vert_offline
1277 subroutine intrpnest_interp_2d_1points( &
1287 real(RP),
intent(out) :: intp(:,:)
1289 real(RP),
intent(in) :: ref (:,:)
1290 real(RP),
intent(in) :: hfact(:,:,:)
1291 integer,
intent(in) :: igrd (:,:,:)
1292 integer,
intent(in) :: jgrd (:,:,:)
1293 integer,
intent(in) :: ia
1294 integer,
intent(in) :: ja
1302 intp(i,j) = ref(igrd(i,j,1),jgrd(i,j,1)) * hfact(i,j,1)
1307 end subroutine intrpnest_interp_2d_1points
1312 subroutine intrpnest_interp_3d_1points( &
1327 real(RP),
intent(out) :: intp(:,:,:)
1329 real(RP),
intent(in) :: ref (:,:,:)
1330 real(RP),
intent(in) :: hfact(:,:,:)
1331 real(RP),
intent(in) :: vfact(:,:,:,:,:)
1332 integer,
intent(in) :: kgrd (:,:,:,:,:)
1333 integer,
intent(in) :: igrd (:,:,:)
1334 integer,
intent(in) :: jgrd (:,:,:)
1335 integer,
intent(in) :: ia
1336 integer,
intent(in) :: ja
1337 integer,
intent(in) :: ks
1338 integer,
intent(in) :: ke
1340 logical,
intent(in),
optional :: logwegt
1343 logical :: logarithmic
1346 logarithmic = .false.
1347 if (
present(logwegt) )
then 1349 logarithmic = .true.
1358 intp(k,i,j) = ref(kgrd(k,i,j,1,1),igrd(i,j,1),jgrd(i,j,1)) &
1359 * hfact(i,j,1) * vfact(k,i,j,1,1) &
1360 + ref(kgrd(k,i,j,1,2),igrd(i,j,1),jgrd(i,j,1)) &
1361 * hfact(i,j,1) * vfact(k,i,j,1,2)
1367 if ( logarithmic )
then 1371 intp(k,i,j) = exp( intp(k,i,j) )
1378 end subroutine intrpnest_interp_3d_1points
1383 subroutine intrpnest_interp_2d_3points( &
1393 real(RP),
intent(out) :: intp(:,:)
1395 real(RP),
intent(in) :: ref (:,:)
1396 real(RP),
intent(in) :: hfact(:,:,:)
1397 integer,
intent(in) :: igrd (:,:,:)
1398 integer,
intent(in) :: jgrd (:,:,:)
1399 integer,
intent(in) :: ia
1400 integer,
intent(in) :: ja
1408 intp(i,j) = ref(igrd(i,j,1),jgrd(i,j,1)) * hfact(i,j,1) &
1409 + ref(igrd(i,j,2),jgrd(i,j,2)) * hfact(i,j,2) &
1410 + ref(igrd(i,j,3),jgrd(i,j,3)) * hfact(i,j,3)
1415 end subroutine intrpnest_interp_2d_3points
1420 subroutine intrpnest_interp_3d_3points( &
1435 real(RP),
intent(out) :: intp(:,:,:)
1437 real(RP),
intent(in) :: ref (:,:,:)
1438 real(RP),
intent(in) :: hfact(:,:,:)
1439 real(RP),
intent(in) :: vfact(:,:,:,:,:)
1440 integer,
intent(in) :: kgrd (:,:,:,:,:)
1441 integer,
intent(in) :: igrd (:,:,:)
1442 integer,
intent(in) :: jgrd (:,:,:)
1443 integer,
intent(in) :: ia
1444 integer,
intent(in) :: ja
1445 integer,
intent(in) :: ks
1446 integer,
intent(in) :: ke
1448 logical,
intent(in),
optional :: logwegt
1451 logical :: logarithmic
1454 logarithmic = .false.
1455 if (
present(logwegt) )
then 1457 logarithmic = .true.
1466 intp(k,i,j) = ref(kgrd(k,i,j,1,1),igrd(i,j,1),jgrd(i,j,1)) &
1467 * hfact(i,j,1) * vfact(k,i,j,1,1) &
1468 + ref(kgrd(k,i,j,2,1),igrd(i,j,2),jgrd(i,j,2)) &
1469 * hfact(i,j,2) * vfact(k,i,j,2,1) &
1470 + ref(kgrd(k,i,j,3,1),igrd(i,j,3),jgrd(i,j,3)) &
1471 * hfact(i,j,3) * vfact(k,i,j,3,1) &
1472 + ref(kgrd(k,i,j,1,2),igrd(i,j,1),jgrd(i,j,1)) &
1473 * hfact(i,j,1) * vfact(k,i,j,1,2) &
1474 + ref(kgrd(k,i,j,2,2),igrd(i,j,2),jgrd(i,j,2)) &
1475 * hfact(i,j,2) * vfact(k,i,j,2,2) &
1476 + ref(kgrd(k,i,j,3,2),igrd(i,j,3),jgrd(i,j,3)) &
1477 * hfact(i,j,3) * vfact(k,i,j,3,2)
1483 if ( logarithmic )
then 1487 intp(k,i,j) = exp( intp(k,i,j) )
1494 end subroutine intrpnest_interp_3d_3points
1499 subroutine intrpnest_interp_2d_4points( &
1509 real(RP),
intent(out) :: intp(:,:)
1511 real(RP),
intent(in) :: ref (:,:)
1512 real(RP),
intent(in) :: hfact(:,:,:)
1513 integer,
intent(in) :: igrd (:,:,:)
1514 integer,
intent(in) :: jgrd (:,:,:)
1515 integer,
intent(in) :: ia
1516 integer,
intent(in) :: ja
1524 intp(i,j) = ref(igrd(i,j,1),jgrd(i,j,1)) * hfact(i,j,1) &
1525 + ref(igrd(i,j,2),jgrd(i,j,2)) * hfact(i,j,2) &
1526 + ref(igrd(i,j,3),jgrd(i,j,3)) * hfact(i,j,3) &
1527 + ref(igrd(i,j,4),jgrd(i,j,4)) * hfact(i,j,4)
1532 end subroutine intrpnest_interp_2d_4points
1537 subroutine intrpnest_interp_3d_4points( &
1552 real(RP),
intent(out) :: intp(:,:,:)
1554 real(RP),
intent(in) :: ref (:,:,:)
1555 real(RP),
intent(in) :: hfact(:,:,:)
1556 real(RP),
intent(in) :: vfact(:,:,:,:,:)
1557 integer,
intent(in) :: kgrd (:,:,:,:,:)
1558 integer,
intent(in) :: igrd (:,:,:)
1559 integer,
intent(in) :: jgrd (:,:,:)
1560 integer,
intent(in) :: ia
1561 integer,
intent(in) :: ja
1562 integer,
intent(in) :: ks
1563 integer,
intent(in) :: ke
1565 logical,
intent(in),
optional :: logwegt
1568 logical :: logarithmic
1571 logarithmic = .false.
1572 if (
present(logwegt) )
then 1574 logarithmic = .true.
1583 intp(k,i,j) = ref(kgrd(k,i,j,1,1),igrd(i,j,1),jgrd(i,j,1)) &
1584 * hfact(i,j,1) * vfact(k,i,j,1,1) &
1585 + ref(kgrd(k,i,j,2,1),igrd(i,j,2),jgrd(i,j,2)) &
1586 * hfact(i,j,2) * vfact(k,i,j,2,1) &
1587 + ref(kgrd(k,i,j,3,1),igrd(i,j,3),jgrd(i,j,3)) &
1588 * hfact(i,j,3) * vfact(k,i,j,3,1) &
1589 + ref(kgrd(k,i,j,4,1),igrd(i,j,4),jgrd(i,j,4)) &
1590 * hfact(i,j,4) * vfact(k,i,j,4,1) &
1591 + ref(kgrd(k,i,j,1,2),igrd(i,j,1),jgrd(i,j,1)) &
1592 * hfact(i,j,1) * vfact(k,i,j,1,2) &
1593 + ref(kgrd(k,i,j,2,2),igrd(i,j,2),jgrd(i,j,2)) &
1594 * hfact(i,j,2) * vfact(k,i,j,2,2) &
1595 + ref(kgrd(k,i,j,3,2),igrd(i,j,3),jgrd(i,j,3)) &
1596 * hfact(i,j,3) * vfact(k,i,j,3,2) &
1597 + ref(kgrd(k,i,j,4,2),igrd(i,j,4),jgrd(i,j,4)) &
1598 * hfact(i,j,4) * vfact(k,i,j,4,2)
1604 if ( logarithmic )
then 1608 intp(k,i,j) = exp( intp(k,i,j) )
1615 end subroutine intrpnest_interp_3d_4points
1620 subroutine intrpnest_interp_2d_8points( &
1630 real(RP),
intent(out) :: intp(:,:)
1632 real(RP),
intent(in) :: ref (:,:)
1633 real(RP),
intent(in) :: hfact(:,:,:)
1634 integer,
intent(in) :: igrd (:,:,:)
1635 integer,
intent(in) :: jgrd (:,:,:)
1636 integer,
intent(in) :: ia
1637 integer,
intent(in) :: ja
1645 intp(i,j) = ref(igrd(i,j,1),jgrd(i,j,1)) * hfact(i,j,1) &
1646 + ref(igrd(i,j,2),jgrd(i,j,2)) * hfact(i,j,2) &
1647 + ref(igrd(i,j,3),jgrd(i,j,3)) * hfact(i,j,3) &
1648 + ref(igrd(i,j,4),jgrd(i,j,4)) * hfact(i,j,4) &
1649 + ref(igrd(i,j,5),jgrd(i,j,5)) * hfact(i,j,5) &
1650 + ref(igrd(i,j,6),jgrd(i,j,6)) * hfact(i,j,6) &
1651 + ref(igrd(i,j,7),jgrd(i,j,7)) * hfact(i,j,7) &
1652 + ref(igrd(i,j,8),jgrd(i,j,8)) * hfact(i,j,8)
1657 end subroutine intrpnest_interp_2d_8points
1662 subroutine intrpnest_interp_3d_8points( &
1677 real(RP),
intent(out) :: intp(:,:,:)
1679 real(RP),
intent(in) :: ref (:,:,:)
1680 real(RP),
intent(in) :: hfact(:,:,:)
1681 real(RP),
intent(in) :: vfact(:,:,:,:,:)
1682 integer,
intent(in) :: kgrd (:,:,:,:,:)
1683 integer,
intent(in) :: igrd (:,:,:)
1684 integer,
intent(in) :: jgrd (:,:,:)
1685 integer,
intent(in) :: ia
1686 integer,
intent(in) :: ja
1687 integer,
intent(in) :: ks
1688 integer,
intent(in) :: ke
1690 logical,
intent(in),
optional :: logwegt
1693 logical :: logarithmic
1696 logarithmic = .false.
1697 if (
present(logwegt) )
then 1699 logarithmic = .true.
1708 intp(k,i,j) = ref(kgrd(k,i,j,1,1),igrd(i,j,1),jgrd(i,j,1)) &
1709 * hfact(i,j,1) * vfact(k,i,j,1,1) &
1710 + ref(kgrd(k,i,j,2,1),igrd(i,j,2),jgrd(i,j,2)) &
1711 * hfact(i,j,2) * vfact(k,i,j,2,1) &
1712 + ref(kgrd(k,i,j,3,1),igrd(i,j,3),jgrd(i,j,3)) &
1713 * hfact(i,j,3) * vfact(k,i,j,3,1) &
1714 + ref(kgrd(k,i,j,4,1),igrd(i,j,4),jgrd(i,j,4)) &
1715 * hfact(i,j,4) * vfact(k,i,j,4,1) &
1716 + ref(kgrd(k,i,j,5,1),igrd(i,j,5),jgrd(i,j,5)) &
1717 * hfact(i,j,5) * vfact(k,i,j,5,1) &
1718 + ref(kgrd(k,i,j,6,1),igrd(i,j,6),jgrd(i,j,6)) &
1719 * hfact(i,j,6) * vfact(k,i,j,6,1) &
1720 + ref(kgrd(k,i,j,7,1),igrd(i,j,7),jgrd(i,j,7)) &
1721 * hfact(i,j,7) * vfact(k,i,j,7,1) &
1722 + ref(kgrd(k,i,j,8,1),igrd(i,j,8),jgrd(i,j,8)) &
1723 * hfact(i,j,8) * vfact(k,i,j,8,1) &
1724 + ref(kgrd(k,i,j,1,2),igrd(i,j,1),jgrd(i,j,1)) &
1725 * hfact(i,j,1) * vfact(k,i,j,1,2) &
1726 + ref(kgrd(k,i,j,2,2),igrd(i,j,2),jgrd(i,j,2)) &
1727 * hfact(i,j,2) * vfact(k,i,j,2,2) &
1728 + ref(kgrd(k,i,j,3,2),igrd(i,j,3),jgrd(i,j,3)) &
1729 * hfact(i,j,3) * vfact(k,i,j,3,2) &
1730 + ref(kgrd(k,i,j,4,2),igrd(i,j,3),jgrd(i,j,3)) &
1731 * hfact(i,j,4) * vfact(k,i,j,4,2) &
1732 + ref(kgrd(k,i,j,5,2),igrd(i,j,3),jgrd(i,j,3)) &
1733 * hfact(i,j,5) * vfact(k,i,j,5,2) &
1734 + ref(kgrd(k,i,j,6,2),igrd(i,j,3),jgrd(i,j,3)) &
1735 * hfact(i,j,6) * vfact(k,i,j,6,2) &
1736 + ref(kgrd(k,i,j,7,2),igrd(i,j,3),jgrd(i,j,3)) &
1737 * hfact(i,j,7) * vfact(k,i,j,7,2) &
1738 + ref(kgrd(k,i,j,8,2),igrd(i,j,8),jgrd(i,j,8)) &
1739 * hfact(i,j,8) * vfact(k,i,j,8,2)
1745 if ( logarithmic )
then 1749 intp(k,i,j) = exp( intp(k,i,j) )
1756 end subroutine intrpnest_interp_3d_8points
1761 subroutine intrpnest_interp_2d_12points( &
1771 real(RP),
intent(out) :: intp(:,:)
1773 real(RP),
intent(in) :: ref (:,:)
1774 real(RP),
intent(in) :: hfact(:,:,:)
1775 integer,
intent(in) :: igrd (:,:,:)
1776 integer,
intent(in) :: jgrd (:,:,:)
1777 integer,
intent(in) :: ia
1778 integer,
intent(in) :: ja
1786 intp(i,j) = ref(igrd(i,j,1), jgrd(i,j,1)) * hfact(i,j,1) &
1787 + ref(igrd(i,j,2), jgrd(i,j,2)) * hfact(i,j,2) &
1788 + ref(igrd(i,j,3), jgrd(i,j,3)) * hfact(i,j,3) &
1789 + ref(igrd(i,j,4), jgrd(i,j,4)) * hfact(i,j,4) &
1790 + ref(igrd(i,j,5), jgrd(i,j,5)) * hfact(i,j,5) &
1791 + ref(igrd(i,j,6), jgrd(i,j,6)) * hfact(i,j,6) &
1792 + ref(igrd(i,j,7), jgrd(i,j,7)) * hfact(i,j,7) &
1793 + ref(igrd(i,j,8), jgrd(i,j,8)) * hfact(i,j,8) &
1794 + ref(igrd(i,j,9), jgrd(i,j,9)) * hfact(i,j,9) &
1795 + ref(igrd(i,j,10),jgrd(i,j,10)) * hfact(i,j,10) &
1796 + ref(igrd(i,j,11),jgrd(i,j,11)) * hfact(i,j,11) &
1797 + ref(igrd(i,j,12),jgrd(i,j,12)) * hfact(i,j,12)
1802 end subroutine intrpnest_interp_2d_12points
1807 subroutine intrpnest_interp_3d_12points( &
1822 real(RP),
intent(out) :: intp(:,:,:)
1824 real(RP),
intent(in) :: ref (:,:,:)
1825 real(RP),
intent(in) :: hfact(:,:,:)
1826 real(RP),
intent(in) :: vfact(:,:,:,:,:)
1827 integer,
intent(in) :: kgrd (:,:,:,:,:)
1828 integer,
intent(in) :: igrd (:,:,:)
1829 integer,
intent(in) :: jgrd (:,:,:)
1830 integer,
intent(in) :: ia
1831 integer,
intent(in) :: ja
1832 integer,
intent(in) :: ks
1833 integer,
intent(in) :: ke
1835 logical,
intent(in),
optional :: logwegt
1838 logical :: logarithmic
1841 logarithmic = .false.
1842 if (
present(logwegt) )
then 1844 logarithmic = .true.
1853 intp(k,i,j) = ref(kgrd(k,i,j,1, 1),igrd(i,j,1 ),jgrd(i,j,1 )) &
1854 * hfact(i,j,1 ) * vfact(k,i,j,1, 1) &
1855 + ref(kgrd(k,i,j,2, 1),igrd(i,j,2 ),jgrd(i,j,2 )) &
1856 * hfact(i,j,2 ) * vfact(k,i,j,2, 1) &
1857 + ref(kgrd(k,i,j,3, 1),igrd(i,j,3 ),jgrd(i,j,3 )) &
1858 * hfact(i,j,3 ) * vfact(k,i,j,3, 1) &
1859 + ref(kgrd(k,i,j,4, 1),igrd(i,j,4 ),jgrd(i,j,4 )) &
1860 * hfact(i,j,4 ) * vfact(k,i,j,4, 1) &
1861 + ref(kgrd(k,i,j,5, 1),igrd(i,j,5 ),jgrd(i,j,5 )) &
1862 * hfact(i,j,5 ) * vfact(k,i,j,5, 1) &
1863 + ref(kgrd(k,i,j,6, 1),igrd(i,j,6 ),jgrd(i,j,6 )) &
1864 * hfact(i,j,6 ) * vfact(k,i,j,6, 1) &
1865 + ref(kgrd(k,i,j,7, 1),igrd(i,j,7 ),jgrd(i,j,7 )) &
1866 * hfact(i,j,7 ) * vfact(k,i,j,7, 1) &
1867 + ref(kgrd(k,i,j,8, 1),igrd(i,j,8 ),jgrd(i,j,8 )) &
1868 * hfact(i,j,8 ) * vfact(k,i,j,8, 1) &
1869 + ref(kgrd(k,i,j,9, 1),igrd(i,j,9 ),jgrd(i,j,9 )) &
1870 * hfact(i,j,9 ) * vfact(k,i,j,9, 1) &
1871 + ref(kgrd(k,i,j,10,1),igrd(i,j,10),jgrd(i,j,10)) &
1872 * hfact(i,j,10) * vfact(k,i,j,10,1) &
1873 + ref(kgrd(k,i,j,11,1),igrd(i,j,11),jgrd(i,j,11)) &
1874 * hfact(i,j,11) * vfact(k,i,j,11,1) &
1875 + ref(kgrd(k,i,j,12,1),igrd(i,j,12),jgrd(i,j,12)) &
1876 * hfact(i,j,12) * vfact(k,i,j,12,1) &
1877 + ref(kgrd(k,i,j,1, 2),igrd(i,j,1 ),jgrd(i,j,1 )) &
1878 * hfact(i,j,1 ) * vfact(k,i,j,1, 2) &
1879 + ref(kgrd(k,i,j,2, 2),igrd(i,j,2 ),jgrd(i,j,2 )) &
1880 * hfact(i,j,2 ) * vfact(k,i,j,2, 2) &
1881 + ref(kgrd(k,i,j,3, 2),igrd(i,j,3 ),jgrd(i,j,3 )) &
1882 * hfact(i,j,3 ) * vfact(k,i,j,3, 2) &
1883 + ref(kgrd(k,i,j,4, 2),igrd(i,j,4 ),jgrd(i,j,4 )) &
1884 * hfact(i,j,4 ) * vfact(k,i,j,4, 2) &
1885 + ref(kgrd(k,i,j,5, 2),igrd(i,j,5 ),jgrd(i,j,5 )) &
1886 * hfact(i,j,5 ) * vfact(k,i,j,5, 2) &
1887 + ref(kgrd(k,i,j,6, 2),igrd(i,j,6 ),jgrd(i,j,6 )) &
1888 * hfact(i,j,6 ) * vfact(k,i,j,6, 2) &
1889 + ref(kgrd(k,i,j,7, 2),igrd(i,j,7 ),jgrd(i,j,7 )) &
1890 * hfact(i,j,7 ) * vfact(k,i,j,7, 2) &
1891 + ref(kgrd(k,i,j,8, 2),igrd(i,j,8 ),jgrd(i,j,8 )) &
1892 * hfact(i,j,8 ) * vfact(k,i,j,8, 2) &
1893 + ref(kgrd(k,i,j,9, 2),igrd(i,j,9 ),jgrd(i,j,9 )) &
1894 * hfact(i,j,9 ) * vfact(k,i,j,9, 2) &
1895 + ref(kgrd(k,i,j,10,2),igrd(i,j,10),jgrd(i,j,10)) &
1896 * hfact(i,j,10) * vfact(k,i,j,10,2) &
1897 + ref(kgrd(k,i,j,11,2),igrd(i,j,11),jgrd(i,j,11)) &
1898 * hfact(i,j,11) * vfact(k,i,j,11,2) &
1899 + ref(kgrd(k,i,j,12,2),igrd(i,j,12),jgrd(i,j,12)) &
1900 * hfact(i,j,12) * vfact(k,i,j,12,2)
1906 if ( logarithmic )
then 1910 intp(k,i,j) = exp( intp(k,i,j) )
1917 end subroutine intrpnest_interp_3d_12points
1936 real(RP),
intent(in) :: lon_org(:,:)
1937 real(RP),
intent(in) :: lat_org(:,:)
1938 real(RP),
intent(in) :: lev_org(:,:,:)
1939 real(RP),
intent(in) :: lon_loc(:,:)
1940 real(RP),
intent(in) :: lat_loc(:,:)
1941 real(RP),
intent(in) :: lev_loc(:,:,:)
1942 logical,
intent(in),
optional :: skip_x
1943 logical,
intent(in),
optional :: skip_y
1944 logical,
intent(in),
optional :: skip_z
1946 real(RP) :: max_ref, min_ref
1947 real(RP) :: max_loc, min_loc
1949 logical :: do_xdirec
1950 logical :: do_ydirec
1951 logical :: do_zdirec
1957 if (
present(skip_x) )
then 1964 if (
present(skip_y) )
then 1971 if (
present(skip_z) )
then 1977 if ( do_xdirec )
then 1978 max_ref = maxval( lon_org(:,:) / d2r )
1979 min_ref = minval( lon_org(:,:) / d2r )
1980 max_loc = maxval( lon_loc(:,:) / d2r )
1981 min_loc = minval( lon_loc(:,:) / d2r )
1983 if ( (min_ref+360.0_rp-max_ref) < 360.0_rp /
size(lon_org,1) * 2.0_rp)
then 1985 else if ( max_ref < max_loc .OR. min_ref > min_loc )
then 1986 write(*,*)
'xxx ERROR: REQUESTED DOMAIN IS TOO MUCH BROAD' 1987 write(*,*)
'xxx -- LONGITUDINAL direction over the limit' 1988 write(*,*)
'xxx -- reference max: ', max_ref
1989 write(*,*)
'xxx -- reference min: ', min_ref
1990 write(*,*)
'xxx -- local max: ', max_loc
1991 write(*,*)
'xxx -- local min: ', min_loc
1996 if ( do_ydirec )
then 1997 max_ref = maxval( lat_org(:,:) / d2r )
1998 min_ref = minval( lat_org(:,:) / d2r )
1999 max_loc = maxval( lat_loc(:,:) / d2r )
2000 min_loc = minval( lat_loc(:,:) / d2r )
2002 if ( max_ref < max_loc .OR. min_ref > min_loc )
then 2003 write(*,*)
'xxx ERROR: REQUESTED DOMAIN IS TOO MUCH BROAD' 2004 write(*,*)
'xxx -- LATITUDINAL direction over the limit' 2005 write(*,*)
'xxx -- reference max: ', max_ref
2006 write(*,*)
'xxx -- reference min: ', min_ref
2007 write(*,*)
'xxx -- local max: ', max_loc
2008 write(*,*)
'xxx -- local min: ', min_loc
2013 if ( do_zdirec )
then 2014 max_ref = maxval( lev_org(:,:,:) )
2016 max_loc = maxval( lev_loc(:,:,:) )
2020 if ( max_ref < max_loc )
then 2022 write(*,*)
'xxx ERROR: REQUESTED DOMAIN IS TOO MUCH BROAD' 2023 write(*,*)
'xxx -- VERTICAL direction over the limit' 2024 write(*,*)
'xxx -- reference max: ', max_ref
2026 write(*,*)
'xxx -- local max: ', max_loc
2038 function intrpnest_haversine( &
2045 real(RP),
intent(in) :: la0, lo0, la, lo
2046 real(RP) :: d, dlon, dlat, work1, work2
2052 work1 = (sin(dlat/2.0_rp))**2.0_rp + &
2053 cos(la0) * cos(la) * (sin(dlon/2.0_rp))**2.0_rp
2054 work2 = 2.0_rp * asin(min( 1.0_rp, sqrt(work1) ))
2057 end function intrpnest_haversine
integer, public is
start point of inner domain: x, local
subroutine, public intrpnest_domain_compatibility(lon_org, lat_org, lev_org, lon_loc, lat_loc, lev_loc, skip_x, skip_y, skip_z)
integer, public je
end point of inner domain: y, local
subroutine, public prc_mpistop
Abort MPI.
logical, public io_l
output log or not? (this process)
real(rp), public const_radius
radius of the planet [m]
integer, public ke
end point of inner domain: z, local
real(rp), public const_d2r
degree to radian
procedure(intrpnest_intfc_interp_2d), pointer, public intrpnest_interp_2d
subroutine, public intrpnest_interp_fact_latlon(hfact, igrd, jgrd, mylat, mylon, myIA, myJA, inlat, inlon, inIA, inJA)
subroutine, public intrpnest_interp_fact_llz(hfact, vfact, kgrd, igrd, jgrd, ncopy, myhgt, mylat, mylon, myKS, myKE, myIA, myJA, inhgt, inlat, inlon, inKA, inIA, inJA, landgrid)
integer, public ia
of x whole cells (local, with HALO)
integer, public js
start point of inner domain: y, local
procedure(intrpnest_intfc_interp_3d), pointer, public intrpnest_interp_3d
integer, public ks
start point of inner domain: z, local
integer, parameter, public khalo
of halo cells: z
module INTERPOLATION (nesting system)
integer, public ie
end point of inner domain: x, local
real(rp), public const_eps
small number
integer, public io_fid_log
Log file ID.
subroutine, public intrpnest_setup(interp_search_divnum, NEST_INTERP_LEVEL, OFFLINE)
Setup.
integer, public ja
of y whole cells (local, with HALO)