Changeset 10087 for vendors/AGRIF/CMEMS_2020/AGRIF_FILES/modinterp.F90
- Timestamp:
- 2018-09-05T15:33:44+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendors/AGRIF/CMEMS_2020/AGRIF_FILES/modinterp.F90
r7752 r10087 26 26 module Agrif_Interpolation 27 27 ! 28 use Agrif_InterpBasic 29 use Agrif_Arrays 30 use Agrif_Mask 31 use Agrif_CurgridFunctions 28 use Agrif_Init 29 use Agrif_Arrays 30 use Agrif_InterpBasic 31 use Agrif_User_Functions 32 32 33 #if defined AGRIF_MPI 33 34 use Agrif_Mpp 34 35 #endif 36 37 use Agrif_Mask 35 38 ! 36 39 implicit none … … 66 69 integer, dimension(6) :: ub_child 67 70 integer, dimension(6) :: lb_parent 68 real , dimension(6) :: s_child, s_parent69 real , dimension(6) :: ds_child, ds_parent71 real(kind=8) , dimension(6) :: s_child, s_parent 72 real(kind=8) , dimension(6) :: ds_child, ds_parent 70 73 integer, dimension(child % root_var % nbdim,2,2) :: childarray 71 74 ! … … 115 118 INTEGER, DIMENSION(nbdim), INTENT(in) :: pttab_Parent !< Index of the first point inside the domain 116 119 !< for the parent grid variable 117 REAL , DIMENSION(nbdim), INTENT(in) :: s_Child,s_Parent !< Positions of the parent and child grids118 REAL , DIMENSION(nbdim), INTENT(in) :: ds_Child,ds_Parent !< Space steps of the parent and child grids120 REAL(kind=8), DIMENSION(nbdim), INTENT(in) :: s_Child,s_Parent !< Positions of the parent and child grids 121 REAL(kind=8), DIMENSION(nbdim), INTENT(in) :: ds_Child,ds_Parent !< Space steps of the parent and child grids 119 122 TYPE(Agrif_Variable), pointer :: restore !< Indicates points where interpolation 120 123 LOGICAL, INTENT(in) :: torestore !< Indicates if the array restore is used … … 128 131 INTEGER :: i,j,k,l,m,n 129 132 INTEGER, DIMENSION(nbdim) :: pttruetab,cetruetab 130 INTEGER, DIMENSION(nbdim) :: indmin, indmax 133 INTEGER, DIMENSION(nbdim) :: indmin, indmax, indmin_required_p, indmax_required_p 131 134 INTEGER, DIMENSION(nbdim) :: indminglob, indmaxglob 132 135 #if defined AGRIF_MPI 133 136 INTEGER, DIMENSION(nbdim) :: indminglob2,indmaxglob2 137 INTEGER, DIMENSION(nbdim) :: indminglob3,indmaxglob3 134 138 #endif 135 139 LOGICAL, DIMENSION(nbdim) :: noraftab 136 REAL , DIMENSION(nbdim) :: s_Child_temp,s_Parent_temp140 REAL(kind=8) , DIMENSION(nbdim) :: s_Child_temp,s_Parent_temp,s_Parent_temp_p 137 141 INTEGER, DIMENSION(nbdim) :: lowerbound, upperbound, coords 138 142 INTEGER, DIMENSION(nbdim,2,2), INTENT(OUT) :: childarray … … 148 152 INTEGER, DIMENSION(nbdim,4,0:Agrif_Nbprocs-1) :: tab4 149 153 INTEGER, DIMENSION(nbdim,0:Agrif_Nbprocs-1,8) :: tab4t 154 INTEGER,DIMENSION(nbdim,2) :: tab5 155 INTEGER,DIMENSION(nbdim,2,0:Agrif_Nbprocs-1) :: tab6 156 INTEGER,DIMENSION(nbdim,0:Agrif_Nbprocs-1,2) :: tab5t 150 157 LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: memberinall 151 158 LOGICAL, DIMENSION(0:Agrif_Nbprocs-1) :: sendtoproc1, recvfromproc1 … … 167 174 child % list_interp, & 168 175 pttab, petab, pttab_Child, pttab_Parent, nbdim, & 169 indmin, indmax, indminglob, indmaxglob, & 176 indmin, indmax, indmin_required_p, indmax_required_p, & 177 indminglob, indmaxglob, & 170 178 pttruetab, cetruetab, memberin & 171 179 #if defined AGRIF_MPI … … 174 182 #endif 175 183 ) 184 176 185 ! 177 186 if (.not.find_list_interp) then 178 187 ! 188 ! output : lowerbound and upperbound are the (local) lower and upper bounds of the child arrays 189 179 190 call Agrif_get_var_bounds_array(child, lowerbound, upperbound, nbdim) 191 192 ! input : pttab, petab : global indexes where the interpolation is required 193 ! output : pttruetab, cetruetab : global indexes restricted to the bounds of the current processor 194 ! output : memberin is false if the current processor is not involved in the interpolation 195 180 196 call Agrif_Childbounds(nbdim, lowerbound, upperbound, & 181 197 pttab, petab, Agrif_Procrank, coords, & 182 198 pttruetab, cetruetab, memberin) 199 200 201 202 ! output : indminglob, indmaxglob : global indexes required on the parent grid for the interpolation 203 ! output : s_Parent_temp, s_Child_temp : local s_Parent, s_Child relatively to indmin ou pttab 183 204 call Agrif_Parentbounds(type_interp,nbdim,indminglob,indmaxglob, & 205 indmin_required_p, indmax_required_p, & 184 206 s_Parent_temp,s_Child_temp, & 185 207 s_Child,ds_Child, & … … 190 212 #if defined AGRIF_MPI 191 213 if (memberin) then 214 215 ! output : indmin, indmax : global indexes required on the parent grid for the interpolation on the current processor (i.e. on pttruetab, cetruetab) 216 ! output : s_Parent_temp, s_Child_temp : local s_Parent, s_Child relatively to indmin ou pttruetab 192 217 call Agrif_Parentbounds(type_interp,nbdim,indmin,indmax, & 218 indmin_required_p, indmax_required_p, & 193 219 s_Parent_temp,s_Child_temp, & 194 220 s_Child,ds_Child, & … … 200 226 201 227 local_proc = Agrif_Procrank 228 229 ! output : lowerbound and upperbound are the (local) lower and upper bounds of the parent arrays 202 230 call Agrif_get_var_bounds_array(parent,lowerbound,upperbound,nbdim) 203 231 call Agrif_ChildGrid_to_ParentGrid() 204 ! 232 233 ! input : indminglob,indmaxglob : global indexes where data are required for the interpolation 234 ! output : indminglob2,indmaxglob2 : global indexes restricted to the bounds of the current processor 235 ! output : member is false if the current processor does not need to send data 236 ! output : indminglob3,indmaxglob3 : global bounds on the current processor for the parent array 237 205 238 call Agrif_Childbounds(nbdim,lowerbound,upperbound, & 206 239 indminglob,indmaxglob, local_proc, coords, & 207 indminglob2,indmaxglob2,member) 240 indminglob2,indmaxglob2,member, & 241 indminglob3,indmaxglob3) 208 242 ! 209 243 if (member) then 244 245 ! output : parentarray 246 ! output : parentarray (:,:,2) : indminglob2, indmaxglob2 in term of local indexes on current processor 247 ! output : parentarray (:,:,1) : indminglob2, indmaxglob2 restricted to the current processor (different from indminglob2 ???) 248 ! output : member is .false. is the current processor has not data to send 249 210 250 call Agrif_GlobalToLocalBounds(parentarray, & 211 251 lowerbound, upperbound, & … … 216 256 call Agrif_ParentGrid_to_ChildGrid() 217 257 #else 258 259 ! In the sequentiel case, the following lines ensure that the bounds needed on the parent grid in the interpolation 260 ! do not exceed lower and upper bounds of the parent array 261 262 ! output : lowerbound and upperbound are the (local) lower and upper bounds of the parent arrays 263 call Agrif_get_var_bounds_array(parent,lowerbound,upperbound,nbdim) 264 call Agrif_ChildGrid_to_ParentGrid() 265 266 ! input : indminglob,indmaxglob : global indexes where data are required for the interpolation 267 ! output : indminglob2,indmaxglob2 : global indexes restricted to the bounds of the current processor 268 ! output : member is false if the current processor does not need to send data 269 270 call Agrif_Childbounds(nbdim,lowerbound,upperbound, & 271 indminglob,indmaxglob, Agrif_Procrank, coords, & 272 indmin,indmax,member) 273 274 call Agrif_ParentGrid_to_ChildGrid() 275 276 indminglob = indmin 277 indmaxglob = indmax 278 218 279 parentarray(:,1,1) = indminglob 219 280 parentarray(:,2,1) = indmaxglob 220 281 parentarray(:,1,2) = indminglob 221 282 parentarray(:,2,2) = indmaxglob 222 indmin = indminglob 223 indmax = indmaxglob 283 284 ! indmin = indminglob 285 ! indmax = indmaxglob 286 224 287 member = .TRUE. 288 s_Parent_temp = s_Parent + (indminglob - pttab_Parent) * ds_Parent 289 225 290 #endif 291 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 292 ! Correct for non refined directions 293 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 294 do i=1,nbdim 295 if (coords(i) == 0) then 296 indmin(i) = indminglob(i) 297 indmax(i) = indmaxglob(i) 298 pttruetab(i) = indminglob(i) 299 cetruetab(i) = indmaxglob(i) 300 endif 301 enddo 226 302 227 303 else … … 231 307 s_Child_temp = s_Child + (pttruetab - pttab_Child) * ds_Child 232 308 #else 309 310 ! In the sequentiel case, the following lines ensure that the bounds needed on the parent grid in the interpolation 311 ! do not exceed lower and upper bounds of the parent array 312 313 ! output : lowerbound and upperbound are the (local) lower and upper bounds of the parent arrays 314 call Agrif_get_var_bounds_array(parent,lowerbound,upperbound,nbdim) 315 call Agrif_ChildGrid_to_ParentGrid() 316 317 ! input : indminglob,indmaxglob : global indexes where data are required for the interpolation 318 ! output : indminglob2,indmaxglob2 : global indexes restricted to the bounds of the current processor 319 ! output : member is false if the current processor does not need to send data 320 321 call Agrif_Childbounds(nbdim,lowerbound,upperbound, & 322 indminglob,indmaxglob, Agrif_Procrank, coords, & 323 indmin,indmax,member) 324 325 call Agrif_ParentGrid_to_ChildGrid() 326 327 indminglob = indmin 328 indmaxglob = indmax 329 233 330 parentarray(:,1,1) = indminglob 234 331 parentarray(:,2,1) = indmaxglob 235 332 parentarray(:,1,2) = indminglob 236 333 parentarray(:,2,2) = indmaxglob 237 indmin = indminglob238 indmax = indmaxglob334 ! indmin = indminglob 335 ! indmax = indmaxglob 239 336 member = .TRUE. 240 337 s_Parent_temp = s_Parent + (indminglob - pttab_Parent) * ds_Parent … … 246 343 if (.not.associated(tempP)) allocate(tempP) 247 344 ! 345 248 346 call Agrif_array_allocate(tempP,parentarray(:,1,1),parentarray(:,2,1),nbdim) 249 347 call Agrif_var_set_array_tozero(tempP,nbdim) … … 286 384 parentarray(6,1,2),parentarray(6,2,2),.TRUE.,nb,ndir) 287 385 end select 386 288 387 ! 289 388 call Agrif_ParentGrid_to_ChildGrid() … … 298 397 tab3(:,3) = indmin(:) 299 398 tab3(:,4) = indmax(:) 399 tab5(:,1) = indminglob3(:) 400 tab5(:,2) = indmaxglob3(:) 300 401 ! 301 402 call MPI_ALLGATHER(tab3,4*nbdim,MPI_INTEGER,tab4,4*nbdim,MPI_INTEGER,Agrif_mpi_comm,code) 302 403 call MPI_ALLGATHER(tab5,2*nbdim,MPI_INTEGER,tab6,2*nbdim,MPI_INTEGER,Agrif_mpi_comm,code) 303 404 if (.not.associated(tempPextend)) allocate(tempPextend) 304 405 … … 311 412 enddo 312 413 414 do k=0,Agrif_Nbprocs-1 415 do j=1,2 416 do i=1,nbdim 417 tab5t(i,k,j) = tab6(i,j,k) 418 enddo 419 enddo 420 enddo 421 313 422 memberin1(1) = memberin 314 423 call MPI_ALLGATHER(memberin1,1,MPI_LOGICAL,memberinall,1,MPI_LOGICAL,Agrif_mpi_comm,code) … … 319 428 sendtoproc1,recvfromproc1, & 320 429 tab4t(:,:,5),tab4t(:,:,6), & 321 tab4t(:,:,7),tab4t(:,:,8) ) 430 tab4t(:,:,7),tab4t(:,:,8), & 431 tab5t(:,:,1),tab5t(:,:,2)) 322 432 endif 323 433 … … 333 443 child%list_interp,pttab,petab, & 334 444 pttab_Child,pttab_Parent,indmin,indmax, & 445 indmin_required_p, indmax_required_p, & 335 446 indminglob,indmaxglob, & 336 447 pttruetab,cetruetab, & … … 345 456 endif 346 457 ! 458 347 459 if (memberin) then 348 460 ! 349 461 if (.not.associated(tempC)) allocate(tempC) 350 462 ! 463 351 464 call Agrif_array_allocate(tempC,pttruetab,cetruetab,nbdim) 465 352 466 ! 353 467 ! Special values on the parent grid … … 357 471 ! 358 472 if (.not.associated(parentvalues)) allocate(parentvalues) 359 ! 473 !t 474 360 475 call Agrif_array_allocate(parentvalues,indmin,indmax,nbdim) 361 476 call Agrif_var_full_copy_array(parentvalues,tempPextend,nbdim) 362 477 ! 363 call Agrif_CheckMasknD(tempPextend,parentvalues, & 364 indmin(1:nbdim),indmax(1:nbdim), & 365 indmin(1:nbdim),indmax(1:nbdim), & 478 call Agrif_CheckMasknD(tempPextend,parentvalues, & 479 indmin(1:nbdim),indmax(1:nbdim), & 480 indmin(1:nbdim),indmax(1:nbdim), & 481 indmin_required_p(1:nbdim),indmax_required_p(1:nbdim), & 366 482 noraftab(1:nbdim),nbdim) 367 483 ! … … 391 507 ds_Child(1:2), ds_Parent(1:2) ) 392 508 case(3) 393 call Agrif_Interp_3D_recursive( type_interp(1:3), & 394 tempPextend % array3, & 395 tempC % array3, & 396 indmin(1:3), indmax(1:3), & 397 pttruetab(1:3), cetruetab(1:3), & 398 s_Child_temp(1:3), s_Parent_temp(1:3), & 509 s_Parent_temp_p = s_Parent + (indmin_required_p - pttab_Parent) * ds_Parent 510 call Agrif_Interp_3D_recursive( type_interp(1:3), & 511 tempPextend % array3( & 512 indmin_required_p(1):indmax_required_p(1), & 513 indmin_required_p(2):indmax_required_p(2), & 514 indmin_required_p(3):indmax_required_p(3)), & 515 tempC % array3, & 516 indmin_required_p(1:3), indmax_required_p(1:3), & 517 pttruetab(1:3), cetruetab(1:3), & 518 s_Child_temp(1:3), s_Parent_temp_p(1:3), & 399 519 ds_Child(1:3), ds_Parent(1:3) ) 520 400 521 case(4) 401 call Agrif_Interp_4D_recursive( type_interp(1:4), & 402 tempPextend % array4, & 403 tempC % array4, & 404 indmin(1:4), indmax(1:4), & 405 pttruetab(1:4), cetruetab(1:4), & 406 s_Child_temp(1:4), s_Parent_temp(1:4), & 522 s_Parent_temp_p = s_Parent + (indmin_required_p - pttab_Parent) * ds_Parent 523 call Agrif_Interp_4D_recursive( type_interp(1:4), & 524 tempPextend % array4( & 525 indmin_required_p(1):indmax_required_p(1), & 526 indmin_required_p(2):indmax_required_p(2), & 527 indmin_required_p(3):indmax_required_p(3), & 528 indmin_required_p(4):indmax_required_p(4)), & 529 tempC % array4, & 530 indmin_required_p(1:4), indmax_required_p(1:4), & 531 pttruetab(1:4), cetruetab(1:4), & 532 s_Child_temp(1:4), s_Parent_temp_p(1:4), & 407 533 ds_Child(1:4), ds_Parent(1:4) ) 408 534 case(5) … … 595 721 else ! .not.to_restore 596 722 ! 723 597 724 if (memberin) then 598 725 ! … … 715 842 endif 716 843 844 717 845 call Agrif_array_deallocate(tempPextend,nbdim) 718 846 call Agrif_array_deallocate(tempC,nbdim) … … 736 864 !--------------------------------------------------------------------------------------------------- 737 865 subroutine Agrif_Parentbounds ( type_interp, nbdim, indmin, indmax, & 866 indmin_required,indmax_required, & 738 867 s_Parent_temp, s_Child_temp, & 739 868 s_Child, ds_Child, & … … 745 874 INTEGER, intent(in) :: nbdim 746 875 INTEGER, DIMENSION(nbdim), intent(out) :: indmin, indmax 747 REAL, DIMENSION(nbdim), intent(out) :: s_Parent_temp, s_child_temp 748 REAL, DIMENSION(nbdim), intent(in) :: s_Child, ds_child 749 REAL, DIMENSION(nbdim), intent(in) :: s_Parent,ds_Parent 876 INTEGER, DIMENSION(nbdim), intent(out) :: indmin_required, indmax_required 877 REAL(kind=8), DIMENSION(nbdim), intent(out) :: s_Parent_temp, s_child_temp 878 REAL(kind=8), DIMENSION(nbdim), intent(in) :: s_Child, ds_child 879 REAL(kind=8), DIMENSION(nbdim), intent(in) :: s_Parent,ds_Parent 750 880 INTEGER, DIMENSION(nbdim), intent(in) :: pttruetab, cetruetab 751 881 INTEGER, DIMENSION(nbdim), intent(in) :: pttab_Child, pttab_Parent … … 753 883 INTEGER, DIMENSION(nbdim), intent(in) :: coords 754 884 ! 885 REAL(kind=8) :: xpmin, xpmax 886 INTEGER :: coeffraf 755 887 INTEGER :: i 756 REAL ,DIMENSION(nbdim) :: dim_newmin, dim_newmax888 REAL(kind=8),DIMENSION(nbdim) :: dim_newmin, dim_newmax 757 889 ! 758 890 dim_newmin = s_Child + (pttruetab - pttab_Child) * ds_Child … … 763 895 indmin(i) = pttab_Parent(i) + agrif_int((dim_newmin(i)-s_Parent(i))/ds_Parent(i)) 764 896 indmax(i) = pttab_Parent(i) + agrif_ceiling((dim_newmax(i)-s_Parent(i))/ds_Parent(i)) 897 898 coeffraf = nint(ds_Parent(i)/ds_Child(i)) 899 900 indmin_required(i) = indmin(i) 901 indmax_required(i) = indmax(i) 765 902 ! 766 903 ! Necessary for the Quadratic interpolation 767 904 ! 905 768 906 if ( (pttruetab(i) == cetruetab(i)) .and. (posvar(i) == 1) ) then 907 if (Agrif_UseSpecialValue) then 908 indmin(i) = indmin(i)-MaxSearch 909 indmax(i) = indmax(i)+MaxSearch 910 endif 769 911 elseif ( coords(i) == 0 ) then ! (interptab == 'N') 770 912 elseif ( (type_interp(i) == Agrif_ppm) .or. & … … 772 914 (type_interp(i) == Agrif_ppm_lim) .or. & 773 915 (type_interp(i) == Agrif_weno) ) then 774 indmin(i) = indmin(i) - 2 775 indmax(i) = indmax(i) + 2 776 916 917 if ((mod(coeffraf,2) == 0).AND.(posvar(i)==2)) then 918 919 xpmax = s_Parent(i)+(indmax(i)-pttab_Parent(i))*ds_Parent(i) 920 if (xpmax > dim_newmax(i)+ds_Child(i)) then 921 indmax(i) = indmax(i) + 1 922 else 923 indmax(i) = indmax(i) + 2 924 endif 925 926 xpmin = s_Parent(i)+(indmin(i)-pttab_Parent(i))*ds_Parent(i) 927 if (xpmin < dim_newmin(i)-ds_Child(i)) then 928 indmin(i) = indmin(i) - 1 929 else 930 indmin(i) = indmin(i) - 2 931 endif 932 933 else 934 indmin(i) = indmin(i) - 2 935 indmax(i) = indmax(i) + 2 936 endif 937 938 indmin_required(i) = indmin(i) 939 indmax_required(i) = indmax(i) 940 777 941 if (Agrif_UseSpecialValue) then 778 942 indmin(i) = indmin(i)-MaxSearch 779 943 indmax(i) = indmax(i)+MaxSearch 780 944 endif 781 945 elseif (type_interp(i) == Agrif_linearconservlim) then 946 947 if ((mod(coeffraf,2) == 0).AND.(posvar(i)==2)) then 948 949 xpmax = s_Parent(i)+(indmax(i)-pttab_Parent(i))*ds_Parent(i) 950 if (xpmax > dim_newmax(i)+ds_Child(i)) then 951 indmax(i) = indmax(i) 952 else 953 indmax(i) = indmax(i) + 1 954 endif 955 956 xpmin = s_Parent(i)+(indmin(i)-pttab_Parent(i))*ds_Parent(i) 957 if (xpmin < dim_newmin(i)-ds_Child(i)) then 958 indmin(i) = indmin(i) 959 else 960 indmin(i) = indmin(i) - 1 961 endif 962 963 else 964 indmin(i) = indmin(i) - 1 965 indmax(i) = indmax(i) + 1 966 endif 967 968 indmin_required(i) = indmin(i) 969 indmax_required(i) = indmax(i) 970 971 if (Agrif_UseSpecialValue) then 972 indmin(i) = indmin(i)-MaxSearch 973 indmax(i) = indmax(i)+MaxSearch 974 endif 975 782 976 elseif ( (type_interp(i) /= Agrif_constant) .and. & 783 977 (type_interp(i) /= Agrif_linear) ) then 784 978 indmin(i) = indmin(i) - 1 785 979 indmax(i) = indmax(i) + 1 980 981 indmin_required(i) = indmin(i) 982 indmax_required(i) = indmax(i) 786 983 787 984 if (Agrif_UseSpecialValue) then … … 789 986 indmax(i) = indmax(i)+MaxSearch 790 987 endif 791 792 988 elseif ( (type_interp(i) == Agrif_constant) .or. & 793 989 (type_interp(i) == Agrif_linear) ) then 990 indmin_required(i) = indmin(i) 991 indmax_required(i) = indmax(i) 794 992 if (Agrif_UseSpecialValue) then 795 993 indmin(i) = indmin(i)-MaxSearch 796 994 indmax(i) = indmax(i)+MaxSearch 797 995 endif 798 799 996 endif 997 800 998 ! 801 999 enddo … … 822 1020 integer, intent(in) :: indmin, indmax 823 1021 integer, intent(in) :: pttab_child, petab_child 824 real , intent(in) :: s_child, s_parent825 real , intent(in) :: ds_child, ds_parent1022 real(kind=8), intent(in) :: s_child, s_parent 1023 real(kind=8), intent(in) :: ds_child, ds_parent 826 1024 real, dimension( & 827 1025 indmin:indmax & … … 857 1055 integer, dimension(2), intent(in) :: indmin, indmax 858 1056 integer, dimension(2), intent(in) :: pttab_child, petab_child 859 real , dimension(2), intent(in) :: s_child, s_parent860 real , dimension(2), intent(in) :: ds_child, ds_parent1057 real(kind=8), dimension(2), intent(in) :: s_child, s_parent 1058 real(kind=8), dimension(2), intent(in) :: ds_child, ds_parent 861 1059 real, dimension( & 862 1060 indmin(1):indmax(1), & … … 875 1073 indmin(2):indmax(2), & 876 1074 pttab_child(1):petab_child(1)) :: tabtemp_trsp 877 integer :: i, j, coeffraf 1075 integer :: i, j, coeffraf, locind_child_left, ideb 878 1076 !--------------------------------------------------------------------------------------------------- 879 1077 ! … … 900 1098 s_parent(1),s_child(1),ds_parent(1),ds_child(1),1) 901 1099 !---CDIR NEXPAND 902 call PPM1dAfterCompute(tabin,tabtemp,size(tabin),size(tabtemp),1) 1100 call PPM1dAfterCompute(tabin,tabtemp,size(tabin),size(tabtemp),1,indchildppm(:,1),tabppm(:,:,1)) 1101 else if (coeffraf == 1) then 1102 locind_child_left = indmin(1) + agrif_int((s_child(1)-s_parent(1))/ds_parent(1)) 1103 1104 do j = indmin(2), indmax(2) 1105 ideb = locind_child_left 1106 do i = pttab_child(1), petab_child(1) 1107 tabtemp(i,j) = tabin(ideb,j) 1108 ideb = ideb + 1 1109 enddo 1110 enddo 1111 903 1112 else 904 1113 do j = indmin(2),indmax(2) … … 941 1150 !---CDIR NEXPAND 942 1151 call PPM1dAfterCompute(tabtemp_trsp, tabout_trsp, & 943 size(tabtemp_trsp), size(tabout_trsp), 2) 1152 size(tabtemp_trsp), size(tabout_trsp), 2, & 1153 indchildppm(:,2),tabppm(:,:,2)) 944 1154 else 945 1155 do i = pttab_child(1), petab_child(1) … … 976 1186 integer, dimension(3), intent(in) :: indmin, indmax 977 1187 integer, dimension(3), intent(in) :: pttab_child, petab_child 978 real , dimension(3), intent(in) :: s_child, s_parent979 real , dimension(3), intent(in) :: ds_child, ds_parent1188 real(kind=8), dimension(3), intent(in) :: s_child, s_parent 1189 real(kind=8), dimension(3), intent(in) :: ds_child, ds_parent 980 1190 real, dimension( & 981 1191 indmin(1):indmax(1), & … … 991 1201 pttab_child(2):petab_child(2), & 992 1202 indmin(3):indmax(3)) :: tabtemp 993 integer :: i, j, k, coeffraf 1203 integer :: i, j, k, coeffraf,kp,kp1,kp2,kp3,kp4,kref 994 1204 integer :: locind_child_left, kdeb 1205 real(kind=8) :: ypos,globind_parent_left 1206 real(kind=8) :: deltax, invdsparent 1207 real :: t2,t3,t4,t5,t6,t7,t8 1208 integer :: locind_parent_left 1209 995 1210 ! 996 1211 coeffraf = nint ( ds_parent(1) / ds_child(1) ) … … 1051 1266 enddo 1052 1267 enddo 1268 else if (type_interp(3) == Agrif_LAGRANGE) then 1269 invdsparent = 1./ds_parent(3) 1270 ypos = s_child(3) 1271 do k=pttab_child(3), petab_child(3) 1272 locind_parent_left = indmin(3)+agrif_int((ypos - s_parent(3))/ds_parent(3)) 1273 globind_parent_left = s_parent(3) + (locind_parent_left - indmin(3))*ds_parent(3) 1274 deltax = invdsparent*(ypos-globind_parent_left) 1275 deltax = nint(coeffraf*deltax)/real(coeffraf) 1276 ypos = ypos + ds_child(3) 1277 1278 if (abs(deltax) <= 0.0001) then 1279 do j = pttab_child(2), petab_child(2) 1280 do i = pttab_child(1), petab_child(1) 1281 tabout(i,j,k) = tabtemp(i,j,locind_parent_left) 1282 enddo 1283 enddo 1284 else 1285 t2 = deltax - 2. 1286 t3 = deltax - 1. 1287 t4 = deltax + 1. 1288 1289 t5 = -(1./6.)*deltax*t2*t3 1290 t6 = 0.5*t2*t3*t4 1291 t7 = -0.5*deltax*t2*t4 1292 t8 = (1./6.)*deltax*t3*t4 1293 do j = pttab_child(2), petab_child(2) 1294 do i = pttab_child(1), petab_child(1) 1295 tabout(i,j,k) = t5*tabtemp(i,j,locind_parent_left-1) + t6*tabtemp(i,j,locind_parent_left) & 1296 +t7*tabtemp(i,j,locind_parent_left+1) + t8*tabtemp(i,j,locind_parent_left+2) 1297 enddo 1298 enddo 1299 1300 endif 1301 1302 enddo 1303 else if (type_interp(3) == Agrif_PPM) then 1304 call PPM1dPrecompute2d(1, & 1305 indmax(3)-indmin(3)+1, & 1306 petab_child(3)-pttab_child(3)+1, & 1307 s_parent(3),s_child(3),ds_parent(3),ds_child(3),1) 1308 1309 do k=pttab_child(3),petab_child(3) 1310 kref = k-pttab_child(3)+1 1311 kp=indmin(3)+indparentppm(kref,1)-1 1312 kp1 = kp + 1 1313 kp2 = kp1 + 1 1314 kp3 = kp2 + 1 1315 kp4 = kp3 + 1 1316 do j = pttab_child(2), petab_child(2) 1317 do i = pttab_child(1), petab_child(1) 1318 tabout(i,j,k) = tabppm(1,indchildppm(kref,1),1)*tabtemp(i,j,kp) + & 1319 tabppm(2,indchildppm(kref,1),1)*tabtemp(i,j,kp1) + & 1320 tabppm(3,indchildppm(kref,1),1)*tabtemp(i,j,kp2) + & 1321 tabppm(4,indchildppm(kref,1),1)*tabtemp(i,j,kp3) + & 1322 tabppm(5,indchildppm(kref,1),1)*tabtemp(i,j,kp4) 1323 enddo 1324 enddo 1325 enddo 1326 1053 1327 else 1328 1054 1329 do j = pttab_child(2), petab_child(2) 1055 1330 do i = pttab_child(1), petab_child(1) … … 1063 1338 enddo 1064 1339 enddo 1340 1065 1341 endif 1066 1342 !--------------------------------------------------------------------------------------------------- … … 1083 1359 integer, dimension(4), intent(in) :: indmin, indmax 1084 1360 integer, dimension(4), intent(in) :: pttab_child, petab_child 1085 real , dimension(4), intent(in) :: s_child, s_parent1086 real , dimension(4), intent(in) :: ds_child, ds_parent1361 real(kind=8), dimension(4), intent(in) :: s_child, s_parent 1362 real(kind=8), dimension(4), intent(in) :: ds_child, ds_parent 1087 1363 real, dimension( & 1088 1364 indmin(1):indmax(1), & … … 1102 1378 indmin(4):indmax(4)) :: tabtemp 1103 1379 integer :: i, j, k, l 1380 1381 real(kind=8) :: ypos,globind_parent_left 1382 real(kind=8) :: deltax, invdsparent 1383 real :: t2,t3,t4,t5,t6,t7,t8 1384 integer :: locind_parent_left, coeffraf 1104 1385 ! 1105 1386 do l = indmin(4), indmax(4) … … 1117 1398 enddo 1118 1399 ! 1400 if (type_interp(4) == Agrif_LAGRANGE) then 1401 coeffraf = nint(ds_parent(4)/ds_child(4)) 1402 invdsparent = 1./ds_parent(4) 1403 ypos = s_child(4) 1404 do l=pttab_child(4), petab_child(4) 1405 locind_parent_left = indmin(4)+agrif_int((ypos - s_parent(4))/ds_parent(4)) 1406 globind_parent_left = s_parent(4) + (locind_parent_left - indmin(4))*ds_parent(4) 1407 deltax = invdsparent*(ypos-globind_parent_left) 1408 deltax = nint(coeffraf*deltax)/real(coeffraf) 1409 ypos = ypos + ds_child(4) 1410 1411 if (abs(deltax) <= 0.0001) then 1412 do k = pttab_child(3), petab_child(3) 1413 do j = pttab_child(2), petab_child(2) 1414 do i = pttab_child(1), petab_child(1) 1415 tabout(i,j,k,l) = tabtemp(i,j,k,locind_parent_left) 1416 enddo 1417 enddo 1418 enddo 1419 else 1420 t2 = deltax - 2. 1421 t3 = deltax - 1. 1422 t4 = deltax + 1. 1423 1424 t5 = -(1./6.)*deltax*t2*t3 1425 t6 = 0.5*t2*t3*t4 1426 t7 = -0.5*deltax*t2*t4 1427 t8 = (1./6.)*deltax*t3*t4 1428 do k = pttab_child(3), petab_child(3) 1429 do j = pttab_child(2), petab_child(2) 1430 do i = pttab_child(1), petab_child(1) 1431 tabout(i,j,k,l) = t5*tabtemp(i,j,k,locind_parent_left-1) + t6*tabtemp(i,j,k,locind_parent_left) & 1432 +t7*tabtemp(i,j,k,locind_parent_left+1) + t8*tabtemp(i,j,k,locind_parent_left+2) 1433 enddo 1434 enddo 1435 enddo 1436 endif 1437 1438 enddo 1439 else 1119 1440 do k = pttab_child(3), petab_child(3) 1120 1441 do j = pttab_child(2), petab_child(2) … … 1130 1451 enddo 1131 1452 enddo 1453 endif 1132 1454 !--------------------------------------------------------------------------------------------------- 1133 1455 end subroutine Agrif_Interp_4D_recursive … … 1149 1471 integer, dimension(5), intent(in) :: indmin, indmax 1150 1472 integer, dimension(5), intent(in) :: pttab_child, petab_child 1151 real , dimension(5), intent(in) :: s_child, s_parent1152 real , dimension(5), intent(in) :: ds_child, ds_parent1473 real(kind=8), dimension(5), intent(in) :: s_child, s_parent 1474 real(kind=8), dimension(5), intent(in) :: ds_child, ds_parent 1153 1475 real, dimension( & 1154 1476 indmin(1):indmax(1), & … … 1222 1544 integer, dimension(6), intent(in) :: indmin, indmax 1223 1545 integer, dimension(6), intent(in) :: pttab_child, petab_child 1224 real , dimension(6), intent(in) :: s_child, s_parent1225 real , dimension(6), intent(in) :: ds_child, ds_parent1546 real(kind=8), dimension(6), intent(in) :: s_child, s_parent 1547 real(kind=8), dimension(6), intent(in) :: ds_child, ds_parent 1226 1548 real, dimension( & 1227 1549 indmin(1):indmax(1), & … … 1301 1623 REAL, DIMENSION(indmin:indmax), INTENT(IN) :: parenttab 1302 1624 REAL, DIMENSION(pttab_child:petab_child), INTENT(OUT) :: childtab 1303 REAL 1304 REAL 1625 REAL(kind=8) :: s_parent, s_child 1626 REAL(kind=8) :: ds_parent,ds_child 1305 1627 ! 1306 1628 if ( (indmin == indmax) .and. (pttab_child == petab_child) ) then … … 1371 1693 !--------------------------------------------------------------------------------------------------- 1372 1694 function Agrif_Find_list_interp ( list_interp, pttab, petab, pttab_Child, pttab_Parent, & 1373 nbdim, indmin, indmax, indminglob, indmaxglob, & 1695 nbdim, indmin, indmax, indmin_required_p, indmax_required_p, & 1696 indminglob, indmaxglob, & 1374 1697 pttruetab, cetruetab, memberin & 1375 1698 #if defined AGRIF_MPI … … 1382 1705 integer, intent(in) :: nbdim 1383 1706 integer, dimension(nbdim), intent(in) :: pttab, petab, pttab_Child, pttab_Parent 1384 integer, dimension(nbdim), intent(out) :: indmin, indmax 1707 integer, dimension(nbdim), intent(out) :: indmin, indmax, indmin_required_p, indmax_required_p 1385 1708 integer, dimension(nbdim), intent(out) :: indminglob, indmaxglob 1386 1709 integer, dimension(nbdim), intent(out) :: pttruetab, cetruetab … … 1421 1744 indmin = pil % indmin(1:nbdim) 1422 1745 indmax = pil % indmax(1:nbdim) 1746 indmin_required_p = pil % indmin_required_p(1:nbdim) 1747 indmax_required_p = pil % indmax_required_p(1:nbdim) 1423 1748 1424 1749 pttruetab = pil % pttruetab(1:nbdim) … … 1452 1777 !--------------------------------------------------------------------------------------------------- 1453 1778 subroutine Agrif_AddTo_list_interp ( list_interp, pttab, petab, pttab_Child, pttab_Parent, & 1454 indmin, indmax, indminglob, indmaxglob, & 1779 indmin, indmax, indmin_required_p, indmax_required_p, & 1780 indminglob, indmaxglob, & 1455 1781 pttruetab, cetruetab, & 1456 1782 memberin, nbdim & … … 1466 1792 integer :: nbdim 1467 1793 integer, dimension(nbdim) :: pttab, petab, pttab_Child, pttab_Parent 1468 integer, dimension(nbdim) :: indmin,indmax 1794 integer, dimension(nbdim) :: indmin,indmax, indmin_required_p, indmax_required_p 1469 1795 integer, dimension(nbdim) :: indminglob, indmaxglob 1470 1796 integer, dimension(nbdim) :: pttruetab, cetruetab … … 1495 1821 pil % indmin(1:nbdim) = indmin(1:nbdim) 1496 1822 pil % indmax(1:nbdim) = indmax(1:nbdim) 1823 1824 pil % indmin_required_p(1:nbdim) = indmin_required_p(1:nbdim) 1825 pil % indmax_required_p(1:nbdim) = indmax_required_p(1:nbdim) 1497 1826 1498 1827 pil % memberin = memberin
Note: See TracChangeset
for help on using the changeset viewer.